@fluentui/react-tabs 9.1.4 → 9.1.5
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 +54 -1
- package/CHANGELOG.md +15 -2
- package/lib/components/Tab/Tab.js +0 -1
- package/lib/components/Tab/Tab.js.map +1 -1
- package/lib/components/Tab/renderTab.js +8 -5
- package/lib/components/Tab/renderTab.js.map +1 -1
- package/lib/components/Tab/useTab.js +0 -1
- package/lib/components/Tab/useTab.js.map +1 -1
- package/lib/components/Tab/useTabAnimatedIndicator.js +27 -38
- package/lib/components/Tab/useTabAnimatedIndicator.js.map +1 -1
- package/lib/components/Tab/useTabStyles.js +334 -349
- package/lib/components/Tab/useTabStyles.js.map +1 -1
- package/lib/components/TabList/TabList.js +0 -1
- package/lib/components/TabList/TabList.js.map +1 -1
- package/lib/components/TabList/TabListContext.js +2 -2
- package/lib/components/TabList/TabListContext.js.map +1 -1
- package/lib/components/TabList/renderTabList.js +2 -2
- package/lib/components/TabList/renderTabList.js.map +1 -1
- package/lib/components/TabList/useTabList.js +2 -3
- package/lib/components/TabList/useTabList.js.map +1 -1
- package/lib/components/TabList/useTabListContextValues.js.map +1 -1
- package/lib/components/TabList/useTabListStyles.js +13 -16
- package/lib/components/TabList/useTabListStyles.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib-commonjs/Tab.js +0 -2
- package/lib-commonjs/Tab.js.map +1 -1
- package/lib-commonjs/TabList.js +0 -2
- package/lib-commonjs/TabList.js.map +1 -1
- package/lib-commonjs/components/Tab/Tab.js +0 -6
- package/lib-commonjs/components/Tab/Tab.js.map +1 -1
- package/lib-commonjs/components/Tab/Tab.types.js.map +1 -1
- package/lib-commonjs/components/Tab/index.js +0 -7
- package/lib-commonjs/components/Tab/index.js.map +1 -1
- package/lib-commonjs/components/Tab/renderTab.js +8 -9
- package/lib-commonjs/components/Tab/renderTab.js.map +1 -1
- package/lib-commonjs/components/Tab/useTab.js +0 -7
- package/lib-commonjs/components/Tab/useTab.js.map +1 -1
- package/lib-commonjs/components/Tab/useTabAnimatedIndicator.js +27 -45
- package/lib-commonjs/components/Tab/useTabAnimatedIndicator.js.map +1 -1
- package/lib-commonjs/components/Tab/useTabStyles.js +334 -355
- package/lib-commonjs/components/Tab/useTabStyles.js.map +1 -1
- package/lib-commonjs/components/TabList/TabList.js +0 -7
- package/lib-commonjs/components/TabList/TabList.js.map +1 -1
- package/lib-commonjs/components/TabList/TabList.types.js.map +1 -1
- package/lib-commonjs/components/TabList/TabListContext.js +2 -4
- package/lib-commonjs/components/TabList/TabListContext.js.map +1 -1
- package/lib-commonjs/components/TabList/index.js +0 -6
- package/lib-commonjs/components/TabList/index.js.map +1 -1
- package/lib-commonjs/components/TabList/renderTabList.js +2 -7
- package/lib-commonjs/components/TabList/renderTabList.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabList.js +2 -8
- package/lib-commonjs/components/TabList/useTabList.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabListContextValues.js +0 -2
- package/lib-commonjs/components/TabList/useTabListContextValues.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabListStyles.js +13 -19
- package/lib-commonjs/components/TabList/useTabListStyles.js.map +1 -1
- package/lib-commonjs/index.js +0 -4
- package/lib-commonjs/index.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.json
CHANGED
|
@@ -2,7 +2,60 @@
|
|
|
2
2
|
"name": "@fluentui/react-tabs",
|
|
3
3
|
"entries": [
|
|
4
4
|
{
|
|
5
|
-
"date": "Wed,
|
|
5
|
+
"date": "Wed, 04 Jan 2023 01:35:55 GMT",
|
|
6
|
+
"tag": "@fluentui/react-tabs_v9.1.5",
|
|
7
|
+
"version": "9.1.5",
|
|
8
|
+
"comments": {
|
|
9
|
+
"none": [
|
|
10
|
+
{
|
|
11
|
+
"author": "martinhochel@microsoft.com",
|
|
12
|
+
"package": "@fluentui/react-tabs",
|
|
13
|
+
"commit": "194b0cf0cc27c1c1233aa945f09b3ad29778d8ca",
|
|
14
|
+
"comment": "chore(scripts): use for @fluentui/scripts version within all package.json"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"author": "martinhochel@microsoft.com",
|
|
18
|
+
"package": "@fluentui/react-tabs",
|
|
19
|
+
"commit": "4ec2b998b294d6d9c3196d3d82893bdd97d0c105",
|
|
20
|
+
"comment": "chore(scripts): move index.ts to to follow sub-folder domain packaging"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"patch": [
|
|
24
|
+
{
|
|
25
|
+
"author": "olfedias@microsoft.com",
|
|
26
|
+
"package": "@fluentui/react-tabs",
|
|
27
|
+
"commit": "2c38f1e4ae07b2b60df596efe11015a68f166dbf",
|
|
28
|
+
"comment": "chore: Update Griffel to latest version"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"author": "beachball",
|
|
32
|
+
"package": "@fluentui/react-tabs",
|
|
33
|
+
"comment": "Bump @fluentui/react-context-selector to v9.1.4",
|
|
34
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"author": "beachball",
|
|
38
|
+
"package": "@fluentui/react-tabs",
|
|
39
|
+
"comment": "Bump @fluentui/react-tabster to v9.3.5",
|
|
40
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"author": "beachball",
|
|
44
|
+
"package": "@fluentui/react-tabs",
|
|
45
|
+
"comment": "Bump @fluentui/react-utilities to v9.3.1",
|
|
46
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
"author": "beachball",
|
|
50
|
+
"package": "@fluentui/react-tabs",
|
|
51
|
+
"comment": "Bump @fluentui/react-conformance-griffel to v9.0.0-beta.19",
|
|
52
|
+
"commit": "3e322d15529451be153e97298873253e21af4082"
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"date": "Wed, 21 Dec 2022 10:20:33 GMT",
|
|
6
59
|
"tag": "@fluentui/react-tabs_v9.1.4",
|
|
7
60
|
"version": "9.1.4",
|
|
8
61
|
"comments": {
|
package/CHANGELOG.md
CHANGED
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-tabs
|
|
2
2
|
|
|
3
|
-
This log was last generated on Wed,
|
|
3
|
+
This log was last generated on Wed, 04 Jan 2023 01:35:55 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.1.5](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabs_v9.1.5)
|
|
8
|
+
|
|
9
|
+
Wed, 04 Jan 2023 01:35:55 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabs_v9.1.4..@fluentui/react-tabs_v9.1.5)
|
|
11
|
+
|
|
12
|
+
### Patches
|
|
13
|
+
|
|
14
|
+
- chore: Update Griffel to latest version ([PR #26045](https://github.com/microsoft/fluentui/pull/26045) by olfedias@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-context-selector to v9.1.4 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
|
16
|
+
- Bump @fluentui/react-tabster to v9.3.5 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
|
17
|
+
- Bump @fluentui/react-utilities to v9.3.1 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
|
18
|
+
- Bump @fluentui/react-conformance-griffel to v9.0.0-beta.19 ([PR #26114](https://github.com/microsoft/fluentui/pull/26114) by beachball)
|
|
19
|
+
|
|
7
20
|
## [9.1.4](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabs_v9.1.4)
|
|
8
21
|
|
|
9
|
-
Wed, 21 Dec 2022 10:
|
|
22
|
+
Wed, 21 Dec 2022 10:20:33 GMT
|
|
10
23
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabs_v9.1.3..@fluentui/react-tabs_v9.1.4)
|
|
11
24
|
|
|
12
25
|
### Patches
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,eAAe,QAAQ,UAAU;AAC1C,SAASC,kBAAkB,QAAQ,aAAa;AAChD,SAASC,qBAAqB,QAAQ,gBAAgB;AAItD;;;AAGA,OAAO,MAAMC,GAAG,gBAAkCJ,KAAK,CAACK,UAAU,CAAC,CAACC,KAAK,EAAEC,GAAG,KAAI;EAChF,MAAMC,KAAK,GAAGP,eAAe,CAACK,KAAK,EAAEC,GAAG,CAAC;EAEzCJ,qBAAqB,CAACK,KAAK,CAAC;EAC5B,OAAON,kBAAkB,CAACM,KAAK,CAAC;AAClC,CAAC,CAAC;AAEFJ,GAAG,CAACK,WAAW,GAAG,KAAK","names":["React","useTab_unstable","renderTab_unstable","useTabStyles_unstable","Tab","forwardRef","props","ref","state","displayName"],"sourceRoot":"../src/","sources":["packages/react-components/react-tabs/src/components/Tab/Tab.tsx"],"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"]}
|
|
@@ -3,16 +3,19 @@ import { getSlots } from '@fluentui/react-utilities';
|
|
|
3
3
|
/**
|
|
4
4
|
* Render the final JSX of Tab
|
|
5
5
|
*/
|
|
6
|
-
|
|
7
6
|
export const renderTab_unstable = state => {
|
|
8
7
|
const {
|
|
9
8
|
slots,
|
|
10
9
|
slotProps
|
|
11
10
|
} = getSlots(state);
|
|
12
|
-
return /*#__PURE__*/React.createElement(slots.root, {
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
|
|
11
|
+
return /*#__PURE__*/React.createElement(slots.root, {
|
|
12
|
+
...slotProps.root
|
|
13
|
+
}, slots.icon && /*#__PURE__*/React.createElement(slots.icon, {
|
|
14
|
+
...slotProps.icon
|
|
15
|
+
}), !state.iconOnly && /*#__PURE__*/React.createElement(slots.content, {
|
|
16
|
+
...slotProps.content
|
|
17
|
+
}), !state.selected && !state.iconOnly && state.contentReservedSpaceClassName !== undefined && /*#__PURE__*/React.createElement(slots.content, {
|
|
18
|
+
...slotProps.content,
|
|
16
19
|
className: state.contentReservedSpaceClassName
|
|
17
20
|
}));
|
|
18
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,QAAQ,QAAQ,2BAA2B;AAGpD;;;AAGA,OAAO,MAAMC,kBAAkB,GAAIC,KAAe,IAAI;EACpD,MAAM;IAAEC,KAAK;IAAEC;EAAS,CAAE,GAAGJ,QAAQ,CAAWE,KAAK,CAAC;EAEtD,oBACEH,oBAACI,KAAK,CAACE,IAAI;IAAA,GAAKD,SAAS,CAACC;EAAI,GAC3BF,KAAK,CAACG,IAAI,iBAAIP,oBAACI,KAAK,CAACG,IAAI;IAAA,GAAKF,SAAS,CAACE;EAAI,EAAI,EAChD,CAACJ,KAAK,CAACK,QAAQ,iBAAIR,oBAACI,KAAK,CAACK,OAAO;IAAA,GAAKJ,SAAS,CAACI;EAAO,EAAI,EAC3D,CAACN,KAAK,CAACO,QAAQ,IAAI,CAACP,KAAK,CAACK,QAAQ,IAAIL,KAAK,CAACQ,6BAA6B,KAAKC,SAAS,iBACtFZ,oBAACI,KAAK,CAACK,OAAO;IAAA,GAAKJ,SAAS,CAACI,OAAO;IAAEI,SAAS,EAAEV,KAAK,CAACQ;EAA6B,EACrF,CACU;AAEjB,CAAC","names":["React","getSlots","renderTab_unstable","state","slots","slotProps","root","icon","iconOnly","content","selected","contentReservedSpaceClassName","undefined","className"],"sourceRoot":"../src/","sources":["packages/react-components/react-tabs/src/components/Tab/renderTab.tsx"],"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 {!state.selected && !state.iconOnly && state.contentReservedSpaceClassName !== undefined && (\n <slots.content {...slotProps.content} className={state.contentReservedSpaceClassName} />\n )}\n </slots.root>\n );\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,qBAAqB,EAAEC,gBAAgB,EAAEC,gBAAgB,EAAEC,aAAa,QAAQ,2BAA2B;AAEpH,SAASC,cAAc,QAAQ,2BAA2B;AAC1D,SAASC,kBAAkB,QAAQ,kCAAkC;AAGrE;;;;;;;;;AASA,OAAO,MAAMC,eAAe,GAAG,CAACC,KAAe,EAAEC,GAA2B,KAAc;EACxF,MAAM;IAAEC,OAAO;IAAEC,QAAQ,EAAEC,WAAW,GAAG,KAAK;IAAEC,IAAI;IAAEC;EAAK,CAAE,GAAGN,KAAK;EAErE,MAAMO,UAAU,GAAGT,kBAAkB,CAACD,cAAc,EAAEW,GAAG,IAAIA,GAAG,CAACD,UAAU,CAAC;EAC5E,MAAME,uBAAuB,GAAGX,kBAAkB,CAACD,cAAc,EAAEW,GAAG,IAAIA,GAAG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MAAMiB,aAAa,GAAG7B,gBAAgB,CAACW,IAAI,CAAC;EAC5C,MAAMmB,gBAAgB,GAAG9B,gBAAgB,CAACQ,OAAO,EAAE;IAAEuB,QAAQ,EAAE,IAAI;IAAEC,YAAY,EAAE;MAAEC,QAAQ,EAAE3B,KAAK,CAAC2B;IAAQ;EAAE,CAAE,CAAC;EAClH,OAAO;IACLC,UAAU,EAAE;MACVC,IAAI,EAAE,QAAQ;MACdxB,IAAI,EAAE,MAAM;MACZH,OAAO,EAAE;KACV;IACD2B,IAAI,EAAEpC,qBAAqB,CAAC,QAAQ,EAAE;MACpCQ,GAAG,EAAEL,aAAa,CAACK,GAAG,EAAEiB,QAAQ,CAAC;MACjCY,IAAI,EAAE,KAAK;MACXC,IAAI,EAAE,QAAQ;MACd;MACA;MACA,eAAe,EAAE5B,QAAQ,GAAG6B,SAAS,GAAG,GAAGrB,QAAQ,EAAE;MACrD,GAAGX,KAAK;MACRG,QAAQ;MACRiB;KACD,CAAC;IACFf,IAAI,EAAEkB,aAAa;IACnBU,QAAQ,EAAEC,OAAO,CAAC,cAAa,aAAbX,aAAa,uBAAbA,aAAa,CAAEI,QAAQ,KAAI,CAACH,gBAAgB,CAACG,QAAQ,CAAC;IACxEzB,OAAO,EAAEsB,gBAAgB;IACzBjB,UAAU;IACV4B,6BAA6B,EAAE1B,uBAAuB,GAAG,EAAE,GAAGuB,SAAS;IACvE7B,QAAQ;IACRQ,QAAQ;IACRK,IAAI;IACJV,KAAK;IACLW;GACD;AACH,CAAC","names":["React","getNativeElementProps","resolveShorthand","useEventCallback","useMergedRefs","TabListContext","useContextSelector","useTab_unstable","props","ref","content","disabled","tabDisabled","icon","value","appearance","ctx","reserveSelectedTabSpace","listDisabled","selected","selectedValue","onRegister","onUnregister","onSelect","size","vertical","innerRef","useRef","onClick","event","useEffect","iconShorthand","contentShorthand","required","defaultProps","children","components","root","role","type","undefined","iconOnly","Boolean","contentReservedSpaceClassName"],"sourceRoot":"../src/","sources":["packages/react-components/react-tabs/src/components/Tab/useTab.ts"],"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 reserveSelectedTabSpace = useContextSelector(TabListContext, ctx => ctx.reserveSelectedTabSpace);\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 type: 'button',\n // aria-selected undefined indicates it is not selectable\n // according to https://www.w3.org/TR/wai-aria-1.1/#aria-selected\n 'aria-selected': disabled ? undefined : `${selected}`,\n ...props,\n disabled,\n onClick,\n }),\n icon: iconShorthand,\n iconOnly: Boolean(iconShorthand?.children && !contentShorthand.children),\n content: contentShorthand,\n appearance,\n contentReservedSpaceClassName: reserveSelectedTabSpace ? '' : undefined,\n disabled,\n selected,\n size,\n value,\n vertical,\n };\n};\n"]}
|
|
@@ -2,45 +2,42 @@ import * as React from 'react';
|
|
|
2
2
|
import { __styles, mergeClasses, shorthands } from '@griffel/react';
|
|
3
3
|
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
4
4
|
import { TabListContext } from '../TabList/TabListContext';
|
|
5
|
-
import { tokens } from '@fluentui/react-theme';
|
|
6
|
-
|
|
5
|
+
import { tokens } from '@fluentui/react-theme';
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
7
7
|
const tabIndicatorCssVars_unstable = {
|
|
8
8
|
offsetVar: '--fui-Tab__indicator--offset',
|
|
9
9
|
scaleVar: '--fui-Tab__indicator--scale'
|
|
10
10
|
};
|
|
11
|
-
|
|
12
11
|
const useActiveIndicatorStyles = /*#__PURE__*/__styles({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
base: {
|
|
13
|
+
B68tc82: "f1mtd64y",
|
|
14
|
+
Bmxbyg5: "f1y7q3j9"
|
|
16
15
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
animated: {
|
|
17
|
+
Ba2ppi3: "fhwpy7i",
|
|
18
|
+
F2fol1: "f6zz20j",
|
|
19
|
+
B1dyfl9: "f1ai4sc1",
|
|
20
|
+
B0vmy72: "f9qxlq5",
|
|
21
|
+
u9bimw: "f1aql376"
|
|
23
22
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
horizontal: {
|
|
24
|
+
sjv3b2: ["fug4aj8", "f1i5xzg7"],
|
|
25
|
+
b1kco5: "f1q7ujh"
|
|
27
26
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
vertical: {
|
|
28
|
+
sjv3b2: "f1hqboyk",
|
|
29
|
+
b1kco5: "f1dxupa6"
|
|
31
30
|
}
|
|
32
31
|
}, {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
d: [".f1mtd64y{overflow-x:visible;}", ".f1y7q3j9{overflow-y:visible;}", ".fhwpy7i::after{transition-property:transform;}", ".f6zz20j::after{transition-duration:var(--durationSlow);}", ".f1ai4sc1::after{transition-timing-function:var(--curveDecelerateMax);}", ".fug4aj8::after{transform-origin:left;}", ".f1i5xzg7::after{transform-origin:right;}", ".f1q7ujh::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));}", ".f1hqboyk::after{transform-origin:top;}", ".f1dxupa6::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));}"],
|
|
33
|
+
m: [["@media (prefers-reduced-motion: reduce){.f9qxlq5::after{transition-property:none;}}", {
|
|
34
|
+
m: "(prefers-reduced-motion: reduce)"
|
|
36
35
|
}], ["@media (prefers-reduced-motion: reduce){.f1aql376::after{transition-duration:0.01ms;}}", {
|
|
37
|
-
|
|
36
|
+
m: "(prefers-reduced-motion: reduce)"
|
|
38
37
|
}]]
|
|
39
38
|
});
|
|
40
|
-
|
|
41
39
|
const calculateTabRect = element => {
|
|
42
40
|
var _a;
|
|
43
|
-
|
|
44
41
|
if (element) {
|
|
45
42
|
const parentRect = ((_a = element.parentElement) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) || {
|
|
46
43
|
x: 0,
|
|
@@ -56,21 +53,16 @@ const calculateTabRect = element => {
|
|
|
56
53
|
height: tabRect.height
|
|
57
54
|
};
|
|
58
55
|
}
|
|
59
|
-
|
|
60
56
|
return undefined;
|
|
61
57
|
};
|
|
62
|
-
|
|
63
58
|
const getRegisteredTabRect = (registeredTabs, value) => {
|
|
64
59
|
var _a;
|
|
65
|
-
|
|
66
60
|
const element = value !== undefined && value !== null ? (_a = registeredTabs[JSON.stringify(value)]) === null || _a === void 0 ? void 0 : _a.ref.current : undefined;
|
|
67
61
|
return element ? calculateTabRect(element) : undefined;
|
|
68
62
|
};
|
|
69
63
|
/**
|
|
70
64
|
* Adds additional styling to the active tab selection indicator to create a sliding animation.
|
|
71
65
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
66
|
export const useTabAnimatedIndicatorStyles_unstable = state => {
|
|
75
67
|
const {
|
|
76
68
|
disabled,
|
|
@@ -92,7 +84,6 @@ export const useTabAnimatedIndicatorStyles_unstable = state => {
|
|
|
92
84
|
});
|
|
93
85
|
}
|
|
94
86
|
}, [lastAnimatedFrom]);
|
|
95
|
-
|
|
96
87
|
if (selected) {
|
|
97
88
|
const {
|
|
98
89
|
previousSelectedValue,
|
|
@@ -101,7 +92,6 @@ export const useTabAnimatedIndicatorStyles_unstable = state => {
|
|
|
101
92
|
} = getRegisteredTabs();
|
|
102
93
|
const previousSelectedTabRect = getRegisteredTabRect(registeredTabs, previousSelectedValue);
|
|
103
94
|
const selectedTabRect = getRegisteredTabRect(registeredTabs, selectedValue);
|
|
104
|
-
|
|
105
95
|
if (selectedTabRect && previousSelectedTabRect && previousSelectedValue && lastAnimatedFrom !== previousSelectedValue) {
|
|
106
96
|
const offset = vertical ? previousSelectedTabRect.y - selectedTabRect.y : previousSelectedTabRect.x - selectedTabRect.x;
|
|
107
97
|
const scale = vertical ? previousSelectedTabRect.height / selectedTabRect.height : previousSelectedTabRect.width / selectedTabRect.width;
|
|
@@ -115,22 +105,21 @@ export const useTabAnimatedIndicatorStyles_unstable = state => {
|
|
|
115
105
|
// need to clear the last animated from so that if this tab is selected again
|
|
116
106
|
// from the same previous tab as last time, that animation still happens.
|
|
117
107
|
setLastAnimatedFrom(undefined);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
108
|
+
}
|
|
109
|
+
// do not apply any animation if the tab is disabled
|
|
121
110
|
if (disabled) {
|
|
122
111
|
return state;
|
|
123
|
-
}
|
|
112
|
+
}
|
|
113
|
+
// the animation should only happen as the selection indicator returns to its
|
|
124
114
|
// original position and not when set at the previous tabs position.
|
|
125
|
-
|
|
126
|
-
|
|
127
115
|
const animating = animationValues.offset === 0 && animationValues.scale === 1;
|
|
128
116
|
state.root.className = mergeClasses(state.root.className, selected && activeIndicatorStyles.base, selected && animating && activeIndicatorStyles.animated, selected && (vertical ? activeIndicatorStyles.vertical : activeIndicatorStyles.horizontal));
|
|
129
117
|
const rootCssVars = {
|
|
130
118
|
[tabIndicatorCssVars_unstable.offsetVar]: `${animationValues.offset}px`,
|
|
131
119
|
[tabIndicatorCssVars_unstable.scaleVar]: `${animationValues.scale}`
|
|
132
120
|
};
|
|
133
|
-
state.root.style = {
|
|
121
|
+
state.root.style = {
|
|
122
|
+
...rootCssVars,
|
|
134
123
|
...state.root.style
|
|
135
124
|
};
|
|
136
125
|
return state;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAG9B,mBAAqBC,YAAY,EAAEC,UAAU,QAAQ,gBAAgB;AACrE,SAASC,kBAAkB,QAAQ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ClBc,uBAAuB,CAAC5B,MAAM,GAAG6B,eAAe,CAAC7B,MAAM,GACvD4B,uBAAuB,CAAC7B,KAAK,GAAG8B,eAAe,CAAC9B,KAAK;MAEzDqB,kBAAkB,CAAC;QAAEC,MAAM;QAAEC;MAAK,CAAE,CAAC;MACrCL,mBAAmB,CAACS,qBAAqB,CAAC;;GAE7C,MAAM,IAAIV,gBAAgB,EAAE;IAC3B;IACA;IACAC,mBAAmB,CAACf,SAAS,CAAC;;EAGhC;EACA,IAAIU,QAAQ,EAAE;IACZ,OAAOD,KAAK;;EAGd;EACA;EACA,MAAMmB,SAAS,GAAGX,eAAe,CAACE,MAAM,KAAK,CAAC,IAAIF,eAAe,CAACG,KAAK,KAAK,CAAC;EAE7EX,KAAK,CAACoB,IAAI,CAACC,SAAS,GAAGjD,YAAY,CACjC4B,KAAK,CAACoB,IAAI,CAACC,SAAS,EACpBnB,QAAQ,IAAIE,qBAAqB,CAACkB,IAAI,EACtCpB,QAAQ,IAAIiB,SAAS,IAAIf,qBAAqB,CAACmB,QAAQ,EACvDrB,QAAQ,KAAKC,QAAQ,GAAGC,qBAAqB,CAACD,QAAQ,GAAGC,qBAAqB,CAACoB,UAAU,CAAC,CAC3F;EAED,MAAMC,WAAW,GAAG;IAClB,CAAChD,4BAA4B,CAACC,SAAS,GAAG,GAAG8B,eAAe,CAACE,MAAM,IAAI;IACvE,CAACjC,4BAA4B,CAACE,QAAQ,GAAG,GAAG6B,eAAe,CAACG,KAAK;GAClE;EAEDX,KAAK,CAACoB,IAAI,CAACM,KAAK,GAAG;IACjB,GAAGD,WAAW;IACd,GAAGzB,KAAK,CAACoB,IAAI,CAACM;GACf;EAED,OAAO1B,KAAK;AACd,CAAC","names":["React","mergeClasses","shorthands","useContextSelector","TabListContext","tokens","tabIndicatorCssVars_unstable","offsetVar","scaleVar","useActiveIndicatorStyles","calculateTabRect","element","parentRect","parentElement","getBoundingClientRect","x","y","width","height","tabRect","undefined","getRegisteredTabRect","registeredTabs","value","JSON","stringify","ref","current","useTabAnimatedIndicatorStyles_unstable","state","disabled","selected","vertical","activeIndicatorStyles","lastAnimatedFrom","setLastAnimatedFrom","useState","animationValues","setAnimationValues","offset","scale","getRegisteredTabs","ctx","useEffect","previousSelectedValue","selectedValue","previousSelectedTabRect","selectedTabRect","animating","root","className","base","animated","horizontal","rootCssVars","style"],"sourceRoot":"../src/","sources":["packages/react-components/react-tabs/src/components/Tab/useTabAnimatedIndicator.ts"],"sourcesContent":["import * as React from 'react';\nimport type { TabState, TabValue } from './Tab.types';\n\nimport { makeStyles, mergeClasses, shorthands } from '@griffel/react';\nimport { useContextSelector } from '@fluentui/react-context-selector';\nimport { TabListContext } from '../TabList/TabListContext';\nimport { TabRegisterData } from '../TabList/TabList.types';\nimport { tokens } from '@fluentui/react-theme';\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: `${tokens.durationSlow}`,\n transitionTimingFunction: `${tokens.curveDecelerateMax}`,\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 =\n value !== undefined && value !== null ? 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"]}
|