@carbon/react 1.88.0 → 1.89.0-rc.1

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 (47) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +848 -848
  2. package/es/components/AILabel/index.d.ts +2 -5
  3. package/es/components/AILabel/index.js +2 -42
  4. package/es/components/ContainedList/ContainedList.d.ts +2 -2
  5. package/es/components/Copy/Copy.js +1 -0
  6. package/es/components/Link/Link.js +15 -1
  7. package/es/components/Menu/MenuContext.d.ts +1 -1
  8. package/es/components/Menu/MenuContext.js +11 -4
  9. package/es/components/Menu/MenuItem.js +2 -9
  10. package/es/components/Modal/Modal.js +15 -7
  11. package/es/components/MultiSelect/FilterableMultiSelect.js +1 -5
  12. package/es/components/MultiSelect/MultiSelect.js +3 -7
  13. package/es/components/Popover/index.d.ts +4 -0
  14. package/es/components/Popover/index.js +11 -22
  15. package/es/components/StructuredList/StructuredList.d.ts +16 -0
  16. package/es/components/StructuredList/StructuredList.js +19 -9
  17. package/es/components/TextArea/TextArea.js +21 -4
  18. package/es/components/Toggletip/index.d.ts +13 -36
  19. package/es/components/Toggletip/index.js +11 -51
  20. package/es/components/UIShell/Header.d.ts +3 -3
  21. package/es/components/UIShell/Header.js +7 -4
  22. package/es/internal/Selection.js +1 -1
  23. package/es/internal/useMergedRefs.js +4 -3
  24. package/lib/components/AILabel/index.d.ts +2 -5
  25. package/lib/components/AILabel/index.js +1 -41
  26. package/lib/components/ContainedList/ContainedList.d.ts +2 -2
  27. package/lib/components/Copy/Copy.js +1 -0
  28. package/lib/components/Link/Link.js +15 -1
  29. package/lib/components/Menu/MenuContext.d.ts +1 -1
  30. package/lib/components/Menu/MenuContext.js +11 -4
  31. package/lib/components/Menu/MenuItem.js +2 -9
  32. package/lib/components/Modal/Modal.js +15 -7
  33. package/lib/components/MultiSelect/FilterableMultiSelect.js +1 -5
  34. package/lib/components/MultiSelect/MultiSelect.js +3 -7
  35. package/lib/components/Popover/index.d.ts +4 -0
  36. package/lib/components/Popover/index.js +10 -21
  37. package/lib/components/StructuredList/StructuredList.d.ts +16 -0
  38. package/lib/components/StructuredList/StructuredList.js +19 -9
  39. package/lib/components/TextArea/TextArea.js +21 -4
  40. package/lib/components/Toggletip/index.d.ts +13 -36
  41. package/lib/components/Toggletip/index.js +10 -50
  42. package/lib/components/UIShell/Header.d.ts +3 -3
  43. package/lib/components/UIShell/Header.js +7 -4
  44. package/lib/internal/Selection.js +1 -1
  45. package/lib/internal/useMergedRefs.js +3 -2
  46. package/package.json +12 -13
  47. package/telemetry.yml +3 -2
