@carbon/react 1.50.0 → 1.51.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.
Files changed (44) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +844 -926
  2. package/README.md +19 -0
  3. package/es/components/AiSkeleton/AiSkeletonIcon.d.ts +32 -0
  4. package/es/components/AiSkeleton/AiSkeletonPlaceholder.d.ts +24 -0
  5. package/es/components/AiSkeleton/AiSkeletonText.d.ts +55 -0
  6. package/es/components/AiSkeleton/index.d.ts +10 -0
  7. package/es/components/ComposedModal/ComposedModal.js +32 -8
  8. package/es/components/Copy/Copy.js +1 -1
  9. package/es/components/DataTable/DataTable.d.ts +2 -2
  10. package/es/components/DataTable/TableToolbarSearch.d.ts +11 -38
  11. package/es/components/DataTable/TableToolbarSearch.js +1 -1
  12. package/es/components/Modal/Modal.js +25 -6
  13. package/es/components/MultiSelect/MultiSelect.d.ts +4 -0
  14. package/es/components/MultiSelect/MultiSelect.js +10 -1
  15. package/es/components/NumberInput/NumberInput.js +1 -1
  16. package/es/components/PaginationNav/PaginationNav.d.ts +45 -0
  17. package/es/components/PaginationNav/PaginationNav.js +24 -25
  18. package/es/components/PaginationNav/index.d.ts +9 -0
  19. package/es/components/Tabs/Tabs.js +2 -1
  20. package/es/components/Tile/Tile.d.ts +2 -2
  21. package/es/components/Tile/Tile.js +2 -2
  22. package/es/index.js +1 -1
  23. package/lib/components/AiSkeleton/AiSkeletonIcon.d.ts +32 -0
  24. package/lib/components/AiSkeleton/AiSkeletonPlaceholder.d.ts +24 -0
  25. package/lib/components/AiSkeleton/AiSkeletonText.d.ts +55 -0
  26. package/lib/components/AiSkeleton/index.d.ts +10 -0
  27. package/lib/components/ComposedModal/ComposedModal.js +32 -7
  28. package/lib/components/Copy/Copy.js +1 -1
  29. package/lib/components/DataTable/DataTable.d.ts +2 -2
  30. package/lib/components/DataTable/TableToolbarSearch.d.ts +11 -38
  31. package/lib/components/DataTable/TableToolbarSearch.js +1 -1
  32. package/lib/components/Modal/Modal.js +25 -5
  33. package/lib/components/MultiSelect/MultiSelect.d.ts +4 -0
  34. package/lib/components/MultiSelect/MultiSelect.js +10 -1
  35. package/lib/components/NumberInput/NumberInput.js +1 -1
  36. package/lib/components/PaginationNav/PaginationNav.d.ts +45 -0
  37. package/lib/components/PaginationNav/PaginationNav.js +24 -25
  38. package/lib/components/PaginationNav/index.d.ts +9 -0
  39. package/lib/components/Tabs/Tabs.js +2 -1
  40. package/lib/components/Tile/Tile.d.ts +2 -2
  41. package/lib/components/Tile/Tile.js +2 -2
  42. package/lib/index.js +2 -2
  43. package/package.json +4 -4
  44. package/scss/components/skeleton-styles/_ai-skeleton-styles.scss +9 -0
@@ -82,6 +82,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
82
82
  sortItems = sorting.defaultSortItems,
83
83
  compareItems = sorting.defaultCompareItems,
84
84
  clearSelectionText = 'To clear selection, press Delete or Backspace',
85
+ clearAnnouncement = 'all items have been cleared',
85
86
  clearSelectionDescription = 'Total items selected: ',
86
87
  light,
87
88
  invalid,
@@ -113,6 +114,7 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
113
114
  const [isOpen, setIsOpen] = React.useState(open || false);
114
115
  const [prevOpenProp, setPrevOpenProp] = React.useState(open);
115
116
  const [topItems, setTopItems] = React.useState([]);
