@viewkitjs/views 0.0.0-stage → 0.2.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 +615 -0
- package/LICENSE.md +7 -0
- package/README.md +99 -2
- package/dist/atoms/CommandMenu.d.ts +2 -0
- package/dist/atoms/CommandMenu.js +20 -0
- package/dist/atoms/List.d.ts +2 -0
- package/dist/atoms/List.js +6 -0
- package/dist/atoms/LoadMore.d.ts +2 -0
- package/dist/atoms/LoadMore.js +25 -0
- package/dist/atoms/Loading.d.ts +2 -0
- package/dist/atoms/Loading.js +7 -0
- package/dist/atoms/PlatformMark.d.ts +2 -0
- package/dist/atoms/PlatformMark.js +4 -0
- package/dist/atoms/RelationLink.d.ts +2 -0
- package/dist/atoms/RelationLink.js +6 -0
- package/dist/atoms/Row.d.ts +3 -0
- package/dist/atoms/Row.js +30 -0
- package/dist/atoms/RowMenu.d.ts +2 -0
- package/dist/atoms/RowMenu.js +112 -0
- package/dist/atoms/StatusBadge.d.ts +2 -0
- package/dist/atoms/StatusBadge.js +7 -0
- package/dist/atoms/StatusMarker.d.ts +2 -0
- package/dist/atoms/StatusMarker.js +19 -0
- package/dist/atoms/Tag.d.ts +2 -0
- package/dist/atoms/Tag.js +13 -0
- package/dist/atoms/TickBox.d.ts +2 -0
- package/dist/atoms/TickBox.js +8 -0
- package/dist/atoms/defaults.d.ts +2 -0
- package/dist/atoms/defaults.js +27 -0
- package/dist/atoms/tones.d.ts +5 -0
- package/dist/atoms/tones.js +28 -0
- package/dist/atoms/types.d.ts +178 -0
- package/dist/atoms/types.js +3 -0
- package/dist/cells/cell-format.d.ts +138 -0
- package/dist/cells/cell-format.js +16 -0
- package/dist/cells/cell-title.d.ts +17 -0
- package/dist/cells/cell-title.js +8 -0
- package/dist/cells/cell-values.d.ts +28 -0
- package/dist/cells/cell-values.js +87 -0
- package/dist/cells/index.d.ts +4 -0
- package/dist/cells/index.js +4 -0
- package/dist/cells/legacy-field.d.ts +52 -0
- package/dist/cells/legacy-field.js +164 -0
- package/dist/cells/relation-wrap.d.ts +3 -0
- package/dist/cells/relation-wrap.js +24 -0
- package/dist/cells/use-cell-format.d.ts +5 -0
- package/dist/cells/use-cell-format.js +10 -0
- package/dist/contract.d.ts +461 -0
- package/dist/contract.js +682 -0
- package/dist/display/actor.d.ts +4 -0
- package/dist/display/actor.js +26 -0
- package/dist/display/boolean.d.ts +18 -0
- package/dist/display/boolean.js +43 -0
- package/dist/display/breakdown.d.ts +15 -0
- package/dist/display/breakdown.js +32 -0
- package/dist/display/currency.d.ts +9 -0
- package/dist/display/currency.js +29 -0
- package/dist/display/date.d.ts +12 -0
- package/dist/display/date.js +26 -0
- package/dist/display/display-cores.d.ts +31 -0
- package/dist/display/display-cores.js +57 -0
- package/dist/display/entity-chip.d.ts +26 -0
- package/dist/display/entity-chip.js +9 -0
- package/dist/display/format.d.ts +66 -0
- package/dist/display/format.js +190 -0
- package/dist/display/index.d.ts +8 -0
- package/dist/display/index.js +7 -0
- package/dist/display/link.d.ts +29 -0
- package/dist/display/link.js +50 -0
- package/dist/display/location.d.ts +8 -0
- package/dist/display/location.js +22 -0
- package/dist/display/multi-value.d.ts +18 -0
- package/dist/display/multi-value.js +28 -0
- package/dist/display/name.d.ts +6 -0
- package/dist/display/name.js +14 -0
- package/dist/display/number.d.ts +11 -0
- package/dist/display/number.js +27 -0
- package/dist/display/options.d.ts +153 -0
- package/dist/display/options.js +1 -0
- package/dist/display/percent.d.ts +4 -0
- package/dist/display/percent.js +40 -0
- package/dist/display/phone.d.ts +11 -0
- package/dist/display/phone.js +45 -0
- package/dist/display/range.d.ts +6 -0
- package/dist/display/range.js +29 -0
- package/dist/display/relation.d.ts +4 -0
- package/dist/display/relation.js +29 -0
- package/dist/display/rich-text.d.ts +10 -0
- package/dist/display/rich-text.js +34 -0
- package/dist/display/select.d.ts +6 -0
- package/dist/display/select.js +38 -0
- package/dist/display/text-class.d.ts +23 -0
- package/dist/display/text-class.js +5 -0
- package/dist/display/text.d.ts +19 -0
- package/dist/display/text.js +8 -0
- package/dist/display/use-display-options.d.ts +2 -0
- package/dist/display/use-display-options.js +14 -0
- package/dist/display/user.d.ts +11 -0
- package/dist/display/user.js +10 -0
- package/dist/display/value-list.d.ts +10 -0
- package/dist/display/value-list.js +12 -0
- package/dist/display/viewer.d.ts +4 -0
- package/dist/display/viewer.js +11 -0
- package/dist/display/web-href.d.ts +8 -0
- package/dist/display/web-href.js +12 -0
- package/dist/editors/ChipsEditor.d.ts +59 -0
- package/dist/editors/ChipsEditor.js +73 -0
- package/dist/editors/DateEditor.d.ts +25 -0
- package/dist/editors/DateEditor.js +122 -0
- package/dist/editors/LocationEditor.d.ts +22 -0
- package/dist/editors/LocationEditor.js +228 -0
- package/dist/editors/NameEditor.d.ts +22 -0
- package/dist/editors/NameEditor.js +92 -0
- package/dist/editors/NumberEditor.d.ts +67 -0
- package/dist/editors/NumberEditor.js +86 -0
- package/dist/editors/RangeEditor.d.ts +22 -0
- package/dist/editors/RangeEditor.js +70 -0
- package/dist/editors/RelationEditor.d.ts +65 -0
- package/dist/editors/RelationEditor.js +64 -0
- package/dist/editors/SelectEditor.d.ts +72 -0
- package/dist/editors/SelectEditor.js +59 -0
- package/dist/editors/ValueListEditor.d.ts +38 -0
- package/dist/editors/ValueListEditor.js +217 -0
- package/dist/editors/edit-cores.d.ts +83 -0
- package/dist/editors/edit-cores.js +38 -0
- package/dist/editors/edit-session.d.ts +74 -0
- package/dist/editors/edit-session.js +35 -0
- package/dist/editors/open-values.d.ts +28 -0
- package/dist/editors/open-values.js +26 -0
- package/dist/editors/relation-source.d.ts +66 -0
- package/dist/editors/relation-source.js +102 -0
- package/dist/fields/binding.d.ts +87 -0
- package/dist/fields/binding.js +117 -0
- package/dist/fields/currency.d.ts +82 -0
- package/dist/fields/currency.js +41 -0
- package/dist/fields/denomination.d.ts +42 -0
- package/dist/fields/denomination.js +11 -0
- package/dist/fields/edit-core-types.d.ts +40 -0
- package/dist/fields/edit-core-types.js +29 -0
- package/dist/fields/format-knobs.d.ts +34 -0
- package/dist/fields/format-knobs.js +36 -0
- package/dist/fields/menus.d.ts +28 -0
- package/dist/fields/menus.js +1 -0
- package/dist/fields/money.d.ts +60 -0
- package/dist/fields/money.js +78 -0
- package/dist/fields/number-edit.d.ts +11 -0
- package/dist/fields/number-edit.js +17 -0
- package/dist/fields/prepare-write.d.ts +55 -0
- package/dist/fields/prepare-write.js +67 -0
- package/dist/fields/relation-source-types.d.ts +54 -0
- package/dist/fields/relation-source-types.js +1 -0
- package/dist/figures.d.ts +52 -0
- package/dist/figures.js +63 -0
- package/dist/filters/date-filter.d.ts +2 -0
- package/dist/filters/date-filter.js +1 -0
- package/dist/filters/filter-model.d.ts +176 -0
- package/dist/filters/filter-model.js +41 -0
- package/dist/filters/number-filter.d.ts +2 -0
- package/dist/filters/number-filter.js +1 -0
- package/dist/filters/range-filter.d.ts +2 -0
- package/dist/filters/range-filter.js +1 -0
- package/dist/filters/registry.d.ts +103 -0
- package/dist/filters/registry.js +8 -0
- package/dist/filters/relation-filter.d.ts +16 -0
- package/dist/filters/relation-filter.js +53 -0
- package/dist/filters/text-filter.d.ts +2 -0
- package/dist/filters/text-filter.js +1 -0
- 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 +27 -0
- package/dist/grid/chrome/GridCellEditors.d.ts +64 -0
- package/dist/grid/chrome/GridCellEditors.js +55 -0
- package/dist/grid/chrome/GridCellOutline.d.ts +70 -0
- package/dist/grid/chrome/GridCellOutline.js +21 -0
- package/dist/grid/chrome/GridChipsEditor.d.ts +28 -0
- package/dist/grid/chrome/GridChipsEditor.js +40 -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 +99 -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 +22 -0
- package/dist/grid/chrome/GridDateEditor.js +31 -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 +23 -0
- package/dist/grid/chrome/GridFooter.js +81 -0
- package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
- package/dist/grid/chrome/GridGroupMenu.js +57 -0
- package/dist/grid/chrome/GridHeader.d.ts +61 -0
- package/dist/grid/chrome/GridHeader.js +37 -0
- package/dist/grid/chrome/GridLongTextEditor.d.ts +36 -0
- package/dist/grid/chrome/GridLongTextEditor.js +127 -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 +19 -0
- package/dist/grid/chrome/GridNameEditor.js +36 -0
- package/dist/grid/chrome/GridNumberEditor.d.ts +35 -0
- package/dist/grid/chrome/GridNumberEditor.js +25 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +20 -0
- package/dist/grid/chrome/GridRangeEditor.js +25 -0
- package/dist/grid/chrome/GridRelationEditor.d.ts +21 -0
- package/dist/grid/chrome/GridRelationEditor.js +30 -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 +25 -0
- package/dist/grid/chrome/GridRow.js +136 -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 +133 -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 +18 -0
- package/dist/grid/chrome/GridSelectEditor.js +49 -0
- package/dist/grid/chrome/GridStructure.d.ts +48 -0
- package/dist/grid/chrome/GridStructure.js +45 -0
- package/dist/grid/chrome/GridTable.d.ts +4 -0
- package/dist/grid/chrome/GridTable.js +125 -0
- package/dist/grid/chrome/GridTableSurface.d.ts +15 -0
- package/dist/grid/chrome/GridTableSurface.js +6 -0
- package/dist/grid/chrome/GridTextEditor.d.ts +11 -0
- package/dist/grid/chrome/GridTextEditor.js +40 -0
- package/dist/grid/chrome/GridValueListEditor.d.ts +18 -0
- package/dist/grid/chrome/GridValueListEditor.js +36 -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/cells.d.ts +21 -0
- package/dist/grid/chrome/cells.js +20 -0
- package/dist/grid/chrome/checks.d.ts +35 -0
- package/dist/grid/chrome/checks.js +22 -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 +59 -0
- package/dist/grid/chrome/grid-cell-classes.js +30 -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-props.d.ts +131 -0
- package/dist/grid/chrome/grid-row-props.js +1 -0
- package/dist/grid/chrome/grid-styles.d.ts +37 -0
- package/dist/grid/chrome/grid-styles.js +8 -0
- package/dist/grid/chrome/grid-table-props.d.ts +173 -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/useGridHeaderDrag.d.ts +20 -0
- package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +47 -0
- package/dist/grid/chrome/useGridKeyboard.js +274 -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 +49 -0
- package/dist/grid/chrome/useGridRangeActions.js +188 -0
- package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
- package/dist/grid/chrome/useGridRangeGestures.js +190 -0
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +35 -0
- package/dist/grid/chrome/useGridRowContextMenu.js +127 -0
- package/dist/grid/chrome/useGridScaleStyles.d.ts +1 -0
- package/dist/grid/chrome/useGridScaleStyles.js +29 -0
- package/dist/grid/chrome/useGridScrollSync.d.ts +38 -0
- package/dist/grid/chrome/useGridScrollSync.js +176 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +55 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +197 -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 +81 -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 +34 -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/edit-values.d.ts +9 -0
- package/dist/grid/core/edit-values.js +1 -0
- package/dist/grid/core/editing-controller.d.ts +59 -0
- package/dist/grid/core/editing-controller.js +240 -0
- package/dist/grid/core/editing-model.d.ts +78 -0
- package/dist/grid/core/editing-model.js +136 -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 +50 -0
- package/dist/grid/core/pending-reconciliation.js +49 -0
- package/dist/grid/core/range-model.d.ts +25 -0
- package/dist/grid/core/range-model.js +59 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +85 -0
- package/dist/grid/core/spreadsheet-operations.js +253 -0
- package/dist/grid/core/useGridEditing.d.ts +43 -0
- package/dist/grid/core/useGridEditing.js +90 -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 +32 -0
- package/dist/grid/core/value-equality.js +34 -0
- package/dist/grid/index.d.ts +18 -0
- package/dist/grid/index.js +5 -0
- package/dist/grid/useGridTablePrefs.d.ts +50 -0
- package/dist/grid/useGridTablePrefs.js +101 -0
- package/dist/grouping/sort-groups.d.ts +18 -0
- package/dist/grouping/sort-groups.js +33 -0
- package/dist/grouping/types.d.ts +10 -0
- package/dist/grouping/types.js +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +28 -0
- package/dist/internal/chip.d.ts +4 -0
- package/dist/internal/chip.js +3 -0
- package/dist/internal/cx.d.ts +3 -0
- package/dist/internal/cx.js +3 -0
- package/dist/internal/viewport.d.ts +5 -0
- package/dist/internal/viewport.js +29 -0
- package/dist/model/aggregates.d.ts +59 -0
- package/dist/model/aggregates.js +186 -0
- package/dist/model/card-density.d.ts +8 -0
- package/dist/model/card-density.js +10 -0
- package/dist/model/card-layout.d.ts +85 -0
- package/dist/model/card-layout.js +90 -0
- package/dist/model/column-capabilities.d.ts +162 -0
- package/dist/model/column-capabilities.js +233 -0
- package/dist/model/column-filters.d.ts +106 -0
- package/dist/model/column-filters.js +321 -0
- package/dist/model/column-format.d.ts +103 -0
- package/dist/model/column-format.js +1 -0
- package/dist/model/column-from.d.ts +28 -0
- package/dist/model/column-from.js +160 -0
- package/dist/model/column-inspect.d.ts +18 -0
- package/dist/model/column-inspect.js +6 -0
- package/dist/model/column-knobs.d.ts +20 -0
- package/dist/model/column-knobs.js +16 -0
- package/dist/model/column-money.d.ts +13 -0
- package/dist/model/column-money.js +27 -0
- package/dist/model/column-order.d.ts +36 -0
- package/dist/model/column-order.js +68 -0
- package/dist/model/column-schema.d.ts +335 -0
- package/dist/model/column-schema.js +1 -0
- package/dist/model/column-sort.d.ts +17 -0
- package/dist/model/column-sort.js +11 -0
- package/dist/model/column-state.d.ts +77 -0
- package/dist/model/column-state.js +95 -0
- package/dist/model/column-types.d.ts +109 -0
- package/dist/model/column-types.js +50 -0
- package/dist/model/column-warnings.d.ts +44 -0
- package/dist/model/column-warnings.js +24 -0
- package/dist/model/density.d.ts +3 -0
- package/dist/model/density.js +13 -0
- package/dist/model/field-type-of.d.ts +21 -0
- package/dist/model/field-type-of.js +11 -0
- package/dist/model/filter-capabilities.d.ts +1 -0
- package/dist/model/filter-capabilities.js +1 -0
- package/dist/model/index.d.ts +38 -0
- package/dist/model/index.js +20 -0
- package/dist/model/part-rows.d.ts +28 -0
- package/dist/model/part-rows.js +40 -0
- package/dist/model/preferences.d.ts +155 -0
- package/dist/model/preferences.js +84 -0
- package/dist/model/prefs-buckets.d.ts +173 -0
- package/dist/model/prefs-buckets.js +71 -0
- package/dist/model/relation-filters.d.ts +45 -0
- package/dist/model/relation-filters.js +78 -0
- package/dist/model/render-count.d.ts +2 -0
- package/dist/model/render-count.js +24 -0
- package/dist/model/row-icon.d.ts +23 -0
- package/dist/model/row-icon.js +5 -0
- package/dist/model/view-rules.d.ts +73 -0
- package/dist/model/view-rules.js +216 -0
- package/dist/provider/ViewsProvider.d.ts +26 -0
- package/dist/provider/ViewsProvider.js +16 -0
- package/dist/provider/components.d.ts +230 -0
- package/dist/provider/components.js +3 -0
- package/dist/provider/context.d.ts +20 -0
- package/dist/provider/context.js +10 -0
- package/dist/provider/icons.d.ts +6 -0
- package/dist/provider/icons.js +1 -0
- package/dist/provider/menu-groups.d.ts +8 -0
- package/dist/provider/menu-groups.js +38 -0
- package/dist/provider/ports.d.ts +57 -0
- package/dist/provider/ports.js +9 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.js +4 -0
- package/dist/selection/SelectCheckbox.d.ts +17 -0
- package/dist/selection/SelectCheckbox.js +11 -0
- package/dist/selection/index.d.ts +7 -0
- package/dist/selection/index.js +6 -0
- package/dist/selection/model.d.ts +55 -0
- package/dist/selection/model.js +86 -0
- package/dist/selection/row-click.d.ts +35 -0
- package/dist/selection/row-click.js +20 -0
- package/dist/selection/types.d.ts +17 -0
- package/dist/selection/types.js +1 -0
- package/dist/selection/useCheckDragSelect.d.ts +61 -0
- package/dist/selection/useCheckDragSelect.js +165 -0
- package/dist/selection/useListSelection.d.ts +39 -0
- package/dist/selection/useListSelection.js +48 -0
- package/dist/selection/useListSelectionShortcuts.d.ts +6 -0
- package/dist/selection/useListSelectionShortcuts.js +14 -0
- package/dist/selection/useRestIntent.d.ts +18 -0
- package/dist/selection/useRestIntent.js +35 -0
- package/docs/contract.md +525 -0
- 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 +412 -0
- package/docs/guides/display.md +203 -0
- package/docs/guides/editors.md +404 -0
- package/docs/guides/ports.md +246 -0
- package/docs/guides/selection.md +270 -0
- package/docs/guides/the-grid.md +677 -0
- package/docs/guides/the-provider.md +446 -0
- package/docs/index.md +50 -0
- package/docs/install.md +67 -0
- package/docs/reference/cells.md +28 -0
- package/docs/reference/display.md +42 -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 +9 -0
- package/docs/reference/editors-range.md +6 -0
- package/docs/reference/editors-relation.md +9 -0
- package/docs/reference/editors-select.md +8 -0
- package/docs/reference/editors-session.md +9 -0
- package/docs/reference/editors-value-list.md +6 -0
- package/docs/reference/editors.md +5 -0
- package/docs/reference/grid.md +39 -0
- package/docs/reference/react.md +86 -0
- package/docs/reference/selection.md +33 -0
- package/docs/reference/views.md +601 -0
- package/docs/reshaping.md +19 -0
- package/package.json +118 -3
- package/skills/views/SKILL.md +102 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../../internal/cx.js";
|
|
4
|
+
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { shownCodeOf } from "../../fields/money.js";
|
|
6
|
+
import { cellEditBaseline } from "./cell-clipboard.js";
|
|
7
|
+
import { renderActionCell, renderTypedCell } from "./cells.js";
|
|
8
|
+
import { gridColumnHasEditor, gridEditorKind } from "./editors.js";
|
|
9
|
+
import { GridCellAnchoredEditor, GridCellInlineEditor, } from "./GridCellEditors.js";
|
|
10
|
+
import { GridCellOutline } from "./GridCellOutline.js";
|
|
11
|
+
import { GRID_RANGE_TINT_CLASS, gridCellClassName } from "./grid-cell-classes.js";
|
|
12
|
+
import { gridBooleanMode, columnEffectiveWritable } from "../../model/column-capabilities.js";
|
|
13
|
+
import { gridColumnInspectable, isLongTextColumn } from "../../model/column-inspect.js";
|
|
14
|
+
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
15
|
+
import { GridRowActions } from "./GridRowActions.js";
|
|
16
|
+
import { GridRowGlyph } from "./GridRowGlyph.js";
|
|
17
|
+
import { requestedSettlementTitle } from "@viewkitjs/fields";
|
|
18
|
+
function FillDot({ enabled }) {
|
|
19
|
+
return (_jsx("span", { "data-fill-dot": enabled ? "" : undefined, className: cx("absolute bottom-[-7px] right-[-7px] z-10 hidden h-3 w-3 rounded-full border-2 border-(color:--vk-ground) bg-(color:--vk-brand)", "[@media(hover:hover)_and_(pointer:fine)]:block", enabled ? "cursor-crosshair" : "pointer-events-none") }));
|
|
20
|
+
}
|
|
21
|
+
export function GridRowCells({ props }) {
|
|
22
|
+
const { conventions, icons, messages } = useViews();
|
|
23
|
+
const { row, id, rowKey, columns, selected, rowActions, rowIcon, verticalBorders = true, wrapCells = false, optionColors, dateStyles, durationStyles, numberFormats, showTimeOverrides, percentDisplays, editingEnabled, focusedColId, editingColId, pendingByCol, settlementByCol, selectValues, rowRange, frozenCount = 0, frozenLeft, listConfig, onStartEdit, onEditorTab, onEditorEnter, editSeed, onCommitCell, onCancelEdit, onOpenRelation: onOpenRelationValue, entityIcon, commands, } = props;
|
|
24
|
+
const canEdit = (column) => editingEnabled && gridColumnHasEditor(column) && columnEffectiveWritable(column, listConfig);
|
|
25
|
+
const editBaseline = (column) => cellEditBaseline(column, row, pendingByCol);
|
|
26
|
+
return columns.map((col, i) => {
|
|
27
|
+
const editing = editingColId === col.id;
|
|
28
|
+
const focused = focusedColId === col.id;
|
|
29
|
+
const span = rowRange?.find((s) => i >= s.startCol && i <= s.endCol);
|
|
30
|
+
const spanLeft = !!span && i === span.startCol;
|
|
31
|
+
const spanRight = !!span && i === span.endCol;
|
|
32
|
+
const writable = canEdit(col);
|
|
33
|
+
const editorKind = writable
|
|
34
|
+
? gridEditorKind(col)
|
|
35
|
+
: gridColumnInspectable(col)
|
|
36
|
+
? "text"
|
|
37
|
+
: null;
|
|
38
|
+
const fieldKey = fieldKeyOf(col);
|
|
39
|
+
const numberFormat = numberFormats?.[fieldKey];
|
|
40
|
+
const showTime = showTimeOverrides?.[fieldKey] ?? col.format?.withTime ?? false;
|
|
41
|
+
const onResolve = editingEnabled &&
|
|
42
|
+
columnEffectiveWritable(col, listConfig) &&
|
|
43
|
+
gridBooleanMode(col) === "marker"
|
|
44
|
+
? () => onCommitCell(row, id, col.id, true, false)
|
|
45
|
+
: undefined;
|
|
46
|
+
const onToggle = editingEnabled &&
|
|
47
|
+
columnEffectiveWritable(col, listConfig) &&
|
|
48
|
+
gridBooleanMode(col) === "toggle"
|
|
49
|
+
? (next) => onCommitCell(row, id, col.id, editBaseline(col) === true, next)
|
|
50
|
+
: undefined;
|
|
51
|
+
const onOpenRelation = onOpenRelationValue && (col.type === "relation" || col.type === "user")
|
|
52
|
+
?
|
|
53
|
+
(value) => onOpenRelationValue(value, col.id, row)
|
|
54
|
+
: undefined;
|
|
55
|
+
const commandItems = col.command ? commands?.[fieldKeyOf(col)]?.(row) : undefined;
|
|
56
|
+
const typedCell = () => renderTypedCell(col, row, {
|
|
57
|
+
optionColors: optionColors?.[fieldKey],
|
|
58
|
+
dateStyle: dateStyles?.[fieldKey],
|
|
59
|
+
durationStyle: durationStyles?.[fieldKey],
|
|
60
|
+
decimals: numberFormat?.decimals,
|
|
61
|
+
withTime: showTime,
|
|
62
|
+
percentDisplay: percentDisplays?.[fieldKey],
|
|
63
|
+
wrap: wrapCells,
|
|
64
|
+
valueOverride: pendingByCol?.[col.id],
|
|
65
|
+
markerReason: col.marker?.reason?.(row),
|
|
66
|
+
onResolve,
|
|
67
|
+
onToggle,
|
|
68
|
+
onOpenRelation,
|
|
69
|
+
entityIcon,
|
|
70
|
+
commandItems,
|
|
71
|
+
});
|
|
72
|
+
const tabTo = (backwards) => onEditorTab(rowKey, col.id, backwards);
|
|
73
|
+
const enterAdvance = () => onEditorEnter(rowKey, col.id);
|
|
74
|
+
const frozen = i < frozenCount;
|
|
75
|
+
const settlement = settlementByCol?.[col.id];
|
|
76
|
+
const editorCtx = {
|
|
77
|
+
row,
|
|
78
|
+
rowId: id,
|
|
79
|
+
col,
|
|
80
|
+
editorKind,
|
|
81
|
+
readOnly: !writable,
|
|
82
|
+
baseline: editBaseline(col),
|
|
83
|
+
editSeed,
|
|
84
|
+
decimals: numberFormat?.decimals,
|
|
85
|
+
selectValues: selectValues?.[col.id],
|
|
86
|
+
optionColors: optionColors?.[fieldKey],
|
|
87
|
+
entityIcon,
|
|
88
|
+
onCommitCell,
|
|
89
|
+
onCancel: () => onCancelEdit(rowKey, col.id),
|
|
90
|
+
onTab: tabTo,
|
|
91
|
+
onEnter: enterAdvance,
|
|
92
|
+
};
|
|
93
|
+
return (_jsxs("div", { "data-slot": "vk-grid-cell", "data-col-id": col.id, "data-settlement": settlement, title: settlement ? requestedSettlementTitle(col.field?.provenance, conventions) : undefined, style: frozen && frozenLeft ? { left: frozenLeft(i) } : undefined, className: gridCellClassName({
|
|
94
|
+
align: col.align,
|
|
95
|
+
isTitle: col.type === "title",
|
|
96
|
+
frozen,
|
|
97
|
+
focused,
|
|
98
|
+
editing,
|
|
99
|
+
inRange: !!span,
|
|
100
|
+
selected,
|
|
101
|
+
lastColumn: i === columns.length - 1,
|
|
102
|
+
verticalBorders,
|
|
103
|
+
wrap: wrapCells,
|
|
104
|
+
settlement,
|
|
105
|
+
}), children: [span && (_jsx("span", { "aria-hidden": true, className: GRID_RANGE_TINT_CLASS })), span?.top && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { top: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), span?.bottom && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { bottom: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), spanLeft && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { left: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), spanRight && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { right: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), span && span.dotCol === i && !editing && (_jsx(FillDot, { enabled: editingEnabled })), (focused || editing) && (_jsx(GridCellOutline, { tone: "focus", editing: editing })), !focused && !editing && !span && col.type !== "title" && (_jsx(GridCellOutline, { tone: "hover" })), focused && !editing && !span && (_jsx(FillDot, { enabled: editingEnabled })), col.type === "title" && rowIcon && !editing && (_jsx("span", { className: "mr-2.5 flex shrink-0 items-center", children: _jsx(GridRowGlyph, { row: row, rowIcon: rowIcon }) })), editing ? _jsx(GridCellInlineEditor, { ctx: editorCtx }) : null, editing &&
|
|
106
|
+
(editorKind === "number" || editorKind === "range" || (editorKind === "text" && !isLongTextColumn(col)))
|
|
107
|
+
? null
|
|
108
|
+
: col.actions
|
|
109
|
+
? renderActionCell(col, row)
|
|
110
|
+
: col.render
|
|
111
|
+
? col.render(row, { value: col.accessor?.(row), code: shownCodeOf(col, row) })
|
|
112
|
+
: typedCell(), editing ? _jsx(GridCellAnchoredEditor, { ctx: editorCtx }) : null, col.type === "title" && !editing && (_jsx(GridRowActions, { row: row, selected: selected, actions: [
|
|
113
|
+
...(rowActions ?? []),
|
|
114
|
+
...(canEdit(col)
|
|
115
|
+
? [
|
|
116
|
+
{
|
|
117
|
+
id: "edit",
|
|
118
|
+
icon: () => _jsx(icons.edit, { className: "h-3.5 w-3.5" }),
|
|
119
|
+
label: () => messages({ key: "views.menus.edit" }),
|
|
120
|
+
onClick: () => onStartEdit(rowKey, col.id),
|
|
121
|
+
},
|
|
122
|
+
]
|
|
123
|
+
: []),
|
|
124
|
+
] })), (editorKind === "select" || editorKind === "relation" || editorKind === "chips") && (_jsx("button", { type: "button", tabIndex: -1, "aria-label": messages({ key: "views.grid.change-value" }), onClick: (e) => {
|
|
125
|
+
e.stopPropagation();
|
|
126
|
+
if (!editing)
|
|
127
|
+
onStartEdit(rowKey, col.id);
|
|
128
|
+
}, className: cx("absolute right-1 top-[calc(var(--vk-chrome-h,100%)/2)] flex h-5 w-5 -translate-y-1/2 items-center justify-center hover:text-(color:--vk-fg)", editing
|
|
129
|
+
? "text-(color:--vk-fg) opacity-100"
|
|
130
|
+
:
|
|
131
|
+
"text-(color:--vk-fg-subtlest) md:opacity-0 md:group-hover/gridcell:opacity-100"), children: _jsx(icons.caretDown, { className: cx("h-3 w-3 transition-transform duration-100", editing && "rotate-180") }) }))] }, col.id));
|
|
132
|
+
});
|
|
133
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ListRowIconAccessor } from "../../model/row-icon.js";
|
|
2
|
+
/**
|
|
3
|
+
* The one place a grid row's leading glyph gets its LOOK — size from the row's
|
|
4
|
+
* own scale variable, color neutral unless the list named a semantic tone.
|
|
5
|
+
*
|
|
6
|
+
* Both facts live here rather than at each call site so a list can only choose
|
|
7
|
+
* WHICH icon and (rarely) what state it means, never how big or how loud.
|
|
8
|
+
*/
|
|
9
|
+
export declare function GridRowGlyph<Row>({ row, rowIcon, }: {
|
|
10
|
+
row: Row;
|
|
11
|
+
rowIcon: ListRowIconAccessor<Row>;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { STATUS_SLOT_CLASSES } from "@viewkitjs/fields/design/status-slots";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { normalizeRowIcon } from "../../model/row-icon.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
export function GridRowGlyph({ row, rowIcon, }) {
|
|
8
|
+
const { AppIcon } = useViews().components;
|
|
9
|
+
const resolved = normalizeRowIcon(rowIcon(row));
|
|
10
|
+
if (!resolved)
|
|
11
|
+
return null;
|
|
12
|
+
return (_jsx(AppIcon, { name: resolved.icon, className: cx("h-(--vk-glyph,0.875rem) w-(--vk-glyph,0.875rem)", resolved.tone ? STATUS_SLOT_CLASSES[resolved.tone].glyph : "text-(color:--vk-fg-subtle)") }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* The GRID's host around the shared `SelectEditor` (`@viewkitjs/views/editors/select`) —
|
|
4
|
+
* the option panel is one component across every surface; this host owns only
|
|
5
|
+
* the grid's mechanics: anchor to the cell rect, open on mount, WHICH close
|
|
6
|
+
* happened, the exit animation gap, and the write.
|
|
7
|
+
*/
|
|
8
|
+
export declare function GridSelectEditor<Row>({ column, values, current, optionColors, onCommit, onCancel, }: {
|
|
9
|
+
column: ListColumn<Row>;
|
|
10
|
+
/** Option values in display order (declared first, then data-discovered). */
|
|
11
|
+
values: string[];
|
|
12
|
+
/** The cell's current value ("" when unset). */
|
|
13
|
+
current: string;
|
|
14
|
+
/** This column's per-user color overrides (select columns). */
|
|
15
|
+
optionColors?: Record<string, ListSelectColor>;
|
|
16
|
+
onCommit: (value: string) => void;
|
|
17
|
+
onCancel: () => void;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { SelectEditor, pickerOptionsFromField, } from "../../editors/SelectEditor.js";
|
|
6
|
+
import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
7
|
+
import { isOpenVocabulary } from "@viewkitjs/fields";
|
|
8
|
+
import { prettifyOptionValue } from "../../model/column-state.js";
|
|
9
|
+
import { offeredValues, useOpenValues } from "../../editors/open-values.js";
|
|
10
|
+
export function GridSelectEditor({ column, values, current, optionColors, onCommit, onCancel, }) {
|
|
11
|
+
const { Popover } = useViews().components;
|
|
12
|
+
const [open, setOpen] = useState(true);
|
|
13
|
+
const editorRef = useRef(null);
|
|
14
|
+
const anchorRef = useRef(null);
|
|
15
|
+
const closedRef = useRef(false);
|
|
16
|
+
const EXIT_MS = 160;
|
|
17
|
+
const close = (reason) => {
|
|
18
|
+
if (closedRef.current)
|
|
19
|
+
return;
|
|
20
|
+
closedRef.current = true;
|
|
21
|
+
const resolution = editorRef.current?.resolveClose(reason) ?? { kind: "noop" };
|
|
22
|
+
setOpen(false);
|
|
23
|
+
window.setTimeout(() => {
|
|
24
|
+
if (resolution.kind === "commit")
|
|
25
|
+
onCommit(resolution.payload);
|
|
26
|
+
else
|
|
27
|
+
onCancel();
|
|
28
|
+
}, EXIT_MS);
|
|
29
|
+
};
|
|
30
|
+
const known = useOpenValues(column.field);
|
|
31
|
+
const optionLabel = (value) => column.options?.find((o) => o.value === value)?.label ?? prettifyOptionValue(value);
|
|
32
|
+
const pickerOptions = column.field && (column.field.type === "select" || column.field.type === "status")
|
|
33
|
+
? pickerOptionsFromField(column.field, { optionColors, extraValues: offeredValues(column.field, known, values) })
|
|
34
|
+
: values.map((value) => column.type === "status"
|
|
35
|
+
? {
|
|
36
|
+
value,
|
|
37
|
+
label: optionLabel(value),
|
|
38
|
+
slot: column.options?.find((o) => o.value === value)?.slot ?? "muted",
|
|
39
|
+
}
|
|
40
|
+
: {
|
|
41
|
+
value,
|
|
42
|
+
label: optionLabel(value),
|
|
43
|
+
color: resolveCategoryColor(value, column.options, optionColors),
|
|
44
|
+
});
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(Popover, { open: open, onOpenChange: (next) => {
|
|
46
|
+
if (!next)
|
|
47
|
+
close("outside");
|
|
48
|
+
}, anchor: anchorRef, align: "start", sideOffset: 4, onEscape: () => close("escape"), onOutsidePress: () => close("outside"), initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-48 z-90", children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, initial: current, creatable: !!column.field && isOpenVocabulary(column.field), onRequestClose: close }) })] }));
|
|
49
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { ListGroup } from "../../grouping/types.js";
|
|
3
|
+
import type { ListGroupSummaryPart } from "../../model/preferences.js";
|
|
4
|
+
import { type GridGroupSortOption } from "./GridGroupMenu.js";
|
|
5
|
+
import type { GridSortState } from "./GridColumnMenu.js";
|
|
6
|
+
import type { GridScrollSurface, useGridScrollSync } from "./useGridScrollSync.js";
|
|
7
|
+
import type { GridGroupFigure, GroupCountNoun } from "./grid-table-props.js";
|
|
8
|
+
type ScrollSync = ReturnType<typeof useGridScrollSync>;
|
|
9
|
+
export declare function GridBody<Row>({ empty, emptyState, grouped, groups, rows, isMobile, selectable, selecting, allSelected, someSelected, selectAll, clearSelection, isCollapsed, countOf, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, figures, countNoun, renderHeader, renderGroupCheckbox, renderRow, renderFooter, minWidth, surface, headerWheelRef, headerPanHandlers, }: {
|
|
10
|
+
empty: boolean;
|
|
11
|
+
emptyState?: ReactNode;
|
|
12
|
+
grouped: boolean;
|
|
13
|
+
groups: ListGroup<Row>[];
|
|
14
|
+
rows: Row[];
|
|
15
|
+
isMobile: boolean;
|
|
16
|
+
selectable: boolean;
|
|
17
|
+
selecting: boolean;
|
|
18
|
+
allSelected: boolean;
|
|
19
|
+
someSelected: boolean;
|
|
20
|
+
selectAll: () => void;
|
|
21
|
+
clearSelection: () => void;
|
|
22
|
+
isCollapsed?: (key: string) => boolean;
|
|
23
|
+
countOf?: (group: ListGroup<Row>) => number;
|
|
24
|
+
sort?: GridSortState;
|
|
25
|
+
sortOptions?: GridGroupSortOption[];
|
|
26
|
+
groupSummary?: ListGroupSummaryPart[];
|
|
27
|
+
onToggleGroup?: (key: string) => void;
|
|
28
|
+
onGroupSummaryChange?: (part: ListGroupSummaryPart, next: boolean) => void;
|
|
29
|
+
renderGroupLabel?: (group: ListGroup<Row>) => ReactNode;
|
|
30
|
+
onHideGroup?: (key: string) => void;
|
|
31
|
+
/** The figures the header can show, in the list's order. */
|
|
32
|
+
figures?: GridGroupFigure<Row>[];
|
|
33
|
+
/** The count's noun: "2 companies". None: a bare count. */
|
|
34
|
+
countNoun?: GroupCountNoun;
|
|
35
|
+
renderHeader: (inline: boolean, checkbox?: ReactNode) => ReactNode;
|
|
36
|
+
renderGroupCheckbox: (items: Row[]) => ReactNode;
|
|
37
|
+
/** Receives map's full triple: the row needs its INDEX and the sibling
|
|
38
|
+
* list to know whether the row above it is selected (see `selectedAbove`). */
|
|
39
|
+
/** The group key rides along: a row drawn under two groups is two rows on
|
|
40
|
+
* screen, and each needs its own identity. See `gridRowKey`. */
|
|
41
|
+
renderRow: (row: Row, index: number, items: Row[], groupKey: string) => ReactNode;
|
|
42
|
+
renderFooter: (group: ListGroup<Row>) => ReactNode;
|
|
43
|
+
minWidth: string;
|
|
44
|
+
surface: GridScrollSurface;
|
|
45
|
+
headerWheelRef: ScrollSync["headerWheelRef"];
|
|
46
|
+
headerPanHandlers: ScrollSync["headerPanHandlers"];
|
|
47
|
+
}): import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../../provider/context.js";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { GridHeadCheck } from "./checks.js";
|
|
6
|
+
import { StuckMarker } from "./StuckMarker.js";
|
|
7
|
+
import { GridFrozenShadow } from "./GridCellOutline.js";
|
|
8
|
+
import { GridGroupMenu } from "./GridGroupMenu.js";
|
|
9
|
+
import { GRID_BLEED, GRID_HEADER_BG, GRID_ROW_PAD } from "./grid-styles.js";
|
|
10
|
+
function GridCollapseRegion({ collapsed, children, }) {
|
|
11
|
+
const { Collapse } = useViews().components;
|
|
12
|
+
return (_jsx(Collapse, { open: !collapsed, clipClassName: cx("pt-[2px] mt-[-2px] pb-2 -mb-2", GRID_BLEED, GRID_ROW_PAD), children: children }));
|
|
13
|
+
}
|
|
14
|
+
function GridRowsScroller({ minWidth, surface, children, }) {
|
|
15
|
+
const { register, onScroll, className } = surface;
|
|
16
|
+
return (_jsx(_Fragment, { children: _jsxs("div", { className: cx("relative flow-root", GRID_BLEED), children: [_jsx("div", { ref: register, onScroll: onScroll, "data-grid-scroller": true, className: cx(className, "pt-[2px] mt-[-2px] pb-2 -mb-2"), children: _jsx("div", { style: { minWidth }, children: children }) }), _jsx(GridFrozenShadow, {})] }) }));
|
|
17
|
+
}
|
|
18
|
+
function GridGroupSection({ group, collapsed, count, isMobile, selectable, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, figures, countNoun, renderHeader, renderGroupCheckbox, renderRow, renderFooter, minWidth, surface, headerWheelRef, headerPanHandlers, }) {
|
|
19
|
+
const { icons, messages } = useViews();
|
|
20
|
+
const Caret = collapsed ? icons.caretRight : icons.caretDown;
|
|
21
|
+
const summaryParts = groupSummary ?? [];
|
|
22
|
+
const shownFigures = (figures ?? []).filter((figure) => summaryParts.includes(figure.part));
|
|
23
|
+
const parts = [];
|
|
24
|
+
if (summaryParts.includes("count")) {
|
|
25
|
+
const noun = countNoun ? (count === 1 ? countNoun.one : countNoun.other) : null;
|
|
26
|
+
parts.push({ key: "count", node: noun ? `${count} ${noun}` : count });
|
|
27
|
+
}
|
|
28
|
+
for (const figure of shownFigures) {
|
|
29
|
+
parts.push({
|
|
30
|
+
key: figure.part,
|
|
31
|
+
node: (_jsxs(_Fragment, { children: [figure.label, " ", figure.render(group)] })),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return (_jsxs("div", { "data-slot": "vk-grid-group", className: "mt-5 first:mt-0", children: [_jsx(StuckMarker, {}), _jsxs("div", { className: cx("sticky top-(--vk-pinned-top,0px) z-30 touch-pan-y data-[stuck=true]:bg-(color:--vk-ground)", GRID_HEADER_BG, GRID_BLEED, GRID_ROW_PAD), ref: headerWheelRef, ...headerPanHandlers, children: [_jsxs("div", { "data-slot": "vk-grid-group-header", className: "group/gridlabel relative mb-1.5 flex h-(--vk-label-h) select-none items-center gap-2", children: [_jsx("button", { type: "button", "aria-label": messages({ key: collapsed ? "views.grid.group-expand" : "views.grid.group-collapse" }), "aria-expanded": !collapsed, onClick: () => onToggleGroup?.(group.key), className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-sm text-(color:--vk-fg-subtle) hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)", children: _jsx(Caret, { className: "h-(--vk-glyph) w-(--vk-glyph)" }) }), _jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem-(1.5rem-var(--vk-glyph))/2)] truncate text-(length:--vk-text) font-medium", children: renderGroupLabel?.(group) ?? group.label ?? "—" }), parts.length > 0 && (_jsx("span", { className: "ml-[calc(var(--vk-px)-0.5rem)] flex min-w-0 items-baseline gap-1.5 overflow-hidden text-(length:--vk-text) text-(color:--vk-fg-subtle) tabular-nums", children: parts.map((part) => (_jsxs("span", { className: "flex items-baseline gap-1.5 whitespace-nowrap", children: [_jsx("span", { className: "text-(color:--vk-fg-subtlest)", children: "\u00B7" }), _jsx("span", { children: part.node })] }, part.key))) })), ((sort && sortOptions && sortOptions.length > 0) || onHideGroup) && (_jsx(GridGroupMenu, { sort: sort, sortOptions: sortOptions ?? [], summary: summaryParts, onSummaryChange: onGroupSummaryChange, figures: figures, onHide: onHideGroup ? () => onHideGroup(group.key) : undefined }))] }), !isMobile && (_jsx(GridCollapseRegion, { collapsed: collapsed, children: renderHeader(false, selectable ? renderGroupCheckbox(group.items) : undefined) }))] }), _jsx(GridCollapseRegion, { collapsed: collapsed, children: _jsxs(GridRowsScroller, { minWidth: minWidth, surface: surface, children: [isMobile && renderHeader(true), group.items.map((row, index, items) => renderRow(row, index, items, group.key)), renderFooter(group)] }) })] }));
|
|
35
|
+
}
|
|
36
|
+
export function GridBody({ empty, emptyState, grouped, groups, rows, isMobile, selectable, selecting, allSelected, someSelected, selectAll, clearSelection, isCollapsed, countOf, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, figures, countNoun, renderHeader, renderGroupCheckbox, renderRow, renderFooter, minWidth, surface, headerWheelRef, headerPanHandlers, }) {
|
|
37
|
+
const { messages } = useViews();
|
|
38
|
+
if (empty) {
|
|
39
|
+
return (_jsxs(_Fragment, { children: [renderHeader(false), emptyState] }));
|
|
40
|
+
}
|
|
41
|
+
if (!grouped) {
|
|
42
|
+
return (_jsxs(_Fragment, { children: [!isMobile && _jsx(StuckMarker, {}), !isMobile && (_jsx("div", { className: cx("sticky top-(--vk-pinned-top,0px) z-20 data-[stuck=true]:bg-(color:--vk-ground)", GRID_HEADER_BG), ref: headerWheelRef, children: renderHeader(false, selectable ? (_jsx(GridHeadCheck, { selecting: selecting, allSelected: allSelected, someSelected: someSelected, onToggle: (next) => (next ? selectAll() : clearSelection()), "aria-label": messages({ key: "views.grid.select-all" }) })) : undefined) })), _jsxs(GridRowsScroller, { minWidth: minWidth, surface: surface, children: [isMobile && renderHeader(true), rows.map((row, index, items) => renderRow(row, index, items, groups[0]?.key ?? "__all__")), groups[0] != null && renderFooter(groups[0])] })] }));
|
|
43
|
+
}
|
|
44
|
+
return groups.map((group) => (_jsx(GridGroupSection, { group: group, collapsed: isCollapsed?.(group.key) ?? false, count: countOf ? countOf(group) : group.items.length, isMobile: isMobile, selectable: selectable, sort: sort, sortOptions: sortOptions, groupSummary: groupSummary, onToggleGroup: onToggleGroup, onGroupSummaryChange: onGroupSummaryChange, renderGroupLabel: renderGroupLabel, onHideGroup: onHideGroup, figures: figures, countNoun: countNoun, renderHeader: renderHeader, renderGroupCheckbox: renderGroupCheckbox, renderRow: renderRow, renderFooter: renderFooter, minWidth: minWidth, surface: surface, headerWheelRef: headerWheelRef, headerPanHandlers: headerPanHandlers }, group.key)));
|
|
45
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { GridTableProps } from "./grid-table-props.js";
|
|
2
|
+
export type { GridTableProps } from "./grid-table-props.js";
|
|
3
|
+
/** Spreadsheet sibling to ListView, including editing and synchronized grouped rails. */
|
|
4
|
+
export declare function GridTable<Row>(props: GridTableProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useDeferredValue, useMemo, useRef } from "react";
|
|
4
|
+
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { GridRailProbe, useGridRailReveal } from "./useGridRailReveal.js";
|
|
6
|
+
import { useGridBatchApi } from "./useGridBatchApi.js";
|
|
7
|
+
import { gridRowKey } from "../core/coordinates.js";
|
|
8
|
+
import { useIsMobile } from "../../internal/viewport.js";
|
|
9
|
+
import { GridRow } from "./GridRow.js";
|
|
10
|
+
import { GridHeadCheck } from "./checks.js";
|
|
11
|
+
import { useGridColumnLayout } from "./useGridColumnLayout.js";
|
|
12
|
+
import { useGridScrollSync } from "./useGridScrollSync.js";
|
|
13
|
+
import { GridHeader } from "./GridHeader.js";
|
|
14
|
+
import { GridFooter } from "./GridFooter.js";
|
|
15
|
+
import { GridBody } from "./GridStructure.js";
|
|
16
|
+
import { useGridScaleStyles } from "./useGridScaleStyles.js";
|
|
17
|
+
import { useGridTableInteractionModel } from "./useGridTableInteractionModel.js";
|
|
18
|
+
import { useGridTableSelection } from "./useGridTableSelection.js";
|
|
19
|
+
import { useGridHeaderDrag } from "./useGridHeaderDrag.js";
|
|
20
|
+
import { GridTableSurface } from "./GridTableSurface.js";
|
|
21
|
+
export function GridTable(props) {
|
|
22
|
+
const { atoms, messages } = useViews();
|
|
23
|
+
const { Loading } = atoms;
|
|
24
|
+
const deferredKey = useDeferredValue(props.transitionKey);
|
|
25
|
+
if (props.transitionPending || !Object.is(deferredKey, props.transitionKey)) {
|
|
26
|
+
return _jsx(Loading, { placement: "body", label: props.transitionLabel ?? messages({ key: "views.grid.loading" }) });
|
|
27
|
+
}
|
|
28
|
+
return _jsx(GridTableContent, { ...props });
|
|
29
|
+
}
|
|
30
|
+
function GridTableContent(props) {
|
|
31
|
+
const { groups, grouped, getRowId, columns, isCollapsed, onToggleGroup, renderGroupLabel, onHideGroup, renderAggregate, countOf, onOpenRow, onPrefetchRow, rowHref, rowClassName, onRowDelete, rowActions, rowIcon, showRowIcon = true, freezeIdentity = true, selection, loadMore, emptyState, sort, groupBy, sortOptions, groupSummary, aggregates, onAggregateChange, onGroupSummaryChange, groupFigures, countNoun, optionColors, onOptionColorChange, dateStyles, onDateStyleChange, durationStyles, onDurationStyleChange, numberFormats, onNumberFormatChange, showTimeOverrides, onShowTimeChange, percentDisplays, onPercentDisplayChange, columnState, onColumnStateChange, listConfig, } = props;
|
|
32
|
+
const { atoms, messages } = useViews();
|
|
33
|
+
const { LoadMore } = atoms;
|
|
34
|
+
const verticalBorders = props.verticalBorders ?? true;
|
|
35
|
+
const wrapCells = props.wrapCells ?? false;
|
|
36
|
+
const scale = props.scale ?? 1;
|
|
37
|
+
const isMobile = useIsMobile();
|
|
38
|
+
const rootRef = useRef(null);
|
|
39
|
+
const { visibleColumns, widthVarsStyle, frozenCount, frozenLeft, columnManager, gridTemplate, minWidth, resizingId, startResize, moveResize, endResize, resetColumnWidth, hideColumn, moveColumn, } = useGridColumnLayout({
|
|
40
|
+
rootRef,
|
|
41
|
+
columns,
|
|
42
|
+
columnState,
|
|
43
|
+
onColumnStateChange,
|
|
44
|
+
scale,
|
|
45
|
+
freezeIdentity,
|
|
46
|
+
viewBacked: props.viewBacked,
|
|
47
|
+
});
|
|
48
|
+
const showAddColumn = !!columnManager && !isMobile;
|
|
49
|
+
const scaleVarsStyle = useGridScaleStyles(scale, grouped, isMobile, showAddColumn);
|
|
50
|
+
const flatRows = useMemo(() => groups.flatMap((g) => g.items), [groups]);
|
|
51
|
+
const rowIndex = useMemo(() => {
|
|
52
|
+
const byKey = new Map();
|
|
53
|
+
for (const group of groups) {
|
|
54
|
+
for (const row of group.items) {
|
|
55
|
+
const rowId = getRowId(row);
|
|
56
|
+
const key = gridRowKey(group.key, rowId);
|
|
57
|
+
byKey.set(key, { key, rowId, row });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
return byKey;
|
|
61
|
+
}, [groups, getRowId]);
|
|
62
|
+
const visibleRowKeys = useMemo(() => [...rowIndex.keys()], [rowIndex]);
|
|
63
|
+
const { selectable, selecting, selectionState: sel, checkDrag, groupSelection, } = useGridTableSelection({
|
|
64
|
+
rootRef,
|
|
65
|
+
groups,
|
|
66
|
+
grouped,
|
|
67
|
+
isCollapsed,
|
|
68
|
+
getRowId,
|
|
69
|
+
selection,
|
|
70
|
+
});
|
|
71
|
+
const visibleColIds = useMemo(() => visibleColumns.map((c) => c.id), [visibleColumns]);
|
|
72
|
+
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, editSeed, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab, onEditorEnter, } = useGridTableInteractionModel({
|
|
73
|
+
rootRef,
|
|
74
|
+
props,
|
|
75
|
+
rows: flatRows,
|
|
76
|
+
visibleRows: visibleRowKeys,
|
|
77
|
+
rowIndex,
|
|
78
|
+
visibleColumns,
|
|
79
|
+
selecting,
|
|
80
|
+
});
|
|
81
|
+
const { scrollXRef, getScroller, surface, registerHeader, headerWheelRef, headerPanHandlers } = useGridScrollSync(rootRef);
|
|
82
|
+
const total = useMemo(() => groups.reduce((n, g) => n + g.items.length, 0), [groups]);
|
|
83
|
+
const empty = grouped ? groups.length === 0 : total === 0;
|
|
84
|
+
const rail = useGridRailReveal({ rootRef, earned: selecting || !!props.alwaysCheckboxes });
|
|
85
|
+
const batchApi = useGridBatchApi({
|
|
86
|
+
enabled: editingEnabled,
|
|
87
|
+
columns: visibleColumns,
|
|
88
|
+
listConfig,
|
|
89
|
+
rows: flatRows,
|
|
90
|
+
getRowId,
|
|
91
|
+
pendingByRow,
|
|
92
|
+
commitBatch,
|
|
93
|
+
});
|
|
94
|
+
const headerDrag = useGridHeaderDrag({
|
|
95
|
+
columns,
|
|
96
|
+
columnState,
|
|
97
|
+
onColumnStateChange,
|
|
98
|
+
visibleColumnIds: visibleColIds,
|
|
99
|
+
scrollXRef,
|
|
100
|
+
getScroller,
|
|
101
|
+
viewBacked: props.viewBacked,
|
|
102
|
+
});
|
|
103
|
+
const rowRangeFor = (rowKey) => rowSpansMap.get(rowKey);
|
|
104
|
+
const renderRow = (row, index, items, groupKey) => {
|
|
105
|
+
const rowId = getRowId(row);
|
|
106
|
+
const rowKey = gridRowKey(groupKey, rowId);
|
|
107
|
+
const above = index > 0 ? items[index - 1] : null;
|
|
108
|
+
return (_jsx(GridRow, { row: row, id: rowId, rowKey: rowKey, gridTemplate: gridTemplate, columns: visibleColumns, selectable: selectable, selected: sel.isSelected(rowId), selectedAbove: above != null && sel.isSelected(getRowId(above)), selecting: selecting, toggle: sel.toggle, toggleRange: sel.toggleRange, contextMenu: props.contextMenu ?? props.rowMenu, rowClassName: rowClassName, rowHref: rowHref, onOpenRow: onOpenRow, onPrefetchRow: onPrefetchRow, onOpenRelation: props.onOpenRelation, entityIcon: props.entityIcon, commands: props.commands, onRowDelete: onRowDelete, deleteLabel: props.deleteLabel, rowActions: rowActions, rowIcon: showRowIcon ? rowIcon : undefined, frozenCount: frozenCount, frozenLeft: frozenLeft, verticalBorders: verticalBorders, wrapCells: wrapCells, optionColors: optionColors, dateStyles: dateStyles, durationStyles: durationStyles, numberFormats: numberFormats, showTimeOverrides: showTimeOverrides, percentDisplays: percentDisplays, editingEnabled: editingEnabled, listConfig: listConfig, focusedColId: focusedCell?.rowId === rowKey ? focusedCell.columnId : null, editingColId: editingCell?.rowId === rowKey ? editingCell.columnId : null, editSeed: editingCell?.rowId === rowKey ? editSeed : null, onEditorTab: onEditorTab, onEditorEnter: onEditorEnter, pendingByCol: pendingByRow.get(rowId), settlementByCol: settlementByRow.get(rowId), selectValues: selectValuesByColumn, rowRange: rowRangeFor(rowKey), onFocusCell: focusCellSync, onStartEdit: startEditSync, onRefuseEdit: refuseEdit, onExtendCell: onExtendCell, onAddCell: onAddCell, onCommitCell: commitEdit, onCancelEdit: cancelEdit, inActiveRange: inActiveRange, rangeCanClear: rangeCanClear, onRangeCopy: onRangeCopy, onRangeCut: onRangeCut, onRangePaste: onRangePaste, onRangeClear: onRangeClear, onPasteAtCell: onPasteAtCell }, rowKey));
|
|
109
|
+
};
|
|
110
|
+
const header = (inline, checkbox) => (_jsx(GridHeader, { inline: inline, showAddColumn: showAddColumn && !inline, checkbox: checkbox, columns: visibleColumns, columnManager: columnManager, gridTemplate: gridTemplate, minWidth: minWidth, sort: sort, selectValues: selectValuesByColumn, optionColors: optionColors, onOptionColorChange: onOptionColorChange, dateStyles: dateStyles, onDateStyleChange: onDateStyleChange, durationStyles: durationStyles, onDurationStyleChange: onDurationStyleChange, numberFormats: numberFormats, onNumberFormatChange: onNumberFormatChange, showTimeOverrides: showTimeOverrides, onShowTimeChange: onShowTimeChange, percentDisplays: percentDisplays, onPercentDisplayChange: onPercentDisplayChange, columnStateEnabled: !!onColumnStateChange, listConfig: listConfig, groupBy: groupBy, viewBacked: props.viewBacked, formatsWritable: props.formatsWritable, renderAddColumn: props.renderAddColumn, renderColumnMenuRows: props.renderColumnMenuRows, resizingId: resizingId, startResize: startResize, moveResize: moveResize, endResize: endResize, resetColumnWidth: resetColumnWidth, hideColumn: hideColumn, moveColumn: moveColumn, headerDrag: headerDrag, registerHeader: registerHeader, frozenCount: frozenCount, frozenLeft: frozenLeft }));
|
|
111
|
+
const footer = (group) => (_jsx(GridFooter, { group: group, columns: visibleColumns, gridTemplate: gridTemplate, selecting: selecting, aggregates: aggregates, numberFormats: numberFormats, renderAggregate: renderAggregate, onAggregateChange: onAggregateChange, viewBacked: props.viewBacked, frozenCount: frozenCount, frozenLeft: frozenLeft, continuation: props.renderGroupFooter?.(group), defaultCurrency: props.defaultCurrency }));
|
|
112
|
+
const groupCheckbox = (items) => (_jsx(GridHeadCheck, { selecting: selecting, ...groupSelection(items), "aria-label": messages({ key: "views.grid.select-group" }) }));
|
|
113
|
+
return (_jsx(GridTableSurface, { rootRef: rootRef, style: { ...widthVarsStyle, ...scaleVarsStyle }, selecting: selecting, railRootProps: rail.rootProps, onPointerDown: (event) => {
|
|
114
|
+
if (checkDrag.tryArm(event))
|
|
115
|
+
return;
|
|
116
|
+
handleRootPointerDown(event);
|
|
117
|
+
}, onPointerDownCapture: handleRootPointerDownCapture, onClickCapture: (event) => {
|
|
118
|
+
if (checkDrag.consumeDrag()) {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
event.stopPropagation();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
handleRootClickCapture(event);
|
|
124
|
+
}, railProbe: _jsx(GridRailProbe, { probeRef: rail.probeRef }), body: _jsx(GridBody, { empty: empty, emptyState: emptyState, grouped: grouped, groups: groups, rows: flatRows, isMobile: isMobile, selectable: selectable, selecting: selecting, allSelected: sel.allSelected, someSelected: sel.someSelected, selectAll: sel.selectAll, clearSelection: sel.clear, isCollapsed: isCollapsed, countOf: countOf, sort: sort, sortOptions: sortOptions, groupSummary: groupSummary, onToggleGroup: onToggleGroup, onGroupSummaryChange: onGroupSummaryChange, renderGroupLabel: renderGroupLabel, onHideGroup: onHideGroup, figures: groupFigures, countNoun: countNoun, renderHeader: header, renderGroupCheckbox: groupCheckbox, renderRow: renderRow, renderFooter: footer, minWidth: minWidth, surface: surface, headerWheelRef: headerWheelRef, headerPanHandlers: headerPanHandlers }), loadMore: loadMore?.hasMore ? _jsx(LoadMore, { onReveal: loadMore.onReveal, label: loadMore.label }) : undefined, selectionBar: selection?.renderBar(sel, batchApi) }));
|
|
125
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CSSProperties, HTMLAttributes, PointerEventHandler, MouseEventHandler, ReactNode, RefObject } from "react";
|
|
2
|
+
export declare function GridTableSurface({ rootRef, style, selecting, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, selectionBar, }: {
|
|
3
|
+
rootRef: RefObject<HTMLDivElement | null>;
|
|
4
|
+
style: CSSProperties;
|
|
5
|
+
selecting: boolean;
|
|
6
|
+
railRootProps: HTMLAttributes<HTMLDivElement>;
|
|
7
|
+
onPointerDown: PointerEventHandler<HTMLDivElement>;
|
|
8
|
+
/** Marks a press as the grid's own, its portaled popups' included: the click-away reads it. */
|
|
9
|
+
onPointerDownCapture: PointerEventHandler<HTMLDivElement>;
|
|
10
|
+
onClickCapture: MouseEventHandler<HTMLDivElement>;
|
|
11
|
+
railProbe: ReactNode;
|
|
12
|
+
body: ReactNode;
|
|
13
|
+
loadMore?: ReactNode;
|
|
14
|
+
selectionBar?: ReactNode;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cx } from "../../internal/cx.js";
|
|
4
|
+
export function GridTableSurface({ rootRef, style, selecting, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, selectionBar, }) {
|
|
5
|
+
return (_jsxs("div", { ref: rootRef, style: style, className: cx("group/gridtable relative animate-fade-in", selecting && "pb-14"), "data-slot": "vk-grid", ...railRootProps, onPointerDown: onPointerDown, onPointerDownCapture: onPointerDownCapture, onClickCapture: onClickCapture, children: [body, loadMore, selectionBar, railProbe] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function GridTextEditor({ initial, strong, onCommit, onCancel, onTab, onEnter, }: {
|
|
2
|
+
initial: string;
|
|
3
|
+
/** Title columns render medium-weight — match it while editing. */
|
|
4
|
+
strong?: boolean;
|
|
5
|
+
onCommit: (value: string) => void;
|
|
6
|
+
onCancel: () => void;
|
|
7
|
+
/** Commit happened via Tab — move to the next cell in reading order. */
|
|
8
|
+
onTab?: (backwards: boolean) => void;
|
|
9
|
+
/** Commit happened via Enter — advance one row down (Sheets). */
|
|
10
|
+
onEnter?: () => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef } from "react";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
export function GridTextEditor({ initial, strong = false, onCommit, onCancel, onTab, onEnter, }) {
|
|
6
|
+
const inputRef = useRef(null);
|
|
7
|
+
const doneRef = useRef(false);
|
|
8
|
+
useEffect(() => {
|
|
9
|
+
const el = inputRef.current;
|
|
10
|
+
if (!el)
|
|
11
|
+
return;
|
|
12
|
+
el.focus();
|
|
13
|
+
const len = el.value.length;
|
|
14
|
+
el.setSelectionRange(len, len);
|
|
15
|
+
}, []);
|
|
16
|
+
const commit = () => {
|
|
17
|
+
if (doneRef.current)
|
|
18
|
+
return;
|
|
19
|
+
doneRef.current = true;
|
|
20
|
+
onCommit(inputRef.current?.value ?? "");
|
|
21
|
+
};
|
|
22
|
+
return (_jsx("input", { ref: inputRef, defaultValue: initial, "data-slot": "vk-grid-editor", "data-grid-editor": true, onKeyDown: (e) => {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
if (e.key === "Enter") {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
commit();
|
|
27
|
+
onEnter?.();
|
|
28
|
+
}
|
|
29
|
+
else if (e.key === "Escape") {
|
|
30
|
+
doneRef.current = true;
|
|
31
|
+
onCancel();
|
|
32
|
+
}
|
|
33
|
+
else if (e.key === "Tab") {
|
|
34
|
+
e.preventDefault();
|
|
35
|
+
const backwards = e.shiftKey;
|
|
36
|
+
commit();
|
|
37
|
+
onTab?.(backwards);
|
|
38
|
+
}
|
|
39
|
+
}, onBlur: () => commit(), onClick: (e) => e.stopPropagation(), className: cx("h-full w-full min-w-0 select-text bg-transparent text-(length:--vk-text) text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtlest)", strong && "font-medium") }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FieldDefOf, MultipleType, ValueItem } from "@viewkitjs/fields";
|
|
2
|
+
/**
|
|
3
|
+
* The GRID's host around the shared `ValueListEditor`. Anchored, like the name
|
|
4
|
+
* editor: a list of rows does not fit a cell, so it opens in a panel under it
|
|
5
|
+
* while the cell's own values stay on screen. No seed: a key typed on a list
|
|
6
|
+
* cell opens the list as it is (`useGridKeyboard`'s `seedable`).
|
|
7
|
+
*/
|
|
8
|
+
export declare function GridValueListEditor({ field, initial, labels, allowEmpty, onCommit, onCancel, onTab, onEnter, }: {
|
|
9
|
+
field: FieldDefOf<MultipleType>;
|
|
10
|
+
initial: unknown;
|
|
11
|
+
labels: boolean;
|
|
12
|
+
allowEmpty?: boolean;
|
|
13
|
+
onCommit: (payload: ValueItem<unknown>[] | null) => void;
|
|
14
|
+
onCancel: () => void;
|
|
15
|
+
onTab?: (backwards: boolean) => void;
|
|
16
|
+
/** Commit happened via Enter — advance one row down. */
|
|
17
|
+
onEnter?: () => void;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
4
|
+
import { useAnchoredEditSession } from "../../editors/edit-session.js";
|
|
5
|
+
import { ValueListEditor } from "../../editors/ValueListEditor.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
export function GridValueListEditor({ field, initial, labels, allowEmpty = false, onCommit, onCancel, onTab, onEnter, }) {
|
|
8
|
+
const { Popover } = useViews().components;
|
|
9
|
+
const anchorRef = useRef(null);
|
|
10
|
+
const editorRef = useRef(null);
|
|
11
|
+
const viaRef = useRef(null);
|
|
12
|
+
const { open, close } = useAnchoredEditSession({
|
|
13
|
+
editorRef,
|
|
14
|
+
onDone: (resolution) => {
|
|
15
|
+
if (resolution.kind === "commit") {
|
|
16
|
+
onCommit(resolution.payload);
|
|
17
|
+
if (viaRef.current === "enter")
|
|
18
|
+
onEnter?.();
|
|
19
|
+
if (viaRef.current === "tab")
|
|
20
|
+
onTab?.(false);
|
|
21
|
+
if (viaRef.current === "shift-tab")
|
|
22
|
+
onTab?.(true);
|
|
23
|
+
}
|
|
24
|
+
else
|
|
25
|
+
onCancel();
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
const closeVia = (reason) => {
|
|
29
|
+
viaRef.current = reason;
|
|
30
|
+
close(reason);
|
|
31
|
+
};
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(Popover, { open: open, onOpenChange: (next) => {
|
|
33
|
+
if (!next)
|
|
34
|
+
closeVia("outside");
|
|
35
|
+
}, anchor: anchorRef, align: "start", sideOffset: 4, onEscape: () => closeVia("escape"), onOutsidePress: () => closeVia("outside"), initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-96 p-2", children: _jsx(ValueListEditor, { ref: editorRef, field: field, initial: initial, labels: labels, allowEmpty: allowEmpty, onRequestClose: closeVia }) })] }));
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Says when the sticky header right after it is STUCK — `data-stuck="true"`
|
|
3
|
+
* on that header, while it stands below where it would rest (Mihai,
|
|
4
|
+
* 2026-10-05).
|
|
5
|
+
*
|
|
6
|
+
* The header's ground leaves a 2px sliver at its foot see-through
|
|
7
|
+
* (GRID_HEADER_BG): at rest it is where the first row's selection ring draws
|
|
8
|
+
* its top edge. Stuck, rows pass under the header, and through that sliver a
|
|
9
|
+
* row's top showed a pixel or two above the header's line. So the header goes
|
|
10
|
+
* solid while stuck (`data-[stuck=true]:bg-(color:--vk-ground)`) and keeps the sliver
|
|
11
|
+
* at rest, where nothing passes under it.
|
|
12
|
+
*
|
|
13
|
+
* Zero-height and in flow, so it marks exactly where the header would rest;
|
|
14
|
+
* the header is stuck once its top has left that mark.
|
|
15
|
+
*/
|
|
16
|
+
export declare function StuckMarker(): import("react/jsx-runtime").JSX.Element;
|