viewkitjs 0.38.0 → 0.40.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 +134 -0
- package/MIGRATION.md +32 -0
- package/fields/dist/derived.d.ts +7 -0
- package/fields/dist/derived.js +4 -0
- package/fields/dist/index.d.ts +1 -1
- package/fields/dist/index.js +1 -1
- package/fields/dist/messages.d.ts +5 -1
- package/fields/dist/messages.js +3 -0
- package/fields/dist/query/evaluate.d.ts +7 -1
- package/fields/dist/query/evaluate.js +8 -5
- package/fields/dist/query/figure-kinds.d.ts +2 -2
- package/fields/dist/query/figure-kinds.js +3 -0
- package/fields/dist/query/figures.d.ts +5 -3
- package/fields/dist/query/figures.js +13 -0
- package/fields/dist/query/filter.d.ts +7 -0
- package/fields/dist/query/filter.js +7 -1
- package/fields/dist/query/kit.d.ts +3 -2
- package/fields/dist/query/kit.js +1 -1
- package/fields/dist/query/layer.d.ts +6 -0
- package/fields/dist/query/layer.js +3 -0
- package/fields/dist/query/number.d.ts +3 -2
- package/fields/dist/query/number.js +5 -3
- package/fields/dist/query/read-rule.d.ts +1 -1
- package/fields/dist/query/read-rule.js +3 -0
- package/fields/docs/guides/queries.md +28 -24
- package/fields/docs/reference/fields.md +1 -0
- package/fields/docs/reference/query.md +9 -7
- package/package.json +2 -4
- package/postgres/dist/check.js +3 -1
- package/postgres/dist/definitions/storage.d.ts +3 -1
- package/postgres/dist/definitions/storage.js +3 -1
- package/postgres/dist/definitions/stored.js +13 -2
- package/postgres/dist/map.d.ts +5 -1
- package/postgres/dist/map.js +4 -0
- package/postgres/dist/records.js +6 -1
- package/postgres/docs/guides/definitions.md +1 -1
- package/postgres/docs/guides/field-map.md +3 -3
- package/postgres/docs/reference/postgres.md +1 -1
- package/views/dist/atoms/HeaderChrome.d.ts +7 -0
- package/views/dist/atoms/HeaderChrome.js +15 -0
- package/views/dist/atoms/ToolbarButton.d.ts +1 -1
- package/views/dist/atoms/ToolbarButton.js +2 -2
- package/views/dist/atoms/defaults.js +4 -0
- package/views/dist/atoms/types.d.ts +39 -2
- package/views/dist/contract.d.ts +38 -9
- package/views/dist/contract.js +64 -6
- package/views/dist/controls/avatar.css +1 -1
- package/views/dist/controls/customize/map-customize-body.js +1 -1
- package/views/dist/controls/field/field.d.ts +2 -14
- package/views/dist/controls/field/field.js +4 -9
- package/views/dist/controls/field/looks.d.ts +1 -1
- package/views/dist/controls/field/looks.js +7 -3
- package/views/dist/controls/field/tokens.d.ts +4 -0
- package/views/dist/controls/field/tokens.js +1 -0
- package/views/dist/controls/field.css +33 -0
- package/views/dist/controls/filter-editor/block.d.ts +3 -1
- package/views/dist/controls/filter-editor/block.js +4 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +15 -2
- package/views/dist/controls/filter-editor/filter-editor.js +49 -16
- package/views/dist/controls/filter-editor/how.d.ts +11 -1
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +4 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +21 -11
- package/views/dist/controls/filter-editor/map-rules.d.ts +6 -4
- package/views/dist/controls/filter-editor/map-rules.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +14 -1
- package/views/dist/controls/filter-editor/parts.js +14 -0
- package/views/dist/controls/filter-editor.css +4 -1
- package/views/dist/controls/index.d.ts +0 -3
- package/views/dist/controls/index.js +0 -3
- package/views/dist/controls/input.css +1 -1
- package/views/dist/controls/internal/menu-items.d.ts +2 -0
- package/views/dist/controls/internal/menu-items.js +1 -1
- package/views/dist/controls/internal/part-slot.d.ts +1 -1
- package/views/dist/controls/internal/part-slot.js +1 -1
- package/views/dist/controls/internal/row-actions.d.ts +33 -0
- package/views/dist/controls/internal/row-actions.js +28 -0
- package/views/dist/controls/menu/map-menu.js +1 -1
- package/views/dist/controls/menu-list.css +1 -1
- package/views/dist/controls/picker/looks.d.ts +1 -1
- package/views/dist/controls/picker.css +2 -2
- package/views/dist/controls/popover/map-popover.d.ts +1 -1
- package/views/dist/controls/popover/map-popover.js +2 -2
- package/views/dist/controls/press.css +0 -1
- package/views/dist/controls/radio/radio.d.ts +1 -1
- package/views/dist/controls/radio/radio.js +1 -16
- package/views/dist/controls/sheet/bottom-sheet.d.ts +2 -2
- package/views/dist/controls/sheet/bottom-sheet.js +31 -24
- package/views/dist/controls/sheet/map-sheet.js +9 -6
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +41 -13
- package/views/dist/controls/text-editor.css +22 -0
- package/views/dist/controls/tokens.js +0 -6
- package/views/dist/controls/toolbar/toolbar.js +2 -2
- package/views/dist/controls/toolbar-button/atom-toolbar-button.d.ts +1 -1
- package/views/dist/controls/toolbar-button/atom-toolbar-button.js +2 -2
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/field-row/FieldRow.js +38 -16
- package/views/dist/field-row/editors/RowChipsEditor.js +3 -1
- package/views/dist/field-row/editors/RowDateEditor.js +3 -1
- package/views/dist/field-row/editors/RowNameEditor.js +3 -1
- package/views/dist/field-row/editors/RowPlaceEditor.js +4 -2
- package/views/dist/field-row/editors/RowRangeEditor.js +3 -1
- package/views/dist/field-row/editors/RowRelationEditor.js +5 -2
- package/views/dist/field-row/editors/RowSelectEditor.js +3 -1
- package/views/dist/field-row/editors/RowTextEditor.d.ts +7 -1
- package/views/dist/field-row/editors/RowTextEditor.js +28 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +4 -4
- package/views/dist/field-row/editors/row-place.d.ts +33 -0
- package/views/dist/field-row/editors/row-place.js +141 -0
- package/views/dist/field-row/field-row-button.d.ts +9 -6
- package/views/dist/field-row/field-row-button.js +3 -3
- package/views/dist/field-row/row-target.d.ts +4 -1
- package/views/dist/field-row/row-target.js +1 -1
- package/views/dist/filters/duration-bound.d.ts +7 -0
- package/views/dist/filters/duration-bound.js +9 -0
- package/views/dist/filters/filter-model.d.ts +4 -0
- package/views/dist/filters/number-refused.d.ts +8 -0
- package/views/dist/filters/number-refused.js +4 -0
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +12 -11
- package/views/dist/grid/chrome/GridAggregateMenu.js +4 -3
- package/views/dist/grid/chrome/GridFooter.d.ts +12 -4
- package/views/dist/grid/chrome/GridFooter.js +11 -9
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridResizeHandle.d.ts +7 -3
- package/views/dist/grid/chrome/GridResizeHandle.js +2 -3
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTableSurface.js +1 -1
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -4
- package/views/dist/grid/chrome/grid-body-place.js +4 -5
- package/views/dist/grid/chrome/grid-figure-value.js +10 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +15 -4
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +12 -2
- package/views/dist/grid/core/clipboard-model.js +42 -8
- package/views/dist/grid/core/commit-model.d.ts +3 -0
- package/views/dist/grid/core/editing-controller.d.ts +29 -1
- package/views/dist/grid/core/editing-controller.js +142 -12
- package/views/dist/grid/core/pending-reconciliation.d.ts +14 -0
- package/views/dist/grid/core/pending-reconciliation.js +20 -8
- package/views/dist/grid/core/save-path.d.ts +4 -2
- package/views/dist/grid/core/save-path.js +1 -1
- package/views/dist/grid/core/spreadsheet-operations.js +43 -5
- package/views/dist/grid/core/useGridEditing.d.ts +5 -1
- package/views/dist/grid/core/useGridEditing.js +4 -4
- package/views/dist/grid/core/written-alongside.d.ts +16 -0
- package/views/dist/grid/core/written-alongside.js +30 -0
- package/views/dist/grid/grid.css +8 -4
- package/views/dist/grid/index.d.ts +1 -1
- package/views/dist/grid/looks.d.ts +2 -2
- package/views/dist/internal/before-paint.d.ts +5 -0
- package/views/dist/internal/before-paint.js +17 -0
- package/views/dist/internal/field-rows.d.ts +0 -8
- package/views/dist/internal/field-rows.js +1 -3
- package/views/dist/internal/over-cell.d.ts +8 -0
- package/views/dist/internal/over-cell.js +5 -0
- package/views/dist/list/bar-keys.d.ts +8 -0
- package/views/dist/list/bar-keys.js +3 -0
- package/views/dist/list/bar-parts.d.ts +27 -0
- package/views/dist/list/bar-parts.js +38 -0
- package/views/dist/list/buttons/clear-save.d.ts +7 -0
- package/views/dist/list/buttons/clear-save.js +19 -0
- package/views/dist/list/buttons/customize.d.ts +28 -0
- package/views/dist/list/buttons/customize.js +31 -0
- package/views/dist/list/buttons/filter.d.ts +32 -0
- package/views/dist/list/buttons/filter.js +60 -0
- package/views/dist/list/buttons/new.d.ts +18 -0
- package/views/dist/list/buttons/new.js +21 -0
- package/views/dist/list/buttons/quick.d.ts +15 -0
- package/views/dist/list/buttons/quick.js +24 -0
- package/views/dist/list/buttons/search.d.ts +18 -0
- package/views/dist/list/buttons/search.js +17 -0
- package/views/dist/list/buttons/shared.d.ts +97 -0
- package/views/dist/list/buttons/shared.js +137 -0
- package/views/dist/list/buttons/sort-filter.d.ts +6 -0
- package/views/dist/list/buttons/sort-filter.js +16 -0
- package/views/dist/list/buttons/sort.d.ts +17 -0
- package/views/dist/list/buttons/sort.js +34 -0
- package/views/dist/list/buttons/views.d.ts +21 -0
- package/views/dist/list/buttons/views.js +38 -0
- package/views/dist/list/editor-menus.d.ts +13 -0
- package/views/dist/list/editor-menus.js +13 -0
- package/views/dist/list/edits.d.ts +3 -1
- package/views/dist/list/index.d.ts +41 -0
- package/views/dist/list/index.js +19 -0
- package/views/dist/list/layer.d.ts +13 -3
- package/views/dist/list/layer.js +13 -3
- package/views/dist/list/line.d.ts +58 -0
- package/views/dist/list/line.js +229 -0
- package/views/dist/list/list.d.ts +7 -1
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/pane-box.d.ts +6 -0
- package/views/dist/list/pane-box.js +15 -0
- package/views/dist/list/panels/customize.d.ts +8 -0
- package/views/dist/list/panels/customize.js +23 -0
- package/views/dist/list/panels/filter-bar.d.ts +12 -0
- package/views/dist/list/panels/filter-bar.js +73 -0
- package/views/dist/list/panels/filter.d.ts +8 -0
- package/views/dist/list/panels/filter.js +23 -0
- package/views/dist/list/panels/quick.d.ts +7 -0
- package/views/dist/list/panels/quick.js +16 -0
- package/views/dist/list/panels/shared.d.ts +26 -0
- package/views/dist/list/panels/shared.js +36 -0
- package/views/dist/list/panels/sort.d.ts +8 -0
- package/views/dist/list/panels/sort.js +19 -0
- package/views/dist/list/panels/views.d.ts +13 -0
- package/views/dist/list/panels/views.js +27 -0
- package/views/dist/list/ready.d.ts +35 -0
- package/views/dist/list/ready.js +7 -0
- package/views/dist/list/root-base.d.ts +19 -1
- package/views/dist/list/root-base.js +13 -3
- package/views/dist/list/root.d.ts +1 -1
- package/views/dist/list/root.js +2 -2
- package/views/dist/list/store.d.ts +29 -0
- package/views/dist/list/store.js +48 -2
- package/views/dist/list/toolbar-model.d.ts +99 -0
- package/views/dist/list/toolbar-model.js +195 -0
- package/views/dist/list/toolbar.js +142 -329
- package/views/dist/list/views-axis.js +15 -4
- package/views/dist/list/views.d.ts +1 -1
- package/views/dist/list/views.js +4 -1
- package/views/dist/looks/index.d.ts +0 -1
- package/views/dist/looks/index.js +0 -1
- package/views/dist/looks/looks.d.ts +1 -1
- package/views/dist/looks/pieces.js +0 -2
- package/views/dist/model/aggregates.d.ts +18 -8
- package/views/dist/model/aggregates.js +16 -22
- package/views/dist/model/column-filters.js +10 -3
- package/views/dist/model/view-rules.js +1 -0
- package/views/dist/panels/filter/NumberFilterBody.js +6 -8
- package/views/dist/panels/labels.js +7 -2
- package/views/dist/panels/model.d.ts +3 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterEditor.js +2 -2
- package/views/dist/panels/react/filter/filter-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-body.js +7 -3
- package/views/dist/panels/react/sort/SortEditor.d.ts +3 -1
- package/views/dist/panels/react/sort/SortEditor.js +4 -4
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +80 -3
- package/views/dist/panels/react/toolbar/Toolbar.js +85 -52
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.d.ts +9 -0
- package/views/dist/panels/react/toolbar/ToolbarBarSorts.js +84 -0
- package/views/dist/panels/react/toolbar/ToolbarButton.d.ts +1 -1
- package/views/dist/panels/react/toolbar/ToolbarButton.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +4 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +30 -0
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +6 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +5 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +6 -4
- package/views/dist/panels/react/toolbar/ToolbarViews.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarViews.js +4 -4
- package/views/dist/panels/react/toolbar/context.d.ts +4 -0
- package/views/dist/panels/react/toolbar/context.js +1 -0
- package/views/dist/panels/react/toolbar/sheet-host.d.ts +3 -0
- package/views/dist/panels/react/toolbar/sheet-host.js +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.d.ts +6 -0
- package/views/dist/panels/react/toolbar/use-give-way.js +10 -3
- package/views/dist/panels/react/views-row/ViewPicker.d.ts +8 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +12 -7
- package/views/dist/panels/settings/filter-groups.js +12 -0
- package/views/dist/panels/settings/input.d.ts +11 -0
- package/views/dist/panels/settings/layout.js +26 -0
- package/views/dist/panels/settings/person.d.ts +15 -0
- package/views/dist/panels/settings/person.js +6 -0
- package/views/dist/panels/toolbar/page-resets.js +14 -3
- package/views/dist/provider/components.d.ts +47 -4
- package/views/dist/react.d.ts +1 -1
- package/views/dist/styles.css +116 -257
- package/views/dist/styles.unlayered.css +116 -257
- package/views/docs/contract.md +28 -18
- package/views/docs/controls/field.md +2 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/menu.md +1 -1
- package/views/docs/controls/sort-editor.md +1 -1
- package/views/docs/guides/atoms.md +1 -0
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +6 -4
- package/views/docs/guides/toolbar-parts.md +337 -0
- package/views/docs/index.md +4 -0
- package/views/docs/reference/controls.md +6 -44
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +8 -7
- package/views/docs/reference/list.md +184 -11
- package/views/docs/reference/looks.md +13 -16
- package/views/docs/reference/panels-react.md +7 -7
- package/views/docs/reference/panels.md +1 -1
- package/views/docs/reference/react.md +14 -11
- package/views/docs/reference/views.md +9 -7
- package/views/skills/views/SKILL.md +2 -1
- package/views/dist/controls/setting-row/looks.d.ts +0 -10
- package/views/dist/controls/setting-row/looks.js +0 -22
- package/views/dist/controls/setting-row/setting-row.d.ts +0 -102
- package/views/dist/controls/setting-row/setting-row.js +0 -135
- package/views/dist/controls/setting-row/tokens.d.ts +0 -156
- package/views/dist/controls/setting-row/tokens.js +0 -41
- package/views/dist/controls/setting-row.css +0 -216
- package/views/dist/controls/switch-row/switch-row.d.ts +0 -1
- package/views/dist/controls/switch-row/switch-row.js +0 -1
- package/views/dist/controls/switch-row/tokens.d.ts +0 -39
- package/views/dist/controls/switch-row/tokens.js +0 -12
- package/views/dist/controls/switch-row.css +0 -35
- package/views/dist/controls/tag-field/tag-field.d.ts +0 -24
- package/views/dist/controls/tag-field/tag-field.js +0 -25
- package/views/dist/controls/tag-field/tokens.d.ts +0 -23
- package/views/dist/controls/tag-field/tokens.js +0 -8
- package/views/dist/controls/tag-field.css +0 -32
- package/views/docs/controls/setting-row.md +0 -44
- package/views/docs/controls/switch-row.md +0 -15
- package/views/docs/controls/tag-field.md +0 -11
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Fragment, useContext, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
5
|
import { ScreenForms } from "../../../internal/screen-forms.js";
|
|
@@ -10,7 +10,7 @@ import { useAnchoredToggle } from "../views-row/use-anchored-toggle.js";
|
|
|
10
10
|
import { ListRadioContext, NOT_FOLDING, ToolbarRadioContext, ToolbarSlotContext, useToolbarPanel, useToolbarRadioState, } from "./context.js";
|
|
11
11
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
12
12
|
import { useBoxNarrow } from "./use-box-narrow.js";
|
|
13
|
-
import {
|
|
13
|
+
import { useGiveWayLook } from "./use-give-way.js";
|
|
14
14
|
const CLUSTER_FADE = "linear-gradient(to right, transparent 0, var(--vk-ground) 1.25rem, var(--vk-ground) 100%)";
|
|
15
15
|
export function Toolbar(props) {
|
|
16
16
|
return (_jsx(ScreenForms, { off: props.phone !== undefined, children: _jsx(ToolbarOnScreen, { ...props }) }));
|
|
@@ -38,12 +38,17 @@ function ToolbarOnScreen({ parts, phone, narrow, narrowBelow = TOOLBAR_NARROW_BE
|
|
|
38
38
|
]));
|
|
39
39
|
if (fold) {
|
|
40
40
|
const menus = new Map(parts.flatMap((part) => (part.menu ? [[part.key, part.menu]] : [])));
|
|
41
|
-
return (_jsx(
|
|
41
|
+
return (_jsx(FoldFrame, { form: form, className: className, frameRef: box, children: lines.map((line) => (_jsx(FoldLine, { line: line, form: form, nodes: nodes, placed: placed, menus: menus, more: more, overflow: overflow, search: { open: searchOpen, onOpenChange: setSearchOpen } }, line.kind))) }));
|
|
42
42
|
}
|
|
43
43
|
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))) }) }));
|
|
44
44
|
}
|
|
45
|
+
export function FoldFrame({ form, className, frameRef, children, }) {
|
|
46
|
+
const own = useToolbarRadioState();
|
|
47
|
+
const radio = useContext(ListRadioContext) ?? own;
|
|
48
|
+
return (_jsx(ToolbarRadioContext.Provider, { value: radio, children: _jsx("div", { ref: frameRef, "data-slot": "vk-toolbar", "data-form": form, "data-fold": "", className: cx("@container flex w-full flex-col", className), children: children }) }));
|
|
49
|
+
}
|
|
45
50
|
const sideOf = (line, key) => (line.end.some((slot) => slot.key === key) ? "end" : "start");
|
|
46
|
-
function useLineName(kind) {
|
|
51
|
+
export function useLineName(kind) {
|
|
47
52
|
const { messages } = useViews();
|
|
48
53
|
return messages({ key: kind === "bar" || kind === "below" ? "views.panels.toolbar-bar" : "views.panels.toolbar-row" });
|
|
49
54
|
}
|
|
@@ -63,61 +68,89 @@ function Line({ line, form, nodes, placed }) {
|
|
|
63
68
|
}
|
|
64
69
|
return (_jsxs("div", { ...mark, className: "flex flex-wrap items-center gap-2 empty:hidden", children: [draw(line.start), line.end.length > 0 && _jsx("div", { className: "ml-auto flex items-center gap-1", children: draw(line.end) })] }));
|
|
65
70
|
}
|
|
66
|
-
function
|
|
67
|
-
const name = useLineName(line.kind);
|
|
68
|
-
const [element, setElement] = useState(null);
|
|
71
|
+
export function useFoldLine(element, line, form, searchHanded) {
|
|
69
72
|
const more = useRef(null);
|
|
73
|
+
const [searchOpen, setSearchOpen] = useState(false);
|
|
74
|
+
const search = searchHanded ?? { open: searchOpen, onOpenChange: setSearchOpen };
|
|
70
75
|
const steps = foldSteps(line);
|
|
71
|
-
const stage =
|
|
76
|
+
const { stage, look } = useGiveWayLook(element, steps.length, true);
|
|
72
77
|
const state = foldState(line, steps, stage);
|
|
73
78
|
const phone = form === "phone";
|
|
74
79
|
const searchTakesLine = phone && search.open && [...line.start, ...line.end].some((slot) => slot.search);
|
|
75
|
-
const
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (slot.separator && (!drawn[i] || searchTakesLine))
|
|
88
|
-
return [];
|
|
89
|
-
const shrinks = slot.key.startsWith("views") && !slot.tabs;
|
|
90
|
-
const fills = searchTakesLine && slot.search;
|
|
91
|
-
const itemNode = (_jsx("span", { "data-toolbar-item": slot.key, hidden: folded || waits(slot) || undefined, className: cx("inline-flex items-center empty:hidden", fills ? "min-w-0 flex-1" : shrinks ? "min-w-0 shrink" : slot.search && search.open ? "min-w-30 shrink" : "shrink-0"), children: _jsx(ToolbarSlotContext.Provider, { value: {
|
|
92
|
-
form,
|
|
93
|
-
fill: false,
|
|
94
|
-
size: line.size,
|
|
95
|
-
line: line.kind,
|
|
96
|
-
...NOT_FOLDING,
|
|
97
|
-
fold: true,
|
|
98
|
-
iconAlone: state.iconAlone.has(slot.key),
|
|
99
|
-
tabsFolded: state.tabsFolded.get(slot.key) ?? 0,
|
|
100
|
-
filtersFolded: state.filtersFolded.get(slot.key) ?? 0,
|
|
101
|
-
folded,
|
|
102
|
-
more,
|
|
103
|
-
search: slot.search ? search : null,
|
|
104
|
-
appFrame: false,
|
|
105
|
-
side: sideOf(line, folded && state.moreAfter ? state.moreAfter : slot.key),
|
|
106
|
-
...placed.get(slot.key),
|
|
107
|
-
}, children: _jsx(Fragment, { children: nodes.get(slot.key) }) }) }, slot.key));
|
|
108
|
-
if (slot.key !== state.moreAfter)
|
|
109
|
-
return [itemNode];
|
|
110
|
-
const rows = [...line.start, ...line.end].flatMap((s) => {
|
|
111
|
-
const menu = state.folded.has(s.key) ? menus.get(s.key) : undefined;
|
|
112
|
-
return menu ? [{ key: s.key, ...menu }] : [];
|
|
113
|
-
});
|
|
114
|
-
const align = sideOf(line, slot.key);
|
|
115
|
-
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, look: overflow }, "vk-overflow")];
|
|
116
|
-
});
|
|
80
|
+
const shown = (s) => !s.separator && !state.folded.has(s.key);
|
|
81
|
+
const drawnSeparators = new Set([line.start, line.end].flatMap((slots) => slots.filter((slot, i) => slot.separator && !phone && slots.slice(0, i).some(shown) && slots.slice(i + 1).some(shown)).map((slot) => slot.key)));
|
|
82
|
+
return {
|
|
83
|
+
line,
|
|
84
|
+
form,
|
|
85
|
+
state,
|
|
86
|
+
searchTakesLine,
|
|
87
|
+
search,
|
|
88
|
+
more,
|
|
89
|
+
separatorDrawn: (key) => drawnSeparators.has(key),
|
|
90
|
+
sideOf: (key) => sideOf(line, key),
|
|
91
|
+
recheck: look,
|
|
117
92
|
};
|
|
118
|
-
|
|
93
|
+
}
|
|
94
|
+
export function foldLineMark(kind, form, name) {
|
|
95
|
+
return {
|
|
96
|
+
"data-slot": "vk-toolbar-line",
|
|
97
|
+
"data-line": kind,
|
|
98
|
+
role: "toolbar",
|
|
99
|
+
"aria-label": name,
|
|
100
|
+
...(kind === "main" ? { "data-toolbar-row": "" } : {}),
|
|
101
|
+
className: cx("flex min-w-0 items-center", form === "phone"
|
|
119
102
|
? "gap-1.5"
|
|
120
|
-
: "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))"),
|
|
103
|
+
: "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))"),
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
export function FoldItem({ view, slot, name, place, rows, reshape, overflow, itemRef, more: drawsMore = true, children, }) {
|
|
107
|
+
const { line, form, state, search, searchTakesLine, more } = view;
|
|
108
|
+
const folded = state.folded.has(slot.key);
|
|
109
|
+
if (slot.separator && (!view.separatorDrawn(slot.key) || searchTakesLine))
|
|
110
|
+
return null;
|
|
111
|
+
const atFoot = name === "new" && place?.foot !== false;
|
|
112
|
+
const waits = searchTakesLine && !slot.search && name !== "views" && !atFoot;
|
|
113
|
+
const shrinks = name.startsWith("views") && !slot.tabs;
|
|
114
|
+
const fills = searchTakesLine && slot.search;
|
|
115
|
+
const item = (_jsx("span", { ref: itemRef, "data-toolbar-item": name, hidden: folded || waits || undefined, className: cx("inline-flex items-center empty:hidden", fills ? "min-w-0 flex-1" : shrinks ? "min-w-0 shrink" : slot.search && search.open ? "min-w-30 shrink" : "shrink-0"), children: _jsx(ToolbarSlotContext.Provider, { value: {
|
|
116
|
+
form,
|
|
117
|
+
fill: false,
|
|
118
|
+
size: line.size,
|
|
119
|
+
line: line.kind,
|
|
120
|
+
...NOT_FOLDING,
|
|
121
|
+
fold: true,
|
|
122
|
+
iconAlone: state.iconAlone.has(slot.key),
|
|
123
|
+
tabsFolded: state.tabsFolded.get(slot.key) ?? 0,
|
|
124
|
+
filtersFolded: state.filtersFolded.get(slot.key) ?? 0,
|
|
125
|
+
folded,
|
|
126
|
+
more,
|
|
127
|
+
search: slot.search ? search : null,
|
|
128
|
+
appFrame: false,
|
|
129
|
+
side: view.sideOf(folded && state.moreAfter ? state.moreAfter : slot.key),
|
|
130
|
+
...place,
|
|
131
|
+
}, children: _jsx(Fragment, { children: children }) }) }));
|
|
132
|
+
if (slot.key !== state.moreAfter || !drawsMore)
|
|
133
|
+
return item;
|
|
134
|
+
return (_jsxs(_Fragment, { children: [item, _jsx(FoldOverflow, { view: view, rows: rows, reshape: reshape, overflow: overflow })] }));
|
|
135
|
+
}
|
|
136
|
+
export function FoldOverflow({ view, rows, reshape, overflow, }) {
|
|
137
|
+
const { line, form, state, more } = view;
|
|
138
|
+
const align = state.moreAfter ? view.sideOf(state.moreAfter) : "end";
|
|
139
|
+
return (_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, look: overflow }));
|
|
140
|
+
}
|
|
141
|
+
function FoldLine({ line, form, nodes, placed, menus, more: reshape, overflow, search, }) {
|
|
142
|
+
const name = useLineName(line.kind);
|
|
143
|
+
const [element, setElement] = useState(null);
|
|
144
|
+
const view = useFoldLine(element, line, form, search);
|
|
145
|
+
const rows = () => [...line.start, ...line.end].flatMap((s) => {
|
|
146
|
+
const menu = view.state.folded.has(s.key) ? menus.get(s.key) : undefined;
|
|
147
|
+
return menu ? [{ key: s.key, ...menu }] : [];
|
|
148
|
+
});
|
|
149
|
+
const draw = (slots) => slots.flatMap((slot) => [
|
|
150
|
+
_jsx(FoldItem, { view: view, slot: slot, name: slot.key, place: placed.get(slot.key), rows: rows, more: false, children: nodes.get(slot.key) }, slot.key),
|
|
151
|
+
...(slot.key === view.state.moreAfter ? [_jsx(FoldOverflow, { view: view, rows: rows, reshape: reshape, overflow: overflow }, "vk-overflow")] : []),
|
|
152
|
+
]);
|
|
153
|
+
return (_jsxs("div", { ref: setElement, ...foldLineMark(line.kind, form, name), children: [draw(line.start), !view.searchTakesLine && _jsx("span", { "data-toolbar-spacer": true, "aria-hidden": true, className: "min-w-0 flex-1" }), draw(line.end)] }));
|
|
121
154
|
}
|
|
122
155
|
const closingFirst = (items, setOpen) => items.map((item) => ({
|
|
123
156
|
...item,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { SortRulesConfig } from "../../model.js";
|
|
3
|
+
export declare function ToolbarBarSorts({ sorts, open: openIn, onOpenChange: onOpenChangeIn, }: {
|
|
4
|
+
/** The builder's rules: `settingsPanels(…).sorts`, with `severalSorts`. */
|
|
5
|
+
sorts: SortRulesConfig<string>;
|
|
6
|
+
/** Whether one of its lists is open, held by the root so another panel opening closes it. */
|
|
7
|
+
open: boolean;
|
|
8
|
+
onOpenChange: (open: boolean) => void;
|
|
9
|
+
}): ReactNode;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useViews } from "../../../provider/context.js";
|
|
5
|
+
import { addSortRule, canAddSortRule, openSortPlaces } from "../../settings/sorts.js";
|
|
6
|
+
import { SortFieldList } from "../sort/SortFieldList.js";
|
|
7
|
+
import { useToolbarPanel } from "./context.js";
|
|
8
|
+
import { useEditorMenus } from "./editor-menus.js";
|
|
9
|
+
import { ToolbarButton } from "./ToolbarButton.js";
|
|
10
|
+
export function ToolbarBarSorts({ sorts, open: openIn, onOpenChange: onOpenChangeIn, }) {
|
|
11
|
+
const { components, icons, messages } = useViews();
|
|
12
|
+
const { Popover } = components;
|
|
13
|
+
const shape = useEditorMenus().sort;
|
|
14
|
+
const panel = useToolbarPanel("bar-sorts", { open: openIn, onOpenChange: onOpenChangeIn });
|
|
15
|
+
const [held, setHeld] = useState(null);
|
|
16
|
+
const at = held?.at ?? null;
|
|
17
|
+
const places = openSortPlaces(sorts);
|
|
18
|
+
const can = canAddSortRule(sorts.rules, places);
|
|
19
|
+
const labelOf = (value) => sorts.options.find((option) => option.value === value)?.label ?? value;
|
|
20
|
+
const Plus = icons.add;
|
|
21
|
+
const Close = icons.close;
|
|
22
|
+
const shown = panel.open ? at : null;
|
|
23
|
+
const openAt = (next, button) => {
|
|
24
|
+
if (shown === next)
|
|
25
|
+
return panel.onOpenChange(false);
|
|
26
|
+
setHeld({ at: next, anchor: { current: button } });
|
|
27
|
+
panel.onOpenChange(true);
|
|
28
|
+
};
|
|
29
|
+
const close = (focus = true) => {
|
|
30
|
+
panel.onOpenChange(false);
|
|
31
|
+
if (focus)
|
|
32
|
+
held?.anchor.current?.focus({ preventScroll: true });
|
|
33
|
+
};
|
|
34
|
+
const write = (rules) => sorts.onChange(rules);
|
|
35
|
+
const pick = (value) => {
|
|
36
|
+
if (at === "add") {
|
|
37
|
+
const next = addSortRule(sorts.rules, value, places);
|
|
38
|
+
if (next !== sorts.rules)
|
|
39
|
+
write(next);
|
|
40
|
+
}
|
|
41
|
+
else if (at !== null) {
|
|
42
|
+
const rule = sorts.rules[at];
|
|
43
|
+
if (rule && rule.value !== value)
|
|
44
|
+
write(sorts.rules.map((held, i) => (i === at ? { ...held, value } : held)));
|
|
45
|
+
}
|
|
46
|
+
close();
|
|
47
|
+
};
|
|
48
|
+
const endOf = (rule, i, label) => {
|
|
49
|
+
const remove = { key: "delete", label: messages({ key: "views.panels.sort-remove", values: { label } }), icon: _jsx(Close, { className: "h-3.5 w-3.5 shrink-0" }) };
|
|
50
|
+
if (!shape)
|
|
51
|
+
return [remove];
|
|
52
|
+
const handed = shape([remove], { menu: "row", field: rule.value, index: i, form: "computer", place: "bar" });
|
|
53
|
+
const keys = new Set();
|
|
54
|
+
return handed.filter((item) => {
|
|
55
|
+
if (item.children !== undefined || item.checked !== undefined || item.key === "more" || keys.has(item.key))
|
|
56
|
+
return false;
|
|
57
|
+
keys.add(item.key);
|
|
58
|
+
return true;
|
|
59
|
+
});
|
|
60
|
+
};
|
|
61
|
+
return (_jsxs(_Fragment, { children: [sorts.rules.map((rule, i) => {
|
|
62
|
+
const label = labelOf(rule.value);
|
|
63
|
+
const direction = messages({ key: rule.dir === "asc" ? "views.panels.sort-ascending" : "views.panels.sort-descending" });
|
|
64
|
+
const ends = endOf(rule, i, label);
|
|
65
|
+
return (_jsxs("span", { "data-slot": "vk-bar-sort", "data-rule": i, role: "group", "aria-label": label, className: "relative inline-flex min-w-0 shrink-0 items-center", children: [_jsx(ToolbarButton, { part: "sort-pill", icon: null, label: messages({ key: "views.panels.sort-field-named", values: { label } }), joined: "start", popup: "dialog", open: shown === i, onClick: (event) => openAt(i, event.currentTarget), children: label }), _jsx(ToolbarButton, { part: "sort-pill", icon: null, label: messages({ key: "views.panels.sort-direction-named", values: { label: direction } }), joined: ends.length > 0 ? "middle" : "end", onClick: () => write(sorts.rules.map((held, k) => (k === i ? { ...held, dir: held.dir === "asc" ? "desc" : "asc" } : held))), children: direction }), ends.map((item, k) => {
|
|
66
|
+
const own = item.key === "delete";
|
|
67
|
+
const icon = item.icon !== undefined ? item.icon : null;
|
|
68
|
+
return (_jsx(ToolbarButton, { part: "sort-pill", icon: icon, label: item.label, joined: k === ends.length - 1 ? "end" : "middle", ...(icon !== null && { iconAlone: true }), ...(item.disabled && { disabled: true, disabledReason: item.disabledReason || item.label }), onClick: () => {
|
|
69
|
+
if (item.disabled)
|
|
70
|
+
return;
|
|
71
|
+
if (own)
|
|
72
|
+
write(sorts.rules.filter((_, k) => k !== i));
|
|
73
|
+
else
|
|
74
|
+
item.onSelect?.();
|
|
75
|
+
}, children: icon === null ? item.label : undefined }, item.key));
|
|
76
|
+
})] }, `${rule.value}-${i}`));
|
|
77
|
+
}), _jsx("span", { "data-slot": "vk-bar-sort-add", className: "inline-flex", children: _jsx(ToolbarButton, { part: "sort-add", icon: _jsx(Plus, { className: "h-4 w-4 shrink-0" }), label: messages({ key: "views.panels.sort-add" }), ...(sorts.rules.length > 0 && { word: null }), popup: "dialog", open: shown === "add", disabled: !can, onClick: (event) => {
|
|
78
|
+
if (can)
|
|
79
|
+
openAt("add", event.currentTarget);
|
|
80
|
+
} }) }), _jsx(Popover, { open: shown !== null, onOpenChange: (next, details) => {
|
|
81
|
+
if (!next)
|
|
82
|
+
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
83
|
+
}, anchor: held?.anchor ?? { current: null }, align: "start", sideOffset: 8, chrome: "menu", panelData: { "data-slot": "vk-bar-sort-fields" }, children: shown !== null && (_jsx(SortFieldList, { sorts: sorts, ...(typeof shown === "number" && sorts.rules[shown] && { own: sorts.rules[shown].value }), onPick: pick, onDone: () => close() })) })] }));
|
|
84
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
3
|
export declare function ToolbarButton({ size, ...props }: Omit<ViewsToolbarButtonProps, "size"> & {
|
|
4
4
|
size?: "md" | "sm";
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useContext } from "react";
|
|
3
4
|
import { cx } from "../../../internal/cx.js";
|
|
4
5
|
import { useViews } from "../../../provider/context.js";
|
|
5
|
-
import { useToolbarSlot } from "./context.js";
|
|
6
|
+
import { PersonWordsContext, useToolbarSlot } from "./context.js";
|
|
6
7
|
export function ToolbarButton({ size, ...props }) {
|
|
7
8
|
const { atoms } = useViews();
|
|
8
9
|
const slot = useToolbarSlot();
|
|
9
|
-
const
|
|
10
|
+
const words = useContext(PersonWordsContext) ?? slot.words;
|
|
11
|
+
const iconOnly = words === "icon" && props.icon != null;
|
|
10
12
|
const hasWords = props.word !== null || props.children != null;
|
|
11
|
-
const wordOnly =
|
|
13
|
+
const wordOnly = words === "word" && hasWords && !props.foot;
|
|
12
14
|
const alone = !wordOnly && (slot.iconAlone || (iconOnly && hasWords));
|
|
13
15
|
const Button = slot.button ?? atoms.ToolbarButton;
|
|
14
16
|
const className = cx(slot.className, props.className) || undefined;
|
|
@@ -2,7 +2,7 @@ import { type ReactNode } from "react";
|
|
|
2
2
|
import type { FilterTreeConfig } from "../../model.js";
|
|
3
3
|
import type { Pending } from "../filter/editor-ctx.js";
|
|
4
4
|
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
5
|
-
export declare function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, changed, opens, }: {
|
|
5
|
+
export declare function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, changed, opens, empty, }: {
|
|
6
6
|
/** The builder's filter tree: `settingsPanels(…).filterTree`. */
|
|
7
7
|
filterTree: FilterTreeConfig;
|
|
8
8
|
/** Holds a yes/no until its value is picked, where the toolbar holds the bar's held rule (so the bar shows it and
|
|
@@ -18,4 +18,7 @@ export declare function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpe
|
|
|
18
18
|
/** What a press opens: the fields, a pick adding a filter (the default), or the view's filters, editable, Add filter
|
|
19
19
|
* under them, as the row's Sort opens its rules (`"filters"`: the ready toolbar's, VK-1047). */
|
|
20
20
|
opens?: "fields" | "filters";
|
|
21
|
+
/** With `opens="filters"` (VK-1091), what it opens with no filter set: the fields (`fields`, the default), or the filter
|
|
22
|
+
* editor saying nothing filters yet, Add filter under it (`editor`). */
|
|
23
|
+
empty?: "fields" | "editor";
|
|
21
24
|
}): ReactNode;
|
|
@@ -9,7 +9,7 @@ import { useSheetPanels } from "../panel-sheet.js";
|
|
|
9
9
|
import { useFoldAnchor, usePanelPlace, useToolbarPanel } from "./context.js";
|
|
10
10
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
11
11
|
import { useFilterAdd } from "./use-filter-add.js";
|
|
12
|
-
export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, changed = false, opens = "fields", }) {
|
|
12
|
+
export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, changed = false, opens = "fields", empty, }) {
|
|
13
13
|
const { components, icons, messages } = useViews();
|
|
14
14
|
const { Popover } = components;
|
|
15
15
|
const phone = useSheetPanels();
|
|
@@ -34,7 +34,7 @@ export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange,
|
|
|
34
34
|
fields.onOpenChange(false);
|
|
35
35
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
36
36
|
};
|
|
37
|
-
const list = opens === "filters" ? (_jsx(WholeFilterEditor, { filterTree: filterTree, onDone: close })) : (_jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: pick, onDone: () => {
|
|
37
|
+
const list = opens === "filters" ? (_jsx(WholeFilterEditor, { filterTree: filterTree, onDone: close, ...(empty && { empty }) })) : (_jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: pick, onDone: () => {
|
|
38
38
|
fields.onOpenChange(false);
|
|
39
39
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
40
40
|
} }));
|
|
@@ -4,6 +4,7 @@ import type { CollectionViewState } from "../../view-state.js";
|
|
|
4
4
|
import type { CustomizePage } from "../../toolbar/page-resets.js";
|
|
5
5
|
import type { ViewsCustomizeItems } from "../../../provider/components.js";
|
|
6
6
|
import type { PanelFieldEditor } from "../field-editor.js";
|
|
7
|
+
import { type PanelStep } from "../panel-step.js";
|
|
7
8
|
import { type ToolbarPanelHost } from "./panel-part.js";
|
|
8
9
|
export declare function ToolbarOptions({ view, viewFoot, footClear, resets, layered, customizeItems, fieldEditor, foldFilters, onClear, open, onOpenChange, page: pageIn, onPageChange, host, widthClassName, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }: ViewOptionInputs & {
|
|
9
10
|
/** The shared view this list shows: the drift dot, and the panel's footer (Reset, Save for everyone). */
|
|
@@ -43,3 +44,32 @@ export declare function ToolbarOptions({ view, viewFoot, footClear, resets, laye
|
|
|
43
44
|
onExport?: () => void;
|
|
44
45
|
exportCount?: string;
|
|
45
46
|
}): ReactNode;
|
|
47
|
+
/** Customize's body, as its panel draws it in the popover, a host or the Sheet, and as a placed Customize panel stands it
|
|
48
|
+
* (VK-1092): the pages over the builder's panels, its count and Clear all, and its foot. Not on the door. */
|
|
49
|
+
export declare function OptionsBody({ step: stepIn, page, onPageChange, count, clear, close, closeButton, fill, foldFilters, view, viewFoot, footClear, resets, layered, customizeItems, fieldEditor, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }: ViewOptionInputs & {
|
|
50
|
+
/** The level of Customize's own its holder tells (a phone's sheet goes back on Escape); absent, its own. */
|
|
51
|
+
step?: PanelStep;
|
|
52
|
+
page: ActivePanel;
|
|
53
|
+
onPageChange: (page: ActivePanel) => void;
|
|
54
|
+
/** The active options counted (0 on a shared view). */
|
|
55
|
+
count: number;
|
|
56
|
+
/** Clear all. */
|
|
57
|
+
clear: () => void;
|
|
58
|
+
/** Dismisses what holds it. */
|
|
59
|
+
close: () => void;
|
|
60
|
+
closeButton: boolean;
|
|
61
|
+
fill: boolean;
|
|
62
|
+
foldFilters?: boolean;
|
|
63
|
+
view?: CollectionViewState;
|
|
64
|
+
viewFoot?: "kit" | "none";
|
|
65
|
+
footClear?: () => void;
|
|
66
|
+
resets?: Partial<Record<CustomizePage, () => void>>;
|
|
67
|
+
layered?: boolean;
|
|
68
|
+
customizeItems?: ViewsCustomizeItems;
|
|
69
|
+
fieldEditor?: PanelFieldEditor | null;
|
|
70
|
+
viewName?: string;
|
|
71
|
+
onRenameView?: (name: string) => void;
|
|
72
|
+
onCopyLink?: () => void;
|
|
73
|
+
onExport?: () => void;
|
|
74
|
+
exportCount?: string;
|
|
75
|
+
}): ReactNode;
|
|
@@ -33,5 +33,10 @@ 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-(--vk-panel-w,calc(var(--spacing)*75))"), onSheetEscape: step.escapeBack, children: ({ fill, close, closeButton }) => (_jsx(
|
|
36
|
+
: viewOptionsPopoverClassName(null, "w-(--vk-panel-w,calc(var(--spacing)*75))"), onSheetEscape: step.escapeBack, children: ({ fill, close, closeButton }) => (_jsx(OptionsBody, { ...inputs, step: step, page: page, onPageChange: setPage, count: count, clear: clear, close: close, closeButton: closeButton, fill: fill, foldFilters: foldFilters, view: view, viewFoot: viewFoot, footClear: footClear, resets: resets, layered: layered, customizeItems: customizeItems, fieldEditor: fieldEditor, viewName: viewName, onRenameView: onRenameView, onCopyLink: onCopyLink, onExport: onExport, exportCount: exportCount })) }));
|
|
37
|
+
}
|
|
38
|
+
export function OptionsBody({ step: stepIn, page, onPageChange, count, clear, close, closeButton, fill, foldFilters = true, view, viewFoot, footClear, resets, layered, customizeItems, fieldEditor, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }) {
|
|
39
|
+
const own = usePanelStep();
|
|
40
|
+
const step = stepIn ?? own;
|
|
41
|
+
return (_jsx(PanelStepHold.Provider, { value: step, children: _jsx(ViewOptionsPanelContent, { ...inputs, activePanel: page, onOpenPanel: onPageChange, 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
42
|
}
|
|
@@ -21,6 +21,11 @@ type PillProps = {
|
|
|
21
21
|
/** Lit while the sort differs from the saved view (VK-1046), whatever it would light by on its own: the ready toolbar
|
|
22
22
|
* hands it. Absent, as before: the row lit while a sort stands, the pill while the sort differs from `defaultRules`. */
|
|
23
23
|
changed?: boolean;
|
|
24
|
+
/** On the row (VK-1091), what a press opens with no sort set: the fields (`fields`, the default), or the sort editor saying
|
|
25
|
+
* nothing sorts yet, Add sort under it (`editor`), which stays open as its last rule is taken away. */
|
|
26
|
+
empty?: "fields" | "editor";
|
|
27
|
+
/** On the row (VK-1091): a press opens the fields every time, a sort standing or not, a pick adding its rule. Default false. */
|
|
28
|
+
fieldsOnly?: boolean;
|
|
24
29
|
};
|
|
25
30
|
export declare function ToolbarSortPill(props: PillProps): ReactNode;
|
|
26
31
|
export {};
|
|
@@ -16,7 +16,7 @@ export function ToolbarSortPill(props) {
|
|
|
16
16
|
return null;
|
|
17
17
|
return (_jsx("span", { "data-slot": props.row ? "vk-toolbar-sort-row" : "vk-toolbar-sort-pill", className: "relative inline-flex shrink-0 items-center gap-1", children: phone ? _jsx(PhonePill, { ...props }) : _jsx(ComputerPill, { ...props }) }));
|
|
18
18
|
}
|
|
19
|
-
function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host: Host, addAfter: addAfterIn = true, row = false, changed, }) {
|
|
19
|
+
function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host: Host, addAfter: addAfterIn = true, row = false, changed, empty, fieldsOnly = false, }) {
|
|
20
20
|
const addAfter = row ? false : addAfterIn;
|
|
21
21
|
const { components, icons, messages } = useViews();
|
|
22
22
|
const { Popover } = components;
|
|
@@ -31,7 +31,9 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
31
31
|
const asideOnly = !named && (sorts.setAside?.length ?? 0) > 0;
|
|
32
32
|
const places = openSortPlaces(sorts);
|
|
33
33
|
const can = canAddSortRule(sorts.rules, places);
|
|
34
|
-
const
|
|
34
|
+
const editorEmpty = row && empty === "editor" && !fieldsOnly;
|
|
35
|
+
const editorFirst = !fieldsOnly && (named || asideOnly || editorEmpty);
|
|
36
|
+
const opens = row ? { what: editorFirst ? "editor" : "fields", at: "pill", addSort: true } : pressed;
|
|
35
37
|
const Glyph = icons.sort;
|
|
36
38
|
const Plus = icons.add;
|
|
37
39
|
const name = messages({ key: "views.panels.sort" });
|
|
@@ -58,11 +60,11 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
58
60
|
...sorts,
|
|
59
61
|
onChange: (next, setAside) => {
|
|
60
62
|
sorts.onChange(next, setAside);
|
|
61
|
-
if (next.length === 0 && (setAside ?? sorts.setAside ?? []).length === 0)
|
|
63
|
+
if (next.length === 0 && (setAside ?? sorts.setAside ?? []).length === 0 && !editorEmpty)
|
|
62
64
|
close();
|
|
63
65
|
},
|
|
64
66
|
};
|
|
65
|
-
const content = opens.what === "editor" ? (_jsx(SortEditorHost, { sorts: editing, form: "computer", addSort: opens.addSort, onDone: () => close() })) : (_jsx(SortFieldList, { sorts: sorts, onPick: (value) => {
|
|
67
|
+
const content = opens.what === "editor" ? (_jsx(SortEditorHost, { sorts: editing, form: "computer", addSort: opens.addSort, onDone: () => close(), ...(editorEmpty && { empty: "editor" }) })) : (_jsx(SortFieldList, { sorts: sorts, onPick: (value) => {
|
|
66
68
|
const next = addSortRule(sorts.rules, value, places);
|
|
67
69
|
sorts.onChange(next);
|
|
68
70
|
close(true, opens.at === "add" && canAddSortRule(next, places));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { type CollectionViewsInput, type ViewsLayout } from "../../views-row/model.js";
|
|
3
|
-
export declare function ToolbarViews({ views, viewsLayout, showCounts, as, stacked, }: {
|
|
3
|
+
export declare function ToolbarViews({ views, viewsLayout, showCounts, as, stacked, press, }: {
|
|
4
4
|
views: CollectionViewsInput<string>;
|
|
5
5
|
/** How several axes stand: `stacked` (the default) puts every axis after the first on the line beneath. */
|
|
6
6
|
viewsLayout?: ViewsLayout;
|
|
@@ -10,4 +10,10 @@ export declare function ToolbarViews({ views, viewsLayout, showCounts, as, stack
|
|
|
10
10
|
as?: "row" | "picker";
|
|
11
11
|
/** This part is the second line's: the axes a stacked layout pushes beneath. */
|
|
12
12
|
stacked?: boolean;
|
|
13
|
+
/** Its picker's list stands elsewhere (VK-1092): handed on to the picker, whose chip calls it and opens no list. */
|
|
14
|
+
press?: {
|
|
15
|
+
onPress: () => void;
|
|
16
|
+
expanded: boolean;
|
|
17
|
+
lit?: boolean;
|
|
18
|
+
};
|
|
13
19
|
}): ReactNode;
|
|
@@ -6,11 +6,11 @@ import { ViewAxes } from "../views-row/ViewAxes.js";
|
|
|
6
6
|
import { ViewsRowInFrameProvider } from "../views-row/in-frame.js";
|
|
7
7
|
import { ViewPicker } from "../views-row/ViewPicker.js";
|
|
8
8
|
import { useToolbarSlot } from "./context.js";
|
|
9
|
-
export function ToolbarViews({ views, viewsLayout, showCounts, as = "row", stacked = false, }) {
|
|
9
|
+
export function ToolbarViews({ views, viewsLayout, showCounts, as = "row", stacked = false, press, }) {
|
|
10
10
|
const { appFrame } = useToolbarSlot();
|
|
11
|
-
return (_jsx(ViewsRowInFrameProvider, { on: appFrame, children: _jsx(ToolbarViewsBody, { views: views, viewsLayout: viewsLayout, showCounts: showCounts, as: as, stacked: stacked }) }));
|
|
11
|
+
return (_jsx(ViewsRowInFrameProvider, { on: appFrame, children: _jsx(ToolbarViewsBody, { views: views, viewsLayout: viewsLayout, showCounts: showCounts, as: as, stacked: stacked, press: press }) }));
|
|
12
12
|
}
|
|
13
|
-
function ToolbarViewsBody({ views, viewsLayout, showCounts, as, stacked, }) {
|
|
13
|
+
function ToolbarViewsBody({ views, viewsLayout, showCounts, as, stacked, press, }) {
|
|
14
14
|
const { form, fold, tabsFolded } = useToolbarSlot();
|
|
15
15
|
const counted = showCounts === undefined ? views : (withCounts(views, showCounts) ?? views);
|
|
16
16
|
if (form === "phone") {
|
|
@@ -24,6 +24,6 @@ function ToolbarViewsBody({ views, viewsLayout, showCounts, as, stacked, }) {
|
|
|
24
24
|
if (!viewAxes)
|
|
25
25
|
return null;
|
|
26
26
|
if (as === "picker" && viewAxes.length === 1 && !stackedAxes)
|
|
27
|
-
return _jsx(ViewPicker, { axis: viewAxes[0] });
|
|
27
|
+
return _jsx(ViewPicker, { axis: viewAxes[0], ...(press && { press }) });
|
|
28
28
|
return _jsx(ViewAxes, { axes: viewAxes, folded: fold ? tabsFolded : undefined });
|
|
29
29
|
}
|
|
@@ -2,6 +2,10 @@ import { type ReactNode, type RefObject, type ComponentType } from "react";
|
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
3
|
import type { ViewsAlign, ViewsSide } from "../../../provider/components.js";
|
|
4
4
|
import type { ToolbarForm, ToolbarLine } from "../../toolbar/model.js";
|
|
5
|
+
/** The toolbar buttons' words a person picked in their own Customize, where the app lets them: over each button's
|
|
6
|
+
* own placement (`ToolbarSlotState.words`), `both` its icon and word, `icon` its icon alone, `word` its word alone. Undefined,
|
|
7
|
+
* each button as placed. A list root provides it (not on the door). */
|
|
8
|
+
export declare const PersonWordsContext: import("react").Context<"icon" | "word" | "both" | undefined>;
|
|
5
9
|
/** Where a part stands: the toolbar's form, whether it fills its line, its buttons' size, and its line's kind.
|
|
6
10
|
* In the fold arrangement (`fold`), also how far its line gave way: whether its words turned to its icon
|
|
7
11
|
* (`iconAlone`), how many of its view tabs folded into "+N" (`tabsFolded`), how many of its filters folded into
|
|
@@ -1,6 +1,7 @@
|
|
|
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 const PersonWordsContext = createContext(undefined);
|
|
4
5
|
export function usePanelPlace(own) {
|
|
5
6
|
const { side, panel } = useToolbarSlot();
|
|
6
7
|
return { ...(panel?.side && { side: panel.side }), align: panel?.align ?? side ?? own, sideOffset: panel?.offset ?? 8 };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { PanelSheet } from "../panel-sheet.js";
|
|
4
|
+
export function SheetHost({ open, onOpenChange, title, children }) {
|
|
5
|
+
return (_jsx(PanelSheet, { open: open, onOpenChange: onOpenChange, title: title, snap: "full", headed: true, children: children }));
|
|
6
|
+
}
|
|
@@ -2,3 +2,9 @@
|
|
|
2
2
|
export declare function overflows(line: HTMLElement): boolean;
|
|
3
3
|
/** The stage a line stands at, out of `max` steps; `on` false, 0. */
|
|
4
4
|
export declare function useGiveWay(line: HTMLElement | null, max: number, on: boolean): number;
|
|
5
|
+
/** The stage, and a fresh look to ask for (not on the door, VK-1105): a line whose parts draw themselves (`ListLine`) asks it
|
|
6
|
+
* when one of them changes its width on its own, which no width of the line's and no render of it shows. */
|
|
7
|
+
export declare function useGiveWayLook(line: HTMLElement | null, max: number, on: boolean): {
|
|
8
|
+
stage: number;
|
|
9
|
+
look: () => void;
|
|
10
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { beforePaint } from "../../../internal/before-paint.js";
|
|
4
4
|
const HOLDING = [
|
|
5
5
|
'[data-slot="vk-toolbar-overflow"] [aria-expanded="true"]',
|
|
6
6
|
'[data-slot="vk-views-more"][aria-expanded="true"]',
|
|
@@ -29,6 +29,9 @@ export function overflows(line) {
|
|
|
29
29
|
return far > edge + 0.5;
|
|
30
30
|
}
|
|
31
31
|
export function useGiveWay(line, max, on) {
|
|
32
|
+
return useGiveWayLook(line, max, on).stage;
|
|
33
|
+
}
|
|
34
|
+
export function useGiveWayLook(line, max, on) {
|
|
32
35
|
const [fit, setFit] = useState({ stage: 0, mode: "done" });
|
|
33
36
|
const stage = on ? Math.min(fit.stage, max) : 0;
|
|
34
37
|
const ours = useRef(false);
|
|
@@ -57,7 +60,7 @@ export function useGiveWay(line, max, on) {
|
|
|
57
60
|
useEffect(() => {
|
|
58
61
|
if (!line || !on)
|
|
59
62
|
return;
|
|
60
|
-
const again = () =>
|
|
63
|
+
const again = () => beforePaint(() => look(latest.current.stage, latest.current.max));
|
|
61
64
|
let width = -1;
|
|
62
65
|
const sized = new ResizeObserver((entries) => {
|
|
63
66
|
const w = entries?.[0]?.contentRect.width;
|
|
@@ -80,7 +83,11 @@ export function useGiveWay(line, max, on) {
|
|
|
80
83
|
fonts?.removeEventListener?.("loadingdone", again);
|
|
81
84
|
};
|
|
82
85
|
}, [line, on, look]);
|
|
83
|
-
|
|
86
|
+
const lookNow = useCallback(() => {
|
|
87
|
+
if (line && on)
|
|
88
|
+
look(latest.current.stage, latest.current.max);
|
|
89
|
+
}, [line, on, look]);
|
|
90
|
+
return { stage, look: lookNow };
|
|
84
91
|
}
|
|
85
92
|
function freshLook(line, at, top, set) {
|
|
86
93
|
if (!line || line.querySelector(HOLDING))
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { type CollectionViewsConfig } from "../../views-row/model.js";
|
|
2
|
-
export declare function ViewPicker({ axis, className }: {
|
|
2
|
+
export declare function ViewPicker({ axis, className, press, }: {
|
|
3
3
|
axis: CollectionViewsConfig<string>;
|
|
4
4
|
className?: string;
|
|
5
|
+
/** Its list stands elsewhere (VK-1092: a placed views list): the chip calls `onPress`, says `expanded`, opens no list, and
|
|
6
|
+
* lights only with `lit` (the list standing because the chip showed it). */
|
|
7
|
+
press?: {
|
|
8
|
+
onPress: () => void;
|
|
9
|
+
expanded: boolean;
|
|
10
|
+
lit?: boolean;
|
|
11
|
+
};
|
|
5
12
|
}): import("react/jsx-runtime").JSX.Element | null;
|