@carbon/react 1.108.0 → 1.109.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.
@@ -106,8 +106,10 @@ const DataTable = (props) => {
106
106
  const getHeaderProps = ({ header, onClick, isSortable: headerIsSortable, ...rest }) => {
107
107
  const { sortDirection, sortHeaderKey } = state;
108
108
  const { key, slug, decorator } = header;
109
+ const id = typeof rest.id === "string" && rest.id.length ? rest.id : getHeaderId(key);
109
110
  return {
110
111
  ...rest,
112
+ id,
111
113
  key,
112
114
  sortDirection,
113
115
  isSortable: headerIsSortable ?? header.isSortable ?? isSortable,
@@ -207,13 +209,10 @@ const DataTable = (props) => {
207
209
  onSelect: require_events.composeEventHandlers([handleSelectAll, onClick])
208
210
  };
209
211
  };
210
- const getToolbarProps = (props) => {
211
- const isSmall = size === "xs" || size === "sm";
212
- return {
213
- ...props,
214
- size: isSmall ? "sm" : void 0
215
- };
216
- };
212
+ const getToolbarProps = (props) => ({
213
+ ...props,
214
+ size: size === "xs" || size === "sm" ? size : void 0
215
+ });
217
216
  const getBatchActionProps = (props) => {
218
217
  const { shouldShowBatchActions } = state;
219
218
  const selectedRowCount = selectedRows.length;
@@ -243,10 +242,12 @@ const DataTable = (props) => {
243
242
  useStaticWidth
244
243
  };
245
244
  };
246
- const getCellProps = ({ cell: { hasAILabelHeader, id }, ...rest }) => {
245
+ const getCellProps = ({ cell: { hasAILabelHeader, id, info: { header } }, headers: customHeaders, ...rest }) => {
246
+ const headers = typeof customHeaders === "string" && customHeaders.length ? customHeaders : getHeaderId(header);
247
247
  return {
248
248
  ...rest,
249
249
  hasAILabelHeader,
250
+ headers,
250
251
  key: id
251
252
  };
252
253
  };
@@ -268,6 +269,7 @@ const DataTable = (props) => {
268
269
  * Generates a prefix for table related IDs.
269
270
  */
270
271
  const getTablePrefix = () => `data-table-${instanceId}`;
272
+ const getHeaderId = (headerKey) => `${getTablePrefix()}__header-${headerKey}`;
271
273
  /**
272
274
  * Generates a new `rowsById` object with updated selection state.
273
275
  */
@@ -1,11 +1,17 @@
1
1
  /**
2
- * Copyright IBM Corp. 2016, 2025
2
+ * Copyright IBM Corp. 2016, 2026
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.
6
6
  */
7
7
  import PropTypes from 'prop-types';
8
8
  import React from 'react';
9
+ export declare const TableToolbarContext: React.Context<{
10
+ size?: "xs" | "sm" | "lg";
11
+ }>;
12
+ export declare const useTableToolbar: () => {
13
+ size?: "xs" | "sm" | "lg";
14
+ };
9
15
  export interface TableToolbarProps extends React.HTMLAttributes<HTMLDivElement> {
10
16
  /**
11
17
  * Specify a label to be read by screen readers on the container node
@@ -24,7 +30,7 @@ export interface TableToolbarProps extends React.HTMLAttributes<HTMLDivElement>
24
30
  /**
25
31
  * `lg` Change the row height of table
26
32
  */
27
- size?: 'sm' | 'lg';
33
+ size?: 'xs' | 'sm' | 'lg';
28
34
  }
29
35
  declare const TableToolbar: {
30
36
  ({ ["aria-label"]: ariaLabel, ariaLabel: deprecatedAriaLabel, children, size, ...rest }: TableToolbarProps): import("react/jsx-runtime").JSX.Element;
@@ -17,30 +17,41 @@ prop_types = require_runtime.__toESM(prop_types);
17
17
  let react_jsx_runtime = require("react/jsx-runtime");
18
18
  //#region src/components/DataTable/TableToolbar.tsx
19
19
  /**
20
- * Copyright IBM Corp. 2016, 2025
20
+ * Copyright IBM Corp. 2016, 2026
21
21
  *
22
22
  * This source code is licensed under the Apache-2.0 license found in the
23
23
  * LICENSE file in the root directory of this source tree.
24
24
  */
25
+ const TableToolbarContext = (0, react.createContext)({});
26
+ const useTableToolbar = () => (0, react.useContext)(TableToolbarContext);
25
27
  const TableToolbar = ({ ["aria-label"]: ariaLabel = "data table toolbar", ariaLabel: deprecatedAriaLabel, children, size, ...rest }) => {
26
28
  const prefix = require_usePrefix.usePrefix();
27
29
  const className = (0, classnames.default)({
28
30
  [`${prefix}--table-toolbar`]: true,
29
- [`${prefix}--table-toolbar--${size}`]: size
31
+ [`${prefix}--table-toolbar--${size}`]: size,
32
+ [`${prefix}--layout--size-${size}`]: size
30
33
  });
31
- return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
32
- role: "group",
33
- "aria-label": deprecatedAriaLabel || ariaLabel,
34
- ...rest,
35
- className,
36
- children
34
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TableToolbarContext.Provider, {
35
+ value: { size },
36
+ children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("section", {
37
+ role: "group",
38
+ "aria-label": deprecatedAriaLabel || ariaLabel,
39
+ ...rest,
40
+ className,
41
+ children
42
+ })
37
43
  });
38
44
  };
39
45
  TableToolbar.propTypes = {
40
46
  ["aria-label"]: prop_types.default.string,
41
47
  ariaLabel: require_deprecate.deprecate(prop_types.default.string, "This prop syntax has been deprecated. Please use the new `aria-label`."),
42
48
  children: prop_types.default.node,
43
- size: prop_types.default.oneOf(["sm", "lg"])
49
+ size: prop_types.default.oneOf([
50
+ "xs",
51
+ "sm",
52
+ "lg"
53
+ ])
44
54
  };
45
55
  //#endregion
46
56
  exports.default = TableToolbar;
57
+ exports.useTableToolbar = useTableToolbar;
@@ -8,7 +8,7 @@ import PropTypes from 'prop-types';
8
8
  import { OverflowMenuProps } from '../OverflowMenu';
9
9
  export type TableToolbarMenuProps = OverflowMenuProps;
10
10
  declare const TableToolbarMenu: {
11
- ({ className, renderIcon, iconDescription, children, menuOptionsClass, ...rest }: TableToolbarMenuProps): import("react/jsx-runtime").JSX.Element;
11
+ ({ className, renderIcon, iconDescription, children, menuOptionsClass, size: sizeProp, ...rest }: TableToolbarMenuProps): import("react/jsx-runtime").JSX.Element;
12
12
  propTypes: {
13
13
  children: PropTypes.Validator<NonNullable<PropTypes.ReactNodeLike>>;
14
14
  /**
@@ -27,6 +27,10 @@ declare const TableToolbarMenu: {
27
27
  * A component used to render an icon.
28
28
  */
29
29
  renderIcon: PropTypes.Requireable<object>;
30
+ /**
31
+ * Specify the size of the ToolbarMenu.
32
+ */
33
+ size: PropTypes.Requireable<string>;
30
34
  };
31
35
  };
32
36
  export default TableToolbarMenu;
@@ -7,6 +7,7 @@
7
7
 
8
8
  const require_runtime = require("../../_virtual/_rolldown/runtime.js");
9
9
  const require_usePrefix = require("../../internal/usePrefix.js");
10
+ const require_TableToolbar = require("./TableToolbar.js");
10
11
  const require_index = require("../OverflowMenu/index.js");
11
12
  let classnames = require("classnames");
12
13
  classnames = require_runtime.__toESM(classnames);
@@ -24,13 +25,16 @@ let _carbon_icons_react = require("@carbon/icons-react");
24
25
  * LICENSE file in the root directory of this source tree.
25
26
  */
26
27
  const defaultIconDescription = "Settings";
27
- const TableToolbarMenu = ({ className, renderIcon = _carbon_icons_react.Settings, iconDescription = defaultIconDescription, children, menuOptionsClass, ...rest }) => {
28
+ const TableToolbarMenu = ({ className, renderIcon = _carbon_icons_react.Settings, iconDescription = defaultIconDescription, children, menuOptionsClass, size: sizeProp, ...rest }) => {
29
+ const toolbarContext = require_TableToolbar.useTableToolbar();
30
+ const size = sizeProp ?? toolbarContext.size;
28
31
  const prefix = require_usePrefix.usePrefix();
29
32
  return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_index.default, {
30
33
  renderIcon,
31
34
  className: (0, classnames.default)(className, `${prefix}--toolbar-action ${prefix}--overflow-menu`),
32
35
  iconDescription,
33
36
  menuOptionsClass: (0, classnames.default)(menuOptionsClass, `${prefix}--toolbar-action__menu`),
37
+ size,
34
38
  flipped: true,
35
39
  ...rest,
36
40
  children
@@ -41,7 +45,13 @@ TableToolbarMenu.propTypes = {
41
45
  className: prop_types.default.string,
42
46
  iconDescription: prop_types.default.string,
43
47
  menuOptionsClass: prop_types.default.string,
44
- renderIcon: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.object])
48
+ renderIcon: prop_types.default.oneOfType([prop_types.default.func, prop_types.default.object]),
49
+ size: prop_types.default.oneOf([
50
+ "xs",
51
+ "sm",
52
+ "md",
53
+ "lg"
54
+ ])
45
55
  };
46
56
  //#endregion
47
57
  exports.default = TableToolbarMenu;
@@ -13,7 +13,7 @@ declare const translationIds: {
13
13
  readonly 'carbon.table.toolbar.search.placeholder': "carbon.table.toolbar.search.placeholder";
14
14
  };
15
15
  type TranslationKey = keyof typeof translationIds;
16
- type ExcludedInheritedProps = 'defaultValue' | 'labelText' | 'onBlur' | 'onChange' | 'onExpand' | 'onFocus' | 'tabIndex' | 'size';
16
+ type ExcludedInheritedProps = 'defaultValue' | 'labelText' | 'onBlur' | 'onChange' | 'onExpand' | 'onFocus' | 'tabIndex';
17
17
  export type TableToolbarSearchHandleExpand = (event: FocusEvent<HTMLInputElement>, newValue?: boolean) => void;
18
18
  /**
19
19
  * @deprecated Passing `''` as the event sentinel is legacy compatibility
@@ -69,14 +69,10 @@ export interface TableToolbarSearchProps extends Omit<SearchProps, ExcludedInher
69
69
  * Provide an optional className for the overall container of the Search
70
70
  */
71
71
  searchContainerClass?: string;
72
- /**
73
- * Specify the size of the Search
74
- */
75
- size?: 'sm' | 'md' | 'lg';
76
72
  tabIndex?: number | string;
77
73
  }
78
74
  declare const TableToolbarSearch: {
79
- ({ className, searchContainerClass, onChange: onChangeProp, onClear, translateWithId: t, placeholder, labelText, expanded: expandedProp, defaultExpanded, defaultValue, disabled, onExpand, persistent, id, onBlur, onFocus, size, tabIndex, ...rest }: TableToolbarSearchProps): import("react/jsx-runtime").JSX.Element;
75
+ ({ className, searchContainerClass, onChange: onChangeProp, onClear, translateWithId: t, placeholder, labelText, expanded: expandedProp, defaultExpanded, defaultValue, disabled, onExpand, persistent, id, onBlur, onFocus, size: sizeProp, tabIndex, ...rest }: TableToolbarSearchProps): import("react/jsx-runtime").JSX.Element;
80
76
  propTypes: {
81
77
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
82
78
  /**
@@ -10,6 +10,7 @@ const require_usePrefix = require("../../internal/usePrefix.js");
10
10
  const require_useId = require("../../internal/useId.js");
11
11
  const require_noopFn = require("../../internal/noopFn.js");
12
12
  const require_index = require("../Search/index.js");
13
+ const require_TableToolbar = require("./TableToolbar.js");
13
14
  let classnames = require("classnames");
14
15
  classnames = require_runtime.__toESM(classnames);
15
16
  let react = require("react");
@@ -35,7 +36,9 @@ const defaultTranslations = {
35
36
  const defaultTranslateWithId = (messageId) => {
36
37
  return defaultTranslations[messageId];
37
38
  };
38
- const TableToolbarSearch = ({ className, searchContainerClass, onChange: onChangeProp, onClear = require_noopFn.noopFn, translateWithId: t = defaultTranslateWithId, placeholder, labelText, expanded: expandedProp, defaultExpanded, defaultValue, disabled, onExpand, persistent = false, id, onBlur, onFocus, size = "lg", tabIndex = "0", ...rest }) => {
39
+ const TableToolbarSearch = ({ className, searchContainerClass, onChange: onChangeProp, onClear = require_noopFn.noopFn, translateWithId: t = defaultTranslateWithId, placeholder, labelText, expanded: expandedProp, defaultExpanded, defaultValue, disabled, onExpand, persistent = false, id, onBlur, onFocus, size: sizeProp, tabIndex = "0", ...rest }) => {
40
+ const toolbarContext = require_TableToolbar.useTableToolbar();
41
+ const size = sizeProp ?? toolbarContext.size;
39
42
  const { current: controlled } = (0, react.useRef)(expandedProp !== void 0);
40
43
  const [expandedState, setExpandedState] = (0, react.useState)(Boolean(defaultExpanded || defaultValue));
41
44
  const expanded = controlled ? expandedProp : expandedState;
@@ -104,6 +107,7 @@ TableToolbarSearch.propTypes = {
104
107
  placeholder: prop_types.default.string,
105
108
  searchContainerClass: prop_types.default.string,
106
109
  size: prop_types.default.oneOf([
110
+ "xs",
107
111
  "sm",
108
112
  "md",
109
113
  "lg"
@@ -171,11 +171,18 @@ const ModalDialog = react.default.forwardRef(function ModalDialog({ "aria-label"
171
171
  [`${prefix}--modal-container--${size}`]: size,
172
172
  [`${prefix}--modal-container--full-width`]: isFullWidth
173
173
  });
174
- /**
175
- * isScrollable is implicitly dependent on height, when height gets updated
176
- * via `useResizeObserver`, clientHeight and scrollHeight get updated too
177
- */
178
- const isScrollable = !!contentRef.current && contentRef?.current?.scrollHeight > contentRef?.current?.clientHeight;
174
+ const currentScrollHeight = contentRef.current?.scrollHeight || 0;
175
+ const currentClientHeight = contentRef.current?.clientHeight || 0;
176
+ const [isScrollable, setIsScrollable] = (0, react.useState)(currentScrollHeight > currentClientHeight);
177
+ (0, react.useEffect)(() => {
178
+ if (!contentRef.current) {
179
+ setIsScrollable(false);
180
+ return;
181
+ }
182
+ const diff = contentRef.current.scrollHeight - contentRef.current.clientHeight;
183
+ if (diff > 5) setIsScrollable(true);
184
+ else if (diff < -5) setIsScrollable(false);
185
+ }, [currentScrollHeight, currentClientHeight]);
179
186
  const contentClasses = (0, classnames.default)(`${prefix}--modal-content`, {
180
187
  [`${prefix}--modal-scroll-content`]: hasScrollingContent || isScrollable,
181
188
  [`${prefix}--modal-scroll-content--no-fade`]: height <= 300
package/lib/index.d.ts CHANGED
@@ -46,6 +46,7 @@ export * from './components/FormLabel';
46
46
  export * from './components/Grid';
47
47
  export * from './components/Icon/Icon.Skeleton';
48
48
  export * from './components/IdPrefix';
49
+ export { InlineCheckbox } from './components/InlineCheckbox';
49
50
  export * from './components/InlineLoading';
50
51
  export * from './components/Link';
51
52
  export * from './components/ListItem';
package/lib/index.js CHANGED
@@ -83,6 +83,7 @@ const require_TableExpandedRow = require("./components/DataTable/TableExpandedRo
83
83
  const require_TableHead = require("./components/DataTable/TableHead.js");
84
84
  const require_TableHeader = require("./components/DataTable/TableHeader.js");
85
85
  const require_TableRow = require("./components/DataTable/TableRow.js");
86
+ const require_InlineCheckbox = require("./components/InlineCheckbox/InlineCheckbox.js");
86
87
  const require_TableSelectAll = require("./components/DataTable/TableSelectAll.js");
87
88
  const require_RadioButton = require("./components/RadioButton/RadioButton.js");
88
89
  const require_TableSelectRow = require("./components/DataTable/TableSelectRow.js");
@@ -366,6 +367,7 @@ exports.IconSkeleton = require_Icon_Skeleton.default || require_Icon_Skeleton;
366
367
  exports.IconSwitch = require_IconSwitch.default || require_IconSwitch;
367
368
  exports.IconTab = require_Tabs.IconTab;
368
369
  exports.IdPrefix = require_index$13.IdPrefix;
370
+ exports.InlineCheckbox = require_InlineCheckbox.default || require_InlineCheckbox;
369
371
  exports.InlineLoading = require_InlineLoading.default || require_InlineLoading;
370
372
  exports.InlineNotification = require_Notification.InlineNotification;
371
373
  exports.Layer = require_index$8.Layer;
@@ -116,7 +116,10 @@ const FloatingMenu = ({ children, flipped, focusTrap, menuDirection = DIRECTION_
116
116
  position: getComputedStyle(target()).position
117
117
  }
118
118
  });
119
- if (!floatingPosition || floatingPosition.left !== newFloatingPosition.left || floatingPosition.top !== newFloatingPosition.top) setFloatingPosition(newFloatingPosition);
119
+ setFloatingPosition((prev) => {
120
+ if (prev && prev.left === newFloatingPosition.left && prev.top === newFloatingPosition.top) return prev;
121
+ return newFloatingPosition;
122
+ });
120
123
  if (!isAdjustment) {
121
124
  const newMenuSize = menuBody.getBoundingClientRect();
122
125
  if (newMenuSize.width !== menuSize.width || newMenuSize.height !== menuSize.height) updateMenuPosition(true);
@@ -128,8 +131,7 @@ const FloatingMenu = ({ children, flipped, focusTrap, menuDirection = DIRECTION_
128
131
  menuDirection,
129
132
  flipped,
130
133
  target,
131
- updateOrientation,
132
- floatingPosition
134
+ updateOrientation
133
135
  ]);
134
136
  const focusMenuContent = (menuBody) => {
135
137
  const primaryFocusNode = selectorPrimaryFocus ? menuBody.querySelector(selectorPrimaryFocus) : null;
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.108.0",
4
+ "version": "1.109.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": "^1.3.0",
56
- "@carbon/icons-react": "^11.81.0",
56
+ "@carbon/icons-react": "^11.82.0-rc.0",
57
57
  "@carbon/layout": "^11.53.0",
58
- "@carbon/styles": "^1.107.0",
58
+ "@carbon/styles": "^1.108.0-rc.0",
59
59
  "@carbon/utilities": "^0.20.0",
60
60
  "@floating-ui/react": "^0.27.4",
61
61
  "@ibm/telemetry-js": "^1.5.0",
@@ -79,8 +79,8 @@
79
79
  "@babel/preset-react": "^7.27.1",
80
80
  "@babel/preset-typescript": "^7.27.1",
81
81
  "@carbon/test-utils": "^10.41.0",
82
- "@carbon/themes": "^11.74.0",
83
- "@figma/code-connect": "^1.4.2",
82
+ "@carbon/themes": "^11.75.0-rc.0",
83
+ "@figma/code-connect": "^1.4.5",
84
84
  "@stackblitz/sdk": "^1.11.0",
85
85
  "@storybook/addon-a11y": "^10.3.5",
86
86
  "@storybook/addon-docs": "^10.3.5",
@@ -125,5 +125,5 @@
125
125
  "**/*.scss",
126
126
  "**/*.css"
127
127
  ],
128
- "gitHead": "2d98f4ee9914fa44acba58f62599c3f5382acad0"
128
+ "gitHead": "b23ca747c33b76557a54aa88b6df70bc76f55da9"
129
129
  }