@workday/canvas-kit-docs 5.3.0-next.3 → 5.3.0-next.32
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 +429 -33
- package/dist/es6/lib/specs.js +429 -33
- package/dist/mdx/5.0-MIGRATION-GUIDE.mdx +81 -7
- package/dist/mdx/6.0-MIGRATION-GUIDE.mdx +560 -0
- package/dist/mdx/COMPOUND_COMPONENTS.mdx +31 -30
- package/dist/mdx/CONTRIBUTING.mdx +90 -63
- package/dist/mdx/TESTING.mdx +29 -5
- package/dist/mdx/labs-react/search-form/SearchForm.mdx +64 -0
- package/dist/mdx/labs-react/search-form/examples/Basic.tsx +61 -0
- package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +72 -0
- package/dist/mdx/labs-react/search-form/examples/Grow.tsx +62 -0
- package/dist/mdx/labs-react/search-form/examples/PropTables.splitProps.tsx +4 -0
- package/dist/mdx/labs-react/search-form/examples/RTL.tsx +70 -0
- package/dist/mdx/labs-react/search-form/examples/Theming.tsx +64 -0
- 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/Menu.mdx +17 -9
- package/dist/mdx/preview-react/menu/examples/Basic.tsx +65 -10
- package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +47 -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/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/preview-react/text-input/TextInput.mdx +145 -0
- package/dist/mdx/preview-react/text-input/examples/Alert.tsx +40 -0
- package/dist/mdx/preview-react/text-input/examples/Basic.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Disabled.tsx +17 -0
- package/dist/mdx/preview-react/text-input/examples/Error.tsx +40 -0
- 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/preview-react/text-input/examples/LoginForm.tsx +105 -0
- 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/preview-react/text-input/examples/RefForwarding.tsx +28 -0
- 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/preview-react/text-input/examples/ThemedError.tsx +37 -0
- package/dist/mdx/react/_examples/CookieBanner.mdx +8 -0
- package/dist/mdx/react/_examples/GlobalHeader.mdx +9 -0
- package/dist/mdx/react/_examples/PageHeader.mdx +8 -0
- package/dist/mdx/react/_examples/examples/CookieBanner.tsx +97 -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 +11 -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 +96 -36
- package/dist/mdx/react/popup/examples/FullScreen.tsx +115 -0
- 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 +82 -38
- 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/text-area/TextArea.mdx +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/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
|
@@ -9,6 +9,7 @@ import FocusRedirect from './examples/FocusRedirect';
|
|
|
9
9
|
import FocusTrap from './examples/FocusTrap';
|
|
10
10
|
import RTL from './examples/RTL';
|
|
11
11
|
import CustomTarget from './examples/CustomTarget';
|
|
12
|
+
import FullScreen from './examples/FullScreen';
|
|
12
13
|
import {
|
|
13
14
|
PopupModelConfigComponent,
|
|
14
15
|
PopupStateComponent,
|
|
@@ -52,7 +53,7 @@ The `Popup` component is a generic
|
|
|
52
53
|
[Compound Component](/getting-started/for-developers/resources/compound-components/) that is used to
|
|
53
54
|
build popup UIs that are not already covered by Canvas Kit.
|
|
54
55
|
|
|
55
|
-
### Basic
|
|
56
|
+
### Basic Example
|
|
56
57
|
|
|
57
58
|
The Popup has no pre-defined behaviors built in, therefore the `usePopupModel` must always be used
|
|
58
59
|
to create a new `model`. This `model` is then used by all behavior hooks to apply additional popup
|
|
@@ -63,7 +64,7 @@ popup behaviors. For accessibility, these behaviors should be included most of t
|
|
|
63
64
|
|
|
64
65
|
<ExampleCodeBlock code={Basic} />
|
|
65
66
|
|
|
66
|
-
### Initial
|
|
67
|
+
### Initial Focus
|
|
67
68
|
|
|
68
69
|
If you want focus to move to a specific element when the popup is opened, set the `initialFocusRef`
|
|
69
70
|
of the model. Check with accessibility before doing this. The following example sets the focus on
|
|
@@ -143,6 +144,25 @@ requires a `label` prop.
|
|
|
143
144
|
|
|
144
145
|
<ExampleCodeBlock code={CustomTarget} />
|
|
145
146
|
|
|
147
|
+
### Full Screen API
|
|
148
|
+
|
|
149
|
+
By default, popups are created as children of the `document.body` element, but the `PopupStack`
|
|
150
|
+
supports the [Fullscreen API](https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API). When
|
|
151
|
+
fullscreen is entered, the `PopupStack` will automatically create a new stacking context for all
|
|
152
|
+
future popups. Any existing popups will disappear, but not be removed. They disappear because the
|
|
153
|
+
fullscreen API is only showing content within the fullscreen element. There are instances where a
|
|
154
|
+
popup may not close when fullscreen is exited:
|
|
155
|
+
|
|
156
|
+
- The escape key is used to exit fullscreen
|
|
157
|
+
- There is a button to exit fullscreen, but the popup doesn't use `useCloseOnOutsideClick`
|
|
158
|
+
|
|
159
|
+
If fullscreen is exited, popups within the fullscreen stacking context are not removed or
|
|
160
|
+
transferred automatically. If you do not handle this case, the popup may not render correctly. This
|
|
161
|
+
example shows a popup that closes when fullscreen is entered/exited and another popup that transfers
|
|
162
|
+
the popup's stack context when entering/exiting fullscreen.
|
|
163
|
+
|
|
164
|
+
<ExampleCodeBlock code={FullScreen} />
|
|
165
|
+
|
|
146
166
|
### RTL
|
|
147
167
|
|
|
148
168
|
The Popup component automatically handles right-to-left rendering.
|
|
@@ -153,7 +173,7 @@ The Popup component automatically handles right-to-left rendering.
|
|
|
153
173
|
|
|
154
174
|
## Components
|
|
155
175
|
|
|
156
|
-
|
|
176
|
+
### Popper
|
|
157
177
|
|
|
158
178
|
A thin wrapper component around the Popper.js positioning engine. For reference:
|
|
159
179
|
https://popper.js.org/. `Popper` also automatically works with the `PopupStack` system. `Popper` has
|
|
@@ -169,7 +189,7 @@ PopupModel or any associate popup [hooks](#hooks).
|
|
|
169
189
|
> element was rendered and that's where extra props were spread to. In v5+, you can provide your own
|
|
170
190
|
> element if you wish.
|
|
171
191
|
|
|
172
|
-
|
|
192
|
+
### Popup
|
|
173
193
|
|
|
174
194
|
This component is a container component that has no semantic element. It provides a React Context
|
|
175
195
|
model for all Popup subcomponents. If you manually pass a `model` to all subcomponents, this
|
|
@@ -189,7 +209,7 @@ container component isn't needed.
|
|
|
189
209
|
|
|
190
210
|
<ArgsTable of={Popup} />
|
|
191
211
|
|
|
192
|
-
|
|
212
|
+
### Popup.Target
|
|
193
213
|
|
|
194
214
|
A `Popup.Target` is any element that is meant to show the Popup. The default component rendered by
|
|
195
215
|
this component is a `SecondaryButton` element. You can override this by passing the desired
|
|
@@ -217,7 +237,7 @@ used, which is `SecondaryButton`. If you don't want any styling, you can do the
|
|
|
217
237
|
To add your own styling, you could either add a `css` prop, or make a styled button and pass that
|
|
218
238
|
styled component via the `as` prop.
|
|
219
239
|
|
|
220
|
-
|
|
240
|
+
### Popup.Popper
|
|
221
241
|
|
|
222
242
|
A `Popup.Popper` is a [Popper](#popper) component that is hooked up to the `PopupModel`
|
|
223
243
|
automatically. The behavior hook used is called `usePopupPopper`.
|
|
@@ -229,7 +249,7 @@ automatically. The behavior hook used is called `usePopupPopper`.
|
|
|
229
249
|
|
|
230
250
|
<ArgsTable of={Popup.Popper} />
|
|
231
251
|
|
|
232
|
-
|
|
252
|
+
### Popup.Card
|
|
233
253
|
|
|
234
254
|
A `Popup.Card` is a wrapper around the `Card` component, but hooked up to a `PopupModel`. By
|
|
235
255
|
default, this element has a `role=dialog` and an `aria-labelledby`. The behavior hook used is called
|
|
@@ -237,7 +257,7 @@ default, this element has a `role=dialog` and an `aria-labelledby`. The behavior
|
|
|
237
257
|
|
|
238
258
|
<ArgsTable of={Popup.Card} />
|
|
239
259
|
|
|
240
|
-
|
|
260
|
+
### Popup.CloseButton
|
|
241
261
|
|
|
242
262
|
A `Popup.CloseButton` is a button that will hide a popup. By default, this is a `SecondaryButton`
|
|
243
263
|
component, but `as` can be used to render any button element (i.e `<DeleteButton>` or
|
|
@@ -245,14 +265,14 @@ component, but `as` can be used to render any button element (i.e `<DeleteButton
|
|
|
245
265
|
|
|
246
266
|
<ArgsTable of={Popup.CloseButton} />
|
|
247
267
|
|
|
248
|
-
|
|
268
|
+
### Popup.CloseIcon
|
|
249
269
|
|
|
250
270
|
A `Popup.CloseIcon` is an icon button that is the `X` in the top of a popup. It will hide a popup
|
|
251
271
|
when clicked. The behavior hook used is called `usePopupCloseButton`.
|
|
252
272
|
|
|
253
273
|
<ArgsTable of={Popup.CloseIcon} />
|
|
254
274
|
|
|
255
|
-
|
|
275
|
+
### Popup.Heading
|
|
256
276
|
|
|
257
277
|
A `Popup.Heading` is a wrapper around `Card.Heading` that connect the heading to a `PopupModel`. It
|
|
258
278
|
will add an `id` to the element that match the `aria-labelledby` that is applied to the `Popup.Card`
|
|
@@ -260,29 +280,29 @@ element for accessibility. The behavior hook used is called `usePopupHeading`.
|
|
|
260
280
|
|
|
261
281
|
<ArgsTable of={Popup.Heading} />
|
|
262
282
|
|
|
263
|
-
|
|
283
|
+
### Popup.Body
|
|
264
284
|
|
|
265
285
|
A `Popup.Body` is a thin wrapper around `Card.Body` and doesn't actually take a model. It adds
|
|
266
286
|
`body` styling and nothing else.
|
|
267
287
|
|
|
268
288
|
<ArgsTable of={Popup.Body} />
|
|
269
289
|
|
|
270
|
-
##
|
|
290
|
+
## Model
|
|
271
291
|
|
|
272
292
|
The PopupModel contains all state and events needed for Popup behaviors and components. It composes
|
|
273
293
|
a `DisclosureModel` for showing and hiding content.
|
|
274
294
|
|
|
275
|
-
###
|
|
295
|
+
### Config
|
|
276
296
|
|
|
277
|
-
<ArgsTable of={
|
|
297
|
+
<ArgsTable of={PopupModelConfigComponent} />
|
|
278
298
|
|
|
279
|
-
###
|
|
299
|
+
### State
|
|
280
300
|
|
|
281
|
-
<ArgsTable of={
|
|
301
|
+
<ArgsTable of={PopupStateComponent} />
|
|
282
302
|
|
|
283
|
-
###
|
|
303
|
+
### Events
|
|
284
304
|
|
|
285
|
-
<ArgsTable of={
|
|
305
|
+
<ArgsTable of={PopupEventsComponent} />
|
|
286
306
|
|
|
287
307
|
## Hooks
|
|
288
308
|
|
|
@@ -325,7 +345,7 @@ return (
|
|
|
325
345
|
);
|
|
326
346
|
```
|
|
327
347
|
|
|
328
|
-
|
|
348
|
+
### useAssistiveHideSiblings
|
|
329
349
|
|
|
330
350
|
```ts
|
|
331
351
|
useAssistiveHideSiblings(model: PopupModel): {}
|
|
@@ -341,7 +361,7 @@ VoiceOver for example.
|
|
|
341
361
|
|
|
342
362
|
This should be used on popup elements that need to hide content (i.e. Modals).
|
|
343
363
|
|
|
344
|
-
|
|
364
|
+
### useBringToTopOnClick
|
|
345
365
|
|
|
346
366
|
```ts
|
|
347
367
|
useBringToTopOnClick(model: PopupModel): {}
|
|
@@ -355,7 +375,7 @@ like a Modal.
|
|
|
355
375
|
|
|
356
376
|
This should be used on popup elements that are meant to persist (i.e. Windows).
|
|
357
377
|
|
|
358
|
-
|
|
378
|
+
### useCloseOnEscape
|
|
359
379
|
|
|
360
380
|
```ts
|
|
361
381
|
useCloseOnEscape(model: PopupModel): {}
|
|
@@ -367,7 +387,7 @@ provided model's `state.stackRef` element is the topmost in the stack.
|
|
|
367
387
|
This should be used with popup elements that are dismissible like Tooltips, Modals, non-modal
|
|
368
388
|
dialogs, dropdown menus, etc.
|
|
369
389
|
|
|
370
|
-
|
|
390
|
+
### useCloseOnOutsideClick
|
|
371
391
|
|
|
372
392
|
```ts
|
|
373
393
|
useCloseOnOutsideClick(model: PopupModel): {}
|
|
@@ -382,7 +402,7 @@ This should be used with popup elements that are dismissible like Modals, non-mo
|
|
|
382
402
|
dropdown menus, etc. Tooltips and hierarchical menus should use `useAlwaysCloseOnClickOutside`
|
|
383
403
|
instead.
|
|
384
404
|
|
|
385
|
-
|
|
405
|
+
### useAlwaysCloseOnOutsideClick
|
|
386
406
|
|
|
387
407
|
```ts
|
|
388
408
|
useAlwaysCloseOnOutsideClick(model: PopupModel): {}
|
|
@@ -396,7 +416,16 @@ stack. This is useful for Tooltips or hierarchical menus. Adds a
|
|
|
396
416
|
This should be used with popup elements that should close no matter their position in the stack
|
|
397
417
|
(i.e. Tooltips).
|
|
398
418
|
|
|
399
|
-
|
|
419
|
+
### useCloseOnFullscreenExit
|
|
420
|
+
|
|
421
|
+
```ts
|
|
422
|
+
useCloseOnFullscreenExit(model: PopupModel): {}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
Closes the popup when fullscreen is exited. Entering/exiting fullscreen changes the context of the
|
|
426
|
+
entire screen. This should be added to popup types that are very context sensitive like Tooltips.
|
|
427
|
+
|
|
428
|
+
### useDisableBodyScroll
|
|
400
429
|
|
|
401
430
|
```ts
|
|
402
431
|
useDisableBodyScroll(model: PopupModel): {}
|
|
@@ -408,7 +437,7 @@ page scrolling while the popup is visible.
|
|
|
408
437
|
This should be used with popup elements that hide all other content and force the user to accept or
|
|
409
438
|
dismiss the popup before continuing (i.e. Modals).
|
|
410
439
|
|
|
411
|
-
|
|
440
|
+
### useFocusRedirect
|
|
412
441
|
|
|
413
442
|
```ts
|
|
414
443
|
useFocusRedirect(model: PopupModel): {}
|
|
@@ -426,7 +455,7 @@ hook does no provide `aria-owns` and this must be provided yourself. Requires
|
|
|
426
455
|
|
|
427
456
|
This should be used with non-modal dialogs.
|
|
428
457
|
|
|
429
|
-
|
|
458
|
+
### useFocusTrap
|
|
430
459
|
|
|
431
460
|
```ts
|
|
432
461
|
useFocusTrap(model: PopupModel): {}
|
|
@@ -440,7 +469,11 @@ with [useInitialFocus](#useinitialfocus) and [useReturnFocus](#usereturnfocus).
|
|
|
440
469
|
|
|
441
470
|
This should be used on popup elements that need to hide content (i.e. Modals).
|
|
442
471
|
|
|
443
|
-
|
|
472
|
+
### useInitialFocus
|
|
473
|
+
|
|
474
|
+
```ts
|
|
475
|
+
useInitialFocus(model: PopupModel): {}
|
|
476
|
+
```
|
|
444
477
|
|
|
445
478
|
Moves focus within the popup when the popup becomes visible. This is useful for keyboard and screen
|
|
446
479
|
reader users alike. This should be used with [useFocusRedirect](#usefocusredirect) or
|
|
@@ -449,7 +482,11 @@ reader users alike. This should be used with [useFocusRedirect](#usefocusredirec
|
|
|
449
482
|
This should be used for popups that have focusable elements inside, like Modals, non-modal dialogs,
|
|
450
483
|
menus, etc.
|
|
451
484
|
|
|
452
|
-
|
|
485
|
+
### useReturnFocus
|
|
486
|
+
|
|
487
|
+
```ts
|
|
488
|
+
useReturnFocus(model: PopupModel): {}
|
|
489
|
+
```
|
|
453
490
|
|
|
454
491
|
Returns focus to the target element when the popup is hidden. This works well with
|
|
455
492
|
[useInitialFocus](#useinitialfocus). This should be used with [useFocusRedirect](#usefocusredirect)
|
|
@@ -457,7 +494,32 @@ or [useFocusTrap](#usefocustrap) for a complete focus management solution.
|
|
|
457
494
|
|
|
458
495
|
This should ble used on popup elements that use [useInitialFocus](#useinitialfocus).
|
|
459
496
|
|
|
460
|
-
|
|
497
|
+
### useTransferOnFullscreenEnter
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
useTransferOnFullscreenEnter(model: PopupModel): {}
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Makes the popup transfer to the fullscreen element when fullscreen is entered. Without this, the
|
|
504
|
+
popup would seem to disappear because the popup container element is not a child of the fullscreen
|
|
505
|
+
element.
|
|
506
|
+
|
|
507
|
+
Don't use this in conjunction with a hook that will close the popup when entering fullscreen. Doing
|
|
508
|
+
so would open the popup when the intention was to close it.
|
|
509
|
+
|
|
510
|
+
### useTransferOnFullscreenExit
|
|
511
|
+
|
|
512
|
+
```ts
|
|
513
|
+
useTransferOnFullscreenExit(model: PopupModel): {}
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
Makes the popup transfer to fullscreen when fullscreen is exited. Without this hook, the popup would
|
|
517
|
+
not operate correctly with other popups on the screen.
|
|
518
|
+
|
|
519
|
+
Don't use this in conjunction with a hook that will close the popup when exiting fullscreen. Doing
|
|
520
|
+
so would open the popup when the intention was to close it.
|
|
521
|
+
|
|
522
|
+
### usePopupPopper
|
|
461
523
|
|
|
462
524
|
```ts
|
|
463
525
|
usePopupPopper(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -466,7 +528,7 @@ usePopupPopper(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
|
466
528
|
Adds the necessary props to a `Popper` component. Used by the [Popup.Popper](#popuppopper)
|
|
467
529
|
subcomponent.
|
|
468
530
|
|
|
469
|
-
|
|
531
|
+
### usePopupCard
|
|
470
532
|
|
|
471
533
|
```ts
|
|
472
534
|
usePopupCard(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -474,7 +536,7 @@ usePopupCard(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
|
474
536
|
|
|
475
537
|
Adds the necessary props to a `Card` component. Used by the [Popup.Card](#popupcard) subcomponent.
|
|
476
538
|
|
|
477
|
-
|
|
539
|
+
### usePopupCloseButton
|
|
478
540
|
|
|
479
541
|
```ts
|
|
480
542
|
usePopupCloseButton(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -484,18 +546,16 @@ Adds the necessary props to a close button component. Used by the
|
|
|
484
546
|
[Popup.CloseButton](#popupclosebutton) subcomponent and [Popup.CloseIcon](#popupcloseicon)
|
|
485
547
|
subcomponent.
|
|
486
548
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
## usePopupHeading
|
|
549
|
+
### usePopupHeading
|
|
490
550
|
|
|
491
551
|
```ts
|
|
492
552
|
usePopupHeading(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
493
|
-
|
|
553
|
+
```
|
|
494
554
|
|
|
495
555
|
Adds the necessary props to a `Heading` component. Used by the [Popup.Heading](#popupheading)
|
|
496
556
|
subcomponent.
|
|
497
557
|
|
|
498
|
-
|
|
558
|
+
### usePopupTarget
|
|
499
559
|
|
|
500
560
|
```ts
|
|
501
561
|
usePopupTarget(model: PopupModel, elemProps: {}, ref: React.Ref<any>): {}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
|
|
3
|
+
import {SecondaryButton} from '@workday/canvas-kit-react/button';
|
|
4
|
+
import {
|
|
5
|
+
Popup,
|
|
6
|
+
useCloseOnEscape,
|
|
7
|
+
useCloseOnOutsideClick,
|
|
8
|
+
useFocusTrap,
|
|
9
|
+
useInitialFocus,
|
|
10
|
+
useReturnFocus,
|
|
11
|
+
usePopupModel,
|
|
12
|
+
useCloseOnFullscreenExit,
|
|
13
|
+
useTransferOnFullscreenExit,
|
|
14
|
+
useTransferOnFullscreenEnter,
|
|
15
|
+
} from '@workday/canvas-kit-react/popup';
|
|
16
|
+
import {HStack, Flex} from '@workday/canvas-kit-labs-react/layout';
|
|
17
|
+
import {useIsFullscreen} from '@workday/canvas-kit-react/common';
|
|
18
|
+
import screenfull from 'screenfull';
|
|
19
|
+
|
|
20
|
+
const SelfClosePopup = () => {
|
|
21
|
+
const model = usePopupModel();
|
|
22
|
+
|
|
23
|
+
useCloseOnOutsideClick(model);
|
|
24
|
+
useCloseOnEscape(model);
|
|
25
|
+
useInitialFocus(model);
|
|
26
|
+
useReturnFocus(model);
|
|
27
|
+
useFocusTrap(model);
|
|
28
|
+
useCloseOnFullscreenExit(model);
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<Popup model={model}>
|
|
32
|
+
<Popup.Target>Open Self-close Popup</Popup.Target>
|
|
33
|
+
<Popup.Popper>
|
|
34
|
+
<Popup.Card width={400} padding="s">
|
|
35
|
+
<Popup.CloseIcon aria-label="Close" />
|
|
36
|
+
<Popup.Heading>Self-close Popup</Popup.Heading>
|
|
37
|
+
<Popup.Body>
|
|
38
|
+
<p>
|
|
39
|
+
When in fullscreen, the escape key will be highjacked by the browser to exit
|
|
40
|
+
fullscreen and <code>useCloseOnEscape</code> hook will not receive the escape key. To
|
|
41
|
+
close when fullscreen is exited, use the <code>useCloseOnFullscreenExit</code> hook.
|
|
42
|
+
</p>
|
|
43
|
+
</Popup.Body>
|
|
44
|
+
<Popup.CloseButton>Close</Popup.CloseButton>
|
|
45
|
+
</Popup.Card>
|
|
46
|
+
</Popup.Popper>
|
|
47
|
+
</Popup>
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const TransferClosePopup = () => {
|
|
52
|
+
const model = usePopupModel();
|
|
53
|
+
|
|
54
|
+
useCloseOnEscape(model);
|
|
55
|
+
useInitialFocus(model);
|
|
56
|
+
useReturnFocus(model);
|
|
57
|
+
useFocusTrap(model);
|
|
58
|
+
useTransferOnFullscreenEnter(model);
|
|
59
|
+
useTransferOnFullscreenExit(model);
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Popup model={model}>
|
|
63
|
+
<Popup.Target>Open Transfer Popup</Popup.Target>
|
|
64
|
+
<Popup.Popper>
|
|
65
|
+
<Popup.Card width={400} padding="s">
|
|
66
|
+
<Popup.CloseIcon aria-label="Close" />
|
|
67
|
+
<Popup.Heading>Transfer Popup</Popup.Heading>
|
|
68
|
+
<Popup.Body>
|
|
69
|
+
<p>
|
|
70
|
+
When in fullscreen, the escape key will be highjacked by the browser to exit
|
|
71
|
+
fullscreen and <code>useCloseOnEscape</code> hook will not receive the escape key. To
|
|
72
|
+
close when fullscreen is exited, use the <code>useTransferOnFullscreenExit</code>{' '}
|
|
73
|
+
hook.
|
|
74
|
+
</p>
|
|
75
|
+
</Popup.Body>
|
|
76
|
+
<Popup.CloseButton>Close</Popup.CloseButton>
|
|
77
|
+
</Popup.Card>
|
|
78
|
+
</Popup.Popper>
|
|
79
|
+
</Popup>
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export default () => {
|
|
84
|
+
// you could make this a hook depending on which fullscreen library your application uses
|
|
85
|
+
const fullscreenElementRef = React.useRef<HTMLDivElement>();
|
|
86
|
+
const isFullscreen = useIsFullscreen();
|
|
87
|
+
|
|
88
|
+
const enterFullScreen = () => {
|
|
89
|
+
screenfull.request(fullscreenElementRef.current);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const exitFullscreen = () => {
|
|
93
|
+
screenfull.exit();
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<>
|
|
98
|
+
<SecondaryButton onClick={enterFullScreen}>Open Fullscreen</SecondaryButton>
|
|
99
|
+
<Flex
|
|
100
|
+
ref={fullscreenElementRef}
|
|
101
|
+
alignItems="center"
|
|
102
|
+
justifyContent="center"
|
|
103
|
+
background="white"
|
|
104
|
+
>
|
|
105
|
+
<HStack spacing="s">
|
|
106
|
+
<SelfClosePopup />
|
|
107
|
+
<TransferClosePopup />
|
|
108
|
+
{isFullscreen ? (
|
|
109
|
+
<SecondaryButton onClick={exitFullscreen}>Exit fullscreen</SecondaryButton>
|
|
110
|
+
) : null}
|
|
111
|
+
</HStack>
|
|
112
|
+
</Flex>
|
|
113
|
+
</>
|
|
114
|
+
);
|
|
115
|
+
};
|
|
@@ -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} />
|