@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,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { numberEditDecimals } from "../../fields/number-edit.js";
|
|
5
|
+
import { isIntegerField, isMultipleType, isNameValue, isRangeValue, rangeDecimals, relationIdOf } from "@viewkitjs/fields";
|
|
6
|
+
import { GridNameEditor } from "./GridNameEditor.js";
|
|
7
|
+
import { GridValueListEditor } from "./GridValueListEditor.js";
|
|
8
|
+
import { cellPrevPayload } from "./cell-clipboard.js";
|
|
9
|
+
import { GridChipsEditor, GridDateEditor, GridLongTextEditor, GridNumberEditor, GridRangeEditor, GridRelationEditor, GridSelectEditor, GridTextEditor, } from "./editors.js";
|
|
10
|
+
import { isLongTextColumn } from "../../model/column-inspect.js";
|
|
11
|
+
import { gridRelationSource } from "../../model/column-types.js";
|
|
12
|
+
export function GridCellInlineEditor({ ctx }) {
|
|
13
|
+
const { row, rowId, col, baseline, onCommitCell, onCancel, onTab, onEnter } = ctx;
|
|
14
|
+
if (ctx.editorKind === "number") {
|
|
15
|
+
const integer = col.field ? isIntegerField(col.field) : false;
|
|
16
|
+
const fallback = col.field ? numberEditDecimals(col.field) : (col.format?.decimals ?? 2);
|
|
17
|
+
const durationUnit = col.format?.style === "duration" ? (col.format.unit ?? "ms") : undefined;
|
|
18
|
+
return (_jsx(GridNumberEditor, { initial: typeof baseline === "number" ? baseline : Number.NaN, seed: ctx.editSeed ?? undefined, unit: col.editUnit?.value(row), unitOptions: col.editUnit?.options, decimals: integer ? 0 : (ctx.decimals ?? fallback), durationUnit: durationUnit, allowEmpty: !!col.clearable, unitLeft: col.align === "right", onCommit: (payload) => onCommitCell(row, rowId, col.id, cellPrevPayload(col, baseline, col.editUnit?.value(row)), payload, { overlay: false }), onCancel: onCancel, onTab: onTab, onEnter: onEnter }));
|
|
19
|
+
}
|
|
20
|
+
if (ctx.editorKind === "range") {
|
|
21
|
+
const def = col.field?.type === "range" ? col.field : undefined;
|
|
22
|
+
return (_jsx(GridRangeEditor, { initial: isRangeValue(baseline) ? baseline : null, seed: ctx.editSeed ?? undefined, decimals: def ? rangeDecimals(def) : 0, allowEmpty: !!col.clearable, suffix: def?.of === "percent" ? "%" : def?.of === "currency" ? def.code?.fixed : undefined, onCommit: (payload) => onCommitCell(row, rowId, col.id, baseline, payload, { overlay: false }), onCancel: onCancel, onTab: onTab, onEnter: onEnter }));
|
|
23
|
+
}
|
|
24
|
+
if (ctx.editorKind === "text" && !isLongTextColumn(col)) {
|
|
25
|
+
return (_jsx(GridTextEditor, { initial: ctx.editSeed ?? String(baseline ?? ""), strong: col.type === "title", onCommit: (value) => onCommitCell(row, rowId, col.id, String(baseline ?? ""), value), onCancel: onCancel, onTab: onTab, onEnter: onEnter }));
|
|
26
|
+
}
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
export function GridCellAnchoredEditor({ ctx, }) {
|
|
30
|
+
const { row, rowId, col, baseline, onCommitCell, onCancel } = ctx;
|
|
31
|
+
const relationSource = useMemo(() => gridRelationSource(col, ctx.entityIcon), [col, ctx.entityIcon]);
|
|
32
|
+
if (ctx.editorKind === "text" && isLongTextColumn(col)) {
|
|
33
|
+
return (_jsx(GridLongTextEditor, { initial: String(baseline ?? ""), seed: ctx.editSeed ?? undefined, readOnly: ctx.readOnly, markdown: col.type === "rich_text", onCommit: (value) => onCommitCell(row, rowId, col.id, String(baseline ?? ""), value), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
34
|
+
}
|
|
35
|
+
if (ctx.editorKind === "select") {
|
|
36
|
+
return (_jsx(GridSelectEditor, { column: col, values: ctx.selectValues ?? (col.options ?? []).map((o) => o.value), current: String(baseline ?? ""), optionColors: ctx.optionColors, onCommit: (value) => onCommitCell(row, rowId, col.id, String(baseline ?? ""), value), onCancel: onCancel }));
|
|
37
|
+
}
|
|
38
|
+
if (ctx.editorKind === "chips") {
|
|
39
|
+
const current = Array.isArray(baseline) ? baseline.map(String) : [];
|
|
40
|
+
return (_jsx(GridChipsEditor, { column: col, values: current, suggestions: ctx.selectValues ?? (col.options ?? []).map((option) => option.value), optionColors: ctx.optionColors, onCommit: (next) => onCommitCell(row, rowId, col.id, current, next), onCancel: onCancel }));
|
|
41
|
+
}
|
|
42
|
+
if (ctx.editorKind === "relation") {
|
|
43
|
+
return (_jsx(GridRelationEditor, { candidates: relationSource, current: relationIdOf(baseline), clearable: !!col.clearable, onCommit: (id) => onCommitCell(row, rowId, col.id, relationIdOf(baseline), id, { overlay: false }), onCancel: onCancel }));
|
|
44
|
+
}
|
|
45
|
+
if (ctx.editorKind === "name") {
|
|
46
|
+
return (_jsx(GridNameEditor, { initial: isNameValue(baseline) ? baseline : null, seed: ctx.editSeed ?? undefined, allowEmpty: !!col.clearable, onCommit: (payload) => onCommitCell(row, rowId, col.id, baseline, payload, { overlay: false }), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
47
|
+
}
|
|
48
|
+
if (ctx.editorKind === "values" && col.field && isMultipleType(col.field.type)) {
|
|
49
|
+
return (_jsx(GridValueListEditor, { field: col.field, initial: baseline, labels: col.labels !== false, allowEmpty: !!col.clearable, onCommit: (payload) => onCommitCell(row, rowId, col.id, baseline, payload, { overlay: false }), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
50
|
+
}
|
|
51
|
+
if (ctx.editorKind === "date") {
|
|
52
|
+
return (_jsx(GridDateEditor, { initial: String(baseline ?? "") || undefined, dayOnly: col.field?.type === "date", onCommit: (ymd) => onCommitCell(row, rowId, col.id, cellPrevPayload(col, baseline), ymd, { overlay: false }), onCancel: onCancel }));
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** A frozen cell's paint for its row's state: the ground and the row's hover, or, on a selected
|
|
2
|
+
* row, the ground with the selection tint and its own hover. One answer per state, so no class has
|
|
3
|
+
* to beat another (`cx` joins, it does not merge). */
|
|
4
|
+
export declare function gridFrozenBg(selected: boolean): string;
|
|
5
|
+
/**
|
|
6
|
+
* NOTE: the frozen block has NO edge treatment on ANY surface — header, rows and
|
|
7
|
+
* footer all end flat, and a frozen cell renders exactly like an unfrozen one.
|
|
8
|
+
* Nothing advertises that a column is pinned.
|
|
9
|
+
*
|
|
10
|
+
* The header used to fade its last frozen cell out over 72px (a mask, so the
|
|
11
|
+
* cell's whole output ramped down together — background, hover tint, border and
|
|
12
|
+
* label). It was removed: rows and footer were always flat, so the soft edge
|
|
13
|
+
* made the header the odd one out, and the mask took the resize hairline with it
|
|
14
|
+
* (alpha ~0 at the cell's right edge, where the handle lives).
|
|
15
|
+
*
|
|
16
|
+
* Rows had already rejected the same idea for their own reason: a mask fades the
|
|
17
|
+
* row's `border-b` and hover tint too, leaving a notch in every horizontal rule
|
|
18
|
+
* and a pale patch in the highlight at the Name column's edge — multiplied by
|
|
19
|
+
* the row count.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* The freeze boundary — ONE shadow cast by the pinned block over the columns
|
|
23
|
+
* sliding under it.
|
|
24
|
+
*
|
|
25
|
+
* A shadow rather than a rule, because the boundary is a DEPTH statement: the
|
|
26
|
+
* pinned columns are floating above the ones passing beneath, and that is
|
|
27
|
+
* exactly what the eye reads from a cast shadow. A 1px line said "divider",
|
|
28
|
+
* which is the one thing every other column edge already says.
|
|
29
|
+
*
|
|
30
|
+
* ONE PER SURFACE, NOT ONE PER CELL. This started as a `box-shadow` on the last
|
|
31
|
+
* frozen cell, which is wrong at the first glance you give it: every row casts
|
|
32
|
+
* its own, so the band breaks at every row boundary and reads as a stack of
|
|
33
|
+
* short shadows rather than one edge. A table has ONE lit edge. So it lives
|
|
34
|
+
* outside the scrolled content — an overlay spanning the full height of its
|
|
35
|
+
* surface — and the rows know nothing about it.
|
|
36
|
+
*
|
|
37
|
+
* Its x is a fixed viewport position, which is what makes this work at all: the
|
|
38
|
+
* whole point of freezing is that the boundary does not move. So the overlay
|
|
39
|
+
* sits OUTSIDE the scroller and needs no sticky positioning, no transform, and
|
|
40
|
+
* no per-frame JS — the same `--vk-frozen-w` the layout already publishes puts
|
|
41
|
+
* it exactly where the block ends, and a live column resize re-lays it for free.
|
|
42
|
+
*
|
|
43
|
+
* Short and strong, not wide and soft: ~8px of travel, so it hugs the edge
|
|
44
|
+
* instead of smearing across the next column, with the alpha carrying the
|
|
45
|
+
* weight. A long faint gradient reads as a rendering artefact at this size.
|
|
46
|
+
* Alpha is roughly doubled in dark mode — the same asymmetry
|
|
47
|
+
* GRID_CELL_HOVER_SHADOW uses, because a shadow that reads on white disappears
|
|
48
|
+
* on a dark surface, where it is nearly the only depth cue available.
|
|
49
|
+
*
|
|
50
|
+
* Visible only when there is something to explain, via two flags multiplied
|
|
51
|
+
* together in the opacity:
|
|
52
|
+
* - `--vk-parked` (0/1, from the scroll sync) — the block has REACHED its
|
|
53
|
+
* stop. Not `--vk-scrolled`, which is the weaker "has moved at all": this
|
|
54
|
+
* band is drawn at the parked x, but the block travels for the first ~24px of
|
|
55
|
+
* scroll before it gets there. Gated on the weaker flag, the shadow appeared
|
|
56
|
+
* immediately and hung in open space while the title column was still sliding
|
|
57
|
+
* toward it. The two flags share a threshold with the block's own sticky
|
|
58
|
+
* stop, so on this one the band and the column's edge arrive together.
|
|
59
|
+
* - `--vk-frozen-on` (0/1, from the column layout) — with the freeze pref off
|
|
60
|
+
* or no title column there is no block, and the band would be a seam between
|
|
61
|
+
* two perfectly ordinary columns.
|
|
62
|
+
* Both are CSS vars rather than props on purpose: neither one re-renders a row.
|
|
63
|
+
*/
|
|
64
|
+
export declare function GridFrozenShadow(): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare const GRID_CELL_HOVER_SHADOW = "hover:shadow-[0_1px_2px_rgb(0_0_0/0.05)] dark:hover:shadow-[0_1px_2px_rgb(0_0_0/0.22)]";
|
|
66
|
+
export declare function GridCellOutline({ tone, editing, }: {
|
|
67
|
+
tone: "focus" | "hover";
|
|
68
|
+
/** `focus` only: lifts the cell with a drop shadow to read as a live input. */
|
|
69
|
+
editing?: boolean;
|
|
70
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cx } from "../../internal/cx.js";
|
|
3
|
+
import { GRID_GROUND } from "./grid-styles.js";
|
|
4
|
+
const GRID_FROZEN_HOVER = "group-hover/gridrow:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]";
|
|
5
|
+
const GRID_FROZEN_BG_SELECTED = "bg-[linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]";
|
|
6
|
+
const GRID_FROZEN_BG_SELECTED_HOVER = "group-hover/gridrow:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent)),linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]";
|
|
7
|
+
export function gridFrozenBg(selected) {
|
|
8
|
+
return selected
|
|
9
|
+
? cx(GRID_GROUND, GRID_FROZEN_BG_SELECTED, GRID_FROZEN_BG_SELECTED_HOVER)
|
|
10
|
+
: cx(GRID_GROUND, GRID_FROZEN_HOVER);
|
|
11
|
+
}
|
|
12
|
+
export function GridFrozenShadow() {
|
|
13
|
+
return (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0 z-8 w-1.5 bg-linear-to-r from-black/15 to-transparent opacity-[calc(var(--vk-parked,0)*var(--vk-frozen-on,0))] transition-opacity duration-150 dark:from-black/60", style: { left: "calc(var(--vk-rail-w) + var(--vk-frozen-w,0px))" } }));
|
|
14
|
+
}
|
|
15
|
+
export const GRID_CELL_HOVER_SHADOW = "hover:shadow-[0_1px_2px_rgb(0_0_0/0.05)] dark:hover:shadow-[0_1px_2px_rgb(0_0_0/0.22)]";
|
|
16
|
+
export function GridCellOutline({ tone, editing = false, }) {
|
|
17
|
+
if (tone === "hover") {
|
|
18
|
+
return (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 z-1 rounded-sm border border-(color:--vk-border-bold) opacity-0 group-hover/gridcell:opacity-100" }));
|
|
19
|
+
}
|
|
20
|
+
return (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: cx("pointer-events-none absolute inset-0 z-1 rounded-sm border", editing ? "border-(color:--vk-border-brand)" : "border-(color:--vk-fg-subtle) group-hover/gridcell:border-(color:--vk-border-brand)", editing && "shadow-lg shadow-black/20 dark:shadow-black/50") }));
|
|
21
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* The GRID's host around the shared `ChipsEditor` (`@viewkitjs/views/editors/chips`) —
|
|
4
|
+
* the set-editing panel is one component across every surface; this host owns
|
|
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
|
+
* Telling Escape from an outside click matters more here than anywhere else,
|
|
9
|
+
* because the two mean OPPOSITE things for a set: Escape discards the session,
|
|
10
|
+
* an outside click keeps what you built. Radix funnels both into one
|
|
11
|
+
* `onOpenChange`, so they are caught by the content's own handlers first.
|
|
12
|
+
*/
|
|
13
|
+
export declare function GridChipsEditor<Row>({ column, values, suggestions, optionColors, onCommit, onCancel, }: {
|
|
14
|
+
/** Read for its declared `options` — the labels and colours the cell uses. */
|
|
15
|
+
column: ListColumn<Row>;
|
|
16
|
+
/** The cell's current values. */
|
|
17
|
+
values: string[];
|
|
18
|
+
/** What this column holds on screen, from `deriveGridSelectValues`. An open
|
|
19
|
+
* field's values the list's source answers come first (`useOpenValues`), as
|
|
20
|
+
* the Filter panel offers them, so a value you can set is one you can then
|
|
21
|
+
* filter for. */
|
|
22
|
+
suggestions: string[];
|
|
23
|
+
/** This column's per-user colour overrides, so a badge here is the badge the
|
|
24
|
+
* cell draws. */
|
|
25
|
+
optionColors?: Record<string, ListSelectColor>;
|
|
26
|
+
onCommit: (next: string[]) => void;
|
|
27
|
+
onCancel: () => void;
|
|
28
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
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 { ChipsEditor } from "../../editors/ChipsEditor.js";
|
|
6
|
+
import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
7
|
+
import { prettifyOptionValue } from "../../model/column-state.js";
|
|
8
|
+
import { offeredValues, useOpenValues } from "../../editors/open-values.js";
|
|
9
|
+
export function GridChipsEditor({ column, values, suggestions, optionColors, onCommit, onCancel, }) {
|
|
10
|
+
const { Popover } = useViews().components;
|
|
11
|
+
const [open, setOpen] = useState(true);
|
|
12
|
+
const editorRef = useRef(null);
|
|
13
|
+
const anchorRef = useRef(null);
|
|
14
|
+
const closedRef = useRef(false);
|
|
15
|
+
const known = useOpenValues(column.field);
|
|
16
|
+
const offered = column.field ? offeredValues(column.field, known, suggestions) : suggestions;
|
|
17
|
+
const EXIT_MS = 160;
|
|
18
|
+
const close = (reason) => {
|
|
19
|
+
if (closedRef.current)
|
|
20
|
+
return;
|
|
21
|
+
closedRef.current = true;
|
|
22
|
+
const resolution = editorRef.current?.resolveClose(reason) ?? { kind: "noop" };
|
|
23
|
+
setOpen(false);
|
|
24
|
+
window.setTimeout(() => {
|
|
25
|
+
if (resolution.kind === "commit")
|
|
26
|
+
onCommit(resolution.payload);
|
|
27
|
+
else
|
|
28
|
+
onCancel();
|
|
29
|
+
}, EXIT_MS);
|
|
30
|
+
};
|
|
31
|
+
const resolve = (value) => ({
|
|
32
|
+
value,
|
|
33
|
+
label: column.options?.find((option) => option.value === value)?.label ?? prettifyOptionValue(value),
|
|
34
|
+
color: resolveCategoryColor(value, column.options, optionColors),
|
|
35
|
+
});
|
|
36
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(Popover, { open: open, onOpenChange: (next) => {
|
|
37
|
+
if (!next)
|
|
38
|
+
close("outside");
|
|
39
|
+
}, anchor: anchorRef, align: "start", sideOffset: 4, onEscape: () => close("escape"), onOutsidePress: () => close("outside"), initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, onRequestClose: close }) })] }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
2
|
+
import { type GridFlyouts } from "./GridFlyout.js";
|
|
3
|
+
export declare function GridColumnColorSection<Row>({ column, values, optionColors, flyouts, onOptionColorChange, onClose, }: {
|
|
4
|
+
column: ListColumn<Row>;
|
|
5
|
+
values: string[];
|
|
6
|
+
optionColors?: Record<string, ListSelectColor>;
|
|
7
|
+
flyouts: GridFlyouts;
|
|
8
|
+
/** Called with the FIELD key — the format map's key on every surface. */
|
|
9
|
+
onOptionColorChange: (key: string, value: string, color: ListSelectColor | null) => void;
|
|
10
|
+
onClose: () => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { CATEGORY_DOT_CLASSES, resolveCategoryColor, } from "@viewkitjs/fields/design/category-colors";
|
|
4
|
+
import { prettifyOptionValue } from "../../model/column-state.js";
|
|
5
|
+
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
import { cx } from "../../internal/cx.js";
|
|
8
|
+
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
9
|
+
import { GridMenuSeparator } from "./GridMenuRow.js";
|
|
10
|
+
const COLOR_DOTS = CATEGORY_DOT_CLASSES;
|
|
11
|
+
const ALL_COLORS = [
|
|
12
|
+
"gray",
|
|
13
|
+
"blue",
|
|
14
|
+
"green",
|
|
15
|
+
"amber",
|
|
16
|
+
"red",
|
|
17
|
+
"purple",
|
|
18
|
+
"pink",
|
|
19
|
+
"teal",
|
|
20
|
+
];
|
|
21
|
+
export function GridColumnColorSection({ column, values, optionColors, flyouts, onOptionColorChange, onClose, }) {
|
|
22
|
+
const { atoms, messages } = useViews();
|
|
23
|
+
const { Row, Tag } = atoms;
|
|
24
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: "max-h-72 overflow-y-auto overscroll-contain", children: values.map((value) => {
|
|
25
|
+
const resolved = resolveCategoryColor(value, column.options, optionColors);
|
|
26
|
+
return (_jsxs(GridFlyoutRow, { id: `color:${value}`, flyouts: flyouts, title: prettifyOptionValue(value), label: _jsx(Tag, { label: column.options?.find((option) => option.value === value)?.label ??
|
|
27
|
+
prettifyOptionValue(value), color: resolved }), children: [_jsx(Row, { chosen: !optionColors?.[value], label: messages({ key: "views.menus.automatic" }), leading: _jsx("span", { className: "h-2.5 w-2.5 rounded-full border border-(color:--vk-border)" }), onClick: () => {
|
|
28
|
+
onOptionColorChange(fieldKeyOf(column), value, null);
|
|
29
|
+
flyouts.close();
|
|
30
|
+
} }), ALL_COLORS.map((color) => (_jsx(Row, { chosen: resolved === color, label: messages({ key: "views.menus.colour", values: { colour: color } }), leading: _jsx("span", { className: cx("h-2.5 w-2.5 rounded-full", COLOR_DOTS[color]) }), onClick: () => {
|
|
31
|
+
onOptionColorChange(fieldKeyOf(column), value, color);
|
|
32
|
+
flyouts.close();
|
|
33
|
+
} }, color)))] }, value));
|
|
34
|
+
}) }), optionColors && Object.keys(optionColors).length > 0 && (_jsxs(_Fragment, { children: [_jsx(GridMenuSeparator, {}), _jsx(Row, { label: messages({ key: "views.menus.colours-reset" }), onClick: () => {
|
|
35
|
+
for (const value of Object.keys(optionColors)) {
|
|
36
|
+
onOptionColorChange(fieldKeyOf(column), value, null);
|
|
37
|
+
}
|
|
38
|
+
onClose();
|
|
39
|
+
} })] }))] }));
|
|
40
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
|
+
import type { ListDateStyle } from "../../model/column-format.js";
|
|
3
|
+
import { type GridFlyouts } from "./GridFlyout.js";
|
|
4
|
+
/**
|
|
5
|
+
* The date-column row in the header menu — one Format row whose flyout holds
|
|
6
|
+
* the styles (each beside a live sample) and, on a date-time, Show time —
|
|
7
|
+
* split out of GridColumnMenu because that file is held under the component
|
|
8
|
+
* ratchet's line ceiling rather than grown to hold them; the policy there is
|
|
9
|
+
* split, not raise (the same reason GridColumnColorSection and
|
|
10
|
+
* GridColumnDurationSection are their own files rather than inline).
|
|
11
|
+
*/
|
|
12
|
+
export declare function GridColumnDateSection<Row>({ column, dateStyle, onDateStyleChange, showTime, onShowTimeChange, flyouts, onClose, }: {
|
|
13
|
+
column: ListColumn<Row>;
|
|
14
|
+
/** This column's date-style override. */
|
|
15
|
+
dateStyle?: ListDateStyle;
|
|
16
|
+
/** Both handlers are called with the FIELD key — the format map's key. */
|
|
17
|
+
onDateStyleChange: (key: string, style: ListDateStyle) => void;
|
|
18
|
+
/** Resolved show-time (override → declared `format.withTime`). */
|
|
19
|
+
showTime?: boolean;
|
|
20
|
+
onShowTimeChange?: (key: string, show: boolean) => void;
|
|
21
|
+
flyouts: GridFlyouts;
|
|
22
|
+
onClose: () => void;
|
|
23
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { temporalKindOf } from "../../model/field-type-of.js";
|
|
4
|
+
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
5
|
+
import { formatDate } from "./cells.js";
|
|
6
|
+
import { useCellFormat } from "../../cells/use-cell-format.js";
|
|
7
|
+
import { useViews } from "../../provider/context.js";
|
|
8
|
+
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
9
|
+
import { GridMenuSeparator, KnobGlyph } from "./GridMenuRow.js";
|
|
10
|
+
const DATE_STYLES = ["short", "long", "numeric", "relative"];
|
|
11
|
+
const sampleDate = () => new Date(Date.now() - 3 * 86_400_000);
|
|
12
|
+
export function GridColumnDateSection({ column, dateStyle, onDateStyleChange, showTime, onShowTimeChange, flyouts, onClose, }) {
|
|
13
|
+
const activeDateStyle = dateStyle ?? column.format?.dateStyle ?? "short";
|
|
14
|
+
const sample = sampleDate();
|
|
15
|
+
const { viewer } = useCellFormat();
|
|
16
|
+
const { atoms, messages } = useViews();
|
|
17
|
+
const { Row } = atoms;
|
|
18
|
+
const styleLabel = (style) => messages({ key: "views.menus.date-style", values: { style } });
|
|
19
|
+
return (_jsxs(GridFlyoutRow, { id: "date-format", flyouts: flyouts, label: messages({ key: "views.menus.format" }), detail: styleLabel(activeDateStyle), leading: _jsx(KnobGlyph, { name: "calendar" }), children: [DATE_STYLES.map((style) => (_jsx(Row, { chosen: activeDateStyle === style, label: styleLabel(style), detail: _jsx("span", { className: "max-w-30 truncate", children: formatDate(sample, column, style, false, viewer) }), onClick: () => {
|
|
20
|
+
onDateStyleChange(fieldKeyOf(column), style);
|
|
21
|
+
onClose();
|
|
22
|
+
} }, style))), onShowTimeChange && temporalKindOf(column) === "datetime" && (_jsxs(_Fragment, { children: [_jsx(GridMenuSeparator, {}), _jsx(Row, { chosen: !!showTime, label: messages({ key: "views.menus.show-time" }), onClick: () => onShowTimeChange(fieldKeyOf(column), !showTime) })] }))] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
|
+
import type { ListDurationStyle } from "../../model/column-format.js";
|
|
3
|
+
import { type GridFlyouts } from "./GridFlyout.js";
|
|
4
|
+
/**
|
|
5
|
+
* The duration-column row in the header menu — one Format row whose flyout
|
|
6
|
+
* holds the styles — split out of GridColumnMenu because that file is held
|
|
7
|
+
* under the component ratchet's line ceiling rather than grown to hold them;
|
|
8
|
+
* the policy there is split, not raise (the same reason GridColumnColorSection
|
|
9
|
+
* is its own file rather than inline).
|
|
10
|
+
*/
|
|
11
|
+
export declare function GridColumnDurationSection<Row>({ column, durationStyle, onDurationStyleChange, flyouts, onClose, }: {
|
|
12
|
+
column: ListColumn<Row>;
|
|
13
|
+
/** This column's duration-rendering override. */
|
|
14
|
+
durationStyle?: ListDurationStyle;
|
|
15
|
+
/** Called with the FIELD key — the format map's key on every surface. */
|
|
16
|
+
onDurationStyleChange: (key: string, style: ListDurationStyle) => void;
|
|
17
|
+
flyouts: GridFlyouts;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
4
|
+
import { formatNumber } from "./cells.js";
|
|
5
|
+
import { useCellFormat } from "../../cells/use-cell-format.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
8
|
+
import { KnobGlyph } from "./GridMenuRow.js";
|
|
9
|
+
const DURATION_STYLES = ["adaptive", "clock", "units"];
|
|
10
|
+
const DURATION_SAMPLE_MS = 5_904_000;
|
|
11
|
+
export function GridColumnDurationSection({ column, durationStyle, onDurationStyleChange, flyouts, onClose, }) {
|
|
12
|
+
const activeDurationStyle = durationStyle ?? column.format?.durationStyle ?? "adaptive";
|
|
13
|
+
const cellFormat = useCellFormat();
|
|
14
|
+
const { atoms, messages } = useViews();
|
|
15
|
+
const { Row } = atoms;
|
|
16
|
+
const styleLabel = (style) => messages({ key: "views.menus.duration-style", values: { style } });
|
|
17
|
+
return (_jsx(GridFlyoutRow, { id: "duration-format", flyouts: flyouts, label: messages({ key: "views.menus.format" }), detail: styleLabel(activeDurationStyle), leading: _jsx(KnobGlyph, { name: "duration" }), children: DURATION_STYLES.map((style) => (_jsx(Row, { chosen: activeDurationStyle === style, label: styleLabel(style), detail: _jsx("span", { className: "max-w-30 truncate", children: formatNumber(DURATION_SAMPLE_MS, column, {
|
|
18
|
+
...cellFormat,
|
|
19
|
+
durationStyle: style,
|
|
20
|
+
}) }), onClick: () => {
|
|
21
|
+
onDurationStyleChange(fieldKeyOf(column), style);
|
|
22
|
+
onClose();
|
|
23
|
+
} }, style))) }));
|
|
24
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { type MouseEvent as ReactMouseEvent, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
|
+
import type { PercentDisplay } from "@viewkitjs/fields";
|
|
3
|
+
import type { OrderDir } from "../../grouping/sort-groups.js";
|
|
4
|
+
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
5
|
+
import type { ListDateStyle, ListDurationStyle, ListNumberFormatState } from "../../model/column-format.js";
|
|
6
|
+
/** What the menu sets on the header cell it opens from. */
|
|
7
|
+
type TriggerProps = {
|
|
8
|
+
ref?: Ref<HTMLElement>;
|
|
9
|
+
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
|
|
10
|
+
role?: "button";
|
|
11
|
+
"aria-haspopup"?: "dialog";
|
|
12
|
+
"aria-expanded"?: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** The list's sort state, threaded from its controller — the menu is a second
|
|
15
|
+
* remote control for the SAME persisted sort the view-options popover drives. */
|
|
16
|
+
export type GridSortState = {
|
|
17
|
+
value: string;
|
|
18
|
+
dir: OrderDir;
|
|
19
|
+
onChange: (next: {
|
|
20
|
+
value: string;
|
|
21
|
+
dir: OrderDir;
|
|
22
|
+
}) => void;
|
|
23
|
+
};
|
|
24
|
+
/** The view's group, as the header asks it: which field, and a writer that
|
|
25
|
+
* takes a field key (or null to ungroup). */
|
|
26
|
+
export type GridGroupByState = {
|
|
27
|
+
fieldKey: string | null;
|
|
28
|
+
onChange: (fieldKey: string | null) => void;
|
|
29
|
+
};
|
|
30
|
+
/** The cheap OUTER gate: action columns declare "no header menu knobs" by
|
|
31
|
+
* contract, so they never get one. Everything else may — whether it actually
|
|
32
|
+
* does is `hasContent` inside the component, which is the only place that knows
|
|
33
|
+
* every per-knob gate. Two levels because this one runs per header cell per
|
|
34
|
+
* render and the other needs the full prop set. */
|
|
35
|
+
export declare function gridColumnMenuEnabled<Row>(col: ListColumn<Row>): boolean;
|
|
36
|
+
/**
|
|
37
|
+
* THE HEADER MENU — sort · group · the type's knobs · move · hide, in that
|
|
38
|
+
* order, every block derived and none by hand:
|
|
39
|
+
*
|
|
40
|
+
* - Sort is offered where `effectiveSortKey` names a key (a declared
|
|
41
|
+
* `sortKey`, or the field itself on a saved view). Clear sort appears only
|
|
42
|
+
* while this column IS the sort.
|
|
43
|
+
* - Group by is offered on a saved view for a field whose type groups
|
|
44
|
+
* (`columnGroupable`, the rule the toolbar's Group menu reads too); Ungroup
|
|
45
|
+
* while it is the group.
|
|
46
|
+
* - The knobs are `columnKnobs`' answer — the same one the Columns drill-in
|
|
47
|
+
* reads, so the two doors cannot disagree. Every knob writes under the
|
|
48
|
+
* FIELD key: it is the workspace's setting for the field, shared by every
|
|
49
|
+
* surface that draws it. Each knob is ONE row — its name, its current
|
|
50
|
+
* value, a chevron — whose choices fly out beside the menu (`GridFlyoutRow`),
|
|
51
|
+
* so a money column's menu is a short list of settings, not every choice
|
|
52
|
+
* of every setting.
|
|
53
|
+
* - Move left / right swap with the visible neighbour; hide is last.
|
|
54
|
+
* - The host's rows for this column's field (a field editor's Edit field,
|
|
55
|
+
* Archive field) sit just above hide (`renderColumnMenuRows`).
|
|
56
|
+
*
|
|
57
|
+
* No admin block: a lock is the workspace's rule about who may WRITE a field,
|
|
58
|
+
* and it lives in Settings → Modules → Tables and the Columns drill-in, not
|
|
59
|
+
* beside the knobs about how the field READS.
|
|
60
|
+
*/
|
|
61
|
+
export declare function GridColumnMenu<Row>({ column, values, viewBacked, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable, renderColumnMenuRows, children, }: {
|
|
62
|
+
column: ListColumn<Row>;
|
|
63
|
+
/** Distinct option values for select columns (declared + discovered), in display order. */
|
|
64
|
+
values: string[];
|
|
65
|
+
/** On a saved view a bound column sorts and groups by its field. */
|
|
66
|
+
viewBacked?: boolean;
|
|
67
|
+
sort?: GridSortState;
|
|
68
|
+
groupBy?: GridGroupByState;
|
|
69
|
+
/** The workspace's colour overrides for this column's option values. */
|
|
70
|
+
optionColors?: Record<string, ListSelectColor>;
|
|
71
|
+
onOptionColorChange?: (key: string, value: string, color: ListSelectColor | null) => void;
|
|
72
|
+
dateStyle?: ListDateStyle;
|
|
73
|
+
onDateStyleChange?: (key: string, style: ListDateStyle) => void;
|
|
74
|
+
durationStyle?: ListDurationStyle;
|
|
75
|
+
onDurationStyleChange?: (key: string, style: ListDurationStyle) => void;
|
|
76
|
+
showTime?: boolean;
|
|
77
|
+
onShowTimeChange?: (key: string, show: boolean) => void;
|
|
78
|
+
percentDisplay?: PercentDisplay;
|
|
79
|
+
onPercentDisplayChange?: (key: string, display: PercentDisplay) => void;
|
|
80
|
+
/** Number columns: current decimals / display-currency state (host-owned). */
|
|
81
|
+
numberFormat?: ListNumberFormatState;
|
|
82
|
+
/** `decimals: null` = the field's own (Automatic). */
|
|
83
|
+
onNumberFormatChange?: (key: string, patch: {
|
|
84
|
+
decimals?: number | null;
|
|
85
|
+
currency?: string;
|
|
86
|
+
}) => void;
|
|
87
|
+
/** Present when there is a visible neighbour on that side. */
|
|
88
|
+
onMoveLeft?: () => void;
|
|
89
|
+
onMoveRight?: () => void;
|
|
90
|
+
/** Renders the "Hide from view" row. The grid passes it only when hiding is
|
|
91
|
+
* allowed (hideable column, more than one visible, host persists state). */
|
|
92
|
+
onHide?: () => void;
|
|
93
|
+
/** Whether a format knob can be stored; the reader's own currency reading stays either way. */
|
|
94
|
+
formatsWritable?: boolean;
|
|
95
|
+
/** The host's rows for this column's field, above Hide; null for a field it adds nothing to. */
|
|
96
|
+
renderColumnMenuRows?: (fieldKey: string, close: () => void) => ReactNode;
|
|
97
|
+
/** The header cell: the menu's anchor, and a press on it opens or closes the menu. The menu
|
|
98
|
+
* sets its `ref`, so it must carry none of its own. */
|
|
99
|
+
children: ReactElement<TriggerProps>;
|
|
100
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
101
|
+
export {};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { cloneElement, useState, } from "react";
|
|
4
|
+
import { columnGroupable } from "../../model/column-order.js";
|
|
5
|
+
import { columnLabel } from "../../model/column-capabilities.js";
|
|
6
|
+
import { columnKnobs } from "../../model/column-knobs.js";
|
|
7
|
+
import { effectiveSortKey } from "../../model/column-sort.js";
|
|
8
|
+
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
9
|
+
import { useViews } from "../../provider/context.js";
|
|
10
|
+
import { GridColumnColorSection } from "./GridColumnColorSection.js";
|
|
11
|
+
import { GridColumnDateSection } from "./GridColumnDateSection.js";
|
|
12
|
+
import { GridColumnDurationSection } from "./GridColumnDurationSection.js";
|
|
13
|
+
import { GridColumnNumberSection } from "./GridColumnNumberSection.js";
|
|
14
|
+
import { GridColumnPercentSection } from "./GridColumnPercentSection.js";
|
|
15
|
+
import { GridColumnSortSection } from "./GridColumnSortSection.js";
|
|
16
|
+
import { insideGridFlyout, useGridFlyouts } from "./GridFlyout.js";
|
|
17
|
+
import { GridMenuRow, GridMenuSeparator } from "./GridMenuRow.js";
|
|
18
|
+
export function gridColumnMenuEnabled(col) {
|
|
19
|
+
return !col.actions;
|
|
20
|
+
}
|
|
21
|
+
export function GridColumnMenu({ column, values, viewBacked = false, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable = true, renderColumnMenuRows, children, }) {
|
|
22
|
+
const [open, setOpen] = useState(false);
|
|
23
|
+
const flyouts = useGridFlyouts();
|
|
24
|
+
const [anchor, setAnchor] = useState(null);
|
|
25
|
+
const { atoms, components, messages } = useViews();
|
|
26
|
+
const { Popover } = components;
|
|
27
|
+
const { List } = atoms;
|
|
28
|
+
const key = fieldKeyOf(column);
|
|
29
|
+
const sortKey = effectiveSortKey(column, viewBacked);
|
|
30
|
+
const sortable = !!(sortKey && sort);
|
|
31
|
+
const groupable = !!groupBy && viewBacked && columnGroupable(column);
|
|
32
|
+
const grouped = groupable && groupBy.fieldKey === column.field.key;
|
|
33
|
+
const knobs = columnKnobs(column);
|
|
34
|
+
const canPercent = formatsWritable && knobs.has("percentDisplay") && !!onPercentDisplayChange;
|
|
35
|
+
const canDate = formatsWritable && knobs.has("dateStyle") && !!onDateStyleChange;
|
|
36
|
+
const canDuration = formatsWritable && knobs.has("durationStyle") && !!onDurationStyleChange;
|
|
37
|
+
const canDecimals = formatsWritable && knobs.has("decimals") && !!onNumberFormatChange;
|
|
38
|
+
const canCurrency = knobs.has("currency") && !!onNumberFormatChange;
|
|
39
|
+
const canColor = formatsWritable &&
|
|
40
|
+
(column.type === "select" || column.type === "multiselect") &&
|
|
41
|
+
!column.render &&
|
|
42
|
+
!!onOptionColorChange &&
|
|
43
|
+
values.length > 0;
|
|
44
|
+
const canMove = !!onMoveLeft || !!onMoveRight;
|
|
45
|
+
const close = () => {
|
|
46
|
+
flyouts.close();
|
|
47
|
+
setOpen(false);
|
|
48
|
+
};
|
|
49
|
+
const handleOpenChange = (next) => (next ? setOpen(true) : close());
|
|
50
|
+
const editorRows = renderColumnMenuRows?.(key, close) ?? null;
|
|
51
|
+
const hasContent = sortable ||
|
|
52
|
+
groupable ||
|
|
53
|
+
canPercent ||
|
|
54
|
+
canDate ||
|
|
55
|
+
canDuration ||
|
|
56
|
+
canDecimals ||
|
|
57
|
+
canCurrency ||
|
|
58
|
+
canColor ||
|
|
59
|
+
canMove ||
|
|
60
|
+
!!editorRows ||
|
|
61
|
+
!!onHide;
|
|
62
|
+
if (!hasContent)
|
|
63
|
+
return _jsx(_Fragment, { children: children });
|
|
64
|
+
const canKnobs = canPercent || canDate || canDuration || canDecimals || canCurrency;
|
|
65
|
+
const present = [sortable, groupable, canKnobs, canColor, canMove, !!editorRows, !!onHide];
|
|
66
|
+
const divider = (i) => (present.slice(0, i).some(Boolean) ? _jsx(GridMenuSeparator, {}) : null);
|
|
67
|
+
const trigger = cloneElement(children, {
|
|
68
|
+
ref: setAnchor,
|
|
69
|
+
onClick: (event) => {
|
|
70
|
+
children.props.onClick?.(event);
|
|
71
|
+
if (open)
|
|
72
|
+
close();
|
|
73
|
+
else
|
|
74
|
+
setOpen(true);
|
|
75
|
+
},
|
|
76
|
+
role: "button",
|
|
77
|
+
"aria-haspopup": "dialog",
|
|
78
|
+
"aria-expanded": open,
|
|
79
|
+
});
|
|
80
|
+
return (_jsxs(_Fragment, { children: [trigger, _jsx(Popover, { open: open, onOpenChange: handleOpenChange, anchor: anchor, side: "bottom", align: "start", sideOffset: 2, initialFocus: false, chrome: "menu", panelData: { "data-slot": "vk-grid-column-menu" }, className: "w-52", onOutsidePress: (event) => anchor?.contains(event.target) || insideGridFlyout(event) ? false : undefined, children: _jsx("div", { onPointerOver: flyouts.onListPointerOver, children: _jsxs(List, { children: [sortable && (_jsxs(_Fragment, { children: [divider(0), _jsx(GridColumnSortSection, { sortKey: sortKey, value: sort.value, dir: sort.dir, onChange: sort.onChange, onClose: close })] })), groupable && (_jsxs(_Fragment, { children: [divider(1), grouped ? (_jsx(GridMenuRow, { label: messages({ key: "views.menus.ungroup" }), icon: "group", active: true, onClick: () => {
|
|
81
|
+
groupBy.onChange(null);
|
|
82
|
+
close();
|
|
83
|
+
} })) : (_jsx(GridMenuRow, { label: messages({
|
|
84
|
+
key: "views.menus.group-by",
|
|
85
|
+
values: { field: columnLabel(column) },
|
|
86
|
+
}), icon: "group", onClick: () => {
|
|
87
|
+
groupBy.onChange(column.field.key);
|
|
88
|
+
close();
|
|
89
|
+
} }))] })), canKnobs && divider(2), canPercent && (_jsx(GridColumnPercentSection, { column: column, fieldKey: key, percentDisplay: percentDisplay, onPercentDisplayChange: onPercentDisplayChange, flyouts: flyouts, onClose: close })), canDate && (_jsx(GridColumnDateSection, { column: column, dateStyle: dateStyle, onDateStyleChange: onDateStyleChange, showTime: showTime, onShowTimeChange: knobs.has("showTime") ? onShowTimeChange : undefined, flyouts: flyouts, onClose: close })), canDuration && (_jsx(GridColumnDurationSection, { column: column, durationStyle: durationStyle, onDurationStyleChange: onDurationStyleChange, flyouts: flyouts, onClose: close })), (canDecimals || canCurrency) && (_jsx(GridColumnNumberSection, { column: column, fieldKey: key, decimals: canDecimals, currency: canCurrency, numberFormat: numberFormat, onNumberFormatChange: onNumberFormatChange, flyouts: flyouts, onClose: close })), canColor && (_jsxs(_Fragment, { children: [divider(3), _jsx(GridColumnColorSection, { column: column, values: values, optionColors: optionColors, flyouts: flyouts, onOptionColorChange: onOptionColorChange, onClose: close })] })), canMove && (_jsxs(_Fragment, { children: [divider(4), onMoveLeft && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.move-left" }), icon: "moveLeft", onClick: () => {
|
|
90
|
+
onMoveLeft();
|
|
91
|
+
close();
|
|
92
|
+
} })), onMoveRight && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.move-right" }), icon: "moveRight", onClick: () => {
|
|
93
|
+
onMoveRight();
|
|
94
|
+
close();
|
|
95
|
+
} }))] })), editorRows && (_jsxs(_Fragment, { children: [divider(5), editorRows] })), onHide && (_jsxs(_Fragment, { children: [divider(6), _jsx(GridMenuRow, { label: messages({ key: "views.menus.hide-column" }), icon: "hide", onClick: () => {
|
|
96
|
+
onHide();
|
|
97
|
+
close();
|
|
98
|
+
} })] }))] }) }) })] }));
|
|
99
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
|
+
import type { ListNumberFormatState } from "../../model/column-format.js";
|
|
3
|
+
import { type GridFlyouts } from "./GridFlyout.js";
|
|
4
|
+
/**
|
|
5
|
+
* The number rows in the header menu — Decimals, and Currency on a column
|
|
6
|
+
* whose binding states rates (Original · EUR · USD · RON), each one row whose
|
|
7
|
+
* choices fly out. Lifted out of GridColumnMenu for the line ceiling; the
|
|
8
|
+
* policy is split, not raise. Writes under the FIELD key.
|
|
9
|
+
*/
|
|
10
|
+
export declare function GridColumnNumberSection<Row>({ column, fieldKey, decimals, currency, numberFormat, onNumberFormatChange, flyouts, onClose, }: {
|
|
11
|
+
column: ListColumn<Row>;
|
|
12
|
+
fieldKey: string;
|
|
13
|
+
/** Offer the Decimals row. */
|
|
14
|
+
decimals: boolean;
|
|
15
|
+
/** Offer the Currency row (the column carries rates — `columnKnobs`). */
|
|
16
|
+
currency: boolean;
|
|
17
|
+
numberFormat?: ListNumberFormatState;
|
|
18
|
+
/** `decimals: null` = the field's own (Automatic). */
|
|
19
|
+
onNumberFormatChange: (key: string, patch: {
|
|
20
|
+
decimals?: number | null;
|
|
21
|
+
currency?: string;
|
|
22
|
+
}) => void;
|
|
23
|
+
flyouts: GridFlyouts;
|
|
24
|
+
onClose: () => void;
|
|
25
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { LIST_DECIMALS_CHOICES } from "../../model/column-state.js";
|
|
4
|
+
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
6
|
+
import { KnobGlyph } from "./GridMenuRow.js";
|
|
7
|
+
const DECIMALS_SAMPLE = 1234.567;
|
|
8
|
+
const AUTOMATIC_SAMPLE = String(Number(DECIMALS_SAMPLE.toFixed(2)));
|
|
9
|
+
export function GridColumnNumberSection({ column, fieldKey, decimals, currency, numberFormat, onNumberFormatChange, flyouts, onClose, }) {
|
|
10
|
+
const chosen = numberFormat?.decimals ?? undefined;
|
|
11
|
+
const declared = column.format?.decimals;
|
|
12
|
+
const shown = chosen ?? declared;
|
|
13
|
+
const currencyOptions = numberFormat?.currencyOptions ?? [];
|
|
14
|
+
const { atoms, messages } = useViews();
|
|
15
|
+
const { Row } = atoms;
|
|
16
|
+
const automatic = messages({ key: "views.menus.automatic" });
|
|
17
|
+
return (_jsxs(_Fragment, { children: [decimals && (_jsxs(GridFlyoutRow, { id: "decimals", flyouts: flyouts, label: messages({ key: "views.menus.decimals" }), detail: shown ?? automatic, leading: _jsx(KnobGlyph, { name: "number" }), children: [_jsx(Row, { chosen: chosen === undefined, label: automatic, detail: _jsx("span", { className: "tabular-nums", children: declared === undefined ? AUTOMATIC_SAMPLE : DECIMALS_SAMPLE.toFixed(declared) }), onClick: () => {
|
|
18
|
+
onNumberFormatChange(fieldKey, { decimals: null });
|
|
19
|
+
onClose();
|
|
20
|
+
} }), LIST_DECIMALS_CHOICES.map((d) => (_jsx(Row, { chosen: chosen === d, label: d, detail: _jsx("span", { className: "tabular-nums", children: DECIMALS_SAMPLE.toFixed(d) }), onClick: () => {
|
|
21
|
+
onNumberFormatChange(fieldKey, { decimals: d });
|
|
22
|
+
onClose();
|
|
23
|
+
} }, d)))] })), currency && currencyOptions.length > 0 && (_jsx(GridFlyoutRow, { id: "currency", flyouts: flyouts, label: messages({ key: "views.menus.currency" }), detail: currencyOptions.find((c) => c.value === numberFormat?.currency)?.label, leading: _jsx(KnobGlyph, { name: "currency" }), children: currencyOptions.map((c) => (_jsx(Row, { chosen: numberFormat?.currency === c.value, label: c.label, onClick: () => {
|
|
24
|
+
onNumberFormatChange(fieldKey, { currency: c.value });
|
|
25
|
+
onClose();
|
|
26
|
+
} }, c.value))) }))] }));
|
|
27
|
+
}
|