@ornery/ui-grid-react 0.1.5 → 0.1.7
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/demo/main.tsx +1 -1
- package/demo/vite.config.ts +1 -1
- package/dist/UiGrid.d.ts +11 -0
- package/dist/UiGrid.d.ts.map +1 -0
- package/dist/gridStateMath.d.ts +8 -0
- package/dist/gridStateMath.d.ts.map +1 -0
- package/dist/index.d.ts +14 -155
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +699 -1063
- package/dist/index.mjs +594 -930
- package/dist/mountUiGrid.d.ts +4 -0
- package/dist/mountUiGrid.d.ts.map +1 -0
- package/dist/rustWasmGridEngine.d.ts +8 -0
- package/dist/rustWasmGridEngine.d.ts.map +1 -0
- package/dist/{index.d.mts → useGridState.d.ts} +6 -50
- package/dist/useGridState.d.ts.map +1 -0
- package/dist/useVirtualScroll.d.ts +20 -0
- package/dist/useVirtualScroll.d.ts.map +1 -0
- package/dist/vanillaAdapter.d.ts +14 -0
- package/dist/vanillaAdapter.d.ts.map +1 -0
- package/dist/virtualScrollMath.d.ts +17 -0
- package/dist/virtualScrollMath.d.ts.map +1 -0
- package/package.json +11 -11
- package/src/UiGrid.test.tsx +63 -25
- package/src/UiGrid.tsx +438 -187
- package/src/gridStateMath.test.ts +10 -8
- package/src/gridStateMath.ts +20 -7
- package/src/index.ts +21 -5
- package/src/mountUiGrid.tsx +10 -0
- package/src/rustWasmGridEngine.test.ts +4 -4
- package/src/rustWasmGridEngine.ts +7 -5
- package/src/ui-grid.css +200 -1
- package/src/useGridState.ts +56 -30
- package/src/useVirtualScroll.ts +2 -0
- package/src/vanillaAdapter.test.ts +33 -0
- package/src/vanillaAdapter.ts +36 -0
- package/tsconfig.build.json +6 -0
- package/tsconfig.dts.json +15 -0
- package/tsconfig.json +1 -1
- package/vitest.config.ts +1 -1
- package/CLAUDE.md +0 -283
package/dist/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,18 +17,28 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
|
|
20
30
|
// src/index.ts
|
|
21
31
|
var index_exports = {};
|
|
22
32
|
__export(index_exports, {
|
|
23
|
-
DEFAULT_GRID_LABELS: () =>
|
|
33
|
+
DEFAULT_GRID_LABELS: () => import_ui_grid_core4.DEFAULT_GRID_LABELS,
|
|
24
34
|
UiGrid: () => UiGrid,
|
|
25
35
|
buildGridTemplateColumns: () => buildGridTemplateColumns,
|
|
26
36
|
computeViewportHeightPx: () => computeViewportHeightPx,
|
|
27
37
|
computeViewportRows: () => computeViewportRows,
|
|
28
38
|
enableReactUiGridWasmEngine: () => enableReactUiGridWasmEngine,
|
|
29
39
|
formatPaginationSummary: () => formatPaginationSummary,
|
|
40
|
+
mountUiGrid: () => mountUiGrid,
|
|
41
|
+
mountUiGridCustomElement: () => mountUiGridCustomElement,
|
|
30
42
|
orderVisibleColumns: () => orderVisibleColumns,
|
|
31
43
|
registerReactUiGridWasmEngineFromModule: () => registerReactUiGridWasmEngineFromModule,
|
|
32
44
|
resolveBenchmarkIterations: () => resolveBenchmarkIterations,
|
|
@@ -35,16 +47,19 @@ __export(index_exports, {
|
|
|
35
47
|
});
|
|
36
48
|
module.exports = __toCommonJS(index_exports);
|
|
37
49
|
|
|
50
|
+
// src/UiGrid.tsx
|
|
51
|
+
var import_react3 = __toESM(require("react"));
|
|
52
|
+
|
|
38
53
|
// src/useGridState.ts
|
|
39
54
|
var import_react = require("react");
|
|
40
55
|
|
|
41
56
|
// src/gridStateMath.ts
|
|
42
|
-
var
|
|
57
|
+
var import_ui_grid_core = require("@ornery/ui-grid-core");
|
|
43
58
|
function orderVisibleColumns(columns, order) {
|
|
44
59
|
return [...columns].filter((column) => column.visible !== false).sort((left, right) => order.indexOf(left.name) - order.indexOf(right.name));
|
|
45
60
|
}
|
|
46
61
|
function buildGridTemplateColumns(columns) {
|
|
47
|
-
return columns.map((column) => (0,
|
|
62
|
+
return columns.map((column) => (0, import_ui_grid_core.gridColumnWidth)(column)).join(" ");
|
|
48
63
|
}
|
|
49
64
|
function resolveBenchmarkIterations(iterations, configuredIterations) {
|
|
50
65
|
return Math.max(1, iterations ?? configuredIterations ?? 25);
|
|
@@ -63,678 +78,7 @@ function computeViewportRows(viewportHeight, rowHeight) {
|
|
|
63
78
|
}
|
|
64
79
|
|
|
65
80
|
// src/useGridState.ts
|
|
66
|
-
var
|
|
67
|
-
|
|
68
|
-
// ../ui-grid/src/lib/grid/grid.core.pagination.ts
|
|
69
|
-
function seekGridPage(page, totalPages) {
|
|
70
|
-
return Math.min(Math.max(page, 1), Math.max(totalPages, 1));
|
|
71
|
-
}
|
|
72
|
-
function resolveGridPageSize(pageSize) {
|
|
73
|
-
return Number.isFinite(pageSize) && pageSize > 0 ? pageSize : null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
// ../ui-grid/src/lib/grid/grid.constants.ts
|
|
77
|
-
var SORT_DIRECTIONS = {
|
|
78
|
-
asc: "asc",
|
|
79
|
-
desc: "desc",
|
|
80
|
-
none: "none"
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// ../ui-grid/src/lib/grid/grid.utils.ts
|
|
84
|
-
var PROTECTED_PATH_SEGMENTS = /* @__PURE__ */ new Set(["__proto__", "constructor", "prototype"]);
|
|
85
|
-
function getPathValue(record, path) {
|
|
86
|
-
return path.split(".").reduce((current, part) => {
|
|
87
|
-
if (current === null || current === void 0 || typeof current !== "object") {
|
|
88
|
-
return void 0;
|
|
89
|
-
}
|
|
90
|
-
if (PROTECTED_PATH_SEGMENTS.has(part)) {
|
|
91
|
-
return void 0;
|
|
92
|
-
}
|
|
93
|
-
if (!Object.prototype.hasOwnProperty.call(current, part)) {
|
|
94
|
-
return void 0;
|
|
95
|
-
}
|
|
96
|
-
return current[part];
|
|
97
|
-
}, record);
|
|
98
|
-
}
|
|
99
|
-
function getCellValue(row, column) {
|
|
100
|
-
if (column.valueGetter) {
|
|
101
|
-
return column.valueGetter(row);
|
|
102
|
-
}
|
|
103
|
-
if (column.field) {
|
|
104
|
-
return getPathValue(row, column.field);
|
|
105
|
-
}
|
|
106
|
-
return row[column.name];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// ../ui-grid/src/lib/grid/grid.core.identity.ts
|
|
110
|
-
function buildGridSortState(columnName, direction) {
|
|
111
|
-
return {
|
|
112
|
-
columnName,
|
|
113
|
-
direction: direction ?? SORT_DIRECTIONS.asc
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// ../ui-grid/src/lib/grid/grid.core.edit.ts
|
|
118
|
-
function beginGridEditSession(rowId, columnName, editingValue) {
|
|
119
|
-
const position = { rowId, columnName };
|
|
120
|
-
return {
|
|
121
|
-
focusedCell: position,
|
|
122
|
-
editingCell: position,
|
|
123
|
-
editingValue
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function clearGridEditSession() {
|
|
127
|
-
return {
|
|
128
|
-
editingCell: null,
|
|
129
|
-
editingValue: ""
|
|
130
|
-
};
|
|
131
|
-
}
|
|
132
|
-
function stringifyGridEditorValue(value) {
|
|
133
|
-
if (value instanceof Date) {
|
|
134
|
-
return value.toISOString().slice(0, 10);
|
|
135
|
-
}
|
|
136
|
-
return value === null || value === void 0 ? "" : String(value);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
// ../ui-grid/src/lib/grid/grid.core.infinite-scroll.ts
|
|
140
|
-
function maybeRequestInfiniteScrollData(context) {
|
|
141
|
-
if (context.state.dataLoading) {
|
|
142
|
-
return { request: null, nextState: context.state };
|
|
143
|
-
}
|
|
144
|
-
if (context.state.scrollUp && context.startIndex <= context.threshold) {
|
|
145
|
-
return {
|
|
146
|
-
request: "top",
|
|
147
|
-
nextState: {
|
|
148
|
-
...context.state,
|
|
149
|
-
dataLoading: true,
|
|
150
|
-
previousVisibleRows: context.visibleRows
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
if (context.state.scrollDown && context.startIndex + context.viewportRows >= Math.max(context.visibleRows - context.threshold, 0)) {
|
|
155
|
-
return {
|
|
156
|
-
request: "bottom",
|
|
157
|
-
nextState: {
|
|
158
|
-
...context.state,
|
|
159
|
-
dataLoading: true,
|
|
160
|
-
previousVisibleRows: context.visibleRows
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
}
|
|
164
|
-
return { request: null, nextState: context.state };
|
|
165
|
-
}
|
|
166
|
-
function completeInfiniteScrollDataLoad(state, scrollUp, scrollDown) {
|
|
167
|
-
return {
|
|
168
|
-
...state,
|
|
169
|
-
scrollUp,
|
|
170
|
-
scrollDown,
|
|
171
|
-
dataLoading: false
|
|
172
|
-
};
|
|
173
|
-
}
|
|
174
|
-
function resetInfiniteScrollState(scrollUp, scrollDown) {
|
|
175
|
-
return {
|
|
176
|
-
scrollUp,
|
|
177
|
-
scrollDown,
|
|
178
|
-
dataLoading: false,
|
|
179
|
-
previousVisibleRows: 0
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
function saveInfiniteScrollPercentage(state, visibleRows) {
|
|
183
|
-
return {
|
|
184
|
-
...state,
|
|
185
|
-
previousVisibleRows: visibleRows
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function setInfiniteScrollDirectionsState(state, scrollUp, scrollDown) {
|
|
189
|
-
return {
|
|
190
|
-
...state,
|
|
191
|
-
scrollUp,
|
|
192
|
-
scrollDown
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// ../ui-grid/src/lib/grid/grid.core.row-state.ts
|
|
197
|
-
function toggleGridRowExpanded(expandedRows, rowId) {
|
|
198
|
-
const expanded = !expandedRows[rowId];
|
|
199
|
-
return {
|
|
200
|
-
expanded,
|
|
201
|
-
nextExpandedRows: {
|
|
202
|
-
...expandedRows,
|
|
203
|
-
[rowId]: expanded
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
function expandAllGridRows(rows) {
|
|
208
|
-
const nextExpandedRows = {};
|
|
209
|
-
for (const row of rows) {
|
|
210
|
-
nextExpandedRows[row.id] = true;
|
|
211
|
-
}
|
|
212
|
-
return nextExpandedRows;
|
|
213
|
-
}
|
|
214
|
-
function setGridTreeRowExpanded(expandedTreeRows, rowId, expanded) {
|
|
215
|
-
return {
|
|
216
|
-
...expandedTreeRows,
|
|
217
|
-
[rowId]: expanded
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function toggleGridTreeRowExpanded(expandedTreeRows, rowId) {
|
|
221
|
-
const expanded = !expandedTreeRows[rowId];
|
|
222
|
-
return {
|
|
223
|
-
expanded,
|
|
224
|
-
nextExpandedTreeRows: setGridTreeRowExpanded(expandedTreeRows, rowId, expanded)
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
function expandAllGridTreeRows(rows) {
|
|
228
|
-
const nextExpandedTreeRows = {};
|
|
229
|
-
for (const row of rows) {
|
|
230
|
-
if (row.hasChildren) {
|
|
231
|
-
nextExpandedTreeRows[row.id] = true;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
return nextExpandedTreeRows;
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// ../ui-grid/src/lib/grid/grid.core.state.ts
|
|
238
|
-
function normalizeGridSavedState(state) {
|
|
239
|
-
const normalized = {};
|
|
240
|
-
if (Array.isArray(state.columnOrder)) {
|
|
241
|
-
normalized.columnOrder = state.columnOrder.filter(
|
|
242
|
-
(columnName) => typeof columnName === "string" && isSafeStateKey(columnName)
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
if (state.filters && typeof state.filters === "object") {
|
|
246
|
-
normalized.filters = Object.entries(state.filters).reduce(
|
|
247
|
-
(accumulator, [key, value]) => {
|
|
248
|
-
if (typeof key === "string" && isSafeStateKey(key) && typeof value === "string") {
|
|
249
|
-
accumulator[key] = value;
|
|
250
|
-
}
|
|
251
|
-
return accumulator;
|
|
252
|
-
},
|
|
253
|
-
{}
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
if (state.sort && typeof state.sort === "object") {
|
|
257
|
-
normalized.sort = {
|
|
258
|
-
columnName: typeof state.sort.columnName === "string" && isSafeStateKey(state.sort.columnName) ? state.sort.columnName : null,
|
|
259
|
-
direction: state.sort.direction === SORT_DIRECTIONS.asc || state.sort.direction === SORT_DIRECTIONS.desc ? state.sort.direction : SORT_DIRECTIONS.none
|
|
260
|
-
};
|
|
261
|
-
}
|
|
262
|
-
if (Array.isArray(state.grouping)) {
|
|
263
|
-
normalized.grouping = state.grouping.filter(
|
|
264
|
-
(columnName) => typeof columnName === "string" && isSafeStateKey(columnName)
|
|
265
|
-
);
|
|
266
|
-
}
|
|
267
|
-
if (state.pagination && typeof state.pagination === "object") {
|
|
268
|
-
const paginationCurrentPage = Number(state.pagination.paginationCurrentPage);
|
|
269
|
-
const paginationPageSize = Number(state.pagination.paginationPageSize);
|
|
270
|
-
normalized.pagination = {
|
|
271
|
-
paginationCurrentPage: Number.isFinite(paginationCurrentPage) && paginationCurrentPage > 0 ? Math.floor(paginationCurrentPage) : 1,
|
|
272
|
-
paginationPageSize: Number.isFinite(paginationPageSize) && paginationPageSize >= 0 ? Math.floor(paginationPageSize) : 0
|
|
273
|
-
};
|
|
274
|
-
}
|
|
275
|
-
if (state.expandable && typeof state.expandable === "object") {
|
|
276
|
-
normalized.expandable = normalizeBooleanMap(state.expandable);
|
|
277
|
-
}
|
|
278
|
-
if (state.treeView && typeof state.treeView === "object") {
|
|
279
|
-
normalized.treeView = normalizeBooleanMap(state.treeView);
|
|
280
|
-
}
|
|
281
|
-
if (state.pinning && typeof state.pinning === "object") {
|
|
282
|
-
normalized.pinning = Object.entries(state.pinning).reduce(
|
|
283
|
-
(acc, [key, value]) => {
|
|
284
|
-
if (typeof key === "string" && isSafeStateKey(key) && (value === "left" || value === "right")) {
|
|
285
|
-
acc[key] = value;
|
|
286
|
-
}
|
|
287
|
-
return acc;
|
|
288
|
-
},
|
|
289
|
-
{}
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
return normalized;
|
|
293
|
-
}
|
|
294
|
-
function normalizeBooleanMap(value) {
|
|
295
|
-
return Object.entries(value).reduce((accumulator, [key, entry]) => {
|
|
296
|
-
if (typeof key === "string" && isSafeStateKey(key) && typeof entry === "boolean") {
|
|
297
|
-
accumulator[key] = entry;
|
|
298
|
-
}
|
|
299
|
-
return accumulator;
|
|
300
|
-
}, {});
|
|
301
|
-
}
|
|
302
|
-
function isSafeStateKey(value) {
|
|
303
|
-
return value !== "__proto__" && value !== "constructor" && value !== "prototype";
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// ../ui-grid/src/lib/grid/grid.core.pinning.ts
|
|
307
|
-
function isPinningEnabled(options) {
|
|
308
|
-
return options.enablePinning === true;
|
|
309
|
-
}
|
|
310
|
-
function isColumnPinnable(options, column) {
|
|
311
|
-
return isPinningEnabled(options) && column.enablePinning !== false;
|
|
312
|
-
}
|
|
313
|
-
function pinColumnState(current, columnName, direction) {
|
|
314
|
-
const next = { ...current };
|
|
315
|
-
if (direction === "none") {
|
|
316
|
-
delete next[columnName];
|
|
317
|
-
} else {
|
|
318
|
-
next[columnName] = direction;
|
|
319
|
-
}
|
|
320
|
-
return next;
|
|
321
|
-
}
|
|
322
|
-
function buildInitialPinnedState(columns) {
|
|
323
|
-
const state = {};
|
|
324
|
-
for (const col of columns) {
|
|
325
|
-
if (col.pinnedLeft) state[col.name] = "left";
|
|
326
|
-
else if (col.pinnedRight) state[col.name] = "right";
|
|
327
|
-
}
|
|
328
|
-
return state;
|
|
329
|
-
}
|
|
330
|
-
function computePinnedOffset(visibleColumns, pinnedColumns, column) {
|
|
331
|
-
const direction = pinnedColumns[column.name];
|
|
332
|
-
if (!direction) return null;
|
|
333
|
-
function resolveColumnWidthForOffset(column2) {
|
|
334
|
-
const w = column2.width;
|
|
335
|
-
if (!w) return "11rem";
|
|
336
|
-
if (w.includes("fr") || w.includes("minmax")) return "11rem";
|
|
337
|
-
return w;
|
|
338
|
-
}
|
|
339
|
-
if (direction === "left") {
|
|
340
|
-
const offsetParts = [];
|
|
341
|
-
for (const col of visibleColumns) {
|
|
342
|
-
if (col.name === column.name) break;
|
|
343
|
-
if (pinnedColumns[col.name] === "left") {
|
|
344
|
-
offsetParts.push(resolveColumnWidthForOffset(col));
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
return {
|
|
348
|
-
side: "left",
|
|
349
|
-
offset: offsetParts.length > 0 ? `calc(${offsetParts.join(" + ")})` : "0px"
|
|
350
|
-
};
|
|
351
|
-
}
|
|
352
|
-
if (direction === "right") {
|
|
353
|
-
const offsetParts = [];
|
|
354
|
-
const reversed = [...visibleColumns].reverse();
|
|
355
|
-
for (const col of reversed) {
|
|
356
|
-
if (col.name === column.name) break;
|
|
357
|
-
if (pinnedColumns[col.name] === "right") {
|
|
358
|
-
offsetParts.push(resolveColumnWidthForOffset(col));
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
return {
|
|
362
|
-
side: "right",
|
|
363
|
-
offset: offsetParts.length > 0 ? `calc(${offsetParts.join(" + ")})` : "0px"
|
|
364
|
-
};
|
|
365
|
-
}
|
|
366
|
-
return null;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// ../ui-grid/src/lib/grid/ui-grid.events.ts
|
|
370
|
-
function raiseGridRenderingComplete(gridApi) {
|
|
371
|
-
gridApi.core.raise.renderingComplete(gridApi);
|
|
372
|
-
}
|
|
373
|
-
function raiseGridRowsRendered(gridApi, rows) {
|
|
374
|
-
gridApi.core.raise.rowsRendered(rows);
|
|
375
|
-
}
|
|
376
|
-
function raiseGridRowsVisibleChanged(gridApi, rows) {
|
|
377
|
-
gridApi.core.raise.rowsVisibleChanged(rows);
|
|
378
|
-
}
|
|
379
|
-
function raiseGridCanvasHeightChanged(gridApi, oldHeight, newHeight) {
|
|
380
|
-
gridApi.core.raise.canvasHeightChanged(oldHeight, newHeight);
|
|
381
|
-
}
|
|
382
|
-
function raiseGridDimensionChanged(gridApi, oldHeight, oldWidth, newHeight, newWidth) {
|
|
383
|
-
gridApi.core.raise.gridDimensionChanged(oldHeight, oldWidth, newHeight, newWidth);
|
|
384
|
-
}
|
|
385
|
-
function raiseGridScrollBegin(gridApi) {
|
|
386
|
-
gridApi.core.raise.scrollBegin();
|
|
387
|
-
}
|
|
388
|
-
function raiseGridScrollEnd(gridApi) {
|
|
389
|
-
gridApi.core.raise.scrollEnd();
|
|
390
|
-
}
|
|
391
|
-
function raiseGridSortChanged(gridApi, sortState) {
|
|
392
|
-
gridApi.core.raise.sortChanged(sortState.columnName, sortState.direction);
|
|
393
|
-
}
|
|
394
|
-
function raiseGridFilterChanged(gridApi, filters) {
|
|
395
|
-
gridApi.core.raise.filterChanged(filters);
|
|
396
|
-
}
|
|
397
|
-
function raiseGridGroupingChanged(gridApi, groupByColumns) {
|
|
398
|
-
gridApi.core.raise.groupingChanged(groupByColumns);
|
|
399
|
-
}
|
|
400
|
-
function raiseGridColumnOrderChanged(gridApi, order) {
|
|
401
|
-
gridApi.core.raise.columnOrderChanged(order);
|
|
402
|
-
}
|
|
403
|
-
function raiseGridBenchmarkComplete(gridApi, result) {
|
|
404
|
-
gridApi.core.raise.benchmarkComplete(result);
|
|
405
|
-
}
|
|
406
|
-
function raiseGridPaginationChanged(gridApi, currentPage, pageSize) {
|
|
407
|
-
gridApi.pagination.raise.paginationChanged(currentPage, pageSize);
|
|
408
|
-
}
|
|
409
|
-
function raiseGridExpandableRowStateChanged(gridApi, row, expanded) {
|
|
410
|
-
gridApi.expandable.raise.rowExpandedStateChanged(row, expanded);
|
|
411
|
-
}
|
|
412
|
-
function raiseGridTreeRowStateChanged(gridApi, row, expanded) {
|
|
413
|
-
if (expanded) {
|
|
414
|
-
gridApi.treeBase.raise.rowExpanded(row);
|
|
415
|
-
return;
|
|
416
|
-
}
|
|
417
|
-
gridApi.treeBase.raise.rowCollapsed(row);
|
|
418
|
-
}
|
|
419
|
-
function raiseGridNeedMoreData(gridApi, request) {
|
|
420
|
-
if (request === "top") {
|
|
421
|
-
gridApi.infiniteScroll.raise.needLoadMoreDataTop();
|
|
422
|
-
return;
|
|
423
|
-
}
|
|
424
|
-
gridApi.infiniteScroll.raise.needLoadMoreData();
|
|
425
|
-
}
|
|
426
|
-
function raiseGridBeginCellEdit(gridApi, rowEntity, column, triggerEvent) {
|
|
427
|
-
gridApi.edit.raise.beginCellEdit(rowEntity, column, triggerEvent);
|
|
428
|
-
}
|
|
429
|
-
function raiseGridAfterCellEdit(gridApi, rowEntity, column, newValue, oldValue) {
|
|
430
|
-
gridApi.edit.raise.afterCellEdit(rowEntity, column, newValue, oldValue);
|
|
431
|
-
}
|
|
432
|
-
function raiseGridCancelCellEdit(gridApi, rowEntity, column) {
|
|
433
|
-
gridApi.edit.raise.cancelCellEdit(rowEntity, column);
|
|
434
|
-
}
|
|
435
|
-
function raiseGridColumnPinned(gridApi, columnName, direction) {
|
|
436
|
-
gridApi.pinning.raise.columnPinned(columnName, direction);
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
// ../ui-grid/src/lib/grid/ui-grid.state.ts
|
|
440
|
-
function moveArrayItem(items, fromIndex, toIndex) {
|
|
441
|
-
const next = [...items];
|
|
442
|
-
const [item] = next.splice(fromIndex, 1);
|
|
443
|
-
if (item === void 0) {
|
|
444
|
-
return next;
|
|
445
|
-
}
|
|
446
|
-
next.splice(toIndex, 0, item);
|
|
447
|
-
return next;
|
|
448
|
-
}
|
|
449
|
-
function moveGridColumnOrderState(current, fromIndex, toIndex) {
|
|
450
|
-
return moveArrayItem(current, fromIndex, toIndex);
|
|
451
|
-
}
|
|
452
|
-
function createGridRestoreMutationPlan(state) {
|
|
453
|
-
const normalizedState = normalizeGridSavedState(state);
|
|
454
|
-
const plan = {};
|
|
455
|
-
if (normalizedState.columnOrder) {
|
|
456
|
-
plan.columnOrder = normalizedState.columnOrder;
|
|
457
|
-
}
|
|
458
|
-
if (normalizedState.filters) {
|
|
459
|
-
plan.filters = normalizedState.filters;
|
|
460
|
-
}
|
|
461
|
-
if (normalizedState.sort) {
|
|
462
|
-
plan.sort = normalizedState.sort;
|
|
463
|
-
}
|
|
464
|
-
if (normalizedState.grouping) {
|
|
465
|
-
plan.grouping = normalizedState.grouping;
|
|
466
|
-
}
|
|
467
|
-
if (normalizedState.pagination) {
|
|
468
|
-
plan.pagination = {
|
|
469
|
-
currentPage: normalizedState.pagination.paginationCurrentPage,
|
|
470
|
-
pageSize: normalizedState.pagination.paginationPageSize
|
|
471
|
-
};
|
|
472
|
-
}
|
|
473
|
-
if (normalizedState.expandable) {
|
|
474
|
-
plan.expandable = normalizedState.expandable;
|
|
475
|
-
}
|
|
476
|
-
if (normalizedState.treeView) {
|
|
477
|
-
plan.treeView = normalizedState.treeView;
|
|
478
|
-
}
|
|
479
|
-
if (normalizedState.pinning) {
|
|
480
|
-
plan.pinning = normalizedState.pinning;
|
|
481
|
-
}
|
|
482
|
-
return plan;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
// ../ui-grid/src/lib/grid/ui-grid.commands.ts
|
|
486
|
-
function applyGridSortStateCommand(gridApi, setSortState, sortState) {
|
|
487
|
-
setSortState(sortState);
|
|
488
|
-
raiseGridSortChanged(gridApi, sortState);
|
|
489
|
-
}
|
|
490
|
-
function sortGridColumnCommand(gridApi, setSortState, columnName, direction) {
|
|
491
|
-
applyGridSortStateCommand(gridApi, setSortState, buildGridSortState(columnName, direction));
|
|
492
|
-
}
|
|
493
|
-
function updateGridFilterCommand(gridApi, updateFilters, getFilters, columnName, value) {
|
|
494
|
-
updateFilters((current) => ({
|
|
495
|
-
...current,
|
|
496
|
-
[columnName]: value
|
|
497
|
-
}));
|
|
498
|
-
raiseGridFilterChanged(gridApi, getFilters());
|
|
499
|
-
}
|
|
500
|
-
function clearGridFiltersCommand(gridApi, setFilters) {
|
|
501
|
-
const nextFilters = {};
|
|
502
|
-
setFilters(nextFilters);
|
|
503
|
-
raiseGridFilterChanged(gridApi, nextFilters);
|
|
504
|
-
}
|
|
505
|
-
function clearGridGroupingCommand(gridApi, setGroupByColumns, shouldRaise = true) {
|
|
506
|
-
const nextGrouping = [];
|
|
507
|
-
setGroupByColumns(nextGrouping);
|
|
508
|
-
if (shouldRaise) {
|
|
509
|
-
raiseGridGroupingChanged(gridApi, nextGrouping);
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
function moveGridColumnCommand(gridApi, canMoveColumns, updateColumnOrder, fromIndex, toIndex) {
|
|
513
|
-
if (!canMoveColumns) {
|
|
514
|
-
return;
|
|
515
|
-
}
|
|
516
|
-
updateColumnOrder((current) => {
|
|
517
|
-
const next = moveGridColumnOrderState(current, fromIndex, toIndex);
|
|
518
|
-
raiseGridColumnOrderChanged(gridApi, next);
|
|
519
|
-
return next;
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
function pinGridColumnCommand(gridApi, isPinningEnabled2, setPinnedColumns, getCurrentPinnedColumns, columnName, direction) {
|
|
523
|
-
if (!isPinningEnabled2) return;
|
|
524
|
-
const next = pinColumnState(getCurrentPinnedColumns(), columnName, direction);
|
|
525
|
-
setPinnedColumns(next);
|
|
526
|
-
raiseGridColumnPinned(gridApi, columnName, direction);
|
|
527
|
-
}
|
|
528
|
-
function seekGridPaginationCommand(gridApi, setCurrentPage, getTotalPages, getEffectivePageSize, page) {
|
|
529
|
-
const nextPage = seekGridPage(page, getTotalPages());
|
|
530
|
-
setCurrentPage(nextPage);
|
|
531
|
-
raiseGridPaginationChanged(gridApi, nextPage, getEffectivePageSize());
|
|
532
|
-
}
|
|
533
|
-
function setGridPaginationPageSizeCommand(gridApi, setPageSize, setCurrentPage, pageSize) {
|
|
534
|
-
const nextPageSize = resolveGridPageSize(pageSize);
|
|
535
|
-
if (nextPageSize === null) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
setPageSize(nextPageSize);
|
|
539
|
-
setCurrentPage(1);
|
|
540
|
-
raiseGridPaginationChanged(gridApi, 1, nextPageSize);
|
|
541
|
-
}
|
|
542
|
-
function restoreGridStateCommand(gridApi, state, access) {
|
|
543
|
-
const restorePlan = createGridRestoreMutationPlan(state);
|
|
544
|
-
if (restorePlan.columnOrder) {
|
|
545
|
-
access.setColumnOrder(restorePlan.columnOrder);
|
|
546
|
-
}
|
|
547
|
-
if (restorePlan.filters) {
|
|
548
|
-
access.setActiveFilters(restorePlan.filters);
|
|
549
|
-
raiseGridFilterChanged(gridApi, restorePlan.filters);
|
|
550
|
-
}
|
|
551
|
-
if (restorePlan.sort) {
|
|
552
|
-
access.setSortState(restorePlan.sort);
|
|
553
|
-
}
|
|
554
|
-
if (restorePlan.grouping) {
|
|
555
|
-
access.setGroupByColumns(restorePlan.grouping);
|
|
556
|
-
raiseGridGroupingChanged(gridApi, restorePlan.grouping);
|
|
557
|
-
}
|
|
558
|
-
if (restorePlan.pagination) {
|
|
559
|
-
access.setCurrentPage(restorePlan.pagination.currentPage);
|
|
560
|
-
access.setPageSize(restorePlan.pagination.pageSize);
|
|
561
|
-
raiseGridPaginationChanged(
|
|
562
|
-
gridApi,
|
|
563
|
-
restorePlan.pagination.currentPage,
|
|
564
|
-
access.getEffectivePageSize()
|
|
565
|
-
);
|
|
566
|
-
}
|
|
567
|
-
if (restorePlan.expandable) {
|
|
568
|
-
access.setExpandedRows(restorePlan.expandable);
|
|
569
|
-
}
|
|
570
|
-
if (restorePlan.treeView) {
|
|
571
|
-
access.setExpandedTreeRows(restorePlan.treeView);
|
|
572
|
-
}
|
|
573
|
-
if (restorePlan.pinning && typeof access.setPinnedColumns === "function") {
|
|
574
|
-
access.setPinnedColumns(restorePlan.pinning);
|
|
575
|
-
for (const [col, dir] of Object.entries(restorePlan.pinning)) {
|
|
576
|
-
raiseGridColumnPinned(gridApi, col, dir);
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
function toggleGridRowExpansionCommand(gridApi, canExpandRows, currentExpandedRows, rowId, setExpandedRows, findRowById) {
|
|
581
|
-
if (!canExpandRows) {
|
|
582
|
-
return;
|
|
583
|
-
}
|
|
584
|
-
const { expanded, nextExpandedRows } = toggleGridRowExpanded(currentExpandedRows, rowId);
|
|
585
|
-
setExpandedRows(nextExpandedRows);
|
|
586
|
-
const gridRow = findRowById(rowId);
|
|
587
|
-
if (!gridRow) {
|
|
588
|
-
return;
|
|
589
|
-
}
|
|
590
|
-
gridRow.expanded = expanded;
|
|
591
|
-
raiseGridExpandableRowStateChanged(gridApi, gridRow, expanded);
|
|
592
|
-
}
|
|
593
|
-
function expandAllGridRowsCommand(buildRows, data, setExpandedRows) {
|
|
594
|
-
setExpandedRows(expandAllGridRows(buildRows(data)));
|
|
595
|
-
}
|
|
596
|
-
function collapseAllGridRowsCommand(setExpandedRows) {
|
|
597
|
-
setExpandedRows({});
|
|
598
|
-
}
|
|
599
|
-
function toggleGridTreeRowCommand(gridApi, currentExpandedTreeRows, rowId, setExpandedTreeRows, findRowById) {
|
|
600
|
-
const { expanded, nextExpandedTreeRows } = toggleGridTreeRowExpanded(
|
|
601
|
-
currentExpandedTreeRows,
|
|
602
|
-
rowId
|
|
603
|
-
);
|
|
604
|
-
setExpandedTreeRows(nextExpandedTreeRows);
|
|
605
|
-
const gridRow = findRowById(rowId);
|
|
606
|
-
if (gridRow) {
|
|
607
|
-
raiseGridTreeRowStateChanged(gridApi, gridRow, expanded);
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
function setGridTreeRowExpandedCommand(gridApi, currentExpandedTreeRows, rowId, expanded, setExpandedTreeRows, findRowById) {
|
|
611
|
-
setExpandedTreeRows(setGridTreeRowExpanded(currentExpandedTreeRows, rowId, expanded));
|
|
612
|
-
const gridRow = findRowById(rowId);
|
|
613
|
-
if (gridRow) {
|
|
614
|
-
raiseGridTreeRowStateChanged(gridApi, gridRow, expanded);
|
|
615
|
-
}
|
|
616
|
-
}
|
|
617
|
-
function expandAllGridTreeRowsCommand(buildRows, data, setExpandedTreeRows) {
|
|
618
|
-
setExpandedTreeRows(expandAllGridTreeRows(buildRows(data)));
|
|
619
|
-
}
|
|
620
|
-
function collapseAllGridTreeRowsCommand(setExpandedTreeRows) {
|
|
621
|
-
setExpandedTreeRows({});
|
|
622
|
-
}
|
|
623
|
-
function beginGridCellEditCommand(gridApi, access, row, column, currentValue, triggerEvent, initialValue) {
|
|
624
|
-
const nextEditSession = beginGridEditSession(
|
|
625
|
-
row.id,
|
|
626
|
-
column.name,
|
|
627
|
-
initialValue ?? stringifyGridEditorValue(currentValue)
|
|
628
|
-
);
|
|
629
|
-
access.setFocusedCell(nextEditSession.focusedCell);
|
|
630
|
-
access.setEditingCell(nextEditSession.editingCell);
|
|
631
|
-
access.setEditingValue(nextEditSession.editingValue);
|
|
632
|
-
raiseGridBeginCellEdit(gridApi, row.entity, column, triggerEvent);
|
|
633
|
-
return nextEditSession.editingCell;
|
|
634
|
-
}
|
|
635
|
-
function commitGridCellEditCommand(gridApi, access) {
|
|
636
|
-
const editingCell = access.getEditingCell();
|
|
637
|
-
if (!editingCell) {
|
|
638
|
-
return { committed: false };
|
|
639
|
-
}
|
|
640
|
-
const row = access.findRowById(editingCell.rowId);
|
|
641
|
-
const column = access.findColumnByName(editingCell.columnName);
|
|
642
|
-
if (!row || !column) {
|
|
643
|
-
access.setEditingCell(null);
|
|
644
|
-
return { committed: false };
|
|
645
|
-
}
|
|
646
|
-
const oldValue = getCellValue(row.entity, column);
|
|
647
|
-
const newValue = access.parseEditedValue(column, access.getEditingValue(), oldValue);
|
|
648
|
-
access.setCellValue(row.entity, column, newValue);
|
|
649
|
-
const clearedEditSession = clearGridEditSession();
|
|
650
|
-
access.setEditingCell(clearedEditSession.editingCell);
|
|
651
|
-
raiseGridAfterCellEdit(gridApi, row.entity, column, newValue, oldValue);
|
|
652
|
-
access.setEditingValue(clearedEditSession.editingValue);
|
|
653
|
-
return {
|
|
654
|
-
committed: true,
|
|
655
|
-
focusTarget: { rowId: row.id, columnName: column.name },
|
|
656
|
-
row,
|
|
657
|
-
column
|
|
658
|
-
};
|
|
659
|
-
}
|
|
660
|
-
function cancelGridCellEditCommand(gridApi, access) {
|
|
661
|
-
const editingCell = access.getEditingCell();
|
|
662
|
-
if (!editingCell) {
|
|
663
|
-
return {};
|
|
664
|
-
}
|
|
665
|
-
const row = access.findRowById(editingCell.rowId);
|
|
666
|
-
const column = access.findColumnByName(editingCell.columnName);
|
|
667
|
-
const clearedEditSession = clearGridEditSession();
|
|
668
|
-
access.setEditingCell(clearedEditSession.editingCell);
|
|
669
|
-
access.setEditingValue(clearedEditSession.editingValue);
|
|
670
|
-
if (!row || !column) {
|
|
671
|
-
return {};
|
|
672
|
-
}
|
|
673
|
-
raiseGridCancelCellEdit(gridApi, row.entity, column);
|
|
674
|
-
return { focusTarget: editingCell };
|
|
675
|
-
}
|
|
676
|
-
function maybeRequestInfiniteScrollCommand(gridApi, access) {
|
|
677
|
-
if (!access.enabled || !access.virtualizationEnabled) {
|
|
678
|
-
return;
|
|
679
|
-
}
|
|
680
|
-
const { request, nextState } = maybeRequestInfiniteScrollData({
|
|
681
|
-
state: access.state,
|
|
682
|
-
startIndex: access.startIndex,
|
|
683
|
-
visibleRows: access.visibleRows,
|
|
684
|
-
viewportRows: access.viewportRows,
|
|
685
|
-
threshold: access.threshold
|
|
686
|
-
});
|
|
687
|
-
if (request === "top" || request === "bottom") {
|
|
688
|
-
access.setState(nextState);
|
|
689
|
-
raiseGridNeedMoreData(gridApi, request);
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
function completeGridInfiniteScrollDataLoadCommand(currentState, setState, scrollUp, scrollDown) {
|
|
693
|
-
setState(completeInfiniteScrollDataLoad(currentState, scrollUp, scrollDown));
|
|
694
|
-
return Promise.resolve();
|
|
695
|
-
}
|
|
696
|
-
function resetGridInfiniteScrollCommand(setState, scrollUp, scrollDown) {
|
|
697
|
-
setState(resetInfiniteScrollState(scrollUp, scrollDown));
|
|
698
|
-
}
|
|
699
|
-
function saveGridInfiniteScrollPercentageCommand(currentState, visibleRows, setState) {
|
|
700
|
-
setState(saveInfiniteScrollPercentage(currentState, visibleRows));
|
|
701
|
-
}
|
|
702
|
-
function setGridInfiniteScrollDirectionsCommand(currentState, setState, scrollUp, scrollDown) {
|
|
703
|
-
setState(setInfiniteScrollDirectionsState(currentState, scrollUp, scrollDown));
|
|
704
|
-
}
|
|
705
|
-
|
|
706
|
-
// ../ui-grid/src/lib/grid/ui-grid.host.ts
|
|
707
|
-
function observeGridHostSize(hostElement, onSizeChange) {
|
|
708
|
-
if (typeof ResizeObserver === "undefined") {
|
|
709
|
-
return null;
|
|
710
|
-
}
|
|
711
|
-
const observer = new ResizeObserver((entries) => {
|
|
712
|
-
const entry = entries[0];
|
|
713
|
-
if (!entry) {
|
|
714
|
-
return;
|
|
715
|
-
}
|
|
716
|
-
onSizeChange({
|
|
717
|
-
height: Math.round(entry.contentRect.height),
|
|
718
|
-
width: Math.round(entry.contentRect.width)
|
|
719
|
-
});
|
|
720
|
-
});
|
|
721
|
-
observer.observe(hostElement);
|
|
722
|
-
return observer;
|
|
723
|
-
}
|
|
724
|
-
function downloadGridCsvFile(csv, filename) {
|
|
725
|
-
if (typeof Blob === "undefined" || typeof URL === "undefined" || typeof document === "undefined") {
|
|
726
|
-
return;
|
|
727
|
-
}
|
|
728
|
-
const blob = new Blob([csv], { type: "text/csv;charset=utf-8" });
|
|
729
|
-
const url = URL.createObjectURL(blob);
|
|
730
|
-
const link = document.createElement("a");
|
|
731
|
-
link.href = url;
|
|
732
|
-
link.download = filename;
|
|
733
|
-
link.click();
|
|
734
|
-
URL.revokeObjectURL(url);
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
// src/useGridState.ts
|
|
81
|
+
var import_ui_grid_core2 = require("@ornery/ui-grid-core");
|
|
738
82
|
function escapeCssSelectorValue(value) {
|
|
739
83
|
const nativeEscape = globalThis.CSS?.escape;
|
|
740
84
|
if (typeof nativeEscape === "function") {
|
|
@@ -772,7 +116,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
772
116
|
const [hiddenRowReasons, setHiddenRowReasons] = (0, import_react.useState)({});
|
|
773
117
|
const [sortState, setSortState] = (0, import_react.useState)({
|
|
774
118
|
columnName: null,
|
|
775
|
-
direction:
|
|
119
|
+
direction: import_ui_grid_core2.SORT_DIRECTIONS.none
|
|
776
120
|
});
|
|
777
121
|
const [focusedCell, setFocusedCell] = (0, import_react.useState)(null);
|
|
778
122
|
const [editingCell, setEditingCell] = (0, import_react.useState)(null);
|
|
@@ -833,12 +177,23 @@ function useGridState(options, onRegisterApi) {
|
|
|
833
177
|
optionsRef.current = options;
|
|
834
178
|
const rowSize = options.rowHeight ?? 44;
|
|
835
179
|
const visibleColumns = (0, import_react.useMemo)(() => {
|
|
836
|
-
|
|
837
|
-
|
|
180
|
+
const orderedColumns = orderVisibleColumns(options.columnDefs, columnOrder);
|
|
181
|
+
const pinnedEntries = Object.entries(pinnedColumns);
|
|
182
|
+
if (pinnedEntries.length === 0) {
|
|
183
|
+
return orderedColumns;
|
|
184
|
+
}
|
|
185
|
+
const columnByName = new Map(orderedColumns.map((column) => [column.name, column]));
|
|
186
|
+
const pinnedLeft = pinnedEntries.filter(([, direction]) => direction === "left").map(([columnName]) => columnByName.get(columnName)).filter((column) => column !== void 0);
|
|
187
|
+
const pinnedRight = pinnedEntries.filter(([, direction]) => direction === "right").map(([columnName]) => columnByName.get(columnName)).filter((column) => column !== void 0);
|
|
188
|
+
const centerColumns = orderedColumns.filter(
|
|
189
|
+
(column) => pinnedColumns[column.name] === void 0
|
|
190
|
+
);
|
|
191
|
+
return [...pinnedLeft, ...centerColumns, ...pinnedRight];
|
|
192
|
+
}, [options.columnDefs, columnOrder, pinnedColumns]);
|
|
838
193
|
const visibleColumnsRef = (0, import_react.useRef)(visibleColumns);
|
|
839
194
|
visibleColumnsRef.current = visibleColumns;
|
|
840
195
|
const pipeline = (0, import_react.useMemo)(() => {
|
|
841
|
-
return
|
|
196
|
+
return import_ui_grid_core2.defaultGridEngine.buildPipeline({
|
|
842
197
|
options,
|
|
843
198
|
columns: visibleColumns,
|
|
844
199
|
activeFilters,
|
|
@@ -868,28 +223,28 @@ function useGridState(options, onRegisterApi) {
|
|
|
868
223
|
]);
|
|
869
224
|
const pipelineRef = (0, import_react.useRef)(pipeline);
|
|
870
225
|
pipelineRef.current = pipeline;
|
|
871
|
-
const labels = (0, import_react.useMemo)(() => (0,
|
|
226
|
+
const labels = (0, import_react.useMemo)(() => (0, import_ui_grid_core2.resolveGridLabels)(options.labels), [options.labels]);
|
|
872
227
|
const gridTemplateColumns = (0, import_react.useMemo)(
|
|
873
228
|
() => buildGridTemplateColumns(visibleColumns),
|
|
874
229
|
[visibleColumns]
|
|
875
230
|
);
|
|
876
231
|
const isPinningEnabledFn = (0, import_react.useCallback)(() => {
|
|
877
|
-
return isPinningEnabled(optionsRef.current);
|
|
232
|
+
return (0, import_ui_grid_core2.isPinningEnabled)(optionsRef.current);
|
|
878
233
|
}, []);
|
|
879
234
|
const isColumnPinnableFn = (0, import_react.useCallback)((column) => {
|
|
880
|
-
return isColumnPinnable(optionsRef.current, column);
|
|
235
|
+
return (0, import_ui_grid_core2.isColumnPinnable)(optionsRef.current, column);
|
|
881
236
|
}, []);
|
|
882
237
|
const isPinnedFn = (0, import_react.useCallback)((column) => {
|
|
883
238
|
return pinnedColumnsRef.current[column.name] !== void 0;
|
|
884
239
|
}, []);
|
|
885
240
|
const pinnedOffsetFn = (0, import_react.useCallback)((column) => {
|
|
886
|
-
return computePinnedOffset(visibleColumnsRef.current, pinnedColumnsRef.current, column);
|
|
241
|
+
return (0, import_ui_grid_core2.computePinnedOffset)(visibleColumnsRef.current, pinnedColumnsRef.current, column);
|
|
887
242
|
}, []);
|
|
888
243
|
const resolveRowId = (0, import_react.useCallback)((row) => {
|
|
889
|
-
return (0,
|
|
244
|
+
return (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
890
245
|
}, []);
|
|
891
246
|
const buildRowsFromData = (0, import_react.useCallback)((data) => {
|
|
892
|
-
return (0,
|
|
247
|
+
return (0, import_ui_grid_core2.buildGridRows)(
|
|
893
248
|
{ ...optionsRef.current, data },
|
|
894
249
|
optionsRef.current.rowHeight ?? 44,
|
|
895
250
|
hiddenRowReasonsRef.current,
|
|
@@ -898,19 +253,19 @@ function useGridState(options, onRegisterApi) {
|
|
|
898
253
|
}, []);
|
|
899
254
|
const findRowById = (0, import_react.useCallback)(
|
|
900
255
|
(rowId) => {
|
|
901
|
-
return (0,
|
|
256
|
+
return (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId);
|
|
902
257
|
},
|
|
903
258
|
[buildRowsFromData]
|
|
904
259
|
);
|
|
905
260
|
const canExpandRowsFn = (0, import_react.useCallback)(() => {
|
|
906
|
-
return
|
|
261
|
+
return import_ui_grid_core2.FEATURE_EXPANDABLE && (0, import_ui_grid_core2.canGridExpandRows)(optionsRef.current);
|
|
907
262
|
}, []);
|
|
908
263
|
const effectivePageSizeFn = (0, import_react.useCallback)((totalItems) => {
|
|
909
|
-
return (0,
|
|
264
|
+
return (0, import_ui_grid_core2.getEffectivePageSize)(optionsRef.current, pageSizeRef.current, totalItems);
|
|
910
265
|
}, []);
|
|
911
266
|
const getCurrentPageValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
912
267
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
913
|
-
return (0,
|
|
268
|
+
return (0, import_ui_grid_core2.getCurrentPageValue)(
|
|
914
269
|
optionsRef.current,
|
|
915
270
|
currentPageRef.current,
|
|
916
271
|
ti,
|
|
@@ -919,11 +274,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
919
274
|
}, []);
|
|
920
275
|
const getTotalPagesValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
921
276
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
922
|
-
return (0,
|
|
277
|
+
return (0, import_ui_grid_core2.getTotalPagesValue)(optionsRef.current, ti, pageSizeRef.current);
|
|
923
278
|
}, []);
|
|
924
279
|
const getFirstRowIndexValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
925
280
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
926
|
-
return (0,
|
|
281
|
+
return (0, import_ui_grid_core2.getFirstRowIndexValue)(
|
|
927
282
|
optionsRef.current,
|
|
928
283
|
currentPageRef.current,
|
|
929
284
|
ti,
|
|
@@ -932,7 +287,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
932
287
|
}, []);
|
|
933
288
|
const getLastRowIndexValueFn = (0, import_react.useCallback)((totalItems) => {
|
|
934
289
|
const ti = totalItems ?? pipelineRef.current.totalItems;
|
|
935
|
-
return (0,
|
|
290
|
+
return (0, import_ui_grid_core2.getLastRowIndexValue)(
|
|
936
291
|
optionsRef.current,
|
|
937
292
|
currentPageRef.current,
|
|
938
293
|
ti,
|
|
@@ -941,7 +296,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
941
296
|
}, []);
|
|
942
297
|
const isCellEditable = (0, import_react.useCallback)(
|
|
943
298
|
(row, column, triggerEvent) => {
|
|
944
|
-
if (!
|
|
299
|
+
if (!import_ui_grid_core2.FEATURE_CELL_EDIT) return false;
|
|
945
300
|
const editable = column.enableCellEdit ?? optionsRef.current.enableCellEdit ?? false;
|
|
946
301
|
if (!editable) return false;
|
|
947
302
|
const condition = column.cellEditableCondition ?? optionsRef.current.cellEditableCondition ?? true;
|
|
@@ -1006,12 +361,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
1006
361
|
refresh: () => setActiveFilters((current) => ({ ...current })),
|
|
1007
362
|
getVisibleRows: () => pipelineRef.current.visibleRows,
|
|
1008
363
|
setRowInvisible: (row, reason = "user") => {
|
|
1009
|
-
const rowId = (0,
|
|
1010
|
-
setHiddenRowReasons((current) => (0,
|
|
364
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
365
|
+
setHiddenRowReasons((current) => (0, import_ui_grid_core2.addGridRowInvisibleReason)(current, rowId, reason));
|
|
1011
366
|
},
|
|
1012
367
|
clearRowInvisible: (row, reason = "user") => {
|
|
1013
|
-
const rowId = (0,
|
|
1014
|
-
setHiddenRowReasons((current) => (0,
|
|
368
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
369
|
+
setHiddenRowReasons((current) => (0, import_ui_grid_core2.clearGridRowInvisibleReason)(current, rowId, reason));
|
|
1015
370
|
},
|
|
1016
371
|
setFilter: (columnName, value) => {
|
|
1017
372
|
setActiveFilters((current) => {
|
|
@@ -1028,19 +383,19 @@ function useGridState(options, onRegisterApi) {
|
|
|
1028
383
|
queueMicrotask(() => gridApiRef.current.core.raise.filterChanged(nextFilters));
|
|
1029
384
|
},
|
|
1030
385
|
sortColumn: (columnName, direction) => {
|
|
1031
|
-
sortGridColumnCommand(gridApiRef.current, (s) => setSortState(s), columnName, direction);
|
|
386
|
+
(0, import_ui_grid_core2.sortGridColumnCommand)(gridApiRef.current, (s) => setSortState(s), columnName, direction);
|
|
1032
387
|
},
|
|
1033
388
|
moveColumn: (fromIndex, toIndex) => {
|
|
1034
|
-
moveGridColumnCommand(
|
|
389
|
+
(0, import_ui_grid_core2.moveGridColumnCommand)(
|
|
1035
390
|
gridApiRef.current,
|
|
1036
|
-
|
|
391
|
+
import_ui_grid_core2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
1037
392
|
(updater) => setColumnOrder((current) => updater(current)),
|
|
1038
393
|
fromIndex,
|
|
1039
394
|
toIndex
|
|
1040
395
|
);
|
|
1041
396
|
},
|
|
1042
397
|
toggleGrouping: (columnName) => {
|
|
1043
|
-
if (!(
|
|
398
|
+
if (!(import_ui_grid_core2.FEATURE_GROUPING && (0, import_ui_grid_core2.isGridGroupingEnabled)(optionsRef.current))) return;
|
|
1044
399
|
const current = groupByColumnsRef.current;
|
|
1045
400
|
const next = current.includes(columnName) ? current.filter((n) => n !== columnName) : [...current, columnName];
|
|
1046
401
|
groupByColumnsRef.current = next;
|
|
@@ -1048,7 +403,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1048
403
|
gridApiRef.current.core.raise.groupingChanged(next);
|
|
1049
404
|
},
|
|
1050
405
|
clearGrouping: () => {
|
|
1051
|
-
clearGridGroupingCommand(
|
|
406
|
+
(0, import_ui_grid_core2.clearGridGroupingCommand)(
|
|
1052
407
|
gridApiRef.current,
|
|
1053
408
|
(grouping) => setGroupByColumns(grouping),
|
|
1054
409
|
false
|
|
@@ -1071,30 +426,30 @@ function useGridState(options, onRegisterApi) {
|
|
|
1071
426
|
toggleRowExpansion: (row) => toggleRowExpansionByRefFn(row),
|
|
1072
427
|
expandAllRows: () => expandAllRowsFn(),
|
|
1073
428
|
collapseAllRows: () => {
|
|
1074
|
-
collapseAllGridRowsCommand((e) => setExpandedRows(e));
|
|
429
|
+
(0, import_ui_grid_core2.collapseAllGridRowsCommand)((e) => setExpandedRows(e));
|
|
1075
430
|
},
|
|
1076
431
|
toggleAllRows: () => toggleAllRowsFn(),
|
|
1077
432
|
treeExpandAllRows: () => {
|
|
1078
|
-
expandAllGridTreeRowsCommand(
|
|
433
|
+
(0, import_ui_grid_core2.expandAllGridTreeRowsCommand)(
|
|
1079
434
|
(data) => buildRowsFromData(data),
|
|
1080
435
|
optionsRef.current.data,
|
|
1081
436
|
(e) => setExpandedTreeRows(e)
|
|
1082
437
|
);
|
|
1083
438
|
},
|
|
1084
439
|
treeCollapseAllRows: () => {
|
|
1085
|
-
collapseAllGridTreeRowsCommand((e) => setExpandedTreeRows(e));
|
|
440
|
+
(0, import_ui_grid_core2.collapseAllGridTreeRowsCommand)((e) => setExpandedTreeRows(e));
|
|
1086
441
|
},
|
|
1087
442
|
treeToggleRow: (row) => toggleTreeRowByRefFn(row),
|
|
1088
443
|
treeExpandRow: (row) => expandTreeRowByRefFn(row),
|
|
1089
444
|
treeCollapseRow: (row) => collapseTreeRowByRefFn(row),
|
|
1090
445
|
treeGetRowChildren: (row) => {
|
|
1091
|
-
const rowId = (0,
|
|
446
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
1092
447
|
return buildRowsFromData(optionsRef.current.data).filter((r) => r.parentId === rowId);
|
|
1093
448
|
},
|
|
1094
449
|
treeGetState: () => expandedTreeRowsRef.current,
|
|
1095
450
|
treeSetState: (state) => setExpandedTreeRows({ ...state }),
|
|
1096
451
|
infiniteScrollDataLoaded: (scrollUp, scrollDown) => {
|
|
1097
|
-
return completeGridInfiniteScrollDataLoadCommand(
|
|
452
|
+
return (0, import_ui_grid_core2.completeGridInfiniteScrollDataLoadCommand)(
|
|
1098
453
|
infiniteScrollStateRef.current,
|
|
1099
454
|
(s) => setInfiniteScrollState(s),
|
|
1100
455
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
@@ -1102,35 +457,35 @@ function useGridState(options, onRegisterApi) {
|
|
|
1102
457
|
);
|
|
1103
458
|
},
|
|
1104
459
|
infiniteScrollReset: (scrollUp, scrollDown) => {
|
|
1105
|
-
resetGridInfiniteScrollCommand(
|
|
460
|
+
(0, import_ui_grid_core2.resetGridInfiniteScrollCommand)(
|
|
1106
461
|
(s) => setInfiniteScrollState(s),
|
|
1107
462
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
1108
463
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
1109
464
|
);
|
|
1110
465
|
},
|
|
1111
466
|
infiniteScrollSaveScrollPercentage: () => {
|
|
1112
|
-
saveGridInfiniteScrollPercentageCommand(
|
|
467
|
+
(0, import_ui_grid_core2.saveGridInfiniteScrollPercentageCommand)(
|
|
1113
468
|
infiniteScrollStateRef.current,
|
|
1114
469
|
pipelineRef.current.visibleRows.length,
|
|
1115
470
|
(s) => setInfiniteScrollState(s)
|
|
1116
471
|
);
|
|
1117
472
|
},
|
|
1118
473
|
infiniteScrollDataRemovedTop: (scrollUp, scrollDown) => {
|
|
1119
|
-
resetGridInfiniteScrollCommand(
|
|
474
|
+
(0, import_ui_grid_core2.resetGridInfiniteScrollCommand)(
|
|
1120
475
|
(s) => setInfiniteScrollState(s),
|
|
1121
476
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
1122
477
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
1123
478
|
);
|
|
1124
479
|
},
|
|
1125
480
|
infiniteScrollDataRemovedBottom: (scrollUp, scrollDown) => {
|
|
1126
|
-
resetGridInfiniteScrollCommand(
|
|
481
|
+
(0, import_ui_grid_core2.resetGridInfiniteScrollCommand)(
|
|
1127
482
|
(s) => setInfiniteScrollState(s),
|
|
1128
483
|
scrollUp ?? infiniteScrollStateRef.current.scrollUp,
|
|
1129
484
|
scrollDown ?? infiniteScrollStateRef.current.scrollDown
|
|
1130
485
|
);
|
|
1131
486
|
},
|
|
1132
487
|
infiniteScrollSetDirections: (scrollUp, scrollDown) => {
|
|
1133
|
-
setGridInfiniteScrollDirectionsCommand(
|
|
488
|
+
(0, import_ui_grid_core2.setGridInfiniteScrollDirectionsCommand)(
|
|
1134
489
|
infiniteScrollStateRef.current,
|
|
1135
490
|
(s) => setInfiniteScrollState(s),
|
|
1136
491
|
scrollUp,
|
|
@@ -1138,7 +493,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1138
493
|
);
|
|
1139
494
|
},
|
|
1140
495
|
saveState: () => {
|
|
1141
|
-
return (0,
|
|
496
|
+
return (0, import_ui_grid_core2.buildGridSavedState)({
|
|
1142
497
|
columnOrder: columnOrderRef.current,
|
|
1143
498
|
activeFilters: activeFiltersRef.current,
|
|
1144
499
|
sortState: sortStateRef.current,
|
|
@@ -1152,7 +507,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1152
507
|
});
|
|
1153
508
|
},
|
|
1154
509
|
restoreState: (state) => {
|
|
1155
|
-
restoreGridStateCommand(gridApiRef.current, state, {
|
|
510
|
+
(0, import_ui_grid_core2.restoreGridStateCommand)(gridApiRef.current, state, {
|
|
1156
511
|
setColumnOrder: (order) => setColumnOrder(order),
|
|
1157
512
|
setActiveFilters: (filters) => setActiveFilters(filters),
|
|
1158
513
|
setSortState: (s) => setSortState(s),
|
|
@@ -1166,8 +521,8 @@ function useGridState(options, onRegisterApi) {
|
|
|
1166
521
|
});
|
|
1167
522
|
},
|
|
1168
523
|
beginCellEdit: (row, columnName, triggerEvent) => {
|
|
1169
|
-
const rowId = (0,
|
|
1170
|
-
const gridRow = (0,
|
|
524
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
525
|
+
const gridRow = (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId);
|
|
1171
526
|
const column = visibleColumnsRef.current.find((c) => c.name === columnName);
|
|
1172
527
|
if (!gridRow || !column || !isCellEditable(gridRow, column, triggerEvent)) return;
|
|
1173
528
|
startCellEditFn(gridRow, column, triggerEvent);
|
|
@@ -1176,7 +531,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1176
531
|
cancelCellEdit: () => cancelCellEditFn(),
|
|
1177
532
|
getEditingCell: () => editingCellRef.current,
|
|
1178
533
|
pinColumn: (columnName, direction) => {
|
|
1179
|
-
pinGridColumnCommand(
|
|
534
|
+
(0, import_ui_grid_core2.pinGridColumnCommand)(
|
|
1180
535
|
gridApiRef.current,
|
|
1181
536
|
isPinningEnabledFn(),
|
|
1182
537
|
(v) => setPinnedColumns(v),
|
|
@@ -1186,12 +541,12 @@ function useGridState(options, onRegisterApi) {
|
|
|
1186
541
|
);
|
|
1187
542
|
}
|
|
1188
543
|
};
|
|
1189
|
-
gridApiRef.current = (0,
|
|
544
|
+
gridApiRef.current = (0, import_ui_grid_core2.createGridApi)(bindings);
|
|
1190
545
|
}
|
|
1191
546
|
const gridApi = gridApiRef.current;
|
|
1192
547
|
const seekPageFn = (0, import_react.useCallback)(
|
|
1193
548
|
(page) => {
|
|
1194
|
-
seekGridPaginationCommand(
|
|
549
|
+
(0, import_ui_grid_core2.seekGridPaginationCommand)(
|
|
1195
550
|
gridApiRef.current,
|
|
1196
551
|
(nextPage) => setCurrentPage(nextPage),
|
|
1197
552
|
() => getTotalPagesValueFn(),
|
|
@@ -1204,7 +559,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1204
559
|
const togglePinFn = (0, import_react.useCallback)((column) => {
|
|
1205
560
|
const current = pinnedColumnsRef.current[column.name];
|
|
1206
561
|
const next = current === "left" ? "right" : current === "right" ? "none" : "left";
|
|
1207
|
-
pinGridColumnCommand(
|
|
562
|
+
(0, import_ui_grid_core2.pinGridColumnCommand)(
|
|
1208
563
|
gridApiRef.current,
|
|
1209
564
|
isPinningEnabledFn(),
|
|
1210
565
|
(v) => setPinnedColumns(v),
|
|
@@ -1214,7 +569,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1214
569
|
);
|
|
1215
570
|
}, []);
|
|
1216
571
|
const setPaginationPageSizeFn = (0, import_react.useCallback)((ps) => {
|
|
1217
|
-
setGridPaginationPageSizeCommand(
|
|
572
|
+
(0, import_ui_grid_core2.setGridPaginationPageSizeCommand)(
|
|
1218
573
|
gridApiRef.current,
|
|
1219
574
|
(nextPageSize) => setPageSize(nextPageSize),
|
|
1220
575
|
(nextPage) => setCurrentPage(nextPage),
|
|
@@ -1223,83 +578,83 @@ function useGridState(options, onRegisterApi) {
|
|
|
1223
578
|
}, []);
|
|
1224
579
|
const toggleRowExpansionByRefFn = (0, import_react.useCallback)(
|
|
1225
580
|
(row) => {
|
|
1226
|
-
const rowId = (0,
|
|
1227
|
-
toggleGridRowExpansionCommand(
|
|
581
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
582
|
+
(0, import_ui_grid_core2.toggleGridRowExpansionCommand)(
|
|
1228
583
|
gridApiRef.current,
|
|
1229
|
-
|
|
584
|
+
import_ui_grid_core2.FEATURE_EXPANDABLE && (0, import_ui_grid_core2.canGridExpandRows)(optionsRef.current),
|
|
1230
585
|
expandedRowsRef.current,
|
|
1231
586
|
rowId,
|
|
1232
587
|
(e) => setExpandedRows(e),
|
|
1233
|
-
(resolvedRowId) => (0,
|
|
588
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
1234
589
|
);
|
|
1235
590
|
},
|
|
1236
591
|
[buildRowsFromData]
|
|
1237
592
|
);
|
|
1238
593
|
const expandAllRowsFn = (0, import_react.useCallback)(() => {
|
|
1239
|
-
if (!(0,
|
|
1240
|
-
expandAllGridRowsCommand(
|
|
594
|
+
if (!(0, import_ui_grid_core2.canGridExpandRows)(optionsRef.current)) return;
|
|
595
|
+
(0, import_ui_grid_core2.expandAllGridRowsCommand)(
|
|
1241
596
|
(data) => buildRowsFromData(data),
|
|
1242
597
|
optionsRef.current.data,
|
|
1243
598
|
(e) => setExpandedRows(e)
|
|
1244
599
|
);
|
|
1245
600
|
}, [buildRowsFromData]);
|
|
1246
601
|
const toggleAllRowsFn = (0, import_react.useCallback)(() => {
|
|
1247
|
-
const allExpanded = (0,
|
|
602
|
+
const allExpanded = (0, import_ui_grid_core2.areAllGridRowsExpanded)(
|
|
1248
603
|
buildRowsFromData(optionsRef.current.data),
|
|
1249
604
|
expandedRowsRef.current
|
|
1250
605
|
);
|
|
1251
606
|
if (allExpanded) {
|
|
1252
|
-
collapseAllGridRowsCommand((e) => setExpandedRows(e));
|
|
607
|
+
(0, import_ui_grid_core2.collapseAllGridRowsCommand)((e) => setExpandedRows(e));
|
|
1253
608
|
} else {
|
|
1254
609
|
expandAllRowsFn();
|
|
1255
610
|
}
|
|
1256
611
|
}, [buildRowsFromData, expandAllRowsFn]);
|
|
1257
612
|
const toggleTreeRowByRefFn = (0, import_react.useCallback)(
|
|
1258
613
|
(row) => {
|
|
1259
|
-
const rowId = (0,
|
|
1260
|
-
toggleGridTreeRowCommand(
|
|
614
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
615
|
+
(0, import_ui_grid_core2.toggleGridTreeRowCommand)(
|
|
1261
616
|
gridApiRef.current,
|
|
1262
617
|
expandedTreeRowsRef.current,
|
|
1263
618
|
rowId,
|
|
1264
619
|
(e) => setExpandedTreeRows(e),
|
|
1265
|
-
(resolvedRowId) => (0,
|
|
620
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
1266
621
|
);
|
|
1267
622
|
},
|
|
1268
623
|
[buildRowsFromData]
|
|
1269
624
|
);
|
|
1270
625
|
const expandTreeRowByRefFn = (0, import_react.useCallback)(
|
|
1271
626
|
(row) => {
|
|
1272
|
-
const rowId = (0,
|
|
1273
|
-
setGridTreeRowExpandedCommand(
|
|
627
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
628
|
+
(0, import_ui_grid_core2.setGridTreeRowExpandedCommand)(
|
|
1274
629
|
gridApiRef.current,
|
|
1275
630
|
expandedTreeRowsRef.current,
|
|
1276
631
|
rowId,
|
|
1277
632
|
true,
|
|
1278
633
|
(e) => setExpandedTreeRows(e),
|
|
1279
|
-
(resolvedRowId) => (0,
|
|
634
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
1280
635
|
);
|
|
1281
636
|
},
|
|
1282
637
|
[buildRowsFromData]
|
|
1283
638
|
);
|
|
1284
639
|
const collapseTreeRowByRefFn = (0, import_react.useCallback)(
|
|
1285
640
|
(row) => {
|
|
1286
|
-
const rowId = (0,
|
|
1287
|
-
setGridTreeRowExpandedCommand(
|
|
641
|
+
const rowId = (0, import_ui_grid_core2.resolveGridRowId)(optionsRef.current, row);
|
|
642
|
+
(0, import_ui_grid_core2.setGridTreeRowExpandedCommand)(
|
|
1288
643
|
gridApiRef.current,
|
|
1289
644
|
expandedTreeRowsRef.current,
|
|
1290
645
|
rowId,
|
|
1291
646
|
false,
|
|
1292
647
|
(e) => setExpandedTreeRows(e),
|
|
1293
|
-
(resolvedRowId) => (0,
|
|
648
|
+
(resolvedRowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), resolvedRowId)
|
|
1294
649
|
);
|
|
1295
650
|
},
|
|
1296
651
|
[buildRowsFromData]
|
|
1297
652
|
);
|
|
1298
653
|
const startCellEditFn = (0, import_react.useCallback)(
|
|
1299
654
|
(row, column, triggerEvent, initialValue) => {
|
|
1300
|
-
const currentValue = (0,
|
|
655
|
+
const currentValue = (0, import_ui_grid_core2.getCellValue)(row.entity, column);
|
|
1301
656
|
const focusToken = ++editorFocusTokenRef.current;
|
|
1302
|
-
const ec = beginGridCellEditCommand(
|
|
657
|
+
const ec = (0, import_ui_grid_core2.beginGridCellEditCommand)(
|
|
1303
658
|
gridApiRef.current,
|
|
1304
659
|
{
|
|
1305
660
|
setFocusedCell: (fc) => setFocusedCell(fc),
|
|
@@ -1320,17 +675,17 @@ function useGridState(options, onRegisterApi) {
|
|
|
1320
675
|
);
|
|
1321
676
|
const commitCellEditFn = (0, import_react.useCallback)(
|
|
1322
677
|
(direction, restoreFocus = true) => {
|
|
1323
|
-
const result = commitGridCellEditCommand(gridApiRef.current, {
|
|
678
|
+
const result = (0, import_ui_grid_core2.commitGridCellEditCommand)(gridApiRef.current, {
|
|
1324
679
|
getEditingCell: () => editingCellRef.current,
|
|
1325
680
|
getEditingValue: () => editingValueRef.current,
|
|
1326
681
|
setEditingCell: (ec) => setEditingCell(ec),
|
|
1327
682
|
setEditingValue: (ev) => setEditingValue(ev),
|
|
1328
|
-
findRowById: (rowId) => (0,
|
|
683
|
+
findRowById: (rowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId),
|
|
1329
684
|
findColumnByName: (columnName) => visibleColumnsRef.current.find((c) => c.name === columnName),
|
|
1330
|
-
parseEditedValue: (column, value, oldValue) => (0,
|
|
685
|
+
parseEditedValue: (column, value, oldValue) => (0, import_ui_grid_core2.parseGridEditedValue)(column, value, oldValue),
|
|
1331
686
|
setCellValue: (rowEntity, column, value) => {
|
|
1332
687
|
const fieldPath = column.editModelField ?? column.field ?? column.name;
|
|
1333
|
-
(0,
|
|
688
|
+
(0, import_ui_grid_core2.setPathValue)(rowEntity, fieldPath, value);
|
|
1334
689
|
}
|
|
1335
690
|
});
|
|
1336
691
|
if (!result.committed || !result.row || !result.column || !result.focusTarget) return;
|
|
@@ -1346,11 +701,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
1346
701
|
);
|
|
1347
702
|
const cancelCellEditFn = (0, import_react.useCallback)(() => {
|
|
1348
703
|
const hadEditingCell = editingCellRef.current !== null;
|
|
1349
|
-
const result = cancelGridCellEditCommand(gridApiRef.current, {
|
|
704
|
+
const result = (0, import_ui_grid_core2.cancelGridCellEditCommand)(gridApiRef.current, {
|
|
1350
705
|
getEditingCell: () => editingCellRef.current,
|
|
1351
706
|
setEditingCell: (ec) => setEditingCell(ec),
|
|
1352
707
|
setEditingValue: (ev) => setEditingValue(ev),
|
|
1353
|
-
findRowById: (rowId) => (0,
|
|
708
|
+
findRowById: (rowId) => (0, import_ui_grid_core2.findGridRowById)(buildRowsFromData(optionsRef.current.data), rowId),
|
|
1354
709
|
findColumnByName: (columnName) => visibleColumnsRef.current.find((c) => c.name === columnName)
|
|
1355
710
|
});
|
|
1356
711
|
if (!hadEditingCell) return;
|
|
@@ -1359,7 +714,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1359
714
|
}, [buildRowsFromData, focusRenderedCell]);
|
|
1360
715
|
const moveFocusFn = (0, import_react.useCallback)(
|
|
1361
716
|
(row, column, direction, triggerEvent) => {
|
|
1362
|
-
const nextCell = (0,
|
|
717
|
+
const nextCell = (0, import_ui_grid_core2.findNextGridCell)({
|
|
1363
718
|
rows: pipelineRef.current.visibleRows,
|
|
1364
719
|
columns: visibleColumnsRef.current,
|
|
1365
720
|
rowId: row.id,
|
|
@@ -1382,7 +737,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1382
737
|
optionsRef.current.benchmark?.iterations
|
|
1383
738
|
);
|
|
1384
739
|
const startedAt = performance.now();
|
|
1385
|
-
let lastResult =
|
|
740
|
+
let lastResult = import_ui_grid_core2.defaultGridEngine.buildPipeline({
|
|
1386
741
|
options: optionsRef.current,
|
|
1387
742
|
columns: visibleColumnsRef.current,
|
|
1388
743
|
activeFilters: activeFiltersRef.current,
|
|
@@ -1397,7 +752,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1397
752
|
rowSize: optionsRef.current.rowHeight ?? 44
|
|
1398
753
|
});
|
|
1399
754
|
for (let i = 1; i < safeIterations; i++) {
|
|
1400
|
-
lastResult =
|
|
755
|
+
lastResult = import_ui_grid_core2.defaultGridEngine.buildPipeline({
|
|
1401
756
|
options: optionsRef.current,
|
|
1402
757
|
columns: visibleColumnsRef.current,
|
|
1403
758
|
activeFilters: activeFiltersRef.current,
|
|
@@ -1421,14 +776,14 @@ function useGridState(options, onRegisterApi) {
|
|
|
1421
776
|
renderedItems: lastResult.displayItems.length
|
|
1422
777
|
};
|
|
1423
778
|
setBenchmarkResult(result);
|
|
1424
|
-
raiseGridBenchmarkComplete(gridApiRef.current, result);
|
|
779
|
+
(0, import_ui_grid_core2.raiseGridBenchmarkComplete)(gridApiRef.current, result);
|
|
1425
780
|
return result;
|
|
1426
781
|
}, []);
|
|
1427
782
|
const exportCsvFn = (0, import_react.useCallback)(() => {
|
|
1428
|
-
if (!
|
|
783
|
+
if (!import_ui_grid_core2.FEATURE_CSV_EXPORT) return;
|
|
1429
784
|
const columns = visibleColumnsRef.current;
|
|
1430
|
-
const csv = (0,
|
|
1431
|
-
downloadGridCsvFile(csv, `${(0,
|
|
785
|
+
const csv = (0, import_ui_grid_core2.exportCsvRows)(columns, pipelineRef.current.visibleRows);
|
|
786
|
+
(0, import_ui_grid_core2.downloadGridCsvFile)(csv, `${(0, import_ui_grid_core2.sanitizeDownloadFilename)(optionsRef.current.id)}.csv`);
|
|
1432
787
|
}, []);
|
|
1433
788
|
(0, import_react.useEffect)(() => {
|
|
1434
789
|
if (initializedGridIdRef.current === options.id) return;
|
|
@@ -1443,9 +798,9 @@ function useGridState(options, onRegisterApi) {
|
|
|
1443
798
|
setExpandedTreeRows({});
|
|
1444
799
|
setColumnOrder(options.columnDefs.map((column) => column.name));
|
|
1445
800
|
setGroupByColumns(options.grouping?.groupBy ?? []);
|
|
1446
|
-
setPinnedColumns(buildInitialPinnedState(options.columnDefs));
|
|
801
|
+
setPinnedColumns((0, import_ui_grid_core2.buildInitialPinnedState)(options.columnDefs));
|
|
1447
802
|
setCurrentPage(options.paginationCurrentPage ?? 1);
|
|
1448
|
-
setPageSize((0,
|
|
803
|
+
setPageSize((0, import_ui_grid_core2.getEffectivePageSize)(options, 0, options.data.length));
|
|
1449
804
|
setInfiniteScrollState({
|
|
1450
805
|
scrollUp: options.infiniteScrollUp === true,
|
|
1451
806
|
scrollDown: options.infiniteScrollDown !== false,
|
|
@@ -1457,28 +812,28 @@ function useGridState(options, onRegisterApi) {
|
|
|
1457
812
|
);
|
|
1458
813
|
setSortState({
|
|
1459
814
|
columnName: initialSort?.name ?? null,
|
|
1460
|
-
direction: initialSort?.sort?.direction ??
|
|
815
|
+
direction: initialSort?.sort?.direction ?? import_ui_grid_core2.SORT_DIRECTIONS.none
|
|
1461
816
|
});
|
|
1462
817
|
onRegisterApi?.(gridApi);
|
|
1463
|
-
raiseGridRenderingComplete(gridApi);
|
|
818
|
+
(0, import_ui_grid_core2.raiseGridRenderingComplete)(gridApi);
|
|
1464
819
|
}, [options.id]);
|
|
1465
820
|
(0, import_react.useEffect)(() => {
|
|
1466
|
-
raiseGridRowsRendered(gridApi, pipeline.visibleRows);
|
|
1467
|
-
raiseGridRowsVisibleChanged(gridApi, pipeline.visibleRows);
|
|
821
|
+
(0, import_ui_grid_core2.raiseGridRowsRendered)(gridApi, pipeline.visibleRows);
|
|
822
|
+
(0, import_ui_grid_core2.raiseGridRowsVisibleChanged)(gridApi, pipeline.visibleRows);
|
|
1468
823
|
const newHeight = pipeline.displayItems.length * rowSize;
|
|
1469
824
|
if (newHeight !== lastCanvasHeightRef.current) {
|
|
1470
|
-
raiseGridCanvasHeightChanged(gridApi, lastCanvasHeightRef.current, newHeight);
|
|
825
|
+
(0, import_ui_grid_core2.raiseGridCanvasHeightChanged)(gridApi, lastCanvasHeightRef.current, newHeight);
|
|
1471
826
|
lastCanvasHeightRef.current = newHeight;
|
|
1472
827
|
}
|
|
1473
828
|
}, [pipeline, gridApi, rowSize]);
|
|
1474
829
|
(0, import_react.useEffect)(() => {
|
|
1475
|
-
if (!
|
|
830
|
+
if (!import_ui_grid_core2.FEATURE_AUTO_RESIZE || !options.enableAutoResize) return;
|
|
1476
831
|
const container = gridContainerRef.current;
|
|
1477
832
|
if (!container) return;
|
|
1478
|
-
const observer = observeGridHostSize(container, ({ height: nextHeight, width: nextWidth }) => {
|
|
833
|
+
const observer = (0, import_ui_grid_core2.observeGridHostSize)(container, ({ height: nextHeight, width: nextWidth }) => {
|
|
1479
834
|
if (nextHeight === lastGridHeightRef.current && nextWidth === lastGridWidthRef.current)
|
|
1480
835
|
return;
|
|
1481
|
-
raiseGridDimensionChanged(
|
|
836
|
+
(0, import_ui_grid_core2.raiseGridDimensionChanged)(
|
|
1482
837
|
gridApi,
|
|
1483
838
|
lastGridHeightRef.current,
|
|
1484
839
|
lastGridWidthRef.current,
|
|
@@ -1503,7 +858,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1503
858
|
const paginationTotalPages = getTotalPagesValueFn();
|
|
1504
859
|
const paginationSelectedPageSize = effectivePageSizeFn(pipeline.totalItems);
|
|
1505
860
|
const viewportHeightPx = computeViewportHeightPx(options.viewportHeight, autoViewportHeight);
|
|
1506
|
-
const headerLabelFn = (0, import_react.useCallback)((column) => (0,
|
|
861
|
+
const headerLabelFn = (0, import_react.useCallback)((column) => (0, import_ui_grid_core2.headerLabel)(column), []);
|
|
1507
862
|
const isGroupItemFn = (0, import_react.useCallback)(
|
|
1508
863
|
(item) => item.kind === "group",
|
|
1509
864
|
[]
|
|
@@ -1518,24 +873,24 @@ function useGridState(options, onRegisterApi) {
|
|
|
1518
873
|
[]
|
|
1519
874
|
);
|
|
1520
875
|
const sortDirectionFn = (0, import_react.useCallback)((column) => {
|
|
1521
|
-
return sortStateRef.current.columnName === column.name ? sortStateRef.current.direction :
|
|
876
|
+
return sortStateRef.current.columnName === column.name ? sortStateRef.current.direction : import_ui_grid_core2.SORT_DIRECTIONS.none;
|
|
1522
877
|
}, []);
|
|
1523
878
|
const sortButtonLabelFn = (0, import_react.useCallback)(
|
|
1524
879
|
(column) => {
|
|
1525
|
-
return (0,
|
|
880
|
+
return (0, import_ui_grid_core2.gridSortButtonLabel)(sortDirectionFn(column), labels);
|
|
1526
881
|
},
|
|
1527
882
|
[labels, sortDirectionFn]
|
|
1528
883
|
);
|
|
1529
884
|
const sortAriaSortFn = (0, import_react.useCallback)(
|
|
1530
885
|
(column) => {
|
|
1531
|
-
return (0,
|
|
886
|
+
return (0, import_ui_grid_core2.gridSortAriaSort)(sortDirectionFn(column));
|
|
1532
887
|
},
|
|
1533
888
|
[sortDirectionFn]
|
|
1534
889
|
);
|
|
1535
890
|
const groupingButtonLabelFn = (0, import_react.useCallback)(
|
|
1536
891
|
(column) => {
|
|
1537
|
-
return (0,
|
|
1538
|
-
(0,
|
|
892
|
+
return (0, import_ui_grid_core2.gridGroupingButtonLabel)(
|
|
893
|
+
(0, import_ui_grid_core2.isGridColumnGrouped)(groupByColumnsRef.current, column),
|
|
1539
894
|
labels
|
|
1540
895
|
);
|
|
1541
896
|
},
|
|
@@ -1546,39 +901,39 @@ function useGridState(options, onRegisterApi) {
|
|
|
1546
901
|
}, []);
|
|
1547
902
|
const filterPlaceholderFn = (0, import_react.useCallback)(
|
|
1548
903
|
(column) => {
|
|
1549
|
-
return (0,
|
|
904
|
+
return (0, import_ui_grid_core2.gridFilterPlaceholder)((0, import_ui_grid_core2.isGridColumnFilterable)(optionsRef.current, column), labels);
|
|
1550
905
|
},
|
|
1551
906
|
[labels]
|
|
1552
907
|
);
|
|
1553
908
|
const isFilterInputDisabledFn = (0, import_react.useCallback)((column) => {
|
|
1554
|
-
return !(0,
|
|
909
|
+
return !(0, import_ui_grid_core2.isGridColumnFilterable)(optionsRef.current, column);
|
|
1555
910
|
}, []);
|
|
1556
911
|
const groupDisclosureLabelFn = (0, import_react.useCallback)(
|
|
1557
912
|
(item) => {
|
|
1558
|
-
return (0,
|
|
913
|
+
return (0, import_ui_grid_core2.gridGroupDisclosureLabel)(item.collapsed, labels);
|
|
1559
914
|
},
|
|
1560
915
|
[labels]
|
|
1561
916
|
);
|
|
1562
917
|
const cellContextFn = (0, import_react.useCallback)(
|
|
1563
918
|
(row, column) => {
|
|
1564
|
-
return (0,
|
|
919
|
+
return (0, import_ui_grid_core2.buildGridCellContext)(row, column);
|
|
1565
920
|
},
|
|
1566
921
|
[]
|
|
1567
922
|
);
|
|
1568
923
|
const displayValueFn = (0, import_react.useCallback)(
|
|
1569
924
|
(row, column) => {
|
|
1570
|
-
return (0,
|
|
925
|
+
return (0, import_ui_grid_core2.formatGridCellDisplayValue)(cellContextFn(row, column));
|
|
1571
926
|
},
|
|
1572
927
|
[cellContextFn]
|
|
1573
928
|
);
|
|
1574
929
|
const isFocusedCellFn = (0, import_react.useCallback)((row, column) => {
|
|
1575
|
-
return (0,
|
|
930
|
+
return (0, import_ui_grid_core2.isGridCellPosition)(focusedCellRef.current, row.id, column.name);
|
|
1576
931
|
}, []);
|
|
1577
932
|
const isEditingCellFn = (0, import_react.useCallback)((row, column) => {
|
|
1578
|
-
return (0,
|
|
933
|
+
return (0, import_ui_grid_core2.isGridCellPosition)(editingCellRef.current, row.id, column.name);
|
|
1579
934
|
}, []);
|
|
1580
935
|
const editorInputTypeFn = (0, import_react.useCallback)((column) => {
|
|
1581
|
-
return (0,
|
|
936
|
+
return (0, import_ui_grid_core2.gridEditorInputType)(column);
|
|
1582
937
|
}, []);
|
|
1583
938
|
const expandedContextFn = (0, import_react.useCallback)(
|
|
1584
939
|
(row) => {
|
|
@@ -1592,42 +947,42 @@ function useGridState(options, onRegisterApi) {
|
|
|
1592
947
|
},
|
|
1593
948
|
[]
|
|
1594
949
|
);
|
|
1595
|
-
const columnWidthFn = (0, import_react.useCallback)((column) => (0,
|
|
950
|
+
const columnWidthFn = (0, import_react.useCallback)((column) => (0, import_ui_grid_core2.gridColumnWidth)(column), []);
|
|
1596
951
|
const isColumnSortableFn = (0, import_react.useCallback)((column) => {
|
|
1597
|
-
return (0,
|
|
952
|
+
return (0, import_ui_grid_core2.isGridColumnSortable)(optionsRef.current, column);
|
|
1598
953
|
}, []);
|
|
1599
954
|
const isColumnFilterableFn = (0, import_react.useCallback)((column) => {
|
|
1600
|
-
return (0,
|
|
955
|
+
return (0, import_ui_grid_core2.isGridColumnFilterable)(optionsRef.current, column);
|
|
1601
956
|
}, []);
|
|
1602
957
|
const cellIndentFn = (0, import_react.useCallback)((row, column) => {
|
|
1603
|
-
return (0,
|
|
958
|
+
return (0, import_ui_grid_core2.gridCellIndent)(optionsRef.current, visibleColumnsRef.current, row, column);
|
|
1604
959
|
}, []);
|
|
1605
960
|
const treeToggleLabelFn = (0, import_react.useCallback)(
|
|
1606
961
|
(row) => {
|
|
1607
|
-
return (0,
|
|
962
|
+
return (0, import_ui_grid_core2.gridTreeToggleLabelForRow)(expandedTreeRowsRef.current, row, labels);
|
|
1608
963
|
},
|
|
1609
964
|
[labels]
|
|
1610
965
|
);
|
|
1611
966
|
const isTreeRowExpandedFn = (0, import_react.useCallback)((row) => {
|
|
1612
|
-
return (0,
|
|
967
|
+
return (0, import_ui_grid_core2.isGridTreeRowExpanded)(expandedTreeRowsRef.current, row);
|
|
1613
968
|
}, []);
|
|
1614
969
|
const expandToggleLabelFn = (0, import_react.useCallback)(
|
|
1615
970
|
(row) => {
|
|
1616
|
-
return (0,
|
|
971
|
+
return (0, import_ui_grid_core2.gridExpandToggleLabelForRow)(row, labels);
|
|
1617
972
|
},
|
|
1618
973
|
[labels]
|
|
1619
974
|
);
|
|
1620
975
|
const isGroupedFn = (0, import_react.useCallback)((column) => {
|
|
1621
|
-
return (0,
|
|
976
|
+
return (0, import_ui_grid_core2.isGridColumnGrouped)(groupByColumnsRef.current, column);
|
|
1622
977
|
}, []);
|
|
1623
978
|
const showTreeToggleFn = (0, import_react.useCallback)((row, column) => {
|
|
1624
|
-
return (0,
|
|
979
|
+
return (0, import_ui_grid_core2.shouldShowGridTreeToggle)(optionsRef.current, visibleColumnsRef.current, row, column);
|
|
1625
980
|
}, []);
|
|
1626
981
|
const showExpandToggleFn = (0, import_react.useCallback)((row, column) => {
|
|
1627
|
-
return (0,
|
|
982
|
+
return (0, import_ui_grid_core2.shouldShowGridExpandToggle)(optionsRef.current, visibleColumnsRef.current, column);
|
|
1628
983
|
}, []);
|
|
1629
984
|
const showPaginationControlsFn = (0, import_react.useCallback)(() => {
|
|
1630
|
-
return
|
|
985
|
+
return import_ui_grid_core2.FEATURE_PAGINATION && (0, import_ui_grid_core2.shouldShowGridPaginationControls)(optionsRef.current);
|
|
1631
986
|
}, []);
|
|
1632
987
|
const paginationSummaryFn = (0, import_react.useCallback)(() => {
|
|
1633
988
|
const ti = pipelineRef.current.totalItems;
|
|
@@ -1637,22 +992,22 @@ function useGridState(options, onRegisterApi) {
|
|
|
1637
992
|
return optionsRef.current.paginationPageSizes ?? [];
|
|
1638
993
|
}, []);
|
|
1639
994
|
const isGroupingEnabledFn = (0, import_react.useCallback)(() => {
|
|
1640
|
-
return
|
|
995
|
+
return import_ui_grid_core2.FEATURE_GROUPING && (0, import_ui_grid_core2.isGridGroupingEnabled)(optionsRef.current);
|
|
1641
996
|
}, []);
|
|
1642
997
|
const isFilteringEnabledFn = (0, import_react.useCallback)(() => {
|
|
1643
|
-
return
|
|
998
|
+
return import_ui_grid_core2.FEATURE_FILTERING && (0, import_ui_grid_core2.isGridFilteringEnabled)(optionsRef.current);
|
|
1644
999
|
}, []);
|
|
1645
1000
|
const toggleSortFn = (0, import_react.useCallback)((column) => {
|
|
1646
|
-
if (!
|
|
1647
|
-
const currentDirection = sortStateRef.current.columnName === column.name ? sortStateRef.current.direction :
|
|
1648
|
-
const nextDirection = currentDirection ===
|
|
1649
|
-
applyGridSortStateCommand(gridApiRef.current, (state) => setSortState(state), {
|
|
1650
|
-
columnName: nextDirection ===
|
|
1001
|
+
if (!import_ui_grid_core2.FEATURE_SORTING || !(0, import_ui_grid_core2.isGridColumnSortable)(optionsRef.current, column)) return;
|
|
1002
|
+
const currentDirection = sortStateRef.current.columnName === column.name ? sortStateRef.current.direction : import_ui_grid_core2.SORT_DIRECTIONS.none;
|
|
1003
|
+
const nextDirection = currentDirection === import_ui_grid_core2.SORT_DIRECTIONS.none ? import_ui_grid_core2.SORT_DIRECTIONS.asc : currentDirection === import_ui_grid_core2.SORT_DIRECTIONS.asc ? import_ui_grid_core2.SORT_DIRECTIONS.desc : import_ui_grid_core2.SORT_DIRECTIONS.none;
|
|
1004
|
+
(0, import_ui_grid_core2.applyGridSortStateCommand)(gridApiRef.current, (state) => setSortState(state), {
|
|
1005
|
+
columnName: nextDirection === import_ui_grid_core2.SORT_DIRECTIONS.none ? null : column.name,
|
|
1651
1006
|
direction: nextDirection
|
|
1652
1007
|
});
|
|
1653
1008
|
}, []);
|
|
1654
1009
|
const updateFilterFn = (0, import_react.useCallback)((columnName, value) => {
|
|
1655
|
-
updateGridFilterCommand(
|
|
1010
|
+
(0, import_ui_grid_core2.updateGridFilterCommand)(
|
|
1656
1011
|
gridApiRef.current,
|
|
1657
1012
|
(updater) => setActiveFilters((current) => updater(current)),
|
|
1658
1013
|
() => activeFiltersRef.current,
|
|
@@ -1661,11 +1016,11 @@ function useGridState(options, onRegisterApi) {
|
|
|
1661
1016
|
);
|
|
1662
1017
|
}, []);
|
|
1663
1018
|
const clearAllFiltersFn = (0, import_react.useCallback)(() => {
|
|
1664
|
-
clearGridFiltersCommand(gridApiRef.current, (filters) => setActiveFilters(filters));
|
|
1019
|
+
(0, import_ui_grid_core2.clearGridFiltersCommand)(gridApiRef.current, (filters) => setActiveFilters(filters));
|
|
1665
1020
|
}, []);
|
|
1666
1021
|
const toggleGroupingFn = (0, import_react.useCallback)((column, event) => {
|
|
1667
1022
|
event?.stopPropagation();
|
|
1668
|
-
if (!(
|
|
1023
|
+
if (!(import_ui_grid_core2.FEATURE_GROUPING && (0, import_ui_grid_core2.isGridGroupingEnabled)(optionsRef.current))) return;
|
|
1669
1024
|
const current = groupByColumnsRef.current;
|
|
1670
1025
|
const next = current.includes(column.name) ? current.filter((n) => n !== column.name) : [...current, column.name];
|
|
1671
1026
|
groupByColumnsRef.current = next;
|
|
@@ -1680,7 +1035,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1680
1035
|
}, []);
|
|
1681
1036
|
const focusCellFn = (0, import_react.useCallback)(
|
|
1682
1037
|
(row, column, triggerEvent) => {
|
|
1683
|
-
const nextFocusResult = (0,
|
|
1038
|
+
const nextFocusResult = (0, import_ui_grid_core2.buildGridFocusCellResult)({
|
|
1684
1039
|
currentFocusedCell: focusedCellRef.current,
|
|
1685
1040
|
currentEditingCell: editingCellRef.current,
|
|
1686
1041
|
rowId: row.id,
|
|
@@ -1739,7 +1094,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1739
1094
|
default:
|
|
1740
1095
|
break;
|
|
1741
1096
|
}
|
|
1742
|
-
if ((0,
|
|
1097
|
+
if ((0, import_ui_grid_core2.isPrintableGridKey)(event.key, event.ctrlKey, event.metaKey, event.altKey) && isCellEditable(row, column, event.nativeEvent)) {
|
|
1743
1098
|
event.preventDefault();
|
|
1744
1099
|
startCellEditFn(row, column, event.nativeEvent, event.key);
|
|
1745
1100
|
}
|
|
@@ -1803,14 +1158,25 @@ function useGridState(options, onRegisterApi) {
|
|
|
1803
1158
|
[toggleTreeRowByRefFn]
|
|
1804
1159
|
);
|
|
1805
1160
|
const moveColumnFn = (0, import_react.useCallback)((fromIndex, toIndex) => {
|
|
1806
|
-
moveGridColumnCommand(
|
|
1161
|
+
(0, import_ui_grid_core2.moveGridColumnCommand)(
|
|
1807
1162
|
gridApiRef.current,
|
|
1808
|
-
|
|
1163
|
+
import_ui_grid_core2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
1809
1164
|
(updater) => setColumnOrder((current) => updater(current)),
|
|
1810
1165
|
fromIndex,
|
|
1811
1166
|
toIndex
|
|
1812
1167
|
);
|
|
1813
1168
|
}, []);
|
|
1169
|
+
const moveVisibleColumnFn = (0, import_react.useCallback)((columnName, targetColumnName) => {
|
|
1170
|
+
(0, import_ui_grid_core2.moveGridVisibleColumnCommand)(
|
|
1171
|
+
gridApiRef.current,
|
|
1172
|
+
import_ui_grid_core2.FEATURE_COLUMN_MOVING && optionsRef.current.enableColumnMoving === true,
|
|
1173
|
+
columnOrderRef.current,
|
|
1174
|
+
visibleColumnsRef.current.map((column) => column.name),
|
|
1175
|
+
columnName,
|
|
1176
|
+
targetColumnName,
|
|
1177
|
+
(order) => setColumnOrder(order)
|
|
1178
|
+
);
|
|
1179
|
+
}, []);
|
|
1814
1180
|
const nextPageFn = (0, import_react.useCallback)(() => {
|
|
1815
1181
|
seekPageFn(getCurrentPageValueFn() + 1);
|
|
1816
1182
|
}, [seekPageFn, getCurrentPageValueFn]);
|
|
@@ -1826,17 +1192,17 @@ function useGridState(options, onRegisterApi) {
|
|
|
1826
1192
|
const onViewportScrollFn = (0, import_react.useCallback)((startIndex) => {
|
|
1827
1193
|
if (!scrollingRef.current) {
|
|
1828
1194
|
scrollingRef.current = true;
|
|
1829
|
-
raiseGridScrollBegin(gridApiRef.current);
|
|
1195
|
+
(0, import_ui_grid_core2.raiseGridScrollBegin)(gridApiRef.current);
|
|
1830
1196
|
}
|
|
1831
1197
|
if (scrollEndHandleRef.current) {
|
|
1832
1198
|
window.clearTimeout(scrollEndHandleRef.current);
|
|
1833
1199
|
}
|
|
1834
1200
|
scrollEndHandleRef.current = window.setTimeout(() => {
|
|
1835
1201
|
scrollingRef.current = false;
|
|
1836
|
-
raiseGridScrollEnd(gridApiRef.current);
|
|
1202
|
+
(0, import_ui_grid_core2.raiseGridScrollEnd)(gridApiRef.current);
|
|
1837
1203
|
}, 120);
|
|
1838
|
-
const isInfiniteScrollEnabled =
|
|
1839
|
-
maybeRequestInfiniteScrollCommand(gridApiRef.current, {
|
|
1204
|
+
const isInfiniteScrollEnabled = import_ui_grid_core2.FEATURE_INFINITE_SCROLL && (optionsRef.current.infiniteScrollRowsFromEnd !== void 0 || optionsRef.current.infiniteScrollUp === true || optionsRef.current.infiniteScrollDown !== void 0);
|
|
1205
|
+
(0, import_ui_grid_core2.maybeRequestInfiniteScrollCommand)(gridApiRef.current, {
|
|
1840
1206
|
enabled: isInfiniteScrollEnabled,
|
|
1841
1207
|
virtualizationEnabled: pipelineRef.current.virtualizationEnabled,
|
|
1842
1208
|
state: infiniteScrollStateRef.current,
|
|
@@ -1914,16 +1280,16 @@ function useGridState(options, onRegisterApi) {
|
|
|
1914
1280
|
pageSizeOptions: pageSizeOptionsFn,
|
|
1915
1281
|
isCellEditable,
|
|
1916
1282
|
shouldEditOnFocus: shouldEditOnFocusFn,
|
|
1917
|
-
sortingFeature:
|
|
1918
|
-
filteringFeature:
|
|
1919
|
-
groupingFeature:
|
|
1920
|
-
paginationFeature:
|
|
1921
|
-
cellEditFeature:
|
|
1922
|
-
expandableFeature:
|
|
1923
|
-
treeViewFeature:
|
|
1924
|
-
infiniteScrollFeature:
|
|
1925
|
-
columnMovingFeature:
|
|
1926
|
-
csvExportFeature:
|
|
1283
|
+
sortingFeature: import_ui_grid_core2.FEATURE_SORTING,
|
|
1284
|
+
filteringFeature: import_ui_grid_core2.FEATURE_FILTERING,
|
|
1285
|
+
groupingFeature: import_ui_grid_core2.FEATURE_GROUPING,
|
|
1286
|
+
paginationFeature: import_ui_grid_core2.FEATURE_PAGINATION,
|
|
1287
|
+
cellEditFeature: import_ui_grid_core2.FEATURE_CELL_EDIT,
|
|
1288
|
+
expandableFeature: import_ui_grid_core2.FEATURE_EXPANDABLE,
|
|
1289
|
+
treeViewFeature: import_ui_grid_core2.FEATURE_TREE_VIEW,
|
|
1290
|
+
infiniteScrollFeature: import_ui_grid_core2.FEATURE_INFINITE_SCROLL,
|
|
1291
|
+
columnMovingFeature: import_ui_grid_core2.FEATURE_COLUMN_MOVING,
|
|
1292
|
+
csvExportFeature: import_ui_grid_core2.FEATURE_CSV_EXPORT,
|
|
1927
1293
|
isGroupingEnabled: isGroupingEnabledFn,
|
|
1928
1294
|
isFilteringEnabled: isFilteringEnabledFn,
|
|
1929
1295
|
toggleSort: toggleSortFn,
|
|
@@ -1940,6 +1306,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1940
1306
|
toggleRowExpansion: toggleRowExpansionFn,
|
|
1941
1307
|
toggleTreeRow: toggleTreeRowFn,
|
|
1942
1308
|
moveColumn: moveColumnFn,
|
|
1309
|
+
moveVisibleColumn: moveVisibleColumnFn,
|
|
1943
1310
|
nextPage: nextPageFn,
|
|
1944
1311
|
previousPage: previousPageFn,
|
|
1945
1312
|
onPageSizeChange: onPageSizeChangeFn,
|
|
@@ -1952,7 +1319,7 @@ function useGridState(options, onRegisterApi) {
|
|
|
1952
1319
|
isPinningEnabled: isPinningEnabledFn,
|
|
1953
1320
|
isColumnPinnable: isColumnPinnableFn,
|
|
1954
1321
|
togglePin: togglePinFn,
|
|
1955
|
-
pinningFeature:
|
|
1322
|
+
pinningFeature: import_ui_grid_core2.FEATURE_PINNING
|
|
1956
1323
|
};
|
|
1957
1324
|
}
|
|
1958
1325
|
|
|
@@ -2000,6 +1367,7 @@ function useVirtualScroll(options) {
|
|
|
2000
1367
|
totalHeight: virtualWindow.totalHeight,
|
|
2001
1368
|
offsetY: virtualWindow.offsetY,
|
|
2002
1369
|
onScroll,
|
|
1370
|
+
setScrollTop,
|
|
2003
1371
|
viewportRef,
|
|
2004
1372
|
scrollTop
|
|
2005
1373
|
};
|
|
@@ -2038,20 +1406,161 @@ function UiGrid({
|
|
|
2038
1406
|
expandableFeature,
|
|
2039
1407
|
treeViewFeature,
|
|
2040
1408
|
csvExportFeature,
|
|
1409
|
+
columnMovingFeature,
|
|
2041
1410
|
paginationCurrentPage,
|
|
2042
1411
|
paginationTotalPages,
|
|
2043
1412
|
paginationSelectedPageSize
|
|
2044
1413
|
} = state;
|
|
1414
|
+
const headerGridRef = import_react3.default.useRef(null);
|
|
1415
|
+
const filterGridRef = import_react3.default.useRef(null);
|
|
1416
|
+
const [headerStickyHeight, setHeaderStickyHeight] = import_react3.default.useState(0);
|
|
1417
|
+
const [filterStickyHeight, setFilterStickyHeight] = import_react3.default.useState(0);
|
|
1418
|
+
const stickyChromeHeight = headerStickyHeight + filterStickyHeight;
|
|
1419
|
+
const bodyViewportHeight = Math.max(
|
|
1420
|
+
rowSize,
|
|
1421
|
+
(options.viewportHeight ?? 560) - stickyChromeHeight
|
|
1422
|
+
);
|
|
2045
1423
|
const virtualScroll = useVirtualScroll({
|
|
2046
1424
|
itemCount: displayItems.length,
|
|
2047
1425
|
itemSize: rowSize,
|
|
2048
|
-
viewportHeight:
|
|
1426
|
+
viewportHeight: bodyViewportHeight,
|
|
2049
1427
|
overscan: 3
|
|
2050
1428
|
});
|
|
1429
|
+
const [openPinMenuColumn, setOpenPinMenuColumn] = import_react3.default.useState(null);
|
|
1430
|
+
const [draggedColumnName, setDraggedColumnName] = import_react3.default.useState(null);
|
|
1431
|
+
const [dropTargetColumnName, setDropTargetColumnName] = import_react3.default.useState(null);
|
|
1432
|
+
const scrollContainerHeight = `${options.viewportHeight ?? 560}px`;
|
|
1433
|
+
const eventPathIncludesClass = import_react3.default.useCallback((event, className2) => {
|
|
1434
|
+
const eventPath = typeof event.composedPath === "function" ? event.composedPath() : event.target ? [event.target] : [];
|
|
1435
|
+
return eventPath.some((target) => {
|
|
1436
|
+
if (!target || typeof target !== "object" || !("classList" in target)) {
|
|
1437
|
+
return false;
|
|
1438
|
+
}
|
|
1439
|
+
const classList = target.classList;
|
|
1440
|
+
return classList?.contains(className2) ?? false;
|
|
1441
|
+
});
|
|
1442
|
+
}, []);
|
|
1443
|
+
const isPinMenuOpen = import_react3.default.useCallback(
|
|
1444
|
+
(column) => openPinMenuColumn === column.name,
|
|
1445
|
+
[openPinMenuColumn]
|
|
1446
|
+
);
|
|
1447
|
+
const pinButtonLabel = import_react3.default.useCallback(
|
|
1448
|
+
(column) => state.isPinned(column) ? labels.unpin : labels.pinColumn,
|
|
1449
|
+
[labels, state]
|
|
1450
|
+
);
|
|
1451
|
+
const onPinTrigger = import_react3.default.useCallback(
|
|
1452
|
+
(column, event) => {
|
|
1453
|
+
event?.stopPropagation();
|
|
1454
|
+
if (state.isPinned(column)) {
|
|
1455
|
+
setOpenPinMenuColumn(null);
|
|
1456
|
+
state.gridApi.pinning.pinColumn(column.name, "none");
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
setOpenPinMenuColumn((current) => current === column.name ? null : column.name);
|
|
1460
|
+
},
|
|
1461
|
+
[state]
|
|
1462
|
+
);
|
|
1463
|
+
const choosePinDirection = import_react3.default.useCallback(
|
|
1464
|
+
(column, direction, event) => {
|
|
1465
|
+
event?.stopPropagation();
|
|
1466
|
+
setOpenPinMenuColumn(null);
|
|
1467
|
+
state.gridApi.pinning.pinColumn(column.name, direction);
|
|
1468
|
+
},
|
|
1469
|
+
[state]
|
|
1470
|
+
);
|
|
1471
|
+
const handleHeaderDragStart = import_react3.default.useCallback(
|
|
1472
|
+
(column, event) => {
|
|
1473
|
+
if (!columnMovingFeature) {
|
|
1474
|
+
event.preventDefault();
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
setDraggedColumnName(column.name);
|
|
1478
|
+
setDropTargetColumnName(null);
|
|
1479
|
+
event.dataTransfer.effectAllowed = "move";
|
|
1480
|
+
event.dataTransfer.setData("text/plain", column.name);
|
|
1481
|
+
},
|
|
1482
|
+
[columnMovingFeature]
|
|
1483
|
+
);
|
|
1484
|
+
const handleHeaderDragOver = import_react3.default.useCallback(
|
|
1485
|
+
(column, event) => {
|
|
1486
|
+
if (!columnMovingFeature || !draggedColumnName || draggedColumnName === column.name) {
|
|
1487
|
+
return;
|
|
1488
|
+
}
|
|
1489
|
+
event.preventDefault();
|
|
1490
|
+
event.dataTransfer.dropEffect = "move";
|
|
1491
|
+
setDropTargetColumnName(column.name);
|
|
1492
|
+
},
|
|
1493
|
+
[columnMovingFeature, draggedColumnName]
|
|
1494
|
+
);
|
|
1495
|
+
const handleHeaderDrop = import_react3.default.useCallback(
|
|
1496
|
+
(column, event) => {
|
|
1497
|
+
event.preventDefault();
|
|
1498
|
+
if (!columnMovingFeature) {
|
|
1499
|
+
return;
|
|
1500
|
+
}
|
|
1501
|
+
const sourceColumnName = draggedColumnName ?? event.dataTransfer.getData("text/plain");
|
|
1502
|
+
setDraggedColumnName(null);
|
|
1503
|
+
setDropTargetColumnName(null);
|
|
1504
|
+
if (!sourceColumnName || sourceColumnName === column.name) {
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
state.moveVisibleColumn(sourceColumnName, column.name);
|
|
1508
|
+
},
|
|
1509
|
+
[columnMovingFeature, draggedColumnName, state]
|
|
1510
|
+
);
|
|
1511
|
+
const handleHeaderDragEnd = import_react3.default.useCallback(() => {
|
|
1512
|
+
setDraggedColumnName(null);
|
|
1513
|
+
setDropTargetColumnName(null);
|
|
1514
|
+
}, []);
|
|
1515
|
+
import_react3.default.useLayoutEffect(() => {
|
|
1516
|
+
setHeaderStickyHeight(headerGridRef.current?.offsetHeight ?? 0);
|
|
1517
|
+
setFilterStickyHeight(filterGridRef.current?.offsetHeight ?? 0);
|
|
1518
|
+
}, [visibleColumns, filteringFeature, options.enableFiltering]);
|
|
1519
|
+
import_react3.default.useLayoutEffect(() => {
|
|
1520
|
+
const headerElement = headerGridRef.current;
|
|
1521
|
+
const filterElement = filterGridRef.current;
|
|
1522
|
+
if (typeof ResizeObserver === "undefined" || !headerElement && !filterElement) {
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
const observer = new ResizeObserver(() => {
|
|
1526
|
+
setHeaderStickyHeight(headerGridRef.current?.offsetHeight ?? 0);
|
|
1527
|
+
setFilterStickyHeight(filterGridRef.current?.offsetHeight ?? 0);
|
|
1528
|
+
});
|
|
1529
|
+
if (headerElement) {
|
|
1530
|
+
observer.observe(headerElement);
|
|
1531
|
+
}
|
|
1532
|
+
if (filterElement) {
|
|
1533
|
+
observer.observe(filterElement);
|
|
1534
|
+
}
|
|
1535
|
+
return () => observer.disconnect();
|
|
1536
|
+
}, []);
|
|
1537
|
+
import_react3.default.useEffect(() => {
|
|
1538
|
+
if (!openPinMenuColumn) {
|
|
1539
|
+
return;
|
|
1540
|
+
}
|
|
1541
|
+
const handleDocumentClick = (event) => {
|
|
1542
|
+
if (eventPathIncludesClass(event, "pin-control")) {
|
|
1543
|
+
return;
|
|
1544
|
+
}
|
|
1545
|
+
setOpenPinMenuColumn(null);
|
|
1546
|
+
};
|
|
1547
|
+
const handleDocumentEscape = (event) => {
|
|
1548
|
+
if (event.key === "Escape") {
|
|
1549
|
+
setOpenPinMenuColumn(null);
|
|
1550
|
+
}
|
|
1551
|
+
};
|
|
1552
|
+
document.addEventListener("click", handleDocumentClick);
|
|
1553
|
+
document.addEventListener("keydown", handleDocumentEscape);
|
|
1554
|
+
return () => {
|
|
1555
|
+
document.removeEventListener("click", handleDocumentClick);
|
|
1556
|
+
document.removeEventListener("keydown", handleDocumentEscape);
|
|
1557
|
+
};
|
|
1558
|
+
}, [eventPathIncludesClass, openPinMenuColumn]);
|
|
2051
1559
|
const itemsToRender = virtualizationEnabled ? displayItems.slice(virtualScroll.visibleRange.start, virtualScroll.visibleRange.end) : displayItems;
|
|
2052
|
-
const
|
|
2053
|
-
|
|
2054
|
-
|
|
1560
|
+
const onGridTableScroll = (event) => {
|
|
1561
|
+
const bodyScrollTop = Math.max(0, event.currentTarget.scrollTop - stickyChromeHeight);
|
|
1562
|
+
virtualScroll.setScrollTop(bodyScrollTop);
|
|
1563
|
+
const startIndex = Math.floor(bodyScrollTop / rowSize);
|
|
2055
1564
|
state.onViewportScroll(startIndex);
|
|
2056
1565
|
};
|
|
2057
1566
|
function renderDisplayItem(item) {
|
|
@@ -2145,12 +1654,21 @@ function UiGrid({
|
|
|
2145
1654
|
"aria-label": state.treeToggleLabel(rowItem.row),
|
|
2146
1655
|
"aria-expanded": state.isTreeRowExpanded(rowItem.row),
|
|
2147
1656
|
onClick: (e) => state.toggleTreeRow(rowItem.row, e),
|
|
2148
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2149
|
-
"
|
|
1657
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1658
|
+
"svg",
|
|
2150
1659
|
{
|
|
2151
|
-
|
|
1660
|
+
className: "toggle-icon",
|
|
1661
|
+
viewBox: "0 0 24 24",
|
|
1662
|
+
"aria-hidden": "true",
|
|
1663
|
+
focusable: false,
|
|
1664
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1665
|
+
"path",
|
|
1666
|
+
{
|
|
1667
|
+
d: state.isTreeRowExpanded(rowItem.row) ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z"
|
|
1668
|
+
}
|
|
1669
|
+
)
|
|
2152
1670
|
}
|
|
2153
|
-
)
|
|
1671
|
+
)
|
|
2154
1672
|
}
|
|
2155
1673
|
),
|
|
2156
1674
|
expandableFeature && state.showExpandToggle(rowItem.row, column) && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -2162,7 +1680,16 @@ function UiGrid({
|
|
|
2162
1680
|
"aria-label": state.expandToggleLabel(rowItem.row),
|
|
2163
1681
|
"aria-expanded": rowItem.row.expanded,
|
|
2164
1682
|
onClick: (e) => state.toggleRowExpansion(rowItem.row, e),
|
|
2165
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1683
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1684
|
+
"svg",
|
|
1685
|
+
{
|
|
1686
|
+
className: "toggle-icon",
|
|
1687
|
+
viewBox: "0 0 24 24",
|
|
1688
|
+
"aria-hidden": "true",
|
|
1689
|
+
focusable: false,
|
|
1690
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: rowItem.row.expanded ? "M7 10l5 5 5-5z" : "M10 7l5 5-5 5z" })
|
|
1691
|
+
}
|
|
1692
|
+
)
|
|
2166
1693
|
}
|
|
2167
1694
|
),
|
|
2168
1695
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "cell-value", children: cellEditFeature && state.isEditingCell(rowItem.row, column) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -2291,262 +1818,368 @@ function UiGrid({
|
|
|
2291
1818
|
] }),
|
|
2292
1819
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: "`gridOptions` compatibility layer: sorting, filtering, grouping, column moving, templating, and virtualized rendering." })
|
|
2293
1820
|
] }),
|
|
2294
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2295
|
-
|
|
2296
|
-
|
|
2297
|
-
|
|
2298
|
-
|
|
2299
|
-
|
|
2300
|
-
|
|
2301
|
-
|
|
2302
|
-
|
|
2303
|
-
|
|
2304
|
-
|
|
2305
|
-
|
|
2306
|
-
"
|
|
2307
|
-
|
|
2308
|
-
|
|
2309
|
-
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2313
|
-
|
|
2314
|
-
|
|
2315
|
-
|
|
2316
|
-
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
onClick: () => state.toggleSort(column),
|
|
2330
|
-
children: [
|
|
2331
|
-
renderSortIcon(column),
|
|
2332
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.sortButtonLabel(column) })
|
|
2333
|
-
]
|
|
2334
|
-
}
|
|
2335
|
-
),
|
|
2336
|
-
groupingFeature && state.isGroupingEnabled() && column.enableGrouping !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2337
|
-
"button",
|
|
2338
|
-
{
|
|
2339
|
-
type: "button",
|
|
2340
|
-
className: `chip-action${state.isGrouped(column) ? " chip-action-active" : ""}`,
|
|
2341
|
-
"data-part": "group-toggle",
|
|
2342
|
-
"aria-label": state.groupingButtonLabel(column),
|
|
2343
|
-
title: state.groupingButtonLabel(column),
|
|
2344
|
-
onClick: (e) => state.toggleGrouping(column, e),
|
|
2345
|
-
children: [
|
|
2346
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 6h8v4H4V6Zm0 8h8v4H4v-4Zm10-8h6v4h-6V6Zm0 8h6v4h-6v-4Z" }) }),
|
|
2347
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.groupingButtonLabel(column) })
|
|
2348
|
-
]
|
|
2349
|
-
}
|
|
2350
|
-
),
|
|
2351
|
-
state.pinningFeature && state.isPinningEnabled() && state.isColumnPinnable(column) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2352
|
-
"button",
|
|
2353
|
-
{
|
|
2354
|
-
type: "button",
|
|
2355
|
-
className: `chip-action${pinned ? " chip-action-active" : ""}`,
|
|
2356
|
-
"data-part": "pin-toggle",
|
|
2357
|
-
"aria-label": pinned ? labels.unpin : labels.pinLeft,
|
|
2358
|
-
title: pinned ? labels.unpin : labels.pinLeft,
|
|
2359
|
-
onClick: () => state.togglePin(column),
|
|
2360
|
-
children: [
|
|
2361
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 12V4h1V2H7v2h1v8l-2 2v2h5v6l1 1 1-1v-6h5v-2l-2-2z" }) }),
|
|
2362
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: pinned ? labels.unpin : labels.pinLeft })
|
|
2363
|
-
]
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1822
|
+
"div",
|
|
1823
|
+
{
|
|
1824
|
+
className: "grid-table ui-grid-contents-wrapper",
|
|
1825
|
+
"data-part": "grid-table",
|
|
1826
|
+
style: virtualizationEnabled ? { height: scrollContainerHeight, overflowY: "auto" } : void 0,
|
|
1827
|
+
onScroll: virtualizationEnabled ? onGridTableScroll : void 0,
|
|
1828
|
+
children: [
|
|
1829
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
1830
|
+
"div",
|
|
1831
|
+
{
|
|
1832
|
+
className: "header-grid ui-grid-header ui-grid-header-canvas",
|
|
1833
|
+
"data-part": "header",
|
|
1834
|
+
role: "row",
|
|
1835
|
+
ref: headerGridRef,
|
|
1836
|
+
style: { gridTemplateColumns },
|
|
1837
|
+
children: visibleColumns.map((column) => {
|
|
1838
|
+
const pinned = state.isPinned(column);
|
|
1839
|
+
const pinOffset = pinned ? state.pinnedOffset(column) : null;
|
|
1840
|
+
const pinMenuOpen = isPinMenuOpen(column);
|
|
1841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1842
|
+
"div",
|
|
1843
|
+
{
|
|
1844
|
+
className: `header-cell ui-grid-header-cell${sortingFeature && state.sortDirection(column) !== "none" ? " is-active" : ""}${pinned ? " is-pinned" : ""}${pinMenuOpen ? " is-pin-menu-open" : ""}${draggedColumnName === column.name ? " is-dragging" : ""}${dropTargetColumnName === column.name ? " is-drag-target" : ""}`,
|
|
1845
|
+
"data-part": "header-cell",
|
|
1846
|
+
role: "columnheader",
|
|
1847
|
+
"aria-sort": sortingFeature ? state.sortAriaSort(column) : void 0,
|
|
1848
|
+
draggable: columnMovingFeature,
|
|
1849
|
+
onDragStart: (event) => handleHeaderDragStart(column, event),
|
|
1850
|
+
onDragOver: (event) => handleHeaderDragOver(column, event),
|
|
1851
|
+
onDrop: (event) => handleHeaderDrop(column, event),
|
|
1852
|
+
onDragEnd: handleHeaderDragEnd,
|
|
1853
|
+
onDragLeave: () => {
|
|
1854
|
+
if (dropTargetColumnName === column.name) {
|
|
1855
|
+
setDropTargetColumnName(null);
|
|
2364
1856
|
}
|
|
2365
|
-
|
|
2366
|
-
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2371
|
-
|
|
2372
|
-
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2377
|
-
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
1857
|
+
},
|
|
1858
|
+
style: {
|
|
1859
|
+
position: pinned ? "sticky" : void 0,
|
|
1860
|
+
left: pinOffset?.side === "left" ? pinOffset.offset : void 0,
|
|
1861
|
+
right: pinOffset?.side === "right" ? pinOffset.offset : void 0,
|
|
1862
|
+
zIndex: pinMenuOpen ? 8 : pinned ? 2 : void 0
|
|
1863
|
+
},
|
|
1864
|
+
children: [
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "header-label", children: state.headerLabel(column) }),
|
|
1866
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "header-actions", children: [
|
|
1867
|
+
sortingFeature && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1868
|
+
"button",
|
|
1869
|
+
{
|
|
1870
|
+
type: "button",
|
|
1871
|
+
className: `header-action${!state.isColumnSortable(column) ? " header-action-disabled" : ""}`,
|
|
1872
|
+
disabled: !state.isColumnSortable(column),
|
|
1873
|
+
"aria-label": state.sortButtonLabel(column),
|
|
1874
|
+
title: state.sortButtonLabel(column),
|
|
1875
|
+
onClick: () => state.toggleSort(column),
|
|
1876
|
+
children: [
|
|
1877
|
+
renderSortIcon(column),
|
|
1878
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.sortButtonLabel(column) })
|
|
1879
|
+
]
|
|
1880
|
+
}
|
|
1881
|
+
),
|
|
1882
|
+
groupingFeature && state.isGroupingEnabled() && column.enableGrouping !== false && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1883
|
+
"button",
|
|
1884
|
+
{
|
|
1885
|
+
type: "button",
|
|
1886
|
+
className: `chip-action${state.isGrouped(column) ? " chip-action-active" : ""}`,
|
|
1887
|
+
"data-part": "group-toggle",
|
|
1888
|
+
"aria-label": state.groupingButtonLabel(column),
|
|
1889
|
+
title: state.groupingButtonLabel(column),
|
|
1890
|
+
onClick: (e) => state.toggleGrouping(column, e),
|
|
1891
|
+
children: [
|
|
1892
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M4 6h8v4H4V6Zm0 8h8v4H4v-4Zm10-8h6v4h-6V6Zm0 8h6v4h-6v-4Z" }) }),
|
|
1893
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: state.groupingButtonLabel(column) })
|
|
1894
|
+
]
|
|
1895
|
+
}
|
|
1896
|
+
),
|
|
1897
|
+
state.pinningFeature && state.isPinningEnabled() && state.isColumnPinnable(column) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1898
|
+
"div",
|
|
1899
|
+
{
|
|
1900
|
+
className: `pin-control${pinMenuOpen ? " pin-control-open" : ""}`,
|
|
1901
|
+
onClick: (event) => event.stopPropagation(),
|
|
1902
|
+
children: [
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1904
|
+
"button",
|
|
1905
|
+
{
|
|
1906
|
+
type: "button",
|
|
1907
|
+
className: `chip-action pin-trigger${pinned || pinMenuOpen ? " chip-action-active" : ""}`,
|
|
1908
|
+
"data-part": "pin-toggle",
|
|
1909
|
+
"aria-label": pinButtonLabel(column),
|
|
1910
|
+
title: pinButtonLabel(column),
|
|
1911
|
+
"aria-haspopup": pinned ? void 0 : "menu",
|
|
1912
|
+
"aria-expanded": pinned ? void 0 : pinMenuOpen,
|
|
1913
|
+
onClick: (event) => onPinTrigger(column, event),
|
|
1914
|
+
children: [
|
|
1915
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M16 12V4h1V2H7v2h1v8l-2 2v2h5v6l1 1 1-1v-6h5v-2l-2-2z" }) }),
|
|
1916
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: pinButtonLabel(column) })
|
|
1917
|
+
]
|
|
1918
|
+
}
|
|
1919
|
+
),
|
|
1920
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1921
|
+
"div",
|
|
1922
|
+
{
|
|
1923
|
+
className: "pin-menu",
|
|
1924
|
+
"data-part": "pin-menu",
|
|
1925
|
+
role: "menu",
|
|
1926
|
+
"aria-label": "Pin options",
|
|
1927
|
+
"aria-hidden": !pinMenuOpen,
|
|
1928
|
+
children: [
|
|
1929
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1930
|
+
"button",
|
|
1931
|
+
{
|
|
1932
|
+
type: "button",
|
|
1933
|
+
className: "pin-menu-action",
|
|
1934
|
+
"data-part": "pin-left-action",
|
|
1935
|
+
role: "menuitem",
|
|
1936
|
+
"aria-label": labels.pinLeft,
|
|
1937
|
+
title: labels.pinLeft,
|
|
1938
|
+
tabIndex: pinMenuOpen ? 0 : -1,
|
|
1939
|
+
onClick: (event) => choosePinDirection(column, "left", event),
|
|
1940
|
+
children: [
|
|
1941
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M10 6 4 12l6 6v-4h10v-4H10V6z" }) }),
|
|
1942
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: labels.pinLeft })
|
|
1943
|
+
]
|
|
1944
|
+
}
|
|
1945
|
+
),
|
|
1946
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1947
|
+
"button",
|
|
1948
|
+
{
|
|
1949
|
+
type: "button",
|
|
1950
|
+
className: "pin-menu-action",
|
|
1951
|
+
"data-part": "pin-right-action",
|
|
1952
|
+
role: "menuitem",
|
|
1953
|
+
"aria-label": labels.pinRight,
|
|
1954
|
+
title: labels.pinRight,
|
|
1955
|
+
tabIndex: pinMenuOpen ? 0 : -1,
|
|
1956
|
+
onClick: (event) => choosePinDirection(column, "right", event),
|
|
1957
|
+
children: [
|
|
1958
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { viewBox: "0 0 24 24", "aria-hidden": "true", focusable: false, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M14 6v4H4v4h10v4l6-6-6-6z" }) }),
|
|
1959
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only ui-grid-sr-only", children: labels.pinRight })
|
|
1960
|
+
]
|
|
1961
|
+
}
|
|
1962
|
+
)
|
|
1963
|
+
]
|
|
1964
|
+
}
|
|
1965
|
+
)
|
|
1966
|
+
]
|
|
1967
|
+
}
|
|
1968
|
+
)
|
|
1969
|
+
] })
|
|
1970
|
+
]
|
|
1971
|
+
},
|
|
1972
|
+
column.name
|
|
1973
|
+
);
|
|
1974
|
+
})
|
|
1975
|
+
}
|
|
1976
|
+
),
|
|
1977
|
+
filteringFeature && state.isFilteringEnabled() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2427
1978
|
"div",
|
|
2428
1979
|
{
|
|
2429
|
-
className: "
|
|
2430
|
-
"data-part": "
|
|
2431
|
-
|
|
1980
|
+
className: "filter-grid ui-grid-header",
|
|
1981
|
+
"data-part": "filters",
|
|
1982
|
+
ref: filterGridRef,
|
|
2432
1983
|
style: {
|
|
2433
1984
|
gridTemplateColumns,
|
|
2434
|
-
|
|
2435
|
-
top: 0,
|
|
2436
|
-
left: 0,
|
|
2437
|
-
right: 0,
|
|
2438
|
-
transform: `translateY(${virtualScroll.offsetY}px)`
|
|
1985
|
+
["--ui-grid-header-sticky-top"]: `${headerStickyHeight}px`
|
|
2439
1986
|
},
|
|
2440
|
-
children:
|
|
1987
|
+
children: visibleColumns.map((column) => {
|
|
1988
|
+
const pinned = state.isPinned(column);
|
|
1989
|
+
const pinOffset = pinned ? state.pinnedOffset(column) : null;
|
|
1990
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
1991
|
+
"label",
|
|
1992
|
+
{
|
|
1993
|
+
className: `filter-cell ui-grid-filter-container${pinned ? " is-pinned" : ""}`,
|
|
1994
|
+
"data-part": "filter-cell",
|
|
1995
|
+
style: {
|
|
1996
|
+
position: pinned ? "sticky" : void 0,
|
|
1997
|
+
left: pinOffset?.side === "left" ? pinOffset.offset : void 0,
|
|
1998
|
+
right: pinOffset?.side === "right" ? pinOffset.offset : void 0,
|
|
1999
|
+
zIndex: pinned ? 2 : void 0
|
|
2000
|
+
},
|
|
2001
|
+
children: [
|
|
2002
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "sr-only ui-grid-sr-only", children: [
|
|
2003
|
+
labels.filterColumn,
|
|
2004
|
+
" ",
|
|
2005
|
+
state.headerLabel(column)
|
|
2006
|
+
] }),
|
|
2007
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2008
|
+
"input",
|
|
2009
|
+
{
|
|
2010
|
+
className: "ui-grid-filter-input",
|
|
2011
|
+
type: "text",
|
|
2012
|
+
defaultValue: state.filterValue(column.name),
|
|
2013
|
+
placeholder: state.filterPlaceholder(column),
|
|
2014
|
+
disabled: state.isFilterInputDisabled(column),
|
|
2015
|
+
onChange: (e) => state.updateFilter(column.name, e.target.value)
|
|
2016
|
+
}
|
|
2017
|
+
)
|
|
2018
|
+
]
|
|
2019
|
+
},
|
|
2020
|
+
column.name
|
|
2021
|
+
);
|
|
2022
|
+
})
|
|
2441
2023
|
}
|
|
2442
|
-
)
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
style: { gridTemplateColumns },
|
|
2451
|
-
children: displayItems.map(renderDisplayItem)
|
|
2452
|
-
}
|
|
2453
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "empty-state ui-grid-no-row-overlay", "data-part": "empty-state", children: [
|
|
2454
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: options.emptyMessage ?? labels.emptyHeading }),
|
|
2455
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: labels.emptyDescription })
|
|
2456
|
-
] }),
|
|
2457
|
-
paginationFeature && state.showPaginationControls() && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2458
|
-
"footer",
|
|
2459
|
-
{
|
|
2460
|
-
className: "pagination-bar ui-grid-pagination",
|
|
2461
|
-
"data-part": "pagination",
|
|
2462
|
-
role: "navigation",
|
|
2463
|
-
"aria-label": labels.paginationPage,
|
|
2464
|
-
children: [
|
|
2465
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: state.paginationSummary() }),
|
|
2466
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pagination-controls", children: [
|
|
2467
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2468
|
-
"button",
|
|
2024
|
+
),
|
|
2025
|
+
displayItems.length > 0 ? virtualizationEnabled ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2026
|
+
"div",
|
|
2027
|
+
{
|
|
2028
|
+
className: "grid-virtual-spacer",
|
|
2029
|
+
style: { height: `${virtualScroll.totalHeight}px` },
|
|
2030
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2031
|
+
"div",
|
|
2469
2032
|
{
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
"
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
viewBox: "0 0 24 24",
|
|
2481
|
-
"aria-hidden": "true",
|
|
2482
|
-
focusable: false,
|
|
2483
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" })
|
|
2484
|
-
}
|
|
2485
|
-
),
|
|
2486
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationPrevious })
|
|
2487
|
-
]
|
|
2033
|
+
className: "body-grid ui-grid-canvas grid-virtual-body",
|
|
2034
|
+
"data-part": "body",
|
|
2035
|
+
role: "rowgroup",
|
|
2036
|
+
style: {
|
|
2037
|
+
gridTemplateColumns,
|
|
2038
|
+
position: "absolute",
|
|
2039
|
+
top: `${virtualScroll.offsetY}px`,
|
|
2040
|
+
left: 0
|
|
2041
|
+
},
|
|
2042
|
+
children: itemsToRender.map(renderDisplayItem)
|
|
2488
2043
|
}
|
|
2489
|
-
)
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2501
|
-
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2044
|
+
)
|
|
2045
|
+
}
|
|
2046
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2047
|
+
"div",
|
|
2048
|
+
{
|
|
2049
|
+
className: "body-grid ui-grid-canvas",
|
|
2050
|
+
"data-part": "body",
|
|
2051
|
+
role: "rowgroup",
|
|
2052
|
+
style: { gridTemplateColumns },
|
|
2053
|
+
children: displayItems.map(renderDisplayItem)
|
|
2054
|
+
}
|
|
2055
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "empty-state ui-grid-no-row-overlay", "data-part": "empty-state", children: [
|
|
2056
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", { children: options.emptyMessage ?? labels.emptyHeading }),
|
|
2057
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: labels.emptyDescription })
|
|
2058
|
+
] }),
|
|
2059
|
+
paginationFeature && state.showPaginationControls() && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2060
|
+
"footer",
|
|
2061
|
+
{
|
|
2062
|
+
className: "pagination-bar ui-grid-pagination",
|
|
2063
|
+
"data-part": "pagination",
|
|
2064
|
+
role: "navigation",
|
|
2065
|
+
"aria-label": labels.paginationPage,
|
|
2066
|
+
children: [
|
|
2067
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { children: state.paginationSummary() }),
|
|
2068
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "pagination-controls", children: [
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2070
|
+
"button",
|
|
2071
|
+
{
|
|
2072
|
+
type: "button",
|
|
2073
|
+
className: "action action-secondary pagination-button",
|
|
2074
|
+
"aria-label": labels.paginationPrevious,
|
|
2075
|
+
disabled: paginationCurrentPage <= 1,
|
|
2076
|
+
onClick: () => state.previousPage(),
|
|
2077
|
+
children: [
|
|
2078
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2079
|
+
"svg",
|
|
2080
|
+
{
|
|
2081
|
+
className: "pagination-icon",
|
|
2082
|
+
viewBox: "0 0 24 24",
|
|
2083
|
+
"aria-hidden": "true",
|
|
2084
|
+
focusable: false,
|
|
2085
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" })
|
|
2086
|
+
}
|
|
2087
|
+
),
|
|
2088
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationPrevious })
|
|
2089
|
+
]
|
|
2090
|
+
}
|
|
2091
|
+
),
|
|
2092
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
|
|
2093
|
+
labels.paginationPage,
|
|
2094
|
+
" ",
|
|
2095
|
+
paginationCurrentPage,
|
|
2096
|
+
" ",
|
|
2097
|
+
labels.paginationOf,
|
|
2098
|
+
" ",
|
|
2099
|
+
paginationTotalPages
|
|
2100
|
+
] }),
|
|
2101
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
2102
|
+
"button",
|
|
2103
|
+
{
|
|
2104
|
+
type: "button",
|
|
2105
|
+
className: "action action-secondary pagination-button",
|
|
2106
|
+
"aria-label": labels.paginationNext,
|
|
2107
|
+
disabled: paginationCurrentPage >= paginationTotalPages,
|
|
2108
|
+
onClick: () => state.nextPage(),
|
|
2109
|
+
children: [
|
|
2110
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2111
|
+
"svg",
|
|
2112
|
+
{
|
|
2113
|
+
className: "pagination-icon",
|
|
2114
|
+
viewBox: "0 0 24 24",
|
|
2115
|
+
"aria-hidden": "true",
|
|
2116
|
+
focusable: false,
|
|
2117
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z" })
|
|
2118
|
+
}
|
|
2119
|
+
),
|
|
2120
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationNext })
|
|
2121
|
+
]
|
|
2122
|
+
}
|
|
2123
|
+
),
|
|
2124
|
+
state.pageSizeOptions().length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "pagination-size", children: [
|
|
2125
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "sr-only", children: labels.paginationRows }),
|
|
2508
2126
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
2509
|
-
"
|
|
2127
|
+
"select",
|
|
2510
2128
|
{
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z" })
|
|
2129
|
+
"aria-label": labels.paginationRows,
|
|
2130
|
+
value: paginationSelectedPageSize,
|
|
2131
|
+
onChange: (e) => state.onPageSizeChange(e.target.value),
|
|
2132
|
+
children: state.pageSizeOptions().map((size) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: size, children: size }, size))
|
|
2516
2133
|
}
|
|
2517
|
-
)
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
{
|
|
2527
|
-
"aria-label": labels.paginationRows,
|
|
2528
|
-
value: paginationSelectedPageSize,
|
|
2529
|
-
onChange: (e) => state.onPageSizeChange(e.target.value),
|
|
2530
|
-
children: state.pageSizeOptions().map((size) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: size, children: size }, size))
|
|
2531
|
-
}
|
|
2532
|
-
)
|
|
2533
|
-
] })
|
|
2534
|
-
] })
|
|
2535
|
-
]
|
|
2536
|
-
}
|
|
2537
|
-
)
|
|
2538
|
-
] })
|
|
2134
|
+
)
|
|
2135
|
+
] })
|
|
2136
|
+
] })
|
|
2137
|
+
]
|
|
2138
|
+
}
|
|
2139
|
+
)
|
|
2140
|
+
]
|
|
2141
|
+
}
|
|
2142
|
+
)
|
|
2539
2143
|
]
|
|
2540
2144
|
}
|
|
2541
2145
|
)
|
|
2542
2146
|
] }) });
|
|
2543
2147
|
}
|
|
2544
2148
|
|
|
2149
|
+
// src/mountUiGrid.tsx
|
|
2150
|
+
var import_react4 = __toESM(require("react"));
|
|
2151
|
+
var import_client = require("react-dom/client");
|
|
2152
|
+
function mountUiGrid(container, props) {
|
|
2153
|
+
const root = (0, import_client.createRoot)(container);
|
|
2154
|
+
root.render(import_react4.default.createElement(UiGrid, props));
|
|
2155
|
+
return root;
|
|
2156
|
+
}
|
|
2157
|
+
|
|
2158
|
+
// src/vanillaAdapter.ts
|
|
2159
|
+
async function mountUiGridCustomElement(container, mountOptions) {
|
|
2160
|
+
const tagName = mountOptions.tagName ?? "ui-grid-element";
|
|
2161
|
+
if (mountOptions.ensureDefined) {
|
|
2162
|
+
await mountOptions.ensureDefined(tagName);
|
|
2163
|
+
}
|
|
2164
|
+
const element = document.createElement(tagName);
|
|
2165
|
+
element.options = mountOptions.options;
|
|
2166
|
+
container.replaceChildren(element);
|
|
2167
|
+
return {
|
|
2168
|
+
element,
|
|
2169
|
+
unmount: () => {
|
|
2170
|
+
if (container.firstElementChild === element) {
|
|
2171
|
+
container.replaceChildren();
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
|
|
2545
2177
|
// src/rustWasmGridEngine.ts
|
|
2546
|
-
var
|
|
2547
|
-
var uiGridWasmModulePath = "../../../dist/ui-grid-wasm/ui_grid_wasm.js";
|
|
2178
|
+
var import_ui_grid_core3 = require("@ornery/ui-grid-core");
|
|
2179
|
+
var uiGridWasmModulePath = "../../../dist/ui-grid-wasm-web/ui_grid_wasm.js";
|
|
2180
|
+
var uiGridWasmBinaryPath = "/dist/ui-grid-wasm-web/ui_grid_wasm_bg.wasm";
|
|
2548
2181
|
function registerReactUiGridWasmEngineFromModule(module2) {
|
|
2549
|
-
(0,
|
|
2182
|
+
(0, import_ui_grid_core3.registerRustWasmGridEngine)({
|
|
2550
2183
|
buildPipeline(context) {
|
|
2551
2184
|
return module2.build_pipeline_js(context);
|
|
2552
2185
|
}
|
|
@@ -2557,11 +2190,12 @@ async function enableReactUiGridWasmEngine() {
|
|
|
2557
2190
|
/* @vite-ignore */
|
|
2558
2191
|
uiGridWasmModulePath
|
|
2559
2192
|
);
|
|
2193
|
+
await module2.default(uiGridWasmBinaryPath);
|
|
2560
2194
|
registerReactUiGridWasmEngineFromModule(module2);
|
|
2561
2195
|
}
|
|
2562
2196
|
|
|
2563
2197
|
// src/index.ts
|
|
2564
|
-
var
|
|
2198
|
+
var import_ui_grid_core4 = require("@ornery/ui-grid-core");
|
|
2565
2199
|
// Annotate the CommonJS export names for ESM import in node:
|
|
2566
2200
|
0 && (module.exports = {
|
|
2567
2201
|
DEFAULT_GRID_LABELS,
|
|
@@ -2571,6 +2205,8 @@ var import_ui_grid9 = require("@ornery/ui-grid");
|
|
|
2571
2205
|
computeViewportRows,
|
|
2572
2206
|
enableReactUiGridWasmEngine,
|
|
2573
2207
|
formatPaginationSummary,
|
|
2208
|
+
mountUiGrid,
|
|
2209
|
+
mountUiGridCustomElement,
|
|
2574
2210
|
orderVisibleColumns,
|
|
2575
2211
|
registerReactUiGridWasmEngineFromModule,
|
|
2576
2212
|
resolveBenchmarkIterations,
|