117
+ const [itemsCleared, setItemsCleared] = React.useState(false);
116
118
  const {
117
119
  selectedItems: controlledSelectedItems,
118
120
  onItemChange,
@@ -159,7 +161,11 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
159
161
  clearSelection();
160
162
  e.stopPropagation();
161
163
  }
164
+ if (!isOpen && match.match(e, keys.Delete) && selectedItems.length > 0) {
165
+ setItemsCleared(true);
166
+ }
162
167
  if ((match.match(e, keys.Space) || match.match(e, keys.ArrowDown) || match.match(e, keys.Enter)) && !isOpen) {
168
+ setItemsCleared(false);
163
169
  setIsOpenWrapper(true);
164
170
  }
165
171
  }
@@ -394,7 +400,10 @@ const MultiSelect = /*#__PURE__*/React__default["default"].forwardRef((_ref, ref
394
400
  }, itemToElement ? /*#__PURE__*/React__default["default"].createElement(ItemToElement, _rollupPluginBabelHelpers["extends"]({
395
401
  key: itemProps.id
396
402
  }, item)) : itemText)));
397
- }))), !inline && !invalid && !warn && helperText && /*#__PURE__*/React__default["default"].createElement("div", {
403
+ })), itemsCleared && /*#__PURE__*/React__default["default"].createElement("span", {
404
+ "aria-live": "assertive",
405
+ "aria-label": clearAnnouncement
406
+ })), !inline && !invalid && !warn && helperText && /*#__PURE__*/React__default["default"].createElement("div", {
398
407
  id: helperId,
399
408
  className: helperClasses
400
409
  }, helperText));
@@ -140,7 +140,7 @@ const NumberInput = /*#__PURE__*/React__default["default"].forwardRef(function N
140
140
  return;
141
141
  }
142
142
  const state = {
143
- value: event.target.value,
143
+ value: Number(event.target.value),
144
144
  direction: value < event.target.value ? 'up' : 'down'
145
145
  };
146
146
  setValue(state.value);
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import React from 'react';
8
+ interface PaginationNavProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onChange'> {
9
+ /**
10
+ * Additional CSS class names.
11
+ */
12
+ className?: string;
13
+ /**
14
+ * If true, the '...' pagination overflow will not render page links between the first and last rendered buttons.
15
+ * Set this to true if you are having performance problems with large data sets.
16
+ */
17
+ disableOverflow?: boolean;
18
+ /**
19
+ * The number of items to be shown.
20
+ */
21
+ itemsShown?: number;
22
+ /**
23
+ * Whether user should be able to loop through the items when reaching first / last.
24
+ */
25
+ loop?: boolean;
26
+ /**
27
+ * The callback function called when the current page changes.
28
+ */
29
+ onChange?: (data: number) => void;
30
+ /**
31
+ * The index of current page.
32
+ */
33
+ page?: number;
34
+ /**
35
+ * The total number of items.
36
+ */
37
+ totalItems?: number;
38
+ /**
39
+ * Specify a custom translation function that takes in a message identifier
40
+ * and returns the localized string for the message
41
+ */
42
+ translateWithId?: (id: string) => string;
43
+ }
44
+ declare const PaginationNav: React.ForwardRefExoticComponent<PaginationNavProps & React.RefAttributes<HTMLElement>>;
45
+ export default PaginationNav;
@@ -37,23 +37,23 @@ function translateWithId(messageId) {
37
37
 
38
38
  // https://reactjs.org/docs/hooks-faq.html#how-to-get-the-previous-props-or-state
39
39
  function usePrevious(value) {
40
- const ref = React.useRef();
40
+ const ref = React.useRef(null);
41
41
  React.useEffect(() => {
42
42
  ref.current = value;
43
43
  });
44
44
  return ref.current;
45
45
  }
46
- function getCuts(page, totalItems, itemsThatFit) {
46
+ function calculateCuts(page, totalItems, itemsDisplayedOnPage) {
47
47
  let splitPoint = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
48
- if (itemsThatFit >= totalItems) {
48
+ if (itemsDisplayedOnPage >= totalItems) {
49
49
  return {
50
50
  front: 0,
51
51
  back: 0
52
52
  };
53
53
  }
54
- const split = splitPoint || Math.ceil(itemsThatFit / 2) - 1;
54
+ const split = splitPoint || Math.ceil(itemsDisplayedOnPage / 2) - 1;
55
55
  let frontHidden = page + 1 - split;
56
- let backHidden = totalItems - page - (itemsThatFit - split) + 1;
56
+ let backHidden = totalItems - page - (itemsDisplayedOnPage - split) + 1;
57
57
  if (frontHidden <= 1) {
58
58
  backHidden -= frontHidden <= 0 ? Math.abs(frontHidden) + 1 : 0;
59
59
  frontHidden = 0;
@@ -103,15 +103,15 @@ function PaginationItem(_ref2) {
103
103
  }),
104
104
  onClick: onClick,
105
105
  "data-page": page,
106
- "aria-current": isActive ? 'page' : null
106
+ "aria-current": isActive ? 'page' : undefined
107
107
  }, /*#__PURE__*/React__default["default"].createElement("span", {
108
108
  className: `${prefix}--pagination-nav__accessibility-label`
109
109
  }, isActive ? `${t('carbon.pagination-nav.active')}, ${itemLabel}` : itemLabel), page));
110
110
  }
