@workday/canvas-kit-docs 5.3.0-next.3 → 5.3.1
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 +30 -14
- package/dist/es6/lib/specs.js +30 -14
- package/dist/mdx/CONTRIBUTING.mdx +90 -63
- package/dist/mdx/preview-react/breadcrumbs/Breadcrumbs.mdx +1 -1
- package/dist/mdx/preview-react/menu/Menu.mdx +17 -9
- package/dist/mdx/preview-react/menu/examples/Basic.tsx +65 -10
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +45 -29
- package/dist/mdx/preview-react/menu/examples/CustomMenuItem.tsx +2 -2
- package/dist/mdx/preview-react/menu/examples/Icons.tsx +1 -1
- package/dist/mdx/preview-react/menu/examples/ManyItems.tsx +2 -2
- package/dist/mdx/react/action-bar/ActionBar.mdx +1 -1
- package/dist/mdx/react/button/button/Button.mdx +7 -7
- package/dist/mdx/react/button/icon-button/IconButton.mdx +1 -1
- 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 +37 -32
- package/dist/mdx/react/tabs/examples/HoistedModel.tsx +1 -1
- package/dist/mdx/react/toast/toast.mdx +1 -17
- package/dist/mdx/react/tooltip/Tooltip.mdx +1 -1
- package/dist/mdx/react/tooltip/examples/Ellipsis.tsx +6 -0
- package/package.json +3 -3
- package/dist/mdx/CODE_OF_CONDUCT.md +0 -68
- package/dist/mdx/preview-react/menu/examples/ContextMenuTarget.tsx +0 -33
- package/dist/mdx/preview-react/menu/examples/ControlButton.tsx +0 -84
- 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} />
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
# Canvas Kit Tabs
|
|
20
20
|
|
|
21
21
|
`Tabs` is a [compound component](/getting-started/for-developers/resources/compound-components/)
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
that allows users to navigate between related views of content while remaining in context of the
|
|
23
|
+
page.
|
|
24
24
|
|
|
25
25
|
[> Workday Design Reference](https://design.workday.com/components/navigation/tabs)
|
|
26
26
|
|
|
@@ -34,8 +34,11 @@ yarn add @workday/canvas-kit-react
|
|
|
34
34
|
|
|
35
35
|
### Basic Example
|
|
36
36
|
|
|
37
|
-
`Tabs` includes a container `Tabs` component and the following subcomponents
|
|
38
|
-
`Tabs.Item` and `Tabs.Panel`.
|
|
37
|
+
`Tabs` includes a container `Tabs` component and the following subcomponents which can be composed
|
|
38
|
+
in a variety of ways: `Tabs.List`, `Tabs.Item` and `Tabs.Panel`. It follows the
|
|
39
|
+
[W3 Tabs specification](https://www.w3.org/TR/wai-aria-practices/#tabpanel).
|
|
40
|
+
|
|
41
|
+
In this example, we set up a basic `Tabs` component with five tabs.
|
|
39
42
|
|
|
40
43
|
<ExampleCodeBlock code={Basic} />
|
|
41
44
|
|
|
@@ -43,8 +46,9 @@ yarn add @workday/canvas-kit-react
|
|
|
43
46
|
|
|
44
47
|
By default, `Tabs` will create and use its own [model](#model) internally. Alternatively, you may
|
|
45
48
|
configure your own model with `useTabsModel` and pass it to `Tabs` via the `model` prop. This
|
|
46
|
-
pattern is referred to as
|
|
47
|
-
|
|
49
|
+
pattern is referred to as
|
|
50
|
+
[hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model)
|
|
51
|
+
and provides direct access to its `state` and `events` outside of the `Tabs` component.
|
|
48
52
|
|
|
49
53
|
In this example, we set up external observation of the model state and create an external button to
|
|
50
54
|
trigger an event to change the active tab.
|
|
@@ -59,9 +63,9 @@ trigger an event to change the active tab.
|
|
|
59
63
|
|
|
60
64
|
<ExampleCodeBlock code={NamedKeys} />
|
|
61
65
|
|
|
62
|
-
### Right-to-Left
|
|
66
|
+
### Right-to-Left (RTL)
|
|
63
67
|
|
|
64
|
-
`Tabs` supports right-to-left
|
|
68
|
+
`Tabs` supports right-to-left languages when specified in the `CanvasProvider` `theme`.
|
|
65
69
|
|
|
66
70
|
<ExampleCodeBlock code={RightToLeft} />
|
|
67
71
|
|
|
@@ -93,9 +97,9 @@ from the `contents` object.
|
|
|
93
97
|
### Dynamic Tabs
|
|
94
98
|
|
|
95
99
|
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
|
-
|
|
100
|
+
of a tab. If not defined, by default it will append tabs to the end. In this example, our tabs are
|
|
101
|
+
stored as an array in the state, and we have a fixed tab at the end that can add new tabs to that
|
|
102
|
+
array.
|
|
99
103
|
|
|
100
104
|
<ExampleCodeBlock code={DynamicTabs} />
|
|
101
105
|
|
|
@@ -106,22 +110,24 @@ the end.
|
|
|
106
110
|
#### Usage
|
|
107
111
|
|
|
108
112
|
`Tabs` is a container component that is responsible for creating a `TabsModel` and sharing it with
|
|
109
|
-
its
|
|
113
|
+
its subcomponents using React context. It does not represent a real element.
|
|
110
114
|
|
|
111
115
|
```tsx
|
|
112
|
-
|
|
113
|
-
|
|
116
|
+
<Tabs onActivate={({data}) => console.log('Activated tab', data.tab)}>
|
|
117
|
+
{/* Child components */}
|
|
118
|
+
</Tabs>
|
|
119
|
+
```
|
|
114
120
|
|
|
115
|
-
|
|
121
|
+
Alternatively, you may pass in a model using the hoisted model pattern.
|
|
116
122
|
|
|
117
|
-
|
|
123
|
+
```tsx
|
|
118
124
|
const model = useTabsModel({
|
|
119
125
|
onActivate({data}) {
|
|
120
126
|
console.log('Activated Tab', data.tab);
|
|
121
127
|
},
|
|
122
128
|
});
|
|
123
129
|
|
|
124
|
-
<Tabs model={model}>{/*
|
|
130
|
+
<Tabs model={model}>{/* Child components */}</Tabs>;
|
|
125
131
|
```
|
|
126
132
|
|
|
127
133
|
#### Props
|
|
@@ -135,8 +141,7 @@ Note that if you pass in a `model` configured with `useTabsModel`, configuration
|
|
|
135
141
|
|
|
136
142
|
#### Usage
|
|
137
143
|
|
|
138
|
-
`Tabs.List` is a
|
|
139
|
-
subcomponents.
|
|
144
|
+
`Tabs.List` is a `<div role="tablist">` element. It is a container for `Tabs.Item` subcomponents.
|
|
140
145
|
|
|
141
146
|
```tsx
|
|
142
147
|
<Tabs.List>{/* Tabs.Items */}</Tabs.List>
|
|
@@ -144,7 +149,7 @@ subcomponents.
|
|
|
144
149
|
|
|
145
150
|
#### Props
|
|
146
151
|
|
|
147
|
-
Undocumented props are spread to the underlying
|
|
152
|
+
Undocumented props are spread to the underlying `<div>` element.
|
|
148
153
|
|
|
149
154
|
<ArgsTable of={Tabs.List} />
|
|
150
155
|
|
|
@@ -152,9 +157,9 @@ Undocumented props are spread to the underlying `div` element.
|
|
|
152
157
|
|
|
153
158
|
#### Usage
|
|
154
159
|
|
|
155
|
-
`Tabs.Item` is a
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
`Tabs.Item` is a `<button role="tab">` element. Each `Tabs.Item` is associated with a `Tabs.Panel`
|
|
161
|
+
either by a `name` attribute or by the position in the list. If a `name` is provided, it must match
|
|
162
|
+
the name passed to the corresponding `Tabs.Panel` component.
|
|
158
163
|
|
|
159
164
|
```tsx
|
|
160
165
|
<Tabs.Item name="first">First Tab</Tabs.Item>
|
|
@@ -170,10 +175,9 @@ Undocumented props are spread to the underlying `button` element.
|
|
|
170
175
|
|
|
171
176
|
#### Usage
|
|
172
177
|
|
|
173
|
-
`Tabs.Panel` is a
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
component.
|
|
178
|
+
`Tabs.Panel` is a `<div role="tabpanel">` element. It is focusable by default. Each `Tabs.Panel` is
|
|
179
|
+
controlled by a `Tabs.Item` either by a `name` attribute or by the position in the list. If a `name`
|
|
180
|
+
is provided, it must match the name passed to the corresponding `Tabs.Item` component.
|
|
177
181
|
|
|
178
182
|
```tsx
|
|
179
183
|
<Tabs.Panel name="first">{/* Contents of the tab panel */}</Tabs.Panel>
|
|
@@ -181,7 +185,7 @@ component.
|
|
|
181
185
|
|
|
182
186
|
#### Props
|
|
183
187
|
|
|
184
|
-
Undocumented props are spread to the underlying
|
|
188
|
+
Undocumented props are spread to the underlying `<div>` element.
|
|
185
189
|
|
|
186
190
|
<ArgsTable of={Tabs.Panel} />
|
|
187
191
|
|
|
@@ -192,9 +196,10 @@ If `Tabs` was stripped of all its markup, attributes, and styling, what would re
|
|
|
192
196
|
object composed of two parts: `state` which describes the current snapshot in time of the component
|
|
193
197
|
and `events` which describes events that can be sent to the model.
|
|
194
198
|
|
|
195
|
-
By default, `Tabs` will create
|
|
196
|
-
access to the model's `state` and `events
|
|
197
|
-
pass it to `Tabs` via a
|
|
199
|
+
By default, `Tabs` will create a model and share it internally with its subcomponents using React
|
|
200
|
+
context. Alternatively, if you need direct access to the model's `state` and `events` outside of the
|
|
201
|
+
`Tabs` component, you may configure your own model with `useTabsModel` and pass it to `Tabs` via a
|
|
202
|
+
pattern called
|
|
198
203
|
[hoisting the model](/getting-started/for-developers/resources/compound-components/#configuring-a-model).
|
|
199
204
|
|
|
200
205
|
```tsx
|
|
@@ -204,7 +209,7 @@ const model = useTabsModel({
|
|
|
204
209
|
},
|
|
205
210
|
});
|
|
206
211
|
|
|
207
|
-
<Tabs model={model}>{/*
|
|
212
|
+
<Tabs model={model}>{/* Child components */}</Tabs>;
|
|
208
213
|
```
|
|
209
214
|
|
|
210
215
|
### Config
|
|
@@ -29,52 +29,36 @@ Below are examples we expect will work for most use cases. Note that all example
|
|
|
29
29
|
they are an important signifier to communicate meaning. For this reason, Toast notifications should
|
|
30
30
|
always include an icon.
|
|
31
31
|
|
|
32
|
-
---
|
|
33
|
-
|
|
34
32
|
#### Complete Example with Popper
|
|
35
33
|
|
|
36
34
|
We use Popper to position Toast. Here's an example of how to use them together.
|
|
37
35
|
|
|
38
36
|
<ExampleCodeBlock code={WithPopper} />
|
|
39
37
|
|
|
40
|
-
---
|
|
41
|
-
|
|
42
38
|
#### Success
|
|
43
39
|
|
|
44
40
|
<ExampleCodeBlock code={Success} />
|
|
45
41
|
|
|
46
|
-
---
|
|
47
|
-
|
|
48
42
|
#### Error
|
|
49
43
|
|
|
50
44
|
<ExampleCodeBlock code={Error} />
|
|
51
45
|
|
|
52
|
-
---
|
|
53
|
-
|
|
54
46
|
#### WithCloseButton
|
|
55
47
|
|
|
56
48
|
<ExampleCodeBlock code={WithCloseButton} />
|
|
57
49
|
|
|
58
|
-
---
|
|
59
|
-
|
|
60
50
|
#### With an Action Link
|
|
61
51
|
|
|
62
52
|
<ExampleCodeBlock code={WithActionLink} />
|
|
63
53
|
|
|
64
|
-
---
|
|
65
|
-
|
|
66
54
|
#### With an Action Link and CloseIcon
|
|
67
55
|
|
|
68
56
|
<ExampleCodeBlock code={WithActionLinkAndCloseIcon} />
|
|
69
57
|
|
|
70
|
-
---
|
|
71
|
-
|
|
72
58
|
#### With RTL
|
|
73
59
|
|
|
74
60
|
<ExampleCodeBlock code={RTL} />
|
|
75
61
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
## Component Props
|
|
62
|
+
## Props
|
|
79
63
|
|
|
80
64
|
<ArgsTable of={Toast} />
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
4
|
import {OverflowTooltip} from '@workday/canvas-kit-react/tooltip';
|
|
5
5
|
import {space} from '@workday/canvas-kit-react/tokens';
|
|
6
|
+
import {resetIcon} from '@workday/canvas-system-icons-web';
|
|
6
7
|
|
|
7
8
|
const CustomContent = ({...elemProps}) => (
|
|
8
9
|
<button
|
|
@@ -30,6 +31,11 @@ export default () => {
|
|
|
30
31
|
Super Mega Ultra Long Content With Max Width On The Button
|
|
31
32
|
</SecondaryButton>
|
|
32
33
|
</OverflowTooltip>
|
|
34
|
+
<OverflowTooltip>
|
|
35
|
+
<SecondaryButton icon={resetIcon} style={{maxWidth: 200}}>
|
|
36
|
+
Super Mega Ultra Long Content With Max Width On The Button with Icon
|
|
37
|
+
</SecondaryButton>
|
|
38
|
+
</OverflowTooltip>
|
|
33
39
|
<OverflowTooltip>
|
|
34
40
|
<button
|
|
35
41
|
style={{
|