@carbon/react 1.97.0-rc.0 → 1.97.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.
@@ -206,7 +206,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
206
206
  // behavior by explicitly setting preventCloseOnClickOutside to false,
207
207
  // rather than just leaving it undefined.
208
208
  !isPassive && preventCloseOnClickOutside === false;
209
- if (shouldCloseOnOutsideClick && target instanceof Node && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
209
+ if (shouldCloseOnOutsideClick && target instanceof Node && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus, prefix) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
210
210
  closeModal(evt);
211
211
  }
212
212
  }
@@ -230,7 +230,8 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
230
230
  endTrapNode: endSentinelNode,
231
231
  currentActiveNode,
232
232
  oldActiveNode,
233
- selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean)
233
+ selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean),
234
+ prefix
234
235
  });
235
236
  }
236
237
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
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.
@@ -62,7 +62,7 @@ const DataTableSkeleton = ({
62
62
  }, rest), /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, columnsArray.map(i => /*#__PURE__*/React.createElement("th", {
63
63
  key: i
64
64
  }, headers ? /*#__PURE__*/React.createElement("div", {
65
- className: "cds--table-header-label"
65
+ className: `${prefix}--table-header-label`
66
66
  }, headers[i]?.header) : _span2 || (_span2 = /*#__PURE__*/React.createElement("span", null)))))), /*#__PURE__*/React.createElement("tbody", null, rows)));
67
67
  };
68
68
  DataTableSkeleton.propTypes = {
@@ -167,7 +167,7 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
167
167
  // behavior by explicitly setting preventCloseOnClickOutside to false,
168
168
  // rather than just leaving it undefined.
169
169
  !passiveModal && preventCloseOnClickOutside === false;
170
- if (shouldCloseOnOutsideClick && target instanceof Node && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
170
+ if (shouldCloseOnOutsideClick && target instanceof Node && !elementOrParentIsFloatingMenu(target, selectorsFloatingMenus, prefix) && innerModal.current && !innerModal.current.contains(target)) {
171
171
  onRequestClose(evt);
172
172
  }
173
173
  }
@@ -194,7 +194,8 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
194
194
  endTrapNode,
195
195
  currentActiveNode,
196
196
  oldActiveNode,
197
- selectorsFloatingMenus
197
+ selectorsFloatingMenus,
198
+ prefix
198
199
  });
199
200
  if (wrapFocusTimeout.current) {
200
201
  clearTimeout(wrapFocusTimeout.current);
@@ -509,7 +509,7 @@ function ActionableNotification({
509
509
  const focusTrapWithoutSentinels = focusTrapWithoutSentinelsFlag || deprecatedFlag;
510
510
  useIsomorphicEffect(() => {
511
511
  if (hasFocus && role === 'alertdialog') {
512
- const button = document.querySelector('button.cds--actionable-notification__action-button');
512
+ const button = document.querySelector(`button.${prefix}--actionable-notification__action-button`);
513
513
  button?.focus();
514
514
  }
515
515
  });
@@ -532,7 +532,8 @@ function ActionableNotification({
532
532
  startTrapNode,
533
533
  endTrapNode,
534
534
  currentActiveNode,
535
- oldActiveNode
535
+ oldActiveNode,
536
+ prefix
536
537
  });
537
538
  }
538
539
  }
@@ -116,8 +116,8 @@ forwardRef) {
116
116
  // If a value is not set via a custom property, provide a default value that matches the
117
117
  // default values defined in the sass style file
118
118
  const getStyle = window.getComputedStyle(popover.current, null);
119
- const offsetProperty = getStyle.getPropertyValue('--cds-popover-offset');
120
- const caretProperty = getStyle.getPropertyValue('--cds-popover-caret-height');
119
+ const offsetProperty = getStyle.getPropertyValue(`--${prefix}-popover-offset`);
120
+ const caretProperty = getStyle.getPropertyValue(`--${prefix}-popover-caret-height`);
121
121
 
122
122
  // Handle if the property values are in px or rem.
123
123
  // We want to store just the base number value without a unit suffix
@@ -257,7 +257,8 @@ const FloatingMenu = ({
257
257
  startTrapNode: startSentinelRef.current,
258
258
  endTrapNode: endSentinelRef.current,
259
259
  currentActiveNode: relatedTarget,
260
- oldActiveNode: target
260
+ oldActiveNode: target,
261
+ prefix
261
262
  });
262
263
  }
