viewkitjs 0.29.0 → 0.30.1
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 +127 -6
- package/MIGRATION.md +97 -8
- package/package.json +1 -1
- package/views/dist/cells/cell-format.d.ts +2 -2
- package/views/dist/cells/cell-values.js +0 -2
- package/views/dist/contract.d.ts +15 -18
- package/views/dist/contract.js +13 -27
- package/views/dist/controls/button/map-button.d.ts +5 -3
- package/views/dist/controls/button/map-button.js +14 -7
- package/views/dist/controls/controls.d.ts +2 -4
- package/views/dist/controls/controls.js +2 -2
- package/views/dist/controls/customize/customize.d.ts +51 -0
- package/views/dist/controls/customize/customize.js +128 -23
- package/views/dist/controls/customize/map-customize-body.d.ts +0 -3
- package/views/dist/controls/customize/map-customize-body.js +46 -11
- package/views/dist/controls/customize/map-ranges.d.ts +23 -0
- package/views/dist/controls/customize/map-ranges.js +41 -0
- package/views/dist/controls/customize/rules.d.ts +17 -1
- package/views/dist/controls/customize/rules.js +2 -0
- package/views/dist/controls/customize/words.d.ts +7 -0
- package/views/dist/controls/customize/words.js +5 -0
- package/views/dist/controls/customize.css +3 -0
- package/views/dist/controls/filter-editor/filter-editor.d.ts +2 -0
- package/views/dist/controls/filter-editor/filter-editor.js +1 -0
- package/views/dist/controls/filter-editor/rules.d.ts +1 -2
- package/views/dist/controls/index.d.ts +8 -8
- package/views/dist/controls/index.js +8 -8
- package/views/dist/controls/menu-list/menu-list.d.ts +16 -1
- package/views/dist/controls/menu-list/menu-list.js +26 -8
- package/views/dist/controls/menu-list.css +8 -0
- package/views/dist/controls/quick-filters/map-quick-filters-body.d.ts +1 -1
- package/views/dist/controls/quick-filters/map-quick-filters-body.js +6 -3
- package/views/dist/controls/sheet/map-sheet.js +1 -1
- package/views/dist/controls/text-editor/map-text-body.d.ts +1 -1
- package/views/dist/controls/text-editor/map-text-body.js +2 -2
- package/views/dist/controls/text-editor/text-editor.d.ts +3 -0
- package/views/dist/controls/text-editor/text-editor.js +16 -2
- package/views/dist/controls/text-editor.css +11 -0
- package/views/dist/controls/values-editor/values.js +6 -2
- package/views/dist/display/options.d.ts +1 -1
- package/views/dist/display/rich-text.js +0 -1
- package/views/dist/editors/ChipsEditor.d.ts +4 -5
- package/views/dist/editors/ChipsEditor.js +12 -78
- package/views/dist/editors/DateEditor.d.ts +12 -16
- package/views/dist/editors/DateEditor.js +40 -191
- package/views/dist/editors/EditorPanel.d.ts +2 -6
- package/views/dist/editors/EditorPanel.js +2 -2
- package/views/dist/editors/LocationEditor.d.ts +11 -19
- package/views/dist/editors/LocationEditor.js +19 -211
- package/views/dist/editors/NameEditor.d.ts +8 -16
- package/views/dist/editors/NameEditor.js +11 -100
- package/views/dist/editors/NumberEditor.d.ts +14 -21
- package/views/dist/editors/NumberEditor.js +22 -49
- package/views/dist/editors/RangeEditor.d.ts +9 -33
- package/views/dist/editors/RangeEditor.js +12 -97
- package/views/dist/editors/RelationEditor.d.ts +6 -9
- package/views/dist/editors/RelationEditor.js +11 -30
- package/views/dist/editors/RelationSetEditor.d.ts +13 -24
- package/views/dist/editors/RelationSetEditor.js +33 -101
- package/views/dist/editors/SelectEditor.d.ts +15 -17
- package/views/dist/editors/SelectEditor.js +15 -94
- package/views/dist/editors/TextEditor.d.ts +23 -26
- package/views/dist/editors/TextEditor.js +11 -48
- package/views/dist/editors/ValueListEditor.d.ts +14 -23
- package/views/dist/editors/ValueListEditor.js +16 -202
- package/views/dist/editors/body-panel.d.ts +13 -7
- package/views/dist/editors/body-panel.js +3 -7
- package/views/dist/editors/edit-cores.d.ts +15 -15
- package/views/dist/editors/edit-cores.js +14 -14
- package/views/dist/editors/number-body.d.ts +1 -1
- package/views/dist/editors/number-step.d.ts +0 -34
- package/views/dist/editors/number-step.js +0 -37
- package/views/dist/editors/option-add-flow.d.ts +1 -13
- package/views/dist/editors/option-add-flow.js +0 -22
- package/views/dist/editors/relation-links-body.d.ts +2 -3
- package/views/dist/editors/relation-picker.d.ts +13 -3
- package/views/dist/editors/relation-source.d.ts +0 -22
- package/views/dist/editors/relation-source.js +0 -21
- package/views/dist/field-row/FieldRow.js +5 -6
- package/views/dist/field-row/FieldRowLane.js +0 -1
- package/views/dist/field-row/editors/RowChipsEditor.js +2 -2
- package/views/dist/field-row/editors/RowDateEditor.d.ts +2 -2
- package/views/dist/field-row/editors/RowDateEditor.js +2 -2
- package/views/dist/field-row/editors/RowNameEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowNameEditor.js +7 -12
- package/views/dist/field-row/editors/RowNumberEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowNumberEditor.js +4 -4
- package/views/dist/field-row/editors/RowPlaceEditor.js +3 -3
- package/views/dist/field-row/editors/RowRangeEditor.d.ts +2 -5
- package/views/dist/field-row/editors/RowRangeEditor.js +7 -14
- package/views/dist/field-row/editors/RowRelationEditor.js +3 -3
- package/views/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/views/dist/field-row/editors/RowTextEditor.d.ts +1 -1
- package/views/dist/field-row/editors/RowTextEditor.js +3 -4
- package/views/dist/field-row/editors/RowValueListEditor.js +5 -5
- package/views/dist/field-row/field-row-button.d.ts +6 -9
- package/views/dist/field-row/field-row-button.js +1 -6
- package/views/dist/field-row/field-row-checkbox.d.ts +1 -1
- package/views/dist/field-row/row-target.d.ts +0 -7
- package/views/dist/field-row/row-target.js +0 -2
- package/views/dist/grid/chrome/GridAddColumn.d.ts +2 -1
- package/views/dist/grid/chrome/GridAddColumn.js +8 -66
- package/views/dist/grid/chrome/GridAggregateMenu.d.ts +5 -7
- package/views/dist/grid/chrome/GridAggregateMenu.js +20 -39
- package/views/dist/grid/chrome/GridCellEditors.d.ts +2 -2
- package/views/dist/grid/chrome/GridCellEditors.js +12 -12
- package/views/dist/grid/chrome/GridChipsEditor.js +3 -3
- package/views/dist/grid/chrome/GridColumnMenu.d.ts +11 -12
- package/views/dist/grid/chrome/GridColumnMenu.js +32 -93
- package/views/dist/grid/chrome/GridDateEditor.d.ts +6 -6
- package/views/dist/grid/chrome/GridDateEditor.js +3 -3
- package/views/dist/grid/chrome/GridGroupMenu.d.ts +4 -6
- package/views/dist/grid/chrome/GridGroupMenu.js +21 -62
- package/views/dist/grid/chrome/GridHeader.d.ts +1 -2
- package/views/dist/grid/chrome/GridHeader.js +2 -2
- package/views/dist/grid/chrome/GridLongTextEditor.d.ts +17 -38
- package/views/dist/grid/chrome/GridLongTextEditor.js +6 -7
- package/views/dist/grid/chrome/GridNameEditor.js +4 -4
- package/views/dist/grid/chrome/GridNumberEditor.d.ts +4 -5
- package/views/dist/grid/chrome/GridNumberEditor.js +3 -4
- package/views/dist/grid/chrome/GridPlaceEditor.d.ts +2 -5
- package/views/dist/grid/chrome/GridPlaceEditor.js +5 -5
- package/views/dist/grid/chrome/GridRangeEditor.d.ts +6 -12
- package/views/dist/grid/chrome/GridRangeEditor.js +7 -15
- package/views/dist/grid/chrome/GridRelationEditor.js +5 -5
- package/views/dist/grid/chrome/GridRow.js +0 -3
- package/views/dist/grid/chrome/GridRowActions.d.ts +1 -1
- package/views/dist/grid/chrome/GridRowActions.js +0 -5
- package/views/dist/grid/chrome/GridRowCells.js +9 -6
- package/views/dist/grid/chrome/GridSelectEditor.js +3 -3
- package/views/dist/grid/chrome/GridStructure.js +0 -1
- package/views/dist/grid/chrome/GridTable.js +1 -1
- package/views/dist/grid/chrome/GridTextEditor.d.ts +5 -7
- package/views/dist/grid/chrome/GridTextEditor.js +4 -17
- package/views/dist/grid/chrome/GridValueListEditor.js +4 -4
- package/views/dist/grid/chrome/grid-body-place.d.ts +2 -3
- package/views/dist/grid/chrome/grid-body-place.js +4 -8
- package/views/dist/grid/chrome/grid-button.d.ts +7 -10
- package/views/dist/grid/chrome/grid-button.js +1 -6
- package/views/dist/grid/chrome/grid-cell-classes.js +1 -1
- package/views/dist/grid/chrome/grid-column-menu-items.d.ts +4 -4
- package/views/dist/grid/chrome/grid-column-menu-items.js +10 -6
- package/views/dist/grid/chrome/grid-group-menu-parts.d.ts +5 -9
- package/views/dist/grid/chrome/grid-group-menu-parts.js +1 -3
- package/views/dist/grid/chrome/grid-hover.js +0 -1
- package/views/dist/grid/chrome/grid-menu-focus.d.ts +7 -31
- package/views/dist/grid/chrome/grid-menu-focus.js +7 -47
- package/views/dist/grid/chrome/grid-styles.d.ts +0 -3
- package/views/dist/grid/chrome/grid-styles.js +0 -1
- package/views/dist/grid/chrome/grid-table-props.d.ts +6 -10
- package/views/dist/grid/chrome/useGridTableInteractionModel.js +2 -4
- package/views/dist/grid/core/editing-controller.d.ts +2 -1
- package/views/dist/grid/core/editing-controller.js +10 -2
- package/views/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/views/dist/grid/core/refusal-sentence.js +2 -2
- package/views/dist/grid/core/write-states.d.ts +3 -1
- package/views/dist/grid/core/write-states.js +6 -2
- package/views/dist/grid/grid.css +1 -1
- package/views/dist/model/body-frame.d.ts +0 -32
- package/views/dist/model/body-frame.js +1 -15
- package/views/dist/model/column-inspect.d.ts +5 -5
- package/views/dist/model/column-inspect.js +2 -2
- package/views/dist/panels/customize-body.d.ts +1 -10
- package/views/dist/panels/customize-body.js +0 -3
- package/views/dist/panels/filter/MenuSelect.js +0 -5
- package/views/dist/panels/filter/RangeFilterBody.js +0 -1
- package/views/dist/panels/filter/details.d.ts +1 -5
- package/views/dist/panels/filter/details.js +0 -13
- package/views/dist/panels/filter/filter-list.d.ts +0 -1
- package/views/dist/panels/filter/filter-list.js +1 -1
- package/views/dist/panels/panel-button.d.ts +10 -12
- package/views/dist/panels/panel-button.js +1 -6
- package/views/dist/panels/react/chrome.d.ts +0 -17
- package/views/dist/panels/react/chrome.js +0 -8
- package/views/dist/panels/react/customize-body.d.ts +9 -12
- package/views/dist/panels/react/customize-body.js +57 -11
- package/views/dist/panels/react/customize.d.ts +9 -12
- package/views/dist/panels/react/customize.js +3 -112
- package/views/dist/panels/react/filter/FilterEditor.d.ts +4 -18
- package/views/dist/panels/react/filter/FilterEditor.js +6 -330
- package/views/dist/panels/react/filter/FilterFieldList.d.ts +1 -1
- package/views/dist/panels/react/filter/FilterFieldList.js +27 -59
- package/views/dist/panels/react/filter/PhoneFilterEditor.d.ts +1 -11
- package/views/dist/panels/react/filter/PhoneFilterEditor.js +8 -144
- package/views/dist/panels/react/filter/editor-ctx.d.ts +1 -33
- package/views/dist/panels/react/filter/editor-ctx.js +5 -33
- package/views/dist/panels/react/filter/filter-part-body.d.ts +3 -6
- package/views/dist/panels/react/filter/filter-part-body.js +0 -5
- package/views/dist/panels/react/filter/rule-writes.d.ts +1 -26
- package/views/dist/panels/react/filter/rule-writes.js +4 -95
- package/views/dist/panels/react/order-details.d.ts +1 -26
- package/views/dist/panels/react/order-details.js +3 -69
- package/views/dist/panels/react/panel-header.js +0 -1
- package/views/dist/panels/react/popover.d.ts +4 -7
- package/views/dist/panels/react/quick/QuickFiltersPanel.d.ts +2 -4
- package/views/dist/panels/react/quick/QuickFiltersPanel.js +16 -137
- package/views/dist/panels/react/sort/SortEditor.d.ts +4 -4
- package/views/dist/panels/react/sort/SortEditor.js +8 -245
- package/views/dist/panels/react/sort/SortFieldList.d.ts +1 -1
- package/views/dist/panels/react/sort/SortFieldList.js +11 -25
- package/views/dist/panels/react/toolbar/ToolbarAdvancedFilters.js +2 -2
- package/views/dist/panels/react/toolbar/ToolbarBarFilter.js +4 -16
- package/views/dist/panels/react/toolbar/ToolbarQuickFilters.js +1 -1
- package/views/dist/panels/react/toolbar/ToolbarSave.js +0 -4
- package/views/dist/panels/react/toolbar/ToolbarSearch.js +0 -1
- package/views/dist/panels/react/toolbar/ToolbarSortPill.js +3 -3
- package/views/dist/panels/react/view-actions.js +0 -1
- package/views/dist/panels/react/views-row/FoldingViewRow.js +5 -9
- package/views/dist/panels/react/views-row/ViewCreatePill.js +0 -1
- package/views/dist/panels/react/views-row/ViewPicker.js +7 -43
- package/views/dist/panels/react/views-row/ViewPickerRow.js +0 -2
- package/views/dist/panels/react/views-row/menu-classes.d.ts +0 -4
- package/views/dist/panels/react/views-row/menu-classes.js +0 -2
- package/views/dist/panels/react.d.ts +5 -12
- package/views/dist/panels/react.js +5 -12
- package/views/dist/provider/ViewsProvider.d.ts +2 -46
- package/views/dist/provider/ViewsProvider.js +2 -22
- package/views/dist/provider/components.d.ts +153 -106
- package/views/dist/provider/context.d.ts +1 -21
- package/views/dist/provider/missing-slot.d.ts +3 -7
- package/views/dist/provider/missing-slot.js +2 -9
- package/views/dist/react.d.ts +1 -2
- package/views/dist/selection/SelectionBar.js +2 -3
- package/views/dist/styles.css +40 -168
- package/views/dist/styles.unlayered.css +40 -168
- package/views/docs/contract.md +99 -123
- package/views/docs/getting-started.md +222 -2
- package/views/docs/guides/cells.md +222 -2
- package/views/docs/guides/display.md +1 -1
- package/views/docs/guides/editors.md +235 -20
- package/views/docs/guides/ports.md +1 -1
- package/views/docs/guides/selection.md +1 -1
- package/views/docs/guides/the-grid.md +14 -16
- package/views/docs/guides/the-provider.md +9 -15
- package/views/docs/reference/cells.md +1 -1
- package/views/docs/reference/controls.md +28 -15
- package/views/docs/reference/editors-chips.md +2 -2
- package/views/docs/reference/editors-date.md +4 -4
- package/views/docs/reference/editors-location.md +4 -7
- package/views/docs/reference/editors-name.md +3 -5
- package/views/docs/reference/editors-number.md +10 -10
- package/views/docs/reference/editors-panel.md +3 -3
- package/views/docs/reference/editors-range.md +3 -5
- package/views/docs/reference/editors-relation.md +4 -4
- package/views/docs/reference/editors-select.md +3 -3
- package/views/docs/reference/editors-text.md +3 -4
- package/views/docs/reference/editors-value-list.md +3 -3
- package/views/docs/reference/field-row.md +1 -1
- package/views/docs/reference/grid.md +2 -2
- package/views/docs/reference/panels-react.md +20 -34
- package/views/docs/reference/react.md +11 -18
- package/views/docs/reference/views.md +5 -5
- package/views/skills/views/SKILL.md +1 -1
- package/views/dist/editors/relation-panel.d.ts +0 -69
- package/views/dist/editors/relation-panel.js +0 -46
- package/views/dist/grid/chrome/GridColumnColorSection.d.ts +0 -13
- package/views/dist/grid/chrome/GridColumnColorSection.js +0 -40
- package/views/dist/grid/chrome/GridColumnDateSection.d.ts +0 -28
- package/views/dist/grid/chrome/GridColumnDateSection.js +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.d.ts +0 -23
- package/views/dist/grid/chrome/GridColumnDurationSection.js +0 -24
- package/views/dist/grid/chrome/GridColumnNumberSection.d.ts +0 -29
- package/views/dist/grid/chrome/GridColumnNumberSection.js +0 -27
- package/views/dist/grid/chrome/GridColumnPercentSection.d.ts +0 -16
- package/views/dist/grid/chrome/GridColumnPercentSection.js +0 -16
- package/views/dist/grid/chrome/GridColumnSortSection.d.ts +0 -38
- package/views/dist/grid/chrome/GridColumnSortSection.js +0 -33
- package/views/dist/grid/chrome/GridFlyout.d.ts +0 -44
- package/views/dist/grid/chrome/GridFlyout.js +0 -80
- package/views/dist/grid/chrome/GridMenuRow.d.ts +0 -15
- package/views/dist/grid/chrome/GridMenuRow.js +0 -15
- package/views/dist/grid/chrome/grid-menu-search.d.ts +0 -7
- package/views/dist/grid/chrome/grid-menu-search.js +0 -7
- package/views/dist/panels/react/GroupBucketsList.d.ts +0 -16
- package/views/dist/panels/react/GroupBucketsList.js +0 -44
- package/views/dist/panels/react/LayoutColumnsList.d.ts +0 -24
- package/views/dist/panels/react/LayoutColumnsList.js +0 -101
- package/views/dist/panels/react/PopoverColumnDetail.d.ts +0 -11
- package/views/dist/panels/react/PopoverColumnDetail.js +0 -24
- package/views/dist/panels/react/drag.d.ts +0 -2
- package/views/dist/panels/react/drag.js +0 -5
- package/views/dist/panels/react/layout-detail.d.ts +0 -4
- package/views/dist/panels/react/layout-detail.js +0 -29
- package/views/dist/panels/react/root-list.d.ts +0 -6
- package/views/dist/panels/react/root-list.js +0 -31
- package/views/dist/panels/react/sort/use-sort-drag.d.ts +0 -17
- package/views/dist/panels/react/sort/use-sort-drag.js +0 -39
- package/views/dist/panels/react/view-footer.d.ts +0 -20
- package/views/dist/panels/react/view-footer.js +0 -41
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx,
|
|
3
|
-
import {
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
|
-
import { useDesktop } from "../../provider/desktop.js";
|
|
6
|
-
import { cx } from "../../internal/cx.js";
|
|
7
5
|
import { drawGridButton } from "./grid-button.js";
|
|
8
6
|
import { gridAddColumnItems } from "./grid-add-column-items.js";
|
|
9
7
|
import { useGridMenuPress } from "./grid-menu-focus.js";
|
|
@@ -16,91 +14,35 @@ export function gridAddColumnNode(render, columns, at = "end") {
|
|
|
16
14
|
return null;
|
|
17
15
|
return own || _jsx(GridAddColumn, { columns: columns, at: at });
|
|
18
16
|
}
|
|
19
|
-
function addColumnRows(items, wanted, drill) {
|
|
20
|
-
const shown = (item) => item.hidden && !item.fixed;
|
|
21
|
-
if (wanted)
|
|
22
|
-
return items
|
|
23
|
-
.filter((item) => shown(item) && item.label.toLowerCase().includes(wanted))
|
|
24
|
-
.map((item) => ({ kind: "pick", item, label: item.label }));
|
|
25
|
-
const partsOf = (whole) => items.filter((item) => item.partOf?.column === whole.id);
|
|
26
|
-
const offered = (whole) => [
|
|
27
|
-
...(shown(whole) ? [{ kind: "pick", item: whole, label: whole.label }] : []),
|
|
28
|
-
...partsOf(whole)
|
|
29
|
-
.filter(shown)
|
|
30
|
-
.map((item) => ({ kind: "pick", item, label: item.partOf?.label ?? item.label })),
|
|
31
|
-
];
|
|
32
|
-
const whole = drill ? items.find((item) => item.id === drill) : undefined;
|
|
33
|
-
if (whole)
|
|
34
|
-
return [{ kind: "back", item: whole }, ...offered(whole)];
|
|
35
|
-
return items
|
|
36
|
-
.filter((item) => !item.partOf && !item.fixed)
|
|
37
|
-
.flatMap((item) => {
|
|
38
|
-
if (partsOf(item).length === 0)
|
|
39
|
-
return shown(item) ? [{ kind: "pick", item, label: item.label }] : [];
|
|
40
|
-
const count = offered(item).length;
|
|
41
|
-
return count ? [{ kind: "drill", item, count }] : [];
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
17
|
export function GridAddColumn({ columns, at = "end", }) {
|
|
45
18
|
const inTitle = at === "title";
|
|
46
19
|
const [open, setOpen] = useState(false);
|
|
47
|
-
const [query, setQuery] = useState("");
|
|
48
20
|
const [anchor, setAnchor] = useState(null);
|
|
49
21
|
const views = useViews();
|
|
50
|
-
const {
|
|
51
|
-
const {
|
|
22
|
+
const { components, icons, messages } = views;
|
|
23
|
+
const { Menu } = components;
|
|
52
24
|
const press = useGridMenuPress(open);
|
|
53
|
-
const menuRoute = (menus ?? "popover") === "menu";
|
|
54
|
-
const desktop = useDesktop();
|
|
55
25
|
const word = messages({ key: "views.grid.add-column" });
|
|
56
|
-
const { List, RowContent } = atoms;
|
|
57
26
|
const Add = icons.add;
|
|
58
|
-
const Chevron = icons.chevronRight;
|
|
59
|
-
const wanted = query.trim().toLowerCase();
|
|
60
|
-
const [drill, setDrill] = useState(null);
|
|
61
|
-
const rows = addColumnRows(columns.items, wanted, drill);
|
|
62
27
|
const close = (reason = "none") => {
|
|
63
28
|
setOpen(false);
|
|
64
|
-
setQuery("");
|
|
65
|
-
setDrill(null);
|
|
66
29
|
if (reason !== "outside-press" && reason !== "focus-out")
|
|
67
30
|
anchor?.focus({ preventScroll: true });
|
|
68
31
|
};
|
|
69
|
-
const focusSearch = useCallback((el) => el?.focus({ preventScroll: true }), []);
|
|
70
|
-
const list = (_jsxs(Command.Root, { shouldFilter: false, loop: true, label: messages({ key: "views.menus.add-column-search" }), children: [_jsx("div", { className: "flex h-10 shrink-0 items-center border-b border-(color:--vk-border)", children: _jsx(Command.Input, { chrome: "bare", value: query, onValueChange: setQuery, placeholder: messages({ key: "views.menus.add-column-search" }), ref: desktop ? focusSearch : undefined, className: cx("h-full min-w-0 flex-1 bg-transparent px-3.5 text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtlest)", desktop ? "text-sm" : "text-base") }) }), _jsx(Command.List, { className: "max-h-80 min-h-0 overflow-y-auto overscroll-contain", children: _jsx(Command.Group, { className: "p-0", children: _jsxs(List, { children: [rows.map((row) => {
|
|
71
|
-
const { item } = row;
|
|
72
|
-
const glyph = (node) => (_jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-(color:--vk-fg-subtle)", children: node }));
|
|
73
|
-
if (row.kind === "back")
|
|
74
|
-
return (_jsx(Command.Item, { value: "back", onSelect: () => setDrill(null), children: _jsx(RowContent, { label: item.label, leading: glyph(_jsx(Chevron, { className: "size-3.5 rotate-180" })) }) }, "back"));
|
|
75
|
-
if (row.kind === "drill")
|
|
76
|
-
return (_jsx(Command.Item, { value: `drill:${item.id}`, onSelect: () => {
|
|
77
|
-
setQuery("");
|
|
78
|
-
setDrill(item.id);
|
|
79
|
-
}, children: _jsx(RowContent, { label: item.label, leading: glyph(item.icon), detail: row.count, trailing: _jsx(Chevron, { className: "size-3.5 shrink-0 text-(color:--vk-fg-subtle)" }) }) }, `drill:${item.id}`));
|
|
80
|
-
return (_jsx(Command.Item, { value: item.id, onSelect: () => {
|
|
81
|
-
columns.onToggleHidden(item.id, false);
|
|
82
|
-
close("item-press");
|
|
83
|
-
}, children: _jsx(RowContent, { label: row.label, leading: glyph(item.icon) }) }, item.id));
|
|
84
|
-
}), !rows.some((row) => row.kind !== "back") && (_jsx("p", { className: "px-2 py-2 text-sm text-(color:--vk-fg-subtle)", children: wanted
|
|
85
|
-
? messages({ key: "views.menus.add-column-no-match", values: { query: query.trim() } })
|
|
86
|
-
: messages({ key: "views.menus.add-column-all-shown" }) }))] }) }) })] }));
|
|
87
32
|
return (_jsxs(_Fragment, { children: [drawGridButton(views, {
|
|
88
33
|
ref: setAnchor,
|
|
89
34
|
tabIndex: -1,
|
|
90
35
|
...(inTitle && { "aria-label": word, title: word }),
|
|
91
|
-
"aria-haspopup":
|
|
36
|
+
"aria-haspopup": "menu",
|
|
92
37
|
"aria-expanded": open,
|
|
93
38
|
"data-open": open ? "" : undefined,
|
|
94
|
-
onPointerDownCapture:
|
|
95
|
-
onClick: (e) => (
|
|
96
|
-
own: cx(inTitle
|
|
97
|
-
? "flex size-6 shrink-0 items-center justify-center rounded-full hover:bg-(color:--vk-hovered)"
|
|
98
|
-
: "flex h-full w-(--vk-tail-w) min-w-0 max-w-full flex-none items-center gap-1.5 px-(--vk-px) text-(length:--vk-head-text) hover:bg-(color:--vk-hovered)", open ? "bg-(color:--vk-pressed) text-(color:--vk-fg)" : "text-(color:--vk-fg-subtle)"),
|
|
39
|
+
onPointerDownCapture: press.notePress,
|
|
40
|
+
onClick: (e) => (press.pressedOpen(e) || open ? close() : setOpen(true)),
|
|
99
41
|
frame: inTitle
|
|
100
42
|
? "size-6 shrink-0 rounded-full"
|
|
101
43
|
: "h-full w-(--vk-tail-w) min-w-0 max-w-full flex-none justify-start gap-1.5 px-(--vk-px) text-(length:--vk-head-text)",
|
|
102
44
|
variant: "ghost",
|
|
103
45
|
size: inTitle ? "icon" : "sm",
|
|
104
46
|
children: inTitle ? (_jsx(Add, { className: "h-(--vk-head-glyph) w-(--vk-head-glyph) shrink-0" })) : (_jsxs(_Fragment, { children: [_jsx(Add, { className: "h-(--vk-head-glyph) w-(--vk-head-glyph) shrink-0 opacity-70" }), _jsx("span", { className: "truncate", children: word })] })),
|
|
105
|
-
}),
|
|
47
|
+
}), _jsx(Menu, { open: open, onOpenChange: (next, details) => (next ? setOpen(true) : close(details?.reason)), anchor: anchor, side: "bottom", align: inTitle ? "start" : "end", label: word, items: open ? gridAddColumnItems(columns, { messages, close: () => close("item-press") }) : [] })] }));
|
|
106
48
|
}
|
|
@@ -6,20 +6,18 @@ type TriggerProps = {
|
|
|
6
6
|
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
|
|
7
7
|
onPointerDownCapture?: () => void;
|
|
8
8
|
role?: "button" | "gridcell";
|
|
9
|
-
"aria-haspopup"?: "
|
|
9
|
+
"aria-haspopup"?: "menu";
|
|
10
10
|
"aria-expanded"?: boolean;
|
|
11
11
|
/** The contract's `open` state: present while the menu is open. */
|
|
12
12
|
"data-open"?: "";
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
|
-
* The footer cell's Calculate
|
|
15
|
+
* The footer cell's Calculate menu — pick the aggregate function for one
|
|
16
16
|
* column (numeric columns get sum/avg/min/max/count; everything else
|
|
17
17
|
* count/filled/unique; a source list's footer offers what the database answers,
|
|
18
18
|
* handed in as `options`). The trigger is the WHOLE footer cell, passed as the
|
|
19
|
-
* child: the map's
|
|
20
|
-
* through the host's persisted `gridAggregates` pref.
|
|
21
|
-
* route; on the `menu` route (the provider's `menus`) it is the map's `Menu`
|
|
22
|
-
* instead, anchored on the same cell, one ticked row per figure.
|
|
19
|
+
* child: the map's `Menu` anchors on it, one ticked row per figure; selection
|
|
20
|
+
* commits through the host's persisted `gridAggregates` pref.
|
|
23
21
|
*/
|
|
24
22
|
export declare function GridAggregateMenu<Row>({ column, options, current, onChange, align, children, }: {
|
|
25
23
|
column: ListColumn<Row>;
|
|
@@ -28,7 +26,7 @@ export declare function GridAggregateMenu<Row>({ column, options, current, onCha
|
|
|
28
26
|
options?: ListAggregateKind[];
|
|
29
27
|
current: ListAggregateKind;
|
|
30
28
|
onChange: (kind: ListAggregateKind) => void;
|
|
31
|
-
/** Match the column's alignment so the
|
|
29
|
+
/** Match the column's alignment so the menu hugs the value. */
|
|
32
30
|
align: "start" | "center" | "end";
|
|
33
31
|
/** The footer cell. The menu sets its `ref`, so it must carry none of its own. */
|
|
34
32
|
children: ReactElement<TriggerProps>;
|
|
@@ -4,57 +4,38 @@ import { cloneElement, useState, } from "react";
|
|
|
4
4
|
import { aggregateLabel, aggregateOptions } from "../../model/aggregates.js";
|
|
5
5
|
import { columnLabel } from "../../model/column-capabilities.js";
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
|
-
import {
|
|
7
|
+
import { useGridMenuFocus, useGridMenuPress } from "./grid-menu-focus.js";
|
|
8
8
|
export function GridAggregateMenu({ column, options, current, onChange, align, children, }) {
|
|
9
9
|
const [open, setOpen] = useState(false);
|
|
10
10
|
const [anchor, setAnchor] = useState(null);
|
|
11
11
|
useGridMenuFocus(open, anchor);
|
|
12
12
|
const press = useGridMenuPress(open);
|
|
13
|
-
const {
|
|
14
|
-
const {
|
|
15
|
-
const { List, Row } = atoms;
|
|
13
|
+
const { components, messages } = useViews();
|
|
14
|
+
const { Menu } = components;
|
|
16
15
|
const figures = options ?? aggregateOptions(column);
|
|
17
|
-
|
|
18
|
-
const menuTrigger = cloneElement(children, {
|
|
19
|
-
ref: setAnchor,
|
|
20
|
-
onPointerDownCapture: press.notePress,
|
|
21
|
-
onClick: (event) => {
|
|
22
|
-
children.props.onClick?.(event);
|
|
23
|
-
if (press.pressedOpen(event))
|
|
24
|
-
setOpen(false);
|
|
25
|
-
else
|
|
26
|
-
setOpen((was) => !was);
|
|
27
|
-
},
|
|
28
|
-
role: children.props.role ?? "button",
|
|
29
|
-
"aria-haspopup": "menu",
|
|
30
|
-
"aria-expanded": open,
|
|
31
|
-
"data-open": open ? "" : undefined,
|
|
32
|
-
});
|
|
33
|
-
return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "bottom", align: align, label: messages({ key: "views.menus.figure-menu", values: { field: columnLabel(column) } }), items: figures.map((kind) => ({
|
|
34
|
-
key: kind,
|
|
35
|
-
label: aggregateLabel(kind, messages),
|
|
36
|
-
checked: kind === current,
|
|
37
|
-
onSelect: () => {
|
|
38
|
-
setOpen(false);
|
|
39
|
-
if (kind !== current)
|
|
40
|
-
onChange(kind);
|
|
41
|
-
},
|
|
42
|
-
})) })] }));
|
|
43
|
-
}
|
|
44
|
-
const trigger = cloneElement(children, {
|
|
16
|
+
const menuTrigger = cloneElement(children, {
|
|
45
17
|
ref: setAnchor,
|
|
18
|
+
onPointerDownCapture: press.notePress,
|
|
46
19
|
onClick: (event) => {
|
|
47
20
|
children.props.onClick?.(event);
|
|
48
|
-
|
|
21
|
+
if (press.pressedOpen(event))
|
|
22
|
+
setOpen(false);
|
|
23
|
+
else
|
|
24
|
+
setOpen((was) => !was);
|
|
49
25
|
},
|
|
50
26
|
role: children.props.role ?? "button",
|
|
51
|
-
"aria-haspopup": "
|
|
27
|
+
"aria-haspopup": "menu",
|
|
52
28
|
"aria-expanded": open,
|
|
53
29
|
"data-open": open ? "" : undefined,
|
|
54
30
|
});
|
|
55
|
-
return (_jsxs(_Fragment, { children: [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
31
|
+
return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: (next) => setOpen(next), anchor: anchor, side: "bottom", align: align, label: messages({ key: "views.menus.figure-menu", values: { field: columnLabel(column) } }), items: figures.map((kind) => ({
|
|
32
|
+
key: kind,
|
|
33
|
+
label: aggregateLabel(kind, messages),
|
|
34
|
+
checked: kind === current,
|
|
35
|
+
onSelect: () => {
|
|
36
|
+
setOpen(false);
|
|
37
|
+
if (kind !== current)
|
|
38
|
+
onChange(kind);
|
|
39
|
+
},
|
|
40
|
+
})) })] }));
|
|
60
41
|
}
|
|
@@ -41,8 +41,8 @@ export type GridCellEditorContext<Row> = {
|
|
|
41
41
|
onEnter: () => void;
|
|
42
42
|
};
|
|
43
43
|
/**
|
|
44
|
-
* The INLINE editors — the ones that replace the cell's own content while open,
|
|
45
|
-
* reads Escape's rule by, and whether it opened the value list.
|
|
44
|
+
* The INLINE editors — the ones that replace the cell's own content while open (a number, a text typed in its cell),
|
|
45
|
+
* under the field type their session reads Escape's rule by, and whether it opened the value list.
|
|
46
46
|
*
|
|
47
47
|
* Its inner editor renders nothing for every other case so the caller can fall through to the
|
|
48
48
|
* cell's normal render. In particular `text` is matched explicitly, never as a
|
|
@@ -46,7 +46,7 @@ function InlineEditor({ ctx }) {
|
|
|
46
46
|
const { row, rowId, col, baseline, onCommitCell, onCancel, onTab, onEnter } = ctx;
|
|
47
47
|
const region = col.region?.(row);
|
|
48
48
|
const refusal = useCellRefusal(col, ctx.listConfig, region, row);
|
|
49
|
-
const
|
|
49
|
+
const writable = !ctx.readOnly;
|
|
50
50
|
if (ctx.editorKind === "number") {
|
|
51
51
|
const integer = col.field ? isIntegerField(col.field) : false;
|
|
52
52
|
const fallback = col.field ? numberEditDecimals(col.field) : (col.format?.decimals ?? 2);
|
|
@@ -55,14 +55,10 @@ function InlineEditor({ ctx }) {
|
|
|
55
55
|
const valueType = valueTypeOf(field);
|
|
56
56
|
return (_jsx(GridNumberEditor, { title: col.header, initial: numberEditInitial(baseline), seed: ctx.editSeed ?? undefined, unit: col.editUnit?.value(row), unitOptions: col.editUnit?.options, code: col.editUnit ? undefined : numberEditCode(field), type: valueType === "currency" || valueType === "percent" ? valueType : "number", bounds: numberBounds(field), decimals: integer ? 0 : (ctx.decimals ?? fallback), durationUnit: durationUnit, allowEmpty: !!col.clearable, unitLeft: col.align === "right", conversion: convertedFromOf(col, row) ? renderTypedCellValue(col, row, { decimals: ctx.decimals }) : undefined, refuse: (payload) => refusal(payload, cellPrevPayload(col, baseline, col.editUnit?.value(row))), onCommit: (payload) => onCommitCell(row, rowId, col.id, cellPrevPayload(col, baseline, col.editUnit?.value(row)), payload, { overlay: gridFigureDrawsAtOnce(col, row, payload) ? "figure" : false }), onCancel: onCancel, onTab: onTab, onEnter: onEnter }));
|
|
57
57
|
}
|
|
58
|
-
if (ctx.editorKind === "
|
|
59
|
-
const def = col.field?.type === "range" ? col.field : undefined;
|
|
60
|
-
return (_jsx(GridRangeEditor, { title: col.header, initial: isRangeValue(baseline) ? baseline : null, seed: ctx.editSeed ?? undefined, decimals: def ? rangeDecimals(def) : 0, allowEmpty: !!col.clearable, suffix: def?.of === "percent" ? "%" : def?.of === "currency" ? def.code?.fixed : undefined, bands: def?.presets, bounds: def ? numberBounds(def) : undefined, refuse: (payload) => refusal(payload, baseline), onCommit: (payload) => onCommitCell(row, rowId, col.id, baseline, payload, { overlay: false }), onCancel: onCancel, onTab: onTab, onEnter: onEnter }));
|
|
61
|
-
}
|
|
62
|
-
if (ctx.editorKind === "text" && !gridTextOpensBox(col, !!ctx.whole, inCell)) {
|
|
58
|
+
if (ctx.editorKind === "text" && !gridTextOpensBox(col, !!ctx.whole, writable)) {
|
|
63
59
|
const phone = col.type === "phone";
|
|
64
60
|
const stored = phone ? phoneText(baseline, null) : String(baseline ?? "");
|
|
65
|
-
return (_jsx(GridTextEditor, { initial: stored, seed: ctx.editSeed ?? undefined, type: gridTextEditorType(col.type), paragraph: isLongTextColumn(col), region: region ?? undefined, title: col.header,
|
|
61
|
+
return (_jsx(GridTextEditor, { initial: stored, seed: ctx.editSeed ?? undefined, type: gridTextEditorType(col.type), paragraph: isLongTextColumn(col), region: region ?? undefined, title: col.header, open: isOpenableType(col.type) && baseline != null && baseline !== ""
|
|
66
62
|
? { type: col.type, value: baseline }
|
|
67
63
|
: undefined, refuse: (value) => refusal(value, phone ? baseline : stored), onCommit: (value) => onCommitCell(row, rowId, col.id, phone ? baseline : stored, value), onCancel: onCancel, onTab: onTab, onEnter: onEnter }));
|
|
68
64
|
}
|
|
@@ -75,12 +71,12 @@ function AnchoredEditor({ ctx }) {
|
|
|
75
71
|
const { row, rowId, col, baseline, onCommitCell, onCancel } = ctx;
|
|
76
72
|
const region = col.region?.(row);
|
|
77
73
|
const refusal = useCellRefusal(col, ctx.listConfig, region, row);
|
|
78
|
-
const { messages
|
|
79
|
-
const
|
|
74
|
+
const { messages } = useViews();
|
|
75
|
+
const writable = !ctx.readOnly;
|
|
80
76
|
const relationSource = useMemo(() => gridRelationSource(col, ctx.entityIcon), [col, ctx.entityIcon]);
|
|
81
|
-
if (ctx.editorKind === "text" && gridTextOpensBox(col, !!ctx.whole,
|
|
77
|
+
if (ctx.editorKind === "text" && gridTextOpensBox(col, !!ctx.whole, writable)) {
|
|
82
78
|
const paragraph = isLongTextColumn(col);
|
|
83
|
-
return (_jsx(GridLongTextEditor, { paragraph: paragraph, type: paragraph ? undefined : gridTextEditorType(col.type), initial: String(baseline ?? ""),
|
|
79
|
+
return (_jsx(GridLongTextEditor, { paragraph: paragraph, type: paragraph ? undefined : gridTextEditorType(col.type), initial: String(baseline ?? ""), markdown: col.type === "rich_text", title: col.header, onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
84
80
|
}
|
|
85
81
|
if (ctx.editorKind === "select") {
|
|
86
82
|
return (_jsx(GridSelectEditor, { column: col, title: col.header, values: ctx.selectValues ?? (col.options ?? []).map((o) => o.value), current: String(baseline ?? ""), clearable: !!col.clearable, seed: ctx.editSeed ?? undefined, openedByKey: !!ctx.byKey, optionColors: ctx.optionColors, refuse: (value) => refusal(value, String(baseline ?? "")), onCommit: (value) => onCommitCell(row, rowId, col.id, String(baseline ?? ""), value), onCancel: onCancel }));
|
|
@@ -106,6 +102,10 @@ function AnchoredEditor({ ctx }) {
|
|
|
106
102
|
if (ctx.editorKind === "name") {
|
|
107
103
|
return (_jsx(GridNameEditor, { title: col.header, initial: isNameValue(baseline) ? baseline : null, seed: ctx.editSeed ?? undefined, allowEmpty: !!col.clearable, onCommit: (payload) => onCommitCell(row, rowId, col.id, baseline, payload, { overlay: false }), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
108
104
|
}
|
|
105
|
+
if (ctx.editorKind === "range") {
|
|
106
|
+
const def = col.field?.type === "range" ? col.field : undefined;
|
|
107
|
+
return (_jsx(GridRangeEditor, { title: col.header, initial: isRangeValue(baseline) ? baseline : null, seed: ctx.editSeed ?? undefined, decimals: def ? rangeDecimals(def) : 0, allowEmpty: !!col.clearable, suffix: def?.of === "percent" ? "%" : def?.of === "currency" ? def.code?.fixed : undefined, bands: def?.presets, refuse: (payload) => refusal(payload, baseline), onCommit: (payload) => onCommitCell(row, rowId, col.id, baseline, payload, { overlay: false }), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
108
|
+
}
|
|
109
109
|
if (ctx.editorKind === "values" && col.field && isMultipleType(col.field.type) && !col.multiple) {
|
|
110
110
|
const stored = String(baseline ?? "");
|
|
111
111
|
return (_jsx(GridValueListEditor, { field: col.field, title: col.header, initial: baseline, labels: false, region: region, holds: "one", seed: ctx.editSeed ?? undefined, allowEmpty: true, refuse: (value) => refusal(value, stored), onCommit: (value) => onCommitCell(row, rowId, col.id, stored, value), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
@@ -119,7 +119,7 @@ function AnchoredEditor({ ctx }) {
|
|
|
119
119
|
const initial = baseline && typeof baseline === "object" && !Array.isArray(baseline)
|
|
120
120
|
? baseline
|
|
121
121
|
: null;
|
|
122
|
-
return (_jsx(GridPlaceEditor, { field: col.field, title: col.header, initial: initial,
|
|
122
|
+
return (_jsx(GridPlaceEditor, { field: col.field, title: col.header, initial: initial, refuse: (place) => place === null && !gridColumnEffectiveClearable(col, ctx.listConfig)
|
|
123
123
|
? gridClearRefusal(col, ctx.listConfig, messages)
|
|
124
124
|
: refusal(place, baseline), onCommit: (place) => onCommitCell(row, rowId, col.id, baseline, place, { overlay: false }), onCancel: onCancel, onTab: ctx.onTab, onEnter: ctx.onEnter }));
|
|
125
125
|
}
|
|
@@ -8,13 +8,13 @@ import { prettifyOptionValue } from "../../model/column-state.js";
|
|
|
8
8
|
import { optionValues } from "viewkitjs/fields";
|
|
9
9
|
import { offeredValues, takesNewValues, useOpenValues } from "../../editors/open-values.js";
|
|
10
10
|
import { useGridEditSession } from "./grid-edit-session.js";
|
|
11
|
-
import {
|
|
11
|
+
import { bodyPanel } from "../../editors/body-panel.js";
|
|
12
12
|
import { useGridBodyPlace } from "./grid-body-place.js";
|
|
13
13
|
export function GridChipsEditor({ column, title, values, suggestions, optionColors, seed, refuse, onCommit, onCancel, onTab, }) {
|
|
14
|
-
const panel =
|
|
14
|
+
const panel = bodyPanel("picker", "z-90");
|
|
15
15
|
const editorRef = useRef(null);
|
|
16
16
|
const anchorRef = useRef(null);
|
|
17
|
-
const place = useGridBodyPlace(
|
|
17
|
+
const place = useGridBodyPlace(anchorRef);
|
|
18
18
|
const { session, close } = useGridEditSession({
|
|
19
19
|
editorRef,
|
|
20
20
|
refuse: refuse && ((value) => refuse(value)),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type MouseEvent as ReactMouseEvent, type ReactElement, type
|
|
1
|
+
import { type MouseEvent as ReactMouseEvent, type ReactElement, type Ref } from "react";
|
|
2
2
|
import type { PercentDisplay } from "viewkitjs/fields";
|
|
3
3
|
import type { SortDirection } from "viewkitjs/fields/query";
|
|
4
4
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
@@ -10,7 +10,7 @@ type TriggerProps = {
|
|
|
10
10
|
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
|
|
11
11
|
onPointerDownCapture?: () => void;
|
|
12
12
|
role?: "button" | "columnheader";
|
|
13
|
-
"aria-haspopup"?: "
|
|
13
|
+
"aria-haspopup"?: "menu";
|
|
14
14
|
"aria-expanded"?: boolean;
|
|
15
15
|
/** The contract's `open` state: present while the menu is open. */
|
|
16
16
|
"data-open"?: "";
|
|
@@ -33,7 +33,7 @@ export type GridGroupByState = {
|
|
|
33
33
|
};
|
|
34
34
|
/** The cheap OUTER gate: action columns declare "no header menu knobs" by
|
|
35
35
|
* contract, so they never get one. Everything else may — whether it actually
|
|
36
|
-
* does is `
|
|
36
|
+
* does is `offers` inside the component, which is the only place that knows
|
|
37
37
|
* every per-knob gate. Two levels because this one runs per header cell per
|
|
38
38
|
* render and the other needs the full prop set. */
|
|
39
39
|
export declare function gridColumnMenuEnabled<Row>(col: ListColumn<Row>): boolean;
|
|
@@ -51,19 +51,20 @@ export declare function gridColumnMenuEnabled<Row>(col: ListColumn<Row>): boolea
|
|
|
51
51
|
* - The knobs are `columnKnobs`' answer — the same one the Columns drill-in
|
|
52
52
|
* reads, so the two doors cannot disagree. Every knob writes under the
|
|
53
53
|
* FIELD key: it is the workspace's setting for the field, shared by every
|
|
54
|
-
* surface that draws it. Each knob is ONE row
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* of every setting.
|
|
54
|
+
* surface that draws it. Each knob is ONE group row whose choices open
|
|
55
|
+
* beside the menu, so a money column's menu is a short list of settings,
|
|
56
|
+
* not every choice of every setting.
|
|
58
57
|
* - Move left / right swap with the visible neighbour; hide is last.
|
|
59
58
|
* - The host's rows for this column's field (a field editor's Edit field,
|
|
60
|
-
* Archive field) sit just above hide (`
|
|
59
|
+
* Archive field) sit just above hide (`columnMenuItems`).
|
|
60
|
+
*
|
|
61
|
+
* The menu is the app's `Menu`, handed these rows as data (`gridColumnMenuItems`).
|
|
61
62
|
*
|
|
62
63
|
* No admin block: a lock is the workspace's rule about who may WRITE a field,
|
|
63
64
|
* and it lives in Settings → Modules → Tables and the Columns drill-in, not
|
|
64
65
|
* beside the knobs about how the field READS.
|
|
65
66
|
*/
|
|
66
|
-
export declare function GridColumnMenu<Row>({ column, values, viewBacked, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable,
|
|
67
|
+
export declare function GridColumnMenu<Row>({ column, values, viewBacked, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable, columnMenuItems, open: heldOpen, onOpenChange, children, }: {
|
|
67
68
|
column: ListColumn<Row>;
|
|
68
69
|
/** Distinct option values for select columns (declared + discovered), in display order. */
|
|
69
70
|
values: string[];
|
|
@@ -97,9 +98,7 @@ export declare function GridColumnMenu<Row>({ column, values, viewBacked, sort,
|
|
|
97
98
|
onHide?: () => void;
|
|
98
99
|
/** Whether a format knob can be stored; the reader's own currency reading stays either way. */
|
|
99
100
|
formatsWritable?: boolean;
|
|
100
|
-
/** The host's rows for this column's field, above Hide; null
|
|
101
|
-
renderColumnMenuRows?: (fieldKey: string, close: () => void) => ReactNode;
|
|
102
|
-
/** The host's rows for this column's field as data, on the `menu` route; null or empty for none. */
|
|
101
|
+
/** The host's rows for this column's field as data, above Hide; null or empty for none. */
|
|
103
102
|
columnMenuItems?: (fieldKey: string) => ViewsMenuItem[] | null;
|
|
104
103
|
/** Open as the app holds it (`openColumnMenu`): a person's press then only tells `onOpenChange`. Absent: the menu
|
|
105
104
|
* holds its own. */
|
|
@@ -2,24 +2,15 @@
|
|
|
2
2
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cloneElement, use, useState, } from "react";
|
|
4
4
|
import { columnLabel } from "../../model/column-capabilities.js";
|
|
5
|
-
import { columnKnobs } from "../../model/column-knobs.js";
|
|
6
5
|
import { cellFormatAt, useUndatedCellFormat } from "../../cells/use-cell-format.js";
|
|
7
6
|
import { useViews } from "../../provider/context.js";
|
|
8
7
|
import { MomentContext } from "../../provider/moment.js";
|
|
9
|
-
import { columnMenuGates, gridColumnMenuItems } from "./grid-column-menu-items.js";
|
|
10
|
-
import {
|
|
11
|
-
import { GridColumnDateSection } from "./GridColumnDateSection.js";
|
|
12
|
-
import { GridColumnDurationSection } from "./GridColumnDurationSection.js";
|
|
13
|
-
import { GridColumnNumberSection } from "./GridColumnNumberSection.js";
|
|
14
|
-
import { GridColumnPercentSection } from "./GridColumnPercentSection.js";
|
|
15
|
-
import { GridColumnSortPartsSection, GridColumnSortSection } from "./GridColumnSortSection.js";
|
|
16
|
-
import { insideGridFlyout, useGridFlyouts } from "./GridFlyout.js";
|
|
17
|
-
import { GridMenuRow, GridMenuSeparator } from "./GridMenuRow.js";
|
|
18
|
-
import { gridMenuArrows, useGridMenuFocus, useGridMenuPress } from "./grid-menu-focus.js";
|
|
8
|
+
import { columnMenuGates, gridColumnMenuItems, } from "./grid-column-menu-items.js";
|
|
9
|
+
import { useGridMenuFocus, useGridMenuPress } from "./grid-menu-focus.js";
|
|
19
10
|
export function gridColumnMenuEnabled(col) {
|
|
20
11
|
return !col.actions;
|
|
21
12
|
}
|
|
22
|
-
export function GridColumnMenu({ column, values, viewBacked = false, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable = true,
|
|
13
|
+
export function GridColumnMenu({ column, values, viewBacked = false, sort, groupBy, optionColors, onOptionColorChange, dateStyle, onDateStyleChange, durationStyle, onDurationStyleChange, showTime, onShowTimeChange, percentDisplay, onPercentDisplayChange, numberFormat, onNumberFormatChange, onMoveLeft, onMoveRight, onHide, formatsWritable = true, columnMenuItems, open: heldOpen, onOpenChange, children, }) {
|
|
23
14
|
const [ownOpen, setOwnOpen] = useState(false);
|
|
24
15
|
const open = heldOpen ?? ownOpen;
|
|
25
16
|
const setOpen = (next) => {
|
|
@@ -27,15 +18,13 @@ export function GridColumnMenu({ column, values, viewBacked = false, sort, group
|
|
|
27
18
|
if (heldOpen === undefined)
|
|
28
19
|
setOwnOpen(next);
|
|
29
20
|
};
|
|
30
|
-
const flyouts = useGridFlyouts();
|
|
31
21
|
const [anchor, setAnchor] = useState(null);
|
|
32
|
-
|
|
22
|
+
useGridMenuFocus(open, anchor);
|
|
33
23
|
const press = useGridMenuPress(open);
|
|
34
24
|
const cellFormat = useUndatedCellFormat();
|
|
35
25
|
const moment = open ? use(MomentContext) : null;
|
|
36
|
-
const {
|
|
37
|
-
const {
|
|
38
|
-
const { List } = atoms;
|
|
26
|
+
const { components, icons, messages } = useViews();
|
|
27
|
+
const { Menu } = components;
|
|
39
28
|
const offer = {
|
|
40
29
|
values,
|
|
41
30
|
viewBacked,
|
|
@@ -52,100 +41,50 @@ export function GridColumnMenu({ column, values, viewBacked = false, sort, group
|
|
|
52
41
|
onMoveRight,
|
|
53
42
|
};
|
|
54
43
|
const gates = columnMenuGates(column, offer);
|
|
55
|
-
const { key,
|
|
56
|
-
const
|
|
57
|
-
const knobs = columnKnobs(column);
|
|
58
|
-
const close = () => {
|
|
59
|
-
flyouts.close();
|
|
60
|
-
setOpen(false);
|
|
61
|
-
};
|
|
44
|
+
const { key, sortable, groupable, canPercent, canDate, canDuration, canDecimals, canCurrency, canColor, canMove, } = gates;
|
|
45
|
+
const close = () => setOpen(false);
|
|
62
46
|
const handleOpenChange = (next) => (next ? setOpen(true) : close());
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const offers = sortable ||
|
|
66
|
-
groupable ||
|
|
67
|
-
canPercent ||
|
|
68
|
-
canDate ||
|
|
69
|
-
canDuration ||
|
|
70
|
-
canDecimals ||
|
|
71
|
-
(canCurrency && (numberFormat?.currencyOptions?.length ?? 0) > 0) ||
|
|
72
|
-
canColor ||
|
|
73
|
-
canMove ||
|
|
74
|
-
(appItems?.length ?? 0) > 0 ||
|
|
75
|
-
!!onHide;
|
|
76
|
-
if (!offers)
|
|
77
|
-
return _jsx(_Fragment, { children: children });
|
|
78
|
-
const items = open
|
|
79
|
-
? gridColumnMenuItems(column, { ...offer, optionColors, dateStyle, showTime, durationStyle, percentDisplay, numberFormat, onHide, appItems }, gates, { messages, icons, cellFormat: cellFormatAt(cellFormat, moment), close })
|
|
80
|
-
: [];
|
|
81
|
-
const menuTrigger = cloneElement(children, {
|
|
82
|
-
ref: setAnchor,
|
|
83
|
-
onPointerDownCapture: press.notePress,
|
|
84
|
-
onClick: (event) => {
|
|
85
|
-
children.props.onClick?.(event);
|
|
86
|
-
if (press.pressedOpen(event) || open)
|
|
87
|
-
close();
|
|
88
|
-
else {
|
|
89
|
-
menuFocus.noteOpen(event);
|
|
90
|
-
setOpen(true);
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
role: children.props.role ?? "button",
|
|
94
|
-
"aria-haspopup": "menu",
|
|
95
|
-
"aria-expanded": open,
|
|
96
|
-
"data-open": open ? "" : undefined,
|
|
97
|
-
});
|
|
98
|
-
return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: handleOpenChange, anchor: anchor, side: "bottom", align: "start", label: messages({ key: "views.menus.column-menu", values: { field: columnLabel(column) } }), items: items })] }));
|
|
99
|
-
}
|
|
100
|
-
const editorRows = renderColumnMenuRows?.(key, close) ?? null;
|
|
101
|
-
const hasContent = sortable ||
|
|
47
|
+
const appItems = columnMenuItems?.(key) ?? null;
|
|
48
|
+
const offers = sortable ||
|
|
102
49
|
groupable ||
|
|
103
50
|
canPercent ||
|
|
104
51
|
canDate ||
|
|
105
52
|
canDuration ||
|
|
106
53
|
canDecimals ||
|
|
107
|
-
canCurrency ||
|
|
54
|
+
(canCurrency && (numberFormat?.currencyOptions?.length ?? 0) > 0) ||
|
|
108
55
|
canColor ||
|
|
109
56
|
canMove ||
|
|
110
|
-
|
|
57
|
+
(appItems?.length ?? 0) > 0 ||
|
|
111
58
|
!!onHide;
|
|
112
|
-
if (!
|
|
59
|
+
if (!offers)
|
|
113
60
|
return _jsx(_Fragment, { children: children });
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
|
|
61
|
+
const items = open
|
|
62
|
+
? gridColumnMenuItems(column, {
|
|
63
|
+
...offer,
|
|
64
|
+
optionColors,
|
|
65
|
+
dateStyle,
|
|
66
|
+
showTime,
|
|
67
|
+
durationStyle,
|
|
68
|
+
percentDisplay,
|
|
69
|
+
numberFormat,
|
|
70
|
+
onHide,
|
|
71
|
+
appItems,
|
|
72
|
+
}, gates, { messages, icons, cellFormat: cellFormatAt(cellFormat, moment), close })
|
|
73
|
+
: [];
|
|
74
|
+
const menuTrigger = cloneElement(children, {
|
|
117
75
|
ref: setAnchor,
|
|
76
|
+
onPointerDownCapture: press.notePress,
|
|
118
77
|
onClick: (event) => {
|
|
119
78
|
children.props.onClick?.(event);
|
|
120
|
-
if (open)
|
|
79
|
+
if (press.pressedOpen(event) || open)
|
|
121
80
|
close();
|
|
122
|
-
else
|
|
123
|
-
menuFocus.noteOpen(event);
|
|
81
|
+
else
|
|
124
82
|
setOpen(true);
|
|
125
|
-
}
|
|
126
83
|
},
|
|
127
84
|
role: children.props.role ?? "button",
|
|
128
|
-
"aria-haspopup": "
|
|
85
|
+
"aria-haspopup": "menu",
|
|
129
86
|
"aria-expanded": open,
|
|
130
87
|
"data-open": open ? "" : undefined,
|
|
131
88
|
});
|
|
132
|
-
return (_jsxs(_Fragment, { children: [
|
|
133
|
-
groupBy.onChange(null);
|
|
134
|
-
close();
|
|
135
|
-
} })) : (_jsx(GridMenuRow, { label: messages({
|
|
136
|
-
key: "views.menus.group-by",
|
|
137
|
-
values: { field: columnLabel(column) },
|
|
138
|
-
}), icon: "group", onClick: () => {
|
|
139
|
-
groupBy.onChange(column.field.key);
|
|
140
|
-
close();
|
|
141
|
-
} }))] })), canKnobs && divider(2), canPercent && (_jsx(GridColumnPercentSection, { column: column, fieldKey: key, percentDisplay: percentDisplay, onPercentDisplayChange: onPercentDisplayChange, flyouts: flyouts, onClose: close })), canDate && (_jsx(GridColumnDateSection, { column: column, dateStyle: dateStyle, onDateStyleChange: onDateStyleChange, showTime: showTime, onShowTimeChange: knobs.has("showTime") ? onShowTimeChange : undefined, flyouts: flyouts, onClose: close })), canDuration && (_jsx(GridColumnDurationSection, { column: column, durationStyle: durationStyle, onDurationStyleChange: onDurationStyleChange, flyouts: flyouts, onClose: close })), (canDecimals || canCurrency) && (_jsx(GridColumnNumberSection, { column: column, fieldKey: key, decimals: canDecimals, currency: canCurrency, numberFormat: numberFormat, onNumberFormatChange: onNumberFormatChange, flyouts: flyouts, onClose: close })), canColor && (_jsxs(_Fragment, { children: [divider(3), _jsx(GridColumnColorSection, { column: column, values: values, optionColors: optionColors, flyouts: flyouts, onOptionColorChange: onOptionColorChange, onClose: close })] })), canMove && (_jsxs(_Fragment, { children: [divider(4), onMoveLeft && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.move-left" }), icon: "moveLeft", onClick: () => {
|
|
142
|
-
onMoveLeft();
|
|
143
|
-
close();
|
|
144
|
-
} })), onMoveRight && (_jsx(GridMenuRow, { label: messages({ key: "views.menus.move-right" }), icon: "moveRight", onClick: () => {
|
|
145
|
-
onMoveRight();
|
|
146
|
-
close();
|
|
147
|
-
} }))] })), editorRows && (_jsxs(_Fragment, { children: [divider(5), editorRows] })), onHide && (_jsxs(_Fragment, { children: [divider(6), _jsx(GridMenuRow, { label: messages({ key: "views.menus.hide-column" }), icon: "hide", onClick: () => {
|
|
148
|
-
onHide();
|
|
149
|
-
close();
|
|
150
|
-
} })] }))] }) }) })] }));
|
|
89
|
+
return (_jsxs(_Fragment, { children: [menuTrigger, _jsx(Menu, { open: open, onOpenChange: handleOpenChange, anchor: anchor, side: "bottom", align: "start", label: messages({ key: "views.menus.column-menu", values: { field: columnLabel(column) } }), items: items })] }));
|
|
151
90
|
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
3
|
-
/** A column whose kind is a day but whose editor has a time
|
|
3
|
+
/** A column whose kind is a day but whose editor has a time (a `type: "date"` column with no `date` field): its
|
|
4
4
|
* cell shows a day and its app's write keeps the day, so its editor keeps the browser's clock and commits
|
|
5
5
|
* `${day}T${time}` unconverted, as on 0.6.0. */
|
|
6
6
|
export declare function dayColumnKeepsBrowserClock<Row>(col: ListColumn<Row>): boolean;
|
|
7
7
|
/**
|
|
8
|
-
* The GRID's host around the shared `
|
|
8
|
+
* The GRID's host around the shared `DateEditorHost` (`viewkitjs/views/editors/date`) —
|
|
9
9
|
* the editing core is one component across every surface. The edit session owns the
|
|
10
10
|
* one-answer guard and the exit gap, and the core answers what the close means
|
|
11
11
|
* (`resolveClose`); the editor panel opens the popover on a desktop and the sheet on a
|
|
12
12
|
* phone. This host owns the anchor on the cell rect and the payload's shape. Time is
|
|
13
13
|
* present in the payload ("YYYY-MM-DDTHH:MM") unless the column is a calendar-day
|
|
14
|
-
* field (`dayOnly`): then the
|
|
15
|
-
* payload is the day. The column's Show-time setting is display only. A cleared
|
|
14
|
+
* field (`dayOnly`): then the app's date body has no time, a day picked saves, and
|
|
15
|
+
* the payload is the day. The column's Show-time setting is display only. A cleared
|
|
16
16
|
* date commits "", which the app's write maps to its empty value.
|
|
17
17
|
*/
|
|
18
18
|
export declare function GridDateEditor({ title, initial, dayOnly, browserClock, clearable, seed, refuse, onCommit, onCancel, onTab, onEnter, }: {
|
|
@@ -22,11 +22,11 @@ export declare function GridDateEditor({ title, initial, dayOnly, browserClock,
|
|
|
22
22
|
initial?: string;
|
|
23
23
|
/** The column presents a calendar-day field (`date`): the commit is the day
|
|
24
24
|
* alone — the shape the row stores and the write gate judges through
|
|
25
|
-
* `zodFor` — the
|
|
25
|
+
* `zodFor` — the date body has no time, and a day picked saves. */
|
|
26
26
|
dayOnly?: boolean;
|
|
27
27
|
/** The panel keeps the browser's clock rather than the conventions' zone (`dayColumnKeepsBrowserClock`). Default false. */
|
|
28
28
|
browserClock?: boolean;
|
|
29
|
-
/** The column may be emptied: the
|
|
29
|
+
/** The column may be emptied: the date body offers No date, which commits "". */
|
|
30
30
|
clearable?: boolean;
|
|
31
31
|
/** The character typed on the cell that opened the editor: the date box starts with it. */
|
|
32
32
|
seed?: string;
|