@fluentui/react-tabs 9.3.59 → 9.4.0
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.md +18 -4
- package/dist/index.d.ts +7 -2
- package/lib/components/Tab/useTab.js +8 -4
- package/lib/components/Tab/useTab.js.map +1 -1
- package/lib/components/TabList/TabList.types.js.map +1 -1
- package/lib/components/TabList/TabListContext.js +1 -0
- package/lib/components/TabList/TabListContext.js.map +1 -1
- package/lib/components/TabList/useTabList.js +2 -1
- package/lib/components/TabList/useTabList.js.map +1 -1
- package/lib/components/TabList/useTabListContextValues.js +2 -1
- package/lib/components/TabList/useTabListContextValues.js.map +1 -1
- package/lib-commonjs/components/Tab/useTab.js +8 -4
- package/lib-commonjs/components/Tab/useTab.js.map +1 -1
- package/lib-commonjs/components/TabList/TabListContext.js +1 -0
- package/lib-commonjs/components/TabList/TabListContext.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabList.js +2 -1
- package/lib-commonjs/components/TabList/useTabList.js.map +1 -1
- package/lib-commonjs/components/TabList/useTabListContextValues.js +2 -1
- package/lib-commonjs/components/TabList/useTabListContextValues.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,18 +1,32 @@
|
|
|
1
1
|
# Change Log - @fluentui/react-tabs
|
|
2
2
|
|
|
3
|
-
This log was last generated on Thu,
|
|
3
|
+
This log was last generated on Thu, 14 Dec 2023 09:51:36 GMT and should not be manually modified.
|
|
4
4
|
|
|
5
5
|
<!-- Start content -->
|
|
6
6
|
|
|
7
|
+
## [9.4.0](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabs_v9.4.0)
|
|
8
|
+
|
|
9
|
+
Thu, 14 Dec 2023 09:51:36 GMT
|
|
10
|
+
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabs_v9.3.59..@fluentui/react-tabs_v9.4.0)
|
|
11
|
+
|
|
12
|
+
### Minor changes
|
|
13
|
+
|
|
14
|
+
- feat: added select tab on focus behavior ([PR #29854](https://github.com/microsoft/fluentui/pull/29854) by gcox@microsoft.com)
|
|
15
|
+
- Bump @fluentui/react-context-selector to v9.1.43 ([commit](https://github.com/microsoft/fluentui/commit/80a1b02be2fbbdde916ac87fbf760e442a2295c4) by beachball)
|
|
16
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.21 ([commit](https://github.com/microsoft/fluentui/commit/80a1b02be2fbbdde916ac87fbf760e442a2295c4) by beachball)
|
|
17
|
+
- Bump @fluentui/react-shared-contexts to v9.13.1 ([commit](https://github.com/microsoft/fluentui/commit/80a1b02be2fbbdde916ac87fbf760e442a2295c4) by beachball)
|
|
18
|
+
- Bump @fluentui/react-tabster to v9.15.1 ([commit](https://github.com/microsoft/fluentui/commit/80a1b02be2fbbdde916ac87fbf760e442a2295c4) by beachball)
|
|
19
|
+
- Bump @fluentui/react-utilities to v9.15.3 ([commit](https://github.com/microsoft/fluentui/commit/80a1b02be2fbbdde916ac87fbf760e442a2295c4) by beachball)
|
|
20
|
+
|
|
7
21
|
## [9.3.59](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabs_v9.3.59)
|
|
8
22
|
|
|
9
|
-
Thu, 30 Nov 2023 13:
|
|
23
|
+
Thu, 30 Nov 2023 13:42:08 GMT
|
|
10
24
|
[Compare changes](https://github.com/microsoft/fluentui/compare/@fluentui/react-tabs_v9.3.58..@fluentui/react-tabs_v9.3.59)
|
|
11
25
|
|
|
12
26
|
### Patches
|
|
13
27
|
|
|
14
|
-
- Bump @fluentui/react-jsx-runtime to v9.0.20 ([PR #
|
|
15
|
-
- Bump @fluentui/react-tabster to v9.15.0 ([PR #
|
|
28
|
+
- Bump @fluentui/react-jsx-runtime to v9.0.20 ([PR #29929](https://github.com/microsoft/fluentui/pull/29929) by beachball)
|
|
29
|
+
- Bump @fluentui/react-tabster to v9.15.0 ([PR #29929](https://github.com/microsoft/fluentui/pull/29929) by beachball)
|
|
16
30
|
|
|
17
31
|
## [9.3.58](https://github.com/microsoft/fluentui/tree/@fluentui/react-tabs_v9.3.58)
|
|
18
32
|
|
package/dist/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export declare type SelectTabData = {
|
|
|
28
28
|
value: TabValue;
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
export declare type SelectTabEvent<E = HTMLElement> = React_2.MouseEvent<E> | React_2.KeyboardEvent<E>;
|
|
31
|
+
export declare type SelectTabEvent<E = HTMLElement> = React_2.MouseEvent<E> | React_2.KeyboardEvent<E> | React_2.FocusEvent<E>;
|
|
32
32
|
|
|
33
33
|
export declare type SelectTabEventHandler = (event: SelectTabEvent, data: SelectTabData) => void;
|
|
34
34
|
|
|
@@ -50,7 +50,7 @@ export declare const TabList: ForwardRefComponent<TabListProps>;
|
|
|
50
50
|
|
|
51
51
|
export declare const tabListClassNames: SlotClassNames<TabListSlots>;
|
|
52
52
|
|
|
53
|
-
export declare type TabListContextValue = Pick<TabListProps, 'onTabSelect' | 'selectedValue' | 'reserveSelectedTabSpace'> & Required<Pick<TabListProps, 'appearance' | 'disabled' | 'size' | 'vertical'>> & {
|
|
53
|
+
export declare type TabListContextValue = Pick<TabListProps, 'onTabSelect' | 'selectTabOnFocus' | 'selectedValue' | 'reserveSelectedTabSpace'> & Required<Pick<TabListProps, 'appearance' | 'disabled' | 'size' | 'vertical'>> & {
|
|
54
54
|
/** A callback to allow a tab to register itself with the tab list. */
|
|
55
55
|
onRegister: RegisterTabEventHandler;
|
|
56
56
|
/** A callback to allow a tab to unregister itself with the tab list. */
|
|
@@ -113,6 +113,11 @@ export declare type TabListProps = ComponentProps<TabListSlots> & {
|
|
|
113
113
|
* Raised when a tab is selected.
|
|
114
114
|
*/
|
|
115
115
|
onTabSelect?: SelectTabEventHandler;
|
|
116
|
+
/**
|
|
117
|
+
* When true, focusing a tab will select it.
|
|
118
|
+
* @default false
|
|
119
|
+
*/
|
|
120
|
+
selectTabOnFocus?: boolean;
|
|
116
121
|
/**
|
|
117
122
|
* The value of the currently selected tab.
|
|
118
123
|
*/
|
|
@@ -10,9 +10,10 @@ import { useTabListContext_unstable } from '../TabList/TabListContext';
|
|
|
10
10
|
* @param props - props from this instance of Tab
|
|
11
11
|
* @param ref - reference to root HTMLElement of Tab
|
|
12
12
|
*/ export const useTab_unstable = (props, ref)=>{
|
|
13
|
-
const { content, disabled: tabDisabled = false, icon, onClick, value } = props;
|
|
13
|
+
const { content, disabled: tabDisabled = false, icon, onClick, onFocus, value } = props;
|
|
14
14
|
const appearance = useTabListContext_unstable((ctx)=>ctx.appearance);
|
|
15
15
|
const reserveSelectedTabSpace = useTabListContext_unstable((ctx)=>ctx.reserveSelectedTabSpace);
|
|
16
|
+
const selectTabOnFocus = useTabListContext_unstable((ctx)=>ctx.selectTabOnFocus);
|
|
16
17
|
const listDisabled = useTabListContext_unstable((ctx)=>ctx.disabled);
|
|
17
18
|
const selected = useTabListContext_unstable((ctx)=>ctx.selectedValue === value);
|
|
18
19
|
const onRegister = useTabListContext_unstable((ctx)=>ctx.onRegister);
|
|
@@ -22,9 +23,11 @@ import { useTabListContext_unstable } from '../TabList/TabListContext';
|
|
|
22
23
|
const vertical = useTabListContext_unstable((ctx)=>!!ctx.vertical);
|
|
23
24
|
const disabled = listDisabled || tabDisabled;
|
|
24
25
|
const innerRef = React.useRef(null);
|
|
25
|
-
const
|
|
26
|
+
const onSelectCallback = (event)=>onSelect(event, {
|
|
26
27
|
value
|
|
27
|
-
})
|
|
28
|
+
});
|
|
29
|
+
const onTabClick = useEventCallback(mergeCallbacks(onClick, onSelectCallback));
|
|
30
|
+
const onTabFocus = useEventCallback(mergeCallbacks(onFocus, onSelectCallback));
|
|
28
31
|
React.useEffect(()=>{
|
|
29
32
|
onRegister({
|
|
30
33
|
value,
|
|
@@ -71,7 +74,8 @@ import { useTabListContext_unstable } from '../TabList/TabListContext';
|
|
|
71
74
|
'aria-selected': disabled ? undefined : `${selected}`,
|
|
72
75
|
...props,
|
|
73
76
|
disabled,
|
|
74
|
-
onClick: onTabClick
|
|
77
|
+
onClick: onTabClick,
|
|
78
|
+
onFocus: selectTabOnFocus ? onTabFocus : onFocus
|
|
75
79
|
}), {
|
|
76
80
|
elementType: 'button'
|
|
77
81
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTab.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { TabProps, TabState } from './Tab.types';\nimport { useTabListContext_unstable } from '../TabList/TabListContext';\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, onClick, value } = props;\n\n const appearance = useTabListContext_unstable(ctx => ctx.appearance);\n const reserveSelectedTabSpace = useTabListContext_unstable(ctx => ctx.reserveSelectedTabSpace);\n const listDisabled = useTabListContext_unstable(ctx => ctx.disabled);\n const selected = useTabListContext_unstable(ctx => ctx.selectedValue === value);\n const onRegister = useTabListContext_unstable(ctx => ctx.onRegister);\n const onUnregister = useTabListContext_unstable(ctx => ctx.onUnregister);\n const onSelect = useTabListContext_unstable(ctx => ctx.onSelect);\n const size = useTabListContext_unstable(ctx => ctx.size);\n const vertical = useTabListContext_unstable(ctx => !!ctx.vertical);\n const disabled = listDisabled || tabDisabled;\n\n const innerRef = React.useRef<HTMLElement>(null);\n const
|
|
1
|
+
{"version":3,"sources":["useTab.ts"],"sourcesContent":["import * as React from 'react';\nimport {\n getIntrinsicElementProps,\n mergeCallbacks,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { TabProps, TabState } from './Tab.types';\nimport { useTabListContext_unstable } from '../TabList/TabListContext';\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, onClick, onFocus, value } = props;\n\n const appearance = useTabListContext_unstable(ctx => ctx.appearance);\n const reserveSelectedTabSpace = useTabListContext_unstable(ctx => ctx.reserveSelectedTabSpace);\n const selectTabOnFocus = useTabListContext_unstable(ctx => ctx.selectTabOnFocus);\n const listDisabled = useTabListContext_unstable(ctx => ctx.disabled);\n const selected = useTabListContext_unstable(ctx => ctx.selectedValue === value);\n const onRegister = useTabListContext_unstable(ctx => ctx.onRegister);\n const onUnregister = useTabListContext_unstable(ctx => ctx.onUnregister);\n const onSelect = useTabListContext_unstable(ctx => ctx.onSelect);\n const size = useTabListContext_unstable(ctx => ctx.size);\n const vertical = useTabListContext_unstable(ctx => !!ctx.vertical);\n const disabled = listDisabled || tabDisabled;\n\n const innerRef = React.useRef<HTMLElement>(null);\n const onSelectCallback = (event: SelectTabEvent) => onSelect(event, { value });\n const onTabClick = useEventCallback(mergeCallbacks(onClick, onSelectCallback));\n const onTabFocus = useEventCallback(mergeCallbacks(onFocus, onSelectCallback));\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 iconSlot = slot.optional(icon, { elementType: 'span' });\n const contentSlot = slot.always(content, {\n defaultProps: { children: props.children },\n elementType: 'span',\n });\n const iconOnly = Boolean(iconSlot?.children && !contentSlot.children);\n return {\n components: { root: 'button', icon: 'span', content: 'span', contentReservedSpace: 'span' },\n root: slot.always(\n getIntrinsicElementProps('button', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLButtonElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, innerRef) as React.Ref<HTMLButtonElement>,\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}` as 'true' | 'false'),\n ...props,\n disabled,\n onClick: onTabClick,\n onFocus: selectTabOnFocus ? onTabFocus : onFocus,\n }),\n { elementType: 'button' },\n ),\n icon: iconSlot,\n iconOnly,\n content: contentSlot,\n contentReservedSpace: slot.optional(content, {\n renderByDefault: !selected && !iconOnly && reserveSelectedTabSpace,\n defaultProps: { children: props.children },\n elementType: 'span',\n }),\n appearance,\n disabled,\n selected,\n size,\n value,\n vertical,\n };\n};\n"],"names":["React","getIntrinsicElementProps","mergeCallbacks","useEventCallback","useMergedRefs","slot","useTabListContext_unstable","useTab_unstable","props","ref","content","disabled","tabDisabled","icon","onClick","onFocus","value","appearance","ctx","reserveSelectedTabSpace","selectTabOnFocus","listDisabled","selected","selectedValue","onRegister","onUnregister","onSelect","size","vertical","innerRef","useRef","onSelectCallback","event","onTabClick","onTabFocus","useEffect","iconSlot","optional","elementType","contentSlot","always","defaultProps","children","iconOnly","Boolean","components","root","contentReservedSpace","role","type","undefined","renderByDefault"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SACEC,wBAAwB,EACxBC,cAAc,EACdC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AAEnC,SAASC,0BAA0B,QAAQ,4BAA4B;AAGvE;;;;;;;;CAQC,GACD,OAAO,MAAMC,kBAAkB,CAACC,OAAiBC;IAC/C,MAAM,EAAEC,OAAO,EAAEC,UAAUC,cAAc,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGR;IAElF,MAAMS,aAAaX,2BAA2BY,CAAAA,MAAOA,IAA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Q,KAAI,CAACH,YAAYG,QAAQ;IACpE,OAAO;QACLG,YAAY;YAAEC,MAAM;YAAUjC,MAAM;YAAQH,SAAS;YAAQqC,sBAAsB;QAAO;QAC1FD,MAAMzC,KAAKmC,MAAM,CACfvC,yBAAyB,UAAU;YACjC,SAAS;YACT,+EAA+E;YAC/E,4FAA4F;YAC5FQ,KAAKL,cAAcK,KAAKoB;YACxBmB,MAAM;YACNC,MAAM;YACN,yDAAyD;YACzD,iEAAiE;YACjE,iBAAiBtC,WAAWuC,YAAa,CAAC,EAAE5B,SAAS,CAAC;YACtD,GAAGd,KAAK;YACRG;YACAG,SAASmB;YACTlB,SAASK,mBAAmBc,aAAanB;QAC3C,IACA;YAAEuB,aAAa;QAAS;QAE1BzB,MAAMuB;QACNO;QACAjC,SAAS6B;QACTQ,sBAAsB1C,KAAKgC,QAAQ,CAAC3B,SAAS;YAC3CyC,iBAAiB,CAAC7B,YAAY,CAACqB,YAAYxB;YAC3CsB,cAAc;gBAAEC,UAAUlC,MAAMkC,QAAQ;YAAC;YACzCJ,aAAa;QACf;QACArB;QACAN;QACAW;QACAK;QACAX;QACAY;IACF;AACF,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TabList.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { TabValue } from '../Tab/Tab.types';\n\nexport type TabRegisterData = {\n /**\n * The value of the tab.\n */\n value: TabValue;\n\n /**\n * The reference to the tab HTML element.\n */\n ref: React.RefObject<HTMLElement>;\n};\n\nexport type RegisterTabEventHandler = (data: TabRegisterData) => void;\n\nexport type SelectTabData = {\n /**\n * The value of the selected tab.\n */\n value: TabValue;\n};\n\nexport type SelectTabEvent<E = HTMLElement> = React.MouseEvent<E> | React.KeyboardEvent<E>;\n\nexport type SelectTabEventHandler = (event: SelectTabEvent, data: SelectTabData) => void;\n\nexport type TabListSlots = {\n /**\n * The slot associated with the root element of this tab list.\n */\n root: Slot<'div'>;\n};\n\n/**\n * TabList Props\n */\nexport type TabListProps = ComponentProps<TabListSlots> & {\n /**\n * A tab list can supports 'transparent' and 'subtle' appearance.\n *- 'subtle': Minimizes emphasis to blend into the background until hovered or focused.\n *- 'transparent': No background and border styling\n * The appearance affects each of the contained tabs.\n * @default 'transparent'\n */\n appearance?: 'transparent' | 'subtle';\n\n /**\n * Tab size may change between unselected and selected states.\n * The default scenario is a selected tab has bold text.\n *\n * When true, this property requests tabs be the same size whether unselected or selected.\n * @default true\n */\n reserveSelectedTabSpace?: boolean;\n\n /**\n * The value of the tab to be selected by default.\n * Typically useful when the selectedValue is uncontrolled.\n */\n defaultSelectedValue?: TabValue;\n /**\n * A tab list can be set to disable interaction.\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Raised when a tab is selected.\n */\n onTabSelect?: SelectTabEventHandler;\n\n /**\n * The value of the currently selected tab.\n */\n selectedValue?: TabValue;\n\n /**\n * A tab list can be either 'small', 'medium', or 'large' size.\n * The size affects each of the contained tabs.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A tab list can arrange its tabs vertically.\n * @default false\n */\n vertical?: boolean;\n};\n\nexport type TabListContextValue = Pick
|
|
1
|
+
{"version":3,"sources":["TabList.types.ts"],"sourcesContent":["import * as React from 'react';\nimport type { ComponentProps, ComponentState, Slot } from '@fluentui/react-utilities';\nimport { TabValue } from '../Tab/Tab.types';\n\nexport type TabRegisterData = {\n /**\n * The value of the tab.\n */\n value: TabValue;\n\n /**\n * The reference to the tab HTML element.\n */\n ref: React.RefObject<HTMLElement>;\n};\n\nexport type RegisterTabEventHandler = (data: TabRegisterData) => void;\n\nexport type SelectTabData = {\n /**\n * The value of the selected tab.\n */\n value: TabValue;\n};\n\nexport type SelectTabEvent<E = HTMLElement> = React.MouseEvent<E> | React.KeyboardEvent<E> | React.FocusEvent<E>;\n\nexport type SelectTabEventHandler = (event: SelectTabEvent, data: SelectTabData) => void;\n\nexport type TabListSlots = {\n /**\n * The slot associated with the root element of this tab list.\n */\n root: Slot<'div'>;\n};\n\n/**\n * TabList Props\n */\nexport type TabListProps = ComponentProps<TabListSlots> & {\n /**\n * A tab list can supports 'transparent' and 'subtle' appearance.\n *- 'subtle': Minimizes emphasis to blend into the background until hovered or focused.\n *- 'transparent': No background and border styling\n * The appearance affects each of the contained tabs.\n * @default 'transparent'\n */\n appearance?: 'transparent' | 'subtle';\n\n /**\n * Tab size may change between unselected and selected states.\n * The default scenario is a selected tab has bold text.\n *\n * When true, this property requests tabs be the same size whether unselected or selected.\n * @default true\n */\n reserveSelectedTabSpace?: boolean;\n\n /**\n * The value of the tab to be selected by default.\n * Typically useful when the selectedValue is uncontrolled.\n */\n defaultSelectedValue?: TabValue;\n\n /**\n * A tab list can be set to disable interaction.\n * @default false\n */\n disabled?: boolean;\n\n /**\n * Raised when a tab is selected.\n */\n onTabSelect?: SelectTabEventHandler;\n\n /**\n * When true, focusing a tab will select it.\n * @default false\n */\n selectTabOnFocus?: boolean;\n\n /**\n * The value of the currently selected tab.\n */\n selectedValue?: TabValue;\n\n /**\n * A tab list can be either 'small', 'medium', or 'large' size.\n * The size affects each of the contained tabs.\n * @default 'medium'\n */\n size?: 'small' | 'medium' | 'large';\n\n /**\n * A tab list can arrange its tabs vertically.\n * @default false\n */\n vertical?: boolean;\n};\n\nexport type TabListContextValue = Pick<\n TabListProps,\n 'onTabSelect' | 'selectTabOnFocus' | 'selectedValue' | 'reserveSelectedTabSpace'\n> &\n Required<Pick<TabListProps, 'appearance' | 'disabled' | 'size' | 'vertical'>> & {\n /** A callback to allow a tab to register itself with the tab list. */\n onRegister: RegisterTabEventHandler;\n\n /** A callback to allow a tab to unregister itself with the tab list. */\n onUnregister: RegisterTabEventHandler;\n /**\n * A callback to allow a tab to select itself when pressed.\n */\n onSelect: SelectTabEventHandler;\n /**\n * Gets the registered tab data along with current and previous selected values.\n */\n getRegisteredTabs: () => {\n selectedValue?: TabValue;\n previousSelectedValue?: TabValue;\n registeredTabs: Record<string, TabRegisterData>;\n };\n };\n\n/**\n * Context values used in rendering TabList.\n */\nexport type TabListContextValues = {\n /**\n * The context of the tab list available to each tab.\n */\n tabList: TabListContextValue;\n};\n\n/**\n * State used in rendering TabList.\n */\nexport type TabListState = ComponentState<Required<TabListSlots>> & TabListContextValue;\n"],"names":["React"],"mappings":"AAAA,YAAYA,WAAW,QAAQ"}
|
|
@@ -2,6 +2,7 @@ import { createContext, useContextSelector } from '@fluentui/react-context-selec
|
|
|
2
2
|
const tabListContextDefaultValue = {
|
|
3
3
|
appearance: 'transparent',
|
|
4
4
|
reserveSelectedTabSpace: true,
|
|
5
|
+
selectTabOnFocus: false,
|
|
5
6
|
disabled: false,
|
|
6
7
|
selectedValue: undefined,
|
|
7
8
|
onRegister: ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TabListContext.ts"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { Context, ContextSelector } from '@fluentui/react-context-selector';\nimport { TabListContextValue } from './TabList.types';\n\nconst tabListContextDefaultValue: TabListContextValue = {\n appearance: 'transparent',\n reserveSelectedTabSpace: true,\n disabled: false,\n selectedValue: undefined,\n onRegister: () => {\n /* noop */\n },\n onUnregister: () => {\n /* noop */\n },\n onSelect: () => {\n /* noop */\n },\n getRegisteredTabs: () => {\n return {\n registeredTabs: {},\n };\n },\n size: 'medium',\n vertical: false,\n};\n\nexport const TabListContext: Context<TabListContextValue> = createContext<TabListContextValue | undefined>(\n undefined,\n) as Context<TabListContextValue>;\n\nexport const TabListProvider = TabListContext.Provider;\nexport const useTabListContext_unstable = <T>(selector: ContextSelector<TabListContextValue, T>): T =>\n useContextSelector(TabListContext, (ctx = tabListContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","tabListContextDefaultValue","appearance","reserveSelectedTabSpace","disabled","selectedValue","undefined","onRegister","onUnregister","onSelect","getRegisteredTabs","registeredTabs","size","vertical","TabListContext","TabListProvider","Provider","useTabListContext_unstable","selector","ctx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,mCAAmC;AAIrF,MAAMC,6BAAkD;IACtDC,YAAY;IACZC,yBAAyB;IACzBC,UAAU;IACVC,eAAeC;IACfC,YAAY;IACV,QAAQ,GACV;IACAC,cAAc;IACZ,QAAQ,GACV;IACAC,UAAU;IACR,QAAQ,GACV;IACAC,mBAAmB;QACjB,OAAO;YACLC,gBAAgB,CAAC;QACnB;IACF;IACAC,MAAM;IACNC,UAAU;AACZ;AAEA,OAAO,MAAMC,iBAA+
|
|
1
|
+
{"version":3,"sources":["TabListContext.ts"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nimport type { Context, ContextSelector } from '@fluentui/react-context-selector';\nimport { TabListContextValue } from './TabList.types';\n\nconst tabListContextDefaultValue: TabListContextValue = {\n appearance: 'transparent',\n reserveSelectedTabSpace: true,\n selectTabOnFocus: false,\n disabled: false,\n selectedValue: undefined,\n onRegister: () => {\n /* noop */\n },\n onUnregister: () => {\n /* noop */\n },\n onSelect: () => {\n /* noop */\n },\n getRegisteredTabs: () => {\n return {\n registeredTabs: {},\n };\n },\n size: 'medium',\n vertical: false,\n};\n\nexport const TabListContext: Context<TabListContextValue> = createContext<TabListContextValue | undefined>(\n undefined,\n) as Context<TabListContextValue>;\n\nexport const TabListProvider = TabListContext.Provider;\nexport const useTabListContext_unstable = <T>(selector: ContextSelector<TabListContextValue, T>): T =>\n useContextSelector(TabListContext, (ctx = tabListContextDefaultValue) => selector(ctx));\n"],"names":["createContext","useContextSelector","tabListContextDefaultValue","appearance","reserveSelectedTabSpace","selectTabOnFocus","disabled","selectedValue","undefined","onRegister","onUnregister","onSelect","getRegisteredTabs","registeredTabs","size","vertical","TabListContext","TabListProvider","Provider","useTabListContext_unstable","selector","ctx"],"mappings":"AAAA,SAASA,aAAa,EAAEC,kBAAkB,QAAQ,mCAAmC;AAIrF,MAAMC,6BAAkD;IACtDC,YAAY;IACZC,yBAAyB;IACzBC,kBAAkB;IAClBC,UAAU;IACVC,eAAeC;IACfC,YAAY;IACV,QAAQ,GACV;IACAC,cAAc;IACZ,QAAQ,GACV;IACAC,UAAU;IACR,QAAQ,GACV;IACAC,mBAAmB;QACjB,OAAO;YACLC,gBAAgB,CAAC;QACnB;IACF;IACAC,MAAM;IACNC,UAAU;AACZ;AAEA,OAAO,MAAMC,iBAA+ChB,cAC1DQ,WACgC;AAElC,OAAO,MAAMS,kBAAkBD,eAAeE,QAAQ,CAAC;AACvD,OAAO,MAAMC,6BAA6B,CAAIC,WAC5CnB,mBAAmBe,gBAAgB,CAACK,MAAMnB,0BAA0B,GAAKkB,SAASC,MAAM"}
|
|
@@ -10,7 +10,7 @@ import { getIntrinsicElementProps, useControllableState, useEventCallback, useMe
|
|
|
10
10
|
* @param props - props from this instance of TabList
|
|
11
11
|
* @param ref - reference to root HTMLElement of TabList
|
|
12
12
|
*/ export const useTabList_unstable = (props, ref)=>{
|
|
13
|
-
const { appearance = 'transparent', reserveSelectedTabSpace = true, disabled = false, onTabSelect, size = 'medium', vertical = false } = props;
|
|
13
|
+
const { appearance = 'transparent', reserveSelectedTabSpace = true, disabled = false, onTabSelect, selectTabOnFocus = false, size = 'medium', vertical = false } = props;
|
|
14
14
|
const innerRef = React.useRef(null);
|
|
15
15
|
const focusAttributes = useArrowNavigationGroup({
|
|
16
16
|
circular: true,
|
|
@@ -71,6 +71,7 @@ import { getIntrinsicElementProps, useControllableState, useEventCallback, useMe
|
|
|
71
71
|
appearance,
|
|
72
72
|
reserveSelectedTabSpace,
|
|
73
73
|
disabled,
|
|
74
|
+
selectTabOnFocus,
|
|
74
75
|
selectedValue,
|
|
75
76
|
size,
|
|
76
77
|
vertical,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTabList.ts"],"sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport {\n getIntrinsicElementProps,\n useControllableState,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { TabRegisterData, SelectTabData, SelectTabEvent, TabListProps, TabListState } from './TabList.types';\nimport { TabValue } from '../Tab/Tab.types';\n\n/**\n * Create the state required to render TabList.\n *\n * The returned state can be modified with hooks such as useTabListStyles_unstable,\n * before being passed to renderTabList_unstable.\n *\n * @param props - props from this instance of TabList\n * @param ref - reference to root HTMLElement of TabList\n */\nexport const useTabList_unstable = (props: TabListProps, ref: React.Ref<HTMLElement>): TabListState => {\n const {\n appearance = 'transparent',\n reserveSelectedTabSpace = true,\n disabled = false,\n onTabSelect,\n size = 'medium',\n vertical = false,\n } = props;\n\n const innerRef = React.useRef<HTMLElement>(null);\n\n const focusAttributes = useArrowNavigationGroup({\n circular: true,\n axis: vertical ? 'vertical' : 'horizontal',\n memorizeCurrent: true,\n });\n\n const [selectedValue, setSelectedValue] = useControllableState({\n state: props.selectedValue,\n defaultState: props.defaultSelectedValue,\n initialState: undefined,\n });\n\n // considered usePrevious, but it is sensitive to re-renders\n // this could cause the previous to move to current in the case where the tab list re-renders.\n // these refs avoid getRegisteredTabs changing when selectedValue changes and causing\n // renders for tabs that have not changed.\n const currentSelectedValue = React.useRef<TabValue | undefined>(undefined);\n const previousSelectedValue = React.useRef<TabValue | undefined>(undefined);\n\n React.useEffect(() => {\n previousSelectedValue.current = currentSelectedValue.current;\n currentSelectedValue.current = selectedValue;\n }, [selectedValue]);\n\n const onSelect = useEventCallback((event: SelectTabEvent, data: SelectTabData) => {\n setSelectedValue(data.value);\n onTabSelect?.(event, data);\n });\n\n const registeredTabs = React.useRef<Record<string, TabRegisterData>>({});\n\n const onRegister = useEventCallback((data: TabRegisterData) => {\n registeredTabs.current[JSON.stringify(data.value)] = data;\n });\n\n const onUnregister = useEventCallback((data: TabRegisterData) => {\n delete registeredTabs.current[JSON.stringify(data.value)];\n });\n\n const getRegisteredTabs = React.useCallback(() => {\n return {\n selectedValue: currentSelectedValue.current,\n previousSelectedValue: previousSelectedValue.current,\n registeredTabs: registeredTabs.current,\n };\n }, []);\n\n return {\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, innerRef) as React.Ref<HTMLDivElement>,\n role: 'tablist',\n 'aria-orientation': vertical ? 'vertical' : 'horizontal',\n ...focusAttributes,\n ...props,\n } as const),\n { elementType: 'div' },\n ),\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectedValue,\n size,\n vertical,\n onRegister,\n onUnregister,\n onSelect,\n getRegisteredTabs,\n };\n};\n"],"names":["React","useArrowNavigationGroup","getIntrinsicElementProps","useControllableState","useEventCallback","useMergedRefs","slot","useTabList_unstable","props","ref","appearance","reserveSelectedTabSpace","disabled","onTabSelect","size","vertical","innerRef","useRef","focusAttributes","circular","axis","memorizeCurrent","selectedValue","setSelectedValue","state","defaultState","defaultSelectedValue","initialState","undefined","currentSelectedValue","previousSelectedValue","useEffect","current","onSelect","event","data","value","registeredTabs","onRegister","JSON","stringify","onUnregister","getRegisteredTabs","useCallback","components","root","always","role","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AAInC;;;;;;;;CAQC,GACD,OAAO,MAAMC,sBAAsB,CAACC,OAAqBC;IACvD,MAAM,EACJC,aAAa,aAAa,EAC1BC,0BAA0B,IAAI,EAC9BC,WAAW,KAAK,EAChBC,WAAW,EACXC,OAAO,QAAQ,EACfC,WAAW,KAAK,EACjB,
|
|
1
|
+
{"version":3,"sources":["useTabList.ts"],"sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport {\n getIntrinsicElementProps,\n useControllableState,\n useEventCallback,\n useMergedRefs,\n slot,\n} from '@fluentui/react-utilities';\nimport type { TabRegisterData, SelectTabData, SelectTabEvent, TabListProps, TabListState } from './TabList.types';\nimport { TabValue } from '../Tab/Tab.types';\n\n/**\n * Create the state required to render TabList.\n *\n * The returned state can be modified with hooks such as useTabListStyles_unstable,\n * before being passed to renderTabList_unstable.\n *\n * @param props - props from this instance of TabList\n * @param ref - reference to root HTMLElement of TabList\n */\nexport const useTabList_unstable = (props: TabListProps, ref: React.Ref<HTMLElement>): TabListState => {\n const {\n appearance = 'transparent',\n reserveSelectedTabSpace = true,\n disabled = false,\n onTabSelect,\n selectTabOnFocus = false,\n size = 'medium',\n vertical = false,\n } = props;\n\n const innerRef = React.useRef<HTMLElement>(null);\n\n const focusAttributes = useArrowNavigationGroup({\n circular: true,\n axis: vertical ? 'vertical' : 'horizontal',\n memorizeCurrent: true,\n });\n\n const [selectedValue, setSelectedValue] = useControllableState({\n state: props.selectedValue,\n defaultState: props.defaultSelectedValue,\n initialState: undefined,\n });\n\n // considered usePrevious, but it is sensitive to re-renders\n // this could cause the previous to move to current in the case where the tab list re-renders.\n // these refs avoid getRegisteredTabs changing when selectedValue changes and causing\n // renders for tabs that have not changed.\n const currentSelectedValue = React.useRef<TabValue | undefined>(undefined);\n const previousSelectedValue = React.useRef<TabValue | undefined>(undefined);\n\n React.useEffect(() => {\n previousSelectedValue.current = currentSelectedValue.current;\n currentSelectedValue.current = selectedValue;\n }, [selectedValue]);\n\n const onSelect = useEventCallback((event: SelectTabEvent, data: SelectTabData) => {\n setSelectedValue(data.value);\n onTabSelect?.(event, data);\n });\n\n const registeredTabs = React.useRef<Record<string, TabRegisterData>>({});\n\n const onRegister = useEventCallback((data: TabRegisterData) => {\n registeredTabs.current[JSON.stringify(data.value)] = data;\n });\n\n const onUnregister = useEventCallback((data: TabRegisterData) => {\n delete registeredTabs.current[JSON.stringify(data.value)];\n });\n\n const getRegisteredTabs = React.useCallback(() => {\n return {\n selectedValue: currentSelectedValue.current,\n previousSelectedValue: previousSelectedValue.current,\n registeredTabs: registeredTabs.current,\n };\n }, []);\n\n return {\n components: {\n root: 'div',\n },\n root: slot.always(\n getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, innerRef) as React.Ref<HTMLDivElement>,\n role: 'tablist',\n 'aria-orientation': vertical ? 'vertical' : 'horizontal',\n ...focusAttributes,\n ...props,\n } as const),\n { elementType: 'div' },\n ),\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectTabOnFocus,\n selectedValue,\n size,\n vertical,\n onRegister,\n onUnregister,\n onSelect,\n getRegisteredTabs,\n };\n};\n"],"names":["React","useArrowNavigationGroup","getIntrinsicElementProps","useControllableState","useEventCallback","useMergedRefs","slot","useTabList_unstable","props","ref","appearance","reserveSelectedTabSpace","disabled","onTabSelect","selectTabOnFocus","size","vertical","innerRef","useRef","focusAttributes","circular","axis","memorizeCurrent","selectedValue","setSelectedValue","state","defaultState","defaultSelectedValue","initialState","undefined","currentSelectedValue","previousSelectedValue","useEffect","current","onSelect","event","data","value","registeredTabs","onRegister","JSON","stringify","onUnregister","getRegisteredTabs","useCallback","components","root","always","role","elementType"],"mappings":"AAAA,YAAYA,WAAW,QAAQ;AAC/B,SAASC,uBAAuB,QAAQ,0BAA0B;AAClE,SACEC,wBAAwB,EACxBC,oBAAoB,EACpBC,gBAAgB,EAChBC,aAAa,EACbC,IAAI,QACC,4BAA4B;AAInC;;;;;;;;CAQC,GACD,OAAO,MAAMC,sBAAsB,CAACC,OAAqBC;IACvD,MAAM,EACJC,aAAa,aAAa,EAC1BC,0BAA0B,IAAI,EAC9BC,WAAW,KAAK,EAChBC,WAAW,EACXC,mBAAmB,KAAK,EACxBC,OAAO,QAAQ,EACfC,WAAW,KAAK,EACjB,GAAGR;IAEJ,MAAMS,WAAWjB,MAAMkB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5E,4FAA4F;YAC5FO,KAAKJ,cAAcI,KAAKQ;YACxB+B,MAAM;YACN,oBAAoBhC,WAAW,aAAa;YAC5C,GAAGG,eAAe;YAClB,GAAGX,KAAK;QACV,IACA;YAAEyC,aAAa;QAAM;QAEvBvC;QACAC;QACAC;QACAE;QACAS;QACAR;QACAC;QACAuB;QACAG;QACAR;QACAS;IACF;AACF,EAAE"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
export function useTabListContextValues_unstable(state) {
|
|
2
|
-
const { appearance, reserveSelectedTabSpace, disabled, selectedValue: selectedKey, onRegister, onUnregister, onSelect, getRegisteredTabs, size, vertical } = state;
|
|
2
|
+
const { appearance, reserveSelectedTabSpace, disabled, selectTabOnFocus, selectedValue: selectedKey, onRegister, onUnregister, onSelect, getRegisteredTabs, size, vertical } = state;
|
|
3
3
|
const tabList = {
|
|
4
4
|
appearance,
|
|
5
5
|
reserveSelectedTabSpace,
|
|
6
6
|
disabled,
|
|
7
|
+
selectTabOnFocus,
|
|
7
8
|
selectedValue: selectedKey,
|
|
8
9
|
onSelect,
|
|
9
10
|
onRegister,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTabListContextValues.tsx"],"sourcesContent":["import { TabListContextValue, TabListContextValues, TabListState } from './TabList.types';\n\nexport function useTabListContextValues_unstable(state: TabListState): TabListContextValues {\n const {\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectedValue: selectedKey,\n onRegister,\n onUnregister,\n onSelect,\n getRegisteredTabs,\n size,\n vertical,\n } = state;\n\n const tabList: TabListContextValue = {\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectedValue: selectedKey,\n onSelect,\n onRegister,\n onUnregister,\n getRegisteredTabs,\n size,\n vertical,\n };\n\n return { tabList };\n}\n"],"names":["useTabListContextValues_unstable","state","appearance","reserveSelectedTabSpace","disabled","selectedValue","selectedKey","onRegister","onUnregister","onSelect","getRegisteredTabs","size","vertical","tabList"],"mappings":"AAEA,OAAO,SAASA,iCAAiCC,KAAmB;IAClE,MAAM,EACJC,UAAU,EACVC,uBAAuB,EACvBC,QAAQ,EACRC,eAAeC,WAAW,EAC1BC,UAAU,EACVC,YAAY,EACZC,QAAQ,EACRC,iBAAiB,EACjBC,IAAI,EACJC,QAAQ,EACT,
|
|
1
|
+
{"version":3,"sources":["useTabListContextValues.tsx"],"sourcesContent":["import { TabListContextValue, TabListContextValues, TabListState } from './TabList.types';\n\nexport function useTabListContextValues_unstable(state: TabListState): TabListContextValues {\n const {\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectTabOnFocus,\n selectedValue: selectedKey,\n onRegister,\n onUnregister,\n onSelect,\n getRegisteredTabs,\n size,\n vertical,\n } = state;\n\n const tabList: TabListContextValue = {\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectTabOnFocus,\n selectedValue: selectedKey,\n onSelect,\n onRegister,\n onUnregister,\n getRegisteredTabs,\n size,\n vertical,\n };\n\n return { tabList };\n}\n"],"names":["useTabListContextValues_unstable","state","appearance","reserveSelectedTabSpace","disabled","selectTabOnFocus","selectedValue","selectedKey","onRegister","onUnregister","onSelect","getRegisteredTabs","size","vertical","tabList"],"mappings":"AAEA,OAAO,SAASA,iCAAiCC,KAAmB;IAClE,MAAM,EACJC,UAAU,EACVC,uBAAuB,EACvBC,QAAQ,EACRC,gBAAgB,EAChBC,eAAeC,WAAW,EAC1BC,UAAU,EACVC,YAAY,EACZC,QAAQ,EACRC,iBAAiB,EACjBC,IAAI,EACJC,QAAQ,EACT,GAAGZ;IAEJ,MAAMa,UAA+B;QACnCZ;QACAC;QACAC;QACAC;QACAC,eAAeC;QACfG;QACAF;QACAC;QACAE;QACAC;QACAC;IACF;IAEA,OAAO;QAAEC;IAAQ;AACnB"}
|
|
@@ -13,9 +13,10 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
13
13
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
14
14
|
const _TabListContext = require("../TabList/TabListContext");
|
|
15
15
|
const useTab_unstable = (props, ref)=>{
|
|
16
|
-
const { content, disabled: tabDisabled = false, icon, onClick, value } = props;
|
|
16
|
+
const { content, disabled: tabDisabled = false, icon, onClick, onFocus, value } = props;
|
|
17
17
|
const appearance = (0, _TabListContext.useTabListContext_unstable)((ctx)=>ctx.appearance);
|
|
18
18
|
const reserveSelectedTabSpace = (0, _TabListContext.useTabListContext_unstable)((ctx)=>ctx.reserveSelectedTabSpace);
|
|
19
|
+
const selectTabOnFocus = (0, _TabListContext.useTabListContext_unstable)((ctx)=>ctx.selectTabOnFocus);
|
|
19
20
|
const listDisabled = (0, _TabListContext.useTabListContext_unstable)((ctx)=>ctx.disabled);
|
|
20
21
|
const selected = (0, _TabListContext.useTabListContext_unstable)((ctx)=>ctx.selectedValue === value);
|
|
21
22
|
const onRegister = (0, _TabListContext.useTabListContext_unstable)((ctx)=>ctx.onRegister);
|
|
@@ -25,9 +26,11 @@ const useTab_unstable = (props, ref)=>{
|
|
|
25
26
|
const vertical = (0, _TabListContext.useTabListContext_unstable)((ctx)=>!!ctx.vertical);
|
|
26
27
|
const disabled = listDisabled || tabDisabled;
|
|
27
28
|
const innerRef = _react.useRef(null);
|
|
28
|
-
const
|
|
29
|
+
const onSelectCallback = (event)=>onSelect(event, {
|
|
29
30
|
value
|
|
30
|
-
})
|
|
31
|
+
});
|
|
32
|
+
const onTabClick = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(onClick, onSelectCallback));
|
|
33
|
+
const onTabFocus = (0, _reactutilities.useEventCallback)((0, _reactutilities.mergeCallbacks)(onFocus, onSelectCallback));
|
|
31
34
|
_react.useEffect(()=>{
|
|
32
35
|
onRegister({
|
|
33
36
|
value,
|
|
@@ -74,7 +77,8 @@ const useTab_unstable = (props, ref)=>{
|
|
|
74
77
|
'aria-selected': disabled ? undefined : `${selected}`,
|
|
75
78
|
...props,
|
|
76
79
|
disabled,
|
|
77
|
-
onClick: onTabClick
|
|
80
|
+
onClick: onTabClick,
|
|
81
|
+
onFocus: selectTabOnFocus ? onTabFocus : onFocus
|
|
78
82
|
}), {
|
|
79
83
|
elementType: 'button'
|
|
80
84
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTab.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeCallbacks, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useTabListContext_unstable } from '../TabList/TabListContext';\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 */ export const useTab_unstable = (props, ref)=>{\n const { content, disabled: tabDisabled = false, icon, onClick, value } = props;\n const appearance = useTabListContext_unstable((ctx)=>ctx.appearance);\n const reserveSelectedTabSpace = useTabListContext_unstable((ctx)=>ctx.reserveSelectedTabSpace);\n const listDisabled = useTabListContext_unstable((ctx)=>ctx.disabled);\n const selected = useTabListContext_unstable((ctx)=>ctx.selectedValue === value);\n const onRegister = useTabListContext_unstable((ctx)=>ctx.onRegister);\n const onUnregister = useTabListContext_unstable((ctx)=>ctx.onUnregister);\n const onSelect = useTabListContext_unstable((ctx)=>ctx.onSelect);\n const size = useTabListContext_unstable((ctx)=>ctx.size);\n const vertical = useTabListContext_unstable((ctx)=>!!ctx.vertical);\n const disabled = listDisabled || tabDisabled;\n const innerRef = React.useRef(null);\n const
|
|
1
|
+
{"version":3,"sources":["useTab.js"],"sourcesContent":["import * as React from 'react';\nimport { getIntrinsicElementProps, mergeCallbacks, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\nimport { useTabListContext_unstable } from '../TabList/TabListContext';\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 */ export const useTab_unstable = (props, ref)=>{\n const { content, disabled: tabDisabled = false, icon, onClick, onFocus, value } = props;\n const appearance = useTabListContext_unstable((ctx)=>ctx.appearance);\n const reserveSelectedTabSpace = useTabListContext_unstable((ctx)=>ctx.reserveSelectedTabSpace);\n const selectTabOnFocus = useTabListContext_unstable((ctx)=>ctx.selectTabOnFocus);\n const listDisabled = useTabListContext_unstable((ctx)=>ctx.disabled);\n const selected = useTabListContext_unstable((ctx)=>ctx.selectedValue === value);\n const onRegister = useTabListContext_unstable((ctx)=>ctx.onRegister);\n const onUnregister = useTabListContext_unstable((ctx)=>ctx.onUnregister);\n const onSelect = useTabListContext_unstable((ctx)=>ctx.onSelect);\n const size = useTabListContext_unstable((ctx)=>ctx.size);\n const vertical = useTabListContext_unstable((ctx)=>!!ctx.vertical);\n const disabled = listDisabled || tabDisabled;\n const innerRef = React.useRef(null);\n const onSelectCallback = (event)=>onSelect(event, {\n value\n });\n const onTabClick = useEventCallback(mergeCallbacks(onClick, onSelectCallback));\n const onTabFocus = useEventCallback(mergeCallbacks(onFocus, onSelectCallback));\n React.useEffect(()=>{\n onRegister({\n value,\n ref: innerRef\n });\n return ()=>{\n onUnregister({\n value,\n ref: innerRef\n });\n };\n }, [\n onRegister,\n onUnregister,\n innerRef,\n value\n ]);\n const iconSlot = slot.optional(icon, {\n elementType: 'span'\n });\n const contentSlot = slot.always(content, {\n defaultProps: {\n children: props.children\n },\n elementType: 'span'\n });\n const iconOnly = Boolean((iconSlot === null || iconSlot === void 0 ? void 0 : iconSlot.children) && !contentSlot.children);\n return {\n components: {\n root: 'button',\n icon: 'span',\n content: 'span',\n contentReservedSpace: 'span'\n },\n root: slot.always(getIntrinsicElementProps('button', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLButtonElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\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: onTabClick,\n onFocus: selectTabOnFocus ? onTabFocus : onFocus\n }), {\n elementType: 'button'\n }),\n icon: iconSlot,\n iconOnly,\n content: contentSlot,\n contentReservedSpace: slot.optional(content, {\n renderByDefault: !selected && !iconOnly && reserveSelectedTabSpace,\n defaultProps: {\n children: props.children\n },\n elementType: 'span'\n }),\n appearance,\n disabled,\n selected,\n size,\n value,\n vertical\n };\n};\n"],"names":["useTab_unstable","props","ref","content","disabled","tabDisabled","icon","onClick","onFocus","value","appearance","useTabListContext_unstable","ctx","reserveSelectedTabSpace","selectTabOnFocus","listDisabled","selected","selectedValue","onRegister","onUnregister","onSelect","size","vertical","innerRef","React","useRef","onSelectCallback","event","onTabClick","useEventCallback","mergeCallbacks","onTabFocus","useEffect","iconSlot","slot","optional","elementType","contentSlot","always","defaultProps","children","iconOnly","Boolean","components","root","contentReservedSpace","getIntrinsicElementProps","useMergedRefs","role","type","undefined","renderByDefault"],"mappings":";;;;+BAWiBA;;;eAAAA;;;;iEAXM;gCACyE;gCACrD;AAShC,MAAMA,kBAAkB,CAACC,OAAOC;IACvC,MAAM,EAAEC,OAAO,EAAEC,UAAUC,cAAc,KAAK,EAAEC,IAAI,EAAEC,OAAO,EAAEC,OAAO,EAAEC,KAAK,EAAE,GAAGR;IAClF,MAAMS,aAAaC,IAAAA,0CAA0B,EAAC,CAACC,MAAMA,IAAIF,UAAU;IACnE,MAAMG,0BAA0BF,IAAAA,0CAA0B,EAAC,CAACC,MAAMA,IAAIC,uBAAuB;IAC7F,MAAMC,mBAAmBH,IAAAA,0CAA0B,EAAC,CAACC,MAAMA,IAAIE,gBAAgB;IAC/E,MAAMC,eAAeJ,IAAAA,0CAA0B,EAAC,CAACC,MAAMA,IAAIR,QAAQ;IACnE,MAAMY,WAAWL,IAAAA,0CAA0B,EAAC,CAACC,MAAMA,IAAIK,aAAa,KAAKR;IACzE,MAAMS,aAAaP,IAAAA,0CAA0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AAwB,EAAC,UAAU;YACjD,SAAS;YACT,+EAA+E;YAC/E,4FAA4F;YAC5F5C,KAAK6C,IAAAA,6BAAa,EAAC7C,KAAKqB;YACxByB,MAAM;YACNC,MAAM;YACN,yDAAyD;YACzD,iEAAiE;YACjE,iBAAiB7C,WAAW8C,YAAY,CAAC,EAAElC,SAAS,CAAC;YACrD,GAAGf,KAAK;YACRG;YACAG,SAASqB;YACTpB,SAASM,mBAAmBiB,aAAavB;QAC7C,IAAI;YACA4B,aAAa;QACjB;QACA9B,MAAM2B;QACNQ;QACAtC,SAASkC;QACTQ,sBAAsBX,oBAAI,CAACC,QAAQ,CAAChC,SAAS;YACzCgD,iBAAiB,CAACnC,YAAY,CAACyB,YAAY5B;YAC3C0B,cAAc;gBACVC,UAAUvC,MAAMuC,QAAQ;YAC5B;YACAJ,aAAa;QACjB;QACA1B;QACAN;QACAY;QACAK;QACAZ;QACAa;IACJ;AACJ"}
|
|
@@ -23,6 +23,7 @@ const _reactcontextselector = require("@fluentui/react-context-selector");
|
|
|
23
23
|
const tabListContextDefaultValue = {
|
|
24
24
|
appearance: 'transparent',
|
|
25
25
|
reserveSelectedTabSpace: true,
|
|
26
|
+
selectTabOnFocus: false,
|
|
26
27
|
disabled: false,
|
|
27
28
|
selectedValue: undefined,
|
|
28
29
|
onRegister: ()=>{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["TabListContext.js"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nconst tabListContextDefaultValue = {\n appearance: 'transparent',\n reserveSelectedTabSpace: true,\n disabled: false,\n selectedValue: undefined,\n onRegister: ()=>{\n /* noop */ },\n onUnregister: ()=>{\n /* noop */ },\n onSelect: ()=>{\n /* noop */ },\n getRegisteredTabs: ()=>{\n return {\n registeredTabs: {}\n };\n },\n size: 'medium',\n vertical: false\n};\nexport const TabListContext = createContext(undefined);\nexport const TabListProvider = TabListContext.Provider;\nexport const useTabListContext_unstable = (selector)=>useContextSelector(TabListContext, (ctx = tabListContextDefaultValue)=>selector(ctx));\n"],"names":["TabListContext","TabListProvider","useTabListContext_unstable","tabListContextDefaultValue","appearance","reserveSelectedTabSpace","disabled","selectedValue","undefined","onRegister","onUnregister","onSelect","getRegisteredTabs","registeredTabs","size","vertical","createContext","Provider","selector","useContextSelector","ctx"],"mappings":";;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["TabListContext.js"],"sourcesContent":["import { createContext, useContextSelector } from '@fluentui/react-context-selector';\nconst tabListContextDefaultValue = {\n appearance: 'transparent',\n reserveSelectedTabSpace: true,\n selectTabOnFocus: false,\n disabled: false,\n selectedValue: undefined,\n onRegister: ()=>{\n /* noop */ },\n onUnregister: ()=>{\n /* noop */ },\n onSelect: ()=>{\n /* noop */ },\n getRegisteredTabs: ()=>{\n return {\n registeredTabs: {}\n };\n },\n size: 'medium',\n vertical: false\n};\nexport const TabListContext = createContext(undefined);\nexport const TabListProvider = TabListContext.Provider;\nexport const useTabListContext_unstable = (selector)=>useContextSelector(TabListContext, (ctx = tabListContextDefaultValue)=>selector(ctx));\n"],"names":["TabListContext","TabListProvider","useTabListContext_unstable","tabListContextDefaultValue","appearance","reserveSelectedTabSpace","selectTabOnFocus","disabled","selectedValue","undefined","onRegister","onUnregister","onSelect","getRegisteredTabs","registeredTabs","size","vertical","createContext","Provider","selector","useContextSelector","ctx"],"mappings":";;;;;;;;;;;IAqBaA,cAAc;eAAdA;;IACAC,eAAe;eAAfA;;IACAC,0BAA0B;eAA1BA;;;sCAvBqC;AAClD,MAAMC,6BAA6B;IAC/BC,YAAY;IACZC,yBAAyB;IACzBC,kBAAkB;IAClBC,UAAU;IACVC,eAAeC;IACfC,YAAY;IACZ,QAAQ,GAAG;IACXC,cAAc;IACd,QAAQ,GAAG;IACXC,UAAU;IACV,QAAQ,GAAG;IACXC,mBAAmB;QACf,OAAO;YACHC,gBAAgB,CAAC;QACrB;IACJ;IACAC,MAAM;IACNC,UAAU;AACd;AACO,MAAMhB,iBAAiBiB,IAAAA,mCAAa,EAACR;AACrC,MAAMR,kBAAkBD,eAAekB,QAAQ;AAC/C,MAAMhB,6BAA6B,CAACiB,WAAWC,IAAAA,wCAAkB,EAACpB,gBAAgB,CAACqB,MAAMlB,0BAA0B,GAAGgB,SAASE"}
|
|
@@ -13,7 +13,7 @@ const _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
|
13
13
|
const _reacttabster = require("@fluentui/react-tabster");
|
|
14
14
|
const _reactutilities = require("@fluentui/react-utilities");
|
|
15
15
|
const useTabList_unstable = (props, ref)=>{
|
|
16
|
-
const { appearance = 'transparent', reserveSelectedTabSpace = true, disabled = false, onTabSelect, size = 'medium', vertical = false } = props;
|
|
16
|
+
const { appearance = 'transparent', reserveSelectedTabSpace = true, disabled = false, onTabSelect, selectTabOnFocus = false, size = 'medium', vertical = false } = props;
|
|
17
17
|
const innerRef = _react.useRef(null);
|
|
18
18
|
const focusAttributes = (0, _reacttabster.useArrowNavigationGroup)({
|
|
19
19
|
circular: true,
|
|
@@ -74,6 +74,7 @@ const useTabList_unstable = (props, ref)=>{
|
|
|
74
74
|
appearance,
|
|
75
75
|
reserveSelectedTabSpace,
|
|
76
76
|
disabled,
|
|
77
|
+
selectTabOnFocus,
|
|
77
78
|
selectedValue,
|
|
78
79
|
size,
|
|
79
80
|
vertical,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTabList.js"],"sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { getIntrinsicElementProps, useControllableState, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\n/**\n * Create the state required to render TabList.\n *\n * The returned state can be modified with hooks such as useTabListStyles_unstable,\n * before being passed to renderTabList_unstable.\n *\n * @param props - props from this instance of TabList\n * @param ref - reference to root HTMLElement of TabList\n */ export const useTabList_unstable = (props, ref)=>{\n const { appearance = 'transparent', reserveSelectedTabSpace = true, disabled = false, onTabSelect, size = 'medium', vertical = false } = props;\n const innerRef = React.useRef(null);\n const focusAttributes = useArrowNavigationGroup({\n circular: true,\n axis: vertical ? 'vertical' : 'horizontal',\n memorizeCurrent: true\n });\n const [selectedValue, setSelectedValue] = useControllableState({\n state: props.selectedValue,\n defaultState: props.defaultSelectedValue,\n initialState: undefined\n });\n // considered usePrevious, but it is sensitive to re-renders\n // this could cause the previous to move to current in the case where the tab list re-renders.\n // these refs avoid getRegisteredTabs changing when selectedValue changes and causing\n // renders for tabs that have not changed.\n const currentSelectedValue = React.useRef(undefined);\n const previousSelectedValue = React.useRef(undefined);\n React.useEffect(()=>{\n previousSelectedValue.current = currentSelectedValue.current;\n currentSelectedValue.current = selectedValue;\n }, [\n selectedValue\n ]);\n const onSelect = useEventCallback((event, data)=>{\n setSelectedValue(data.value);\n onTabSelect === null || onTabSelect === void 0 ? void 0 : onTabSelect(event, data);\n });\n const registeredTabs = React.useRef({});\n const onRegister = useEventCallback((data)=>{\n registeredTabs.current[JSON.stringify(data.value)] = data;\n });\n const onUnregister = useEventCallback((data)=>{\n delete registeredTabs.current[JSON.stringify(data.value)];\n });\n const getRegisteredTabs = React.useCallback(()=>{\n return {\n selectedValue: currentSelectedValue.current,\n previousSelectedValue: previousSelectedValue.current,\n registeredTabs: registeredTabs.current\n };\n }, []);\n return {\n components: {\n root: 'div'\n },\n root: slot.always(getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, innerRef),\n role: 'tablist',\n 'aria-orientation': vertical ? 'vertical' : 'horizontal',\n ...focusAttributes,\n ...props\n }), {\n elementType: 'div'\n }),\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectedValue,\n size,\n vertical,\n onRegister,\n onUnregister,\n onSelect,\n getRegisteredTabs\n };\n};\n"],"names":["useTabList_unstable","props","ref","appearance","reserveSelectedTabSpace","disabled","onTabSelect","size","vertical","innerRef","React","useRef","focusAttributes","useArrowNavigationGroup","circular","axis","memorizeCurrent","selectedValue","setSelectedValue","useControllableState","state","defaultState","defaultSelectedValue","initialState","undefined","currentSelectedValue","previousSelectedValue","useEffect","current","onSelect","useEventCallback","event","data","value","registeredTabs","onRegister","JSON","stringify","onUnregister","getRegisteredTabs","useCallback","components","root","slot","always","getIntrinsicElementProps","useMergedRefs","role","elementType"],"mappings":";;;;+BAWiBA;;;eAAAA;;;;iEAXM;8BACiB;gCAC8D;AAS3F,MAAMA,sBAAsB,CAACC,OAAOC;IAC3C,MAAM,EAAEC,aAAa,aAAa,EAAEC,0BAA0B,IAAI,EAAEC,WAAW,KAAK,EAAEC,WAAW,EAAEC,OAAO,QAAQ,EAAEC,WAAW,KAAK,EAAE,
|
|
1
|
+
{"version":3,"sources":["useTabList.js"],"sourcesContent":["import * as React from 'react';\nimport { useArrowNavigationGroup } from '@fluentui/react-tabster';\nimport { getIntrinsicElementProps, useControllableState, useEventCallback, useMergedRefs, slot } from '@fluentui/react-utilities';\n/**\n * Create the state required to render TabList.\n *\n * The returned state can be modified with hooks such as useTabListStyles_unstable,\n * before being passed to renderTabList_unstable.\n *\n * @param props - props from this instance of TabList\n * @param ref - reference to root HTMLElement of TabList\n */ export const useTabList_unstable = (props, ref)=>{\n const { appearance = 'transparent', reserveSelectedTabSpace = true, disabled = false, onTabSelect, selectTabOnFocus = false, size = 'medium', vertical = false } = props;\n const innerRef = React.useRef(null);\n const focusAttributes = useArrowNavigationGroup({\n circular: true,\n axis: vertical ? 'vertical' : 'horizontal',\n memorizeCurrent: true\n });\n const [selectedValue, setSelectedValue] = useControllableState({\n state: props.selectedValue,\n defaultState: props.defaultSelectedValue,\n initialState: undefined\n });\n // considered usePrevious, but it is sensitive to re-renders\n // this could cause the previous to move to current in the case where the tab list re-renders.\n // these refs avoid getRegisteredTabs changing when selectedValue changes and causing\n // renders for tabs that have not changed.\n const currentSelectedValue = React.useRef(undefined);\n const previousSelectedValue = React.useRef(undefined);\n React.useEffect(()=>{\n previousSelectedValue.current = currentSelectedValue.current;\n currentSelectedValue.current = selectedValue;\n }, [\n selectedValue\n ]);\n const onSelect = useEventCallback((event, data)=>{\n setSelectedValue(data.value);\n onTabSelect === null || onTabSelect === void 0 ? void 0 : onTabSelect(event, data);\n });\n const registeredTabs = React.useRef({});\n const onRegister = useEventCallback((data)=>{\n registeredTabs.current[JSON.stringify(data.value)] = data;\n });\n const onUnregister = useEventCallback((data)=>{\n delete registeredTabs.current[JSON.stringify(data.value)];\n });\n const getRegisteredTabs = React.useCallback(()=>{\n return {\n selectedValue: currentSelectedValue.current,\n previousSelectedValue: previousSelectedValue.current,\n registeredTabs: registeredTabs.current\n };\n }, []);\n return {\n components: {\n root: 'div'\n },\n root: slot.always(getIntrinsicElementProps('div', {\n // FIXME:\n // `ref` is wrongly assigned to be `HTMLElement` instead of `HTMLDivElement`\n // but since it would be a breaking change to fix it, we are casting ref to it's proper type\n ref: useMergedRefs(ref, innerRef),\n role: 'tablist',\n 'aria-orientation': vertical ? 'vertical' : 'horizontal',\n ...focusAttributes,\n ...props\n }), {\n elementType: 'div'\n }),\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectTabOnFocus,\n selectedValue,\n size,\n vertical,\n onRegister,\n onUnregister,\n onSelect,\n getRegisteredTabs\n };\n};\n"],"names":["useTabList_unstable","props","ref","appearance","reserveSelectedTabSpace","disabled","onTabSelect","selectTabOnFocus","size","vertical","innerRef","React","useRef","focusAttributes","useArrowNavigationGroup","circular","axis","memorizeCurrent","selectedValue","setSelectedValue","useControllableState","state","defaultState","defaultSelectedValue","initialState","undefined","currentSelectedValue","previousSelectedValue","useEffect","current","onSelect","useEventCallback","event","data","value","registeredTabs","onRegister","JSON","stringify","onUnregister","getRegisteredTabs","useCallback","components","root","slot","always","getIntrinsicElementProps","useMergedRefs","role","elementType"],"mappings":";;;;+BAWiBA;;;eAAAA;;;;iEAXM;8BACiB;gCAC8D;AAS3F,MAAMA,sBAAsB,CAACC,OAA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,WAAW,CAAC;QACxC,OAAO;YACHvB,eAAeQ,qBAAqBG,OAAO;YAC3CF,uBAAuBA,sBAAsBE,OAAO;YACpDM,gBAAgBA,eAAeN,OAAO;QAC1C;IACJ,GAAG,EAAE;IACL,OAAO;QACHa,YAAY;YACRC,MAAM;QACV;QACAA,MAAMC,oBAAI,CAACC,MAAM,CAACC,IAAAA,wCAAwB,EAAC,OAAO;YAC9C,SAAS;YACT,4EAA4E;YAC5E,4FAA4F;YAC5F5C,KAAK6C,IAAAA,6BAAa,EAAC7C,KAAKQ;YACxBsC,MAAM;YACN,oBAAoBvC,WAAW,aAAa;YAC5C,GAAGI,eAAe;YAClB,GAAGZ,KAAK;QACZ,IAAI;YACAgD,aAAa;QACjB;QACA9C;QACAC;QACAC;QACAE;QACAW;QACAV;QACAC;QACA2B;QACAG;QACAT;QACAU;IACJ;AACJ"}
|
|
@@ -9,11 +9,12 @@ Object.defineProperty(exports, "useTabListContextValues_unstable", {
|
|
|
9
9
|
}
|
|
10
10
|
});
|
|
11
11
|
function useTabListContextValues_unstable(state) {
|
|
12
|
-
const { appearance, reserveSelectedTabSpace, disabled, selectedValue: selectedKey, onRegister, onUnregister, onSelect, getRegisteredTabs, size, vertical } = state;
|
|
12
|
+
const { appearance, reserveSelectedTabSpace, disabled, selectTabOnFocus, selectedValue: selectedKey, onRegister, onUnregister, onSelect, getRegisteredTabs, size, vertical } = state;
|
|
13
13
|
const tabList = {
|
|
14
14
|
appearance,
|
|
15
15
|
reserveSelectedTabSpace,
|
|
16
16
|
disabled,
|
|
17
|
+
selectTabOnFocus,
|
|
17
18
|
selectedValue: selectedKey,
|
|
18
19
|
onSelect,
|
|
19
20
|
onRegister,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["useTabListContextValues.js"],"sourcesContent":["export function useTabListContextValues_unstable(state) {\n const { appearance, reserveSelectedTabSpace, disabled, selectedValue: selectedKey, onRegister, onUnregister, onSelect, getRegisteredTabs, size, vertical } = state;\n const tabList = {\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectedValue: selectedKey,\n onSelect,\n onRegister,\n onUnregister,\n getRegisteredTabs,\n size,\n vertical\n };\n return {\n tabList\n };\n}\n"],"names":["useTabListContextValues_unstable","state","appearance","reserveSelectedTabSpace","disabled","selectedValue","selectedKey","onRegister","onUnregister","onSelect","getRegisteredTabs","size","vertical","tabList"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,iCAAiCC,KAAK;IAClD,MAAM,EAAEC,UAAU,EAAEC,uBAAuB,EAAEC,QAAQ,EAAEC,eAAeC,WAAW,EAAEC,UAAU,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,IAAI,EAAEC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"sources":["useTabListContextValues.js"],"sourcesContent":["export function useTabListContextValues_unstable(state) {\n const { appearance, reserveSelectedTabSpace, disabled, selectTabOnFocus, selectedValue: selectedKey, onRegister, onUnregister, onSelect, getRegisteredTabs, size, vertical } = state;\n const tabList = {\n appearance,\n reserveSelectedTabSpace,\n disabled,\n selectTabOnFocus,\n selectedValue: selectedKey,\n onSelect,\n onRegister,\n onUnregister,\n getRegisteredTabs,\n size,\n vertical\n };\n return {\n tabList\n };\n}\n"],"names":["useTabListContextValues_unstable","state","appearance","reserveSelectedTabSpace","disabled","selectTabOnFocus","selectedValue","selectedKey","onRegister","onUnregister","onSelect","getRegisteredTabs","size","vertical","tabList"],"mappings":";;;;+BAAgBA;;;eAAAA;;;AAAT,SAASA,iCAAiCC,KAAK;IAClD,MAAM,EAAEC,UAAU,EAAEC,uBAAuB,EAAEC,QAAQ,EAAEC,gBAAgB,EAAEC,eAAeC,WAAW,EAAEC,UAAU,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,iBAAiB,EAAEC,IAAI,EAAEC,QAAQ,EAAE,GAAGZ;IAC/K,MAAMa,UAAU;QACZZ;QACAC;QACAC;QACAC;QACAC,eAAeC;QACfG;QACAF;QACAC;QACAE;QACAC;QACAC;IACJ;IACA,OAAO;QACHC;IACJ;AACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluentui/react-tabs",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.4.0",
|
|
4
4
|
"description": "Fluent UI React tabs components",
|
|
5
5
|
"main": "lib-commonjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"@fluentui/scripts-tasks": "*"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fluentui/react-context-selector": "^9.1.
|
|
36
|
-
"@fluentui/react-jsx-runtime": "^9.0.
|
|
37
|
-
"@fluentui/react-shared-contexts": "^9.13.
|
|
38
|
-
"@fluentui/react-tabster": "^9.15.
|
|
35
|
+
"@fluentui/react-context-selector": "^9.1.43",
|
|
36
|
+
"@fluentui/react-jsx-runtime": "^9.0.21",
|
|
37
|
+
"@fluentui/react-shared-contexts": "^9.13.1",
|
|
38
|
+
"@fluentui/react-tabster": "^9.15.1",
|
|
39
39
|
"@fluentui/react-theme": "^9.1.16",
|
|
40
|
-
"@fluentui/react-utilities": "^9.15.
|
|
40
|
+
"@fluentui/react-utilities": "^9.15.3",
|
|
41
41
|
"@griffel/react": "^1.5.14",
|
|
42
42
|
"@swc/helpers": "^0.5.1"
|
|
43
43
|
},
|