@workday/canvas-kit-docs 6.9.0-next.0 → 6.9.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. package/dist/commonjs/index.js +13 -6
  2. package/dist/commonjs/lib/Specifications.d.ts.map +1 -1
  3. package/dist/commonjs/lib/Specifications.js +3 -1
  4. package/dist/commonjs/lib/docs.js +1 -0
  5. package/dist/commonjs/lib/specs.js +259 -2
  6. package/dist/es6/lib/Specifications.d.ts.map +1 -1
  7. package/dist/es6/lib/specs.js +259 -2
  8. package/dist/mdx/{4.0-MIGRATION-GUIDE.mdx → 4.0-UPGRADE-GUIDE.mdx} +1 -1
  9. package/dist/mdx/{5.0-MIGRATION-GUIDE.mdx → 5.0-UPGRADE-GUIDE.mdx} +3 -3
  10. package/dist/mdx/{6.0-MIGRATION-GUIDE.mdx → 6.0-UPGRADE-GUIDE.mdx} +4 -4
  11. package/dist/mdx/7.0-UPGRADE-GUIDE.mdx +1006 -0
  12. package/dist/mdx/COMPOUND_COMPONENTS.mdx +2 -2
  13. package/dist/mdx/CONTRIBUTING.mdx +2 -2
  14. package/dist/mdx/TESTING.mdx +1 -1
  15. package/dist/mdx/changelog.stories.mdx +1 -0
  16. package/dist/mdx/labs-react/search-form/examples/Basic.tsx +4 -2
  17. package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +4 -2
  18. package/dist/mdx/labs-react/search-form/examples/Grow.tsx +4 -2
  19. package/dist/mdx/labs-react/search-form/examples/RTL.tsx +4 -2
  20. package/dist/mdx/labs-react/search-form/examples/Theming.tsx +4 -2
  21. package/dist/mdx/preview-react/_examples/SidePanelWithOverlay.mdx +8 -0
  22. package/dist/mdx/preview-react/_examples/examples/SidePanelWithOverlay.tsx +31 -0
  23. package/dist/mdx/preview-react/_examples/examples/TextInputWithFormik.tsx +3 -3
  24. package/dist/mdx/preview-react/form-field/examples/Custom.tsx +4 -5
  25. package/dist/mdx/preview-react/menu/Menu.mdx +1 -1
  26. package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +2 -2
  27. package/dist/mdx/preview-react/menu/examples/Icons.tsx +0 -1
  28. package/dist/mdx/preview-react/pill/Pill.mdx +241 -0
  29. package/dist/mdx/preview-react/pill/examples/Basic.tsx +18 -0
  30. package/dist/mdx/preview-react/pill/examples/WithAvatar.tsx +21 -0
  31. package/dist/mdx/preview-react/pill/examples/WithCount.tsx +9 -0
  32. package/dist/mdx/preview-react/pill/examples/WithList.tsx +31 -0
  33. package/dist/mdx/preview-react/pill/examples/WithReadOnly.tsx +15 -0
  34. package/dist/mdx/preview-react/pill/examples/WithRemovable.tsx +25 -0
  35. package/dist/mdx/preview-react/pill/examples/test-avatar.png +0 -0
  36. package/dist/mdx/preview-react/side-panel/SidePanel.mdx +5 -3
  37. package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +16 -22
  38. package/dist/mdx/preview-react/side-panel/examples/Basic.tsx +9 -14
  39. package/dist/mdx/preview-react/side-panel/examples/ExternalControl.tsx +9 -13
  40. package/dist/mdx/preview-react/side-panel/examples/HiddenName.tsx +1 -1
  41. package/dist/mdx/preview-react/side-panel/examples/OnExpandedChange.tsx +1 -1
  42. package/dist/mdx/preview-react/side-panel/examples/OnStateTransition.tsx +1 -1
  43. package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +17 -24
  44. package/dist/mdx/preview-react/side-panel/examples/Variant.tsx +9 -14
  45. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +2 -1
  46. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +6 -4
  47. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +1 -1
  48. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +2 -1
  49. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +6 -4
  50. package/dist/mdx/preview-react/text-input/examples/RefForwarding.tsx +1 -1
  51. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +2 -1
  52. package/dist/mdx/react/_examples/SegmentedControlWithText.mdx +12 -0
  53. package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +7 -6
  54. package/dist/mdx/react/_examples/examples/PageHeader.tsx +5 -5
  55. package/dist/mdx/react/_examples/examples/SegmentControlWithText.tsx +119 -0
  56. package/dist/mdx/react/action-bar/ActionBar.mdx +126 -23
  57. package/dist/mdx/react/action-bar/examples/Basic.tsx +7 -4
  58. package/dist/mdx/react/action-bar/examples/DeleteAction.tsx +15 -0
  59. package/dist/mdx/react/action-bar/examples/Icons.tsx +18 -0
  60. package/dist/mdx/react/action-bar/examples/OverflowActionBar.tsx +59 -0
  61. package/dist/mdx/react/banner/Banner.mdx +203 -19
  62. package/dist/mdx/react/banner/PropTables.splitprops.tsx +39 -0
  63. package/dist/mdx/react/banner/examples/ActionText.tsx +8 -1
  64. package/dist/mdx/react/banner/examples/Basic.tsx +8 -1
  65. package/dist/mdx/react/banner/examples/Error.tsx +8 -1
  66. package/dist/mdx/react/banner/examples/RefForwarding.tsx +25 -0
  67. package/dist/mdx/react/banner/examples/Sticky.tsx +12 -7
  68. package/dist/mdx/react/banner/examples/StickyAnimation.tsx +64 -0
  69. package/dist/mdx/react/banner/examples/StickyRTL.tsx +35 -0
  70. package/dist/mdx/react/banner/examples/ThemedAlert.tsx +28 -0
  71. package/dist/mdx/react/banner/examples/ThemedError.tsx +29 -0
  72. package/dist/mdx/react/button/button/Button.mdx +3 -3
  73. package/dist/mdx/react/button/button/Hyperlink.mdx +72 -0
  74. package/dist/mdx/react/button/button/examples/ExternalHyperlink.tsx +7 -0
  75. package/dist/mdx/react/button/button/examples/ExternalHyperlinkInverse.tsx +12 -0
  76. package/dist/mdx/react/button/button/examples/Hyperlink.tsx +5 -0
  77. package/dist/mdx/react/button/button/examples/HyperlinkInverse.tsx +12 -0
  78. package/dist/mdx/react/button/button/examples/Primary.tsx +11 -3
  79. package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +11 -3
  80. package/dist/mdx/react/button/button/examples/Secondary.tsx +11 -3
  81. package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +11 -3
  82. package/dist/mdx/react/button/button/examples/Tertiary.tsx +9 -4
  83. package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +12 -3
  84. package/dist/mdx/react/card/card.mdx +2 -2
  85. package/dist/mdx/react/card/examples/Depth.tsx +1 -1
  86. package/dist/mdx/react/checkbox/Checkbox.mdx +7 -0
  87. package/dist/mdx/react/checkbox/examples/Indeterminate.tsx +1 -1
  88. package/dist/mdx/react/checkbox/examples/Inverse.tsx +22 -0
  89. package/dist/mdx/react/checkbox/examples/RefForwarding.tsx +1 -1
  90. package/dist/mdx/react/collection/Collection.mdx +136 -0
  91. package/dist/mdx/react/collection/examples/Basic.tsx +12 -0
  92. package/dist/mdx/react/collection/examples/BasicVirtual.tsx +24 -0
  93. package/dist/mdx/react/collection/examples/DynamicItems.tsx +20 -0
  94. package/dist/mdx/react/collection/examples/IdentifiedItems.tsx +12 -0
  95. package/dist/mdx/react/collection/examples/MultiSelection.tsx +56 -0
  96. package/dist/mdx/react/collection/examples/RovingFocus.tsx +39 -0
  97. package/dist/mdx/react/collection/examples/Selection.tsx +58 -0
  98. package/dist/mdx/react/color-picker/color-input/ColorInput.mdx +2 -2
  99. package/dist/mdx/react/color-picker/color-preview/ColorPreview.mdx +2 -2
  100. package/dist/mdx/{labs-react/common → react/layout}/Box.mdx +3 -6
  101. package/dist/mdx/{labs-react → react}/layout/Flex.mdx +24 -27
  102. package/dist/mdx/{labs-react → react}/layout/Stack.mdx +98 -146
  103. package/dist/mdx/{labs-react/common → react/layout}/examples/As.tsx +1 -1
  104. package/dist/mdx/{labs-react/common → react/layout}/examples/Border.tsx +1 -1
  105. package/dist/mdx/{labs-react/common → react/layout}/examples/Color.tsx +1 -1
  106. package/dist/mdx/{labs-react/common → react/layout}/examples/Depth.tsx +9 -3
  107. package/dist/mdx/{labs-react → react}/layout/examples/Flex/FlexCard.tsx +2 -3
  108. package/dist/mdx/{labs-react → react}/layout/examples/Flex/FlexLayout.tsx +1 -1
  109. package/dist/mdx/{labs-react → react}/layout/examples/Flex/Usage.tsx +2 -3
  110. package/dist/mdx/{labs-react/common → react/layout}/examples/FlexItem.tsx +1 -2
  111. package/dist/mdx/{labs-react/common → react/layout}/examples/Layout.tsx +1 -1
  112. package/dist/mdx/{labs-react/common → react/layout}/examples/Position.tsx +1 -1
  113. package/dist/mdx/{labs-react → react}/layout/examples/PropTables.splitprops.tsx +1 -1
  114. package/dist/mdx/{labs-react/common → react/layout}/examples/Ref.tsx +1 -1
  115. package/dist/mdx/{labs-react/common → react/layout}/examples/Space.tsx +1 -1
  116. package/dist/mdx/{labs-react → react}/layout/examples/Stack/BasicStack.tsx +1 -1
  117. package/dist/mdx/{labs-react → react}/layout/examples/Stack/HStackCards.tsx +2 -3
  118. package/dist/mdx/{labs-react → react}/layout/examples/Stack/NestedStacks.tsx +1 -1
  119. package/dist/mdx/react/layout/examples/Stack/ShouldWrapChildren.tsx +28 -0
  120. package/dist/mdx/{labs-react → react}/layout/examples/Stack/StackCard.tsx +2 -2
  121. package/dist/mdx/{labs-react → react}/layout/examples/Stack/StackItems.tsx +1 -2
  122. package/dist/mdx/{labs-react → react}/layout/examples/Stack/VStackCards.tsx +2 -2
  123. package/dist/mdx/react/menu/Menu.mdx +123 -0
  124. package/dist/mdx/react/menu/examples/Basic.tsx +26 -0
  125. package/dist/mdx/react/menu/examples/ContextMenu.tsx +25 -0
  126. package/dist/mdx/react/menu/examples/Icons.tsx +41 -0
  127. package/dist/mdx/react/modal/Modal.mdx +34 -11
  128. package/dist/mdx/react/modal/examples/Basic.tsx +4 -2
  129. package/dist/mdx/react/modal/examples/BodyOverflow.tsx +56 -0
  130. package/dist/mdx/react/modal/examples/CustomFocus.tsx +4 -2
  131. package/dist/mdx/react/modal/examples/FullOverflow.tsx +55 -0
  132. package/dist/mdx/react/modal/examples/ReturnFocus.tsx +5 -3
  133. package/dist/mdx/react/modal/examples/WithoutCloseIcon.tsx +4 -2
  134. package/dist/mdx/react/pagination/PropTables.splitprops.tsx +1 -1
  135. package/dist/mdx/react/pagination/pagination.mdx +14 -14
  136. package/dist/mdx/react/popup/Popup.mdx +2 -1
  137. package/dist/mdx/react/popup/examples/Basic.tsx +1 -1
  138. package/dist/mdx/react/popup/examples/FocusRedirect.tsx +3 -2
  139. package/dist/mdx/react/popup/examples/FocusTrap.tsx +1 -1
  140. package/dist/mdx/react/popup/examples/FullScreen.tsx +1 -1
  141. package/dist/mdx/react/popup/examples/InitialFocus.tsx +4 -2
  142. package/dist/mdx/react/popup/examples/MultiplePopups.tsx +1 -1
  143. package/dist/mdx/react/popup/examples/NestedPopups.tsx +18 -18
  144. package/dist/mdx/react/popup/examples/RTL.tsx +6 -3
  145. package/dist/mdx/react/radio/Radio.mdx +7 -0
  146. package/dist/mdx/react/radio/examples/Inverse.tsx +23 -0
  147. package/dist/mdx/react/segmented-control/SegmentedControl.mdx +2 -2
  148. package/dist/mdx/react/segmented-control/examples/Basic.tsx +13 -11
  149. package/dist/mdx/react/skeleton/examples/Basic.tsx +1 -1
  150. package/dist/mdx/react/skeleton/examples/Color.tsx +1 -2
  151. package/dist/mdx/react/skeleton/examples/Simulation.tsx +11 -10
  152. package/dist/mdx/react/status-indicator/StatusIndicator.mdx +12 -0
  153. package/dist/mdx/react/status-indicator/examples/MaxWidth.tsx +30 -0
  154. package/dist/mdx/react/tabs/Tabs.mdx +14 -17
  155. package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +6 -13
  156. package/dist/mdx/react/tabs/examples/HoistedModel.tsx +8 -8
  157. package/dist/mdx/react/tabs/examples/Icons.tsx +4 -4
  158. package/dist/mdx/react/tabs/examples/NamedTabs.tsx +10 -10
  159. package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +4 -8
  160. package/dist/mdx/react/tabs/examples/SinglePanel.tsx +3 -3
  161. package/dist/mdx/react/text-input/examples/Basic.tsx +3 -0
  162. package/dist/mdx/react/tooltip/Tooltip.mdx +2 -2
  163. package/dist/mdx/react/tooltip/examples/Default.tsx +2 -2
  164. package/dist/mdx/react/tooltip/examples/UseTooltip.tsx +2 -2
  165. package/package.json +9 -17
  166. package/dist/mdx/labs-react/common/examples/PropTables.splitprops.tsx +0 -91
  167. package/dist/mdx/labs-react/layout/examples/Stack/ShouldWrapChildren.tsx +0 -33
  168. package/dist/mdx/react/button/icon-button/IconButton.mdx +0 -103
  169. package/dist/mdx/react/button/icon-button/examples/Circle.tsx +0 -6
  170. package/dist/mdx/react/button/icon-button/examples/CircleFilled.tsx +0 -8
  171. package/dist/mdx/react/button/icon-button/examples/Inverse.tsx +0 -20
  172. package/dist/mdx/react/button/icon-button/examples/InverseFilled.tsx +0 -20
  173. package/dist/mdx/react/button/icon-button/examples/MirroredIcon.tsx +0 -11
  174. package/dist/mdx/react/button/icon-button/examples/Plain.tsx +0 -8
  175. package/dist/mdx/react/button/icon-button/examples/Square.tsx +0 -8
  176. package/dist/mdx/react/button/icon-button/examples/SquareFilled.tsx +0 -8
  177. package/dist/mdx/react/button/icon-button/examples/Toggleable.tsx +0 -20
  178. package/ts3.5/dist/commonjs/index.d.ts +0 -4
  179. package/ts3.5/dist/commonjs/lib/Specifications.d.ts +0 -6
  180. package/ts3.5/dist/commonjs/lib/docs.d.ts +0 -5
  181. package/ts3.5/dist/commonjs/lib/specs.d.ts +0 -16
  182. package/ts3.5/dist/es6/index.d.ts +0 -4
  183. package/ts3.5/dist/es6/lib/Specifications.d.ts +0 -6
  184. package/ts3.5/dist/es6/lib/docs.d.ts +0 -5
  185. package/ts3.5/dist/es6/lib/specs.d.ts +0 -16
