@1771technologies/lytenyte-pro 1.0.0-beta.36 → 1.0.0-beta.38
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 +4469 -4219
- package/dist/cell-selection/adjust-rect-for-row-and-cell-span.js +38 -38
- package/dist/cell-selection/are-rects-equal.js +4 -6
- package/dist/cell-selection/bound-selection-rect.js +14 -14
- package/dist/cell-selection/cell-selection-containers.js +78 -108
- package/dist/cell-selection/cell-selection-driver.js +262 -250
- package/dist/cell-selection/cell-style-row.d.ts +6 -12
- package/dist/cell-selection/cell-style-row.js +79 -82
- package/dist/cell-selection/deselect-rect-range.js +40 -41
- package/dist/cell-selection/expand-cell-selection-down.d.ts +2 -5
- package/dist/cell-selection/expand-cell-selection-down.js +33 -29
- package/dist/cell-selection/expand-cell-selection-end.d.ts +2 -5
- package/dist/cell-selection/expand-cell-selection-end.js +34 -30
- package/dist/cell-selection/expand-cell-selection-start.d.ts +2 -5
- package/dist/cell-selection/expand-cell-selection-start.js +33 -29
- package/dist/cell-selection/expand-cell-selection-up.d.ts +2 -5
- package/dist/cell-selection/expand-cell-selection-up.js +33 -29
- package/dist/cell-selection/full-width-start-end-index.js +3 -3
- package/dist/cell-selection/get-root-cell.d.ts +1 -5
- package/dist/cell-selection/get-root-cell.js +79 -77
- package/dist/cell-selection/is-bottom-rect.js +5 -5
- package/dist/cell-selection/is-center-col-rect.d.ts +2 -5
- package/dist/cell-selection/is-center-col-rect.js +3 -5
- package/dist/cell-selection/is-center-rect.js +3 -3
- package/dist/cell-selection/is-end-rect.d.ts +2 -5
- package/dist/cell-selection/is-end-rect.js +2 -2
- package/dist/cell-selection/is-overlapping-rect.js +4 -6
- package/dist/cell-selection/is-start-rect.d.ts +2 -5
- package/dist/cell-selection/is-start-rect.js +2 -2
- package/dist/cell-selection/is-top-rect.js +2 -2
- package/dist/cell-selection/is-within-selection-rect.js +1 -1
- package/dist/cell-selection/split-cell-selection-rect.d.ts +6 -12
- package/dist/cell-selection/split-cell-selection-rect.js +47 -53
- package/dist/cell-selection/update-additive-cell-selection.d.ts +2 -5
- package/dist/cell-selection/update-additive-cell-selection.js +17 -16
- package/dist/cell-selection/use-edge-scroll.d.ts +6 -8
- package/dist/cell-selection/use-edge-scroll.js +63 -65
- package/dist/cells/cell-default.d.ts +1 -5
- package/dist/cells/cell-default.js +5 -5
- package/dist/cells/cell-editor.d.ts +2 -4
- package/dist/cells/cell-editor.js +92 -129
- package/dist/cells/cell.d.ts +3 -16
- package/dist/cells/cell.js +27 -56
- package/dist/column-manager/branch-lookup-context.d.ts +1 -3
- package/dist/column-manager/branch.d.ts +9 -17
- package/dist/column-manager/branch.js +46 -64
- package/dist/column-manager/column-manager.d.ts +8 -57
- package/dist/column-manager/column-manager.js +8 -8
- package/dist/column-manager/context.d.ts +1 -1
- package/dist/column-manager/label.d.ts +2 -10
- package/dist/column-manager/label.js +12 -11
- package/dist/column-manager/leaf.d.ts +2 -10
- package/dist/column-manager/leaf.js +49 -61
- package/dist/column-manager/move-handle.d.ts +6 -14
- package/dist/column-manager/move-handle.js +48 -52
- package/dist/column-manager/panel.d.ts +1 -10
- package/dist/column-manager/root.d.ts +3 -7
- package/dist/column-manager/root.js +1 -4
- package/dist/column-manager/use-column-manager.d.ts +5 -7
- package/dist/column-manager/use-column-manager.js +21 -15
- package/dist/column-manager/use-columns-from-context.d.ts +1 -3
- package/dist/column-manager/use-columns-from-context.js +18 -18
- package/dist/column-manager/visibility-checkbox.d.ts +6 -14
- package/dist/column-manager/visibility-checkbox.js +23 -36
- package/dist/context.d.ts +4 -4
- package/dist/filter-tree/branch.d.ts +8 -16
- package/dist/filter-tree/branch.js +13 -23
- package/dist/filter-tree/context.d.ts +16 -16
- package/dist/filter-tree/filter-tree.d.ts +8 -49
- package/dist/filter-tree/filter-tree.js +8 -8
- package/dist/filter-tree/hooks/use-filter-tree.d.ts +29 -35
- package/dist/filter-tree/hooks/use-filter-tree.js +92 -94
- package/dist/filter-tree/hooks/use-tree-item.d.ts +4 -4
- package/dist/filter-tree/hooks/use-tree-item.js +106 -99
- package/dist/filter-tree/inclusion-checkbox.d.ts +6 -14
- package/dist/filter-tree/inclusion-checkbox.js +9 -19
- package/dist/filter-tree/label.d.ts +2 -10
- package/dist/filter-tree/label.js +12 -11
- package/dist/filter-tree/leaf.d.ts +2 -10
- package/dist/filter-tree/leaf.js +5 -15
- package/dist/filter-tree/root.d.ts +7 -23
- package/dist/filter-tree/root.js +23 -51
- package/dist/grid-box/+types.d.ts +11 -11
- package/dist/grid-box/context.d.ts +3 -3
- package/dist/grid-box/grid-box.d.ts +6 -26
- package/dist/grid-box/grid-box.js +6 -6
- package/dist/grid-box/item.d.ts +5 -13
- package/dist/grid-box/item.js +56 -73
- package/dist/grid-box/panel.d.ts +1 -13
- package/dist/grid-box/panel.js +2 -9
- package/dist/grid-box/root.d.ts +5 -11
- package/dist/grid-box/root.js +2 -11
- package/dist/grid-box/use-aggregation-box-items.d.ts +13 -16
- package/dist/grid-box/use-aggregation-box-items.js +57 -56
- package/dist/grid-box/use-column-box-items.d.ts +23 -33
- package/dist/grid-box/use-column-box-items.js +75 -87
- package/dist/grid-box/use-row-group-box-items.d.ts +12 -17
- package/dist/grid-box/use-row-group-box-items.js +123 -120
- package/dist/grid-provider/context.d.ts +2 -4
- package/dist/grid-provider/provider.d.ts +2 -4
- package/dist/grid-provider/use-grid.d.ts +1 -1
- package/dist/grid.d.ts +14 -126
- package/dist/grid.js +14 -14
- package/dist/header/header-cell.d.ts +5 -13
- package/dist/header/header-cell.js +15 -41
- package/dist/header/header-group-cell.d.ts +2 -10
- package/dist/header/header-group-cell.js +8 -26
- package/dist/header/header-row.d.ts +2 -10
- package/dist/header/header-row.js +2 -2
- package/dist/header/header.d.ts +1 -10
- package/dist/header/header.js +2 -11
- package/dist/header/resize-handler.d.ts +6 -15
- package/dist/header/resize-handler.js +122 -131
- package/dist/header/use-drag-move.d.ts +11 -22
- package/dist/header/use-drag-move.js +94 -95
- package/dist/header/use-header-cell-renderer.d.ts +2 -9
- package/dist/header/use-header-cell-renderer.js +29 -25
- package/dist/icons/index.d.ts +1 -92
- package/dist/icons/index.js +1 -92
- package/dist/index.d.ts +5 -22
- package/dist/index.js +5 -22
- package/dist/license.js +174 -174
- package/dist/listbox/context.d.ts +2 -2
- package/dist/listbox/item.d.ts +1 -10
- package/dist/listbox/item.js +19 -23
- package/dist/listbox/panel.d.ts +1 -10
- package/dist/listbox/panel.js +43 -69
- package/dist/listbox/root.d.ts +3 -5
- package/dist/listbox/root.js +7 -7
- package/dist/root/dialog-driver.js +16 -22
- package/dist/root/popover-driver.js +16 -27
- package/dist/root/root.d.ts +3 -7
- package/dist/root/root.js +107 -111
- package/dist/row-data-source-client/+types.d.ts +17 -17
- package/dist/row-data-source-client/built-ins/avg.js +4 -3
- package/dist/row-data-source-client/built-ins/built-ins.d.ts +16 -16
- package/dist/row-data-source-client/built-ins/built-ins.js +16 -16
- package/dist/row-data-source-client/built-ins/count.js +5 -3
- package/dist/row-data-source-client/built-ins/first.js +1 -1
- package/dist/row-data-source-client/built-ins/group.js +1 -1
- package/dist/row-data-source-client/built-ins/last.js +1 -1
- package/dist/row-data-source-client/built-ins/max.js +13 -9
- package/dist/row-data-source-client/built-ins/min.js +13 -9
- package/dist/row-data-source-client/built-ins/sum.js +10 -8
- package/dist/row-data-source-client/filter/+types.d.ts +13 -35
- package/dist/row-data-source-client/filter/compute-filtered-rows.d.ts +2 -16
- package/dist/row-data-source-client/filter/compute-filtered-rows.js +102 -102
- package/dist/row-data-source-client/pivots/create-agg-model.d.ts +4 -8
- package/dist/row-data-source-client/pivots/create-agg-model.js +9 -8
- package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.d.ts +1 -6
- package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.js +46 -42
- package/dist/row-data-source-client/pivots/create-pivot-columns.d.ts +1 -6
- package/dist/row-data-source-client/pivots/create-pivot-columns.js +17 -16
- package/dist/row-data-source-client/pivots/create-pivot-tree.d.ts +1 -7
- package/dist/row-data-source-client/pivots/create-pivot-tree.js +19 -19
- package/dist/row-data-source-client/tree/client-tree.d.ts +13 -19
- package/dist/row-data-source-client/tree/client-tree.js +67 -64
- package/dist/row-data-source-client/tree/evaluator-aggregation.d.ts +1 -4
- package/dist/row-data-source-client/tree/evaluator-aggregation.js +6 -6
- package/dist/row-data-source-client/tree/evaluator-group.d.ts +1 -4
- package/dist/row-data-source-client/tree/evaluator-group.js +7 -6
- package/dist/row-data-source-client/tree/traverse.d.ts +1 -5
- package/dist/row-data-source-client/tree/traverse.js +18 -15
- package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +5 -9
- package/dist/row-data-source-client/use-client-data-source-paginated.js +551 -566
- package/dist/row-data-source-client/use-client-data-source.d.ts +5 -9
- package/dist/row-data-source-client/use-client-data-source.js +661 -696
- package/dist/row-data-source-client/use-client-tree-data-source.d.ts +5 -9
- package/dist/row-data-source-client/use-client-tree-data-source.js +512 -523
- package/dist/row-data-source-server/async-tree/+types.async-tree.d.ts +33 -36
- package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.d.ts +1 -4
- package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.js +22 -18
- package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.d.ts +1 -4
- package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.js +25 -17
- package/dist/row-data-source-server/async-tree/check-set-action-item-keys-are-unique.js +18 -18
- package/dist/row-data-source-server/async-tree/check-set-action-item-keys-are-valid.js +10 -9
- package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.d.ts +1 -4
- package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.js +14 -13
- package/dist/row-data-source-server/async-tree/check-set-action-item-kinds.js +10 -9
- package/dist/row-data-source-server/async-tree/get-parent-node-by-path.d.ts +1 -4
- package/dist/row-data-source-server/async-tree/get-parent-node-by-path.js +13 -13
- package/dist/row-data-source-server/async-tree/is-set-action-a-no-op-on-node.d.ts +1 -4
- package/dist/row-data-source-server/async-tree/is-set-action-a-no-op-on-node.js +1 -1
- package/dist/row-data-source-server/async-tree/make-async-tree.js +14 -14
- package/dist/row-data-source-server/async-tree/maybe-apply-parent-remove-self.d.ts +1 -3
- package/dist/row-data-source-server/async-tree/maybe-apply-parent-remove-self.js +6 -6
- package/dist/row-data-source-server/async-tree/maybe-apply-resize.d.ts +1 -5
- package/dist/row-data-source-server/async-tree/maybe-apply-resize.js +14 -11
- package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.d.ts +1 -4
- package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.js +46 -42
- package/dist/row-data-source-server/range-tree/range-tree.d.ts +28 -28
- package/dist/row-data-source-server/range-tree/range-tree.js +48 -49
- package/dist/row-data-source-server/use-server-data-source.d.ts +2 -11
- package/dist/row-data-source-server/use-server-data-source.js +675 -688
- package/dist/row-data-source-server/utils/get-node-depth.js +7 -7
- package/dist/row-data-source-server/utils/get-node-path.js +7 -7
- package/dist/row-data-source-server/utils/get-request-id.js +4 -3
- package/dist/rows/row/context.d.ts +2 -2
- package/dist/rows/row/row.d.ts +3 -16
- package/dist/rows/row/row.js +4 -19
- package/dist/rows/row/use-row-context-value.d.ts +2 -5
- package/dist/rows/row/use-row-context-value.js +26 -23
- package/dist/rows/row-detail-row.d.ts +2 -4
- package/dist/rows/row-detail-row.js +124 -147
- package/dist/rows/row-full-width.d.ts +4 -12
- package/dist/rows/row-full-width.js +7 -35
- package/dist/rows/rows-container.d.ts +1 -10
- package/dist/rows/rows-container.js +3 -12
- package/dist/rows/rows-sections.d.ts +3 -30
- package/dist/rows/rows-sections.js +10 -42
- package/dist/rows/scrollers/native-scroller.d.ts +1 -3
- package/dist/rows/scrollers/native-scroller.js +13 -17
- package/dist/sort-manager/+types.d.ts +7 -14
- package/dist/sort-manager/context.d.ts +4 -4
- package/dist/sort-manager/hooks/use-sort-manager.d.ts +9 -9
- package/dist/sort-manager/hooks/use-sort-manager.js +49 -45
- package/dist/sort-manager/hooks/use-sort-row-item.d.ts +46 -57
- package/dist/sort-manager/hooks/use-sort-row-item.js +131 -126
- package/dist/sort-manager/hooks/use-sortable-column-items.d.ts +3 -6
- package/dist/sort-manager/hooks/use-sortable-column-items.js +10 -10
- package/dist/sort-manager/root.d.ts +1 -7
- package/dist/sort-manager/root.js +10 -10
- package/dist/sort-manager/sort-add.d.ts +5 -13
- package/dist/sort-manager/sort-add.js +8 -8
- package/dist/sort-manager/sort-apply.d.ts +4 -12
- package/dist/sort-manager/sort-apply.js +16 -16
- package/dist/sort-manager/sort-cancel.d.ts +4 -12
- package/dist/sort-manager/sort-cancel.js +19 -19
- package/dist/sort-manager/sort-clear.d.ts +4 -12
- package/dist/sort-manager/sort-clear.js +16 -15
- package/dist/sort-manager/sort-column-select.d.ts +6 -14
- package/dist/sort-manager/sort-column-select.js +14 -22
- package/dist/sort-manager/sort-direction-select.d.ts +6 -14
- package/dist/sort-manager/sort-direction-select.js +19 -27
- package/dist/sort-manager/sort-manager.d.ts +12 -93
- package/dist/sort-manager/sort-manager.js +12 -12
- package/dist/sort-manager/sort-remove.d.ts +4 -12
- package/dist/sort-manager/sort-remove.js +8 -8
- package/dist/sort-manager/sort-row.d.ts +2 -10
- package/dist/sort-manager/sort-row.js +1 -4
- package/dist/sort-manager/sort-rows.d.ts +1 -10
- package/dist/sort-manager/sort-rows.js +1 -1
- package/dist/sort-manager/sort-value-select.d.ts +7 -15
- package/dist/sort-manager/sort-value-select.js +19 -28
- package/dist/sort-manager/utils/sort-item-to-sort-model.d.ts +1 -4
- package/dist/sort-manager/utils/sort-item-to-sort-model.js +49 -46
- package/dist/sort-manager/utils/sort-model-to-sort-items.d.ts +1 -4
- package/dist/sort-manager/utils/sort-model-to-sort-items.js +44 -36
- package/dist/state/+types.d.ts +29 -43
- package/dist/state/api/column-autosize.d.ts +2 -4
- package/dist/state/api/column-autosize.js +63 -62
- package/dist/state/api/column-by-id.js +4 -4
- package/dist/state/api/column-field.js +20 -17
- package/dist/state/api/column-from-index.js +4 -4
- package/dist/state/api/column-group-toggle.js +8 -8
- package/dist/state/api/column-index.js +5 -5
- package/dist/state/api/column-move.js +46 -48
- package/dist/state/api/column-resize.js +7 -9
- package/dist/state/api/column-update.d.ts +2 -4
- package/dist/state/api/column-update.js +23 -23
- package/dist/state/api/dialog-frame.d.ts +4 -8
- package/dist/state/api/dialog-frame.js +12 -11
- package/dist/state/api/edit-begin.d.ts +2 -4
- package/dist/state/api/edit-begin.js +84 -71
- package/dist/state/api/edit-end.d.ts +2 -4
- package/dist/state/api/edit-end.js +41 -38
- package/dist/state/api/edit-is-cell-active.d.ts +2 -4
- package/dist/state/api/edit-is-cell-active.js +24 -17
- package/dist/state/api/edit-update.d.ts +2 -4
- package/dist/state/api/edit-update.js +85 -74
- package/dist/state/api/event-listeners.d.ts +3 -12
- package/dist/state/api/event-listeners.js +17 -16
- package/dist/state/api/export-csv.js +35 -33
- package/dist/state/api/export-data-rect.js +21 -21
- package/dist/state/api/focus-cell.d.ts +2 -4
- package/dist/state/api/focus-cell.js +109 -110
- package/dist/state/api/popover-frame.d.ts +4 -8
- package/dist/state/api/popover-frame.js +12 -11
- package/dist/state/api/position-from-element.js +6 -5
- package/dist/state/api/row-by-id.js +3 -3
- package/dist/state/api/row-by-index.js +6 -11
- package/dist/state/api/row-detail-is-expanded.d.ts +1 -3
- package/dist/state/api/row-detail-is-expanded.js +4 -4
- package/dist/state/api/row-detail-rendered-height.d.ts +2 -4
- package/dist/state/api/row-detail-rendered-height.js +12 -10
- package/dist/state/api/row-detail-toggle.js +30 -26
- package/dist/state/api/row-group-apply-expansions.d.ts +1 -3
- package/dist/state/api/row-group-apply-expansions.js +17 -15
- package/dist/state/api/row-group-column-index.d.ts +1 -3
- package/dist/state/api/row-group-column-index.js +12 -14
- package/dist/state/api/row-group-is-expanded.d.ts +1 -3
- package/dist/state/api/row-group-is-expanded.js +13 -11
- package/dist/state/api/row-group-toggle.js +5 -5
- package/dist/state/api/row-handle-select.d.ts +2 -4
- package/dist/state/api/row-handle-select.js +40 -36
- package/dist/state/api/row-select-all.js +15 -14
- package/dist/state/api/row-select.d.ts +2 -4
- package/dist/state/api/row-select.js +33 -30
- package/dist/state/api/row-selected.js +11 -10
- package/dist/state/api/scroll-into-view.d.ts +2 -4
- package/dist/state/api/scroll-into-view.js +47 -47
- package/dist/state/api/sort-for-column.js +7 -6
- package/dist/state/api/use-row-drag.js +24 -22
- package/dist/state/helpers/cell-row-group.d.ts +1 -5
- package/dist/state/helpers/cell-row-group.js +16 -18
- package/dist/state/helpers/column-add-row-group.d.ts +7 -18
- package/dist/state/helpers/column-add-row-group.js +66 -71
- package/dist/state/helpers/column-layout.d.ts +1 -7
- package/dist/state/helpers/column-layout.js +60 -60
- package/dist/state/helpers/column-marker.d.ts +4 -8
- package/dist/state/helpers/column-marker.js +34 -38
- package/dist/state/helpers/column-view.d.ts +15 -21
- package/dist/state/helpers/column-view.js +32 -56
- package/dist/state/helpers/edit-on-change.d.ts +10 -18
- package/dist/state/helpers/edit-on-change.js +25 -25
- package/dist/state/helpers/empty-row-data-source.js +16 -16
- package/dist/state/helpers/get-data-rect.d.ts +10 -20
- package/dist/state/helpers/get-data-rect.js +62 -67
- package/dist/state/helpers/get-full-width-callback.d.ts +1 -5
- package/dist/state/helpers/get-full-width-callback.js +6 -5
- package/dist/state/helpers/get-span-callback.d.ts +1 -6
- package/dist/state/helpers/get-span-callback.js +18 -15
- package/dist/state/helpers/resolve-column.d.ts +2 -6
- package/dist/state/helpers/resolve-column.js +23 -23
- package/dist/state/helpers/row-layout/get-focus-criteria.d.ts +12 -15
- package/dist/state/helpers/row-layout/get-focus-criteria.js +56 -57
- package/dist/state/helpers/row-layout/row-layout.d.ts +9 -15
- package/dist/state/helpers/row-layout/row-layout.js +401 -387
- package/dist/state/use-lytenyte.js +528 -567
- package/dist/tree-view/branch/branch.d.ts +11 -19
- package/dist/tree-view/branch/branch.js +54 -106
- package/dist/tree-view/branch/use-branch-keys.d.ts +1 -5
- package/dist/tree-view/branch/use-branch-keys.js +74 -71
- package/dist/tree-view/context.d.ts +17 -21
- package/dist/tree-view/hooks/use-tree-view-paths.d.ts +1 -7
- package/dist/tree-view/hooks/use-tree-view-paths.js +5 -5
- package/dist/tree-view/index.d.ts +7 -35
- package/dist/tree-view/index.js +7 -7
- package/dist/tree-view/leaf.d.ts +2 -10
- package/dist/tree-view/leaf.js +21 -30
- package/dist/tree-view/navigation/get-all-ids.js +3 -3
- package/dist/tree-view/navigation/get-first-node.js +3 -3
- package/dist/tree-view/navigation/get-last-node.js +3 -3
- package/dist/tree-view/navigation/get-next-node.js +8 -6
- package/dist/tree-view/navigation/get-prev-node.js +8 -6
- package/dist/tree-view/panel/make-handle-navigation.js +31 -23
- package/dist/tree-view/panel/make-handle-selection.js +77 -68
- package/dist/tree-view/panel/make-handle-typeahead.js +40 -34
- package/dist/tree-view/panel/panel.d.ts +1 -10
- package/dist/tree-view/panel/panel.js +20 -40
- package/dist/tree-view/panel/use-tree-navigation.js +52 -64
- package/dist/tree-view/root.d.ts +14 -20
- package/dist/tree-view/root.js +55 -53
- package/dist/tree-view/utils/get-focusable-nodes.js +2 -4
- package/dist/tree-view/utils/get-focused-node.js +11 -11
- package/dist/tree-view/utils/get-ids-between-nodes.d.ts +1 -5
- package/dist/tree-view/utils/get-ids-between-nodes.js +11 -10
- package/dist/tree-view/utils/get-panel.js +5 -5
- package/dist/tree-view/utils/get-parent-node.js +7 -6
- package/dist/tree-view/utils/get-sibling-branches.js +10 -8
- package/dist/tree-view/utils/get-tree-node-id.js +1 -1
- package/dist/tree-view/utils/is-branch-node.js +1 -1
- package/dist/tree-view/utils/is-leaf-node.js +1 -1
- package/dist/tree-view/utils/is-tree-node-disabled.js +1 -1
- package/dist/tree-view/utils/select-node.d.ts +1 -5
- package/dist/tree-view/utils/select-node.js +11 -8
- package/dist/tree-view/utils/toggle-all-selections.js +6 -4
- package/dist/tree-view/utils/toggle-selection.js +18 -15
- package/dist/tree-view/virtualized/force-sync-scrolling.d.ts +1 -3
- package/dist/tree-view/virtualized/force-sync-scrolling.js +18 -24
- package/dist/tree-view/virtualized/get-virtual-tree-paths.d.ts +1 -3
- package/dist/tree-view/virtualized/get-virtual-tree-paths.js +12 -11
- package/dist/tree-view/virtualized/make-virtual-tree.d.ts +21 -26
- package/dist/tree-view/virtualized/make-virtual-tree.js +85 -79
- package/dist/tree-view/virtualized/use-flattened-tree.d.ts +8 -17
- package/dist/tree-view/virtualized/use-flattened-tree.js +31 -30
- package/dist/tree-view/virtualized/use-row-start-and-end.d.ts +1 -6
- package/dist/tree-view/virtualized/use-row-start-and-end.js +23 -21
- package/dist/tree-view/virtualized/use-virtualized-tree.d.ts +15 -21
- package/dist/tree-view/virtualized/use-virtualized-tree.js +90 -103
- package/dist/utils/cycle-sorts.js +14 -12
- package/dist/viewport/begin-editing.d.ts +2 -6
- package/dist/viewport/begin-editing.js +13 -9
- package/dist/viewport/viewport.d.ts +1 -10
- package/dist/viewport/viewport.js +70 -93
- package/main.css +4 -4
- package/package.json +7 -7
|
@@ -7,712 +7,699 @@ import { getRequestId } from "./utils/get-request-id.js";
|
|
|
7
7
|
import { RangeTree } from "./range-tree/range-tree.js";
|
|
8
8
|
import { getNodePath } from "./utils/get-node-path.js";
|
|
9
9
|
import { equal } from "@1771technologies/lytenyte-js-utils";
|
|
10
|
-
export function makeServerDataSource({
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
columns: [],
|
|
41
|
-
filters: {},
|
|
42
|
-
filtersIn: {},
|
|
43
|
-
rows: [],
|
|
44
|
-
sorts: [],
|
|
45
|
-
values: [],
|
|
46
|
-
},
|
|
47
|
-
});
|
|
48
|
-
const model = makeGridAtom(model$, rdsStore);
|
|
49
|
-
const pivotGroupExpansions = atom((g) => g(model$).pivotGroupExpansions);
|
|
50
|
-
const rowGroupExpansions = atom((g) => g(model$).groupExpansions);
|
|
51
|
-
const pivotMode = atom((g) => g(model$).pivotMode);
|
|
52
|
-
const topData = atom([]);
|
|
53
|
-
const botData = atom([]);
|
|
54
|
-
const seenRequests = new Set();
|
|
55
|
-
const dataResponseHandler = (res) => {
|
|
56
|
-
const t = tree.get();
|
|
57
|
-
const dataResponses = res.filter((r) => {
|
|
58
|
-
return !("kind" in r && (r.kind === "top" || r.kind === "bottom"));
|
|
10
|
+
export function makeServerDataSource({ dataFetcher, dataColumnPivotFetcher, dataInFilterItemFetcher, cellUpdateHandler, cellUpdateOptimistically = true, blockSize = 200, }) {
|
|
11
|
+
let grid = null;
|
|
12
|
+
const snapshot$ = atom(Date.now());
|
|
13
|
+
const rdsStore = createStore();
|
|
14
|
+
const tree$ = atom(makeAsyncTree());
|
|
15
|
+
const tree = makeGridAtom(tree$, rdsStore);
|
|
16
|
+
const isLoading$ = atom(false);
|
|
17
|
+
const isLoading = makeGridAtom(isLoading$, rdsStore);
|
|
18
|
+
const error$ = atom();
|
|
19
|
+
const loadError = makeGridAtom(error$, rdsStore);
|
|
20
|
+
const nodesWithError = atom(new Map());
|
|
21
|
+
const initialized = atom(false);
|
|
22
|
+
const model$ = atom({
|
|
23
|
+
sorts: [],
|
|
24
|
+
filters: {},
|
|
25
|
+
filtersIn: {},
|
|
26
|
+
quickSearch: null,
|
|
27
|
+
group: [],
|
|
28
|
+
groupExpansions: {},
|
|
29
|
+
aggregations: {},
|
|
30
|
+
pivotGroupExpansions: {},
|
|
31
|
+
pivotMode: false,
|
|
32
|
+
pivotModel: {
|
|
33
|
+
columns: [],
|
|
34
|
+
filters: {},
|
|
35
|
+
filtersIn: {},
|
|
36
|
+
rows: [],
|
|
37
|
+
sorts: [],
|
|
38
|
+
values: [],
|
|
39
|
+
},
|
|
59
40
|
});
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
requests: p,
|
|
118
|
-
});
|
|
119
|
-
dataResponseHandler(res);
|
|
120
|
-
onSuccess?.();
|
|
121
|
-
} catch (e) {
|
|
122
|
-
// Mark them as unseen since the request failed.
|
|
123
|
-
unseen.forEach((x) => seenRequests.delete(x.id));
|
|
124
|
-
onFailure?.(e);
|
|
125
|
-
console.error(e);
|
|
126
|
-
} finally {
|
|
127
|
-
rdsStore.set(snapshot$, Date.now());
|
|
128
|
-
grid.state.rowDataStore.rowClearCache();
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
const viewChange = () => {
|
|
132
|
-
if (!grid) return;
|
|
133
|
-
const bounds = grid.state.viewBounds.get();
|
|
134
|
-
const f = flat.get();
|
|
135
|
-
const te = bounds.rowTopEnd;
|
|
136
|
-
const seen = new Set();
|
|
137
|
-
const requests = [];
|
|
138
|
-
for (let i = bounds.rowCenterStart - te; i < bounds.rowCenterEnd - te; i++) {
|
|
139
|
-
const ranges = f.rangeTree.findRangesForRowIndex(i);
|
|
140
|
-
ranges.forEach((c) => {
|
|
141
|
-
if (c.parent.kind === "root") {
|
|
142
|
-
const blockIndex = Math.floor(i / blockSize);
|
|
143
|
-
const start = blockIndex * blockSize;
|
|
144
|
-
const end = Math.min(start + blockSize, c.parent.size);
|
|
145
|
-
const reqId = getRequestId([], start, end);
|
|
146
|
-
if (seen.has(reqId)) return;
|
|
147
|
-
seen.add(reqId);
|
|
148
|
-
const size = start + blockSize > c.parent.size ? c.parent.size - start : blockSize;
|
|
149
|
-
requests.push({
|
|
150
|
-
id: reqId,
|
|
151
|
-
path: [],
|
|
152
|
-
start,
|
|
153
|
-
end,
|
|
154
|
-
rowStartIndex: i,
|
|
155
|
-
rowEndIndex: i + size,
|
|
156
|
-
});
|
|
157
|
-
} else {
|
|
158
|
-
const blockIndex = Math.floor(c.parent.relIndex / blockSize);
|
|
159
|
-
const start = blockIndex * blockSize;
|
|
160
|
-
const end = Math.min(start + blockSize, c.parent.size);
|
|
161
|
-
const path = getNodePath(c.parent);
|
|
162
|
-
const reqId = getRequestId(path, start, end);
|
|
163
|
-
if (seen.has(reqId)) return;
|
|
164
|
-
seen.add(reqId);
|
|
165
|
-
const size = start + blockSize > c.parent.size ? c.parent.size - start : blockSize;
|
|
166
|
-
requests.push({
|
|
167
|
-
id: reqId,
|
|
168
|
-
path,
|
|
169
|
-
start,
|
|
170
|
-
end,
|
|
171
|
-
rowStartIndex: i,
|
|
172
|
-
rowEndIndex: i + size,
|
|
173
|
-
});
|
|
41
|
+
const model = makeGridAtom(model$, rdsStore);
|
|
42
|
+
const pivotGroupExpansions = atom((g) => g(model$).pivotGroupExpansions);
|
|
43
|
+
const rowGroupExpansions = atom((g) => g(model$).groupExpansions);
|
|
44
|
+
const pivotMode = atom((g) => g(model$).pivotMode);
|
|
45
|
+
const topData = atom([]);
|
|
46
|
+
const botData = atom([]);
|
|
47
|
+
const seenRequests = new Set();
|
|
48
|
+
const dataResponseHandler = (res) => {
|
|
49
|
+
const t = tree.get();
|
|
50
|
+
const dataResponses = res.filter((r) => {
|
|
51
|
+
return !("kind" in r && (r.kind === "top" || r.kind === "bottom"));
|
|
52
|
+
});
|
|
53
|
+
dataResponses.sort((l, r) => l.path.length - r.path.length);
|
|
54
|
+
const pinResponses = res.filter((r) => {
|
|
55
|
+
return "kind" in r && (r.kind === "top" || r.kind === "bottom");
|
|
56
|
+
});
|
|
57
|
+
pinResponses.forEach((p) => {
|
|
58
|
+
if (p.kind === "top") {
|
|
59
|
+
rdsStore.set(topData, p.data);
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
rdsStore.set(botData, p.data);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
dataResponses.forEach((r) => {
|
|
66
|
+
t.set({
|
|
67
|
+
path: r.path,
|
|
68
|
+
items: r.data.map((c, i) => {
|
|
69
|
+
if (c.kind === "leaf") {
|
|
70
|
+
return {
|
|
71
|
+
kind: "leaf",
|
|
72
|
+
data: c,
|
|
73
|
+
relIndex: r.start + i,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
return {
|
|
78
|
+
kind: "parent",
|
|
79
|
+
data: c,
|
|
80
|
+
path: c.key,
|
|
81
|
+
relIndex: r.start + i,
|
|
82
|
+
size: c.childCount,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}),
|
|
86
|
+
size: r.size,
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
const dataRequestHandler = async (p, force = false, onSuccess, onFailure) => {
|
|
91
|
+
if (!grid)
|
|
92
|
+
return;
|
|
93
|
+
const unseen = p.filter((x) => force || !seenRequests.has(x.id));
|
|
94
|
+
unseen.forEach((x) => seenRequests.add(x.id));
|
|
95
|
+
if (unseen.length === 0) {
|
|
96
|
+
onSuccess?.();
|
|
97
|
+
return;
|
|
174
98
|
}
|
|
175
|
-
});
|
|
176
|
-
}
|
|
177
|
-
dataRequestHandler(
|
|
178
|
-
requests,
|
|
179
|
-
false,
|
|
180
|
-
() => {},
|
|
181
|
-
(e) => {
|
|
182
99
|
rdsStore.set(nodesWithError, (prev) => {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
100
|
+
const next = new Map(prev);
|
|
101
|
+
p.forEach((r) => {
|
|
102
|
+
for (let i = r.rowStartIndex; i < r.rowEndIndex; i++) {
|
|
103
|
+
next.delete(i);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
return prev;
|
|
190
107
|
});
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
108
|
+
try {
|
|
109
|
+
const res = await dataFetcher({
|
|
110
|
+
grid: grid,
|
|
111
|
+
model: model.get(),
|
|
112
|
+
reqTime: Date.now(),
|
|
113
|
+
requests: p,
|
|
114
|
+
});
|
|
115
|
+
dataResponseHandler(res);
|
|
116
|
+
onSuccess?.();
|
|
117
|
+
}
|
|
118
|
+
catch (e) {
|
|
119
|
+
// Mark them as unseen since the request failed.
|
|
120
|
+
unseen.forEach((x) => seenRequests.delete(x.id));
|
|
121
|
+
onFailure?.(e);
|
|
122
|
+
console.error(e);
|
|
123
|
+
}
|
|
124
|
+
finally {
|
|
125
|
+
rdsStore.set(snapshot$, Date.now());
|
|
126
|
+
grid.state.rowDataStore.rowClearCache();
|
|
127
|
+
}
|
|
206
128
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
129
|
+
const viewChange = () => {
|
|
130
|
+
if (!grid)
|
|
131
|
+
return;
|
|
132
|
+
const bounds = grid.state.viewBounds.get();
|
|
133
|
+
const f = flat.get();
|
|
134
|
+
const te = bounds.rowTopEnd;
|
|
135
|
+
const seen = new Set();
|
|
136
|
+
const requests = [];
|
|
137
|
+
for (let i = bounds.rowCenterStart - te; i < bounds.rowCenterEnd - te; i++) {
|
|
138
|
+
const ranges = f.rangeTree.findRangesForRowIndex(i);
|
|
139
|
+
ranges.forEach((c) => {
|
|
140
|
+
if (c.parent.kind === "root") {
|
|
141
|
+
const blockIndex = Math.floor(i / blockSize);
|
|
142
|
+
const start = blockIndex * blockSize;
|
|
143
|
+
const end = Math.min(start + blockSize, c.parent.size);
|
|
144
|
+
const reqId = getRequestId([], start, end);
|
|
145
|
+
if (seen.has(reqId))
|
|
146
|
+
return;
|
|
147
|
+
seen.add(reqId);
|
|
148
|
+
const size = start + blockSize > c.parent.size ? c.parent.size - start : blockSize;
|
|
149
|
+
requests.push({
|
|
150
|
+
id: reqId,
|
|
151
|
+
path: [],
|
|
152
|
+
start,
|
|
153
|
+
end,
|
|
154
|
+
rowStartIndex: i,
|
|
155
|
+
rowEndIndex: i + size,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const blockIndex = Math.floor(c.parent.relIndex / blockSize);
|
|
160
|
+
const start = blockIndex * blockSize;
|
|
161
|
+
const end = Math.min(start + blockSize, c.parent.size);
|
|
162
|
+
const path = getNodePath(c.parent);
|
|
163
|
+
const reqId = getRequestId(path, start, end);
|
|
164
|
+
if (seen.has(reqId))
|
|
165
|
+
return;
|
|
166
|
+
seen.add(reqId);
|
|
167
|
+
const size = start + blockSize > c.parent.size ? c.parent.size - start : blockSize;
|
|
168
|
+
requests.push({
|
|
169
|
+
id: reqId,
|
|
170
|
+
path,
|
|
171
|
+
start,
|
|
172
|
+
end,
|
|
173
|
+
rowStartIndex: i,
|
|
174
|
+
rowEndIndex: i + size,
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
|
240
178
|
}
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
rangeTree,
|
|
179
|
+
dataRequestHandler(requests, false, () => { }, (e) => {
|
|
180
|
+
rdsStore.set(nodesWithError, (prev) => {
|
|
181
|
+
const next = new Map(prev);
|
|
182
|
+
requests.forEach((r) => {
|
|
183
|
+
for (let i = r.rowStartIndex; i < r.rowEndIndex; i++) {
|
|
184
|
+
next.set(i, e);
|
|
185
|
+
}
|
|
186
|
+
});
|
|
187
|
+
return prev;
|
|
188
|
+
});
|
|
189
|
+
});
|
|
253
190
|
};
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
quickSearch,
|
|
274
|
-
aggregations,
|
|
275
|
-
group,
|
|
276
|
-
groupExpansions,
|
|
277
|
-
pivotMode,
|
|
278
|
-
pivotModel,
|
|
279
|
-
pivotGroupExpansions,
|
|
280
|
-
});
|
|
281
|
-
rdsStore.set(initialized, true);
|
|
282
|
-
// Handle row count changes
|
|
283
|
-
const f = flat.get();
|
|
284
|
-
g.state.rowDataStore.rowCenterCount.set(f.size);
|
|
285
|
-
g.state.rowDataStore.rowBottomCount.set(rdsStore.get(botData).length);
|
|
286
|
-
g.state.rowDataStore.rowTopCount.set(rdsStore.get(topData).length);
|
|
287
|
-
rdsStore.sub(flat$, () => {
|
|
288
|
-
const f = flat.get();
|
|
289
|
-
g.state.rowDataStore.rowCenterCount.set(f.size);
|
|
290
|
-
viewChange();
|
|
291
|
-
});
|
|
292
|
-
rdsStore.sub(topData, () => {
|
|
293
|
-
g.state.rowDataStore.rowTopCount.set(rdsStore.get(topData).length);
|
|
294
|
-
g.state.rowDataStore.rowClearCache();
|
|
295
|
-
});
|
|
296
|
-
rdsStore.sub(botData, () => {
|
|
297
|
-
g.state.rowDataStore.rowBottomCount.set(rdsStore.get(botData).length);
|
|
298
|
-
g.state.rowDataStore.rowClearCache();
|
|
299
|
-
});
|
|
300
|
-
resetRequest();
|
|
301
|
-
// Watch the view bound changes.
|
|
302
|
-
g.state.viewBounds.watch(() => {
|
|
303
|
-
viewChange();
|
|
304
|
-
});
|
|
305
|
-
let prevPivotColumnModel = pivotModel.columns;
|
|
306
|
-
let prevPivotColumnValues = pivotModel.values;
|
|
307
|
-
const updatePivotColumns = async (mdl, ignoreEqualCheck = false) => {
|
|
308
|
-
if (
|
|
309
|
-
!ignoreEqualCheck &&
|
|
310
|
-
equal(prevPivotColumnModel, mdl.columns) &&
|
|
311
|
-
equal(prevPivotColumnValues, mdl.values)
|
|
312
|
-
)
|
|
313
|
-
return;
|
|
314
|
-
const cols = await dataColumnPivotFetcher?.({
|
|
315
|
-
grid: grid,
|
|
316
|
-
model: model.get(),
|
|
317
|
-
reqTime: Date.now(),
|
|
318
|
-
});
|
|
319
|
-
if (cols) grid?.state.columnPivotColumns.set(cols);
|
|
320
|
-
resetRequest();
|
|
321
|
-
prevPivotColumnModel = mdl.columns;
|
|
322
|
-
prevPivotColumnValues = mdl.values;
|
|
191
|
+
const resetRequest = async () => {
|
|
192
|
+
seenRequests.clear();
|
|
193
|
+
tree.set(makeAsyncTree());
|
|
194
|
+
rdsStore.set(nodesWithError, new Map());
|
|
195
|
+
// Initialize the grid.
|
|
196
|
+
const initialDataRequest = {
|
|
197
|
+
path: [],
|
|
198
|
+
id: getRequestId([], 0, blockSize),
|
|
199
|
+
rowStartIndex: 0,
|
|
200
|
+
rowEndIndex: blockSize,
|
|
201
|
+
start: 0,
|
|
202
|
+
end: blockSize,
|
|
203
|
+
};
|
|
204
|
+
loadError.set(null);
|
|
205
|
+
isLoading.set(true);
|
|
206
|
+
await dataRequestHandler([initialDataRequest], false, () => { }, (e) => {
|
|
207
|
+
loadError.set(e);
|
|
208
|
+
});
|
|
209
|
+
isLoading.set(false);
|
|
323
210
|
};
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
const
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
211
|
+
const flat$ = atom((g) => {
|
|
212
|
+
g(snapshot$);
|
|
213
|
+
const mode = rdsStore.get(pivotMode);
|
|
214
|
+
const expansions = mode ? g(pivotGroupExpansions) : g(rowGroupExpansions);
|
|
215
|
+
const t = g(tree$);
|
|
216
|
+
const rowIdToRow = new Map();
|
|
217
|
+
const rowIndexToRow = new Map();
|
|
218
|
+
const rowIdToRowIndex = new Map();
|
|
219
|
+
const ranges = [];
|
|
220
|
+
function processParent(node, start) {
|
|
221
|
+
const rows = [...node.byIndex.values()].sort((l, r) => l.relIndex - r.relIndex);
|
|
222
|
+
// Track the additional rows added by expanded groups
|
|
223
|
+
let offset = 0;
|
|
224
|
+
for (let i = 0; i < rows.length; i++) {
|
|
225
|
+
const row = rows[i];
|
|
226
|
+
const rowIndex = row.relIndex + start + offset;
|
|
227
|
+
rowIndexToRow.set(rowIndex, row);
|
|
228
|
+
rowIdToRowIndex.set(row.data.id, rowIndex);
|
|
229
|
+
rowIdToRow.set(row.data.id, row);
|
|
230
|
+
if (row.kind === "parent" && expansions[row.data.id]) {
|
|
231
|
+
offset += processParent(row, rowIndex + 1);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
ranges.push({ rowStart: start, rowEnd: offset + node.size + start, parent: node });
|
|
235
|
+
return offset + node.size;
|
|
236
|
+
}
|
|
237
|
+
const size = processParent(t, 0);
|
|
238
|
+
const rangeTree = new RangeTree(ranges);
|
|
239
|
+
return {
|
|
240
|
+
size,
|
|
241
|
+
rowIndexToRow,
|
|
242
|
+
rowIdToRow,
|
|
243
|
+
rowIdToRowIndex,
|
|
244
|
+
rangeTree,
|
|
245
|
+
};
|
|
351
246
|
});
|
|
352
|
-
|
|
353
|
-
cleanup
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
247
|
+
const flat = makeGridAtom(flat$, rdsStore);
|
|
248
|
+
const cleanup = [];
|
|
249
|
+
const init = (g) => {
|
|
250
|
+
grid = g;
|
|
251
|
+
const sorts = g.state.sortModel.get();
|
|
252
|
+
const filters = g.state.filterModel.get();
|
|
253
|
+
const filtersIn = g.state.filterInModel.get();
|
|
254
|
+
const quickSearch = g.state.quickSearch.get();
|
|
255
|
+
const group = g.state.rowGroupModel.get();
|
|
256
|
+
const groupExpansions = g.state.rowGroupExpansions.get();
|
|
257
|
+
const aggregations = g.state.aggModel.get();
|
|
258
|
+
const pivotMode = g.state.columnPivotMode.get();
|
|
259
|
+
const pivotModel = g.state.columnPivotModel.get();
|
|
260
|
+
const pivotGroupExpansions = g.state.columnPivotRowGroupExpansions.get();
|
|
261
|
+
rdsStore.set(model$, {
|
|
262
|
+
sorts,
|
|
263
|
+
filters,
|
|
264
|
+
filtersIn,
|
|
265
|
+
quickSearch,
|
|
266
|
+
aggregations,
|
|
267
|
+
group,
|
|
268
|
+
groupExpansions,
|
|
269
|
+
pivotMode,
|
|
270
|
+
pivotModel,
|
|
271
|
+
pivotGroupExpansions,
|
|
272
|
+
});
|
|
273
|
+
rdsStore.set(initialized, true);
|
|
274
|
+
// Handle row count changes
|
|
275
|
+
const f = flat.get();
|
|
276
|
+
g.state.rowDataStore.rowCenterCount.set(f.size);
|
|
277
|
+
g.state.rowDataStore.rowBottomCount.set(rdsStore.get(botData).length);
|
|
278
|
+
g.state.rowDataStore.rowTopCount.set(rdsStore.get(topData).length);
|
|
279
|
+
rdsStore.sub(flat$, () => {
|
|
280
|
+
const f = flat.get();
|
|
281
|
+
g.state.rowDataStore.rowCenterCount.set(f.size);
|
|
282
|
+
viewChange();
|
|
283
|
+
});
|
|
284
|
+
rdsStore.sub(topData, () => {
|
|
285
|
+
g.state.rowDataStore.rowTopCount.set(rdsStore.get(topData).length);
|
|
286
|
+
g.state.rowDataStore.rowClearCache();
|
|
287
|
+
});
|
|
288
|
+
rdsStore.sub(botData, () => {
|
|
289
|
+
g.state.rowDataStore.rowBottomCount.set(rdsStore.get(botData).length);
|
|
290
|
+
g.state.rowDataStore.rowClearCache();
|
|
291
|
+
});
|
|
382
292
|
resetRequest();
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
293
|
+
// Watch the view bound changes.
|
|
294
|
+
g.state.viewBounds.watch(() => {
|
|
295
|
+
viewChange();
|
|
296
|
+
});
|
|
297
|
+
let prevPivotColumnModel = pivotModel.columns;
|
|
298
|
+
let prevPivotColumnValues = pivotModel.values;
|
|
299
|
+
const updatePivotColumns = async (mdl, ignoreEqualCheck = false) => {
|
|
300
|
+
if (!ignoreEqualCheck &&
|
|
301
|
+
equal(prevPivotColumnModel, mdl.columns) &&
|
|
302
|
+
equal(prevPivotColumnValues, mdl.values))
|
|
303
|
+
return;
|
|
304
|
+
const cols = await dataColumnPivotFetcher?.({
|
|
305
|
+
grid: grid,
|
|
306
|
+
model: model.get(),
|
|
307
|
+
reqTime: Date.now(),
|
|
308
|
+
});
|
|
309
|
+
if (cols)
|
|
310
|
+
grid?.state.columnPivotColumns.set(cols);
|
|
311
|
+
resetRequest();
|
|
312
|
+
prevPivotColumnModel = mdl.columns;
|
|
313
|
+
prevPivotColumnValues = mdl.values;
|
|
314
|
+
};
|
|
315
|
+
if (pivotMode)
|
|
316
|
+
updatePivotColumns(pivotModel);
|
|
317
|
+
// Make these deep equality checks
|
|
318
|
+
cleanup.push(g.state.columnPivotMode.watch(() => {
|
|
319
|
+
const model = g.state.columnPivotModel.get();
|
|
320
|
+
updatePivotColumns(model, true);
|
|
321
|
+
rdsStore.set(model$, (prev) => ({ ...prev, pivotMode: g.state.columnPivotMode.get() }));
|
|
322
|
+
g.state.rowDataStore.rowClearCache();
|
|
323
|
+
}));
|
|
324
|
+
cleanup.push(g.state.columnPivotModel.watch(() => {
|
|
325
|
+
const model = g.state.columnPivotModel.get();
|
|
326
|
+
updatePivotColumns(model);
|
|
327
|
+
rdsStore.set(model$, (prev) => ({
|
|
328
|
+
...prev,
|
|
329
|
+
pivotModel: model,
|
|
330
|
+
}));
|
|
331
|
+
g.state.rowDataStore.rowClearCache();
|
|
332
|
+
}));
|
|
333
|
+
g.state.columnPivotRowGroupExpansions.watch(() => {
|
|
334
|
+
rdsStore.set(model$, (prev) => ({
|
|
335
|
+
...prev,
|
|
336
|
+
columnPivotGroupExpansions: g.state.columnPivotRowGroupExpansions.get(),
|
|
337
|
+
}));
|
|
338
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
339
|
+
});
|
|
340
|
+
// Sort model monitoring
|
|
341
|
+
cleanup.push(g.state.sortModel.watch(() => {
|
|
342
|
+
rdsStore.set(model$, (prev) => ({ ...prev, sorts: g.state.sortModel.get() }));
|
|
343
|
+
resetRequest();
|
|
344
|
+
}));
|
|
345
|
+
// Filter model monitoring
|
|
346
|
+
cleanup.push(g.state.filterModel.watch(() => {
|
|
347
|
+
rdsStore.set(model$, (prev) => ({ ...prev, filters: g.state.filterModel.get() }));
|
|
348
|
+
resetRequest();
|
|
349
|
+
}));
|
|
350
|
+
cleanup.push(g.state.quickSearch.watch(() => {
|
|
351
|
+
rdsStore.set(model$, (prev) => ({ ...prev, quickSearch: g.state.quickSearch.get() }));
|
|
352
|
+
resetRequest();
|
|
353
|
+
}));
|
|
354
|
+
cleanup.push(g.state.filterInModel.watch(() => {
|
|
355
|
+
rdsStore.set(model$, (prev) => ({ ...prev, filtersIn: g.state.filterInModel.get() }));
|
|
356
|
+
resetRequest();
|
|
357
|
+
}));
|
|
358
|
+
// Row group model monitoring
|
|
359
|
+
cleanup.push(g.state.rowGroupModel.watch(() => {
|
|
360
|
+
rdsStore.set(model$, (prev) => ({ ...prev, group: g.state.rowGroupModel.get() }));
|
|
361
|
+
resetRequest();
|
|
362
|
+
}));
|
|
363
|
+
// Row group expansions monitoring
|
|
364
|
+
cleanup.push(g.state.rowGroupExpansions.watch(() => {
|
|
365
|
+
rdsStore.set(model$, (prev) => ({
|
|
366
|
+
...prev,
|
|
367
|
+
groupExpansions: g.state.rowGroupExpansions.get(),
|
|
368
|
+
}));
|
|
369
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
370
|
+
}));
|
|
371
|
+
// Agg model monitoring
|
|
372
|
+
cleanup.push(g.state.aggModel.watch(() => {
|
|
373
|
+
rdsStore.set(model$, (prev) => ({ ...prev, agg: g.state.aggModel.get() }));
|
|
374
|
+
resetRequest();
|
|
391
375
|
}));
|
|
392
|
-
grid?.state.rowDataStore.rowClearCache();
|
|
393
|
-
}),
|
|
394
|
-
);
|
|
395
|
-
// Agg model monitoring
|
|
396
|
-
cleanup.push(
|
|
397
|
-
g.state.aggModel.watch(() => {
|
|
398
|
-
rdsStore.set(model$, (prev) => ({ ...prev, agg: g.state.aggModel.get() }));
|
|
399
|
-
resetRequest();
|
|
400
|
-
}),
|
|
401
|
-
);
|
|
402
|
-
};
|
|
403
|
-
const rowById = (id) => {
|
|
404
|
-
const f = flat.get();
|
|
405
|
-
const node = f.rowIdToRow.get(id);
|
|
406
|
-
if (!node) {
|
|
407
|
-
{
|
|
408
|
-
const top = rdsStore.get(topData);
|
|
409
|
-
const node = top.find((c) => c.id === id);
|
|
410
|
-
if (node) return { kind: "leaf", data: node.data, id: node.id };
|
|
411
|
-
}
|
|
412
|
-
{
|
|
413
|
-
const bot = rdsStore.get(topData);
|
|
414
|
-
const node = bot.find((c) => c.id === id);
|
|
415
|
-
if (node) return { kind: "leaf", data: node.data, id: node.id };
|
|
416
|
-
}
|
|
417
|
-
return null;
|
|
418
|
-
}
|
|
419
|
-
if (node.kind === "parent") {
|
|
420
|
-
return {
|
|
421
|
-
kind: "branch",
|
|
422
|
-
data: node.data.data,
|
|
423
|
-
id: node.data.id,
|
|
424
|
-
key: node.path,
|
|
425
|
-
depth: getNodeDepth(node),
|
|
426
|
-
};
|
|
427
|
-
}
|
|
428
|
-
return {
|
|
429
|
-
kind: "leaf",
|
|
430
|
-
data: node.data.data,
|
|
431
|
-
id: node.data.id,
|
|
432
376
|
};
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
};
|
|
485
|
-
}
|
|
486
|
-
return {
|
|
487
|
-
kind: "leaf",
|
|
488
|
-
data: node.data.data,
|
|
489
|
-
id: node.data.id,
|
|
490
|
-
error,
|
|
377
|
+
const rowById = (id) => {
|
|
378
|
+
const f = flat.get();
|
|
379
|
+
const node = f.rowIdToRow.get(id);
|
|
380
|
+
if (!node) {
|
|
381
|
+
{
|
|
382
|
+
const top = rdsStore.get(topData);
|
|
383
|
+
const node = top.find((c) => c.id === id);
|
|
384
|
+
if (node)
|
|
385
|
+
return { kind: "leaf", data: node.data, id: node.id };
|
|
386
|
+
}
|
|
387
|
+
{
|
|
388
|
+
const bot = rdsStore.get(topData);
|
|
389
|
+
const node = bot.find((c) => c.id === id);
|
|
390
|
+
if (node)
|
|
391
|
+
return { kind: "leaf", data: node.data, id: node.id };
|
|
392
|
+
}
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
if (node.kind === "parent") {
|
|
396
|
+
return {
|
|
397
|
+
kind: "branch",
|
|
398
|
+
data: node.data.data,
|
|
399
|
+
id: node.data.id,
|
|
400
|
+
key: node.path,
|
|
401
|
+
depth: getNodeDepth(node),
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
405
|
+
kind: "leaf",
|
|
406
|
+
data: node.data.data,
|
|
407
|
+
id: node.data.id,
|
|
408
|
+
};
|
|
409
|
+
};
|
|
410
|
+
const rowAllChildIds = (rowId) => {
|
|
411
|
+
const f = flat.get();
|
|
412
|
+
const row = f.rowIdToRow.get(rowId);
|
|
413
|
+
if (!row || row.kind === "leaf")
|
|
414
|
+
return [];
|
|
415
|
+
const ids = new Set();
|
|
416
|
+
const stack = [...row.byPath.values()];
|
|
417
|
+
while (stack.length) {
|
|
418
|
+
const item = stack.pop();
|
|
419
|
+
if (item.kind === "leaf") {
|
|
420
|
+
ids.add(item.data.id);
|
|
421
|
+
}
|
|
422
|
+
else {
|
|
423
|
+
stack.push(...item.byPath.values());
|
|
424
|
+
ids.add(item.data.id);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return [...ids];
|
|
491
428
|
};
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
if (
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
429
|
+
const rowByIndex = (ri) => {
|
|
430
|
+
const f = flat.get();
|
|
431
|
+
const top = rdsStore.get(topData);
|
|
432
|
+
const bot = rdsStore.get(botData);
|
|
433
|
+
const errors = rdsStore.get(nodesWithError);
|
|
434
|
+
const error = errors.get(ri);
|
|
435
|
+
if (ri == null || ri < 0 || ri >= f.size + top.length + bot.length)
|
|
436
|
+
return null;
|
|
437
|
+
// Top node
|
|
438
|
+
if (ri < top.length) {
|
|
439
|
+
const row = top[ri];
|
|
440
|
+
if (!row)
|
|
441
|
+
return null;
|
|
442
|
+
return { kind: "leaf", data: row.data, id: row.id, error };
|
|
443
|
+
}
|
|
444
|
+
if (ri >= f.size + top.length) {
|
|
445
|
+
const i = ri - f.size - top.length;
|
|
446
|
+
const row = bot[i];
|
|
447
|
+
if (!row)
|
|
448
|
+
return null;
|
|
449
|
+
return { kind: "leaf", data: row.data, id: row.id, error };
|
|
450
|
+
}
|
|
451
|
+
const node = f.rowIndexToRow.get(ri - top.length);
|
|
452
|
+
if (!node && error)
|
|
453
|
+
return { kind: "leaf", data: null, id: `error-${ri}`, loading: false, error };
|
|
454
|
+
if (!node)
|
|
455
|
+
return { kind: "leaf", data: null, id: `loading-${ri}`, loading: true, error: null };
|
|
456
|
+
const isLoading = rdsStore.get(loadingGroups$);
|
|
457
|
+
if (node.kind === "parent") {
|
|
458
|
+
return {
|
|
459
|
+
kind: "branch",
|
|
460
|
+
data: node.data.data,
|
|
461
|
+
id: node.data.id,
|
|
462
|
+
key: node.path,
|
|
463
|
+
depth: getNodeDepth(node),
|
|
464
|
+
error,
|
|
465
|
+
loading: isLoading.has(node.data.id),
|
|
466
|
+
};
|
|
467
|
+
}
|
|
511
468
|
return {
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
rowStartIndex: rowIndex + 1,
|
|
517
|
-
rowEndIndex: Math.min(row.size, rowIndex + blockSize + 1),
|
|
469
|
+
kind: "leaf",
|
|
470
|
+
data: node.data.data,
|
|
471
|
+
id: node.data.id,
|
|
472
|
+
error,
|
|
518
473
|
};
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
const
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
474
|
+
};
|
|
475
|
+
const loadingGroups$ = atom(new Set());
|
|
476
|
+
const rowExpand = (p) => {
|
|
477
|
+
const f = flat.get();
|
|
478
|
+
const loadingRows = new Set(rdsStore.get(loadingGroups$));
|
|
479
|
+
const rowsForThis = new Set();
|
|
480
|
+
const rowIndices = [];
|
|
481
|
+
const requests = Object.entries(p)
|
|
482
|
+
.map(([rowId, state]) => {
|
|
483
|
+
if (!state)
|
|
484
|
+
return null;
|
|
485
|
+
// Mark as loading
|
|
486
|
+
loadingRows.add(rowId);
|
|
487
|
+
rowsForThis.add(rowId);
|
|
488
|
+
const rowIndex = rowToIndex(rowId);
|
|
489
|
+
if (rowIndex == null)
|
|
490
|
+
return null;
|
|
491
|
+
const row = f.rowIndexToRow.get(rowIndex);
|
|
492
|
+
if (!row || row.kind === "leaf")
|
|
493
|
+
return null;
|
|
494
|
+
const path = getNodePath(row);
|
|
495
|
+
rowIndices.push(rowIndex);
|
|
496
|
+
return {
|
|
497
|
+
id: getRequestId(path, 0, Math.min(blockSize, row.size)),
|
|
498
|
+
start: 0,
|
|
499
|
+
end: Math.min(blockSize, row.size),
|
|
500
|
+
path,
|
|
501
|
+
rowStartIndex: rowIndex + 1,
|
|
502
|
+
rowEndIndex: Math.min(row.size, rowIndex + blockSize + 1),
|
|
503
|
+
};
|
|
504
|
+
})
|
|
505
|
+
.filter((c) => !!c);
|
|
506
|
+
const mode = rdsStore.get(pivotMode);
|
|
507
|
+
// Remove the errors before requesting.
|
|
508
|
+
const errorRows = rdsStore.get(nodesWithError);
|
|
509
|
+
if (rowIndices.some((c) => errorRows.has(c))) {
|
|
510
|
+
rdsStore.set(nodesWithError, (prev) => {
|
|
511
|
+
const n = new Map(prev);
|
|
512
|
+
rowIndices.forEach((c) => n.delete(c));
|
|
513
|
+
return prev;
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
// Mark these groups as loading
|
|
517
|
+
rdsStore.set(loadingGroups$, loadingRows);
|
|
518
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
519
|
+
dataRequestHandler(requests, false, () => {
|
|
520
|
+
if (mode)
|
|
521
|
+
grid?.state.columnPivotColumnGroupExpansions.set((prev) => ({ ...prev, ...p }));
|
|
522
|
+
else
|
|
523
|
+
grid?.state.rowGroupExpansions.set((prev) => ({ ...prev, ...p }));
|
|
524
|
+
const next = new Set(rdsStore.get(loadingGroups$));
|
|
525
|
+
rowsForThis.forEach((c) => next.delete(c));
|
|
526
|
+
rdsStore.set(loadingGroups$, next);
|
|
527
|
+
setTimeout(() => {
|
|
528
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
529
|
+
});
|
|
530
|
+
}, (error) => {
|
|
531
|
+
rdsStore.set(nodesWithError, (prev) => {
|
|
532
|
+
const n = new Map(prev);
|
|
533
|
+
rowIndices.forEach((c) => n.set(c, error));
|
|
534
|
+
return prev;
|
|
535
|
+
});
|
|
536
|
+
const next = new Set(rdsStore.get(loadingGroups$));
|
|
537
|
+
rowsForThis.forEach((c) => next.delete(c));
|
|
538
|
+
rdsStore.set(loadingGroups$, next);
|
|
539
|
+
setTimeout(() => {
|
|
540
|
+
grid?.state.rowDataStore.rowClearCache();
|
|
541
|
+
});
|
|
558
542
|
});
|
|
559
|
-
|
|
560
|
-
)
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
}
|
|
576
|
-
const ids = new Set();
|
|
577
|
-
if (params.startId === params.endId) {
|
|
578
|
-
ids.add(params.startId);
|
|
579
|
-
if (params.selectChildren) {
|
|
580
|
-
rowAllChildIds(params.startId).forEach((c) => ids.add(c));
|
|
581
|
-
}
|
|
582
|
-
} else {
|
|
583
|
-
const first = rowToIndex(params.startId);
|
|
584
|
-
const last = rowToIndex(params.endId);
|
|
585
|
-
if (first == null || last == null) return;
|
|
586
|
-
const start = Math.min(first, last);
|
|
587
|
-
const end = Math.max(first, last);
|
|
588
|
-
for (let i = start; i <= end; i++) {
|
|
589
|
-
const row = rowByIndex(i);
|
|
590
|
-
if (!row) continue;
|
|
591
|
-
if (params.selectChildren) {
|
|
592
|
-
rowAllChildIds(row.id).forEach((c) => ids.add(c));
|
|
543
|
+
};
|
|
544
|
+
const rowToIndex = (rowId) => {
|
|
545
|
+
const f = flat.get();
|
|
546
|
+
return f.rowIdToRowIndex.get(rowId) ?? null;
|
|
547
|
+
};
|
|
548
|
+
const rowSelect = (params) => {
|
|
549
|
+
if (!grid || params.mode === "none")
|
|
550
|
+
return;
|
|
551
|
+
if (params.mode === "single") {
|
|
552
|
+
if (params.deselect) {
|
|
553
|
+
grid.state.rowSelectedIds.set(new Set());
|
|
554
|
+
}
|
|
555
|
+
else {
|
|
556
|
+
grid.state.rowSelectedIds.set(new Set([params.startId]));
|
|
557
|
+
}
|
|
558
|
+
return;
|
|
593
559
|
}
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
)
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
const
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
560
|
+
const ids = new Set();
|
|
561
|
+
if (params.startId === params.endId) {
|
|
562
|
+
ids.add(params.startId);
|
|
563
|
+
if (params.selectChildren) {
|
|
564
|
+
rowAllChildIds(params.startId).forEach((c) => ids.add(c));
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
else {
|
|
568
|
+
const first = rowToIndex(params.startId);
|
|
569
|
+
const last = rowToIndex(params.endId);
|
|
570
|
+
if (first == null || last == null)
|
|
571
|
+
return;
|
|
572
|
+
const start = Math.min(first, last);
|
|
573
|
+
const end = Math.max(first, last);
|
|
574
|
+
for (let i = start; i <= end; i++) {
|
|
575
|
+
const row = rowByIndex(i);
|
|
576
|
+
if (!row)
|
|
577
|
+
continue;
|
|
578
|
+
if (params.selectChildren) {
|
|
579
|
+
rowAllChildIds(row.id).forEach((c) => ids.add(c));
|
|
580
|
+
}
|
|
581
|
+
if (row?.id)
|
|
582
|
+
ids.add(row.id);
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
if (params.deselect) {
|
|
586
|
+
const current = grid.state.rowSelectedIds.get();
|
|
587
|
+
const next = current.difference(ids);
|
|
588
|
+
grid.state.rowSelectedIds.set(next);
|
|
589
|
+
}
|
|
590
|
+
else {
|
|
591
|
+
const current = grid.state.rowSelectedIds.get();
|
|
592
|
+
const next = current.union(ids);
|
|
593
|
+
grid.state.rowSelectedIds.set(next);
|
|
594
|
+
}
|
|
595
|
+
};
|
|
596
|
+
const rowSelectAll = (params) => {
|
|
597
|
+
if (!grid)
|
|
598
|
+
return;
|
|
599
|
+
if (params.deselect) {
|
|
600
|
+
grid.state.rowSelectedIds.set(new Set());
|
|
601
|
+
return;
|
|
602
|
+
}
|
|
603
|
+
const t = flat.get();
|
|
604
|
+
grid.state.rowSelectedIds.set(new Set(t.rowIdToRow.keys()));
|
|
605
|
+
};
|
|
606
|
+
const rowSetBotData = () => {
|
|
607
|
+
throw new Error(`Server data source does not support directly setting pinned rows. Instead send a DataResponsePinned object via the pushData method`);
|
|
608
|
+
};
|
|
609
|
+
const rowSetTopData = () => {
|
|
610
|
+
throw new Error(`Server data source does not support directly setting pinned rows. Instead send a DataResponsePinned object via the pushData method`);
|
|
611
|
+
};
|
|
612
|
+
// CRUD ops
|
|
613
|
+
const rowAdd = () => {
|
|
614
|
+
throw new Error(`Server data source does not support adding rows directly. Instead push updates via the pushResponses or pushRequests method`);
|
|
615
|
+
};
|
|
616
|
+
const rowDelete = () => {
|
|
617
|
+
throw new Error(`Server data source does not support deleting rows directly. Instead push updates via the pushResponses or pushRequests method`);
|
|
618
|
+
};
|
|
619
|
+
const rowUpdate = (updates) => {
|
|
620
|
+
const f = flat.get();
|
|
621
|
+
const top = rdsStore.get(topData);
|
|
622
|
+
const bot = rdsStore.get(botData);
|
|
623
|
+
const firstBot = f.size + top.length;
|
|
624
|
+
const idMap = new Map([...updates.entries()]
|
|
625
|
+
.map(([key, data]) => {
|
|
626
|
+
if (typeof key === "string")
|
|
627
|
+
return [key, data];
|
|
628
|
+
const row = rowByIndex(key);
|
|
629
|
+
if (!row)
|
|
630
|
+
return null;
|
|
631
|
+
return [row.id, data];
|
|
649
632
|
})
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
633
|
+
.filter((n) => n != null));
|
|
634
|
+
cellUpdateHandler?.(idMap);
|
|
635
|
+
if (!cellUpdateOptimistically)
|
|
636
|
+
return;
|
|
637
|
+
for (const [key, data] of updates.entries()) {
|
|
638
|
+
const rowIndex = typeof key === "number" ? key : rowToIndex(key);
|
|
639
|
+
const row = rowByIndex(rowIndex);
|
|
640
|
+
if (!row || !grid) {
|
|
641
|
+
console.error(`Failed to find the row at index ${rowIndex} which is being updated.`);
|
|
642
|
+
continue;
|
|
643
|
+
}
|
|
644
|
+
if (rowIndex < top.length) {
|
|
645
|
+
top[rowIndex].data = data;
|
|
646
|
+
}
|
|
647
|
+
else if (rowIndex >= firstBot) {
|
|
648
|
+
bot[rowIndex].data = data;
|
|
649
|
+
}
|
|
650
|
+
else {
|
|
651
|
+
const node = f.rowIndexToRow.get(rowIndex - top.length);
|
|
652
|
+
if (node)
|
|
653
|
+
node.data.data = data;
|
|
654
|
+
}
|
|
655
|
+
grid.state.rowDataStore.rowInvalidateIndex(rowIndex);
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
const inFilterItems = (c) => {
|
|
659
|
+
if (!dataInFilterItemFetcher || !grid)
|
|
660
|
+
return [];
|
|
661
|
+
return dataInFilterItemFetcher({ column: c, grid, reqTime: Date.now() });
|
|
662
|
+
};
|
|
663
|
+
const rowAreAllSelected = () => {
|
|
664
|
+
return false;
|
|
665
|
+
};
|
|
666
|
+
return {
|
|
667
|
+
init,
|
|
668
|
+
rowAdd,
|
|
669
|
+
rowById,
|
|
670
|
+
rowAllChildIds,
|
|
671
|
+
rowByIndex,
|
|
672
|
+
rowDelete,
|
|
673
|
+
rowExpand,
|
|
674
|
+
rowSelect,
|
|
675
|
+
rowSelectAll,
|
|
676
|
+
rowSetBotData,
|
|
677
|
+
rowSetCenterData: () => {
|
|
678
|
+
throw new Error("Server side data source does not support full row updates");
|
|
679
|
+
},
|
|
680
|
+
rowSetTopData,
|
|
681
|
+
rowToIndex,
|
|
682
|
+
rowUpdate,
|
|
683
|
+
inFilterItems,
|
|
684
|
+
rowAreAllSelected,
|
|
685
|
+
isLoading,
|
|
686
|
+
loadError,
|
|
687
|
+
pushResponses: (res) => {
|
|
688
|
+
dataResponseHandler(res);
|
|
689
|
+
},
|
|
690
|
+
pushRequests: (req, onSuccess, onFailure) => {
|
|
691
|
+
dataRequestHandler(req, true, onSuccess, onFailure);
|
|
692
|
+
},
|
|
693
|
+
reset: resetRequest,
|
|
694
|
+
retry: () => {
|
|
695
|
+
viewChange();
|
|
696
|
+
},
|
|
697
|
+
};
|
|
711
698
|
}
|
|
712
699
|
export function useServerDataSource(p) {
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
700
|
+
const ds = useRef(null);
|
|
701
|
+
if (!ds.current) {
|
|
702
|
+
ds.current = makeServerDataSource(p);
|
|
703
|
+
}
|
|
704
|
+
return ds.current;
|
|
718
705
|
}
|