viewkitjs 0.36.0 → 0.38.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 +75 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +18 -9
- package/views/dist/contract.js +18 -1
- package/views/dist/controls/button/own-look-moved.d.ts +11 -0
- package/views/dist/controls/button/own-look-moved.js +3 -0
- package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
- package/views/dist/controls/date-editor/date-behaviour.js +187 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
- package/views/dist/controls/date-editor/date-editor.js +29 -166
- package/views/dist/controls/field/field.d.ts +3 -2
- package/views/dist/controls/field/field.js +7 -2
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -4
- package/views/dist/controls/field.css +64 -1
- package/views/dist/controls/filter-editor/filter-editor.js +2 -2
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +1 -1
- package/views/dist/controls/glyphs/glyphs.js +2 -0
- package/views/dist/controls/index.d.ts +3 -1
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +10 -0
- package/views/dist/controls/internal/phone.d.ts +1 -1
- package/views/dist/controls/internal/phone.js +3 -2
- package/views/dist/controls/internal/read-token.d.ts +2 -1
- package/views/dist/controls/internal/read-token.js +2 -1
- package/views/dist/controls/list/tokens.d.ts +1 -1
- package/views/dist/controls/list/tokens.js +1 -1
- package/views/dist/controls/list.css +5 -2
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/number-editor/tokens.d.ts +8 -0
- package/views/dist/controls/number-editor/tokens.js +2 -0
- package/views/dist/controls/number-editor.css +20 -0
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker.css +5 -3
- package/views/dist/controls/popover/looks.d.ts +1 -1
- package/views/dist/controls/popover/looks.js +5 -0
- package/views/dist/controls/popover/tokens.d.ts +13 -1
- package/views/dist/controls/popover/tokens.js +4 -1
- package/views/dist/controls/popover.css +59 -8
- package/views/dist/controls/select/select.js +1 -1
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/text-editor/tokens.d.ts +8 -0
- package/views/dist/controls/text-editor/tokens.js +2 -0
- package/views/dist/controls/text-editor.css +28 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +7 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +1 -1
- package/views/dist/controls/tooltip/tokens.js +1 -1
- package/views/dist/controls/tooltip/tooltip.js +2 -1
- package/views/dist/controls/tooltip.css +5 -3
- package/views/dist/controls/values-editor.css +20 -5
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/field-row/FieldRow.js +25 -12
- package/views/dist/field-row/field-row-button.d.ts +12 -0
- package/views/dist/field-row/field-row-button.js +5 -0
- package/views/dist/fields/binding.d.ts +4 -0
- package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
- package/views/dist/grid/chrome/GridCellEditors.js +3 -2
- package/views/dist/grid/chrome/GridCellOutline.d.ts +15 -5
- package/views/dist/grid/chrome/GridCellOutline.js +20 -5
- package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridDateEditor.js +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
- package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNameEditor.js +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +3 -2
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
- package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
- package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +6 -5
- package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
- package/views/dist/grid/chrome/GridStructure.js +3 -3
- package/views/dist/grid/chrome/GridTable.d.ts +2 -1
- package/views/dist/grid/chrome/GridTable.js +7 -2
- package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +4 -2
- package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
- package/views/dist/grid/chrome/grid-body-place.js +9 -4
- package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
- package/views/dist/grid/chrome/grid-edit-session.d.ts +8 -0
- package/views/dist/grid/chrome/grid-edit-session.js +21 -3
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +11 -0
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +4 -4
- package/views/dist/grid/chrome/grid-fitted-box.js +1 -3
- package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
- package/views/dist/grid/chrome/grid-hover.js +2 -3
- package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +5 -2
- package/views/dist/grid/chrome/useGridKeyboard.js +11 -15
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +30 -2
- package/views/dist/grid/core/useGridEditing.d.ts +3 -0
- package/views/dist/grid/core/useGridEditing.js +2 -0
- package/views/dist/grid/grid.css +4 -19
- package/views/dist/internal/length.d.ts +2 -0
- package/views/dist/internal/length.js +16 -0
- package/views/dist/internal/screen-forms.d.ts +11 -0
- package/views/dist/internal/screen-forms.js +31 -0
- package/views/dist/list/list.js +2 -1
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +7 -3
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +6 -3
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +3 -2
- package/views/dist/panels/react/views-row/FoldingViewRow.js +24 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +1 -1
- package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
- package/views/dist/panels/react/views-row/more-views.js +3 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/toolbar/model.d.ts +2 -2
- package/views/dist/provider/components.d.ts +8 -7
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/selection/bar-overflow.d.ts +2 -0
- package/views/dist/selection/bar-overflow.js +2 -1
- package/views/dist/selection/bar-props.d.ts +1 -1
- package/views/dist/selection/verbs.d.ts +2 -2
- package/views/dist/styles.css +341 -80
- package/views/dist/styles.unlayered.css +341 -80
- package/views/docs/contract.md +77 -23
- package/views/docs/controls/list.md +2 -0
- package/views/docs/controls/menu.md +2 -0
- package/views/docs/controls/number-editor.md +2 -0
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/popover.md +7 -0
- package/views/docs/controls/text-editor.md +2 -0
- package/views/docs/controls/tooltip.md +2 -0
- package/views/docs/guides/atoms.md +11 -10
- package/views/docs/guides/selection.md +1 -1
- package/views/docs/guides/the-grid.md +7 -5
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/reference/controls.md +11 -6
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/list.md +5 -6
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +5 -4
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +6 -6
- package/views/docs/reference/selection.md +1 -1
- package/views/docs/reference/views.md +3 -3
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -14,6 +14,7 @@ import { GridEditsSinkContext } from "../core/edits-sink.js";
|
|
|
14
14
|
import { GRID_KEY_OWNING_SURFACES, gridFocusElement } from "./useGridFocus.js";
|
|
15
15
|
import { isGridRowMenuKey, openGridRowMenu } from "./grid-row-menu-key.js";
|
|
16
16
|
import { openGridEditEscape } from "./grid-edit-escape.js";
|
|
17
|
+
import { flushGridKeptAnswers } from "./grid-edit-session.js";
|
|
17
18
|
import { bodyInnerStepFrame } from "../../editors/inner-escape.js";
|
|
18
19
|
import { gridBarArrow, gridFocusStep, gridFocusTab, } from "../core/grid-focus.js";
|
|
19
20
|
const NAV_KEYS = {
|
|
@@ -33,11 +34,10 @@ function eventBelongsElsewhere(target, root) {
|
|
|
33
34
|
return true;
|
|
34
35
|
return !!target.closest(INTERACTIVE) && !root?.contains(target);
|
|
35
36
|
}
|
|
36
|
-
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, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome = null, setChrome = () => { }, shape, toggleGroup, }) {
|
|
37
|
+
export function useGridKeyboard({ rootRef, focusedCell, editingCell, editClosing = false, editingEnabled, listConfig, rowWritable, visibleRowIds, rowByKey, visibleColIds, visibleColumns, rows, getRowId, pendingByRow, rangeVerbsRef, focusCell, clearFocus, startEdit, cancelEdit, commitEdit, refuseEdit, undo, redo, isLastEdited = () => true, editsState, rangeSetRect, rangeExtendTo, ranges, revealCell, releaseToFrame, lastCellRef, chrome = null, setChrome = () => { }, shape, toggleGroup, }) {
|
|
37
38
|
const { ports, messages, conventions } = useViews();
|
|
38
|
-
const navFromEditorRef = useRef({ tab: () => { }
|
|
39
|
+
const navFromEditorRef = useRef({ tab: () => { } });
|
|
39
40
|
const onEditorTab = useCallback((rowId, columnId, backwards) => navFromEditorRef.current.tab(rowId, columnId, backwards), []);
|
|
40
|
-
const onEditorEnter = useCallback((rowId, columnId) => navFromEditorRef.current.enter(rowId, columnId), []);
|
|
41
41
|
const rowMenuWatchRef = useRef(null);
|
|
42
42
|
useEffect(() => () => rowMenuWatchRef.current?.(), []);
|
|
43
43
|
useEffect(() => {
|
|
@@ -49,13 +49,6 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
49
49
|
focusCell(next.rowId, next.columnId);
|
|
50
50
|
revealCell(next, "auto");
|
|
51
51
|
},
|
|
52
|
-
enter: (rowId, columnId) => {
|
|
53
|
-
const next = nextCellPos({ rowId, columnId }, "down", visibleRowIds, visibleColIds);
|
|
54
|
-
if (!next)
|
|
55
|
-
return;
|
|
56
|
-
focusCell(next.rowId, next.columnId);
|
|
57
|
-
revealCell(next, "auto");
|
|
58
|
-
},
|
|
59
52
|
};
|
|
60
53
|
}, [focusCell, revealCell, visibleColIds, visibleRowIds]);
|
|
61
54
|
const rowsWait = useContext(GridWaitContext);
|
|
@@ -101,6 +94,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
101
94
|
const holder = event.target?.closest?.('[data-slot="vk-grid"]') ?? null;
|
|
102
95
|
if (holder ? holder !== rootRef.current : !isLastEdited())
|
|
103
96
|
return;
|
|
97
|
+
flushGridKeptAnswers();
|
|
104
98
|
const handled = event.shiftKey
|
|
105
99
|
? redo(resolveRow, scrollToCell)
|
|
106
100
|
: undo(resolveRow, scrollToCell);
|
|
@@ -278,6 +272,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
278
272
|
const bare = !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
279
273
|
const navDirection = NAV_KEYS[event.key];
|
|
280
274
|
const navIntent = gridNavIntent(event);
|
|
275
|
+
const editorHolds = editingCell != null && !editClosing;
|
|
281
276
|
rowMenuWatchRef.current?.();
|
|
282
277
|
rowMenuWatchRef.current = null;
|
|
283
278
|
if (isGridRowMenuKey(event) && !editingCell) {
|
|
@@ -289,14 +284,14 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
289
284
|
}
|
|
290
285
|
if (event.key === "Escape") {
|
|
291
286
|
event.stopPropagation();
|
|
292
|
-
if (
|
|
287
|
+
if (editorHolds)
|
|
293
288
|
(openGridEditEscape() ?? cancelEdit)();
|
|
294
289
|
else {
|
|
295
290
|
clearFocus();
|
|
296
291
|
releaseToFrame();
|
|
297
292
|
}
|
|
298
293
|
}
|
|
299
|
-
else if (navDirection && bare && !
|
|
294
|
+
else if (navDirection && bare && !editorHolds) {
|
|
300
295
|
event.preventDefault();
|
|
301
296
|
if (shape && navDirection !== "right") {
|
|
302
297
|
const step = gridFocusStep({ kind: "cell", pos: focusedCell }, navDirection, shape);
|
|
@@ -310,7 +305,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
310
305
|
focusCell(next.rowId, next.columnId);
|
|
311
306
|
revealCell(next, "auto");
|
|
312
307
|
}
|
|
313
|
-
else if (navIntent && !
|
|
308
|
+
else if (navIntent && !editorHolds) {
|
|
314
309
|
event.preventDefault();
|
|
315
310
|
if (navIntent.kind === "selectAll") {
|
|
316
311
|
const rect = wholeTableRect(visibleRowIds, visibleColIds);
|
|
@@ -336,7 +331,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
336
331
|
revealCell(next, "auto");
|
|
337
332
|
}
|
|
338
333
|
else if (event.key === "Tab" && !event.metaKey && !event.ctrlKey && !event.altKey) {
|
|
339
|
-
if (
|
|
334
|
+
if (editorHolds) {
|
|
340
335
|
event.preventDefault();
|
|
341
336
|
return;
|
|
342
337
|
}
|
|
@@ -464,6 +459,7 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
464
459
|
chrome,
|
|
465
460
|
clearFocus,
|
|
466
461
|
commitEdit,
|
|
462
|
+
editClosing,
|
|
467
463
|
editingCell,
|
|
468
464
|
editingEnabled,
|
|
469
465
|
entryCell,
|
|
@@ -494,5 +490,5 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
494
490
|
visibleColumns,
|
|
495
491
|
visibleRowIds,
|
|
496
492
|
]);
|
|
497
|
-
return { onEditorTab,
|
|
493
|
+
return { onEditorTab, enterGrid };
|
|
498
494
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type RefObject } from "react";
|
|
2
2
|
import { type GridCommitOverlay, type GridEditCell } from "../core/useGridEditing.js";
|
|
3
3
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
4
|
+
import { type CloseReason } from "viewkitjs/fields";
|
|
4
5
|
import { type GridCellPos } from "../core/coordinates.js";
|
|
5
6
|
import type { GridTableProps } from "./grid-table-props.js";
|
|
6
7
|
import { type GridFocusShape } from "../core/grid-focus.js";
|
|
@@ -40,7 +41,6 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
|
|
|
40
41
|
lastCellRef: RefObject<GridCellPos | null>;
|
|
41
42
|
};
|
|
42
43
|
onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
|
|
43
|
-
onEditorEnter: (rowId: string, columnId: string) => void;
|
|
44
44
|
enterGrid: (_which: "start" | "end", from: Element | null) => void;
|
|
45
45
|
visibleColIds: string[];
|
|
46
46
|
rowSpansMap: Map<string, import("../core/range-model.js").GridRowRangeSpan[]>;
|
|
@@ -63,6 +63,8 @@ export declare function useGridTableInteractionModel<Row>({ rootRef, props, rows
|
|
|
63
63
|
editSeed: string | null;
|
|
64
64
|
editWhole: boolean;
|
|
65
65
|
editByKey: boolean;
|
|
66
|
+
editClosing: boolean;
|
|
67
|
+
onEditorClosing: (rowId: string, columnId: string, reason: CloseReason | null, popover: boolean) => void;
|
|
66
68
|
focusCellSync: (rowId: string, columnId: string) => void;
|
|
67
69
|
startEditSync: (rowId: string, columnId: string, seed?: string | null, whole?: boolean, byKey?: boolean) => void;
|
|
68
70
|
cancelEdit: (rowId?: string, columnId?: string) => void;
|
|
@@ -12,7 +12,7 @@ import { gridFigureOf } from "../core/clipboard-model.js";
|
|
|
12
12
|
import { sameStoredValue } from "viewkitjs/fields";
|
|
13
13
|
import { gridRowIdFromKey } from "../core/coordinates.js";
|
|
14
14
|
import { revealGridCell } from "./grid-scroll-owner.js";
|
|
15
|
-
import { useGridFocus } from "./useGridFocus.js";
|
|
15
|
+
import { gridFocusElement, useGridFocus } from "./useGridFocus.js";
|
|
16
16
|
import { gridBarOf } from "../core/grid-focus.js";
|
|
17
17
|
import { useGridKeyboard } from "./useGridKeyboard.js";
|
|
18
18
|
import { useGridPendingReconciliation } from "./useGridPendingReconciliation.js";
|
|
@@ -34,7 +34,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
34
34
|
const columnById = useMemo(() => new Map([...columns, ...visibleColumns].map((column) => [column.id, column])), [columns, visibleColumns]);
|
|
35
35
|
const partOfWhole = useCallback((wholeId) => [...columnById.values()].find((column) => column.partOf?.column === wholeId)?.partOf, [columnById]);
|
|
36
36
|
const keepsSent = useCallback((columnId) => partOfWhole(columnId) != null, [partOfWhole]);
|
|
37
|
-
const { focused: focusedCell, editing: editingCell, pendingByRow, pendingOf, settlementByRow, writeStateByRow, focusCell, clearFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, canUndo: canUndoNow, canRedo: canRedoNow, saving: savingNow, hasInflight, pendingBaseline, sent, sentCells, forgetSent, isLastEdited, } = useGridEditing(props.onCellCommit, props.onCellsCommit, sayRefusal, keepsSent);
|
|
37
|
+
const { focused: focusedCell, editing: editingCell, pendingByRow, pendingOf, settlementByRow, writeStateByRow, focusCell, clearFocus, dropFocus, startEdit, cancelEdit, closeEdit, commitEdit: commitEditRaw, commitBatch: commitBatchRaw, undo, redo, reconcile, canUndo: canUndoNow, canRedo: canRedoNow, saving: savingNow, hasInflight, pendingBaseline, sent, sentCells, forgetSent, isLastEdited, } = useGridEditing(props.onCellCommit, props.onCellsCommit, sayRefusal, keepsSent);
|
|
38
38
|
const wholeStored = useCallback((rowId, wholeId, row) => {
|
|
39
39
|
const part = partOfWhole(wholeId);
|
|
40
40
|
const overlay = pendingOf(rowId);
|
|
@@ -225,6 +225,31 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
225
225
|
if (onGround || !cellPick.held)
|
|
226
226
|
clearFocusSync();
|
|
227
227
|
}, [cellPick.held, clearFocusSync]);
|
|
228
|
+
const [editClosing, setEditClosing] = useState(false);
|
|
229
|
+
const [seenEditing, setSeenEditing] = useState(editingCell);
|
|
230
|
+
if (seenEditing !== editingCell) {
|
|
231
|
+
setSeenEditing(editingCell);
|
|
232
|
+
setEditClosing(false);
|
|
233
|
+
}
|
|
234
|
+
const closingRef = useRef({ editingCell, held: cellPick.held, dropFocus, rangeClear });
|
|
235
|
+
useEffect(() => {
|
|
236
|
+
closingRef.current = { editingCell, held: cellPick.held, dropFocus, rangeClear };
|
|
237
|
+
});
|
|
238
|
+
const onEditorClosing = useCallback((rowId, columnId, reason, popover) => {
|
|
239
|
+
const { editingCell: open, held, dropFocus: drop, rangeClear: clear } = closingRef.current;
|
|
240
|
+
if (!open || open.rowId !== rowId || open.columnId !== columnId)
|
|
241
|
+
return;
|
|
242
|
+
setEditClosing(true);
|
|
243
|
+
const away = reason === "outside" || reason === "blur";
|
|
244
|
+
if (away && document.hasFocus() && !held) {
|
|
245
|
+
drop();
|
|
246
|
+
clear();
|
|
247
|
+
}
|
|
248
|
+
const keeps = reason === "escape" || reason === "pick" || reason === "enter";
|
|
249
|
+
const root = rootRef.current;
|
|
250
|
+
if (keeps && popover && root)
|
|
251
|
+
gridFocusElement(root, { kind: "cell", pos: open })?.focus({ preventScroll: true });
|
|
252
|
+
}, [rootRef]);
|
|
228
253
|
const spreadsheetModel = useMemo(() => ({
|
|
229
254
|
rows,
|
|
230
255
|
rowByKey: rowIndex,
|
|
@@ -284,6 +309,7 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
284
309
|
rootRef,
|
|
285
310
|
focusedCell,
|
|
286
311
|
editingCell,
|
|
312
|
+
editClosing,
|
|
287
313
|
editingEnabled,
|
|
288
314
|
listConfig,
|
|
289
315
|
rowWritable,
|
|
@@ -329,6 +355,8 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
329
355
|
editSeed,
|
|
330
356
|
editWhole,
|
|
331
357
|
editByKey,
|
|
358
|
+
editClosing,
|
|
359
|
+
onEditorClosing,
|
|
332
360
|
focusCellSync,
|
|
333
361
|
startEditSync,
|
|
334
362
|
cancelEdit,
|
|
@@ -20,6 +20,9 @@ type GridEditingApi<Row> = {
|
|
|
20
20
|
writeStateByRow: GridWriteStateByRow;
|
|
21
21
|
focusCell: (rowId: string, columnId: string) => void;
|
|
22
22
|
clearFocus: () => void;
|
|
23
|
+
/** Lets the pick go and leaves an open editor be: it plays out its close, and its answer is written as before. A press
|
|
24
|
+
* away from a cell whose editor is closing. */
|
|
25
|
+
dropFocus: () => void;
|
|
23
26
|
startEdit: (rowId: string, columnId: string) => void;
|
|
24
27
|
cancelEdit: (rowId?: string, columnId?: string) => void;
|
|
25
28
|
/** Close the editor open on this cell, by its RECORD id as a commit carries it, and write nothing:
|
|
@@ -29,6 +29,7 @@ export function useGridEditing(onCellCommit, onCellsCommit, onRefused, keepsSent
|
|
|
29
29
|
setFocused(null);
|
|
30
30
|
setEditing(null);
|
|
31
31
|
}, []);
|
|
32
|
+
const dropFocus = useCallback(() => setFocused(null), []);
|
|
32
33
|
const startEdit = useCallback((rowId, columnId) => {
|
|
33
34
|
setFocused({ rowId, columnId });
|
|
34
35
|
setEditing({ rowId, columnId });
|
|
@@ -94,6 +95,7 @@ export function useGridEditing(onCellCommit, onCellsCommit, onRefused, keepsSent
|
|
|
94
95
|
writeStateByRow,
|
|
95
96
|
focusCell,
|
|
96
97
|
clearFocus,
|
|
98
|
+
dropFocus,
|
|
97
99
|
startEdit,
|
|
98
100
|
cancelEdit,
|
|
99
101
|
closeEdit,
|
package/views/dist/grid/grid.css
CHANGED
|
@@ -90,16 +90,16 @@
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/* Picked cell, Wash: the focused cell (data-focused) washed in the brand's lightest ground inside its frame. Ring: the frame
|
|
93
|
-
alone. */
|
|
94
|
-
[data-grid-cell="wash"] [data-slot="vk-grid-cell"][data-focused],
|
|
95
|
-
[data-slot="vk-grid-cell"][data-focused]:not([data-grid-cell] *) {
|
|
93
|
+
alone. Neither while its editor is open (data-editing): the cell stays as it was under it. */
|
|
94
|
+
[data-grid-cell="wash"] [data-slot="vk-grid-cell"][data-focused]:not([data-editing]),
|
|
95
|
+
[data-slot="vk-grid-cell"][data-focused]:not([data-editing]):not([data-grid-cell] *) {
|
|
96
96
|
background-color: var(--vk-brand-subtlest);
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
/* The two frames the grid draws round a cell, the hovered cell's and the picked cell's, on its four variables. Cell corners:
|
|
100
100
|
both frames' corners, which the grid ties, square or the small corner. Hover frame: the hovered cell's line, none, the
|
|
101
101
|
line's colour or its stronger one. Picked cell frame: the picked cell's line at rest, the brand's or the stronger line;
|
|
102
|
-
under the pointer
|
|
102
|
+
under the pointer it is the brand's either way. */
|
|
103
103
|
[data-grid-corners="square"] [data-slot="vk-grid"] { --vk-outline-radius: 0; }
|
|
104
104
|
[data-grid-corners="round"] [data-slot="vk-grid"],
|
|
105
105
|
[data-slot="vk-grid"]:not([data-grid-corners] *) { --vk-outline-radius: var(--vk-radius-sm); }
|
|
@@ -112,21 +112,6 @@
|
|
|
112
112
|
[data-grid-frame="neutral"] [data-slot="vk-grid"] { --vk-outline: var(--vk-border-bold); }
|
|
113
113
|
[data-slot="vk-grid"] { --vk-outline-active: var(--vk-border-accent); }
|
|
114
114
|
|
|
115
|
-
/* A cell being edited in an editor that draws its own edge shows that edge alone: where ViewKit's Text editor or Number
|
|
116
|
-
editor stands in the cell (data-kit, CONTROLS.TextBody and NumberBody), the input draws the only edge round what is typed,
|
|
117
|
-
so the grid's outline, its brand line and its lift, stands down on the cell being edited (data-editing). Where the grid's
|
|
118
|
-
own editor stands its outline stays, and a cell at rest keeps it. */
|
|
119
|
-
[data-slot="vk-grid-cell"][data-editing]:has([data-kit="text-editor"], [data-kit="number-editor"]) [data-slot="vk-grid-outline"] {
|
|
120
|
-
display: none;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/* A body over its cell has its own edge: while the grid's editor part holds ViewKit's Picker, Compound editor,
|
|
124
|
-
Values editor or Date editor, the cell being edited under it shows no outline, so the brand's line never peeks out under the
|
|
125
|
-
body's rounded corners. The grid's own editors keep it. */
|
|
126
|
-
:root:has([data-slot="vk-grid-editor"] [data-kit="picker"], [data-slot="vk-grid-editor"] [data-kit="compound-editor"], [data-slot="vk-grid-editor"] [data-kit="values-editor"], [data-slot="vk-grid-editor"] [data-kit="date-editor"]) [data-slot="vk-grid-cell"][data-editing] [data-slot="vk-grid-outline"] {
|
|
127
|
-
display: none;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
115
|
/* Picked rows: Tint, Attio's, keeps a picked row's own line, its tint alone saying it is picked (--vk-selection-edge). Tint
|
|
131
116
|
and line, the portal's, is the grid's own: the brand's line over the first picked row and under each. */
|
|
132
117
|
[data-grid-picked="tint"] [data-slot="vk-grid"] {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function lengthPx(el, prop) {
|
|
2
|
+
if (!el || typeof getComputedStyle === "undefined")
|
|
3
|
+
return 0;
|
|
4
|
+
const value = getComputedStyle(el).getPropertyValue(prop).trim();
|
|
5
|
+
if (!value)
|
|
6
|
+
return 0;
|
|
7
|
+
if (/^-?(\d+\.?\d*|\.\d+)(px)?$/.test(value))
|
|
8
|
+
return parseFloat(value);
|
|
9
|
+
const probe = el.ownerDocument.createElement("span");
|
|
10
|
+
probe.style.cssText = "position:absolute;visibility:hidden;pointer-events:none";
|
|
11
|
+
probe.style.setProperty("outline-offset", value);
|
|
12
|
+
el.appendChild(probe);
|
|
13
|
+
const px = parseFloat(getComputedStyle(probe).outlineOffset);
|
|
14
|
+
probe.remove();
|
|
15
|
+
return Number.isFinite(px) ? px : 0;
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
/** The screen a part is told it stands on, inside a `ScreenForms` twin while the page comes alive; null elsewhere. */
|
|
3
|
+
export declare const ScreenTold: import("react").Context<"phone" | "computer" | null>;
|
|
4
|
+
/** The rules that show the twin `query` picks: the computer's where it matches, the phone's elsewhere. ViewKit's own line's are
|
|
5
|
+
* in the toolbar's stylesheet too, for a page whose policy refuses an inline style. */
|
|
6
|
+
export declare function screenFormsCss(query: string): string;
|
|
7
|
+
/** What it holds, drawn for both screens until the page comes alive (above). `off`: once, as it is: the form is told already. */
|
|
8
|
+
export declare function ScreenForms({ children, off }: {
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
off?: boolean;
|
|
11
|
+
}): ReactNode;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useState, useSyncExternalStore } from "react";
|
|
4
|
+
import { PhoneLine } from "./phone-line.js";
|
|
5
|
+
export const ScreenTold = createContext(null);
|
|
6
|
+
const BOX = { display: "contents" };
|
|
7
|
+
const never = () => () => { };
|
|
8
|
+
const useAlive = () => useSyncExternalStore(never, () => true, () => false);
|
|
9
|
+
const canAsk = () => typeof window !== "undefined" && typeof window.matchMedia === "function";
|
|
10
|
+
export function screenFormsCss(query) {
|
|
11
|
+
const line = query.replace(/</g, "");
|
|
12
|
+
const at = `[data-vk-twin-line="${line.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"]`;
|
|
13
|
+
return (`[data-vk-screen-forms]{display:contents}` +
|
|
14
|
+
`[data-vk-twin="computer"]${at}{display:none}` +
|
|
15
|
+
`@media ${line}{[data-vk-twin="computer"]${at}{display:contents}[data-vk-twin="phone"]${at}{display:none}}`);
|
|
16
|
+
}
|
|
17
|
+
export function ScreenForms({ children, off = false }) {
|
|
18
|
+
const told = useContext(ScreenTold), line = useContext(PhoneLine), alive = useAlive();
|
|
19
|
+
const [twinned] = useState(() => !alive && !told && !off);
|
|
20
|
+
const [kept] = useState(() => (!alive && canAsk() ? (window.matchMedia(line).matches ? "computer" : "phone") : null));
|
|
21
|
+
if (!twinned)
|
|
22
|
+
return children;
|
|
23
|
+
const twin = (form) => {
|
|
24
|
+
if (alive) {
|
|
25
|
+
return form === (kept ?? "computer") ? (_jsx("div", { "data-vk-screen-forms": "", style: BOX, children: _jsx(ScreenTold.Provider, { value: null, children: children }) })) : null;
|
|
26
|
+
}
|
|
27
|
+
const marks = { "data-vk-screen-forms": "", "data-vk-twin": form, "data-vk-twin-line": line };
|
|
28
|
+
return kept && form !== kept ? (_jsx("div", { ...marks, dangerouslySetInnerHTML: { __html: "" }, suppressHydrationWarning: true })) : (_jsx("div", { ...marks, children: _jsx(ScreenTold.Provider, { value: form, children: children }) }));
|
|
29
|
+
};
|
|
30
|
+
return (_jsxs(_Fragment, { children: [alive ? null : _jsx("style", { children: screenFormsCss(line) }), twin("computer"), twin("phone")] }));
|
|
31
|
+
}
|
package/views/dist/list/list.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
+
import { ScreenForms } from "../internal/screen-forms.js";
|
|
4
5
|
import { ListBulkBar } from "./bulk-bar.js";
|
|
5
6
|
import { ListGrid } from "./grid.js";
|
|
6
7
|
import { ListRoot } from "./root.js";
|
|
@@ -14,5 +15,5 @@ export function List({ id, fields, rows, source, pageSize, save, columns, views,
|
|
|
14
15
|
const [box, setBox] = useState(null);
|
|
15
16
|
const inPane = (customizeIn ?? toolbar?.customizeIn) === "pane";
|
|
16
17
|
const gridOf = (_jsx(ListGrid, { ...grid, ...handed({ onOpenRow, rowHref, rowWritable }), menus: gridMenus, children: grid?.children ?? _jsx(ListBulkBar, { ...bulk }) }));
|
|
17
|
-
return (_jsx(ListRoot, { id: id, fields: fields, ...(source ? { source, pageSize } : { rows }), quickFilters: quickFilters, save: save, columns: columns, views: views, defaults: defaults, sortFilter: sortFilter, bar: bar, can: can, link: link, children: _jsxs("div", { "data-slot": "vk-list", className: className, children: [_jsx(ListToolbar, { ...toolbar, ...handed({ toolbarParts, onAdd, addItems, quickFilters, customizeIn }), ...(inPane && { paneBox: box }), menus: toolbarMenus }), inPane ? (_jsx("div", { ref: setBox, "data-slot": "vk-list-box", className: "relative isolate flex min-h-0 flex-1 flex-col", children: gridOf })) : (gridOf)] }) }));
|
|
18
|
+
return (_jsx(ListRoot, { id: id, fields: fields, ...(source ? { source, pageSize } : { rows }), quickFilters: quickFilters, save: save, columns: columns, views: views, defaults: defaults, sortFilter: sortFilter, bar: bar, can: can, link: link, children: _jsx(ScreenForms, { children: _jsxs("div", { "data-slot": "vk-list", className: className, children: [_jsx(ListToolbar, { ...toolbar, ...handed({ toolbarParts, onAdd, addItems, quickFilters, customizeIn }), ...(inPane && { paneBox: box }), menus: toolbarMenus }), inPane ? (_jsx("div", { ref: setBox, "data-slot": "vk-list-box", className: "relative isolate flex min-h-0 flex-1 flex-col", children: gridOf })) : (gridOf)] }) }) }));
|
|
18
19
|
}
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
1
2
|
import type { ToolbarPart } from "../panels/react/toolbar/Toolbar.js";
|
|
2
3
|
import type { ToolbarPartPlace, ToolbarParts, ToolbarPartsContext } from "../panels/react/toolbar/ReadyToolbar.js";
|
|
4
|
+
/** A part as the list's toolbar builds it: one made of halves the app may place apart carries each half's node by its key, in
|
|
5
|
+
* their order (the bar's `save`: `{ clear, save }`). */
|
|
6
|
+
export type ListPart = ToolbarPart & {
|
|
7
|
+
apart?: Readonly<Record<string, ReactNode>>;
|
|
8
|
+
};
|
|
3
9
|
/** Each part's place, in the order the form draws them: the row's start and end, then the bar's (a kit phone's one line). */
|
|
4
|
-
export declare function placesOf(parts: readonly
|
|
10
|
+
export declare function placesOf(parts: readonly ListPart[], ctx: ToolbarPartsContext): ToolbarPartPlace[];
|
|
5
11
|
/** The form's parts as the app's `toolbarParts` places them. */
|
|
6
|
-
export declare function applyParts(parts: readonly
|
|
12
|
+
export declare function applyParts(parts: readonly ListPart[], place: ToolbarParts, ctx: ToolbarPartsContext): readonly ToolbarPart[];
|
package/views/dist/list/parts.js
CHANGED
|
@@ -3,21 +3,21 @@ const kitPhone = (ctx) => ctx.arrangement === "kit" && ctx.phone;
|
|
|
3
3
|
const lineOf = (part) => ((part.line ?? 1) === 2 ? "bar" : "row");
|
|
4
4
|
export function placesOf(parts, ctx) {
|
|
5
5
|
const byKey = new Map(parts.map((part) => [part.key, part]));
|
|
6
|
-
const
|
|
7
|
-
key
|
|
6
|
+
const placeOne = (part, line) => Object.keys(part.apart ?? { [part.key]: null }).map((key) => ({
|
|
7
|
+
key,
|
|
8
8
|
line,
|
|
9
9
|
side: part.side ?? "start",
|
|
10
10
|
words: part.words ?? "both",
|
|
11
|
-
});
|
|
11
|
+
}));
|
|
12
12
|
if (kitPhone(ctx)) {
|
|
13
13
|
const [line] = arrangeToolbar(parts, "phone", { fold: true });
|
|
14
14
|
const slots = line ? [...line.start, ...line.end] : [];
|
|
15
15
|
return slots.flatMap((slot) => {
|
|
16
16
|
const part = byKey.get(slot.key);
|
|
17
|
-
return part ?
|
|
17
|
+
return part ? placeOne(part, part.key === "new" && part.foot !== false ? "foot" : "row") : [];
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
const drawn = (line, side) => parts.filter((part) => lineOf(part) === line && (part.side ?? "start") === side).
|
|
20
|
+
const drawn = (line, side) => parts.filter((part) => lineOf(part) === line && (part.side ?? "start") === side).flatMap((part) => placeOne(part, line));
|
|
21
21
|
return [...drawn("row", "start"), ...drawn("row", "end"), ...drawn("bar", "start"), ...drawn("bar", "end")];
|
|
22
22
|
}
|
|
23
23
|
const samePlaces = (a, b) => a.length === b.length &&
|
|
@@ -34,10 +34,17 @@ export function applyParts(parts, place, ctx) {
|
|
|
34
34
|
const back = place(given, ctx);
|
|
35
35
|
if (samePlaces(back, given))
|
|
36
36
|
return parts;
|
|
37
|
-
const byKey = new Map(
|
|
37
|
+
const byKey = new Map();
|
|
38
|
+
for (const part of parts) {
|
|
39
|
+
if (!part.apart)
|
|
40
|
+
byKey.set(part.key, part);
|
|
41
|
+
else
|
|
42
|
+
for (const [key, node] of Object.entries(part.apart))
|
|
43
|
+
byKey.set(key, { ...withoutHalves(part), key, node });
|
|
44
|
+
}
|
|
38
45
|
const seen = new Set();
|
|
39
46
|
const one = kitPhone(ctx);
|
|
40
|
-
|
|
47
|
+
const drawn = back.flatMap((at) => {
|
|
41
48
|
if (seen.has(at.key))
|
|
42
49
|
return [];
|
|
43
50
|
seen.add(at.key);
|
|
@@ -56,6 +63,8 @@ export function applyParts(parts, place, ctx) {
|
|
|
56
63
|
next.words = at.words;
|
|
57
64
|
if (at.words === "both" && own === "icon" && !part.shed)
|
|
58
65
|
next.shed = true;
|
|
66
|
+
if (at.words === "word")
|
|
67
|
+
delete next.shed;
|
|
59
68
|
if (one && part.key === "new") {
|
|
60
69
|
if (at.line === "foot")
|
|
61
70
|
delete next.foot;
|
|
@@ -64,4 +73,19 @@ export function applyParts(parts, place, ctx) {
|
|
|
64
73
|
}
|
|
65
74
|
return [next];
|
|
66
75
|
});
|
|
76
|
+
return parts.reduce((list, part) => (part.apart ? rejoined(list, part) : list), drawn);
|
|
77
|
+
}
|
|
78
|
+
const withoutHalves = ({ apart: _apart, ...part }) => part;
|
|
79
|
+
function rejoined(drawn, whole) {
|
|
80
|
+
const halves = Object.keys(whole.apart ?? {});
|
|
81
|
+
const at = drawn.findIndex((part) => part.key === halves[0]);
|
|
82
|
+
if (at < 0)
|
|
83
|
+
return drawn;
|
|
84
|
+
const run = drawn.slice(at, at + halves.length);
|
|
85
|
+
const together = run.length === halves.length &&
|
|
86
|
+
run.every((part, i) => part.key === halves[i] && (part.line ?? 1) === (run[0].line ?? 1) && (part.side ?? "start") === (run[0].side ?? "start"));
|
|
87
|
+
if (!together)
|
|
88
|
+
return drawn;
|
|
89
|
+
const { key: _key, node: _node, ...first } = run[0];
|
|
90
|
+
return [...drawn.slice(0, at), { ...withoutHalves(whole), ...first, key: whole.key, node: whole.node }, ...drawn.slice(at + halves.length)];
|
|
67
91
|
}
|
|
@@ -28,13 +28,15 @@ import { ToolbarSort } from "../panels/react/toolbar/ToolbarSort.js";
|
|
|
28
28
|
import { ToolbarSortPill } from "../panels/react/toolbar/ToolbarSortPill.js";
|
|
29
29
|
import { ToolbarAdvancedFilters } from "../panels/react/toolbar/ToolbarAdvancedFilters.js";
|
|
30
30
|
import { ToolbarViews } from "../panels/react/toolbar/ToolbarViews.js";
|
|
31
|
+
import { MoreViews } from "../panels/react/views-row/more-views.js";
|
|
32
|
+
import { ScreenForms } from "../internal/screen-forms.js";
|
|
31
33
|
import { applyParts } from "./parts.js";
|
|
32
34
|
import { useList, useListPanel, useListStore } from "./root-base.js";
|
|
33
35
|
import { useListViewsAxis } from "./views-axis.js";
|
|
34
36
|
import { EMPTY_LAYER, layerHolds } from "./layer.js";
|
|
35
37
|
export function ListToolbar(props) {
|
|
36
38
|
const { sortEditor: sort, filterEditor: filter, groupEditor: group } = props.menus ?? {};
|
|
37
|
-
return (_jsx(PaneBox.Provider, { value: props.paneBox ?? null, children: _jsx(EditorMenus.Provider, { value: { ...(sort && { sort }), ...(filter && { filter }), ...(group && { group }) }, children: _jsx(ToolbarOfList, { ...props }) }) }));
|
|
39
|
+
return (_jsx(PaneBox.Provider, { value: props.paneBox ?? null, children: _jsx(EditorMenus.Provider, { value: { ...(sort && { sort }), ...(filter && { filter }), ...(group && { group }) }, children: _jsx(MoreViews.Provider, { value: props.moreViews ?? null, children: _jsx(ScreenForms, { off: props.phone !== undefined, children: _jsx(ToolbarOfList, { ...props }) }) }) }) }));
|
|
38
40
|
}
|
|
39
41
|
function ToolbarOfList(props) {
|
|
40
42
|
const { views: viewsHanded, viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, overflow, } = props;
|
|
@@ -182,6 +184,8 @@ function ToolbarOfList(props) {
|
|
|
182
184
|
useLayoutEffect(() => store.patch({ panels: { barShown: barPublished, footHere: footPublished } }), [store, barPublished, footPublished]);
|
|
183
185
|
if (kit) {
|
|
184
186
|
const clearable = !view && (layered || settingsCleared(input, "options", { phone }) !== null);
|
|
187
|
+
const saveOf = (only) => (_jsx(ToolbarSave, { view: view, layered: layered, onClear: clearable ? resetAll : undefined, ...(only && { only }) }));
|
|
188
|
+
const saveParts = { node: saveOf(), apart: { clear: saveOf("clear"), save: saveOf("save") } };
|
|
185
189
|
const tabs = !phone && viewAxes?.length === 1 ? Math.max(0, viewAxes[0].options.length - 1) : 0;
|
|
186
190
|
const Sort = icons.sort;
|
|
187
191
|
const Filter = icons.filter;
|
|
@@ -277,7 +281,7 @@ function ToolbarOfList(props) {
|
|
|
277
281
|
key: "save",
|
|
278
282
|
line: 2,
|
|
279
283
|
side: "end",
|
|
280
|
-
|
|
284
|
+
...saveParts,
|
|
281
285
|
},
|
|
282
286
|
]
|
|
283
287
|
: []),
|
|
@@ -334,7 +338,7 @@ function ToolbarOfList(props) {
|
|
|
334
338
|
key: "save",
|
|
335
339
|
line: 2,
|
|
336
340
|
side: "end",
|
|
337
|
-
|
|
341
|
+
...saveParts,
|
|
338
342
|
},
|
|
339
343
|
]
|
|
340
344
|
: [];
|
|
@@ -6,6 +6,7 @@ export { lookAttrs, lookPicks, lookWorn, lookWornOf, type Look, type LookDevice,
|
|
|
6
6
|
export { LOOKS } from "./pieces.js";
|
|
7
7
|
export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, type GridLookOptionId, type GridLookProps, type GridLookWorn, } from "../grid/looks.js";
|
|
8
8
|
export { BUTTON_LOOKS, type ButtonLookOptionId } from "../controls/button/looks.js";
|
|
9
|
+
export { buttonOwnAttrs, buttonOwnOptions, type ButtonOwnLook } from "../controls/button/own-look.js";
|
|
9
10
|
export { SPINNER_LOOKS, type SpinnerLookOptionId } from "../controls/spinner/looks.js";
|
|
10
11
|
export { KBD_LOOKS, type KbdLookOptionId } from "../controls/kbd/looks.js";
|
|
11
12
|
export { TOOLTIP_LOOKS, type TooltipLookOptionId } from "../controls/tooltip/looks.js";
|
|
@@ -2,6 +2,7 @@ export { lookAttrs, lookPicks, lookWorn, lookWornOf, } from "./looks.js";
|
|
|
2
2
|
export { LOOKS } from "./pieces.js";
|
|
3
3
|
export { GRID_LOOKS, GRID_LOOK_READ, gridLookProps, gridLookWorn, gridLookWornOf, } from "../grid/looks.js";
|
|
4
4
|
export { BUTTON_LOOKS } from "../controls/button/looks.js";
|
|
5
|
+
export { buttonOwnAttrs, buttonOwnOptions } from "../controls/button/own-look.js";
|
|
5
6
|
export { SPINNER_LOOKS } from "../controls/spinner/looks.js";
|
|
6
7
|
export { KBD_LOOKS } from "../controls/kbd/looks.js";
|
|
7
8
|
export { TOOLTIP_LOOKS } from "../controls/tooltip/looks.js";
|
|
@@ -21,7 +21,9 @@ export declare function keepPanelOpenForPortals(event: {
|
|
|
21
21
|
}): void;
|
|
22
22
|
/**
|
|
23
23
|
* What the Customize popover adds on top of the app's menu popover, which is the panel itself: the width, the
|
|
24
|
-
* widen-for-a-calendar rule, the z-index that sits under an entity overlay, and its slide-from-the-right motion
|
|
24
|
+
* widen-for-a-calendar rule, the z-index that sits under an entity overlay, and its slide-from-the-right motion, as long as a popup's
|
|
25
|
+
* motion says (`--vk-popup-open-duration`, `--vk-popup-close-duration`), else `--vk-duration`. Its width
|
|
26
|
+
* is the app's `--vk-panel-w` where it declares one (VK-992), else 240, 248 on a calendar's page.
|
|
25
27
|
*/
|
|
26
28
|
export declare function viewOptionsPopoverClassName(activePanel: ActivePanel, widthClassName?: string): string;
|
|
27
29
|
/** Which page the panel is on, and the active-options count and clear it starts from. */
|
|
@@ -17,9 +17,9 @@ export function keepPanelOpenForPortals(event) {
|
|
|
17
17
|
if (source === document.body || source === document.documentElement)
|
|
18
18
|
event.preventDefault();
|
|
19
19
|
}
|
|
20
|
-
export function viewOptionsPopoverClassName(activePanel, widthClassName = "w-60") {
|
|
20
|
+
export function viewOptionsPopoverClassName(activePanel, widthClassName = "w-(--vk-panel-w,calc(var(--spacing)*60))") {
|
|
21
21
|
const isWidePanel = activePanel?.type === "dateRange" || activePanel?.type === "timeScope";
|
|
22
|
-
return cx("z-90", isWidePanel ? "w-62" : widthClassName, "data-[state=open]:slide-in-from-right-3 data-[state=closed]:slide-out-to-right-3", "data-[state=open]:zoom-in-100 data-[state=closed]:zoom-out-100", "duration-(--vk-duration,150ms)");
|
|
22
|
+
return cx("z-90", isWidePanel ? "w-(--vk-panel-w,calc(var(--spacing)*62))" : widthClassName, "data-[state=open]:slide-in-from-right-3 data-[state=closed]:slide-out-to-right-3", "data-[state=open]:zoom-in-100 data-[state=closed]:zoom-out-100", "duration-(--vk-popup-open-duration,var(--vk-duration,150ms))", "data-ending-style:duration-(--vk-popup-close-duration,var(--vk-duration,150ms)) data-[state=closed]:duration-(--vk-popup-close-duration,var(--vk-duration,150ms))");
|
|
23
23
|
}
|
|
24
24
|
export function useViewActivePanel(args) {
|
|
25
25
|
const [activePanel, setActivePanel] = useState(null);
|
|
@@ -8,7 +8,7 @@ import type { CollectionViewsInput, ViewsLayout } from "../../views-row/model.js
|
|
|
8
8
|
import type { PanelFieldEditor } from "../field-editor.js";
|
|
9
9
|
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
10
10
|
import type { ToolbarPanelPlace } from "./context.js";
|
|
11
|
-
import type { ToolbarMore, ToolbarOverflow, ToolbarPartButton } from "./Toolbar.js";
|
|
11
|
+
import type { ToolbarMore, ToolbarMoreViews, ToolbarOverflow, ToolbarPartButton } from "./Toolbar.js";
|
|
12
12
|
/** The toolbar's menus as data (VK-741): each handed its default items, each item keyed, and handing back the items it shows.
|
|
13
13
|
* `view`, a view's menu, handed the view too: the rows an option hands (`menu`, Edit view… among them) and the menu a views
|
|
14
14
|
* list draws from an axis's verbs. `add`, New's items: `addItems`, or, with `onAdd` alone, one row keyed `new` that runs it;
|
|
@@ -29,7 +29,7 @@ export type ToolbarMenus = {
|
|
|
29
29
|
/** A part of the ready toolbar as the app places it (VK-967): its key (list.md, Default keys); the line it stands on: `row`,
|
|
30
30
|
* `bar` (the filter bar; in `row`, the line below the row) or `foot` (a kit phone list's foot, New's place: anywhere else, the
|
|
31
31
|
* row); on a kit phone the row and the bar are one line. Its side, and its words (`both`, as the look's words say; `icon`, its
|
|
32
|
-
* icon alone), meaningful for a part whose button has a word: `search`, `quick`, `sort`, `filter`, `filter-add`, `options`,
|
|
32
|
+
* icon alone; `word`, its word alone, VK-970), meaningful for a part whose button has a word: `search`, `quick`, `sort`, `filter`, `filter-add`, `options`,
|
|
33
33
|
* `new`. `node`: a part of the app's own, under a key of its own (a key the form holds keeps its own node).
|
|
34
34
|
* Its look (VK-984): `className`, put on every toolbar button the part draws (each handed its `part`, list.md's table), and
|
|
35
35
|
* `button`, your own button drawn for each of them in place of your `ToolbarButton`, handed the very props it would get, `ref`
|
|
@@ -39,7 +39,7 @@ export type ToolbarPartPlace = {
|
|
|
39
39
|
key: string;
|
|
40
40
|
line: "row" | "bar" | "foot";
|
|
41
41
|
side: "start" | "end";
|
|
42
|
-
words: "both" | "icon";
|
|
42
|
+
words: "both" | "icon" | "word";
|
|
43
43
|
node?: ReactNode;
|
|
44
44
|
className?: string;
|
|
45
45
|
button?: ToolbarPartButton;
|
|
@@ -142,6 +142,9 @@ export type ReadyToolbarProps<Row> = SettingsPanelsInput<Row> & {
|
|
|
142
142
|
/** ⋯ as the app draws it where the parts don't fit (VK-1031, `ToolbarOverflow`): its glyph, its class, or its whole button,
|
|
143
143
|
* handed the props your `ToolbarButton` would get. Absent, your `ToolbarButton` with `icons.more`. */
|
|
144
144
|
overflow?: ToolbarOverflow;
|
|
145
|
+
/** The views row's "+N" as the app draws it (VK-1068, `ToolbarMoreViews`): its class on ViewKit's own, or its whole button, handed
|
|
146
|
+
* the props your `ToolbarButton` would get. Absent, ViewKit's own. In your own frame "+N" is your `ToolbarButton` (`views-more`). */
|
|
147
|
+
moreViews?: ToolbarMoreViews;
|
|
145
148
|
className?: string;
|
|
146
149
|
};
|
|
147
150
|
export declare function ReadyToolbar<Row>({ settings, layer, onChange, onLayerChange, view, sortFilter, bar, ...rest }: ReadyToolbarProps<Row>): ReactNode;
|
|
@@ -34,7 +34,17 @@ export type ToolbarOverflow = {
|
|
|
34
34
|
className?: string;
|
|
35
35
|
button?: ToolbarPartButton;
|
|
36
36
|
};
|
|
37
|
-
|
|
37
|
+
/** The views row's "+N" as the app draws it (VK-1068), as ⋯ is handed: `className`, put on ViewKit's own "+N"; `button`, your own
|
|
38
|
+
* button drawn in its place, handed the props your `ToolbarButton` would get (`part: "views-more"`, "+N" as its `children`,
|
|
39
|
+
* `popup: "dialog"`, `open`, `ref` included: put `ref` on your button, so the folded views' list hangs at it). Absent, ViewKit's. */
|
|
40
|
+
export type ToolbarMoreViews = {
|
|
41
|
+
className?: string;
|
|
42
|
+
button?: ToolbarPartButton;
|
|
43
|
+
};
|
|
44
|
+
/** Server-rendered with no `phone` handed, it draws the phone's form and the computer's, CSS showing the screen's until the
|
|
45
|
+
* page comes alive (VK-1038, `ScreenForms`). */
|
|
46
|
+
export declare function Toolbar(props: Parameters<typeof ToolbarOnScreen>[0]): ReactNode;
|
|
47
|
+
declare function ToolbarOnScreen({ parts, phone, narrow, narrowBelow, fold, more, overflow, className, }: {
|
|
38
48
|
parts: readonly ToolbarPart[];
|
|
39
49
|
/** The phone's one row; absent, the provider's answer (`desktopQuery`). */
|
|
40
50
|
phone?: boolean;
|
|
@@ -57,3 +67,4 @@ export declare function Toolbar({ parts, phone, narrow, narrowBelow, fold, more,
|
|
|
57
67
|
/** A line between what belongs together and what doesn't: placed with `role: "separator"`, drawn in the fold
|
|
58
68
|
* arrangement only while a part of its side stands drawn on each side of it, and never on a phone's line. */
|
|
59
69
|
export declare function ToolbarSeparator(): ReactNode;
|
|
70
|
+
export {};
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { Fragment, useContext, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
|
+
import { ScreenForms } from "../../../internal/screen-forms.js";
|
|
5
6
|
import { useViews } from "../../../provider/context.js";
|
|
6
7
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
7
8
|
import { TOOLBAR_NARROW_BELOW, arrangeToolbar, foldState, foldSteps, toolbarForm, } from "../../toolbar/model.js";
|
|
@@ -11,7 +12,10 @@ import { ToolbarButton } from "./ToolbarButton.js";
|
|
|
11
12
|
import { useBoxNarrow } from "./use-box-narrow.js";
|
|
12
13
|
import { useGiveWay } from "./use-give-way.js";
|
|
13
14
|
const CLUSTER_FADE = "linear-gradient(to right, transparent 0, var(--vk-ground) 1.25rem, var(--vk-ground) 100%)";
|
|
14
|
-
export function Toolbar(
|
|
15
|
+
export function Toolbar(props) {
|
|
16
|
+
return (_jsx(ScreenForms, { off: props.phone !== undefined, children: _jsx(ToolbarOnScreen, { ...props }) }));
|
|
17
|
+
}
|
|
18
|
+
function ToolbarOnScreen({ parts, phone, narrow, narrowBelow = TOOLBAR_NARROW_BELOW, fold = false, more, overflow, className, }) {
|
|
15
19
|
const box = useRef(null);
|
|
16
20
|
const desktop = useDesktop();
|
|
17
21
|
const measured = useBoxNarrow(box, narrowBelow);
|
|
@@ -82,5 +82,5 @@ export function AdvancedFilterPill({ filterTree, at, count, aside = false, host:
|
|
|
82
82
|
return (_jsxs("span", { "data-slot": "vk-toolbar-advanced-filter", "data-open": (slot.fold || foldedAt) && panel.open ? "" : undefined, hidden: foldedAt ? true : undefined, className: "relative inline-flex shrink-0 items-center", children: [aside ? (_jsx(Tooltip, { content: messages({ key: "views.panels.advanced-filter-set-aside" }), side: "bottom", children: _jsx("span", { className: "inline-flex min-w-0", children: button }) })) : (button), Host ? (_jsx(Host, { open: panel.open, onOpenChange: panel.onOpenChange, title: name, children: content })) : (_jsx(Popover, { open: panel.open, onOpenChange: (next, details) => {
|
|
83
83
|
if (!next)
|
|
84
84
|
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
85
|
-
}, anchor: anchor, ...hangs, chrome: "
|
|
85
|
+
}, anchor: anchor, ...hangs, chrome: "menu", className: "w-(--vk-panel-w,fit-content) max-w-[calc(100vw-2rem)]", panelData: { "data-slot": "vk-toolbar-advanced-filter-panel" }, children: content }))] }));
|
|
86
86
|
}
|