@carbon/react 1.88.0 → 1.89.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.
@@ -7,9 +7,9 @@
7
7
  import React, { ReactNode } from 'react';
8
8
  import ContainedListItem from './ContainedListItem';
9
9
  declare const variants: readonly ["on-page", "disclosed"];
10
- export interface ContainedListType extends React.FC<ContainedListProps> {
10
+ export type ContainedListType = React.FC<ContainedListProps> & {
11
11
  ContainedListItem: typeof ContainedListItem;
12
- }
12
+ };
13
13
  export type Variants = (typeof variants)[number];
14
14
  export interface ContainedListProps {
15
15
  /**
@@ -9,7 +9,7 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
11
  import deprecateValuesWithin from '../../prop-types/deprecateValuesWithin.js';
12
- import React, { useRef, useEffect, useMemo } from 'react';
12
+ import React, { useRef, useMemo, useEffect } from 'react';
13
13
  import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
14
14
  import { useMergedRefs } from '../../internal/useMergedRefs.js';
15
15
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -361,29 +361,12 @@ function PopoverContentRenderFunction(
361
361
  caretRef,
362
362
  autoAlign
363
363
  } = React.useContext(PopoverContext);
364
- const textRef = useRef(null);
365
- const [isMultiLine, setIsMultiLine] = React.useState(false);
366
- const ref = useMergedRefs([setFloating, textRef, forwardRef]);
364
+ const ref = useMergedRefs([setFloating, forwardRef]);
367
365
  const enableFloatingStyles = useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
368
- useEffect(() => {
369
- checkIfMultiLine();
370
- }, [children]);
371
- const checkIfMultiLine = () => {
372
- const el = textRef.current;
373
- if (el) {
374
- const style = getComputedStyle(el);
375
- const lineHeight = parseFloat(style.lineHeight);
376
- const height = el.offsetHeight;
377
- const lines = Math.floor(height / lineHeight);
378
- setIsMultiLine(lines > 1);
379
- }
380
- };
381
366
  return /*#__PURE__*/React.createElement("span", _extends({}, rest, {
382
367
  className: `${prefix}--popover`
383
368
  }), /*#__PURE__*/React.createElement("span", {
384
- className: cx(`${prefix}--popover-content`, className, {
385
- [`${prefix}--tooltip-content--multiline`]: isMultiLine
386
- }),
369
+ className: cx(`${prefix}--popover-content`, className),
387
370
  ref: ref
388
371
  }, children, enableFloatingStyles && /*#__PURE__*/React.createElement("span", {
389
372
  className: cx({
@@ -59,7 +59,11 @@ const TextArea = frFn((props, forwardRef) => {
59
59
  value
60
60
  } = other;
61
61
  const textAreaInstanceId = useId();
62
+ const wrapperRef = useRef(null);
62
63
  const textareaRef = useRef(null);
64
+ const helperTextRef = useRef(null);
65
+ const errorTextRef = useRef(null);
66
+ const warnTextRef = useRef(null);
63
67
  const ref = useMergedRefs([forwardRef, textareaRef]);
64
68
  function getInitialTextCount() {
65
69
  const targetValue = defaultValue || value || textareaRef.current?.value || '';
@@ -76,13 +80,20 @@ const TextArea = frFn((props, forwardRef) => {
76
80
  // eslint-disable-next-line react-hooks/exhaustive-deps
77
81
  }, [value, defaultValue, counterMode]);
78
82
  useIsomorphicEffect(() => {
83
+ const measuredWidth = wrapperRef.current?.scrollWidth;
79
84
  if (other.cols && textareaRef.current) {
80
85
  textareaRef.current.style.width = '';
81
86
  textareaRef.current.style.resize = 'none';
82
87
  } else if (textareaRef.current) {
83
88
  textareaRef.current.style.width = `100%`;
84
89
  }
85
- }, [other.cols]);
90
+ [helperTextRef, errorTextRef, warnTextRef].forEach(r => {
91
+ if (r.current) {
92
+ r.current.style.maxWidth = `${measuredWidth}px`;
93
+ r.current.style.overflowWrap = 'break-word';
94
+ }
95
+ });
96
+ }, [other.cols, invalid, warn]);
86
97
  const textareaProps = {
87
98
  id,
88
99
  onKeyDown: evt => {
@@ -190,21 +201,26 @@ const TextArea = frFn((props, forwardRef) => {
190
201
  const helper = helperText ? /*#__PURE__*/React.createElement(Text, {
191
202
  as: "div",
192
203
  id: helperId,
193
- className: helperTextClasses
204
+ className: helperTextClasses,
205
+ ref: helperTextRef
194
206
  }, helperText) : null;
195
207
  const errorId = id + '-error-msg';
196
208
  const error = invalid ? /*#__PURE__*/React.createElement(Text, {
197
209
  as: "div",
198
210
  role: "alert",
199
211
  className: `${prefix}--form-requirement`,
200
- id: errorId
212
+ id: errorId,
213
+ ref: errorTextRef
201
214
  }, invalidText, isFluid && /*#__PURE__*/React.createElement(WarningFilled, {
202
215
  className: `${prefix}--text-area__invalid-icon`
203
216
  })) : null;
217
+ const warnId = id + '-warn-msg';
204
218
  const warning = warn ? /*#__PURE__*/React.createElement(Text, {
205
219
  as: "div",
206
220
  role: "alert",
207
- className: `${prefix}--form-requirement`
221
+ className: `${prefix}--form-requirement`,
222
+ id: warnId,
223
+ ref: warnTextRef
208
224
  }, warnText, isFluid && /*#__PURE__*/React.createElement(WarningAltFilled, {
209
225
  className: `${prefix}--text-area__invalid-icon ${prefix}--text-area__invalid-icon--warning`
210
226
  })) : null;
@@ -270,6 +286,7 @@ const TextArea = frFn((props, forwardRef) => {
270
286
  }, /*#__PURE__*/React.createElement("div", {
271
287
  className: `${prefix}--text-area__label-wrapper`
272
288
  }, label, counter), /*#__PURE__*/React.createElement("div", {
289
+ ref: wrapperRef,
273
290
  className: textAreaWrapperClasses,
274
291
  "data-invalid": invalid || null
275
292
  }, invalid && !isFluid && /*#__PURE__*/React.createElement(WarningFilled, {
@@ -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
  }
@@ -9,7 +9,6 @@ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js
9
9
  import cx from 'classnames';
10
10
  import PropTypes from 'prop-types';
11
11
  import React from 'react';
12
- import { AriaLabelPropType } from '../../prop-types/AriaPropTypes.js';
13
12
  import { usePrefix } from '../../internal/usePrefix.js';
14
13
 
15
14
  const Header = ({
@@ -25,11 +24,15 @@ const Header = ({
25
24
  };
26
25
  Header.propTypes = {
27
26
  /**
28
- * Required props for the accessibility label of the header
27
+ * Optionally provide aria-label
29
28
  */
30
- ...AriaLabelPropType,
29
+ 'aria-label': PropTypes.string,
31
30
  /**
32
- * Optionally provide a custom class name that is applied to the underlying <header>
31
+ * Optionally provide aria-labelledby
32
+ */
33
+ 'aria-labelledby': PropTypes.string,
34
+ /**
35
+ * Optionally provide a custom class name that is applied to the underlying header
33
36
  */
34
37
  className: PropTypes.string
35
38
  };
@@ -7,9 +7,9 @@
7
7
  import React, { ReactNode } from 'react';
8
8
  import ContainedListItem from './ContainedListItem';
9
9
  declare const variants: readonly ["on-page", "disclosed"];
10
- export interface ContainedListType extends React.FC<ContainedListProps> {
10
+ export type ContainedListType = React.FC<ContainedListProps> & {
11
11
  ContainedListItem: typeof ContainedListItem;
12
- }
12
+ };
13
13
  export type Variants = (typeof variants)[number];
14
14
  export interface ContainedListProps {
15
15
  /**
@@ -363,29 +363,12 @@ function PopoverContentRenderFunction(
363
363
  caretRef,
364
364
  autoAlign
365
365
  } = React.useContext(PopoverContext);
366
- const textRef = React.useRef(null);
367
- const [isMultiLine, setIsMultiLine] = React.useState(false);
368
- const ref = useMergedRefs.useMergedRefs([setFloating, textRef, forwardRef]);
366
+ const ref = useMergedRefs.useMergedRefs([setFloating, forwardRef]);
369
367
  const enableFloatingStyles = index.useFeatureFlag('enable-v12-dynamic-floating-styles') || autoAlign;
370
- React.useEffect(() => {
371
- checkIfMultiLine();
372
- }, [children]);
373
- const checkIfMultiLine = () => {
374
- const el = textRef.current;
375
- if (el) {
376
- const style = getComputedStyle(el);
377
- const lineHeight = parseFloat(style.lineHeight);
378
- const height = el.offsetHeight;
379
- const lines = Math.floor(height / lineHeight);
380
- setIsMultiLine(lines > 1);
381
- }
382
- };
383
368
  return /*#__PURE__*/React.createElement("span", _rollupPluginBabelHelpers.extends({}, rest, {
384
369
  className: `${prefix}--popover`
385
370
  }), /*#__PURE__*/React.createElement("span", {
386
- className: cx(`${prefix}--popover-content`, className, {
387
- [`${prefix}--tooltip-content--multiline`]: isMultiLine
388
- }),
371
+ className: cx(`${prefix}--popover-content`, className),
389
372
  ref: ref
390
373
  }, children, enableFloatingStyles && /*#__PURE__*/React.createElement("span", {
391
374
  className: cx({
@@ -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, {
@@ -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
  };
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.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -53,9 +53,9 @@
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.27.3",
55
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",
56
+ "@carbon/icons-react": "^11.65.0-rc.0",
57
+ "@carbon/layout": "^11.39.0-rc.0",
58
+ "@carbon/styles": "^1.88.0-rc.0",
59
59
  "@carbon/utilities": "^0.7.0",
60
60
  "@floating-ui/react": "^0.27.4",
61
61
  "@ibm/telemetry-js": "^1.5.0",
@@ -80,7 +80,7 @@
80
80
  "@babel/preset-react": "^7.27.1",
81
81
  "@babel/preset-typescript": "^7.27.1",
82
82
  "@carbon/test-utils": "^10.36.0",
83
- "@carbon/themes": "^11.57.0",
83
+ "@carbon/themes": "^11.58.0-rc.0",
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,7 +96,7 @@
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
102
  "clipboardy": "^2.1.0",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "6568a3389c2a82348c693b167b511dea66b7b269"
142
+ "gitHead": "babd7a9692f8c0595b67877417d7ebf915e19b20"
143
143
  }