111
111
  function PaginationOverflow(_ref3) {
112
112
  let {
113
- fromIndex,
114
- count,
113
+ fromIndex = NaN,
114
+ count = NaN,
115
115
  onSelect,
116
116
  // eslint-disable-next-line react/prop-types
117
117
  disableOverflow,
@@ -145,7 +145,7 @@ function PaginationOverflow(_ref3) {
145
145
  "aria-label": `Select ${t('carbon.pagination-nav.item')} number`,
146
146
  onChange: e => {
147
147
  const index = Number(e.target.value);
148
- onSelect(index);
148
+ onSelect?.(index);
149
149
  }
150
150
  }, _option || (_option = /*#__PURE__*/React__default["default"].createElement("option", {
151
151
  value: "",
@@ -165,7 +165,7 @@ function PaginationOverflow(_ref3) {
165
165
  page: fromIndex + 1,
166
166
  translateWithId: t,
167
167
  onClick: () => {
168
- onSelect(fromIndex);
168
+ onSelect?.(fromIndex);
169
169
  }
170
170
  });
171
171
  }
@@ -175,7 +175,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
175
175
  let {
176
176
  className,
177
177
  onChange = () => {},
178
- totalItems,
178
+ totalItems = NaN,
179
179
  disableOverflow,
180
180
  itemsShown = 10,
181
181
  page = 0,
@@ -184,8 +184,8 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
184
184
  ...rest
185
185
  } = _ref4;
186
186
  const [currentPage, setCurrentPage] = React.useState(page);
187
- const [itemsThatFit, setItemsThatFit] = React.useState(itemsShown >= 4 ? itemsShown : 4);
188
- const [cuts, setCuts] = React.useState(getCuts(currentPage, totalItems, itemsThatFit));
187
+ const [itemsDisplayedOnPage, setItemsDisplayedOnPage] = React.useState(itemsShown >= 4 ? itemsShown : 4);
188
+ const [cuts, setCuts] = React.useState(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage));
189
189
  const prevPage = usePrevious(currentPage);
190
190
  const prefix = usePrefix.usePrefix();
191
191
  const [isOverflowDisabled, setIsOverFlowDisabled] = React.useState(disableOverflow);
@@ -216,7 +216,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
216
216
  }
217
217
  }
