@viewkitjs/views 0.2.0 → 0.3.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 +571 -0
- package/README.md +5 -3
- package/dist/atoms/LoadMore.js +11 -1
- package/dist/atoms/RowMenu.js +5 -2
- package/dist/cells/cell-format.d.ts +3 -3
- package/dist/cells/cell-title.d.ts +1 -2
- package/dist/cells/cell-title.js +2 -2
- package/dist/cells/cell-values.js +6 -3
- package/dist/contract.d.ts +50 -9
- package/dist/contract.js +33 -5
- package/dist/display/converted.d.ts +19 -0
- package/dist/display/converted.js +12 -0
- package/dist/display/index.d.ts +1 -0
- package/dist/display/index.js +1 -0
- package/dist/display/link-click.d.ts +11 -0
- package/dist/display/link-click.js +3 -0
- package/dist/display/link.js +7 -3
- package/dist/display/multi-value.d.ts +1 -1
- package/dist/display/multi-value.js +1 -1
- package/dist/display/options.d.ts +7 -1
- package/dist/display/phone.js +3 -1
- package/dist/editors/ChipsEditor.d.ts +9 -4
- package/dist/editors/ChipsEditor.js +6 -2
- package/dist/editors/DateEditor.d.ts +21 -6
- package/dist/editors/DateEditor.js +118 -30
- package/dist/editors/EditorPanel.d.ts +61 -0
- package/dist/editors/EditorPanel.js +54 -0
- package/dist/editors/LocationEditor.d.ts +3 -0
- package/dist/editors/LocationEditor.js +14 -6
- package/dist/editors/NameEditor.d.ts +3 -0
- package/dist/editors/NameEditor.js +11 -7
- package/dist/editors/NumberEditor.d.ts +3 -0
- package/dist/editors/NumberEditor.js +6 -6
- package/dist/editors/RangeEditor.d.ts +16 -1
- package/dist/editors/RangeEditor.js +21 -5
- package/dist/editors/RelationEditor.d.ts +13 -28
- package/dist/editors/RelationEditor.js +17 -40
- package/dist/editors/RelationSetEditor.d.ts +53 -0
- package/dist/editors/RelationSetEditor.js +112 -0
- package/dist/editors/SelectEditor.d.ts +21 -3
- package/dist/editors/SelectEditor.js +55 -9
- package/dist/editors/TextEditor.d.ts +51 -0
- package/dist/editors/TextEditor.js +81 -0
- package/dist/editors/ValueListEditor.d.ts +3 -0
- package/dist/editors/ValueListEditor.js +4 -2
- package/dist/editors/edit-cores.d.ts +12 -9
- package/dist/editors/edit-cores.js +7 -6
- package/dist/editors/edit-session.d.ts +21 -11
- package/dist/editors/edit-session.js +19 -5
- package/dist/editors/keep-inside.d.ts +12 -0
- package/dist/editors/keep-inside.js +20 -0
- package/dist/editors/open-value.d.ts +21 -0
- package/dist/editors/open-value.js +36 -0
- package/dist/editors/open-values.d.ts +4 -0
- package/dist/editors/open-values.js +7 -0
- package/dist/editors/relation-kinds.d.ts +7 -0
- package/dist/editors/relation-kinds.js +21 -0
- package/dist/editors/relation-panel.d.ts +69 -0
- package/dist/editors/relation-panel.js +40 -0
- package/dist/field-row/FieldNoteLine.d.ts +14 -0
- package/dist/field-row/FieldNoteLine.js +14 -0
- package/dist/field-row/FieldRow.d.ts +73 -0
- package/dist/field-row/FieldRow.js +157 -0
- package/dist/field-row/FieldRowLane.d.ts +19 -0
- package/dist/field-row/FieldRowLane.js +11 -0
- package/dist/field-row/editors/RowChipsEditor.d.ts +11 -0
- package/dist/field-row/editors/RowChipsEditor.js +25 -0
- package/dist/field-row/editors/RowDateEditor.d.ts +16 -0
- package/dist/field-row/editors/RowDateEditor.js +18 -0
- package/dist/field-row/editors/RowEditor.d.ts +39 -0
- package/dist/field-row/editors/RowEditor.js +64 -0
- package/dist/field-row/editors/RowNameEditor.d.ts +4 -0
- package/dist/field-row/editors/RowNameEditor.js +15 -0
- package/dist/field-row/editors/RowNumberEditor.d.ts +12 -0
- package/dist/field-row/editors/RowNumberEditor.js +18 -0
- package/dist/field-row/editors/RowPlaceEditor.d.ts +8 -0
- package/dist/field-row/editors/RowPlaceEditor.js +18 -0
- package/dist/field-row/editors/RowRangeEditor.d.ts +4 -0
- package/dist/field-row/editors/RowRangeEditor.js +15 -0
- package/dist/field-row/editors/RowRelationEditor.d.ts +20 -0
- package/dist/field-row/editors/RowRelationEditor.js +77 -0
- package/dist/field-row/editors/RowSelectEditor.d.ts +13 -0
- package/dist/field-row/editors/RowSelectEditor.js +23 -0
- package/dist/field-row/editors/RowTextEditor.d.ts +15 -0
- package/dist/field-row/editors/RowTextEditor.js +16 -0
- package/dist/field-row/editors/RowValueListEditor.d.ts +4 -0
- package/dist/field-row/editors/RowValueListEditor.js +21 -0
- package/dist/field-row/editors/host.d.ts +59 -0
- package/dist/field-row/editors/host.js +1 -0
- package/dist/field-row/editors/row-session.d.ts +49 -0
- package/dist/field-row/editors/row-session.js +49 -0
- package/dist/field-row/index.d.ts +5 -0
- package/dist/field-row/index.js +5 -0
- package/dist/field-row/row-target.d.ts +20 -0
- package/dist/field-row/row-target.js +3 -0
- package/dist/field-row/useFieldWrite.d.ts +45 -0
- package/dist/field-row/useFieldWrite.js +190 -0
- package/dist/field-row/useRowSettlement.d.ts +33 -0
- package/dist/field-row/useRowSettlement.js +23 -0
- package/dist/fields/binding.d.ts +6 -1
- package/dist/fields/binding.js +13 -6
- package/dist/fields/edit-core-types.d.ts +9 -9
- package/dist/fields/edit-core-types.js +6 -6
- package/dist/fields/money.d.ts +5 -0
- package/dist/fields/money.js +10 -0
- package/dist/fields/number-edit.d.ts +6 -0
- package/dist/fields/number-edit.js +4 -0
- package/dist/fields/prepare-write.js +6 -1
- package/dist/fields/relation-source-types.d.ts +12 -0
- package/dist/fields/write-target.d.ts +50 -0
- package/dist/fields/write-target.js +10 -0
- package/dist/grid/chrome/GridAddColumn.js +1 -1
- package/dist/grid/chrome/GridAggregateMenu.d.ts +1 -1
- package/dist/grid/chrome/GridAggregateMenu.js +8 -6
- package/dist/grid/chrome/GridCellEditors.d.ts +7 -0
- package/dist/grid/chrome/GridCellEditors.js +87 -16
- package/dist/grid/chrome/GridCellOutline.d.ts +22 -43
- package/dist/grid/chrome/GridCellOutline.js +2 -7
- package/dist/grid/chrome/GridChipsEditor.d.ts +16 -6
- package/dist/grid/chrome/GridChipsEditor.js +21 -26
- package/dist/grid/chrome/GridColumnMenu.d.ts +1 -1
- package/dist/grid/chrome/GridColumnMenu.js +7 -3
- package/dist/grid/chrome/GridDateEditor.d.ts +23 -11
- package/dist/grid/chrome/GridDateEditor.js +13 -25
- package/dist/grid/chrome/GridFooter.d.ts +12 -2
- package/dist/grid/chrome/GridFooter.js +10 -6
- package/dist/grid/chrome/GridGroupMenu.js +20 -13
- package/dist/grid/chrome/GridHeader.d.ts +9 -4
- package/dist/grid/chrome/GridHeader.js +15 -10
- package/dist/grid/chrome/GridLongTextEditor.d.ts +28 -9
- package/dist/grid/chrome/GridLongTextEditor.js +16 -74
- package/dist/grid/chrome/GridNameEditor.d.ts +11 -6
- package/dist/grid/chrome/GridNameEditor.js +12 -27
- package/dist/grid/chrome/GridNumberEditor.d.ts +20 -6
- package/dist/grid/chrome/GridNumberEditor.js +46 -20
- package/dist/grid/chrome/GridPlaceEditor.d.ts +26 -0
- package/dist/grid/chrome/GridPlaceEditor.js +22 -0
- package/dist/grid/chrome/GridRangeEditor.d.ts +15 -5
- package/dist/grid/chrome/GridRangeEditor.js +16 -20
- package/dist/grid/chrome/GridRelationEditor.d.ts +38 -14
- package/dist/grid/chrome/GridRelationEditor.js +86 -24
- package/dist/grid/chrome/GridRow.d.ts +7 -1
- package/dist/grid/chrome/GridRow.js +57 -14
- package/dist/grid/chrome/GridRowActions.js +1 -1
- package/dist/grid/chrome/GridRowCells.js +18 -23
- package/dist/grid/chrome/GridSelectEditor.d.ts +19 -4
- package/dist/grid/chrome/GridSelectEditor.js +21 -27
- package/dist/grid/chrome/GridStructure.d.ts +9 -10
- package/dist/grid/chrome/GridStructure.js +10 -14
- package/dist/grid/chrome/GridTable.js +97 -30
- package/dist/grid/chrome/GridTableSurface.d.ts +39 -2
- package/dist/grid/chrome/GridTableSurface.js +12 -3
- package/dist/grid/chrome/GridTextEditor.d.ts +35 -1
- package/dist/grid/chrome/GridTextEditor.js +35 -37
- package/dist/grid/chrome/GridValueListEditor.d.ts +15 -3
- package/dist/grid/chrome/GridValueListEditor.js +10 -27
- package/dist/grid/chrome/cell-cut-off.d.ts +11 -0
- package/dist/grid/chrome/cell-cut-off.js +20 -0
- package/dist/grid/chrome/cells.js +1 -2
- package/dist/grid/chrome/checks.d.ts +2 -5
- package/dist/grid/chrome/checks.js +15 -5
- package/dist/grid/chrome/editors.d.ts +1 -1
- package/dist/grid/chrome/editors.js +1 -1
- package/dist/grid/chrome/grid-cell-classes.d.ts +2 -8
- package/dist/grid/chrome/grid-cell-classes.js +10 -8
- package/dist/grid/chrome/grid-cell-link.d.ts +13 -0
- package/dist/grid/chrome/grid-cell-link.js +9 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +63 -0
- package/dist/grid/chrome/grid-edit-session.js +118 -0
- package/dist/grid/chrome/grid-hover.d.ts +60 -0
- package/dist/grid/chrome/grid-hover.js +81 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +43 -0
- package/dist/grid/chrome/grid-menu-focus.js +93 -0
- package/dist/grid/chrome/grid-row-menu-key.d.ts +15 -0
- package/dist/grid/chrome/grid-row-menu-key.js +36 -0
- package/dist/grid/chrome/grid-row-props.d.ts +16 -4
- package/dist/grid/chrome/grid-row-window.d.ts +61 -0
- package/dist/grid/chrome/grid-row-window.js +212 -0
- package/dist/grid/chrome/grid-scroll-owner.d.ts +38 -0
- package/dist/grid/chrome/grid-scroll-owner.js +75 -0
- package/dist/grid/chrome/grid-styles.d.ts +4 -1
- package/dist/grid/chrome/grid-styles.js +1 -0
- package/dist/grid/chrome/grid-table-props.d.ts +2 -3
- package/dist/grid/chrome/useGridFocus.d.ts +45 -0
- package/dist/grid/chrome/useGridFocus.js +122 -0
- package/dist/grid/chrome/useGridKeyboard.d.ts +21 -4
- package/dist/grid/chrome/useGridKeyboard.js +214 -38
- package/dist/grid/chrome/useGridRangeActions.d.ts +3 -1
- package/dist/grid/chrome/useGridRangeActions.js +17 -10
- package/dist/grid/chrome/useGridRangeGestures.js +68 -21
- package/dist/grid/chrome/useGridRowContextMenu.d.ts +4 -2
- package/dist/grid/chrome/useGridRowContextMenu.js +28 -2
- package/dist/grid/chrome/useGridScaleStyles.d.ts +3 -1
- package/dist/grid/chrome/useGridScaleStyles.js +6 -7
- package/dist/grid/chrome/useGridScrollArea.d.ts +21 -0
- package/dist/grid/chrome/useGridScrollArea.js +65 -0
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +28 -5
- package/dist/grid/chrome/useGridTableInteractionModel.js +66 -14
- package/dist/grid/chrome/useHeaderDragReorder.d.ts +2 -2
- package/dist/grid/core/clipboard-model.d.ts +2 -0
- package/dist/grid/core/clipboard-model.js +1 -1
- package/dist/grid/core/commit-model.d.ts +7 -0
- package/dist/grid/core/edge-scroll.d.ts +21 -0
- package/dist/grid/core/edge-scroll.js +23 -0
- package/dist/grid/core/editing-controller.d.ts +2 -1
- package/dist/grid/core/editing-controller.js +35 -9
- package/dist/grid/core/editing-model.d.ts +9 -0
- package/dist/grid/core/editing-model.js +12 -0
- package/dist/grid/core/flat-rows.d.ts +35 -0
- package/dist/grid/core/flat-rows.js +20 -0
- package/dist/grid/core/grid-aria.d.ts +27 -0
- package/dist/grid/core/grid-aria.js +39 -0
- package/dist/grid/core/grid-focus.d.ts +54 -0
- package/dist/grid/core/grid-focus.js +148 -0
- package/dist/grid/core/nav.d.ts +2 -2
- package/dist/grid/core/pending-reconciliation.d.ts +3 -0
- package/dist/grid/core/pending-reconciliation.js +5 -3
- package/dist/grid/core/row-window.d.ts +40 -0
- package/dist/grid/core/row-window.js +43 -0
- package/dist/grid/core/spreadsheet-operations.d.ts +17 -1
- package/dist/grid/core/spreadsheet-operations.js +33 -6
- package/dist/grid/core/useGridEditing.d.ts +3 -0
- package/dist/grid/core/useGridEditing.js +6 -3
- package/dist/grid/core/value-equality.d.ts +23 -1
- package/dist/grid/core/value-equality.js +46 -0
- package/dist/grid/useGridTablePrefs.d.ts +0 -1
- package/dist/grid/useGridTablePrefs.js +1 -3
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/viewport.d.ts +0 -2
- package/dist/internal/viewport.js +0 -14
- package/dist/model/column-capabilities.d.ts +2 -1
- package/dist/model/column-capabilities.js +28 -8
- package/dist/model/column-from.js +3 -0
- package/dist/model/column-inspect.d.ts +10 -2
- package/dist/model/column-inspect.js +9 -0
- package/dist/model/column-schema.d.ts +6 -1
- package/dist/model/column-types.d.ts +3 -1
- package/dist/model/column-types.js +1 -1
- package/dist/model/preferences.d.ts +0 -4
- package/dist/model/preferences.js +0 -1
- package/dist/model/prefs-buckets.d.ts +0 -1
- package/dist/model/prefs-buckets.js +0 -3
- package/dist/model/render-count.d.ts +6 -0
- package/dist/model/render-count.js +11 -0
- package/dist/provider/ViewsProvider.d.ts +5 -1
- package/dist/provider/ViewsProvider.js +9 -3
- package/dist/provider/components.d.ts +19 -1
- package/dist/provider/components.js +4 -2
- package/dist/provider/context.d.ts +5 -2
- package/dist/provider/desktop.d.ts +9 -0
- package/dist/provider/desktop.js +22 -0
- package/dist/provider/plain-input.d.ts +8 -0
- package/dist/provider/plain-input.js +5 -0
- package/dist/react.d.ts +2 -1
- package/dist/react.js +1 -0
- package/dist/selection/SelectCheckbox.d.ts +3 -1
- package/dist/selection/SelectCheckbox.js +2 -2
- package/dist/selection/useCheckDragSelect.js +6 -5
- package/docs/contract.md +93 -35
- package/docs/guides/atoms.md +1 -1
- package/docs/guides/cells.md +2 -2
- package/docs/guides/columns.md +3 -2
- package/docs/guides/display.md +1 -0
- package/docs/guides/editors.md +71 -13
- package/docs/guides/the-grid.md +32 -13
- package/docs/guides/the-provider.md +3 -1
- package/docs/index.md +3 -1
- package/docs/install.md +1 -1
- package/docs/reference/cells.md +1 -1
- package/docs/reference/display.md +3 -1
- package/docs/reference/editors-chips.md +2 -2
- package/docs/reference/editors-date.md +3 -3
- package/docs/reference/editors-location.md +1 -1
- package/docs/reference/editors-number.md +1 -1
- package/docs/reference/editors-open-values.md +1 -0
- package/docs/reference/editors-panel.md +12 -0
- package/docs/reference/editors-range.md +1 -1
- package/docs/reference/editors-relation.md +6 -3
- package/docs/reference/editors-select.md +3 -2
- package/docs/reference/editors-session.md +4 -2
- package/docs/reference/editors-text.md +9 -0
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/editors.md +2 -2
- package/docs/reference/field-row.md +16 -0
- package/docs/reference/grid.md +3 -3
- package/docs/reference/react.md +8 -5
- package/docs/reference/views.md +36 -15
- package/package.json +23 -4
- package/skills/views/SKILL.md +4 -4
- package/dist/grid/chrome/useGridScrollSync.d.ts +0 -38
- package/dist/grid/chrome/useGridScrollSync.js +0 -176
|
@@ -1,30 +1,92 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
3
|
+
import { useMemo, useRef } from "react";
|
|
4
|
+
import { RelationEditor, RelationSetEditor, } from "../../editors/RelationEditor.js";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
|
+
import { useGridEditSession } from "./grid-edit-session.js";
|
|
7
|
+
function useKnownKinds(candidates) {
|
|
8
|
+
const seen = useRef(new Map());
|
|
9
|
+
const source = useMemo(() => candidates.kind === "static"
|
|
10
|
+
? candidates
|
|
11
|
+
: {
|
|
12
|
+
...candidates,
|
|
13
|
+
search: async (query, signal, offset) => {
|
|
14
|
+
const items = await candidates.search(query, signal, offset);
|
|
15
|
+
for (const item of items)
|
|
16
|
+
if (item.kind !== undefined)
|
|
17
|
+
seen.current.set(item.id, item.kind);
|
|
18
|
+
return items;
|
|
19
|
+
},
|
|
20
|
+
}, [candidates]);
|
|
21
|
+
const kindOf = (id) => candidates.kind === "static"
|
|
22
|
+
? candidates.items.find((item) => item.id === id)?.kind
|
|
23
|
+
: seen.current.get(id);
|
|
24
|
+
return [source, kindOf];
|
|
25
|
+
}
|
|
26
|
+
export function GridRelationEditor({ title, candidates, current, clearable, seed, create, refuse, onCommit, onLink, onCancel, }) {
|
|
9
27
|
const editorRef = useRef(null);
|
|
10
28
|
const anchorRef = useRef(null);
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
const [source, kindOf] = useKnownKinds(candidates);
|
|
30
|
+
const { session, close, sheet } = useGridEditSession({
|
|
31
|
+
editorRef,
|
|
32
|
+
refuse: refuse &&
|
|
33
|
+
((value) => refuse(value, value == null ? undefined : kindOf(value))),
|
|
34
|
+
onCommit: (id) => onCommit(id, id == null ? undefined : kindOf(id)),
|
|
35
|
+
onCancel,
|
|
36
|
+
});
|
|
37
|
+
const creates = create && onLink
|
|
38
|
+
? [
|
|
39
|
+
{
|
|
40
|
+
label: create.label,
|
|
41
|
+
onCreate: (query) => create.onCreate(query, (id, kind) => onLink(id, kind)),
|
|
42
|
+
},
|
|
43
|
+
]
|
|
44
|
+
: undefined;
|
|
45
|
+
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: 4, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), panelData: { "data-slot": "vk-grid-editor" }, chrome: "menu", className: "w-64 z-90", children: _jsx(RelationEditor, { ref: editorRef, candidates: source, initial: current, clearable: clearable, seed: seed, focusSearch: !sheet, creates: creates, onRequestClose: close }) })] }));
|
|
46
|
+
}
|
|
47
|
+
export function GridRelationSetEditor({ title, candidates, current, lead, seed, create, refuse, onCommit, onLink, onCancel, onTab, }) {
|
|
48
|
+
const editorRef = useRef(null);
|
|
49
|
+
const anchorRef = useRef(null);
|
|
50
|
+
const savedRef = useRef(null);
|
|
51
|
+
const heldRef = useRef([]);
|
|
52
|
+
const linkOnTop = (added) => {
|
|
53
|
+
const base = savedRef.current;
|
|
54
|
+
savedRef.current = [...base, added];
|
|
55
|
+
onLink(base, added);
|
|
56
|
+
};
|
|
57
|
+
const settle = (links) => {
|
|
58
|
+
savedRef.current = links;
|
|
59
|
+
const held = heldRef.current;
|
|
60
|
+
heldRef.current = [];
|
|
61
|
+
for (const added of held)
|
|
62
|
+
linkOnTop(added);
|
|
25
63
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
64
|
+
const { session, close, sheet } = useGridEditSession({
|
|
65
|
+
editorRef,
|
|
66
|
+
refuse: refuse && ((value) => refuse(value)),
|
|
67
|
+
onCommit: (links) => {
|
|
68
|
+
onCommit(links);
|
|
69
|
+
settle(links);
|
|
70
|
+
},
|
|
71
|
+
onCancel: () => {
|
|
72
|
+
onCancel();
|
|
73
|
+
settle(current.map(({ label: _label, icon: _icon, ...link }) => link));
|
|
74
|
+
},
|
|
75
|
+
onTab,
|
|
76
|
+
});
|
|
77
|
+
const creates = create && onLink
|
|
78
|
+
? [
|
|
79
|
+
{
|
|
80
|
+
label: create.label,
|
|
81
|
+
onCreate: (query) => create.onCreate(query, (id, kind) => {
|
|
82
|
+
const added = { id, ...(kind !== undefined ? { kind } : {}) };
|
|
83
|
+
if (savedRef.current)
|
|
84
|
+
linkOnTop(added);
|
|
85
|
+
else
|
|
86
|
+
heldRef.current.push(added);
|
|
87
|
+
}),
|
|
88
|
+
},
|
|
89
|
+
]
|
|
90
|
+
: undefined;
|
|
91
|
+
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: 4, initialFocus: false, onPanelClick: (e) => e.stopPropagation(), panelData: { "data-slot": "vk-grid-editor" }, chrome: "menu", className: "w-64 z-90", children: _jsx(RelationSetEditor, { ref: editorRef, candidates: candidates, initial: current, lead: lead, seed: seed, focusSearch: !sheet, creates: creates, onRequestClose: close }) })] }));
|
|
30
92
|
}
|
|
@@ -12,12 +12,18 @@ export declare function shouldPrefetchGridRow(target: HTMLElement): boolean;
|
|
|
12
12
|
* (the row's menu, `RowMenu`) and in the entity drawer.
|
|
13
13
|
*
|
|
14
14
|
* Click contract (Sheets model, Tier 3):
|
|
15
|
-
* real controls win
|
|
15
|
+
* real controls win (a cell's own email, phone or link is no control: a
|
|
16
|
+
* ⌘- or Ctrl-click follows it, and any other click is the cell's, the link
|
|
17
|
+
* not followed) → cmd/shift cell-range select → selection-mode toggle →
|
|
16
18
|
* title-TEXT click opens the drawer (`[data-cell-open]` hotspot — the text
|
|
17
19
|
* only, never the cell's padding) →
|
|
18
20
|
* otherwise the click SELECTS the cell, the title cell included; a second
|
|
19
21
|
* click on the selected cell (or dblclick / Enter) starts editing when the
|
|
20
22
|
* column has an editor.
|
|
23
|
+
* On a phone (below the provider's `desktopQuery`, asked at the tap): real
|
|
24
|
+
* controls and selection mode as above, then a tap anywhere on the name's
|
|
25
|
+
* cell opens the drawer, and one tap on any other cell opens its editor
|
|
26
|
+
* (the sheet) or, when it opens nothing, selects it and says why.
|
|
21
27
|
* Middle-click still opens `rowHref` in a new tab.
|
|
22
28
|
*/
|
|
23
29
|
declare function GridRowInner<Row>(props: GridRowProps<Row>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -8,11 +8,16 @@ import { gridRowClassName } from "./grid-cell-classes.js";
|
|
|
8
8
|
import { preventShiftTextSelect, ROW_INTERACTIVE_SELECTOR } from "../../selection/row-click.js";
|
|
9
9
|
import { useRestIntent } from "../../selection/useRestIntent.js";
|
|
10
10
|
import { gridColumnHasEditor } from "./editors.js";
|
|
11
|
-
import { gridColumnInspectable } from "../../model/column-inspect.js";
|
|
11
|
+
import { gridColumnInspectable, isWholeTextColumn } from "../../model/column-inspect.js";
|
|
12
|
+
import { gridCellCutOff } from "./cell-cut-off.js";
|
|
12
13
|
import { countRowRender } from "../../model/render-count.js";
|
|
13
14
|
import { useGridRowContextMenu } from "./useGridRowContextMenu.js";
|
|
14
15
|
import { GridRowCells } from "./GridRowCells.js";
|
|
16
|
+
import { gridCellLinkAt, gridControlAt } from "./grid-cell-link.js";
|
|
17
|
+
import { useGridRowHoverHandlers } from "./grid-hover.js";
|
|
15
18
|
import { useViews } from "../../provider/context.js";
|
|
19
|
+
import { isDesktopNow } from "../../provider/desktop.js";
|
|
20
|
+
import { gridFocusOnPress } from "./useGridFocus.js";
|
|
16
21
|
export function shouldPrefetchGridRow(target) {
|
|
17
22
|
if (target.closest(ROW_INTERACTIVE_SELECTOR))
|
|
18
23
|
return false;
|
|
@@ -20,17 +25,19 @@ export function shouldPrefetchGridRow(target) {
|
|
|
20
25
|
}
|
|
21
26
|
function GridRowInner(props) {
|
|
22
27
|
countRowRender();
|
|
23
|
-
const { icons, messages, atoms } = useViews();
|
|
28
|
+
const { icons, messages, atoms, desktopQuery } = useViews();
|
|
24
29
|
const More = icons.more;
|
|
25
30
|
const RowMenu = atoms.RowMenu;
|
|
26
|
-
const { row, id,
|
|
31
|
+
const { row, id, columns, selectable, selected, selectedAbove, selecting, toggle, toggleRange, contextMenu, rowClassName, rowHref, onOpenRow, onPrefetchRow, onRowDelete, deleteLabel, editingEnabled, focusedColId, editingColId, pendingByCol, selectValues, rowRange, onFocusCell, rowKey, onStartEdit, onRefuseEdit, onExtendCell, onAddCell, onCommitCell, inActiveRange, rangeCanClear, onRangeCopy, onRangeCut, onRangePaste, onRangeClear, onPasteAtCell, ariaRowIndex, ariaLevel, ariaPosInSet, ariaSetSize, ariaTailIndex, } = props;
|
|
27
32
|
const href = rowHref?.(row);
|
|
28
33
|
const canEdit = (col) => editingEnabled && gridColumnHasEditor(col);
|
|
29
|
-
const
|
|
34
|
+
const whole = (col, cell) => isWholeTextColumn(col) && gridCellCutOff(cell);
|
|
35
|
+
const opensPanel = (col, cell) => canEdit(col) || gridColumnInspectable(col) || whole(col, cell);
|
|
30
36
|
const { contextItems, handleContextMenu } = useGridRowContextMenu({
|
|
31
37
|
row,
|
|
32
38
|
id,
|
|
33
39
|
columns,
|
|
40
|
+
rowActions: props.rowActions,
|
|
34
41
|
selecting,
|
|
35
42
|
selectable,
|
|
36
43
|
selected,
|
|
@@ -57,12 +64,35 @@ function GridRowInner(props) {
|
|
|
57
64
|
};
|
|
58
65
|
const handleClick = (e) => {
|
|
59
66
|
const target = e.target;
|
|
60
|
-
if (target
|
|
67
|
+
if (gridControlAt(target))
|
|
61
68
|
return;
|
|
69
|
+
const link = gridCellLinkAt(target);
|
|
70
|
+
if (link) {
|
|
71
|
+
if (e.metaKey || e.ctrlKey || !link.closest("[data-col-id]"))
|
|
72
|
+
return;
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
}
|
|
62
75
|
if (selecting) {
|
|
63
76
|
toggle(id);
|
|
64
77
|
return;
|
|
65
78
|
}
|
|
79
|
+
if (!isDesktopNow(desktopQuery)) {
|
|
80
|
+
const cell = target.closest("[data-col-id]");
|
|
81
|
+
if (cell?.querySelector("[data-cell-open]")) {
|
|
82
|
+
onOpenRow(row);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
const col = findCol(target);
|
|
86
|
+
if (!col || editingColId === col.id)
|
|
87
|
+
return;
|
|
88
|
+
if (opensPanel(col, cell))
|
|
89
|
+
onStartEdit(rowKey, col.id, null, whole(col, cell));
|
|
90
|
+
else {
|
|
91
|
+
onFocusCell(rowKey, col.id);
|
|
92
|
+
onRefuseEdit?.(col.id);
|
|
93
|
+
}
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
66
96
|
if (e.shiftKey || e.metaKey || e.ctrlKey) {
|
|
67
97
|
const col = findCol(target);
|
|
68
98
|
if (col)
|
|
@@ -77,36 +107,45 @@ function GridRowInner(props) {
|
|
|
77
107
|
if (!col)
|
|
78
108
|
return;
|
|
79
109
|
if (focusedColId === col.id) {
|
|
80
|
-
|
|
110
|
+
const cell = target.closest("[data-col-id]");
|
|
111
|
+
if (!opensPanel(col, cell))
|
|
81
112
|
onRefuseEdit?.(col.id);
|
|
82
113
|
else if (editingColId !== col.id)
|
|
83
|
-
onStartEdit(rowKey, col.id);
|
|
114
|
+
onStartEdit(rowKey, col.id, null, whole(col, cell));
|
|
84
115
|
return;
|
|
85
116
|
}
|
|
86
117
|
onFocusCell(rowKey, col.id);
|
|
87
118
|
};
|
|
88
119
|
const handleDoubleClick = (e) => {
|
|
89
120
|
const target = e.target;
|
|
90
|
-
if (target
|
|
121
|
+
if (gridControlAt(target))
|
|
91
122
|
return;
|
|
92
123
|
if (selecting || target.closest("[data-cell-open]"))
|
|
93
124
|
return;
|
|
125
|
+
if (!isDesktopNow(desktopQuery))
|
|
126
|
+
return;
|
|
94
127
|
const col = findCol(target);
|
|
95
128
|
if (!col)
|
|
96
129
|
return;
|
|
97
|
-
|
|
130
|
+
const cell = target.closest("[data-col-id]");
|
|
131
|
+
if (!opensPanel(col, cell))
|
|
98
132
|
onRefuseEdit?.(col.id);
|
|
99
133
|
else if (editingColId !== col.id)
|
|
100
|
-
onStartEdit(rowKey, col.id);
|
|
134
|
+
onStartEdit(rowKey, col.id, null, whole(col, cell));
|
|
101
135
|
};
|
|
102
136
|
const handlePointerDown = (e) => {
|
|
103
137
|
if (e.button !== 0)
|
|
104
138
|
return;
|
|
139
|
+
gridFocusOnPress(e, '[data-slot="vk-grid-cell"]');
|
|
105
140
|
const target = e.target;
|
|
106
|
-
|
|
141
|
+
const opensOnPhone = !isDesktopNow(desktopQuery) &&
|
|
142
|
+
!target.closest(ROW_INTERACTIVE_SELECTOR) &&
|
|
143
|
+
target.closest("[data-col-id]")?.querySelector("[data-cell-open]") != null;
|
|
144
|
+
if (shouldPrefetchGridRow(target) || opensOnPhone)
|
|
107
145
|
onPrefetchRow?.(row);
|
|
108
146
|
};
|
|
109
147
|
const rest = useRestIntent(onPrefetchRow ? () => onPrefetchRow(row) : undefined, (target) => shouldPrefetchGridRow(target));
|
|
148
|
+
const hover = useGridRowHoverHandlers(rowKey);
|
|
110
149
|
const handleMouseDown = (e) => {
|
|
111
150
|
if (e.button === 1) {
|
|
112
151
|
const target = e.target;
|
|
@@ -119,9 +158,13 @@ function GridRowInner(props) {
|
|
|
119
158
|
if (selectable)
|
|
120
159
|
preventShiftTextSelect(e);
|
|
121
160
|
};
|
|
122
|
-
const body = (_jsxs("div", { "data-slot": "vk-grid-row", "data-row-id": rowKey,
|
|
123
|
-
|
|
124
|
-
|
|
161
|
+
const body = (_jsxs("div", { "data-slot": "vk-grid-row", "data-row-id": rowKey, role: "row", "aria-rowindex": ariaRowIndex, "aria-level": ariaLevel, "aria-posinset": ariaPosInSet, "aria-setsize": ariaSetSize, "aria-selected": selectable ? selected : undefined, onPointerDown: handlePointerDown, onPointerOver: (e) => {
|
|
162
|
+
rest.onPointerOver(e);
|
|
163
|
+
hover.onPointerOver(e);
|
|
164
|
+
}, onPointerLeave: (e) => {
|
|
165
|
+
rest.onPointerLeave();
|
|
166
|
+
hover.onPointerLeave(e);
|
|
167
|
+
}, onMouseDown: handleMouseDown, onClick: handleClick, onDoubleClick: handleDoubleClick, onContextMenu: handleContextMenu, className: gridRowClassName({ selected, selectable, hostClass: rowClassName?.(row) }), children: [selected && !selectedAbove && (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-0 top-0 z-11 h-px bg-(color:--vk-brand)" })), selected && (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-0 bottom-0 z-11 h-px bg-(color:--vk-brand)" })), 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 })), _jsx(GridRowCells, { props: props }), _jsx("div", { "data-slot": "vk-grid-tail", role: "gridcell", "aria-colindex": ariaTailIndex, className: "flex h-(--vk-row-h) items-center border-b border-(color:--vk-border-subtle) pl-(--vk-tail-pl,var(--vk-px))", children: _jsx("button", { type: "button", tabIndex: -1, "data-slot": "vk-grid-row-more", "aria-label": messages({ key: "views.grid.row-menu" }), title: messages({ key: "views.grid.row-menu" }), onClick: (e) => {
|
|
125
168
|
e.stopPropagation();
|
|
126
169
|
const rect = e.currentTarget.getBoundingClientRect();
|
|
127
170
|
e.currentTarget.dispatchEvent(new MouseEvent("contextmenu", {
|
|
@@ -16,7 +16,7 @@ const LANE_RAMP = "linear-gradient(to right, transparent 0, rgb(0 0 0) 2rem)";
|
|
|
16
16
|
export function GridRowActions({ row, actions, selected = false, }) {
|
|
17
17
|
if (actions.length === 0)
|
|
18
18
|
return null;
|
|
19
|
-
return (_jsxs("span", { className: "pointer-events-none absolute
|
|
19
|
+
return (_jsxs("span", { className: "pointer-events-none absolute inset-y-0 right-0 hidden md:flex items-center gap-1 pl-8 pr-(--vk-px)", children: [_jsx("span", { "aria-hidden": true, className: cx("absolute inset-0", gridFrozenBg(selected)), style: { maskImage: LANE_RAMP, WebkitMaskImage: LANE_RAMP } }), actions.map((a) => {
|
|
20
20
|
const glyph = a.icon(row);
|
|
21
21
|
if (!glyph)
|
|
22
22
|
return null;
|
|
@@ -8,11 +8,12 @@ import { renderActionCell, renderTypedCell } from "./cells.js";
|
|
|
8
8
|
import { gridColumnHasEditor, gridEditorKind } from "./editors.js";
|
|
9
9
|
import { GridCellAnchoredEditor, GridCellInlineEditor, } from "./GridCellEditors.js";
|
|
10
10
|
import { GridCellOutline } from "./GridCellOutline.js";
|
|
11
|
+
import { GridValueUnderEditor } from "./grid-edit-session.js";
|
|
11
12
|
import { GRID_RANGE_TINT_CLASS, gridCellClassName } from "./grid-cell-classes.js";
|
|
12
13
|
import { gridBooleanMode, columnEffectiveWritable } from "../../model/column-capabilities.js";
|
|
13
|
-
import { gridColumnInspectable,
|
|
14
|
+
import { gridColumnInspectable, gridTextOpensBox, isWholeTextColumn } from "../../model/column-inspect.js";
|
|
14
15
|
import { fieldKeyOf } from "../../model/view-rules.js";
|
|
15
|
-
import {
|
|
16
|
+
import { GridPickerCaret, GridRowHoverActions } from "./grid-hover.js";
|
|
16
17
|
import { GridRowGlyph } from "./GridRowGlyph.js";
|
|
17
18
|
import { requestedSettlementTitle } from "@viewkitjs/fields";
|
|
18
19
|
function FillDot({ enabled }) {
|
|
@@ -20,7 +21,7 @@ function FillDot({ enabled }) {
|
|
|
20
21
|
}
|
|
21
22
|
export function GridRowCells({ props }) {
|
|
22
23
|
const { conventions, icons, messages } = useViews();
|
|
23
|
-
const { row, id, rowKey, columns, selected, rowActions, rowIcon, verticalBorders = true,
|
|
24
|
+
const { row, id, rowKey, columns, selected, rowActions, rowIcon, verticalBorders = true, optionColors, dateStyles, durationStyles, numberFormats, showTimeOverrides, percentDisplays, editingEnabled, focusedColId, editingColId, pendingByCol, settlementByCol, selectValues, rowRange, frozenCount = 0, frozenLeft, listConfig, onStartEdit, onEditorTab, onEditorEnter, editSeed, editWhole = false, onCommitCell, onCancelEdit, onOpenRelation: onOpenRelationValue, entityIcon, commands, ariaColOffset = 0, } = props;
|
|
24
25
|
const canEdit = (column) => editingEnabled && gridColumnHasEditor(column) && columnEffectiveWritable(column, listConfig);
|
|
25
26
|
const editBaseline = (column) => cellEditBaseline(column, row, pendingByCol);
|
|
26
27
|
return columns.map((col, i) => {
|
|
@@ -30,9 +31,10 @@ export function GridRowCells({ props }) {
|
|
|
30
31
|
const spanLeft = !!span && i === span.startCol;
|
|
31
32
|
const spanRight = !!span && i === span.endCol;
|
|
32
33
|
const writable = canEdit(col);
|
|
34
|
+
const whole = editing && editWhole;
|
|
33
35
|
const editorKind = writable
|
|
34
36
|
? gridEditorKind(col)
|
|
35
|
-
: gridColumnInspectable(col)
|
|
37
|
+
: gridColumnInspectable(col) || (whole && isWholeTextColumn(col))
|
|
36
38
|
? "text"
|
|
37
39
|
: null;
|
|
38
40
|
const fieldKey = fieldKeyOf(col);
|
|
@@ -60,7 +62,6 @@ export function GridRowCells({ props }) {
|
|
|
60
62
|
decimals: numberFormat?.decimals,
|
|
61
63
|
withTime: showTime,
|
|
62
64
|
percentDisplay: percentDisplays?.[fieldKey],
|
|
63
|
-
wrap: wrapCells,
|
|
64
65
|
valueOverride: pendingByCol?.[col.id],
|
|
65
66
|
markerReason: col.marker?.reason?.(row),
|
|
66
67
|
onResolve,
|
|
@@ -68,7 +69,13 @@ export function GridRowCells({ props }) {
|
|
|
68
69
|
onOpenRelation,
|
|
69
70
|
entityIcon,
|
|
70
71
|
commandItems,
|
|
72
|
+
hostOwnsPlainClick: true,
|
|
71
73
|
});
|
|
74
|
+
const cellValue = () => col.actions
|
|
75
|
+
? renderActionCell(col, row)
|
|
76
|
+
: col.render
|
|
77
|
+
? col.render(row, { value: col.accessor?.(row), code: shownCodeOf(col, row) })
|
|
78
|
+
: typedCell();
|
|
72
79
|
const tabTo = (backwards) => onEditorTab(rowKey, col.id, backwards);
|
|
73
80
|
const enterAdvance = () => onEditorEnter(rowKey, col.id);
|
|
74
81
|
const frozen = i < frozenCount;
|
|
@@ -81,16 +88,18 @@ export function GridRowCells({ props }) {
|
|
|
81
88
|
readOnly: !writable,
|
|
82
89
|
baseline: editBaseline(col),
|
|
83
90
|
editSeed,
|
|
91
|
+
whole,
|
|
84
92
|
decimals: numberFormat?.decimals,
|
|
85
93
|
selectValues: selectValues?.[col.id],
|
|
86
94
|
optionColors: optionColors?.[fieldKey],
|
|
87
95
|
entityIcon,
|
|
96
|
+
listConfig,
|
|
88
97
|
onCommitCell,
|
|
89
98
|
onCancel: () => onCancelEdit(rowKey, col.id),
|
|
90
99
|
onTab: tabTo,
|
|
91
100
|
onEnter: enterAdvance,
|
|
92
101
|
};
|
|
93
|
-
return (_jsxs("div", { "data-slot": "vk-grid-cell", "data-col-id": col.id, "data-settlement": settlement, title: settlement ? requestedSettlementTitle(col.field?.provenance, conventions) : undefined, style: frozen && frozenLeft ? { left: frozenLeft(i) } : undefined, className: gridCellClassName({
|
|
102
|
+
return (_jsxs("div", { "data-slot": "vk-grid-cell", "data-col-id": col.id, tabIndex: -1, role: "gridcell", "aria-colindex": ariaColOffset + i + 1, "aria-readonly": writable ? undefined : true, "aria-selected": span ? true : undefined, "data-settlement": settlement, title: settlement ? requestedSettlementTitle(col.field?.provenance, conventions) : undefined, style: frozen && frozenLeft ? { left: frozenLeft(i) } : undefined, className: gridCellClassName({
|
|
94
103
|
align: col.align,
|
|
95
104
|
isTitle: col.type === "title",
|
|
96
105
|
frozen,
|
|
@@ -100,16 +109,9 @@ export function GridRowCells({ props }) {
|
|
|
100
109
|
selected,
|
|
101
110
|
lastColumn: i === columns.length - 1,
|
|
102
111
|
verticalBorders,
|
|
103
|
-
wrap: wrapCells,
|
|
104
112
|
settlement,
|
|
105
|
-
}), 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 || editing) && (_jsx(GridCellOutline, {
|
|
106
|
-
(editorKind === "number" || editorKind === "range" || (editorKind === "text" && !
|
|
107
|
-
? null
|
|
108
|
-
: col.actions
|
|
109
|
-
? renderActionCell(col, row)
|
|
110
|
-
: col.render
|
|
111
|
-
? col.render(row, { value: col.accessor?.(row), code: shownCodeOf(col, row) })
|
|
112
|
-
: typedCell(), editing ? _jsx(GridCellAnchoredEditor, { ctx: editorCtx }) : null, col.type === "title" && !editing && (_jsx(GridRowActions, { row: row, selected: selected, actions: [
|
|
113
|
+
}), 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 || editing) && (_jsx(GridCellOutline, { editing: editing })), focused && !editing && !span && (_jsx(FillDot, { enabled: editingEnabled })), 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 &&
|
|
114
|
+
(editorKind === "number" || editorKind === "range" || (editorKind === "text" && !gridTextOpensBox(col, whole))) ? (_jsx(GridValueUnderEditor, { children: cellValue() })) : (cellValue()), editing ? _jsx(GridCellAnchoredEditor, { ctx: editorCtx }) : null, col.type === "title" && !editing && (_jsx(GridRowHoverActions, { rowKey: rowKey, row: row, selected: selected, actions: [
|
|
113
115
|
...(rowActions ?? []),
|
|
114
116
|
...(canEdit(col)
|
|
115
117
|
? [
|
|
@@ -121,13 +123,6 @@ export function GridRowCells({ props }) {
|
|
|
121
123
|
},
|
|
122
124
|
]
|
|
123
125
|
: []),
|
|
124
|
-
] })), (editorKind === "select" || editorKind === "relation" || editorKind === "chips") && (_jsx(
|
|
125
|
-
e.stopPropagation();
|
|
126
|
-
if (!editing)
|
|
127
|
-
onStartEdit(rowKey, col.id);
|
|
128
|
-
}, className: cx("absolute right-1 top-[calc(var(--vk-chrome-h,100%)/2)] flex h-5 w-5 -translate-y-1/2 items-center justify-center hover:text-(color:--vk-fg)", editing
|
|
129
|
-
? "text-(color:--vk-fg) opacity-100"
|
|
130
|
-
:
|
|
131
|
-
"text-(color:--vk-fg-subtlest) md:opacity-0 md:group-hover/gridcell:opacity-100"), children: _jsx(icons.caretDown, { className: cx("h-3 w-3 transition-transform duration-100", editing && "rotate-180") }) }))] }, col.id));
|
|
126
|
+
] })), (editorKind === "select" || editorKind === "relation" || editorKind === "chips") && (_jsx(GridPickerCaret, { rowKey: rowKey, colId: col.id, editing: editing, onOpen: () => onStartEdit(rowKey, col.id) }))] }, col.id));
|
|
132
127
|
});
|
|
133
128
|
}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
2
3
|
/**
|
|
3
4
|
* The GRID's host around the shared `SelectEditor` (`@viewkitjs/views/editors/select`) —
|
|
4
|
-
* the option panel is one component across every surface
|
|
5
|
-
*
|
|
6
|
-
*
|
|
5
|
+
* the option panel is one component across every surface. The edit session owns the
|
|
6
|
+
* one-answer guard and the exit gap; the editor panel opens the popover on a desktop
|
|
7
|
+
* and the sheet on a phone. This host owns only the grid's part: the anchor on the
|
|
8
|
+
* cell rect, the options it offers, and the write.
|
|
9
|
+
*
|
|
10
|
+
* The write waits for the exit gap: notifying at once would unmount the popover (or
|
|
11
|
+
* the sheet) mid-animation. Side effect, and a wanted one: clicks during the exit see
|
|
12
|
+
* the cell still editing and no-op, which is the click-open / click-close toggle.
|
|
7
13
|
*/
|
|
8
|
-
export declare function GridSelectEditor<Row>({ column, values, current, optionColors, onCommit, onCancel, }: {
|
|
14
|
+
export declare function GridSelectEditor<Row>({ column, title, values, current, clearable, seed, optionColors, refuse, onCommit, onCancel, }: {
|
|
9
15
|
column: ListColumn<Row>;
|
|
16
|
+
/** The field's name: the sheet's title on a phone. */
|
|
17
|
+
title: ReactNode;
|
|
10
18
|
/** Option values in display order (declared first, then data-discovered). */
|
|
11
19
|
values: string[];
|
|
12
20
|
/** The cell's current value ("" when unset). */
|
|
13
21
|
current: string;
|
|
22
|
+
/** The column may be emptied: the list opens with None first, and picking it commits "" (Delete clears too). */
|
|
23
|
+
clearable?: boolean;
|
|
24
|
+
/** The letter typed on the cell that opened it: starts the list's search when it has one. */
|
|
25
|
+
seed?: string;
|
|
14
26
|
/** This column's per-user color overrides (select columns). */
|
|
15
27
|
optionColors?: Record<string, ListSelectColor>;
|
|
16
28
|
onCommit: (value: string) => void;
|
|
17
29
|
onCancel: () => void;
|
|
30
|
+
/** The grid's judgement of a value before it is written: its reason when it would refuse it.
|
|
31
|
+
* A refused value keeps the editor open with that reason. */
|
|
32
|
+
refuse?: (value: string) => string | null;
|
|
18
33
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useRef
|
|
4
|
-
import { useViews } from "../../provider/context.js";
|
|
3
|
+
import { useRef } from "react";
|
|
5
4
|
import { SelectEditor, pickerOptionsFromField, } from "../../editors/SelectEditor.js";
|
|
5
|
+
import { EditorPanel } from "../../editors/EditorPanel.js";
|
|
6
6
|
import { resolveCategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
7
7
|
import { isOpenVocabulary } from "@viewkitjs/fields";
|
|
8
8
|
import { prettifyOptionValue } from "../../model/column-state.js";
|
|
9
9
|
import { offeredValues, useOpenValues } from "../../editors/open-values.js";
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const [open, setOpen] = useState(true);
|
|
10
|
+
import { useGridEditSession } from "./grid-edit-session.js";
|
|
11
|
+
export function GridSelectEditor({ column, title, values, current, clearable = false, seed, optionColors, refuse, onCommit, onCancel, }) {
|
|
13
12
|
const editorRef = useRef(null);
|
|
14
13
|
const anchorRef = useRef(null);
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const resolution = editorRef.current?.resolveClose(reason) ?? { kind: "noop" };
|
|
22
|
-
setOpen(false);
|
|
23
|
-
window.setTimeout(() => {
|
|
24
|
-
if (resolution.kind === "commit")
|
|
25
|
-
onCommit(resolution.payload);
|
|
26
|
-
else
|
|
27
|
-
onCancel();
|
|
28
|
-
}, EXIT_MS);
|
|
29
|
-
};
|
|
14
|
+
const { session, close, sheet } = useGridEditSession({
|
|
15
|
+
editorRef,
|
|
16
|
+
refuse: refuse && ((value) => refuse(value)),
|
|
17
|
+
onCommit: (value) => onCommit(value),
|
|
18
|
+
onCancel,
|
|
19
|
+
});
|
|
30
20
|
const known = useOpenValues(column.field);
|
|
31
21
|
const optionLabel = (value) => column.options?.find((o) => o.value === value)?.label ?? prettifyOptionValue(value);
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
22
|
+
const field = column.field && (column.field.type === "select" || column.field.type === "status") ? column.field : null;
|
|
23
|
+
const declared = column.options?.filter((o) => !o.archived).map((o) => o.value);
|
|
24
|
+
const bareValues = declared && declared.length > 0 ? [...declared, ...(current && !declared.includes(current) ? [current] : [])] : values;
|
|
25
|
+
const pickerOptions = field
|
|
26
|
+
? pickerOptionsFromField(field, {
|
|
27
|
+
optionColors,
|
|
28
|
+
extraValues: isOpenVocabulary(field) ? offeredValues(field, known, values) : [],
|
|
29
|
+
current,
|
|
30
|
+
})
|
|
31
|
+
: bareValues.map((value) => column.type === "status"
|
|
35
32
|
? {
|
|
36
33
|
value,
|
|
37
34
|
label: optionLabel(value),
|
|
@@ -42,8 +39,5 @@ export function GridSelectEditor({ column, values, current, optionColors, onComm
|
|
|
42
39
|
label: optionLabel(value),
|
|
43
40
|
color: resolveCategoryColor(value, column.options, optionColors),
|
|
44
41
|
});
|
|
45
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(
|
|
46
|
-
if (!next)
|
|
47
|
-
close("outside");
|
|
48
|
-
}, anchor: anchorRef, align: "start", sideOffset: 4, onEscape: () => close("escape"), onOutsidePress: () => close("outside"), initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-48 z-90", children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, initial: current, creatable: !!column.field && isOpenVocabulary(column.field), onRequestClose: close }) })] }));
|
|
42
|
+
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: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (e) => e.stopPropagation(), chrome: "menu", className: "w-48 z-90", children: _jsx(SelectEditor, { ref: editorRef, options: pickerOptions, initial: current, clearable: clearable, creatable: !!column.field && isOpenVocabulary(column.field), seed: seed, focusSearch: !sheet, onRequestClose: close }) })] }));
|
|
49
43
|
}
|
|
@@ -3,16 +3,17 @@ import type { ListGroup } from "../../grouping/types.js";
|
|
|
3
3
|
import type { ListGroupSummaryPart } from "../../model/preferences.js";
|
|
4
4
|
import { type GridGroupSortOption } from "./GridGroupMenu.js";
|
|
5
5
|
import type { GridSortState } from "./GridColumnMenu.js";
|
|
6
|
-
import type { GridScrollSurface, useGridScrollSync } from "./useGridScrollSync.js";
|
|
7
6
|
import type { GridGroupFigure, GroupCountNoun } from "./grid-table-props.js";
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export declare function GridBody<Row>({ empty, emptyState, grouped, groups, rows, selectable, selecting, allSelected, someSelected, selectAll, clearSelection, isCollapsed, countOf, sort, sortOptions, groupSummary, onToggleGroup, onGroupSummaryChange, renderGroupLabel, onHideGroup, figures, countNoun, renderHeader, renderGroupCheckbox, renderRow, renderFooter, keptFor, barIndexOf, ariaColCount, }: {
|
|
8
|
+
/** Each bar's row number among every row of the grid (`core/grid-aria.ts`). */
|
|
9
|
+
barIndexOf?: (groupKey: string) => number | undefined;
|
|
10
|
+
/** The grid's columns, which a bar's one cell spans. */
|
|
11
|
+
ariaColCount?: number;
|
|
10
12
|
empty: boolean;
|
|
11
13
|
emptyState?: ReactNode;
|
|
12
14
|
grouped: boolean;
|
|
13
15
|
groups: ListGroup<Row>[];
|
|
14
16
|
rows: Row[];
|
|
15
|
-
isMobile: boolean;
|
|
16
17
|
selectable: boolean;
|
|
17
18
|
selecting: boolean;
|
|
18
19
|
allSelected: boolean;
|
|
@@ -32,7 +33,8 @@ export declare function GridBody<Row>({ empty, emptyState, grouped, groups, rows
|
|
|
32
33
|
figures?: GridGroupFigure<Row>[];
|
|
33
34
|
/** The count's noun: "2 companies". None: a bare count. */
|
|
34
35
|
countNoun?: GroupCountNoun;
|
|
35
|
-
|
|
36
|
+
/** The column names' row, ending its rail lane with `checkbox` where it has one. */
|
|
37
|
+
renderHeader: (checkbox?: ReactNode, groupKey?: string) => ReactNode;
|
|
36
38
|
renderGroupCheckbox: (items: Row[]) => ReactNode;
|
|
37
39
|
/** Receives map's full triple: the row needs its INDEX and the sibling
|
|
38
40
|
* list to know whether the row above it is selected (see `selectedAbove`). */
|
|
@@ -40,9 +42,6 @@ export declare function GridBody<Row>({ empty, emptyState, grouped, groups, rows
|
|
|
40
42
|
* screen, and each needs its own identity. See `gridRowKey`. */
|
|
41
43
|
renderRow: (row: Row, index: number, items: Row[], groupKey: string) => ReactNode;
|
|
42
44
|
renderFooter: (group: ListGroup<Row>) => ReactNode;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
headerWheelRef: ScrollSync["headerWheelRef"];
|
|
46
|
-
headerPanHandlers: ScrollSync["headerPanHandlers"];
|
|
45
|
+
/** The indices a section draws wherever they are: the focused and the editing row. */
|
|
46
|
+
keptFor: (groupKey: string) => readonly number[];
|
|
47
47
|
}): import("react/jsx-runtime").JSX.Element | import("react/jsx-runtime").JSX.Element[];
|
|
48
|
-
export {};
|