pixelize-design-library 2.3.1-beta.6 → 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 +35 -20
- 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
|
@@ -43,6 +43,15 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
43
43
|
return result;
|
|
44
44
|
};
|
|
45
45
|
})();
|
|
46
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
47
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
48
|
+
if (ar || !(i in from)) {
|
|
49
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
50
|
+
ar[i] = from[i];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
54
|
+
};
|
|
46
55
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
56
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
57
|
};
|
|
@@ -139,22 +148,26 @@ function Table(_a) {
|
|
|
139
148
|
(0, react_1.useEffect)(function () {
|
|
140
149
|
if (!groupLoadMore)
|
|
141
150
|
return;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
setAccumulatedRows(function (prev) {
|
|
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();
|
|
170
|
+
});
|
|
158
171
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
159
172
|
}, [tableData, groupLoadMore]);
|
|
160
173
|
(0, react_1.useEffect)(function () {
|
|
@@ -171,9 +184,11 @@ function Table(_a) {
|
|
|
171
184
|
setDensityState(d);
|
|
172
185
|
savePreferences === null || savePreferences === void 0 ? void 0 : savePreferences(__assign(__assign({}, tablePreferences), { columns: columnsList, groupBy: groupByState !== null && groupByState !== void 0 ? groupByState : null, density: d }));
|
|
173
186
|
};
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
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 });
|
|
177
192
|
};
|
|
178
193
|
var _filteredData = (0, react_1.useMemo)(function () {
|
|
179
194
|
return (0, table_1.searchAndSortData)(filteredData, columnsSearch);
|
|
@@ -359,7 +374,7 @@ function Table(_a) {
|
|
|
359
374
|
react_1.default.createElement(TableSearch_1.default, { onSearch: onGlobalSearch }),
|
|
360
375
|
isTableSettings && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
361
376
|
react_1.default.createElement(Divider_1.default, null),
|
|
362
|
-
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 }))),
|
|
363
378
|
headerActions && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
364
379
|
react_1.default.createElement(Divider_1.default, null),
|
|
365
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);
|