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
|
@@ -52,7 +52,5 @@ export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange,
|
|
|
52
52
|
const why = details?.reason;
|
|
53
53
|
if (!next && why !== "outside-press" && why !== "focus-out")
|
|
54
54
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
55
|
-
}, anchor: hangsAt.anchor, ...hangs, ...(opens === "filters"
|
|
56
|
-
? { chrome: "panel", className: "w-fit max-w-[calc(100vw-2rem)]" }
|
|
57
|
-
: { chrome: "menu" }), panelData: { "data-slot": "vk-toolbar-filters-panel" }, children: list }))] }));
|
|
55
|
+
}, anchor: hangsAt.anchor, ...hangs, chrome: "menu", ...(opens === "filters" && { className: "w-(--vk-panel-w,fit-content) max-w-[calc(100vw-2rem)]" }), panelData: { "data-slot": "vk-toolbar-filters-panel" }, children: list }))] }));
|
|
58
56
|
}
|
|
@@ -33,5 +33,5 @@ export function ToolbarOptions({ view, viewFoot, footClear, resets, layered, cus
|
|
|
33
33
|
};
|
|
34
34
|
return (_jsx(ToolbarPanelPart, { panelKey: "options", slot: "vk-toolbar-options", part: "options", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, word: name, count: count, onClear: clear, dot: !!view && view.changes > 0, open: holdsOpen ? open : ownOpen, onOpenChange: handleOpenChange, host: host, popoverClassName: widthClassName
|
|
35
35
|
? viewOptionsPopoverClassName(page, widthClassName)
|
|
36
|
-
: viewOptionsPopoverClassName(null, "w-75"), onSheetEscape: step.escapeBack, children: ({ fill, close, closeButton }) => (_jsx(PanelStepHold.Provider, { value: step, children: _jsx(ViewOptionsPanelContent, { ...inputs, activePanel: page, onOpenPanel: setPage, anyActive: view ? view.changes > 0 : count > 0, clearAll: clear, foldFilters: foldFilters, onClose: close, closeButton: closeButton, fill: fill, view: view, viewFoot: viewFoot, footClear: footClear, ...(resets && { resets }), ...(layered && { layered }), ...(customizeItems && { customizeItems }), fieldEditor: fieldEditor, ...(viewName !== undefined && { viewName }), ...(onRenameView && { onRenameView }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }), ...(exportCount !== undefined && { exportCount }) }) })) }));
|
|
36
|
+
: viewOptionsPopoverClassName(null, "w-(--vk-panel-w,calc(var(--spacing)*75))"), onSheetEscape: step.escapeBack, children: ({ fill, close, closeButton }) => (_jsx(PanelStepHold.Provider, { value: step, children: _jsx(ViewOptionsPanelContent, { ...inputs, activePanel: page, onOpenPanel: setPage, anyActive: view ? view.changes > 0 : count > 0, clearAll: clear, foldFilters: foldFilters, onClose: close, closeButton: closeButton, fill: fill, view: view, viewFoot: viewFoot, footClear: footClear, ...(resets && { resets }), ...(layered && { layered }), ...(customizeItems && { customizeItems }), fieldEditor: fieldEditor, ...(viewName !== undefined && { viewName }), ...(onRenameView && { onRenameView }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }), ...(exportCount !== undefined && { exportCount }) }) })) }));
|
|
37
37
|
}
|
|
@@ -11,7 +11,7 @@ export declare function ToolbarQuickFilters({ quickFilters, open, onOpenChange,
|
|
|
11
11
|
host?: ToolbarPanelHost;
|
|
12
12
|
/** The button's glyph; absent, the filter row's category glyph. */
|
|
13
13
|
icon?: ReactNode;
|
|
14
|
-
/** `null`: its icon alone, its words its name to a screen reader, unless it was placed `words: "both"` (VK-967); absent,
|
|
14
|
+
/** `null`: its icon alone, its words its name to a screen reader, unless it was placed `words: "both"` (VK-967) or `"word"` (VK-970); absent,
|
|
15
15
|
* its icon and its words. */
|
|
16
16
|
word?: null;
|
|
17
17
|
}): ReactNode;
|
|
@@ -14,5 +14,5 @@ export function ToolbarQuickFilters({ quickFilters, open, onOpenChange, host, ic
|
|
|
14
14
|
return null;
|
|
15
15
|
const Glyph = icons.filterCategory;
|
|
16
16
|
const label = quickFilters.label ?? messages({ key: "views.panels.quick-filters" });
|
|
17
|
-
return (_jsx(ToolbarPanelPart, { panelKey: "quick", slot: "vk-toolbar-quick", part: "quick", icon: icon ?? _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: label, word: word === null && slot.words !== "both" ? null : label, changed: holdStands(quickFilters.hold), open: open, onOpenChange: onOpenChange, host: host, children: ({ close, closeButton }) => (_jsx(QuickFiltersPanel, { quickFilters: quickFilters, form: phone ? "phone" : "computer", onDone: close, closeButton: closeButton, inHost: !!host })) }));
|
|
17
|
+
return (_jsx(ToolbarPanelPart, { panelKey: "quick", slot: "vk-toolbar-quick", part: "quick", icon: icon ?? _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: label, word: word === null && slot.words !== "both" && slot.words !== "word" ? null : label, changed: holdStands(quickFilters.hold), open: open, onOpenChange: onOpenChange, host: host, children: ({ close, closeButton }) => (_jsx(QuickFiltersPanel, { quickFilters: quickFilters, form: phone ? "phone" : "computer", onDone: close, closeButton: closeButton, inHost: !!host })) }));
|
|
18
18
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { CollectionViewState } from "../../view-state.js";
|
|
3
|
-
export declare function ToolbarSave({ view, layered, onClear, }: {
|
|
3
|
+
export declare function ToolbarSave({ view, layered, onClear, only, }: {
|
|
4
4
|
/** The shared view this list shows: Clear is its `onReset`, Save its `onPublish`. */
|
|
5
5
|
view?: CollectionViewState;
|
|
6
6
|
/** With no shared view, what Clear does: the list back to its default. Absent, nothing to clear. */
|
|
7
7
|
onClear?: () => void;
|
|
8
8
|
/** The reader's own layer holds something (VK-1034): on a shared view Clear stands for it too, Save doesn't. */
|
|
9
9
|
layered?: boolean;
|
|
10
|
+
/** One half alone, where the app placed Clear and Save apart (VK-970): `clear` or `save`. Absent, both in one box. */
|
|
11
|
+
only?: "clear" | "save";
|
|
10
12
|
}): ReactNode;
|
|
@@ -4,7 +4,7 @@ import { useViews } from "../../../provider/context.js";
|
|
|
4
4
|
import { drawPanelButton } from "../../panel-button.js";
|
|
5
5
|
import { useToolbarSlot } from "./context.js";
|
|
6
6
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
7
|
-
export function ToolbarSave({ view, layered = false, onClear, }) {
|
|
7
|
+
export function ToolbarSave({ view, layered = false, onClear, only, }) {
|
|
8
8
|
const views = useViews();
|
|
9
9
|
const { messages } = views;
|
|
10
10
|
const { appFrame } = useToolbarSlot();
|
|
@@ -16,24 +16,32 @@ export function ToolbarSave({ view, layered = false, onClear, }) {
|
|
|
16
16
|
if (appFrame) {
|
|
17
17
|
const clearWord = messages({ key: "views.panels.view-clear" });
|
|
18
18
|
const saveWord = messages({ key: "views.panels.view-save" });
|
|
19
|
-
|
|
19
|
+
const clearButton = (_jsx(ToolbarButton, { icon: null, label: clearWord, part: "clear", disabled: pending, onClick: clear, children: clearWord }));
|
|
20
|
+
const saveButton = publish && (_jsx(ToolbarButton, { icon: null, label: saveWord, part: "save", disabled: pending, onClick: view.onPublish, children: saveWord }));
|
|
21
|
+
if (only)
|
|
22
|
+
return only === "clear" ? clearButton : saveButton || null;
|
|
23
|
+
return (_jsxs("span", { "data-slot": "vk-toolbar-save", className: "inline-flex shrink-0 items-center gap-2", children: [clearButton, saveButton] }));
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
const clearButton = drawPanelButton(views, {
|
|
26
|
+
frame: "h-8 px-3",
|
|
27
|
+
variant: "ghost",
|
|
28
|
+
size: "sm",
|
|
29
|
+
disabled: pending,
|
|
30
|
+
onClick: clear,
|
|
31
|
+
"data-slot": "vk-toolbar-clear",
|
|
32
|
+
children: messages({ key: "views.panels.view-clear" }),
|
|
33
|
+
});
|
|
34
|
+
const saveButton = publish &&
|
|
35
|
+
drawPanelButton(views, {
|
|
36
|
+
frame: "h-8 px-3",
|
|
37
|
+
variant: "outline",
|
|
38
|
+
size: "sm",
|
|
39
|
+
disabled: pending,
|
|
40
|
+
onClick: view.onPublish,
|
|
41
|
+
"data-slot": "vk-toolbar-save-button",
|
|
42
|
+
children: messages({ key: "views.panels.view-save" }),
|
|
43
|
+
});
|
|
44
|
+
if (only)
|
|
45
|
+
return only === "clear" ? clearButton : saveButton || null;
|
|
46
|
+
return (_jsxs("span", { "data-slot": "vk-toolbar-save", className: "inline-flex shrink-0 items-center gap-2", children: [clearButton, saveButton] }));
|
|
39
47
|
}
|
|
@@ -43,7 +43,7 @@ export function ToolbarSearch({ value, onChange, placeholder, searching = false,
|
|
|
43
43
|
setOpened(false);
|
|
44
44
|
};
|
|
45
45
|
if (!shown) {
|
|
46
|
-
return (_jsx("div", { "data-slot": "vk-toolbar-search", className: "relative flex flex-none items-center", children: _jsx(ToolbarButton, { part: "search", icon: searching ? _jsx(LoadingRing, { label: busy, slot: "vk-toolbar-search-spinner", className: "h-4 w-4" }) : _jsx(Glass, { className: "h-4 w-4 shrink-0" }), label: name, word: slot.words === "both" ? undefined : null, onClick: () => {
|
|
46
|
+
return (_jsx("div", { "data-slot": "vk-toolbar-search", className: "relative flex flex-none items-center", children: _jsx(ToolbarButton, { part: "search", icon: searching ? _jsx(LoadingRing, { label: busy, slot: "vk-toolbar-search-spinner", className: "h-4 w-4" }) : _jsx(Glass, { className: "h-4 w-4 shrink-0" }), label: name, word: slot.words === "both" || slot.words === "word" ? undefined : null, onClick: () => {
|
|
47
47
|
pressed.current = true;
|
|
48
48
|
setOpened(true);
|
|
49
49
|
} }) }));
|
|
@@ -29,8 +29,9 @@ export type ToolbarSlotState = {
|
|
|
29
29
|
* part's chip, tabs, "+N" and "+", and Clear and Save draw through your `ToolbarButton`. */
|
|
30
30
|
appFrame: boolean;
|
|
31
31
|
/** Its words as it was placed (`ToolbarPlacement.words`, VK-967): `icon`, its icon alone; `both`, a part that is its icon
|
|
32
|
-
* alone by default (the search, the quick filters' button) reads its word
|
|
33
|
-
|
|
32
|
+
* alone by default (the search, the quick filters' button) reads its word; `word`, its word alone, no icon, on every button
|
|
33
|
+
* of the part that has a word (VK-970). Absent, its own. */
|
|
34
|
+
words?: "both" | "icon" | "word";
|
|
34
35
|
/** `false`: New stays on a phone's folding line instead of at the list's foot. */
|
|
35
36
|
foot?: boolean;
|
|
36
37
|
/** The key of the place it stands in (VK-984): a part whose button stands in more than one place (Sort's pill, a panel
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useCallback, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useCallback, useContext, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import { useViews } from "../../../provider/context.js";
|
|
5
5
|
import { formatCount } from "../../../internal/count.js";
|
|
6
6
|
import { drawPanelButton, PanelButton } from "../../panel-button.js";
|
|
@@ -10,6 +10,8 @@ import { PillGroup } from "./PillGroup.js";
|
|
|
10
10
|
import { useAnchoredToggle } from "./use-anchored-toggle.js";
|
|
11
11
|
import { ToolbarButton } from "../toolbar/ToolbarButton.js";
|
|
12
12
|
import { useViewsRowInFrame } from "./in-frame.js";
|
|
13
|
+
import { MoreViews } from "./more-views.js";
|
|
14
|
+
import { cx } from "../../../internal/cx.js";
|
|
13
15
|
import { ViewCreatePill } from "./ViewCreatePill.js";
|
|
14
16
|
import { useNewView } from "./new-view.js";
|
|
15
17
|
import { ViewPickerRow } from "./ViewPickerRow.js";
|
|
@@ -21,6 +23,7 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
21
23
|
const [visible, setVisible] = useState(axis.options.length);
|
|
22
24
|
const words = usePillWords(axis.hideCounts);
|
|
23
25
|
const inFrame = useViewsRowInFrame();
|
|
26
|
+
const ownMore = useContext(MoreViews);
|
|
24
27
|
const pills = useMemo(() => toPillOptions(axis.options, words), [axis.options, words]);
|
|
25
28
|
const viewMenu = useMemo(() => (axis.verbs && views.components.ViewMenu ? { views: viewsListItemsOf(axis), value: axis.value, verbs: axis.verbs } : undefined), [axis, views.components.ViewMenu]);
|
|
26
29
|
const newView = useNewView(axis);
|
|
@@ -93,19 +96,32 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
93
96
|
const ordered = pills.filter(inBlock).map((pill) => (visibleValues.has(pill.value) ? dealt.shift() : pill.value));
|
|
94
97
|
axis.onReorder(ordered);
|
|
95
98
|
};
|
|
96
|
-
return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag, viewMenu: viewMenu }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions, viewMenu: viewMenu }), newView.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: newView.onCreate }), newView.slot(hostRef), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
|
|
97
|
-
frame: MORE_CHIP_FRAME,
|
|
99
|
+
return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag, viewMenu: viewMenu }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions, viewMenu: viewMenu }), newView.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: newView.onCreate }), newView.slot(hostRef), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: ownMore?.button ? (_jsx(ownMore.button, { ...ownMoreProps(views, 99, ownMore.className) })) : (drawPanelButton(views, {
|
|
100
|
+
frame: cx(MORE_CHIP_FRAME, ownMore?.className),
|
|
98
101
|
variant: "ghost",
|
|
99
102
|
size: "sm",
|
|
100
103
|
"data-slot": "vk-views-more",
|
|
101
104
|
children: moreChipInner(views, 99),
|
|
102
|
-
}) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }) }))] }));
|
|
105
|
+
})) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }) }))] }));
|
|
103
106
|
}
|
|
104
107
|
const MORE_CHIP_FRAME = "h-8 shrink-0 gap-0.5 whitespace-nowrap px-2.5";
|
|
105
108
|
function moreChipInner({ conventions, icons }, count) {
|
|
106
109
|
const Chevron = icons.chevronDown;
|
|
107
110
|
return (_jsxs(_Fragment, { children: ["+", formatCount(count, conventions), _jsx(Chevron, { className: "h-3.5 w-3.5 shrink-0 opacity-70" })] }));
|
|
108
111
|
}
|
|
112
|
+
function ownMoreProps({ conventions, messages }, count, className) {
|
|
113
|
+
return {
|
|
114
|
+
part: "views-more",
|
|
115
|
+
icon: null,
|
|
116
|
+
word: null,
|
|
117
|
+
label: messages({ key: "views.panels.views-more", values: { count } }),
|
|
118
|
+
children: `+${formatCount(count, conventions)}`,
|
|
119
|
+
popup: "dialog",
|
|
120
|
+
open: false,
|
|
121
|
+
size: "sm",
|
|
122
|
+
...(className && { className }),
|
|
123
|
+
};
|
|
124
|
+
}
|
|
109
125
|
function MoreButton({ count, ref, open, onPointerDown, onClick, }) {
|
|
110
126
|
const { conventions, messages } = useViews();
|
|
111
127
|
return (_jsxs(ToolbarButton, { ref: ref, icon: null, label: messages({ key: "views.panels.views-more", values: { count } }), part: "views-more", popup: "dialog", open: Boolean(open), onPointerDown: onPointerDown, onClick: onClick, children: ["+", formatCount(count, conventions)] }));
|
|
@@ -117,13 +133,14 @@ function FoldedViews({ axis, options, viewMenu, }) {
|
|
|
117
133
|
const anchor = useRef(null);
|
|
118
134
|
const toggle = useAnchoredToggle(anchor);
|
|
119
135
|
const inFrame = useViewsRowInFrame();
|
|
136
|
+
const ownMore = useContext(MoreViews);
|
|
120
137
|
const holding = useRef(false);
|
|
121
138
|
const onHold = useCallback((on) => {
|
|
122
139
|
holding.current = on;
|
|
123
140
|
}, []);
|
|
124
141
|
const rowMenu = viewMenu && { ...viewMenu, onDone: toggle.close, onHold };
|
|
125
|
-
return (_jsxs(_Fragment, { children: [inFrame ? (_jsx(MoreButton, { count: options.length, ref: anchor, open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick })) : (_jsx(PanelButton, { views: views, draw: {
|
|
126
|
-
frame: MORE_CHIP_FRAME,
|
|
142
|
+
return (_jsxs(_Fragment, { children: [inFrame ? (_jsx(MoreButton, { count: options.length, ref: anchor, open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick })) : ownMore?.button ? (_jsx(ownMore.button, { ...ownMoreProps(views, options.length, ownMore.className), ref: anchor, open: toggle.open, onPointerDown: toggle.triggerProps.onPointerDown, onClick: toggle.triggerProps.onClick })) : (_jsx(PanelButton, { views: views, draw: {
|
|
143
|
+
frame: cx(MORE_CHIP_FRAME, ownMore?.className),
|
|
127
144
|
variant: "ghost",
|
|
128
145
|
size: "sm",
|
|
129
146
|
ref: anchor,
|
|
@@ -135,7 +152,7 @@ function FoldedViews({ axis, options, viewMenu, }) {
|
|
|
135
152
|
onPointerDown: toggle.triggerProps.onPointerDown,
|
|
136
153
|
onClick: toggle.triggerProps.onClick,
|
|
137
154
|
children: moreChipInner(views, options.length),
|
|
138
|
-
} })), _jsx(Popover, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-64", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: _jsx("div", { role: "listbox", "aria-label": messages({ key: "views.panels.views-more-list" }), className: VIEWS_LIST_CLASS, children: options.map((option) => (_jsx(ViewPickerRow, { option: option, active: option.value === axis.value, hideCounts: axis.hideCounts, viewMenu: rowMenu, onSelect: () => {
|
|
155
|
+
} })), _jsx(Popover, { open: toggle.open, onOpenChange: toggle.onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-(--vk-panel-w,calc(var(--spacing)*64))", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: _jsx("div", { role: "listbox", "aria-label": messages({ key: "views.panels.views-more-list" }), className: VIEWS_LIST_CLASS, children: options.map((option) => (_jsx(ViewPickerRow, { option: option, active: option.value === axis.value, hideCounts: axis.hideCounts, viewMenu: rowMenu, onSelect: () => {
|
|
139
156
|
axis.onChange(option.value);
|
|
140
157
|
toggle.close();
|
|
141
158
|
} }, option.value))) }) })] }));
|
|
@@ -88,5 +88,5 @@ export function ViewPicker({ axis, className }) {
|
|
|
88
88
|
close: { label: messages({ key: "views.panels.close" }), onPress: () => toggle.setOpen(false) },
|
|
89
89
|
back: { label: messages({ key: "views.panels.back" }), onPress: step.back },
|
|
90
90
|
},
|
|
91
|
-
}), onSheetEscape: step.escapeBack, children: list })) : (_jsx(Popover, { open: toggle.open, onOpenChange: onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-72", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: list }))] }));
|
|
91
|
+
}), onSheetEscape: step.escapeBack, children: list })) : (_jsx(Popover, { open: toggle.open, onOpenChange: onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-(--vk-panel-w,calc(var(--spacing)*72))", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: list }))] }));
|
|
92
92
|
}
|
|
@@ -27,7 +27,7 @@ export { ViewOptionsActions } from "./react/view-actions.js";
|
|
|
27
27
|
export { ViewOptionsPopoverPanel, keepPanelOpenForPortals, useViewActivePanel, useViewOptionsPopover, viewOptionsPopoverClassName, } from "./react/popover.js";
|
|
28
28
|
export type { ViewOptionsPopoverState } from "./react/popover.js";
|
|
29
29
|
export { Toolbar, ToolbarSeparator } from "./react/toolbar/Toolbar.js";
|
|
30
|
-
export type { ToolbarMore, ToolbarOverflow, ToolbarPart } from "./react/toolbar/Toolbar.js";
|
|
30
|
+
export type { ToolbarMore, ToolbarMoreViews, ToolbarOverflow, ToolbarPart } from "./react/toolbar/Toolbar.js";
|
|
31
31
|
export { ToolbarButton } from "./react/toolbar/ToolbarButton.js";
|
|
32
32
|
export { useToolbarPanel, useToolbarSlot } from "./react/toolbar/context.js";
|
|
33
33
|
export { ToolbarRadioProvider, ToolbarSlotProvider } from "./react/toolbar/context.js";
|
|
@@ -17,8 +17,8 @@ export type ToolbarPlacement = {
|
|
|
17
17
|
/** In the fold arrangement, it may fold into ⋯ when its line still has no room. */
|
|
18
18
|
fold?: boolean;
|
|
19
19
|
/** Its words, for a part whose button has a word (VK-967): `both`, as the look's words say (icon and word where they show);
|
|
20
|
-
* `icon`, its icon alone whatever the look. Absent, the part's own. */
|
|
21
|
-
words?: "both" | "icon";
|
|
20
|
+
* `icon`, its icon alone whatever the look; `word`, its word alone, no icon (VK-970). Absent, the part's own. */
|
|
21
|
+
words?: "both" | "icon" | "word";
|
|
22
22
|
/** On a phone's folding line New stands at the list's foot, unless `false` keeps it on the line (VK-967). */
|
|
23
23
|
foot?: boolean;
|
|
24
24
|
};
|
|
@@ -150,7 +150,7 @@ export type ViewsMenuItem = {
|
|
|
150
150
|
* disables every row under it: the provider hands the app's `Menu` those rows already `disabled`. */
|
|
151
151
|
children?: ViewsMenuItem[];
|
|
152
152
|
/** A group (`children`) that opens its rows beside the menu, one level in, rather than in place: its row
|
|
153
|
-
* shows its label and `detail` and opens on a hover
|
|
153
|
+
* shows its label and `detail` and opens on a hover or →. A hint: an adapter with no flyouts
|
|
154
154
|
* draws the group in place under its label, as every group is drawn. Ignored on a row with no `children`. */
|
|
155
155
|
beside?: boolean;
|
|
156
156
|
/** A checkable row (`checked` set) that leaves the menu open when picked, so several can be ticked in
|
|
@@ -476,7 +476,7 @@ type ViewsPartsBodyCommon = {
|
|
|
476
476
|
/** The field's name: the body's accessible name, a sheet's title. */
|
|
477
477
|
label: string;
|
|
478
478
|
/** The edit is finished: the editor closes and saves what was handed. With no argument it closes as Enter does
|
|
479
|
-
* (the grid
|
|
479
|
+
* (the grid writes and keeps the cell); `"pick"` closes as a pick (a band picked), the same. */
|
|
480
480
|
onDone: (how?: "pick") => void;
|
|
481
481
|
/** It may be emptied: every box cleared is a clear. */
|
|
482
482
|
empty: boolean;
|
|
@@ -579,7 +579,7 @@ export type ViewsValuesBodyProps = {
|
|
|
579
579
|
value: readonly ViewsValueLine[];
|
|
580
580
|
/** Every change as it is made, the whole list each time. A line handed as it was drawn keeps what is stored. */
|
|
581
581
|
onValueChange: (value: readonly ViewsValueLine[]) => void;
|
|
582
|
-
/** The edit is finished: the editor closes as Enter does (the grid
|
|
582
|
+
/** The edit is finished: the editor closes as Enter does (the grid writes and keeps the cell) and saves what was handed. */
|
|
583
583
|
onDone: () => void;
|
|
584
584
|
/** Why a value would be refused, in the app's words, or null when it reads: check each value as it is added or changed. */
|
|
585
585
|
check: (value: string) => string | null;
|
|
@@ -617,7 +617,7 @@ export type ViewsTextBodyProps = {
|
|
|
617
617
|
value: string;
|
|
618
618
|
/** Every change as it is made, the whole text each time. */
|
|
619
619
|
onValueChange: (value: string) => void;
|
|
620
|
-
/** The edit is finished: the editor closes as Enter does (the grid
|
|
620
|
+
/** The edit is finished: the editor closes as Enter does (the grid writes and keeps the cell) and saves what was handed. */
|
|
621
621
|
onDone: () => void;
|
|
622
622
|
/** Why a value would be refused, in the app's words, or null when it reads. The editor checks again at the close. */
|
|
623
623
|
check: (value: string) => string | null;
|
|
@@ -657,7 +657,7 @@ export type ViewsNumberBodyProps = {
|
|
|
657
657
|
/** Every change as it is made: the number, null when emptied, `NaN` for text that reads as no number (a close on it
|
|
658
658
|
* changes nothing); and the unit when it is one of `units`. */
|
|
659
659
|
onValueChange: (value: number | null, unit?: string) => void;
|
|
660
|
-
/** The edit is finished: the editor closes as Enter does (the grid
|
|
660
|
+
/** The edit is finished: the editor closes as Enter does (the grid writes and keeps the cell) and saves what was handed. */
|
|
661
661
|
onDone: () => void;
|
|
662
662
|
/** Why a value would be refused, in the app's words, or null when it reads. The editor checks again at the close. */
|
|
663
663
|
check: (value: number | null, unit?: string) => string | null;
|
|
@@ -1710,7 +1710,7 @@ export type ViewsComponents = {
|
|
|
1710
1710
|
Checkbox: ComponentType<ViewsCheckboxProps>;
|
|
1711
1711
|
Menu: ComponentType<ViewsMenuProps>;
|
|
1712
1712
|
/** @deprecated Read by nothing: the grid's menus are your `Menu` and every list an editor opens is your `Picker`.
|
|
1713
|
-
* Leave it out; it goes
|
|
1713
|
+
* Leave it out; it goes in a later release that breaks something anyway. */
|
|
1714
1714
|
Command?: ViewsCommandParts;
|
|
1715
1715
|
/** Optional: the filter's month draws through it (the date editor opens `DateBody`). Reached without one, it throws
|
|
1716
1716
|
* an error naming it. */
|
|
@@ -5,7 +5,8 @@ export { DEFAULT_DESKTOP_QUERY } from "../internal/phone-line.js";
|
|
|
5
5
|
* The package's own: no entry point exports it. */
|
|
6
6
|
export declare function isDesktopNow(query: string): boolean;
|
|
7
7
|
/** Whether the screen is a desktop, by the provider's `desktopQuery`: true where there is no
|
|
8
|
-
* `matchMedia
|
|
8
|
+
* `matchMedia`; inside a `ScreenForms` twin while the page comes alive, the screen it is told. It follows the query's
|
|
9
|
+
* changes. The package's own: no entry point exports it. */
|
|
9
10
|
export declare function useDesktop(): boolean;
|
|
10
11
|
/** Whether `query` matches the screen, following its changes. `fallback` is the answer where the screen
|
|
11
12
|
* can't be asked (a server render, no `matchMedia`). The package's own: no entry point exports it. */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { useCallback, useSyncExternalStore } from "react";
|
|
2
|
+
import { useCallback, useContext, useSyncExternalStore } from "react";
|
|
3
|
+
import { ScreenTold } from "../internal/screen-forms.js";
|
|
3
4
|
import { useViews } from "./context.js";
|
|
4
5
|
export { DEFAULT_DESKTOP_QUERY } from "../internal/phone-line.js";
|
|
5
6
|
function canAsk() {
|
|
@@ -10,7 +11,9 @@ export function isDesktopNow(query) {
|
|
|
10
11
|
}
|
|
11
12
|
export function useDesktop() {
|
|
12
13
|
const { desktopQuery } = useViews();
|
|
13
|
-
|
|
14
|
+
const told = useContext(ScreenTold);
|
|
15
|
+
const desktop = useMediaQuery(desktopQuery, true);
|
|
16
|
+
return told ? told === "computer" : desktop;
|
|
14
17
|
}
|
|
15
18
|
export function useMediaQuery(query, fallback) {
|
|
16
19
|
const subscribe = useCallback((onChange) => {
|