263
264
  };
@@ -14,12 +14,12 @@
14
14
  * @returns {boolean} Whether the node or one of its ancestors is in a floating
15
15
  * menu.
16
16
  */
17
- export declare const elementOrParentIsFloatingMenu: (node: Node, selectorsFloatingMenus?: string[]) => boolean;
17
+ export declare const elementOrParentIsFloatingMenu: (node: Node, selectorsFloatingMenus?: string[], prefix?: string) => boolean;
18
18
  /**
19
19
  * Ensures the focus is kept within the given container by implementing
20
20
  * "focus-wrap" behavior.
21
21
  */
22
- export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, currentActiveNode, oldActiveNode, selectorsFloatingMenus, }: {
22
+ export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, currentActiveNode, oldActiveNode, selectorsFloatingMenus, prefix, }: {
23
23
  /** The DOM node of the container. */
24
24
  bodyNode: HTMLElement | null;
25
25
  /** The start sentinel node for focus trapping. */
@@ -32,6 +32,8 @@ export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, current
32
32
  oldActiveNode: HTMLElement;
33
33
  /** CSS selectors for floating menus. */
34
34
  selectorsFloatingMenus?: string[];
35
+ /** Classname prefix for Carbon selectors. */
36
+ prefix?: string;
35
37
  }) => void;
36
38
  /**
37
39
  * Ensures the focus is kept in the given container, implementing "focus-wrap"
@@ -30,9 +30,9 @@ const DOCUMENT_POSITION_BROAD_FOLLOWING = typeof Node !== 'undefined' ? Node.DOC
30
30
  * @returns {boolean} Whether the node or one of its ancestors is in a floating
31
31
  * menu.
32
32
  */
33
- const elementOrParentIsFloatingMenu = (node, selectorsFloatingMenus = []) => {
33
+ const elementOrParentIsFloatingMenu = (node, selectorsFloatingMenus = [], prefix = 'cds') => {
34
34
  if (node instanceof Element && typeof node.closest === 'function') {
35
- const allSelectorsFloatingMenus = ['.cds--overflow-menu-options', '.cds--tooltip', '.flatpickr-calendar', ...selectorsFloatingMenus];
35
+ const allSelectorsFloatingMenus = [`.${prefix}--overflow-menu-options`, `.${prefix}--tooltip`, '.flatpickr-calendar', ...selectorsFloatingMenus];
36
36
  return allSelectorsFloatingMenus.some(selector => !!node.closest(selector));
37
37
  }
38
38
  return false;
@@ -48,9 +48,10 @@ const wrapFocus = ({
48
48
  endTrapNode,
49
49
  currentActiveNode,
50
50
  oldActiveNode,
51
- selectorsFloatingMenus
51
+ selectorsFloatingMenus,
52
+ prefix = 'cds'
52
53
  }) => {
53
- if (bodyNode && currentActiveNode && oldActiveNode && !bodyNode.contains(currentActiveNode) && !elementOrParentIsFloatingMenu(currentActiveNode, selectorsFloatingMenus)) {
54
+ if (bodyNode && currentActiveNode && oldActiveNode && !bodyNode.contains(currentActiveNode) && !elementOrParentIsFloatingMenu(currentActiveNode, selectorsFloatingMenus, prefix)) {
54
55
  const comparisonResult = oldActiveNode.compareDocumentPosition(currentActiveNode);
55
56
  if (currentActiveNode === startTrapNode || comparisonResult & DOCUMENT_POSITION_BROAD_PRECEDING) {
56
57
  const tabbableElement = Array.from(bodyNode.querySelectorAll(selectorTabbable)).reverse().find(({
@@ -210,7 +210,7 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
210
210
  // behavior by explicitly setting preventCloseOnClickOutside to false,
211
211
  // rather than just leaving it undefined.
212
212
  !isPassive && preventCloseOnClickOutside === false;
213
- if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
213
+ if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus, prefix) && innerModal.current && !innerModal.current.contains(target) && !innerModal.current.contains(mouseDownTarget)) {
214
214
  closeModal(evt);
215
215
  }
216
216
  }
@@ -234,7 +234,8 @@ const ComposedModalDialog = /*#__PURE__*/React.forwardRef(function ComposedModal
234
234
  endTrapNode: endSentinelNode,
235
235
  currentActiveNode,
236
236
  oldActiveNode,
237
- selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean)
237
+ selectorsFloatingMenus: selectorsFloatingMenus?.filter(Boolean),
238
+ prefix
238
239
  });
239
240
  }
240
241
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2023
2
+ * Copyright IBM Corp. 2016, 2025
3
3
  *
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.
@@ -66,7 +66,7 @@ const DataTableSkeleton = ({
66
66
  }, rest), /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, columnsArray.map(i => /*#__PURE__*/React.createElement("th", {
67
67
  key: i
68
68
  }, headers ? /*#__PURE__*/React.createElement("div", {
69
- className: "cds--table-header-label"
69
+ className: `${prefix}--table-header-label`
70
70
  }, headers[i]?.header) : _span2 || (_span2 = /*#__PURE__*/React.createElement("span", null)))))), /*#__PURE__*/React.createElement("tbody", null, rows)));