218
218
  function pageWouldBeHidden(page) {
219
- const startOffset = itemsThatFit <= 4 && page > 1 ? 0 : 1;
219
+ const startOffset = itemsDisplayedOnPage <= 4 && page > 1 ? 0 : 1;
220
220
  const wouldBeHiddenInFront = page >= startOffset && page <= cuts.front;
221
221
  const wouldBeHiddenInBack = page >= totalItems - cuts.back - 1 && page <= totalItems - 2;
222
222
  return wouldBeHiddenInFront || wouldBeHiddenInBack;
@@ -229,20 +229,20 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
229
229
 
230
230
  // re-calculate cuts if props.totalItems or props.itemsShown change
231
231
  React.useEffect(() => {
232
- setItemsThatFit(itemsShown >= 4 ? itemsShown : 4);
233
- setCuts(getCuts(currentPage, totalItems, itemsShown));
232
+ setItemsDisplayedOnPage(itemsShown >= 4 ? itemsShown : 4);
233
+ setCuts(calculateCuts(currentPage, totalItems, itemsShown));
234
234
  }, [totalItems, itemsShown]); // eslint-disable-line react-hooks/exhaustive-deps
235
235
 
236
236
  // update cuts if necessary whenever currentPage changes
237
237
  React.useEffect(() => {
238
238
  if (pageWouldBeHidden(currentPage)) {
239
- const delta = currentPage - prevPage || 0;
239
+ const delta = currentPage - (prevPage || 0);
240
240
  if (delta > 0) {
241
- const splitPoint = itemsThatFit - 3;
242
- setCuts(getCuts(currentPage, totalItems, itemsThatFit, splitPoint));
241
+ const splitPoint = itemsDisplayedOnPage - 3;
242
+ setCuts(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage, splitPoint));
243
243
  } else {
244
- const splitPoint = itemsThatFit > 4 ? 2 : 1;
245
- setCuts(getCuts(currentPage, totalItems, itemsThatFit, splitPoint));
244
+ const splitPoint = itemsDisplayedOnPage > 4 ? 2 : 1;
245
+ setCuts(calculateCuts(currentPage, totalItems, itemsDisplayedOnPage, splitPoint));
246
246
  }
247
247
  }
248
248
  }, [currentPage]); // eslint-disable-line react-hooks/exhaustive-deps
@@ -253,7 +253,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
253
253
  const classNames = cx__default["default"](`${prefix}--pagination-nav`, className);
254
254
  const backwardButtonDisabled = !loop && currentPage === 0;
255
255
  const forwardButtonDisabled = !loop && currentPage === totalItems - 1;
