@workday/canvas-kit-preview-react 16.0.0-alpha.0474-next.0 → 16.0.0-alpha.0476-next.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/dist/commonjs/index.d.ts +1 -0
- package/dist/commonjs/index.d.ts.map +1 -1
- package/dist/commonjs/index.js +1 -0
- package/dist/commonjs/tabs/index.d.ts +7 -0
- package/dist/commonjs/tabs/index.d.ts.map +1 -0
- package/dist/commonjs/tabs/index.js +22 -0
- package/dist/commonjs/tabs/lib/Tabs.d.ts +9555 -0
- package/dist/commonjs/tabs/lib/Tabs.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/Tabs.js +127 -0
- package/dist/commonjs/tabs/lib/TabsItem.d.ts +719 -0
- package/dist/commonjs/tabs/lib/TabsItem.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/TabsItem.js +50 -0
- package/dist/commonjs/tabs/lib/TabsList.d.ts +998 -0
- package/dist/commonjs/tabs/lib/TabsList.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/TabsList.js +121 -0
- package/dist/commonjs/tabs/lib/TabsOverflowButton.d.ts +650 -0
- package/dist/commonjs/tabs/lib/TabsOverflowButton.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/TabsOverflowButton.js +28 -0
- package/dist/commonjs/tabs/lib/TabsPanel.d.ts +654 -0
- package/dist/commonjs/tabs/lib/TabsPanel.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/TabsPanel.js +42 -0
- package/dist/commonjs/tabs/lib/TabsPanels.d.ts +320 -0
- package/dist/commonjs/tabs/lib/TabsPanels.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/TabsPanels.js +13 -0
- package/dist/commonjs/tabs/lib/useTabsModel.d.ts +5924 -0
- package/dist/commonjs/tabs/lib/useTabsModel.d.ts.map +1 -0
- package/dist/commonjs/tabs/lib/useTabsModel.js +128 -0
- package/dist/es6/index.d.ts +1 -0
- package/dist/es6/index.d.ts.map +1 -1
- package/dist/es6/index.js +1 -0
- package/dist/es6/tabs/index.d.ts +7 -0
- package/dist/es6/tabs/index.d.ts.map +1 -0
- package/dist/es6/tabs/index.js +6 -0
- package/dist/es6/tabs/lib/Tabs.d.ts +9555 -0
- package/dist/es6/tabs/lib/Tabs.d.ts.map +1 -0
- package/dist/es6/tabs/lib/Tabs.js +124 -0
- package/dist/es6/tabs/lib/TabsItem.d.ts +719 -0
- package/dist/es6/tabs/lib/TabsItem.d.ts.map +1 -0
- package/dist/es6/tabs/lib/TabsItem.js +47 -0
- package/dist/es6/tabs/lib/TabsList.d.ts +998 -0
- package/dist/es6/tabs/lib/TabsList.d.ts.map +1 -0
- package/dist/es6/tabs/lib/TabsList.js +95 -0
- package/dist/es6/tabs/lib/TabsOverflowButton.d.ts +650 -0
- package/dist/es6/tabs/lib/TabsOverflowButton.d.ts.map +1 -0
- package/dist/es6/tabs/lib/TabsOverflowButton.js +25 -0
- package/dist/es6/tabs/lib/TabsPanel.d.ts +654 -0
- package/dist/es6/tabs/lib/TabsPanel.d.ts.map +1 -0
- package/dist/es6/tabs/lib/TabsPanel.js +36 -0
- package/dist/es6/tabs/lib/TabsPanels.d.ts +320 -0
- package/dist/es6/tabs/lib/TabsPanels.d.ts.map +1 -0
- package/dist/es6/tabs/lib/TabsPanels.js +10 -0
- package/dist/es6/tabs/lib/useTabsModel.d.ts +5924 -0
- package/dist/es6/tabs/lib/useTabsModel.d.ts.map +1 -0
- package/dist/es6/tabs/lib/useTabsModel.js +122 -0
- package/index.ts +1 -0
- package/package.json +4 -4
- package/tabs/index.ts +7 -0
- package/tabs/lib/Tabs.tsx +135 -0
- package/tabs/lib/TabsItem.tsx +274 -0
- package/tabs/lib/TabsList.tsx +181 -0
- package/tabs/lib/TabsOverflowButton.tsx +61 -0
- package/tabs/lib/TabsPanel.tsx +77 -0
- package/tabs/lib/TabsPanels.tsx +20 -0
- package/tabs/lib/useTabsModel.tsx +141 -0
- package/tabs/package.json +6 -0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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BL,CAAC"}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { defaultGetId, useListModel, useOverflowListModel, } from '@workday/canvas-kit-react/collection';
|
|
3
|
+
import { createModelHook, useModalityType } from '@workday/canvas-kit-react/common';
|
|
4
|
+
import { useMenuModel } from '@workday/canvas-kit-react/menu';
|
|
5
|
+
/**
|
|
6
|
+
* The TabsModel extends the [Collection
|
|
7
|
+
* System](/get-started/for-developers/guides/collection-api/). Tabs have tab items and
|
|
8
|
+
* panels. Tabs can be overflowed if there isn't enough room to render and will overflow to a
|
|
9
|
+
* {@link MenuModel} sub-model.
|
|
10
|
+
*
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const model = useTabsModel({
|
|
13
|
+
* onSelect(data) {
|
|
14
|
+
* console.log('Selected Tab', data)
|
|
15
|
+
* }
|
|
16
|
+
* })
|
|
17
|
+
*
|
|
18
|
+
* <Tabs model={model}>{Tabs child components}</Tabs>
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export const useTabsModel = createModelHook({
|
|
22
|
+
defaultConfig: {
|
|
23
|
+
...useOverflowListModel.defaultConfig,
|
|
24
|
+
/**
|
|
25
|
+
* Optional id for the whole `Tabs` group. The `aria-controls` of the `Tab.Item` and `id` of the
|
|
26
|
+
* `Tab.Panel` will automatically be derived from this id. If not provided, a unique id will be
|
|
27
|
+
* created.
|
|
28
|
+
* @default useUniqueId()
|
|
29
|
+
*/
|
|
30
|
+
id: '',
|
|
31
|
+
/**
|
|
32
|
+
* An initially selected tab. This value must match the `name` of the `Tab.Item` component. If
|
|
33
|
+
* not provided, the first tab will be selected.
|
|
34
|
+
*/
|
|
35
|
+
initialTab: '',
|
|
36
|
+
/**
|
|
37
|
+
* The default Tabs sub-components only handle rendering of tabs in a horizontal orientation, but
|
|
38
|
+
* the sub-components could be replaced to handle vertical orientations.
|
|
39
|
+
* @default 'horizontal'
|
|
40
|
+
*/
|
|
41
|
+
orientation: 'horizontal',
|
|
42
|
+
/**
|
|
43
|
+
* The variant of the Tabs.
|
|
44
|
+
* @default 'filled'
|
|
45
|
+
*/
|
|
46
|
+
variant: 'filled',
|
|
47
|
+
menuConfig: {},
|
|
48
|
+
},
|
|
49
|
+
requiredConfig: useOverflowListModel.requiredConfig,
|
|
50
|
+
contextOverride: useOverflowListModel.Context,
|
|
51
|
+
})(config => {
|
|
52
|
+
var _a;
|
|
53
|
+
const initialSelectedRef = React.useRef(config.initialTab);
|
|
54
|
+
const getId = config.getId || defaultGetId;
|
|
55
|
+
const modality = useModalityType();
|
|
56
|
+
const model = useOverflowListModel(useOverflowListModel.mergeConfig(config, {
|
|
57
|
+
shouldCalculateOverflow: modality !== 'touch',
|
|
58
|
+
orientation: config.orientation || 'horizontal',
|
|
59
|
+
onRegisterItem(data) {
|
|
60
|
+
if (!initialSelectedRef.current) {
|
|
61
|
+
initialSelectedRef.current = data.id;
|
|
62
|
+
events.select({ id: initialSelectedRef.current });
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
initialSelectedIds: config.initialTab
|
|
66
|
+
? [config.initialTab]
|
|
67
|
+
: ((_a = config.items) === null || _a === void 0 ? void 0 : _a.length)
|
|
68
|
+
? [getId(config.items[0])]
|
|
69
|
+
: [],
|
|
70
|
+
shouldVirtualize: false,
|
|
71
|
+
}));
|
|
72
|
+
const panels = useListModel();
|
|
73
|
+
const state = {
|
|
74
|
+
...model.state,
|
|
75
|
+
getId,
|
|
76
|
+
orientation: config.orientation || 'horizontal',
|
|
77
|
+
/**
|
|
78
|
+
* A list of panels. Uses `ListModel`
|
|
79
|
+
*/
|
|
80
|
+
panels: panels.state.items,
|
|
81
|
+
/**
|
|
82
|
+
* A React.Ref of the current item index. A ref is used to allow for updating outside the normal
|
|
83
|
+
* React state cycle to ensure accurate index tracking as items are registered within the same
|
|
84
|
+
* state setting phase.
|
|
85
|
+
*/
|
|
86
|
+
panelIndexRef: panels.state.indexRef,
|
|
87
|
+
variant: config.variant || 'filled',
|
|
88
|
+
};
|
|
89
|
+
const overflowItems = React.useMemo(() => config.items ? config.items.filter(item => state.hiddenIds.includes(getId(item))) : undefined,
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
[state.hiddenIds, config.items]);
|
|
92
|
+
const events = {
|
|
93
|
+
...model.events,
|
|
94
|
+
/**
|
|
95
|
+
* This event registers panels with state.panels. Called when a panel is mounted.
|
|
96
|
+
*/
|
|
97
|
+
registerPanel: panels.events.registerItem,
|
|
98
|
+
/**
|
|
99
|
+
* This event unregisters panels with state.panels. Called when a panel is unmounted.
|
|
100
|
+
*/
|
|
101
|
+
unregisterPanel: panels.events.unregisterItem,
|
|
102
|
+
};
|
|
103
|
+
const menu = useMenuModel(useMenuModel.mergeConfig(config.menuConfig, {
|
|
104
|
+
id: `menu-${model.state.id}`,
|
|
105
|
+
items: overflowItems,
|
|
106
|
+
nonInteractiveIds: state.nonInteractiveIds.filter(key => !state.hiddenIds.includes(key)),
|
|
107
|
+
onSelect(data) {
|
|
108
|
+
menu.events.hide();
|
|
109
|
+
events.select(data);
|
|
110
|
+
},
|
|
111
|
+
onShow() {
|
|
112
|
+
// Always select the first item when the menu is opened
|
|
113
|
+
menu.events.goToFirst();
|
|
114
|
+
},
|
|
115
|
+
}));
|
|
116
|
+
return {
|
|
117
|
+
...model,
|
|
118
|
+
state,
|
|
119
|
+
events,
|
|
120
|
+
menu,
|
|
121
|
+
};
|
|
122
|
+
});
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-preview-react",
|
|
3
|
-
"version": "16.0.0-alpha.
|
|
3
|
+
"version": "16.0.0-alpha.0476-next.0",
|
|
4
4
|
"description": "Canvas Kit Preview is made up of components that have the full design and a11y review, are part of the DS ecosystem and are approved for use in product. The API's could be subject to change, but not without strong communication and migration strategies.",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@emotion/react": "^11.7.1",
|
|
50
50
|
"@emotion/styled": "^11.6.0",
|
|
51
|
-
"@workday/canvas-kit-react": "^16.0.0-alpha.
|
|
52
|
-
"@workday/canvas-kit-styling": "^16.0.0-alpha.
|
|
51
|
+
"@workday/canvas-kit-react": "^16.0.0-alpha.0476-next.0",
|
|
52
|
+
"@workday/canvas-kit-styling": "^16.0.0-alpha.0476-next.0",
|
|
53
53
|
"@workday/canvas-system-icons-web": "4.0.4",
|
|
54
54
|
"@workday/canvas-tokens-web": "4.4.0-beta.6",
|
|
55
55
|
"@workday/design-assets-types": "^0.3.0"
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"react-hook-form": "7.36.1",
|
|
61
61
|
"yup": "^0.32.11"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "2d96fab9d2a9a47e06b99ae59e5f939799efa76d"
|
|
64
64
|
}
|
package/tabs/index.ts
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createContainer} from '@workday/canvas-kit-react/common';
|
|
4
|
+
import {Menu} from '@workday/canvas-kit-react/menu';
|
|
5
|
+
|
|
6
|
+
import {TabsItem} from './TabsItem';
|
|
7
|
+
import {TabsList} from './TabsList';
|
|
8
|
+
import {TabsOverflowButton} from './TabsOverflowButton';
|
|
9
|
+
import {TabsPanel} from './TabsPanel';
|
|
10
|
+
import {TabsPanels} from './TabsPanels';
|
|
11
|
+
import {useTabsModel} from './useTabsModel';
|
|
12
|
+
|
|
13
|
+
// use `T = any` here because there's no way to pass generics to a compound component...
|
|
14
|
+
export interface TabsProps {
|
|
15
|
+
/**
|
|
16
|
+
* The contents of the Tabs. Can be `Tabs` children or any valid elements.
|
|
17
|
+
*/
|
|
18
|
+
children: React.ReactNode;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* `Tabs` is a container component that is responsible for creating a {@link TabsModel} and sharing
|
|
23
|
+
* it with its subcomponents using React context. It does not represent a real element.
|
|
24
|
+
*
|
|
25
|
+
* ```tsx
|
|
26
|
+
* <Tabs onSelect={data => console.log('Selected tab', data.id)}>
|
|
27
|
+
* {child components}
|
|
28
|
+
* </Tabs>
|
|
29
|
+
* ```
|
|
30
|
+
*
|
|
31
|
+
* Alternatively, you may pass in a model using the hoisted model pattern.
|
|
32
|
+
*
|
|
33
|
+
* ```tsx
|
|
34
|
+
* const model = useTabsModel({
|
|
35
|
+
* onSelect(data) {
|
|
36
|
+
* console.log('Activated Tab', data.id);
|
|
37
|
+
* },
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* <Tabs model={model}>{child components}</Tabs>
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* See [Configuring a
|
|
44
|
+
* Model](/get-started/for-developers/documentation/compound-components/#configuring-a-model) for
|
|
45
|
+
* more information on model configuration.
|
|
46
|
+
*/
|
|
47
|
+
export const Tabs = createContainer()({
|
|
48
|
+
displayName: 'Tabs',
|
|
49
|
+
modelHook: useTabsModel,
|
|
50
|
+
subComponents: {
|
|
51
|
+
/**
|
|
52
|
+
* `Tabs.List` is a `<div role="tablist">` element. It is a container for {@link TabsItem Tabs.Item}
|
|
53
|
+
* subcomponents.
|
|
54
|
+
*
|
|
55
|
+
* ```tsx
|
|
56
|
+
* <Tabs.List>{Tabs.Items}</Tabs.List>
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
List: TabsList,
|
|
60
|
+
/**
|
|
61
|
+
* `Tabs.Item` is a `<button role="tab">` element. Each `Tabs.Item` is associated with a
|
|
62
|
+
* `Tabs.Panel` either by a `data-id` attribute or by the position in the list. If a `data-id`
|
|
63
|
+
* is provided, it must match the `data-id` passed to the corresponding `Tabs.Panel` component.
|
|
64
|
+
*
|
|
65
|
+
* ```tsx
|
|
66
|
+
* <Tabs.Item data-id="first">First Tab</Tabs.Item>
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
Item: TabsItem,
|
|
70
|
+
/**
|
|
71
|
+
* `Tabs.Panel` is a `<div role="tabpanel">` element. It is focusable by default. Each
|
|
72
|
+
* `Tabs.Panel` is controlled by a `Tabs.Item` either by a `data-id` attribute or by the
|
|
73
|
+
* position in the list. If a `data-id` is provided, it must match the `data-id` passed to the
|
|
74
|
+
* corresponding `Tabs.Item` component.
|
|
75
|
+
*
|
|
76
|
+
* ```tsx
|
|
77
|
+
* <Tabs.Panel data-id="first">
|
|
78
|
+
* {contents of tab panel}
|
|
79
|
+
* </Tabs.Panel>
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
Panel: TabsPanel,
|
|
83
|
+
/**
|
|
84
|
+
* Optional subcomponent of tabs that makes dealing with dynamic tabs easier. `Tabs.Panels` only
|
|
85
|
+
* works if the model is given an array of items.
|
|
86
|
+
*
|
|
87
|
+
* ```tsx
|
|
88
|
+
* const items = [{ id: '1', name: 'first' }]
|
|
89
|
+
* <Tabs items={items}>
|
|
90
|
+
* {tab list}
|
|
91
|
+
* <Tabs.Panels>
|
|
92
|
+
* {item => <Tabs.Panel>Contents of {item.name}</Tabs.Panel>}
|
|
93
|
+
* </Tabs.Panels>
|
|
94
|
+
* </Tabs>
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
Panels: TabsPanels,
|
|
98
|
+
/**
|
|
99
|
+
* The overflow button of a `Tabs.List`. When a tab list overflows, this overflow button is
|
|
100
|
+
* rendered. Overflow only works when the model is given an array of `items`.
|
|
101
|
+
*
|
|
102
|
+
* ```tsx
|
|
103
|
+
* <Tabs items={items}>
|
|
104
|
+
* <Tabs.List overflowButton={
|
|
105
|
+
* <Tabs.OverflowButton>More</Tabs.OverflowButton>
|
|
106
|
+
* }>
|
|
107
|
+
* {dynamic tab items}
|
|
108
|
+
* </Tabs.List>
|
|
109
|
+
* </Tabs>
|
|
110
|
+
* ```
|
|
111
|
+
*/
|
|
112
|
+
OverflowButton: TabsOverflowButton,
|
|
113
|
+
/**
|
|
114
|
+
* The overflow menu of the Tabs component. If there isn't enough room to render all the tab
|
|
115
|
+
* items, the extra tabs that don't fit will be overflowed into this menu.
|
|
116
|
+
*
|
|
117
|
+
* ```tsx
|
|
118
|
+
* <Tabs.Menu.Popper>
|
|
119
|
+
* <Tabs.Menu.Card>
|
|
120
|
+
* <Tabs.Menu.List>
|
|
121
|
+
* {(item: MyTabItem) => <Tabs.Menu.Item data-id={item.id}>
|
|
122
|
+
* {item.text}
|
|
123
|
+
* </Tabs.Menu.Item>}
|
|
124
|
+
* </Tabs.Menu.List>
|
|
125
|
+
* </Tabs.Menu.Card>
|
|
126
|
+
* </Tabs.Menu.Popper>
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
// We don't use shorthand here for documentation. The shorthand will give the `Tabs.Menu` the
|
|
130
|
+
// JSDoc of `Menu` instead of `Tabs.Menu`
|
|
131
|
+
Menu: Menu,
|
|
132
|
+
},
|
|
133
|
+
})<TabsProps>(({children}, _, model) => {
|
|
134
|
+
return <Menu model={model.menu}>{children}</Menu>;
|
|
135
|
+
});
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
isSelected,
|
|
5
|
+
useListItemRegister,
|
|
6
|
+
useListItemRovingFocus,
|
|
7
|
+
useListItemSelect,
|
|
8
|
+
useOverflowListItemMeasure,
|
|
9
|
+
} from '@workday/canvas-kit-react/collection';
|
|
10
|
+
import {
|
|
11
|
+
EllipsisText,
|
|
12
|
+
ExtractProps,
|
|
13
|
+
composeHooks,
|
|
14
|
+
cornerShapeStencil,
|
|
15
|
+
createComponent,
|
|
16
|
+
createElemPropsHook,
|
|
17
|
+
createSubcomponent,
|
|
18
|
+
focusRing,
|
|
19
|
+
slugify,
|
|
20
|
+
useModalityType,
|
|
21
|
+
} from '@workday/canvas-kit-react/common';
|
|
22
|
+
import {SystemIcon, systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
23
|
+
import {Box, FlexProps, mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
24
|
+
import {OverflowTooltip} from '@workday/canvas-kit-react/tooltip';
|
|
25
|
+
import {createStencil, px2rem} from '@workday/canvas-kit-styling';
|
|
26
|
+
import {base, component, system} from '@workday/canvas-tokens-web';
|
|
27
|
+
|
|
28
|
+
import {useTabsModel} from './useTabsModel';
|
|
29
|
+
|
|
30
|
+
export interface TabsItemProps
|
|
31
|
+
extends ExtractProps<typeof Box, never>,
|
|
32
|
+
Partial<Pick<FlexProps, 'gap'>> {
|
|
33
|
+
/**
|
|
34
|
+
* Optionally pass index to tab item. This should be done if `Tabs.Item` components were created
|
|
35
|
+
* via a `Array::map` function. This index will ensure keyboard navigation works even if items are
|
|
36
|
+
* inserted out of order.
|
|
37
|
+
*/
|
|
38
|
+
index?: number;
|
|
39
|
+
/**
|
|
40
|
+
* The contents of the tab item. This will be the accessible name of the tab for screen readers.
|
|
41
|
+
* Often, this is text. Icons are also supported. Using `Tabs.Icon` will render an icon that is
|
|
42
|
+
* not visible to screen readers and therefore the icon should not be necessary to understand the
|
|
43
|
+
* tab. In most circumstances, `aria-label` should not be used.
|
|
44
|
+
*
|
|
45
|
+
* ```tsx
|
|
46
|
+
* <Tabs.Item>First Tab</Tabs.Item>
|
|
47
|
+
* <Tabs.Item>
|
|
48
|
+
* <Tabs.Icon icon={canvasIcon} />
|
|
49
|
+
* <Tabs.Text>Second Tab</Tabs.Text>
|
|
50
|
+
* </Tabs.Item>
|
|
51
|
+
* ```
|
|
52
|
+
*/
|
|
53
|
+
children: React.ReactNode;
|
|
54
|
+
/**
|
|
55
|
+
* The identifier of the tab. This identifier will be used in change events and for `initialTab`.
|
|
56
|
+
* Must match the `data-id` of the associated tab panel. If this property is not provided, it will
|
|
57
|
+
* default to a string representation of the the zero-based index of the Tab when it was
|
|
58
|
+
* initialized.
|
|
59
|
+
*/
|
|
60
|
+
'data-id'?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Optional id. If not set, it will inherit the ID passed to the `Tabs` component and append the
|
|
63
|
+
* index at the end. Only set this for advanced cases.
|
|
64
|
+
*/
|
|
65
|
+
id?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Part of the ARIA specification for tabs. This attributes links a `role=tab` to a
|
|
68
|
+
* `role=tabpanel`. This value must be the same as the associated `id` attribute of the tab panel.
|
|
69
|
+
* This is automatically set by the component and should only be used in advanced cases.
|
|
70
|
+
*/
|
|
71
|
+
'aria-controls'?: string;
|
|
72
|
+
/**
|
|
73
|
+
* Part of the ARIA specification for tabs. Lets screen readers know which tab is active. This
|
|
74
|
+
* should either be `true` or `undefined` and never `false`. This is automatically set by the
|
|
75
|
+
* component and should only be used in advanced cases.
|
|
76
|
+
*/
|
|
77
|
+
'aria-selected'?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Part of the ARIA specification for tabs. The currently active tab should not have a `tabIndex`
|
|
80
|
+
* set while all inactive tabs should have a `tabIndex={-1}`
|
|
81
|
+
*/
|
|
82
|
+
tabIndex?: number;
|
|
83
|
+
/**
|
|
84
|
+
* The variant of the TabsItem.
|
|
85
|
+
* @default 'filled'
|
|
86
|
+
*/
|
|
87
|
+
variant?: 'filled' | 'outlined';
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
const tabItemStencil = createStencil({
|
|
91
|
+
extends: cornerShapeStencil,
|
|
92
|
+
base: {
|
|
93
|
+
[cornerShapeStencil.vars.shape]: system.legacy.shape.lg,
|
|
94
|
+
...system.legacy.type.subtext.lg,
|
|
95
|
+
fontWeight: system.fontWeight.medium,
|
|
96
|
+
backgroundColor: system.legacy.color.surface.transparent,
|
|
97
|
+
flex: '0 0 auto',
|
|
98
|
+
minWidth: 0,
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
padding: `0 ${system.legacy.padding.md}`,
|
|
101
|
+
height: system.legacy.size.md,
|
|
102
|
+
cursor: 'pointer',
|
|
103
|
+
color: system.color.fg.default,
|
|
104
|
+
position: 'relative',
|
|
105
|
+
transition: 'background 150ms ease, color 150ms ease',
|
|
106
|
+
whiteSpace: 'nowrap',
|
|
107
|
+
textOverflow: 'ellipsis',
|
|
108
|
+
overflow: 'hidden',
|
|
109
|
+
[systemIconStencil.vars.color]: 'currentColor',
|
|
110
|
+
[systemIconStencil.vars.size]: component.legacy.systemIcon.size.md,
|
|
111
|
+
|
|
112
|
+
'&:has(span)': {
|
|
113
|
+
display: 'flex',
|
|
114
|
+
gap: base.legacy.size75,
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
'&:hover, &.hover': {
|
|
118
|
+
color: system.color.fg.strong,
|
|
119
|
+
[systemIconStencil.vars.color]: system.color.fg.strong,
|
|
120
|
+
},
|
|
121
|
+
|
|
122
|
+
'&:focus-visible, &.focus': {
|
|
123
|
+
// focus outline for Windows high contrast theme
|
|
124
|
+
outline: `${px2rem(2)} solid transparent`,
|
|
125
|
+
backgroundColor: system.legacy.color.surface.transparent,
|
|
126
|
+
color: system.color.fg.strong,
|
|
127
|
+
[systemIconStencil.vars.color]: system.color.fg.strong,
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// Using opacity token applied to container to achieve disabled state instead of 'disabled" color tokens for
|
|
131
|
+
// icon and text colors
|
|
132
|
+
'&:disabled, &.disabled, &[aria-disabled]': {
|
|
133
|
+
opacity: system.opacity.disabled,
|
|
134
|
+
'&:hover': {
|
|
135
|
+
cursor: 'auto',
|
|
136
|
+
backgroundColor: system.legacy.color.surface.transparent,
|
|
137
|
+
[systemIconStencil.vars.color]: system.color.fg.default,
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
'&[aria-selected=true]': {
|
|
142
|
+
color: system.color.fg.default,
|
|
143
|
+
[systemIconStencil.vars.color]: system.color.fg.default,
|
|
144
|
+
'&:hover, &.hover, &:focus-visible, &.focus': {
|
|
145
|
+
color: system.color.fg.default,
|
|
146
|
+
[systemIconStencil.vars.color]: system.color.fg.default,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
modifiers: {
|
|
151
|
+
variant: {
|
|
152
|
+
filled: {
|
|
153
|
+
border: `${px2rem(1)} solid transparent`,
|
|
154
|
+
|
|
155
|
+
'&:hover, &.hover': {
|
|
156
|
+
backgroundColor: system.legacy.color.surface.overlay.hover.default,
|
|
157
|
+
},
|
|
158
|
+
|
|
159
|
+
'&:focus-visible, &.focus': {
|
|
160
|
+
...focusRing({
|
|
161
|
+
width: 2,
|
|
162
|
+
separation: 2,
|
|
163
|
+
innerColor: system.legacy.color.focus.inverse,
|
|
164
|
+
outerColor: system.legacy.color.brand.focus.primary,
|
|
165
|
+
}),
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
'&[aria-selected=true]': {
|
|
169
|
+
backgroundColor: system.legacy.color.surface.overlay.pressed.default,
|
|
170
|
+
borderColor: system.color.border.input.default,
|
|
171
|
+
'&:hover, &.hover, &:focus-visible, &.focus': {
|
|
172
|
+
backgroundColor: system.legacy.color.surface.overlay.pressed.default,
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
'&:focus-visible, &.focus': {
|
|
176
|
+
borderWidth: px2rem(2),
|
|
177
|
+
marginInline: px2rem(-1),
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
// Non-color outline indicator for Windows high contrast theme
|
|
181
|
+
'@media (forced-colors: active)': {
|
|
182
|
+
outline: `${px2rem(2)} solid ButtonBorder`,
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
outlined: {
|
|
187
|
+
border: `${px2rem(1)} solid ${system.legacy.color.border.default}`,
|
|
188
|
+
// adding extra margin to the left and right of the tab item to avoid visual glitch when the tab is selected
|
|
189
|
+
marginInline: px2rem(1),
|
|
190
|
+
|
|
191
|
+
'&:hover, &.hover': {
|
|
192
|
+
borderColor: system.legacy.color.border.strong,
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
'&:focus-visible, &.focus': {
|
|
196
|
+
marginInline: px2rem(0),
|
|
197
|
+
border: `${px2rem(2)} solid ${system.legacy.color.brand.focus.primary}`,
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
'&[aria-selected=true]': {
|
|
201
|
+
marginInline: px2rem(0),
|
|
202
|
+
border: `${px2rem(2)} solid ${system.color.border.contrast.default}`,
|
|
203
|
+
'&:hover, &.hover, &:focus-visible, &.focus': {
|
|
204
|
+
border: `${px2rem(2)} solid ${system.color.border.contrast.default}`,
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
'&:focus-visible, &.focus': {
|
|
208
|
+
...focusRing({
|
|
209
|
+
width: 2,
|
|
210
|
+
separation: 2,
|
|
211
|
+
innerColor: system.legacy.color.focus.inverse,
|
|
212
|
+
outerColor: system.legacy.color.brand.focus.primary,
|
|
213
|
+
}),
|
|
214
|
+
},
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
export const StyledTabItem = createComponent('button')<TabsItemProps>({
|
|
222
|
+
displayName: 'StyledTabItem',
|
|
223
|
+
Component: ({children, variant, ...elemProps}, ref, Element) => {
|
|
224
|
+
return (
|
|
225
|
+
<Element ref={ref} {...mergeStyles(elemProps, tabItemStencil({variant}))}>
|
|
226
|
+
{children}
|
|
227
|
+
</Element>
|
|
228
|
+
);
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
export const useTabsItem = composeHooks(
|
|
233
|
+
createElemPropsHook(useTabsModel)(({state}, _, elemProps: {'data-id'?: string} = {}) => {
|
|
234
|
+
const name = elemProps['data-id'] || '';
|
|
235
|
+
|
|
236
|
+
const selected = !!elemProps['data-id'] && isSelected(name, state);
|
|
237
|
+
|
|
238
|
+
return {
|
|
239
|
+
type: 'button' as const,
|
|
240
|
+
role: 'tab' as const,
|
|
241
|
+
'aria-selected': selected,
|
|
242
|
+
'aria-controls': slugify(`tabpanel-${state.id}-${name}`),
|
|
243
|
+
};
|
|
244
|
+
}),
|
|
245
|
+
useListItemSelect,
|
|
246
|
+
useOverflowListItemMeasure,
|
|
247
|
+
useListItemRovingFocus,
|
|
248
|
+
useListItemRegister
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
export const TabsItem = createSubcomponent('button')({
|
|
252
|
+
displayName: 'Tabs.Item',
|
|
253
|
+
modelHook: useTabsModel,
|
|
254
|
+
elemPropsHook: useTabsItem,
|
|
255
|
+
subComponents: {
|
|
256
|
+
Icon: SystemIcon,
|
|
257
|
+
Text: EllipsisText,
|
|
258
|
+
},
|
|
259
|
+
})<TabsItemProps>(({children, ...elemProps}, Element, model) => {
|
|
260
|
+
const modality = useModalityType();
|
|
261
|
+
|
|
262
|
+
return (
|
|
263
|
+
<OverflowTooltip>
|
|
264
|
+
<StyledTabItem
|
|
265
|
+
as={Element}
|
|
266
|
+
maxWidth={modality === 'touch' ? undefined : 280}
|
|
267
|
+
{...elemProps}
|
|
268
|
+
variant={model.state.variant}
|
|
269
|
+
>
|
|
270
|
+
{children}
|
|
271
|
+
</StyledTabItem>
|
|
272
|
+
</OverflowTooltip>
|
|
273
|
+
);
|
|
274
|
+
});
|