@viewkitjs/views 0.4.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +148 -0
  2. package/README.md +3 -3
  3. package/dist/atoms/DrillRows.d.ts +3 -0
  4. package/dist/atoms/DrillRows.js +25 -0
  5. package/dist/atoms/PanelRows.d.ts +5 -0
  6. package/dist/atoms/PanelRows.js +40 -0
  7. package/dist/atoms/PanelSearch.d.ts +2 -0
  8. package/dist/atoms/PanelSearch.js +21 -0
  9. package/dist/atoms/SelectionSheet.d.ts +3 -0
  10. package/dist/atoms/SelectionSheet.js +30 -0
  11. package/dist/atoms/defaults.js +12 -0
  12. package/dist/atoms/types.d.ts +117 -1
  13. package/dist/contract.d.ts +170 -9
  14. package/dist/contract.js +179 -2
  15. package/dist/figures.d.ts +5 -48
  16. package/dist/figures.js +1 -63
  17. package/dist/grid/chrome/GridColumnMenu.d.ts +3 -3
  18. package/dist/grid/chrome/GridColumnSortSection.d.ts +3 -3
  19. package/dist/grid/chrome/GridGroupMenu.d.ts +2 -2
  20. package/dist/grid/chrome/GridTable.js +1 -1
  21. package/dist/grid/useGridTablePrefs.d.ts +1 -1
  22. package/dist/grouping/sort-groups.d.ts +6 -7
  23. package/dist/model/aggregates.d.ts +3 -3
  24. package/dist/model/aggregates.js +17 -71
  25. package/dist/model/column-order.d.ts +2 -2
  26. package/dist/model/column-schema.d.ts +6 -7
  27. package/dist/model/column-state.d.ts +3 -20
  28. package/dist/model/column-state.js +1 -4
  29. package/dist/model/column-types.d.ts +1 -15
  30. package/dist/model/column-types.js +1 -1
  31. package/dist/model/part-columns.d.ts +1 -6
  32. package/dist/model/part-columns.js +1 -1
  33. package/dist/model/part-rows.d.ts +2 -9
  34. package/dist/model/part-rows.js +1 -10
  35. package/dist/model/preferences.d.ts +3 -23
  36. package/dist/model/preferences.js +1 -17
  37. package/dist/model/prefs-buckets.d.ts +0 -27
  38. package/dist/model/prefs-buckets.js +1 -1
  39. package/dist/model/relation-filters.d.ts +0 -1
  40. package/dist/model/relation-filters.js +1 -1
  41. package/dist/model/row-icon.d.ts +5 -9
  42. package/dist/model/view-rules.d.ts +32 -6
  43. package/dist/model/view-rules.js +94 -22
  44. package/dist/provider/ViewsProvider.d.ts +6 -2
  45. package/dist/provider/ViewsProvider.js +3 -2
  46. package/dist/provider/components.d.ts +16 -0
  47. package/dist/provider/context.d.ts +3 -1
  48. package/dist/provider/desktop.d.ts +3 -0
  49. package/dist/provider/desktop.js +7 -4
  50. package/dist/react.d.ts +2 -2
  51. package/dist/selection/SelectionBar.d.ts +18 -0
  52. package/dist/selection/SelectionBar.js +92 -0
  53. package/dist/selection/SelectionBarPhone.d.ts +3 -0
  54. package/dist/selection/SelectionBarPhone.js +14 -0
  55. package/dist/selection/bar-overflow.d.ts +12 -0
  56. package/dist/selection/bar-overflow.js +42 -0
  57. package/dist/selection/bar-parts.d.ts +15 -0
  58. package/dist/selection/bar-parts.js +17 -0
  59. package/dist/selection/index.d.ts +2 -0
  60. package/dist/selection/index.js +1 -0
  61. package/dist/selection/types.d.ts +3 -2
  62. package/dist/selection/verbs.d.ts +34 -0
  63. package/dist/selection/verbs.js +1 -0
  64. package/docs/contract.md +62 -8
  65. package/docs/getting-started.md +1 -1
  66. package/docs/guides/atoms.md +2 -1
  67. package/docs/guides/selection.md +32 -20
  68. package/docs/guides/the-grid.md +3 -2
  69. package/docs/guides/the-provider.md +4 -2
  70. package/docs/index.md +2 -0
  71. package/docs/install.md +4 -1
  72. package/docs/reference/grid.md +2 -2
  73. package/docs/reference/react.md +13 -3
  74. package/docs/reference/selection.md +10 -2
  75. package/docs/reference/views.md +25 -27
  76. package/package.json +22 -3
  77. package/skills/views/SKILL.md +1 -1
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode } from "react";
2
- import type { OrderDir } from "../../grouping/sort-groups.js";
2
+ import type { SortDirection } from "@viewkitjs/fields/query";
3
3
  import type { GridSortState } from "./GridColumnMenu.js";
