@carbon/react 1.42.1 → 1.43.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.
Files changed (59) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +2542 -1275
  2. package/es/components/Breadcrumb/BreadcrumbItem.js +1 -2
  3. package/es/components/ComboBox/ComboBox.d.ts +5 -0
  4. package/es/components/ComboBox/ComboBox.js +16 -2
  5. package/es/components/ComposedModal/ModalFooter.d.ts +18 -0
  6. package/es/components/ComposedModal/ModalFooter.js +48 -16
  7. package/es/components/DatePickerInput/DatePickerInput.d.ts +4 -0
  8. package/es/components/DatePickerInput/DatePickerInput.js +16 -2
  9. package/es/components/Dropdown/Dropdown.d.ts +5 -0
  10. package/es/components/Dropdown/Dropdown.js +16 -2
  11. package/es/components/InlineLoading/index.js +9 -0
  12. package/es/components/Modal/Modal.d.ts +17 -0
  13. package/es/components/Modal/Modal.js +38 -3
  14. package/es/components/MultiSelect/FilterableMultiSelect.js +17 -3
  15. package/es/components/MultiSelect/MultiSelect.d.ts +5 -0
  16. package/es/components/MultiSelect/MultiSelect.js +17 -3
  17. package/es/components/NumberInput/NumberInput.d.ts +5 -0
  18. package/es/components/NumberInput/NumberInput.js +29 -4
  19. package/es/components/Select/Select.d.ts +6 -1
  20. package/es/components/Select/Select.js +16 -2
  21. package/es/components/Slug/index.js +187 -0
  22. package/es/components/TextArea/TextArea.d.ts +4 -0
  23. package/es/components/TextArea/TextArea.js +47 -31
  24. package/es/components/TextInput/TextInput.d.ts +5 -0
  25. package/es/components/TextInput/TextInput.js +16 -2
  26. package/es/components/UIShell/SideNavHeader.d.ts +29 -0
  27. package/es/components/UIShell/SideNavHeader.js +3 -3
  28. package/es/index.d.ts +1 -0
  29. package/es/index.js +1 -0
  30. package/lib/components/Breadcrumb/BreadcrumbItem.js +1 -2
  31. package/lib/components/ComboBox/ComboBox.d.ts +5 -0
  32. package/lib/components/ComboBox/ComboBox.js +16 -2
  33. package/lib/components/ComposedModal/ModalFooter.d.ts +18 -0
  34. package/lib/components/ComposedModal/ModalFooter.js +48 -16
  35. package/lib/components/DatePickerInput/DatePickerInput.d.ts +4 -0
  36. package/lib/components/DatePickerInput/DatePickerInput.js +16 -2
  37. package/lib/components/Dropdown/Dropdown.d.ts +5 -0
  38. package/lib/components/Dropdown/Dropdown.js +16 -2
  39. package/lib/components/InlineLoading/index.js +17 -0
  40. package/lib/components/Modal/Modal.d.ts +17 -0
  41. package/lib/components/Modal/Modal.js +38 -3
  42. package/lib/components/MultiSelect/FilterableMultiSelect.js +17 -3
  43. package/lib/components/MultiSelect/MultiSelect.d.ts +5 -0
  44. package/lib/components/MultiSelect/MultiSelect.js +17 -3
  45. package/lib/components/NumberInput/NumberInput.d.ts +5 -0
  46. package/lib/components/NumberInput/NumberInput.js +28 -3
  47. package/lib/components/Select/Select.d.ts +6 -1
  48. package/lib/components/Select/Select.js +16 -2
  49. package/lib/components/Slug/index.js +199 -0
  50. package/lib/components/TextArea/TextArea.d.ts +4 -0
  51. package/lib/components/TextArea/TextArea.js +47 -31
  52. package/lib/components/TextInput/TextInput.d.ts +5 -0
  53. package/lib/components/TextInput/TextInput.js +16 -2
  54. package/lib/components/UIShell/SideNavHeader.d.ts +29 -0
  55. package/lib/components/UIShell/SideNavHeader.js +3 -3
  56. package/lib/index.d.ts +1 -0
  57. package/lib/index.js +45 -41
  58. package/package.json +6 -6
  59. package/scss/utilities/_ai-gradient.scss +9 -0
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import { Subtract, Add } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
- import React__default, { useContext, useState, useRef } from 'react';
12
+ import React__default, { useContext, useState, useRef, useEffect } from 'react';
13
13
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
14
14
  import { useNormalizedInputProps } from '../../internal/useNormalizedInputProps.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -34,7 +34,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
34
34
  className: customClassName,
35
35
  disabled = false,
36
36
  disableWheel: disableWheelProp = false,
37
- defaultValue,
37
+ defaultValue = 0,
38
38
  helperText = '',
39
39
  hideLabel = false,
