@workday/canvas-kit-docs 16.1.4 → 16.2.0-0612-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.
Files changed (26) hide show
  1. package/dist/es6/lib/docs.js +18352 -5202
  2. package/dist/es6/lib/specs.js +204 -20
  3. package/dist/es6/lib/stackblitzFiles/packageJSONFile.js +5 -5
  4. package/dist/es6/lib/stackblitzFiles/packageJSONFile.ts +5 -5
  5. package/dist/mdx/accessibility/AccessibilityOverview.mdx +1 -3
  6. package/dist/mdx/labs-react/selection-group/SelectionGroup.mdx +135 -0
  7. package/dist/mdx/labs-react/selection-group/examples/Basic.tsx +11 -0
  8. package/dist/mdx/labs-react/selection-group/examples/Caution.tsx +27 -0
  9. package/dist/mdx/labs-react/selection-group/examples/ColumnWidth.tsx +17 -0
  10. package/dist/mdx/labs-react/selection-group/examples/ContentWidth.tsx +11 -0
  11. package/dist/mdx/labs-react/selection-group/examples/Disabled.tsx +33 -0
  12. package/dist/mdx/labs-react/selection-group/examples/EqualWidth.tsx +11 -0
  13. package/dist/mdx/labs-react/selection-group/examples/Error.tsx +27 -0
  14. package/dist/mdx/labs-react/selection-group/examples/MultiSelect.tsx +41 -0
  15. package/dist/mdx/labs-react/selection-group/examples/RTL.tsx +13 -0
  16. package/dist/mdx/labs-react/selection-group/examples/SingleSelect.tsx +33 -0
  17. package/dist/mdx/preview-react/_examples/mdx/FormLibraryExample.mdx +1 -33
  18. package/dist/mdx/preview-react/_examples/mdx/examples/TextInputWithReactHookForm.tsx +65 -94
  19. package/dist/mdx/react/_examples/mdx/Density.mdx +3 -19
  20. package/dist/mdx/react/_examples/mdx/FormsWithFormik.mdx +9 -0
  21. package/dist/mdx/react/_examples/mdx/examples/Density.tsx +212 -139
  22. package/dist/mdx/react/_examples/mdx/examples/SelectWithFormik.tsx +84 -0
  23. package/dist/mdx/react/select/Select.mdx +77 -239
  24. package/dist/mdx/react/select/examples/GroupedItems.tsx +30 -24
  25. package/dist/mdx/react/select/examples/WithIcons.tsx +1 -1
  26. package/package.json +6 -6
@@ -1491,26 +1491,6 @@ module.exports = {specifications: [
1491
1491
  {
1492
1492
  "type": "it",
1493
1493
  "name": "should not have any axe errors"
1494
- },
1495
- {
1496
- "type": "describe",
1497
- "name": "when the form is submitted with an empty required select",
1498
- "children": [
1499
- {
1500
- "type": "it",
1501
- "name": "should focus the first invalid field"
1502
- }
1503
- ]
1504
- },
1505
- {
1506
- "type": "describe",
1507
- "name": "when a later required field is empty",
1508
- "children": [
1509
- {
1510
- "type": "it",
1511
- "name": "should focus the first invalid field"
1512
- }
1513
- ]
1514
1494
  }
1515
1495
  ]
1516
1496
  }
@@ -5237,6 +5217,210 @@ module.exports = {specifications: [
5237
5217
  }
5238
5218
  ]
5239
5219
  },
