viewkitjs 0.31.0 → 0.32.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 +129 -0
- package/MIGRATION.md +40 -6
- package/README.md +1 -1
- package/fields/dist/query/index.d.ts +2 -0
- package/fields/dist/query/index.js +2 -0
- package/fields/dist/query/list-request.d.ts +148 -0
- package/fields/dist/query/list-request.js +125 -0
- package/fields/dist/query/saved-view.d.ts +15 -0
- package/fields/dist/query/saved-view.js +11 -0
- package/fields/dist/query/settings.d.ts +9 -0
- package/fields/dist/query/settings.js +9 -0
- package/fields/docs/reference/query.md +66 -0
- package/package.json +5 -1
- package/postgres/README.md +1 -0
- package/postgres/dist/handler.d.ts +53 -0
- package/postgres/dist/handler.js +211 -0
- package/postgres/dist/ids.d.ts +1 -1
- package/postgres/dist/ids.js +19 -1
- package/postgres/dist/index.d.ts +1 -0
- package/postgres/dist/index.js +1 -0
- package/postgres/dist/limits.d.ts +3 -1
- package/postgres/dist/limits.js +1 -1
- package/postgres/dist/list-fields.d.ts +10 -0
- package/postgres/dist/list-fields.js +36 -0
- package/postgres/dist/readable.d.ts +4 -0
- package/postgres/dist/readable.js +4 -0
- package/postgres/dist/refusals.d.ts +9 -2
- package/postgres/dist/refusals.js +6 -0
- package/postgres/docs/guides/field-map.md +2 -2
- package/postgres/docs/guides/list-handler.md +99 -0
- package/postgres/docs/index.md +1 -0
- package/postgres/docs/reference/postgres.md +11 -3
- package/views/README.md +2 -2
- package/views/dist/atoms/RowMenu.d.ts +7 -0
- package/views/dist/atoms/RowMenu.js +18 -16
- package/views/dist/atoms/carried.d.ts +5 -0
- package/views/dist/atoms/carried.js +7 -0
- package/views/dist/atoms/types.d.ts +3 -0
- package/views/dist/contract.d.ts +26 -6
- package/views/dist/contract.js +25 -0
- package/views/dist/controls/alert-dialog/alert-dialog.js +2 -1
- package/views/dist/controls/atoms.d.ts +2 -0
- package/views/dist/controls/atoms.js +2 -0
- package/views/dist/controls/avatar/avatar.d.ts +3 -3
- package/views/dist/controls/avatar/avatar.js +1 -1
- package/views/dist/controls/avatar/tokens.d.ts +44 -0
- package/views/dist/controls/avatar/tokens.js +11 -0
- package/views/dist/controls/avatar.css +22 -5
- package/views/dist/controls/choice/tokens.d.ts +0 -4
- package/views/dist/controls/choice/tokens.js +0 -1
- package/views/dist/controls/choice.css +3 -3
- package/views/dist/controls/controls.d.ts +6 -0
- package/views/dist/controls/controls.js +10 -2
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +19 -4
- package/views/dist/controls/field/field.js +63 -5
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +41 -16
- package/views/dist/controls/glyphs/glyphs.d.ts +10 -0
- package/views/dist/controls/glyphs/glyphs.js +173 -0
- package/views/dist/controls/index.d.ts +2 -1
- package/views/dist/controls/index.js +2 -1
- package/views/dist/controls/input/input.js +5 -2
- package/views/dist/controls/input/tokens.d.ts +4 -0
- package/views/dist/controls/input/tokens.js +1 -0
- package/views/dist/controls/input.css +31 -3
- package/views/dist/controls/internal/icons.js +10 -0
- package/views/dist/controls/internal/keep-focus.d.ts +2 -0
- package/views/dist/controls/internal/keep-focus.js +17 -0
- package/views/dist/controls/internal/watch-frame.d.ts +2 -0
- package/views/dist/controls/internal/watch-frame.js +33 -0
- package/views/dist/controls/markdown/map-markdown.d.ts +4 -0
- package/views/dist/controls/markdown/map-markdown.js +5 -0
- package/views/dist/controls/menu/map-menu.js +2 -2
- package/views/dist/controls/menu-list/menu-list.d.ts +3 -0
- package/views/dist/controls/menu-list/menu-list.js +5 -4
- package/views/dist/controls/modal/modal.js +5 -1
- package/views/dist/controls/pane/pane.js +2 -1
- package/views/dist/controls/phone-header/header-bar.d.ts +5 -1
- package/views/dist/controls/phone-header/header-bar.js +2 -2
- package/views/dist/controls/phone-header.css +11 -1
- package/views/dist/controls/picker/map-picker.js +3 -0
- package/views/dist/controls/picker/picker.d.ts +14 -0
- package/views/dist/controls/picker/picker.js +30 -10
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/popover/popover.js +2 -1
- package/views/dist/controls/radio/radio.d.ts +5 -3
- package/views/dist/controls/radio/radio.js +18 -2
- package/views/dist/controls/radio/tokens.d.ts +44 -0
- package/views/dist/controls/radio/tokens.js +11 -0
- package/views/dist/controls/radio.css +79 -1
- package/views/dist/controls/select/select.d.ts +4 -0
- package/views/dist/controls/select/select.js +11 -5
- package/views/dist/controls/select/tokens.d.ts +8 -0
- package/views/dist/controls/select/tokens.js +2 -0
- package/views/dist/controls/select.css +17 -0
- package/views/dist/controls/setting-row/looks.d.ts +1 -1
- package/views/dist/controls/setting-row/looks.js +9 -4
- package/views/dist/controls/setting-row/setting-row.d.ts +45 -10
- package/views/dist/controls/setting-row/setting-row.js +82 -15
- package/views/dist/controls/setting-row/tokens.d.ts +74 -2
- package/views/dist/controls/setting-row/tokens.js +19 -1
- package/views/dist/controls/setting-row.css +135 -14
- package/views/dist/controls/sheet/bottom-sheet.d.ts +10 -2
- package/views/dist/controls/sheet/bottom-sheet.js +6 -3
- package/views/dist/controls/sheet.css +4 -1
- package/views/dist/controls/sort-editor/sort-editor.js +3 -2
- package/views/dist/controls/sort-editor.css +8 -2
- package/views/dist/controls/switch-row/tokens.d.ts +0 -12
- package/views/dist/controls/switch-row/tokens.js +0 -3
- package/views/dist/controls/switch-row.css +3 -7
- package/views/dist/controls/switch.css +17 -7
- package/views/dist/controls/tag/tag.d.ts +3 -1
- package/views/dist/controls/tag/tag.js +2 -2
- package/views/dist/controls/tag/tokens.d.ts +4 -0
- package/views/dist/controls/tag/tokens.js +1 -0
- package/views/dist/controls/tag-field/tag-field.d.ts +5 -1
- package/views/dist/controls/tag-field/tag-field.js +11 -5
- package/views/dist/controls/tag-field/tokens.d.ts +16 -0
- package/views/dist/controls/tag-field/tokens.js +4 -0
- package/views/dist/controls/tag-field.css +19 -0
- package/views/dist/controls/tag.css +2 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +15 -3
- package/views/dist/controls/toolbar/toolbar.js +22 -15
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +14 -0
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +51 -0
- package/views/dist/controls/toolbar-button/toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/toolbar-button.js +2 -3
- package/views/dist/controls/toolbar-button.css +4 -0
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -0
- package/views/dist/controls/views-list/map-view-menu.js +25 -0
- package/views/dist/controls/views-list/map-views-list-body.d.ts +28 -1
- package/views/dist/controls/views-list/map-views-list-body.js +39 -21
- package/views/dist/controls/views-list/rules.d.ts +2 -0
- package/views/dist/controls/views-list/view-menu.d.ts +7 -0
- package/views/dist/controls/views-list/view-menu.js +28 -24
- package/views/dist/controls/views-list/words.d.ts +2 -0
- package/views/dist/controls/views-list/words.js +1 -1
- package/views/dist/editors/EditorPanel.js +2 -1
- package/views/dist/editors/edit-session.js +2 -5
- package/views/dist/field-row/FieldRow.d.ts +4 -2
- package/views/dist/field-row/FieldRow.js +67 -20
- package/views/dist/field-row/FieldRowLane.d.ts +7 -2
- package/views/dist/field-row/FieldRowLane.js +4 -3
- package/views/dist/field-row/editors/RowEditor.d.ts +12 -0
- package/views/dist/field-row/editors/RowEditor.js +31 -1
- package/views/dist/field-row/editors/RowValueListEditor.d.ts +5 -1
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -1
- package/views/dist/field-row/field-row-button.d.ts +5 -0
- package/views/dist/field-row/field-row-button.js +2 -0
- package/views/dist/fields/binding.d.ts +3 -2
- package/views/dist/fields/binding.js +38 -5
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +4 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +3 -2
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -1
- package/views/dist/grid/chrome/GridGroupMenu.js +4 -3
- package/views/dist/grid/chrome/GridHeader.d.ts +4 -1
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +6 -5
- package/views/dist/grid/chrome/GridRowCells.js +6 -9
- package/views/dist/grid/chrome/GridStructure.d.ts +4 -1
- package/views/dist/grid/chrome/GridStructure.js +4 -4
- package/views/dist/grid/chrome/GridTable.js +5 -2
- package/views/dist/grid/chrome/grid-column-menu-items.js +1 -1
- package/views/dist/grid/chrome/grid-row-menu-items.d.ts +27 -3
- package/views/dist/grid/chrome/grid-row-menu-items.js +92 -6
- package/views/dist/grid/chrome/grid-row-props.d.ts +7 -2
- package/views/dist/grid/chrome/grid-rows-menu.js +34 -6
- package/views/dist/grid/chrome/grid-table-props.d.ts +38 -7
- package/views/dist/grid/chrome/useGridBatchApi.d.ts +3 -1
- package/views/dist/grid/chrome/useGridBatchApi.js +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +4 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +15 -9
- package/views/dist/grid/chrome/useGridPendingReconciliation.js +1 -2
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +11 -5
- package/views/dist/grid/core/commit-model.d.ts +20 -2
- package/views/dist/grid/core/editing-controller.d.ts +18 -0
- package/views/dist/grid/core/editing-controller.js +188 -42
- package/views/dist/grid/core/editing-model.d.ts +3 -0
- package/views/dist/grid/core/editing-model.js +3 -0
- package/views/dist/grid/core/save-path.d.ts +24 -0
- package/views/dist/grid/core/save-path.js +122 -0
- package/views/dist/grid/core/spreadsheet-operations.d.ts +3 -0
- package/views/dist/grid/core/spreadsheet-operations.js +23 -0
- package/views/dist/grid/index.d.ts +3 -2
- package/views/dist/grid/index.js +1 -0
- package/views/dist/internal/field-rows.d.ts +26 -0
- package/views/dist/internal/field-rows.js +8 -0
- package/views/dist/internal/page-close.d.ts +7 -0
- package/views/dist/internal/page-close.js +43 -0
- package/views/dist/list/browser-views-store.d.ts +10 -0
- package/views/dist/list/browser-views-store.js +182 -0
- package/views/dist/list/index.d.ts +23 -0
- package/views/dist/list/index.js +8 -0
- package/views/dist/list/menu.d.ts +31 -0
- package/views/dist/list/menu.js +76 -0
- package/views/dist/list/parts.d.ts +6 -0
- package/views/dist/list/parts.js +59 -0
- package/views/dist/list/registry.d.ts +11 -0
- package/views/dist/list/registry.js +31 -0
- package/views/dist/list/root.d.ts +40 -0
- package/views/dist/list/root.js +128 -0
- package/views/dist/list/slot.d.ts +14 -0
- package/views/dist/list/slot.js +22 -0
- package/views/dist/list/source.d.ts +11 -0
- package/views/dist/list/source.js +31 -0
- package/views/dist/list/store.d.ts +87 -0
- package/views/dist/list/store.js +115 -0
- package/views/dist/list/toolbar.d.ts +6 -0
- package/views/dist/list/toolbar.js +359 -0
- package/views/dist/list/views-axis.d.ts +5 -0
- package/views/dist/list/views-axis.js +96 -0
- package/views/dist/list/views-store.d.ts +41 -0
- package/views/dist/list/views-store.js +1 -0
- package/views/dist/list/views.d.ts +67 -0
- package/views/dist/list/views.js +400 -0
- package/views/dist/model/preferences.js +1 -1
- package/views/dist/model/prefs-buckets.js +1 -1
- package/views/dist/panels/index.d.ts +3 -1
- package/views/dist/panels/index.js +1 -0
- package/views/dist/panels/react/customize-body.js +1 -0
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +41 -4
- package/views/dist/panels/react/toolbar/ReadyToolbar.js +6 -326
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +9 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +34 -23
- package/views/dist/panels/react/toolbar/ToolbarButton.js +4 -1
- package/views/dist/panels/react/toolbar/ToolbarNew.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +10 -2
- package/views/dist/panels/react/toolbar/context.js +3 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.d.ts +1 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +15 -4
- package/views/dist/panels/react/views-row/PillGroup.d.ts +5 -2
- package/views/dist/panels/react/views-row/PillGroup.js +16 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +2 -12
- package/views/dist/panels/react/views-row/ViewPickerRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/ViewPickerRow.js +9 -5
- package/views/dist/panels/react.d.ts +2 -2
- package/views/dist/panels/toolbar/edit-view.d.ts +7 -1
- package/views/dist/panels/toolbar/edit-view.js +14 -0
- package/views/dist/panels/toolbar/model.d.ts +5 -0
- package/views/dist/panels/toolbar/model.js +7 -3
- package/views/dist/panels/view-state.d.ts +5 -3
- package/views/dist/panels/views-row/model.d.ts +19 -2
- package/views/dist/panels/views-row/model.js +14 -0
- package/views/dist/provider/ViewsProvider.d.ts +16 -7
- package/views/dist/provider/ViewsProvider.js +23 -5
- package/views/dist/provider/components.d.ts +43 -2
- package/views/dist/provider/context.d.ts +2 -1
- package/views/dist/provider/context.js +1 -1
- package/views/dist/provider/ports.d.ts +19 -12
- package/views/dist/provider/ports.js +69 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +418 -59
- package/views/dist/styles.unlayered.css +418 -59
- package/views/docs/contract.md +42 -31
- package/views/docs/controls/avatar.md +11 -0
- package/views/docs/controls/choice.md +0 -1
- package/views/docs/controls/field.md +3 -0
- package/views/docs/controls/input.md +1 -0
- package/views/docs/controls/radio.md +16 -1
- package/views/docs/controls/select.md +2 -0
- package/views/docs/controls/setting-row.md +18 -0
- package/views/docs/controls/switch-row.md +0 -3
- package/views/docs/controls/tag-field.md +4 -0
- package/views/docs/controls/tag.md +1 -0
- package/views/docs/getting-started.md +2 -2
- package/views/docs/guides/atoms.md +2 -2
- package/views/docs/guides/columns.md +1 -1
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/the-grid.md +34 -7
- package/views/docs/guides/the-provider.md +4 -2
- package/views/docs/index.md +1 -0
- package/views/docs/reference/controls.md +35 -25
- package/views/docs/reference/editors-session.md +1 -1
- package/views/docs/reference/field-row.md +9 -1
- package/views/docs/reference/grid.md +14 -8
- package/views/docs/reference/list.md +227 -0
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +17 -12
- package/views/docs/reference/panels.md +8 -5
- package/views/docs/reference/react.md +11 -9
- package/views/docs/reference/views.md +2 -2
- package/views/skills/views/SKILL.md +9 -6
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { cloneElement, createContext, useEffect, useLayoutEffect, useRef, useState, } from "react";
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
|
-
import { gridRowMenuColumnAt, gridRowMenuItems } from "./grid-row-menu-items.js";
|
|
5
|
+
import { gridRowMenuColumnAt, gridRowMenuItems, reshapeRowMenu, rowMenuWaiting } from "./grid-row-menu-items.js";
|
|
6
6
|
const ROW = '[data-slot="vk-grid-row"]';
|
|
7
7
|
function rowKeyAt(container, target) {
|
|
8
8
|
const row = target instanceof Element ? target.closest(ROW) : null;
|
|
@@ -16,6 +16,9 @@ export function GridRowsMenu({ rowPropsFor, selectable, answerHeldPress, childre
|
|
|
16
16
|
const RowMenu = views.atoms.RowMenu;
|
|
17
17
|
const [aim, setAim] = useState(null);
|
|
18
18
|
const [menuColumnId, setMenuColumnId] = useState(null);
|
|
19
|
+
const [opening, setOpening] = useState(null);
|
|
20
|
+
const openings = useRef(0);
|
|
21
|
+
const [answer, setAnswer] = useState(null);
|
|
19
22
|
const aimRef = useRef(null);
|
|
20
23
|
const touchTimer = useRef(null);
|
|
21
24
|
const settle = () => {
|
|
@@ -29,20 +32,45 @@ export function GridRowsMenu({ rowPropsFor, selectable, answerHeldPress, childre
|
|
|
29
32
|
aimRef.current = key;
|
|
30
33
|
setAim(key);
|
|
31
34
|
setMenuColumnId(columnId);
|
|
35
|
+
setOpening(null);
|
|
32
36
|
};
|
|
33
|
-
const latest = useRef({ rowPropsFor, aimAt, aim });
|
|
37
|
+
const latest = useRef({ rowPropsFor, aimAt, aim, views });
|
|
34
38
|
useLayoutEffect(() => {
|
|
35
|
-
latest.current = { rowPropsFor, aimAt, aim };
|
|
39
|
+
latest.current = { rowPropsFor, aimAt, aim, views };
|
|
36
40
|
});
|
|
37
41
|
const [aimByRow] = useState(() => (rowKey, event) => {
|
|
38
42
|
const aimed = latest.current.rowPropsFor(rowKey);
|
|
39
43
|
if (!aimed)
|
|
40
44
|
return;
|
|
41
45
|
AIMED.add(event.nativeEvent);
|
|
42
|
-
|
|
46
|
+
const columnId = gridRowMenuColumnAt(aimed, event.target instanceof Element ? event.target : null);
|
|
47
|
+
latest.current.aimAt(rowKey, columnId);
|
|
48
|
+
openings.current += 1;
|
|
49
|
+
const opened = openings.current;
|
|
50
|
+
setOpening(opened);
|
|
51
|
+
const shape = aimed.rowMenuReshape;
|
|
52
|
+
if (!shape)
|
|
53
|
+
return;
|
|
54
|
+
const rows = gridRowMenuItems(aimed, columnId, latest.current.views);
|
|
55
|
+
const shaped = reshapeRowMenu(shape, rows, aimed.row);
|
|
56
|
+
if (Array.isArray(shaped)) {
|
|
57
|
+
setAnswer({ opening: opened, rows: "now" });
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
setAnswer({ opening: opened, rows: null });
|
|
61
|
+
const land = (answered) => setAnswer((current) => (current?.opening === opened ? { opening: opened, rows: answered } : current));
|
|
62
|
+
shaped.then(land, () => land(rows));
|
|
43
63
|
});
|
|
44
64
|
const props = aim != null ? rowPropsFor(aim) : null;
|
|
45
|
-
const
|
|
65
|
+
const reshape = props?.rowMenuReshape;
|
|
66
|
+
const own = props ? gridRowMenuItems(props, menuColumnId, views) : [];
|
|
67
|
+
const opened = props && reshape ? opening : null;
|
|
68
|
+
let items = own;
|
|
69
|
+
if (props && reshape) {
|
|
70
|
+
const rows = answer && answer.opening === opened ? answer.rows : null;
|
|
71
|
+
const now = rows === "now" ? reshapeRowMenu(reshape, own, props.row) : rows;
|
|
72
|
+
items = Array.isArray(now) ? now : rowMenuWaiting(views);
|
|
73
|
+
}
|
|
46
74
|
const [target] = useState(() => ({
|
|
47
75
|
onPointerDownCapture: (event) => {
|
|
48
76
|
const key = rowKeyAt(event.currentTarget, event.target);
|
|
@@ -73,7 +101,7 @@ export function GridRowsMenu({ rowPropsFor, selectable, answerHeldPress, childre
|
|
|
73
101
|
},
|
|
74
102
|
}));
|
|
75
103
|
const rows = cloneElement(children, target);
|
|
76
|
-
return (_jsx(GridRowMenuAimContext.Provider, { value: aimByRow, children: _jsx(RowMenu, { rowId: props?.id ?? "", items: items, openHref: props ? props.rowHref?.(props.row) : undefined, onDelete: props?.onRowDelete, deleteLabel: props?.deleteLabel, onToggleSelect: selectable
|
|
104
|
+
return (_jsx(GridRowMenuAimContext.Provider, { value: aimByRow, children: _jsx(RowMenu, { rowId: props?.id ?? "", items: items, openHref: props && !reshape ? props.rowHref?.(props.row) : undefined, onDelete: reshape ? undefined : props?.onRowDelete, deleteLabel: props?.deleteLabel, onToggleSelect: selectable
|
|
77
105
|
? () => {
|
|
78
106
|
if (answerHeldPress?.())
|
|
79
107
|
return;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { FieldDef } from "viewkitjs/fields";
|
|
2
3
|
import type { DisplayCurrency } from "../../fields/currency.js";
|
|
3
4
|
import type { ViewsRowMenuItem } from "../../atoms/types.js";
|
|
4
5
|
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
@@ -17,6 +18,28 @@ import type { GridCellCommitFn, GridCellsCommitFn } from "../core/commit-model.j
|
|
|
17
18
|
import type { GridGroupByState, GridSortState } from "./GridColumnMenu.js";
|
|
18
19
|
import type { GridGroupSortOption } from "./GridGroupMenu.js";
|
|
19
20
|
import type { GridGroupMenuPart } from "./grid-group-menu-parts.js";
|
|
21
|
+
/** Each of the grid's menus as a function from its default items to the items it shows (`menu.drop`, `menu.rename`,
|
|
22
|
+
* `menu.add` and `menu.move` on `viewkitjs/views/list` do the usual changes). `column` gets the column and its field,
|
|
23
|
+
* `row` the row, `group` the group its band names. Each reshapes a menu the grid opens: a column or band whose menu holds
|
|
24
|
+
* none of the grid's rows stays without one. Called while a menu draws: keep them pure and cheap.
|
|
25
|
+
*
|
|
26
|
+
* `row` is asked as a row's menu opens (a right-click, the row's ⋯, the menu key), never for a row drawn or pressed, and
|
|
27
|
+
* may answer later: a promise is asked once per opening, the menu holding one greyed row that waits (`row-waiting`) until
|
|
28
|
+
* it answers, an answer that an opening since has outrun dropped, and one that fails drawing the grid's own rows. Its
|
|
29
|
+
* items hold Open page and Delete (`row-open`, `row-delete`, from `rowHref` and `onRowDelete`): drop `row-delete` for a
|
|
30
|
+
* row that can't be deleted. */
|
|
31
|
+
export type GridMenus<Row> = {
|
|
32
|
+
column?: (items: ViewsMenuItem[], ctx: {
|
|
33
|
+
field: FieldDef | undefined;
|
|
34
|
+
column: ListColumn<Row>;
|
|
35
|
+
}) => ViewsMenuItem[];
|
|
36
|
+
row?: (items: ViewsMenuItem[], ctx: {
|
|
37
|
+
row: Row;
|
|
38
|
+
}) => ViewsMenuItem[] | Promise<ViewsMenuItem[]>;
|
|
39
|
+
group?: (items: ViewsMenuItem[], ctx: {
|
|
40
|
+
group: ListGroup<Row>;
|
|
41
|
+
}) => ViewsMenuItem[];
|
|
42
|
+
};
|
|
20
43
|
/** A group count's noun, singular and plural ("company", "companies"): "2 companies". None: a bare
|
|
21
44
|
* count. */
|
|
22
45
|
export type GroupCountNoun = {
|
|
@@ -167,15 +190,16 @@ export type GridTableProps<Row> = {
|
|
|
167
190
|
sort?: GridSortState;
|
|
168
191
|
/** A sorted column's header wears `icons.sortAsc` or `icons.sortDesc` after its name. Default false. */
|
|
169
192
|
sortMark?: boolean;
|
|
170
|
-
/** The
|
|
171
|
-
*
|
|
193
|
+
/** The list's group, for a column menu's Group by and Ungroup, wherever you keep it (a saved view, the page's
|
|
194
|
+
* address): handed, every column whose field can split the list offers them, as `sort` offers Sort. */
|
|
172
195
|
groupBy?: GridGroupByState;
|
|
173
196
|
sortOptions?: GridGroupSortOption[];
|
|
174
197
|
/** Which figures ride beside a group name — a set, not a choice. */
|
|
175
198
|
groupSummary?: ListGroupSummaryPart[];
|
|
176
199
|
aggregates?: Record<string, ListAggregateKind>;
|
|
177
200
|
onAggregateChange?: (columnId: string, kind: ListAggregateKind) => void;
|
|
178
|
-
/**
|
|
201
|
+
/** The grid shows a saved view: Sort on every bound column, columns placed by the view, and figures only for
|
|
202
|
+
* field-backed columns. It doesn't decide Group by, which follows `groupBy` alone. */
|
|
179
203
|
viewBacked?: boolean;
|
|
180
204
|
onGroupSummaryChange?: (part: ListGroupSummaryPart, next: boolean) => void;
|
|
181
205
|
/** The figures a group header can show, in the list's order: each declared by its column and kind, or drawn
|
|
@@ -228,10 +252,11 @@ export type GridTableProps<Row> = {
|
|
|
228
252
|
* a sort's `fieldKey` and `by`), copies, edits and pastes as its part; an edit commits the whole column's id and
|
|
229
253
|
* the whole value with that part replaced, locked, refused and limited as its whole. Off by default. */
|
|
230
254
|
parts?: boolean;
|
|
231
|
-
/**
|
|
232
|
-
*
|
|
233
|
-
|
|
234
|
-
/** The host's rows for a column's field, as data, drawn just above Hide
|
|
255
|
+
/** Each menu's items reshaped by your function: a column's, a row's and a group band's (`GridMenus`). Without it, each
|
|
256
|
+
* menu holds the grid's rows and what `columnMenuItems`, `rowMenu`, `contextMenu` and `groupMenu` add. */
|
|
257
|
+
menus?: GridMenus<Row>;
|
|
258
|
+
/** The host's rows for a column's field, as data, drawn just above Hide (the old route: `menus.column` reshapes the
|
|
259
|
+
* whole menu); null or an empty
|
|
235
260
|
* list for a field the host adds nothing to. Their keys must not reuse the package's own (`sort-asc`,
|
|
236
261
|
* `hide-column` and the rest). It is called while the grid renders, for every column: keep it pure and cheap. */
|
|
237
262
|
columnMenuItems?: (fieldKey: string) => ViewsMenuItem[] | null;
|
|
@@ -263,6 +288,12 @@ export type GridTableProps<Row> = {
|
|
|
263
288
|
* `declaration → config → prefs` — it may only SUBTRACT from what the
|
|
264
289
|
* columns declare. UI constraint only; the host's API guards its own writes. */
|
|
265
290
|
listConfig?: ListSettingsConfig;
|
|
291
|
+
/** Whether a row's cells write, per row: a row it answers false for opens no editor, takes no typing, paste, fill,
|
|
292
|
+
* clear, cut or bulk-bar write, says "Cell is read-only" when a person tries, and marks its cells `aria-readonly`,
|
|
293
|
+
* as a read-only column's are. It only takes away: a column that doesn't write stays read-only on every row. Absent:
|
|
294
|
+
* every row writes as its columns say. Called while the grid renders, for every row: keep it pure and cheap. A
|
|
295
|
+
* constraint on the screen, while your API guards its own writes. */
|
|
296
|
+
rowWritable?: (row: Row) => boolean;
|
|
266
297
|
/** A row drawn as under the pointer, by its id: its tint, its rail's box, its ⋯ and the name's actions, as a real
|
|
267
298
|
* hover draws them, and `data-hovered` on the row. A real pointer still hovers any row beside it. Every copy of a
|
|
268
299
|
* record a grouping draws twice. Drawn, as a hover is, only on a screen whose pointer hovers (`any-hover`). Absent
|
|
@@ -16,12 +16,14 @@ import type { ListColumn } from "../../model/column-schema.js";
|
|
|
16
16
|
* oversized-debt ceiling whose policy says split the responsibility rather than
|
|
17
17
|
* raise the number.
|
|
18
18
|
*/
|
|
19
|
-
export declare function useGridBatchApi<Row>({ enabled, columns, listConfig, rows, getRowId, pendingByRow, commitBatch, }: {
|
|
19
|
+
export declare function useGridBatchApi<Row>({ enabled, columns, listConfig, rowWritable, rows, getRowId, pendingByRow, commitBatch, }: {
|
|
20
20
|
/** The grid can write at all (the host passed a commit handler). */
|
|
21
21
|
enabled: boolean;
|
|
22
22
|
/** Visible columns — the id resolves against what the user can actually see. */
|
|
23
23
|
columns: ListColumn<Row>[];
|
|
24
24
|
listConfig: ListSettingsConfig | undefined;
|
|
25
|
+
/** The grid's `rowWritable`: a row it refuses is passed over. */
|
|
26
|
+
rowWritable?: (row: Row) => boolean;
|
|
25
27
|
/** Every loaded row, for resolving selected ids to row objects. */
|
|
26
28
|
rows: Row[];
|
|
27
29
|
getRowId: (row: Row) => string;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
import { cellEditBaseline, cellPrevPayload, gridFigureOverlay, gridPasteOverlay } from "./cell-clipboard.js";
|
|
4
4
|
import { columnEffectiveWritable } from "../../model/column-capabilities.js";
|
|
5
|
-
export function useGridBatchApi({ enabled, columns, listConfig, rows, getRowId, pendingByRow, commitBatch, }) {
|
|
5
|
+
export function useGridBatchApi({ enabled, columns, listConfig, rowWritable, rows, getRowId, pendingByRow, commitBatch, }) {
|
|
6
6
|
return useMemo(() => {
|
|
7
7
|
if (!enabled)
|
|
8
8
|
return undefined;
|
|
@@ -18,6 +18,8 @@ export function useGridBatchApi({ enabled, columns, listConfig, rows, getRowId,
|
|
|
18
18
|
const row = byId.get(rowId);
|
|
19
19
|
if (row == null)
|
|
20
20
|
continue;
|
|
21
|
+
if (rowWritable && !rowWritable(row))
|
|
22
|
+
continue;
|
|
21
23
|
const prev = cellPrevPayload(col, cellEditBaseline(col, row, pendingByRow.get(rowId)), col.editUnit?.value(row));
|
|
22
24
|
edits.push({
|
|
23
25
|
row,
|
|
@@ -32,5 +34,5 @@ export function useGridBatchApi({ enabled, columns, listConfig, rows, getRowId,
|
|
|
32
34
|
return commitBatch(edits);
|
|
33
35
|
},
|
|
34
36
|
};
|
|
35
|
-
}, [enabled, columns, listConfig, rows, getRowId, pendingByRow, commitBatch]);
|
|
37
|
+
}, [enabled, columns, listConfig, rowWritable, rows, getRowId, pendingByRow, commitBatch]);
|
|
36
38
|
}
|
|
@@ -5,7 +5,7 @@ import type { ListSettingsConfig } from "../../model/column-capabilities.js";
|
|
|
5
5
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
6
6
|
import type { GridRangeVerbs } from "./useGridRangeActions.js";
|
|
7
7
|
import { type GridChromeTarget, type GridFocusShape } from "../core/grid-focus.js";
|
|
8
|
-
export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome, setChrome, shape, toggleGroup, }: {
|
|
8
|
+
export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome, setChrome, shape, toggleGroup, }: {
|
|
9
9
|
rootRef: RefObject<HTMLDivElement | null>;
|
|
10
10
|
/** A column name, a footer cell, a bar or a checkbox holding the focus (`useGridFocus`); null: a data cell, or
|
|
11
11
|
* nothing. */
|
|
@@ -29,6 +29,8 @@ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell
|
|
|
29
29
|
/** Workspace-settings capability config — the keyboard routes ask the same effective
|
|
30
30
|
* write gate the cells do, so a lock holds here too. */
|
|
31
31
|
listConfig?: ListSettingsConfig;
|
|
32
|
+
/** The grid's per-row answer: a row it refuses takes no edit from a key, as a locked column doesn't. */
|
|
33
|
+
rowWritable?: (row: Row) => boolean;
|
|
32
34
|
visibleRowIds: string[];
|
|
33
35
|
/** Row key → the rendered row and its DATA id. Focus is a KEY; a commit needs
|
|
34
36
|
* the record and the id behind it. */
|
|
@@ -55,7 +57,7 @@ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell
|
|
|
55
57
|
cancelEdit: () => void;
|
|
56
58
|
commitEdit: (row: Row, rowId: string, columnId: string, previous: unknown, next: unknown) => void;
|
|
57
59
|
/** Say why a cell can't be written; answers whether it said anything. */
|
|
58
|
-
refuseEdit: (columnId: string) => boolean;
|
|
60
|
+
refuseEdit: (columnId: string, rowOk?: boolean) => boolean;
|
|
59
61
|
undo: (resolveRow: (rowId: string) => Row | undefined, onApply?: (pos: GridCellPos) => void) => boolean;
|
|
60
62
|
redo: (resolveRow: (rowId: string) => Row | undefined, onApply?: (pos: GridCellPos) => void) => boolean;
|
|
61
63
|
/** This grid is the one the page edited last (`useGridEditing`'s `isLastEdited`): with the focus in no grid's frame,
|
|
@@ -30,7 +30,7 @@ function eventBelongsElsewhere(target, root) {
|
|
|
30
30
|
return true;
|
|
31
31
|
return !!target.closest(INTERACTIVE) && !root?.contains(target);
|
|
32
32
|
}
|
|
33
|
-
export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited = () => true, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome = null, setChrome = () => { }, shape, toggleGroup, }) {
|
|
33
|
+
export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited = () => true, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome = null, setChrome = () => { }, shape, toggleGroup, }) {
|
|
34
34
|
const { ports, messages } = useViews();
|
|
35
35
|
const navFromEditorRef = useRef({ tab: () => { }, enter: () => { } });
|
|
36
36
|
const onEditorTab = useCallback((rowId, columnId, backwards) => navFromEditorRef.current.tab(rowId, columnId, backwards), []);
|
|
@@ -247,6 +247,11 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
247
247
|
};
|
|
248
248
|
function handleCellKey(event, focusedCell, leave) {
|
|
249
249
|
const resolveFocused = () => resolveFocusedAt(focusedCell);
|
|
250
|
+
const rowOk = () => {
|
|
251
|
+
const { row } = resolveFocused();
|
|
252
|
+
return row == null || (rowWritable?.(row) ?? true);
|
|
253
|
+
};
|
|
254
|
+
const cellWrites = (column) => columnEffectiveWritable(column, listConfig) && rowOk();
|
|
250
255
|
const mod = (event.metaKey || event.ctrlKey) && !event.shiftKey && !event.altKey;
|
|
251
256
|
const bare = !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
252
257
|
const navDirection = NAV_KEYS[event.key];
|
|
@@ -329,7 +334,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
329
334
|
isWholeTextColumn(column) &&
|
|
330
335
|
gridCellCutOff(findGridCell(rootRef.current, focusedCell));
|
|
331
336
|
if (column &&
|
|
332
|
-
((editingEnabled && gridColumnHasEditor(column) &&
|
|
337
|
+
((editingEnabled && gridColumnHasEditor(column) && cellWrites(column)) ||
|
|
333
338
|
gridColumnInspectable(column) ||
|
|
334
339
|
whole)) {
|
|
335
340
|
startEdit(focusedCell.rowId, focusedCell.columnId, undefined, whole, true);
|
|
@@ -338,7 +343,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
338
343
|
if (column &&
|
|
339
344
|
editingEnabled &&
|
|
340
345
|
gridBooleanMode(column) === "toggle" &&
|
|
341
|
-
|
|
346
|
+
cellWrites(column)) {
|
|
342
347
|
const { row, rowId } = resolveFocused();
|
|
343
348
|
if (row != null) {
|
|
344
349
|
const on = cellEditBaseline(column, row, pendingByRow.get(rowId)) === true;
|
|
@@ -346,7 +351,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
346
351
|
return;
|
|
347
352
|
}
|
|
348
353
|
}
|
|
349
|
-
if (column && refuseEdit(column.id))
|
|
354
|
+
if (column && refuseEdit(column.id, rowOk()))
|
|
350
355
|
return;
|
|
351
356
|
const next = nextCellPos(focusedCell, "down", visibleRowIds, visibleColIds);
|
|
352
357
|
if (!next)
|
|
@@ -377,7 +382,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
377
382
|
const { column, row, rowId } = resolveFocused();
|
|
378
383
|
if (!column || row == null)
|
|
379
384
|
return;
|
|
380
|
-
if (!editingEnabled || !
|
|
385
|
+
if (!editingEnabled || !cellWrites(column))
|
|
381
386
|
return;
|
|
382
387
|
if (!gridBooleanMode(column) && !column.clearable)
|
|
383
388
|
return;
|
|
@@ -396,8 +401,8 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
396
401
|
const { column, row, rowId } = resolveFocused();
|
|
397
402
|
if (!column || row == null || !editingEnabled)
|
|
398
403
|
return;
|
|
399
|
-
if (!
|
|
400
|
-
if (!refuseEdit(column.id))
|
|
404
|
+
if (!cellWrites(column)) {
|
|
405
|
+
if (!refuseEdit(column.id, rowOk()))
|
|
401
406
|
ports.toast.error(gridClearRefusal(column, listConfig, messages));
|
|
402
407
|
return;
|
|
403
408
|
}
|
|
@@ -417,8 +422,8 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
417
422
|
const column = visibleColumns.find((item) => item.id === focusedCell.columnId);
|
|
418
423
|
if (!column)
|
|
419
424
|
return;
|
|
420
|
-
if (!
|
|
421
|
-
if (refuseEdit(column.id))
|
|
425
|
+
if (!cellWrites(column)) {
|
|
426
|
+
if (refuseEdit(column.id, rowOk()))
|
|
422
427
|
event.preventDefault();
|
|
423
428
|
return;
|
|
424
429
|
}
|
|
@@ -444,6 +449,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
444
449
|
getRowId,
|
|
445
450
|
lastCellRef,
|
|
446
451
|
listConfig,
|
|
452
|
+
rowWritable,
|
|
447
453
|
releaseToFrame,
|
|
448
454
|
messages,
|
|
449
455
|
pendingByRow,
|
|
@@ -26,7 +26,6 @@ export function useGridPendingReconciliation({ rows, columns, getRowId, pendingB
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
const matched = findGridPendingMatches(rows, columns, getRowId, pendingByRow, hasInflight);
|
|
29
|
-
|
|
30
|
-
reconcile(matched);
|
|
29
|
+
reconcile(matched);
|
|
31
30
|
}, [columns, getRowId, hasInflight, messages, pendingBaseline, pendingByRow, ports, reconcile, rows]);
|
|
32
31
|
}
|
|
@@ -72,7 +72,7 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
|
|
|
72
72
|
commitBatch: (edits: (GridEditCell<Row> & {
|
|
73
73
|
row: Row;
|
|
74
74
|
})[]) => Promise<boolean>;
|
|
75
|
-
refuseEdit: (columnId: string) => boolean;
|
|
75
|
+
refuseEdit: (columnId: string, rowOk?: boolean) => boolean;
|
|
76
76
|
onExtendCell: (rowId: string, columnId: string) => void;
|
|
77
77
|
onAddCell: (rowId: string, columnId: string) => void;
|
|
78
78
|
handleRootPointerDown: (event: React.PointerEvent) => void;
|
|
@@ -20,7 +20,7 @@ import { useGridRangeGestures } from "./useGridRangeGestures.js";
|
|
|
20
20
|
import { useGridCellPick } from "./useGridCellPick.js";
|
|
21
21
|
const REFUSAL_REPEAT_MS = 600;
|
|
22
22
|
export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows, heldRows, rowIndex, visibleColumns, selecting, revealRow, focusShape, groupOfRow, }) {
|
|
23
|
-
const { columns, getRowId, listConfig } = props;
|
|
23
|
+
const { columns, getRowId, listConfig, rowWritable } = props;
|
|
24
24
|
const { conventions, ports, messages } = useViews();
|
|
25
25
|
const editingEnabled = !!props.onCellCommit;
|
|
26
26
|
const sayRefusal = useCallback((refusal) => {
|
|
@@ -133,13 +133,17 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
133
133
|
return commitBatchRaw(kept);
|
|
134
134
|
}, [columnById, commitBatchRaw, conventions, messages, ports, lockedRefusal, wholeStored]);
|
|
135
135
|
const lastRefusalRef = useRef(null);
|
|
136
|
-
const refuseEdit = useCallback((columnId) => {
|
|
136
|
+
const refuseEdit = useCallback((columnId, rowOk = true) => {
|
|
137
137
|
if (!editingEnabled)
|
|
138
138
|
return false;
|
|
139
139
|
const col = visibleColumns.find((c) => c.id === columnId);
|
|
140
|
-
if (!col
|
|
140
|
+
if (!col)
|
|
141
141
|
return false;
|
|
142
|
-
const reason =
|
|
142
|
+
const reason = !columnEffectiveWritable(col, listConfig)
|
|
143
|
+
? gridEditRefusal(col, listConfig, conventions, messages)
|
|
144
|
+
: rowOk
|
|
145
|
+
? undefined
|
|
146
|
+
: messages({ key: "views.grid.cell-read-only" });
|
|
143
147
|
if (!reason)
|
|
144
148
|
return false;
|
|
145
149
|
const now = Date.now();
|
|
@@ -229,7 +233,8 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
229
233
|
conventions,
|
|
230
234
|
messages,
|
|
231
235
|
listConfig,
|
|
232
|
-
|
|
236
|
+
rowWritable,
|
|
237
|
+
}), [rows, rowIndex, visibleRows, visibleColumns, pendingByRow, conventions, messages, listConfig, rowWritable]);
|
|
233
238
|
const revealCell = useCallback((pos, behavior) => revealGridCell(rootRef.current, pos, behavior, revealRow), [revealRow, rootRef]);
|
|
234
239
|
const finishFillRef = useRef(() => { });
|
|
235
240
|
const { fillTargetRow, onExtendCell, onAddCell, handleRootPointerDown, handleRootPointerDownCapture, handleRootClickCapture, } = useGridRangeGestures({
|
|
@@ -275,6 +280,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
275
280
|
editingCell,
|
|
276
281
|
editingEnabled,
|
|
277
282
|
listConfig,
|
|
283
|
+
rowWritable,
|
|
278
284
|
visibleRowIds: visibleRows,
|
|
279
285
|
visibleColIds: visibleColumnIds,
|
|
280
286
|
visibleColumns,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { FieldSettlement } from "viewkitjs/fields";
|
|
2
2
|
/** `reload: false`: the commit's own reload is skipped because its caller reloads once after a second
|
|
3
|
-
* write — a board drop under manual order saves the order next, and that reload shows both.
|
|
3
|
+
* write — a board drop under manual order saves the order next, and that reload shows both.
|
|
4
|
+
* `closing`: the page is going (`pagehide`): send it so it outlives the page (`fetch(…, { keepalive: true })`). */
|
|
4
5
|
export type GridCommitContext = {
|
|
5
6
|
kind: "commit";
|
|
6
7
|
reload?: false;
|
|
8
|
+
closing?: true;
|
|
7
9
|
} | {
|
|
8
10
|
kind: "restore";
|
|
9
11
|
expected: unknown;
|
|
12
|
+
closing?: true;
|
|
10
13
|
};
|
|
11
14
|
export type GridCommitOutcome = {
|
|
12
15
|
status: "confirmed";
|
|
@@ -22,7 +25,8 @@ export type GridCommitOutcome = {
|
|
|
22
25
|
* as null): the value as the row now reads it in this column. Present, even
|
|
23
26
|
* as null, the cell shows it in place of what was typed, undo and redo
|
|
24
27
|
* restore from it (unless `history` says otherwise), and the rows that carry
|
|
25
|
-
* it next clear the cell without a word.
|
|
28
|
+
* it next clear the cell without a word. On an undo or a redo the cell shows it
|
|
29
|
+
* until the rows carry it; the history is left as it was. */
|
|
26
30
|
stored?: unknown;
|
|
27
31
|
} | {
|
|
28
32
|
status: "unconfirmed";
|
|
@@ -31,6 +35,20 @@ export type GridCommitOutcome = {
|
|
|
31
35
|
status: "failed";
|
|
32
36
|
error?: unknown;
|
|
33
37
|
};
|
|
38
|
+
/** One record's change, as an app's save receives it: the record's id, its row as the grid holds it, the values to
|
|
39
|
+
* write (one key or more per cell, merged), and whether the page is going (send it so it outlives the page). */
|
|
40
|
+
export type ListChange<Row> = {
|
|
41
|
+
id: string;
|
|
42
|
+
row: Row;
|
|
43
|
+
values: Record<string, unknown>;
|
|
44
|
+
closing?: boolean;
|
|
45
|
+
};
|
|
46
|
+
/** The one function an app gives to save a change to a record: an edit, a paste, a fill, an undo or a redo. It
|
|
47
|
+
* resolves once the record holds the values, with what was kept where the server stored something else; it rejects
|
|
48
|
+
* to refuse the change. */
|
|
49
|
+
export type ListSave<Row> = (change: ListChange<Row>) => Promise<void | {
|
|
50
|
+
stored?: Partial<Row>;
|
|
51
|
+
}>;
|
|
34
52
|
/** One write the app refused, as the editing core reports it: the columns of the cells that failed, in order, how many,
|
|
35
53
|
* and the first failure's error (or the call's rejection). */
|
|
36
54
|
export type GridCommitRefusal = {
|
|
@@ -68,6 +68,10 @@ export declare class GridEditingController<Row> {
|
|
|
68
68
|
* as success: a caller awaiting this should confirm, not report a failure.
|
|
69
69
|
*/
|
|
70
70
|
commit(cells: GridCommitCell<Row>[]): Promise<boolean>;
|
|
71
|
+
/** The rows were read again, and these cells now show their overlay's value (or have moved past it). A press's
|
|
72
|
+
* overlay not yet sent is held: rows that show what it puts back before its write went out may be rows the edit it
|
|
73
|
+
* takes back hasn't reached yet. It is cleared when its restore is confirmed, if the latest rows still showed it:
|
|
74
|
+
* every pass says again what the rows show, the press sent or not. */
|
|
71
75
|
reconcile(matchedKeys: readonly string[]): void;
|
|
72
76
|
undo(resolveRow: ResolveRow<Row>, onApply?: (pos: GridCellPos) => void): boolean;
|
|
73
77
|
redo(resolveRow: ResolveRow<Row>, onApply?: (pos: GridCellPos) => void): boolean;
|
|
@@ -136,7 +140,21 @@ export declare class GridEditingController<Row> {
|
|
|
136
140
|
private performBatch;
|
|
137
141
|
private inflightFor;
|
|
138
142
|
private enqueueApply;
|
|
143
|
+
/** Takes a press's overlay off these cells where it still stands, putting back what it covered; a later press that
|
|
144
|
+
* covered it covers what it covered instead. */
|
|
145
|
+
private liftPress;
|
|
146
|
+
/** What a waiting press covered follows the overlay it covered: gone with a refused write, the kept value with a
|
|
147
|
+
* stored one, marked with a `requested` one. */
|
|
148
|
+
private reviseCovered;
|
|
149
|
+
/** Is this cell's overlay a press's own, not yet sent? */
|
|
150
|
+
private unsentPressOn;
|
|
139
151
|
private applyPin;
|
|
152
|
+
/** Decides what a press writes and hands it to the app, synchronously up to the call: after the wait for the edit
|
|
153
|
+
* it takes back, or inside the page's close. Null when it sends nothing. */
|
|
154
|
+
private sendPin;
|
|
155
|
+
/** The page is going: a press still waiting for the edit it takes back is sent now, inside the event, or never. Its
|
|
156
|
+
* answer settles it as usual if the page stays (the back-forward cache). */
|
|
157
|
+
private sendAtClose;
|
|
140
158
|
/** A press that applied hands what it put back to the first edit written over each of its cells since: that edit
|
|
141
159
|
* was typed over what the press took back, so its own undo has to put back what the press put back. */
|
|
142
160
|
private carryPutBack;
|