@carbon/react 1.95.1-rc.0 → 1.97.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.
@@ -531,6 +531,10 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
531
531
  }
532
532
  }
533
533
  });
534
+
535
+ // Keep the dropdown highlight in sync with either the controlled value or
536
+ // Downshift's own selection when uncontrolled.
537
+ const menuSelectedItem = typeof selectedItemProp !== 'undefined' ? selectedItemProp : selectedItem;
534
538
  useEffect(() => {
535
539
  // Used to expose the downshift actions to consumers for use with downshiftProps
536
540
  // An odd pattern, here we mutate the value stored in the ref provided from the consumer.
@@ -758,13 +762,13 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
758
762
  } = itemProps;
759
763
  return /*#__PURE__*/React.createElement(ListBox.MenuItem, _extends({
760
764
  key: itemProps.id,
761
- isActive: isEqual(selectedItem, item),
765
+ isActive: isEqual(menuSelectedItem, item),
762
766
  isHighlighted: highlightedIndex === index,
763
767
  title: title,
764
768
  disabled: disabled
765
769
  }, modifiedItemProps), ItemToElement ? /*#__PURE__*/React.createElement(ItemToElement, _extends({
766
770
  key: itemProps.id
767
- }, item)) : itemToString(item), isEqual(selectedItem, item) && /*#__PURE__*/React.createElement(Checkmark, {
771
+ }, item)) : itemToString(item), isEqual(menuSelectedItem, item) && /*#__PURE__*/React.createElement(Checkmark, {
768
772
  className: `${prefix}--list-box__menu-item__selected-icon`
769
773
  }));
