@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
|
+
import { cellCopyText, serializeClipboardMatrix, } from "../core/clipboard-model.js";
|
|
2
|
+
export { cellClearPrev, cellEditBaseline, cellPrevPayload, rowHoldsCurrency, coercePaste, parseTsvText, } from "../core/clipboard-model.js";
|
|
3
|
+
let clipboard = null;
|
|
4
|
+
export function getGridClipboard() {
|
|
5
|
+
return clipboard;
|
|
6
|
+
}
|
|
7
|
+
export async function copyCell(write, col, baseline, unit) {
|
|
8
|
+
const text = cellCopyText(col, baseline);
|
|
9
|
+
clipboard = { text, value: baseline, type: col.type, unit };
|
|
10
|
+
try {
|
|
11
|
+
await write(text);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
}
|
|
15
|
+
return text;
|
|
16
|
+
}
|
|
17
|
+
export async function copyCells(write, matrix) {
|
|
18
|
+
if (matrix.length === 0 || matrix[0].length === 0)
|
|
19
|
+
return "";
|
|
20
|
+
const text = serializeClipboardMatrix(matrix);
|
|
21
|
+
clipboard = { ...matrix[0][0], text, matrix };
|
|
22
|
+
try {
|
|
23
|
+
await write(text);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
}
|
|
27
|
+
return text;
|
|
28
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { GridCellPos } from "../core/coordinates.js";
|
|
2
|
+
/**
|
|
3
|
+
* True when something inside the cell clips its value across: the ellipsis a `truncate` draws.
|
|
4
|
+
* Only an element that clips counts, and never the cell itself: a focused cell drops its clip and
|
|
5
|
+
* draws its fill handle past its edge, which widens what it scrolls without cutting anything off.
|
|
6
|
+
* An element with no box of its own (an inline span, width 0) counts for nothing. False for no cell.
|
|
7
|
+
*/
|
|
8
|
+
export declare function gridCellCutOff(cell: Element | null): boolean;
|
|
9
|
+
/** The drawn cell at `pos` inside `root` (the grid's frame), or null when the page holds no such
|
|
10
|
+
* row. */
|
|
11
|
+
export declare function findGridCell(root: ParentNode | null, pos: GridCellPos): Element | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function clips(el) {
|
|
2
|
+
const style = getComputedStyle(el);
|
|
3
|
+
if (style.overflowX && style.overflowX !== "visible")
|
|
4
|
+
return true;
|
|
5
|
+
const across = style.overflow.split(" ")[0];
|
|
6
|
+
return !!across && across !== "visible";
|
|
7
|
+
}
|
|
8
|
+
export function gridCellCutOff(cell) {
|
|
9
|
+
if (!cell)
|
|
10
|
+
return false;
|
|
11
|
+
for (const el of cell.querySelectorAll("*")) {
|
|
12
|
+
if (el.clientWidth > 0 && el.scrollWidth > el.clientWidth && clips(el))
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
export function findGridCell(root, pos) {
|
|
18
|
+
const row = root?.querySelector(`[data-row-id="${CSS.escape(pos.rowId)}"]`);
|
|
19
|
+
return row?.querySelector(`[data-col-id="${CSS.escape(pos.columnId)}"]`) ?? null;
|
|
20
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { GridCellOptions } from "../../cells/cell-format.js";
|
|
3
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
4
|
+
export { formatDate, formatNumber } from "../../cells/cell-format.js";
|
|
5
|
+
/**
|
|
6
|
+
* Renders a typed cell, then appends the column's `indicator` if it has one.
|
|
7
|
+
*
|
|
8
|
+
* `indicator` is declared on EVERY column in the schema but used to be read only
|
|
9
|
+
* inside the `title` branch — so it looked generic and was honoured by exactly
|
|
10
|
+
* one type. That gap is why a column needing a per-row adornment (Subscriptions'
|
|
11
|
+
* next-charge urgency) reached for a full custom `render` instead, throwing away
|
|
12
|
+
* the typed renderer's date formatting and hover tooltip to get it.
|
|
13
|
+
*
|
|
14
|
+
* `title` still places its own indicator: its cell has layout rules about where
|
|
15
|
+
* the click target ends, and the adornment has to sit inside them.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderTypedCell<Row>(col: ListColumn<Row>, row: Row, opts?: GridCellOptions): ReactNode;
|
|
18
|
+
/** Renders an `action` column's cell — a centered row of icon buttons. Real
|
|
19
|
+
* `<button>`s so GridRow's click contract treats them as interactive (the row
|
|
20
|
+
* does not open / select on an action click). */
|
|
21
|
+
export declare function renderActionCell<Row>(col: ListColumn<Row>, row: Row): ReactNode;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { GridActionButton } from "./GridRowActions.js";
|
|
4
|
+
import { renderTypedCellValue } from "../../cells/cell-values.js";
|
|
5
|
+
export { formatDate, formatNumber } from "../../cells/cell-format.js";
|
|
6
|
+
export function renderTypedCell(col, row, opts) {
|
|
7
|
+
const cell = renderTypedCellValue(col, row, opts);
|
|
8
|
+
if (col.type === "title")
|
|
9
|
+
return cell;
|
|
10
|
+
const indicator = col.indicator?.(row);
|
|
11
|
+
if (!indicator)
|
|
12
|
+
return cell;
|
|
13
|
+
return (_jsxs("span", { className: "flex h-(--vk-line-h) min-w-0 flex-1 flex-wrap content-start items-center gap-x-1.5 overflow-hidden leading-(--vk-line-h)", children: [_jsx("span", { className: "max-w-full flex-none truncate", children: cell }), indicator] }));
|
|
14
|
+
}
|
|
15
|
+
export function renderActionCell(col, row) {
|
|
16
|
+
if (!col.actions?.length)
|
|
17
|
+
return null;
|
|
18
|
+
return (_jsx("span", { className: "flex items-center justify-center gap-1", children: col.actions.map((a) => (_jsx(GridActionButton, { variant: "bare", label: a.label?.(row), onClick: a.onClick ? () => a.onClick?.(row) : undefined, children: a.icon(row) }, a.id))) }));
|
|
19
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** Empty rail segment — keeps the opaque lane continuous across the header and
|
|
2
|
+
* footer rows, which have no checkbox of their own. `bordered` follows whether
|
|
3
|
+
* that surface's own cells draw a bottom rule: the header's do, the footer's
|
|
4
|
+
* don't. */
|
|
5
|
+
export declare function GridRailSpacer({ selecting, bordered, }: {
|
|
6
|
+
selecting: boolean;
|
|
7
|
+
bordered?: boolean;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
/** Row checkbox — reveals while the row (`group/gridrow`) is hovered. */
|
|
10
|
+
export declare function GridRowCheck({ selecting, checked, revealed, onChange, "aria-label": ariaLabel, }: {
|
|
11
|
+
selecting: boolean;
|
|
12
|
+
checked: boolean;
|
|
13
|
+
revealed: boolean;
|
|
14
|
+
onChange: (next: boolean, shift: boolean) => void;
|
|
15
|
+
"aria-label"?: string;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* Select-all / group checkbox — the SAME rail slot the rows use, mounted as the
|
|
19
|
+
* header's leading track rather than as an overlay beside it.
|
|
20
|
+
*
|
|
21
|
+
* The header sits in the grid's one scroll area with the rows, so its rail slot
|
|
22
|
+
* travels and parks exactly as theirs do. An overlay would be the one piece of
|
|
23
|
+
* leading chrome that didn't move — parked at a fixed x while every row's
|
|
24
|
+
* checkbox slid away from it and stopped somewhere else.
|
|
25
|
+
*/
|
|
26
|
+
export declare function GridHeadCheck({ selecting, allSelected, someSelected, onToggle, "aria-label": ariaLabel, }: {
|
|
27
|
+
selecting: boolean;
|
|
28
|
+
allSelected: boolean;
|
|
29
|
+
someSelected: boolean;
|
|
30
|
+
onToggle: (next: boolean) => void;
|
|
31
|
+
"aria-label"?: string;
|
|
32
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../../provider/context.js";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { gridFrozenBg } from "./GridCellOutline.js";
|
|
6
|
+
import { GRID_GROUND } from "./grid-styles.js";
|
|
7
|
+
import { SelectCheckbox } from "../../selection/SelectCheckbox.js";
|
|
8
|
+
const HOVER_RAISE = {
|
|
9
|
+
row: {
|
|
10
|
+
backing: "group-hover/gridrow:opacity-[max(var(--vk-frozen-on,0),var(--vk-parked,0))]",
|
|
11
|
+
rule: "group-hover/gridrow:opacity-(--vk-parked,0)",
|
|
12
|
+
},
|
|
13
|
+
head: {
|
|
14
|
+
backing: "group-hover/gridhead:opacity-[max(var(--vk-frozen-on,0),var(--vk-parked,0))]",
|
|
15
|
+
rule: "group-hover/gridhead:opacity-(--vk-parked,0)",
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
function RailSlot({ selecting, selected = false, bordered = false, reveal, children, }) {
|
|
19
|
+
return (_jsx("div", { "data-slot": "vk-grid-rail", role: children ? (reveal === "head" ? "columnheader" : "gridcell") : undefined, "aria-colindex": children ? 1 : undefined, "aria-hidden": children ? undefined : true, className: cx("sticky left-(--vk-rail-w) z-10 h-full", "after:pointer-events-none after:absolute after:inset-y-0 after:left-(--vk-frozen-w,0px) after:w-1.5 after:content-['']", "after:bg-linear-to-r after:from-black/15 after:to-transparent dark:after:from-black/60", "after:opacity-[calc(var(--vk-parked,0)*var(--vk-frozen-on,0))] after:transition-opacity after:duration-150"), "data-action-menu": true, onClick: (e) => e.stopPropagation(), children: _jsxs("div", { "data-row-check": selecting ? "" : undefined, className: cx("relative flex h-full w-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] -translate-x-full items-start justify-end", "pr-[calc(var(--vk-rail-gap)+((var(--vk-rail-w)-16px)/2-var(--vk-rail-gap))*var(--vk-parked,0)*(1-var(--vk-frozen-on,0)))]", "transition-[padding-right] duration-150"), children: [_jsx("span", { "aria-hidden": true, className: cx("absolute inset-0", gridFrozenBg(selected), "opacity-(--vk-frozen-on,0) transition-opacity duration-150", reveal && HOVER_RAISE[reveal].backing, "group-data-[rail=on]/gridtable:opacity-100") }), bordered && (_jsx("span", { "aria-hidden": true, className: cx("pointer-events-none absolute inset-x-0 bottom-0 h-px bg-(color:--vk-border-subtle) transition-opacity duration-150", "opacity-[calc(var(--vk-parked,0)*var(--vk-frozen-on,0))]", reveal && HOVER_RAISE[reveal].rule, "group-data-[rail=on]/gridtable:opacity-(--vk-parked,0)") })), children ? (_jsx("span", { "data-row-check": true, className: "relative flex h-full items-center", children: children })) : null] }) }));
|
|
20
|
+
}
|
|
21
|
+
export function GridRailSpacer({ selecting, bordered = false, }) {
|
|
22
|
+
return _jsx(RailSlot, { selecting: selecting, bordered: bordered });
|
|
23
|
+
}
|
|
24
|
+
export function GridRowCheck({ selecting, checked, revealed, onChange, "aria-label": ariaLabel, }) {
|
|
25
|
+
return (_jsx(RailSlot, { selecting: selecting, selected: checked, bordered: true, reveal: "row", children: _jsx(SelectCheckbox, { checked: checked, revealed: revealed, onChange: onChange, "aria-label": ariaLabel, tabIndex: -1, className: cx(GRID_GROUND, "transition-opacity duration-150 group-hover/gridrow:opacity-100 group-data-[rail=on]/gridtable:opacity-100 focus-visible:opacity-100") }) }));
|
|
26
|
+
}
|
|
27
|
+
export function GridHeadCheck({ selecting, allSelected, someSelected, onToggle, "aria-label": ariaLabel, }) {
|
|
28
|
+
const { Checkbox } = useViews().components;
|
|
29
|
+
return (_jsx(RailSlot, { selecting: selecting, bordered: true, reveal: "head", children: _jsx(Checkbox, { checked: allSelected, indeterminate: !allSelected && someSelected, onCheckedChange: (next) => onToggle(next), "aria-label": ariaLabel, tabIndex: -1, partialTone: "brand", className: cx(cx(GRID_GROUND, "transition-opacity duration-150"), selecting || allSelected || someSelected
|
|
30
|
+
? "opacity-100"
|
|
31
|
+
: "opacity-0 group-hover/gridhead:opacity-100 group-data-[rail=on]/gridtable:opacity-100 focus-visible:opacity-100") }) }));
|
|
32
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ComponentType, ReactNode } from "react";
|
|
2
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
3
|
+
import type { ViewsIcons } from "../../provider/icons.js";
|
|
4
|
+
type GridGlyphs = {
|
|
5
|
+
icons: ViewsIcons;
|
|
6
|
+
AppIcon: ComponentType<{
|
|
7
|
+
name: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
}>;
|
|
10
|
+
};
|
|
11
|
+
/** The column's glyph: its explicit `icon` → its binding's glyph → its field's type → a computed
|
|
12
|
+
* column's mark → its list type's → nothing. */
|
|
13
|
+
export declare function gridColumnGlyph<Row>({ icons, AppIcon }: GridGlyphs, col: ListColumn<Row>, className?: string): ReactNode;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
const LIST_TYPE_GLYPHS = {
|
|
4
|
+
title: "text",
|
|
5
|
+
status: "status",
|
|
6
|
+
text: "text",
|
|
7
|
+
number: "number",
|
|
8
|
+
percent: "percent",
|
|
9
|
+
currency: "currency",
|
|
10
|
+
date: "date",
|
|
11
|
+
datetime: "datetime",
|
|
12
|
+
select: "select",
|
|
13
|
+
multiselect: "multiselect",
|
|
14
|
+
boolean: "boolean",
|
|
15
|
+
relation: "relation",
|
|
16
|
+
user: "user",
|
|
17
|
+
url: "url",
|
|
18
|
+
domain: "domain",
|
|
19
|
+
email: "email",
|
|
20
|
+
phone: "phone",
|
|
21
|
+
location: "location",
|
|
22
|
+
name: "name",
|
|
23
|
+
actor: "actor",
|
|
24
|
+
rich_text: "rich_text",
|
|
25
|
+
range: "range",
|
|
26
|
+
};
|
|
27
|
+
export function gridColumnGlyph({ icons, AppIcon }, col, className = "h-3.5 w-3.5 shrink-0 opacity-70") {
|
|
28
|
+
if (col.icon)
|
|
29
|
+
return col.icon;
|
|
30
|
+
if (col.binding?.icon)
|
|
31
|
+
return _jsx(AppIcon, { name: col.binding.icon, className: className });
|
|
32
|
+
if (col.field) {
|
|
33
|
+
const Glyph = icons[col.field.type];
|
|
34
|
+
return _jsx(Glyph, { className: className });
|
|
35
|
+
}
|
|
36
|
+
if (col.custom) {
|
|
37
|
+
const Glyph = icons.computed;
|
|
38
|
+
return _jsx(Glyph, { className: className });
|
|
39
|
+
}
|
|
40
|
+
if (!col.type)
|
|
41
|
+
return null;
|
|
42
|
+
const Glyph = icons[LIST_TYPE_GLYPHS[col.type]];
|
|
43
|
+
return _jsx(Glyph, { className: className });
|
|
44
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export { gridColumnHasEditor, gridEditorKind } from "../../model/column-capabilities.js";
|
|
2
|
+
export { GridTextEditor } from "./GridTextEditor.js";
|
|
3
|
+
export { GridLongTextEditor } from "./GridLongTextEditor.js";
|
|
4
|
+
export { GridSelectEditor } from "./GridSelectEditor.js";
|
|
5
|
+
export { GridChipsEditor } from "./GridChipsEditor.js";
|
|
6
|
+
export { GridNumberEditor } from "./GridNumberEditor.js";
|
|
7
|
+
export { GridRangeEditor } from "./GridRangeEditor.js";
|
|
8
|
+
export { GridDateEditor } from "./GridDateEditor.js";
|
|
9
|
+
export { GridRelationEditor, GridRelationSetEditor } from "./GridRelationEditor.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
export { gridColumnHasEditor, gridEditorKind } from "../../model/column-capabilities.js";
|
|
3
|
+
export { GridTextEditor } from "./GridTextEditor.js";
|
|
4
|
+
export { GridLongTextEditor } from "./GridLongTextEditor.js";
|
|
5
|
+
export { GridSelectEditor } from "./GridSelectEditor.js";
|
|
6
|
+
export { GridChipsEditor } from "./GridChipsEditor.js";
|
|
7
|
+
export { GridNumberEditor } from "./GridNumberEditor.js";
|
|
8
|
+
export { GridRangeEditor } from "./GridRangeEditor.js";
|
|
9
|
+
export { GridDateEditor } from "./GridDateEditor.js";
|
|
10
|
+
export { GridRelationEditor, GridRelationSetEditor } from "./GridRelationEditor.js";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { FieldSettlement } from "@viewkitjs/fields";
|
|
2
|
+
/**
|
|
3
|
+
* One body cell's class string.
|
|
4
|
+
*
|
|
5
|
+
* Extracted from `GridRowCells` because that file is held under the line ceiling
|
|
6
|
+
* and the policy there is split, not raise — and because this is the one part
|
|
7
|
+
* of the cell that is pure: a dozen booleans in, a string out. That makes the
|
|
8
|
+
* geometry testable without rendering a grid.
|
|
9
|
+
*/
|
|
10
|
+
export type GridCellClassState = {
|
|
11
|
+
align?: "left" | "center" | "right";
|
|
12
|
+
/** The title column: an ordinary cell that holds the row-open hotspot (its
|
|
13
|
+
* rendered text), which the cell dresses as a link. */
|
|
14
|
+
isTitle: boolean;
|
|
15
|
+
/** Pinned to the left edge (inside the frozen block). */
|
|
16
|
+
frozen: boolean;
|
|
17
|
+
focused: boolean;
|
|
18
|
+
editing: boolean;
|
|
19
|
+
/** Inside the active multi-cell range. */
|
|
20
|
+
inRange: boolean;
|
|
21
|
+
/** The row is selected (frozen cells repaint the selection tint). */
|
|
22
|
+
selected: boolean;
|
|
23
|
+
/** Last visible column — its right border is always transparent. */
|
|
24
|
+
lastColumn: boolean;
|
|
25
|
+
verticalBorders: boolean;
|
|
26
|
+
/** The value is saved here but its provider has not accepted it yet (spec
|
|
27
|
+
* §11.2) — the one pending state the grid draws, beside `data-settlement`. */
|
|
28
|
+
settlement?: Extract<FieldSettlement, "requested">;
|
|
29
|
+
};
|
|
30
|
+
/** The row-open hotspot inside a title cell, dressed as a link on its own hover. */
|
|
31
|
+
export declare const GRID_TITLE_LINK_CLASS = "**:data-cell-open:underline-offset-2 [&_[data-cell-open]:hover]:text-(color:--vk-fg-brand) [&_[data-cell-open]:hover]:underline";
|
|
32
|
+
/** A ranged cell's tint: it covers the cell and reaches 1px past its trailing edges, bridging the
|
|
33
|
+
* hairlines between cells into one surface. `-z-1` lays it under the cell's value and over the
|
|
34
|
+
* cell's own ground, inside the stacking context every ranged cell is (its z, or sticky). */
|
|
35
|
+
export declare const GRID_RANGE_TINT_CLASS = "pointer-events-none absolute left-0 top-0 -bottom-px -right-px -z-1 bg-(color:--vk-brand-subtlest)";
|
|
36
|
+
export declare function gridCellClassName(state: GridCellClassState): string;
|
|
37
|
+
/** The row's own classes. A SELECTED row hovers brand, not neutral: hover and selected both write
|
|
38
|
+
* background-image, so the neutral tint would replace the selection, and the row would grey out
|
|
39
|
+
* under the pointer exactly where it should feel most active. A doubled brand mix keeps the hover
|
|
40
|
+
* a clear step up in the same colour. The host's class is the row's last word, as it was under the
|
|
41
|
+
* merge: where it paints the row's own ground (Domains' unregistered rows), the selected tint
|
|
42
|
+
* stands aside for it — only that one property conflicts; the hover is an image.
|
|
43
|
+
*
|
|
44
|
+
* The row owns the page gutter (px) — the checkbox reveals inside it at left-0 — so the table's
|
|
45
|
+
* left edge stays aligned with the page content; pl includes --vk-indent (grouped tables shift
|
|
46
|
+
* right as one unit). The hover tint is FLAT and full-bleed, a one-stop background-IMAGE rather
|
|
47
|
+
* than a colour so it layers OVER the selected ground; the same string as GRID_FROZEN_HOVER, so
|
|
48
|
+
* pinned and scrolling cells tint the same. */
|
|
49
|
+
export declare function gridRowClassName(state: {
|
|
50
|
+
selected: boolean;
|
|
51
|
+
selectable: boolean;
|
|
52
|
+
hostClass?: string;
|
|
53
|
+
}): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { ROW_NO_TEXT_SELECT } from "../../selection/row-click.js";
|
|
2
|
+
import { cx } from "../../internal/cx.js";
|
|
3
|
+
import { GRID_CELL_HOVER_RING, GRID_CELL_HOVER_SHADOW, gridFrozenBg } from "./GridCellOutline.js";
|
|
4
|
+
import { GRID_GROUND } from "./grid-styles.js";
|
|
5
|
+
const GRID_CELL_REQUESTED = "italic opacity-80";
|
|
6
|
+
export const GRID_TITLE_LINK_CLASS = "**:data-cell-open:underline-offset-2 [&_[data-cell-open]:hover]:text-(color:--vk-fg-brand) [&_[data-cell-open]:hover]:underline";
|
|
7
|
+
export const GRID_RANGE_TINT_CLASS = "pointer-events-none absolute left-0 top-0 -bottom-px -right-px -z-1 bg-(color:--vk-brand-subtlest)";
|
|
8
|
+
export function gridCellClassName(state) {
|
|
9
|
+
const { focused, editing, inRange, frozen, selected } = state;
|
|
10
|
+
return cx(state.settlement === "requested" && GRID_CELL_REQUESTED, "group/gridcell", "outline-none", "flex min-w-0 border-b border-r border-(color:--vk-border-subtle) px-(--vk-px) text-(length:--vk-text)", "h-(--vk-row-h) items-center whitespace-nowrap", "scroll-mt-(--vk-scroll-mt)", "scroll-ml-[calc(var(--vk-rail-w)+var(--vk-frozen-w,0px))]", (!state.verticalBorders || state.lastColumn) && "border-r-transparent", state.align === "right" && "justify-end text-right tabular-nums", state.align === "center" && "justify-center text-center", frozen ? "sticky" : "relative", focused || editing || inRange ? "overflow-visible" : "overflow-hidden", frozen
|
|
11
|
+
? focused || editing
|
|
12
|
+
? "z-9"
|
|
13
|
+
: inRange
|
|
14
|
+
? "z-[calc(8*var(--vk-scrolled,0))]"
|
|
15
|
+
: "z-[calc(7*var(--vk-scrolled,0))]"
|
|
16
|
+
: focused || editing
|
|
17
|
+
? "z-5"
|
|
18
|
+
: inRange
|
|
19
|
+
? "z-4"
|
|
20
|
+
: undefined, frozen && gridFrozenBg(selected), editing && GRID_GROUND, !focused &&
|
|
21
|
+
!editing &&
|
|
22
|
+
!inRange &&
|
|
23
|
+
!state.isTitle &&
|
|
24
|
+
cx(GRID_CELL_HOVER_SHADOW, GRID_CELL_HOVER_RING), state.isTitle && GRID_TITLE_LINK_CLASS);
|
|
25
|
+
}
|
|
26
|
+
export function gridRowClassName(state) {
|
|
27
|
+
const { selected, selectable, hostClass } = state;
|
|
28
|
+
const hostPaintsGround = hostClass != null && /(?:^|\s)bg-/.test(hostClass);
|
|
29
|
+
return cx("group/gridrow relative grid grid-cols-(--vk-cols) cursor-pointer pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] pr-(--vk-gutter,0px)", selectable && ROW_NO_TEXT_SELECT, selected
|
|
30
|
+
? "hover:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent))]"
|
|
31
|
+
: "hover:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]", selected && !hostPaintsGround && "bg-(color:--vk-brand-subtlest)", hostClass);
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An email, phone, url or domain drawn in a grid cell (`hostOwnsPlainClick`): a link that is part of its cell, not a
|
|
3
|
+
* control beside it. A plain click on it is a click on the cell (it selects, a second click edits, and the link is
|
|
4
|
+
* not followed); a ⌘- or Ctrl-click follows it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const GRID_CELL_LINK = "[data-cell-link]";
|
|
7
|
+
/**
|
|
8
|
+
* The control a press landed on, which handles the press itself: the nearest real control, unless that is one of
|
|
9
|
+
* the cell's own links (`GRID_CELL_LINK`), which the cell handles as itself. Null when the press is the cell's.
|
|
10
|
+
*/
|
|
11
|
+
export declare function gridControlAt(target: HTMLElement): Element | null;
|
|
12
|
+
/** The cell link a press landed on, or null. */
|
|
13
|
+
export declare function gridCellLinkAt(target: HTMLElement): Element | null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ROW_INTERACTIVE_SELECTOR } from "../../selection/row-click.js";
|
|
2
|
+
export const GRID_CELL_LINK = "[data-cell-link]";
|
|
3
|
+
export function gridControlAt(target) {
|
|
4
|
+
const hit = target.closest(ROW_INTERACTIVE_SELECTOR);
|
|
5
|
+
return hit && !hit.matches(GRID_CELL_LINK) ? hit : null;
|
|
6
|
+
}
|
|
7
|
+
export function gridCellLinkAt(target) {
|
|
8
|
+
return target.closest(GRID_CELL_LINK);
|
|
9
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ReactNode, type RefObject } from "react";
|
|
2
|
+
import type { CloseReason, CloseResolution } from "@viewkitjs/fields";
|
|
3
|
+
import { type EditSession } from "../../editors/edit-session.js";
|
|
4
|
+
/** The gap a grid editor waits after its sheet closes before it writes: a sheet slides away for
|
|
5
|
+
* about half a second, and the popover's 160 ms would unmount it mid-slide. */
|
|
6
|
+
export declare const GRID_SHEET_EXIT_MS = 500;
|
|
7
|
+
type Handle<P> = {
|
|
8
|
+
resolveClose: (reason: CloseReason) => CloseResolution<P>;
|
|
9
|
+
};
|
|
10
|
+
export type GridEditSessionArgs<P> = {
|
|
11
|
+
editorRef: RefObject<Handle<P> | null>;
|
|
12
|
+
/** Reshapes a commit before it is judged and written (a day field's timestamp trimmed to its day). */
|
|
13
|
+
mapPayload?: (payload: P) => unknown;
|
|
14
|
+
/** A type-in that stays in the cell on a desktop: its write lands at once, before the focus moves,
|
|
15
|
+
* so a click on another cell finds it done. Elsewhere the write waits for the exit. */
|
|
16
|
+
inPlace?: boolean;
|
|
17
|
+
/** The grid's own judgement of the value it is about to write: its reason when the grid would
|
|
18
|
+
* refuse it, or null. A refused value keeps the editor open with that reason. */
|
|
19
|
+
refuse?: (payload: unknown) => string | null;
|
|
20
|
+
onCommit: (payload: unknown) => void;
|
|
21
|
+
onCancel: () => void;
|
|
22
|
+
onTab?: (backwards: boolean) => void;
|
|
23
|
+
onEnter?: () => void;
|
|
24
|
+
};
|
|
25
|
+
export type GridEditSession = {
|
|
26
|
+
/** For `EditorPanel`: its own closes (the popover's dismissals, the sheet's ✕ and ✓) move no focus. */
|
|
27
|
+
session: EditSession;
|
|
28
|
+
/** For the editor's `onRequestClose`: Enter and Tab move the focus after the write, and in the
|
|
29
|
+
* sheet a blur is no close (tapping ✕ or ✓ blurs the box first). */
|
|
30
|
+
close: (reason: CloseReason) => void;
|
|
31
|
+
/** The edit opened in the sheet: the screen was not a desktop when it opened. Read once, as the
|
|
32
|
+
* panel reads it, so the gap matches the panel the edit opened in. */
|
|
33
|
+
sheet: boolean;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Runs one grid edit through the shared session, in its admitted mode. A close asks the editor for
|
|
37
|
+
* its answer (Escape is always a discard); a commit the grid would refuse stays open with its reason.
|
|
38
|
+
* An accepted answer is written at once by an in-place type-in on a desktop, and after the exit gap
|
|
39
|
+
* otherwise, so the popover or the sheet plays out before the cell repaints; on a desktop, Enter or
|
|
40
|
+
* Tab moves the focus at once all the same, and a key in the gap writes the answer first. Left mid-exit (the cell
|
|
41
|
+
* unmounted first), the answer is still written, and the focus stays where the person put it. Left
|
|
42
|
+
* while a refusal stands (another cell clicked), nothing is written and the reason is said in a toast,
|
|
43
|
+
* as the grid says every refusal it can't show in an editor.
|
|
44
|
+
*/
|
|
45
|
+
export declare function useGridEditSession<P>(args: GridEditSessionArgs<P>): GridEditSession;
|
|
46
|
+
/**
|
|
47
|
+
* The value of a cell whose type-in is open: hidden where the editor stands in the cell (a desktop),
|
|
48
|
+
* drawn where it opened in the sheet (a phone), so the row behind the sheet still says what is being
|
|
49
|
+
* changed. Mounted only in the editing cell, and read once, at open, as the session and the panel
|
|
50
|
+
* read it, so all three agree on where the edit opened.
|
|
51
|
+
*/
|
|
52
|
+
export declare function GridValueUnderEditor({ children }: {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}): ReactNode;
|
|
55
|
+
/** Where a line hung under a type-in's cell sits: from the cell's left, or ending at its right where the left would run
|
|
56
|
+
* out of sight (`useKeepInside`). */
|
|
57
|
+
export declare const UNDER_CELL_CLASS = "absolute left-0 top-full z-90 mt-1 whitespace-nowrap rounded-md border border-(color:--vk-border) bg-(color:--vk-overlay) px-2 py-1 shadow-sm data-[side=end]:left-auto data-[side=end]:right-0";
|
|
58
|
+
/** A type-in's refusal, drawn under the cell it is typed in: in place there is no panel to hold it,
|
|
59
|
+
* and the editing cell drops its clip, so it hangs below the box. */
|
|
60
|
+
export declare function GridRefusal({ reason }: {
|
|
61
|
+
reason: string | null;
|
|
62
|
+
}): ReactNode;
|
|
63
|
+
export {};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useAnchoredEditSession } from "../../editors/edit-session.js";
|
|
5
|
+
import { useKeepInside } from "../../editors/keep-inside.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
import { useDesktop } from "../../provider/desktop.js";
|
|
8
|
+
export const GRID_SHEET_EXIT_MS = 500;
|
|
9
|
+
export function useGridEditSession(args) {
|
|
10
|
+
const { editorRef, mapPayload, inPlace = false } = args;
|
|
11
|
+
const desktop = useDesktop();
|
|
12
|
+
const { ports } = useViews();
|
|
13
|
+
const [sheet] = useState(!desktop);
|
|
14
|
+
const latest = useRef(args);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
latest.current = args;
|
|
17
|
+
});
|
|
18
|
+
const viaRef = useRef(null);
|
|
19
|
+
const keptRef = useRef(null);
|
|
20
|
+
const refusedRef = useRef(null);
|
|
21
|
+
const movedRef = useRef(false);
|
|
22
|
+
const flushRef = useRef(null);
|
|
23
|
+
const stopFlush = () => {
|
|
24
|
+
if (flushRef.current)
|
|
25
|
+
document.removeEventListener("keydown", flushRef.current, true);
|
|
26
|
+
flushRef.current = null;
|
|
27
|
+
};
|
|
28
|
+
const move = () => {
|
|
29
|
+
const { onTab, onEnter } = latest.current;
|
|
30
|
+
if (viaRef.current === "enter")
|
|
31
|
+
onEnter?.();
|
|
32
|
+
if (viaRef.current === "tab")
|
|
33
|
+
onTab?.(false);
|
|
34
|
+
if (viaRef.current === "shift-tab")
|
|
35
|
+
onTab?.(true);
|
|
36
|
+
};
|
|
37
|
+
const write = (answer, moveFocus) => {
|
|
38
|
+
keptRef.current = null;
|
|
39
|
+
stopFlush();
|
|
40
|
+
const { onCommit, onCancel } = latest.current;
|
|
41
|
+
if (answer.kind === "commit")
|
|
42
|
+
onCommit(answer.payload);
|
|
43
|
+
else
|
|
44
|
+
onCancel();
|
|
45
|
+
if (moveFocus && !movedRef.current)
|
|
46
|
+
move();
|
|
47
|
+
};
|
|
48
|
+
const keep = (answer) => {
|
|
49
|
+
keptRef.current = answer;
|
|
50
|
+
if (sheet || (viaRef.current !== "enter" && viaRef.current !== "tab" && viaRef.current !== "shift-tab"))
|
|
51
|
+
return;
|
|
52
|
+
movedRef.current = true;
|
|
53
|
+
move();
|
|
54
|
+
const flush = () => {
|
|
55
|
+
if (keptRef.current)
|
|
56
|
+
write(keptRef.current, false);
|
|
57
|
+
else
|
|
58
|
+
stopFlush();
|
|
59
|
+
};
|
|
60
|
+
flushRef.current = flush;
|
|
61
|
+
document.addEventListener("keydown", flush, true);
|
|
62
|
+
};
|
|
63
|
+
const session = useAnchoredEditSession({
|
|
64
|
+
editorRef,
|
|
65
|
+
mapPayload,
|
|
66
|
+
exitMs: sheet ? GRID_SHEET_EXIT_MS : undefined,
|
|
67
|
+
onAttempt: (answer) => {
|
|
68
|
+
const reason = answer.kind === "commit" ? (latest.current.refuse?.(answer.payload) ?? null) : null;
|
|
69
|
+
refusedRef.current = reason;
|
|
70
|
+
if (reason !== null)
|
|
71
|
+
return { accepted: false, reason };
|
|
72
|
+
if (inPlace && !sheet)
|
|
73
|
+
write(answer, true);
|
|
74
|
+
else
|
|
75
|
+
keep(answer);
|
|
76
|
+
return { accepted: true };
|
|
77
|
+
},
|
|
78
|
+
onClose: () => {
|
|
79
|
+
if (keptRef.current)
|
|
80
|
+
write(keptRef.current, true);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
useEffect(() => () => {
|
|
84
|
+
if (keptRef.current)
|
|
85
|
+
write(keptRef.current, false);
|
|
86
|
+
else if (refusedRef.current)
|
|
87
|
+
ports.toast.error(refusedRef.current);
|
|
88
|
+
stopFlush();
|
|
89
|
+
}, []);
|
|
90
|
+
const close = (reason) => {
|
|
91
|
+
if (sheet && reason === "blur")
|
|
92
|
+
return;
|
|
93
|
+
viaRef.current = reason;
|
|
94
|
+
session.close(reason);
|
|
95
|
+
};
|
|
96
|
+
const closeFromPanel = (reason) => {
|
|
97
|
+
if (session.open)
|
|
98
|
+
viaRef.current = null;
|
|
99
|
+
session.close(reason);
|
|
100
|
+
};
|
|
101
|
+
return { session: { ...session, close: closeFromPanel }, close, sheet };
|
|
102
|
+
}
|
|
103
|
+
export function GridValueUnderEditor({ children }) {
|
|
104
|
+
const desktop = useDesktop();
|
|
105
|
+
const [sheet] = useState(!desktop);
|
|
106
|
+
return sheet ? children : null;
|
|
107
|
+
}
|
|
108
|
+
export const UNDER_CELL_CLASS = "absolute left-0 top-full z-90 mt-1 whitespace-nowrap rounded-md border border-(color:--vk-border) bg-(color:--vk-overlay) px-2 py-1 shadow-sm data-[side=end]:left-auto data-[side=end]:right-0";
|
|
109
|
+
export function GridRefusal({ reason }) {
|
|
110
|
+
if (!reason)
|
|
111
|
+
return null;
|
|
112
|
+
return _jsx(Refusal, { reason: reason });
|
|
113
|
+
}
|
|
114
|
+
function Refusal({ reason }) {
|
|
115
|
+
const ref = useRef(null);
|
|
116
|
+
useKeepInside(ref);
|
|
117
|
+
return (_jsx("p", { ref: ref, role: "alert", "data-slot": "vk-editor-refusal", className: `${UNDER_CELL_CLASS} text-xs text-(color:--vk-danger)`, children: reason }));
|
|
118
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type PointerEvent as ReactPointerEvent } from "react";
|
|
2
|
+
import type { ListCellAction } from "../../model/column-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* WHERE THE POINTER IS, for the two things a row draws only there: the name's
|
|
5
|
+
* actions (on the row under the pointer) and a pick-list's ▾ (on the cell under
|
|
6
|
+
* it). Every other row draws neither, so a table of thousands of rows carries
|
|
7
|
+
* one lane and one ▾, not one per row and per cell.
|
|
8
|
+
*
|
|
9
|
+
* One store per table. A row's pointer handlers write `{ rowKey, colId }`; the
|
|
10
|
+
* lane and the ▾ each subscribe with a selector that answers a boolean, so a
|
|
11
|
+
* pointer move redraws only the lane or ▾ whose answer changed, never a row.
|
|
12
|
+
* Without a store (a row drawn outside a table) nothing is drawn by hover.
|
|
13
|
+
*/
|
|
14
|
+
export type GridHoverTarget = {
|
|
15
|
+
rowKey: string;
|
|
16
|
+
colId: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type GridHoverStore = {
|
|
19
|
+
get(): GridHoverTarget | null;
|
|
20
|
+
set(target: GridHoverTarget | null): void;
|
|
21
|
+
subscribe(listener: () => void): () => void;
|
|
22
|
+
};
|
|
23
|
+
export declare function createGridHoverStore(): GridHoverStore;
|
|
24
|
+
export declare const GridHoverContext: import("react").Context<GridHoverStore | null>;
|
|
25
|
+
/** Whether the pointer is over this row. */
|
|
26
|
+
export declare function useGridRowHovered(rowKey: string): boolean;
|
|
27
|
+
/** Whether the pointer is over this cell. */
|
|
28
|
+
export declare function useGridCellHovered(rowKey: string, colId: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The row's pointer handlers. A touch pointer names nothing: a tap is not a
|
|
31
|
+
* hover, and a phone draws neither copy. An event from a portalled child (a
|
|
32
|
+
* picker drawn into the body) bubbles through the row in React but is not over
|
|
33
|
+
* it on screen, so it clears the row instead of naming it.
|
|
34
|
+
*/
|
|
35
|
+
export declare function useGridRowHoverHandlers(rowKey: string): {
|
|
36
|
+
onPointerOver(event: ReactPointerEvent<HTMLElement>): void;
|
|
37
|
+
onPointerLeave(event: ReactPointerEvent<HTMLElement>): void;
|
|
38
|
+
};
|
|
39
|
+
/** The name's action lane, drawn only on the row under the pointer. */
|
|
40
|
+
export declare function GridRowHoverActions<Row>({ rowKey, row, selected, actions, }: {
|
|
41
|
+
rowKey: string;
|
|
42
|
+
row: Row;
|
|
43
|
+
selected: boolean;
|
|
44
|
+
actions: ListCellAction<Row>[];
|
|
45
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
46
|
+
/**
|
|
47
|
+
* A pick-list's ▾: the cue that the value is a choice, and its one-click
|
|
48
|
+
* opener. A real button (the row's click contract lets real controls win), so
|
|
49
|
+
* clicking it opens the picker directly, with no select-first step. Drawn on the
|
|
50
|
+
* cell under the pointer, and on the cell whose picker is open, where it flips
|
|
51
|
+
* up as a native select does; clicking it then closes the picker (the click
|
|
52
|
+
* lands during the exit animation and can't reopen). Never drawn on a phone,
|
|
53
|
+
* where a tap selects the cell and a second opens its editor in a sheet.
|
|
54
|
+
*/
|
|
55
|
+
export declare function GridPickerCaret({ rowKey, colId, editing, onOpen, }: {
|
|
56
|
+
rowKey: string;
|
|
57
|
+
colId: string;
|
|
58
|
+
editing: boolean;
|
|
59
|
+
onOpen: () => void;
|
|
60
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|