@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,28 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
export const GRID_ROW_PX = 37;
|
|
4
|
+
export function useGridScaleStyles(scale, grouped, phone, addColumn = false) {
|
|
5
|
+
return useMemo(() => ({
|
|
6
|
+
"--vk-scale": String(scale),
|
|
7
|
+
"--vk-indent": phone ? "0px" : "24px",
|
|
8
|
+
"--vk-row-h": `calc(${GRID_ROW_PX}px * var(--vk-scale))`,
|
|
9
|
+
"--vk-line-h": "calc(22px * var(--vk-scale))",
|
|
10
|
+
"--vk-head-h": "calc(32px * var(--vk-scale))",
|
|
11
|
+
"--vk-head-text": "calc(12px * var(--vk-scale))",
|
|
12
|
+
"--vk-head-glyph": "calc(12px * var(--vk-scale))",
|
|
13
|
+
"--vk-footer-h": "calc(36px * var(--vk-scale))",
|
|
14
|
+
"--vk-label-h": "calc(36px * var(--vk-scale))",
|
|
15
|
+
"--vk-text": "calc(14px * var(--vk-scale))",
|
|
16
|
+
"--vk-text-xs": "calc(12px * var(--vk-scale))",
|
|
17
|
+
"--vk-text-10": "calc(10px * var(--vk-scale))",
|
|
18
|
+
"--vk-px": "calc(12px * var(--vk-scale))",
|
|
19
|
+
"--vk-rail-gap": "3px",
|
|
20
|
+
"--vk-rail-w": "min(32px, calc(var(--vk-gutter,0px) + var(--vk-indent,0px)))",
|
|
21
|
+
"--vk-tail-w": addColumn ? "calc(140px + var(--vk-px))" : "calc(36px + var(--vk-px))",
|
|
22
|
+
"--vk-tail-pl": addColumn
|
|
23
|
+
? "max(0px, calc(var(--vk-px) + var(--vk-head-glyph) / 2 - 18px))"
|
|
24
|
+
: "var(--vk-px)",
|
|
25
|
+
"--vk-glyph": "calc(14px * var(--vk-scale))",
|
|
26
|
+
"--vk-scroll-mt": `calc(${grouped ? "var(--vk-label-h) + 6px" : "0px"} + var(--vk-head-h) + 4px)`,
|
|
27
|
+
}), [addColumn, grouped, phone, scale]);
|
|
28
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* The grid's one scroll area, and what the rest of the grid reads off it.
|
|
4
|
+
*
|
|
5
|
+
* The whole table, headers and rows of every group, scrolls in ONE native element, both ways. Every
|
|
6
|
+
* browser engine scrolls off the main thread, so a position script copies from one scroller to
|
|
7
|
+
* another lands at least a frame late; here nothing is copied. The headers pin and the frozen
|
|
8
|
+
* columns stick because they sit in the same scrollport as the rows, and the browser moves them all
|
|
9
|
+
* at once.
|
|
10
|
+
*
|
|
11
|
+
* What script still does is paint bookkeeping, never position: one passive listener writes two 0/1
|
|
12
|
+
* flags on the frame, and only when one flips. `--vk-scrolled` is "has the table moved sideways at
|
|
13
|
+
* all"; `--vk-parked` is "has the leading chrome (the checkbox rail, the frozen block) reached its
|
|
14
|
+
* stop", which happens `parkAt` px later (measured below). It also keeps `scrollXRef` at the area's
|
|
15
|
+
* x, which the header's column drag folds into its shift.
|
|
16
|
+
*/
|
|
17
|
+
export declare function useGridScrollArea(rootRef: RefObject<HTMLDivElement | null>): {
|
|
18
|
+
areaRef: (element: HTMLDivElement | null) => (() => void) | undefined;
|
|
19
|
+
scrollXRef: RefObject<number>;
|
|
20
|
+
getScroller: () => HTMLElement | undefined;
|
|
21
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
export function useGridScrollArea(rootRef) {
|
|
4
|
+
const areaElRef = useRef(null);
|
|
5
|
+
const scrollXRef = useRef(0);
|
|
6
|
+
const parkAtRef = useRef(0);
|
|
7
|
+
const flagsRef = useRef({ scrolled: "", parked: "" });
|
|
8
|
+
const writeFlags = useCallback((x) => {
|
|
9
|
+
const root = rootRef.current;
|
|
10
|
+
if (!root)
|
|
11
|
+
return;
|
|
12
|
+
const scrolled = x > 0 ? "1" : "0";
|
|
13
|
+
const parked = x > 0 && x >= parkAtRef.current ? "1" : "0";
|
|
14
|
+
if (flagsRef.current.scrolled !== scrolled) {
|
|
15
|
+
flagsRef.current.scrolled = scrolled;
|
|
16
|
+
root.style.setProperty("--vk-scrolled", scrolled);
|
|
17
|
+
}
|
|
18
|
+
if (flagsRef.current.parked !== parked) {
|
|
19
|
+
flagsRef.current.parked = parked;
|
|
20
|
+
root.style.setProperty("--vk-parked", parked);
|
|
21
|
+
}
|
|
22
|
+
}, [rootRef]);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const root = rootRef.current;
|
|
25
|
+
if (!root)
|
|
26
|
+
return;
|
|
27
|
+
const probe = document.createElement("div");
|
|
28
|
+
probe.setAttribute("aria-hidden", "true");
|
|
29
|
+
probe.style.cssText =
|
|
30
|
+
"position:absolute;top:0;left:0;height:0;visibility:hidden;pointer-events:none;" +
|
|
31
|
+
"width:calc(var(--vk-gutter,0px) + var(--vk-indent,0px) - var(--vk-rail-w))";
|
|
32
|
+
root.appendChild(probe);
|
|
33
|
+
const read = () => {
|
|
34
|
+
parkAtRef.current = probe.offsetWidth;
|
|
35
|
+
writeFlags(scrollXRef.current);
|
|
36
|
+
};
|
|
37
|
+
read();
|
|
38
|
+
if (typeof ResizeObserver === "undefined")
|
|
39
|
+
return () => probe.remove();
|
|
40
|
+
const observer = new ResizeObserver(read);
|
|
41
|
+
observer.observe(probe);
|
|
42
|
+
return () => {
|
|
43
|
+
observer.disconnect();
|
|
44
|
+
probe.remove();
|
|
45
|
+
};
|
|
46
|
+
}, [rootRef, writeFlags]);
|
|
47
|
+
const areaRef = useCallback((element) => {
|
|
48
|
+
areaElRef.current = element;
|
|
49
|
+
if (!element)
|
|
50
|
+
return;
|
|
51
|
+
const onScroll = () => {
|
|
52
|
+
const x = element.scrollLeft;
|
|
53
|
+
scrollXRef.current = x;
|
|
54
|
+
writeFlags(x);
|
|
55
|
+
};
|
|
56
|
+
element.addEventListener("scroll", onScroll, { passive: true });
|
|
57
|
+
return () => {
|
|
58
|
+
element.removeEventListener("scroll", onScroll);
|
|
59
|
+
if (areaElRef.current === element)
|
|
60
|
+
areaElRef.current = null;
|
|
61
|
+
};
|
|
62
|
+
}, [writeFlags]);
|
|
63
|
+
const getScroller = useCallback(() => areaElRef.current ?? undefined, []);
|
|
64
|
+
return { areaRef, scrollXRef, getScroller };
|
|
65
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import { type GridEditCell } from "../core/useGridEditing.js";
|
|
3
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
4
|
+
import { type GridCellPos } from "../core/coordinates.js";
|
|
5
|
+
import type { GridTableProps } from "./grid-table-props.js";
|
|
6
|
+
import { type GridFocusShape } from "../core/grid-focus.js";
|
|
7
|
+
export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }: {
|
|
8
|
+
/** What the keyboard walks beyond the data cells (`core/grid-focus.ts`): the sections, their footers and menus,
|
|
9
|
+
* the checkbox lane. None: the keys stay on the data cells. */
|
|
10
|
+
focusShape?: GridFocusShape;
|
|
11
|
+
/** The section a row KEY is drawn in, a shut one's included: a collapse sends that row's focus to its bar. */
|
|
12
|
+
groupOfRow?: (rowKey: string) => string | undefined;
|
|
13
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
14
|
+
props: GridTableProps<Row>;
|
|
15
|
+
rows: Row[];
|
|
16
|
+
/** Row KEYS of the open groups in render order — positions, not records (see `GridCellPos`): the keyboard's, the
|
|
17
|
+
* range's, the spreadsheet's and the fill's order, so each skips a shut group's rows. */
|
|
18
|
+
visibleRows: string[];
|
|
19
|
+
/** Row KEYS the page holds, a shut group's included: what an open edit is checked against, so collapsing a group
|
|
20
|
+
* never cancels an edit in it. Default: `visibleRows`, a list with no shut group. */
|
|
21
|
+
heldRows?: string[];
|
|
22
|
+
/** Row key → the rendered row and its DATA id. */
|
|
23
|
+
rowIndex: ReadonlyMap<string, {
|
|
24
|
+
key: string;
|
|
25
|
+
rowId: string;
|
|
26
|
+
row: Row;
|
|
27
|
+
}>;
|
|
28
|
+
visibleColumns: ListColumn<Row>[];
|
|
29
|
+
selecting: boolean;
|
|
30
|
+
/** Bring a row the page doesn't hold into view, by its row KEY and the column to show: the table's row window,
|
|
31
|
+
* since only the rows on screen are drawn. The one reveal (`revealGridCell`) calls it for a row it can't find in the page. */
|
|
32
|
+
revealRow?: (rowKey: string, columnId?: string) => void;
|
|
33
|
+
}): {
|
|
34
|
+
focus: {
|
|
35
|
+
chrome: import("../core/grid-focus.js").GridChromeTarget | null;
|
|
36
|
+
setChrome: (target: import("../core/grid-focus.js").GridChromeTarget | null) => void;
|
|
37
|
+
target: import("../core/grid-focus.js").GridFocusTarget | null;
|
|
38
|
+
releaseToFrame: () => void;
|
|
39
|
+
lastCellRef: RefObject<GridCellPos | null>;
|
|
40
|
+
};
|
|
41
|
+
onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
|
|
42
|
+
onEditorEnter: (rowId: string, columnId: string) => void;
|
|
43
|
+
enterGrid: (_which: "start" | "end", from: Element | null) => void;
|
|
44
|
+
visibleColIds: string[];
|
|
45
|
+
rowSpansMap: Map<string, import("../core/range-model.js").GridRowRangeSpan[]>;
|
|
46
|
+
selectValuesByColumn: Record<string, string[]>;
|
|
47
|
+
finishFill: (targetRowId: string) => void;
|
|
48
|
+
onRangeCopy: () => void | undefined;
|
|
49
|
+
onRangeCut: () => void | undefined;
|
|
50
|
+
onRangeClear: () => void | undefined;
|
|
51
|
+
onRangePaste: () => void | undefined;
|
|
52
|
+
onPasteAtCell: (rowId: string, columnId: string) => void | undefined;
|
|
53
|
+
inActiveRange: (rowId: string, columnId: string) => boolean;
|
|
54
|
+
rangeCanClear: () => boolean;
|
|
55
|
+
rangeVerbsRef: RefObject<import("./useGridRangeActions.js").GridRangeVerbs | null>;
|
|
56
|
+
editingEnabled: boolean;
|
|
57
|
+
focusedCell: GridCellPos | null;
|
|
58
|
+
editingCell: GridCellPos | null;
|
|
59
|
+
pendingByRow: ReadonlyMap<string, Record<string, unknown>>;
|
|
60
|
+
settlementByRow: import("../core/editing-model.js").GridSettlementByRow;
|
|
61
|
+
editSeed: string | null;
|
|
62
|
+
editWhole: boolean;
|
|
63
|
+
focusCellSync: (rowId: string, columnId: string) => void;
|
|
64
|
+
startEditSync: (rowId: string, columnId: string, seed?: string | null, whole?: boolean) => void;
|
|
65
|
+
cancelEdit: (rowId?: string, columnId?: string) => void;
|
|
66
|
+
commitEdit: (row: Row, rowId: string, columnId: string, prev: unknown, next: unknown, opts?: {
|
|
67
|
+
overlay?: boolean;
|
|
68
|
+
}) => void;
|
|
69
|
+
commitBatch: (edits: (GridEditCell<Row> & {
|
|
70
|
+
row: Row;
|
|
71
|
+
})[]) => Promise<boolean>;
|
|
72
|
+
refuseEdit: (columnId: string) => boolean;
|
|
73
|
+
onExtendCell: (rowId: string, columnId: string) => void;
|
|
74
|
+
onAddCell: (rowId: string, columnId: string) => void;
|
|
75
|
+
handleRootPointerDown: (event: React.PointerEvent) => void;
|
|
76
|
+
handleRootPointerDownCapture: (event: React.PointerEvent) => void;
|
|
77
|
+
handleRootClickCapture: (event: React.MouseEvent) => void;
|
|
78
|
+
};
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useViews } from "../../provider/context.js";
|
|
4
|
+
import { useGridEditing } from "../core/useGridEditing.js";
|
|
5
|
+
import { useGridRange } from "../core/useGridRange.js";
|
|
6
|
+
import { columnEffectiveWritable, gridColumnLocked, gridEditRefusal, gridNormalizeWrite, } from "../../model/column-capabilities.js";
|
|
7
|
+
import { gridRowIdFromKey } from "../core/coordinates.js";
|
|
8
|
+
import { revealGridCell } from "./grid-scroll-owner.js";
|
|
9
|
+
import { useGridFocus } from "./useGridFocus.js";
|
|
10
|
+
import { gridBarOf } from "../core/grid-focus.js";
|
|
11
|
+
import { useGridKeyboard } from "./useGridKeyboard.js";
|
|
12
|
+
import { useGridPendingReconciliation } from "./useGridPendingReconciliation.js";
|
|
13
|
+
import { useGridRangeActions } from "./useGridRangeActions.js";
|
|
14
|
+
import { useGridRangeGestures } from "./useGridRangeGestures.js";
|
|
15
|
+
const REFUSAL_REPEAT_MS = 600;
|
|
16
|
+
export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }) {
|
|
17
|
+
const { columns, getRowId, listConfig } = props;
|
|
18
|
+
const { conventions, ports, messages } = useViews();
|
|
19
|
+
const editingEnabled = !!props.onCellCommit;
|
|
20
|
+
const { focused: focusedCell, editing: editingCell, pendingByRow, settlementByRow, focusCell, clearFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, hasInflight, pendingBaseline, } = useGridEditing(props.onCellCommit, props.onCellsCommit);
|
|
21
|
+
const lockedRefusal = useCallback((col) => gridColumnLocked(col, listConfig) ? gridEditRefusal(col, listConfig, conventions, messages) : undefined, [listConfig, conventions, messages]);
|
|
22
|
+
const commitEdit = useCallback((row, rowId, columnId, prev, next, opts) => {
|
|
23
|
+
const col = visibleColumns.find((c) => c.id === columnId);
|
|
24
|
+
if (col) {
|
|
25
|
+
const locked = lockedRefusal(col);
|
|
26
|
+
if (locked) {
|
|
27
|
+
ports.toast.error(locked);
|
|
28
|
+
closeEdit(rowId, columnId);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
const res = gridNormalizeWrite(col, next, conventions, { messages, stored: prev, region: col.region?.(row) });
|
|
32
|
+
if (!res.ok) {
|
|
33
|
+
ports.toast.error(res.reason);
|
|
34
|
+
closeEdit(rowId, columnId);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
next = res.value;
|
|
38
|
+
}
|
|
39
|
+
commitEditRaw(row, rowId, columnId, prev, next, opts);
|
|
40
|
+
}, [visibleColumns, commitEditRaw, closeEdit, conventions, messages, ports, lockedRefusal]);
|
|
41
|
+
const commitBatch = useCallback((edits) => {
|
|
42
|
+
const colById = new Map(visibleColumns.map((c) => [c.id, c]));
|
|
43
|
+
const kept = [];
|
|
44
|
+
let firstRefusal;
|
|
45
|
+
for (const edit of edits) {
|
|
46
|
+
const col = colById.get(edit.columnId);
|
|
47
|
+
if (!col) {
|
|
48
|
+
kept.push(edit);
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const locked = lockedRefusal(col);
|
|
52
|
+
if (locked) {
|
|
53
|
+
firstRefusal ??= locked;
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
const res = gridNormalizeWrite(col, edit.next, conventions, {
|
|
57
|
+
messages,
|
|
58
|
+
stored: edit.prev,
|
|
59
|
+
region: col.region?.(edit.row),
|
|
60
|
+
});
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
firstRefusal ??= res.reason;
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
kept.push(res.value === edit.next ? edit : { ...edit, next: res.value });
|
|
66
|
+
}
|
|
67
|
+
if (kept.length === 0) {
|
|
68
|
+
if (firstRefusal)
|
|
69
|
+
ports.toast.error(firstRefusal);
|
|
70
|
+
return Promise.resolve(true);
|
|
71
|
+
}
|
|
72
|
+
return commitBatchRaw(kept);
|
|
73
|
+
}, [visibleColumns, commitBatchRaw, conventions, messages, ports, lockedRefusal]);
|
|
74
|
+
const lastRefusalRef = useRef(null);
|
|
75
|
+
const refuseEdit = useCallback((columnId) => {
|
|
76
|
+
if (!editingEnabled)
|
|
77
|
+
return false;
|
|
78
|
+
const col = visibleColumns.find((c) => c.id === columnId);
|
|
79
|
+
if (!col || columnEffectiveWritable(col, listConfig))
|
|
80
|
+
return false;
|
|
81
|
+
const reason = gridEditRefusal(col, listConfig, conventions, messages);
|
|
82
|
+
if (!reason)
|
|
83
|
+
return false;
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
const last = lastRefusalRef.current;
|
|
86
|
+
lastRefusalRef.current = { columnId, at: now };
|
|
87
|
+
if (last?.columnId === columnId && now - last.at < REFUSAL_REPEAT_MS)
|
|
88
|
+
return true;
|
|
89
|
+
ports.toast.error(reason);
|
|
90
|
+
return true;
|
|
91
|
+
}, [editingEnabled, visibleColumns, listConfig, conventions, messages, ports]);
|
|
92
|
+
const { ranges, setSingle: rangeSetSingle, setRect: rangeSetRect, beginDrag: rangeBeginDrag, extendTo: rangeExtendTo, addCell: rangeAddCell, clear: rangeClear, } = useGridRange();
|
|
93
|
+
const [editSeed, setEditSeed] = useState(null);
|
|
94
|
+
const [editWhole, setEditWhole] = useState(false);
|
|
95
|
+
const focusCellSync = useCallback((rowId, columnId) => {
|
|
96
|
+
focusCell(rowId, columnId);
|
|
97
|
+
rangeSetSingle({ rowId, columnId });
|
|
98
|
+
}, [focusCell, rangeSetSingle]);
|
|
99
|
+
const startEditSync = useCallback((rowId, columnId, seed, whole) => {
|
|
100
|
+
setEditSeed(seed ?? null);
|
|
101
|
+
setEditWhole(!!whole);
|
|
102
|
+
startEdit(rowId, columnId);
|
|
103
|
+
rangeSetSingle({ rowId, columnId });
|
|
104
|
+
}, [startEdit, rangeSetSingle]);
|
|
105
|
+
const clearFocusSync = useCallback(() => {
|
|
106
|
+
clearFocus();
|
|
107
|
+
rangeClear();
|
|
108
|
+
}, [clearFocus, rangeClear]);
|
|
109
|
+
const focus = useGridFocus({ rootRef, focusedCell, editingCell });
|
|
110
|
+
const setChrome = focus.setChrome;
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
if (!focusedCell && !editingCell)
|
|
113
|
+
return;
|
|
114
|
+
const visible = new Set(visibleRows);
|
|
115
|
+
const held = heldRows ? new Set(heldRows) : visible;
|
|
116
|
+
const staleEdit = editingCell != null && !held.has(editingCell.rowId);
|
|
117
|
+
const focusKeptByEdit = focusedCell != null && editingCell?.rowId === focusedCell.rowId;
|
|
118
|
+
const staleFocus = focusedCell != null && !(focusKeptByEdit ? held : visible).has(focusedCell.rowId);
|
|
119
|
+
if (!staleEdit && !staleFocus)
|
|
120
|
+
return;
|
|
121
|
+
const editedRowId = editingCell != null
|
|
122
|
+
? (rowIndex.get(editingCell.rowId)?.rowId ?? gridRowIdFromKey(editingCell.rowId))
|
|
123
|
+
: undefined;
|
|
124
|
+
const editedRowGone = editingCell != null && !rows.some((row) => getRowId(row) === editedRowId);
|
|
125
|
+
if (staleEdit)
|
|
126
|
+
cancelEdit();
|
|
127
|
+
if (staleFocus) {
|
|
128
|
+
clearFocusSync();
|
|
129
|
+
const shutGroup = focusedCell && held.has(focusedCell.rowId) ? groupOfRow?.(focusedCell.rowId) : undefined;
|
|
130
|
+
const root = rootRef.current;
|
|
131
|
+
const active = document.activeElement;
|
|
132
|
+
const inGrid = active == null || active === document.body || (root?.contains(active) ?? false);
|
|
133
|
+
if (shutGroup != null && inGrid)
|
|
134
|
+
setChrome(gridBarOf(shutGroup));
|
|
135
|
+
}
|
|
136
|
+
if (staleEdit && editedRowGone) {
|
|
137
|
+
ports.toast.error(messages({ key: "views.grid.row-left" }));
|
|
138
|
+
}
|
|
139
|
+
}, [cancelEdit, clearFocusSync, editingCell, focusedCell, getRowId, groupOfRow, heldRows, messages, ports, rootRef, rowIndex, rows, setChrome, visibleRows]);
|
|
140
|
+
const visibleColumnIds = useMemo(() => visibleColumns.map((column) => column.id), [visibleColumns]);
|
|
141
|
+
const spreadsheetModel = useMemo(() => ({
|
|
142
|
+
rows,
|
|
143
|
+
rowByKey: rowIndex,
|
|
144
|
+
visibleRowIds: visibleRows,
|
|
145
|
+
visibleColumns,
|
|
146
|
+
pendingByRow,
|
|
147
|
+
conventions,
|
|
148
|
+
messages,
|
|
149
|
+
listConfig,
|
|
150
|
+
}), [rows, rowIndex, visibleRows, visibleColumns, pendingByRow, conventions, messages, listConfig]);
|
|
151
|
+
const revealCell = useCallback((pos, behavior) => revealGridCell(rootRef.current, pos, behavior, revealRow), [revealRow, rootRef]);
|
|
152
|
+
const finishFillRef = useRef(() => { });
|
|
153
|
+
const { fillTargetRow, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, } = useGridRangeGestures({
|
|
154
|
+
rootRef,
|
|
155
|
+
focusedCell,
|
|
156
|
+
editingCell,
|
|
157
|
+
editingEnabled,
|
|
158
|
+
selecting,
|
|
159
|
+
focusCell,
|
|
160
|
+
clearFocus: clearFocusSync,
|
|
161
|
+
rangeBeginDrag,
|
|
162
|
+
rangeExtendTo,
|
|
163
|
+
rangeAddCell,
|
|
164
|
+
finishFillRef,
|
|
165
|
+
});
|
|
166
|
+
const rangeActions = useGridRangeActions({
|
|
167
|
+
ranges,
|
|
168
|
+
focusedCell,
|
|
169
|
+
editingCell,
|
|
170
|
+
editingEnabled,
|
|
171
|
+
fillTargetRow,
|
|
172
|
+
visibleRowIds: visibleRows,
|
|
173
|
+
visibleColumns,
|
|
174
|
+
spreadsheetModel,
|
|
175
|
+
commitBatch,
|
|
176
|
+
focusCell,
|
|
177
|
+
rangeSetRect,
|
|
178
|
+
rangeExtendTo,
|
|
179
|
+
revealCell,
|
|
180
|
+
});
|
|
181
|
+
useEffect(() => {
|
|
182
|
+
finishFillRef.current = rangeActions.finishFill;
|
|
183
|
+
}, [rangeActions.finishFill]);
|
|
184
|
+
const keyboard = useGridKeyboard({
|
|
185
|
+
releaseToFrame: focus.releaseToFrame,
|
|
186
|
+
lastCellRef: focus.lastCellRef,
|
|
187
|
+
chrome: focus.chrome,
|
|
188
|
+
setChrome: focus.setChrome,
|
|
189
|
+
shape: focusShape,
|
|
190
|
+
toggleGroup: props.onToggleGroup,
|
|
191
|
+
rootRef,
|
|
192
|
+
focusedCell,
|
|
193
|
+
editingCell,
|
|
194
|
+
editingEnabled,
|
|
195
|
+
listConfig,
|
|
196
|
+
visibleRowIds: visibleRows,
|
|
197
|
+
visibleColIds: visibleColumnIds,
|
|
198
|
+
visibleColumns,
|
|
199
|
+
rows,
|
|
200
|
+
getRowId,
|
|
201
|
+
rowByKey: rowIndex,
|
|
202
|
+
pendingByRow,
|
|
203
|
+
rangeVerbsRef: rangeActions.rangeVerbsRef,
|
|
204
|
+
focusCell: focusCellSync,
|
|
205
|
+
clearFocus: clearFocusSync,
|
|
206
|
+
startEdit: startEditSync,
|
|
207
|
+
cancelEdit,
|
|
208
|
+
commitEdit,
|
|
209
|
+
refuseEdit,
|
|
210
|
+
undo,
|
|
211
|
+
redo,
|
|
212
|
+
rangeSetRect,
|
|
213
|
+
rangeExtendTo,
|
|
214
|
+
ranges,
|
|
215
|
+
revealCell,
|
|
216
|
+
});
|
|
217
|
+
useGridPendingReconciliation({
|
|
218
|
+
rows,
|
|
219
|
+
columns,
|
|
220
|
+
getRowId,
|
|
221
|
+
pendingByRow,
|
|
222
|
+
reconcile,
|
|
223
|
+
hasInflight,
|
|
224
|
+
pendingBaseline,
|
|
225
|
+
});
|
|
226
|
+
return {
|
|
227
|
+
editingEnabled,
|
|
228
|
+
focusedCell,
|
|
229
|
+
editingCell,
|
|
230
|
+
pendingByRow,
|
|
231
|
+
settlementByRow,
|
|
232
|
+
editSeed,
|
|
233
|
+
editWhole,
|
|
234
|
+
focusCellSync,
|
|
235
|
+
startEditSync,
|
|
236
|
+
cancelEdit,
|
|
237
|
+
commitEdit,
|
|
238
|
+
commitBatch,
|
|
239
|
+
refuseEdit,
|
|
240
|
+
onExtendCell,
|
|
241
|
+
onAddCell,
|
|
242
|
+
handleRootPointerDown,
|
|
243
|
+
handleRootPointerDownCapture,
|
|
244
|
+
handleRootClickCapture,
|
|
245
|
+
...rangeActions,
|
|
246
|
+
...keyboard,
|
|
247
|
+
focus,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
import type { GridTableProps } from "./grid-table-props.js";
|
|
3
|
+
export declare function getVisibleGridRowIds<Row>({ groups, grouped, isCollapsed, getRowId, }: Pick<GridTableProps<Row>, "groups" | "grouped" | "isCollapsed" | "getRowId">): string[];
|
|
4
|
+
/**
|
|
5
|
+
* The Grid renderer's list-selection binding.
|
|
6
|
+
*
|
|
7
|
+
* Selection order includes every rendered row, while checkbox-lane drag order
|
|
8
|
+
* deliberately excludes rows hidden inside collapsed groups. Keeping both
|
|
9
|
+
* orders here prevents the renderer from accidentally feeding one contract to
|
|
10
|
+
* the other when its group chrome changes.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useGridTableSelection<Row>({ rootRef, groups, grouped, isCollapsed, getRowId, selection, }: Pick<GridTableProps<Row>, "groups" | "grouped" | "isCollapsed" | "getRowId" | "selection"> & {
|
|
13
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
14
|
+
}): {
|
|
15
|
+
selectable: boolean;
|
|
16
|
+
selecting: boolean;
|
|
17
|
+
selectionState: import("../../selection/useListSelection.js").UseListSelectionResult;
|
|
18
|
+
derivedOrderedIds: string[];
|
|
19
|
+
visibleRowIds: string[];
|
|
20
|
+
checkDrag: {
|
|
21
|
+
tryArm: (e: import("react").PointerEvent) => boolean;
|
|
22
|
+
consumeDrag: () => boolean;
|
|
23
|
+
};
|
|
24
|
+
groupSelection: (items: Row[]) => {
|
|
25
|
+
allSelected: boolean;
|
|
26
|
+
someSelected: boolean;
|
|
27
|
+
onToggle: () => void;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { useCheckDragSelect } from "../../selection/useCheckDragSelect.js";
|
|
4
|
+
import { useEscapeToClear } from "../../selection/useListSelectionShortcuts.js";
|
|
5
|
+
import { useListSelection } from "../../selection/useListSelection.js";
|
|
6
|
+
import { gridRowIdFromKey } from "../core/coordinates.js";
|
|
7
|
+
export function getVisibleGridRowIds({ groups, grouped, isCollapsed, getRowId, }) {
|
|
8
|
+
const ids = [];
|
|
9
|
+
for (const group of groups) {
|
|
10
|
+
if (grouped && (isCollapsed?.(group.key) ?? false))
|
|
11
|
+
continue;
|
|
12
|
+
for (const row of group.items)
|
|
13
|
+
ids.push(getRowId(row));
|
|
14
|
+
}
|
|
15
|
+
return ids;
|
|
16
|
+
}
|
|
17
|
+
export function useGridTableSelection({ rootRef, groups, grouped, isCollapsed, getRowId, selection, }) {
|
|
18
|
+
const selectable = !!selection;
|
|
19
|
+
const derivedOrderedIds = useMemo(() => groups.flatMap((group) => group.items).map(getRowId), [groups, getRowId]);
|
|
20
|
+
const orderedIds = selection?.orderedIds ?? derivedOrderedIds;
|
|
21
|
+
const selectionState = useListSelection({
|
|
22
|
+
orderedIds,
|
|
23
|
+
retention: selection?.retention,
|
|
24
|
+
resetKey: selection?.resetKey,
|
|
25
|
+
});
|
|
26
|
+
useEscapeToClear(selectionState.count > 0, selectionState.clear);
|
|
27
|
+
const selecting = selectable && selectionState.count > 0;
|
|
28
|
+
const visibleRowIds = useMemo(() => getVisibleGridRowIds({ groups, grouped, isCollapsed, getRowId }), [groups, grouped, isCollapsed, getRowId]);
|
|
29
|
+
const checkDrag = useCheckDragSelect({
|
|
30
|
+
enabled: selectable,
|
|
31
|
+
rootRef,
|
|
32
|
+
rowIds: visibleRowIds,
|
|
33
|
+
rowIdOf: gridRowIdFromKey,
|
|
34
|
+
isSelected: selectionState.isSelected,
|
|
35
|
+
setRowSelected: selectionState.toggle,
|
|
36
|
+
});
|
|
37
|
+
const groupSelection = (items) => {
|
|
38
|
+
const ids = items.map(getRowId);
|
|
39
|
+
const selectedCount = ids.filter((id) => selectionState.isSelected(id)).length;
|
|
40
|
+
return {
|
|
41
|
+
allSelected: selectedCount > 0 && selectedCount === ids.length,
|
|
42
|
+
someSelected: selectedCount > 0 && selectedCount < ids.length,
|
|
43
|
+
onToggle: () => selectionState.toggleMany(ids),
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
selectable,
|
|
48
|
+
selecting,
|
|
49
|
+
selectionState,
|
|
50
|
+
derivedOrderedIds,
|
|
51
|
+
visibleRowIds,
|
|
52
|
+
checkDrag,
|
|
53
|
+
groupSelection,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type React from "react";
|
|
2
|
+
export declare function useHeaderDragReorder({ enabled, ids, scrollXRef, getScroller, canDrag, onReorder, }: {
|
|
3
|
+
enabled: boolean;
|
|
4
|
+
/** Visible column ids, in current order. */
|
|
5
|
+
ids: string[];
|
|
6
|
+
/** The grid's scroll area's current scrollLeft (GridTable's scrollXRef). */
|
|
7
|
+
scrollXRef: React.MutableRefObject<number>;
|
|
8
|
+
/** The grid's scroll area: the edge autoscroll moves it. */
|
|
9
|
+
getScroller: () => HTMLElement | undefined;
|
|
10
|
+
/** Optional ownership gate for columns that remain fixed in declaration order. */
|
|
11
|
+
canDrag?: (id: string) => boolean;
|
|
12
|
+
/** Commit: the moved id + the full visible order after the move. */
|
|
13
|
+
onReorder: (movedId: string, nextVisibleIds: string[]) => void;
|
|
14
|
+
}): {
|
|
15
|
+
cellStyle: (id: string, index: number) => React.CSSProperties | undefined;
|
|
16
|
+
onCellPointerDown: (id: string, index: number) => (e: React.PointerEvent<HTMLElement>) => void;
|
|
17
|
+
onCellPointerMove: (e: React.PointerEvent<HTMLElement>) => void;
|
|
18
|
+
onCellPointerUp: (e: React.PointerEvent<HTMLElement>) => void;
|
|
19
|
+
onCellPointerCancel: () => void;
|
|
20
|
+
onCellClickCapture: (e: React.MouseEvent<HTMLElement>) => void;
|
|
21
|
+
};
|