4
4
  import type { ListGroupSummaryPart } from "../../model/preferences.js";
5
5
  import { type GridGroupMenuPart } from "./grid-group-menu-parts.js";
@@ -7,7 +7,7 @@ import { type GridGroupMenuPart } from "./grid-group-menu-parts.js";
7
7
  export type GridGroupSortOption = {
8
8
  value: string;
9
9
  label: string;
10
- defaultDir?: OrderDir;
10
+ defaultDir?: SortDirection;
11
11
  };
12
12
  /**
13
13
  * The group-header `…` menu — a second remote for the list's row sort (all
@@ -310,5 +310,5 @@ function GridTableContent(props) {
310
310
  }, railProbe: _jsx(GridRailProbe, { probeRef: rail.probeRef }), onGuardFocus: (which, from) => {
311
311
  if (!settlingFrom())
312
312
  enterGrid(which, from);
313
- }, body: _jsx(GridBody, { empty: empty, emptyState: emptyState, grouped: grouped, groups: groups, rows: flatRows, selectable: selectable, selecting: selecting, allSelected: sel.allSelected, someSelected: sel.someSelected, selectAll: sel.selectAll, clearSelection: sel.clear, isCollapsed: isCollapsed, countOf: countOf, sort: sort, sortOptions: sortOptions, groupSummary: groupSummary, onToggleGroup: onToggleGroup, onGroupSummaryChange: onGroupSummaryChange, renderGroupLabel: renderGroupLabel, onHideGroup: onHideGroup, groupMenu: props.groupMenu, figures: bandFigures, countNoun: countNoun, renderHeader: header, renderGroupCheckbox: groupCheckbox, renderRow: renderRow, wrapRows: wrapRows, renderFooter: footer, keptFor: keptFor, barIndexOf: aria.barIndex, ariaColCount: ariaTailIndex }), loadMore: loadMore?.hasMore ? _jsx(LoadMore, { onReveal: loadMore.onReveal, label: loadMore.label }) : undefined, selectionBar: selection?.renderBar(sel, batchApi) }) }) }));
313
+ }, body: _jsx(GridBody, { empty: empty, emptyState: emptyState, grouped: grouped, groups: groups, rows: flatRows, selectable: selectable, selecting: selecting, allSelected: sel.allSelected, someSelected: sel.someSelected, selectAll: sel.selectAll, clearSelection: sel.clear, isCollapsed: isCollapsed, countOf: countOf, sort: sort, sortOptions: sortOptions, groupSummary: groupSummary, onToggleGroup: onToggleGroup, onGroupSummaryChange: onGroupSummaryChange, renderGroupLabel: renderGroupLabel, onHideGroup: onHideGroup, groupMenu: props.groupMenu, figures: bandFigures, countNoun: countNoun, renderHeader: header, renderGroupCheckbox: groupCheckbox, renderRow: renderRow, wrapRows: wrapRows, renderFooter: footer, keptFor: keptFor, barIndexOf: aria.barIndex, ariaColCount: ariaTailIndex }), loadMore: loadMore?.hasMore ? _jsx(LoadMore, { onReveal: loadMore.onReveal, label: loadMore.label }) : undefined, selectionBar: selection?.renderBar?.(sel, batchApi) }) }) }));
314
314
  }
@@ -37,7 +37,7 @@ export declare function useGridTablePrefs<Row>({ prefs, setPrefs, columns, viewB
37
37
  onColumnStateChange: (next: ListColumnState) => void;
38
38
  groupSummary: ListGroupSummaryPart[];
39
39
  onGroupSummaryChange: (part: ListGroupSummaryPart, next: boolean) => void;
40
- aggregates: Record<string, ListAggregateKind>;
40
+ aggregates: Record<string, import("@viewkitjs/fields/query").FigureKind>;
41
41
  onAggregateChange: (columnId: string, kind: ListAggregateKind) => void;
42
42
  viewBacked: boolean;
43
43
  numberFormats: ListNumberFormatOverrides;
@@ -1,13 +1,12 @@
1
- /** `manual`: the reader's own order, by stored positions (POR-498). Only the
2
- * source list orders by it; `sortGroupEntries` below treats it as `name`. */
3
- export type OrderMode = "lifecycle" | "count" | "name" | "manual";
4
- export type OrderDir = "asc" | "desc";
1
+ import type { BucketOrderMode, SortDirection } from "@viewkitjs/fields/query";
2
+ /** How a grouping orders its sections, and which way. `manual`: the reader's own order, by stored positions
3
+ * (POR-498); only the source list orders by it, and `sortGroupEntries` below treats it as `name`. */
5
4
  export type OrderChoice = {
6
- mode: OrderMode;
7
- dir: OrderDir;
5
+ mode: BucketOrderMode;
6
+ dir: SortDirection;
8
7
  };
