@splunk/react-ui 5.0.0-rc.2 → 5.1.0

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 (104) hide show
  1. package/Accordion.js +59 -59
  2. package/Avatar.js +20 -20
  3. package/Breadcrumbs.js +46 -46
  4. package/Button.js +24 -24
  5. package/CHANGELOG.md +380 -0
  6. package/Calendar.js +69 -69
  7. package/Card.js +68 -68
  8. package/Chip.js +16 -16
  9. package/Clickable.js +29 -29
  10. package/Code.js +654 -519
  11. package/CollapsiblePanel.js +112 -112
  12. package/Color.js +107 -107
  13. package/ColumnLayout.js +35 -35
  14. package/ComboBox.js +190 -206
  15. package/ControlGroup.js +129 -121
  16. package/Date.js +148 -146
  17. package/DefinitionList.js +26 -26
  18. package/Dropdown.js +9 -9
  19. package/DualListbox.js +701 -717
  20. package/File.js +403 -403
  21. package/FormRows.js +66 -63
  22. package/Image.js +15 -15
  23. package/JSONTree.js +458 -357
  24. package/Layer.js +60 -72
  25. package/MIGRATION.md +550 -1
  26. package/Markdown.js +66 -66
  27. package/Menu.js +44 -44
  28. package/Message.js +47 -43
  29. package/Modal.js +49 -49
  30. package/ModalLayer.js +21 -17
  31. package/Monogram.js +16 -16
  32. package/Multiselect.js +673 -669
  33. package/Number.js +100 -100
  34. package/Paginator.js +7 -7
  35. package/Popover.js +473 -424
  36. package/Progress.js +12 -12
  37. package/Prose.js +6 -6
  38. package/README.md +6 -6
  39. package/RadioBar.js +180 -166
  40. package/RadioList.js +80 -79
  41. package/ResultsMenu.js +129 -128
  42. package/Scroll.js +50 -50
  43. package/Search.js +148 -164
  44. package/Select.js +674 -674
  45. package/Slider.js +30 -30
  46. package/SlidingPanels.js +24 -24
  47. package/SplitButton.js +50 -50
  48. package/StepBar.js +100 -100
  49. package/Switch.js +45 -45
  50. package/TabBar.js +196 -196
  51. package/TabLayout.js +16 -16
  52. package/Table.js +1207 -1193
  53. package/Text.js +65 -65
  54. package/TextArea.js +108 -93
  55. package/Tooltip.js +203 -197
  56. package/TransitionOpen.js +4 -1
  57. package/Tree.js +464 -366
  58. package/package.json +11 -11
  59. package/stubs-dependencies.d.ts +0 -70
  60. package/stubs-splunkui.d.ts +4 -0
  61. package/types/src/Code/Code.d.ts +17 -1
  62. package/types/src/Code/LineHighlights.d.ts +11 -0
  63. package/types/src/Code/LineNumbers.d.ts +6 -0
  64. package/types/src/Code/docs/examples/LineHighlights.d.ts +3 -0
  65. package/types/src/Code/docs/examples/LineNumbers.d.ts +3 -0
  66. package/types/src/Code/docs/examples/LineNumbersCustomStart.d.ts +3 -0
  67. package/types/src/Date/Date.d.ts +6 -1
  68. package/types/src/DefinitionList/DefinitionList.d.ts +6 -6
  69. package/types/src/Dropdown/Dropdown.d.ts +1 -0
  70. package/types/src/FormRows/FormRows.d.ts +1 -1
  71. package/types/src/JSONTree/JSONTreeItem.d.ts +5 -2
  72. package/types/src/Markdown/Markdown.d.ts +1 -1
  73. package/types/src/Markdown/renderers/MarkdownBlockquote.d.ts +1 -1
  74. package/types/src/Markdown/renderers/MarkdownCodeBlock.d.ts +1 -1
  75. package/types/src/Markdown/renderers/index.d.ts +1 -1
  76. package/types/src/Popover/Popover.d.ts +8 -2
  77. package/types/src/RadioBar/Option.d.ts +1 -1
  78. package/types/src/RadioBar/RadioBar.d.ts +13 -6
  79. package/types/src/RadioBar/RadioBarContext.d.ts +4 -2
  80. package/types/src/RadioList/RadioList.d.ts +2 -1
  81. package/types/src/ResultsMenu/ResultsMenu.d.ts +2 -1
  82. package/types/src/ScreenReaderContent/docs/examples/SkipLink.d.ts +3 -0
  83. package/types/src/Scroll/Inner.d.ts +1 -1
  84. package/types/src/Select/Option.d.ts +1 -1
  85. package/types/src/Select/Select.d.ts +1 -1
  86. package/types/src/Slider/docs/examples/Controlled.d.ts +1 -1
  87. package/types/src/TabLayout/Panel.d.ts +0 -1
  88. package/types/src/Table/Head.d.ts +1 -0
  89. package/types/src/Table/HeadCell.d.ts +2 -3
  90. package/types/src/Table/HeadDropdownCell.d.ts +2 -2
  91. package/types/src/Table/HeadInner.d.ts +4 -4
  92. package/types/src/Table/KeyboardSensor.d.ts +1 -1
  93. package/types/src/Table/RowDragCell.d.ts +1 -1
  94. package/types/src/Tooltip/Tooltip.d.ts +10 -5
  95. package/types/src/Tree/Item.d.ts +63 -0
  96. package/types/src/Tree/Tree.d.ts +13 -6
  97. package/types/src/Tree/TreeContext.d.ts +1 -1
  98. package/types/src/Tree/index.d.ts +1 -1
  99. package/types/src/useControlled/useControlled.d.ts +3 -1
  100. package/useControlled.js +29 -13
  101. package/CHANGELOG.v5.md +0 -354
  102. package/MIGRATION.v5.md +0 -552
  103. package/types/src/Button/docs/examples/Truncated.d.ts +0 -3
  104. package/types/src/Tree/TreeItem.d.ts +0 -44
