viewkitjs 0.36.0 → 0.37.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 +49 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +14 -8
- package/views/dist/contract.js +14 -1
- package/views/dist/controls/button/own-look-moved.d.ts +11 -0
- package/views/dist/controls/button/own-look-moved.js +3 -0
- package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
- package/views/dist/controls/date-editor/date-behaviour.js +187 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
- package/views/dist/controls/date-editor/date-editor.js +29 -166
- package/views/dist/controls/field/field.d.ts +3 -2
- package/views/dist/controls/field/field.js +7 -2
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +5 -4
- package/views/dist/controls/field.css +4 -0
- package/views/dist/controls/filter-editor/filter-editor.js +2 -2
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +1 -1
- package/views/dist/controls/index.d.ts +3 -1
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +9 -0
- package/views/dist/controls/internal/phone.d.ts +1 -1
- package/views/dist/controls/internal/phone.js +3 -2
- package/views/dist/controls/list/tokens.d.ts +1 -1
- package/views/dist/controls/list/tokens.js +1 -1
- package/views/dist/controls/list.css +5 -2
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker.css +5 -3
- package/views/dist/controls/popover/looks.d.ts +1 -1
- package/views/dist/controls/popover/looks.js +5 -0
- package/views/dist/controls/popover/tokens.d.ts +13 -1
- package/views/dist/controls/popover/tokens.js +4 -1
- package/views/dist/controls/popover.css +59 -8
- package/views/dist/controls/select/select.js +1 -1
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/text-editor.css +6 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +7 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +1 -1
- package/views/dist/controls/tooltip/tokens.js +1 -1
- package/views/dist/controls/tooltip.css +5 -3
- package/views/dist/controls/values-editor.css +20 -5
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/field-row/FieldRow.js +12 -8
- package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
- package/views/dist/grid/chrome/GridCellEditors.js +3 -2
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -5
- package/views/dist/grid/chrome/GridCellOutline.js +3 -5
- package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridDateEditor.js +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
- package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNameEditor.js +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
- package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
- package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +6 -5
- package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
- package/views/dist/grid/chrome/GridTable.d.ts +2 -1
- package/views/dist/grid/chrome/GridTable.js +7 -2
- package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +2 -2
- package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
- package/views/dist/grid/chrome/grid-body-place.js +8 -4
- package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
- package/views/dist/grid/chrome/grid-edit-session.d.ts +4 -0
- package/views/dist/grid/chrome/grid-edit-session.js +10 -1
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +10 -0
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +4 -4
- package/views/dist/grid/chrome/grid-fitted-box.js +1 -3
- package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
- package/views/dist/grid/chrome/grid-hover.js +2 -3
- package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +2 -10
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +24 -1
- package/views/dist/grid/core/useGridEditing.d.ts +3 -0
- package/views/dist/grid/core/useGridEditing.js +2 -0
- package/views/dist/grid/grid.css +4 -19
- package/views/dist/internal/screen-forms.d.ts +11 -0
- package/views/dist/internal/screen-forms.js +31 -0
- package/views/dist/list/list.js +2 -1
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +7 -3
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +6 -3
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +3 -2
- package/views/dist/panels/react/views-row/FoldingViewRow.js +24 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +1 -1
- package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
- package/views/dist/panels/react/views-row/more-views.js +3 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/toolbar/model.d.ts +2 -2
- package/views/dist/provider/components.d.ts +6 -6
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/styles.css +181 -80
- package/views/dist/styles.unlayered.css +181 -80
- package/views/docs/contract.md +68 -20
- package/views/docs/controls/list.md +2 -0
- package/views/docs/controls/menu.md +2 -0
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/popover.md +7 -0
- package/views/docs/controls/tooltip.md +2 -0
- package/views/docs/guides/atoms.md +11 -10
- package/views/docs/guides/the-grid.md +7 -5
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/reference/controls.md +11 -6
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/list.md +5 -6
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +5 -4
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +6 -6
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { cx } from "../../internal/cx.js";
|
|
3
|
-
import {
|
|
3
|
+
import { GRID_GROUND, GRID_GROUND_WHILE_SCROLLED } from "./grid-styles.js";
|
|
4
4
|
const GRID_FROZEN_HOVER = "group-hover/gridrow:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))] group-data-hovered/gridrow:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]";
|
|
5
5
|
const GRID_FROZEN_BG_SELECTED = "bg-[linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]";
|
|
6
6
|
const GRID_FROZEN_BG_SELECTED_HOVER = "group-hover/gridrow:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent)),linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))] group-data-hovered/gridrow:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent)),linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]";
|
|
@@ -39,8 +39,6 @@ export function gridFrozenBg(selected, on, highlight = "hover") {
|
|
|
39
39
|
}
|
|
40
40
|
export const GRID_CELL_HOVER_SHADOW = "hover:shadow-[var(--vk-outline-hover-shadow,0_1px_2px_rgb(0_0_0/0.05))] dark:hover:shadow-[var(--vk-outline-hover-shadow,0_1px_2px_rgb(0_0_0/0.22))]";
|
|
41
41
|
export 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))";
|
|
42
|
-
export function GridCellOutline(
|
|
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",
|
|
44
|
-
? "border-(color:--vk-outline-active,var(--vk-border-brand))"
|
|
45
|
-
: "border-(color:--vk-outline,var(--vk-fg-subtle)) group-hover/gridcell:border-(color:--vk-outline-active,var(--vk-border-brand))", editing && GRID_EDITING_SHADOW) }));
|
|
42
|
+
export function GridCellOutline() {
|
|
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))") }));
|
|
46
44
|
}
|
|
@@ -36,5 +36,5 @@ export function GridChipsEditor({ column, title, values, suggestions, optionColo
|
|
|
36
36
|
(column.field ? (optionFor(column.field, value)?.label ?? value) : prettifyOptionValue(value)),
|
|
37
37
|
color: resolveCategoryColor(value, column.options, optionColors),
|
|
38
38
|
});
|
|
39
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: panel.className, children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, creatable: open, seed: seed, addOption: field ? column.addOption : undefined, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: panel.className, children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, creatable: open, seed: seed, addOption: field ? column.addOption : undefined, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
40
40
|
}
|
|
@@ -38,6 +38,6 @@ export declare function GridDateEditor({ title, initial, dayOnly, browserClock,
|
|
|
38
38
|
refuse?: (value: string) => string | null;
|
|
39
39
|
/** After a Tab out of the panel saves: move to the next cell, or the one before on Shift-Tab. */
|
|
40
40
|
onTab?: (backwards: boolean) => void;
|
|
41
|
-
/** After an Enter saves:
|
|
41
|
+
/** After an Enter saves: the grid's answer, which keeps the cell, as a text or number cell's Enter does. */
|
|
42
42
|
onEnter?: () => void;
|
|
43
43
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -23,5 +23,5 @@ export function GridDateEditor({ title, initial, dayOnly = false, browserClock =
|
|
|
23
23
|
onTab,
|
|
24
24
|
onEnter,
|
|
25
25
|
});
|
|
26
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-auto", children: _jsx(EditorClockContext.Provider, { value: browserClock ? "browser" : "conventions", children: _jsx(DateEditorHost, { ref: editorRef, label: typeof title === "string" ? title : undefined, initial: initial, dayOnly: dayOnly, clearable: clearable, seed: seed, focusDate: !sheet, onRequestClose: close }) }) })] }));
|
|
26
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 w-auto", children: _jsx(EditorClockContext.Provider, { value: browserClock ? "browser" : "conventions", children: _jsx(DateEditorHost, { ref: editorRef, label: typeof title === "string" ? title : undefined, initial: initial, dayOnly: dayOnly, clearable: clearable, seed: seed, focusDate: !sheet, onRequestClose: close }) }) })] }));
|
|
27
27
|
}
|
|
@@ -29,6 +29,6 @@ export declare function GridLongTextEditor({ initial, markdown, paragraph, type,
|
|
|
29
29
|
onCancel: () => void;
|
|
30
30
|
/** Closed via Tab — move to the next cell in reading order. */
|
|
31
31
|
onTab?: (backwards: boolean) => void;
|
|
32
|
-
/** Closed via Enter (⌘ or Ctrl Enter in a paragraph)
|
|
32
|
+
/** Closed via Enter (⌘ or Ctrl Enter in a paragraph): the grid's answer, which keeps the cell. */
|
|
33
33
|
onEnter?: () => void;
|
|
34
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -6,6 +6,7 @@ import { TextEditorHost, } from "../../editors/TextEditor.js";
|
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { cx } from "../../internal/cx.js";
|
|
8
8
|
import { useGridEditSession } from "./grid-edit-session.js";
|
|
9
|
+
import { useGridBodyPlace } from "./grid-body-place.js";
|
|
9
10
|
const MIN_W = 320;
|
|
10
11
|
const MAX_W = 512;
|
|
11
12
|
export function GridLongTextEditor({ initial, markdown = false, paragraph = true, type, title, onCancel, onTab, onEnter, }) {
|
|
@@ -25,14 +26,16 @@ export function GridLongTextEditor({ initial, markdown = false, paragraph = true
|
|
|
25
26
|
onTab,
|
|
26
27
|
onEnter,
|
|
27
28
|
});
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const place = useGridBodyPlace(anchorRef);
|
|
30
|
+
const step = -place.alignOffset;
|
|
31
|
+
const width = cell ? Math.min(MAX_W, Math.max(MIN_W, cell.width + 2 * step)) : MIN_W;
|
|
32
|
+
const padY = cell ? Math.max(0, (cell.height - cell.lineHeight) / 2 - 1) + step : 8;
|
|
33
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title ?? "", anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "z-90 rounded-sm border-(color:--vk-border) p-0", style: { width }, children: (surface) => {
|
|
31
34
|
const framed = surface === "sheet" && paragraph;
|
|
32
35
|
const editor = (_jsx(TextEditorHost, { ref: editorRef, type: type ?? (markdown ? "rich_text" : "text"), multiline: paragraph, initial: initial, readOnly: true, ...(framed ? { rows: 3 } : {}), closeOnBlur: false, label: messages({ key: "views.grid.value" }), boxData: { "data-grid-editor": "" }, onRequestClose: close, style: cell && surface === "popover"
|
|
33
36
|
? {
|
|
34
|
-
paddingLeft: cell.paddingX,
|
|
35
|
-
paddingRight: cell.paddingX,
|
|
37
|
+
paddingLeft: cell.paddingX + step,
|
|
38
|
+
paddingRight: cell.paddingX + step,
|
|
36
39
|
paddingTop: padY,
|
|
37
40
|
paddingBottom: padY,
|
|
38
41
|
fontSize: cell.fontSize,
|
|
@@ -19,6 +19,6 @@ export declare function GridNameEditor({ title, initial, seed, allowEmpty, onCom
|
|
|
19
19
|
onCommit: (payload: NameValue | null) => void;
|
|
20
20
|
onCancel: () => void;
|
|
21
21
|
onTab?: (backwards: boolean) => void;
|
|
22
|
-
/** Commit happened via Enter
|
|
22
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
23
23
|
onEnter?: () => void;
|
|
24
24
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -18,7 +18,7 @@ export function GridNameEditor({ title, initial, seed, allowEmpty = false, onCom
|
|
|
18
18
|
onTab,
|
|
19
19
|
onEnter,
|
|
20
20
|
});
|
|
21
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (surface) => {
|
|
21
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (surface) => {
|
|
22
22
|
const editor = (_jsx(NameEditor, { ref: editorRef, initial: initial, seed: seed, allowEmpty: allowEmpty, label: typeof title === "string" ? title : undefined, onRequestClose: close }));
|
|
23
23
|
return surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor;
|
|
24
24
|
} })] }));
|
|
@@ -40,7 +40,7 @@ export declare function GridNumberEditor({ title, initial, seed, unit, unitOptio
|
|
|
40
40
|
onCommit: (payload: GridNumberEditValue) => void;
|
|
41
41
|
onCancel: () => void;
|
|
42
42
|
onTab?: (backwards: boolean) => void;
|
|
43
|
-
/** Commit happened via Enter
|
|
43
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
44
44
|
onEnter?: () => void;
|
|
45
45
|
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
46
46
|
* A refused value keeps the editor open with that reason. */
|
|
@@ -6,7 +6,7 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
|
6
6
|
import { ConversionLine } from "../../display/converted.js";
|
|
7
7
|
import { useKeepInside } from "../../editors/keep-inside.js";
|
|
8
8
|
import { cx } from "../../internal/cx.js";
|
|
9
|
-
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER } from "./grid-editor-layer.js";
|
|
9
|
+
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER, GRID_TYPE_IN } from "./grid-editor-layer.js";
|
|
10
10
|
import { GridFittedBox } from "./grid-fitted-box.js";
|
|
11
11
|
import { GridRefusal, UNDER_CELL_CLASS, useGridEditSession } from "./grid-edit-session.js";
|
|
12
12
|
export function GridNumberEditor({ title, initial, seed, unit, unitOptions, code, decimals = 2, durationUnit, allowEmpty = false, unitLeft = false, conversion, onCommit, onCancel, onTab, onEnter, refuse, type, bounds, }) {
|
|
@@ -32,7 +32,7 @@ export function GridNumberEditor({ title, initial, seed, unit, unitOptions, code
|
|
|
32
32
|
form: surface === "sheet" ? "phone" : "computer",
|
|
33
33
|
}
|
|
34
34
|
: {}), onRequestClose: close }));
|
|
35
|
-
return (_jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, inPlace: true, sheetOnPhone: true, children: (surface) => body ? (surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [editor(surface), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", "data-grown": "", className: cx(GRID_EDITOR_LAYER, unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, edge: false, room: BODY_FIGURE_ROOM_PX, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] }))) : surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [_jsx("div", { className: "flex h-10 min-w-0 items-center rounded-md border border-(color:--vk-border) px-2", children: editor(surface) }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", className: cx("relative flex h-full w-full min-w-0", unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] })) }));
|
|
35
|
+
return (_jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, inPlace: true, sheetOnPhone: true, children: (surface) => body ? (surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [editor(surface), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", "data-grown": "", ...GRID_TYPE_IN, className: cx(GRID_EDITOR_LAYER, unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, edge: false, room: BODY_FIGURE_ROOM_PX, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] }))) : surface === "sheet" ? (_jsxs("div", { className: "px-2 pb-3", children: [_jsx("div", { className: "flex h-10 min-w-0 items-center rounded-md border border-(color:--vk-border) px-2", children: editor(surface) }), conversion ? _jsx(ConversionLine, { figure: conversion, className: "pt-1.5" }) : null] })) : (_jsxs("span", { "data-slot": "vk-grid-editor", className: cx("relative flex h-full w-full min-w-0", unitLeft && "justify-end"), children: [_jsx(GridFittedBox, { boxRef: anchorRef, grows: unitLeft ? "left" : "right", children: editor(surface) }), _jsx(GridRefusal, { reason: session.refusal }), conversion && !session.refusal ? _jsx(UnderCellConversion, { figure: conversion }) : null] })) }));
|
|
36
36
|
}
|
|
37
37
|
function UnderCellConversion({ figure }) {
|
|
38
38
|
const ref = useRef(null);
|
|
@@ -21,6 +21,6 @@ export declare function GridPlaceEditor({ field, title, initial, refuse, onCommi
|
|
|
21
21
|
onCommit: (place: LocationValue | null) => void;
|
|
22
22
|
onCancel: () => void;
|
|
23
23
|
onTab?: (backwards: boolean) => void;
|
|
24
|
-
/** Commit happened via Enter
|
|
24
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
25
25
|
onEnter?: () => void;
|
|
26
26
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -19,7 +19,7 @@ export function GridPlaceEditor({ field, title, initial, refuse, onCommit, onCan
|
|
|
19
19
|
onTab,
|
|
20
20
|
onEnter,
|
|
21
21
|
});
|
|
22
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (surface) => {
|
|
22
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (surface) => {
|
|
23
23
|
const editor = (_jsx(LocationEditor, { ref: editorRef, field: field, initial: initial, allowEmpty: true, label: typeof title === "string" ? title : undefined, onRequestClose: close }));
|
|
24
24
|
return surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor;
|
|
25
25
|
} })] }));
|
|
@@ -3,7 +3,7 @@ import type { RangePreset, RangeValue } from "viewkitjs/fields";
|
|
|
3
3
|
/**
|
|
4
4
|
* The GRID's host around the shared `RangeEditor`: the edit session owns the
|
|
5
5
|
* one-answer guard and the editor panel decides where it opens. On a desktop the
|
|
6
|
-
* app's parts body opens in a popover over the cell,
|
|
6
|
+
* app's parts body opens in a popover over the cell, a step above and left of it;
|
|
7
7
|
* on a phone it opens in the sheet and the answer waits for the sheet to slide away.
|
|
8
8
|
*/
|
|
9
9
|
export declare function GridRangeEditor({ title, initial, seed, decimals, allowEmpty, suffix, bands, min, max, onCommit, onCancel, onTab, onEnter, refuse, }: {
|
|
@@ -24,7 +24,7 @@ export declare function GridRangeEditor({ title, initial, seed, decimals, allowE
|
|
|
24
24
|
onCommit: (payload: RangeValue) => void;
|
|
25
25
|
onCancel: () => void;
|
|
26
26
|
onTab?: (backwards: boolean) => void;
|
|
27
|
-
/** Commit happened via Enter
|
|
27
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
28
28
|
onEnter?: () => void;
|
|
29
29
|
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
30
30
|
* A refused value keeps the editor open with that reason. */
|
|
@@ -20,5 +20,5 @@ export function GridRangeEditor({ title, initial, seed, decimals = 0, allowEmpty
|
|
|
20
20
|
onEnter,
|
|
21
21
|
});
|
|
22
22
|
const editor = (_jsx(RangeEditor, { ref: editorRef, initial: initial, seed: seed, decimals: decimals, allowEmpty: allowEmpty, suffix: suffix, bands: bands, min: min, max: max, label: typeof title === "string" ? title : undefined, onRequestClose: close }));
|
|
23
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (surface) => (surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor) })] }));
|
|
23
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: (surface) => (surface === "sheet" ? _jsx("div", { className: "px-4 pb-4", children: editor }) : editor) })] }));
|
|
24
24
|
}
|
|
@@ -46,7 +46,7 @@ export function GridRelationEditor({ title, candidates, current, clearable, seed
|
|
|
46
46
|
},
|
|
47
47
|
]
|
|
48
48
|
: undefined;
|
|
49
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), panelData: { "data-slot": "vk-grid-editor", ...panel.data }, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(RelationEditor, { ref: editorRef, candidates: source, initial: current, clearable: clearable, seed: seed, focusSearch: !sheet, creates: creates, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
49
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), panelData: { "data-slot": "vk-grid-editor", ...panel.data }, chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(RelationEditor, { ref: editorRef, candidates: source, initial: current, clearable: clearable, seed: seed, focusSearch: !sheet, creates: creates, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
50
50
|
}
|
|
51
51
|
export function GridRelationSetEditor({ title, candidates, current, lead, links, seed, create, refuse, onCommit, onLink, onCancel, onTab, }) {
|
|
52
52
|
const body = useSetBody(links);
|
|
@@ -95,5 +95,5 @@ export function GridRelationSetEditor({ title, candidates, current, lead, links,
|
|
|
95
95
|
},
|
|
96
96
|
]
|
|
97
97
|
: undefined;
|
|
98
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), panelData: { "data-slot": "vk-grid-editor", ...panel.data }, chrome: "menu", className: panel.className, children: _jsx(RelationSetEditor, { ref: editorRef, candidates: candidates, initial: current, lead: lead, links: links, seed: seed, focusSearch: !sheet, creates: creates, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
98
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), panelData: { "data-slot": "vk-grid-editor", ...panel.data }, chrome: "menu", className: panel.className, children: _jsx(RelationSetEditor, { ref: editorRef, candidates: candidates, initial: current, lead: lead, links: links, seed: seed, focusSearch: !sheet, creates: creates, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
99
99
|
}
|
|
@@ -31,12 +31,13 @@ export function GridRowCells({ props }) {
|
|
|
31
31
|
const booleanCheckbox = components.Checkbox;
|
|
32
32
|
const hoverStore = useContext(GridHoverContext);
|
|
33
33
|
const highlight = useContext(GridRowHighlightContext);
|
|
34
|
-
const { row, id, rowKey, columns, selected, checkColumnId, toggle, rowActions, rowIcon, verticalBorders = true, optionColors, dateStyles, durationStyles, numberFormats, showTimeOverrides, percentDisplays, editingEnabled, focusedColId, editingColId, pendingByCol, settlementByCol, writeStateByCol, selectValues, rowRange, frozenCount = 0, frozenLeft, listConfig, rowWritable = true, onStartEdit, onEditorTab,
|
|
34
|
+
const { row, id, rowKey, columns, selected, checkColumnId, toggle, rowActions, rowIcon, verticalBorders = true, optionColors, dateStyles, durationStyles, numberFormats, showTimeOverrides, percentDisplays, editingEnabled, focusedColId, editingColId, editClosing = false, pendingByCol, settlementByCol, writeStateByCol, selectValues, rowRange, frozenCount = 0, frozenLeft, listConfig, rowWritable = true, onStartEdit, onEditorTab, onFocusCell, onEditorClosing, editSeed, editWhole = false, editByKey = false, onCommitCell, onCancelEdit, onOpenRelation: onOpenRelationValue, entityIcon, commands, ariaColOffset = 0, } = props;
|
|
35
35
|
const writes = (column) => editingEnabled && rowWritable && columnEffectiveWritable(column, listConfig);
|
|
36
36
|
const canEdit = (column) => writes(column) && gridColumnHasEditor(column);
|
|
37
37
|
const editBaseline = (column) => cellEditBaseline(column, row, pendingByCol);
|
|
38
38
|
return columns.map((col, i) => {
|
|
39
39
|
const editing = editingColId === col.id;
|
|
40
|
+
const open = editing && !editClosing;
|
|
40
41
|
const focused = focusedColId === col.id;
|
|
41
42
|
const span = rowRange?.find((s) => i >= s.startCol && i <= s.endCol);
|
|
42
43
|
const spanLeft = !!span && i === span.startCol;
|
|
@@ -86,7 +87,6 @@ export function GridRowCells({ props }) {
|
|
|
86
87
|
? col.render(row, { value: col.accessor?.(row), code: shownCodeOf(col, row) })
|
|
87
88
|
: typedCell();
|
|
88
89
|
const tabTo = (backwards) => onEditorTab(rowKey, col.id, backwards);
|
|
89
|
-
const enterAdvance = () => onEditorEnter(rowKey, col.id);
|
|
90
90
|
const frozen = i < frozenCount;
|
|
91
91
|
const settlement = settlementByCol?.[col.id];
|
|
92
92
|
const write = writeStateByCol?.[col.id];
|
|
@@ -113,12 +113,13 @@ export function GridRowCells({ props }) {
|
|
|
113
113
|
listConfig,
|
|
114
114
|
onCommitCell,
|
|
115
115
|
onCancel: () => onCancelEdit(rowKey, col.id),
|
|
116
|
+
onClosing: (reason) => onEditorClosing?.(rowKey, col.id, reason),
|
|
116
117
|
onTab: tabTo,
|
|
117
|
-
onEnter:
|
|
118
|
+
onEnter: () => onFocusCell(rowKey, col.id),
|
|
118
119
|
};
|
|
119
120
|
return (_jsxs("div", { "data-slot": "vk-grid-cell", "data-col-id": col.id, tabIndex: -1, role: "gridcell", "aria-colindex": ariaColOffset + i + 1, "aria-readonly": writes(col) ? undefined : true, "aria-selected": span ? true : undefined, "data-settlement": settlement, ...gridCellStates({
|
|
120
121
|
focused,
|
|
121
|
-
editing,
|
|
122
|
+
editing: open,
|
|
122
123
|
range: span && { top: !!span.top, right: spanRight, bottom: !!span.bottom, left: spanLeft },
|
|
123
124
|
write,
|
|
124
125
|
empty,
|
|
@@ -141,7 +142,7 @@ export function GridRowCells({ props }) {
|
|
|
141
142
|
verticalBorders,
|
|
142
143
|
highlight,
|
|
143
144
|
settlement,
|
|
144
|
-
}), children: [span && (_jsx("span", { "aria-hidden": true, className: GRID_RANGE_TINT_CLASS })), span?.top && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { top: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), span?.bottom && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { bottom: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), spanLeft && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { left: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), spanRight && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { right: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), span && span.dotCol === i && !editing && (_jsx(FillDot, { enabled: editingEnabled })),
|
|
145
|
+
}), children: [span && (_jsx("span", { "aria-hidden": true, className: GRID_RANGE_TINT_CLASS })), span?.top && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { top: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), span?.bottom && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { bottom: -2, height: 1, left: spanLeft ? -2 : 0, right: -2 } })), spanLeft && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { left: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), spanRight && span && (_jsx("span", { "aria-hidden": true, "data-slot": "vk-grid-outline", className: "pointer-events-none absolute z-6 bg-(color:--vk-brand)", style: { right: -2, width: 1, top: span.top ? -2 : 0, bottom: -2 } })), span && span.dotCol === i && !editing && (_jsx(FillDot, { enabled: editingEnabled })), focused && !open && (_jsx(GridCellOutline, {})), focused && !editing && !span && (_jsx(FillDot, { enabled: editingEnabled })), col.id === checkColumnId && !editing && (_jsx(GridNameCheck, { children: _jsx(SelectCheckbox, { checked: selected, revealed: true, onChange: (next) => toggle(id, next), "aria-label": messages({ key: "views.grid.select-row" }), tabIndex: -1 }) })), col.type === "title" && rowIcon && !editing && (_jsx("span", { className: "mr-2.5 flex shrink-0 items-center", children: _jsx(GridRowGlyph, { row: row, rowIcon: rowIcon }) })), editing ? _jsx(GridCellInlineEditor, { ctx: editorCtx }) : null, editing &&
|
|
145
146
|
(editorKind === "number" || (editorKind === "text" && !gridTextOpensBox(col, whole, writable))) ? (_jsx(GridValueUnderEditor, { children: cellValue() })) : (cellValue()), editing ? _jsx(GridCellAnchoredEditor, { ctx: editorCtx }) : null, hoverStore && col.type === "title" && !editing && (_jsx(GridRowHoverActions, { views: views, rowKey: rowKey, row: row, selected: selected, actions: [
|
|
146
147
|
...(rowActions ?? []),
|
|
147
148
|
...(canEdit(col)
|
|
@@ -54,5 +54,5 @@ export function GridSelectEditor({ column, title, values, current, clearable = f
|
|
|
54
54
|
label: optionLabel(value),
|
|
55
55
|
color: resolveCategoryColor(value, column.options, optionColors),
|
|
56
56
|
});
|
|
57
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, steps: field ? statusSteps(field) : undefined, initial: initial, clearable: clearable, creatable: !!column.field && isOpenVocabulary(column.field), seed: seed, focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, label: typeof title === "string" ? title : undefined, addOption: field?.type === "select" && !country ? column.addOption : undefined }) })] }));
|
|
57
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, savesOnPick: true, children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, steps: field ? statusSteps(field) : undefined, initial: initial, clearable: clearable, creatable: !!column.field && isOpenVocabulary(column.field), seed: seed, focusSearch: !sheet, focusList: openedByKey && !sheet, onRequestClose: close, label: typeof title === "string" ? title : undefined, addOption: field?.type === "select" && !country ? column.addOption : undefined }) })] }));
|
|
58
58
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { GridTableProps } from "./grid-table-props.js";
|
|
2
2
|
export type { GridTableProps } from "./grid-table-props.js";
|
|
3
|
-
/** Spreadsheet sibling to ListView, including editing and synchronized grouped rails.
|
|
3
|
+
/** Spreadsheet sibling to ListView, including editing and synchronized grouped rails. Server-rendered, it draws its phone's
|
|
4
|
+
* and its computer's forms, CSS showing the screen's until the page comes alive (`ScreenForms`). */
|
|
4
5
|
export declare function GridTable<Row>(props: GridTableProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -40,7 +40,11 @@ import { GridPager } from "./GridPager.js";
|
|
|
40
40
|
import { useGridHeldMenuReport } from "./grid-menu-focus.js";
|
|
41
41
|
import { EditLeaveContext, useEditLeaveScope } from "../../editors/leave-scope.js";
|
|
42
42
|
import { GridRowsSlotContext, GridWaitContext } from "./grid-wait.js";
|
|
43
|
+
import { ScreenForms } from "../../internal/screen-forms.js";
|
|
43
44
|
export function GridTable(props) {
|
|
45
|
+
return (_jsx(ScreenForms, { children: _jsx(GridTableOnScreen, { ...props }) }));
|
|
46
|
+
}
|
|
47
|
+
function GridTableOnScreen(props) {
|
|
44
48
|
const { atoms, messages, components } = useViews();
|
|
45
49
|
const { Loading } = atoms;
|
|
46
50
|
const deferredKey = useDeferredValue(props.transitionKey);
|
|
@@ -233,7 +237,7 @@ function GridTableContent(given) {
|
|
|
233
237
|
}), [flat, footerKey, grouped, oneHead, selectable, visibleColIds, more]);
|
|
234
238
|
const ariaTailIndex = aria.colCount + 1;
|
|
235
239
|
const ariaColOffset = selectable ? 1 : 0;
|
|
236
|
-
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, writeStateByRow, editSeed, editWhole, editByKey, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab,
|
|
240
|
+
const { rowSpansMap, selectValuesByColumn, onRangeCopy, onRangeCut, onRangeClear, onRangePaste, onPasteAtCell, inActiveRange, rangeCanClear, editingEnabled, focusedCell, editingCell, pendingByRow, settlementByRow, writeStateByRow, editSeed, editWhole, editByKey, editClosing, onEditorClosing, focusCellSync, startEditSync, cancelEdit, commitEdit, commitBatch, refuseEdit, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, onEditorTab, enterGrid, revealCell, focus, } = useGridTableInteractionModel({
|
|
237
241
|
rootRef,
|
|
238
242
|
props,
|
|
239
243
|
rows: flatRows,
|
|
@@ -346,8 +350,9 @@ function GridTableContent(given) {
|
|
|
346
350
|
editSeed: editingCell?.rowId === rowKey ? editSeed : null,
|
|
347
351
|
editWhole: editingCell?.rowId === rowKey && editWhole,
|
|
348
352
|
editByKey: editingCell?.rowId === rowKey && editByKey,
|
|
353
|
+
editClosing: editingCell?.rowId === rowKey && editClosing,
|
|
354
|
+
onEditorClosing,
|
|
349
355
|
onEditorTab,
|
|
350
|
-
onEditorEnter,
|
|
351
356
|
pendingByCol: pendingByRow.get(rowId),
|
|
352
357
|
settlementByCol: settlementByRow.get(rowId),
|
|
353
358
|
writeStateByCol: writeStateByRow.get(rowId),
|
|
@@ -39,7 +39,7 @@ export declare function GridTextEditor({ initial, seed, type, paragraph, region,
|
|
|
39
39
|
onCancel: () => void;
|
|
40
40
|
/** Commit happened via Tab — move to the next cell in reading order. */
|
|
41
41
|
onTab?: (backwards: boolean) => void;
|
|
42
|
-
/** Commit happened via Enter
|
|
42
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
43
43
|
onEnter?: () => void;
|
|
44
44
|
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
45
45
|
* A refused value stays in the box with that reason. */
|
|
@@ -5,7 +5,7 @@ import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
|
5
5
|
import { OpenValueAction } from "../../editors/open-value.js";
|
|
6
6
|
import { TextEditorHost, } from "../../editors/TextEditor.js";
|
|
7
7
|
import { GridRefusal, useGridEditSession } from "./grid-edit-session.js";
|
|
8
|
-
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER } from "./grid-editor-layer.js";
|
|
8
|
+
import { BODY_FIGURE_ROOM_PX, GRID_EDITOR_LAYER, GRID_TYPE_IN } from "./grid-editor-layer.js";
|
|
9
9
|
import { GridFittedBox } from "./grid-fitted-box.js";
|
|
10
10
|
const TEXT_TYPES = new Set([
|
|
11
11
|
"text",
|
|
@@ -33,6 +33,6 @@ export function GridTextEditor({ initial, seed, type = "text", paragraph = false
|
|
|
33
33
|
const [stored, setStored] = useState(seed === undefined);
|
|
34
34
|
return (_jsx(EditorPanel, { session: session, title: title ?? "", anchor: null, inPlace: true, sheetOnPhone: true, children: (surface) => {
|
|
35
35
|
const editor = (_jsx(TextEditorHost, { ref: editorRef, type: type, initial: initial, seed: seed, closeOnBlur: surface === "in-place", ...(paragraph ? { multiline: true } : {}), label: typeof title === "string" ? title : undefined, check: refuse, region: region, escapeKeeps: session.keeps ?? false, form: surface === "sheet" ? "phone" : "computer", place: "cell", onRequestClose: close }));
|
|
36
|
-
return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { "data-grown": "", className: GRID_EDITOR_LAYER, children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
36
|
+
return surface === "sheet" ? (open ? (_jsxs("div", { className: "flex items-center gap-2 px-4 pb-4", onInput: (e) => setStored(e.target.value === initial), children: [_jsx("div", { className: "min-w-0 flex-1", children: editor }), stored && _jsx(OpenValueAction, { type: open.type, value: open.value, label: initial })] })) : (_jsx("div", { className: "px-4 pb-4", children: editor }))) : (_jsxs("span", { "data-grown": "", ...GRID_TYPE_IN, className: GRID_EDITOR_LAYER, children: [_jsx(GridFittedBox, { boxRef: boxRef, edge: false, room: BODY_FIGURE_ROOM_PX, children: editor }), _jsx(GridRefusal, { reason: session.refusal })] }));
|
|
37
37
|
} }));
|
|
38
38
|
}
|
|
@@ -28,7 +28,7 @@ export declare function GridValueListEditor({ field, title, initial, labels, all
|
|
|
28
28
|
onCommit: (payload: ValuesPayload) => void;
|
|
29
29
|
onCancel: () => void;
|
|
30
30
|
onTab?: (backwards: boolean) => void;
|
|
31
|
-
/** Commit happened via Enter
|
|
31
|
+
/** Commit happened via Enter: the grid's answer, which keeps the cell. */
|
|
32
32
|
onEnter?: () => void;
|
|
33
33
|
/** `one`: a single value opened as a list of one; `initial`, `refuse` and `onCommit` take its string. */
|
|
34
34
|
holds?: "one" | "several";
|
|
@@ -25,5 +25,5 @@ export function GridValueListEditor({ field, title, initial, labels, allowEmpty
|
|
|
25
25
|
onTab,
|
|
26
26
|
onEnter,
|
|
27
27
|
});
|
|
28
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: () => (_jsx(ValueListEditor, { ref: listRef, field: field, label: typeof title === "string" ? title : undefined, initial: one ? listOfOne(initial) : initial, labels: labels && !one, holds: holds, seed: one ? seed : undefined, allowEmpty: allowEmpty, region: region, escapeKeeps: session.keeps ?? false, onRequestClose: close })) })] }));
|
|
28
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: place.sideOffset, alignOffset: place.alignOffset, initialFocus: false, panelData: { "data-slot": "vk-grid-editor", ...panel.data }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: panel.className, children: () => (_jsx(ValueListEditor, { ref: listRef, field: field, label: typeof title === "string" ? title : undefined, initial: one ? listOfOne(initial) : initial, labels: labels && !one, holds: holds, seed: one ? seed : undefined, allowEmpty: allowEmpty, region: region, escapeKeeps: session.keeps ?? false, onRequestClose: close })) })] }));
|
|
29
29
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
|
-
/** The
|
|
3
|
-
export
|
|
2
|
+
/** The offsets a grid editor hands the popover around the app's body. */
|
|
3
|
+
export type GridBodyPlace = {
|
|
4
|
+
sideOffset: number;
|
|
5
|
+
alignOffset: number;
|
|
6
|
+
};
|
|
7
|
+
/** The offsets a grid editor hands its panel around the app's body: over the cell, a step up and a step left of it. */
|
|
8
|
+
export declare function useGridBodyPlace(anchor: RefObject<HTMLElement | null>): GridBodyPlace;
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useLayoutEffect, useState } from "react";
|
|
3
3
|
const UNDER = 4;
|
|
4
|
+
const stepOf = (el) => parseFloat(getComputedStyle(el).getPropertyValue("--vk-spacing")) || 0;
|
|
4
5
|
export function useGridBodyPlace(anchor) {
|
|
5
|
-
const [
|
|
6
|
+
const [at, setAt] = useState(null);
|
|
6
7
|
useLayoutEffect(() => {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const el = anchor.current;
|
|
9
|
+
if (!el)
|
|
10
|
+
return;
|
|
11
|
+
const height = el.getBoundingClientRect().height, step = stepOf(el);
|
|
12
|
+
setAt((now) => (now && now.height === height && now.step === step ? now : { height, step }));
|
|
9
13
|
}, [anchor]);
|
|
10
|
-
return
|
|
14
|
+
return at ? { sideOffset: -(at.height + at.step), alignOffset: -at.step } : { sideOffset: UNDER, alignOffset: 0 };
|
|
11
15
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ROW_NO_TEXT_SELECT } from "../../selection/row-click.js";
|
|
2
2
|
import { cx } from "../../internal/cx.js";
|
|
3
3
|
import { GRID_CELL_HOVER_RING, GRID_CELL_HOVER_SHADOW, gridFrozenBg } from "./GridCellOutline.js";
|
|
4
|
-
import {
|
|
4
|
+
import { GRID_ONE_LINE } from "./grid-styles.js";
|
|
5
5
|
const GRID_CELL_REQUESTED = "italic opacity-80";
|
|
6
6
|
export const GRID_TITLE_LINK_CLASS = "**:data-cell-open:underline-offset-(--vk-underline-offset,2px) [&_[data-cell-open]:hover]:text-(color:--vk-fg-brand) [&_[data-cell-open]:hover]:underline";
|
|
7
7
|
export const GRID_TITLE_DATA = { "data-slot": "vk-grid-title" };
|
|
@@ -55,7 +55,7 @@ export function gridCellClassName(state) {
|
|
|
55
55
|
: "z-5"
|
|
56
56
|
: inRange
|
|
57
57
|
? "z-4"
|
|
58
|
-
: undefined, frozen && gridFrozenBg(selected,
|
|
58
|
+
: undefined, frozen && gridFrozenBg(selected, "while-scrolled", state.highlight), !focused &&
|
|
59
59
|
!editing &&
|
|
60
60
|
!inRange &&
|
|
61
61
|
!state.isTitle &&
|
|
@@ -7,6 +7,10 @@ export declare const GRID_SHEET_EXIT_MS = 500;
|
|
|
7
7
|
type Handle<P> = {
|
|
8
8
|
resolveClose: (reason: CloseReason) => CloseResolution<P>;
|
|
9
9
|
};
|
|
10
|
+
/** The cell around a grid editor, told the moment the editor starts to close: its session accepted an answer, and the
|
|
11
|
+
* popover or the sheet begins its exit. With the reason the session closed by (null where it names none). The cell
|
|
12
|
+
* stops wearing the editing state then, not once the exit is over, and a press away lets its pick go. */
|
|
13
|
+
export declare const GridEditClosingContext: import("react").Context<((reason: CloseReason | null) => void) | null>;
|
|
10
14
|
export type GridEditSessionArgs<P> = {
|
|
11
15
|
editorRef: RefObject<Handle<P> | null>;
|
|
12
16
|
/** Reshapes a commit before it is judged and written (a day field's timestamp trimmed to its day). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
import { useContext, useEffect, useRef, useState } from "react";
|
|
3
|
+
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { useAnchoredEditSession } from "../../editors/edit-session.js";
|
|
5
5
|
import { EditFieldTypeContext, EditOpensListContext, useEscapeRule } from "../../editors/escape-rule.js";
|
|
6
6
|
import { registerGridEditEscape } from "./grid-edit-escape.js";
|
|
@@ -8,17 +8,22 @@ import { useKeepInside } from "../../editors/keep-inside.js";
|
|
|
8
8
|
import { useViews } from "../../provider/context.js";
|
|
9
9
|
import { useDesktop } from "../../provider/desktop.js";
|
|
10
10
|
export const GRID_SHEET_EXIT_MS = 500;
|
|
11
|
+
export const GridEditClosingContext = createContext(null);
|
|
11
12
|
export function useGridEditSession(args) {
|
|
12
13
|
const { editorRef, mapPayload, inPlace = false } = args;
|
|
13
14
|
const desktop = useDesktop();
|
|
14
15
|
const { ports } = useViews();
|
|
16
|
+
const closing = useContext(GridEditClosingContext);
|
|
15
17
|
const [sheet] = useState(!desktop);
|
|
16
18
|
const escape = useEscapeRule(useContext(EditFieldTypeContext), useContext(EditOpensListContext));
|
|
17
19
|
const latest = useRef(args);
|
|
20
|
+
const closingRef = useRef(closing);
|
|
18
21
|
useEffect(() => {
|
|
19
22
|
latest.current = args;
|
|
23
|
+
closingRef.current = closing;
|
|
20
24
|
});
|
|
21
25
|
const viaRef = useRef(null);
|
|
26
|
+
const reasonRef = useRef(null);
|
|
22
27
|
const keptRef = useRef(null);
|
|
23
28
|
const refusedRef = useRef(null);
|
|
24
29
|
const movedRef = useRef(false);
|
|
@@ -81,6 +86,8 @@ export function useGridEditSession(args) {
|
|
|
81
86
|
refusedRef.current = reason;
|
|
82
87
|
if (reason !== null)
|
|
83
88
|
return { accepted: false, reason };
|
|
89
|
+
if (!leavingRef.current)
|
|
90
|
+
closingRef.current?.(reasonRef.current);
|
|
84
91
|
if (inPlace && !sheet)
|
|
85
92
|
write(answer, true);
|
|
86
93
|
else
|
|
@@ -104,6 +111,7 @@ export function useGridEditSession(args) {
|
|
|
104
111
|
return;
|
|
105
112
|
leavingRef.current = false;
|
|
106
113
|
viaRef.current = reason;
|
|
114
|
+
reasonRef.current = reason;
|
|
107
115
|
session.close(reason);
|
|
108
116
|
};
|
|
109
117
|
const closeRef = useRef(close);
|
|
@@ -119,6 +127,7 @@ export function useGridEditSession(args) {
|
|
|
119
127
|
leavingRef.current = false;
|
|
120
128
|
if (session.open)
|
|
121
129
|
viaRef.current = null;
|
|
130
|
+
reasonRef.current = reason;
|
|
122
131
|
session.close(reason);
|
|
123
132
|
};
|
|
124
133
|
return { session: { ...session, close: closeFromPanel }, close, sheet };
|
|
@@ -6,6 +6,16 @@
|
|
|
6
6
|
* the cell, leftward in a right-aligned column, when its unit or country leaves the value too little room.
|
|
7
7
|
*/
|
|
8
8
|
export declare const GRID_EDITOR_LAYER = "absolute -inset-px z-2 flex min-w-0";
|
|
9
|
+
/**
|
|
10
|
+
* What a cell typed in shows: only the caret. The layer tells ViewKit's Inline input it stands in a cell
|
|
11
|
+
* (`data-inline-input-place`, inline-input.css): no edge, no ring and no ground of its own, so the cell shows as it was;
|
|
12
|
+
* grown past its cell, the plain ground, never lifted. A text grows from the cell as the "In the cell" look grows it, whatever
|
|
13
|
+
* the page's text look (`data-text-editor-box`). An app's own body draws its own look.
|
|
14
|
+
*/
|
|
15
|
+
export declare const GRID_TYPE_IN: {
|
|
16
|
+
readonly "data-inline-input-place": "cell";
|
|
17
|
+
readonly "data-text-editor-box": "cell";
|
|
18
|
+
};
|
|
9
19
|
/** The least room a body's value keeps beside its unit's button or a phone's country, empty or not: a few digits and
|
|
10
20
|
* the caret. */
|
|
11
21
|
export declare const BODY_FIGURE_ROOM_PX = 48;
|
|
@@ -7,14 +7,14 @@ import { type ReactNode, type RefObject } from "react";
|
|
|
7
7
|
* cell: the grid's visible edge on that side. Past it, the value scrolls in its box.
|
|
8
8
|
* Measured as it opens, before the panel brings it into view (a child's layout effect runs first), and
|
|
9
9
|
* again at every keystroke: the input says by how much its text overflows it, and the box takes that
|
|
10
|
-
* much more. Grown, it
|
|
11
|
-
*
|
|
12
|
-
*
|
|
10
|
+
* much more. Grown, it lays the plain ground (the overlay's) under itself, with no edge and no lift, so what it stands
|
|
11
|
+
* over doesn't show through, and the cell rises over the frozen columns (`data-grown`, `gridCellClassName`).
|
|
12
|
+
* A body (`edge={false}`) draws its own ground, which grows with the box, so the box lays none; its value shares the
|
|
13
13
|
* box with a unit or a country, so it keeps `room` to type in even when empty.
|
|
14
14
|
*/
|
|
15
15
|
export declare function GridFittedBox({ boxRef, edge, room, grows, children, }: {
|
|
16
16
|
boxRef: RefObject<HTMLSpanElement | null>;
|
|
17
|
-
/** The
|
|
17
|
+
/** The plain ground under the grown box: false where what it holds draws its own. */
|
|
18
18
|
edge?: boolean;
|
|
19
19
|
/** The pixels the input keeps at least, its value or not: a box that shares the cell with a unit's button. */
|
|
20
20
|
room?: number;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useLayoutEffect } from "react";
|
|
4
|
-
import { cx } from "../../internal/cx.js";
|
|
5
|
-
import { GRID_EDITING_SHADOW, GRID_GROUND } from "./grid-styles.js";
|
|
6
4
|
function roomBeside(box, grows) {
|
|
7
5
|
const at = box.getBoundingClientRect();
|
|
8
6
|
if (at.width === 0 && at.height === 0)
|
|
@@ -32,5 +30,5 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, grows = "right",
|
|
|
32
30
|
}
|
|
33
31
|
}, [boxRef, room, grows]);
|
|
34
32
|
useLayoutEffect(fit, [fit]);
|
|
35
|
-
return (_jsxs("span", { ref: boxRef, onInput: fit, className: "group/fitted relative flex h-full w-full min-w-0 shrink-0 data-grown:z-2", children: [edge && (_jsx("span", { "aria-hidden": true, className:
|
|
33
|
+
return (_jsxs("span", { ref: boxRef, onInput: fit, className: "group/fitted relative flex h-full w-full min-w-0 shrink-0 data-grown:z-2", children: [edge && (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-y-0 -inset-x-(--vk-px) -z-1 hidden rounded-sm bg-(color:--vk-overlay) group-data-grown/fitted:block" })), children] }));
|
|
36
34
|
}
|
|
@@ -69,9 +69,9 @@ export declare function GridRowHoverActions<Row>({ views, rowKey, row, selected,
|
|
|
69
69
|
* A pick-list's ▾: the cue that the value is a choice, and its one-click
|
|
70
70
|
* opener. A real button (the row's click contract lets real controls win), so
|
|
71
71
|
* clicking it opens the picker directly, with no select-first step. Drawn on the
|
|
72
|
-
* cell under the pointer,
|
|
73
|
-
*
|
|
74
|
-
* lands during the exit
|
|
72
|
+
* cell under the pointer, the same whether its picker is open or not: an open
|
|
73
|
+
* picker leaves its cell as it was. A click on it while its picker
|
|
74
|
+
* is open opens nothing (it lands during the exit and can't reopen). Never drawn on a phone,
|
|
75
75
|
* where a tap selects the cell and a second opens its editor in a sheet.
|
|
76
76
|
*/
|
|
77
77
|
export declare function GridPickerCaret({ rowKey, colId, editing, onOpen, }: {
|