viewkitjs 0.35.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 +112 -0
- package/MIGRATION.md +7 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +32 -9
- package/views/dist/contract.js +35 -1
- package/views/dist/controls/avatar/avatar.d.ts +3 -1
- package/views/dist/controls/avatar/avatar.js +2 -2
- 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/compound-editor/map-parts-body.js +2 -0
- package/views/dist/controls/compound-editor/name-parts.js +1 -1
- package/views/dist/controls/compound-editor/place-parts.js +1 -1
- package/views/dist/controls/compound-editor/range-parts.js +1 -1
- package/views/dist/controls/compound-editor/words.d.ts +3 -0
- package/views/dist/controls/compound-editor/words.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +10 -3
- package/views/dist/controls/customize/customize.js +147 -63
- package/views/dist/controls/customize/items.d.ts +49 -0
- package/views/dist/controls/customize/items.js +104 -0
- package/views/dist/controls/customize/map-customize-body.js +7 -4
- package/views/dist/controls/customize/words.d.ts +2 -0
- package/views/dist/controls/customize/words.js +1 -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/block.js +5 -2
- package/views/dist/controls/filter-editor/filter-editor.d.ts +14 -1
- package/views/dist/controls/filter-editor/filter-editor.js +21 -13
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
- package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
- package/views/dist/controls/filter-editor/map-rules.js +18 -13
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +13 -12
- package/views/dist/controls/filter-editor/rules.d.ts +4 -4
- package/views/dist/controls/filter-editor/rules.js +6 -3
- package/views/dist/controls/filter-editor/words.d.ts +2 -0
- package/views/dist/controls/filter-editor/words.js +1 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
- package/views/dist/controls/group-editor/group-editor.js +21 -15
- package/views/dist/controls/group-editor/map-group-body.js +1 -0
- package/views/dist/controls/index.d.ts +4 -2
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +9 -0
- package/views/dist/controls/internal/kit-words.d.ts +11 -0
- package/views/dist/controls/internal/kit-words.js +7 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
- package/views/dist/controls/internal/map-panel-controls.js +14 -1
- package/views/dist/controls/internal/menu-items.d.ts +9 -0
- package/views/dist/controls/internal/menu-items.js +97 -0
- package/views/dist/controls/internal/panel-controls.js +1 -1
- 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/menu.d.ts +1 -1
- package/views/dist/controls/menu/menu.js +1 -1
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/number-editor/map-number-body.js +2 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/number-editor/words.d.ts +3 -0
- package/views/dist/controls/number-editor/words.js +2 -0
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker/fields-frame.d.ts +5 -0
- package/views/dist/controls/picker/fields-frame.js +30 -0
- package/views/dist/controls/picker/map-fields-body.js +3 -26
- package/views/dist/controls/picker/map-picker.d.ts +2 -1
- package/views/dist/controls/picker/map-picker.js +4 -2
- package/views/dist/controls/picker/picker.js +9 -2
- package/views/dist/controls/picker/rows.d.ts +3 -1
- package/views/dist/controls/picker.css +7 -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/map-select.d.ts +1 -1
- package/views/dist/controls/select/map-select.js +4 -1
- package/views/dist/controls/select/select.d.ts +2 -0
- package/views/dist/controls/select/select.js +4 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
- package/views/dist/controls/sheet/bottom-sheet.js +3 -3
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +3 -1
- package/views/dist/controls/sort-editor/sort-editor.js +6 -4
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/tag/tag.js +4 -2
- package/views/dist/controls/text-editor/map-text-body.js +4 -1
- package/views/dist/controls/text-editor/text-editor.js +2 -2
- package/views/dist/controls/text-editor/words.d.ts +3 -0
- package/views/dist/controls/text-editor/words.js +1 -1
- package/views/dist/controls/text-editor.css +6 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +12 -4
- 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/controls/views-list/map-views-list-body.js +9 -1
- package/views/dist/controls/views-list/rules.d.ts +1 -0
- package/views/dist/controls/views-list/rules.js +2 -2
- package/views/dist/controls/views-list/view-menu.js +2 -2
- package/views/dist/controls/views-list/words.d.ts +4 -0
- package/views/dist/controls/views-list/words.js +2 -1
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/display/option-badges.d.ts +3 -2
- package/views/dist/display/option-badges.js +2 -2
- package/views/dist/field-row/FieldRow.js +12 -8
- package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
- package/views/dist/grid/chrome/GridAddColumn.js +5 -4
- 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/GridHeader.js +3 -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/GridRow.js +7 -1
- 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/GridTableSurface.js +2 -1
- 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 +9 -6
- package/views/dist/grid/chrome/grid-fitted-box.js +15 -7
- 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/grid-table-props.d.ts +6 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +2 -10
- package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
- package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
- 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-format-props.d.ts +1 -1
- package/views/dist/grid/grid-format-props.js +18 -5
- package/views/dist/grid/grid.css +9 -20
- package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/views/dist/grid/useGridTableSettings.d.ts +1 -1
- 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 +4 -3
- package/views/dist/list/menu.d.ts +5 -4
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +11 -5
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/customize-body.d.ts +1 -1
- package/views/dist/panels/customize-body.js +8 -1
- package/views/dist/panels/model.d.ts +5 -0
- package/views/dist/panels/react/customize-body.js +11 -2
- package/views/dist/panels/react/customize.d.ts +3 -0
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
- package/views/dist/panels/react/filter/filter-body.js +3 -1
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-part-body.js +2 -2
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/sort/SortEditor.js +3 -1
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +15 -4
- 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/ToolbarBarFilter.js +5 -3
- 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.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- 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/toolbar/editor-menus.d.ts +8 -0
- package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +26 -11
- package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
- package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +7 -10
- 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/views-row/new-view.d.ts +11 -0
- package/views/dist/panels/react/views-row/new-view.js +21 -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 +88 -8
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +198 -84
- package/views/dist/styles.unlayered.css +198 -84
- package/views/docs/contract.md +87 -32
- 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 +24 -18
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +4 -4
- package/views/docs/reference/list.md +30 -11
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +7 -6
- package/views/docs/reference/panels.md +2 -2
- package/views/docs/reference/react.md +22 -10
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -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, 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, 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,6 +31,12 @@ function GridRowInner(props) {
|
|
|
31
31
|
const More = icons.more;
|
|
32
32
|
const { row, id, columns, selectable, selected, selectedAbove, selecting, toggle, toggleRange, rowClassName, rowHref, onOpenRow, onPrefetchRow, editingEnabled, focusedColId, editingColId, onFocusCell, rowKey, onStartEdit, onRefuseEdit, rowWritable = true, onExtendCell, onAddCell, ariaRowIndex, ariaLevel, ariaPosInSet, ariaSetSize, ariaTailIndex, } = props;
|
|
33
33
|
const href = rowHref?.(row);
|
|
34
|
+
const offersMenu = selectable ||
|
|
35
|
+
!!props.contextMenu ||
|
|
36
|
+
!!props.rowMenuReshape ||
|
|
37
|
+
!!rowHref ||
|
|
38
|
+
!!props.onRowDelete ||
|
|
39
|
+
!!props.rowActions?.some((action) => !!action.onClick);
|
|
34
40
|
const canEdit = (col) => editingEnabled && rowWritable && gridColumnHasEditor(col) && columnEffectiveWritable(col, props.listConfig);
|
|
35
41
|
const refuse = (columnId) => (rowWritable ? onRefuseEdit?.(columnId) : onRefuseEdit?.(columnId, false));
|
|
36
42
|
const whole = (col, cell) => isWholeTextColumn(col) && gridCellCutOff(cell);
|
|
@@ -147,7 +153,7 @@ function GridRowInner(props) {
|
|
|
147
153
|
}, onPointerLeave: (e) => {
|
|
148
154
|
rest.onPointerLeave();
|
|
149
155
|
hover.onPointerLeave(e);
|
|
150
|
-
}, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: aimMenu ? (event) => aimMenu(rowKey, event) : undefined, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row), highlight }), children: [selected && !selectedAbove && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("top") }), selected && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("bottom") }), selectable && props.checkColumnId != null ? (_jsx(GridRailSpacer, { selecting: selecting, bordered: true, shadow: false, cell: "row" })) : selectable ? (_jsx(GridRowCheck, { selecting: selecting, checked: selected, revealed: selected, onChange: (next, shift) => (shift ? toggleRange(id) : toggle(id, next)), "aria-label": messages({ key: "views.grid.select-row" }) })) : (_jsx(GridRailSpacer, { selecting: false, bordered: true, shadow: false })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, style: GRID_TAIL_PLACE, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: drawGridButton(views, {
|
|
156
|
+
}, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: aimMenu ? (event) => aimMenu(rowKey, event) : undefined, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row), highlight }), children: [selected && !selectedAbove && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("top") }), selected && _jsx("span", { "aria-hidden": true, className: gridSelectionEdgeClass("bottom") }), selectable && props.checkColumnId != null ? (_jsx(GridRailSpacer, { selecting: selecting, bordered: true, shadow: false, cell: "row" })) : selectable ? (_jsx(GridRowCheck, { selecting: selecting, checked: selected, revealed: selected, onChange: (next, shift) => (shift ? toggleRange(id) : toggle(id, next)), "aria-label": messages({ key: "views.grid.select-row" }) })) : (_jsx(GridRailSpacer, { selecting: false, bordered: true, shadow: false })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, style: GRID_TAIL_PLACE, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: offersMenu && drawGridButton(views, {
|
|
151
157
|
tabIndex: -1,
|
|
152
158
|
"data-slot": "vk-grid-row-more",
|
|
153
159
|
"aria-label": messages({ key: "views.grid.row-menu" }),
|
|
@@ -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),
|
|
@@ -5,6 +5,7 @@ import { cx } from "../../internal/cx.js";
|
|
|
5
5
|
import { BarRoomContext } from "../../selection/bar-room.js";
|
|
6
6
|
import { GRID_BLEED } from "./grid-styles.js";
|
|
7
7
|
import { useBarRoom } from "./useBarRoom.js";
|
|
8
|
+
import { GRID_HEIGHTS } from "./useGridScaleStyles.js";
|
|
8
9
|
export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selecting, minWidth, columnsTemplate, railRootProps, onPointerDown, onPointerDownCapture, onClickCapture, railProbe, body, loadMore, pager, selectionBar, onGuardFocus, gridAria, empty, pinFooter, desktop = true, }) {
|
|
9
10
|
const endGuardRef = useRef(null);
|
|
10
11
|
const { room, ownBarRef } = useBarRoom(selecting, rootRef, endGuardRef);
|
|
@@ -19,7 +20,7 @@ export function GridTableSurface({ rootRef, areaRef, panRef, boxes, style, selec
|
|
|
19
20
|
paddingBottom: footAt && pinFooter?.flush ? footAt : `calc(${foot} + 0.5rem)`,
|
|
20
21
|
...(footAt ? { "--vk-foot-at": footAt } : {}),
|
|
21
22
|
}, children: [body, loadMore ? (_jsx("div", { role: "row", children: _jsx("div", { role: "gridcell", "aria-colspan": gridAria?.colCount, children: loadMore }) })) : null] }));
|
|
22
|
-
const frame = (_jsxs("div", { ref: rootRef, style: style, tabIndex: -1, className: "group/gridtable relative isolate flex h-full min-h-0 flex-1 flex-col animate-fade-in outline-none", "data-slot": "vk-grid", "data-empty": empty ? "" : undefined, "data-desktop": desktop ? "" : undefined, ...railRootProps, onPointerDown: onPointerDown, onPointerDownCapture: onPointerDownCapture, onClickCapture: onClickCapture, children: [_jsx("span", { "data-grid-guard": "start", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("start", event.relatedTarget) }), boxes === 2 ? (_jsx("div", { ref: panRef, "data-slot": "vk-grid-pan", className: cx("@container flex min-h-0 flex-1 flex-col", GRID_BLEED), style: { overflowX: "auto", overflowY: "hidden", overscrollBehaviorX: "contain" }, children: _jsx("div", { ref: areaRef, "data-slot": "vk-grid-scroll", className: "min-h-0 flex-1", style: {
|
|
23
|
+
const frame = (_jsxs("div", { ref: rootRef, style: style, tabIndex: -1, className: cx("group/gridtable relative isolate flex h-full min-h-0 flex-1 flex-col animate-fade-in outline-none", GRID_HEIGHTS), "data-slot": "vk-grid", "data-empty": empty ? "" : undefined, "data-desktop": desktop ? "" : undefined, ...railRootProps, onPointerDown: onPointerDown, onPointerDownCapture: onPointerDownCapture, onClickCapture: onClickCapture, children: [_jsx("span", { "data-grid-guard": "start", tabIndex: 0, className: "absolute size-0 overflow-hidden outline-none", onFocus: (event) => onGuardFocus?.("start", event.relatedTarget) }), boxes === 2 ? (_jsx("div", { ref: panRef, "data-slot": "vk-grid-pan", className: cx("@container flex min-h-0 flex-1 flex-col", GRID_BLEED), style: { overflowX: "auto", overflowY: "hidden", overscrollBehaviorX: "contain" }, children: _jsx("div", { ref: areaRef, "data-slot": "vk-grid-scroll", className: "min-h-0 flex-1", style: {
|
|
23
24
|
overflowX: "hidden",
|
|
24
25
|
overflowY: "auto",
|
|
25
26
|
minWidth,
|
|
@@ -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;
|
|
@@ -3,19 +3,22 @@ import { type ReactNode, type RefObject } from "react";
|
|
|
3
3
|
* THE IN-PLACE EDITOR'S BOX, AS WIDE AS WHAT IS TYPED IN IT — an amount and its unit, or a line of
|
|
4
4
|
* text (a link, an email, a phone, a domain, plain text). It is the cell's width until the value doesn't
|
|
5
5
|
* fit; then it grows past the cell, away from the side the column aligns to (a right-aligned column's
|
|
6
|
-
* box grows left, its amount still flush with the column's edge; a text's grows right),
|
|
6
|
+
* box grows left, its amount still flush with the column's edge; a text's grows right), as far as the room beside the
|
|
7
|
+
* cell: the grid's visible edge on that side. Past it, the value scrolls in its box.
|
|
7
8
|
* Measured as it opens, before the panel brings it into view (a child's layout effect runs first), and
|
|
8
9
|
* again at every keystroke: the input says by how much its text overflows it, and the box takes that
|
|
9
|
-
* much more. Grown, it
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
|
12
13
|
* box with a unit or a country, so it keeps `room` to type in even when empty.
|
|
13
14
|
*/
|
|
14
|
-
export declare function GridFittedBox({ boxRef, edge, room, children, }: {
|
|
15
|
+
export declare function GridFittedBox({ boxRef, edge, room, grows, children, }: {
|
|
15
16
|
boxRef: RefObject<HTMLSpanElement | null>;
|
|
16
|
-
/** The
|
|
17
|
+
/** The plain ground under the grown box: false where what it holds draws its own. */
|
|
17
18
|
edge?: boolean;
|
|
18
19
|
/** The pixels the input keeps at least, its value or not: a box that shares the cell with a unit's button. */
|
|
19
20
|
room?: number;
|
|
21
|
+
/** The side it grows to: right for a text, left for an amount in a right-aligned column (its box at the cell's end). */
|
|
22
|
+
grows?: "left" | "right";
|
|
20
23
|
children: ReactNode;
|
|
21
24
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,10 +1,18 @@
|
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
function roomBeside(box, grows) {
|
|
5
|
+
const at = box.getBoundingClientRect();
|
|
6
|
+
if (at.width === 0 && at.height === 0)
|
|
7
|
+
return Infinity;
|
|
8
|
+
const page = { left: 0, right: document.documentElement.clientWidth || window.innerWidth };
|
|
9
|
+
const area = box.closest('[data-slot="vk-grid-scroll"]');
|
|
10
|
+
const seen = area?.getBoundingClientRect();
|
|
11
|
+
const left = seen ? Math.max(page.left, seen.left + area.clientLeft) : page.left;
|
|
12
|
+
const right = seen ? Math.min(page.right, seen.left + area.clientLeft + area.clientWidth) : page.right;
|
|
13
|
+
return Math.floor(grows === "left" ? at.right - left : right - at.left);
|
|
14
|
+
}
|
|
15
|
+
export function GridFittedBox({ boxRef, edge = true, room = 0, grows = "right", children, }) {
|
|
8
16
|
const fit = useCallback(() => {
|
|
9
17
|
const box = boxRef.current;
|
|
10
18
|
const input = box?.querySelector("input");
|
|
@@ -12,7 +20,7 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
|
|
|
12
20
|
return;
|
|
13
21
|
box.style.minWidth = "";
|
|
14
22
|
const over = Math.max(input.scrollWidth, room) - input.clientWidth;
|
|
15
|
-
const width = over > 0 ? Math.min(box.offsetWidth + over + 1,
|
|
23
|
+
const width = over > 0 ? Math.min(box.offsetWidth + over + 1, roomBeside(box, grows)) : 0;
|
|
16
24
|
if (width > box.offsetWidth) {
|
|
17
25
|
box.style.minWidth = `${width}px`;
|
|
18
26
|
box.dataset.grown = "";
|
|
@@ -20,7 +28,7 @@ export function GridFittedBox({ boxRef, edge = true, room = 0, children, }) {
|
|
|
20
28
|
else {
|
|
21
29
|
delete box.dataset.grown;
|
|
22
30
|
}
|
|
23
|
-
}, [boxRef, room]);
|
|
31
|
+
}, [boxRef, room, grows]);
|
|
24
32
|
useLayoutEffect(fit, [fit]);
|
|
25
|
-
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] }));
|
|
26
34
|
}
|