@viewkitjs/views 0.3.0 → 0.5.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 +641 -0
- package/README.md +3 -3
- package/dist/atoms/CommandMenu.d.ts +1 -1
- package/dist/atoms/CommandMenu.js +7 -3
- package/dist/atoms/DrillRows.d.ts +3 -0
- package/dist/atoms/DrillRows.js +25 -0
- package/dist/atoms/PanelRows.d.ts +5 -0
- package/dist/atoms/PanelRows.js +40 -0
- package/dist/atoms/PanelSearch.d.ts +2 -0
- package/dist/atoms/PanelSearch.js +21 -0
- package/dist/atoms/RelationRoles.d.ts +2 -0
- package/dist/atoms/RelationRoles.js +6 -0
- package/dist/atoms/Row.js +2 -1
- package/dist/atoms/RowMenu.js +2 -1
- package/dist/atoms/SelectionSheet.d.ts +3 -0
- package/dist/atoms/SelectionSheet.js +30 -0
- package/dist/atoms/StatusMarker.js +3 -1
- package/dist/atoms/Tag.js +2 -1
- package/dist/atoms/defaults.js +14 -0
- package/dist/atoms/types.d.ts +146 -8
- package/dist/cells/cell-values.js +4 -2
- package/dist/cells/relation-wrap.js +3 -1
- package/dist/contract.d.ts +212 -17
- package/dist/contract.js +208 -6
- package/dist/display/boolean.js +3 -1
- package/dist/display/date.d.ts +1 -1
- package/dist/display/date.js +4 -2
- package/dist/display/format.js +20 -4
- package/dist/display/link.js +4 -3
- package/dist/display/multi-value.js +2 -1
- package/dist/display/percent.js +2 -1
- package/dist/display/phone.js +2 -1
- package/dist/display/range.js +3 -13
- package/dist/display/relation.js +23 -8
- package/dist/display/rich-text.js +2 -1
- package/dist/editors/ChipsEditor.d.ts +5 -1
- package/dist/editors/ChipsEditor.js +15 -2
- package/dist/editors/DateEditor.d.ts +2 -0
- package/dist/editors/DateEditor.js +76 -10
- package/dist/editors/EditorPanel.d.ts +14 -4
- package/dist/editors/EditorPanel.js +21 -4
- package/dist/editors/LocationEditor.js +35 -3
- package/dist/editors/NumberEditor.js +3 -2
- package/dist/editors/RangeEditor.d.ts +8 -0
- package/dist/editors/RangeEditor.js +3 -2
- package/dist/editors/RelationEditor.d.ts +2 -0
- package/dist/editors/RelationEditor.js +16 -2
- package/dist/editors/RelationSetEditor.d.ts +4 -2
- package/dist/editors/RelationSetEditor.js +36 -2
- package/dist/editors/SelectEditor.d.ts +5 -2
- package/dist/editors/SelectEditor.js +31 -4
- package/dist/editors/TextEditor.js +3 -1
- package/dist/editors/ValueListEditor.d.ts +3 -0
- package/dist/editors/ValueListEditor.js +10 -4
- package/dist/editors/edit-session.d.ts +14 -2
- package/dist/editors/edit-session.js +13 -5
- package/dist/editors/escape-rule.d.ts +12 -0
- package/dist/editors/escape-rule.js +8 -0
- package/dist/editors/open-value.js +2 -1
- package/dist/editors/picker-slot.d.ts +25 -0
- package/dist/editors/picker-slot.js +37 -0
- package/dist/editors/relation-picker.d.ts +44 -0
- package/dist/editors/relation-picker.js +49 -0
- package/dist/editors/relation-source.d.ts +1 -0
- package/dist/editors/relation-source.js +7 -1
- package/dist/field-row/FieldNoteLine.js +2 -1
- package/dist/field-row/FieldRow.js +41 -6
- package/dist/field-row/FieldRowLane.js +3 -1
- package/dist/field-row/editors/RowChipsEditor.js +1 -1
- package/dist/field-row/editors/RowDateEditor.js +1 -1
- package/dist/field-row/editors/RowEditor.js +2 -1
- package/dist/field-row/editors/RowRangeEditor.js +2 -1
- package/dist/field-row/editors/RowRelationEditor.js +2 -2
- package/dist/field-row/editors/RowSelectEditor.d.ts +1 -1
- package/dist/field-row/editors/RowSelectEditor.js +2 -2
- package/dist/field-row/editors/RowValueListEditor.js +1 -1
- package/dist/field-row/editors/host.d.ts +3 -0
- package/dist/field-row/editors/row-session.js +4 -1
- package/dist/fields/menus.d.ts +2 -0
- package/dist/fields/range-unit.d.ts +7 -0
- package/dist/fields/range-unit.js +13 -0
- package/dist/figures.d.ts +5 -48
- package/dist/figures.js +1 -63
- package/dist/grid/chrome/GridAddColumn.d.ts +8 -0
- package/dist/grid/chrome/GridAddColumn.js +66 -9
- package/dist/grid/chrome/GridAggregateMenu.d.ts +5 -2
- package/dist/grid/chrome/GridAggregateMenu.js +33 -4
- package/dist/grid/chrome/GridCellEditors.d.ts +9 -2
- package/dist/grid/chrome/GridCellEditors.js +24 -5
- package/dist/grid/chrome/GridCellOutline.d.ts +3 -2
- package/dist/grid/chrome/GridCellOutline.js +11 -1
- package/dist/grid/chrome/GridChipsEditor.js +1 -1
- package/dist/grid/chrome/GridColumnColorSection.d.ts +2 -0
- package/dist/grid/chrome/GridColumnColorSection.js +2 -2
- package/dist/grid/chrome/GridColumnDateSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnDateSection.js +2 -2
- package/dist/grid/chrome/GridColumnDurationSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnDurationSection.js +2 -2
- package/dist/grid/chrome/GridColumnMenu.d.ts +10 -6
- package/dist/grid/chrome/GridColumnMenu.js +62 -24
- package/dist/grid/chrome/GridColumnNumberSection.d.ts +4 -0
- package/dist/grid/chrome/GridColumnNumberSection.js +2 -2
- package/dist/grid/chrome/GridColumnPercentSection.d.ts +1 -0
- package/dist/grid/chrome/GridColumnPercentSection.js +1 -1
- package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
- package/dist/grid/chrome/GridDateEditor.js +1 -1
- package/dist/grid/chrome/GridFooter.js +7 -48
- package/dist/grid/chrome/GridGroupMenu.d.ts +11 -5
- package/dist/grid/chrome/GridGroupMenu.js +28 -13
- package/dist/grid/chrome/GridHeader.d.ts +3 -1
- package/dist/grid/chrome/GridHeader.js +8 -8
- package/dist/grid/chrome/GridNumberEditor.js +3 -24
- package/dist/grid/chrome/GridRangeEditor.js +3 -2
- package/dist/grid/chrome/GridRelationEditor.js +2 -2
- package/dist/grid/chrome/GridRow.d.ts +2 -1
- package/dist/grid/chrome/GridRow.js +13 -37
- package/dist/grid/chrome/GridRowActions.js +2 -1
- package/dist/grid/chrome/GridRowCells.js +9 -4
- package/dist/grid/chrome/GridSelectEditor.js +30 -20
- package/dist/grid/chrome/GridStructure.d.ts +11 -4
- package/dist/grid/chrome/GridStructure.js +19 -7
- package/dist/grid/chrome/GridTable.js +138 -16
- package/dist/grid/chrome/GridTableSurface.d.ts +25 -12
- package/dist/grid/chrome/GridTableSurface.js +13 -6
- package/dist/grid/chrome/GridTextEditor.js +3 -1
- package/dist/grid/chrome/GridValueListEditor.js +1 -1
- package/dist/grid/chrome/cell-clipboard.d.ts +1 -1
- package/dist/grid/chrome/cell-clipboard.js +1 -1
- package/dist/grid/chrome/checks.d.ts +10 -2
- package/dist/grid/chrome/checks.js +17 -11
- package/dist/grid/chrome/column-glyph.d.ts +2 -2
- package/dist/grid/chrome/column-glyph.js +4 -0
- package/dist/grid/chrome/grid-add-column-items.d.ts +13 -0
- package/dist/grid/chrome/grid-add-column-items.js +40 -0
- package/dist/grid/chrome/grid-cell-classes.d.ts +2 -0
- package/dist/grid/chrome/grid-cell-classes.js +10 -4
- package/dist/grid/chrome/grid-column-menu-items.d.ts +75 -0
- package/dist/grid/chrome/grid-column-menu-items.js +263 -0
- package/dist/grid/chrome/grid-edit-escape.d.ts +4 -0
- package/dist/grid/chrome/grid-edit-escape.js +12 -0
- package/dist/grid/chrome/grid-edit-session.d.ts +2 -1
- package/dist/grid/chrome/grid-edit-session.js +14 -1
- package/dist/grid/chrome/grid-figure-value.d.ts +25 -0
- package/dist/grid/chrome/grid-figure-value.js +40 -0
- package/dist/grid/chrome/grid-fitted-box.d.ts +15 -0
- package/dist/grid/chrome/grid-fitted-box.js +26 -0
- package/dist/grid/chrome/grid-group-menu-items.d.ts +31 -0
- package/dist/grid/chrome/grid-group-menu-items.js +75 -0
- package/dist/grid/chrome/grid-group-menu-parts.d.ts +27 -0
- package/dist/grid/chrome/grid-group-menu-parts.js +19 -0
- package/dist/grid/chrome/grid-hover.d.ts +1 -0
- package/dist/grid/chrome/grid-hover.js +13 -1
- package/dist/grid/chrome/grid-lab.d.ts +7 -0
- package/dist/grid/chrome/grid-lab.js +7 -0
- package/dist/grid/chrome/grid-menu-focus.d.ts +12 -0
- package/dist/grid/chrome/grid-menu-focus.js +13 -0
- package/dist/grid/chrome/{useGridRowContextMenu.d.ts → grid-row-menu-items.d.ts} +15 -4
- package/dist/grid/chrome/{useGridRowContextMenu.js → grid-row-menu-items.js} +15 -18
- package/dist/grid/chrome/grid-row-props.d.ts +3 -1
- package/dist/grid/chrome/grid-row-window.d.ts +15 -5
- package/dist/grid/chrome/grid-row-window.js +44 -10
- package/dist/grid/chrome/grid-rows-menu.d.ts +38 -0
- package/dist/grid/chrome/grid-rows-menu.js +83 -0
- package/dist/grid/chrome/grid-table-props.d.ts +53 -8
- package/dist/grid/chrome/useGridBandFigures.d.ts +26 -0
- package/dist/grid/chrome/useGridBandFigures.js +50 -0
- package/dist/grid/chrome/useGridBoxes.d.ts +22 -0
- package/dist/grid/chrome/useGridBoxes.js +22 -0
- package/dist/grid/chrome/useGridColumnLayout.js +29 -4
- package/dist/grid/chrome/useGridKeyboard.js +7 -2
- package/dist/grid/chrome/useGridPartColumns.d.ts +5 -0
- package/dist/grid/chrome/useGridPartColumns.js +9 -0
- package/dist/grid/chrome/useGridRangeGestures.js +2 -1
- package/dist/grid/chrome/useGridRecorder.d.ts +16 -0
- package/dist/grid/chrome/useGridRecorder.js +144 -0
- package/dist/grid/chrome/useGridRowOpener.d.ts +41 -0
- package/dist/grid/chrome/useGridRowOpener.js +83 -0
- package/dist/grid/chrome/useGridScrollArea.d.ts +38 -12
- package/dist/grid/chrome/useGridScrollArea.js +70 -17
- package/dist/grid/chrome/useGridTableInteractionModel.d.ts +1 -0
- package/dist/grid/chrome/useGridTableInteractionModel.js +67 -9
- package/dist/grid/core/clipboard-model.d.ts +11 -3
- package/dist/grid/core/clipboard-model.js +9 -4
- package/dist/grid/core/commit-model.d.ts +7 -0
- package/dist/grid/core/editing-controller.d.ts +31 -1
- package/dist/grid/core/editing-controller.js +65 -0
- package/dist/grid/core/grid-recorder.d.ts +111 -0
- package/dist/grid/core/grid-recorder.js +223 -0
- package/dist/grid/core/part-edits.d.ts +18 -0
- package/dist/grid/core/part-edits.js +48 -0
- package/dist/grid/core/pending-reconciliation.js +12 -3
- package/dist/grid/core/refusal-sentence.d.ts +3 -0
- package/dist/grid/core/refusal-sentence.js +15 -0
- package/dist/grid/core/row-opened-from.d.ts +21 -0
- package/dist/grid/core/row-opened-from.js +11 -0
- package/dist/grid/core/useGridEditing.d.ts +16 -2
- package/dist/grid/core/useGridEditing.js +10 -4
- package/dist/grid/core/value-equality.d.ts +19 -1
- package/dist/grid/core/value-equality.js +24 -0
- package/dist/grid/index.d.ts +4 -1
- package/dist/grid/index.js +1 -0
- package/dist/grid/useGridTablePrefs.d.ts +1 -1
- package/dist/grid-lab.d.ts +18 -0
- package/dist/grid-lab.js +16 -0
- package/dist/grouping/sort-groups.d.ts +6 -7
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/internal/reset.d.ts +9 -0
- package/dist/internal/reset.js +1 -0
- package/dist/model/aggregates.d.ts +3 -3
- package/dist/model/aggregates.js +17 -71
- package/dist/model/column-capabilities.d.ts +29 -2
- package/dist/model/column-capabilities.js +27 -3
- package/dist/model/column-filters.js +24 -4
- package/dist/model/column-inspect.d.ts +2 -1
- package/dist/model/column-order.d.ts +2 -2
- package/dist/model/column-schema.d.ts +18 -7
- package/dist/model/column-state.d.ts +9 -20
- package/dist/model/column-state.js +1 -4
- package/dist/model/column-types.d.ts +1 -15
- package/dist/model/column-types.js +1 -1
- package/dist/model/part-columns.d.ts +17 -0
- package/dist/model/part-columns.js +67 -0
- package/dist/model/part-rows.d.ts +3 -10
- package/dist/model/part-rows.js +6 -11
- package/dist/model/part-write.d.ts +11 -0
- package/dist/model/part-write.js +52 -0
- package/dist/model/preferences.d.ts +3 -23
- package/dist/model/preferences.js +1 -17
- package/dist/model/prefs-buckets.d.ts +0 -27
- package/dist/model/prefs-buckets.js +1 -1
- package/dist/model/relation-filters.d.ts +0 -1
- package/dist/model/relation-filters.js +1 -1
- package/dist/model/row-icon.d.ts +5 -9
- package/dist/model/view-rules.d.ts +32 -6
- package/dist/model/view-rules.js +101 -21
- package/dist/provider/ViewsProvider.d.ts +22 -2
- package/dist/provider/ViewsProvider.js +21 -2
- package/dist/provider/components.d.ts +197 -9
- package/dist/provider/context.d.ts +12 -1
- package/dist/provider/desktop.d.ts +3 -0
- package/dist/provider/desktop.js +7 -4
- package/dist/provider/menu-groups.d.ts +3 -2
- package/dist/provider/menu-groups.js +13 -7
- package/dist/provider/missing-slot.d.ts +10 -0
- package/dist/provider/missing-slot.js +15 -0
- package/dist/provider/plain-input.d.ts +3 -2
- package/dist/provider/plain-input.js +3 -1
- package/dist/react.d.ts +3 -2
- package/dist/selection/SelectionBar.d.ts +18 -0
- package/dist/selection/SelectionBar.js +92 -0
- package/dist/selection/SelectionBarPhone.d.ts +3 -0
- package/dist/selection/SelectionBarPhone.js +14 -0
- package/dist/selection/bar-overflow.d.ts +12 -0
- package/dist/selection/bar-overflow.js +42 -0
- package/dist/selection/bar-parts.d.ts +15 -0
- package/dist/selection/bar-parts.js +17 -0
- package/dist/selection/index.d.ts +2 -0
- package/dist/selection/index.js +1 -0
- package/dist/selection/types.d.ts +3 -2
- package/dist/selection/verbs.d.ts +34 -0
- package/dist/selection/verbs.js +1 -0
- package/docs/contract.md +142 -39
- package/docs/getting-started.md +1 -1
- package/docs/guides/atoms.md +32 -4
- package/docs/guides/columns.md +1 -1
- package/docs/guides/display.md +1 -1
- package/docs/guides/editors.md +3 -3
- package/docs/guides/ports.md +1 -1
- package/docs/guides/selection.md +32 -20
- package/docs/guides/the-grid.md +43 -21
- package/docs/guides/the-provider.md +14 -4
- package/docs/index.md +2 -0
- package/docs/install.md +8 -1
- package/docs/reference/editors-date.md +2 -0
- package/docs/reference/editors-panel.md +4 -4
- package/docs/reference/editors-range.md +1 -1
- package/docs/reference/editors-relation.md +3 -3
- package/docs/reference/editors-select.md +1 -1
- package/docs/reference/editors-session.md +3 -2
- package/docs/reference/editors-value-list.md +1 -1
- package/docs/reference/field-row.md +2 -2
- package/docs/reference/grid.md +25 -6
- package/docs/reference/react.md +30 -8
- package/docs/reference/selection.md +10 -2
- package/docs/reference/views.md +42 -36
- package/package.json +22 -3
- package/skills/views/SKILL.md +3 -3
package/dist/figures.js
CHANGED
|
@@ -1,63 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
function either(a, b, both) {
|
|
3
|
-
return a == null ? b : b == null ? a : both(a, b);
|
|
4
|
-
}
|
|
5
|
-
export function combineFigure(a, b) {
|
|
6
|
-
return {
|
|
7
|
-
sum: either(a.sum, b.sum, (x, y) => x + y),
|
|
8
|
-
count: a.count + b.count,
|
|
9
|
-
min: either(a.min, b.min, Math.min),
|
|
10
|
-
max: either(a.max, b.max, Math.max),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export function figureOf(values) {
|
|
14
|
-
let figure = EMPTY_FIGURE;
|
|
15
|
-
for (const value of values) {
|
|
16
|
-
if (value == null || Number.isNaN(value))
|
|
17
|
-
continue;
|
|
18
|
-
figure = combineFigure(figure, { sum: value, count: 1, min: value, max: value });
|
|
19
|
-
}
|
|
20
|
-
return figure;
|
|
21
|
-
}
|
|
22
|
-
export function figureFor(kind, figures, key) {
|
|
23
|
-
if (kind === "none" || kind === "unique" || kind === "ratio")
|
|
24
|
-
return null;
|
|
25
|
-
if (kind === "count")
|
|
26
|
-
return figures.rows;
|
|
27
|
-
const figure = figures.fields[key];
|
|
28
|
-
if (!figure)
|
|
29
|
-
return null;
|
|
30
|
-
if (kind === "filled")
|
|
31
|
-
return figure.count;
|
|
32
|
-
if (figure.count === 0)
|
|
33
|
-
return null;
|
|
34
|
-
if (kind === "sum")
|
|
35
|
-
return figure.sum;
|
|
36
|
-
if (kind === "avg")
|
|
37
|
-
return figure.sum == null ? null : figure.sum / figure.count;
|
|
38
|
-
return kind === "min" ? figure.min : figure.max;
|
|
39
|
-
}
|
|
40
|
-
export function ratioFigure(figures, numerator, denominator) {
|
|
41
|
-
const num = figures.fields[numerator];
|
|
42
|
-
const den = figures.fields[denominator];
|
|
43
|
-
if (!num || !den)
|
|
44
|
-
return null;
|
|
45
|
-
const denominatorSum = den.sum ?? 0;
|
|
46
|
-
return denominatorSum > 0 ? Math.round(((num.sum ?? 0) / denominatorSum) * 100) : null;
|
|
47
|
-
}
|
|
48
|
-
const isFigure = (value) => !!value &&
|
|
49
|
-
typeof value === "object" &&
|
|
50
|
-
typeof value.count === "number" &&
|
|
51
|
-
["sum", "min", "max"].every((part) => {
|
|
52
|
-
const at = value[part];
|
|
53
|
-
return at === null || typeof at === "number";
|
|
54
|
-
});
|
|
55
|
-
export function isGroupFigures(value) {
|
|
56
|
-
if (!value || typeof value !== "object")
|
|
57
|
-
return false;
|
|
58
|
-
const { rows, fields } = value;
|
|
59
|
-
return (typeof rows === "number" &&
|
|
60
|
-
!!fields &&
|
|
61
|
-
typeof fields === "object" &&
|
|
62
|
-
Object.values(fields).every(isFigure));
|
|
63
|
-
}
|
|
1
|
+
export { EMPTY_FIGURE, combineFigure, figureFor, figureOf, isGroupFigures, ratioFigure, } from "@viewkitjs/fields/query";
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
1
2
|
import type { ListColumnsConfig } from "../../model/column-state.js";
|
|
3
|
+
/** An app's own "+ Add column": a node, `null` for none, anything else falsy for the grid's own. */
|
|
4
|
+
type RenderAddColumn = ((columns: ListColumnsConfig) => ReactNode) | undefined;
|
|
5
|
+
/** Whether the header row ends in an Add column: not where the app's own answers `null`. */
|
|
6
|
+
export declare function gridAddColumnDrawn(render: RenderAddColumn, columns: ListColumnsConfig): boolean;
|
|
7
|
+
/** The header row's last cell: the app's own Add column, none where it answers `null`, else the grid's own. */
|
|
8
|
+
export declare function gridAddColumnNode(render: RenderAddColumn, columns: ListColumnsConfig): ReactNode | null;
|
|
2
9
|
/**
|
|
3
10
|
* "+ ADD COLUMN" ON EVERY GRID: the header row's last cell, for anyone who reads the list. It lists the columns
|
|
4
11
|
* this view hides and can show, and shows the one picked: a choice about the reader's own view, never a change
|
|
@@ -9,3 +16,4 @@ import type { ListColumnsConfig } from "../../model/column-state.js";
|
|
|
9
16
|
export declare function GridAddColumn({ columns }: {
|
|
10
17
|
columns: ListColumnsConfig;
|
|
11
18
|
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export {};
|
|
@@ -2,28 +2,85 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useCallback, useState } from "react";
|
|
4
4
|
import { useViews } from "../../provider/context.js";
|
|
5
|
+
import { useDesktop } from "../../provider/desktop.js";
|
|
5
6
|
import { cx } from "../../internal/cx.js";
|
|
7
|
+
import { ELEMENT_RESET } from "../../internal/reset.js";
|
|
8
|
+
import { gridAddColumnItems } from "./grid-add-column-items.js";
|
|
9
|
+
import { useGridMenuPress } from "./grid-menu-focus.js";
|
|
10
|
+
export function gridAddColumnDrawn(render, columns) {
|
|
11
|
+
return render?.(columns) !== null;
|
|
12
|
+
}
|
|
13
|
+
export function gridAddColumnNode(render, columns) {
|
|
14
|
+
const own = render?.(columns);
|
|
15
|
+
if (own === null)
|
|
16
|
+
return null;
|
|
17
|
+
return own || _jsx(GridAddColumn, { columns: columns });
|
|
18
|
+
}
|
|
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
|
+
}
|
|
6
44
|
export function GridAddColumn({ columns }) {
|
|
7
45
|
const [open, setOpen] = useState(false);
|
|
8
46
|
const [query, setQuery] = useState("");
|
|
9
47
|
const [anchor, setAnchor] = useState(null);
|
|
10
|
-
const { atoms, components, icons, messages } = useViews();
|
|
11
|
-
const { Popover, Command } = components;
|
|
48
|
+
const { atoms, components, icons, messages, menus } = useViews();
|
|
49
|
+
const { Popover, Command, Sheet, Menu } = components;
|
|
50
|
+
const press = useGridMenuPress(open);
|
|
51
|
+
const menuRoute = (menus ?? "popover") === "menu";
|
|
52
|
+
const desktop = useDesktop();
|
|
53
|
+
const word = messages({ key: "views.grid.add-column" });
|
|
12
54
|
const { List, RowContent } = atoms;
|
|
13
55
|
const Add = icons.add;
|
|
56
|
+
const Chevron = icons.chevronRight;
|
|
14
57
|
const wanted = query.trim().toLowerCase();
|
|
15
|
-
const
|
|
58
|
+
const [drill, setDrill] = useState(null);
|
|
59
|
+
const rows = addColumnRows(columns.items, wanted, drill);
|
|
16
60
|
const close = (reason = "none") => {
|
|
17
61
|
setOpen(false);
|
|
18
62
|
setQuery("");
|
|
63
|
+
setDrill(null);
|
|
19
64
|
if (reason !== "outside-press" && reason !== "focus-out")
|
|
20
65
|
anchor?.focus({ preventScroll: true });
|
|
21
66
|
};
|
|
22
67
|
const focusSearch = useCallback((el) => el?.focus({ preventScroll: true }), []);
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
68
|
+
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: "h-full min-w-0 flex-1 bg-transparent px-3.5 text-base text-(color:--vk-fg) outline-hidden placeholder:text-(color:--vk-fg-subtlest) md:text-sm" }) }), _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) => {
|
|
69
|
+
const { item } = row;
|
|
70
|
+
const glyph = (node) => (_jsx("span", { className: "flex size-4 shrink-0 items-center justify-center text-(color:--vk-fg-subtle)", children: node }));
|
|
71
|
+
if (row.kind === "back")
|
|
72
|
+
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"));
|
|
73
|
+
if (row.kind === "drill")
|
|
74
|
+
return (_jsx(Command.Item, { value: `drill:${item.id}`, onSelect: () => {
|
|
75
|
+
setQuery("");
|
|
76
|
+
setDrill(item.id);
|
|
77
|
+
}, 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}`));
|
|
78
|
+
return (_jsx(Command.Item, { value: item.id, onSelect: () => {
|
|
79
|
+
columns.onToggleHidden(item.id, false);
|
|
80
|
+
close("item-press");
|
|
81
|
+
}, children: _jsx(RowContent, { label: row.label, leading: glyph(item.icon) }) }, item.id));
|
|
82
|
+
}), !rows.some((row) => row.kind !== "back") && (_jsx("p", { className: "px-2 py-2 text-sm text-(color:--vk-fg-subtle)", children: wanted
|
|
83
|
+
? messages({ key: "views.menus.add-column-no-match", values: { query: query.trim() } })
|
|
84
|
+
: messages({ key: "views.menus.add-column-all-shown" }) }))] }) }) })] }));
|
|
85
|
+
return (_jsxs(_Fragment, { children: [_jsxs("button", { ref: setAnchor, type: "button", tabIndex: -1, "aria-haspopup": menuRoute ? "menu" : "dialog", "aria-expanded": open, onPointerDownCapture: menuRoute ? press.notePress : undefined, onClick: (e) => ((menuRoute && press.pressedOpen(e)) || open ? close() : setOpen(true)), className: cx(ELEMENT_RESET, "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)"), children: [_jsx(Add, { className: "h-(--vk-head-glyph) w-(--vk-head-glyph) shrink-0 opacity-70" }), _jsx("span", { className: "truncate", children: messages({ key: "views.grid.add-column" }) })] }), menuRoute ? (_jsx(Menu, { open: open, onOpenChange: (next, details) => (next ? setOpen(true) : close(details?.reason)), anchor: anchor, side: "bottom", align: "end", label: word, items: open ? gridAddColumnItems(columns, { messages, close: () => close("item-press") }) : [] })) : desktop ? (_jsx(Popover, { open: open, onOpenChange: (next, details) => (next ? setOpen(true) : close(details?.reason)), anchor: anchor, side: "bottom", align: "end", sideOffset: 4, chrome: "menu", initialFocus: false, className: "flex w-60 flex-col", onOutsidePress: (event) => (anchor?.contains(event.target) ? false : undefined), children: list })) : (_jsx(Sheet, { open: open, onOpenChange: (next, details) => (next ? setOpen(true) : close(details?.reason)), title: word, label: word, snap: "half", children: list }))] }));
|
|
29
86
|
}
|
|
@@ -4,8 +4,9 @@ import type { ListAggregateKind, ListColumn } from "../../model/column-schema.js
|
|
|
4
4
|
type TriggerProps = {
|
|
5
5
|
ref?: Ref<HTMLElement>;
|
|
6
6
|
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
|
|
7
|
+
onPointerDownCapture?: () => void;
|
|
7
8
|
role?: "button" | "gridcell";
|
|
8
|
-
"aria-haspopup"?: "dialog";
|
|
9
|
+
"aria-haspopup"?: "dialog" | "menu";
|
|
9
10
|
"aria-expanded"?: boolean;
|
|
10
11
|
};
|
|
11
12
|
/**
|
|
@@ -14,7 +15,9 @@ type TriggerProps = {
|
|
|
14
15
|
* count/filled/unique; a source list's footer offers what the database answers,
|
|
15
16
|
* handed in as `options`). The trigger is the WHOLE footer cell, passed as the
|
|
16
17
|
* child: the map's popover anchors on it, in its slot; selection commits
|
|
17
|
-
* through the host's persisted `gridAggregates` pref.
|
|
18
|
+
* through the host's persisted `gridAggregates` pref. That is the `popover`
|
|
19
|
+
* route; on the `menu` route (the provider's `menus`) it is the map's `Menu`
|
|
20
|
+
* instead, anchored on the same cell, one ticked row per figure.
|
|
18
21
|
*/
|
|
19
22
|
export declare function GridAggregateMenu<Row>({ column, options, current, onChange, align, children, }: {
|
|
20
23
|
column: ListColumn<Row>;
|
|
@@ -2,15 +2,44 @@
|
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { cloneElement, useState, } from "react";
|
|
4
4
|
import { aggregateLabel, aggregateOptions } from "../../model/aggregates.js";
|
|
5
|
+
import { columnLabel } from "../../model/column-capabilities.js";
|
|
5
6
|
import { useViews } from "../../provider/context.js";
|
|
6
|
-
import { gridMenuArrows, useGridMenuFocus } from "./grid-menu-focus.js";
|
|
7
|
+
import { gridMenuArrows, useGridMenuFocus, useGridMenuPress } from "./grid-menu-focus.js";
|
|
7
8
|
export function GridAggregateMenu({ column, options, current, onChange, align, children, }) {
|
|
8
9
|
const [open, setOpen] = useState(false);
|
|
9
10
|
const [anchor, setAnchor] = useState(null);
|
|
10
11
|
useGridMenuFocus(open, anchor);
|
|
11
|
-
const
|
|
12
|
-
const {
|
|
12
|
+
const press = useGridMenuPress(open);
|
|
13
|
+
const { atoms, components, messages, menus } = useViews();
|
|
14
|
+
const { Popover, Menu } = components;
|
|
13
15
|
const { List, Row } = atoms;
|
|
16
|
+
const figures = options ?? aggregateOptions(column);
|
|
17
|
+
if ((menus ?? "popover") === "menu") {
|
|
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
|
+
});
|
|
32
|
+
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) => ({
|
|
33
|
+
key: kind,
|
|
34
|
+
label: aggregateLabel(kind, messages),
|
|
35
|
+
checked: kind === current,
|
|
36
|
+
onSelect: () => {
|
|
37
|
+
setOpen(false);
|
|
38
|
+
if (kind !== current)
|
|
39
|
+
onChange(kind);
|
|
40
|
+
},
|
|
41
|
+
})) })] }));
|
|
42
|
+
}
|
|
14
43
|
const trigger = cloneElement(children, {
|
|
15
44
|
ref: setAnchor,
|
|
16
45
|
onClick: (event) => {
|
|
@@ -21,7 +50,7 @@ export function GridAggregateMenu({ column, options, current, onChange, align, c
|
|
|
21
50
|
"aria-haspopup": "dialog",
|
|
22
51
|
"aria-expanded": open,
|
|
23
52
|
});
|
|
24
|
-
return (_jsxs(_Fragment, { children: [trigger, _jsx(Popover, { open: open, onOpenChange: setOpen, anchor: anchor, side: "bottom", align: align, sideOffset: 4, chrome: "menu", panelData: { "data-slot": "vk-grid-aggregate-menu" }, className: "w-40", onOutsidePress: (event) => (anchor?.contains(event.target) ? false : undefined), children: _jsx("div", { onKeyDown: gridMenuArrows, children: _jsx(List, { children:
|
|
53
|
+
return (_jsxs(_Fragment, { children: [trigger, _jsx(Popover, { open: open, onOpenChange: setOpen, anchor: anchor, side: "bottom", align: align, sideOffset: 4, chrome: "menu", panelData: { "data-slot": "vk-grid-aggregate-menu" }, className: "w-40", onOutsidePress: (event) => (anchor?.contains(event.target) ? false : undefined), children: _jsx("div", { onKeyDown: gridMenuArrows, children: _jsx(List, { children: figures.map((kind) => (_jsx(Row, { chosen: kind === current, label: aggregateLabel(kind, messages), onClick: () => {
|
|
25
54
|
setOpen(false);
|
|
26
55
|
if (kind !== current)
|
|
27
56
|
onChange(kind);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
+
import { type FieldType } from "@viewkitjs/fields";
|
|
2
3
|
import type { GridEditorId } from "../../model/column-types.js";
|
|
3
4
|
import { type ListSettingsConfig } from "../../model/column-capabilities.js";
|
|
4
5
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
@@ -37,9 +38,10 @@ export type GridCellEditorContext<Row> = {
|
|
|
37
38
|
onEnter: () => void;
|
|
38
39
|
};
|
|
39
40
|
/**
|
|
40
|
-
* The INLINE editors — the ones that replace the cell's own content while open
|
|
41
|
+
* The INLINE editors — the ones that replace the cell's own content while open, under the field type their session
|
|
42
|
+
* reads Escape's rule by.
|
|
41
43
|
*
|
|
42
|
-
*
|
|
44
|
+
* Its inner editor renders nothing for every other case so the caller can fall through to the
|
|
43
45
|
* cell's normal render. In particular `text` is matched explicitly, never as a
|
|
44
46
|
* bare else: it is the last arm of the chain, and an unguarded fallback would
|
|
45
47
|
* mount a text input on top of an open picker, and on any editor-less type that
|
|
@@ -48,6 +50,11 @@ export type GridCellEditorContext<Row> = {
|
|
|
48
50
|
export declare function GridCellInlineEditor<Row>({ ctx }: {
|
|
49
51
|
ctx: GridCellEditorContext<Row>;
|
|
50
52
|
}): ReactNode;
|
|
53
|
+
/**
|
|
54
|
+
* The field type a cell's editor edits, for what Escape does there (`ViewsProvider`'s `escape`): the column's
|
|
55
|
+
* field's, or, for a column with no field, its own type, a title read as text.
|
|
56
|
+
*/
|
|
57
|
+
export declare function gridEscapeType<Row>(col: ListColumn<Row>): FieldType | undefined;
|
|
51
58
|
/**
|
|
52
59
|
* The ANCHORED editors (select popover, date calendar). They hang off the END
|
|
53
60
|
* of the cell rather than wrapping its value, because the value has to keep its
|
|
@@ -10,25 +10,39 @@ import { isIntegerField, isMultipleType, isNameValue, isRangeValue, phoneText, r
|
|
|
10
10
|
import { GridNameEditor } from "./GridNameEditor.js";
|
|
11
11
|
import { GridPlaceEditor } from "./GridPlaceEditor.js";
|
|
12
12
|
import { GridValueListEditor } from "./GridValueListEditor.js";
|
|
13
|
-
import { cellPrevPayload } from "./cell-clipboard.js";
|
|
13
|
+
import { cellPrevPayload, gridDateDrawsAtOnce } from "./cell-clipboard.js";
|
|
14
14
|
import { GridChipsEditor, GridDateEditor, GridLongTextEditor, GridNumberEditor, GridRangeEditor, GridRelationEditor, GridRelationSetEditor, GridSelectEditor, GridTextEditor, } from "./editors.js";
|
|
15
15
|
import { gridTextEditorType } from "./GridTextEditor.js";
|
|
16
16
|
import { gridTextOpensBox, isLongTextColumn } from "../../model/column-inspect.js";
|
|
17
17
|
import { gridClearRefusal, gridColumnEffectiveClearable, gridColumnLocked, gridEditRefusal, gridNormalizeWrite, } from "../../model/column-capabilities.js";
|
|
18
18
|
import { useViews } from "../../provider/context.js";
|
|
19
|
+
import { EditFieldTypeContext } from "../../editors/escape-rule.js";
|
|
19
20
|
import { gridRelationSource } from "../../model/column-types.js";
|
|
20
|
-
|
|
21
|
+
import { gridPartWrite } from "../../model/part-write.js";
|
|
22
|
+
function useCellRefusal(col, listConfig, region, row) {
|
|
21
23
|
const { conventions, messages } = useViews();
|
|
22
24
|
return (next, prev) => {
|
|
23
25
|
if (gridColumnLocked(col, listConfig))
|
|
24
26
|
return gridEditRefusal(col, listConfig, conventions, messages) ?? null;
|
|
27
|
+
if (col.partOf) {
|
|
28
|
+
const part = gridPartWrite(col, col.partOf.read(row), next, conventions, { messages });
|
|
29
|
+
return part.ok ? null : part.reason;
|
|
30
|
+
}
|
|
25
31
|
const result = gridNormalizeWrite(col, next, conventions, { messages, stored: prev, region });
|
|
26
32
|
return result.ok ? null : result.reason;
|
|
27
33
|
};
|
|
28
34
|
}
|
|
29
35
|
export function GridCellInlineEditor({ ctx }) {
|
|
36
|
+
return (_jsx(EditFieldTypeContext.Provider, { value: gridEscapeType(ctx.col), children: _jsx(InlineEditor, { ctx: ctx }) }));
|
|
37
|
+
}
|
|
38
|
+
export function gridEscapeType(col) {
|
|
39
|
+
if (col.field)
|
|
40
|
+
return col.field.type;
|
|
41
|
+
return col.type === "title" ? "text" : col.type;
|
|
42
|
+
}
|
|
43
|
+
function InlineEditor({ ctx }) {
|
|
30
44
|
const { row, rowId, col, baseline, onCommitCell, onCancel, onTab, onEnter } = ctx;
|
|
31
|
-
const refusal = useCellRefusal(col, ctx.listConfig, col.region?.(row));
|
|
45
|
+
const refusal = useCellRefusal(col, ctx.listConfig, col.region?.(row), row);
|
|
32
46
|
if (ctx.editorKind === "number") {
|
|
33
47
|
const integer = col.field ? isIntegerField(col.field) : false;
|
|
34
48
|
const fallback = col.field ? numberEditDecimals(col.field) : (col.format?.decimals ?? 2);
|
|
@@ -49,9 +63,12 @@ export function GridCellInlineEditor({ ctx }) {
|
|
|
49
63
|
return null;
|
|
50
64
|
}
|
|
51
65
|
export function GridCellAnchoredEditor({ ctx, }) {
|
|
66
|
+
return (_jsx(EditFieldTypeContext.Provider, { value: gridEscapeType(ctx.col), children: _jsx(AnchoredEditor, { ctx: ctx }) }));
|
|
67
|
+
}
|
|
68
|
+
function AnchoredEditor({ ctx }) {
|
|
52
69
|
const { row, rowId, col, baseline, onCommitCell, onCancel } = ctx;
|
|
53
70
|
const region = col.region?.(row);
|
|
54
|
-
const refusal = useCellRefusal(col, ctx.listConfig, region);
|
|
71
|
+
const refusal = useCellRefusal(col, ctx.listConfig, region, row);
|
|
55
72
|
const { messages } = useViews();
|
|
56
73
|
const relationSource = useMemo(() => gridRelationSource(col, ctx.entityIcon), [col, ctx.entityIcon]);
|
|
57
74
|
if (ctx.editorKind === "text" && gridTextOpensBox(col, !!ctx.whole)) {
|
|
@@ -98,7 +115,9 @@ export function GridCellAnchoredEditor({ ctx, }) {
|
|
|
98
115
|
if (ctx.editorKind === "date") {
|
|
99
116
|
return (_jsx(GridDateEditor, { title: col.header, initial: String(baseline ?? "") || undefined, dayOnly: col.field?.type === "date", clearable: gridColumnEffectiveClearable(col, ctx.listConfig), seed: ctx.editSeed ?? undefined, refuse: (ymd) => ymd === "" && !gridColumnEffectiveClearable(col, ctx.listConfig)
|
|
100
117
|
? gridClearRefusal(col, ctx.listConfig, messages)
|
|
101
|
-
: refusal(ymd, cellPrevPayload(col, baseline)), onCommit: (ymd) => onCommitCell(row, rowId, col.id, cellPrevPayload(col, baseline), ymd, ymd === ""
|
|
118
|
+
: refusal(ymd, cellPrevPayload(col, baseline)), onCommit: (ymd) => onCommitCell(row, rowId, col.id, cellPrevPayload(col, baseline), ymd, ymd === "" || gridDateDrawsAtOnce(col)
|
|
119
|
+
? undefined
|
|
120
|
+
: { overlay: false }), onCancel: onCancel, onTab: ctx.onTab }));
|
|
102
121
|
}
|
|
103
122
|
return null;
|
|
104
123
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/** A frozen cell's paint for its row's state: the ground and the row's hover, or, on a selected
|
|
2
2
|
* row, the ground with the selection tint and its own hover. One answer per state, so no class has
|
|
3
|
-
* to beat another (`cx` joins, it does not merge).
|
|
4
|
-
|
|
3
|
+
* to beat another (`cx` joins, it does not merge). `on: "before"` paints it on the element's
|
|
4
|
+
* `::before` instead. */
|
|
5
|
+
export declare function gridFrozenBg(selected: boolean, on?: "before"): string;
|
|
5
6
|
/**
|
|
6
7
|
* NOTE: the frozen block has NO edge treatment on ANY surface — header, rows and
|
|
7
8
|
* footer all end flat, and a frozen cell renders exactly like an unfrozen one.
|
|
@@ -4,7 +4,17 @@ import { GRID_GROUND } from "./grid-styles.js";
|
|
|
4
4
|
const GRID_FROZEN_HOVER = "group-hover/gridrow:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]";
|
|
5
5
|
const GRID_FROZEN_BG_SELECTED = "bg-[linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]";
|
|
6
6
|
const GRID_FROZEN_BG_SELECTED_HOVER = "group-hover/gridrow:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent)),linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]";
|
|
7
|
-
|
|
7
|
+
const GRID_FROZEN_BG_BEFORE = {
|
|
8
|
+
ground: "before:bg-(color:--vk-ground)",
|
|
9
|
+
hover: "group-hover/gridrow:before:bg-[linear-gradient(var(--vk-hovered),var(--vk-hovered))]",
|
|
10
|
+
selected: "before:bg-[linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]",
|
|
11
|
+
selectedHover: "group-hover/gridrow:before:bg-[linear-gradient(color-mix(in_oklab,_var(--vk-brand)_10%,_transparent),color-mix(in_oklab,_var(--vk-brand)_10%,_transparent)),linear-gradient(var(--vk-brand-subtlest),var(--vk-brand-subtlest))]",
|
|
12
|
+
};
|
|
13
|
+
export function gridFrozenBg(selected, on) {
|
|
14
|
+
if (on === "before") {
|
|
15
|
+
const b = GRID_FROZEN_BG_BEFORE;
|
|
16
|
+
return selected ? cx(b.ground, b.selected, b.selectedHover) : cx(b.ground, b.hover);
|
|
17
|
+
}
|
|
8
18
|
return selected
|
|
9
19
|
? cx(GRID_GROUND, GRID_FROZEN_BG_SELECTED, GRID_FROZEN_BG_SELECTED_HOVER)
|
|
10
20
|
: cx(GRID_GROUND, GRID_FROZEN_HOVER);
|
|
@@ -31,5 +31,5 @@ export function GridChipsEditor({ column, title, values, suggestions, optionColo
|
|
|
31
31
|
label: column.options?.find((option) => option.value === value)?.label ?? prettifyOptionValue(value),
|
|
32
32
|
color: resolveCategoryColor(value, column.options, optionColors),
|
|
33
33
|
});
|
|
34
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, creatable: open, onRequestClose: close }) })] }));
|
|
34
|
+
return (_jsxs(_Fragment, { children: [_jsx("span", { ref: anchorRef, "aria-hidden": true, className: "pointer-events-none absolute inset-0" }), _jsx(EditorPanel, { session: session, title: title, anchor: anchorRef, align: "start", sideOffset: 4, initialFocus: false, panelData: { "data-slot": "vk-grid-editor" }, onPanelClick: (event) => event.stopPropagation(), chrome: "menu", className: "w-64 z-90", children: _jsx(ChipsEditor, { ref: editorRef, values: values, suggestions: offered, resolve: resolve, normalize: column.chips?.normalize, creatable: open, onRequestClose: close, label: typeof title === "string" ? title : undefined }) })] }));
|
|
35
35
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
2
2
|
import { type GridFlyouts } from "./GridFlyout.js";
|
|
3
|
+
export declare const COLOR_DOTS: Record<ListSelectColor, string>;
|
|
4
|
+
export declare const ALL_COLORS: ListSelectColor[];
|
|
3
5
|
export declare function GridColumnColorSection<Row>({ column, values, optionColors, flyouts, onOptionColorChange, onClose, }: {
|
|
4
6
|
column: ListColumn<Row>;
|
|
5
7
|
values: string[];
|
|
@@ -7,8 +7,8 @@ import { useViews } from "../../provider/context.js";
|
|
|
7
7
|
import { cx } from "../../internal/cx.js";
|
|
8
8
|
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
9
9
|
import { GridMenuSeparator } from "./GridMenuRow.js";
|
|
10
|
-
const COLOR_DOTS = CATEGORY_DOT_CLASSES;
|
|
11
|
-
const ALL_COLORS = [
|
|
10
|
+
export const COLOR_DOTS = CATEGORY_DOT_CLASSES;
|
|
11
|
+
export const ALL_COLORS = [
|
|
12
12
|
"gray",
|
|
13
13
|
"blue",
|
|
14
14
|
"green",
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
2
|
import type { ListDateStyle } from "../../model/column-format.js";
|
|
3
3
|
import { type GridFlyouts } from "./GridFlyout.js";
|
|
4
|
+
export declare const DATE_STYLES: ListDateStyle[];
|
|
5
|
+
/** The live sample beside each style: a few days back, so Relative reads as a
|
|
6
|
+
* real "3d ago" rather than the "now" it would say of the moment it opened. */
|
|
7
|
+
export declare const sampleDate: () => Date;
|
|
4
8
|
/**
|
|
5
9
|
* The date-column row in the header menu — one Format row whose flyout holds
|
|
6
10
|
* the styles (each beside a live sample) and, on a date-time, Show time —
|
|
@@ -7,8 +7,8 @@ import { useCellFormat } from "../../cells/use-cell-format.js";
|
|
|
7
7
|
import { useViews } from "../../provider/context.js";
|
|
8
8
|
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
9
9
|
import { GridMenuSeparator, KnobGlyph } from "./GridMenuRow.js";
|
|
10
|
-
const DATE_STYLES = ["short", "long", "numeric", "relative"];
|
|
11
|
-
const sampleDate = () => new Date(Date.now() - 3 * 86_400_000);
|
|
10
|
+
export const DATE_STYLES = ["short", "long", "numeric", "relative"];
|
|
11
|
+
export const sampleDate = () => new Date(Date.now() - 3 * 86_400_000);
|
|
12
12
|
export function GridColumnDateSection({ column, dateStyle, onDateStyleChange, showTime, onShowTimeChange, flyouts, onClose, }) {
|
|
13
13
|
const activeDateStyle = dateStyle ?? column.format?.dateStyle ?? "short";
|
|
14
14
|
const sample = sampleDate();
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { ListColumn } from "../../model/column-schema.js";
|
|
2
2
|
import type { ListDurationStyle } from "../../model/column-format.js";
|
|
3
3
|
import { type GridFlyouts } from "./GridFlyout.js";
|
|
4
|
+
export declare const DURATION_STYLES: ListDurationStyle[];
|
|
5
|
+
/** Live example beside each of the three duration renderings — long enough
|
|
6
|
+
* (an hour and a half) that every style's shape is visible at a glance. */
|
|
7
|
+
export declare const DURATION_SAMPLE_MS = 5904000;
|
|
4
8
|
/**
|
|
5
9
|
* The duration-column row in the header menu — one Format row whose flyout
|
|
6
10
|
* holds the styles — split out of GridColumnMenu because that file is held
|
|
@@ -6,8 +6,8 @@ import { useCellFormat } from "../../cells/use-cell-format.js";
|
|
|
6
6
|
import { useViews } from "../../provider/context.js";
|
|
7
7
|
import { GridFlyoutRow } from "./GridFlyout.js";
|
|
8
8
|
import { KnobGlyph } from "./GridMenuRow.js";
|
|
9
|
-
const DURATION_STYLES = ["adaptive", "clock", "units"];
|
|
10
|
-
const DURATION_SAMPLE_MS = 5_904_000;
|
|
9
|
+
export const DURATION_STYLES = ["adaptive", "clock", "units"];
|
|
10
|
+
export const DURATION_SAMPLE_MS = 5_904_000;
|
|
11
11
|
export function GridColumnDurationSection({ column, durationStyle, onDurationStyleChange, flyouts, onClose, }) {
|
|
12
12
|
const activeDurationStyle = durationStyle ?? column.format?.durationStyle ?? "adaptive";
|
|
13
13
|
const cellFormat = useCellFormat();
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
import { type MouseEvent as ReactMouseEvent, type ReactElement, type ReactNode, type Ref } from "react";
|
|
2
2
|
import type { PercentDisplay } from "@viewkitjs/fields";
|
|
3
|
-
import type {
|
|
3
|
+
import type { SortDirection } from "@viewkitjs/fields/query";
|
|
4
4
|
import type { ListColumn, ListSelectColor } from "../../model/column-schema.js";
|
|
5
5
|
import type { ListDateStyle, ListDurationStyle, ListNumberFormatState } from "../../model/column-format.js";
|
|
6
|
+
import type { ViewsMenuItem } from "../../provider/components.js";
|
|
6
7
|
/** What the menu sets on the header cell it opens from. */
|
|
7
8
|
type TriggerProps = {
|
|
8
9
|
ref?: Ref<HTMLElement>;
|
|
9
10
|
onClick?: (event: ReactMouseEvent<HTMLElement>) => void;
|
|
11
|
+
onPointerDownCapture?: () => void;
|
|
10
12
|
role?: "button" | "columnheader";
|
|
11
|
-
"aria-haspopup"?: "dialog";
|
|
13
|
+
"aria-haspopup"?: "dialog" | "menu";
|
|
12
14
|
"aria-expanded"?: boolean;
|
|
13
15
|
};
|
|
14
16
|
/** The list's sort state, threaded from its controller — the menu is a second
|
|
15
17
|
* remote control for the SAME persisted sort the view-options popover drives. */
|
|
16
18
|
export type GridSortState = {
|
|
17
19
|
value: string;
|
|
18
|
-
dir:
|
|
20
|
+
dir: SortDirection;
|
|
19
21
|
onChange: (next: {
|
|
20
22
|
value: string;
|
|
21
|
-
dir:
|
|
23
|
+
dir: SortDirection;
|
|
22
24
|
}) => void;
|
|
23
25
|
};
|
|
24
26
|
/** The view's group, as the header asks it: which field, and a writer that
|
|
@@ -58,7 +60,7 @@ export declare function gridColumnMenuEnabled<Row>(col: ListColumn<Row>): boolea
|
|
|
58
60
|
* and it lives in Settings → Modules → Tables and the Columns drill-in, not
|
|
59
61
|
* beside the knobs about how the field READS.
|
|
60
62
|
*/
|
|
61
|
-
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, renderColumnMenuRows, children, }: {
|
|
63
|
+
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, renderColumnMenuRows, columnMenuItems, children, }: {
|
|
62
64
|
column: ListColumn<Row>;
|
|
63
65
|
/** Distinct option values for select columns (declared + discovered), in display order. */
|
|
64
66
|
values: string[];
|
|
@@ -92,8 +94,10 @@ export declare function GridColumnMenu<Row>({ column, values, viewBacked, sort,
|
|
|
92
94
|
onHide?: () => void;
|
|
93
95
|
/** Whether a format knob can be stored; the reader's own currency reading stays either way. */
|
|
94
96
|
formatsWritable?: boolean;
|
|
95
|
-
/** The host's rows for this column's field, above Hide; null for a field it adds nothing to. */
|
|
97
|
+
/** The host's rows for this column's field, above Hide; null for a field it adds nothing to. Popover route only. */
|
|
96
98
|
renderColumnMenuRows?: (fieldKey: string, close: () => void) => ReactNode;
|
|
99
|
+
/** The host's rows for this column's field as data, on the `menu` route; null or empty for none. */
|
|
100
|
+
columnMenuItems?: (fieldKey: string) => ViewsMenuItem[] | null;
|
|
97
101
|
/** The header cell: the menu's anchor, and a press on it opens or closes the menu. The menu
|
|
98
102
|
* sets its `ref`, so it must carry none of its own. */
|
|
99
103
|
children: ReactElement<TriggerProps>;
|