71
71
  };
72
72
  DataTableSkeleton.propTypes = {
@@ -171,7 +171,7 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
171
171
  // behavior by explicitly setting preventCloseOnClickOutside to false,
172
172
  // rather than just leaving it undefined.
173
173
  !passiveModal && preventCloseOnClickOutside === false;
174
- if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus) && innerModal.current && !innerModal.current.contains(target)) {
174
+ if (shouldCloseOnOutsideClick && target instanceof Node && !wrapFocus.elementOrParentIsFloatingMenu(target, selectorsFloatingMenus, prefix) && innerModal.current && !innerModal.current.contains(target)) {
175
175
  onRequestClose(evt);
176
176
  }
177
177
  }
@@ -198,7 +198,8 @@ const ModalDialog = /*#__PURE__*/React.forwardRef(function ModalDialog({
198
198
  endTrapNode,
199
199
  currentActiveNode,
200
200
  oldActiveNode,
201
- selectorsFloatingMenus
201
+ selectorsFloatingMenus,
202
+ prefix
202
203
  });
203
204
  if (wrapFocusTimeout.current) {
204
205
  clearTimeout(wrapFocusTimeout.current);
@@ -511,7 +511,7 @@ function ActionableNotification({
511
511
  const focusTrapWithoutSentinels = focusTrapWithoutSentinelsFlag || deprecatedFlag;
512
512
  useIsomorphicEffect.default(() => {
513
513
  if (hasFocus && role === 'alertdialog') {
514
- const button = document.querySelector('button.cds--actionable-notification__action-button');
514
+ const button = document.querySelector(`button.${prefix}--actionable-notification__action-button`);
515
515
  button?.focus();
516
516
  }
517
517
  });
@@ -534,7 +534,8 @@ function ActionableNotification({
534
534
  startTrapNode,
535
535
  endTrapNode,
536
536
  currentActiveNode,
537
- oldActiveNode
537
+ oldActiveNode,
538
+ prefix
538
539
  });
539
540
  }
540
541
  }
@@ -118,8 +118,8 @@ forwardRef) {
118
118
  // If a value is not set via a custom property, provide a default value that matches the
119
119
  // default values defined in the sass style file
120
120
  const getStyle = window.getComputedStyle(popover.current, null);
121
- const offsetProperty = getStyle.getPropertyValue('--cds-popover-offset');
122
- const caretProperty = getStyle.getPropertyValue('--cds-popover-caret-height');
121
+ const offsetProperty = getStyle.getPropertyValue(`--${prefix}-popover-offset`);
122
+ const caretProperty = getStyle.getPropertyValue(`--${prefix}-popover-caret-height`);
123
123
 
124
124
  // Handle if the property values are in px or rem.
125
125
  // We want to store just the base number value without a unit suffix
@@ -278,7 +278,8 @@ const FloatingMenu = ({
278
278
  startTrapNode: startSentinelRef.current,
279
279
  endTrapNode: endSentinelRef.current,
280
280
  currentActiveNode: relatedTarget,
281
- oldActiveNode: target
281
+ oldActiveNode: target,
282
+ prefix
282
283
  });
283
284
  }
284
285
  };
@@ -14,12 +14,12 @@
14
14
  * @returns {boolean} Whether the node or one of its ancestors is in a floating
15
15
  * menu.
16
16
  */
