@carbon/react 1.85.1 → 1.86.0-rc.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 (189) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +816 -816
  2. package/es/components/AILabel/index.js +1 -1
  3. package/es/components/Accordion/AccordionItem.d.ts +1 -1
  4. package/es/components/Accordion/AccordionItem.js +1 -1
  5. package/es/components/Checkbox/Checkbox.js +1 -1
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +1 -1
  7. package/es/components/CodeSnippet/CodeSnippet.d.ts +2 -2
  8. package/es/components/CodeSnippet/CodeSnippet.js +1 -1
  9. package/es/components/ComboBox/ComboBox.js +1 -1
  10. package/es/components/ComposedModal/ComposedModal.js +1 -1
  11. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  12. package/es/components/ContentSwitcher/ContentSwitcher.js +1 -1
  13. package/es/components/DataTable/DataTable.d.ts +230 -170
  14. package/es/components/DataTable/DataTable.js +508 -519
  15. package/es/components/DataTable/TableContainer.d.ts +9 -1
  16. package/es/components/DataTable/TableContainer.js +7 -1
  17. package/es/components/DataTable/TableExpandHeader.d.ts +1 -1
  18. package/es/components/DataTable/TableExpandHeader.js +1 -1
  19. package/es/components/DataTable/TableSelectAll.d.ts +2 -2
  20. package/es/components/DataTable/TableSelectAll.js +1 -1
  21. package/es/components/DataTable/TableSelectRow.d.ts +2 -2
  22. package/es/components/DataTable/TableSelectRow.js +1 -1
  23. package/es/components/DataTable/TableToolbar.d.ts +1 -1
  24. package/es/components/DataTable/TableToolbar.js +1 -1
  25. package/es/components/DataTable/TableToolbarMenu.d.ts +2 -18
  26. package/es/components/DataTable/TableToolbarMenu.js +0 -1
  27. package/es/components/DataTable/index.d.ts +1 -1
  28. package/es/components/DataTable/state/getDerivedStateFromProps.js +5 -1
  29. package/es/components/DatePicker/DatePicker.js +1 -1
  30. package/es/components/DatePickerInput/DatePickerInput.js +1 -1
  31. package/es/components/Dropdown/Dropdown.js +1 -1
  32. package/es/components/FeatureFlags/index.d.ts +2 -2
  33. package/es/components/FeatureFlags/index.js +1 -1
  34. package/es/components/FileUploader/FileUploaderButton.d.ts +1 -1
  35. package/es/components/FileUploader/FileUploaderButton.js +1 -1
  36. package/es/components/FileUploader/FileUploaderDropContainer.d.ts +2 -2
  37. package/es/components/FileUploader/FileUploaderDropContainer.js +1 -1
  38. package/es/components/FluidTextArea/FluidTextArea.d.ts +1 -1
  39. package/es/components/FluidTextArea/FluidTextArea.js +1 -1
  40. package/es/components/InlineCheckbox/InlineCheckbox.js +1 -1
  41. package/es/components/ListBox/ListBox.js +1 -1
  42. package/es/components/Loading/Loading.d.ts +1 -1
  43. package/es/components/Loading/Loading.js +1 -1
  44. package/es/components/Menu/Menu.js +1 -1
  45. package/es/components/Modal/Modal.js +1 -1
  46. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
  47. package/es/components/MultiSelect/MultiSelect.js +1 -1
  48. package/es/components/Notification/Notification.d.ts +4 -4
  49. package/es/components/Notification/Notification.js +1 -1
  50. package/es/components/NumberInput/NumberInput.d.ts +7 -0
  51. package/es/components/NumberInput/NumberInput.js +80 -25
  52. package/es/components/OverflowMenu/OverflowMenu.d.ts +2 -6
  53. package/es/components/OverflowMenu/OverflowMenu.js +1 -1
  54. package/es/components/Pagination/Pagination.js +22 -5
  55. package/es/components/RadioButton/RadioButton.js +1 -1
  56. package/es/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  57. package/es/components/RadioTile/RadioTile.js +1 -1
  58. package/es/components/Search/Search.js +1 -1
  59. package/es/components/Select/Select.js +1 -1
  60. package/es/components/Slider/Slider.js +1 -1
  61. package/es/components/StructuredList/StructuredList.d.ts +5 -5
  62. package/es/components/StructuredList/StructuredList.js +1 -1
  63. package/es/components/Tabs/Tabs.d.ts +1 -1
  64. package/es/components/Tabs/Tabs.js +1 -1
  65. package/es/components/Tag/DismissibleTag.js +1 -1
  66. package/es/components/Tag/Tag.js +1 -1
  67. package/es/components/TextArea/TextArea.js +1 -1
  68. package/es/components/TextInput/ControlledPasswordInput.js +1 -1
  69. package/es/components/TextInput/PasswordInput.js +1 -1
  70. package/es/components/TextInput/TextInput.js +1 -1
  71. package/es/components/Tile/Tile.js +1 -1
  72. package/es/components/TileGroup/TileGroup.d.ts +5 -5
  73. package/es/components/TimePicker/TimePicker.d.ts +8 -0
  74. package/es/components/TimePicker/TimePicker.js +6 -4
  75. package/es/components/Tooltip/DefinitionTooltip.d.ts +1 -1
  76. package/es/components/Tooltip/DefinitionTooltip.js +1 -1
  77. package/es/components/TreeView/TreeContext.d.ts +19 -0
  78. package/es/components/TreeView/TreeContext.js +13 -0
  79. package/es/components/TreeView/TreeNode.d.ts +4 -4
  80. package/es/components/TreeView/TreeNode.js +56 -108
  81. package/es/components/TreeView/TreeView.js +42 -79
  82. package/es/components/UIShell/HeaderMenu.js +1 -1
  83. package/es/components/UIShell/HeaderMenuItem.d.ts +1 -1
  84. package/es/components/UIShell/HeaderMenuItem.js +1 -1
  85. package/es/components/UIShell/HeaderName.d.ts +1 -1
  86. package/es/components/UIShell/Link.d.ts +2 -2
  87. package/es/components/UIShell/Link.js +1 -1
  88. package/es/components/UIShell/Switcher.d.ts +1 -1
  89. package/es/components/UIShell/Switcher.js +39 -12
  90. package/es/index.js +1 -1
  91. package/es/internal/useNoInteractiveChildren.d.ts +25 -0
  92. package/es/internal/useNoInteractiveChildren.js +39 -32
  93. package/es/prop-types/deprecate.d.ts +17 -0
  94. package/es/prop-types/deprecate.js +22 -12
  95. package/lib/components/AILabel/index.js +2 -2
  96. package/lib/components/Accordion/AccordionItem.d.ts +1 -1
  97. package/lib/components/Accordion/AccordionItem.js +1 -1
  98. package/lib/components/Checkbox/Checkbox.js +1 -1
  99. package/lib/components/CheckboxGroup/CheckboxGroup.js +1 -1
  100. package/lib/components/CodeSnippet/CodeSnippet.d.ts +2 -2
  101. package/lib/components/CodeSnippet/CodeSnippet.js +2 -2
  102. package/lib/components/ComboBox/ComboBox.js +3 -3
  103. package/lib/components/ComposedModal/ComposedModal.js +1 -1
  104. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  105. package/lib/components/ContentSwitcher/ContentSwitcher.js +1 -1
  106. package/lib/components/DataTable/DataTable.d.ts +230 -170
  107. package/lib/components/DataTable/DataTable.js +507 -518
  108. package/lib/components/DataTable/TableContainer.d.ts +9 -1
  109. package/lib/components/DataTable/TableContainer.js +7 -1
  110. package/lib/components/DataTable/TableExpandHeader.d.ts +1 -1
  111. package/lib/components/DataTable/TableExpandHeader.js +1 -1
  112. package/lib/components/DataTable/TableSelectAll.d.ts +2 -2
  113. package/lib/components/DataTable/TableSelectAll.js +1 -1
  114. package/lib/components/DataTable/TableSelectRow.d.ts +2 -2
  115. package/lib/components/DataTable/TableSelectRow.js +1 -1
  116. package/lib/components/DataTable/TableToolbar.d.ts +1 -1
  117. package/lib/components/DataTable/TableToolbar.js +1 -1
  118. package/lib/components/DataTable/TableToolbarMenu.d.ts +2 -18
  119. package/lib/components/DataTable/TableToolbarMenu.js +0 -1
  120. package/lib/components/DataTable/index.d.ts +1 -1
  121. package/lib/components/DataTable/state/getDerivedStateFromProps.js +5 -1
  122. package/lib/components/DatePicker/DatePicker.js +1 -1
  123. package/lib/components/DatePickerInput/DatePickerInput.js +1 -1
  124. package/lib/components/Dropdown/Dropdown.js +3 -3
  125. package/lib/components/FeatureFlags/index.d.ts +2 -2
  126. package/lib/components/FeatureFlags/index.js +1 -1
  127. package/lib/components/FileUploader/FileUploaderButton.d.ts +1 -1
  128. package/lib/components/FileUploader/FileUploaderButton.js +1 -1
  129. package/lib/components/FileUploader/FileUploaderDropContainer.d.ts +2 -2
  130. package/lib/components/FileUploader/FileUploaderDropContainer.js +2 -2
  131. package/lib/components/FluidTextArea/FluidTextArea.d.ts +1 -1
  132. package/lib/components/FluidTextArea/FluidTextArea.js +1 -1
  133. package/lib/components/InlineCheckbox/InlineCheckbox.js +1 -1
  134. package/lib/components/ListBox/ListBox.js +1 -1
  135. package/lib/components/Loading/Loading.d.ts +1 -1
  136. package/lib/components/Loading/Loading.js +1 -1
  137. package/lib/components/Menu/Menu.js +1 -1
  138. package/lib/components/Modal/Modal.js +1 -1
  139. package/lib/components/MultiSelect/FilterableMultiSelect.js +4 -4
  140. package/lib/components/MultiSelect/MultiSelect.js +2 -2
  141. package/lib/components/Notification/Notification.d.ts +4 -4
  142. package/lib/components/Notification/Notification.js +4 -4
  143. package/lib/components/NumberInput/NumberInput.d.ts +7 -0
  144. package/lib/components/NumberInput/NumberInput.js +81 -26
  145. package/lib/components/OverflowMenu/OverflowMenu.d.ts +2 -6
  146. package/lib/components/OverflowMenu/OverflowMenu.js +2 -2
  147. package/lib/components/Pagination/Pagination.js +21 -4
  148. package/lib/components/RadioButton/RadioButton.js +1 -1
  149. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +1 -1
  150. package/lib/components/RadioTile/RadioTile.js +2 -2
  151. package/lib/components/Search/Search.js +1 -1
  152. package/lib/components/Select/Select.js +2 -2
  153. package/lib/components/Slider/Slider.js +1 -1
  154. package/lib/components/StructuredList/StructuredList.d.ts +5 -5
  155. package/lib/components/StructuredList/StructuredList.js +4 -4
  156. package/lib/components/Tabs/Tabs.d.ts +1 -1
  157. package/lib/components/Tabs/Tabs.js +1 -1
  158. package/lib/components/Tag/DismissibleTag.js +1 -1
  159. package/lib/components/Tag/Tag.js +4 -4
  160. package/lib/components/TextArea/TextArea.js +2 -2
  161. package/lib/components/TextInput/ControlledPasswordInput.js +1 -1
  162. package/lib/components/TextInput/PasswordInput.js +1 -1
  163. package/lib/components/TextInput/TextInput.js +2 -2
  164. package/lib/components/Tile/Tile.js +9 -9
  165. package/lib/components/TileGroup/TileGroup.d.ts +5 -5
  166. package/lib/components/TimePicker/TimePicker.d.ts +8 -0
  167. package/lib/components/TimePicker/TimePicker.js +6 -4
  168. package/lib/components/Tooltip/DefinitionTooltip.d.ts +1 -1
  169. package/lib/components/Tooltip/DefinitionTooltip.js +1 -1
  170. package/lib/components/TreeView/TreeContext.d.ts +19 -0
  171. package/lib/components/TreeView/TreeContext.js +18 -0
  172. package/lib/components/TreeView/TreeNode.d.ts +4 -4
  173. package/lib/components/TreeView/TreeNode.js +55 -107
  174. package/lib/components/TreeView/TreeView.js +41 -78
  175. package/lib/components/UIShell/HeaderMenu.js +1 -1
  176. package/lib/components/UIShell/HeaderMenuItem.d.ts +1 -1
  177. package/lib/components/UIShell/HeaderMenuItem.js +1 -1
  178. package/lib/components/UIShell/HeaderName.d.ts +1 -1
  179. package/lib/components/UIShell/Link.d.ts +2 -2
  180. package/lib/components/UIShell/Link.js +1 -1
  181. package/lib/components/UIShell/Switcher.d.ts +1 -1
  182. package/lib/components/UIShell/Switcher.js +38 -11
  183. package/lib/index.js +1 -1
  184. package/lib/internal/useNoInteractiveChildren.d.ts +25 -0
  185. package/lib/internal/useNoInteractiveChildren.js +39 -32
  186. package/lib/prop-types/deprecate.d.ts +17 -0
  187. package/lib/prop-types/deprecate.js +22 -12
  188. package/package.json +3 -3
  189. package/telemetry.yml +15 -14
