@workday/canvas-kit-docs 5.3.0-next.10 → 5.3.0-next.24
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/LICENSE +1 -1
- package/dist/commonjs/lib/specs.js +295 -33
- package/dist/es6/lib/specs.js +295 -33
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +265 -1
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +31 -30
- package/dist/mdx/CONTRIBUTING.mdx +90 -63
- package/dist/mdx/preview-react/breadcrumbs/Breadcrumbs.mdx +1 -1
- package/dist/mdx/preview-react/form-field/FormField.mdx +27 -0
- package/dist/mdx/preview-react/form-field/examples/Custom.tsx +57 -0
- package/dist/mdx/preview-react/menu/examples/Icons.tsx +1 -1
- package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +1 -1
- package/dist/mdx/preview-react/text-area/TextArea.mdx +122 -0
- package/dist/mdx/preview-react/text-area/examples/Alert.tsx +31 -0
- package/dist/mdx/preview-react/text-area/examples/Basic.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Disabled.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Error.tsx +40 -0
- package/dist/mdx/preview-react/text-area/examples/Grow.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +20 -0
- package/dist/mdx/preview-react/text-area/examples/LabelPositionHorizontal.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/LabelPositionVertical.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/Placeholder.tsx +21 -0
- package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +28 -0
- package/dist/mdx/preview-react/text-area/examples/Required.tsx +17 -0
- package/dist/mdx/preview-react/text-area/examples/ResizeConstraints.tsx +22 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/TextInput.mdx +40 -18
- package/dist/mdx/preview-react/text-input/examples/Alert.tsx +40 -0
- package/dist/mdx/{labs-react/text-input/examples/HiddenLabel.tsx → preview-react/text-input/examples/Basic.tsx} +3 -3
- package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/Error.tsx +6 -9
- package/dist/mdx/preview-react/text-input/examples/Grow.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +20 -0
- package/dist/mdx/preview-react/text-input/examples/LabelPositionHorizontal.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/LabelPositionVertical.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/LoginForm.tsx +10 -5
- package/dist/mdx/preview-react/text-input/examples/Password.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Placeholder.tsx +17 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/RefForwarding.tsx +7 -6
- package/dist/mdx/preview-react/text-input/examples/Required.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +46 -0
- package/dist/mdx/{labs-react → preview-react}/text-input/examples/ThemedError.tsx +8 -11
- package/dist/mdx/react/_examples/GlobalHeader.mdx +9 -0
- package/dist/mdx/react/_examples/PageHeader.mdx +8 -0
- package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +66 -0
- package/dist/mdx/react/_examples/examples/PageHeader.tsx +63 -0
- package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
- package/dist/mdx/react/button/button/Button.mdx +34 -9
- package/dist/mdx/react/button/button/examples/Primary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +14 -0
- package/dist/mdx/react/button/button/examples/Secondary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +14 -0
- package/dist/mdx/react/button/button/examples/Tertiary.tsx +10 -1
- package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +14 -0
- package/dist/mdx/react/button/icon-button/IconButton.mdx +1 -1
- package/dist/mdx/react/loading-animation/LoadingAnimation.mdx +5 -0
- package/dist/mdx/react/loading-animation/examples/RTL.tsx +16 -0
- package/dist/mdx/react/pagination/PropTables.splitprops.tsx +47 -0
- package/dist/mdx/react/pagination/examples/{StepControls.tsx → Basic.tsx} +1 -1
- package/dist/mdx/react/pagination/examples/GoToForm.tsx +1 -1
- package/dist/mdx/react/pagination/examples/HoistedModel.tsx +36 -22
- package/dist/mdx/react/pagination/examples/RTL.tsx +1 -1
- package/dist/mdx/react/pagination/pagination.mdx +225 -474
- package/dist/mdx/react/popup/Popup.mdx +34 -36
- package/dist/mdx/react/radio/examples/Alert.tsx +3 -3
- package/dist/mdx/react/radio/examples/Basic.tsx +3 -3
- package/dist/mdx/react/radio/examples/Disabled.tsx +3 -3
- package/dist/mdx/react/radio/examples/Error.tsx +3 -3
- package/dist/mdx/react/radio/examples/LabelPosition.tsx +3 -3
- package/dist/mdx/react/radio/examples/NoValue.tsx +3 -3
- package/dist/mdx/react/radio/examples/RefForwarding.tsx +3 -3
- package/dist/mdx/react/radio/examples/Required.tsx +3 -3
- package/dist/mdx/react/segmented-control/SegmentedControl.mdx +1 -1
- package/dist/mdx/react/tabs/Tabs.mdx +67 -36
- package/dist/mdx/react/tabs/examples/DisabledTab.tsx +1 -1
- package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +41 -13
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +4 -4
- package/dist/mdx/react/tabs/examples/Icons.tsx +36 -0
- package/dist/mdx/react/tabs/examples/{NamedKeys.tsx → NamedTabs.tsx} +0 -0
- package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +58 -0
- package/dist/mdx/react/tabs/examples/SinglePanel.tsx +1 -1
- package/dist/mdx/react/toast/toast.mdx +1 -17
- package/dist/mdx/react/tooltip/Tooltip.mdx +9 -1
- package/dist/mdx/react/tooltip/examples/DelayedTooltip.tsx +16 -0
- package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +6 -0
- package/package.json +5 -4
- package/dist/mdx/CODE_OF_CONDUCT.md +0 -68
- package/dist/mdx/labs-react/text-input/examples/Alert.tsx +0 -46
- package/dist/mdx/labs-react/text-input/examples/Basic.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Disabled.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Grow.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/LabelPosition.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Password.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Placeholder.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/Required.tsx +0 -20
- package/dist/mdx/labs-react/text-input/examples/ThemedAlert.tsx +0 -51
- package/dist/mdx/react/pagination/examples/ShowAdditionalDetails.tsx +0 -52
|
@@ -52,7 +52,7 @@ The `Popup` component is a generic
|
|
|
52
52
|
[Compound Component](/getting-started/for-developers/resources/compound-components/) that is used to
|
|
53
53
|
build popup UIs that are not already covered by Canvas Kit.
|
|
54
54
|
|
|
55
|
-
### Basic
|
|
55
|
+
### Basic Example
|
|
56
56
|
|
|
57
57
|
The Popup has no pre-defined behaviors built in, therefore the `usePopupModel` must always be used
|
|
58
58
|
to create a new `model`. This `model` is then used by all behavior hooks to apply additional popup
|
|
@@ -63,7 +63,7 @@ popup behaviors. For accessibility, these behaviors should be included most of t
|
|
|
63
63
|
|
|
64
64
|
<ExampleCodeBlock code={Basic} />
|
|
65
65
|
|
|
66
|
-
### Initial
|
|
66
|
+
### Initial Focus
|
|
67
67
|
|
|
68
68
|
If you want focus to move to a specific element when the popup is opened, set the `initialFocusRef`
|
|
69
69
|
of the model. Check with accessibility before doing this. The following example sets the focus on
|
|
@@ -153,7 +153,7 @@ The Popup component automatically handles right-to-left rendering.
|
|
|
153
153
|
|
|
154
154
|
## Components
|
|
155
155
|
|
|
156
|
-
|
|
156
|
+
### Popper
|
|
157
157
|
|
|
158
158
|
A thin wrapper component around the Popper.js positioning engine. For reference:
|
|
159
159
|
https://popper.js.org/. `Popper` also automatically works with the `PopupStack` system. `Popper` has
|
|
@@ -169,7 +169,7 @@ PopupModel or any associate popup [hooks](#hooks).
|
|
|
169
169
|
> element was rendered and that's where extra props were spread to. In v5+, you can provide your own
|
|
170
170
|
> element if you wish.
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
### Popup
|
|
173
173
|
|
|
174
174
|
This component is a container component that has no semantic element. It provides a React Context
|
|
175
175
|
model for all Popup subcomponents. If you manually pass a `model` to all subcomponents, this
|
|
@@ -189,7 +189,7 @@ container component isn't needed.
|
|
|
189
189
|
|
|
190
190
|
<ArgsTable of={Popup} />
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
### Popup.Target
|
|
193
193
|
|
|
194
194
|
A `Popup.Target` is any element that is meant to show the Popup. The default component rendered by
|
|
195
195
|
this component is a `SecondaryButton` element. You can override this by passing the desired
|
|
@@ -217,7 +217,7 @@ used, which is `SecondaryButton`. If you don't want any styling, you can do the
|
|
|
217
217
|
To add your own styling, you could either add a `css` prop, or make a styled button and pass that
|
|
218
218
|
styled component via the `as` prop.
|
|
219
219
|
|
|
220
|
-
|
|
220
|
+
### Popup.Popper
|
|
221
221
|
|
|
222
222
|
A `Popup.Popper` is a [Popper](#popper) component that is hooked up to the `PopupModel`
|
|
223
223
|
automatically. The behavior hook used is called `usePopupPopper`.
|
|
@@ -229,7 +229,7 @@ automatically. The behavior hook used is called `usePopupPopper`.
|
|
|
229
229
|
|
|
230
230
|
<ArgsTable of={Popup.Popper} />
|
|
231
231
|
|
|
232
|
-
|
|
232
|
+
### Popup.Card
|
|
233
233
|
|
|
234
234
|
A `Popup.Card` is a wrapper around the `Card` component, but hooked up to a `PopupModel`. By
|
|
235
235
|
default, this element has a `role=dialog` and an `aria-labelledby`. The behavior hook used is called
|
|
@@ -237,7 +237,7 @@ default, this element has a `role=dialog` and an `aria-labelledby`. The behavior
|
|
|
237
237
|
|
|
238
238
|
<ArgsTable of={Popup.Card} />
|
|
239
239
|
|
|
240
|
-
|
|
240
|
+
### Popup.CloseButton
|
|
241
241
|
|
|
242
242
|
A `Popup.CloseButton` is a button that will hide a popup. By default, this is a `SecondaryButton`
|
|
243
243
|
component, but `as` can be used to render any button element (i.e `<DeleteButton>` or
|
|
@@ -245,14 +245,14 @@ component, but `as` can be used to render any button element (i.e `<DeleteButton
|
|
|
245
245
|
|
|
246
246
|
<ArgsTable of={Popup.CloseButton} />
|
|
247
247
|
|
|
248
|
-
|
|
248
|
+
### Popup.CloseIcon
|
|
249
249
|
|
|
250
250
|
A `Popup.CloseIcon` is an icon button that is the `X` in the top of a popup. It will hide a popup
|
|
251
251
|
when clicked. The behavior hook used is called `usePopupCloseButton`.
|
|
252
252
|
|
|
253
253
|
<ArgsTable of={Popup.CloseIcon} />
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
### Popup.Heading
|
|
256
256
|
|
|
257
257
|
A `Popup.Heading` is a wrapper around `Card.Heading` that connect the heading to a `PopupModel`. It
|
|
258
258
|
will add an `id` to the element that match the `aria-labelledby` that is applied to the `Popup.Card`
|
|
@@ -260,29 +260,29 @@ element for accessibility. The behavior hook used is called `usePopupHeading`.
|
|
|
260
260
|
|
|
261
261
|
<ArgsTable of={Popup.Heading} />
|
|
262
262
|
|
|
263
|
-
|
|
263
|
+
### Popup.Body
|
|
264
264
|
|
|
265
265
|
A `Popup.Body` is a thin wrapper around `Card.Body` and doesn't actually take a model. It adds
|
|
266
266
|
`body` styling and nothing else.
|
|
267
267
|
|
|
268
268
|
<ArgsTable of={Popup.Body} />
|
|
269
269
|
|
|
270
|
-
##
|
|
270
|
+
## Model
|
|
271
271
|
|
|
272
272
|
The PopupModel contains all state and events needed for Popup behaviors and components. It composes
|
|
273
273
|
a `DisclosureModel` for showing and hiding content.
|
|
274
274
|
|
|
275
|
-
###
|
|
275
|
+
### Config
|
|
276
276
|
|
|
277
|
-
<ArgsTable of={
|
|
277
|
+
<ArgsTable of={PopupModelConfigComponent} />
|
|
278
278
|
|
|
279
|
-
###
|
|
279
|
+
### State
|
|
280
280
|
|
|
281
|
-
<ArgsTable of={
|
|
281
|
+
<ArgsTable of={PopupStateComponent} />
|
|
282
282
|
|
|
283
|
-
###
|
|
283
|
+
### Events
|
|
284
284
|
|
|
285
|
-
<ArgsTable of={
|
|
285
|
+
<ArgsTable of={PopupEventsComponent} />
|
|
286
286
|
|
|
287
287
|
## Hooks
|
|
288
288
|
|
|
@@ -325,7 +325,7 @@ return (
|
|
|
325
325
|
);
|
|
326
326
|
```
|
|
327
327
|
|
|
328
|
-
|
|
328
|
+
### useAssistiveHideSiblings
|
|
329
329
|
|
|
330
330
|
```ts
|
|
331
331
|
useAssistiveHideSiblings(model: PopupModel): {}
|
|
@@ -341,7 +341,7 @@ VoiceOver for example.
|
|
|
341
341
|
|
|
342
342
|
This should be used on popup elements that need to hide content (i.e. Modals).
|
|
343
343
|
|
|
344
|
-
|
|
344
|
+
### useBringToTopOnClick
|
|
345
345
|
|
|
346
346
|
```ts
|
|
347
347
|
useBringToTopOnClick(model: PopupModel): {}
|
|
@@ -355,7 +355,7 @@ like a Modal.
|
|
|
355
355
|
|
|
356
356
|
This should be used on popup elements that are meant to persist (i.e. Windows).
|
|
357
357
|
|
|
358
|
-
|
|
358
|
+
### useCloseOnEscape
|
|
359
359
|
|
|
360
360
|
```ts
|
|
361
361
|
useCloseOnEscape(model: PopupModel): {}
|
|
@@ -367,7 +367,7 @@ provided model's `state.stackRef` element is the topmost in the stack.
|
|
|
367
367
|
This should be used with popup elements that are dismissible like Tooltips, Modals, non-modal
|
|
368
368
|
dialogs, dropdown menus, etc.
|
|
369
369
|
|
|
370
|
-
|
|
370
|
+
### useCloseOnOutsideClick
|
|
371
371
|
|
|
372
372
|
```ts
|
|
373
373
|
useCloseOnOutsideClick(model: PopupModel): {}
|
|
@@ -382,7 +382,7 @@ This should be used with popup elements that are dismissible like Modals, non-mo
|
|
|
382
382
|
dropdown menus, etc. Tooltips and hierarchical menus should use `useAlwaysCloseOnClickOutside`
|
|
383
383
|
instead.
|
|
384
384
|
|
|
385
|
-
|
|
385
|
+
### useAlwaysCloseOnOutsideClick
|
|
386
386
|
|
|
387
387
|
```ts
|
|
388
388
|
useAlwaysCloseOnOutsideClick(model: PopupModel): {}
|
|
@@ -396,7 +396,7 @@ stack. This is useful for Tooltips or hierarchical menus. Adds a
|
|
|
396
396
|
This should be used with popup elements that should close no matter their position in the stack
|
|
397
397
|
(i.e. Tooltips).
|
|
398
398
|
|
|
399
|
-
|
|
399
|
+
### useDisableBodyScroll
|
|
400
400
|
|
|
401
401
|
```ts
|
|
402
402
|
useDisableBodyScroll(model: PopupModel): {}
|
|
@@ -408,7 +408,7 @@ page scrolling while the popup is visible.
|
|
|
408
408
|
This should be used with popup elements that hide all other content and force the user to accept or
|
|
409
409
|
dismiss the popup before continuing (i.e. Modals).
|
|
410
410
|
|
|
411
|
-
|
|
411
|
+
### useFocusRedirect
|
|
412
412
|
|
|
413
413
|
```ts
|
|
414
414
|
useFocusRedirect(model: PopupModel): {}
|
|
@@ -426,7 +426,7 @@ hook does no provide `aria-owns` and this must be provided yourself. Requires
|
|
|
426
426
|
|
|
427
427
|
This should be used with non-modal dialogs.
|
|
428
428
|
|
|
429
|
-
|
|
429
|
+
### useFocusTrap
|
|
430
430
|
|
|
431
431
|
```ts
|
|
432
432
|
useFocusTrap(model: PopupModel): {}
|
|
@@ -440,7 +440,7 @@ with [useInitialFocus](#useinitialfocus) and [useReturnFocus](#usereturnfocus).
|
|
|
440
440
|
|
|
441
441
|
This should be used on popup elements that need to hide content (i.e. Modals).
|
|
442
442
|
|
|
443
|
-
|
|
443
|
+
### useInitialFocus
|
|
444
444
|
|
|
445
445
|
Moves focus within the popup when the popup becomes visible. This is useful for keyboard and screen
|
|
446
446
|
reader users alike. This should be used with [useFocusRedirect](#usefocusredirect) or
|
|
@@ -449,7 +449,7 @@ reader users alike. This should be used with [useFocusRedirect](#usefocusredirec
|
|
|
449
449
|
This should be used for popups that have focusable elements inside, like Modals, non-modal dialogs,
|
|
450
450
|
menus, etc.
|
|
451
451
|
|
|
452
|
-
|
|
452
|
+
### useReturnFocus
|
|
453
453
|
|
|
454
454
|
Returns focus to the target element when the popup is hidden. This works well with
|
|
455
455
|
[useInitialFocus](#useinitialfocus). This should be used with [useFocusRedirect](#usefocusredirect)
|
|
@@ -457,7 +457,7 @@ or [useFocusTrap](#usefocustrap) for a complete focus management solution.
|
|
|
457
457
|
|
|
458
458
|
This should ble used on popup elements that use [useInitialFocus](#useinitialfocus).
|
|
459
459
|
|
|
460
|
-
|
|
460
|
+
### usePopupPopper
|
|
461
461
|
|
|
462
462
|
```ts
|
|
463
463
|
usePopupPopper(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -466,7 +466,7 @@ usePopupPopper(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
|
466
466
|
Adds the necessary props to a `Popper` component. Used by the [Popup.Popper](#popuppopper)
|
|
467
467
|
subcomponent.
|
|
468
468
|
|
|
469
|
-
|
|
469
|
+
### usePopupCard
|
|
470
470
|
|
|
471
471
|
```ts
|
|
472
472
|
usePopupCard(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -474,7 +474,7 @@ usePopupCard(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
|
474
474
|
|
|
475
475
|
Adds the necessary props to a `Card` component. Used by the [Popup.Card](#popupcard) subcomponent.
|
|
476
476
|
|
|
477
|
-
|
|
477
|
+
### usePopupCloseButton
|
|
478
478
|
|
|
479
479
|
```ts
|
|
480
480
|
usePopupCloseButton(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -484,18 +484,16 @@ Adds the necessary props to a close button component. Used by the
|
|
|
484
484
|
[Popup.CloseButton](#popupclosebutton) subcomponent and [Popup.CloseIcon](#popupcloseicon)
|
|
485
485
|
subcomponent.
|
|
486
486
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
## usePopupHeading
|
|
487
|
+
### usePopupHeading
|
|
490
488
|
|
|
491
489
|
```ts
|
|
492
490
|
usePopupHeading(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
493
|
-
|
|
491
|
+
```
|
|
494
492
|
|
|
495
493
|
Adds the necessary props to a `Heading` component. Used by the [Popup.Heading](#popupheading)
|
|
496
494
|
subcomponent.
|
|
497
495
|
|
|
498
|
-
|
|
496
|
+
### usePopupTarget
|
|
499
497
|
|
|
500
498
|
```ts
|
|
501
499
|
usePopupTarget(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -14,13 +14,13 @@ export default () => {
|
|
|
14
14
|
error={FormField.ErrorType.Alert}
|
|
15
15
|
hintId="hint-alert"
|
|
16
16
|
hintText="Deep Dish is no longer available. Please select a different crust."
|
|
17
|
-
label="Choose
|
|
17
|
+
label="Choose Your Pizza Crust"
|
|
18
18
|
useFieldset={true}
|
|
19
19
|
>
|
|
20
20
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
21
|
-
<Radio disabled={true} label="Deep
|
|
21
|
+
<Radio disabled={true} label="Deep dish (sold out)" value="deep-dish" />
|
|
22
22
|
<Radio label="Thin" value="thin" />
|
|
23
|
-
<Radio label="Gluten
|
|
23
|
+
<Radio label="Gluten free" value="gluten-free" />
|
|
24
24
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
25
25
|
</RadioGroup>
|
|
26
26
|
</FormField>
|
|
@@ -10,11 +10,11 @@ export default () => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<FormField label="Choose
|
|
13
|
+
<FormField label="Choose Your Pizza Crust" useFieldset={true}>
|
|
14
14
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
15
|
-
<Radio label="Deep
|
|
15
|
+
<Radio label="Deep dish" value="deep-dish" />
|
|
16
16
|
<Radio label="Thin" value="thin" />
|
|
17
|
-
<Radio label="Gluten
|
|
17
|
+
<Radio label="Gluten free" value="gluten-free" />
|
|
18
18
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
19
19
|
</RadioGroup>
|
|
20
20
|
</FormField>
|
|
@@ -10,11 +10,11 @@ export default () => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<FormField label="Choose
|
|
13
|
+
<FormField label="Choose Your Pizza Crust" useFieldset={true}>
|
|
14
14
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
15
|
-
<Radio label="Deep
|
|
15
|
+
<Radio label="Deep dish" value="deep-dish" />
|
|
16
16
|
<Radio label="Thin" value="thin" />
|
|
17
|
-
<Radio disabled={true} label="Gluten
|
|
17
|
+
<Radio disabled={true} label="Gluten free (sold out)" value="gluten-free" />
|
|
18
18
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
19
19
|
</RadioGroup>
|
|
20
20
|
</FormField>
|
|
@@ -14,13 +14,13 @@ export default () => {
|
|
|
14
14
|
error={FormField.ErrorType.Error}
|
|
15
15
|
hintId="hint-error"
|
|
16
16
|
hintText="Deep Dish is no longer available. Please select a different crust."
|
|
17
|
-
label="Choose
|
|
17
|
+
label="Choose Your Pizza Crust"
|
|
18
18
|
useFieldset={true}
|
|
19
19
|
>
|
|
20
20
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
21
|
-
<Radio disabled={true} label="Deep
|
|
21
|
+
<Radio disabled={true} label="Deep dish (sold out)" value="deep-dish" />
|
|
22
22
|
<Radio label="Thin" value="thin" />
|
|
23
|
-
<Radio label="Gluten
|
|
23
|
+
<Radio label="Gluten free" value="gluten-free" />
|
|
24
24
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
25
25
|
</RadioGroup>
|
|
26
26
|
</FormField>
|
|
@@ -11,14 +11,14 @@ export default () => {
|
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
13
|
<FormField
|
|
14
|
-
label="Choose
|
|
14
|
+
label="Choose Your Pizza Crust"
|
|
15
15
|
labelPosition={FormField.LabelPosition.Left}
|
|
16
16
|
useFieldset={true}
|
|
17
17
|
>
|
|
18
18
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
19
|
-
<Radio label="Deep
|
|
19
|
+
<Radio label="Deep dish" value="deep-dish" />
|
|
20
20
|
<Radio label="Thin" value="thin" />
|
|
21
|
-
<Radio label="Gluten
|
|
21
|
+
<Radio label="Gluten free" value="gluten-free" />
|
|
22
22
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
23
23
|
</RadioGroup>
|
|
24
24
|
</FormField>
|
|
@@ -12,11 +12,11 @@ export default () => {
|
|
|
12
12
|
|
|
13
13
|
return (
|
|
14
14
|
<>
|
|
15
|
-
<FormField label="Choose
|
|
15
|
+
<FormField label="Choose Your Pizza Crust" useFieldset={true}>
|
|
16
16
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
17
|
-
<Radio label="Deep
|
|
17
|
+
<Radio label="Deep dish" />
|
|
18
18
|
<Radio label="Thin" />
|
|
19
|
-
<Radio label="Gluten
|
|
19
|
+
<Radio label="Gluten free" />
|
|
20
20
|
<Radio label="Cauliflower" />
|
|
21
21
|
</RadioGroup>
|
|
22
22
|
</FormField>
|
|
@@ -17,11 +17,11 @@ export default () => {
|
|
|
17
17
|
|
|
18
18
|
return (
|
|
19
19
|
<>
|
|
20
|
-
<FormField label="Choose
|
|
20
|
+
<FormField label="Choose Your Pizza Crust" useFieldset={true}>
|
|
21
21
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
22
|
-
<Radio label="Deep
|
|
22
|
+
<Radio label="Deep dish" value="deep-dish" />
|
|
23
23
|
<Radio label="Thin" value="thin" />
|
|
24
|
-
<Radio label="Gluten
|
|
24
|
+
<Radio label="Gluten free" ref={glutenFreeRef} value="gluten-free" />
|
|
25
25
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
26
26
|
</RadioGroup>
|
|
27
27
|
</FormField>
|
|
@@ -10,11 +10,11 @@ export default () => {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
return (
|
|
13
|
-
<FormField label="Choose
|
|
13
|
+
<FormField label="Choose Your Pizza Crust" required={true} useFieldset={true}>
|
|
14
14
|
<RadioGroup name="crust" onChange={handleChange} value={value}>
|
|
15
|
-
<Radio label="Deep
|
|
15
|
+
<Radio label="Deep dish" value="deep-dish" />
|
|
16
16
|
<Radio label="Thin" value="thin" />
|
|
17
|
-
<Radio label="Gluten
|
|
17
|
+
<Radio label="Gluten free" value="gluten-free" />
|
|
18
18
|
<Radio label="Cauliflower" value="cauliflower" />
|
|
19
19
|
</RadioGroup>
|
|
20
20
|
</FormField>
|
|
@@ -27,6 +27,6 @@ indexes and omit the `value` field. It is strongly recommended to not mix these
|
|
|
27
27
|
|
|
28
28
|
## Props
|
|
29
29
|
|
|
30
|
-
Undocumented props are spread to the underlying container
|
|
30
|
+
Undocumented props are spread to the underlying container `<div>` element.
|
|
31
31
|
|
|
32
32
|
<ArgsTable of={SegmentedControl} />
|
|
@@ -2,9 +2,11 @@ import {Tabs} from '@workday/canvas-kit-react/tabs';
|
|
|
2
2
|
import {Specifications} from '@workday/canvas-kit-docs';
|
|
3
3
|
|
|
4
4
|
import Basic from './examples/Basic';
|
|
5
|
-
import
|
|
5
|
+
import NamedTabs from './examples/NamedTabs';
|
|
6
6
|
import RightToLeft from './examples/RightToLeft';
|
|
7
|
+
import OverflowTabs from './examples/OverflowTabs';
|
|
7
8
|
import DisabledTab from './examples/DisabledTab';
|
|
9
|
+
import Icons from './examples/Icons';
|
|
8
10
|
import SinglePanel from './examples/SinglePanel';
|
|
9
11
|
import AlternativeTabStop from './examples/AlternativeTabStop';
|
|
10
12
|
import HoistedModel from './examples/HoistedModel';
|
|
@@ -19,8 +21,8 @@ import {
|
|
|
19
21
|
# Canvas Kit Tabs
|
|
20
22
|
|
|
21
23
|
`Tabs` is a [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
+
that allows users to navigate between related views of content while remaining in context of the
|
|
25
|
+
page.
|
|
24
26
|
|
|
25
27
|
[> Workday Design Reference](https://design.workday.com/components/navigation/tabs)
|
|
26
28
|
|
|
@@ -34,34 +36,54 @@ yarn add @workday/canvas-kit-react
|
|
|
34
36
|
|
|
35
37
|
### Basic Example
|
|
36
38
|
|
|
37
|
-
`Tabs` includes a container `Tabs` component and the following subcomponents
|
|
38
|
-
`Tabs.Item` and `Tabs.Panel`.
|
|
39
|
+
`Tabs` includes a container `Tabs` component and the following subcomponents which can be composed
|
|
40
|
+
in a variety of ways: `Tabs.List`, `Tabs.Item` and `Tabs.Panel`. It follows the
|
|
41
|
+
[W3 Tabs specification](https://www.w3.org/TR/wai-aria-practices/#tabpanel).
|
|
42
|
+
|
|
43
|
+
In this example, we set up a basic `Tabs` component with five tabs. This example uses a static API
|
|
44
|
+
that does not support overflow.
|
|
39
45
|
|
|
40
46
|
<ExampleCodeBlock code={Basic} />
|
|
41
47
|
|
|
48
|
+
### Overflow Tabs
|
|
49
|
+
|
|
50
|
+
Tabs is a responsive component based on the width of its container. If the rendered tabs exceed the
|
|
51
|
+
width of the `Tabs.List`, an overflow menu will be rendered. This only works against the dynamic API
|
|
52
|
+
where you give the `TabsModel` an array of items to be rendered. The dynamic API handles the React
|
|
53
|
+
`key` for you based on the item's identifier. The dynamic API requires either an `id` on each item
|
|
54
|
+
object or a `getId` function that returns an identifier based on the item. The below example uses an
|
|
55
|
+
`id` property on each item.
|
|
56
|
+
|
|
57
|
+
The dynamic API takes in any object, but since nothing is known about your object, a
|
|
58
|
+
[render prop](https://reactjs.org/docs/render-props.html) is necessary to instruct a list how it
|
|
59
|
+
should render.
|
|
60
|
+
|
|
61
|
+
<ExampleCodeBlock code={OverflowTabs} />
|
|
62
|
+
|
|
42
63
|
### Hoisted Model
|
|
43
64
|
|
|
44
65
|
By default, `Tabs` will create and use its own [model](#model) internally. Alternatively, you may
|
|
45
66
|
configure your own model with `useTabsModel` and pass it to `Tabs` via the `model` prop. This
|
|
46
|
-
pattern is referred to as
|
|
47
|
-
|
|
67
|
+
pattern is referred to as
|
|
68
|
+
[hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model)
|
|
69
|
+
and provides direct access to its `state` and `events` outside of the `Tabs` component.
|
|
48
70
|
|
|
49
71
|
In this example, we set up external observation of the model state and create an external button to
|
|
50
72
|
trigger an event to change the active tab.
|
|
51
73
|
|
|
52
74
|
<ExampleCodeBlock code={HoistedModel} />
|
|
53
75
|
|
|
54
|
-
### Named
|
|
76
|
+
### Named Tabs
|
|
55
77
|
|
|
56
78
|
`Tabs.Item` and `Tabs.Panel` both take an optional `name` attribute that is used for the
|
|
57
|
-
`onActivate` callback. This example is identical to the Basic Example, but with named
|
|
79
|
+
`onActivate` callback. This example is identical to the Basic Example, but with named tabs for the
|
|
58
80
|
`Tabs.Item` and `Tabs.Panel` subcomponents.
|
|
59
81
|
|
|
60
|
-
<ExampleCodeBlock code={
|
|
82
|
+
<ExampleCodeBlock code={NamedTabs} />
|
|
61
83
|
|
|
62
|
-
### Right-to-Left
|
|
84
|
+
### Right-to-Left (RTL)
|
|
63
85
|
|
|
64
|
-
`Tabs` supports right-to-left
|
|
86
|
+
`Tabs` supports right-to-left languages when specified in the `CanvasProvider` `theme`.
|
|
65
87
|
|
|
66
88
|
<ExampleCodeBlock code={RightToLeft} />
|
|
67
89
|
|
|
@@ -71,6 +93,14 @@ Set the `disabled` prop of a `Tabs.Item` to `true` to disable it.
|
|
|
71
93
|
|
|
72
94
|
<ExampleCodeBlock code={DisabledTab} />
|
|
73
95
|
|
|
96
|
+
### Tab Icons
|
|
97
|
+
|
|
98
|
+
Tabs can have icons. You must set `hasIcon` on the `Tabs.Item` and use the `Icon` and `Text`
|
|
99
|
+
subcomponent. The `hasIcon` changes the `Tabs.Item` to change where overflow detection is from the
|
|
100
|
+
`Tabs.Item` element to the `Tabs.Item.Text` element.
|
|
101
|
+
|
|
102
|
+
<ExampleCodeBlock code={Icons} />
|
|
103
|
+
|
|
74
104
|
### Alternative Tab Stop
|
|
75
105
|
|
|
76
106
|
By default, tab panels are focusable for accessibility. If the contents of a tab panel have a
|
|
@@ -93,9 +123,9 @@ from the `contents` object.
|
|
|
93
123
|
### Dynamic Tabs
|
|
94
124
|
|
|
95
125
|
The `Tabs.Item` component takes in an optional `index` property if you want to specify the position
|
|
96
|
-
of a tab. If not defined, by default it will append tabs to the end.
|
|
97
|
-
stored as an array in the state
|
|
98
|
-
|
|
126
|
+
of a tab. If not defined, by default it will append tabs to the end. In this example, our tabs are
|
|
127
|
+
stored as an array in the state, and we have a fixed tab at the end that can add new tabs to that
|
|
128
|
+
array.
|
|
99
129
|
|
|
100
130
|
<ExampleCodeBlock code={DynamicTabs} />
|
|
101
131
|
|
|
@@ -106,22 +136,24 @@ the end.
|
|
|
106
136
|
#### Usage
|
|
107
137
|
|
|
108
138
|
`Tabs` is a container component that is responsible for creating a `TabsModel` and sharing it with
|
|
109
|
-
its
|
|
139
|
+
its subcomponents using React context. It does not represent a real element.
|
|
110
140
|
|
|
111
141
|
```tsx
|
|
112
|
-
|
|
113
|
-
|
|
142
|
+
<Tabs onActivate={({data}) => console.log('Activated tab', data.tab)}>
|
|
143
|
+
{/* Child components */}
|
|
144
|
+
</Tabs>
|
|
145
|
+
```
|
|
114
146
|
|
|
115
|
-
|
|
147
|
+
Alternatively, you may pass in a model using the hoisted model pattern.
|
|
116
148
|
|
|
117
|
-
|
|
149
|
+
```tsx
|
|
118
150
|
const model = useTabsModel({
|
|
119
151
|
onActivate({data}) {
|
|
120
152
|
console.log('Activated Tab', data.tab);
|
|
121
153
|
},
|
|
122
154
|
});
|
|
123
155
|
|
|
124
|
-
<Tabs model={model}>{/*
|
|
156
|
+
<Tabs model={model}>{/* Child components */}</Tabs>;
|
|
125
157
|
```
|
|
126
158
|
|
|
127
159
|
#### Props
|
|
@@ -135,8 +167,7 @@ Note that if you pass in a `model` configured with `useTabsModel`, configuration
|
|
|
135
167
|
|
|
136
168
|
#### Usage
|
|
137
169
|
|
|
138
|
-
`Tabs.List` is a
|
|
139
|
-
subcomponents.
|
|
170
|
+
`Tabs.List` is a `<div role="tablist">` element. It is a container for `Tabs.Item` subcomponents.
|
|
140
171
|
|
|
141
172
|
```tsx
|
|
142
173
|
<Tabs.List>{/* Tabs.Items */}</Tabs.List>
|
|
@@ -144,7 +175,7 @@ subcomponents.
|
|
|
144
175
|
|
|
145
176
|
#### Props
|
|
146
177
|
|
|
147
|
-
Undocumented props are spread to the underlying
|
|
178
|
+
Undocumented props are spread to the underlying `<div>` element.
|
|
148
179
|
|
|
149
180
|
<ArgsTable of={Tabs.List} />
|
|
150
181
|
|
|
@@ -152,9 +183,9 @@ Undocumented props are spread to the underlying `div` element.
|
|
|
152
183
|
|
|
153
184
|
#### Usage
|
|
154
185
|
|
|
155
|
-
`Tabs.Item` is a
|
|
156
|
-
|
|
157
|
-
|
|
186
|
+
`Tabs.Item` is a `<button role="tab">` element. Each `Tabs.Item` is associated with a `Tabs.Panel`
|
|
187
|
+
either by a `name` attribute or by the position in the list. If a `name` is provided, it must match
|
|
188
|
+
the name passed to the corresponding `Tabs.Panel` component.
|
|
158
189
|
|
|
159
190
|
```tsx
|
|
160
191
|
<Tabs.Item name="first">First Tab</Tabs.Item>
|
|
@@ -170,10 +201,9 @@ Undocumented props are spread to the underlying `button` element.
|
|
|
170
201
|
|
|
171
202
|
#### Usage
|
|
172
203
|
|
|
173
|
-
`Tabs.Panel` is a
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
component.
|
|
204
|
+
`Tabs.Panel` is a `<div role="tabpanel">` element. It is focusable by default. Each `Tabs.Panel` is
|
|
205
|
+
controlled by a `Tabs.Item` either by a `name` attribute or by the position in the list. If a `name`
|
|
206
|
+
is provided, it must match the name passed to the corresponding `Tabs.Item` component.
|
|
177
207
|
|
|
178
208
|
```tsx
|
|
179
209
|
<Tabs.Panel name="first">{/* Contents of the tab panel */}</Tabs.Panel>
|
|
@@ -181,7 +211,7 @@ component.
|
|
|
181
211
|
|
|
182
212
|
#### Props
|
|
183
213
|
|
|
184
|
-
Undocumented props are spread to the underlying
|
|
214
|
+
Undocumented props are spread to the underlying `<div>` element.
|
|
185
215
|
|
|
186
216
|
<ArgsTable of={Tabs.Panel} />
|
|
187
217
|
|
|
@@ -192,9 +222,10 @@ If `Tabs` was stripped of all its markup, attributes, and styling, what would re
|
|
|
192
222
|
object composed of two parts: `state` which describes the current snapshot in time of the component
|
|
193
223
|
and `events` which describes events that can be sent to the model.
|
|
194
224
|
|
|
195
|
-
By default, `Tabs` will create
|
|
196
|
-
access to the model's `state` and `events
|
|
197
|
-
pass it to `Tabs` via a
|
|
225
|
+
By default, `Tabs` will create a model and share it internally with its subcomponents using React
|
|
226
|
+
context. Alternatively, if you need direct access to the model's `state` and `events` outside of the
|
|
227
|
+
`Tabs` component, you may configure your own model with `useTabsModel` and pass it to `Tabs` via a
|
|
228
|
+
pattern called
|
|
198
229
|
[hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model).
|
|
199
230
|
|
|
200
231
|
```tsx
|
|
@@ -204,7 +235,7 @@ const model = useTabsModel({
|
|
|
204
235
|
},
|
|
205
236
|
});
|
|
206
237
|
|
|
207
|
-
<Tabs model={model}>{/*
|
|
238
|
+
<Tabs model={model}>{/* Child components */}</Tabs>;
|
|
208
239
|
```
|
|
209
240
|
|
|
210
241
|
### Config
|
|
@@ -8,7 +8,7 @@ export default () => {
|
|
|
8
8
|
<Tabs>
|
|
9
9
|
<Tabs.List>
|
|
10
10
|
<Tabs.Item>First Tab</Tabs.Item>
|
|
11
|
-
<Tabs.Item disabled>Disabled Tab</Tabs.Item>
|
|
11
|
+
<Tabs.Item aria-disabled>Disabled Tab</Tabs.Item>
|
|
12
12
|
<Tabs.Item>Third Tab</Tabs.Item>
|
|
13
13
|
</Tabs.List>
|
|
14
14
|
<div style={{marginTop: space.m}}>
|