40
40
  hideSteppers,
@@ -51,6 +51,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
51
51
  onKeyUp,
52
52
  readOnly,
53
53
  size = 'md',
54
+ slug,
54
55
  step = 1,
55
56
  translateWithId: t = id => defaultTranslations[id],
56
57
  warn = false,
@@ -102,7 +103,8 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
102
103
  });
103
104
  const [incrementNumLabel, decrementNumLabel] = [t('increment.number'), t('decrement.number')];
104
105
  const wrapperClasses = cx(`${prefix}--number__input-wrapper`, {
105
- [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn
106
+ [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
107
+ [`${prefix}--number__input-wrapper--slug`]: slug
106
108
  });
107
109
  const iconClasses = cx({
108
110
  [`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
@@ -167,6 +169,25 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
167
169
  }
168
170
  }
169
171
  }
172
+
173
+ // Slug is always size `mini`
174
+ let normalizedSlug;
175
+ if (slug) {
176
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
177
+ size: 'mini'
178
+ });
179
+ }
180
+
181
+ // Need to update the internal value when the revert button is clicked
182
+ let isRevertActive;
183
+ if (slug) {
184
+ isRevertActive = normalizedSlug.props.revertActive;
185
+ }
186
+ useEffect(() => {
187
+ if (!isRevertActive && slug && defaultValue) {
188
+ setValue(defaultValue);
189
+ }
190
+ }, [defaultValue, isRevertActive, slug]);
170
191
  return /*#__PURE__*/React__default.createElement("div", {
171
192
  className: outerElementClasses,
172
193
  onFocus: isFluid ? handleFocus : undefined,
@@ -214,7 +235,7 @@ const NumberInput = /*#__PURE__*/React__default.forwardRef(function NumberInput(
214
235
  step: step,
215
236
  type: "number",
216
237
  value: value
217
- })), Icon ? /*#__PURE__*/React__default.createElement(Icon, {
238
+ })), normalizedSlug, Icon ? /*#__PURE__*/React__default.createElement(Icon, {
218
239
  className: iconClasses
219
240
  }) : null, !hideSteppers && /*#__PURE__*/React__default.createElement("div", {
220
241
  className: `${prefix}--number__controls`
@@ -338,6 +359,10 @@ NumberInput.propTypes = {
338
359
  * Specify the size of the Number Input.
339
360
  */
340
361
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
362
+ /**
363
+ * Provide a `Slug` component to be rendered inside the `NumberInput` component
364
+ */
365
+ slug: PropTypes.node,
341
366
  /**
342
367
  * Specify how much the values should increase/decrease upon clicking on up/down button
343
368
  */
@@ -4,6 +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 { ReactNodeLike } from 'prop-types';
7
8
  import React, { ChangeEventHandler, ComponentPropsWithRef, ReactNode } from 'react';
8
9
  type ExcludedAttributes = 'size';
9
10
  interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttributes> {
@@ -76,6 +77,10 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
76
77
  * Specify the size of the Select Input.
77
78
  */
78
79
  size?: 'sm' | 'md' | 'lg';
80
+ /**
81
+ * Provide a `Slug` component to be rendered inside the `Dropdown` component
82
+ */
83
+ slug?: ReactNodeLike;
79
84
  /**
80
85
  * Specify whether the control is currently in warning state
81
86
  */
@@ -85,5 +90,5 @@ interface SelectProps extends Omit<ComponentPropsWithRef<'select'>, ExcludedAttr
85
90
  */
86
91
  warnText?: ReactNode;
87
92
  }
88
- declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "disabled" | "form" | "slot" | "style" | "title" | "className" | "size" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "onKeyDown" | "tabIndex" | "color" | "lang" | "name" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "inline" | "readOnly" | "required" | "light" | "invalid" | "labelText" | "helperText" | "invalidText" | "hideLabel" | "warn" | "warnText" | "noLabel"> & React.RefAttributes<HTMLSelectElement>>;
93
+ declare const Select: React.ForwardRefExoticComponent<Pick<SelectProps, "value" | "children" | "disabled" | "form" | "slot" | "style" | "title" | "className" | "size" | "dir" | "defaultChecked" | "defaultValue" | "suppressContentEditableWarning" | "suppressHydrationWarning" | "accessKey" | "autoFocus" | "autoComplete" | "multiple" | "key" | "id" | "aria-controls" | "aria-expanded" | "onClick" | "onAnimationEnd" | "onKeyDown" | "tabIndex" | "color" | "lang" | "name" | "role" | "aria-activedescendant" | "aria-atomic" | "aria-autocomplete" | "aria-busy" | "aria-checked" | "aria-colcount" | "aria-colindex" | "aria-colspan" | "aria-current" | "aria-describedby" | "aria-details" | "aria-disabled" | "aria-dropeffect" | "aria-errormessage" | "aria-flowto" | "aria-grabbed" | "aria-haspopup" | "aria-hidden" | "aria-invalid" | "aria-keyshortcuts" | "aria-label" | "aria-labelledby" | "aria-level" | "aria-live" | "aria-modal" | "aria-multiline" | "aria-multiselectable" | "aria-orientation" | "aria-owns" | "aria-placeholder" | "aria-posinset" | "aria-pressed" | "aria-readonly" | "aria-relevant" | "aria-required" | "aria-roledescription" | "aria-rowcount" | "aria-rowindex" | "aria-rowspan" | "aria-selected" | "aria-setsize" | "aria-sort" | "aria-valuemax" | "aria-valuemin" | "aria-valuenow" | "aria-valuetext" | "dangerouslySetInnerHTML" | "onCopy" | "onCopyCapture" | "onCut" | "onCutCapture" | "onPaste" | "onPasteCapture" | "onCompositionEnd" | "onCompositionEndCapture" | "onCompositionStart" | "onCompositionStartCapture" | "onCompositionUpdate" | "onCompositionUpdateCapture" | "onFocus" | "onFocusCapture" | "onBlur" | "onBlurCapture" | "onChange" | "onChangeCapture" | "onBeforeInput" | "onBeforeInputCapture" | "onInput" | "onInputCapture" | "onReset" | "onResetCapture" | "onSubmit" | "onSubmitCapture" | "onInvalid" | "onInvalidCapture" | "onLoad" | "onLoadCapture" | "onError" | "onErrorCapture" | "onKeyDownCapture" | "onKeyPress" | "onKeyPressCapture" | "onKeyUp" | "onKeyUpCapture" | "onAbort" | "onAbortCapture" | "onCanPlay" | "onCanPlayCapture" | "onCanPlayThrough" | "onCanPlayThroughCapture" | "onDurationChange" | "onDurationChangeCapture" | "onEmptied" | "onEmptiedCapture" | "onEncrypted" | "onEncryptedCapture" | "onEnded" | "onEndedCapture" | "onLoadedData" | "onLoadedDataCapture" | "onLoadedMetadata" | "onLoadedMetadataCapture" | "onLoadStart" | "onLoadStartCapture" | "onPause" | "onPauseCapture" | "onPlay" | "onPlayCapture" | "onPlaying" | "onPlayingCapture" | "onProgress" | "onProgressCapture" | "onRateChange" | "onRateChangeCapture" | "onSeeked" | "onSeekedCapture" | "onSeeking" | "onSeekingCapture" | "onStalled" | "onStalledCapture" | "onSuspend" | "onSuspendCapture" | "onTimeUpdate" | "onTimeUpdateCapture" | "onVolumeChange" | "onVolumeChangeCapture" | "onWaiting" | "onWaitingCapture" | "onAuxClick" | "onAuxClickCapture" | "onClickCapture" | "onContextMenu" | "onContextMenuCapture" | "onDoubleClick" | "onDoubleClickCapture" | "onDrag" | "onDragCapture" | "onDragEnd" | "onDragEndCapture" | "onDragEnter" | "onDragEnterCapture" | "onDragExit" | "onDragExitCapture" | "onDragLeave" | "onDragLeaveCapture" | "onDragOver" | "onDragOverCapture" | "onDragStart" | "onDragStartCapture" | "onDrop" | "onDropCapture" | "onMouseDown" | "onMouseDownCapture" | "onMouseEnter" | "onMouseLeave" | "onMouseMove" | "onMouseMoveCapture" | "onMouseOut" | "onMouseOutCapture" | "onMouseOver" | "onMouseOverCapture" | "onMouseUp" | "onMouseUpCapture" | "onSelect" | "onSelectCapture" | "onTouchCancel" | "onTouchCancelCapture" | "onTouchEnd" | "onTouchEndCapture" | "onTouchMove" | "onTouchMoveCapture" | "onTouchStart" | "onTouchStartCapture" | "onPointerDown" | "onPointerDownCapture" | "onPointerMove" | "onPointerMoveCapture" | "onPointerUp" | "onPointerUpCapture" | "onPointerCancel" | "onPointerCancelCapture" | "onPointerEnter" | "onPointerEnterCapture" | "onPointerLeave" | "onPointerLeaveCapture" | "onPointerOver" | "onPointerOverCapture" | "onPointerOut" | "onPointerOutCapture" | "onGotPointerCapture" | "onGotPointerCaptureCapture" | "onLostPointerCapture" | "onLostPointerCaptureCapture" | "onScroll" | "onScrollCapture" | "onWheel" | "onWheelCapture" | "onAnimationStart" | "onAnimationStartCapture" | "onAnimationEndCapture" | "onAnimationIteration" | "onAnimationIterationCapture" | "onTransitionEnd" | "onTransitionEndCapture" | "contentEditable" | "contextMenu" | "draggable" | "hidden" | "placeholder" | "spellCheck" | "translate" | "radioGroup" | "about" | "datatype" | "inlist" | "prefix" | "property" | "resource" | "typeof" | "vocab" | "autoCapitalize" | "autoCorrect" | "autoSave" | "itemProp" | "itemScope" | "itemType" | "itemID" | "itemRef" | "results" | "security" | "unselectable" | "inputMode" | "is" | "inline" | "readOnly" | "required" | "light" | "invalid" | "labelText" | "helperText" | "invalidText" | "hideLabel" | "warn" | "warnText" | "slug" | "noLabel"> & React.RefAttributes<HTMLSelectElement>>;
89
94
  export default Select;
@@ -41,6 +41,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
41
41
  warn = false,
42
42
  warnText,
43
43
  onChange,
44
+ slug,
44
45
  ...other
45
46
  } = _ref;
46
47
  const prefix = usePrefix();
@@ -61,7 +62,8 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
61
62
  [`${prefix}--select--readonly`]: readOnly,
62
63
  [`${prefix}--select--warning`]: warn,
63
64
  [`${prefix}--select--fluid--invalid`]: isFluid && invalid,
64
- [`${prefix}--select--fluid--focus`]: isFluid && isFocused
65
+ [`${prefix}--select--fluid--focus`]: isFluid && isFocused,
66
+ [`${prefix}--select--slug`]: slug
65
67
  });
66
68
  const labelClasses = cx(`${prefix}--label`, {
67
69
  [`${prefix}--visually-hidden`]: hideLabel,
@@ -123,6 +125,14 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
123
125
  }
124
126
  }
125
127
  };
128
+
129
+ // Slug is always size `mini`
130
+ let normalizedSlug;
131
+ if (slug) {
132
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
133
+ size: 'mini'
134
+ });
135
+ }
126
136
  const input = (() => {
127
137
  return /*#__PURE__*/React__default.createElement(React__default.Fragment, null, /*#__PURE__*/React__default.createElement("select", _extends({}, other, ariaProps, {
128
138
  id: id,
@@ -160,7 +170,7 @@ const Select = /*#__PURE__*/React__default.forwardRef(function Select(_ref, ref)
160
170
  "data-invalid": invalid || null,
161
171
  onFocus: handleFocus,
162
172
  onBlur: handleFocus
163
- }, input, isFluid && /*#__PURE__*/React__default.createElement("hr", {
173
+ }, input, normalizedSlug, isFluid && /*#__PURE__*/React__default.createElement("hr", {
164
174
  className: `${prefix}--select__divider`
165
175
  }), isFluid && error ? error : null), !inline && !isFluid && error ? error : helper));
166
176
  });
@@ -234,6 +244,10 @@ Select.propTypes = {
234
244
  * Specify the size of the Select Input.
235
245
  */
236
246
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
247
+ /**
248
+ * Provide a `Slug` component to be rendered inside the `Select` component
249
+ */
250
+ slug: PropTypes.node,
237
251
  /**
238
252
  * Specify whether the control is currently in warning state
239
253
  */
@@ -0,0 +1,187 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
9
+ import cx from 'classnames';
10
+ import PropTypes from 'prop-types';
11
+ import React__default from 'react';
12
+ import { usePrefix } from '../../internal/usePrefix.js';
13
+ import { ToggletipContent, ToggletipActions, Toggletip, ToggletipButton } from '../Toggletip/index.js';
14
+ import { IconButton } from '../IconButton/index.js';
15
+ import { Undo } from '@carbon/icons-react';
16
+ import { useId } from '../../internal/useId.js';
17
+
18
+ var _Undo;
19
+ const SlugContent = /*#__PURE__*/React__default.forwardRef(function SlugContent(_ref, ref) {
20
+ let {
21
+ children,
22
+ className
23
+ } = _ref;
24
+ const prefix = usePrefix();
25
+ const slugContentClasses = cx(className, {
26
+ [`${prefix}--slug-content`]: true
27
+ });
28
+ return /*#__PURE__*/React__default.createElement(ToggletipContent, {
29
+ className: slugContentClasses,
30
+ ref: ref
31
+ }, children);
32
+ });
33
+ SlugContent.propTypes = {
34
+ /**
35
+ * Specify the content you want rendered inside the slug ToggleTip
36
+ */
37
+ children: PropTypes.node,
38
+ /**
39
+ * Specify an optional className to be added to the AI slug callout
40
+ */
41
+ className: PropTypes.string
42
+ };
43
+ const SlugActions = /*#__PURE__*/React__default.forwardRef(function SlugActions(_ref2, ref) {
44
+ let {
45
+ children,
46
+ className
47
+ } = _ref2;
48
+ const prefix = usePrefix();
49
+ const slugActionBarClasses = cx(className, {
50
+ [`${prefix}--slug-actions`]: true
51
+ });
52
+ return /*#__PURE__*/React__default.createElement(ToggletipActions, {
53
+ className: slugActionBarClasses,
54
+ ref: ref
55
+ }, children);
56
+ });
57
+ SlugActions.propTypes = {
58
+ /**
59
+ * Specify the content you want rendered inside the slug callout toolbar
60
+ */
61
+ children: PropTypes.node,
62
+ /**
63
+ * Specify an optional className to be added to the AI slug toolbar
64
+ */
65
+ className: PropTypes.string
66
+ };
67
+ const Slug = /*#__PURE__*/React__default.forwardRef(function Slug(_ref3, ref) {
68
+ let {
69
+ aiText = 'AI',
70
+ aiTextLabel,
71
+ align,
72
+ autoAlign = true,
73
+ children,
74
+ className,
75
+ dotType,
76
+ kind,
77
+ onRevertClick,
78
+ revertActive,
79
+ revertLabel = 'Revert to AI input',
80
+ slugLabel = 'Show information',
81
+ size = 'xs',
82
+ ...rest
83
+ } = _ref3;
84
+ const prefix = usePrefix();
85
+ const id = useId('slug');
86
+ const slugClasses = cx(className, {
87
+ [`${prefix}--slug`]: true,
88
+ [`${prefix}--slug--hollow`]: kind === 'hollow' || dotType === 'hollow',
89
+ // Need to come up with a better name; explainable?
90
+ // Need to be able to target the non-hollow variant another way
91
+ // other than using `:not` all over the styles
92
+ [`${prefix}--slug--enabled`]: kind !== 'hollow' && dotType !== 'hollow',
93
+ [`${prefix}--slug--revert`]: revertActive
94
+ });
95
+ const slugButtonClasses = cx({
96
+ [`${prefix}--slug__button`]: true,
97
+ [`${prefix}--slug__button--${size}`]: size,
98
+ [`${prefix}--slug__button--${kind}`]: kind,
99
+ [`${prefix}--slug__button--inline-with-content`]: kind === 'inline' && aiTextLabel
100
+ });
101
+ const handleOnRevertClick = evt => {
102
+ if (onRevertClick) {
103
+ onRevertClick(evt);
104
+ }
105
+ };
106
+ const ariaLabel = `${aiText} - ${slugLabel}`;
107
+ return /*#__PURE__*/React__default.createElement("div", {
108
+ className: slugClasses,
109
+ ref: ref,
110
+ id: id
111
+ }, revertActive ? /*#__PURE__*/React__default.createElement(IconButton, _extends({
112
+ onClick: handleOnRevertClick,
113
+ kind: "ghost",
114
+ size: "sm",
115
+ label: revertLabel
116
+ }, rest), _Undo || (_Undo = /*#__PURE__*/React__default.createElement(Undo, null))) : /*#__PURE__*/React__default.createElement(Toggletip, _extends({
117
+ align: align,
118
+ autoAlign: autoAlign
119
+ }, rest), /*#__PURE__*/React__default.createElement(ToggletipButton, {
120
+ className: slugButtonClasses,
121
+ label: ariaLabel
122
+ }, /*#__PURE__*/React__default.createElement("span", {
123
+ className: `${prefix}--slug__text`
124
+ }, aiText), aiTextLabel && /*#__PURE__*/React__default.createElement("span", {
125
+ className: `${prefix}--slug__additional-text`
126
+ }, aiTextLabel)), children));
127
+ });
128
+ Slug.propTypes = {
129
+ /**
130
+ * Specify the correct translation of the AI text
131
+ */
132
+ aiText: PropTypes.string,
133
+ /**
134
+ * Specify additional text to be rendered next to the AI label in the inline variant
135
+ */
136
+ aiTextLabel: PropTypes.string,
137
+ /**
138
+ * Specify how the popover should align with the button
139
+ */
140
+ align: PropTypes.oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
141
+ /**
142
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
143
+ */
144
+ autoAlign: PropTypes.bool,
145
+ /**
146
+ * Specify the content you want rendered inside the slug ToggleTip
147
+ */
148
+ children: PropTypes.node,
149
+ /**
150
+ * Specify an optional className to be added to the AI slug
151
+ */
152
+ className: PropTypes.string,
153
+ /**
154
+ * Specify the type of dot that should be rendered in front of the inline variant
155
+ */
156
+ dotType: PropTypes.oneOf(['default', 'hollow']),
157
+ /**
158
+ * Specify the type of Slug, from the following list of types:
159
+ */
160
+ kind: PropTypes.oneOf(['default', 'hollow', 'inline']),
161
+ /**
162
+ * Callback function that fires when the revert button is clicked
163
+ */
164
+ onRevertClick: PropTypes.func,
165
+ /**
166
+ * Specify whether the revert button should be visible
167
+ */
168
+ revertActive: PropTypes.bool,
169
+ /**
170
+ * Specify the text that should be shown when the revert button is hovered
171
+ */
172
+ revertLabel: PropTypes.string,
173
+ /**
174
+ * Specify the size of the button, from the following list of sizes:
175
+ */
176
+ size: PropTypes.oneOf(['mini', '2xs', 'xs', 'sm', 'md', 'lg', 'xl']),
177
+ /**
178
+ * Specify the content you want rendered inside the slug ToggleTip
179
+ */
180
+ slugContent: PropTypes.node,
181
+ /**
182
+ * Specify the text that will be provided to the aria-label of the `Slug` button
183
+ */
184
+ slugLabel: PropTypes.string
185
+ };
186
+
187
+ export { Slug, SlugActions, SlugContent };
@@ -85,6 +85,10 @@ export interface TextAreaProps extends React.InputHTMLAttributes<HTMLTextAreaEle
85
85
  * Specify the rows attribute for the `<textarea>`
86
86
  */
87
87
  rows?: number;
88
+ /**
89
+ * Provide a `Slug` component to be rendered inside the `TextArea` component
90
+ */
91
+ slug?: ReactNodeLike;
88
92
  /**
89
93
  * Provide the current value of the `<textarea>`
90
94
  */
@@ -42,6 +42,7 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
42
42
  warn = false,
43
43
  warnText = '',
44
44
  rows = 4,
45
+ slug,
45
46
  ...other
46
47
  } = props;
47
48
  const prefix = usePrefix();
@@ -56,9 +57,19 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
56
57
  const {
57
58
  current: textAreaInstanceId
58
59
  } = useRef(getInstanceId());
60
+ const textareaRef = useRef(null);
61
+ const ref = useMergedRefs([forwardRef, textareaRef]);
59
62
  useEffect(() => {
60
63
  setTextCount(defaultValue?.toString()?.length || value?.toString()?.length || 0);
61
64
  }, [value, defaultValue]);
65
+ useIsomorphicEffect(() => {
66
+ if (other.cols && textareaRef.current) {
67
+ textareaRef.current.style.width = '';
68
+ textareaRef.current.style.resize = 'none';
69
+ } else if (textareaRef.current) {
70
+ textareaRef.current.style.width = `100%`;
71
+ }
72
+ }, [other.cols]);
62
73
  const textareaProps = {
63
74
  id,
64
75
  onChange: evt => {
@@ -77,29 +88,36 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
77
88
  }
78
89
  }
79
90
  };
80
- if (enableCounter) {
81
- textareaProps.maxLength = maxCount;
82
- }
83
- const ariaAnnouncement = useAnnouncer(textCount, maxCount);
91
+ const formItemClasses = cx(`${prefix}--form-item`, className);
92
+ const textAreaWrapperClasses = cx(`${prefix}--text-area__wrapper`, {
93
+ [`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
94
+ [`${prefix}--text-area__wrapper--warn`]: warn,
95
+ [`${prefix}--text-area__wrapper--slug`]: slug
96
+ });
84
97
  const labelClasses = cx(`${prefix}--label`, {
85
98
  [`${prefix}--visually-hidden`]: hideLabel && !isFluid,
86
99
  [`${prefix}--label--disabled`]: disabled
87
100
  });
101
+ const textareaClasses = cx(`${prefix}--text-area`, {
102
+ [`${prefix}--text-area--light`]: light,
103
+ [`${prefix}--text-area--invalid`]: invalid,
104
+ [`${prefix}--text-area--warn`]: warn
105
+ });
106
+ const counterClasses = cx(`${prefix}--label`, {
107
+ [`${prefix}--label--disabled`]: disabled
108
+ });
109
+ const helperTextClasses = cx(`${prefix}--form__helper-text`, {
110
+ [`${prefix}--form__helper-text--disabled`]: disabled
111
+ });
88
112
  const label = labelText ? /*#__PURE__*/React__default.createElement(Text, {
89
113
  as: "label",
90
114
  htmlFor: id,
91
115
  className: labelClasses
92
116
  }, labelText) : null;
93
- const counterClasses = cx(`${prefix}--label`, {
94
- [`${prefix}--label--disabled`]: disabled
95
- });
96
117
  const counter = enableCounter && maxCount ? /*#__PURE__*/React__default.createElement(Text, {
97
118
  as: "div",
98
119
  className: counterClasses
99
120
  }, `${textCount}/${maxCount}`) : null;
100
- const helperTextClasses = cx(`${prefix}--form__helper-text`, {
101
- [`${prefix}--form__helper-text--disabled`]: disabled
102
- });
103
121
  const helperId = !helperText ? undefined : `text-area-helper-text-${textAreaInstanceId}`;
104
122
  const helper = helperText ? /*#__PURE__*/React__default.createElement(Text, {
105
123
  as: "div",
@@ -122,27 +140,16 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
122
140
  }, warnText, isFluid && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
123
141
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
124
142
  })) : null;
125
- const textareaClasses = cx(`${prefix}--text-area`, {
126
- [`${prefix}--text-area--light`]: light,
127
- [`${prefix}--text-area--invalid`]: invalid,
128
- [`${prefix}--text-area--warn`]: warn
129
- });
130
- const textareaRef = useRef(null);
131
- const ref = useMergedRefs([forwardRef, textareaRef]);
132
- useIsomorphicEffect(() => {
133
- if (other.cols && textareaRef.current) {
134
- textareaRef.current.style.width = '';
135
- textareaRef.current.style.resize = 'none';
136
- } else if (textareaRef.current) {
137
- textareaRef.current.style.width = `100%`;
138
- }
139
- }, [other.cols]);
140
143
  let ariaDescribedBy;
141
144
  if (invalid) {
142
145
  ariaDescribedBy = errorId;
143
146
  } else if (!invalid && !warn && !isFluid && helperText) {
144
147
  ariaDescribedBy = helperId;
145
148
  }
149
+ if (enableCounter) {
150
+ textareaProps.maxLength = maxCount;
151
+ }
152
+ const ariaAnnouncement = useAnnouncer(textCount, maxCount);
146
153
  const input = /*#__PURE__*/React__default.createElement("textarea", _extends({}, other, textareaProps, {
147
154
  placeholder: placeholder,
148
155
  className: textareaClasses,
@@ -153,21 +160,26 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
153
160
  readOnly: other.readOnly,
154
161
  ref: ref
155
162
  }));
163
+
164
+ // Slug is always size `mini`
165
+ let normalizedSlug;
166
+ if (slug) {
167
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
168
+ size: 'mini'
169
+ });
170
+ }
156
171
  return /*#__PURE__*/React__default.createElement("div", {
157
- className: cx(`${prefix}--form-item`, className)
172
+ className: formItemClasses
158
173
  }, /*#__PURE__*/React__default.createElement("div", {
159
174
  className: `${prefix}--text-area__label-wrapper`
160
175
  }, label, counter), /*#__PURE__*/React__default.createElement("div", {
161
- className: cx(`${prefix}--text-area__wrapper`, {
162
- [`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
163
- [`${prefix}--text-area__wrapper--warn`]: warn
164
- }),
176
+ className: textAreaWrapperClasses,
165
177
  "data-invalid": invalid || null
166
178
  }, invalid && !isFluid && /*#__PURE__*/React__default.createElement(WarningFilled, {
167
179
  className: `${prefix}--text-area__invalid-icon`
168
180
  }), warn && !invalid && !isFluid && /*#__PURE__*/React__default.createElement(WarningAltFilled, {
169
181
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
170
- }), input, /*#__PURE__*/React__default.createElement("span", {
182
+ }), input, normalizedSlug, /*#__PURE__*/React__default.createElement("span", {
171
183
  className: `${prefix}--text-area__counter-alert`,
172
184
  role: "alert"
173
185
  }, ariaAnnouncement), isFluid && /*#__PURE__*/React__default.createElement("hr", {
@@ -253,6 +265,10 @@ TextArea.propTypes = {
253
265
  * Specify the rows attribute for the `<textarea>`
254
266
  */
255
267
  rows: PropTypes.number,
268
+ /**
269
+ * Provide a `Slug` component to be rendered inside the `TextArea` component
270
+ */
271
+ slug: PropTypes.node,
256
272
  /**
257
273
  * Provide the current value of the `<textarea>`
258
274
  */
@@ -4,6 +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 { ReactNodeLike } from 'prop-types';
7
8
  import React, { ReactNode } from 'react';
8
9
  type ExcludedAttributes = 'defaultValue' | 'id' | 'size' | 'value';
9
10
  export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInputElement>, ExcludedAttributes> {
@@ -85,6 +86,10 @@ export interface TextInputProps extends Omit<React.InputHTMLAttributes<HTMLInput
85
86
  * Specify the size of the Text Input. Currently supports the following:
86
87
  */
87
88
  size?: 'sm' | 'md' | 'lg' | 'xl';
89
+ /**
90
+ * Provide a `Slug` component to be rendered inside the `TextInput` component
91
+ */
92
+ slug?: ReactNodeLike;
88
93
  /**
89
94
  * Specify the type of the `<input>`
90
95
  */
@@ -42,6 +42,7 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
42
42
  warnText,
43
43
  enableCounter = false,
44
44
  maxCount,
45
+ slug,
45
46
  ...rest
46
47
  } = _ref;
47
48
  const prefix = usePrefix();
@@ -113,7 +114,8 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
113
114
  [`${prefix}--text-input__field-outer-wrapper--inline`]: inline
114
115
  });
115
116
  const fieldWrapperClasses = cx(`${prefix}--text-input__field-wrapper`, {
116
- [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn
117
+ [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
118
+ [`${prefix}--text-input__field-wrapper--slug`]: slug
117
119
  });
118
120
  const iconClasses = cx({
119
121
  [`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
@@ -152,6 +154,14 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
152
154
  } = useContext(FormContext);
153
155
  const ariaAnnouncement = useAnnouncer(textCount, maxCount);
154
156
  const Icon = normalizedProps.icon;
157
+
158
+ // Slug is always size `mini`
159
+ let normalizedSlug;
160
+ if (slug) {
161
+ normalizedSlug = /*#__PURE__*/React__default.cloneElement(slug, {
162
+ size: 'mini'
163
+ });
164
+ }
155
165
  return /*#__PURE__*/React__default.createElement("div", {
156
166
  className: inputWrapperClasses
157
167
  }, !inline ? labelWrapper : /*#__PURE__*/React__default.createElement("div", {
@@ -163,7 +173,7 @@ const TextInput = /*#__PURE__*/React__default.forwardRef(function TextInput(_ref
163
173
  "data-invalid": normalizedProps.invalid || null
164
174
  }, Icon && /*#__PURE__*/React__default.createElement(Icon, {
165
175
  className: iconClasses
166
- }), input, /*#__PURE__*/React__default.createElement("span", {
176
+ }), input, normalizedSlug, /*#__PURE__*/React__default.createElement("span", {
167
177
  className: `${prefix}--text-input__counter-alert`,
168
178
  role: "alert"
169
179
  }, ariaAnnouncement), isFluid && /*#__PURE__*/React__default.createElement("hr", {
@@ -250,6 +260,10 @@ TextInput.propTypes = {
250
260
  * Specify the size of the Text Input. Currently supports the following:
251
261
  */
252
262
  size: PropTypes.oneOf(['sm', 'md', 'lg']),
263
+ /**
264
+ * Provide a `Slug` component to be rendered inside the `TextInput` component
265
+ */
266
+ slug: PropTypes.node,
253
267
  /**
254
268
  * Specify the type of the `<input>`
255
269
  */
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ interface SideNavHeaderProps {
9
+ /**
10
+ * The child nodes to be rendered
11
+ */
12
+ children?: React.ReactNode;
13
+ /**
14
+ * Provide an optional class to be applied to the containing node
15
+ */
16
+ className?: string;
17
+ /**
18
+ * Property to indicate if the side nav container is open (or not). Use to
19
+ * keep local state and styling in step with the SideNav expansion state.
20
+ */
21
+ isSideNavExpanded?: boolean;
22
+ /**
23
+ * Provide an icon to render in the header of the side navigation. Should be
24
+ * a React class.
25
+ */
26
+ renderIcon: React.ComponentType;
27
+ }
28
+ declare const SideNavHeader: React.FC<SideNavHeaderProps>;
29
+ export default SideNavHeader;
@@ -13,8 +13,8 @@ import { usePrefix } from '../../internal/usePrefix.js';
13
13
 
14
14
  const SideNavHeader = _ref => {
15
15
  let {
16
- className: customClassName,
17
16
  children,
17
+ className: customClassName,
18
18
  renderIcon: IconElement
19
19
  } = _ref;
20
20
  const prefix = usePrefix();
@@ -42,8 +42,8 @@ SideNavHeader.propTypes = {
42
42
  * Provide an icon to render in the header of the side navigation. Should be
43
43
  * a React class.
44
44
  */
45
+ // @ts-expect-error - PropTypes are unable to cover this case.
45
46
  renderIcon: PropTypes.oneOfType([PropTypes.func, PropTypes.object]).isRequired
46
47
  };
47
- var SideNavHeader$1 = SideNavHeader;
48
48
 
49
- export { SideNavHeader$1 as default };
49
+ export { SideNavHeader as default };
package/es/index.d.ts CHANGED
@@ -114,6 +114,7 @@ export { OverflowMenuV2 as unstable_OverflowMenuV2 } from './components/Overflow
114
114
  export { PageSelector as unstable_PageSelector, Pagination as unstable_Pagination, } from './components/Pagination/experimental';
115
115
  export * from './components/Popover';
116
116
  export * from './components/ProgressBar';
117
+ export { Slug as unstable__Slug, SlugContent as unstable__SlugContent, SlugActions as unstable__SlugActions, } from './components/Slug';
117
118
  export * from './components/Stack';
118
119
  export * from './components/Tooltip';
119
120
  export { Text as unstable_Text, TextDirection as unstable_TextDirection, } from './components/Text';