viewkitjs 0.33.0 → 0.34.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 +29 -0
- package/package.json +1 -1
- package/views/dist/contract.d.ts +20 -10
- package/views/dist/contract.js +37 -3
- package/views/dist/controls/alert/alert.js +2 -1
- package/views/dist/controls/alert-dialog/alert-dialog.js +3 -2
- package/views/dist/controls/bulk-bar/bulk-bar.js +25 -22
- package/views/dist/controls/controls.d.ts +2 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/customize/customize.js +8 -6
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -2
- package/views/dist/controls/customize/map-customize-body.js +3 -2
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
- package/views/dist/controls/date-editor/date-editor.js +13 -7
- package/views/dist/controls/date-editor/map-calendar.js +2 -0
- package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
- package/views/dist/controls/date-editor/map-date-body.js +7 -3
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +2 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +3 -1
- package/views/dist/controls/filter-editor/parts.js +7 -6
- package/views/dist/controls/group-editor/group-editor.js +2 -1
- package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
- package/views/dist/controls/group-editor/map-group-body.js +5 -1
- package/views/dist/controls/input/input.js +2 -1
- package/views/dist/controls/internal/head-button.d.ts +9 -0
- package/views/dist/controls/internal/head-button.js +13 -0
- package/views/dist/controls/internal/panel-controls.d.ts +13 -5
- package/views/dist/controls/internal/panel-controls.js +53 -10
- package/views/dist/controls/menu/menu.d.ts +2 -1
- package/views/dist/controls/menu/menu.js +2 -2
- package/views/dist/controls/modal/modal.js +5 -3
- package/views/dist/controls/number-editor/map-number-body.js +5 -1
- package/views/dist/controls/number-editor/number-editor.js +6 -6
- package/views/dist/controls/pane/map-pane.d.ts +3 -0
- package/views/dist/controls/pane/map-pane.js +5 -0
- package/views/dist/controls/picker/map-fields-body.js +25 -1
- package/views/dist/controls/picker.css +10 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +2 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +7 -3
- package/views/dist/controls/quick-filters/quick-filters.js +5 -3
- package/views/dist/controls/setting-row/looks.js +5 -5
- package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
- package/views/dist/controls/setting-row/setting-row.js +3 -1
- package/views/dist/controls/setting-row.css +3 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +3 -1
- package/views/dist/controls/sheet/bottom-sheet.js +2 -2
- package/views/dist/controls/sort-editor/map-sort-body.js +4 -4
- package/views/dist/controls/text-editor/map-text-body.js +5 -1
- package/views/dist/controls/text-editor/text-editor.js +5 -4
- package/views/dist/controls/toolbar/toolbar.d.ts +4 -2
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/controls/views-list/map-view-menu.d.ts +3 -2
- package/views/dist/controls/views-list/map-view-menu.js +6 -2
- package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
- package/views/dist/controls/views-list/map-views-list-body.js +6 -5
- package/views/dist/controls/views-list/view-menu.js +3 -4
- package/views/dist/controls/views-list/views-list.js +2 -2
- package/views/dist/editors/EditorPanel.js +3 -3
- package/views/dist/list/list.d.ts +6 -2
- package/views/dist/list/list.js +6 -2
- package/views/dist/list/parts.js +3 -2
- package/views/dist/list/toolbar.js +9 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -0
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +4 -0
- package/views/dist/panels/react/toolbar/Toolbar.js +8 -3
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -2
- package/views/dist/panels/react/toolbar/context.d.ts +21 -0
- package/views/dist/panels/react/toolbar/context.js +4 -0
- package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
- package/views/dist/panels/react/toolbar/pane-host.js +17 -0
- package/views/dist/panels/react/toolbar/panel-part.js +3 -2
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/provider/ViewsProvider.d.ts +4 -3
- package/views/dist/provider/components.d.ts +34 -5
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +97 -78
- package/views/dist/styles.unlayered.css +97 -78
- package/views/docs/contract.md +62 -6
- package/views/docs/controls/alert-dialog.md +4 -0
- package/views/docs/controls/alert.md +4 -0
- package/views/docs/controls/bulk-bar.md +4 -0
- package/views/docs/controls/customize.md +3 -1
- package/views/docs/controls/date-editor.md +2 -0
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/group-editor.md +2 -0
- package/views/docs/controls/menu.md +3 -1
- package/views/docs/controls/modal.md +4 -0
- package/views/docs/controls/number-editor.md +2 -0
- package/views/docs/controls/quick-filters.md +3 -1
- package/views/docs/controls/sheet.md +1 -1
- package/views/docs/controls/text-editor.md +2 -0
- package/views/docs/controls/toolbar.md +4 -0
- package/views/docs/controls/views-list.md +2 -0
- package/views/docs/guides/the-provider.md +4 -4
- package/views/docs/reference/controls.md +5 -3
- package/views/docs/reference/list.md +5 -3
- package/views/docs/reference/looks.md +1 -1
- package/views/docs/reference/panels-react.md +6 -5
- package/views/docs/reference/react.md +7 -6
- package/views/docs/reference/views.md +4 -2
- package/views/docs/reshaping.md +16 -5
- package/views/skills/views/SKILL.md +1 -1
|
@@ -5,7 +5,7 @@ import { Icon } from "../internal/icons.js";
|
|
|
5
5
|
import { PhoneHost, phoneMark, usePhone } from "../internal/phone.js";
|
|
6
6
|
import { MENU_LIST_CARD_FRAME } from "../menu-list/looks.js";
|
|
7
7
|
import { usePicker } from "../picker/picker.js";
|
|
8
|
-
import {
|
|
8
|
+
import { PanelHeadButton } from "../internal/head-button.js";
|
|
9
9
|
import { openerAt, useStepReturn } from "../internal/step-return.js";
|
|
10
10
|
import { VIEWS_LIST_ATTRS, viewsListWornOf } from "./looks.js";
|
|
11
11
|
import { listed } from "./rules.js";
|
|
@@ -58,7 +58,7 @@ export function useViewsList(props) {
|
|
|
58
58
|
const placeRoot = React.useCallback((el) => { rootRef.current = el; setRoot(el); }, [setRoot]);
|
|
59
59
|
useStepReturn(rootRef, step && opener ? [openerAt(() => `[role="option"][data-name="${CSS.escape(opener)}"] .o-picker-row-menu`)] : []);
|
|
60
60
|
if (step) {
|
|
61
|
-
const back = _jsx(
|
|
61
|
+
const back = _jsx(PanelHeadButton, { "data-slot": "vk-editor-back", "aria-label": w.back, className: "o-sheet-back", icon: _jsx(Icon, { name: "left" }), onClick: step.onBack });
|
|
62
62
|
return {
|
|
63
63
|
body: _jsx("div", { ref: placeRoot, className: "o-views-list", "data-slot": "vk-views-list", "data-kit": "views-list", "data-views-form": "phone", "data-views-step": "", ...phoneMark(!!screen || small), children: step.body }),
|
|
64
64
|
head: { left: back, children: step.title, right: _jsx("span", {}) },
|
|
@@ -140,9 +140,9 @@ export function EditorPanel({ session, title, anchor, inPlace = false, sheetOnPh
|
|
|
140
140
|
const back = () => stepRef.current?.onBack();
|
|
141
141
|
const actions = views.sheetActions === "head"
|
|
142
142
|
? {
|
|
143
|
-
close: { label: discardLabel, onPress: () => close("escape") },
|
|
144
|
-
...(!savesOnPick && { done: { label: saveLabel, onPress: () => close("enter") } }),
|
|
145
|
-
...(step && { back: { label: backLabel, onPress: back } }),
|
|
143
|
+
close: { label: discardLabel, onPress: () => close("escape"), slot: "vk-editor-close" },
|
|
144
|
+
...(!savesOnPick && { done: { label: saveLabel, onPress: () => close("enter"), slot: "vk-editor-save" } }),
|
|
145
|
+
...(step && { back: { label: backLabel, onPress: back, slot: "vk-editor-back" } }),
|
|
146
146
|
}
|
|
147
147
|
: undefined;
|
|
148
148
|
const sheetTitle = step ? step.title : title;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import type { ListRow, ListSettings } from "viewkitjs/fields/query";
|
|
3
3
|
import type { GridTableProps } from "../grid/chrome/grid-table-props.js";
|
|
4
4
|
import type { ListSave } from "../grid/core/commit-model.js";
|
|
@@ -46,6 +46,10 @@ type ListPropsCommon<Row extends ListRow> = {
|
|
|
46
46
|
menus?: ListMenus<Row>;
|
|
47
47
|
/** Where each of the toolbar's parts stands (`ReadyToolbar`'s `toolbarParts`). */
|
|
48
48
|
toolbarParts?: ToolbarParts;
|
|
49
|
+
/** Where Customize opens on a computer (VK-1026): `"popover"`, the default, at its button; `"pane"`, in the components map's
|
|
50
|
+
* Pane at the list's right edge, under the toolbar and as tall as the grid, the grid in use beside it. The grid then
|
|
51
|
+
* stands in a box of its own, `vk-list-box`, the Pane's. On a phone, its Sheet either way. */
|
|
52
|
+
customizeIn?: "popover" | "pane";
|
|
49
53
|
/** The address carries the open view and what changed. Default true; `false` leaves the address alone (a second list
|
|
50
54
|
* on the same page). */
|
|
51
55
|
link?: boolean;
|
|
@@ -66,5 +70,5 @@ type ListPropsCommon<Row extends ListRow> = {
|
|
|
66
70
|
bulk?: ListBulkBarProps;
|
|
67
71
|
className?: string;
|
|
68
72
|
};
|
|
69
|
-
export declare function List<Row extends ListRow>({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, link, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }: ListProps<Row>): ReactNode;
|
|
73
|
+
export declare function List<Row extends ListRow>({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, customizeIn, link, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }: ListProps<Row>): ReactNode;
|
|
70
74
|
export {};
|
package/views/dist/list/list.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
3
4
|
import { ListBulkBar } from "./bulk-bar.js";
|
|
4
5
|
import { ListGrid } from "./grid.js";
|
|
5
6
|
import { ListRoot } from "./root.js";
|
|
@@ -7,8 +8,11 @@ import { ListToolbar } from "./toolbar.js";
|
|
|
7
8
|
function handed(from) {
|
|
8
9
|
return Object.fromEntries(Object.entries(from).filter(([, value]) => value !== undefined));
|
|
9
10
|
}
|
|
10
|
-
export function List({ id, fields, rows, source, pageSize, save, columns, views, defaults, sortFilter, bar, menus, toolbarParts, link = true, can, onOpenRow, rowHref, rowWritable, onAdd, addItems, quickFilters, toolbar, grid, bulk, className, }) {
|
|
11
|
+
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, }) {
|
|
11
12
|
const toolbarMenus = { ...toolbar?.menus, ...handed({ view: menus?.view, add: menus?.add, more: menus?.more }) };
|
|
12
13
|
const gridMenus = { ...grid?.menus, ...handed({ column: menus?.column, row: menus?.row, group: menus?.group }) };
|
|
13
|
-
|
|
14
|
+
const [box, setBox] = useState(null);
|
|
15
|
+
const inPane = (customizeIn ?? toolbar?.customizeIn) === "pane";
|
|
16
|
+
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)] }) }));
|
|
14
18
|
}
|
package/views/dist/list/parts.js
CHANGED
|
@@ -27,7 +27,8 @@ const samePlaces = (a, b) => a.length === b.length &&
|
|
|
27
27
|
p.words === b[i].words &&
|
|
28
28
|
p.node === undefined &&
|
|
29
29
|
p.className === undefined &&
|
|
30
|
-
p.button === undefined
|
|
30
|
+
p.button === undefined &&
|
|
31
|
+
p.panel === undefined);
|
|
31
32
|
export function applyParts(parts, place, ctx) {
|
|
32
33
|
const given = placesOf(parts, ctx);
|
|
33
34
|
const back = place(given, ctx);
|
|
@@ -42,7 +43,7 @@ export function applyParts(parts, place, ctx) {
|
|
|
42
43
|
seen.add(at.key);
|
|
43
44
|
const part = byKey.get(at.key);
|
|
44
45
|
const line = !one && at.line === "bar" ? 2 : 1;
|
|
45
|
-
const look = { ...(at.className && { className: at.className }), ...(at.button && { button: at.button }) };
|
|
46
|
+
const look = { ...(at.className && { className: at.className }), ...(at.button && { button: at.button }), ...(at.panel && { panel: at.panel }) };
|
|
46
47
|
if (!part)
|
|
47
48
|
return at.node === undefined ? [] : [{ key: at.key, line, side: at.side, words: at.words, node: at.node, ...look }];
|
|
48
49
|
const own = part.words ?? "both";
|
|
@@ -18,6 +18,7 @@ import { ToolbarFilterAdd } from "../panels/react/toolbar/ToolbarFilterAdd.js";
|
|
|
18
18
|
import { ToolbarFilters, foldableFilters } from "../panels/react/toolbar/ToolbarFilters.js";
|
|
19
19
|
import { ToolbarNew } from "../panels/react/toolbar/ToolbarNew.js";
|
|
20
20
|
import { ToolbarOptions } from "../panels/react/toolbar/ToolbarOptions.js";
|
|
21
|
+
import { PaneBox, PaneHost } from "../panels/react/toolbar/pane-host.js";
|
|
21
22
|
import { ToolbarQuickFilters } from "../panels/react/toolbar/ToolbarQuickFilters.js";
|
|
22
23
|
import { ToolbarSave } from "../panels/react/toolbar/ToolbarSave.js";
|
|
23
24
|
import { ToolbarSearch } from "../panels/react/toolbar/ToolbarSearch.js";
|
|
@@ -29,6 +30,9 @@ import { applyParts } from "./parts.js";
|
|
|
29
30
|
import { useList, useListPanel, useListStore } from "./root-base.js";
|
|
30
31
|
import { useListViewsAxis } from "./views-axis.js";
|
|
31
32
|
export function ListToolbar(props) {
|
|
33
|
+
return (_jsx(PaneBox.Provider, { value: props.paneBox ?? null, children: _jsx(ToolbarOfList, { ...props }) }));
|
|
34
|
+
}
|
|
35
|
+
function ToolbarOfList(props) {
|
|
32
36
|
const { views: viewsHanded, viewsLayout, onAdd, addItems, addLabel, fieldEditor, searchPlaceholder, searching, hosts, narrow, className, viewName, onRenameView, onCopyLink, onExport, exportCount, menus, toolbarParts, } = props;
|
|
33
37
|
const storeViews = useListViewsAxis(props.layouts);
|
|
34
38
|
const rootColumns = useList((s) => s.columns);
|
|
@@ -49,9 +53,11 @@ export function ListToolbar(props) {
|
|
|
49
53
|
...(onExport && { onExport }),
|
|
50
54
|
...(exportCount !== undefined && { exportCount }),
|
|
51
55
|
};
|
|
52
|
-
const { icons, messages, conventions } = useViews();
|
|
56
|
+
const { icons, messages, conventions, components } = useViews();
|
|
53
57
|
const desktop = useDesktop();
|
|
54
58
|
const phone = props.phone ?? !desktop;
|
|
59
|
+
const optionsHost = hosts?.options ??
|
|
60
|
+
(props.customizeIn === "pane" && props.paneBox !== undefined && !phone && components.Pane ? PaneHost : undefined);
|
|
55
61
|
const options = useListPanel("options");
|
|
56
62
|
const sortState = useListPanel("sort");
|
|
57
63
|
const filterState = useListPanel("filter");
|
|
@@ -204,7 +210,7 @@ export function ListToolbar(props) {
|
|
|
204
210
|
icon: _jsx(Edit, { className: "h-4 w-4" }),
|
|
205
211
|
onSelect: () => options.onOpenChange(true),
|
|
206
212
|
},
|
|
207
|
-
node: (_jsx(ToolbarOptions, { ...inputs, view: view, viewFoot: !footHere ? "none" : view ? undefined : "kit", footClear: footHere && clearable ? clear("options") : undefined, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host:
|
|
213
|
+
node: (_jsx(ToolbarOptions, { ...inputs, view: view, viewFoot: !footHere ? "none" : view ? undefined : "kit", footClear: footHere && clearable ? clear("options") : undefined, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: optionsHost, ...customizeOwn })),
|
|
208
214
|
},
|
|
209
215
|
...(quickNode
|
|
210
216
|
? [
|
|
@@ -363,7 +369,7 @@ export function ListToolbar(props) {
|
|
|
363
369
|
{
|
|
364
370
|
key: "options",
|
|
365
371
|
side: "end",
|
|
366
|
-
node: (_jsx(ToolbarOptions, { ...inputs, view: view, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host:
|
|
372
|
+
node: (_jsx(ToolbarOptions, { ...inputs, view: view, fieldEditor: fieldEditor, onClear: view ? view.onReset : clear("options"), open: options.open, onOpenChange: options.onOpenChange, page: options.page, onPageChange: options.onPageChange, host: optionsHost, ...customizeOwn })),
|
|
367
373
|
},
|
|
368
374
|
{ key: "new", side: "end", node: _jsx(ToolbarNew, { onAdd: onAdd, items: newItems, label: addLabel }) },
|
|
369
375
|
];
|
|
@@ -7,6 +7,7 @@ import type { CollectionViewState } from "../../view-state.js";
|
|
|
7
7
|
import type { CollectionViewsInput, ViewsLayout } from "../../views-row/model.js";
|
|
8
8
|
import type { PanelFieldEditor } from "../field-editor.js";
|
|
9
9
|
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
10
|
+
import type { ToolbarPanelPlace } from "./context.js";
|
|
10
11
|
import type { ToolbarMore, ToolbarPartButton } from "./Toolbar.js";
|
|
11
12
|
/** The toolbar's menus as data (VK-741): each handed its default items, each item keyed, and handing back the items it shows.
|
|
12
13
|
* `view`, a view's menu, handed the view too: the rows an option hands (`menu`, Edit view… among them) and the menu a views
|
|
@@ -34,6 +35,9 @@ export type ToolbarPartPlace = {
|
|
|
34
35
|
node?: ReactNode;
|
|
35
36
|
className?: string;
|
|
36
37
|
button?: ToolbarPartButton;
|
|
38
|
+
/** Where what it opens hangs at its button (VK-994): its popover's `side`, `align` and `offset`. Absent, toward its side
|
|
39
|
+
* of its line, 8 px below it. */
|
|
40
|
+
panel?: ToolbarPanelPlace;
|
|
37
41
|
};
|
|
38
42
|
/** Which form's parts these are. */
|
|
39
43
|
export type ToolbarPartsContext = {
|
|
@@ -69,6 +73,15 @@ export type ReadyToolbarProps<Row> = SettingsPanelsInput<Row> & {
|
|
|
69
73
|
filter?: ToolbarPanelHost;
|
|
70
74
|
quick?: ToolbarPanelHost;
|
|
71
75
|
};
|
|
76
|
+
/** Where Customize opens on a computer (VK-1026): `"popover"`, the default, at its button; `"pane"`, in the components map's
|
|
77
|
+
* `Pane` (`CONTROLS.Pane`), at the right edge of `paneBox` under the toolbar, as tall as the list (where the list has a
|
|
78
|
+
* height of its own: a page that scrolls whole makes it as tall as every row), the list in use beside it. On a phone Customize keeps its Sheet either way. A map with no `Pane`, or an app's own `hosts.options`, keeps
|
|
79
|
+
* theirs. */
|
|
80
|
+
customizeIn?: "popover" | "pane";
|
|
81
|
+
/** The list's box the Pane stands in, with `customizeIn: "pane"`: positioned, holding the grid (which scrolls inside it)
|
|
82
|
+
* under the toolbar, never scrolling itself. Null until it is on the page; not handed, Customize opens in the popover.
|
|
83
|
+
* The ready `<List>` hands its own. */
|
|
84
|
+
paneBox?: HTMLElement | null;
|
|
72
85
|
/** Quick filters (VK-563): the fields offered, the hold and its writes. Handed, their button stands on the row. */
|
|
73
86
|
quickFilters?: QuickFiltersConfig;
|
|
74
87
|
/** The quick filters' panel open, when the app holds it (VK-566), so the reminder at its list's foot
|
|
@@ -2,6 +2,7 @@ import { type ComponentType, type ReactNode } from "react";
|
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
3
|
import type { ViewsMenuItem } from "../../../provider/components.js";
|
|
4
4
|
import { type ToolbarPlacement } from "../../toolbar/model.js";
|
|
5
|
+
import { type ToolbarPanelPlace } from "./context.js";
|
|
5
6
|
/** ⋯ as data (VK-741): the folded parts' rows, each keyed by its part, and which line's ⋯ they are in. */
|
|
6
7
|
export type ToolbarMore = (items: ViewsMenuItem[], ctx: {
|
|
7
8
|
line: "row" | "bar";
|
|
@@ -19,6 +20,9 @@ export type ToolbarPart = ToolbarPlacement & {
|
|
|
19
20
|
className?: string;
|
|
20
21
|
/** Drawn for every toolbar button the part draws, in place of the app's `ToolbarButton`, handed the same props (VK-984). */
|
|
21
22
|
button?: ToolbarPartButton;
|
|
23
|
+
/** Where what it opens hangs at its button (VK-994): its popover's side, align and offset. Absent, toward the part's
|
|
24
|
+
* side of its line, 8 px below it. */
|
|
25
|
+
panel?: ToolbarPanelPlace;
|
|
22
26
|
};
|
|
23
27
|
/** A place's own button (VK-984): a `ToolbarButton` of the app's, for one place. */
|
|
24
28
|
export type ToolbarPartButton = ComponentType<ViewsToolbarButtonProps>;
|
|
@@ -29,6 +29,7 @@ export function Toolbar({ parts, phone, narrow, narrowBelow = TOOLBAR_NARROW_BEL
|
|
|
29
29
|
...(part.foot !== undefined && { foot: part.foot }),
|
|
30
30
|
...(part.className && { className: part.className }),
|
|
31
31
|
...(part.button && { button: part.button }),
|
|
32
|
+
...(part.panel && { panel: part.panel }),
|
|
32
33
|
},
|
|
33
34
|
]));
|
|
34
35
|
if (fold) {
|
|
@@ -37,13 +38,14 @@ export function Toolbar({ parts, phone, narrow, narrowBelow = TOOLBAR_NARROW_BEL
|
|
|
37
38
|
}
|
|
38
39
|
return (_jsx(ToolbarRadioContext.Provider, { value: radio, children: _jsx("div", { ref: box, "data-slot": "vk-toolbar", "data-form": form, className: cx("flex w-full flex-col", form === "row" ? "gap-1" : "gap-2", className), children: lines.map((line) => (_jsx(Line, { line: line, form: form, nodes: nodes, placed: placed }, line.kind))) }) }));
|
|
39
40
|
}
|
|
41
|
+
const sideOf = (line, key) => (line.end.some((slot) => slot.key === key) ? "end" : "start");
|
|
40
42
|
function useLineName(kind) {
|
|
41
43
|
const { messages } = useViews();
|
|
42
44
|
return messages({ key: kind === "bar" || kind === "below" ? "views.panels.toolbar-bar" : "views.panels.toolbar-row" });
|
|
43
45
|
}
|
|
44
46
|
function Line({ line, form, nodes, placed }) {
|
|
45
47
|
const name = useLineName(line.kind);
|
|
46
|
-
const draw = (slots) => slots.map((slot) => (_jsx(ToolbarSlotContext.Provider, { value: { form, fill: slot.fill, size: line.size, line: line.kind, ...NOT_FOLDING, appFrame: false, ...placed.get(slot.key) }, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }, slot.key)));
|
|
48
|
+
const draw = (slots) => slots.map((slot) => (_jsx(ToolbarSlotContext.Provider, { value: { form, fill: slot.fill, size: line.size, line: line.kind, ...NOT_FOLDING, appFrame: false, side: sideOf(line, slot.key), ...placed.get(slot.key) }, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }, slot.key)));
|
|
47
49
|
const mark = { "data-slot": "vk-toolbar-line", "data-line": line.kind, role: "toolbar", "aria-label": name };
|
|
48
50
|
if (line.kind === "main" && form === "row") {
|
|
49
51
|
return (_jsxs("div", { ...mark, "data-toolbar-row": true, className: "relative flex min-h-9 items-center empty:hidden", children: [_jsx("div", { className: "flex min-w-0 flex-1 items-center gap-2", children: draw(line.start) }), line.end.length > 0 && (_jsx("div", { "data-slot": "vk-toolbar-cluster", "data-toolbar-cluster": true, className: "absolute inset-y-0 right-0 flex items-center gap-1 pl-8", style: { background: CLUSTER_FADE }, children: draw(line.end) }))] }));
|
|
@@ -96,6 +98,7 @@ function FoldLine({ line, form, nodes, placed, menus, more: reshape, search, })
|
|
|
96
98
|
more,
|
|
97
99
|
search: slot.search ? search : null,
|
|
98
100
|
appFrame: false,
|
|
101
|
+
side: sideOf(line, folded && state.moreAfter ? state.moreAfter : slot.key),
|
|
99
102
|
...placed.get(slot.key),
|
|
100
103
|
}, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }) }, slot.key));
|
|
101
104
|
if (slot.key !== state.moreAfter)
|
|
@@ -104,11 +107,13 @@ function FoldLine({ line, form, nodes, placed, menus, more: reshape, search, })
|
|
|
104
107
|
const menu = state.folded.has(s.key) ? menus.get(s.key) : undefined;
|
|
105
108
|
return menu ? [{ key: s.key, ...menu }] : [];
|
|
106
109
|
});
|
|
107
|
-
const align = line
|
|
110
|
+
const align = sideOf(line, slot.key);
|
|
108
111
|
return [itemNode, _jsx(Overflow, { anchor: more, rows: rows, reshape: reshape && ((items) => reshape(items, { line: line.kind === "bar" || line.kind === "below" ? "bar" : "row" })), size: line.size, form: form, align: align }, "vk-overflow")];
|
|
109
112
|
});
|
|
110
113
|
};
|
|
111
|
-
return (_jsxs("div", { ref: setElement, "data-slot": "vk-toolbar-line", "data-line": line.kind, role: "toolbar", "aria-label": name, ...(line.kind === "main" ? { "data-toolbar-row": "" } : {}), className: cx("flex min-w-0 items-center", phone
|
|
114
|
+
return (_jsxs("div", { ref: setElement, "data-slot": "vk-toolbar-line", "data-line": line.kind, role: "toolbar", "aria-label": name, ...(line.kind === "main" ? { "data-toolbar-row": "" } : {}), className: cx("flex min-w-0 items-center", phone
|
|
115
|
+
? "gap-1.5"
|
|
116
|
+
: "gap-(--vk-toolbar-line-gap,calc(var(--spacing)*2)) border-b-(length:--vk-toolbar-line-w,1px) border-(color:--vk-border-subtle) py-(--vk-toolbar-line-py,calc(var(--spacing)*2.5))"), children: [draw(line.start), !searchTakesLine && _jsx("span", { "data-toolbar-spacer": true, "aria-hidden": true, className: "min-w-0 flex-1" }), draw(line.end)] }));
|
|
112
117
|
}
|
|
113
118
|
const closingFirst = (items, setOpen) => items.map((item) => ({
|
|
114
119
|
...item,
|
|
@@ -5,7 +5,7 @@ import { advancedFiltersOf, followAdvancedKeys, } from "../../../filters/filter-
|
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
6
6
|
import { FilterEditorHost } from "../filter/FilterEditor.js";
|
|
7
7
|
import { useSheetPanels } from "../panel-sheet.js";
|
|
8
|
-
import { useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
8
|
+
import { usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
9
9
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
10
10
|
export function ToolbarAdvancedFilters({ filterTree, host, }) {
|
|
11
11
|
const phone = useSheetPanels();
|
|
@@ -65,6 +65,7 @@ export function AdvancedFilterPill({ filterTree, at, count, aside = false, host:
|
|
|
65
65
|
const name = messages({ key: "views.panels.advanced-filter" });
|
|
66
66
|
const openAtPress = useRef(false);
|
|
67
67
|
const anchor = foldedAt ?? pill;
|
|
68
|
+
const hangs = usePanelPlace("end");
|
|
68
69
|
const close = (focus = true) => {
|
|
69
70
|
panel.onOpenChange(false);
|
|
70
71
|
if (focus)
|
|
@@ -81,5 +82,5 @@ export function AdvancedFilterPill({ filterTree, at, count, aside = false, host:
|
|
|
81
82
|
return (_jsxs("span", { "data-slot": "vk-toolbar-advanced-filter", "data-open": (slot.fold || foldedAt) && panel.open ? "" : undefined, hidden: foldedAt ? true : undefined, className: "relative inline-flex shrink-0 items-center", children: [aside ? (_jsx(Tooltip, { content: messages({ key: "views.panels.advanced-filter-set-aside" }), side: "bottom", children: _jsx("span", { className: "inline-flex min-w-0", children: button }) })) : (button), Host ? (_jsx(Host, { open: panel.open, onOpenChange: panel.onOpenChange, title: name, children: content })) : (_jsx(Popover, { open: panel.open, onOpenChange: (next, details) => {
|
|
82
83
|
if (!next)
|
|
83
84
|
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
84
|
-
}, anchor: anchor,
|
|
85
|
+
}, anchor: anchor, ...hangs, chrome: "panel", className: "w-fit max-w-[calc(100vw-2rem)]", panelData: { "data-slot": "vk-toolbar-advanced-filter-panel" }, children: content }))] }));
|
|
85
86
|
}
|
|
@@ -5,7 +5,7 @@ import { useViews } from "../../../provider/context.js";
|
|
|
5
5
|
import { listedFieldsOf } from "../../settings/filter-groups.js";
|
|
6
6
|
import { FilterFieldList } from "../filter/FilterFieldList.js";
|
|
7
7
|
import { useSheetPanels } from "../panel-sheet.js";
|
|
8
|
-
import { useFoldAnchor, useToolbarPanel } from "./context.js";
|
|
8
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel } from "./context.js";
|
|
9
9
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
10
10
|
import { useFilterAdd } from "./use-filter-add.js";
|
|
11
11
|
export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, }) {
|
|
@@ -15,6 +15,7 @@ export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange,
|
|
|
15
15
|
const fields = useToolbarPanel("filter-add", open === undefined || !onOpenChange ? undefined : { open, onOpenChange });
|
|
16
16
|
const box = useRef(null);
|
|
17
17
|
const hangsAt = useFoldAnchor(box);
|
|
18
|
+
const hangs = usePanelPlace("start");
|
|
18
19
|
const atPress = useRef(false);
|
|
19
20
|
const { refusal, reason, onPick } = useFilterAdd({
|
|
20
21
|
filterTree,
|
|
@@ -46,5 +47,5 @@ export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange,
|
|
|
46
47
|
const why = details?.reason;
|
|
47
48
|
if (!next && why !== "outside-press" && why !== "focus-out")
|
|
48
49
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
49
|
-
}, anchor: hangsAt.anchor,
|
|
50
|
+
}, anchor: hangsAt.anchor, ...hangs, chrome: "menu", panelData: { "data-slot": "vk-toolbar-filters-panel" }, children: list }))] }));
|
|
50
51
|
}
|
|
@@ -9,7 +9,7 @@ import { asideFilterWords, barFilterWords } from "../../toolbar/filter-words.js"
|
|
|
9
9
|
import { fieldOfRule, heldStands, relationOf, samePath, useEditorCtx, } from "../filter/editor-ctx.js";
|
|
10
10
|
import { FilterFieldList } from "../filter/FilterFieldList.js";
|
|
11
11
|
import { useSheetPanels } from "../panel-sheet.js";
|
|
12
|
-
import { useFoldAnchor, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
12
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
13
13
|
import { AdvancedFilterPill } from "./ToolbarAdvancedFilters.js";
|
|
14
14
|
import { ToolbarAsideFilter } from "./ToolbarAsideFilter.js";
|
|
15
15
|
import { ToolbarBarFilter } from "./ToolbarBarFilter.js";
|
|
@@ -86,6 +86,7 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
86
86
|
const addBox = useRef(null);
|
|
87
87
|
const fields = useToolbarPanel("filters", openIn === undefined || !onOpenChangeIn ? undefined : { open: openIn, onOpenChange: onOpenChangeIn });
|
|
88
88
|
const hangsAt = useFoldAnchor(addBox);
|
|
89
|
+
const hangs = usePanelPlace("start");
|
|
89
90
|
const fieldsAtPress = useRef(false);
|
|
90
91
|
const leaving = useRef(null);
|
|
91
92
|
const leave = (from) => {
|
|
@@ -281,7 +282,7 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
281
282
|
const why = details?.reason;
|
|
282
283
|
if (!next && why !== "outside-press" && why !== "focus-out")
|
|
283
284
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
284
|
-
}, anchor: hangsAt.anchor,
|
|
285
|
+
}, anchor: hangsAt.anchor, ...hangs, chrome: "menu", panelData: { "data-slot": "vk-toolbar-filters-panel" }, children: _jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: onPick, onDone: () => {
|
|
285
286
|
fields.onOpenChange(false);
|
|
286
287
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
287
288
|
} }) }))] }, "add"));
|
|
@@ -7,7 +7,7 @@ import { useSheetDrawsClose, useSheetPanels } from "../panel-sheet.js";
|
|
|
7
7
|
import { SortEditorHost, useSortEditorHost } from "../sort/SortEditor.js";
|
|
8
8
|
import { SortFieldList } from "../sort/SortFieldList.js";
|
|
9
9
|
import { placePart } from "../../../atoms/frame-parts.js";
|
|
10
|
-
import { useFoldAnchor, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
10
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
11
11
|
import { ToolbarPanelPart } from "./panel-part.js";
|
|
12
12
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
13
13
|
export function ToolbarSortPill(props) {
|
|
@@ -26,6 +26,7 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
26
26
|
const pill = useRef(null);
|
|
27
27
|
const add = useRef(null);
|
|
28
28
|
const hangsAt = useFoldAnchor(pill);
|
|
29
|
+
const hangs = usePanelPlace("start");
|
|
29
30
|
const named = sortRulesLabel(sorts);
|
|
30
31
|
const asideOnly = !named && (sorts.setAside?.length ?? 0) > 0;
|
|
31
32
|
const places = openSortPlaces(sorts);
|
|
@@ -75,7 +76,7 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
75
76
|
: undefined, popup: "dialog", open: panel.open && opens.at === "pill", onPointerDown: pressStart("pill"), onClick: press({ what: named || asideOnly ? "editor" : "fields", at: "pill", addSort: asideOnly || !addAfter }), children: named && !row ? (_jsxs(_Fragment, { children: [messages({ key: "views.panels.sorted-by" }), " ", _jsx("b", { children: named.first })] })) : (name) }), addAfter && named && can && (_jsx("span", { "data-slot": "vk-toolbar-sort-add", className: "inline-flex", children: _jsx(ToolbarButton, { ref: add, part: "sort-add", icon: _jsx(Plus, { className: "h-4 w-4 shrink-0" }), label: messages({ key: "views.panels.sort-add-one" }), word: null, popup: "dialog", open: panel.open && opens.at === "add", onPointerDown: pressStart("add"), onClick: press({ what: "fields", at: "add" }) }) })), Host ? (_jsx(Host, { open: panel.open, onOpenChange: panel.onOpenChange, title: name, children: content })) : (_jsx(Popover, { open: panel.open, onOpenChange: (next, details) => {
|
|
76
77
|
if (!next)
|
|
77
78
|
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
78
|
-
}, anchor: hangsAt.hidden ? hangsAt.anchor : opens.at === "add" ? add : pill,
|
|
79
|
+
}, anchor: hangsAt.hidden ? hangsAt.anchor : opens.at === "add" ? add : pill, ...hangs, chrome: "menu", panelData: { "data-slot": "vk-toolbar-sort-panel" }, children: content }))] }));
|
|
79
80
|
}
|
|
80
81
|
function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host }) {
|
|
81
82
|
const { icons, messages } = useViews();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode, type RefObject, type ComponentType } from "react";
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
|
+
import type { ViewsAlign, ViewsSide } from "../../../provider/components.js";
|
|
3
4
|
import type { ToolbarForm, ToolbarLine } from "../../toolbar/model.js";
|
|
4
5
|
/** Where a part stands: the toolbar's form, whether it fills its line, its buttons' size, and its line's kind.
|
|
5
6
|
* In the fold arrangement (`fold`), also how far its line gave way: whether its words turned to its icon
|
|
@@ -40,6 +41,26 @@ export type ToolbarSlotState = {
|
|
|
40
41
|
/** Its place's own button (`ToolbarPartPlace.button`, VK-984), drawn for every toolbar button the part draws, in place of
|
|
41
42
|
* your `ToolbarButton`, handed the same props. */
|
|
42
43
|
button?: ComponentType<ViewsToolbarButtonProps>;
|
|
44
|
+
/** Its side of its line (VK-994), folded into ⋯ ⋯'s side: what it opens hangs toward it. Absent outside ViewKit's
|
|
45
|
+
* `Toolbar`. */
|
|
46
|
+
side?: "start" | "end";
|
|
47
|
+
/** Its place's own placement for what it opens (`ToolbarPartPlace.panel`, VK-994). */
|
|
48
|
+
panel?: ToolbarPanelPlace;
|
|
49
|
+
};
|
|
50
|
+
/** Where a part's popover hangs at its button (VK-994): the popover's `side`, `align` and `sideOffset` (`offset`). */
|
|
51
|
+
export type ToolbarPanelPlace = {
|
|
52
|
+
side?: ViewsSide;
|
|
53
|
+
align?: ViewsAlign;
|
|
54
|
+
offset?: number;
|
|
55
|
+
};
|
|
56
|
+
/** Where a part's popover hangs: its place's own `panel` first; else toward its side of its line, on the end side
|
|
57
|
+
* aligned to its button's end, on the start side to its start; outside ViewKit's `Toolbar`, `own`, as it always hung.
|
|
58
|
+
* 8 px below its button unless its place says. Read from where it stands, never from whether it is open, so a closing
|
|
59
|
+
* panel keeps its side. */
|
|
60
|
+
export declare function usePanelPlace(own: ViewsAlign): {
|
|
61
|
+
side?: ViewsSide;
|
|
62
|
+
align: ViewsAlign;
|
|
63
|
+
sideOffset: number;
|
|
43
64
|
};
|
|
44
65
|
/** The fold arrangement's part of a slot, for a line that doesn't fold. */
|
|
45
66
|
export declare const NOT_FOLDING: {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, createElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, } from "react";
|
|
3
3
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
4
|
+
export function usePanelPlace(own) {
|
|
5
|
+
const { side, panel } = useToolbarSlot();
|
|
6
|
+
return { ...(panel?.side && { side: panel.side }), align: panel?.align ?? side ?? own, sideOffset: panel?.offset ?? 8 };
|
|
7
|
+
}
|
|
4
8
|
export const NOT_FOLDING = {
|
|
5
9
|
fold: false,
|
|
6
10
|
iconAlone: false,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
3
|
+
/** The list's box the Pane stands in: positioned, holding the grid under the toolbar. Null until it is on the page. */
|
|
4
|
+
export declare const PaneBox: import("react").Context<HTMLElement | null>;
|
|
5
|
+
/** A toolbar panel in the map's `Pane`, in the box `PaneBox` holds. Drawn only where the map has a `Pane`. */
|
|
6
|
+
export declare function PaneHost({ open, onOpenChange, title, opener, children }: ComponentProps<ToolbarPanelHost>): ReactNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useLayoutEffect, useState } from "react";
|
|
4
|
+
import { useViews } from "../../../provider/context.js";
|
|
5
|
+
export const PaneBox = createContext(null);
|
|
6
|
+
export function PaneHost({ open, onOpenChange, title, opener, children }) {
|
|
7
|
+
const { Pane } = useViews().components;
|
|
8
|
+
const box = useContext(PaneBox);
|
|
9
|
+
const [from, setFrom] = useState(null);
|
|
10
|
+
useLayoutEffect(() => {
|
|
11
|
+
if (open)
|
|
12
|
+
setFrom(opener?.current ?? null);
|
|
13
|
+
}, [open, opener]);
|
|
14
|
+
if (!Pane)
|
|
15
|
+
return null;
|
|
16
|
+
return (_jsx(Pane, { open: open, onOpenChange: onOpenChange, container: box, opener: from, label: title, children: children }));
|
|
17
|
+
}
|
|
@@ -4,7 +4,7 @@ import { useEffect, useRef } from "react";
|
|
|
4
4
|
import { useViews } from "../../../provider/context.js";
|
|
5
5
|
import { PanelSheet, useSheetDrawsClose, useSheetPanels } from "../panel-sheet.js";
|
|
6
6
|
import { placePart } from "../../../atoms/frame-parts.js";
|
|
7
|
-
import { useFoldAnchor, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
7
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
8
8
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
9
9
|
export function ToolbarPanelPart({ panelKey, slot, part: ownPart, icon, label, word, count, onClear, dot, changed, open: openIn, onOpenChange: onOpenChangeIn, host: Host, popoverClassName, words, more, empty, disabled, disabledReason, sheetActions, sheetTitle, onSheetEscape, children, }) {
|
|
10
10
|
const { components } = useViews();
|
|
@@ -16,6 +16,7 @@ export function ToolbarPanelPart({ panelKey, slot, part: ownPart, icon, label, w
|
|
|
16
16
|
const held = useToolbarPanel(panelKey, openIn === undefined || !onOpenChangeIn ? undefined : { open: openIn, onOpenChange: onOpenChangeIn });
|
|
17
17
|
const { open, onOpenChange } = held;
|
|
18
18
|
const hangsAt = useFoldAnchor(anchor);
|
|
19
|
+
const hangs = usePanelPlace("end");
|
|
19
20
|
const openAtPress = useRef(false);
|
|
20
21
|
const focusBack = useRef(false);
|
|
21
22
|
const close = () => {
|
|
@@ -44,7 +45,7 @@ export function ToolbarPanelPart({ panelKey, slot, part: ownPart, icon, label, w
|
|
|
44
45
|
const reason = details?.reason;
|
|
45
46
|
if (!next && reason !== "outside-press" && reason !== "focus-out")
|
|
46
47
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
47
|
-
}, anchor: hangsAt.anchor,
|
|
48
|
+
}, anchor: hangsAt.anchor, ...hangs, chrome: "menu", className: popoverClassName, panelData: { "data-slot": `${slot}-panel` }, children: _jsx(PanelBody, { render: children, args: { fill: false, close, closeButton: true } }) }))] }));
|
|
48
49
|
}
|
|
49
50
|
function PanelBody({ render, args }) {
|
|
50
51
|
return render(args);
|
|
@@ -31,7 +31,7 @@ export type { ToolbarMore, 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";
|
|
34
|
-
export type { ToolbarSlotState } from "./react/toolbar/context.js";
|
|
34
|
+
export type { ToolbarPanelPlace, ToolbarSlotState } from "./react/toolbar/context.js";
|
|
35
35
|
export { ToolbarSearch } from "./react/toolbar/ToolbarSearch.js";
|
|
36
36
|
export { ToolbarNew } from "./react/toolbar/ToolbarNew.js";
|
|
37
37
|
export { ToolbarViews } from "./react/toolbar/ToolbarViews.js";
|
|
@@ -69,9 +69,10 @@ export type ViewsProviderProps = {
|
|
|
69
69
|
* while rendering; until the first read a date that needs it draws its full form. A moment you hand is kept as it is:
|
|
70
70
|
* hand a new one to move it. */
|
|
71
71
|
now?: Date;
|
|
72
|
-
/** Which of your own controls ViewKit's panels draw inside them (VK-1013): `true` for all
|
|
73
|
-
* `Select`, `Menu`, `Popover` and `
|
|
74
|
-
*
|
|
72
|
+
/** Which of your own controls ViewKit's panels and field editors draw inside them (VK-1013, VK-1021): `true` for all six, or
|
|
73
|
+
* the names among `Button`, `Select`, `Menu`, `Popover`, `Input` and `Calendar` (the date editor's month; the filter's range
|
|
74
|
+
* calendar reads your `Calendar` whatever this says). Each is handed the map's props and the part's `data-slot` and
|
|
75
|
+
* `data-key`. A control of `CONTROLS`' stays ViewKit's whatever this says. Absent, they draw ViewKit's own, as before. */
|
|
75
76
|
panelControls?: boolean | readonly PanelControlName[];
|
|
76
77
|
children: ReactNode;
|
|
77
78
|
};
|
|
@@ -401,7 +401,9 @@ export type ViewsLinksBodyProps = {
|
|
|
401
401
|
/** In the phone's sheet: the step of your own you stand on (a link's roles), or `null` once you are back. */
|
|
402
402
|
onStepChange?: (step: ViewsBodyStep | null) => void;
|
|
403
403
|
};
|
|
404
|
-
/** A calendar over ISO days (`YYYY-MM-DD`) and months (`YYYY-MM`); the app's date library stays its own.
|
|
404
|
+
/** A calendar over ISO days (`YYYY-MM-DD`) and months (`YYYY-MM`); the app's date library stays its own. The filter's range
|
|
405
|
+
* calendar draws it as it is; inside the field editors (VK-1021) it draws the date editor's month, its head and its days, only
|
|
406
|
+
* where the provider's `panelControls` names `Calendar`. */
|
|
405
407
|
export type ViewsCalendarProps = {
|
|
406
408
|
value: string | null;
|
|
407
409
|
onChange: (day: string | null) => void;
|
|
@@ -419,6 +421,9 @@ export type ViewsCalendarProps = {
|
|
|
419
421
|
* its week as this locale does; an adapter may ignore it and keep its calendar's own. */
|
|
420
422
|
locale: string;
|
|
421
423
|
className?: string;
|
|
424
|
+
/** The part's public name where ViewKit names it (VK-1021: `vk-calendar`, the date editor's month under the provider's
|
|
425
|
+
* `panelControls`): draw it on your calendar's root as its `data-slot`. */
|
|
426
|
+
"data-slot"?: string;
|
|
422
427
|
};
|
|
423
428
|
/** A quick pick a date body offers: a day the editor names, or `none`, which empties the field. `next-monday` is the
|
|
424
429
|
* Monday after today (a week on when today is one); `in-a-week` is a week from today (today + 7 on the
|
|
@@ -684,6 +689,9 @@ export type ViewsCollapseProps = {
|
|
|
684
689
|
export type ViewsSheetAction = {
|
|
685
690
|
label: string;
|
|
686
691
|
onPress: () => void;
|
|
692
|
+
/** The action's public name (VK-1021): `vk-editor-close`, `vk-editor-save` or `vk-editor-back` on an editor panel's ✕, ✓
|
|
693
|
+
* and Back. Draw it on your button as its `data-slot`. */
|
|
694
|
+
slot?: string;
|
|
687
695
|
};
|
|
688
696
|
/** The editor panel's ✕ and ✓. `close` throws the edit away, as a swipe does; `done` closes it as
|
|
689
697
|
* done, and is absent where the body saves on its pick (a pick of one), which needs no ✓. A toolbar panel's sheet
|
|
@@ -1547,7 +1555,8 @@ export type ViewsSelectItem = {
|
|
|
1547
1555
|
level?: ViewsSelectItem[];
|
|
1548
1556
|
};
|
|
1549
1557
|
/** The components map's `Select` (VK-1013): pick one value, or several, from a list. ViewKit's panels draw it under the
|
|
1550
|
-
* provider's `panelControls` for the boxes that pick (the sort's field and direction, the filter's field, way and choices
|
|
1558
|
+
* provider's `panelControls` for the boxes that pick (the sort's field and direction, the filter's field, way and choices, New
|
|
1559
|
+
* view's columns). */
|
|
1551
1560
|
export type ViewsSelectProps = {
|
|
1552
1561
|
items: ViewsSelectItem[];
|
|
1553
1562
|
/** One value, several (with `multiple`), or none. */
|
|
@@ -1571,8 +1580,9 @@ export type ViewsSelectProps = {
|
|
|
1571
1580
|
"data-slot"?: string;
|
|
1572
1581
|
"data-key"?: string;
|
|
1573
1582
|
};
|
|
1574
|
-
/** The controls ViewKit's panels can draw as the app's own, under the provider's `panelControls` (VK-1013
|
|
1575
|
-
|
|
1583
|
+
/** The controls ViewKit's panels and field editors can draw as the app's own, under the provider's `panelControls` (VK-1013;
|
|
1584
|
+
* `Calendar`, the date editor's month, VK-1021). */
|
|
1585
|
+
export type PanelControlName = "Button" | "Select" | "Menu" | "Popover" | "Input" | "Calendar";
|
|
1576
1586
|
export declare const PANEL_CONTROL_NAMES: readonly PanelControlName[];
|
|
1577
1587
|
/** What the components map's `RowsWait` is handed: a grid's rows, and whether new ones are loading. */
|
|
1578
1588
|
export type ViewsRowsWaitProps = {
|
|
@@ -1692,11 +1702,30 @@ export type ViewsComponents = {
|
|
|
1692
1702
|
* draws it in its own place, in the box that holds it, at every count (zero included, so it can leave), handed its props;
|
|
1693
1703
|
* left out, ViewKit draws its own bar, portalled to the screen's foot. */
|
|
1694
1704
|
SelectionBar?: ComponentType<ViewsSelectionBarProps>;
|
|
1705
|
+
/** Optional: the Pane (CONTROLS: ViewKit's), a panel standing at the right edge of the list's box, the list in use beside
|
|
1706
|
+
* it. Handed one, a toolbar with `customizeIn: "pane"` opens Customize in it on a computer; left out, Customize opens in
|
|
1707
|
+
* the `Popover` as before. */
|
|
1708
|
+
Pane?: ComponentType<ViewsPaneProps>;
|
|
1709
|
+
};
|
|
1710
|
+
/** What the components map's `Pane` is handed (VK-1026): a toolbar panel standing at the right edge of the list's box, under
|
|
1711
|
+
* the toolbar, the list in use beside it, on a computer (`customizeIn: "pane"`: Customize). */
|
|
1712
|
+
export type ViewsPaneProps = {
|
|
1713
|
+
open: boolean;
|
|
1714
|
+
/** It closes from inside (Escape, its ✕): set `open` from it. */
|
|
1715
|
+
onOpenChange: (open: boolean) => void;
|
|
1716
|
+
/** The list's box it stands in: positioned, holding the grid, never scrolling itself. Null until it is on the page: draw
|
|
1717
|
+
* nothing. */
|
|
1718
|
+
container: HTMLElement | null;
|
|
1719
|
+
/** The part's button that opened it (⋯ while the part is folded into it): give it the focus back as it closes from inside. */
|
|
1720
|
+
opener: HTMLElement | null;
|
|
1721
|
+
/** Its name to a screen reader: the part's label. */
|
|
1722
|
+
label: string;
|
|
1723
|
+
children: ReactNode;
|
|
1695
1724
|
};
|
|
1696
1725
|
/** The selection bar's props, as your `SelectionBar` is handed them: ViewKit's `SelectionBar`'s own. */
|
|
1697
1726
|
export type ViewsSelectionBarProps = SelectionBarProps;
|
|
1698
1727
|
/** The map as the views read it: `Input` and `Calendar` always filled, the app's or the
|
|
1699
|
-
* package's own; `RowsWait`, `GroupBody`, `SearchField`, `PortsHost`, `SelectionBar` and `
|
|
1728
|
+
* package's own; `RowsWait`, `GroupBody`, `SearchField`, `PortsHost`, `SelectionBar`, `ViewMenu` and `Pane` as the app handed them. */
|
|
1700
1729
|
export type ViewsResolvedComponents = ViewsComponents & {
|
|
1701
1730
|
Input: ComponentType<ViewsInputProps>;
|
|
1702
1731
|
Calendar: ComponentType<ViewsCalendarProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const PANEL_CONTROL_NAMES = ["Button", "Select", "Menu", "Popover", "Input"];
|
|
1
|
+
export const PANEL_CONTROL_NAMES = ["Button", "Select", "Menu", "Popover", "Input", "Calendar"];
|
|
2
2
|
const _requiredMatchContract = true;
|
|
3
3
|
const _optionalMatchContract = true;
|
|
4
4
|
void _requiredMatchContract;
|
package/views/dist/react.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export { DEFAULT_DESKTOP_QUERY } from "./provider/desktop.js";
|
|
|
6
6
|
export { PANEL_CONTROL_NAMES } from "./provider/components.js";
|
|
7
7
|
export { flatSelectItems } from "./provider/select-items.js";
|
|
8
8
|
export type { ViewsSeveralValues } from "./display/fit-values.js";
|
|
9
|
-
export type { ViewsAlign, ViewsAnchor, ViewsBarPlacement, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsCustomizeBodyProps, ViewsCustomizeChoice, ViewsCustomizeColumn, ViewsCustomizeColumns, ViewsCustomizeField, ViewsCustomizeFields, ViewsCustomizeLayout, ViewsCustomizePage, ViewsCustomizeToggle, ViewsDateBodyProps, ViewsDatePick, ViewsDatePicks, ViewsInputProps, ViewsFieldsBodyField, ViewsFieldsBodyProps, ViewsFilterBodyField, ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsGroupBodyProps, ViewsGroupDimension, ViewsGroupEntry, ViewsGroupValue, ViewsMenuItem, ViewsMenuProps, ViewsNumberBodyProps, ViewsOpenChange, ViewsPartsBodyProps, ViewsPickerAction, ViewsPickerItem, ViewsPickerProps, ViewsLink, ViewsLinkRole, ViewsLinksBodyProps, ViewsPlacePart, ViewsPlaceParts, ViewsPopoverProps, ViewsPortsHostProps, PanelControlName, ViewsSelectionBarProps, ViewsSelectItem, ViewsSelectProps, ViewsQuickFiltersBodyProps, ViewsResolvedComponents, ViewsRowsWaitProps, ViewsSearchFieldProps, ViewsSelectionBarSettings, ViewsSheetAction, ViewsSheetActions, ViewsBodyStep, ViewsSheetActionsPlace, ViewsSheetProps, ViewsSide, ViewsSortBodyProps, ViewsTextBodyProps, ViewsTooltipProps, ViewsValueLine, ViewsValuesBodyProps, ViewsViewsListBodyProps, ViewsViewsListItem, ViewsViewChange, ViewsViewLayout, ViewsViewMenuProps, ViewsViewRecord, ViewsViewVerbs, } from "./provider/components.js";
|
|
9
|
+
export type { ViewsAlign, ViewsAnchor, ViewsBarPlacement, ViewsButtonProps, ViewsCalendarProps, ViewsCheckboxProps, ViewsCloseReason, ViewsCollapseProps, ViewsCommandParts, ViewsComponents, ViewsCustomizeBodyProps, ViewsCustomizeChoice, ViewsCustomizeColumn, ViewsCustomizeColumns, ViewsCustomizeField, ViewsCustomizeFields, ViewsCustomizeLayout, ViewsCustomizePage, ViewsCustomizeToggle, ViewsDateBodyProps, ViewsDatePick, ViewsDatePicks, ViewsInputProps, ViewsFieldsBodyField, ViewsFieldsBodyProps, ViewsFilterBodyField, ViewsFilterBodyProps, ViewsFilterPartBodyProps, ViewsGroupBodyProps, ViewsGroupDimension, ViewsGroupEntry, ViewsGroupValue, ViewsMenuItem, ViewsMenuProps, ViewsNumberBodyProps, ViewsOpenChange, ViewsPartsBodyProps, ViewsPickerAction, ViewsPickerItem, ViewsPickerProps, ViewsLink, ViewsLinkRole, ViewsLinksBodyProps, ViewsPlacePart, ViewsPlaceParts, ViewsPopoverProps, ViewsPortsHostProps, PanelControlName, ViewsSelectionBarProps, ViewsSelectItem, ViewsSelectProps, ViewsQuickFiltersBodyProps, ViewsResolvedComponents, ViewsRowsWaitProps, ViewsSearchFieldProps, ViewsSelectionBarSettings, ViewsSheetAction, ViewsSheetActions, ViewsBodyStep, ViewsSheetActionsPlace, ViewsSheetProps, ViewsSide, ViewsSortBodyProps, ViewsTextBodyProps, ViewsTooltipProps, ViewsValueLine, ViewsValuesBodyProps, ViewsViewsListBodyProps, ViewsViewsListItem, ViewsViewChange, ViewsViewLayout, ViewsViewMenuProps, ViewsPaneProps, ViewsViewRecord, ViewsViewVerbs, } from "./provider/components.js";
|
|
10
10
|
export type { ViewsIconProps, ViewsIcons } from "./provider/icons.js";
|
|
11
11
|
export { NOOP_PORTS, NOOP_TOAST } from "./provider/ports.js";
|
|
12
12
|
export type { ViewsClipboardPort, ViewsConfirmPort, ViewsConfirmRequest, ViewsHapticsPort, ViewsPorts, ViewsPrefsPort, ViewsResolvedPorts, ViewsToastPort, } from "./provider/ports.js";
|