@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
|
@@ -7,6 +7,7 @@ import type { CategoryColor } from "@viewkitjs/fields/design/category-colors";
|
|
|
7
7
|
import type { StageMark } from "@viewkitjs/fields/design/stage-marks";
|
|
8
8
|
import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
|
|
9
9
|
import type { FieldDef, RelationValue, ValueType } from "@viewkitjs/fields";
|
|
10
|
+
import type { FigureKind } from "@viewkitjs/fields/query";
|
|
10
11
|
import type { ListColumnFormat } from "./column-format.js";
|
|
11
12
|
/** The grid's column vocabulary: a column presents a VALUE, so its type is
|
|
12
13
|
* the field's value type (a rollup or formula column is its result's type;
|
|
@@ -14,9 +15,6 @@ import type { ListColumnFormat } from "./column-format.js";
|
|
|
14
15
|
* field-less legacy column still names one of these; `legacyFieldFromColumn`
|
|
15
16
|
* is the bridge that reads it as a def. */
|
|
16
17
|
export type ListColumnType = ValueType | "title";
|
|
17
|
-
/** The list's name for the design system's slot — one union, aliased like
|
|
18
|
-
* `ListDurationStyle` below, so the two cannot drift. */
|
|
19
|
-
export type ListStatusSlot = StatusSlot;
|
|
20
18
|
/**
|
|
21
19
|
* Where a field lands on a CARD. The board's own type→zone table decides this
|
|
22
20
|
* for almost every column; this union is declared here, in the model, so a
|
|
@@ -33,7 +31,7 @@ export type ListSelectColor = CategoryColor;
|
|
|
33
31
|
export type ListColumnOption = {
|
|
34
32
|
value: string;
|
|
35
33
|
label?: string;
|
|
36
|
-
slot?:
|
|
34
|
+
slot?: StatusSlot;
|
|
37
35
|
color?: ListSelectColor;
|
|
38
36
|
/**
|
|
39
37
|
* The value's stage mark — set when this option is a POSITION ON A LADDER,
|
|
@@ -76,14 +74,15 @@ export type ListRelationValue = RelationValue & {
|
|
|
76
74
|
};
|
|
77
75
|
export type { ListColumnFormat, ListDateStyle, ListDateStyleOverrides, ListDurationStyle, ListDurationStyleOverrides, ListNumberFormatOverrides, ListNumberFormatState, ListPercentDisplayOverrides, ListShowTimeOverrides, } from "./column-format.js";
|
|
78
76
|
export type ListOptionColorOverrides = Record<string, Record<string, ListSelectColor>>;
|
|
79
|
-
/** `ratio` is sum-over-sum as a percent, offered only by a column
|
|
80
|
-
|
|
77
|
+
/** A column's footer pick: fields' figure kinds. `ratio` is sum-over-sum as a percent, offered only by a column
|
|
78
|
+
* carrying `ratio`. */
|
|
79
|
+
export type ListAggregateKind = FigureKind;
|
|
81
80
|
export type ListCellAction<Row> = {
|
|
82
81
|
id: string;
|
|
83
82
|
icon: (row: Row) => ReactNode;
|
|
84
83
|
label?: (row: Row) => string;
|
|
85
84
|
onClick?: (row: Row, event?: ReactMouseEvent<HTMLButtonElement>) => void;
|
|
86
|
-
status?: (row: Row) =>
|
|
85
|
+
status?: (row: Row) => StatusSlot | null;
|
|
87
86
|
};
|
|
88
87
|
/**
|
|
89
88
|
* Declarative column schema. A typed `accessor` uses standard chrome; `render`
|
|
@@ -96,6 +95,15 @@ export type RenderedValue = {
|
|
|
96
95
|
value: unknown;
|
|
97
96
|
code?: string;
|
|
98
97
|
};
|
|
98
|
+
/** Which part of which column's value a part column shows: the whole column's id, the part (`countryCode`,
|
|
99
|
+
* `given`, `low`), the whole column's field, and `read`, the whole value as stored on a row (the whole column's
|
|
100
|
+
* `editAccessor`, else its `accessor`), which a part's edit is written onto. */
|
|
101
|
+
export type ListColumnPartOf<Row = unknown> = {
|
|
102
|
+
column: string;
|
|
103
|
+
part: string;
|
|
104
|
+
field: FieldDef;
|
|
105
|
+
read: (row: Row) => unknown;
|
|
106
|
+
};
|
|
99
107
|
export type ListColumn<Row> = {
|
|
100
108
|
id: string;
|
|
101
109
|
header: ReactNode;
|
|
@@ -327,6 +335,9 @@ export type ListColumn<Row> = {
|
|
|
327
335
|
* commit. Nothing on the def reads the row — that is `binding` below.
|
|
328
336
|
*/
|
|
329
337
|
field?: FieldDef;
|
|
338
|
+
/** The part of another column's value this column shows (VK-324): derived by the grid behind `parts`, never
|
|
339
|
+
* declared. Such a column carries no `field` of its own: it reads as the part's own type. */
|
|
340
|
+
partOf?: ListColumnPartOf<Row>;
|
|
330
341
|
/**
|
|
331
342
|
* How that field READS AND WRITES this row — the module's binding (spec
|
|
332
343
|
* §3.5), the one declaration the grid, the drawer and the board all consume.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
import type { ListColumnState } from "@viewkitjs/fields/query";
|
|
2
3
|
import type { ListColumn } from "./column-schema.js";
|
|
4
|
+
/** A list's column state and its density are fields' own, so a server reads them without React. */
|
|
5
|
+
export type { ListColumnState, ListDensity } from "@viewkitjs/fields/query";
|
|
3
6
|
/** One column of a view, as a list that shows and hides columns reads it. */
|
|
4
7
|
export type ListColumnItem = {
|
|
5
8
|
id: string;
|
|
@@ -9,6 +12,12 @@ export type ListColumnItem = {
|
|
|
9
12
|
hideable: boolean;
|
|
10
13
|
/** Declaration-only column: a saved view cannot hide or reorder it. */
|
|
11
14
|
fixed?: boolean;
|
|
15
|
+
/** A part column's whole and its part, with the part's word ("Country"): what an Add column drills into (VK-324). */
|
|
16
|
+
partOf?: {
|
|
17
|
+
column: string;
|
|
18
|
+
part: string;
|
|
19
|
+
label: string;
|
|
20
|
+
};
|
|
12
21
|
};
|
|
13
22
|
/**
|
|
14
23
|
* A view's columns with what may be done to them: the grid's "+ Add column" lists the hidden ones, and a host's
|
|
@@ -22,23 +31,6 @@ export type ListColumnsConfig = {
|
|
|
22
31
|
onReset?: () => void;
|
|
23
32
|
dirty?: boolean;
|
|
24
33
|
};
|
|
25
|
-
export type ListColumnState = {
|
|
26
|
-
widths?: Record<string, number>;
|
|
27
|
-
hidden?: string[];
|
|
28
|
-
visible?: string[];
|
|
29
|
-
order?: string[];
|
|
30
|
-
/** Board only: ids that START a new line on the card. Absent = the board's
|
|
31
|
-
* default line-building (dates on their own line); present — even empty —
|
|
32
|
-
* is the user's explicit layout. The grid ignores it. */
|
|
33
|
-
breaks?: string[];
|
|
34
|
-
};
|
|
35
|
-
export declare const LIST_DEFAULT_MIN_WIDTH = 60;
|
|
36
|
-
/**
|
|
37
|
-
* The density vocabulary, shared by every view. How a view SPENDS it differs —
|
|
38
|
-
* the grid multiplies its pixel scale, the rows views widen their padding — so
|
|
39
|
-
* only the names live here; see `grid/core/grid-scale.ts`.
|
|
40
|
-
*/
|
|
41
|
-
export type ListDensity = "compact" | "default" | "spacious";
|
|
42
34
|
/**
|
|
43
35
|
* The decimal places a number column can be shown at, offered by BOTH doors onto
|
|
44
36
|
* the setting — the grid's header menu and the Layout drill-in's Columns panel.
|
|
@@ -72,6 +64,3 @@ export declare function resolveColumnOrder<Row>(declared: ListColumn<Row>[], ord
|
|
|
72
64
|
export declare function resolveVisibleColumns<Row>(declared: ListColumn<Row>[], state?: ListColumnState, viewId?: string): ListColumn<Row>[];
|
|
73
65
|
export declare function resolveColumnWidths<Row>(visible: ListColumn<Row>[], widths?: Record<string, number>): Record<string, number>;
|
|
74
66
|
export declare function prettifyOptionValue(value: string): string;
|
|
75
|
-
export declare function computeMinWidth(columns: ListColumn<never>[] | {
|
|
76
|
-
width: number;
|
|
77
|
-
}[], gutterPx: number): number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const LIST_DEFAULT_MIN_WIDTH = 60;
|
|
2
2
|
export const LIST_DECIMALS_CHOICES = [0, 1, 2, 3, 4];
|
|
3
3
|
export function columnHideable(col) {
|
|
4
4
|
return col.type !== "title";
|
|
@@ -90,6 +90,3 @@ export function resolveColumnWidths(visible, widths) {
|
|
|
90
90
|
export function prettifyOptionValue(value) {
|
|
91
91
|
return value.replace(/[_-]+/g, " ").replace(/\b\w/g, (character) => character.toUpperCase());
|
|
92
92
|
}
|
|
93
|
-
export function computeMinWidth(columns, gutterPx) {
|
|
94
|
-
return columns.reduce((sum, column) => sum + column.width, gutterPx);
|
|
95
|
-
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { RelationSource } from "../fields/relation-source-types.js";
|
|
3
|
-
import type { ListColumn, ListColumnType
|
|
3
|
+
import type { ListColumn, ListColumnType } from "./column-schema.js";
|
|
4
4
|
/**
|
|
5
5
|
* ONE declaration per column type — what the machinery may do with it.
|
|
6
6
|
*
|
|
@@ -75,20 +75,6 @@ export declare function typeRule(type: ListColumnType | undefined): GridTypeRule
|
|
|
75
75
|
* no list, or that presents no field to read its values, takes no paste, as it mounts no editor (`gridEditorKind`).
|
|
76
76
|
*/
|
|
77
77
|
export declare function gridPasteKind<Row>(col: ListColumn<Row>): GridPasteKind | null;
|
|
78
|
-
/**
|
|
79
|
-
* A relation value with the column's default KIND filled in.
|
|
80
|
-
*
|
|
81
|
-
* The rule itself is the contract's (`resolveRelationValue`), because a display
|
|
82
|
-
* core has to answer it without a column to look at. What the list adds is the
|
|
83
|
-
* one thing the contract has no word for: where the default kind comes from —
|
|
84
|
-
* `col.relation.entity`, the monomorphic column's single answer. The value's
|
|
85
|
-
* own `entity` still wins, which is the polymorphic case.
|
|
86
|
-
*
|
|
87
|
-
* The result is typed as `ListRelationValue` because the list's value is the
|
|
88
|
-
* contract's plus an optional per-value `icon`, so a resolved value that
|
|
89
|
-
* carried one still has it.
|
|
90
|
-
*/
|
|
91
|
-
export declare function resolveGridRelation<Row>(col: ListColumn<Row>, raw: unknown): ListRelationValue | null;
|
|
92
78
|
/**
|
|
93
79
|
* The column's candidates, each wearing the glyph its KIND wears everywhere
|
|
94
80
|
* else in the app — what the picker offers.
|
|
@@ -31,7 +31,7 @@ export function gridPasteKind(col) {
|
|
|
31
31
|
return col.field && col.type && isMultipleType(col.type) ? "list" : null;
|
|
32
32
|
return typeRule(col.type)?.paste ?? null;
|
|
33
33
|
}
|
|
34
|
-
|
|
34
|
+
function resolveGridRelation(col, raw) {
|
|
35
35
|
return resolveRelationValue(raw, col.relation?.entity);
|
|
36
36
|
}
|
|
37
37
|
export function gridRelationSource(col, entityIcon) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type FieldDef } from "@viewkitjs/fields";
|
|
2
|
+
import { type ViewsMessageResolver } from "../contract.js";
|
|
3
|
+
import type { ListColumnFormat } from "./column-format.js";
|
|
4
|
+
import type { ListColumn } from "./column-schema.js";
|
|
5
|
+
type PartColumnOptions = {
|
|
6
|
+
messages?: ViewsMessageResolver;
|
|
7
|
+
locale?: string;
|
|
8
|
+
};
|
|
9
|
+
/** A range end's figure, as the range writes it: its decimals, then its unit and its period ("EUR /yr", "/mo"), the
|
|
10
|
+
* words the whole range's cell draws after its figures, in the column's one suffix. */
|
|
11
|
+
export declare function rangeEndFormat(field: FieldDef): ListColumnFormat;
|
|
12
|
+
/** The part columns of one whole column: none unless it has a field whose stored type has parts, a value to read, and
|
|
13
|
+
* a single value (a lookup, a rollup or a list of values gets none). */
|
|
14
|
+
export declare function partColumnsOf<Row>(whole: ListColumn<Row>, opts?: PartColumnOptions): ListColumn<Row>[];
|
|
15
|
+
/** Each column, followed by its part columns. */
|
|
16
|
+
export declare function withPartColumns<Row>(columns: readonly ListColumn<Row>[], opts?: PartColumnOptions): ListColumn<Row>[];
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { countryName, isRangeValue, locationPart, namePart, RANGE_PARTS, } from "@viewkitjs/fields";
|
|
2
|
+
import { LOCATION_FILTER_PARTS, sortOrdersFor } from "@viewkitjs/fields/query";
|
|
3
|
+
import { resolveViewsMessage } from "../contract.js";
|
|
4
|
+
import { rangePeriodShort, rangeUnit } from "../fields/range-unit.js";
|
|
5
|
+
import { partKey, partLabel } from "./part-rows.js";
|
|
6
|
+
const GRID_PART_COLUMNS = {
|
|
7
|
+
location: LOCATION_FILTER_PARTS,
|
|
8
|
+
name: ["given", "family"],
|
|
9
|
+
range: RANGE_PARTS,
|
|
10
|
+
};
|
|
11
|
+
function readPart(type, value, part, locale) {
|
|
12
|
+
if (type === "name")
|
|
13
|
+
return namePart(value, part) || null;
|
|
14
|
+
if (type === "location") {
|
|
15
|
+
const text = locationPart(value, part);
|
|
16
|
+
if (!text)
|
|
17
|
+
return null;
|
|
18
|
+
return part === "countryCode" ? countryName(text, locale) : text;
|
|
19
|
+
}
|
|
20
|
+
if (type === "range")
|
|
21
|
+
return isRangeValue(value) ? value[part] : null;
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export function rangeEndFormat(field) {
|
|
25
|
+
const def = field;
|
|
26
|
+
const format = { style: "plain" };
|
|
27
|
+
if (def.validation?.integer)
|
|
28
|
+
format.decimals = 0;
|
|
29
|
+
else if (def.format?.decimals !== undefined)
|
|
30
|
+
format.decimals = def.format.decimals;
|
|
31
|
+
const suffix = [rangeUnit(def), rangePeriodShort(def)].filter(Boolean).join(" ");
|
|
32
|
+
if (suffix)
|
|
33
|
+
format.suffix = suffix;
|
|
34
|
+
return format;
|
|
35
|
+
}
|
|
36
|
+
export function partColumnsOf(whole, opts = {}) {
|
|
37
|
+
const { field, accessor } = whole;
|
|
38
|
+
if (!field || !accessor || whole.multiple || whole.partOf)
|
|
39
|
+
return [];
|
|
40
|
+
const limit = field.type === "location" ? field.parts : undefined;
|
|
41
|
+
const parts = GRID_PART_COLUMNS[field.type]?.filter((part) => !limit || limit.includes(part));
|
|
42
|
+
if (!parts)
|
|
43
|
+
return [];
|
|
44
|
+
const messages = opts.messages ?? resolveViewsMessage;
|
|
45
|
+
const locale = opts.locale ?? "en";
|
|
46
|
+
const label = typeof whole.header === "string" && whole.header ? whole.header : field.label;
|
|
47
|
+
const orders = sortOrdersFor(field.type);
|
|
48
|
+
const range = field.type === "range";
|
|
49
|
+
return parts.map((part) => ({
|
|
50
|
+
id: partKey(whole.id, part),
|
|
51
|
+
header: partLabel(label, field.type, part, messages),
|
|
52
|
+
type: range ? "number" : "text",
|
|
53
|
+
...(range ? { align: "right", format: rangeEndFormat(field) } : {}),
|
|
54
|
+
width: range ? 120 : 160,
|
|
55
|
+
defaultHidden: true,
|
|
56
|
+
accessor: (row) => readPart(field.type, accessor(row), part, locale),
|
|
57
|
+
...(whole.sortable !== false && orders.includes(part)
|
|
58
|
+
? { sortKey: partKey(field.key, part) }
|
|
59
|
+
: { sortable: false }),
|
|
60
|
+
...(whole.editable ? { editable: true, clearable: whole.clearable !== false } : {}),
|
|
61
|
+
...(whole.reasons ? { reasons: whole.reasons } : {}),
|
|
62
|
+
partOf: { column: whole.id, part, field, read: whole.editAccessor ?? accessor },
|
|
63
|
+
}));
|
|
64
|
+
}
|
|
65
|
+
export function withPartColumns(columns, opts = {}) {
|
|
66
|
+
return columns.flatMap((column) => [column, ...partColumnsOf(column, opts)]);
|
|
67
|
+
}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type FieldType } from "@viewkitjs/fields";
|
|
2
2
|
import { type ViewsMessageResolver } from "../contract.js";
|
|
3
|
-
/**
|
|
4
|
-
export
|
|
5
|
-
/** A row's key for one part: a column id (Filter) or a field key (Sort, Group), then the part. */
|
|
6
|
-
export declare function partKey(id: string, part: string): string;
|
|
7
|
-
/** `{ id }` for a whole-value key, `{ id, part }` for a part key; split at the LAST separator. */
|
|
8
|
-
export declare function parsePartKey(key: string): {
|
|
9
|
-
id: string;
|
|
10
|
-
part?: string;
|
|
11
|
-
};
|
|
3
|
+
/** The part-key grammar is fields' own: a list's column state names a part column by it. */
|
|
4
|
+
export { partKey, parsePartKey } from "@viewkitjs/fields/query";
|
|
12
5
|
/** The parts each type offers a Filter row for, in the order the rows are listed. A name's full name has none: the
|
|
13
6
|
* name's own row already reads it. */
|
|
14
7
|
export declare const FILTER_PART_ROWS: {
|
package/dist/model/part-rows.js
CHANGED
|
@@ -1,22 +1,16 @@
|
|
|
1
|
+
import { RANGE_PARTS } from "@viewkitjs/fields";
|
|
1
2
|
import { LOCATION_FILTER_PARTS, LOCATION_ORDERS } from "@viewkitjs/fields/query";
|
|
2
3
|
import { resolveViewsMessage } from "../contract.js";
|
|
3
|
-
export
|
|
4
|
-
export function partKey(id, part) {
|
|
5
|
-
return `${id}${PART_KEY_SEPARATOR}${part}`;
|
|
6
|
-
}
|
|
7
|
-
export function parsePartKey(key) {
|
|
8
|
-
const at = key.lastIndexOf(PART_KEY_SEPARATOR);
|
|
9
|
-
if (at < 0)
|
|
10
|
-
return { id: key };
|
|
11
|
-
return { id: key.slice(0, at), part: key.slice(at + PART_KEY_SEPARATOR.length) };
|
|
12
|
-
}
|
|
4
|
+
export { partKey, parsePartKey } from "@viewkitjs/fields/query";
|
|
13
5
|
export const FILTER_PART_ROWS = {
|
|
14
6
|
location: LOCATION_FILTER_PARTS,
|
|
15
7
|
name: ["given", "family"],
|
|
8
|
+
range: RANGE_PARTS,
|
|
16
9
|
};
|
|
17
10
|
export const SORT_PART_ROWS = {
|
|
18
|
-
location: LOCATION_ORDERS,
|
|
11
|
+
location: [...LOCATION_ORDERS, "postalCode"],
|
|
19
12
|
name: ["family", "given"],
|
|
13
|
+
range: RANGE_PARTS,
|
|
20
14
|
};
|
|
21
15
|
export const GROUP_PART_ROWS = {
|
|
22
16
|
location: LOCATION_ORDERS,
|
|
@@ -29,6 +23,7 @@ const PART_WORDS = {
|
|
|
29
23
|
postalCode: "views.editors.place-postal-postal",
|
|
30
24
|
},
|
|
31
25
|
name: { given: "views.editors.name-given", family: "views.editors.name-family" },
|
|
26
|
+
range: { low: "views.editors.range-low", high: "views.editors.range-high" },
|
|
32
27
|
};
|
|
33
28
|
export function partWord(type, part, messages = resolveViewsMessage) {
|
|
34
29
|
const words = PART_WORDS[type];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type FieldConventions } from "@viewkitjs/fields";
|
|
2
|
+
import { type ViewsMessageResolver } from "../contract.js";
|
|
3
|
+
import { type GridWriteResult } from "./column-capabilities.js";
|
|
4
|
+
import type { ListColumn } from "./column-schema.js";
|
|
5
|
+
/** One part's edit written as its whole: the part coerced as its column's type, a country typed as a name read into
|
|
6
|
+
* its code, the whole stored value with that part replaced, then judged as the whole field (`acceptFieldCommit`,
|
|
7
|
+
* `stored` the whole's stored value). Its value is the WHOLE value to commit. A column that is no part, or is not
|
|
8
|
+
* editable, is refused with the not-editable sentence. */
|
|
9
|
+
export declare function gridPartWrite<Row>(part: ListColumn<Row>, wholeStored: unknown, next: unknown, conventions: FieldConventions, options?: {
|
|
10
|
+
messages?: ViewsMessageResolver;
|
|
11
|
+
}): GridWriteResult;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { acceptFieldCommit, countryCodeOf, isEmptyName, isEmptyRange, LOCATION_PARTS, locationPart, withLocationPart, withNamePart, withRangeEnd, } from "@viewkitjs/fields";
|
|
2
|
+
import { resolveViewsMessage } from "../contract.js";
|
|
3
|
+
import { coerceWrite, columnEditRefusal } from "./column-capabilities.js";
|
|
4
|
+
function unwrap(next) {
|
|
5
|
+
if (next != null && typeof next === "object" && !Array.isArray(next) && "value" in next)
|
|
6
|
+
return next.value;
|
|
7
|
+
return next;
|
|
8
|
+
}
|
|
9
|
+
const blank = (value) => value == null || (typeof value === "string" && value.trim() === "");
|
|
10
|
+
function emptyWhole(type, value) {
|
|
11
|
+
if (type === "name")
|
|
12
|
+
return isEmptyName(value);
|
|
13
|
+
if (type === "location")
|
|
14
|
+
return LOCATION_PARTS.every((part) => locationPart(value, part) === "");
|
|
15
|
+
if (type === "range")
|
|
16
|
+
return isEmptyRange(value);
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
export function gridPartWrite(part, wholeStored, next, conventions, options = {}) {
|
|
20
|
+
const messages = options.messages ?? resolveViewsMessage;
|
|
21
|
+
const of = part.partOf;
|
|
22
|
+
if (!of || !part.editable)
|
|
23
|
+
return {
|
|
24
|
+
ok: false,
|
|
25
|
+
reason: columnEditRefusal(part, conventions, messages) ?? messages({ key: "views.grid.read-only-why" }),
|
|
26
|
+
};
|
|
27
|
+
const coerced = coerceWrite(part, unwrap(next), messages);
|
|
28
|
+
if (!coerced.ok)
|
|
29
|
+
return coerced;
|
|
30
|
+
let value = blank(coerced.value) ? null : coerced.value;
|
|
31
|
+
const type = of.field.type;
|
|
32
|
+
let whole;
|
|
33
|
+
if (type === "name") {
|
|
34
|
+
whole = withNamePart(wholeStored, of.part, value == null ? null : String(value));
|
|
35
|
+
}
|
|
36
|
+
else if (type === "location") {
|
|
37
|
+
if (of.part === "countryCode" && typeof value === "string")
|
|
38
|
+
value = countryCodeOf(value, [conventions.locale, "en"]) ?? value.trim();
|
|
39
|
+
whole = withLocationPart(wholeStored, of.part, value == null ? null : String(value));
|
|
40
|
+
}
|
|
41
|
+
else if (type === "range") {
|
|
42
|
+
const n = typeof value === "number" ? value : value == null ? null : Number(value);
|
|
43
|
+
whole = withRangeEnd(wholeStored, of.part, n);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
return { ok: false, reason: messages({ key: "views.grid.read-only-why" }) };
|
|
47
|
+
}
|
|
48
|
+
return acceptFieldCommit(of.field, emptyWhole(type, whole) ? null : whole, {
|
|
49
|
+
conventions,
|
|
50
|
+
stored: wholeStored,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ListAggregateKind, ListDateStyle, ListDateStyleOverrides, ListDurationStyle, ListDurationStyleOverrides, ListOptionColorOverrides, ListPercentDisplayOverrides, ListSelectColor, ListShowTimeOverrides } from "./column-schema.js";
|
|
2
2
|
import type { PercentDisplay } from "@viewkitjs/fields";
|
|
3
|
-
import type { BoardLaneSpec, FilterRelationRule } from "@viewkitjs/fields/query";
|
|
3
|
+
import type { BoardLaneSpec, FilterRelationRule, ListGroupSummaryPart } from "@viewkitjs/fields/query";
|
|
4
4
|
import type { MoneyReading } from "../fields/currency.js";
|
|
5
5
|
import type { ListColumnState, ListDensity } from "./column-state.js";
|
|
6
6
|
import type { TextFilterRule } from "../filters/text-filter.js";
|
|
7
7
|
import type { NumberFilterRule } from "../filters/number-filter.js";
|
|
8
8
|
import type { DateFilterRule } from "../filters/date-filter.js";
|
|
9
9
|
import type { RangeFilterRule } from "../filters/range-filter.js";
|
|
10
|
+
/** A group header's figures are fields' own, so a server reads a stored view without React. */
|
|
11
|
+
export { groupFigurePart, isGroupSummaryPart, normalizeGroupSummary, type ListGroupFigurePart, type ListGroupSummaryPart, } from "@viewkitjs/fields/query";
|
|
10
12
|
/**
|
|
11
13
|
* One column's filter rule. Tagged with its editor so the persisted blob stays
|
|
12
14
|
* readable as number / date / boolean rules land beside these — a stored rule
|
|
@@ -112,28 +114,6 @@ export type ListViewPrefs = {
|
|
|
112
114
|
* time. Empty = a bare group name, which is a legitimate choice. */
|
|
113
115
|
groupSummary: ListGroupSummaryPart[];
|
|
114
116
|
};
|
|
115
|
-
/** A figure after the list's first: the total under one column, named by its id (POR-1393). */
|
|
116
|
-
export type ListGroupFigurePart = `total:${string}`;
|
|
117
|
-
/** The figures a group header can carry: its count, and its totals. `total` is the list's FIRST figure, named after
|
|
118
|
-
* its own column in the menu; each later one is `total:<columnId>`. The first stays a position, not a column, so
|
|
119
|
-
* every view stored before the header offered more than one figure keeps the one it showed. */
|
|
120
|
-
export type ListGroupSummaryPart = "count" | "total" | ListGroupFigurePart;
|
|
121
|
-
/** The part that shows one figure: `total` for the list's first, `total:<columnId>` for every other. */
|
|
122
|
-
export declare function groupFigurePart(columnId: string, first: boolean): ListGroupSummaryPart;
|
|
123
|
-
/** Whether a stored value is a part a group header knows: `count`, `total`, or `total:` and a column id of 1–120
|
|
124
|
-
* characters. */
|
|
125
|
-
export declare function isGroupSummaryPart(value: unknown): value is ListGroupSummaryPart;
|
|
126
|
-
/**
|
|
127
|
-
* Reads a stored `groupSummary` back as a set.
|
|
128
|
-
*
|
|
129
|
-
* It was a single `"count" | "total"` before, so every persisted blob out there
|
|
130
|
-
* still holds a bare string — parsed here rather than migrated, because a view
|
|
131
|
-
* pref is not worth a migration. Keeps the parts it recognises and drops the
|
|
132
|
-
* rest, so a value it cannot read comes back as `[]`, a bare group name, never
|
|
133
|
-
* the default: a caller with no stored value applies
|
|
134
|
-
* `LIST_VIEW_PREF_DEFAULTS.groupSummary` itself before calling.
|
|
135
|
-
*/
|
|
136
|
-
export declare function normalizeGroupSummary(value: unknown): ListGroupSummaryPart[];
|
|
137
117
|
export declare const LIST_VIEW_PREF_DEFAULTS: ListViewPrefs;
|
|
138
118
|
/** Set or drop one column's rule, keeping the map sparse (null = no rule). */
|
|
139
119
|
export declare function setFilterRule(current: ListFilterRuleState, columnId: string, rule: ListFilterRule | null): ListFilterRuleState;
|
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const FIGURE_KEY_MAX = 120;
|
|
3
|
-
export function groupFigurePart(columnId, first) {
|
|
4
|
-
return first ? "total" : `${FIGURE_PREFIX}${columnId}`;
|
|
5
|
-
}
|
|
6
|
-
export function isGroupSummaryPart(value) {
|
|
7
|
-
if (value === "count" || value === "total")
|
|
8
|
-
return true;
|
|
9
|
-
if (typeof value !== "string" || !value.startsWith(FIGURE_PREFIX))
|
|
10
|
-
return false;
|
|
11
|
-
const key = value.length - FIGURE_PREFIX.length;
|
|
12
|
-
return key >= 1 && key <= FIGURE_KEY_MAX;
|
|
13
|
-
}
|
|
14
|
-
export function normalizeGroupSummary(value) {
|
|
15
|
-
const parts = Array.isArray(value) ? value : typeof value === "string" ? [value] : [];
|
|
16
|
-
return Array.from(new Set(parts.filter(isGroupSummaryPart)));
|
|
17
|
-
}
|
|
1
|
+
export { groupFigurePart, isGroupSummaryPart, normalizeGroupSummary, } from "@viewkitjs/fields/query";
|
|
18
2
|
export const LIST_VIEW_PREF_DEFAULTS = {
|
|
19
3
|
viewStyle: "grid",
|
|
20
4
|
viewStyleMobile: "rows",
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type { ListColumnState, ListDensity } from "./column-state.js";
|
|
2
|
-
import type { ListDateStyle, ListDurationStyle, ListSelectColor } from "./column-schema.js";
|
|
3
|
-
import type { PercentDisplay } from "@viewkitjs/fields";
|
|
4
2
|
import type { BoardLaneSpec } from "@viewkitjs/fields/query";
|
|
5
3
|
import type { MoneyReading } from "../fields/currency.js";
|
|
6
4
|
/**
|
|
@@ -97,31 +95,6 @@ export type ListMoneyBucket = {
|
|
|
97
95
|
};
|
|
98
96
|
export declare const EMPTY_MONEY_BUCKET: ListMoneyBucket;
|
|
99
97
|
export declare function moneyKey(listKey: string): string;
|
|
100
|
-
/**
|
|
101
|
-
* How a FIELD reads — the workspace's shared answer (system.field_settings),
|
|
102
|
-
* identical in every view and on every surface. The flat maps in
|
|
103
|
-
* `ListViewPrefs` are this shape spread per key, keyed by FIELD KEY.
|
|
104
|
-
*/
|
|
105
|
-
export type ListFieldFormatPrefs = {
|
|
106
|
-
decimals?: number;
|
|
107
|
-
currency?: string;
|
|
108
|
-
dateStyle?: ListDateStyle;
|
|
109
|
-
durationStyle?: ListDurationStyle;
|
|
110
|
-
withTime?: boolean;
|
|
111
|
-
optionColors?: Record<string, ListSelectColor>;
|
|
112
|
-
percentDisplay?: PercentDisplay;
|
|
113
|
-
};
|
|
114
|
-
/**
|
|
115
|
-
* One view's layout, fully resolved — every key this bucket can carry has a
|
|
116
|
-
* value here.
|
|
117
|
-
*
|
|
118
|
-
* Completeness is load-bearing, not tidiness. `layoutToFlat` emits all seven
|
|
119
|
-
* keys unconditionally and spreads them over the surface blob, so a key absent
|
|
120
|
-
* here arrived as `undefined` and silently beat the flat default it was meant
|
|
121
|
-
* to inherit. Two partial sources made the effective default depend on which
|
|
122
|
-
* view id a list had written under and whether the legacy hoist had run.
|
|
123
|
-
*/
|
|
124
|
-
export declare const LIST_LAYOUT_DEFAULTS: ListViewLayout;
|
|
125
98
|
/** What vertical borders resolve to for a view that has no answer of its own:
|
|
126
99
|
* the reader's default, or the shipped one when they never set it. */
|
|
127
100
|
export declare function verticalBordersDefault(defaults?: ListDefaults): boolean;
|
|
@@ -19,7 +19,6 @@ export declare const FAR_PATH_SEPARATOR = ".";
|
|
|
19
19
|
/** A far field's path, as the list's route answers its values: the relation's key (itself a two-hop path, `a.b`, for
|
|
20
20
|
* a rollup's second hop) and the far field's. */
|
|
21
21
|
export declare function farPathOf(relationKey: string, farKey: string): string;
|
|
22
|
-
export declare const RELATED_RECORDS_SECTION = "Related records";
|
|
23
22
|
/** A Related records row's key, from the relation's field key. */
|
|
24
23
|
export declare function relationFilterKey(fieldKey: string): string;
|
|
25
24
|
/** The relation's field key, back from a Related records row's key. */
|
|
@@ -5,7 +5,7 @@ export const FAR_PATH_SEPARATOR = ".";
|
|
|
5
5
|
export function farPathOf(relationKey, farKey) {
|
|
6
6
|
return `${relationKey}${FAR_PATH_SEPARATOR}${farKey}`;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const RELATED_RECORDS_SECTION = "Related records";
|
|
9
9
|
const RELATION_KEY_PREFIX = "relation:";
|
|
10
10
|
export function relationFilterKey(fieldKey) {
|
|
11
11
|
return `${RELATION_KEY_PREFIX}${fieldKey}`;
|
package/dist/model/row-icon.d.ts
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
1
|
import type { StatusSlot } from "@viewkitjs/fields/design/status-slots";
|
|
2
|
-
/**
|
|
3
|
-
* The glyph's tint. Semantic slots only — a row icon that carries color is
|
|
4
|
-
* saying something about STATE, which is the one thing worth spending color on
|
|
5
|
-
* here. Omit it (the overwhelmingly common case) and the chassis draws the
|
|
6
|
-
* glyph in its secondary text colour.
|
|
7
|
-
*/
|
|
8
|
-
export type ListRowIconTone = StatusSlot;
|
|
9
2
|
/** A bare glyph, optionally tinted. Bare on purpose: the row is ~37px, which an
|
|
10
|
-
* avatar component dwarfs.
|
|
3
|
+
* avatar component dwarfs. `tone` takes semantic slots only — a row icon that
|
|
4
|
+
* carries color is saying something about STATE, which is the one thing worth
|
|
5
|
+
* spending color on here. Omit it (the overwhelmingly common case) and the
|
|
6
|
+
* chassis draws the glyph in its secondary text colour. */
|
|
11
7
|
export type ListRowIcon = {
|
|
12
8
|
icon: string;
|
|
13
|
-
tone?:
|
|
9
|
+
tone?: StatusSlot;
|
|
14
10
|
};
|
|
15
11
|
/**
|
|
16
12
|
* What a list declares. Return the icon alone for the neutral default, or the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type FieldType } from "@viewkitjs/fields";
|
|
2
|
-
import { type FilterRelationRule, type FilterRule, type FilterTree, type ViewFieldReader } from "@viewkitjs/fields/query";
|
|
2
|
+
import { type FilterNode, type FilterRelationRule, type FilterRule, type FilterTree, type ViewFieldReader } from "@viewkitjs/fields/query";
|
|
3
3
|
import type { ListColumn } from "./column-schema.js";
|
|
4
4
|
import type { ListFilterRule, ListFilterRuleState } from "./preferences.js";
|
|
5
5
|
/** THE KEY A COLUMN IS KNOWN BY OFF THE GRID — its FIELD, when it has one, and
|
|
@@ -29,15 +29,41 @@ opts?: {
|
|
|
29
29
|
export declare function rootRulesByColumn<Row>(tree: FilterTree, columns: ListColumn<Row>[], opts?: {
|
|
30
30
|
parts?: boolean;
|
|
31
31
|
}): ListFilterRuleState;
|
|
32
|
-
/**
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
/** A filter tree as a panel edits it. */
|
|
33
|
+
export type FilterPanelState = {
|
|
34
|
+
/** How the root's items combine. */
|
|
35
|
+
op: FilterTree["op"];
|
|
36
|
+
/** One rule per row: a column's whole value under its id; with `parts`, a part row's under its part key. */
|
|
37
|
+
rules: ListFilterRuleState;
|
|
38
|
+
/** Every root item no row draws, whole and in its order: and/or/not groups, relation rules, a second rule on a row
|
|
39
|
+
* already drawn, and a rule no row can show (an operator its editor doesn't write, a field no column carries). */
|
|
40
|
+
rest: readonly FilterNode[];
|
|
41
|
+
};
|
|
42
|
+
/** A quick-filter panel's picks, by field key: an option's codes, a yes/no field's "true" or "false". */
|
|
43
|
+
export type QuickValues = Readonly<Record<string, readonly string[]>>;
|
|
44
|
+
/** A field a quick-filter panel offers: its key and the type its value is read as, one whose rule picks options. */
|
|
45
|
+
export type QuickValueField = {
|
|
46
|
+
key: string;
|
|
47
|
+
type: FieldType;
|
|
48
|
+
};
|
|
49
|
+
/** The tree as the panel draws it: a rule per column (and, with `parts`, per part row), and the rest kept whole. */
|
|
50
|
+
export declare function filterPanelFromTree<Row>(tree: FilterTree, columns: ListColumn<Row>[], opts?: {
|
|
51
|
+
parts?: boolean;
|
|
52
|
+
}): FilterPanelState;
|
|
53
|
+
/** The tree the panel's state says: the rows' rules in column order, then the rest as it was kept. A key no row
|
|
54
|
+
* names writes nothing. `treeFromFilterPanel(filterPanelFromTree(tree))` holds every rule `tree` held. */
|
|
55
|
+
export declare function treeFromFilterPanel<Row>(panel: FilterPanelState, columns: ListColumn<Row>[], opts?: {
|
|
36
56
|
parts?: boolean;
|
|
37
57
|
}): FilterTree;
|
|
58
|
+
/** The picks a quick-filter panel draws: each offered field's root rule that picks options, as its values. */
|
|
59
|
+
export declare function quickValuesFromTree(tree: FilterTree, fields: readonly QuickValueField[]): QuickValues;
|
|
60
|
+
/** The tree with the offered fields' picks written as ordinary root rules (a field with none picked has none);
|
|
61
|
+
* every other item kept, a rule on an offered field the panel can't show (an `is_none_of`) among them. */
|
|
62
|
+
export declare function withQuickValues(tree: FilterTree, fields: readonly QuickValueField[], values: QuickValues): FilterTree;
|
|
38
63
|
/** The root relation rules, by relation field key — the Filter panel's Related records rows (POR-704). */
|
|
39
64
|
export declare function rootRelationRules(tree: FilterTree): Record<string, FilterRelationRule>;
|
|
40
|
-
/** The tree with its root relation rules replaced by `rules`; every other rule and group untouched
|
|
65
|
+
/** The tree with its root relation rules replaced by `rules`; every other rule and group untouched, and a set-aside
|
|
66
|
+
* relation rule kept, since no row shows it. */
|
|
41
67
|
export declare function withRootRelationRules(tree: FilterTree, rules: Readonly<Record<string, FilterRelationRule>>): FilterTree;
|
|
42
68
|
/** Replace (or drop, on null) the root rule for one column, or with `part` its rule on that part of the value; groups
|
|
43
69
|
* untouched. */
|