@@ -0,0 +1,123 @@
1
+ import {Specifications} from '@workday/canvas-kit-docs';
2
+ import {Menu} from '@workday/canvas-kit-react/menu';
3
+
4
+ import Basic from './examples/Basic';
5
+ import ContextMenu from './examples/ContextMenu';
6
+ import Icons from './examples/Icons';
7
+
8
+
9
+ # Canvas Kit Menu
10
+
11
+ `Menu` displays a list of options when triggered by an action or UI element like an icon or button.
12
+
13
+ [> Workday Design Reference](https://design.workday.com/components/popups/menus)
14
+
15
+ ## Installation
16
+
17
+ ```sh
18
+ yarn add @workday/canvas-kit-react
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ### Basic Example
24
+
25
+ `Menu` is typically triggered by an action such as pressing a button. The `Menu` comes with a
26
+ `Target` subcomponent and a Popup.
27
+
28
+ <ExampleCodeBlock code={Basic} />
29
+
30
+ `Menu` will automatically focus on the cursor item (first item by default). The `Menu` uses a menu
31
+ model which composes a list model and a popup model and sets up accessibility features for you.
32
+
33
+ `Menu` follows the
34
+ [Actions Menu pattern](https://www.w3.org/TR/wai-aria-practices/examples/menu-button/menu-button-actions.html)
35
+ using roving tabindex. Below is table of supported keyboard shortcuts and associated actions.
36
+
37
+ | Key | Action |
38
+ | ------------------ | ------------------------------------------------------------------------------------------------------------ |
39
+ | `Enter` or `Space` | Activates the menu item and then closes the menu |
40
+ | `Escape` | Closes the menu |
41
+ | `Up Arrow` | Moves focus to the previous menu item – if focus is on first menu item, it moves focus to the last menu item |
42
+ | `Down Arrow` | Moves focus to the next menu item – if focus is on last menu item, it moves focus to the first menu item |
43
+ | `Home` | Moves focus to the first menu item |
44
+ | `End` | Moves focus to the last menu item |
45
+
46
+ ### Context Menu
47
+
48
+ <ExampleCodeBlock code={ContextMenu} />
49
+
50
+ ### Icons
51
+
52
+ <ExampleCodeBlock code={Icons} />
53
+
54
+ ## Components
55
+
56
+ ### Menu
57
+
58
+ ### Usage
59
+
60
+ `Menu` is a combination of as popup and a list. It usually has some type of target element that
61
+ expands/collapses the menu and a `menu` role and and several `menuitem` roles. Focus is managed uses
62
+ [roving tabindex](https://w3c.github.io/aria-practices/#kbd_roving_tabindex) for maximum
63
+ compatibility. A `Menu` can have two modes: `single` and `multiple`. This mode determines both how
64
+ many items can be selected as well as the default behavior when a menuitem is clicked. For the
65
+ `single` mode, selecting a `menuitem` will select and close the menu. For the `multiple` mode,
66
+ clicking a `menuitem` will toggle selection and will not close the menu.
67
+
68
+ #### Props
69
+
70
+ <ArgsTable of={Menu} />
71
+
72
+ #### Usage
73
+
74
+ Like all compound components, the `Menu` component is a container component. It is responsible for
75
+ putting a `MenuModel` in the React context for all the menu subcomponents. You can either pass this
76
+ component model config or a "hoisted" model.
77
+
78
+ With model config:
79
+
80
+ ```tsx
81
+ <Menu mode="multiple">{/* Child components */}</Menu>
82
+ ```
83
+
84
+ With a hoisted model:
85
+
86
+ ```tsx
87
+ const model = useMenuModel({
88
+ mode: 'multiple',
89
+ });
90
+
91
+ // we now have access to `model.state` and `model.events`
92
+
93
+ <Menu model={model}>{/* Child components */}</Menu>;
94
+ ```
95
+
96
+ ### Menu.Target
97
+
98
+ #### Usage
99
+
100
+ `Menu.Target` is similar to all `Popup.Target` types. The component only provides behavior and no
101
+ styling. The `as` prop is used to determine which component is rendered. This component should
102
+ forward the `ref` and apply any additional props directly to an element. The default `as` is a
103
+ `SecondaryButton`. Any Canvas Kit component should work with an `as`.
104
+
105
+ An example changing to a `PrimaryButton`
106
+
107
+ ```tsx
108
+ <Menu.Target as={PrimaryButton}>Primary Button Text</Menu.Target>
109
+ ```
110
+
111
+ This element will apply `aria-haspopup` and `aria-expanded` to inform screen readers there's a popup
112
+ associated with the element.
113
+
114
+ #### Props
115
+
116
+ Undocumented props are spread to the element provided by the `as` which is a `SecondaryButton` by
117
+ default.
118
+
119
+ <ArgsTable of={Menu.Target} />
120
+
121
+ ## Specifications
122
+
123
+ <Specifications file="Menu.spec.ts" name="Menu" />
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+
3
+ import {Menu} from '@workday/canvas-kit-react/menu';
4
+
5
+ export default () => {
6
+ const [selected, setSelected] = React.useState('');
7
+ return (
8
+ <Menu onSelect={data => setSelected(data.id)}>
9
+ <Menu.Target>Open Menu</Menu.Target>
10
+ <Menu.Popper>
11
+ <Menu.Card>
12
+ <Menu.List>
13
+ <Menu.Item>First Item</Menu.Item>
14
+ <Menu.Item>Second Item</Menu.Item>
15
+ <Menu.Divider />
16
+ <Menu.Item>Third Item (with a really, really, really long label)</Menu.Item>
17
+ <Menu.Item>Fourth Item</Menu.Item>
18
+ </Menu.List>
19
+ </Menu.Card>
20
+ </Menu.Popper>
21
+ <p>
22
+ Selected: <span data-testid="output">{selected}</span>
23
+ </p>
24
+ </Menu>
25
+ );
26
+ };
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+
3
+ import {Menu} from '@workday/canvas-kit-react/menu';
4
+
5
+ export default () => {
6
+ const [selected, setSelected] = React.useState('');
7
+ return (
8
+ <Menu onSelect={data => setSelected(data.id)}>
9
+ <Menu.TargetContext>Open Menu</Menu.TargetContext>
10
+ <Menu.Popper>
11
+ <Menu.Card>
12
+ <Menu.List>
13
+ <Menu.Item>First Item</Menu.Item>
14
+ <Menu.Item>Second Item</Menu.Item>
15
+ <Menu.Item>Third Item (with a really, really, really long label)</Menu.Item>
16
+ <Menu.Item>Fourth Item</Menu.Item>
17
+ </Menu.List>
18
+ </Menu.Card>
19
+ </Menu.Popper>
20
+ <p>
21
+ Selected: <span data-testid="output">{selected}</span>
22
+ </p>
23
+ </Menu>
24
+ );
25
+ };
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import {
3
+ setupIcon,
4
+ uploadCloudIcon,
5
+ userIcon,
6
+ taskContactIcon,
7
+ } from '@workday/canvas-system-icons-web';
8
+ import {Menu} from '@workday/canvas-kit-react/menu';
9
+
10
+ export default () => {
11
+ return (
12
+ <Menu>
13
+ <Menu.Card>
14
+ <Menu.List>
15
+ <Menu.Item>
16
+ <Menu.Item.Icon icon={uploadCloudIcon} />
17
+ <Menu.Item.Text>First Item</Menu.Item.Text>
18
+ </Menu.Item>
19
+ <Menu.Item>
20
+ <Menu.Item.Icon icon={setupIcon} />
21
+ <Menu.Item.Text>Second Item (with a really really really long label)</Menu.Item.Text>
22
+ </Menu.Item>
23
+ <Menu.Item aria-disabled>
24
+ <Menu.Item.Icon icon={uploadCloudIcon} />
25
+ <Menu.Item.Text>Third Item</Menu.Item.Text>
26
+ <Menu.Item.Icon icon={taskContactIcon} />
27
+ </Menu.Item>
28
+ <Menu.Item>
29
+ <Menu.Item.Icon icon={userIcon} />
30
+ <Menu.Item.Text></Menu.Item.Text>
31
+ </Menu.Item>
32
+ <Menu.Divider />
33
+ <Menu.Item>
34
+ <Menu.Item.Icon icon={taskContactIcon} />
35
+ <Menu.Item.Text>Fifth Item (with divider)</Menu.Item.Text>
36
+ </Menu.Item>
37
+ </Menu.List>
38
+ </Menu.Card>
39
+ </Menu>
40
+ );
41
+ };
@@ -6,6 +6,8 @@ import WithoutCloseIcon from './examples/WithoutCloseIcon';
6
6
  import CustomFocus from './examples/CustomFocus';
7
7
  import ReturnFocus from './examples/ReturnFocus';
8
8
  import CustomTarget from './examples/CustomTarget';
9
+ import BodyOverflow from './examples/BodyOverflow';
10
+ import FullOverflow from './examples/FullOverflow';
9
11
 
10
12
 
11
13
  # Canvas Kit Modal
@@ -78,6 +80,25 @@ requires a `label` prop.
78
80
 
79
81
  <ExampleCodeBlock code={CustomTarget} />
80
82
 
83
+ ### Body Content Overflow
84
+
85
+ The Modal automatically handles overflowing content inside the `Modal.Body` element. If contents are
86
+ larger than the browser's height will allow, the content will overflow with a scrollbar. You may
87
+ need to restrict the height of your browser to observe the overflow.
88
+
89
+ <ExampleCodeBlock code={BodyOverflow} />
90
+
91
+ ### Full overlay scrolling
92
+
93
+ If content is large, scrolling the entire overlay container is an option. Use the
94
+ `Modal.OverflowOverlay` component instead of the `Modal.Overlay` component. The `Modal.Card`'s
95
+ `maxHeight` and `height` will need to be reset to `inherit` to prevent any internal overflow.
96
+
97
+ This has the effect of scrolling the heading, close button, and any action buttons. If this type of
98
+ scrolling behavior is not desired, try the [Body Content Overflow](#body-content-overflow) method.
99
+
100
+ <ExampleCodeBlock code={FullOverflow} />
101
+
81
102
  ## Components
82
103
 
83
104
  ### Modal
@@ -94,12 +115,13 @@ container component will build a default one using `useModalModel`. `Modal` is a
94
115
 
95
116
  The `Modal.Target` is any element that is meant to show the Modal. The default component rendered by
96
117
  this component is a `SecondaryButton` element. You can override this by passing the desired
97
- component via `as`. Many examples above use `as={DeleteButton}`. If you want to render an
98
- `IconButton` instead, use `as={IconButton}`. The `Modal.Target` is an alias for `Popup.Target` and
99
- uses the `usePopupTarget` hook, which provides a `ref` and an `onClick`. The provided `ref` will be
100
- used to return focus to this element when the Modal is closed. If the provided component does not
101
- forward the `ref` to an element, the fallback is to capture an element in the `onClick`. This can be
102
- overridden by providing a `returnFocusRef` to the model.
118
+ component via `as`. Many examples above use `as={DeleteButton}`. If you want to render an icon
119
+ button instead, pass an icon to the the `icon` prop and pass no children to the button. The
120
+ `Modal.Target` is an alias for `Popup.Target` and uses the `usePopupTarget` hook, which provides a
121
+ `ref` and an `onClick`. The provided `ref` will be used to return focus to this element when the
122
+ Modal is closed. If the provided component does not forward the `ref` to an element, the fallback is
123
+ to capture an element in the `onClick`. This can be overridden by providing a `returnFocusRef` to
124
+ the model.
103
125
 
104
126
  <ArgsTable of={Modal.Target} />
105
127
 
@@ -137,8 +159,8 @@ cannot use this component. The default element is an `h2` and can be changed via
137
159
 
138
160
  The `Modal.CloseIcon` is the 'X' icon in the top corner of a Modal. It always requires an
139
161
  `aria-label` which must be translated. It uses the `usePopupCloseIcon` which adds an `onClick` that
140
- will close the Modal. The default component rendered is an `IconButton` can be changed via the `as`.
141
- All props that `IconButton` takes are also available by default.
162
+ will close the Modal. The default component rendered is an `TertiaryButton` with just an icon that
163
+ can be changed via the `as`. All props that `TertiaryButton` takes are also available by default.
142
164
 
143
165
  <ArgsTable of={Modal.CloseIcon} />
144
166
 
@@ -150,9 +172,10 @@ Modal. It uses the `usePopupCloseButton` behavior hook which adds an `onClick` t
150
172
  you'll have to hoist the model. The default component rendered is a `SecondaryButton` and can be
151
173
  changed via the `as` prop. This component doesn't contain any styles and will take on the styles of
152
174
  the component given to it. For example, `as={DeleteButton}` will render a delete button.
153
- `as={IconButton}` will render an `IconButton`. If you give it a base element like `as="button"`, you
154
- are responsible for styling the element. You can add your own `onClick` to perform side effects.
155
- Your callback will be merged with the `onClick` that closes the Modal.
175
+ `as={TertiaryButton}` with no children and an `icon` will render a `TertiaryButton` styled icon
176
+ button. If you give it a base element like `as="button"`, you are responsible for styling the
177
+ element. You can add your own `onClick` to perform side effects. Your callback will be merged with
178
+ the `onClick` that closes the Modal.
156
179
 
157
180
  <ArgsTable of={Modal.CloseButton} />
158
181
 
@@ -2,7 +2,7 @@ import React from 'react';
2
2
 
3
3
  import {Modal} from '@workday/canvas-kit-react/modal';
4
4
  import {DeleteButton} from '@workday/canvas-kit-react/button';
5
- import {HStack} from '@workday/canvas-kit-labs-react';
5
+ import {HStack, Box} from '@workday/canvas-kit-react/layout';
6
6
 
7
7
  export default () => {
8
8
  const handleDelete = () => {
@@ -17,7 +17,9 @@ export default () => {
17
17
  <Modal.CloseIcon aria-label="Close" />
18
18
  <Modal.Heading>Delete Item</Modal.Heading>
19
19
  <Modal.Body>
20
- <p>Are you sure you want to delete the item?</p>
20
+ <Box as="p" marginTop={0} marginBottom="m">
21
+ Are you sure you want to delete the item?
22
+ </Box>
21
23
  <HStack spacing="s">
22
24
  <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
23
25
  Delete
@@ -0,0 +1,56 @@
1
+ import React from 'react';
2
+
3
+ import {Modal} from '@workday/canvas-kit-react/modal';
4
+ import {DeleteButton} from '@workday/canvas-kit-react/button';
5
+ import {HStack, VStack, Stack, Box} from '@workday/canvas-kit-react/layout';
6
+ import {space} from '@workday/canvas-kit-react/tokens';
7
+
8
+ export default () => {
9
+ const handleDelete = () => {
10
+ console.log('Deleted item');
11
+ };
12
+
13
+ return (
14
+ <Modal>
15
+ <Modal.Target as={DeleteButton}>Delete Item</Modal.Target>
16
+ <Modal.Overlay>
17
+ <Modal.Card>
18
+ <Modal.CloseIcon aria-label="Close" />
19
+ <Modal.Heading>Delete Item</Modal.Heading>
20
+ <Modal.Body>
21
+ <p>Are you sure you want to delete the item?</p>
22
+ <p>Are you sure you want to delete the item?</p>
23
+ <p>Are you sure you want to delete the item?</p>
24
+ <p>Are you sure you want to delete the item?</p>
25
+ <p>Are you sure you want to delete the item?</p>
26
+ <p>Are you sure you want to delete the item?</p>
27
+ <p>Are you sure you want to delete the item?</p>
28
+ <p>Are you sure you want to delete the item?</p>
29
+ <p>Are you sure you want to delete the item?</p>
30
+ <p>Are you sure you want to delete the item?</p>
31
+ <p>Are you sure you want to delete the item?</p>
32
+ <p>Are you sure you want to delete the item?</p>
33
+ <p>Are you sure you want to delete the item?</p>
34
+ <p>Are you sure you want to delete the item?</p>
35
+ <p>Are you sure you want to delete the item?</p>
36
+ <p>Are you sure you want to delete the item?</p>
37
+ <p>Are you sure you want to delete the item?</p>
38
+ <p>Are you sure you want to delete the item?</p>
39
+ <p>Are you sure you want to delete the item?</p>
40
+ <p>Are you sure you want to delete the item?</p>
41
+ <p>Are you sure you want to delete the item?</p>
42
+ <p>Are you sure you want to delete the item?</p>
43
+ <p>Are you sure you want to delete the item?</p>
44
+ <p>Are you sure you want to delete the item?</p>
45
+ </Modal.Body>
46
+ <HStack spacing="s" paddingTop="s">
47
+ <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
48
+ Delete
49
+ </Modal.CloseButton>
50
+ <Modal.CloseButton>Cancel</Modal.CloseButton>
51
+ </HStack>
52
+ </Modal.Card>
53
+ </Modal.Overlay>
54
+ </Modal>
55
+ );
56
+ };
@@ -3,7 +3,7 @@ import {Modal, useModalModel} from '@workday/canvas-kit-react/modal';
3
3
  import {DeleteButton} from '@workday/canvas-kit-react/button';
4
4
  import FormField from '@workday/canvas-kit-react/form-field';
5
5
  import TextInput from '@workday/canvas-kit-react/text-input';
6
- import {HStack} from '@workday/canvas-kit-labs-react';
6
+ import {HStack, Box} from '@workday/canvas-kit-react/layout';
7
7
 
8
8
  export default () => {
9
9
  const ref = React.useRef<HTMLInputElement>(null);
@@ -24,7 +24,9 @@ export default () => {
24
24
  <Modal.CloseIcon aria-label="Close" />
25
25
  <Modal.Heading>Delete Item</Modal.Heading>
26
26
  <Modal.Body>
27
- <p>Enter name to confirm deletion</p>
27
+ <Box as="p" marginTop={0} marginBottom="m">
28
+ Enter name to confirm deletion
29
+ </Box>
28
30
  <FormField label="Item name">
29
31
  <TextInput ref={ref} value={value} onChange={e => setValue(e.currentTarget.value)} />
30
32
  </FormField>
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+
3
+ import {Modal} from '@workday/canvas-kit-react/modal';
4
+ import {DeleteButton} from '@workday/canvas-kit-react/button';
5
+ import {HStack} from '@workday/canvas-kit-react/layout';
6
+
7
+ export default () => {
8
+ const handleDelete = () => {
9
+ console.log('Deleted item');
10
+ };
11
+
12
+ return (
13
+ <Modal>
14
+ <Modal.Target as={DeleteButton}>Delete Item</Modal.Target>
15
+ <Modal.OverflowOverlay>
16
+ <Modal.Card maxHeight="inherit" height="inherit">
17
+ <Modal.CloseIcon aria-label="Close" />
18
+ <Modal.Heading>Delete Item</Modal.Heading>
19
+ <Modal.Body>
20
+ <p>Are you sure you want to delete the item?</p>
21
+ <p>Are you sure you want to delete the item?</p>
22
+ <p>Are you sure you want to delete the item?</p>
23
+ <p>Are you sure you want to delete the item?</p>
24
+ <p>Are you sure you want to delete the item?</p>
25
+ <p>Are you sure you want to delete the item?</p>
26
+ <p>Are you sure you want to delete the item?</p>
27
+ <p>Are you sure you want to delete the item?</p>
28
+ <p>Are you sure you want to delete the item?</p>
29
+ <p>Are you sure you want to delete the item?</p>
30
+ <p>Are you sure you want to delete the item?</p>
31
+ <p>Are you sure you want to delete the item?</p>
32
+ <p>Are you sure you want to delete the item?</p>
33
+ <p>Are you sure you want to delete the item?</p>
34
+ <p>Are you sure you want to delete the item?</p>
35
+ <p>Are you sure you want to delete the item?</p>
36
+ <p>Are you sure you want to delete the item?</p>
37
+ <p>Are you sure you want to delete the item?</p>
38
+ <p>Are you sure you want to delete the item?</p>
39
+ <p>Are you sure you want to delete the item?</p>
40
+ <p>Are you sure you want to delete the item?</p>
41
+ <p>Are you sure you want to delete the item?</p>
42
+ <p>Are you sure you want to delete the item?</p>
43
+ <p>Are you sure you want to delete the item?</p>
44
+ </Modal.Body>
45
+ <HStack spacing="s">
46
+ <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
47
+ Delete
48
+ </Modal.CloseButton>
49
+ <Modal.CloseButton>Cancel</Modal.CloseButton>
50
+ </HStack>
51
+ </Modal.Card>
52
+ </Modal.OverflowOverlay>
53
+ </Modal>
54
+ );
55
+ };
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import {Modal, useModalModel} from '@workday/canvas-kit-react/modal';
3
- import {DeleteButton, SecondaryButton} from '@workday/canvas-kit-react/button';
3
+ import {DeleteButton} from '@workday/canvas-kit-react/button';
4
4
  import {FormField} from '@workday/canvas-kit-react/form-field';
5
- import {HStack} from '@workday/canvas-kit-labs-react/layout';
5
+ import {HStack, Box} from '@workday/canvas-kit-react/layout';
6
6
  import {Select} from '@workday/canvas-kit-preview-react/select';
7
7
 
8
8
  export default () => {
@@ -39,7 +39,9 @@ export default () => {
39
39
  <Modal.CloseIcon aria-label="Close" />
40
40
  <Modal.Heading>Delete Item</Modal.Heading>
41
41
  <Modal.Body>
42
- <p>Are you sure you want to delete the item?</p>
42
+ <Box as="p" marginTop={0} marginBottom="m">
43
+ Are you sure you want to delete the item?
44
+ </Box>
43
45
  <HStack spacing="s">
44
46
  <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
45
47
  Delete
@@ -10,7 +10,7 @@ import {
10
10
  useDisableBodyScroll,
11
11
  } from '@workday/canvas-kit-react/popup';
12
12
  import {DeleteButton} from '@workday/canvas-kit-react/button';
13
- import {HStack} from '@workday/canvas-kit-labs-react';
13
+ import {HStack, Box} from '@workday/canvas-kit-react/layout';
14
14
 
15
15
  export default () => {
16
16
  const model = usePopupModel();
@@ -32,7 +32,9 @@ export default () => {
32
32
  <Modal.Card>
33
33
  <Modal.Heading>Delete Item</Modal.Heading>
34
34
  <Modal.Body>
35
- <p>Are you sure you want to delete the item?</p>
35
+ <Box as="p" marginTop={0} marginBottom="m">
36
+ Are you sure you want to delete the item?
37
+ </Box>
36
38
  <HStack spacing="s">
37
39
  <Modal.CloseButton as={DeleteButton} onClick={handleDelete}>
38
40
  Delete
@@ -11,7 +11,7 @@ import {
11
11
  export const PaginationHoistedComponent = (_: {model: PaginationModel}) => <div />;
12
12
 
13
13
  // <ArgsTable of={Pagination.PageButton} /> generates a props table with
14
- // IconButton props. Use this dummy component instead to limit the props shown.
14
+ // Button props. Use this dummy component instead to limit the props shown.
15
15
  export const PageButtonComponent = (_: {pageNumber: number}) => <div />;
16
16
 
17
17
  // <ArgsTable of={Pagination.PageListComponent} /> generates a very large props
@@ -163,7 +163,7 @@ Undocumented props are spread to the underlying `<div>` element.
163
163
 
164
164
  #### Usage
165
165
 
166
- `Pagination.JumpToFirstButton` is an `IconButton` that subscribes to the `Pagination` context. This
166
+ `Pagination.JumpToFirstButton` is an `Button` that subscribes to the `Pagination` context. This
167
167
  allows it to know when to disable and set `currentPage` to the first page.
168
168
 
169
169
  ```tsx
@@ -176,14 +176,14 @@ Undocumented props are spread to the underlying `<button>` element. Note that yo
176
176
  `aria-label` to meet accessibility standards. We recommend setting it to `First` or the translated
177
177
  equivalent.
178
178
 
179
- `Pagination.JumpToFirstButton` supports all `IconButton` props.
179
+ `Pagination.JumpToFirstButton` supports all `TertiaryButton` props.
180
180
 
181
181
  ### Pagination.StepToPreviousButton
182
182
 
183
183
  #### Usage
184
184
 
185
- `Pagination.StepToPreviousButton` is an `IconButton` that subscribes to the `Pagination` context.
186
- This allows it to know when to disable and decrement the `currentPage`.
185
+ `Pagination.StepToPreviousButton` is an `TertiaryButton` that renders an icon that subscribes to the
186
+ `Pagination` context. This allows it to know when to disable and decrement the `currentPage`.
187
187
 
188
188
  ```tsx
189
189
  <Pagination.StepToPreviousButton aria-label="Previous" />
@@ -195,14 +195,14 @@ Undocumented props are spread to the underlying `<button>` element. Note that yo
195
195
  `aria-label` to meet accessibility standards. We recommend setting it to `Previous` or the
196
196
  translated equivalent.
197
197
 
198
- `Pagination.StepToPreviousButton` supports all `IconButton` props.
198
+ `Pagination.StepToPreviousButton` supports all `TertiaryButton` props.
199
199
 
200
200
  ### Pagination.StepToNextButton
201
201
 
202
202
  #### Usage
203
203
 
204
- `Pagination.StepToNextButton` is an `IconButton` that subscribes to the `Pagination` context. This
205
- allows it to know when to disable and increment the `currentPage`.
204
+ `Pagination.StepToNextButton` is an `TertiaryButton` that subscribes to the `Pagination` context.
205
+ This allows it to know when to disable and increment the `currentPage`.
206
206
 
207
207
  ```tsx
208
208
  <Pagination.StepToNextButton aria-label="Next" />
@@ -214,14 +214,14 @@ Undocumented props are spread to the underlying `<button>` element. Note that yo
214
214
  `aria-label` to meet accessibility standards. We recommend setting it to `Next` or the translated
215
215
  equivalent.
216
216
 
217
- `Pagination.StepToNextButton` supports all `IconButton` props.
217
+ `Pagination.StepToNextButton` supports all `TertiaryButton` props.
218
218
 
219
219
  ### Pagination.JumpToLastButton
220
220
 
221
221
  #### Usage
222
222
 
223
- `Pagination.JumpToLastButton` is an `IconButton` that subscribes to the `Pagination` context. This
224
- allows it to know when to disable and set `currentPage` to the last page.
223
+ `Pagination.JumpToLastButton` is an `TertiaryButton` that renders an icon that subscribes to the
224
+ `Pagination` context. This allows it to know when to disable and set `currentPage` to the last page.
225
225
 
226
226
  ```tsx
227
227
  <Pagination.JumpToLastButton aria-label="Last" />
@@ -233,7 +233,7 @@ Undocumented props are spread to the underlying `<button>` element. Note that yo
233
233
  `aria-label` to meet accessibility standards. We recommend setting it to `Last` or the translated
234
234
  equivalent.
235
235
 
236
- `Pagination.JumpToLastButton` supports all `IconButton` props.
236
+ `Pagination.JumpToLastButton` supports all `TertiaryButton` props.
237
237
 
238
238
  ### Pagination.PageList
239
239
 
@@ -285,8 +285,8 @@ Undocumented props are spread to the underlying `<li>` element.
285
285
 
286
286
  #### Usage
287
287
 
288
- `Pagination.PageButton` is an `IconButton` that subscribes to the `Pagination` context. This allows
289
- it to update the `currentPage` and set the `toggled` styling when it is the current item.
288
+ `Pagination.PageButton` is a `Button` that subscribes to the `Pagination` context. This allows it to
289
+ update the `currentPage` and set the `toggled` styling when it is the current item.
290
290
 
291
291
  `Pagination.PageButton` will render `pageNumber` as its children.
292
292
 
@@ -302,7 +302,7 @@ translated equivalent.
302
302
 
303
303
  <ArgsTable of={PageButtonComponent} />
304
304
 
305
- `Pagination.PageButton` also supports all `IconButton` props.
305
+ `Pagination.PageButton` also supports all `Button` props.
306
306
 
307
307
  ### Pagination.GoToForm
308
308
 
@@ -214,7 +214,8 @@ container component isn't needed.
214
214
  A `Popup.Target` is any element that is meant to show the Popup. The default component rendered by
215
215
  this component is a `SecondaryButton` element. You can override this by passing the desired
216
216
  component via `as`. Many examples above use `as={DeleteButton}`. If you want to render an
217
- `IconButton` instead, use `as={IconButton}`. The behavior hook used is called `usePopupTarget`.
217
+ `TertiaryButton` instead, use `as={TertiaryButton}`. The behavior hook used is called
218
+ `usePopupTarget`.
218
219
 
219
220
  ```tsx
220
221
  const model = usePopupModel();
@@ -9,7 +9,7 @@ import {
9
9
  useInitialFocus,
10
10
  useReturnFocus,
11
11
  } from '@workday/canvas-kit-react/popup';
12
- import {HStack} from '@workday/canvas-kit-labs-react';
12
+ import {HStack} from '@workday/canvas-kit-react/layout';
13
13
 
14
14
  export default () => {
15
15
  const model = usePopupModel();
@@ -10,7 +10,7 @@ import {
10
10
  useFocusRedirect,
11
11
  usePopupModel,
12
12
  } from '@workday/canvas-kit-react/popup';
13
- import {HStack} from '@workday/canvas-kit-labs-react/layout';
13
+ import {HStack} from '@workday/canvas-kit-react/layout';
14
14
 
15
15
  export default () => {
16
16
  const model = usePopupModel();
@@ -49,7 +49,8 @@ export default () => {
49
49
  <Popup.CloseButton as={DeleteButton} onClick={handleDelete}>
50
50
  Delete
51
51
  </Popup.CloseButton>
52
- <Popup.CloseButton>Cancel</Popup.CloseButton>
52
+ {/* Disabled elements should not be focusable and focus should move to the next focusable element */}
53
+ <Popup.CloseButton disabled>Cancel</Popup.CloseButton>
53
54
  </HStack>
54
55
  </Popup.Card>
55
56
  </Popup.Popper>
@@ -10,7 +10,7 @@ import {
10
10
  useReturnFocus,
11
11
  usePopupModel,
12
12
  } from '@workday/canvas-kit-react/popup';
13
- import {HStack} from '@workday/canvas-kit-labs-react/layout';
13
+ import {HStack} from '@workday/canvas-kit-react/layout';
14
14
 
15
15
  export default () => {
16
16
  const model = usePopupModel();