pixelize-design-library 2.3.1-beta.7 → 2.3.1-beta.8
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/dist/Components/Table/Table.js +24 -18
- package/dist/Components/Table/hooks/useTable.d.ts +1 -1
- package/dist/Components/Table/hooks/useTable.js +3 -2
- package/dist/Components/Table/settings/TableSettings.d.ts +2 -3
- package/dist/Components/Table/settings/TableSettings.js +3 -4
- package/package.json +1 -1
|
@@ -148,21 +148,25 @@ function Table(_a) {
|
|
|
148
148
|
(0, react_1.useEffect)(function () {
|
|
149
149
|
if (!groupLoadMore)
|
|
150
150
|
return;
|
|
151
|
-
if (!pendingLoadMoreRef.current) {
|
|
152
|
-
// Fresh load (initial / search / filter / sort / page-size) → reset.
|
|
153
|
-
setAccumulatedRows(tableData);
|
|
154
|
-
return;
|
|
155
|
-
}
|
|
156
|
-
// A "Load more" is in flight. The parent may re-emit the SAME page (new array
|
|
157
|
-
// reference) on intermediate re-renders before the next page actually arrives,
|
|
158
|
-
// so only consume the pending flag once genuinely new rows (by id) show up.
|
|
159
151
|
setAccumulatedRows(function (prev) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
152
|
+
if (prev.length === 0)
|
|
153
|
+
return tableData.slice();
|
|
154
|
+
var accIds = new Set(prev.map(function (r) { return r.id; }));
|
|
155
|
+
if (pendingLoadMoreRef.current) {
|
|
156
|
+
// A "Load more" is in flight. The parent may re-emit the SAME page (new
|
|
157
|
+
// array reference) on intermediate re-renders before the next page arrives,
|
|
158
|
+
// so only append + consume the flag once genuinely new rows show up.
|
|
159
|
+
var newRows = tableData.filter(function (r) { return !accIds.has(r.id); });
|
|
160
|
+
if (newRows.length === 0)
|
|
161
|
+
return prev; // same page re-emitted — keep waiting
|
|
162
|
+
pendingLoadMoreRef.current = false;
|
|
163
|
+
return __spreadArray(__spreadArray([], prev, true), newRows, true);
|
|
164
|
+
}
|
|
165
|
+
// Not a load-more: a re-emit of already-loaded rows keeps the accumulation
|
|
166
|
+
// (the parent re-renders the current page often). Genuinely new rows
|
|
167
|
+
// (search / filter / sort / page-size / reload) reset it.
|
|
168
|
+
var allKnown = tableData.length > 0 && tableData.every(function (r) { return accIds.has(r.id); });
|
|
169
|
+
return allKnown ? prev : tableData.slice();
|
|
166
170
|
});
|
|
167
171
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
172
|
}, [tableData, groupLoadMore]);
|
|
@@ -180,9 +184,11 @@ function Table(_a) {
|
|
|
180
184
|
setDensityState(d);
|
|
181
185
|
savePreferences === null || savePreferences === void 0 ? void 0 : savePreferences(__assign(__assign({}, tablePreferences), { columns: columnsList, groupBy: groupByState !== null && groupByState !== void 0 ? groupByState : null, density: d }));
|
|
182
186
|
};
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
// Settings "Save": persist columns + group (+ current density) in ONE write so
|
|
188
|
+
// they don't clobber each other, and apply them locally.
|
|
189
|
+
var handleSettingsSave = function (cols, group) {
|
|
190
|
+
setGroupByState(group);
|
|
191
|
+
handleColumnPreferences(cols, { density: densityState, groupBy: group !== null && group !== void 0 ? group : null });
|
|
186
192
|
};
|
|
187
193
|
var _filteredData = (0, react_1.useMemo)(function () {
|
|
188
194
|
return (0, table_1.searchAndSortData)(filteredData, columnsSearch);
|
|
@@ -368,7 +374,7 @@ function Table(_a) {
|
|
|
368
374
|
react_1.default.createElement(TableSearch_1.default, { onSearch: onGlobalSearch }),
|
|
369
375
|
isTableSettings && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
370
376
|
react_1.default.createElement(Divider_1.default, null),
|
|
371
|
-
react_1.default.createElement(TableSettings_1.default, { columns: columnsList, onSave: function (cols) { return
|
|
377
|
+
react_1.default.createElement(TableSettings_1.default, { columns: columnsList, onSave: function (cols, group) { return handleSettingsSave(cols, group); }, tableSettings: tableSettings, density: densityState, onDensityChange: handleDensityChange, groupBy: groupByState }))),
|
|
372
378
|
headerActions && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
373
379
|
react_1.default.createElement(Divider_1.default, null),
|
|
374
380
|
react_1.default.createElement(HeaderActions_1.default, { actions: headerActions, selections: selection }))),
|
|
@@ -41,7 +41,7 @@ declare const useTable: ({ tableBorderColor, data, isPagination, selections, onS
|
|
|
41
41
|
rowsPerPage: number;
|
|
42
42
|
setCurrentPage: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
43
43
|
columnsList: TableHeaderProps[];
|
|
44
|
-
handleColumnPreferences: (columns: any) => void;
|
|
44
|
+
handleColumnPreferences: (columns: any, extra?: Record<string, any>) => void;
|
|
45
45
|
isSelecting: boolean;
|
|
46
46
|
};
|
|
47
47
|
export default useTable;
|
|
@@ -187,10 +187,11 @@ var useTable = function (_a) {
|
|
|
187
187
|
(_a = onSelectionRef.current) === null || _a === void 0 ? void 0 : _a.call(onSelectionRef, selectedItems);
|
|
188
188
|
}
|
|
189
189
|
}, [tableData]);
|
|
190
|
-
var handleColumnPreferences = function (columns) {
|
|
190
|
+
var handleColumnPreferences = function (columns, extra) {
|
|
191
|
+
if (extra === void 0) { extra = {}; }
|
|
191
192
|
setColumnsList(columns);
|
|
192
193
|
savePreferences &&
|
|
193
|
-
savePreferences(__assign(__assign({}, tablePreferences), { columns: columns }));
|
|
194
|
+
savePreferences(__assign(__assign(__assign({}, tablePreferences), { columns: columns }), extra));
|
|
194
195
|
};
|
|
195
196
|
return {
|
|
196
197
|
tableData: tableData,
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { TableDensity, TableProps } from "../TableProps";
|
|
3
|
-
declare const TableSettings: ({ columns, onSave, density, onDensityChange, groupBy,
|
|
3
|
+
declare const TableSettings: ({ columns, onSave, density, onDensityChange, groupBy, }: {
|
|
4
4
|
columns: TableProps["columns"];
|
|
5
|
-
onSave: (updatedColumns: TableProps["columns"]) => void;
|
|
5
|
+
onSave: (updatedColumns: TableProps["columns"], groupBy: string | number | undefined) => void;
|
|
6
6
|
tableSettings?: TableProps["tableSettings"];
|
|
7
7
|
density?: TableDensity;
|
|
8
8
|
onDensityChange?: (d: TableDensity) => void;
|
|
9
9
|
groupBy?: string | number;
|
|
10
|
-
onGroupByChange?: (value: string | number | undefined) => void;
|
|
11
10
|
}) => React.JSX.Element;
|
|
12
11
|
export default TableSettings;
|
|
@@ -71,7 +71,7 @@ var DENSITY_OPTIONS = [
|
|
|
71
71
|
];
|
|
72
72
|
var TableSettings = function (_a) {
|
|
73
73
|
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
|
74
|
-
var columns = _a.columns, onSave = _a.onSave, _p = _a.density, density = _p === void 0 ? "normal" : _p, onDensityChange = _a.onDensityChange, groupBy = _a.groupBy
|
|
74
|
+
var columns = _a.columns, onSave = _a.onSave, _p = _a.density, density = _p === void 0 ? "normal" : _p, onDensityChange = _a.onDensityChange, groupBy = _a.groupBy;
|
|
75
75
|
var theme = (0, useCustomTheme_1.useCustomTheme)();
|
|
76
76
|
var childInputMethodsRef = (0, react_2.useRef)({});
|
|
77
77
|
var _q = (0, react_2.useState)(false), settingsOpen = _q[0], setSettingsOpen = _q[1];
|
|
@@ -80,10 +80,9 @@ var TableSettings = function (_a) {
|
|
|
80
80
|
// Group selection is applied on Save (not live), per "click Apply to group".
|
|
81
81
|
var _t = (0, react_2.useState)(groupBy), selectedGroup = _t[0], setSelectedGroup = _t[1];
|
|
82
82
|
var handleSave = (0, react_2.useCallback)(function () {
|
|
83
|
-
onSave(items);
|
|
84
|
-
onGroupByChange === null || onGroupByChange === void 0 ? void 0 : onGroupByChange(selectedGroup);
|
|
83
|
+
onSave(items, selectedGroup);
|
|
85
84
|
setSettingsOpen(false);
|
|
86
|
-
}, [onSave, items,
|
|
85
|
+
}, [onSave, items, selectedGroup]);
|
|
87
86
|
var handleOpen = (0, react_2.useCallback)(function () {
|
|
88
87
|
setItems(columns);
|
|
89
88
|
setSelectedGroup(groupBy);
|