@fluentui/react-tabs 0.0.0-nightly2170ed575f20220223.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.json +128 -0
- package/CHANGELOG.md +44 -0
- package/LICENSE +15 -0
- package/README.md +5 -0
- package/Spec.md +433 -0
- package/dist/react-tabs.d.ts +231 -0
- package/lib/Tab.d.ts +1 -0
- package/lib/Tab.js +2 -0
- package/lib/Tab.js.map +1 -0
- package/lib/TabList.d.ts +1 -0
- package/lib/TabList.js +2 -0
- package/lib/TabList.js.map +1 -0
- package/lib/components/Tab/Tab.d.ts +6 -0
- package/lib/components/Tab/Tab.js +15 -0
- package/lib/components/Tab/Tab.js.map +1 -0
- package/lib/components/Tab/Tab.types.d.ts +52 -0
- package/lib/components/Tab/Tab.types.js +2 -0
- package/lib/components/Tab/Tab.types.js.map +1 -0
- package/lib/components/Tab/index.d.ts +5 -0
- package/lib/components/Tab/index.js +6 -0
- package/lib/components/Tab/index.js.map +1 -0
- package/lib/components/Tab/renderTab.d.ts +5 -0
- package/lib/components/Tab/renderTab.js +18 -0
- package/lib/components/Tab/renderTab.js.map +1 -0
- package/lib/components/Tab/useTab.d.ts +12 -0
- package/lib/components/Tab/useTab.js +82 -0
- package/lib/components/Tab/useTab.js.map +1 -0
- package/lib/components/Tab/useTabStyles.d.ts +6 -0
- package/lib/components/Tab/useTabStyles.js +205 -0
- package/lib/components/Tab/useTabStyles.js.map +1 -0
- package/lib/components/TabList/TabList.d.ts +6 -0
- package/lib/components/TabList/TabList.js +17 -0
- package/lib/components/TabList/TabList.js.map +1 -0
- package/lib/components/TabList/TabList.types.d.ts +99 -0
- package/lib/components/TabList/TabList.types.js +2 -0
- package/lib/components/TabList/TabList.types.js.map +1 -0
- package/lib/components/TabList/TabListContext.d.ts +3 -0
- package/lib/components/TabList/TabListContext.js +17 -0
- package/lib/components/TabList/TabListContext.js.map +1 -0
- package/lib/components/TabList/index.d.ts +5 -0
- package/lib/components/TabList/index.js +6 -0
- package/lib/components/TabList/index.js.map +1 -0
- package/lib/components/TabList/renderTabList.d.ts +5 -0
- package/lib/components/TabList/renderTabList.js +19 -0
- package/lib/components/TabList/renderTabList.js.map +1 -0
- package/lib/components/TabList/useTabList.d.ts +12 -0
- package/lib/components/TabList/useTabList.js +106 -0
- package/lib/components/TabList/useTabList.js.map +1 -0
- package/lib/components/TabList/useTabListContextValues.d.ts +2 -0
- package/lib/components/TabList/useTabListContextValues.js +24 -0
- package/lib/components/TabList/useTabListContextValues.js.map +1 -0
- package/lib/components/TabList/useTabListStyles.d.ts +9 -0
- package/lib/components/TabList/useTabListStyles.js +118 -0
- package/lib/components/TabList/useTabListStyles.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/tab.constants.d.ts +15 -0
- package/lib/tab.constants.js +17 -0
- package/lib/tab.constants.js.map +1 -0
- package/lib/tsdoc-metadata.json +11 -0
- package/lib-commonjs/Tab.d.ts +1 -0
- package/lib-commonjs/Tab.js +10 -0
- package/lib-commonjs/Tab.js.map +1 -0
- package/lib-commonjs/TabList.d.ts +1 -0
- package/lib-commonjs/TabList.js +10 -0
- package/lib-commonjs/TabList.js.map +1 -0
- package/lib-commonjs/components/Tab/Tab.d.ts +6 -0
- package/lib-commonjs/components/Tab/Tab.js +26 -0
- package/lib-commonjs/components/Tab/Tab.js.map +1 -0
- package/lib-commonjs/components/Tab/Tab.types.d.ts +52 -0
- package/lib-commonjs/components/Tab/Tab.types.js +6 -0
- package/lib-commonjs/components/Tab/Tab.types.js.map +1 -0
- package/lib-commonjs/components/Tab/index.d.ts +5 -0
- package/lib-commonjs/components/Tab/index.js +18 -0
- package/lib-commonjs/components/Tab/index.js.map +1 -0
- package/lib-commonjs/components/Tab/renderTab.d.ts +5 -0
- package/lib-commonjs/components/Tab/renderTab.js +29 -0
- package/lib-commonjs/components/Tab/renderTab.js.map +1 -0
- package/lib-commonjs/components/Tab/useTab.d.ts +12 -0
- package/lib-commonjs/components/Tab/useTab.js +95 -0
- package/lib-commonjs/components/Tab/useTab.js.map +1 -0
- package/lib-commonjs/components/Tab/useTabStyles.d.ts +6 -0
- package/lib-commonjs/components/Tab/useTabStyles.js +218 -0
- package/lib-commonjs/components/Tab/useTabStyles.js.map +1 -0
- package/lib-commonjs/components/TabList/TabList.d.ts +6 -0
- package/lib-commonjs/components/TabList/TabList.js +29 -0
- package/lib-commonjs/components/TabList/TabList.js.map +1 -0
- package/lib-commonjs/components/TabList/TabList.types.d.ts +99 -0
- package/lib-commonjs/components/TabList/TabList.types.js +6 -0
- package/lib-commonjs/components/TabList/TabList.types.js.map +1 -0
- package/lib-commonjs/components/TabList/TabListContext.d.ts +3 -0
- package/lib-commonjs/components/TabList/TabListContext.js +25 -0
- package/lib-commonjs/components/TabList/TabListContext.js.map +1 -0
- package/lib-commonjs/components/TabList/index.d.ts +5 -0
- package/lib-commonjs/components/TabList/index.js +18 -0
- package/lib-commonjs/components/TabList/index.js.map +1 -0
- package/lib-commonjs/components/TabList/renderTabList.d.ts +5 -0
- package/lib-commonjs/components/TabList/renderTabList.js +31 -0
- package/lib-commonjs/components/TabList/renderTabList.js.map +1 -0
- package/lib-commonjs/components/TabList/useTabList.d.ts +12 -0
- package/lib-commonjs/components/TabList/useTabList.js +118 -0
- package/lib-commonjs/components/TabList/useTabList.js.map +1 -0
- package/lib-commonjs/components/TabList/useTabListContextValues.d.ts +2 -0
- package/lib-commonjs/components/TabList/useTabListContextValues.js +33 -0
- package/lib-commonjs/components/TabList/useTabListContextValues.js.map +1 -0
- package/lib-commonjs/components/TabList/useTabListStyles.d.ts +9 -0
- package/lib-commonjs/components/TabList/useTabListStyles.js +131 -0
- package/lib-commonjs/components/TabList/useTabListStyles.js.map +1 -0
- package/lib-commonjs/index.d.ts +2 -0
- package/lib-commonjs/index.js +12 -0
- package/lib-commonjs/index.js.map +1 -0
- package/lib-commonjs/tab.constants.d.ts +15 -0
- package/lib-commonjs/tab.constants.js +23 -0
- package/lib-commonjs/tab.constants.js.map +1 -0
- package/package.json +64 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import type { ComponentProps } from '@fluentui/react-utilities';
|
|
2
|
+
import type { ComponentState } from '@fluentui/react-utilities';
|
|
3
|
+
import type { ForwardRefComponent } from '@fluentui/react-utilities';
|
|
4
|
+
import * as React_2 from 'react';
|
|
5
|
+
import type { Slot } from '@fluentui/react-utilities';
|
|
6
|
+
|
|
7
|
+
export declare const indicatorLengthVar = "--selection-indicator-length";
|
|
8
|
+
|
|
9
|
+
export declare const indicatorOffsetVar = "--selection-indicator-offset";
|
|
10
|
+
|
|
11
|
+
export declare type RegisterTabData = {
|
|
12
|
+
/**
|
|
13
|
+
* The value of the selected tab.
|
|
14
|
+
*/
|
|
15
|
+
value: TabValue;
|
|
16
|
+
ref: React_2.RefObject<HTMLElement>;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export declare type RegisterTabEventHandler = (data: RegisterTabData) => void;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Render the final JSX of Tab
|
|
23
|
+
*/
|
|
24
|
+
export declare const renderTab_unstable: (state: TabState) => JSX.Element;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Render the final JSX of TabList
|
|
28
|
+
*/
|
|
29
|
+
export declare const renderTabList_unstable: (state: TabListState, contextValues: TabListContextValues) => JSX.Element;
|
|
30
|
+
|
|
31
|
+
export declare type SelectTabData = {
|
|
32
|
+
/**
|
|
33
|
+
* The value of the selected tab.
|
|
34
|
+
*/
|
|
35
|
+
value: TabValue;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export declare type SelectTabEvent<E = HTMLElement> = React_2.MouseEvent<E> | React_2.KeyboardEvent<E>;
|
|
39
|
+
|
|
40
|
+
export declare type SelectTabEventHandler = (event: SelectTabEvent, data: SelectTabData) => void;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A tab provides a selectable item in a tab list.
|
|
44
|
+
*/
|
|
45
|
+
export declare const Tab: ForwardRefComponent<TabProps>;
|
|
46
|
+
|
|
47
|
+
export declare const tabClassName = "fui-Tab";
|
|
48
|
+
|
|
49
|
+
declare type TabCommons = {
|
|
50
|
+
/**
|
|
51
|
+
* The value that identifies this tab when selected.
|
|
52
|
+
*/
|
|
53
|
+
value: TabValue;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A bounding rectangle of a tab
|
|
58
|
+
*/
|
|
59
|
+
export declare type TabContentRect = {
|
|
60
|
+
x: number;
|
|
61
|
+
y: number;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* A tab list provides single selection from a set of tabs.
|
|
68
|
+
*/
|
|
69
|
+
export declare const TabList: ForwardRefComponent<TabListProps>;
|
|
70
|
+
|
|
71
|
+
export declare const tabListClassName = "fui-TabList";
|
|
72
|
+
|
|
73
|
+
declare type TabListCommons = {
|
|
74
|
+
/**
|
|
75
|
+
* A tab list can supports 'transparent' and 'subtle' appearance.
|
|
76
|
+
*- 'subtle': Minimizes emphasis to blend into the background until hovered or focused.
|
|
77
|
+
*- 'transparent': No background and border styling
|
|
78
|
+
* The appearance affects each of the contained tabs.
|
|
79
|
+
* @default 'transparent'
|
|
80
|
+
*/
|
|
81
|
+
appearance?: 'transparent' | 'subtle';
|
|
82
|
+
/**
|
|
83
|
+
* Raised when a tab is selected.
|
|
84
|
+
*/
|
|
85
|
+
onTabSelect?: SelectTabEventHandler;
|
|
86
|
+
/**
|
|
87
|
+
* The value of the currently selected tab.
|
|
88
|
+
*/
|
|
89
|
+
selectedValue?: TabValue;
|
|
90
|
+
/**
|
|
91
|
+
* A tab list can be either 'small' or 'medium' size.
|
|
92
|
+
* The size affects each of the contained tabs.
|
|
93
|
+
* @default 'medium'
|
|
94
|
+
*/
|
|
95
|
+
size?: 'small' | 'medium';
|
|
96
|
+
/**
|
|
97
|
+
* A tab list can arrange its tabs vertically.
|
|
98
|
+
* @default false
|
|
99
|
+
*/
|
|
100
|
+
vertical?: boolean;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export declare type TabListContextValue = Pick<TabListCommons, 'onTabSelect' | 'selectedValue'> & Required<Pick<TabListCommons, 'appearance' | 'size' | 'vertical'>> & {
|
|
104
|
+
/** A callback to allow a tab to register itself with the tab list. */
|
|
105
|
+
onRegister: RegisterTabEventHandler;
|
|
106
|
+
/** A callback to allow a tab to unregister itself with the tab list. */
|
|
107
|
+
onUnregister: RegisterTabEventHandler;
|
|
108
|
+
/**
|
|
109
|
+
* A callback to allow a tab to select itself when pressed.
|
|
110
|
+
*/
|
|
111
|
+
onSelect: SelectTabEventHandler;
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Context values used in rendering TabList.
|
|
116
|
+
*/
|
|
117
|
+
export declare type TabListContextValues = {
|
|
118
|
+
/**
|
|
119
|
+
* The context of the tab list available to each tab.
|
|
120
|
+
*/
|
|
121
|
+
tabList: TabListContextValue;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* TabList Props
|
|
126
|
+
*/
|
|
127
|
+
export declare type TabListProps = ComponentProps<TabListSlots> & TabListCommons & {
|
|
128
|
+
/**
|
|
129
|
+
* The value of the tab to be selected by default.
|
|
130
|
+
* Typically useful when the selectedValue is uncontrolled.
|
|
131
|
+
*/
|
|
132
|
+
defaultSelectedValue?: TabValue;
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
export declare const tabListSelectionIndicatorName = "fui-TabList_SelectionIndicator";
|
|
136
|
+
|
|
137
|
+
export declare type TabListSlots = {
|
|
138
|
+
/**
|
|
139
|
+
* The slot associated with the root element of this tab list.
|
|
140
|
+
*/
|
|
141
|
+
root: Slot<'div'>;
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* State used in rendering TabList.
|
|
146
|
+
*/
|
|
147
|
+
export declare type TabListState = ComponentState<Required<TabListSlots>> & TabListContextValue & {
|
|
148
|
+
selectedTabRect?: TabContentRect;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Tab Props
|
|
153
|
+
*/
|
|
154
|
+
export declare type TabProps = ComponentProps<Partial<TabSlots>> & TabCommons;
|
|
155
|
+
|
|
156
|
+
export declare type TabSlots = {
|
|
157
|
+
/**
|
|
158
|
+
* Root of the component.
|
|
159
|
+
*/
|
|
160
|
+
root: Slot<'div'>;
|
|
161
|
+
/**
|
|
162
|
+
* Icon that renders before the content.
|
|
163
|
+
*/
|
|
164
|
+
icon?: Slot<'span'>;
|
|
165
|
+
/**
|
|
166
|
+
* Component children are placed in this slot
|
|
167
|
+
* Avoid using the `children` property in this slot in favour of Component children whenever possible.
|
|
168
|
+
*/
|
|
169
|
+
content: NonNullable<Slot<'span'>>;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* State used in rendering Tab
|
|
174
|
+
*/
|
|
175
|
+
export declare type TabState = ComponentState<TabSlots> & TabCommons & {
|
|
176
|
+
/**
|
|
177
|
+
* A tab supports 'transparent' and 'subtle' appearance.
|
|
178
|
+
*/
|
|
179
|
+
appearance?: string;
|
|
180
|
+
/**
|
|
181
|
+
* If this tab is selected.
|
|
182
|
+
*/
|
|
183
|
+
selected?: boolean;
|
|
184
|
+
/**
|
|
185
|
+
* A tab can be either 'small' or 'medium' size.
|
|
186
|
+
*/
|
|
187
|
+
size: 'small' | 'medium';
|
|
188
|
+
/**
|
|
189
|
+
* A tab can arrange its content based on if the tabs in the list are arranged vertically.
|
|
190
|
+
*/
|
|
191
|
+
vertical: boolean;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Any value that identifies a specific tab.
|
|
196
|
+
*/
|
|
197
|
+
export declare type TabValue = unknown;
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Create the state required to render Tab.
|
|
201
|
+
*
|
|
202
|
+
* The returned state can be modified with hooks such as useTabStyles_unstable,
|
|
203
|
+
* before being passed to renderTab_unstable.
|
|
204
|
+
*
|
|
205
|
+
* @param props - props from this instance of Tab
|
|
206
|
+
* @param ref - reference to root HTMLElement of Tab
|
|
207
|
+
*/
|
|
208
|
+
export declare const useTab_unstable: (props: TabProps, ref: React_2.Ref<HTMLElement>) => TabState;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Create the state required to render TabList.
|
|
212
|
+
*
|
|
213
|
+
* The returned state can be modified with hooks such as useTabListStyles_unstable,
|
|
214
|
+
* before being passed to renderTabList_unstable.
|
|
215
|
+
*
|
|
216
|
+
* @param props - props from this instance of TabList
|
|
217
|
+
* @param ref - reference to root HTMLElement of TabList
|
|
218
|
+
*/
|
|
219
|
+
export declare const useTabList_unstable: (props: TabListProps, ref: React_2.Ref<HTMLElement>) => TabListState;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* Apply styling to the TabList slots based on the state
|
|
223
|
+
*/
|
|
224
|
+
export declare const useTabListStyles_unstable: (state: TabListState) => TabListState;
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* Apply styling to the Tab slots based on the state
|
|
228
|
+
*/
|
|
229
|
+
export declare const useTabStyles_unstable: (state: TabState) => TabState;
|
|
230
|
+
|
|
231
|
+
export { }
|
package/lib/Tab.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/Tab/index';
|
package/lib/Tab.js
ADDED
package/lib/Tab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab.js","sourceRoot":"../src/","sources":["Tab.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC","sourcesContent":["export * from './components/Tab/index';\n"]}
|
package/lib/TabList.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/TabList/index';
|
package/lib/TabList.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TabList.js","sourceRoot":"../src/","sources":["TabList.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC","sourcesContent":["export * from './components/TabList/index';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useTab_unstable } from './useTab';
|
|
3
|
+
import { renderTab_unstable } from './renderTab';
|
|
4
|
+
import { useTabStyles_unstable } from './useTabStyles';
|
|
5
|
+
/**
|
|
6
|
+
* A tab provides a selectable item in a tab list.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export const Tab = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
10
|
+
const state = useTab_unstable(props, ref);
|
|
11
|
+
useTabStyles_unstable(state);
|
|
12
|
+
return renderTab_unstable(state);
|
|
13
|
+
});
|
|
14
|
+
Tab.displayName = 'Tab';
|
|
15
|
+
//# sourceMappingURL=Tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/Tab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,eAAT,QAAgC,UAAhC;AACA,SAAS,kBAAT,QAAmC,aAAnC;AACA,SAAS,qBAAT,QAAsC,gBAAtC;AAIA;;AAEG;;AACH,OAAO,MAAM,GAAG,gBAAkC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAChF,QAAM,KAAK,GAAG,eAAe,CAAC,KAAD,EAAQ,GAAR,CAA7B;AAEA,EAAA,qBAAqB,CAAC,KAAD,CAArB;AACA,SAAO,kBAAkB,CAAC,KAAD,CAAzB;AACD,CALiD,CAA3C;AAOP,GAAG,CAAC,WAAJ,GAAkB,KAAlB","sourcesContent":["import * as React from 'react';\nimport { useTab_unstable } from './useTab';\nimport { renderTab_unstable } from './renderTab';\nimport { useTabStyles_unstable } from './useTabStyles';\nimport type { TabProps } from './Tab.types';\nimport type { ForwardRefComponent } from '@fluentui/react-utilities';\n\n/**\n * A tab provides a selectable item in a tab list.\n */\nexport const Tab: ForwardRefComponent<TabProps> = React.forwardRef((props, ref) => {\n const state = useTab_unstable(props, ref);\n\n useTabStyles_unstable(state);\n return renderTab_unstable(state);\n});\n\nTab.displayName = 'Tab';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';
|
|
2
|
+
/**
|
|
3
|
+
* Any value that identifies a specific tab.
|
|
4
|
+
*/
|
|
5
|
+
export declare type TabValue = unknown;
|
|
6
|
+
export declare type TabSlots = {
|
|
7
|
+
/**
|
|
8
|
+
* Root of the component.
|
|
9
|
+
*/
|
|
10
|
+
root: Slot<'div'>;
|
|
11
|
+
/**
|
|
12
|
+
* Icon that renders before the content.
|
|
13
|
+
*/
|
|
14
|
+
icon?: Slot<'span'>;
|
|
15
|
+
/**
|
|
16
|
+
* Component children are placed in this slot
|
|
17
|
+
* Avoid using the `children` property in this slot in favour of Component children whenever possible.
|
|
18
|
+
*/
|
|
19
|
+
content: NonNullable<Slot<'span'>>;
|
|
20
|
+
};
|
|
21
|
+
declare type TabCommons = {
|
|
22
|
+
/**
|
|
23
|
+
* The value that identifies this tab when selected.
|
|
24
|
+
*/
|
|
25
|
+
value: TabValue;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Tab Props
|
|
29
|
+
*/
|
|
30
|
+
export declare type TabProps = ComponentProps<Partial<TabSlots>> & TabCommons;
|
|
31
|
+
/**
|
|
32
|
+
* State used in rendering Tab
|
|
33
|
+
*/
|
|
34
|
+
export declare type TabState = ComponentState<TabSlots> & TabCommons & {
|
|
35
|
+
/**
|
|
36
|
+
* A tab supports 'transparent' and 'subtle' appearance.
|
|
37
|
+
*/
|
|
38
|
+
appearance?: string;
|
|
39
|
+
/**
|
|
40
|
+
* If this tab is selected.
|
|
41
|
+
*/
|
|
42
|
+
selected?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* A tab can be either 'small' or 'medium' size.
|
|
45
|
+
*/
|
|
46
|
+
size: 'small' | 'medium';
|
|
47
|
+
/**
|
|
48
|
+
* A tab can arrange its content based on if the tabs in the list are arranged vertically.
|
|
49
|
+
*/
|
|
50
|
+
vertical: boolean;
|
|
51
|
+
};
|
|
52
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tab.types.js","sourceRoot":"../src/","sources":["components/Tab/Tab.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\n\n/**\n * Any value that identifies a specific tab.\n */\nexport type TabValue = unknown;\n\nexport type TabSlots = {\n /**\n * Root of the component.\n */\n root: Slot<'div'>;\n\n /**\n * Icon that renders before the content.\n */\n icon?: Slot<'span'>;\n\n /**\n * Component children are placed in this slot\n * Avoid using the `children` property in this slot in favour of Component children whenever possible.\n */\n content: NonNullable<Slot<'span'>>;\n};\n\ntype TabCommons = {\n /**\n * The value that identifies this tab when selected.\n */\n value: TabValue;\n};\n\n/**\n * Tab Props\n */\nexport type TabProps = ComponentProps<Partial<TabSlots>> & TabCommons;\n\n/**\n * State used in rendering Tab\n */\nexport type TabState = ComponentState<TabSlots> &\n TabCommons & {\n /**\n * A tab supports 'transparent' and 'subtle' appearance.\n */\n appearance?: string;\n /**\n * If this tab is selected.\n */\n selected?: boolean;\n /**\n * A tab can be either 'small' or 'medium' size.\n */\n size: 'small' | 'medium';\n /**\n * A tab can arrange its content based on if the tabs in the list are arranged vertically.\n */\n vertical: boolean;\n };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["components/Tab/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC","sourcesContent":["export * from './Tab';\nexport * from './Tab.types';\nexport * from './renderTab';\nexport * from './useTab';\nexport * from './useTabStyles';\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getSlots } from '@fluentui/react-utilities';
|
|
3
|
+
/**
|
|
4
|
+
* Render the final JSX of Tab
|
|
5
|
+
*/
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
|
+
|
|
8
|
+
export const renderTab_unstable = state => {
|
|
9
|
+
const {
|
|
10
|
+
slots,
|
|
11
|
+
slotProps
|
|
12
|
+
} = getSlots(state);
|
|
13
|
+
return /*#__PURE__*/React.createElement(slots.root, { ...slotProps.root
|
|
14
|
+
}, slots.icon && /*#__PURE__*/React.createElement(slots.icon, { ...slotProps.icon
|
|
15
|
+
}), /*#__PURE__*/React.createElement(slots.content, { ...slotProps.content
|
|
16
|
+
}));
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=renderTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/renderTab.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,QAAT,QAAyB,2BAAzB;AAGA;;AAEG;AACH;;AACA,OAAO,MAAM,kBAAkB,GAAI,KAAD,IAAoB;AACpD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,QAAQ,CAAW,KAAX,CAArC;AAEA,sBACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACG,KAAK,CAAC,IAAN,iBAAc,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,CADjB,eAEE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;AAAf,GAAd,CAFF,CADF;AAMD,CATM","sourcesContent":["import * as React from 'react';\nimport { getSlots } from '@fluentui/react-utilities';\nimport type { TabState, TabSlots } from './Tab.types';\n\n/**\n * Render the final JSX of Tab\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const renderTab_unstable = (state: TabState) => {\n const { slots, slotProps } = getSlots<TabSlots>(state);\n\n return (\n <slots.root {...slotProps.root}>\n {slots.icon && <slots.icon {...slotProps.icon} />}\n <slots.content {...slotProps.content} />\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import type { TabProps, TabState } from './Tab.types';
|
|
3
|
+
/**
|
|
4
|
+
* Create the state required to render Tab.
|
|
5
|
+
*
|
|
6
|
+
* The returned state can be modified with hooks such as useTabStyles_unstable,
|
|
7
|
+
* before being passed to renderTab_unstable.
|
|
8
|
+
*
|
|
9
|
+
* @param props - props from this instance of Tab
|
|
10
|
+
* @param ref - reference to root HTMLElement of Tab
|
|
11
|
+
*/
|
|
12
|
+
export declare const useTab_unstable: (props: TabProps, ref: React.Ref<HTMLElement>) => TabState;
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { getNativeElementProps, resolveShorthand, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';
|
|
3
|
+
import { TabListContext } from '../TabList/TabListContext';
|
|
4
|
+
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
5
|
+
/**
|
|
6
|
+
* Create the state required to render Tab.
|
|
7
|
+
*
|
|
8
|
+
* The returned state can be modified with hooks such as useTabStyles_unstable,
|
|
9
|
+
* before being passed to renderTab_unstable.
|
|
10
|
+
*
|
|
11
|
+
* @param props - props from this instance of Tab
|
|
12
|
+
* @param ref - reference to root HTMLElement of Tab
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
|
+
|
|
16
|
+
export const useTab_unstable = (props, ref) => {
|
|
17
|
+
const {
|
|
18
|
+
content,
|
|
19
|
+
icon,
|
|
20
|
+
value
|
|
21
|
+
} = props;
|
|
22
|
+
const {
|
|
23
|
+
appearance,
|
|
24
|
+
selected,
|
|
25
|
+
onRegister,
|
|
26
|
+
onUnregister,
|
|
27
|
+
onSelect,
|
|
28
|
+
size,
|
|
29
|
+
vertical
|
|
30
|
+
} = useContextSelector(TabListContext, ctx => ({
|
|
31
|
+
appearance: ctx.appearance,
|
|
32
|
+
selected: ctx.selectedValue === value,
|
|
33
|
+
onRegister: ctx.onRegister,
|
|
34
|
+
onUnregister: ctx.onUnregister,
|
|
35
|
+
onSelect: ctx.onSelect,
|
|
36
|
+
size: ctx.size,
|
|
37
|
+
vertical: !!ctx.vertical
|
|
38
|
+
}));
|
|
39
|
+
const onClick = useEventCallback(event => onSelect(event, {
|
|
40
|
+
value
|
|
41
|
+
}));
|
|
42
|
+
const innerRef = React.useRef(null);
|
|
43
|
+
React.useEffect(() => {
|
|
44
|
+
onRegister({
|
|
45
|
+
value,
|
|
46
|
+
ref: innerRef
|
|
47
|
+
});
|
|
48
|
+
return () => {
|
|
49
|
+
onUnregister({
|
|
50
|
+
value,
|
|
51
|
+
ref: innerRef
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
}, [onRegister, onUnregister, innerRef, value]);
|
|
55
|
+
return {
|
|
56
|
+
components: {
|
|
57
|
+
root: 'div',
|
|
58
|
+
icon: 'span',
|
|
59
|
+
content: 'span'
|
|
60
|
+
},
|
|
61
|
+
root: getNativeElementProps('div', {
|
|
62
|
+
ref: useMergedRefs(ref, innerRef),
|
|
63
|
+
role: 'tab',
|
|
64
|
+
tabIndex: 0,
|
|
65
|
+
...props,
|
|
66
|
+
onClick
|
|
67
|
+
}),
|
|
68
|
+
icon: resolveShorthand(icon),
|
|
69
|
+
content: resolveShorthand(content, {
|
|
70
|
+
required: true,
|
|
71
|
+
defaultProps: {
|
|
72
|
+
children: props.children
|
|
73
|
+
}
|
|
74
|
+
}),
|
|
75
|
+
appearance,
|
|
76
|
+
selected,
|
|
77
|
+
size,
|
|
78
|
+
value,
|
|
79
|
+
vertical
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=useTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/useTab.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAZ,MAAuB,OAAvB;AACA,SAAS,qBAAT,EAAgC,gBAAhC,EAAkD,gBAAlD,EAAoE,aAApE,QAAyF,2BAAzF;AAEA,SAAS,cAAT,QAA+B,2BAA/B;AACA,SAAS,kBAAT,QAAmC,kCAAnC;AAGA;;;;;;;;AAQG;AACH;;AACA,OAAO,MAAM,eAAe,GAAG,CAAC,KAAD,EAAkB,GAAlB,KAA2D;AACxF,QAAM;AAAE,IAAA,OAAF;AAAW,IAAA,IAAX;AAAiB,IAAA;AAAjB,MAA2B,KAAjC;AAEA,QAAM;AAAE,IAAA,UAAF;AAAc,IAAA,QAAd;AAAwB,IAAA,UAAxB;AAAoC,IAAA,YAApC;AAAkD,IAAA,QAAlD;AAA4D,IAAA,IAA5D;AAAkE,IAAA;AAAlE,MAA+E,kBAAkB,CACrG,cADqG,EAErG,GAAG,KAAK;AACN,IAAA,UAAU,EAAE,GAAG,CAAC,UADV;AAEN,IAAA,QAAQ,EAAE,GAAG,CAAC,aAAJ,KAAsB,KAF1B;AAGN,IAAA,UAAU,EAAE,GAAG,CAAC,UAHV;AAIN,IAAA,YAAY,EAAE,GAAG,CAAC,YAJZ;AAKN,IAAA,QAAQ,EAAE,GAAG,CAAC,QALR;AAMN,IAAA,IAAI,EAAE,GAAG,CAAC,IANJ;AAON,IAAA,QAAQ,EAAE,CAAC,CAAC,GAAG,CAAC;AAPV,GAAL,CAFkG,CAAvG;AAaA,QAAM,OAAO,GAAG,gBAAgB,CAAE,KAAD,IAA2B,QAAQ,CAAC,KAAD,EAAQ;AAAE,IAAA;AAAF,GAAR,CAApC,CAAhC;AAEA,QAAM,QAAQ,GAAG,KAAK,CAAC,MAAN,CAA0B,IAA1B,CAAjB;AAEA,EAAA,KAAK,CAAC,SAAN,CAAgB,MAAK;AACnB,IAAA,UAAU,CAAC;AACT,MAAA,KADS;AAET,MAAA,GAAG,EAAE;AAFI,KAAD,CAAV;AAKA,WAAO,MAAK;AACV,MAAA,YAAY,CAAC;AAAE,QAAA,KAAF;AAAS,QAAA,GAAG,EAAE;AAAd,OAAD,CAAZ;AACD,KAFD;AAGD,GATD,EASG,CAAC,UAAD,EAAa,YAAb,EAA2B,QAA3B,EAAqC,KAArC,CATH;AAWA,SAAO;AACL,IAAA,UAAU,EAAE;AACV,MAAA,IAAI,EAAE,KADI;AAEV,MAAA,IAAI,EAAE,MAFI;AAGV,MAAA,OAAO,EAAE;AAHC,KADP;AAML,IAAA,IAAI,EAAE,qBAAqB,CAAC,KAAD,EAAQ;AACjC,MAAA,GAAG,EAAE,aAAa,CAAC,GAAD,EAAM,QAAN,CADe;AAEjC,MAAA,IAAI,EAAE,KAF2B;AAGjC,MAAA,QAAQ,EAAE,CAHuB;AAIjC,SAAG,KAJ8B;AAKjC,MAAA;AALiC,KAAR,CANtB;AAaL,IAAA,IAAI,EAAE,gBAAgB,CAAC,IAAD,CAbjB;AAcL,IAAA,OAAO,EAAE,gBAAgB,CAAC,OAAD,EAAU;AAAE,MAAA,QAAQ,EAAE,IAAZ;AAAkB,MAAA,YAAY,EAAE;AAAE,QAAA,QAAQ,EAAE,KAAK,CAAC;AAAlB;AAAhC,KAAV,CAdpB;AAeL,IAAA,UAfK;AAgBL,IAAA,QAhBK;AAiBL,IAAA,IAjBK;AAkBL,IAAA,KAlBK;AAmBL,IAAA;AAnBK,GAAP;AAqBD,CApDM","sourcesContent":["import * as React from 'react';\nimport { getNativeElementProps, resolveShorthand, useEventCallback, useMergedRefs } from '@fluentui/react-utilities';\nimport type { TabProps, TabState } from './Tab.types';\nimport { TabListContext } from '../TabList/TabListContext';\nimport { useContextSelector } from '@fluentui/react-context-selector';\nimport { SelectTabEvent } from '../TabList/TabList.types';\n\n/**\n * Create the state required to render Tab.\n *\n * The returned state can be modified with hooks such as useTabStyles_unstable,\n * before being passed to renderTab_unstable.\n *\n * @param props - props from this instance of Tab\n * @param ref - reference to root HTMLElement of Tab\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const useTab_unstable = (props: TabProps, ref: React.Ref<HTMLElement>): TabState => {\n const { content, icon, value } = props;\n\n const { appearance, selected, onRegister, onUnregister, onSelect, size, vertical } = useContextSelector(\n TabListContext,\n ctx => ({\n appearance: ctx.appearance,\n selected: ctx.selectedValue === value,\n onRegister: ctx.onRegister,\n onUnregister: ctx.onUnregister,\n onSelect: ctx.onSelect,\n size: ctx.size,\n vertical: !!ctx.vertical,\n }),\n );\n\n const onClick = useEventCallback((event: SelectTabEvent) => onSelect(event, { value }));\n\n const innerRef = React.useRef<HTMLElement>(null);\n\n React.useEffect(() => {\n onRegister({\n value,\n ref: innerRef,\n });\n\n return () => {\n onUnregister({ value, ref: innerRef });\n };\n }, [onRegister, onUnregister, innerRef, value]);\n\n return {\n components: {\n root: 'div',\n icon: 'span',\n content: 'span',\n },\n root: getNativeElementProps('div', {\n ref: useMergedRefs(ref, innerRef),\n role: 'tab',\n tabIndex: 0,\n ...props,\n onClick,\n }),\n icon: resolveShorthand(icon),\n content: resolveShorthand(content, { required: true, defaultProps: { children: props.children } }),\n appearance,\n selected,\n size,\n value,\n vertical,\n };\n};\n"],"sourceRoot":"../src/"}
|