@synerise/ds-table-new 1.5.0 → 1.5.2

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.5.2](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.5.1...@synerise/ds-table-new@1.5.2) (2026-06-27)
7
+
8
+ **Note:** Version bump only for package @synerise/ds-table-new
9
+
10
+ ## [1.5.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.5.0...@synerise/ds-table-new@1.5.1) (2026-06-24)
11
+
12
+ ### Bug Fixes
13
+
14
+ - **table-new:** pagination fixes ([57a4ef9](https://github.com/Synerise/synerise-design/commit/57a4ef964ebe284f9c389b6d568be3a5b4bb33ca))
15
+
6
16
  # [1.5.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.4.5...@synerise/ds-table-new@1.5.0) (2026-06-22)
7
17
 
8
18
  ### Features
@@ -1,5 +1,5 @@
1
- import { PaginationProps } from 'antd';
2
1
  import { CSSProperties, HTMLAttributes, MouseEvent, MutableRefObject, ReactElement, ReactNode, RefObject } from 'react';
2
+ import { PaginationProps } from '@synerise/ds-pagination';
3
3
  import { SearchInputProps } from '@synerise/ds-search';
4
4
  import { TooltipProps } from '@synerise/ds-tooltip';
5
5
  import { Column, ColumnDef, ColumnMeta, Row, RowData } from '@tanstack/react-table';
@@ -4,7 +4,7 @@ import { TableHorizontalScroll } from "../TableHorizontalScroll/TableHorizontalS
4
4
  const BaseTableWrapper = /* @__PURE__ */ styled.div.withConfig({
5
5
  displayName: "BaseTablestyles__BaseTableWrapper",
6
6
  componentId: "sc-1oa5lc2-0"
7
- })(["", " --table-size:", ";", " position:relative;z-index:1;.ant-pagination .ant-pagination-total-text strong{font-weight:500;}"], (props) => css(["", ""], Object.entries(props.columnSizing || {}).map(([key, value]) => `--${key}-width: ${value}px;`).join("\n")), (props) => !props.isEmpty && props.$size ? `${props.$size}px` : "100%", (props) => !props.$isColumnSizingReady && `opacity: 0;`);
7
+ })(["", " --table-size:", ";", " position:relative;z-index:1;.ds-pagination .ds-pagination-total-text strong{font-weight:500;}"], (props) => css(["", ""], Object.entries(props.columnSizing || {}).map(([key, value]) => `--${key}-width: ${value}px;`).join("\n")), (props) => !props.isEmpty && props.$size ? `${props.$size}px` : "100%", (props) => !props.$isColumnSizingReady && `opacity: 0;`);
8
8
  const TableContainer = /* @__PURE__ */ styled.div.withConfig({
9
9
  displayName: "BaseTablestyles__TableContainer",
10
10
  componentId: "sc-1oa5lc2-1"
@@ -8,11 +8,22 @@ const TablePagination = ({
8
8
  const {
9
9
  table
10
10
  } = useTableContext();
11
- return /* @__PURE__ */ jsx(PaginationWrapper, { "data-testid": "ds-table-pagination", children: /* @__PURE__ */ jsx(Pagination, { hideOnSinglePage: true, ...rest, total: table.getRowCount(), onShowSizeChange: (_current, size) => {
12
- table.setPageSize(size);
13
- }, onChange: (page) => {
14
- table.setPageIndex(page - 1);
15
- }, pageSize: table.getState().pagination.pageSize }) });
11
+ return /* @__PURE__ */ jsx(PaginationWrapper, { "data-testid": "ds-table-pagination", children: /* @__PURE__ */ jsx(
12
+ Pagination,
13
+ {
14
+ hideOnSinglePage: true,
15
+ ...rest,
16
+ total: table.getRowCount(),
17
+ onShowSizeChange: (_current, size) => {
18
+ table.setPageSize(size);
19
+ },
20
+ onChange: (page) => {
21
+ table.setPageIndex(page - 1);
22
+ },
23
+ pageSize: table.getState().pagination.pageSize,
24
+ current: table.getState().pagination.pageIndex + 1
25
+ }
26
+ ) });
16
27
  };
17
28
  export {
18
29
  TablePagination
@@ -137,6 +137,39 @@ const useTable = ({
137
137
  initialState: paginationInitialState,
138
138
  ...paginationProps
139
139
  } = getPaginationConfig(!infiniteScroll && pagination);
140
+ const manualPaginationConfig = hasPagination && typeof pagination === "object" && pagination.total !== void 0 && pagination.total > data.length ? pagination : void 0;
141
+ const isManualPagination = !!manualPaginationConfig;
142
+ const paginationTotal = typeof pagination === "object" ? pagination.total : void 0;
143
+ const consumerPageIndex = (manualPaginationConfig?.current ?? 1) - 1;
144
+ const consumerPageSize = manualPaginationConfig?.pageSize ?? 10;
145
+ const [manualPagination, setManualPagination] = useState({
146
+ pageIndex: consumerPageIndex,
147
+ pageSize: consumerPageSize
148
+ });
149
+ const manualPaginationRef = useRef(manualPagination);
150
+ manualPaginationRef.current = manualPagination;
151
+ useEffect(() => {
152
+ if (!isManualPagination) {
153
+ return;
154
+ }
155
+ setManualPagination({
156
+ pageIndex: consumerPageIndex,
157
+ pageSize: consumerPageSize
158
+ });
159
+ }, [consumerPageIndex, consumerPageSize, isManualPagination]);
160
+ const handleManualPaginationChange = useCallback((updater) => {
161
+ if (!manualPaginationConfig) {
162
+ return;
163
+ }
164
+ const prev = manualPaginationRef.current;
165
+ const next = typeof updater === "function" ? updater(prev) : updater;
166
+ manualPaginationRef.current = next;
167
+ setManualPagination(next);
168
+ if (next.pageSize !== prev.pageSize) {
169
+ manualPaginationConfig.onShowSizeChange?.(next.pageIndex + 1, next.pageSize);
170
+ }
171
+ manualPaginationConfig.onChange?.(next.pageIndex + 1, next.pageSize);
172
+ }, [manualPaginationConfig]);
140
173
  const getSubRows = useCallback((row) => {
141
174
  return row[childrenColumnName];
142
175
  }, [childrenColumnName]);
@@ -162,6 +195,14 @@ const useTable = ({
162
195
  getPaginationRowModel: hasPagination ? getPaginationRowModel() : void 0,
163
196
  getExpandedRowModel: expandable ? getExpandedRowModel() : void 0,
164
197
  getGroupedRowModel: getGroupedRowModel(),
198
+ // Server-side paging: page against the server total and don't slice the local page.
199
+ // Set these ONLY in manual mode — passing `onPaginationChange: undefined` in client mode
200
+ // overrides TanStack's default internal state-updater, which freezes page/size changes.
201
+ ...isManualPagination ? {
202
+ manualPagination: true,
203
+ rowCount: manualPaginationConfig.total,
204
+ onPaginationChange: handleManualPaginationChange
205
+ } : {},
165
206
  onRowSelectionChange: handleSelectionChange,
166
207
  // Swallow TanStack's expansion writes only when the consumer is the source
167
208
  // of truth (controlled via `expandable.expandedRowKeys`). For uncontrolled
@@ -201,9 +242,22 @@ const useTable = ({
201
242
  // TanStack keeps and manages its own internal state.
202
243
  ...isExpansionControlled ? {
203
244
  expanded: expandedKeys
245
+ } : {},
246
+ // Server-side paging: driven by the local responsive copy (seeded from / synced to the
247
+ // consumer's current/pageSize), so the controls react immediately to user interaction.
248
+ ...isManualPagination ? {
249
+ pagination: manualPagination
204
250
  } : {}
205
251
  }
206
252
  });
253
+ const previousSearchQuery = useRef(searchQuery);
254
+ useEffect(() => {
255
+ if (previousSearchQuery.current === searchQuery) {
256
+ return;
257
+ }
258
+ previousSearchQuery.current = searchQuery;
259
+ table.setPageIndex(0);
260
+ }, [searchQuery]);
207
261
  return {
208
262
  table,
209
263
  paginationProps,
@@ -214,7 +268,9 @@ const useTable = ({
214
268
  setSearchQuery,
215
269
  handleSearchClear,
216
270
  hasBuiltInSearch,
217
- totalDataCount: data.length
271
+ // Header-counter source: prefer the declared server total, fall back to the rows we hold.
272
+ // (A consumer `dataSourceTotalCount` prop still wins — it is spread over this in Table.tsx.)
273
+ totalDataCount: paginationTotal ?? data.length
218
274
  };
219
275
  };
220
276
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synerise/ds-table-new",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
4
4
  "description": "TableNew UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -45,7 +45,7 @@
45
45
  "@floating-ui/react": "^0.27.16",
46
46
  "@synerise/ds-badge": "^1.0.57",
47
47
  "@synerise/ds-button": "^1.5.33",
48
- "@synerise/ds-checkbox": "^1.2.34",
48
+ "@synerise/ds-checkbox": "^1.2.35",
49
49
  "@synerise/ds-copy-icon": "^1.2.15",
50
50
  "@synerise/ds-dropdown": "^1.3.16",
51
51
  "@synerise/ds-flag": "^1.0.12",
@@ -55,13 +55,13 @@
55
55
  "@synerise/ds-input-number": "^1.2.48",
56
56
  "@synerise/ds-loader": "^1.0.17",
57
57
  "@synerise/ds-modal": "^1.6.1",
58
- "@synerise/ds-pagination": "^1.0.68",
58
+ "@synerise/ds-pagination": "^1.0.69",
59
59
  "@synerise/ds-result": "^1.0.64",
60
60
  "@synerise/ds-scrollbar": "^1.5.1",
61
61
  "@synerise/ds-search": "^1.5.29",
62
- "@synerise/ds-skeleton": "^1.0.58",
62
+ "@synerise/ds-skeleton": "^1.0.59",
63
63
  "@synerise/ds-tag": "^1.4.31",
64
- "@synerise/ds-tags": "^1.5.45",
64
+ "@synerise/ds-tags": "^1.5.46",
65
65
  "@synerise/ds-tooltip": "^1.5.3",
66
66
  "@synerise/ds-typography": "^1.1.26",
67
67
  "@synerise/ds-utils": "^1.10.1",
@@ -80,5 +80,5 @@
80
80
  "react-intl": ">= 3.12.0 <= 6.8",
81
81
  "styled-components": "^5.3.3"
82
82
  },
83
- "gitHead": "d71e1daf33593c1e9d8959942a6caa5d8db981fc"
83
+ "gitHead": "dfd892acc1d02abebcf661db3fb32f0fc4b6c354"
84
84
  }