@viewkitjs/views 0.1.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +767 -1
- package/README.md +92 -41
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/Row.js +1 -1
- package/dist/atoms/RowMenu.d.ts +1 -1
- package/dist/atoms/RowMenu.js +20 -6
- package/dist/atoms/types.d.ts +4 -4
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +79 -8
- package/dist/contract.js +55 -8
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/format.d.ts +16 -1
- package/dist/display/format.js +10 -1
- package/dist/display/index.d.ts +2 -1
- package/dist/display/index.js +2 -1
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +12 -6
- package/dist/display/location.d.ts +4 -3
- package/dist/display/location.js +12 -5
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +8 -2
- package/dist/display/percent.js +10 -3
- package/dist/display/phone.d.ts +2 -1
- package/dist/display/phone.js +11 -2
- package/dist/display/relation.js +1 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +7 -3
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +28 -21
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +15 -10
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +7 -7
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +22 -6
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +5 -2
- package/dist/editors/ValueListEditor.js +11 -9
- package/dist/editors/edit-cores.d.ts +13 -10
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +7 -2
- package/dist/fields/binding.js +13 -6
- package/dist/fields/currency.d.ts +0 -10
- package/dist/fields/currency.js +0 -14
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +6 -0
- package/dist/fields/money.js +11 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/filters/filter-model.d.ts +0 -1
- package/dist/filters/registry.d.ts +3 -36
- package/dist/filters/registry.js +0 -38
- package/dist/grid/chrome/GridAddColumn.d.ts +11 -0
- package/dist/grid/chrome/GridAddColumn.js +29 -0
- package/dist/grid/chrome/GridAggregateMenu.d.ts +31 -0
- package/dist/grid/chrome/GridAggregateMenu.js +29 -0
- package/dist/grid/chrome/GridCellEditors.d.ts +71 -0
- package/dist/grid/chrome/GridCellEditors.js +126 -0
- package/dist/grid/chrome/GridCellOutline.d.ts +49 -0
- package/dist/grid/chrome/GridCellOutline.js +16 -0
- package/dist/grid/chrome/GridChipsEditor.d.ts +38 -0
- package/dist/grid/chrome/GridChipsEditor.js +35 -0
- package/dist/grid/chrome/GridColumnColorSection.d.ts +11 -0
- package/dist/grid/chrome/GridColumnColorSection.js +40 -0
- package/dist/grid/chrome/GridColumnDateSection.d.ts +23 -0
- package/dist/grid/chrome/GridColumnDateSection.js +23 -0
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +19 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +24 -0
- package/dist/grid/chrome/GridColumnMenu.d.ts +101 -0
- package/dist/grid/chrome/GridColumnMenu.js +103 -0
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +25 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +27 -0
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +15 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +16 -0
- package/dist/grid/chrome/GridColumnSortSection.d.ts +18 -0
- package/dist/grid/chrome/GridColumnSortSection.js +16 -0
- package/dist/grid/chrome/GridDateEditor.d.ts +34 -0
- package/dist/grid/chrome/GridDateEditor.js +19 -0
- package/dist/grid/chrome/GridFlyout.d.ts +44 -0
- package/dist/grid/chrome/GridFlyout.js +80 -0
- package/dist/grid/chrome/GridFooter.d.ts +33 -0
- package/dist/grid/chrome/GridFooter.js +85 -0
- package/dist/grid/chrome/GridGroupMenu.d.ts +37 -0
- package/dist/grid/chrome/GridGroupMenu.js +64 -0
- package/dist/grid/chrome/GridHeader.d.ts +66 -0
- package/dist/grid/chrome/GridHeader.js +42 -0
- package/dist/grid/chrome/GridLongTextEditor.d.ts +55 -0
- package/dist/grid/chrome/GridLongTextEditor.js +69 -0
- package/dist/grid/chrome/GridMenuRow.d.ts +15 -0
- package/dist/grid/chrome/GridMenuRow.js +15 -0
- package/dist/grid/chrome/GridNameEditor.d.ts +24 -0
- package/dist/grid/chrome/GridNameEditor.js +21 -0
- package/dist/grid/chrome/GridNumberEditor.d.ts +49 -0
- package/dist/grid/chrome/GridNumberEditor.js +51 -0
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +30 -0
- package/dist/grid/chrome/GridRangeEditor.js +21 -0
- package/dist/grid/chrome/GridRelationEditor.d.ts +45 -0
- package/dist/grid/chrome/GridRelationEditor.js +92 -0
- package/dist/grid/chrome/GridResizeHandle.d.ts +19 -0
- package/dist/grid/chrome/GridResizeHandle.js +19 -0
- package/dist/grid/chrome/GridRow.d.ts +31 -0
- package/dist/grid/chrome/GridRow.js +179 -0
- package/dist/grid/chrome/GridRowActions.d.ts +32 -0
- package/dist/grid/chrome/GridRowActions.js +25 -0
- package/dist/grid/chrome/GridRowCells.d.ts +4 -0
- package/dist/grid/chrome/GridRowCells.js +128 -0
- package/dist/grid/chrome/GridRowGlyph.d.ts +12 -0
- package/dist/grid/chrome/GridRowGlyph.js +13 -0
- package/dist/grid/chrome/GridSelectEditor.d.ts +33 -0
- package/dist/grid/chrome/GridSelectEditor.js +43 -0
- package/dist/grid/chrome/GridStructure.d.ts +47 -0
- package/dist/grid/chrome/GridStructure.js +41 -0
- package/dist/grid/chrome/GridTable.d.ts +4 -0
- package/dist/grid/chrome/GridTable.js +192 -0
- package/dist/grid/chrome/GridTableSurface.d.ts +52 -0
- package/dist/grid/chrome/GridTableSurface.js +15 -0
- package/dist/grid/chrome/GridTextEditor.d.ts +45 -0
- package/dist/grid/chrome/GridTextEditor.js +38 -0
- package/dist/grid/chrome/GridValueListEditor.d.ts +30 -0
- package/dist/grid/chrome/GridValueListEditor.js +19 -0
- package/dist/grid/chrome/StuckMarker.d.ts +16 -0
- package/dist/grid/chrome/StuckMarker.js +34 -0
- package/dist/grid/chrome/cell-clipboard.d.ts +9 -0
- package/dist/grid/chrome/cell-clipboard.js +28 -0
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.d.ts +21 -0
- package/dist/grid/chrome/cells.js +19 -0
- package/dist/grid/chrome/checks.d.ts +32 -0
- package/dist/grid/chrome/checks.js +32 -0
- package/dist/grid/chrome/column-glyph.d.ts +14 -0
- package/dist/grid/chrome/column-glyph.js +44 -0
- package/dist/grid/chrome/editors.d.ts +9 -0
- package/dist/grid/chrome/editors.js +10 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +53 -0
- package/dist/grid/chrome/grid-cell-classes.js +32 -0
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-menu-search.d.ts +7 -0
- package/dist/grid/chrome/grid-menu-search.js +7 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +143 -0
- package/dist/grid/chrome/grid-row-props.js +1 -0
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +40 -0
- package/dist/grid/chrome/grid-styles.js +9 -0
- package/dist/grid/chrome/grid-table-props.d.ts +172 -0
- package/dist/grid/chrome/grid-table-props.js +1 -0
- package/dist/grid/chrome/useGridBatchApi.d.ts +34 -0
- package/dist/grid/chrome/useGridBatchApi.js +35 -0
- package/dist/grid/chrome/useGridColumnLayout.d.ts +30 -0
- package/dist/grid/chrome/useGridColumnLayout.js +206 -0
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridHeaderDrag.d.ts +20 -0
- package/dist/grid/chrome/useGridHeaderDrag.js +37 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +64 -0
- package/dist/grid/chrome/useGridKeyboard.js +450 -0
- package/dist/grid/chrome/useGridPendingReconciliation.d.ts +12 -0
- package/dist/grid/chrome/useGridPendingReconciliation.js +32 -0
- package/dist/grid/chrome/useGridRailReveal.d.ts +57 -0
- package/dist/grid/chrome/useGridRailReveal.js +67 -0
- package/dist/grid/chrome/useGridRangeActions.d.ts +51 -0
- package/dist/grid/chrome/useGridRangeActions.js +195 -0
- package/dist/grid/chrome/useGridRangeGestures.d.ts +32 -0
- package/dist/grid/chrome/useGridRangeGestures.js +237 -0
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +37 -0
- package/dist/grid/chrome/useGridRowContextMenu.js +153 -0
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -0
- package/dist/grid/chrome/useGridScaleStyles.js +28 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +78 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +249 -0
- package/dist/grid/chrome/useGridTableSelection.d.ts +29 -0
- package/dist/grid/chrome/useGridTableSelection.js +55 -0
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +21 -0
- package/dist/grid/chrome/useHeaderDragReorder.js +216 -0
- package/dist/grid/core/clipboard-model.d.ts +83 -0
- package/dist/grid/core/clipboard-model.js +291 -0
- package/dist/grid/core/column-values.d.ts +27 -0
- package/dist/grid/core/column-values.js +76 -0
- package/dist/grid/core/commit-model.d.ts +41 -0
- package/dist/grid/core/commit-model.js +3 -0
- package/dist/grid/core/coordinates.d.ts +48 -0
- package/dist/grid/core/coordinates.js +27 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/edit-values.d.ts +9 -0
- package/dist/grid/core/edit-values.js +1 -0
- package/dist/grid/core/editing-controller.d.ts +60 -0
- package/dist/grid/core/editing-controller.js +266 -0
- package/dist/grid/core/editing-model.d.ts +87 -0
- package/dist/grid/core/editing-model.js +148 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/grid-scale.d.ts +14 -0
- package/dist/grid/core/grid-scale.js +8 -0
- package/dist/grid/core/nav.d.ts +94 -0
- package/dist/grid/core/nav.js +92 -0
- package/dist/grid/core/pending-reconciliation.d.ts +53 -0
- package/dist/grid/core/pending-reconciliation.js +51 -0
- package/dist/grid/core/range-model.d.ts +25 -0
- package/dist/grid/core/range-model.js +59 -0
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +101 -0
- package/dist/grid/core/spreadsheet-operations.js +280 -0
- package/dist/grid/core/useGridEditing.d.ts +46 -0
- package/dist/grid/core/useGridEditing.js +93 -0
- package/dist/grid/core/useGridRange.d.ts +20 -0
- package/dist/grid/core/useGridRange.js +24 -0
- package/dist/grid/core/value-equality.d.ts +54 -0
- package/dist/grid/core/value-equality.js +80 -0
- package/dist/grid/index.d.ts +18 -0
- package/dist/grid/index.js +5 -0
- package/dist/grid/useGridTablePrefs.d.ts +49 -0
- package/dist/grid/useGridTablePrefs.js +99 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal/viewport.d.ts +3 -0
- package/dist/internal/viewport.js +15 -0
- package/dist/model/column-capabilities.d.ts +3 -2
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-state.d.ts +1 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/density.js +3 -3
- package/dist/model/filter-capabilities.d.ts +1 -1
- package/dist/model/filter-capabilities.js +1 -1
- package/dist/model/index.d.ts +4 -6
- package/dist/model/index.js +0 -1
- package/dist/model/preferences.d.ts +7 -7
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +6 -2
- package/dist/provider/ViewsProvider.js +12 -2
- package/dist/provider/components.d.ts +35 -9
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +8 -4
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/menu-groups.d.ts +8 -0
- package/dist/provider/menu-groups.js +38 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/provider/ports.d.ts +22 -0
- package/dist/provider/ports.js +1 -0
- package/dist/react.d.ts +3 -2
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +202 -72
- package/docs/getting-started.md +250 -0
- package/docs/guides/atoms.md +245 -0
- package/docs/guides/cells.md +302 -0
- package/docs/guides/columns.md +413 -0
- package/docs/guides/display.md +204 -0
- package/docs/guides/editors.md +462 -0
- package/docs/guides/ports.md +246 -0
- package/docs/guides/selection.md +270 -0
- package/docs/guides/the-grid.md +696 -0
- package/docs/guides/the-provider.md +448 -0
- package/docs/index.md +52 -0
- package/docs/install.md +9 -47
- package/docs/reference/cells.md +28 -0
- package/docs/reference/display.md +44 -0
- package/docs/reference/editors-chips.md +6 -0
- package/docs/reference/editors-date.md +6 -0
- package/docs/reference/editors-location.md +10 -0
- package/docs/reference/editors-name.md +6 -0
- package/docs/reference/editors-number.md +11 -0
- package/docs/reference/editors-open-values.md +10 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +6 -0
- package/docs/reference/editors-relation.md +12 -0
- package/docs/reference/editors-select.md +9 -0
- package/docs/reference/editors-session.md +11 -0
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +6 -0
- package/docs/reference/editors.md +5 -0
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +39 -0
- package/docs/reference/react.md +89 -0
- package/docs/reference/selection.md +33 -0
- package/docs/reference/views.md +622 -0
- package/package.json +27 -4
- package/skills/views/SKILL.md +20 -5
- package/dist/filters/types.d.ts +0 -27
- package/dist/filters/types.js +0 -1
- package/dist/model/filter-pushdown.d.ts +0 -106
- package/dist/model/filter-pushdown.js +0 -147
|
@@ -0,0 +1,99 @@
|
|
|
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, 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
|
+
alwaysCheckboxes: gridAlwaysCheckboxes,
|
|
52
|
+
scale: GRID_SCALE_MULTIPLIER[gridScale],
|
|
53
|
+
optionColors: gridOptionColors,
|
|
54
|
+
onOptionColorChange,
|
|
55
|
+
dateStyles: gridDateStyles,
|
|
56
|
+
onDateStyleChange,
|
|
57
|
+
durationStyles: gridDurationStyles,
|
|
58
|
+
onDurationStyleChange,
|
|
59
|
+
showTimeOverrides: gridShowTime,
|
|
60
|
+
onShowTimeChange,
|
|
61
|
+
percentDisplays: gridPercentDisplays,
|
|
62
|
+
onPercentDisplayChange,
|
|
63
|
+
columnState: gridColumns,
|
|
64
|
+
onColumnStateChange,
|
|
65
|
+
groupSummary: summaryParts,
|
|
66
|
+
onGroupSummaryChange,
|
|
67
|
+
aggregates: gridAggregates,
|
|
68
|
+
onAggregateChange,
|
|
69
|
+
viewBacked,
|
|
70
|
+
numberFormats,
|
|
71
|
+
onNumberFormatChange,
|
|
72
|
+
}), [
|
|
73
|
+
gridVerticalBorders,
|
|
74
|
+
gridRowIcon,
|
|
75
|
+
gridFreezeIdentity,
|
|
76
|
+
gridAlwaysCheckboxes,
|
|
77
|
+
gridScale,
|
|
78
|
+
gridOptionColors,
|
|
79
|
+
onOptionColorChange,
|
|
80
|
+
gridDateStyles,
|
|
81
|
+
onDateStyleChange,
|
|
82
|
+
gridDurationStyles,
|
|
83
|
+
onDurationStyleChange,
|
|
84
|
+
gridShowTime,
|
|
85
|
+
onShowTimeChange,
|
|
86
|
+
gridPercentDisplays,
|
|
87
|
+
onPercentDisplayChange,
|
|
88
|
+
gridColumns,
|
|
89
|
+
onColumnStateChange,
|
|
90
|
+
summaryParts,
|
|
91
|
+
onGroupSummaryChange,
|
|
92
|
+
gridAggregates,
|
|
93
|
+
onAggregateChange,
|
|
94
|
+
viewBacked,
|
|
95
|
+
numberFormats,
|
|
96
|
+
onNumberFormatChange,
|
|
97
|
+
]);
|
|
98
|
+
return { gridProps };
|
|
99
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./model/column-format.js";
|
|
|
6
6
|
export * from "./model/column-inspect.js";
|
|
7
7
|
export * from "./model/column-money.js";
|
|
8
8
|
export * from "./filters/registry.js";
|
|
9
|
-
export * from "./filters/types.js";
|
|
10
9
|
export * from "./filters/text-filter.js";
|
|
11
10
|
export * from "./filters/number-filter.js";
|
|
12
11
|
export * from "./filters/range-filter.js";
|
|
@@ -22,6 +21,7 @@ export * from "./fields/money.js";
|
|
|
22
21
|
export * from "./fields/currency.js";
|
|
23
22
|
export * from "./fields/denomination.js";
|
|
24
23
|
export * from "./fields/prepare-write.js";
|
|
24
|
+
export * from "./fields/write-target.js";
|
|
25
25
|
export * from "./fields/edit-core-types.js";
|
|
26
26
|
export * from "./fields/number-edit.js";
|
|
27
27
|
export * from "./fields/format-knobs.js";
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,6 @@ export * from "./model/column-format.js";
|
|
|
6
6
|
export * from "./model/column-inspect.js";
|
|
7
7
|
export * from "./model/column-money.js";
|
|
8
8
|
export * from "./filters/registry.js";
|
|
9
|
-
export * from "./filters/types.js";
|
|
10
9
|
export * from "./filters/text-filter.js";
|
|
11
10
|
export * from "./filters/number-filter.js";
|
|
12
11
|
export * from "./filters/range-filter.js";
|
|
@@ -22,6 +21,7 @@ export * from "./fields/money.js";
|
|
|
22
21
|
export * from "./fields/currency.js";
|
|
23
22
|
export * from "./fields/denomination.js";
|
|
24
23
|
export * from "./fields/prepare-write.js";
|
|
24
|
+
export * from "./fields/write-target.js";
|
|
25
25
|
export * from "./fields/edit-core-types.js";
|
|
26
26
|
export * from "./fields/number-edit.js";
|
|
27
27
|
export * from "./fields/format-knobs.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export function useHasHover() {
|
|
4
|
+
const [hasHover, setHasHover] = useState(true);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
7
|
+
return;
|
|
8
|
+
const mq = window.matchMedia("(hover: hover) and (pointer: fine)");
|
|
9
|
+
setHasHover(mq.matches);
|
|
10
|
+
const handler = (e) => setHasHover(e.matches);
|
|
11
|
+
mq.addEventListener("change", handler);
|
|
12
|
+
return () => mq.removeEventListener("change", handler);
|
|
13
|
+
}, []);
|
|
14
|
+
return hasHover;
|
|
15
|
+
}
|
|
@@ -153,8 +153,9 @@ export type GridWriteResult = {
|
|
|
153
153
|
export declare function gridNormalizeWrite<Row>(col: ListColumn<Row>, next: unknown, conventions: FieldConventions,
|
|
154
154
|
/** `region`: the record's country, where a phone typed without its country code is read. A host whose rows carry
|
|
155
155
|
* a country passes the row's here; absent, the conventions' region reads it. `messages`: the app's words for a
|
|
156
|
-
* refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a
|
|
157
|
-
* that comes back as it is here is kept, never read again
|
|
156
|
+
* refusal, the package's English when absent. `stored`: the cell's value before this edit, as stored; a value
|
|
157
|
+
* fields keeps by `stored` (a phone, a url) that comes back as it is here is kept, never read again, and a value
|
|
158
|
+
* a closed multiselect already holds passes though no option names it. */
|
|
158
159
|
options?: {
|
|
159
160
|
region?: string | null;
|
|
160
161
|
messages?: ViewsMessageResolver;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { acceptFieldCommit, isMultipleType, lockReason, valueTypeOf } from "@viewkitjs/fields";
|
|
1
|
+
import { acceptFieldCommit, isMultipleType, lockReason, relationIdOf, valueTypeOf, } from "@viewkitjs/fields";
|
|
2
2
|
import { resolveViewsMessage } from "../contract.js";
|
|
3
3
|
import { prettifyOptionValue, resolveColumnOrder } from "./column-state.js";
|
|
4
4
|
import { typeRule } from "./column-types.js";
|
|
@@ -10,6 +10,8 @@ export function gridEditorKind(col) {
|
|
|
10
10
|
return col.field && col.type && isMultipleType(col.type) ? "values" : null;
|
|
11
11
|
if (col.type === "title" && col.field && valueTypeOf(col.field) === "name")
|
|
12
12
|
return "name";
|
|
13
|
+
if (col.type === "location")
|
|
14
|
+
return col.field && valueTypeOf(col.field) === "location" ? "place" : null;
|
|
13
15
|
return typeRule(col.type)?.editor ?? null;
|
|
14
16
|
}
|
|
15
17
|
export function gridColumnHasEditor(col) {
|
|
@@ -112,7 +114,9 @@ export function columnClearRefusal(col, messages = resolveViewsMessage) {
|
|
|
112
114
|
export function columnEditRefusal(col, conventions, messages = resolveViewsMessage) {
|
|
113
115
|
return (col.reasons?.editable ??
|
|
114
116
|
(col.field ? lockReason(col.field, conventions) : undefined) ??
|
|
115
|
-
(col.custom
|
|
117
|
+
(col.custom
|
|
118
|
+
? messages({ key: "views.grid.computed", values: { from: col.custom.from } })
|
|
119
|
+
: undefined));
|
|
116
120
|
}
|
|
117
121
|
export function gridEditRefusal(col, config, conventions, messages = resolveViewsMessage) {
|
|
118
122
|
if (gridColumnLocked(col, config))
|
|
@@ -186,15 +190,31 @@ function coerceWrite(col, next, messages) {
|
|
|
186
190
|
return { ok: true, value: trimmed };
|
|
187
191
|
}
|
|
188
192
|
case "relation": {
|
|
193
|
+
const many = col.field?.type === "relation" && col.field.cardinality === "many";
|
|
189
194
|
if (isCleared(next))
|
|
190
|
-
return { ok: true, value: null };
|
|
191
|
-
if (typeof next !== "string")
|
|
192
|
-
return { ok: false, reason: messages({ key: "views.grid.write-not-link" }) };
|
|
195
|
+
return { ok: true, value: many ? [] : null };
|
|
193
196
|
const known = col.relation?.options;
|
|
194
|
-
|
|
195
|
-
|
|
197
|
+
const judge = (item) => {
|
|
198
|
+
const id = typeof item === "string" || col.field ? relationIdOf(item) : null;
|
|
199
|
+
if (id === null)
|
|
200
|
+
return messages({ key: "views.grid.write-not-link" });
|
|
201
|
+
if (known && !known.some((option) => option.id === id)) {
|
|
202
|
+
return messages({ key: "views.grid.write-not-linkable" });
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
};
|
|
206
|
+
if (many) {
|
|
207
|
+
if (!Array.isArray(next))
|
|
208
|
+
return { ok: false, reason: messages({ key: "views.grid.write-not-link" }) };
|
|
209
|
+
for (const item of next) {
|
|
210
|
+
const reason = judge(item);
|
|
211
|
+
if (reason)
|
|
212
|
+
return { ok: false, reason };
|
|
213
|
+
}
|
|
214
|
+
return { ok: true, value: next };
|
|
196
215
|
}
|
|
197
|
-
|
|
216
|
+
const reason = judge(next);
|
|
217
|
+
return reason ? { ok: false, reason } : { ok: true, value: next };
|
|
198
218
|
}
|
|
199
219
|
case "list": {
|
|
200
220
|
if (isCleared(next))
|
|
@@ -146,12 +146,15 @@ export function columnFrom(binding, presentation) {
|
|
|
146
146
|
entity: shown.type === "user" ? "user" : relationKinds(shown)[0],
|
|
147
147
|
...(source ? { source } : {}),
|
|
148
148
|
...(source?.kind === "static" ? { options: source.items } : {}),
|
|
149
|
+
...(binding.create ? { create: binding.create } : {}),
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
152
|
if (isMultipleType(shown.type) && "multiple" in shown && shown.multiple)
|
|
152
153
|
column.multiple = true;
|
|
153
154
|
if (binding.labels === false)
|
|
154
155
|
column.labels = false;
|
|
156
|
+
if (binding.region)
|
|
157
|
+
column.region = binding.region;
|
|
155
158
|
if (shown.type === "multiselect")
|
|
156
159
|
column.chips = { normalize: normalizerFor(shown) };
|
|
157
160
|
if (column.money)
|
|
@@ -7,8 +7,9 @@ import type { ListColumn } from "./column-schema.js";
|
|
|
7
7
|
* editor, can it be written, in what shape). This file answers the one read
|
|
8
8
|
* question the mount gestures (click-on-focused, double-click, Enter) ask
|
|
9
9
|
* beside them: a long text you cannot edit is still worth reading in full, and
|
|
10
|
-
* the anchored panel is the one reading surface the grid has.
|
|
11
|
-
* text qualifies
|
|
10
|
+
* the anchored panel is the one reading surface the grid has. A long text
|
|
11
|
+
* always qualifies; a plain text or a text name qualifies when its cell cuts
|
|
12
|
+
* it off, which only the cell can measure at the gesture.
|
|
12
13
|
*/
|
|
13
14
|
/** A text column whose value is a paragraph, not a phrase — the field said so
|
|
14
15
|
* with `format.long`. It edits (and reads) in the anchored long-text panel
|
|
@@ -16,3 +17,10 @@ import type { ListColumn } from "./column-schema.js";
|
|
|
16
17
|
export declare function isLongTextColumn<Row>(col: ListColumn<Row>): boolean;
|
|
17
18
|
/** Whether a cell opens a PANEL to be READ, whatever its write state. */
|
|
18
19
|
export declare function gridColumnInspectable<Row>(col: ListColumn<Row>): boolean;
|
|
20
|
+
/** A text that opens WHOLE in the panel when the cell cuts it off: plain text, and a name that is
|
|
21
|
+
* text (not a person's name, which edits in its own boxes). Links, emails, phones and domains keep
|
|
22
|
+
* their one-line box. Whether it IS cut off is the cell's to measure (`gridCellCutOff`). */
|
|
23
|
+
export declare function isWholeTextColumn<Row>(col: ListColumn<Row>): boolean;
|
|
24
|
+
/** Whether an open text cell is drawn in the panel over the cell rather than in the cell: a
|
|
25
|
+
* paragraph always, a line when it opened `whole` (cut off when it was opened). */
|
|
26
|
+
export declare function gridTextOpensBox<Row>(col: ListColumn<Row>, whole: boolean): boolean;
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { valueTypeOf } from "@viewkitjs/fields";
|
|
1
2
|
export function isLongTextColumn(col) {
|
|
2
3
|
return (col.type === "text" && !!col.format?.long) || col.type === "rich_text";
|
|
3
4
|
}
|
|
4
5
|
export function gridColumnInspectable(col) {
|
|
5
6
|
return isLongTextColumn(col);
|
|
6
7
|
}
|
|
8
|
+
export function isWholeTextColumn(col) {
|
|
9
|
+
if (col.type === "text")
|
|
10
|
+
return !col.format?.long;
|
|
11
|
+
return col.type === "title" && !(col.field && valueTypeOf(col.field) === "name");
|
|
12
|
+
}
|
|
13
|
+
export function gridTextOpensBox(col, whole) {
|
|
14
|
+
return isLongTextColumn(col) || (whole && isWholeTextColumn(col));
|
|
15
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MouseEvent as ReactMouseEvent, ReactNode } from "react";
|
|
2
2
|
import type { FieldBinding } from "../fields/binding.js";
|
|
3
3
|
import type { MoneyDeclaration } from "../fields/money.js";
|
|
4
|
-
import type { RelationSource } from "../fields/relation-source-types.js";
|
|
4
|
+
import type { RelationCellCreate, RelationSource } from "../fields/relation-source-types.js";
|
|
5
5
|
import type { MoneyReading } from "../fields/currency.js";
|
|
6
6
|
import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
7
7
|
import type { StageMark } from "@viewkitjs/fields/design/stage-marks";
|
|
@@ -159,6 +159,9 @@ export type ListColumn<Row> = {
|
|
|
159
159
|
value: (row: Row) => string;
|
|
160
160
|
options?: string[];
|
|
161
161
|
};
|
|
162
|
+
/** The record's country, where a phone typed without its country code is read: the grid's editors and every
|
|
163
|
+
* write gate read it off the row. Absent, the conventions' region reads it. A binding's `region` carries here. */
|
|
164
|
+
region?: (row: Row) => string | null | undefined;
|
|
162
165
|
type?: ListColumnType;
|
|
163
166
|
/**
|
|
164
167
|
* `relation` columns only — the candidates the picker offers, and the default
|
|
@@ -174,6 +177,8 @@ export type ListColumn<Row> = {
|
|
|
174
177
|
options?: ListRelationValue[];
|
|
175
178
|
/** Kind for values that don't carry their own — the monomorphic case. */
|
|
176
179
|
entity?: string;
|
|
180
|
+
/** The app's create row, offered under the candidates (`FieldBinding.create`). */
|
|
181
|
+
create?: RelationCellCreate;
|
|
177
182
|
};
|
|
178
183
|
/**
|
|
179
184
|
* This cell holds SEVERAL values, not one (an array). Declared rather than
|
|
@@ -36,7 +36,7 @@ export declare const LIST_DEFAULT_MIN_WIDTH = 60;
|
|
|
36
36
|
/**
|
|
37
37
|
* The density vocabulary, shared by every view. How a view SPENDS it differs —
|
|
38
38
|
* the grid multiplies its pixel scale, the rows views widen their padding — so
|
|
39
|
-
* only the names live here; see `grid
|
|
39
|
+
* only the names live here; see `grid/core/grid-scale.ts`.
|
|
40
40
|
*/
|
|
41
41
|
export type ListDensity = "compact" | "default" | "spacious";
|
|
42
42
|
/**
|
|
@@ -29,7 +29,9 @@ import type { ListColumn, ListColumnType, ListRelationValue } from "./column-sch
|
|
|
29
29
|
/** Which editor a writable column mounts when clicked, Entered or typed into. */
|
|
30
30
|
export type GridEditorId = "text" | "select" | "number" | "date" | "relation" | "chips" | "range" | "name"
|
|
31
31
|
/** Several values of one kind (`multiple` email, phone, url or domain), each with its label and a main one. */
|
|
32
|
-
| "values"
|
|
32
|
+
| "values"
|
|
33
|
+
/** A place: the country first, then that country's own parts (`LocationEditor`). */
|
|
34
|
+
| "place";
|
|
33
35
|
/** Which editor this type opens in the Filter drill-in. `none` lists the
|
|
34
36
|
* column and opens nothing — a structured value with no rule to write. */
|
|
35
37
|
export type ListFilterEditor = "options" | "text" | "number" | "date" | "boolean" | "range" | "none";
|
|
@@ -14,7 +14,7 @@ export const GRID_TYPE_RULES = {
|
|
|
14
14
|
relation: { editor: "relation", filter: "options", paste: "relation", value: "relation" },
|
|
15
15
|
user: { editor: "relation", filter: "options", paste: "relation", value: "relation" },
|
|
16
16
|
phone: { editor: "text", filter: "text", paste: "text", value: "any" },
|
|
17
|
-
location: { editor:
|
|
17
|
+
location: { editor: "place", filter: "none", paste: "none", value: "any" },
|
|
18
18
|
name: { editor: "name", filter: "text", paste: "text", value: "any" },
|
|
19
19
|
actor: { editor: null, filter: "options", paste: "none", value: "any" },
|
|
20
20
|
rich_text: { editor: "text", filter: "text", paste: "text", value: "any" },
|
package/dist/model/density.js
CHANGED
|
@@ -6,8 +6,8 @@ const DENSITY = {
|
|
|
6
6
|
export function densityStyle(density) {
|
|
7
7
|
const spec = DENSITY[density] ?? DENSITY.default;
|
|
8
8
|
return {
|
|
9
|
-
"--
|
|
10
|
-
"--
|
|
11
|
-
"--
|
|
9
|
+
"--vk-row-py": spec.py,
|
|
10
|
+
"--vk-head-mb": spec.headMb,
|
|
11
|
+
"--vk-row-gap": spec.gap,
|
|
12
12
|
};
|
|
13
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { type ListFilterCapability, type ListFilterCapabilities } from "../filters/registry.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {};
|
package/dist/model/index.d.ts
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
*
|
|
4
4
|
* What a list's columns ARE (`column-schema`), what may be DONE to them
|
|
5
5
|
* (`column-capabilities`), which of them are shown and in what order
|
|
6
|
-
* (`column-state`), how they narrow a cohort (`column-filters
|
|
7
|
-
*
|
|
8
|
-
* (`preferences`).
|
|
6
|
+
* (`column-state`), how they narrow a cohort (`column-filters`), and what a
|
|
7
|
+
* user has persisted about them (`preferences`).
|
|
9
8
|
*
|
|
10
|
-
* It lives OUTSIDE `grid
|
|
9
|
+
* It lives OUTSIDE `grid/` because none of it is about a spreadsheet.
|
|
11
10
|
* A table view reads the same schema to align its columns; a card view reads
|
|
12
11
|
* it to find the title field; a board would read a `select` column's `options`
|
|
13
12
|
* to get its lanes; and all of them must ask `column-capabilities` before a
|
|
14
13
|
* write, or a workspace lock would protect the grid and nothing else.
|
|
15
14
|
*
|
|
16
|
-
* What stayed behind in `grid
|
|
15
|
+
* What stayed behind in `grid/` is what only a spreadsheet does: cell
|
|
17
16
|
* editors, range selection, clipboard, keyboard navigation, and the pixel
|
|
18
17
|
* scale (`core/grid-scale.ts`).
|
|
19
18
|
*/
|
|
@@ -29,7 +28,6 @@ export * from "./column-types.js";
|
|
|
29
28
|
export * from "./column-capabilities.js";
|
|
30
29
|
export * from "./column-warnings.js";
|
|
31
30
|
export * from "./column-filters.js";
|
|
32
|
-
export * from "./filter-pushdown.js";
|
|
33
31
|
export * from "./filter-capabilities.js";
|
|
34
32
|
export * from "./preferences.js";
|
|
35
33
|
export * from "./view-rules.js";
|
package/dist/model/index.js
CHANGED
|
@@ -10,7 +10,6 @@ export * from "./column-types.js";
|
|
|
10
10
|
export * from "./column-capabilities.js";
|
|
11
11
|
export * from "./column-warnings.js";
|
|
12
12
|
export * from "./column-filters.js";
|
|
13
|
-
export * from "./filter-pushdown.js";
|
|
14
13
|
export * from "./filter-capabilities.js";
|
|
15
14
|
export * from "./preferences.js";
|
|
16
15
|
export * from "./view-rules.js";
|
|
@@ -56,10 +56,6 @@ export type ListViewPrefs = {
|
|
|
56
56
|
/** Pin the identity columns (everything through the title) to the left edge
|
|
57
57
|
* while the rest of the table scrolls under them. */
|
|
58
58
|
gridFreezeIdentity: boolean;
|
|
59
|
-
/** Cells wrap to at most 3 lines instead of truncating to one, and rows grow
|
|
60
|
-
* to fit their tallest cell. Off by default: one line per row is what makes
|
|
61
|
-
* a grid scannable, and wrapping is the deliberate trade against it. */
|
|
62
|
-
gridWrapCells: boolean;
|
|
63
59
|
/** Keep every row's checkbox on screen instead of revealing it on hover.
|
|
64
60
|
* Off by default: the rail is chrome, and a permanent column of empty boxes
|
|
65
61
|
* is a cost every row pays for a gesture used occasionally. On for anyone
|
|
@@ -132,8 +128,10 @@ export declare function isGroupSummaryPart(value: unknown): value is ListGroupSu
|
|
|
132
128
|
*
|
|
133
129
|
* It was a single `"count" | "total"` before, so every persisted blob out there
|
|
134
130
|
* still holds a bare string — parsed here rather than migrated, because a view
|
|
135
|
-
* pref is not worth a migration
|
|
136
|
-
*
|
|
131
|
+
* pref is not worth a migration. Keeps the parts it recognises and drops the
|
|
132
|
+
* rest, so a value it cannot read comes back as `[]`, a bare group name, never
|
|
133
|
+
* the default: a caller with no stored value applies
|
|
134
|
+
* `LIST_VIEW_PREF_DEFAULTS.groupSummary` itself before calling.
|
|
137
135
|
*/
|
|
138
136
|
export declare function normalizeGroupSummary(value: unknown): ListGroupSummaryPart[];
|
|
139
137
|
export declare const LIST_VIEW_PREF_DEFAULTS: ListViewPrefs;
|
|
@@ -141,7 +139,9 @@ export declare const LIST_VIEW_PREF_DEFAULTS: ListViewPrefs;
|
|
|
141
139
|
export declare function setFilterRule(current: ListFilterRuleState, columnId: string, rule: ListFilterRule | null): ListFilterRuleState;
|
|
142
140
|
export declare function setOptionColor(current: ListOptionColorOverrides, columnId: string, value: string, color: ListSelectColor | null): ListOptionColorOverrides;
|
|
143
141
|
export declare function setDateStyle(current: ListDateStyleOverrides, columnId: string, style: ListDateStyle): ListDateStyleOverrides;
|
|
144
|
-
/** Set one column's duration rendering
|
|
142
|
+
/** Set one column's duration rendering. Always writes the entry, the column's
|
|
143
|
+
* own style included: unlike `setFilterRule` and `setOptionColor`, it never
|
|
144
|
+
* drops one. */
|
|
145
145
|
export declare function setDurationStyle(current: ListDurationStyleOverrides, columnId: string, style: ListDurationStyle): ListDurationStyleOverrides;
|
|
146
146
|
export declare function setShowTime(current: ListShowTimeOverrides, columnId: string, show: boolean): ListShowTimeOverrides;
|
|
147
147
|
export declare function setPercentDisplay(current: ListPercentDisplayOverrides, key: string, display: PercentDisplay): ListPercentDisplayOverrides;
|
|
@@ -11,7 +11,6 @@ export const LIST_LAYOUT_DEFAULTS = {
|
|
|
11
11
|
verticalBorders: false,
|
|
12
12
|
rowIcon: true,
|
|
13
13
|
freezeIdentity: false,
|
|
14
|
-
wrapCells: false,
|
|
15
14
|
alwaysCheckboxes: false,
|
|
16
15
|
};
|
|
17
16
|
export function verticalBordersDefault(defaults) {
|
|
@@ -29,7 +28,6 @@ export function readViewLayout(bucket, viewId, defaults) {
|
|
|
29
28
|
verticalBorders: stored?.verticalBorders ?? verticalBordersDefault(defaults),
|
|
30
29
|
rowIcon: stored?.rowIcon ?? LIST_LAYOUT_DEFAULTS.rowIcon,
|
|
31
30
|
freezeIdentity: stored?.freezeIdentity ?? LIST_LAYOUT_DEFAULTS.freezeIdentity,
|
|
32
|
-
wrapCells: stored?.wrapCells ?? LIST_LAYOUT_DEFAULTS.wrapCells,
|
|
33
31
|
alwaysCheckboxes: stored?.alwaysCheckboxes ?? LIST_LAYOUT_DEFAULTS.alwaysCheckboxes,
|
|
34
32
|
...(stored?.dateColumnId ? { dateColumnId: stored.dateColumnId } : {}),
|
|
35
33
|
...(stored?.boardFieldId ? { boardFieldId: stored.boardFieldId } : {}),
|
|
@@ -61,7 +59,6 @@ export function hoistLegacyPrefs(legacy) {
|
|
|
61
59
|
verticalBorders: pick(legacy, "gridVerticalBorders"),
|
|
62
60
|
rowIcon: pick(legacy, "gridRowIcon"),
|
|
63
61
|
freezeIdentity: pick(legacy, "gridFreezeIdentity"),
|
|
64
|
-
wrapCells: pick(legacy, "gridWrapCells"),
|
|
65
62
|
alwaysCheckboxes: pick(legacy, "gridAlwaysCheckboxes"),
|
|
66
63
|
}),
|
|
67
64
|
list: {},
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
export declare function countRowRender(): void;
|
|
2
|
+
/**
|
|
3
|
+
* Counts row renders whatever `localStorage.perf` says, from zero, until the
|
|
4
|
+
* returned stop runs. For tests only: the package doesn't export it, and the
|
|
5
|
+
* browser's log never calls it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function countRowRendersInTest(): () => void;
|
|
2
8
|
export declare function takeRowRenders(): number;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
let on = null;
|
|
2
|
+
let forced = 0;
|
|
2
3
|
let rendered = 0;
|
|
3
4
|
function counting() {
|
|
5
|
+
if (forced > 0)
|
|
6
|
+
return true;
|
|
4
7
|
if (typeof window === "undefined")
|
|
5
8
|
return false;
|
|
6
9
|
if (on === null) {
|
|
@@ -17,6 +20,14 @@ export function countRowRender() {
|
|
|
17
20
|
if (counting())
|
|
18
21
|
rendered += 1;
|
|
19
22
|
}
|
|
23
|
+
export function countRowRendersInTest() {
|
|
24
|
+
forced += 1;
|
|
25
|
+
rendered = 0;
|
|
26
|
+
return () => {
|
|
27
|
+
forced -= 1;
|
|
28
|
+
rendered = 0;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
20
31
|
export function takeRowRenders() {
|
|
21
32
|
const count = rendered;
|
|
22
33
|
rendered = 0;
|
|
@@ -5,7 +5,7 @@ import type { ViewsAtoms } from "../atoms/types.js";
|
|
|
5
5
|
import type { FieldPresentation } from "../display/options.js";
|
|
6
6
|
import type { ViewsComponents } from "./components.js";
|
|
7
7
|
import type { ViewsIcons } from "./icons.js";
|
|
8
|
-
import type
|
|
8
|
+
import { type ViewsPorts } from "./ports.js";
|
|
9
9
|
export { useViews, type ViewsContextValue } from "./context.js";
|
|
10
10
|
export type ViewsProviderProps = {
|
|
11
11
|
components: ViewsComponents;
|
|
@@ -21,6 +21,10 @@ export type ViewsProviderProps = {
|
|
|
21
21
|
* app's. It is called where a value is drawn, so the app's provider imports none of the
|
|
22
22
|
* display. Absent, the package's defaults in the conventions' locale. */
|
|
23
23
|
presentation?: (defaults: FieldPresentation) => FieldPresentation;
|
|
24
|
+
/** The media query that means a desktop, so an editor opens as a popover there and as a sheet
|
|
25
|
+
* elsewhere. Hand in the one your own shell switches on. Default `DEFAULT_DESKTOP_QUERY`,
|
|
26
|
+
* `(min-width: 1024px)`. */
|
|
27
|
+
desktopQuery?: string;
|
|
24
28
|
children: ReactNode;
|
|
25
29
|
};
|
|
26
|
-
export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
export declare function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages, presentation, desktopQuery, }: ViewsProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -4,9 +4,19 @@ import { useMemo } from "react";
|
|
|
4
4
|
import { resolveViewsMessage } from "../contract.js";
|
|
5
5
|
import { DEFAULT_VIEWS_ATOMS } from "../atoms/defaults.js";
|
|
6
6
|
import { ViewsContext } from "./context.js";
|
|
7
|
+
import { PlainInput } from "./plain-input.js";
|
|
8
|
+
import { withSettledGroups } from "./menu-groups.js";
|
|
9
|
+
import { DEFAULT_DESKTOP_QUERY } from "./desktop.js";
|
|
10
|
+
import { browserConfirm } from "./ports.js";
|
|
7
11
|
export { useViews } from "./context.js";
|
|
8
|
-
export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, }) {
|
|
12
|
+
export function ViewsProvider({ children, components, conventions, icons, ports, atoms, messages = resolveViewsMessage, presentation, desktopQuery = DEFAULT_DESKTOP_QUERY, }) {
|
|
9
13
|
const merged = useMemo(() => ({ ...DEFAULT_VIEWS_ATOMS, ...atoms }), [atoms]);
|
|
10
|
-
const
|
|
14
|
+
const settled = useMemo(() => ({
|
|
15
|
+
...components,
|
|
16
|
+
Menu: withSettledGroups(components.Menu),
|
|
17
|
+
Input: components.Input ?? PlainInput,
|
|
18
|
+
}), [components]);
|
|
19
|
+
const resolved = useMemo(() => (ports.confirm ? ports : { ...ports, confirm: browserConfirm }), [ports]);
|
|
20
|
+
const value = useMemo(() => ({ components: settled, atoms: merged, conventions, icons, ports: resolved, messages, presentation, desktopQuery }), [settled, merged, conventions, icons, resolved, messages, presentation, desktopQuery]);
|
|
11
21
|
return _jsx(ViewsContext.Provider, { value: value, children: children });
|
|
12
22
|
}
|