@workday/canvas-kit-docs 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/dist/es6/lib/docs.js +3179 -2281
- package/dist/mdx/12.0-UPGRADE-GUIDE.mdx +21 -0
- package/dist/mdx/labs-react/combobox/examples/Basic.tsx +4 -3
- package/dist/mdx/labs-react/combobox/examples/DisabledItem.tsx +4 -3
- package/dist/mdx/labs-react/combobox/examples/GroupOfResult.tsx +4 -3
- package/dist/mdx/labs-react/combobox/examples/Grow.tsx +4 -3
- package/dist/mdx/labs-react/combobox/examples/NoClearButton.tsx +4 -3
- package/dist/mdx/labs-react/combobox/examples/RTL.tsx +3 -3
- package/dist/mdx/react/menu/Menu.mdx +14 -0
- package/dist/mdx/react/menu/examples/SelectableMenu.tsx +27 -0
- package/package.json +6 -6
|
@@ -44,6 +44,7 @@ A note to the reader:
|
|
|
44
44
|
- [Form Field](#form-field)
|
|
45
45
|
- [Form Field Group](#form-field-group)
|
|
46
46
|
- [Form Field Field](#form-field-field)
|
|
47
|
+
- [Menu Item](#menu-item)
|
|
47
48
|
- [Search Form](#search-form)
|
|
48
49
|
- [Select](#select)
|
|
49
50
|
- [Text Area](#text-area)
|
|
@@ -373,6 +374,26 @@ this sub-component when using `FormField`. This component also exists on `FormFi
|
|
|
373
374
|
</FormField>
|
|
374
375
|
```
|
|
375
376
|
|
|
377
|
+
### Menu Item
|
|
378
|
+
|
|
379
|
+
**PR: ** [2969](https://github.com/Workday/canvas-kit/pull/2969)
|
|
380
|
+
|
|
381
|
+
`Menu.Item` was converted to use Stencils for styling and uses SystemIcon stencil variables to
|
|
382
|
+
change icon color instead of deeply nested selectors. We also added `Menu.Option` component for
|
|
383
|
+
menus that have a selected visual state. `Menu.Option` will need more accessibility affordances that
|
|
384
|
+
depend on the nature of your use of the `Menu` component. For example, `<Combobox>` and `<Select>`
|
|
385
|
+
use `Menu.Option` and add keyboard events and `aria-*` attributes to function according to w3c
|
|
386
|
+
specifications.
|
|
387
|
+
|
|
388
|
+
We've deprecated the `isDisabled` prop. It didn't do anything in v10 or v11. It was part of the
|
|
389
|
+
preview Menu deprecation, but was never hooked up. We mapped it to `aria-disabled` and added a
|
|
390
|
+
deprecation comment to use `aria-disabled` instead.
|
|
391
|
+
|
|
392
|
+
We've removed the `MenuItemProps` export from `@workday/canvas-kit-react/menu`. Use
|
|
393
|
+
`ExtractProps<typeof Menu.Item, never>` instead. We don't mean to export prop interfaces of
|
|
394
|
+
polymorphic components. The `never` means "don't add element props". The second parameter is used to
|
|
395
|
+
pass the interface that the `as` prop is pointing to.
|
|
396
|
+
|
|
376
397
|
### Search Form (Labs)
|
|
377
398
|
|
|
378
399
|
**PRs:** [#2934](https://github.com/Workday/canvas-kit/pull/2934),
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
+
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
2
3
|
import {
|
|
3
4
|
Combobox,
|
|
4
5
|
ComboboxProps,
|
|
5
6
|
ComboBoxMenuItemGroup,
|
|
6
7
|
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
8
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem
|
|
9
|
+
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
10
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
11
|
|
|
11
12
|
const autocompleteResult = (
|
|
12
13
|
textModifier: number,
|
|
13
14
|
disabled: boolean
|
|
14
|
-
): ReactElement<
|
|
15
|
-
<StyledMenuItem
|
|
15
|
+
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
+
<StyledMenuItem aria-disabled={disabled}>
|
|
16
17
|
Result
|
|
17
18
|
<span>
|
|
18
19
|
num<span>ber</span>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
+
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
2
3
|
import {
|
|
3
4
|
Combobox,
|
|
4
5
|
ComboboxProps,
|
|
5
6
|
ComboBoxMenuItemGroup,
|
|
6
7
|
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
8
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem
|
|
9
|
+
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
10
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
11
|
|
|
11
12
|
const autocompleteResult = (
|
|
12
13
|
textModifier: number,
|
|
13
14
|
disabled: boolean
|
|
14
|
-
): ReactElement<
|
|
15
|
-
<StyledMenuItem
|
|
15
|
+
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
+
<StyledMenuItem aria-disabled={disabled}>
|
|
16
17
|
Result
|
|
17
18
|
<span>
|
|
18
19
|
num<span>ber</span>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
+
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
2
3
|
import {
|
|
3
4
|
Combobox,
|
|
4
5
|
ComboboxProps,
|
|
5
6
|
ComboBoxMenuItemGroup,
|
|
6
7
|
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
8
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem
|
|
9
|
+
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
10
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
11
|
|
|
11
12
|
const autocompleteResult = (
|
|
12
13
|
textModifier: number,
|
|
13
14
|
disabled: boolean
|
|
14
|
-
): ReactElement<
|
|
15
|
-
<StyledMenuItem
|
|
15
|
+
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
+
<StyledMenuItem aria-disabled={disabled}>
|
|
16
17
|
Result{' '}
|
|
17
18
|
<span>
|
|
18
19
|
num<span>ber</span>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
+
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
2
3
|
import {
|
|
3
4
|
Combobox,
|
|
4
5
|
ComboboxProps,
|
|
5
6
|
ComboBoxMenuItemGroup,
|
|
6
7
|
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
8
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem
|
|
9
|
+
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
10
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
11
|
|
|
11
12
|
const autocompleteResult = (
|
|
12
13
|
textModifier: number,
|
|
13
14
|
disabled: boolean
|
|
14
|
-
): ReactElement<
|
|
15
|
-
<StyledMenuItem
|
|
15
|
+
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
+
<StyledMenuItem aria-disabled={disabled}>
|
|
16
17
|
Result
|
|
17
18
|
<span>
|
|
18
19
|
num<span>ber</span>
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import React, {ReactNode, ReactElement, FC, ChangeEvent} from 'react';
|
|
2
|
+
import {ExtractProps} from '@workday/canvas-kit-react/common';
|
|
2
3
|
import {
|
|
3
4
|
Combobox,
|
|
4
5
|
ComboboxProps,
|
|
5
6
|
ComboBoxMenuItemGroup,
|
|
6
7
|
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
8
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem
|
|
9
|
+
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
10
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
11
|
|
|
11
12
|
const autocompleteResult = (
|
|
12
13
|
textModifier: number,
|
|
13
14
|
disabled: boolean
|
|
14
|
-
): ReactElement<
|
|
15
|
-
<StyledMenuItem
|
|
15
|
+
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
|
+
<StyledMenuItem aria-disabled={disabled}>
|
|
16
17
|
Result
|
|
17
18
|
<span>
|
|
18
19
|
num<span>ber</span>
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
ComboBoxMenuItemGroup,
|
|
6
6
|
} from '@workday/canvas-kit-labs-react/combobox';
|
|
7
7
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
8
|
-
import {StyledMenuItem
|
|
8
|
+
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
9
9
|
import {TextInput} from '@workday/canvas-kit-react/text-input';
|
|
10
|
-
import {CanvasProvider, ContentDirection} from '@workday/canvas-kit-react/common';
|
|
10
|
+
import {CanvasProvider, ContentDirection, ExtractProps} from '@workday/canvas-kit-react/common';
|
|
11
11
|
|
|
12
12
|
const autocompleteResult = (
|
|
13
13
|
textModifier: number,
|
|
14
14
|
disabled: boolean
|
|
15
|
-
): ReactElement<
|
|
15
|
+
): ReactElement<ExtractProps<typeof StyledMenuItem>> => (
|
|
16
16
|
<StyledMenuItem isDisabled={disabled}>
|
|
17
17
|
Result
|
|
18
18
|
<span>
|
|
@@ -2,6 +2,7 @@ import {ExampleCodeBlock, SymbolDoc, Specifications} from '@workday/canvas-kit-d
|
|
|
2
2
|
import Basic from './examples/Basic';
|
|
3
3
|
import ContextMenu from './examples/ContextMenu';
|
|
4
4
|
import Icons from './examples/Icons';
|
|
5
|
+
import SelectableMenu from './examples/SelectableMenu';
|
|
5
6
|
|
|
6
7
|
# Canvas Kit Menu
|
|
7
8
|
|
|
@@ -55,6 +56,19 @@ about the text of the item.
|
|
|
55
56
|
|
|
56
57
|
<ExampleCodeBlock code={Icons} />
|
|
57
58
|
|
|
59
|
+
### Selectable Menu
|
|
60
|
+
|
|
61
|
+
The `Menu.Item` renders a `role=menuitem` element which does not have `aria-selected` and thus no
|
|
62
|
+
selected state. If you wish your menu to have selectable menu items, use `Menu.Option` instead of
|
|
63
|
+
`Menu.Item`. The `Menu.Option` is meant to be used when the `Menu.Card` has a role of `listbox` and
|
|
64
|
+
is controlled via `aria-activedescendant`. This example uses `Menu.Option` to should what the
|
|
65
|
+
checkmark looks like, but the example is not keyboard or screen reader accessible. There are many
|
|
66
|
+
other behaviors that need to be composed into the `Menu.Target` and `Menu.List` components and the
|
|
67
|
+
behaviors depend on many other things. To see a full example of all these behaviors, look at the
|
|
68
|
+
`<Combobox>` and `<Select>` component source code as examples.
|
|
69
|
+
|
|
70
|
+
<ExampleCodeBlock code={SelectableMenu} />
|
|
71
|
+
|
|
58
72
|
## Component API
|
|
59
73
|
|
|
60
74
|
<SymbolDoc name="Menu" fileName="/react/" />
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import {Menu} from '@workday/canvas-kit-react/menu';
|
|
4
|
+
import {BodyText} from '@workday/canvas-kit-react/text';
|
|
5
|
+
|
|
6
|
+
export default () => {
|
|
7
|
+
const [selected, setSelected] = React.useState('');
|
|
8
|
+
return (
|
|
9
|
+
<Menu onSelect={data => setSelected(data.id)}>
|
|
10
|
+
<Menu.Target>Open Menu</Menu.Target>
|
|
11
|
+
<Menu.Popper>
|
|
12
|
+
<Menu.Card role="listbox">
|
|
13
|
+
<Menu.List as="ul">
|
|
14
|
+
<Menu.Option>First Item</Menu.Option>
|
|
15
|
+
<Menu.Option>Second Item</Menu.Option>
|
|
16
|
+
<Menu.Divider />
|
|
17
|
+
<Menu.Option>Third Item (with a really, really, really long label)</Menu.Option>
|
|
18
|
+
<Menu.Option aria-disabled>Fourth Item</Menu.Option>
|
|
19
|
+
</Menu.List>
|
|
20
|
+
</Menu.Card>
|
|
21
|
+
</Menu.Popper>
|
|
22
|
+
<BodyText size="small" marginTop="s">
|
|
23
|
+
Selected: <span data-testid="output">{selected}</span>
|
|
24
|
+
</BodyText>
|
|
25
|
+
</Menu>
|
|
26
|
+
);
|
|
27
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workday/canvas-kit-docs",
|
|
3
|
-
"version": "12.0.0-alpha.
|
|
3
|
+
"version": "12.0.0-alpha.908-next.0",
|
|
4
4
|
"description": "Documentation components of Canvas Kit components",
|
|
5
5
|
"author": "Workday, Inc. (https://www.workday.com)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@emotion/styled": "^11.6.0",
|
|
46
46
|
"@storybook/csf": "0.0.1",
|
|
47
|
-
"@workday/canvas-kit-labs-react": "^12.0.0-alpha.
|
|
48
|
-
"@workday/canvas-kit-preview-react": "^12.0.0-alpha.
|
|
49
|
-
"@workday/canvas-kit-react": "^12.0.0-alpha.
|
|
50
|
-
"@workday/canvas-kit-styling": "^12.0.0-alpha.
|
|
47
|
+
"@workday/canvas-kit-labs-react": "^12.0.0-alpha.908-next.0",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^12.0.0-alpha.908-next.0",
|
|
49
|
+
"@workday/canvas-kit-react": "^12.0.0-alpha.908-next.0",
|
|
50
|
+
"@workday/canvas-kit-styling": "^12.0.0-alpha.908-next.0",
|
|
51
51
|
"@workday/canvas-system-icons-web": "^3.0.0",
|
|
52
52
|
"@workday/canvas-tokens-web": "^2.0.1",
|
|
53
53
|
"markdown-to-jsx": "^7.2.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"mkdirp": "^1.0.3",
|
|
61
61
|
"typescript": "4.9"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "96aa087e44d928f9b530e0133be4326b8ff2fdce"
|
|
64
64
|
}
|