5220
+ {
5221
+ "type": "file",
5222
+ "name": "SelectionGroup",
5223
+ "children": [
5224
+ {
5225
+ "type": "describe",
5226
+ "name": "SelectionGroup",
5227
+ "children": [
5228
+ {
5229
+ "type": "describe",
5230
+ "name": "given the story is rendered",
5231
+ "children": [
5232
+ {
5233
+ "type": "it",
5234
+ "name": "should not have any axe errors"
5235
+ }
5236
+ ]
5237
+ },
5238
+ {
5239
+ "type": "describe",
5240
+ "name": "given the story is rendered",
5241
+ "children": [
5242
+ {
5243
+ "type": "it",
5244
+ "name": "should not have any axe errors"
5245
+ }
5246
+ ]
5247
+ },
5248
+ {
5249
+ "type": "describe",
5250
+ "name": "given the story is rendered",
5251
+ "children": [
5252
+ {
5253
+ "type": "it",
5254
+ "name": "should not have any axe errors"
5255
+ }
5256
+ ]
5257
+ },
5258
+ {
5259
+ "type": "describe",
5260
+ "name": "given the story is rendered",
5261
+ "children": [
5262
+ {
5263
+ "type": "it",
5264
+ "name": "should not have any axe errors"
5265
+ }
5266
+ ]
5267
+ },
5268
+ {
5269
+ "type": "describe",
5270
+ "name": "given the story is rendered",
5271
+ "children": [
5272
+ {
5273
+ "type": "it",
5274
+ "name": "should not have any axe errors"
5275
+ }
5276
+ ]
5277
+ },
5278
+ {
5279
+ "type": "describe",
5280
+ "name": "given the story is rendered",
5281
+ "children": [
5282
+ {
5283
+ "type": "it",
5284
+ "name": "should not have any axe errors"
5285
+ }
5286
+ ]
5287
+ },
5288
+ {
5289
+ "type": "describe",
5290
+ "name": "given the story is rendered",
5291
+ "children": [
5292
+ {
5293
+ "type": "it",
5294
+ "name": "should not have any axe errors"
5295
+ }
5296
+ ]
5297
+ },
5298
+ {
5299
+ "type": "describe",
5300
+ "name": "given the story is rendered",
5301
+ "children": [
5302
+ {
5303
+ "type": "it",
5304
+ "name": "should not have any axe errors"
5305
+ }
5306
+ ]
5307
+ },
5308
+ {
5309
+ "type": "describe",
5310
+ "name": "given the story is rendered",
5311
+ "children": [
5312
+ {
5313
+ "type": "it",
5314
+ "name": "should not have any axe errors"
5315
+ }
5316
+ ]
5317
+ },
5318
+ {
5319
+ "type": "describe",
5320
+ "name": "given the Basic story is rendered",
5321
+ "children": [
5322
+ {
5323
+ "type": "it",
5324
+ "name": "should render a radiogroup"
5325
+ },
5326
+ {
5327
+ "type": "it",
5328
+ "name": "should start with nothing selected"
5329
+ },
5330
+ {
5331
+ "type": "describe",
5332
+ "name": "when an item is clicked",
5333
+ "children": [
5334
+ {
5335
+ "type": "it",
5336
+ "name": "should select that item"
5337
+ },
5338
+ {
5339
+ "type": "it",
5340
+ "name": "should deselect the item when another is clicked"
5341
+ }
5342
+ ]
5343
+ },
5344
+ {
5345
+ "type": "describe",
5346
+ "name": "when navigating with the keyboard",
5347
+ "children": [
5348
+ {
5349
+ "type": "it",
5350
+ "name": "should move focus to the next item with the right arrow key"
5351
+ },
5352
+ {
5353
+ "type": "it",
5354
+ "name": "should move selection along with focus, as a radio group does"
5355
+ },
5356
+ {
5357
+ "type": "it",
5358
+ "name": "should have a single tab stop for the whole group"
5359
+ }
5360
+ ]
5361
+ }
5362
+ ]
5363
+ },
5364
+ {
5365
+ "type": "describe",
5366
+ "name": "given the MultiSelect story is rendered",
5367
+ "children": [
5368
+ {
5369
+ "type": "it",
5370
+ "name": "should keep every item in the tab order, as a checkbox group does"
5371
+ },
5372
+ {
5373
+ "type": "it",
5374
+ "name": "should allow more than one item to be selected"
5375
+ },
5376
+ {
5377
+ "type": "it",
5378
+ "name": "should deselect an item when it is clicked again"
5379
+ }
5380
+ ]
5381
+ },
5382
+ {
5383
+ "type": "describe",
5384
+ "name": "given the Disabled story is rendered",
5385
+ "children": [
5386
+ {
5387
+ "type": "it",
5388
+ "name": "should disable every item when the whole group is disabled"
5389
+ },
5390
+ {
5391
+ "type": "it",
5392
+ "name": "should only disable the non-interactive item in a partially disabled group"
5393
+ }
5394
+ ]
5395
+ },
5396
+ {
5397
+ "type": "describe",
5398
+ "name": "given the EqualWidth story is rendered",
5399
+ "children": [
5400
+ {
5401
+ "type": "it",
5402
+ "name": "should render every item at the same width"
5403
+ }
5404
+ ]
5405
+ },
5406
+ {
5407
+ "type": "describe",
5408
+ "name": "given the Error story is rendered",
5409
+ "children": [
5410
+ {
5411
+ "type": "it",
5412
+ "name": "should mark the group as invalid"
5413
+ },
5414
+ {
5415
+ "type": "it",
5416
+ "name": "should associate the hint text with the group"
5417
+ }
5418
+ ]
5419
+ }
5420
+ ]
5421
+ }
5422
+ ]
5423
+ },
5240
5424
  {
5241
5425
  "type": "file",
5242
5426
  "name": "SidePanel",
@@ -18,11 +18,11 @@ export const packageJSONFile = `{
18
18
  "@emotion/react": "11.11.4",
19
19
  "@types/react": "18.2.60",
20
20
  "@types/react-dom": "18.2.19",
21
- "@workday/canvas-kit-labs-react": "16.1.4",
22
- "@workday/canvas-kit-preview-react": "16.1.4",
23
- "@workday/canvas-kit-react": "16.1.4",
24
- "@workday/canvas-kit-react-fonts": "^16.1.4",
25
- "@workday/canvas-kit-styling": "16.1.4",
21
+ "@workday/canvas-kit-labs-react": "16.1.2",
22
+ "@workday/canvas-kit-preview-react": "16.1.2",
23
+ "@workday/canvas-kit-react": "16.1.2",
24
+ "@workday/canvas-kit-react-fonts": "^16.1.2",
25
+ "@workday/canvas-kit-styling": "16.1.2",
26
26
  "@workday/canvas-system-icons-web": "^5.0.3",
27
27
  "@workday/canvas-expressive-icons-web": "1.0.1",
28
28
  "@workday/canvas-tokens-web": "4.4.0-beta.11"
@@ -19,11 +19,11 @@ export const packageJSONFile = `{
19
19
  "@emotion/react": "11.11.4",
20
20
  "@types/react": "18.2.60",
21
21
  "@types/react-dom": "18.2.19",
22
- "@workday/canvas-kit-labs-react": "16.1.4",
23
- "@workday/canvas-kit-preview-react": "16.1.4",
24
- "@workday/canvas-kit-react": "16.1.4",
25
- "@workday/canvas-kit-react-fonts": "^16.1.4",
26
- "@workday/canvas-kit-styling": "16.1.4",
22
+ "@workday/canvas-kit-labs-react": "16.1.2",
23
+ "@workday/canvas-kit-preview-react": "16.1.2",
24
+ "@workday/canvas-kit-react": "16.1.2",
25
+ "@workday/canvas-kit-react-fonts": "^16.1.2",
26
+ "@workday/canvas-kit-styling": "16.1.2",
27
27
  "@workday/canvas-system-icons-web": "^5.0.3",
28
28
  "@workday/canvas-expressive-icons-web": "1.0.1",
29
29
  "@workday/canvas-tokens-web": "4.4.0-beta.11"
@@ -86,9 +86,7 @@ Further reading:
86
86
  ```
87
87
 
88
88
  Check out our [Aria Live Region Examples](?path=/docs/guides-accessibility-aria-live-regions--docs)
89
- for more detailed information about this topic. For labels, error text, `aria-invalid`, and focus
90
- after a failed submit, see
91
- [Form Validation](?path=/docs/guides-accessibility-form-validation--docs).
89
+ for more detailed information about this topic.
92
90
 
93
91
  Sometimes, things change on a webpage without the whole page reloading. Think of a live sports score
94
92
  that updates every few seconds or a search result that appears as you type. For users of screen
@@ -0,0 +1,135 @@
1
+ import {ExampleCodeBlock, Specifications, SymbolDoc} from '@workday/canvas-kit-docs';
2
+ import Basic from './examples/Basic';
3
+ import Caution from './examples/Caution';
4
+ import ColumnWidth from './examples/ColumnWidth';
5
+ import ContentWidth from './examples/ContentWidth';
6
+ import Disabled from './examples/Disabled';
7
+ import EqualWidth from './examples/EqualWidth';
8
+ import Error from './examples/Error';
9
+ import MultiSelect from './examples/MultiSelect';
10
+ import RTL from './examples/RTL';
11
+ import SingleSelect from './examples/SingleSelect';
12
+
13
+
14
+ # Canvas Kit Selection Group
15
+
16
+ Selection Group is a
17
+ [compound component](/getting-started/for-developers/resources/compound-components/) that lets users
18
+ select one or more options from a predefined list using chip-style controls with a lightweight glyph
19
+ indicator.
20
+
21
+ Reach for Selection Group instead of standard radio buttons or checkboxes when a larger, more
22
+ scannable tap target and a lighter visual footprint are preferred. It works best with roughly seven
23
+ or fewer options and short, concise labels.
24
+
25
+ ## Installation
26
+
27
+ ```sh
28
+ yarn add @workday/canvas-kit-labs-react
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ ### Basic Example
34
+
35
+ `SelectionGroup` includes a container `SelectionGroup` component and the following subcomponents:
36
+ `SelectionGroup.List` and `SelectionGroup.Item`.
37
+
38
+ <ExampleCodeBlock code={Basic} />
39
+
40
+ ### Single Select
41
+
42
+ Use `mode="single"` to allow only one selection at a time. Single-select groups use a circle glyph
43
+ and behave like a radio group: they have a single tab stop and arrow keys move both focus and
44
+ selection.
45
+
46
+ <ExampleCodeBlock code={SingleSelect} />
47
+
48
+ ### Multi Select
49
+
50
+ Use `mode="multiple"` to allow more than one selection. Multi-select groups use a square glyph and
51
+ behave like a checkbox group, where every item is its own tab stop. The group label must state that
52
+ multiple selections are allowed.
53
+
54
+ <ExampleCodeBlock code={MultiSelect} />
55
+
56
+ ### Width Variations
57
+
58
+ All items within a group use the same sizing method — don't mix sizing methods within one group.
59
+
60
+ #### Content Width
61
+
62
+ Each item is sized to its own label, so items within a group may differ in width.
63
+
64
+ <ExampleCodeBlock code={ContentWidth} />
65
+
66
+ #### Equal Width
67
+
68
+ Every item is sized to match the width of the longest label, so all items end up the same width.
69
+
70
+ <ExampleCodeBlock code={EqualWidth} />
71
+
72
+ #### Column Width
73
+
74
+ Every item spans the full width of the column. Best for longer labels, or when the group is the
75
+ primary input on the page.
76
+
77
+ <ExampleCodeBlock code={ColumnWidth} />
78
+
79
+ ### Disabled
80
+
81
+ Set the `disabled` prop on `SelectionGroup` to disable the entire group. To disable individual
82
+ items, pass their ids to `nonInteractiveIds` so that keyboard navigation skips over them as well.
83
+
84
+ <ExampleCodeBlock code={Disabled} />
85
+
86
+ ### Error
87
+
88
+ Notification states apply to the whole group rather than to individual items. Wrapping the group in
89
+ a `FormField` with `error="error"` applies the error state and associates the hint text with the
90
+ group. This is the recommended approach, because `FormField` also renders the visible hint text,
91
+ sets `aria-invalid`, and points the group's `aria-describedby` at that text.
92
+
93
+ You can set `error="error"` directly on `SelectionGroup` when you aren't using `FormField`, but the
94
+ prop only changes the group's border color. Color on its own is not an accessible way to
95
+ communicate a notification state, so pair it with your own visible text and pass that element's id
96
+ to `aria-describedby` on `SelectionGroup`.
97
+
98
+ <ExampleCodeBlock code={Error} />
99
+
100
+ ### Caution
101
+
102
+ <ExampleCodeBlock code={Caution} />
103
+
104
+ ### Right-to-Left (RTL)
105
+
106
+ `SelectionGroup` supports right-to-left languages when specified in the `CanvasProvider` `theme` or
107
+ via the `dir` attribute on a parent element.
108
+
109
+ <ExampleCodeBlock code={RTL} />
110
+
111
+ ## Accessibility
112
+
113
+ - Single-select groups render `role="radiogroup"` with `role="radio"` items and `aria-checked`, and
114
+ follow the [radio group keyboard pattern](https://www.w3.org/WAI/ARIA/apg/patterns/radio/): one
115
+ tab stop for the group, with arrow keys moving focus and selection together.
116
+ - Multi-select groups render `role="group"` with `role="checkbox"` items and `aria-checked`, and
117
+ follow the [checkbox keyboard pattern](https://www.w3.org/WAI/ARIA/apg/patterns/checkbox/): every
118
+ item is in the tab order and <kbd>Space</kbd> toggles it.
119
+ - The icon always renders, in both modes and in both selected states. Selection is communicated by
120
+ the checkmark inside the icon _and_ a color change, never by color alone.
121
+ - `aria-invalid` is only set on a single-select group. The `group` role that a multi-select group
122
+ renders does not allow the attribute, so a multi-select group communicates its error state
123
+ through the text referenced by `aria-describedby`. Make sure that text names the problem.
124
+ - A group label is required. Provide it with `aria-label` or `aria-labelledby` on
125
+ `SelectionGroup.List`, or wrap the group in a `FormField` with a visible label. The label must
126
+ state the selection mode — "Select one" versus "Select all that apply" — so the mode is clear
127
+ before interacting.
128
+
129
+ ## Component API
130
+
131
+ <SymbolDoc name="SelectionGroup" fileName="/labs-react/" />
132
+
133
+ ## Specifications
134
+
135
+ <Specifications file="./cypress/component/SelectionGroup.spec.tsx" name="SelectionGroup" />
@@ -0,0 +1,11 @@
1
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
2
+
3
+ export default () => (
4
+ <SelectionGroup mode="single">
5
+ <SelectionGroup.List aria-label="Preferred contact method (select one)">
6
+ <SelectionGroup.Item data-id="email">Email</SelectionGroup.Item>
7
+ <SelectionGroup.Item data-id="phone">Phone</SelectionGroup.Item>
8
+ <SelectionGroup.Item data-id="text">Text Message</SelectionGroup.Item>
9
+ </SelectionGroup.List>
10
+ </SelectionGroup>
11
+ );
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+
6
+ export default () => {
7
+ const [selected, setSelected] = React.useState(['deep-dish']);
8
+
9
+ return (
10
+ <FormField error="caution" as="fieldset">
11
+ <FormField.Label as="legend">Select Your Pizza Crust (Select one)</FormField.Label>
12
+ <FormField.Input
13
+ as={SelectionGroup}
14
+ mode="single"
15
+ selectedIds={selected}
16
+ onSelect={data => setSelected([data.id])}
17
+ >
18
+ <SelectionGroup.List aria-label="Pizza crust options (select one)">
19
+ <SelectionGroup.Item data-id="deep-dish">Deep Dish</SelectionGroup.Item>
20
+ <SelectionGroup.Item data-id="thin">Thin</SelectionGroup.Item>
21
+ <SelectionGroup.Item data-id="gluten-free">Gluten Free</SelectionGroup.Item>
22
+ </SelectionGroup.List>
23
+ </FormField.Input>
24
+ <FormField.Hint>Deep dish is an extra $2.99</FormField.Hint>
25
+ </FormField>
26
+ );
27
+ };
@@ -0,0 +1,17 @@
1
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
2
+
3
+ export default () => (
4
+ <SelectionGroup mode="single" width="column" initialSelectedIds={['option-a']}>
5
+ <SelectionGroup.List aria-label="Column width selection group (select one)">
6
+ <SelectionGroup.Item data-id="option-a">
7
+ Option A with a longer descriptive label
8
+ </SelectionGroup.Item>
9
+ <SelectionGroup.Item data-id="option-b">
10
+ Option B with a longer descriptive label
11
+ </SelectionGroup.Item>
12
+ <SelectionGroup.Item data-id="option-c">
13
+ Option C with a longer descriptive label
14
+ </SelectionGroup.Item>
15
+ </SelectionGroup.List>
16
+ </SelectionGroup>
17
+ );
@@ -0,0 +1,11 @@
1
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
2
+
3
+ export default () => (
4
+ <SelectionGroup mode="single" width="content" initialSelectedIds={['short']}>
5
+ <SelectionGroup.List aria-label="Content width selection group (select one)">
6
+ <SelectionGroup.Item data-id="short">Short</SelectionGroup.Item>
7
+ <SelectionGroup.Item data-id="medium-length">Medium Length</SelectionGroup.Item>
8
+ <SelectionGroup.Item data-id="a-much-longer-label">A Much Longer Label</SelectionGroup.Item>
9
+ </SelectionGroup.List>
10
+ </SelectionGroup>
11
+ );
@@ -0,0 +1,33 @@
1
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
2
+ import {BodyText} from '@workday/canvas-kit-react/text';
3
+ import {system} from '@workday/canvas-tokens-web';
4
+
5
+ export default () => (
6
+ <>
7
+ <BodyText size="small" cs={{marginBlockEnd: system.gap.xs}}>
8
+ The whole group is disabled
9
+ </BodyText>
10
+ <SelectionGroup mode="single" disabled initialSelectedIds={['option-a']}>
11
+ <SelectionGroup.List aria-label="Fully disabled selection group (select one)">
12
+ <SelectionGroup.Item data-id="option-a">Option A</SelectionGroup.Item>
13
+ <SelectionGroup.Item data-id="option-b">Option B</SelectionGroup.Item>
14
+ <SelectionGroup.Item data-id="option-c">Option C</SelectionGroup.Item>
15
+ </SelectionGroup.List>
16
+ </SelectionGroup>
17
+
18
+ <BodyText size="small" cs={{marginBlockStart: system.gap.md, marginBlockEnd: system.gap.xs}}>
19
+ A single item is disabled
20
+ </BodyText>
21
+ <SelectionGroup
22
+ mode="single"
23
+ nonInteractiveIds={['option-c']}
24
+ initialSelectedIds={['option-a']}
25
+ >
26
+ <SelectionGroup.List aria-label="Partially disabled selection group (select one)">
27
+ <SelectionGroup.Item data-id="option-a">Option A</SelectionGroup.Item>
28
+ <SelectionGroup.Item data-id="option-b">Option B</SelectionGroup.Item>
29
+ <SelectionGroup.Item data-id="option-c">Option C</SelectionGroup.Item>
30
+ </SelectionGroup.List>
31
+ </SelectionGroup>
32
+ </>
33
+ );
@@ -0,0 +1,11 @@
1
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
2
+
3
+ export default () => (
4
+ <SelectionGroup mode="single" width="equal" initialSelectedIds={['short']}>
5
+ <SelectionGroup.List aria-label="Equal width selection group (select one)">
6
+ <SelectionGroup.Item data-id="short">Short</SelectionGroup.Item>
7
+ <SelectionGroup.Item data-id="medium-length">Medium Length</SelectionGroup.Item>
8
+ <SelectionGroup.Item data-id="a-much-longer-label">A Much Longer Label</SelectionGroup.Item>
9
+ </SelectionGroup.List>
10
+ </SelectionGroup>
11
+ );
@@ -0,0 +1,27 @@
1
+ import React from 'react';
2
+
3
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+
6
+ export default () => {
7
+ const [selected, setSelected] = React.useState<string[]>([]);
8
+
9
+ return (
10
+ <FormField error="error" as="fieldset">
11
+ <FormField.Label as="legend">Select Your Pizza Crust (Select one)</FormField.Label>
12
+ <FormField.Input
13
+ as={SelectionGroup}
14
+ mode="single"
15
+ selectedIds={selected}
16
+ onSelect={data => setSelected([data.id])}
17
+ >
18
+ <SelectionGroup.List aria-label="Pizza crust options (select one)">
19
+ <SelectionGroup.Item data-id="deep-dish">Deep Dish</SelectionGroup.Item>
20
+ <SelectionGroup.Item data-id="thin">Thin</SelectionGroup.Item>
21
+ <SelectionGroup.Item data-id="gluten-free">Gluten Free</SelectionGroup.Item>
22
+ </SelectionGroup.List>
23
+ </FormField.Input>
24
+ <FormField.Hint>Please select a crust to continue</FormField.Hint>
25
+ </FormField>
26
+ );
27
+ };
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+
3
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+ import {BodyText} from '@workday/canvas-kit-react/text';
6
+ import {system} from '@workday/canvas-tokens-web';
7
+
8
+ export default () => {
9
+ const [selected, setSelected] = React.useState<string[]>(['monday']);
10
+
11
+ const handleSelect = (data: {id: string}) => {
12
+ setSelected(previous =>
13
+ previous.includes(data.id) ? previous.filter(id => id !== data.id) : previous.concat(data.id)
14
+ );
15
+ };
16
+
17
+ return (
18
+ <>
19
+ <FormField as="fieldset">
20
+ <FormField.Label as="legend">Available Days (Select all that apply)</FormField.Label>
21
+ <FormField.Input
22
+ as={SelectionGroup}
23
+ mode="multiple"
24
+ selectedIds={selected}
25
+ onSelect={handleSelect}
26
+ >
27
+ <SelectionGroup.List aria-label="Available days (select all that apply)">
28
+ <SelectionGroup.Item data-id="monday">Monday</SelectionGroup.Item>
29
+ <SelectionGroup.Item data-id="tuesday">Tuesday</SelectionGroup.Item>
30
+ <SelectionGroup.Item data-id="wednesday">Wednesday</SelectionGroup.Item>
31
+ <SelectionGroup.Item data-id="thursday">Thursday</SelectionGroup.Item>
32
+ <SelectionGroup.Item data-id="friday">Friday</SelectionGroup.Item>
33
+ </SelectionGroup.List>
34
+ </FormField.Input>
35
+ </FormField>
36
+ <BodyText size="small" cs={{marginBlockStart: system.gap.md}}>
37
+ Selected: {selected.join(', ') || 'None'}
38
+ </BodyText>
39
+ </>
40
+ );
41
+ };
@@ -0,0 +1,13 @@
1
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
2
+
3
+ export default () => (
4
+ <div dir="rtl">
5
+ <SelectionGroup mode="single" initialSelectedIds={['option-b']}>
6
+ <SelectionGroup.List aria-label="اختر واحدا">
7
+ <SelectionGroup.Item data-id="option-a">الخيار أ</SelectionGroup.Item>
8
+ <SelectionGroup.Item data-id="option-b">الخيار ب</SelectionGroup.Item>
9
+ <SelectionGroup.Item data-id="option-c">الخيار ج</SelectionGroup.Item>
10
+ </SelectionGroup.List>
11
+ </SelectionGroup>
12
+ </div>
13
+ );
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+
3
+ import {SelectionGroup} from '@workday/canvas-kit-labs-react/selection-group';
4
+ import {FormField} from '@workday/canvas-kit-react/form-field';
5
+ import {BodyText} from '@workday/canvas-kit-react/text';
6
+ import {system} from '@workday/canvas-tokens-web';
7
+
8
+ export default () => {
9
+ const [selected, setSelected] = React.useState('email');
10
+
11
+ return (
12
+ <>
13
+ <FormField as="fieldset">
14
+ <FormField.Label as="legend">Preferred Contact Method (Select one)</FormField.Label>
15
+ <FormField.Input
16
+ as={SelectionGroup}
17
+ mode="single"
18
+ selectedIds={[selected]}
19
+ onSelect={data => setSelected(data.id)}
20
+ >
21
+ <SelectionGroup.List aria-label="Preferred contact method (select one)">
22
+ <SelectionGroup.Item data-id="email">Email</SelectionGroup.Item>
23
+ <SelectionGroup.Item data-id="phone">Phone</SelectionGroup.Item>
24
+ <SelectionGroup.Item data-id="text">Text Message</SelectionGroup.Item>
25
+ </SelectionGroup.List>
26
+ </FormField.Input>
27
+ </FormField>
28
+ <BodyText size="small" cs={{marginBlockStart: system.gap.md}}>
29
+ Selected: {selected}
30
+ </BodyText>
31
+ </>
32
+ );
33
+ };