@viewkitjs/views 0.5.0 → 0.6.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 +620 -0
- package/README.md +4 -2
- package/dist/atoms/Avatar.d.ts +2 -0
- package/dist/atoms/Avatar.js +13 -0
- package/dist/atoms/CellMore.d.ts +2 -0
- package/dist/atoms/CellMore.js +4 -0
- package/dist/atoms/DisabledReason.d.ts +11 -0
- package/dist/atoms/DisabledReason.js +10 -0
- package/dist/atoms/DrillRows.d.ts +2 -2
- package/dist/atoms/DrillRows.js +7 -5
- package/dist/atoms/Loading.d.ts +6 -0
- package/dist/atoms/Loading.js +4 -1
- package/dist/atoms/PanelRows.js +3 -5
- package/dist/atoms/Pill.d.ts +2 -0
- package/dist/atoms/Pill.js +25 -0
- package/dist/atoms/RangeCalendar.d.ts +8 -0
- package/dist/atoms/RangeCalendar.js +30 -0
- package/dist/atoms/RelationRoles.js +2 -2
- package/dist/atoms/SelectionSheet.js +5 -4
- package/dist/atoms/ToolbarButton.d.ts +2 -0
- package/dist/atoms/ToolbarButton.js +18 -0
- package/dist/atoms/defaults.js +10 -0
- package/dist/atoms/types.d.ts +141 -1
- package/dist/cells/cell-format.d.ts +10 -1
- package/dist/cells/cell-title.d.ts +5 -1
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +22 -7
- package/dist/cells/relation-wrap.js +1 -1
- package/dist/contract.d.ts +351 -15
- package/dist/contract.js +482 -4
- package/dist/display/actor.js +1 -1
- package/dist/display/boolean.js +5 -0
- package/dist/display/entity-chip.d.ts +12 -9
- package/dist/display/entity-chip.js +4 -5
- package/dist/display/fit-values.d.ts +34 -0
- package/dist/display/fit-values.js +45 -0
- package/dist/display/location.js +1 -1
- package/dist/display/multi-value.js +72 -8
- package/dist/display/options.d.ts +9 -1
- package/dist/display/relation.js +1 -1
- package/dist/display/rich-text.js +17 -6
- package/dist/display/select.js +6 -4
- package/dist/display/status-steps.d.ts +8 -0
- package/dist/display/status-steps.js +18 -0
- package/dist/display/viewer.js +1 -0
- package/dist/editors/BodyFrame.d.ts +29 -0
- package/dist/editors/BodyFrame.js +80 -0
- package/dist/editors/DateEditor.js +13 -17
- package/dist/editors/LocationEditor.d.ts +2 -0
- package/dist/editors/LocationEditor.js +29 -5
- package/dist/editors/NameEditor.d.ts +2 -0
- package/dist/editors/NameEditor.js +27 -7
- package/dist/editors/NumberEditor.d.ts +18 -0
- package/dist/editors/NumberEditor.js +29 -2
- package/dist/editors/RangeEditor.d.ts +2 -0
- package/dist/editors/RangeEditor.js +29 -4
- package/dist/editors/SelectEditor.d.ts +5 -0
- package/dist/editors/SelectEditor.js +3 -2
- package/dist/editors/TextEditor.d.ts +11 -1
- package/dist/editors/TextEditor.js +25 -8
- package/dist/editors/ValueListEditor.d.ts +7 -0
- package/dist/editors/ValueListEditor.js +60 -48
- package/dist/editors/body-panel.d.ts +7 -0
- package/dist/editors/body-panel.js +8 -0
- package/dist/editors/edit-session.d.ts +20 -3
- package/dist/editors/edit-session.js +43 -3
- package/dist/editors/leave-scope.d.ts +23 -0
- package/dist/editors/leave-scope.js +28 -0
- package/dist/editors/number-body.d.ts +29 -0
- package/dist/editors/number-body.js +37 -0
- package/dist/editors/parts-body.d.ts +66 -0
- package/dist/editors/parts-body.js +114 -0
- package/dist/editors/tab-ends.d.ts +5 -0
- package/dist/editors/tab-ends.js +7 -0
- package/dist/editors/text-body.d.ts +16 -0
- package/dist/editors/text-body.js +30 -0
- package/dist/editors/values-body.d.ts +47 -0
- package/dist/editors/values-body.js +140 -0
- package/dist/field-row/FieldRow.d.ts +7 -0
- package/dist/field-row/FieldRow.js +44 -24
- package/dist/field-row/FieldRowLane.js +12 -4
- package/dist/field-row/editors/RowChipsEditor.js +3 -1
- package/dist/field-row/editors/RowEditor.js +2 -1
- package/dist/field-row/editors/RowNameEditor.d.ts +5 -2
- package/dist/field-row/editors/RowNameEditor.js +12 -5
- package/dist/field-row/editors/RowNumberEditor.js +18 -2
- package/dist/field-row/editors/RowPlaceEditor.js +4 -2
- package/dist/field-row/editors/RowRangeEditor.d.ts +5 -2
- package/dist/field-row/editors/RowRangeEditor.js +13 -6
- package/dist/field-row/editors/RowRelationEditor.js +5 -2
- package/dist/field-row/editors/RowSelectEditor.js +4 -1
- package/dist/field-row/editors/RowTextEditor.d.ts +1 -1
- package/dist/field-row/editors/RowTextEditor.js +12 -3
- package/dist/field-row/editors/RowValueListEditor.d.ts +2 -1
- package/dist/field-row/editors/RowValueListEditor.js +17 -4
- package/dist/field-row/editors/host.d.ts +3 -0
- package/dist/field-row/editors/row-session.d.ts +12 -1
- package/dist/field-row/editors/row-session.js +52 -2
- package/dist/field-row/field-row-button.d.ts +40 -0
- package/dist/field-row/field-row-button.js +18 -0
- package/dist/field-row/field-row-checkbox.d.ts +9 -0
- package/dist/field-row/field-row-checkbox.js +7 -0
- package/dist/filters/filter-model.d.ts +2 -0
- package/dist/grid/chrome/GridAddColumn.js +17 -3
- package/dist/grid/chrome/GridAggregateMenu.d.ts +2 -0
- package/dist/grid/chrome/GridAggregateMenu.js +2 -0
- package/dist/grid/chrome/GridCellEditors.js +16 -6
- package/dist/grid/chrome/GridCellOutline.d.ts +7 -4
- package/dist/grid/chrome/GridCellOutline.js +4 -2
- package/dist/grid/chrome/GridChipsEditor.js +3 -1
- package/dist/grid/chrome/GridColumnMenu.d.ts +4 -1
- package/dist/grid/chrome/GridColumnMenu.js +5 -3
- package/dist/grid/chrome/GridColumnSortSection.d.ts +20 -0
- package/dist/grid/chrome/GridColumnSortSection.js +18 -1
- package/dist/grid/chrome/GridFooter.d.ts +4 -1
- package/dist/grid/chrome/GridFooter.js +6 -4
- package/dist/grid/chrome/GridGroupMenu.d.ts +5 -1
- package/dist/grid/chrome/GridGroupMenu.js +30 -8
- package/dist/grid/chrome/GridHeader.d.ts +5 -1
- package/dist/grid/chrome/GridHeader.js +9 -5
- package/dist/grid/chrome/GridLongTextEditor.js +15 -11
- package/dist/grid/chrome/GridNameEditor.js +4 -2
- package/dist/grid/chrome/GridNumberEditor.d.ts +8 -1
- package/dist/grid/chrome/GridNumberEditor.js +15 -3
- package/dist/grid/chrome/GridPager.d.ts +7 -0
- package/dist/grid/chrome/GridPager.js +34 -0
- package/dist/grid/chrome/GridPlaceEditor.js +4 -2
- package/dist/grid/chrome/GridRangeEditor.js +12 -4
- package/dist/grid/chrome/GridRelationEditor.js +5 -2
- package/dist/grid/chrome/GridRow.js +18 -6
- package/dist/grid/chrome/GridRowActions.d.ts +8 -3
- package/dist/grid/chrome/GridRowActions.js +16 -6
- package/dist/grid/chrome/GridRowCells.js +23 -7
- package/dist/grid/chrome/GridRowGlyph.d.ts +3 -1
- package/dist/grid/chrome/GridRowGlyph.js +7 -2
- package/dist/grid/chrome/GridSelectEditor.js +6 -3
- package/dist/grid/chrome/GridStructure.d.ts +6 -1
- package/dist/grid/chrome/GridStructure.js +32 -8
- package/dist/grid/chrome/GridTable.js +36 -24
- package/dist/grid/chrome/GridTableSurface.d.ts +5 -1
- package/dist/grid/chrome/GridTableSurface.js +5 -2
- package/dist/grid/chrome/GridTextEditor.d.ts +5 -1
- package/dist/grid/chrome/GridTextEditor.js +13 -3
- package/dist/grid/chrome/GridValueListEditor.d.ts +12 -4
- package/dist/grid/chrome/GridValueListEditor.js +11 -3
- package/dist/grid/chrome/StuckMarker.d.ts +3 -1
- package/dist/grid/chrome/StuckMarker.js +6 -2
- package/dist/grid/chrome/cells.d.ts +4 -2
- package/dist/grid/chrome/cells.js +2 -2
- package/dist/grid/chrome/grid-add-column-items.d.ts +1 -1
- package/dist/grid/chrome/grid-add-column-items.js +8 -1
- package/dist/grid/chrome/grid-button.d.ts +32 -0
- package/dist/grid/chrome/grid-button.js +12 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +38 -0
- package/dist/grid/chrome/grid-cell-classes.js +30 -0
- package/dist/grid/chrome/grid-column-menu-items.d.ts +3 -0
- package/dist/grid/chrome/grid-column-menu-items.js +32 -3
- package/dist/grid/chrome/grid-columns-template.d.ts +27 -0
- package/dist/grid/chrome/grid-columns-template.js +13 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +4 -1
- package/dist/grid/chrome/grid-edit-session.js +11 -1
- package/dist/grid/chrome/grid-group-menu-items.d.ts +8 -1
- package/dist/grid/chrome/grid-group-menu-items.js +17 -0
- package/dist/grid/chrome/grid-group-menu-parts.d.ts +10 -6
- package/dist/grid/chrome/grid-group-menu-parts.js +4 -2
- package/dist/grid/chrome/grid-hover.d.ts +4 -1
- package/dist/grid/chrome/grid-hover.js +16 -6
- package/dist/grid/chrome/grid-pages.d.ts +15 -0
- package/dist/grid/chrome/grid-pages.js +9 -0
- package/dist/grid/chrome/grid-row-menu-items.js +18 -10
- package/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/dist/grid/chrome/grid-row-window.d.ts +7 -0
- package/dist/grid/chrome/grid-row-window.js +35 -1
- package/dist/grid/chrome/grid-table-props.d.ts +38 -4
- package/dist/grid/chrome/useGridColumnLayout.d.ts +3 -1
- package/dist/grid/chrome/useGridColumnLayout.js +29 -9
- package/dist/grid/chrome/useGridPartColumns.js +1 -1
- package/dist/grid/chrome/useGridScrollArea.js +2 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +5 -3
- package/dist/grid/chrome/useGridTableSelection.d.ts +3 -1
- package/dist/grid/chrome/useGridTableSelection.js +2 -2
- package/dist/grid/chrome/useHeaderDragReorder.js +2 -0
- package/dist/grid/core/editing-controller.d.ts +36 -11
- package/dist/grid/core/editing-controller.js +92 -25
- package/dist/grid/core/grid-aria.d.ts +4 -0
- package/dist/grid/core/grid-aria.js +6 -4
- package/dist/grid/core/grid-focus.d.ts +6 -0
- package/dist/grid/core/grid-focus.js +28 -5
- package/dist/grid/core/useGridEditing.d.ts +11 -2
- package/dist/grid/core/useGridEditing.js +9 -5
- package/dist/grid/core/write-states.d.ts +20 -0
- package/dist/grid/core/write-states.js +21 -0
- package/dist/grid/grid-format-props.d.ts +26 -0
- package/dist/grid/grid-format-props.js +65 -0
- package/dist/grid/index.d.ts +3 -1
- package/dist/grid/index.js +1 -0
- package/dist/grid/useGridTablePrefs.d.ts +19 -20
- package/dist/grid/useGridTablePrefs.js +6 -58
- package/dist/grid/useGridTableSettings.d.ts +60 -0
- package/dist/grid/useGridTableSettings.js +61 -0
- package/dist/internal/count.d.ts +3 -0
- package/dist/internal/count.js +3 -0
- package/dist/model/body-frame.d.ts +16 -0
- package/dist/model/body-frame.js +5 -0
- package/dist/model/column-capabilities.d.ts +4 -1
- package/dist/model/column-capabilities.js +4 -1
- package/dist/model/column-filters.d.ts +7 -4
- package/dist/model/column-filters.js +26 -18
- package/dist/model/column-inspect.d.ts +3 -2
- package/dist/model/column-inspect.js +3 -1
- package/dist/model/column-sort.d.ts +11 -0
- package/dist/model/column-sort.js +14 -0
- package/dist/model/one-value.d.ts +6 -0
- package/dist/model/one-value.js +5 -0
- package/dist/model/part-write.js +1 -1
- package/dist/model/place-parts.d.ts +6 -0
- package/dist/model/place-parts.js +14 -0
- package/dist/model/relation-filters.d.ts +13 -2
- package/dist/model/relation-filters.js +9 -4
- package/dist/model/row-icon.d.ts +16 -6
- package/dist/model/settings-columns.d.ts +34 -0
- package/dist/model/settings-columns.js +146 -0
- package/dist/model/settings-look.d.ts +17 -0
- package/dist/model/settings-look.js +23 -0
- package/dist/model/view-rules.js +6 -2
- package/dist/panels/availability.d.ts +26 -0
- package/dist/panels/availability.js +28 -0
- package/dist/panels/filter/DateFilterBody.d.ts +42 -0
- package/dist/panels/filter/DateFilterBody.js +64 -0
- package/dist/panels/filter/DateFilterCalendar.d.ts +19 -0
- package/dist/panels/filter/DateFilterCalendar.js +37 -0
- package/dist/panels/filter/DateFilterInput.d.ts +16 -0
- package/dist/panels/filter/DateFilterInput.js +37 -0
- package/dist/panels/filter/FilterIcon.d.ts +7 -0
- package/dist/panels/filter/FilterIcon.js +15 -0
- package/dist/panels/filter/MenuSelect.d.ts +12 -0
- package/dist/panels/filter/MenuSelect.js +34 -0
- package/dist/panels/filter/NumberFilterBody.d.ts +21 -0
- package/dist/panels/filter/NumberFilterBody.js +76 -0
- package/dist/panels/filter/RangeFilterBody.d.ts +19 -0
- package/dist/panels/filter/RangeFilterBody.js +71 -0
- package/dist/panels/filter/RelationFilterBody.d.ts +17 -0
- package/dist/panels/filter/RelationFilterBody.js +20 -0
- package/dist/panels/filter/TextFilterBody.d.ts +31 -0
- package/dist/panels/filter/TextFilterBody.js +44 -0
- package/dist/panels/filter/TimeScopeDetail.d.ts +6 -0
- package/dist/panels/filter/TimeScopeDetail.js +47 -0
- package/dist/panels/filter/details.d.ts +17 -0
- package/dist/panels/filter/details.js +73 -0
- package/dist/panels/filter/filter-list.d.ts +23 -0
- package/dist/panels/filter/filter-list.js +38 -0
- package/dist/panels/group-sort.d.ts +24 -0
- package/dist/panels/group-sort.js +58 -0
- package/dist/panels/index.d.ts +24 -0
- package/dist/panels/index.js +17 -0
- package/dist/panels/labels.d.ts +37 -0
- package/dist/panels/labels.js +166 -0
- package/dist/panels/model.d.ts +343 -0
- package/dist/panels/model.js +77 -0
- package/dist/panels/react/GroupBucketsList.d.ts +16 -0
- package/dist/panels/react/GroupBucketsList.js +38 -0
- package/dist/panels/react/LayoutColumnsList.d.ts +24 -0
- package/dist/panels/react/LayoutColumnsList.js +71 -0
- package/dist/panels/react/PopoverColumnDetail.d.ts +11 -0
- package/dist/panels/react/PopoverColumnDetail.js +24 -0
- package/dist/panels/react/chrome.d.ts +17 -0
- package/dist/panels/react/chrome.js +8 -0
- package/dist/panels/react/column-refusals.d.ts +7 -0
- package/dist/panels/react/column-refusals.js +14 -0
- package/dist/panels/react/customize.d.ts +26 -0
- package/dist/panels/react/customize.js +98 -0
- package/dist/panels/react/drag.d.ts +2 -0
- package/dist/panels/react/drag.js +6 -0
- package/dist/panels/react/field-editor.d.ts +10 -0
- package/dist/panels/react/field-editor.js +1 -0
- package/dist/panels/react/filter-panel.d.ts +15 -0
- package/dist/panels/react/filter-panel.js +48 -0
- package/dist/panels/react/layout-detail.d.ts +4 -0
- package/dist/panels/react/layout-detail.js +21 -0
- package/dist/panels/react/order-details.d.ts +32 -0
- package/dist/panels/react/order-details.js +81 -0
- package/dist/panels/react/panel-header.d.ts +10 -0
- package/dist/panels/react/panel-header.js +12 -0
- package/dist/panels/react/panel-sheet.d.ts +19 -0
- package/dist/panels/react/panel-sheet.js +22 -0
- package/dist/panels/react/popover.d.ts +71 -0
- package/dist/panels/react/popover.js +47 -0
- package/dist/panels/react/root-list.d.ts +6 -0
- package/dist/panels/react/root-list.js +31 -0
- package/dist/panels/react/toolbar/ReadyToolbar.d.ts +42 -0
- package/dist/panels/react/toolbar/ReadyToolbar.js +92 -0
- package/dist/panels/react/toolbar/Toolbar.d.ts +16 -0
- package/dist/panels/react/toolbar/Toolbar.js +34 -0
- package/dist/panels/react/toolbar/ToolbarButton.d.ts +5 -0
- package/dist/panels/react/toolbar/ToolbarButton.js +9 -0
- package/dist/panels/react/toolbar/ToolbarFilter.d.ts +19 -0
- package/dist/panels/react/toolbar/ToolbarFilter.js +32 -0
- package/dist/panels/react/toolbar/ToolbarNew.d.ts +12 -0
- package/dist/panels/react/toolbar/ToolbarNew.js +21 -0
- package/dist/panels/react/toolbar/ToolbarOptions.d.ts +25 -0
- package/dist/panels/react/toolbar/ToolbarOptions.js +33 -0
- package/dist/panels/react/toolbar/ToolbarSearch.d.ts +9 -0
- package/dist/panels/react/toolbar/ToolbarSearch.js +41 -0
- package/dist/panels/react/toolbar/ToolbarSort.d.ts +12 -0
- package/dist/panels/react/toolbar/ToolbarSort.js +16 -0
- package/dist/panels/react/toolbar/ToolbarViews.d.ts +13 -0
- package/dist/panels/react/toolbar/ToolbarViews.js +24 -0
- package/dist/panels/react/toolbar/context.d.ts +29 -0
- package/dist/panels/react/toolbar/context.js +49 -0
- package/dist/panels/react/toolbar/panel-part.d.ts +37 -0
- package/dist/panels/react/toolbar/panel-part.js +37 -0
- package/dist/panels/react/toolbar/panel-state.d.ts +9 -0
- package/dist/panels/react/toolbar/panel-state.js +12 -0
- package/dist/panels/react/toolbar/use-box-narrow.d.ts +2 -0
- package/dist/panels/react/toolbar/use-box-narrow.js +18 -0
- package/dist/panels/react/toolbar/use-list-settings-state.d.ts +10 -0
- package/dist/panels/react/toolbar/use-list-settings-state.js +10 -0
- package/dist/panels/react/view-actions.d.ts +4 -0
- package/dist/panels/react/view-actions.js +37 -0
- package/dist/panels/react/view-footer.d.ts +16 -0
- package/dist/panels/react/view-footer.js +11 -0
- package/dist/panels/react/views-row/FoldingViewRow.d.ts +4 -0
- package/dist/panels/react/views-row/FoldingViewRow.js +105 -0
- package/dist/panels/react/views-row/HScrollRow.d.ts +7 -0
- package/dist/panels/react/views-row/HScrollRow.js +42 -0
- package/dist/panels/react/views-row/PillGroup.d.ts +30 -0
- package/dist/panels/react/views-row/PillGroup.js +86 -0
- package/dist/panels/react/views-row/ViewAxes.d.ts +6 -0
- package/dist/panels/react/views-row/ViewAxes.js +16 -0
- package/dist/panels/react/views-row/ViewCreatePill.d.ts +7 -0
- package/dist/panels/react/views-row/ViewCreatePill.js +11 -0
- package/dist/panels/react/views-row/ViewPicker.d.ts +5 -0
- package/dist/panels/react/views-row/ViewPicker.js +65 -0
- package/dist/panels/react/views-row/ViewPickerRow.d.ts +7 -0
- package/dist/panels/react/views-row/ViewPickerRow.js +18 -0
- package/dist/panels/react/views-row/ViewTabs.d.ts +31 -0
- package/dist/panels/react/views-row/ViewTabs.js +29 -0
- package/dist/panels/react/views-row/menu-classes.d.ts +6 -0
- package/dist/panels/react/views-row/menu-classes.js +3 -0
- package/dist/panels/react/views-row/use-anchored-toggle.d.ts +19 -0
- package/dist/panels/react/views-row/use-anchored-toggle.js +31 -0
- package/dist/panels/react.d.ts +51 -0
- package/dist/panels/react.js +43 -0
- package/dist/panels/settings/axes.d.ts +28 -0
- package/dist/panels/settings/axes.js +71 -0
- package/dist/panels/settings/filters.d.ts +5 -0
- package/dist/panels/settings/filters.js +62 -0
- package/dist/panels/settings/group-buckets.d.ts +23 -0
- package/dist/panels/settings/group-buckets.js +73 -0
- package/dist/panels/settings/input.d.ts +69 -0
- package/dist/panels/settings/input.js +1 -0
- package/dist/panels/settings/layout.d.ts +5 -0
- package/dist/panels/settings/layout.js +244 -0
- package/dist/panels/settings/order.d.ts +19 -0
- package/dist/panels/settings/order.js +271 -0
- package/dist/panels/settings/settings-panels.d.ts +17 -0
- package/dist/panels/settings/settings-panels.js +28 -0
- package/dist/panels/toolbar/clear.d.ts +9 -0
- package/dist/panels/toolbar/clear.js +26 -0
- package/dist/panels/toolbar/counts.d.ts +15 -0
- package/dist/panels/toolbar/counts.js +21 -0
- package/dist/panels/toolbar/edit-view.d.ts +5 -0
- package/dist/panels/toolbar/edit-view.js +18 -0
- package/dist/panels/toolbar/model.d.ts +34 -0
- package/dist/panels/toolbar/model.js +52 -0
- package/dist/panels/use-filter-opened.d.ts +8 -0
- package/dist/panels/use-filter-opened.js +11 -0
- package/dist/panels/view-state.d.ts +38 -0
- package/dist/panels/view-state.js +1 -0
- package/dist/panels/views-row/model.d.ts +131 -0
- package/dist/panels/views-row/model.js +14 -0
- package/dist/provider/ViewsProvider.d.ts +46 -6
- package/dist/provider/ViewsProvider.js +32 -2
- package/dist/provider/components.d.ts +258 -11
- package/dist/provider/context.d.ts +21 -2
- package/dist/react.d.ts +5 -2
- package/dist/selection/SelectionBar.js +13 -7
- package/dist/selection/bar-overflow.js +14 -1
- package/dist/selection/bar-parts.d.ts +4 -2
- package/dist/selection/bar-parts.js +5 -3
- package/dist/selection/useListSelectionShortcuts.d.ts +3 -2
- package/dist/selection/useListSelectionShortcuts.js +1 -1
- package/dist/selection/verbs.d.ts +7 -0
- package/docs/contract.md +307 -41
- package/docs/getting-started.md +1 -1
- package/docs/guides/atoms.md +37 -5
- package/docs/guides/columns.md +1 -1
- package/docs/guides/display.md +3 -2
- package/docs/guides/editors.md +4 -3
- package/docs/guides/selection.md +4 -2
- package/docs/guides/the-grid.md +21 -11
- package/docs/guides/the-provider.md +22 -6
- package/docs/index.md +2 -2
- package/docs/install.md +2 -3
- package/docs/reference/cells.md +1 -1
- package/docs/reference/display.md +5 -4
- package/docs/reference/editors-location.md +3 -1
- package/docs/reference/editors-name.md +3 -1
- package/docs/reference/editors-number.md +1 -0
- package/docs/reference/editors-range.md +3 -1
- package/docs/reference/editors-session.md +1 -0
- package/docs/reference/editors-text.md +2 -2
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/field-row.md +2 -2
- package/docs/reference/grid.md +8 -5
- package/docs/reference/panels-react.md +101 -0
- package/docs/reference/panels.md +123 -0
- package/docs/reference/react.md +39 -16
- package/docs/reference/selection.md +5 -5
- package/docs/reference/views.md +17 -12
- package/package.json +16 -6
- package/skills/views/SKILL.md +4 -3
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { partKey, settingsChange, } from "@viewkitjs/fields/query";
|
|
2
|
+
import { resolveViewColumnOrder } from "./column-capabilities.js";
|
|
3
|
+
import { columnDefaultHidden } from "./column-state.js";
|
|
4
|
+
import { fieldKeyOf } from "./view-rules.js";
|
|
5
|
+
export function columnRefOf(column) {
|
|
6
|
+
return column.partOf
|
|
7
|
+
? { key: column.partOf.field.key, part: column.partOf.part }
|
|
8
|
+
: { key: fieldKeyOf(column) };
|
|
9
|
+
}
|
|
10
|
+
export function settingsColumnId(ref) {
|
|
11
|
+
return ref.part === undefined ? ref.key : partKey(ref.key, ref.part);
|
|
12
|
+
}
|
|
13
|
+
export function isSettingsColumn(column) {
|
|
14
|
+
return !!column && (!!column.field || !!column.custom || !!column.partOf);
|
|
15
|
+
}
|
|
16
|
+
function columnsBySettingsId(columns) {
|
|
17
|
+
return new Map(columns.map((column) => [settingsColumnId(columnRefOf(column)), column]));
|
|
18
|
+
}
|
|
19
|
+
function figureOf(kind) {
|
|
20
|
+
return kind && kind !== "none" && kind !== "ratio" ? kind : null;
|
|
21
|
+
}
|
|
22
|
+
export function columnStateOf(settings, layer, columns) {
|
|
23
|
+
const byId = columnsBySettingsId(columns);
|
|
24
|
+
const order = [];
|
|
25
|
+
const hidden = [];
|
|
26
|
+
const visible = [];
|
|
27
|
+
const breaks = [];
|
|
28
|
+
const widths = {};
|
|
29
|
+
for (const placed of settings.columns) {
|
|
30
|
+
const column = byId.get(settingsColumnId(placed));
|
|
31
|
+
if (!column)
|
|
32
|
+
continue;
|
|
33
|
+
order.push(column.id);
|
|
34
|
+
if (!placed.visible)
|
|
35
|
+
hidden.push(column.id);
|
|
36
|
+
else if (columnDefaultHidden(column, settings.layout))
|
|
37
|
+
visible.push(column.id);
|
|
38
|
+
if (placed.lineBreak)
|
|
39
|
+
breaks.push(column.id);
|
|
40
|
+
if (placed.width !== undefined)
|
|
41
|
+
widths[column.id] = placed.width;
|
|
42
|
+
}
|
|
43
|
+
for (const [id, width] of Object.entries(layer.widths ?? {})) {
|
|
44
|
+
const column = byId.get(id);
|
|
45
|
+
if (column)
|
|
46
|
+
widths[column.id] = width;
|
|
47
|
+
}
|
|
48
|
+
return { order, hidden, visible, widths, breaks };
|
|
49
|
+
}
|
|
50
|
+
export function columnsChangeOf(settings, layer, state, columns) {
|
|
51
|
+
const byGridId = new Map(columns.map((column) => [column.id, column]));
|
|
52
|
+
const bySettingsId = columnsBySettingsId(columns);
|
|
53
|
+
const placedById = new Map(settings.columns.map((placed) => [settingsColumnId(placed), placed]));
|
|
54
|
+
const hidden = state.hidden ?? [];
|
|
55
|
+
const shown = state.visible ?? [];
|
|
56
|
+
const breaks = state.breaks ?? [];
|
|
57
|
+
const named = state.order?.length
|
|
58
|
+
? state.order
|
|
59
|
+
: settings.columns.map((placed) => bySettingsId.get(settingsColumnId(placed))?.id ?? placed.key);
|
|
60
|
+
const unnamed = [...hidden, ...shown, ...breaks].some((id) => isSettingsColumn(byGridId.get(id)) && !named.includes(id));
|
|
61
|
+
const order = unnamed ? resolveViewColumnOrder([...columns], named) : named;
|
|
62
|
+
const placed = [];
|
|
63
|
+
for (const id of order) {
|
|
64
|
+
const column = byGridId.get(id);
|
|
65
|
+
if (!isSettingsColumn(column))
|
|
66
|
+
continue;
|
|
67
|
+
const ref = columnRefOf(column);
|
|
68
|
+
const previous = placedById.get(settingsColumnId(ref));
|
|
69
|
+
const figure = previous
|
|
70
|
+
? previous.figure
|
|
71
|
+
: column.field
|
|
72
|
+
? figureOf(column.defaultAggregate)
|
|
73
|
+
: null;
|
|
74
|
+
placed.push({
|
|
75
|
+
key: ref.key,
|
|
76
|
+
...(ref.part !== undefined ? { part: ref.part } : {}),
|
|
77
|
+
visible: !hidden.includes(id) &&
|
|
78
|
+
(!columnDefaultHidden(column, settings.layout) || shown.includes(id)),
|
|
79
|
+
...(previous?.width !== undefined ? { width: previous.width } : {}),
|
|
80
|
+
...(figure ? { figure } : {}),
|
|
81
|
+
...(breaks.includes(id) ? { lineBreak: true } : {}),
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const placedIds = new Set(placed.map(settingsColumnId));
|
|
85
|
+
let cursor = 0;
|
|
86
|
+
for (const kept of settings.columns) {
|
|
87
|
+
const id = settingsColumnId(kept);
|
|
88
|
+
if (placedIds.has(id)) {
|
|
89
|
+
cursor = placed.findIndex((column) => settingsColumnId(column) === id) + 1;
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
placed.splice(cursor, 0, kept);
|
|
93
|
+
cursor += 1;
|
|
94
|
+
}
|
|
95
|
+
const change = settingsChange(settings, { ...settings, columns: placed });
|
|
96
|
+
if (Object.keys(state).length === 0)
|
|
97
|
+
return { change, layer: null };
|
|
98
|
+
const next = state.widths ?? {};
|
|
99
|
+
const seen = columnStateOf(settings, layer, columns).widths ?? {};
|
|
100
|
+
const widths = { ...layer.widths };
|
|
101
|
+
let changed = false;
|
|
102
|
+
for (const [id, width] of Object.entries(next)) {
|
|
103
|
+
if (seen[id] === width)
|
|
104
|
+
continue;
|
|
105
|
+
const column = byGridId.get(id);
|
|
106
|
+
widths[column ? settingsColumnId(columnRefOf(column)) : id] = width;
|
|
107
|
+
changed = true;
|
|
108
|
+
}
|
|
109
|
+
for (const column of columns) {
|
|
110
|
+
const key = settingsColumnId(columnRefOf(column));
|
|
111
|
+
if (layer.widths?.[key] === undefined || next[column.id] !== undefined)
|
|
112
|
+
continue;
|
|
113
|
+
delete widths[key];
|
|
114
|
+
changed = true;
|
|
115
|
+
}
|
|
116
|
+
return { change, layer: changed ? { widths } : null };
|
|
117
|
+
}
|
|
118
|
+
export function aggregatesOf(settings, columns) {
|
|
119
|
+
const byId = columnsBySettingsId(columns);
|
|
120
|
+
const aggregates = {};
|
|
121
|
+
for (const placed of settings.columns) {
|
|
122
|
+
const column = byId.get(settingsColumnId(placed));
|
|
123
|
+
if (!column)
|
|
124
|
+
continue;
|
|
125
|
+
if (placed.figure)
|
|
126
|
+
aggregates[column.id] = placed.figure;
|
|
127
|
+
else if (column.defaultAggregate)
|
|
128
|
+
aggregates[column.id] = "none";
|
|
129
|
+
}
|
|
130
|
+
return aggregates;
|
|
131
|
+
}
|
|
132
|
+
export function figuresChangeOf(settings, aggregates, columns) {
|
|
133
|
+
const byId = columnsBySettingsId(columns);
|
|
134
|
+
const next = settings.columns.map((placed) => {
|
|
135
|
+
const column = byId.get(settingsColumnId(placed));
|
|
136
|
+
if (!column)
|
|
137
|
+
return placed;
|
|
138
|
+
const figure = column.field ? figureOf(aggregates[column.id]) : null;
|
|
139
|
+
const { figure: _held, ...rest } = placed;
|
|
140
|
+
return figure ? { ...rest, figure } : rest;
|
|
141
|
+
});
|
|
142
|
+
return settingsChange(settings, { ...settings, columns: next });
|
|
143
|
+
}
|
|
144
|
+
export function columnsReset(settings, columns) {
|
|
145
|
+
return columnsChangeOf(settings, {}, {}, columns).change;
|
|
146
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ListDensity, type ListPersonalLayer, type ListSettings, type ListSettingsChange } from "@viewkitjs/fields/query";
|
|
2
|
+
import { type ListDefaults } from "./prefs-buckets.js";
|
|
3
|
+
/** Every look setting, resolved. */
|
|
4
|
+
export type SeenLook = {
|
|
5
|
+
density: ListDensity;
|
|
6
|
+
verticalBorders: boolean;
|
|
7
|
+
rowIcon: boolean;
|
|
8
|
+
freezeIdentity: boolean;
|
|
9
|
+
alwaysCheckboxes: boolean;
|
|
10
|
+
};
|
|
11
|
+
/** The look a person sees: their layer's, else the view's, else the default (the reader's own, for vertical
|
|
12
|
+
* borders). */
|
|
13
|
+
export declare function seenLook(settings: ListSettings, layer: ListPersonalLayer, defaults?: ListDefaults): SeenLook;
|
|
14
|
+
/** One look setting set on the view, as a change. `null` takes it out. Vertical borders set to the reader's default
|
|
15
|
+
* is the view following that default: the key is taken out, so a default changed later still reaches the view.
|
|
16
|
+
* Empty when nothing changes. */
|
|
17
|
+
export declare function lookChange<K extends keyof SeenLook>(settings: ListSettings, key: K, value: SeenLook[K] | null, defaults?: ListDefaults): ListSettingsChange;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { settingsChange, } from "@viewkitjs/fields/query";
|
|
2
|
+
import { LIST_VIEW_PREF_DEFAULTS } from "./preferences.js";
|
|
3
|
+
import { verticalBordersDefault } from "./prefs-buckets.js";
|
|
4
|
+
export function seenLook(settings, layer, defaults) {
|
|
5
|
+
const view = settings.look;
|
|
6
|
+
const own = layer.look ?? {};
|
|
7
|
+
return {
|
|
8
|
+
density: own.density ?? view.density ?? LIST_VIEW_PREF_DEFAULTS.gridScale,
|
|
9
|
+
verticalBorders: own.verticalBorders ?? view.verticalBorders ?? verticalBordersDefault(defaults),
|
|
10
|
+
rowIcon: own.rowIcon ?? view.rowIcon ?? LIST_VIEW_PREF_DEFAULTS.gridRowIcon,
|
|
11
|
+
freezeIdentity: own.freezeIdentity ?? view.freezeIdentity ?? LIST_VIEW_PREF_DEFAULTS.gridFreezeIdentity,
|
|
12
|
+
alwaysCheckboxes: own.alwaysCheckboxes ?? view.alwaysCheckboxes ?? LIST_VIEW_PREF_DEFAULTS.gridAlwaysCheckboxes,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export function lookChange(settings, key, value, defaults) {
|
|
16
|
+
const follows = key === "verticalBorders" && value === verticalBordersDefault(defaults);
|
|
17
|
+
const look = { ...settings.look };
|
|
18
|
+
if (follows || value === null)
|
|
19
|
+
delete look[key];
|
|
20
|
+
else
|
|
21
|
+
look[key] = value;
|
|
22
|
+
return settingsChange(settings, { ...settings, look });
|
|
23
|
+
}
|
package/dist/model/view-rules.js
CHANGED
|
@@ -2,6 +2,7 @@ import { valueTypeOf } from "@viewkitjs/fields";
|
|
|
2
2
|
import { denominationOf } from "../fields/denomination.js";
|
|
3
3
|
import { isFilterGroup, isRelationRule, operatorsFor, } from "@viewkitjs/fields/query";
|
|
4
4
|
import { FILTER_PART_ROWS, partKey } from "./part-rows.js";
|
|
5
|
+
import { keptParts } from "./place-parts.js";
|
|
5
6
|
export function fieldKeyOf(col) {
|
|
6
7
|
return col.field?.key ?? col.id;
|
|
7
8
|
}
|
|
@@ -159,7 +160,10 @@ export function rootRulesByColumn(tree, columns, opts) {
|
|
|
159
160
|
const col = columns.find((c) => fieldKeyOf(c) === item.fieldKey);
|
|
160
161
|
if (!col?.field)
|
|
161
162
|
continue;
|
|
162
|
-
const
|
|
163
|
+
const type = valueTypeOf(col.field);
|
|
164
|
+
if (item.part !== undefined && !keptParts(col.field, FILTER_PART_ROWS[type] ?? []).includes(item.part))
|
|
165
|
+
continue;
|
|
166
|
+
const rule = toListFilterRule(type, item, opts);
|
|
163
167
|
if (rule)
|
|
164
168
|
out[item.part === undefined ? col.id : partKey(col.id, item.part)] = rule;
|
|
165
169
|
}
|
|
@@ -174,7 +178,7 @@ function columnRows(columns, opts) {
|
|
|
174
178
|
const fieldKey = fieldKeyOf(col);
|
|
175
179
|
rows.push({ key: col.id, fieldKey, type });
|
|
176
180
|
if (opts?.parts)
|
|
177
|
-
for (const part of FILTER_PART_ROWS[type] ?? [])
|
|
181
|
+
for (const part of keptParts(col.field, FILTER_PART_ROWS[type] ?? []))
|
|
178
182
|
rows.push({ key: partKey(col.id, part), fieldKey, type, part });
|
|
179
183
|
}
|
|
180
184
|
return rows;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type ViewsMessageResolver } from "../contract.js";
|
|
2
|
+
import type { LayoutConfig, LayoutViewChoice, ToggleConfig, ViewOptionInputs } from "./model.js";
|
|
3
|
+
/**
|
|
4
|
+
* Which sections of the view options exist for a render, and on which
|
|
5
|
+
* viewport. Split from `model.ts` — the server-safe contracts — so that file
|
|
6
|
+
* holds shapes and the small predicates on them, and this one the two
|
|
7
|
+
* resolutions the desktop popover and the mobile sheet both draw from.
|
|
8
|
+
*/
|
|
9
|
+
/** What the "For you" section actually shows, resolved once so the desktop
|
|
10
|
+
* popover and the mobile sheet can't drift on the gate or the fallback label —
|
|
11
|
+
* they render the same three fields with different chrome. `null` means the
|
|
12
|
+
* section does not exist for this render (no `personal`, or one with nothing
|
|
13
|
+
* in it for the active view). */
|
|
14
|
+
type ResolvedPersonalSection<V extends string = string> = {
|
|
15
|
+
label: string;
|
|
16
|
+
toggles: ToggleConfig[];
|
|
17
|
+
choices: LayoutViewChoice<V>[];
|
|
18
|
+
onReset?: () => void;
|
|
19
|
+
};
|
|
20
|
+
export declare function resolvePersonalSection<V extends string>(layout: LayoutConfig<V>, messages?: ViewsMessageResolver): ResolvedPersonalSection<V> | null;
|
|
21
|
+
/** Desktop-only controls must not create an empty mobile View sheet. */
|
|
22
|
+
export declare function getViewOptionAvailability<S extends string, G extends string, T extends string>({ filters, sort, group, timeScopeConfig, dateRangeConfigs, toggles, layout, }: ViewOptionInputs<S, G, T>): {
|
|
23
|
+
desktop: boolean;
|
|
24
|
+
mobile: boolean;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { resolveViewsMessage } from "../contract.js";
|
|
2
|
+
export function resolvePersonalSection(layout, messages = resolveViewsMessage) {
|
|
3
|
+
const personal = layout.personal;
|
|
4
|
+
if (!personal)
|
|
5
|
+
return null;
|
|
6
|
+
const toggles = personal.toggles ?? [];
|
|
7
|
+
const choices = (personal.choices ?? []).filter((choice) => !choice.views || choice.views.includes(layout.value));
|
|
8
|
+
if (toggles.length === 0 && choices.length === 0)
|
|
9
|
+
return null;
|
|
10
|
+
return {
|
|
11
|
+
label: personal.label ?? messages({ key: "views.panels.for-you" }),
|
|
12
|
+
toggles,
|
|
13
|
+
choices,
|
|
14
|
+
onReset: personal.onReset,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export function getViewOptionAvailability({ filters, sort, group, timeScopeConfig, dateRangeConfigs, toggles, layout, }) {
|
|
18
|
+
const shared = !!filters?.length || !!sort || !!group || !!timeScopeConfig || !!dateRangeConfigs?.length;
|
|
19
|
+
const hasPersonal = layout ? resolvePersonalSection(layout) !== null : false;
|
|
20
|
+
const mobileLayout = !!layout &&
|
|
21
|
+
(hasPersonal ||
|
|
22
|
+
!layout.desktopOnly ||
|
|
23
|
+
(layout.mobileValue != null && layout.onMobileChange !== undefined));
|
|
24
|
+
return {
|
|
25
|
+
desktop: shared || !!toggles?.length || !!layout,
|
|
26
|
+
mobile: shared || !!toggles?.some((toggle) => !toggle.desktopOnly) || mobileLayout,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { type Dispatch, type ReactNode, type RefObject, type SetStateAction } from "react";
|
|
2
|
+
import { type DateFilterEditingEnd } from "./DateFilterCalendar.js";
|
|
3
|
+
import type { FilterConfigDate } from "../../filters/filter-model.js";
|
|
4
|
+
import { type DateFilterOperator, type DateFilterRule } from "@viewkitjs/fields/query";
|
|
5
|
+
/** The date editor's state, shared by the popover's editor and the sheet's. */
|
|
6
|
+
export type DateFilterEditor = {
|
|
7
|
+
rule: DateFilterRule;
|
|
8
|
+
dates: 0 | 1 | 2;
|
|
9
|
+
relative: boolean;
|
|
10
|
+
editing: DateFilterEditingEnd;
|
|
11
|
+
setEditing: Dispatch<SetStateAction<DateFilterEditingEnd>>;
|
|
12
|
+
fromInputRef: RefObject<HTMLInputElement | null>;
|
|
13
|
+
toInputRef: RefObject<HTMLInputElement | null>;
|
|
14
|
+
set: (patch: Partial<DateFilterRule>) => void;
|
|
15
|
+
setOperator: (op: DateFilterOperator) => void;
|
|
16
|
+
};
|
|
17
|
+
export declare function useDateFilterEditor(filter: FilterConfigDate): DateFilterEditor;
|
|
18
|
+
/**
|
|
19
|
+
* Everything under the operator: the date fields when the rule takes dates,
|
|
20
|
+
* the host's relative pair when it is relative, then the calendar.
|
|
21
|
+
*/
|
|
22
|
+
export declare function DateFilterFields({ editor, relativePair, cellSize, }: {
|
|
23
|
+
editor: DateFilterEditor;
|
|
24
|
+
relativePair: ReactNode;
|
|
25
|
+
cellSize: string;
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
/**
|
|
28
|
+
* The date dimension's editor: the operator, the relative pair when it
|
|
29
|
+
* applies, then a full-width calendar.
|
|
30
|
+
*
|
|
31
|
+
* MENUS rather than a radio list, unlike the text and number editors. A date
|
|
32
|
+
* rule is up to three choices at once (operator × direction × unit) and the
|
|
33
|
+
* calendar has to stay in view while they are made — nine stacked radio rows
|
|
34
|
+
* would push it off the panel, which is the one thing the editor exists to
|
|
35
|
+
* show. A phone's sheet draws its own body around `DateFilterFields` instead:
|
|
36
|
+
* a menu portals out of a sheet, and its closing press closes the sheet.
|
|
37
|
+
*/
|
|
38
|
+
export declare function DateFilterBody({ filter, fieldClassName, }: {
|
|
39
|
+
filter: FilterConfigDate;
|
|
40
|
+
/** The editor's padding, in place of the default. */
|
|
41
|
+
fieldClassName?: string;
|
|
42
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState, } from "react";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { useViews } from "../../provider/context.js";
|
|
6
|
+
import { DateFilterCalendar } from "./DateFilterCalendar.js";
|
|
7
|
+
import { DateFilterInput } from "./DateFilterInput.js";
|
|
8
|
+
import { MenuSelect } from "./MenuSelect.js";
|
|
9
|
+
import { DATE_FILTER_OPERATORS, dateFilterOperatorLabel, DEFAULT_DATE_FILTER_RULE, RELATIVE_DIRECTIONS, RELATIVE_UNITS, dateFilterDates, } from "@viewkitjs/fields/query";
|
|
10
|
+
const EDITOR_PADDING = "px-2 pt-2 pb-1";
|
|
11
|
+
const UNSET_RULE = { operator: "is", from: null, to: null };
|
|
12
|
+
export function useDateFilterEditor(filter) {
|
|
13
|
+
const [editing, setEditing] = useState("from");
|
|
14
|
+
const fromInputRef = useRef(null);
|
|
15
|
+
const toInputRef = useRef(null);
|
|
16
|
+
const rule = filter.value ?? UNSET_RULE;
|
|
17
|
+
const set = (patch) => filter.onChange({ ...rule, ...patch });
|
|
18
|
+
const setOperator = (op) => {
|
|
19
|
+
const shape = dateFilterDates(op);
|
|
20
|
+
setEditing("from");
|
|
21
|
+
set({
|
|
22
|
+
operator: op,
|
|
23
|
+
from: shape === 0 ? null : rule.from,
|
|
24
|
+
to: shape === 2 ? rule.to : null,
|
|
25
|
+
...(op === "is_relative"
|
|
26
|
+
? {
|
|
27
|
+
direction: rule.direction ?? DEFAULT_DATE_FILTER_RULE.direction,
|
|
28
|
+
unit: rule.unit ?? DEFAULT_DATE_FILTER_RULE.unit,
|
|
29
|
+
}
|
|
30
|
+
: {}),
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
return {
|
|
34
|
+
rule,
|
|
35
|
+
dates: dateFilterDates(rule.operator),
|
|
36
|
+
relative: rule.operator === "is_relative",
|
|
37
|
+
editing,
|
|
38
|
+
setEditing,
|
|
39
|
+
fromInputRef,
|
|
40
|
+
toInputRef,
|
|
41
|
+
set,
|
|
42
|
+
setOperator,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
export function DateFilterFields({ editor, relativePair, cellSize, }) {
|
|
46
|
+
const { messages } = useViews();
|
|
47
|
+
const { rule, dates, relative, editing, setEditing, fromInputRef, toInputRef, set } = editor;
|
|
48
|
+
return (_jsxs(_Fragment, { children: [dates > 0 && (_jsxs("div", { className: "flex items-center gap-2", children: [_jsx(DateFilterInput, { value: rule.from ?? null, onCommit: (key) => set({ from: key }), placeholder: messages({ key: dates === 2 ? "views.panels.date-start" : "views.panels.date-placeholder" }), active: editing === "from", onActivate: () => setEditing("from"), inputRef: fromInputRef }), dates === 2 && (_jsx(DateFilterInput, { value: rule.to ?? null, onCommit: (key) => set({ to: key }), placeholder: messages({ key: "views.panels.date-end" }), active: editing === "to", onActivate: () => setEditing("to"), inputRef: toInputRef }))] })), relative && relativePair, (dates > 0 || relative) && (_jsx(DateFilterCalendar, { rule: rule, dates: dates, relative: relative, editing: editing, setEditing: setEditing, setRule: set, fromInputRef: fromInputRef, toInputRef: toInputRef, cellSize: cellSize }))] }));
|
|
49
|
+
}
|
|
50
|
+
export function DateFilterBody({ filter, fieldClassName, }) {
|
|
51
|
+
const { conventions, messages } = useViews();
|
|
52
|
+
const editor = useDateFilterEditor(filter);
|
|
53
|
+
const { rule, set } = editor;
|
|
54
|
+
const operators = DATE_FILTER_OPERATORS.map((op) => ({ ...op, label: dateFilterOperatorLabel(op.value, conventions) }));
|
|
55
|
+
const directions = RELATIVE_DIRECTIONS.map((d) => ({
|
|
56
|
+
...d,
|
|
57
|
+
label: conventions.messages({ key: "filter.relative-direction", values: { direction: d.value } }),
|
|
58
|
+
}));
|
|
59
|
+
const units = RELATIVE_UNITS.map((u) => ({
|
|
60
|
+
...u,
|
|
61
|
+
label: conventions.messages({ key: "filter.relative-unit", values: { unit: u.value } }),
|
|
62
|
+
}));
|
|
63
|
+
return (_jsxs("div", { "data-vs-inset": true, className: cx("space-y-2", fieldClassName ?? EDITOR_PADDING), children: [_jsx("div", { children: _jsx(MenuSelect, { value: rule.operator, options: operators, onChange: (next) => editor.setOperator(next), label: messages({ key: "views.panels.date-operator" }), look: "sentence" }) }), _jsx(DateFilterFields, { editor: editor, cellSize: "1.875rem", relativePair: _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(MenuSelect, { value: rule.direction ?? "this", options: directions, onChange: (direction) => set({ direction }), label: messages({ key: "views.panels.date-direction" }), look: "field", className: "flex-1" }), _jsx(MenuSelect, { value: rule.unit ?? "week", options: units, onChange: (unit) => set({ unit }), label: messages({ key: "views.panels.date-unit" }), look: "field", className: "flex-1" })] }) })] }));
|
|
64
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Dispatch, RefObject, SetStateAction } from "react";
|
|
2
|
+
import { type DateFilterRule } from "@viewkitjs/fields/query";
|
|
3
|
+
export type DateFilterEditingEnd = "from" | "to";
|
|
4
|
+
/**
|
|
5
|
+
* The date filter's month and its armed range-end interaction contract, drawn through the
|
|
6
|
+
* `RangeCalendar` atom. The end being edited is ALWAYS one of the two: a press sets it, and on a
|
|
7
|
+
* two-date rule hands the caret to the other end's box.
|
|
8
|
+
*/
|
|
9
|
+
export declare function DateFilterCalendar({ rule, dates, relative, editing, setEditing, setRule, fromInputRef, toInputRef, cellSize, }: {
|
|
10
|
+
rule: DateFilterRule;
|
|
11
|
+
dates: number;
|
|
12
|
+
relative: boolean;
|
|
13
|
+
editing: DateFilterEditingEnd;
|
|
14
|
+
setEditing: Dispatch<SetStateAction<DateFilterEditingEnd>>;
|
|
15
|
+
setRule: (patch: Partial<DateFilterRule>) => void;
|
|
16
|
+
fromInputRef: RefObject<HTMLInputElement | null>;
|
|
17
|
+
toInputRef: RefObject<HTMLInputElement | null>;
|
|
18
|
+
cellSize: string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../../provider/context.js";
|
|
4
|
+
import { resolveRelativeWindow } from "@viewkitjs/fields/query";
|
|
5
|
+
export function DateFilterCalendar({ rule, dates, relative, editing, setEditing, setRule, fromInputRef, toInputRef, cellSize, }) {
|
|
6
|
+
const { atoms, conventions, messages } = useViews();
|
|
7
|
+
const preview = relative
|
|
8
|
+
? resolveRelativeWindow(rule.direction ?? "this", rule.unit ?? "week", undefined, conventions)
|
|
9
|
+
: null;
|
|
10
|
+
const limit = (() => {
|
|
11
|
+
if (dates !== 2)
|
|
12
|
+
return undefined;
|
|
13
|
+
const other = editing === "from" ? rule.to : rule.from;
|
|
14
|
+
if (!other)
|
|
15
|
+
return undefined;
|
|
16
|
+
return editing === "from" ? { after: other } : { before: other };
|
|
17
|
+
})();
|
|
18
|
+
return (_jsxs("div", { onMouseDown: (event) => {
|
|
19
|
+
if (editing)
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
}, children: [_jsx(atoms.RangeCalendar, { mode: dates === 2 || relative ? "range" : "single", from: rule.from ?? null, to: dates === 2 ? (rule.to ?? null) : null, armed: editing, limit: limit, window: preview ? { from: preview.from, to: preview.to } : undefined, cellSize: cellSize, locale: conventions.locale, onSelect: (next, day) => {
|
|
22
|
+
if (relative)
|
|
23
|
+
return;
|
|
24
|
+
if (dates !== 2 && !relative) {
|
|
25
|
+
setRule({ from: next.from });
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
if (day) {
|
|
29
|
+
setRule(editing === "from" ? { from: day } : { to: day });
|
|
30
|
+
const nextEnd = editing === "from" ? "to" : "from";
|
|
31
|
+
setEditing(nextEnd);
|
|
32
|
+
(nextEnd === "to" ? toInputRef : fromInputRef).current?.focus();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
setRule({ from: next.from, to: next.to });
|
|
36
|
+
} }), relative && (_jsx("p", { className: "pt-1 text-[11px] text-(color:--vk-fg-subtle)", children: messages({ key: "views.panels.date-relative-note" }) }))] }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RefObject } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* A date that can be typed without replacing the calendar. The draft remains
|
|
4
|
+
* local while it is incomplete; only a complete day or an explicit clear is
|
|
5
|
+
* committed to the filter rule.
|
|
6
|
+
*/
|
|
7
|
+
export declare function DateFilterInput({ value, onCommit, placeholder, active, onActivate, inputRef, }: {
|
|
8
|
+
value: string | null;
|
|
9
|
+
onCommit: (key: string | null) => void;
|
|
10
|
+
placeholder: string;
|
|
11
|
+
/** The calendar continues to target this end even while it owns the click. */
|
|
12
|
+
active?: boolean;
|
|
13
|
+
onActivate?: () => void;
|
|
14
|
+
/** Allows a calendar pick to hand the caret to the opposite range end. */
|
|
15
|
+
inputRef?: RefObject<HTMLInputElement | null>;
|
|
16
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { formatDayInput, parseDateInput } from "@viewkitjs/fields/query";
|
|
6
|
+
const ACTIVE_BOX = "bg-(color:--vk-neutral) ring-1 ring-(color:--vk-border-brand)";
|
|
7
|
+
export function DateFilterInput({ value, onCommit, placeholder, active = false, onActivate, inputRef, }) {
|
|
8
|
+
const { PanelSearch } = useViews().atoms;
|
|
9
|
+
const [draft, setDraft] = useState(formatDayInput(value));
|
|
10
|
+
const committed = useRef(value);
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (value !== committed.current) {
|
|
13
|
+
committed.current = value;
|
|
14
|
+
setDraft(formatDayInput(value));
|
|
15
|
+
}
|
|
16
|
+
}, [value]);
|
|
17
|
+
const commit = (raw) => {
|
|
18
|
+
const key = raw.trim() === "" ? null : parseDateInput(raw);
|
|
19
|
+
if (raw.trim() !== "" && key == null)
|
|
20
|
+
return;
|
|
21
|
+
committed.current = key;
|
|
22
|
+
onCommit(key);
|
|
23
|
+
};
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
if (draft === formatDayInput(committed.current))
|
|
26
|
+
return;
|
|
27
|
+
const id = setTimeout(() => commit(draft), 300);
|
|
28
|
+
return () => clearTimeout(id);
|
|
29
|
+
}, [draft]);
|
|
30
|
+
return (_jsx("div", { className: "min-w-0 flex-1", children: _jsx(PanelSearch, { value: draft, onChange: setDraft, onClear: () => {
|
|
31
|
+
setDraft("");
|
|
32
|
+
commit("");
|
|
33
|
+
}, onKeyDown: (event) => {
|
|
34
|
+
if (event.key === "Enter")
|
|
35
|
+
commit(draft);
|
|
36
|
+
}, onFocus: onActivate, inputRef: inputRef, className: active ? ACTIVE_BOX : undefined, placeholder: placeholder, leading: null, inputMode: "numeric" }) }));
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { FilterConfig } from "../../filters/filter-model.js";
|
|
3
|
+
/** A filter row's glyph: the filter's own, else its kind's, else the plain filter mark. */
|
|
4
|
+
export declare function FilterIcon<T extends string>({ filter, className, }: {
|
|
5
|
+
filter: FilterConfig<T>;
|
|
6
|
+
className: string;
|
|
7
|
+
}): ReactNode;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useViews } from "../../provider/context.js";
|
|
4
|
+
const FILTER_KIND_ICONS = {
|
|
5
|
+
status: "filterStatus",
|
|
6
|
+
category: "filterCategory",
|
|
7
|
+
metric: "filterMetric",
|
|
8
|
+
};
|
|
9
|
+
export function FilterIcon({ filter, className, }) {
|
|
10
|
+
const { icons } = useViews();
|
|
11
|
+
if (filter.icon)
|
|
12
|
+
return filter.icon;
|
|
13
|
+
const Glyph = icons[(filter.kind && FILTER_KIND_ICONS[filter.kind]) || "filter"];
|
|
14
|
+
return _jsx(Glyph, { className: className });
|
|
15
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function MenuSelect<V extends string>({ value, options, onChange, label, look, className, }: {
|
|
2
|
+
value: V;
|
|
3
|
+
options: readonly {
|
|
4
|
+
value: V;
|
|
5
|
+
label: string;
|
|
6
|
+
}[];
|
|
7
|
+
onChange: (next: V) => void;
|
|
8
|
+
/** The menu's name, which a screen reader announces as it opens. */
|
|
9
|
+
label: string;
|
|
10
|
+
look: "sentence" | "field";
|
|
11
|
+
className?: string;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { cx } from "../../internal/cx.js";
|
|
5
|
+
import { ELEMENT_RESET } from "../../internal/reset.js";
|
|
6
|
+
import { useViews } from "../../provider/context.js";
|
|
7
|
+
const LOOKS = {
|
|
8
|
+
sentence: "inline-flex items-center gap-1 whitespace-nowrap text-sm font-medium text-(color:--vk-fg)",
|
|
9
|
+
field: "flex h-8 w-full items-center justify-between gap-1 whitespace-nowrap rounded-lg border border-(color:--vk-border) px-2.5 text-sm text-(color:--vk-fg)",
|
|
10
|
+
};
|
|
11
|
+
export function MenuSelect({ value, options, onChange, label, look, className, }) {
|
|
12
|
+
const { components, icons } = useViews();
|
|
13
|
+
const { Menu } = components;
|
|
14
|
+
const Chevron = icons.chevronDown;
|
|
15
|
+
const [open, setOpen] = useState(false);
|
|
16
|
+
const anchor = useRef(null);
|
|
17
|
+
const openAtPress = useRef(null);
|
|
18
|
+
const chosen = options.find((option) => option.value === value)?.label ?? value;
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { ref: anchor, type: "button", "aria-haspopup": "menu", "aria-expanded": open, onPointerDownCapture: () => {
|
|
20
|
+
openAtPress.current = open;
|
|
21
|
+
}, onClick: () => {
|
|
22
|
+
const wasOpen = openAtPress.current ?? open;
|
|
23
|
+
openAtPress.current = null;
|
|
24
|
+
setOpen(!wasOpen);
|
|
25
|
+
}, className: cx(ELEMENT_RESET, LOOKS[look], className), children: [_jsx("span", { className: "truncate", children: chosen }), _jsx(Chevron, { className: cx("size-4 shrink-0", look === "sentence" ? "opacity-60" : "opacity-50") })] }), _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, label: label, items: options.map((option) => ({
|
|
26
|
+
key: option.value,
|
|
27
|
+
label: option.label,
|
|
28
|
+
checked: option.value === value,
|
|
29
|
+
onSelect: () => {
|
|
30
|
+
setOpen(false);
|
|
31
|
+
onChange(option.value);
|
|
32
|
+
},
|
|
33
|
+
})) })] }));
|
|
34
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { FilterConfigNumber } from "../../filters/filter-model.js";
|
|
3
|
+
/**
|
|
4
|
+
* The numeric dimension's editor: the bound(s), then the operator list. Same
|
|
5
|
+
* shape as the text one — one body for both surfaces, box above the operators.
|
|
6
|
+
*
|
|
7
|
+
* `between` grows a second box rather than opening a sub-panel: a range is one
|
|
8
|
+
* thought, and splitting it across a drill-in makes you leave the screen to
|
|
9
|
+
* finish the sentence you started.
|
|
10
|
+
*/
|
|
11
|
+
export declare function NumberFilterBody({ filter, rowClassName, rowBorderClassName, labelClassName, checkClassName, fieldClassName, wrapRows, autoFocus, }: {
|
|
12
|
+
filter: FilterConfigNumber;
|
|
13
|
+
rowClassName?: string;
|
|
14
|
+
rowBorderClassName?: string;
|
|
15
|
+
labelClassName?: string;
|
|
16
|
+
checkClassName?: string;
|
|
17
|
+
/** The boxes' padding, in place of the default. */
|
|
18
|
+
fieldClassName?: string;
|
|
19
|
+
wrapRows?: (rows: ReactNode) => ReactNode;
|
|
20
|
+
autoFocus?: boolean;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|