@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,118 @@
|
|
|
1
|
+
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
2
|
+
import { tokens } from '@fluentui/react-theme';
|
|
3
|
+
import { usePrevious } from '@fluentui/react-utilities';
|
|
4
|
+
import { tabPendingDesignTokens } from '../../tab.constants';
|
|
5
|
+
export const tabListClassName = 'fui-TabList';
|
|
6
|
+
export const tabListSelectionIndicatorName = 'fui-TabList_SelectionIndicator';
|
|
7
|
+
export const indicatorOffsetVar = '--selection-indicator-offset';
|
|
8
|
+
export const indicatorLengthVar = '--selection-indicator-length';
|
|
9
|
+
/**
|
|
10
|
+
* Styles for the root slot
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
const useStyles = /*#__PURE__*/__styles({
|
|
14
|
+
"root": {
|
|
15
|
+
"mc9l5x": "f22iagw",
|
|
16
|
+
"Beiy3e4": "f1063pyq",
|
|
17
|
+
"qhf8xq": "f10pi13n"
|
|
18
|
+
},
|
|
19
|
+
"vertical": {
|
|
20
|
+
"Beiy3e4": "f1vx9l62"
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
"d": [".f22iagw{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;}", ".f1063pyq{-webkit-flex-direction:row;-ms-flex-direction:row;flex-direction:row;}", ".f10pi13n{position:relative;}", ".f1vx9l62{-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;}"]
|
|
24
|
+
});
|
|
25
|
+
/**
|
|
26
|
+
* Styles for the selection indicator slot when horizontal.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
const useHorizontalIndicatorStyles = /*#__PURE__*/__styles({
|
|
31
|
+
"base": {
|
|
32
|
+
"Bkbwdz4": "f30248y",
|
|
33
|
+
"frdscb": ["fvxed1z", "f1j2a01o"],
|
|
34
|
+
"B9nohqn": ["f1j2a01o", "fvxed1z"],
|
|
35
|
+
"B1dhsta": ["fsamouo", "f1aazreq"],
|
|
36
|
+
"Bjdmjzx": ["f1aazreq", "fsamouo"],
|
|
37
|
+
"Bj55yzk": "fw2wsqs",
|
|
38
|
+
"oqd9ik": "ffdc0f3",
|
|
39
|
+
"Bs6t6z0": "fqc6z8f",
|
|
40
|
+
"mpb1vu": "f119hevp",
|
|
41
|
+
"jc51t6": ["f1uyszuw", "f1xp83vy"],
|
|
42
|
+
"Hdbjpj": "f11ef69",
|
|
43
|
+
"Biobvvw": "f1tzy5p2",
|
|
44
|
+
"Bunff0j": "fs357bs"
|
|
45
|
+
},
|
|
46
|
+
"small": {
|
|
47
|
+
"jc51t6": ["f1w3ykbk", "f1xm0lqg"],
|
|
48
|
+
"Biobvvw": "f1akpkq3"
|
|
49
|
+
},
|
|
50
|
+
"animated": {
|
|
51
|
+
"wbfbqe": ["fjzde92", "f1xfxhj5"],
|
|
52
|
+
"mafdb0": "f1fuwhvj"
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
"d": [".f30248y:after{background-color:var(--colorBrandStroke1);}", ".fvxed1z:after{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f1j2a01o:after{border-bottom-left-radius:var(--borderRadiusMedium);}", ".fsamouo:after{border-top-right-radius:var(--borderRadiusMedium);}", ".f1aazreq:after{border-top-left-radius:var(--borderRadiusMedium);}", ".fw2wsqs:after{bottom:0;}", ".ffdc0f3:after{box-sizing:border-box;}", ".fqc6z8f:after{content:\"\";}", ".f119hevp:after{height:2px;}", ".f1uyszuw:after{left:calc(var(--selection-indicator-offset) + 10px);}", ".f1xp83vy:after{right:calc(var(--selection-indicator-offset) + 10px);}", ".f11ef69:after{position:absolute;}", ".f1tzy5p2:after{width:calc(var(--selection-indicator-length) - (2 * 10px));}", ".fs357bs:after{z-index:1;}", ".f1w3ykbk:after{left:calc(var(--selection-indicator-offset) + 6px);}", ".f1xm0lqg:after{right:calc(var(--selection-indicator-offset) + 6px);}", ".f1akpkq3:after{width:calc(var(--selection-indicator-length) - (2 * 6px));}", ".fjzde92:after{transition-property:left,width;}", ".f1xfxhj5:after{transition-property:right,width;}", ".f1fuwhvj:after{transition-duration:350ms,350ms;}"]
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Styles for the selection indicator slot when vertical.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
const useVerticalIndicatorStyles = /*#__PURE__*/__styles({
|
|
63
|
+
"base": {
|
|
64
|
+
"B1dvbpk": "fa05st",
|
|
65
|
+
"px8gyy": ["f16to4m4", "f1ceoihi"],
|
|
66
|
+
"B5c9fhp": ["f1ceoihi", "f16to4m4"],
|
|
67
|
+
"Bhe99jt": ["fkibbow", "fnlo9u7"],
|
|
68
|
+
"B2r1szc": ["fnlo9u7", "fkibbow"],
|
|
69
|
+
"Bmqnesq": "f170vdtw",
|
|
70
|
+
"rurcny": "fuzzvh5",
|
|
71
|
+
"Bbc2r3f": "f13xaayz",
|
|
72
|
+
"Byque4d": ["f1t0u0az", "fmlx6bj"],
|
|
73
|
+
"xx9plb": "fxf9f1y",
|
|
74
|
+
"Bf8kmfk": "fwt37qm",
|
|
75
|
+
"Bdn98qo": "f15bpuwh",
|
|
76
|
+
"Bab4cu6": "f1ijlm3k"
|
|
77
|
+
},
|
|
78
|
+
"small": {
|
|
79
|
+
"Bf8kmfk": "f8k0k00",
|
|
80
|
+
"Bbc2r3f": "fyephjl"
|
|
81
|
+
},
|
|
82
|
+
"animated": {
|
|
83
|
+
"iukgx1": "fcs48rj",
|
|
84
|
+
"B5szp9g": "f1u309tb"
|
|
85
|
+
}
|
|
86
|
+
}, {
|
|
87
|
+
"d": [".fa05st:before{background-color:var(--colorBrandStroke1);}", ".f16to4m4:before{border-bottom-right-radius:var(--borderRadiusMedium);}", ".f1ceoihi:before{border-bottom-left-radius:var(--borderRadiusMedium);}", ".fkibbow:before{border-top-right-radius:var(--borderRadiusMedium);}", ".fnlo9u7:before{border-top-left-radius:var(--borderRadiusMedium);}", ".f170vdtw:before{box-sizing:border-box;}", ".fuzzvh5:before{content:\"\";}", ".f13xaayz:before{height:calc(var(--selection-indicator-length) - (2 * 10px));}", ".f1t0u0az:before{left:0;}", ".fmlx6bj:before{right:0;}", ".fxf9f1y:before{position:absolute;}", ".fwt37qm:before{top:calc(var(--selection-indicator-offset) + 10px);}", ".f15bpuwh:before{width:2px;}", ".f1ijlm3k:before{z-index:1;}", ".f8k0k00:before{top:calc(var(--selection-indicator-offset) + 6px);}", ".fyephjl:before{height:calc(var(--selection-indicator-length) - (2 * 6px));}", ".fcs48rj:before{transition-property:top,height;}", ".f1u309tb:before{transition-duration:350ms,350ms;}"]
|
|
88
|
+
});
|
|
89
|
+
/**
|
|
90
|
+
* Apply styling to the TabList slots based on the state
|
|
91
|
+
*/
|
|
92
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
export const useTabListStyles_unstable = state => {
|
|
96
|
+
const {
|
|
97
|
+
selectedTabRect: selectionIndicatorRect,
|
|
98
|
+
selectedValue,
|
|
99
|
+
size,
|
|
100
|
+
vertical
|
|
101
|
+
} = state; // only animate when the selected value has changed
|
|
102
|
+
|
|
103
|
+
const previousSelectedValue = usePrevious(selectedValue);
|
|
104
|
+
const shouldAnimate = !!previousSelectedValue && previousSelectedValue !== selectedValue;
|
|
105
|
+
const styles = useStyles();
|
|
106
|
+
const horizontalIndicatorStyles = useHorizontalIndicatorStyles();
|
|
107
|
+
const verticalIndicatorStyles = useVerticalIndicatorStyles();
|
|
108
|
+
state.root.className = mergeClasses(tabListClassName, styles.root, vertical && styles.vertical, !!selectedValue && (vertical ? verticalIndicatorStyles.base : horizontalIndicatorStyles.base), !!selectedValue && size === 'small' && (vertical ? verticalIndicatorStyles.small : horizontalIndicatorStyles.small), !!selectedValue && shouldAnimate && (vertical ? verticalIndicatorStyles.animated : horizontalIndicatorStyles.animated), state.root.className);
|
|
109
|
+
const rootCssVars = selectionIndicatorRect ? {
|
|
110
|
+
[indicatorOffsetVar]: vertical ? `${selectionIndicatorRect.y}px` : `${selectionIndicatorRect.x}px`,
|
|
111
|
+
[indicatorLengthVar]: vertical ? `${selectionIndicatorRect.height}px` : `${selectionIndicatorRect.width}px`
|
|
112
|
+
} : {};
|
|
113
|
+
state.root.style = { ...rootCssVars,
|
|
114
|
+
...state.root.style
|
|
115
|
+
};
|
|
116
|
+
return state;
|
|
117
|
+
};
|
|
118
|
+
//# sourceMappingURL=useTabListStyles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/TabList/useTabListStyles.ts"],"names":[],"mappings":"AAAA,mBAAqB,YAArB,EAAmC,UAAnC,QAAqD,gBAArD;AAEA,SAAS,MAAT,QAAuB,uBAAvB;AACA,SAAS,WAAT,QAA4B,2BAA5B;AACA,SAAS,sBAAT,QAAuC,qBAAvC;AAEA,OAAO,MAAM,gBAAgB,GAAG,aAAzB;AACP,OAAO,MAAM,6BAA6B,GAAG,gCAAtC;AAEP,OAAO,MAAM,kBAAkB,GAAG,8BAA3B;AACP,OAAO,MAAM,kBAAkB,GAAG,8BAA3B;AAEP;;AAEG;;AACH,MAAM,SAAS,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAlB;AAWA;;AAEG;;;AACH,MAAM,4BAA4B,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAArC;AA6BA;;AAEG;;;AACH,MAAM,0BAA0B,gBAAG;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAnC;AA6BA;;AAEG;AACH;;;AACA,OAAO,MAAM,yBAAyB,GAAI,KAAD,IAAsC;AAC7E,QAAM;AAAE,IAAA,eAAe,EAAE,sBAAnB;AAA2C,IAAA,aAA3C;AAA0D,IAAA,IAA1D;AAAgE,IAAA;AAAhE,MAA6E,KAAnF,CAD6E,CAG7E;;AACA,QAAM,qBAAqB,GAAG,WAAW,CAAC,aAAD,CAAzC;AACA,QAAM,aAAa,GAAG,CAAC,CAAC,qBAAF,IAA2B,qBAAqB,KAAK,aAA3E;AAEA,QAAM,MAAM,GAAG,SAAS,EAAxB;AACA,QAAM,yBAAyB,GAAG,4BAA4B,EAA9D;AACA,QAAM,uBAAuB,GAAG,0BAA0B,EAA1D;AAEA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,YAAY,CACjC,gBADiC,EAEjC,MAAM,CAAC,IAF0B,EAGjC,QAAQ,IAAI,MAAM,CAAC,QAHc,EAIjC,CAAC,CAAC,aAAF,KAAoB,QAAQ,GAAG,uBAAuB,CAAC,IAA3B,GAAkC,yBAAyB,CAAC,IAAxF,CAJiC,EAKjC,CAAC,CAAC,aAAF,IAAmB,IAAI,KAAK,OAA5B,KAAwC,QAAQ,GAAG,uBAAuB,CAAC,KAA3B,GAAmC,yBAAyB,CAAC,KAA7G,CALiC,EAMjC,CAAC,CAAC,aAAF,IACE,aADF,KAEG,QAAQ,GAAG,uBAAuB,CAAC,QAA3B,GAAsC,yBAAyB,CAAC,QAF3E,CANiC,EASjC,KAAK,CAAC,IAAN,CAAW,SATsB,CAAnC;AAYA,QAAM,WAAW,GAAG,sBAAsB,GACtC;AACE,KAAC,kBAAD,GAAsB,QAAQ,GAAG,GAAG,sBAAsB,CAAC,CAAC,IAA9B,GAAqC,GAAG,sBAAsB,CAAC,CAAC,IADhG;AAEE,KAAC,kBAAD,GAAsB,QAAQ,GAAG,GAAG,sBAAsB,CAAC,MAAM,IAAnC,GAA0C,GAAG,sBAAsB,CAAC,KAAK;AAFzG,GADsC,GAKtC,EALJ;AAOA,EAAA,KAAK,CAAC,IAAN,CAAW,KAAX,GAAmB,EACjB,GAAG,WADc;AAEjB,OAAG,KAAK,CAAC,IAAN,CAAW;AAFG,GAAnB;AAKA,SAAO,KAAP;AACD,CApCM","sourcesContent":["import { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport type { TabListState } from './TabList.types';\nimport { tokens } from '@fluentui/react-theme';\nimport { usePrevious } from '@fluentui/react-utilities';\nimport { tabPendingDesignTokens } from '../../tab.constants';\n\nexport const tabListClassName = 'fui-TabList';\nexport const tabListSelectionIndicatorName = 'fui-TabList_SelectionIndicator';\n\nexport const indicatorOffsetVar = '--selection-indicator-offset';\nexport const indicatorLengthVar = '--selection-indicator-length';\n\n/**\n * Styles for the root slot\n */\nconst useStyles = makeStyles({\n root: {\n display: 'flex',\n flexDirection: 'row',\n position: 'relative',\n },\n vertical: {\n flexDirection: 'column',\n },\n});\n\n/**\n * Styles for the selection indicator slot when horizontal.\n */\nconst useHorizontalIndicatorStyles = makeStyles({\n base: {\n ':after': {\n backgroundColor: tokens.colorBrandStroke1,\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n bottom: 0,\n boxSizing: 'border-box',\n content: '\"\"',\n height: tabPendingDesignTokens.indicatorThickness,\n left: `calc(var(${indicatorOffsetVar}) + ${tabPendingDesignTokens.tabPadding.medium})`,\n position: 'absolute',\n width: `calc(var(${indicatorLengthVar}) - (2 * ${tabPendingDesignTokens.tabPadding.medium}))`,\n zIndex: 1,\n },\n },\n small: {\n ':after': {\n left: `calc(var(${indicatorOffsetVar}) + ${tabPendingDesignTokens.tabPadding.small})`,\n width: `calc(var(${indicatorLengthVar}) - (2 * ${tabPendingDesignTokens.tabPadding.small}))`,\n },\n },\n animated: {\n ':after': {\n transitionProperty: 'left, width',\n transitionDuration: `350ms, 350ms`,\n },\n },\n});\n\n/**\n * Styles for the selection indicator slot when vertical.\n */\nconst useVerticalIndicatorStyles = makeStyles({\n base: {\n ':before': {\n backgroundColor: tokens.colorBrandStroke1,\n ...shorthands.borderRadius(tokens.borderRadiusMedium),\n boxSizing: 'border-box',\n content: '\"\"',\n height: `calc(var(${indicatorLengthVar}) - (2 * ${tabPendingDesignTokens.tabPadding.medium}))`,\n left: '0',\n position: 'absolute',\n top: `calc(var(${indicatorOffsetVar}) + ${tabPendingDesignTokens.tabPadding.medium})`,\n width: tabPendingDesignTokens.indicatorThickness,\n zIndex: 1,\n },\n },\n small: {\n ':before': {\n top: `calc(var(${indicatorOffsetVar}) + ${tabPendingDesignTokens.tabPadding.small})`,\n height: `calc(var(${indicatorLengthVar}) - (2 * ${tabPendingDesignTokens.tabPadding.small}))`,\n },\n },\n animated: {\n ':before': {\n transitionProperty: 'top, height',\n transitionDuration: `350ms, 350ms`,\n },\n },\n});\n\n/**\n * Apply styling to the TabList slots based on the state\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const useTabListStyles_unstable = (state: TabListState): TabListState => {\n const { selectedTabRect: selectionIndicatorRect, selectedValue, size, vertical } = state;\n\n // only animate when the selected value has changed\n const previousSelectedValue = usePrevious(selectedValue);\n const shouldAnimate = !!previousSelectedValue && previousSelectedValue !== selectedValue;\n\n const styles = useStyles();\n const horizontalIndicatorStyles = useHorizontalIndicatorStyles();\n const verticalIndicatorStyles = useVerticalIndicatorStyles();\n\n state.root.className = mergeClasses(\n tabListClassName,\n styles.root,\n vertical && styles.vertical,\n !!selectedValue && (vertical ? verticalIndicatorStyles.base : horizontalIndicatorStyles.base),\n !!selectedValue && size === 'small' && (vertical ? verticalIndicatorStyles.small : horizontalIndicatorStyles.small),\n !!selectedValue &&\n shouldAnimate &&\n (vertical ? verticalIndicatorStyles.animated : horizontalIndicatorStyles.animated),\n state.root.className,\n );\n\n const rootCssVars = selectionIndicatorRect\n ? {\n [indicatorOffsetVar]: vertical ? `${selectionIndicatorRect.y}px` : `${selectionIndicatorRect.x}px`,\n [indicatorLengthVar]: vertical ? `${selectionIndicatorRect.height}px` : `${selectionIndicatorRect.width}px`,\n }\n : {};\n\n state.root.style = {\n ...rootCssVars,\n ...state.root.style,\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
package/lib/index.d.ts
ADDED
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"../src/","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,WAAW,CAAC","sourcesContent":["export * from './Tab';\nexport * from './TabList';\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const tabPendingDesignTokens: {
|
|
2
|
+
tabPadding: {
|
|
3
|
+
medium: string;
|
|
4
|
+
small: string;
|
|
5
|
+
};
|
|
6
|
+
indicatorThickness: string;
|
|
7
|
+
gap: {
|
|
8
|
+
medium: string;
|
|
9
|
+
small: string;
|
|
10
|
+
};
|
|
11
|
+
contentPadding: {
|
|
12
|
+
medium: string;
|
|
13
|
+
small: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// TODO: These constants should be replaced with design tokens
|
|
2
|
+
export const tabPendingDesignTokens = {
|
|
3
|
+
tabPadding: {
|
|
4
|
+
medium: '10px',
|
|
5
|
+
small: '6px'
|
|
6
|
+
},
|
|
7
|
+
indicatorThickness: '2px',
|
|
8
|
+
gap: {
|
|
9
|
+
medium: '6px',
|
|
10
|
+
small: '2px'
|
|
11
|
+
},
|
|
12
|
+
contentPadding: {
|
|
13
|
+
medium: '2px',
|
|
14
|
+
small: '2px'
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=tab.constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["tab.constants.ts"],"names":[],"mappings":"AAAA;AACA,OAAO,MAAM,sBAAsB,GAAG;AACpC,EAAA,UAAU,EAAE;AACV,IAAA,MAAM,EAAE,MADE;AAEV,IAAA,KAAK,EAAE;AAFG,GADwB;AAKpC,EAAA,kBAAkB,EAAE,KALgB;AAMpC,EAAA,GAAG,EAAE;AAAE,IAAA,MAAM,EAAE,KAAV;AAAiB,IAAA,KAAK,EAAE;AAAxB,GAN+B;AAOpC,EAAA,cAAc,EAAE;AACd,IAAA,MAAM,EAAE,KADM;AAEd,IAAA,KAAK,EAAE;AAFO;AAPoB,CAA/B","sourcesContent":["// TODO: These constants should be replaced with design tokens\nexport const tabPendingDesignTokens = {\n tabPadding: {\n medium: '10px',\n small: '6px',\n },\n indicatorThickness: '2px',\n gap: { medium: '6px', small: '2px' },\n contentPadding: {\n medium: '2px',\n small: '2px',\n },\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.18.1"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/Tab/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["Tab.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,wBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/Tab/index';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components/TabList/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["TabList.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,4BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './components/TabList/index';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Tab = void 0;
|
|
7
|
+
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
|
+
|
|
10
|
+
const useTab_1 = /*#__PURE__*/require("./useTab");
|
|
11
|
+
|
|
12
|
+
const renderTab_1 = /*#__PURE__*/require("./renderTab");
|
|
13
|
+
|
|
14
|
+
const useTabStyles_1 = /*#__PURE__*/require("./useTabStyles");
|
|
15
|
+
/**
|
|
16
|
+
* A tab provides a selectable item in a tab list.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
exports.Tab = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
21
|
+
const state = useTab_1.useTab_unstable(props, ref);
|
|
22
|
+
useTabStyles_1.useTabStyles_unstable(state);
|
|
23
|
+
return renderTab_1.renderTab_unstable(state);
|
|
24
|
+
});
|
|
25
|
+
exports.Tab.displayName = 'Tab';
|
|
26
|
+
//# sourceMappingURL=Tab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/Tab.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,QAAA,gBAAA,OAAA,CAAA,UAAA,CAAA;;AACA,MAAA,WAAA,gBAAA,OAAA,CAAA,aAAA,CAAA;;AACA,MAAA,cAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;AAIA;;AAEG;;;AACU,OAAA,CAAA,GAAA,gBAAqC,KAAK,CAAC,UAAN,CAAiB,CAAC,KAAD,EAAQ,GAAR,KAAe;AAChF,QAAM,KAAK,GAAG,QAAA,CAAA,eAAA,CAAgB,KAAhB,EAAuB,GAAvB,CAAd;AAEA,EAAA,cAAA,CAAA,qBAAA,CAAsB,KAAtB;AACA,SAAO,WAAA,CAAA,kBAAA,CAAmB,KAAnB,CAAP;AACD,CALiD,CAArC;AAOb,OAAA,CAAA,GAAA,CAAI,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,"sources":[],"names":[],"mappings":"","sourceRoot":"../src/"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
const tslib_1 = /*#__PURE__*/require("tslib");
|
|
8
|
+
|
|
9
|
+
tslib_1.__exportStar(require("./Tab"), exports);
|
|
10
|
+
|
|
11
|
+
tslib_1.__exportStar(require("./Tab.types"), exports);
|
|
12
|
+
|
|
13
|
+
tslib_1.__exportStar(require("./renderTab"), exports);
|
|
14
|
+
|
|
15
|
+
tslib_1.__exportStar(require("./useTab"), exports);
|
|
16
|
+
|
|
17
|
+
tslib_1.__exportStar(require("./useTabStyles"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/index.ts"],"names":[],"mappings":";;;;;;;;AAAA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,OAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,aAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,UAAA,CAAA,EAAA,OAAA;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,gBAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Tab';\nexport * from './Tab.types';\nexport * from './renderTab';\nexport * from './useTab';\nexport * from './useTabStyles';\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.renderTab_unstable = void 0;
|
|
7
|
+
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
|
+
|
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
+
/**
|
|
12
|
+
* Render the final JSX of Tab
|
|
13
|
+
*/
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
const renderTab_unstable = state => {
|
|
18
|
+
const {
|
|
19
|
+
slots,
|
|
20
|
+
slotProps
|
|
21
|
+
} = react_utilities_1.getSlots(state);
|
|
22
|
+
return React.createElement(slots.root, { ...slotProps.root
|
|
23
|
+
}, slots.icon && React.createElement(slots.icon, { ...slotProps.icon
|
|
24
|
+
}), React.createElement(slots.content, { ...slotProps.content
|
|
25
|
+
}));
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
exports.renderTab_unstable = renderTab_unstable;
|
|
29
|
+
//# sourceMappingURL=renderTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/renderTab.tsx"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;AAGA;;AAEG;AACH;;;AACO,MAAM,kBAAkB,GAAI,KAAD,IAAoB;AACpD,QAAM;AAAE,IAAA,KAAF;AAAS,IAAA;AAAT,MAAuB,iBAAA,CAAA,QAAA,CAAmB,KAAnB,CAA7B;AAEA,SACE,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,IAAP,EAAW,EAAA,GAAK,SAAS,CAAC;AAAf,GAAX,EACG,KAAK,CAAC,IAAN,IAAc,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;;AAAM,OAAA,CAAA,kBAAA,GAAkB,kBAAlB","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,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTab_unstable = void 0;
|
|
7
|
+
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
|
+
|
|
10
|
+
const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
11
|
+
|
|
12
|
+
const TabListContext_1 = /*#__PURE__*/require("../TabList/TabListContext");
|
|
13
|
+
|
|
14
|
+
const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
|
15
|
+
/**
|
|
16
|
+
* Create the state required to render Tab.
|
|
17
|
+
*
|
|
18
|
+
* The returned state can be modified with hooks such as useTabStyles_unstable,
|
|
19
|
+
* before being passed to renderTab_unstable.
|
|
20
|
+
*
|
|
21
|
+
* @param props - props from this instance of Tab
|
|
22
|
+
* @param ref - reference to root HTMLElement of Tab
|
|
23
|
+
*/
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
const useTab_unstable = (props, ref) => {
|
|
28
|
+
const {
|
|
29
|
+
content,
|
|
30
|
+
icon,
|
|
31
|
+
value
|
|
32
|
+
} = props;
|
|
33
|
+
const {
|
|
34
|
+
appearance,
|
|
35
|
+
selected,
|
|
36
|
+
onRegister,
|
|
37
|
+
onUnregister,
|
|
38
|
+
onSelect,
|
|
39
|
+
size,
|
|
40
|
+
vertical
|
|
41
|
+
} = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ({
|
|
42
|
+
appearance: ctx.appearance,
|
|
43
|
+
selected: ctx.selectedValue === value,
|
|
44
|
+
onRegister: ctx.onRegister,
|
|
45
|
+
onUnregister: ctx.onUnregister,
|
|
46
|
+
onSelect: ctx.onSelect,
|
|
47
|
+
size: ctx.size,
|
|
48
|
+
vertical: !!ctx.vertical
|
|
49
|
+
}));
|
|
50
|
+
const onClick = react_utilities_1.useEventCallback(event => onSelect(event, {
|
|
51
|
+
value
|
|
52
|
+
}));
|
|
53
|
+
const innerRef = React.useRef(null);
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
onRegister({
|
|
56
|
+
value,
|
|
57
|
+
ref: innerRef
|
|
58
|
+
});
|
|
59
|
+
return () => {
|
|
60
|
+
onUnregister({
|
|
61
|
+
value,
|
|
62
|
+
ref: innerRef
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
}, [onRegister, onUnregister, innerRef, value]);
|
|
66
|
+
return {
|
|
67
|
+
components: {
|
|
68
|
+
root: 'div',
|
|
69
|
+
icon: 'span',
|
|
70
|
+
content: 'span'
|
|
71
|
+
},
|
|
72
|
+
root: react_utilities_1.getNativeElementProps('div', {
|
|
73
|
+
ref: react_utilities_1.useMergedRefs(ref, innerRef),
|
|
74
|
+
role: 'tab',
|
|
75
|
+
tabIndex: 0,
|
|
76
|
+
...props,
|
|
77
|
+
onClick
|
|
78
|
+
}),
|
|
79
|
+
icon: react_utilities_1.resolveShorthand(icon),
|
|
80
|
+
content: react_utilities_1.resolveShorthand(content, {
|
|
81
|
+
required: true,
|
|
82
|
+
defaultProps: {
|
|
83
|
+
children: props.children
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
appearance,
|
|
87
|
+
selected,
|
|
88
|
+
size,
|
|
89
|
+
value,
|
|
90
|
+
vertical
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
exports.useTab_unstable = useTab_unstable;
|
|
95
|
+
//# sourceMappingURL=useTab.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/useTab.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AACA,MAAA,iBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AAEA,MAAA,gBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;AAGA;;;;;;;;AAQG;AACH;;;AACO,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,wBAAA,CAAA,kBAAA,CACnF,gBAAA,CAAA,cADmF,EAEnF,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,CAFgF,CAArF;AAaA,QAAM,OAAO,GAAG,iBAAA,CAAA,gBAAA,CAAkB,KAAD,IAA2B,QAAQ,CAAC,KAAD,EAAQ;AAAE,IAAA;AAAF,GAAR,CAApD,CAAhB;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,iBAAA,CAAA,qBAAA,CAAsB,KAAtB,EAA6B;AACjC,MAAA,GAAG,EAAE,iBAAA,CAAA,aAAA,CAAc,GAAd,EAAmB,QAAnB,CAD4B;AAEjC,MAAA,IAAI,EAAE,KAF2B;AAGjC,MAAA,QAAQ,EAAE,CAHuB;AAIjC,SAAG,KAJ8B;AAKjC,MAAA;AALiC,KAA7B,CAND;AAaL,IAAA,IAAI,EAAE,iBAAA,CAAA,gBAAA,CAAiB,IAAjB,CAbD;AAcL,IAAA,OAAO,EAAE,iBAAA,CAAA,gBAAA,CAAiB,OAAjB,EAA0B;AAAE,MAAA,QAAQ,EAAE,IAAZ;AAAkB,MAAA,YAAY,EAAE;AAAE,QAAA,QAAQ,EAAE,KAAK,CAAC;AAAlB;AAAhC,KAA1B,CAdJ;AAeL,IAAA,UAfK;AAgBL,IAAA,QAhBK;AAiBL,IAAA,IAjBK;AAkBL,IAAA,KAlBK;AAmBL,IAAA;AAnBK,GAAP;AAqBD,CApDM;;AAAM,OAAA,CAAA,eAAA,GAAe,eAAf","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/"}
|