@1771technologies/lytenyte-pro 1.0.0-beta.33 → 1.0.0-beta.36
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 +4203 -4009
- package/dist/cell-selection/adjust-rect-for-row-and-cell-span.js +38 -38
- package/dist/cell-selection/are-rects-equal.js +6 -4
- package/dist/cell-selection/bound-selection-rect.js +14 -14
- package/dist/cell-selection/cell-selection-containers.js +108 -78
- package/dist/cell-selection/cell-selection-driver.js +250 -262
- package/dist/cell-selection/cell-style-row.d.ts +12 -6
- package/dist/cell-selection/cell-style-row.js +82 -79
- package/dist/cell-selection/deselect-rect-range.js +41 -40
- package/dist/cell-selection/expand-cell-selection-down.d.ts +5 -2
- package/dist/cell-selection/expand-cell-selection-down.js +29 -33
- package/dist/cell-selection/expand-cell-selection-end.d.ts +5 -2
- package/dist/cell-selection/expand-cell-selection-end.js +30 -34
- package/dist/cell-selection/expand-cell-selection-start.d.ts +5 -2
- package/dist/cell-selection/expand-cell-selection-start.js +29 -33
- package/dist/cell-selection/expand-cell-selection-up.d.ts +5 -2
- package/dist/cell-selection/expand-cell-selection-up.js +29 -33
- package/dist/cell-selection/full-width-start-end-index.js +3 -3
- package/dist/cell-selection/get-root-cell.d.ts +5 -1
- package/dist/cell-selection/get-root-cell.js +77 -79
- package/dist/cell-selection/is-bottom-rect.js +5 -5
- package/dist/cell-selection/is-center-col-rect.d.ts +5 -2
- package/dist/cell-selection/is-center-col-rect.js +5 -3
- package/dist/cell-selection/is-center-rect.js +3 -3
- package/dist/cell-selection/is-end-rect.d.ts +5 -2
- package/dist/cell-selection/is-end-rect.js +2 -2
- package/dist/cell-selection/is-overlapping-rect.js +6 -4
- package/dist/cell-selection/is-start-rect.d.ts +5 -2
- 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 +12 -6
- package/dist/cell-selection/split-cell-selection-rect.js +53 -47
- package/dist/cell-selection/update-additive-cell-selection.d.ts +5 -2
- package/dist/cell-selection/update-additive-cell-selection.js +16 -17
- package/dist/cell-selection/use-edge-scroll.d.ts +8 -6
- package/dist/cell-selection/use-edge-scroll.js +65 -63
- package/dist/cells/cell-default.d.ts +5 -1
- package/dist/cells/cell-default.js +5 -5
- package/dist/cells/cell-editor.d.ts +4 -2
- package/dist/cells/cell-editor.js +129 -92
- package/dist/cells/cell.d.ts +16 -3
- package/dist/cells/cell.js +56 -27
- package/dist/column-manager/branch-lookup-context.d.ts +3 -1
- package/dist/column-manager/branch.d.ts +17 -9
- package/dist/column-manager/branch.js +64 -46
- package/dist/column-manager/column-manager.d.ts +57 -8
- 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 +10 -2
- package/dist/column-manager/label.js +11 -12
- package/dist/column-manager/leaf.d.ts +10 -2
- package/dist/column-manager/leaf.js +61 -49
- package/dist/column-manager/move-handle.d.ts +14 -6
- package/dist/column-manager/move-handle.js +52 -48
- package/dist/column-manager/panel.d.ts +10 -1
- package/dist/column-manager/root.d.ts +7 -3
- package/dist/column-manager/root.js +4 -1
- package/dist/column-manager/use-column-manager.d.ts +6 -3
- package/dist/column-manager/use-column-manager.js +14 -15
- package/dist/column-manager/use-columns-from-context.d.ts +3 -1
- package/dist/column-manager/use-columns-from-context.js +18 -18
- package/dist/column-manager/visibility-checkbox.d.ts +14 -6
- package/dist/column-manager/visibility-checkbox.js +36 -23
- package/dist/context.d.ts +4 -4
- package/dist/filter-tree/branch.d.ts +16 -5
- package/dist/filter-tree/branch.js +23 -13
- package/dist/filter-tree/context.d.ts +16 -16
- package/dist/filter-tree/filter-tree.d.ts +49 -8
- package/dist/filter-tree/filter-tree.js +8 -8
- package/dist/filter-tree/hooks/use-filter-tree.d.ts +35 -29
- package/dist/filter-tree/hooks/use-filter-tree.js +94 -92
- package/dist/filter-tree/hooks/use-tree-item.d.ts +4 -4
- package/dist/filter-tree/hooks/use-tree-item.js +99 -106
- package/dist/filter-tree/inclusion-checkbox.d.ts +14 -6
- package/dist/filter-tree/inclusion-checkbox.js +19 -9
- package/dist/filter-tree/label.d.ts +10 -2
- package/dist/filter-tree/label.js +11 -12
- package/dist/filter-tree/leaf.d.ts +10 -2
- package/dist/filter-tree/leaf.js +15 -5
- package/dist/filter-tree/root.d.ts +23 -7
- package/dist/filter-tree/root.js +51 -23
- 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 +26 -6
- package/dist/grid-box/grid-box.js +6 -6
- package/dist/grid-box/item.d.ts +13 -5
- package/dist/grid-box/item.js +73 -56
- package/dist/grid-box/panel.d.ts +13 -1
- package/dist/grid-box/panel.js +9 -2
- package/dist/grid-box/root.d.ts +11 -5
- package/dist/grid-box/root.js +11 -2
- package/dist/grid-box/use-aggregation-box-items.d.ts +16 -13
- package/dist/grid-box/use-aggregation-box-items.js +56 -57
- package/dist/grid-box/use-column-box-items.d.ts +33 -23
- package/dist/grid-box/use-column-box-items.js +87 -75
- package/dist/grid-box/use-row-group-box-items.d.ts +17 -12
- package/dist/grid-box/use-row-group-box-items.js +120 -123
- package/dist/grid-provider/context.d.ts +4 -2
- package/dist/grid-provider/provider.d.ts +4 -2
- package/dist/grid-provider/use-grid.d.ts +1 -1
- package/dist/grid.d.ts +126 -14
- package/dist/grid.js +14 -14
- package/dist/header/header-cell.d.ts +13 -5
- package/dist/header/header-cell.js +41 -15
- package/dist/header/header-group-cell.d.ts +10 -2
- package/dist/header/header-group-cell.js +26 -8
- package/dist/header/header-row.d.ts +10 -2
- package/dist/header/header-row.js +2 -2
- package/dist/header/header.d.ts +10 -1
- package/dist/header/header.js +11 -2
- package/dist/header/resize-handler.d.ts +15 -6
- package/dist/header/resize-handler.js +131 -122
- package/dist/header/use-drag-move.d.ts +22 -11
- package/dist/header/use-drag-move.js +95 -94
- package/dist/header/use-header-cell-renderer.d.ts +9 -2
- package/dist/header/use-header-cell-renderer.js +25 -29
- package/dist/icons/index.d.ts +92 -1
- package/dist/icons/index.js +92 -1
- package/dist/index.d.ts +22 -5
- package/dist/index.js +22 -5
- package/dist/license.js +174 -174
- package/dist/listbox/context.d.ts +2 -2
- package/dist/listbox/item.d.ts +10 -1
- package/dist/listbox/item.js +23 -19
- package/dist/listbox/panel.d.ts +10 -1
- package/dist/listbox/panel.js +69 -43
- package/dist/listbox/root.d.ts +5 -3
- package/dist/listbox/root.js +7 -7
- package/dist/root/dialog-driver.js +22 -16
- package/dist/root/popover-driver.js +27 -16
- package/dist/root/root.d.ts +7 -3
- package/dist/root/root.js +111 -107
- package/dist/row-data-source-client/+types.d.ts +17 -17
- package/dist/row-data-source-client/built-ins/avg.js +3 -4
- 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 +3 -5
- 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 +9 -13
- package/dist/row-data-source-client/built-ins/min.js +9 -13
- package/dist/row-data-source-client/built-ins/sum.js +8 -10
- package/dist/row-data-source-client/filter/+types.d.ts +35 -13
- package/dist/row-data-source-client/filter/compute-filtered-rows.d.ts +16 -2
- 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 +8 -4
- package/dist/row-data-source-client/pivots/create-agg-model.js +8 -9
- package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.d.ts +6 -1
- package/dist/row-data-source-client/pivots/create-pivot-columns-from-paths.js +42 -46
- package/dist/row-data-source-client/pivots/create-pivot-columns.d.ts +6 -1
- package/dist/row-data-source-client/pivots/create-pivot-columns.js +16 -17
- package/dist/row-data-source-client/pivots/create-pivot-tree.d.ts +7 -1
- package/dist/row-data-source-client/pivots/create-pivot-tree.js +19 -19
- package/dist/row-data-source-client/tree/client-tree.d.ts +19 -13
- package/dist/row-data-source-client/tree/client-tree.js +64 -67
- package/dist/row-data-source-client/tree/evaluator-aggregation.d.ts +4 -1
- package/dist/row-data-source-client/tree/evaluator-aggregation.js +6 -6
- package/dist/row-data-source-client/tree/evaluator-group.d.ts +4 -1
- package/dist/row-data-source-client/tree/evaluator-group.js +6 -7
- package/dist/row-data-source-client/tree/traverse.d.ts +5 -1
- package/dist/row-data-source-client/tree/traverse.js +15 -18
- package/dist/row-data-source-client/use-client-data-source-paginated.d.ts +9 -5
- package/dist/row-data-source-client/use-client-data-source-paginated.js +566 -551
- package/dist/row-data-source-client/use-client-data-source.d.ts +9 -5
- package/dist/row-data-source-client/use-client-data-source.js +696 -661
- package/dist/row-data-source-client/use-client-tree-data-source.d.ts +9 -5
- package/dist/row-data-source-client/use-client-tree-data-source.js +523 -512
- package/dist/row-data-source-server/async-tree/+types.async-tree.d.ts +36 -33
- package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.d.ts +4 -1
- package/dist/row-data-source-server/async-tree/apply-delete-action-to-tree.js +18 -22
- package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.d.ts +4 -1
- package/dist/row-data-source-server/async-tree/apply-set-action-to-tree.js +17 -25
- 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 +9 -10
- package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.d.ts +4 -1
- package/dist/row-data-source-server/async-tree/check-set-action-item-keys-fit.js +13 -14
- package/dist/row-data-source-server/async-tree/check-set-action-item-kinds.js +9 -10
- package/dist/row-data-source-server/async-tree/get-parent-node-by-path.d.ts +4 -1
- 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 +4 -1
- 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 +3 -1
- 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 +5 -1
- package/dist/row-data-source-server/async-tree/maybe-apply-resize.js +11 -14
- package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.d.ts +4 -1
- package/dist/row-data-source-server/async-tree/maybe-apply-set-action-items.js +42 -46
- 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 +49 -48
- package/dist/row-data-source-server/use-server-data-source.d.ts +11 -2
- package/dist/row-data-source-server/use-server-data-source.js +688 -675
- 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 +3 -4
- package/dist/rows/row/context.d.ts +2 -2
- package/dist/rows/row/row.d.ts +16 -3
- package/dist/rows/row/row.js +19 -4
- package/dist/rows/row/use-row-context-value.d.ts +5 -2
- package/dist/rows/row/use-row-context-value.js +23 -26
- package/dist/rows/row-detail-row.d.ts +4 -2
- package/dist/rows/row-detail-row.js +147 -124
- package/dist/rows/row-full-width.d.ts +12 -4
- package/dist/rows/row-full-width.js +35 -7
- package/dist/rows/rows-container.d.ts +10 -1
- package/dist/rows/rows-container.js +12 -3
- package/dist/rows/rows-sections.d.ts +30 -3
- package/dist/rows/rows-sections.js +42 -10
- package/dist/rows/scrollers/native-scroller.d.ts +3 -1
- package/dist/rows/scrollers/native-scroller.js +17 -13
- package/dist/sort-manager/+types.d.ts +14 -7
- 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 +45 -49
- package/dist/sort-manager/hooks/use-sort-row-item.d.ts +57 -46
- package/dist/sort-manager/hooks/use-sort-row-item.js +126 -131
- package/dist/sort-manager/hooks/use-sortable-column-items.d.ts +6 -3
- package/dist/sort-manager/hooks/use-sortable-column-items.js +10 -10
- package/dist/sort-manager/root.d.ts +7 -1
- package/dist/sort-manager/root.js +10 -10
- package/dist/sort-manager/sort-add.d.ts +13 -5
- package/dist/sort-manager/sort-add.js +8 -8
- package/dist/sort-manager/sort-apply.d.ts +12 -4
- package/dist/sort-manager/sort-apply.js +16 -16
- package/dist/sort-manager/sort-cancel.d.ts +12 -4
- package/dist/sort-manager/sort-cancel.js +19 -19
- package/dist/sort-manager/sort-clear.d.ts +12 -4
- package/dist/sort-manager/sort-clear.js +15 -16
- package/dist/sort-manager/sort-column-select.d.ts +14 -6
- package/dist/sort-manager/sort-column-select.js +22 -14
- package/dist/sort-manager/sort-direction-select.d.ts +14 -6
- package/dist/sort-manager/sort-direction-select.js +27 -19
- package/dist/sort-manager/sort-manager.d.ts +93 -12
- package/dist/sort-manager/sort-manager.js +12 -12
- package/dist/sort-manager/sort-remove.d.ts +12 -4
- package/dist/sort-manager/sort-remove.js +8 -8
- package/dist/sort-manager/sort-row.d.ts +10 -2
- package/dist/sort-manager/sort-row.js +4 -1
- package/dist/sort-manager/sort-rows.d.ts +10 -1
- package/dist/sort-manager/sort-rows.js +1 -1
- package/dist/sort-manager/sort-value-select.d.ts +15 -7
- package/dist/sort-manager/sort-value-select.js +28 -19
- package/dist/sort-manager/utils/sort-item-to-sort-model.d.ts +4 -1
- package/dist/sort-manager/utils/sort-item-to-sort-model.js +46 -49
- package/dist/sort-manager/utils/sort-model-to-sort-items.d.ts +4 -1
- package/dist/sort-manager/utils/sort-model-to-sort-items.js +36 -44
- package/dist/state/+types.d.ts +43 -29
- package/dist/state/api/column-autosize.d.ts +4 -2
- package/dist/state/api/column-autosize.js +62 -63
- package/dist/state/api/column-by-id.js +4 -4
- package/dist/state/api/column-field.js +17 -20
- 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 +48 -46
- package/dist/state/api/column-resize.js +9 -7
- package/dist/state/api/column-update.d.ts +4 -2
- package/dist/state/api/column-update.js +23 -23
- package/dist/state/api/dialog-frame.d.ts +8 -4
- package/dist/state/api/dialog-frame.js +11 -12
- package/dist/state/api/edit-begin.d.ts +4 -2
- package/dist/state/api/edit-begin.js +71 -84
- package/dist/state/api/edit-end.d.ts +4 -2
- package/dist/state/api/edit-end.js +38 -41
- package/dist/state/api/edit-is-cell-active.d.ts +4 -2
- package/dist/state/api/edit-is-cell-active.js +17 -24
- package/dist/state/api/edit-update.d.ts +4 -2
- package/dist/state/api/edit-update.js +74 -85
- package/dist/state/api/event-listeners.d.ts +12 -3
- package/dist/state/api/event-listeners.js +16 -17
- package/dist/state/api/export-csv.js +33 -35
- package/dist/state/api/export-data-rect.js +21 -21
- package/dist/state/api/focus-cell.d.ts +4 -2
- package/dist/state/api/focus-cell.js +110 -109
- package/dist/state/api/popover-frame.d.ts +8 -4
- package/dist/state/api/popover-frame.js +11 -12
- package/dist/state/api/position-from-element.js +5 -6
- package/dist/state/api/row-by-id.js +3 -3
- package/dist/state/api/row-by-index.js +11 -6
- package/dist/state/api/row-detail-is-expanded.d.ts +3 -1
- package/dist/state/api/row-detail-is-expanded.js +4 -4
- package/dist/state/api/row-detail-rendered-height.d.ts +4 -2
- package/dist/state/api/row-detail-rendered-height.js +10 -12
- package/dist/state/api/row-detail-toggle.js +26 -30
- package/dist/state/api/row-group-apply-expansions.d.ts +3 -1
- package/dist/state/api/row-group-apply-expansions.js +15 -17
- package/dist/state/api/row-group-column-index.d.ts +3 -1
- package/dist/state/api/row-group-column-index.js +14 -12
- package/dist/state/api/row-group-is-expanded.d.ts +3 -1
- package/dist/state/api/row-group-is-expanded.js +11 -13
- package/dist/state/api/row-group-toggle.js +5 -5
- package/dist/state/api/row-handle-select.d.ts +4 -2
- package/dist/state/api/row-handle-select.js +36 -40
- package/dist/state/api/row-select-all.js +14 -15
- package/dist/state/api/row-select.d.ts +4 -2
- package/dist/state/api/row-select.js +30 -33
- package/dist/state/api/row-selected.js +10 -11
- package/dist/state/api/scroll-into-view.d.ts +4 -2
- package/dist/state/api/scroll-into-view.js +47 -47
- package/dist/state/api/sort-for-column.js +6 -7
- package/dist/state/api/use-row-drag.js +22 -24
- package/dist/state/helpers/cell-row-group.d.ts +5 -1
- package/dist/state/helpers/cell-row-group.js +18 -16
- package/dist/state/helpers/column-add-row-group.d.ts +18 -7
- package/dist/state/helpers/column-add-row-group.js +71 -66
- package/dist/state/helpers/column-layout.d.ts +7 -1
- package/dist/state/helpers/column-layout.js +60 -60
- package/dist/state/helpers/column-marker.d.ts +8 -4
- package/dist/state/helpers/column-marker.js +38 -34
- package/dist/state/helpers/column-view.d.ts +21 -15
- package/dist/state/helpers/column-view.js +56 -32
- package/dist/state/helpers/edit-on-change.d.ts +18 -10
- 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 +20 -10
- package/dist/state/helpers/get-data-rect.js +67 -62
- package/dist/state/helpers/get-full-width-callback.d.ts +5 -1
- package/dist/state/helpers/get-full-width-callback.js +5 -6
- package/dist/state/helpers/get-span-callback.d.ts +6 -1
- package/dist/state/helpers/get-span-callback.js +15 -18
- package/dist/state/helpers/resolve-column.d.ts +6 -2
- package/dist/state/helpers/resolve-column.js +23 -23
- package/dist/state/helpers/row-layout/get-focus-criteria.d.ts +15 -12
- package/dist/state/helpers/row-layout/get-focus-criteria.js +57 -56
- package/dist/state/helpers/row-layout/row-layout.d.ts +15 -9
- package/dist/state/helpers/row-layout/row-layout.js +387 -401
- package/dist/state/use-lytenyte.js +567 -528
- package/dist/tree-view/branch/branch.d.ts +19 -11
- package/dist/tree-view/branch/branch.js +106 -54
- package/dist/tree-view/branch/use-branch-keys.d.ts +5 -1
- package/dist/tree-view/branch/use-branch-keys.js +71 -74
- package/dist/tree-view/context.d.ts +21 -17
- package/dist/tree-view/hooks/use-tree-view-paths.d.ts +7 -1
- package/dist/tree-view/hooks/use-tree-view-paths.js +5 -5
- package/dist/tree-view/index.d.ts +35 -7
- package/dist/tree-view/index.js +7 -7
- package/dist/tree-view/leaf.d.ts +10 -2
- package/dist/tree-view/leaf.js +30 -21
- 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 +6 -8
- package/dist/tree-view/navigation/get-prev-node.js +6 -8
- package/dist/tree-view/panel/make-handle-navigation.js +23 -31
- package/dist/tree-view/panel/make-handle-selection.js +68 -77
- package/dist/tree-view/panel/make-handle-typeahead.js +34 -40
- package/dist/tree-view/panel/panel.d.ts +10 -1
- package/dist/tree-view/panel/panel.js +40 -20
- package/dist/tree-view/panel/use-tree-navigation.js +64 -52
- package/dist/tree-view/root.d.ts +20 -14
- package/dist/tree-view/root.js +53 -55
- package/dist/tree-view/utils/get-focusable-nodes.js +4 -2
- package/dist/tree-view/utils/get-focused-node.js +11 -11
- package/dist/tree-view/utils/get-ids-between-nodes.d.ts +5 -1
- package/dist/tree-view/utils/get-ids-between-nodes.js +10 -11
- package/dist/tree-view/utils/get-panel.js +5 -5
- package/dist/tree-view/utils/get-parent-node.js +6 -7
- package/dist/tree-view/utils/get-sibling-branches.js +8 -10
- 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 +5 -1
- package/dist/tree-view/utils/select-node.js +8 -11
- package/dist/tree-view/utils/toggle-all-selections.js +4 -6
- package/dist/tree-view/utils/toggle-selection.js +15 -18
- package/dist/tree-view/virtualized/force-sync-scrolling.d.ts +3 -1
- package/dist/tree-view/virtualized/force-sync-scrolling.js +24 -18
- package/dist/tree-view/virtualized/get-virtual-tree-paths.d.ts +3 -1
- package/dist/tree-view/virtualized/get-virtual-tree-paths.js +11 -12
- package/dist/tree-view/virtualized/make-virtual-tree.d.ts +26 -21
- package/dist/tree-view/virtualized/make-virtual-tree.js +79 -85
- package/dist/tree-view/virtualized/use-flattened-tree.d.ts +17 -8
- package/dist/tree-view/virtualized/use-flattened-tree.js +30 -31
- package/dist/tree-view/virtualized/use-row-start-and-end.d.ts +6 -1
- package/dist/tree-view/virtualized/use-row-start-and-end.js +21 -23
- package/dist/tree-view/virtualized/use-virtualized-tree.d.ts +21 -15
- package/dist/tree-view/virtualized/use-virtualized-tree.js +103 -90
- package/dist/utils/cycle-sorts.js +12 -14
- package/dist/viewport/begin-editing.d.ts +6 -2
- package/dist/viewport/begin-editing.js +9 -13
- package/dist/viewport/viewport.d.ts +10 -1
- package/dist/viewport/viewport.js +93 -70
- package/package.json +7 -7
|
@@ -2,58 +2,61 @@
|
|
|
2
2
|
* The root of the async tree. This is the entry point of the tree.
|
|
3
3
|
*/
|
|
4
4
|
export type TreeRoot<K, D> = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
readonly kind: "root";
|
|
6
|
+
readonly byPath: Map<string | null, LeafOrParent<K, D>>;
|
|
7
|
+
readonly byIndex: Map<number, LeafOrParent<K, D>>;
|
|
8
|
+
readonly size: number;
|
|
9
|
+
readonly asOf: number;
|
|
10
10
|
};
|
|
11
11
|
export type TreeParent<K, D> = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
readonly kind: "parent";
|
|
13
|
+
readonly relIndex: number;
|
|
14
|
+
readonly data: K;
|
|
15
|
+
readonly asOf: number;
|
|
16
|
+
readonly byPath: Map<string | null, LeafOrParent<K, D>>;
|
|
17
|
+
readonly byIndex: Map<number, LeafOrParent<K, D>>;
|
|
18
|
+
readonly size: number;
|
|
19
|
+
readonly path: string | null;
|
|
20
|
+
readonly parent: TreeParent<K, D> | TreeRoot<K, D>;
|
|
21
21
|
};
|
|
22
22
|
export type TreeLeaf<K, D> = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
readonly kind: "leaf";
|
|
24
|
+
readonly relIndex: number;
|
|
25
|
+
readonly data: D;
|
|
26
|
+
readonly asOf: number;
|
|
27
|
+
readonly parent: TreeParent<K, D> | TreeRoot<K, D>;
|
|
28
|
+
readonly path: string;
|
|
29
29
|
};
|
|
30
30
|
export type LeafOrParent<K, D> = TreeLeaf<K, D> | TreeParent<K, D>;
|
|
31
31
|
export type TreeRootAndApi<K, D> = TreeRoot<K, D> & {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
readonly set: (payload: SetDataAction<K, D>) => void;
|
|
33
|
+
readonly delete: (path: DeleteDataAction) => void;
|
|
34
|
+
readonly get: (payload: GetDataAction) => TreeRoot<K, D> | TreeParent<K, D> | null;
|
|
35
35
|
};
|
|
36
36
|
export interface SetDataAction<K = any, D = any> {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
readonly path: (string | null)[];
|
|
38
|
+
readonly asOf?: number;
|
|
39
|
+
readonly size?: number;
|
|
40
|
+
readonly items?: (
|
|
41
|
+
| {
|
|
41
42
|
kind: "parent";
|
|
42
43
|
path: string | null;
|
|
43
44
|
data: K;
|
|
44
45
|
relIndex: number;
|
|
45
46
|
size: number;
|
|
46
|
-
|
|
47
|
+
}
|
|
48
|
+
| {
|
|
47
49
|
kind: "leaf";
|
|
48
50
|
data: D;
|
|
49
51
|
relIndex: number;
|
|
50
|
-
|
|
52
|
+
}
|
|
53
|
+
)[];
|
|
51
54
|
}
|
|
52
55
|
export interface DeleteDataAction {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
+
readonly path: (string | null)[];
|
|
57
|
+
readonly paths?: string[];
|
|
58
|
+
readonly relIndices?: number[];
|
|
56
59
|
}
|
|
57
60
|
export interface GetDataAction {
|
|
58
|
-
|
|
61
|
+
readonly path: (string | null)[];
|
|
59
62
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { DeleteDataAction, TreeRoot } from "./+types.async-tree";
|
|
2
|
-
export declare function applyDeleteActionToTree<K, D>(
|
|
2
|
+
export declare function applyDeleteActionToTree<K, D>(
|
|
3
|
+
p: DeleteDataAction,
|
|
4
|
+
tree: TreeRoot<K, D>,
|
|
5
|
+
): void;
|
|
@@ -1,27 +1,23 @@
|
|
|
1
1
|
import { getParentNodeByPath } from "./get-parent-node-by-path.js";
|
|
2
2
|
export function applyDeleteActionToTree(p, tree) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
continue;
|
|
14
|
-
parentNode.byPath.delete(node.path);
|
|
15
|
-
parentNode.byIndex.delete(rel);
|
|
16
|
-
}
|
|
3
|
+
// No op. We aren't deleting keys or indices
|
|
4
|
+
if (!p.relIndices?.length && !p.paths?.length) return;
|
|
5
|
+
const parentNode = getParentNodeByPath(tree, p.path);
|
|
6
|
+
if (!parentNode) return;
|
|
7
|
+
if (p.relIndices) {
|
|
8
|
+
for (const rel of p.relIndices) {
|
|
9
|
+
const node = parentNode.byIndex.get(rel);
|
|
10
|
+
if (!node) continue;
|
|
11
|
+
parentNode.byPath.delete(node.path);
|
|
12
|
+
parentNode.byIndex.delete(rel);
|
|
17
13
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
14
|
+
}
|
|
15
|
+
if (p.paths) {
|
|
16
|
+
for (const path of p.paths) {
|
|
17
|
+
const node = parentNode.byPath.get(path);
|
|
18
|
+
if (!node) continue;
|
|
19
|
+
parentNode.byPath.delete(node.path);
|
|
20
|
+
parentNode.byIndex.delete(node.relIndex);
|
|
26
21
|
}
|
|
22
|
+
}
|
|
27
23
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { SetDataAction, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function applySetActionToTree<K, D>(
|
|
2
|
+
export declare function applySetActionToTree<K, D>(
|
|
3
|
+
p: SetDataAction<K, D>,
|
|
4
|
+
root: TreeRoot<K, D>,
|
|
5
|
+
): boolean;
|
|
@@ -8,29 +8,21 @@ import { isSetActionANoOpOnNode } from "./is-set-action-a-no-op-on-node.js";
|
|
|
8
8
|
import { maybeApplyResize } from "./maybe-apply-resize.js";
|
|
9
9
|
import { maybeApplySetActionItems } from "./maybe-apply-set-action-items.js";
|
|
10
10
|
export function applySetActionToTree(p, root) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return false;
|
|
29
|
-
if (isSetActionANoOpOnNode(p, pathNode))
|
|
30
|
-
return false;
|
|
31
|
-
maybeApplyResize(pathNode, p.size, p.asOf ?? Date.now());
|
|
32
|
-
if (maybeApplyParentRemoveSelf(pathNode))
|
|
33
|
-
return true;
|
|
34
|
-
maybeApplySetActionItems(p, pathNode);
|
|
35
|
-
return true;
|
|
11
|
+
// If we are not adding items and we are not resizing a node, then we just
|
|
12
|
+
// return our previous data and skip the update. This is effectively a no-op.
|
|
13
|
+
if (!p.items?.length && p.size == null) return false;
|
|
14
|
+
// We need to find the parent that we are adding data to. Its possible the path is invalid.
|
|
15
|
+
// If we encounter an invalid path we return early without change. An invalid path is a
|
|
16
|
+
// path that does not exist or where there is a leaf node at some point in the path.
|
|
17
|
+
const pathNode = getParentNodeByPath(root, p.path);
|
|
18
|
+
if (!pathNode) return false;
|
|
19
|
+
if (!checkSetActionItemKeysFit(p, pathNode)) return false;
|
|
20
|
+
if (!checkSetActionItemKinds(p)) return false;
|
|
21
|
+
if (!checkSetActionItemKeysAreValid(p)) return false;
|
|
22
|
+
if (!checkSetActionItemKeysAreUnique(p)) return false;
|
|
23
|
+
if (isSetActionANoOpOnNode(p, pathNode)) return false;
|
|
24
|
+
maybeApplyResize(pathNode, p.size, p.asOf ?? Date.now());
|
|
25
|
+
if (maybeApplyParentRemoveSelf(pathNode)) return true;
|
|
26
|
+
maybeApplySetActionItems(p, pathNode);
|
|
27
|
+
return true;
|
|
36
28
|
}
|
|
@@ -2,23 +2,23 @@ import { ROOT_LEAF_PREFIX } from "./+constants.async-tree.js";
|
|
|
2
2
|
const invalidItemKeyDupes = "Invalid set action items, the same 'key' appears more than once";
|
|
3
3
|
const invalidItemPathsDupes = "Invalid set action items, the same 'path' appears more than once";
|
|
4
4
|
export function checkSetActionItemKeysAreUnique(p) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const pathId = item.kind === "leaf" ? `${p.path.at(-1) ?? ROOT_LEAF_PREFIX}#${item.relIndex}` : item.path;
|
|
16
|
-
if (seenPaths.has(pathId)) {
|
|
17
|
-
console.error(invalidItemPathsDupes, p);
|
|
18
|
-
return false;
|
|
19
|
-
}
|
|
20
|
-
seenPaths.add(pathId);
|
|
21
|
-
seenKeys.add(item.relIndex);
|
|
5
|
+
const seenKeys = new Set();
|
|
6
|
+
const seenPaths = new Set();
|
|
7
|
+
if (!p.items?.length) return true;
|
|
8
|
+
for (let i = p.items.length - 1; i >= 0; i--) {
|
|
9
|
+
const item = p.items[i];
|
|
10
|
+
if (seenKeys.has(item.relIndex)) {
|
|
11
|
+
console.error(invalidItemKeyDupes, p);
|
|
12
|
+
return false;
|
|
22
13
|
}
|
|
23
|
-
|
|
14
|
+
const pathId =
|
|
15
|
+
item.kind === "leaf" ? `${p.path.at(-1) ?? ROOT_LEAF_PREFIX}#${item.relIndex}` : item.path;
|
|
16
|
+
if (seenPaths.has(pathId)) {
|
|
17
|
+
console.error(invalidItemPathsDupes, p);
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
seenPaths.add(pathId);
|
|
21
|
+
seenKeys.add(item.relIndex);
|
|
22
|
+
}
|
|
23
|
+
return true;
|
|
24
24
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
const invalidItemKeyType = "Invalid set action items, 'relIndex' must be a positive integer";
|
|
2
2
|
export function checkSetActionItemKeysAreValid(p) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
3
|
+
if (!p.items?.length) return true;
|
|
4
|
+
const items = p.items;
|
|
5
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
6
|
+
const x = items[i];
|
|
7
|
+
if (typeof x.relIndex !== "number" || x.relIndex < 0 || Math.floor(x.relIndex) !== x.relIndex) {
|
|
8
|
+
console.error(invalidItemKeyType, p);
|
|
9
|
+
return false;
|
|
12
10
|
}
|
|
13
|
-
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
14
13
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { SetDataAction, TreeParent, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function checkSetActionItemKeysFit<K, D>(
|
|
2
|
+
export declare function checkSetActionItemKeysFit<K, D>(
|
|
3
|
+
p: SetDataAction<K, D>,
|
|
4
|
+
pathNode: TreeParent<K, D> | TreeRoot<K, D>,
|
|
5
|
+
): boolean;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
const invalidItemKeySize = "Invalid set action items, 'relIndex' must be less than parent size";
|
|
2
2
|
export function checkSetActionItemKeysFit(p, pathNode) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
3
|
+
// If we are not adding any items, then the items definitely fit - since 0 fits in 0.
|
|
4
|
+
if (!p.items?.length) return true;
|
|
5
|
+
// Grab the node size. The action may be updating the size, so we check for that first, otherwise
|
|
6
|
+
// we check if the current size.
|
|
7
|
+
const size = p.size ?? pathNode.size;
|
|
8
|
+
// We check the relative item indices. They should be within the size.
|
|
9
|
+
for (let i = p.items.length - 1; i >= 0; i--) {
|
|
10
|
+
const x = p.items[i];
|
|
11
|
+
if (x.relIndex >= size) {
|
|
12
|
+
console.error(invalidItemKeySize, p, pathNode);
|
|
13
|
+
return false;
|
|
16
14
|
}
|
|
17
|
-
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
18
17
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
const invalidItemKind = "Invalid set action items, 'kind' must be 'leaf' or 'parent'";
|
|
2
2
|
export function checkSetActionItemKinds(p) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
3
|
+
if (!p.items?.length) return true;
|
|
4
|
+
const items = p.items;
|
|
5
|
+
for (let i = items.length - 1; i >= 0; i--) {
|
|
6
|
+
const x = items[i];
|
|
7
|
+
if (x.kind !== "leaf" && x.kind !== "parent") {
|
|
8
|
+
console.error(invalidItemKind, p);
|
|
9
|
+
return false;
|
|
12
10
|
}
|
|
13
|
-
|
|
11
|
+
}
|
|
12
|
+
return true;
|
|
14
13
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { TreeParent, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function getParentNodeByPath<K, D>(
|
|
2
|
+
export declare function getParentNodeByPath<K, D>(
|
|
3
|
+
tree: TreeRoot<K, D>,
|
|
4
|
+
path: (string | null)[],
|
|
5
|
+
): TreeRoot<K, D> | TreeParent<K, D> | null;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
const invalidPathRoute = "Invalid path specified. Paths must be built up incrementally.";
|
|
2
2
|
const invalidPathChild = "Invalid path specified. Leaf nodes can have children.";
|
|
3
3
|
export function getParentNodeByPath(tree, path) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
if (next.kind === "leaf") {
|
|
12
|
-
console.error(invalidPathChild, path.slice(0, i));
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
15
|
-
target = next;
|
|
4
|
+
let target = tree;
|
|
5
|
+
for (let i = 0; i < path.length; i++) {
|
|
6
|
+
const next = target.byPath.get(path[i]);
|
|
7
|
+
if (!next) {
|
|
8
|
+
console.error(invalidPathRoute, path.slice(0, i));
|
|
9
|
+
return null;
|
|
16
10
|
}
|
|
17
|
-
|
|
11
|
+
if (next.kind === "leaf") {
|
|
12
|
+
console.error(invalidPathChild, path.slice(0, i));
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
target = next;
|
|
16
|
+
}
|
|
17
|
+
return target;
|
|
18
18
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { SetDataAction, TreeParent, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function isSetActionANoOpOnNode<K, D>(
|
|
2
|
+
export declare function isSetActionANoOpOnNode<K, D>(
|
|
3
|
+
p: SetDataAction<K, D>,
|
|
4
|
+
pathNode: TreeParent<K, D> | TreeRoot<K, D>,
|
|
5
|
+
): boolean;
|
|
@@ -2,18 +2,18 @@ import { applyDeleteActionToTree } from "./apply-delete-action-to-tree.js";
|
|
|
2
2
|
import { applySetActionToTree } from "./apply-set-action-to-tree.js";
|
|
3
3
|
import { getParentNodeByPath } from "./get-parent-node-by-path.js";
|
|
4
4
|
export function makeAsyncTree() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
5
|
+
const tree = {
|
|
6
|
+
kind: "root",
|
|
7
|
+
byIndex: new Map(),
|
|
8
|
+
byPath: new Map(),
|
|
9
|
+
size: 0,
|
|
10
|
+
asOf: Date.now(),
|
|
11
|
+
};
|
|
12
|
+
const api = {
|
|
13
|
+
set: (p) => applySetActionToTree(p, tree),
|
|
14
|
+
delete: (p) => applyDeleteActionToTree(p, tree),
|
|
15
|
+
get: (p) => getParentNodeByPath(tree, p.path),
|
|
16
|
+
};
|
|
17
|
+
Object.assign(tree, api);
|
|
18
|
+
return tree;
|
|
19
19
|
}
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { TreeParent, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function maybeApplyParentRemoveSelf<K, D>(
|
|
2
|
+
export declare function maybeApplyParentRemoveSelf<K, D>(
|
|
3
|
+
pathNode: TreeParent<K, D> | TreeRoot<K, D>,
|
|
4
|
+
): boolean;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export function maybeApplyParentRemoveSelf(pathNode) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
if (!pathNode.size && pathNode.kind === "parent") {
|
|
3
|
+
pathNode.parent.byPath.delete(pathNode.path);
|
|
4
|
+
pathNode.parent.byIndex.delete(pathNode.relIndex);
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
8
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
1
|
import type { TreeParent, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function maybeApplyResize<K, D>(
|
|
2
|
+
export declare function maybeApplyResize<K, D>(
|
|
3
|
+
pathNode: TreeParent<K, D> | TreeRoot<K, D>,
|
|
4
|
+
size: number | undefined,
|
|
5
|
+
asOf: number,
|
|
6
|
+
): boolean;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
export function maybeApplyResize(pathNode, size, asOf) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (number >= size) {
|
|
12
|
-
pathNode.byIndex.delete(number);
|
|
13
|
-
pathNode.byPath.delete(node.path);
|
|
14
|
-
}
|
|
2
|
+
if (size == null) return false;
|
|
3
|
+
if (size === pathNode.size) return false;
|
|
4
|
+
if (pathNode.asOf > asOf) return false;
|
|
5
|
+
pathNode.size = size;
|
|
6
|
+
// Remove those nodes that are no long within the allowed size
|
|
7
|
+
for (const [number, node] of pathNode.byIndex) {
|
|
8
|
+
if (number >= size) {
|
|
9
|
+
pathNode.byIndex.delete(number);
|
|
10
|
+
pathNode.byPath.delete(node.path);
|
|
15
11
|
}
|
|
16
|
-
|
|
12
|
+
}
|
|
13
|
+
return true;
|
|
17
14
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import type { SetDataAction, TreeParent, TreeRoot } from "./+types.async-tree.js";
|
|
2
|
-
export declare function maybeApplySetActionItems<K, D>(
|
|
2
|
+
export declare function maybeApplySetActionItems<K, D>(
|
|
3
|
+
p: SetDataAction<K, D>,
|
|
4
|
+
pathNode: TreeParent<K, D> | TreeRoot<K, D>,
|
|
5
|
+
): boolean;
|
|
@@ -1,51 +1,47 @@
|
|
|
1
1
|
import { ROOT_LEAF_PREFIX } from "./+constants.async-tree.js";
|
|
2
2
|
export function maybeApplySetActionItems(p, pathNode) {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
if (!p.items?.length) {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
const asOf = p.asOf ?? Date.now();
|
|
7
|
+
for (let i = 0; i < p.items.length; i++) {
|
|
8
|
+
const item = p.items[i];
|
|
9
|
+
const path =
|
|
10
|
+
item.kind === "leaf" ? `${p.path.at(-1) ?? ROOT_LEAF_PREFIX}#${item.relIndex}` : item.path;
|
|
11
|
+
const existingIndex = pathNode.byIndex.get(item.relIndex);
|
|
12
|
+
if (existingIndex) {
|
|
13
|
+
pathNode.byPath.delete(existingIndex.path);
|
|
14
|
+
pathNode.byIndex.delete(item.relIndex);
|
|
5
15
|
}
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const existingIndex = pathNode.byIndex.get(item.relIndex);
|
|
11
|
-
if (existingIndex) {
|
|
12
|
-
pathNode.byPath.delete(existingIndex.path);
|
|
13
|
-
pathNode.byIndex.delete(item.relIndex);
|
|
14
|
-
}
|
|
15
|
-
const existing = pathNode.byPath.get(path);
|
|
16
|
-
if (existing) {
|
|
17
|
-
pathNode.byPath.delete(existing.path);
|
|
18
|
-
pathNode.byIndex.delete(existing.relIndex);
|
|
19
|
-
}
|
|
20
|
-
// We always replace when making a leaf
|
|
21
|
-
if (item.kind === "leaf") {
|
|
22
|
-
const node = { ...item, parent: pathNode, path: path, asOf };
|
|
23
|
-
const currentI = pathNode.byIndex.get(item.relIndex);
|
|
24
|
-
const currentP = pathNode.byPath.get(path);
|
|
25
|
-
if (!currentI || currentI.asOf < asOf)
|
|
26
|
-
pathNode.byIndex.set(item.relIndex, node);
|
|
27
|
-
if (!currentP || currentP.asOf < asOf)
|
|
28
|
-
pathNode.byPath.set(path, node);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
const node = {
|
|
32
|
-
byIndex: existing?.kind === "parent" ? existing.byIndex : new Map(),
|
|
33
|
-
byPath: existing?.kind === "parent" ? existing.byPath : new Map(),
|
|
34
|
-
data: item.data,
|
|
35
|
-
kind: "parent",
|
|
36
|
-
relIndex: item.relIndex,
|
|
37
|
-
parent: pathNode,
|
|
38
|
-
path,
|
|
39
|
-
size: item.size,
|
|
40
|
-
asOf,
|
|
41
|
-
};
|
|
42
|
-
const currentI = pathNode.byIndex.get(item.relIndex);
|
|
43
|
-
const currentP = pathNode.byPath.get(path);
|
|
44
|
-
if (!currentI || currentI.asOf < asOf)
|
|
45
|
-
pathNode.byIndex.set(item.relIndex, node);
|
|
46
|
-
if (!currentP || currentP.asOf < asOf)
|
|
47
|
-
pathNode.byPath.set(path, node);
|
|
48
|
-
}
|
|
16
|
+
const existing = pathNode.byPath.get(path);
|
|
17
|
+
if (existing) {
|
|
18
|
+
pathNode.byPath.delete(existing.path);
|
|
19
|
+
pathNode.byIndex.delete(existing.relIndex);
|
|
49
20
|
}
|
|
50
|
-
|
|
21
|
+
// We always replace when making a leaf
|
|
22
|
+
if (item.kind === "leaf") {
|
|
23
|
+
const node = { ...item, parent: pathNode, path: path, asOf };
|
|
24
|
+
const currentI = pathNode.byIndex.get(item.relIndex);
|
|
25
|
+
const currentP = pathNode.byPath.get(path);
|
|
26
|
+
if (!currentI || currentI.asOf < asOf) pathNode.byIndex.set(item.relIndex, node);
|
|
27
|
+
if (!currentP || currentP.asOf < asOf) pathNode.byPath.set(path, node);
|
|
28
|
+
} else {
|
|
29
|
+
const node = {
|
|
30
|
+
byIndex: existing?.kind === "parent" ? existing.byIndex : new Map(),
|
|
31
|
+
byPath: existing?.kind === "parent" ? existing.byPath : new Map(),
|
|
32
|
+
data: item.data,
|
|
33
|
+
kind: "parent",
|
|
34
|
+
relIndex: item.relIndex,
|
|
35
|
+
parent: pathNode,
|
|
36
|
+
path,
|
|
37
|
+
size: item.size,
|
|
38
|
+
asOf,
|
|
39
|
+
};
|
|
40
|
+
const currentI = pathNode.byIndex.get(item.relIndex);
|
|
41
|
+
const currentP = pathNode.byPath.get(path);
|
|
42
|
+
if (!currentI || currentI.asOf < asOf) pathNode.byIndex.set(item.relIndex, node);
|
|
43
|
+
if (!currentP || currentP.asOf < asOf) pathNode.byPath.set(path, node);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return true;
|
|
51
47
|
}
|