@1771technologies/lytenyte-pro 1.0.0-beta.2 → 1.0.0-beta.20
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 +40 -11
- package/dist/cell-selection/adjust-rect-for-row-and-cell-span.d.ts +1 -1
- package/dist/cell-selection/adjust-rect-for-row-and-cell-span.js +1 -1
- package/dist/cell-selection/are-rects-equal.d.ts +1 -1
- package/dist/cell-selection/bound-selection-rect.d.ts +1 -1
- package/dist/cell-selection/cell-selection-driver.js +9 -1
- package/dist/cell-selection/deselect-rect-range.d.ts +1 -1
- package/dist/cell-selection/deselect-rect-range.js +1 -1
- package/dist/cell-selection/expand-cell-selection-down.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-down.js +1 -1
- package/dist/cell-selection/expand-cell-selection-end.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-end.js +1 -1
- package/dist/cell-selection/expand-cell-selection-start.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-start.js +1 -1
- package/dist/cell-selection/expand-cell-selection-up.d.ts +2 -2
- package/dist/cell-selection/expand-cell-selection-up.js +1 -1
- package/dist/cell-selection/full-width-start-end-index.d.ts +1 -1
- package/dist/cell-selection/get-root-cell.d.ts +1 -1
- package/dist/cell-selection/get-root-cell.js +2 -2
- package/dist/cell-selection/is-bottom-rect.d.ts +1 -1
- package/dist/cell-selection/is-center-col-rect.d.ts +1 -1
- package/dist/cell-selection/is-center-rect.d.ts +1 -1
- package/dist/cell-selection/is-end-rect.d.ts +1 -1
- package/dist/cell-selection/is-overlapping-rect.d.ts +1 -1
- package/dist/cell-selection/is-start-rect.d.ts +1 -1
- package/dist/cell-selection/is-top-rect.d.ts +1 -1
- package/dist/cell-selection/is-within-selection-rect.d.ts +1 -1
- package/dist/cell-selection/split-cell-selection-rect.d.ts +1 -1
- package/dist/cell-selection/update-additive-cell-selection.d.ts +2 -2
- package/dist/cell-selection/update-additive-cell-selection.js +4 -6
- package/dist/cell-selection/use-edge-scroll.d.ts +2 -2
- package/dist/cells/cell.js +3 -2
- package/dist/column-manager/branch.js +19 -3
- package/dist/column-manager/label.d.ts +1 -1
- package/dist/column-manager/label.js +2 -2
- package/dist/column-manager/leaf.js +21 -3
- package/dist/column-manager/move-handle.d.ts +1 -1
- package/dist/column-manager/move-handle.js +2 -2
- package/dist/column-manager/root.js +1 -1
- package/dist/column-manager/use-column-manager.d.ts +7 -3
- package/dist/column-manager/use-column-manager.js +3 -3
- package/dist/column-manager/use-columns-from-context.d.ts +2 -2
- package/dist/column-manager/use-columns-from-context.js +1 -1
- package/dist/column-manager/visibility-checkbox.d.ts +1 -1
- package/dist/column-manager/visibility-checkbox.js +2 -2
- package/dist/filter-tree/filter-tree.d.ts +7 -7
- package/dist/filter-tree/filter-tree.js +8 -8
- package/dist/filter-tree/hooks/use-tree-item.d.ts +2 -2
- package/dist/filter-tree/hooks/use-tree-item.js +2 -2
- 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 +3 -3
- package/dist/grid-box/+types.d.ts +5 -3
- package/dist/grid-box/context.d.ts +1 -1
- 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.d.ts +2 -2
- package/dist/grid-box/use-aggregation-box-items.js +3 -1
- package/dist/grid-box/use-column-box-items.d.ts +8 -4
- package/dist/grid-box/use-column-box-items.js +11 -14
- package/dist/grid-box/use-row-group-box-items.d.ts +4 -4
- package/dist/grid-box/use-row-group-box-items.js +14 -15
- package/dist/grid-provider/context.d.ts +2 -2
- package/dist/grid-provider/provider.d.ts +2 -2
- package/dist/grid-provider/provider.js +1 -1
- package/dist/grid-provider/use-grid.d.ts +2 -2
- package/dist/grid-provider/use-grid.js +1 -1
- package/dist/grid.d.ts +1 -12
- package/dist/grid.js +2 -12
- package/dist/header/header-cell.d.ts +1 -1
- package/dist/header/header-cell.js +2 -2
- package/dist/header/resize-handler.d.ts +2 -2
- package/dist/header/resize-handler.js +8 -3
- package/dist/header/use-drag-move.d.ts +2 -2
- package/dist/header/use-drag-move.js +9 -2
- package/dist/header/use-header-cell-renderer.js +3 -3
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/listbox/item.js +1 -1
- package/dist/row-data-source-client/built-ins/built-ins.d.ts +1 -1
- package/dist/row-data-source-client/built-ins/built-ins.js +1 -1
- package/dist/row-data-source-client/filter/compute-filtered-rows.js +1 -1
- package/dist/row-data-source-client/pivots/create-pivot-columns.js +2 -2
- package/dist/row-data-source-client/tree/evaluator-aggregation.d.ts +1 -1
- package/dist/row-data-source-client/tree/evaluator-group.d.ts +1 -1
- package/dist/row-data-source-client/tree/traverse.d.ts +1 -1
- package/dist/row-data-source-client/tree/traverse.js +1 -1
- package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +2 -2
- package/dist/row-data-source-client/use-client-data-source-paginated.js +54 -25
- package/dist/row-data-source-client/use-client-data-source.d.ts +2 -2
- package/dist/row-data-source-client/use-client-data-source.js +56 -27
- package/dist/row-data-source-client/use-client-tree-data-source.d.ts +1 -1
- package/dist/row-data-source-client/use-client-tree-data-source.js +54 -25
- package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.js +1 -1
- package/dist/row-data-source-server/async-tree/make-async-tree.js +3 -3
- package/dist/row-data-source-server/use-server-data-source.d.ts +1 -1
- package/dist/row-data-source-server/use-server-data-source.js +8 -5
- package/dist/sort-manager/context.d.ts +3 -3
- package/dist/sort-manager/hooks/use-sort-manager.d.ts +2 -2
- package/dist/sort-manager/hooks/use-sort-manager.js +2 -2
- package/dist/sort-manager/hooks/use-sort-row-item.d.ts +1 -1
- package/dist/sort-manager/hooks/use-sort-row-item.js +1 -1
- 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/sort-manager/utils/sort-item-to-sort-model.d.ts +1 -1
- package/dist/sort-manager/utils/sort-model-to-sort-items.d.ts +1 -1
- package/dist/state/+types.d.ts +2 -1
- package/dist/state/api/column-autosize.d.ts +1 -1
- package/dist/state/api/column-autosize.js +2 -2
- package/dist/state/api/column-move.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/dialog-frame.d.ts +1 -1
- package/dist/state/api/edit-begin.d.ts +1 -1
- package/dist/state/api/edit-begin.js +1 -1
- package/dist/state/api/edit-end.d.ts +1 -1
- package/dist/state/api/edit-is-cell-active.d.ts +1 -1
- package/dist/state/api/edit-update.d.ts +1 -1
- package/dist/state/api/edit-update.js +1 -1
- package/dist/state/api/export-csv.js +1 -1
- package/dist/state/api/export-data-rect.js +1 -1
- package/dist/state/api/focus-cell.d.ts +1 -1
- package/dist/state/api/popover-frame.d.ts +2 -2
- package/dist/state/api/row-detail-rendered-height.d.ts +2 -2
- 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/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 +5 -0
- package/dist/tree-view/leaf.js +1 -0
- package/package.json +12 -6
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import {} from "../+types";
|
|
1
|
+
import {} from "../+types.js";
|
|
2
2
|
import { useRef } from "react";
|
|
3
3
|
import { atom, createStore } from "@1771technologies/atom";
|
|
4
|
-
import { traverse } from "./tree/traverse";
|
|
4
|
+
import { traverse } from "./tree/traverse.js";
|
|
5
5
|
import { dateComparator, makeGridAtom, numberComparator, stringComparator, } from "@1771technologies/lytenyte-shared";
|
|
6
6
|
import { equal } from "@1771technologies/lytenyte-js-utils";
|
|
7
|
-
import { makeClientTree } from "./tree/client-tree";
|
|
8
|
-
import { computeFilteredRows } from "./filter/compute-filtered-rows";
|
|
9
|
-
import { builtIns } from "./built-ins/built-ins";
|
|
7
|
+
import { makeClientTree } from "./tree/client-tree.js";
|
|
8
|
+
import { computeFilteredRows } from "./filter/compute-filtered-rows.js";
|
|
9
|
+
import { builtIns } from "./built-ins/built-ins.js";
|
|
10
10
|
export function makeClientTreeDataSource(p) {
|
|
11
11
|
const rdsStore = createStore();
|
|
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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getParentNodeByPath } from "./get-parent-node-by-path";
|
|
1
|
+
import { getParentNodeByPath } from "./get-parent-node-by-path.js";
|
|
2
2
|
export function applyDeleteActionToTree(p, tree) {
|
|
3
3
|
// No op. We aren't deleting keys or indices
|
|
4
4
|
if (!p.relIndices?.length && !p.paths?.length)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { applyDeleteActionToTree } from "./apply-delete-action-to-tree";
|
|
2
|
-
import { applySetActionToTree } from "./apply-set-action-to-tree";
|
|
3
|
-
import { getParentNodeByPath } from "./get-parent-node-by-path";
|
|
1
|
+
import { applyDeleteActionToTree } from "./apply-delete-action-to-tree.js";
|
|
2
|
+
import { applySetActionToTree } from "./apply-set-action-to-tree.js";
|
|
3
|
+
import { getParentNodeByPath } from "./get-parent-node-by-path.js";
|
|
4
4
|
export function makeAsyncTree() {
|
|
5
5
|
const tree = {
|
|
6
6
|
kind: "root",
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { RowDataSourceServer, RowDataSourceServerParams } from "../+types";
|
|
1
|
+
import type { RowDataSourceServer, RowDataSourceServerParams } from "../+types.js";
|
|
2
2
|
export declare function makeServerDataSource<T>({ dataFetcher, dataColumnPivotFetcher, dataInFilterItemFetcher, cellUpdateHandler, cellUpdateOptimistically, blockSize, }: RowDataSourceServerParams<T>): RowDataSourceServer<T>;
|
|
3
3
|
export declare function useServerDataSource<T>(p: RowDataSourceServerParams<T>): RowDataSourceServer<T>;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { atom, createStore } from "@1771technologies/atom";
|
|
2
2
|
import { useRef } from "react";
|
|
3
|
-
import { makeAsyncTree } from "./async-tree/make-async-tree";
|
|
3
|
+
import { makeAsyncTree } from "./async-tree/make-async-tree.js";
|
|
4
4
|
import { makeGridAtom } from "@1771technologies/lytenyte-shared";
|
|
5
|
-
import { getNodeDepth } from "./utils/get-node-depth";
|
|
6
|
-
import { getRequestId } from "./utils/get-request-id";
|
|
7
|
-
import { RangeTree } from "./range-tree/range-tree";
|
|
8
|
-
import { getNodePath } from "./utils/get-node-path";
|
|
5
|
+
import { getNodeDepth } from "./utils/get-node-depth.js";
|
|
6
|
+
import { getRequestId } from "./utils/get-request-id.js";
|
|
7
|
+
import { RangeTree } from "./range-tree/range-tree.js";
|
|
8
|
+
import { getNodePath } from "./utils/get-node-path.js";
|
|
9
9
|
import { equal } from "@1771technologies/lytenyte-js-utils";
|
|
10
10
|
export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, dataInFilterItemFetcher, cellUpdateHandler, cellUpdateOptimistically = true, blockSize = 200, }) {
|
|
11
11
|
let grid = null;
|
|
@@ -651,6 +651,9 @@ export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, data
|
|
|
651
651
|
rowSelect,
|
|
652
652
|
rowSelectAll,
|
|
653
653
|
rowSetBotData,
|
|
654
|
+
rowSetCenterData: () => {
|
|
655
|
+
throw new Error("Server side data source does not support full row updates");
|
|
656
|
+
},
|
|
654
657
|
rowSetTopData,
|
|
655
658
|
rowToIndex,
|
|
656
659
|
rowUpdate,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type Dispatch, type SetStateAction } from "react";
|
|
2
|
-
import type { SortItem } from "./+types";
|
|
3
|
-
import type { SortRowItem } from "./hooks/use-sort-row-item";
|
|
4
|
-
import type { Grid } from "../+types";
|
|
2
|
+
import type { SortItem } from "./+types.js";
|
|
3
|
+
import type { SortRowItem } from "./hooks/use-sort-row-item.js";
|
|
4
|
+
import type { Grid } from "../+types.js";
|
|
5
5
|
export interface SortManagerContext {
|
|
6
6
|
readonly grid: Grid<any>;
|
|
7
7
|
readonly sortItems: SortItem[];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Grid } from "../../+types";
|
|
2
|
-
import type { SortItem } from "../+types";
|
|
2
|
+
import type { SortItem } from "../+types.js";
|
|
3
3
|
export interface UseSortManagerArgs<T> {
|
|
4
4
|
readonly grid: Grid<T>;
|
|
5
5
|
readonly pivotMode?: boolean;
|
|
@@ -11,5 +11,5 @@ export declare function useSortManager<T>({ grid, pivotMode }: UseSortManagerArg
|
|
|
11
11
|
mode: boolean;
|
|
12
12
|
grid: Grid<T>;
|
|
13
13
|
};
|
|
14
|
-
rows: import("./use-sort-row-item").SortRowItem[];
|
|
14
|
+
rows: import("./use-sort-row-item.js").SortRowItem[];
|
|
15
15
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
-
import { sortModelToSortItems } from "../utils/sort-model-to-sort-items";
|
|
2
|
+
import { sortModelToSortItems } from "../utils/sort-model-to-sort-items.js";
|
|
3
3
|
import { itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
4
|
-
import { useSortRowItems } from "./use-sort-row-item";
|
|
4
|
+
import { useSortRowItems } from "./use-sort-row-item.js";
|
|
5
5
|
import { useEvent } from "@1771technologies/lytenyte-react-hooks";
|
|
6
6
|
export function useSortManager({ grid, pivotMode }) {
|
|
7
7
|
const statePivotMode = grid.state.columnPivotMode.useValue();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useMemo } from "react";
|
|
2
|
-
import { useSortableColumnItems } from "./use-sortable-column-items";
|
|
2
|
+
import { useSortableColumnItems } from "./use-sortable-column-items.js";
|
|
3
3
|
import { itemsWithIdToMap } from "@1771technologies/lytenyte-js-utils";
|
|
4
4
|
export function useSortRowItems(sortItems, setSortItems, grid, pivotMode) {
|
|
5
5
|
const columnItems = useSortableColumnItems(grid, pivotMode);
|
|
@@ -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,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { SortItem } from "../+types";
|
|
1
|
+
import type { SortItem } from "../+types.js";
|
|
2
2
|
import type { Column, SortModelItem } from "../../+types";
|
|
3
3
|
export declare function sortItemsToSortModel(sortItems: SortItem[], lookup: Map<string, Column<any>>): SortModelItem<any>[];
|
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, {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { measureText } from "@1771technologies/lytenyte-shared";
|
|
2
|
-
import { resolveColumn } from "../helpers/resolve-column";
|
|
2
|
+
import { resolveColumn } from "../helpers/resolve-column.js";
|
|
3
3
|
export const makeColumnAutosize = (grid) => {
|
|
4
4
|
return (params) => {
|
|
5
5
|
const errorRef = { current: false };
|
|
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,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]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { focusCell, isFullWidthMap } from "@1771technologies/lytenyte-shared";
|
|
2
2
|
import { runWithBackoff } from "@1771technologies/lytenyte-js-utils";
|
|
3
|
-
import { editOnChange } from "../helpers/edit-on-change";
|
|
3
|
+
import { editOnChange } from "../helpers/edit-on-change.js";
|
|
4
4
|
export const makeEditBegin = (grid) => {
|
|
5
5
|
return (params) => {
|
|
6
6
|
if (grid.state.editCellMode.get() === "readonly" || grid.state.columnPivotMode.get())
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { editOnChange } from "../helpers/edit-on-change";
|
|
1
|
+
import { editOnChange } from "../helpers/edit-on-change.js";
|
|
2
2
|
export const makeEditUpdate = (grid) => {
|
|
3
3
|
return (params) => {
|
|
4
4
|
if (grid.state.editCellMode.get() === "readonly" || grid.state.columnPivotMode.get())
|