@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
@@ -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
  export declare const translationIds: {
9
10
  'increment.number': string;
@@ -107,6 +108,10 @@ export interface NumberInputProps extends Omit<React.InputHTMLAttributes<HTMLInp
107
108
  * Specify the size of the Number Input.
108
109
  */
109
110
  size?: 'sm' | 'md' | 'lg';
111
+ /**
112
+ * Provide a `Slug` component to be rendered inside the `TextInput` component
113
+ */
114
+ slug?: ReactNodeLike;
110
115
  /**
111
116
  * Specify how much the values should increase/decrease upon clicking on up/down button
112
117
  */
@@ -44,7 +44,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
44
44
  className: customClassName,
45
45
  disabled = false,
46
46
  disableWheel: disableWheelProp = false,
47
- defaultValue,
47
+ defaultValue = 0,
48
48
  helperText = '',
49
49
  hideLabel = false,
50
50
  hideSteppers,
@@ -61,6 +61,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
61
61
  onKeyUp,
62
62
  readOnly,
63
63
  size = 'md',
64
+ slug,
64
65
  step = 1,
65
66
  translateWithId: t = id => defaultTranslations[id],
66
67
  warn = false,
@@ -112,7 +113,8 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
112
113
  });
113
114
  const [incrementNumLabel, decrementNumLabel] = [t('increment.number'), t('decrement.number')];
114
115
  const wrapperClasses = cx__default["default"](`${prefix}--number__input-wrapper`, {
115
- [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn
116
+ [`${prefix}--number__input-wrapper--warning`]: normalizedProps.warn,
117
+ [`${prefix}--number__input-wrapper--slug`]: slug
116
118
  });
117
119
  const iconClasses = cx__default["default"]({
118
120
  [`${prefix}--number__invalid`]: normalizedProps.invalid || normalizedProps.warn,
@@ -177,6 +179,25 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
177
179
  }
178
180
  }
179
181
  }
182
+
183
+ // Slug is always size `mini`
184
+ let normalizedSlug;
185
+ if (slug) {
186
+ normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
187
+ size: 'mini'
188
+ });
189
+ }
190
+
191
+ // Need to update the internal value when the revert button is clicked
192
+ let isRevertActive;
193
+ if (slug) {
194
+ isRevertActive = normalizedSlug.props.revertActive;
195
+ }
196
+ React.useEffect(() => {
197
+ if (!isRevertActive && slug && defaultValue) {
198
+ setValue(defaultValue);
199
+ }
200
+ }, [defaultValue, isRevertActive, slug]);
180
201
  return /*#__PURE__*/React__default["default"].createElement("div", {
181
202
  className: outerElementClasses,
182
203
  onFocus: isFluid ? handleFocus : undefined,
@@ -224,7 +245,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
224
245
  step: step,
225
246
  type: "number",
226
247
  value: value
227
- })), Icon ? /*#__PURE__*/React__default["default"].createElement(Icon, {
248
+ })), normalizedSlug, Icon ? /*#__PURE__*/React__default["default"].createElement(Icon, {
228
249
  className: iconClasses
229
250
  }) : null, !hideSteppers && /*#__PURE__*/React__default["default"].createElement("div", {
230
251
  className: `${prefix}--number__controls`
@@ -348,6 +369,10 @@ NumberInput.propTypes = {
348
369
  * Specify the size of the Number Input.
349
370
  */
350
371
  size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
372
+ /**
373
+ * Provide a `Slug` component to be rendered inside the `NumberInput` component
374
+ */
375
+ slug: PropTypes__default["default"].node,
351
376
  /**
352
377
  * Specify how much the values should increase/decrease upon clicking on up/down button
353
378
  */
@@ -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;
@@ -51,6 +51,7 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
51
51
  warn = false,
52
52
  warnText,
53
53
  onChange,
54
+ slug,
54
55
  ...other
55
56
  } = _ref;
56
57
  const prefix = usePrefix.usePrefix();
@@ -71,7 +72,8 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
71
72
  [`${prefix}--select--readonly`]: readOnly,
72
73
  [`${prefix}--select--warning`]: warn,
73
74
  [`${prefix}--select--fluid--invalid`]: isFluid && invalid,
74
- [`${prefix}--select--fluid--focus`]: isFluid && isFocused
75
+ [`${prefix}--select--fluid--focus`]: isFluid && isFocused,
76
+ [`${prefix}--select--slug`]: slug
75
77
  });
