@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,73 @@
|
|
|
1
|
+
import { type FieldType } from "@viewkitjs/fields";
|
|
2
|
+
import { type FilterRelationRule, type FilterRule, type FilterTree, type ViewFieldReader } from "@viewkitjs/fields/query";
|
|
3
|
+
import type { ListColumn } from "./column-schema.js";
|
|
4
|
+
import type { ListFilterRule, ListFilterRuleState } from "./preferences.js";
|
|
5
|
+
/** THE KEY A COLUMN IS KNOWN BY OFF THE GRID — its FIELD, when it has one, and
|
|
6
|
+
* otherwise its own id, which is the only name it has. Every surface that is
|
|
7
|
+
* not the grid (a saved view's rows, a drawer, a lock) asks under this: they
|
|
8
|
+
* share the field key and nothing else. `lockKeyOf` is this function under the
|
|
9
|
+
* name a lock site reads best. */
|
|
10
|
+
export declare function fieldKeyOf<Row>(col: ListColumn<Row>): string;
|
|
11
|
+
/**
|
|
12
|
+
* The Filter panel's editors speak `ListFilterRule` (one rule per column,
|
|
13
|
+
* keyed by column id); a saved view speaks `FilterRule` (keyed by field key,
|
|
14
|
+
* with the option-set operators). The panel keeps editing the ROOT level of a
|
|
15
|
+
* view's tree through these two conversions; nested groups pass through
|
|
16
|
+
* untouched and are drawn by the group editor.
|
|
17
|
+
*/
|
|
18
|
+
export declare function fromListFilterRule(fieldKey: string, type: FieldType, rule: ListFilterRule,
|
|
19
|
+
/** The part of the value a part row's rule reads (VK-57); absent, the rule reads the whole value. */
|
|
20
|
+
part?: string): FilterRule | null;
|
|
21
|
+
export declare function toListFilterRule(type: FieldType, rule: FilterRule,
|
|
22
|
+
/** `parts`: a rule on one part of the value maps onto its part row's editor (VK-57). Without it, such a rule has
|
|
23
|
+
* no editor: the column's own row edits the whole value only. */
|
|
24
|
+
opts?: {
|
|
25
|
+
parts?: boolean;
|
|
26
|
+
}): ListFilterRule | null;
|
|
27
|
+
/** The root-level rules a column can edit, keyed by column id; with `parts`, a rule on one part of a value under its
|
|
28
|
+
* part key (`partKey(columnId, part)`). */
|
|
29
|
+
export declare function rootRulesByColumn<Row>(tree: FilterTree, columns: ListColumn<Row>[], opts?: {
|
|
30
|
+
parts?: boolean;
|
|
31
|
+
}): ListFilterRuleState;
|
|
32
|
+
/** The tree with its root rules replaced by `state`, a whole-value key per column and, with `parts`, a part key per
|
|
33
|
+
* part row. Groups, relation rules and every rule no panel row can name (a country `is_none_of`, a part no table
|
|
34
|
+
* lists, a whole rule `toListFilterRule` maps to null) are kept as they are, never cleared. */
|
|
35
|
+
export declare function withRootRuleState<Row>(tree: FilterTree, columns: ListColumn<Row>[], state: ListFilterRuleState, opts?: {
|
|
36
|
+
parts?: boolean;
|
|
37
|
+
}): FilterTree;
|
|
38
|
+
/** The root relation rules, by relation field key — the Filter panel's Related records rows (POR-704). */
|
|
39
|
+
export declare function rootRelationRules(tree: FilterTree): Record<string, FilterRelationRule>;
|
|
40
|
+
/** The tree with its root relation rules replaced by `rules`; every other rule and group untouched. */
|
|
41
|
+
export declare function withRootRelationRules(tree: FilterTree, rules: Readonly<Record<string, FilterRelationRule>>): FilterTree;
|
|
42
|
+
/** Replace (or drop, on null) the root rule for one column, or with `part` its rule on that part of the value; groups
|
|
43
|
+
* untouched. */
|
|
44
|
+
export declare function withRootRule<Row>(tree: FilterTree, col: ListColumn<Row>, rule: ListFilterRule | null, part?: string): FilterTree;
|
|
45
|
+
/**
|
|
46
|
+
* HOW A VIEW READS THIS LIST'S ROWS — the bridge from a field key to a value.
|
|
47
|
+
*
|
|
48
|
+
* A view names `stage`; the list holds a column whose `field.key` is `stage`
|
|
49
|
+
* and whose accessor knows how to reach it. Built from the columns rather than
|
|
50
|
+
* from a module's binding, because the binding layer is the module's and this
|
|
51
|
+
* one is the grid's: every list that carries typed columns already has
|
|
52
|
+
* everything needed here, and one that does not has no fields for a view to
|
|
53
|
+
* name in the first place.
|
|
54
|
+
*
|
|
55
|
+
* `accessor` WINS OVER `editAccessor` — a view reads what the reader sees.
|
|
56
|
+
* That is the contract `ViewFieldReader.read` already states ("the DISPLAY
|
|
57
|
+
* value — what the cell draws — so a rule compares what is on screen"), and it
|
|
58
|
+
* is the only reading under which a filter, a sort and a group agree with the
|
|
59
|
+
* column they are named after. The Transactions ledger is where the two come
|
|
60
|
+
* apart hardest: its Amount column converts every row into the display currency
|
|
61
|
+
* and signs it by direction, so `> 100` under the stored read would compare a
|
|
62
|
+
* hundred of whatever currency each row happens to be kept in; its Date column
|
|
63
|
+
* is the coalesced `occurred_at ?? expected_at`, so a rule under the stored read
|
|
64
|
+
* would drop every payment that has only ever been expected.
|
|
65
|
+
*
|
|
66
|
+
* `editAccessor` is the FALLBACK, for a column that draws itself and so has no
|
|
67
|
+
* display accessor at all (`accessor: null` — see `columnFrom`). It remains the
|
|
68
|
+
* right read for an EDITOR, which opens on the stored value, and every editing
|
|
69
|
+
* surface keeps preferring it (`clipboard-model`, `pending-reconciliation`,
|
|
70
|
+
* `card-edit`). Those two questions are different, and this is the one that asks
|
|
71
|
+
* what is on screen.
|
|
72
|
+
*/
|
|
73
|
+
export declare function viewReaderFrom<Row>(columns: ListColumn<Row>[], decimals?: Record<string, number>): ViewFieldReader<Row>;
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { valueTypeOf } from "@viewkitjs/fields";
|
|
2
|
+
import { denominationOf } from "../fields/denomination.js";
|
|
3
|
+
import { isFilterGroup, isRelationRule, operatorsFor, } from "@viewkitjs/fields/query";
|
|
4
|
+
import { FILTER_PART_ROWS, partKey } from "./part-rows.js";
|
|
5
|
+
export function fieldKeyOf(col) {
|
|
6
|
+
return col.field?.key ?? col.id;
|
|
7
|
+
}
|
|
8
|
+
export function fromListFilterRule(fieldKey, type, rule, part) {
|
|
9
|
+
const whole = wholeFromListFilterRule(fieldKey, type, rule);
|
|
10
|
+
return whole && part !== undefined ? { ...whole, part } : whole;
|
|
11
|
+
}
|
|
12
|
+
function wholeFromListFilterRule(fieldKey, type, rule) {
|
|
13
|
+
switch (rule.editor) {
|
|
14
|
+
case "text":
|
|
15
|
+
return { fieldKey, operator: rule.operator, value: rule.query };
|
|
16
|
+
case "number":
|
|
17
|
+
return rule.operator === "between"
|
|
18
|
+
? { fieldKey, operator: "between", value: [rule.value ?? 0, rule.value2 ?? 0] }
|
|
19
|
+
: { fieldKey, operator: rule.operator, value: rule.value };
|
|
20
|
+
case "date":
|
|
21
|
+
if (rule.operator === "is_relative")
|
|
22
|
+
return {
|
|
23
|
+
fieldKey,
|
|
24
|
+
operator: "is_relative",
|
|
25
|
+
value: { direction: rule.direction ?? "this", unit: rule.unit ?? "week" },
|
|
26
|
+
};
|
|
27
|
+
if (rule.operator === "is_between")
|
|
28
|
+
return { fieldKey, operator: "is_between", value: [rule.from ?? "", rule.to ?? ""] };
|
|
29
|
+
return { fieldKey, operator: rule.operator, value: rule.from ?? null };
|
|
30
|
+
case "options":
|
|
31
|
+
if (type === "boolean") {
|
|
32
|
+
if (rule.values.length !== 1)
|
|
33
|
+
return null;
|
|
34
|
+
return { fieldKey, operator: "is", value: rule.values[0] === "true" };
|
|
35
|
+
}
|
|
36
|
+
return rule.values.length ? { fieldKey, operator: "is_any_of", value: rule.values } : null;
|
|
37
|
+
case "range":
|
|
38
|
+
return rule.operator === "overlaps" || rule.operator === "within"
|
|
39
|
+
? { fieldKey, operator: rule.operator, value: [rule.value ?? null, rule.value2 ?? null] }
|
|
40
|
+
: { fieldKey, operator: rule.operator, value: rule.value };
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function toListFilterRule(type, rule, opts) {
|
|
44
|
+
if (rule.part !== undefined)
|
|
45
|
+
return opts?.parts ? partListFilterRule(type, rule, rule.part) : null;
|
|
46
|
+
switch (type) {
|
|
47
|
+
case "text":
|
|
48
|
+
case "url":
|
|
49
|
+
case "domain":
|
|
50
|
+
case "email":
|
|
51
|
+
case "phone":
|
|
52
|
+
case "rich_text":
|
|
53
|
+
return {
|
|
54
|
+
editor: "text",
|
|
55
|
+
operator: rule.operator,
|
|
56
|
+
query: typeof rule.value === "string" ? rule.value : "",
|
|
57
|
+
};
|
|
58
|
+
case "number":
|
|
59
|
+
case "percent":
|
|
60
|
+
case "currency":
|
|
61
|
+
if (Array.isArray(rule.value))
|
|
62
|
+
return {
|
|
63
|
+
editor: "number",
|
|
64
|
+
operator: "between",
|
|
65
|
+
value: Number(rule.value[0]),
|
|
66
|
+
value2: Number(rule.value[1]),
|
|
67
|
+
};
|
|
68
|
+
return {
|
|
69
|
+
editor: "number",
|
|
70
|
+
operator: rule.operator,
|
|
71
|
+
value: typeof rule.value === "number" ? rule.value : null,
|
|
72
|
+
};
|
|
73
|
+
case "date":
|
|
74
|
+
case "datetime": {
|
|
75
|
+
const v = rule.value;
|
|
76
|
+
if (rule.operator === "is_relative" && v && typeof v === "object" && "direction" in v)
|
|
77
|
+
return { editor: "date", operator: "is_relative", direction: v.direction, unit: v.unit };
|
|
78
|
+
if (Array.isArray(v))
|
|
79
|
+
return { editor: "date", operator: "is_between", from: String(v[0]), to: String(v[1]) };
|
|
80
|
+
return {
|
|
81
|
+
editor: "date",
|
|
82
|
+
operator: rule.operator,
|
|
83
|
+
from: typeof v === "string" ? v : null,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
case "select":
|
|
87
|
+
case "status":
|
|
88
|
+
case "multiselect":
|
|
89
|
+
case "relation":
|
|
90
|
+
case "user":
|
|
91
|
+
case "actor":
|
|
92
|
+
return rule.operator === "is_any_of" && Array.isArray(rule.value)
|
|
93
|
+
? { editor: "options", values: [...rule.value] }
|
|
94
|
+
: null;
|
|
95
|
+
case "boolean":
|
|
96
|
+
return rule.operator === "is"
|
|
97
|
+
? { editor: "options", values: [String(rule.value === true)] }
|
|
98
|
+
: null;
|
|
99
|
+
case "range":
|
|
100
|
+
return Array.isArray(rule.value)
|
|
101
|
+
? {
|
|
102
|
+
editor: "range",
|
|
103
|
+
operator: rule.operator,
|
|
104
|
+
value: rule.value[0] ?? null,
|
|
105
|
+
value2: rule.value[1] ?? null,
|
|
106
|
+
}
|
|
107
|
+
: {
|
|
108
|
+
editor: "range",
|
|
109
|
+
operator: rule.operator,
|
|
110
|
+
value: typeof rule.value === "number" ? rule.value : null,
|
|
111
|
+
};
|
|
112
|
+
case "location":
|
|
113
|
+
return null;
|
|
114
|
+
case "name":
|
|
115
|
+
return {
|
|
116
|
+
editor: "text",
|
|
117
|
+
operator: rule.operator,
|
|
118
|
+
query: typeof rule.value === "string" ? rule.value : "",
|
|
119
|
+
};
|
|
120
|
+
case "lookup":
|
|
121
|
+
case "rollup":
|
|
122
|
+
case "formula":
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
function partListFilterRule(type, rule, part) {
|
|
127
|
+
if (!FILTER_PART_ROWS[type]?.includes(part))
|
|
128
|
+
return null;
|
|
129
|
+
const ops = operatorsFor(type, part);
|
|
130
|
+
if (!ops.includes(rule.operator))
|
|
131
|
+
return null;
|
|
132
|
+
if (ops[0] === "is_any_of")
|
|
133
|
+
return rule.operator === "is_any_of" && Array.isArray(rule.value)
|
|
134
|
+
? { editor: "options", values: [...rule.value] }
|
|
135
|
+
: null;
|
|
136
|
+
return {
|
|
137
|
+
editor: "text",
|
|
138
|
+
operator: rule.operator,
|
|
139
|
+
query: typeof rule.value === "string" ? rule.value : "",
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export function rootRulesByColumn(tree, columns, opts) {
|
|
143
|
+
const out = {};
|
|
144
|
+
for (const item of tree.items) {
|
|
145
|
+
if (isFilterGroup(item) || isRelationRule(item))
|
|
146
|
+
continue;
|
|
147
|
+
const col = columns.find((c) => fieldKeyOf(c) === item.fieldKey);
|
|
148
|
+
if (!col?.field)
|
|
149
|
+
continue;
|
|
150
|
+
const rule = toListFilterRule(valueTypeOf(col.field), item, opts);
|
|
151
|
+
if (rule)
|
|
152
|
+
out[item.part === undefined ? col.id : partKey(col.id, item.part)] = rule;
|
|
153
|
+
}
|
|
154
|
+
return out;
|
|
155
|
+
}
|
|
156
|
+
export function withRootRuleState(tree, columns, state, opts) {
|
|
157
|
+
const named = rootRulesByColumn(tree, columns, opts);
|
|
158
|
+
let next = tree;
|
|
159
|
+
for (const col of columns) {
|
|
160
|
+
if (!col.field)
|
|
161
|
+
continue;
|
|
162
|
+
const parts = opts?.parts ? (FILTER_PART_ROWS[valueTypeOf(col.field)] ?? []) : [];
|
|
163
|
+
for (const part of [undefined, ...parts]) {
|
|
164
|
+
const key = part === undefined ? col.id : partKey(col.id, part);
|
|
165
|
+
const rule = state[key] ?? null;
|
|
166
|
+
if (rule || key in named)
|
|
167
|
+
next = withRootRule(next, col, rule, part);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return next;
|
|
171
|
+
}
|
|
172
|
+
export function rootRelationRules(tree) {
|
|
173
|
+
const out = {};
|
|
174
|
+
for (const item of tree.items)
|
|
175
|
+
if (isRelationRule(item))
|
|
176
|
+
out[item.fieldKey] = item;
|
|
177
|
+
return out;
|
|
178
|
+
}
|
|
179
|
+
export function withRootRelationRules(tree, rules) {
|
|
180
|
+
const kept = tree.items.filter((item) => !isRelationRule(item));
|
|
181
|
+
return { op: tree.op, items: [...kept, ...Object.values(rules)] };
|
|
182
|
+
}
|
|
183
|
+
export function withRootRule(tree, col, rule, part) {
|
|
184
|
+
const key = fieldKeyOf(col);
|
|
185
|
+
const type = col.field ? valueTypeOf(col.field) : undefined;
|
|
186
|
+
const kept = tree.items.filter((item) => isFilterGroup(item) ||
|
|
187
|
+
isRelationRule(item) ||
|
|
188
|
+
item.fieldKey !== key ||
|
|
189
|
+
item.part !== part ||
|
|
190
|
+
(part !== undefined && (!type || !toListFilterRule(type, item, { parts: true }))));
|
|
191
|
+
const next = rule && col.field ? fromListFilterRule(key, valueTypeOf(col.field), rule, part) : null;
|
|
192
|
+
return { op: tree.op, items: next ? [...kept, next] : kept };
|
|
193
|
+
}
|
|
194
|
+
export function viewReaderFrom(columns, decimals = {}) {
|
|
195
|
+
const byKey = new Map();
|
|
196
|
+
for (const col of columns) {
|
|
197
|
+
if (col.field)
|
|
198
|
+
byKey.set(col.field.key, col);
|
|
199
|
+
}
|
|
200
|
+
return {
|
|
201
|
+
fieldOf: (key) => byKey.get(key)?.field,
|
|
202
|
+
read: (row, key) => {
|
|
203
|
+
const col = byKey.get(key);
|
|
204
|
+
if (!col)
|
|
205
|
+
return undefined;
|
|
206
|
+
return (col.accessor ?? col.editAccessor)?.(row);
|
|
207
|
+
},
|
|
208
|
+
decimalsOf: (key) => {
|
|
209
|
+
const col = byKey.get(key);
|
|
210
|
+
if (!col)
|
|
211
|
+
return undefined;
|
|
212
|
+
return decimals[key] ?? col.format?.decimals;
|
|
213
|
+
},
|
|
214
|
+
codeOf: (row, key) => denominationOf(byKey.get(key), row),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { FieldConventions } from "@viewkitjs/fields";
|
|
3
|
+
import { type ViewsMessageResolver } from "../contract.js";
|
|
4
|
+
import type { ViewsAtoms } from "../atoms/types.js";
|
|
5
|
+
import type { FieldPresentation } from "../display/options.js";
|
|
6
|
+
import type { ViewsComponents } from "./components.js";
|
|
7
|
+
import type { ViewsIcons } from "./icons.js";
|
|
8
|
+
import { type ViewsPorts } from "./ports.js";
|
|
9
|
+
export { useViews, type ViewsContextValue } from "./context.js";
|
|
10
|
+
export type ViewsProviderProps = {
|
|
11
|
+
components: ViewsComponents;
|
|
12
|
+
icons: ViewsIcons;
|
|
13
|
+
ports: ViewsPorts;
|
|
14
|
+
conventions: FieldConventions;
|
|
15
|
+
/** The app's own atoms, each over the default of its name. Pass a module-level
|
|
16
|
+
* object: a new one each render re-renders every view. */
|
|
17
|
+
atoms?: Partial<ViewsAtoms>;
|
|
18
|
+
/** The app's wording for the package's own messages. Default: the package's English. */
|
|
19
|
+
messages?: ViewsMessageResolver;
|
|
20
|
+
/** How the app's numbers, dates and durations read: given the package's defaults, return the
|
|
21
|
+
* app's. It is called where a value is drawn, so the app's provider imports none of the
|
|
22
|
+
* display. Absent, the package's defaults in the conventions' locale. */
|
|
23
|
+
presentation?: (defaults: FieldPresentation) => FieldPresentation;
|
|
24
|
+
children: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { resolveViewsMessage } from "../contract.js";
|
|
5
|
+
import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
|
|
6
|
+
import { ViewsContext } from "./context.js";
|
|
7
|
+
import { withSettledGroups } from "./menu-groups.js";
|
|
8
|
+
import { browserConfirm } from "./ports.js";
|
|
9
|
+
export { useViews } from "./context.js";
|
|
10
|
+
export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, }) {
|
|
11
|
+
const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
|
|
12
|
+
const settled = useMemo(() => ({ ...components, Menu: withSettledGroups(components.Menu) }), [components]);
|
|
13
|
+
const resolved = useMemo(() => (ports.confirm ? ports : { ...ports, confirm: browserConfirm }), [ports]);
|
|
14
|
+
const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation }), [settled, merged, conventions, icons, resolved, messages, presentation]);
|
|
15
|
+
return _jsx(ViewsContext.Provider, { value: value, children: children });
|
|
16
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
import type { ComponentType, CSSProperties, KeyboardEvent as ReactKeyboardEvent, MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref, RefObject } from "react";
|
|
2
|
+
/** Where a floating part attaches: an element, a ref to one, or a point (a context menu). */
|
|
3
|
+
export type ViewsAnchor = HTMLElement | RefObject<HTMLElement | null> | {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
} | null;
|
|
7
|
+
export type ViewsSide = "top" | "right" | "bottom" | "left";
|
|
8
|
+
export type ViewsAlign = "start" | "center" | "end";
|
|
9
|
+
/** Why a floating part closed, by Base UI's names; an adapter maps its own reasons onto these,
|
|
10
|
+
* and any other reason is `none`. */
|
|
11
|
+
export type ViewsCloseReason = "trigger-press" | "outside-press" | "escape-key" | "focus-out" | "item-press" | "close-press" | "swipe" | "none";
|
|
12
|
+
export type ViewsOpenChange = (open: boolean, details?: {
|
|
13
|
+
reason?: ViewsCloseReason;
|
|
14
|
+
}) => void;
|
|
15
|
+
export type ViewsButtonProps = {
|
|
16
|
+
children?: ReactNode;
|
|
17
|
+
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
variant?: "default" | "ghost" | "outline" | "destructive";
|
|
20
|
+
size?: "default" | "sm" | "icon";
|
|
21
|
+
type?: "button" | "submit";
|
|
22
|
+
className?: string;
|
|
23
|
+
"aria-label"?: string;
|
|
24
|
+
title?: string;
|
|
25
|
+
};
|
|
26
|
+
export type ViewsPopoverProps = {
|
|
27
|
+
open: boolean;
|
|
28
|
+
onOpenChange: ViewsOpenChange;
|
|
29
|
+
anchor: ViewsAnchor;
|
|
30
|
+
side?: ViewsSide;
|
|
31
|
+
align?: ViewsAlign;
|
|
32
|
+
sideOffset?: number;
|
|
33
|
+
alignOffset?: number;
|
|
34
|
+
/** False keeps focus where it was when the popup opens (an editor that owns
|
|
35
|
+
* its own input); that editor focuses its input with `preventScroll`, so the
|
|
36
|
+
* page stays where it is however the popup places itself. Default true. */
|
|
37
|
+
initialFocus?: boolean;
|
|
38
|
+
/** Called on a press outside the popup before it closes; return false to keep it open.
|
|
39
|
+
* `event` is the pointer press, with its `target` where the press landed, also when the
|
|
40
|
+
* focus that press moves is what would close the popup: a vetoed press holds against its
|
|
41
|
+
* focus too. Focus leaving by keyboard (a Tab out) closes without asking. */
|
|
42
|
+
onOutsidePress?: (event: Event) => void | false;
|
|
43
|
+
/** Called on Escape before the popup closes; return false to keep it open. */
|
|
44
|
+
onEscape?: (event: KeyboardEvent) => void | false;
|
|
45
|
+
/** The popup's look. `panel` is the app's card popover; `menu` is its menu
|
|
46
|
+
* panel's surface, for a popover that holds a list: no inset (the list
|
|
47
|
+
* carries its own) and no card width (it is as wide as its list). Default
|
|
48
|
+
* `panel`. */
|
|
49
|
+
chrome?: "panel" | "menu";
|
|
50
|
+
/** A click inside the popup. A popup is a portal, so its clicks still bubble
|
|
51
|
+
* through the React tree to the anchor's row; the rendering stops them here. */
|
|
52
|
+
onPanelClick?: (event: ReactMouseEvent<HTMLDivElement>) => void;
|
|
53
|
+
/** `data-*` attributes set on the popup element, for the rendering's own selectors. */
|
|
54
|
+
panelData?: Readonly<Record<`data-${string}`, string>>;
|
|
55
|
+
/** The popup's own style, where a class cannot say it: a width that follows the cell it opens on. */
|
|
56
|
+
style?: CSSProperties;
|
|
57
|
+
className?: string;
|
|
58
|
+
children: ReactNode;
|
|
59
|
+
};
|
|
60
|
+
/** The app mounts one tooltip provider above the views; a tooltip never mounts its own. */
|
|
61
|
+
export type ViewsTooltipProps = {
|
|
62
|
+
content: ReactNode;
|
|
63
|
+
children: ReactElement;
|
|
64
|
+
side?: ViewsSide;
|
|
65
|
+
align?: ViewsAlign;
|
|
66
|
+
delayMs?: number;
|
|
67
|
+
className?: string;
|
|
68
|
+
};
|
|
69
|
+
export type ViewsCheckboxProps = {
|
|
70
|
+
checked: boolean;
|
|
71
|
+
/** Partly ticked: some, not all. The box draws its partial mark instead of the tick while this
|
|
72
|
+
* is true; a press on it while `checked` is false hands `true`. Default false. */
|
|
73
|
+
indeterminate?: boolean;
|
|
74
|
+
/** `details.event` is the press that changed it, as Base UI reports it — a list reads its
|
|
75
|
+
* `shiftKey` for a range. An adapter that cannot tell hands nothing. */
|
|
76
|
+
onCheckedChange: (checked: boolean, details?: {
|
|
77
|
+
event: Event;
|
|
78
|
+
}) => void;
|
|
79
|
+
/** The partial (indeterminate) mark's colour: `muted` (default), or `brand` for a select-all
|
|
80
|
+
* whose partial state is a live selection. */
|
|
81
|
+
partialTone?: "muted" | "brand";
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
className?: string;
|
|
84
|
+
tabIndex?: number;
|
|
85
|
+
"aria-label"?: string;
|
|
86
|
+
};
|
|
87
|
+
/** A menu is data: the app draws it with its own primitive. */
|
|
88
|
+
export type ViewsMenuItem = {
|
|
89
|
+
key: string;
|
|
90
|
+
label: ReactNode;
|
|
91
|
+
icon?: ReactNode;
|
|
92
|
+
onSelect?: () => void;
|
|
93
|
+
disabled?: boolean;
|
|
94
|
+
destructive?: boolean;
|
|
95
|
+
/** A checkable row: the app draws its tick. A checkable row closes the menu like any row. */
|
|
96
|
+
checked?: boolean;
|
|
97
|
+
/** A group: its rows drawn in place under this row's label, never a flyout. A group row is a
|
|
98
|
+
* label, not a target: its own `onSelect`, `href` and `checked` are ignored. A disabled group
|
|
99
|
+
* disables every row under it: the provider hands the app's `Menu` those rows already `disabled`. */
|
|
100
|
+
children?: ViewsMenuItem[];
|
|
101
|
+
separatorBefore?: boolean;
|
|
102
|
+
/** A keyboard hint drawn at the row's end, never bound by the menu. */
|
|
103
|
+
shortcut?: string;
|
|
104
|
+
/** A link item: the row is an anchor and `onSelect` still fires. */
|
|
105
|
+
href?: string;
|
|
106
|
+
};
|
|
107
|
+
/** Opens at `anchor`, with no trigger child and no flyouts: on Base UI, the menu's root,
|
|
108
|
+
* positioner and popup, the anchor handed to the positioner. */
|
|
109
|
+
export type ViewsMenuProps = {
|
|
110
|
+
open: boolean;
|
|
111
|
+
onOpenChange: ViewsOpenChange;
|
|
112
|
+
anchor: ViewsAnchor;
|
|
113
|
+
items: ViewsMenuItem[];
|
|
114
|
+
side?: ViewsSide;
|
|
115
|
+
align?: ViewsAlign;
|
|
116
|
+
className?: string;
|
|
117
|
+
};
|
|
118
|
+
/** The command list's parts, the shape both cmdk-based shadcn copies already have. */
|
|
119
|
+
export type ViewsCommandParts = {
|
|
120
|
+
Root: ComponentType<{
|
|
121
|
+
children: ReactNode;
|
|
122
|
+
className?: string;
|
|
123
|
+
label?: string;
|
|
124
|
+
/** False hands filtering to the host (a remote search already filtered). Default true. */
|
|
125
|
+
shouldFilter?: boolean;
|
|
126
|
+
/** Scores an item against the search: 0 hides it, higher ranks it first. */
|
|
127
|
+
filter?: (value: string, search: string) => number;
|
|
128
|
+
/** The arrows wrap from the last item to the first and back. Default false. */
|
|
129
|
+
loop?: boolean;
|
|
130
|
+
}>;
|
|
131
|
+
Input: ComponentType<{
|
|
132
|
+
value: string;
|
|
133
|
+
onValueChange: (value: string) => void;
|
|
134
|
+
placeholder?: string;
|
|
135
|
+
autoFocus?: boolean;
|
|
136
|
+
className?: string;
|
|
137
|
+
ref?: Ref<HTMLInputElement>;
|
|
138
|
+
onKeyDown?: (event: ReactKeyboardEvent<HTMLInputElement>) => void;
|
|
139
|
+
/** `search` draws the app's search row (its glyph and divider); `bare` draws
|
|
140
|
+
* the input alone, for a field that frames it itself. Default `search`. */
|
|
141
|
+
chrome?: "search" | "bare";
|
|
142
|
+
}>;
|
|
143
|
+
List: ComponentType<{
|
|
144
|
+
children: ReactNode;
|
|
145
|
+
className?: string;
|
|
146
|
+
}>;
|
|
147
|
+
Empty: ComponentType<{
|
|
148
|
+
children: ReactNode;
|
|
149
|
+
className?: string;
|
|
150
|
+
}>;
|
|
151
|
+
Group: ComponentType<{
|
|
152
|
+
children: ReactNode;
|
|
153
|
+
heading?: ReactNode;
|
|
154
|
+
className?: string;
|
|
155
|
+
}>;
|
|
156
|
+
Item: ComponentType<{
|
|
157
|
+
value: string;
|
|
158
|
+
onSelect: (value: string) => void;
|
|
159
|
+
disabled?: boolean;
|
|
160
|
+
/** The value this item stands for is the current one. The app colours the item as its
|
|
161
|
+
* chosen row; the check is the package's, drawn by the row inside, so the item draws no
|
|
162
|
+
* tick of its own. */
|
|
163
|
+
chosen?: boolean;
|
|
164
|
+
children: ReactNode;
|
|
165
|
+
className?: string;
|
|
166
|
+
}>;
|
|
167
|
+
};
|
|
168
|
+
/** A calendar over ISO days (`YYYY-MM-DD`) and months (`YYYY-MM`); the app's date library stays its own. */
|
|
169
|
+
export type ViewsCalendarProps = {
|
|
170
|
+
value: string | null;
|
|
171
|
+
onChange: (day: string | null) => void;
|
|
172
|
+
min?: string;
|
|
173
|
+
max?: string;
|
|
174
|
+
/** The month shown. Controlled with `onMonthChange`; without it the calendar keeps its own. */
|
|
175
|
+
month?: string;
|
|
176
|
+
onMonthChange?: (month: string) => void;
|
|
177
|
+
/** `dropdown` draws month and year pickers in the caption. Default `label`. */
|
|
178
|
+
captionLayout?: "label" | "dropdown";
|
|
179
|
+
/** The first and last months the caption's pickers offer. */
|
|
180
|
+
startMonth?: string;
|
|
181
|
+
endMonth?: string;
|
|
182
|
+
/** The conventions' locale (BCP 47). The calendar draws its month and weekday names and starts
|
|
183
|
+
* its week as this locale does; an adapter may ignore it and keep its calendar's own. */
|
|
184
|
+
locale: string;
|
|
185
|
+
className?: string;
|
|
186
|
+
};
|
|
187
|
+
export type ViewsCollapseProps = {
|
|
188
|
+
open: boolean;
|
|
189
|
+
children: ReactNode;
|
|
190
|
+
className?: string;
|
|
191
|
+
/** A class on the box that crops the content (a bleed, a padding the crop must not shave). */
|
|
192
|
+
clipClassName?: string;
|
|
193
|
+
durationMs?: number;
|
|
194
|
+
};
|
|
195
|
+
/** A phone sheet. `snap` is a hint: an app whose sheet has no snap points ignores it. */
|
|
196
|
+
export type ViewsSheetProps = {
|
|
197
|
+
open: boolean;
|
|
198
|
+
onOpenChange: ViewsOpenChange;
|
|
199
|
+
title?: ReactNode;
|
|
200
|
+
description?: string;
|
|
201
|
+
snap?: "full" | "half" | "peek" | "auto";
|
|
202
|
+
className?: string;
|
|
203
|
+
children: ReactNode;
|
|
204
|
+
};
|
|
205
|
+
export type ViewsComponents = {
|
|
206
|
+
Button: ComponentType<ViewsButtonProps>;
|
|
207
|
+
Popover: ComponentType<ViewsPopoverProps>;
|
|
208
|
+
Tooltip: ComponentType<ViewsTooltipProps>;
|
|
209
|
+
Checkbox: ComponentType<ViewsCheckboxProps>;
|
|
210
|
+
Menu: ComponentType<ViewsMenuProps>;
|
|
211
|
+
Command: ViewsCommandParts;
|
|
212
|
+
Calendar: ComponentType<ViewsCalendarProps>;
|
|
213
|
+
Collapse: ComponentType<ViewsCollapseProps>;
|
|
214
|
+
Sheet: ComponentType<ViewsSheetProps>;
|
|
215
|
+
/** The app's own icon component by the app's own names, for glyphs a host
|
|
216
|
+
* declares (`rowIcon`, a binding's `icon`). It draws on the first paint,
|
|
217
|
+
* because rows are measured as they mount: map the names from a static
|
|
218
|
+
* record, never icons loaded on demand. Semantic glyphs use `icons`. */
|
|
219
|
+
AppIcon: ComponentType<{
|
|
220
|
+
name: string;
|
|
221
|
+
className?: string;
|
|
222
|
+
}>;
|
|
223
|
+
/** The app's own markdown renderer, for rich text: the package draws no
|
|
224
|
+
* markdown itself (it may import only React and zod). `source` is the stored
|
|
225
|
+
* markdown, whole. */
|
|
226
|
+
Markdown: ComponentType<{
|
|
227
|
+
source: string;
|
|
228
|
+
className?: string;
|
|
229
|
+
}>;
|
|
230
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { FieldConventions } from "@viewkitjs/fields";
|
|
2
|
+
import type { ViewsMessageResolver } from "../contract.js";
|
|
3
|
+
import type { ViewsAtoms } from "../atoms/types.js";
|
|
4
|
+
import type { FieldPresentation } from "../display/options.js";
|
|
5
|
+
import type { ViewsComponents } from "./components.js";
|
|
6
|
+
import type { ViewsIcons } from "./icons.js";
|
|
7
|
+
import type { ViewsResolvedPorts } from "./ports.js";
|
|
8
|
+
export type ViewsContextValue = {
|
|
9
|
+
components: ViewsComponents;
|
|
10
|
+
atoms: ViewsAtoms;
|
|
11
|
+
icons: ViewsIcons;
|
|
12
|
+
/** The app's ports, with `confirm` always a function (the browser's where the app handed none). */
|
|
13
|
+
ports: ViewsResolvedPorts;
|
|
14
|
+
messages: ViewsMessageResolver;
|
|
15
|
+
conventions: FieldConventions;
|
|
16
|
+
/** The app's formatting: given the package's defaults, return the app's. */
|
|
17
|
+
presentation?: (defaults: FieldPresentation) => FieldPresentation;
|
|
18
|
+
};
|
|
19
|
+
export declare const ViewsContext: import("react").Context<ViewsContextValue | null>;
|
|
20
|
+
export declare function useViews(): ViewsContextValue;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
export const ViewsContext = createContext(null);
|
|
4
|
+
export function useViews() {
|
|
5
|
+
const value = useContext(ViewsContext);
|
|
6
|
+
if (!value) {
|
|
7
|
+
throw new Error("useViews() needs a <ViewsProvider> above it: mount one at the app's client root with its components, icons, ports and conventions.");
|
|
8
|
+
}
|
|
9
|
+
return value;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ComponentType } from "react";
|
|
2
|
+
import type { ViewsMenuItem, ViewsMenuProps } from "./components.js";
|
|
3
|
+
/** The items with every row under a disabled group marked `disabled`, at every depth. Only the
|
|
4
|
+
* path to a disabled group is copied; with none, the same array comes back. */
|
|
5
|
+
export declare function settleMenuGroups(items: ViewsMenuItem[]): ViewsMenuItem[];
|
|
6
|
+
/** The app's Menu, handed its items settled. One wrapper per app Menu, so an open menu never
|
|
7
|
+
* remounts; a wrapper handed in again (a nested provider) comes back as it is. */
|
|
8
|
+
export declare function withSettledGroups(Menu: ComponentType<ViewsMenuProps>): ComponentType<ViewsMenuProps>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { createElement, useMemo } from "react";
|
|
2
|
+
function disableAll(items) {
|
|
3
|
+
return items.map((item) => ({
|
|
4
|
+
...item,
|
|
5
|
+
disabled: true,
|
|
6
|
+
...(item.children && { children: disableAll(item.children) }),
|
|
7
|
+
}));
|
|
8
|
+
}
|
|
9
|
+
export function settleMenuGroups(items) {
|
|
10
|
+
let changed = false;
|
|
11
|
+
const settled = items.map((item) => {
|
|
12
|
+
if (!item.children || item.children.length === 0)
|
|
13
|
+
return item;
|
|
14
|
+
const children = item.disabled ? disableAll(item.children) : settleMenuGroups(item.children);
|
|
15
|
+
if (children === item.children)
|
|
16
|
+
return item;
|
|
17
|
+
changed = true;
|
|
18
|
+
return { ...item, children };
|
|
19
|
+
});
|
|
20
|
+
return changed ? settled : items;
|
|
21
|
+
}
|
|
22
|
+
const wrappers = new WeakMap();
|
|
23
|
+
const settledMenus = new WeakSet();
|
|
24
|
+
export function withSettledGroups(Menu) {
|
|
25
|
+
if (settledMenus.has(Menu))
|
|
26
|
+
return Menu;
|
|
27
|
+
const known = wrappers.get(Menu);
|
|
28
|
+
if (known)
|
|
29
|
+
return known;
|
|
30
|
+
function SettledMenu(props) {
|
|
31
|
+
const items = useMemo(() => settleMenuGroups(props.items), [props.items]);
|
|
32
|
+
return createElement(Menu, { ...props, items });
|
|
33
|
+
}
|
|
34
|
+
SettledMenu.displayName = `Settled(${Menu.displayName ?? (Menu.name || "Menu")})`;
|
|
35
|
+
wrappers.set(Menu, SettledMenu);
|
|
36
|
+
settledMenus.add(SettledMenu);
|
|
37
|
+
return SettledMenu;
|
|
38
|
+
}
|