9
8
  /** The natural direction for a mode. Used to seed dir when a user picks a new mode. */
10
- export declare function defaultDirFor(mode: OrderMode): OrderDir;
9
+ export declare function defaultDirFor(mode: BucketOrderMode): SortDirection;
11
10
  type Entry<K extends string> = [key: K, items: unknown[]];
12
11
  export declare function sortGroupEntries<K extends string>(entries: Entry<K>[], opts: {
13
12
  order: OrderChoice;
@@ -3,9 +3,6 @@ import { type DisplayCurrency } from "../fields/currency.js";
3
3
  import type { ListAggregateKind, ListColumn } from "./column-schema.js";
4
4
  /** A figure's name, as the app words it: `views.grid.figure`. */
5
5
  export declare function aggregateLabel(kind: ListAggregateKind, messages?: ViewsMessageResolver): string;
6
- /** The figures' names in the package's English. A grid reads `aggregateLabel` with the provider's `messages`. */
7
- export declare const LIST_AGGREGATE_LABELS: Record<Exclude<ListAggregateKind, "none">, string>;
8
- export declare function gridColumnIsNumericAgg<Row>(col: ListColumn<Row>): boolean;
9
6
  /** A source list's footer (POR-470, POR-472): the keys whose figures the
10
7
  * database answered, and the reader's default currency — the key a money
11
8
  * column read in Original is totalled under. */
@@ -27,6 +24,9 @@ export declare function figureKeyOf<Row>(col: ListColumn<Row>, defaultCurrency:
27
24
  */
28
25
  export declare function aggregateOptions<Row>(col: ListColumn<Row>, sourced?: SourcedAggregates): ListAggregateKind[];
29
26
  export declare function resolveAggregateKind<Row>(col: ListColumn<Row>, prefs?: Readonly<Record<string, ListAggregateKind>>, sourced?: SourcedAggregates): ListAggregateKind;
27
+ /** A column's figure over some rows, worked out by `@viewkitjs/fields` (`figureOfValues`, `ratioOf`) from what the
28
+ * column reads: its cells for a count, the filled and the different ones; the figure it says to total
29
+ * (`aggAccessor`, else the cell) for the numbers; its two readers for a ratio. */
30
30
  export declare function computeAggregate<Row>(kind: ListAggregateKind, col: ListColumn<Row>, rows: readonly Row[]): number | null;
31
31
  /** One figure, and the currency it is in. */
32
32
  export type MoneyTotal = {
@@ -1,5 +1,5 @@
1
- import { isMultipleType, locationText, nameText, presentedDef, scalarOf, valueItems, valueKey, } from "@viewkitjs/fields";
2
- import { phoneMatchText } from "@viewkitjs/fields/phone";
1
+ import { presentedDef } from "@viewkitjs/fields";
2
+ import { figureNumber, figureOfNumbers, figureOfValues, ratioOf } from "@viewkitjs/fields/query";
3
3
  import { resolveViewsMessage } from "../contract.js";
4
4
  import { COLUMN_WIDE_CODE } from "../fields/denomination.js";
5
5
  import { convertMoney } from "../fields/money.js";
@@ -9,18 +9,8 @@ import { fieldKeyOf } from "./view-rules.js";
9
9
  export function aggregateLabel(kind, messages = resolveViewsMessage) {
10
10
  return messages({ key: "views.grid.figure", values: { kind } });
11
11
  }
12
- export const LIST_AGGREGATE_LABELS = {
13
- sum: aggregateLabel("sum"),
14
- avg: aggregateLabel("avg"),
15
- min: aggregateLabel("min"),
16
- max: aggregateLabel("max"),
17
- count: aggregateLabel("count"),
18
- filled: aggregateLabel("filled"),
19
- unique: aggregateLabel("unique"),
20
- ratio: aggregateLabel("ratio"),
21
- };
22
12
  const NUMERIC = new Set(["number", "percent", "currency"]);
23
- export function gridColumnIsNumericAgg(col) {
13
+ function gridColumnIsNumericAgg(col) {
24
14
  return !!col.aggAccessor || NUMERIC.has(fieldTypeOf(col));
25
15
  }
26
16
  export function figureKeyOf(col, defaultCurrency) {
@@ -85,74 +75,30 @@ export function resolveAggregateKind(col, prefs, sourced) {
85
75
  export function computeAggregate(kind, col, rows) {
86
76
  if (kind === "none")
87
77
  return null;
88
- if (kind === "count")
89
- return rows.length;
90
- if (kind === "filled" || kind === "unique") {
91
- const type = fieldTypeOf(col);
92
- if (col.multiple && isMultipleType(type)) {
93
- const lists = rows
94
- .map((row) => {
95
- const value = col.accessor?.(row);
96
- const one = Array.isArray(value) ? valueItems(value) : valueItems([value]);
97
- return one.map((item) => valueKey(item.value, type));
98
- })
99
- .filter((keys) => keys.length > 0);
100
- if (kind === "filled")
101
- return lists.length;
102
- return new Set(lists.map((keys) => [...keys].sort().join("|"))).size;
103
- }
104
- const asText = type === "location" ? locationText : type === "name" ? nameText : type === "phone" ? phoneMatchText : undefined;
105
- const written = (value) => !asText ? value : Array.isArray(value) ? value.map((item) => asText(item)).filter(Boolean) : asText(value);
106
- const values = rows
107
- .map((row) => written(col.accessor?.(row)))
108
- .filter((value) => value != null && value !== "" && !(Array.isArray(value) && value.length === 0));
109
- if (kind === "filled")
110
- return values.length;
111
- return new Set(values.map((value) => Array.isArray(value) ? value.map(String).sort().join("|") : String(value))).size;
112
- }
113
78
  if (kind === "ratio") {
114
- if (!col.ratio)
115
- return null;
116
- let num = 0;
117
- let den = 0;
118
- for (const row of rows) {
119
- num += col.ratio.numerator(row) ?? 0;
120
- den += col.ratio.denominator(row) ?? 0;
121
- }
122
- return den > 0 ? Math.round((num / den) * 100) : null;
79
+ const ratio = col.ratio;
80
+ return ratio ? ratioOf(rows.map((row) => [ratio.numerator(row), ratio.denominator(row)])) : null;
123
81
  }
124
- return reduceNumbers(kind, totalledNumbers(col, rows));
82
+ const reading = { type: fieldTypeOf(col), multiple: col.multiple, field: col.field };
83
+ if (NUMERIC_AGGREGATES.has(kind))
84
+ return figureOfValues(kind, totalledValues(col, rows), reading);
85
+ if (kind === "count")
86
+ return rows.length;
87
+ return figureOfValues(kind, rows.map((row) => col.accessor?.(row)), reading);
125
88
  }
126
89
  const NUMERIC_AGGREGATES = new Set(["sum", "avg", "min", "max"]);
127
- function totalledNumber(col, row) {
128
- const read = col.aggAccessor ? col.aggAccessor(row) : col.accessor?.(row);
129
- const value = col.field ? scalarOf(col.field, read) : read;
130
- const number = typeof value === "number" ? value : value == null || value === "" ? NaN : Number(value);
131
- return Number.isNaN(number) ? null : number;
90
+ function totalledValues(col, rows) {
91
+ return rows.map((row) => (col.aggAccessor ? col.aggAccessor(row) : col.accessor?.(row)));
132
92
  }
133
93
  function totalledNumbers(col, rows) {
134
94
  const numbers = [];
135
- for (const row of rows) {
136
- const number = totalledNumber(col, row);
95
+ for (const value of totalledValues(col, rows)) {
96
+ const number = figureNumber(value, col.field);
137
97
  if (number != null)
138
98
  numbers.push(number);
139
99
  }
140
100
  return numbers;
141
101
  }
142
- function reduceNumbers(kind, numbers) {
143
- if (numbers.length === 0)
144
- return null;
145
- switch (kind) {
146
- case "sum":
147
- return numbers.reduce((sum, value) => sum + value, 0);
148
- case "avg":
149
- return numbers.reduce((sum, value) => sum + value, 0) / numbers.length;
150
- case "min":
151
- return Math.min(...numbers);
152
- default:
153
- return Math.max(...numbers);
154
- }
155
- }
156
102
  export function moneyTotal(kind, col, rows, defaultCurrency) {
157
103
  if (!NUMERIC_AGGREGATES.has(kind) || fieldTypeOf(col) !== "currency")
158
104
  return undefined;
@@ -165,12 +111,12 @@ export function moneyTotal(kind, col, rows, defaultCurrency) {
165
111
  if (converted != null)
166
112
  numbers.push(converted);
167
113
  }
168
- const amount = reduceNumbers(kind, numbers);
114
+ const amount = figureOfNumbers(kind, numbers);
169
115
  return amount == null ? null : { amount, code: defaultCurrency };
170
116
  }
171
117
  if (col.currencyAccessor && !money)
172
118
  return null;
173
- const amount = reduceNumbers(kind, totalledNumbers(col, rows));
119
+ const amount = figureOfNumbers(kind, totalledNumbers(col, rows));
174
120
  if (amount == null)
175
121
  return null;
176
122
  const code = col.format?.currency;
@@ -1,5 +1,5 @@
1
1
  import { type FieldDef } from "@viewkitjs/fields";
2
- import type { OrderDir } from "../grouping/sort-groups.js";
2
+ import { type SortDirection } from "@viewkitjs/fields/query";
3
3
  import type { ListColumn } from "./column-schema.js";
4
4
  /** Whether a column offers Group by on a saved view: it presents a field of a type that splits a list, and the
5
5
  * list has not taken it out (`bucketable: false`). */
@@ -33,4 +33,4 @@ export declare function groupableOrders<Row>(columns: readonly ListColumn<Row>[]
33
33
  }): GroupableEntry<Row>[];
34
34
  /** The direction a sort by `field` opens in: a date newest first, a number or a yes/no largest first, text and
35
35
  * options A to Z; a date that looks ahead (a due date) soonest first. */
36
- export declare function sortDirFor(field: FieldDef): OrderDir;
36
+ export declare function sortDirFor(field: FieldDef): SortDirection;
@@ -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?: ListStatusSlot;
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 carrying `ratio`. */
80
- export type ListAggregateKind = "none" | "sum" | "avg" | "min" | "max" | "count" | "filled" | "unique" | "ratio";
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) => ListStatusSlot | null;
85
+ status?: (row: Row) => StatusSlot | null;
87
86
  };
88
87
  /**
89
88
  * Declarative column schema. A typed `accessor` uses standard chrome; `render`
@@ -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;
@@ -28,23 +31,6 @@ export type ListColumnsConfig = {
28
31
  onReset?: () => void;
29
32
  dirty?: boolean;
30
33
  };
31
- export type ListColumnState = {
32
- widths?: Record<string, number>;
33
- hidden?: string[];
34
- visible?: string[];
35
- order?: string[];
36
- /** Board only: ids that START a new line on the card. Absent = the board's
37
- * default line-building (dates on their own line); present — even empty —
38
- * is the user's explicit layout. The grid ignores it. */
39
- breaks?: string[];
40
- };
41
- export declare const LIST_DEFAULT_MIN_WIDTH = 60;
42
- /**
43
- * The density vocabulary, shared by every view. How a view SPENDS it differs —
44
- * the grid multiplies its pixel scale, the rows views widen their padding — so
45
- * only the names live here; see `grid/core/grid-scale.ts`.
46
- */
47
- export type ListDensity = "compact" | "default" | "spacious";
48
34
  /**
49
35
  * The decimal places a number column can be shown at, offered by BOTH doors onto
50
36
  * the setting — the grid's header menu and the Layout drill-in's Columns panel.
@@ -78,6 +64,3 @@ export declare function resolveColumnOrder<Row>(declared: ListColumn<Row>[], ord
78
64
  export declare function resolveVisibleColumns<Row>(declared: ListColumn<Row>[], state?: ListColumnState, viewId?: string): ListColumn<Row>[];
79
65
  export declare function resolveColumnWidths<Row>(visible: ListColumn<Row>[], widths?: Record<string, number>): Record<string, number>;
80
66
  export declare function prettifyOptionValue(value: string): string;
81
- export declare function computeMinWidth(columns: ListColumn<never>[] | {
82
- width: number;
83
- }[], gutterPx: number): number;
@@ -1,4 +1,4 @@
1
- export const LIST_DEFAULT_MIN_WIDTH = 60;
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, ListRelationValue } from "./column-schema.js";
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
- export function resolveGridRelation(col, raw) {
34
+ function resolveGridRelation(col, raw) {
35
35
  return resolveRelationValue(raw, col.relation?.entity);
36
36
  }
37
37
  export function gridRelationSource(col, entityIcon) {
@@ -1,12 +1,7 @@
1
- import { type FieldDef, type FieldType } from "@viewkitjs/fields";
1
+ import { type FieldDef } from "@viewkitjs/fields";
2
2
  import { type ViewsMessageResolver } from "../contract.js";
3
3
  import type { ListColumnFormat } from "./column-format.js";
4
4
  import type { ListColumn } from "./column-schema.js";
5
- /** The parts each stored type offers a column for, in the order "+ Add column" lists them. A place's street has none:
6
- * ViewKit's part tables don't list it, and Attio offers none. */
7
- export declare const GRID_PART_COLUMNS: {
8
- readonly [K in FieldType]?: readonly string[];
9
- };
10
5
  type PartColumnOptions = {
11
6
  messages?: ViewsMessageResolver;
12
7
  locale?: string;
@@ -3,7 +3,7 @@ import { LOCATION_FILTER_PARTS, sortOrdersFor } from "@viewkitjs/fields/query";
3
3
  import { resolveViewsMessage } from "../contract.js";
4
4
  import { rangePeriodShort, rangeUnit } from "../fields/range-unit.js";
5
5
  import { partKey, partLabel } from "./part-rows.js";
6
- export const GRID_PART_COLUMNS = {
6
+ const GRID_PART_COLUMNS = {
7
7
  location: LOCATION_FILTER_PARTS,
8
8
  name: ["given", "family"],
9
9
  range: RANGE_PARTS,
@@ -1,14 +1,7 @@
1
1
  import { type FieldType } from "@viewkitjs/fields";
2
2
  import { type ViewsMessageResolver } from "../contract.js";
3
- /** Joins a row's id and its part. A part never holds it, so a key splits at its last one. */
4
- export declare const PART_KEY_SEPARATOR = "::";
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: {
@@ -1,16 +1,7 @@
1
1
  import { RANGE_PARTS } from "@viewkitjs/fields";
2
2
  import { LOCATION_FILTER_PARTS, LOCATION_ORDERS } from "@viewkitjs/fields/query";
3
3
  import { resolveViewsMessage } from "../contract.js";
4
- export const PART_KEY_SEPARATOR = "::";
5
- export function partKey(id, part) {
6
- return `${id}${PART_KEY_SEPARATOR}${part}`;
7
- }
8
- export function parsePartKey(key) {
9
- const at = key.lastIndexOf(PART_KEY_SEPARATOR);
10
- if (at < 0)
11
- return { id: key };
12
- return { id: key.slice(0, at), part: key.slice(at + PART_KEY_SEPARATOR.length) };
13
- }
4
+ export { partKey, parsePartKey } from "@viewkitjs/fields/query";
14
5
  export const FILTER_PART_ROWS = {
15
6
  location: LOCATION_FILTER_PARTS,
16
7
  name: ["given", "family"],
@@ -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
- const FIGURE_PREFIX = "total:";
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;
@@ -5,7 +5,7 @@ export const EMPTY_MONEY_BUCKET = Object.freeze({
5
5
  export function moneyKey(listKey) {
6
6
  return `list:${listKey}:money`;
7
7
  }
8
- export const LIST_LAYOUT_DEFAULTS = {
8
+ const LIST_LAYOUT_DEFAULTS = {
9
9
  columns: {},
10
10
  density: "default",
11
11
  verticalBorders: false,
@@ -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
- export const RELATED_RECORDS_SECTION = "Related records";
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}`;
@@ -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?: ListRowIconTone;
9
+ tone?: StatusSlot;
14
10
  };
15
11
  /**
16
12
  * What a list declares. Return the icon alone for the neutral default, or the