@carbon/react 1.106.0 → 1.107.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 (161) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1017 -982
  2. package/es/components/Accordion/AccordionItem.d.ts +2 -2
  3. package/es/components/Button/Button.d.ts +2 -2
  4. package/es/components/Button/Button.js +1 -1
  5. package/es/components/Checkbox/Checkbox.js +2 -1
  6. package/es/components/CheckboxGroup/CheckboxGroup.js +2 -1
  7. package/es/components/ComboBox/ComboBox.d.ts +1 -1
  8. package/es/components/ComboBox/ComboBox.js +1 -1
  9. package/es/components/ComboButton/index.js +2 -2
  10. package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  11. package/es/components/ContentSwitcher/ContentSwitcher.js +24 -15
  12. package/es/components/DataTable/DataTable.d.ts +3 -3
  13. package/es/components/DataTable/TableActionList.d.ts +1 -1
  14. package/es/components/DataTable/TableHead.d.ts +1 -1
  15. package/es/components/DataTable/TableSlugRow.d.ts +2 -2
  16. package/es/components/DataTable/TableSlugRow.js +8 -11
  17. package/es/components/DataTable/TableToolbarContent.d.ts +1 -1
  18. package/es/components/DataTable/TableToolbarSearch.d.ts +5 -1
  19. package/es/components/DatePicker/DatePicker.js +15 -13
  20. package/es/components/DatePicker/plugins/fixEventsPlugin.js +2 -3
  21. package/es/components/Dropdown/Dropdown.d.ts +1 -1
  22. package/es/components/FluidTimePicker/FluidTimePicker.d.ts +1 -1
  23. package/es/components/FluidTimePicker/FluidTimePicker.js +6 -4
  24. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +4 -0
  25. package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +2 -1
  26. package/es/components/FluidTimePickerSelect/index.js +18 -0
  27. package/es/components/Grid/CSSGrid.js +11 -6
  28. package/es/components/Grid/Column.d.ts +2 -2
  29. package/es/components/Grid/ColumnHang.d.ts +3 -3
  30. package/es/components/Grid/ColumnHang.js +1 -1
  31. package/es/components/Grid/FlexGrid.js +5 -3
  32. package/es/components/Grid/Grid.js +2 -1
  33. package/es/components/Grid/GridTypes.d.ts +5 -0
  34. package/es/components/Grid/Row.d.ts +3 -3
  35. package/es/components/Grid/Row.js +1 -1
  36. package/es/components/Menu/Menu.js +1 -1
  37. package/es/components/Menu/MenuItem.js +4 -0
  38. package/es/components/Modal/Modal.d.ts +1 -1
  39. package/es/components/Modal/Modal.js +20 -6
  40. package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  41. package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
  42. package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
  43. package/es/components/NumberInput/NumberInput.js +4 -2
  44. package/es/components/OverflowMenu/OverflowMenu.js +11 -12
  45. package/es/components/Pagination/Pagination.d.ts +1 -1
  46. package/es/components/Pagination/Pagination.js +2 -0
  47. package/es/components/Popover/index.js +14 -1
  48. package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
  49. package/es/components/RadioButtonGroup/RadioButtonGroup.js +8 -6
  50. package/es/components/Search/Search.Skeleton.d.ts +12 -3
  51. package/es/components/Search/Search.Skeleton.js +16 -8
  52. package/es/components/Search/Search.d.ts +1 -1
  53. package/es/components/Search/Search.js +4 -4
  54. package/es/components/Select/Select.d.ts +1 -1
  55. package/es/components/Select/Select.js +7 -6
  56. package/es/components/Slider/Slider.js +58 -76
  57. package/es/components/Tabs/Tabs.js +2 -2
  58. package/es/components/TextArea/TextArea.js +5 -2
  59. package/es/components/TextInput/ControlledPasswordInput.js +2 -1
  60. package/es/components/TextInput/PasswordInput.d.ts +2 -2
  61. package/es/components/TextInput/PasswordInput.js +33 -21
  62. package/es/components/TextInput/TextInput.Skeleton.d.ts +10 -2
  63. package/es/components/TextInput/TextInput.Skeleton.js +10 -4
  64. package/es/components/TextInput/TextInput.d.ts +1 -1
  65. package/es/components/TextInput/TextInput.js +39 -30
  66. package/es/components/TextInput/util.d.ts +1 -0
  67. package/es/components/TextInput/util.js +1 -1
  68. package/es/components/Theme/index.d.ts +2 -2
  69. package/es/components/Theme/index.js +3 -3
  70. package/es/components/TimePicker/TimePicker.js +5 -2
  71. package/es/components/TreeView/TreeNode.js +2 -2
  72. package/es/components/UIShell/HeaderGlobalBar.d.ts +1 -1
  73. package/es/components/UIShell/HeaderMenu.d.ts +1 -1
  74. package/es/components/UIShell/HeaderMenu.js +5 -3
  75. package/es/index.js +2 -2
  76. package/es/internal/FloatingMenu.d.ts +5 -1
  77. package/es/internal/hasHelperText.d.ts +8 -0
  78. package/es/internal/hasHelperText.js +11 -0
  79. package/es/tools/wrapComponent.d.ts +3 -3
  80. package/es/tools/wrapComponent.js +1 -1
  81. package/lib/components/Accordion/AccordionItem.d.ts +2 -2
  82. package/lib/components/Button/Button.d.ts +2 -2
  83. package/lib/components/Button/Button.js +1 -1
  84. package/lib/components/Checkbox/Checkbox.js +2 -1
  85. package/lib/components/CheckboxGroup/CheckboxGroup.js +2 -1
  86. package/lib/components/ComboBox/ComboBox.d.ts +1 -1
  87. package/lib/components/ComboBox/ComboBox.js +1 -1
  88. package/lib/components/ComboButton/index.js +2 -2
  89. package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
  90. package/lib/components/ContentSwitcher/ContentSwitcher.js +22 -13
  91. package/lib/components/DataTable/DataTable.d.ts +3 -3
  92. package/lib/components/DataTable/TableActionList.d.ts +1 -1
  93. package/lib/components/DataTable/TableHead.d.ts +1 -1
  94. package/lib/components/DataTable/TableSlugRow.d.ts +2 -2
  95. package/lib/components/DataTable/TableSlugRow.js +7 -10
  96. package/lib/components/DataTable/TableToolbarContent.d.ts +1 -1
  97. package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -1
  98. package/lib/components/DatePicker/DatePicker.js +15 -13
  99. package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -2
  100. package/lib/components/Dropdown/Dropdown.d.ts +1 -1
  101. package/lib/components/FluidTimePicker/FluidTimePicker.d.ts +1 -1
  102. package/lib/components/FluidTimePicker/FluidTimePicker.js +5 -3
  103. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +4 -0
  104. package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +2 -1
  105. package/lib/components/FluidTimePickerSelect/index.js +17 -0
  106. package/lib/components/Grid/CSSGrid.js +11 -6
  107. package/lib/components/Grid/Column.d.ts +2 -2
  108. package/lib/components/Grid/ColumnHang.d.ts +3 -3
  109. package/lib/components/Grid/ColumnHang.js +1 -1
  110. package/lib/components/Grid/FlexGrid.js +5 -3
  111. package/lib/components/Grid/Grid.js +2 -1
  112. package/lib/components/Grid/GridTypes.d.ts +5 -0
  113. package/lib/components/Grid/Row.d.ts +3 -3
  114. package/lib/components/Grid/Row.js +1 -1
  115. package/lib/components/Menu/Menu.js +1 -1
  116. package/lib/components/Menu/MenuItem.js +4 -0
  117. package/lib/components/Modal/Modal.d.ts +1 -1
  118. package/lib/components/Modal/Modal.js +19 -5
  119. package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
  120. package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -2
  121. package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
  122. package/lib/components/NumberInput/NumberInput.js +4 -2
  123. package/lib/components/OverflowMenu/OverflowMenu.js +10 -11
  124. package/lib/components/Pagination/Pagination.d.ts +1 -1
  125. package/lib/components/Pagination/Pagination.js +2 -0
  126. package/lib/components/Popover/index.js +14 -1
  127. package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
  128. package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -5
  129. package/lib/components/Search/Search.Skeleton.d.ts +12 -3
  130. package/lib/components/Search/Search.Skeleton.js +15 -7
  131. package/lib/components/Search/Search.d.ts +1 -1
  132. package/lib/components/Search/Search.js +4 -4
  133. package/lib/components/Select/Select.d.ts +1 -1
  134. package/lib/components/Select/Select.js +7 -6
  135. package/lib/components/Slider/Slider.js +58 -76
  136. package/lib/components/Tabs/Tabs.js +2 -2
  137. package/lib/components/TextArea/TextArea.js +5 -2
  138. package/lib/components/TextInput/ControlledPasswordInput.js +2 -1
  139. package/lib/components/TextInput/PasswordInput.d.ts +2 -2
  140. package/lib/components/TextInput/PasswordInput.js +33 -21
  141. package/lib/components/TextInput/TextInput.Skeleton.d.ts +10 -2
  142. package/lib/components/TextInput/TextInput.Skeleton.js +10 -4
  143. package/lib/components/TextInput/TextInput.d.ts +1 -1
  144. package/lib/components/TextInput/TextInput.js +39 -30
  145. package/lib/components/TextInput/util.d.ts +1 -0
  146. package/lib/components/TextInput/util.js +1 -1
  147. package/lib/components/Theme/index.d.ts +2 -2
  148. package/lib/components/Theme/index.js +2 -2
  149. package/lib/components/TimePicker/TimePicker.js +5 -2
  150. package/lib/components/TreeView/TreeNode.js +1 -1
  151. package/lib/components/UIShell/HeaderGlobalBar.d.ts +1 -1
  152. package/lib/components/UIShell/HeaderMenu.d.ts +1 -1
  153. package/lib/components/UIShell/HeaderMenu.js +5 -3
  154. package/lib/index.js +2 -2
  155. package/lib/internal/FloatingMenu.d.ts +5 -1
  156. package/lib/internal/hasHelperText.d.ts +8 -0
  157. package/lib/internal/hasHelperText.js +11 -0
  158. package/lib/tools/wrapComponent.d.ts +3 -3
  159. package/lib/tools/wrapComponent.js +1 -1
  160. package/package.json +11 -11
  161. package/telemetry.yml +1 -0
