@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,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { fieldKeyOf } from "../model/view-rules.js";
|
|
4
|
+
import { GRID_SCALE_MULTIPLIER } from "./core/grid-scale.js";
|
|
5
|
+
import { normalizeGroupSummary, setAggregate, setDateStyle, setCurrency, setDecimals, setDurationStyle, setOptionColor, setPercentDisplay, setShowTime, } from "../model/preferences.js";
|
|
6
|
+
import { moneyReadingOf } from "../fields/money.js";
|
|
7
|
+
import { isMoneyReading, MONEY_READING_OPTIONS } from "../fields/currency.js";
|
|
8
|
+
export function useGridTablePrefs({ prefs, setPrefs, columns, viewBacked = false, }) {
|
|
9
|
+
const { gridVerticalBorders, gridRowIcon, gridFreezeIdentity, gridWrapCells, gridAlwaysCheckboxes, gridOptionColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals, gridCurrencies, gridAggregates, gridColumns, gridScale, groupSummary, } = prefs;
|
|
10
|
+
const onOptionColorChange = useCallback((key, value, color) => {
|
|
11
|
+
setPrefs({ gridOptionColors: setOptionColor(gridOptionColors, key, value, color) });
|
|
12
|
+
}, [gridOptionColors, setPrefs]);
|
|
13
|
+
const onDateStyleChange = useCallback((key, style) => setPrefs({ gridDateStyles: setDateStyle(gridDateStyles, key, style) }), [gridDateStyles, setPrefs]);
|
|
14
|
+
const onDurationStyleChange = useCallback((key, style) => setPrefs({ gridDurationStyles: setDurationStyle(gridDurationStyles, key, style) }), [gridDurationStyles, setPrefs]);
|
|
15
|
+
const onShowTimeChange = useCallback((key, show) => setPrefs({ gridShowTime: setShowTime(gridShowTime, key, show) }), [gridShowTime, setPrefs]);
|
|
16
|
+
const onPercentDisplayChange = useCallback((key, display) => setPrefs({ gridPercentDisplays: setPercentDisplay(gridPercentDisplays, key, display) }), [gridPercentDisplays, setPrefs]);
|
|
17
|
+
const onColumnStateChange = useCallback((next) => setPrefs({ gridColumns: next }), [setPrefs]);
|
|
18
|
+
const summaryParts = useMemo(() => normalizeGroupSummary(groupSummary), [groupSummary]);
|
|
19
|
+
const onGroupSummaryChange = useCallback((part, next) => setPrefs({
|
|
20
|
+
groupSummary: next
|
|
21
|
+
? Array.from(new Set([...normalizeGroupSummary(groupSummary), part]))
|
|
22
|
+
: normalizeGroupSummary(groupSummary).filter((p) => p !== part),
|
|
23
|
+
}), [groupSummary, setPrefs]);
|
|
24
|
+
const onAggregateChange = useCallback((columnId, kind) => setPrefs({ gridAggregates: setAggregate(gridAggregates, columnId, kind) }), [gridAggregates, setPrefs]);
|
|
25
|
+
const numberFormats = useMemo(() => {
|
|
26
|
+
const out = {};
|
|
27
|
+
for (const col of columns) {
|
|
28
|
+
const key = fieldKeyOf(col);
|
|
29
|
+
const reading = moneyReadingOf(col);
|
|
30
|
+
if (gridDecimals[key] === undefined && !reading)
|
|
31
|
+
continue;
|
|
32
|
+
out[key] = {
|
|
33
|
+
decimals: gridDecimals[key],
|
|
34
|
+
...(reading ? { currency: reading, currencyOptions: MONEY_READING_OPTIONS } : {}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
return out;
|
|
38
|
+
}, [columns, gridDecimals]);
|
|
39
|
+
const onNumberFormatChange = useCallback((key, patch) => {
|
|
40
|
+
if (patch.currency != null && isMoneyReading(patch.currency))
|
|
41
|
+
setPrefs({ gridCurrencies: setCurrency(gridCurrencies, key, patch.currency) });
|
|
42
|
+
if (patch.decimals === null)
|
|
43
|
+
setPrefs({ gridDecimals: { [key]: null } });
|
|
44
|
+
else if (patch.decimals !== undefined)
|
|
45
|
+
setPrefs({ gridDecimals: setDecimals(gridDecimals, key, patch.decimals) });
|
|
46
|
+
}, [gridCurrencies, gridDecimals, setPrefs]);
|
|
47
|
+
const gridProps = useMemo(() => ({
|
|
48
|
+
verticalBorders: gridVerticalBorders,
|
|
49
|
+
showRowIcon: gridRowIcon,
|
|
50
|
+
freezeIdentity: gridFreezeIdentity,
|
|
51
|
+
wrapCells: gridWrapCells,
|
|
52
|
+
alwaysCheckboxes: gridAlwaysCheckboxes,
|
|
53
|
+
scale: GRID_SCALE_MULTIPLIER[gridScale],
|
|
54
|
+
optionColors: gridOptionColors,
|
|
55
|
+
onOptionColorChange,
|
|
56
|
+
dateStyles: gridDateStyles,
|
|
57
|
+
onDateStyleChange,
|
|
58
|
+
durationStyles: gridDurationStyles,
|
|
59
|
+
onDurationStyleChange,
|
|
60
|
+
showTimeOverrides: gridShowTime,
|
|
61
|
+
onShowTimeChange,
|
|
62
|
+
percentDisplays: gridPercentDisplays,
|
|
63
|
+
onPercentDisplayChange,
|
|
64
|
+
columnState: gridColumns,
|
|
65
|
+
onColumnStateChange,
|
|
66
|
+
groupSummary: summaryParts,
|
|
67
|
+
onGroupSummaryChange,
|
|
68
|
+
aggregates: gridAggregates,
|
|
69
|
+
onAggregateChange,
|
|
70
|
+
viewBacked,
|
|
71
|
+
numberFormats,
|
|
72
|
+
onNumberFormatChange,
|
|
73
|
+
}), [
|
|
74
|
+
gridVerticalBorders,
|
|
75
|
+
gridRowIcon,
|
|
76
|
+
gridFreezeIdentity,
|
|
77
|
+
gridWrapCells,
|
|
78
|
+
gridAlwaysCheckboxes,
|
|
79
|
+
gridScale,
|
|
80
|
+
gridOptionColors,
|
|
81
|
+
onOptionColorChange,
|
|
82
|
+
gridDateStyles,
|
|
83
|
+
onDateStyleChange,
|
|
84
|
+
gridDurationStyles,
|
|
85
|
+
onDurationStyleChange,
|
|
86
|
+
gridShowTime,
|
|
87
|
+
onShowTimeChange,
|
|
88
|
+
gridPercentDisplays,
|
|
89
|
+
onPercentDisplayChange,
|
|
90
|
+
gridColumns,
|
|
91
|
+
onColumnStateChange,
|
|
92
|
+
summaryParts,
|
|
93
|
+
onGroupSummaryChange,
|
|
94
|
+
gridAggregates,
|
|
95
|
+
onAggregateChange,
|
|
96
|
+
viewBacked,
|
|
97
|
+
numberFormats,
|
|
98
|
+
onNumberFormatChange,
|
|
99
|
+
]);
|
|
100
|
+
return { gridProps };
|
|
101
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** `manual`: the reader's own order, by stored positions (POR-498). Only the
|
|
2
|
+
* source list orders by it; `sortGroupEntries` below treats it as `name`. */
|
|
3
|
+
export type OrderMode = "lifecycle" | "count" | "name" | "manual";
|
|
4
|
+
export type OrderDir = "asc" | "desc";
|
|
5
|
+
export type OrderChoice = {
|
|
6
|
+
mode: OrderMode;
|
|
7
|
+
dir: OrderDir;
|
|
8
|
+
};
|
|
9
|
+
/** The natural direction for a mode. Used to seed dir when a user picks a new mode. */
|
|
10
|
+
export declare function defaultDirFor(mode: OrderMode): OrderDir;
|
|
11
|
+
type Entry<K extends string> = [key: K, items: unknown[]];
|
|
12
|
+
export declare function sortGroupEntries<K extends string>(entries: Entry<K>[], opts: {
|
|
13
|
+
order: OrderChoice;
|
|
14
|
+
lifecycleIndex?: Partial<Record<K, number>>;
|
|
15
|
+
label?: (key: K) => string;
|
|
16
|
+
uncategorizedKey?: K;
|
|
17
|
+
}): Entry<K>[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export function defaultDirFor(mode) {
|
|
2
|
+
return mode === "count" ? "desc" : "asc";
|
|
3
|
+
}
|
|
4
|
+
export function sortGroupEntries(entries, opts) {
|
|
5
|
+
const { order, lifecycleIndex, label, uncategorizedKey } = opts;
|
|
6
|
+
const labelOf = label ?? ((k) => String(k));
|
|
7
|
+
const reverse = order.dir !== defaultDirFor(order.mode) ? -1 : 1;
|
|
8
|
+
const arr = [...entries];
|
|
9
|
+
arr.sort(([a, aItems], [b, bItems]) => {
|
|
10
|
+
if (uncategorizedKey !== undefined) {
|
|
11
|
+
if (a === uncategorizedKey)
|
|
12
|
+
return 1;
|
|
13
|
+
if (b === uncategorizedKey)
|
|
14
|
+
return -1;
|
|
15
|
+
}
|
|
16
|
+
let base = 0;
|
|
17
|
+
if (order.mode === "count") {
|
|
18
|
+
base = bItems.length - aItems.length;
|
|
19
|
+
}
|
|
20
|
+
else if (order.mode === "lifecycle") {
|
|
21
|
+
const ai = lifecycleIndex?.[a] ?? 99;
|
|
22
|
+
const bi = lifecycleIndex?.[b] ?? 99;
|
|
23
|
+
base = ai - bi;
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
base = labelOf(a).localeCompare(labelOf(b));
|
|
27
|
+
}
|
|
28
|
+
if (base !== 0)
|
|
29
|
+
return base * reverse;
|
|
30
|
+
return labelOf(a).localeCompare(labelOf(b));
|
|
31
|
+
});
|
|
32
|
+
return arr;
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GroupFigures } from "../figures.js";
|
|
2
|
+
/** A group of rows, already filtered/sorted/grouped by the caller's controller. */
|
|
3
|
+
export type ListGroup<Row> = {
|
|
4
|
+
key: string;
|
|
5
|
+
label: string | null;
|
|
6
|
+
items: Row[];
|
|
7
|
+
/** The database's figures over the WHOLE group, when a source list answered
|
|
8
|
+
* them (POR-470). Absent where the rows in hand are the group. */
|
|
9
|
+
figures?: GroupFigures;
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "./contract.js";
|
|
2
|
+
export * from "./model/index.js";
|
|
3
|
+
export * from "./model/card-density.js";
|
|
4
|
+
export * from "./model/card-layout.js";
|
|
5
|
+
export * from "./model/column-format.js";
|
|
6
|
+
export * from "./model/column-inspect.js";
|
|
7
|
+
export * from "./model/column-money.js";
|
|
8
|
+
export * from "./filters/registry.js";
|
|
9
|
+
export * from "./filters/text-filter.js";
|
|
10
|
+
export * from "./filters/number-filter.js";
|
|
11
|
+
export * from "./filters/range-filter.js";
|
|
12
|
+
export * from "./filters/date-filter.js";
|
|
13
|
+
export * from "./filters/filter-model.js";
|
|
14
|
+
export * from "./filters/relation-filter.js";
|
|
15
|
+
export * from "./model/relation-filters.js";
|
|
16
|
+
export * from "./figures.js";
|
|
17
|
+
export * from "./grouping/types.js";
|
|
18
|
+
export * from "./grouping/sort-groups.js";
|
|
19
|
+
export * from "./fields/binding.js";
|
|
20
|
+
export * from "./fields/money.js";
|
|
21
|
+
export * from "./fields/currency.js";
|
|
22
|
+
export * from "./fields/denomination.js";
|
|
23
|
+
export * from "./fields/prepare-write.js";
|
|
24
|
+
export * from "./fields/edit-core-types.js";
|
|
25
|
+
export * from "./fields/number-edit.js";
|
|
26
|
+
export * from "./fields/format-knobs.js";
|
|
27
|
+
export * from "./fields/relation-source-types.js";
|
|
28
|
+
export * from "./fields/menus.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export * from "./contract.js";
|
|
2
|
+
export * from "./model/index.js";
|
|
3
|
+
export * from "./model/card-density.js";
|
|
4
|
+
export * from "./model/card-layout.js";
|
|
5
|
+
export * from "./model/column-format.js";
|
|
6
|
+
export * from "./model/column-inspect.js";
|
|
7
|
+
export * from "./model/column-money.js";
|
|
8
|
+
export * from "./filters/registry.js";
|
|
9
|
+
export * from "./filters/text-filter.js";
|
|
10
|
+
export * from "./filters/number-filter.js";
|
|
11
|
+
export * from "./filters/range-filter.js";
|
|
12
|
+
export * from "./filters/date-filter.js";
|
|
13
|
+
export * from "./filters/filter-model.js";
|
|
14
|
+
export * from "./filters/relation-filter.js";
|
|
15
|
+
export * from "./model/relation-filters.js";
|
|
16
|
+
export * from "./figures.js";
|
|
17
|
+
export * from "./grouping/types.js";
|
|
18
|
+
export * from "./grouping/sort-groups.js";
|
|
19
|
+
export * from "./fields/binding.js";
|
|
20
|
+
export * from "./fields/money.js";
|
|
21
|
+
export * from "./fields/currency.js";
|
|
22
|
+
export * from "./fields/denomination.js";
|
|
23
|
+
export * from "./fields/prepare-write.js";
|
|
24
|
+
export * from "./fields/edit-core-types.js";
|
|
25
|
+
export * from "./fields/number-edit.js";
|
|
26
|
+
export * from "./fields/format-knobs.js";
|
|
27
|
+
export * from "./fields/relation-source-types.js";
|
|
28
|
+
export * from "./fields/menus.js";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { cx } from "./cx.js";
|
|
2
|
+
export const CHIP_BASE = "flex min-w-0 items-center gap-1.5";
|
|
3
|
+
export const CHIP_INTERACTIVE = cx(CHIP_BASE, "rounded-sm text-left transition-colors", "text-inherit", "hover:text-(color:--vk-fg-brand) hover:[&>span]:underline hover:[&>span]:decoration-(color:--vk-fg-brand)", "[&>span]:underline-offset-[3px]");
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** True below 768px wide, from the first effect on; false during a server render. */
|
|
2
|
+
export declare function useIsMobile(): boolean;
|
|
3
|
+
/** True when the primary input can hover (a mouse, a trackpad); true during a server render, so
|
|
4
|
+
* the hover-capable rendering is what the server sends. */
|
|
5
|
+
export declare function useHasHover(): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
const MOBILE_BREAKPOINT = 768;
|
|
4
|
+
export function useIsMobile() {
|
|
5
|
+
const [isMobile, setIsMobile] = useState(undefined);
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
8
|
+
const onChange = () => {
|
|
9
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
10
|
+
};
|
|
11
|
+
mql.addEventListener("change", onChange);
|
|
12
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
13
|
+
return () => mql.removeEventListener("change", onChange);
|
|
14
|
+
}, []);
|
|
15
|
+
return !!isMobile;
|
|
16
|
+
}
|
|
17
|
+
export function useHasHover() {
|
|
18
|
+
const [hasHover, setHasHover] = useState(true);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
21
|
+
return;
|
|
22
|
+
const mq = window.matchMedia("(hover: hover) and (pointer: fine)");
|
|
23
|
+
setHasHover(mq.matches);
|
|
24
|
+
const handler = (e) => setHasHover(e.matches);
|
|
25
|
+
mq.addEventListener("change", handler);
|
|
26
|
+
return () => mq.removeEventListener("change", handler);
|
|
27
|
+
}, []);
|
|
28
|
+
return hasHover;
|
|
29
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type ViewsMessageResolver } from "../contract.js";
|
|
2
|
+
import { type DisplayCurrency } from "../fields/currency.js";
|
|
3
|
+
import type { ListAggregateKind, ListColumn } from "./column-schema.js";
|
|
4
|
+
/** A figure's name, as the app words it: `views.grid.figure`. */
|
|
5
|
+
export declare function aggregateLabel(kind: ListAggregateKind, messages?: ViewsMessageResolver): string;
|
|
6
|
+
/** The figures' names in the package's English. A grid reads `aggregateLabel` with the provider's `messages`. */
|
|
7
|
+
export declare const LIST_AGGREGATE_LABELS: Record<Exclude<ListAggregateKind, "none">, string>;
|
|
8
|
+
export declare function gridColumnIsNumericAgg<Row>(col: ListColumn<Row>): boolean;
|
|
9
|
+
/** A source list's footer (POR-470, POR-472): the keys whose figures the
|
|
10
|
+
* database answered, and the reader's default currency — the key a money
|
|
11
|
+
* column read in Original is totalled under. */
|
|
12
|
+
export type SourcedAggregates = {
|
|
13
|
+
totalled: ReadonlySet<string>;
|
|
14
|
+
defaultCurrency: DisplayCurrency;
|
|
15
|
+
};
|
|
16
|
+
/** The key a column's database figure is read under: a convertible money
|
|
17
|
+
* column's in the currency it shows — the reader's default under Original —
|
|
18
|
+
* else its field's — or the field its footer names (`footerField`). The
|
|
19
|
+
* server's `moneyFigureKey` writes the same key. */
|
|
20
|
+
export declare function figureKeyOf<Row>(col: ListColumn<Row>, defaultCurrency: DisplayCurrency): string;
|
|
21
|
+
/**
|
|
22
|
+
* The aggregates a column offers. A PERCENT never offers `sum` — adding
|
|
23
|
+
* percents is meaningless — and offers `ratio` only when the column carries the
|
|
24
|
+
* two readers (a ratio formula): sum over sum is the honest total for a
|
|
25
|
+
* percent-of-something, where `avg` weights every row alike. The rule reads
|
|
26
|
+
* the column's value type — a bound column's field, a field-less column's own.
|
|
27
|
+
*/
|
|
28
|
+
export declare function aggregateOptions<Row>(col: ListColumn<Row>, sourced?: SourcedAggregates): ListAggregateKind[];
|
|
29
|
+
export declare function resolveAggregateKind<Row>(col: ListColumn<Row>, prefs?: Readonly<Record<string, ListAggregateKind>>, sourced?: SourcedAggregates): ListAggregateKind;
|
|
30
|
+
export declare function computeAggregate<Row>(kind: ListAggregateKind, col: ListColumn<Row>, rows: readonly Row[]): number | null;
|
|
31
|
+
/** One figure, and the currency it is in. */
|
|
32
|
+
export type MoneyTotal = {
|
|
33
|
+
amount: number;
|
|
34
|
+
code: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* ONE number for a money column's total — never a list per currency.
|
|
38
|
+
*
|
|
39
|
+
* A column read in a currency totals in that currency: its accessors already
|
|
40
|
+
* converted every row (`readMoneyColumn`), so the ordinary reduction is right
|
|
41
|
+
* and the code is the column's own. A column read in ORIGINAL keeps each cell
|
|
42
|
+
* in its own currency, but a total over mixed currencies is either one
|
|
43
|
+
* converted figure or nothing, and the list chose one figure: each row's
|
|
44
|
+
* figure is converted into the reader's DEFAULT currency, for the total only.
|
|
45
|
+
* A money column that carries no rates and no single code (a per-row column
|
|
46
|
+
* nothing can convert) answers `null` — nothing honest to draw.
|
|
47
|
+
*
|
|
48
|
+
* `undefined` means "not this function's question": a non-money column, or a
|
|
49
|
+
* kind that is not numeric (a count is a count in any currency). The footer
|
|
50
|
+
* takes `computeAggregate` for those.
|
|
51
|
+
*/
|
|
52
|
+
export declare function moneyTotal<Row>(kind: ListAggregateKind, col: ListColumn<Row>, rows: readonly Row[], defaultCurrency: DisplayCurrency): MoneyTotal | null | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* The currency a money column's DATABASE figure is drawn in — `moneyTotal`'s
|
|
55
|
+
* choice, without the rows: under Original, the reader's default currency (the
|
|
56
|
+
* source totals the column converted into it); read in a currency, the
|
|
57
|
+
* column's code; a per-row column nothing can convert, null (no figure).
|
|
58
|
+
*/
|
|
59
|
+
export declare function moneyFigureCode<Row>(col: ListColumn<Row>, defaultCurrency: DisplayCurrency): string | undefined | null;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { isMultipleType, locationText, nameText, presentedDef, scalarOf, valueItems, valueKey, } from "@viewkitjs/fields";
|
|
2
|
+
import { phoneMatchText } from "@viewkitjs/fields/phone";
|
|
3
|
+
import { resolveViewsMessage } from "../contract.js";
|
|
4
|
+
import { COLUMN_WIDE_CODE } from "../fields/denomination.js";
|
|
5
|
+
import { convertMoney } from "../fields/money.js";
|
|
6
|
+
import { ORIGINAL_READING } from "../fields/currency.js";
|
|
7
|
+
import { fieldTypeOf } from "./field-type-of.js";
|
|
8
|
+
import { fieldKeyOf } from "./view-rules.js";
|
|
9
|
+
export function aggregateLabel(kind, messages = resolveViewsMessage) {
|
|
10
|
+
return messages({ key: "views.grid.figure", values: { kind } });
|
|
11
|
+
}
|
|
12
|
+
export const LIST_AGGREGATE_LABELS = {
|
|
13
|
+
sum: aggregateLabel("sum"),
|
|
14
|
+
avg: aggregateLabel("avg"),
|
|
15
|
+
min: aggregateLabel("min"),
|
|
16
|
+
max: aggregateLabel("max"),
|
|
17
|
+
count: aggregateLabel("count"),
|
|
18
|
+
filled: aggregateLabel("filled"),
|
|
19
|
+
unique: aggregateLabel("unique"),
|
|
20
|
+
ratio: aggregateLabel("ratio"),
|
|
21
|
+
};
|
|
22
|
+
const NUMERIC = new Set(["number", "percent", "currency"]);
|
|
23
|
+
export function gridColumnIsNumericAgg(col) {
|
|
24
|
+
return !!col.aggAccessor || NUMERIC.has(fieldTypeOf(col));
|
|
25
|
+
}
|
|
26
|
+
export function figureKeyOf(col, defaultCurrency) {
|
|
27
|
+
const key = col.footerField ?? fieldKeyOf(col);
|
|
28
|
+
if (!col.money)
|
|
29
|
+
return key;
|
|
30
|
+
const currency = col.reading && col.reading !== ORIGINAL_READING ? col.reading : defaultCurrency;
|
|
31
|
+
return `${key}.${currency}`;
|
|
32
|
+
}
|
|
33
|
+
function isOneCurrencyField(field) {
|
|
34
|
+
const shown = presentedDef(field);
|
|
35
|
+
const code = shown.type === "currency" ? shown.code : undefined;
|
|
36
|
+
return !!code && "fixed" in code;
|
|
37
|
+
}
|
|
38
|
+
function sourceCanTotal(col) {
|
|
39
|
+
if (!col.field || !gridColumnIsNumericAgg(col))
|
|
40
|
+
return false;
|
|
41
|
+
if (fieldTypeOf(col) !== "currency")
|
|
42
|
+
return true;
|
|
43
|
+
return !!col.money || isOneCurrencyField(col.field);
|
|
44
|
+
}
|
|
45
|
+
export function aggregateOptions(col, sourced) {
|
|
46
|
+
const offered = typeOptions(col, sourced);
|
|
47
|
+
const named = col.footerKinds;
|
|
48
|
+
return named ? offered.filter((kind) => kind === "none" || named.includes(kind)) : offered;
|
|
49
|
+
}
|
|
50
|
+
function typeOptions(col, sourced) {
|
|
51
|
+
if (sourced) {
|
|
52
|
+
const totalled = sourceCanTotal(col) ||
|
|
53
|
+
(gridColumnIsNumericAgg(col) && sourced.totalled.has(figureKeyOf(col, sourced.defaultCurrency)));
|
|
54
|
+
if (!totalled)
|
|
55
|
+
return col.ratio ? ["none", "ratio", "count"] : ["none", "count"];
|
|
56
|
+
if (fieldTypeOf(col) === "percent")
|
|
57
|
+
return col.ratio
|
|
58
|
+
? ["none", "ratio", "avg", "min", "max", "count"]
|
|
59
|
+
: ["none", "avg", "min", "max", "count"];
|
|
60
|
+
return ["none", "sum", "avg", "min", "max", "count"];
|
|
61
|
+
}
|
|
62
|
+
if (fieldTypeOf(col) === "percent") {
|
|
63
|
+
return col.ratio
|
|
64
|
+
? ["none", "ratio", "avg", "min", "max", "count"]
|
|
65
|
+
: ["none", "avg", "min", "max", "count"];
|
|
66
|
+
}
|
|
67
|
+
return gridColumnIsNumericAgg(col)
|
|
68
|
+
? ["none", "sum", "avg", "min", "max", "count"]
|
|
69
|
+
: ["none", "count", "filled", "unique"];
|
|
70
|
+
}
|
|
71
|
+
export function resolveAggregateKind(col, prefs, sourced) {
|
|
72
|
+
const options = aggregateOptions(col, sourced);
|
|
73
|
+
const chosen = prefs?.[col.id];
|
|
74
|
+
if (chosen && options.includes(chosen))
|
|
75
|
+
return chosen;
|
|
76
|
+
if (col.ratio && options.includes("ratio"))
|
|
77
|
+
return "ratio";
|
|
78
|
+
const declared = col.defaultAggregate;
|
|
79
|
+
if (!declared || !options.includes(declared))
|
|
80
|
+
return "none";
|
|
81
|
+
if (sourced && declared !== "count" && !sourced.totalled.has(figureKeyOf(col, sourced.defaultCurrency)))
|
|
82
|
+
return "none";
|
|
83
|
+
return declared;
|
|
84
|
+
}
|
|
85
|
+
export function computeAggregate(kind, col, rows) {
|
|
86
|
+
if (kind === "none")
|
|
87
|
+
return null;
|
|
88
|
+
if (kind === "count")
|
|
89
|
+
return rows.length;
|
|
90
|
+
if (kind === "filled" || kind === "unique") {
|
|
91
|
+
const type = fieldTypeOf(col);
|
|
92
|
+
if (col.multiple && isMultipleType(type)) {
|
|
93
|
+
const lists = rows
|
|
94
|
+
.map((row) => {
|
|
95
|
+
const value = col.accessor?.(row);
|
|
96
|
+
const one = Array.isArray(value) ? valueItems(value) : valueItems([value]);
|
|
97
|
+
return one.map((item) => valueKey(item.value, type));
|
|
98
|
+
})
|
|
99
|
+
.filter((keys) => keys.length > 0);
|
|
100
|
+
if (kind === "filled")
|
|
101
|
+
return lists.length;
|
|
102
|
+
return new Set(lists.map((keys) => [...keys].sort().join("|"))).size;
|
|
103
|
+
}
|
|
104
|
+
const asText = type === "location" ? locationText : type === "name" ? nameText : type === "phone" ? phoneMatchText : undefined;
|
|
105
|
+
const written = (value) => !asText ? value : Array.isArray(value) ? value.map((item) => asText(item)).filter(Boolean) : asText(value);
|
|
106
|
+
const values = rows
|
|
107
|
+
.map((row) => written(col.accessor?.(row)))
|
|
108
|
+
.filter((value) => value != null && value !== "" && !(Array.isArray(value) && value.length === 0));
|
|
109
|
+
if (kind === "filled")
|
|
110
|
+
return values.length;
|
|
111
|
+
return new Set(values.map((value) => Array.isArray(value) ? value.map(String).sort().join("|") : String(value))).size;
|
|
112
|
+
}
|
|
113
|
+
if (kind === "ratio") {
|
|
114
|
+
if (!col.ratio)
|
|
115
|
+
return null;
|
|
116
|
+
let num = 0;
|
|
117
|
+
let den = 0;
|
|
118
|
+
for (const row of rows) {
|
|
119
|
+
num += col.ratio.numerator(row) ?? 0;
|
|
120
|
+
den += col.ratio.denominator(row) ?? 0;
|
|
121
|
+
}
|
|
122
|
+
return den > 0 ? Math.round((num / den) * 100) : null;
|
|
123
|
+
}
|
|
124
|
+
return reduceNumbers(kind, totalledNumbers(col, rows));
|
|
125
|
+
}
|
|
126
|
+
const NUMERIC_AGGREGATES = new Set(["sum", "avg", "min", "max"]);
|
|
127
|
+
function totalledNumber(col, row) {
|
|
128
|
+
const read = col.aggAccessor ? col.aggAccessor(row) : col.accessor?.(row);
|
|
129
|
+
const value = col.field ? scalarOf(col.field, read) : read;
|
|
130
|
+
const number = typeof value === "number" ? value : value == null || value === "" ? NaN : Number(value);
|
|
131
|
+
return Number.isNaN(number) ? null : number;
|
|
132
|
+
}
|
|
133
|
+
function totalledNumbers(col, rows) {
|
|
134
|
+
const numbers = [];
|
|
135
|
+
for (const row of rows) {
|
|
136
|
+
const number = totalledNumber(col, row);
|
|
137
|
+
if (number != null)
|
|
138
|
+
numbers.push(number);
|
|
139
|
+
}
|
|
140
|
+
return numbers;
|
|
141
|
+
}
|
|
142
|
+
function reduceNumbers(kind, numbers) {
|
|
143
|
+
if (numbers.length === 0)
|
|
144
|
+
return null;
|
|
145
|
+
switch (kind) {
|
|
146
|
+
case "sum":
|
|
147
|
+
return numbers.reduce((sum, value) => sum + value, 0);
|
|
148
|
+
case "avg":
|
|
149
|
+
return numbers.reduce((sum, value) => sum + value, 0) / numbers.length;
|
|
150
|
+
case "min":
|
|
151
|
+
return Math.min(...numbers);
|
|
152
|
+
default:
|
|
153
|
+
return Math.max(...numbers);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
export function moneyTotal(kind, col, rows, defaultCurrency) {
|
|
157
|
+
if (!NUMERIC_AGGREGATES.has(kind) || fieldTypeOf(col) !== "currency")
|
|
158
|
+
return undefined;
|
|
159
|
+
const money = col.money;
|
|
160
|
+
if (money && col.reading === ORIGINAL_READING) {
|
|
161
|
+
const numbers = [];
|
|
162
|
+
for (const row of rows) {
|
|
163
|
+
const own = money.total ? money.total(row) : money.amount(row);
|
|
164
|
+
const converted = convertMoney(money, row, own, defaultCurrency);
|
|
165
|
+
if (converted != null)
|
|
166
|
+
numbers.push(converted);
|
|
167
|
+
}
|
|
168
|
+
const amount = reduceNumbers(kind, numbers);
|
|
169
|
+
return amount == null ? null : { amount, code: defaultCurrency };
|
|
170
|
+
}
|
|
171
|
+
if (col.currencyAccessor && !money)
|
|
172
|
+
return null;
|
|
173
|
+
const amount = reduceNumbers(kind, totalledNumbers(col, rows));
|
|
174
|
+
if (amount == null)
|
|
175
|
+
return null;
|
|
176
|
+
const code = col.format?.currency;
|
|
177
|
+
return { amount, code: code && code !== COLUMN_WIDE_CODE ? code : undefined };
|
|
178
|
+
}
|
|
179
|
+
export function moneyFigureCode(col, defaultCurrency) {
|
|
180
|
+
if (col.money && col.reading === ORIGINAL_READING)
|
|
181
|
+
return defaultCurrency;
|
|
182
|
+
if (col.currencyAccessor && !col.money)
|
|
183
|
+
return null;
|
|
184
|
+
const code = col.format?.currency;
|
|
185
|
+
return code && code !== COLUMN_WIDE_CODE ? code : undefined;
|
|
186
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How much of a card gets drawn. Lives in the LIST model, not in calendar:
|
|
3
|
+
* board and calendar name the same three tiers, and the zone table's density
|
|
4
|
+
* floors are stated once against this scale.
|
|
5
|
+
*/
|
|
6
|
+
export type CardDensity = "compact" | "standard" | "rich";
|
|
7
|
+
/** Is a field with this floor drawn at this density? No floor ⇒ always. */
|
|
8
|
+
export declare function meetsDensity(floor: CardDensity | undefined, actual: CardDensity): boolean;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { CardDensity } from "./card-density.js";
|
|
2
|
+
import type { ListCardZone, ListColumn, ListColumnType } from "./column-schema.js";
|
|
3
|
+
import { type ListColumnState } from "./column-state.js";
|
|
4
|
+
/**
|
|
5
|
+
* A card is typed ZONES, not aligned columns: the title line, a chip row where
|
|
6
|
+
* the badge-shaped types flow and wrap, a figures strip for the numeric facts,
|
|
7
|
+
* a footer for dates, and — at `rich` density only — a body line for prose.
|
|
8
|
+
* Which zone a field lands in is decided by its TYPE — never per host — so
|
|
9
|
+
* every card in the app (board or calendar) composes the same way and a
|
|
10
|
+
* restyle is an edit to one table.
|
|
11
|
+
*/
|
|
12
|
+
export type CardZoneRule = {
|
|
13
|
+
zone: ListCardZone;
|
|
14
|
+
minDensity?: CardDensity;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* THE type→zone table. Total over `ListColumnType` on purpose: a new column
|
|
18
|
+
* type fails to compile until someone decides where (or whether) it appears.
|
|
19
|
+
* `null` keeps a type off cards by default — prose and link-like types. A
|
|
20
|
+
* `text` column that IS a short fact opts in per column via `card.zone`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const ZONE_BY_TYPE: Record<ListColumnType, CardZoneRule | null>;
|
|
23
|
+
/** One field bound for a card: its column plus the zone that styles it. The
|
|
24
|
+
* zone stopped deciding PLACEMENT when the Fields panel took ownership of
|
|
25
|
+
* order — it now only picks the field's dress (money / chip / labeled date). */
|
|
26
|
+
export type CardField<Row> = {
|
|
27
|
+
col: ListColumn<Row>;
|
|
28
|
+
zone: ListCardZone;
|
|
29
|
+
};
|
|
30
|
+
export type CardLayout<Row> = {
|
|
31
|
+
title?: ListColumn<Row>;
|
|
32
|
+
/** The card's body fields in display order — the Fields panel's order, or
|
|
33
|
+
* zone rank when the user has set none. */
|
|
34
|
+
fields: CardField<Row>[];
|
|
35
|
+
/** Ids that START a new line. Applied per ROW (see `buildCardLines`), never
|
|
36
|
+
* baked into the field list, because which fields render varies by row. */
|
|
37
|
+
breakIds: ReadonlySet<string>;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Split a row's rendered fields into lines at the break ids.
|
|
41
|
+
*
|
|
42
|
+
* Applied PER ROW, over the fields that actually produced a cell — a break
|
|
43
|
+
* belongs to its field, so when that field is empty for this row the break
|
|
44
|
+
* leaves with it and the fields after it flow on instead of dropping to a line
|
|
45
|
+
* of their own. Splitting the layout up front instead left a card whose client
|
|
46
|
+
* was blank showing its two money figures stacked, because the absent client's
|
|
47
|
+
* break outlived it.
|
|
48
|
+
*
|
|
49
|
+
* A break on the first surviving item is a no-op: there is no line above it to
|
|
50
|
+
* end.
|
|
51
|
+
*/
|
|
52
|
+
export declare function buildCardLines<T>(items: readonly T[], idOf: (item: T) => string, breakIds: ReadonlySet<string>): T[][];
|
|
53
|
+
export type ListCardLayoutOpts = {
|
|
54
|
+
/** Excluded from the card: the column the board is laid out by — every card
|
|
55
|
+
* in a column shares that value, so on the card it is noise. */
|
|
56
|
+
laneColumnId?: string | null;
|
|
57
|
+
/** Excluded from the card regardless of zone — a column the host is already
|
|
58
|
+
* drawing elsewhere (e.g. the row it positions the card by). */
|
|
59
|
+
suppressColumnId?: string | null;
|
|
60
|
+
/** How much of the card to draw. Defaults to `"rich"` so a caller that
|
|
61
|
+
* passes none (board, today) keeps drawing exactly what it draws now. */
|
|
62
|
+
density?: CardDensity;
|
|
63
|
+
};
|
|
64
|
+
/** The break set the card is actually using: the user's stored ids once any
|
|
65
|
+
* were written (empty included — that is "everything on one line"), else the
|
|
66
|
+
* defaults. The panel reads this so a first toggle edits the real layout
|
|
67
|
+
* rather than an empty set. */
|
|
68
|
+
export declare function effectiveCardBreakIds<Row>(columns: ListColumn<Row>[], state: ListColumnState | undefined, excludeId: string | null): string[];
|
|
69
|
+
/**
|
|
70
|
+
* Where a column lands on a card — its own declaration first, then its type.
|
|
71
|
+
*
|
|
72
|
+
* Lifted out of `listCardFields` because the phone row asks the same question
|
|
73
|
+
* the board card does, and two copies of this rule is exactly how the two
|
|
74
|
+
* surfaces would come to disagree about where a date goes.
|
|
75
|
+
*/
|
|
76
|
+
export declare function cardZoneOf<Row>(col: ListColumn<Row>, density?: CardDensity): ListCardZone | null;
|
|
77
|
+
/**
|
|
78
|
+
* The card's body plan: which fields, in what order, and where the user asked
|
|
79
|
+
* for a new line. Deliberately NOT pre-split into lines — that is
|
|
80
|
+
* `buildCardLines`'s job, per row, once it is known which fields rendered.
|
|
81
|
+
*
|
|
82
|
+
* Visibility and order come from the host view's OWN slot in the layout
|
|
83
|
+
* bucket (the Fields panel).
|
|
84
|
+
*/
|
|
85
|
+
export declare function listCardLayout<Row>(columns: ListColumn<Row>[], state: ListColumnState | undefined, opts?: ListCardLayoutOpts): CardLayout<Row>;
|