@carbon/react 1.53.1 → 1.54.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.
Files changed (86) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +1009 -1096
  2. package/es/components/ComboBox/ComboBox.js +13 -4
  3. package/es/components/ComboButton/index.js +1 -1
  4. package/es/components/ComposedModal/ComposedModal.js +19 -10
  5. package/es/components/DataTable/DataTable.js +1 -1
  6. package/es/components/DataTable/TableBatchAction.d.ts +1 -1
  7. package/es/components/DataTable/TableToolbarMenu.d.ts +5 -1
  8. package/es/components/DataTable/TableToolbarMenu.js +7 -0
  9. package/es/components/DatePicker/DatePicker.d.ts +4 -0
  10. package/es/components/DatePicker/DatePicker.js +37 -0
  11. package/es/components/IconButton/index.d.ts +1 -1
  12. package/es/components/IconButton/index.js +1 -1
  13. package/es/components/ListBox/ListBox.d.ts +8 -0
  14. package/es/components/ListBox/ListBox.js +15 -3
  15. package/es/components/Loading/Loading.d.ts +1 -1
  16. package/es/components/Modal/Modal.js +14 -5
  17. package/es/components/Notification/Notification.js +18 -6
  18. package/es/components/Pagination/Pagination.Skeleton.d.ts +25 -0
  19. package/es/components/Pagination/Pagination.d.ts +102 -0
  20. package/es/components/Pagination/Pagination.js +13 -14
  21. package/es/components/Pagination/index.d.ts +10 -0
  22. package/es/components/Popover/index.d.ts +1 -1
  23. package/es/components/Popover/index.js +175 -108
  24. package/es/components/RadioTile/RadioTile.d.ts +55 -0
  25. package/es/components/RadioTile/RadioTile.js +17 -17
  26. package/es/components/RadioTile/index.d.ts +10 -0
  27. package/es/components/Slug/index.js +23 -2
  28. package/es/components/Stack/HStack.d.ts +10 -0
  29. package/es/components/Stack/HStack.js +23 -0
  30. package/es/components/Stack/Stack.d.ts +1 -1
  31. package/es/components/Stack/Stack.js +2 -2
  32. package/es/components/Stack/VStack.d.ts +10 -0
  33. package/es/components/Stack/{index.js → VStack.js} +1 -8
  34. package/es/components/Stack/index.d.ts +3 -6
  35. package/es/components/TileGroup/TileGroup.js +30 -24
  36. package/es/components/Toggletip/index.d.ts +1 -18
  37. package/es/components/Toggletip/index.js +27 -4
  38. package/es/components/Tooltip/Tooltip.js +23 -5
  39. package/es/index.d.ts +1 -0
  40. package/es/index.js +5 -4
  41. package/es/internal/FloatingMenu.js +26 -5
  42. package/es/internal/wrapFocus.js +51 -1
  43. package/es/tools/createPropAdapter.js +40 -0
  44. package/lib/components/ComboBox/ComboBox.js +13 -4
  45. package/lib/components/ComboButton/index.js +1 -1
  46. package/lib/components/ComposedModal/ComposedModal.js +17 -8
  47. package/lib/components/DataTable/DataTable.js +1 -1
  48. package/lib/components/DataTable/TableBatchAction.d.ts +1 -1
  49. package/lib/components/DataTable/TableToolbarMenu.d.ts +5 -1
  50. package/lib/components/DataTable/TableToolbarMenu.js +7 -0
  51. package/lib/components/DatePicker/DatePicker.d.ts +4 -0
  52. package/lib/components/DatePicker/DatePicker.js +37 -0
  53. package/lib/components/IconButton/index.d.ts +1 -1
  54. package/lib/components/IconButton/index.js +1 -1
  55. package/lib/components/ListBox/ListBox.d.ts +8 -0
  56. package/lib/components/ListBox/ListBox.js +15 -3
  57. package/lib/components/Loading/Loading.d.ts +1 -1
  58. package/lib/components/Modal/Modal.js +14 -5
  59. package/lib/components/Notification/Notification.js +15 -3
  60. package/lib/components/Pagination/Pagination.Skeleton.d.ts +25 -0
  61. package/lib/components/Pagination/Pagination.d.ts +102 -0
  62. package/lib/components/Pagination/Pagination.js +13 -14
  63. package/lib/components/Pagination/index.d.ts +10 -0
  64. package/lib/components/Popover/index.d.ts +1 -1
  65. package/lib/components/Popover/index.js +174 -107
  66. package/lib/components/RadioTile/RadioTile.d.ts +55 -0
  67. package/lib/components/RadioTile/RadioTile.js +17 -17
  68. package/lib/components/RadioTile/index.d.ts +10 -0
  69. package/lib/components/Slug/index.js +23 -2
  70. package/lib/components/Stack/HStack.d.ts +10 -0
  71. package/lib/components/Stack/HStack.js +31 -0
  72. package/lib/components/Stack/Stack.d.ts +1 -1
  73. package/lib/components/Stack/Stack.js +3 -3
  74. package/lib/components/Stack/VStack.d.ts +10 -0
  75. package/lib/components/Stack/{index.js → VStack.js} +0 -8
  76. package/lib/components/Stack/index.d.ts +3 -6
  77. package/lib/components/TileGroup/TileGroup.js +30 -24
  78. package/lib/components/Toggletip/index.d.ts +1 -18
  79. package/lib/components/Toggletip/index.js +27 -4
  80. package/lib/components/Tooltip/Tooltip.js +23 -5
  81. package/lib/index.d.ts +1 -0
  82. package/lib/index.js +15 -14
  83. package/lib/internal/FloatingMenu.js +44 -4
  84. package/lib/internal/wrapFocus.js +51 -0
  85. package/lib/tools/createPropAdapter.js +44 -0
  86. package/package.json +9 -7