256
- const startOffset = itemsThatFit <= 4 && currentPage > 1 ? 0 : 1;
256
+ const startOffset = itemsDisplayedOnPage <= 4 && currentPage > 1 ? 0 : 1;
257
257
  return /*#__PURE__*/React__default["default"].createElement("nav", _rollupPluginBabelHelpers["extends"]({
258
258
  className: classNames,
259
259
  ref: ref
@@ -269,7 +269,7 @@ const PaginationNav = /*#__PURE__*/React__default["default"].forwardRef(function
269
269
  }),
270
270
  // render first item if at least 5 items can be displayed or
271
271
  // 4 items can be displayed and the current page is either 0 or 1
272
- (itemsThatFit >= 5 || itemsThatFit <= 4 && currentPage <= 1) && /*#__PURE__*/React__default["default"].createElement(PaginationItem, {
272
+ (itemsDisplayedOnPage >= 5 || itemsDisplayedOnPage <= 4 && currentPage <= 1) && /*#__PURE__*/React__default["default"].createElement(PaginationItem, {
273
273
  page: 1,
274
274
  translateWithId: t,
275
275
  isActive: currentPage === 0,
@@ -411,6 +411,5 @@ PaginationNav.propTypes = {
411
411
  */
412
412
  translateWithId: PropTypes__default["default"].func
413
413
  };
414
- var PaginationNav$1 = PaginationNav;
415
414
 
416
- exports["default"] = PaginationNav$1;
415
+ exports["default"] = PaginationNav;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Copyright IBM Corp. 2020
3
+ *
4
+ * This source code is licensed under the Apache-2.0 license found in the
5
+ * LICENSE file in the root directory of this source tree.
6
+ */
7
+ import PaginationNav from './PaginationNav';
8
+ export default PaginationNav;
9
+ export { PaginationNav };
@@ -239,7 +239,8 @@ function TabList(_ref2) {
239
239
  function onKeyDown(event) {
240
240
  if (match.matches(event, [keys.ArrowRight, keys.ArrowLeft, keys.Home, keys.End])) {
241
241
  event.preventDefault();
242
- const activeTabs = tabs.current.filter(tab => !tab.disabled);
242
+ const filtredTabs = tabs.current.filter(tab => tab !== null);
243
+ const activeTabs = filtredTabs.filter(tab => !tab.disabled);
243
244
  const currentIndex = activeTabs.indexOf(tabs.current[activation === 'automatic' ? selectedIndex : activeIndex]);
244
245
  const nextIndex = tabs.current.indexOf(activeTabs[getNextIndex(event, activeTabs.length, currentIndex)]);
245
246
  if (activation === 'automatic') {
@@ -180,11 +180,11 @@ export interface TileAboveTheFoldContentProps {
180
180
  */
181
181
  children?: ReactNode;
182
182
  }
183
- export declare const TileAboveTheFoldContent: React.ForwardRefExoticComponent<TileAboveTheFoldContentProps & React.RefAttributes<HTMLSpanElement>>;
183
+ export declare const TileAboveTheFoldContent: React.ForwardRefExoticComponent<TileAboveTheFoldContentProps & React.RefAttributes<HTMLDivElement>>;
184
184
  export interface TileBelowTheFoldContentProps {
185
185
  /**
186
186
  * The child nodes.
187
187
  */
188
188
  children?: ReactNode;
189
189
  }
190
- export declare const TileBelowTheFoldContent: React.ForwardRefExoticComponent<TileBelowTheFoldContentProps & React.RefAttributes<HTMLSpanElement>>;
190
+ export declare const TileBelowTheFoldContent: React.ForwardRefExoticComponent<TileBelowTheFoldContentProps & React.RefAttributes<HTMLDivElement>>;
@@ -614,7 +614,7 @@ const TileAboveTheFoldContent = /*#__PURE__*/React__default["default"].forwardRe
614
614
  children
615
615
  } = _ref5;
616
616
  const prefix = usePrefix.usePrefix();
617
- return /*#__PURE__*/React__default["default"].createElement("span", {
617
+ return /*#__PURE__*/React__default["default"].createElement("div", {
618
618
  ref: ref,
619
619
  className: `${prefix}--tile-content__above-the-fold`
620
620
  }, children);
@@ -631,7 +631,7 @@ const TileBelowTheFoldContent = /*#__PURE__*/React__default["default"].forwardRe
631
631
  children
632
632
  } = _ref6;
633
633
  const prefix = usePrefix.usePrefix();
634
- return /*#__PURE__*/React__default["default"].createElement("span", {
634
+ return /*#__PURE__*/React__default["default"].createElement("div", {
635
635
  ref: ref,
636
636
  className: `${prefix}--tile-content__below-the-fold`
637
637
  }, children);
package/lib/index.js CHANGED
@@ -76,6 +76,7 @@ var OrderedList = require('./components/OrderedList/OrderedList.js');
76
76
  var index$9 = require('./components/OverflowMenu/index.js');
77
77
  var OverflowMenuItem = require('./components/OverflowMenuItem/OverflowMenuItem.js');
78
78
  var Pagination_Skeleton = require('./components/Pagination/Pagination.Skeleton.js');
79
+ var PaginationNav = require('./components/PaginationNav/PaginationNav.js');
79
80
  var PrimaryButton = require('./components/PrimaryButton/PrimaryButton.js');
80
81
  var ProgressIndicator_Skeleton = require('./components/ProgressIndicator/ProgressIndicator.Skeleton.js');
81
82
  var ProgressIndicator = require('./components/ProgressIndicator/ProgressIndicator.js');
@@ -222,7 +223,6 @@ var TableToolbarMenu = require('./components/DataTable/TableToolbarMenu.js');
222
223
  var FilterableMultiSelect = require('./components/MultiSelect/FilterableMultiSelect.js');
223
224
  var MultiSelect = require('./components/MultiSelect/MultiSelect.js');
224
225
  var Pagination$1 = require('./components/Pagination/Pagination.js');
225
- var PaginationNav = require('./components/PaginationNav/PaginationNav.js');
226
226
  var ControlledPasswordInput = require('./components/TextInput/ControlledPasswordInput.js');
227
227
  var PasswordInput = require('./components/TextInput/PasswordInput.js');
228
228
  var RadioTile = require('./components/RadioTile/RadioTile.js');
@@ -310,6 +310,7 @@ exports.OrderedList = OrderedList["default"];
310
310
  exports.OverflowMenu = index$9["default"];
311
311
  exports.OverflowMenuItem = OverflowMenuItem["default"];
312
312
  exports.PaginationSkeleton = Pagination_Skeleton["default"];
313
+ exports.PaginationNav = PaginationNav["default"];
313
314
  exports.PrimaryButton = PrimaryButton["default"];
314
315
  exports.ProgressIndicatorSkeleton = ProgressIndicator_Skeleton["default"];
315
316
  exports.ProgressIndicator = ProgressIndicator.ProgressIndicator;
@@ -488,7 +489,6 @@ exports.TableToolbarMenu = TableToolbarMenu["default"];
488
489
  exports.FilterableMultiSelect = FilterableMultiSelect["default"];
489
490
  exports.MultiSelect = MultiSelect["default"];
490
491
  exports.Pagination = Pagination$1["default"];
491
- exports.PaginationNav = PaginationNav["default"];
492
492
  exports.ControlledPasswordInput = ControlledPasswordInput["default"];
493
493
  exports.PasswordInput = PasswordInput["default"];
494
494
  exports.RadioTile = RadioTile["default"];
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.50.0",
4
+ "version": "1.51.0",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -51,7 +51,7 @@
51
51
  "@carbon/feature-flags": "^0.16.0",
52
52
  "@carbon/icons-react": "^11.36.0",
53
53
  "@carbon/layout": "^11.20.0",
54
- "@carbon/styles": "^1.50.0",
54
+ "@carbon/styles": "^1.51.0",
55
55
  "@ibm/telemetry-js": "^1.2.0",
56
56
  "classnames": "2.5.1",
57
57
  "copy-to-clipboard": "^3.3.1",
@@ -79,7 +79,7 @@
79
79
  "@babel/preset-react": "^7.22.3",
80
80
  "@babel/preset-typescript": "^7.21.5",
81
81
  "@carbon/test-utils": "^10.30.0",
82
- "@carbon/themes": "^11.31.0",
82
+ "@carbon/themes": "^11.32.0",
83
83
  "@rollup/plugin-babel": "^6.0.0",
84
84
  "@rollup/plugin-commonjs": "^25.0.0",
85
85
  "@rollup/plugin-node-resolve": "^15.0.0",
@@ -139,5 +139,5 @@
139
139
  "**/*.scss",
140
140
  "**/*.css"
141
141
  ],
142
- "gitHead": "eb7d66891262363368b48211b9fd1caa78fa58f9"
142
+ "gitHead": "957667fa7f197b544f6cb336814daa7074daaaee"
143
143
  }
@@ -0,0 +1,9 @@
1
+ // Code generated by @carbon/react. DO NOT EDIT.
2
+ //
3
+ // Copyright IBM Corp. 2018, 2023
4
+ //
5
+ // This source code is licensed under the Apache-2.0 license found in the
6
+ // LICENSE file in the root directory of this source tree.
7
+ //
8
+
9
+ @forward '@carbon/styles/scss/components/skeleton-styles/ai-skeleton-styles';