viewkitjs 0.34.0 → 0.36.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 +173 -0
- package/MIGRATION.md +7 -0
- package/package.json +1 -1
- package/views/README.md +1 -1
- package/views/dist/atoms/Avatar.js +2 -1
- package/views/dist/atoms/RelationChip.d.ts +2 -0
- package/views/dist/atoms/RelationChip.js +5 -0
- package/views/dist/atoms/RowMenu.d.ts +1 -1
- package/views/dist/atoms/RowMenu.js +15 -3
- package/views/dist/atoms/defaults.js +2 -0
- package/views/dist/atoms/types.d.ts +40 -4
- package/views/dist/cells/relation-wrap.js +9 -2
- package/views/dist/contract.d.ts +27 -7
- package/views/dist/contract.js +25 -2
- package/views/dist/controls/avatar/avatar-mark.d.ts +4 -0
- package/views/dist/controls/avatar/avatar-mark.js +5 -0
- package/views/dist/controls/avatar/avatar.d.ts +10 -5
- package/views/dist/controls/avatar/avatar.js +12 -6
- package/views/dist/controls/avatar/looks.d.ts +1 -1
- package/views/dist/controls/avatar/looks.js +3 -0
- package/views/dist/controls/avatar/record-mark.d.ts +16 -0
- package/views/dist/controls/avatar/record-mark.js +13 -0
- package/views/dist/controls/avatar/tokens.d.ts +12 -0
- package/views/dist/controls/avatar/tokens.js +3 -0
- package/views/dist/controls/avatar.css +54 -17
- package/views/dist/controls/bulk-bar/bulk-bar.js +4 -5
- package/views/dist/controls/bulk-bar/map-selection-bar.js +2 -1
- package/views/dist/controls/compound-editor/compound-editor.d.ts +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.d.ts +1 -1
- package/views/dist/controls/compound-editor/map-parts-body.js +8 -1
- package/views/dist/controls/compound-editor/name-parts.js +3 -2
- package/views/dist/controls/compound-editor/place-parts.js +3 -3
- package/views/dist/controls/compound-editor/range-parts.js +11 -10
- package/views/dist/controls/compound-editor/words.d.ts +3 -0
- package/views/dist/controls/compound-editor/words.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +22 -6
- package/views/dist/controls/customize/customize.js +154 -73
- package/views/dist/controls/customize/items.d.ts +49 -0
- package/views/dist/controls/customize/items.js +104 -0
- package/views/dist/controls/customize/map-customize-body.js +19 -15
- package/views/dist/controls/customize/words.d.ts +5 -3
- package/views/dist/controls/customize/words.js +1 -0
- package/views/dist/controls/filter-editor/block.js +5 -2
- package/views/dist/controls/filter-editor/filter-editor.d.ts +16 -1
- package/views/dist/controls/filter-editor/filter-editor.js +22 -16
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
- package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
- package/views/dist/controls/filter-editor/map-rules.js +18 -13
- package/views/dist/controls/filter-editor/parts.d.ts +1 -1
- package/views/dist/controls/filter-editor/parts.js +16 -15
- package/views/dist/controls/filter-editor/rules.d.ts +4 -4
- package/views/dist/controls/filter-editor/rules.js +6 -3
- package/views/dist/controls/filter-editor/words.d.ts +2 -0
- package/views/dist/controls/filter-editor/words.js +1 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
- package/views/dist/controls/group-editor/group-editor.js +21 -15
- package/views/dist/controls/group-editor/map-group-body.js +1 -0
- package/views/dist/controls/index.d.ts +1 -1
- package/views/dist/controls/internal/kit-words.d.ts +11 -0
- package/views/dist/controls/internal/kit-words.js +7 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
- package/views/dist/controls/internal/map-panel-controls.js +23 -6
- package/views/dist/controls/internal/menu-items.d.ts +9 -0
- package/views/dist/controls/internal/menu-items.js +97 -0
- package/views/dist/controls/internal/panel-controls.d.ts +27 -3
- package/views/dist/controls/internal/panel-controls.js +142 -13
- package/views/dist/controls/links-editor/links-editor.js +5 -7
- package/views/dist/controls/links-editor/map-links-body.d.ts +1 -1
- package/views/dist/controls/links-editor/map-links-body.js +5 -1
- package/views/dist/controls/menu/menu.d.ts +4 -1
- package/views/dist/controls/menu/menu.js +3 -2
- package/views/dist/controls/number-editor/map-number-body.js +2 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/number-editor/words.d.ts +3 -0
- package/views/dist/controls/number-editor/words.js +2 -0
- package/views/dist/controls/picker/fields-frame.d.ts +5 -0
- package/views/dist/controls/picker/fields-frame.js +30 -0
- package/views/dist/controls/picker/map-fields-body.d.ts +2 -2
- package/views/dist/controls/picker/map-fields-body.js +7 -26
- package/views/dist/controls/picker/map-picker.d.ts +9 -3
- package/views/dist/controls/picker/map-picker.js +16 -3
- package/views/dist/controls/picker/picker.js +20 -10
- package/views/dist/controls/picker/rows.d.ts +9 -2
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +2 -1
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/quick-filters/reminder.js +2 -2
- package/views/dist/controls/quick-filters/rules.d.ts +4 -1
- package/views/dist/controls/quick-filters/words.d.ts +2 -0
- package/views/dist/controls/quick-filters/words.js +1 -0
- package/views/dist/controls/select/map-select.d.ts +1 -1
- package/views/dist/controls/select/map-select.js +4 -1
- package/views/dist/controls/select/select.d.ts +5 -0
- package/views/dist/controls/select/select.js +11 -3
- package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
- package/views/dist/controls/sheet/bottom-sheet.js +3 -3
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +9 -8
- package/views/dist/controls/tag/tag.js +4 -2
- package/views/dist/controls/text-editor/map-text-body.js +4 -1
- package/views/dist/controls/text-editor/text-editor.js +2 -2
- package/views/dist/controls/text-editor/words.d.ts +3 -0
- package/views/dist/controls/text-editor/words.js +1 -1
- package/views/dist/controls/toolbar/toolbar.d.ts +31 -12
- package/views/dist/controls/toolbar/toolbar.js +15 -20
- package/views/dist/controls/toolbar.css +0 -5
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +4 -2
- package/views/dist/controls/values-editor/map-values-body.d.ts +1 -2
- package/views/dist/controls/values-editor/map-values-body.js +5 -1
- package/views/dist/controls/values-editor/values-editor.js +8 -7
- package/views/dist/controls/views-list/map-views-list-body.js +9 -1
- package/views/dist/controls/views-list/rules.d.ts +1 -0
- package/views/dist/controls/views-list/rules.js +2 -2
- package/views/dist/controls/views-list/view-menu.js +2 -2
- package/views/dist/controls/views-list/words.d.ts +4 -0
- package/views/dist/controls/views-list/words.js +2 -1
- package/views/dist/display/option-badges.d.ts +17 -0
- package/views/dist/display/option-badges.js +11 -0
- package/views/dist/display/relation-link.d.ts +12 -0
- package/views/dist/display/relation-link.js +17 -0
- package/views/dist/display/relation.d.ts +1 -1
- package/views/dist/display/relation.js +10 -3
- package/views/dist/display/select.js +1 -8
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/editors/RangeEditor.d.ts +3 -0
- package/views/dist/editors/RangeEditor.js +2 -2
- package/views/dist/editors/SelectEditor.d.ts +2 -2
- package/views/dist/editors/SelectEditor.js +1 -1
- package/views/dist/editors/TextEditor.js +4 -2
- package/views/dist/editors/ValueListEditor.js +2 -1
- package/views/dist/field-row/FieldRow.js +32 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
- package/views/dist/grid/chrome/GridAddColumn.js +13 -9
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -1
- package/views/dist/grid/chrome/GridCellOutline.js +16 -6
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +7 -4
- package/views/dist/grid/chrome/GridFooter.d.ts +4 -1
- package/views/dist/grid/chrome/GridFooter.js +4 -4
- package/views/dist/grid/chrome/GridGroupMenu.js +39 -14
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -1
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridNumberEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +4 -1
- package/views/dist/grid/chrome/GridRangeEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +11 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +4 -1
- package/views/dist/grid/chrome/GridRowActions.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +3 -2
- package/views/dist/grid/chrome/GridStructure.js +1 -1
- package/views/dist/grid/chrome/GridTable.js +32 -20
- package/views/dist/grid/chrome/GridTableSurface.js +2 -1
- package/views/dist/grid/chrome/checks.d.ts +1 -1
- package/views/dist/grid/chrome/checks.js +4 -1
- package/views/dist/grid/chrome/grid-cell-classes.d.ts +6 -2
- package/views/dist/grid/chrome/grid-cell-classes.js +10 -5
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +5 -2
- package/views/dist/grid/chrome/grid-fitted-box.js +14 -4
- package/views/dist/grid/chrome/grid-hover.d.ts +10 -2
- package/views/dist/grid/chrome/grid-hover.js +14 -4
- package/views/dist/grid/chrome/grid-row-props.d.ts +4 -0
- package/views/dist/grid/chrome/grid-rows-menu.js +9 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +16 -4
- package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
- package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
- package/views/dist/grid/grid-format-props.d.ts +1 -1
- package/views/dist/grid/grid-format-props.js +18 -5
- package/views/dist/grid/grid.css +11 -1
- package/views/dist/grid/looks.d.ts +3 -1
- package/views/dist/grid/looks.js +10 -4
- package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/views/dist/grid/useGridTableSettings.d.ts +1 -1
- package/views/dist/list/layer.d.ts +8 -0
- package/views/dist/list/layer.js +7 -0
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/menu.d.ts +5 -4
- package/views/dist/list/store.d.ts +1 -1
- package/views/dist/list/toolbar.js +47 -20
- package/views/dist/list/views.js +1 -0
- package/views/dist/panels/availability.d.ts +5 -0
- package/views/dist/panels/availability.js +4 -5
- package/views/dist/panels/customize-body.d.ts +5 -1
- package/views/dist/panels/customize-body.js +21 -12
- package/views/dist/panels/model.d.ts +14 -4
- package/views/dist/panels/react/customize-body.js +15 -3
- package/views/dist/panels/react/customize.d.ts +8 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +6 -0
- package/views/dist/panels/react/filter/FilterEditor.js +7 -0
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
- package/views/dist/panels/react/filter/filter-body.js +3 -1
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-part-body.js +2 -2
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +3 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
- package/views/dist/panels/react/sort/SortEditor.js +3 -1
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +11 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +16 -6
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +12 -5
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +18 -8
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +9 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +5 -4
- package/views/dist/panels/react/toolbar/ToolbarSort.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +6 -3
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +3 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +4 -4
- package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
- package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +3 -5
- package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
- package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +8 -3
- package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
- package/views/dist/panels/react/views-row/new-view.js +21 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/layout.js +6 -38
- package/views/dist/panels/toolbar/page-resets.d.ts +17 -0
- package/views/dist/panels/toolbar/page-resets.js +62 -0
- package/views/dist/panels/toolbar/same-item.d.ts +7 -0
- package/views/dist/panels/toolbar/same-item.js +9 -0
- package/views/dist/panels/view-state.d.ts +4 -0
- package/views/dist/provider/ViewsProvider.d.ts +9 -4
- package/views/dist/provider/ViewsProvider.js +13 -2
- package/views/dist/provider/components.d.ts +109 -7
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/styles.css +115 -27
- package/views/dist/styles.unlayered.css +115 -27
- package/views/docs/contract.md +55 -35
- package/views/docs/controls/avatar.md +3 -0
- package/views/docs/controls/bulk-bar.md +3 -1
- package/views/docs/controls/compound-editor.md +2 -0
- package/views/docs/controls/customize.md +1 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/links-editor.md +2 -0
- package/views/docs/controls/pane.md +1 -1
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/quick-filters.md +1 -1
- package/views/docs/controls/text-editor.md +1 -1
- package/views/docs/controls/values-editor.md +2 -0
- package/views/docs/guides/atoms.md +54 -3
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/index.md +2 -2
- package/views/docs/install.md +198 -104
- package/views/docs/reference/controls.md +27 -24
- package/views/docs/reference/editors-range.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +6 -5
- package/views/docs/reference/list.md +27 -7
- package/views/docs/reference/looks.md +5 -5
- package/views/docs/reference/panels-react.md +15 -14
- package/views/docs/reference/panels.md +5 -5
- package/views/docs/reference/react.md +25 -11
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +22 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -62,6 +62,7 @@ export function customizeWordsOf(say) {
|
|
|
62
62
|
newLineOn: (label) => say({ key: "views.panels.new-line-on", values: { label } }),
|
|
63
63
|
newLineStart: (label) => say({ key: "views.panels.new-line-start", values: { label } }),
|
|
64
64
|
nothingToPick: say({ key: "views.panels.filter-no-options" }),
|
|
65
|
+
unavailable: say({ key: "views.panels.customize-unavailable" }),
|
|
65
66
|
rows: {
|
|
66
67
|
move: (label) => say({ key: "views.panels.sort-move", values: { label } }),
|
|
67
68
|
howKeys: say({ key: "views.panels.list-move-keys" }),
|
|
@@ -98,14 +99,12 @@ export function customizeWriteOf(p, own, now, next) {
|
|
|
98
99
|
return null;
|
|
99
100
|
return () => viewKit.onColumnsChange(next.columns.map((c) => ({ id: c.id, hidden: !c.shown })));
|
|
100
101
|
}
|
|
101
|
-
const toggleOf = (t) => ({ key: t.key, label: t.label, value: t.value, onChange: t.onChange, ...(t.icon != null && { icon: t.icon }), ...(t.
|
|
102
|
+
const toggleOf = (t) => ({ key: t.key, label: t.label, value: t.value, onChange: t.onChange, ...(t.icon != null && { icon: t.icon }), ...(t.section && { section: t.section }) });
|
|
102
103
|
const choiceOf = (c) => ({ key: c.key, label: c.label, value: c.value, options: [...c.options], onChange: c.onChange });
|
|
103
104
|
function layoutSettingsOf(layout) {
|
|
104
105
|
return {
|
|
105
106
|
choices: [...(layout.density ? [choiceOf(layout.density)] : []), ...layout.choices.map(choiceOf)],
|
|
106
107
|
toggles: layout.toggles.map(toggleOf),
|
|
107
|
-
...(layout.personal && { personal: { label: layout.personal.label, toggles: layout.personal.toggles.map(toggleOf), choices: layout.personal.choices.map(choiceOf),
|
|
108
|
-
...(layout.personal.onReset && { onReset: layout.personal.onReset }) } }),
|
|
109
108
|
};
|
|
110
109
|
}
|
|
111
110
|
const NO_SORT = { label: "", options: [], rules: [], setAside: [], max: 1, addSort: true, onRulesChange() { } };
|
|
@@ -127,26 +126,29 @@ function CustomizeBodyInner(props) {
|
|
|
127
126
|
const groupWords = React.useMemo(() => groupEditorWordsOf(say), [say]);
|
|
128
127
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
129
128
|
const editorForm = phone ? "phone" : "narrow";
|
|
129
|
+
const marked = (page) => (p.resets ? !!p.resets[page] : undefined);
|
|
130
130
|
const sortProps = sortEditorPropsOf({ ...(p.sort ?? NO_SORT), form: p.form, onDone: stay }, sortWords, say);
|
|
131
|
-
const
|
|
131
|
+
const clearAll = !p.resets;
|
|
132
|
+
const sorting = useSortEditor({ ...sortProps, form: editorForm, onDone: undefined, clearAll });
|
|
132
133
|
const sortSaid = sortLabel(sortProps.rules, sortProps.fields);
|
|
133
|
-
const sort = p.sort && { says: sortSaid ? `${sortSaid.first}${sortSaid.more ? ` +${sortSaid.more}` : ""}` : w.none, inForce: !!sortSaid,
|
|
134
|
+
const sort = p.sort && { says: sortSaid ? `${sortSaid.first}${sortSaid.more ? ` +${sortSaid.more}` : ""}` : w.none, inForce: marked("sort") ?? !!sortSaid,
|
|
134
135
|
opens: sorting.body, level: levelOf(sorting) };
|
|
135
136
|
const filterHanded = { ...(p.filter ?? NO_FILTER), form: p.form, onDone: stay };
|
|
136
137
|
const map = useMapFilterBody(filterHanded, filterWords, say, views?.components.AppIcon, wayWord);
|
|
137
|
-
const filtering = useFilterEditor({ label: filterHanded.label, fields: map.kit.fields, filter: map.filter, levels: filterHanded.levels, form: editorForm, onFilterChange: map.change,
|
|
138
|
-
own: map.own, words: filterWords });
|
|
138
|
+
const filtering = useFilterEditor({ ...(map.items && { items: map.items }), label: filterHanded.label, fields: map.kit.fields, filter: map.filter, levels: filterHanded.levels, form: editorForm, onFilterChange: map.change,
|
|
139
|
+
own: map.own, words: filterWords, clearAll });
|
|
139
140
|
const ruleCount = rulesOf(map.filter).length;
|
|
140
|
-
const filter = p.filter && { says: ruleCount > 0 ? String(ruleCount) : w.none, inForce: ruleCount > 0, opens: filtering.body, level: levelOf(filtering) };
|
|
141
|
+
const filter = p.filter && { says: ruleCount > 0 ? String(ruleCount) : w.none, inForce: marked("filter") ?? ruleCount > 0, opens: filtering.body, level: levelOf(filtering) };
|
|
141
142
|
const groupProps = groupEditorPropsOf({ ...(p.group ?? NO_GROUP), form: p.form, onDone: stay }, groupWords);
|
|
142
143
|
const grouping = useGroupEditor(groupProps);
|
|
143
|
-
const group = p.group && { says: groupLabel(groupProps.group, groupProps.fields, w.none), inForce: p.group.group.value !== "none",
|
|
144
|
+
const group = p.group && { says: groupLabel(groupProps.group, groupProps.fields, w.none), inForce: marked("group") ?? p.group.group.value !== "none",
|
|
144
145
|
opens: grouping.body, level: grouping.level };
|
|
145
146
|
const view = { name: onRename ? name ?? "" : "", layout: p.layout?.value ?? "", columns: columnsOf(p, say), counts: false, freeze: false, wrap: false };
|
|
146
147
|
const shared = p.view, kit = p.foot === "kit";
|
|
147
|
-
const foot = shared ? (shared.changes > 0 && p.foot !== "none" ? {
|
|
148
|
-
changed: true, onReset: shared.onReset, ...(shared.canPublish && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
|
|
149
|
-
words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : shared.own ? "views.panels.view-save-own" : "views.panels.view-publish" })
|
|
148
|
+
const foot = shared ? ((shared.changes > 0 || shared.layered) && p.foot !== "none" ? {
|
|
149
|
+
changed: true, onReset: shared.onReset, ...(shared.canPublish && shared.changes > 0 && { onSave: shared.onPublish }), pending: shared.pending, stale: shared.stale,
|
|
150
|
+
words: { reset: say({ key: kit ? "views.panels.view-clear" : "views.panels.view-reset" }), save: say({ key: kit ? "views.panels.view-save" : shared.own ? "views.panels.view-save-own" : "views.panels.view-publish" }),
|
|
151
|
+
stale: say({ key: shared.own ? "views.panels.view-stale-own" : "views.panels.view-stale" }) },
|
|
150
152
|
} : {}) : p.onClear && p.foot !== "none" ? { changed: true, onReset: p.onClear, words: { reset: say({ key: "views.panels.view-clear" }) } } : {};
|
|
151
153
|
const { words: footWords, ...footProps } = foot;
|
|
152
154
|
const timeField = p.fields?.items.find((f) => f.time);
|
|
@@ -177,13 +179,15 @@ function CustomizeBodyInner(props) {
|
|
|
177
179
|
toggles: p.toggles.map(toggleOf),
|
|
178
180
|
...(p.layout && { layoutSettings: layoutSettingsOf(p.layout) }),
|
|
179
181
|
...(p.columns?.reset && { columnsReset: p.columns.reset }),
|
|
182
|
+
...(p.items && { items: p.items }),
|
|
183
|
+
...(p.resets && { resets: p.resets, differs: { layout: !!p.resets.layout, columns: !!p.resets.columns } }),
|
|
180
184
|
...(p.columns?.onStartsLineChange && { onLineChange: p.columns.onStartsLineChange }),
|
|
181
185
|
...(p.columns?.footer != null && { columnsFoot: p.columns.footer }),
|
|
182
186
|
...(fields.length > 0 && { fields, foldFields: p.fields.folded }),
|
|
183
187
|
...footProps,
|
|
184
188
|
...(exportCount !== undefined && { exportCount }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }),
|
|
185
189
|
onClose: p.onDone, onScreenChange: p.onPageChange, screen: p.page, form: p.form,
|
|
186
|
-
words: { ...w, ...(p.layout && { layout: p.layout.label }), ...(p.columns && { columns: p.columns.label }),
|
|
190
|
+
words: { ...w, reset: say({ key: shared && !kit ? "views.panels.view-reset" : "views.panels.view-clear" }), ...(p.layout && { layout: p.layout.label }), ...(p.columns && { columns: p.columns.label }),
|
|
187
191
|
...(p.layout && p.layout.value !== "table" && { shownHeading: say({ key: "views.panels.customize-shown-fields" }) }), ...footWords },
|
|
188
192
|
});
|
|
189
193
|
const told = parts.level;
|
|
@@ -194,7 +198,7 @@ function CustomizeBodyInner(props) {
|
|
|
194
198
|
React.useLayoutEffect(() => () => setParts?.(null), [setParts]);
|
|
195
199
|
if (!phone || setParts)
|
|
196
200
|
return _jsx(_Fragment, { children: parts.body });
|
|
197
|
-
const { onBack, close
|
|
201
|
+
const { onBack } = parts.head, close = parts.head.close && p.actions?.close;
|
|
198
202
|
return (_jsxs(_Fragment, { children: [_jsx(HeaderBar, { className: "o-sheet-row o-customize-own-head", title: parts.title, left: onBack ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": w.back, className: "o-sheet-back", icon: glyph(BACK), onClick: onBack })
|
|
199
|
-
: close ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick:
|
|
203
|
+
: close ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: close.onPress }) : _jsx("span", {}), right: close && onBack ? _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": w.close, icon: glyph(X), onClick: close.onPress }) : _jsx("span", {}) }), parts.body, parts.foot] }));
|
|
200
204
|
}
|
|
@@ -42,11 +42,11 @@ export interface CustomizeWords {
|
|
|
42
42
|
/** A table's two settings, as its own page draws them (the view's `freeze` and `wrap`). */
|
|
43
43
|
freeze: string;
|
|
44
44
|
wrap: string;
|
|
45
|
-
/**
|
|
45
|
+
/** @deprecated Drawn nowhere since the Layout page ends at its toggles (VK-1033). To be removed in a later release. */
|
|
46
46
|
personalReset: string;
|
|
47
|
-
/** Columns
|
|
47
|
+
/** @deprecated Drawn nowhere since Columns resets through its page's Reset (VK-1034). To be removed in a later release. */
|
|
48
48
|
columnsReset: string;
|
|
49
|
-
/**
|
|
49
|
+
/** @deprecated Drawn nowhere since a toggle carries no way back of its own (VK-1033). To be removed in a later release. */
|
|
50
50
|
toggleReset: (label: string) => string;
|
|
51
51
|
/** The shared view moved after the reader's changes began. */
|
|
52
52
|
stale: string;
|
|
@@ -57,6 +57,8 @@ export interface CustomizeWords {
|
|
|
57
57
|
newLineStart: (label: string) => string;
|
|
58
58
|
/** A per-field filter's screen with nothing to pick (VK-891). */
|
|
59
59
|
nothingToPick: string;
|
|
60
|
+
/** A disabled row's reason where the app hands none (VK-1062). */
|
|
61
|
+
unavailable: string;
|
|
60
62
|
/** The rows' own words (the Menu list's: a column's grip, how the columns move, a Switch's two words). */
|
|
61
63
|
rows?: Partial<MenuListWords>;
|
|
62
64
|
}
|
|
@@ -38,5 +38,6 @@ export const CUSTOMIZE_WORDS = {
|
|
|
38
38
|
newLineOn: (label) => `${label} starts a new line`,
|
|
39
39
|
newLineStart: (label) => `Start a new line at ${label}`,
|
|
40
40
|
nothingToPick: "Nothing to pick",
|
|
41
|
+
unavailable: "Not available",
|
|
41
42
|
};
|
|
42
43
|
export const customizeWords = (given) => (given ? { ...CUSTOMIZE_WORDS, ...given } : CUSTOMIZE_WORDS);
|
|
@@ -14,14 +14,17 @@ export function GroupMenu({ entries, words }) {
|
|
|
14
14
|
return _jsx(Menu, { label: words.groupActions, align: "end", entries: entries, trigger: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-filter-editor-more", "data-slot": "vk-filter-group-more", "aria-label": words.groupActions, icon: glyph(DOTS_UP) }) });
|
|
15
15
|
}
|
|
16
16
|
export function MenuStep({ label, entries, onClose, words }) {
|
|
17
|
-
const
|
|
17
|
+
const closing = (e) => {
|
|
18
18
|
if (e.kind === "pick")
|
|
19
19
|
return { ...e, onChoose: (v) => { e.onChoose?.(v); onClose(); } };
|
|
20
20
|
if (e.kind === "check")
|
|
21
21
|
return e.disabled ? { ...e, note: e.disabled } : e;
|
|
22
22
|
if (e.kind === undefined || e.kind === "action")
|
|
23
23
|
return { ...e, ...(e.disabled ? { note: e.disabled } : {}), onSelect: () => { e.onSelect?.(); onClose(); } };
|
|
24
|
+
if (e.kind === "group")
|
|
25
|
+
return { ...e, entries: e.entries.map(closing) };
|
|
24
26
|
return e;
|
|
25
|
-
}
|
|
27
|
+
};
|
|
28
|
+
const rows = entries.map(closing);
|
|
26
29
|
return _jsx("div", { className: "o-filter-editor-menu-step", ...MENU_LIST_CARD_FRAME, children: _jsx(MenuList, { label: label, entries: rows, ...(words ? { words } : {}) }) });
|
|
27
30
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
2
3
|
import type { SheetHeadProps } from "../sheet/bottom-sheet.js";
|
|
3
4
|
import { type FilterField } from "./how.js";
|
|
4
5
|
import { type FilterGroup, type FilterRule } from "./rules.js";
|
|
@@ -13,9 +14,24 @@ export interface FilterOwn {
|
|
|
13
14
|
value: string | null;
|
|
14
15
|
body: React.ReactNode | null;
|
|
15
16
|
}
|
|
17
|
+
/** The filter editor's own menus' context (VK-1063): a rule's or a group's, by the editor's own ids. Its map hands the app the
|
|
18
|
+
* ViewKit filter's public terms instead (`ViewsFilterEditorItemsContext`). */
|
|
19
|
+
export type FilterEditorItemsContext = ({
|
|
20
|
+
menu: "rule" | "aside";
|
|
21
|
+
rule: string;
|
|
22
|
+
} | {
|
|
23
|
+
menu: "group";
|
|
24
|
+
group: string;
|
|
25
|
+
}) & {
|
|
26
|
+
form: "computer" | "phone";
|
|
27
|
+
};
|
|
16
28
|
export interface FilterEditorProps {
|
|
29
|
+
/** Its menus as data (VK-1063): a rule's ⋮, a set-aside rule's and a group's actions, handed their default items. */
|
|
30
|
+
items?: (items: ViewsMenuItem[], ctx: FilterEditorItemsContext) => ViewsMenuItem[];
|
|
17
31
|
/** What it filters, as its shell names it ("Filter"): the Sheet's title on a phone, and the rules' name to a screen reader. */
|
|
18
32
|
label: string;
|
|
33
|
+
/** Clear all at its foot; default on. Off inside Customize, where its page's Reset stands in its place (VK-1034). */
|
|
34
|
+
clearAll?: boolean;
|
|
19
35
|
/** The fields a list filters by, each typed, a choice's values with it; one leading one level in (a deal's Company) holds its own. */
|
|
20
36
|
fields: FilterField[];
|
|
21
37
|
/** The view's filter: its rules, joined by its join, groups in it. */
|
|
@@ -52,7 +68,6 @@ export interface FilterEditorParts {
|
|
|
52
68
|
/** On a phone's step, its title: Add filter, Field, how a field compares, or the field's name; absent off a step. */
|
|
53
69
|
title?: string;
|
|
54
70
|
}
|
|
55
|
-
/** The filter editor's state and the parts a shell pours in. */
|
|
56
71
|
export declare function useFilterEditor(props: FilterEditorProps): FilterEditorParts;
|
|
57
72
|
/** @deprecated `useFilterEditor`, under the name the controls door gave it until the panels' older filter editor took a host's name. */
|
|
58
73
|
export declare const useFilterEditorParts: typeof useFilterEditor;
|
|
@@ -7,14 +7,14 @@ import { asSelect, DOTS, DOTS_LOOK, DOTS_UP, glyph, MORE_LOOK, PLUS, TRASH, useD
|
|
|
7
7
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
8
8
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
9
9
|
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
10
|
-
import {
|
|
10
|
+
import { shapeMenu } from "../internal/menu-items.js";
|
|
11
11
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
12
|
+
import { FieldsFrame } from "../picker/fields-frame.js";
|
|
12
13
|
import { itemLabel } from "../picker/rows.js";
|
|
13
|
-
import { Tooltip } from "../tooltip/tooltip.js";
|
|
14
14
|
import { HOW, wayOf } from "./how.js";
|
|
15
15
|
import { PairValue } from "./parts.js";
|
|
16
16
|
import { BlockHead, GroupMenu, MenuStep } from "./block.js";
|
|
17
|
-
import { addRule, blockAround, canExclude, setExclude, canGroup, changeRule, clearAll, everyFits, fieldOf, fieldsIn, isBlock, isGroup, isOwnWay, isPair, isWhole, itemOf, putBack, QUANTIFIERS, relationOf, removeRule, rulesOf, setJoin, setQuantifier, toBlock, toGroup } from "./rules.js";
|
|
17
|
+
import { addRule, blockAround, canExclude, setExclude, canGroup, changeRule, clearAll, everyFits, fieldOf, fieldsIn, FILTER_DEPTH, isBlock, isGroup, isOwnWay, isPair, isWhole, itemOf, putBack, QUANTIFIERS, relationOf, removeRule, rulesOf, setJoin, setQuantifier, toBlock, toGroup } from "./rules.js";
|
|
18
18
|
import { filterWords } from "./words.js";
|
|
19
19
|
const GROUP = ["M4 7a3 3 0 0 1 3 -3h10a3 3 0 0 1 3 3v10a3 3 0 0 1 -3 3h-10a3 3 0 0 1 -3 -3z", "M8 9h8", "M8 13h5"];
|
|
20
20
|
const TURNS = ["M7 4l-3 3l3 3", "M4 7h13", "M17 20l3 -3l-3 -3", "M20 17h-13"];
|
|
@@ -36,15 +36,18 @@ function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
|
|
|
36
36
|
onOpenChange(true);
|
|
37
37
|
} } }), !phone && takes && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: own.body }))] }));
|
|
38
38
|
}
|
|
39
|
+
const RULE_KEYS = new Set(["convert", "relation", "delete", "why", "put-back"]), GROUP_KEYS = new Set(["exclude"]);
|
|
39
40
|
export function useFilterEditor(props) {
|
|
40
|
-
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels } = props;
|
|
41
|
+
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels, items } = props;
|
|
42
|
+
const deepest = levels ?? FILTER_DEPTH;
|
|
41
43
|
const w = filterWords(props.words), words = w.picker ? { words: w.picker } : {};
|
|
42
|
-
const { Button, Select, Menu, Popover, Input } = usePanelControls();
|
|
44
|
+
const { Button, Select, Menu, Popover, Input, Tooltip, NumberBox } = usePanelControls();
|
|
43
45
|
const screen = React.useContext(PhoneHost), small = usePhone(), way = props.form ?? (screen || small ? "phone" : "computer");
|
|
44
46
|
const phone = way === "phone", stacked = phone || way === "narrow";
|
|
45
47
|
const now = React.useRef(filter);
|
|
46
48
|
React.useLayoutEffect(() => { now.current = filter; });
|
|
47
49
|
const change = (next) => { now.current = next; onFilterChange(next); };
|
|
50
|
+
const latest = React.useMemo(() => ({ get filter() { return now.current; } }), []);
|
|
48
51
|
const nameOf = (field) => itemLabel(fields, field);
|
|
49
52
|
const ownOf = (r) => props.own?.(r) ?? null;
|
|
50
53
|
const labelOf = (r) => r.aside?.label ?? (fieldOf(fields, r.field) ? nameOf(r.field) : ownOf(r)?.field ?? nameOf(r.field));
|
|
@@ -136,7 +139,7 @@ export function useFilterEditor(props) {
|
|
|
136
139
|
const every = everyFits(g.rules, fieldsIn(filter, g.id, fields));
|
|
137
140
|
return QUANTIFIERS.map((q) => ({ value: q, label: w.quantifier(q), ...(q === "every" && !every ? { disabled: true, line: w.everyNeedsWhere(blockLabel(g).toLocaleLowerCase()) } : {}) }));
|
|
138
141
|
};
|
|
139
|
-
const stepFields = step?.list === "add" ? fieldsIn(filter, step.group, fields) : stepRule ? fieldsIn(filter, stepRule.id, fields) : fields;
|
|
142
|
+
const stepFields = step?.list === "add" ? fieldsIn(filter, step.group, fields, deepest) : stepRule ? fieldsIn(filter, stepRule.id, fields, deepest) : fields;
|
|
140
143
|
const stepList = usePicker(step?.list === "how" && stepRule && stepField
|
|
141
144
|
? { label: w.howOf(nameOf(stepRule.field)), items: waysOf(stepField), value: isOwnWay(stepRule.how) ? null : stepRule.how, searchShown: false, fromHeld: true, form: "phone", onDone: back,
|
|
142
145
|
onValueChange: (v) => { if (typeof v === "string" && v !== stepRule.how)
|
|
@@ -191,32 +194,35 @@ export function useFilterEditor(props) {
|
|
|
191
194
|
return _jsx(DateValue, { name: name, value: typeof r.value === "string" ? r.value : null, onValue: set(r.id), open: !standing && isOpen, onOpenChange: phone ? (o) => { if (o)
|
|
192
195
|
setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.chooseDate });
|
|
193
196
|
if (field.type === "number" || field.type === "range")
|
|
194
|
-
return _jsx(
|
|
197
|
+
return _jsx(NumberBox, { size: size, steppers: false, "aria-label": name, placeholder: w.typeNumber, value: typeof r.value === "number" ? r.value : null, onValueChange: (v) => set(r.id)(v ?? null) });
|
|
195
198
|
return _jsx(Input, { size: size, "aria-label": name, placeholder: w.typeValue, value: typeof r.value === "string" ? r.value : "", onChange: (e) => set(r.id)(e.target.value) });
|
|
196
199
|
};
|
|
197
200
|
function groupEntries(g) {
|
|
198
201
|
const can = canExclude(filter, g.id);
|
|
199
|
-
return [{ kind: "check", label: w.exclude, checked: !!g.exclude, slot: { slot: "vk-filter-group-action", key: "exclude" }, ...(can ? {} : { disabled: w.excludeNeedsAnd }),
|
|
200
|
-
onCheckedChange: (on) => change(setExclude(
|
|
202
|
+
return shapeMenu([{ kind: "check", label: w.exclude, checked: !!g.exclude, slot: { slot: "vk-filter-group-action", key: "exclude" }, ...(can ? {} : { disabled: w.excludeNeedsAnd }),
|
|
203
|
+
onCheckedChange: (on) => change(setExclude(latest.filter, g.id, on)) }], items, { menu: "group", group: g.id, form: phone ? "phone" : "computer" }, "vk-filter-group-action", GROUP_KEYS);
|
|
201
204
|
}
|
|
202
205
|
function ruleEntries(r) {
|
|
206
|
+
return shapeMenu(ruleEntriesOwn(r), items, { menu: r.aside ? "aside" : "rule", rule: r.id, form: phone ? "phone" : "computer" }, "vk-filter-rule-action", RULE_KEYS, { relation: w.relationRows });
|
|
207
|
+
}
|
|
208
|
+
function ruleEntriesOwn(r) {
|
|
203
209
|
const aside = r.aside;
|
|
204
210
|
const act = (key) => ({ slot: { slot: "vk-filter-rule-action", key } });
|
|
205
211
|
if (aside)
|
|
206
212
|
return [{ icon: null, label: aside.why, disabled: aside.why, ...act("why") },
|
|
207
|
-
...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(
|
|
213
|
+
...(aside.putBack ? [{ icon: null, label: w.putBack, onSelect: () => change(putBack(latest.filter, r.id)), ...act("put-back") }] : []),
|
|
208
214
|
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id), ...act("delete") }];
|
|
209
215
|
const blockable = !!relationOf(fields, r.field) && !blockAround(filter, r.id) && canGroup(filter, r.id, levels);
|
|
210
|
-
return [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(
|
|
216
|
+
return [...(canGroup(filter, r.id, levels) ? [{ icon: glyph(GROUP), label: w.toGroup, onSelect: () => change(toGroup(latest.filter, r.id, ids, levels)), ...act("convert") }] : []),
|
|
211
217
|
...(blockable ? [{ kind: "separator" }, { kind: "pick", value: "any", choices: QUANTIFIERS.filter((q) => q !== "every" || isWhole(r, fields)).map((q) => ({ value: q, label: w.quantifier(q), ...act(q) })),
|
|
212
|
-
onChoose: (q) => change(toBlock(
|
|
218
|
+
onChoose: (q) => change(toBlock(latest.filter, r.id, q, fields, ids, levels)), slot: { slot: "vk-filter-rule-action", key: "relation" } }, { kind: "separator" }] : []),
|
|
213
219
|
{ icon: glyph(TRASH), label: w.deleteRule, danger: true, onSelect: () => remove(r.id), ...act("delete") }];
|
|
214
220
|
}
|
|
215
221
|
const ruleRow = (r) => {
|
|
216
222
|
const field = fieldOf(fields, r.field), own = ownOf(r), aside = r.aside, name = labelOf(r);
|
|
217
223
|
const kitWay = field ? wayOf(field.type, r.how) : undefined, takes = kitWay ? kitWay.takes : own && !aside && own.body != null ? "one" : undefined;
|
|
218
224
|
const ways = field ? waysOf(field) : [];
|
|
219
|
-
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields));
|
|
225
|
+
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields, deepest));
|
|
220
226
|
const why = (node) => (aside ? _jsx(Tooltip, { label: aside.why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: node }) }) : node);
|
|
221
227
|
const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
|
|
222
228
|
return (_jsxs("div", { className: "o-filter-editor-rule", "data-slot": "vk-filter-rule", "data-key": r.field, "data-rule": r.id, "data-whole": (field || own) && isWhole(r, fields) ? "" : undefined, "data-set-aside": aside || (!field && !own) ? "" : undefined, "data-aside": aside ? "" : undefined, children: [_jsxs("div", { className: "o-filter-editor-boxes", children: [_jsx("div", { className: "o-filter-editor-field", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.field, "data-slot": "vk-filter-field", items: fieldItems, value: field && !aside ? r.field : null, placeholder: name, search: w.search, ...stepOf({ list: "field", rule: r.id }), onValueChange: (v) => { if (typeof v === "string" && (v !== r.field || aside))
|
|
@@ -233,14 +239,14 @@ export function useFilterEditor(props) {
|
|
|
233
239
|
const top = _jsxs(_Fragment, { children: [filter.exclude && _jsx("p", { className: "o-filter-editor-excluded", "data-slot": "vk-filter-excluded", children: w.excluded }), blockHead(filter)] });
|
|
234
240
|
const level = (g, depth) => (_jsx("div", { className: "o-filter-editor-rules", "data-slot": "vk-filter-rules", role: "list", "aria-label": depth ? w.group : label, children: g.rules.map((item, i) => (_jsxs("div", { role: "listitem", className: "o-filter-editor-item", "data-slot": "vk-filter-item", "data-index": i, children: [lead(g, i), isBlock(item) ? (_jsxs("div", { className: "o-filter-editor-group o-filter-editor-block", "data-slot": "vk-filter-group", "data-group": item.id, "data-block": item.id, children: [blockHead(item), level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", "data-slot": "vk-filter-delete", onClick: () => remove(item.id), children: w.deleteRule })] })] })) : isGroup(item) ? (_jsxs("div", { className: "o-filter-editor-group", "data-slot": "vk-filter-group", "data-group": item.id, children: [item.exclude && _jsx("p", { className: "o-filter-editor-excluded", "data-slot": "vk-filter-excluded", children: w.excluded }), level(item, depth + 1), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"), _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-delete", "data-slot": "vk-filter-delete", onClick: () => remove(item.id), children: w.deleteGroup }), groupMore(item)] })] })) : ruleRow(item)] }, item.id))) }));
|
|
235
241
|
const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
|
|
236
|
-
setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-
|
|
242
|
+
setAdding(null); }, anchor: adding?.at, className: "w-fit min-w-0", "aria-label": w.add, children: adding && _jsx(FieldsFrame, { children: _jsx(Picker, { label: w.add, items: fieldsIn(filter, adding.group, fields, deepest), value: null, onValueChange: (v) => add(adding.group, v), onDone: () => setAdding(null), search: w.search, searchShown: true, form: "computer", ...words }) }) }));
|
|
237
243
|
if (stacked) {
|
|
238
244
|
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "data-kit": "filter-editor", "data-filter-form": way, role: phone ? undefined : "group", "aria-label": phone ? undefined : label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-filter-step": stepTitle !== undefined ? step?.list : undefined, children: stepTitle !== undefined ? stepBody : _jsxs(_Fragment, { children: [top, filter.rules.length ? level(filter, 0)
|
|
239
|
-
: _jsxs("div", { className: "o-filter-editor-none", "data-slot": "vk-filter-none", children: [_jsx("p", { className: "o-filter-editor-none-head", children: w.none }), _jsx("p", { className: "o-filter-editor-none-line", children: w.noneLine })] }), _jsxs("div", { className: "o-filter-editor-acts", "data-slot": "vk-filter-foot", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAll }), props.excludable && groupMore(filter)] }), !phone && addingPopover] }) }));
|
|
245
|
+
: _jsxs("div", { className: "o-filter-editor-none", "data-slot": "vk-filter-none", children: [_jsx("p", { className: "o-filter-editor-none-head", children: w.none }), _jsx("p", { className: "o-filter-editor-none-line", children: w.noneLine })] }), _jsxs("div", { className: "o-filter-editor-acts", "data-slot": "vk-filter-foot", children: [addButton(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"), props.clearAll !== false && filter.rules.length > 0 && _jsx(Button, { kind: "quiet", size: phone ? "44" : "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAll }), props.excludable && groupMore(filter)] }), !phone && addingPopover] }) }));
|
|
240
246
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
241
247
|
}
|
|
242
248
|
const fieldsAlone = !filter.rules.length && !filter.relation;
|
|
243
|
-
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(filter.id, "outline", "sm"), _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words })) }));
|
|
249
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-filter-editor", "data-slot": "vk-filter", "data-kit": "filter-editor", "data-filter-form": "computer", role: "group", "aria-label": label, tabIndex: -1, "data-filter-fields": fieldsAlone ? "" : undefined, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsxs("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: [addButton(filter.id, "outline", "sm"), props.clearAll !== false && _jsx(Button, { kind: "quiet", size: "sm", className: "o-filter-editor-clear", "data-slot": "vk-filter-clear", onClick: clear, children: w.clearAllFilters }), props.excludable && groupMore(filter)] }), addingPopover] }) : (_jsx(FieldsFrame, { children: _jsx(Picker, { label: label, items: fields, value: null, onValueChange: (v) => add(filter.id, v), search: w.search, searchShown: true, form: "computer", ...words }) })) }));
|
|
244
250
|
return { body, head: {} };
|
|
245
251
|
}
|
|
246
252
|
export const useFilterEditorParts = useFilterEditor;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import type { FilterRule as ViewKitRule } from "viewkitjs/fields/query";
|
|
3
3
|
import { type ViewsMessageResolver } from "../../contract.js";
|
|
4
|
-
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps } from "../../provider/components.js";
|
|
5
|
-
import { type FilterOwn } from "./filter-editor.js";
|
|
4
|
+
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsMenuItem } from "../../provider/components.js";
|
|
5
|
+
import { type FilterEditorItemsContext, type FilterOwn } from "./filter-editor.js";
|
|
6
6
|
import { type ChoicesOf, type KitFields } from "./map-rules.js";
|
|
7
7
|
import { type FilterGroup as KitGroup, type FilterRule as KitRule } from "./rules.js";
|
|
8
8
|
import type { FilterEditorWords } from "./words.js";
|
|
@@ -15,6 +15,7 @@ type AppIcon = React.ComponentType<{
|
|
|
15
15
|
export declare function filterWordsOf(say: ViewsMessageResolver): FilterEditorWords;
|
|
16
16
|
/** ViewKit's filter body's props as the filter editor's parts, the level turned both ways. */
|
|
17
17
|
export declare function useMapFilterBody(p: ViewsFilterBodyProps, words: FilterEditorWords, say: ViewsMessageResolver, AppIcon: AppIcon | undefined, wayWord: (operator: string) => string): {
|
|
18
|
+
items?: ((is: ViewsMenuItem[], ctx: FilterEditorItemsContext) => ViewsMenuItem[]) | undefined;
|
|
18
19
|
kit: KitFields;
|
|
19
20
|
filter: KitGroup;
|
|
20
21
|
change: (next: KitGroup) => void;
|
|
@@ -49,6 +49,7 @@ export function filterWordsOf(say) {
|
|
|
49
49
|
save: say({ key: "views.panels.filter-done" }),
|
|
50
50
|
putBack: say({ key: "views.panels.put-back" }),
|
|
51
51
|
quantifier: (quantifier) => say({ key: "views.panels.filter-relation-way", values: { quantifier } }),
|
|
52
|
+
relationRows: say({ key: "views.panels.filter-relation-rows" }),
|
|
52
53
|
everyNeedsWhere: (one) => say({ key: "views.panels.relation-every-needs-where", values: { one } }),
|
|
53
54
|
groupActions: say({ key: "views.panels.filter-group-actions" }),
|
|
54
55
|
exclude: say({ key: "views.panels.filter-exclude" }),
|
|
@@ -135,7 +136,20 @@ export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
|
135
136
|
};
|
|
136
137
|
return { field: said?.field ?? f.label, way: said?.way ?? wayWord(inner.operator), value: said?.value ?? null, body: p.ruleValue(inner, put, relation) };
|
|
137
138
|
};
|
|
138
|
-
|
|
139
|
+
const publicOf = (ctx) => {
|
|
140
|
+
const paths = new Map();
|
|
141
|
+
viewKitFilterOf(read.filter, kit, read.kept, read.raw, paths);
|
|
142
|
+
if (ctx.menu === "group")
|
|
143
|
+
return { menu: "group", path: paths.get(ctx.group) ?? [], form: ctx.form };
|
|
144
|
+
const rule = rulesOf(read.filter).find((r) => r.id === ctx.rule), place = rule && kit.at.get(rule.field), node = read.raw.get(ctx.rule);
|
|
145
|
+
const inner = node && (isRelation(node.node) ? node.node.where.items[0] : node.node);
|
|
146
|
+
const field = place?.fieldKey ?? inner?.fieldKey ?? (node && isRelation(node.node) ? node.node.fieldKey : "");
|
|
147
|
+
const part = place ? place.part : inner?.part;
|
|
148
|
+
const relation = place ? place.relation ?? within : node && isRelation(node.node) ? node.node.fieldKey : node?.relation ?? within;
|
|
149
|
+
return { menu: ctx.menu, field, ...(part != null && { part }), ...(relation !== undefined && relation !== field && { relation }), path: paths.get(ctx.rule) ?? [], form: ctx.form };
|
|
150
|
+
};
|
|
151
|
+
const items = p.items && ((is, ctx) => p.items(is, publicOf(ctx)));
|
|
152
|
+
return { kit, filter: read.filter, change: (next) => write(next), own: ownOf, ...(items && { items }) };
|
|
139
153
|
}
|
|
140
154
|
export function MapFilterBody(props) {
|
|
141
155
|
return _jsx(PanelControlsFromViews, { children: _jsx(FilterBodyInner, { ...props }) });
|
|
@@ -146,7 +160,7 @@ function FilterBodyInner(props) {
|
|
|
146
160
|
const words = React.useMemo(() => filterWordsOf(say), [say]);
|
|
147
161
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
148
162
|
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord);
|
|
149
|
-
const parts = useFilterEditor({ label: props.label, fields: map.kit.fields, filter: map.filter, levels: props.levels, form: props.form, onDone: props.onDone,
|
|
163
|
+
const parts = useFilterEditor({ ...(map.items && { items: map.items }), label: props.label, fields: map.kit.fields, filter: map.filter, levels: props.levels, form: props.form, onDone: props.onDone,
|
|
150
164
|
onFilterChange: map.change, own: map.own, words, excludable: props.excludable });
|
|
151
165
|
useToldStep(parts, props.onStepChange);
|
|
152
166
|
const { actions } = props;
|
|
@@ -45,8 +45,12 @@ export type FieldAt = {
|
|
|
45
45
|
export type KitFields = {
|
|
46
46
|
fields: FilterField[];
|
|
47
47
|
at: ReadonlyMap<string, FieldAt>;
|
|
48
|
-
/** Each relation's kit field (its Related records row), by ViewKit's field key
|
|
48
|
+
/** Each relation's kit field (its Related records row), by ViewKit's field key: every relation the fields hand, a far field
|
|
49
|
+
* the kit types or not (VK-848). */
|
|
49
50
|
relations: ReadonlyMap<string, string>;
|
|
51
|
+
/** The name of a relation that has no Related records row (no far field the kit types), by ViewKit's field key: its block's
|
|
52
|
+
* head reads it. */
|
|
53
|
+
relationLabels?: ReadonlyMap<string, string>;
|
|
50
54
|
};
|
|
51
55
|
/** A field's values to pick from, by its key, and for a related record's field, its relation's; a part's (a place's country) by
|
|
52
56
|
* its part. */
|
|
@@ -69,7 +73,10 @@ export declare const RELATION_WAY = "vk:relation";
|
|
|
69
73
|
/** The kit's filter as a level of ViewKit's: its join (`not` again where the level read excluded its matches), its rules in fields'
|
|
70
74
|
* operators, its groups, each rule the kit can't word as the node it was read from (`raw`), and what was kept back in each group in
|
|
71
75
|
* its place, a group the kit took away handing its kept to the nearest one left. */
|
|
72
|
-
|
|
76
|
+
/** Where each kit item lands in ViewKit's filter: its path of indices through `items` (and a relation rule's `where.items`), the
|
|
77
|
+
* whole filter `[]` (VK-1063: an app's menus name a rule or a group by it). */
|
|
78
|
+
export type KitPaths = Map<string, number[]>;
|
|
79
|
+
export declare function viewKitFilterOf(filter: KitGroup, fields: KitFields, kept: Kept, raw?: Raw, paths?: KitPaths): FilterGroup;
|
|
73
80
|
/** A level of ViewKit's filter as the kit's: its rules and groups, ids `root`, then `v1`… and `r1`… in reading order; a set-aside rule
|
|
74
81
|
* carrying its words (`asideWords`), a rule on a way or a place's part the kit can't word on its `vk:` way, each with the node it was
|
|
75
82
|
* read from in `raw`. A `not` group is a kit group that excludes its matches (`exclude`, joined by And), or a date's "is not" an
|
|
@@ -42,18 +42,20 @@ export function kitFieldsOf(fields, choices, relation) {
|
|
|
42
42
|
return [{ value, label: f.label, type, ...(values ? { choices: values } : {}), ...(f.integer ? { integer: true } : {}) }];
|
|
43
43
|
};
|
|
44
44
|
const own = (f, from) => field(f, f.key, { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}) }, from);
|
|
45
|
-
const relations = new Map();
|
|
45
|
+
const relations = new Map(), relationLabels = new Map();
|
|
46
46
|
if (relation !== undefined)
|
|
47
47
|
return { fields: (fields.find((f) => f.far && f.fieldKey === relation)?.far ?? []).flatMap((f) => own(f, relation)), at, relations };
|
|
48
48
|
const list = fields.filter((f) => !f.far).flatMap((f) => own(f));
|
|
49
49
|
const related = fields.filter((f) => f.far).flatMap((r) => {
|
|
50
50
|
const level = (r.far ?? []).flatMap((f) => field(f, pathOf(r.key, f.key), { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}), relation: r.fieldKey }, r.fieldKey));
|
|
51
|
-
if (!level.length)
|
|
52
|
-
return [];
|
|
53
51
|
relations.set(r.fieldKey, r.key);
|
|
52
|
+
if (!level.length) {
|
|
53
|
+
relationLabels.set(r.fieldKey, r.label);
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
54
56
|
return [{ value: r.key, label: r.label, type: "record", group: RELATED, level }];
|
|
55
57
|
});
|
|
56
|
-
return { fields: [...list, ...related], at, relations };
|
|
58
|
+
return { fields: [...list, ...related], at, relations, relationLabels };
|
|
57
59
|
}
|
|
58
60
|
const none = { write: () => null, read: () => null };
|
|
59
61
|
const list = (v) => (Array.isArray(v) ? v.map(String) : typeof v === "string" ? [v] : []);
|
|
@@ -111,7 +113,7 @@ function anchorIn(g, order, after) {
|
|
|
111
113
|
}
|
|
112
114
|
return null;
|
|
113
115
|
}
|
|
114
|
-
export function viewKitFilterOf(filter, fields, kept, raw = new Map()) {
|
|
116
|
+
export function viewKitFilterOf(filter, fields, kept, raw = new Map(), paths) {
|
|
115
117
|
const here = new Set(groupIds(filter)), orphans = {};
|
|
116
118
|
for (const [id, k] of Object.entries(kept)) {
|
|
117
119
|
if (here.has(id) || !k.nodes.length)
|
|
@@ -121,7 +123,8 @@ export function viewKitFilterOf(filter, fields, kept, raw = new Map()) {
|
|
|
121
123
|
to = kept[to]?.parent ?? null;
|
|
122
124
|
(orphans[to ?? filter.id] ??= []).push({ op: k.op, items: k.nodes.map((n) => n.node) });
|
|
123
125
|
}
|
|
124
|
-
|
|
126
|
+
paths?.set(filter.id, []);
|
|
127
|
+
return levelOf(filter, fields, kept, raw, orphans, undefined, paths, []);
|
|
125
128
|
}
|
|
126
129
|
function withoutAside(n) {
|
|
127
130
|
const { setAside: _gone, ...rest } = n;
|
|
@@ -143,7 +146,7 @@ function ruleNodes(x, fields, raw, inRelation) {
|
|
|
143
146
|
return [place.relation !== undefined && place.relation !== inRelation ? { fieldKey: place.relation, quantifier: "any", where: { op: "and", items: [rule] } } : rule];
|
|
144
147
|
}
|
|
145
148
|
const relationKeyOf = (fields, field) => [...fields.relations].find(([, value]) => value === field)?.[0];
|
|
146
|
-
function levelOf(filter, fields, kept, raw, orphans, inRelation) {
|
|
149
|
+
function levelOf(filter, fields, kept, raw, orphans, inRelation, paths, at = []) {
|
|
147
150
|
const k = kept[filter.id];
|
|
148
151
|
const after = new Map();
|
|
149
152
|
for (const n of k?.nodes ?? []) {
|
|
@@ -152,17 +155,19 @@ function levelOf(filter, fields, kept, raw, orphans, inRelation) {
|
|
|
152
155
|
}
|
|
153
156
|
const items = [...(after.get(null) ?? [])];
|
|
154
157
|
for (const x of filter.rules) {
|
|
155
|
-
|
|
158
|
+
const path = [...at, items.length];
|
|
159
|
+
paths?.set(x.id, path);
|
|
160
|
+
items.push(...(isKitGroup(x) ? groupNodes(x, fields, kept, raw, orphans, inRelation, paths, path) : ruleNodes(x, fields, raw, inRelation)), ...(after.get(x.id) ?? []));
|
|
156
161
|
}
|
|
157
162
|
return { op: filter.exclude ? "not" : filter.join, items: [...items, ...(orphans[filter.id] ?? [])] };
|
|
158
163
|
}
|
|
159
|
-
function groupNodes(x, fields, kept, raw, orphans, inRelation) {
|
|
164
|
+
function groupNodes(x, fields, kept, raw, orphans, inRelation, paths, at = []) {
|
|
160
165
|
if (!x.relation)
|
|
161
|
-
return [levelOf(x, fields, kept, raw, orphans, inRelation)];
|
|
166
|
+
return [levelOf(x, fields, kept, raw, orphans, inRelation, paths, at)];
|
|
162
167
|
const key = relationKeyOf(fields, x.relation.field);
|
|
163
168
|
if (key === undefined)
|
|
164
169
|
return [];
|
|
165
|
-
const where = levelOf(x, fields, kept, raw, orphans, key);
|
|
170
|
+
const where = levelOf(x, fields, kept, raw, orphans, key, paths, at);
|
|
166
171
|
return [{ fieldKey: key, quantifier: x.relation.quantifier, where: { op: where.op === "or" ? "or" : "and", items: where.items } }];
|
|
167
172
|
}
|
|
168
173
|
export function kitFilterOf(level, fields, asideWords) {
|
|
@@ -248,8 +253,8 @@ export function kitFilterOf(level, fields, asideWords) {
|
|
|
248
253
|
out.push(readAsideRelation(n));
|
|
249
254
|
continue;
|
|
250
255
|
}
|
|
251
|
-
const block = walk(n.where, `v${++groups}`, id, n.fieldKey);
|
|
252
|
-
out.push({ ...block, relation: { field: relation, quantifier: n.quantifier } });
|
|
256
|
+
const block = walk(n.where, `v${++groups}`, id, n.fieldKey), label = fields.relationLabels?.get(n.fieldKey);
|
|
257
|
+
out.push({ ...block, relation: { field: relation, ...(label !== undefined ? { label } : {}), quantifier: n.quantifier } });
|
|
253
258
|
continue;
|
|
254
259
|
}
|
|
255
260
|
out.push(n.setAside ? readAside(n, inBlock, n, inBlock) : read(n, inBlock) ?? readOwn(n, n, inBlock, inBlock) ?? readTheirs(n, inBlock));
|
|
@@ -35,7 +35,7 @@ export declare const FILTER_SEARCH: string;
|
|
|
35
35
|
export declare function valuePlaceholder(field: FilterField, w?: FilterEditorWords): string;
|
|
36
36
|
/** The body a Popover holds under the part of a filter pressed: the fields, its type's ways, or its value in its type's own. */
|
|
37
37
|
export declare function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFilterChange, onDone, own, form, words: given }: FilterPartProps): import("react/jsx-runtime").JSX.Element | null;
|
|
38
|
-
/** A range's From and To: two
|
|
38
|
+
/** A range's From and To: two number boxes, an en dash between, each named by its end; either may be left empty. */
|
|
39
39
|
export declare function PairValue({ name, value, onValue, size, onKeyDown, words: given, slot }: {
|
|
40
40
|
name: string;
|
|
41
41
|
value: [number | null, number | null];
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { DateEditor } from "../date-editor/date-editor.js";
|
|
4
4
|
import { usePanelControls } from "../internal/panel-controls.js";
|
|
5
|
-
import { NumberField } from "../number-field/number-field.js";
|
|
6
5
|
import { Picker } from "../picker/picker.js";
|
|
6
|
+
import { FieldsFrame } from "../picker/fields-frame.js";
|
|
7
7
|
import { itemLabel } from "../picker/rows.js";
|
|
8
8
|
import { HOW, wayOf } from "./how.js";
|
|
9
9
|
import { addRule, changeRule, fieldOf, isOwnWay, isPair, rulesOf } from "./rules.js";
|
|
@@ -21,17 +21,17 @@ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFi
|
|
|
21
21
|
const set = (change) => { if (r)
|
|
22
22
|
onFilterChange((now) => (rulesOf(now).some((x) => x.id === r.id) ? changeRule(now, r.id, change, fields) : now)); };
|
|
23
23
|
if (part === "field")
|
|
24
|
-
return (_jsx(Picker, { label: r ? name : label, items: fields, value: r?.field ?? null, search: w.search, searchShown: true, form: form, onDone: onDone, ...words, onValueChange: (v) => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
24
|
+
return (_jsx(FieldsFrame, { children: _jsx(Picker, { label: r ? name : label, items: fields, value: r?.field ?? null, search: w.search, searchShown: true, form: form, onDone: onDone, ...words, onValueChange: (v) => {
|
|
25
|
+
if (typeof v !== "string")
|
|
26
|
+
return;
|
|
27
|
+
if (!r) {
|
|
28
|
+
const added = addRule(filter, v, fields);
|
|
29
|
+
if (added.id)
|
|
30
|
+
onFilterChange(added.filter);
|
|
31
|
+
}
|
|
32
|
+
else if (v !== r.field)
|
|
33
|
+
set({ field: v });
|
|
34
|
+
} }) }));
|
|
35
35
|
if (!r)
|
|
36
36
|
return null;
|
|
37
37
|
const theirs = part === "value" ? own?.(r) : null;
|
|
@@ -62,7 +62,8 @@ export function FilterPartBody({ part, rule: ruleId, label, fields, filter, onFi
|
|
|
62
62
|
}
|
|
63
63
|
export function PairValue({ name, value, onValue, size, onKeyDown, words: given, slot }) {
|
|
64
64
|
const w = filterWords(given), [from, to] = value;
|
|
65
|
-
|
|
65
|
+
const { NumberBox } = usePanelControls();
|
|
66
|
+
return (_jsxs("div", { className: "o-filter-editor-pair", ...(slot ? { "data-slot": slot } : {}), children: [_jsx(NumberBox, { size: size, steppers: false, "aria-label": w.fromOf(name), placeholder: w.from, value: from, onValueChange: (v) => onValue([v ?? null, to]), onKeyDown: onKeyDown }), _jsx("span", { className: "o-filter-editor-dash", "aria-hidden": "true", children: "\u2013" }), _jsx(NumberBox, { size: size, steppers: false, "aria-label": w.toOf(name), placeholder: w.to, value: to, onValueChange: (v) => onValue([from, v ?? null]), onKeyDown: onKeyDown })] }));
|
|
66
67
|
}
|
|
67
68
|
const WHOLE = { maximumFractionDigits: 0 };
|
|
68
69
|
function TypedValue({ rule: r, field, name, set, onDone, w }) {
|
|
@@ -70,8 +71,8 @@ function TypedValue({ rule: r, field, name, set, onDone, w }) {
|
|
|
70
71
|
e.preventDefault();
|
|
71
72
|
onDone();
|
|
72
73
|
} };
|
|
73
|
-
const { Input } = usePanelControls();
|
|
74
|
+
const { Input, NumberBox } = usePanelControls();
|
|
74
75
|
return field.type === "number" || field.type === "range"
|
|
75
|
-
? _jsx(
|
|
76
|
+
? _jsx(NumberBox, { "data-slot": "vk-filter-part-value", "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "number" ? r.value : null, format: field.integer ? WHOLE : undefined, onValueChange: (v) => set({ value: v ?? null }), onKeyDown: enter })
|
|
76
77
|
: _jsx(Input, { "data-slot": "vk-filter-part-value", "aria-label": name, placeholder: valuePlaceholder(field, w), value: typeof r.value === "string" ? r.value : "", onChange: (e) => set({ value: e.target.value }), onKeyDown: enter });
|
|
77
78
|
}
|
|
@@ -82,10 +82,10 @@ export declare function toGroup(f: FilterGroup, ruleId: string, taken?: readonly
|
|
|
82
82
|
export declare const blockAround: (f: FilterGroup, id: string) => FilterGroup | undefined;
|
|
83
83
|
/** The field a rule's field stands under one level in (a deal's Company for Company › Region); none at the top. */
|
|
84
84
|
export declare function relationOf(fields: FilterField[], field: string): FilterField | undefined;
|
|
85
|
-
/** The fields a rule in group `id` may name: a block's relation's own (its `level`; none where the fields don't
|
|
86
|
-
* nothing outside the relation is offered), else every field
|
|
87
|
-
* root) holds that relation's fields as its own. */
|
|
88
|
-
export declare function fieldsIn(f: FilterGroup, id: string, fields: FilterField[]): FilterField[];
|
|
85
|
+
/** The fields a rule in group `id` (or the rule `id`) may name: a block's relation's own (its `level`; none where the fields don't
|
|
86
|
+
* list it, so nothing outside the relation is offered), else every field, but for one standing `levels` deep (when handed) no
|
|
87
|
+
* related field. The filter itself open on a relation's where (`relation` on the root) holds that relation's fields as its own. */
|
|
88
|
+
export declare function fieldsIn(f: FilterGroup, id: string, fields: FilterField[], levels?: number): FilterField[];
|
|
89
89
|
/** Whether the group `id` can exclude its matches: a group, not a block, joined by And. The filter itself answers so too: whether
|
|
90
90
|
* it may (an advanced filter's own group, not a whole filter) is its holder's to say (`excludable`). */
|
|
91
91
|
export declare const canExclude: (f: FilterGroup, id: string) => boolean;
|
|
@@ -96,11 +96,14 @@ export const blockAround = (f, id) => groupsAround(f, id).reverse().find((g) =>
|
|
|
96
96
|
export function relationOf(fields, field) {
|
|
97
97
|
return findItem(fields, field)?.path[0];
|
|
98
98
|
}
|
|
99
|
-
export function fieldsIn(f, id, fields) {
|
|
99
|
+
export function fieldsIn(f, id, fields, levels) {
|
|
100
100
|
const block = blockAround(f, id);
|
|
101
|
-
if (
|
|
101
|
+
if (block && block !== f)
|
|
102
|
+
return fieldOf(fields, block.relation.field)?.level ?? [];
|
|
103
|
+
if (levels === undefined)
|
|
102
104
|
return fields;
|
|
103
|
-
|
|
105
|
+
const x = itemOf(f, id), at = x && isGroup(x) ? depthOf(f, id) + 1 : depthOf(f, id);
|
|
106
|
+
return at >= levels ? fields.filter((field) => !field.level) : fields;
|
|
104
107
|
}
|
|
105
108
|
export const canExclude = (f, id) => { const g = itemOf(f, id); return !!g && isGroup(g) && !g.relation && g.join === "and"; };
|
|
106
109
|
export function setExclude(f, id, exclude) {
|