@carbon/react 1.75.0 → 1.76.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.
@@ -462,7 +462,8 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
462
462
  selectedItem: newSelectedItem
463
463
  });
464
464
  }
465
- if (type === useCombobox.stateChangeTypes.FunctionSelectItem || type === useCombobox.stateChangeTypes.InputKeyDownEnter) {
465
+ if ((type === useCombobox.stateChangeTypes.FunctionSelectItem || type === useCombobox.stateChangeTypes.InputKeyDownEnter) && !isEqual(selectedItemProp, newSelectedItem) // Only fire if there's an actual change
466
+ ) {
466
467
  onChange({
467
468
  selectedItem: newSelectedItem
468
469
  });
@@ -600,9 +601,9 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
600
601
  // Since `onChange` does not normally fire when the menu is closed, we should
601
602
  // manually fire it when `allowCustomValue` is provided, the menu is closing,
602
603
  // and there is a value.
603
- if (allowCustomValue && isOpen && inputValue) {
604
+ if (allowCustomValue && isOpen && inputValue && highlightedIndex === -1) {
604
605
  onChange({
605
- selectedItem,
606
+ selectedItem: null,
606
607
  inputValue
607
608
  });
608
609
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import PropTypes from 'prop-types';
7
+ import React from 'react';
8
8
  import { ReactAttr } from '../../types/common';
9
9
  export interface TableRowProps extends ReactAttr<HTMLTableRowElement> {
10
10
  /**
@@ -16,17 +16,5 @@ export interface TableRowProps extends ReactAttr<HTMLTableRowElement> {
16
16
  */
17
17
  isSelected?: boolean;
18
18
  }
19
- declare const TableRow: {
20
- (props: TableRowProps): import("react/jsx-runtime").JSX.Element;
21
- propTypes: {
22
- /**
23
- * Specify an optional className to be applied to the container node
24
- */
25
- className: PropTypes.Requireable<string>;
26
- /**
27
- * Specify if the row is selected
28
- */
29
- isSelected: PropTypes.Requireable<boolean>;
30
- };
31
- };
19
+ declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLTableCellElement>>;
32
20
  export default TableRow;
@@ -5,12 +5,13 @@
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
7
 
8
+ import { extends as _extends } from '../../_virtual/_rollupPluginBabelHelpers.js';
8
9
  import React__default from 'react';
9
10
  import PropTypes from 'prop-types';
10
11
  import cx from 'classnames';
11
12
  import { usePrefix } from '../../internal/usePrefix.js';
12
13
 
13
- const TableRow = props => {
14
+ const TableRow = /*#__PURE__*/React__default.forwardRef((props, ref) => {
14
15
  const prefix = usePrefix();
15
16
  let rowHasAILabel;
16
17
  if (props?.children) {
@@ -40,8 +41,10 @@ const TableRow = props => {
40
41
  if (className) {
41
42
  cleanProps.className = className;
42
43
  }
43
- return /*#__PURE__*/React__default.createElement("tr", cleanProps);
44
- };
44
+ return /*#__PURE__*/React__default.createElement("tr", _extends({
45
+ ref: ref
46
+ }, cleanProps));
47
+ });
45
48
  TableRow.propTypes = {
46
49
  /**
47
50
  * Specify an optional className to be applied to the container node
@@ -34,6 +34,14 @@ export interface FluidTextInputProps {
34
34
  * Specify whether the control is a password input
35
35
  */
36
36
  isPassword?: boolean;
37
+ /**
38
+ * Max character count allowed for the textInput. This is needed in order for enableCounter to display
39
+ */
40
+ maxCount?: number;
41
+ /**
42
+ * Specify whether to display the character counter
43
+ */
44
+ enableCounter?: boolean;
37
45
  /**
38
46
  * Provide the text that will be read by a screen reader when visiting this
39
47
  * control
@@ -67,6 +67,14 @@ FluidTextInput.propTypes = {
67
67
  * Specify whether the control is a password input
68
68
  */
69
69
  isPassword: PropTypes.bool,
70
+ /**
71
+ * Max character count allowed for the textInput. This is needed in order for enableCounter to display
72
+ */
73
+ maxCount: PropTypes.number,
74
+ /**
75
+ * Specify whether to display the character counter
76
+ */
77
+ enableCounter: PropTypes.bool,
70
78
  /**
71
79
  * Provide the text that will be read by a screen reader when visiting this
72
80
  * control
@@ -419,8 +419,10 @@ export interface ActionableNotificationProps extends HTMLAttributes<HTMLDivEleme
419
419
  */
420
420
  onCloseButtonClick?(event: MouseEvent): void;
421
421
  /**
422
- * By default, this value is "alertdialog". You can also provide an alternate
423
- * role if it makes sense from from an accessibility perspective.
422
+ * Provide an accessible role to be used. Defaults to `alertdialog`. Any other
423
+ * value will disable the wrapping of focus. To remain accessible, additional
424
+ * work is required. See the storybook docs for more info:
425
+ * https://react.carbondesignsystem.com/?path=/docs/components-notifications-actionable--overview#using-the-role-prop
424
426
  */
425
427
  role?: string;
426
428
  /**
@@ -494,8 +496,10 @@ export declare namespace ActionableNotification {
494
496
  */
495
497
  onCloseButtonClick: PropTypes.Requireable<(...args: any[]) => any>;
496
498
  /**
497
- * By default, this value is "alertdialog". You can also provide an alternate
498
- * role if it makes sense from the accessibility-side.
499
+ * Provide an accessible role to be used. Defaults to `alertdialog`. Any other
500
+ * value will disable the wrapping of focus. To remain accessible, additional
501
+ * work is required. See the storybook docs for more info:
502
+ * https://react.carbondesignsystem.com/?path=/docs/components-notifications-actionable--overview#using-the-role-prop
499
503
  */
500
504
  role: PropTypes.Requireable<string>;
501
505
  /**
@@ -514,7 +514,7 @@ function ActionableNotification(_ref6) {
514
514
  const ref = useRef(null);
515
515
  const focusTrapWithoutSentinels = useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
516
516
  useIsomorphicEffect(() => {
517
- if (hasFocus) {
517
+ if (hasFocus && role === 'alertdialog') {
518
518
  const button = document.querySelector('button.cds--actionable-notification__action-button');
519
519
  button?.focus();
520
520
  }
@@ -524,7 +524,7 @@ function ActionableNotification(_ref6) {
524
524
  target: oldActiveNode,
525
525
  relatedTarget: currentActiveNode
526
526
  } = _ref7;
527
- if (isOpen && currentActiveNode && oldActiveNode) {
527
+ if (isOpen && currentActiveNode && oldActiveNode && role === 'alertdialog') {
528
528
  const {
529
529
  current: bodyNode
530
530
  } = innerModal;
@@ -544,7 +544,7 @@ function ActionableNotification(_ref6) {
544
544
  }
545
545
  }
546
546
  function handleKeyDown(event) {
547
- if (isOpen && match(event, Tab) && ref.current) {
547
+ if (isOpen && match(event, Tab) && ref.current && role === 'alertdialog') {
548
548
  wrapFocusWithoutSentinels({
549
549
  containerNode: ref.current,
550
550
  currentActiveNode: event.target,
@@ -671,8 +671,10 @@ ActionableNotification.propTypes = {
671
671
  */
672
672
  onCloseButtonClick: PropTypes.func,
673
673
  /**
674
- * By default, this value is "alertdialog". You can also provide an alternate
675
- * role if it makes sense from the accessibility-side.
674
+ * Provide an accessible role to be used. Defaults to `alertdialog`. Any other
675
+ * value will disable the wrapping of focus. To remain accessible, additional
676
+ * work is required. See the storybook docs for more info:
677
+ * https://react.carbondesignsystem.com/?path=/docs/components-notifications-actionable--overview#using-the-role-prop
676
678
  */
677
679
  role: PropTypes.string,
678
680
  /**
@@ -4,9 +4,9 @@
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 React, { type ForwardedRef, type WeakValidationMap, type ElementType } from 'react';
8
- import { type PolymorphicProps } from '../../types/common';
7
+ import React, { type WeakValidationMap } from 'react';
9
8
  import { type Boundary } from '@floating-ui/react';
9
+ import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
10
10
  export interface PopoverContext {
11
11
  setFloating: React.Ref<HTMLSpanElement>;
12
12
  caretRef: React.Ref<HTMLSpanElement>;
@@ -67,14 +67,11 @@ export interface PopoverBaseProps {
67
67
  */
68
68
  open: boolean;
69
69
  }
70
- export type PopoverProps<E extends ElementType> = PolymorphicProps<E, PopoverBaseProps>;
71
- export interface PopoverComponent {
72
- <E extends ElementType = 'span'>(props: PopoverProps<E> & {
73
- forwardRef?: ForwardedRef<ElementType>;
74
- }): JSX.Element | null;
70
+ export type PopoverProps<E extends React.ElementType> = PolymorphicComponentPropWithRef<E, PopoverBaseProps>;
71
+ export type PopoverComponent = <E extends React.ElementType = 'span'>(props: PopoverProps<E>) => React.ReactElement | any;
72
+ export declare const Popover: PopoverComponent & {
75
73
  displayName?: string;
76
74
  propTypes?: WeakValidationMap<PopoverProps<any>>;
77
- }
78
- export declare const Popover: PopoverComponent;
75
+ };
79
76
  export type PopoverContentProps = React.HTMLAttributes<HTMLSpanElement>;
80
77
  export declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLSpanElement>>;
@@ -168,7 +168,8 @@ const TextArea = /*#__PURE__*/React__default.forwardRef((props, forwardRef) => {
168
168
  [`${prefix}--text-area--warn`]: warn
169
169
  });
170
170
  const counterClasses = cx(`${prefix}--label`, {
171
- [`${prefix}--label--disabled`]: disabled
171
+ [`${prefix}--label--disabled`]: disabled,
172
+ [`${prefix}--text-area__label-counter`]: true
172
173
  });
173
174
  const helperTextClasses = cx(`${prefix}--form__helper-text`, {
174
175
  [`${prefix}--form__helper-text--disabled`]: disabled
@@ -260,7 +260,8 @@ const ToggletipContent = /*#__PURE__*/React__default.forwardRef(function Togglet
260
260
  return /*#__PURE__*/React__default.createElement(PopoverContent, _extends({
261
261
  className: customClassName
262
262
  }, toggletip?.contentProps, {
263
- ref: ref
263
+ ref: ref,
264
+ "aria-live": "polite"
264
265
  }), /*#__PURE__*/React__default.createElement("div", {
265
266
  className: `${prefix}--toggletip-content`
266
267
  }, children));
@@ -473,7 +473,8 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
473
473
  selectedItem: newSelectedItem
474
474
  });
475
475
  }
476
- if (type === Downshift.useCombobox.stateChangeTypes.FunctionSelectItem || type === Downshift.useCombobox.stateChangeTypes.InputKeyDownEnter) {
476
+ if ((type === Downshift.useCombobox.stateChangeTypes.FunctionSelectItem || type === Downshift.useCombobox.stateChangeTypes.InputKeyDownEnter) && !isEqual__default["default"](selectedItemProp, newSelectedItem) // Only fire if there's an actual change
477
+ ) {
477
478
  onChange({
478
479
  selectedItem: newSelectedItem
479
480
  });
@@ -611,9 +612,9 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
611
612
  // Since `onChange` does not normally fire when the menu is closed, we should
612
613
  // manually fire it when `allowCustomValue` is provided, the menu is closing,
613
614
  // and there is a value.
614
- if (allowCustomValue && isOpen && inputValue) {
615
+ if (allowCustomValue && isOpen && inputValue && highlightedIndex === -1) {
615
616
  onChange({
616
- selectedItem,
617
+ selectedItem: null,
617
618
  inputValue
618
619
  });
619
620
  }
@@ -4,7 +4,7 @@
4
4
  * This source code is licensed under the Apache-2.0 license found in the
5
5
  * LICENSE file in the root directory of this source tree.
6
6
  */
7
- import PropTypes from 'prop-types';
7
+ import React from 'react';
8
8
  import { ReactAttr } from '../../types/common';
9
9
  export interface TableRowProps extends ReactAttr<HTMLTableRowElement> {
10
10
  /**
@@ -16,17 +16,5 @@ export interface TableRowProps extends ReactAttr<HTMLTableRowElement> {
16
16
  */
17
17
  isSelected?: boolean;
18
18
  }
19
- declare const TableRow: {
20
- (props: TableRowProps): import("react/jsx-runtime").JSX.Element;
21
- propTypes: {
22
- /**
23
- * Specify an optional className to be applied to the container node
24
- */
25
- className: PropTypes.Requireable<string>;
26
- /**
27
- * Specify if the row is selected
28
- */
29
- isSelected: PropTypes.Requireable<boolean>;
30
- };
31
- };
19
+ declare const TableRow: React.ForwardRefExoticComponent<TableRowProps & React.RefAttributes<HTMLTableCellElement>>;
32
20
  export default TableRow;
@@ -9,6 +9,7 @@
9
9
 
10
10
  Object.defineProperty(exports, '__esModule', { value: true });
11
11
 
12
+ var _rollupPluginBabelHelpers = require('../../_virtual/_rollupPluginBabelHelpers.js');
12
13
  var React = require('react');
13
14
  var PropTypes = require('prop-types');
14
15
  var cx = require('classnames');
@@ -20,7 +21,7 @@ var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
20
21
  var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
21
22
  var cx__default = /*#__PURE__*/_interopDefaultLegacy(cx);
22
23
 
23
- const TableRow = props => {
24
+ const TableRow = /*#__PURE__*/React__default["default"].forwardRef((props, ref) => {
24
25
  const prefix = usePrefix.usePrefix();
25
26
  let rowHasAILabel;
26
27
  if (props?.children) {
@@ -50,8 +51,10 @@ const TableRow = props => {
50
51
  if (className) {
51
52
  cleanProps.className = className;
52
53
  }
53
- return /*#__PURE__*/React__default["default"].createElement("tr", cleanProps);
54
- };
54
+ return /*#__PURE__*/React__default["default"].createElement("tr", _rollupPluginBabelHelpers["extends"]({
55
+ ref: ref
56
+ }, cleanProps));
57
+ });
55
58
  TableRow.propTypes = {
56
59
  /**
57
60
  * Specify an optional className to be applied to the container node
@@ -34,6 +34,14 @@ export interface FluidTextInputProps {
34
34
  * Specify whether the control is a password input
35
35
  */
36
36
  isPassword?: boolean;
37
+ /**
38
+ * Max character count allowed for the textInput. This is needed in order for enableCounter to display
39
+ */
40
+ maxCount?: number;
41
+ /**
42
+ * Specify whether to display the character counter
43
+ */
44
+ enableCounter?: boolean;
37
45
  /**
38
46
  * Provide the text that will be read by a screen reader when visiting this
39
47
  * control
@@ -77,6 +77,14 @@ FluidTextInput.propTypes = {
77
77
  * Specify whether the control is a password input
78
78
  */
79
79
  isPassword: PropTypes__default["default"].bool,
80
+ /**
81
+ * Max character count allowed for the textInput. This is needed in order for enableCounter to display
82
+ */
83
+ maxCount: PropTypes__default["default"].number,
84
+ /**
85
+ * Specify whether to display the character counter
86
+ */
87
+ enableCounter: PropTypes__default["default"].bool,
80
88
  /**
81
89
  * Provide the text that will be read by a screen reader when visiting this
82
90
  * control
@@ -419,8 +419,10 @@ export interface ActionableNotificationProps extends HTMLAttributes<HTMLDivEleme
419
419
  */
420
420
  onCloseButtonClick?(event: MouseEvent): void;
421
421
  /**
422
- * By default, this value is "alertdialog". You can also provide an alternate
423
- * role if it makes sense from from an accessibility perspective.
422
+ * Provide an accessible role to be used. Defaults to `alertdialog`. Any other
423
+ * value will disable the wrapping of focus. To remain accessible, additional
424
+ * work is required. See the storybook docs for more info:
425
+ * https://react.carbondesignsystem.com/?path=/docs/components-notifications-actionable--overview#using-the-role-prop
424
426
  */
425
427
  role?: string;
426
428
  /**
@@ -494,8 +496,10 @@ export declare namespace ActionableNotification {
494
496
  */
495
497
  onCloseButtonClick: PropTypes.Requireable<(...args: any[]) => any>;
496
498
  /**
497
- * By default, this value is "alertdialog". You can also provide an alternate
498
- * role if it makes sense from the accessibility-side.
499
+ * Provide an accessible role to be used. Defaults to `alertdialog`. Any other
500
+ * value will disable the wrapping of focus. To remain accessible, additional
501
+ * work is required. See the storybook docs for more info:
502
+ * https://react.carbondesignsystem.com/?path=/docs/components-notifications-actionable--overview#using-the-role-prop
499
503
  */
500
504
  role: PropTypes.Requireable<string>;
501
505
  /**
@@ -524,7 +524,7 @@ function ActionableNotification(_ref6) {
524
524
  const ref = React.useRef(null);
525
525
  const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
526
526
  useIsomorphicEffect["default"](() => {
527
- if (hasFocus) {
527
+ if (hasFocus && role === 'alertdialog') {
528
528
  const button = document.querySelector('button.cds--actionable-notification__action-button');
529
529
  button?.focus();
530
530
  }
@@ -534,7 +534,7 @@ function ActionableNotification(_ref6) {
534
534
  target: oldActiveNode,
535
535
  relatedTarget: currentActiveNode
536
536
  } = _ref7;
537
- if (isOpen && currentActiveNode && oldActiveNode) {
537
+ if (isOpen && currentActiveNode && oldActiveNode && role === 'alertdialog') {
538
538
  const {
539
539
  current: bodyNode
540
540
  } = innerModal;
@@ -554,7 +554,7 @@ function ActionableNotification(_ref6) {
554
554
  }
555
555
  }
556
556
  function handleKeyDown(event) {
557
- if (isOpen && match.match(event, keys.Tab) && ref.current) {
557
+ if (isOpen && match.match(event, keys.Tab) && ref.current && role === 'alertdialog') {
558
558
  wrapFocus.wrapFocusWithoutSentinels({
559
559
  containerNode: ref.current,
560
560
  currentActiveNode: event.target,
@@ -681,8 +681,10 @@ ActionableNotification.propTypes = {
681
681
  */
682
682
  onCloseButtonClick: PropTypes__default["default"].func,
683
683
  /**
684
- * By default, this value is "alertdialog". You can also provide an alternate
685
- * role if it makes sense from the accessibility-side.
684
+ * Provide an accessible role to be used. Defaults to `alertdialog`. Any other
685
+ * value will disable the wrapping of focus. To remain accessible, additional
686
+ * work is required. See the storybook docs for more info:
687
+ * https://react.carbondesignsystem.com/?path=/docs/components-notifications-actionable--overview#using-the-role-prop
686
688
  */
687
689
  role: PropTypes__default["default"].string,
688
690
  /**
@@ -4,9 +4,9 @@
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 React, { type ForwardedRef, type WeakValidationMap, type ElementType } from 'react';
8
- import { type PolymorphicProps } from '../../types/common';
7
+ import React, { type WeakValidationMap } from 'react';
9
8
  import { type Boundary } from '@floating-ui/react';
9
+ import { PolymorphicComponentPropWithRef } from '../../internal/PolymorphicProps';
10
10
  export interface PopoverContext {
11
11
  setFloating: React.Ref<HTMLSpanElement>;
12
12
  caretRef: React.Ref<HTMLSpanElement>;
@@ -67,14 +67,11 @@ export interface PopoverBaseProps {
67
67
  */
68
68
  open: boolean;
69
69
  }
70
- export type PopoverProps<E extends ElementType> = PolymorphicProps<E, PopoverBaseProps>;
71
- export interface PopoverComponent {
72
- <E extends ElementType = 'span'>(props: PopoverProps<E> & {
73
- forwardRef?: ForwardedRef<ElementType>;
74
- }): JSX.Element | null;
70
+ export type PopoverProps<E extends React.ElementType> = PolymorphicComponentPropWithRef<E, PopoverBaseProps>;
71
+ export type PopoverComponent = <E extends React.ElementType = 'span'>(props: PopoverProps<E>) => React.ReactElement | any;
72
+ export declare const Popover: PopoverComponent & {
75
73
  displayName?: string;
76
74
  propTypes?: WeakValidationMap<PopoverProps<any>>;
77
- }
78
- export declare const Popover: PopoverComponent;
75
+ };
79
76
  export type PopoverContentProps = React.HTMLAttributes<HTMLSpanElement>;
80
77
  export declare const PopoverContent: React.ForwardRefExoticComponent<PopoverContentProps & React.RefAttributes<HTMLSpanElement>>;
@@ -178,7 +178,8 @@ const TextArea = /*#__PURE__*/React__default["default"].forwardRef((props, forwa
178
178
  [`${prefix}--text-area--warn`]: warn
179
179
  });
180
180
  const counterClasses = cx__default["default"](`${prefix}--label`, {
181
- [`${prefix}--label--disabled`]: disabled
181
+ [`${prefix}--label--disabled`]: disabled,
182
+ [`${prefix}--text-area__label-counter`]: true
182
183
  });
183
184
  const helperTextClasses = cx__default["default"](`${prefix}--form__helper-text`, {
184
185
  [`${prefix}--form__helper-text--disabled`]: disabled
@@ -270,7 +270,8 @@ const ToggletipContent = /*#__PURE__*/React__default["default"].forwardRef(funct
270
270
  return /*#__PURE__*/React__default["default"].createElement(index.PopoverContent, _rollupPluginBabelHelpers["extends"]({
271
271
  className: customClassName
272
272
  }, toggletip?.contentProps, {
273
- ref: ref
273
+ ref: ref,
274
+ "aria-live": "polite"
274
275
  }), /*#__PURE__*/React__default["default"].createElement("div", {
275
276
  className: `${prefix}--toggletip-content`
276
277
  }, children));
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.75.0",
4
+ "version": "1.76.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -51,9 +51,9 @@
51
51
  "dependencies": {
52
52
  "@babel/runtime": "^7.24.7",
53
53
  "@carbon/feature-flags": "^0.24.0",
54
- "@carbon/icons-react": "^11.54.0",
54
+ "@carbon/icons-react": "^11.55.0",
55
55
  "@carbon/layout": "^11.29.0",
56
- "@carbon/styles": "^1.74.0",
56
+ "@carbon/styles": "^1.75.0",
57
57
  "@floating-ui/react": "^0.26.0",
58
58
  "@ibm/telemetry-js": "^1.5.0",
59
59
  "classnames": "2.5.1",
@@ -145,5 +145,5 @@
145
145
  "**/*.scss",
146
146
  "**/*.css"
147
147
  ],
148
- "gitHead": "9815eaf3bbe004ffe8243299dd6470d5313fb38a"
148
+ "gitHead": "fd1b7ab668473833c250488e0f7fc4feb55f1d88"
149
149
  }