viewkitjs 0.33.0 → 0.35.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 +139 -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 -14
- package/views/dist/contract.js +40 -4
- package/views/dist/controls/alert/alert.js +2 -1
- package/views/dist/controls/alert-dialog/alert-dialog.js +3 -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 +7 -4
- package/views/dist/controls/avatar/avatar.js +10 -4
- 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 +29 -27
- 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 +6 -1
- package/views/dist/controls/compound-editor/name-parts.js +2 -1
- package/views/dist/controls/compound-editor/place-parts.js +2 -2
- package/views/dist/controls/compound-editor/range-parts.js +10 -9
- package/views/dist/controls/controls.d.ts +2 -0
- package/views/dist/controls/controls.js +2 -0
- package/views/dist/controls/customize/customize.d.ts +14 -5
- package/views/dist/controls/customize/customize.js +19 -20
- package/views/dist/controls/customize/map-customize-body.d.ts +2 -2
- package/views/dist/controls/customize/map-customize-body.js +15 -13
- package/views/dist/controls/customize/words.d.ts +3 -3
- package/views/dist/controls/date-editor/date-editor.d.ts +3 -0
- package/views/dist/controls/date-editor/date-editor.js +13 -7
- package/views/dist/controls/date-editor/map-calendar.js +2 -0
- package/views/dist/controls/date-editor/map-date-body.d.ts +1 -1
- package/views/dist/controls/date-editor/map-date-body.js +7 -3
- package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +4 -6
- package/views/dist/controls/filter-editor/map-filter-body.d.ts +2 -0
- package/views/dist/controls/filter-editor/map-filter-body.js +7 -4
- package/views/dist/controls/filter-editor/parts.d.ts +4 -2
- package/views/dist/controls/filter-editor/parts.js +8 -7
- package/views/dist/controls/group-editor/group-editor.js +2 -1
- package/views/dist/controls/group-editor/map-group-body.d.ts +1 -0
- package/views/dist/controls/group-editor/map-group-body.js +5 -1
- package/views/dist/controls/index.d.ts +1 -1
- package/views/dist/controls/input/input.js +2 -1
- package/views/dist/controls/internal/head-button.d.ts +9 -0
- package/views/dist/controls/internal/head-button.js +13 -0
- package/views/dist/controls/internal/map-panel-controls.js +9 -5
- package/views/dist/controls/internal/panel-controls.d.ts +38 -6
- package/views/dist/controls/internal/panel-controls.js +191 -19
- 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 +5 -1
- package/views/dist/controls/menu/menu.js +4 -3
- package/views/dist/controls/modal/modal.js +5 -3
- package/views/dist/controls/number-editor/map-number-body.js +5 -1
- package/views/dist/controls/number-editor/number-editor.js +6 -6
- package/views/dist/controls/pane/map-pane.d.ts +3 -0
- package/views/dist/controls/pane/map-pane.js +5 -0
- package/views/dist/controls/picker/map-fields-body.d.ts +2 -2
- package/views/dist/controls/picker/map-fields-body.js +30 -2
- package/views/dist/controls/picker/map-picker.d.ts +8 -3
- package/views/dist/controls/picker/map-picker.js +14 -3
- package/views/dist/controls/picker/picker.js +11 -8
- package/views/dist/controls/picker/rows.d.ts +7 -2
- package/views/dist/controls/picker.css +10 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +2 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +9 -4
- package/views/dist/controls/quick-filters/quick-filters.js +8 -6
- 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/select.d.ts +3 -0
- package/views/dist/controls/select/select.js +9 -3
- package/views/dist/controls/setting-row/looks.js +5 -5
- package/views/dist/controls/setting-row/setting-row.d.ts +3 -1
- package/views/dist/controls/setting-row/setting-row.js +3 -1
- package/views/dist/controls/setting-row.css +3 -2
- package/views/dist/controls/sheet/bottom-sheet.d.ts +3 -1
- package/views/dist/controls/sheet/bottom-sheet.js +2 -2
- package/views/dist/controls/sort-editor/map-sort-body.js +4 -4
- package/views/dist/controls/sort-editor/sort-editor.d.ts +2 -0
- package/views/dist/controls/sort-editor/sort-editor.js +4 -5
- package/views/dist/controls/text-editor/map-text-body.js +5 -1
- package/views/dist/controls/text-editor/text-editor.js +5 -4
- package/views/dist/controls/toolbar/toolbar.d.ts +29 -14
- package/views/dist/controls/toolbar/toolbar.js +17 -22
- 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-view-menu.d.ts +3 -2
- package/views/dist/controls/views-list/map-view-menu.js +6 -2
- package/views/dist/controls/views-list/map-views-list-body.d.ts +2 -1
- package/views/dist/controls/views-list/map-views-list-body.js +6 -5
- package/views/dist/controls/views-list/view-menu.js +3 -4
- package/views/dist/controls/views-list/views-list.js +2 -2
- package/views/dist/display/option-badges.d.ts +16 -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 +4 -4
- 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.js +9 -6
- 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 +1 -2
- 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 +5 -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/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-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 +10 -2
- package/views/dist/grid/grid.css +6 -0
- package/views/dist/grid/looks.d.ts +3 -1
- package/views/dist/grid/looks.js +10 -4
- package/views/dist/list/layer.d.ts +8 -0
- package/views/dist/list/layer.js +7 -0
- package/views/dist/list/list.d.ts +6 -2
- package/views/dist/list/list.js +6 -2
- package/views/dist/list/parts.js +3 -2
- package/views/dist/list/store.d.ts +1 -1
- package/views/dist/list/toolbar.js +51 -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 +4 -0
- package/views/dist/panels/customize-body.js +13 -11
- package/views/dist/panels/model.d.ts +9 -4
- package/views/dist/panels/react/customize-body.js +5 -2
- package/views/dist/panels/react/customize.d.ts +5 -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/quick/QuickFiltersPanel.d.ts +3 -1
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +7 -3
- package/views/dist/panels/react/toolbar/ReadyToolbar.d.ts +17 -1
- package/views/dist/panels/react/toolbar/Toolbar.d.ts +15 -1
- package/views/dist/panels/react/toolbar/Toolbar.js +24 -9
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +3 -2
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.d.ts +6 -1
- package/views/dist/panels/react/toolbar/ToolbarFilterAdd.js +14 -6
- package/views/dist/panels/react/toolbar/ToolbarFilters.d.ts +7 -3
- package/views/dist/panels/react/toolbar/ToolbarFilters.js +21 -10
- package/views/dist/panels/react/toolbar/ToolbarOptions.d.ts +6 -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 +7 -6
- package/views/dist/panels/react/toolbar/context.d.ts +21 -0
- package/views/dist/panels/react/toolbar/context.js +4 -0
- package/views/dist/panels/react/toolbar/pane-host.d.ts +6 -0
- package/views/dist/panels/react/toolbar/pane-host.js +17 -0
- package/views/dist/panels/react/toolbar/panel-part.js +3 -2
- package/views/dist/panels/react/views-row/ViewPicker.js +13 -5
- package/views/dist/panels/react.d.ts +2 -2
- 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 -3
- package/views/dist/provider/ViewsProvider.js +13 -2
- package/views/dist/provider/components.d.ts +59 -8
- package/views/dist/provider/components.js +1 -1
- package/views/dist/react.d.ts +2 -2
- package/views/dist/styles.css +194 -100
- package/views/dist/styles.unlayered.css +194 -100
- package/views/docs/contract.md +96 -27
- package/views/docs/controls/alert-dialog.md +4 -0
- package/views/docs/controls/alert.md +4 -0
- package/views/docs/controls/avatar.md +3 -0
- package/views/docs/controls/bulk-bar.md +7 -1
- package/views/docs/controls/compound-editor.md +2 -0
- package/views/docs/controls/customize.md +3 -1
- package/views/docs/controls/date-editor.md +2 -0
- package/views/docs/controls/filter-editor.md +1 -1
- package/views/docs/controls/group-editor.md +2 -0
- package/views/docs/controls/links-editor.md +2 -0
- package/views/docs/controls/menu.md +3 -1
- package/views/docs/controls/modal.md +4 -0
- package/views/docs/controls/number-editor.md +2 -0
- package/views/docs/controls/pane.md +1 -1
- package/views/docs/controls/picker.md +2 -0
- package/views/docs/controls/quick-filters.md +4 -2
- package/views/docs/controls/sheet.md +1 -1
- package/views/docs/controls/text-editor.md +3 -1
- package/views/docs/controls/toolbar.md +4 -0
- package/views/docs/controls/values-editor.md +2 -0
- package/views/docs/controls/views-list.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 +4 -4
- package/views/docs/index.md +2 -2
- package/views/docs/install.md +198 -104
- package/views/docs/reference/controls.md +21 -17
- package/views/docs/reference/editors-range.md +1 -1
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -1
- package/views/docs/reference/list.md +7 -5
- package/views/docs/reference/looks.md +6 -6
- package/views/docs/reference/panels-react.md +17 -15
- package/views/docs/reference/panels.md +4 -4
- package/views/docs/reference/react.md +15 -12
- package/views/docs/reference/views.md +6 -4
- package/views/docs/reshaping.md +32 -5
- package/views/skills/views/SKILL.md +3 -3
|
@@ -9,20 +9,24 @@ import { asideFilterWords, barFilterWords } from "../../toolbar/filter-words.js"
|
|
|
9
9
|
import { fieldOfRule, heldStands, relationOf, samePath, useEditorCtx, } from "../filter/editor-ctx.js";
|
|
10
10
|
import { FilterFieldList } from "../filter/FilterFieldList.js";
|
|
11
11
|
import { useSheetPanels } from "../panel-sheet.js";
|
|
12
|
-
import { useFoldAnchor, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
12
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
13
13
|
import { AdvancedFilterPill } from "./ToolbarAdvancedFilters.js";
|
|
14
14
|
import { ToolbarAsideFilter } from "./ToolbarAsideFilter.js";
|
|
15
15
|
import { ToolbarBarFilter } from "./ToolbarBarFilter.js";
|
|
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();
|
|
@@ -86,6 +90,7 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
86
90
|
const addBox = useRef(null);
|
|
87
91
|
const fields = useToolbarPanel("filters", openIn === undefined || !onOpenChangeIn ? undefined : { open: openIn, onOpenChange: onOpenChangeIn });
|
|
88
92
|
const hangsAt = useFoldAnchor(addBox);
|
|
93
|
+
const hangs = usePanelPlace("start");
|
|
89
94
|
const fieldsAtPress = useRef(false);
|
|
90
95
|
const leaving = useRef(null);
|
|
91
96
|
const leave = (from) => {
|
|
@@ -143,6 +148,8 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
143
148
|
return i >= 0 ? (now.keys[i] ?? `bf-pending-${i}`) : null;
|
|
144
149
|
};
|
|
145
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;
|
|
146
153
|
const shown = items.map((item) => {
|
|
147
154
|
if (item.kind === "far" && !relationOf(ctx, item.relation.fieldKey))
|
|
148
155
|
return { kind: "advanced", path: item.path, count: 1 };
|
|
@@ -155,7 +162,8 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
155
162
|
: null;
|
|
156
163
|
const candidates = shown
|
|
157
164
|
.map((item, i) => ({ item, i, key: now.keys[i] ?? `bf-pending-${i}` }))
|
|
158
|
-
.filter(({ item, key }) => !(
|
|
165
|
+
.filter(({ item, key }) => !off(item) &&
|
|
166
|
+
!(pending?.replaces && samePath(pending.replaces, item.path)) &&
|
|
159
167
|
!(open?.key === key && open.via === "bar"));
|
|
160
168
|
const folding = candidates.slice(Math.max(0, candidates.length - slot.filtersFolded));
|
|
161
169
|
const folded = new Set(folding.map(({ key }) => key));
|
|
@@ -193,6 +201,8 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
193
201
|
};
|
|
194
202
|
const drawn = shown.map((item, i) => {
|
|
195
203
|
const key = now.keys[i] ?? `bf-pending-${i}`;
|
|
204
|
+
if (off(item))
|
|
205
|
+
return null;
|
|
196
206
|
if (pending?.replaces && samePath(pending.replaces, item.path))
|
|
197
207
|
return heldFilter();
|
|
198
208
|
const aside = asideOf(item);
|
|
@@ -257,9 +267,10 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
257
267
|
fields.onOpenChange(false);
|
|
258
268
|
addPicked(picked, far);
|
|
259
269
|
};
|
|
260
|
-
|
|
270
|
+
const addable = filterTree.fields.length > 0;
|
|
271
|
+
if ((!emptyPlace || !addable) && standing === 0 && !pending)
|
|
261
272
|
return null;
|
|
262
|
-
const empty =
|
|
273
|
+
const empty = standing === 0 && !pending;
|
|
263
274
|
const Glyph = icons.filter;
|
|
264
275
|
const Plus = icons.add;
|
|
265
276
|
const name = messages({ key: "views.panels.filter" });
|
|
@@ -281,7 +292,7 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
281
292
|
const why = details?.reason;
|
|
282
293
|
if (!next && why !== "outside-press" && why !== "focus-out")
|
|
283
294
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
284
|
-
}, anchor: hangsAt.anchor,
|
|
295
|
+
}, anchor: hangsAt.anchor, ...hangs, chrome: "menu", panelData: { "data-slot": "vk-toolbar-filters-panel" }, children: _jsx(FilterFieldList, { fields: listedFieldsOf(filterTree), relations: true, onPick: onPick, onDone: () => {
|
|
285
296
|
fields.onOpenChange(false);
|
|
286
297
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
287
298
|
} }) }))] }, "add"));
|
|
@@ -290,7 +301,7 @@ export function ToolbarFilters({ filterTree, open: openIn, onOpenChange: onOpenC
|
|
|
290
301
|
const line = [
|
|
291
302
|
...drawn.flatMap((el, i) => (i === filtersAt ? [el, moreFilters] : [el])),
|
|
292
303
|
pending && !pending.replaces ? heldFilter() : null,
|
|
293
|
-
add,
|
|
304
|
+
addable ? add : null,
|
|
294
305
|
];
|
|
295
|
-
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) }) }))] }));
|
|
296
307
|
}
|
|
@@ -1,15 +1,20 @@
|
|
|
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";
|
|
4
5
|
import type { PanelFieldEditor } from "../field-editor.js";
|
|
5
6
|
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 & {
|
|
7
|
+
export declare function ToolbarOptions({ view, viewFoot, footClear, resets, layered, fieldEditor, foldFilters, onClear, open, onOpenChange, page: pageIn, onPageChange, host, widthClassName, viewName, onRenameView, onCopyLink, onExport, exportCount, ...inputs }: ViewOptionInputs & {
|
|
7
8
|
/** The shared view this list shows: the drift dot, and the panel's footer (Reset, Save for everyone). */
|
|
8
9
|
view?: CollectionViewState;
|
|
9
10
|
/** Customize's foot: `kit` for Clear and Save, `none` for none; absent, Reset and Save for everyone. */
|
|
10
11
|
viewFoot?: "kit" | "none";
|
|
11
12
|
/** With no shared view, the foot's Clear (the list back to its default); absent, no foot. */
|
|
12
13
|
footClear?: () => void;
|
|
14
|
+
/** Each Customize page's own Reset, while that page differs (VK-1034). */
|
|
15
|
+
resets?: Partial<Record<CustomizePage, () => void>>;
|
|
16
|
+
/** The reader's own layer holds something: the foot's Reset stands for it too, Save doesn't (VK-1034). */
|
|
17
|
+
layered?: boolean;
|
|
13
18
|
/** The list's field editor, for the Columns list and a column's settings. */
|
|
14
19
|
fieldEditor?: PanelFieldEditor | null;
|
|
15
20
|
/** 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, 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 }), 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 {};
|
|
@@ -7,7 +7,7 @@ import { useSheetDrawsClose, useSheetPanels } from "../panel-sheet.js";
|
|
|
7
7
|
import { SortEditorHost, useSortEditorHost } from "../sort/SortEditor.js";
|
|
8
8
|
import { SortFieldList } from "../sort/SortFieldList.js";
|
|
9
9
|
import { placePart } from "../../../atoms/frame-parts.js";
|
|
10
|
-
import { useFoldAnchor, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
10
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
11
11
|
import { ToolbarPanelPart } from "./panel-part.js";
|
|
12
12
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
13
13
|
export function ToolbarSortPill(props) {
|
|
@@ -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;
|
|
@@ -26,6 +26,7 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
26
26
|
const pill = useRef(null);
|
|
27
27
|
const add = useRef(null);
|
|
28
28
|
const hangsAt = useFoldAnchor(pill);
|
|
29
|
+
const hangs = usePanelPlace("start");
|
|
29
30
|
const named = sortRulesLabel(sorts);
|
|
30
31
|
const asideOnly = !named && (sorts.setAside?.length ?? 0) > 0;
|
|
31
32
|
const places = openSortPlaces(sorts);
|
|
@@ -66,7 +67,7 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
66
67
|
sorts.onChange(next);
|
|
67
68
|
close(true, opens.at === "add" && canAddSortRule(next, places));
|
|
68
69
|
}, onDone: () => close() }));
|
|
69
|
-
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
|
|
70
71
|
? sorts.rules.length > 1
|
|
71
72
|
? String(sorts.rules.length)
|
|
72
73
|
: undefined
|
|
@@ -75,9 +76,9 @@ function ComputerPill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host:
|
|
|
75
76
|
: undefined, popup: "dialog", open: panel.open && opens.at === "pill", onPointerDown: pressStart("pill"), onClick: press({ what: named || asideOnly ? "editor" : "fields", at: "pill", addSort: asideOnly || !addAfter }), children: named && !row ? (_jsxs(_Fragment, { children: [messages({ key: "views.panels.sorted-by" }), " ", _jsx("b", { children: named.first })] })) : (name) }), addAfter && named && can && (_jsx("span", { "data-slot": "vk-toolbar-sort-add", className: "inline-flex", children: _jsx(ToolbarButton, { ref: add, part: "sort-add", icon: _jsx(Plus, { className: "h-4 w-4 shrink-0" }), label: messages({ key: "views.panels.sort-add-one" }), word: null, popup: "dialog", open: panel.open && opens.at === "add", onPointerDown: pressStart("add"), onClick: press({ what: "fields", at: "add" }) }) })), Host ? (_jsx(Host, { open: panel.open, onOpenChange: panel.onOpenChange, title: name, children: content })) : (_jsx(Popover, { open: panel.open, onOpenChange: (next, details) => {
|
|
76
77
|
if (!next)
|
|
77
78
|
close(details?.reason !== "outside-press" && details?.reason !== "focus-out");
|
|
78
|
-
}, anchor: hangsAt.hidden ? hangsAt.anchor : opens.at === "add" ? add : pill,
|
|
79
|
+
}, anchor: hangsAt.hidden ? hangsAt.anchor : opens.at === "add" ? add : pill, ...hangs, chrome: "menu", panelData: { "data-slot": "vk-toolbar-sort-panel" }, children: content }))] }));
|
|
79
80
|
}
|
|
80
|
-
function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host }) {
|
|
81
|
+
function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host, changed }) {
|
|
81
82
|
const { icons, messages } = useViews();
|
|
82
83
|
const [held, setHeld] = useState(false);
|
|
83
84
|
const holds = openIn !== undefined && !!onOpenChangeIn;
|
|
@@ -88,5 +89,5 @@ function PhonePill({ sorts, open: openIn, onOpenChange: onOpenChangeIn, host })
|
|
|
88
89
|
const Glyph = icons.sort;
|
|
89
90
|
const name = messages({ key: "views.panels.sort" });
|
|
90
91
|
const n = sorts.rules.length;
|
|
91
|
-
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) })) }));
|
|
92
93
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { type ReactNode, type RefObject, type ComponentType } from "react";
|
|
2
2
|
import type { ViewsToolbarButtonProps } from "../../../atoms/types.js";
|
|
3
|
+
import type { ViewsAlign, ViewsSide } from "../../../provider/components.js";
|
|
3
4
|
import type { ToolbarForm, ToolbarLine } from "../../toolbar/model.js";
|
|
4
5
|
/** Where a part stands: the toolbar's form, whether it fills its line, its buttons' size, and its line's kind.
|
|
5
6
|
* In the fold arrangement (`fold`), also how far its line gave way: whether its words turned to its icon
|
|
@@ -40,6 +41,26 @@ export type ToolbarSlotState = {
|
|
|
40
41
|
/** Its place's own button (`ToolbarPartPlace.button`, VK-984), drawn for every toolbar button the part draws, in place of
|
|
41
42
|
* your `ToolbarButton`, handed the same props. */
|
|
42
43
|
button?: ComponentType<ViewsToolbarButtonProps>;
|
|
44
|
+
/** Its side of its line (VK-994), folded into ⋯ ⋯'s side: what it opens hangs toward it. Absent outside ViewKit's
|
|
45
|
+
* `Toolbar`. */
|
|
46
|
+
side?: "start" | "end";
|
|
47
|
+
/** Its place's own placement for what it opens (`ToolbarPartPlace.panel`, VK-994). */
|
|
48
|
+
panel?: ToolbarPanelPlace;
|
|
49
|
+
};
|
|
50
|
+
/** Where a part's popover hangs at its button (VK-994): the popover's `side`, `align` and `sideOffset` (`offset`). */
|
|
51
|
+
export type ToolbarPanelPlace = {
|
|
52
|
+
side?: ViewsSide;
|
|
53
|
+
align?: ViewsAlign;
|
|
54
|
+
offset?: number;
|
|
55
|
+
};
|
|
56
|
+
/** Where a part's popover hangs: its place's own `panel` first; else toward its side of its line, on the end side
|
|
57
|
+
* aligned to its button's end, on the start side to its start; outside ViewKit's `Toolbar`, `own`, as it always hung.
|
|
58
|
+
* 8 px below its button unless its place says. Read from where it stands, never from whether it is open, so a closing
|
|
59
|
+
* panel keeps its side. */
|
|
60
|
+
export declare function usePanelPlace(own: ViewsAlign): {
|
|
61
|
+
side?: ViewsSide;
|
|
62
|
+
align: ViewsAlign;
|
|
63
|
+
sideOffset: number;
|
|
43
64
|
};
|
|
44
65
|
/** The fold arrangement's part of a slot, for a line that doesn't fold. */
|
|
45
66
|
export declare const NOT_FOLDING: {
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { createContext, createElement, useCallback, useContext, useEffect, useId, useLayoutEffect, useRef, useState, } from "react";
|
|
3
3
|
import { useDesktop } from "../../../provider/desktop.js";
|
|
4
|
+
export function usePanelPlace(own) {
|
|
5
|
+
const { side, panel } = useToolbarSlot();
|
|
6
|
+
return { ...(panel?.side && { side: panel.side }), align: panel?.align ?? side ?? own, sideOffset: panel?.offset ?? 8 };
|
|
7
|
+
}
|
|
4
8
|
export const NOT_FOLDING = {
|
|
5
9
|
fold: false,
|
|
6
10
|
iconAlone: false,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type ComponentProps, type ReactNode } from "react";
|
|
2
|
+
import type { ToolbarPanelHost } from "./panel-part.js";
|
|
3
|
+
/** The list's box the Pane stands in: positioned, holding the grid under the toolbar. Null until it is on the page. */
|
|
4
|
+
export declare const PaneBox: import("react").Context<HTMLElement | null>;
|
|
5
|
+
/** A toolbar panel in the map's `Pane`, in the box `PaneBox` holds. Drawn only where the map has a `Pane`. */
|
|
6
|
+
export declare function PaneHost({ open, onOpenChange, title, opener, children }: ComponentProps<ToolbarPanelHost>): ReactNode;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useLayoutEffect, useState } from "react";
|
|
4
|
+
import { useViews } from "../../../provider/context.js";
|
|
5
|
+
export const PaneBox = createContext(null);
|
|
6
|
+
export function PaneHost({ open, onOpenChange, title, opener, children }) {
|
|
7
|
+
const { Pane } = useViews().components;
|
|
8
|
+
const box = useContext(PaneBox);
|
|
9
|
+
const [from, setFrom] = useState(null);
|
|
10
|
+
useLayoutEffect(() => {
|
|
11
|
+
if (open)
|
|
12
|
+
setFrom(opener?.current ?? null);
|
|
13
|
+
}, [open, opener]);
|
|
14
|
+
if (!Pane)
|
|
15
|
+
return null;
|
|
16
|
+
return (_jsx(Pane, { open: open, onOpenChange: onOpenChange, container: box, opener: from, label: title, children: children }));
|
|
17
|
+
}
|
|
@@ -4,7 +4,7 @@ import { useEffect, useRef } from "react";
|
|
|
4
4
|
import { useViews } from "../../../provider/context.js";
|
|
5
5
|
import { PanelSheet, useSheetDrawsClose, useSheetPanels } from "../panel-sheet.js";
|
|
6
6
|
import { placePart } from "../../../atoms/frame-parts.js";
|
|
7
|
-
import { useFoldAnchor, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
7
|
+
import { useFoldAnchor, usePanelPlace, useToolbarPanel, useToolbarSlot } from "./context.js";
|
|
8
8
|
import { ToolbarButton } from "./ToolbarButton.js";
|
|
9
9
|
export function ToolbarPanelPart({ panelKey, slot, part: ownPart, icon, label, word, count, onClear, dot, changed, open: openIn, onOpenChange: onOpenChangeIn, host: Host, popoverClassName, words, more, empty, disabled, disabledReason, sheetActions, sheetTitle, onSheetEscape, children, }) {
|
|
10
10
|
const { components } = useViews();
|
|
@@ -16,6 +16,7 @@ export function ToolbarPanelPart({ panelKey, slot, part: ownPart, icon, label, w
|
|
|
16
16
|
const held = useToolbarPanel(panelKey, openIn === undefined || !onOpenChangeIn ? undefined : { open: openIn, onOpenChange: onOpenChangeIn });
|
|
17
17
|
const { open, onOpenChange } = held;
|
|
18
18
|
const hangsAt = useFoldAnchor(anchor);
|
|
19
|
+
const hangs = usePanelPlace("end");
|
|
19
20
|
const openAtPress = useRef(false);
|
|
20
21
|
const focusBack = useRef(false);
|
|
21
22
|
const close = () => {
|
|
@@ -44,7 +45,7 @@ export function ToolbarPanelPart({ panelKey, slot, part: ownPart, icon, label, w
|
|
|
44
45
|
const reason = details?.reason;
|
|
45
46
|
if (!next && reason !== "outside-press" && reason !== "focus-out")
|
|
46
47
|
hangsAt.anchor.current?.focus({ preventScroll: true });
|
|
47
|
-
}, anchor: hangsAt.anchor,
|
|
48
|
+
}, anchor: hangsAt.anchor, ...hangs, chrome: "menu", className: popoverClassName, panelData: { "data-slot": `${slot}-panel` }, children: _jsx(PanelBody, { render: children, args: { fill: false, close, closeButton: true } }) }))] }));
|
|
48
49
|
}
|
|
49
50
|
function PanelBody({ render, args }) {
|
|
50
51
|
return render(args);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import { useCallback, useRef } from "react";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useCallback, useRef, useState } from "react";
|
|
4
4
|
import { cx } from "../../../internal/cx.js";
|
|
5
5
|
import { useViews } from "../../../provider/context.js";
|
|
6
6
|
import { formatCount } from "../../../internal/count.js";
|
|
@@ -15,7 +15,7 @@ import { ViewCreatePill } from "./ViewCreatePill.js";
|
|
|
15
15
|
export function ViewPicker({ axis, className }) {
|
|
16
16
|
const context = useViews();
|
|
17
17
|
const { components, conventions, icons, messages } = context;
|
|
18
|
-
const { AppIcon, Popover, ViewsListBody } = components;
|
|
18
|
+
const { AppIcon, Popover, ViewMenu, ViewsListBody } = components;
|
|
19
19
|
const Chevron = icons.chevronDown;
|
|
20
20
|
const anchor = useRef(null);
|
|
21
21
|
const toggle = useAnchoredToggle(anchor);
|
|
@@ -30,8 +30,15 @@ export function ViewPicker({ axis, className }) {
|
|
|
30
30
|
const active = axis.options.find((option) => option.value === axis.value);
|
|
31
31
|
const onOpenChange = toggle.onOpenChange;
|
|
32
32
|
const close = toggle.close;
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const [creating, setCreating] = useState(0);
|
|
34
|
+
const empty = axis.options.length === 0;
|
|
35
|
+
if (!empty && creating !== 0)
|
|
36
|
+
setCreating(0);
|
|
37
|
+
if (empty) {
|
|
38
|
+
if (!axis.onCreate)
|
|
39
|
+
return null;
|
|
40
|
+
const verbs = ViewMenu ? axis.verbs : undefined;
|
|
41
|
+
return (_jsxs(_Fragment, { children: [_jsx(ViewCreatePill, { label: axis.createLabel, onClick: verbs ? () => setCreating((n) => n + 1) : axis.onCreate, className: className }), ViewMenu && verbs && creating > 0 && (_jsx(ViewMenu, { open: true, onOpenChange: keepOpen, anchor: anchor, views: [], value: axis.value, verbs: verbs }, creating))] }));
|
|
35
42
|
}
|
|
36
43
|
const { onCreate, onReorder } = axis;
|
|
37
44
|
const listLabel = messages({ key: "views.panels.views-list" });
|
|
@@ -85,3 +92,4 @@ export function ViewPicker({ axis, className }) {
|
|
|
85
92
|
},
|
|
86
93
|
}), onSheetEscape: step.escapeBack, children: list })) : (_jsx(Popover, { open: toggle.open, onOpenChange: onOpenChange, anchor: anchor, align: "start", sideOffset: 6, chrome: "menu", className: "w-72", onOutsidePress: () => (holding.current ? false : undefined), onEscape: () => (holding.current ? false : undefined), children: list }))] }));
|
|
87
94
|
}
|
|
95
|
+
const keepOpen = () => { };
|
|
@@ -27,11 +27,11 @@ 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";
|
|
34
|
-
export type { ToolbarSlotState } from "./react/toolbar/context.js";
|
|
34
|
+
export type { ToolbarPanelPlace, ToolbarSlotState } from "./react/toolbar/context.js";
|
|
35
35
|
export { ToolbarSearch } from "./react/toolbar/ToolbarSearch.js";
|
|
36
36
|
export { ToolbarNew } from "./react/toolbar/ToolbarNew.js";
|
|
37
37
|
export { ToolbarViews } from "./react/toolbar/ToolbarViews.js";
|
|
@@ -3,22 +3,16 @@ import { resolveViewsMessage } from "../../contract.js";
|
|
|
3
3
|
import { listCardLayout } from "../../model/card-layout.js";
|
|
4
4
|
import { columnLabel, columnPlacedByView, resolveViewColumnOrder, } from "../../model/column-capabilities.js";
|
|
5
5
|
import { columnHideable, isColumnHidden, resolveColumnOrder, toggleColumnHidden, } from "../../model/column-state.js";
|
|
6
|
-
import { verticalBordersDefault } from "../../model/prefs-buckets.js";
|
|
7
6
|
import { boardFieldCandidates, boardFieldOf, calendarFieldCandidates, calendarFieldOf, defaultCalendarField, withBoardField, withCalendarField, } from "./axes.js";
|
|
8
7
|
import { columnRefOf, columnsChangeOf, columnsReset, columnStateOf, settingsColumnId, } from "../../model/settings-columns.js";
|
|
9
8
|
import { withPartColumns } from "../../model/part-columns.js";
|
|
10
9
|
import { lookChange, seenLook } from "../../model/settings-look.js";
|
|
11
10
|
const LAYOUTS = ["table", "list", "board", "calendar"];
|
|
12
11
|
const DENSITIES = ["compact", "default", "spacious"];
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
(layer.folded ?? []).length > 0 ||
|
|
18
|
-
layer.phoneLayout !== undefined);
|
|
19
|
-
}
|
|
20
|
-
function phoneLayoutOf(settings, layer) {
|
|
21
|
-
return layer.phoneLayout ?? (settings.layout === "table" ? "list" : settings.layout);
|
|
12
|
+
function phoneLayoutOf(settings, layer, offered) {
|
|
13
|
+
if (layer.phoneLayout && offered.includes(layer.phoneLayout))
|
|
14
|
+
return layer.phoneLayout;
|
|
15
|
+
return settings.layout === "table" && offered.includes("list") ? "list" : settings.layout;
|
|
22
16
|
}
|
|
23
17
|
export function settingsLayout(input) {
|
|
24
18
|
const { settings, layer, columns, onChange, onLayerChange, defaults } = input;
|
|
@@ -86,18 +80,8 @@ export function settingsLayout(input) {
|
|
|
86
80
|
value: look[key],
|
|
87
81
|
onChange: (next) => write(applyLook(settings, key, next, defaults)),
|
|
88
82
|
});
|
|
89
|
-
const bordersDefault = verticalBordersDefault(defaults);
|
|
90
83
|
const toggles = [
|
|
91
|
-
|
|
92
|
-
...lookToggle("verticalBorders", "views.panels.look-vertical-borders"),
|
|
93
|
-
...(look.verticalBorders !== bordersDefault
|
|
94
|
-
? {
|
|
95
|
-
reset: {
|
|
96
|
-
onReset: () => write(applyLook(settings, "verticalBorders", bordersDefault, defaults)),
|
|
97
|
-
},
|
|
98
|
-
}
|
|
99
|
-
: {}),
|
|
100
|
-
},
|
|
84
|
+
lookToggle("verticalBorders", "views.panels.look-vertical-borders"),
|
|
101
85
|
...(input.rowIcon ? [lookToggle("rowIcon", "views.panels.look-row-icon")] : []),
|
|
102
86
|
...(columns.some((column) => column.type === "title")
|
|
103
87
|
? [lookToggle("freezeIdentity", "views.panels.look-freeze-identity")]
|
|
@@ -205,26 +189,11 @@ export function settingsLayout(input) {
|
|
|
205
189
|
views: ["board"],
|
|
206
190
|
});
|
|
207
191
|
}
|
|
208
|
-
const phone = phoneLayoutOf(settings, layer);
|
|
192
|
+
const phone = phoneLayoutOf(settings, layer, options.map((option) => option.value));
|
|
209
193
|
const setPhone = (value) => {
|
|
210
194
|
if (value !== layer.phoneLayout)
|
|
211
195
|
onLayerChange({ phoneLayout: value });
|
|
212
196
|
};
|
|
213
|
-
const personal = {
|
|
214
|
-
choices: [
|
|
215
|
-
{
|
|
216
|
-
key: "personal.mobileLayout",
|
|
217
|
-
label: word("views.panels.phone-layout"),
|
|
218
|
-
value: phone,
|
|
219
|
-
options: LAYOUTS.map((value) => ({
|
|
220
|
-
value,
|
|
221
|
-
label: word(value === "list" ? "views.panels.layout-rows" : `views.panels.layout-${value}`),
|
|
222
|
-
})),
|
|
223
|
-
onChange: (value) => setPhone(value),
|
|
224
|
-
},
|
|
225
|
-
],
|
|
226
|
-
...(layerTouched(layer) ? { onReset: () => onLayerChange(EMPTY_LAYER) } : {}),
|
|
227
|
-
};
|
|
228
197
|
return {
|
|
229
198
|
label: word("views.panels.layout"),
|
|
230
199
|
value: settings.layout,
|
|
@@ -251,7 +220,6 @@ export function settingsLayout(input) {
|
|
|
251
220
|
},
|
|
252
221
|
...(choices.length ? { choices } : {}),
|
|
253
222
|
...(offersBoard ? { hidesGroupFor: ["board"] } : {}),
|
|
254
|
-
personal,
|
|
255
223
|
};
|
|
256
224
|
}
|
|
257
225
|
function applyLook(settings, key, value, defaults) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ListPersonalLayer, type ListSettings, type ListSettingsChange } from "viewkitjs/fields/query";
|
|
2
|
+
import type { SettingsPanelsInput } from "../settings/input.js";
|
|
3
|
+
/** A Customize page that resets itself. */
|
|
4
|
+
export type CustomizePage = "layout" | "columns" | "filter" | "sort" | "group";
|
|
5
|
+
/** A page's way back: the settings change it writes and its part of the layer, each null where it holds nothing (a page
|
|
6
|
+
* that differs by its layer part alone writes no settings). */
|
|
7
|
+
export type PageReset = {
|
|
8
|
+
change: ListSettingsChange | null;
|
|
9
|
+
layer: ListPersonalLayer | null;
|
|
10
|
+
};
|
|
11
|
+
/** Each page's way back to `saved`, present only while that page differs. `saved` null: no page has one (a shown view
|
|
12
|
+
* that hands no saved settings). With `cleared` (no view shown), the first page's Clear is the baseline, on a phone the
|
|
13
|
+
* phone's (`phone`), as the first page's Clear reads it. */
|
|
14
|
+
export declare function pageResets<Row>(input: Omit<SettingsPanelsInput<Row>, "onChange" | "onLayerChange">, saved: ListSettings | null, { cleared, phone }?: {
|
|
15
|
+
cleared?: boolean;
|
|
16
|
+
phone?: boolean;
|
|
17
|
+
}): Partial<Record<CustomizePage, PageReset>>;
|