package/MIGRATION.v5.md DELETED
@@ -1,552 +0,0 @@
1
- # Migration
2
-
3
- This document lists migration guidance for new features and breaking changes in v5.
4
-
5
- ## Component spacing
6
-
7
- To unify the styling of components margin has been removed and components should not have any spacing outside of its border box.
8
-
9
- ### Content components
10
-
11
- Some components had `margin-bottom` by default: e.g. `Heading` or `Paragraph`. Although this could
12
- simplify styling with text content, often it needed to be overridden when using these
13
- components in an application. Additionally, it was not consistent which components
14
- would have the additional spacing.
15
-
16
- When spacing is needed in long-form text content the new `Prose` component can be used to add styling that optimizes for readability.
17
-
18
- ### inline margin
19
-
20
- Previously, certain components automatically applied a `margin-left` when siblings with other components (e.g., two `Button`s, or a `Text` and a `Button`). This behavior worked fine for basic use cases where no additional styling was needed for spacing.
21
-
22
- However, it created issues in more complex layouts, especially with modern techniques like flex and grid, requiring developers to manually reset the margin. To be consistent with removing margin outside components' border box and encourage modern layout practices, this automatic margin has been removed. The `inline` attribute remains, and it still affects the display and width of certain components.
23
-
24
- For spacing between components, use the new `Layout` component, which applies spacing without relying on margin. If you’re already using a wrapper, you can instead use `@splunk/themes/mixins/layout` to manage spacing, allowing you to remove previous margin overrides.
25
-
26
- ## Component font styles
27
-
28
- ### New features and changes
29
-
30
- - The font size and line height no longer change with density (SUI-5508).
31
- - The default font-size in Enterprise Compact now is 14px (SUI-5508).
32
-
33
- ### Migration steps for font-size, font-weight and font-family
34
-
35
- ```jsx
36
- css`font-size: ${variables.fontSizeSmall}`
37
- is equivalent to
38
- css`font-size: ${mixins.typography({ size: 12 })}`
39
-
40
- css`font-size: ${variables.fontWeightSemiBold}`
41
- is equivalent to
42
- css`font-weight: ${mixins.typography({ weight: 'semiBold' })}`
43
-
44
- css`font-family: ${variables.sansFontFamily}`
45
- is equivalent to
46
- css`font-family: ${mixins.typography({ family: 'sansSerif' })}`
47
-
48
- css`line-height: ${variables.lineHeight}`
49
- is equivalent to
50
- css`font-size: ${mixins.typography({ lineHeight: 20 })}`
51
- ```
52
-
53
- ## Monogram to Avatar
54
-
55
- `Monogram` will be removed in a future major version. Use `Avatar` instead (SUI-5608).
56
-
57
- ### New features and changes
58
-
59
- - `Avatar` supports images via `image` prop (SUI-3227).
60
- - `Avatar`'s `value` prop replaces `Monogram`'s `name` prop (SUI-5610).
61
- - `Avatar`'s `size` prop doesn't have an `"xlarge"` option (SUI-5518).
62
- - `Avatar`'s `size` prop supports `string` instead of `number` (SUI-5615).
63
- - `Avatar`'s `"medium"` size is `32px` and `large` size is `48px` (SUI-5615).
64
- - `Avatar` has the same sizes in Enterprise and Prisma theme (SUI-5617).
65
- - `Avatar` requires `label` prop (SUI-5611).
66
- - `Avatar`'s text color will change automatically depending on the background color to comply with accessibility contrast requirements (SUI-5614).
67
- - `Avatar`'s `backgroundColor` prop doesn't have a `"theme"` option (SUI-5614). No value for `backgroundColor` is needed for the default background colors.
68
-
69
- ### Migration steps
70
-
71
- #### `size` prop
72
-
73
- ```jsx
74
- <Monogram size="medium" /> is equivalent to <Avatar size='large'/>
75
- <Monogram size="large" /> is equivalent to <Avatar size='80px'/>
76
- <Monogram size="xlarge" /> is equivalent to <Avatar size='144px'/>
77
-
78
- Convert any usage of a number type to string type:
79
- <Monogram size={40} /> is equivalent to <Avatar size='40px'/>
80
- ```
81
-
82
- #### `name` prop
83
-
84
- ```jsx
85
- <Monogram initials="A" name="Amelia" onClick={() => {}} />
86
- is equivalent to
87
- <Avatar initials="A" value="Amelia" onClick={() => {}}/>
88
- ```
89
-
90
- ## Change to `Modal.Header` icon
91
-
92
- `Modal.Header`'s `icon` prop no longer requires `width="100%" height="100%"` to be set on the icon to render at the correct size (SUI-5931).
93
-
94
- ### Migration steps
95
-
96
- Remove `width="100%" height="100%"` from the icon.
97
-
98
- ## Changes to `Modal` and `Modal.Header` `onRequestClose` prop
99
-
100
- `Modal.Header` now uses the `onRequestClose` prop from `Modal` and no longer supports its own `onRequestClose`.
101
- When the `Modal` is closed by clicking the "close" button in Modal.Header` the `reason` parameter will be `"clickCloseButton"` (SUI-5933).
102
-
103
- For cases where `onRequestClose` was not set on `Modal.Header`, the "close" button can be hidden with the new `hideCloseButton` prop to maintain prior behavior.
104
-
105
- ### Migration steps
106
-
107
- If `onRequestClose` was set on `Modal.Header`, remove it and either add the `onRequestClose` to `Modal` or update it if it exists. If it's necessary to determine if the prop was called by the "close" button in `Modal.Header`, the `reason` parameter will be set to `"`clickCloseButton`" in those cases.
108
- If `onRequestClose` was not set on `Modal.Header`, add the new `hideCloseButton` prop to maintain prior behavior.
109
-
110
- ## `JSONTree`'s `expandChildren` prop renamed to `defaultExpanded` and no longer affects node expansion behavior after the initial render.
111
-
112
- ### Change
113
-
114
- `JSONTree`'s `expandChildren` prop has been renamed to `defaultExpanded` and no longer affects node expansion behavior after the initial render.
115
-
116
- ### Context
117
-
118
- The old behavior of `JSONTree`'s `expandChildren` prop was to:
119
- 1. Start with all nodes expanded.
120
- 2. Always expand all descendant nodes when a node is expanded.
121
-
122
- Now `expandChildren` has been renamed to `defaultExpanded` and the behavior of `defaultExpanded` is to:
123
- 1. Start with all nodes expanded. This behavior remains the same as `expandChildren`.
124
- 2. Subsequent node expansions are not affected by `defaultExpanded` - they only expand one level of nodes. This behavior is different from `expandChildren`'s old behavior.
125
-
126
- This change in behavior was made because it was likely not a desired behavior and unintuitive that `expandChildren` would always expand all descendant nodes.
127
- Then `expandChildren` was renamed to `defaultExpanded` to make it clear it does not affect node expansion behavior after the initial render.
128
-
129
- ### Migration steps
130
-
131
- Replace all usage of `JSONTree`'s `expandChildren` prop with `defaultExpanded`.
132
- To expand all descendant nodes when a node is expanded, use the `expandChildrenOnShiftKey` prop instead.
133
-
134
- ## `ComboBox`, `Date`, `Multiselect`, `Number`, `Search`, `Select`, and `Text` no longer use the TypeScript `HTMLTextAreaElement` type in event handlers and refs
135
-
136
- ### Change
137
-
138
- `ComboBox`, `Date`, `Multiselect`, `Number`, `Search`, `Select`, and `Text` no longer use the TypeScript `HTMLTextAreaElement` type in event handlers.
139
- `Number` and `Text` no longer use the TypeScript `HTMLTextAreaElement` type for the `inputRef` prop (SUI-6206).
140
-
141
- ### Context
142
-
143
- `Text`'s `multiline` prop was removed. With this change, it is no longer necessary for `Text` and components that use `Text` to
144
- have props that include the TypeScript `HTMLTextAreaElement` type.
145
-
146
- ### Migration steps
147
- * Change the callbacks passed into the following props to use an event type that doesn't include `HTMLTextAreaElement`:
148
- * `ComboBox`
149
- * `onBlur`
150
- * `onChange`
151
- * `onFocus`
152
- * `Date`
153
- * `onBlur`
154
- * `onFocus`
155
- * `Multiselect`
156
- * `onFilterChange`
157
- * `Number`
158
- * `onBlur`
159
- * `onChange`
160
- * `onFocus`
161
- * `Search`
162
- * `onBlur`
163
- * `onChange`
164
- * `onFocus`
165
- * `Select`
166
- * `onFilterChange`
167
- * `Text`
168
- * `onBlur`
169
- * `onClick`
170
- * `onChange`
171
- * `onFocus`
172
- * `onKeyDown`
173
- * `onSelect`
174
- * Change any refs passed into `Text` and `Number`'s `inputRef` prop with the TypeScript `HTMLTextAreaElement` type to be of `HTMLInputElement` type instead.
175
-
176
- ## `Text`, `Date`, and `Number` `onClick` prop API changes
177
-
178
- ### Change
179
- - `Text`'s `onInputClick` prop has been renamed to `onClick`.
180
- - `Date`'s `onClick` prop now uses Typescript `HTMLInputElement` type.
181
- - `Number` supports new `onClick` prop with TypeScript `HTMLInputElement` type.
182
-
183
- ### Context
184
-
185
- `Text`'s `onClick` prop was applied to the wrapping element rather than the `input` element itself.
186
- This caused difficulty disambiguating clicks on the `input` from clicks on other parts of the component, such as adornments.
187
- To provide a temporary solution without breaking changes, an `onInputClick` prop was added for clicks on the `input` itself.
188
- In 5.0, we're fixing the issue and removing the workaround, so `onClick` will now be applied directly to the `input` element,
189
- which will result in a change to the TypeScript types.
190
- `Date` and `Number` components will leverage the new callback, so their types will change to match.
191
-
192
- ### Migration steps
193
-
194
- - Replace all usage of `Text`'s `onInputClick` prop with `onClick`.
195
- - Change callbacks passed to `Date`'s `onClick` prop to use an event with the TypeScript `HTMLInputElement` type.
196
- - Change callbacks passed to `Number`'s `onClick` prop to use an event with the TypeScript `HTMLInputElement` type.
197
-
198
- ## `Collapsible Panel`, `Color`, `ControlGroup`, `Dropdown`, `Image`, `Link `, `Menu`, `Modal`, `Switch`, and `Text` converted to functional components
199
-
200
- ### Change
201
- `Collapsible Panel`, `Color`, `ControlGroup`, `File`, `Image`, `Link `, `Menu`, `Modal`, `Select.Option`, `Slider`, `SlidingPanel.Panel`, `Switch`, `Table.HeadDropdownCell`, and `Text` converted from class to functional components.
202
-
203
- ### Context
204
- React recommends defining components as functions instead of classes. Functional components don't have `ref` support.
205
- Components that formerly supported class focus methods (`Color`, `Link`, `Menu`, `Number`, `Select.Option`, `Switch`, `TabBar.Tab`, `Table.HeadDropdownCell`, `Text`) no longer do so.
206
-
207
- ### Migration steps
208
- - Convert all usage of `ref` to `elementRef`.
209
- - For `Number` and `Text`: Replace all usage of the class `focus` method with passing a `ref` to the `inputRef` prop and calling `inputRef.current.focus()`.
210
- - For `Button`, `Color`, `Link`, `Menu`, `Multiselect.Option`, `Select.Option`, `SplitButton.Item`, and `TabBar.Tab`: Replace all usage of the class `focus` method with passing a `ref` to the `elementRef` prop and calling `elementRef.current.focus()`.
211
- - For `Table.HeadDropdownCell`: Replace all usage of the class `focus` method with passing a `ref` to the `buttonRef` prop and calling `buttonRef.current.focus()`.
212
- - For `Switch`: Replace all usage of the class `focus` method with passing a `ref` to the `toggleRef` prop and calling `toggleRef.current.focus()`.
213
- - For `Slider`: Replace all usage of the class `focus` method with passing a `ref` to the `thumbRef` prop and calling `thumbRef.current.focus()`.
214
- - For `Dropdown`: Replace all usage of the class `focus` method with passing `focus()` on the element passed to `toggle`.
215
-
216
- ## `Table.HeadDropdownCell`'s `defaultPlacement` prop has been removed
217
-
218
- ### Change
219
- `Table.HeadDropdownCell` no longer accepts a `defaultPlacement` prop.
220
-
221
- ### Context
222
- Previously `Table.HeadDropdownCell` accepted (and passed down to its `Popover` instance) a `defaultPlacement` prop. To avoid layout and positioning issues this is no longer able to be overridden in favor of only supporting `bottom` placement of the `Table.HeadDropdownCell`'s `Popover`.
223
-
224
- ### Migration steps
225
- - Remove any passing of `defaultPlacement` prop to `Table.HeadDropdownCell`
226
-
227
- ## Deprecation
228
-
229
- ### Deprecated `RadioList`'s `direction` prop
230
-
231
- #### Change
232
- `RadioList`'s `direction` prop has been deprecated and will be removed in the next major version.
233
-
234
- #### Context
235
- When having a single select option list displayed horizontally, `RadioBar` provides a better user interface and experience.
236
-
237
- #### Migration steps
238
- - Replace any instances of `RadioList` that use `direction="row"` with `RadioBar`.
239
-
240
- ### Deprecated `Card`'s `selected` prop
241
-
242
- #### Change
243
- `Card`'s `selected` prop has been deprecated and will be removed in the next major version.
244
-
245
- #### Context
246
- There was a concept of a `Card` being selected (driven by the `selected` prop) but it failed to meet proper accessibility standards. This was due to the individual `Card` component not having the proper context of how it was being used to correctly apply aria attributes such as `aria-role` and `aria-checked`.
247
-
248
- #### Migration steps
249
- - General guidance remains to prefer more purpose specific input components such as `Multiselect`, `RadioList`, or `Switch` over using `Card` in an input context due to the accessibility considerations they contain. If possible consider removing any selectable `Card` usage and migrating to those components instead.
250
- - If continuing to use `Card` as an input, remove any passing of the `selected` prop to `Card` and provide selected state accessibility affordance instead by using a radio button or checkbox in the `Card` such as in the `Card.Header`. Be sure to handle aria attributes such as [aria-role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles) and [aria-checked](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-checked) as your use case may require.
251
-
252
- ### Deprecated `Select`'s `appearance="link"` value
253
-
254
- #### Change
255
- `Select`'s `appearance="link"` value has been deprecated and will be removed in the next major version.
256
-
257
- #### Context
258
- Using a `Select` with `appearance="link"` can be misleading because links are primarily used for navigation, while a `Select` is designed for making a choice, which involves a different interaction model.
259
- This difference can cause confusion and conflict with accessibility expectations, as dropdowns have different interaction requirements compared to inline links.
260
-
261
- #### Migration steps
262
- - Replace Select with appearance="link" by using either appearance="default" or appearance="subtle", depending on design requirements.
263
-
264
- ### Deprecated `TabBar` and `TabLayout`'s `iconPosition` prop
265
-
266
- #### Change
267
- `TabBar` and `TabLayouts`'s `iconPosition` prop is deprecated and will be removed in the next major version.
268
-
269
- #### Context
270
- `TabBar`'s `iconPosition="above"` value is deprecated because stacking an icon above text creates a vertical layout that’s harder to scan quickly, especially when multiple `Tab`s are present. The added vertical space can make the `TabBar` taller and more visually crowded, reducing the clarity and simplicity that `TabBar`s are supposed to offer.
271
- Due to this `TabBar`'s `iconPosition` would only have the value of `left` remaining thus there is no longer a need for the `iconPosition` prop to specify icon positioning. Because `TabLayout` uses `TabBar` its matching prop is deprecated as well.
272
-
273
- #### Migration steps
274
- - Remove any setting of `TabBar` or `TabLayout`'s `iconPosition` prop and instead allow its default behavior of left icon positioning to take effect when icons are passed.
275
-
276
- ### Deprecated `Multiselect`'s `selectAllAppearance="buttongroup"` value
277
-
278
- #### Change
279
- `Multiselect`'s `"buttongroup"` value of the `selectAllAppearance` prop has been deprecated and will be removed in the next major version.
280
-
281
- #### Context
282
- Using `Multiselect`'s `selectAllAppearance="checkbox"` will fix accessibility issue by making it easier to toggle between "select all" and "select none" with one less tab stop.
283
-
284
- #### Migration steps
285
- - Replace `Mulitselect`'s `selectAllAppearance="buttongroup"` with `selectAllAppearance="checkbox"`.
286
-
287
- ## Markdown users `react-markdown`
288
-
289
- ### Change
290
- The `commonmark-react-markdown` library has been replaced with `react-markdown` for rendering markdown.
291
-
292
- ### Context
293
- `commonmark-react-markdown` does not support GitHub flavored markdown (GFM) and is no longer actively-maintained. `react-markdown` supports GFM via plugins. In addition to other features, this primarily enables rendering tables within markdown.
294
-
295
- `react-markdown` ships as ESM which can cause issues with test runners like `jest`.
296
-
297
- ### Migration steps
298
- - If using `jest`, add the following to your `jest.config` file:
299
- ```
300
- moduleNameMapper: {
301
- 'react-markdown': '<rootDir>../../node_modules/react-markdown/react-markdown.min.js',
302
- },
303
- ```
304
-
305
-
306
- ## `Modal.Footer` layout
307
-
308
- ### Change
309
-
310
- `Modal.Footer` has a new `layout` prop to control the layout and styling of children.
311
-
312
- ### Context
313
-
314
- Common use cases for content within Modal.Footer include:
315
- - A single Button
316
- - A pair of Buttons
317
- - Documentation links
318
- - Controls (e.g., Checkbox, Switch)
319
- - Wizards
320
- - Static content
321
- - Combinations of the above
322
-
323
- In 4.x versions, `Modal.Footer` handled styling for a single `Button` or pair of `Button`s correctly. Other use cases required custom styling. In 5.x `Button`'s no longer have margin from sibling `[data-inline]` elements, which would break the use cases previously supported by `Modal.Footer` in 4.x.
324
-
325
- To simplify the implementation and ensure consistent design for these common use cases, the default styling for `Modal.Footer` has been updated. Now, these common use cases will display correctly without requiring additional styling.
326
-
327
- A new prop `layout` has been added to `Modal.Footer` to control styling children.
328
- The default value, `auto`, uses the updated styling, while `layout="none"` will revert to the 4.x styling, in cases where the new layout is incorrect.
329
-
330
- ### Migration steps
331
- **For a single Button or pair of Buttons**: No migration is necessary—existing code should work as before.
332
-
333
- **For other common use cases (e.g., Checkbox, static content, wizards)**: Any custom layout or styling previously applied may no longer be needed and can be removed.
334
-
335
- **For custom layouts**: If a custom layout is still required, revert to the 4.x styling by setting the `layout="none"` prop and/or refactor styles to work with the `auto` styling.
336
-
337
-
338
- ## `Button`, `Clickable', `CollapsiblePanel`, and `Menu.Item`'s default `disabled` behavior is now `dimmed`
339
-
340
- ### Change
341
-
342
- `Button`, `Clickable`, `CollapsiblePanel`, and `Menu.Item` components with the `disabled` prop will, by default, exhibit the `dimmed` behavior.
343
- To revert to the original behavior (where the component cannot receive focus), set disabled="disabled".
344
-
345
- For testing, a new `data-test-disabled` test hook has been added.
346
-
347
- ### Context
348
-
349
- Whenever possible `disabled` components should be avoided.
350
-
351
- A `disabled="disabled"` component is less accessible, since it is less discoverable to keyboard users by not receiving focus. Additionally, `Tooltip`s associated with these components become inaccessible, since the component cannot receive focus to activate the `Tooltip`.
352
-
353
- `disabled="dimmed"` was introduced in v4.25.0 to provide a more inclusive approach to disabling components. Dimmed components remain focusable, are semantically marked as disabled, and still prevent the user from activating the component.
354
-
355
- By using the `"dimmed"` state as the default, the user experience of these components is more inclusive.
356
-
357
- ### Migration Steps
358
-
359
- #### Validate new default `dimmed` behavior
360
-
361
- Validate your application and components work as expected with the new default behavior.
362
- If the component can benefit from being more discoverable and accessible, leave the `disabled` prop as is.
363
-
364
- #### Use `disabled="disabled"` sparingly
365
- Assess whether you want to retain the button’s original disabled behavior (non-focusable, non-interactive, etc.). If that's the case, set disabled="disabled".
366
-
367
- #### Updating tests
368
- When testing, it is recommended to test the user interaction rather than component's state or props (e.g. test that the user cannot activate the control).
369
-
370
- Matchers like `toBeDisabled()` will no longer pass when using `disabled` or `disabled="dimmed"`.
371
- If it is necessary to test the components state, use the new test hook state attribute.
372
-
373
- * For `dimmed` components, replace `expect(button).toBeDisabled()` with:
374
- ```
375
- expect(button).toHaveAttribute('data-test-disabled');
376
- ```
377
-
378
- * For `disabled="disabled" components, `toBeDisabled` will continue to work.
379
-
380
-
381
- ## `Slider`'s test hook `[data-test="handle"]` renamed to `[data-test="thumb"]`
382
-
383
- ### Change
384
-
385
- `Slider`'s test hook `[data-test="handle"]` has been renamed to `[data-test="thumb"]`.
386
-
387
- ### Context
388
-
389
- `Slider`'s draggable control has been renamed from "handle" to "thumb" to better align with
390
- the more commonly used name for this element (e.g. ARIA refers to it as "thumb"). Also,
391
- the name "handle" can be misleading, as it could be confused with event handlers, etc.
392
-
393
- ### Migration steps
394
-
395
- Replace all usage of `Slider`'s test hook `[data-test="handle"]` with `[data-test="thumb"]`.
396
-
397
- ## `Dropdown`'s `toggle` prop now requires an HTML Element or `React.forwardRef`
398
-
399
- ### Change
400
-
401
- `Dropdown`'s `toggle` prop no longer accepts React class components or functional components without `React.forwardRef`.
402
- Components passed to `Dropdown`'s `toggle` prop must accept a `ref` that returns an HTML element.
403
-
404
- ### Context
405
-
406
- `Dropdown` previously leveraged `Popover`s usage of `findDOMNode` to find the underlying HTML element for a React component.
407
- Given that `findDOMNode` is deprecated and scheduled for removal in React 19, we're removing our usages of it.
408
-
409
- ### Migration Steps
410
-
411
- If you are using `Button`, `Clickable`, or `Link` components as the `toggle`, no migration is necessary.
412
-
413
- Otherwise:
414
- - Convert any components passed to `toggle` to `React.forwardRef` components that forward the ref to an HTML element.
415
- - If you previously passed a component wrapped in `Tooltip` to `toggle`, you need to forward the ref to the wrapped component.
416
- - Consider using `react-ui`'s `Button`, `Clickable`, or `Link` components for the `toggle` prop.
417
- - See the React docs for alternatives to `findDOMNode` usage: https://18.react.dev/reference/react-dom/findDOMNode#alternatives
418
-
419
- ## `Popover`'s `anchor` prop now requires an HTML element
420
-
421
- ### Change
422
-
423
- `Popover`'s `anchor` prop now requires a ref to a HTML element and no longer accepts refs to React class component instances.
424
-
425
- ### Context
426
-
427
- `Popover`s has previously used `findDOMNode` to find the underlying HTML element for a React component.
428
- Given that `findDOMNode` is deprecated and scheduled for removal in React 19, we're removing our usages of it.
429
-
430
- ### Migration Steps
431
-
432
- Pass a `ref` that refers to an HTML Element to the `anchor` prop.
433
-
434
- - For `react-ui` components, use `elementRef` to get a `ref` to the underlying HTML element.
435
- - For custom components, use `forwardRef`.
436
- - See the React docs for alternatives to `findDOMNode` usage: https://18.react.dev/reference/react-dom/findDOMNode#alternatives
437
-
438
-
439
- ## `Switch`'s test hook `[data-test="button"]` renamed to `[data-test="toggle"]`
440
-
441
- ### Change
442
-
443
- `Switch`'s test hook `[data-test="button"]` has been renamed to `[data-test="toggle"]`.
444
-
445
- ### Context
446
-
447
- `Switch`'s underlying toggle element has been renamed from "button" to "toggle" to be less generic and describe its function of switching between states.
448
-
449
- ### Migration steps
450
-
451
- Replace all usage of `Switch`'s test hook `[data-test="button"]` with `[data-test="toggle"]`.
452
-
453
- ## `TabBar`'s `tabWidth` prop has been removed
454
-
455
- ### Change
456
- `TabBar`'s `tabWidth` prop has been removed. A new `maxTabWidth` prop has been added to support some use cases previously supported by the `tabWidth` prop.
457
-
458
- ### Context
459
- In previous versions `TabBar.Tab`s could have their width statically set by passing the `tabWidth` prop to the `TabBar`. However, the updated design for `TabBar` has responsive widths for `TabBar.Tab`s so setting a static tab width is no longer supported.
460
-
461
- ### Migration steps
462
- There are were two possible use cases for `tabWidth`:
463
-
464
- 1) If you desire each `Tab` to not exceed a certain width, use `maxTabWidth`.
465
- 2) If you desire each `Tab` to be the exact same width, we recommend against this - please reach out to us if you have a specific use case in mind.
466
-
467
- ## Deprecated `Card.Header`'s `anchor` prop
468
-
469
- ### Change
470
-
471
- `Card.Header`'s `anchor` prop has been deprecated and will be removed in the next major version.
472
-
473
- ### Context
474
-
475
- Card titles need to be headings when there is content underneath to satisfy accessibility requirement WCAG 1.3.1.
476
- The recommended way to do this is to pass the `Heading` component into the `title` prop.
477
-
478
- The anchor prop leads to visual issues when non-text content (such as a Heading is passed to the `title` attribute).
479
- To avoid this and because the functionality of the `anchor` prop can be achieved by passing the `Anchor` component to the `title` prop,
480
- we have deprecated the `anchor` prop.
481
-
482
- ### Migration steps
483
- Replace all usage of the `anchor` prop with passing in the `Anchor` component to the `title` prop:
484
- ```jsx
485
- <Card.Header title={<Anchor name="Title">Title</Anchor>} />
486
- ```
487
-
488
- ## Deprecated `Popover`'s `"inverted"` value of the `appearance` prop
489
-
490
- ### Change
491
-
492
- `Popover`'s `"inverted"` value of the `appearance` prop has been deprecated and will be removed in the next major version.
493
-
494
- ### Context
495
-
496
- The inverted appearance was deprecated to ensure the Popover background aligns with the color scheme, i.e. Popover should be light in light mode and dark in dark mode.
497
-
498
- ### Migration steps
499
- Replace all usage of Popover's `appearance="inverted"` with `appearance="normal"` (default).
500
- If teams need to keep inverted Popovers they can use `backgroundColorFloating` and `contentColorInverted`. Otherwise Popover uses `backgroundColorPopup`.
501
- ```jsx
502
- const StyledContent = styled.div`
503
- background-color: ${variables.backgroundColorFloating};
504
- color: ${variables.contentColorInverted};
505
- `;
506
-
507
- return (
508
- <Popover>
509
- <StyledContent>Popover content</StyledContent>
510
- </Popover>
511
- )
512
- ```
513
-
514
- ## `Button`'s `label` prop no longer sets `label` attribute
515
-
516
- ### Change
517
- `Button`'s `label` prop no longer sets HTML attribute `label` on the underlying button element.
518
-
519
- ### Context
520
- In previous versions, the `label` prop, which sets the text on the Button, was also passed as a `label` HTML attribute which is invalid HTML for a `<button>`. This has been removed.
521
-
522
- ### Migration steps
523
- Replace usages of `label` selector in tests with a different suitable query e.g. replace `querySelector('[label="Save"]')` with `getByText('Save')`.
524
-
525
- ## `Color`'s test hook `[data-test="color"]` moved to root and `[data-test="toggle-swatch"]` added to toggle swatch
526
-
527
- ### Change
528
-
529
- `Color`'s test hook `[data-test="color"]` has been moved to the root `div` element and a new test hook `[data-test="toggle-swatch"]` has been added to the toggle swatch.
530
-
531
- ### Context
532
-
533
- `Color`'s test hook `[data-test="color"]` was incorrectly documented as the root of the component but was actually set on the toggle swatch.
534
-
535
- ### Migration steps
536
- If the test hook needs to be on the root element of `Color`, use `[data-test="color"]`.
537
- If the test hook was being used to interact with the toggle swatch, replace usage of `[data-test="color"]` with `[data-test="toggle-swatch"]`.
538
-
539
- ## All components that previously used `KeyboardEvent`'s deprecated `keyCode` property now use `KeyboardEvent`'s `key` property.
540
-
541
- ### Change
542
-
543
- Switched all components that previously used `KeyboardEvent`'s deprecated `keyCode` property to use its `key` property instead.
544
-
545
- ### Context
546
-
547
- Since current testing library tooling (such as `userEvent`) no longer provides a keyCode along with synthetic keyboard events,
548
- upgrading testing libaries could cause tests to break. By removing the usage of `keyCode` in our codebase, this enables testing libary upgrades.
549
-
550
- ### Migration steps
551
-
552
- Use `KeyboardEvent`'s `key` property instead `keyCode` property to identify key presses.
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare function Truncated(): React.JSX.Element;
3
- export default Truncated;
@@ -1,44 +0,0 @@
1
- import React from 'react';
2
- import PropTypes from 'prop-types';
3
- import { ComponentProps } from '../utils/types';
4
- interface TreeItemPropsBase {
5
- /** A unique `id` for this item and used by `Tree` to keep track of the focused item. */
6
- id: string;
7
- /** Should contain `TreeItems`, can also include other elements to display in between tree items. */
8
- children?: React.ReactNode;
9
- /** Content to show on the TreeItem. */
10
- content?: React.ReactNode;
11
- /** Custom indent to show before TreeItem content. */
12
- customIndent?: React.ReactNode;
13
- endAdornment?: React.ReactNode;
14
- labelledBy?: string;
15
- onFocus?: React.FocusEventHandler<HTMLLIElement>;
16
- onKeyDown?: React.KeyboardEventHandler<HTMLLIElement>;
17
- onToggle?: TreeItemToggleHandler;
18
- /** Default open state of the node. */
19
- open?: boolean;
20
- /** Toggle to pass that opens/closes the node on click. */
21
- toggle?: React.ReactElement;
22
- }
23
- type TreeItemProps = ComponentProps<TreeItemPropsBase, 'li'>;
24
- type TreeItemClickHandler = (event: React.MouseEvent<HTMLSpanElement>, id: string) => void;
25
- type TreeItemKeyDownHandler = (event: React.KeyboardEvent<HTMLLIElement>, id: string, showChildren: boolean | undefined, childrenCleaned: React.ReactElement[] | undefined | null, handleToggle: TreeItemToggleHandler) => void;
26
- type TreeItemToggleHandler = (isOpen: boolean, event?: React.KeyboardEvent<HTMLLIElement> | React.MouseEvent<HTMLSpanElement>) => void;
27
- declare function TreeItem({ id, children, content, customIndent, endAdornment, labelledBy, onFocus, onKeyDown, onToggle, open, toggle, ...otherProps }: TreeItemProps): React.JSX.Element;
28
- declare namespace TreeItem {
29
- var propTypes: {
30
- id: PropTypes.Requireable<string>;
31
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
32
- content: PropTypes.Requireable<PropTypes.ReactNodeLike>;
33
- customIndent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
34
- endAdornment: PropTypes.Requireable<PropTypes.ReactNodeLike>;
35
- labelledBy: PropTypes.Requireable<string>;
36
- onFocus: PropTypes.Requireable<(...args: any[]) => any>;
37
- onKeyDown: PropTypes.Requireable<(...args: any[]) => any>;
38
- onToggle: PropTypes.Requireable<(...args: any[]) => any>;
39
- open: PropTypes.Requireable<boolean>;
40
- toggle: PropTypes.Requireable<PropTypes.ReactNodeLike>;
41
- };
42
- }
43
- export default TreeItem;
44
- export { TreeItemClickHandler, TreeItemKeyDownHandler, TreeItemPropsBase, TreeItemToggleHandler };