viewkitjs 0.34.0 → 0.36.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 +173 -0
- package/MIGRATION.md +7 -0
- package/package.json +1 -1
- package/views/README.md +1 -1
- package/views/dist/atoms/Avatar.js +2 -1
- package/views/dist/atoms/RelationChip.d.ts +2 -0
- package/views/dist/atoms/RelationChip.js +5 -0
- package/views/dist/atoms/RowMenu.d.ts +1 -1
- package/views/dist/atoms/RowMenu.js +15 -3
- package/views/dist/atoms/defaults.js +2 -0
- package/views/dist/atoms/types.d.ts +40 -4
- package/views/dist/cells/relation-wrap.js +9 -2
- package/views/dist/contract.d.ts +27 -7
- package/views/dist/contract.js +25 -2
- package/views/dist/controls/avatar/avatar-mark.d.ts +4 -0
- package/views/dist/controls/avatar/avatar-mark.js +5 -0
- package/views/dist/controls/avatar/avatar.d.ts +10 -5
- package/views/dist/controls/avatar/avatar.js +12 -6
- package/views/dist/controls/avatar/looks.d.ts +1 -1
- package/views/dist/controls/avatar/looks.js +3 -0
- package/views/dist/controls/avatar/record-mark.d.ts +16 -0
- package/views/dist/controls/avatar/record-mark.js +13 -0
- package/views/dist/controls/avatar/tokens.d.ts +12 -0
- package/views/dist/controls/avatar/tokens.js +3 -0
- package/views/dist/controls/avatar.css +54 -17
- package/views/dist/controls/bulk-bar/bulk-bar.js +4 -5
- package/views/dist/controls/bulk-bar/map-selection-bar.js +2 -1
- package/views/dist/controls/compound-editor/compound-editor.d.ts +3 -0
- package/views/dist/controls/compound-editor/map-parts-body.d.ts +1 -1
- package/views/dist/controls/compound-editor/map-parts-body.js +8 -1
- package/views/dist/controls/compound-editor/name-parts.js +3 -2
- package/views/dist/controls/compound-editor/place-parts.js +3 -3
- package/views/dist/controls/compound-editor/range-parts.js +11 -10
- package/views/dist/controls/compound-editor/words.d.ts +3 -0
- package/views/dist/controls/compound-editor/words.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +22 -6
- package/views/dist/controls/customize/customize.js +154 -73
- package/views/dist/controls/customize/items.d.ts +49 -0
- package/views/dist/controls/customize/items.js +104 -0
- package/views/dist/controls/customize/map-customize-body.js +19 -15
- package/views/dist/controls/customize/words.d.ts +5 -3
- package/views/dist/controls/customize/words.js +1 -0
- package/views/dist/controls/filter-editor/block.js +5 -2
- package/views/dist/controls/filter-editor/filter-editor.d.ts +16 -1
- package/views/dist/controls/filter-editor/filter-editor.js +22 -16
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +3 -2
- package/views/dist/controls/filter-editor/map-filter-body.js +16 -2
- package/views/dist/controls/filter-editor/map-rules.d.ts +9 -2
- package/views/dist/controls/filter-editor/map-rules.js +18 -13
- package/views/dist/controls/filter-editor/parts.d.ts +1 -1
- package/views/dist/controls/filter-editor/parts.js +16 -15
- package/views/dist/controls/filter-editor/rules.d.ts +4 -4
- package/views/dist/controls/filter-editor/rules.js +6 -3
- package/views/dist/controls/filter-editor/words.d.ts +2 -0
- package/views/dist/controls/filter-editor/words.js +1 -0
- package/views/dist/controls/group-editor/group-editor.d.ts +3 -0
- package/views/dist/controls/group-editor/group-editor.js +21 -15
- package/views/dist/controls/group-editor/map-group-body.js +1 -0
- package/views/dist/controls/index.d.ts +1 -1
- package/views/dist/controls/internal/kit-words.d.ts +11 -0
- package/views/dist/controls/internal/kit-words.js +7 -0
- package/views/dist/controls/internal/map-panel-controls.d.ts +4 -1
- package/views/dist/controls/internal/map-panel-controls.js +23 -6
- package/views/dist/controls/internal/menu-items.d.ts +9 -0
- package/views/dist/controls/internal/menu-items.js +97 -0
- package/views/dist/controls/internal/panel-controls.d.ts +27 -3
- package/views/dist/controls/internal/panel-controls.js +142 -13
- package/views/dist/controls/links-editor/links-editor.js +5 -7
- package/views/dist/controls/links-editor/map-links-body.d.ts +1 -1
- package/views/dist/controls/links-editor/map-links-body.js +5 -1
- package/views/dist/controls/menu/menu.d.ts +4 -1
- package/views/dist/controls/menu/menu.js +3 -2
- package/views/dist/controls/number-editor/map-number-body.js +2 -0
- package/views/dist/controls/number-editor/number-editor.js +1 -1
- package/views/dist/controls/number-editor/words.d.ts +3 -0
- package/views/dist/controls/number-editor/words.js +2 -0
- package/views/dist/controls/picker/fields-frame.d.ts +5 -0
- package/views/dist/controls/picker/fields-frame.js +30 -0
- package/views/dist/controls/picker/map-fields-body.d.ts +2 -2
- package/views/dist/controls/picker/map-fields-body.js +7 -26
- package/views/dist/controls/picker/map-picker.d.ts +9 -3
- package/views/dist/controls/picker/map-picker.js +16 -3
- package/views/dist/controls/picker/picker.js +20 -10
- package/views/dist/controls/picker/rows.d.ts +9 -2
- package/views/dist/controls/picker.css +2 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +2 -1
- package/views/dist/controls/quick-filters/quick-filters.js +4 -4
- package/views/dist/controls/quick-filters/reminder.js +2 -2
- package/views/dist/controls/quick-filters/rules.d.ts +4 -1
- package/views/dist/controls/quick-filters/words.d.ts +2 -0
- package/views/dist/controls/quick-filters/words.js +1 -0
- package/views/dist/controls/select/map-select.d.ts +1 -1
- package/views/dist/controls/select/map-select.js +4 -1
- package/views/dist/controls/select/select.d.ts +5 -0
- package/views/dist/controls/select/select.js +11 -3
- package/views/dist/controls/sheet/bottom-sheet.d.ts +6 -1
- package/views/dist/controls/sheet/bottom-sheet.js +3 -3
- package/views/dist/controls/sort-editor/map-sort-body.js +1 -0
- package/views/dist/controls/sort-editor/sort-editor.d.ts +5 -1
- package/views/dist/controls/sort-editor/sort-editor.js +9 -8
- package/views/dist/controls/tag/tag.js +4 -2
- package/views/dist/controls/text-editor/map-text-body.js +4 -1
- package/views/dist/controls/text-editor/text-editor.js +2 -2
- package/views/dist/controls/text-editor/words.d.ts +3 -0
- package/views/dist/controls/text-editor/words.js +1 -1
- package/views/dist/controls/toolbar/toolbar.d.ts +31 -12
- package/views/dist/controls/toolbar/toolbar.js +15 -20
- package/views/dist/controls/toolbar.css +0 -5
- package/views/dist/controls/tooltip/map-tooltip.d.ts +1 -1
- package/views/dist/controls/tooltip/map-tooltip.js +4 -2
- package/views/dist/controls/values-editor/map-values-body.d.ts +1 -2
- package/views/dist/controls/values-editor/map-values-body.js +5 -1
- package/views/dist/controls/values-editor/values-editor.js +8 -7
- package/views/dist/controls/views-list/map-views-list-body.js +9 -1
- package/views/dist/controls/views-list/rules.d.ts +1 -0
- package/views/dist/controls/views-list/rules.js +2 -2
- package/views/dist/controls/views-list/view-menu.js +2 -2
- package/views/dist/controls/views-list/words.d.ts +4 -0
- package/views/dist/controls/views-list/words.js +2 -1
- package/views/dist/display/option-badges.d.ts +17 -0
- package/views/dist/display/option-badges.js +11 -0
- package/views/dist/display/relation-link.d.ts +12 -0
- package/views/dist/display/relation-link.js +17 -0
- package/views/dist/display/relation.d.ts +1 -1
- package/views/dist/display/relation.js +10 -3
- package/views/dist/display/select.js +1 -8
- package/views/dist/editors/EditorPanel.js +1 -1
- package/views/dist/editors/RangeEditor.d.ts +3 -0
- package/views/dist/editors/RangeEditor.js +2 -2
- package/views/dist/editors/SelectEditor.d.ts +2 -2
- package/views/dist/editors/SelectEditor.js +1 -1
- package/views/dist/editors/TextEditor.js +4 -2
- package/views/dist/editors/ValueListEditor.js +2 -1
- package/views/dist/field-row/FieldRow.js +32 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/views/dist/grid/chrome/GridAddColumn.d.ts +7 -2
- package/views/dist/grid/chrome/GridAddColumn.js +13 -9
- package/views/dist/grid/chrome/GridCellEditors.js +1 -1
- package/views/dist/grid/chrome/GridCellOutline.d.ts +3 -1
- package/views/dist/grid/chrome/GridCellOutline.js +16 -6
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -2
- package/views/dist/grid/chrome/GridColumnMenu.js +7 -4
- package/views/dist/grid/chrome/GridFooter.d.ts +4 -1
- package/views/dist/grid/chrome/GridFooter.js +4 -4
- package/views/dist/grid/chrome/GridGroupMenu.js +39 -14
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -1
- package/views/dist/grid/chrome/GridHeader.js +4 -3
- package/views/dist/grid/chrome/GridNumberEditor.js +1 -1
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +4 -1
- package/views/dist/grid/chrome/GridRangeEditor.js +2 -2
- package/views/dist/grid/chrome/GridRow.js +11 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +4 -1
- package/views/dist/grid/chrome/GridRowActions.js +2 -2
- package/views/dist/grid/chrome/GridRowCells.js +3 -2
- package/views/dist/grid/chrome/GridStructure.js +1 -1
- package/views/dist/grid/chrome/GridTable.js +32 -20
- package/views/dist/grid/chrome/GridTableSurface.js +2 -1
- package/views/dist/grid/chrome/checks.d.ts +1 -1
- package/views/dist/grid/chrome/checks.js +4 -1
- package/views/dist/grid/chrome/grid-cell-classes.d.ts +6 -2
- package/views/dist/grid/chrome/grid-cell-classes.js +10 -5
- package/views/dist/grid/chrome/grid-fitted-box.d.ts +5 -2
- package/views/dist/grid/chrome/grid-fitted-box.js +14 -4
- package/views/dist/grid/chrome/grid-hover.d.ts +10 -2
- package/views/dist/grid/chrome/grid-hover.js +14 -4
- package/views/dist/grid/chrome/grid-row-props.d.ts +4 -0
- package/views/dist/grid/chrome/grid-rows-menu.js +9 -4
- package/views/dist/grid/chrome/grid-table-props.d.ts +16 -4
- package/views/dist/grid/chrome/useGridScaleStyles.d.ts +9 -1
- package/views/dist/grid/chrome/useGridScaleStyles.js +1 -4
- package/views/dist/grid/grid-format-props.d.ts +1 -1
- package/views/dist/grid/grid-format-props.js +18 -5
- package/views/dist/grid/grid.css +11 -1
- package/views/dist/grid/looks.d.ts +3 -1
- package/views/dist/grid/looks.js +10 -4
- package/views/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/views/dist/grid/useGridTableSettings.d.ts +1 -1
- package/views/dist/list/layer.d.ts +8 -0
- package/views/dist/list/layer.js +7 -0
- package/views/dist/list/list.js +2 -2
- package/views/dist/list/menu.d.ts +5 -4
- package/views/dist/list/store.d.ts +1 -1
- package/views/dist/list/toolbar.js +47 -20
- package/views/dist/list/views.js +1 -0
- package/views/dist/panels/availability.d.ts +5 -0
- package/views/dist/panels/availability.js +4 -5
- package/views/dist/panels/customize-body.d.ts +5 -1
- package/views/dist/panels/customize-body.js +21 -12
- package/views/dist/panels/model.d.ts +14 -4
- package/views/dist/panels/react/customize-body.js +15 -3
- package/views/dist/panels/react/customize.d.ts +8 -0
- package/views/dist/panels/react/filter/FilterEditor.d.ts +6 -0
- package/views/dist/panels/react/filter/FilterEditor.js +7 -0
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +3 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +2 -2
- package/views/dist/panels/react/filter/filter-body.js +3 -1
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -1
- package/views/dist/panels/react/filter/filter-part-body.js +2 -2
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +3 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
- package/views/dist/panels/react/sort/SortEditor.js +3 -1
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +13 -2
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +11 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +16 -6
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +5 -3
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +12 -5
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +18 -8
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +9 -1
- package/views/dist/panels/react/toolbar/ToolbarOptions.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.d.ts +3 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +5 -4
- package/views/dist/panels/react/toolbar/ToolbarSort.d.ts +7 -1
- package/views/dist/panels/react/toolbar/ToolbarSort.js +6 -3
- package/views/dist/panels/react/toolbar/ToolbarSortPill.d.ts +3 -0
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +4 -4
- package/views/dist/panels/react/toolbar/editor-menus.d.ts +8 -0
- package/views/dist/panels/react/toolbar/editor-menus.js +3 -0
- package/views/dist/panels/react/views-row/FoldingViewRow.js +3 -5
- package/views/dist/panels/react/views-row/HScrollRow.d.ts +4 -2
- package/views/dist/panels/react/views-row/HScrollRow.js +6 -2
- package/views/dist/panels/react/views-row/ViewAxes.js +6 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +8 -3
- package/views/dist/panels/react/views-row/new-view.d.ts +11 -0
- package/views/dist/panels/react/views-row/new-view.js +21 -0
- package/views/dist/panels/react.d.ts +1 -1
- package/views/dist/panels/settings/layout.js +6 -38
- package/views/dist/panels/toolbar/page-resets.d.ts +17 -0
- package/views/dist/panels/toolbar/page-resets.js +62 -0
- package/views/dist/panels/toolbar/same-item.d.ts +7 -0
- package/views/dist/panels/toolbar/same-item.js +9 -0
- package/views/dist/panels/view-state.d.ts +4 -0
- package/views/dist/provider/ViewsProvider.d.ts +9 -4
- package/views/dist/provider/ViewsProvider.js +13 -2
- package/views/dist/provider/components.d.ts +109 -7
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/styles.css +115 -27
- package/views/dist/styles.unlayered.css +115 -27
- package/views/docs/contract.md +55 -35
- package/views/docs/controls/avatar.md +3 -0
- package/views/docs/controls/bulk-bar.md +3 -1
- package/views/docs/controls/compound-editor.md +2 -0
- package/views/docs/controls/customize.md +1 -1
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/links-editor.md +2 -0
- package/views/docs/controls/pane.md +1 -1
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/quick-filters.md +1 -1
- package/views/docs/controls/text-editor.md +1 -1
- package/views/docs/controls/values-editor.md +2 -0
- package/views/docs/guides/atoms.md +54 -3
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/looks.md +1 -1
- package/views/docs/guides/the-grid.md +4 -2
- package/views/docs/guides/the-provider.md +2 -2
- package/views/docs/index.md +2 -2
- package/views/docs/install.md +198 -104
- package/views/docs/reference/controls.md +27 -24
- package/views/docs/reference/editors-range.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +6 -5
- package/views/docs/reference/list.md +27 -7
- package/views/docs/reference/looks.md +5 -5
- package/views/docs/reference/panels-react.md +15 -14
- package/views/docs/reference/panels.md +5 -5
- package/views/docs/reference/react.md +25 -11
- package/views/docs/reference/views.md +2 -2
- package/views/docs/reshaping.md +22 -6
- package/views/skills/views/SKILL.md +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { WholeFilterEditor } from "../filter/FilterEditor.js";
|
|
3
4
|
import { useRef } from "react";
|
|
4
5
|
import { useViews } from "../../../provider/context.js";
|
|
5
6
|
import { listedFieldsOf } from "../../settings/filter-groups.js";
|
|
@@ -8,7 +9,7 @@ import { useSheetPanels } from "../panel-sheet.js";
|
|
|
8
9
|
import { useFoldAnchor, usePanelPlace, useToolbarPanel } from "./context.js";
|
|
9
10
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
10
11
|
import { useFilterAdd } from "./use-filter-add.js";
|
|
11
|
-
export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, }) {
|
|
12
|
+
export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange, host, changed = false, opens = "fields", }) {
|
|
12
13
|
const { components, icons, messages } = useViews();
|
|
13
14
|
const { Popover } = components;
|
|
14
15
|
const phone = useSheetPanels();
|
|
@@ -29,15 +30,19 @@ export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange,
|
|
|
29
30
|
fields.onOpenChange(false);
|
|
30
31
|
onPick(picked, far);
|
|
31
32
|
};
|
|
32
|
-
const
|
|
33
|
+
const close = () => {
|
|
34
|
+
fields.onOpenChange(false);
|
|
35
|
+
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
36
|
+
};
|
|
37
|
+
const list = opens === "filters" ? (_jsx(WholeFilterEditor, { filterTree: filterTree, onDone: close })) : (_jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: pick, onDone: () => {
|
|
33
38
|
fields.onOpenChange(false);
|
|
34
39
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
35
40
|
} }));
|
|
36
41
|
const HostPanel = host;
|
|
37
|
-
return (_jsxs("span", { "data-slot": "vk-toolbar-filter-add-row", "data-open": hangsAt.fold && fields.open ? "" : undefined, className: "relative inline-flex shrink-0", children: [_jsx(ToolbarButton, { ref: box, part: "filter-add", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, popup: "dialog", open: fields.open, disabled: !!refusal, disabledReason: reason, onPointerDown: () => {
|
|
42
|
+
return (_jsxs("span", { "data-slot": "vk-toolbar-filter-add-row", "data-open": hangsAt.fold && fields.open ? "" : undefined, className: "relative inline-flex shrink-0", children: [_jsx(ToolbarButton, { ref: box, part: "filter-add", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, popup: "dialog", open: fields.open, changed: changed, disabled: opens === "fields" && !!refusal, disabledReason: opens === "fields" ? reason : undefined, onPointerDown: () => {
|
|
38
43
|
atPress.current = fields.open;
|
|
39
44
|
}, onClick: (event) => {
|
|
40
|
-
if (refusal)
|
|
45
|
+
if (opens === "fields" && refusal)
|
|
41
46
|
return;
|
|
42
47
|
const wasOpen = event.detail === 0 ? fields.open : atPress.current;
|
|
43
48
|
atPress.current = false;
|
|
@@ -47,5 +52,7 @@ export function ToolbarFilterAdd({ filterTree, onHeldChange, open, onOpenChange,
|
|
|
47
52
|
const why = details?.reason;
|
|
48
53
|
if (!next && why !== "outside-press" && why !== "focus-out")
|
|
49
54
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
50
|
-
}, anchor: hangsAt.anchor, ...hangs,
|
|
55
|
+
}, anchor: hangsAt.anchor, ...hangs, ...(opens === "filters"
|
|
56
|
+
? { chrome: "panel", className: "w-fit max-w-[calc(100vw-2rem)]" }
|
|
57
|
+
: { chrome: "menu" }), panelData: { "data-slot": "vk-toolbar-filters-panel" }, children: list }))] }));
|
|
51
58
|
}
|
|
@@ -3,9 +3,10 @@ import { type FilterTree } from "viewkitjs/fields/query";
|
|
|
3
3
|
import type { FilterTreeConfig } from "../../model.js";
|
|
4
4
|
import { type Pending } from "../filter/editor-ctx.js";
|
|
5
5
|
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
6
|
-
/** How many of the bar's filters may fold: its top-level items less the one a held rule stands in place of
|
|
7
|
-
|
|
8
|
-
export declare function
|
|
6
|
+
/** How many of the bar's filters may fold: its top-level items less the one a held rule stands in place of, and less the
|
|
7
|
+
* saved view's own (`saved`, VK-1046), which stand in Customize, not on the bar. */
|
|
8
|
+
export declare function foldableFilters(tree: FilterTree, held: Pending | null, saved?: FilterTree): number;
|
|
9
|
+
export declare function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenChangeIn, held: heldIn, onHeldChange, host, emptyPlace, saved, }: {
|
|
9
10
|
/** The builder's filter tree: `settingsPanels(…).filterTree`, with `filterGroups`. */
|
|
10
11
|
filterTree: FilterTreeConfig;
|
|
11
12
|
/** Whether Filter and + list its fields' pages open: the ready toolbar holds it, so ⋯ can open Filter. */
|
|
@@ -19,4 +20,7 @@ export declare function ToolbarFilters({ filterTree, open: openIn, onOpenChange:
|
|
|
19
20
|
/** While nothing filters, Filter, an empty place (the default); false, nothing, where Filter stands on the row's right
|
|
20
21
|
* instead (`ToolbarFilterAdd`, Mihai's look): the bar holds a filter only once one is set or held. */
|
|
21
22
|
emptyPlace?: boolean;
|
|
23
|
+
/** The saved view's filter (VK-1046): its own top-level items stand in Customize, not on the bar, and an edited one
|
|
24
|
+
* stands as edited; every write is still the whole filter's. Absent, every filter stands, as before. */
|
|
25
|
+
saved?: FilterTree;
|
|
22
26
|
}): ReactNode;
|
|
@@ -15,14 +15,18 @@ import { ToolbarAsideFilter } from "./ToolbarAsideFilter.js";
|
|
|
15
15
|
import { ToolbarBarFilter } from "./ToolbarBarFilter.js";
|
|
16
16
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
17
17
|
import { useFilterAdd } from "./use-filter-add.js";
|
|
18
|
+
import { savedItem } from "../../toolbar/same-item.js";
|
|
18
19
|
const rowFilterIn = (root) => root?.querySelector('[data-slot="vk-toolbar-filter-add-row"] button') ?? null;
|
|
19
|
-
export function foldableFilters(tree, held) {
|
|
20
|
-
const items = barItemsOf(tree);
|
|
20
|
+
export function foldableFilters(tree, held, saved) {
|
|
21
21
|
const replaces = heldStands(held, tree)?.replaces;
|
|
22
|
+
const items = barItemsOf(tree).filter((item) => !(saved && isSavedOnBar(tree, item.path, saved, replaces)));
|
|
22
23
|
const standsIn = replaces ? items.some((item) => samePath(item.path, replaces)) : false;
|
|
23
24
|
return items.length - (standsIn ? 1 : 0);
|
|
24
25
|
}
|
|
25
|
-
|
|
26
|
+
function isSavedOnBar(tree, path, saved, replaces) {
|
|
27
|
+
return path.length === 1 && !(replaces && samePath(replaces, path)) && savedItem(tree, path[0], saved);
|
|
28
|
+
}
|
|
29
|
+
export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenChangeIn, held: heldIn, onHeldChange, host, emptyPlace = true, saved, }) {
|
|
26
30
|
const { components, conventions, icons, messages } = useViews();
|
|
27
31
|
const { Menu, Popover } = components;
|
|
28
32
|
const phone = useSheetPanels();
|
|
@@ -144,6 +148,8 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
144
148
|
return i >= 0 ? (now.keys[i] ?? `bf-pending-${i}`) : null;
|
|
145
149
|
};
|
|
146
150
|
const heldKey = pending ? ((pending.replaces && keyAt(pending.replaces)) ?? added.key) : null;
|
|
151
|
+
const off = (item) => !!saved && isSavedOnBar(tree, item.path, saved, pending?.replaces);
|
|
152
|
+
const standing = items.filter((item) => !off(item)).length;
|
|
147
153
|
const shown = items.map((item) => {
|
|
148
154
|
if (item.kind === "far" && !relationOf(ctx, item.relation.fieldKey))
|
|
149
155
|
return { kind: "advanced", path: item.path, count: 1 };
|
|
@@ -156,7 +162,8 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
156
162
|
: null;
|
|
157
163
|
const candidates = shown
|
|
158
164
|
.map((item, i) => ({ item, i, key: now.keys[i] ?? `bf-pending-${i}` }))
|
|
159
|
-
.filter(({ item, key }) => !(
|
|
165
|
+
.filter(({ item, key }) => !off(item) &&
|
|
166
|
+
!(pending?.replaces && samePath(pending.replaces, item.path)) &&
|
|
160
167
|
!(open?.key === key && open.via === "bar"));
|
|
161
168
|
const folding = candidates.slice(Math.max(0, candidates.length - slot.filtersFolded));
|
|
162
169
|
const folded = new Set(folding.map(({ key }) => key));
|
|
@@ -194,6 +201,8 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
194
201
|
};
|
|
195
202
|
const drawn = shown.map((item, i) => {
|
|
196
203
|
const key = now.keys[i] ?? `bf-pending-${i}`;
|
|
204
|
+
if (off(item))
|
|
205
|
+
return null;
|
|
197
206
|
if (pending?.replaces && samePath(pending.replaces, item.path))
|
|
198
207
|
return heldFilter();
|
|
199
208
|
const aside = asideOf(item);
|
|
@@ -258,9 +267,10 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
258
267
|
fields.onOpenChange(false);
|
|
259
268
|
addPicked(picked, far);
|
|
260
269
|
};
|
|
261
|
-
|
|
270
|
+
const addable = filterTree.fields.length > 0;
|
|
271
|
+
if ((!emptyPlace || !addable) && standing === 0 && !pending)
|
|
262
272
|
return null;
|
|
263
|
-
const empty =
|
|
273
|
+
const empty = standing === 0 && !pending;
|
|
264
274
|
const Glyph = icons.filter;
|
|
265
275
|
const Plus = icons.add;
|
|
266
276
|
const name = messages({ key: "views.panels.filter" });
|
|
@@ -291,7 +301,7 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
291
301
|
const line = [
|
|
292
302
|
...drawn.flatMap((el, i) => (i === filtersAt ? [el, moreFilters] : [el])),
|
|
293
303
|
pending && !pending.replaces ? heldFilter() : null,
|
|
294
|
-
add,
|
|
304
|
+
addable ? add : null,
|
|
295
305
|
];
|
|
296
|
-
return (_jsxs("span", { "data-slot": "vk-toolbar-filters", className: "inline-flex min-w-0 items-center gap-2", children: [line, HostPanel && (_jsx(HostPanel, { open: fields.open, onOpenChange: fields.onOpenChange, title: empty ? name : addLabel, children: _jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: onPick, onDone: () => fields.onOpenChange(false) }) }))] }));
|
|
306
|
+
return (_jsxs("span", { "data-slot": "vk-toolbar-filters", className: "inline-flex min-w-0 items-center gap-2", children: [line, HostPanel && addable && (_jsx(HostPanel, { open: fields.open, onOpenChange: fields.onOpenChange, title: empty ? name : addLabel, children: _jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: onPick, onDone: () => fields.onOpenChange(false) }) }))] }));
|
|
297
307
|
}
|
|
@@ -1,15 +1,23 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type ActivePanel, type ViewOptionInputs } from "../../model.js";
|
|
3
3
|
import type { CollectionViewState } from "../../view-state.js";
|
|
4
|
+
import type { CustomizePage } from "../../toolbar/page-resets.js";
|
|
5
|
+
import type { ViewsCustomizeItems } from "../../../provider/components.js";
|
|
4
6
|
import type { PanelFieldEditor } from "../field-editor.js";
|
|
5
7
|
import { type ToolbarPanelHost } from "./panel-part.js";
|
|
6
|
-
export declare function ToolbarOptions({ view, viewFoot, footClear, fieldEditor, foldFilters, onClear, open, onOpenChange, page: pageIn, onPageChange, host, widthClassName, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }: ViewOptionInputs & {
|
|
8
|
+
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 & {
|
|
7
9
|
/** The shared view this list shows: the drift dot, and the panel's footer (Reset, Save for everyone). */
|
|
8
10
|
view?: CollectionViewState;
|
|
9
11
|
/** Customize's foot: `kit` for Clear and Save, `none` for none; absent, Reset and Save for everyone. */
|
|
10
12
|
viewFoot?: "kit" | "none";
|
|
11
13
|
/** With no shared view, the foot's Clear (the list back to its default); absent, no foot. */
|
|
12
14
|
footClear?: () => void;
|
|
15
|
+
/** Each Customize page's own Reset, while that page differs (VK-1034). */
|
|
16
|
+
resets?: Partial<Record<CustomizePage, () => void>>;
|
|
17
|
+
/** The reader's own layer holds something: the foot's Reset stands for it too, Save doesn't (VK-1034). */
|
|
18
|
+
layered?: boolean;
|
|
19
|
+
/** Customize's rows as data (`menus.customize`, VK-1062), handed to the body as `items`. */
|
|
20
|
+
customizeItems?: ViewsCustomizeItems;
|
|
13
21
|
/** The list's field editor, for the Columns list and a column's settings. */
|
|
14
22
|
fieldEditor?: PanelFieldEditor | null;
|
|
15
23
|
/** The filter dimensions behind one Filter row (lists). Default true. */
|
|
@@ -8,7 +8,7 @@ import { ViewOptionsPanelContent } from "../customize.js";
|
|
|
8
8
|
import { viewOptionsPopoverClassName } from "../popover.js";
|
|
9
9
|
import { PanelStepHold, usePanelStep } from "../panel-step.js";
|
|
10
10
|
import { ToolbarPanelPart } from "./panel-part.js";
|
|
11
|
-
export function ToolbarOptions({ view, viewFoot, footClear, fieldEditor, foldFilters = true, onClear, open, onOpenChange, page: pageIn, onPageChange, host, widthClassName, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }) {
|
|
11
|
+
export function ToolbarOptions({ view, viewFoot, footClear, resets, layered, customizeItems, fieldEditor, foldFilters = true, onClear, open, onOpenChange, page: pageIn, onPageChange, host, widthClassName, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }) {
|
|
12
12
|
const { icons, messages } = useViews();
|
|
13
13
|
const Glyph = icons.options;
|
|
14
14
|
const [ownOpen, setOwnOpen] = useState(false);
|
|
@@ -33,5 +33,5 @@ export function ToolbarOptions({ view, viewFoot, footClear, fieldEditor, foldFil
|
|
|
33
33
|
};
|
|
34
34
|
return (_jsx(ToolbarPanelPart, { panelKey: "options", slot: "vk-toolbar-options", part: "options", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, word: name, count: count, onClear: clear, dot: !!view && view.changes > 0, open: holdsOpen ? open : ownOpen, onOpenChange: handleOpenChange, host: host, popoverClassName: widthClassName
|
|
35
35
|
? viewOptionsPopoverClassName(page, widthClassName)
|
|
36
|
-
: viewOptionsPopoverClassName(null, "w-75"), onSheetEscape: step.escapeBack, children: ({ fill, close, closeButton }) => (_jsx(PanelStepHold.Provider, { value: step, children: _jsx(ViewOptionsPanelContent, { ...inputs, activePanel: page, onOpenPanel: setPage, anyActive: view ? view.changes > 0 : count > 0, clearAll: clear, foldFilters: foldFilters, onClose: close, closeButton: closeButton, fill: fill, view: view, viewFoot: viewFoot, footClear: footClear, fieldEditor: fieldEditor, ...(viewName !== undefined && { viewName }), ...(onRenameView && { onRenameView }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }), ...(exportCount !== undefined && { exportCount }) }) })) }));
|
|
36
|
+
: viewOptionsPopoverClassName(null, "w-75"), onSheetEscape: step.escapeBack, children: ({ fill, close, closeButton }) => (_jsx(PanelStepHold.Provider, { value: step, children: _jsx(ViewOptionsPanelContent, { ...inputs, activePanel: page, onOpenPanel: setPage, anyActive: view ? view.changes > 0 : count > 0, clearAll: clear, foldFilters: foldFilters, onClose: close, closeButton: closeButton, fill: fill, view: view, viewFoot: viewFoot, footClear: footClear, ...(resets && { resets }), ...(layered && { layered }), ...(customizeItems && { customizeItems }), fieldEditor: fieldEditor, ...(viewName !== undefined && { viewName }), ...(onRenameView && { onRenameView }), ...(onCopyLink && { onCopyLink }), ...(onExport && { onExport }), ...(exportCount !== undefined && { exportCount }) }) })) }));
|
|
37
37
|
}
|
|
@@ -14,5 +14,5 @@ export function ToolbarQuickFilters({ quickFilters, open, onOpenChange, host, ic
|
|
|
14
14
|
return null;
|
|
15
15
|
const Glyph = icons.filterCategory;
|
|
16
16
|
const label = quickFilters.label ?? messages({ key: "views.panels.quick-filters" });
|
|
17
|
-
return (_jsx(ToolbarPanelPart, { panelKey: "quick", slot: "vk-toolbar-quick", part: "quick", icon: icon ?? _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: label, word: word === null && slot.words !== "both" ? null : label, changed: holdStands(quickFilters.hold), open: open, onOpenChange: onOpenChange, host: host, children: ({ close, closeButton }) => (_jsx(QuickFiltersPanel, { quickFilters: quickFilters, form: phone ? "phone" : "computer", onDone: close, closeButton: closeButton })) }));
|
|
17
|
+
return (_jsx(ToolbarPanelPart, { panelKey: "quick", slot: "vk-toolbar-quick", part: "quick", icon: icon ?? _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: label, word: word === null && slot.words !== "both" ? null : label, changed: holdStands(quickFilters.hold), open: open, onOpenChange: onOpenChange, host: host, children: ({ close, closeButton }) => (_jsx(QuickFiltersPanel, { quickFilters: quickFilters, form: phone ? "phone" : "computer", onDone: close, closeButton: closeButton, inHost: !!host })) }));
|
|
18
18
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { CollectionViewState } from "../../view-state.js";
|
|
3
|
-
export declare function ToolbarSave({ view, onClear, }: {
|
|
3
|
+
export declare function ToolbarSave({ view, layered, onClear, }: {
|
|
4
4
|
/** The shared view this list shows: Clear is its `onReset`, Save its `onPublish`. */
|
|
5
5
|
view?: CollectionViewState;
|
|
6
6
|
/** With no shared view, what Clear does: the list back to its default. Absent, nothing to clear. */
|
|
7
7
|
onClear?: () => void;
|
|
8
|
+
/** The reader's own layer holds something (VK-1034): on a shared view Clear stands for it too, Save doesn't. */
|
|
9
|
+
layered?: boolean;
|
|
8
10
|
}): ReactNode;
|
|
@@ -4,18 +4,19 @@ import { useViews } from "../../../provider/context.js";
|
|
|
4
4
|
import { drawPanelButton } from "../../panel-button.js";
|
|
5
5
|
import { useToolbarSlot } from "./context.js";
|
|
6
6
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
7
|
-
export function ToolbarSave({ view, onClear, }) {
|
|
7
|
+
export function ToolbarSave({ view, layered = false, onClear, }) {
|
|
8
8
|
const views = useViews();
|
|
9
9
|
const { messages } = views;
|
|
10
10
|
const { appFrame } = useToolbarSlot();
|
|
11
|
-
const clear = view ? (view.changes > 0 ? view.onReset : undefined) : onClear;
|
|
11
|
+
const clear = view ? (view.changes > 0 || layered ? view.onReset : undefined) : onClear;
|
|
12
|
+
const publish = !!view?.canPublish && view.changes > 0;
|
|
12
13
|
if (!clear)
|
|
13
14
|
return null;
|
|
14
15
|
const pending = view?.pending ?? false;
|
|
15
16
|
if (appFrame) {
|
|
16
17
|
const clearWord = messages({ key: "views.panels.view-clear" });
|
|
17
18
|
const saveWord = messages({ key: "views.panels.view-save" });
|
|
18
|
-
return (_jsxs("span", { "data-slot": "vk-toolbar-save", className: "inline-flex shrink-0 items-center gap-2", children: [_jsx(ToolbarButton, { icon: null, label: clearWord, part: "clear", disabled: pending, onClick: clear, children: clearWord }),
|
|
19
|
+
return (_jsxs("span", { "data-slot": "vk-toolbar-save", className: "inline-flex shrink-0 items-center gap-2", children: [_jsx(ToolbarButton, { icon: null, label: clearWord, part: "clear", disabled: pending, onClick: clear, children: clearWord }), publish && (_jsx(ToolbarButton, { icon: null, label: saveWord, part: "save", disabled: pending, onClick: view.onPublish, children: saveWord }))] }));
|
|
19
20
|
}
|
|
20
21
|
return (_jsxs("span", { "data-slot": "vk-toolbar-save", className: "inline-flex shrink-0 items-center gap-2", children: [drawPanelButton(views, {
|
|
21
22
|
frame: "h-8 px-3",
|
|
@@ -25,7 +26,7 @@ export function ToolbarSave({ view, onClear, }) {
|
|
|
25
26
|
onClick: clear,
|
|
26
27
|
"data-slot": "vk-toolbar-clear",
|
|
27
28
|
children: messages({ key: "views.panels.view-clear" }),
|
|
28
|
-
}),
|
|
29
|
+
}), publish &&
|
|
29
30
|
drawPanelButton(views, {
|
|
30
31
|
frame: "h-8 px-3",
|
|
31
32
|
variant: "outline",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import { type SortConfig, type SortRulesConfig } from "../../model.js";
|
|
3
3
|
import { type ToolbarPanelHost } from "./panel-part.js";
|
|
4
|
-
export declare function ToolbarSort({ sort, sorts, open, onOpenChange, host, }: {
|
|
4
|
+
export declare function ToolbarSort({ sort, sorts, open, onOpenChange, host, bar, changed, }: {
|
|
5
5
|
/** The builder's Sort: `settingsPanels(…).sort`. */
|
|
6
6
|
sort: SortConfig<string>;
|
|
7
7
|
/** The builder's rules (`settingsPanels(…).sorts`, with `severalSorts`): handed, Sort adds a rule from the fields. */
|
|
@@ -11,4 +11,10 @@ export declare function ToolbarSort({ sort, sorts, open, onOpenChange, host, }:
|
|
|
11
11
|
onOpenChange?: (open: boolean) => void;
|
|
12
12
|
/** The app's drawer or sheet; absent, the map's `Popover` (on a phone, its `Sheet`). */
|
|
13
13
|
host?: ToolbarPanelHost;
|
|
14
|
+
/** On the filter bar (the ready toolbar's, while the sort differs: VK-1052): "Sorted by" the sort's field, in the bar's
|
|
15
|
+
* sort place. Without `sorts` only. */
|
|
16
|
+
bar?: boolean;
|
|
17
|
+
/** Lit while the sort differs from the saved view (VK-1046), whatever it would light by on its own: the ready toolbar
|
|
18
|
+
* hands it. Absent, lit while the list sorts other than its default. */
|
|
19
|
+
changed?: boolean;
|
|
14
20
|
}): ReactNode;
|
|
@@ -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 { useViews } from "../../../provider/context.js";
|
|
4
4
|
import { isSortActive, isSortRulesActive } from "../../model.js";
|
|
5
5
|
import { addSortRule, canAddSortRule, openSortPlaces } from "../../settings/sorts.js";
|
|
@@ -9,7 +9,7 @@ import { CompactSortDetail } from "../order-details.js";
|
|
|
9
9
|
import { PanelHeader } from "../panel-header.js";
|
|
10
10
|
import { useSheetPanels } from "../panel-sheet.js";
|
|
11
11
|
import { ToolbarPanelPart } from "./panel-part.js";
|
|
12
|
-
export function ToolbarSort({ sort, sorts, open, onOpenChange, host, }) {
|
|
12
|
+
export function ToolbarSort({ sort, sorts, open, onOpenChange, host, bar = false, changed, }) {
|
|
13
13
|
const { icons, messages } = useViews();
|
|
14
14
|
const phone = useSheetPanels();
|
|
15
15
|
const Glyph = icons.sort;
|
|
@@ -25,5 +25,8 @@ export function ToolbarSort({ sort, sorts, open, onOpenChange, host, }) {
|
|
|
25
25
|
close();
|
|
26
26
|
}, onDone: close })) }));
|
|
27
27
|
}
|
|
28
|
-
|
|
28
|
+
const by = bar ? (sort.options.find((option) => option.value === sort.value)?.label ?? sort.value) : null;
|
|
29
|
+
return (_jsx(ToolbarPanelPart, { panelKey: "sort", slot: bar ? "vk-toolbar-sort-pill" : "vk-toolbar-sort", part: "sort", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, word: name, ...(by !== null && {
|
|
30
|
+
words: (_jsxs(_Fragment, { children: [messages({ key: "views.panels.sorted-by" }), " ", _jsx("b", { children: by })] })),
|
|
31
|
+
}), changed: changed ?? isSortActive(sort), open: open, onOpenChange: onOpenChange, host: host, popoverClassName: viewOptionsPopoverClassName(null), children: ({ fill, close, closeButton }) => (_jsxs("div", { className: fill ? "flex h-full min-h-0 flex-col" : "flex flex-col", children: [_jsx(PanelHeader, { title: sort.label ?? name, onClose: closeButton ? close : undefined }), _jsx("div", { className: fill ? "min-h-0 flex-1 overflow-y-auto overscroll-contain **:data-vs-detail:max-h-none" : undefined, children: _jsx(CompactSortDetail, { sort: sort }) })] })) }));
|
|
29
32
|
}
|
|
@@ -18,6 +18,9 @@ type PillProps = {
|
|
|
18
18
|
* remove the rules and add one from Add sort at its foot; with none, the fields, a pick adding a rule. No + after it.
|
|
19
19
|
* On a phone it draws as the pill does there, its slot `vk-toolbar-sort-row`. */
|
|
20
20
|
row?: boolean;
|
|
21
|
+
/** Lit while the sort differs from the saved view (VK-1046), whatever it would light by on its own: the ready toolbar
|
|
22
|
+
* hands it. Absent, as before: the row lit while a sort stands, the pill while the sort differs from `defaultRules`. */
|
|
23
|
+
changed?: boolean;
|
|
21
24
|
};
|
|
22
25
|
export declare function ToolbarSortPill(props: PillProps): ReactNode;
|
|
23
26
|
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, }) {
|
|
19
|
+
function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host: Host, addAfter: addAfterIn = true, row = false, changed, }) {
|
|
20
20
|
const addAfter = row ? false : addAfterIn;
|
|
21
21
|
const { components, icons, messages } = useViews();
|
|
22
22
|
const { Popover } = components;
|
|
@@ -67,7 +67,7 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
67
67
|
sorts.onChange(next);
|
|
68
68
|
close(true, opens.at === "add" && canAddSortRule(next, places));
|
|
69
69
|
}, onDone: () => close() }));
|
|
70
|
-
return (_jsxs("span", { className: "contents", "data-open": hangsAt.fold && panel.open ? "" : undefined, children: [_jsx(ToolbarButton, { ref: pill, part: placePart(slot.key) ?? "sort", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, empty: !row && !named && !asideOnly, aside: asideOnly, changed: row ? !!named : isSortRulesActive(sorts), more: row
|
|
70
|
+
return (_jsxs("span", { className: "contents", "data-open": hangsAt.fold && panel.open ? "" : undefined, children: [_jsx(ToolbarButton, { ref: pill, part: placePart(slot.key) ?? "sort", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, empty: !row && !named && !asideOnly, aside: asideOnly, changed: changed ?? (row ? !!named : isSortRulesActive(sorts)), more: row
|
|
71
71
|
? sorts.rules.length > 1
|
|
72
72
|
? String(sorts.rules.length)
|
|
73
73
|
: undefined
|
|
@@ -78,7 +78,7 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
78
78
|
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
79
79
|
}, anchor: hangsAt.hidden ? hangsAt.anchor : opens.at === "add" ? add : pill, ...hangs, chrome: "menu", panelData: { "data-slot": "vk-toolbar-sort-panel" }, children: content }))] }));
|
|
80
80
|
}
|
|
81
|
-
function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host }) {
|
|
81
|
+
function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host, changed }) {
|
|
82
82
|
const { icons, messages } = useViews();
|
|
83
83
|
const [held, setHeld] = useState(false);
|
|
84
84
|
const holds = openIn !== undefined && !!onOpenChangeIn;
|
|
@@ -89,5 +89,5 @@ function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host })
|
|
|
89
89
|
const Glyph = icons.sort;
|
|
90
90
|
const name = messages({ key: "views.panels.sort" });
|
|
91
91
|
const n = sorts.rules.length;
|
|
92
|
-
return (_jsx(ToolbarPanelPart, { panelKey: "sort", slot: "vk-toolbar-sort", part: "sort", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, word: name, more: n > 0 ? String(n) : undefined, changed: isSortRulesActive(sorts), open: open, onOpenChange: onOpenChange, host: host, sheetActions: editor.head, ...(headDraws && editor.title !== undefined && { sheetTitle: editor.title }), onSheetEscape: editor.escapeBack, children: ({ fill, closeButton }) => (_jsx("div", { className: fill ? "flex h-full min-h-0 flex-col" : "flex flex-col", children: editor.body(closeButton) })) }));
|
|
92
|
+
return (_jsx(ToolbarPanelPart, { panelKey: "sort", slot: "vk-toolbar-sort", part: "sort", icon: _jsx(Glyph, { className: "h-4 w-4 shrink-0" }), label: name, word: name, more: n > 0 ? String(n) : undefined, changed: changed ?? isSortRulesActive(sorts), open: open, onOpenChange: onOpenChange, host: host, sheetActions: editor.head, ...(headDraws && editor.title !== undefined && { sheetTitle: editor.title }), onSheetEscape: editor.escapeBack, children: ({ fill, closeButton }) => (_jsx("div", { className: fill ? "flex h-full min-h-0 flex-col" : "flex flex-col", children: editor.body(closeButton) })) }));
|
|
93
93
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ViewsFilterEditorItems, ViewsGroupEditorItems, ViewsSortEditorItems } from "../../../provider/components.js";
|
|
2
|
+
export type EditorMenusValue = {
|
|
3
|
+
sort?: ViewsSortEditorItems;
|
|
4
|
+
filter?: ViewsFilterEditorItems;
|
|
5
|
+
group?: ViewsGroupEditorItems;
|
|
6
|
+
};
|
|
7
|
+
export declare const EditorMenus: import("react").Context<EditorMenusValue>;
|
|
8
|
+
export declare const useEditorMenus: () => EditorMenusValue;
|
|
@@ -11,6 +11,7 @@ import { useAnchoredToggle } from "./use-anchored-toggle.js";
|
|
|
11
11
|
import { ToolbarButton } from "../toolbar/ToolbarButton.js";
|
|
12
12
|
import { useViewsRowInFrame } from "./in-frame.js";
|
|
13
13
|
import { ViewCreatePill } from "./ViewCreatePill.js";
|
|
14
|
+
import { useNewView } from "./new-view.js";
|
|
14
15
|
import { ViewPickerRow } from "./ViewPickerRow.js";
|
|
15
16
|
import { toPillOptions, usePillWords } from "./ViewTabs.js";
|
|
16
17
|
export function FoldingViewRow({ axis, folded: told }) {
|
|
@@ -22,9 +23,7 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
22
23
|
const inFrame = useViewsRowInFrame();
|
|
23
24
|
const pills = useMemo(() => toPillOptions(axis.options, words), [axis.options, words]);
|
|
24
25
|
const viewMenu = useMemo(() => (axis.verbs && views.components.ViewMenu ? { views: viewsListItemsOf(axis), value: axis.value, verbs: axis.verbs } : undefined), [axis, views.components.ViewMenu]);
|
|
25
|
-
const
|
|
26
|
-
const ViewMenu = views.components.ViewMenu;
|
|
27
|
-
const newView = viewMenu && ViewMenu ? { ViewMenu, menu: viewMenu } : undefined;
|
|
26
|
+
const newView = useNewView(axis);
|
|
28
27
|
const isTold = told !== undefined;
|
|
29
28
|
useLayoutEffect(() => {
|
|
30
29
|
const host = hostRef.current;
|
|
@@ -94,7 +93,7 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
94
93
|
const ordered = pills.filter(inBlock).map((pill) => (visibleValues.has(pill.value) ? dealt.shift() : pill.value));
|
|
95
94
|
axis.onReorder(ordered);
|
|
96
95
|
};
|
|
97
|
-
return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag, viewMenu: viewMenu }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions, viewMenu: viewMenu }),
|
|
96
|
+
return (_jsxs("div", { ref: hostRef, "data-slot": "vk-views-row", className: isTold ? "relative flex flex-none items-center gap-0.5" : "relative flex min-w-0 flex-1 items-center gap-0.5", children: [_jsx(PillGroup, { value: axis.value, options: shown, onChange: axis.onChange, variant: "plain", onReorder: axis.onReorder ? onPillReorder : undefined, canDrag: axis.canDrag, viewMenu: viewMenu }), folded.length > 0 && _jsx(FoldedViews, { axis: axis, options: foldedOptions, viewMenu: viewMenu }), newView.onCreate && _jsx(ViewCreatePill, { label: axis.createLabel, onClick: newView.onCreate }), newView.slot(hostRef), !isTold && (_jsx("div", { "aria-hidden": true, inert: true, className: "pointer-events-none absolute inset-0 overflow-hidden", style: { visibility: "hidden" }, children: _jsxs("div", { ref: measureRef, "data-slot": "vk-views-row", className: "pointer-events-none absolute left-0 top-0 flex items-center gap-0.5 whitespace-nowrap", children: [_jsx("div", { "data-measure-pills": true, className: "contents", children: _jsx(PillGroup, { value: axis.value, options: pills, onChange: () => { }, variant: "plain" }) }), inFrame ? (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: _jsx(MoreButton, { count: 99 }) })) : (_jsx("span", { "data-measure-more": true, className: "inline-flex", children: drawPanelButton(views, {
|
|
98
97
|
frame: MORE_CHIP_FRAME,
|
|
99
98
|
variant: "ghost",
|
|
100
99
|
size: "sm",
|
|
@@ -102,7 +101,6 @@ export function FoldingViewRow({ axis, folded: told }) {
|
|
|
102
101
|
children: moreChipInner(views, 99),
|
|
103
102
|
}) })), axis.onCreate && (_jsx("span", { "data-measure-ghost": true, children: _jsx(ViewCreatePill, { label: axis.createLabel, onClick: () => { } }) }))] }) }))] }));
|
|
104
103
|
}
|
|
105
|
-
const keepOpen = () => { };
|
|
106
104
|
const MORE_CHIP_FRAME = "h-8 shrink-0 gap-0.5 whitespace-nowrap px-2.5";
|
|
107
105
|
function moreChipInner({ conventions, icons }, count) {
|
|
108
106
|
const Chevron = icons.chevronDown;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { type ReactNode } from "react";
|
|
1
|
+
import { type ReactNode, type RefObject } from "react";
|
|
2
2
|
type Props = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
gap?: string;
|
|
5
|
+
/** The rail's own box, for what opens at the row (New view's Modal from its +, VK-1025). */
|
|
6
|
+
rowRef?: RefObject<HTMLDivElement | null>;
|
|
5
7
|
};
|
|
6
|
-
export declare function HScrollRow({ children, gap }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function HScrollRow({ children, gap, rowRef }: Props): import("react/jsx-runtime").JSX.Element;
|
|
7
9
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useLayoutEffect, useRef } from "react";
|
|
4
|
-
export function HScrollRow({ children, gap = "6px" }) {
|
|
4
|
+
export function HScrollRow({ children, gap = "6px", rowRef }) {
|
|
5
5
|
const scrollRef = useRef(null);
|
|
6
6
|
useLayoutEffect(() => {
|
|
7
7
|
const container = scrollRef.current;
|
|
@@ -21,7 +21,11 @@ export function HScrollRow({ children, gap = "6px" }) {
|
|
|
21
21
|
const target = childLeft - (containerWidth - childWidth) / 2;
|
|
22
22
|
container.scrollLeft = Math.max(0, target);
|
|
23
23
|
});
|
|
24
|
-
return (_jsx("div", { ref:
|
|
24
|
+
return (_jsx("div", { ref: (el) => {
|
|
25
|
+
scrollRef.current = el;
|
|
26
|
+
if (rowRef)
|
|
27
|
+
rowRef.current = el;
|
|
28
|
+
}, onTouchMove: (e) => e.stopPropagation(), style: {
|
|
25
29
|
marginLeft: "-1rem",
|
|
26
30
|
marginRight: "-1rem",
|
|
27
31
|
maxWidth: "calc(100vw - var(--vk-scroll-row-inset, 0px))",
|
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useRef } from "react";
|
|
3
4
|
import { FoldingViewRow } from "./FoldingViewRow.js";
|
|
4
5
|
import { HScrollRow } from "./HScrollRow.js";
|
|
5
6
|
import { PillGroup } from "./PillGroup.js";
|
|
6
7
|
import { ViewCreatePill } from "./ViewCreatePill.js";
|
|
8
|
+
import { useNewView } from "./new-view.js";
|
|
7
9
|
import { toPillOptions, usePillWords } from "./ViewTabs.js";
|
|
8
10
|
const AXIS_GAP = "0.5rem";
|
|
9
11
|
const AXIS_TRACK_CLASS = "rounded-full bg-(color:--vk-neutral) p-0.5";
|
|
10
12
|
export function ViewAxes({ axes, size, folded, }) {
|
|
11
13
|
const words = usePillWords();
|
|
14
|
+
const rowRef = useRef(null);
|
|
15
|
+
const growing = axes.find((axis) => axis.onCreate);
|
|
16
|
+
const newView = useNewView(growing);
|
|
12
17
|
const grouped = axes.length > 1;
|
|
13
18
|
if (!grouped && size !== "sm")
|
|
14
19
|
return _jsx(FoldingViewRow, { axis: axes[0], folded: folded });
|
|
15
|
-
return (_jsxs(HScrollRow, { gap: AXIS_GAP, children: [axes.map((axis, i) => (_jsx(PillGroup, { value: axis.value, options: toPillOptions(axis.options, { ...words, hideCounts: axis.hideCounts }), onChange: axis.onChange, size: size, variant: "plain", className: grouped ? AXIS_TRACK_CLASS : undefined }, axis.key ?? i))),
|
|
20
|
+
return (_jsxs(HScrollRow, { gap: AXIS_GAP, rowRef: rowRef, children: [axes.map((axis, i) => (_jsx(PillGroup, { value: axis.value, options: toPillOptions(axis.options, { ...words, hideCounts: axis.hideCounts }), onChange: axis.onChange, size: size, variant: "plain", className: grouped ? AXIS_TRACK_CLASS : undefined }, axis.key ?? i))), growing && newView.onCreate && (_jsx(ViewCreatePill, { label: growing.createLabel, onClick: newView.onCreate, size: size }, `create-${growing.key ?? axes.indexOf(growing)}`)), newView.slot(rowRef)] }));
|
|
16
21
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useRef } from "react";
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
@@ -12,6 +12,7 @@ import { useAnchoredToggle } from "./use-anchored-toggle.js";
|
|
|
12
12
|
import { ToolbarButton } from "../toolbar/ToolbarButton.js";
|
|
13
13
|
import { useViewsRowInFrame } from "./in-frame.js";
|
|
14
14
|
import { ViewCreatePill } from "./ViewCreatePill.js";
|
|
15
|
+
import { useNewView } from "./new-view.js";
|
|
15
16
|
export function ViewPicker({ axis, className }) {
|
|
16
17
|
const context = useViews();
|
|
17
18
|
const { components, conventions, icons, messages } = context;
|
|
@@ -30,8 +31,12 @@ export function ViewPicker({ axis, className }) {
|
|
|
30
31
|
const active = axis.options.find((option) => option.value === axis.value);
|
|
31
32
|
const onOpenChange = toggle.onOpenChange;
|
|
32
33
|
const close = toggle.close;
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const empty = axis.options.length === 0;
|
|
35
|
+
const newView = useNewView(axis, empty);
|
|
36
|
+
if (empty) {
|
|
37
|
+
if (!newView.onCreate)
|
|
38
|
+
return null;
|
|
39
|
+
return (_jsxs(_Fragment, { children: [_jsx(ViewCreatePill, { label: axis.createLabel, onClick: newView.onCreate, className: className }), newView.slot(anchor)] }));
|
|
35
40
|
}
|
|
36
41
|
const { onCreate, onReorder } = axis;
|
|
37
42
|
const listLabel = messages({ key: "views.panels.views-list" });
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { ViewsAnchor } from "../../../provider/components.js";
|
|
3
|
+
import { type CollectionViewsConfig } from "../../views-row/model.js";
|
|
4
|
+
/** What a views + does, and New view's slot to draw beside it. `active` false (the picker once its axis holds a view): back
|
|
5
|
+
* to none, so an axis emptied again opens nothing until its + is pressed. */
|
|
6
|
+
export declare function useNewView(axis: CollectionViewsConfig<string> | undefined, active?: boolean): {
|
|
7
|
+
/** The + press: New view's Modal through `verbs`, else the axis's own `onCreate`; absent, the axis doesn't grow. */
|
|
8
|
+
onCreate: (() => void) | undefined;
|
|
9
|
+
/** New view's Modal, at `anchor`, while a press stands; null otherwise. */
|
|
10
|
+
slot: (anchor: ViewsAnchor) => ReactNode;
|
|
11
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { useViews } from "../../../provider/context.js";
|
|
5
|
+
import { viewsListItemsOf } from "../../views-row/model.js";
|
|
6
|
+
export function useNewView(axis, active = true) {
|
|
7
|
+
const { ViewMenu } = useViews().components;
|
|
8
|
+
const [creating, setCreating] = useState(0);
|
|
9
|
+
if (!active && creating !== 0)
|
|
10
|
+
setCreating(0);
|
|
11
|
+
const verbs = ViewMenu ? axis?.verbs : undefined;
|
|
12
|
+
if (!axis?.onCreate)
|
|
13
|
+
return { onCreate: undefined, slot: () => null };
|
|
14
|
+
if (!ViewMenu || !verbs)
|
|
15
|
+
return { onCreate: axis.onCreate, slot: () => null };
|
|
16
|
+
return {
|
|
17
|
+
onCreate: () => setCreating((n) => n + 1),
|
|
18
|
+
slot: (anchor) => creating > 0 ? _jsx(ViewMenu, { open: true, onOpenChange: keepOpen, anchor: anchor, views: viewsListItemsOf(axis), value: axis.value, verbs: verbs }, creating) : null,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
const keepOpen = () => { };
|
|
@@ -27,7 +27,7 @@ export { ViewOptionsActions } from "./react/view-actions.js";
|
|
|
27
27
|
export { ViewOptionsPopoverPanel, keepPanelOpenForPortals, useViewActivePanel, useViewOptionsPopover, viewOptionsPopoverClassName, } from "./react/popover.js";
|
|
28
28
|
export type { ViewOptionsPopoverState } from "./react/popover.js";
|
|
29
29
|
export { Toolbar, ToolbarSeparator } from "./react/toolbar/Toolbar.js";
|
|
30
|
-
export type { ToolbarMore, ToolbarPart } from "./react/toolbar/Toolbar.js";
|
|
30
|
+
export type { ToolbarMore, ToolbarOverflow, ToolbarPart } from "./react/toolbar/Toolbar.js";
|
|
31
31
|
export { ToolbarButton } from "./react/toolbar/ToolbarButton.js";
|
|
32
32
|
export { useToolbarPanel, useToolbarSlot } from "./react/toolbar/context.js";
|
|
33
33
|
export { ToolbarRadioProvider, ToolbarSlotProvider } from "./react/toolbar/context.js";
|