770
774
  }) : null)), helperText && !invalid && !warn && !isFluid && /*#__PURE__*/React.createElement(Text, {
@@ -149,7 +149,7 @@ const Menu = /*#__PURE__*/forwardRef(function Menu({
149
149
  }
150
150
  }
151
151
  function handleBlur(e) {
152
- if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
152
+ if (open && onClose && isRoot && e.relatedTarget && !menu.current?.contains(e.relatedTarget)) {
153
153
  handleClose();
154
154
  }
155
155
  }
@@ -250,6 +250,7 @@ const Pagination = /*#__PURE__*/React.forwardRef(({
250
250
  hideLabel: true,
251
251
  onChange: handlePageInputChange,
252
252
  value: page,
253
+ key: page,
253
254
  disabled: pageInputDisabled || disabled
254
255
  }, selectItems), /*#__PURE__*/React.createElement("span", {
255
256
  className: `${prefix}--pagination__text`
@@ -69,5 +69,5 @@ export interface RadioTileProps {
69
69
  */
70
70
  required?: boolean;
71
71
  }
72
- declare const RadioTile: React.ForwardRefExoticComponent<RadioTileProps & React.RefAttributes<HTMLInputElement>>;
72
+ declare const RadioTile: React.ForwardRefExoticComponent<RadioTileProps & React.AriaAttributes & React.RefAttributes<HTMLInputElement>>;
73
73
  export default RadioTile;
@@ -51,6 +51,11 @@ const RadioTile = /*#__PURE__*/React.forwardRef(({
51
51
  [`${prefix}--tile--decorator`]: decorator,
52
52
  [`${prefix}--tile--decorator-rounded`]: decorator && hasRoundedCorners
53
53
  });
54
+ const {
55
+ 'aria-describedby': ariaDescribedBy,
56
+ 'aria-labelledby': ariaLabelledBy,
57
+ ...labelProps
58
+ } = rest;
54
59
  const v12TileRadioIcons = useFeatureFlag('enable-v12-tile-radio-icons');
55
60
  function icon() {
56
61
  if (v12TileRadioIcons) {
@@ -79,7 +84,7 @@ const RadioTile = /*#__PURE__*/React.forwardRef(({
79
84
  const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/cloneElement(candidate, {
80
85
  size: 'xs'
81
86
  }) : candidate;
82
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
87
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", _extends({
83
88
  checked: checked,
84
89
  className: `${prefix}--tile-input`,
85
90
  disabled: disabled,
@@ -89,10 +94,15 @@ const RadioTile = /*#__PURE__*/React.forwardRef(({
89
94
  onKeyDown: !disabled ? handleOnKeyDown : undefined,
90
95
  tabIndex: !disabled ? tabIndex : undefined,
91
96
  type: "radio",
92
- value: value,
97
+ value: value
98
+ }, ariaDescribedBy && {
99
+ 'aria-describedby': ariaDescribedBy
100
+ }, ariaLabelledBy && {
101
+ 'aria-labelledby': ariaLabelledBy
102
+ }, {
93
103
  ref: ref,
94
104
  required: required
95
- }), /*#__PURE__*/React.createElement("label", _extends({}, rest, {
105
+ })), /*#__PURE__*/React.createElement("label", _extends({}, labelProps, {
96
106
  htmlFor: inputId,
97
107
  className: className
98
108
  }), /*#__PURE__*/React.createElement("span", {
@@ -10,7 +10,7 @@ import { Close, Search as Search$1 } from '@carbon/icons-react';
10
10
  import cx from 'classnames';
11
11
  import PropTypes from 'prop-types';
12
12
  import React, { useContext, useRef, useState } from 'react';
13
- import { Enter, Space, Escape } from '../../internal/keyboard/keys.js';
13
+ import { Escape, Enter, Space } from '../../internal/keyboard/keys.js';
14
14
  import { match } from '../../internal/keyboard/match.js';
15
15
  import { useId } from '../../internal/useId.js';
16
16
  import { usePrefix } from '../../internal/usePrefix.js';
@@ -20,6 +20,8 @@ import { deprecate } from '../../prop-types/deprecate.js';
20
20
  import '../FluidForm/FluidForm.js';
21
21
  import { FormContext } from '../FluidForm/FormContext.js';
22
22
  import { noopFn } from '../../internal/noopFn.js';
23
+ import '../Tooltip/DefinitionTooltip.js';
24
+ import { Tooltip } from '../Tooltip/Tooltip.js';
23
25
 
24
26
  var _Close;
25
27
  const Search = /*#__PURE__*/React.forwardRef(({
@@ -129,11 +131,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
129
131
  }
130
132
  }
131
133
  }
132
- return /*#__PURE__*/React.createElement("div", {
133
- role: "search",
134
- "aria-label": placeholder,
135
- className: searchClasses
136
- }, /*#__PURE__*/React.createElement("div", {
134
+ const magnifierButton = /*#__PURE__*/React.createElement("div", {
137
135
  "aria-labelledby": onExpand ? searchId : undefined,
138
136
  role: onExpand ? 'button' : undefined,
139
137
  className: `${prefix}--search-magnifier`,
@@ -145,7 +143,19 @@ const Search = /*#__PURE__*/React.forwardRef(({
145
143
  "aria-controls": onExpand ? uniqueId : undefined
146
144
  }, /*#__PURE__*/React.createElement(CustomSearchIcon, {
147
145
  icon: renderIcon
148
- })), /*#__PURE__*/React.createElement("label", {
146
+ }));
147
+
148
+ // Wrap magnifierButton in a tooltip if it's expandable
149
+ const magnifierWithTooltip = onExpand && !isExpanded ? /*#__PURE__*/React.createElement(Tooltip, {
150
+ className: `${prefix}--search-tooltip ${prefix}--search-magnifier-tooltip`,
151
+ align: "top",
152
+ label: "Search"
153
+ }, magnifierButton) : magnifierButton;
154
+ return /*#__PURE__*/React.createElement("div", {
155
+ role: "search",
156
+ "aria-label": placeholder,
157
+ className: searchClasses
158
+ }, magnifierWithTooltip, /*#__PURE__*/React.createElement("label", {
149
159
  id: searchId,
150
160
  htmlFor: uniqueId,
151
161
  className: `${prefix}--label`
@@ -36,6 +36,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
36
36
  closeOnActivation = false,
37
37
  dropShadow = false,
38
38
  highContrast = true,
39
+ // TODO: remove in v12, highContrast should not be configurable
39
40
  ...rest
40
41
  }, ref) => {
41
42
  const tooltipRef = useRef(null);
@@ -167,7 +168,8 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
167
168
  align: align,
168
169
  className: cx(`${prefix}--tooltip`, customClassName),
169
170
  dropShadow: dropShadow,
170
- highContrast: highContrast,
171
+ highContrast: highContrast // TODO: v12 hard-set highContrast to true
172
+ ,
171
173
  onKeyDown: onKeyDown,
172
174
  onMouseLeave: onMouseLeave,
173
175
  open: open
@@ -250,6 +252,8 @@ Tooltip.propTypes = {
250
252
  * Render the component using the high-contrast theme
251
253
  */
252
254
  highContrast: PropTypes.bool,
255
+ // TODO: remove in v12, highContrast should not be configurable
256
+
253
257
  /**
254
258
  * Provide the label to be rendered inside of the Tooltip. The label will use
255
259
  * `aria-labelledby` and will fully describe the child node that is provided.
@@ -535,6 +535,10 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
535
535
  }
536
536
  }
537
537
  });
538
+
539
+ // Keep the dropdown highlight in sync with either the controlled value or
540
+ // Downshift's own selection when uncontrolled.
541
+ const menuSelectedItem = typeof selectedItemProp !== 'undefined' ? selectedItemProp : selectedItem;
538
542
  React.useEffect(() => {
539
543
  // Used to expose the downshift actions to consumers for use with downshiftProps
540
544
  // An odd pattern, here we mutate the value stored in the ref provided from the consumer.
@@ -762,13 +766,13 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
762
766
  } = itemProps;
763
767
  return /*#__PURE__*/React.createElement(index$2.default.MenuItem, _rollupPluginBabelHelpers.extends({
764
768
  key: itemProps.id,
765
- isActive: isEqual(selectedItem, item),
769
+ isActive: isEqual(menuSelectedItem, item),
766
770
  isHighlighted: highlightedIndex === index,
767
771
  title: title,
768
772
  disabled: disabled
769
773
  }, modifiedItemProps), ItemToElement ? /*#__PURE__*/React.createElement(ItemToElement, _rollupPluginBabelHelpers.extends({
770
774
  key: itemProps.id
771
- }, item)) : itemToString(item), isEqual(selectedItem, item) && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
775
+ }, item)) : itemToString(item), isEqual(menuSelectedItem, item) && /*#__PURE__*/React.createElement(iconsReact.Checkmark, {
772
776
  className: `${prefix}--list-box__menu-item__selected-icon`
773
777
  }));
774
778
  }) : null)), helperText && !invalid && !warn && !isFluid && /*#__PURE__*/React.createElement(Text.Text, {
@@ -151,7 +151,7 @@ const Menu = /*#__PURE__*/React.forwardRef(function Menu({
151
151
  }
152
152
  }
153
153
  function handleBlur(e) {
154
- if (open && onClose && isRoot && !menu.current?.contains(e.relatedTarget)) {
154
+ if (open && onClose && isRoot && e.relatedTarget && !menu.current?.contains(e.relatedTarget)) {
155
155
  handleClose();
156
156
  }
157
157
  }
@@ -254,6 +254,7 @@ const Pagination = /*#__PURE__*/React.forwardRef(({
254
254
  hideLabel: true,
255
255
  onChange: handlePageInputChange,
256
256
  value: page,
257
+ key: page,
257
258
  disabled: pageInputDisabled || disabled
258
259
  }, selectItems), /*#__PURE__*/React.createElement("span", {
259
260
  className: `${prefix}--pagination__text`
@@ -69,5 +69,5 @@ export interface RadioTileProps {
69
69
  */
70
70
  required?: boolean;
71
71
  }
72
- declare const RadioTile: React.ForwardRefExoticComponent<RadioTileProps & React.RefAttributes<HTMLInputElement>>;
72
+ declare const RadioTile: React.ForwardRefExoticComponent<RadioTileProps & React.AriaAttributes & React.RefAttributes<HTMLInputElement>>;
73
73
  export default RadioTile;
@@ -55,6 +55,11 @@ const RadioTile = /*#__PURE__*/React.forwardRef(({
55
55
  [`${prefix}--tile--decorator`]: decorator,
56
56
  [`${prefix}--tile--decorator-rounded`]: decorator && hasRoundedCorners
57
57
  });
58
+ const {
59
+ 'aria-describedby': ariaDescribedBy,
60
+ 'aria-labelledby': ariaLabelledBy,
61
+ ...labelProps
62
+ } = rest;
58
63
  const v12TileRadioIcons = index.useFeatureFlag('enable-v12-tile-radio-icons');
59
64
  function icon() {
60
65
  if (v12TileRadioIcons) {
@@ -83,7 +88,7 @@ const RadioTile = /*#__PURE__*/React.forwardRef(({
83
88
  const normalizedDecorator = candidateIsAILabel ? /*#__PURE__*/React.cloneElement(candidate, {
84
89
  size: 'xs'
85
90
  }) : candidate;
86
- return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", {
91
+ return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement("input", _rollupPluginBabelHelpers.extends({
87
92
  checked: checked,
88
93
  className: `${prefix}--tile-input`,
89
94
  disabled: disabled,
@@ -93,10 +98,15 @@ const RadioTile = /*#__PURE__*/React.forwardRef(({
93
98
  onKeyDown: !disabled ? handleOnKeyDown : undefined,
94
99
  tabIndex: !disabled ? tabIndex : undefined,
95
100
  type: "radio",
96
- value: value,
101
+ value: value
102
+ }, ariaDescribedBy && {
103
+ 'aria-describedby': ariaDescribedBy
104
+ }, ariaLabelledBy && {
105
+ 'aria-labelledby': ariaLabelledBy
106
+ }, {
97
107
  ref: ref,
98
108
  required: required
99
- }), /*#__PURE__*/React.createElement("label", _rollupPluginBabelHelpers.extends({}, rest, {
109
+ })), /*#__PURE__*/React.createElement("label", _rollupPluginBabelHelpers.extends({}, labelProps, {
100
110
  htmlFor: inputId,
101
111
  className: className
102
112
  }), /*#__PURE__*/React.createElement("span", {
@@ -24,6 +24,8 @@ var deprecate = require('../../prop-types/deprecate.js');
24
24
  require('../FluidForm/FluidForm.js');
25
25
  var FormContext = require('../FluidForm/FormContext.js');
26
26
  var noopFn = require('../../internal/noopFn.js');
27
+ require('../Tooltip/DefinitionTooltip.js');
28
+ var Tooltip = require('../Tooltip/Tooltip.js');
27
29
 
28
30
  var _Close;
29
31
  const Search = /*#__PURE__*/React.forwardRef(({
@@ -133,11 +135,7 @@ const Search = /*#__PURE__*/React.forwardRef(({
133
135
  }
134
136
  }
135
137
  }
136
- return /*#__PURE__*/React.createElement("div", {
137
- role: "search",
138
- "aria-label": placeholder,
139
- className: searchClasses
140
- }, /*#__PURE__*/React.createElement("div", {
138
+ const magnifierButton = /*#__PURE__*/React.createElement("div", {
141
139
  "aria-labelledby": onExpand ? searchId : undefined,
142
140
  role: onExpand ? 'button' : undefined,
143
141
  className: `${prefix}--search-magnifier`,
@@ -149,7 +147,19 @@ const Search = /*#__PURE__*/React.forwardRef(({
149
147
  "aria-controls": onExpand ? uniqueId : undefined
150
148
  }, /*#__PURE__*/React.createElement(CustomSearchIcon, {
151
149
  icon: renderIcon
152
- })), /*#__PURE__*/React.createElement("label", {
150
+ }));
151
+
152
+ // Wrap magnifierButton in a tooltip if it's expandable
153
+ const magnifierWithTooltip = onExpand && !isExpanded ? /*#__PURE__*/React.createElement(Tooltip.Tooltip, {
154
+ className: `${prefix}--search-tooltip ${prefix}--search-magnifier-tooltip`,
155
+ align: "top",
156
+ label: "Search"
157
+ }, magnifierButton) : magnifierButton;
158
+ return /*#__PURE__*/React.createElement("div", {
159
+ role: "search",
160
+ "aria-label": placeholder,
161
+ className: searchClasses
162
+ }, magnifierWithTooltip, /*#__PURE__*/React.createElement("label", {
153
163
  id: searchId,
154
164
  htmlFor: uniqueId,
155
165
  className: `${prefix}--label`
@@ -38,6 +38,7 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
38
38
  closeOnActivation = false,
39
39
  dropShadow = false,
40
40
  highContrast = true,
41
+ // TODO: remove in v12, highContrast should not be configurable
41
42
  ...rest
42
43
  }, ref) => {
43
44
  const tooltipRef = React.useRef(null);
@@ -169,7 +170,8 @@ const Tooltip = /*#__PURE__*/React.forwardRef(({
169
170
  align: align,
170
171
  className: cx(`${prefix}--tooltip`, customClassName),
171
172
  dropShadow: dropShadow,
172
- highContrast: highContrast,
173
+ highContrast: highContrast // TODO: v12 hard-set highContrast to true
174
+ ,
173
175
  onKeyDown: onKeyDown,
174
176
  onMouseLeave: onMouseLeave,
175
177
  open: open
@@ -252,6 +254,8 @@ Tooltip.propTypes = {
252
254
  * Render the component using the high-contrast theme
253
255
  */
254
256
  highContrast: PropTypes.bool,
257
+ // TODO: remove in v12, highContrast should not be configurable
258
+
255
259
  /**
256
260
  * Provide the label to be rendered inside of the Tooltip. The label will use
257
261
  * `aria-labelledby` and will fully describe the child node that is provided.
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.95.1-rc.0",
4
+ "version": "1.97.0-rc.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/index.d.ts",
@@ -55,7 +55,7 @@
55
55
  "@carbon/feature-flags": "0.32.0",
56
56
  "@carbon/icons-react": "^11.70.0",
57
57
  "@carbon/layout": "^11.43.0",
58
- "@carbon/styles": "^1.94.1-rc.0",
58
+ "@carbon/styles": "^1.96.0-rc.0",
59
59
  "@carbon/utilities": "^0.12.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.38.0",
83
- "@carbon/themes": "^11.62.1-rc.0",
83
+ "@carbon/themes": "^11.64.0-rc.0",
84
84
  "@figma/code-connect": "^1.3.5",
85
85
  "@rollup/plugin-babel": "^6.0.0",
86
86
  "@rollup/plugin-commonjs": "^28.0.3",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "fde0c0fc9b6c3931d871720ee94e99255603d18d"
142
+ "gitHead": "87ff7d321ab5e0f7147383b2a71f43936b7e34c1"
143
143
  }