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
|
@@ -9,6 +9,7 @@ import { usePanelControls } from "../internal/panel-controls.js";
|
|
|
9
9
|
import { moved, useReorder } from "../internal/reorder.js";
|
|
10
10
|
import { useStepReturn } from "../internal/step-return.js";
|
|
11
11
|
import { shapeMenu } from "../internal/menu-items.js";
|
|
12
|
+
import { shapeActions } from "../internal/row-actions.js";
|
|
12
13
|
import { Picker, usePicker } from "../picker/picker.js";
|
|
13
14
|
import { findItem, itemLabel } from "../picker/rows.js";
|
|
14
15
|
import { addSort, canAddSort, dropAside, openPlaces, putBack, repoint, SORT_MAX, takenBy } from "./rules.js";
|
|
@@ -30,6 +31,7 @@ function fieldsFor(fields, rules, sorted, own, fieldOf) {
|
|
|
30
31
|
}
|
|
31
32
|
export const sortableFields = (fields, rules, fieldOf, sorted = sortWords().sorted) => fieldsFor(fields, rules, sorted, undefined, fieldOf);
|
|
32
33
|
const RULE_KEYS = new Set(["delete"]), ASIDE_KEYS = new Set(["why", "put-back", "delete"]);
|
|
34
|
+
const ROW_KEYS = new Set(["delete", "more"]), FOOT_KEYS = new Set(["add", "clear"]);
|
|
33
35
|
export function useSortEditor(props) {
|
|
34
36
|
const { label, fields, rules, onRulesChange, max = SORT_MAX, onDone, opens, fieldOf, addSort: adds = true, clearAll: clears = true, items } = props;
|
|
35
37
|
const { Button, Select, Menu, Popover, Tooltip } = usePanelControls();
|
|
@@ -65,8 +67,9 @@ export function useSortEditor(props) {
|
|
|
65
67
|
if (refocus == null || !root)
|
|
66
68
|
return;
|
|
67
69
|
setRefocus(null);
|
|
70
|
+
const rows = [...root.querySelectorAll(".o-sort-editor-rule:not(.o-sort-editor-aside)")].slice(refocus);
|
|
68
71
|
const xs = root.querySelectorAll(".o-sort-editor-remove");
|
|
69
|
-
(
|
|
72
|
+
(rows.map((r) => r.querySelector(".o-sort-editor-remove")).find((x) => x) ?? xs[xs.length - 1])?.focus({ preventScroll: true });
|
|
70
73
|
}, [refocus, root]);
|
|
71
74
|
const remove = (i) => { root?.focus({ preventScroll: true }); change(now.current.filter((_, k) => k !== i)); setRefocus(i); };
|
|
72
75
|
const held = React.useMemo(() => ({ get current() { return { rules: now.current, aside: asideNow.current }; } }), []);
|
|
@@ -110,11 +113,30 @@ export function useSortEditor(props) {
|
|
|
110
113
|
React.useEffect(() => { if (step && step.list !== "add" && !stepRule && !(step.list === "repoint" && aside.some((a) => a.key === step.key)))
|
|
111
114
|
setStep(null); }, [step, stepRule, aside]);
|
|
112
115
|
const stepTitle = phone && step ? (stepRule ? nameOf(stepRule.field) : stepAside ? w.fieldNamed(stepAside.label) : step.list === "add" ? w.add : undefined) : undefined;
|
|
113
|
-
const addButton = (size) => (_jsx(Tooltip, { label: w.max(max), reason: true, side: "top", disabled: can, children: _jsx(Button, { kind: "outline", size: size, icon: glyph(PLUS), className: "o-sort-editor-add", "data-slot": "vk-sort-add", disabled: !can, focusableWhenDisabled: true, "aria-haspopup": phone ? undefined : "dialog", "aria-expanded": phone ? undefined : pop?.list === "add", onClick: (e) => { const at = e.currentTarget; if (phone)
|
|
116
|
+
const addButton = (size, shown) => (_jsx(Tooltip, { label: shown?.disabled ?? w.max(max), reason: true, side: "top", disabled: can && !shown?.disabled, children: _jsx(Button, { kind: "outline", size: size, icon: shown?.icon ?? glyph(PLUS), className: "o-sort-editor-add", "data-slot": "vk-sort-add", disabled: !can || !!shown?.disabled, focusableWhenDisabled: true, "aria-haspopup": phone ? undefined : "dialog", "aria-expanded": phone ? undefined : pop?.list === "add", onClick: (e) => { const at = e.currentTarget; if (phone)
|
|
114
117
|
setStep({ list: "add" });
|
|
115
118
|
else
|
|
116
|
-
setPop((p) => (p?.list === "add" ? null : { list: "add", rule: -1, at })); }, children: w.add }) }));
|
|
119
|
+
setPop((p) => (p?.list === "add" ? null : { list: "add", rule: -1, at })); }, children: shown?.label ?? w.add }) }));
|
|
117
120
|
const closePop = () => setPop(null);
|
|
121
|
+
const ctxForm = phone ? "phone" : "computer";
|
|
122
|
+
const rowLook = phone ? { slot: "vk-sort-row-action", size: "40x44", look: DOTS_LOOK }
|
|
123
|
+
: narrow ? { slot: "vk-sort-row-action", size: "xs", look: MORE_LOOK } : { slot: "vk-sort-row-action", size: "2xs", look: X_LOOK };
|
|
124
|
+
const footLook = { slot: "vk-sort-foot-action", size: phone ? "44" : "sm" };
|
|
125
|
+
const rowEnd = (key, label, icon, draw, ctx) => shapeActions([{ key, label, icon, draw }], items, ctx, ROW_KEYS, rowLook);
|
|
126
|
+
const greyed = (why, node) => _jsx(Tooltip, { label: why, reason: true, side: "top", children: node });
|
|
127
|
+
const moreMenu = (menuLabel, entries, trigger) => {
|
|
128
|
+
function drawn(shown) {
|
|
129
|
+
return shown?.disabled ? greyed(shown.disabled, trigger(shown.label, true)) : _jsx(Menu, { label: menuLabel, align: "end", entries: entries, trigger: trigger(shown?.label) });
|
|
130
|
+
}
|
|
131
|
+
return drawn;
|
|
132
|
+
};
|
|
133
|
+
const footOf = (size, add, clear, clearWords) => shapeActions([
|
|
134
|
+
...(add ? [{ key: "add", label: w.add, icon: glyph(PLUS), ...(!can && { disabled: w.max(max) }), draw: (shown) => addButton(size, shown) }] : []),
|
|
135
|
+
...(clear ? [{ key: "clear", label: clearWords, draw: (shown) => {
|
|
136
|
+
const b = _jsx(Button, { kind: "quiet", size: size, className: "o-sort-editor-clear", "data-slot": "vk-sort-clear", ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }), onClick: clear, children: shown?.label ?? clearWords });
|
|
137
|
+
return shown?.disabled ? greyed(shown.disabled, b) : b;
|
|
138
|
+
} }] : []),
|
|
139
|
+
], items, { menu: "foot", form: ctxForm }, FOOT_KEYS, footLook);
|
|
118
140
|
const addPicker = _jsx(Picker, { label: w.add, items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { addField(v); }, ...words });
|
|
119
141
|
const asideEntries = (a) => shapeMenu([
|
|
120
142
|
{ icon: null, label: a.why, disabled: a.why, slot: { slot: "vk-sort-rule-action", key: "why" } },
|
|
@@ -123,9 +145,10 @@ export function useSortEditor(props) {
|
|
|
123
145
|
], items, { menu: "aside", field: a.key, form: phone ? "phone" : "computer" }, "vk-sort-rule-action", ASIDE_KEYS);
|
|
124
146
|
if (phone || narrow) {
|
|
125
147
|
const size = phone ? "44" : "sm";
|
|
126
|
-
const more = (name) => (phone
|
|
127
|
-
? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS) })
|
|
128
|
-
: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": w.actionsFor(name), icon: glyph(DOTS_UP) }));
|
|
148
|
+
const more = (name, label, disabled) => (phone
|
|
149
|
+
? _jsx(Button, { kind: "quiet", shape: "icon", size: "40x44", look: DOTS_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": label ?? w.actionsFor(name), icon: glyph(DOTS), ...(disabled && { disabled, focusableWhenDisabled: true }) })
|
|
150
|
+
: _jsx(Button, { kind: "quiet", shape: "icon", size: "xs", look: MORE_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": label ?? w.actionsFor(name), icon: glyph(DOTS_UP), ...(disabled && { disabled, focusableWhenDisabled: true }) }));
|
|
151
|
+
const moreGlyph = glyph(phone ? DOTS : DOTS_UP);
|
|
129
152
|
const ruleRow = (r, i) => {
|
|
130
153
|
const name = nameOf(r.field), mark = markFor(r.field), g = gripProps(i), standing = narrow && opens?.list === "direction" && opens.rule === i;
|
|
131
154
|
const inner = _jsxs(_Fragment, { children: [_jsxs("button", { type: "button", className: "o-sort-editor-press", "data-slot": "vk-sort-rule-open", ...g, onPointerDown: (e) => { dragged.current = false; setMoving(false); g.onPointerDown(e); }, "aria-haspopup": narrow ? "dialog" : undefined, "aria-expanded": narrow ? pop?.list === "direction" && pop.rule === i : undefined, onClick: (e) => {
|
|
@@ -138,7 +161,7 @@ export function useSortEditor(props) {
|
|
|
138
161
|
setPop((p) => (p?.list === "direction" && p.rule === i ? null : { list: "direction", rule: i, at }));
|
|
139
162
|
else
|
|
140
163
|
setStep({ list: "direction", rule: i });
|
|
141
|
-
}, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }),
|
|
164
|
+
}, children: [mark, _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: name }), _jsx("span", { className: "o-sort-editor-way", children: r.direction === "ascending" ? w.ascending : w.descending })] })] }), rowEnd("more", w.actionsFor(name), moreGlyph, moreMenu(w.sortBy(name), shapeMenu([{ icon: glyph(TRASH), label: w.delete, danger: true, onSelect: () => change(now.current.filter((_, k) => k !== i)), slot: { slot: "vk-sort-rule-action", key: "delete" } }], items, { menu: "rule", field: r.field, index: i, form: phone ? "phone" : "computer" }, "vk-sort-rule-action", RULE_KEYS), (l, d) => more(name, l, d)), { menu: "row", field: r.field, index: i, form: ctxForm }), standing && shownList(DIRECTIONS, r.direction, w.direction, false)] });
|
|
142
165
|
return phone
|
|
143
166
|
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field)
|
|
144
167
|
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: inner }, r.field);
|
|
@@ -149,7 +172,7 @@ export function useSortEditor(props) {
|
|
|
149
172
|
else {
|
|
150
173
|
repointed.current = null;
|
|
151
174
|
setStep({ list: "repoint", key: a.key });
|
|
152
|
-
} }, children: _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: a.label }), _jsx("span", { className: "o-sort-editor-way", children: a.why })] }) }),
|
|
175
|
+
} }, children: _jsxs("span", { className: "o-sort-editor-words", children: [_jsx("span", { className: "o-sort-editor-name", children: a.label }), _jsx("span", { className: "o-sort-editor-way", children: a.why })] }) }), rowEnd("more", w.actionsFor(a.label), moreGlyph, moreMenu(w.sortBy(a.label), asideEntries(a), (l, d) => more(a.label, l, d)), { menu: "row", field: a.key, aside: true, form: ctxForm })] });
|
|
153
176
|
return phone
|
|
154
177
|
? _jsx(FieldRow, { as: "div", role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`)
|
|
155
178
|
: _jsx("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: inner }, `aside-${a.key}`);
|
|
@@ -158,20 +181,25 @@ export function useSortEditor(props) {
|
|
|
158
181
|
const popAside = pop?.list === "repoint" ? aside.find((a) => a.key === pop.key) : undefined;
|
|
159
182
|
const body = (_jsxs("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": way, role: narrow ? "group" : undefined, "aria-label": narrow ? label : undefined, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), "data-sort-step": stepTitle !== undefined ? step?.list : undefined, children: [stepTitle !== undefined ? stepList.body : _jsxs(_Fragment, { children: [rules.length || aside.length ? (phone
|
|
160
183
|
? _jsxs(FieldRows, { look: ROWS, className: "o-sort-editor-card", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })
|
|
161
|
-
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })),
|
|
184
|
+
: _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map(ruleRow), aside.map(asideRow)] })) : (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })), _jsx("div", { className: "o-sort-editor-acts", "data-slot": "vk-sort-foot", children: footOf(size, true, clears && rules.length > 0 ? () => change([]) : null, w.clearAll) })] }), narrow && (_jsx(Popover, { open: !!pop && (pop.list === "add" || !!popRule || !!popAside), onOpenChange: (o) => { if (!o)
|
|
162
185
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": pop?.list === "add" ? w.add : popAside ? w.fieldNamed(popAside.label) : popRule ? nameOf(popRule.field) : label, children: pop?.list === "add"
|
|
163
186
|
? addPicker
|
|
164
187
|
: popAside ? _jsx(Picker, { label: w.fieldNamed(popAside.label), items: pickable(), value: null, search: search, searchShown: true, form: "computer", defaultLevel: props.level, onDone: closePop, onValueChange: (v) => { pointAt(popAside.key)(v); closePop(); }, ...words })
|
|
165
188
|
: popRule && _jsx(Picker, { label: nameOf(popRule.field), items: DIRECTIONS, value: popRule.direction, searchShown: false, form: "computer", fromHeld: true, onDone: closePop, onValueChange: turn(pop?.rule ?? -1), ...words }) }))] }));
|
|
166
189
|
return { body, head: !phone ? {} : stepTitle !== undefined ? { onBack: back } : decide.head, ...(stepTitle !== undefined ? { title: stepTitle } : {}) };
|
|
167
190
|
}
|
|
168
|
-
const
|
|
191
|
+
const sayNone = props.empty === "editor" && rules.length === 0 && aside.length === 0;
|
|
192
|
+
const foot = footOf("sm", adds, clears && rules.length > 0 ? () => { closePop(); change([]); if (!asideNow.current.length && props.empty !== "editor")
|
|
193
|
+
onDone?.(); } : null, w.clearAllSorts);
|
|
194
|
+
const body = (_jsx("div", { ref: placeRoot, className: "o-sort-editor", "data-slot": "vk-sort", "data-kit": "sort-editor", "data-sort-form": "computer", role: "group", "aria-label": label, tabIndex: -1, style: room ? { paddingBottom: room } : undefined, ...phoneMark(!!screen || small), children: (rules.length > 0 || aside.length > 0 || sayNone) && _jsxs(_Fragment, { children: [sayNone ? (_jsxs("div", { className: "o-sort-editor-none", "data-slot": "vk-sort-none", children: [_jsx("p", { className: "o-sort-editor-none-head", children: w.none }), _jsx("p", { className: "o-sort-editor-none-line", children: w.noneLine })] })) : _jsxs("div", { className: "o-sort-editor-rules", "data-slot": "vk-sort-rules", role: "list", "aria-label": label, children: [rules.map((r, i) => {
|
|
169
195
|
const name = nameOf(r.field), g = gripProps(i), open = opens?.rule === i ? opens.list : null;
|
|
170
196
|
const items = pickable(r.field);
|
|
171
197
|
return (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule", "data-slot": "vk-sort-rule", "data-key": r.field, "data-index": i, "data-row": i, "data-lifted": liftedAt(i), style: lift(i), children: [_jsx(Grip, { label: w.move(name), className: "o-sort-editor-grip", "data-slot": "vk-sort-grip", ...g }), _jsxs("div", { className: "o-sort-editor-field", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.field, "data-slot": "vk-sort-field", items: asSelect(items), value: r.field, search: search, "data-force": open === "field" ? "focus" : undefined, onValueChange: (v) => { if (typeof v === "string" && v !== r.field && !takenBy(now.current, v, r.field, fieldOf))
|
|
172
|
-
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }),
|
|
173
|
-
|
|
174
|
-
|
|
198
|
+
change(now.current.map((x, k) => (k === i ? { ...x, field: v } : x))); } }), open === "field" && shownList(items, r.field, w.field, true)] }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: r.direction, "data-force": open === "direction" ? "focus" : undefined, onValueChange: turn(i) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) }), open === "direction" && shownList(DIRECTIONS, r.direction, w.direction, false)] }), rowEnd("delete", w.remove(name), glyph(X), (shown) => {
|
|
199
|
+
const x = _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-remove", "data-slot": "vk-sort-remove", "aria-label": shown?.label ?? w.remove(name), icon: shown?.icon ?? glyph(X), ...(shown?.disabled && { disabled: true, focusableWhenDisabled: true }), onClick: () => remove(i) });
|
|
200
|
+
return shown?.disabled ? greyed(shown.disabled, x) : x;
|
|
201
|
+
}, { menu: "row", field: r.field, index: i, form: "computer" })] }, r.field));
|
|
202
|
+
}), aside.map((a) => (_jsxs("div", { role: "listitem", className: "o-sort-editor-rule o-sort-editor-aside", "data-slot": "vk-sort-rule", "data-key": a.key, "data-aside": "", "data-aside-key": a.key, children: [_jsx("span", { className: "o-sort-editor-grip-place", "aria-hidden": "true" }), _jsx("div", { className: "o-sort-editor-field", children: _jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.fieldNamed(a.label), "data-slot": "vk-sort-field", items: asSelect(pickable()), value: null, placeholder: a.label, search: search, onValueChange: pointAt(a.key) }) }) }) }), _jsxs("div", { className: "o-sort-editor-direction", children: [_jsx(Tooltip, { label: a.why, side: "bottom", children: _jsx("span", { className: "o-sort-editor-why", children: _jsx(Select, { size: "xs", listWidth: "rows", "aria-label": w.direction, "data-slot": "vk-sort-direction", items: asSelect(DIRECTIONS), value: a.direction, disabled: true, onValueChange: () => { } }) }) }), _jsx(DirectionFit, { items: asSelect(DIRECTIONS) })] }), rowEnd("more", w.actionsFor(a.label), glyph(DOTS), moreMenu(w.sortBy(a.label), asideEntries(a), (label, disabled) => _jsx(Button, { kind: "quiet", shape: "icon", size: "2xs", look: X_LOOK, className: "o-sort-editor-more", "data-slot": "vk-sort-rule-more", "aria-label": label ?? w.actionsFor(a.label), icon: glyph(DOTS), ...(disabled && { disabled, focusableWhenDisabled: true }) })), { menu: "row", field: a.key, aside: true, form: "computer" })] }, `aside-${a.key}`)))] }), foot.length > 0 && _jsx("div", { className: "o-sort-editor-foot", "data-slot": "vk-sort-foot", children: foot }), _jsx(Popover, { open: pop?.list === "add", onOpenChange: (o) => { if (!o)
|
|
175
203
|
closePop(); }, anchor: pop?.at, className: "o-sort-editor-pop", "aria-label": w.add, children: pop?.list === "add" && addPicker })] }) }));
|
|
176
204
|
return { body, head: {} };
|
|
177
205
|
}
|
|
@@ -101,6 +101,28 @@
|
|
|
101
101
|
white-space: pre; overflow: hidden;
|
|
102
102
|
}
|
|
103
103
|
|
|
104
|
+
/* ── A record's long text under the Field's Long (row-long: line, field.css), on a computer: its box stands in a popover on top of the
|
|
105
|
+
row's box (the popover marked data-field-row-long-editor, field-row/editors/RowTextEditor.tsx), the popover its only frame. The
|
|
106
|
+
box is the popover's whole content: no edge, ring or ground of its own, its words as far from its edge as the row's box holds
|
|
107
|
+
them (--vk-field-row-box-h and -x, undeclared 32 and 8), so its first line stands where the row's words stood. It is as tall as its
|
|
108
|
+
text up to the editor's most height (--vk-editor-max-h, the popover's own cap; undeclared, 320), then it scrolls. The popover's
|
|
109
|
+
corners are the row box's own, so nothing of the box shows round them (VK-1110): the box's rounded-md, or under the Field's Box
|
|
110
|
+
(data-field-row-long-editor="box") its corner, --vk-field-row-box-r (undeclared 8). (0,5,0): over the row's place. ──────────── */
|
|
111
|
+
.o-popover[data-field-row-long-editor] { --popover-pad: 0px; --popover-corners: var(--vk-radius-md); }
|
|
112
|
+
.o-popover[data-field-row-long-editor="box"] { --popover-corners: var(--vk-field-row-box-r, calc(var(--vk-spacing) * 2)); }
|
|
113
|
+
[data-field-row-long-editor] .o-text-editor[data-text-place="row"][data-text-form="computer"] {
|
|
114
|
+
--inline-input-row: var(--vk-field-row-box-h, calc(var(--vk-spacing) * 8)); --inline-input-edge: 0px; --inline-input-ring: 0px;
|
|
115
|
+
}
|
|
116
|
+
[data-field-row-long-editor] .o-text-editor[data-text-place="row"][data-text-form] .o-text-editor-box {
|
|
117
|
+
--inline-input-words: var(--vk-field-row-box-x, calc(var(--vk-spacing) * 2));
|
|
118
|
+
max-height: var(--vk-editor-max-h, calc(var(--vk-spacing) * 80)); border-radius: 0; background-color: transparent; box-shadow: none;
|
|
119
|
+
}
|
|
120
|
+
/* In place, under the Field's Action (row-action: icon, field.css), a long text's box keeps the icon's room at its end, as its
|
|
121
|
+
target did at rest, so its lines break where they did. */
|
|
122
|
+
:where([data-field-row-action="icon"] [data-field-row-editor]) .o-text-editor[data-text-place="row"][data-text-form="computer"][data-text-kind="long"] .o-text-editor-box {
|
|
123
|
+
padding-right: calc(var(--vk-spacing) * 8 - var(--inline-input-e));
|
|
124
|
+
}
|
|
125
|
+
|
|
104
126
|
/* ── On a phone: the Input at the phone's size; long text one tall box; a phone's country in the box's start side ──── */
|
|
105
127
|
.o-text-editor[data-text-form="phone"] { display: grid; }
|
|
106
128
|
.o-text-editor[data-text-form="phone"] .o-text-editor-country { gap: calc(var(--vk-spacing) * 0.75); }
|
|
@@ -50,9 +50,6 @@ import { VALUES_EDITOR_PRIVATE, VALUES_EDITOR_TOKENS } from "./values-editor/tok
|
|
|
50
50
|
import { LINKS_EDITOR_PRIVATE, LINKS_EDITOR_TOKENS } from "./links-editor/tokens.js";
|
|
51
51
|
import { PRESS_PRIVATE, PRESS_TOKENS } from "./press/tokens.js";
|
|
52
52
|
import { CHOICE_PRIVATE, CHOICE_TOKENS } from "./choice/tokens.js";
|
|
53
|
-
import { TAG_FIELD_PRIVATE, TAG_FIELD_TOKENS } from "./tag-field/tokens.js";
|
|
54
|
-
import { SETTING_ROW_PRIVATE, SETTING_ROW_TOKENS } from "./setting-row/tokens.js";
|
|
55
|
-
import { SWITCH_ROW_PRIVATE, SWITCH_ROW_TOKENS } from "./switch-row/tokens.js";
|
|
56
53
|
const CONTROLS_OWN = {
|
|
57
54
|
button: { tokens: BUTTON_TOKENS, private: BUTTON_PRIVATE },
|
|
58
55
|
spinner: { tokens: SPINNER_TOKENS, private: SPINNER_PRIVATE },
|
|
@@ -106,9 +103,6 @@ const CONTROLS_OWN = {
|
|
|
106
103
|
"links-editor": { tokens: LINKS_EDITOR_TOKENS, private: LINKS_EDITOR_PRIVATE },
|
|
107
104
|
press: { tokens: PRESS_TOKENS, private: PRESS_PRIVATE },
|
|
108
105
|
choice: { tokens: CHOICE_TOKENS, private: CHOICE_PRIVATE },
|
|
109
|
-
"tag-field": { tokens: TAG_FIELD_TOKENS, private: TAG_FIELD_PRIVATE },
|
|
110
|
-
"switch-row": { tokens: SWITCH_ROW_TOKENS, private: SWITCH_ROW_PRIVATE },
|
|
111
|
-
"setting-row": { tokens: SETTING_ROW_TOKENS, private: SETTING_ROW_PRIVATE },
|
|
112
106
|
};
|
|
113
107
|
export const VK_CONTROL_TOKENS_BY_PIECE = Object.fromEntries(Object.entries(CONTROLS_OWN).map(([piece, own]) => [piece, own.tokens]));
|
|
114
108
|
export const VK_CONTROL_TOKENS = Object.entries(VK_CONTROL_TOKENS_BY_PIECE)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import * as React from "react";
|
|
4
|
-
import { flushSync } from "react-dom";
|
|
5
4
|
import { Toolbar as BaseToolbar } from "@base-ui/react/toolbar";
|
|
5
|
+
import { beforePaint } from "../../internal/before-paint.js";
|
|
6
6
|
import { cx as cn } from "../../internal/cx.js";
|
|
7
7
|
import { ScreenForms } from "../../internal/screen-forms.js";
|
|
8
8
|
import { Button, ButtonGroup } from "../button/button.js";
|
|
@@ -139,7 +139,7 @@ function useGiveWay(line, max, on, holds = false) {
|
|
|
139
139
|
if (!line || !on)
|
|
140
140
|
return;
|
|
141
141
|
let width = -1;
|
|
142
|
-
const again = () =>
|
|
142
|
+
const again = () => beforePaint(() => look(latest.current.stage, latest.current.max));
|
|
143
143
|
const sized = new ResizeObserver(([e]) => { const w = e.contentRect.width; if (w !== width) {
|
|
144
144
|
width = w;
|
|
145
145
|
again();
|
|
@@ -11,4 +11,4 @@ export declare function toolbarPartDress(part: ViewsFramePart, { current, phone,
|
|
|
11
11
|
ground: ToolbarButtonGround;
|
|
12
12
|
}): Partial<ToolbarButtonProps>;
|
|
13
13
|
/** The ToolbarButton atom as the toolbar button. ViewKit's own `size` is not read: in a Toolbar a button takes its line's. */
|
|
14
|
-
export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export declare function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, expanded, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }: ViewsToolbarButtonProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -22,7 +22,7 @@ export function toolbarPartDress(part, { current, phone, tabs, ground }) {
|
|
|
22
22
|
case "save": return { ground: "bordered", words: "word" };
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }) {
|
|
25
|
+
export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, changed, edge, disabled, disabledReason, children, empty, aside, foot, iconAlone, popup, expanded, joined, waits, current, part, className, onContextMenu, onClick, onPointerDown, ref }) {
|
|
26
26
|
const row = React.useContext(InToolbar);
|
|
27
27
|
const [el, setEl] = React.useState(null);
|
|
28
28
|
const picks = useToolbarWorn(el);
|
|
@@ -33,7 +33,7 @@ export function ToolbarButtonAtom({ icon, label, word, count, more, dot, open, c
|
|
|
33
33
|
else if (ref)
|
|
34
34
|
ref.current = node;
|
|
35
35
|
}, [ref]);
|
|
36
|
-
const opens = popup ? { "aria-haspopup": popup, "aria-expanded": !!open } : {};
|
|
36
|
+
const opens = popup ? { "aria-haspopup": popup, "aria-expanded": !!open } : expanded !== undefined ? { "aria-expanded": expanded } : {};
|
|
37
37
|
const text = children ?? (typeof word === "string" ? word : undefined);
|
|
38
38
|
const said = waits && text != null ? _jsx("span", { className: "o-toolbar-button-waits", children: text }) : text;
|
|
39
39
|
if (foot)
|
|
@@ -108,7 +108,7 @@ export function EditorPanel({ session, title, anchor, inPlace = false, sheetOnPh
|
|
|
108
108
|
return editor;
|
|
109
109
|
const reason = refusal ? (_jsx("p", { role: "alert", "data-slot": "vk-editor-refusal", className: cx("px-2 pb-2 text-xs text-(color:--vk-danger)", surface === "popover" && "sticky bottom-0 bg-(color:--vk-overlay)"), children: refusal })) : null;
|
|
110
110
|
if (surface === "popover") {
|
|
111
|
-
return (_jsxs(Popover, { ...popover, open: open, onOpenChange: (next, details) => {
|
|
111
|
+
return (_jsxs(Popover, { ...popover, ...(around ? { finalFocus: false } : {}), open: open, onOpenChange: (next, details) => {
|
|
112
112
|
if (next || details?.reason === "outside-press")
|
|
113
113
|
return;
|
|
114
114
|
if (details?.reason === "escape-key" && escapedRef.current) {
|
|
@@ -14,13 +14,14 @@ import { useViews } from "../provider/context.js";
|
|
|
14
14
|
import { ScreenForms } from "../internal/screen-forms.js";
|
|
15
15
|
import { useDesktop } from "../provider/desktop.js";
|
|
16
16
|
import { RowEditor, rowOpensSheet } from "./editors/RowEditor.js";
|
|
17
|
+
import { RowLongContext } from "./editors/row-place.js";
|
|
17
18
|
import { drawnText } from "./drawn-text.js";
|
|
18
19
|
import { FieldNoteLine } from "./FieldNoteLine.js";
|
|
19
20
|
import { FieldRowCheckbox } from "./field-row-checkbox.js";
|
|
20
21
|
import { FIELD_ROW_FRAME, FIELD_ROW_FRAME_BESIDE, FIELD_ROW_FRAME_ROWS, FIELD_ROW_FRAME_ROWS_UNDER, FIELD_ROW_FRAME_UNDER, FieldRowButton, drawFieldRowButton, TARGET_KEY, } from "./field-row-button.js";
|
|
21
22
|
import { FieldRowLane } from "./FieldRowLane.js";
|
|
22
23
|
import { FieldWriteReconciliationRequired, } from "../fields/write-target.js";
|
|
23
|
-
import { OpenValueAction, isOpenableType } from "../editors/open-value.js";
|
|
24
|
+
import { OpenValueAction, isOpenableType, openValueHref } from "../editors/open-value.js";
|
|
24
25
|
import { FIELD_ROW_TARGET as TARGET } from "./row-target.js";
|
|
25
26
|
import { settlementAttributes, useRowSettlement } from "./useRowSettlement.js";
|
|
26
27
|
import { EditLeaveContext, useEditLeaveScope } from "../editors/leave-scope.js";
|
|
@@ -57,6 +58,9 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
57
58
|
const { AppIcon } = components;
|
|
58
59
|
const [editing, setEditing] = useState(false);
|
|
59
60
|
const [byKey, setByKey] = useState(false);
|
|
61
|
+
const [longLine, setLongLine] = useState(false);
|
|
62
|
+
const [edge, setEdge] = useState();
|
|
63
|
+
const [linkWords, setLinkWords] = useState(false);
|
|
60
64
|
const [pending, setPending] = useState(null);
|
|
61
65
|
const [error, setError] = useState(null);
|
|
62
66
|
const [retryDraft, setRetryDraft] = useState(null);
|
|
@@ -192,6 +196,13 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
192
196
|
booleanCheckbox: FieldRowCheckbox,
|
|
193
197
|
};
|
|
194
198
|
const editsInPlace = writable && shownDef.type !== "boolean" && !hasMenu && !unread && !isEmpty;
|
|
199
|
+
const textMark = inRows || !editsInPlace
|
|
200
|
+
? undefined
|
|
201
|
+
: (shownDef.type === "text" && shownDef.format?.long) || shownDef.type === "rich_text"
|
|
202
|
+
? "long"
|
|
203
|
+
: shownDef.type === "text"
|
|
204
|
+
? "line"
|
|
205
|
+
: undefined;
|
|
195
206
|
const openType = editsInPlace && singleLink && isOpenableType(shownDef.type) ? shownDef.type : null;
|
|
196
207
|
const openOne = Array.isArray(shown) ? shown[0] : shown;
|
|
197
208
|
const openValue = openOne && typeof openOne === "object" && "value" in openOne
|
|
@@ -200,6 +211,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
200
211
|
const openLabel = shownDef.type === "phone"
|
|
201
212
|
? phoneText(openValue, binding.region?.(row) ?? null)
|
|
202
213
|
: String(openValue ?? "");
|
|
214
|
+
const wordsLink = linkWords && !inRows && openType !== null && openValueHref(openType, openValue) !== null;
|
|
203
215
|
const valueOverButton = editsInPlace && shownDef.type === "rich_text" && base.wrap === "full";
|
|
204
216
|
const displayOpts = shownDef.type === "boolean" && writable
|
|
205
217
|
? {
|
|
@@ -209,7 +221,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
209
221
|
onResolve: !ready || pending ? undefined : () => attempt({ kind: "commit", payload: false }),
|
|
210
222
|
}
|
|
211
223
|
:
|
|
212
|
-
valueOverButton
|
|
224
|
+
valueOverButton || wordsLink
|
|
213
225
|
? { ...base, slotOwnsClick: false }
|
|
214
226
|
: base;
|
|
215
227
|
const rowCurrency = unread || fieldOwnsCurrency ? undefined : binding.unit?.read(row);
|
|
@@ -230,7 +242,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
230
242
|
const TypeGlyph = icons[field.type];
|
|
231
243
|
const glyph = binding.icon ? (_jsx(AppIcon, { name: binding.icon, className: "h-3.5 w-3.5 text-(color:--vk-fg-subtlest)" })) : (_jsx(TypeGlyph, { className: "h-3.5 w-3.5 text-(color:--vk-fg-subtlest)" }));
|
|
232
244
|
const menuItems = fieldRowMenuItems(menu, ready, messages);
|
|
233
|
-
const valueNode = (_jsxs("span", { ref: valueRef, className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { className: "min-w-0 wrap-break-word", children: _jsx(RelationChipSize.Provider, { value: "row", children: body }) }), meta ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: meta }) : null] }));
|
|
245
|
+
const valueNode = (_jsxs("span", { ref: valueRef, className: "flex min-w-0 flex-1 items-center gap-2", children: [_jsx("span", { className: base.wrap === false ? (inRows ? "min-w-0 truncate *:max-w-full" : "min-w-0 truncate") : "min-w-0 wrap-break-word", "data-field-row-text": textMark, children: _jsx(RelationChipSize.Provider, { value: "row", children: body }) }), meta ? _jsx("span", { className: "shrink-0 text-xs text-(color:--vk-fg-subtle)", children: meta }) : null] }));
|
|
234
246
|
const handOver = () => {
|
|
235
247
|
const row = rowRef.current;
|
|
236
248
|
if (!row || !buttonRef.current || document.activeElement !== buttonRef.current)
|
|
@@ -249,14 +261,19 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
249
261
|
handOver();
|
|
250
262
|
setError(null);
|
|
251
263
|
setByKey(byKey);
|
|
264
|
+
setLongLine(!inRows && rowRef.current?.closest("[data-field-row-long]")?.getAttribute("data-field-row-long") === "line");
|
|
265
|
+
const button = buttonRef.current && getComputedStyle(buttonRef.current);
|
|
266
|
+
setEdge(button ? [button.borderTopWidth, button.borderRightWidth, button.borderBottomWidth, button.borderLeftWidth].map((w) => w || "0px").join(" ") : undefined);
|
|
252
267
|
setEditing(true);
|
|
253
268
|
};
|
|
254
269
|
const action = binding.action ??
|
|
255
|
-
(
|
|
256
|
-
? "
|
|
257
|
-
:
|
|
258
|
-
? "
|
|
259
|
-
:
|
|
270
|
+
(wordsLink
|
|
271
|
+
? "edit"
|
|
272
|
+
: (field.type === "text" && field.format?.long) || field.type === "rich_text"
|
|
273
|
+
? "expand"
|
|
274
|
+
: rowOpensSheet(field, oneValue)
|
|
275
|
+
? "edit"
|
|
276
|
+
: "none");
|
|
260
277
|
const Act = inRows || action === "none" ? null : icons[action];
|
|
261
278
|
const actIcon = Act ? (_jsx("span", { "data-field-row-act": action, "aria-hidden": "true", className: "hidden", children: _jsx(Act, { className: "size-3.75" }) })) : null;
|
|
262
279
|
const frameOf = (shape) => inRows
|
|
@@ -272,6 +289,11 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
272
289
|
: FIELD_ROW_FRAME;
|
|
273
290
|
const editButton = (shape, children) => (_jsx(FieldRowButton, { views: views, frame: cx(frameOf(shape), "disabled:pointer-events-none aria-disabled:pointer-events-none", shape !== "under" && pending && "opacity-70"), variant: "ghost", size: "sm", ref: buttonRef, "data-key": inRows ? undefined : TARGET_KEY[shape], "aria-label": unread || shape === "under" || !shownText ? field.label : `${field.label}, ${shownText}`, disabled: !ready, "aria-disabled": pending ? true : undefined, onClick: (event) => open(event.detail === 0), children: children }));
|
|
274
291
|
const rowRef = useRef(null);
|
|
292
|
+
useLayoutEffect(() => {
|
|
293
|
+
const words = rowRef.current?.closest("[data-field-row-link]")?.getAttribute("data-field-row-link") === "words";
|
|
294
|
+
if (words !== linkWords)
|
|
295
|
+
setLinkWords(words);
|
|
296
|
+
});
|
|
275
297
|
const downWhileEditing = useRef(false);
|
|
276
298
|
const pressOpens = inRows && writable && shownDef.type !== "boolean" && !hasMenu && !unread && !editing && !pending && ready;
|
|
277
299
|
const onRowPress = (event) => {
|
|
@@ -303,13 +325,13 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
303
325
|
? "o-field-row-glyph"
|
|
304
326
|
: "flex h-5 w-3.5 shrink-0 items-center justify-center group-data-[form=computer]/field-row:in-data-[field-row-icon=off]:hidden", children: glyph }), _jsx("span", { className: inRows
|
|
305
327
|
? "o-field-row-label"
|
|
306
|
-
: "text-sm leading-5 text-(color:--vk-field-row-label-fg,var(--vk-fg-subtle))", children: field.label }), _jsxs("div", { className: cx(inRows ? "min-w-0 flex-1" : "min-w-0 flex-1 text-sm leading-5 text-(color:--vk-fg)", !inRows && "group-data-[form=phone]/field-row:col-span-2 group-data-[form=phone]/field-row:col-start-2 group-data-[form=phone]/field-row:row-start-2", settlement.requested && "italic opacity-80"), ...settlementAttributes(settlement.requested, field.provenance, conventions), children: [editing ? (_jsx("div", { "data-field-row-editor": inRows ? undefined : "", children: _jsx(RowEditor, { binding: binding, row: row, initial: retryDraft ? retryDraft.commit : editValue, refused: retryDraft?.reason, shown: shown, conversion: convertedFrom ? body : undefined, anchor: inRows ? (_jsx("span", { className: "flex min-w-0", children: valueNode })) : (_jsxs("span", { className: cx(TARGET, "bg-(color:--vk-neutral)"), "data-field-row-anchor": "", children: [valueNode, actIcon] })), onAttempt: (resolution) => {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
328
|
+
: "text-sm leading-5 text-(color:--vk-field-row-label-fg,var(--vk-fg-subtle))", children: field.label }), _jsxs("div", { className: cx(inRows ? "min-w-0 flex-1" : "min-w-0 flex-1 text-sm leading-5 text-(color:--vk-fg)", !inRows && "group-data-[form=phone]/field-row:col-span-2 group-data-[form=phone]/field-row:col-start-2 group-data-[form=phone]/field-row:row-start-2", settlement.requested && "italic opacity-80"), ...settlementAttributes(settlement.requested, field.provenance, conventions), children: [editing ? (_jsx("div", { "data-field-row-editor": inRows ? undefined : "", children: _jsx(RowLongContext.Provider, { value: longLine, children: _jsx(RowEditor, { binding: binding, row: row, initial: retryDraft ? retryDraft.commit : editValue, refused: retryDraft?.reason, shown: shown, conversion: convertedFrom ? body : undefined, anchor: inRows ? (_jsx("span", { className: "flex min-w-0", children: valueNode })) : (_jsxs("span", { className: cx(TARGET, "border-solid border-transparent bg-(color:--vk-neutral)"), style: { borderWidth: edge ?? 0 }, "data-field-row-anchor": "", children: [valueNode, actIcon] })), onAttempt: (resolution) => {
|
|
329
|
+
watchLeaving();
|
|
330
|
+
const answer = attempt(resolution);
|
|
331
|
+
if (answer.accepted && leaving.current)
|
|
332
|
+
leaving.current.exiting = true;
|
|
333
|
+
return answer;
|
|
334
|
+
}, onClose: closed, message: message, kindIcon: kindIcon, openedByKey: byKey }) }) })) : hasMenu && !verbsInLane ? (_jsx(CommandMenu, { trigger: drawFieldRowButton(views, {
|
|
313
335
|
frame: inRows ? FIELD_ROW_FRAME_ROWS : FIELD_ROW_FRAME,
|
|
314
336
|
...(inRows ? {} : { "data-key": TARGET_KEY.target }),
|
|
315
337
|
variant: "ghost",
|
|
@@ -317,7 +339,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
317
339
|
"aria-label": field.label,
|
|
318
340
|
disabled: !ready,
|
|
319
341
|
children: valueNode,
|
|
320
|
-
}), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton ? (_jsxs("div", { className: "relative min-w-0", children: [editButton("under", actIcon), _jsx("span", { "data-slot": "vk-row-value-layer", className: cx("pointer-events-none relative block min-w-0 [&_a]:pointer-events-auto [&_button]:pointer-events-auto", pending && "opacity-70"), children: valueNode })] })) : openType ? (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [editButton("beside", _jsxs(_Fragment, { children: [valueNode, actIcon] })), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton("target", _jsxs(_Fragment, { children: [valueNode, actIcon] })))) : (_jsx("span", { className: "block min-w-0", children: valueNode })), !editing && note ? (_jsx(FieldNoteLine, { note: typeof note === "string" ? { text: note } : note })) : null, !editing && error && retryDraft ? (_jsx("div", { role: "alert", className: "mt-1 text-xs text-(color:--vk-danger)", children: _jsx("button", { type: "button", "data-slot": "vk-field-retry", onClick: () => {
|
|
342
|
+
}), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton || wordsLink ? (_jsxs("div", { className: "relative min-w-0", "data-field-row-words": wordsLink ? "" : undefined, children: [editButton("under", actIcon), _jsx("span", { "data-slot": "vk-row-value-layer", className: cx("pointer-events-none relative block min-w-0 [&_a]:pointer-events-auto [&_button]:pointer-events-auto", pending && "opacity-70"), children: valueNode })] })) : openType ? (_jsxs("div", { className: "flex min-w-0 items-center gap-1", children: [editButton("beside", _jsxs(_Fragment, { children: [valueNode, actIcon] })), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton("target", _jsxs(_Fragment, { children: [valueNode, actIcon] })))) : (_jsx("span", { className: "block min-w-0", children: valueNode })), !editing && note ? (_jsx(FieldNoteLine, { note: typeof note === "string" ? { text: note } : note })) : null, !editing && error && retryDraft ? (_jsx("div", { role: "alert", className: "mt-1 text-xs text-(color:--vk-danger)", children: _jsx("button", { type: "button", "data-slot": "vk-field-retry", onClick: () => {
|
|
321
343
|
setError(null);
|
|
322
344
|
const retried = attempt({ kind: "commit", payload: retryDraft.commit });
|
|
323
345
|
if (!retried.accepted)
|
|
@@ -7,12 +7,14 @@ import { ChipsEditor } from "../../editors/ChipsEditor.js";
|
|
|
7
7
|
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
8
8
|
import { offeredValues, takesNewValues, useOpenValues } from "../../editors/open-values.js";
|
|
9
9
|
import { OPTION_ROW_INSET } from "./host.js";
|
|
10
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
10
11
|
import { useRowEditSession } from "./row-session.js";
|
|
11
12
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
12
13
|
export function RowChipsEditor({ binding, field, initial, anchor, onAttempt, onClose, message, }) {
|
|
13
14
|
const panel = bodyPanel("picker", "z-90");
|
|
14
15
|
const editorRef = useRef(null);
|
|
15
16
|
const anchorRef = useRef(null);
|
|
17
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
|
|
16
18
|
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
17
19
|
const known = useOpenValues(field);
|
|
18
20
|
const values = Array.isArray(initial)
|
|
@@ -23,5 +25,5 @@ export function RowChipsEditor({ binding, field, initial, anchor, onAttempt, onC
|
|
|
23
25
|
label: optionFor(field, value)?.label ?? value,
|
|
24
26
|
color: resolveCategoryColor(value, field.options, undefined),
|
|
25
27
|
});
|
|
26
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset:
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offeredValues(field, known), resolve: resolve, normalize: normalizerFor(field), creatable: takesNewValues(field), onRequestClose: close, message: message, label: field.label, addOption: binding.addOption }) }) })] }));
|
|
27
29
|
}
|
|
@@ -3,10 +3,12 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
3
3
|
import { useRef } from "react";
|
|
4
4
|
import { DateEditorHost } from "../../editors/DateEditor.js";
|
|
5
5
|
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
6
7
|
import { useRowEditSession } from "./row-session.js";
|
|
7
8
|
export function RowDateEditor({ field, initial, anchor, onAttempt, onClose, message, }) {
|
|
8
9
|
const editorRef = useRef(null);
|
|
9
10
|
const anchorRef = useRef(null);
|
|
11
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
|
|
10
12
|
const dayOnly = field.type === "date";
|
|
11
13
|
const { session, close, sheet } = useRowEditSession({
|
|
12
14
|
editorRef,
|
|
@@ -14,5 +16,5 @@ export function RowDateEditor({ field, initial, anchor, onAttempt, onClose, mess
|
|
|
14
16
|
onClose,
|
|
15
17
|
mapPayload: (payload) => (payload === "" ? null : dayOnly ? payload.slice(0, 10) : payload),
|
|
16
18
|
});
|
|
17
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset:
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, chrome: "menu", className: "z-90 w-auto", children: () => (_jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(DateEditorHost, { ref: editorRef, label: field.label, initial: typeof initial === "string" && initial !== "" ? initial : undefined, timeOptional: dayOnly, dayOnly: dayOnly, clearable: !!field.nullable, focusDate: !sheet, onRequestClose: close, message: message }) })) })] }));
|
|
18
20
|
}
|
|
@@ -5,6 +5,7 @@ import { isNameValue } from "viewkitjs/fields";
|
|
|
5
5
|
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
6
|
import { NameEditor } from "../../editors/NameEditor.js";
|
|
7
7
|
import { useViews } from "../../provider/context.js";
|
|
8
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
8
9
|
import { useRowEditSession } from "./row-session.js";
|
|
9
10
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
10
11
|
export function RowNameEditor({ field, initial, anchor, onAttempt, onClose, }) {
|
|
@@ -12,7 +13,8 @@ export function RowNameEditor({ field, initial, anchor, onAttempt, onClose, }) {
|
|
|
12
13
|
const { conventions } = useViews();
|
|
13
14
|
const editorRef = useRef(null);
|
|
14
15
|
const anchorRef = useRef(null);
|
|
16
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
|
|
15
17
|
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
16
18
|
const editor = (_jsx(NameEditor, { ref: editorRef, initial: isNameValue(initial) ? initial : null, allowEmpty: !!field.nullable, conventions: conventions, label: field.label, onRequestClose: close }));
|
|
17
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset:
|
|
19
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: (surface) => _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor }) })] }));
|
|
18
20
|
}
|
|
@@ -4,6 +4,7 @@ import { useRef } from "react";
|
|
|
4
4
|
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
5
5
|
import { LocationEditor } from "../../editors/LocationEditor.js";
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
7
8
|
import { useRowEditSession } from "./row-session.js";
|
|
8
9
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
9
10
|
export function RowPlaceEditor({ field, initial, anchor, onAttempt, onClose, }) {
|
|
@@ -11,10 +12,11 @@ export function RowPlaceEditor({ field, initial, anchor, onAttempt, onClose, })
|
|
|
11
12
|
const { conventions } = useViews();
|
|
12
13
|
const editorRef = useRef(null);
|
|
13
14
|
const anchorRef = useRef(null);
|
|
15
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
|
|
14
16
|
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
15
17
|
const place = initial && typeof initial === "object" && !Array.isArray(initial) ? initial : null;
|
|
16
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset:
|
|
18
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: (surface) => {
|
|
17
19
|
const editor = (_jsx(LocationEditor, { ref: editorRef, field: field, initial: place, allowEmpty: true, conventions: conventions, label: field.label, onRequestClose: close }));
|
|
18
|
-
return surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor;
|
|
20
|
+
return _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor });
|
|
19
21
|
} })] }));
|
|
20
22
|
}
|
|
@@ -6,6 +6,7 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
|
6
6
|
import { RangeEditor } from "../../editors/RangeEditor.js";
|
|
7
7
|
import { numberBounds } from "../../editors/number-body.js";
|
|
8
8
|
import { useViews } from "../../provider/context.js";
|
|
9
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
9
10
|
import { useRowEditSession } from "./row-session.js";
|
|
10
11
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
11
12
|
export function RowRangeEditor({ field, initial, anchor, onAttempt, onClose, }) {
|
|
@@ -13,7 +14,8 @@ export function RowRangeEditor({ field, initial, anchor, onAttempt, onClose, })
|
|
|
13
14
|
const { conventions } = useViews();
|
|
14
15
|
const editorRef = useRef(null);
|
|
15
16
|
const anchorRef = useRef(null);
|
|
17
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
|
|
16
18
|
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
17
19
|
const editor = (_jsx(RangeEditor, { ref: editorRef, initial: isRangeValue(initial) ? initial : null, decimals: rangeDecimals(field), allowEmpty: !!field.nullable, suffix: field.of === "percent" ? "%" : field.of === "currency" ? field.code?.fixed : undefined, bands: field.presets, ...numberBounds(field), conventions: conventions, label: field.label, onRequestClose: close }));
|
|
18
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset:
|
|
20
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", sideOffset: opens.sideOffset, alignOffset: opens.alignOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: (surface) => _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor }) })] }));
|
|
19
21
|
}
|
|
@@ -7,6 +7,7 @@ import { RelationEditor, RelationSetEditor, } from "../../editors/RelationEditor
|
|
|
7
7
|
import { useKnownKinds } from "../../editors/relation-kinds.js";
|
|
8
8
|
import { useViews } from "../../provider/context.js";
|
|
9
9
|
import { OPTION_ROW_INSET } from "./host.js";
|
|
10
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
10
11
|
import { useRowEditSession } from "./row-session.js";
|
|
11
12
|
import { bodyPanel, useSetBody } from "../../editors/body-panel.js";
|
|
12
13
|
export function RowRelationEditor(props) {
|
|
@@ -25,6 +26,7 @@ function RowRelationOneEditor({ binding, field, initial, anchor, onAttempt, onCl
|
|
|
25
26
|
const panel = bodyPanel("picker", "z-90");
|
|
26
27
|
const editorRef = useRef(null);
|
|
27
28
|
const anchorRef = useRef(null);
|
|
29
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
|
|
28
30
|
const kindGlyph = useKindGlyph(field, kindIcon);
|
|
29
31
|
const [candidates, kindOf] = useKnownKinds(binding.relation ?? { kind: "static", items: [] });
|
|
30
32
|
const { session, close, sheet } = useRowEditSession({
|
|
@@ -40,12 +42,13 @@ function RowRelationOneEditor({ binding, field, initial, anchor, onAttempt, onCl
|
|
|
40
42
|
});
|
|
41
43
|
if (!binding.relation)
|
|
42
44
|
return null;
|
|
43
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset:
|
|
45
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(RelationEditor, { ref: editorRef, candidates: candidates, initial: relationIdOf(initial), clearable: !!field.nullable, kindGlyph: kindGlyph, focusSearch: !sheet, onRequestClose: close, message: message, label: field.label }) }) })] }));
|
|
44
46
|
}
|
|
45
47
|
function RowRelationSetEditor({ binding, field, initial, shown, anchor, onAttempt, onClose, message, kindIcon, }) {
|
|
46
48
|
const panel = bodyPanel(useSetBody(field.links), "z-90");
|
|
47
49
|
const editorRef = useRef(null);
|
|
48
50
|
const anchorRef = useRef(null);
|
|
51
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
|
|
49
52
|
const kindGlyph = useKindGlyph(field, kindIcon);
|
|
50
53
|
const { session, close, sheet } = useRowEditSession({
|
|
51
54
|
editorRef,
|
|
@@ -56,7 +59,7 @@ function RowRelationSetEditor({ binding, field, initial, shown, anchor, onAttemp
|
|
|
56
59
|
const candidates = binding.relation;
|
|
57
60
|
if (!candidates)
|
|
58
61
|
return null;
|
|
59
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset:
|
|
62
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(RelationSetEditor, { ref: editorRef, candidates: candidates, initial: setItems(field, initial, shown, candidates), lead: field.links?.primary === "flag", links: field.links, kindGlyph: kindGlyph, focusSearch: !sheet, onRequestClose: close, message: message, label: field.label }) }) })] }));
|
|
60
63
|
}
|
|
61
64
|
function setItems(field, initial, shown, candidates) {
|
|
62
65
|
const labels = new Map();
|
|
@@ -7,12 +7,14 @@ import { statusSteps } from "../../display/status-steps.js";
|
|
|
7
7
|
import { useOpenValues } from "../../editors/open-values.js";
|
|
8
8
|
import { SelectEditor, pickerOptionsFromField, } from "../../editors/SelectEditor.js";
|
|
9
9
|
import { OPTION_ROW_INSET } from "./host.js";
|
|
10
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
10
11
|
import { useRowEditSession } from "./row-session.js";
|
|
11
12
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
12
13
|
export function RowSelectEditor({ binding, field, initial, anchor, onAttempt, onClose, message, openedByKey = false, }) {
|
|
13
14
|
const panel = bodyPanel("picker", "z-90");
|
|
14
15
|
const editorRef = useRef(null);
|
|
15
16
|
const anchorRef = useRef(null);
|
|
17
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4, alignOffset: -OPTION_ROW_INSET });
|
|
16
18
|
const known = useOpenValues(field);
|
|
17
19
|
const current = typeof initial === "string" ? initial : null;
|
|
18
20
|
const options = useMemo(() => pickerOptionsFromField(field, { extraValues: known, current }), [field, known, current]);
|
|
@@ -22,5 +24,5 @@ export function RowSelectEditor({ binding, field, initial, anchor, onAttempt, on
|
|
|
22
24
|
onClose,
|
|
23
25
|
mapPayload: (payload) => (payload === "" ? null : payload),
|
|
24
26
|
});
|
|
25
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset:
|
|
27
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, className: "block min-w-0", children: anchor }), _jsx(EditorPanel, { panelData: panel.data, session: session, title: field.label, anchor: anchorRef, align: "start", alignOffset: opens.alignOffset, sideOffset: opens.sideOffset, style: opens.style, initialFocus: false, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx("span", { ref: onBody, style: { display: "contents" }, children: _jsx(SelectEditor, { ref: editorRef, options: options, steps: statusSteps(field), initial: current, clearable: !!field.nullable, creatable: isOpenVocabulary(field), focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, message: message, label: field.label, addOption: field.type === "select" ? binding.addOption : undefined }) }) })] }));
|
|
26
28
|
}
|