@razorpay/blade 12.65.1 → 12.67.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 (65) hide show
  1. package/build/lib/native/components/Pagination/Pagination.native.js +12 -0
  2. package/build/lib/native/components/Pagination/Pagination.native.js.map +1 -0
  3. package/build/lib/native/components/Popover/Popover.native.js +1 -1
  4. package/build/lib/native/components/Popover/Popover.native.js.map +1 -1
  5. package/build/lib/native/components/Popover/PopoverContent.js +1 -1
  6. package/build/lib/native/components/Popover/PopoverContent.js.map +1 -1
  7. package/build/lib/native/components/Popover/PopoverContext.js.map +1 -1
  8. package/build/lib/native/components/Table/tokens.js.map +1 -1
  9. package/build/lib/native/components/index.js +1 -0
  10. package/build/lib/native/components/index.js.map +1 -1
  11. package/build/lib/native/utils/metaAttribute/metaConstants.js +1 -1
  12. package/build/lib/native/utils/metaAttribute/metaConstants.js.map +1 -1
  13. package/build/lib/web/development/components/Pagination/Pagination.web.js +466 -0
  14. package/build/lib/web/development/components/Pagination/Pagination.web.js.map +1 -0
  15. package/build/lib/web/development/components/Pagination/index.js +2 -0
  16. package/build/lib/web/development/components/Pagination/index.js.map +1 -0
  17. package/build/lib/web/development/components/Pagination/tokens.js +25 -0
  18. package/build/lib/web/development/components/Pagination/tokens.js.map +1 -0
  19. package/build/lib/web/development/components/Popover/Popover.web.js +13 -7
  20. package/build/lib/web/development/components/Popover/Popover.web.js.map +1 -1
  21. package/build/lib/web/development/components/Popover/PopoverContent.js +8 -3
  22. package/build/lib/web/development/components/Popover/PopoverContent.js.map +1 -1
  23. package/build/lib/web/development/components/Popover/PopoverContext.js.map +1 -1
  24. package/build/lib/web/development/components/SpotlightPopoverTour/TourPopover.web.js +2 -1
  25. package/build/lib/web/development/components/SpotlightPopoverTour/TourPopover.web.js.map +1 -1
  26. package/build/lib/web/development/components/Table/TablePagination.web.js +128 -395
  27. package/build/lib/web/development/components/Table/TablePagination.web.js.map +1 -1
  28. package/build/lib/web/development/components/Table/tokens.js +0 -16
  29. package/build/lib/web/development/components/Table/tokens.js.map +1 -1
  30. package/build/lib/web/development/components/Toast/ToastContainer.web.js +15 -5
  31. package/build/lib/web/development/components/Toast/ToastContainer.web.js.map +1 -1
  32. package/build/lib/web/development/components/Toast/constants.js +1 -1
  33. package/build/lib/web/development/components/Toast/constants.js.map +1 -1
  34. package/build/lib/web/development/components/index.js +2 -0
  35. package/build/lib/web/development/components/index.js.map +1 -1
  36. package/build/lib/web/development/utils/metaAttribute/metaConstants.js +1 -0
  37. package/build/lib/web/development/utils/metaAttribute/metaConstants.js.map +1 -1
  38. package/build/lib/web/production/components/Pagination/Pagination.web.js +466 -0
  39. package/build/lib/web/production/components/Pagination/Pagination.web.js.map +1 -0
  40. package/build/lib/web/production/components/Pagination/index.js +2 -0
  41. package/build/lib/web/production/components/Pagination/index.js.map +1 -0
  42. package/build/lib/web/production/components/Pagination/tokens.js +25 -0
  43. package/build/lib/web/production/components/Pagination/tokens.js.map +1 -0
  44. package/build/lib/web/production/components/Popover/Popover.web.js +13 -7
  45. package/build/lib/web/production/components/Popover/Popover.web.js.map +1 -1
  46. package/build/lib/web/production/components/Popover/PopoverContent.js +8 -3
  47. package/build/lib/web/production/components/Popover/PopoverContent.js.map +1 -1
  48. package/build/lib/web/production/components/Popover/PopoverContext.js.map +1 -1
  49. package/build/lib/web/production/components/SpotlightPopoverTour/TourPopover.web.js +2 -1
  50. package/build/lib/web/production/components/SpotlightPopoverTour/TourPopover.web.js.map +1 -1
  51. package/build/lib/web/production/components/Table/TablePagination.web.js +128 -395
  52. package/build/lib/web/production/components/Table/TablePagination.web.js.map +1 -1
  53. package/build/lib/web/production/components/Table/tokens.js +0 -16
  54. package/build/lib/web/production/components/Table/tokens.js.map +1 -1
  55. package/build/lib/web/production/components/Toast/ToastContainer.web.js +15 -5
  56. package/build/lib/web/production/components/Toast/ToastContainer.web.js.map +1 -1
  57. package/build/lib/web/production/components/Toast/constants.js +1 -1
  58. package/build/lib/web/production/components/Toast/constants.js.map +1 -1
  59. package/build/lib/web/production/components/index.js +2 -0
  60. package/build/lib/web/production/components/index.js.map +1 -1
  61. package/build/lib/web/production/utils/metaAttribute/metaConstants.js +1 -0
  62. package/build/lib/web/production/utils/metaAttribute/metaConstants.js.map +1 -1
  63. package/build/types/components/index.d.ts +99 -3
  64. package/build/types/components/index.native.d.ts +90 -1
  65. package/package.json +2 -2
