@cerberus-design/data-grid 0.25.3 → 1.0.0-rc.5
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/column-helpers.cjs +55 -21
- package/dist/column-helpers.js +55 -17
- package/dist/components/cerby-data-grid.client.cjs +12 -11
- package/dist/components/cerby-data-grid.client.js +12 -7
- package/dist/components/count-menu.client.cjs +46 -49
- package/dist/components/count-menu.client.js +46 -45
- package/dist/components/data-grid.client.cjs +89 -82
- package/dist/components/data-grid.client.js +89 -78
- package/dist/components/features.client.cjs +72 -76
- package/dist/components/features.client.js +72 -72
- package/dist/components/grid.client.cjs +280 -309
- package/dist/components/grid.client.js +281 -303
- package/dist/components/pagination.client.cjs +90 -113
- package/dist/components/pagination.client.js +90 -109
- package/dist/components/pinned-items.client.cjs +60 -59
- package/dist/components/pinned-items.client.js +60 -55
- package/dist/components/sort-items.client.cjs +44 -49
- package/dist/components/sort-items.client.js +44 -45
- package/dist/const.cjs +32 -43
- package/dist/const.js +33 -31
- package/dist/context.client.cjs +12 -12
- package/dist/context.client.js +12 -8
- package/dist/hooks.client.cjs +13 -20
- package/dist/hooks.client.js +13 -16
- package/dist/index.cjs +9 -15
- package/dist/index.js +5 -4
- package/dist/store.cjs +241 -284
- package/dist/store.js +241 -280
- package/dist/utils.cjs +23 -45
- package/dist/utils.js +23 -41
- package/dist/virtualizer.client.cjs +63 -53
- package/dist/virtualizer.client.js +63 -49
- package/package.json +29 -26
package/dist/store.js
CHANGED
|
@@ -1,283 +1,244 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { determineInitialCount, determinePageIndex, determinePageRange, determinePageSize, determineRowHeight } from "./utils.js";
|
|
3
|
+
import { batch, createComputed, createSignal } from "@cerberus-design/signals";
|
|
4
|
+
//#region src/store.ts
|
|
5
|
+
/**
|
|
6
|
+
* Internal signal-based Store engine driving the state. We expose this in
|
|
7
|
+
* the public Context API.
|
|
8
|
+
*/
|
|
6
9
|
function createGridStore(options) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
const newSort = { id: colId, desc: true };
|
|
240
|
-
setSorting(multi ? [...current, newSort] : [newSort]);
|
|
241
|
-
}
|
|
242
|
-
},
|
|
243
|
-
setPage: (details) => {
|
|
244
|
-
setPageIndex(details.page);
|
|
245
|
-
options.onPageChange?.(details);
|
|
246
|
-
},
|
|
247
|
-
setPageSize: (size) => {
|
|
248
|
-
if (isServerPaginated()) {
|
|
249
|
-
setPageIndex(DEFAULT_PAGE_IDX);
|
|
250
|
-
}
|
|
251
|
-
setPageSize(size);
|
|
252
|
-
},
|
|
253
|
-
setGlobalFilter: (val) => {
|
|
254
|
-
batch(() => {
|
|
255
|
-
setGlobalFilter(val);
|
|
256
|
-
setPageIndex(DEFAULT_PAGE_IDX);
|
|
257
|
-
});
|
|
258
|
-
},
|
|
259
|
-
setContainerWidth: (w) => {
|
|
260
|
-
setContainerWidth(w);
|
|
261
|
-
},
|
|
262
|
-
resizeColumn: (colId, delta) => {
|
|
263
|
-
const col = columns().find((c) => c.id === colId);
|
|
264
|
-
if (col) {
|
|
265
|
-
if (col.isFlex()) {
|
|
266
|
-
const fixedSpace = columns().filter((c) => !c.isFlex()).reduce((a, b) => a + b.width(), 0);
|
|
267
|
-
const flexCount = columns().filter((c) => c.isFlex()).length;
|
|
268
|
-
const currentFlexWidth = Math.max(
|
|
269
|
-
col.original.minWidth ?? 150,
|
|
270
|
-
(containerWidth() - fixedSpace) / flexCount
|
|
271
|
-
);
|
|
272
|
-
col.setColWidth(currentFlexWidth);
|
|
273
|
-
col.setFlex(false);
|
|
274
|
-
}
|
|
275
|
-
col.setColWidth(
|
|
276
|
-
Math.max(col.original.minWidth ?? 50, col.width() + delta)
|
|
277
|
-
);
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
};
|
|
10
|
+
const [containerWidth, setContainerWidth] = createSignal(0);
|
|
11
|
+
const [rows, setRows] = createSignal(options.data);
|
|
12
|
+
const [rowSize] = createSignal(determineRowHeight(options.rowSize));
|
|
13
|
+
const [globalFilter, setGlobalFilter] = createSignal("");
|
|
14
|
+
const [sorting, setSorting] = createSignal([]);
|
|
15
|
+
const [pageIndex, setPageIndex] = createSignal(determinePageIndex(options.initialState?.pagination));
|
|
16
|
+
const [pageSize, setPageSize] = createSignal(determinePageSize(options.initialState?.pagination));
|
|
17
|
+
const [pageRange] = createSignal(determinePageRange(options.initialState?.pagination));
|
|
18
|
+
const [isServerPaginated] = createSignal(Boolean(determineInitialCount(options.initialState?.pagination)));
|
|
19
|
+
const [columns] = createSignal(options.columns.map((col) => {
|
|
20
|
+
const pinnable = Boolean(col.features?.pinning);
|
|
21
|
+
const filterable = Boolean(col.features?.filter);
|
|
22
|
+
const sortable = Boolean(col.features?.sort);
|
|
23
|
+
const hasFeatures = pinnable || filterable || sortable;
|
|
24
|
+
const minWForFeatures = 100;
|
|
25
|
+
let finalWidth = col.width ?? 150;
|
|
26
|
+
if (hasFeatures && col.width && col.width < minWForFeatures) finalWidth = minWForFeatures;
|
|
27
|
+
const [isVisible] = createSignal(true);
|
|
28
|
+
const [isFlex, setFlex] = createSignal(col.width === void 0);
|
|
29
|
+
const [pinned, setPinned] = createSignal(col.features?.pinning?.defaultPosition ?? false);
|
|
30
|
+
const [width, setColWidth] = createSignal(finalWidth);
|
|
31
|
+
return {
|
|
32
|
+
id: col.id,
|
|
33
|
+
isFlex,
|
|
34
|
+
isVisible,
|
|
35
|
+
original: col,
|
|
36
|
+
pinned,
|
|
37
|
+
width,
|
|
38
|
+
getValue: col.accessor,
|
|
39
|
+
pinnable,
|
|
40
|
+
filterable,
|
|
41
|
+
sortable,
|
|
42
|
+
setFlex,
|
|
43
|
+
setPinned,
|
|
44
|
+
setColWidth
|
|
45
|
+
};
|
|
46
|
+
}));
|
|
47
|
+
const currentPageRange = createComputed(() => {
|
|
48
|
+
const dataIdx = pageIndex() - 1;
|
|
49
|
+
return {
|
|
50
|
+
start: dataIdx === 0 ? 0 : dataIdx * pageSize() - 1,
|
|
51
|
+
end: pageIndex() * pageSize()
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
const processedRows = createComputed(() => {
|
|
55
|
+
let result = [...rows()];
|
|
56
|
+
const filter = globalFilter().toLowerCase();
|
|
57
|
+
const sortState = sorting();
|
|
58
|
+
if (filter) result = result.filter((row) => {
|
|
59
|
+
return columns().some((col) => {
|
|
60
|
+
if (!col.filterable) return false;
|
|
61
|
+
return String(col.getValue(row)).toLowerCase().includes(filter);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
if (sortState.length > 0) result.sort((a, b) => {
|
|
65
|
+
for (const sort of sortState) {
|
|
66
|
+
const col = columns().find((c) => c.id === sort.id);
|
|
67
|
+
if (!col) continue;
|
|
68
|
+
const valA = col.getValue(a);
|
|
69
|
+
const valB = col.getValue(b);
|
|
70
|
+
if (valA === valB) continue;
|
|
71
|
+
let comparison = 0;
|
|
72
|
+
const customComparator = typeof col.original.features?.sort === "object" ? col.original.features.sort.comparator : void 0;
|
|
73
|
+
if (customComparator) comparison = customComparator(valA, valB);
|
|
74
|
+
else comparison = valA > valB ? 1 : -1;
|
|
75
|
+
return sort.desc ? -comparison : comparison;
|
|
76
|
+
}
|
|
77
|
+
return 0;
|
|
78
|
+
});
|
|
79
|
+
return result;
|
|
80
|
+
});
|
|
81
|
+
const rowCount = createComputed(() => determineInitialCount(options?.initialState?.pagination) ?? processedRows().length);
|
|
82
|
+
const pageCount = createComputed(() => Math.ceil(rowCount() / pageSize()));
|
|
83
|
+
const orderedColumns = createComputed(() => {
|
|
84
|
+
const left = [];
|
|
85
|
+
const center = [];
|
|
86
|
+
const right = [];
|
|
87
|
+
columns().forEach((col) => {
|
|
88
|
+
const pin = col.pinned();
|
|
89
|
+
if (pin === "left") left.push(col);
|
|
90
|
+
else if (pin === "right") right.push(col);
|
|
91
|
+
else center.push(col);
|
|
92
|
+
});
|
|
93
|
+
return [
|
|
94
|
+
...left,
|
|
95
|
+
...center,
|
|
96
|
+
...right
|
|
97
|
+
];
|
|
98
|
+
});
|
|
99
|
+
const visibleRows = createComputed(() => {
|
|
100
|
+
if (pageSize() && pageCount() > 1) {
|
|
101
|
+
const currentRange = currentPageRange();
|
|
102
|
+
return processedRows().slice(currentRange.start, currentRange.end);
|
|
103
|
+
}
|
|
104
|
+
return processedRows();
|
|
105
|
+
});
|
|
106
|
+
return {
|
|
107
|
+
columns,
|
|
108
|
+
rows,
|
|
109
|
+
globalFilter,
|
|
110
|
+
sorting,
|
|
111
|
+
pageCount,
|
|
112
|
+
pageIndex,
|
|
113
|
+
pageSize,
|
|
114
|
+
pageRange,
|
|
115
|
+
currentPageRange,
|
|
116
|
+
isServerPaginated,
|
|
117
|
+
rootCssVars: createComputed(() => {
|
|
118
|
+
const vars = {};
|
|
119
|
+
const visibleCols = [];
|
|
120
|
+
const cols = columns();
|
|
121
|
+
const cWidth = containerWidth();
|
|
122
|
+
let fixedSpace = 0;
|
|
123
|
+
let flexCount = 0;
|
|
124
|
+
for (let i = 0; i < cols.length; i++) {
|
|
125
|
+
const col = cols[i];
|
|
126
|
+
if (!col.isVisible()) continue;
|
|
127
|
+
visibleCols.push(col);
|
|
128
|
+
if (col.isFlex()) flexCount++;
|
|
129
|
+
else fixedSpace += col.width();
|
|
130
|
+
const order = orderedColumns().findIndex((orderedCol) => orderedCol.id === col.id);
|
|
131
|
+
vars[`--col-${col.id}-order`] = `${order}`;
|
|
132
|
+
}
|
|
133
|
+
const remainingSpace = Math.max(0, cWidth - fixedSpace);
|
|
134
|
+
const flexWidth = flexCount > 0 ? remainingSpace / flexCount : 0;
|
|
135
|
+
let leftOffset = 0;
|
|
136
|
+
let totalW = 0;
|
|
137
|
+
const computedWidths = new Float64Array(visibleCols.length);
|
|
138
|
+
for (let i = 0; i < visibleCols.length; i++) {
|
|
139
|
+
const col = visibleCols[i];
|
|
140
|
+
let finalWidth = col.width();
|
|
141
|
+
if (col.isFlex()) finalWidth = Math.max(col.original.minWidth ?? 150, flexWidth);
|
|
142
|
+
computedWidths[i] = finalWidth;
|
|
143
|
+
totalW += finalWidth;
|
|
144
|
+
vars[`--col-${col.id}-width`] = `${finalWidth}px`;
|
|
145
|
+
if (col.pinned() === "left") {
|
|
146
|
+
vars[`--col-${col.id}-left`] = `${leftOffset}px`;
|
|
147
|
+
leftOffset += finalWidth;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
let rightOffset = 0;
|
|
151
|
+
for (let i = visibleCols.length - 1; i >= 0; i--) {
|
|
152
|
+
const col = visibleCols[i];
|
|
153
|
+
if (col.pinned() === "right") {
|
|
154
|
+
vars[`--col-${col.id}-right`] = `${rightOffset}px`;
|
|
155
|
+
rightOffset += computedWidths[i];
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
vars["--total-grid-width"] = `${totalW}px`;
|
|
159
|
+
vars["--row-height"] = `${rowSize()}px`;
|
|
160
|
+
return vars;
|
|
161
|
+
}),
|
|
162
|
+
rowCount,
|
|
163
|
+
rowSize,
|
|
164
|
+
totalWidth: createComputed(() => columns().reduce((acc, c) => acc + c.width(), 0)),
|
|
165
|
+
visibleRows,
|
|
166
|
+
updateData: (newData) => {
|
|
167
|
+
setRows(newData);
|
|
168
|
+
},
|
|
169
|
+
setSort: (colId, direction, multi = false) => {
|
|
170
|
+
if (direction === null) {
|
|
171
|
+
setSorting(sorting().filter((s) => s.id !== colId));
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const current = sorting();
|
|
175
|
+
const newSort = {
|
|
176
|
+
id: colId,
|
|
177
|
+
desc: direction === "desc"
|
|
178
|
+
};
|
|
179
|
+
if (multi) {
|
|
180
|
+
const existingIndex = current.findIndex((s) => s.id === colId);
|
|
181
|
+
if (existingIndex >= 0) {
|
|
182
|
+
const next = [...current];
|
|
183
|
+
next[existingIndex] = newSort;
|
|
184
|
+
setSorting(next);
|
|
185
|
+
} else setSorting([...current, newSort]);
|
|
186
|
+
} else setSorting([newSort]);
|
|
187
|
+
},
|
|
188
|
+
togglePinned: (colId, state) => {
|
|
189
|
+
const col = columns().find((c) => c.id === colId);
|
|
190
|
+
if (col) col.setPinned(state ?? false);
|
|
191
|
+
},
|
|
192
|
+
toggleSort: (colId, multi) => {
|
|
193
|
+
const current = sorting();
|
|
194
|
+
const exists = current.findIndex((s) => s.id === colId) !== -1;
|
|
195
|
+
const updatedSort = current.map((s) => {
|
|
196
|
+
if (s.id === colId) return {
|
|
197
|
+
...s,
|
|
198
|
+
desc: !s.desc
|
|
199
|
+
};
|
|
200
|
+
return s;
|
|
201
|
+
});
|
|
202
|
+
if (exists) setSorting(multi ? [...current, ...updatedSort] : [...updatedSort]);
|
|
203
|
+
else {
|
|
204
|
+
const newSort = {
|
|
205
|
+
id: colId,
|
|
206
|
+
desc: true
|
|
207
|
+
};
|
|
208
|
+
setSorting(multi ? [...current, newSort] : [newSort]);
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
setPage: (details) => {
|
|
212
|
+
setPageIndex(details.page);
|
|
213
|
+
options.onPageChange?.(details);
|
|
214
|
+
},
|
|
215
|
+
setPageSize: (size) => {
|
|
216
|
+
if (isServerPaginated()) setPageIndex(1);
|
|
217
|
+
setPageSize(size);
|
|
218
|
+
},
|
|
219
|
+
setGlobalFilter: (val) => {
|
|
220
|
+
batch(() => {
|
|
221
|
+
setGlobalFilter(val);
|
|
222
|
+
setPageIndex(1);
|
|
223
|
+
});
|
|
224
|
+
},
|
|
225
|
+
setContainerWidth: (w) => {
|
|
226
|
+
setContainerWidth(w);
|
|
227
|
+
},
|
|
228
|
+
resizeColumn: (colId, delta) => {
|
|
229
|
+
const col = columns().find((c) => c.id === colId);
|
|
230
|
+
if (col) {
|
|
231
|
+
if (col.isFlex()) {
|
|
232
|
+
const fixedSpace = columns().filter((c) => !c.isFlex()).reduce((a, b) => a + b.width(), 0);
|
|
233
|
+
const flexCount = columns().filter((c) => c.isFlex()).length;
|
|
234
|
+
const currentFlexWidth = Math.max(col.original.minWidth ?? 150, (containerWidth() - fixedSpace) / flexCount);
|
|
235
|
+
col.setColWidth(currentFlexWidth);
|
|
236
|
+
col.setFlex(false);
|
|
237
|
+
}
|
|
238
|
+
col.setColWidth(Math.max(col.original.minWidth ?? 50, col.width() + delta));
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
281
242
|
}
|
|
282
|
-
|
|
243
|
+
//#endregion
|
|
283
244
|
export { createGridStore };
|
package/dist/utils.cjs
CHANGED
|
@@ -1,57 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (typeof rowSize === "number") {
|
|
11
|
-
return rowSize;
|
|
12
|
-
}
|
|
13
|
-
if (prebuiltSizes.includes(rowSize)) {
|
|
14
|
-
const size = _const.ROW_SIZES.results[rowSize];
|
|
15
|
-
return size;
|
|
16
|
-
}
|
|
17
|
-
console.error(
|
|
18
|
-
"Unknown row size provided to Data Grid. The rowSize prop requires a number to determine pixel-based value.",
|
|
19
|
-
rowSize
|
|
20
|
-
);
|
|
21
|
-
return 0;
|
|
1
|
+
"use client";
|
|
2
|
+
const require_const = require("./const.cjs");
|
|
3
|
+
//#region src/utils.ts
|
|
4
|
+
function determineRowHeight(rowSize = "sm") {
|
|
5
|
+
const prebuiltSizes = require_const.ROW_SIZES.items;
|
|
6
|
+
if (typeof rowSize === "number") return rowSize;
|
|
7
|
+
if (prebuiltSizes.includes(rowSize)) return require_const.ROW_SIZES.results[rowSize];
|
|
8
|
+
console.error("Unknown row size provided to Data Grid. The rowSize prop requires a number to determine pixel-based value.", rowSize);
|
|
9
|
+
return 0;
|
|
22
10
|
}
|
|
23
11
|
function determinePageSize(options) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (options.customRange?.length) {
|
|
29
|
-
return options.customRange[0];
|
|
30
|
-
}
|
|
31
|
-
return options.pageSize ?? _const.SM_PAGE_SIZE;
|
|
12
|
+
if (!options) return 0;
|
|
13
|
+
if (typeof options === "boolean" && options === true) return 25;
|
|
14
|
+
if (options.customRange?.length) return options.customRange[0];
|
|
15
|
+
return options.pageSize ?? 25;
|
|
32
16
|
}
|
|
33
17
|
function determinePageIndex(options) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
return options.defaultPage ?? _const.DEFAULT_PAGE_IDX;
|
|
18
|
+
if (!options) return 1;
|
|
19
|
+
if (typeof options === "boolean" && options === true) return 1;
|
|
20
|
+
return options.defaultPage ?? 1;
|
|
39
21
|
}
|
|
40
22
|
function determinePageRange(options) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return options.customRange ?? _const.DEFAULT_PAGE_SIZES;
|
|
23
|
+
if (!options) return require_const.DEFAULT_PAGE_SIZES;
|
|
24
|
+
if (typeof options === "boolean" && options === true) return require_const.DEFAULT_PAGE_SIZES;
|
|
25
|
+
return options.customRange ?? require_const.DEFAULT_PAGE_SIZES;
|
|
46
26
|
}
|
|
47
27
|
function determineInitialCount(options) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
return options?.count ?? void 0;
|
|
28
|
+
if (!options) return void 0;
|
|
29
|
+
if (typeof options === "boolean" && options === true) return;
|
|
30
|
+
return options?.count ?? void 0;
|
|
53
31
|
}
|
|
54
|
-
|
|
32
|
+
//#endregion
|
|
55
33
|
exports.determineInitialCount = determineInitialCount;
|
|
56
34
|
exports.determinePageIndex = determinePageIndex;
|
|
57
35
|
exports.determinePageRange = determinePageRange;
|