@workday/canvas-kit-docs 6.8.9 → 6.9.0-next.2

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 (189) 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 +229 -6
  6. package/dist/es6/lib/Specifications.d.ts.map +1 -1
  7. package/dist/es6/lib/specs.js +229 -6
  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/changelog.stories.mdx +1 -0
  15. package/dist/mdx/labs-react/search-form/examples/Basic.tsx +4 -2
  16. package/dist/mdx/labs-react/search-form/examples/CustomTheme.tsx +4 -2
  17. package/dist/mdx/labs-react/search-form/examples/Grow.tsx +4 -2
  18. package/dist/mdx/labs-react/search-form/examples/RTL.tsx +4 -2
  19. package/dist/mdx/labs-react/search-form/examples/Theming.tsx +4 -2
  20. package/dist/mdx/preview-react/_examples/SidePanelWithOverlay.mdx +8 -0
  21. package/dist/mdx/preview-react/_examples/examples/SidePanelWithOverlay.tsx +31 -0
  22. package/dist/mdx/preview-react/_examples/examples/TextInputWithFormik.tsx +3 -3
  23. package/dist/mdx/preview-react/form-field/examples/Custom.tsx +4 -5
  24. package/dist/mdx/preview-react/menu/Menu.mdx +1 -1
  25. package/dist/mdx/preview-react/menu/examples/ContextMenu.tsx +2 -2
  26. package/dist/mdx/preview-react/menu/examples/Icons.tsx +0 -1
  27. package/dist/mdx/preview-react/pill/Pill.mdx +241 -0
  28. package/dist/mdx/preview-react/pill/examples/Basic.tsx +18 -0
  29. package/dist/mdx/preview-react/pill/examples/WithAvatar.tsx +21 -0
  30. package/dist/mdx/preview-react/pill/examples/WithCount.tsx +9 -0
  31. package/dist/mdx/preview-react/pill/examples/WithList.tsx +31 -0
  32. package/dist/mdx/preview-react/pill/examples/WithReadOnly.tsx +15 -0
  33. package/dist/mdx/preview-react/pill/examples/WithRemovable.tsx +25 -0
  34. package/dist/mdx/preview-react/pill/examples/test-avatar.png +0 -0
  35. package/dist/mdx/preview-react/side-panel/SidePanel.mdx +5 -3
  36. package/dist/mdx/preview-react/side-panel/examples/AlwaysOpen.tsx +16 -22
  37. package/dist/mdx/preview-react/side-panel/examples/Basic.tsx +9 -14
  38. package/dist/mdx/preview-react/side-panel/examples/ExternalControl.tsx +9 -13
  39. package/dist/mdx/preview-react/side-panel/examples/HiddenName.tsx +1 -1
  40. package/dist/mdx/preview-react/side-panel/examples/OnExpandedChange.tsx +1 -1
  41. package/dist/mdx/preview-react/side-panel/examples/OnStateTransition.tsx +1 -1
  42. package/dist/mdx/preview-react/side-panel/examples/RightOrigin.tsx +17 -24
  43. package/dist/mdx/preview-react/side-panel/examples/Variant.tsx +9 -14
  44. package/dist/mdx/preview-react/text-area/examples/Alert.tsx +2 -1
  45. package/dist/mdx/preview-react/text-area/examples/HiddenLabel.tsx +6 -4
  46. package/dist/mdx/preview-react/text-area/examples/RefForwarding.tsx +1 -1
  47. package/dist/mdx/preview-react/text-input/examples/Alert.tsx +2 -1
  48. package/dist/mdx/preview-react/text-input/examples/HiddenLabel.tsx +6 -4
  49. package/dist/mdx/preview-react/text-input/examples/RefForwarding.tsx +1 -1
  50. package/dist/mdx/preview-react/text-input/examples/ThemedAlert.tsx +2 -1
  51. package/dist/mdx/react/_examples/SegmentedControlWithText.mdx +12 -0
  52. package/dist/mdx/react/_examples/examples/GlobalHeader.tsx +7 -6
  53. package/dist/mdx/react/_examples/examples/PageHeader.tsx +5 -5
  54. package/dist/mdx/react/_examples/examples/SegmentControlWithText.tsx +119 -0
  55. package/dist/mdx/react/action-bar/ActionBar.mdx +126 -23
  56. package/dist/mdx/react/action-bar/examples/Basic.tsx +7 -4
  57. package/dist/mdx/react/action-bar/examples/DeleteAction.tsx +15 -0
  58. package/dist/mdx/react/action-bar/examples/Icons.tsx +18 -0
  59. package/dist/mdx/react/action-bar/examples/OverflowActionBar.tsx +59 -0
  60. package/dist/mdx/react/banner/Banner.mdx +203 -19
  61. package/dist/mdx/react/banner/PropTables.splitprops.tsx +39 -0
  62. package/dist/mdx/react/banner/examples/ActionText.tsx +8 -1
  63. package/dist/mdx/react/banner/examples/Basic.tsx +8 -1
  64. package/dist/mdx/react/banner/examples/Error.tsx +8 -1
  65. package/dist/mdx/react/banner/examples/RefForwarding.tsx +25 -0
  66. package/dist/mdx/react/banner/examples/Sticky.tsx +12 -7
  67. package/dist/mdx/react/banner/examples/StickyAnimation.tsx +64 -0
  68. package/dist/mdx/react/banner/examples/StickyRTL.tsx +35 -0
  69. package/dist/mdx/react/banner/examples/ThemedAlert.tsx +28 -0
  70. package/dist/mdx/react/banner/examples/ThemedError.tsx +29 -0
  71. package/dist/mdx/react/button/button/Button.mdx +3 -3
  72. package/dist/mdx/react/button/button/Hyperlink.mdx +72 -0
  73. package/dist/mdx/react/button/button/examples/ExternalHyperlink.tsx +7 -0
  74. package/dist/mdx/react/button/button/examples/ExternalHyperlinkInverse.tsx +12 -0
  75. package/dist/mdx/react/button/button/examples/Hyperlink.tsx +5 -0
  76. package/dist/mdx/react/button/button/examples/HyperlinkInverse.tsx +12 -0
  77. package/dist/mdx/react/button/button/examples/Primary.tsx +11 -3
  78. package/dist/mdx/react/button/button/examples/PrimaryInverse.tsx +11 -3
  79. package/dist/mdx/react/button/button/examples/Secondary.tsx +11 -3
  80. package/dist/mdx/react/button/button/examples/SecondaryInverse.tsx +11 -3
  81. package/dist/mdx/react/button/button/examples/Tertiary.tsx +9 -4
  82. package/dist/mdx/react/button/button/examples/TertiaryInverse.tsx +12 -3
  83. package/dist/mdx/react/card/card.mdx +2 -2
  84. package/dist/mdx/react/card/examples/Depth.tsx +1 -1
  85. package/dist/mdx/react/checkbox/Checkbox.mdx +7 -0
  86. package/dist/mdx/react/checkbox/examples/Indeterminate.tsx +1 -1
  87. package/dist/mdx/react/checkbox/examples/Inverse.tsx +22 -0
  88. package/dist/mdx/react/checkbox/examples/RefForwarding.tsx +1 -1
  89. package/dist/mdx/react/collection/Collection.mdx +358 -0
  90. package/dist/mdx/react/collection/Collection.splitprops.tsx +19 -0
  91. package/dist/mdx/react/collection/examples/Basic.tsx +12 -0
  92. package/dist/mdx/react/collection/examples/BasicGrid.tsx +46 -0
  93. package/dist/mdx/react/collection/examples/BasicVirtual.tsx +24 -0
  94. package/dist/mdx/react/collection/examples/DynamicItems.tsx +20 -0
  95. package/dist/mdx/react/collection/examples/IdentifiedItems.tsx +12 -0
  96. package/dist/mdx/react/collection/examples/MultiSelection.tsx +56 -0
  97. package/dist/mdx/react/collection/examples/RovingFocus.tsx +39 -0
  98. package/dist/mdx/react/collection/examples/Selection.tsx +58 -0
  99. package/dist/mdx/react/collection/examples/WrappingGrid.tsx +48 -0
  100. package/dist/mdx/react/color-picker/color-input/ColorInput.mdx +2 -2
  101. package/dist/mdx/react/color-picker/color-preview/ColorPreview.mdx +2 -2
  102. package/dist/mdx/{labs-react/common → react/layout}/Box.mdx +3 -6
  103. package/dist/mdx/{labs-react → react}/layout/Flex.mdx +24 -27
  104. package/dist/mdx/{labs-react → react}/layout/Stack.mdx +98 -146
  105. package/dist/mdx/{labs-react/common → react/layout}/examples/As.tsx +1 -1
  106. package/dist/mdx/{labs-react/common → react/layout}/examples/Border.tsx +1 -1
  107. package/dist/mdx/{labs-react/common → react/layout}/examples/Color.tsx +1 -1
  108. package/dist/mdx/{labs-react/common → react/layout}/examples/Depth.tsx +9 -3
  109. package/dist/mdx/{labs-react → react}/layout/examples/Flex/FlexCard.tsx +2 -3
  110. package/dist/mdx/{labs-react → react}/layout/examples/Flex/FlexLayout.tsx +1 -1
  111. package/dist/mdx/{labs-react → react}/layout/examples/Flex/Usage.tsx +2 -3
  112. package/dist/mdx/{labs-react/common → react/layout}/examples/FlexItem.tsx +1 -2
  113. package/dist/mdx/{labs-react/common → react/layout}/examples/Layout.tsx +1 -1
  114. package/dist/mdx/{labs-react/common → react/layout}/examples/Position.tsx +1 -1
  115. package/dist/mdx/{labs-react → react}/layout/examples/PropTables.splitprops.tsx +1 -1
  116. package/dist/mdx/{labs-react/common → react/layout}/examples/Ref.tsx +1 -1
  117. package/dist/mdx/{labs-react/common → react/layout}/examples/Space.tsx +1 -1
  118. package/dist/mdx/{labs-react → react}/layout/examples/Stack/BasicStack.tsx +1 -1
  119. package/dist/mdx/{labs-react → react}/layout/examples/Stack/HStackCards.tsx +2 -3
  120. package/dist/mdx/{labs-react → react}/layout/examples/Stack/NestedStacks.tsx +1 -1
  121. package/dist/mdx/react/layout/examples/Stack/ShouldWrapChildren.tsx +28 -0
  122. package/dist/mdx/{labs-react → react}/layout/examples/Stack/StackCard.tsx +2 -2
  123. package/dist/mdx/{labs-react → react}/layout/examples/Stack/StackItems.tsx +1 -2
  124. package/dist/mdx/{labs-react → react}/layout/examples/Stack/VStackCards.tsx +2 -2
  125. package/dist/mdx/react/menu/Menu.mdx +123 -0
  126. package/dist/mdx/react/menu/examples/Basic.tsx +26 -0
  127. package/dist/mdx/react/menu/examples/ContextMenu.tsx +25 -0
  128. package/dist/mdx/react/menu/examples/Icons.tsx +41 -0
  129. package/dist/mdx/react/modal/Modal.mdx +34 -11
  130. package/dist/mdx/react/modal/examples/Basic.tsx +4 -2
  131. package/dist/mdx/react/modal/examples/BodyOverflow.tsx +56 -0
  132. package/dist/mdx/react/modal/examples/CustomFocus.tsx +4 -2
  133. package/dist/mdx/react/modal/examples/FullOverflow.tsx +55 -0
  134. package/dist/mdx/react/modal/examples/ReturnFocus.tsx +5 -3
  135. package/dist/mdx/react/modal/examples/WithoutCloseIcon.tsx +4 -2
  136. package/dist/mdx/react/pagination/PropTables.splitprops.tsx +1 -1
  137. package/dist/mdx/react/pagination/pagination.mdx +14 -14
  138. package/dist/mdx/react/popup/Popup.mdx +2 -1
  139. package/dist/mdx/react/popup/examples/Basic.tsx +1 -1
  140. package/dist/mdx/react/popup/examples/FocusRedirect.tsx +1 -1
  141. package/dist/mdx/react/popup/examples/FocusTrap.tsx +1 -1
  142. package/dist/mdx/react/popup/examples/FullScreen.tsx +1 -1
  143. package/dist/mdx/react/popup/examples/InitialFocus.tsx +4 -2
  144. package/dist/mdx/react/popup/examples/MultiplePopups.tsx +1 -1
  145. package/dist/mdx/react/popup/examples/NestedPopups.tsx +18 -18
  146. package/dist/mdx/react/popup/examples/RTL.tsx +6 -3
  147. package/dist/mdx/react/radio/Radio.mdx +7 -0
  148. package/dist/mdx/react/radio/examples/Basic.tsx +11 -2
  149. package/dist/mdx/react/radio/examples/Inverse.tsx +23 -0
  150. package/dist/mdx/react/segmented-control/SegmentedControl.mdx +2 -2
  151. package/dist/mdx/react/segmented-control/examples/Basic.tsx +13 -11
  152. package/dist/mdx/react/skeleton/examples/Basic.tsx +1 -1
  153. package/dist/mdx/react/skeleton/examples/Color.tsx +1 -2
  154. package/dist/mdx/react/skeleton/examples/Simulation.tsx +31 -30
  155. package/dist/mdx/react/status-indicator/StatusIndicator.mdx +12 -0
  156. package/dist/mdx/react/status-indicator/examples/MaxWidth.tsx +30 -0
  157. package/dist/mdx/react/tabs/Tabs.mdx +14 -17
  158. package/dist/mdx/react/tabs/TabsModel.splitprops.tsx +7 -3
  159. package/dist/mdx/react/tabs/examples/DynamicTabs.tsx +6 -13
  160. package/dist/mdx/react/tabs/examples/HoistedModel.tsx +8 -8
  161. package/dist/mdx/react/tabs/examples/Icons.tsx +4 -4
  162. package/dist/mdx/react/tabs/examples/NamedTabs.tsx +10 -10
  163. package/dist/mdx/react/tabs/examples/OverflowTabs.tsx +4 -8
  164. package/dist/mdx/react/tabs/examples/SinglePanel.tsx +3 -3
  165. package/dist/mdx/react/text-input/examples/Basic.tsx +3 -0
  166. package/dist/mdx/react/tooltip/Tooltip.mdx +2 -2
  167. package/dist/mdx/react/tooltip/examples/Default.tsx +2 -2
  168. package/dist/mdx/react/tooltip/examples/UseTooltip.tsx +2 -2
  169. package/package.json +9 -17
  170. package/dist/mdx/labs-react/common/examples/PropTables.splitprops.tsx +0 -91
  171. package/dist/mdx/labs-react/layout/examples/Stack/ShouldWrapChildren.tsx +0 -33
  172. package/dist/mdx/react/button/icon-button/IconButton.mdx +0 -103
  173. package/dist/mdx/react/button/icon-button/examples/Circle.tsx +0 -6
  174. package/dist/mdx/react/button/icon-button/examples/CircleFilled.tsx +0 -8
  175. package/dist/mdx/react/button/icon-button/examples/Inverse.tsx +0 -20
  176. package/dist/mdx/react/button/icon-button/examples/InverseFilled.tsx +0 -20
  177. package/dist/mdx/react/button/icon-button/examples/MirroredIcon.tsx +0 -11
  178. package/dist/mdx/react/button/icon-button/examples/Plain.tsx +0 -8
  179. package/dist/mdx/react/button/icon-button/examples/Square.tsx +0 -8
  180. package/dist/mdx/react/button/icon-button/examples/SquareFilled.tsx +0 -8
  181. package/dist/mdx/react/button/icon-button/examples/Toggleable.tsx +0 -20
  182. package/ts3.5/dist/commonjs/index.d.ts +0 -4
  183. package/ts3.5/dist/commonjs/lib/Specifications.d.ts +0 -6
  184. package/ts3.5/dist/commonjs/lib/docs.d.ts +0 -5
  185. package/ts3.5/dist/commonjs/lib/specs.d.ts +0 -16
  186. package/ts3.5/dist/es6/index.d.ts +0 -4
  187. package/ts3.5/dist/es6/lib/Specifications.d.ts +0 -6
  188. package/ts3.5/dist/es6/lib/docs.d.ts +0 -5
  189. package/ts3.5/dist/es6/lib/specs.d.ts +0 -16
