@1771technologies/lytenyte-pro 1.0.0-beta.3 → 1.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/+types.d.ts +88 -14
- package/dist/cell-selection/cell-selection-driver.js +9 -1
- package/dist/cell-selection/update-additive-cell-selection.js +0 -2
- package/dist/cells/cell-editor.js +11 -4
- package/dist/cells/cell.js +6 -3
- package/dist/column-manager/branch.d.ts +9 -3
- package/dist/column-manager/branch.js +20 -4
- package/dist/column-manager/column-manager.d.ts +3 -5
- package/dist/column-manager/column-manager.js +6 -8
- package/dist/column-manager/context.d.ts +2 -2
- package/dist/column-manager/label.d.ts +1 -1
- package/dist/column-manager/label.js +5 -5
- package/dist/column-manager/leaf.d.ts +2 -2
- package/dist/column-manager/leaf.js +22 -4
- package/dist/column-manager/move-handle.d.ts +3 -3
- package/dist/column-manager/move-handle.js +3 -5
- package/dist/column-manager/panel.d.ts +1 -0
- package/dist/column-manager/panel.js +2 -0
- package/dist/column-manager/root.d.ts +6 -7
- package/dist/column-manager/root.js +2 -15
- package/dist/column-manager/use-column-manager.d.ts +8 -18
- package/dist/column-manager/use-column-manager.js +18 -22
- package/dist/column-manager/use-columns-from-context.d.ts +2 -2
- package/dist/column-manager/use-columns-from-context.js +2 -2
- package/dist/column-manager/visibility-checkbox.d.ts +1 -1
- package/dist/column-manager/visibility-checkbox.js +2 -2
- package/dist/filter-tree/branch.js +1 -1
- package/dist/filter-tree/inclusion-checkbox.d.ts +1 -1
- package/dist/filter-tree/inclusion-checkbox.js +2 -2
- package/dist/filter-tree/label.d.ts +1 -1
- package/dist/filter-tree/label.js +2 -2
- package/dist/filter-tree/root.d.ts +3 -3
- package/dist/filter-tree/root.js +4 -4
- package/dist/grid-box/+types.d.ts +4 -2
- package/dist/grid-box/item.d.ts +4 -1
- package/dist/grid-box/item.js +39 -9
- package/dist/grid-box/use-aggregation-box-items.js +3 -1
- package/dist/grid-box/use-column-box-items.d.ts +6 -2
- package/dist/grid-box/use-column-box-items.js +11 -14
- package/dist/grid-box/use-row-group-box-items.d.ts +2 -2
- package/dist/grid-box/use-row-group-box-items.js +14 -15
- package/dist/grid.d.ts +0 -12
- package/dist/grid.js +0 -12
- package/dist/header/header-cell.d.ts +1 -1
- package/dist/header/header-cell.js +2 -2
- package/dist/header/header-group-cell.js +3 -1
- package/dist/header/resize-handler.d.ts +2 -2
- package/dist/header/resize-handler.js +8 -3
- package/dist/header/use-drag-move.js +9 -2
- package/dist/header/use-header-cell-renderer.js +4 -4
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +7 -0
- package/dist/listbox/item.js +1 -1
- package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
- package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +3 -3
- package/dist/row-data-source-client/use-client-data-source-paginated.js +66 -24
- package/dist/row-data-source-client/use-client-data-source.js +50 -20
- package/dist/row-data-source-client/use-client-tree-data-source.js +49 -20
- package/dist/row-data-source-server/use-server-data-source.js +20 -0
- package/dist/sort-manager/sort-add.d.ts +1 -1
- package/dist/sort-manager/sort-add.js +3 -3
- package/dist/sort-manager/sort-apply.d.ts +1 -1
- package/dist/sort-manager/sort-apply.js +3 -3
- package/dist/sort-manager/sort-cancel.d.ts +1 -1
- package/dist/sort-manager/sort-cancel.js +3 -3
- package/dist/sort-manager/sort-clear.d.ts +1 -1
- package/dist/sort-manager/sort-clear.js +3 -3
- package/dist/sort-manager/sort-column-select.d.ts +1 -1
- package/dist/sort-manager/sort-column-select.js +2 -2
- package/dist/sort-manager/sort-direction-select.d.ts +1 -1
- package/dist/sort-manager/sort-direction-select.js +2 -2
- package/dist/sort-manager/sort-remove.d.ts +1 -1
- package/dist/sort-manager/sort-remove.js +3 -3
- package/dist/sort-manager/sort-value-select.d.ts +1 -1
- package/dist/sort-manager/sort-value-select.js +2 -2
- package/dist/state/+types.d.ts +2 -1
- package/dist/state/api/column-autosize.js +1 -1
- package/dist/state/api/column-from-index.d.ts +1 -1
- package/dist/state/api/column-from-index.js +1 -1
- package/dist/state/api/column-update.d.ts +4 -1
- package/dist/state/api/column-update.js +13 -0
- package/dist/state/api/edit-end.js +1 -1
- package/dist/state/api/export-data-rect.js +1 -1
- package/dist/state/helpers/column-add-row-group.d.ts +2 -1
- package/dist/state/helpers/column-add-row-group.js +9 -1
- package/dist/state/helpers/column-marker.js +1 -1
- package/dist/state/helpers/edit-on-change.js +1 -0
- package/dist/state/helpers/empty-row-data-source.js +1 -0
- package/dist/state/helpers/resolve-column.d.ts +1 -1
- package/dist/state/helpers/resolve-column.js +7 -0
- package/dist/state/use-lytenyte.js +16 -4
- package/dist/tree-view/branch/branch.d.ts +4 -1
- package/dist/tree-view/branch/branch.js +3 -2
- package/dist/tree-view/hooks/use-tree-view-paths.d.ts +1 -1
- package/dist/tree-view/hooks/use-tree-view-paths.js +3 -3
- package/dist/tree-view/leaf.js +1 -0
- package/dist/viewport/begin-editing.js +1 -1
- package/main.css +4 -0
- package/package.json +12 -6
- package/dist/column-manager/passive-scroll.d.ts +0 -2
- package/dist/column-manager/passive-scroll.js +0 -2
|
@@ -12,6 +12,9 @@ export function makeClientTreeDataSource(p) {
|
|
|
12
12
|
const data = atom(p.data);
|
|
13
13
|
const topData = atom(p.topData ?? []);
|
|
14
14
|
const bottomData = atom(p.bottomData ?? []);
|
|
15
|
+
const dataToSrc$ = atom((g) => {
|
|
16
|
+
return new Map(g(data).map((c, i) => [c, i]));
|
|
17
|
+
});
|
|
15
18
|
const cache = new Map();
|
|
16
19
|
const centerNodes = atom((g) => {
|
|
17
20
|
const nodes = [];
|
|
@@ -130,6 +133,13 @@ export function makeClientTreeDataSource(p) {
|
|
|
130
133
|
};
|
|
131
134
|
return comparator;
|
|
132
135
|
});
|
|
136
|
+
const idToNode = atom((g) => {
|
|
137
|
+
const map = new Map();
|
|
138
|
+
traverse(g(tree).root, (node) => {
|
|
139
|
+
map.set(node.id, node);
|
|
140
|
+
});
|
|
141
|
+
return map;
|
|
142
|
+
});
|
|
133
143
|
const initialized = atom(false);
|
|
134
144
|
const flat = atom((g) => {
|
|
135
145
|
if (!g(initialized))
|
|
@@ -275,30 +285,32 @@ export function makeClientTreeDataSource(p) {
|
|
|
275
285
|
};
|
|
276
286
|
const rowUpdate = (updates) => {
|
|
277
287
|
const grid = rdsStore.get(grid$);
|
|
278
|
-
const t = rdsStore.get(tree);
|
|
279
288
|
const d = rdsStore.get(data);
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
289
|
+
const idMap = rdsStore.get(idToNode);
|
|
290
|
+
const dataToSrc = rdsStore.get(dataToSrc$);
|
|
291
|
+
for (const [key, next] of updates.entries()) {
|
|
292
|
+
const row = typeof key === "string" ? rowById(key) : rowByIndex(key);
|
|
293
|
+
const treeNode = typeof key === "string" ? idMap.get(key) : null;
|
|
294
|
+
if ((!row && !treeNode) || !grid) {
|
|
295
|
+
console.error(`Failed to find the row with identifier ${key} which is being updated.`);
|
|
285
296
|
continue;
|
|
286
297
|
}
|
|
287
|
-
if (row
|
|
288
|
-
row.data =
|
|
298
|
+
if (row?.kind === "branch") {
|
|
299
|
+
row.data = next;
|
|
289
300
|
}
|
|
290
301
|
else {
|
|
291
|
-
const
|
|
302
|
+
const data = row?.kind === "leaf" ? row.data : treeNode?.data.data;
|
|
303
|
+
const source = dataToSrc.get(data);
|
|
292
304
|
if (source == null) {
|
|
293
|
-
console.error(`Failed to find the row
|
|
305
|
+
console.error(`Failed to find the row with identifier ${key} which is being updated.`);
|
|
294
306
|
continue;
|
|
295
307
|
}
|
|
296
|
-
d[source] =
|
|
308
|
+
d[source] = next;
|
|
297
309
|
}
|
|
298
|
-
grid.state.rowDataStore.rowInvalidateIndex(rowIndex);
|
|
299
310
|
}
|
|
300
311
|
rdsStore.set(data, [...d]);
|
|
301
312
|
rdsStore.set(snapshot, (prev) => prev + 1);
|
|
313
|
+
grid.state.rowDataStore.rowClearCache();
|
|
302
314
|
};
|
|
303
315
|
const rowToIndex = (rowId) => {
|
|
304
316
|
const f = rdsStore.get(flat);
|
|
@@ -346,11 +358,10 @@ export function makeClientTreeDataSource(p) {
|
|
|
346
358
|
const field = grid.api.columnField(c, row);
|
|
347
359
|
return field;
|
|
348
360
|
}));
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
});
|
|
361
|
+
if (p.transformInFilterItem) {
|
|
362
|
+
return p.transformInFilterItem({ column: c, values: [...values] });
|
|
363
|
+
}
|
|
364
|
+
return [...values].map((x) => ({ id: `${x}`, label: `${x}`, value: x }));
|
|
354
365
|
},
|
|
355
366
|
rowAdd: (newRows, place = "end") => {
|
|
356
367
|
rdsStore.set(data, (prev) => {
|
|
@@ -392,6 +403,11 @@ export function makeClientTreeDataSource(p) {
|
|
|
392
403
|
const grid = rdsStore.get(grid$);
|
|
393
404
|
grid?.state.rowDataStore.rowClearCache();
|
|
394
405
|
},
|
|
406
|
+
rowSetCenterData: (d) => {
|
|
407
|
+
rdsStore.set(data, d);
|
|
408
|
+
const grid = rdsStore.get(grid$);
|
|
409
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
410
|
+
},
|
|
395
411
|
rowSetTopData: (data) => {
|
|
396
412
|
rdsStore.set(topData, data);
|
|
397
413
|
const grid = rdsStore.get(grid$);
|
|
@@ -470,6 +486,19 @@ export function makeClientTreeDataSource(p) {
|
|
|
470
486
|
const t = rdsStore.get(tree);
|
|
471
487
|
grid.state.rowSelectedIds.set(new Set(t.idsAll));
|
|
472
488
|
},
|
|
489
|
+
rowData: (section) => {
|
|
490
|
+
const d = [];
|
|
491
|
+
if (section === "top" || section === "flat") {
|
|
492
|
+
d.push(...rdsStore.get(topData));
|
|
493
|
+
}
|
|
494
|
+
if (section === "center" || section === "flat") {
|
|
495
|
+
d.push(...rdsStore.get(data));
|
|
496
|
+
}
|
|
497
|
+
if (section === "bottom" || section === "flat") {
|
|
498
|
+
d.push(...rdsStore.get(bottomData));
|
|
499
|
+
}
|
|
500
|
+
return d;
|
|
501
|
+
},
|
|
473
502
|
rowAreAllSelected: (rowId) => {
|
|
474
503
|
const g = rdsStore.get(grid$);
|
|
475
504
|
if (!g)
|
|
@@ -502,12 +531,12 @@ export function useClientTreeDataSource(p) {
|
|
|
502
531
|
if (p.reflectData) {
|
|
503
532
|
// Need to queue the microtask since it we cannot update state during render.
|
|
504
533
|
if (p.data !== da.center.get())
|
|
505
|
-
queueMicrotask(() =>
|
|
534
|
+
queueMicrotask(() => ds.current.rowSetCenterData(p.data));
|
|
506
535
|
if (!equal(p.topData ?? [], da.top.get())) {
|
|
507
|
-
queueMicrotask(() =>
|
|
536
|
+
queueMicrotask(() => ds.current.rowSetTopData(p.topData ?? []));
|
|
508
537
|
}
|
|
509
538
|
if (!equal(p.bottomData ?? [], da.bottom.get()))
|
|
510
|
-
queueMicrotask(() =>
|
|
539
|
+
queueMicrotask(() => ds.current.rowSetBotData(p.bottomData ?? []));
|
|
511
540
|
}
|
|
512
541
|
return ds.current;
|
|
513
542
|
}
|
|
@@ -453,6 +453,7 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
453
453
|
return { kind: "leaf", data: null, id: `error-${ri}`, loading: false, error };
|
|
454
454
|
if (!node)
|
|
455
455
|
return { kind: "leaf", data: null, id: `loading-${ri}`, loading: true, error: null };
|
|
456
|
+
const isLoading = rdsStore.get(loadingGroups$);
|
|
456
457
|
if (node.kind === "parent") {
|
|
457
458
|
return {
|
|
458
459
|
kind: "branch",
|
|
@@ -461,6 +462,7 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
461
462
|
key: node.path,
|
|
462
463
|
depth: getNodeDepth(node),
|
|
463
464
|
error,
|
|
465
|
+
loading: isLoading.has(node.data.id),
|
|
464
466
|
};
|
|
465
467
|
}
|
|
466
468
|
return {
|
|
@@ -470,13 +472,19 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
470
472
|
error,
|
|
471
473
|
};
|
|
472
474
|
};
|
|
475
|
+
const loadingGroups$ = atom(new Set());
|
|
473
476
|
const rowExpand = (p) => {
|
|
474
477
|
const f = flat.get();
|
|
478
|
+
const loadingRows = new Set(rdsStore.get(loadingGroups$));
|
|
479
|
+
const rowsForThis = new Set();
|
|
475
480
|
const rowIndices = [];
|
|
476
481
|
const requests = Object.entries(p)
|
|
477
482
|
.map(([rowId, state]) => {
|
|
478
483
|
if (!state)
|
|
479
484
|
return null;
|
|
485
|
+
// Mark as loading
|
|
486
|
+
loadingRows.add(rowId);
|
|
487
|
+
rowsForThis.add(rowId);
|
|
480
488
|
const rowIndex = rowToIndex(rowId);
|
|
481
489
|
if (rowIndex == null)
|
|
482
490
|
return null;
|
|
@@ -505,17 +513,26 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
505
513
|
return prev;
|
|
506
514
|
});
|
|
507
515
|
}
|
|
516
|
+
// Mark these groups as loading
|
|
517
|
+
rdsStore.set(loadingGroups$, loadingRows);
|
|
518
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
508
519
|
dataRequestHandler(requests, false, () => {
|
|
509
520
|
if (mode)
|
|
510
521
|
grid?.state.columnPivotColumnGroupExpansions.set((prev) => ({ ...prev, ...p }));
|
|
511
522
|
else
|
|
512
523
|
grid?.state.rowGroupExpansions.set((prev) => ({ ...prev, ...p }));
|
|
524
|
+
const next = new Set(rdsStore.get(loadingGroups$));
|
|
525
|
+
rowsForThis.forEach((c) => next.delete(c));
|
|
526
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
513
527
|
}, (error) => {
|
|
514
528
|
rdsStore.set(nodesWithError, (prev) => {
|
|
515
529
|
const n = new Map(prev);
|
|
516
530
|
rowIndices.forEach((c) => n.set(c, error));
|
|
517
531
|
return prev;
|
|
518
532
|
});
|
|
533
|
+
const next = new Set(rdsStore.get(loadingGroups$));
|
|
534
|
+
rowsForThis.forEach((c) => next.delete(c));
|
|
535
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
519
536
|
});
|
|
520
537
|
};
|
|
521
538
|
const rowToIndex = (rowId) => {
|
|
@@ -651,6 +668,9 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
651
668
|
rowSelect,
|
|
652
669
|
rowSelectAll,
|
|
653
670
|
rowSetBotData,
|
|
671
|
+
rowSetCenterData: () => {
|
|
672
|
+
throw new Error("Server side data source does not support full row updates");
|
|
673
|
+
},
|
|
654
674
|
rowSetTopData,
|
|
655
675
|
rowToIndex,
|
|
656
676
|
rowUpdate,
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortAdd = forwardRef(function SortAdd({
|
|
5
|
+
export const SortAdd = forwardRef(function SortAdd({ as: as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const renderer = useSlot({
|
|
8
|
-
props: [props],
|
|
8
|
+
props: [typeof as !== "function" ? { onClick: row.onAdd, disabled: !row.canAdd } : {}, props],
|
|
9
9
|
ref: forwarded,
|
|
10
|
-
slot:
|
|
10
|
+
slot: as ?? _jsx("button", { children: "+" }),
|
|
11
11
|
state: { onAdd: row.onAdd, disabled: !row.canAdd },
|
|
12
12
|
});
|
|
13
13
|
return renderer;
|
|
@@ -4,7 +4,7 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { useSortManagerCtx } from "./context";
|
|
5
5
|
import { itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
6
6
|
import { sortItemsToSortModel } from "./utils/sort-item-to-sort-model";
|
|
7
|
-
export const SortApply = forwardRef(function SortApply({
|
|
7
|
+
export const SortApply = forwardRef(function SortApply({ as, ...props }, forwarded) {
|
|
8
8
|
const ctx = useSortManagerCtx();
|
|
9
9
|
const onApply = useEvent(() => {
|
|
10
10
|
const lookup = itemsWithIdToMap(ctx.mode ? ctx.grid.state.columnPivotColumns.get() : ctx.grid.state.columns.get());
|
|
@@ -15,9 +15,9 @@ export const SortApply = forwardRef(function SortApply({ slot, ...props }, forwa
|
|
|
15
15
|
ctx.grid.state.sortModel.set(model);
|
|
16
16
|
});
|
|
17
17
|
const renderer = useSlot({
|
|
18
|
-
props: [props],
|
|
18
|
+
props: [typeof as !== "function" ? { onClick: onApply } : {}, props],
|
|
19
19
|
ref: forwarded,
|
|
20
|
-
slot:
|
|
20
|
+
slot: as ?? _jsx("button", {}),
|
|
21
21
|
state: { onApply },
|
|
22
22
|
});
|
|
23
23
|
return renderer;
|
|
@@ -4,7 +4,7 @@ import { forwardRef } from "react";
|
|
|
4
4
|
import { useSortManagerCtx } from "./context";
|
|
5
5
|
import { sortModelToSortItems } from "./utils/sort-model-to-sort-items";
|
|
6
6
|
import { itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
7
|
-
export const SortCancel = forwardRef(function SortCancel({
|
|
7
|
+
export const SortCancel = forwardRef(function SortCancel({ as, ...props }, forwarded) {
|
|
8
8
|
const ctx = useSortManagerCtx();
|
|
9
9
|
const onCancel = useEvent(() => {
|
|
10
10
|
const model = ctx.mode
|
|
@@ -18,9 +18,9 @@ export const SortCancel = forwardRef(function SortCancel({ slot, ...props }, for
|
|
|
18
18
|
ctx.setSortItems(state);
|
|
19
19
|
});
|
|
20
20
|
const renderer = useSlot({
|
|
21
|
-
props: [props],
|
|
21
|
+
props: [typeof as !== "function" ? { onClick: onCancel } : {}, props],
|
|
22
22
|
ref: forwarded,
|
|
23
|
-
slot:
|
|
23
|
+
slot: as ?? _jsx("button", {}),
|
|
24
24
|
state: { onCancel },
|
|
25
25
|
});
|
|
26
26
|
return renderer;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEvent, useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortManagerCtx } from "./context";
|
|
5
|
-
export const SortClear = forwardRef(function SortClear({
|
|
5
|
+
export const SortClear = forwardRef(function SortClear({ as, ...props }, forwarded) {
|
|
6
6
|
const ctx = useSortManagerCtx();
|
|
7
7
|
const onClear = useEvent(() => {
|
|
8
8
|
if (ctx.mode) {
|
|
@@ -13,9 +13,9 @@ export const SortClear = forwardRef(function SortClear({ slot, ...props }, forwa
|
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
15
|
const renderer = useSlot({
|
|
16
|
-
props: [props],
|
|
16
|
+
props: [typeof as !== "function" ? { onClick: onClear } : {}, props],
|
|
17
17
|
ref: forwarded,
|
|
18
|
-
slot:
|
|
18
|
+
slot: as ?? _jsx("button", {}),
|
|
19
19
|
state: { onClear },
|
|
20
20
|
});
|
|
21
21
|
return renderer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import type { Option } from "./+types";
|
|
3
3
|
export interface SortColumnSelectProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly as?: SlotComponent<{
|
|
5
5
|
options: Option[];
|
|
6
6
|
onSelect: (v: Option | null) => void;
|
|
7
7
|
value: Option | null;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortColumnSelect = forwardRef(function SortColumnSelect({
|
|
5
|
+
export const SortColumnSelect = forwardRef(function SortColumnSelect({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const el = (_jsxs("select", { "aria-label": "Select column to sort", value: row.columnItem?.value ?? "", onChange: (e) => {
|
|
8
8
|
const item = row.columnOptions.find((c) => c.value === e.target.value);
|
|
@@ -13,7 +13,7 @@ export const SortColumnSelect = forwardRef(function SortColumnSelect({ slot, ...
|
|
|
13
13
|
const renderer = useSlot({
|
|
14
14
|
props: [props],
|
|
15
15
|
ref: forwarded,
|
|
16
|
-
slot:
|
|
16
|
+
slot: as ?? el,
|
|
17
17
|
state: { options: row.columnOptions, onSelect: row.columnOnSelect, value: row.columnSelected },
|
|
18
18
|
});
|
|
19
19
|
return renderer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import type { Option } from "./+types";
|
|
3
3
|
export interface SortDirectionSelectProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly as?: SlotComponent<{
|
|
5
5
|
options: Option[];
|
|
6
6
|
onSelect: (v: Option | null) => void;
|
|
7
7
|
value: Option | null;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortDirectionSelect = forwardRef(function SortDirectionSelect({
|
|
5
|
+
export const SortDirectionSelect = forwardRef(function SortDirectionSelect({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const el = (_jsx("select", { "aria-label": "Select sort direction", value: row.sortDirectionSelected?.value ?? "", onChange: (e) => {
|
|
8
8
|
const item = row.sortDirectionOptions.find((c) => c.value === e.target.value);
|
|
@@ -13,7 +13,7 @@ export const SortDirectionSelect = forwardRef(function SortDirectionSelect({ slo
|
|
|
13
13
|
const renderer = useSlot({
|
|
14
14
|
props: [props],
|
|
15
15
|
ref: forwarded,
|
|
16
|
-
slot:
|
|
16
|
+
slot: as ?? el,
|
|
17
17
|
state: {
|
|
18
18
|
options: row.sortDirectionOptions,
|
|
19
19
|
onSelect: row.sortDirectionOnSelect,
|
|
@@ -2,12 +2,12 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortRemove = forwardRef(function SortRemove({
|
|
5
|
+
export const SortRemove = forwardRef(function SortRemove({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const renderer = useSlot({
|
|
8
|
-
props: [props],
|
|
8
|
+
props: [typeof as !== "function" ? { onClick: row.onDelete } : {}, props],
|
|
9
9
|
ref: forwarded,
|
|
10
|
-
slot:
|
|
10
|
+
slot: as ?? _jsx("button", { children: "x" }),
|
|
11
11
|
state: { onAdd: row.onDelete },
|
|
12
12
|
});
|
|
13
13
|
return renderer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type SlotComponent } from "@1771technologies/lytenyte-react-hooks";
|
|
2
2
|
import type { Option } from "./+types";
|
|
3
3
|
export interface SortValueSelectProps {
|
|
4
|
-
readonly
|
|
4
|
+
readonly as?: SlotComponent<{
|
|
5
5
|
options: Option[];
|
|
6
6
|
onSelect: (v: Option | null) => void;
|
|
7
7
|
value: Option | null;
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSlot } from "@1771technologies/lytenyte-react-hooks";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
4
|
import { useSortRowCtx } from "./context";
|
|
5
|
-
export const SortValueSelect = forwardRef(function SortValueSelect({
|
|
5
|
+
export const SortValueSelect = forwardRef(function SortValueSelect({ as, ...props }, forwarded) {
|
|
6
6
|
const row = useSortRowCtx();
|
|
7
7
|
const el = (_jsxs("select", { "aria-label": "Select sort value", value: row.sortSelected?.value ?? "", onChange: (e) => {
|
|
8
8
|
const item = row.sortOptions.find((c) => c.value === e.target.value);
|
|
@@ -13,7 +13,7 @@ export const SortValueSelect = forwardRef(function SortValueSelect({ slot, ...pr
|
|
|
13
13
|
const renderer = useSlot({
|
|
14
14
|
props: [props],
|
|
15
15
|
ref: forwarded,
|
|
16
|
-
slot:
|
|
16
|
+
slot: as ?? el,
|
|
17
17
|
state: {
|
|
18
18
|
options: row.sortOptions,
|
|
19
19
|
value: row.sortSelected,
|
package/dist/state/+types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { LayoutMap } from "@1771technologies/lytenyte-shared";
|
|
2
|
-
import type { DataRect, EditActivePosition, GridAtom, GridAtomReadonly, HeaderGroupCellLayout, PositionUnion, VirtualTarget } from "../+types";
|
|
2
|
+
import type { Column, DataRect, EditActivePosition, GridAtom, GridAtomReadonly, HeaderGroupCellLayout, PositionUnion, VirtualTarget } from "../+types";
|
|
3
3
|
import type { Atom, createStore } from "@1771technologies/atom";
|
|
4
4
|
export interface InternalAtoms {
|
|
5
5
|
readonly headerRows: GridAtomReadonly<number>;
|
|
@@ -20,6 +20,7 @@ export interface InternalAtoms {
|
|
|
20
20
|
readonly rowSelectedIds: Atom<Set<string>>;
|
|
21
21
|
readonly rowSelectionPivot: GridAtom<string | null>;
|
|
22
22
|
readonly rowSelectionLastWasDeselect: GridAtom<boolean>;
|
|
23
|
+
readonly rowGroupColumnState: GridAtom<Record<string, Partial<Column<any>>>>;
|
|
23
24
|
readonly draggingHeader: GridAtom<HeaderGroupCellLayout | null>;
|
|
24
25
|
readonly dialogFrames: GridAtom<Record<string, any>>;
|
|
25
26
|
readonly popoverFrames: GridAtom<Record<string, {
|
|
@@ -6,7 +6,7 @@ export const makeColumnAutosize = (grid) => {
|
|
|
6
6
|
const meta = grid.state.columnMeta.get();
|
|
7
7
|
const columns = params.columns
|
|
8
8
|
?.map((c) => resolveColumn(c, errorRef, meta))
|
|
9
|
-
.map((c) => c && grid.api.columnById(c))
|
|
9
|
+
.map((c) => c && (typeof c === "string" ? grid.api.columnById(c) : c))
|
|
10
10
|
.filter(Boolean) ?? grid.state.columnMeta.get().columnsVisible;
|
|
11
11
|
if (errorRef.current) {
|
|
12
12
|
console.error("Invalid column autosize column params");
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Grid, GridApi } from "../../+types";
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const makeColumnByIndex: (grid: Grid<any>) => GridApi<any>["columnByIndex"];
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { Grid, GridApi } from "../../+types";
|
|
2
|
-
|
|
2
|
+
import type { InternalAtoms } from "../+types";
|
|
3
|
+
export declare const makeColumnUpdate: (grid: Grid<any> & {
|
|
4
|
+
internal: InternalAtoms;
|
|
5
|
+
}) => GridApi<any>["columnUpdate"];
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import { GROUP_COLUMN_PREFIX } from "@1771technologies/lytenyte-shared";
|
|
1
2
|
export const makeColumnUpdate = (grid) => {
|
|
2
3
|
return (updates) => {
|
|
3
4
|
const columns = [...grid.state.columns.get()];
|
|
5
|
+
const groupColumns = grid.state.columnMeta
|
|
6
|
+
.get()
|
|
7
|
+
.columnsVisible.filter((c) => c.id.startsWith(GROUP_COLUMN_PREFIX));
|
|
8
|
+
const groupState = { ...grid.internal.rowGroupColumnState.get() };
|
|
9
|
+
for (let i = 0; i < groupColumns.length; i++) {
|
|
10
|
+
const column = groupColumns[i];
|
|
11
|
+
if (updates[column.id]) {
|
|
12
|
+
const next = { ...groupState[column.id], ...updates[column.id] };
|
|
13
|
+
groupState[column.id] = next;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
grid.internal.rowGroupColumnState.set(groupState);
|
|
4
17
|
for (let i = 0; i < columns.length; i++) {
|
|
5
18
|
const column = columns[i];
|
|
6
19
|
if (updates[column.id]) {
|
|
@@ -11,7 +11,7 @@ export const makeEditEnd = (grid) => {
|
|
|
11
11
|
return;
|
|
12
12
|
}
|
|
13
13
|
const validation = grid.internal.editValidation.get();
|
|
14
|
-
if (!validation || Object.keys(validation).length
|
|
14
|
+
if (!validation || Object.keys(validation).length >= 1) {
|
|
15
15
|
grid.api.eventFire("editError", {
|
|
16
16
|
column: active.column,
|
|
17
17
|
rowIndex: active.rowIndex,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getDataRect } from "../helpers/get-data-rect.js";
|
|
2
2
|
export const makeExportDataRect = (grid) => {
|
|
3
|
-
return (p) => {
|
|
3
|
+
return async (p) => {
|
|
4
4
|
const s = grid.state;
|
|
5
5
|
const rowCount = s.rowDataStore.rowCount.get();
|
|
6
6
|
const visible = s.columnMeta.get().columnsVisible;
|
|
@@ -4,6 +4,7 @@ interface ColumnHandleGroupColumnArgs<T> {
|
|
|
4
4
|
readonly rowGroupTemplate: RowGroupColumn<T>;
|
|
5
5
|
readonly rowGroupModel: RowGroupModelItem<T>[];
|
|
6
6
|
readonly rowGroupDisplayMode: RowGroupDisplayMode;
|
|
7
|
+
readonly rowGroupColumnState: Record<string, Partial<Column<T>>>;
|
|
7
8
|
}
|
|
8
|
-
export declare function columnAddRowGroup<T>({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, }: ColumnHandleGroupColumnArgs<T>): Column<T>[];
|
|
9
|
+
export declare function columnAddRowGroup<T>({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, rowGroupColumnState, }: ColumnHandleGroupColumnArgs<T>): Column<T>[];
|
|
9
10
|
export {};
|
|
@@ -10,7 +10,7 @@ const baseGroup = {
|
|
|
10
10
|
return d.data.key;
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
|
-
export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, }) {
|
|
13
|
+
export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode, rowGroupTemplate, rowGroupColumnState, }) {
|
|
14
14
|
const lookup = itemsWithIdToMap(columns);
|
|
15
15
|
rowGroupModel.forEach((c) => {
|
|
16
16
|
if (typeof c === "string")
|
|
@@ -62,5 +62,13 @@ export function columnAddRowGroup({ columns, rowGroupModel, rowGroupDisplayMode,
|
|
|
62
62
|
}
|
|
63
63
|
if (!hasGroupColumn)
|
|
64
64
|
columns = columns.filter((c) => !c.id.startsWith(GROUP_COLUMN_PREFIX));
|
|
65
|
+
// TODO: this can be improved - what if the columns are really large?
|
|
66
|
+
const keys = Object.keys(rowGroupColumnState);
|
|
67
|
+
for (let i = 0; i < keys.length; i++) {
|
|
68
|
+
const column = columns.find((c) => c.id === keys[i]);
|
|
69
|
+
if (!column)
|
|
70
|
+
continue;
|
|
71
|
+
Object.assign(column, rowGroupColumnState[keys[i]]);
|
|
72
|
+
}
|
|
65
73
|
return columns;
|
|
66
74
|
}
|
|
@@ -13,7 +13,7 @@ export function columnHandleMarker({ columns, marker, markerEnabled, }) {
|
|
|
13
13
|
widthMin: 24,
|
|
14
14
|
cellRenderer: marker.cellRenderer,
|
|
15
15
|
headerRenderer: marker.headerRenderer ?? HeaderRenderer,
|
|
16
|
-
|
|
16
|
+
floatingCellRenderer: marker.floatingCellRenderer ?? FloatingRenderer,
|
|
17
17
|
uiHints: marker.uiHints,
|
|
18
18
|
},
|
|
19
19
|
...columns,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Column, ColumnMeta } from "../../+types";
|
|
2
2
|
export declare function resolveColumn(c: string | number | Column<any>, errorRef: {
|
|
3
3
|
current: boolean;
|
|
4
|
-
}, meta: ColumnMeta<any>): string | undefined;
|
|
4
|
+
}, meta: ColumnMeta<any>): string | Column<any> | undefined;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { GROUP_COLUMN_PREFIX } from "@1771technologies/lytenyte-shared";
|
|
1
2
|
export function resolveColumn(c, errorRef, meta) {
|
|
2
3
|
if (typeof c === "string") {
|
|
4
|
+
if (c.startsWith(GROUP_COLUMN_PREFIX)) {
|
|
5
|
+
return meta.columnsVisible.find((x) => x.id === c);
|
|
6
|
+
}
|
|
3
7
|
if (!meta.columnLookup.has(c)) {
|
|
4
8
|
errorRef.current = true;
|
|
5
9
|
console.error(`Invalid column ${c}`);
|
|
@@ -14,6 +18,9 @@ export function resolveColumn(c, errorRef, meta) {
|
|
|
14
18
|
}
|
|
15
19
|
return col?.id;
|
|
16
20
|
}
|
|
21
|
+
if (c.id.startsWith(GROUP_COLUMN_PREFIX)) {
|
|
22
|
+
return meta.columnsVisible.find((x) => x.id === c.id);
|
|
23
|
+
}
|
|
17
24
|
if (!meta.columnLookup.has(c.id)) {
|
|
18
25
|
errorRef.current = true;
|
|
19
26
|
console.error(`Invalid column ${c.id}`);
|