@carbon/react 1.95.0-rc.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.
@@ -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
- inputValue
284
- } = state;
285
- changes.selectedItem = inputValue;
286
- if (onChange) {
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: inputValue,
291
+ selectedItem: nextSelectedItem,
289
292
  inputValue
290
293
  });
291
294
  }
292
- return changes;
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.
@@ -637,7 +643,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
637
643
  title: textInput?.current?.value
638
644
  }, getInputProps({
639
645
  'aria-label': titleText ? undefined : deprecatedAriaLabel || ariaLabel,
640
- 'aria-controls': isOpen ? undefined : menuProps.id,
646
+ 'aria-controls': menuProps.id,
641
647
  placeholder,
642
648
  value: inputValue,
643
649
  ...inputProps,
@@ -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 === item,
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 === item && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
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 useId = require('../../internal/useId.js');
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 showWarning = !invalid && warn;
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`]: showWarning,
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
- invalidText: invalidText,
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
- }), showWarning && /*#__PURE__*/React.createElement(iconsReact.WarningAltFilled, {
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 && !invalid && !warn && helper);
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().
@@ -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
@@ -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`
@@ -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 PropTypes from 'prop-types';
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 SliderSkeleton: {
32
- ({ ariaLabel, unstable_ariaLabelHandleUpper: ariaLabelHandleUpper, hideLabel, className, twoHandles, ...rest }: SliderSkeletonProps): import("react/jsx-runtime").JSX.Element;
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;
@@ -103,5 +103,4 @@ SliderSkeleton.propTypes = {
103
103
  twoHandles: PropTypes.bool
104
104
  };
105
105
 
106
- exports.SliderSkeleton = SliderSkeleton;
107
106
  exports.default = SliderSkeleton;
@@ -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
- export declare const Slider: {
166
- (props: SliderProps): import("react/jsx-runtime").JSX.Element;
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;
@@ -7,6 +7,8 @@
7
7
 
8
8
  'use strict';
9
9
 
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
10
12
  var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
11
13
  var React = require('react');
12
14
  var PropTypes = require('prop-types');
@@ -1356,4 +1358,4 @@ Slider.propTypes = {
1356
1358
  warnText: PropTypes.node
1357
1359
  };
1358
1360
 
1359
- exports.Slider = Slider;
1361
+ exports.default = Slider;
@@ -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
- import { Slider } from './Slider';
7
+ export { default as Slider } from './Slider';
8
8
  export { default as SliderSkeleton } from './Slider.Skeleton';
9
- export default Slider;
10
- export { Slider };
@@ -15,7 +15,7 @@ var PropTypes = require('prop-types');
15
15
  var React = require('react');
16
16
  var usePrefix = require('../../internal/usePrefix.js');
17
17
  var deprecate = require('../../prop-types/deprecate.js');
18
- var iconsReact = require('@carbon/icons-react');
18
+ var useNormalizedInputProps = require('../../internal/useNormalizedInputProps.js');
19
19
 
20
20
  const frFn = React.forwardRef;
21
21
  const TimePicker = frFn((props, ref) => {
@@ -74,15 +74,24 @@ const TimePicker = frFn((props, ref) => {
74
74
  onBlur(evt);
75
75
  }
76
76
  }
77
+ const normalizedProps = useNormalizedInputProps.useNormalizedInputProps({
78
+ id,
79
+ readOnly,
80
+ disabled,
81
+ invalid,
82
+ invalidText,
83
+ warn: warning,
84
+ warnText: warningText
85
+ });
77
86
  const timePickerInputClasses = cx(`${prefix}--time-picker__input-field`, `${prefix}--text-input`, [inputClassName], {
78
87
  [`${prefix}--text-input--light`]: light,
79
- [`${prefix}--time-picker__input-field-error`]: invalid || warning
88
+ [`${prefix}--time-picker__input-field-error`]: normalizedProps.invalid || normalizedProps.warn
80
89
  });
81
90
  const timePickerClasses = cx({
82
91
  [`${prefix}--time-picker`]: true,
83
92
  [`${prefix}--time-picker--light`]: light,
84
- [`${prefix}--time-picker--invalid`]: invalid,
85
- [`${prefix}--time-picker--warning`]: warning,
93
+ [`${prefix}--time-picker--invalid`]: normalizedProps.invalid,
94
+ [`${prefix}--time-picker--warning`]: normalizedProps.warn,
86
95
  [`${prefix}--time-picker--readonly`]: readOnly,
87
96
  [`${prefix}--time-picker--${size}`]: size,
88
97
  ...(pickerClassName && {
@@ -140,8 +149,8 @@ const TimePicker = frFn((props, ref) => {
140
149
  className: `${prefix}--time-picker__input`
141
150
  }, /*#__PURE__*/React.createElement("input", _rollupPluginBabelHelpers.extends({
142
151
  className: timePickerInputClasses,
143
- "data-invalid": invalid ? invalid : undefined,
144
- disabled: disabled,
152
+ "data-invalid": normalizedProps.invalid ? true : undefined,
153
+ disabled: normalizedProps.disabled,
145
154
  id: id,
146
155
  maxLength: maxLength,
147
156
  onClick: handleOnClick,
@@ -152,17 +161,12 @@ const TimePicker = frFn((props, ref) => {
152
161
  ref: ref,
153
162
  type: type,
154
163
  value: value
155
- }, rest, readOnlyProps)), (invalid || warning) && /*#__PURE__*/React.createElement("div", {
164
+ }, rest, readOnlyProps)), (normalizedProps.invalid || normalizedProps.warn) && normalizedProps.icon && /*#__PURE__*/React.createElement("div", {
156
165
  className: `${prefix}--time-picker__error__icon`
157
- }, invalid ? /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
158
- className: `${prefix}--checkbox__invalid-icon`,
159
- size: 16
160
- }) : /*#__PURE__*/React.createElement(iconsReact.WarningAltFilled, {
161
- className: `${prefix}--text-input__invalid-icon--warning`,
166
+ }, /*#__PURE__*/React.createElement(normalizedProps.icon, {
167
+ className: normalizedProps.invalid ? `${prefix}--checkbox__invalid-icon` : `${prefix}--text-input__invalid-icon--warning`,
162
168
  size: 16
163
- }))), getInternalPickerSelects()), (invalid || warning) && /*#__PURE__*/React.createElement("div", {
164
- className: `${prefix}--form-requirement`
165
- }, invalid ? invalidText : warningText));
169
+ }))), getInternalPickerSelects()), normalizedProps.validation);
166
170
  });
167
171
  TimePicker.propTypes = {
168
172
  /**
package/lib/index.js CHANGED
@@ -396,7 +396,7 @@ exports.SelectItemGroup = SelectItemGroup.default;
396
396
  exports.SkeletonIcon = SkeletonIcon.default;
397
397
  exports.SkeletonPlaceholder = SkeletonPlaceholder.default;
398
398
  exports.SkeletonText = SkeletonText.default;
399
- exports.Slider = Slider.Slider;
399
+ exports.Slider = Slider.default;
400
400
  exports.SliderSkeleton = Slider_Skeleton.default;
401
401
  exports.HStack = HStack.HStack;
402
402
  exports.Stack = Stack.Stack;