@@ -0,0 +1,1006 @@
1
+ # Canvas Kit 7.0 Upgrade Guide
2
+
3
+ This guide contains breaking changes in Canvas Kit v7. Please
4
+ [reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you have
5
+ any questions.
6
+
7
+ - [Codemod](#codemod)
8
+ - [General Changes](#general-changes)
9
+ - [Dependency Upgrades](#dependency-upgrades)
10
+ - [Model Changes](#model-changes)
11
+ - [Tokens](#tokens)
12
+ - [Depth](#depth)
13
+ - [Components](#components)
14
+ - [Component Deprecations](#component-deprecations)
15
+ - [Component Promotions](#component-promotions)
16
+ - [Action Bar](#action-bar)
17
+ - [Banner](#banner)
18
+ - [Button](#button)
19
+ - [Icon](#icon)
20
+ - [Popper](#popper)
21
+ - [Popup](#popup)
22
+ - [Segmented Control](#segmented-control)
23
+ - [Side Panel](#side-panel)
24
+ - [Status Indicator](#status-indicator)
25
+ - [Tabs](#tabs)
26
+
27
+ ## Codemod
28
+
29
+ Please use our [codemod package](https://github.com/Workday/canvas-kit/tree/master/modules/codemod)
30
+ to automatically update your code to work with many of the breaking changes as you upgrade from
31
+ Canvas Kit v6 to v7:
32
+
33
+ ```sh
34
+ > npx @workday/canvas-kit-codemod v7 [path]
35
+ ```
36
+
37
+ > Note: This codemod only works on `.js`, `.jsx`, `.ts`, and `.tsx` extensions. You may need to make
38
+ > some manual changes in other file types (`.json`, `.mdx`, `.md`, etc.).
39
+
40
+ > Note: You may need to run your linter after executing the codemod, as its resulting formatting
41
+ > (spacing, quotes, etc.) may not match your project's styling.
42
+
43
+ **Breaking changes handled by this codemod will be marked with a 🤖.**
44
+
45
+ **Please verify all changes made by the codemod. As a safety precaution, we recommend committing the
46
+ changes from the codemod as a single isolated commit (separate from other changes) so you can
47
+ rollback more easily if necessary.**
48
+
49
+ [Let us know](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) if you
50
+ encounter any issues or use cases that we've missed.
51
+
52
+ ## General Changes
53
+
54
+ ### Dependency Upgrades
55
+
56
+ We've upgraded to Emotion 11 and React 17 in v7. This allows teams to upgrade to newer versions of
57
+ Emotion and React without needing to maintain older versions in order to use Canvas Kit.
58
+
59
+ As part of this upgrade, we've removed use of the `/** @jsx jsx */` pragma and `css` prop within
60
+ Canvas Kit. See our [React 17 discussion](https://github.com/Workday/canvas-kit/discussions/1455)
61
+ and [corresponding PR](https://github.com/Workday/canvas-kit/pull/1409) for more information on why
62
+ we made this change. Consumers may continue to use the `css` prop.
63
+
64
+ To use v7, you'll need to upgrade the following dependencies:
65
+
66
+ - React 16.14 OR React 17.X for backwards compatibility on JSX transform if you're using Babel or
67
+ TypeScript to compile code
68
+ - Emotion 11
69
+ - TypeScript 4.1 or higher, if applicable
70
+ - Babel 7.9 or higher, if applicable
71
+ - An Enzyme adapter for React 17, if applicable
72
+
73
+ > We no longer support TypeScript 3.5-3.9. Previously, we used `downlevel-dts` to support TypeScript
74
+ > 3.5+ while using TypeScript 3.8 features, but `downlevel-dts` does not support features we use in
75
+ > TypeScript 4.1. TypeScript 4.1 was released in November 2020, and we feel it is time to move
76
+ > forward. Reach out if you experience issues upgrading your TypeScript version. In our experience,
77
+ > TypeScript 4.1 found a few more errors than TypeScript 3.8, but the upgrade was manageable.
78
+
79
+ Please note that you may also need to update any side effect dependencies or linting packages with
80
+ this update.
81
+
82
+ View our [React 17](https://github.com/Workday/canvas-kit/discussions/1455) and
83
+ [Emotion 11](https://github.com/Workday/canvas-kit/discussions/1453) discussions to learn more about
84
+ any gotchas or tips and tricks with these upgrades. And of course, feel free to contribute to the
85
+ discussion with any questions or learnings of your own!
86
+
87
+ ---
88
+
89
+ ### Model Changes
90
+
91
+ #### Guards and Callbacks
92
+
93
+ We've changed the signature of model event guards and callbacks. In v6, the parameters were in an
94
+ object. This was a less than ideal developer experience as IntelliSense isn't engaged immediately
95
+ and we don't plan on adding any additional parameters to guard and callback functions. We've removed
96
+ the object wrapper.
97
+
98
+ ```tsx
99
+ // v6
100
+ const model = useTabsModel({
101
+ onSelect({data: {id}, prevState}) {
102
+ console.log(id, prevState);
103
+ },
104
+ });
105
+
106
+ // v7
107
+ const model = useTabsModel({
108
+ onSelect({id}, prevState) {
109
+ console.log(id, prevState);
110
+ },
111
+ });
112
+ ```
113
+
114
+ 🤖 The codemod will handle this change for you automatically.
115
+
116
+ #### Model Implementation
117
+
118
+ If you don't extend models, you can skip this section.
119
+
120
+ In v6 we supported TypeScript 3.8 which limited the way types could be inferred and defined. v7
121
+ requires TypeScript 4.1 which introduced
122
+ [Template Literal Types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html).
123
+ This means guards and callbacks no longer need to be manually defined via an `eventMap`. Event maps
124
+ were a stopgap, manual, and prone to errors in defining them. Not all events have guards or
125
+ callbacks, and there's no way other than manual review to verify their existence. Template Literal
126
+ Types allow us to properly type guards and callbacks without event maps. The previous types forced
127
+ `data` to be an object. We've since dropped that restriction. You can still only pass a single
128
+ argument to events. If you need additional information, use an object.
129
+
130
+ This change also allowed us to remove a lot of boilerplate associated with models without
131
+ sacrificing type safety. This change doesn't affect most use cases, but will affect those who
132
+ extended a model. We created a new `createModelHook` utility function to help set up types.
133
+
134
+ ##### v6
135
+
136
+ ```ts
137
+ export type MyState = {
138
+ value: string;
139
+ };
140
+
141
+ export type MyEvents = {
142
+ updateValue(data: {value: string}): void; // enforced that `data` is an object even if we only need to pass a string
143
+ };
144
+
145
+ export type MyModel = Model<MyState, MyEvents>;
146
+
147
+ export const myEventMap = createEventMap<MyEvents>()({
148
+ guards: {
149
+ shouldUpdateValue: 'updateValue', // easy to forget or make a mistake on guard name
150
+ },
151
+ callbacks: {
152
+ onUpdateValue: 'updateValue',
153
+ },
154
+ });
155
+
156
+ export type MyBaseConfig = {
157
+ initialValue?: string;
158
+ };
159
+
160
+ export type MyConfig = MyBaseConfig & Partial<ToModelConfig<MyState, MyEvents, typeof myEventMap>>;
161
+
162
+ const useMyModel = (config: MyConfig = {}): MyModel => {
163
+ const [value, setValue] = React.useState(config.initialValue || '');
164
+
165
+ const state = {value};
166
+
167
+ // useEventMap is used to wrap the event object with guards and callbacks according to the event map
168
+ const events = useEventMap(myEventMap, state, config, {
169
+ updateValue(data) {
170
+ setValue(data.value);
171
+ },
172
+ });
173
+
174
+ return {state, events};
175
+ };
176
+ ```
177
+
178
+ ##### v7
179
+
180
+ ```tsx
181
+ const useMyModel = createModelHook({
182
+ defaultConfig: {
183
+ initialValue: '',
184
+ },
185
+ })(config => {
186
+ const [value, setValue] = React.useState(config.initialValue); // default is already handled
187
+
188
+ const state = {value};
189
+
190
+ const events = {
191
+ updateValue(value: string) {
192
+ // doesn't need to be an object anymore
193
+ setValue(value);
194
+ },
195
+ };
196
+
197
+ return {state, events};
198
+ });
199
+ ```
200
+
201
+ Note the large reduction in TypeScript type boilerplate. In this example, the only place that
202
+ TypeScript syntax exists is in the `updateValue` function definition. This allows better collocating
203
+ of types and values. Also note that `useEventMap` is no longer needed. `createModelHook` will
204
+ automatically wrap the `events` returned to call guards and callbacks when appropriate. Today, this
205
+ is done by creating a new events object. Once we drop IE11 support, this will be done via a proxy
206
+ instead. `createModelHook` handles all type inference so you don't need to explicitly type
207
+ everything. `createModelHook` also attaches React Context directly to the hook along with
208
+ `defaultConfig` and `requiredConfig` for model extension.
209
+
210
+ If you extended a model, you'll notice all those types are no longer being exported. You'll have to
211
+ use this new utility function. Here's an example we found in the wild:
212
+
213
+ ##### v6
214
+
215
+ ```tsx
216
+ import {
217
+ BasePopupModelConfig,
218
+ createEventMap,
219
+ Model,
220
+ popupEventMap,
221
+ PopupEvents,
222
+ PopupModelConfig,
223
+ PopupState,
224
+ ToModelConfig,
225
+ useCloseOnEscape,
226
+ useEventMap,
227
+ useFocusTrap,
228
+ useInitialFocus,
229
+ usePopupModel,
230
+ useReturnFocus,
231
+ } from '@workday/canvas-kit-react';
232
+
233
+ type MyModalState = PopupState & {
234
+ showOverlay: boolean;
235
+ };
236
+
237
+ type MyModalEvents = PopupEvents;
238
+
239
+ const myModalEventMap = createEventMap<MyModalEvents>()({
240
+ guards: {
241
+ ...popupEventMap.guards,
242
+ },
243
+ callbacks: {
244
+ ...popupEventMap.callbacks,
245
+ },
246
+ });
247
+
248
+ type MyBaseModalConfig = BasePopupModelConfig & {
249
+ showOverlay?: boolean;
250
+ };
251
+
252
+ type MyModalModel = Model<MyModalState, MyModalEvents>;
253
+
254
+ type MyConfig = MyBaseConfig &
255
+ Partial<ToModelConfig<MyModalState, MyModalEvents, typeof myModalEventMap>>;
256
+
257
+ export const useMyModalModel = (config: MyConfig = {}): MyModalModel => {
258
+ const [showOverlay] = React.useState(config.showOverlay ?? true);
259
+
260
+ const model = usePopupModel({
261
+ ...config,
262
+ // hook up to a redux store
263
+ onShow(...params) {
264
+ dispatch(setIsModalOpen(true));
265
+ config?.onShow?.(...params);
266
+ },
267
+ onHide(...params) {
268
+ dispatch(setIsModalOpen(false));
269
+ config?.onShow?.(...params);
270
+ },
271
+ });
272
+
273
+ useInitialFocus(model);
274
+ useReturnFocus(model);
275
+ useFocusTrap(model);
276
+ useCloseOnEscape(model);
277
+
278
+ const state = {
279
+ ...model.state,
280
+ showOverlay,
281
+ };
282
+
283
+ const events = useEventMap(myEventMap, state, config, {
284
+ ...model.events,
285
+ });
286
+
287
+ return {state, events};
288
+ };
289
+ ```
290
+
291
+ ##### v7
292
+
293
+ ```ts
294
+ import {
295
+ useCloseOnEscape,
296
+ useEventMap,
297
+ useFocusTrap,
298
+ useInitialFocus,
299
+ usePopupModel,
300
+ useReturnFocus,
301
+ } from '@workday/canvas-kit-react';
302
+
303
+ const useMyModalModel = createModelHook({
304
+ defaultConfig: {
305
+ ...usePopupModel.defaultConfig,
306
+ showOverlay: true,
307
+ },
308
+ requiredConfig: usePopupModel.requiredConfig,
309
+ contextOverride: usePopupModel.Context, // needed to make sure this model uses the same context as the popup model, otherwise it will create a new one
310
+ })(config => {
311
+ // `mergeConfig` takes care of the manual merging we were doing earlier
312
+ const model = usePopupModel(
313
+ usePopupModel.mergeConfig(config, {
314
+ // hook up to a redux store
315
+ onShow() {
316
+ dispatch(setIsModalOpen(true));
317
+ },
318
+ onHide() {
319
+ dispatch(setIsModalOpen(false));
320
+ },
321
+ })
322
+ );
323
+
324
+ useInitialFocus(model);
325
+ useReturnFocus(model);
326
+ useFocusTrap(model);
327
+ useCloseOnEscape(model);
328
+
329
+ const state = {
330
+ ...model.state,
331
+ showOverlay,
332
+ };
333
+
334
+ return {...model, state};
335
+ });
336
+ ```
337
+
338
+ We've eliminated the cumbersome type boilerplate and type imports. The code is more focused on your
339
+ unique logic and less on boilerplate.
340
+
341
+ Given the complex nature of this code, this change is **not** handled by the codemod.
342
+
343
+ ## Tokens
344
+
345
+ ### Depth
346
+
347
+ **Changes:**
348
+
349
+ - Removed `inset` depth
350
+ - Added new depth values: `none` (to remove the default depth from a component), `5` and `6`
351
+ - Updated all depth values: depth now adds only `box-shadow` with two shadows and no border
352
+
353
+ We've also changed the default depth for the following components:
354
+
355
+ - Breadcrumbs (Dropdown Menu): Depth 2 → Depth 3
356
+ - Card: Depth 2 → Depth 1
357
+ - Color Picker (Palette): Depth 2 → Depth 5
358
+ - Combobox: Depth 1 → Depth 3
359
+ - Dialog: Depth 2 → Depth 5
360
+ - Menu: Depth 2 → Depth 3
361
+ - Modal: Depth 2 → Depth 6
362
+ - Popup: Depth 2 → Depth 5
363
+ - Side Panel (Preview, alternate variant): Depth 3 → Depth 5
364
+ - Toast: Depth 2 → Depth 5
365
+
366
+ ## Components
367
+
368
+ ### Component Deprecations
369
+
370
+ #### Deprecation Types
371
+
372
+ There are two types of deprecations: soft and hard.
373
+
374
+ ##### Soft Deprecation
375
+
376
+ A soft-deprecated component is still available with its full functionality, but it will have been
377
+ renamed with a prefix to indicate its soft-deprecated status. It will also include a console warning
378
+ announcing its deprecation. This warning will only be triggered on the component's initial render.
379
+
380
+ Soft-deprecated types and utilities will also be renamed but generally will not trigger a console
381
+ warning.
382
+
383
+ ##### Hard Deprecation
384
+
385
+ A hard-deprecated component or package is no longer available. You will need to follow the method
386
+ prescribed in our upgrade guide to update your application. Please
387
+ [reach out](https://github.com/Workday/canvas-kit/issues/new?labels=bug&template=bug.md) to our team
388
+ directly if you need additional help.
389
+
390
+ #### Cookie Banner
391
+
392
+ We are [hard-deprecating](#hard-deprecation) `CookieBanner`. Please reference this
393
+ [example](https://workday.github.io/canvas-kit/?path=/story/examples-cookiebanner-react--basic) to
394
+ migrate away from `CookieBanner`.
395
+
396
+ #### Page Header
397
+
398
+ We are [hard-deprecating](#hard-deprecation) `PageHeader`. Please reference this
399
+ [example](https://workday.github.io/canvas-kit/?path=/story/examples-pageheader-react--basic) to
400
+ migrate away from `PageHeader`.
401
+
402
+ #### Header / Global Header
403
+
404
+ We are [hard-deprecating](#hard-deprecation) `Header`. Please reference this
405
+ [example](https://workday.github.io/canvas-kit/?path=/story/examples-globalheader-react--basic) to
406
+ migrate away from `Header`.
407
+
408
+ ---
409
+
410
+ ### Component Promotions
411
+
412
+ We've [promoted](https://github.com/Workday/canvas-kit/issues/1395) the following components in v7:
413
+
414
+ - `Box` from `@workday/canvas-kit-labs/common` to `@workday/canvas-kit-react/layout`
415
+ - `Flex` from `@workday/canvas-kit-labs/layout` to `@workday/canvas-kit-react/layout`
416
+ - `Stack` from `@workday/canvas-kit-labs/layout` to `@workday/canvas-kit-react/layout`
417
+
418
+ ```tsx
419
+ // v6
420
+ import {Box} from '@workday/canvas-kit-labs-react/common';
421
+
422
+ // v7
423
+ import {Box} from '@workday/canvas-kit-react/layout';
424
+ ```
425
+
426
+ 🤖 The codemod will update imports for these promoted components.
427
+
428
+ The APIs for these promoted components remain unchanged.
429
+
430
+ ---
431
+
432
+ ### Action Bar
433
+
434
+ The ActionBar API changed to model API to support more generic behaviors to allow for other
435
+ components to support responsive layouts using the same models and behaviors. It also allows to
436
+ implement a responsive layout based on a container width
437
+ ([#1585](https://github.com/Workday/canvas-kit/pull/1585)).
438
+
439
+ ```tsx
440
+ const model = useActionBarModel({
441
+ items: [
442
+ {
443
+ id: 'first',
444
+ text: 'First Action',
445
+ },
446
+ ],
447
+ });
448
+
449
+ <ActionBar model={model} />;
450
+ ```
451
+
452
+ The ActionBar component can now handle responsive containers, but the support is not automatic. You
453
+ must use the dynamic API and provide an overflow menu subcomponent. The dynamic API doesn't know the
454
+ shape of your object, so render props must be used to instruct React how to render each item.
455
+
456
+ ```tsx
457
+ const [items] = React.useState<MyActionItem[]>([
458
+ {
459
+ id: 'first',
460
+ text: 'First Action',
461
+ },
462
+ {
463
+ id: 'second',
464
+ text: 'Second Action',
465
+ },
466
+ {
467
+ id: 'third',
468
+ text: 'Third Action',
469
+ },
470
+ {
471
+ id: 'fourth',
472
+ text: 'Fourth Action',
473
+ },
474
+ {
475
+ id: 'fifth',
476
+ text: 'Fifth Action',
477
+ },
478
+ ]);
479
+
480
+ const model = useActionBarModel({items});
481
+
482
+ <ActionBar model={model}>
483
+ <ActionBar.List>
484
+ {item => <ActionBar.Item onClick={() => console.log(item.id)}>{item.text}</ActionBar.Item>}
485
+ </ActionBar.List>
486
+ <ActionBar.Menu.Popper>
487
+ <ActionBar.Menu.Card maxWidth={300} maxHeight={200}>
488
+ <ActionBar.Menu.List>
489
+ {item => (
490
+ <ActionBar.Menu.Item onClick={() => console.log(item.id)}>
491
+ {item.text}
492
+ </ActionBar.Menu.Item>
493
+ )}
494
+ </ActionBar.Menu.List>
495
+ </ActionBar.Menu.Card>
496
+ </ActionBar.Menu.Popper>
497
+ </ActionBar>;
498
+ ```
499
+
500
+ 🤖 The codemod will remove uses of the `fixed` prop from `ActionBar` and restructure component by
501
+ creating `ActionBar.List` subcomponent and replacing all `ActionBar` children to it.
502
+
503
+ ---
504
+
505
+ ### Banner
506
+
507
+ Banner is now a [compound component](/getting-started/for-developers/resources/compound-components/)
508
+ composed of `Banner.Icon`, `Banner.Label`, and `Banner.ActionText`. This allows direct access to the
509
+ icon, label, and text elements.
510
+
511
+ ```tsx
512
+ // v6
513
+ <Banner label="3 Warnings" actionText="Show Details" variant={Banner.Variant.Sticky} error={Banner.ErrorType.Error} />
514
+
515
+ // v7
516
+ <Banner isSticky={true} hasError={true}>
517
+ <Banner.Icon />
518
+ <Banner.Label>3 Warnings</Banner.Label>
519
+ <Banner.ActionText>Show Details</Banner.ActionText>
520
+ </Banner>
521
+ ```
522
+
523
+ 🤖 The codemod will rewrite your JSX to match the new API.
524
+
525
+ Like all compound components, `Banner` is written using the
526
+ [createComponent](/getting-started/for-developers/resources/creating-compound-components/#disclosurecontent-component)
527
+ utility from our
528
+ [common](https://github.com/Workday/canvas-kit/blob/ff77c5bd83e41c3ab2b9c55e41a8b7c1fde33a1b/modules/react/common/lib/utils/components.ts#L167)
529
+ module; it supports [ref forwarding](https://reactjs.org/docs/forwarding-refs.html) and using the
530
+ `as` prop to change the rendered element.
531
+
532
+ The `variant` prop (which previously accepted `Banner.Variant.Full` or `Banner.Variant.Sticky`) has
533
+ been converted to the boolean `isSticky` prop on the container `Banner` component.
534
+
535
+ Similarly, the `error` prop (which previously accepted `Banner.ErrorType.Alert` or
536
+ `Banner.ErrorType.Error`) has been converted to the boolean `hasError` prop on `Banner`. `Banner`
537
+ now uses the `useThemedPalette` hook which allows you to override its colors using the Canvas theme.
538
+
539
+ The icon is now customizable via the `icon` prop of `Banner.Icon`. Previously, the icon was limited
540
+ to `exclamationTriangleIcon` and `exclamationCircleIcon` for the alert and error states,
541
+ respectively.
542
+
543
+ ---
544
+
545
+ ### Button
546
+
547
+ #### Removal of Icon Button
548
+
549
+ To consolidate Button APIs, we've removed `IconButton` in favor of `SecondaryButton` and
550
+ `TertiaryButton`. The following table shows how `IconButton` variants in v6 map to their
551
+ corresponding buttons in v7.
552
+
553
+ | v6 `IconButton` variant | v7 button (and variant, if necessary) |
554
+ | -------------------------- | ---------------------------------------- |
555
+ | `circle` (default variant) | `TertiaryButton` |
556
+ | `circleFilled` | `SecondaryButton` |
557
+ | `inverse` | `TertiaryButton` with `inverse` variant |
558
+ | `inverseFilled` | `SecondaryButton` with `inverse` variant |
559
+ | `plain` | Unsupported |
560
+ | `square` | Unsupported |
561
+ | `squareFilled` | Unsupported |
562
+
563
+ > Note: See below for more information about how to manually migrate from
564
+ > [unsupported v6 variants](#unsupported-iconbutton-variants).
565
+
566
+ 🤖 Use the codemod to migrate your `IconButton` components in v6 to their corresponding buttons in
567
+ v7:
568
+
569
+ ```tsx
570
+ // v6
571
+ <IconButton icon={plusIcon} />
572
+ <IconButton variant="circleFilled" icon={plusIcon} />
573
+ <IconButton variant="inverse" icon={plusIcon} />
574
+ <IconButton variant="inverseFilled" icon={plusIcon} />
575
+
576
+ // v7
577
+ <TertiaryButton icon={plusIcon} />
578
+ <SecondaryButton icon={plusIcon} />
579
+ <TertiaryButton variant="inverse" icon={plusIcon} />
580
+ <SecondaryButton variant="inverse" icon={plusIcon} />
581
+ ```
582
+
583
+ ##### Unsupported IconButton Variants
584
+
585
+ In order to simplify our API, we no longer support the `plain`, `square`, and `squareFilled`
586
+ variants from `IconButton`.
587
+
588
+ `IconButton` components with `square`, `squareFilled` and `plain` variants should be updated to the
589
+ corresponding icon-only button versions (`PrimaryButton`, `SecondaryButton`, and `TertiaryButton`),
590
+ `ToolbarIconButton`, or `SegmentedControl`. You may use `ToolbarIconButton` if you would still like
591
+ to have a square icon that is toggleable.
592
+
593
+ These changes are **not** handled by the codemod.
594
+
595
+ > If none of these options support your use case, we've introduced a low-level
596
+ > [`BaseButton`](#basebutton) component which allows you to modify the button's colors, size, and
597
+ > other props. For an example of it being used, reference our
598
+ > [`PageButton`](https://github.com/Workday/canvas-kit/blob/master/modules/react/pagination/lib/Pagination/PageButton.tsx)
599
+ > component.
600
+
601
+ ##### Removal of IconButtonProps
602
+
603
+ The `IconButtonProps` interface no longer exists now that `IconButton` has been removed.
604
+
605
+ This change is **not** handled by the codemod.
606
+
607
+ ##### Toggled
608
+
609
+ There is no equivalent to the `IconButton` `toggled` prop in `SecondaryButton` and `TertiaryButton`.
610
+ If you wish to render a button with a toggled state, consider using `ToolbarIconButton`.
611
+
612
+ This change is **not** handled by the codemod.
613
+
614
+ #### Icon Position
615
+
616
+ The `iconPosition` prop determines where an icon should be rendered relative to the button text.
617
+ We've updated the values from `left` and `right` to `start` and `end` respectively to better reflect
618
+ bidirectionality. The default value is `start`.
619
+
620
+ ```tsx
621
+ // v6
622
+ iconPosition: 'left' | 'right';
623
+
624
+ // v7
625
+ iconPosition: 'start' | 'end';
626
+ ```
627
+
628
+ 🤖 The codemod will map `left` to `start` and `right` to `end` for all uses of `iconPosition`.
629
+
630
+ `iconPosition` will have no effect if you're rendering a button with only an icon and no text.
631
+
632
+ #### Removal of dataLabel
633
+
634
+ In order to simplify our API, we've removed the `dataLabel` prop from `PrimaryButton` and
635
+ `SecondaryButton`.
636
+
637
+ Given the varied use of `dataLabel`, this change is **not** handled by the codemod. Here's an
638
+ example of how to achieve a similar styling in v7:
639
+
640
+ ```tsx
641
+ // v6
642
+ <PrimaryButton dataLabel="1:00">Time</PrimaryButton>;
643
+
644
+ // v7
645
+ import {space, type} from '@workday/canvas-kit-react/common';
646
+
647
+ const DataLabel = styled('span')({
648
+ position: 'relative', // Fixes an IE issue with text within button moving on click
649
+ overflow: 'hidden',
650
+ whiteSpace: 'nowrap',
651
+ fontWeight: type.properties.fontWeights.regular,
652
+ marginLeft: space.xxxs,
653
+ });
654
+
655
+ return (
656
+ <PrimaryButton>
657
+ Time
658
+ <DataLabel>1:00</DataLabel>
659
+ </PrimaryButton>
660
+ );
661
+ ```
662
+
663
+ #### BaseButton
664
+
665
+ > **Disclaimer**: We **strongly** advise consumers **not** to use `BaseButton` and to instead rely
666
+ > on `PrimaryButton`, `SecondaryButton` and `TertiaryButton` whenever possible. `BaseButton` is
667
+ > strictly provided as a last resort if no other option is available for your use case.
668
+
669
+ As part of our Button restructuring, we've created a low level `BaseButton` component. This
670
+ component isn't intended to be used outside of Canvas Kit, but we do export it for very specific use
671
+ cases. `BaseButton` is a styled `<button>` element which supports style properties such as `colors`,
672
+ `padding`, and `width` among many others.
673
+
674
+ Here's an example:
675
+
676
+ ```tsx
677
+ import * as React from 'react';
678
+ import {colors} from '@workday/canvas-kit-react/tokens';
679
+ import {BaseButton} from '@workday/canvas-kit-react/button';
680
+ import {plusIcon} from '@workday/canvas-system-icons-web';
681
+
682
+ const getBasicButtonColors = () => {
683
+ return {
684
+ default: {
685
+ background: colors.blueberry400,
686
+ label: colors.frenchVanilla100,
687
+ icon: colors.frenchVanilla100,
688
+ },
689
+ hover: {
690
+ background: colors.blueberry500,
691
+ label: colors.frenchVanilla100,
692
+ icon: colors.frenchVanilla100,
693
+ },
694
+ active: {
695
+ background: colors.blueberry500,
696
+ label: colors.frenchVanilla100,
697
+ icon: colors.frenchVanilla100,
698
+ },
699
+ focus: {
700
+ background: colors.blueberry400,
701
+ label: colors.frenchVanilla100,
702
+ icon: colors.frenchVanilla100,
703
+ },
704
+ disabled: {
705
+ background: colors.blueberry400,
706
+ },
707
+ };
708
+ };
709
+
710
+ export type BasicButtonProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {};
711
+
712
+ export const BasicButton = ({children, ...elemProps}: BasicButtonProps) => {
713
+ return (
714
+ <BaseButton
715
+ colors={getPaginationButtonColors()}
716
+ {...elemProps}
717
+ >
718
+ <BaseButton.Label>{children}</BaseButton.Label>
719
+ <BaseButton.Icon icon={plusIcon}>
720
+ </BaseButton>
721
+ );
722
+ };
723
+ ```
724
+
725
+ `BaseButton` uses our `Box` component under the hood, which allows it to accept a variety of style
726
+ properties. Because of the flexibility of this component, consumers can use it to create toggled
727
+ buttons or other buttons that aren't supported by our standard button components.
728
+
729
+ ---
730
+
731
+ ### Icon
732
+
733
+ We've updated `AccentIcon`, `AppletIcon`, `Graphic`, `Icon`, `Svg`, `SystemIcon`, and
734
+ `SystemIconCircle` to use the
735
+ [createComponent](/getting-started/for-developers/resources/creating-compound-components/#disclosurecontent-component)
736
+ utility from our
737
+ [common](https://github.com/Workday/canvas-kit/blob/ff77c5bd83e41c3ab2b9c55e41a8b7c1fde33a1b/modules/react/common/lib/utils/components.ts#L167)
738
+ module; they now support [ref forwarding](https://reactjs.org/docs/forwarding-refs.html) and using
739
+ the `as` prop to change the rendered element.
740
+
741
+ These components previously supported an `iconRef` prop. In v7, you'll need to use `ref` instead of
742
+ `iconRef`:
743
+
744
+ ```tsx
745
+ // v6
746
+ <SystemIcon iconRef={ref} />;
747
+
748
+ // v7
749
+ <SystemIcon ref={ref} />;
750
+ ```
751
+
752
+ 🤖 The codemod will update all Icon components that previously supported `iconRef` to use `ref`
753
+ instead.
754
+
755
+ ---
756
+
757
+ ### Popper
758
+
759
+ We've removed the `containerElement` prop from `Popper` because it's no longer needed with the
760
+ Fullscreen API.
761
+
762
+ ---
763
+
764
+ ### Popup
765
+
766
+ #### Popup.Card
767
+
768
+ `Popup.Card` components (this includes `Modal.Card` and `Dialog.Card`) are now flexbox containers.
769
+ This was done to support overflowing content (by default, the `Popup.Body` component). The card is a
770
+ vertical flexbox container and `Popup.Heading`, `Popup.Body`, and any other children are flex items.
771
+ `Popup.Body` now has `overflow-y: auto` to naturally allow the body content to overflow in a scroll
772
+ container. This is a breaking change if your `Popup`, `Modal`, or `Dialog` doesn't work with a
773
+ flexbox with `flex-direction: column`. In most cases, this shouldn't matter. If this change does
774
+ cause your popup to display incorrectly, you may need to play around with flex item containers.
775
+
776
+ Here's an example of where your current implementation might break. A common `Modal` has a heading,
777
+ body, and footer (Cancel/Submit buttons). If the Cancel and Submit buttons are direct children of
778
+ the `Modal.Card` like the following...
779
+
780
+ ```tsx
781
+ <Modal.Card>
782
+ <Modal.Heading>Some Heading</Modal.Heading>
783
+ <Modal.Body>Some Body</Modal.Body>
784
+ <SecondaryButton>Cancel</SecondaryButton>
785
+ <PrimaryButton>Submit</PrimaryButton>
786
+ </Modal.Card>
787
+ ```
788
+
789
+ ...the buttons will become vertical flex items instead of the default which is displaying
790
+ inline-block. Before v7, the buttons would layout next to each other horizontally. In v7, the
791
+ buttons will stack vertically. To fix this, you'll need to add another element as a flex item in the
792
+ `Modal.Card`. The following example uses `HStack` to achieve the desired horizontal layout:
793
+
794
+ ```tsx
795
+ <Modal.Card>
796
+ <Modal.Heading>Some Heading</Modal.Heading>
797
+ <Modal.Body>Some Body</Modal.Body>
798
+ <HStack spacing="s">
799
+ <SecondaryButton>Cancel</SecondaryButton>
800
+ <PrimaryButton>Submit</PrimaryButton>
801
+ </HStack>
802
+ </Modal.Card>
803
+ ```
804
+
805
+ If your code contains any hacks to make a `Modal` overflow, those hacks should now be removed.
806
+ [This example shows how body content overflows](https://workday.github.io/canvas-kit/?path=/docs/components-popups-modal-react--body-overflow)
807
+ (you may have to limit your browser height to see the overflow). Before v7, you had to manually set
808
+ the `max-height` of the `Modal.Body` element using calculations. These should now be removed. The
809
+ `Popup.Card` now has a max height and the `Popup.Body` height is automatically calculated.
810
+
811
+ #### Popup.Body
812
+
813
+ `Popup.Body` is now an overflow container. This means two things:
814
+
815
+ - `Popup.Body` will scroll if the contents are too big to fit in the page
816
+ - `Popup.Body` will hide focus rings that render outside the overflow container
817
+
818
+ Our examples contained buttons inside the `Body` element with their focus rings cut off. We fixed
819
+ this by moving the buttons outside the `Body` element. This is most likely the desired structure
820
+ anyway since the buttons will no longer scroll with overflowed `Body` content.
821
+
822
+ ```tsx
823
+ // v6
824
+ <Modal.Card>
825
+ <Modal.Body>
826
+ Body Contents
827
+ <HStack spacing="s">
828
+ {/* Will scroll with the body */}
829
+ <Modal.CloseButton as={PrimaryButton}>Delete</Modal.CloseButton>
830
+ <Modal.CloseButton>Cancel</Modal.CloseButton>
831
+ </HStack>
832
+ </Modal.Body>
833
+ </Modal.Card>
834
+
835
+ // v7
836
+ <Modal.Card>
837
+ <Modal.Body>Body Contents</Modal.Body>
838
+ <HStack spacing="s">
839
+ <Modal.CloseButton as={PrimaryButton}>Delete</Modal.CloseButton>
840
+ <Modal.CloseButton>Cancel</Modal.CloseButton>
841
+ </HStack>
842
+ </Modal.Card>
843
+ ```
844
+
845
+ #### Popup Model
846
+
847
+ In addition to the other [Model Changes](#model-changes), the `show` and `hide` events of all
848
+ disclosure-type models have been updated to remove the extra event wrapper. This change allows
849
+ developers to directly attach the `show` and `hide` events to React event handlers.
850
+
851
+ The following models were affected:
852
+
853
+ - `useDisclosureModel`
854
+ - `usePopupModel`
855
+ - `useModalModel`
856
+ - `useDisclosureModel`
857
+
858
+ ```tsx
859
+ // v6
860
+ <button onClick={() => model.events.show()} /> // most use-cases look like this
861
+ <button onClick={event => model.events.show({event})} />
862
+
863
+ // v7
864
+ <button onClick={model.events.show} />
865
+ ```
866
+
867
+ Removing the object wrapper around the `event` allows us to directly pass the `show` or `hide` event
868
+ to the `onClick` handler which is much more convenient. We couldn't find many uses of the `event` in
869
+ the wild, so the impact will be minimal. Most usage of `show` or `hide` events are called without
870
+ `event`, so this change will not impact most people. There is **no** codemod for this change,
871
+ because the usage is very difficult to detect since most people pass a callback that doesn't take
872
+ parameters.
873
+
874
+ Guards and callback signatures have also changed to remove the object wrapper around the `event`.
875
+ The following v6 example includes the [Model Changes](#model-changes) which this change compounds
876
+ upon.
877
+
878
+ ```tsx
879
+ // v6
880
+ const model = usePopupModel({
881
+ shouldShow({data: {event}, state}) {
882
+ console.log(event, state);
883
+ },
884
+ onShow({data: {event}, prevState}) {
885
+ console.log(event, prevState);
886
+ },
887
+ });
888
+
889
+ // v7
890
+ const model = usePopupModel({
891
+ shouldShow(event, state) {
892
+ console.log(event, state);
893
+ },
894
+ onShow(event, prevState) {
895
+ console.log(event, prevState);
896
+ },
897
+ });
898
+ ```
899
+
900
+ 🤖 The codemod will update all inline guards and callbacks defined like they are in this example. If
901
+ a guard or callback was defined outside the model config block, it will not be covered by the
902
+ codemod.
903
+
904
+ ---
905
+
906
+ ### Segmented Control
907
+
908
+ `SegmentedControl` is now a
909
+ [compound component](/getting-started/for-developers/resources/compound-components/).
910
+
911
+ Given the [removal of `IconButton`](#removal-of-icon-button) in v7, you'll now need to use
912
+ `SegmentedControl.Button` instead.
913
+
914
+ ```tsx
915
+ // v6
916
+ <SegmentedControl value={value} onChange={handleToggle}>
917
+ <IconButton
918
+ icon={listViewIcon}
919
+ value="list-view"
920
+ aria-label="List View"
921
+ onClick={e => console.log('Existing IconButton onClick callback')}
922
+ />
923
+ <IconButton icon={worksheetsIcon} value="table-view" aria-label="Table View" disabled={true} />
924
+ <IconButton icon={deviceTabletIcon} value="device-view" aria-label="Device View" />
925
+ <IconButton icon={percentageIcon} value="percent-view" aria-label="Percent View" />
926
+ </SegmentedControl>
927
+
928
+ // v7
929
+ <SegmentedControl value={value} onChange={handleToggle}>
930
+ <SegmentedControl.Button
931
+ icon={listViewIcon}
932
+ value="list-view"
933
+ aria-label="List View"
934
+ onClick={e => console.log('Existing IconButton onClick callback')}
935
+ />
936
+ <SegmentedControl.Button
937
+ icon={worksheetsIcon}
938
+ value="table-view"
939
+ aria-label="Table View"
940
+ disabled={true}
941
+ />
942
+ <SegmentedControl.Button icon={deviceTabletIcon} value="device-view" aria-label="Device View" />
943
+ <SegmentedControl.Button icon={percentageIcon} value="percent-view" aria-label="Percent View" />
944
+ </SegmentedControl>
945
+ ```
946
+
947
+ 🤖 The codemod will replace all `IconButton` children of `SegmentedControl` with
948
+ `SegmentedControl.Button`.
949
+
950
+ ---
951
+
952
+ ### Side Panel
953
+
954
+ The `SidePanel` in our Preview package now has a tooltip built in to its toggle button. If you
955
+ currently have a `Tooltip` component wrapping this component, you should remove it. Instead, you'll
956
+ need to provide the appropriate tooltip text to the button based on its state using the following
957
+ new props added to `SidePanel.ToggleButton`:
958
+
959
+ ```tsx
960
+ /**
961
+ * The tooltip text to expand the side panel
962
+ * @default 'Expand'
963
+ */
964
+ tooltipTextExpand?: string;
965
+ /**
966
+ * The tooltip text to collapse the side panel
967
+ * @default 'Collapse'
968
+ */
969
+ tooltipTextCollapse?: string;
970
+ ```
971
+
972
+ ---
973
+
974
+ ### Status Indicator
975
+
976
+ Status Indicators currently truncate when they reach their max width of `150px`. After receiving
977
+ requests to increase this value, we've increased it by 33% to `200px`.
978
+
979
+ We've also added a `maxWidth` prop to further configure this value if necessary. While this
980
+ increases flexibility, please keep in mind that status text should be short, direct, and preferably
981
+ a single word.
982
+
983
+ ```tsx
984
+ <StatusIndicator label="Slightly Longer Status" type={StatusIndicator.Type.Gray} maxWidth={250} />
985
+ ```
986
+
987
+ ---
988
+
989
+ ### Tabs
990
+
991
+ To avoid interference with the HTML `name` attribute, we're now using `data-id` instead of `name`
992
+ for `Tabs.Item`, `Tabs.Panel`, and `Tabs.Menu.Item`.
993
+
994
+ ```tsx
995
+ // v6
996
+ <Tabs.Item name="tabs-item">...</Tabs.Item>
997
+ <Tabs.Panel name="tabs-panel">...</Tabs.Panel>
998
+ <Tabs.Menu.Item name="tabs-menu-item">...</Tabs.Menu.Item>
999
+
1000
+ // v7
1001
+ <Tabs.Item data-id="tabs-item">...</TabsItem>
1002
+ <Tabs.Panel data-id="tabs-panel">...</Tabs.Panel>
1003
+ <Tabs.Menu.Item data-id="tabs-menu-item">...</Tabs.Menu.Item>
1004
+ ```
1005
+
1006
+ 🤖 The codemod will handle these changes for you automatically.