viewkitjs 0.37.0 → 0.39.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 +95 -0
- package/MIGRATION.md +7 -0
- 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/docs/reference/query.md +3 -3
- package/package.json +1 -1
- package/postgres/docs/guides/field-map.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 +25 -11
- package/views/dist/contract.js +41 -6
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +9 -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 +93 -1
- 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 +13 -2
- package/views/dist/controls/filter-editor/filter-editor.js +45 -15
- package/views/dist/controls/filter-editor/how.d.ts +3 -1
- package/views/dist/controls/filter-editor/map-filter-body.js +5 -4
- package/views/dist/controls/filter-editor/map-rules.d.ts +2 -1
- package/views/dist/controls/filter-editor/map-rules.js +3 -3
- package/views/dist/controls/glyphs/glyphs.js +2 -0
- package/views/dist/controls/inline-input.css +3 -2
- 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/read-token.d.ts +2 -1
- package/views/dist/controls/internal/read-token.js +2 -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/number-editor/tokens.d.ts +8 -0
- package/views/dist/controls/number-editor/tokens.js +2 -0
- package/views/dist/controls/number-editor.css +20 -0
- 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/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/tokens.d.ts +8 -0
- package/views/dist/controls/text-editor/tokens.js +2 -0
- package/views/dist/controls/text-editor.css +44 -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/controls/tooltip/tooltip.js +2 -1
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +46 -15
- 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 +25 -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 +21 -6
- package/views/dist/field-row/field-row-button.js +8 -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/fields/binding.d.ts +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/GridCellEditors.d.ts +1 -1
- package/views/dist/grid/chrome/GridCellOutline.d.ts +13 -1
- package/views/dist/grid/chrome/GridCellOutline.js +17 -0
- 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/GridNumberEditor.js +2 -1
- package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
- package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
- package/views/dist/grid/chrome/GridRowCells.js +1 -1
- package/views/dist/grid/chrome/GridStructure.js +3 -3
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTableSurface.js +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +3 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
- package/views/dist/grid/chrome/grid-body-place.js +4 -4
- package/views/dist/grid/chrome/grid-edit-session.d.ts +7 -3
- package/views/dist/grid/chrome/grid-edit-session.js +12 -3
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +5 -4
- package/views/dist/grid/chrome/grid-figure-value.js +10 -4
- package/views/dist/grid/chrome/grid-row-props.d.ts +1 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +11 -3
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +5 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +9 -5
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +8 -3
- package/views/dist/grid/grid.css +7 -3
- package/views/dist/internal/length.d.ts +2 -0
- package/views/dist/internal/length.js +16 -0
- 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 +5 -0
- package/views/dist/list/bar-keys.js +2 -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 +15 -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 +9 -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 +91 -0
- package/views/dist/list/buttons/shared.js +131 -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 +36 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/line.d.ts +55 -0
- package/views/dist/list/line.js +221 -0
- 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 +67 -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 +25 -0
- package/views/dist/list/panels/shared.js +33 -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 +17 -0
- package/views/dist/list/root-base.js +9 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +19 -0
- package/views/dist/list/store.js +40 -1
- package/views/dist/list/toolbar-model.d.ts +95 -0
- package/views/dist/list/toolbar-model.js +177 -0
- package/views/dist/list/toolbar.js +140 -328
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- 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 +2 -2
- 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 +57 -0
- 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/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 +8 -1
- 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 +7 -0
- package/views/dist/provider/components.d.ts +38 -3
- package/views/dist/react.d.ts +1 -1
- package/views/dist/selection/bar-overflow.d.ts +2 -0
- package/views/dist/selection/bar-overflow.js +2 -1
- package/views/dist/selection/bar-props.d.ts +1 -1
- package/views/dist/selection/verbs.d.ts +2 -2
- package/views/dist/styles.css +268 -5
- package/views/dist/styles.unlayered.css +268 -5
- package/views/docs/contract.md +29 -15
- package/views/docs/controls/field.md +1 -0
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/menu.md +1 -1
- package/views/docs/controls/number-editor.md +2 -0
- package/views/docs/controls/sort-editor.md +1 -1
- package/views/docs/controls/text-editor.md +2 -0
- package/views/docs/guides/atoms.md +1 -0
- package/views/docs/guides/selection.md +1 -1
- package/views/docs/guides/the-grid.md +3 -3
- package/views/docs/reference/controls.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +4 -4
- package/views/docs/reference/list.md +168 -6
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/react.md +13 -10
- package/views/docs/reference/selection.md +1 -1
- package/views/docs/reference/views.md +9 -7
- package/views/skills/views/SKILL.md +2 -1
|
@@ -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
|
}
|
|
@@ -46,6 +46,14 @@ export declare const TEXT_EDITOR_TOKENS: readonly [{
|
|
|
46
46
|
readonly name: "--vk-radius-md";
|
|
47
47
|
readonly kind: "size";
|
|
48
48
|
readonly outright: "--radius-md";
|
|
49
|
+
}, {
|
|
50
|
+
readonly name: "--vk-shadow-field-focus";
|
|
51
|
+
readonly kind: "shadow";
|
|
52
|
+
readonly outright: "--shadow-field-focus";
|
|
53
|
+
}, {
|
|
54
|
+
readonly name: "--vk-shadow-field-focus-danger";
|
|
55
|
+
readonly kind: "shadow";
|
|
56
|
+
readonly outright: "--shadow-field-focus-danger";
|
|
49
57
|
}, {
|
|
50
58
|
readonly name: "--vk-shadow-lg";
|
|
51
59
|
readonly kind: "shadow";
|
|
@@ -11,6 +11,8 @@ export const TEXT_EDITOR_TOKENS = [
|
|
|
11
11
|
{ name: "--vk-line-height-xs", kind: "size", outright: "--text-xs--line-height" },
|
|
12
12
|
{ name: "--vk-overlay", kind: "colour", outright: "--surface-overlay" },
|
|
13
13
|
{ name: "--vk-radius-md", kind: "size", outright: "--radius-md" },
|
|
14
|
+
{ name: "--vk-shadow-field-focus", kind: "shadow", outright: "--shadow-field-focus" },
|
|
15
|
+
{ name: "--vk-shadow-field-focus-danger", kind: "shadow", outright: "--shadow-field-focus-danger" },
|
|
14
16
|
{ name: "--vk-shadow-lg", kind: "shadow", outright: "--shadow-lg" },
|
|
15
17
|
{ name: "--vk-shadow-menu", kind: "shadow", outright: "--shadow-menu" },
|
|
16
18
|
{ name: "--vk-spacing", kind: "size", outright: "--spacing" },
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
width: max(100%, calc(var(--vk-spacing) * 75)); max-width: none; max-height: calc(var(--vk-spacing) * 80);
|
|
36
36
|
box-shadow: var(--vk-shadow-lg), inset 0 0 0 var(--inline-input-ring, 0px) var(--inline-input-colour);
|
|
37
37
|
}
|
|
38
|
-
/* In a grid's cell (data-inline-input-place="cell", inline-input.css), never lifted, grown or long: the cell typed in
|
|
39
|
-
the
|
|
38
|
+
/* In a grid's cell (data-inline-input-place="cell", inline-input.css), never lifted, grown or long: the cell typed in wears only
|
|
39
|
+
the selected cell's ring. (0,5,0): over the two lifts above. */
|
|
40
40
|
[data-inline-input-place="cell"] .o-text-editor[data-text-box][data-grown] .o-text-editor-box,
|
|
41
41
|
[data-inline-input-place="cell"] .o-text-editor[data-text-box][data-text-kind="long"] .o-text-editor-box {
|
|
42
42
|
box-shadow: inset 0 0 0 var(--inline-input-ring, 0px) var(--inline-input-colour);
|
|
@@ -79,6 +79,48 @@
|
|
|
79
79
|
.o-text-editor[data-text-place="row"][data-text-form] .o-text-editor-phone { position: relative; top: auto; left: auto; width: 100%; height: var(--inline-input-row); }
|
|
80
80
|
.o-text-editor[data-text-place="row"][data-text-form] .o-text-editor-note { position: relative; top: auto; left: auto; margin-top: var(--vk-spacing); max-width: 100%; }
|
|
81
81
|
|
|
82
|
+
/* ── In a record's row that wears the Field's Box (data-field-row-box="box" on a frame round the rows; the row marks its open
|
|
83
|
+
editor data-field-row-editor): on a computer the box is the row's own, the rectangle its hover and its press drew. It stands
|
|
84
|
+
where that rectangle stood, pulled out by the box's reach and its height round the row's one line (the row's
|
|
85
|
+
--field-row-box-* variables, field.css), its words that reach in, no edge of its own, the row's ground: so
|
|
86
|
+
not a pixel of the words moves and the row keeps its height. Its ring is drawn outside it, a line of the brand and the
|
|
87
|
+
focus glow, red when refused. A line of text stays one line, scrolling sideways; long text still grows. A phone's form is
|
|
88
|
+
the phone's own. ─────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
89
|
+
:where([data-field-row-box="box"] [data-field-row-editor]) .o-text-editor[data-text-place="row"][data-text-form="computer"] {
|
|
90
|
+
--inline-input-row: var(--field-row-box-h); --inline-input-edge: 0px; --inline-input-ring: 0px;
|
|
91
|
+
width: calc(100% + var(--field-row-box-x) * 2); margin: calc(var(--field-row-box-y) * -1) calc(var(--field-row-box-x) * -1);
|
|
92
|
+
}
|
|
93
|
+
:where([data-field-row-box="box"] [data-field-row-editor]) .o-text-editor[data-text-place="row"][data-text-form="computer"] :is(.o-text-editor-box, .o-text-editor-phone) {
|
|
94
|
+
--inline-input-words: var(--field-row-box-x); border-radius: var(--field-row-box-r); background-color: transparent;
|
|
95
|
+
box-shadow: 0 0 0 var(--vk-border-width) var(--inline-input-colour), var(--vk-shadow-field-focus);
|
|
96
|
+
}
|
|
97
|
+
:where([data-field-row-box="box"] [data-field-row-editor]) .o-text-editor[data-text-place="row"][data-text-form="computer"] :is(.o-text-editor-box, .o-text-editor-phone):is([aria-invalid="true"], [data-refused]) {
|
|
98
|
+
box-shadow: 0 0 0 var(--vk-border-width) var(--inline-input-colour), var(--vk-shadow-field-focus-danger);
|
|
99
|
+
}
|
|
100
|
+
:where([data-field-row-box="box"] [data-field-row-editor]) .o-text-editor[data-text-place="row"][data-text-form="computer"]:not([data-text-kind="long"]) .o-text-editor-box {
|
|
101
|
+
white-space: pre; overflow: hidden;
|
|
102
|
+
}
|
|
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. (0,5,0): over the
|
|
109
|
+
row's place. ─────────────────────────────────────────────────────────────────────────────────────────────────────────────── */
|
|
110
|
+
.o-popover[data-field-row-long-editor] { --popover-pad: 0px; }
|
|
111
|
+
[data-field-row-long-editor] .o-text-editor[data-text-place="row"][data-text-form="computer"] {
|
|
112
|
+
--inline-input-row: var(--vk-field-row-box-h, calc(var(--vk-spacing) * 8)); --inline-input-edge: 0px; --inline-input-ring: 0px;
|
|
113
|
+
}
|
|
114
|
+
[data-field-row-long-editor] .o-text-editor[data-text-place="row"][data-text-form] .o-text-editor-box {
|
|
115
|
+
--inline-input-words: var(--vk-field-row-box-x, calc(var(--vk-spacing) * 2));
|
|
116
|
+
max-height: var(--vk-editor-max-h, calc(var(--vk-spacing) * 80)); border-radius: 0; background-color: transparent; box-shadow: none;
|
|
117
|
+
}
|
|
118
|
+
/* 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
|
|
119
|
+
target did at rest, so its lines break where they did. */
|
|
120
|
+
: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 {
|
|
121
|
+
padding-right: calc(var(--vk-spacing) * 8 - var(--inline-input-e));
|
|
122
|
+
}
|
|
123
|
+
|
|
82
124
|
/* ── 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 ──── */
|
|
83
125
|
.o-text-editor[data-text-form="phone"] { display: grid; }
|
|
84
126
|
.o-text-editor[data-text-form="phone"] .o-text-editor-country { gap: calc(var(--vk-spacing) * 0.75); }
|
|
@@ -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)
|
|
@@ -3,6 +3,7 @@ import * as React from "react";
|
|
|
3
3
|
import { Tooltip as BaseTooltip } from "@base-ui/react/tooltip";
|
|
4
4
|
import { cx } from "../../internal/cx.js";
|
|
5
5
|
import { usePopupHost } from "../internal/popup-host.js";
|
|
6
|
+
import { pxOf } from "../internal/read-token.js";
|
|
6
7
|
import { Kbd } from "../kbd/kbd.js";
|
|
7
8
|
export const TOOLTIP_TIMING = { delay: 500, warm: 300, tap: 4000 };
|
|
8
9
|
function readMs(el, name, fallback) {
|
|
@@ -11,7 +12,7 @@ function readMs(el, name, fallback) {
|
|
|
11
12
|
}
|
|
12
13
|
const GroupWarm = React.createContext(null);
|
|
13
14
|
const Box = ({ label, keys }) => _jsxs(_Fragment, { children: [label, keys && _jsx(Kbd, { keys: keys })] });
|
|
14
|
-
const gap = (trigger, popup) => (
|
|
15
|
+
const gap = (trigger, popup) => (pxOf(popup, "--vk-spacing") || 4) * (trigger?.closest('[data-tooltip-arrow="soft"]') ? 2.5 : 1.5);
|
|
15
16
|
export function Tooltip({ label, keys, reason, side = "top", align = "center", sideOffset, alignOffset = 0, open, defaultOpen, onOpenChange, disabled, delay, className, children }) {
|
|
16
17
|
const ref = React.useRef(null), popup = React.useRef(null), host = usePopupHost(ref), id = React.useId();
|
|
17
18
|
const [wait, setWait] = React.useState(TOOLTIP_TIMING.delay), tellWarm = React.useContext(GroupWarm);
|
|
@@ -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) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { memo, useContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
4
4
|
import { optimisticDisplay, phoneText, presentedDef, resolveFieldMessage, } from "viewkitjs/fields";
|
|
5
5
|
import { ConvertedFigure } from "../display/converted.js";
|
|
@@ -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
|
-
import { FIELD_ROW_FRAME, FIELD_ROW_FRAME_BESIDE, FIELD_ROW_FRAME_ROWS, FIELD_ROW_FRAME_ROWS_UNDER, FIELD_ROW_FRAME_UNDER, FieldRowButton, drawFieldRowButton, } from "./field-row-button.js";
|
|
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,8 +261,21 @@ 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
|
};
|
|
269
|
+
const action = binding.action ??
|
|
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");
|
|
277
|
+
const Act = inRows || action === "none" ? null : icons[action];
|
|
278
|
+
const actIcon = Act ? (_jsx("span", { "data-field-row-act": action, "aria-hidden": "true", className: "hidden", children: _jsx(Act, { className: "size-3.75" }) })) : null;
|
|
254
279
|
const frameOf = (shape) => inRows
|
|
255
280
|
? shape === "under"
|
|
256
281
|
? FIELD_ROW_FRAME_ROWS_UNDER
|
|
@@ -262,8 +287,13 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
262
287
|
: shape === "beside"
|
|
263
288
|
? FIELD_ROW_FRAME_BESIDE
|
|
264
289
|
: FIELD_ROW_FRAME;
|
|
265
|
-
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, "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 }));
|
|
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 }));
|
|
266
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
|
+
});
|
|
267
297
|
const downWhileEditing = useRef(false);
|
|
268
298
|
const pressOpens = inRows && writable && shownDef.type !== "boolean" && !hasMenu && !unread && !editing && !pending && ready;
|
|
269
299
|
const onRowPress = (event) => {
|
|
@@ -287,7 +317,7 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
287
317
|
?
|
|
288
318
|
cx("o-field-row py-3", pressOpens && "cursor-pointer")
|
|
289
319
|
:
|
|
290
|
-
"group/field-row grid content-center items-start data-[form=computer]:grid-cols-[auto_var(--vk-field-row-label-w,calc(var(--spacing)*32))_minmax(0,1fr)_auto] data-[form=computer]:in-data-[field-row-icon=off]:grid-cols-[var(--vk-field-row-label-w,calc(var(--spacing)*32))_minmax(0,1fr)_auto] data-[form=phone]:grid-cols-[auto_minmax(0,1fr)_auto] data-[form=phone]:gap-y-1", !inRows && FIELD_ROW_FRAME_READS), "aria-busy": pending ? "true" : undefined, onClick: inRows ? onRowPress : undefined, onPointerDown: inRows
|
|
320
|
+
"group/field-row grid content-center items-start data-[form=computer]:grid-cols-[auto_var(--vk-field-row-label-w,calc(var(--spacing)*32))_minmax(0,1fr)_auto] data-[form=computer]:in-data-[field-row-icon=off]:grid-cols-[var(--vk-field-row-label-w,calc(var(--spacing)*32))_minmax(0,1fr)_auto] data-[form=phone]:grid-cols-[auto_minmax(0,1fr)_auto] data-[form=phone]:gap-y-1", !inRows && FIELD_ROW_FRAME_READS), "data-field-row": inRows ? undefined : "", "aria-busy": pending ? "true" : undefined, onClick: inRows ? onRowPress : undefined, onPointerDown: inRows
|
|
291
321
|
? () => {
|
|
292
322
|
downWhileEditing.current = editing;
|
|
293
323
|
}
|
|
@@ -295,20 +325,21 @@ function FieldRowImpl({ binding, row, value, editValue, writable, ready = true,
|
|
|
295
325
|
? "o-field-row-glyph"
|
|
296
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
|
|
297
327
|
? "o-field-row-label"
|
|
298
|
-
: "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", { 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 })) : (
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
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, {
|
|
305
335
|
frame: inRows ? FIELD_ROW_FRAME_ROWS : FIELD_ROW_FRAME,
|
|
336
|
+
...(inRows ? {} : { "data-key": TARGET_KEY.target }),
|
|
306
337
|
variant: "ghost",
|
|
307
338
|
size: "sm",
|
|
308
339
|
"aria-label": field.label,
|
|
309
340
|
disabled: !ready,
|
|
310
341
|
children: valueNode,
|
|
311
|
-
}), items: menuItems, align: "start" })) : writable && shownDef.type !== "boolean" ? (valueOverButton ? (_jsxs("div", { className: "relative min-w-0", children: [editButton("under"), _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", valueNode), _jsx(OpenValueAction, { type: openType, value: openValue, label: openLabel, compact: true })] })) : (editButton("target", valueNode))) : (_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: () => {
|
|
312
343
|
setError(null);
|
|
313
344
|
const retried = attempt({ kind: "commit", payload: retryDraft.commit });
|
|
314
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
|
}
|