76
78
  const labelClasses = cx__default["default"](`${prefix}--label`, {
77
79
  [`${prefix}--visually-hidden`]: hideLabel,
@@ -133,6 +135,14 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
133
135
  }
134
136
  }
135
137
  };
138
+
139
+ // Slug is always size `mini`
140
+ let normalizedSlug;
141
+ if (slug) {
142
+ normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
143
+ size: 'mini'
144
+ });
145
+ }
136
146
  const input = (() => {
137
147
  return /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("select", _rollupPluginBabelHelpers["extends"]({}, other, ariaProps, {
138
148
  id: id,
@@ -170,7 +180,7 @@ const Select = /*#__PURE__*/React__default["default"].forwardRef(function Select
170
180
  "data-invalid": invalid || null,
171
181
  onFocus: handleFocus,
172
182
  onBlur: handleFocus
173
- }, input, isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
183
+ }, input, normalizedSlug, isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
174
184
  className: `${prefix}--select__divider`
175
185
  }), isFluid && error ? error : null), !inline && !isFluid && error ? error : helper));
176
186
  });
@@ -244,6 +254,10 @@ Select.propTypes = {
244
254
  * Specify the size of the Select Input.
245
255
  */
246
256
  size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
257
+ /**
258
+ * Provide a `Slug` component to be rendered inside the `Select` component
259
+ */
260
+ slug: PropTypes__default["default"].node,
247
261
  /**
248
262
  * Specify whether the control is currently in warning state
249
263
  */
@@ -0,0 +1,199 @@
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
+ 'use strict';
9
+
10
+ Object.defineProperty(exports, '__esModule', { value: true });
11
+
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
13
+ var cx = require('classnames');
14
+ var PropTypes = require('prop-types');
15
+ var React = require('react');
16
+ var usePrefix = require('../../internal/usePrefix.js');
17
+ var index = require('../Toggletip/index.js');
18
+ var index$1 = require('../IconButton/index.js');
19
+ var iconsReact = require('@carbon/icons-react');
20
+ var useId = require('../../internal/useId.js');
21
+
22
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
23
+
24
+ var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
25
+ var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
26
+ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
27
+
28
+ var _Undo;
29
+ const SlugContent = /*#__PURE__*/React__default["default"].forwardRef(function SlugContent(_ref, ref) {
30
+ let {
31
+ children,
32
+ className
33
+ } = _ref;
34
+ const prefix = usePrefix.usePrefix();
35
+ const slugContentClasses = cx__default["default"](className, {
36
+ [`${prefix}--slug-content`]: true
37
+ });
38
+ return /*#__PURE__*/React__default["default"].createElement(index.ToggletipContent, {
39
+ className: slugContentClasses,
40
+ ref: ref
41
+ }, children);
42
+ });
43
+ SlugContent.propTypes = {
44
+ /**
45
+ * Specify the content you want rendered inside the slug ToggleTip
46
+ */
47
+ children: PropTypes__default["default"].node,
48
+ /**
49
+ * Specify an optional className to be added to the AI slug callout
50
+ */
51
+ className: PropTypes__default["default"].string
52
+ };
53
+ const SlugActions = /*#__PURE__*/React__default["default"].forwardRef(function SlugActions(_ref2, ref) {
54
+ let {
55
+ children,
56
+ className
57
+ } = _ref2;
58
+ const prefix = usePrefix.usePrefix();
59
+ const slugActionBarClasses = cx__default["default"](className, {
60
+ [`${prefix}--slug-actions`]: true
61
+ });
62
+ return /*#__PURE__*/React__default["default"].createElement(index.ToggletipActions, {
63
+ className: slugActionBarClasses,
64
+ ref: ref
65
+ }, children);
66
+ });
67
+ SlugActions.propTypes = {
68
+ /**
69
+ * Specify the content you want rendered inside the slug callout toolbar
70
+ */
71
+ children: PropTypes__default["default"].node,
72
+ /**
73
+ * Specify an optional className to be added to the AI slug toolbar
74
+ */
75
+ className: PropTypes__default["default"].string
76
+ };
77
+ const Slug = /*#__PURE__*/React__default["default"].forwardRef(function Slug(_ref3, ref) {
78
+ let {
79
+ aiText = 'AI',
80
+ aiTextLabel,
81
+ align,
82
+ autoAlign = true,
83
+ children,
84
+ className,
85
+ dotType,
86
+ kind,
87
+ onRevertClick,
88
+ revertActive,
89
+ revertLabel = 'Revert to AI input',
90
+ slugLabel = 'Show information',
91
+ size = 'xs',
92
+ ...rest
93
+ } = _ref3;
94
+ const prefix = usePrefix.usePrefix();
95
+ const id = useId.useId('slug');
96
+ const slugClasses = cx__default["default"](className, {
97
+ [`${prefix}--slug`]: true,
98
+ [`${prefix}--slug--hollow`]: kind === 'hollow' || dotType === 'hollow',
99
+ // Need to come up with a better name; explainable?
100
+ // Need to be able to target the non-hollow variant another way
101
+ // other than using `:not` all over the styles
102
+ [`${prefix}--slug--enabled`]: kind !== 'hollow' && dotType !== 'hollow',
103
+ [`${prefix}--slug--revert`]: revertActive
104
+ });
105
+ const slugButtonClasses = cx__default["default"]({
106
+ [`${prefix}--slug__button`]: true,
107
+ [`${prefix}--slug__button--${size}`]: size,
108
+ [`${prefix}--slug__button--${kind}`]: kind,
109
+ [`${prefix}--slug__button--inline-with-content`]: kind === 'inline' && aiTextLabel
110
+ });
111
+ const handleOnRevertClick = evt => {
112
+ if (onRevertClick) {
113
+ onRevertClick(evt);
114
+ }
115
+ };
116
+ const ariaLabel = `${aiText} - ${slugLabel}`;
117
+ return /*#__PURE__*/React__default["default"].createElement("div", {
118
+ className: slugClasses,
119
+ ref: ref,
120
+ id: id
121
+ }, revertActive ? /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, _rollupPluginBabelHelpers["extends"]({
122
+ onClick: handleOnRevertClick,
123
+ kind: "ghost",
124
+ size: "sm",
125
+ label: revertLabel
126
+ }, rest), _Undo || (_Undo = /*#__PURE__*/React__default["default"].createElement(iconsReact.Undo, null))) : /*#__PURE__*/React__default["default"].createElement(index.Toggletip, _rollupPluginBabelHelpers["extends"]({
127
+ align: align,
128
+ autoAlign: autoAlign
129
+ }, rest), /*#__PURE__*/React__default["default"].createElement(index.ToggletipButton, {
130
+ className: slugButtonClasses,
131
+ label: ariaLabel
132
+ }, /*#__PURE__*/React__default["default"].createElement("span", {
133
+ className: `${prefix}--slug__text`
134
+ }, aiText), aiTextLabel && /*#__PURE__*/React__default["default"].createElement("span", {
135
+ className: `${prefix}--slug__additional-text`
136
+ }, aiTextLabel)), children));
137
+ });
138
+ Slug.propTypes = {
139
+ /**
140
+ * Specify the correct translation of the AI text
141
+ */
142
+ aiText: PropTypes__default["default"].string,
143
+ /**
144
+ * Specify additional text to be rendered next to the AI label in the inline variant
145
+ */
146
+ aiTextLabel: PropTypes__default["default"].string,
147
+ /**
148
+ * Specify how the popover should align with the button
149
+ */
150
+ align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'left-bottom', 'left-top', 'right', 'right-bottom', 'right-top']),
151
+ /**
152
+ * Will auto-align the popover on first render if it is not visible. This prop is currently experimental and is subject to future changes.
153
+ */
154
+ autoAlign: PropTypes__default["default"].bool,
155
+ /**
156
+ * Specify the content you want rendered inside the slug ToggleTip
157
+ */
158
+ children: PropTypes__default["default"].node,
159
+ /**
160
+ * Specify an optional className to be added to the AI slug
161
+ */
162
+ className: PropTypes__default["default"].string,
163
+ /**
164
+ * Specify the type of dot that should be rendered in front of the inline variant
165
+ */
166
+ dotType: PropTypes__default["default"].oneOf(['default', 'hollow']),
167
+ /**
168
+ * Specify the type of Slug, from the following list of types:
169
+ */
170
+ kind: PropTypes__default["default"].oneOf(['default', 'hollow', 'inline']),
171
+ /**
172
+ * Callback function that fires when the revert button is clicked
173
+ */
174
+ onRevertClick: PropTypes__default["default"].func,
175
+ /**
176
+ * Specify whether the revert button should be visible
177
+ */
178
+ revertActive: PropTypes__default["default"].bool,
179
+ /**
180
+ * Specify the text that should be shown when the revert button is hovered
181
+ */
182
+ revertLabel: PropTypes__default["default"].string,
183
+ /**
184
+ * Specify the size of the button, from the following list of sizes:
185
+ */
186
+ size: PropTypes__default["default"].oneOf(['mini', '2xs', 'xs', 'sm', 'md', 'lg', 'xl']),
187
+ /**
188
+ * Specify the content you want rendered inside the slug ToggleTip
189
+ */
190
+ slugContent: PropTypes__default["default"].node,
191
+ /**
192
+ * Specify the text that will be provided to the aria-label of the `Slug` button
193
+ */
194
+ slugLabel: PropTypes__default["default"].string
195
+ };
196
+
197
+ exports.Slug = Slug;
198
+ exports.SlugActions = SlugActions;
199
+ exports.SlugContent = 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
  */