@@ -23,6 +23,7 @@ var toggleClass = require('../../tools/toggleClass.js');
23
23
  var requiredIfGivenPropIsTruthy = require('../../prop-types/requiredIfGivenPropIsTruthy.js');
24
24
  var wrapFocus = require('../../internal/wrapFocus.js');
25
25
  var usePrefix = require('../../internal/usePrefix.js');
26
+ var index = require('../FeatureFlags/index.js');
26
27
  var match = require('../../internal/keyboard/match.js');
27
28
  var keys = require('../../internal/keyboard/keys.js');
28
29
 
@@ -125,6 +126,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
125
126
  const button = React.useRef(null);
126
127
  const startSentinel = React.useRef(null);
127
128
  const endSentinel = React.useRef(null);
129
+ const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
128
130
 
129
131
  // Keep track of modal open/close state
130
132
  // and propagate it to the document.body
@@ -142,12 +144,19 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
142
144
  };
143
145
  }, []); // eslint-disable-line react-hooks/exhaustive-deps
144
146
 
145
- function handleKeyDown(evt) {
146
- evt.stopPropagation();
147
- if (match.match(evt, keys.Escape)) {
148
- closeModal(evt);
147
+ function handleKeyDown(event) {
148
+ event.stopPropagation();
149
+ if (match.match(event, keys.Escape)) {
150
+ closeModal(event);
151
+ }
152
+ if (focusTrapWithoutSentinels && open && match.match(event, keys.Tab) && innerModal.current) {
153
+ wrapFocus.wrapFocusWithoutSentinels({
154
+ containerNode: innerModal.current,
155
+ currentActiveNode: event.target,
156
+ event: event
157
+ });
149
158
  }
150
- onKeyDown?.(evt);
159
+ onKeyDown?.(event);
151
160
  }
152
161
  function handleMousedown(evt) {
153
162
  evt.stopPropagation();
@@ -255,7 +264,7 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
255
264
  role: "presentation",
256
265
  ref: ref,
257
266
  "aria-hidden": !open,
258
- onBlur: handleBlur,
267
+ onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
259
268
  onMouseDown: handleMousedown,
260
269
  onKeyDown: handleKeyDown,
261
270
  className: modalClass
@@ -265,14 +274,14 @@ const ComposedModal = /*#__PURE__*/React__default["default"].forwardRef(function
265
274
  "aria-modal": "true",
266
275
  "aria-label": ariaLabel ? ariaLabel : generatedAriaLabel,
267
276
  "aria-labelledby": ariaLabelledBy
268
- }, /*#__PURE__*/React__default["default"].createElement("button", {
277
+ }, !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("button", {
269
278
  type: "button",
270
279
  ref: startSentinel,
271
280
  className: `${prefix}--visually-hidden`
272
281
  }, "Focus sentinel"), /*#__PURE__*/React__default["default"].createElement("div", {
273
282
  ref: innerModal,
274
283
  className: `${prefix}--modal-container-body`
275
- }, normalizedSlug, childrenWithProps), /*#__PURE__*/React__default["default"].createElement("button", {
284
+ }, normalizedSlug, childrenWithProps), !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("button", {
276
285
  type: "button",
277
286
  ref: endSentinel,
278
287
  className: `${prefix}--visually-hidden`
@@ -324,7 +324,7 @@ class DataTable extends React__default["default"].Component {
324
324
  isSortable,
325
325
  useStaticWidth,
326
326
  stickyHeader,
327
- overflowMenuOnHover = true,
327
+ overflowMenuOnHover = false,
328
328
  experimentalAutoAlign
329
329
  } = this.props;
330
330
  return {
@@ -24,7 +24,7 @@ export interface TableBatchActionProps extends React.ButtonHTMLAttributes<HTMLBu
24
24
  declare const TableBatchAction: {
25
25
  ({ renderIcon, iconDescription, ...props }: {
26
26
  [x: string]: any;
27
- renderIcon?: import("@carbon/icons-react/lib/CarbonIcon").CarbonIconType | undefined;
27
+ renderIcon?: import("@carbon/icons-react").CarbonIconType | undefined;
28
28
  iconDescription?: string | undefined;
29
29
  }): import("react/jsx-runtime").JSX.Element;
30
30
  propTypes: {
@@ -8,13 +8,17 @@ import React from 'react';
8
8
  export interface TableToolbarMenuProps extends React.HTMLAttributes<HTMLDivElement> {
9
9
  children: React.ReactNode;
10
10
  /**
11
- * Provide an optional class name for the toolbar menu
11
+ * Provide an optional class name for the toolbar menu trigger button
12
12
  */
13
13
  className?: string;
14
14
  /**
15
15
  * The description of the menu icon.
16
16
  */
17
17
  iconDescription?: string;
18
+ /**
19
+ * Provide an optional class name for the toolbar menu
20
+ */
21
+ menuOptionsClass?: string;
18
22
  /**
19
23
  * Optional prop to allow overriding the default menu icon
20
24
  */
@@ -30,16 +30,19 @@ const TableToolbarMenu = _ref => {
30
30
  renderIcon = iconsReact.Settings,
31
31
  iconDescription = defaultIconDescription,
32
32
  children,
33
+ menuOptionsClass,
33
34
  ...rest
34
35
  } = _ref;
35
36
  const prefix = usePrefix.usePrefix();
36
37
  const toolbarActionClasses = cx__default["default"](className, `${prefix}--toolbar-action ${prefix}--overflow-menu`);
38
+ const menuOptionsClasses = cx__default["default"](menuOptionsClass, `${prefix}--toolbar-action__menu`);
37
39
  return /*#__PURE__*/React__default["default"].createElement(index["default"], _rollupPluginBabelHelpers["extends"]({
38
40
  "aria-label": iconDescription,
39
41
  renderIcon: renderIcon,
40
42
  className: toolbarActionClasses,
41
43
  title: iconDescription,
42
44
  iconDescription: iconDescription,
45
+ menuOptionsClass: menuOptionsClasses,
43
46
  flipped: true
44
47
  }, rest), children);
45
48
  };
@@ -53,6 +56,10 @@ TableToolbarMenu.propTypes = {
53
56
  * The description of the menu icon.
54
57
  */
55
58
  iconDescription: PropTypes__default["default"].string,
59
+ /**
60
+ * Provide an optional class name for the toolbar menu
61
+ */
62
+ menuOptionsClass: PropTypes__default["default"].string,
56
63
  /**
57
64
  * Optional prop to allow overriding the default menu icon
58
65
  */
@@ -102,6 +102,10 @@ interface DatePickerProps {
102
102
  * The `open` event handler.
103
103
  */
104
104
  onOpen?: flatpickr.Options.Hook;
105
+ /**
106
+ * flatpickr prop passthrough. Controls how dates are parsed.
107
+ */
108
+ parseDate?: (date: string) => Date | false;
105
109
  /**
106
110
  * whether the DatePicker is to be readOnly
107
111
  * if boolean applies to all inputs
@@ -170,6 +170,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
170
170
  readOnly = false,
171
171
  short = false,
172
172
  value,
173
+ parseDate: parseDateProp,
173
174
  ...rest
174
175
  } = _ref;
175
176
  const prefix = usePrefix.usePrefix();
@@ -279,6 +280,37 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
279
280
  } else {
280
281
  localeData = l10n__default["default"][locale];
281
282
  }
283
+
284
+ /**
285
+ * parseDate is called before the date is actually set.
286
+ * It attempts to parse the input value and return a valid date string.
287
+ * Flatpickr's default parser results in odd dates when given invalid
288
+ * values, so instead here we normalize the month/day to `1` if given
289
+ * a value outside the acceptable range.
290
+ */
291
+ let parseDate;
292
+ if (!parseDateProp && dateFormat === 'm/d/Y') {
293
+ // This function only supports the default dateFormat.
294
+ parseDate = date => {
295
+ // Month must be 1-12. If outside these bounds, `1` should be used.
296
+ const month = date.split('/')[0] <= 12 && date.split('/')[0] > 0 ? parseInt(date.split('/')[0]) : 1;
297
+ const year = parseInt(date.split('/')[2]);
298
+ if (month && year) {
299
+ // The month and year must be provided to be able to determine
300
+ // the number of days in the month.
301
+ const daysInMonth = new Date(year, month, 0).getDate();
302
+ // If the day does not fall within the days in the month, `1` should be used.
303
+ const day = date.split('/')[1] <= daysInMonth && date.split('/')[1] > 0 ? parseInt(date.split('/')[1]) : 1;
304
+ return new Date(`${year}/${month}/${day}`);
305
+ } else {
306
+ // With no month and year, we cannot calculate anything.
307
+ // Returning false gives flatpickr an invalid date, which will clear the input
308
+ return false;
309
+ }
310
+ };
311
+ } else if (parseDateProp) {
312
+ parseDate = parseDateProp;
313
+ }
282
314
  const {
283
315
  current: start
284
316
  } = startInputField;
@@ -297,6 +329,7 @@ const DatePicker = /*#__PURE__*/React__default["default"].forwardRef(function Da
297
329
  [enableOrDisable]: enableOrDisableArr,
298
330
  minDate: minDate,
299
331
  maxDate: maxDate,
332
+ parseDate: parseDate,
300
333
  plugins: [datePickerType === 'range' ? rangePlugin["default"]({
301
334
  input: endInputField.current
302
335
  }) : () => {}, appendTo ? appendToPlugin["default"]({
@@ -708,6 +741,10 @@ DatePicker.propTypes = {
708
741
  * `(dates: Date[], dStr: string, fp: Instance, data?: any):void;`
709
742
  */
710
743
  onOpen: PropTypes__default["default"].func,
744
+ /**
745
+ * flatpickr prop passthrough. Controls how dates are parsed.
746
+ */
747
+ parseDate: PropTypes__default["default"].func,
711
748
  /**
712
749
  * whether the DatePicker is to be readOnly
713
750
  * if boolean applies to all inputs
@@ -13,7 +13,7 @@ interface IconButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement>
13
13
  /**
14
14
  * Specify how the trigger should align with the tooltip
15
15
  */
16
- align?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'right';
16
+ align?: 'top' | 'top-left' | 'top-start' | 'top-right' | 'top-end' | 'bottom' | 'bottom-left' | 'bottom-start' | 'bottom-right' | 'bottom-end' | 'left' | 'right';
17
17
  /**
18
18
  * Provide an icon or asset to be rendered inside of the IconButton
19
19
  */
@@ -69,7 +69,7 @@ IconButton.propTypes = {
69
69
  /**
70
70
  * Specify how the trigger should align with the tooltip
71
71
  */
72
- align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-right', 'bottom', 'bottom-left', 'bottom-right', 'left', 'right']),
72
+ align: PropTypes__default["default"].oneOf(['top', 'top-left', 'top-start', 'top-right', 'top-end', 'bottom', 'bottom-left', 'bottom-start', 'bottom-right', 'bottom-end', 'left', 'right']),
73
73
  /**
74
74
  * Provide an icon or asset to be rendered inside of the IconButton
75
75
  */
@@ -21,6 +21,10 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
21
21
  * Specify the text to be displayed when the control is invalid
22
22
  */
23
23
  invalidText?: React.ReactNode;
24
+ /**
25
+ * Specify the id to be applied to the element containing the invalid text
26
+ */
27
+ invalidTextId?: string;
24
28
  /**
25
29
  * Specify if the control should render open
26
30
  */
@@ -50,6 +54,10 @@ export interface ListBoxProps extends Omit<ReactAttr<HTMLDivElement>, ExcludedAt
50
54
  * Provide the text that is displayed when the control is in warning state
51
55
  */
52
56
  warnText?: React.ReactNode;
57
+ /**
58
+ * Specify the id to be applied to the element containing the warn text
59
+ */
60
+ warnTextId?: string;
53
61
  }
54
62
  export type ListBoxComponent = ForwardRefReturn<HTMLDivElement, ListBoxProps>;
55
63
  /**
@@ -47,8 +47,10 @@ const ListBox = /*#__PURE__*/React__default["default"].forwardRef(function ListB
47
47
  size,
48
48
  invalid,
49
49
  invalidText,
50
+ invalidTextId,
50
51
  warn,
51
52
  warnText,
53
+ warnTextId,
52
54
  light,
53
55
  isOpen,
54
56
  ...rest
@@ -80,9 +82,11 @@ const ListBox = /*#__PURE__*/React__default["default"].forwardRef(function ListB
80
82
  }), children), isFluid && /*#__PURE__*/React__default["default"].createElement("hr", {
81
83
  className: `${prefix}--list-box__divider`
82
84
  }), invalid ? /*#__PURE__*/React__default["default"].createElement("div", {
83
- className: `${prefix}--form-requirement`
85
+ className: `${prefix}--form-requirement`,
86
+ id: invalidTextId
84
87
  }, invalidText) : null, showWarning ? /*#__PURE__*/React__default["default"].createElement("div", {
85
- className: `${prefix}--form-requirement`
88
+ className: `${prefix}--form-requirement`,
89
+ id: warnTextId
86
90
  }, warnText) : null);
87
91
  });
88
92
  ListBox.displayName = 'ListBox';
@@ -107,6 +111,10 @@ ListBox.propTypes = {
107
111
  * Specify the text to be displayed when the control is invalid
108
112
  */
109
113
  invalidText: PropTypes__default["default"].node,
114
+ /**
115
+ * Specify the id to be applied to the element containing the invalid text
116
+ */
117
+ invalidTextId: PropTypes__default["default"].string,
110
118
  /**
111
119
  * Specify if the control should render open
112
120
  */
@@ -132,7 +140,11 @@ ListBox.propTypes = {
132
140
  /**
133
141
  * Provide the text that is displayed when the control is in warning state
134
142
  */
135
- warnText: PropTypes__default["default"].node
143
+ warnText: PropTypes__default["default"].string,
144
+ /**
145
+ * Specify the id to be applied to the element containing the warn text
146
+ */
147
+ warnTextId: PropTypes__default["default"].string
136
148
  };
137
149
 
138
150
  exports["default"] = ListBox;
@@ -30,7 +30,7 @@ export interface LoadingProps extends ReactAttr<HTMLDivElement> {
30
30
  /**
31
31
  * Specify whether you want the loader to be applied with an overlay
32
32
  */
33
- withOverlay: boolean;
33
+ withOverlay?: boolean;
34
34
  }
35
35
  declare function Loading({ active, className: customClassName, withOverlay, small, description, ...rest }: LoadingProps): import("react/jsx-runtime").JSX.Element;
36
36
  declare namespace Loading {
@@ -25,9 +25,10 @@ var debounce = require('lodash.debounce');
25
25
  var useIsomorphicEffect = require('../../internal/useIsomorphicEffect.js');
26
26
  var setupGetInstanceId = require('../../tools/setupGetInstanceId.js');
27
27
  var usePrefix = require('../../internal/usePrefix.js');
28
- var index = require('../IconButton/index.js');
28
+ var index$1 = require('../IconButton/index.js');
29
29
  var noopFn = require('../../internal/noopFn.js');
30
30
  require('../Text/index.js');
31
+ var index = require('../FeatureFlags/index.js');
31
32
  var Text = require('../Text/Text.js');
32
33
  var match = require('../../internal/keyboard/match.js');
33
34
  var keys = require('../../internal/keyboard/keys.js');
@@ -93,6 +94,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
93
94
  [`${prefix}--btn--loading`]: loadingStatus !== 'inactive'
94
95
  });
95
96
  const loadingActive = loadingStatus !== 'inactive';
97
+ const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
96
98
  function isCloseButton(element) {
97
99
  return !onSecondarySubmit && element === secondaryButton.current || element.classList.contains(modalCloseButtonClass);
98
100
  }
@@ -105,6 +107,13 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
105
107
  if (match.match(evt, keys.Enter) && shouldSubmitOnEnter && !isCloseButton(evt.target)) {
106
108
  onRequestSubmit(evt);
107
109
  }
110
+ if (focusTrapWithoutSentinels && match.match(evt, keys.Tab) && innerModal.current) {
111
+ wrapFocus.wrapFocusWithoutSentinels({
112
+ containerNode: innerModal.current,
113
+ currentActiveNode: evt.target,
114
+ event: evt
115
+ });
116
+ }
108
117
  }
109
118
  }
110
119
  function handleMousedown(evt) {
@@ -237,7 +246,7 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
237
246
  }
238
247
  const modalButton = /*#__PURE__*/React__default["default"].createElement("div", {
239
248
  className: `${prefix}--modal-close-button`
240
- }, /*#__PURE__*/React__default["default"].createElement(index.IconButton, {
249
+ }, /*#__PURE__*/React__default["default"].createElement(index$1.IconButton, {
241
250
  className: modalCloseButtonClass,
242
251
  label: closeButtonLabel,
243
252
  onClick: onRequestClose,
@@ -306,16 +315,16 @@ const Modal = /*#__PURE__*/React__default["default"].forwardRef(function Modal(_
306
315
  return /*#__PURE__*/React__default["default"].createElement("div", _rollupPluginBabelHelpers["extends"]({}, rest, {
307
316
  onKeyDown: handleKeyDown,
308
317
  onMouseDown: handleMousedown,
309
- onBlur: handleBlur,
318
+ onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
310
319
  className: modalClasses,
311
320
  role: "presentation",
312
321
  ref: ref
313
- }), /*#__PURE__*/React__default["default"].createElement("span", {
322
+ }), !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("span", {
314
323
  ref: startTrap,
315
324
  tabIndex: 0,
316
325
  role: "link",
317
326
  className: `${prefix}--visually-hidden`
318
- }, "Focus sentinel"), modalBody, /*#__PURE__*/React__default["default"].createElement("span", {
327
+ }, "Focus sentinel"), modalBody, !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("span", {
319
328
  ref: endTrap,
320
329
  tabIndex: 0,
321
330
  role: "link",
@@ -24,6 +24,7 @@ var usePrefix = require('../../internal/usePrefix.js');
24
24
  var useId = require('../../internal/useId.js');
25
25
  var noopFn = require('../../internal/noopFn.js');
26
26
  var wrapFocus = require('../../internal/wrapFocus.js');
27
+ var index = require('../FeatureFlags/index.js');
27
28
  var Text = require('../Text/Text.js');
28
29
  var match = require('../../internal/keyboard/match.js');
29
30
  var keys = require('../../internal/keyboard/keys.js');
@@ -521,6 +522,7 @@ function ActionableNotification(_ref6) {
521
522
  const startTrap = React.useRef(null);
522
523
  const endTrap = React.useRef(null);
523
524
  const ref = React.useRef(null);
525
+ const focusTrapWithoutSentinels = index.useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
524
526
  useIsomorphicEffect["default"](() => {
525
527
  if (hasFocus) {
526
528
  const button = document.querySelector('button.cds--actionable-notification__action-button');
@@ -551,6 +553,15 @@ function ActionableNotification(_ref6) {
551
553
  });
552
554
  }
553
555
  }
556
+ function handleKeyDown(event) {
557
+ if (isOpen && match.match(event, keys.Tab) && ref.current) {
558
+ wrapFocus.wrapFocusWithoutSentinels({
559
+ containerNode: ref.current,
560
+ currentActiveNode: event.target,
561
+ event
562
+ });
563
+ }
564
+ }
554
565
  const handleClose = evt => {
555
566
  if (!onClose || onClose(evt) !== false) {
556
567
  setIsOpen(false);
@@ -569,8 +580,9 @@ function ActionableNotification(_ref6) {
569
580
  role: role,
570
581
  className: containerClassName,
571
582
  "aria-labelledby": title ? id : subtitleId,
572
- onBlur: handleBlur
573
- }), /*#__PURE__*/React__default["default"].createElement("span", {
583
+ onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
584
+ onKeyDown: focusTrapWithoutSentinels ? handleKeyDown : () => {}
585
+ }), !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("span", {
574
586
  ref: startTrap,
575
587
  tabIndex: 0,
576
588
  role: "link",
@@ -603,7 +615,7 @@ function ActionableNotification(_ref6) {
603
615
  "aria-label": deprecatedAriaLabel || ariaLabel,
604
616
  notificationType: "actionable",
605
617
  onClick: handleCloseButtonClick
606
- })), /*#__PURE__*/React__default["default"].createElement("span", {
618
+ })), !focusTrapWithoutSentinels && /*#__PURE__*/React__default["default"].createElement("span", {
607
619
  ref: endTrap,
608
620
  tabIndex: 0,
609
621
  role: "link",
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
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 PropTypes from 'prop-types';
8
+ import React from 'react';
9
+ export interface PaginationSkeletonProps extends React.HTMLAttributes<HTMLDivElement> {
10
+ /**
11
+ * Specify an optional className to add.
12
+ */
13
+ className?: string;
14
+ }
15
+ declare function PaginationSkeleton({ className, ...rest }: PaginationSkeletonProps): import("react/jsx-runtime").JSX.Element;
16
+ declare namespace PaginationSkeleton {
17
+ var propTypes: {
18
+ /**
19
+ * Specify an optional className to add.
20
+ */
21
+ className: PropTypes.Requireable<string>;
22
+ };
23
+ }
24
+ export default PaginationSkeleton;
25
+ export { PaginationSkeleton };
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
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
+ type ExcludedAttributes = 'id' | 'onChange';
9
+ export interface PaginationPageSize {
10
+ text: string;
11
+ value: number;
12
+ }
13
+ export interface PaginationProps extends Omit<React.HTMLAttributes<HTMLDivElement>, ExcludedAttributes> {
14
+ /**
15
+ * The description for the backward icon.
16
+ */
17
+ backwardText?: string;
18
+ /**
19
+ * The CSS class names.
20
+ */
21
+ className?: string;
22
+ /**
23
+ * `true` if the backward/forward buttons, as well as the page select elements, should be disabled.
24
+ */
25
+ disabled?: boolean;
26
+ /**
27
+ * The description for the forward icon.
28
+ */
29
+ forwardText?: string;
30
+ /**
31
+ * The unique ID of this component instance.
32
+ */
33
+ id?: string | number;
34
+ /**
35
+ * `true` if the current page should be the last page.
36
+ */
37
+ isLastPage?: boolean;
38
+ /**
39
+ * The function returning a translatable text showing where the current page is,
40
+ * in a manner of the range of items.
41
+ */
42
+ itemRangeText?: (min: number, max: number, total: number) => string;
43
+ /**
44
+ * A variant of `itemRangeText`, used if the total number of items is unknown.
45
+ */
46
+ itemText?: (min: number, max: number) => string;
47
+ /**
48
+ * The translatable text indicating the number of items per page.
49
+ */
50
+ itemsPerPageText?: string;
51
+ /**
52
+ * The callback function called when the current page changes.
53
+ */
54
+ onChange?: (data: {
55
+ page: number;
56
+ pageSize: number;
57
+ ref?: React.RefObject<any>;
58
+ }) => void;
59
+ /**
60
+ * The current page.
61
+ */
62
+ page?: number;
63
+ /**
64
+ * `true` if the select box to change the page should be disabled.
65
+ */
66
+ pageInputDisabled?: boolean;
67
+ pageNumberText?: string;
68
+ /**
69
+ * A function returning PII showing where the current page is.
70
+ */
71
+ pageRangeText?: (current: number, total: number) => string;
72
+ /**
73
+ * The number dictating how many items a page contains.
74
+ */
75
+ pageSize?: number;
76
+ /**
77
+ * `true` if the select box to change the items per page should be disabled.
78
+ */
79
+ pageSizeInputDisabled?: boolean;
80
+ /**
81
+ * The choices for `pageSize`.
82
+ */
83
+ pageSizes: number[] | PaginationPageSize[];
84
+ /**
85
+ * The translatable text showing the current page.
86
+ */
87
+ pageText?: (page: number, pagesUnknown?: boolean) => string;
88
+ /**
89
+ * `true` if the total number of items is unknown.
90
+ */
91
+ pagesUnknown?: boolean;
92
+ /**
93
+ * Specify the size of the Pagination.
94
+ */
95
+ size?: 'sm' | 'md' | 'lg';
96
+ /**
97
+ * The total number of items.
98
+ */
99
+ totalItems?: number;
100
+ }
101
+ declare const Pagination: React.ForwardRefExoticComponent<PaginationProps & React.RefAttributes<HTMLDivElement>>;
102
+ export default Pagination;
@@ -37,7 +37,7 @@ function mapPageSizesToObject(sizes) {
37
37
  }
38
38
  function renderSelectItems(total) {
39
39
  let counter = 1;
40
- let itemArr = [];
40
+ const itemArr = [];
41
41
  while (counter <= total) {
42
42
  itemArr.push( /*#__PURE__*/React__default["default"].createElement(SelectItem["default"], {
43
43
  key: counter,
@@ -62,7 +62,7 @@ function getPageSize(pageSizes, pageSize) {
62
62
  const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pagination(_ref, ref) {
63
63
  let {
64
64
  backwardText = 'Previous page',
65
- className: customClassName,
65
+ className: customClassName = '',
66
66
  disabled = false,
67
67
  forwardText = 'Next page',
68
68
  id,
@@ -81,11 +81,11 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
81
81
  pageText = (page, pagesUnknown) => `page ${pagesUnknown ? '' : page}`,
82
82
  pagesUnknown = false,
83
83
  size = 'md',
84
- totalItems,
84
+ totalItems = 1,
85
85
  ...rest
86
86
  } = _ref;
87
87
  const prefix = usePrefix.usePrefix();
88
- const inputId = useId.useFallbackId(id);
88
+ const inputId = useId.useFallbackId(id?.toString());
89
89
  const backBtnRef = React.useRef(null);
90
90
  const forwardBtnRef = React.useRef(null);
91
91
  const [pageSizes, setPageSizes] = React.useState(() => {
@@ -173,14 +173,14 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
173
173
  // the icon button becomes disabled and the focus shifts to `main`
174
174
  // this presents an a11y problem for keyboard & screen reader users
175
175
  // instead, we want the focus to shift to the other pagination btn
176
- if (nextPage === totalPages) {
176
+ if (nextPage === totalPages && backBtnRef?.current) {
177
177
  backBtnRef.current.focus();
178
178
  }
179
179
  if (onChange) {
180
180
  onChange({
181
181
  page: nextPage,
182
182
  pageSize,
183
- backBtnRef
183
+ ref: backBtnRef
184
184
  });
185
185
  }
186
186
  }
@@ -192,14 +192,14 @@ const Pagination = /*#__PURE__*/React__default["default"].forwardRef(function Pa
192
192
  // the icon button becomes disabled and the focus shifts to `main`
193
193
  // this presents an a11y problem for keyboard & screen reader users
194
194
  // instead, we want the focus to shift to the other pagination btn
195
- if (nextPage === 1) {
195
+ if (nextPage === 1 && forwardBtnRef?.current) {
196
196
  forwardBtnRef.current.focus();
197
197
  }
198
198
  if (onChange) {
199
199
  onChange({
200
200
  page: nextPage,
201
201
  pageSize,
202
- forwardBtnRef
202
+ ref: forwardBtnRef
203
203
  });
204
204
  }
205
205
  }
@@ -330,10 +330,10 @@ Pagination.propTypes = {
330
330
  /**
331
331
  * The choices for `pageSize`.
332
332
  */
333
- pageSizes: PropTypes__default["default"].oneOfType([PropTypes__default["default"].arrayOf(PropTypes__default["default"].number), PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
334
- text: PropTypes__default["default"].text,
335
- value: PropTypes__default["default"].number
336
- }))]).isRequired,
333
+ pageSizes: PropTypes__default["default"].oneOfType([PropTypes__default["default"].arrayOf(PropTypes__default["default"].number.isRequired), PropTypes__default["default"].arrayOf(PropTypes__default["default"].shape({
334
+ text: PropTypes__default["default"].string.isRequired,
335
+ value: PropTypes__default["default"].number.isRequired
336
+ }).isRequired)]).isRequired,
337
337
  /**
338
338
  * The translatable text showing the current page.
339
339
  */
@@ -351,6 +351,5 @@ Pagination.propTypes = {
351
351
  */
352
352
  totalItems: PropTypes__default["default"].number
353
353
  };
354
- var Pagination$1 = Pagination;
355
354
 
356
- exports["default"] = Pagination$1;
355
+ exports["default"] = Pagination;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Copyright IBM Corp. 2016, 2023
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 Pagination from './Pagination';
8
+ export * from './Pagination.Skeleton';
9
+ export default Pagination;
10
+ export { Pagination };