@@ -1,174 +1,39 @@
1
- import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
2
- import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
4
- import React__default, { useEffect, useCallback } from 'react';
5
- import styled from 'styled-components';
2
+ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
3
+ import { useEffect, useMemo } from 'react';
6
4
  import { useTableContext } from './TableContext.js';
7
5
  import { ComponentIds } from './componentIds.js';
8
6
  import { tablePagination } from './tokens.js';
9
7
  import isUndefined from '../../utils/lodashButBetter/isUndefined.js';
10
- import getIn from '../../utils/lodashButBetter/get.js';
11
8
  import '../Box/BaseBox/index.js';
12
- import '../Icons/index.js';
13
- import '../Dropdown/index.js';
14
- import '../Input/DropdownInputTriggers/index.js';
15
- import '../ActionList/index.js';
16
- import '../Typography/index.js';
17
- import '../../utils/index.js';
18
- import '../Button/index.js';
19
- import '../../utils/makeAccessible/index.js';
20
9
  import '../../utils/assignWithoutSideEffects/index.js';
21
- import '../BladeProvider/index.js';
22
10
  import '../../utils/logger/index.js';
23
- import '../../utils/getFocusRingStyles/index.js';
24
- import '../../utils/makeAnalyticsAttribute/index.js';
25
- import '../../utils/metaAttribute/index.js';
26
- import { jsxs, jsx } from 'react/jsx-runtime';
27
- import { metaAttribute } from '../../utils/metaAttribute/metaAttribute.web.js';
28
- import { MetaConstants } from '../../utils/metaAttribute/metaConstants.js';
29
- import { makeSize } from '../../utils/makeSize/makeSize.js';
30
- import { getFocusRingStyles } from '../../utils/getFocusRingStyles/getFocusRingStyles.web.js';
31
- import useTheme from '../BladeProvider/useTheme.js';
11
+ import '../Pagination/index.js';
12
+ import { jsx } from 'react/jsx-runtime';
32
13
  import { throwBladeError } from '../../utils/logger/logger.js';
33
14
  import { BaseBox } from '../Box/BaseBox/BaseBox.web.js';
34
- import { makeAnalyticsAttribute } from '../../utils/makeAnalyticsAttribute/makeAnalyticsAttribute.js';
35
- import { Text } from '../Typography/Text/Text.js';
36
- import { Dropdown } from '../Dropdown/Dropdown.js';
37
- import { SelectInput } from '../Input/DropdownInputTriggers/SelectInput.js';
38
- import { DropdownOverlay } from '../Dropdown/DropdownOverlay.web.js';
39
- import { ActionList } from '../ActionList/ActionList.js';
40
- import { ActionListItem } from '../ActionList/ActionListItem.js';
41
- import Button from '../Button/Button/Button.js';
42
- import ChevronLeftIcon from '../Icons/ChevronLeftIcon/ChevronLeftIcon.js';
43
- import { makeAccessible } from '../../utils/makeAccessible/makeAccessible.web.js';
44
- import ChevronsLeftIcon from '../Icons/ChevronsLeftIcon/ChevronsLeftIcon.js';
45
- import MoreHorizontalIcon from '../Icons/MoreHorizontalIcon/MoreHorizontalIcon.js';
46
- import ChevronsRightIcon from '../Icons/ChevronsRightIcon/ChevronsRightIcon.js';
47
- import ChevronRightIcon from '../Icons/ChevronRightIcon/ChevronRightIcon.js';
15
+ import { Pagination } from '../Pagination/Pagination.web.js';
48
16
  import { assignWithoutSideEffects } from '../../utils/assignWithoutSideEffects/assignWithoutSideEffects.js';