@@ -52,6 +52,7 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
52
52
  warn = false,
53
53
  warnText = '',
54
54
  rows = 4,
55
+ slug,
55
56
  ...other
56
57
  } = props;
57
58
  const prefix = usePrefix.usePrefix();
@@ -66,9 +67,19 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
66
67
  const {
67
68
  current: textAreaInstanceId
68
69
  } = React.useRef(getInstanceId());
70
+ const textareaRef = React.useRef(null);
71
+ const ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
69
72
  React.useEffect(() => {
70
73
  setTextCount(defaultValue?.toString()?.length || value?.toString()?.length || 0);
71
74
  }, [value, defaultValue]);
75
+ useIsomorphicEffect["default"](() => {
76
+ if (other.cols && textareaRef.current) {
77
+ textareaRef.current.style.width = '';
78
+ textareaRef.current.style.resize = 'none';
79
+ } else if (textareaRef.current) {
80
+ textareaRef.current.style.width = `100%`;
81
+ }
82
+ }, [other.cols]);
72
83
  const textareaProps = {
73
84
  id,
74
85
  onChange: evt => {
@@ -87,29 +98,36 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
87
98
  }
88
99
  }
89
100
  };
90
- if (enableCounter) {
91
- textareaProps.maxLength = maxCount;
92
- }
93
- const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
101
+ const formItemClasses = cx__default["default"](`${prefix}--form-item`, className);
102
+ const textAreaWrapperClasses = cx__default["default"](`${prefix}--text-area__wrapper`, {
103
+ [`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
104
+ [`${prefix}--text-area__wrapper--warn`]: warn,
105
+ [`${prefix}--text-area__wrapper--slug`]: slug
106
+ });
94
107
  const labelClasses = cx__default["default"](`${prefix}--label`, {
95
108
  [`${prefix}--visually-hidden`]: hideLabel && !isFluid,
96
109
  [`${prefix}--label--disabled`]: disabled
97
110
  });
111
+ const textareaClasses = cx__default["default"](`${prefix}--text-area`, {
112
+ [`${prefix}--text-area--light`]: light,
113
+ [`${prefix}--text-area--invalid`]: invalid,
114
+ [`${prefix}--text-area--warn`]: warn
115
+ });
116
+ const counterClasses = cx__default["default"](`${prefix}--label`, {
117
+ [`${prefix}--label--disabled`]: disabled
118
+ });
119
+ const helperTextClasses = cx__default["default"](`${prefix}--form__helper-text`, {
120
+ [`${prefix}--form__helper-text--disabled`]: disabled
121
+ });
98
122
  const label = labelText ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
99
123
  as: "label",
100
124
  htmlFor: id,
101
125
  className: labelClasses
102
126
  }, labelText) : null;
103
- const counterClasses = cx__default["default"](`${prefix}--label`, {
104
- [`${prefix}--label--disabled`]: disabled
105
- });
106
127
  const counter = enableCounter && maxCount ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
107
128
  as: "div",
108
129
  className: counterClasses
109
130
  }, `${textCount}/${maxCount}`) : null;
110
- const helperTextClasses = cx__default["default"](`${prefix}--form__helper-text`, {
111
- [`${prefix}--form__helper-text--disabled`]: disabled
112
- });
113
131
  const helperId = !helperText ? undefined : `text-area-helper-text-${textAreaInstanceId}`;
114
132
  const helper = helperText ? /*#__PURE__*/React__default["default"].createElement(Text.Text, {
115
133
  as: "div",
@@ -132,27 +150,16 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
132
150
  }, warnText, isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
133
151
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
134
152
  })) : null;
135
- const textareaClasses = cx__default["default"](`${prefix}--text-area`, {
136
- [`${prefix}--text-area--light`]: light,
137
- [`${prefix}--text-area--invalid`]: invalid,
138
- [`${prefix}--text-area--warn`]: warn
139
- });
140
- const textareaRef = React.useRef(null);
141
- const ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
142
- useIsomorphicEffect["default"](() => {
143
- if (other.cols && textareaRef.current) {
144
- textareaRef.current.style.width = '';
145
- textareaRef.current.style.resize = 'none';
146
- } else if (textareaRef.current) {
147
- textareaRef.current.style.width = `100%`;
148
- }
149
- }, [other.cols]);
150
153
  let ariaDescribedBy;
151
154
  if (invalid) {
152
155
  ariaDescribedBy = errorId;
153
156
  } else if (!invalid && !warn && !isFluid && helperText) {
154
157
  ariaDescribedBy = helperId;
155
158
  }
159
+ if (enableCounter) {
160
+ textareaProps.maxLength = maxCount;
161
+ }
162
+ const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
156
163
  const input = /*#__PURE__*/React__default["default"].createElement("textarea", _rollupPluginBabelHelpers["extends"]({}, other, textareaProps, {
157
164
  placeholder: placeholder,
158
165
  className: textareaClasses,
@@ -163,21 +170,26 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
163
170
  readOnly: other.readOnly,
164
171
  ref: ref
165
172
  }));
173
+
174
+ // Slug is always size `mini`
175
+ let normalizedSlug;
176
+ if (slug) {
177
+ normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
178
+ size: 'mini'
179
+ });
180
+ }
166
181
  return /*#__PURE__*/React__default["default"].createElement("div", {
167
- className: cx__default["default"](`${prefix}--form-item`, className)
182
+ className: formItemClasses
168
183
  }, /*#__PURE__*/React__default["default"].createElement("div", {
169
184
  className: `${prefix}--text-area__label-wrapper`
170
185
  }, label, counter), /*#__PURE__*/React__default["default"].createElement("div", {
171
- className: cx__default["default"](`${prefix}--text-area__wrapper`, {
172
- [`${prefix}--text-area__wrapper--readonly`]: other.readOnly,
173
- [`${prefix}--text-area__wrapper--warn`]: warn
174
- }),
186
+ className: textAreaWrapperClasses,
175
187
  "data-invalid": invalid || null
176
188
  }, invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningFilled, {
177
189
  className: `${prefix}--text-area__invalid-icon`
178
190
  }), warn && !invalid && !isFluid && /*#__PURE__*/React__default["default"].createElement(iconsReact.WarningAltFilled, {
179
191
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
180
- }), input, /*#__PURE__*/React__default["default"].createElement("span", {
192
+ }), input, normalizedSlug, /*#__PURE__*/React__default["default"].createElement("span", {
181
193
  className: `${prefix}--text-area__counter-alert`,
182
194
  role: "alert"
183
195
  }, ariaAnnouncement), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
@@ -263,6 +275,10 @@ TextArea.propTypes = {
263
275
  * Specify the rows attribute for the `<textarea>`
264
276
  */
265
277
  rows: PropTypes__default["default"].number,
278
+ /**
279
+ * Provide a `Slug` component to be rendered inside the `TextArea` component
280
+ */
281
+ slug: PropTypes__default["default"].node,
266
282
  /**
267
283
  * Provide the current value of the `<textarea>`
268
284
  */
@@ -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
  */
@@ -52,6 +52,7 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
52
52
  warnText,
53
53
  enableCounter = false,
54
54
  maxCount,
55
+ slug,
55
56
  ...rest
56
57
  } = _ref;
57
58
  const prefix = usePrefix.usePrefix();
@@ -123,7 +124,8 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
123
124
  [`${prefix}--text-input__field-outer-wrapper--inline`]: inline
124
125
  });
125
126
  const fieldWrapperClasses = cx__default["default"](`${prefix}--text-input__field-wrapper`, {
126
- [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn
127
+ [`${prefix}--text-input__field-wrapper--warning`]: normalizedProps.warn,
128
+ [`${prefix}--text-input__field-wrapper--slug`]: slug
127
129
  });
128
130
  const iconClasses = cx__default["default"]({
129
131
  [`${prefix}--text-input__invalid-icon`]: normalizedProps.invalid || normalizedProps.warn,
@@ -162,6 +164,14 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
162
164
  } = React.useContext(FormContext.FormContext);
163
165
  const ariaAnnouncement = useAnnouncer.useAnnouncer(textCount, maxCount);
164
166
  const Icon = normalizedProps.icon;
167
+
168
+ // Slug is always size `mini`
169
+ let normalizedSlug;
170
+ if (slug) {
171
+ normalizedSlug = /*#__PURE__*/React__default["default"].cloneElement(slug, {
172
+ size: 'mini'
173
+ });
174
+ }
165
175
  return /*#__PURE__*/React__default["default"].createElement("div", {
166
176
  className: inputWrapperClasses
167
177
  }, !inline ? labelWrapper : /*#__PURE__*/React__default["default"].createElement("div", {
@@ -173,7 +183,7 @@ const TextInput = /*#__PURE__*/React__default["default"].forwardRef(function Tex
173
183
  "data-invalid": normalizedProps.invalid || null
174
184
  }, Icon && /*#__PURE__*/React__default["default"].createElement(Icon, {
175
185
  className: iconClasses
176
- }), input, /*#__PURE__*/React__default["default"].createElement("span", {
186
+ }), input, normalizedSlug, /*#__PURE__*/React__default["default"].createElement("span", {
177
187
  className: `${prefix}--text-input__counter-alert`,
178
188
  role: "alert"
179
189
  }, ariaAnnouncement), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
@@ -260,6 +270,10 @@ TextInput.propTypes = {
260
270
  * Specify the size of the Text Input. Currently supports the following:
261
271
  */
262
272
  size: PropTypes__default["default"].oneOf(['sm', 'md', 'lg']),
273
+ /**
274
+ * Provide a `Slug` component to be rendered inside the `TextInput` component
275
+ */
276
+ slug: PropTypes__default["default"].node,
263
277
  /**
264
278
  * Specify the type of the `<input>`
265
279
  */
@@ -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;