@@ -72,18 +72,13 @@ const DRAG_STOP_EVENT_TYPES = new Set([
72
72
  "touchcancel"
73
73
  ]);
74
74
  const Slider = (props) => {
75
- const controlledValue = props.value;
76
- const controlledValueUpper = props.unstable_valueUpper;
77
- const controlledMax = props.max;
78
- const controlledMin = props.min;
79
- const onChange = props.onChange;
80
- const onRelease = props.onRelease;
75
+ const { ariaLabelInput, unstable_ariaLabelInputUpper: ariaLabelInputUpper, className, hideTextInput = false, id: idProp, min, minLabel, max, maxLabel, formatLabel = defaultFormatLabel, labelText, hideLabel, step = 1, inputType = "number", invalidText, required, disabled = false, name, unstable_nameUpper: nameUpper, light, readOnly = false, value: controlledValue, unstable_valueUpper: controlledValueUpper, invalid, onBlur, onChange, onInputKeyUp, onRelease, stepMultiplier = 4, warn = false, warnText, translateWithId: t = defaultTranslateWithId, ...other } = props;
81
76
  const [state, setState] = (0, react.useReducer)((prev, args) => ({
82
77
  ...prev,
83
78
  ...args
84
79
  }), {
85
- value: props.value,
86
- valueUpper: props.unstable_valueUpper,
80
+ value: controlledValue,
81
+ valueUpper: controlledValueUpper,
87
82
  left: 0,
88
83
  leftUpper: 0,
89
84
  needsOnRelease: false,
@@ -98,15 +93,10 @@ const Slider = (props) => {
98
93
  (0, react.useEffect)(() => {
99
94
  stateRef.current = state;
100
95
  }, [state]);
101
- const propsRef = (0, react.useRef)(props);
102
- (0, react.useEffect)(() => {
103
- propsRef.current = props;
104
- }, [props]);
105
96
  const thumbRef = (0, react.useRef)(null);
106
97
  const thumbRefUpper = (0, react.useRef)(null);
107
98
  const filledTrackRef = (0, react.useRef)(null);
108
99
  const elementRef = (0, react.useRef)(null);
109
- const trackRef = (0, react.useRef)(null);
110
100
  const generatedId = require_useId.useId();
111
101
  const prefix = require_usePrefix.usePrefix();
112
102
  const twoHandles = hasUpperValue(state.valueUpper);
@@ -196,23 +186,23 @@ const Slider = (props) => {
196
186
  const next = [
197
187
  controlledValue,
198
188
  controlledValueUpper,
199
- controlledMax,
200
- controlledMin
189
+ max,
190
+ min
201
191
  ];
202
192
  if (!prev || prev[0] !== next[0] || prev[1] !== next[1] || prev[2] !== next[2] || prev[3] !== next[3]) {
203
193
  setState({
204
194
  value: controlledValue,
205
195
  left: calcRawLeftPercent({
206
- max: controlledMax,
207
- min: controlledMin,
196
+ max,
197
+ min,
208
198
  value: controlledValue
209
199
  }) * 100
210
200
  });
211
201
  if (typeof controlledValueUpper !== "undefined") setState({
212
202
  valueUpper: controlledValueUpper,
213
203
  leftUpper: calcRawLeftPercent({
214
- max: controlledMax,
215
- min: controlledMin,
204
+ max,
205
+ min,
216
206
  value: controlledValueUpper
217
207
  }) * 100
218
208
  });
@@ -223,10 +213,10 @@ const Slider = (props) => {
223
213
  prevSyncKeysRef.current = next;
224
214
  }
225
215
  }, [
226
- controlledMax,
227
- controlledMin,
228
216
  controlledValue,
229
- controlledValueUpper
217
+ controlledValueUpper,
218
+ max,
219
+ min
230
220
  ]);
231
221
  /**
232
222
  * Rounds a given value to the nearest step defined by the slider's `step`
@@ -236,7 +226,7 @@ const Slider = (props) => {
236
226
  * @returns The value rounded to the precision determined by the step.
237
227
  */
238
228
  const nearestStepValue = (value = 0) => {
239
- const decimals = (props.step?.toString().split(".")[1] ?? "").length;
229
+ const decimals = (step.toString().split(".")[1] ?? "").length;
240
230
  return Number(value.toFixed(decimals));
241
231
  };
242
232
  const handleDrag = (event) => {
@@ -248,7 +238,7 @@ const Slider = (props) => {
248
238
  * event.
249
239
  */
250
240
  const onDragStart = (evt) => {
251
- if (props.disabled || props.readOnly) return;
241
+ if (disabled || readOnly) return;
252
242
  evt.preventDefault();
253
243
  DRAG_STOP_EVENT_TYPES.forEach((element) => {
254
244
  elementRef.current?.ownerDocument.addEventListener(element, onDragStop);
@@ -277,18 +267,18 @@ const Slider = (props) => {
277
267
  * indicating that the `onRelease` callback should be called.
278
268
  */
279
269
  const onDragStop = () => {
280
- if (props.disabled || props.readOnly) return;
270
+ if (disabled || readOnly) return;
281
271
  DRAG_STOP_EVENT_TYPES.forEach((element) => {
282
272
  elementRef.current?.ownerDocument.removeEventListener(element, onDragStop);
283
273
  });
284
274
  DRAG_EVENT_TYPES.forEach((element) => {
285
275
  elementRef.current?.ownerDocument.removeEventListener(element, handleDrag);
286
276
  });
287
- setState({
288
- needsOnRelease: true,
289
- isValid: true,
290
- isValidUpper: true
291
- });
277
+ setState({ needsOnRelease: true });
278
+ };
279
+ const getValidityUpdateForHandle = (handle, validity) => {
280
+ if (typeof invalid !== "undefined") return {};
281
+ return handle === "upper" ? { isValidUpper: validity } : { isValid: validity };
292
282
  };
293
283
  /**
294
284
  * Handles a "drag" event by recalculating the value/thumb and setting state
@@ -301,7 +291,7 @@ const Slider = (props) => {
301
291
  const _onDragRef = (0, react.useRef)(null);
302
292
  _onDragRef.current = (evt, activeHandle) => {
303
293
  activeHandle = activeHandle ?? stateRef.current.activeHandle;
304
- if (propsRef.current.disabled || propsRef.current.readOnly) return;
294
+ if (disabled || readOnly) return;
305
295
  const { value, left } = calcValue({
306
296
  clientX: getClientXFromEvent(evt),
307
297
  value: stateRef.current.value
@@ -313,7 +303,7 @@ const Slider = (props) => {
313
303
  else setState({
314
304
  value: nearestStepValue(value),
315
305
  left,
316
- isValid: true
306
+ ...getValidityUpdateForHandle("lower", true)
317
307
  });
318
308
  setState({
319
309
  correctedValue: null,
@@ -335,25 +325,24 @@ const Slider = (props) => {
335
325
  * state accordingly.
336
326
  */
337
327
  const onKeyDown = (evt) => {
338
- if (props.disabled || props.readOnly) return;
339
- const { step = 1, stepMultiplier = 4 } = props;
328
+ if (disabled || readOnly) return;
340
329
  let delta = 0;
341
330
  if (require_match.matches(evt, [require_keys.ArrowDown, require_keys.ArrowLeft])) delta = -step;
342
331
  else if (require_match.matches(evt, [require_keys.ArrowUp, require_keys.ArrowRight])) delta = step;
343
332
  else return;
344
333
  if (evt.shiftKey) delta *= stepMultiplier;
345
334
  if (twoHandles && state.activeHandle) {
346
- const { value, left } = calcValue({ value: calcValueForDelta((state.activeHandle === "lower" ? state.value : state.valueUpper) ?? props.min, delta, props.step) });
335
+ const { value, left } = calcValue({ value: calcValueForDelta((state.activeHandle === "lower" ? state.value : state.valueUpper) ?? min, delta, step) });
347
336
  setValueLeftForHandle(state.activeHandle, {
348
337
  value: nearestStepValue(value),
349
338
  left
350
339
  });
351
340
  } else {
352
- const { value, left } = calcValue({ value: calcValueForDelta(state.value, delta, props.step) });
341
+ const { value, left } = calcValue({ value: calcValueForDelta(state.value, delta, step) });
353
342
  setState({
354
343
  value: nearestStepValue(value),
355
344
  left,
356
- isValid: true
345
+ ...getValidityUpdateForHandle("lower", true)
357
346
  });
358
347
  }
359
348
  setState({
@@ -367,22 +356,22 @@ const Slider = (props) => {
367
356
  * setting state accordingly.
368
357
  */
369
358
  const onChangeInput = (evt) => {
370
- if (props.disabled || props.readOnly) return;
359
+ if (disabled || readOnly) return;
371
360
  const activeHandle = evt.target.dataset.handlePosition ?? "lower";
372
361
  const targetValue = Number.parseFloat(evt.target.value);
373
362
  if (twoHandles) if (isNaN(targetValue)) setValueForHandle(activeHandle, evt.target.value);
374
363
  else if (isValidValueForPosition({
375
364
  handle: activeHandle,
376
365
  value: targetValue,
377
- min: props.min,
378
- max: props.max
366
+ min,
367
+ max
379
368
  })) processNewInputValue(evt.target);
380
369
  else setValueForHandle(activeHandle, targetValue);
381
370
  else if (isNaN(targetValue)) setState({ value: evt.target.value });
382
371
  else if (isValidValue({
383
372
  value: targetValue,
384
- min: props.min,
385
- max: props.max
373
+ min,
374
+ max
386
375
  })) processNewInputValue(evt.target);
387
376
  else setState({ value: targetValue });
388
377
  };
@@ -393,13 +382,13 @@ const Slider = (props) => {
393
382
  const onBlurInput = (evt) => {
394
383
  const { value: targetValue } = evt.target;
395
384
  processNewInputValue(evt.target);
396
- props.onBlur?.({
385
+ onBlur?.({
397
386
  value: targetValue,
398
387
  handlePosition: evt.target.dataset.handlePosition
399
388
  });
400
389
  };
401
390
  const onInputKeyDown = (evt) => {
402
- if (props.disabled || props.readOnly || !(evt.target instanceof HTMLInputElement)) return;
391
+ if (disabled || readOnly || !(evt.target instanceof HTMLInputElement)) return;
403
392
  if (require_match.matches(evt, [require_keys.Enter])) processNewInputValue(evt.target);
404
393
  };
405
394
  const processNewInputValue = (input) => {
@@ -410,19 +399,17 @@ const Slider = (props) => {
410
399
  const targetValue = Number.parseFloat(input.value);
411
400
  const validity = !isNaN(targetValue);
412
401
  const handlePosition = input.dataset.handlePosition;
413
- if (handlePosition === "lower") setState({ isValid: validity });
414
- else if (handlePosition === "upper") setState({ isValidUpper: validity });
415
- setState({ isValid: validity });
402
+ setState(getValidityUpdateForHandle(handlePosition ?? "lower", validity));
416
403
  if (validity) {
417
404
  const adjustedValue = handlePosition ? getAdjustedValueForPosition({
418
405
  handle: handlePosition,
419
406
  value: targetValue,
420
- min: props.min,
421
- max: props.max
407
+ min,
408
+ max
422
409
  }) : getAdjustedValue({
423
410
  value: targetValue,
424
- min: props.min,
425
- max: props.max
411
+ min,
412
+ max
426
413
  });
427
414
  if (adjustedValue !== targetValue) setState({
428
415
  correctedValue: targetValue.toString(),
@@ -449,12 +436,12 @@ const Slider = (props) => {
449
436
  const calcLeftPercent = ({ clientX, value }) => {
450
437
  const boundingRect = elementRef.current?.getBoundingClientRect?.();
451
438
  let width = boundingRect ? boundingRect.right - boundingRect.left : 0;
452
- const nextValue = value ?? props.min;
439
+ const nextValue = value ?? min;
453
440
  if (width <= 0) width = 1;
454
441
  if (clientX) return (state.isRtl ? (boundingRect?.right ?? 0) - clientX : clientX - (boundingRect?.left ?? 0)) / width;
455
442
  return calcRawLeftPercent({
456
- max: props.max,
457
- min: props.min,
443
+ max,
444
+ min,
458
445
  value: nextValue
459
446
  });
460
447
  };
@@ -463,7 +450,6 @@ const Slider = (props) => {
463
450
  * with the corresponding handle position percentage.
464
451
  */
465
452
  const calcDiscreteValueAndPercent = ({ leftPercent }) => {
466
- const { step = 1, min, max } = props;
467
453
  const numSteps = Math.floor((max - min) / step) + 1;
468
454
  /** Index of the step that corresponds to `leftPercent`. */
469
455
  const stepIndex = Math.round(leftPercent * (numSteps - 1));
@@ -523,22 +509,22 @@ const Slider = (props) => {
523
509
  if (handle === "lower") setState({
524
510
  value: valueUpper && newValue > valueUpper ? valueUpper : newValue,
525
511
  left: valueUpper && newValue > valueUpper ? leftUpper : newLeft,
526
- isValid: true
512
+ ...getValidityUpdateForHandle(handle, true)
527
513
  });
528
514
  else setState({
529
515
  valueUpper: value && newValue < value ? value : newValue,
530
516
  leftUpper: value && newValue < value ? left : newLeft,
531
- isValidUpper: true
517
+ ...getValidityUpdateForHandle(handle, true)
532
518
  });
533
519
  };
534
520
  const setValueForHandle = (handle, value) => {
535
521
  if (handle === "lower") setState({
536
522
  value,
537
- isValid: true
523
+ ...getValidityUpdateForHandle(handle, true)
538
524
  });
539
525
  else setState({
540
526
  valueUpper: value,
541
- isValidUpper: true
527
+ ...getValidityUpdateForHandle(handle, true)
542
528
  });
543
529
  };
544
530
  const isValidValueForPosition = ({ handle, value: newValue, min, max }) => {
@@ -590,16 +576,15 @@ const Slider = (props) => {
590
576
  (0, react.useEffect)(() => {
591
577
  const { isValid, isValidUpper } = stateRef.current;
592
578
  const derivedState = {};
593
- if (props.invalid === true) {
579
+ if (invalid === true) {
594
580
  if (isValid === true) derivedState.isValid = false;
595
581
  if (isValidUpper === true) derivedState.isValidUpper = false;
596
- } else if (props.invalid === false) {
582
+ } else if (invalid === false) {
597
583
  if (isValid === false) derivedState.isValid = true;
598
584
  if (isValidUpper === false) derivedState.isValidUpper = true;
599
585
  }
600
586
  if (Object.keys(derivedState).length) setState(derivedState);
601
- }, [props.invalid]);
602
- const { ariaLabelInput, unstable_ariaLabelInputUpper: ariaLabelInputUpper, className, hideTextInput = false, id: idProp, min, minLabel, max, maxLabel, formatLabel = defaultFormatLabel, labelText, hideLabel, step = 1, inputType = "number", invalidText, required, disabled = false, name, unstable_nameUpper: nameUpper, light, readOnly = false, warn = false, warnText, translateWithId: t = defaultTranslateWithId, ...other } = props;
587
+ }, [invalid]);
603
588
  const id = idProp ?? generatedId;
604
589
  const { value, valueUpper, isValid, isValidUpper, correctedValue, correctedPosition, isRtl } = state;
605
590
  const normalizedProps = require_useNormalizedInputProps.useNormalizedInputProps({
@@ -616,10 +601,12 @@ const Slider = (props) => {
616
601
  invalid: !isValidUpper,
617
602
  warn
618
603
  });
619
- delete other.invalid;
620
- delete other.onRelease;
621
- delete other.stepMultiplier;
622
- delete other.unstable_valueUpper;
604
+ const passthroughProps = {
605
+ ...other,
606
+ onBlur,
607
+ onChange,
608
+ value: controlledValue
609
+ };
623
610
  const showWarning = normalizedProps.warn || correctedPosition === "lower" && isValid;
624
611
  const showWarningUpper = normalizedUpperProps.warn || correctedPosition === (twoHandles ? "upper" : "lower") && (twoHandles ? isValidUpper : isValid);
625
612
  const labelId = `${id}-label`;
@@ -719,7 +706,7 @@ const Slider = (props) => {
719
706
  step,
720
707
  onChange: onChangeInput,
721
708
  onBlur: onBlurInput,
722
- onKeyUp: props.onInputKeyUp,
709
+ onKeyUp: onInputKeyUp,
723
710
  onKeyDown: onInputKeyDown,
724
711
  "data-invalid": normalizedProps.invalid ? true : null,
725
712
  "data-handle-position": "lower",
@@ -745,7 +732,7 @@ const Slider = (props) => {
745
732
  role: "presentation",
746
733
  tabIndex: -1,
747
734
  "data-invalid": (twoHandles ? normalizedProps.invalid || normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
748
- ...other,
735
+ ...passthroughProps,
749
736
  children: [
750
737
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ThumbWrapper, {
751
738
  hasTooltip: hideTextInput,
@@ -788,12 +775,7 @@ const Slider = (props) => {
788
775
  children: !isRtl ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SliderHandles.UpperHandle, { "aria-label": ariaLabelInputUpper }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SliderHandles.UpperHandleFocus, { "aria-label": ariaLabelInputUpper })] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SliderHandles.LowerHandle, { "aria-label": ariaLabelInput }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_SliderHandles.LowerHandleFocus, { "aria-label": ariaLabelInput })] })
789
776
  })
790
777
  }) : null,
791
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
792
- className: `${prefix}--slider__track`,
793
- ref: (node) => {
794
- trackRef.current = node;
795
- }
796
- }),
778
+ /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `${prefix}--slider__track` }),
797
779
  /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
798
780
  className: `${prefix}--slider__filled-track`,
799
781
  ref: filledTrackRef
@@ -823,7 +805,7 @@ const Slider = (props) => {
823
805
  onChange: onChangeInput,
824
806
  onBlur: onBlurInput,
825
807
  onKeyDown: onInputKeyDown,
826
- onKeyUp: props.onInputKeyUp,
808
+ onKeyUp: onInputKeyUp,
827
809
  "data-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
828
810
  "data-handle-position": twoHandles ? "upper" : null,
829
811
  "aria-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : void 0,
@@ -169,7 +169,7 @@ function TabList({ activation = "automatic", "aria-label": label, children, clas
169
169
  [`${prefix}--tabs--full-width`]: distributeWidth,
170
170
  [`${prefix}--tabs--dismissable`]: dismissable
171
171
  }, customClassName);
172
- const [isNextButtonVisible, setIsNextButtonVisible] = (0, react.useState)(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth < ref.current.scrollWidth : false);
172
+ const [isNextButtonVisible, setIsNextButtonVisible] = (0, react.useState)(ref.current ? scrollLeft + ref.current.clientWidth < ref.current.scrollWidth : false);
173
173
  const isPreviousButtonVisible = ref.current ? isScrollable && scrollLeft > 0 : false;
174
174
  const previousButtonClasses = (0, classnames.default)(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--previous`, { [`${prefix}--tab--overflow-nav-button--hidden`]: !isPreviousButtonVisible });
175
175
  const nextButtonClasses = (0, classnames.default)(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--next`, { [`${prefix}--tab--overflow-nav-button--hidden`]: !isNextButtonVisible });
@@ -224,7 +224,7 @@ function TabList({ activation = "automatic", "aria-label": label, children, clas
224
224
  });
225
225
  }, []);
226
226
  (0, react.useEffect)(() => {
227
- setIsNextButtonVisible(ref.current ? scrollLeft + buttonWidth + ref.current.clientWidth + 1 < ref.current.scrollWidth : false);
227
+ setIsNextButtonVisible(ref.current ? scrollLeft + ref.current.clientWidth + 1 < ref.current.scrollWidth : false);
228
228
  if (dismissable && ref.current) setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
229
229
  }, [
230
230
  children,
@@ -14,6 +14,7 @@ const require_noopFn = require("../../internal/noopFn.js");
14
14
  const require_deprecate = require("../../prop-types/deprecate.js");
15
15
  const require_utils = require("../../internal/utils.js");
16
16
  const require_useMergedRefs = require("../../internal/useMergedRefs.js");
17
+ const require_hasHelperText = require("../../internal/hasHelperText.js");
17
18
  const require_index = require("../AILabel/index.js");
18
19
  const require_FormContext = require("../FluidForm/FormContext.js");
19
20
  const require_getAnnouncement = require("../../internal/getAnnouncement.js");
@@ -175,7 +176,7 @@ const TextArea = (0, react.forwardRef)((props, forwardRef) => {
175
176
  children: `${textCount}/${maxCount}`
176
177
  }) : null;
177
178
  const counterDescriptionId = enableCounter && maxCount ? `${id}-counter-desc` : void 0;
178
- const hasHelper = typeof helperText !== "undefined" && helperText !== null;
179
+ const hasHelper = require_hasHelperText.hasHelperText(helperText);
179
180
  const helperId = !hasHelper ? void 0 : `text-area-helper-text-${textAreaInstanceId}`;
180
181
  const helper = hasHelper && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Text.Text, {
181
182
  as: "div",
@@ -203,7 +204,8 @@ const TextArea = (0, react.forwardRef)((props, forwardRef) => {
203
204
  children: [warnText, isFluid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_carbon_icons_react.WarningAltFilled, { className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning` })]
204
205
  }) : null;
205
206
  let ariaDescribedBy;
206
- if (invalid) ariaDescribedBy = errorId;
207
+ let ariaErrorMessage;
208
+ if (invalid) ariaErrorMessage = errorId;
207
209
  else if (warn && !isFluid) ariaDescribedBy = warnId;
208
210
  else {
209
211
  const ids = [];
@@ -246,6 +248,7 @@ const TextArea = (0, react.forwardRef)((props, forwardRef) => {
246
248
  className: textareaClasses,
247
249
  "aria-invalid": invalid,
248
250
  "aria-describedby": ariaDescribedBy,
251
+ "aria-errormessage": ariaErrorMessage,
249
252
  disabled,
250
253
  rows,
251
254
  readOnly: other.readOnly,
@@ -10,6 +10,7 @@ const require_usePrefix = require("../../internal/usePrefix.js");
10
10
  const require_useId = require("../../internal/useId.js");
11
11
  const require_noopFn = require("../../internal/noopFn.js");
12
12
  const require_deprecate = require("../../prop-types/deprecate.js");
13
+ const require_hasHelperText = require("../../internal/hasHelperText.js");
13
14
  const require_util = require("./util.js");
14
15
  let classnames = require("classnames");
15
16
  classnames = require_runtime.__toESM(classnames);
@@ -69,7 +70,7 @@ const ControlledPasswordInput = (0, react.forwardRef)(({ labelText, className, i
69
70
  [`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
70
71
  [`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
71
72
  });
72
- const hasHelper = typeof helperText !== "undefined" && helperText !== null;
73
+ const hasHelper = require_hasHelperText.hasHelperText(helperText);
73
74
  const helperId = !hasHelper ? void 0 : `controlled-password-helper-text-${controlledPasswordInstanceId}`;
74
75
  const input = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("input", {
75
76
  ...require_util.getTextInputProps({
@@ -96,9 +96,9 @@ export interface PasswordInputProps extends Omit<InputHTMLAttributes<HTMLInputEl
96
96
  */
97
97
  showPasswordLabel?: string;
98
98
  /**
99
- * Specify the size of the Text Input. Supports `sm`, `md`, or `lg`.
99
+ * Specify the size of the Text Input. Supports `xs`, `sm`, `md`, or `lg`.
100
100
  */
101
- size?: 'sm' | 'md' | 'lg';
101
+ size?: 'xs' | 'sm' | 'md' | 'lg';
102
102
  /**
103
103
  * Specify the alignment of the tooltip to the icon-only button.
104
104
  * Can be one of: `start`, `center`, or `end`.
@@ -9,6 +9,7 @@ const require_runtime = require("../../_virtual/_rolldown/runtime.js");
9
9
  const require_usePrefix = require("../../internal/usePrefix.js");
10
10
  const require_deprecate = require("../../prop-types/deprecate.js");
11
11
  const require_Tooltip = require("../Tooltip/Tooltip.js");
12
+ const require_hasHelperText = require("../../internal/hasHelperText.js");
12
13
  const require_useNormalizedInputProps = require("../../internal/useNormalizedInputProps.js");
13
14
  const require_FormContext = require("../FluidForm/FormContext.js");
14
15
  const require_util = require("./util.js");
@@ -27,7 +28,7 @@ let _carbon_icons_react = require("@carbon/icons-react");
27
28
  * This source code is licensed under the Apache-2.0 license found in the
28
29
  * LICENSE file in the root directory of this source tree.
29
30
  */
30
- const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, helperText, hideLabel, hidePasswordLabel = "Hide password", id, inline, invalid = false, invalidText, labelText, light, onChange = () => {}, onClick = () => {}, onTogglePasswordVisibility, placeholder, readOnly, size = "md", showPasswordLabel = "Show password", tooltipPosition = "bottom", tooltipAlignment = "end", type = "password", warn = false, warnText, ...rest }, ref) => {
31
+ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, helperText, hideLabel, hidePasswordLabel = "Hide password", id, inline, invalid = false, invalidText, labelText, light, onChange = () => {}, onClick = () => {}, onTogglePasswordVisibility, placeholder, readOnly, size, showPasswordLabel = "Show password", tooltipPosition = "bottom", tooltipAlignment = "end", type = "password", warn = false, warnText, ...rest }, ref) => {
31
32
  const [inputType, setInputType] = (0, react.useState)(type);
32
33
  const prefix = require_usePrefix.usePrefix();
33
34
  const normalizedProps = require_useNormalizedInputProps.useNormalizedInputProps({
@@ -58,8 +59,7 @@ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, help
58
59
  [`${prefix}--text-input--light`]: light,
59
60
  [`${prefix}--text-input--invalid`]: normalizedProps.invalid,
60
61
  [`${prefix}--text-input--warning`]: normalizedProps.warn,
61
- [`${prefix}--text-input--${size}`]: size,
62
- [`${prefix}--layout--size-${size}`]: size
62
+ [`${prefix}--text-input--${size}`]: size
63
63
  }),
64
64
  readOnly,
65
65
  ref,
@@ -69,6 +69,7 @@ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, help
69
69
  [`${prefix}--text-input-wrapper--readonly`]: readOnly,
70
70
  [`${prefix}--text-input-wrapper--light`]: light,
71
71
  [`${prefix}--text-input-wrapper--inline`]: inline,
72
+ [`${prefix}--text-input-wrapper--inline--invalid`]: inline && normalizedProps.invalid,
72
73
  [`${prefix}--text-input--fluid`]: isFluid
73
74
  });
74
75
  const labelClasses = (0, classnames.default)(`${prefix}--label`, {
@@ -82,7 +83,10 @@ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, help
82
83
  [`${prefix}--form__helper-text--inline`]: inline
83
84
  });
84
85
  const fieldOuterWrapperClasses = (0, classnames.default)(`${prefix}--text-input__field-outer-wrapper`, { [`${prefix}--text-input__field-outer-wrapper--inline`]: inline });
85
- const fieldWrapperClasses = (0, classnames.default)(`${prefix}--text-input__field-wrapper`, { [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn });
86
+ const fieldWrapperClasses = (0, classnames.default)(`${prefix}--text-input__field-wrapper`, {
87
+ [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
88
+ [`${prefix}--layout--size-${size}`]: size
89
+ });
86
90
  const iconClasses = (0, classnames.default)({
87
91
  [`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
88
92
  [`${prefix}--text-input__invalid-icon--warning`]: normalizedProps.warn
@@ -92,7 +96,7 @@ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, help
92
96
  className: labelClasses,
93
97
  children: labelText
94
98
  });
95
- const helper = typeof helperText !== "undefined" && helperText !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
99
+ const helper = require_hasHelperText.hasHelperText(helperText) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
96
100
  id: normalizedProps.helperId,
97
101
  className: helperTextClasses,
98
102
  children: helperText
@@ -121,7 +125,7 @@ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, help
121
125
  invalidId: normalizedProps.invalidId,
122
126
  warn: normalizedProps.warn,
123
127
  warnId: normalizedProps.warnId,
124
- hasHelper: Boolean(helperText && !isFluid && (inline || !inline && !normalizedProps.validation)),
128
+ hasHelper: require_hasHelperText.hasHelperText(helperText) && !isFluid && (inline || !inline && !normalizedProps.validation),
125
129
  helperId: normalizedProps.helperId
126
130
  }),
127
131
  disabled,
@@ -147,21 +151,28 @@ const PasswordInput = (0, react.forwardRef)(({ className, disabled = false, help
147
151
  const Icon = normalizedProps.icon;
148
152
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
149
153
  className: inputWrapperClasses,
150
- children: [!inline ? label : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
151
- className: `${prefix}--text-input__label-helper-wrapper`,
152
- children: [label, !isFluid && helper]
153
- }), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
154
- className: fieldOuterWrapperClasses,
155
- children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
156
- className: fieldWrapperClasses,
157
- "data-invalid": normalizedProps.invalid || null,
158
- children: [
159
- Icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: iconClasses }),
160
- input,
161
- isFluid && !inline && normalizedProps.validation
162
- ]
163
- }), !isFluid && !inline && (normalizedProps.validation || helper)]
164
- })]
154
+ children: [
155
+ !inline ? label : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
156
+ className: `${prefix}--text-input__label-helper-wrapper`,
157
+ children: label
158
+ }),
159
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
160
+ className: fieldOuterWrapperClasses,
161
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
162
+ className: fieldWrapperClasses,
163
+ "data-invalid": normalizedProps.invalid || null,
164
+ children: [
165
+ Icon && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Icon, { className: iconClasses }),
166
+ input,
167
+ isFluid && !inline && normalizedProps.validation
168
+ ]
169
+ }), !isFluid && !inline && (normalizedProps.validation || helper)]
170
+ }),
171
+ inline && !isFluid && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
172
+ className: `${prefix}--text-input__label-helper-wrapper`,
173
+ children: normalizedProps.validation || helper
174
+ })
175
+ ]
165
176
  });
166
177
  });
167
178
  PasswordInput.displayName = "PasswordInput";
@@ -185,6 +196,7 @@ PasswordInput.propTypes = {
185
196
  placeholder: prop_types.default.string,
186
197
  showPasswordLabel: prop_types.default.string,
187
198
  size: prop_types.default.oneOf([
199
+ "xs",
188
200
  "sm",
189
201
  "md",
190
202
  "lg"
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2026
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.
@@ -15,9 +15,13 @@ export interface TextInputSkeletonProps extends React.HTMLAttributes<HTMLDivElem
15
15
  * Specify whether the label should be hidden or not.
16
16
  */
17
17
  hideLabel?: boolean;
18
+ /**
19
+ * Specify the size of the TextInputSkeleton
20
+ */
21
+ size?: 'xs' | 'sm' | 'md' | 'lg';
18
22
  }
19
23
  declare const TextInputSkeleton: {
20
- ({ hideLabel, className, ...rest }: TextInputSkeletonProps): import("react/jsx-runtime").JSX.Element;
24
+ ({ hideLabel, className, size, ...rest }: TextInputSkeletonProps): import("react/jsx-runtime").JSX.Element;
21
25
  propTypes: {
22
26
  /**
23
27
  * Specify an optional className to add to the form item wrapper.
@@ -27,6 +31,10 @@ declare const TextInputSkeleton: {
27
31
  * Specify whether the label should be hidden, or not
28
32
  */
29
33
  hideLabel: PropTypes.Requireable<boolean>;
34
+ /**
35
+ * Specify the size of the TextInputSkeleton
36
+ */
37
+ size: PropTypes.Requireable<string>;
30
38
  };
31
39
  };
32
40
  export default TextInputSkeleton;
@@ -16,22 +16,28 @@ prop_types = require_runtime.__toESM(prop_types);
16
16
  let react_jsx_runtime = require("react/jsx-runtime");
17
17
  //#region src/components/TextInput/TextInput.Skeleton.tsx
18
18
  /**
19
- * Copyright IBM Corp. 2016, 2023
19
+ * Copyright IBM Corp. 2016, 2026
20
20
  *
21
21
  * This source code is licensed under the Apache-2.0 license found in the
22
22
  * LICENSE file in the root directory of this source tree.
23
23
  */
24
- const TextInputSkeleton = ({ hideLabel, className, ...rest }) => {
24
+ const TextInputSkeleton = ({ hideLabel, className, size, ...rest }) => {
25
25
  const prefix = require_usePrefix.usePrefix();
26
26
  return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
27
- className: (0, classnames.default)(`${prefix}--form-item`, className),
27
+ className: (0, classnames.default)(`${prefix}--form-item`, className, { [`${prefix}--layout--size-${size}`]: size }),
28
28
  ...rest,
29
29
  children: [!hideLabel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", { className: `${prefix}--label ${prefix}--skeleton` }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { className: `${prefix}--skeleton ${prefix}--text-input` })]
30
30
  });
31
31
  };
32
32
  TextInputSkeleton.propTypes = {
33
33
  className: prop_types.default.string,
34
- hideLabel: prop_types.default.bool
34
+ hideLabel: prop_types.default.bool,
35
+ size: prop_types.default.oneOf([
36
+ "xs",
37
+ "sm",
38
+ "md",
39
+ "lg"
40
+ ])
35
41
  };
36
42
  //#endregion
37
43
  exports.default = TextInputSkeleton;
@@ -88,7 +88,7 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
88
88
  /**
89
89
  * Specify the size of the Text Input. Currently supports the following:
90
90
  */
91
- size?: 'sm' | 'md' | 'lg' | 'xl';
91
+ size?: 'xs' | 'sm' | 'md' | 'lg';
92
92
  /**
93
93
  * @deprecated please use `decorator` instead.
94
94
  * **Experimental**: Provide a `Slug` component to be rendered inside the `TextInput` component