49
17
 
50
18
  var _excluded = ["currentPage", "onPageChange", "onPageSizeChange", "defaultPageSize", "showPageSizePicker", "showPageNumberSelector", "showLabel", "label", "totalItemCount", "paginationType"];
51
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
52
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
53
- var pageSizeOptions = [10, 25, 50];
54
- var PageSelectionButton = /*#__PURE__*/styled.button.attrs(function () {
55
- return _objectSpread({}, metaAttribute({
56
- name: MetaConstants.TablePageSelectionButton
57
- }));
58
- }).withConfig({
59
- displayName: "TablePaginationweb__PageSelectionButton",
60
- componentId: "sc-127igl5-0"
61
- })(function (_ref) {
62
- var theme = _ref.theme,
63
- isSelected = _ref.isSelected;
64
- return {
65
- backgroundColor: isSelected ? getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorSelected) : 'transparent',
66
- border: 'none',
67
- cursor: 'pointer',
68
- height: makeSize(tablePagination.pageSelectionButton.height),
69
- width: makeSize(tablePagination.pageSelectionButton.width),
70
- display: 'flex',
71
- alignItems: 'center',
72
- justifyContent: 'center',
73
- borderRadius: getIn(theme.border.radius, tablePagination.pageSelectionButton.borderRadius),
74
- '&:hover': {
75
- backgroundColor: isSelected ? getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorSelectedHover) : getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorHover)
76
- },
77
- '&:focus-visible': {
78
- backgroundColor: isSelected ? getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorSelectedActive) : getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorActive),
79
- outline: 'none',
80
- '&:focus-visible': getFocusRingStyles({
81
- theme: theme
82
- })
83
- },
84
- '&:active': {
85
- backgroundColor: isSelected ? getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorSelectedActive) : getIn(theme.colors, tablePagination.pageSelectionButton.backgroundColorActive)
86
- }
87
- };
88
- });
89
- var getPaginationButtons = function getPaginationButtons(_ref2) {
90
- var currentSelection = _ref2.currentSelection,
91
- totalPages = _ref2.totalPages;
92
- var halfRange = 2;
93
- var minMiddleItems = 5;
94
-
95
- // return if totalPages is less than minMiddleItems
96
- if (totalPages <= minMiddleItems) {
97
- return {
98
- middleItems: Array.from({
99
- length: totalPages - 2
100
- }, function (_, index) {
101
- return index + 2;
102
- }),
103
- showStartEllipsis: false,
104
- showEndEllipsis: false,
105
- firstItem: 1,
106
- lastItem: totalPages
107
- };
108
- }
109
- var start = Math.max(1, currentSelection - halfRange);
110
- var end = Math.min(totalPages, start + 2 * halfRange);
111
-
112
- // Ensure at least minMiddleItems items in middleItems
113
- while (end - start + 1 < minMiddleItems && (start > 1 || end < totalPages)) {
114
- if (start > 1) {
115
- start--;
116
- }
117
- if (end < totalPages) {
118
- end++;
119
- }
120
- }
121
- var showStartEllipsis = false;
122
- var showEndEllipsis = false;
123
- var paginationButtons = [];
124
- for (var i = start; i <= end; i++) {
125
- paginationButtons.push(i);
126
- }
127
-
128
- // if paginationButtons contains 1, remove it
129
- if (paginationButtons.includes(1)) {
130
- paginationButtons.shift();
131
- // add an extra item at the end if length of total pages is greater than minMiddleItems+1
132
- if (totalPages > minMiddleItems + 1) paginationButtons.push(end + 1);
133
- }
134
-
135
- // if paginationButtons contains totalPages, remove it
136
- if (paginationButtons.includes(totalPages)) {
137
- paginationButtons.pop();
138
- // add an extra item at the beginning if length of total pages is greater than minMiddleItems+1
139
- if (totalPages > minMiddleItems + 1) paginationButtons.unshift(start - 1);
140
- }
141
- if (paginationButtons[0] > 2) {
142
- showStartEllipsis = true;
143
- }
144
- if (paginationButtons[paginationButtons.length - 1] + 1 < totalPages) {
145
- showEndEllipsis = true;
146
- }
147
- return {
148
- middleItems: paginationButtons,
149
- showStartEllipsis: showStartEllipsis,
150
- showEndEllipsis: showEndEllipsis,
151
- firstItem: 1,
152
- lastItem: totalPages
153
- };
154
- };
155
- var _TablePagination = function _TablePagination(_ref3) {
156
- var _currentPaginationSta;
157
- var controlledCurrentPage = _ref3.currentPage,
158
- onPageChange = _ref3.onPageChange,
159
- onPageSizeChange = _ref3.onPageSizeChange,
160
- _ref3$defaultPageSize = _ref3.defaultPageSize,
161
- defaultPageSize = _ref3$defaultPageSize === void 0 ? tablePagination.defaultPageSize : _ref3$defaultPageSize,
162
- _ref3$showPageSizePic = _ref3.showPageSizePicker,
163
- showPageSizePicker = _ref3$showPageSizePic === void 0 ? true : _ref3$showPageSizePic,
164
- _ref3$showPageNumberS = _ref3.showPageNumberSelector,
165
- showPageNumberSelector = _ref3$showPageNumberS === void 0 ? false : _ref3$showPageNumberS,
166
- showLabel = _ref3.showLabel,
167
- label = _ref3.label,
168
- totalItemCount = _ref3.totalItemCount,
169
- _ref3$paginationType = _ref3.paginationType,
170
- paginationType = _ref3$paginationType === void 0 ? 'client' : _ref3$paginationType,
171
- rest = _objectWithoutProperties(_ref3, _excluded);
21
+ var _TablePagination = function _TablePagination(_ref) {
22
+ var controlledCurrentPage = _ref.currentPage,
23
+ onPageChange = _ref.onPageChange,
24
+ onPageSizeChange = _ref.onPageSizeChange,
25
+ _ref$defaultPageSize = _ref.defaultPageSize,
26
+ defaultPageSize = _ref$defaultPageSize === void 0 ? tablePagination.defaultPageSize : _ref$defaultPageSize,
27
+ _ref$showPageSizePick = _ref.showPageSizePicker,
28
+ showPageSizePicker = _ref$showPageSizePick === void 0 ? true : _ref$showPageSizePick,
29
+ _ref$showPageNumberSe = _ref.showPageNumberSelector,
30
+ showPageNumberSelector = _ref$showPageNumberSe === void 0 ? false : _ref$showPageNumberSe,
31
+ showLabel = _ref.showLabel,
32
+ label = _ref.label,
33
+ totalItemCount = _ref.totalItemCount,
34
+ _ref$paginationType = _ref.paginationType,
35
+ paginationType = _ref$paginationType === void 0 ? 'client' : _ref$paginationType,
36
+ rest = _objectWithoutProperties(_ref, _excluded);
172
37
  var _useTableContext = useTableContext(),
173
38
  setPaginationPage = _useTableContext.setPaginationPage,
174
39
  currentPaginationState = _useTableContext.currentPaginationState,
@@ -176,53 +41,105 @@ var _TablePagination = function _TablePagination(_ref3) {
176
41
  setPaginationRowSize = _useTableContext.setPaginationRowSize,
177
42
  setPaginationType = _useTableContext.setPaginationType,
178
43
  backgroundColor = _useTableContext.backgroundColor;
179
- var _React$useState = React__default.useState(defaultPageSize),
180
- _React$useState2 = _slicedToArray(_React$useState, 2),
181
- currentPageSize = _React$useState2[0],
182
- setCurrentPageSize = _React$useState2[1];
183
- var _React$useState3 = React__default.useState(!isUndefined(controlledCurrentPage) ? controlledCurrentPage : (_currentPaginationSta = currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page) !== null && _currentPaginationSta !== void 0 ? _currentPaginationSta : 0),
184
- _React$useState4 = _slicedToArray(_React$useState3, 2),
185
- currentPage = _React$useState4[0],
186
- setCurrentPage = _React$useState4[1];
187
- var _React$useState5 = React__default.useState(undefined),
188
- _React$useState6 = _slicedToArray(_React$useState5, 2),
189
- currentEllipseHover = _React$useState6[0],
190
- setCurrentEllipseHover = _React$useState6[1];
191
- var defaultLabel = currentPaginationState ? "Showing ".concat(currentPaginationState.page * currentPaginationState.size + 1, "-").concat(currentPaginationState.page * currentPaginationState.size + currentPaginationState.size, " Items") : "Showing 1 to ".concat(totalItems, " Items");
192
- var _useTheme = useTheme(),
193
- platform = _useTheme.platform;
194
- var onMobile = platform === 'onMobile';
44
+
45
+ // Sync pagination type with table context
195
46
  useEffect(function () {
196
- setPaginationRowSize(currentPageSize);
197
47
  setPaginationType(paginationType);
198
- }, []);
199
- useEffect(function () {
200
- if (currentPage && (currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page) !== currentPage) {
201
- setPaginationPage(currentPage);
48
+ // eslint-disable-next-line react-hooks/exhaustive-deps
49
+ }, [paginationType]);
50
+
51
+ // Calculate totalPages - use provided value, or calculate from totalItemCount
52
+ var totalPages = useMemo(function () {
53
+ if (!isUndefined(totalItemCount) && currentPaginationState && !isUndefined(currentPaginationState.size)) {
54
+ return Math.ceil(totalItemCount / currentPaginationState.size);
202
55
  }
203
- }, [currentPage, currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page, setPaginationPage]);
204
- var totalPages = isUndefined(totalItemCount) ? Math.ceil(totalItems / currentPageSize) : Math.ceil(totalItemCount / currentPageSize);
205
- var handlePageChange = useCallback(function (page) {
206
- var pageToJumpTo = page;
207
- if (pageToJumpTo < 0) {
208
- pageToJumpTo = 0;
209
- } else if (pageToJumpTo > totalPages - 1) {
210
- pageToJumpTo = totalPages - 1;
56
+ if (paginationType === 'client' && totalItems && currentPaginationState && !isUndefined(currentPaginationState.size)) {
57
+ return Math.ceil(totalItems / currentPaginationState.size);
211
58
  }
212
- onPageChange === null || onPageChange === void 0 || onPageChange({
213
- page: pageToJumpTo
214
- });
59
+ return 1;
60
+ }, [totalItemCount, currentPaginationState, totalItems, paginationType]);
61
+
62
+ // Determine current page - use controlled value, fallback to table context, or default to 0 (0-indexed)
63
+ var currentPage = useMemo(function () {
215
64
  if (!isUndefined(controlledCurrentPage)) {
216
- pageToJumpTo = controlledCurrentPage;
65
+ return controlledCurrentPage;
66
+ }
67
+ if (!isUndefined(currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page)) {
68
+ return currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page;
69
+ }
70
+ return 0;
71
+ }, [controlledCurrentPage, currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page]);
72
+
73
+ // Determine current page size - fallback to table context, or default
74
+ var currentPageSize = useMemo(function () {
75
+ if (!isUndefined(currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.size)) {
76
+ return currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.size;
77
+ }
78
+ return defaultPageSize;
79
+ }, [currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.size, defaultPageSize]);
80
+
81
+ // Generate default label for table context
82
+ var defaultLabel = useMemo(function () {
83
+ if (label) {
84
+ return label;
85
+ }
86
+ if (currentPaginationState && totalItemCount) {
87
+ var start = currentPaginationState.page * currentPaginationState.size + 1;
88
+ var end = Math.min((currentPaginationState.page + 1) * currentPaginationState.size, totalItemCount);
89
+ return "Showing ".concat(start, "-").concat(end, " Items");
217
90
  }
218
- setPaginationPage(pageToJumpTo);
219
- setCurrentPage(pageToJumpTo);
220
- }, [controlledCurrentPage, onPageChange, setPaginationPage, totalPages]);
91
+ if (currentPaginationState && totalItems) {
92
+ var _start = currentPaginationState.page * currentPaginationState.size + 1;
93
+ var _end = Math.min((currentPaginationState.page + 1) * currentPaginationState.size, totalItems);
94
+ return "Showing ".concat(_start, "-").concat(_end, " Items");
95
+ }
96
+ if (totalItemCount) {
97
+ return "Showing 1 to ".concat(totalItemCount, " Items");
98
+ }
99
+ if (totalItems) {
100
+ return "Showing 1 to ".concat(totalItems, " Items");
101
+ }
102
+ return 'Showing Items';
103
+ }, [label, currentPaginationState, totalItemCount, totalItems]);
104
+
105
+ // Sync page size with table context
221
106
  useEffect(function () {
222
- if (!isUndefined(controlledCurrentPage) && controlledCurrentPage !== currentPage) {
223
- handlePageChange(controlledCurrentPage);
107
+ if (!isUndefined(currentPageSize)) {
108
+ setPaginationRowSize(currentPageSize);
224
109
  }
225
- }, [controlledCurrentPage, currentPage, handlePageChange, onPageChange]);
110
+ // eslint-disable-next-line react-hooks/exhaustive-deps
111
+ }, [currentPageSize]);
112
+
113
+ // Sync page with table context
114
+ useEffect(function () {
115
+ if (!isUndefined(currentPage) && (currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page) !== currentPage) {
116
+ setPaginationPage(currentPage);
117
+ }
118
+ // eslint-disable-next-line react-hooks/exhaustive-deps
119
+ }, [currentPage, currentPaginationState === null || currentPaginationState === void 0 ? void 0 : currentPaginationState.page]);
120
+
121
+ // Handle page change - update table context and call callback
122
+ // Pagination component uses 1-indexed pages, but Table uses 0-indexed
123
+ var handlePageChange = function handlePageChange(_ref2) {
124
+ var page = _ref2.page;
125
+ // Convert from 1-indexed (Pagination) to 0-indexed (Table)
126
+ var zeroIndexedPage = page - 1;
127
+ onPageChange === null || onPageChange === void 0 || onPageChange({
128
+ page: zeroIndexedPage
129
+ });
130
+ setPaginationPage(zeroIndexedPage);
131
+ };
132
+
133
+ // Handle page size change - update table context and call callback
134
+ var handlePageSizeChange = function handlePageSizeChange(_ref3) {
135
+ var pageSize = _ref3.pageSize;
136
+ onPageSizeChange === null || onPageSizeChange === void 0 || onPageSizeChange({
137
+ pageSize: pageSize
138
+ });
139
+ setPaginationRowSize(pageSize);
140
+ };
141
+
142
+ // Validation for server-side pagination
226
143
  if (true) {
227
144
  if (paginationType === 'server' && (isUndefined(totalItemCount) || isUndefined(onPageChange))) {
228
145
  throwBladeError({
@@ -231,207 +148,23 @@ var _TablePagination = function _TablePagination(_ref3) {
231
148
  });
232
149
  }
233
150
  }
234
- var handlePageSizeChange = function handlePageSizeChange(pageSize) {
235
- onPageSizeChange === null || onPageSizeChange === void 0 || onPageSizeChange({
236
- pageSize: pageSize
237
- });
238
- setPaginationRowSize(pageSize);
239
- setCurrentPageSize(pageSize);
240
- };
241
- var shouldDisableNextPage = function shouldDisableNextPage() {
242
- return currentPage >= totalPages - 1;
243
- };
244
- var paginationButtons = getPaginationButtons({
245
- currentSelection: currentPage + 1,
246
- totalPages: totalPages
151
+ return /*#__PURE__*/jsx(BaseBox, {
152
+ backgroundColor: backgroundColor,
153
+ children: /*#__PURE__*/jsx(Pagination, _objectSpread({
154
+ totalPages: totalPages,
155
+ selectedPage: currentPage !== undefined ? currentPage + 1 : undefined,
156
+ defaultSelectedPage: 1,
157
+ onSelectedPageChange: handlePageChange,
158
+ defaultPageSize: defaultPageSize,
159
+ pageSize: currentPageSize,
160
+ onPageSizeChange: handlePageSizeChange,
161
+ showPageSizePicker: showPageSizePicker,
162
+ showPageNumberSelector: showPageNumberSelector,
163
+ showLabel: showLabel,
164
+ label: defaultLabel,
165
+ pageSizeLabel: "rows / page"
166
+ }, rest))
247
167
  });
248
- return /*#__PURE__*/jsxs(BaseBox, _objectSpread(_objectSpread({
249
- display: "flex",
250
- flexDirection: "row",
251
- padding: tablePagination.padding,
252
- backgroundColor: backgroundColor
253
- }, makeAnalyticsAttribute(rest)), {}, {
254
- children: [showLabel && !onMobile && /*#__PURE__*/jsx(BaseBox, {
255
- display: "flex",
256
- justifyContent: "center",
257
- alignItems: "center",
258
- children: /*#__PURE__*/jsx(Text, {
259
- color: "surface.text.gray.subtle",
260
- size: "small",
261
- weight: "regular",
262
- children: label !== null && label !== void 0 ? label : defaultLabel
263
- })
264
- }), /*#__PURE__*/jsxs(BaseBox, {
265
- display: "flex",
266
- flex: 1,
267
- gap: "spacing.2",
268
- justifyContent: "flex-end",
269
- alignItems: "center",
270
- children: [showPageSizePicker && !onMobile && /*#__PURE__*/jsxs(BaseBox, {
271
- display: "flex",
272
- flexDirection: "row",
273
- alignItems: "center",
274
- children: [/*#__PURE__*/jsxs(Dropdown, {
275
- selectionType: "single",
276
- children: [/*#__PURE__*/jsx(SelectInput, {
277
- accessibilityLabel: "Select pages per row",
278
- name: "page-size",
279
- label: "",
280
- labelPosition: "inside-input",
281
- placeholder: "",
282
- onChange: function onChange(_ref4) {
283
- var values = _ref4.values;
284
- handlePageSizeChange(Number(values[0]));
285
- },
286
- defaultValue: currentPageSize.toString()
287
- }), /*#__PURE__*/jsx(DropdownOverlay, {
288
- children: /*#__PURE__*/jsx(ActionList, {
289
- children: pageSizeOptions.map(function (item, index) {
290
- return /*#__PURE__*/jsx(ActionListItem, {
291
- title: item.toString(),
292
- value: item.toString()
293
- }, index);
294
- })
295
- })
296
- })]
297
- }), /*#__PURE__*/jsx(BaseBox, {
298
- "aria-hidden": true,
299
- paddingLeft: "spacing.3",
300
- paddingRight: "spacing.3",
301
- children: /*#__PURE__*/jsx(Text, {
302
- children: "rows / page"
303
- })
304
- })]
305
- }), /*#__PURE__*/jsxs(BaseBox, {
306
- display: "flex",
307
- flexDirection: "row",
308
- gap: "spacing.2",
309
- flex: onMobile ? 1 : undefined,
310
- alignItems: "center",
311
- children: [/*#__PURE__*/jsx(Button, {
312
- icon: ChevronLeftIcon,
313
- accessibilityLabel: "Previous Page",
314
- variant: "tertiary",
315
- onClick: function onClick() {
316
- handlePageChange(currentPage - 1);
317
- },
318
- isDisabled: currentPage <= 0
319
- }), onMobile && /*#__PURE__*/jsx(BaseBox, {
320
- flex: 1,
321
- alignItems: "center",
322
- justifyContent: "center",
323
- children: /*#__PURE__*/jsx(Text, {
324
- color: "surface.text.gray.subtle",
325
- size: "small",
326
- textAlign: "center",
327
- children: "Showing ".concat(currentPage + 1, " of ").concat(totalPages, " pages")
328
- })
329
- }), totalPages > 1 && showPageNumberSelector && !onMobile && /*#__PURE__*/jsxs(BaseBox, {
330
- gap: "spacing.1",
331
- display: "flex",
332
- flexDirection: "row",
333
- children: [/*#__PURE__*/jsx(PageSelectionButton, _objectSpread(_objectSpread({
334
- onClick: function onClick() {
335
- return handlePageChange(paginationButtons.firstItem - 1);
336
- },
337
- isSelected: currentPage === paginationButtons.firstItem - 1
338
- }, makeAccessible({
339
- label: "Page ".concat(paginationButtons.firstItem)
340
- })), {}, {
341
- children: /*#__PURE__*/jsx(Text, {
342
- size: "medium",
343
- color: currentPage === paginationButtons.firstItem - 1 ? tablePagination.pageSelectionButton.textColorSelected : tablePagination.pageSelectionButton.textColor,
344
- children: paginationButtons.firstItem
345
- })
346
- })), paginationButtons.showStartEllipsis && /*#__PURE__*/jsx(PageSelectionButton, _objectSpread(_objectSpread({
347
- onClick: function onClick() {
348
- return handlePageChange(currentPage - 5);
349
- },
350
- onMouseOver: function onMouseOver() {
351
- return setCurrentEllipseHover('start');
352
- },
353
- onMouseLeave: function onMouseLeave() {
354
- return setCurrentEllipseHover(undefined);
355
- },
356
- onFocus: function onFocus() {
357
- return setCurrentEllipseHover('start');
358
- },
359
- onBlur: function onBlur() {
360
- return setCurrentEllipseHover(undefined);
361
- }
362
- }, makeAccessible({
363
- label: 'Go back 5 pages'
364
- })), {}, {
365
- children: currentEllipseHover === 'start' ? /*#__PURE__*/jsx(ChevronsLeftIcon, {
366
- size: "medium"
367
- }) : /*#__PURE__*/jsx(MoreHorizontalIcon, {
368
- size: "medium"
369
- })
370
- })), paginationButtons.middleItems.map(function (item) {
371
- return /*#__PURE__*/jsx(PageSelectionButton, _objectSpread(_objectSpread({
372
- onClick: function onClick() {
373
- return handlePageChange(item - 1);
374
- },
375
- isSelected: currentPage === item - 1
376
- }, makeAccessible({
377
- label: "Page ".concat(item)
378
- })), {}, {
379
- children: /*#__PURE__*/jsx(Text, {
380
- size: "medium",
381
- color: currentPage === item - 1 ? tablePagination.pageSelectionButton.textColorSelected : tablePagination.pageSelectionButton.textColor,
382
- children: item
383
- })
384
- }), item - 1);
385
- }), paginationButtons.showEndEllipsis && /*#__PURE__*/jsx(PageSelectionButton, _objectSpread(_objectSpread({
386
- onClick: function onClick() {
387
- return handlePageChange(currentPage + 5);
388
- },
389
- onMouseOver: function onMouseOver() {
390
- return setCurrentEllipseHover('end');
391
- },
392
- onMouseLeave: function onMouseLeave() {
393
- return setCurrentEllipseHover(undefined);
394
- },
395
- onFocus: function onFocus() {
396
- return setCurrentEllipseHover('end');
397
- },
398
- onBlur: function onBlur() {
399
- return setCurrentEllipseHover(undefined);
400
- }
401
- }, makeAccessible({
402
- label: 'Go forward 5 pages'
403
- })), {}, {
404
- children: currentEllipseHover === 'end' ? /*#__PURE__*/jsx(ChevronsRightIcon, {
405
- size: "medium"
406
- }) : /*#__PURE__*/jsx(MoreHorizontalIcon, {
407
- size: "medium"
408
- })
409
- })), /*#__PURE__*/jsx(PageSelectionButton, _objectSpread(_objectSpread({
410
- onClick: function onClick() {
411
- return handlePageChange(paginationButtons.lastItem - 1);
412
- },
413
- isSelected: currentPage === paginationButtons.lastItem - 1
414
- }, makeAccessible({
415
- label: "Page ".concat(paginationButtons.lastItem)
416
- })), {}, {
417
- children: /*#__PURE__*/jsx(Text, {
418
- size: "medium",
419
- color: currentPage === paginationButtons.lastItem - 1 ? tablePagination.pageSelectionButton.textColorSelected : tablePagination.pageSelectionButton.textColor,
420
- children: paginationButtons.lastItem
421
- })
422
- }))]
423
- }), /*#__PURE__*/jsx(Button, {
424
- variant: "tertiary",
425
- icon: ChevronRightIcon,
426
- accessibilityLabel: "Next Page",
427
- onClick: function onClick() {
428
- handlePageChange(currentPage + 1);
429
- },
430
- isDisabled: shouldDisableNextPage()
431
- })]
432
- })]
433
- })]
434
- }));
435
168
  };
436
169
  var TablePagination = /*#__PURE__*/assignWithoutSideEffects(_TablePagination, {
437
170
  componentId: ComponentIds.TablePagination