viewkitjs 0.36.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +49 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +14 -8
- package/views/dist/contract.js +14 -1
- package/views/dist/controls/button/own-look-moved.d.ts +11 -0
- package/views/dist/controls/button/own-look-moved.js +3 -0
- package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
- package/views/dist/controls/date-editor/date-behaviour.js +187 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
- package/views/dist/controls/date-editor/date-editor.js +29 -166
- package/views/dist/controls/field/field.d.ts +3 -2
- package/views/dist/controls/field/field.js +7 -2
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +5 -4
- package/views/dist/controls/field.css +4 -0
- package/views/dist/controls/filter-editor/filter-editor.js +2 -2
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +1 -1
- package/views/dist/controls/index.d.ts +3 -1
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +9 -0
- package/views/dist/controls/internal/phone.d.ts +1 -1
- package/views/dist/controls/internal/phone.js +3 -2
- package/views/dist/controls/list/tokens.d.ts +1 -1
- package/views/dist/controls/list/tokens.js +1 -1
- package/views/dist/controls/list.css +5 -2
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker.css +5 -3
- package/views/dist/controls/popover/looks.d.ts +1 -1
- package/views/dist/controls/popover/looks.js +5 -0
- package/views/dist/controls/popover/tokens.d.ts +13 -1
- package/views/dist/controls/popover/tokens.js +4 -1
- package/views/dist/controls/popover.css +59 -8
- package/views/dist/controls/select/select.js +1 -1
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/text-editor.css +6 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +7 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +1 -1
- package/views/dist/controls/tooltip/tokens.js +1 -1
- package/views/dist/controls/tooltip.css +5 -3
- package/views/dist/controls/values-editor.css +20 -5
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/field-row/FieldRow.js +12 -8
- package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
- package/views/dist/grid/chrome/GridCellEditors.js +3 -2
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -5
- package/views/dist/grid/chrome/GridCellOutline.js +3 -5
- package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridDateEditor.js +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
- package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNameEditor.js +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
- package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
- package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +6 -5
- package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
- package/views/dist/grid/chrome/GridTable.d.ts +2 -1
- package/views/dist/grid/chrome/GridTable.js +7 -2
- package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +2 -2
- package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
- package/views/dist/grid/chrome/grid-body-place.js +8 -4
- package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
- package/views/dist/grid/chrome/grid-edit-session.d.ts +4 -0
- package/views/dist/grid/chrome/grid-edit-session.js +10 -1
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +10 -0
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +4 -4
- package/views/dist/grid/chrome/grid-fitted-box.js +1 -3
- package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
- package/views/dist/grid/chrome/grid-hover.js +2 -3
- package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +2 -10
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +24 -1
- package/views/dist/grid/core/useGridEditing.d.ts +3 -0
- package/views/dist/grid/core/useGridEditing.js +2 -0
- package/views/dist/grid/grid.css +4 -19
- package/views/dist/internal/screen-forms.d.ts +11 -0
- package/views/dist/internal/screen-forms.js +31 -0
- package/views/dist/list/list.js +2 -1
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +7 -3
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +6 -3
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +3 -2
- package/views/dist/panels/react/views-row/FoldingViewRow.js +24 -7
- package/views/dist/panels/react/views-row/ViewPicker.js +1 -1
- package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
- package/views/dist/panels/react/views-row/more-views.js +3 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/toolbar/model.d.ts +2 -2
- package/views/dist/provider/components.d.ts +6 -6
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/styles.css +181 -80
- package/views/dist/styles.unlayered.css +181 -80
- package/views/docs/contract.md +68 -20
- package/views/docs/controls/list.md +2 -0
- package/views/docs/controls/menu.md +2 -0
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/popover.md +7 -0
- package/views/docs/controls/tooltip.md +2 -0
- package/views/docs/guides/atoms.md +11 -10
- package/views/docs/guides/the-grid.md +7 -5
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/reference/controls.md +11 -6
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/list.md +5 -6
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +5 -4
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +6 -6
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { createContext, useContext, useEffect, useRef, useSyncExternalStore, } from "react";
|
|
4
|
-
import { cx } from "../../internal/cx.js";
|
|
5
4
|
import { gridRowIdFromKey } from "../core/coordinates.js";
|
|
6
5
|
import { useDesktop } from "../../provider/desktop.js";
|
|
7
6
|
import { useViews } from "../../provider/context.js";
|
|
@@ -134,7 +133,7 @@ export function GridRowHoverActions({ views, rowKey, row, selected, actions, })
|
|
|
134
133
|
}
|
|
135
134
|
export function GridPickerCaret({ rowKey, colId, editing, onOpen, }) {
|
|
136
135
|
const hovered = useGridCellHovered(rowKey, colId);
|
|
137
|
-
if (!hovered
|
|
136
|
+
if (!hovered)
|
|
138
137
|
return null;
|
|
139
138
|
return _jsx(PickerCaretButton, { editing: editing, onOpen: onOpen });
|
|
140
139
|
}
|
|
@@ -154,6 +153,6 @@ function PickerCaretButton({ editing, onOpen }) {
|
|
|
154
153
|
frame: "absolute right-1 top-1/2 h-5 w-5 -translate-y-1/2",
|
|
155
154
|
variant: "ghost",
|
|
156
155
|
size: "icon",
|
|
157
|
-
children: _jsx(icons.caretDown, { className:
|
|
156
|
+
children: _jsx(icons.caretDown, { className: "h-3 w-3" }),
|
|
158
157
|
});
|
|
159
158
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { GridMenus } from "./grid-table-props.js";
|
|
2
2
|
import type { ReactNode } from "react";
|
|
3
|
+
import type { CloseReason } from "viewkitjs/fields";
|
|
3
4
|
import type { ViewsRowMenuItem } from "../../atoms/types.js";
|
|
4
5
|
import type { FieldMenus } from "../../fields/menus.js";
|
|
5
6
|
import type { ListSettingsConfig } from "../../model/column-capabilities.js";
|
|
@@ -71,6 +72,11 @@ export type GridRowProps<Row> = {
|
|
|
71
72
|
/** Told this row's key on a press anywhere on it, under `rowHighlight: "active"`; absent otherwise. */
|
|
72
73
|
onActivate?: (rowKey: string) => void;
|
|
73
74
|
editingColId: string | null;
|
|
75
|
+
/** THIS row's open editor has started to close (it accepted an answer and plays its exit): its cell stands as
|
|
76
|
+
* picked again, no longer `data-editing`. False on every row but the editing one. */
|
|
77
|
+
editClosing?: boolean;
|
|
78
|
+
/** Told when THIS row's open editor starts to close, with the reason it closed by (null where its panel names none). */
|
|
79
|
+
onEditorClosing?: (rowId: string, columnId: string, reason: CloseReason | null) => void;
|
|
74
80
|
/** columnId → optimistic pending value (undefined when this row has none). */
|
|
75
81
|
pendingByCol?: Record<string, unknown>;
|
|
76
82
|
/** columnId → `requested` for a pending value saved here but not yet accepted
|
|
@@ -118,8 +124,6 @@ export type GridRowProps<Row> = {
|
|
|
118
124
|
/** Tab out of an editor → next/prev cell in reading order (grid-owned so it
|
|
119
125
|
* matches Tab-while-focused; wraps rows). */
|
|
120
126
|
onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
|
|
121
|
-
/** Enter out of an editor → advance one row down. */
|
|
122
|
-
onEditorEnter: (rowId: string, columnId: string) => void;
|
|
123
127
|
/** Type-to-replace seed: the character that opened THIS row's editor, or null.
|
|
124
128
|
* Used as the editor's initial value in place of the cell's own. */
|
|
125
129
|
editSeed?: string | null;
|
|
@@ -5,7 +5,7 @@ export declare const GRID_ONE_LINE = "grid-rows-[auto] auto-rows-[0px]";
|
|
|
5
5
|
export declare const GRID_ROW_PAD = "px-(--vk-gutter,0px)";
|
|
6
6
|
export declare const GRID_CONTENT_PAD = "pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0px))] pr-(--vk-gutter,0px)";
|
|
7
7
|
/** A part that paints the ground at every scroll, because it always stands over something — the
|
|
8
|
-
*
|
|
8
|
+
* box a type-in grows into past its cell, the header's drag ghost. The page's ground, without
|
|
9
9
|
* re-declaring its states: every host the grid mounts in carries the page's own. */
|
|
10
10
|
export declare const GRID_GROUND = "bg-(color:--vk-ground)";
|
|
11
11
|
/** The ground, only while the table is scrolled sideways (`--vk-scrolled`, 0 or 1): a pinned part covers what passes
|
|
@@ -14,10 +14,6 @@ export declare const GRID_GROUND_WHILE_SCROLLED = "bg-[color-mix(in_oklab,_var(-
|
|
|
14
14
|
/** The keyboard's mark on a part that isn't a data cell (a column name, a footer cell, a bar's name): the cells'
|
|
15
15
|
* brand ring, inset, only for focus a key put there, so a click draws nothing new. */
|
|
16
16
|
export declare const GRID_CHROME_FOCUS = "outline-none focus-visible:shadow-[var(--vk-focus-ring,inset_0_0_0_2px_var(--vk-brand))]";
|
|
17
|
-
/** THE OPEN EDITOR'S LIFT: the shadow under the picked cell's ring while it is edited, and under the box a value wider
|
|
18
|
-
* than its cell grows into. One whole `box-shadow` value, the app's `--vk-editing-shadow` (`none` turns it off);
|
|
19
|
-
* undeclared, what `shadow-lg shadow-black/20 dark:shadow-black/50` drew. */
|
|
20
|
-
export declare const GRID_EDITING_SHADOW = "shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.2),0_4px_6px_-4px_rgb(0_0_0/0.2))] dark:shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.5),0_4px_6px_-4px_rgb(0_0_0/0.5))]";
|
|
21
17
|
/**
|
|
22
18
|
* A FROZEN header cell's OWN paint — the ground down to a 2px sliver at its
|
|
23
19
|
* foot, alpha-gated on `--vk-scrolled` (0/1, from the scroll area), like the
|
|
@@ -5,6 +5,5 @@ export const GRID_CONTENT_PAD = "pl-[calc(var(--vk-gutter,0px)+var(--vk-indent,0
|
|
|
5
5
|
export const GRID_GROUND = "bg-(color:--vk-ground)";
|
|
6
6
|
export const GRID_GROUND_WHILE_SCROLLED = "bg-[color-mix(in_oklab,_var(--vk-ground)_calc(var(--vk-scrolled,0)*100%),_transparent)]";
|
|
7
7
|
export const GRID_CHROME_FOCUS = "outline-none focus-visible:shadow-[var(--vk-focus-ring,inset_0_0_0_2px_var(--vk-brand))]";
|
|
8
|
-
export const GRID_EDITING_SHADOW = "shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.2),0_4px_6px_-4px_rgb(0_0_0/0.2))] dark:shadow-[var(--vk-editing-shadow,0_10px_15px_-3px_rgb(0_0_0/0.5),0_4px_6px_-4px_rgb(0_0_0/0.5))]";
|
|
9
8
|
export const GRID_HEADER_BG_FROZEN = "bg-[linear-gradient(to_bottom,color-mix(in_oklab,_var(--vk-ground)_calc(var(--vk-scrolled,0)*100%),_transparent)_calc(100%-2px),transparent_calc(100%-2px))]";
|
|
10
9
|
export const GRID_HEADER_BG_FROZEN_HOVER = "hover:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered)),linear-gradient(to_bottom,color-mix(in_oklab,_var(--vk-ground)_calc(var(--vk-scrolled,0)*100%),_transparent)_calc(100%-2px),transparent_calc(100%-2px))]";
|
|
@@ -68,6 +68,5 @@ export declare function useGridKeyboard<Row>({ rootRef, focusedCell, editingCell
|
|
|
68
68
|
editsState?: () => GridEditsState;
|
|
69
69
|
}): {
|
|
70
70
|
onEditorTab: (rowId: string, columnId: string, backwards: boolean) => void;
|
|
71
|
-
onEditorEnter: (rowId: string, columnId: string) => void;
|
|
72
71
|
enterGrid: (_which: "start" | "end", from: Element | null) => void;
|
|
73
72
|
};
|
|
@@ -35,9 +35,8 @@ function eventBelongsElsewhere(target, root) {
|
|
|
35
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
37
|
const { ports, messages, conventions } = useViews();
|
|
38
|
-
const navFromEditorRef = useRef({ tab: () => { }
|
|
38
|
+
const navFromEditorRef = useRef({ tab: () => { } });
|
|
39
39
|
const onEditorTab = useCallback((rowId, columnId, backwards) => navFromEditorRef.current.tab(rowId, columnId, backwards), []);
|
|
40
|
-
const onEditorEnter = useCallback((rowId, columnId) => navFromEditorRef.current.enter(rowId, columnId), []);
|
|
41
40
|
const rowMenuWatchRef = useRef(null);
|
|
42
41
|
useEffect(() => () => rowMenuWatchRef.current?.(), []);
|
|
43
42
|
useEffect(() => {
|
|
@@ -49,13 +48,6 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
49
48
|
focusCell(next.rowId, next.columnId);
|
|
50
49
|
revealCell(next, "auto");
|
|
51
50
|
},
|
|
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
51
|
};
|
|
60
52
|
}, [focusCell, revealCell, visibleColIds, visibleRowIds]);
|
|
61
53
|
const rowsWait = useContext(GridWaitContext);
|
|
@@ -494,5 +486,5 @@ export function useGridKeyboard({ rootRef, focusedCell, editingCell, editingEnab
|
|
|
494
486
|
visibleColumns,
|
|
495
487
|
visibleRowIds,
|
|
496
488
|
]);
|
|
497
|
-
return { onEditorTab,
|
|
489
|
+
return { onEditorTab, enterGrid };
|
|
498
490
|
}
|
|
@@ -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) => 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;
|
|
@@ -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,27 @@ 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) => {
|
|
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
|
+
}, []);
|
|
228
249
|
const spreadsheetModel = useMemo(() => ({
|
|
229
250
|
rows,
|
|
230
251
|
rowByKey: rowIndex,
|
|
@@ -329,6 +350,8 @@ export function useGridTableInteractionModel({ rootRef, props, rows, visibleRows
|
|
|
329
350
|
editSeed,
|
|
330
351
|
editWhole,
|
|
331
352
|
editByKey,
|
|
353
|
+
editClosing,
|
|
354
|
+
onEditorClosing,
|
|
332
355
|
focusCellSync,
|
|
333
356
|
startEditSync,
|
|
334
357
|
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,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
|
}
|
|
@@ -8,8 +8,9 @@ export function ToolbarButton({ size, ...props }) {
|
|
|
8
8
|
const slot = useToolbarSlot();
|
|
9
9
|
const iconOnly = slot.words === "icon" && props.icon != null;
|
|
10
10
|
const hasWords = props.word !== null || props.children != null;
|
|
11
|
-
const
|
|
11
|
+
const wordOnly = slot.words === "word" && hasWords && !props.foot;
|
|
12
|
+
const alone = !wordOnly && (slot.iconAlone || (iconOnly && hasWords));
|
|
12
13
|
const Button = slot.button ?? atoms.ToolbarButton;
|
|
13
14
|
const className = cx(slot.className, props.className) || undefined;
|
|
14
|
-
return (_jsx(Button, { ...props, ...(iconOnly && { word: null }), ...(alone && { iconAlone: true }), ...(className && { className }), size: size ?? slot.size }));
|
|
15
|
+
return (_jsx(Button, { ...props, ...(iconOnly && { word: null }), ...(wordOnly && { icon: null, children: props.children ?? props.word ?? props.label }), ...(alone && { iconAlone: true }), ...(className && { className }), size: size ?? slot.size }));
|
|
15
16
|
}
|