1- import React , { FunctionComponent } from 'react' ;
1+ import React , { FunctionComponent , FC , PropsWithChildren } from 'react' ;
22export type Callback = ( instance : Instance ) => void ;
33/**
44 * - ready function accepts a callback as its parameter and executes it as soon as Tabs get mounted.
@@ -26,30 +26,36 @@ export interface TabComponentProps {
2626 api : Instance ;
2727 tabProps : TabProps ;
2828 iconProps ?: IconProps ;
29+ children : React . ReactNode ;
30+ }
31+ export interface PanelProps {
32+ id : string ;
33+ isSelected : boolean ;
34+ api : Instance ;
2935}
3036export interface Options {
3137 /** * default value is "ltr"*/
3238 direction ?: 'rtl' | 'ltr' ;
33- defaultPanelComponent ?: ( ) => FunctionComponent < { id : string , isSelected : boolean , api : Instance } > | null ;
34- tabComponent ?: FunctionComponent < TabComponentProps > ;
39+ defaultPanelComponent ?: React . ReactElement < any , any > | FunctionComponent < PanelProps > | React . ComponentClass < PanelProps > ;
40+ tabComponent ?: React . ComponentClass < TabComponentProps > | ( ( props : TabComponentProps ) => JSX . Element ) ;
3541 selectedTabID ?: string ;
3642 tabs ?: Array < TabData > ;
3743 /** * default value is true */
3844 accessibility ?: boolean ;
3945 /** * default value is false */
4046 isVertical ?: boolean ;
41- onLoad ?: ( ) => void ;
42- onInit ?: ( ) => void ;
43- onChange ?: ( { currentData, previousData, closedTabIDs, openedTabIDs } : { currentData : any , previousData : any , closedTabIDs : Array < string > , openedTabIDs : Array < string > } ) => void ;
47+ onLoad ?( this : Instance ) : void ;
48+ onInit ?( this : Instance ) : void ;
49+ onChange ?( this : Instance , { currentData, previousData, closedTabIDs, openedTabIDs } : { currentData : CurrentData , previousData : CurrentData , closedTabIDs : Array < string > , openedTabIDs : Array < string > } ) : void ;
4450 /** * defautl value function returns true */
45- beforeSelect ?: ( e : React . MouseEvent < HTMLElement > , id : string ) => boolean ;
46- onFirstSelect ?: ( { currentSelectedTabId, previousSelectedTabId } : { currentSelectedTabId : string , previousSelectedTabId : string } ) => void ;
47- onSelect ?: ( { currentSelectedTabId, previousSelectedTabId } : { currentSelectedTabId : string , previousSelectedTabId : string } ) => void ;
48- onOpen ?: ( openedTabIDs : Array < string > ) => void ;
51+ beforeSelect ?( this : Instance , e : React . MouseEvent < HTMLElement > , id : string ) : boolean ;
52+ onFirstSelect ?( this : Instance , { currentSelectedTabId, previousSelectedTabId } : { currentSelectedTabId : string , previousSelectedTabId : string } ) : void ;
53+ onSelect ?( this : Instance , { currentSelectedTabId, previousSelectedTabId } : { currentSelectedTabId : string , previousSelectedTabId : string } ) : void ;
54+ onOpen ?( this : Instance , openedTabIDs : Array < string > ) : void ;
4955 /** * defautl value function returns true */
50- beforeClose ?: ( e : React . MouseEvent < HTMLElement > , id : string ) => boolean ;
51- onClose ?: ( closedTabIDs : Array < string > ) => void ;
52- onDestroy ?: ( ) => void ;
56+ beforeClose ?( this : Instance , e : React . MouseEvent < HTMLElement > , id : string ) : boolean ;
57+ onClose ?( this : Instance , closedTabIDs : Array < string > ) : void ;
58+ onDestroy ?( ) : void ;
5359}
5460export interface TabData {
5561 id ?: string ;
@@ -62,37 +68,35 @@ export interface TabData {
6268 iconClass ?: string ;
6369 /** * default value is false */
6470 disable ?: boolean ;
65- panelComponent ?: React . ReactElement < any , any > | FunctionComponent < { id : string , isSelected : boolean , api : Instance } > | null ;
66- [ x : string ] : unknown ;
71+ panelComponent ?: React . ReactElement < any , any > | FunctionComponent < PanelProps > | React . ComponentClass < PanelProps > | null ;
72+ [ x : string ] : any ;
6773}
6874export interface CurrentData {
6975 openTabIDs : Array < string > ;
7076 selectedTabID : string ;
7177}
7278export interface Instance {
73- isOpen : ( tabID : string ) => boolean ;
74- open : ( tabData : TabData ) => Promise < { currentData : CurrentData , instance : Instance } > ;
75- isSelected : ( tabID : string ) => boolean ;
76- select : ( tabID : string ) => Promise < { currentData : CurrentData , instance : Instance } > ;
79+ isOpen ( tabID : string ) : boolean ;
80+ open ( tabData : TabData ) : Promise < { currentData : CurrentData , instance : Instance } > ;
81+ isSelected ( tabID : string ) : boolean ;
82+ select ( tabID : string ) : Promise < { currentData : CurrentData , instance : Instance } > ;
7783 /**
7884 * - When switching parameter is true, it switches to previous selected tab
7985 */
80- close : ( tabID : string , switching ?: boolean ) => Promise < { currentData : CurrentData , instance : Instance } > ;
81- refresh : ( ) => Promise < { currentData : CurrentData , instance : Instance } > ;
82- getOption : ( optionName : string ) => any ;
83- setOption : ( optionName : string , optionValue : any ) => Instance ;
84- getTab : ( tabID : string ) => TabData ;
85- setTab : ( tabID : string , sourceObject : TabData ) => Instance ;
86- on : ( eventName : string , handler : Function ) => Instance ;
87- one : ( eventName : string , handler : Function ) => Instance ;
88- off : ( eventName : string , handler : Function ) => Instance ;
89- getData : ( ) => TabData ;
90- getPreviousData : ( ) => TabData ;
91- sort : ( tabIDs : Array < string > ) => Promise < { currentData : CurrentData , instance : Instance } > ;
86+ close ( tabID : string , switching ?: boolean ) : Promise < { currentData : CurrentData , instance : Instance } > ;
87+ refresh ( ) : Promise < { currentData : CurrentData , instance : Instance } > ;
88+ getOption ( optionName : string ) : any ;
89+ setOption ( optionName : string , optionValue : any ) : Instance ;
90+ getTab ( tabID : string ) : TabData ;
91+ setTab ( tabID : string , sourceObject : TabData ) : Instance ;
92+ on ( eventName : string , handler : Function ) : Instance ;
93+ one ( eventName : string , handler : Function ) : Instance ;
94+ off ( eventName : string , handler : Function ) : Instance ;
95+ getData ( ) : CurrentData ;
96+ getPreviousData ( ) : CurrentData ;
97+ sort ( tabIDs : Array < string > ) : Promise < { currentData : CurrentData , instance : Instance } > ;
9298}
93- type Tablist = FunctionComponent < { } > ;
99+ type Tablist = FC < PropsWithChildren < { } > > ;
94100type Panellist = FunctionComponent < { } > ;
95- export const TabList : Tablist ;
96- export const PanelList : Panellist ;
97101declare const useDynTabs : ( options ?: Options ) => [ Tablist , Panellist , Ready ] ;
98102export default useDynTabs ;
0 commit comments