@viewkitjs/views 0.1.0 → 0.3.0
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/CHANGELOG.md +767 -1
- package/README.md +92 -41
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/Row.js +1 -1
- package/dist/atoms/RowMenu.d.ts +1 -1
- package/dist/atoms/RowMenu.js +20 -6
- package/dist/atoms/types.d.ts +4 -4
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +79 -8
- package/dist/contract.js +55 -8
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/format.d.ts +16 -1
- package/dist/display/format.js +10 -1
- package/dist/display/index.d.ts +2 -1
- package/dist/display/index.js +2 -1
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +12 -6
- package/dist/display/location.d.ts +4 -3
- package/dist/display/location.js +12 -5
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +8 -2
- package/dist/display/percent.js +10 -3
- package/dist/display/phone.d.ts +2 -1
- package/dist/display/phone.js +11 -2
- package/dist/display/relation.js +1 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +7 -3
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +28 -21
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +15 -10
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +7 -7
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +22 -6
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +5 -2
- package/dist/editors/ValueListEditor.js +11 -9
- package/dist/editors/edit-cores.d.ts +13 -10
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +7 -2
- package/dist/fields/binding.js +13 -6
- package/dist/fields/currency.d.ts +0 -10
- package/dist/fields/currency.js +0 -14
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +6 -0
- package/dist/fields/money.js +11 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/filters/filter-model.d.ts +0 -1
- package/dist/filters/registry.d.ts +3 -36
- package/dist/filters/registry.js +0 -38
- package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
- package/dist/grid/chrome/GridAddColumn.js +29 -0
- package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
- package/dist/grid/chrome/GridAggregateMenu.js +29 -0
- package/dist/grid/chrome/GridCellEditors.d.ts +71 -0
- package/dist/grid/chrome/GridCellEditors.js +126 -0
- package/dist/grid/chrome/GridCellOutline.d.ts +49 -0
- package/dist/grid/chrome/GridCellOutline.js +16 -0
- package/dist/grid/chrome/GridChipsEditor.d.ts +38 -0
- package/dist/grid/chrome/GridChipsEditor.js +35 -0
- package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
- package/dist/grid/chrome/GridColumnColorSection.js +40 -0
- package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
- package/dist/grid/chrome/GridColumnDateSection.js +23 -0
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
- package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
- package/dist/grid/chrome/GridColumnMenu.js +103 -0
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
- package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
- package/dist/grid/chrome/GridColumnSortSection.js +16 -0
- package/dist/grid/chrome/GridDateEditor.d.ts +34 -0
- package/dist/grid/chrome/GridDateEditor.js +19 -0
- package/dist/grid/chrome/GridFlyout.d.ts +44 -0
- package/dist/grid/chrome/GridFlyout.js +80 -0
- package/dist/grid/chrome/GridFooter.d.ts +33 -0
- package/dist/grid/chrome/GridFooter.js +85 -0
- package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
- package/dist/grid/chrome/GridGroupMenu.js +64 -0
- package/dist/grid/chrome/GridHeader.d.ts +66 -0
- package/dist/grid/chrome/GridHeader.js +42 -0
- package/dist/grid/chrome/GridLongTextEditor.d.ts +55 -0
- package/dist/grid/chrome/GridLongTextEditor.js +69 -0
- package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
- package/dist/grid/chrome/GridMenuRow.js +15 -0
- package/dist/grid/chrome/GridNameEditor.d.ts +24 -0
- package/dist/grid/chrome/GridNameEditor.js +21 -0
- package/dist/grid/chrome/GridNumberEditor.d.ts +49 -0
- package/dist/grid/chrome/GridNumberEditor.js +51 -0
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +30 -0
- package/dist/grid/chrome/GridRangeEditor.js +21 -0
- package/dist/grid/chrome/GridRelationEditor.d.ts +45 -0
- package/dist/grid/chrome/GridRelationEditor.js +92 -0
- package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
- package/dist/grid/chrome/GridResizeHandle.js +19 -0
- package/dist/grid/chrome/GridRow.d.ts +31 -0
- package/dist/grid/chrome/GridRow.js +179 -0
- package/dist/grid/chrome/GridRowActions.d.ts +32 -0
- package/dist/grid/chrome/GridRowActions.js +25 -0
- package/dist/grid/chrome/GridRowCells.d.ts +4 -0
- package/dist/grid/chrome/GridRowCells.js +128 -0
- package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
- package/dist/grid/chrome/GridRowGlyph.js +13 -0
- package/dist/grid/chrome/GridSelectEditor.d.ts +33 -0
- package/dist/grid/chrome/GridSelectEditor.js +43 -0
- package/dist/grid/chrome/GridStructure.d.ts +47 -0
- package/dist/grid/chrome/GridStructure.js +41 -0
- package/dist/grid/chrome/GridTable.d.ts +4 -0
- package/dist/grid/chrome/GridTable.js +192 -0
- package/dist/grid/chrome/GridTableSurface.d.ts +52 -0
- package/dist/grid/chrome/GridTableSurface.js +15 -0
- package/dist/grid/chrome/GridTextEditor.d.ts +45 -0
- package/dist/grid/chrome/GridTextEditor.js +38 -0
- package/dist/grid/chrome/GridValueListEditor.d.ts +30 -0
- package/dist/grid/chrome/GridValueListEditor.js +19 -0
- package/dist/grid/chrome/StuckMarker.d.ts +16 -0
- package/dist/grid/chrome/StuckMarker.js +34 -0
- package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
- package/dist/grid/chrome/cell-clipboard.js +28 -0
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.d.ts +21 -0
- package/dist/grid/chrome/cells.js +19 -0
- package/dist/grid/chrome/checks.d.ts +32 -0
- package/dist/grid/chrome/checks.js +32 -0
- package/dist/grid/chrome/column-glyph.d.ts +14 -0
- package/dist/grid/chrome/column-glyph.js +44 -0
- package/dist/grid/chrome/editors.d.ts +9 -0
- package/dist/grid/chrome/editors.js +10 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +53 -0
- package/dist/grid/chrome/grid-cell-classes.js +32 -0
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
- package/dist/grid/chrome/grid-menu-search.js +7 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +143 -0
- package/dist/grid/chrome/grid-row-props.js +1 -0
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +40 -0
- package/dist/grid/chrome/grid-styles.js +9 -0
- package/dist/grid/chrome/grid-table-props.d.ts +172 -0
- package/dist/grid/chrome/grid-table-props.js +1 -0
- package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
- package/dist/grid/chrome/useGridBatchApi.js +35 -0
- package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
- package/dist/grid/chrome/useGridColumnLayout.js +206 -0
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
- package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +64 -0
- package/dist/grid/chrome/useGridKeyboard.js +450 -0
- package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
- package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
- package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
- package/dist/grid/chrome/useGridRailReveal.js +67 -0
- package/dist/grid/chrome/useGridRangeActions.d.ts +51 -0
- package/dist/grid/chrome/useGridRangeActions.js +195 -0
- package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
- package/dist/grid/chrome/useGridRangeGestures.js +237 -0
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +37 -0
- package/dist/grid/chrome/useGridRowContextMenu.js +153 -0
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -0
- package/dist/grid/chrome/useGridScaleStyles.js +28 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +78 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +249 -0
- package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
- package/dist/grid/chrome/useGridTableSelection.js +55 -0
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
- package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
- package/dist/grid/core/clipboard-model.d.ts +83 -0
- package/dist/grid/core/clipboard-model.js +291 -0
- package/dist/grid/core/column-values.d.ts +27 -0
- package/dist/grid/core/column-values.js +76 -0
- package/dist/grid/core/commit-model.d.ts +41 -0
- package/dist/grid/core/commit-model.js +3 -0
- package/dist/grid/core/coordinates.d.ts +48 -0
- package/dist/grid/core/coordinates.js +27 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/edit-values.d.ts +9 -0
- package/dist/grid/core/edit-values.js +1 -0
- package/dist/grid/core/editing-controller.d.ts +60 -0
- package/dist/grid/core/editing-controller.js +266 -0
- package/dist/grid/core/editing-model.d.ts +87 -0
- package/dist/grid/core/editing-model.js +148 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/grid-scale.d.ts +14 -0
- package/dist/grid/core/grid-scale.js +8 -0
- package/dist/grid/core/nav.d.ts +94 -0
- package/dist/grid/core/nav.js +92 -0
- package/dist/grid/core/pending-reconciliation.d.ts +53 -0
- package/dist/grid/core/pending-reconciliation.js +51 -0
- package/dist/grid/core/range-model.d.ts +25 -0
- package/dist/grid/core/range-model.js +59 -0
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +101 -0
- package/dist/grid/core/spreadsheet-operations.js +280 -0
- package/dist/grid/core/useGridEditing.d.ts +46 -0
- package/dist/grid/core/useGridEditing.js +93 -0
- package/dist/grid/core/useGridRange.d.ts +20 -0
- package/dist/grid/core/useGridRange.js +24 -0
- package/dist/grid/core/value-equality.d.ts +54 -0
- package/dist/grid/core/value-equality.js +80 -0
- package/dist/grid/index.d.ts +18 -0
- package/dist/grid/index.js +5 -0
- package/dist/grid/useGridTablePrefs.d.ts +49 -0
- package/dist/grid/useGridTablePrefs.js +99 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/viewport.d.ts +3 -0
- package/dist/internal/viewport.js +15 -0
- package/dist/model/column-capabilities.d.ts +3 -2
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-state.d.ts +1 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/density.js +3 -3
- package/dist/model/filter-capabilities.d.ts +1 -1
- package/dist/model/filter-capabilities.js +1 -1
- package/dist/model/index.d.ts +4 -6
- package/dist/model/index.js +0 -1
- package/dist/model/preferences.d.ts +7 -7
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +6 -2
- package/dist/provider/ViewsProvider.js +12 -2
- package/dist/provider/components.d.ts +35 -9
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +8 -4
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/menu-groups.d.ts +8 -0
- package/dist/provider/menu-groups.js +38 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/provider/ports.d.ts +22 -0
- package/dist/provider/ports.js +1 -0
- package/dist/react.d.ts +3 -2
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +202 -72
- package/docs/getting-started.md +250 -0
- package/docs/guides/atoms.md +245 -0
- package/docs/guides/cells.md +302 -0
- package/docs/guides/columns.md +413 -0
- package/docs/guides/display.md +204 -0
- package/docs/guides/editors.md +462 -0
- package/docs/guides/ports.md +246 -0
- package/docs/guides/selection.md +270 -0
- package/docs/guides/the-grid.md +696 -0
- package/docs/guides/the-provider.md +448 -0
- package/docs/index.md +52 -0
- package/docs/install.md +9 -47
- package/docs/reference/cells.md +28 -0
- package/docs/reference/display.md +44 -0
- package/docs/reference/editors-chips.md +6 -0
- package/docs/reference/editors-date.md +6 -0
- package/docs/reference/editors-location.md +10 -0
- package/docs/reference/editors-name.md +6 -0
- package/docs/reference/editors-number.md +11 -0
- package/docs/reference/editors-open-values.md +10 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +6 -0
- package/docs/reference/editors-relation.md +12 -0
- package/docs/reference/editors-select.md +9 -0
- package/docs/reference/editors-session.md +11 -0
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +6 -0
- package/docs/reference/editors.md +5 -0
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +39 -0
- package/docs/reference/react.md +89 -0
- package/docs/reference/selection.md +33 -0
- package/docs/reference/views.md +622 -0
- package/package.json +27 -4
- package/skills/views/SKILL.md +20 -5
- package/dist/filters/types.d.ts +0 -27
- package/dist/filters/types.js +0 -1
- package/dist/model/filter-pushdown.d.ts +0 -106
- package/dist/model/filter-pushdown.js +0 -147
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { gridCellKey } from "./commit-model.js";
|
|
2
|
+
import { sameListValue } from "@viewkitjs/fields";
|
|
3
|
+
import { markGridKeptValue } from "./value-equality.js";
|
|
4
|
+
const GRID_UNDO_MAX = 50;
|
|
5
|
+
export function createGridHistory() {
|
|
6
|
+
return { undo: [], redo: [] };
|
|
7
|
+
}
|
|
8
|
+
export function prepareGridCommitCells(edits) {
|
|
9
|
+
return edits
|
|
10
|
+
.filter((edit) => !sameListValue(edit.next, edit.prev))
|
|
11
|
+
.map(({ row, ...cell }) => ({ row, cell }));
|
|
12
|
+
}
|
|
13
|
+
export function recordGridHistory(state, entry, maxEntries = GRID_UNDO_MAX) {
|
|
14
|
+
const undo = [...state.undo, entry];
|
|
15
|
+
if (undo.length > maxEntries)
|
|
16
|
+
undo.splice(0, undo.length - maxEntries);
|
|
17
|
+
return { undo, redo: [] };
|
|
18
|
+
}
|
|
19
|
+
export function pruneGridHistoryEntry(state, entryId, successes) {
|
|
20
|
+
const prune = (entries) => entries.flatMap((entry) => {
|
|
21
|
+
if (entry.id !== entryId)
|
|
22
|
+
return [entry];
|
|
23
|
+
const edits = entry.edits.filter((_, index) => successes[index]);
|
|
24
|
+
return edits.length > 0 ? [{ ...entry, edits }] : [];
|
|
25
|
+
});
|
|
26
|
+
return { undo: prune(state.undo), redo: prune(state.redo) };
|
|
27
|
+
}
|
|
28
|
+
export function beginGridHistoryApply(state, kind) {
|
|
29
|
+
const source = kind === "undo" ? state.undo : state.redo;
|
|
30
|
+
const entry = source[source.length - 1] ?? null;
|
|
31
|
+
if (!entry)
|
|
32
|
+
return { state, entry: null };
|
|
33
|
+
return {
|
|
34
|
+
state: kind === "undo"
|
|
35
|
+
? { undo: source.slice(0, -1), redo: state.redo }
|
|
36
|
+
: { undo: state.undo, redo: source.slice(0, -1) },
|
|
37
|
+
entry,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function settleGridHistoryApply(state, kind, entry, success) {
|
|
41
|
+
if (kind === "undo") {
|
|
42
|
+
return success
|
|
43
|
+
? { undo: state.undo, redo: [...state.redo, entry] }
|
|
44
|
+
: { undo: [...state.undo, entry], redo: state.redo };
|
|
45
|
+
}
|
|
46
|
+
return success
|
|
47
|
+
? { undo: [...state.undo, entry], redo: state.redo }
|
|
48
|
+
: { undo: state.undo, redo: [...state.redo, entry] };
|
|
49
|
+
}
|
|
50
|
+
export function gridEditValue(cell, side) {
|
|
51
|
+
return side === "next" ? cell.next : cell.prev;
|
|
52
|
+
}
|
|
53
|
+
export function gridHistoryValue(cell, side) {
|
|
54
|
+
if (side === "next" && "historyNext" in cell)
|
|
55
|
+
return cell.historyNext;
|
|
56
|
+
if (side === "prev" && "historyPrev" in cell)
|
|
57
|
+
return cell.historyPrev;
|
|
58
|
+
return gridEditValue(cell, side);
|
|
59
|
+
}
|
|
60
|
+
export function planGridPendingAssignments(cells, side, revision) {
|
|
61
|
+
return cells
|
|
62
|
+
.filter(({ cell }) => cell.overlay)
|
|
63
|
+
.map(({ cell }) => ({
|
|
64
|
+
key: gridCellKey(cell.rowId, cell.columnId),
|
|
65
|
+
value: gridEditValue(cell, side),
|
|
66
|
+
baseline: gridEditValue(cell, side === "next" ? "prev" : "next"),
|
|
67
|
+
revision,
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
export function applyGridPending(state, assignments) {
|
|
71
|
+
if (assignments.length === 0)
|
|
72
|
+
return new Map(state);
|
|
73
|
+
const next = new Map(state);
|
|
74
|
+
for (const assignment of assignments) {
|
|
75
|
+
next.set(assignment.key, {
|
|
76
|
+
value: assignment.value,
|
|
77
|
+
revision: assignment.revision,
|
|
78
|
+
baseline: assignment.baseline,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return next;
|
|
82
|
+
}
|
|
83
|
+
export function rollbackGridPending(state, assignments) {
|
|
84
|
+
const next = new Map(state);
|
|
85
|
+
for (const assignment of assignments) {
|
|
86
|
+
if (next.get(assignment.key)?.revision === assignment.revision)
|
|
87
|
+
next.delete(assignment.key);
|
|
88
|
+
}
|
|
89
|
+
return next;
|
|
90
|
+
}
|
|
91
|
+
export function markGridPendingSettlement(state, assignments, settlement) {
|
|
92
|
+
const next = new Map(state);
|
|
93
|
+
for (const assignment of assignments) {
|
|
94
|
+
const entry = next.get(assignment.key);
|
|
95
|
+
if (entry?.revision === assignment.revision)
|
|
96
|
+
next.set(assignment.key, { ...entry, settlement });
|
|
97
|
+
}
|
|
98
|
+
return next;
|
|
99
|
+
}
|
|
100
|
+
export function keepGridPending(state, kept) {
|
|
101
|
+
const next = new Map(state);
|
|
102
|
+
for (const { assignment, stored } of kept) {
|
|
103
|
+
const entry = next.get(assignment.key);
|
|
104
|
+
if (entry?.revision !== assignment.revision)
|
|
105
|
+
continue;
|
|
106
|
+
markGridKeptValue(stored);
|
|
107
|
+
next.set(assignment.key, { ...entry, value: stored });
|
|
108
|
+
}
|
|
109
|
+
return next;
|
|
110
|
+
}
|
|
111
|
+
export function reconcileGridPending(state, matchedKeys) {
|
|
112
|
+
if (matchedKeys.length === 0)
|
|
113
|
+
return new Map(state);
|
|
114
|
+
const next = new Map(state);
|
|
115
|
+
for (const key of matchedKeys)
|
|
116
|
+
next.delete(key);
|
|
117
|
+
return next;
|
|
118
|
+
}
|
|
119
|
+
export function groupGridPendingByRow(state) {
|
|
120
|
+
const byRow = new Map();
|
|
121
|
+
for (const [key, entry] of state) {
|
|
122
|
+
const separator = key.lastIndexOf(":");
|
|
123
|
+
const rowId = key.slice(0, separator);
|
|
124
|
+
const columnId = key.slice(separator + 1);
|
|
125
|
+
const existing = byRow.get(rowId);
|
|
126
|
+
if (existing)
|
|
127
|
+
existing[columnId] = entry.value;
|
|
128
|
+
else
|
|
129
|
+
byRow.set(rowId, { [columnId]: entry.value });
|
|
130
|
+
}
|
|
131
|
+
return byRow;
|
|
132
|
+
}
|
|
133
|
+
export function groupGridPendingSettlement(state) {
|
|
134
|
+
const byRow = new Map();
|
|
135
|
+
for (const [key, entry] of state) {
|
|
136
|
+
if (!entry.settlement)
|
|
137
|
+
continue;
|
|
138
|
+
const separator = key.lastIndexOf(":");
|
|
139
|
+
const rowId = key.slice(0, separator);
|
|
140
|
+
const columnId = key.slice(separator + 1);
|
|
141
|
+
const existing = byRow.get(rowId);
|
|
142
|
+
if (existing)
|
|
143
|
+
existing[columnId] = entry.settlement;
|
|
144
|
+
else
|
|
145
|
+
byRow.set(rowId, { [columnId]: entry.settlement });
|
|
146
|
+
}
|
|
147
|
+
return byRow;
|
|
148
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ListGroup } from "../../grouping/types.js";
|
|
2
|
+
/** Where one drawn row sits: its section's key and its index among that section's rows. */
|
|
3
|
+
export type GridRowPlace = {
|
|
4
|
+
groupKey: string;
|
|
5
|
+
index: number;
|
|
6
|
+
};
|
|
7
|
+
/** One list the grid draws: a group, or the one ungrouped list. */
|
|
8
|
+
export type GridFlatSection<Row> = {
|
|
9
|
+
groupKey: string;
|
|
10
|
+
items: Row[];
|
|
11
|
+
collapsed: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The grid's rows as one flat list behind the groups. It says what each section draws, the keyboard's order (the
|
|
15
|
+
* rows a person can see, group by group, as drawn) and where every row sits, so the window, the reveal and the
|
|
16
|
+
* screen reader's row numbers all read one answer.
|
|
17
|
+
*/
|
|
18
|
+
export type GridFlatRows<Row> = {
|
|
19
|
+
/** One section per drawn list: every group, or the one ungrouped list. */
|
|
20
|
+
sections: GridFlatSection<Row>[];
|
|
21
|
+
/** Row KEYS the page holds, in the drawn order, a collapsed group's rows included: what an open edit or a focus is
|
|
22
|
+
* checked against, so collapsing a group never cancels an edit in it. */
|
|
23
|
+
order: string[];
|
|
24
|
+
/** Row KEYS of the open sections, in the drawn order: the keyboard's, the range's, the paste's and the fill's
|
|
25
|
+
* order, so each skips a collapsed group's rows as a spreadsheet skips filtered ones. */
|
|
26
|
+
visible: string[];
|
|
27
|
+
/** Every row key, collapsed or not → its section and index there. */
|
|
28
|
+
place: ReadonlyMap<string, GridRowPlace>;
|
|
29
|
+
};
|
|
30
|
+
export declare function gridFlatRows<Row>({ groups, grouped, isCollapsed, getRowId, }: {
|
|
31
|
+
groups: ListGroup<Row>[];
|
|
32
|
+
grouped: boolean;
|
|
33
|
+
isCollapsed?: (key: string) => boolean;
|
|
34
|
+
getRowId: (row: Row) => string;
|
|
35
|
+
}): GridFlatRows<Row>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { gridRowKey } from "./coordinates.js";
|
|
2
|
+
const UNGROUPED_KEY = "__all__";
|
|
3
|
+
export function gridFlatRows({ groups, grouped, isCollapsed, getRowId, }) {
|
|
4
|
+
const sections = grouped
|
|
5
|
+
? groups.map((group) => ({ groupKey: group.key, items: group.items, collapsed: isCollapsed?.(group.key) ?? false }))
|
|
6
|
+
: [{ groupKey: groups[0]?.key ?? UNGROUPED_KEY, items: groups.flatMap((group) => group.items), collapsed: false }];
|
|
7
|
+
const order = [];
|
|
8
|
+
const visible = [];
|
|
9
|
+
const place = new Map();
|
|
10
|
+
for (const section of sections) {
|
|
11
|
+
section.items.forEach((row, index) => {
|
|
12
|
+
const key = gridRowKey(section.groupKey, getRowId(row));
|
|
13
|
+
place.set(key, { groupKey: section.groupKey, index });
|
|
14
|
+
order.push(key);
|
|
15
|
+
if (!section.collapsed)
|
|
16
|
+
visible.push(key);
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
return { sections, order, visible, place };
|
|
20
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export type GridAriaSection = {
|
|
2
|
+
groupKey: string;
|
|
3
|
+
collapsed: boolean;
|
|
4
|
+
count: number;
|
|
5
|
+
footer: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type GridAriaLayout = {
|
|
8
|
+
role: "grid" | "treegrid";
|
|
9
|
+
/** Every row the grid holds, bars, column names and footers included; -1 while more rows remain to load. */
|
|
10
|
+
rowCount: number;
|
|
11
|
+
/** The checkbox lane (when selectable) and every visible column. */
|
|
12
|
+
colCount: number;
|
|
13
|
+
/** 1-based; undefined for a part the section doesn't draw (a shut group's column names, rows and footer). */
|
|
14
|
+
barIndex: (groupKey: string) => number | undefined;
|
|
15
|
+
headIndex: (groupKey: string) => number | undefined;
|
|
16
|
+
rowIndex: (groupKey: string, index: number) => number | undefined;
|
|
17
|
+
footIndex: (groupKey: string) => number | undefined;
|
|
18
|
+
/** 1-based column index of a column id (GRID_RAIL_COLUMN included when selectable). */
|
|
19
|
+
colIndex: (columnId: string) => number | undefined;
|
|
20
|
+
};
|
|
21
|
+
export declare function gridAriaLayout(input: {
|
|
22
|
+
sections: readonly GridAriaSection[];
|
|
23
|
+
grouped: boolean;
|
|
24
|
+
selectable: boolean;
|
|
25
|
+
columnIds: readonly string[];
|
|
26
|
+
more: boolean;
|
|
27
|
+
}): GridAriaLayout;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { GRID_RAIL_COLUMN } from "./grid-focus.js";
|
|
2
|
+
export function gridAriaLayout(input) {
|
|
3
|
+
const bySection = new Map();
|
|
4
|
+
let next = 1;
|
|
5
|
+
for (const section of input.sections) {
|
|
6
|
+
const rows = { count: section.count };
|
|
7
|
+
if (input.grouped)
|
|
8
|
+
rows.bar = next++;
|
|
9
|
+
if (!section.collapsed || !input.grouped) {
|
|
10
|
+
rows.head = next++;
|
|
11
|
+
rows.firstRow = next;
|
|
12
|
+
next += section.count;
|
|
13
|
+
if (section.footer)
|
|
14
|
+
rows.foot = next++;
|
|
15
|
+
}
|
|
16
|
+
bySection.set(section.groupKey, rows);
|
|
17
|
+
}
|
|
18
|
+
const columns = new Map();
|
|
19
|
+
let col = 1;
|
|
20
|
+
if (input.selectable)
|
|
21
|
+
columns.set(GRID_RAIL_COLUMN, col++);
|
|
22
|
+
for (const id of input.columnIds)
|
|
23
|
+
columns.set(id, col++);
|
|
24
|
+
return {
|
|
25
|
+
role: input.grouped ? "treegrid" : "grid",
|
|
26
|
+
rowCount: input.more ? -1 : next - 1,
|
|
27
|
+
colCount: columns.size,
|
|
28
|
+
barIndex: (groupKey) => bySection.get(groupKey)?.bar,
|
|
29
|
+
headIndex: (groupKey) => bySection.get(groupKey)?.head,
|
|
30
|
+
rowIndex: (groupKey, index) => {
|
|
31
|
+
const rows = bySection.get(groupKey);
|
|
32
|
+
if (rows?.firstRow == null || index < 0 || index >= rows.count)
|
|
33
|
+
return undefined;
|
|
34
|
+
return rows.firstRow + index;
|
|
35
|
+
},
|
|
36
|
+
footIndex: (groupKey) => bySection.get(groupKey)?.foot,
|
|
37
|
+
colIndex: (columnId) => columns.get(columnId),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { GridCellPos } from "./coordinates.js";
|
|
2
|
+
import { type GridNavDirection } from "./nav.js";
|
|
3
|
+
/** The checkbox lane's column id, on a row and on the column names' row. */
|
|
4
|
+
export declare const GRID_RAIL_COLUMN = "__rail__";
|
|
5
|
+
/** "+ Add column", the column names' row's last cell where the header draws it. */
|
|
6
|
+
export declare const GRID_ADD_COLUMN = "__add__";
|
|
7
|
+
export type GridChromeTarget = {
|
|
8
|
+
kind: "bar";
|
|
9
|
+
groupKey: string;
|
|
10
|
+
part: "name" | "menu";
|
|
11
|
+
} | {
|
|
12
|
+
kind: "head";
|
|
13
|
+
groupKey: string;
|
|
14
|
+
columnId: string;
|
|
15
|
+
} | {
|
|
16
|
+
kind: "foot";
|
|
17
|
+
groupKey: string;
|
|
18
|
+
columnId: string;
|
|
19
|
+
} | {
|
|
20
|
+
kind: "rail";
|
|
21
|
+
rowKey: string;
|
|
22
|
+
};
|
|
23
|
+
export type GridFocusTarget = {
|
|
24
|
+
kind: "cell";
|
|
25
|
+
pos: GridCellPos;
|
|
26
|
+
} | GridChromeTarget;
|
|
27
|
+
export type GridFocusSection = {
|
|
28
|
+
groupKey: string;
|
|
29
|
+
collapsed: boolean;
|
|
30
|
+
/** Its rows' keys in drawn order (a shut section's too; they are skipped). */
|
|
31
|
+
rowKeys: readonly string[];
|
|
32
|
+
/** The group's footer row is drawn (GridFooter draws one). */
|
|
33
|
+
footer: boolean;
|
|
34
|
+
/** Its bar carries a ⋯ menu. */
|
|
35
|
+
menu: boolean;
|
|
36
|
+
};
|
|
37
|
+
export type GridFocusShape = {
|
|
38
|
+
sections: readonly GridFocusSection[];
|
|
39
|
+
grouped: boolean;
|
|
40
|
+
selectable: boolean;
|
|
41
|
+
columnIds: readonly string[];
|
|
42
|
+
addColumn: boolean;
|
|
43
|
+
};
|
|
44
|
+
/** One arrow from `from`; null where nothing lies that way. A bar's ←/→ that collapse or open are not moves:
|
|
45
|
+
* `gridBarArrow` answers those first. */
|
|
46
|
+
export declare function gridFocusStep(from: GridFocusTarget, dir: GridNavDirection, shape: GridFocusShape): GridFocusTarget | null;
|
|
47
|
+
/** Tab (backwards: Shift+Tab). A data cell moves as `nextCellLinear` over the visible rows; null past the grid's
|
|
48
|
+
* last (or before its first) cell means "leave the grid". A chrome target moves along its own row, and leaves the
|
|
49
|
+
* grid at the row's ends, so Tab never traps a keyboard (an empty grid's column names included). */
|
|
50
|
+
export declare function gridFocusTab(from: GridFocusTarget, backwards: boolean, shape: GridFocusShape): GridFocusTarget | null;
|
|
51
|
+
/** What ← or → does on a bar's name: collapse, open, or move (to the ⋯ menu). */
|
|
52
|
+
export declare function gridBarArrow(collapsed: boolean, dir: "left" | "right", menu: boolean): "collapse" | "open" | "move" | "none";
|
|
53
|
+
/** The bar a section's row or chrome belongs to, for a focus whose group just shut. */
|
|
54
|
+
export declare function gridBarOf(groupKey: string): GridChromeTarget;
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { nextCellLinear, nextCellPos } from "./nav.js";
|
|
2
|
+
export const GRID_RAIL_COLUMN = "__rail__";
|
|
3
|
+
export const GRID_ADD_COLUMN = "__add__";
|
|
4
|
+
const cell = (rowId, columnId) => ({ kind: "cell", pos: { rowId, columnId } });
|
|
5
|
+
function locate(shape, rowKey) {
|
|
6
|
+
for (let s = 0; s < shape.sections.length; s++) {
|
|
7
|
+
const section = shape.sections[s];
|
|
8
|
+
if (section.collapsed)
|
|
9
|
+
continue;
|
|
10
|
+
const i = section.rowKeys.indexOf(rowKey);
|
|
11
|
+
if (i >= 0)
|
|
12
|
+
return { s, i };
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
function sectionIndex(shape, groupKey) {
|
|
17
|
+
return shape.sections.findIndex((section) => section.groupKey === groupKey);
|
|
18
|
+
}
|
|
19
|
+
function headColumns(shape) {
|
|
20
|
+
return [
|
|
21
|
+
...(shape.selectable ? [GRID_RAIL_COLUMN] : []),
|
|
22
|
+
...shape.columnIds,
|
|
23
|
+
...(shape.addColumn ? [GRID_ADD_COLUMN] : []),
|
|
24
|
+
];
|
|
25
|
+
}
|
|
26
|
+
function onRow(shape, rowKey, columnId) {
|
|
27
|
+
if (columnId === GRID_RAIL_COLUMN && shape.selectable)
|
|
28
|
+
return { kind: "rail", rowKey };
|
|
29
|
+
if (shape.columnIds.includes(columnId))
|
|
30
|
+
return cell(rowKey, columnId);
|
|
31
|
+
const last = shape.columnIds[shape.columnIds.length - 1];
|
|
32
|
+
return cell(rowKey, columnId === GRID_ADD_COLUMN && last != null ? last : (shape.columnIds[0] ?? columnId));
|
|
33
|
+
}
|
|
34
|
+
function onHead(shape, groupKey, columnId) {
|
|
35
|
+
return { kind: "head", groupKey, columnId: headColumns(shape).includes(columnId) ? columnId : (shape.columnIds[0] ?? columnId) };
|
|
36
|
+
}
|
|
37
|
+
function onFoot(shape, groupKey, columnId) {
|
|
38
|
+
if (shape.columnIds.includes(columnId))
|
|
39
|
+
return { kind: "foot", groupKey, columnId };
|
|
40
|
+
const last = shape.columnIds[shape.columnIds.length - 1];
|
|
41
|
+
return { kind: "foot", groupKey, columnId: columnId === GRID_ADD_COLUMN && last != null ? last : (shape.columnIds[0] ?? columnId) };
|
|
42
|
+
}
|
|
43
|
+
function nextTop(shape, s) {
|
|
44
|
+
const next = shape.sections[s + 1];
|
|
45
|
+
return next && shape.grouped ? gridBarOf(next.groupKey) : null;
|
|
46
|
+
}
|
|
47
|
+
function prevBottom(shape, s) {
|
|
48
|
+
const prev = shape.sections[s - 1];
|
|
49
|
+
if (!prev)
|
|
50
|
+
return null;
|
|
51
|
+
if (prev.collapsed && shape.grouped)
|
|
52
|
+
return gridBarOf(prev.groupKey);
|
|
53
|
+
const first = shape.columnIds[0] ?? "";
|
|
54
|
+
if (prev.footer)
|
|
55
|
+
return { kind: "foot", groupKey: prev.groupKey, columnId: first };
|
|
56
|
+
const last = prev.rowKeys[prev.rowKeys.length - 1];
|
|
57
|
+
if (last != null)
|
|
58
|
+
return cell(last, first);
|
|
59
|
+
return { kind: "head", groupKey: prev.groupKey, columnId: first };
|
|
60
|
+
}
|
|
61
|
+
function belowRows(shape, s, columnId) {
|
|
62
|
+
const section = shape.sections[s];
|
|
63
|
+
return section.footer ? onFoot(shape, section.groupKey, columnId) : nextTop(shape, s);
|
|
64
|
+
}
|
|
65
|
+
function stepAlong(columns, columnId, dir) {
|
|
66
|
+
const at = columns.indexOf(columnId);
|
|
67
|
+
if (at < 0)
|
|
68
|
+
return null;
|
|
69
|
+
return columns[at + (dir === "right" ? 1 : -1)] ?? null;
|
|
70
|
+
}
|
|
71
|
+
export function gridFocusStep(from, dir, shape) {
|
|
72
|
+
const horizontal = dir === "left" || dir === "right";
|
|
73
|
+
if (from.kind === "cell" || from.kind === "rail") {
|
|
74
|
+
const rowKey = from.kind === "cell" ? from.pos.rowId : from.rowKey;
|
|
75
|
+
const columnId = from.kind === "cell" ? from.pos.columnId : GRID_RAIL_COLUMN;
|
|
76
|
+
const at = locate(shape, rowKey);
|
|
77
|
+
if (!at)
|
|
78
|
+
return null;
|
|
79
|
+
const section = shape.sections[at.s];
|
|
80
|
+
const columns = columnId === GRID_RAIL_COLUMN ? [GRID_RAIL_COLUMN] : [...shape.columnIds];
|
|
81
|
+
const inside = nextCellPos({ rowId: rowKey, columnId }, dir, [...section.rowKeys], columns);
|
|
82
|
+
if (inside)
|
|
83
|
+
return onRow(shape, inside.rowId, inside.columnId);
|
|
84
|
+
if (horizontal) {
|
|
85
|
+
if (dir === "left" && columnId === shape.columnIds[0] && shape.selectable)
|
|
86
|
+
return { kind: "rail", rowKey };
|
|
87
|
+
if (dir === "right" && columnId === GRID_RAIL_COLUMN && shape.columnIds[0] != null) {
|
|
88
|
+
return cell(rowKey, shape.columnIds[0]);
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
return dir === "up" ? onHead(shape, section.groupKey, columnId) : belowRows(shape, at.s, columnId);
|
|
93
|
+
}
|
|
94
|
+
const s = sectionIndex(shape, from.groupKey);
|
|
95
|
+
if (s < 0)
|
|
96
|
+
return null;
|
|
97
|
+
const section = shape.sections[s];
|
|
98
|
+
if (from.kind === "head") {
|
|
99
|
+
if (horizontal) {
|
|
100
|
+
const next = stepAlong(headColumns(shape), from.columnId, dir);
|
|
101
|
+
return next == null ? null : { kind: "head", groupKey: from.groupKey, columnId: next };
|
|
102
|
+
}
|
|
103
|
+
if (dir === "up")
|
|
104
|
+
return shape.grouped ? gridBarOf(section.groupKey) : null;
|
|
105
|
+
const first = section.rowKeys[0];
|
|
106
|
+
return first != null ? onRow(shape, first, from.columnId) : belowRows(shape, s, from.columnId);
|
|
107
|
+
}
|
|
108
|
+
if (from.kind === "foot") {
|
|
109
|
+
if (horizontal) {
|
|
110
|
+
const next = stepAlong(shape.columnIds, from.columnId, dir);
|
|
111
|
+
return next == null ? null : { kind: "foot", groupKey: from.groupKey, columnId: next };
|
|
112
|
+
}
|
|
113
|
+
if (dir === "down")
|
|
114
|
+
return nextTop(shape, s);
|
|
115
|
+
const last = section.rowKeys[section.rowKeys.length - 1];
|
|
116
|
+
return last != null ? onRow(shape, last, from.columnId) : onHead(shape, section.groupKey, from.columnId);
|
|
117
|
+
}
|
|
118
|
+
if (horizontal) {
|
|
119
|
+
if (dir === "right" && from.part === "name" && section.menu)
|
|
120
|
+
return { kind: "bar", groupKey: from.groupKey, part: "menu" };
|
|
121
|
+
if (dir === "left" && from.part === "menu")
|
|
122
|
+
return gridBarOf(from.groupKey);
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
if (dir === "up")
|
|
126
|
+
return prevBottom(shape, s);
|
|
127
|
+
if (section.collapsed)
|
|
128
|
+
return nextTop(shape, s);
|
|
129
|
+
return { kind: "head", groupKey: section.groupKey, columnId: shape.columnIds[0] ?? "" };
|
|
130
|
+
}
|
|
131
|
+
export function gridFocusTab(from, backwards, shape) {
|
|
132
|
+
if (from.kind === "cell") {
|
|
133
|
+
const visible = shape.sections.flatMap((section) => (section.collapsed ? [] : section.rowKeys));
|
|
134
|
+
const next = nextCellLinear(from.pos, backwards, visible, [...shape.columnIds]);
|
|
135
|
+
return next ? { kind: "cell", pos: next } : null;
|
|
136
|
+
}
|
|
137
|
+
return gridFocusStep(from, backwards ? "left" : "right", shape);
|
|
138
|
+
}
|
|
139
|
+
export function gridBarArrow(collapsed, dir, menu) {
|
|
140
|
+
if (dir === "left")
|
|
141
|
+
return collapsed ? "none" : "collapse";
|
|
142
|
+
if (collapsed)
|
|
143
|
+
return "open";
|
|
144
|
+
return menu ? "move" : "none";
|
|
145
|
+
}
|
|
146
|
+
export function gridBarOf(groupKey) {
|
|
147
|
+
return { kind: "bar", groupKey, part: "name" };
|
|
148
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ListDensity } from "../../model/column-state.js";
|
|
2
|
+
/**
|
|
3
|
+
* The spreadsheet's pixel multiplier.
|
|
4
|
+
*
|
|
5
|
+
* Stays in `grid/` while the PRESET NAMES live in the model, because the
|
|
6
|
+
* two are different facts: "compact / default / spacious" is a vocabulary every
|
|
7
|
+
* view shares, but multiplying a 37px row height by 0.9 is something only a
|
|
8
|
+
* grid does. The rows-based views express the same vocabulary as padding
|
|
9
|
+
* variables instead (see `model/density.ts`).
|
|
10
|
+
*/
|
|
11
|
+
export declare const GRID_SCALE_MULTIPLIER: Record<ListDensity, number>;
|
|
12
|
+
/** The CSS custom property holding one column's resolved width: the contract's internal
|
|
13
|
+
* family `--vk-col-w-` (`VK_INTERNAL_FAMILIES`). */
|
|
14
|
+
export declare function gridWidthVar(id: string): string;
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import type { GridCellPos } from "./coordinates.js";
|
|
2
|
+
export type GridNavDirection = "up" | "down" | "left" | "right";
|
|
3
|
+
/** Where a keyboard gesture wants to land. `step` is one cell in a direction;
|
|
4
|
+
* the edge kinds jump to a boundary. Deliberately a data description, not a
|
|
5
|
+
* cell — resolution needs the visible order, which the parser doesn't have. */
|
|
6
|
+
type GridNavTarget = {
|
|
7
|
+
kind: "step";
|
|
8
|
+
dir: GridNavDirection;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "rowEdge";
|
|
11
|
+
edge: "start" | "end";
|
|
12
|
+
} | {
|
|
13
|
+
kind: "tableEdge";
|
|
14
|
+
edge: "start" | "end";
|
|
15
|
+
};
|
|
16
|
+
/** What a key chord MEANS. `selectAll` is its own kind because it resolves to
|
|
17
|
+
* a rectangle rather than a cell. */
|
|
18
|
+
type GridNavIntent = {
|
|
19
|
+
kind: "selectAll";
|
|
20
|
+
} | {
|
|
21
|
+
kind: "cell";
|
|
22
|
+
target: GridNavTarget;
|
|
23
|
+
extend: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Parse a key chord into a navigation/selection intent.
|
|
27
|
+
*
|
|
28
|
+
* Returns null for everything this layer doesn't own, and two of those nulls
|
|
29
|
+
* are load-bearing:
|
|
30
|
+
*
|
|
31
|
+
* - a BARE arrow — plain navigation is a separate, older branch in the chrome,
|
|
32
|
+
* and returning an intent here would give one keystroke two handlers;
|
|
33
|
+
* - any ⌘/⌃ + arrow — those are browser back/forward, and on macOS ⌘↑/⌘↓ are
|
|
34
|
+
* scroll-to-document-end. Sheets trains the opposite instinct, so this is
|
|
35
|
+
* the rule most likely to be "fixed" by a future reader. It is deliberate.
|
|
36
|
+
*
|
|
37
|
+
* PageUp/PageDown are absent on purpose: a page is scrollport-height ÷ row
|
|
38
|
+
* height, which is a DOM measurement this pure layer can't make. When they
|
|
39
|
+
* arrive they become another `GridNavTarget` variant.
|
|
40
|
+
*/
|
|
41
|
+
export declare function gridNavIntent(e: {
|
|
42
|
+
key: string;
|
|
43
|
+
shiftKey: boolean;
|
|
44
|
+
metaKey: boolean;
|
|
45
|
+
ctrlKey: boolean;
|
|
46
|
+
altKey: boolean;
|
|
47
|
+
}): GridNavIntent | null;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve a target against the VISIBLE order. Null at a hard edge, or when
|
|
50
|
+
* `from` itself is no longer in the visible order — the same `< 0` bail every
|
|
51
|
+
* other consumer of these arrays uses.
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveNavTarget(from: GridCellPos, target: GridNavTarget, visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
54
|
+
/** The whole visible rectangle (⌘A), or null when the grid has nothing in it. */
|
|
55
|
+
export declare function wholeTableRect(visibleRowIds: string[], visibleColIds: string[]): {
|
|
56
|
+
anchor: GridCellPos;
|
|
57
|
+
head: GridCellPos;
|
|
58
|
+
} | null;
|
|
59
|
+
/**
|
|
60
|
+
* The cell a keyboard extension grows FROM: the ACTIVE (last) range's head.
|
|
61
|
+
*
|
|
62
|
+
* Null means "there is no usable range" — either none was ever drawn, or its
|
|
63
|
+
* head left the visible order (its group was collapsed, a refetch dropped the
|
|
64
|
+
* row). The caller rebuilds from the focused cell in that case; without this,
|
|
65
|
+
* a stranded range would be unpaintable AND unextendable, and the key would
|
|
66
|
+
* look permanently broken.
|
|
67
|
+
*
|
|
68
|
+
* Structurally typed so this module never has to import the range model.
|
|
69
|
+
*/
|
|
70
|
+
export declare function activeRangeHead(ranges: readonly {
|
|
71
|
+
head: GridCellPos;
|
|
72
|
+
}[], visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
73
|
+
/**
|
|
74
|
+
* The cell one step from `pos` in `dir`, or null at a boundary.
|
|
75
|
+
*
|
|
76
|
+
* Both id arrays are the VISIBLE order — `visibleRowIds` already excludes rows
|
|
77
|
+
* in collapsed groups and `visibleColIds` excludes hidden columns, so walking
|
|
78
|
+
* them is what makes navigation skip collapsed groups. That has to be done by
|
|
79
|
+
* DATA: only the rows on screen are drawn, and a focused row stays drawn even
|
|
80
|
+
* inside a shut group's clip, so no DOM-visibility test can answer it.
|
|
81
|
+
*
|
|
82
|
+
* Returns null when `pos` itself isn't in the visible order — e.g. the focused
|
|
83
|
+
* row's group was just collapsed, or a refetch dropped the row. Same `< 0` bail
|
|
84
|
+
* every other consumer of these arrays uses.
|
|
85
|
+
*/
|
|
86
|
+
export declare function nextCellPos(pos: GridCellPos, dir: GridNavDirection, visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
87
|
+
/**
|
|
88
|
+
* The next cell in READING order — Tab / Shift-Tab. Walks the row, then wraps
|
|
89
|
+
* to the first cell of the next row (or the last cell of the previous one going
|
|
90
|
+
* backwards). Stops at the very first/last cell of the table rather than
|
|
91
|
+
* cycling, so Tab can't loop forever.
|
|
92
|
+
*/
|
|
93
|
+
export declare function nextCellLinear(pos: GridCellPos, backwards: boolean, visibleRowIds: string[], visibleColIds: string[]): GridCellPos | null;
|
|
94
|
+
export {};
|