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
|
@@ -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
|
}
|
|
@@ -11,5 +11,11 @@ import type { RowHostProps } from "./host.js";
|
|
|
11
11
|
* throws the edit away. A `long` text is a paragraph, where Enter is a newline
|
|
12
12
|
* and ⌘/Ctrl+Enter closes. The row's session asks whether the answer may
|
|
13
13
|
* close: a refused one keeps the box open with its draft and its reason under it.
|
|
14
|
+
*
|
|
15
|
+
* UNDER THE FIELD'S LONG (`row-long: line`, read by the row as it opened, `RowLongContext`), on a computer, a long text opens on top
|
|
16
|
+
* of the row's box instead: the row keeps its value, one line, as the anchor, and the box stands in a popover over it, placed as the
|
|
17
|
+
* Field's Open places a body (`useRowBodyPlace`, over whatever that option says), the box's first line where the words were. It
|
|
18
|
+
* grows down over the rows below to the editor's most height (`--vk-editor-max-h`, text-editor.css), then scrolls; the row never
|
|
19
|
+
* moves. Its keys are the same; a press outside closes it as the popover's, a blur alone doesn't. A phone keeps its box in place.
|
|
14
20
|
*/
|
|
15
|
-
export declare function RowTextEditor<Row>({ field, binding, row, initial, onAttempt, onClose, }: RowHostProps<Row, "text" | "url" | "domain" | "email" | "phone" | "rich_text">): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function RowTextEditor<Row>({ field, binding, row, initial, anchor, onAttempt, onClose, }: RowHostProps<Row, "text" | "url" | "domain" | "email" | "phone" | "rich_text">): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,17 +1,36 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef } from "react";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useContext, useRef, useState } from "react";
|
|
4
4
|
import { acceptFieldCommit, phoneText } from "viewkitjs/fields";
|
|
5
5
|
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
6
|
import { TextEditorHost } from "../../editors/TextEditor.js";
|
|
7
7
|
import { useViews } from "../../provider/context.js";
|
|
8
|
+
import { useDesktop } from "../../provider/desktop.js";
|
|
9
|
+
import { RowLongContext, useRowBodyPlace } from "./row-place.js";
|
|
8
10
|
import { RowRefusal, useRowEditSession } from "./row-session.js";
|
|
9
|
-
export function RowTextEditor({ field, binding, row, initial, onAttempt, onClose, }) {
|
|
11
|
+
export function RowTextEditor({ field, binding, row, initial, anchor, onAttempt, onClose, }) {
|
|
10
12
|
const editorRef = useRef(null);
|
|
11
13
|
const anchorRef = useRef(null);
|
|
12
14
|
const baseline = field.type === "phone" ? phoneText(initial, null) : typeof initial === "string" ? initial : "";
|
|
13
15
|
const long = (field.type === "text" && !!field.format?.long) || field.type === "rich_text";
|
|
14
|
-
const
|
|
16
|
+
const longLine = useContext(RowLongContext);
|
|
17
|
+
const desktop = useDesktop();
|
|
18
|
+
const [over] = useState(() => long && longLine && desktop);
|
|
19
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 }, { over: over ? "force" : "auto" });
|
|
20
|
+
const [edge, setEdge] = useState();
|
|
21
|
+
const onAnchor = useCallback((el) => {
|
|
22
|
+
anchorRef.current = el;
|
|
23
|
+
const box = el?.querySelector("[data-field-row-anchor]");
|
|
24
|
+
if (!box)
|
|
25
|
+
return;
|
|
26
|
+
const s = getComputedStyle(box);
|
|
27
|
+
const sides = [s.borderTopWidth, s.borderRightWidth, s.borderBottomWidth, s.borderLeftWidth];
|
|
28
|
+
if (!sides.some((w) => parseFloat(w) > 0))
|
|
29
|
+
return;
|
|
30
|
+
const most = s.getPropertyValue("--vk-editor-max-h").trim() || "calc(var(--vk-spacing) * 80)";
|
|
31
|
+
setEdge({ padding: sides.join(" "), "--vk-editor-max-h": `calc(${most} - ${sides[0]} - ${sides[2]})` });
|
|
32
|
+
}, []);
|
|
33
|
+
const { session, close } = useRowEditSession({ editorRef, inPlace: !over, onAttempt, onClose });
|
|
15
34
|
const { conventions } = useViews();
|
|
16
35
|
const region = binding.region?.(row) ?? undefined;
|
|
17
36
|
const check = (text) => {
|
|
@@ -20,5 +39,7 @@ export function RowTextEditor({ field, binding, row, initial, onAttempt, onClose
|
|
|
20
39
|
const read = acceptFieldCommit(field, text, { conventions, region, stored: initial });
|
|
21
40
|
return read.ok ? null : read.reason;
|
|
22
41
|
};
|
|
42
|
+
if (over)
|
|
43
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: onAnchor, 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, panelData: { "data-field-row-long-editor": "" }, className: "z-90 max-w-[calc(100vw-2rem)]", children: _jsx("span", { ref: onBody, style: edge ? { display: "flex", flexDirection: "column", flex: "1 1 auto", minHeight: 0, ...edge } : { display: "contents" }, children: _jsx(TextEditorHost, { ref: editorRef, type: field.type, multiline: true, initial: baseline, label: field.label, closeOnBlur: false, onRequestClose: close, check: check, region: region, escapeKeeps: session.keeps ?? false, place: "row" }) }) })] }));
|
|
23
44
|
return (_jsxs(EditorPanel, { session: session, title: field.label, anchor: anchorRef, inPlace: true, children: [_jsx(TextEditorHost, { ref: editorRef, type: field.type, multiline: long, initial: baseline, label: field.label, onRequestClose: close, check: check, region: region, escapeKeeps: session.keeps ?? false, place: "row" }), _jsx(RowRefusal, { text: session.refusal })] }));
|
|
24
45
|
}
|
|
@@ -7,6 +7,7 @@ import { opensAsList } from "../../model/one-value.js";
|
|
|
7
7
|
import { ValueListEditor } from "../../editors/ValueListEditor.js";
|
|
8
8
|
import { listOfOne, oneOfList } from "../../editors/values-body.js";
|
|
9
9
|
import { useViews } from "../../provider/context.js";
|
|
10
|
+
import { useRowBodyPlace } from "./row-place.js";
|
|
10
11
|
import { RowTextEditor } from "./RowTextEditor.js";
|
|
11
12
|
import { useRowEditSession } from "./row-session.js";
|
|
12
13
|
import { bodyPanel } from "../../editors/body-panel.js";
|
|
@@ -17,12 +18,11 @@ function RowValueListEditor({ field, binding, row, initial, anchor, onAttempt, o
|
|
|
17
18
|
const oneRef = useRef({ resolveClose: (reason) => oneOfList(listRef.current.resolveClose(reason)) });
|
|
18
19
|
const editorRef = one ? oneRef : listRef;
|
|
19
20
|
const anchorRef = useRef(null);
|
|
21
|
+
const { onBody, ...opens } = useRowBodyPlace(anchorRef, { sideOffset: 4 });
|
|
20
22
|
const { session, close } = useRowEditSession({ editorRef, onAttempt, onClose });
|
|
21
|
-
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:
|
|
23
|
+
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) => {
|
|
22
24
|
const editor = (_jsx(ValueListEditor, { ref: listRef, field: field, label: field.label, initial: one ? listOfOne(initial) : initial, labels: binding.labels !== false && !one, holds: holds, allowEmpty: true, region: binding.region?.(row), escapeKeeps: session.keeps ?? false, onRequestClose: close }));
|
|
23
|
-
|
|
24
|
-
return editor;
|
|
25
|
-
return _jsx("div", { className: "px-4 pb-4", children: editor });
|
|
25
|
+
return _jsx("span", { ref: onBody, style: { display: "contents" }, children: surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor });
|
|
26
26
|
} })] }));
|
|
27
27
|
}
|
|
28
28
|
export function rowOpensList(field, oneValue) {
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type CSSProperties, type RefObject } from "react";
|
|
2
|
+
/** The Field's Long reads `line` round the row (`data-field-row-long`, FIELD_LOOKS `row-long`), as the row read it when its editor
|
|
3
|
+
* opened: a long text's editor opens over the row's box, whatever the Field's Open says (RowTextEditor). */
|
|
4
|
+
export declare const RowLongContext: import("react").Context<boolean>;
|
|
5
|
+
/** Over whatever the frame says (`force`), or as the Field's Open on a frame round the rows says (`auto`). */
|
|
6
|
+
export type RowBodyOver = "auto" | "force";
|
|
7
|
+
/** What a row host hands its EditorPanel: the offsets and style it hands its popover, and the ref round its body. */
|
|
8
|
+
export type RowBodyPlace = {
|
|
9
|
+
sideOffset: number;
|
|
10
|
+
alignOffset: number | undefined;
|
|
11
|
+
/** Only over: `{ minWidth }` in px, wide enough to cover the row's box. Undefined below. */
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
/** Set on a `display: contents` span wrapping the body inside the EditorPanel: the body the hook measures. */
|
|
14
|
+
onBody: (el: HTMLElement | null) => void;
|
|
15
|
+
};
|
|
16
|
+
/** A point: where a line's words start (x) and their line's middle (y). */
|
|
17
|
+
type Words = {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
/** Where a line's words start, and their middle: the line a body marks `data-vk-first-line`; else the first, in the order drawn,
|
|
22
|
+
* of a typed input (its content box; a textarea's first line) and a visible, non-blank text (its line box), an aria-hidden part
|
|
23
|
+
* passed over. Null when nothing in it is laid out. */
|
|
24
|
+
export declare function firstWords(root: Element): Words | null;
|
|
25
|
+
/** Where a row's body opens: today's `below` offsets, or over the box (`data-field-row-open="over"` round the anchor, or
|
|
26
|
+
* `over: "force"`, a computer only), its first line's words on the value's. */
|
|
27
|
+
export declare function useRowBodyPlace(anchor: RefObject<HTMLElement | null>, below: {
|
|
28
|
+
sideOffset: number;
|
|
29
|
+
alignOffset?: number;
|
|
30
|
+
}, opts?: {
|
|
31
|
+
over?: RowBodyOver;
|
|
32
|
+
}): RowBodyPlace;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { createContext, useCallback, useLayoutEffect, useState } from "react";
|
|
3
|
+
import { overCellOffsets } from "../../internal/over-cell.js";
|
|
4
|
+
import { useDesktop } from "../../provider/desktop.js";
|
|
5
|
+
export const RowLongContext = createContext(false);
|
|
6
|
+
const BOX = "[data-field-row-anchor]";
|
|
7
|
+
const FIRST_LINE = "[data-vk-first-line]";
|
|
8
|
+
const TYPED = new Set(["", "text", "search", "tel", "email", "url", "number", "password"]);
|
|
9
|
+
const px = (value) => parseFloat(value) || 0;
|
|
10
|
+
function typedWords(el) {
|
|
11
|
+
const r = el.getBoundingClientRect();
|
|
12
|
+
if (r.width <= 1 || r.height <= 1)
|
|
13
|
+
return null;
|
|
14
|
+
const s = getComputedStyle(el);
|
|
15
|
+
const x = r.left + px(s.borderLeftWidth) + px(s.paddingLeft);
|
|
16
|
+
if (el instanceof HTMLInputElement)
|
|
17
|
+
return { x, y: r.top + r.height / 2 };
|
|
18
|
+
return { x, y: r.top + px(s.borderTopWidth) + px(s.paddingTop) + px(s.lineHeight) / 2 };
|
|
19
|
+
}
|
|
20
|
+
function textWords(node) {
|
|
21
|
+
let holder = node.parentElement;
|
|
22
|
+
while (holder && getComputedStyle(holder).display === "contents")
|
|
23
|
+
holder = holder.parentElement;
|
|
24
|
+
const own = holder?.getBoundingClientRect();
|
|
25
|
+
if (own && (own.width <= 1 || own.height <= 1))
|
|
26
|
+
return null;
|
|
27
|
+
const range = document.createRange();
|
|
28
|
+
range.selectNodeContents(node);
|
|
29
|
+
const r = range.getClientRects()[0];
|
|
30
|
+
return r && r.width > 1 && r.height > 1 ? { x: r.left, y: r.top + r.height / 2 } : null;
|
|
31
|
+
}
|
|
32
|
+
export function firstWords(root) {
|
|
33
|
+
const marked = root.querySelector(FIRST_LINE);
|
|
34
|
+
const from = marked ?? root;
|
|
35
|
+
const walk = document.createTreeWalker(from, NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_TEXT, {
|
|
36
|
+
acceptNode: (n) => n instanceof Element && n.getAttribute("aria-hidden") === "true" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT,
|
|
37
|
+
});
|
|
38
|
+
for (let n = from; n; n = walk.nextNode()) {
|
|
39
|
+
if (n instanceof HTMLTextAreaElement || (n instanceof HTMLInputElement && TYPED.has(n.type))) {
|
|
40
|
+
const at = typedWords(n);
|
|
41
|
+
if (at)
|
|
42
|
+
return at;
|
|
43
|
+
}
|
|
44
|
+
else if (n instanceof Text && n.textContent?.trim()) {
|
|
45
|
+
const at = textWords(n);
|
|
46
|
+
if (at)
|
|
47
|
+
return at;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
function positionerOf(body) {
|
|
53
|
+
for (let el = body.parentElement; el; el = el.parentElement) {
|
|
54
|
+
const position = getComputedStyle(el).position;
|
|
55
|
+
if (position === "fixed" || position === "absolute")
|
|
56
|
+
return el;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function popupOf(body, positioner) {
|
|
61
|
+
let el = body;
|
|
62
|
+
while (el.parentElement && el.parentElement !== positioner)
|
|
63
|
+
el = el.parentElement;
|
|
64
|
+
return el;
|
|
65
|
+
}
|
|
66
|
+
const busy = (body) => body.querySelector('[aria-busy="true"]') !== null;
|
|
67
|
+
function minWidthOf(anchor, box, alignOffset) {
|
|
68
|
+
const left = anchor.left + alignOffset;
|
|
69
|
+
return box.right - left + Math.max(0, box.left - left);
|
|
70
|
+
}
|
|
71
|
+
function overBox(anchor) {
|
|
72
|
+
const boxEl = anchor.querySelector(BOX) ?? anchor;
|
|
73
|
+
const a = anchor.getBoundingClientRect(), b = boxEl.getBoundingClientRect();
|
|
74
|
+
const o = overCellOffsets(boxEl);
|
|
75
|
+
const alignOffset = b.left + o.alignOffset - a.left;
|
|
76
|
+
return { sideOffset: b.bottom + o.sideOffset - a.bottom, alignOffset, minWidth: minWidthOf(a, b, alignOffset) };
|
|
77
|
+
}
|
|
78
|
+
function overWords(anchor, body) {
|
|
79
|
+
if (busy(body))
|
|
80
|
+
return null;
|
|
81
|
+
const positioner = positionerOf(body);
|
|
82
|
+
if (!positioner)
|
|
83
|
+
return null;
|
|
84
|
+
const popup = popupOf(body, positioner);
|
|
85
|
+
const first = firstWords(body), value = firstWords(anchor);
|
|
86
|
+
if (!first || !value)
|
|
87
|
+
return null;
|
|
88
|
+
const drawn = popup.getBoundingClientRect();
|
|
89
|
+
const sx = popup.offsetWidth ? drawn.width / popup.offsetWidth : 1, sy = popup.offsetHeight ? drawn.height / popup.offsetHeight : 1;
|
|
90
|
+
const inset = { x: popup.offsetLeft + (first.x - drawn.left) / (sx || 1), y: popup.offsetTop + (first.y - drawn.top) / (sy || 1) };
|
|
91
|
+
const boxEl = anchor.querySelector(BOX) ?? anchor;
|
|
92
|
+
const a = anchor.getBoundingClientRect(), b = boxEl.getBoundingClientRect();
|
|
93
|
+
const alignOffset = value.x - inset.x - a.left;
|
|
94
|
+
return { sideOffset: value.y - inset.y - a.bottom, alignOffset, minWidth: minWidthOf(a, b, alignOffset) };
|
|
95
|
+
}
|
|
96
|
+
const same = (a, b) => !!a && Math.abs(a.sideOffset - b.sideOffset) < 0.01 && Math.abs(a.alignOffset - b.alignOffset) < 0.01 && Math.abs(a.minWidth - b.minWidth) < 0.01;
|
|
97
|
+
export function useRowBodyPlace(anchor, below, opts) {
|
|
98
|
+
const desktop = useDesktop();
|
|
99
|
+
const force = opts?.over === "force";
|
|
100
|
+
const [body, setBody] = useState(null);
|
|
101
|
+
const onBody = useCallback((el) => setBody(el), []);
|
|
102
|
+
const [place, setPlace] = useState(null);
|
|
103
|
+
const keep = useCallback((next) => setPlace((now) => (same(now, next) ? now : next)), []);
|
|
104
|
+
const [over, setOver] = useState(false);
|
|
105
|
+
useLayoutEffect(() => {
|
|
106
|
+
const el = anchor.current;
|
|
107
|
+
if (!el || !desktop)
|
|
108
|
+
return;
|
|
109
|
+
if (!force && el.closest("[data-field-row-open]")?.getAttribute("data-field-row-open") !== "over")
|
|
110
|
+
return;
|
|
111
|
+
setOver(true);
|
|
112
|
+
keep(overBox(el));
|
|
113
|
+
}, []);
|
|
114
|
+
useLayoutEffect(() => {
|
|
115
|
+
const el = anchor.current;
|
|
116
|
+
if (!over || !el || !body)
|
|
117
|
+
return;
|
|
118
|
+
const measure = () => {
|
|
119
|
+
const next = overWords(el, body);
|
|
120
|
+
if (next)
|
|
121
|
+
keep(next);
|
|
122
|
+
};
|
|
123
|
+
measure();
|
|
124
|
+
const positioner = positionerOf(body);
|
|
125
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(measure);
|
|
126
|
+
if (positioner)
|
|
127
|
+
observer?.observe(popupOf(body, positioner));
|
|
128
|
+
const hold = () => stop();
|
|
129
|
+
const stop = () => {
|
|
130
|
+
observer?.disconnect();
|
|
131
|
+
body.removeEventListener("input", hold, true);
|
|
132
|
+
body.removeEventListener("keydown", hold, true);
|
|
133
|
+
};
|
|
134
|
+
body.addEventListener("input", hold, true);
|
|
135
|
+
body.addEventListener("keydown", hold, true);
|
|
136
|
+
return stop;
|
|
137
|
+
}, [anchor, body, over, keep]);
|
|
138
|
+
if (!over || !place)
|
|
139
|
+
return { sideOffset: below.sideOffset, alignOffset: below.alignOffset, style: undefined, onBody };
|
|
140
|
+
return { sideOffset: place.sideOffset, alignOffset: place.alignOffset, style: { minWidth: place.minWidth }, onBody };
|
|
141
|
+
}
|
|
@@ -2,6 +2,16 @@ import type { MouseEvent as ReactMouseEvent, ReactElement, ReactNode, Ref } from
|
|
|
2
2
|
import type { ViewsContextValue } from "../provider/context.js";
|
|
3
3
|
/** What a field row's button reads from the provider: the app's `Button`. */
|
|
4
4
|
export type FieldRowButtonViews = Pick<ViewsContextValue, "components">;
|
|
5
|
+
/** The row's target outside a Field rows card, named for the Field's Box (`data-field-row-box="box"`, field.css), which dresses it:
|
|
6
|
+
* the button, the button beside a link's open action, or the empty one laid under a rich text. Named in its `data-key`, which the
|
|
7
|
+
* app's Button forwards and writes nothing of its own into, so its own `data-slot` stays its own. The value an open picker keeps
|
|
8
|
+
* drawn in its place is ViewKit's own span, marked `data-field-row-anchor`. */
|
|
9
|
+
export type FieldRowTargetShape = "target" | "beside" | "under";
|
|
10
|
+
export declare const TARGET_KEY: {
|
|
11
|
+
readonly target: "vk-field-row-target";
|
|
12
|
+
readonly beside: "vk-field-row-beside";
|
|
13
|
+
readonly under: "vk-field-row-under";
|
|
14
|
+
};
|
|
5
15
|
/** One button a field row draws itself, as each of its places describes it. */
|
|
6
16
|
export type FieldRowButtonDraw = {
|
|
7
17
|
/** The box ViewKit keeps on the app's `Button`: its size and its place. The look is the app's. */
|
|
@@ -13,21 +23,26 @@ export type FieldRowButtonDraw = {
|
|
|
13
23
|
"aria-disabled"?: boolean;
|
|
14
24
|
"aria-label"?: string;
|
|
15
25
|
"data-slot"?: string;
|
|
26
|
+
/** Which of the row's targets this is, outside a Field rows card (`TARGET_KEY`). */
|
|
27
|
+
"data-key"?: string;
|
|
16
28
|
/** Marks the press as the host's own: `data-no-nav` on a `display: contents` span around the app's button. */
|
|
17
29
|
noNav?: boolean;
|
|
18
30
|
onClick?: (event: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
19
31
|
children?: ReactNode;
|
|
20
32
|
};
|
|
21
33
|
/** The row's edit target on the app's `Button`: the target's own box (padded out and pulled back by the same amount),
|
|
22
|
-
* a height that grows with a wrapped value, and the row's own type, so the value reads as it does unpressed.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
34
|
+
* a height that grows with a wrapped value, and the row's own type, so the value reads as it does unpressed. What the app's
|
|
35
|
+
* Button wraps its words in shrinks with it, so a value asked for one line ends in its "…" at the box's end. */
|
|
36
|
+
export declare const FIELD_ROW_FRAME = "-mx-2 -my-1 flex h-auto min-h-7 w-[calc(100%+1rem)] min-w-0 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
|
|
37
|
+
/** The same, sharing its line with a link's open action beside it. What the app's Button wraps its words in shrinks with it, so a
|
|
38
|
+
* long link wraps, or ends in its "…" on one line, before the action. */
|
|
39
|
+
export declare const FIELD_ROW_FRAME_BESIDE = "-ml-2 -my-1 flex h-auto min-h-7 min-w-0 flex-1 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
|
|
26
40
|
/** The empty target laid under a rich text, filling the value's footprint. */
|
|
27
41
|
export declare const FIELD_ROW_FRAME_UNDER = "absolute -inset-x-2 -inset-y-1 h-auto w-auto p-0";
|
|
28
42
|
/** In a Field rows card the target is the row's value, with no pill of its own: the card's row is what is pressed. It keeps
|
|
29
|
-
* its own box: its cut and its phone pressing area are absolute, and would otherwise lie over the rows round it.
|
|
30
|
-
|
|
43
|
+
* its own box: its cut and its phone pressing area are absolute, and would otherwise lie over the rows round it. What the app's
|
|
44
|
+
* Button wraps its words in shrinks with it, so a value on one line is cut short of the row's ›. */
|
|
45
|
+
export declare const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 *:min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
|
|
31
46
|
/** The same in a card, laid under a rich text: the value's whole box, no ground of its own. */
|
|
32
47
|
export declare const FIELD_ROW_FRAME_ROWS_UNDER = "absolute inset-0 h-auto w-auto p-0 bg-transparent hover:bg-transparent";
|
|
33
48
|
/** The same drawing as an element, for a button that carries a ref: the ref passes as a prop, never read while the
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
export const
|
|
4
|
-
|
|
3
|
+
export const TARGET_KEY = {
|
|
4
|
+
target: "vk-field-row-target",
|
|
5
|
+
beside: "vk-field-row-beside",
|
|
6
|
+
under: "vk-field-row-under",
|
|
7
|
+
};
|
|
8
|
+
export const FIELD_ROW_FRAME = "-mx-2 -my-1 flex h-auto min-h-7 w-[calc(100%+1rem)] min-w-0 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
|
|
9
|
+
export const FIELD_ROW_FRAME_BESIDE = "-ml-2 -my-1 flex h-auto min-h-7 min-w-0 flex-1 *:min-w-0 items-center justify-start whitespace-normal px-2 py-1 text-left [font:inherit]";
|
|
5
10
|
export const FIELD_ROW_FRAME_UNDER = "absolute -inset-x-2 -inset-y-1 h-auto w-auto p-0";
|
|
6
|
-
export const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
|
|
11
|
+
export const FIELD_ROW_FRAME_ROWS = "flex h-auto min-h-0 w-full min-w-0 *:min-w-0 items-center justify-start whitespace-normal p-0 text-left [font:inherit] bg-transparent hover:bg-transparent";
|
|
7
12
|
export const FIELD_ROW_FRAME_ROWS_UNDER = "absolute inset-0 h-auto w-auto p-0 bg-transparent hover:bg-transparent";
|
|
8
13
|
export function FieldRowButton({ views, ...draw }) {
|
|
9
14
|
return drawFieldRowButton(views, draw);
|
|
@@ -9,5 +9,8 @@
|
|
|
9
9
|
* `py-1` top and bottom (8px) is 28px — `h-7`. `min-h-5` looks like "one line"
|
|
10
10
|
* and is 12px of content once the padding is taken out, which is why an empty
|
|
11
11
|
* row's hover came up visibly short of its neighbours'.
|
|
12
|
+
*
|
|
13
|
+
* It says `box-border` itself: the row wears it on the value an open picker keeps in the button's place, a span, which isn't
|
|
14
|
+
* border-box of its own. That span takes the button's edge too (FieldRow's `edge`), so it stands in the button's box.
|
|
12
15
|
*/
|
|
13
|
-
export declare const FIELD_ROW_TARGET = "-mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
|
|
16
|
+
export declare const FIELD_ROW_TARGET = "box-border -mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const FIELD_ROW_TARGET = "-mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
|
|
1
|
+
export const FIELD_ROW_TARGET = "box-border -mx-2 -my-1 flex min-h-7 w-[calc(100%+1rem)] min-w-0 items-center rounded-md px-2 py-1 text-left transition-colors hover:bg-(color:--vk-hovered)";
|
|
@@ -67,6 +67,10 @@ export type FieldBinding<Row, D extends FieldDef = FieldDef> = {
|
|
|
67
67
|
addOption?: OptionAdd;
|
|
68
68
|
/** The app's own icon name for this field, drawn by the app's AppIcon; the type's glyph when absent. */
|
|
69
69
|
icon?: string;
|
|
70
|
+
/** What a field row's one icon says a click does, under the Field's Action (`row-action: icon`): `edit` (an editor
|
|
71
|
+
* opens), `expand` (a long text opens) or `none`. Absent, the row answers by its type: expand for a long text or a rich
|
|
72
|
+
* text, edit where its editor opens in a popover, none where the box is the input. */
|
|
73
|
+
action?: "none" | "edit" | "expand";
|
|
70
74
|
/** This row keeps only the values of a `multiple` field (a plain list column): its editor offers no label box.
|
|
71
75
|
* Absent, each value keeps its label. */
|
|
72
76
|
labels?: false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type MouseEvent as ReactMouseEvent, type ReactElement, type Ref } from "react";
|
|
2
2
|
import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js";
|
|
3
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
3
4
|
/** What the menu sets on the footer cell it opens from. */
|
|
4
5
|
type TriggerProps = {
|
|
5
6
|
ref?: Ref<HTMLElement>;
|
|
@@ -12,22 +13,22 @@ type TriggerProps = {
|
|
|
12
13
|
"data-open"?: "";
|
|
13
14
|
};
|
|
14
15
|
/**
|
|
15
|
-
* The footer cell's
|
|
16
|
-
* column
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
16
|
+
* The footer cell's calculation picker — pick the figure for one column, from what it offers (`aggregateOptions`:
|
|
17
|
+
* Count on the first column, the empty and filled counts and percents elsewhere, Sum, Average, Min and Max on a
|
|
18
|
+
* number and money), handed in as `options`. The trigger is the WHOLE footer cell, passed as the child: the map's
|
|
19
|
+
* `Menu` anchors on it, above it with its right edge on the cell's on every column (Attio's), one ticked row per
|
|
20
|
+
* figure keyed by its kind, its rows reshaped by the app's `menus.figure` (`reshape`); selection commits through the
|
|
21
|
+
* host's persisted `gridAggregates` pref.
|
|
21
22
|
*/
|
|
22
|
-
export declare function GridAggregateMenu<Row>({ column, options, current, onChange,
|
|
23
|
+
export declare function GridAggregateMenu<Row>({ column, options, current, onChange, reshape, children, }: {
|
|
23
24
|
column: ListColumn<Row>;
|
|
24
|
-
/** The picks to offer
|
|
25
|
-
*
|
|
25
|
+
/** The picks to offer, as the footer works them out for the column's place (`aggregateOptions(column, sourced,
|
|
26
|
+
* place)`). Default: the column's own off the first column. */
|
|
26
27
|
options?: ListAggregateKind[];
|
|
27
28
|
current: ListAggregateKind;
|
|
28
29
|
onChange: (kind: ListAggregateKind) => void;
|
|
29
|
-
/**
|
|
30
|
-
|
|
30
|
+
/** The app's function from the picker's rows to the rows it shows (`menus.figure`, its context already handed). */
|
|
31
|
+
reshape?: (items: ViewsMenuItem[]) => ViewsMenuItem[];
|
|
31
32
|
/** The footer cell. The menu sets its `ref`, so it must carry none of its own. */
|
|
32
33
|
children: ReactElement<TriggerProps>;
|
|
33
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,7 +5,7 @@ import { aggregateLabel, aggregateOptions } from "../../model/aggregates.js";
|
|
|
5
5
|
import { columnLabel } from "../../model/column-capabilities.js";
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { useGridMenuFocus, useGridMenuPress } from "./grid-menu-focus.js";
|
|
8
|
-
export function GridAggregateMenu({ column, options, current, onChange,
|
|
8
|
+
export function GridAggregateMenu({ column, options, current, onChange, reshape, children, }) {
|
|
9
9
|
const [open, setOpen] = useState(false);
|
|
10
10
|
const [anchor, setAnchor] = useState(null);
|
|
11
11
|
useGridMenuFocus(open, anchor);
|
|
@@ -13,6 +13,7 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
|
|
|
13
13
|
const { components, messages } = useViews();
|
|
14
14
|
const { Menu } = components;
|
|
15
15
|
const figures = options ?? aggregateOptions(column);
|
|
16
|
+
const reshaped = (items) => (reshape ? reshape(items) : items);
|
|
16
17
|
const menuTrigger = cloneElement(children, {
|
|
17
18
|
ref: setAnchor,
|
|
18
19
|
onPointerDownCapture: press.notePress,
|
|
@@ -28,7 +29,7 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
|
|
|
28
29
|
"aria-expanded": open,
|
|
29
30
|
"data-open": open ? "" : undefined,
|
|
30
31
|
});
|
|
31
|
-
return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "
|
|
32
|
+
return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "top", align: "end", "data-slot": "vk-grid-figure-menu", label: messages({ key: "views.menus.figure-menu", values: { field: columnLabel(column) } }), items: reshaped(figures.map((kind) => ({
|
|
32
33
|
key: kind,
|
|
33
34
|
label: aggregateLabel(kind, messages),
|
|
34
35
|
checked: kind === current,
|
|
@@ -37,5 +38,5 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
|
|
|
37
38
|
if (kind !== current)
|
|
38
39
|
onChange(kind);
|
|
39
40
|
},
|
|
40
|
-
})) })] }));
|
|
41
|
+
}))) })] }));
|
|
41
42
|
}
|
|
@@ -39,7 +39,7 @@ export type GridCellEditorContext<Row> = {
|
|
|
39
39
|
onCancel: () => void;
|
|
40
40
|
/** Told the moment the editor starts to close (its session accepted an answer), with the reason, before its exit
|
|
41
41
|
* plays: the cell stops wearing `data-editing` then, and a press away lets the pick go. */
|
|
42
|
-
onClosing?: (reason: CloseReason | null) => void;
|
|
42
|
+
onClosing?: (reason: CloseReason | null, popover: boolean) => void;
|
|
43
43
|
onTab: (backwards: boolean) => void;
|
|
44
44
|
onEnter: () => void;
|
|
45
45
|
};
|
|
@@ -49,5 +49,17 @@ export declare const GRID_CELL_HOVER_SHADOW = "hover:shadow-[var(--vk-outline-ho
|
|
|
49
49
|
*/
|
|
50
50
|
export declare const GRID_CELL_HOVER_RING = "hover:after:pointer-events-none hover:after:absolute hover:after:inset-0 hover:after:z-1 hover:after:rounded-(--vk-outline-radius,var(--radius-sm)) hover:after:border hover:after:border-(color:--vk-outline-hover,var(--vk-border-bold))";
|
|
51
51
|
/** The selection ring, in the same geometry the hover ring draws. Drawn on a selected cell, never while its editor is
|
|
52
|
-
* open: an open editor shows no
|
|
52
|
+
* open: an open editor shows no lift and no tint on its cell, a popover no ring, and a cell typed in this same ring drawn
|
|
53
|
+
* by its box (`GRID_TYPED_RING`). */
|
|
53
54
|
export declare function GridCellOutline(): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
/**
|
|
56
|
+
* The selection ring on the box a cell is typed in (a text, an email, a link, a phone, a number): the same line, colour and
|
|
57
|
+
* corners as `GridCellOutline`, where it stood, so typing in keeps the cell marked; worn by the box itself, it goes round all
|
|
58
|
+
* the box covers as it grows past the cell. On the grid's type-in layer, which stands a pixel past the cell on each side
|
|
59
|
+
* (`GRID_EDITOR_LAYER`), so the line is set two lines in and the corners a line rounder, lying exactly on the selected
|
|
60
|
+
* ring. Refused, the box's own red ring stands alone. A text box is a textarea, whose own corners weigh a tag more.
|
|
61
|
+
*/
|
|
62
|
+
export declare const GRID_TYPED_RING: {
|
|
63
|
+
readonly text: string;
|
|
64
|
+
readonly number: string;
|
|
65
|
+
};
|
|
@@ -42,3 +42,20 @@ export const GRID_CELL_HOVER_RING = "hover:after:pointer-events-none hover:after
|
|
|
42
42
|
export function GridCellOutline() {
|
|
43
43
|
return (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: cx("pointer-events-none absolute inset-0 z-1 rounded-(--vk-outline-radius,var(--radius-sm)) border", "border-(color:--vk-outline,var(--vk-fg-subtle)) group-hover/gridcell:border-(color:--vk-outline-active,var(--vk-border-brand))") }));
|
|
44
44
|
}
|
|
45
|
+
export const GRID_TYPED_RING = {
|
|
46
|
+
text: [
|
|
47
|
+
"[&_[data-slot=vk-text-box]]:outline [&_[data-slot=vk-text-box]]:-outline-offset-[calc(var(--vk-border-width)+var(--vk-border-width))]",
|
|
48
|
+
"[&_[data-slot=vk-text-box]]:outline-(color:--vk-outline,var(--vk-fg-subtle))",
|
|
49
|
+
"group-hover/gridcell:[&_[data-slot=vk-text-box]]:outline-(color:--vk-outline-active,var(--vk-border-brand))",
|
|
50
|
+
"[&_[data-slot=vk-text-box]]:rounded-[calc(var(--vk-outline-radius,var(--radius-sm))+var(--vk-border-width))]",
|
|
51
|
+
"[&_textarea[data-slot=vk-text-box]]:rounded-[calc(var(--vk-outline-radius,var(--radius-sm))+var(--vk-border-width))]",
|
|
52
|
+
"[&_[data-slot=vk-text-box]:is([aria-invalid=true],:has([aria-invalid=true]))]:outline-hidden",
|
|
53
|
+
].join(" "),
|
|
54
|
+
number: [
|
|
55
|
+
"[&_[data-slot=vk-number-box]]:outline [&_[data-slot=vk-number-box]]:-outline-offset-[calc(var(--vk-border-width)+var(--vk-border-width))]",
|
|
56
|
+
"[&_[data-slot=vk-number-box]]:outline-(color:--vk-outline,var(--vk-fg-subtle))",
|
|
57
|
+
"group-hover/gridcell:[&_[data-slot=vk-number-box]]:outline-(color:--vk-outline-active,var(--vk-border-brand))",
|
|
58
|
+
"[&_[data-slot=vk-number-box]]:rounded-[calc(var(--vk-outline-radius,var(--radius-sm))+var(--vk-border-width))]",
|
|
59
|
+
"[&_[data-slot=vk-number-box]:is([aria-invalid=true],:has([aria-invalid=true]))]:outline-hidden",
|
|
60
|
+
].join(" "),
|
|
61
|
+
};
|
|
@@ -3,13 +3,14 @@ import type { ListGroup } from "../../grouping/types.js";
|
|
|
3
3
|
import { type DisplayCurrency } from "../../fields/currency.js";
|
|
4
4
|
import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js";
|
|
5
5
|
import type { ListNumberFormatOverrides } from "../../model/column-format.js";
|
|
6
|
+
import type { GridMenus } from "./grid-table-props.js";
|
|
6
7
|
/** Whether a group's footer row is drawn: when its figures can be picked, or the host hands in one of its own. The
|
|
7
8
|
* keyboard and the screen reader's row numbers ask the same question the footer does. */
|
|
8
9
|
export declare function gridFooterShown({ interactive, hostCells, }: {
|
|
9
10
|
interactive: boolean;
|
|
10
11
|
hostCells: readonly ReactNode[];
|
|
11
12
|
}): boolean;
|
|
12
|
-
export declare function GridFooter<Row>({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked, frozenCount, frozenLeft, continuation, defaultCurrency, pageOnly, pin, verticalBorders, ariaRowIndex, ariaLevel, ariaColOffset, }: {
|
|
13
|
+
export declare function GridFooter<Row>({ group, columns, selecting, aggregates, numberFormats, renderAggregate, onAggregateChange, viewBacked, frozenCount, frozenLeft, continuation, defaultCurrency, pageOnly, pin, verticalBorders, desktop, menus, ariaRowIndex, ariaLevel, ariaColOffset, }: {
|
|
13
14
|
/** What a screen reader reads (`core/grid-aria.ts`): the row's number, its level in a tree grid, and the columns
|
|
14
15
|
* before the first data column (the checkbox lane). */
|
|
15
16
|
ariaRowIndex?: number;
|
|
@@ -34,10 +35,17 @@ export declare function GridFooter<Row>({ group, columns, selecting, aggregates,
|
|
|
34
35
|
* own sum is not the view's), and no column offers one. The row is still drawn, as without it. */
|
|
35
36
|
pageOnly?: boolean;
|
|
36
37
|
/** The grid's `pinFooter`: the row pins at the rows' box's foot (`--vk-foot-at` above its edge, set on the content
|
|
37
|
-
* box), over the rows. `foot`, the one footer of an ungrouped grid,
|
|
38
|
-
* it, so it stands at the foot when they don't fill the
|
|
38
|
+
* box), over the rows, and is never pushed below its last row. `foot`, the one footer of an ungrouped grid,
|
|
39
|
+
* which on a phone also takes the space its rows leave above it, so it stands at the foot when they don't fill the
|
|
40
|
+
* area; `group`, a group's, which closes its group. */
|
|
39
41
|
pin?: "foot" | "group";
|
|
40
42
|
/** The grid's column lines (`verticalBorders`): each cell ruled on its right as the rows' cells are, the last
|
|
41
|
-
* included
|
|
43
|
+
* included. The line under the row (its cells, its rail and its tail) stands in every look, as does the one over it
|
|
44
|
+
* while rows pass under a pinned footer. */
|
|
42
45
|
verticalBorders?: boolean;
|
|
46
|
+
/** The grid's computer form (`data-desktop`): a pinned footer follows its last row there, never pushed below it; a
|
|
47
|
+
* phone's one footer stands at the foot. */
|
|
48
|
+
desktop?: boolean;
|
|
49
|
+
/** The app's menus (`GridMenus`): `figure` reshapes each cell's calculation picker. */
|
|
50
|
+
menus?: GridMenus<Row>;
|
|
43
51
|
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
|