17
- export declare const elementOrParentIsFloatingMenu: (node: Node, selectorsFloatingMenus?: string[]) => boolean;
17
+ export declare const elementOrParentIsFloatingMenu: (node: Node, selectorsFloatingMenus?: string[], prefix?: string) => boolean;
18
18
  /**
19
19
  * Ensures the focus is kept within the given container by implementing
20
20
  * "focus-wrap" behavior.
21
21
  */
22
- export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, currentActiveNode, oldActiveNode, selectorsFloatingMenus, }: {
22
+ export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, currentActiveNode, oldActiveNode, selectorsFloatingMenus, prefix, }: {
23
23
  /** The DOM node of the container. */
24
24
  bodyNode: HTMLElement | null;
25
25
  /** The start sentinel node for focus trapping. */
@@ -32,6 +32,8 @@ export declare const wrapFocus: ({ bodyNode, startTrapNode, endTrapNode, current
32
32
  oldActiveNode: HTMLElement;
33
33
  /** CSS selectors for floating menus. */
34
34
  selectorsFloatingMenus?: string[];
35
+ /** Classname prefix for Carbon selectors. */
36
+ prefix?: string;
35
37
  }) => void;
36
38
  /**
37
39
  * Ensures the focus is kept in the given container, implementing "focus-wrap"
@@ -32,9 +32,9 @@ const DOCUMENT_POSITION_BROAD_FOLLOWING = typeof Node !== 'undefined' ? Node.DOC
32
32
  * @returns {boolean} Whether the node or one of its ancestors is in a floating
33
33
  * menu.
34
34
  */
35
- const elementOrParentIsFloatingMenu = (node, selectorsFloatingMenus = []) => {
35
+ const elementOrParentIsFloatingMenu = (node, selectorsFloatingMenus = [], prefix = 'cds') => {
36
36
  if (node instanceof Element && typeof node.closest === 'function') {
37
- const allSelectorsFloatingMenus = ['.cds--overflow-menu-options', '.cds--tooltip', '.flatpickr-calendar', ...selectorsFloatingMenus];
37
+ const allSelectorsFloatingMenus = [`.${prefix}--overflow-menu-options`, `.${prefix}--tooltip`, '.flatpickr-calendar', ...selectorsFloatingMenus];
38
38
  return allSelectorsFloatingMenus.some(selector => !!node.closest(selector));
39
39
  }
40
40
  return false;
@@ -50,9 +50,10 @@ const wrapFocus = ({
50
50
  endTrapNode,
51
51
  currentActiveNode,
52
52
  oldActiveNode,
53
- selectorsFloatingMenus
53
+ selectorsFloatingMenus,
54
+ prefix = 'cds'
54
55
  }) => {
55
- if (bodyNode && currentActiveNode && oldActiveNode && !bodyNode.contains(currentActiveNode) && !elementOrParentIsFloatingMenu(currentActiveNode, selectorsFloatingMenus)) {
56
+ if (bodyNode && currentActiveNode && oldActiveNode && !bodyNode.contains(currentActiveNode) && !elementOrParentIsFloatingMenu(currentActiveNode, selectorsFloatingMenus, prefix)) {
56
57
  const comparisonResult = oldActiveNode.compareDocumentPosition(currentActiveNode);
57
58
  if (currentActiveNode === startTrapNode || comparisonResult & DOCUMENT_POSITION_BROAD_PRECEDING) {
58
59
  const tabbableElement = Array.from(bodyNode.querySelectorAll(navigation.selectorTabbable)).reverse().find(({
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.97.0-rc.0",
4
+ "version": "1.97.0",
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.32.0",
56
- "@carbon/icons-react": "^11.70.0",
57
- "@carbon/layout": "^11.43.0",
58
- "@carbon/styles": "^1.96.0-rc.0",
59
- "@carbon/utilities": "^0.12.0",
55
+ "@carbon/feature-flags": ">=0.32.0",
56
+ "@carbon/icons-react": "^11.71.0",
57
+ "@carbon/layout": "^11.44.0",
58
+ "@carbon/styles": "^1.96.0",
59
+ "@carbon/utilities": "^0.13.0",
60
60
  "@floating-ui/react": "^0.27.4",
61
61
  "@ibm/telemetry-js": "^1.5.0",
62
62
  "classnames": "2.5.1",
@@ -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.64.0-rc.0",
83
+ "@carbon/themes": "^11.64.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": "87ff7d321ab5e0f7147383b2a71f43936b7e34c1"
142
+ "gitHead": "4a42de3036ca693bf2c6477e917824982fafd7af"
143
143
  }