@fluentui/react-tabs 9.0.0-beta.6 → 9.0.0-beta.9
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 +180 -1
- package/CHANGELOG.md +49 -2
- package/dist/react-tabs.d.ts +48 -36
- package/lib/components/Tab/Tab.types.d.ts +14 -5
- package/lib/components/Tab/Tab.types.js.map +1 -1
- package/lib/components/Tab/index.d.ts +1 -0
- package/lib/components/Tab/index.js +1 -0
- package/lib/components/Tab/index.js.map +1 -1
- package/lib/components/Tab/renderTab.js +1 -2
- package/lib/components/Tab/renderTab.js.map +1 -1
- package/lib/components/Tab/useTab.js +25 -29
- package/lib/components/Tab/useTab.js.map +1 -1
- package/lib/components/Tab/useTabAnimatedIndicator.d.ts +5 -0
- package/lib/components/Tab/useTabAnimatedIndicator.js +134 -0
- package/lib/components/Tab/useTabAnimatedIndicator.js.map +1 -0
- package/lib/components/Tab/useTabStyles.d.ts +4 -2
- package/lib/components/Tab/useTabStyles.js +280 -84
- package/lib/components/Tab/useTabStyles.js.map +1 -1
- package/lib/components/TabList/TabList.types.d.ts +21 -16
- package/lib/components/TabList/TabList.types.js.map +1 -1
- package/lib/components/TabList/TabListContext.js +6 -0
- package/lib/components/TabList/TabListContext.js.map +1 -1
- package/lib/components/TabList/renderTabList.js +0 -1
- package/lib/components/TabList/renderTabList.js.map +1 -1
- package/lib/components/TabList/useTabList.js +26 -51
- package/lib/components/TabList/useTabList.js.map +1 -1
- package/lib/components/TabList/useTabListContextValues.js +4 -0
- package/lib/components/TabList/useTabListContextValues.js.map +1 -1
- package/lib/components/TabList/useTabListStyles.d.ts +4 -5
- package/lib/components/TabList/useTabListStyles.js +8 -90
- package/lib/components/TabList/useTabListStyles.js.map +1 -1
- package/lib/index.d.ts +4 -2
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/tab.constants.d.ts +59 -12
- package/lib/tab.constants.js +64 -13
- package/lib/tab.constants.js.map +1 -1
- package/lib-commonjs/components/Tab/Tab.types.d.ts +14 -5
- package/lib-commonjs/components/Tab/index.d.ts +1 -0
- package/lib-commonjs/components/Tab/index.js +2 -0
- package/lib-commonjs/components/Tab/index.js.map +1 -1
- package/lib-commonjs/components/Tab/renderTab.js +1 -2
- package/lib-commonjs/components/Tab/renderTab.js.map +1 -1
- package/lib-commonjs/components/Tab/useTab.js +25 -29
- package/lib-commonjs/components/Tab/useTab.js.map +1 -1
- package/lib-commonjs/components/Tab/useTabAnimatedIndicator.d.ts +5 -0
- package/lib-commonjs/components/Tab/useTabAnimatedIndicator.js +148 -0
- package/lib-commonjs/components/Tab/useTabAnimatedIndicator.js.map +1 -0
- package/lib-commonjs/components/Tab/useTabStyles.d.ts +4 -2
- package/lib-commonjs/components/Tab/useTabStyles.js +281 -84
- package/lib-commonjs/components/Tab/useTabStyles.js.map +1 -1
- package/lib-commonjs/components/TabList/TabList.types.d.ts +21 -16
- package/lib-commonjs/components/TabList/TabListContext.js +6 -0
- package/lib-commonjs/components/TabList/TabListContext.js.map +1 -1
- package/lib-commonjs/components/TabList/renderTabList.js +0 -1
- package/lib-commonjs/components/TabList/renderTabList.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabList.js +25 -50
- package/lib-commonjs/components/TabList/useTabList.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabListContextValues.js +4 -0
- package/lib-commonjs/components/TabList/useTabListContextValues.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabListStyles.d.ts +4 -5
- package/lib-commonjs/components/TabList/useTabListStyles.js +7 -92
- package/lib-commonjs/components/TabList/useTabListStyles.js.map +1 -1
- package/lib-commonjs/index.d.ts +4 -2
- package/lib-commonjs/index.js +76 -3
- package/lib-commonjs/index.js.map +1 -1
- package/lib-commonjs/tab.constants.d.ts +59 -12
- package/lib-commonjs/tab.constants.js +66 -14
- package/lib-commonjs/tab.constants.js.map +1 -1
- package/package.json +16 -17
|
@@ -7,7 +7,7 @@ export declare type TabSlots = {
|
|
|
7
7
|
/**
|
|
8
8
|
* Root of the component.
|
|
9
9
|
*/
|
|
10
|
-
root: Slot<'
|
|
10
|
+
root: Slot<'button'>;
|
|
11
11
|
/**
|
|
12
12
|
* Icon that renders before the content.
|
|
13
13
|
*/
|
|
@@ -19,6 +19,11 @@ export declare type TabSlots = {
|
|
|
19
19
|
content: NonNullable<Slot<'span'>>;
|
|
20
20
|
};
|
|
21
21
|
declare type TabCommons = {
|
|
22
|
+
/**
|
|
23
|
+
* A tab can be set to disable interaction.
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
disabled?: boolean;
|
|
22
27
|
/**
|
|
23
28
|
* The value that identifies this tab when selected.
|
|
24
29
|
*/
|
|
@@ -31,15 +36,19 @@ export declare type TabProps = ComponentProps<Partial<TabSlots>> & TabCommons;
|
|
|
31
36
|
/**
|
|
32
37
|
* State used in rendering Tab
|
|
33
38
|
*/
|
|
34
|
-
export declare type TabState = ComponentState<TabSlots> & TabCommons & {
|
|
39
|
+
export declare type TabState = ComponentState<TabSlots> & Omit<TabCommons, 'disabled'> & Required<Pick<TabCommons, 'disabled'>> & {
|
|
35
40
|
/**
|
|
36
41
|
* A tab supports 'transparent' and 'subtle' appearance.
|
|
37
42
|
*/
|
|
38
|
-
appearance?:
|
|
43
|
+
appearance?: 'transparent' | 'subtle';
|
|
44
|
+
/**
|
|
45
|
+
* A tab can have only an icon slot filled and no content.
|
|
46
|
+
*/
|
|
47
|
+
iconOnly: boolean;
|
|
39
48
|
/**
|
|
40
|
-
* If this tab is selected
|
|
49
|
+
* If this tab is selected
|
|
41
50
|
*/
|
|
42
|
-
selected
|
|
51
|
+
selected: boolean;
|
|
43
52
|
/**
|
|
44
53
|
* A tab can be either 'small' or 'medium' size.
|
|
45
54
|
*/
|
|
@@ -15,4 +15,6 @@ tslib_1.__exportStar(require("./renderTab"), exports);
|
|
|
15
15
|
tslib_1.__exportStar(require("./useTab"), exports);
|
|
16
16
|
|
|
17
17
|
tslib_1.__exportStar(require("./useTabStyles"), exports);
|
|
18
|
+
|
|
19
|
+
tslib_1.__exportStar(require("./useTabAnimatedIndicator"), exports);
|
|
18
20
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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/"}
|
|
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;;AACA,OAAA,CAAA,YAAA,CAAA,OAAA,CAAA,2BAAA,CAAA,EAAA,OAAA","sourcesContent":["export * from './Tab';\nexport * from './Tab.types';\nexport * from './renderTab';\nexport * from './useTab';\nexport * from './useTabStyles';\nexport * from './useTabAnimatedIndicator';\n"],"sourceRoot":"../src/"}
|
|
@@ -11,7 +11,6 @@ const react_utilities_1 = /*#__PURE__*/require("@fluentui/react-utilities");
|
|
|
11
11
|
/**
|
|
12
12
|
* Render the final JSX of Tab
|
|
13
13
|
*/
|
|
14
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
15
14
|
|
|
16
15
|
|
|
17
16
|
const renderTab_unstable = state => {
|
|
@@ -21,7 +20,7 @@ const renderTab_unstable = state => {
|
|
|
21
20
|
} = react_utilities_1.getSlots(state);
|
|
22
21
|
return React.createElement(slots.root, { ...slotProps.root
|
|
23
22
|
}, slots.icon && React.createElement(slots.icon, { ...slotProps.icon
|
|
24
|
-
}), React.createElement(slots.content, { ...slotProps.content
|
|
23
|
+
}), !state.iconOnly && React.createElement(slots.content, { ...slotProps.content
|
|
25
24
|
}));
|
|
26
25
|
};
|
|
27
26
|
|
|
@@ -1 +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
|
|
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;;;AACI,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,EAEG,CAAC,KAAK,CAAC,QAAP,IAAmB,KAAA,CAAA,aAAA,CAAC,KAAK,CAAC,OAAP,EAAc,EAAA,GAAK,SAAS,CAAC;AAAf,GAAd,CAFtB,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 */\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 {!state.iconOnly && <slots.content {...slotProps.content} />}\n </slots.root>\n );\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -21,36 +21,28 @@ const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-s
|
|
|
21
21
|
* @param props - props from this instance of Tab
|
|
22
22
|
* @param ref - reference to root HTMLElement of Tab
|
|
23
23
|
*/
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
25
24
|
|
|
26
25
|
|
|
27
26
|
const useTab_unstable = (props, ref) => {
|
|
28
27
|
const {
|
|
29
28
|
content,
|
|
29
|
+
disabled: tabDisabled = false,
|
|
30
30
|
icon,
|
|
31
31
|
value
|
|
32
32
|
} = props;
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
}));
|
|
33
|
+
const appearance = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.appearance);
|
|
34
|
+
const listDisabled = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.disabled);
|
|
35
|
+
const selected = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.selectedValue === value);
|
|
36
|
+
const onRegister = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.onRegister);
|
|
37
|
+
const onUnregister = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.onUnregister);
|
|
38
|
+
const onSelect = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.onSelect);
|
|
39
|
+
const size = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.size);
|
|
40
|
+
const vertical = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => !!ctx.vertical);
|
|
41
|
+
const disabled = listDisabled || tabDisabled;
|
|
42
|
+
const innerRef = React.useRef(null);
|
|
50
43
|
const onClick = react_utilities_1.useEventCallback(event => onSelect(event, {
|
|
51
44
|
value
|
|
52
45
|
}));
|
|
53
|
-
const innerRef = React.useRef(null);
|
|
54
46
|
React.useEffect(() => {
|
|
55
47
|
onRegister({
|
|
56
48
|
value,
|
|
@@ -63,27 +55,31 @@ const useTab_unstable = (props, ref) => {
|
|
|
63
55
|
});
|
|
64
56
|
};
|
|
65
57
|
}, [onRegister, onUnregister, innerRef, value]);
|
|
58
|
+
const iconShorthand = react_utilities_1.resolveShorthand(icon);
|
|
59
|
+
const contentShorthand = react_utilities_1.resolveShorthand(content, {
|
|
60
|
+
required: true,
|
|
61
|
+
defaultProps: {
|
|
62
|
+
children: props.children
|
|
63
|
+
}
|
|
64
|
+
});
|
|
66
65
|
return {
|
|
67
66
|
components: {
|
|
68
|
-
root: '
|
|
67
|
+
root: 'button',
|
|
69
68
|
icon: 'span',
|
|
70
69
|
content: 'span'
|
|
71
70
|
},
|
|
72
|
-
root: react_utilities_1.getNativeElementProps('
|
|
71
|
+
root: react_utilities_1.getNativeElementProps('button', {
|
|
73
72
|
ref: react_utilities_1.useMergedRefs(ref, innerRef),
|
|
74
73
|
role: 'tab',
|
|
75
|
-
tabIndex: 0,
|
|
76
74
|
...props,
|
|
75
|
+
disabled,
|
|
77
76
|
onClick
|
|
78
77
|
}),
|
|
79
|
-
icon:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
defaultProps: {
|
|
83
|
-
children: props.children
|
|
84
|
-
}
|
|
85
|
-
}),
|
|
78
|
+
icon: iconShorthand,
|
|
79
|
+
iconOnly: Boolean((iconShorthand === null || iconShorthand === void 0 ? void 0 : iconShorthand.children) && !contentShorthand.children),
|
|
80
|
+
content: contentShorthand,
|
|
86
81
|
appearance,
|
|
82
|
+
disabled,
|
|
87
83
|
selected,
|
|
88
84
|
size,
|
|
89
85
|
value,
|
|
@@ -1 +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
|
|
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;;;AACI,MAAM,eAAe,GAAG,CAAC,KAAD,EAAkB,GAAlB,KAA2D;AACxF,QAAM;AAAE,IAAA,OAAF;AAAW,IAAA,QAAQ,EAAE,WAAW,GAAG,K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IAAA,QAjBK;AAkBL,IAAA,QAlBK;AAmBL,IAAA,IAnBK;AAoBL,IAAA,KApBK;AAqBL,IAAA;AArBK,GAAP;AAuBD,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 */\nexport const useTab_unstable = (props: TabProps, ref: React.Ref<HTMLElement>): TabState => {\n const { content, disabled: tabDisabled = false, icon, value } = props;\n\n const appearance = useContextSelector(TabListContext, ctx => ctx.appearance);\n const listDisabled = useContextSelector(TabListContext, ctx => ctx.disabled);\n const selected = useContextSelector(TabListContext, ctx => ctx.selectedValue === value);\n const onRegister = useContextSelector(TabListContext, ctx => ctx.onRegister);\n const onUnregister = useContextSelector(TabListContext, ctx => ctx.onUnregister);\n const onSelect = useContextSelector(TabListContext, ctx => ctx.onSelect);\n const size = useContextSelector(TabListContext, ctx => ctx.size);\n const vertical = useContextSelector(TabListContext, ctx => !!ctx.vertical);\n const disabled = listDisabled || tabDisabled;\n\n const innerRef = React.useRef<HTMLElement>(null);\n const onClick = useEventCallback((event: SelectTabEvent) => onSelect(event, { value }));\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 const iconShorthand = resolveShorthand(icon);\n const contentShorthand = resolveShorthand(content, { required: true, defaultProps: { children: props.children } });\n return {\n components: {\n root: 'button',\n icon: 'span',\n content: 'span',\n },\n root: getNativeElementProps('button', {\n ref: useMergedRefs(ref, innerRef),\n role: 'tab',\n ...props,\n disabled,\n onClick,\n }),\n icon: iconShorthand,\n iconOnly: Boolean(iconShorthand?.children && !contentShorthand.children),\n content: contentShorthand,\n appearance,\n disabled,\n selected,\n size,\n value,\n vertical,\n };\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useTabAnimatedIndicatorStyles_unstable = void 0;
|
|
7
|
+
|
|
8
|
+
const React = /*#__PURE__*/require("react");
|
|
9
|
+
|
|
10
|
+
const react_1 = /*#__PURE__*/require("@griffel/react");
|
|
11
|
+
|
|
12
|
+
const tab_constants_1 = /*#__PURE__*/require("../../tab.constants");
|
|
13
|
+
|
|
14
|
+
const react_context_selector_1 = /*#__PURE__*/require("@fluentui/react-context-selector");
|
|
15
|
+
|
|
16
|
+
const TabListContext_1 = /*#__PURE__*/require("../TabList/TabListContext"); // eslint-disable-next-line @typescript-eslint/naming-convention
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
const tabIndicatorCssVars_unstable = {
|
|
20
|
+
offsetVar: '--fui-Tab__indicator--offset',
|
|
21
|
+
scaleVar: '--fui-Tab__indicator--scale'
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const useActiveIndicatorStyles = /*#__PURE__*/react_1.__styles({
|
|
25
|
+
"base": {
|
|
26
|
+
"B68tc82": "f1mtd64y",
|
|
27
|
+
"Bmxbyg5": "f1y7q3j9"
|
|
28
|
+
},
|
|
29
|
+
"animated": {
|
|
30
|
+
"wbfbqe": "fopw4to",
|
|
31
|
+
"mafdb0": "f8wx3i3",
|
|
32
|
+
"Jgwf15": "fgw312z",
|
|
33
|
+
"Bh4j9q1": "f1cif4e6",
|
|
34
|
+
"Gk6w4d": "fa42t5a"
|
|
35
|
+
},
|
|
36
|
+
"horizontal": {
|
|
37
|
+
"Blx6ldh": ["f1g89gis", "fcjnwxz"],
|
|
38
|
+
"xn0juu": "f7m34ad"
|
|
39
|
+
},
|
|
40
|
+
"vertical": {
|
|
41
|
+
"Blx6ldh": "fqfgdei",
|
|
42
|
+
"xn0juu": "fwvsziq"
|
|
43
|
+
}
|
|
44
|
+
}, {
|
|
45
|
+
"d": [".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".fopw4to:after{transition-property:transform;}", ".f8wx3i3:after{transition-duration:300ms;}", ".fgw312z:after{transition-timing-function:cubic-bezier(0,0,0,1);}", ".f1g89gis:after{transform-origin:left;}", ".fcjnwxz:after{transform-origin:right;}", ".f7m34ad:after{-webkit-transform:translateX(var(--fui-Tab__indicator--offset)) scaleX(var(--fui-Tab__indicator--scale));-moz-transform:translateX(var(--fui-Tab__indicator--offset)) scaleX(var(--fui-Tab__indicator--scale));-ms-transform:translateX(var(--fui-Tab__indicator--offset)) scaleX(var(--fui-Tab__indicator--scale));transform:translateX(var(--fui-Tab__indicator--offset)) scaleX(var(--fui-Tab__indicator--scale));}", ".fqfgdei:after{transform-origin:top;}", ".fwvsziq:after{-webkit-transform:translateY(var(--fui-Tab__indicator--offset)) scaleY(var(--fui-Tab__indicator--scale));-moz-transform:translateY(var(--fui-Tab__indicator--offset)) scaleY(var(--fui-Tab__indicator--scale));-ms-transform:translateY(var(--fui-Tab__indicator--offset)) scaleY(var(--fui-Tab__indicator--scale));transform:translateY(var(--fui-Tab__indicator--offset)) scaleY(var(--fui-Tab__indicator--scale));}"],
|
|
46
|
+
"t": ["@media (prefers-reduced-motion: reduce){.f1cif4e6:after{transition-property:none;}}", "@media (prefers-reduced-motion: reduce){.fa42t5a:after{transition-duration:0.01ms;}}"]
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const calculateTabRect = element => {
|
|
50
|
+
var _a;
|
|
51
|
+
|
|
52
|
+
if (element) {
|
|
53
|
+
const parentRect = ((_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
|
|
54
|
+
x: 0,
|
|
55
|
+
y: 0,
|
|
56
|
+
width: 0,
|
|
57
|
+
height: 0
|
|
58
|
+
};
|
|
59
|
+
const tabRect = element.getBoundingClientRect();
|
|
60
|
+
return {
|
|
61
|
+
x: tabRect.x - parentRect.x,
|
|
62
|
+
y: tabRect.y - parentRect.y,
|
|
63
|
+
width: tabRect.width,
|
|
64
|
+
height: tabRect.height
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return undefined;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const getRegisteredTabRect = (registeredTabs, value) => {
|
|
72
|
+
var _a;
|
|
73
|
+
|
|
74
|
+
const element = value ? (_a = registeredTabs[JSON.stringify(value)]) === null || _a === void 0 ? void 0 : _a.ref.current : undefined;
|
|
75
|
+
return element ? calculateTabRect(element) : undefined;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Adds additional styling to the active tab selection indicator to create a sliding animation.
|
|
79
|
+
*/
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
const useTabAnimatedIndicatorStyles_unstable = state => {
|
|
83
|
+
const {
|
|
84
|
+
disabled,
|
|
85
|
+
selected,
|
|
86
|
+
vertical
|
|
87
|
+
} = state;
|
|
88
|
+
const activeIndicatorStyles = useActiveIndicatorStyles();
|
|
89
|
+
const [lastAnimatedFrom, setLastAnimatedFrom] = React.useState();
|
|
90
|
+
const [animationValues, setAnimationValues] = React.useState({
|
|
91
|
+
offset: 0,
|
|
92
|
+
scale: 1
|
|
93
|
+
});
|
|
94
|
+
const getRegisteredTabs = react_context_selector_1.useContextSelector(TabListContext_1.TabListContext, ctx => ctx.getRegisteredTabs);
|
|
95
|
+
React.useEffect(() => {
|
|
96
|
+
if (lastAnimatedFrom) {
|
|
97
|
+
setAnimationValues({
|
|
98
|
+
offset: 0,
|
|
99
|
+
scale: 1
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}, [lastAnimatedFrom]);
|
|
103
|
+
|
|
104
|
+
if (selected) {
|
|
105
|
+
const {
|
|
106
|
+
previousSelectedValue,
|
|
107
|
+
selectedValue,
|
|
108
|
+
registeredTabs
|
|
109
|
+
} = getRegisteredTabs();
|
|
110
|
+
const previousSelectedTabRect = getRegisteredTabRect(registeredTabs, previousSelectedValue);
|
|
111
|
+
const selectedTabRect = getRegisteredTabRect(registeredTabs, selectedValue);
|
|
112
|
+
|
|
113
|
+
if (selectedTabRect && previousSelectedTabRect && previousSelectedValue && lastAnimatedFrom !== previousSelectedValue) {
|
|
114
|
+
const offset = vertical ? previousSelectedTabRect.y - selectedTabRect.y : previousSelectedTabRect.x - selectedTabRect.x;
|
|
115
|
+
const scale = vertical ? previousSelectedTabRect.height / selectedTabRect.height : previousSelectedTabRect.width / selectedTabRect.width;
|
|
116
|
+
setAnimationValues({
|
|
117
|
+
offset,
|
|
118
|
+
scale
|
|
119
|
+
});
|
|
120
|
+
setLastAnimatedFrom(previousSelectedValue);
|
|
121
|
+
}
|
|
122
|
+
} else if (lastAnimatedFrom) {
|
|
123
|
+
// need to clear the last animated from so that if this tab is selected again
|
|
124
|
+
// from the same previous tab as last time, that animation still happens.
|
|
125
|
+
setLastAnimatedFrom(undefined);
|
|
126
|
+
} // do not apply any animation if the tab is disabled
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if (disabled) {
|
|
130
|
+
return state;
|
|
131
|
+
} // the animation should only happen as the selection indicator returns to its
|
|
132
|
+
// original position and not when set at the previous tabs position.
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
const animating = animationValues.offset === 0 && animationValues.scale === 1;
|
|
136
|
+
state.root.className = react_1.mergeClasses(state.root.className, selected && activeIndicatorStyles.base, selected && animating && activeIndicatorStyles.animated, selected && (vertical ? activeIndicatorStyles.vertical : activeIndicatorStyles.horizontal));
|
|
137
|
+
const rootCssVars = {
|
|
138
|
+
[tabIndicatorCssVars_unstable.offsetVar]: `${animationValues.offset}px`,
|
|
139
|
+
[tabIndicatorCssVars_unstable.scaleVar]: `${animationValues.scale}`
|
|
140
|
+
};
|
|
141
|
+
state.root.style = { ...rootCssVars,
|
|
142
|
+
...state.root.style
|
|
143
|
+
};
|
|
144
|
+
return state;
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
exports.useTabAnimatedIndicatorStyles_unstable = useTabAnimatedIndicatorStyles_unstable;
|
|
148
|
+
//# sourceMappingURL=useTabAnimatedIndicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["components/Tab/useTabAnimatedIndicator.ts"],"names":[],"mappings":";;;;;;;AAAA,MAAA,KAAA,gBAAA,OAAA,CAAA,OAAA,CAAA;;AAGA,MAAA,OAAA,gBAAA,OAAA,CAAA,gBAAA,CAAA;;AACA,MAAA,eAAA,gBAAA,OAAA,CAAA,qBAAA,CAAA;;AACA,MAAA,wBAAA,gBAAA,OAAA,CAAA,kCAAA,CAAA;;AACA,MAAA,gBAAA,gBAAA,OAAA,CAAA,2BAAA,CAAA,C,CAGA;;;AACA,MAAM,4BAA4B,GAAG;AACnC,EAAA,SAAS,EAAE,8BADwB;AAEnC,EAAA,QAAQ,EAAE;AAFyB,CAArC;;AAKA,MAAM,wBAAwB,gBAAG,OAAA,SAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAjC;;AAkCA,MAAM,gBAAgB,GAAI,OAAD,IAAyB;;;AAChD,MAAI,OAAJ,EAAa;AACX,UAAM,UAAU,GAAG,CAAA,CAAA,EAAA,GAAA,OAAO,CAAC,aAAR,MAAqB,IAArB,IAAqB,EAAA,KAAA,KAAA,CAArB,GAAqB,KAAA,CAArB,GAAqB,EAAA,CAAE,qBAAF,EAArB,KAAkD;AAAE,MAAA,CAAC,EAAE,CAAL;AAA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,KAA2B,CAA3B,IAAgC,eAAe,CAAC,KAAhB,KAA0B,CAA5E;AAEA,EAAA,KAAK,CAAC,IAAN,CAAW,SAAX,GAAuB,OAAA,CAAA,YAAA,CACrB,KAAK,CAAC,IAAN,CAAW,SADU,EAErB,QAAQ,IAAI,qBAAqB,CAAC,IAFb,EAGrB,QAAQ,IAAI,SAAZ,IAAyB,qBAAqB,CAAC,QAH1B,EAIrB,QAAQ,KAAK,QAAQ,GAAG,qBAAqB,CAAC,QAAzB,GAAoC,qBAAqB,CAAC,UAAvE,CAJa,CAAvB;AAOA,QAAM,WAAW,GAAG;AAClB,KAAC,4BAA4B,CAAC,SAA9B,GAA0C,GAAG,eAAe,CAAC,MAAM,IADjD;AAElB,KAAC,4BAA4B,CAAC,QAA9B,GAAyC,GAAG,eAAe,CAAC,KAAK;AAF/C,GAApB;AAKA,EAAA,KAAK,CAAC,IAAN,CAAW,KAAX,GAAmB,EACjB,GAAG,WADc;AAEjB,OAAG,KAAK,CAAC,IAAN,CAAW;AAFG,GAAnB;AAKA,SAAO,KAAP;AACD,CArEM;;AAAM,OAAA,CAAA,sCAAA,GAAsC,sCAAtC","sourcesContent":["import * as React from 'react';\nimport type { TabState, TabValue } from './Tab.types';\n\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { pendingAnimationDurationTokens, pendingAnimationEasingTokens } from '../../tab.constants';\nimport { useContextSelector } from '@fluentui/react-context-selector';\nimport { TabListContext } from '../TabList/TabListContext';\nimport { TabRegisterData } from '../TabList/TabList.types';\n\n// eslint-disable-next-line @typescript-eslint/naming-convention\nconst tabIndicatorCssVars_unstable = {\n offsetVar: '--fui-Tab__indicator--offset',\n scaleVar: '--fui-Tab__indicator--scale',\n};\n\nconst useActiveIndicatorStyles = makeStyles({\n base: {\n // overflow is required to allow the selection indicator to animate outside the tab area.\n ...shorthands.overflow('visible'),\n },\n animated: {\n ':after': {\n transitionProperty: 'transform',\n transitionDuration: `${pendingAnimationDurationTokens.slow}`,\n transitionTimingFunction: `${pendingAnimationEasingTokens.declerateMax}`,\n },\n '@media (prefers-reduced-motion: reduce)': {\n ':after': {\n transitionProperty: 'none',\n transitionDuration: '0.01ms',\n },\n },\n },\n horizontal: {\n ':after': {\n transformOrigin: 'left',\n transform: `translateX(var(${tabIndicatorCssVars_unstable.offsetVar}))\n scaleX(var(${tabIndicatorCssVars_unstable.scaleVar}))`,\n },\n },\n vertical: {\n ':after': {\n transformOrigin: 'top',\n transform: `translateY(var(${tabIndicatorCssVars_unstable.offsetVar}))\n scaleY(var(${tabIndicatorCssVars_unstable.scaleVar}))`,\n },\n },\n});\n\nconst calculateTabRect = (element: HTMLElement) => {\n if (element) {\n const parentRect = element.parentElement?.getBoundingClientRect() || { x: 0, y: 0, width: 0, height: 0 };\n const tabRect = element.getBoundingClientRect();\n\n return {\n x: tabRect.x - parentRect.x,\n y: tabRect.y - parentRect.y,\n width: tabRect.width,\n height: tabRect.height,\n };\n }\n return undefined;\n};\n\nconst getRegisteredTabRect = (registeredTabs: Record<string, TabRegisterData>, value?: TabValue) => {\n const element = value ? registeredTabs[JSON.stringify(value)]?.ref.current : undefined;\n return element ? calculateTabRect(element) : undefined;\n};\n\n/**\n * Adds additional styling to the active tab selection indicator to create a sliding animation.\n */\nexport const useTabAnimatedIndicatorStyles_unstable = (state: TabState): TabState => {\n const { disabled, selected, vertical } = state;\n\n const activeIndicatorStyles = useActiveIndicatorStyles();\n const [lastAnimatedFrom, setLastAnimatedFrom] = React.useState<TabValue>();\n const [animationValues, setAnimationValues] = React.useState({ offset: 0, scale: 1 });\n const getRegisteredTabs = useContextSelector(TabListContext, ctx => ctx.getRegisteredTabs);\n\n React.useEffect(() => {\n if (lastAnimatedFrom) {\n setAnimationValues({ offset: 0, scale: 1 });\n }\n }, [lastAnimatedFrom]);\n\n if (selected) {\n const { previousSelectedValue, selectedValue, registeredTabs } = getRegisteredTabs();\n const previousSelectedTabRect = getRegisteredTabRect(registeredTabs, previousSelectedValue);\n const selectedTabRect = getRegisteredTabRect(registeredTabs, selectedValue);\n\n if (\n selectedTabRect &&\n previousSelectedTabRect &&\n previousSelectedValue &&\n lastAnimatedFrom !== previousSelectedValue\n ) {\n const offset = vertical\n ? previousSelectedTabRect.y - selectedTabRect.y\n : previousSelectedTabRect.x - selectedTabRect.x;\n\n const scale = vertical\n ? previousSelectedTabRect.height / selectedTabRect.height\n : previousSelectedTabRect.width / selectedTabRect.width;\n\n setAnimationValues({ offset, scale });\n setLastAnimatedFrom(previousSelectedValue);\n }\n } else if (lastAnimatedFrom) {\n // need to clear the last animated from so that if this tab is selected again\n // from the same previous tab as last time, that animation still happens.\n setLastAnimatedFrom(undefined);\n }\n\n // do not apply any animation if the tab is disabled\n if (disabled) {\n return state;\n }\n\n // the animation should only happen as the selection indicator returns to its\n // original position and not when set at the previous tabs position.\n const animating = animationValues.offset === 0 && animationValues.scale === 1;\n\n state.root.className = mergeClasses(\n state.root.className,\n selected && activeIndicatorStyles.base,\n selected && animating && activeIndicatorStyles.animated,\n selected && (vertical ? activeIndicatorStyles.vertical : activeIndicatorStyles.horizontal),\n );\n\n const rootCssVars = {\n [tabIndicatorCssVars_unstable.offsetVar]: `${animationValues.offset}px`,\n [tabIndicatorCssVars_unstable.scaleVar]: `${animationValues.scale}`,\n };\n\n state.root.style = {\n ...rootCssVars,\n ...state.root.style,\n };\n\n return state;\n};\n"],"sourceRoot":"../src/"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import type { TabState } from './Tab.types';
|
|
2
|
-
|
|
1
|
+
import type { TabSlots, TabState } from './Tab.types';
|
|
2
|
+
import { SlotClassNames } from '@fluentui/react-utilities';
|
|
3
|
+
export declare const tabClassNames: SlotClassNames<TabSlots>;
|
|
4
|
+
export declare const tabClassName: string;
|
|
3
5
|
/**
|
|
4
6
|
* Apply styling to the Tab slots based on the state
|
|
5
7
|
*/
|