@@ -13,7 +13,7 @@ import React, { useContext, useState, useMemo, useCallback, useRef, useEffect, c
13
13
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
14
14
  import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
- import deprecate from '../../prop-types/deprecate.js';
16
+ import { deprecate } from '../../prop-types/deprecate.js';
17
17
  import '../FluidForm/FluidForm.js';
18
18
  import { FormContext } from '../FluidForm/FormContext.js';
19
19
  import '../Text/index.js';
@@ -48,7 +48,6 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
48
48
  decorator,
49
49
  disabled = false,
50
50
  disableWheel: disableWheelProp = false,
51
- defaultValue = 0,
52
51
  formatOptions,
53
52
  helperText = '',
54
53
  hideLabel = false,
@@ -63,6 +62,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
63
62
  locale = 'en-US',
64
63
  max,
65
64
  min,
65
+ onBlur,
66
66
  onChange,
67
67
  onClick,
68
68
  onKeyUp,
@@ -73,6 +73,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
73
73
  step = 1,
74
74
  translateWithId: t = id => defaultTranslations[id],
75
75
  type = 'number',
76
+ defaultValue = type === 'number' ? 0 : NaN,
76
77
  warn = false,
77
78
  warnText = '',
78
79
  value: controlledValue,
@@ -112,6 +113,12 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
112
113
  value: typeof controlledValue === 'string' ? numberParser.parse(controlledValue) : controlledValue
113
114
  });
