viewkitjs 0.38.0 → 0.40.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 +134 -0
- package/MIGRATION.md +32 -0
- package/fields/dist/derived.d.ts +7 -0
- package/fields/dist/derived.js +4 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +5 -1
- package/fields/dist/messages.js +3 -0
- package/fields/dist/query/evaluate.d.ts +7 -1
- package/fields/dist/query/evaluate.js +8 -5
- package/fields/dist/query/figure-kinds.d.ts +2 -2
- package/fields/dist/query/figure-kinds.js +3 -0
- package/fields/dist/query/figures.d.ts +5 -3
- package/fields/dist/query/figures.js +13 -0
- package/fields/dist/query/filter.d.ts +7 -0
- package/fields/dist/query/filter.js +7 -1
- package/fields/dist/query/kit.d.ts +3 -2
- package/fields/dist/query/kit.js +1 -1
- package/fields/dist/query/layer.d.ts +6 -0
- package/fields/dist/query/layer.js +3 -0
- package/fields/dist/query/number.d.ts +3 -2
- package/fields/dist/query/number.js +5 -3
- package/fields/dist/query/read-rule.d.ts +1 -1
- package/fields/dist/query/read-rule.js +3 -0
- package/fields/docs/guides/queries.md +28 -24
- package/fields/docs/reference/fields.md +1 -0
- package/fields/docs/reference/query.md +9 -7
- package/package.json +2 -4
- package/postgres/dist/check.js +3 -1
- package/postgres/dist/definitions/storage.d.ts +3 -1
- package/postgres/dist/definitions/storage.js +3 -1
- package/postgres/dist/definitions/stored.js +13 -2
- package/postgres/dist/map.d.ts +5 -1
- package/postgres/dist/map.js +4 -0
- package/postgres/dist/records.js +6 -1
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +3 -3
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/HeaderChrome.d.ts +7 -0
- package/views/dist/atoms/HeaderChrome.js +15 -0
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +2 -2
- package/views/dist/atoms/defaults.js +4 -0
- package/views/dist/atoms/types.d.ts +39 -2
- package/views/dist/contract.d.ts +38 -9
- package/views/dist/contract.js +64 -6
- package/views/dist/controls/avatar.css +1 -1
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +2 -14
- package/views/dist/controls/field/field.js +4 -9
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -3
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +33 -0
- package/views/dist/controls/filter-editor/block.d.ts +3 -1
- package/views/dist/controls/filter-editor/block.js +4 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +15 -2
- package/views/dist/controls/filter-editor/filter-editor.js +49 -16
- package/views/dist/controls/filter-editor/how.d.ts +11 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +21 -11
- package/views/dist/controls/filter-editor/map-rules.d.ts +6 -4
- package/views/dist/controls/filter-editor/map-rules.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +14 -1
- package/views/dist/controls/filter-editor/parts.js +14 -0
- package/views/dist/controls/filter-editor.css +4 -1
- package/views/dist/controls/index.d.ts +0 -3
- package/views/dist/controls/index.js +0 -3
- package/views/dist/controls/input.css +1 -1
- package/views/dist/controls/internal/menu-items.d.ts +2 -0
- package/views/dist/controls/internal/menu-items.js +1 -1
- package/views/dist/controls/internal/part-slot.d.ts +1 -1
- package/views/dist/controls/internal/part-slot.js +1 -1
- package/views/dist/controls/internal/row-actions.d.ts +33 -0
- package/views/dist/controls/internal/row-actions.js +28 -0
- package/views/dist/controls/menu/map-menu.js +1 -1
- package/views/dist/controls/menu-list.css +1 -1
- package/views/dist/controls/picker/looks.d.ts +1 -1
- package/views/dist/controls/picker.css +2 -2
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/press.css +0 -1
- package/views/dist/controls/radio/radio.d.ts +1 -1
- package/views/dist/controls/radio/radio.js +1 -16
- package/views/dist/controls/sheet/bottom-sheet.d.ts +2 -2
- package/views/dist/controls/sheet/bottom-sheet.js +31 -24
- package/views/dist/controls/sheet/map-sheet.js +9 -6
- 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 +41 -13
- package/views/dist/controls/text-editor.css +22 -0
- package/views/dist/controls/tokens.js +0 -6
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +38 -16
- package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
- package/views/dist/field-row/editors/RowDateEditor.js +3 -1
- package/views/dist/field-row/editors/RowNameEditor.js +3 -1
- package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
- package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
- package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
- package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
- package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
- package/views/dist/field-row/editors/RowTextEditor.js +28 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
- package/views/dist/field-row/editors/row-place.d.ts +33 -0
- package/views/dist/field-row/editors/row-place.js +141 -0
- package/views/dist/field-row/field-row-button.d.ts +9 -6
- package/views/dist/field-row/field-row-button.js +3 -3
- package/views/dist/field-row/row-target.d.ts +4 -1
- package/views/dist/field-row/row-target.js +1 -1
- package/views/dist/filters/duration-bound.d.ts +7 -0
- package/views/dist/filters/duration-bound.js +9 -0
- package/views/dist/filters/filter-model.d.ts +4 -0
- package/views/dist/filters/number-refused.d.ts +8 -0
- package/views/dist/filters/number-refused.js +4 -0
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
- package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
- package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
- package/views/dist/grid/chrome/GridFooter.js +11 -9
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
- package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTableSurface.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
- package/views/dist/grid/chrome/grid-body-place.js +4 -5
- package/views/dist/grid/chrome/grid-figure-value.js +10 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +15 -4
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +12 -2
- package/views/dist/grid/core/clipboard-model.js +42 -8
- package/views/dist/grid/core/commit-model.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.d.ts +29 -1
- package/views/dist/grid/core/editing-controller.js +142 -12
- package/views/dist/grid/core/pending-reconciliation.d.ts +14 -0
- package/views/dist/grid/core/pending-reconciliation.js +20 -8
- package/views/dist/grid/core/save-path.d.ts +4 -2
- package/views/dist/grid/core/save-path.js +1 -1
- package/views/dist/grid/core/spreadsheet-operations.js +43 -5
- package/views/dist/grid/core/useGridEditing.d.ts +5 -1
- package/views/dist/grid/core/useGridEditing.js +4 -4
- package/views/dist/grid/core/written-alongside.d.ts +16 -0
- package/views/dist/grid/core/written-alongside.js +30 -0
- package/views/dist/grid/grid.css +8 -4
- package/views/dist/grid/index.d.ts +1 -1
- package/views/dist/grid/looks.d.ts +2 -2
- package/views/dist/internal/before-paint.d.ts +5 -0
- package/views/dist/internal/before-paint.js +17 -0
- package/views/dist/internal/field-rows.d.ts +0 -8
- package/views/dist/internal/field-rows.js +1 -3
- package/views/dist/internal/over-cell.d.ts +8 -0
- package/views/dist/internal/over-cell.js +5 -0
- package/views/dist/list/bar-keys.d.ts +8 -0
- package/views/dist/list/bar-keys.js +3 -0
- package/views/dist/list/bar-parts.d.ts +27 -0
- package/views/dist/list/bar-parts.js +38 -0
- package/views/dist/list/buttons/clear-save.d.ts +7 -0
- package/views/dist/list/buttons/clear-save.js +19 -0
- package/views/dist/list/buttons/customize.d.ts +28 -0
- package/views/dist/list/buttons/customize.js +31 -0
- package/views/dist/list/buttons/filter.d.ts +32 -0
- package/views/dist/list/buttons/filter.js +60 -0
- package/views/dist/list/buttons/new.d.ts +18 -0
- package/views/dist/list/buttons/new.js +21 -0
- package/views/dist/list/buttons/quick.d.ts +15 -0
- package/views/dist/list/buttons/quick.js +24 -0
- package/views/dist/list/buttons/search.d.ts +18 -0
- package/views/dist/list/buttons/search.js +17 -0
- package/views/dist/list/buttons/shared.d.ts +97 -0
- package/views/dist/list/buttons/shared.js +137 -0
- package/views/dist/list/buttons/sort-filter.d.ts +6 -0
- package/views/dist/list/buttons/sort-filter.js +16 -0
- package/views/dist/list/buttons/sort.d.ts +17 -0
- package/views/dist/list/buttons/sort.js +34 -0
- package/views/dist/list/buttons/views.d.ts +21 -0
- package/views/dist/list/buttons/views.js +38 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/edits.d.ts +3 -1
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/layer.d.ts +13 -3
- package/views/dist/list/layer.js +13 -3
- package/views/dist/list/line.d.ts +58 -0
- package/views/dist/list/line.js +229 -0
- package/views/dist/list/list.d.ts +7 -1
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/pane-box.d.ts +6 -0
- package/views/dist/list/pane-box.js +15 -0
- package/views/dist/list/panels/customize.d.ts +8 -0
- package/views/dist/list/panels/customize.js +23 -0
- package/views/dist/list/panels/filter-bar.d.ts +12 -0
- package/views/dist/list/panels/filter-bar.js +73 -0
- package/views/dist/list/panels/filter.d.ts +8 -0
- package/views/dist/list/panels/filter.js +23 -0
- package/views/dist/list/panels/quick.d.ts +7 -0
- package/views/dist/list/panels/quick.js +16 -0
- package/views/dist/list/panels/shared.d.ts +26 -0
- package/views/dist/list/panels/shared.js +36 -0
- package/views/dist/list/panels/sort.d.ts +8 -0
- package/views/dist/list/panels/sort.js +19 -0
- package/views/dist/list/panels/views.d.ts +13 -0
- package/views/dist/list/panels/views.js +27 -0
- package/views/dist/list/ready.d.ts +35 -0
- package/views/dist/list/ready.js +7 -0
- package/views/dist/list/root-base.d.ts +19 -1
- package/views/dist/list/root-base.js +13 -3
- package/views/dist/list/root.d.ts +1 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +29 -0
- package/views/dist/list/store.js +48 -2
- package/views/dist/list/toolbar-model.d.ts +99 -0
- package/views/dist/list/toolbar-model.js +195 -0
- package/views/dist/list/toolbar.js +142 -329
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/list/views.d.ts +1 -1
- package/views/dist/list/views.js +4 -1
- package/views/dist/looks/index.d.ts +0 -1
- package/views/dist/looks/index.js +0 -1
- package/views/dist/looks/looks.d.ts +1 -1
- package/views/dist/looks/pieces.js +0 -2
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- package/views/dist/model/column-filters.js +10 -3
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/filter/NumberFilterBody.js +6 -8
- package/views/dist/panels/labels.js +7 -2
- package/views/dist/panels/model.d.ts +3 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-body.js +7 -3
- package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
- package/views/dist/panels/react/sort/SortEditor.js +4 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +84 -0
- package/views/dist/panels/react/toolbar/ToolbarButton.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
- package/views/dist/panels/react/toolbar/context.d.ts +4 -0
- package/views/dist/panels/react/toolbar/context.js +1 -0
- package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
- package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +10 -3
- package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
- package/views/dist/panels/settings/filter-groups.js +12 -0
- package/views/dist/panels/settings/input.d.ts +11 -0
- package/views/dist/panels/settings/layout.js +26 -0
- package/views/dist/panels/settings/person.d.ts +15 -0
- package/views/dist/panels/settings/person.js +6 -0
- package/views/dist/panels/toolbar/page-resets.js +14 -3
- package/views/dist/provider/components.d.ts +47 -4
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +116 -257
- package/views/dist/styles.unlayered.css +116 -257
- package/views/docs/contract.md +28 -18
- package/views/docs/controls/field.md +2 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/menu.md +1 -1
- package/views/docs/controls/sort-editor.md +1 -1
- package/views/docs/guides/atoms.md +1 -0
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +6 -4
- package/views/docs/guides/toolbar-parts.md +337 -0
- package/views/docs/index.md +4 -0
- package/views/docs/reference/controls.md +6 -44
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +8 -7
- package/views/docs/reference/list.md +184 -11
- package/views/docs/reference/looks.md +13 -16
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +14 -11
- package/views/docs/reference/views.md +9 -7
- package/views/skills/views/SKILL.md +2 -1
- package/views/dist/controls/setting-row/looks.d.ts +0 -10
- package/views/dist/controls/setting-row/looks.js +0 -22
- package/views/dist/controls/setting-row/setting-row.d.ts +0 -102
- package/views/dist/controls/setting-row/setting-row.js +0 -135
- package/views/dist/controls/setting-row/tokens.d.ts +0 -156
- package/views/dist/controls/setting-row/tokens.js +0 -41
- package/views/dist/controls/setting-row.css +0 -216
- package/views/dist/controls/switch-row/switch-row.d.ts +0 -1
- package/views/dist/controls/switch-row/switch-row.js +0 -1
- package/views/dist/controls/switch-row/tokens.d.ts +0 -39
- package/views/dist/controls/switch-row/tokens.js +0 -12
- package/views/dist/controls/switch-row.css +0 -35
- package/views/dist/controls/tag-field/tag-field.d.ts +0 -24
- package/views/dist/controls/tag-field/tag-field.js +0 -25
- package/views/dist/controls/tag-field/tokens.d.ts +0 -23
- package/views/dist/controls/tag-field/tokens.js +0 -8
- package/views/dist/controls/tag-field.css +0 -32
- package/views/docs/controls/setting-row.md +0 -44
- package/views/docs/controls/switch-row.md +0 -15
- package/views/docs/controls/tag-field.md +0 -11
|
@@ -5,7 +5,7 @@ import { Field as BaseField } from "@base-ui/react/field";
|
|
|
5
5
|
import { Fieldset as BaseFieldset } from "@base-ui/react/fieldset";
|
|
6
6
|
import { FieldRootContext, useFieldRootContext } from "@base-ui/react/internals/field-root-context";
|
|
7
7
|
import { cx } from "../../internal/cx.js";
|
|
8
|
-
import {
|
|
8
|
+
import { FieldRowsCardContext, InFieldRow, OutOfFieldRows } from "../../internal/field-rows.js";
|
|
9
9
|
import { ScreenForms } from "../../internal/screen-forms.js";
|
|
10
10
|
import { ComputerHost, PhoneHost, phoneMark, usePhoneForm } from "../internal/phone.js";
|
|
11
11
|
import { fieldRowsAttrs } from "./looks.js";
|
|
@@ -17,13 +17,8 @@ export function ErrorWords({ errors }) {
|
|
|
17
17
|
return errors.length > 1 ? _jsx("ul", { className: "o-field-errors", children: errors.map((e, i) => _jsx("li", { children: e }, i)) }) : _jsx(_Fragment, { children: errors[0] });
|
|
18
18
|
}
|
|
19
19
|
export function Field(props) {
|
|
20
|
-
const card = React.useContext(FieldRowsCardContext)
|
|
21
|
-
return card ? _jsx(FieldAsRow, { ...props, card: card }) :
|
|
22
|
-
}
|
|
23
|
-
function FieldAsSettingRow({ label, required = false, note, error, keepNote = false, disabled, nativeLabel = true, labelId, className, children, "data-slot": partSlot, "data-key": partKey }) {
|
|
24
|
-
const errors = errorsOf(error), invalid = errors.length > 0, name = typeof label === "string" ? label : undefined;
|
|
25
|
-
const end = React.useMemo(() => ({ name }), [name]);
|
|
26
|
-
return (_jsxs(BaseField.Root, { className: cx("o-setting-row o-setting-row-field", className), "data-slot": partSlot, "data-key": partKey, "data-setting-row-kind": "field", invalid: invalid, disabled: disabled, "data-kit": "field", children: [_jsxs("span", { className: "o-choice-text", children: [label != null && _jsxs(BaseField.Label, { className: "o-choice-label", id: labelId, ...(nativeLabel ? {} : { nativeLabel: false, render: _jsx("span", {}) }), children: [label, required && _jsx("span", { className: "o-field-req", "aria-hidden": "true", children: "*" })] }), note != null && (!invalid || keepNote) && _jsx(BaseField.Description, { className: "o-choice-note", children: note }), invalid && _jsx(BaseField.Error, { className: "o-choice-note o-setting-row-error", match: true, children: _jsx(ErrorWords, { errors: errors }) })] }), _jsx("span", { className: "o-setting-row-end", children: _jsx(SettingRowField.Provider, { value: false, children: _jsx(AtSettingRowEnd.Provider, { value: end, children: children }) }) })] }));
|
|
20
|
+
const card = React.useContext(FieldRowsCardContext);
|
|
21
|
+
return card ? _jsx(FieldAsRow, { ...props, card: card }) : _jsx(FieldBox, { ...props });
|
|
27
22
|
}
|
|
28
23
|
const useBeforePaint = typeof window === "undefined" ? React.useEffect : React.useLayoutEffect;
|
|
29
24
|
function FieldAsRow({ card, label, required = false, note, error, disabled, nativeLabel = true, labelId, className, children, "data-slot": partSlot, "data-key": partKey }) {
|
|
@@ -61,7 +56,7 @@ function FieldRowsCardOf({ look, className, children, ...props }) {
|
|
|
61
56
|
const { card, foot } = useFieldRowsCard();
|
|
62
57
|
return (_jsxs(FieldRowsCardContext.Provider, { value: card, children: [_jsx("div", { className: cx("o-field-rows", className), "data-kit": "field", ...(look ? fieldRowsAttrs(look) : {}), ...props, children: children }), foot] }));
|
|
63
58
|
}
|
|
64
|
-
|
|
59
|
+
function useFieldRowsCard() {
|
|
65
60
|
const [order, setOrder] = React.useState([]);
|
|
66
61
|
const [needs, setNeeds] = React.useState(() => new Set());
|
|
67
62
|
const [slots, setSlots] = React.useState(() => new Map());
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PieceLooks } from "../../looks/looks.js";
|
|
2
|
-
export type FieldLookOptionId = "rows-cards" | "rows-edge" | "rows-height" | "rows-label" | "rows-lines" | "row-icon" | "row-box" | "row-action";
|
|
2
|
+
export type FieldLookOptionId = "rows-cards" | "rows-edge" | "rows-height" | "rows-label" | "rows-lines" | "row-icon" | "row-box" | "row-action" | "row-open" | "row-long" | "row-link";
|
|
3
3
|
/** A card's own look, handed by its place (an editor's look): each option, an option left out taking its default. */
|
|
4
4
|
export type FieldRowsLook = Partial<{
|
|
5
5
|
cards: "one" | "each";
|
|
@@ -7,15 +7,19 @@ const options = [
|
|
|
7
7
|
{ id: "row-icon", name: "Icon", def: "on", device: "desktop", demo: false, values: [{ id: "on", name: "On" }, { id: "off", name: "Off" }] },
|
|
8
8
|
{ id: "row-box", name: "Box", def: "target", device: "desktop", demo: false, values: [{ id: "target", name: "Target" }, { id: "box", name: "Box" }] },
|
|
9
9
|
{ id: "row-action", name: "Action", def: "none", device: "desktop", demo: false, values: [{ id: "none", name: "None" }, { id: "icon", name: "Icon" }] },
|
|
10
|
+
{ id: "row-open", name: "Open", def: "below", device: "desktop", demo: false, values: [{ id: "below", name: "Below" }, { id: "over", name: "Over" }] },
|
|
11
|
+
{ id: "row-long", name: "Long", def: "full", device: "desktop", demo: false, values: [{ id: "full", name: "Full" }, { id: "line", name: "Line" }] },
|
|
12
|
+
{ id: "row-link", name: "Link", def: "beside", device: "desktop", demo: false, values: [{ id: "beside", name: "Beside" }, { id: "words", name: "Words" }] },
|
|
10
13
|
];
|
|
11
14
|
export const FIELD_LOOKS = {
|
|
12
15
|
id: "field",
|
|
13
16
|
name: "Field",
|
|
14
17
|
options,
|
|
15
18
|
looks: [
|
|
16
|
-
{ id: "card", name: "Card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "on", "rows-height": "52", "rows-label": "104", "rows-lines": "words", "row-icon": "on", "row-box": "target", "row-action": "none" } },
|
|
17
|
-
{ id: "each", name: "A card each", device: "phone", picks: { "rows-cards": "each", "rows-edge": "on", "rows-height": "56", "rows-label": "104", "rows-lines": "none", "row-icon": "on", "row-box": "target", "row-action": "none" } },
|
|
18
|
-
{ id: "rows", name: "Rows in a card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "off", "rows-height": "48", "rows-label": "104", "rows-lines": "across", "row-icon": "on", "row-box": "target", "row-action": "none" } },
|
|
19
|
+
{ id: "card", name: "Card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "on", "rows-height": "52", "rows-label": "104", "rows-lines": "words", "row-icon": "on", "row-box": "target", "row-action": "none", "row-open": "below", "row-long": "full", "row-link": "beside" } },
|
|
20
|
+
{ id: "each", name: "A card each", device: "phone", picks: { "rows-cards": "each", "rows-edge": "on", "rows-height": "56", "rows-label": "104", "rows-lines": "none", "row-icon": "on", "row-box": "target", "row-action": "none", "row-open": "below", "row-long": "full", "row-link": "beside" } },
|
|
21
|
+
{ id: "rows", name: "Rows in a card", device: "phone", picks: { "rows-cards": "one", "rows-edge": "off", "rows-height": "48", "rows-label": "104", "rows-lines": "across", "row-icon": "on", "row-box": "target", "row-action": "none", "row-open": "below", "row-long": "full", "row-link": "beside" } },
|
|
22
|
+
{ id: "attio", name: "Attio", picks: { "rows-cards": "one", "rows-edge": "on", "rows-height": "52", "rows-label": "104", "rows-lines": "words", "row-icon": "off", "row-box": "box", "row-action": "icon", "row-open": "over", "row-long": "line", "row-link": "words" } },
|
|
19
23
|
],
|
|
20
24
|
};
|
|
21
25
|
const known = (o, v) => (v && o.values.some((x) => x.id === v) ? v : o.def);
|
|
@@ -50,6 +50,10 @@ export declare const FIELD_TOKENS: readonly [{
|
|
|
50
50
|
readonly name: "--vk-font-weight-normal";
|
|
51
51
|
readonly kind: "size";
|
|
52
52
|
readonly outright: "--font-weight-normal";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-hovered";
|
|
55
|
+
readonly kind: "colour";
|
|
56
|
+
readonly outright: "--surface-hovered";
|
|
53
57
|
}, {
|
|
54
58
|
readonly name: "--vk-line-height-base";
|
|
55
59
|
readonly kind: "size";
|
|
@@ -12,6 +12,7 @@ export const FIELD_TOKENS = [
|
|
|
12
12
|
{ name: "--vk-font-size-xs", kind: "size", outright: "--text-xs" },
|
|
13
13
|
{ name: "--vk-font-weight-medium", kind: "size", outright: "--font-weight-medium" },
|
|
14
14
|
{ name: "--vk-font-weight-normal", kind: "size", outright: "--font-weight-normal" },
|
|
15
|
+
{ name: "--vk-hovered", kind: "colour", outright: "--surface-hovered" },
|
|
15
16
|
{ name: "--vk-line-height-base", kind: "size", outright: "--text-base--line-height" },
|
|
16
17
|
{ name: "--vk-line-height-sm", kind: "size", outright: "--text-sm--line-height" },
|
|
17
18
|
{ name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
|
|
@@ -173,6 +173,39 @@ button.o-field-row { cursor: pointer; }
|
|
|
173
173
|
}
|
|
174
174
|
:where([data-field-row-action="icon"]) [data-field-row] :is([data-key="vk-field-row-target"], [data-key="vk-field-row-beside"], [data-key="vk-field-row-under"]):is(:hover, :focus-visible) [data-field-row-act] { visibility: visible; }
|
|
175
175
|
|
|
176
|
+
/* ── The Field's Link (row-link: words, looks.ts; data-field-row-link="words" on a frame round the rows): a record's field row outside
|
|
177
|
+
a card draws one link's words as the link itself, laid over the row's empty target as a rich text's are (data-field-row-words,
|
|
178
|
+
field-row/FieldRow.tsx), so the words open the link and the rest of the box edits. The pointer on the words is the box's too:
|
|
179
|
+
it keeps the quiet Button's hover ground (ViewKit's Button reads it; an app's own Button draws its own hover past the words) and
|
|
180
|
+
shows its ✎. ──────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
181
|
+
@media (hover: hover) {
|
|
182
|
+
[data-field-row-words]:hover > [data-key="vk-field-row-under"]:not(:disabled, [aria-disabled="true"]) { --button-ground: var(--vk-hovered); }
|
|
183
|
+
}
|
|
184
|
+
:where([data-field-row-action="icon"]) [data-field-row] [data-field-row-words]:hover [data-field-row-act] { visibility: visible; }
|
|
185
|
+
|
|
186
|
+
/* ── The Field's Long (row-long: line, looks.ts; data-field-row-long="line" on a frame round the rows): a record's field row outside a
|
|
187
|
+
card draws the words of a value it opens an editor on in one line at rest (data-field-row-text, field-row/FieldRow.tsx), so a
|
|
188
|
+
description never makes a record uneven. A long text or a rich text (long) runs on as one line, its paragraphs and their blocks
|
|
189
|
+
inline, a space after each, its Show more gone, and its end fades under a mask, never an "…": its editor shows the rest, on top of
|
|
190
|
+
the box (RowTextEditor). A text (line) keeps to its first line, ending in its "…", so its one-line box keeps the row's height as it
|
|
191
|
+
edits. As the box's, the geometry is !important: the display's classes are Tailwind's (the Field's Box, above, says why). ───── */
|
|
192
|
+
:where([data-field-row-long="line"]) [data-field-row] [data-field-row-text="long"] {
|
|
193
|
+
display: block !important; flex: 1 1 0%; overflow: hidden !important; white-space: nowrap !important; max-height: calc(var(--vk-spacing) * 5);
|
|
194
|
+
-webkit-mask-image: linear-gradient(to right, #000 calc(100% - var(--vk-spacing) * 12), transparent);
|
|
195
|
+
mask-image: linear-gradient(to right, #000 calc(100% - var(--vk-spacing) * 12), transparent);
|
|
196
|
+
}
|
|
197
|
+
/* What holds the words in the target (an app's Button wraps its children) may shrink to the box, so the line is cut at its end. */
|
|
198
|
+
:where([data-field-row-long="line"]) [data-field-row] :is([data-key="vk-field-row-target"], [data-key="vk-field-row-beside"], [data-field-row-anchor]):has([data-field-row-text="long"]) > * {
|
|
199
|
+
min-width: 0 !important;
|
|
200
|
+
}
|
|
201
|
+
:where([data-field-row-long="line"]) [data-field-row] [data-field-row-text="long"] * {
|
|
202
|
+
display: inline !important; white-space: nowrap !important; overflow: visible !important; max-height: none !important;
|
|
203
|
+
margin: 0 !important; padding: 0 !important; -webkit-line-clamp: none !important;
|
|
204
|
+
}
|
|
205
|
+
:where([data-field-row-long="line"]) [data-field-row] [data-field-row-text="long"] :is(p, li, h1, h2, h3, h4, h5, h6, blockquote, pre, tr)::after { content: " "; }
|
|
206
|
+
:where([data-field-row-long="line"]) [data-field-row] [data-field-row-text="long"] :is([data-slot="vk-show-more"], br, hr, img, .absolute) { display: none !important; }
|
|
207
|
+
:where([data-field-row-long="line"]) [data-field-row] [data-field-row-text="line"] > * { -webkit-line-clamp: 1 !important; }
|
|
208
|
+
|
|
176
209
|
/* A phone's first paint: server-rendered, Field rows' card stands twice, the phone's form and the computer's (`ScreenForms`,
|
|
177
210
|
internal/screen-forms.tsx), and this shows the screen's at ViewKit's own line, as the toolbar's stylesheet does: here for an app
|
|
178
211
|
that imports this card's stylesheet alone, on a page whose policy refuses an inline style. Kept on one line, as screenFormsCss writes it. */
|
|
@@ -16,9 +16,11 @@ export declare function BlockHead({ id, label, items, value, onPick, size, step
|
|
|
16
16
|
};
|
|
17
17
|
}): import("react/jsx-runtime").JSX.Element;
|
|
18
18
|
/** A group's ⋮ on a computer and in the narrow form: its Menu. */
|
|
19
|
-
export declare function GroupMenu({ entries, words }: {
|
|
19
|
+
export declare function GroupMenu({ entries, words, label, disabled }: {
|
|
20
20
|
entries: MenuEntry[];
|
|
21
21
|
words: FilterEditorWords;
|
|
22
|
+
label?: string;
|
|
23
|
+
disabled?: string;
|
|
22
24
|
}): import("react/jsx-runtime").JSX.Element;
|
|
23
25
|
/** A menu's rows as a step of the phone's one sheet: each action and pick done then the step closed; a tick stays; a row that can't be
|
|
24
26
|
* used says why under it, as a phone has no tooltip. Its rows are the sheet's card rows, as Customize's and the group editor's are:
|
|
@@ -9,9 +9,10 @@ export function BlockHead({ id, label, items, value, onPick, size, step }) {
|
|
|
9
9
|
return (_jsxs("div", { className: "o-filter-editor-block-head", "data-slot": "vk-filter-group-head", "data-block-head": id, children: [_jsxs("span", { className: "o-filter-editor-relation", children: [label, ":"] }), _jsx(Select, { size: size, listWidth: "rows", "aria-label": label, "data-slot": "vk-filter-quantifier", items: items, value: value, ...(step ?? {}), onValueChange: (v) => { if (typeof v === "string" && v !== value)
|
|
10
10
|
onPick(v); } })] }));
|
|
11
11
|
}
|
|
12
|
-
export function GroupMenu({ entries, words }) {
|
|
13
|
-
const { Button, Menu } = usePanelControls();
|
|
14
|
-
|
|
12
|
+
export function GroupMenu({ entries, words, label = words.groupActions, disabled }) {
|
|
13
|
+
const { Button, Menu, Tooltip } = usePanelControls();
|
|
14
|
+
const 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": label, icon: glyph(DOTS_UP), ...(disabled && { disabled: true, focusableWhenDisabled: true }) });
|
|
15
|
+
return disabled ? _jsx(Tooltip, { label: disabled, reason: true, side: "top", children: trigger }) : _jsx(Menu, { label: words.groupActions, align: "end", entries: entries, trigger: trigger });
|
|
15
16
|
}
|
|
16
17
|
export function MenuStep({ label, entries, onClose, words }) {
|
|
17
18
|
const closing = (e) => {
|
|
@@ -14,19 +14,27 @@ export interface FilterOwn {
|
|
|
14
14
|
value: string | null;
|
|
15
15
|
body: React.ReactNode | null;
|
|
16
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
|
|
17
|
+
/** The filter editor's own menus' context (VK-1063): a rule's or a group's, by the editor's own ids; a rule's end and a foot (VK-1065). Its map hands the app the
|
|
18
18
|
* ViewKit filter's public terms instead (`ViewsFilterEditorItemsContext`). */
|
|
19
19
|
export type FilterEditorItemsContext = ({
|
|
20
20
|
menu: "rule" | "aside";
|
|
21
21
|
rule: string;
|
|
22
|
+
} | {
|
|
23
|
+
menu: "row";
|
|
24
|
+
rule: string;
|
|
25
|
+
aside?: true;
|
|
22
26
|
} | {
|
|
23
27
|
menu: "group";
|
|
24
28
|
group: string;
|
|
29
|
+
} | {
|
|
30
|
+
menu: "foot";
|
|
31
|
+
group: string;
|
|
25
32
|
}) & {
|
|
26
33
|
form: "computer" | "phone";
|
|
27
34
|
};
|
|
28
35
|
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
|
|
36
|
+
/** Its menus as data (VK-1063): a rule's ⋮, a set-aside rule's and a group's actions, handed their default items; and (VK-1065) a
|
|
37
|
+
* rule's end (`row`) and each foot (`foot`, by its group). */
|
|
30
38
|
items?: (items: ViewsMenuItem[], ctx: FilterEditorItemsContext) => ViewsMenuItem[];
|
|
31
39
|
/** What it filters, as its shell names it ("Filter"): the Sheet's title on a phone, and the rules' name to a screen reader. */
|
|
32
40
|
label: string;
|
|
@@ -56,10 +64,15 @@ export interface FilterEditorProps {
|
|
|
56
64
|
/** ViewKit's own words and value body for a rule the kit has no box for (set aside, a way only ViewKit words, a field the kit
|
|
57
65
|
* doesn't list, a choice with no values); null where the kit draws the rule itself. */
|
|
58
66
|
own?: (rule: FilterRule) => FilterOwn | null;
|
|
67
|
+
/** Why a whole rule filters nothing, in words, drawn under its boxes (amounts in several currencies); null for most. */
|
|
68
|
+
note?: (rule: FilterRule) => string | null;
|
|
59
69
|
/** Whether the filter itself may exclude its matches (an advanced filter's own group): its foot gets a group's ⋮ too (VK-827). */
|
|
60
70
|
excludable?: boolean;
|
|
61
71
|
/** Its words; English unless handed. */
|
|
62
72
|
words?: Partial<FilterEditorWords>;
|
|
73
|
+
/** What its computer form shows with nothing filtered (VK-1091): the fields, a pick adding its rule (`fields`, the default), or
|
|
74
|
+
* that nothing is filtered yet, with Add filter (`editor`), as its stacked forms do. */
|
|
75
|
+
empty?: "fields" | "editor";
|
|
63
76
|
}
|
|
64
77
|
export interface FilterEditorParts {
|
|
65
78
|
body: React.ReactNode;
|
|
@@ -8,11 +8,12 @@ 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
10
|
import { shapeMenu } from "../internal/menu-items.js";
|
|
11
|
+
import { shapeActions } from "../internal/row-actions.js";
|
|
11
12
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
12
13
|
import { FieldsFrame } from "../picker/fields-frame.js";
|
|
13
14
|
import { itemLabel } from "../picker/rows.js";
|
|
14
15
|
import { HOW, wayOf } from "./how.js";
|
|
15
|
-
import { PairValue, WHOLE } from "./parts.js";
|
|
16
|
+
import { DurationValue, PairValue, WHOLE } from "./parts.js";
|
|
16
17
|
import { BlockHead, GroupMenu, MenuStep } from "./block.js";
|
|
17
18
|
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
19
|
import { filterWords } from "./words.js";
|
|
@@ -37,6 +38,7 @@ function OwnValue({ name, own, open, onOpenChange, phone, size, placeholder }) {
|
|
|
37
38
|
} } }), !phone && takes && (_jsx(Popover, { open: open, onOpenChange: (o) => onOpenChange(o), anchor: box, className: "w-fit", "aria-label": name, children: own.body }))] }));
|
|
38
39
|
}
|
|
39
40
|
const RULE_KEYS = new Set(["convert", "relation", "delete", "why", "put-back"]), GROUP_KEYS = new Set(["exclude"]);
|
|
41
|
+
const ROW_KEYS = new Set(["more"]), FOOT_KEYS = new Set(["add", "clear", "delete", "more"]);
|
|
40
42
|
export function useFilterEditor(props) {
|
|
41
43
|
const { label, fields, filter, onFilterChange, onDone, standing = false, ids, levels, items } = props;
|
|
42
44
|
const deepest = levels ?? FILTER_DEPTH;
|
|
@@ -102,10 +104,10 @@ export function useFilterEditor(props) {
|
|
|
102
104
|
root?.focus({ preventScroll: true });
|
|
103
105
|
const next = removeRule(now.current, id);
|
|
104
106
|
change(next);
|
|
105
|
-
if (way === "computer" && !next.rules.length)
|
|
107
|
+
if (way === "computer" && !next.rules.length && props.empty !== "editor")
|
|
106
108
|
onDone?.();
|
|
107
109
|
};
|
|
108
|
-
const clear = () => { change(clearAll(now.current)); if (way === "computer")
|
|
110
|
+
const clear = () => { change(clearAll(now.current)); if (way === "computer" && props.empty !== "editor")
|
|
109
111
|
onDone?.(); };
|
|
110
112
|
const set = (id) => (v) => change(changeRule(now.current, id, { value: v }, fields));
|
|
111
113
|
const decide = useDecide(now, change, onDone, { close: w.close, save: w.save }), placed = decide.place;
|
|
@@ -113,13 +115,14 @@ export function useFilterEditor(props) {
|
|
|
113
115
|
const room = useStandingRoom(root, "[data-filter-shown]", phone, [standing, props.at]);
|
|
114
116
|
const [adding, setAdding] = React.useState(null);
|
|
115
117
|
const gone = filter.relation?.gone;
|
|
116
|
-
const addButton = (group, kind, size) => {
|
|
117
|
-
const
|
|
118
|
+
const addButton = (group, kind, size, shown) => {
|
|
119
|
+
const why = shown?.disabled ?? gone;
|
|
120
|
+
const add = (_jsx(Button, { kind: kind, size: size, icon: shown?.icon ?? glyph(PLUS), className: "o-filter-editor-add", "data-slot": "vk-filter-add", "data-add-to": group, "aria-haspopup": "dialog", "aria-disabled": why ? true : undefined, "aria-expanded": phone ? step?.list === "add" && step.group === group : adding?.group === group, onClick: (e) => { if (why)
|
|
118
121
|
return; const at = e.currentTarget; if (phone)
|
|
119
122
|
setStep({ list: "add", group });
|
|
120
123
|
else
|
|
121
|
-
setAdding((a) => (a?.group === group ? null : { group, at })); }, children: w.add }));
|
|
122
|
-
return
|
|
124
|
+
setAdding((a) => (a?.group === group ? null : { group, at })); }, children: shown?.label ?? w.add }));
|
|
125
|
+
return why ? _jsx(Tooltip, { label: why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: add }) }) : add;
|
|
123
126
|
};
|
|
124
127
|
const stepRule = step && "rule" in step ? rulesOf(filter).find((x) => x.id === step.rule) : undefined;
|
|
125
128
|
const stepField = stepRule ? fieldOf(fields, stepRule.field) : undefined;
|
|
@@ -175,7 +178,18 @@ export function useFilterEditor(props) {
|
|
|
175
178
|
: stepDate && stepRule ? _jsx(DateStep, { name: labelOf(stepRule), value: typeof stepRule.value === "string" ? stepRule.value : null, onValue: set(stepRule.id), onDone: back })
|
|
176
179
|
: stepList.body;
|
|
177
180
|
const size = phone ? "lg" : "sm";
|
|
178
|
-
const moreStep = (id, label, slot) => (_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-filter-editor-more", "data-slot": slot, "data-more-of": id, "aria-label": label, "aria-haspopup": "dialog", icon: glyph(DOTS), onClick: () => setStep({ list: "menu", item: id }) }));
|
|
181
|
+
const moreStep = (id, label, slot, disabled) => (_jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-filter-editor-more", "data-slot": slot, "data-more-of": id, "aria-label": label, "aria-haspopup": "dialog", icon: glyph(DOTS), ...(disabled ? { disabled, focusableWhenDisabled: true } : { onClick: () => setStep({ list: "menu", item: id }) }) }));
|
|
182
|
+
const ctxForm = phone ? "phone" : "computer";
|
|
183
|
+
const rowLook = phone ? { slot: "vk-filter-row-action", size: "40x44", look: DOTS_LOOK } : { slot: "vk-filter-row-action", size: "xs", look: MORE_LOOK };
|
|
184
|
+
const footLook = { slot: "vk-filter-foot-action", size: phone ? "44" : "sm" };
|
|
185
|
+
const greyed = (why, node) => _jsx(Tooltip, { label: why, reason: true, side: "top", children: node });
|
|
186
|
+
const footOf = (group, own) => shapeActions(own.filter((o) => !!o), items, { menu: "foot", group, form: ctxForm }, FOOT_KEYS, footLook);
|
|
187
|
+
const addOwn = (group, kind, size) => ({ key: "add", label: w.add, icon: glyph(PLUS), ...(gone && { disabled: gone }), draw: (shown) => addButton(group, kind, size, shown) });
|
|
188
|
+
const quietOwn = (key, label, className, slot, size, onClick) => ({ key, label, draw: (shown) => {
|
|
189
|
+
const b = _jsx(Button, { kind: "quiet", size: size, className: className, "data-slot": slot, ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }), onClick: onClick, children: shown?.label ?? label });
|
|
190
|
+
return shown?.disabled ? greyed(shown.disabled, b) : b;
|
|
191
|
+
} });
|
|
192
|
+
const moreOwn = (g) => ({ key: "more", label: w.groupActions, icon: glyph(phone ? DOTS : DOTS_UP), draw: (shown) => groupMore(g, shown) });
|
|
179
193
|
const stepOf = (s) => (phone ? { open: false, onOpenChange: (o) => { if (o)
|
|
180
194
|
setStep(s); } } : {});
|
|
181
195
|
const valueBox = (r, field, takes, own) => {
|
|
@@ -193,6 +207,8 @@ export function useFilterEditor(props) {
|
|
|
193
207
|
if (field.type === "date")
|
|
194
208
|
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)
|
|
195
209
|
setStep({ list: "value", rule: r.id }); } : onOpenChange, phone: phone, size: size, placeholder: w.chooseDate });
|
|
210
|
+
if (field.duration)
|
|
211
|
+
return _jsx(DurationValue, { size: size, "aria-label": name, placeholder: w.typeNumber, duration: field.duration, value: typeof r.value === "number" ? r.value : null, onValue: (v) => set(r.id)(v) });
|
|
196
212
|
if (field.type === "number" || field.type === "range")
|
|
197
213
|
return _jsx(NumberBox, { size: size, steppers: false, "aria-label": name, placeholder: w.typeNumber, value: typeof r.value === "number" ? r.value : null, format: field.integer ? WHOLE : undefined, onValueChange: (v) => set(r.id)(v ?? null) });
|
|
198
214
|
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) });
|
|
@@ -220,33 +236,50 @@ export function useFilterEditor(props) {
|
|
|
220
236
|
}
|
|
221
237
|
const ruleRow = (r) => {
|
|
222
238
|
const field = fieldOf(fields, r.field), own = ownOf(r), aside = r.aside, name = labelOf(r);
|
|
239
|
+
const note = props.note?.(r) ?? null;
|
|
223
240
|
const kitWay = field ? wayOf(field.type, r.how) : undefined, takes = kitWay ? kitWay.takes : own && !aside && own.body != null ? "one" : undefined;
|
|
224
241
|
const ways = field ? waysOf(field) : [];
|
|
225
242
|
const entries = ruleEntries(r), fieldItems = asSelect(fieldsIn(filter, r.id, fields, deepest));
|
|
226
243
|
const why = (node) => (aside ? _jsx(Tooltip, { label: aside.why, reason: true, side: "bottom", children: _jsx("span", { className: "o-filter-editor-why", children: node }) }) : node);
|
|
227
244
|
const wayPlaceholder = own && !kitWay ? own.way : w.way(r.how);
|
|
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))
|
|
245
|
+
return (_jsxs("div", { className: "o-filter-editor-rule", "data-slot": "vk-filter-rule", "data-key": field?.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))
|
|
229
246
|
pointAt(r.id, v); } })) }), _jsx("div", { className: "o-filter-editor-how", children: why(_jsx(Select, { size: size, listWidth: "rows", "aria-label": w.how, "data-slot": "vk-filter-how", items: ways, value: field && kitWay && !aside ? r.how : null, placeholder: wayPlaceholder, disabled: !!aside || (!field && !!own), ...(field || !own ? stepOf({ list: "how", rule: r.id }) : {}), onValueChange: (v) => { if (typeof v === "string" && v !== r.how)
|
|
230
|
-
change(changeRule(now.current, r.id, { how: v }, fields)); } })) }), aside && own?.value != null && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": "own", children: why(_jsx(Input, { readOnly: true, disabled: true, size: size, "aria-label": name, value: own.value, className: "o-filter-editor-own-box" })) })), !aside && takes && takes !== "none" && (field || own) && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": own ? "own" : field?.choices ? "choice" : takes === "two" ? "pair" : field?.type === "date" ? "date" : "typed", children: valueBox(r, field ?? { value: r.field, label: name, type: "text" }, takes, own) }))] }),
|
|
231
|
-
|
|
247
|
+
change(changeRule(now.current, r.id, { how: v }, fields)); } })) }), aside && own?.value != null && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": "own", children: why(_jsx(Input, { readOnly: true, disabled: true, size: size, "aria-label": name, value: own.value, className: "o-filter-editor-own-box" })) })), !aside && takes && takes !== "none" && (field || own) && (_jsx("div", { className: "o-filter-editor-value", "data-slot": "vk-filter-value", "data-value-of": r.id, "data-value-box": own ? "own" : field?.choices ? "choice" : takes === "two" ? "pair" : field?.type === "date" ? "date" : "typed", children: valueBox(r, field ?? { value: r.field, label: name, type: "text" }, takes, own) })), note && !aside && _jsx("p", { className: "o-filter-editor-note", role: "note", "data-slot": "vk-filter-refused", children: note })] }), shapeActions([{ key: "more", label: w.ruleOf(name), icon: glyph(phone ? DOTS : DOTS_UP), draw: (shown) => {
|
|
248
|
+
const label = shown?.label ?? w.ruleOf(name);
|
|
249
|
+
if (phone)
|
|
250
|
+
return shown?.disabled ? greyed(shown.disabled, moreStep(r.id, label, "vk-filter-rule-more", true)) : moreStep(r.id, label, "vk-filter-rule-more");
|
|
251
|
+
const trigger = _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-filter-editor-more", "data-slot": "vk-filter-rule-more", "aria-label": label, icon: glyph(DOTS_UP), ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }) });
|
|
252
|
+
return shown?.disabled ? greyed(shown.disabled, trigger) : _jsx(Menu, { label: w.ruleOf(name), align: "end", entries: entries, trigger: trigger });
|
|
253
|
+
} }], items, { menu: "row", rule: r.id, ...(r.aside && { aside: true }), form: ctxForm }, ROW_KEYS, rowLook)] }));
|
|
232
254
|
};
|
|
233
255
|
const lead = (g, i) => i === 0 ? _jsx("span", { className: "o-filter-editor-where", "data-slot": "vk-filter-where", children: w.where })
|
|
234
256
|
: i === 1 && !g.exclude ? _jsx(Button, { kind: "outline", size: "sm", className: "o-filter-editor-join", "data-slot": "vk-filter-join", iconEnd: glyph(TURNS), onClick: () => change(setJoin(now.current, g.id, g.join === "and" ? "or" : "and")), children: w.join(g.join) })
|
|
235
257
|
: _jsx("span", { className: "o-filter-editor-joined", "data-slot": "vk-filter-joined", children: w.join(g.join) });
|
|
236
258
|
const blockHead = (g) => g.relation && (_jsx(BlockHead, { id: g.id, label: blockLabel(g), items: quantifiersOf(g), value: g.relation.quantifier, size: size, onPick: (q) => change(setQuantifier(now.current, g.id, q)), ...(phone ? { step: { open: false, onOpenChange: (o) => { if (o)
|
|
237
259
|
setStep({ list: "quantifier", group: g.id }); } } } : {}) }));
|
|
238
|
-
const groupMore = (g
|
|
260
|
+
const groupMore = (g, shown) => {
|
|
261
|
+
const label = shown?.label ?? w.groupActions;
|
|
262
|
+
if (phone)
|
|
263
|
+
return shown?.disabled ? greyed(shown.disabled, moreStep(g.id, label, "vk-filter-group-more", true)) : moreStep(g.id, label, "vk-filter-group-more");
|
|
264
|
+
return _jsx(GroupMenu, { entries: groupEntries(g), words: w, ...(shown && { label }), ...(shown?.disabled && { disabled: shown.disabled }) });
|
|
265
|
+
};
|
|
239
266
|
const top = _jsxs(_Fragment, { children: [filter.exclude && _jsx("p", { className: "o-filter-editor-excluded", "data-slot": "vk-filter-excluded", children: w.excluded }), blockHead(filter)] });
|
|
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),
|
|
267
|
+
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), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(item.id, [addOwn(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"),
|
|
268
|
+
quietOwn("delete", w.deleteRule, "o-filter-editor-delete", "vk-filter-delete", phone ? "44" : "sm", () => remove(item.id))]) })] })) : 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), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(item.id, [addOwn(item.id, stacked ? "quiet" : "outline", phone ? "44" : "sm"),
|
|
269
|
+
quietOwn("delete", w.deleteGroup, "o-filter-editor-delete", "vk-filter-delete", phone ? "44" : "sm", () => remove(item.id)), moreOwn(item)]) })] })) : ruleRow(item)] }, item.id))) }));
|
|
241
270
|
const addingPopover = !standing && (_jsx(Popover, { open: !!adding, onOpenChange: (o) => { if (!o)
|
|
242
271
|
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 }) }) }));
|
|
243
272
|
if (stacked) {
|
|
244
273
|
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)
|
|
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 })] }),
|
|
274
|
+
: _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 })] }), _jsx("div", { className: "o-filter-editor-acts", "data-slot": "vk-filter-foot", children: footOf(filter.id, [addOwn(filter.id, filter.rules.length ? "outline" : "primary", phone ? "44" : "sm"),
|
|
275
|
+
props.clearAll !== false && filter.rules.length > 0 && quietOwn("clear", w.clearAll, "o-filter-editor-clear", "vk-filter-clear", phone ? "44" : "sm", clear),
|
|
276
|
+
props.excludable && moreOwn(filter)]) }), !phone && addingPopover] }) }));
|
|
246
277
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
247
278
|
}
|
|
248
|
-
const
|
|
249
|
-
const
|
|
279
|
+
const nothing = !filter.rules.length && !filter.relation;
|
|
280
|
+
const fieldsAlone = nothing && props.empty !== "editor";
|
|
281
|
+
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: nothing && !fieldsAlone ? _jsxs(_Fragment, { children: [top, _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 })] }), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(filter.id, [addOwn(filter.id, "primary", "sm")]) }), addingPopover] }) : !fieldsAlone ? _jsxs(_Fragment, { children: [top, level(filter, 0), _jsx("div", { className: "o-filter-editor-foot", "data-slot": "vk-filter-foot", children: footOf(filter.id, [addOwn(filter.id, "outline", "sm"), props.clearAll !== false && quietOwn("clear", w.clearAllFilters, "o-filter-editor-clear", "vk-filter-clear", "sm", clear),
|
|
282
|
+
props.excludable && moreOwn(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 }) })) }));
|
|
250
283
|
return { body, head: {} };
|
|
251
284
|
}
|
|
252
285
|
export const useFilterEditorParts = useFilterEditor;
|
|
@@ -10,12 +10,22 @@ export interface FilterWay {
|
|
|
10
10
|
}
|
|
11
11
|
/** A field a list filters by: the Picker's item, with its type; a choice's values (a stage's, a person's, a record's), each a
|
|
12
12
|
* Picker's item with its mark; a related record's fields one level in (a deal's Company), each typed too; a number that
|
|
13
|
-
* holds whole numbers only (`integer`), whose box rounds what is typed
|
|
13
|
+
* holds whole numbers only (`integer`), whose box rounds what is typed; and its public name (`key`), the `data-key` a rule on
|
|
14
|
+
* it draws, where its `value` is no name a stylesheet can hold (absent, its `value`). */
|
|
14
15
|
export interface FilterField extends PickerItem {
|
|
15
16
|
type: FieldType;
|
|
16
17
|
choices?: PickerItem[];
|
|
17
18
|
level?: FilterField[];
|
|
18
19
|
integer?: boolean;
|
|
20
|
+
key?: string;
|
|
21
|
+
/** A number kept as a duration: how its box writes a stored bound (`1m 30s`) and reads what is typed back as one, null for
|
|
22
|
+
* what reads as none (VK-1121). Absent, the Number field. */
|
|
23
|
+
duration?: DurationBox;
|
|
24
|
+
}
|
|
25
|
+
/** How a duration's box writes a stored bound and reads one typed. */
|
|
26
|
+
export interface DurationBox {
|
|
27
|
+
write: (value: number) => string;
|
|
28
|
+
read: (typed: string) => number | null;
|
|
19
29
|
}
|
|
20
30
|
/** Each type's ways, in the order they are offered; the first is a new rule's. */
|
|
21
31
|
export declare const HOW: Record<FieldType, FilterWay[]>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import type { FieldConventions } from "viewkitjs/fields";
|
|
2
3
|
import type { FilterRule as ViewKitRule } from "viewkitjs/fields/query";
|
|
3
4
|
import { type ViewsMessageResolver } from "../../contract.js";
|
|
4
5
|
import type { ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsMenuItem } from "../../provider/components.js";
|
|
@@ -14,18 +15,19 @@ type AppIcon = React.ComponentType<{
|
|
|
14
15
|
/** The filter editor's words in the app's messages. */
|
|
15
16
|
export declare function filterWordsOf(say: ViewsMessageResolver): FilterEditorWords;
|
|
16
17
|
/** ViewKit's filter body's props as the filter editor's parts, the level turned both ways. */
|
|
17
|
-
export declare function useMapFilterBody(p: ViewsFilterBodyProps, words: FilterEditorWords, say: ViewsMessageResolver, AppIcon: AppIcon | undefined, wayWord: (operator: string) => string): {
|
|
18
|
+
export declare function useMapFilterBody(p: ViewsFilterBodyProps, words: FilterEditorWords, say: ViewsMessageResolver, AppIcon: AppIcon | undefined, wayWord: (operator: string) => string, cv?: FieldConventions): {
|
|
18
19
|
items?: ((is: ViewsMenuItem[], ctx: FilterEditorItemsContext) => ViewsMenuItem[]) | undefined;
|
|
19
20
|
kit: KitFields;
|
|
20
21
|
filter: KitGroup;
|
|
21
22
|
change: (next: KitGroup) => void;
|
|
22
23
|
own: (rule: KitRule) => FilterOwn | null;
|
|
24
|
+
note: (rule: KitRule) => string | null;
|
|
23
25
|
};
|
|
24
26
|
/** ViewKit's filter body, its controls the app's where the provider's `panelControls` names them (VK-1013). */
|
|
25
27
|
export declare function MapFilterBody(props: ViewsFilterBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
26
28
|
/** The rule as a one-rule kit filter, with the kit's fields for it; null where the kit draws no rule of it, or where a choice has no
|
|
27
29
|
* values to offer, which ViewKit's own body then draws. */
|
|
28
|
-
export declare function partOf(rule: ViewKitRule, field: ViewsFilterPartBodyProps["field"], choices: ChoicesOf): {
|
|
30
|
+
export declare function partOf(rule: ViewKitRule, field: ViewsFilterPartBodyProps["field"], choices: ChoicesOf, cv?: FieldConventions): {
|
|
29
31
|
kit: KitFields;
|
|
30
32
|
filter: KitGroup;
|
|
31
33
|
} | null;
|
|
@@ -80,10 +80,10 @@ function listed(fields, rule, relation) {
|
|
|
80
80
|
const at = relation !== undefined ? fields.find((f) => f.far && f.fieldKey === relation)?.far ?? [] : fields.filter((f) => !f.far);
|
|
81
81
|
return at.some((f) => f.disabled === undefined && f.fieldKey === rule.fieldKey && (f.part ?? undefined) === (rule.part ?? undefined));
|
|
82
82
|
}
|
|
83
|
-
export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
83
|
+
export function useMapFilterBody(p, words, say, AppIcon, wayWord, cv) {
|
|
84
84
|
const within = p.relation?.fieldKey;
|
|
85
85
|
const choices = React.useMemo(() => choicesOf(p.fields, AppIcon), [p.fields, AppIcon]);
|
|
86
|
-
const kit = React.useMemo(() => kitFieldsOf(p.fields, choices, within), [p.fields, choices, within]);
|
|
86
|
+
const kit = React.useMemo(() => kitFieldsOf(p.fields, choices, within, cv), [p.fields, choices, within, cv]);
|
|
87
87
|
const [, redraw] = React.useReducer((n) => n + 1, 0);
|
|
88
88
|
const own = React.useRef(new Map()).current;
|
|
89
89
|
const asideWords = (rule, relation) => {
|
|
@@ -139,17 +139,27 @@ export function useMapFilterBody(p, words, say, AppIcon, wayWord) {
|
|
|
139
139
|
const publicOf = (ctx) => {
|
|
140
140
|
const paths = new Map();
|
|
141
141
|
viewKitFilterOf(read.filter, kit, read.kept, read.raw, paths);
|
|
142
|
-
if (ctx.menu === "group")
|
|
143
|
-
return { menu:
|
|
142
|
+
if (ctx.menu === "group" || ctx.menu === "foot")
|
|
143
|
+
return { menu: ctx.menu, path: paths.get(ctx.group) ?? [], form: ctx.form };
|
|
144
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
145
|
const inner = node && (isRelation(node.node) ? node.node.where.items[0] : node.node);
|
|
146
146
|
const field = place?.fieldKey ?? inner?.fieldKey ?? (node && isRelation(node.node) ? node.node.fieldKey : "");
|
|
147
147
|
const part = place ? place.part : inner?.part;
|
|
148
148
|
const relation = place ? place.relation ?? within : node && isRelation(node.node) ? node.node.fieldKey : node?.relation ?? within;
|
|
149
|
-
|
|
149
|
+
const named = { field, ...(part != null && { part }), ...(relation !== undefined && relation !== field && { relation }), path: paths.get(ctx.rule) ?? [], form: ctx.form };
|
|
150
|
+
return ctx.menu === "row" ? { menu: "row", ...named, ...(ctx.aside && { aside: true }) } : { menu: ctx.menu, ...named };
|
|
150
151
|
};
|
|
151
152
|
const items = p.items && ((is, ctx) => p.items(is, publicOf(ctx)));
|
|
152
|
-
|
|
153
|
+
const note = (rule) => {
|
|
154
|
+
if (rule.aside || !p.ruleWords)
|
|
155
|
+
return null;
|
|
156
|
+
const as = viewKitFilterOf({ id: "one", join: "and", rules: [rule] }, kit, {}).items[0];
|
|
157
|
+
if (!as)
|
|
158
|
+
return null;
|
|
159
|
+
const inner = isRelation(as) ? as.where.items[0] : as;
|
|
160
|
+
return (inner && p.ruleWords(inner, isRelation(as) ? as.fieldKey : within).refused) ?? null;
|
|
161
|
+
};
|
|
162
|
+
return { kit, filter: read.filter, change: (next) => write(next), own: ownOf, note, ...(items && { items }) };
|
|
153
163
|
}
|
|
154
164
|
export function MapFilterBody(props) {
|
|
155
165
|
return _jsx(PanelControlsFromViews, { children: _jsx(FilterBodyInner, { ...props }) });
|
|
@@ -159,9 +169,9 @@ function FilterBodyInner(props) {
|
|
|
159
169
|
const say = views?.messages ?? resolveViewsMessage;
|
|
160
170
|
const words = React.useMemo(() => filterWordsOf(say), [say]);
|
|
161
171
|
const wayWord = (operator) => (views?.conventions ? views.conventions.messages({ key: "filter.operator", values: { operator } }) : operator.replace(/_/g, " "));
|
|
162
|
-
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord);
|
|
172
|
+
const map = useMapFilterBody(props, words, say, views?.components.AppIcon, wayWord, views?.conventions);
|
|
163
173
|
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,
|
|
164
|
-
onFilterChange: map.change, own: map.own, words, excludable: props.excludable });
|
|
174
|
+
onFilterChange: map.change, own: map.own, note: map.note, words, excludable: props.excludable, ...(props.empty && { empty: props.empty }) });
|
|
165
175
|
useToldStep(parts, props.onStepChange);
|
|
166
176
|
const { actions } = props;
|
|
167
177
|
if (!actions)
|
|
@@ -171,8 +181,8 @@ function FilterBodyInner(props) {
|
|
|
171
181
|
? _jsx(BodyHead, { title: parts.title, left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": words.back, className: "o-sheet-back", icon: glyph(BACK), onClick: parts.head.onBack }), right: done || _jsx("span", {}) })
|
|
172
182
|
: _jsx(BodyHead, { title: props.label, left: _jsx(PanelHeadButton, { "data-slot": "vk-editor-close", "aria-label": actions.close.label, icon: glyph(X), onClick: actions.close.onPress }), right: done || _jsx("span", {}) }), parts.body] }));
|
|
173
183
|
}
|
|
174
|
-
export function partOf(rule, field, choices) {
|
|
175
|
-
const kit = kitFieldsOf([field], choices), [f] = kit.fields, { filter } = kitFilterOf({ op: "and", items: [rule] }, kit);
|
|
184
|
+
export function partOf(rule, field, choices, cv) {
|
|
185
|
+
const kit = kitFieldsOf([field], choices, undefined, cv), [f] = kit.fields, { filter } = kitFilterOf({ op: "and", items: [rule] }, kit);
|
|
176
186
|
if (!f || (CHOICE.has(f.type) && !f.choices))
|
|
177
187
|
return null;
|
|
178
188
|
return filter.rules.length === 1 ? { kit, filter } : null;
|
|
@@ -192,7 +202,7 @@ function FilterPartBodyInner(props) {
|
|
|
192
202
|
const words = React.useMemo(() => filterWordsOf(say), [say]);
|
|
193
203
|
const { part, label, rule, field, ways, own, form, onRuleChange, onDone } = props;
|
|
194
204
|
const choices = React.useMemo(() => choicesOf([field], views?.components.AppIcon), [field, views?.components.AppIcon]);
|
|
195
|
-
const drawn = partOf(rule, field, choices);
|
|
205
|
+
const drawn = partOf(rule, field, choices, views?.conventions);
|
|
196
206
|
const pickerWords = words.picker ? { words: words.picker } : {};
|
|
197
207
|
const theirs = !drawn || isOwnWay(rulesOf(drawn.filter)[0]?.how ?? "");
|
|
198
208
|
if (theirs && part === "value")
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldType } from "viewkitjs/fields";
|
|
1
|
+
import type { FieldConventions, FieldType } from "viewkitjs/fields";
|
|
2
2
|
import type { FilterGroup, FilterNode, FilterRelationRule, FilterRule } from "viewkitjs/fields/query";
|
|
3
3
|
import type { ViewsFilterBodyField } from "../../provider/components.js";
|
|
4
4
|
import { type PickerItem } from "../picker/rows.js";
|
|
@@ -57,15 +57,17 @@ export type KitFields = {
|
|
|
57
57
|
export type ChoicesOf = (fieldKey: string, relation?: string, part?: string) => PickerItem[] | undefined;
|
|
58
58
|
/** The heading the related records stand under, ViewKit's own English (views.panels.related-records). */
|
|
59
59
|
export declare const RELATED = "Related records";
|
|
60
|
-
/** A related record's field as one value of the kit's: the relation's row and the far field's key; and back.
|
|
60
|
+
/** A related record's field as one value of the kit's: the relation's row and the far field's key; and back. Its public name, the
|
|
61
|
+
* `data-key` its rule draws, joins the two with a dot (`company.industry`), as the kit's own fields name a level (VK-1108). */
|
|
61
62
|
export declare const pathOf: (relationKey: string, farKey: string) => string;
|
|
62
63
|
export declare const pathParts: (value: string) => [string, string?];
|
|
63
64
|
/** The fields ViewKit hands as the kit's filter editor takes them: each of a type it draws, a part by its own type, a choice's values
|
|
64
|
-
* from `choices` (a choice with none stays a field, its value ViewKit's to draw), a yes/no's Checked and Unchecked
|
|
65
|
+
* from `choices` (a choice with none stays a field, its value ViewKit's to draw), a yes/no's Checked and Unchecked, a duration its
|
|
66
|
+
* box read and written as one (VK-1121, by the conventions `cv`); then each
|
|
65
67
|
* relation under Related records, its far fields one level in. A place's part the kit draws no type for is no field of the kit's,
|
|
66
68
|
* but its place is known, so a rule on it is ViewKit's to word. Open on a relation's where (`relation`, its field key), that
|
|
67
69
|
* relation's far fields alone, as plain fields. */
|
|
68
|
-
export declare function kitFieldsOf(fields: readonly ViewsFilterBodyField[], choices: ChoicesOf, relation?: string): KitFields;
|
|
70
|
+
export declare function kitFieldsOf(fields: readonly ViewsFilterBodyField[], choices: ChoicesOf, relation?: string, cv?: FieldConventions): KitFields;
|
|
69
71
|
/** The field a rule the kit has no type for names: ViewKit's to word (`own:<fieldKey>~<part>`). */
|
|
70
72
|
export declare const OWN_FIELD = "own:";
|
|
71
73
|
/** The way of a relation rule drawn as one row (set aside, or on a relation the fields don't list). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { findItem } from "../picker/rows.js";
|
|
2
|
+
import { durationBound, durationDraft } from "../../filters/duration-bound.js";
|
|
2
3
|
import { CHECKED } from "./how.js";
|
|
3
4
|
import { isOwnWay, isPair, OWN_WAY, rulesOf } from "./rules.js";
|
|
4
5
|
const TYPES = {
|
|
@@ -26,9 +27,10 @@ export const pathParts = (value) => {
|
|
|
26
27
|
return at < 0 ? [value] : [value.slice(0, at), value.slice(at + 1)];
|
|
27
28
|
};
|
|
28
29
|
const placeOf = (a) => [a.relation ?? "", a.fieldKey, a.part ?? ""].join(SEP);
|
|
29
|
-
|
|
30
|
+
const durationBox = (unit, cv) => ({ write: (value) => durationDraft(value, unit), read: (typed) => durationBound(typed, unit, cv) });
|
|
31
|
+
export function kitFieldsOf(fields, choices, relation, cv) {
|
|
30
32
|
const at = new Map();
|
|
31
|
-
const field = (f, value, place, from) => {
|
|
33
|
+
const field = (f, value, place, from, key) => {
|
|
32
34
|
const type = kitPartTypeOf(f.type, f.part);
|
|
33
35
|
if (f.disabled !== undefined)
|
|
34
36
|
return [{ value, label: f.label, type: type ?? "text", disabled: true, line: f.disabled }];
|
|
@@ -39,7 +41,8 @@ export function kitFieldsOf(fields, choices, relation) {
|
|
|
39
41
|
}
|
|
40
42
|
const values = type === "checkbox" ? CHECKED : CHOICE.has(type) ? choices(f.fieldKey, from, f.part) : undefined;
|
|
41
43
|
at.set(value, place);
|
|
42
|
-
return [{ value, label: f.label, type, ...(values ? { choices: values } : {}), ...(f.integer ? { integer: true } : {}) }
|
|
44
|
+
return [{ value, label: f.label, type, ...(values ? { choices: values } : {}), ...(f.integer ? { integer: true } : {}), ...(key !== undefined ? { key } : {}),
|
|
45
|
+
...(f.duration && type === "number" ? { duration: durationBox(f.duration, cv) } : {}) }];
|
|
43
46
|
};
|
|
44
47
|
const own = (f, from) => field(f, f.key, { fieldKey: f.fieldKey, ...(f.part !== undefined ? { part: f.part } : {}) }, from);
|
|
45
48
|
const relations = new Map(), relationLabels = new Map();
|
|
@@ -47,7 +50,7 @@ export function kitFieldsOf(fields, choices, relation) {
|
|
|
47
50
|
return { fields: (fields.find((f) => f.far && f.fieldKey === relation)?.far ?? []).flatMap((f) => own(f, relation)), at, relations };
|
|
48
51
|
const list = fields.filter((f) => !f.far).flatMap((f) => own(f));
|
|
49
52
|
const related = fields.filter((f) => f.far).flatMap((r) => {
|
|
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));
|
|
53
|
+
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, `${r.key}.${f.key}`));
|
|
51
54
|
relations.set(r.fieldKey, r.key);
|
|
52
55
|
if (!level.length) {
|
|
53
56
|
relationLabels.set(r.fieldKey, r.label);
|