@synerise/ds-table-new 1.4.5 → 1.5.1
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 +12 -0
- package/dist/Table.d.ts +1 -1
- package/dist/Table.js +2 -1
- package/dist/Table.types.d.ts +2 -2
- package/dist/components/TablePagination/TablePagination.js +16 -5
- package/dist/hooks/useTable.js +57 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,18 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- **table-new:** pagination fixes ([57a4ef9](https://github.com/Synerise/synerise-design/commit/57a4ef964ebe284f9c389b6d568be3a5b4bb33ca))
|
|
11
|
+
|
|
12
|
+
# [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)
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
- **table-new:** extend maxHeight prop to default table component ([c99b632](https://github.com/Synerise/synerise-design/commit/c99b632f9a1ba1b6e8c62822512c827eb238743c))
|
|
17
|
+
|
|
6
18
|
## [1.4.5](https://github.com/Synerise/synerise-design/compare/@synerise/ds-table-new@1.4.4...@synerise/ds-table-new@1.4.5) (2026-06-17)
|
|
7
19
|
|
|
8
20
|
**Note:** Version bump only for package @synerise/ds-table-new
|
package/dist/Table.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { default as React } from 'react';
|
|
2
2
|
import { TableProps } from './Table.types';
|
|
3
|
-
export declare const Table: <TData extends object, TValue>({ data, columns, texts: defaultTexts, selectionConfig, isLoading, selectedRowKeys, pagination, matchesSearchQuery, filterData, onSearchQueryChange, searchProps, expandable, rowKey, onSort, tableRef, stickyHeader, ...props }: TableProps<TData, TValue>) => React.JSX.Element;
|
|
3
|
+
export declare const Table: <TData extends object, TValue>({ data, columns, texts: defaultTexts, selectionConfig, isLoading, selectedRowKeys, pagination, matchesSearchQuery, filterData, onSearchQueryChange, searchProps, expandable, rowKey, onSort, tableRef, stickyHeader, maxHeight, ...props }: TableProps<TData, TValue>) => React.JSX.Element;
|
package/dist/Table.js
CHANGED
|
@@ -27,6 +27,7 @@ const Table = ({
|
|
|
27
27
|
onSort,
|
|
28
28
|
tableRef,
|
|
29
29
|
stickyHeader,
|
|
30
|
+
maxHeight,
|
|
30
31
|
...props
|
|
31
32
|
}) => {
|
|
32
33
|
const texts = useDefaultTexts(defaultTexts);
|
|
@@ -80,7 +81,7 @@ const Table = ({
|
|
|
80
81
|
stickyData,
|
|
81
82
|
setStickyData
|
|
82
83
|
} : null, [stickyData, stickyHeader]);
|
|
83
|
-
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(StickyContext.Provider, { value: stickyValue, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selectionConfig, children: /* @__PURE__ */ jsx(BaseTable, { texts, isLoading: effectiveIsLoading, hasPagination, paginationProps, tableOuterRef: wrapperRef, selectedRowKeys, columnSizing, isColumnSizingReady, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, dataSourceTotalCount: totalDataCount, expandable, ...props }) }) }) });
|
|
84
|
+
return /* @__PURE__ */ jsx(TableContext.Provider, { value: tableContextValue, children: /* @__PURE__ */ jsx(StickyContext.Provider, { value: stickyValue, children: /* @__PURE__ */ jsx(SelectionContext.Provider, { value: selectionConfig, children: /* @__PURE__ */ jsx(BaseTable, { texts, isLoading: effectiveIsLoading, hasPagination, paginationProps, tableOuterRef: wrapperRef, selectedRowKeys, columnSizing, isColumnSizingReady, searchQuery, setSearchQuery, handleSearchClear, hasBuiltInSearch, searchProps, dataSourceTotalCount: totalDataCount, expandable, withBodyScroll: !!maxHeight, maxHeight, ...props }) }) }) });
|
|
84
85
|
};
|
|
85
86
|
export {
|
|
86
87
|
Table
|
package/dist/Table.types.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ export type SharedTableProps<TData, TValue> = {
|
|
|
112
112
|
columns: ColumnDef<TData, TValue>[];
|
|
113
113
|
dataSourceTotalCount?: number;
|
|
114
114
|
expandable?: Expandable<TData>;
|
|
115
|
+
/** max-height (px) for the built-in scroll container. Ignored when scrollElementRef is provided. Defaults to 800. */
|
|
116
|
+
maxHeight?: number;
|
|
115
117
|
onRowClick?: (row: TData, event: MouseEvent<HTMLTableRowElement>) => void;
|
|
116
118
|
/**
|
|
117
119
|
* Returns arbitrary HTML attributes (style, className, data-*, event handlers, etc.)
|
|
@@ -353,8 +355,6 @@ export type VirtualTableRef = {
|
|
|
353
355
|
highlightRow: (rowKey: string, options?: HighlightOptions) => void;
|
|
354
356
|
};
|
|
355
357
|
type VirtualProps = {
|
|
356
|
-
/** max-height (px) for the built-in scroll container. Ignored when scrollElementRef is provided. Defaults to 800. */
|
|
357
|
-
maxHeight?: number;
|
|
358
358
|
tableRef?: RefObject<VirtualTableRef>;
|
|
359
359
|
/**
|
|
360
360
|
* uses body virtualisation
|
|
@@ -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(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
package/dist/hooks/useTable.js
CHANGED
|
@@ -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
|
-
|
|
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.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "TableNew UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"react-intl": ">= 3.12.0 <= 6.8",
|
|
81
81
|
"styled-components": "^5.3.3"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "190c325eb1de36751984fd1a5a4674669a1311a3"
|
|
84
84
|
}
|