Skip to content

Commit b94e025

Browse files
update index.d.ts
1 parent cc996d3 commit b94e025

File tree

1 file changed

+30
-8
lines changed

1 file changed

+30
-8
lines changed

index.d.ts

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { ReactNode, FunctionComponent } from 'react';
1+
import React, { FunctionComponent } from 'react';
22
export type Callback = (instance: Instance) => void;
33
/**
44
* - ready function accepts a callback as its parameter and executes it as soon as Tabs get mounted.
@@ -8,12 +8,32 @@ export type Callback = (instance: Instance) => void;
88
* - ready function can be executed multiple times and its identity is stable and won’t change on re-renders.
99
*/
1010
export type Ready = (callback: Callback) => void;
11+
export interface TabProps {
12+
'tab-id': string;
13+
className: string;
14+
title: string;
15+
tabIndex: number;
16+
id?: string;
17+
role?: string;
18+
}
19+
export interface IconProps {
20+
className: string;
21+
role: string;
22+
}
23+
export interface TabComponentProps {
24+
id: string;
25+
isSelected: boolean;
26+
api: Instance;
27+
tabProps: TabProps;
28+
iconProps?: IconProps;
29+
}
1130
export interface Options {
1231
/** * default value is "ltr"*/
1332
direction?: 'rtl' | 'ltr';
14-
defaultPanelComponent?: () => ReactNode | null;
15-
tabComponent?: (props: any) => ReactNode;
16-
selectedTabID?: string; tabs?: Array<TabData>;
33+
defaultPanelComponent?: () => FunctionComponent<{ id: string, isSelected: boolean, api: Instance }> | null;
34+
tabComponent?: FunctionComponent<TabComponentProps>;
35+
selectedTabID?: string;
36+
tabs?: Array<TabData>;
1737
/** * default value is true */
1838
accessibility?: boolean;
1939
/** * default value is false */
@@ -22,12 +42,14 @@ export interface Options {
2242
onInit?: () => void;
2343
onChange?: ({ currentData, previousData, closedTabIDs, openedTabIDs }: { currentData: any, previousData: any, closedTabIDs: Array<string>, openedTabIDs: Array<string> }) => void;
2444
/** * defautl value function returns true */
25-
beforeSelect?: (e: React.MouseEvent<HTMLInputElement>, id: string) => boolean; onFirstSelect?: ({ currentSelectedTabId, previousSelectedTabId }: { currentSelectedTabId: string, previousSelectedTabId: string }) => void;
45+
beforeSelect?: (e: React.MouseEvent<HTMLElement>, id: string) => boolean;
46+
onFirstSelect?: ({ currentSelectedTabId, previousSelectedTabId }: { currentSelectedTabId: string, previousSelectedTabId: string }) => void;
2647
onSelect?: ({ currentSelectedTabId, previousSelectedTabId }: { currentSelectedTabId: string, previousSelectedTabId: string }) => void;
2748
onOpen?: (openedTabIDs: Array<string>) => void;
2849
/** * defautl value function returns true */
29-
beforeClose?: (e: React.MouseEvent<HTMLInputElement>, id: string) => boolean;
30-
onClose?: (closedTabIDs: Array<string>) => void; onDestroy?: () => void;
50+
beforeClose?: (e: React.MouseEvent<HTMLElement>, id: string) => boolean;
51+
onClose?: (closedTabIDs: Array<string>) => void;
52+
onDestroy?: () => void;
3153
}
3254
export interface TabData {
3355
id?: string;
@@ -40,7 +62,7 @@ export interface TabData {
4062
iconClass?: string;
4163
/** * default value is false */
4264
disable?: boolean;
43-
panelComponent?: React.ReactNode | React.ReactElement | React.FunctionComponent;
65+
panelComponent?: React.ReactElement<any, any> | FunctionComponent<{ id: string, isSelected: boolean, api: Instance }> | null;
4466
[x: string]: unknown;
4567
}
4668
export interface CurrentData {

0 commit comments

Comments
 (0)