@carbon/react 1.53.1 → 1.54.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 (114) hide show
  1. package/.playwright/INTERNAL_AVT_REPORT_DO_NOT_USE.json +981 -1068
  2. package/es/components/Button/Button.d.ts +1 -1
  3. package/es/components/Button/Button.js +13 -89
  4. package/es/components/Button/ButtonBase.d.ts +10 -0
  5. package/es/components/Button/ButtonBase.js +110 -0
  6. package/es/components/CodeSnippet/CodeSnippet.js +1 -0
  7. package/es/components/ComboBox/ComboBox.js +13 -4
  8. package/es/components/ComboButton/index.js +1 -1
  9. package/es/components/ComposedModal/ComposedModal.js +19 -10
  10. package/es/components/DataTable/DataTable.js +1 -1
  11. package/es/components/DataTable/TableBatchAction.d.ts +1 -1
  12. package/es/components/DataTable/TableToolbarMenu.d.ts +5 -1
  13. package/es/components/DataTable/TableToolbarMenu.js +7 -0
  14. package/es/components/DatePicker/DatePicker.d.ts +4 -0
  15. package/es/components/DatePicker/DatePicker.js +37 -0
  16. package/es/components/IconButton/index.d.ts +1 -1
  17. package/es/components/IconButton/index.js +3 -4
  18. package/es/components/ListBox/ListBox.d.ts +8 -0
  19. package/es/components/ListBox/ListBox.js +15 -3
  20. package/es/components/Loading/Loading.d.ts +1 -1
  21. package/es/components/Menu/Menu.js +2 -0
  22. package/es/components/Modal/Modal.js +14 -5
  23. package/es/components/ModalWrapper/ModalWrapper.d.ts +1 -1
  24. package/es/components/Notification/Notification.js +18 -6
  25. package/es/components/Pagination/Pagination.Skeleton.d.ts +25 -0
  26. package/es/components/Pagination/Pagination.d.ts +102 -0
  27. package/es/components/Pagination/Pagination.js +13 -14
  28. package/es/components/Pagination/index.d.ts +10 -0
  29. package/es/components/Popover/index.d.ts +1 -1
  30. package/es/components/Popover/index.js +175 -108
  31. package/es/components/RadioTile/RadioTile.d.ts +55 -0
  32. package/es/components/RadioTile/RadioTile.js +17 -17
  33. package/es/components/RadioTile/index.d.ts +10 -0
  34. package/es/components/Slider/Slider.Skeleton.js +6 -2
  35. package/es/components/Slug/index.js +23 -2
  36. package/es/components/Stack/HStack.d.ts +10 -0
  37. package/es/components/Stack/HStack.js +23 -0
  38. package/es/components/Stack/Stack.d.ts +1 -1
  39. package/es/components/Stack/Stack.js +2 -2
  40. package/es/components/Stack/VStack.d.ts +10 -0
  41. package/es/components/Stack/{index.js → VStack.js} +1 -8
  42. package/es/components/Stack/index.d.ts +3 -6
  43. package/es/components/StructuredList/StructuredList.d.ts +8 -0
  44. package/es/components/StructuredList/StructuredList.js +28 -10
  45. package/es/components/TileGroup/TileGroup.js +30 -24
  46. package/es/components/Toggletip/index.d.ts +1 -18
  47. package/es/components/Toggletip/index.js +27 -4
  48. package/es/components/Tooltip/Tooltip.js +23 -5
  49. package/es/feature-flags.js +2 -1
  50. package/es/index.d.ts +1 -0
  51. package/es/index.js +5 -4
  52. package/es/internal/FloatingMenu.js +26 -5
  53. package/es/internal/environment.js +5 -1
  54. package/es/internal/keyboard/navigation.js +6 -2
  55. package/es/internal/useOutsideClick.js +31 -0
  56. package/es/internal/wrapFocus.js +51 -1
  57. package/es/tools/createPropAdapter.js +40 -0
  58. package/lib/components/Button/Button.d.ts +1 -1
  59. package/lib/components/Button/Button.js +13 -90
  60. package/lib/components/Button/ButtonBase.d.ts +10 -0
  61. package/lib/components/Button/ButtonBase.js +119 -0
  62. package/lib/components/CodeSnippet/CodeSnippet.js +1 -0
  63. package/lib/components/ComboBox/ComboBox.js +13 -4
  64. package/lib/components/ComboButton/index.js +1 -1
  65. package/lib/components/ComposedModal/ComposedModal.js +17 -8
  66. package/lib/components/DataTable/DataTable.js +1 -1
  67. package/lib/components/DataTable/TableBatchAction.d.ts +1 -1
  68. package/lib/components/DataTable/TableToolbarMenu.d.ts +5 -1
  69. package/lib/components/DataTable/TableToolbarMenu.js +7 -0
  70. package/lib/components/DatePicker/DatePicker.d.ts +4 -0
  71. package/lib/components/DatePicker/DatePicker.js +37 -0
  72. package/lib/components/IconButton/index.d.ts +1 -1
  73. package/lib/components/IconButton/index.js +3 -4
  74. package/lib/components/ListBox/ListBox.d.ts +8 -0
  75. package/lib/components/ListBox/ListBox.js +15 -3
  76. package/lib/components/Loading/Loading.d.ts +1 -1
  77. package/lib/components/Menu/Menu.js +2 -0
  78. package/lib/components/Modal/Modal.js +14 -5
  79. package/lib/components/ModalWrapper/ModalWrapper.d.ts +1 -1
  80. package/lib/components/Notification/Notification.js +15 -3
  81. package/lib/components/Pagination/Pagination.Skeleton.d.ts +25 -0
  82. package/lib/components/Pagination/Pagination.d.ts +102 -0
  83. package/lib/components/Pagination/Pagination.js +13 -14
  84. package/lib/components/Pagination/index.d.ts +10 -0
  85. package/lib/components/Popover/index.d.ts +1 -1
  86. package/lib/components/Popover/index.js +174 -107
  87. package/lib/components/RadioTile/RadioTile.d.ts +55 -0
  88. package/lib/components/RadioTile/RadioTile.js +17 -17
  89. package/lib/components/RadioTile/index.d.ts +10 -0
  90. package/lib/components/Slider/Slider.Skeleton.js +5 -1
  91. package/lib/components/Slug/index.js +23 -2
  92. package/lib/components/Stack/HStack.d.ts +10 -0
  93. package/lib/components/Stack/HStack.js +31 -0
  94. package/lib/components/Stack/Stack.d.ts +1 -1
  95. package/lib/components/Stack/Stack.js +3 -3
  96. package/lib/components/Stack/VStack.d.ts +10 -0
  97. package/lib/components/Stack/{index.js → VStack.js} +0 -8
  98. package/lib/components/Stack/index.d.ts +3 -6
  99. package/lib/components/StructuredList/StructuredList.d.ts +8 -0
  100. package/lib/components/StructuredList/StructuredList.js +27 -9
  101. package/lib/components/TileGroup/TileGroup.js +30 -24
  102. package/lib/components/Toggletip/index.d.ts +1 -18
  103. package/lib/components/Toggletip/index.js +27 -4
  104. package/lib/components/Tooltip/Tooltip.js +23 -5
  105. package/lib/feature-flags.js +2 -1
  106. package/lib/index.d.ts +1 -0
  107. package/lib/index.js +15 -14
  108. package/lib/internal/FloatingMenu.js +44 -4
  109. package/lib/internal/environment.js +5 -1
  110. package/lib/internal/keyboard/navigation.js +6 -2
  111. package/lib/internal/useOutsideClick.js +35 -0
  112. package/lib/internal/wrapFocus.js +51 -0
  113. package/lib/tools/createPropAdapter.js +44 -0
  114. package/package.json +9 -7
