@carbon/react 1.95.0 → 1.95.1-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 +1017 -1017
- package/es/components/ComboBox/ComboBox.js +15 -9
- package/es/components/Dropdown/Dropdown.js +26 -22
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/es/components/RadioButton/RadioButton.d.ts +20 -0
- package/es/components/RadioButton/RadioButton.js +43 -5
- package/es/components/RadioButtonGroup/RadioButtonGroup.js +3 -3
- package/es/components/Slider/Slider.Skeleton.d.ts +3 -29
- package/es/components/Slider/Slider.Skeleton.js +1 -1
- package/es/components/Slider/Slider.d.ts +2 -144
- package/es/components/Slider/Slider.js +1 -1
- package/es/components/Slider/index.d.ts +1 -3
- package/es/components/TimePicker/TimePicker.js +19 -15
- package/es/index.js +1 -1
- package/lib/components/ComboBox/ComboBox.js +15 -9
- package/lib/components/Dropdown/Dropdown.js +26 -22
- package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/lib/components/RadioButton/RadioButton.d.ts +20 -0
- package/lib/components/RadioButton/RadioButton.js +43 -5
- package/lib/components/RadioButtonGroup/RadioButtonGroup.js +3 -3
- package/lib/components/Slider/Slider.Skeleton.d.ts +3 -29
- package/lib/components/Slider/Slider.Skeleton.js +0 -1
- package/lib/components/Slider/Slider.d.ts +2 -144
- package/lib/components/Slider/Slider.js +3 -1
- package/lib/components/Slider/index.d.ts +1 -3
- package/lib/components/TimePicker/TimePicker.js +19 -15
- package/lib/index.js +1 -1
- package/package.json +4 -4
|
@@ -275,17 +275,23 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
275
275
|
// If custom values are allowed, treat whatever the user typed as
|
|
276
276
|
// the value.
|
|
277
277
|
if (allowCustomValue && highlightedIndex === -1) {
|
|
278
|
-
const
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
const inputValue = state.inputValue ?? '';
|
|
279
|
+
const currentSelectedItem = typeof changes.selectedItem === 'undefined' ? state.selectedItem : changes.selectedItem;
|
|
280
|
+
const isMatchingSelection = currentSelectedItem !== null && typeof currentSelectedItem !== 'undefined' && itemToString(currentSelectedItem) === inputValue && items.some(item => isEqual(item, currentSelectedItem));
|
|
281
|
+
if (isMatchingSelection) {
|
|
282
|
+
return changes;
|
|
283
|
+
}
|
|
284
|
+
const nextSelectedItem = items.find(item => itemToString(item) === inputValue) ?? inputValue;
|
|
285
|
+
if (!isEqual(currentSelectedItem, nextSelectedItem) && onChange) {
|
|
283
286
|
onChange({
|
|
284
|
-
selectedItem:
|
|
287
|
+
selectedItem: nextSelectedItem,
|
|
285
288
|
inputValue
|
|
286
289
|
});
|
|
287
290
|
}
|
|
288
|
-
return
|
|
291
|
+
return {
|
|
292
|
+
...changes,
|
|
293
|
+
selectedItem: nextSelectedItem
|
|
294
|
+
};
|
|
289
295
|
}
|
|
290
296
|
|
|
291
297
|
// If a new item was selected, keep its label in the input.
|
|
@@ -752,13 +758,13 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
752
758
|
} = itemProps;
|
|
753
759
|
return /*#__PURE__*/React.createElement(ListBox.MenuItem, _extends({
|
|
754
760
|
key: itemProps.id,
|
|
755
|
-
isActive: selectedItem
|
|
761
|
+
isActive: isEqual(selectedItem, item),
|
|
756
762
|
isHighlighted: highlightedIndex === index,
|
|
757
763
|
title: title,
|
|
758
764
|
disabled: disabled
|
|
759
765
|
}, modifiedItemProps), ItemToElement ? /*#__PURE__*/React.createElement(ItemToElement, _extends({
|
|
760
766
|
key: itemProps.id
|
|
761
|
-
}, item)) : itemToString(item), selectedItem
|
|
767
|
+
}, item)) : itemToString(item), isEqual(selectedItem, item) && /*#__PURE__*/React.createElement(Checkmark, {
|
|
762
768
|
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
763
769
|
}));
|
|
764
770
|
}) : null)), helperText && !invalid && !warn && !isFluid && /*#__PURE__*/React.createElement(Text, {
|
|
@@ -17,7 +17,7 @@ import { deprecate } from '../../prop-types/deprecate.js';
|
|
|
17
17
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
18
18
|
import '../FluidForm/FluidForm.js';
|
|
19
19
|
import { FormContext } from '../FluidForm/FormContext.js';
|
|
20
|
-
import {
|
|
20
|
+
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
21
21
|
import { useFloating, autoUpdate, size, flip, hide } from '@floating-ui/react';
|
|
22
22
|
import { useFeatureFlag } from '../FeatureFlags/index.js';
|
|
23
23
|
import { AILabel } from '../AILabel/index.js';
|
|
@@ -189,7 +189,6 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
189
189
|
}),
|
|
190
190
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
191
191
|
[items, itemToString, initialSelectedItem, onSelectedItemChange, stateReducer, isItemDisabled, onHighlightedIndexChange, downshiftProps]);
|
|
192
|
-
const dropdownInstanceId = useId();
|
|
193
192
|
|
|
194
193
|
// only set selectedItem if the prop is defined. Setting if it is undefined
|
|
195
194
|
// will overwrite default selected items from useSelect
|
|
@@ -206,15 +205,23 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
206
205
|
highlightedIndex
|
|
207
206
|
} = useSelect(selectProps);
|
|
208
207
|
const inline = type === 'inline';
|
|
209
|
-
const
|
|
208
|
+
const normalizedProps = useNormalizedInputProps({
|
|
209
|
+
id,
|
|
210
|
+
readOnly,
|
|
211
|
+
disabled: disabled ?? false,
|
|
212
|
+
invalid: invalid ?? false,
|
|
213
|
+
invalidText,
|
|
214
|
+
warn: warn ?? false,
|
|
215
|
+
warnText
|
|
216
|
+
});
|
|
210
217
|
const [isFocused, setIsFocused] = useState(false);
|
|
211
218
|
const className = cx(`${prefix}--dropdown`, {
|
|
212
|
-
[`${prefix}--dropdown--invalid`]: invalid,
|
|
213
|
-
[`${prefix}--dropdown--warning`]:
|
|
219
|
+
[`${prefix}--dropdown--invalid`]: normalizedProps.invalid,
|
|
220
|
+
[`${prefix}--dropdown--warning`]: normalizedProps.warn,
|
|
214
221
|
[`${prefix}--dropdown--open`]: isOpen,
|
|
215
222
|
[`${prefix}--dropdown--focus`]: isFocused,
|
|
216
223
|
[`${prefix}--dropdown--inline`]: inline,
|
|
217
|
-
[`${prefix}--dropdown--disabled`]: disabled,
|
|
224
|
+
[`${prefix}--dropdown--disabled`]: normalizedProps.disabled,
|
|
218
225
|
[`${prefix}--dropdown--light`]: light,
|
|
219
226
|
[`${prefix}--dropdown--readonly`]: readOnly,
|
|
220
227
|
[`${prefix}--dropdown--${size$1}`]: size$1,
|
|
@@ -222,22 +229,21 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
222
229
|
[`${prefix}--autoalign`]: autoAlign
|
|
223
230
|
});
|
|
224
231
|
const titleClasses = cx(`${prefix}--label`, {
|
|
225
|
-
[`${prefix}--label--disabled`]: disabled,
|
|
232
|
+
[`${prefix}--label--disabled`]: normalizedProps.disabled,
|
|
226
233
|
[`${prefix}--visually-hidden`]: hideLabel
|
|
227
234
|
});
|
|
228
235
|
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
229
|
-
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
236
|
+
[`${prefix}--form__helper-text--disabled`]: normalizedProps.disabled
|
|
230
237
|
});
|
|
231
238
|
const wrapperClasses = cx(`${prefix}--dropdown__wrapper`, `${prefix}--list-box__wrapper`, containerClassName, {
|
|
232
239
|
[`${prefix}--dropdown__wrapper--inline`]: inline,
|
|
233
240
|
[`${prefix}--list-box__wrapper--inline`]: inline,
|
|
234
|
-
[`${prefix}--dropdown__wrapper--inline--invalid`]: inline && invalid,
|
|
235
|
-
[`${prefix}--list-box__wrapper--inline--invalid`]: inline && invalid,
|
|
236
|
-
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
241
|
+
[`${prefix}--dropdown__wrapper--inline--invalid`]: inline && normalizedProps.invalid,
|
|
242
|
+
[`${prefix}--list-box__wrapper--inline--invalid`]: inline && normalizedProps.invalid,
|
|
243
|
+
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && normalizedProps.invalid,
|
|
237
244
|
[`${prefix}--list-box__wrapper--slug`]: slug,
|
|
238
245
|
[`${prefix}--list-box__wrapper--decorator`]: decorator
|
|
239
246
|
});
|
|
240
|
-
const helperId = !helperText ? undefined : `dropdown-helper-text-${dropdownInstanceId}`;
|
|
241
247
|
|
|
242
248
|
// needs to be Capitalized for react to render it correctly
|
|
243
249
|
const ItemToElement = itemToElement;
|
|
@@ -245,7 +251,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
245
251
|
'aria-label': ariaLabel || deprecatedAriaLabel
|
|
246
252
|
});
|
|
247
253
|
const helper = helperText && !isFluid ? /*#__PURE__*/React.createElement("div", {
|
|
248
|
-
id: helperId,
|
|
254
|
+
id: normalizedProps.helperId,
|
|
249
255
|
className: helperClasses
|
|
250
256
|
}, helperText) : null;
|
|
251
257
|
const handleFocus = evt => {
|
|
@@ -327,27 +333,25 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
327
333
|
onBlur: handleFocus,
|
|
328
334
|
size: size$1,
|
|
329
335
|
className: className,
|
|
330
|
-
invalid: invalid,
|
|
331
|
-
|
|
332
|
-
warn: warn,
|
|
333
|
-
warnText: warnText,
|
|
336
|
+
invalid: normalizedProps.invalid,
|
|
337
|
+
warn: normalizedProps.warn,
|
|
334
338
|
light: light,
|
|
335
339
|
isOpen: isOpen,
|
|
336
340
|
ref: enableFloatingStyles || autoAlign ? refs.setReference : null,
|
|
337
341
|
id: id
|
|
338
|
-
}, invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
342
|
+
}, normalizedProps.invalid && /*#__PURE__*/React.createElement(WarningFilled, {
|
|
339
343
|
className: `${prefix}--list-box__invalid-icon`
|
|
340
|
-
}),
|
|
344
|
+
}), normalizedProps.warn && /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
341
345
|
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
342
346
|
}), /*#__PURE__*/React.createElement("button", _extends({
|
|
343
347
|
type: "button"
|
|
344
348
|
// aria-expanded is already being passed through {...toggleButtonProps}
|
|
345
349
|
,
|
|
346
350
|
className: `${prefix}--list-box__field`,
|
|
347
|
-
disabled: disabled,
|
|
351
|
+
disabled: normalizedProps.disabled,
|
|
348
352
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
349
353
|
,
|
|
350
|
-
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
354
|
+
"aria-describedby": !inline && !normalizedProps.invalid && !normalizedProps.warn && helper ? normalizedProps.helperId : normalizedProps.invalid ? normalizedProps.invalidId : normalizedProps.warn ? normalizedProps.warnId : undefined,
|
|
351
355
|
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString(label)
|
|
352
356
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
353
357
|
ref: mergedRef
|
|
@@ -378,7 +382,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
378
382
|
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React.createElement(Checkmark, {
|
|
379
383
|
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
380
384
|
}));
|
|
381
|
-
}))), !inline && !
|
|
385
|
+
}))), !inline && !isFluid && !normalizedProps.validation && helper, !inline && !isFluid && normalizedProps.validation);
|
|
382
386
|
});
|
|
383
387
|
|
|
384
388
|
// Workaround problems with forwardRef() and generics. In the long term, should stop using forwardRef().
|
|
@@ -695,7 +695,7 @@ const FilterableMultiSelect = /*#__PURE__*/forwardRef(function FilterableMultiSe
|
|
|
695
695
|
translateWithId: translateWithId
|
|
696
696
|
}))), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
697
697
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
698
|
-
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(ListBox.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
698
|
+
}, candidateIsAILabel ? normalizedDecorator : /*#__PURE__*/React.createElement("span", null, normalizedDecorator)) : '', /*#__PURE__*/React.createElement(ListBox.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
699
699
|
let isChecked;
|
|
700
700
|
let isIndeterminate = false;
|
|
701
701
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
@@ -71,6 +71,26 @@ export interface RadioButtonProps extends Omit<React.InputHTMLAttributes<HTMLInp
|
|
|
71
71
|
* `true` to specify if the input is required.
|
|
72
72
|
*/
|
|
73
73
|
required?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Specify whether the control is currently invalid
|
|
76
|
+
*/
|
|
77
|
+
invalid?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Provide the text that is displayed when the control is in an invalid state
|
|
80
|
+
*/
|
|
81
|
+
invalidText?: ReactNode;
|
|
82
|
+
/**
|
|
83
|
+
* Specify whether the control is currently in warning state
|
|
84
|
+
*/
|
|
85
|
+
warn?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Provide the text that is displayed when the control is in warning state
|
|
88
|
+
*/
|
|
89
|
+
warnText?: ReactNode;
|
|
90
|
+
/**
|
|
91
|
+
* Specify whether the RadioButton should be read-only
|
|
92
|
+
*/
|
|
93
|
+
readOnly?: boolean;
|
|
74
94
|
}
|
|
75
95
|
declare const RadioButton: React.ForwardRefExoticComponent<RadioButtonProps & React.RefAttributes<HTMLInputElement>>;
|
|
76
96
|
export default RadioButton;
|
|
@@ -17,12 +17,13 @@ import { useId } from '../../internal/useId.js';
|
|
|
17
17
|
import { mergeRefs } from '../../tools/mergeRefs.js';
|
|
18
18
|
import { AILabel } from '../AILabel/index.js';
|
|
19
19
|
import { isComponentElement } from '../../internal/utils.js';
|
|
20
|
+
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
20
21
|
|
|
21
22
|
const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
22
23
|
const {
|
|
23
24
|
className,
|
|
24
25
|
decorator,
|
|
25
|
-
disabled,
|
|
26
|
+
disabled = false,
|
|
26
27
|
hideLabel,
|
|
27
28
|
id,
|
|
28
29
|
labelPosition = 'right',
|
|
@@ -32,11 +33,25 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
32
33
|
value = '',
|
|
33
34
|
slug,
|
|
34
35
|
required,
|
|
36
|
+
invalid = false,
|
|
37
|
+
invalidText,
|
|
38
|
+
warn = false,
|
|
39
|
+
warnText,
|
|
40
|
+
readOnly,
|
|
35
41
|
...rest
|
|
36
42
|
} = props;
|
|
37
43
|
const prefix = usePrefix();
|
|
38
44
|
const uid = useId('radio-button');
|
|
39
45
|
const uniqueId = id || uid;
|
|
46
|
+
const normalizedProps = useNormalizedInputProps({
|
|
47
|
+
id: uniqueId,
|
|
48
|
+
readOnly,
|
|
49
|
+
disabled,
|
|
50
|
+
invalid,
|
|
51
|
+
invalidText,
|
|
52
|
+
warn,
|
|
53
|
+
warnText
|
|
54
|
+
});
|
|
40
55
|
function handleOnChange(event) {
|
|
41
56
|
onChange(value, name, event);
|
|
42
57
|
}
|
|
@@ -46,7 +61,9 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
46
61
|
const wrapperClasses = cx(className, `${prefix}--radio-button-wrapper`, {
|
|
47
62
|
[`${prefix}--radio-button-wrapper--label-${labelPosition}`]: labelPosition !== 'right',
|
|
48
63
|
[`${prefix}--radio-button-wrapper--slug`]: slug,
|
|
49
|
-
[`${prefix}--radio-button-wrapper--decorator`]: decorator
|
|
64
|
+
[`${prefix}--radio-button-wrapper--decorator`]: decorator,
|
|
65
|
+
[`${prefix}--radio-button-wrapper--invalid`]: normalizedProps.invalid,
|
|
66
|
+
[`${prefix}--radio-button-wrapper--warning`]: normalizedProps.warn
|
|
50
67
|
});
|
|
51
68
|
const inputRef = useRef(null);
|
|
52
69
|
const candidate = slug ?? decorator;
|
|
@@ -62,10 +79,11 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
62
79
|
onChange: handleOnChange,
|
|
63
80
|
id: uniqueId,
|
|
64
81
|
ref: mergeRefs(inputRef, ref),
|
|
65
|
-
disabled: disabled,
|
|
82
|
+
disabled: normalizedProps.disabled,
|
|
66
83
|
value: value,
|
|
67
84
|
name: name,
|
|
68
|
-
required: required
|
|
85
|
+
required: required,
|
|
86
|
+
readOnly: readOnly
|
|
69
87
|
})), /*#__PURE__*/React.createElement("label", {
|
|
70
88
|
htmlFor: uniqueId,
|
|
71
89
|
className: `${prefix}--radio-button__label`
|
|
@@ -75,7 +93,7 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
75
93
|
className: innerLabelClasses
|
|
76
94
|
}, labelText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
77
95
|
className: `${prefix}--radio-button-wrapper-inner--decorator`
|
|
78
|
-
}, normalizedDecorator) : '')));
|
|
96
|
+
}, normalizedDecorator) : '')), normalizedProps.validation);
|
|
79
97
|
});
|
|
80
98
|
RadioButton.displayName = 'RadioButton';
|
|
81
99
|
RadioButton.propTypes = {
|
|
@@ -134,6 +152,26 @@ RadioButton.propTypes = {
|
|
|
134
152
|
* `true` to specify if the control is required.
|
|
135
153
|
*/
|
|
136
154
|
required: PropTypes.bool,
|
|
155
|
+
/**
|
|
156
|
+
* Specify whether the control is currently invalid
|
|
157
|
+
*/
|
|
158
|
+
invalid: PropTypes.bool,
|
|
159
|
+
/**
|
|
160
|
+
* Provide the text that is displayed when the control is in an invalid state
|
|
161
|
+
*/
|
|
162
|
+
invalidText: PropTypes.node,
|
|
163
|
+
/**
|
|
164
|
+
* Specify whether the control is currently in warning state
|
|
165
|
+
*/
|
|
166
|
+
warn: PropTypes.bool,
|
|
167
|
+
/**
|
|
168
|
+
* Provide the text that is displayed when the control is in warning state
|
|
169
|
+
*/
|
|
170
|
+
warnText: PropTypes.node,
|
|
171
|
+
/**
|
|
172
|
+
* Specify whether the RadioButton should be read-only
|
|
173
|
+
*/
|
|
174
|
+
readOnly: PropTypes.bool,
|
|
137
175
|
/**
|
|
138
176
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
139
177
|
*/
|
|
@@ -82,14 +82,14 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
const showWarning = !readOnly && !invalid && warn;
|
|
85
|
+
const showWarning = !readOnly && !disabled && !invalid && warn;
|
|
86
86
|
const showHelper = !invalid && !disabled && !warn;
|
|
87
87
|
const wrapperClasses = cx(`${prefix}--form-item`, className);
|
|
88
88
|
const fieldsetClasses = cx(`${prefix}--radio-button-group`, {
|
|
89
89
|
[`${prefix}--radio-button-group--${orientation}`]: orientation === 'vertical',
|
|
90
90
|
[`${prefix}--radio-button-group--label-${labelPosition}`]: labelPosition,
|
|
91
91
|
[`${prefix}--radio-button-group--readonly`]: readOnly,
|
|
92
|
-
[`${prefix}--radio-button-group--invalid`]: !readOnly && invalid,
|
|
92
|
+
[`${prefix}--radio-button-group--invalid`]: !readOnly && !disabled && invalid,
|
|
93
93
|
[`${prefix}--radio-button-group--warning`]: showWarning,
|
|
94
94
|
[`${prefix}--radio-button-group--slug`]: slug,
|
|
95
95
|
[`${prefix}--radio-button-group--decorator`]: decorator
|
|
@@ -125,7 +125,7 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
125
125
|
className: `${prefix}--radio-button-group-inner--decorator`
|
|
126
126
|
}, normalizedDecorator) : ''), getRadioButtons()), /*#__PURE__*/React.createElement("div", {
|
|
127
127
|
className: `${prefix}--radio-button__validation-msg`
|
|
128
|
-
}, !readOnly && invalid && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WarningFilled, {
|
|
128
|
+
}, !readOnly && !disabled && invalid && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(WarningFilled, {
|
|
129
129
|
className: `${prefix}--radio-button__invalid-icon`
|
|
130
130
|
}), /*#__PURE__*/React.createElement("div", {
|
|
131
131
|
className: `${prefix}--form-requirement`
|
|
@@ -4,8 +4,7 @@
|
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import { HTMLAttributes } from 'react';
|
|
7
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
9
8
|
export interface SliderSkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
10
9
|
/**
|
|
11
10
|
* The `ariaLabel` for the handle icon.
|
|
@@ -28,30 +27,5 @@ export interface SliderSkeletonProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
28
27
|
*/
|
|
29
28
|
twoHandles?: boolean;
|
|
30
29
|
}
|
|
31
|
-
declare const
|
|
32
|
-
|
|
33
|
-
propTypes: {
|
|
34
|
-
/**
|
|
35
|
-
* The `ariaLabel` for the handle icon.
|
|
36
|
-
*/
|
|
37
|
-
ariaLabel: PropTypes.Requireable<string>;
|
|
38
|
-
/**
|
|
39
|
-
* The `ariaLabel` for the upper bound slider handle when there are two handles.
|
|
40
|
-
*/
|
|
41
|
-
unstable_ariaLabelHandleUpper: PropTypes.Requireable<string>;
|
|
42
|
-
/**
|
|
43
|
-
* Specify an optional className to add to the form item wrapper.
|
|
44
|
-
*/
|
|
45
|
-
className: PropTypes.Requireable<string>;
|
|
46
|
-
/**
|
|
47
|
-
* Specify whether the label should be hidden, or not
|
|
48
|
-
*/
|
|
49
|
-
hideLabel: PropTypes.Requireable<boolean>;
|
|
50
|
-
/**
|
|
51
|
-
* Turn the slider into a range slider.
|
|
52
|
-
*/
|
|
53
|
-
twoHandles: PropTypes.Requireable<boolean>;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
export default SliderSkeleton;
|
|
57
|
-
export { SliderSkeleton };
|
|
30
|
+
declare const _default: (props: SliderSkeletonProps) => ReactNode;
|
|
31
|
+
export default _default;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
import { type InputHTMLAttributes, type KeyboardEventHandler, type ReactNode } from 'react';
|
|
8
|
-
import PropTypes from 'prop-types';
|
|
9
8
|
import type { TranslateWithId } from '../../types/common';
|
|
10
9
|
declare const translationIds: {
|
|
11
10
|
readonly 'carbon.slider.auto-correct-announcement': "carbon.slider.auto-correct-announcement";
|
|
@@ -162,146 +161,5 @@ export interface SliderProps extends Omit<InputHTMLAttributes<HTMLInputElement>,
|
|
|
162
161
|
*/
|
|
163
162
|
warnText?: ReactNode;
|
|
164
163
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
propTypes: {
|
|
168
|
-
/**
|
|
169
|
-
* The `ariaLabel` for the `<input>`.
|
|
170
|
-
*/
|
|
171
|
-
ariaLabelInput: PropTypes.Requireable<string>;
|
|
172
|
-
/**
|
|
173
|
-
* The child nodes.
|
|
174
|
-
*/
|
|
175
|
-
children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
176
|
-
/**
|
|
177
|
-
* The CSS class name for the slider.
|
|
178
|
-
*/
|
|
179
|
-
className: PropTypes.Requireable<string>;
|
|
180
|
-
/**
|
|
181
|
-
* `true` to disable this slider.
|
|
182
|
-
*/
|
|
183
|
-
disabled: PropTypes.Requireable<boolean>;
|
|
184
|
-
/**
|
|
185
|
-
* The callback to format the label associated with the minimum/maximum value.
|
|
186
|
-
*/
|
|
187
|
-
formatLabel: PropTypes.Requireable<(...args: any[]) => any>;
|
|
188
|
-
/**
|
|
189
|
-
* `true` to hide the number input box.
|
|
190
|
-
*/
|
|
191
|
-
hideTextInput: PropTypes.Requireable<boolean>;
|
|
192
|
-
/**
|
|
193
|
-
* The ID of the `<input>`.
|
|
194
|
-
*/
|
|
195
|
-
id: PropTypes.Requireable<string>;
|
|
196
|
-
/**
|
|
197
|
-
* The `type` attribute of the `<input>`.
|
|
198
|
-
*/
|
|
199
|
-
inputType: PropTypes.Requireable<string>;
|
|
200
|
-
/**
|
|
201
|
-
* `Specify whether the Slider is currently invalid
|
|
202
|
-
*/
|
|
203
|
-
invalid: PropTypes.Requireable<boolean>;
|
|
204
|
-
/**
|
|
205
|
-
* Provide the text that is displayed when the Slider is in an invalid state
|
|
206
|
-
*/
|
|
207
|
-
invalidText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
208
|
-
/**
|
|
209
|
-
* The label for the slider.
|
|
210
|
-
*/
|
|
211
|
-
labelText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
212
|
-
/**
|
|
213
|
-
* Specify whether you want the underlying label to be visually hidden
|
|
214
|
-
*/
|
|
215
|
-
hideLabel: PropTypes.Requireable<boolean>;
|
|
216
|
-
/**
|
|
217
|
-
* `true` to use the light version.
|
|
218
|
-
*/
|
|
219
|
-
light: (props: Record<string, any>, propName: string, componentName: string, ...rest: any[]) => any;
|
|
220
|
-
/**
|
|
221
|
-
* The maximum value.
|
|
222
|
-
*/
|
|
223
|
-
max: PropTypes.Validator<number>;
|
|
224
|
-
/**
|
|
225
|
-
* The label associated with the maximum value.
|
|
226
|
-
*/
|
|
227
|
-
maxLabel: PropTypes.Requireable<string>;
|
|
228
|
-
/**
|
|
229
|
-
* The minimum value.
|
|
230
|
-
*/
|
|
231
|
-
min: PropTypes.Validator<number>;
|
|
232
|
-
/**
|
|
233
|
-
* The label associated with the minimum value.
|
|
234
|
-
*/
|
|
235
|
-
minLabel: PropTypes.Requireable<string>;
|
|
236
|
-
/**
|
|
237
|
-
* The `name` attribute of the `<input>`.
|
|
238
|
-
*/
|
|
239
|
-
name: PropTypes.Requireable<string>;
|
|
240
|
-
/**
|
|
241
|
-
* Provide an optional function to be called when the input element
|
|
242
|
-
* loses focus
|
|
243
|
-
*/
|
|
244
|
-
onBlur: PropTypes.Requireable<(...args: any[]) => any>;
|
|
245
|
-
/**
|
|
246
|
-
* The callback to get notified of change in value.
|
|
247
|
-
*/
|
|
248
|
-
onChange: PropTypes.Requireable<(...args: any[]) => any>;
|
|
249
|
-
/**
|
|
250
|
-
* Provide an optional function to be called when a key is pressed in the number input.
|
|
251
|
-
*/
|
|
252
|
-
onInputKeyUp: PropTypes.Requireable<(...args: any[]) => any>;
|
|
253
|
-
/**
|
|
254
|
-
* The callback to get notified of value on handle release.
|
|
255
|
-
*/
|
|
256
|
-
onRelease: PropTypes.Requireable<(...args: any[]) => any>;
|
|
257
|
-
/**
|
|
258
|
-
* Whether the slider should be read-only
|
|
259
|
-
*/
|
|
260
|
-
readOnly: PropTypes.Requireable<boolean>;
|
|
261
|
-
/**
|
|
262
|
-
* `true` to specify if the control is required.
|
|
263
|
-
*/
|
|
264
|
-
required: PropTypes.Requireable<boolean>;
|
|
265
|
-
/**
|
|
266
|
-
* A value determining how much the value should increase/decrease by moving the thumb by mouse. If a value other than 1 is provided and the input is *not* hidden, the new step requirement should be added to a visible label. Values outside the `step` increment will be considered invalid.
|
|
267
|
-
*/
|
|
268
|
-
step: PropTypes.Requireable<number>;
|
|
269
|
-
/**
|
|
270
|
-
* A value determining how much the value should increase/decrease by Shift+arrow keys,
|
|
271
|
-
* which will be `(max - min) / stepMultiplier`.
|
|
272
|
-
*/
|
|
273
|
-
stepMultiplier: PropTypes.Requireable<number>;
|
|
274
|
-
/**
|
|
275
|
-
* Supply a method to translate internal strings with your i18n tool of
|
|
276
|
-
* choice. Translation keys are available on the `translationIds` field for
|
|
277
|
-
* this component.
|
|
278
|
-
*/
|
|
279
|
-
translateWithId: PropTypes.Requireable<(...args: any[]) => any>;
|
|
280
|
-
/**
|
|
281
|
-
* The `ariaLabel` for the upper bound `<input>` when there are two handles.
|
|
282
|
-
*/
|
|
283
|
-
unstable_ariaLabelInputUpper: PropTypes.Requireable<string>;
|
|
284
|
-
/**
|
|
285
|
-
* The `name` attribute of the upper bound `<input>` when there are two handles.
|
|
286
|
-
*/
|
|
287
|
-
unstable_nameUpper: PropTypes.Requireable<string>;
|
|
288
|
-
/**
|
|
289
|
-
* The upper bound when there are two handles.
|
|
290
|
-
*/
|
|
291
|
-
unstable_valueUpper: PropTypes.Requireable<number>;
|
|
292
|
-
/**
|
|
293
|
-
* The value of the slider. When there are two handles, value is the lower
|
|
294
|
-
* bound.
|
|
295
|
-
*/
|
|
296
|
-
value: PropTypes.Validator<number>;
|
|
297
|
-
/**
|
|
298
|
-
* `Specify whether the Slider is in a warn state
|
|
299
|
-
*/
|
|
300
|
-
warn: PropTypes.Requireable<boolean>;
|
|
301
|
-
/**
|
|
302
|
-
* Provide the text that is displayed when the Slider is in a warn state
|
|
303
|
-
*/
|
|
304
|
-
warnText: PropTypes.Requireable<PropTypes.ReactNodeLike>;
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
export {};
|
|
164
|
+
declare const _default: (props: SliderProps) => ReactNode;
|
|
165
|
+
export default _default;
|
|
@@ -4,7 +4,5 @@
|
|
|
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.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
export { default as Slider } from './Slider';
|
|
8
8
|
export { default as SliderSkeleton } from './Slider.Skeleton';
|
|
9
|
-
export default Slider;
|
|
10
|
-
export { Slider };
|
|
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
|
|
|
11
11
|
import React, { forwardRef } from 'react';
|
|
12
12
|
import { usePrefix } from '../../internal/usePrefix.js';
|
|
13
13
|
import { deprecate } from '../../prop-types/deprecate.js';
|
|
14
|
-
import {
|
|
14
|
+
import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
|
|
15
15
|
|
|
16
16
|
const frFn = forwardRef;
|
|
17
17
|
const TimePicker = frFn((props, ref) => {
|
|
@@ -70,15 +70,24 @@ const TimePicker = frFn((props, ref) => {
|
|
|
70
70
|
onBlur(evt);
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
+
const normalizedProps = useNormalizedInputProps({
|
|
74
|
+
id,
|
|
75
|
+
readOnly,
|
|
76
|
+
disabled,
|
|
77
|
+
invalid,
|
|
78
|
+
invalidText,
|
|
79
|
+
warn: warning,
|
|
80
|
+
warnText: warningText
|
|
81
|
+
});
|
|
73
82
|
const timePickerInputClasses = cx(`${prefix}--time-picker__input-field`, `${prefix}--text-input`, [inputClassName], {
|
|
74
83
|
[`${prefix}--text-input--light`]: light,
|
|
75
|
-
[`${prefix}--time-picker__input-field-error`]: invalid ||
|
|
84
|
+
[`${prefix}--time-picker__input-field-error`]: normalizedProps.invalid || normalizedProps.warn
|
|
76
85
|
});
|
|
77
86
|
const timePickerClasses = cx({
|
|
78
87
|
[`${prefix}--time-picker`]: true,
|
|
79
88
|
[`${prefix}--time-picker--light`]: light,
|
|
80
|
-
[`${prefix}--time-picker--invalid`]: invalid,
|
|
81
|
-
[`${prefix}--time-picker--warning`]:
|
|
89
|
+
[`${prefix}--time-picker--invalid`]: normalizedProps.invalid,
|
|
90
|
+
[`${prefix}--time-picker--warning`]: normalizedProps.warn,
|
|
82
91
|
[`${prefix}--time-picker--readonly`]: readOnly,
|
|
83
92
|
[`${prefix}--time-picker--${size}`]: size,
|
|
84
93
|
...(pickerClassName && {
|
|
@@ -136,8 +145,8 @@ const TimePicker = frFn((props, ref) => {
|
|
|
136
145
|
className: `${prefix}--time-picker__input`
|
|
137
146
|
}, /*#__PURE__*/React.createElement("input", _extends({
|
|
138
147
|
className: timePickerInputClasses,
|
|
139
|
-
"data-invalid": invalid ?
|
|
140
|
-
disabled: disabled,
|
|
148
|
+
"data-invalid": normalizedProps.invalid ? true : undefined,
|
|
149
|
+
disabled: normalizedProps.disabled,
|
|
141
150
|
id: id,
|
|
142
151
|
maxLength: maxLength,
|
|
143
152
|
onClick: handleOnClick,
|
|
@@ -148,17 +157,12 @@ const TimePicker = frFn((props, ref) => {
|
|
|
148
157
|
ref: ref,
|
|
149
158
|
type: type,
|
|
150
159
|
value: value
|
|
151
|
-
}, rest, readOnlyProps)), (invalid ||
|
|
160
|
+
}, rest, readOnlyProps)), (normalizedProps.invalid || normalizedProps.warn) && normalizedProps.icon && /*#__PURE__*/React.createElement("div", {
|
|
152
161
|
className: `${prefix}--time-picker__error__icon`
|
|
153
|
-
},
|
|
154
|
-
className: `${prefix}--checkbox__invalid-icon`,
|
|
155
|
-
size: 16
|
|
156
|
-
}) : /*#__PURE__*/React.createElement(WarningAltFilled, {
|
|
157
|
-
className: `${prefix}--text-input__invalid-icon--warning`,
|
|
162
|
+
}, /*#__PURE__*/React.createElement(normalizedProps.icon, {
|
|
163
|
+
className: normalizedProps.invalid ? `${prefix}--checkbox__invalid-icon` : `${prefix}--text-input__invalid-icon--warning`,
|
|
158
164
|
size: 16
|
|
159
|
-
}))), getInternalPickerSelects()),
|
|
160
|
-
className: `${prefix}--form-requirement`
|
|
161
|
-
}, invalid ? invalidText : warningText));
|
|
165
|
+
}))), getInternalPickerSelects()), normalizedProps.validation);
|
|
162
166
|
});
|
|
163
167
|
TimePicker.propTypes = {
|
|
164
168
|
/**
|
package/es/index.js
CHANGED
|
@@ -133,7 +133,7 @@ export { default as SelectItemGroup } from './components/SelectItemGroup/SelectI
|
|
|
133
133
|
export { default as SkeletonIcon } from './components/SkeletonIcon/SkeletonIcon.js';
|
|
134
134
|
export { default as SkeletonPlaceholder } from './components/SkeletonPlaceholder/SkeletonPlaceholder.js';
|
|
135
135
|
export { default as SkeletonText } from './components/SkeletonText/SkeletonText.js';
|
|
136
|
-
export { Slider } from './components/Slider/Slider.js';
|
|
136
|
+
export { default as Slider } from './components/Slider/Slider.js';
|
|
137
137
|
export { default as SliderSkeleton } from './components/Slider/Slider.Skeleton.js';
|
|
138
138
|
export { HStack } from './components/Stack/HStack.js';
|
|
139
139
|
export { Stack } from './components/Stack/Stack.js';
|