@workday/canvas-kit-react 12.0.0-alpha.906-next.0 → 12.0.0-alpha.908-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/collection/index.ts +1 -0
- package/collection/lib/useListItemActiveDescendant.ts +26 -0
- package/combobox/lib/ComboboxMenu.tsx +1 -2
- package/combobox/lib/ComboboxMenuItem.tsx +3 -91
- package/dist/commonjs/action-bar/lib/ActionBar.d.ts +82 -10
- package/dist/commonjs/action-bar/lib/ActionBar.d.ts.map +1 -1
- package/dist/commonjs/avatar/lib/Avatar.js +21 -21
- package/dist/commonjs/badge/lib/CountBadge.js +3 -3
- package/dist/commonjs/breadcrumbs/lib/Breadcrumbs.d.ts +1 -1
- package/dist/commonjs/breadcrumbs/lib/BreadcrumbsMenu.d.ts +2 -2
- package/dist/commonjs/button/lib/BaseButton.js +21 -21
- package/dist/commonjs/button/lib/DeleteButton.js +1 -1
- package/dist/commonjs/button/lib/PrimaryButton.js +2 -2
- package/dist/commonjs/button/lib/SecondaryButton.js +2 -2
- package/dist/commonjs/button/lib/TertiaryButton.js +18 -18
- package/dist/commonjs/card/lib/Card.js +1 -1
- package/dist/commonjs/card/lib/CardBody.js +1 -1
- package/dist/commonjs/card/lib/CardHeading.js +1 -1
- package/dist/commonjs/checkbox/lib/CheckBackground.js +3 -3
- package/dist/commonjs/checkbox/lib/CheckboxCheck.js +5 -5
- package/dist/commonjs/checkbox/lib/CheckboxContainer.js +1 -1
- package/dist/commonjs/checkbox/lib/CheckboxInput.js +5 -5
- package/dist/commonjs/checkbox/lib/CheckboxRipple.js +1 -1
- package/dist/commonjs/collection/index.d.ts +1 -0
- package/dist/commonjs/collection/index.d.ts.map +1 -1
- package/dist/commonjs/collection/index.js +1 -0
- package/dist/commonjs/collection/lib/ListBox.js +4 -4
- package/dist/commonjs/collection/lib/useListItemActiveDescendant.d.ts +69 -0
- package/dist/commonjs/collection/lib/useListItemActiveDescendant.d.ts.map +1 -0
- package/dist/commonjs/collection/lib/useListItemActiveDescendant.js +25 -0
- package/dist/commonjs/combobox/lib/Combobox.d.ts +5 -83
- package/dist/commonjs/combobox/lib/Combobox.d.ts.map +1 -1
- package/dist/commonjs/combobox/lib/ComboboxMenu.d.ts +5 -83
- package/dist/commonjs/combobox/lib/ComboboxMenu.d.ts.map +1 -1
- package/dist/commonjs/combobox/lib/ComboboxMenu.js +1 -2
- package/dist/commonjs/combobox/lib/ComboboxMenuItem.d.ts +18 -260
- package/dist/commonjs/combobox/lib/ComboboxMenuItem.d.ts.map +1 -1
- package/dist/commonjs/combobox/lib/ComboboxMenuItem.js +3 -59
- package/dist/commonjs/combobox/lib/ComboboxMenuList.js +1 -1
- package/dist/commonjs/common/lib/AccessibleHide.js +1 -1
- package/dist/commonjs/common/lib/CanvasProvider.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldContainer.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldField.js +1 -1
- package/dist/commonjs/form-field/lib/FormFieldGroupLabel.js +5 -5
- package/dist/commonjs/form-field/lib/FormFieldGroupList.js +3 -3
- package/dist/commonjs/form-field/lib/FormFieldHint.js +3 -3
- package/dist/commonjs/form-field/lib/FormFieldLabel.js +5 -5
- package/dist/commonjs/form-field/lib/formFieldStencil.js +8 -8
- package/dist/commonjs/icon/lib/AccentIcon.js +2 -2
- package/dist/commonjs/icon/lib/AppletIcon.js +1 -1
- package/dist/commonjs/icon/lib/Graphic.js +2 -2
- package/dist/commonjs/icon/lib/Svg.js +2 -2
- package/dist/commonjs/icon/lib/SystemIcon.js +1 -1
- package/dist/commonjs/icon/lib/SystemIconCircle.js +1 -1
- package/dist/commonjs/loading-dots/lib/LoadingDots.js +3 -3
- package/dist/commonjs/menu/index.d.ts +2 -1
- package/dist/commonjs/menu/index.d.ts.map +1 -1
- package/dist/commonjs/menu/index.js +5 -1
- package/dist/commonjs/menu/lib/Menu.d.ts +89 -9
- package/dist/commonjs/menu/lib/Menu.d.ts.map +1 -1
- package/dist/commonjs/menu/lib/Menu.js +10 -0
- package/dist/commonjs/menu/lib/MenuCard.js +1 -1
- package/dist/commonjs/menu/lib/MenuItem.d.ts +12 -19
- package/dist/commonjs/menu/lib/MenuItem.d.ts.map +1 -1
- package/dist/commonjs/menu/lib/MenuItem.js +20 -91
- package/dist/commonjs/menu/lib/MenuList.js +3 -3
- package/dist/commonjs/menu/lib/MenuOption.d.ts +192 -0
- package/dist/commonjs/menu/lib/MenuOption.d.ts.map +1 -0
- package/dist/commonjs/menu/lib/MenuOption.js +89 -0
- package/dist/commonjs/modal/lib/ModalBody.js +1 -1
- package/dist/commonjs/modal/lib/ModalCard.js +1 -1
- package/dist/commonjs/modal/lib/ModalHeading.js +1 -1
- package/dist/commonjs/modal/lib/ModalOverflowOverlay.js +1 -1
- package/dist/commonjs/modal/lib/ModalOverlay.js +2 -2
- package/dist/commonjs/popup/lib/PopupBody.js +1 -1
- package/dist/commonjs/popup/lib/PopupCard.js +2 -2
- package/dist/commonjs/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/commonjs/popup/lib/PopupHeading.js +1 -1
- package/dist/commonjs/select/lib/Select.d.ts +59 -962
- package/dist/commonjs/select/lib/Select.d.ts.map +1 -1
- package/dist/commonjs/select/lib/Select.js +5 -5
- package/dist/commonjs/switch/lib/Switch.js +7 -7
- package/dist/commonjs/table/lib/Table.js +1 -1
- package/dist/commonjs/table/lib/TableBody.js +1 -1
- package/dist/commonjs/table/lib/TableCaption.js +1 -1
- package/dist/commonjs/table/lib/TableCell.js +1 -1
- package/dist/commonjs/table/lib/TableFooter.js +1 -1
- package/dist/commonjs/table/lib/TableHead.js +1 -1
- package/dist/commonjs/table/lib/TableHeader.js +1 -1
- package/dist/commonjs/table/lib/TableRow.js +1 -1
- package/dist/commonjs/tabs/lib/Tabs.d.ts +82 -10
- package/dist/commonjs/tabs/lib/Tabs.d.ts.map +1 -1
- package/dist/commonjs/text/lib/LabelText.js +6 -6
- package/dist/commonjs/text/lib/Text.js +16 -16
- package/dist/commonjs/text/lib/TypeLevelComponents.js +4 -4
- package/dist/commonjs/text-area/lib/TextArea.js +5 -5
- package/dist/commonjs/text-input/lib/InputGroup.js +6 -6
- package/dist/commonjs/text-input/lib/TextInput.js +5 -5
- package/dist/commonjs/toast/lib/Toast.js +1 -1
- package/dist/commonjs/toast/lib/ToastBody.js +1 -1
- package/dist/commonjs/toast/lib/ToastCloseIcon.js +1 -1
- package/dist/commonjs/toast/lib/ToastIcon.js +1 -1
- package/dist/commonjs/toast/lib/ToastMessage.js +1 -1
- package/dist/es6/action-bar/lib/ActionBar.d.ts +82 -10
- package/dist/es6/action-bar/lib/ActionBar.d.ts.map +1 -1
- package/dist/es6/avatar/lib/Avatar.js +21 -21
- package/dist/es6/badge/lib/CountBadge.js +3 -3
- package/dist/es6/breadcrumbs/lib/Breadcrumbs.d.ts +1 -1
- package/dist/es6/breadcrumbs/lib/BreadcrumbsMenu.d.ts +2 -2
- package/dist/es6/button/lib/BaseButton.js +21 -21
- package/dist/es6/button/lib/DeleteButton.js +1 -1
- package/dist/es6/button/lib/PrimaryButton.js +2 -2
- package/dist/es6/button/lib/SecondaryButton.js +2 -2
- package/dist/es6/button/lib/TertiaryButton.js +18 -18
- package/dist/es6/card/lib/Card.js +1 -1
- package/dist/es6/card/lib/CardBody.js +1 -1
- package/dist/es6/card/lib/CardHeading.js +1 -1
- package/dist/es6/checkbox/lib/CheckBackground.js +3 -3
- package/dist/es6/checkbox/lib/CheckboxCheck.js +5 -5
- package/dist/es6/checkbox/lib/CheckboxContainer.js +1 -1
- package/dist/es6/checkbox/lib/CheckboxInput.js +5 -5
- package/dist/es6/checkbox/lib/CheckboxRipple.js +1 -1
- package/dist/es6/collection/index.d.ts +1 -0
- package/dist/es6/collection/index.d.ts.map +1 -1
- package/dist/es6/collection/index.js +1 -0
- package/dist/es6/collection/lib/ListBox.js +4 -4
- package/dist/es6/collection/lib/useListItemActiveDescendant.d.ts +69 -0
- package/dist/es6/collection/lib/useListItemActiveDescendant.d.ts.map +1 -0
- package/dist/es6/collection/lib/useListItemActiveDescendant.js +22 -0
- package/dist/es6/combobox/lib/Combobox.d.ts +5 -83
- package/dist/es6/combobox/lib/Combobox.d.ts.map +1 -1
- package/dist/es6/combobox/lib/ComboboxMenu.d.ts +5 -83
- package/dist/es6/combobox/lib/ComboboxMenu.d.ts.map +1 -1
- package/dist/es6/combobox/lib/ComboboxMenu.js +1 -2
- package/dist/es6/combobox/lib/ComboboxMenuItem.d.ts +18 -260
- package/dist/es6/combobox/lib/ComboboxMenuItem.d.ts.map +1 -1
- package/dist/es6/combobox/lib/ComboboxMenuItem.js +3 -56
- package/dist/es6/combobox/lib/ComboboxMenuList.js +1 -1
- package/dist/es6/common/lib/AccessibleHide.js +1 -1
- package/dist/es6/common/lib/CanvasProvider.js +1 -1
- package/dist/es6/form-field/lib/FormFieldContainer.js +1 -1
- package/dist/es6/form-field/lib/FormFieldField.js +1 -1
- package/dist/es6/form-field/lib/FormFieldGroupLabel.js +5 -5
- package/dist/es6/form-field/lib/FormFieldGroupList.js +3 -3
- package/dist/es6/form-field/lib/FormFieldHint.js +3 -3
- package/dist/es6/form-field/lib/FormFieldLabel.js +5 -5
- package/dist/es6/form-field/lib/formFieldStencil.js +8 -8
- package/dist/es6/icon/lib/AccentIcon.js +2 -2
- package/dist/es6/icon/lib/AppletIcon.js +1 -1
- package/dist/es6/icon/lib/Graphic.js +2 -2
- package/dist/es6/icon/lib/Svg.js +2 -2
- package/dist/es6/icon/lib/SystemIcon.js +1 -1
- package/dist/es6/icon/lib/SystemIconCircle.js +1 -1
- package/dist/es6/loading-dots/lib/LoadingDots.js +3 -3
- package/dist/es6/menu/index.d.ts +2 -1
- package/dist/es6/menu/index.d.ts.map +1 -1
- package/dist/es6/menu/index.js +2 -1
- package/dist/es6/menu/lib/Menu.d.ts +89 -9
- package/dist/es6/menu/lib/Menu.d.ts.map +1 -1
- package/dist/es6/menu/lib/Menu.js +10 -0
- package/dist/es6/menu/lib/MenuCard.js +1 -1
- package/dist/es6/menu/lib/MenuItem.d.ts +12 -19
- package/dist/es6/menu/lib/MenuItem.d.ts.map +1 -1
- package/dist/es6/menu/lib/MenuItem.js +22 -93
- package/dist/es6/menu/lib/MenuList.js +3 -3
- package/dist/es6/menu/lib/MenuOption.d.ts +192 -0
- package/dist/es6/menu/lib/MenuOption.d.ts.map +1 -0
- package/dist/es6/menu/lib/MenuOption.js +63 -0
- package/dist/es6/modal/lib/ModalBody.js +1 -1
- package/dist/es6/modal/lib/ModalCard.js +1 -1
- package/dist/es6/modal/lib/ModalHeading.js +1 -1
- package/dist/es6/modal/lib/ModalOverflowOverlay.js +1 -1
- package/dist/es6/modal/lib/ModalOverlay.js +2 -2
- package/dist/es6/popup/lib/PopupBody.js +1 -1
- package/dist/es6/popup/lib/PopupCard.js +2 -2
- package/dist/es6/popup/lib/PopupCloseIcon.js +1 -1
- package/dist/es6/popup/lib/PopupHeading.js +1 -1
- package/dist/es6/select/lib/Select.d.ts +59 -962
- package/dist/es6/select/lib/Select.d.ts.map +1 -1
- package/dist/es6/select/lib/Select.js +5 -5
- package/dist/es6/switch/lib/Switch.js +7 -7
- package/dist/es6/table/lib/Table.js +1 -1
- package/dist/es6/table/lib/TableBody.js +1 -1
- package/dist/es6/table/lib/TableCaption.js +1 -1
- package/dist/es6/table/lib/TableCell.js +1 -1
- package/dist/es6/table/lib/TableFooter.js +1 -1
- package/dist/es6/table/lib/TableHead.js +1 -1
- package/dist/es6/table/lib/TableHeader.js +1 -1
- package/dist/es6/table/lib/TableRow.js +1 -1
- package/dist/es6/tabs/lib/Tabs.d.ts +82 -10
- package/dist/es6/tabs/lib/Tabs.d.ts.map +1 -1
- package/dist/es6/text/lib/LabelText.js +6 -6
- package/dist/es6/text/lib/Text.js +16 -16
- package/dist/es6/text/lib/TypeLevelComponents.js +4 -4
- package/dist/es6/text-area/lib/TextArea.js +5 -5
- package/dist/es6/text-input/lib/InputGroup.js +6 -6
- package/dist/es6/text-input/lib/TextInput.js +5 -5
- package/dist/es6/toast/lib/Toast.js +1 -1
- package/dist/es6/toast/lib/ToastBody.js +1 -1
- package/dist/es6/toast/lib/ToastCloseIcon.js +1 -1
- package/dist/es6/toast/lib/ToastIcon.js +1 -1
- package/dist/es6/toast/lib/ToastMessage.js +1 -1
- package/menu/index.ts +2 -1
- package/menu/lib/Menu.tsx +10 -0
- package/menu/lib/MenuItem.tsx +107 -99
- package/menu/lib/MenuOption.tsx +138 -0
- package/package.json +4 -4
- package/select/lib/Select.tsx +1 -1
package/menu/index.ts
CHANGED
|
@@ -2,7 +2,8 @@ export {useMenuModel} from './lib/useMenuModel';
|
|
|
2
2
|
export {Menu} from './lib/Menu';
|
|
3
3
|
|
|
4
4
|
export {useMenuCard} from './lib/MenuCard';
|
|
5
|
-
export {useMenuItem,
|
|
5
|
+
export {useMenuItem, menuItemStencil, StyledMenuItem} from './lib/MenuItem';
|
|
6
|
+
export {useMenuOption, menuOptionStencil} from './lib/MenuOption';
|
|
6
7
|
export {useMenuList, menuListStencil} from './lib/MenuList';
|
|
7
8
|
export {useMenuPopper} from './lib/MenuPopper';
|
|
8
9
|
export {useMenuTarget, useMenuTargetContext} from './lib/MenuTarget';
|
package/menu/lib/Menu.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {MenuItem} from './MenuItem';
|
|
|
9
9
|
import {MenuCard} from './MenuCard';
|
|
10
10
|
import {MenuList} from './MenuList';
|
|
11
11
|
import {MenuDivider} from './MenuDivider';
|
|
12
|
+
import {MenuOption} from './MenuOption';
|
|
12
13
|
|
|
13
14
|
export interface MenuProps {
|
|
14
15
|
/**
|
|
@@ -99,6 +100,15 @@ export const Menu = createContainer()({
|
|
|
99
100
|
* the model.
|
|
100
101
|
*/
|
|
101
102
|
Item: MenuItem,
|
|
103
|
+
/**
|
|
104
|
+
* A `Menu.Option` is similar to the `Menu.Item`, but has a `role=option` and works with
|
|
105
|
+
* `aria-activedescendant` and is selectable with a selected checkmark. It adds the
|
|
106
|
+
* `aria-selected="true/false"` attribute. `Menu.Option` requires much more accessibility
|
|
107
|
+
* behavior composed into the `Menu.Target` and `Menu.List` component. The `Combobox` and
|
|
108
|
+
* `Select` components make use of the `Menu.Option`. See those components for a better idea of
|
|
109
|
+
* how behavior is composed.
|
|
110
|
+
*/
|
|
111
|
+
Option: MenuOption,
|
|
102
112
|
Divider: MenuDivider,
|
|
103
113
|
/**
|
|
104
114
|
* A `Menu.TargetContext` is the same as a {@link MenuTarget Menu.Target}, except it adds a
|
package/menu/lib/MenuItem.tsx
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {createStencil} from '@workday/canvas-kit-styling';
|
|
4
|
+
import {brand, system} from '@workday/canvas-tokens-web';
|
|
5
|
+
|
|
4
6
|
import {
|
|
5
7
|
createSubcomponent,
|
|
6
|
-
styled,
|
|
7
|
-
StyledType,
|
|
8
8
|
composeHooks,
|
|
9
9
|
createElemPropsHook,
|
|
10
10
|
useLocalRef,
|
|
11
|
+
createComponent,
|
|
11
12
|
} from '@workday/canvas-kit-react/common';
|
|
12
|
-
import {SystemIcon} from '@workday/canvas-kit-react/icon';
|
|
13
|
+
import {SystemIcon, SystemIconProps, systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
13
14
|
import {OverflowTooltip} from '@workday/canvas-kit-react/tooltip';
|
|
14
|
-
import {
|
|
15
|
+
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
15
16
|
import {
|
|
16
17
|
useListItemRegister,
|
|
17
18
|
useListItemRovingFocus,
|
|
@@ -30,113 +31,120 @@ export interface MenuItemProps {
|
|
|
30
31
|
/**
|
|
31
32
|
* The label text of the MenuItem.
|
|
32
33
|
*/
|
|
33
|
-
children
|
|
34
|
+
children?: React.ReactNode;
|
|
34
35
|
/**
|
|
35
36
|
* The name of the menu item. This name will be used in the `onSelect` callback in the model. If
|
|
36
37
|
* this property is not provided, it will default to a string representation of the the zero-based
|
|
37
38
|
* index of the Tab when it was initialized.
|
|
38
39
|
*/
|
|
39
40
|
'data-id'?: string;
|
|
41
|
+
/**
|
|
42
|
+
* `aria-disabled` is used for keyboard and screen reader users to discover disabled content with
|
|
43
|
+
* the keyboard or screen reader caret tool. For more information, see
|
|
44
|
+
* https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls
|
|
45
|
+
*/
|
|
40
46
|
'aria-disabled'?: boolean;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
interface StyledMenuProps {
|
|
44
47
|
/**
|
|
45
48
|
* If true, set the StyledMenuItem to the disabled state so it is not clickable.
|
|
46
49
|
* @default false
|
|
50
|
+
* @deprecated Use `aria-disabled` instead
|
|
47
51
|
*/
|
|
48
52
|
isDisabled?: boolean;
|
|
49
53
|
}
|
|
50
54
|
|
|
51
|
-
export const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
color: colors.licorice100,
|
|
109
|
-
cursor: 'default',
|
|
110
|
-
'.wd-icon-fill, .wd-icon-accent, .wd-icon-accent2': {
|
|
111
|
-
fill: iconColors.disabled,
|
|
112
|
-
},
|
|
113
|
-
'&:focus, &.focus': {
|
|
114
|
-
backgroundColor: colors.blueberry200,
|
|
115
|
-
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
116
|
-
fill: iconColors.disabled,
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
'&:hover, &[aria-selected=true]': {
|
|
120
|
-
'.wd-icon-background ~ .wd-icon-accent, .wd-icon-background ~ .wd-icon-accent2': {
|
|
121
|
-
fill: iconColors.disabled,
|
|
122
|
-
},
|
|
123
|
-
'*:hover .wd-icon-fill': {
|
|
124
|
-
fill: iconColors.disabled,
|
|
125
|
-
},
|
|
126
|
-
},
|
|
55
|
+
export const menuItemStencil = createStencil({
|
|
56
|
+
base: {
|
|
57
|
+
...system.type.subtext.large,
|
|
58
|
+
display: 'flex',
|
|
59
|
+
alignItems: 'center',
|
|
60
|
+
width: '100%',
|
|
61
|
+
gap: system.space.x4,
|
|
62
|
+
padding: `${system.space.x2} ${system.space.x4}`,
|
|
63
|
+
boxSizing: 'border-box',
|
|
64
|
+
cursor: 'pointer',
|
|
65
|
+
color: system.color.fg.default,
|
|
66
|
+
borderWidth: 0,
|
|
67
|
+
textAlign: 'start',
|
|
68
|
+
transition: 'background-color 80ms, color 80ms',
|
|
69
|
+
backgroundColor: 'inherit',
|
|
70
|
+
minHeight: system.space.x10,
|
|
71
|
+
// We want the icon colors to be the same as the text color
|
|
72
|
+
[systemIconStencil.vars.color]: 'currentcolor',
|
|
73
|
+
|
|
74
|
+
// selected checkmark
|
|
75
|
+
'& :where([data-part="menu-item-selected"])': {
|
|
76
|
+
transition: 'opacity 80ms linear',
|
|
77
|
+
opacity: system.opacity.zero,
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
// if the menu item has children we need it to be displayed in flex
|
|
81
|
+
'&:where(:has(span))': {
|
|
82
|
+
display: 'flex',
|
|
83
|
+
},
|
|
84
|
+
|
|
85
|
+
// Selected styles
|
|
86
|
+
'&:is([aria-selected=true])': {
|
|
87
|
+
color: brand.primary.dark,
|
|
88
|
+
backgroundColor: brand.primary.lightest,
|
|
89
|
+
},
|
|
90
|
+
|
|
91
|
+
// Hover styles
|
|
92
|
+
'&:is(.hover, :hover)': {
|
|
93
|
+
color: system.color.fg.strong,
|
|
94
|
+
backgroundColor: brand.neutral.lightest,
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// Focus styles
|
|
98
|
+
'&:is(.focus, :focus)': {
|
|
99
|
+
color: brand.primary.accent,
|
|
100
|
+
outline: 'none',
|
|
101
|
+
backgroundColor: brand.primary.base,
|
|
102
|
+
},
|
|
103
|
+
|
|
104
|
+
// Disabled styles
|
|
105
|
+
'&:is(:disabled, [aria-disabled=true])': {
|
|
106
|
+
color: system.color.text.disabled,
|
|
107
|
+
cursor: 'default',
|
|
108
|
+
|
|
109
|
+
// Focus + Disabled
|
|
110
|
+
'&:where(.focus, :focus)': {
|
|
111
|
+
backgroundColor: brand.primary.light,
|
|
127
112
|
},
|
|
128
|
-
}
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
'& :where([data-part="menu-item-text"])': {
|
|
116
|
+
flexGrow: 1,
|
|
117
|
+
alignSelf: 'center',
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
'& :where([data-part="menu-icon-icon"])': {
|
|
121
|
+
alignSelf: 'start',
|
|
122
|
+
},
|
|
129
123
|
},
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const MenuItemIcon = (elemProps: SystemIconProps) => {
|
|
127
|
+
return <SystemIcon data-part="menu-item-icon" {...elemProps} />;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const MenuItemText = ({children}: React.PropsWithChildren) => {
|
|
131
|
+
return <span data-part="menu-item-text">{children}</span>;
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
export const StyledMenuItem = createComponent('button')({
|
|
135
|
+
displayName: 'MenuItem',
|
|
136
|
+
Component: ({children, isDisabled, ...elemProps}: MenuItemProps, ref, Element) => {
|
|
137
|
+
return (
|
|
138
|
+
<Element
|
|
139
|
+
ref={ref}
|
|
140
|
+
aria-disabled={isDisabled}
|
|
141
|
+
{...mergeStyles(elemProps, menuItemStencil({}))}
|
|
142
|
+
>
|
|
143
|
+
{typeof children === 'string' ? <MenuItemText>{children}</MenuItemText> : children}
|
|
144
|
+
</Element>
|
|
145
|
+
);
|
|
146
|
+
},
|
|
147
|
+
});
|
|
140
148
|
|
|
141
149
|
export const useMenuItem = composeHooks(
|
|
142
150
|
createElemPropsHook(useMenuModel)(
|
|
@@ -181,13 +189,13 @@ export const MenuItem = createSubcomponent('button')({
|
|
|
181
189
|
modelHook: useMenuModel,
|
|
182
190
|
elemPropsHook: useMenuItem,
|
|
183
191
|
subComponents: {
|
|
184
|
-
Icon:
|
|
185
|
-
Text:
|
|
192
|
+
Icon: MenuItemIcon,
|
|
193
|
+
Text: MenuItemText,
|
|
186
194
|
},
|
|
187
195
|
})<MenuItemProps>(({children, ...elemProps}, Element) => {
|
|
188
196
|
return (
|
|
189
197
|
<OverflowTooltip placement="left">
|
|
190
|
-
<StyledMenuItem
|
|
198
|
+
<StyledMenuItem as={Element} {...elemProps}>
|
|
191
199
|
{children}
|
|
192
200
|
</StyledMenuItem>
|
|
193
201
|
</OverflowTooltip>
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {createStencil} from '@workday/canvas-kit-styling';
|
|
4
|
+
import {brand, system} from '@workday/canvas-tokens-web';
|
|
5
|
+
import {checkSmallIcon} from '@workday/canvas-system-icons-web';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
createSubcomponent,
|
|
9
|
+
composeHooks,
|
|
10
|
+
createElemPropsHook,
|
|
11
|
+
createComponent,
|
|
12
|
+
} from '@workday/canvas-kit-react/common';
|
|
13
|
+
import {SystemIcon, SystemIconProps, systemIconStencil} from '@workday/canvas-kit-react/icon';
|
|
14
|
+
import {OverflowTooltip} from '@workday/canvas-kit-react/tooltip';
|
|
15
|
+
import {mergeStyles} from '@workday/canvas-kit-react/layout';
|
|
16
|
+
import {
|
|
17
|
+
isSelected,
|
|
18
|
+
useListItemActiveDescendant,
|
|
19
|
+
useListItemRegister,
|
|
20
|
+
} from '@workday/canvas-kit-react/collection';
|
|
21
|
+
|
|
22
|
+
import {useMenuModel} from './useMenuModel';
|
|
23
|
+
import {menuItemStencil} from './MenuItem';
|
|
24
|
+
|
|
25
|
+
export interface MenuOptionProps {
|
|
26
|
+
/**
|
|
27
|
+
* Optionally pass index to menu item. This should be done if `Menu.Item` components were created
|
|
28
|
+
* via a `Array::map` function. This index will ensure keyboard navigation works even if items are
|
|
29
|
+
* inserted out of order.
|
|
30
|
+
*/
|
|
31
|
+
index?: number;
|
|
32
|
+
/**
|
|
33
|
+
* The label text of the MenuOption.
|
|
34
|
+
*/
|
|
35
|
+
children?: React.ReactNode;
|
|
36
|
+
/**
|
|
37
|
+
* The name of the menu item. This name will be used in the `onSelect` callback in the model. If
|
|
38
|
+
* this property is not provided, it will default to a string representation of the the zero-based
|
|
39
|
+
* index of the Tab when it was initialized.
|
|
40
|
+
*/
|
|
41
|
+
'data-id'?: string;
|
|
42
|
+
/**
|
|
43
|
+
* `aria-disabled` is used for keyboard and screen reader users to discover disabled content with
|
|
44
|
+
* the keyboard or screen reader caret tool. For more information, see
|
|
45
|
+
* https://www.w3.org/WAI/ARIA/apg/practices/keyboard-interface/#kbd_disabled_controls
|
|
46
|
+
*/
|
|
47
|
+
'aria-disabled'?: boolean;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const menuOptionStencil = createStencil({
|
|
51
|
+
extends: menuItemStencil,
|
|
52
|
+
base: {
|
|
53
|
+
'&:where([aria-selected=true])': {
|
|
54
|
+
'& :where([data-part="menu-item-selected"])': {
|
|
55
|
+
opacity: system.opacity.full,
|
|
56
|
+
},
|
|
57
|
+
'&:where(.focus, :focus)': {
|
|
58
|
+
[systemIconStencil.vars.color]: brand.primary.accent,
|
|
59
|
+
outline: 'none',
|
|
60
|
+
backgroundColor: brand.primary.base,
|
|
61
|
+
color: systemIconStencil.vars.color,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const MenuOptionIcon = (elemProps: SystemIconProps) => {
|
|
68
|
+
return <SystemIcon data-part="menu-item-icon" {...elemProps} />;
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const MenuOptionText = ({children}: React.PropsWithChildren) => {
|
|
72
|
+
return (
|
|
73
|
+
<>
|
|
74
|
+
<span data-part="menu-item-text">{children}</span>
|
|
75
|
+
<SystemIcon icon={checkSmallIcon} data-part="menu-item-selected" />
|
|
76
|
+
</>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export const StyledMenuOption = createComponent('button')({
|
|
81
|
+
displayName: 'MenuOption',
|
|
82
|
+
Component: ({children, ...elemProps}: MenuOptionProps, ref, Element) => {
|
|
83
|
+
return (
|
|
84
|
+
<Element ref={ref} {...mergeStyles(elemProps, menuOptionStencil())}>
|
|
85
|
+
{typeof children === 'string' ? <MenuOptionText>{children}</MenuOptionText> : children}
|
|
86
|
+
</Element>
|
|
87
|
+
);
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
export const useMenuOption = composeHooks(
|
|
92
|
+
createElemPropsHook(useMenuModel)((model, ref, elemProps: {'data-id'?: string} = {}) => {
|
|
93
|
+
const id = elemProps['data-id'] || '';
|
|
94
|
+
|
|
95
|
+
const selected = isSelected(id, model.state);
|
|
96
|
+
|
|
97
|
+
const onMouseDown = (event: React.MouseEvent<HTMLElement>) => {
|
|
98
|
+
// Only left mouse button
|
|
99
|
+
if (event.button === 0) {
|
|
100
|
+
if (event.currentTarget.getAttribute('aria-disabled') !== 'true') {
|
|
101
|
+
model.events.select({id});
|
|
102
|
+
|
|
103
|
+
if (model.state.mode === 'single') {
|
|
104
|
+
model.events.hide(event);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// prevent focus changes
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
role: 'option',
|
|
114
|
+
'aria-selected': selected,
|
|
115
|
+
onMouseDown,
|
|
116
|
+
};
|
|
117
|
+
}),
|
|
118
|
+
useListItemActiveDescendant,
|
|
119
|
+
useListItemRegister
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
export const MenuOption = createSubcomponent('li')({
|
|
123
|
+
displayName: 'Menu.Item',
|
|
124
|
+
modelHook: useMenuModel,
|
|
125
|
+
elemPropsHook: useMenuOption,
|
|
126
|
+
subComponents: {
|
|
127
|
+
Icon: MenuOptionIcon,
|
|
128
|
+
Text: MenuOptionText,
|
|
129
|
+
},
|
|
130
|
+
})<MenuOptionProps>(({children, ...elemProps}, Element) => {
|
|
131
|
+
return (
|
|
132
|
+
<OverflowTooltip placement="left">
|
|
133
|
+
<StyledMenuOption as={Element} {...elemProps}>
|
|
134
|
+
{children}
|
|
135
|
+
</StyledMenuOption>
|
|
136
|
+
</OverflowTooltip>
|
|
137
|
+
);
|
|
138
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-react",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.908-next.0",
|
|
4
4
|
"description": "The parent module that contains all Workday Canvas Kit React components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"@emotion/styled": "^11.6.0",
|
|
50
50
|
"@popperjs/core": "^2.5.4",
|
|
51
51
|
"@workday/canvas-colors-web": "^2.0.0",
|
|
52
|
-
"@workday/canvas-kit-popup-stack": "^12.0.0-alpha.
|
|
53
|
-
"@workday/canvas-kit-styling": "^12.0.0-alpha.
|
|
52
|
+
"@workday/canvas-kit-popup-stack": "^12.0.0-alpha.908-next.0",
|
|
53
|
+
"@workday/canvas-kit-styling": "^12.0.0-alpha.908-next.0",
|
|
54
54
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
55
55
|
"@workday/canvas-tokens-web": "^2.0.1",
|
|
56
56
|
"@workday/design-assets-types": "^0.2.8",
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"@workday/canvas-accent-icons-web": "^3.0.0",
|
|
68
68
|
"@workday/canvas-applet-icons-web": "^2.0.0"
|
|
69
69
|
},
|
|
70
|
-
"gitHead": "
|
|
70
|
+
"gitHead": "96aa087e44d928f9b530e0133be4326b8ff2fdce"
|
|
71
71
|
}
|
package/select/lib/Select.tsx
CHANGED
|
@@ -124,7 +124,7 @@ export const SelectItem = createSubcomponent('li')({
|
|
|
124
124
|
},
|
|
125
125
|
})<ExtractProps<typeof Combobox.Menu.Item>>(({children, ...elemProps}, Element, _model) => {
|
|
126
126
|
return (
|
|
127
|
-
<Combobox.Menu.Item
|
|
127
|
+
<Combobox.Menu.Item as={Element} {...elemProps}>
|
|
128
128
|
{children}
|
|
129
129
|
</Combobox.Menu.Item>
|
|
130
130
|
);
|