viewkitjs 0.35.0 → 0.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/MIGRATION.md +7 -0
- package/package.json +1 -1
- package/views/dist/atoms/types.d.ts +32 -4
- package/views/dist/contract.d.ts +32 -9
- package/views/dist/contract.js +35 -1
- package/views/dist/controls/avatar/avatar.d.ts +3 -1
- package/views/dist/controls/avatar/avatar.js +2 -2
- package/views/dist/controls/button/own-look-moved.d.ts +11 -0
- package/views/dist/controls/button/own-look-moved.js +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.js +2 -0
- package/views/dist/controls/compound-editor/name-parts.js +1 -1
- package/views/dist/controls/compound-editor/place-parts.js +1 -1
- package/views/dist/controls/compound-editor/range-parts.js +1 -1
- package/views/dist/controls/compound-editor/words.d.ts +3 -0
- package/views/dist/controls/compound-editor/words.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +10 -3
- package/views/dist/controls/customize/customize.js +147 -63
- package/views/dist/controls/customize/items.d.ts +49 -0
- package/views/dist/controls/customize/items.js +104 -0
- package/views/dist/controls/customize/map-customize-body.js +7 -4
- package/views/dist/controls/customize/words.d.ts +2 -0
- package/views/dist/controls/customize/words.js +1 -0
- package/views/dist/controls/date-editor/date-behaviour.d.ts +80 -0
- package/views/dist/controls/date-editor/date-behaviour.js +187 -0
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -2
- package/views/dist/controls/date-editor/date-editor.js +29 -166
- package/views/dist/controls/field/field.d.ts +3 -2
- package/views/dist/controls/field/field.js +7 -2
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +5 -4
- package/views/dist/controls/field.css +4 -0
- package/views/dist/controls/filter-editor/block.js +5 -2
- package/views/dist/controls/filter-editor/filter-editor.d.ts +14 -1
- package/views/dist/controls/filter-editor/filter-editor.js +21 -13
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
- package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
- package/views/dist/controls/filter-editor/map-rules.js +18 -13
- package/views/dist/controls/filter-editor/parts.d.ts +2 -0
- package/views/dist/controls/filter-editor/parts.js +13 -12
- package/views/dist/controls/filter-editor/rules.d.ts +4 -4
- package/views/dist/controls/filter-editor/rules.js +6 -3
- package/views/dist/controls/filter-editor/words.d.ts +2 -0
- package/views/dist/controls/filter-editor/words.js +1 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
- package/views/dist/controls/group-editor/group-editor.js +21 -15
- package/views/dist/controls/group-editor/map-group-body.js +1 -0
- package/views/dist/controls/index.d.ts +4 -2
- package/views/dist/controls/index.js +3 -1
- package/views/dist/controls/inline-input.css +9 -0
- package/views/dist/controls/internal/kit-words.d.ts +11 -0
- package/views/dist/controls/internal/kit-words.js +7 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
- package/views/dist/controls/internal/map-panel-controls.js +14 -1
- package/views/dist/controls/internal/menu-items.d.ts +9 -0
- package/views/dist/controls/internal/menu-items.js +97 -0
- package/views/dist/controls/internal/panel-controls.js +1 -1
- package/views/dist/controls/internal/phone.d.ts +1 -1
- package/views/dist/controls/internal/phone.js +3 -2
- package/views/dist/controls/list/tokens.d.ts +1 -1
- package/views/dist/controls/list/tokens.js +1 -1
- package/views/dist/controls/list.css +5 -2
- package/views/dist/controls/menu/menu.d.ts +1 -1
- package/views/dist/controls/menu/menu.js +1 -1
- package/views/dist/controls/menu-list/menu-list.js +3 -2
- package/views/dist/controls/menu.css +4 -4
- package/views/dist/controls/number-editor/map-number-body.js +2 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/number-editor/words.d.ts +3 -0
- package/views/dist/controls/number-editor/words.js +2 -0
- package/views/dist/controls/pane.css +1 -1
- package/views/dist/controls/picker/fields-frame.d.ts +5 -0
- package/views/dist/controls/picker/fields-frame.js +30 -0
- package/views/dist/controls/picker/map-fields-body.js +3 -26
- package/views/dist/controls/picker/map-picker.d.ts +2 -1
- package/views/dist/controls/picker/map-picker.js +4 -2
- package/views/dist/controls/picker/picker.js +9 -2
- package/views/dist/controls/picker/rows.d.ts +3 -1
- package/views/dist/controls/picker.css +7 -3
- package/views/dist/controls/popover/looks.d.ts +1 -1
- package/views/dist/controls/popover/looks.js +5 -0
- package/views/dist/controls/popover/tokens.d.ts +13 -1
- package/views/dist/controls/popover/tokens.js +4 -1
- package/views/dist/controls/popover.css +59 -8
- package/views/dist/controls/select/map-select.d.ts +1 -1
- package/views/dist/controls/select/map-select.js +4 -1
- package/views/dist/controls/select/select.d.ts +2 -0
- package/views/dist/controls/select/select.js +4 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
- package/views/dist/controls/sheet/bottom-sheet.js +3 -3
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +3 -1
- package/views/dist/controls/sort-editor/sort-editor.js +6 -4
- package/views/dist/controls/sort-editor.css +4 -2
- package/views/dist/controls/tag/tag.js +4 -2
- package/views/dist/controls/text-editor/map-text-body.js +4 -1
- package/views/dist/controls/text-editor/text-editor.js +2 -2
- package/views/dist/controls/text-editor/words.d.ts +3 -0
- package/views/dist/controls/text-editor/words.js +1 -1
- package/views/dist/controls/text-editor.css +6 -0
- package/views/dist/controls/toolbar/toolbar.d.ts +12 -4
- package/views/dist/controls/toolbar/toolbar.js +7 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +1 -1
- package/views/dist/controls/toolbar.css +5 -0
- package/views/dist/controls/tooltip/tokens.d.ts +1 -1
- package/views/dist/controls/tooltip/tokens.js +1 -1
- package/views/dist/controls/tooltip.css +5 -3
- package/views/dist/controls/values-editor.css +20 -5
- package/views/dist/controls/views-list/map-views-list-body.js +9 -1
- package/views/dist/controls/views-list/rules.d.ts +1 -0
- package/views/dist/controls/views-list/rules.js +2 -2
- package/views/dist/controls/views-list/view-menu.js +2 -2
- package/views/dist/controls/views-list/words.d.ts +4 -0
- package/views/dist/controls/views-list/words.js +2 -1
- package/views/dist/display/entity-chip.d.ts +7 -1
- package/views/dist/display/entity-chip.js +2 -1
- package/views/dist/display/option-badges.d.ts +3 -2
- package/views/dist/display/option-badges.js +2 -2
- package/views/dist/field-row/FieldRow.js +12 -8
- package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
- package/views/dist/grid/chrome/GridAddColumn.js +5 -4
- package/views/dist/grid/chrome/GridCellEditors.d.ts +4 -1
- package/views/dist/grid/chrome/GridCellEditors.js +3 -2
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -5
- package/views/dist/grid/chrome/GridCellOutline.js +3 -5
- package/views/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/views/dist/grid/chrome/GridDateEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridDateEditor.js +1 -1
- package/views/dist/grid/chrome/GridHeader.js +3 -1
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridLongTextEditor.js +8 -5
- package/views/dist/grid/chrome/GridNameEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNameEditor.js +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridNumberEditor.js +2 -2
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridPlaceEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +2 -2
- package/views/dist/grid/chrome/GridRangeEditor.js +1 -1
- package/views/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +7 -1
- package/views/dist/grid/chrome/GridRowCells.js +6 -5
- package/views/dist/grid/chrome/GridSelectEditor.js +1 -1
- package/views/dist/grid/chrome/GridTable.d.ts +2 -1
- package/views/dist/grid/chrome/GridTable.js +7 -2
- package/views/dist/grid/chrome/GridTableSurface.js +2 -1
- package/views/dist/grid/chrome/GridTextEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridTextEditor.js +2 -2
- package/views/dist/grid/chrome/GridValueListEditor.d.ts +1 -1
- package/views/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +7 -2
- package/views/dist/grid/chrome/grid-body-place.js +8 -4
- package/views/dist/grid/chrome/grid-cell-classes.js +2 -2
- package/views/dist/grid/chrome/grid-edit-session.d.ts +4 -0
- package/views/dist/grid/chrome/grid-edit-session.js +10 -1
- package/views/dist/grid/chrome/grid-editor-layer.d.ts +10 -0
- package/views/dist/grid/chrome/grid-editor-layer.js +1 -0
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +9 -6
- package/views/dist/grid/chrome/grid-fitted-box.js +15 -7
- package/views/dist/grid/chrome/grid-hover.d.ts +3 -3
- package/views/dist/grid/chrome/grid-hover.js +2 -3
- package/views/dist/grid/chrome/grid-row-props.d.ts +6 -2
- package/views/dist/grid/chrome/grid-styles.d.ts +1 -5
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +6 -2
- package/views/dist/grid/chrome/useGridKeyboard.d.ts +0 -1
- package/views/dist/grid/chrome/useGridKeyboard.js +2 -10
- package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
- package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
- package/views/dist/grid/chrome/useGridTableInteractionModel.d.ts +3 -1
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +24 -1
- package/views/dist/grid/core/useGridEditing.d.ts +3 -0
- package/views/dist/grid/core/useGridEditing.js +2 -0
- package/views/dist/grid/grid-format-props.d.ts +1 -1
- package/views/dist/grid/grid-format-props.js +18 -5
- package/views/dist/grid/grid.css +9 -20
- package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/views/dist/grid/useGridTableSettings.d.ts +1 -1
- package/views/dist/internal/screen-forms.d.ts +11 -0
- package/views/dist/internal/screen-forms.js +31 -0
- package/views/dist/list/list.js +4 -3
- package/views/dist/list/menu.d.ts +5 -4
- package/views/dist/list/parts.d.ts +8 -2
- package/views/dist/list/parts.js +31 -7
- package/views/dist/list/toolbar.js +11 -5
- package/views/dist/looks/index.d.ts +1 -0
- package/views/dist/looks/index.js +1 -0
- package/views/dist/panels/customize-body.d.ts +1 -1
- package/views/dist/panels/customize-body.js +8 -1
- package/views/dist/panels/model.d.ts +5 -0
- package/views/dist/panels/react/customize-body.js +11 -2
- package/views/dist/panels/react/customize.d.ts +3 -0
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
- package/views/dist/panels/react/filter/filter-body.js +3 -1
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-part-body.js +2 -2
- package/views/dist/panels/react/popover.d.ts +3 -1
- package/views/dist/panels/react/popover.js +2 -2
- package/views/dist/panels/react/sort/SortEditor.js +3 -1
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +15 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +12 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +5 -1
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarButton.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +1 -3
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +28 -20
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +1 -1
- package/views/dist/panels/react/toolbar/context.d.ts +3 -2
- package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
- package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +26 -11
- package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
- package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +7 -10
- package/views/dist/panels/react/views-row/more-views.d.ts +2 -0
- package/views/dist/panels/react/views-row/more-views.js +3 -0
- package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
- package/views/dist/panels/react/views-row/new-view.js +21 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/toolbar/model.d.ts +2 -2
- package/views/dist/provider/components.d.ts +88 -8
- package/views/dist/provider/desktop.d.ts +2 -1
- package/views/dist/provider/desktop.js +5 -2
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +198 -84
- package/views/dist/styles.unlayered.css +198 -84
- package/views/docs/contract.md +87 -32
- package/views/docs/controls/list.md +2 -0
- package/views/docs/controls/menu.md +2 -0
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/popover.md +7 -0
- package/views/docs/controls/tooltip.md +2 -0
- package/views/docs/guides/atoms.md +11 -10
- package/views/docs/guides/the-grid.md +7 -5
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/reference/controls.md +24 -18
- package/views/docs/reference/display.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +4 -4
- package/views/docs/reference/list.md +30 -11
- package/views/docs/reference/looks.md +4 -1
- package/views/docs/reference/panels-react.md +7 -6
- package/views/docs/reference/panels.md +2 -2
- package/views/docs/reference/react.md +22 -10
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +2 -2
- package/views/skills/views/SKILL.md +1 -1
|
@@ -69,9 +69,9 @@ export declare function GridRowHoverActions<Row>({ views, rowKey, row, selected,
|
|
|
69
69
|
* A pick-list's ▾: the cue that the value is a choice, and its one-click
|
|
70
70
|
* opener. A real button (the row's click contract lets real controls win), so
|
|
71
71
|
* clicking it opens the picker directly, with no select-first step. Drawn on the
|
|
72
|
-
* cell under the pointer,
|
|
73
|
-
*
|
|
74
|
-
* lands during the exit
|
|
72
|
+
* cell under the pointer, the same whether its picker is open or not: an open
|
|
73
|
+
* picker leaves its cell as it was. A click on it while its picker
|
|
74
|
+
* is open opens nothing (it lands during the exit and can't reopen). Never drawn on a phone,
|
|
75
75
|
* where a tap selects the cell and a second opens its editor in a sheet.
|
|
76
76
|
*/
|
|
77
77
|
export declare function GridPickerCaret({ rowKey, colId, editing, onOpen, }: {
|
|
@@ -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))]";
|
|
@@ -9,7 +9,7 @@ import type { ListSelectionConfig } from "../../selection/types.js";
|
|
|
9
9
|
import type { ListSettingsConfig } from "../../model/column-capabilities.js";
|
|
10
10
|
import type { ListAggregateKind, ListCellAction, ListColumn, ListOptionColorOverrides, ListRelationValue, ListSelectColor } from "../../model/column-schema.js";
|
|
11
11
|
import type { ListDateStyle, ListDateStyleOverrides, ListDurationStyle, ListDurationStyleOverrides, ListNumberFormatOverrides, ListPercentDisplayOverrides, ListShowTimeOverrides } from "../../model/column-format.js";
|
|
12
|
-
import type { ListColumnState, ListColumnsConfig } from "../../model/column-state.js";
|
|
12
|
+
import type { ListColumnItem, ListColumnState, ListColumnsConfig } from "../../model/column-state.js";
|
|
13
13
|
import type { PercentDisplay } from "viewkitjs/fields";
|
|
14
14
|
import type { ListGroupSummaryPart } from "../../model/preferences.js";
|
|
15
15
|
import type { ListRowIconAccessor } from "../../model/row-icon.js";
|
|
@@ -20,7 +20,8 @@ import type { GridGroupSortOption } from "./GridGroupMenu.js";
|
|
|
20
20
|
import type { GridGroupMenuPart } from "./grid-group-menu-parts.js";
|
|
21
21
|
/** Each of the grid's menus as a function from its default items to the items it shows (`menu.drop`, `menu.rename`,
|
|
22
22
|
* `menu.add` and `menu.move` on `viewkitjs/views/list` do the usual changes). `column` gets the column and its field,
|
|
23
|
-
* `row` the row, `group` the group its band names
|
|
23
|
+
* `row` the row, `group` the group its band names, `addColumn` every column of the list, shown or hidden (+ Add column's
|
|
24
|
+
* rows: each hidden column `add:<id>`, a field with parts `field:<id>`, or `all-shown`). Each reshapes a menu the grid opens: a column or band whose menu holds
|
|
24
25
|
* none of the grid's rows stays without one. Called while a menu draws: keep them pure and cheap.
|
|
25
26
|
*
|
|
26
27
|
* `row` is asked as a row's menu opens (a right-click, the row's ⋯, the menu key), never for a row drawn or pressed, and
|
|
@@ -39,6 +40,9 @@ export type GridMenus<Row> = {
|
|
|
39
40
|
group?: (items: ViewsMenuItem[], ctx: {
|
|
40
41
|
group: ListGroup<Row>;
|
|
41
42
|
}) => ViewsMenuItem[];
|
|
43
|
+
addColumn?: (items: ViewsMenuItem[], ctx: {
|
|
44
|
+
columns: readonly ListColumnItem[];
|
|
45
|
+
}) => ViewsMenuItem[];
|
|
42
46
|
};
|
|
43
47
|
/** A group count's noun, singular and plural ("company", "companies"): "2 companies". None: a bare
|
|
44
48
|
* count. */
|
|
@@ -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,3 +1,11 @@
|
|
|
1
|
-
/** One row's height at scale 1, in px: `--vk-row-h`
|
|
1
|
+
/** One row's height at scale 1, in px: `--vk-row-h`'s default (`GRID_HEIGHTS`), and the row window's count until it has
|
|
2
|
+
* measured a drawn row. */
|
|
2
3
|
export declare const GRID_ROW_PX = 37;
|
|
4
|
+
/**
|
|
5
|
+
* The four heights an app sets on the frame (`--vk-row-h`, `--vk-head-h`, `--vk-label-h`, `--vk-footer-h`), at the
|
|
6
|
+
* scale: classes on the frame, never an inline declaration, which would beat the app's own rule there. Each weighs
|
|
7
|
+
* nothing (`:where`), so any rule on the frame wins over it: an app's, and the grid look's (its Words header's height).
|
|
8
|
+
* Written whole, as the stylesheet's scan reads them; the row's is `GRID_ROW_PX`.
|
|
9
|
+
*/
|
|
10
|
+
export declare const GRID_HEIGHTS = "[:where(&)]:[--vk-row-h:calc(37px*var(--vk-scale))] [:where(&)]:[--vk-head-h:calc(32px*var(--vk-scale))] [:where(&)]:[--vk-label-h:calc(36px*var(--vk-scale))] [:where(&)]:[--vk-footer-h:calc(36px*var(--vk-scale))]";
|
|
3
11
|
export declare function useGridScaleStyles(scale: number, grouped: boolean, phone: boolean, addColumn?: boolean): import("react").CSSProperties;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useMemo } from "react";
|
|
3
3
|
export const GRID_ROW_PX = 37;
|
|
4
|
+
export const GRID_HEIGHTS = "[:where(&)]:[--vk-row-h:calc(37px*var(--vk-scale))] [:where(&)]:[--vk-head-h:calc(32px*var(--vk-scale))] [:where(&)]:[--vk-label-h:calc(36px*var(--vk-scale))] [:where(&)]:[--vk-footer-h:calc(36px*var(--vk-scale))]";
|
|
4
5
|
export function useGridScaleStyles(scale, grouped, phone, addColumn = false) {
|
|
5
6
|
return useMemo(() => ({
|
|
6
7
|
"--vk-scale": String(scale),
|
|
7
8
|
"--vk-indent": phone ? "0px" : "24px",
|
|
8
|
-
"--vk-row-h": `calc(${GRID_ROW_PX}px * var(--vk-scale))`,
|
|
9
9
|
"--vk-line-h": "calc(22px * var(--vk-scale))",
|
|
10
|
-
"--vk-head-h": "calc(32px * var(--vk-scale))",
|
|
11
10
|
"--vk-head-text": "calc(12px * var(--vk-scale))",
|
|
12
11
|
"--vk-head-glyph": "calc(12px * var(--vk-scale))",
|
|
13
|
-
"--vk-footer-h": "calc(36px * var(--vk-scale))",
|
|
14
|
-
"--vk-label-h": "calc(36px * var(--vk-scale))",
|
|
15
12
|
"--vk-text": "calc(14px * var(--vk-scale))",
|
|
16
13
|
"--vk-text-xs": "calc(12px * var(--vk-scale))",
|
|
17
14
|
"--vk-text-10": "calc(10px * var(--vk-scale))",
|
|
@@ -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,
|
|
@@ -8,7 +8,7 @@ export type GridFormatPrefs = Pick<ListViewPrefs, "gridOptionColors" | "gridDate
|
|
|
8
8
|
/** The grid's format props and the handlers that write them back through `setFormats`. Every format is keyed by the
|
|
9
9
|
* FIELD key (`fieldKeyOf(column)`), the name every surface shares. */
|
|
10
10
|
export declare function useGridFormatProps<Row>(formats: GridFormatPrefs, setFormats: (patch: Partial<GridFormatPrefs>) => void, columns: ListColumn<Row>[]): {
|
|
11
|
-
optionColors: import("
|
|
11
|
+
optionColors: Record<string, Record<string, import("viewkitjs/fields/design/category-colors").CategoryColor>>;
|
|
12
12
|
onOptionColorChange: (key: string, value: string, color: ListSelectColor | null) => void;
|
|
13
13
|
dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
|
|
14
14
|
onDateStyleChange: (key: string, style: ListDateStyle) => void;
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback, useMemo } from "react";
|
|
2
|
+
import { useCallback, useEffect, useMemo, useRef } from "react";
|
|
3
3
|
import { fieldKeyOf } from "../model/view-rules.js";
|
|
4
4
|
import { setCurrency, setDateStyle, setDecimals, setDurationStyle, setOptionColor, setPercentDisplay, setShowTime, } from "../model/preferences.js";
|
|
5
5
|
import { moneyReadingOf } from "../fields/money.js";
|
|
6
6
|
import { isMoneyReading, MONEY_READING_OPTIONS } from "../fields/currency.js";
|
|
7
|
+
function settled(map) {
|
|
8
|
+
if (!Object.values(map).includes(null))
|
|
9
|
+
return map;
|
|
10
|
+
return Object.fromEntries(Object.entries(map).filter(([, held]) => held !== null));
|
|
11
|
+
}
|
|
7
12
|
export function useGridFormatProps(formats, setFormats, columns) {
|
|
8
|
-
const { gridOptionColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals, gridCurrencies, } = formats;
|
|
13
|
+
const { gridOptionColors: storedColors, gridDateStyles, gridDurationStyles, gridShowTime, gridPercentDisplays, gridDecimals: storedDecimals, gridCurrencies, } = formats;
|
|
14
|
+
const gridOptionColors = useMemo(() => settled(storedColors), [storedColors]);
|
|
15
|
+
const gridDecimals = useMemo(() => settled(storedDecimals), [storedDecimals]);
|
|
16
|
+
const colours = useRef(gridOptionColors);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
colours.current = gridOptionColors;
|
|
19
|
+
}, [gridOptionColors]);
|
|
9
20
|
const onOptionColorChange = useCallback((key, value, color) => {
|
|
10
|
-
|
|
11
|
-
|
|
21
|
+
const next = setOptionColor(colours.current, key, value, color);
|
|
22
|
+
colours.current = next;
|
|
23
|
+
setFormats({ gridOptionColors: { ...next, [key]: next[key] ?? null } });
|
|
24
|
+
}, [setFormats]);
|
|
12
25
|
const onDateStyleChange = useCallback((key, style) => setFormats({ gridDateStyles: setDateStyle(gridDateStyles, key, style) }), [gridDateStyles, setFormats]);
|
|
13
26
|
const onDurationStyleChange = useCallback((key, style) => setFormats({ gridDurationStyles: setDurationStyle(gridDurationStyles, key, style) }), [gridDurationStyles, setFormats]);
|
|
14
27
|
const onShowTimeChange = useCallback((key, show) => setFormats({ gridShowTime: setShowTime(gridShowTime, key, show) }), [gridShowTime, setFormats]);
|
|
@@ -31,7 +44,7 @@ export function useGridFormatProps(formats, setFormats, columns) {
|
|
|
31
44
|
if (patch.currency != null && isMoneyReading(patch.currency))
|
|
32
45
|
setFormats({ gridCurrencies: setCurrency(gridCurrencies, key, patch.currency) });
|
|
33
46
|
if (patch.decimals === null)
|
|
34
|
-
setFormats({ gridDecimals: { [key]: null } });
|
|
47
|
+
setFormats({ gridDecimals: { ...gridDecimals, [key]: null } });
|
|
35
48
|
else if (patch.decimals !== undefined)
|
|
36
49
|
setFormats({ gridDecimals: setDecimals(gridDecimals, key, patch.decimals) });
|
|
37
50
|
}, [gridCurrencies, gridDecimals, setFormats]);
|
package/views/dist/grid/grid.css
CHANGED
|
@@ -28,11 +28,15 @@
|
|
|
28
28
|
one; the grid draws them at 70% of it. */
|
|
29
29
|
[data-grid-header="words"] [data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header"],
|
|
30
30
|
[data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header"]:not([data-grid-header] *) {
|
|
31
|
-
--vk-head-h: calc(var(--vk-spacing) * 9 * var(--vk-scale));
|
|
32
31
|
--vk-head-text: calc(var(--vk-font-size-sm) * var(--vk-scale));
|
|
33
32
|
--vk-head-glyph: calc(var(--vk-spacing) * 3.5 * var(--vk-scale));
|
|
34
33
|
--vk-head-glyph-fg: var(--vk-fg-subtle);
|
|
35
34
|
}
|
|
35
|
+
/* Its height is the frame's, where an app sets the header's own (`--vk-head-h`): weighing nothing (`:where`), so
|
|
36
|
+
any rule of the app's on the frame wins over the look's. */
|
|
37
|
+
:where([data-grid-header="words"] [data-slot="vk-grid"][data-desktop], [data-slot="vk-grid"][data-desktop]:not([data-grid-header] *)) {
|
|
38
|
+
--vk-head-h: calc(var(--vk-spacing) * 9 * var(--vk-scale));
|
|
39
|
+
}
|
|
36
40
|
[data-grid-header="words"] [data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header-cell"],
|
|
37
41
|
[data-slot="vk-grid"][data-desktop] [data-slot="vk-grid-header-cell"]:not([data-grid-header] *) {
|
|
38
42
|
--vk-fg-subtle: var(--vk-fg);
|
|
@@ -86,16 +90,16 @@
|
|
|
86
90
|
}
|
|
87
91
|
|
|
88
92
|
/* Picked cell, Wash: the focused cell (data-focused) washed in the brand's lightest ground inside its frame. Ring: the frame
|
|
89
|
-
alone. */
|
|
90
|
-
[data-grid-cell="wash"] [data-slot="vk-grid-cell"][data-focused],
|
|
91
|
-
[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] *) {
|
|
92
96
|
background-color: var(--vk-brand-subtlest);
|
|
93
97
|
}
|
|
94
98
|
|
|
95
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:
|
|
96
100
|
both frames' corners, which the grid ties, square or the small corner. Hover frame: the hovered cell's line, none, the
|
|
97
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;
|
|
98
|
-
under the pointer
|
|
102
|
+
under the pointer it is the brand's either way. */
|
|
99
103
|
[data-grid-corners="square"] [data-slot="vk-grid"] { --vk-outline-radius: 0; }
|
|
100
104
|
[data-grid-corners="round"] [data-slot="vk-grid"],
|
|
101
105
|
[data-slot="vk-grid"]:not([data-grid-corners] *) { --vk-outline-radius: var(--vk-radius-sm); }
|
|
@@ -108,21 +112,6 @@
|
|
|
108
112
|
[data-grid-frame="neutral"] [data-slot="vk-grid"] { --vk-outline: var(--vk-border-bold); }
|
|
109
113
|
[data-slot="vk-grid"] { --vk-outline-active: var(--vk-border-accent); }
|
|
110
114
|
|
|
111
|
-
/* A cell being edited in an editor that draws its own edge shows that edge alone: where ViewKit's Text editor or Number
|
|
112
|
-
editor stands in the cell (data-kit, CONTROLS.TextBody and NumberBody), the input draws the only edge round what is typed,
|
|
113
|
-
so the grid's outline, its brand line and its lift, stands down on the cell being edited (data-editing). Where the grid's
|
|
114
|
-
own editor stands its outline stays, and a cell at rest keeps it. */
|
|
115
|
-
[data-slot="vk-grid-cell"][data-editing]:has([data-kit="text-editor"], [data-kit="number-editor"]) [data-slot="vk-grid-outline"] {
|
|
116
|
-
display: none;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/* A body over its cell has its own edge: while the grid's editor part holds ViewKit's Picker, Compound editor,
|
|
120
|
-
Values editor or Date editor, the cell being edited under it shows no outline, so the brand's line never peeks out under the
|
|
121
|
-
body's rounded corners. The grid's own editors keep it. */
|
|
122
|
-
: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"] {
|
|
123
|
-
display: none;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
115
|
/* Picked rows: Tint, Attio's, keeps a picked row's own line, its tint alone saying it is picked (--vk-selection-edge). Tint
|
|
127
116
|
and line, the portal's, is the grid's own: the brand's line over the first picked row and under each. */
|
|
128
117
|
[data-grid-picked="tint"] [data-slot="vk-grid"] {
|
|
@@ -24,7 +24,7 @@ export declare function useGridTablePrefs<Row>({ prefs, setPrefs, columns, viewB
|
|
|
24
24
|
aggregates: Record<string, import("viewkitjs/fields/query").FigureKind>;
|
|
25
25
|
onAggregateChange: (columnId: string, kind: ListAggregateKind) => void;
|
|
26
26
|
viewBacked: boolean;
|
|
27
|
-
optionColors: import("
|
|
27
|
+
optionColors: Record<string, Record<string, import("viewkitjs/fields/design/category-colors").CategoryColor>>;
|
|
28
28
|
onOptionColorChange: (key: string, value: string, color: import("../model/column-schema.js").ListSelectColor | null) => void;
|
|
29
29
|
dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
|
|
30
30
|
onDateStyleChange: (key: string, style: import("../model/column-format.js").ListDateStyle) => void;
|
|
@@ -36,7 +36,7 @@ export declare function useGridTableSettings<Row>({ settings, layer, columns, pa
|
|
|
36
36
|
aggregates: Record<string, import("viewkitjs/fields/query").FigureKind>;
|
|
37
37
|
onAggregateChange: (columnId: string, kind: ListAggregateKind) => void;
|
|
38
38
|
viewBacked: true;
|
|
39
|
-
optionColors: import("
|
|
39
|
+
optionColors: Record<string, Record<string, import("viewkitjs/fields/design/category-colors").CategoryColor>>;
|
|
40
40
|
onOptionColorChange: (key: string, value: string, color: import("../model/column-schema.js").ListSelectColor | null) => void;
|
|
41
41
|
dateStyles: import("../model/column-format.js").ListDateStyleOverrides;
|
|
42
42
|
onDateStyleChange: (key: string, style: import("../model/column-format.js").ListDateStyle) => void;
|
|
@@ -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";
|
|
@@ -9,10 +10,10 @@ function handed(from) {
|
|
|
9
10
|
return Object.fromEntries(Object.entries(from).filter(([, value]) => value !== undefined));
|
|
10
11
|
}
|
|
11
12
|
export function List({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, customizeIn, link = true, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }) {
|
|
12
|
-
const toolbarMenus = { ...toolbar?.menus, ...handed({ view: menus?.view, add: menus?.add, more: menus?.more }) };
|
|
13
|
-
const gridMenus = { ...grid?.menus, ...handed({ column: menus?.column, row: menus?.row, group: menus?.group }) };
|
|
13
|
+
const toolbarMenus = { ...toolbar?.menus, ...handed({ view: menus?.view, add: menus?.add, more: menus?.more, customize: menus?.customize, sortEditor: menus?.sortEditor, filterEditor: menus?.filterEditor, groupEditor: menus?.groupEditor }) };
|
|
14
|
+
const gridMenus = { ...grid?.menus, ...handed({ column: menus?.column, row: menus?.row, group: menus?.group, addColumn: menus?.addColumn }) };
|
|
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,8 +1,7 @@
|
|
|
1
1
|
import type { GridMenus } from "../grid/chrome/grid-table-props.js";
|
|
2
2
|
import type { ToolbarMenus } from "../panels/react/toolbar/ReadyToolbar.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* (`view`, `add`, `more`, which `ReadyToolbar` and `ListToolbar` take as `menus`). Each is handed its default items and hands
|
|
3
|
+
/** Every menu of a list as data: the grid's (`column`, `row`, `group`, `addColumn`, which `GridTable` takes as `menus`) and the toolbar's
|
|
4
|
+
* (`view`, `add`, `more`, `customize`, which `ReadyToolbar` and `ListToolbar` take as `menus`). Each is handed its default items and hands
|
|
6
5
|
* back the items it shows; a menu with no function is as ViewKit draws it. */
|
|
7
6
|
export type ListMenus<Row> = GridMenus<Row> & ToolbarMenus;
|
|
8
7
|
/** Where a row goes: right after the row of that key, or right before it. */
|
|
@@ -18,7 +17,9 @@ type Keyed<T> = {
|
|
|
18
17
|
children?: T[];
|
|
19
18
|
};
|
|
20
19
|
declare function drop<T extends Keyed<T>>(items: T[], ...keys: string[]): T[];
|
|
21
|
-
declare function rename
|
|
20
|
+
declare function rename<T extends Keyed<T> & {
|
|
21
|
+
label: string;
|
|
22
|
+
}>(items: T[], key: string, label: string): T[];
|
|
22
23
|
declare function add<T extends Keyed<T>>(items: T[], item: T, place?: MenuPlace): T[];
|
|
23
24
|
declare function move<T extends Keyed<T>>(items: T[], key: string, place: MenuPlace): T[];
|
|
24
25
|
/** The four changes an app's menu function makes to the items it is handed. */
|
|
@@ -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[];
|