114
115
 
116
+ /**
117
+ * The number value that was previously "committed" to the input on blur
118
+ * Only used when type="text"
119
+ */
120
+ const [previousNumberValue, setPreviousNumberValue] = useState(numberValue);
121
+
115
122
  /**
116
123
  * The current text value of the input.
117
124
  * Only used when type=text
@@ -124,6 +131,10 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
124
131
  numberingSystem
125
132
  }), [locale, formatOptions, numberingSystem]);
126
133
  const format = useCallback(value => isNaN(value) || value === null ? '' : numberFormatter.format(value), [numberFormatter]);
134
+ if (isControlled && !(isNaN(previousNumberValue) && isNaN(numberValue)) && previousNumberValue !== numberValue) {
135
+ setInputValue(format(numberValue));
136
+ setPreviousNumberValue(numberValue);
137
+ }
127
138
  const inputRef = useRef(null);
128
139
  const ref = useMergedRefs([forwardRef, inputRef]);
129
140
  const numberInputClasses = cx({
@@ -161,7 +172,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
161
172
  [`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
162
173
  [`${prefix}--number__invalid--warning`]: normalizedProps.warn
163
174
  });
164
- if (controlledValue !== prevControlledValue) {
175
+ if (controlledValue !== prevControlledValue && !(isNaN(Number(controlledValue)) === isNaN(Number(prevControlledValue)))) {
165
176
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
166
177
  setValue(controlledValue);
167
178
  setPrevControlledValue(controlledValue);
@@ -193,6 +204,8 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
193
204
  }
194
205
  if (type === 'text') {
195
206
  const _value = allowEmpty && event.target.value === '' ? '' : event.target.value;
207
+
208
+ // When isControlled, setNumberValue will not update numberValue in useControllableState.
196
209
  setNumberValue(numberParser.parse(_value));
197
210
  setInputValue(_value);
198
211
  // The onChange prop isn't called here because it will be called on blur
@@ -221,30 +234,46 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
221
234
  };
222
235
  const handleStep = (event, direction) => {
223
236
  if (inputRef.current) {
224
- const currentValue = type === 'number' ? Number(inputRef.current.value) : numberParser.parse(inputRef.current.value);
225
- const rawValue = direction === 'up' ? currentValue + step : currentValue - step;
237
+ const currentValue = type === 'number' ? Number(inputRef.current.value) : numberValue;
238
+ let rawValue;
239
+ if (Number.isNaN(currentValue)) {
240
+ // When the field is empty (NaN), incrementing begins at min,
241
+ // decrementing begins at max.
242
+ // When there's no min or max to use, it begins at 0.
243
+ if (direction === `up` && min) {
244
+ rawValue = min;
245
+ } else if (direction === `down` && max) {
246
+ rawValue = max;
247
+ } else {
248
+ rawValue = 0;
249
+ }
250
+ } else if (direction === 'up') {
251
+ rawValue = currentValue + step;
252
+ } else {
253
+ rawValue = currentValue - step;
254
+ }
226
255
  const precision = Math.max(getDecimalPlaces(currentValue), getDecimalPlaces(step));
227
256
  const floatValue = parseFloat(rawValue.toFixed(precision));
228
257
  const newValue = clamp(floatValue, min ?? -Infinity, max ?? Infinity);
229
- let state;
258
+ const state = {
259
+ value: newValue,
260
+ direction
261
+ };
230
262
  if (type === 'number') {
231
- state = {
232
- value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : newValue,
233
- direction
234
- };
235
263
  setValue(state.value);
236
264
  }
237
265
  if (type === 'text') {
266
+ // Calling format() can alter the number (such as rounding it) causing
267
+ // the numberValue to mismatch the formatted value in the input.
268
+ // To avoid this, the newValue is re-parsed after formatting.
238
269
  const formattedNewValue = format(newValue);
239
- state = {
240
- value: allowEmpty && inputRef.current.value === '' && step === 0 ? '' : formattedNewValue,
241
- direction
242
- };
270
+ const parsedFormattedNewValue = numberParser.parse(formattedNewValue);
243
271
 
244
- // newValue does not need to be parsed because it is derived from
245
- // currentValue, which is parsed at the beginning of this function
246
- setNumberValue(newValue);
272
+ // When isControlled, setNumberValue will not actually update
273
+ // numberValue in useControllableState.
274
+ setNumberValue(parsedFormattedNewValue);
247
275
  setInputValue(formattedNewValue);
276
+ setPreviousNumberValue(parsedFormattedNewValue);
248
277
  }
249
278
  if (onChange) {
250
279
  onChange(event, state);
@@ -254,9 +283,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
254
283
  };
255
284
  const handleStepperClick = (event, direction) => {
256
285
  if (inputRef.current) {
257
- const {
258
- state
259
- } = handleStep(event, direction);
286
+ const state = handleStep(event, direction);
260
287
  if (onClick) {
261
288
  onClick(event, state);
262
289
  }
@@ -336,16 +363,37 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
336
363
  const _numberValue = isControlled ? numberParser.parse(inputValue) : numberValue;
337
364
  const formattedValue = isNaN(_numberValue) ? '' : format(_numberValue);
338
365
  setInputValue(formattedValue);
366
+
367
+ // Calling format() can alter the number (such as rounding it)
368
+ // causing the _numberValue to mismatch the formatted value in
369
+ // the input. To avoid this, formattedValue is re-parsed.
370
+ const parsedFormattedNewValue = numberParser.parse(formattedValue);
339
371
  if (onChange) {
340
372
  const state = {
341
- value: formattedValue,
342
- direction: value < e.target.value ? 'up' : 'down'
373
+ value: parsedFormattedNewValue,
374
+ direction: previousNumberValue < parsedFormattedNewValue ? 'up' : 'down'
343
375
  };
344
- onChange(e, state);
376
+
377
+ // If the old and new values are NaN, don't call onChange
378
+ // to avoid an unecessary re-render and potential infinite
379
+ // loop when isControlled.
380
+ if (!(isNaN(previousNumberValue) && isNaN(parsedFormattedNewValue))) {
381
+ onChange(e, state);
382
+ }
383
+ }
384
+
385
+ // If the old and new values are NaN, don't set state to avoid
386
+ // an unecessary re-render and potential infinite loop when
387
+ // isControlled.
388
+ if (!(isNaN(previousNumberValue) && isNaN(numberValue))) {
389
+ setPreviousNumberValue(numberValue);
390
+ }
391
+ if (!(isNaN(numberValue) && isNaN(parsedFormattedNewValue))) {
392
+ setNumberValue(parsedFormattedNewValue);
345
393
  }
346
394
  }
347
- if (rest.onBlur) {
348
- rest.onBlur(e);
395
+ if (onBlur) {
396
+ onBlur(e);
349
397
  }
350
398
  },
351
399
  pattern: pattern,
@@ -365,6 +413,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
365
413
  className: `${prefix}--number__control-btn down-icon`,
366
414
  disabled: disabled || readOnly,
367
415
  onClick: event => handleStepperClick(event, 'down'),
416
+ onBlur: onBlur,
368
417
  tabIndex: -1,
369
418
  title: decrementNumLabel || iconDescription,
370
419
  type: "button"
@@ -377,6 +426,7 @@ const NumberInput = /*#__PURE__*/React.forwardRef(function NumberInput(props, fo
377
426
  className: `${prefix}--number__control-btn up-icon`,
378
427
  disabled: disabled || readOnly,
379
428
  onClick: event => handleStepperClick(event, 'up'),
429
+ onBlur: onBlur,
380
430
  tabIndex: -1,
381
431
  title: incrementNumLabel || iconDescription,
382
432
  type: "button"
@@ -481,6 +531,11 @@ NumberInput.propTypes = {
481
531
  * The minimum value.
482
532
  */
483
533
  min: PropTypes.number,
534
+ /**
535
+ * Provide an optional handler that is called when the input or stepper
536
+ * buttons are blurred.
537
+ */
538
+ onBlur: PropTypes.func,
484
539
  /**
485
540
  * Provide an optional handler that is called when the internal state of
486
541
  * NumberInput changes. This handler is called with event and state info.
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React, { type ElementType, type ReactNode, type Ref } from 'react';
8
8
  import { type MenuDirection, type MenuOffset } from '../../internal/FloatingMenu';
9
- import { PopoverAlignment } from '../Popover';
9
+ import { IconButtonProps } from '../IconButton';
10
10
  /**
11
11
  * Calculates the offset for the floating menu.
12
12
  *
@@ -16,11 +16,7 @@ import { PopoverAlignment } from '../Popover';
16
16
  * the menu arrow.
17
17
  */
18
18
  export declare const getMenuOffset: MenuOffset;
19
- export interface OverflowMenuProps {
20
- /**
21
- * Specify how the trigger tooltip should be aligned.
22
- */
23
- align?: PopoverAlignment;
19
+ export interface OverflowMenuProps extends Omit<IconButtonProps, 'type' | 'aria-haspopup' | 'aria-expanded' | 'aria-controls' | 'className' | 'onClick' | 'id' | 'ref' | 'size' | 'label' | 'kind'> {
24
20
  /**
25
21
  * Specify a label to be read by screen readers on the container node
26
22
  */
@@ -16,7 +16,7 @@ import { ArrowUp, ArrowRight, ArrowDown, ArrowLeft, Escape } from '../../interna
16
16
  import { matches } from '../../internal/keyboard/match.js';
17
17
  import { noopFn } from '../../internal/noopFn.js';
18
18
  import { PrefixContext } from '../../internal/usePrefix.js';
19
- import deprecate from '../../prop-types/deprecate.js';
19
+ import { deprecate } from '../../prop-types/deprecate.js';
20
20
  import mergeRefs from '../../tools/mergeRefs.js';
21
21
  import { setupGetInstanceId } from '../../tools/setupGetInstanceId.js';
22
22
  import { IconButton } from '../IconButton/index.js';
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { CaretLeft, CaretRight } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React, { useRef, useState } from 'react';
12
+ import React, { useRef, useState, useEffect } from 'react';
13
13
  import Select from '../Select/Select.js';
14
14
  import '../Select/Select.Skeleton.js';
15
15
  import SelectItem from '../SelectItem/SelectItem.js';
@@ -83,6 +83,7 @@ const Pagination = /*#__PURE__*/React.forwardRef(function Pagination({
83
83
  const [prevPageSizes, setPrevPageSizes] = useState(controlledPageSizes);
84
84
  const [page, setPage] = useState(controlledPage);
85
85
  const [prevControlledPage, setPrevControlledPage] = useState(controlledPage);
86
+ const [focusTarget, setFocusTarget] = useState(null);
86
87
  const [pageSize, setPageSize] = useState(() => {
87
88
  return getPageSize(pageSizes, controlledPageSize);
88
89
  });
@@ -106,6 +107,22 @@ const Pagination = /*#__PURE__*/React.forwardRef(function Pagination({
106
107
  [`${prefix}--pagination__button--no-index`]: forwardButtonDisabled
107
108
  });
108
109
  const selectItems = renderSelectItems(totalPages);
110
+ const focusMap = {
111
+ backward: backBtnRef,
112
+ forward: forwardBtnRef
113
+ };
114
+ const handleFocus = target => {
115
+ const targetRef = focusMap[target];
116
+ if (targetRef?.current && !targetRef.current.disabled) {
117
+ targetRef.current.focus();
118
+ }
119
+ };
120
+ useEffect(() => {
121
+ if (focusTarget) {
122
+ handleFocus(focusTarget);
123
+ setFocusTarget(null);
124
+ }
125
+ }, [focusTarget]);
109
126
 
110
127
  // Sync state with props
111
128
  if (controlledPage !== prevControlledPage) {
@@ -162,8 +179,8 @@ const Pagination = /*#__PURE__*/React.forwardRef(function Pagination({
162
179
  // the icon button becomes disabled and the focus shifts to `main`
163
180
  // this presents an a11y problem for keyboard & screen reader users
164
181
  // instead, we want the focus to shift to the other pagination btn
165
- if (nextPage === totalPages && backBtnRef?.current) {
166
- backBtnRef.current.focus();
182
+ if (nextPage === totalPages) {
183
+ setFocusTarget('backward');
167
184
  }
168
185
  if (onChange) {
169
186
  onChange({
@@ -181,8 +198,8 @@ const Pagination = /*#__PURE__*/React.forwardRef(function Pagination({
181
198
  // the icon button becomes disabled and the focus shifts to `main`
182
199
  // this presents an a11y problem for keyboard & screen reader users
183
200
  // instead, we want the focus to shift to the other pagination btn
184
- if (nextPage === 1 && forwardBtnRef?.current) {
185
- forwardBtnRef.current.focus();
201
+ if (nextPage === 1) {
202
+ setFocusTarget('forward');
186
203
  }
187
204
  if (onChange) {
188
205
  onChange({
@@ -10,7 +10,7 @@ import PropTypes from 'prop-types';
10
10
  import React, { useRef, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import '../Text/index.js';
13
- import deprecate from '../../prop-types/deprecate.js';
13
+ import { deprecate } from '../../prop-types/deprecate.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import { useId } from '../../internal/useId.js';
16
16
  import mergeRefs from '../../tools/mergeRefs.js';
@@ -12,7 +12,7 @@ import cx from 'classnames';
12
12
  import { Legend } from '../Text/index.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
14
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
15
- import deprecate from '../../prop-types/deprecate.js';
15
+ import { deprecate } from '../../prop-types/deprecate.js';
16
16
  import mergeRefs from '../../tools/mergeRefs.js';
17
17
  import { useId } from '../../internal/useId.js';
18
18
  import { AILabel } from '../AILabel/index.js';
@@ -14,7 +14,7 @@ import { Enter, Space } from '../../internal/keyboard/keys.js';
14
14
  import { matches } from '../../internal/keyboard/match.js';
15
15
  import { useFallbackId } from '../../internal/useId.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
- import deprecate from '../../prop-types/deprecate.js';
17
+ import { deprecate } from '../../prop-types/deprecate.js';
18
18
  import { noopFn } from '../../internal/noopFn.js';
19
19
  import '../Text/index.js';
20
20
  import { useFeatureFlag } from '../FeatureFlags/index.js';
@@ -16,7 +16,7 @@ import { useId } from '../../internal/useId.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
17
  import { composeEventHandlers } from '../../tools/events.js';
18
18
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
19
- import deprecate from '../../prop-types/deprecate.js';
19
+ import { deprecate } from '../../prop-types/deprecate.js';
20
20
  import '../FluidForm/FluidForm.js';
21
21
  import { FormContext } from '../FluidForm/FormContext.js';
22
22
  import { noopFn } from '../../internal/noopFn.js';
@@ -10,7 +10,7 @@ import PropTypes from 'prop-types';
10
10
  import React, { useContext, useState, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
12
  import { ChevronDown, WarningFilled, WarningAltFilled } from '@carbon/icons-react';
13
- import deprecate from '../../prop-types/deprecate.js';
13
+ import { deprecate } from '../../prop-types/deprecate.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import '../FluidForm/FluidForm.js';
16
16
  import { FormContext } from '../FluidForm/FormContext.js';
@@ -12,7 +12,7 @@ import cx from 'classnames';
12
12
  import { ArrowDown, ArrowLeft, ArrowUp, ArrowRight, Enter } from '../../internal/keyboard/keys.js';
13
13
  import { matches } from '../../internal/keyboard/match.js';
14
14
  import { PrefixContext } from '../../internal/usePrefix.js';
15
- import deprecate from '../../prop-types/deprecate.js';
15
+ import { deprecate } from '../../prop-types/deprecate.js';
16
16
  import { FeatureFlagContext } from '../FeatureFlags/index.js';
17
17
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
18
18
  import '../Text/index.js';
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -44,7 +44,7 @@ export declare namespace StructuredListWrapper {
44
44
  * Deprecated, please use `aria-label` instead.
45
45
  * Specify a label to be read by screen readers on the container note.
46
46
  */
47
- ariaLabel: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
47
+ ariaLabel: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
48
48
  /**
49
49
  * Provide the contents of your StructuredListWrapper
50
50
  */
@@ -167,7 +167,7 @@ export declare namespace StructuredListRow {
167
167
  /**
168
168
  * Specify whether a `<label>` should be used
169
169
  */
170
- label: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
170
+ label: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
171
171
  /**
172
172
  * Provide a handler that is invoked on the click
173
173
  */
@@ -214,7 +214,7 @@ export declare namespace StructuredListInput {
214
214
  /**
215
215
  * Specify whether the underlying input should be checked by default
216
216
  */
217
- defaultChecked: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
217
+ defaultChecked: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
218
218
  /**
219
219
  * Specify a custom `id` for the input
220
220
  */
@@ -234,7 +234,7 @@ export declare namespace StructuredListInput {
234
234
  /**
235
235
  * Specify the value of the input
236
236
  */
237
- value: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
237
+ value: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
238
238
  };
239
239
  }
240
240
  export interface StructuredListCellProps extends DivAttrs {
@@ -10,7 +10,7 @@ import React, { useState, useRef } from 'react';
10
10
  import PropTypes from 'prop-types';
11
11
  import cx from 'classnames';
12
12
  import { useId } from '../../internal/useId.js';
13
- import deprecate from '../../prop-types/deprecate.js';
13
+ import { deprecate } from '../../prop-types/deprecate.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import '../Text/index.js';
16
16
  import { RadioButtonChecked, RadioButton } from '@carbon/icons-react';
@@ -234,7 +234,7 @@ declare namespace TabList {
234
234
  /**
235
235
  * Specify whether to use the light component variant
236
236
  */
237
- light: (props: any, propName: any, componentName: any, ...rest: any[]) => any;
237
+ light: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
238
238
  /**
239
239
  * Provide the props that describe the right overflow button
240
240
  */
@@ -29,7 +29,7 @@ import { usePrefix } from '../../internal/usePrefix.js';
29
29
  import { ArrowRight, ArrowLeft, Home, End, ArrowDown, ArrowUp, Delete } from '../../internal/keyboard/keys.js';
30
30
  import { matches, match } from '../../internal/keyboard/match.js';
31
31
  import { usePressable } from './usePressable.js';
32
- import deprecate from '../../prop-types/deprecate.js';
32
+ import { deprecate } from '../../prop-types/deprecate.js';
33
33
  import { useEvent } from '../../internal/useEvent.js';
34
34
  import { useMatchMedia } from '../../internal/useMatchMedia.js';
35
35
  import '../Text/index.js';
@@ -11,7 +11,7 @@ import React, { forwardRef, useRef, useState, useLayoutEffect, cloneElement } fr
11
11
  import cx from 'classnames';
12
12
  import { useId } from '../../internal/useId.js';
13
13
  import { usePrefix } from '../../internal/usePrefix.js';
14
- import deprecate from '../../prop-types/deprecate.js';
14
+ import { deprecate } from '../../prop-types/deprecate.js';
15
15
  import Tag, { SIZES, TYPES } from './Tag.js';
16
16
  import { Close } from '@carbon/icons-react';
17
17
  import '../Tooltip/DefinitionTooltip.js';
@@ -13,7 +13,7 @@ import { Close } from '@carbon/icons-react';
13
13
  import { useId } from '../../internal/useId.js';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import '../Text/index.js';
16
- import deprecate from '../../prop-types/deprecate.js';
16
+ import { deprecate } from '../../prop-types/deprecate.js';
17
17
  import { DefinitionTooltip } from '../Tooltip/DefinitionTooltip.js';
18
18
  import '../Tooltip/Tooltip.js';
19
19
  import { isEllipsisActive } from './isEllipsisActive.js';
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import PropTypes from 'prop-types';
10
10
  import React, { useContext, useRef, useState, useEffect, forwardRef, cloneElement } from 'react';
11
11
  import cx from 'classnames';
12
- import deprecate from '../../prop-types/deprecate.js';
12
+ import { deprecate } from '../../prop-types/deprecate.js';
13
13
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
14
14
  import { usePrefix } from '../../internal/usePrefix.js';
15
15
  import '../FluidForm/FluidForm.js';
@@ -11,7 +11,7 @@ import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
12
  import { WarningFilled, ViewOff, View } from '@carbon/icons-react';
13
13
  import { textInputProps } from './util.js';
14
- import deprecate from '../../prop-types/deprecate.js';
14
+ import { deprecate } from '../../prop-types/deprecate.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
16
16
  import { useId } from '../../internal/useId.js';
17
17
  import { noopFn } from '../../internal/noopFn.js';
@@ -16,7 +16,7 @@ import '../FluidForm/FluidForm.js';
16
16
  import { FormContext } from '../FluidForm/FormContext.js';
17
17
  import '../Tooltip/DefinitionTooltip.js';
18
18
  import { Tooltip } from '../Tooltip/Tooltip.js';
19
- import deprecate from '../../prop-types/deprecate.js';
19
+ import { deprecate } from '../../prop-types/deprecate.js';
20
20
  import { usePrefix } from '../../internal/usePrefix.js';
21
21
 
22
22
  const PasswordInput = /*#__PURE__*/React.forwardRef(function PasswordInput({
@@ -9,7 +9,7 @@ import PropTypes from 'prop-types';
9
9
  import React, { useRef, useState, useEffect, useContext, cloneElement } from 'react';
10
10
  import cx from 'classnames';
11
11
  import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
12
- import deprecate from '../../prop-types/deprecate.js';
12
+ import { deprecate } from '../../prop-types/deprecate.js';
13
13
  import { textInputProps } from './util.js';
14
14
  import '../FluidForm/FluidForm.js';
15
15
  import { FormContext } from '../FluidForm/FormContext.js';
@@ -13,7 +13,7 @@ import { AiLabel, CheckboxCheckedFilled, Checkbox, ChevronDown, ArrowRight, Erro
13
13
  import Link from '../Link/Link.js';
14
14
  import { Enter, Space } from '../../internal/keyboard/keys.js';
15
15
  import { matches } from '../../internal/keyboard/match.js';
16
- import deprecate from '../../prop-types/deprecate.js';
16
+ import { deprecate } from '../../prop-types/deprecate.js';
17
17
  import { composeEventHandlers } from '../../tools/events.js';
18
18
  import { usePrefix } from '../../internal/usePrefix.js';
19
19
  import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
@@ -7,7 +7,7 @@
7
7
  import PropTypes from 'prop-types';
8
8
  import { type HTMLAttributes, type ReactNode } from 'react';
9
9
  type ExcludedAttributes = 'onChange';
10
- export interface TileGroupProps extends Omit<HTMLAttributes<HTMLFieldSetElement>, ExcludedAttributes> {
10
+ export interface TileGroupProps<T = string | number> extends Omit<HTMLAttributes<HTMLFieldSetElement>, ExcludedAttributes> {
11
11
  /**
12
12
  * Provide a collection of <RadioTile> components to render in the group
13
13
  */
@@ -19,7 +19,7 @@ export interface TileGroupProps extends Omit<HTMLAttributes<HTMLFieldSetElement>
19
19
  /**
20
20
  * Specify the the value of <RadioTile> to be selected by default
21
21
  */
22
- defaultSelected?: string | number;
22
+ defaultSelected?: T;
23
23
  /**
24
24
  * Specify whether the group is disabled
25
25
  */
@@ -35,18 +35,18 @@ export interface TileGroupProps extends Omit<HTMLAttributes<HTMLFieldSetElement>
35
35
  /**
36
36
  * Provide an optional `onChange` hook that is called whenever the value of the group changes
37
37
  */
38
- onChange?: (selection: unknown, name: string, evt: unknown) => void;
38
+ onChange?: (selection: T, name: string, evt: unknown) => void;
39
39
  /**
40
40
  * Specify the value that is currently selected in the group
41
41
  */
42
- valueSelected?: string | number;
42
+ valueSelected?: T;
43
43
  /**
44
44
  * `true` to specify if input selection in group is required.
45
45
  */
46
46
  required?: boolean;
47
47
  }
48
48
  export declare const TileGroup: {
49
- ({ children, className, defaultSelected, disabled, legend, name, onChange, valueSelected, required, }: TileGroupProps): import("react/jsx-runtime").JSX.Element;
49
+ <T extends string | number = string>({ children, className, defaultSelected, disabled, legend, name, onChange, valueSelected, required, }: TileGroupProps<T>): import("react/jsx-runtime").JSX.Element;
50
50
  displayName: string;
51
51
  propTypes: {
52
52
  /**
@@ -15,6 +15,14 @@ export interface TimePickerProps extends Omit<HTMLAttributes<HTMLInputElement>,
15
15
  * Specify an optional className to be applied to the container node
16
16
  */
17
17
  className?: string;
18
+ /**
19
+ * Specify an optional className to be applied to the `<input>` node
20
+ */
21
+ inputClassName?: string;
22
+ /**
23
+ * Specify an optional className to be applied to the container that wraps the `<input>` and select option
24
+ */
25
+ pickerClassName?: string;
18
26
  /**
19
27
  * Specify whether the `<input>` should be disabled
20
28
  */
@@ -10,7 +10,7 @@ import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
11
  import React, { forwardRef } from 'react';
12
12
  import { usePrefix } from '../../internal/usePrefix.js';
13
- import deprecate from '../../prop-types/deprecate.js';
13
+ import { deprecate } from '../../prop-types/deprecate.js';
14
14
  import { WarningFilled, WarningAltFilled } from '@carbon/icons-react';
15
15
 
16
16
  const frFn = forwardRef;
@@ -18,6 +18,8 @@ const TimePicker = frFn((props, ref) => {
18
18
  const {
19
19
  children,
20
20
  className,
21
+ inputClassName,
22
+ pickerClassName,
21
23
  disabled = false,
22
24
  hideLabel,
23
25
  id,
@@ -68,7 +70,7 @@ const TimePicker = frFn((props, ref) => {
68
70
  onBlur(evt);
69
71
  }
70
72
  }
71
- const timePickerInputClasses = cx(`${prefix}--time-picker__input-field`, `${prefix}--text-input`, [className], {
73
+ const timePickerInputClasses = cx(`${prefix}--time-picker__input-field`, `${prefix}--text-input`, [inputClassName], {
72
74
  [`${prefix}--text-input--light`]: light,
73
75
  [`${prefix}--time-picker__input-field-error`]: invalid || warning
74
76
  });
@@ -79,8 +81,8 @@ const TimePicker = frFn((props, ref) => {
79
81
  [`${prefix}--time-picker--warning`]: warning,
80
82
  [`${prefix}--time-picker--readonly`]: readOnly,
81
83
  [`${prefix}--time-picker--${size}`]: size,
82
- ...(className && {
83
- [className]: true
84
+ ...(pickerClassName && {
85
+ [pickerClassName]: true
84
86
  })
85
87
  });
86
88
  const labelClasses = cx(`${prefix}--label`, {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
@@ -14,7 +14,7 @@ import { Escape } from '../../internal/keyboard/keys.js';
14
14
  import { match } from '../../internal/keyboard/match.js';
15
15
  import { useFallbackId } from '../../internal/useId.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
17
- import deprecate from '../../prop-types/deprecate.js';
17
+ import { deprecate } from '../../prop-types/deprecate.js';
18
18
 
19
19
  const DefinitionTooltip = ({
20
20
  align = 'bottom',