@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
@@ -1,4 +1,9 @@
1
- import {ExampleCodeBlock, Specifications, SymbolDoc} from '@workday/canvas-kit-docs';
1
+ import {
2
+ ExampleCodeBlock,
3
+ Specifications,
4
+ SymbolDoc,
5
+ } from '@workday/canvas-kit-docs';
6
+ import {Table} from '@workday/canvas-kit-react/table';
2
7
  import Basic from './examples/Basic';
3
8
  import Caution from './examples/Caution';
4
9
  import Complex from './examples/Complex';
@@ -35,16 +40,30 @@ yarn add @workday/canvas-kit-react
35
40
 
36
41
  ### Basic Example
37
42
 
38
- `Select` supports a [dynamic API](/get-started/for-developers/guides/collection-api/#dynamic-items)
39
- where you pass an array of items via the `items` prop and provide a render function to display the
40
- items. The items may be provided as an
43
+ `Select` supports a
44
+ [dynamic API](/get-started/for-developers/guides/collection-api/#dynamic-items) where you
45
+ pass an array of items via the `items` prop and provide a render function to display the items. The
46
+ items may be provided as an
41
47
  [array of strings](/get-started/for-developers/guides/collection-api/#array-of-strings) or an
42
48
  [array of objects](/get-started/for-developers/guides/collection-api/#array-of-objects).
43
49
 
44
- `Select` should be used in tandem with [Form Field](/components/inputs/form-field/) to ensure proper
45
- label association and screen reader support. Wrap **`Select`** with **`FormField`**, and compose
46
- **`FormField.Input as={Select.Input}`** so the combobox receives the field label. Include
47
- **`Select.Popper`**, **`Select.Card`**, **`Select.List`**, and **`Select.Item`**.
50
+ `Select` should be used in tandem with [Form Field](/components/inputs/form-field/) where the
51
+ `Select` wraps the `FormField` element and the `FormField` element wraps the children of `Select` to
52
+ meet accessibility standards. This ensures the `label` text from `FormField` is attached to the
53
+ `Select.Input` and read out as a group for voiceover.
54
+
55
+ ```tsx
56
+ <Select items={options}>
57
+ <FormField label="Your Label">
58
+ <Select.Input onChange={e => handleChange(e)} id="contact-select" />
59
+ <Select.Popper>
60
+ <Select.Card>
61
+ <Select.List>{item => <Select.Item>{item.id}</Select.Item>}</Select.List>
62
+ </Select.Card>
63
+ </Select.Popper>
64
+ </FormField>
65
+ </Select>
66
+ ```
48
67
 
49
68
  <ExampleCodeBlock code={Basic} />
50
69
 
@@ -77,15 +96,14 @@ input component. By default, the orientation will be set to `vertical`.
77
96
 
78
97
  ### Required
79
98
 
80
- Set the `isRequired` prop of the wrapping `FormField` to `true` to indicate that the field is
99
+ Set the `required` prop of the wrapping `FormField` to `true` to indicate that the field is
81
100
  required. Labels for required fields are suffixed by a red asterisk.
82
101
 
83
102
  <ExampleCodeBlock code={Required} />
84
103
 
85
104
  ### Disabled
86
105
 
87
- Set the `disabled` prop on **`FormField.Input as={Select.Input}`** to prevent users from interacting
88
- with the combobox.
106
+ Set the `disabled` prop of `Select.Input` to prevent users from interacting with it.
89
107
 
90
108
  <ExampleCodeBlock code={Disabled} />
91
109
 
@@ -111,21 +129,20 @@ sets `aria-disabled` for the disabled items.
111
129
  Use `Select.Item.Icon` to render an icon for a `Select.Item`. The `icon` prop for `Select.Item.Icon`
112
130
  accepts [system icons](/assets/system-icons/) from `@workday/canvas-system-icons-web`.
113
131
 
114
- In order to render the icon for the selected item on **`FormField.Input as={Select.Input}`**:
132
+ In order to render the icon for the selected item in the `Select.Input`:
115
133
 
116
134
  1. Obtain a reference to the `model` by registering your `items` with `useSelectModel`.
117
135
  2. Get the selected item:
118
136
  `const selectedItem = model.navigation.getItem(model.state.selectedIds[0], model)`
119
137
  3. Pass the icon for the selected item to the input:
120
- `<FormField.Input as={Select.Input} inputStartIcon={selectedItem?.value.icon} />`
138
+ `<Select.Input inputStartIcon={selectedItem.value.icon}>`
121
139
 
122
- > **Note:** Dynamic `{item => <Select.Item>}` registration already uses the collection `id`. Set
123
- > **`data-id`** only on static **`Select.Item`** children (see [Grouped Items](#grouped-items)), and
124
- > keep it equal to that id (`id` or **`getId`**).
140
+ > **Note: `data-id` on `Select.Item` must match the `id` property in your array of objects. This
141
+ > ensures proper keyboard handling and type-ahead.**
125
142
 
126
143
  <ExampleCodeBlock code={WithIcons} />
127
144
 
128
- **Note: that `FormField.Input as={Select.Input}` will only render an icon if an item is selected.**
145
+ **Note: that `Select.Input` will only render an icon if an item is selected.**
129
146
 
130
147
  ### Grow
131
148
 
@@ -150,10 +167,23 @@ forward `ref` to its underlying `<input type="text" role="combobox">` element.
150
167
 
151
168
  ### Error States
152
169
 
153
- Form Field provides error and caution states for Select. Set the `error` prop on Form Field to
154
- `"error"` or `"caution"` and use `FormField.Hint` to provide messages. See
155
- [Form Field's Error documentation](/components/inputs/form-field/#error-states) for examples and
156
- accessibility guidance.
170
+ Set the `error` prop of the wrapping `FormField` to `"caution"` or `"error"` to set the `Select` to
171
+ the caution or error state, respectively. You will also need to set the `hintId` and `hintText`
172
+ props on the `FormField` to meet accessibility standards. You must set an `id` attribute on the
173
+ `Select.Input` element that matches the value of `inputId` set on the `FormField` element. These
174
+ attributes ensure that the caution message is associated to the `Select` and read out by voiceover.
175
+
176
+ **Note: The Select container component, `Select`, must wrap `FormField` to ensure `Select.Input` is
177
+ styled correctly.**
178
+
179
+ ```tsx
180
+ <Select items={options}>
181
+ <FormField label="Contact" inputId="contact-id-formfield">
182
+ <Select.Input id="contact-id-formfield" />
183
+ ...
184
+ </FormField>
185
+ </Select>
186
+ ```
157
187
 
158
188
  #### Caution
159
189
 
@@ -175,9 +205,8 @@ You can set `initialSelectedIds` to the value that you want initially selected.
175
205
 
176
206
  ### Placeholder
177
207
 
178
- You can change the placeholder text by passing a string to the `placeholder` prop on
179
- **`FormField.Input as={Select.Input}`**. Placeholder text is not a substitute for
180
- **`FormField.Label`**.
208
+ You can change the placeholder text by passing in a string value to the `placeholder` attribute on
209
+ the `Select.Input`.
181
210
 
182
211
  <ExampleCodeBlock code={Placeholder} />
183
212
 
@@ -203,9 +232,8 @@ to `id` and `text` hence the usage of `getId` and `getTextValue`. If your object
203
232
  <ExampleCodeBlock code={Complex} />
204
233
 
205
234
  **Note: By default, the identifier and text value are `id` and `text` properties respectively. If
206
- your data object for each item is different, provide `getId` and/or `getTextValue`. If a custom
207
- `getId` does not return the display text, also pass `getTextValue` — otherwise the model uses
208
- `getId` for type-ahead and the selected value. For example:**
235
+ your data object for each item is different, provide a `getId` or `getTextValue` function to the
236
+ model config. For example:**
209
237
 
210
238
  ```jsx
211
239
  const items = [
@@ -237,24 +265,20 @@ prop as well as the `value` DOM property and will update the model accordingly.
237
265
  `items`, do not override this function. Instead provide static items via JSX. the list will create
238
266
  an internal array of items where `id` is the only property and the default `getId` will return the
239
267
  desired result. **Note: If your array of objects has a different property for `id`, like
240
- `serverId`, use this function to set the id. If that function does not return the display text,
241
- also pass `getTextValue`.**
268
+ `serverId`, use this function to set the id.**
242
269
 
243
270
  ```tsx
244
271
  const options = [{text: 'Pizza', serverId: 'pizza-1'}, {text: 'Cheeseburger', serverId: 'cheeseburger'}]
245
- <FormField>
246
- <FormField.Label>Your Label</FormField.Label>
247
- <FormField.Field>
248
- <Select items={options} getId={(item) => item.serverId} getTextValue={(item) => item.text}>
249
- <FormField.Input as={Select.Input} onChange={e => handleChange(e)} />
250
- <Select.Popper>
251
- <Select.Card>
252
- <Select.List>{item => <Select.Item>{item.text}</Select.Item>}</Select.List>
253
- </Select.Card>
254
- </Select.Popper>
255
- </Select>
256
- </FormField.Field>
257
- </FormField>
272
+ <Select items={options} getId={(item) => item.serverId}>
273
+ <FormField label="Your Label">
274
+ <Select.Input onChange={e => handleChange(e)} id="contact-select" />
275
+ <Select.Popper>
276
+ <Select.Card>
277
+ <Select.List>{item => <Select.Item>{item.text}</Select.Item>}</Select.List>
278
+ </Select.Card>
279
+ </Select.Popper>
280
+ </FormField>
281
+ </Select>
258
282
  ```
259
283
 
260
284
  - `getTextValue`: Optional function to return the text representation of an item. If not provided,
@@ -265,25 +289,21 @@ prop as well as the `value` DOM property and will update the model accordingly.
265
289
 
266
290
  ```tsx
267
291
  const options = [{label: 'Pizza', id: 'pizza-1'}, {label: 'Cheeseburger', id: 'cheeseburger'}]
268
- <FormField>
269
- <FormField.Label>Your Label</FormField.Label>
270
- <FormField.Field>
271
- <Select items={options} getTextValue={(item) => item.label}>
272
- <FormField.Input as={Select.Input} onChange={e => handleChange(e)} />
273
- <Select.Popper>
274
- <Select.Card>
275
- <Select.List>{item => <Select.Item>{item.label}</Select.Item>}</Select.List>
276
- </Select.Card>
277
- </Select.Popper>
278
- </Select>
279
- </FormField.Field>
280
- </FormField>
292
+ <Select items={options} getTextValue={(item) => item.label}>
293
+ <FormField label="Your Label">
294
+ <Select.Input onChange={e => handleChange(e)} id="contact-select" />
295
+ <Select.Popper>
296
+ <Select.Card>
297
+ <Select.List>{item => <Select.Item>{item.label}</Select.Item>}</Select.List>
298
+ </Select.Card>
299
+ </Select.Popper>
300
+ </FormField>
301
+ </Select>
281
302
  ```
282
303
 
283
304
  ### Grouped Items
284
305
 
285
- In order to group items, use the static item API with **`Menu.Group`** inside **`Select.List`**, and
286
- still pass **`items`** whose ids match each **`Select.Item`** **`data-id`**.
306
+ In order to group items, you have to use the static API in combination of the `Menu.Group` component.
287
307
 
288
308
  <ExampleCodeBlock code={GroupedItems} />
289
309
 
@@ -293,188 +313,6 @@ Select and its subcomponents support custom styling via the `cs` prop. For more
293
313
  our
294
314
  ["How To Customize Styles"](https://workday.github.io/canvas-kit/?path=/docs/styling-guides-customizing-styles--docs).
295
315
 
296
- ## Accessibility
297
-
298
- The primary accessibility goal for `Select` is a visible, persistent label and a single choice from
299
- a known list that assistive technology identifies as a combobox. Use **`Select`** when the user must
300
- pick one option. For multiple selections, use [**MultiSelect**](/docs/preview-multiselect--docs).
301
- For a value outside a fixed list, use [**Combobox**](/features/combobox/). See
302
- [FormField's accessibility documentation](/components/inputs/form-field/#accessibility) for label,
303
- hint, error, and required wiring. This follows the WAI-ARIA
304
- [Select-Only Combobox](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/examples/combobox-select-only/)
305
- pattern.
306
-
307
- ### Minimum Accessible Structure
308
-
309
- Build on the [Basic Example](#basic-example): label first, then **`Select`** inside
310
- **`FormField.Field`**, with the combobox, popup, list, and items in this order.
311
-
312
- ```tsx
313
- import {FormField} from '@workday/canvas-kit-react/form-field';
314
- import {Select} from '@workday/canvas-kit-react/select';
315
-
316
- const options = ['E-mail', 'Phone', 'Fax'];
317
-
318
- <FormField>
319
- <FormField.Label>Contact</FormField.Label>
320
- <FormField.Field>
321
- <Select items={options}>
322
- <FormField.Input as={Select.Input} />
323
- <Select.Popper>
324
- <Select.Card>
325
- <Select.List>{item => <Select.Item>{item}</Select.Item>}</Select.List>
326
- </Select.Card>
327
- </Select.Popper>
328
- </Select>
329
- </FormField.Field>
330
- </FormField>;
331
- ```
332
-
333
- Every `Select` requires **`FormField`**, a visible **`FormField.Label`**, and
334
- **`FormField.Input as={Select.Input}`** so the combobox has a programmatically determinable name,
335
- relationships, and instructions. See
336
- [FormField's accessibility documentation](/components/inputs/form-field/#accessibility) for hint,
337
- error, and required wiring.
338
-
339
- ### Built-in Behaviors
340
-
341
- Canvas Kit applies these automatically when you compose `Select` with `FormField` subcomponents.
342
- **Do not duplicate them** in consuming code.
343
-
344
- **ARIA and DOM** (_applied by subcomponents_):
345
-
346
- - **`Select.Input`**: Visual `<input>` with `role="combobox"`, `aria-haspopup="listbox"`,
347
- `aria-expanded` from menu visibility, `aria-autocomplete="list"` (do not change to `"none"`),
348
- `aria-controls` pointing at the listbox id (`{modelId}-list`), and `aria-activedescendant` while
349
- the list is open (removed when the list is closed). `autoComplete` is `"off"`. Keyboard characters
350
- are not inserted into the input; type-ahead is handled by the model. **`FormField.Label`** (via
351
- **`FormField.Input`**) is the accessible name of the combobox — do not add a second name on the
352
- listbox.
353
- - **Hidden form input**: A second input holds the selected id(s) for form submission. It is
354
- `aria-hidden`, has `tabIndex={-1}`, and is not in the tab order. `onChange` and `name` apply to
355
- this input. Focus and blur on a `ref` are forwarded to the visual combobox.
356
- - **`Select.List`**: `role="listbox"` with an id that matches the combobox `aria-controls`. Options
357
- are not in the tab order; keyboard focus stays on the combobox. Listbox labelling is library-owned
358
- — do not set `aria-labelledby` (or `aria-label`) on **`Select.List`**.
359
- - **`Select.Item`**: `role="option"` and `aria-selected` from selection state. Disabled options need
360
- **`aria-disabled`** from application code (see **Accessibility Requirements**).
361
- - **`Menu.Group`** (when used inside **`Select.List`**): `role="group"` with `aria-labelledby`
362
- referencing the group heading (`title` or **`Menu.Group.Heading`**).
363
- - **`Select.Item.Icon`** and the caret / start icons on **`Select.Input`**: Canvas Kit icons use
364
- `role="presentation"` and `focusable="false"`. Decorative icons need no extra attributes.
365
- - **`disabled` on `Select.Input`**: Maps to the native `disabled` attribute on both inputs; the
366
- combobox is removed from the tab order.
367
- - **`ref`**: Forwards to the visual combobox (`<input type="text" role="combobox">`).
368
-
369
- **Keyboard** (_select-only combobox; focus remains on **`Select.Input`**_):
370
-
371
- - <kbd>Tab</kbd> / <kbd>Shift</kbd>+<kbd>Tab</kbd> move to and from the combobox (native tab order).
372
- Other keys are prevented from editing the input.
373
- - Clicking **`FormField.Label`** moves focus to the combobox. Clicking the combobox opens or closes
374
- the list.
375
- - <kbd>ArrowDown</kbd> / <kbd>ArrowUp</kbd> open the list. While the list is open, those keys move
376
- the active option (skipping ids in **`nonInteractiveIds`**). <kbd>Home</kbd> / <kbd>End</kbd> move
377
- to the first or last option while the list is open.
378
- - <kbd>Space</kbd> opens the list when it is closed and no type-ahead string is in progress. While
379
- the list is open and type-ahead is empty, <kbd>Space</kbd> selects the active option and closes
380
- the list.
381
- - Printable characters type-ahead: with the list closed, matching options are selected; with the
382
- list open, assistive focus moves to the matching option. Consecutive keys within 500ms form a
383
- search string.
384
- - <kbd>Enter</kbd> while the list is open selects the active option (unless **`aria-disabled`**) and
385
- closes the list in single-select mode. It does not submit the form while the list is open.
386
- - <kbd>Escape</kbd> closes the list. Blur also hides the list. After close, `aria-activedescendant`
387
- is removed; the active option returns to the selected item when one is selected.
388
- - Activating an option with the pointer keeps focus on the combobox and closes the list.
389
-
390
- **Screen reader expectations** (_when built-in behaviors are used as intended_):
391
-
392
- - On focus, assistive technology announces the field label and, when applicable: required state,
393
- invalid state (`error="error"`), hint or error text via `aria-describedby`, and the current
394
- selected text (or the placeholder when nothing is selected).
395
- - The control is announced as a combobox. Collapsed vs expanded follows `aria-expanded`. While the
396
- list is open, the active option is exposed through `aria-activedescendant`.
397
- - Options are announced with selected or not-selected state (`aria-selected`). Disabled options are
398
- announced as disabled when **`aria-disabled`** is set.
399
- - The Caution state is visual only — `aria-invalid` is **not** set for `error="caution"`.
400
- - Disabled comboboxes may be announced as unavailable and are skipped in the tab order.
401
- - The hidden form input and decorative icons are not announced.
402
-
403
- For rendered label, input, and hint association markup, see the DOM examples in
404
- [FormField's Built-in Behaviors](/components/inputs/form-field/#built-in-behaviors).
405
-
406
- ### Accessibility Requirements
407
-
408
- Required in application code for an accessible `Select`. Rows marked _(conditional)_ apply only when
409
- the situation matches—otherwise omit.
410
-
411
- **If no design spec is provided:** use a visible `FormField.Label`, wrap **`Select`** with
412
- **`FormField`**, use **`FormField.Input as={Select.Input}`**, include **`Select.Popper`**,
413
- **`Select.Card`**, **`Select.List`**, and **`Select.Item`**, and pass **`items`**. Omit `isHidden`,
414
- omit a custom `id` unless testing or composition requires it, omit a `ref` unless programmatic focus
415
- is required, omit **`disabled`**, **`nonInteractiveIds`**, icons, grouped list items, and a custom
416
- **`placeholder`** unless the spec includes them.
417
-
418
- **Programmatic focus** _(conditional — omit by default)_:
419
-
420
- Use a ref when the product needs to move focus to the combobox after an action. Do not attach a
421
- `ref` or call `focus()` unless the design or developer asks for it. See
422
- [Ref Forwarding](#ref-forwarding) under Usage for a complete Storybook example (imports, `ref` on
423
- **`FormField.Input as={Select.Input}`**, and a button that calls `focus()`).
424
-
425
- **Disabled options** _(conditional)_:
426
-
427
- When an option is unavailable, set **`nonInteractiveIds`** on **`Select`** and **`aria-disabled`**
428
- on those **`Select.Item`**s. See [Disabled Items](#disabled-items) under Usage for a complete
429
- Storybook example. Do not use styling alone.
430
-
431
- | Requirement | How to satisfy |
432
- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
433
- | Input wiring | **`FormField.Input as={Select.Input}`** for the combobox, with **`Select.Popper`**, **`Select.Card`**, **`Select.List`**, and **`Select.Item`**. See [FormField accessibility](/components/inputs/form-field/#accessibility) for label, hint, error, and required wiring |
434
- | Disabled combobox _(conditional)_ | `disabled` on **`FormField.Input as={Select.Input}`**. See [Disabled](#disabled) |
435
- | Disabled options _(conditional)_ | **`nonInteractiveIds`** on **`Select`** (ids skipped by keyboard and type-ahead) **and** **`aria-disabled`** on those **`Select.Item`**s. See [Disabled Items](#disabled-items) |
436
- | Grouped list items _(conditional)_ | Keep **`items`**. Inside **`Select.List`**, render static **`Menu.Group`** (`title` or **`Menu.Group.Heading`**) and **`Select.Item`**s with matching **`data-id`** — not `{item => …}`. See [Grouped Items](#grouped-items) |
437
- | Option icons _(conditional)_ | **`Select.Item.Icon`** on each item; **`inputStartIcon`** on **`FormField.Input as={Select.Input}`** for the selected item. Decorative icons need no extra attributes; meaning beyond the label must be text |
438
- | Custom placeholder _(conditional)_ | `placeholder` on **`FormField.Input as={Select.Input}`** only as short prompt text—never as the only name. Default is `"Choose an option"` |
439
- | Programmatic focus _(conditional)_ | `ref` on **`FormField.Input as={Select.Input}`** and call `focus()` when moving focus to the field after an action—omit by default (see **Programmatic focus** above) |
440
-
441
- **Summary for code generation:**
442
-
443
- - **REQUIRED:** visible label, **`FormField.Input as={Select.Input}`**, popup list composition
444
- (**`Select.Popper`**, **`Select.Card`**, **`Select.List`**, **`Select.Item`**), **`items`**.
445
- Default list rendering is `{item => <Select.Item>{item}</Select.Item>}` (or `item.text` /
446
- **`getTextValue`**).
447
- - **CONDITIONAL:** disabled combobox, disabled options (`nonInteractiveIds` + `aria-disabled`),
448
- grouped list items (**`items`** plus static **`Menu.Group`** / **`data-id`** children — do not
449
- omit **`items`**), option icons, custom placeholder, programmatic focus via `ref`, **`getId`** and
450
- **`getTextValue`** when item shape is not `{id, text}` (always pass **`getTextValue`** if custom
451
- **`getId`** is not the display text), **`data-id`** on static JSX **`Select.Item`**s. See
452
- [FormField accessibility](/components/inputs/form-field/#accessibility) for shared FormField
453
- conditionals (hint/error, required, stable `id`).
454
-
455
- ### Anti-Patterns
456
-
457
- Do **not** generate code that does the following (see **Accessibility Requirements** above for what
458
- to supply instead):
459
-
460
- - **Missing `FormField` wiring**: Do not use `Select` without **`FormField`** and
461
- **`FormField.Label`**, and do not render a bare **`Select.Input`** when a **`FormField`** is
462
- present. Use **`FormField.Input as={Select.Input}`** (see **Minimum accessible structure**). For
463
- shared FormField anti-patterns (manual ARIA, placeholder-only labels, color-only errors, broken ID
464
- references), see [FormField Anti-Patterns](/components/inputs/form-field/#anti-patterns).
465
- - **Duplicating combobox or listbox ARIA**: Do not set `role`, `aria-haspopup`, `aria-expanded`,
466
- `aria-autocomplete` (including `"none"`), `aria-controls`, `aria-activedescendant`,
467
- `autoComplete`, or listbox `role` / `id` / `aria-labelledby` / `aria-label`. Do not make
468
- **`Select.Item`** focusable — the active option is **`aria-activedescendant`** on the combobox.
469
- - **Wrong component**: Do not use a native `<select>`, **`Menu`**, **`Combobox`**, **`TextInput`**,
470
- or **`FormFieldGroup`** for a single submitted list value. Use
471
- [**MultiSelect**](/docs/preview-multiselect--docs) when more than one option can be selected.
472
- - **Item identity / grouping**: Do not set **`data-id`** on `{item => <Select.Item>}`. Do not omit
473
- **`items`** when grouping, and do not group with a render callback alone — use **`Menu.Group`**
474
- and **`data-id`** (see **Static item ids** and **Grouped list items**).
475
- - **Free-text keyboard on the combobox**: Do not add `onKeyDown` that types into the input or calls
476
- `preventDefault` on <kbd>Tab</kbd> — Select is select-only.
477
-
478
316
  ## Component API
479
317
 
480
318
  <SymbolDoc name="Select" fileName="/react/" />
@@ -24,30 +24,36 @@ const items = [
24
24
  ];
25
25
 
26
26
  export default () => {
27
+ const [selected, setSelected] = React.useState('');
28
+
27
29
  return (
28
- <FormField>
29
- <FormField.Label>Contact</FormField.Label>
30
- <FormField.Field>
31
- <Select items={items} getId={item => item.id} getTextValue={item => item.text}>
32
- <FormField.Input as={Select.Input} />
33
- <Select.Popper>
34
- <Select.Card>
35
- <Select.List>
36
- <Menu.Group title="First Group">
37
- <Select.Item data-id="first">First Item</Select.Item>
38
- <Select.Item data-id="second">Second Item</Select.Item>
39
- </Menu.Group>
40
- <Menu.Group title="Second Group">
41
- <Select.Item data-id="third">
42
- Third Item (with a really, really, really long label)
43
- </Select.Item>
44
- <Select.Item data-id="fourth">Fourth Item</Select.Item>
45
- </Menu.Group>
46
- </Select.List>
47
- </Select.Card>
48
- </Select.Popper>
49
- </Select>
50
- </FormField.Field>
51
- </FormField>
30
+ <>
31
+ <FormField>
32
+ <FormField.Label>Contact</FormField.Label>
33
+ <FormField.Field>
34
+ <Select items={items} getId={item => item.id} getTextValue={item => item.text}>
35
+ <FormField.Input as={Select.Input} />
36
+ <Select.Popper>
37
+ <Select.Card>
38
+ <Select.List>
39
+ <Menu.Group title="First Group">
40
+ <Select.Item data-id="first">First Item</Select.Item>
41
+ <Select.Item data-id="second">Second Item</Select.Item>
42
+ </Menu.Group>
43
+ <Menu.Group title="Second Group">
44
+ <Select.Item data-id="third">
45
+ Third Item (with a really, really, really long label)
46
+ </Select.Item>
47
+ <Select.Item aria-disabled data-id="fourth">
48
+ Fourth Item
49
+ </Select.Item>
50
+ </Menu.Group>
51
+ </Select.List>
52
+ </Select.Card>
53
+ </Select.Popper>
54
+ </Select>
55
+ </FormField.Field>
56
+ </FormField>
57
+ </>
52
58
  );
53
59
  };
@@ -43,7 +43,7 @@ export default () => {
43
43
  {model.state.items.length > 0 && (
44
44
  <Select.List>
45
45
  {item => (
46
- <Select.Item>
46
+ <Select.Item data-id={item.id}>
47
47
  <Select.Item.Icon icon={item.icon} />
48
48
  {item.text}
49
49
  </Select.Item>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@workday/canvas-kit-docs",
3
- "version": "16.1.4",
3
+ "version": "16.2.0-0612-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",
@@ -47,10 +47,10 @@
47
47
  "@stackblitz/sdk": "^1.11.0",
48
48
  "@storybook/csf": "0.0.1",
49
49
  "@workday/canvas-expressive-icons-web": "1.0.2",
50
- "@workday/canvas-kit-labs-react": "^16.1.4",
51
- "@workday/canvas-kit-preview-react": "^16.1.4",
52
- "@workday/canvas-kit-react": "^16.1.4",
53
- "@workday/canvas-kit-styling": "^16.1.4",
50
+ "@workday/canvas-kit-labs-react": "^16.2.0-0612-next.0",
51
+ "@workday/canvas-kit-preview-react": "^16.2.0-0612-next.0",
52
+ "@workday/canvas-kit-react": "^16.2.0-0612-next.0",
53
+ "@workday/canvas-kit-styling": "^16.2.0-0612-next.0",
54
54
  "@workday/canvas-system-icons-web": "^5.0.3",
55
55
  "@workday/canvas-tokens-web": "^4.4.0",
56
56
  "markdown-to-jsx": "^7.2.0",
@@ -63,5 +63,5 @@
63
63
  "mkdirp": "^1.0.3",
64
64
  "typescript": "5.0"
65
65
  },
66
- "gitHead": "431b7a4d30f20e2b836e1db1a7edcab005308f30"
66
+ "gitHead": "11919e5ffbe1b947f0e5d156e1efc91dfeffd259"
67
67
  }