@carbon/react 1.95.0 → 1.96.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 +1039 -1004
- package/es/components/ComboBox/ComboBox.js +15 -9
- package/es/components/Dropdown/Dropdown.js +26 -22
- package/es/components/Menu/Menu.js +1 -1
- package/es/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/es/components/Pagination/Pagination.js +1 -0
- 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/Search/Search.js +17 -7
- 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/Menu/Menu.js +1 -1
- package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -1
- package/lib/components/Pagination/Pagination.js +1 -0
- 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/Search/Search.js +16 -6
- 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
|
@@ -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';
|
|
@@ -279,17 +279,23 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
279
279
|
// If custom values are allowed, treat whatever the user typed as
|
|
280
280
|
// the value.
|
|
281
281
|
if (allowCustomValue && highlightedIndex === -1) {
|
|
282
|
-
const
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
const inputValue = state.inputValue ?? '';
|
|
283
|
+
const currentSelectedItem = typeof changes.selectedItem === 'undefined' ? state.selectedItem : changes.selectedItem;
|
|
284
|
+
const isMatchingSelection = currentSelectedItem !== null && typeof currentSelectedItem !== 'undefined' && itemToString(currentSelectedItem) === inputValue && items.some(item => isEqual(item, currentSelectedItem));
|
|
285
|
+
if (isMatchingSelection) {
|
|
286
|
+
return changes;
|
|
287
|
+
}
|
|
288
|
+
const nextSelectedItem = items.find(item => itemToString(item) === inputValue) ?? inputValue;
|
|
289
|
+
if (!isEqual(currentSelectedItem, nextSelectedItem) && onChange) {
|
|
287
290
|
onChange({
|
|
288
|
-
selectedItem:
|
|
291
|
+
selectedItem: nextSelectedItem,
|
|
289
292
|
inputValue
|
|
290
293
|
});
|
|
291
294
|
}
|
|
292
|
-
return
|
|
295
|
+
return {
|
|
296
|
+
...changes,
|
|
297
|
+
selectedItem: nextSelectedItem
|
|
298
|
+
};
|
|
293
299
|
}
|
|
294
300
|
|
|
295
301
|
// If a new item was selected, keep its label in the input.
|
|
@@ -756,13 +762,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
756
762
|
} = itemProps;
|
|
757
763
|
return /*#__PURE__*/React.createElement(index$2.default.MenuItem, _rollupPluginBabelHelpers.extends({
|
|
758
764
|
key: itemProps.id,
|
|
759
|
-
isActive: selectedItem
|
|
765
|
+
isActive: isEqual(selectedItem, item),
|
|
760
766
|
isHighlighted: highlightedIndex === index,
|
|
761
767
|
title: title,
|
|
762
768
|
disabled: disabled
|
|
763
769
|
}, modifiedItemProps), ItemToElement ? /*#__PURE__*/React.createElement(ItemToElement, _rollupPluginBabelHelpers.extends({
|
|
764
770
|
key: itemProps.id
|
|
765
|
-
}, item)) : itemToString(item), selectedItem
|
|
771
|
+
}, item)) : itemToString(item), isEqual(selectedItem, item) && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
|
|
766
772
|
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
767
773
|
}));
|
|
768
774
|
}) : null)), helperText && !invalid && !warn && !isFluid && /*#__PURE__*/React.createElement(Text.Text, {
|
|
@@ -21,7 +21,7 @@ var deprecate = require('../../prop-types/deprecate.js');
|
|
|
21
21
|
var usePrefix = require('../../internal/usePrefix.js');
|
|
22
22
|
require('../FluidForm/FluidForm.js');
|
|
23
23
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
24
|
-
var
|
|
24
|
+
var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
|
|
25
25
|
var react = require('@floating-ui/react');
|
|
26
26
|
var index = require('../FeatureFlags/index.js');
|
|
27
27
|
var index$1 = require('../AILabel/index.js');
|
|
@@ -193,7 +193,6 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
193
193
|
}),
|
|
194
194
|
// eslint-disable-next-line react-hooks/exhaustive-deps -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
195
195
|
[items, itemToString, initialSelectedItem, onSelectedItemChange, stateReducer, isItemDisabled, onHighlightedIndexChange, downshiftProps]);
|
|
196
|
-
const dropdownInstanceId = useId.useId();
|
|
197
196
|
|
|
198
197
|
// only set selectedItem if the prop is defined. Setting if it is undefined
|
|
199
198
|
// will overwrite default selected items from useSelect
|
|
@@ -210,15 +209,23 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
210
209
|
highlightedIndex
|
|
211
210
|
} = Downshift.useSelect(selectProps);
|
|
212
211
|
const inline = type === 'inline';
|
|
213
|
-
const
|
|
212
|
+
const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
|
|
213
|
+
id,
|
|
214
|
+
readOnly,
|
|
215
|
+
disabled: disabled ?? false,
|
|
216
|
+
invalid: invalid ?? false,
|
|
217
|
+
invalidText,
|
|
218
|
+
warn: warn ?? false,
|
|
219
|
+
warnText
|
|
220
|
+
});
|
|
214
221
|
const [isFocused, setIsFocused] = React.useState(false);
|
|
215
222
|
const className = cx(`${prefix}--dropdown`, {
|
|
216
|
-
[`${prefix}--dropdown--invalid`]: invalid,
|
|
217
|
-
[`${prefix}--dropdown--warning`]:
|
|
223
|
+
[`${prefix}--dropdown--invalid`]: normalizedProps.invalid,
|
|
224
|
+
[`${prefix}--dropdown--warning`]: normalizedProps.warn,
|
|
218
225
|
[`${prefix}--dropdown--open`]: isOpen,
|
|
219
226
|
[`${prefix}--dropdown--focus`]: isFocused,
|
|
220
227
|
[`${prefix}--dropdown--inline`]: inline,
|
|
221
|
-
[`${prefix}--dropdown--disabled`]: disabled,
|
|
228
|
+
[`${prefix}--dropdown--disabled`]: normalizedProps.disabled,
|
|
222
229
|
[`${prefix}--dropdown--light`]: light,
|
|
223
230
|
[`${prefix}--dropdown--readonly`]: readOnly,
|
|
224
231
|
[`${prefix}--dropdown--${size}`]: size,
|
|
@@ -226,22 +233,21 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
226
233
|
[`${prefix}--autoalign`]: autoAlign
|
|
227
234
|
});
|
|
228
235
|
const titleClasses = cx(`${prefix}--label`, {
|
|
229
|
-
[`${prefix}--label--disabled`]: disabled,
|
|
236
|
+
[`${prefix}--label--disabled`]: normalizedProps.disabled,
|
|
230
237
|
[`${prefix}--visually-hidden`]: hideLabel
|
|
231
238
|
});
|
|
232
239
|
const helperClasses = cx(`${prefix}--form__helper-text`, {
|
|
233
|
-
[`${prefix}--form__helper-text--disabled`]: disabled
|
|
240
|
+
[`${prefix}--form__helper-text--disabled`]: normalizedProps.disabled
|
|
234
241
|
});
|
|
235
242
|
const wrapperClasses = cx(`${prefix}--dropdown__wrapper`, `${prefix}--list-box__wrapper`, containerClassName, {
|
|
236
243
|
[`${prefix}--dropdown__wrapper--inline`]: inline,
|
|
237
244
|
[`${prefix}--list-box__wrapper--inline`]: inline,
|
|
238
|
-
[`${prefix}--dropdown__wrapper--inline--invalid`]: inline && invalid,
|
|
239
|
-
[`${prefix}--list-box__wrapper--inline--invalid`]: inline && invalid,
|
|
240
|
-
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && invalid,
|
|
245
|
+
[`${prefix}--dropdown__wrapper--inline--invalid`]: inline && normalizedProps.invalid,
|
|
246
|
+
[`${prefix}--list-box__wrapper--inline--invalid`]: inline && normalizedProps.invalid,
|
|
247
|
+
[`${prefix}--list-box__wrapper--fluid--invalid`]: isFluid && normalizedProps.invalid,
|
|
241
248
|
[`${prefix}--list-box__wrapper--slug`]: slug,
|
|
242
249
|
[`${prefix}--list-box__wrapper--decorator`]: decorator
|
|
243
250
|
});
|
|
244
|
-
const helperId = !helperText ? undefined : `dropdown-helper-text-${dropdownInstanceId}`;
|
|
245
251
|
|
|
246
252
|
// needs to be Capitalized for react to render it correctly
|
|
247
253
|
const ItemToElement = itemToElement;
|
|
@@ -249,7 +255,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
249
255
|
'aria-label': ariaLabel || deprecatedAriaLabel
|
|
250
256
|
});
|
|
251
257
|
const helper = helperText && !isFluid ? /*#__PURE__*/React.createElement("div", {
|
|
252
|
-
id: helperId,
|
|
258
|
+
id: normalizedProps.helperId,
|
|
253
259
|
className: helperClasses
|
|
254
260
|
}, helperText) : null;
|
|
255
261
|
const handleFocus = evt => {
|
|
@@ -331,27 +337,25 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
331
337
|
onBlur: handleFocus,
|
|
332
338
|
size: size,
|
|
333
339
|
className: className,
|
|
334
|
-
invalid: invalid,
|
|
335
|
-
|
|
336
|
-
warn: warn,
|
|
337
|
-
warnText: warnText,
|
|
340
|
+
invalid: normalizedProps.invalid,
|
|
341
|
+
warn: normalizedProps.warn,
|
|
338
342
|
light: light,
|
|
339
343
|
isOpen: isOpen,
|
|
340
344
|
ref: enableFloatingStyles || autoAlign ? refs.setReference : null,
|
|
341
345
|
id: id
|
|
342
|
-
}, invalid && /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
346
|
+
}, normalizedProps.invalid && /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
343
347
|
className: `${prefix}--list-box__invalid-icon`
|
|
344
|
-
}),
|
|
348
|
+
}), normalizedProps.warn && /*#__PURE__*/React.createElement(iconsReact.WarningAltFilled, {
|
|
345
349
|
className: `${prefix}--list-box__invalid-icon ${prefix}--list-box__invalid-icon--warning`
|
|
346
350
|
}), /*#__PURE__*/React.createElement("button", _rollupPluginBabelHelpers.extends({
|
|
347
351
|
type: "button"
|
|
348
352
|
// aria-expanded is already being passed through {...toggleButtonProps}
|
|
349
353
|
,
|
|
350
354
|
className: `${prefix}--list-box__field`,
|
|
351
|
-
disabled: disabled,
|
|
355
|
+
disabled: normalizedProps.disabled,
|
|
352
356
|
"aria-disabled": readOnly ? true : undefined // aria-disabled to remain focusable
|
|
353
357
|
,
|
|
354
|
-
"aria-describedby": !inline && !invalid && !warn && helper ? helperId : undefined,
|
|
358
|
+
"aria-describedby": !inline && !normalizedProps.invalid && !normalizedProps.warn && helper ? normalizedProps.helperId : normalizedProps.invalid ? normalizedProps.invalidId : normalizedProps.warn ? normalizedProps.warnId : undefined,
|
|
355
359
|
title: selectedItem && itemToString !== undefined ? itemToString(selectedItem) : defaultItemToString.defaultItemToString(label)
|
|
356
360
|
}, toggleButtonProps, readOnlyEventHandlers, {
|
|
357
361
|
ref: mergedRef
|
|
@@ -382,7 +386,7 @@ const Dropdown = /*#__PURE__*/React.forwardRef(({
|
|
|
382
386
|
}, item)) : itemToString(item), selectedItem === item && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
|
|
383
387
|
className: `${prefix}--list-box__menu-item__selected-icon`
|
|
384
388
|
}));
|
|
385
|
-
}))), !inline && !
|
|
389
|
+
}))), !inline && !isFluid && !normalizedProps.validation && helper, !inline && !isFluid && normalizedProps.validation);
|
|
386
390
|
});
|
|
387
391
|
|
|
388
392
|
// Workaround problems with forwardRef() and generics. In the long term, should stop using forwardRef().
|
|
@@ -151,7 +151,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
function handleBlur(e) {
|
|
154
|
-
if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
|
|
154
|
+
if (open && onClose && isRoot && e.relatedTarget && !menu.current?.contains(e.relatedTarget)) {
|
|
155
155
|
handleClose();
|
|
156
156
|
}
|
|
157
157
|
}
|
|
@@ -697,7 +697,7 @@ const FilterableMultiSelect = /*#__PURE__*/React.forwardRef(function FilterableM
|
|
|
697
697
|
translateWithId: translateWithId
|
|
698
698
|
}))), slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
699
699
|
className: `${prefix}--list-box__inner-wrapper--decorator`
|
|
700
|
-
}, normalizedDecorator) : '', /*#__PURE__*/React.createElement(index$1.default.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
700
|
+
}, candidateIsAILabel ? normalizedDecorator : /*#__PURE__*/React.createElement("span", null, normalizedDecorator)) : '', /*#__PURE__*/React.createElement(index$1.default.Menu, menuProps, isOpen ? sortedItems.map((item, index) => {
|
|
701
701
|
let isChecked;
|
|
702
702
|
let isIndeterminate = false;
|
|
703
703
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- https://github.com/carbon-design-system/carbon/issues/20452
|
|
@@ -254,6 +254,7 @@ const Pagination = /*#__PURE__*/React.forwardRef(({
|
|
|
254
254
|
hideLabel: true,
|
|
255
255
|
onChange: handlePageInputChange,
|
|
256
256
|
value: page,
|
|
257
|
+
key: page,
|
|
257
258
|
disabled: pageInputDisabled || disabled
|
|
258
259
|
}, selectItems), /*#__PURE__*/React.createElement("span", {
|
|
259
260
|
className: `${prefix}--pagination__text`
|
|
@@ -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;
|
|
@@ -21,12 +21,13 @@ var useId = require('../../internal/useId.js');
|
|
|
21
21
|
var mergeRefs = require('../../tools/mergeRefs.js');
|
|
22
22
|
var index = require('../AILabel/index.js');
|
|
23
23
|
var utils = require('../../internal/utils.js');
|
|
24
|
+
var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
|
|
24
25
|
|
|
25
26
|
const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
26
27
|
const {
|
|
27
28
|
className,
|
|
28
29
|
decorator,
|
|
29
|
-
disabled,
|
|
30
|
+
disabled = false,
|
|
30
31
|
hideLabel,
|
|
31
32
|
id,
|
|
32
33
|
labelPosition = 'right',
|
|
@@ -36,11 +37,25 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
36
37
|
value = '',
|
|
37
38
|
slug,
|
|
38
39
|
required,
|
|
40
|
+
invalid = false,
|
|
41
|
+
invalidText,
|
|
42
|
+
warn = false,
|
|
43
|
+
warnText,
|
|
44
|
+
readOnly,
|
|
39
45
|
...rest
|
|
40
46
|
} = props;
|
|
41
47
|
const prefix = usePrefix.usePrefix();
|
|
42
48
|
const uid = useId.useId('radio-button');
|
|
43
49
|
const uniqueId = id || uid;
|
|
50
|
+
const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
|
|
51
|
+
id: uniqueId,
|
|
52
|
+
readOnly,
|
|
53
|
+
disabled,
|
|
54
|
+
invalid,
|
|
55
|
+
invalidText,
|
|
56
|
+
warn,
|
|
57
|
+
warnText
|
|
58
|
+
});
|
|
44
59
|
function handleOnChange(event) {
|
|
45
60
|
onChange(value, name, event);
|
|
46
61
|
}
|
|
@@ -50,7 +65,9 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
50
65
|
const wrapperClasses = cx(className, `${prefix}--radio-button-wrapper`, {
|
|
51
66
|
[`${prefix}--radio-button-wrapper--label-${labelPosition}`]: labelPosition !== 'right',
|
|
52
67
|
[`${prefix}--radio-button-wrapper--slug`]: slug,
|
|
53
|
-
[`${prefix}--radio-button-wrapper--decorator`]: decorator
|
|
68
|
+
[`${prefix}--radio-button-wrapper--decorator`]: decorator,
|
|
69
|
+
[`${prefix}--radio-button-wrapper--invalid`]: normalizedProps.invalid,
|
|
70
|
+
[`${prefix}--radio-button-wrapper--warning`]: normalizedProps.warn
|
|
54
71
|
});
|
|
55
72
|
const inputRef = React.useRef(null);
|
|
56
73
|
const candidate = slug ?? decorator;
|
|
@@ -66,10 +83,11 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
66
83
|
onChange: handleOnChange,
|
|
67
84
|
id: uniqueId,
|
|
68
85
|
ref: mergeRefs.mergeRefs(inputRef, ref),
|
|
69
|
-
disabled: disabled,
|
|
86
|
+
disabled: normalizedProps.disabled,
|
|
70
87
|
value: value,
|
|
71
88
|
name: name,
|
|
72
|
-
required: required
|
|
89
|
+
required: required,
|
|
90
|
+
readOnly: readOnly
|
|
73
91
|
})), /*#__PURE__*/React.createElement("label", {
|
|
74
92
|
htmlFor: uniqueId,
|
|
75
93
|
className: `${prefix}--radio-button__label`
|
|
@@ -79,7 +97,7 @@ const RadioButton = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
79
97
|
className: innerLabelClasses
|
|
80
98
|
}, labelText, slug ? normalizedDecorator : decorator ? /*#__PURE__*/React.createElement("div", {
|
|
81
99
|
className: `${prefix}--radio-button-wrapper-inner--decorator`
|
|
82
|
-
}, normalizedDecorator) : '')));
|
|
100
|
+
}, normalizedDecorator) : '')), normalizedProps.validation);
|
|
83
101
|
});
|
|
84
102
|
RadioButton.displayName = 'RadioButton';
|
|
85
103
|
RadioButton.propTypes = {
|
|
@@ -138,6 +156,26 @@ RadioButton.propTypes = {
|
|
|
138
156
|
* `true` to specify if the control is required.
|
|
139
157
|
*/
|
|
140
158
|
required: PropTypes.bool,
|
|
159
|
+
/**
|
|
160
|
+
* Specify whether the control is currently invalid
|
|
161
|
+
*/
|
|
162
|
+
invalid: PropTypes.bool,
|
|
163
|
+
/**
|
|
164
|
+
* Provide the text that is displayed when the control is in an invalid state
|
|
165
|
+
*/
|
|
166
|
+
invalidText: PropTypes.node,
|
|
167
|
+
/**
|
|
168
|
+
* Specify whether the control is currently in warning state
|
|
169
|
+
*/
|
|
170
|
+
warn: PropTypes.bool,
|
|
171
|
+
/**
|
|
172
|
+
* Provide the text that is displayed when the control is in warning state
|
|
173
|
+
*/
|
|
174
|
+
warnText: PropTypes.node,
|
|
175
|
+
/**
|
|
176
|
+
* Specify whether the RadioButton should be read-only
|
|
177
|
+
*/
|
|
178
|
+
readOnly: PropTypes.bool,
|
|
141
179
|
/**
|
|
142
180
|
* **Experimental**: Provide a `Slug` component to be rendered inside the `RadioButton` component
|
|
143
181
|
*/
|
|
@@ -86,14 +86,14 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
|
-
const showWarning = !readOnly && !invalid && warn;
|
|
89
|
+
const showWarning = !readOnly && !disabled && !invalid && warn;
|
|
90
90
|
const showHelper = !invalid && !disabled && !warn;
|
|
91
91
|
const wrapperClasses = cx(`${prefix}--form-item`, className);
|
|
92
92
|
const fieldsetClasses = cx(`${prefix}--radio-button-group`, {
|
|
93
93
|
[`${prefix}--radio-button-group--${orientation}`]: orientation === 'vertical',
|
|
94
94
|
[`${prefix}--radio-button-group--label-${labelPosition}`]: labelPosition,
|
|
95
95
|
[`${prefix}--radio-button-group--readonly`]: readOnly,
|
|
96
|
-
[`${prefix}--radio-button-group--invalid`]: !readOnly && invalid,
|
|
96
|
+
[`${prefix}--radio-button-group--invalid`]: !readOnly && !disabled && invalid,
|
|
97
97
|
[`${prefix}--radio-button-group--warning`]: showWarning,
|
|
98
98
|
[`${prefix}--radio-button-group--slug`]: slug,
|
|
99
99
|
[`${prefix}--radio-button-group--decorator`]: decorator
|
|
@@ -129,7 +129,7 @@ const RadioButtonGroup = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
129
129
|
className: `${prefix}--radio-button-group-inner--decorator`
|
|
130
130
|
}, normalizedDecorator) : ''), getRadioButtons()), /*#__PURE__*/React.createElement("div", {
|
|
131
131
|
className: `${prefix}--radio-button__validation-msg`
|
|
132
|
-
}, !readOnly && invalid && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
132
|
+
}, !readOnly && !disabled && invalid && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
|
|
133
133
|
className: `${prefix}--radio-button__invalid-icon`
|
|
134
134
|
}), /*#__PURE__*/React.createElement("div", {
|
|
135
135
|
className: `${prefix}--form-requirement`
|
|
@@ -24,6 +24,8 @@ var deprecate = require('../../prop-types/deprecate.js');
|
|
|
24
24
|
require('../FluidForm/FluidForm.js');
|
|
25
25
|
var FormContext = require('../FluidForm/FormContext.js');
|
|
26
26
|
var noopFn = require('../../internal/noopFn.js');
|
|
27
|
+
require('../Tooltip/DefinitionTooltip.js');
|
|
28
|
+
var Tooltip = require('../Tooltip/Tooltip.js');
|
|
27
29
|
|
|
28
30
|
var _Close;
|
|
29
31
|
const Search = /*#__PURE__*/React.forwardRef(({
|
|
@@ -133,11 +135,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
133
135
|
}
|
|
134
136
|
}
|
|
135
137
|
}
|
|
136
|
-
|
|
137
|
-
role: "search",
|
|
138
|
-
"aria-label": placeholder,
|
|
139
|
-
className: searchClasses
|
|
140
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
138
|
+
const magnifierButton = /*#__PURE__*/React.createElement("div", {
|
|
141
139
|
"aria-labelledby": onExpand ? searchId : undefined,
|
|
142
140
|
role: onExpand ? 'button' : undefined,
|
|
143
141
|
className: `${prefix}--search-magnifier`,
|
|
@@ -149,7 +147,19 @@ const Search = /*#__PURE__*/React.forwardRef(({
|
|
|
149
147
|
"aria-controls": onExpand ? uniqueId : undefined
|
|
150
148
|
}, /*#__PURE__*/React.createElement(CustomSearchIcon, {
|
|
151
149
|
icon: renderIcon
|
|
152
|
-
}))
|
|
150
|
+
}));
|
|
151
|
+
|
|
152
|
+
// Wrap magnifierButton in a tooltip if it's expandable
|
|
153
|
+
const magnifierWithTooltip = onExpand && !isExpanded ? /*#__PURE__*/React.createElement(Tooltip.Tooltip, {
|
|
154
|
+
className: `${prefix}--search-tooltip ${prefix}--search-magnifier-tooltip`,
|
|
155
|
+
align: "top",
|
|
156
|
+
label: "Search"
|
|
157
|
+
}, magnifierButton) : magnifierButton;
|
|
158
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
159
|
+
role: "search",
|
|
160
|
+
"aria-label": placeholder,
|
|
161
|
+
className: searchClasses
|
|
162
|
+
}, magnifierWithTooltip, /*#__PURE__*/React.createElement("label", {
|
|
153
163
|
id: searchId,
|
|
154
164
|
htmlFor: uniqueId,
|
|
155
165
|
className: `${prefix}--label`
|
|
@@ -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;
|