@carbon/react 1.106.0-rc.0 → 1.107.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.
- package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1006 -971
- package/es/components/Accordion/AccordionItem.d.ts +2 -2
- package/es/components/Button/Button.js +1 -1
- package/es/components/Checkbox/Checkbox.js +2 -1
- package/es/components/CheckboxGroup/CheckboxGroup.js +2 -1
- package/es/components/ComboBox/ComboBox.d.ts +1 -1
- package/es/components/ComboBox/ComboBox.js +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
- package/es/components/ContentSwitcher/ContentSwitcher.js +24 -15
- package/es/components/DataTable/DataTable.d.ts +3 -3
- package/es/components/DataTable/TableActionList.d.ts +1 -1
- package/es/components/DataTable/TableHead.d.ts +1 -1
- package/es/components/DataTable/TableSlugRow.d.ts +2 -2
- package/es/components/DataTable/TableSlugRow.js +8 -11
- package/es/components/DataTable/TableToolbarContent.d.ts +1 -1
- package/es/components/DataTable/TableToolbarSearch.d.ts +5 -1
- package/es/components/DatePicker/DatePicker.js +15 -13
- package/es/components/DatePicker/plugins/fixEventsPlugin.js +2 -3
- package/es/components/DatePickerInput/DatePickerInput.js +9 -2
- package/es/components/Dropdown/Dropdown.d.ts +1 -1
- package/es/components/FluidTimePicker/FluidTimePicker.d.ts +1 -1
- package/es/components/FluidTimePicker/FluidTimePicker.js +6 -4
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +4 -0
- package/es/components/FluidTimePickerSelect/FluidTimePickerSelect.js +2 -1
- package/es/components/FluidTimePickerSelect/index.js +18 -0
- package/es/components/Grid/CSSGrid.js +11 -6
- package/es/components/Grid/Column.d.ts +2 -2
- package/es/components/Grid/ColumnHang.d.ts +3 -3
- package/es/components/Grid/ColumnHang.js +1 -1
- package/es/components/Grid/FlexGrid.js +5 -3
- package/es/components/Grid/Grid.js +2 -1
- package/es/components/Grid/GridTypes.d.ts +5 -0
- package/es/components/Grid/Row.d.ts +3 -3
- package/es/components/Grid/Row.js +1 -1
- package/es/components/Menu/Menu.js +1 -1
- package/es/components/Menu/MenuItem.js +4 -0
- package/es/components/Modal/Modal.js +3 -0
- package/es/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +3 -2
- package/es/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/es/components/OverflowMenu/OverflowMenu.js +11 -12
- package/es/components/Pagination/Pagination.d.ts +1 -1
- package/es/components/Pagination/Pagination.js +2 -0
- package/es/components/Popover/index.js +14 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +8 -6
- package/es/components/Search/Search.Skeleton.d.ts +12 -3
- package/es/components/Search/Search.Skeleton.js +16 -8
- package/es/components/Search/Search.d.ts +1 -1
- package/es/components/Search/Search.js +4 -4
- package/es/components/Select/Select.d.ts +1 -1
- package/es/components/Select/Select.js +7 -6
- package/es/components/Slider/Slider.js +46 -62
- package/es/components/Tabs/Tabs.js +2 -2
- package/es/components/TextArea/TextArea.js +5 -2
- package/es/components/TextInput/ControlledPasswordInput.js +2 -1
- package/es/components/TextInput/PasswordInput.d.ts +2 -2
- package/es/components/TextInput/PasswordInput.js +33 -21
- package/es/components/TextInput/TextInput.Skeleton.d.ts +10 -2
- package/es/components/TextInput/TextInput.Skeleton.js +10 -4
- package/es/components/TextInput/TextInput.d.ts +1 -1
- package/es/components/TextInput/TextInput.js +39 -30
- package/es/components/TextInput/util.d.ts +1 -0
- package/es/components/TextInput/util.js +1 -1
- package/es/components/Theme/index.d.ts +2 -2
- package/es/components/Theme/index.js +3 -3
- package/es/components/TimePicker/TimePicker.js +5 -2
- package/es/components/TreeView/TreeNode.js +2 -2
- package/es/components/UIShell/HeaderGlobalBar.d.ts +1 -1
- package/es/components/UIShell/HeaderMenu.d.ts +1 -1
- package/es/components/UIShell/HeaderMenu.js +5 -3
- package/es/index.js +2 -2
- package/es/internal/FloatingMenu.d.ts +5 -1
- package/es/internal/hasHelperText.d.ts +8 -0
- package/es/internal/hasHelperText.js +11 -0
- package/es/tools/wrapComponent.d.ts +3 -3
- package/es/tools/wrapComponent.js +1 -1
- package/lib/components/Accordion/AccordionItem.d.ts +2 -2
- package/lib/components/Button/Button.js +1 -1
- package/lib/components/Checkbox/Checkbox.js +2 -1
- package/lib/components/CheckboxGroup/CheckboxGroup.js +2 -1
- package/lib/components/ComboBox/ComboBox.d.ts +1 -1
- package/lib/components/ComboBox/ComboBox.js +1 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.d.ts +1 -1
- package/lib/components/ContentSwitcher/ContentSwitcher.js +22 -13
- package/lib/components/DataTable/DataTable.d.ts +3 -3
- package/lib/components/DataTable/TableActionList.d.ts +1 -1
- package/lib/components/DataTable/TableHead.d.ts +1 -1
- package/lib/components/DataTable/TableSlugRow.d.ts +2 -2
- package/lib/components/DataTable/TableSlugRow.js +7 -10
- package/lib/components/DataTable/TableToolbarContent.d.ts +1 -1
- package/lib/components/DataTable/TableToolbarSearch.d.ts +5 -1
- package/lib/components/DatePicker/DatePicker.js +15 -13
- package/lib/components/DatePicker/plugins/fixEventsPlugin.js +1 -2
- package/lib/components/DatePickerInput/DatePickerInput.js +9 -2
- package/lib/components/Dropdown/Dropdown.d.ts +1 -1
- package/lib/components/FluidTimePicker/FluidTimePicker.d.ts +1 -1
- package/lib/components/FluidTimePicker/FluidTimePicker.js +5 -3
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.d.ts +4 -0
- package/lib/components/FluidTimePickerSelect/FluidTimePickerSelect.js +2 -1
- package/lib/components/FluidTimePickerSelect/index.js +17 -0
- package/lib/components/Grid/CSSGrid.js +11 -6
- package/lib/components/Grid/Column.d.ts +2 -2
- package/lib/components/Grid/ColumnHang.d.ts +3 -3
- package/lib/components/Grid/ColumnHang.js +1 -1
- package/lib/components/Grid/FlexGrid.js +5 -3
- package/lib/components/Grid/Grid.js +2 -1
- package/lib/components/Grid/GridTypes.d.ts +5 -0
- package/lib/components/Grid/Row.d.ts +3 -3
- package/lib/components/Grid/Row.js +1 -1
- package/lib/components/Menu/Menu.js +1 -1
- package/lib/components/Menu/MenuItem.js +4 -0
- package/lib/components/Modal/Modal.js +3 -0
- package/lib/components/MultiSelect/FilterableMultiSelect.d.ts +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +3 -2
- package/lib/components/MultiSelect/MultiSelect.d.ts +1 -1
- package/lib/components/OverflowMenu/OverflowMenu.js +10 -11
- package/lib/components/Pagination/Pagination.d.ts +1 -1
- package/lib/components/Pagination/Pagination.js +2 -0
- package/lib/components/Popover/index.js +14 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.d.ts +1 -1
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +7 -5
- package/lib/components/Search/Search.Skeleton.d.ts +12 -3
- package/lib/components/Search/Search.Skeleton.js +15 -7
- package/lib/components/Search/Search.d.ts +1 -1
- package/lib/components/Search/Search.js +4 -4
- package/lib/components/Select/Select.d.ts +1 -1
- package/lib/components/Select/Select.js +7 -6
- package/lib/components/Slider/Slider.js +46 -62
- package/lib/components/Tabs/Tabs.js +2 -2
- package/lib/components/TextArea/TextArea.js +5 -2
- package/lib/components/TextInput/ControlledPasswordInput.js +2 -1
- package/lib/components/TextInput/PasswordInput.d.ts +2 -2
- package/lib/components/TextInput/PasswordInput.js +33 -21
- package/lib/components/TextInput/TextInput.Skeleton.d.ts +10 -2
- package/lib/components/TextInput/TextInput.Skeleton.js +10 -4
- package/lib/components/TextInput/TextInput.d.ts +1 -1
- package/lib/components/TextInput/TextInput.js +39 -30
- package/lib/components/TextInput/util.d.ts +1 -0
- package/lib/components/TextInput/util.js +1 -1
- package/lib/components/Theme/index.d.ts +2 -2
- package/lib/components/Theme/index.js +2 -2
- package/lib/components/TimePicker/TimePicker.js +5 -2
- package/lib/components/TreeView/TreeNode.js +1 -1
- package/lib/components/UIShell/HeaderGlobalBar.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenu.d.ts +1 -1
- package/lib/components/UIShell/HeaderMenu.js +5 -3
- package/lib/index.js +2 -2
- package/lib/internal/FloatingMenu.d.ts +5 -1
- package/lib/internal/hasHelperText.d.ts +8 -0
- package/lib/internal/hasHelperText.js +11 -0
- package/lib/tools/wrapComponent.d.ts +3 -3
- package/lib/tools/wrapComponent.js +1 -1
- package/package.json +8 -8
- package/telemetry.yml +1 -0
|
@@ -68,18 +68,13 @@ const DRAG_STOP_EVENT_TYPES = new Set([
|
|
|
68
68
|
"touchcancel"
|
|
69
69
|
]);
|
|
70
70
|
const Slider = (props) => {
|
|
71
|
-
const controlledValue = props
|
|
72
|
-
const controlledValueUpper = props.unstable_valueUpper;
|
|
73
|
-
const controlledMax = props.max;
|
|
74
|
-
const controlledMin = props.min;
|
|
75
|
-
const onChange = props.onChange;
|
|
76
|
-
const onRelease = props.onRelease;
|
|
71
|
+
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;
|
|
77
72
|
const [state, setState] = useReducer((prev, args) => ({
|
|
78
73
|
...prev,
|
|
79
74
|
...args
|
|
80
75
|
}), {
|
|
81
|
-
value:
|
|
82
|
-
valueUpper:
|
|
76
|
+
value: controlledValue,
|
|
77
|
+
valueUpper: controlledValueUpper,
|
|
83
78
|
left: 0,
|
|
84
79
|
leftUpper: 0,
|
|
85
80
|
needsOnRelease: false,
|
|
@@ -94,15 +89,10 @@ const Slider = (props) => {
|
|
|
94
89
|
useEffect(() => {
|
|
95
90
|
stateRef.current = state;
|
|
96
91
|
}, [state]);
|
|
97
|
-
const propsRef = useRef(props);
|
|
98
|
-
useEffect(() => {
|
|
99
|
-
propsRef.current = props;
|
|
100
|
-
}, [props]);
|
|
101
92
|
const thumbRef = useRef(null);
|
|
102
93
|
const thumbRefUpper = useRef(null);
|
|
103
94
|
const filledTrackRef = useRef(null);
|
|
104
95
|
const elementRef = useRef(null);
|
|
105
|
-
const trackRef = useRef(null);
|
|
106
96
|
const generatedId = useId();
|
|
107
97
|
const prefix = usePrefix();
|
|
108
98
|
const twoHandles = hasUpperValue(state.valueUpper);
|
|
@@ -192,23 +182,23 @@ const Slider = (props) => {
|
|
|
192
182
|
const next = [
|
|
193
183
|
controlledValue,
|
|
194
184
|
controlledValueUpper,
|
|
195
|
-
|
|
196
|
-
|
|
185
|
+
max,
|
|
186
|
+
min
|
|
197
187
|
];
|
|
198
188
|
if (!prev || prev[0] !== next[0] || prev[1] !== next[1] || prev[2] !== next[2] || prev[3] !== next[3]) {
|
|
199
189
|
setState({
|
|
200
190
|
value: controlledValue,
|
|
201
191
|
left: calcRawLeftPercent({
|
|
202
|
-
max
|
|
203
|
-
min
|
|
192
|
+
max,
|
|
193
|
+
min,
|
|
204
194
|
value: controlledValue
|
|
205
195
|
}) * 100
|
|
206
196
|
});
|
|
207
197
|
if (typeof controlledValueUpper !== "undefined") setState({
|
|
208
198
|
valueUpper: controlledValueUpper,
|
|
209
199
|
leftUpper: calcRawLeftPercent({
|
|
210
|
-
max
|
|
211
|
-
min
|
|
200
|
+
max,
|
|
201
|
+
min,
|
|
212
202
|
value: controlledValueUpper
|
|
213
203
|
}) * 100
|
|
214
204
|
});
|
|
@@ -219,10 +209,10 @@ const Slider = (props) => {
|
|
|
219
209
|
prevSyncKeysRef.current = next;
|
|
220
210
|
}
|
|
221
211
|
}, [
|
|
222
|
-
controlledMax,
|
|
223
|
-
controlledMin,
|
|
224
212
|
controlledValue,
|
|
225
|
-
controlledValueUpper
|
|
213
|
+
controlledValueUpper,
|
|
214
|
+
max,
|
|
215
|
+
min
|
|
226
216
|
]);
|
|
227
217
|
/**
|
|
228
218
|
* Rounds a given value to the nearest step defined by the slider's `step`
|
|
@@ -232,7 +222,7 @@ const Slider = (props) => {
|
|
|
232
222
|
* @returns The value rounded to the precision determined by the step.
|
|
233
223
|
*/
|
|
234
224
|
const nearestStepValue = (value = 0) => {
|
|
235
|
-
const decimals = (
|
|
225
|
+
const decimals = (step.toString().split(".")[1] ?? "").length;
|
|
236
226
|
return Number(value.toFixed(decimals));
|
|
237
227
|
};
|
|
238
228
|
const handleDrag = (event) => {
|
|
@@ -244,7 +234,7 @@ const Slider = (props) => {
|
|
|
244
234
|
* event.
|
|
245
235
|
*/
|
|
246
236
|
const onDragStart = (evt) => {
|
|
247
|
-
if (
|
|
237
|
+
if (disabled || readOnly) return;
|
|
248
238
|
evt.preventDefault();
|
|
249
239
|
DRAG_STOP_EVENT_TYPES.forEach((element) => {
|
|
250
240
|
elementRef.current?.ownerDocument.addEventListener(element, onDragStop);
|
|
@@ -273,7 +263,7 @@ const Slider = (props) => {
|
|
|
273
263
|
* indicating that the `onRelease` callback should be called.
|
|
274
264
|
*/
|
|
275
265
|
const onDragStop = () => {
|
|
276
|
-
if (
|
|
266
|
+
if (disabled || readOnly) return;
|
|
277
267
|
DRAG_STOP_EVENT_TYPES.forEach((element) => {
|
|
278
268
|
elementRef.current?.ownerDocument.removeEventListener(element, onDragStop);
|
|
279
269
|
});
|
|
@@ -297,7 +287,7 @@ const Slider = (props) => {
|
|
|
297
287
|
const _onDragRef = useRef(null);
|
|
298
288
|
_onDragRef.current = (evt, activeHandle) => {
|
|
299
289
|
activeHandle = activeHandle ?? stateRef.current.activeHandle;
|
|
300
|
-
if (
|
|
290
|
+
if (disabled || readOnly) return;
|
|
301
291
|
const { value, left } = calcValue({
|
|
302
292
|
clientX: getClientXFromEvent(evt),
|
|
303
293
|
value: stateRef.current.value
|
|
@@ -331,21 +321,20 @@ const Slider = (props) => {
|
|
|
331
321
|
* state accordingly.
|
|
332
322
|
*/
|
|
333
323
|
const onKeyDown = (evt) => {
|
|
334
|
-
if (
|
|
335
|
-
const { step = 1, stepMultiplier = 4 } = props;
|
|
324
|
+
if (disabled || readOnly) return;
|
|
336
325
|
let delta = 0;
|
|
337
326
|
if (matches(evt, [ArrowDown, ArrowLeft])) delta = -step;
|
|
338
327
|
else if (matches(evt, [ArrowUp$1, ArrowRight$1])) delta = step;
|
|
339
328
|
else return;
|
|
340
329
|
if (evt.shiftKey) delta *= stepMultiplier;
|
|
341
330
|
if (twoHandles && state.activeHandle) {
|
|
342
|
-
const { value, left } = calcValue({ value: calcValueForDelta((state.activeHandle === "lower" ? state.value : state.valueUpper) ??
|
|
331
|
+
const { value, left } = calcValue({ value: calcValueForDelta((state.activeHandle === "lower" ? state.value : state.valueUpper) ?? min, delta, step) });
|
|
343
332
|
setValueLeftForHandle(state.activeHandle, {
|
|
344
333
|
value: nearestStepValue(value),
|
|
345
334
|
left
|
|
346
335
|
});
|
|
347
336
|
} else {
|
|
348
|
-
const { value, left } = calcValue({ value: calcValueForDelta(state.value, delta,
|
|
337
|
+
const { value, left } = calcValue({ value: calcValueForDelta(state.value, delta, step) });
|
|
349
338
|
setState({
|
|
350
339
|
value: nearestStepValue(value),
|
|
351
340
|
left,
|
|
@@ -363,22 +352,22 @@ const Slider = (props) => {
|
|
|
363
352
|
* setting state accordingly.
|
|
364
353
|
*/
|
|
365
354
|
const onChangeInput = (evt) => {
|
|
366
|
-
if (
|
|
355
|
+
if (disabled || readOnly) return;
|
|
367
356
|
const activeHandle = evt.target.dataset.handlePosition ?? "lower";
|
|
368
357
|
const targetValue = Number.parseFloat(evt.target.value);
|
|
369
358
|
if (twoHandles) if (isNaN(targetValue)) setValueForHandle(activeHandle, evt.target.value);
|
|
370
359
|
else if (isValidValueForPosition({
|
|
371
360
|
handle: activeHandle,
|
|
372
361
|
value: targetValue,
|
|
373
|
-
min
|
|
374
|
-
max
|
|
362
|
+
min,
|
|
363
|
+
max
|
|
375
364
|
})) processNewInputValue(evt.target);
|
|
376
365
|
else setValueForHandle(activeHandle, targetValue);
|
|
377
366
|
else if (isNaN(targetValue)) setState({ value: evt.target.value });
|
|
378
367
|
else if (isValidValue({
|
|
379
368
|
value: targetValue,
|
|
380
|
-
min
|
|
381
|
-
max
|
|
369
|
+
min,
|
|
370
|
+
max
|
|
382
371
|
})) processNewInputValue(evt.target);
|
|
383
372
|
else setState({ value: targetValue });
|
|
384
373
|
};
|
|
@@ -389,13 +378,13 @@ const Slider = (props) => {
|
|
|
389
378
|
const onBlurInput = (evt) => {
|
|
390
379
|
const { value: targetValue } = evt.target;
|
|
391
380
|
processNewInputValue(evt.target);
|
|
392
|
-
|
|
381
|
+
onBlur?.({
|
|
393
382
|
value: targetValue,
|
|
394
383
|
handlePosition: evt.target.dataset.handlePosition
|
|
395
384
|
});
|
|
396
385
|
};
|
|
397
386
|
const onInputKeyDown = (evt) => {
|
|
398
|
-
if (
|
|
387
|
+
if (disabled || readOnly || !(evt.target instanceof HTMLInputElement)) return;
|
|
399
388
|
if (matches(evt, [Enter])) processNewInputValue(evt.target);
|
|
400
389
|
};
|
|
401
390
|
const processNewInputValue = (input) => {
|
|
@@ -413,12 +402,12 @@ const Slider = (props) => {
|
|
|
413
402
|
const adjustedValue = handlePosition ? getAdjustedValueForPosition({
|
|
414
403
|
handle: handlePosition,
|
|
415
404
|
value: targetValue,
|
|
416
|
-
min
|
|
417
|
-
max
|
|
405
|
+
min,
|
|
406
|
+
max
|
|
418
407
|
}) : getAdjustedValue({
|
|
419
408
|
value: targetValue,
|
|
420
|
-
min
|
|
421
|
-
max
|
|
409
|
+
min,
|
|
410
|
+
max
|
|
422
411
|
});
|
|
423
412
|
if (adjustedValue !== targetValue) setState({
|
|
424
413
|
correctedValue: targetValue.toString(),
|
|
@@ -445,12 +434,12 @@ const Slider = (props) => {
|
|
|
445
434
|
const calcLeftPercent = ({ clientX, value }) => {
|
|
446
435
|
const boundingRect = elementRef.current?.getBoundingClientRect?.();
|
|
447
436
|
let width = boundingRect ? boundingRect.right - boundingRect.left : 0;
|
|
448
|
-
const nextValue = value ??
|
|
437
|
+
const nextValue = value ?? min;
|
|
449
438
|
if (width <= 0) width = 1;
|
|
450
439
|
if (clientX) return (state.isRtl ? (boundingRect?.right ?? 0) - clientX : clientX - (boundingRect?.left ?? 0)) / width;
|
|
451
440
|
return calcRawLeftPercent({
|
|
452
|
-
max
|
|
453
|
-
min
|
|
441
|
+
max,
|
|
442
|
+
min,
|
|
454
443
|
value: nextValue
|
|
455
444
|
});
|
|
456
445
|
};
|
|
@@ -459,7 +448,6 @@ const Slider = (props) => {
|
|
|
459
448
|
* with the corresponding handle position percentage.
|
|
460
449
|
*/
|
|
461
450
|
const calcDiscreteValueAndPercent = ({ leftPercent }) => {
|
|
462
|
-
const { step = 1, min, max } = props;
|
|
463
451
|
const numSteps = Math.floor((max - min) / step) + 1;
|
|
464
452
|
/** Index of the step that corresponds to `leftPercent`. */
|
|
465
453
|
const stepIndex = Math.round(leftPercent * (numSteps - 1));
|
|
@@ -586,16 +574,15 @@ const Slider = (props) => {
|
|
|
586
574
|
useEffect(() => {
|
|
587
575
|
const { isValid, isValidUpper } = stateRef.current;
|
|
588
576
|
const derivedState = {};
|
|
589
|
-
if (
|
|
577
|
+
if (invalid === true) {
|
|
590
578
|
if (isValid === true) derivedState.isValid = false;
|
|
591
579
|
if (isValidUpper === true) derivedState.isValidUpper = false;
|
|
592
|
-
} else if (
|
|
580
|
+
} else if (invalid === false) {
|
|
593
581
|
if (isValid === false) derivedState.isValid = true;
|
|
594
582
|
if (isValidUpper === false) derivedState.isValidUpper = true;
|
|
595
583
|
}
|
|
596
584
|
if (Object.keys(derivedState).length) setState(derivedState);
|
|
597
|
-
}, [
|
|
598
|
-
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;
|
|
585
|
+
}, [invalid]);
|
|
599
586
|
const id = idProp ?? generatedId;
|
|
600
587
|
const { value, valueUpper, isValid, isValidUpper, correctedValue, correctedPosition, isRtl } = state;
|
|
601
588
|
const normalizedProps = useNormalizedInputProps({
|
|
@@ -612,10 +599,12 @@ const Slider = (props) => {
|
|
|
612
599
|
invalid: !isValidUpper,
|
|
613
600
|
warn
|
|
614
601
|
});
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
602
|
+
const passthroughProps = {
|
|
603
|
+
...other,
|
|
604
|
+
onBlur,
|
|
605
|
+
onChange,
|
|
606
|
+
value: controlledValue
|
|
607
|
+
};
|
|
619
608
|
const showWarning = normalizedProps.warn || correctedPosition === "lower" && isValid;
|
|
620
609
|
const showWarningUpper = normalizedUpperProps.warn || correctedPosition === (twoHandles ? "upper" : "lower") && (twoHandles ? isValidUpper : isValid);
|
|
621
610
|
const labelId = `${id}-label`;
|
|
@@ -715,7 +704,7 @@ const Slider = (props) => {
|
|
|
715
704
|
step,
|
|
716
705
|
onChange: onChangeInput,
|
|
717
706
|
onBlur: onBlurInput,
|
|
718
|
-
onKeyUp:
|
|
707
|
+
onKeyUp: onInputKeyUp,
|
|
719
708
|
onKeyDown: onInputKeyDown,
|
|
720
709
|
"data-invalid": normalizedProps.invalid ? true : null,
|
|
721
710
|
"data-handle-position": "lower",
|
|
@@ -741,7 +730,7 @@ const Slider = (props) => {
|
|
|
741
730
|
role: "presentation",
|
|
742
731
|
tabIndex: -1,
|
|
743
732
|
"data-invalid": (twoHandles ? normalizedProps.invalid || normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
|
|
744
|
-
...
|
|
733
|
+
...passthroughProps,
|
|
745
734
|
children: [
|
|
746
735
|
/* @__PURE__ */ jsx(ThumbWrapper, {
|
|
747
736
|
hasTooltip: hideTextInput,
|
|
@@ -784,12 +773,7 @@ const Slider = (props) => {
|
|
|
784
773
|
children: !isRtl ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(UpperHandle, { "aria-label": ariaLabelInputUpper }), /* @__PURE__ */ jsx(UpperHandleFocus, { "aria-label": ariaLabelInputUpper })] }) : /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(LowerHandle, { "aria-label": ariaLabelInput }), /* @__PURE__ */ jsx(LowerHandleFocus, { "aria-label": ariaLabelInput })] })
|
|
785
774
|
})
|
|
786
775
|
}) : null,
|
|
787
|
-
/* @__PURE__ */ jsx("div", {
|
|
788
|
-
className: `${prefix}--slider__track`,
|
|
789
|
-
ref: (node) => {
|
|
790
|
-
trackRef.current = node;
|
|
791
|
-
}
|
|
792
|
-
}),
|
|
776
|
+
/* @__PURE__ */ jsx("div", { className: `${prefix}--slider__track` }),
|
|
793
777
|
/* @__PURE__ */ jsx("div", {
|
|
794
778
|
className: `${prefix}--slider__filled-track`,
|
|
795
779
|
ref: filledTrackRef
|
|
@@ -819,7 +803,7 @@ const Slider = (props) => {
|
|
|
819
803
|
onChange: onChangeInput,
|
|
820
804
|
onBlur: onBlurInput,
|
|
821
805
|
onKeyDown: onInputKeyDown,
|
|
822
|
-
onKeyUp:
|
|
806
|
+
onKeyUp: onInputKeyUp,
|
|
823
807
|
"data-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : null,
|
|
824
808
|
"data-handle-position": twoHandles ? "upper" : null,
|
|
825
809
|
"aria-invalid": (twoHandles ? normalizedUpperProps.invalid : normalizedProps.invalid) ? true : void 0,
|
|
@@ -165,7 +165,7 @@ function TabList({ activation = "automatic", "aria-label": label, children, clas
|
|
|
165
165
|
[`${prefix}--tabs--full-width`]: distributeWidth,
|
|
166
166
|
[`${prefix}--tabs--dismissable`]: dismissable
|
|
167
167
|
}, customClassName);
|
|
168
|
-
const [isNextButtonVisible, setIsNextButtonVisible] = useState(ref.current ? scrollLeft +
|
|
168
|
+
const [isNextButtonVisible, setIsNextButtonVisible] = useState(ref.current ? scrollLeft + ref.current.clientWidth < ref.current.scrollWidth : false);
|
|
169
169
|
const isPreviousButtonVisible = ref.current ? isScrollable && scrollLeft > 0 : false;
|
|
170
170
|
const previousButtonClasses = classNames(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--previous`, { [`${prefix}--tab--overflow-nav-button--hidden`]: !isPreviousButtonVisible });
|
|
171
171
|
const nextButtonClasses = classNames(`${prefix}--tab--overflow-nav-button`, `${prefix}--tab--overflow-nav-button--next`, { [`${prefix}--tab--overflow-nav-button--hidden`]: !isNextButtonVisible });
|
|
@@ -220,7 +220,7 @@ function TabList({ activation = "automatic", "aria-label": label, children, clas
|
|
|
220
220
|
});
|
|
221
221
|
}, []);
|
|
222
222
|
useEffect(() => {
|
|
223
|
-
setIsNextButtonVisible(ref.current ? scrollLeft +
|
|
223
|
+
setIsNextButtonVisible(ref.current ? scrollLeft + ref.current.clientWidth + 1 < ref.current.scrollWidth : false);
|
|
224
224
|
if (dismissable && ref.current) setIsScrollable(ref.current.scrollWidth > ref.current.clientWidth + 1);
|
|
225
225
|
}, [
|
|
226
226
|
children,
|
|
@@ -13,6 +13,7 @@ import { noopFn } from "../../internal/noopFn.js";
|
|
|
13
13
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
14
14
|
import { isComponentElement } from "../../internal/utils.js";
|
|
15
15
|
import { useMergedRefs } from "../../internal/useMergedRefs.js";
|
|
16
|
+
import { hasHelperText } from "../../internal/hasHelperText.js";
|
|
16
17
|
import { AILabel } from "../AILabel/index.js";
|
|
17
18
|
import { FormContext } from "../FluidForm/FormContext.js";
|
|
18
19
|
import { getAnnouncement } from "../../internal/getAnnouncement.js";
|
|
@@ -171,7 +172,7 @@ const TextArea = forwardRef((props, forwardRef) => {
|
|
|
171
172
|
children: `${textCount}/${maxCount}`
|
|
172
173
|
}) : null;
|
|
173
174
|
const counterDescriptionId = enableCounter && maxCount ? `${id}-counter-desc` : void 0;
|
|
174
|
-
const hasHelper =
|
|
175
|
+
const hasHelper = hasHelperText(helperText);
|
|
175
176
|
const helperId = !hasHelper ? void 0 : `text-area-helper-text-${textAreaInstanceId}`;
|
|
176
177
|
const helper = hasHelper && /* @__PURE__ */ jsx(Text, {
|
|
177
178
|
as: "div",
|
|
@@ -199,7 +200,8 @@ const TextArea = forwardRef((props, forwardRef) => {
|
|
|
199
200
|
children: [warnText, isFluid && /* @__PURE__ */ jsx(WarningAltFilled, { className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning` })]
|
|
200
201
|
}) : null;
|
|
201
202
|
let ariaDescribedBy;
|
|
202
|
-
|
|
203
|
+
let ariaErrorMessage;
|
|
204
|
+
if (invalid) ariaErrorMessage = errorId;
|
|
203
205
|
else if (warn && !isFluid) ariaDescribedBy = warnId;
|
|
204
206
|
else {
|
|
205
207
|
const ids = [];
|
|
@@ -242,6 +244,7 @@ const TextArea = forwardRef((props, forwardRef) => {
|
|
|
242
244
|
className: textareaClasses,
|
|
243
245
|
"aria-invalid": invalid,
|
|
244
246
|
"aria-describedby": ariaDescribedBy,
|
|
247
|
+
"aria-errormessage": ariaErrorMessage,
|
|
245
248
|
disabled,
|
|
246
249
|
rows,
|
|
247
250
|
readOnly: other.readOnly,
|
|
@@ -9,6 +9,7 @@ import { usePrefix } from "../../internal/usePrefix.js";
|
|
|
9
9
|
import { useId } from "../../internal/useId.js";
|
|
10
10
|
import { noopFn } from "../../internal/noopFn.js";
|
|
11
11
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
12
|
+
import { hasHelperText } from "../../internal/hasHelperText.js";
|
|
12
13
|
import { getTextInputProps } from "./util.js";
|
|
13
14
|
import classNames from "classnames";
|
|
14
15
|
import { forwardRef } from "react";
|
|
@@ -65,7 +66,7 @@ const ControlledPasswordInput = forwardRef(({ labelText, className, id, placehol
|
|
|
65
66
|
[`${prefix}--tooltip--${tooltipPosition}`]: tooltipPosition,
|
|
66
67
|
[`${prefix}--tooltip--align-${tooltipAlignment}`]: tooltipAlignment
|
|
67
68
|
});
|
|
68
|
-
const hasHelper =
|
|
69
|
+
const hasHelper = hasHelperText(helperText);
|
|
69
70
|
const helperId = !hasHelper ? void 0 : `controlled-password-helper-text-${controlledPasswordInstanceId}`;
|
|
70
71
|
const input = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("input", {
|
|
71
72
|
...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`.
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { usePrefix } from "../../internal/usePrefix.js";
|
|
9
9
|
import { deprecate } from "../../prop-types/deprecate.js";
|
|
10
10
|
import { Tooltip } from "../Tooltip/Tooltip.js";
|
|
11
|
+
import { hasHelperText } from "../../internal/hasHelperText.js";
|
|
11
12
|
import { useNormalizedInputProps } from "../../internal/useNormalizedInputProps.js";
|
|
12
13
|
import { FormContext } from "../FluidForm/FormContext.js";
|
|
13
14
|
import { getTextInputProps } from "./util.js";
|
|
@@ -23,7 +24,7 @@ import { View, ViewOff } from "@carbon/icons-react";
|
|
|
23
24
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
24
25
|
* LICENSE file in the root directory of this source tree.
|
|
25
26
|
*/
|
|
26
|
-
const PasswordInput = forwardRef(({ className, disabled = false, helperText, hideLabel, hidePasswordLabel = "Hide password", id, inline, invalid = false, invalidText, labelText, light, onChange = () => {}, onClick = () => {}, onTogglePasswordVisibility, placeholder, readOnly, size
|
|
27
|
+
const PasswordInput = 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) => {
|
|
27
28
|
const [inputType, setInputType] = useState(type);
|
|
28
29
|
const prefix = usePrefix();
|
|
29
30
|
const normalizedProps = useNormalizedInputProps({
|
|
@@ -54,8 +55,7 @@ const PasswordInput = forwardRef(({ className, disabled = false, helperText, hid
|
|
|
54
55
|
[`${prefix}--text-input--light`]: light,
|
|
55
56
|
[`${prefix}--text-input--invalid`]: normalizedProps.invalid,
|
|
56
57
|
[`${prefix}--text-input--warning`]: normalizedProps.warn,
|
|
57
|
-
[`${prefix}--text-input--${size}`]: size
|
|
58
|
-
[`${prefix}--layout--size-${size}`]: size
|
|
58
|
+
[`${prefix}--text-input--${size}`]: size
|
|
59
59
|
}),
|
|
60
60
|
readOnly,
|
|
61
61
|
ref,
|
|
@@ -65,6 +65,7 @@ const PasswordInput = forwardRef(({ className, disabled = false, helperText, hid
|
|
|
65
65
|
[`${prefix}--text-input-wrapper--readonly`]: readOnly,
|
|
66
66
|
[`${prefix}--text-input-wrapper--light`]: light,
|
|
67
67
|
[`${prefix}--text-input-wrapper--inline`]: inline,
|
|
68
|
+
[`${prefix}--text-input-wrapper--inline--invalid`]: inline && normalizedProps.invalid,
|
|
68
69
|
[`${prefix}--text-input--fluid`]: isFluid
|
|
69
70
|
});
|
|
70
71
|
const labelClasses = classNames(`${prefix}--label`, {
|
|
@@ -78,7 +79,10 @@ const PasswordInput = forwardRef(({ className, disabled = false, helperText, hid
|
|
|
78
79
|
[`${prefix}--form__helper-text--inline`]: inline
|
|
79
80
|
});
|
|
80
81
|
const fieldOuterWrapperClasses = classNames(`${prefix}--text-input__field-outer-wrapper`, { [`${prefix}--text-input__field-outer-wrapper--inline`]: inline });
|
|
81
|
-
const fieldWrapperClasses = classNames(`${prefix}--text-input__field-wrapper`, {
|
|
82
|
+
const fieldWrapperClasses = classNames(`${prefix}--text-input__field-wrapper`, {
|
|
83
|
+
[`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
|
|
84
|
+
[`${prefix}--layout--size-${size}`]: size
|
|
85
|
+
});
|
|
82
86
|
const iconClasses = classNames({
|
|
83
87
|
[`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
|
|
84
88
|
[`${prefix}--text-input__invalid-icon--warning`]: normalizedProps.warn
|
|
@@ -88,7 +92,7 @@ const PasswordInput = forwardRef(({ className, disabled = false, helperText, hid
|
|
|
88
92
|
className: labelClasses,
|
|
89
93
|
children: labelText
|
|
90
94
|
});
|
|
91
|
-
const helper =
|
|
95
|
+
const helper = hasHelperText(helperText) && /* @__PURE__ */ jsx("div", {
|
|
92
96
|
id: normalizedProps.helperId,
|
|
93
97
|
className: helperTextClasses,
|
|
94
98
|
children: helperText
|
|
@@ -117,7 +121,7 @@ const PasswordInput = forwardRef(({ className, disabled = false, helperText, hid
|
|
|
117
121
|
invalidId: normalizedProps.invalidId,
|
|
118
122
|
warn: normalizedProps.warn,
|
|
119
123
|
warnId: normalizedProps.warnId,
|
|
120
|
-
hasHelper:
|
|
124
|
+
hasHelper: hasHelperText(helperText) && !isFluid && (inline || !inline && !normalizedProps.validation),
|
|
121
125
|
helperId: normalizedProps.helperId
|
|
122
126
|
}),
|
|
123
127
|
disabled,
|
|
@@ -143,21 +147,28 @@ const PasswordInput = forwardRef(({ className, disabled = false, helperText, hid
|
|
|
143
147
|
const Icon = normalizedProps.icon;
|
|
144
148
|
return /* @__PURE__ */ jsxs("div", {
|
|
145
149
|
className: inputWrapperClasses,
|
|
146
|
-
children: [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
className:
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
150
|
+
children: [
|
|
151
|
+
!inline ? label : /* @__PURE__ */ jsx("div", {
|
|
152
|
+
className: `${prefix}--text-input__label-helper-wrapper`,
|
|
153
|
+
children: label
|
|
154
|
+
}),
|
|
155
|
+
/* @__PURE__ */ jsxs("div", {
|
|
156
|
+
className: fieldOuterWrapperClasses,
|
|
157
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
158
|
+
className: fieldWrapperClasses,
|
|
159
|
+
"data-invalid": normalizedProps.invalid || null,
|
|
160
|
+
children: [
|
|
161
|
+
Icon && /* @__PURE__ */ jsx(Icon, { className: iconClasses }),
|
|
162
|
+
input,
|
|
163
|
+
isFluid && !inline && normalizedProps.validation
|
|
164
|
+
]
|
|
165
|
+
}), !isFluid && !inline && (normalizedProps.validation || helper)]
|
|
166
|
+
}),
|
|
167
|
+
inline && !isFluid && /* @__PURE__ */ jsx("div", {
|
|
168
|
+
className: `${prefix}--text-input__label-helper-wrapper`,
|
|
169
|
+
children: normalizedProps.validation || helper
|
|
170
|
+
})
|
|
171
|
+
]
|
|
161
172
|
});
|
|
162
173
|
});
|
|
163
174
|
PasswordInput.displayName = "PasswordInput";
|
|
@@ -181,6 +192,7 @@ PasswordInput.propTypes = {
|
|
|
181
192
|
placeholder: PropTypes.string,
|
|
182
193
|
showPasswordLabel: PropTypes.string,
|
|
183
194
|
size: PropTypes.oneOf([
|
|
195
|
+
"xs",
|
|
184
196
|
"sm",
|
|
185
197
|
"md",
|
|
186
198
|
"lg"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Copyright IBM Corp. 2016,
|
|
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;
|
|
@@ -12,22 +12,28 @@ import PropTypes from "prop-types";
|
|
|
12
12
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
13
13
|
//#region src/components/TextInput/TextInput.Skeleton.tsx
|
|
14
14
|
/**
|
|
15
|
-
* Copyright IBM Corp. 2016,
|
|
15
|
+
* Copyright IBM Corp. 2016, 2026
|
|
16
16
|
*
|
|
17
17
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
18
18
|
* LICENSE file in the root directory of this source tree.
|
|
19
19
|
*/
|
|
20
|
-
const TextInputSkeleton = ({ hideLabel, className, ...rest }) => {
|
|
20
|
+
const TextInputSkeleton = ({ hideLabel, className, size, ...rest }) => {
|
|
21
21
|
const prefix = usePrefix();
|
|
22
22
|
return /* @__PURE__ */ jsxs("div", {
|
|
23
|
-
className: classNames(`${prefix}--form-item`, className),
|
|
23
|
+
className: classNames(`${prefix}--form-item`, className, { [`${prefix}--layout--size-${size}`]: size }),
|
|
24
24
|
...rest,
|
|
25
25
|
children: [!hideLabel && /* @__PURE__ */ jsx("span", { className: `${prefix}--label ${prefix}--skeleton` }), /* @__PURE__ */ jsx("div", { className: `${prefix}--skeleton ${prefix}--text-input` })]
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
TextInputSkeleton.propTypes = {
|
|
29
29
|
className: PropTypes.string,
|
|
30
|
-
hideLabel: PropTypes.bool
|
|
30
|
+
hideLabel: PropTypes.bool,
|
|
31
|
+
size: PropTypes.oneOf([
|
|
32
|
+
"xs",
|
|
33
|
+
"sm",
|
|
34
|
+
"md",
|
|
35
|
+
"lg"
|
|
36
|
+
])
|
|
31
37
|
};
|
|
32
38
|
//#endregion
|
|
33
39
|
export { TextInputSkeleton as default };
|
|
@@ -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?: '
|
|
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
|