@@ -37,8 +37,10 @@ const ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, re
37
37
  size,
38
38
  invalid,
39
39
  invalidText,
40
+ invalidTextId,
40
41
  warn,
41
42
  warnText,
43
+ warnTextId,
42
44
  light,
43
45
  isOpen,
44
46
  ...rest
@@ -70,9 +72,11 @@ const ListBox = /*#__PURE__*/React__default.forwardRef(function ListBox(_ref, re
70
72
  }), children), isFluid && /*#__PURE__*/React__default.createElement("hr", {
71
73
  className: `${prefix}--list-box__divider`
72
74
  }), invalid ? /*#__PURE__*/React__default.createElement("div", {
73
- className: `${prefix}--form-requirement`
75
+ className: `${prefix}--form-requirement`,
76
+ id: invalidTextId
74
77
  }, invalidText) : null, showWarning ? /*#__PURE__*/React__default.createElement("div", {
75
- className: `${prefix}--form-requirement`
78
+ className: `${prefix}--form-requirement`,
79
+ id: warnTextId
76
80
  }, warnText) : null);
77
81
  });
78
82
  ListBox.displayName = 'ListBox';
@@ -97,6 +101,10 @@ ListBox.propTypes = {
97
101
  * Specify the text to be displayed when the control is invalid
98
102
  */
99
103
  invalidText: PropTypes.node,
104
+ /**
105
+ * Specify the id to be applied to the element containing the invalid text
106
+ */
107
+ invalidTextId: PropTypes.string,
100
108
  /**
101
109
  * Specify if the control should render open
102
110
  */
@@ -122,7 +130,11 @@ ListBox.propTypes = {
122
130
  /**
123
131
  * Provide the text that is displayed when the control is in warning state
124
132
  */
125
- warnText: PropTypes.node
133
+ warnText: PropTypes.string,
134
+ /**
135
+ * Specify the id to be applied to the element containing the warn text
136
+ */
137
+ warnTextId: PropTypes.string
126
138
  };
127
139
 
128
140
  export { ListBox as default };
@@ -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 {
@@ -32,6 +32,8 @@ const Menu = /*#__PURE__*/forwardRef(function Menu(_ref, forwardRef) {
32
32
  onOpen,
33
33
  open,
34
34
  size = 'sm',
35
+ // TODO: #16004
36
+ // eslint-disable-next-line ssr-friendly/no-dom-globals-in-react-fc
35
37
  target = document.body,
36
38
  x = 0,
37
39
  y = 0,
@@ -16,7 +16,7 @@ import '../Button/Button.Skeleton.js';
16
16
  import ButtonSet from '../ButtonSet/ButtonSet.js';
17
17
  import InlineLoading from '../InlineLoading/InlineLoading.js';
18
18
  import requiredIfGivenPropIsTruthy from '../../prop-types/requiredIfGivenPropIsTruthy.js';
19
- import wrapFocus, { elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
19
+ import wrapFocus, { wrapFocusWithoutSentinels, elementOrParentIsFloatingMenu } from '../../internal/wrapFocus.js';
20
20
  import debounce from 'lodash.debounce';
21
21
  import useIsomorphicEffect from '../../internal/useIsomorphicEffect.js';
22
22
  import setupGetInstanceId from '../../tools/setupGetInstanceId.js';
@@ -24,9 +24,10 @@ import { usePrefix } from '../../internal/usePrefix.js';
24
24
  import { IconButton } from '../IconButton/index.js';
25
25
  import { noopFn } from '../../internal/noopFn.js';
26
26
  import '../Text/index.js';
27
+ import { useFeatureFlag } from '../FeatureFlags/index.js';
27
28
  import { Text } from '../Text/Text.js';
28
29
  import { match } from '../../internal/keyboard/match.js';
29
- import { Escape, Enter } from '../../internal/keyboard/keys.js';
30
+ import { Escape, Enter, Tab } from '../../internal/keyboard/keys.js';
30
31
 
31
32
  const getInstanceId = setupGetInstanceId();
32
33
  const ModalSizes = ['xs', 'sm', 'md', 'lg'];
@@ -82,6 +83,7 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
82
83
  [`${prefix}--btn--loading`]: loadingStatus !== 'inactive'
83
84
  });
84
85
  const loadingActive = loadingStatus !== 'inactive';
86
+ const focusTrapWithoutSentinels = useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
85
87
  function isCloseButton(element) {
86
88
  return !onSecondarySubmit && element === secondaryButton.current || element.classList.contains(modalCloseButtonClass);
87
89
  }
@@ -94,6 +96,13 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
94
96
  if (match(evt, Enter) && shouldSubmitOnEnter && !isCloseButton(evt.target)) {
95
97
  onRequestSubmit(evt);
96
98
  }
99
+ if (focusTrapWithoutSentinels && match(evt, Tab) && innerModal.current) {
100
+ wrapFocusWithoutSentinels({
101
+ containerNode: innerModal.current,
102
+ currentActiveNode: evt.target,
103
+ event: evt
104
+ });
105
+ }
97
106
  }
98
107
  }
99
108
  function handleMousedown(evt) {
@@ -295,16 +304,16 @@ const Modal = /*#__PURE__*/React__default.forwardRef(function Modal(_ref, ref) {
295
304
  return /*#__PURE__*/React__default.createElement("div", _extends({}, rest, {
296
305
  onKeyDown: handleKeyDown,
297
306
  onMouseDown: handleMousedown,
298
- onBlur: handleBlur,
307
+ onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
299
308
  className: modalClasses,
300
309
  role: "presentation",
301
310
  ref: ref
302
- }), /*#__PURE__*/React__default.createElement("span", {
311
+ }), !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("span", {
303
312
  ref: startTrap,
304
313
  tabIndex: 0,
305
314
  role: "link",
306
315
  className: `${prefix}--visually-hidden`
307
- }, "Focus sentinel"), modalBody, /*#__PURE__*/React__default.createElement("span", {
316
+ }, "Focus sentinel"), modalBody, !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("span", {
308
317
  ref: endTrap,
309
318
  tabIndex: 0,
310
319
  role: "link",
@@ -59,7 +59,7 @@ export default class ModalWrapper extends React.Component<ModalWrapperProps, Mod
59
59
  shouldCloseAfterSubmit: PropTypes.Requireable<boolean>;
60
60
  status: PropTypes.Requireable<string>;
61
61
  triggerButtonIconDescription: PropTypes.Requireable<string>;
62
- triggerButtonKind: PropTypes.Requireable<"primary" | "secondary" | "ghost" | "tertiary" | "danger" | "danger--primary" | "danger--ghost" | "danger--tertiary">;
62
+ triggerButtonKind: PropTypes.Requireable<"primary" | "secondary" | "danger" | "ghost" | "danger--primary" | "danger--ghost" | "danger--tertiary" | "tertiary">;
63
63
  withHeader: PropTypes.Requireable<boolean>;
64
64
  };
65
65
  triggerButton: React.RefObject<HTMLButtonElement>;
@@ -19,10 +19,11 @@ import { useNoInteractiveChildren, useInteractiveChildrenNeedDescription } from
19
19
  import { usePrefix } from '../../internal/usePrefix.js';
20
20
  import { useId } from '../../internal/useId.js';
21
21
  import { noopFn } from '../../internal/noopFn.js';
22
- import wrapFocus from '../../internal/wrapFocus.js';
22
+ import wrapFocus, { wrapFocusWithoutSentinels } from '../../internal/wrapFocus.js';
23
+ import { useFeatureFlag } from '../FeatureFlags/index.js';
23
24
  import { Text } from '../Text/Text.js';
24
- import { matches } from '../../internal/keyboard/match.js';
25
- import { Escape } from '../../internal/keyboard/keys.js';
25
+ import { match, matches } from '../../internal/keyboard/match.js';
26
+ import { Tab, Escape } from '../../internal/keyboard/keys.js';
26
27
 
27
28
  /**
28
29
  * Conditionally call a callback when the escape key is pressed
@@ -511,6 +512,7 @@ function ActionableNotification(_ref6) {
511
512
  const startTrap = useRef(null);
512
513
  const endTrap = useRef(null);
513
514
  const ref = useRef(null);
515
+ const focusTrapWithoutSentinels = useFeatureFlag('enable-experimental-focus-wrap-without-sentinels');
514
516
  useIsomorphicEffect(() => {
515
517
  if (hasFocus) {
516
518
  const button = document.querySelector('button.cds--actionable-notification__action-button');
@@ -541,6 +543,15 @@ function ActionableNotification(_ref6) {
541
543
  });
542
544
  }
543
545
  }
546
+ function handleKeyDown(event) {
547
+ if (isOpen && match(event, Tab) && ref.current) {
548
+ wrapFocusWithoutSentinels({
549
+ containerNode: ref.current,
550
+ currentActiveNode: event.target,
551
+ event
552
+ });
553
+ }
554
+ }
544
555
  const handleClose = evt => {
545
556
  if (!onClose || onClose(evt) !== false) {
546
557
  setIsOpen(false);
@@ -559,8 +570,9 @@ function ActionableNotification(_ref6) {
559
570
  role: role,
560
571
  className: containerClassName,
561
572
  "aria-labelledby": title ? id : subtitleId,
562
- onBlur: handleBlur
563
- }), /*#__PURE__*/React__default.createElement("span", {
573
+ onBlur: !focusTrapWithoutSentinels ? handleBlur : () => {},
574
+ onKeyDown: focusTrapWithoutSentinels ? handleKeyDown : () => {}
575
+ }), !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("span", {
564
576
  ref: startTrap,
565
577
  tabIndex: 0,
566
578
  role: "link",
@@ -593,7 +605,7 @@ function ActionableNotification(_ref6) {
593
605
  "aria-label": deprecatedAriaLabel || ariaLabel,
594
606
  notificationType: "actionable",
595
607
  onClick: handleCloseButtonClick
596
- })), /*#__PURE__*/React__default.createElement("span", {
608
+ })), !focusTrapWithoutSentinels && /*#__PURE__*/React__default.createElement("span", {
597
609
  ref: endTrap,
598
610
  tabIndex: 0,
599
611
  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;
@@ -27,7 +27,7 @@ function mapPageSizesToObject(sizes) {
27
27
  }
28
28
  function renderSelectItems(total) {
29
29
  let counter = 1;
30
- let itemArr = [];
30
+ const itemArr = [];
31
31
  while (counter <= total) {
32
32
  itemArr.push( /*#__PURE__*/React__default.createElement(SelectItem, {
33
33
  key: counter,
@@ -52,7 +52,7 @@ function getPageSize(pageSizes, pageSize) {
52
52
  const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_ref, ref) {
53
53
  let {
54
54
  backwardText = 'Previous page',
55
- className: customClassName,
55
+ className: customClassName = '',
56
56
  disabled = false,
57
57
  forwardText = 'Next page',
58
58
  id,
@@ -71,11 +71,11 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
71
71
  pageText = (page, pagesUnknown) => `page ${pagesUnknown ? '' : page}`,
72
72
  pagesUnknown = false,
73
73
  size = 'md',
74
- totalItems,
74
+ totalItems = 1,
75
75
  ...rest
76
76
  } = _ref;
77
77
  const prefix = usePrefix();
78
- const inputId = useFallbackId(id);
78
+ const inputId = useFallbackId(id?.toString());
79
79
  const backBtnRef = useRef(null);
80
80
  const forwardBtnRef = useRef(null);
81
81
  const [pageSizes, setPageSizes] = useState(() => {
@@ -163,14 +163,14 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
163
163
  // the icon button becomes disabled and the focus shifts to `main`
164
164
  // this presents an a11y problem for keyboard & screen reader users
165
165
  // instead, we want the focus to shift to the other pagination btn
166
- if (nextPage === totalPages) {
166
+ if (nextPage === totalPages && backBtnRef?.current) {
167
167
  backBtnRef.current.focus();
168
168
  }
169
169
  if (onChange) {
170
170
  onChange({
171
171
  page: nextPage,
172
172
  pageSize,
173
- backBtnRef
173
+ ref: backBtnRef
174
174
  });
175
175
  }
176
176
  }
@@ -182,14 +182,14 @@ const Pagination = /*#__PURE__*/React__default.forwardRef(function Pagination(_r
182
182
  // the icon button becomes disabled and the focus shifts to `main`
183
183
  // this presents an a11y problem for keyboard & screen reader users
184
184
  // instead, we want the focus to shift to the other pagination btn
185
- if (nextPage === 1) {
185
+ if (nextPage === 1 && forwardBtnRef?.current) {
186
186
  forwardBtnRef.current.focus();
187
187
  }
188
188
  if (onChange) {
189
189
  onChange({
190
190
  page: nextPage,
191
191
  pageSize,
192
- forwardBtnRef
192
+ ref: forwardBtnRef
193
193
  });
194
194
  }
195
195
  }
@@ -320,10 +320,10 @@ Pagination.propTypes = {
320
320
  /**
321
321
  * The choices for `pageSize`.
322
322
  */
323
- pageSizes: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number), PropTypes.arrayOf(PropTypes.shape({
324
- text: PropTypes.text,
325
- value: PropTypes.number
326
- }))]).isRequired,
323
+ pageSizes: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.number.isRequired), PropTypes.arrayOf(PropTypes.shape({
324
+ text: PropTypes.string.isRequired,
325
+ value: PropTypes.number.isRequired
326
+ }).isRequired)]).isRequired,
327
327
  /**
328
328
  * The translatable text showing the current page.
329
329
  */
@@ -341,6 +341,5 @@ Pagination.propTypes = {
341
341
  */
342
342
  totalItems: PropTypes.number
343
343
  };
344
- var Pagination$1 = Pagination;
345
344
 
346
- export { Pagination$1 as default };
345
+ export { Pagination as default };
@@ -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 };
@@ -6,7 +6,7 @@
6
6
  */
7
7
  import React, { type ForwardedRef, type WeakValidationMap, type ElementType } from 'react';
8
8
  import { type PolymorphicProps } from '../../types/common';
9
- export type PopoverAlignment = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-bottom' | 'left-top' | 'right' | 'right-bottom' | 'right-top';
9
+ export type PopoverAlignment = 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' | 'left' | 'left-bottom' | 'left-top' | 'right' | 'right-bottom' | 'right-top' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'left-end' | 'left-start' | 'right-end' | 'right-start';
10
10
  interface PopoverBaseProps {
11
11
  /**
12
12
  * Specify how the popover should align with the trigger element