@@ -63,7 +63,11 @@ const TextArea = frFn((props, forwardRef) => {
63
63
  value
64
64
  } = other;
65
65
  const textAreaInstanceId = useId.useId();
66
+ const wrapperRef = React.useRef(null);
66
67
  const textareaRef = React.useRef(null);
68
+ const helperTextRef = React.useRef(null);
69
+ const errorTextRef = React.useRef(null);
70
+ const warnTextRef = React.useRef(null);
67
71
  const ref = useMergedRefs.useMergedRefs([forwardRef, textareaRef]);
68
72
  function getInitialTextCount() {
69
73
  const targetValue = defaultValue || value || textareaRef.current?.value || '';
@@ -80,13 +84,20 @@ const TextArea = frFn((props, forwardRef) => {
80
84
  // eslint-disable-next-line react-hooks/exhaustive-deps
81
85
  }, [value, defaultValue, counterMode]);
82
86
  useIsomorphicEffect.default(() => {
87
+ const measuredWidth = wrapperRef.current?.scrollWidth;
83
88
  if (other.cols && textareaRef.current) {
84
89
  textareaRef.current.style.width = '';
85
90
  textareaRef.current.style.resize = 'none';
86
91
  } else if (textareaRef.current) {
87
92
  textareaRef.current.style.width = `100%`;
88
93
  }
89
- }, [other.cols]);
94
+ [helperTextRef, errorTextRef, warnTextRef].forEach(r => {
95
+ if (r.current) {
96
+ r.current.style.maxWidth = `${measuredWidth}px`;
97
+ r.current.style.overflowWrap = 'break-word';
98
+ }
99
+ });
100
+ }, [other.cols, invalid, warn]);
90
101
  const textareaProps = {
91
102
  id,
92
103
  onKeyDown: evt => {
@@ -194,21 +205,26 @@ const TextArea = frFn((props, forwardRef) => {
194
205
  const helper = helperText ? /*#__PURE__*/React.createElement(Text.Text, {
195
206
  as: "div",
196
207
  id: helperId,
197
- className: helperTextClasses
208
+ className: helperTextClasses,
209
+ ref: helperTextRef
198
210
  }, helperText) : null;
199
211
  const errorId = id + '-error-msg';
200
212
  const error = invalid ? /*#__PURE__*/React.createElement(Text.Text, {
201
213
  as: "div",
202
214
  role: "alert",
203
215
  className: `${prefix}--form-requirement`,
204
- id: errorId
216
+ id: errorId,
217
+ ref: errorTextRef
205
218
  }, invalidText, isFluid && /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
206
219
  className: `${prefix}--text-area__invalid-icon`
207
220
  })) : null;
221
+ const warnId = id + '-warn-msg';
208
222
  const warning = warn ? /*#__PURE__*/React.createElement(Text.Text, {
209
223
  as: "div",
210
224
  role: "alert",
211
- className: `${prefix}--form-requirement`
225
+ className: `${prefix}--form-requirement`,
226
+ id: warnId,
227
+ ref: warnTextRef
212
228
  }, warnText, isFluid && /*#__PURE__*/React.createElement(iconsReact.WarningAltFilled, {
213
229
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
214
230
  })) : null;
@@ -274,6 +290,7 @@ const TextArea = frFn((props, forwardRef) => {
274
290
  }, /*#__PURE__*/React.createElement("div", {
275
291
  className: `${prefix}--text-area__label-wrapper`
276
292
  }, label, counter), /*#__PURE__*/React.createElement("div", {
293
+ ref: wrapperRef,
277
294
  className: textAreaWrapperClasses,
278
295
  "data-invalid": invalid || null
279
296
  }, invalid && !isFluid && /*#__PURE__*/React.createElement(iconsReact.WarningFilled, {
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  import React, { type ElementType, type ReactNode } from 'react';
9
- import { type PopoverAlignment } from '../Popover';
9
+ import { type PopoverAlignment, PopoverBaseProps } from '../Popover';
10
10
  import { PolymorphicProps } from '../../types/common';
11
11
  import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
12
12
  type ToggletipLabelProps<E extends ElementType> = {
@@ -36,12 +36,7 @@ export declare namespace ToggletipLabel {
36
36
  className: PropTypes.Requireable<string>;
37
37
  };
38
38
  }
39
- export interface ToggletipBaseProps {
40
- align?: PopoverAlignment;
41
- alignmentAxisOffset?: number;
42
- autoAlign?: boolean;
43
- className?: string;
44
- children?: ReactNode;
39
+ export interface ToggletipBaseProps extends Omit<PopoverBaseProps, 'open'> {
45
40
  defaultOpen?: boolean;
46
41
  }
47
42
  export type ToggletipProps<T extends ElementType> = PolymorphicComponentPropWithRef<T, ToggletipBaseProps>;
@@ -53,39 +48,21 @@ export type ToggletipProps<T extends ElementType> = PolymorphicComponentPropWith
53
48
  export declare function Toggletip<E extends ElementType = 'span'>({ align, as, autoAlign, className: customClassName, children, defaultOpen, ...rest }: ToggletipProps<E>): import("react/jsx-runtime").JSX.Element;
54
49
  export declare namespace Toggletip {
55
50
  var propTypes: {
56
- /**
57
- * Specify how the toggletip should align with the button
58
- */
59
- align: PropTypes.Requireable<string>;
60
- /**
61
- * **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
62
- */
63
- alignmentAxisOffset: PropTypes.Requireable<number>;
64
- /**
65
- * Provide a custom element or component to render the top-level node for the
66
- * component.
67
- */
68
- as: PropTypes.Requireable<PropTypes.ReactComponentLike>;
69
- /**
70
- * Will auto-align the popover on first render if it is not visible. This prop
71
- * is currently experimental and is subject to future changes. Requires
72
- * React v17+
73
- * @see https://github.com/carbon-design-system/carbon/issues/18714
74
- */
75
- autoAlign: PropTypes.Requireable<boolean>;
76
- /**
77
- * Custom children to be rendered as the content of the label
78
- */
79
- children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
80
- /**
81
- * Provide a custom class name to be added to the outermost node in the
82
- * component
83
- */
84
- className: PropTypes.Requireable<string>;
85
51
  /**
86
52
  * Specify if the toggletip should be open by default
87
53
  */
88
54
  defaultOpen: PropTypes.Requireable<boolean>;
55
+ align?: PopoverAlignment;
56
+ alignmentAxisOffset?: number;
57
+ autoAlign?: boolean;
58
+ autoAlignBoundary?: import("@floating-ui/dom").Boundary;
59
+ caret?: boolean;
60
+ children?: React.ReactNode;
61
+ className?: string;
62
+ dropShadow?: boolean;
63
+ highContrast?: boolean;
64
+ isTabTip?: boolean;
65
+ onRequestClose?: () => void;
89
66
  };
90
67
  }
91
68
  export interface ToggletipButtonBaseProps {
@@ -151,57 +151,17 @@ function Toggletip({
151
151
  autoAlign: autoAlign
152
152
  }, rest), children));
153
153
  }
154
- Toggletip.propTypes = {
155
- /**
156
- * Specify how the toggletip should align with the button
157
- */
158
- align: PropTypes.oneOf(['top', 'top-left',
159
- // deprecated use top-start instead
160
- 'top-right',
161
- // deprecated use top-end instead
162
-
163
- 'bottom', 'bottom-left',
164
- // deprecated use bottom-start instead
165
- 'bottom-right',
166
- // deprecated use bottom-end instead
167
154
 
168
- 'left', 'left-bottom',
169
- // deprecated use left-end instead
170
- 'left-top',
171
- // deprecated use left-start instead
172
-
173
- 'right', 'right-bottom',
174
- // deprecated use right-end instead
175
- 'right-top',
176
- // deprecated use right-start instead
177
-
178
- // new values to match floating-ui
179
- 'top-start', 'top-end', 'bottom-start', 'bottom-end', 'left-end', 'left-start', 'right-end', 'right-start']),
180
- /**
181
- * **Experimental:** Provide an offset value for alignment axis. Only takes effect when `autoalign` is enabled.
182
- */
183
- alignmentAxisOffset: PropTypes.number,
184
- /**
185
- * Provide a custom element or component to render the top-level node for the
186
- * component.
187
- */
188
- as: PropTypes.elementType,
189
- /**
190
- * Will auto-align the popover on first render if it is not visible. This prop
191
- * is currently experimental and is subject to future changes. Requires
192
- * React v17+
193
- * @see https://github.com/carbon-design-system/carbon/issues/18714
194
- */
195
- autoAlign: PropTypes.bool,
196
- /**
197
- * Custom children to be rendered as the content of the label
198
- */
199
- children: PropTypes.node,
200
- /**
201
- * Provide a custom class name to be added to the outermost node in the
202
- * component
203
- */
204
- className: PropTypes.string,
155
+ // Get all the properties from Popover except for "open".
156
+ // The Typescript types for PropTypes are really messed up so we need lots of
157
+ // casting. It will be great when we can finally get rid of PropTypes altogether.
158
+ const {
159
+ open,
160
+ ...popoverNonOpenPropTypes
161
+ } = index.Popover.propTypes ?? {};
162
+ Toggletip.propTypes = {
163
+ // Has all of Popover's PropTypes except for "open".
164
+ ...popoverNonOpenPropTypes,
205
165
  /**
206
166
  * Specify if the toggletip should be open by default
207
167
  */
@@ -8,15 +8,15 @@ import React, { ReactNode } from 'react';
8
8
  export interface HeaderProps {
9
9
  children?: ReactNode;
10
10
  /**
11
- * Required props for the accessibility label of the header
11
+ * Optionally provide aria-label
12
12
  */
13
13
  'aria-label'?: string;
14
14
  /**
15
- * Required props for the accessibility label of the header
15
+ * Optionally provide aria-labelledby
16
16
  */
17
17
  'aria-labelledby'?: string;
18
18
  /**
19
- * Optionally provide a custom class name that is applied to the underlying <header>
19
+ * Optionally provide a custom class name that is applied to the underlying header
20
20
  */
21
21
  className?: string;
22
22
  }
@@ -13,7 +13,6 @@ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelper
13
13
  var cx = require('classnames');
14
14
  var PropTypes = require('prop-types');
15
15
  var React = require('react');
16
- var AriaPropTypes = require('../../prop-types/AriaPropTypes.js');
17
16
  var usePrefix = require('../../internal/usePrefix.js');
18
17
 
19
18
  const Header = ({
@@ -29,11 +28,15 @@ const Header = ({
29
28
  };
30
29
  Header.propTypes = {
31
30
  /**
32
- * Required props for the accessibility label of the header
31
+ * Optionally provide aria-label
33
32
  */
34
- ...AriaPropTypes.AriaLabelPropType,
33
+ 'aria-label': PropTypes.string,
35
34
  /**
36
- * Optionally provide a custom class name that is applied to the underlying <header>
35
+ * Optionally provide aria-labelledby
36
+ */
37
+ 'aria-labelledby': PropTypes.string,
38
+ /**
39
+ * Optionally provide a custom class name that is applied to the underlying header
37
40
  */
38
41
  className: PropTypes.string
39
42
  };
@@ -50,7 +50,7 @@ const useSelection = ({
50
50
 
51
51
  // Assert special properties (e.g., `disabled`, `isSelectAll`, etc.) are
52
52
  // `any` since those properties aren’t part of the generic type.
53
- const allSelectableItems = filteredItems.filter(item => !item?.disabled);
53
+ const allSelectableItems = filteredItems.filter(item => !item?.disabled && !item?.isSelectAll);
54
54
  const disabledItemCount = filteredItems.filter(item => item?.disabled).length;
55
55
  let newSelectedItems;
56
56
 
@@ -18,15 +18,16 @@ var React = require('react');
18
18
  * node, assigns that node to every ref in the array.
19
19
  */
20
20
  const useMergedRefs = refs => {
21
+ const memoizedRefs = React.useMemo(() => refs, refs);
21
22
  return React.useCallback(node => {
22
- refs.forEach(ref => {
23
+ memoizedRefs.forEach(ref => {
23
24
  if (typeof ref === 'function') {
24
25
  ref(node);
25
26
  } else if (ref) {
26
27
  ref.current = node;
27
28
  }
28
29
  });
29
- }, [refs]);
30
+ }, [memoizedRefs]);
30
31
  };
31
32
 
32
33
  exports.useMergedRefs = useMergedRefs;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.88.0",
4
+ "version": "1.89.0-rc.1",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -52,11 +52,11 @@
52
52
  },
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.27.3",
55
- "@carbon/feature-flags": "^0.29.0",
56
- "@carbon/icons-react": "^11.64.0",
57
- "@carbon/layout": "^11.38.0",
58
- "@carbon/styles": "^1.87.0",
59
- "@carbon/utilities": "^0.7.0",
55
+ "@carbon/feature-flags": "^0.29.1-rc.0",
56
+ "@carbon/icons-react": "^11.65.0-rc.1",
57
+ "@carbon/layout": "^11.39.0-rc.1",
58
+ "@carbon/styles": "^1.88.0-rc.1",
59
+ "@carbon/utilities": "^0.7.1-rc.0",
60
60
  "@floating-ui/react": "^0.27.4",
61
61
  "@ibm/telemetry-js": "^1.5.0",
62
62
  "classnames": "2.5.1",
@@ -79,8 +79,8 @@
79
79
  "@babel/preset-env": "^7.27.2",
80
80
  "@babel/preset-react": "^7.27.1",
81
81
  "@babel/preset-typescript": "^7.27.1",
82
- "@carbon/test-utils": "^10.36.0",
83
- "@carbon/themes": "^11.57.0",
82
+ "@carbon/test-utils": "^10.36.1-rc.0",
83
+ "@carbon/themes": "^11.58.0-rc.1",
84
84
  "@figma/code-connect": "^1.3.2",
85
85
  "@rollup/plugin-babel": "^6.0.0",
86
86
  "@rollup/plugin-commonjs": "^28.0.3",
@@ -96,19 +96,18 @@
96
96
  "autoprefixer": "^10.4.0",
97
97
  "babel-loader": "^10.0.0",
98
98
  "babel-plugin-dev-expression": "^0.2.3",
99
- "babel-preset-carbon": "^0.7.0",
99
+ "babel-preset-carbon": "^0.8.0-rc.0",
100
100
  "browserify-zlib": "^0.2.0",
101
101
  "browserslist-config-carbon": "^11.2.0",
102
- "clipboardy": "^2.1.0",
102
+ "clipboardy": "^4.0.0",
103
103
  "css-loader": "^7.0.0",
104
104
  "enquirer": "^2.3.6",
105
- "fast-glob": "^3.2.7",
105
+ "fast-glob": "^3.3.3",
106
106
  "fs-extra": "^11.0.0",
107
107
  "html-webpack-plugin": "^5.5.0",
108
108
  "mini-css-extract-plugin": "^2.4.5",
109
109
  "postcss": "^8.4.5",
110
110
  "postcss-loader": "^8.0.0",
111
- "prettier2": "npm:prettier@2",
112
111
  "process": "^0.11.10",
113
112
  "prop-types": "^15.8.1",
114
113
  "react": "^19.0.0",
@@ -139,5 +138,5 @@
139
138
  "**/*.scss",
140
139
  "**/*.css"
141
140
  ],
142
- "gitHead": "6568a3389c2a82348c693b167b511dea66b7b269"
141
+ "gitHead": "573fc72ac30bc2d71ebb90644b803ba8408fe82e"
143
142
  }
package/telemetry.yml CHANGED
@@ -496,6 +496,7 @@ collect:
496
496
  - itemsShown
497
497
  - loop
498
498
  # Popover
499
+ - alignmentAxisOffset
499
500
  - autoAlignBoundary
500
501
  - caret
501
502
  - isTabTip
@@ -544,6 +545,8 @@ collect:
544
545
  - unstable_ariaLabelHandleUpper
545
546
  # StructuredListCell
546
547
  - noWrap
548
+ # StructuredListWrapper
549
+ - selectedInitialRow
547
550
  # SwitcherItem
548
551
  - handleSwitcherItemFocus
549
552
  # Tab
@@ -609,8 +612,6 @@ collect:
609
612
  - labelA
610
613
  - labelB
611
614
  - toggled
612
- # Toggletip
613
- - alignmentAxisOffset
614
615
  # TreeNode
615
616
  - defaultIsExpanded
616
617
  - depth