viewkitjs 0.29.0 → 0.30.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 +111 -0
- package/MIGRATION.md +97 -8
- package/package.json +1 -1
- package/views/dist/cells/cell-format.d.ts +2 -2
- package/views/dist/cells/cell-values.js +0 -2
- package/views/dist/contract.d.ts +15 -18
- package/views/dist/contract.js +13 -27
- package/views/dist/controls/controls.d.ts +2 -4
- package/views/dist/controls/controls.js +2 -2
- package/views/dist/controls/customize/customize.d.ts +51 -0
- package/views/dist/controls/customize/customize.js +128 -23
- package/views/dist/controls/customize/map-customize-body.d.ts +0 -3
- package/views/dist/controls/customize/map-customize-body.js +46 -11
- package/views/dist/controls/customize/map-ranges.d.ts +23 -0
- package/views/dist/controls/customize/map-ranges.js +41 -0
- package/views/dist/controls/customize/rules.d.ts +17 -1
- package/views/dist/controls/customize/rules.js +2 -0
- package/views/dist/controls/customize/words.d.ts +7 -0
- package/views/dist/controls/customize/words.js +5 -0
- package/views/dist/controls/customize.css +3 -0
- package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +1 -0
- package/views/dist/controls/filter-editor/rules.d.ts +1 -2
- package/views/dist/controls/index.d.ts +8 -8
- package/views/dist/controls/index.js +8 -8
- package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
- package/views/dist/controls/menu-list/menu-list.js +26 -8
- package/views/dist/controls/menu-list.css +8 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +1 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +6 -3
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
- package/views/dist/controls/text-editor/map-text-body.js +2 -2
- package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
- package/views/dist/controls/text-editor/text-editor.js +16 -2
- package/views/dist/controls/text-editor.css +11 -0
- package/views/dist/controls/values-editor/values.js +6 -2
- package/views/dist/display/options.d.ts +1 -1
- package/views/dist/display/rich-text.js +0 -1
- package/views/dist/editors/ChipsEditor.d.ts +4 -5
- package/views/dist/editors/ChipsEditor.js +12 -78
- package/views/dist/editors/DateEditor.d.ts +12 -16
- package/views/dist/editors/DateEditor.js +40 -191
- package/views/dist/editors/EditorPanel.d.ts +2 -6
- package/views/dist/editors/EditorPanel.js +2 -2
- package/views/dist/editors/LocationEditor.d.ts +11 -19
- package/views/dist/editors/LocationEditor.js +19 -211
- package/views/dist/editors/NameEditor.d.ts +8 -16
- package/views/dist/editors/NameEditor.js +11 -100
- package/views/dist/editors/NumberEditor.d.ts +14 -21
- package/views/dist/editors/NumberEditor.js +22 -49
- package/views/dist/editors/RangeEditor.d.ts +9 -33
- package/views/dist/editors/RangeEditor.js +12 -97
- package/views/dist/editors/RelationEditor.d.ts +6 -9
- package/views/dist/editors/RelationEditor.js +11 -30
- package/views/dist/editors/RelationSetEditor.d.ts +13 -24
- package/views/dist/editors/RelationSetEditor.js +33 -101
- package/views/dist/editors/SelectEditor.d.ts +15 -17
- package/views/dist/editors/SelectEditor.js +15 -94
- package/views/dist/editors/TextEditor.d.ts +23 -26
- package/views/dist/editors/TextEditor.js +11 -48
- package/views/dist/editors/ValueListEditor.d.ts +14 -23
- package/views/dist/editors/ValueListEditor.js +16 -202
- package/views/dist/editors/body-panel.d.ts +13 -7
- package/views/dist/editors/body-panel.js +3 -7
- package/views/dist/editors/edit-cores.d.ts +15 -15
- package/views/dist/editors/edit-cores.js +14 -14
- package/views/dist/editors/number-body.d.ts +1 -1
- package/views/dist/editors/number-step.d.ts +0 -34
- package/views/dist/editors/number-step.js +0 -37
- package/views/dist/editors/option-add-flow.d.ts +1 -13
- package/views/dist/editors/option-add-flow.js +0 -22
- package/views/dist/editors/relation-links-body.d.ts +2 -3
- package/views/dist/editors/relation-picker.d.ts +13 -3
- package/views/dist/editors/relation-source.d.ts +0 -22
- package/views/dist/editors/relation-source.js +0 -21
- package/views/dist/field-row/FieldRow.js +5 -6
- package/views/dist/field-row/FieldRowLane.js +0 -1
- package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
- package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
- package/views/dist/field-row/editors/RowDateEditor.js +2 -2
- package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowNameEditor.js +7 -12
- package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
- package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
- package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
- package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
- package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowTextEditor.js +3 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
- package/views/dist/field-row/field-row-button.d.ts +6 -9
- package/views/dist/field-row/field-row-button.js +1 -6
- package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
- package/views/dist/field-row/row-target.d.ts +0 -7
- package/views/dist/field-row/row-target.js +0 -2
- package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
- package/views/dist/grid/chrome/GridAddColumn.js +8 -66
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
- package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
- package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
- package/views/dist/grid/chrome/GridCellEditors.js +12 -12
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
- package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
- package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
- package/views/dist/grid/chrome/GridDateEditor.js +3 -3
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
- package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
- package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
- package/views/dist/grid/chrome/GridNameEditor.js +4 -4
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
- package/views/dist/grid/chrome/GridNumberEditor.js +3 -4
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
- package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
- package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
- package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
- package/views/dist/grid/chrome/GridRow.js +0 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
- package/views/dist/grid/chrome/GridRowActions.js +0 -5
- package/views/dist/grid/chrome/GridRowCells.js +9 -6
- package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
- package/views/dist/grid/chrome/GridStructure.js +0 -1
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
- package/views/dist/grid/chrome/GridTextEditor.js +4 -17
- package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
- package/views/dist/grid/chrome/grid-body-place.js +4 -8
- package/views/dist/grid/chrome/grid-button.d.ts +7 -10
- package/views/dist/grid/chrome/grid-button.js +1 -6
- package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
- package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
- package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
- package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
- package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
- package/views/dist/grid/chrome/grid-hover.js +0 -1
- package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
- package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
- package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
- package/views/dist/grid/core/editing-controller.d.ts +2 -1
- package/views/dist/grid/core/editing-controller.js +10 -2
- package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/views/dist/grid/core/refusal-sentence.js +2 -2
- package/views/dist/grid/core/write-states.d.ts +3 -1
- package/views/dist/grid/core/write-states.js +6 -2
- package/views/dist/grid/grid.css +1 -1
- package/views/dist/model/body-frame.d.ts +0 -32
- package/views/dist/model/body-frame.js +1 -15
- package/views/dist/model/column-inspect.d.ts +5 -5
- package/views/dist/model/column-inspect.js +2 -2
- package/views/dist/panels/customize-body.d.ts +1 -10
- package/views/dist/panels/customize-body.js +0 -3
- package/views/dist/panels/filter/MenuSelect.js +0 -5
- package/views/dist/panels/filter/RangeFilterBody.js +0 -1
- package/views/dist/panels/filter/details.d.ts +1 -5
- package/views/dist/panels/filter/details.js +0 -13
- package/views/dist/panels/filter/filter-list.d.ts +0 -1
- package/views/dist/panels/filter/filter-list.js +1 -1
- package/views/dist/panels/panel-button.d.ts +10 -12
- package/views/dist/panels/panel-button.js +1 -6
- package/views/dist/panels/react/chrome.d.ts +0 -17
- package/views/dist/panels/react/chrome.js +0 -8
- package/views/dist/panels/react/customize-body.d.ts +9 -12
- package/views/dist/panels/react/customize-body.js +57 -11
- package/views/dist/panels/react/customize.d.ts +9 -12
- package/views/dist/panels/react/customize.js +3 -112
- package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
- package/views/dist/panels/react/filter/FilterEditor.js +6 -330
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +27 -59
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
- package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
- package/views/dist/panels/react/filter/editor-ctx.js +5 -33
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
- package/views/dist/panels/react/filter/filter-part-body.js +0 -5
- package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
- package/views/dist/panels/react/filter/rule-writes.js +4 -95
- package/views/dist/panels/react/order-details.d.ts +1 -26
- package/views/dist/panels/react/order-details.js +3 -69
- package/views/dist/panels/react/panel-header.js +0 -1
- package/views/dist/panels/react/popover.d.ts +4 -7
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -137
- package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
- package/views/dist/panels/react/sort/SortEditor.js +8 -245
- package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
- package/views/dist/panels/react/sort/SortFieldList.js +11 -25
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -16
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
- package/views/dist/panels/react/view-actions.js +0 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +2 -5
- package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +7 -43
- package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
- package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
- package/views/dist/panels/react/views-row/menu-classes.js +0 -2
- package/views/dist/panels/react.d.ts +5 -12
- package/views/dist/panels/react.js +5 -12
- package/views/dist/provider/ViewsProvider.d.ts +2 -46
- package/views/dist/provider/ViewsProvider.js +2 -22
- package/views/dist/provider/components.d.ts +153 -106
- package/views/dist/provider/context.d.ts +1 -21
- package/views/dist/provider/missing-slot.d.ts +3 -7
- package/views/dist/provider/missing-slot.js +2 -9
- package/views/dist/react.d.ts +1 -2
- package/views/dist/selection/SelectionBar.js +2 -3
- package/views/dist/styles.css +40 -168
- package/views/dist/styles.unlayered.css +40 -168
- package/views/docs/contract.md +99 -123
- package/views/docs/getting-started.md +222 -2
- package/views/docs/guides/cells.md +222 -2
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/editors.md +235 -20
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/selection.md +1 -1
- package/views/docs/guides/the-grid.md +14 -16
- package/views/docs/guides/the-provider.md +9 -15
- package/views/docs/reference/cells.md +1 -1
- package/views/docs/reference/controls.md +26 -13
- package/views/docs/reference/editors-chips.md +2 -2
- package/views/docs/reference/editors-date.md +4 -4
- package/views/docs/reference/editors-location.md +4 -7
- package/views/docs/reference/editors-name.md +3 -5
- package/views/docs/reference/editors-number.md +10 -10
- package/views/docs/reference/editors-panel.md +3 -3
- package/views/docs/reference/editors-range.md +3 -5
- package/views/docs/reference/editors-relation.md +4 -4
- package/views/docs/reference/editors-select.md +3 -3
- package/views/docs/reference/editors-text.md +3 -4
- package/views/docs/reference/editors-value-list.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -2
- package/views/docs/reference/panels-react.md +20 -34
- package/views/docs/reference/react.md +11 -18
- package/views/docs/reference/views.md +5 -5
- package/views/skills/views/SKILL.md +1 -1
- package/views/dist/editors/relation-panel.d.ts +0 -69
- package/views/dist/editors/relation-panel.js +0 -46
- package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
- package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
- package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
- package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
- package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
- package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
- package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
- package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
- package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
- package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
- package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
- package/views/dist/grid/chrome/GridFlyout.js +0 -80
- package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
- package/views/dist/grid/chrome/GridMenuRow.js +0 -15
- package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
- package/views/dist/grid/chrome/grid-menu-search.js +0 -7
- package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
- package/views/dist/panels/react/GroupBucketsList.js +0 -44
- package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
- package/views/dist/panels/react/LayoutColumnsList.js +0 -101
- package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
- package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
- package/views/dist/panels/react/drag.d.ts +0 -2
- package/views/dist/panels/react/drag.js +0 -5
- package/views/dist/panels/react/layout-detail.d.ts +0 -4
- package/views/dist/panels/react/layout-detail.js +0 -29
- package/views/dist/panels/react/root-list.d.ts +0 -6
- package/views/dist/panels/react/root-list.js +0 -31
- package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
- package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
- package/views/dist/panels/react/view-footer.d.ts +0 -20
- package/views/dist/panels/react/view-footer.js +0 -41
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx
|
|
3
|
-
import { useLayoutEffect, useRef
|
|
4
|
-
import { DisabledReason } from "../../../atoms/DisabledReason.js";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useLayoutEffect, useRef } from "react";
|
|
5
4
|
import { useViews } from "../../../provider/context.js";
|
|
6
|
-
import { itemsAt, shownRuleCount } from "../../../filters/filter-tree.js";
|
|
7
|
-
import { filterWaysOf, listedFieldsOf, takesValue } from "../../settings/filter-groups.js";
|
|
8
|
-
import { PanelHeader } from "../panel-header.js";
|
|
9
|
-
import { fieldOfRule, relationOf, useEditorCtx, } from "./editor-ctx.js";
|
|
10
|
-
import { AppFilterBody } from "./filter-body.js";
|
|
11
5
|
import { usePanelStep } from "../panel-step.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { AppFilterPart, useFilterPartBody } from "./filter-part-body.js";
|
|
15
|
-
import { FilterValueBody } from "./FilterValueBody.js";
|
|
16
|
-
import { addPicked, addState, everyBlocked, pickField, pickQuantifier, pickWay, relationRuleAt, ruleAt, writeRule, } from "./rule-writes.js";
|
|
6
|
+
import { useEditorCtx } from "./editor-ctx.js";
|
|
7
|
+
import { AppFilterBody } from "./filter-body.js";
|
|
17
8
|
export function usePhoneFilterEditor(o) {
|
|
18
9
|
const { filterTree, open, onDone } = o;
|
|
19
10
|
const { messages } = useViews();
|
|
@@ -55,135 +46,8 @@ export function usePhoneFilterEditor(o) {
|
|
|
55
46
|
const body = (closeButton = true) => (_jsx(PhoneFilterEditor, { filterTree: tracked, head: closeButton ? head : null, onDone: onDone, onStepChange: step.onStepChange }));
|
|
56
47
|
return { body, head, title: step.title, escapeBack: step.escapeBack };
|
|
57
48
|
}
|
|
58
|
-
|
|
59
|
-
const {
|
|
60
|
-
const {
|
|
61
|
-
|
|
62
|
-
const { ctx, root, group, clearAll } = useEditorCtx({
|
|
63
|
-
filterTree,
|
|
64
|
-
at: [],
|
|
65
|
-
form: "phone",
|
|
66
|
-
whole: true,
|
|
67
|
-
openPage: setPage,
|
|
68
|
-
});
|
|
69
|
-
if (components.FilterBody)
|
|
70
|
-
return group ? (_jsx(AppFilterBody, { ctx: ctx, level: group, relation: null, excludable: false, label: filterTree.label ?? messages({ key: "views.panels.filter" }), onDone: onDone, actions: head ?? undefined, onStepChange: onStepChange })) : null;
|
|
71
|
-
const back = () => setPage({ to: "rules" });
|
|
72
|
-
if (!pageResolves(ctx, page))
|
|
73
|
-
setPage({ to: "rules" });
|
|
74
|
-
const turned = page.to === "rules" || !pageResolves(ctx, page) ? null : (_jsx(Turned, { ctx: ctx, page: page, setPage: setPage, back: back }));
|
|
75
|
-
const Check = icons.check;
|
|
76
|
-
const title = filterTree.label ?? messages({ key: "views.panels.filter" });
|
|
77
|
-
if (turned)
|
|
78
|
-
return (_jsx("div", { "data-slot": "vk-filter-editor", className: "flex h-full min-h-0 flex-col", children: turned }));
|
|
79
|
-
if (!group)
|
|
80
|
-
return null;
|
|
81
|
-
const shown = group.items.length > 0 || ctx.pending?.container.length === 0;
|
|
82
|
-
const { full } = addState(ctx, []);
|
|
83
|
-
return (_jsxs("div", { "data-slot": "vk-filter-editor", className: "flex h-full min-h-0 flex-col", children: [_jsx(PanelHeader, { title: title, onClose: head ? head.close.onPress : undefined, trailing: head?.done ? (_jsx(Button, { variant: "ghost", size: "icon", "aria-label": head.done.label, onClick: head.done.onPress, children: _jsx(Check, { className: "h-4 w-4" }) })) : undefined }), _jsxs("div", { ref: root, tabIndex: -1, role: "group", "aria-label": title, className: "flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto px-4 py-2 outline-none", children: [group.op === "not" && _jsx(Excluded, {}), shown ? (_jsx(Level, { ctx: ctx, items: group.items, rel: [], join: group.op, onAdd: () => { } })) : (_jsxs("div", { className: "py-4 text-center", children: [_jsx("p", { className: "text-sm font-medium text-(color:--vk-fg)", children: messages({ key: "views.panels.filter-empty" }) }), _jsx("p", { className: "text-sm text-(color:--vk-fg-subtle)", children: messages({ key: "views.panels.filter-empty-line" }) })] })), _jsxs("div", { className: "flex flex-col gap-1", children: [_jsx(DisabledReason, { reason: full ? messages({ key: "views.panels.filter-too-many" }) : null, side: "top", children: _jsx(Button, { variant: shown ? "outline" : "default", "aria-disabled": full || undefined, "aria-haspopup": "dialog", className: "w-full", onClick: () => {
|
|
84
|
-
if (!full)
|
|
85
|
-
setPage({ to: "add", rel: [] });
|
|
86
|
-
}, children: messages({ key: "views.panels.filter-add" }) }) }), full && (_jsx("p", { className: "text-center text-xs text-(color:--vk-fg-subtle)", children: messages({ key: "views.panels.filter-too-many" }) })), shownRuleCount(group) > 0 && (_jsx(Button, { variant: "ghost", className: "w-full", onClick: clearAll, children: messages({ key: "views.panels.filter-clear-all" }) }))] })] })] }));
|
|
87
|
-
}
|
|
88
|
-
function Turned({ ctx, page, setPage, back, }) {
|
|
89
|
-
const { atoms, conventions, messages } = useViews();
|
|
90
|
-
const { RadioRow } = atoms;
|
|
91
|
-
const partBody = useFilterPartBody();
|
|
92
|
-
const scroll = "min-h-0 flex-1 overflow-y-auto overscroll-contain **:data-vs-detail:max-h-none";
|
|
93
|
-
if (page.to === "add") {
|
|
94
|
-
const relation = relationOf(ctx, page.relation);
|
|
95
|
-
const { relations } = addState(ctx, page.rel, relation);
|
|
96
|
-
return (_jsxs(_Fragment, { children: [_jsx(PanelHeader, { title: messages({ key: "views.panels.filter-add" }), onBack: back }), _jsx("div", { className: scroll, children: _jsx(FilterFieldList, { fields: relation?.far ?? listedFieldsOf(ctx.filterTree), relations: relations, form: "phone", onPick: (picked, far) => {
|
|
97
|
-
const added = addPicked(ctx, page.rel, picked, far, relation);
|
|
98
|
-
setPage(added ? { to: "value", rule: added } : { to: "rules" });
|
|
99
|
-
}, onDone: back }) })] }));
|
|
100
|
-
}
|
|
101
|
-
if (page.to === "quantifier") {
|
|
102
|
-
const rule = relationRuleAt(ctx, page.rel, page.relation);
|
|
103
|
-
if (!rule)
|
|
104
|
-
return null;
|
|
105
|
-
const relation = relationOf(ctx, page.relation);
|
|
106
|
-
const label = relation?.label ?? rule.fieldKey;
|
|
107
|
-
const blocked = everyBlocked(relation, rule);
|
|
108
|
-
return (_jsxs(_Fragment, { children: [_jsx(PanelHeader, { title: label, onBack: back }), _jsx("div", { className: scroll, children: ["any", "none", "every"].map((quantifier) => {
|
|
109
|
-
const off = quantifier === "every" && blocked;
|
|
110
|
-
const why = messages({
|
|
111
|
-
key: "views.panels.relation-every-needs-where",
|
|
112
|
-
values: { one: label.toLocaleLowerCase() },
|
|
113
|
-
});
|
|
114
|
-
return (_jsxs("div", { children: [_jsx(RadioRow, { mark: "box", selected: rule.quantifier === quantifier, label: messages({
|
|
115
|
-
key: "views.panels.filter-relation-way",
|
|
116
|
-
values: { quantifier },
|
|
117
|
-
}), disabled: off, ...(off ? { disabledReason: why } : {}), onClick: () => {
|
|
118
|
-
if (off)
|
|
119
|
-
return;
|
|
120
|
-
pickQuantifier(ctx, page.rel, rule, quantifier);
|
|
121
|
-
back();
|
|
122
|
-
} }), off && _jsx("p", { className: "px-3 pb-2 text-xs text-(color:--vk-fg-subtle)", children: why })] }, quantifier));
|
|
123
|
-
}) })] }));
|
|
124
|
-
}
|
|
125
|
-
const found = ruleAt(ctx, page.rule);
|
|
126
|
-
const field = found
|
|
127
|
-
? fieldOfRule(ctx.filterTree.fields, found.rule, found.at.relation)
|
|
128
|
-
: undefined;
|
|
129
|
-
if (!found)
|
|
130
|
-
return null;
|
|
131
|
-
const { rule, at } = found;
|
|
132
|
-
if (page.to === "field")
|
|
133
|
-
return (_jsxs(_Fragment, { children: [_jsx(PanelHeader, { title: messages({ key: "views.panels.filter-field" }), onBack: back }), _jsx("div", { className: scroll, children: _jsx(FilterFieldList, { fields: at.relation?.far ?? listedFieldsOf(ctx.filterTree), own: field?.key, relations: false, form: "phone", onPick: (picked) => {
|
|
134
|
-
pickField(ctx, at, rule, field, picked);
|
|
135
|
-
back();
|
|
136
|
-
}, onDone: back }) })] }));
|
|
137
|
-
if (!field)
|
|
138
|
-
return null;
|
|
139
|
-
const write = (next) => {
|
|
140
|
-
const now = writeRule(ctx, at, next);
|
|
141
|
-
if (now && !at.rel)
|
|
142
|
-
setPage({ to: "value", rule: { ...page.rule, rel: now, fieldKey: next.fieldKey } });
|
|
143
|
-
};
|
|
144
|
-
if (page.to === "way") {
|
|
145
|
-
const ways = filterWaysOf(field, conventions);
|
|
146
|
-
return (_jsxs(_Fragment, { children: [_jsx(PanelHeader, { title: messages({ key: "views.panels.filter-way" }), onBack: back }), _jsxs("div", { className: scroll, children: [partBody ? (_jsx(AppFilterPart, { part: "way", rule: rule, field: field, options: ctx.filterTree.optionsOf?.(rule.fieldKey, rule.part, at.relation?.fieldKey), own: null, form: "phone", onWay: (operator) => {
|
|
147
|
-
pickWay(ctx, at, rule, field, operator);
|
|
148
|
-
back();
|
|
149
|
-
}, onValue: write, onDone: back })) : null, partBody ? null : ways.map((way) => (_jsxs("div", { children: [way.value === "is_empty" && (_jsx("div", { role: "separator", className: "my-1 border-t border-solid border-(color:--vk-border)" })), _jsx(RadioRow, { mark: "box", selected: way.value === rule.operator, label: way.label, onClick: () => {
|
|
150
|
-
pickWay(ctx, at, rule, field, way.value);
|
|
151
|
-
back();
|
|
152
|
-
} })] }, way.value)))] })] }));
|
|
153
|
-
}
|
|
154
|
-
const config = takesValue(rule.operator)
|
|
155
|
-
? ctx.filterTree.valueOf(rule, write, at.relation?.fieldKey)
|
|
156
|
-
: null;
|
|
157
|
-
if (!config)
|
|
158
|
-
return null;
|
|
159
|
-
return (_jsxs(_Fragment, { children: [_jsx(PanelHeader, { title: field.label, onBack: back }), _jsx("div", { className: scroll, children: partBody ? (_jsx(AppFilterPart, { part: "value", rule: rule, field: field, options: ctx.filterTree.optionsOf?.(rule.fieldKey, rule.part, at.relation?.fieldKey), own: _jsx(FilterValueBody, { filter: config }), form: "phone", onWay: (operator) => {
|
|
160
|
-
pickWay(ctx, at, rule, field, operator);
|
|
161
|
-
if (!at.rel)
|
|
162
|
-
back();
|
|
163
|
-
}, onValue: write, onDone: back })) : (_jsx(FilterValueBody, { filter: config })) })] }));
|
|
164
|
-
}
|
|
165
|
-
function pageResolves(ctx, page) {
|
|
166
|
-
switch (page.to) {
|
|
167
|
-
case "rules":
|
|
168
|
-
return true;
|
|
169
|
-
case "add":
|
|
170
|
-
return page.relation
|
|
171
|
-
? relationRuleAt(ctx, page.rel, page.relation) !== null
|
|
172
|
-
: itemsAt(ctx.view, page.rel) !== undefined;
|
|
173
|
-
case "quantifier":
|
|
174
|
-
return relationRuleAt(ctx, page.rel, page.relation) !== null;
|
|
175
|
-
default: {
|
|
176
|
-
const found = ruleAt(ctx, page.rule);
|
|
177
|
-
if (!found)
|
|
178
|
-
return false;
|
|
179
|
-
if (page.to === "field")
|
|
180
|
-
return true;
|
|
181
|
-
if (!fieldOfRule(ctx.filterTree.fields, found.rule, found.at.relation))
|
|
182
|
-
return false;
|
|
183
|
-
if (page.to !== "value")
|
|
184
|
-
return true;
|
|
185
|
-
return (takesValue(found.rule.operator) &&
|
|
186
|
-
ctx.filterTree.valueOf(found.rule, () => { }, found.at.relation?.fieldKey) !== null);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
49
|
+
function PhoneFilterEditor({ filterTree, head, onDone, onStepChange, }) {
|
|
50
|
+
const { messages } = useViews();
|
|
51
|
+
const { ctx, group } = useEditorCtx({ filterTree, at: [], form: "phone", whole: true });
|
|
52
|
+
return group ? (_jsx(AppFilterBody, { ctx: ctx, level: group, relation: null, excludable: false, label: filterTree.label ?? messages({ key: "views.panels.filter" }), onDone: onDone, actions: head ?? undefined, onStepChange: onStepChange })) : null;
|
|
189
53
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { type RefObject } from "react";
|
|
2
1
|
import { type FilterGroup, type FilterNode, type FilterRelationRule, type FilterRule, type FilterTree } from "viewkitjs/fields/query";
|
|
3
2
|
import { type FilterPath } from "../../../filters/filter-tree.js";
|
|
4
3
|
import type { FilterEditorField, FilterTreeConfig } from "../../model.js";
|
|
@@ -15,30 +14,8 @@ export type Pending = {
|
|
|
15
14
|
};
|
|
16
15
|
/** The held rule while it still stands: absent `over`, always; else while its container is as it was held over. */
|
|
17
16
|
export declare function heldStands(held: Pending | null | undefined, tree: FilterTree): Pending | null;
|
|
18
|
-
/** A rule an editor page addresses: its path from the edited container, or null for the held rule; the field it names,
|
|
19
|
-
* so a page whose rule moved under it falls back to the rules; `relation` the relation's field key for a far rule. */
|
|
20
|
-
export type RuleTarget = {
|
|
21
|
-
rel: FilterPath | null;
|
|
22
|
-
fieldKey: string;
|
|
23
|
-
relation?: string;
|
|
24
|
-
};
|
|
25
|
-
/** What the phone's sheet shows: the rules, or one box's list in their place. */
|
|
26
|
-
export type FilterEditorPage = {
|
|
27
|
-
to: "rules";
|
|
28
|
-
} | {
|
|
29
|
-
to: "field" | "way" | "value";
|
|
30
|
-
rule: RuleTarget;
|
|
31
|
-
} | {
|
|
32
|
-
to: "quantifier";
|
|
33
|
-
rel: FilterPath | null;
|
|
34
|
-
relation: string;
|
|
35
|
-
} | {
|
|
36
|
-
to: "add";
|
|
37
|
-
rel: FilterPath;
|
|
38
|
-
relation?: string;
|
|
39
|
-
};
|
|
40
17
|
export type Edit = (tree: FilterTree, at: FilterPath) => FilterTree | null;
|
|
41
|
-
/** What
|
|
18
|
+
/** What the filter editor's hosts and the bar share: the tree as drawn, where it is edited, and its writes. */
|
|
42
19
|
export type Ctx = {
|
|
43
20
|
filterTree: FilterTreeConfig;
|
|
44
21
|
/** The tree as drawn: on a computer the Or top wrapped where it will be; on the phone the tree as it is. */
|
|
@@ -58,15 +35,10 @@ export type Ctx = {
|
|
|
58
35
|
remove: (rel: FilterPath) => void;
|
|
59
36
|
pending: Pending | null;
|
|
60
37
|
setPending: (pending: Pending | null) => void;
|
|
61
|
-
/** The rule whose value opens as it is drawn: a rule just added. */
|
|
62
|
-
opensValue: string | null;
|
|
63
38
|
form: "computer" | "phone";
|
|
64
39
|
/** The phone's whole tree, edited in place (`editWhole`): its top's join turns, nothing closes on emptying. */
|
|
65
40
|
whole: boolean;
|
|
66
|
-
/** The phone's page turn; absent on a computer. */
|
|
67
|
-
openPage?: (page: FilterEditorPage) => void;
|
|
68
41
|
};
|
|
69
|
-
export declare const keyOf: (path: FilterPath) => string;
|
|
70
42
|
export declare const abs: (at: FilterPath, rel: FilterPath) => FilterPath;
|
|
71
43
|
export declare const samePath: (a: FilterPath, b: FilterPath) => boolean;
|
|
72
44
|
/** The field a rule names: the list's own, or, inside a relation, one of its far fields. */
|
|
@@ -81,7 +53,6 @@ export declare function useEditorCtx(o: {
|
|
|
81
53
|
onDone?: () => void;
|
|
82
54
|
/** A delete took a node away: the outermost one that went, so the pills' keys follow. */
|
|
83
55
|
onRemoved?: (removed: FilterPath) => void;
|
|
84
|
-
openPage?: (page: FilterEditorPage) => void;
|
|
85
56
|
/** The rule held until whole, held by the caller: handed `onPendingChange`, the editor reads it from `pending` and
|
|
86
57
|
* every change goes to `onPendingChange`, each held rule saying the container it was held over (`over`), and one
|
|
87
58
|
* a write from elsewhere left stale reads as none. Without it, the editor holds its own. */
|
|
@@ -89,10 +60,7 @@ export declare function useEditorCtx(o: {
|
|
|
89
60
|
onPendingChange?: (pending: Pending | null) => void;
|
|
90
61
|
}): {
|
|
91
62
|
ctx: Ctx;
|
|
92
|
-
root: RefObject<HTMLDivElement | null>;
|
|
93
63
|
group: FilterGroup | FilterTree | null;
|
|
94
64
|
/** The relation rule edited in place, whose where is `group`; null otherwise. */
|
|
95
65
|
relation: FilterRelationRule | null;
|
|
96
|
-
clearAll: () => void;
|
|
97
|
-
setOpensValue: (id: string | null) => void;
|
|
98
66
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLayoutEffect, useRef, useState } from "react";
|
|
3
3
|
import { isRelationRule, } from "viewkitjs/fields/query";
|
|
4
|
-
import {
|
|
4
|
+
import { editIn, editView, editWhole, nodeAt, removeAt, shownRuleCount, } from "../../../filters/filter-tree.js";
|
|
5
5
|
export function heldStands(held, tree) {
|
|
6
6
|
if (!held)
|
|
7
7
|
return null;
|
|
@@ -9,7 +9,7 @@ export function heldStands(held, tree) {
|
|
|
9
9
|
return held;
|
|
10
10
|
return JSON.stringify(nodeAt(tree, held.container)) === JSON.stringify(held.over) ? held : null;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
const keyOf = (path) => path.join(".");
|
|
13
13
|
export const abs = (at, rel) => [...at, ...rel];
|
|
14
14
|
export const samePath = (a, b) => a.length === b.length && a.every((step, i) => step === b[i]);
|
|
15
15
|
export function fieldOfRule(fields, rule, relation) {
|
|
@@ -25,7 +25,7 @@ export function relationOf(ctx, key) {
|
|
|
25
25
|
return ctx.filterTree.fields.find((field) => field.far && field.fieldKey === key);
|
|
26
26
|
}
|
|
27
27
|
export function useEditorCtx(o) {
|
|
28
|
-
const { filterTree, at, form, whole, onDone, onRemoved,
|
|
28
|
+
const { filterTree, at, form, whole, onDone, onRemoved, onPendingChange } = o;
|
|
29
29
|
const latest = useRef(filterTree.tree);
|
|
30
30
|
const atNow = useRef(at);
|
|
31
31
|
const atKey = keyOf(at);
|
|
@@ -41,8 +41,6 @@ export function useEditorCtx(o) {
|
|
|
41
41
|
else
|
|
42
42
|
onPendingChange(next && { ...next, over: nodeAt(tree, next.container) });
|
|
43
43
|
};
|
|
44
|
-
const [opensValue, setOpensValue] = useState(null);
|
|
45
|
-
const root = useRef(null);
|
|
46
44
|
const drawn = whole ? { tree: filterTree.tree, at: [] } : editView(filterTree.tree, at);
|
|
47
45
|
const orInPlace = !whole && at.length === 0 && drawn.at.length === 0;
|
|
48
46
|
const container = nodeAt(drawn.tree, drawn.at);
|
|
@@ -82,8 +80,6 @@ export function useEditorCtx(o) {
|
|
|
82
80
|
samePath(removed, edited.slice(0, removed.length)));
|
|
83
81
|
if (gone)
|
|
84
82
|
onDone?.();
|
|
85
|
-
else
|
|
86
|
-
root.current?.focus({ preventScroll: true });
|
|
87
83
|
};
|
|
88
84
|
const ctx = {
|
|
89
85
|
filterTree,
|
|
@@ -94,38 +90,14 @@ export function useEditorCtx(o) {
|
|
|
94
90
|
change,
|
|
95
91
|
remove,
|
|
96
92
|
pending,
|
|
97
|
-
setPending:
|
|
98
|
-
setPendingState(next);
|
|
99
|
-
if (next)
|
|
100
|
-
setOpensValue("pending");
|
|
101
|
-
},
|
|
102
|
-
opensValue,
|
|
93
|
+
setPending: setPendingState,
|
|
103
94
|
form,
|
|
104
95
|
whole,
|
|
105
|
-
openPage,
|
|
106
|
-
};
|
|
107
|
-
const clearAll = () => {
|
|
108
|
-
if (whole || atNow.current.length === 0) {
|
|
109
|
-
const cleared = clearedTree(latest.current);
|
|
110
|
-
if (JSON.stringify(cleared) !== JSON.stringify(latest.current)) {
|
|
111
|
-
latest.current = cleared;
|
|
112
|
-
filterTree.onChange(cleared);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const out = removeAt(latest.current, atNow.current);
|
|
117
|
-
latest.current = out.tree;
|
|
118
|
-
onRemoved?.(out.removed);
|
|
119
|
-
filterTree.onChange(out.tree);
|
|
120
|
-
}
|
|
121
|
-
setPendingState(null);
|
|
122
|
-
if (!whole)
|
|
123
|
-
onDone?.();
|
|
124
96
|
};
|
|
125
97
|
const group = relation
|
|
126
98
|
? relation.where
|
|
127
99
|
: container && "items" in container
|
|
128
100
|
? container
|
|
129
101
|
: null;
|
|
130
|
-
return { ctx,
|
|
102
|
+
return { ctx, group, relation };
|
|
131
103
|
}
|
|
@@ -2,10 +2,7 @@ import type { FilterOperator, FilterRule } from "viewkitjs/fields/query";
|
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
3
|
import type { ViewsPickerItem } from "../../../provider/components.js";
|
|
4
4
|
import type { FilterEditorField } from "../../model.js";
|
|
5
|
-
/**
|
|
6
|
-
export declare function useFilterPartBody(): boolean;
|
|
7
|
-
/** The app's `FilterPartBody` for a rule's way or value, over the holder's own writes; null when the app handed none,
|
|
8
|
-
* so the holder draws ViewKit's own. */
|
|
5
|
+
/** The app's `FilterPartBody` for a rule's way or value, over the holder's own writes. */
|
|
9
6
|
export declare function AppFilterPart({ part, rule, field, own, options, form, onWay, onValue, onDone, }: {
|
|
10
7
|
part: "way" | "value";
|
|
11
8
|
rule: FilterRule;
|
|
@@ -15,9 +12,9 @@ export declare function AppFilterPart({ part, rule, field, own, options, form, o
|
|
|
15
12
|
/** ViewKit's own value body for the rule (`<FilterValueBody filter={config} />`), null at `way`. */
|
|
16
13
|
own: ReactNode;
|
|
17
14
|
form: "computer" | "phone";
|
|
18
|
-
/** The holder's own way write (`writeBarRule(ctx, at, withOperator(…))
|
|
15
|
+
/** The holder's own way write (`writeBarRule(ctx, at, withOperator(…))`). */
|
|
19
16
|
onWay: (operator: FilterOperator) => void;
|
|
20
|
-
/** The holder's own value write (`writeBarRule(ctx, at, next)
|
|
17
|
+
/** The holder's own value write (`writeBarRule(ctx, at, next)`). */
|
|
21
18
|
onValue: (next: FilterRule) => void;
|
|
22
19
|
onDone: () => void;
|
|
23
20
|
}): ReactNode;
|
|
@@ -3,14 +3,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { useViews } from "../../../provider/context.js";
|
|
4
4
|
import { filterPartChangeFits, filterWaysOf } from "../../settings/filter-groups.js";
|
|
5
5
|
import { filterBodyFields } from "./filter-body.js";
|
|
6
|
-
export function useFilterPartBody() {
|
|
7
|
-
return !!useViews().components.FilterPartBody;
|
|
8
|
-
}
|
|
9
6
|
export function AppFilterPart({ part, rule, field, own, options, form, onWay, onValue, onDone, }) {
|
|
10
7
|
const { components, conventions, messages } = useViews();
|
|
11
8
|
const FilterPartBody = components.FilterPartBody;
|
|
12
|
-
if (!FilterPartBody)
|
|
13
|
-
return null;
|
|
14
9
|
const [shown] = filterBodyFields([field]);
|
|
15
10
|
const { far: _far, ...bodyField } = shown;
|
|
16
11
|
if (options)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type FilterRelationRule, type FilterRule, type FilterTree } from "viewkitjs/fields/query";
|
|
2
2
|
import { type FilterPath } from "../../../filters/filter-tree.js";
|
|
3
3
|
import type { FilterEditorField } from "../../model.js";
|
|
4
|
-
import { type Ctx
|
|
4
|
+
import { type Ctx } from "./editor-ctx.js";
|
|
5
5
|
/** Where a rule stands, resolved: its path, or null while it is held; the relation it is a far rule of; the held
|
|
6
6
|
* relation block it is the first far rule of. */
|
|
7
7
|
export type RuleAt = {
|
|
@@ -9,14 +9,6 @@ export type RuleAt = {
|
|
|
9
9
|
relation?: FilterEditorField;
|
|
10
10
|
inPending?: FilterRelationRule;
|
|
11
11
|
};
|
|
12
|
-
/** The rule a page's target names, read from the tree as drawn or from the held rule; null when it is gone, isn't a
|
|
13
|
-
* plain rule, or names another field than the page opened on. */
|
|
14
|
-
export declare function ruleAt(ctx: Ctx, target: RuleTarget): {
|
|
15
|
-
rule: FilterRule;
|
|
16
|
-
at: RuleAt;
|
|
17
|
-
} | null;
|
|
18
|
-
/** The relation rule at `rel` (null: the held block) naming `key`; null when it is gone. */
|
|
19
|
-
export declare function relationRuleAt(ctx: Ctx, rel: FilterPath | null, key: string): FilterRelationRule | null;
|
|
20
12
|
/** A rule's new form written: in place, or a held rule kept held or written once whole. The rule's path from the
|
|
21
13
|
* edited container once it stands in the tree (a held block's far rule: [...blockPath, 0]); null while still held or
|
|
22
14
|
* refused. */
|
|
@@ -37,20 +29,3 @@ export declare function writeHeld(ctx: Ctx, at: Omit<RuleAt, "rel">, next: Filte
|
|
|
37
29
|
export declare function pickField(ctx: Ctx, at: RuleAt, rule: FilterRule,
|
|
38
30
|
/** The rule's field; undefined for a set-aside rule, which any pick points at the field picked. */
|
|
39
31
|
field: FilterEditorField | undefined, picked: FilterEditorField): void;
|
|
40
|
-
/** A rule's way picked: written with the value it takes. */
|
|
41
|
-
export declare function pickWay(ctx: Ctx, at: RuleAt, rule: FilterRule, field: FilterEditorField, way: string): void;
|
|
42
|
-
/** Whether Every can't be picked: it needs a rule in the where that narrows something, a far rule that is whole or a
|
|
43
|
-
* group holding one. */
|
|
44
|
-
export declare function everyBlocked(relation: FilterEditorField | undefined, rule: FilterRelationRule): boolean;
|
|
45
|
-
/** A relation block's way picked: in the tree, or into its held entry. */
|
|
46
|
-
export declare function pickQuantifier(ctx: Ctx, rel: FilterPath | null, rule: FilterRelationRule, quantifier: FilterRelationRule["quantifier"]): void;
|
|
47
|
-
/** Add filter's pick at the container `rel` (inside `relation`'s where, its far fields): the new rule's target
|
|
48
|
-
* ({ rel: null } when held), or null when refused. */
|
|
49
|
-
export declare function addPicked(ctx: Ctx, rel: FilterPath, picked: FilterEditorField, far?: FilterEditorField, relation?: FilterEditorField): RuleTarget | null;
|
|
50
|
-
/** Whether Add filter at `rel` is full (fifty items), and whether it offers Related records: a relation's where stands a
|
|
51
|
-
* level deeper, so only where the tree stays three deep, and never inside a relation. */
|
|
52
|
-
export declare function addState(ctx: Ctx, rel: FilterPath, relation?: FilterEditorField): {
|
|
53
|
-
full: boolean;
|
|
54
|
-
relations: boolean;
|
|
55
|
-
gone: boolean;
|
|
56
|
-
};
|
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { addAt, itemsAt,
|
|
4
|
-
import { heldUntilWhole,
|
|
5
|
-
import { abs, fieldOfRule
|
|
6
|
-
const plain = (node) => !!node && !("items" in node) && !isRelationRule(node) && !isFilterGroup(node);
|
|
7
|
-
export function ruleAt(ctx, target) {
|
|
8
|
-
if (target.rel) {
|
|
9
|
-
const node = nodeAt(ctx.view, abs(ctx.base, target.rel));
|
|
10
|
-
if (!plain(node) || node.fieldKey !== target.fieldKey)
|
|
11
|
-
return null;
|
|
12
|
-
return { rule: node, at: { rel: target.rel, relation: relationOf(ctx, target.relation) } };
|
|
13
|
-
}
|
|
14
|
-
const held = ctx.pending?.node;
|
|
15
|
-
if (!held)
|
|
16
|
-
return null;
|
|
17
|
-
if (isRelationRule(held)) {
|
|
18
|
-
const first = held.where.items[0];
|
|
19
|
-
if (!plain(first) || first.fieldKey !== target.fieldKey)
|
|
20
|
-
return null;
|
|
21
|
-
return { rule: first, at: { rel: null, relation: relationOf(ctx, held.fieldKey), inPending: held } };
|
|
22
|
-
}
|
|
23
|
-
if (held.fieldKey !== target.fieldKey)
|
|
24
|
-
return null;
|
|
25
|
-
return { rule: held, at: { rel: null, relation: relationOf(ctx, target.relation) } };
|
|
26
|
-
}
|
|
27
|
-
export function relationRuleAt(ctx, rel, key) {
|
|
28
|
-
const node = rel ? nodeAt(ctx.view, abs(ctx.base, rel)) : ctx.pending?.node;
|
|
29
|
-
return node && isRelationRule(node) && node.fieldKey === key
|
|
30
|
-
? node
|
|
31
|
-
: null;
|
|
32
|
-
}
|
|
2
|
+
import { ruleIsActive } from "viewkitjs/fields/query";
|
|
3
|
+
import { addAt, itemsAt, replaceAt } from "../../../filters/filter-tree.js";
|
|
4
|
+
import { heldUntilWhole, newRuleFor, withField } from "../../settings/filter-groups.js";
|
|
5
|
+
import { abs, fieldOfRule } from "./editor-ctx.js";
|
|
33
6
|
export function writeRule(ctx, at, next) {
|
|
34
7
|
const { rel, inPending } = at;
|
|
35
8
|
if (rel)
|
|
@@ -86,67 +59,3 @@ export function pickField(ctx, at, rule, field, picked) {
|
|
|
86
59
|
}
|
|
87
60
|
writeRule(ctx, at, withField(rule, picked));
|
|
88
61
|
}
|
|
89
|
-
export function pickWay(ctx, at, rule, field, way) {
|
|
90
|
-
if (way !== rule.operator)
|
|
91
|
-
writeRule(ctx, at, withOperator(rule, field.type, way));
|
|
92
|
-
}
|
|
93
|
-
export function everyBlocked(relation, rule) {
|
|
94
|
-
const narrows = (node) => {
|
|
95
|
-
if (isFilterGroup(node))
|
|
96
|
-
return node.items.some(narrows);
|
|
97
|
-
if (isRelationRule(node))
|
|
98
|
-
return false;
|
|
99
|
-
const far = relation?.far?.find((field) => field.fieldKey === node.fieldKey);
|
|
100
|
-
return !!far && ruleIsActive(far.type, node);
|
|
101
|
-
};
|
|
102
|
-
return !rule.where.items.some(narrows);
|
|
103
|
-
}
|
|
104
|
-
export function pickQuantifier(ctx, rel, rule, quantifier) {
|
|
105
|
-
if (quantifier === rule.quantifier)
|
|
106
|
-
return;
|
|
107
|
-
if (rel)
|
|
108
|
-
ctx.change((tree, a) => replaceAt(tree, abs(a, rel), { ...rule, quantifier }));
|
|
109
|
-
else if (ctx.pending)
|
|
110
|
-
ctx.setPending({ ...ctx.pending, node: { ...rule, quantifier } });
|
|
111
|
-
}
|
|
112
|
-
export function addPicked(ctx, rel, picked, far, relation) {
|
|
113
|
-
const count = itemsAt(ctx.view, abs(ctx.base, rel))?.length ?? 0;
|
|
114
|
-
if (far) {
|
|
115
|
-
if (heldUntilWhole(far)) {
|
|
116
|
-
ctx.setPending({ container: rel, node: newRelationRuleFor(picked, far) });
|
|
117
|
-
return { rel: null, fieldKey: far.fieldKey, relation: picked.fieldKey };
|
|
118
|
-
}
|
|
119
|
-
const block = ctx.change((tree, a) => addAt(tree, abs(a, rel), newRelationRuleFor(picked, far)), {
|
|
120
|
-
structural: true,
|
|
121
|
-
});
|
|
122
|
-
return block ? { rel: [...rel, count, 0], fieldKey: far.fieldKey, relation: picked.fieldKey } : null;
|
|
123
|
-
}
|
|
124
|
-
const own = relation?.fieldKey;
|
|
125
|
-
if (heldUntilWhole(picked)) {
|
|
126
|
-
ctx.setPending({ container: rel, node: newRuleFor(picked) });
|
|
127
|
-
return { rel: null, fieldKey: picked.fieldKey, ...(own ? { relation: own } : {}) };
|
|
128
|
-
}
|
|
129
|
-
const added = ctx.change((tree, a) => addAt(tree, abs(a, rel), newRuleFor(picked)), {
|
|
130
|
-
structural: true,
|
|
131
|
-
});
|
|
132
|
-
return added ? { rel: [...rel, count], fieldKey: picked.fieldKey, ...(own ? { relation: own } : {}) } : null;
|
|
133
|
-
}
|
|
134
|
-
export function addState(ctx, rel, relation) {
|
|
135
|
-
const at = abs(ctx.base, rel);
|
|
136
|
-
const items = itemsAt(ctx.view, at) ?? [];
|
|
137
|
-
const probe = ctx.filterTree.fields.find((field) => field.far && field.far.length > 0);
|
|
138
|
-
const gone = underGoneRelation(ctx, at);
|
|
139
|
-
return {
|
|
140
|
-
full: items.length >= 50,
|
|
141
|
-
relations: !gone && !relation && !!probe && addAt(ctx.view, at, newRelationRuleFor(probe, probe.far[0])) !== null,
|
|
142
|
-
gone,
|
|
143
|
-
};
|
|
144
|
-
}
|
|
145
|
-
function underGoneRelation(ctx, at) {
|
|
146
|
-
for (let depth = at.length; depth > 0; depth--) {
|
|
147
|
-
const node = nodeAt(ctx.view, at.slice(0, depth));
|
|
148
|
-
if (node && isRelationRule(node))
|
|
149
|
-
return !relationOf(ctx, node.fieldKey);
|
|
150
|
-
}
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { SortConfig } from "../model.js";
|
|
2
2
|
/** Sort's own page: every option, the current one ticked with its direction. A search once there are more
|
|
3
3
|
* than eight, as Group by has, in a filter search's inset (`data-vs-inset`, `FIELD_PADDING`), so a host's
|
|
4
4
|
* overlay that insets its rows insets it with them. */
|
|
5
5
|
export declare function CompactSortDetail<V extends string>({ sort }: {
|
|
6
6
|
sort: SortConfig<V>;
|
|
7
7
|
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
-
/**
|
|
9
|
-
* THE GROUP PANEL: Group by, Sort and Date by are rows that open pages of their own; Hide empty groups is a
|
|
10
|
-
* switch; the Groups section lists every group to show, hide and drag; Remove grouping ungroups. A host that
|
|
11
|
-
* hands no `hideEmpty` or `groups` gets no such section.
|
|
12
|
-
*/
|
|
13
|
-
export declare function CompactGroupDetail<D extends string>({ group, onOpenPanel, }: {
|
|
14
|
-
group: GroupConfig<D>;
|
|
15
|
-
onOpenPanel: (panel: ActivePanel) => void;
|
|
16
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
17
|
-
/** Group by's own page: None and every dimension, the current one checked. A search once there are more than
|
|
18
|
-
* eight. A pick goes back to Group. */
|
|
19
|
-
export declare function CompactGroupByDetail<D extends string>({ group, onBack, }: {
|
|
20
|
-
group: GroupConfig<D>;
|
|
21
|
-
onBack: () => void;
|
|
22
|
-
}): import("react/jsx-runtime").JSX.Element;
|
|
23
|
-
/** Sort's own page in Group: the dimension's orders both ways, then Manual. */
|
|
24
|
-
export declare function CompactGroupSortDetail<D extends string>({ group, onBack, }: {
|
|
25
|
-
group: GroupConfig<D>;
|
|
26
|
-
onBack: () => void;
|
|
27
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
28
|
-
/** Date by's own page: a date dimension's granularities. */
|
|
29
|
-
export declare function CompactGroupDateByDetail<D extends string>({ group, onBack, }: {
|
|
30
|
-
group: GroupConfig<D>;
|
|
31
|
-
onBack: () => void;
|
|
32
|
-
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,16 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../provider/context.js";
|
|
6
|
-
import {
|
|
7
|
-
import { GROUP_BY_SEARCH_AFTER, activeGroupDimension, groupDateByLabel, groupSortLabel, groupValueLabel, matchGroupDimensions, matchSortOptions, } from "../labels.js";
|
|
6
|
+
import { GROUP_BY_SEARCH_AFTER, matchSortOptions } from "../labels.js";
|
|
8
7
|
import { FIELD_PADDING } from "../filter/TextFilterBody.js";
|
|
9
|
-
import {
|
|
10
|
-
import { drawPanelButton } from "../panel-button.js";
|
|
11
|
-
import { PANEL_LIST_CLASS, PANEL_SEPARATOR_CLASS } from "./chrome.js";
|
|
12
|
-
import { GroupBucketsList } from "./GroupBucketsList.js";
|
|
13
|
-
const GLYPH = "h-3.5 w-3.5";
|
|
8
|
+
import { PANEL_LIST_CLASS } from "./chrome.js";
|
|
14
9
|
export function CompactSortDetail({ sort }) {
|
|
15
10
|
const { atoms, messages } = useViews();
|
|
16
11
|
const { RadioRow, DirectionButton, PanelSearch } = atoms;
|
|
@@ -26,64 +21,3 @@ export function CompactSortDetail({ sort }) {
|
|
|
26
21
|
return (_jsx(RadioRow, { mark: "box", selected: selected, label: opt.label, onClick: () => pickValue(opt.value), trailing: selected ? _jsx(DirectionButton, { dir: sort.dir, onClick: flipDir }) : null }, opt.value));
|
|
27
22
|
})] }));
|
|
28
23
|
}
|
|
29
|
-
export function CompactGroupDetail({ group, onOpenPanel, }) {
|
|
30
|
-
const views = useViews();
|
|
31
|
-
const { atoms, icons, messages } = views;
|
|
32
|
-
const { MenuRow, ToggleRow, ChoiceRow } = atoms;
|
|
33
|
-
const activeDim = activeGroupDimension(group);
|
|
34
|
-
const anyShown = group.groups?.entries.some((entry) => !entry.hidden && !entry.empty) ?? false;
|
|
35
|
-
const anyHidden = group.groups?.entries.some((entry) => entry.hidden) ?? false;
|
|
36
|
-
const { group: GroupGlyph, sortRowsDown: SortGlyph, calendar: CalendarGlyph, hide: HideGlyph, delete: TrashGlyph } = icons;
|
|
37
|
-
return (_jsxs("div", { "data-vs-detail": true, className: cx("max-h-96", PANEL_LIST_CLASS), children: [_jsx(MenuRow, { icon: _jsx(GroupGlyph, { className: GLYPH }), label: messages({ key: "views.panels.group-by" }), value: groupValueLabel(group, messages), active: false, onClick: () => onOpenPanel({ type: "groupBy" }) }), activeDim && (_jsx(MenuRow, { icon: _jsx(SortGlyph, { className: GLYPH }), label: messages({ key: "views.panels.sort" }), value: groupSortLabel(group, messages), active: false, onClick: () => onOpenPanel({ type: "groupSort" }) })), activeDim?.granularities && activeDim.granularities.length > 0 && (_jsx(MenuRow, { icon: _jsx(CalendarGlyph, { className: GLYPH }), label: messages({ key: "views.panels.date-by" }), value: groupDateByLabel(group), active: false, onClick: () => onOpenPanel({ type: "groupDateBy" }) })), activeDim && group.hideEmpty && (_jsx(ToggleRow, { icon: _jsx(HideGlyph, { className: GLYPH }), label: messages({ key: "views.panels.hide-empty-groups" }), active: group.hideEmpty.value, onClick: () => group.hideEmpty.onChange(!group.hideEmpty.value) })), activeDim && group.groups && (_jsxs(_Fragment, { children: [_jsx("div", { className: PANEL_SEPARATOR_CLASS }), _jsxs("div", { "data-vs-heading": true, className: "flex items-center justify-between px-3 pt-1.5 pb-1", children: [_jsx("span", { className: "text-(length:--vk-caption-text,10px) font-bold uppercase tracking-(--vk-caps-tracking,0.15em) text-(color:--vk-fg-subtlest)", children: messages({ key: "views.panels.groups" }) }), (anyShown || anyHidden) && (drawPanelButton(views, {
|
|
38
|
-
own: "text-xs text-(color:--vk-fg-brand) hover:underline focus-visible:underline",
|
|
39
|
-
frame: "h-auto p-0",
|
|
40
|
-
variant: "ghost",
|
|
41
|
-
size: "sm",
|
|
42
|
-
onClick: anyShown ? group.groups.onHideAll : group.groups.onShowAll,
|
|
43
|
-
children: messages({ key: anyShown ? "views.panels.groups-hide-all" : "views.panels.groups-show-all" }),
|
|
44
|
-
}))] }), _jsx(GroupBucketsList, { groups: group.groups, variant: "compact" })] })), activeDim && (_jsxs(_Fragment, { children: [_jsx("div", { className: PANEL_SEPARATOR_CLASS }), _jsx(ChoiceRow, { "data-vs-row": true, label: messages({ key: "views.panels.group-remove" }), leading: _jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-(color:--vk-fg-subtle)", children: _jsx(TrashGlyph, { className: GLYPH }) }), onClick: () => group.onChange({ value: "none", order: group.order, granularity: group.granularity }) })] }))] }));
|
|
45
|
-
}
|
|
46
|
-
export function CompactGroupByDetail({ group, onBack, }) {
|
|
47
|
-
const { atoms, messages } = useViews();
|
|
48
|
-
const { RadioRow, PanelSearch } = atoms;
|
|
49
|
-
const [query, setQuery] = useState("");
|
|
50
|
-
const searchable = group.dimensions.length > GROUP_BY_SEARCH_AFTER;
|
|
51
|
-
const needle = query.trim();
|
|
52
|
-
const dimensions = matchGroupDimensions(group.dimensions, query);
|
|
53
|
-
const pick = (next) => {
|
|
54
|
-
group.onChange({ value: next, order: group.order, granularity: group.granularity });
|
|
55
|
-
onBack();
|
|
56
|
-
};
|
|
57
|
-
return (_jsxs("div", { "data-vs-detail": true, className: cx("max-h-96", PANEL_LIST_CLASS), children: [searchable && (_jsx("div", { "data-vs-inset": true, className: FIELD_PADDING, children: _jsx(PanelSearch, { value: query, onChange: setQuery, placeholder: messages({ key: "views.panels.search" }), autoFocus: true }) })), !needle && (_jsx(RadioRow, { selected: group.value === "none", label: messages({ key: "views.panels.group-none" }), onClick: () => pick("none") })), dimensions.map((dimension) => (_jsx(RadioRow, { selected: group.value === dimension.value, label: dimension.label, onClick: () => pick(dimension.value) }, dimension.value)))] }));
|
|
58
|
-
}
|
|
59
|
-
export function CompactGroupSortDetail({ group, onBack, }) {
|
|
60
|
-
const { atoms, messages } = useViews();
|
|
61
|
-
const { RadioRow } = atoms;
|
|
62
|
-
const activeDim = activeGroupDimension(group);
|
|
63
|
-
if (!activeDim)
|
|
64
|
-
return null;
|
|
65
|
-
const current = groupSortValue(group.order[activeDim.value] ?? groupOrderFor(activeDim));
|
|
66
|
-
return (_jsx("div", { "data-vs-detail": true, className: cx("max-h-96", PANEL_LIST_CLASS), children: groupSortChoices(activeDim, { manual: offersManualOrder(group) }, messages).map((choice) => (_jsx(RadioRow, { selected: choice.value === current, label: choice.label, onClick: () => {
|
|
67
|
-
group.onChange({
|
|
68
|
-
value: activeDim.value,
|
|
69
|
-
order: { ...group.order, [activeDim.value]: choice.order },
|
|
70
|
-
granularity: group.granularity,
|
|
71
|
-
});
|
|
72
|
-
onBack();
|
|
73
|
-
} }, choice.value))) }));
|
|
74
|
-
}
|
|
75
|
-
export function CompactGroupDateByDetail({ group, onBack, }) {
|
|
76
|
-
const { RadioRow } = useViews().atoms;
|
|
77
|
-
const activeDim = activeGroupDimension(group);
|
|
78
|
-
if (!activeDim?.granularities?.length)
|
|
79
|
-
return null;
|
|
80
|
-
const current = group.granularity?.[activeDim.value] ?? activeDim.defaultGranularity ?? activeDim.granularities[0].value;
|
|
81
|
-
return (_jsx("div", { "data-vs-detail": true, className: cx("max-h-96", PANEL_LIST_CLASS), children: activeDim.granularities.map((choice) => (_jsx(RadioRow, { selected: choice.value === current, label: choice.label, onClick: () => {
|
|
82
|
-
group.onChange({
|
|
83
|
-
value: activeDim.value,
|
|
84
|
-
order: group.order,
|
|
85
|
-
granularity: { ...group.granularity, [activeDim.value]: choice.value },
|
|
86
|
-
});
|
|
87
|
-
onBack();
|
|
88
|
-
} }, choice.value))) }));
|
|
89
|
-
}
|
|
@@ -5,7 +5,6 @@ import { useViews } from "../../provider/context.js";
|
|
|
5
5
|
import { drawPanelButton } from "../panel-button.js";
|
|
6
6
|
function HeaderIconButton({ icon, label, onClick, edge, }) {
|
|
7
7
|
return drawPanelButton(useViews(), {
|
|
8
|
-
own: cx("-my-1 p-1 inline-flex shrink-0 items-center justify-center rounded-md", "text-(color:--vk-fg-subtle) transition-colors hover:bg-(color:--vk-hovered) hover:text-(color:--vk-fg)", edge === "left" ? "-ml-1" : "-mr-1"),
|
|
9
8
|
frame: cx("-my-1 h-6 w-6 shrink-0", edge === "left" ? "-ml-1" : "-mr-1"),
|
|
10
9
|
variant: "ghost",
|
|
11
10
|
size: "icon",
|