@workday/canvas-kit-docs 12.0.0-alpha.908-next.0 → 12.0.0-alpha.918-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 +5320 -2233
- package/dist/mdx/10.0-UPGRADE-GUIDE.mdx +16 -5
- package/dist/mdx/12.0-UPGRADE-GUIDE.mdx +224 -6
- package/dist/mdx/5.0-UPGRADE-GUIDE.mdx +66 -53
- package/dist/mdx/6.0-UPGRADE-GUIDE.mdx +12 -5
- package/dist/mdx/7.0-UPGRADE-GUIDE.mdx +15 -8
- package/dist/mdx/MAINTAINING.mdx +15 -8
- package/dist/mdx/preview-react/menu/Menu.mdx +14 -7
- package/dist/mdx/react/combobox/Combobox.mdx +37 -3
- package/dist/mdx/react/combobox/examples/Autocomplete.tsx +41 -33
- package/dist/mdx/react/form-field/FormField.mdx +8 -0
- package/dist/mdx/react/form-field/examples/HiddenLabel.tsx +30 -0
- package/dist/mdx/react/menu/Menu.mdx +12 -6
- package/dist/mdx/react/select/Select.mdx +11 -0
- package/dist/mdx/react/select/examples/Basic.tsx +1 -0
- package/dist/mdx/react/select/examples/Controlled.tsx +68 -0
- package/dist/mdx/react/select/examples/WithIcons.tsx +1 -1
- package/dist/mdx/react/status-indicator/StatusIndicator.mdx +12 -6
- package/dist/mdx/react/text-input/TextInput.mdx +2 -1
- package/package.json +7 -7
package/dist/mdx/MAINTAINING.mdx
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {Markdown} from '@storybook/blocks';
|
|
2
|
+
|
|
3
|
+
|
|
1
4
|
# Maintaining Canvas Kit
|
|
2
5
|
|
|
3
6
|
If you're a Canvas Kit core maintainer, this doc is for you! Consider this a field guide to help you
|
|
@@ -48,13 +51,17 @@ runs on `support`, `master`, and `prerelease/minor` branches. Forward merges for
|
|
|
48
51
|
starts with `chore: Release`, and that's how the forward merge workflow identifies them. Forward
|
|
49
52
|
merges will run on every merge to `prerelease/minor` regardless of the commit message.
|
|
50
53
|
|
|
54
|
+
<Markdown>
|
|
55
|
+
{`
|
|
51
56
|
| Run Forward Merge? | Branch | Commit Message |
|
|
52
57
|
| ------------------ | ------------------ | --------------------------------------- |
|
|
53
|
-
| ✅ |
|
|
54
|
-
| ⛔️ |
|
|
55
|
-
| ✅ |
|
|
56
|
-
| ⛔️ |
|
|
57
|
-
| ✅ |
|
|
58
|
+
| ✅ | \`support\` | \`chore: Release v6.8.14 [skip release]\` |
|
|
59
|
+
| ⛔️ | \`support\` | \`fix: Remove unused props\` |
|
|
60
|
+
| ✅ | \`master\` | \`chore: Release v7.3.0 [skip release]\` |
|
|
61
|
+
| ⛔️ | \`master\` | \`fix: Update Popup types\` |
|
|
62
|
+
| ✅ | \`prerelease/minor\` | \`feat: Add new Layout components\` |
|
|
63
|
+
`}
|
|
64
|
+
</Markdown>
|
|
58
65
|
|
|
59
66
|
If the forward merge workflow fails and cannot automatically merge the update to the next branch, it
|
|
60
67
|
will generate a PR with instructions on how to handle the forward merge manually. For a more
|
|
@@ -264,9 +271,9 @@ We use codemods to reduce friction for consumers as they make changes and do upg
|
|
|
264
271
|
accompany major version releases since v5, and can also be released in minor releases if users want
|
|
265
272
|
to apply some changes sooner.
|
|
266
273
|
|
|
267
|
-
> **Note: In v12, we have done some infrastructure updates with moving to Webpack 5 and Storybook 7.
|
|
268
|
-
these updates has come some formatting issues after running our codemods. We recommend
|
|
269
|
-
formatter to address the format issues that have been introduced in v12.**
|
|
274
|
+
> **Note: In v12, we have done some infrastructure updates with moving to Webpack 5 and Storybook 7.
|
|
275
|
+
> With these updates has come some formatting issues after running our codemods. We recommend
|
|
276
|
+
> running a formatter to address the format issues that have been introduced in v12.**
|
|
270
277
|
|
|
271
278
|
### Add a New Codemod
|
|
272
279
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
import {Markdown} from '@storybook/blocks';
|
|
2
|
+
|
|
1
3
|
import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
|
|
4
|
+
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
2
5
|
import Basic from './examples/Basic';
|
|
3
6
|
import ContextMenu from './examples/ContextMenu';
|
|
4
7
|
import CustomMenuItem from './examples/CustomMenuItem';
|
|
@@ -47,15 +50,19 @@ closing the `DeprecatedMenu`.
|
|
|
47
50
|
using `aria-activedescendant`. Below is table of supported keyboard shortcuts and associated
|
|
48
51
|
actions.
|
|
49
52
|
|
|
53
|
+
<Markdown>
|
|
54
|
+
{`
|
|
50
55
|
| Key | Action |
|
|
51
56
|
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
52
|
-
|
|
|
53
|
-
|
|
|
54
|
-
|
|
|
55
|
-
|
|
|
56
|
-
|
|
|
57
|
-
|
|
|
58
|
-
|
|
|
57
|
+
| \`Enter\` or \`Space\` | Activates the menu item and then closes the menu |
|
|
58
|
+
| \`Escape\` | Closes the menu |
|
|
59
|
+
| \`Up Arrow\` | Moves focus to the previous menu item – if focus is on first menu item, it moves focus to the last menu item |
|
|
60
|
+
| \`Down Arrow\` | Moves focus to the next menu item – if focus is on last menu item, it moves focus to the first menu item |
|
|
61
|
+
| \`Home\` | Moves focus to the first menu item |
|
|
62
|
+
| \`End\` | Moves focus to the last menu item |
|
|
63
|
+
| \`A-Z / a-z\` | Moves focus to the next menu item with a label that starts with the typed character if such an menu item exists – otherwise, focus does not move |
|
|
64
|
+
`}
|
|
65
|
+
</Markdown>
|
|
59
66
|
|
|
60
67
|
Note that although `DeprecatedMenu` includes support for keyboard shortcuts for the menu itself,
|
|
61
68
|
you'll need to add your own keyboard handling and aria attributes to the triggering button.
|
|
@@ -16,6 +16,34 @@ Authoring Practices Guide (APG):
|
|
|
16
16
|
|
|
17
17
|
Examples of a "combobox" would be date pickers, autocomplete, and select components.
|
|
18
18
|
|
|
19
|
+
## Combobox value restriction
|
|
20
|
+
|
|
21
|
+
A Combobox can either be either "constrained" or "arbitrary".
|
|
22
|
+
|
|
23
|
+
### Constrained
|
|
24
|
+
|
|
25
|
+
A constrained combobox can only have a value from a set of values presented as options. The user can
|
|
26
|
+
pick from these values, but cannot input a value outside the options provided. Constrained
|
|
27
|
+
comboboxes use the [useComboboxInputConstrained](#usecomboboxinputconstrained) hook and often have
|
|
28
|
+
two separate `input` elements.
|
|
29
|
+
|
|
30
|
+
- user input - This is the visible input and it should contain user-friendly values. Calls to
|
|
31
|
+
`.focus()` or `.blur()` are redirected to this input. Any prop passed to the `*.Input` component
|
|
32
|
+
that is not directly related to forms will be passed here (i.e. `data-testid`, `aria-*`, etc).
|
|
33
|
+
|
|
34
|
+
- form input - This input is only visible to forms and the `value` will usually be server IDs. If
|
|
35
|
+
the combobox options don't have an ID and only use user values, the value of this input will be
|
|
36
|
+
the same as the user input. Any prop related to the function of forms will be passed here. For
|
|
37
|
+
example, the `name` attribute will be passed here. The `ref` will be pointed to this element.
|
|
38
|
+
|
|
39
|
+
### Arbitrary
|
|
40
|
+
|
|
41
|
+
An arbitrary combobox allows the user to enter any value. The list of options are presented as
|
|
42
|
+
suggestions and selecting an option will prefill the combobox with the value of the option. The user
|
|
43
|
+
is still allowed to modify the combobox even after an option is entered. With arbitrary comboboxes,
|
|
44
|
+
there is only one `input` element. Arbitrary combobox inputs should use the
|
|
45
|
+
[useComboboxInputArbitrary](#usecomboboxinputarbirary) hook.
|
|
46
|
+
|
|
19
47
|
## Installation
|
|
20
48
|
|
|
21
49
|
```sh
|
|
@@ -27,12 +55,14 @@ yarn add @workday/canvas-kit-react
|
|
|
27
55
|
### Autocomplete
|
|
28
56
|
|
|
29
57
|
This example shows an Autocomplete example using `FormField`, `InputGroup`, and the `Combobox`
|
|
30
|
-
components to make an autocomplete form field. It uses
|
|
31
|
-
using `setTimeout`. Your application may use
|
|
58
|
+
components to make an autocomplete form field. It uses [useComboboxLoader](#usecomboboxloader) to
|
|
59
|
+
make mock API calls using `setTimeout`. Your application may use
|
|
32
60
|
[fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API),
|
|
33
61
|
[WebSockets](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API), or other means of
|
|
34
62
|
communicating with a server.
|
|
35
63
|
|
|
64
|
+
An Autocomplete is an example of an arbitrary combobox.
|
|
65
|
+
|
|
36
66
|
<ExampleCodeBlock code={Autocomplete} />
|
|
37
67
|
|
|
38
68
|
### Custom Styles
|
|
@@ -47,4 +77,8 @@ our
|
|
|
47
77
|
|
|
48
78
|
## Hooks
|
|
49
79
|
|
|
50
|
-
<SymbolDoc name="useComboboxLoader" fileName="/react/" />
|
|
80
|
+
<SymbolDoc name="useComboboxLoader" fileName="/react/" />
|
|
81
|
+
|
|
82
|
+
<SymbolDoc name="useComboboxInputConstrained" fileName="/react/" />
|
|
83
|
+
|
|
84
|
+
<SymbolDoc name="useComboboxInputArbitrary" fileName="/react/" />
|
|
@@ -4,7 +4,6 @@ import {
|
|
|
4
4
|
createElemPropsHook,
|
|
5
5
|
createSubcomponent,
|
|
6
6
|
composeHooks,
|
|
7
|
-
ExtractProps,
|
|
8
7
|
} from '@workday/canvas-kit-react/common';
|
|
9
8
|
import {LoadReturn} from '@workday/canvas-kit-react/collection';
|
|
10
9
|
import {
|
|
@@ -12,12 +11,13 @@ import {
|
|
|
12
11
|
useComboboxModel,
|
|
13
12
|
useComboboxLoader,
|
|
14
13
|
useComboboxInput,
|
|
14
|
+
useComboboxInputArbitrary,
|
|
15
15
|
} from '@workday/canvas-kit-react/combobox';
|
|
16
16
|
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
17
17
|
import {StyledMenuItem} from '@workday/canvas-kit-react/menu';
|
|
18
18
|
import {LoadingDots} from '@workday/canvas-kit-react/loading-dots';
|
|
19
19
|
import {InputGroup, TextInput} from '@workday/canvas-kit-react/text-input';
|
|
20
|
-
import {
|
|
20
|
+
import {createStencil, px2rem} from '@workday/canvas-kit-styling';
|
|
21
21
|
import {system} from '@workday/canvas-tokens-web';
|
|
22
22
|
|
|
23
23
|
const colors = ['Red', 'Blue', 'Purple', 'Green', 'Pink'];
|
|
@@ -36,30 +36,51 @@ const useAutocompleteInput = composeHooks(
|
|
|
36
36
|
},
|
|
37
37
|
};
|
|
38
38
|
}),
|
|
39
|
+
useComboboxInputArbitrary,
|
|
39
40
|
useComboboxInput
|
|
40
41
|
);
|
|
41
42
|
|
|
43
|
+
const loadingDotsStencil = createStencil({
|
|
44
|
+
base: {
|
|
45
|
+
transition: 'opacity 100ms ease',
|
|
46
|
+
'& [data-part="loading-dots"]': {
|
|
47
|
+
display: 'flex',
|
|
48
|
+
transform: 'scale(0.3)',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
modifiers: {
|
|
52
|
+
isLoading: {
|
|
53
|
+
true: {
|
|
54
|
+
opacity: system.opacity.full,
|
|
55
|
+
},
|
|
56
|
+
false: {
|
|
57
|
+
opacity: system.opacity.zero,
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
|
|
42
63
|
const AutoCompleteInput = createSubcomponent(TextInput)({
|
|
43
64
|
modelHook: useComboboxModel,
|
|
44
65
|
elemPropsHook: useAutocompleteInput,
|
|
45
|
-
})<
|
|
46
|
-
return
|
|
66
|
+
})<{isLoading?: boolean}>(({isLoading, ...elemProps}, Element) => {
|
|
67
|
+
return (
|
|
68
|
+
<InputGroup>
|
|
69
|
+
<InputGroup.Input as={Element} {...elemProps} />
|
|
70
|
+
<InputGroup.InnerEnd
|
|
71
|
+
cs={loadingDotsStencil({isLoading})}
|
|
72
|
+
width={px2rem(20)}
|
|
73
|
+
data-loading={isLoading}
|
|
74
|
+
>
|
|
75
|
+
<LoadingDots data-part="loading-dots" />
|
|
76
|
+
</InputGroup.InnerEnd>
|
|
77
|
+
<InputGroup.InnerEnd>
|
|
78
|
+
<InputGroup.ClearButton data-testid="clear" />
|
|
79
|
+
</InputGroup.InnerEnd>
|
|
80
|
+
</InputGroup>
|
|
81
|
+
);
|
|
47
82
|
});
|
|
48
83
|
|
|
49
|
-
const styleOverrides = {
|
|
50
|
-
inputGroupInner: createStyles({
|
|
51
|
-
width: px2rem(20),
|
|
52
|
-
transition: 'opacity 100ms ease',
|
|
53
|
-
}),
|
|
54
|
-
loadingDots: createStyles({
|
|
55
|
-
display: 'flex',
|
|
56
|
-
transform: 'scale(0.3)',
|
|
57
|
-
}),
|
|
58
|
-
comboboxMenuList: createStyles({
|
|
59
|
-
maxHeight: px2rem(200),
|
|
60
|
-
}),
|
|
61
|
-
};
|
|
62
|
-
|
|
63
84
|
export default () => {
|
|
64
85
|
const {model, loader} = useComboboxLoader(
|
|
65
86
|
{
|
|
@@ -109,27 +130,14 @@ export default () => {
|
|
|
109
130
|
<FormField.Label>Fruit</FormField.Label>
|
|
110
131
|
<FormField.Field>
|
|
111
132
|
<Combobox model={model} onChange={event => console.log('input', event.currentTarget.value)}>
|
|
112
|
-
<
|
|
113
|
-
<InputGroup.Input as={FormField.Input.as(AutoCompleteInput)} />
|
|
114
|
-
<InputGroup.InnerEnd
|
|
115
|
-
cs={styleOverrides.inputGroupInner}
|
|
116
|
-
pointerEvents="none"
|
|
117
|
-
style={{opacity: loader.isLoading ? system.opacity.full : system.opacity.zero}}
|
|
118
|
-
data-loading={loader.isLoading}
|
|
119
|
-
>
|
|
120
|
-
<LoadingDots cs={styleOverrides.loadingDots} />
|
|
121
|
-
</InputGroup.InnerEnd>
|
|
122
|
-
<InputGroup.InnerEnd>
|
|
123
|
-
<InputGroup.ClearButton data-testid="clear" />
|
|
124
|
-
</InputGroup.InnerEnd>
|
|
125
|
-
</InputGroup>
|
|
133
|
+
<FormField.Input as={AutoCompleteInput} isLoading={loader.isLoading} />
|
|
126
134
|
<Combobox.Menu.Popper>
|
|
127
135
|
<Combobox.Menu.Card>
|
|
128
136
|
{model.state.items.length === 0 && (
|
|
129
137
|
<StyledMenuItem as="span">No Results Found</StyledMenuItem>
|
|
130
138
|
)}
|
|
131
139
|
{model.state.items.length > 0 && (
|
|
132
|
-
<Combobox.Menu.List
|
|
140
|
+
<Combobox.Menu.List maxHeight={px2rem(200)}>
|
|
133
141
|
{item => <Combobox.Menu.Item>{item}</Combobox.Menu.Item>}
|
|
134
142
|
</Combobox.Menu.List>
|
|
135
143
|
)}
|
|
@@ -3,6 +3,7 @@ import Basic from './examples/Basic';
|
|
|
3
3
|
import Alert from './examples/Alert';
|
|
4
4
|
import Error from './examples/Error';
|
|
5
5
|
import Disabled from './examples/Disabled';
|
|
6
|
+
import HiddenLabel from './examples/HiddenLabel';
|
|
6
7
|
import LabelPositionHorizontalStart from './examples/LabelPositionHorizontalStart';
|
|
7
8
|
import LabelPositionHorizontalEnd from './examples/LabelPositionHorizontalEnd';
|
|
8
9
|
import RefForwarding from './examples/RefForwarding';
|
|
@@ -183,6 +184,13 @@ Form Field should allow you to use it with all `inputs` including `Select`, `Tex
|
|
|
183
184
|
|
|
184
185
|
<ExampleCodeBlock code={AllFields} />
|
|
185
186
|
|
|
187
|
+
### Hidden Label
|
|
188
|
+
|
|
189
|
+
In cases where you want to hide the label while still meeting accessibility standards, you can add
|
|
190
|
+
`isHidden` on the `<FormField.Label/>`. This prop will visually hide the label.
|
|
191
|
+
|
|
192
|
+
<ExampleCodeBlock code={HiddenLabel} />
|
|
193
|
+
|
|
186
194
|
### Themed Errors
|
|
187
195
|
|
|
188
196
|
You can theme your error rings by wrapping an input in a `CanvasProvider` and defining
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
4
|
+
import {TextInput, InputGroup} from '@workday/canvas-kit-react/text-input';
|
|
5
|
+
import {SystemIcon} from '@workday/canvas-kit-react/icon';
|
|
6
|
+
import {searchIcon} from '@workday/canvas-system-icons-web';
|
|
7
|
+
|
|
8
|
+
export default () => {
|
|
9
|
+
const [value, setValue] = React.useState('');
|
|
10
|
+
|
|
11
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
12
|
+
setValue(event.target.value);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Flex>
|
|
17
|
+
<FormField>
|
|
18
|
+
<FormField.Label isHidden>Search</FormField.Label>
|
|
19
|
+
<FormField.Field>
|
|
20
|
+
<FormField.Input as={InputGroup}>
|
|
21
|
+
<InputGroup.InnerStart pointerEvents="none">
|
|
22
|
+
<SystemIcon icon={searchIcon} size="small" />
|
|
23
|
+
</InputGroup.InnerStart>
|
|
24
|
+
<InputGroup.Input as={TextInput} onChange={handleChange} />
|
|
25
|
+
</FormField.Input>
|
|
26
|
+
</FormField.Field>
|
|
27
|
+
</FormField>
|
|
28
|
+
</Flex>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {Markdown} from '@storybook/blocks';
|
|
2
|
+
|
|
1
3
|
import {ExampleCodeBlock, SymbolDoc, Specifications} from '@workday/canvas-kit-docs';
|
|
2
4
|
import Basic from './examples/Basic';
|
|
3
5
|
import ContextMenu from './examples/ContextMenu';
|
|
@@ -32,14 +34,18 @@ model which composes a list model and a popup model and sets up accessibility fe
|
|
|
32
34
|
[Actions Menu pattern](https://www.w3.org/WAI/ARIA/apg/patterns/menu-button/examples/menu-button-actions/)
|
|
33
35
|
using roving tabindex. Below is table of supported keyboard shortcuts and associated actions.
|
|
34
36
|
|
|
37
|
+
<Markdown>
|
|
38
|
+
{`
|
|
35
39
|
| Key | Action |
|
|
36
40
|
| ------------------ | ------------------------------------------------------------------------------------------------------------ |
|
|
37
|
-
|
|
|
38
|
-
|
|
|
39
|
-
|
|
|
40
|
-
|
|
|
41
|
-
|
|
|
42
|
-
|
|
|
41
|
+
| \`Enter\` or \`Space\` | Activates the menu item and then closes the menu |
|
|
42
|
+
| \`Escape\` | Closes the menu |
|
|
43
|
+
| \`Up Arrow\` | Moves focus to the previous menu item – if focus is on first menu item, it moves focus to the last menu item |
|
|
44
|
+
| \`Down Arrow\` | Moves focus to the next menu item – if focus is on last menu item, it moves focus to the first menu item |
|
|
45
|
+
| \`Home\` | Moves focus to the first menu item |
|
|
46
|
+
| \`End\` | Moves focus to the last menu item |
|
|
47
|
+
`}
|
|
48
|
+
</Markdown>
|
|
43
49
|
|
|
44
50
|
### Context Menu
|
|
45
51
|
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
import Alert from './examples/Alert';
|
|
8
8
|
import Basic from './examples/Basic';
|
|
9
9
|
import Complex from './examples/Complex';
|
|
10
|
+
import Controlled from './examples/Controlled';
|
|
10
11
|
import Disabled from './examples/Disabled';
|
|
11
12
|
import DisabledOptions from './examples/DisabledOption';
|
|
12
13
|
import Error from './examples/Error';
|
|
@@ -247,6 +248,16 @@ const items = [
|
|
|
247
248
|
</Select>;
|
|
248
249
|
```
|
|
249
250
|
|
|
251
|
+
### Controlled
|
|
252
|
+
|
|
253
|
+
The Select can be a
|
|
254
|
+
[controlled input](https://react.dev/reference/react-dom/components/input#controlling-an-input-with-a-state-variable)
|
|
255
|
+
component by passing the `value` and `onChange` to either the `<Select>` component or the
|
|
256
|
+
`<Select.Input>` component. Internally, the `Select.Input` watches for changes on the `value` React
|
|
257
|
+
prop as well as the `value` DOM property and will update the model accordingly.
|
|
258
|
+
|
|
259
|
+
<ExampleCodeBlock code={Controlled} />
|
|
260
|
+
|
|
250
261
|
### When to use `getId`, or `getTextValue`
|
|
251
262
|
|
|
252
263
|
- `getId`: This is an optional function to return the id of an item. If not provided, the default
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {FormField} from '@workday/canvas-kit-react/form-field';
|
|
3
|
+
import {Select} from '@workday/canvas-kit-react/select';
|
|
4
|
+
import {Flex} from '@workday/canvas-kit-react/layout';
|
|
5
|
+
import {createStyles} from '@workday/canvas-kit-styling';
|
|
6
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
7
|
+
|
|
8
|
+
const parentContainerStyles = createStyles({
|
|
9
|
+
flexDirection: 'column',
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const options = [
|
|
13
|
+
{serverId: 'email', label: 'E-mail'},
|
|
14
|
+
{serverId: 'phone', label: 'Phone'},
|
|
15
|
+
{serverId: 'fax', label: 'Fax'},
|
|
16
|
+
{serverId: 'mail', label: 'Mail'},
|
|
17
|
+
{serverId: 'mobile', label: 'Mobile Phone'},
|
|
18
|
+
{
|
|
19
|
+
serverId: 'oasis',
|
|
20
|
+
label: 'The Ontologically Anthropocentric Sensory Immersive Simulation',
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
export default () => {
|
|
25
|
+
const [value, setValue] = React.useState('');
|
|
26
|
+
const [label, setLabel] = React.useState('');
|
|
27
|
+
|
|
28
|
+
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
29
|
+
setValue(event.currentTarget.value);
|
|
30
|
+
setLabel(options.find(item => item.serverId === event.currentTarget.value)?.label || '');
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<Flex cs={parentContainerStyles}>
|
|
35
|
+
<FormField>
|
|
36
|
+
<FormField.Label>Contact</FormField.Label>
|
|
37
|
+
<FormField.Field>
|
|
38
|
+
<Select items={options} getId={item => item.serverId} getTextValue={item => item.label}>
|
|
39
|
+
<FormField.Input as={Select.Input} onChange={handleChange} value={value} />
|
|
40
|
+
<Select.Popper>
|
|
41
|
+
<Select.Card>
|
|
42
|
+
<Select.List>{item => <Select.Item>{item.label}</Select.Item>}</Select.List>
|
|
43
|
+
</Select.Card>
|
|
44
|
+
</Select.Popper>
|
|
45
|
+
</Select>
|
|
46
|
+
</FormField.Field>
|
|
47
|
+
</FormField>
|
|
48
|
+
<p>Id: {value}</p>
|
|
49
|
+
<p>Label: {label}</p>
|
|
50
|
+
<Flex gap="s">
|
|
51
|
+
<SecondaryButton
|
|
52
|
+
onClick={e => {
|
|
53
|
+
setValue('fax');
|
|
54
|
+
}}
|
|
55
|
+
>
|
|
56
|
+
Set to "Fax"
|
|
57
|
+
</SecondaryButton>
|
|
58
|
+
<SecondaryButton
|
|
59
|
+
onClick={e => {
|
|
60
|
+
setValue('');
|
|
61
|
+
}}
|
|
62
|
+
>
|
|
63
|
+
Clear
|
|
64
|
+
</SecondaryButton>
|
|
65
|
+
</Flex>
|
|
66
|
+
</Flex>
|
|
67
|
+
);
|
|
68
|
+
};
|
|
@@ -40,7 +40,7 @@ export default () => {
|
|
|
40
40
|
<FormField.Input
|
|
41
41
|
as={Select.Input}
|
|
42
42
|
cs={styleOverrides.formfieldInputStyles}
|
|
43
|
-
inputStartIcon={selectedItem
|
|
43
|
+
inputStartIcon={selectedItem?.value.icon}
|
|
44
44
|
/>
|
|
45
45
|
<Select.Popper>
|
|
46
46
|
<Select.Card cs={styleOverrides.selectCardStyles}>
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import {Markdown} from '@storybook/blocks';
|
|
2
|
+
|
|
1
3
|
import {ExampleCodeBlock, SymbolDoc} from '@workday/canvas-kit-docs';
|
|
2
4
|
import {StatusIndicator} from '@workday/canvas-kit-preview-react/status-indicator';
|
|
3
5
|
|
|
@@ -36,14 +38,18 @@ yarn add @workday/canvas-kit-react
|
|
|
36
38
|
Note that the `type` prop is required (there is no default value). `type` accepts the following
|
|
37
39
|
values:
|
|
38
40
|
|
|
41
|
+
<Markdown>
|
|
42
|
+
{`
|
|
39
43
|
| Type | Suggested Purpose |
|
|
40
44
|
| ---------------------------------- | ---------------------------------------------------------------------------------------------- |
|
|
41
|
-
|
|
|
42
|
-
|
|
|
43
|
-
|
|
|
44
|
-
|
|
|
45
|
-
|
|
|
46
|
-
|
|
|
45
|
+
| \`StatusIndicator.Type.Gray\` | Basic, general status. No action required. |
|
|
46
|
+
| \`StatusIndicator.Type.Orange\` | Signifies alerts, that a user must take action, or that something requires attention. |
|
|
47
|
+
| \`StatusIndicator.Type.Blue\` | Signifies an item in progress, an update, or a current status. |
|
|
48
|
+
| \`StatusIndicator.Type.Green\` | Signifies success, completion, or celebration. |
|
|
49
|
+
| \`StatusIndicator.Type.Red\` | Signifies an error or issue, or removal or destruction. |
|
|
50
|
+
| \`StatusIndicator.Type.Transparent\` | General status and related information intended for use on top of imagery, video, or graphics. |
|
|
51
|
+
`}
|
|
52
|
+
</Markdown>
|
|
47
53
|
|
|
48
54
|
### Emphasis
|
|
49
55
|
|
|
@@ -92,7 +92,8 @@ and will be semantically correct in left-to-right and right-to-left languages.
|
|
|
92
92
|
`InputGroup.InnerStart` and `InputGroup.InnerEnd` subcomponents can handle any child elements, but
|
|
93
93
|
are built for icons. The default width is `40px`, which is perfect for icons. If you need to use
|
|
94
94
|
something else, be sure to set the `width` property of `InputGroup.InnerStart` or
|
|
95
|
-
`InputGroup.InnerEnd` to match the intended width of the element.
|
|
95
|
+
`InputGroup.InnerEnd` to match the intended width of the element. Do not use the `cs` prop or any
|
|
96
|
+
method to change width. The `width` prop is used to correctly position other inner elements.
|
|
96
97
|
|
|
97
98
|
<ExampleCodeBlock code={Icons} />
|
|
98
99
|
|
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.918-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.918-next.0",
|
|
48
|
+
"@workday/canvas-kit-preview-react": "^12.0.0-alpha.918-next.0",
|
|
49
|
+
"@workday/canvas-kit-react": "^12.0.0-alpha.918-next.0",
|
|
50
|
+
"@workday/canvas-kit-styling": "^12.0.0-alpha.918-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",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"fs-extra": "^10.0.0",
|
|
59
59
|
"glob": "^7.1.6",
|
|
60
60
|
"mkdirp": "^1.0.3",
|
|
61
|
-
"typescript": "
|
|
61
|
+
"typescript": "5.0"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "3f21a8c474728598369595c8978854dab2355235"
|
|
64
64
|
}
|