@ai-matrx/records-ui 0.107.5 → 0.108.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 +7 -0
- package/dist/first-page.cjs +487 -0
- package/dist/first-page.cjs.map +1 -0
- package/dist/first-page.d.cts +35 -0
- package/dist/first-page.d.ts +35 -0
- package/dist/first-page.js +474 -0
- package/dist/first-page.js.map +1 -0
- package/dist/index.d.cts +98 -595
- package/dist/index.d.ts +98 -595
- package/dist/views-VPwb3QQk.d.cts +505 -0
- package/dist/views-VPwb3QQk.d.ts +505 -0
- package/package.json +15 -5
|
@@ -0,0 +1,505 @@
|
|
|
1
|
+
import { TableStyle, GroupAggregateSpec, GroupOrder, ChoiceColorLookup } from '@ai-matrx/design-system/data-table';
|
|
2
|
+
import { FieldFormatConfig } from '@ai-matrx/design-system/field-formats';
|
|
3
|
+
import { Field, TableDecorations, Uuid, RecordFilter, RuleExpression, RecordsResult, SavedViewRow } from '@ai-matrx/records';
|
|
4
|
+
import { RecordsClient } from '@ai-matrx/records/core';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* HOW A TABLE LOOKS — colors, formats and the frozen column.
|
|
8
|
+
*
|
|
9
|
+
* THE SPLIT, AND WHY IT IS THIS ONE. A Field declares WHAT it holds: a
|
|
10
|
+
* currency, a percent, a date, a person. A VIEW declares HOW that reads and
|
|
11
|
+
* what it is worth looking at: two decimal places or none, tint the row when
|
|
12
|
+
* Status is Blocked, keep Name in place while the rest scrolls. Airtable draws
|
|
13
|
+
* the line in exactly this place, and it has to be here: two people read one
|
|
14
|
+
* table two different ways, and neither reading is a fact about the records.
|
|
15
|
+
*
|
|
16
|
+
* So nothing in this module is a new column on a Field and nothing here needed
|
|
17
|
+
* a migration. A presentation lives on the saved-view record (`views.ts`), which
|
|
18
|
+
* is an ordinary record of an ordinary Table — which means an agent sets it
|
|
19
|
+
* through the same `records` tool it uses for everything else, and it travels
|
|
20
|
+
* with the table the way every other record does.
|
|
21
|
+
*
|
|
22
|
+
* A FIELD STILL GETS ITS MONEY RIGHT WITH NO CONFIGURATION. `formatForField`
|
|
23
|
+
* reads the Field's OWN declaration — a `currency` parity type with unit `$`, a
|
|
24
|
+
* `percent`, a `datetime` with `config.kind` — and returns the format that
|
|
25
|
+
* follows from it. The view's `formats` map only OVERRIDES that. A table nobody
|
|
26
|
+
* has ever styled still shows `$1,250.50` and `45%`.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* SECTIONS BY A FIELD — the view's own grouping.
|
|
31
|
+
*
|
|
32
|
+
* `field` is a Field KEY, exactly like `frozen` and the keys of `formats`,
|
|
33
|
+
* because a view is written against the Table's declaration and never against
|
|
34
|
+
* whatever id a screen happened to build its columns with.
|
|
35
|
+
*
|
|
36
|
+
* `aggregates` is keyed by Field key too, and `collapsed` holds the data
|
|
37
|
+
* table's own group keys (`s:Blocked`, `n:3`, `empty`), which is what the
|
|
38
|
+
* primitive emits and the only thing that survives a value rendering the same
|
|
39
|
+
* text as another.
|
|
40
|
+
*
|
|
41
|
+
* NOTHING HERE IS EVER CALLED `valueOf`, `toString` or `hasOwnProperty`: every
|
|
42
|
+
* object in JavaScript already has all three, so an optional field by one of
|
|
43
|
+
* those names is NEVER absent and a `config.valueOf ? … : …` check silently
|
|
44
|
+
* reads `Object.prototype`. It cost the primitive a whole grouping once.
|
|
45
|
+
*/
|
|
46
|
+
type GridGrouping = {
|
|
47
|
+
/** The Field key whose value makes the sections. */
|
|
48
|
+
field: string;
|
|
49
|
+
/** Per-Field-key subtotal on every section header. */
|
|
50
|
+
aggregates?: Record<string, GroupAggregateSpec>;
|
|
51
|
+
/** Section order. The primitive's default is `value-asc`; blanks sort last. */
|
|
52
|
+
order?: GroupOrder;
|
|
53
|
+
/** The sections this view keeps shut, by the primitive's own group key. */
|
|
54
|
+
collapsed?: string[];
|
|
55
|
+
/** The grouped column drawn as a column too. Absent = it steps aside (the headers name its value). */
|
|
56
|
+
showColumn?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* SUB-GROUPS (lane S1-PRIME VIEW-KEYS; ui-bench LISTS "sub-grouping"): up to two more levels
|
|
59
|
+
* inside each section, by Field key. At most three levels in all — the store refuses a fourth
|
|
60
|
+
* (`custom.view_declare`). A layout that draws one level ignores the rest; it never drops them,
|
|
61
|
+
* because this list is parsed and written back whole with the rest of the look.
|
|
62
|
+
*/
|
|
63
|
+
then?: GridSubGroup[];
|
|
64
|
+
/**
|
|
65
|
+
* DRILL (lane DRILL-TABLE-PRIMITIVE): the Dimension pivoted across the top — a Field key, or
|
|
66
|
+
* `<key>:<grain>` for a date cut into periods.
|
|
67
|
+
*/
|
|
68
|
+
across?: string;
|
|
69
|
+
/** DRILL: the period `field` is cut into when it is a date (`month`); the store keeps `field` a Field key. */
|
|
70
|
+
grain?: string;
|
|
71
|
+
/** The Measures shown ("what to display"), by the store's own keys (`count`, `sum_quantity`). */
|
|
72
|
+
show?: string[];
|
|
73
|
+
/** The drill trail, in order: each crumb a Dimension reference and the value it narrowed to. */
|
|
74
|
+
trail?: GridDrillStep[];
|
|
75
|
+
};
|
|
76
|
+
/** One crumb of a saved drill trail. `value: null` is "no value". */
|
|
77
|
+
type GridDrillStep = {
|
|
78
|
+
dim: string;
|
|
79
|
+
value: string | null;
|
|
80
|
+
};
|
|
81
|
+
/** One sub-group level: a Field key and its section order. */
|
|
82
|
+
type GridSubGroup = {
|
|
83
|
+
field: string;
|
|
84
|
+
order?: GroupOrder;
|
|
85
|
+
grain?: string;
|
|
86
|
+
};
|
|
87
|
+
/** Everything a view says about how its table LOOKS. */
|
|
88
|
+
type GridPresentation = {
|
|
89
|
+
/** Color-by-a-column, rules and manual highlights. */
|
|
90
|
+
style?: TableStyle;
|
|
91
|
+
/** Per-column format overrides, by the Field's key. */
|
|
92
|
+
formats?: Record<string, FieldFormatConfig>;
|
|
93
|
+
/**
|
|
94
|
+
* The columns that stay in place while the table scrolls sideways, by Field
|
|
95
|
+
* key. Only the LEADING run of the view's column order can actually freeze —
|
|
96
|
+
* the data table decides that, and declines rather than pinning a column at a
|
|
97
|
+
* guessed offset.
|
|
98
|
+
*/
|
|
99
|
+
frozen?: string[];
|
|
100
|
+
/** Collapsible sections by one Field, with subtotals on each header. */
|
|
101
|
+
grouping?: GridGrouping;
|
|
102
|
+
/**
|
|
103
|
+
* The width a person dragged a column to, by Field key. SPARSE on purpose —
|
|
104
|
+
* a view saved before widths existed carries none and still parses, and a
|
|
105
|
+
* column nobody resized is left to the table's own measurement.
|
|
106
|
+
*/
|
|
107
|
+
widths?: Record<string, number>;
|
|
108
|
+
/** The body row height this view remembers, in px. */
|
|
109
|
+
rowHeight?: number;
|
|
110
|
+
/**
|
|
111
|
+
* Field keys hidden from this view — the SAME hidden-column list the grid's
|
|
112
|
+
* own column picker holds, now given a place on the view so it survives a
|
|
113
|
+
* reload and a layout switch reads the identical set gallery and grid agree
|
|
114
|
+
* on, rather than a second "fields shown" list nobody kept in sync.
|
|
115
|
+
*/
|
|
116
|
+
hiddenFields?: string[];
|
|
117
|
+
/**
|
|
118
|
+
* THE FIELDS A CARD LEAVES OFF (board, list, gallery, calendar, timeline), by Field key — the
|
|
119
|
+
* card's own choice, kept apart from `hiddenFields` so a board's "Card fields" never hides the
|
|
120
|
+
* grid's columns when the view switches layout (v7 TABLE-EXPERIENCE, walk 2026-10-05). An empty
|
|
121
|
+
* list is a choice (every field shown); absent means the card never chose.
|
|
122
|
+
*/
|
|
123
|
+
cardHidden?: string[];
|
|
124
|
+
/**
|
|
125
|
+
* THE ORDER A PERSON DRAGGED THE COLUMNS INTO, by Field key (merge tranche 6a). Sparse like
|
|
126
|
+
* `widths`: a key it does not name keeps its Field's own place after the named ones, and a key
|
|
127
|
+
* whose Field is gone is skipped — a column order can never hide or invent a column.
|
|
128
|
+
*/
|
|
129
|
+
columnOrder?: string[];
|
|
130
|
+
/**
|
|
131
|
+
* The gallery's card size, remembered the same way the grid remembers its
|
|
132
|
+
* row height — a per-view look, not a global default.
|
|
133
|
+
*/
|
|
134
|
+
gallerySize?: "small" | "medium" | "large";
|
|
135
|
+
/**
|
|
136
|
+
* THIS VIEW'S OWN LAYOUT CHOICES, over the organization's `custom/grid_layout` knob (lane
|
|
137
|
+
* DEFAULT-GRID-PARITY, TABLE-PARITY D1 D5 D6). Absent means "whatever the organization
|
|
138
|
+
* says"; present is the view's word. `freezeFirst: false` is an explicit NO over an
|
|
139
|
+
* organization that freezes the first column — an empty `frozen` cannot say that.
|
|
140
|
+
*/
|
|
141
|
+
wrap?: boolean;
|
|
142
|
+
/** NOTION'S "WRAP COLUMN" (N5): the columns that wrap their text when the view as a whole does not. */
|
|
143
|
+
wrapColumns?: string[];
|
|
144
|
+
fit?: "auto" | "fit" | "scroll";
|
|
145
|
+
freezeFirst?: boolean;
|
|
146
|
+
/**
|
|
147
|
+
* THE SUMMARY BAR (TABLE-PARITY F1): Field key → the store measure shown under that column
|
|
148
|
+
* (`count`, `sum`, `avg`, `min`, `max`, `median`, `filled`, `empty`, `unique`), worked out
|
|
149
|
+
* by `custom.record_aggregate` over the whole table.
|
|
150
|
+
*/
|
|
151
|
+
summaries?: Record<string, string>;
|
|
152
|
+
/**
|
|
153
|
+
* WHERE THE FOOTER SITS (lane TABLE-PAGE-CHROME, owner 2026-09-25) — the row count and the
|
|
154
|
+
* pages: `sticky`, pinned to the bottom of the screen while the rows scroll (the older grid's
|
|
155
|
+
* way, and the default when a view says nothing), or `inline`, right after the last row with
|
|
156
|
+
* the page scrolling. Read by the Grid and a host's Sheet.
|
|
157
|
+
*/
|
|
158
|
+
footer?: FooterPlacement;
|
|
159
|
+
};
|
|
160
|
+
/** Where a grid's footer sits. */
|
|
161
|
+
type FooterPlacement = "sticky" | "inline";
|
|
162
|
+
/** What a view that says nothing gets — the older grid's pinned footer. */
|
|
163
|
+
declare const DEFAULT_FOOTER: FooterPlacement;
|
|
164
|
+
/** Where THIS view's footer sits, said or defaulted. */
|
|
165
|
+
declare function footerOf(p: GridPresentation | null | undefined): FooterPlacement;
|
|
166
|
+
declare const EMPTY_PRESENTATION: GridPresentation;
|
|
167
|
+
/** A frozen column needs a known width, or the table declines to freeze at all. */
|
|
168
|
+
declare const FROZEN_COLUMN_WIDTH = 200;
|
|
169
|
+
/**
|
|
170
|
+
* WHAT A ROW HEIGHT IS ALLOWED TO BE. Below the floor the text is clipped and
|
|
171
|
+
* no editor fits; above the ceiling one record fills the screen. A view asking
|
|
172
|
+
* for anything outside it is DROPPED rather than obeyed, because a saved look
|
|
173
|
+
* must not be able to make a table unreadable — and the Fields' own heights
|
|
174
|
+
* still draw, which is the tolerant half.
|
|
175
|
+
*/
|
|
176
|
+
declare const MIN_ROW_HEIGHT = 24;
|
|
177
|
+
declare const MAX_ROW_HEIGHT = 96;
|
|
178
|
+
/**
|
|
179
|
+
* Read a presentation out of whatever the view record holds — an object, or the
|
|
180
|
+
* JSON string a text field stores.
|
|
181
|
+
*
|
|
182
|
+
* Tolerant in exactly the way `parseTableStyle` is: an unreadable half is
|
|
183
|
+
* dropped and the rest still applies, because a table must keep drawing when
|
|
184
|
+
* one piece of its styling goes out of date.
|
|
185
|
+
*/
|
|
186
|
+
declare function parseGridPresentation(raw: unknown): GridPresentation;
|
|
187
|
+
/** True when nothing here would change how anything looks. */
|
|
188
|
+
declare function presentationIsEmpty(p: GridPresentation): boolean;
|
|
189
|
+
/** The string a view record stores. Empty string for "this view styles nothing". */
|
|
190
|
+
declare function presentationDocument(p: GridPresentation): string;
|
|
191
|
+
/**
|
|
192
|
+
* The format a Field's OWN declaration implies, before any view says anything.
|
|
193
|
+
*
|
|
194
|
+
* Returns `undefined` for a Field whose value the record renderer already draws
|
|
195
|
+
* better than a formatter could — a relation chip, a person, an attachment, a
|
|
196
|
+
* choice — because handing those to a text formatter would REPLACE a working
|
|
197
|
+
* control with a string.
|
|
198
|
+
*/
|
|
199
|
+
declare function formatForField(field: Field): FieldFormatConfig | undefined;
|
|
200
|
+
declare function currencyCodeFor(unit: string | null | undefined): string;
|
|
201
|
+
/**
|
|
202
|
+
* The color a value paints with when a view colors BY a column.
|
|
203
|
+
*
|
|
204
|
+
* NOTHING FAILS SILENTLY, so this never returns "no color" for a value that
|
|
205
|
+
* exists. The store keeps a list column's choices as records of another Table,
|
|
206
|
+
* and this grid has not read that Table's option colors, so the color is
|
|
207
|
+
* derived from the value's own text: the same word always gets the same color,
|
|
208
|
+
* different words get different ones, and `true` is green the way every
|
|
209
|
+
* checklist reads. When those option colors do land, this is the ONE function
|
|
210
|
+
* that changes and every screen follows.
|
|
211
|
+
*/
|
|
212
|
+
declare const colorFromTheValue: ChoiceColorLookup;
|
|
213
|
+
/**
|
|
214
|
+
* G1's TABLE-LEVEL COLORS (`custom.table_decorations` / `client.tableDecorations`),
|
|
215
|
+
* TRANSLATED INTO A `TableStyle` — the same document a saved view's own `presentation.style`
|
|
216
|
+
* is, so one resolver (`resolveTableStyle`, below) can treat "the table's colors" and "this
|
|
217
|
+
* view's colors" as two layers of the SAME thing instead of two unrelated systems.
|
|
218
|
+
*
|
|
219
|
+
* THE TRANSLATION IS NECESSARY AND IT IS THE ONLY ONE. G1 addresses a Field by its ID
|
|
220
|
+
* (REC-17 — a column renamed keeps its color), because it is the STORE's own door; a
|
|
221
|
+
* `TableStyle` addresses a Field by its KEY, because it reads straight off `row.document`,
|
|
222
|
+
* which is keyed by Field key. A rule or a color-by whose Field has been deleted (its id no
|
|
223
|
+
* longer resolves to a key) is dropped rather than crashing the whole style — a defect in
|
|
224
|
+
* one rule costs that rule, never the read.
|
|
225
|
+
*/
|
|
226
|
+
declare function styleFromDecorations(decorations: TableDecorations | null | undefined, fields: readonly Field[]): TableStyle;
|
|
227
|
+
/**
|
|
228
|
+
* THE ONE PRESENTATION RESOLVER every colored surface in this package reads —
|
|
229
|
+
* `Grid`, and (via `Card`) the kanban board, the calendar and the gallery.
|
|
230
|
+
*
|
|
231
|
+
* THE CLASS THIS CLOSES (lane UI-QUICK-1, TABLE-PARITY review, 2026-09-24). Threading
|
|
232
|
+
* `view.presentation.style` into `Card` closed the instance the CALENDAR-GALLERY bench
|
|
233
|
+
* found — a VIEW that had its own color-by looked right everywhere — but it left the
|
|
234
|
+
* class open: a table whose colors are the ORGANIZATION's decorations (G1's
|
|
235
|
+
* `custom.table_decorations` — "color rows by Account Type", "MAXED and NEAR rules" on
|
|
236
|
+
* Arman's own Coding Accounts table) and whose views never set a `presentation.style` of
|
|
237
|
+
* their own drew NOTHING, on the grid exactly as much as on every other layout, because
|
|
238
|
+
* nothing in this package had ever read G1's door at all.
|
|
239
|
+
*
|
|
240
|
+
* TWO LAYERS, ONE DOCUMENT. The table's decorations are the base coat — what every view
|
|
241
|
+
* of this table shows until a view says otherwise. A view's OWN `presentation.style` is
|
|
242
|
+
* an override, piece by piece: a view that only ever set manual row highlights still
|
|
243
|
+
* inherits the table's color-by and rules for everything it never touched, and a view
|
|
244
|
+
* that fully redecorated (its own `colorBy` AND its own `rules`) is not haunted by a
|
|
245
|
+
* table rule it meant to replace. Per-piece, never all-or-nothing, because a view is a
|
|
246
|
+
* LOOK on top of the table, not a wholesale substitute for it.
|
|
247
|
+
*/
|
|
248
|
+
declare function resolveTableStyle(decorations: TableDecorations | null | undefined, fields: readonly Field[], viewStyle: TableStyle | undefined): TableStyle;
|
|
249
|
+
|
|
250
|
+
/** The ways one saved view can be looked at (SCR-6; the timeline, lane VIEWS-AND-FIELDS TL). */
|
|
251
|
+
declare const VIEW_LAYOUTS: readonly ["grid", "kanban", "calendar", "gallery", "timeline", "list"];
|
|
252
|
+
type ViewLayout = (typeof VIEW_LAYOUTS)[number];
|
|
253
|
+
declare const LAYOUT_LABEL: Record<ViewLayout, string>;
|
|
254
|
+
/**
|
|
255
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
256
|
+
* WHAT EACH LAYOUT NEEDS FROM THE TABLE, AND HOW THE SCREEN SUPPLIES IT
|
|
257
|
+
* (lane DATA-V2-VIEWS-1, Arman 2026-09-28).
|
|
258
|
+
*
|
|
259
|
+
* THE DEFECT. A plain table opened as a Kanban said "A kanban board needs a Field to make its
|
|
260
|
+
* columns from … Add column, then Select — and it appears here." It told the person what to do
|
|
261
|
+
* instead of doing it, and on an AI platform it offered no AI. The ruling: ONE primitive, used by
|
|
262
|
+
* every view (`ViewNeeds`) — the empty state says in one plain sentence what is missing and what
|
|
263
|
+
* pressing will do, offers "Make it work" (the column is declared through the store's
|
|
264
|
+
* `custom.field_declare`, its key minted by the store, its name and choices editable before the
|
|
265
|
+
* press) and "Ask AI" (the agent does it through the same door, held for the person's approval by
|
|
266
|
+
* the organization's "Agent changes to this organization's data" setting).
|
|
267
|
+
*
|
|
268
|
+
* THE CENSUS — every layout this package draws, and what it reads:
|
|
269
|
+
* · grid nothing.
|
|
270
|
+
* · kanban a CHOICE column (its options become the board's columns). Blocking.
|
|
271
|
+
* · calendar a DATE column (it places each record on a day). Blocking.
|
|
272
|
+
* · gallery a FILE column for the card's picture. NOT blocking: the cards draw without one,
|
|
273
|
+
* so the offer sits above them instead of in place of them.
|
|
274
|
+
* · timeline a DATE column each bar starts on (the calendar's `dateField`). Blocking.
|
|
275
|
+
* `PAGE_VIEWS`' two extra values (dashboards, archived) read
|
|
276
|
+
* nothing a table can lack. This package ships no map layout; the day it does,
|
|
277
|
+
* `Record<ViewLayout, …>` below refuses to compile until the new layout names what it needs.
|
|
278
|
+
*/
|
|
279
|
+
type ViewNeedKind = "choice" | "date" | "file";
|
|
280
|
+
interface ViewNeed {
|
|
281
|
+
/** What the layout reads, as a kind a column declares (`offerableFields`). */
|
|
282
|
+
kind: ViewNeedKind;
|
|
283
|
+
/** The view key the made column is written onto, so the layout opens drawn by it. */
|
|
284
|
+
viewKey: "groupField" | "dateField" | "imageField";
|
|
285
|
+
/** True when the layout cannot draw at all without it (kanban, calendar). */
|
|
286
|
+
blocking: boolean;
|
|
287
|
+
/** The column the press makes, before the person edits it: its name, the store's word, its choices. */
|
|
288
|
+
starter: {
|
|
289
|
+
label: string;
|
|
290
|
+
type: "select" | "datetime" | "attachment";
|
|
291
|
+
options?: readonly string[];
|
|
292
|
+
};
|
|
293
|
+
/** The table HAS columns this layout can use and none is chosen: the sentence over the picker. */
|
|
294
|
+
pick: string;
|
|
295
|
+
/** One plain sentence: what the table is missing (all a person who may not change it is told). */
|
|
296
|
+
missing: string;
|
|
297
|
+
/** One plain sentence: what pressing Make it work will do, with the column's name. */
|
|
298
|
+
does: (label: string) => string;
|
|
299
|
+
/** The sentence an agent is asked with — the same act, said in words. */
|
|
300
|
+
ask: (label: string, options: readonly string[]) => string;
|
|
301
|
+
}
|
|
302
|
+
/** A list of words as a person says it: "To do, In progress and Done". */
|
|
303
|
+
declare function wordsList(words: readonly string[]): string;
|
|
304
|
+
declare const VIEW_NEEDS: Record<ViewLayout, ViewNeed | null>;
|
|
305
|
+
/**
|
|
306
|
+
* A NAME NO COLUMN OF THIS TABLE ALREADY HAS: the starter's own, else "Status 2", "Status 3"…
|
|
307
|
+
* A table that already holds a text column called Status must not be refused the board.
|
|
308
|
+
*/
|
|
309
|
+
declare function freeColumnName(wanted: string, taken: readonly string[]): string;
|
|
310
|
+
/** One sort clause. The Field's key and a direction; nothing else is a sort. */
|
|
311
|
+
interface ViewSort {
|
|
312
|
+
field: string;
|
|
313
|
+
direction: "asc" | "desc";
|
|
314
|
+
}
|
|
315
|
+
/** How a saved view is ordered: by hand, by its sort, or it never said (the same as sorted). */
|
|
316
|
+
type ViewOrder = "manual" | "sorted" | null;
|
|
317
|
+
/**
|
|
318
|
+
* THE DECLARATIVE SPEC. An agent writes this whole object; a person tweaks it.
|
|
319
|
+
* Every builder component in this package takes one of these as a prop.
|
|
320
|
+
*/
|
|
321
|
+
interface SavedViewSpec {
|
|
322
|
+
name: string;
|
|
323
|
+
/** The Table this view looks at. */
|
|
324
|
+
subject: Uuid;
|
|
325
|
+
layout: ViewLayout;
|
|
326
|
+
/** Kanban: the Field whose value becomes a column. */
|
|
327
|
+
groupField?: string | null;
|
|
328
|
+
/**
|
|
329
|
+
* Kanban: a number Field to TOTAL under each column heading. It lives on the VIEW for
|
|
330
|
+
* the same reason the colours do — two people read one board two ways and neither
|
|
331
|
+
* reading is a fact about the records.
|
|
332
|
+
*/
|
|
333
|
+
measure?: string | null;
|
|
334
|
+
/**
|
|
335
|
+
* Kanban: the Field whose values cut the board into SWIMLANES across the columns — a
|
|
336
|
+
* dispatcher's board by Status, one lane per Technician (S1-PRIME VIEW-KEYS). Never the
|
|
337
|
+
* column Field itself; the store refuses that.
|
|
338
|
+
*/
|
|
339
|
+
swimlaneField?: string | null;
|
|
340
|
+
/** Kanban: the columns this view keeps shut to a strip, by the column's stored value. */
|
|
341
|
+
collapsedColumns?: string[];
|
|
342
|
+
/** Calendar: the Field that places a record in the month. */
|
|
343
|
+
dateField?: string | null;
|
|
344
|
+
/** Timeline: the Field a record's bar starts on (`start_field`). */
|
|
345
|
+
startField?: string | null;
|
|
346
|
+
/** Calendar and timeline: the Field a record ends on (`end_field`). */
|
|
347
|
+
endField?: string | null;
|
|
348
|
+
/** Gallery: the Field shown large on the card. */
|
|
349
|
+
imageField?: string | null;
|
|
350
|
+
sorts?: ViewSort[];
|
|
351
|
+
/**
|
|
352
|
+
* HOW THE VIEW IS ORDERED (ORDER-FIX): `"manual"` — the positions a person set by hand ARE the
|
|
353
|
+
* view's sort, and it carries no `sorts`; `"sorted"` or null — by `sorts`. READ ONLY: the store
|
|
354
|
+
* writes "manual" only when the rows are placed (`custom.view_record_order_set`) and turns it
|
|
355
|
+
* off itself when a sort is saved, so no patch ever sends it (`viewSettingsPatch` does not).
|
|
356
|
+
*/
|
|
357
|
+
order?: ViewOrder;
|
|
358
|
+
/**
|
|
359
|
+
* The membership Rule. The STORE decides who is in this view; this is a
|
|
360
|
+
* reference to its Rule record, never a predicate this package evaluates.
|
|
361
|
+
*/
|
|
362
|
+
ruleId?: Uuid | null;
|
|
363
|
+
/**
|
|
364
|
+
* THE FLAT FILTER a digest or a notify rule wrote the view with — the one shape
|
|
365
|
+
* `custom.record_filter_sql` compiles, by Field KEY. A view saved in the bar has
|
|
366
|
+
* none; a view saved by `DigestScheduler` ("where Status is Open") does, and the
|
|
367
|
+
* grid and the board show exactly the records it names.
|
|
368
|
+
*/
|
|
369
|
+
filters?: RecordFilter;
|
|
370
|
+
/**
|
|
371
|
+
* S2-PRIME — THE VIEW'S OWN QUESTION, as the condition builder writes it: the store's Rule
|
|
372
|
+
* shape `{op, args}`, ALL / ANY / NOT groups nested to any depth, Fields by id. Kept in the
|
|
373
|
+
* definition as `where` and asked of the store unchanged — the grid's list door, the board's
|
|
374
|
+
* headings and the dashboard's numbers compile it into the one WHERE clause
|
|
375
|
+
* (`custom.record_filter_sql`). Never stored under `filters`: that key is the flat map the
|
|
376
|
+
* digests and the notifier read, and they would refuse it by name.
|
|
377
|
+
*/
|
|
378
|
+
where?: RuleExpression | null;
|
|
379
|
+
isDefault?: boolean;
|
|
380
|
+
/**
|
|
381
|
+
* HOW THIS VIEW LOOKS — its colors, its per-column formats and its frozen
|
|
382
|
+
* column (`presentation.ts`).
|
|
383
|
+
*
|
|
384
|
+
* It lives on the VIEW and not on the Fields because two people read one
|
|
385
|
+
* table two ways and neither reading is a fact about the records; it lives on
|
|
386
|
+
* a RECORD, not a new column, because that is what makes it something an
|
|
387
|
+
* agent writes with the same `records` tool as everything else.
|
|
388
|
+
*/
|
|
389
|
+
presentation?: GridPresentation;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* A saved view as it comes back out of the store, with its row's own id.
|
|
393
|
+
*
|
|
394
|
+
* It carries no version: `custom.view_declare` MERGES one key at a time, so two
|
|
395
|
+
* tabs pressing two different controls on one view both stand, and one control
|
|
396
|
+
* pressed in both keeps the latest — how Airtable and Notion keep a view change.
|
|
397
|
+
*/
|
|
398
|
+
interface SavedView extends SavedViewSpec {
|
|
399
|
+
id: Uuid;
|
|
400
|
+
/** Where the view came from when it was moved in (the mover, the S0 repair), else null. */
|
|
401
|
+
movedFrom: Record<string, unknown> | null;
|
|
402
|
+
}
|
|
403
|
+
/** THE TABLE'S DEFAULT VIEW: the first view that says it is. */
|
|
404
|
+
declare function defaultViewOf<V extends Pick<SavedView, "isDefault">>(views: readonly V[]): V | undefined;
|
|
405
|
+
/**
|
|
406
|
+
* WHICH FIELD EACH LAYOUT CAN BE DRAWN FROM, decided from the FIELD'S OWN
|
|
407
|
+
* DECLARATION and never from the values it happens to hold.
|
|
408
|
+
*
|
|
409
|
+
* A kanban makes columns from a choice: the Field whose value is one of a
|
|
410
|
+
* closed set (FLD-5 / FLD-6 — a pick-list is a Table, and a select stores the
|
|
411
|
+
* id of one of its records). Grouping by a free-text Field produces one column
|
|
412
|
+
* per record, which is not a board. A calendar places a record in time, so it
|
|
413
|
+
* needs a Field that holds a date.
|
|
414
|
+
*
|
|
415
|
+
* These two answers are here, beside the layouts, because the picker on the
|
|
416
|
+
* screen and any agent writing a view spec must agree about what is offerable.
|
|
417
|
+
*/
|
|
418
|
+
declare const LAYOUT_FIELD_KIND: Record<ViewLayout, ViewNeedKind | null>;
|
|
419
|
+
/**
|
|
420
|
+
* ─────────────────────────────────────────────────────────────────────────────
|
|
421
|
+
* WHICH VIEW A LINK NAMES — the address bar as a first-class control.
|
|
422
|
+
*
|
|
423
|
+
* 🚨 THE DEFECT THIS CLOSES (lane FRONT-DOOR, 2026-09-21; VERIFIER-8 HIGH-2).
|
|
424
|
+
* `/data/<table>?view=kanban` returned 200 and rendered THE GRID. The
|
|
425
|
+
* switcher was there, the four buttons worked, and the parameter was read by
|
|
426
|
+
* nobody — so a person who bookmarked a board, or sent one to a colleague, got
|
|
427
|
+
* a grid, and nothing on the screen said the view had been dropped. A link that
|
|
428
|
+
* does not land is the inbox-link defect (`activeRecordId`) and the dashboard
|
|
429
|
+
* defect (`activeDashboardId`) for the third time, so this is the same shape of
|
|
430
|
+
* fix: the URL names it, the page opens on it, and the URL FOLLOWS the person
|
|
431
|
+
* when they pick another.
|
|
432
|
+
*
|
|
433
|
+
* The dashboards are a fifth value and not a special case: to the person, "the
|
|
434
|
+
* dashboard" is one of the ways to look at this table, and a link to it has to
|
|
435
|
+
* work like a link to the board.
|
|
436
|
+
*/
|
|
437
|
+
/**
|
|
438
|
+
* 🚨 `archived` IS THE SIXTH VALUE, AND IT IS NOT A SPECIAL CASE EITHER (lane
|
|
439
|
+
* FIX-10A-ARCHIVE, 2026-09-22; VERIFIER-10 F4).
|
|
440
|
+
*
|
|
441
|
+
* Archiving a record used to be a ONE-WAY DOOR: the grid's row action soft-
|
|
442
|
+
* deletes correctly — `deleted_at` set, version bumped, nothing removed — and
|
|
443
|
+
* then no screen anywhere in the platform could bring it back. The store's
|
|
444
|
+
* `custom.record_restore` was there the whole time and did exactly the right
|
|
445
|
+
* thing; nothing reached it, because every read door answers live rows only.
|
|
446
|
+
*
|
|
447
|
+
* So the archive is a WAY OF LOOKING AT THIS TABLE, like the board and the
|
|
448
|
+
* dashboards, reached by the same row of buttons and named by the same
|
|
449
|
+
* `?view=` parameter — never a Trash area of the app somebody has to know
|
|
450
|
+
* exists, and never a per-table screen. Every Table inherits it the moment it
|
|
451
|
+
* is in this list.
|
|
452
|
+
*/
|
|
453
|
+
declare const PAGE_VIEWS: readonly ["grid", "kanban", "calendar", "gallery", "timeline", "list", "dashboards", "archived"];
|
|
454
|
+
type PageView = (typeof PAGE_VIEWS)[number];
|
|
455
|
+
declare const PAGE_VIEW_LABEL: Record<PageView, string>;
|
|
456
|
+
/**
|
|
457
|
+
* What a `?view=` value means, or `null` when it means nothing here.
|
|
458
|
+
*
|
|
459
|
+
* `null` is NOT "show the grid": the caller is expected to say that the link
|
|
460
|
+
* named something this table has no view for, because silently substituting a
|
|
461
|
+
* different view is exactly the defect above wearing a parser.
|
|
462
|
+
*/
|
|
463
|
+
declare function pageViewFromParam(raw: string | null | undefined): PageView | null;
|
|
464
|
+
/** The sentence a link that named a view nobody has says. Never silent. */
|
|
465
|
+
declare function unknownViewLine(raw: string): string;
|
|
466
|
+
/**
|
|
467
|
+
* THE SPEC AS THE ONE DEFINITION `platform.saved_view` HOLDS — the keys
|
|
468
|
+
* `custom.view_declare` documents, by Field KEY. `subject` is not in it: the door
|
|
469
|
+
* takes the Table as its own argument and writes `table_id` itself.
|
|
470
|
+
*/
|
|
471
|
+
declare function viewDocument(spec: SavedViewSpec): Record<string, unknown>;
|
|
472
|
+
/**
|
|
473
|
+
* One row of `custom.views` back into the spec a screen and an agent both read — THROUGH THE ONE
|
|
474
|
+
* ACCESSOR (`viewSettings`, viewKeys.ts), so every layout sees every declared key the same way.
|
|
475
|
+
*/
|
|
476
|
+
declare function viewFromRow(row: SavedViewRow): SavedView;
|
|
477
|
+
/**
|
|
478
|
+
* SAVE ONE NEW VIEW of a Table — the bar's "New view" and an agent's seed spec.
|
|
479
|
+
* One `view_declare` with no `view_id`; the answer is the new view's id.
|
|
480
|
+
*/
|
|
481
|
+
declare function declareView(client: Pick<RecordsClient, "viewDeclare">, spec: SavedViewSpec): Promise<RecordsResult<Uuid>>;
|
|
482
|
+
/**
|
|
483
|
+
* WRITE A CHANGE ONTO A SAVED VIEW, AND KEEP IT.
|
|
484
|
+
*
|
|
485
|
+
* `custom.view_declare` with the view's id MERGES: only the keys in `patch` are
|
|
486
|
+
* written, a key cleared to null is removed, and everything the patch did not
|
|
487
|
+
* name — the grid's own choices, a hand-set order, where the view was moved from,
|
|
488
|
+
* a colour set in another tab — stays exactly as it was (S0, 2026-09-23: the door
|
|
489
|
+
* used to rebuild the whole definition from what one press sent).
|
|
490
|
+
*
|
|
491
|
+
* There is no version to be stale against (VERIFIER-15 M4 is closed by the shape,
|
|
492
|
+
* not by a retry): a saved view is a person's own arrangement of a table, and
|
|
493
|
+
* their latest press on a control is the one that stands. A refusal — the view
|
|
494
|
+
* was removed, or belongs to a table this person cannot open — is handed back for
|
|
495
|
+
* the page to say through the one notice.
|
|
496
|
+
*/
|
|
497
|
+
declare function saveViewPatch(client: Pick<RecordsClient, "viewDeclare">, tableId: Uuid, viewId: Uuid, patch: Partial<SavedViewSpec>): Promise<RecordsResult<Uuid>>;
|
|
498
|
+
/**
|
|
499
|
+
* A PARTIAL change to a saved view, as the definition keys the door merges. Only
|
|
500
|
+
* the keys the caller actually changed are sent; a Field cleared (a board with no
|
|
501
|
+
* "Group by") is sent as `null`, which the door removes.
|
|
502
|
+
*/
|
|
503
|
+
declare function viewPatchDocument(patch: Partial<SavedViewSpec>): Record<string, unknown>;
|
|
504
|
+
|
|
505
|
+
export { styleFromDecorations as A, unknownViewLine as B, viewDocument as C, DEFAULT_FOOTER as D, EMPTY_PRESENTATION as E, type FooterPlacement as F, type GridPresentation as G, viewFromRow as H, viewPatchDocument as I, wordsList as J, LAYOUT_FIELD_KIND as L, MAX_ROW_HEIGHT as M, type PageView as P, type SavedView as S, type ViewOrder as V, type ViewSort as a, type SavedViewSpec as b, type ViewLayout as c, type ViewNeed as d, FROZEN_COLUMN_WIDTH as e, type GridGrouping as f, LAYOUT_LABEL as g, MIN_ROW_HEIGHT as h, PAGE_VIEWS as i, PAGE_VIEW_LABEL as j, VIEW_LAYOUTS as k, VIEW_NEEDS as l, type ViewNeedKind as m, colorFromTheValue as n, currencyCodeFor as o, declareView as p, defaultViewOf as q, footerOf as r, formatForField as s, freeColumnName as t, pageViewFromParam as u, parseGridPresentation as v, presentationDocument as w, presentationIsEmpty as x, resolveTableStyle as y, saveViewPatch as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-matrx/records-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.108.0",
|
|
4
4
|
"description": "The thirty-one canonical screens of the AI Matrx record store: grid, generated record form, field editor, table settings, relation picker, peek, views, import/export, custom fields, action inbox, history, comments, forms, charts, documents, record chat, AI field fill, checklists, bookings, offline capture, portals, public pages and embeds. Built on @ai-matrx/design-system's data table, carrying @ai-matrx/alchemy's menu, and reading and writing ONLY through @ai-matrx/records.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -71,7 +71,17 @@
|
|
|
71
71
|
"default": "./dist/pickers.cjs"
|
|
72
72
|
}
|
|
73
73
|
},
|
|
74
|
-
"./package.json": "./package.json"
|
|
74
|
+
"./package.json": "./package.json",
|
|
75
|
+
"./first-page": {
|
|
76
|
+
"import": {
|
|
77
|
+
"types": "./dist/first-page.d.ts",
|
|
78
|
+
"default": "./dist/first-page.js"
|
|
79
|
+
},
|
|
80
|
+
"require": {
|
|
81
|
+
"types": "./dist/first-page.d.cts",
|
|
82
|
+
"default": "./dist/first-page.cjs"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
75
85
|
},
|
|
76
86
|
"peerDependencies": {
|
|
77
87
|
"@dnd-kit/core": ">=6.3.1",
|
|
@@ -83,13 +93,13 @@
|
|
|
83
93
|
"@tanstack/react-query": ">=5.100.0"
|
|
84
94
|
},
|
|
85
95
|
"dependencies": {
|
|
96
|
+
"@ai-matrx/alchemy": "latest",
|
|
86
97
|
"@ai-matrx/content-ir": "latest",
|
|
87
98
|
"@ai-matrx/design-system": "latest",
|
|
88
|
-
"@ai-matrx/print": "latest",
|
|
89
99
|
"@ai-matrx/kit": "latest",
|
|
90
|
-
"@ai-matrx/
|
|
100
|
+
"@ai-matrx/print": "latest",
|
|
91
101
|
"@ai-matrx/realtime": "latest",
|
|
92
|
-
"@ai-matrx/
|
|
102
|
+
"@ai-matrx/records": "latest"
|
|
93
103
|
},
|
|
94
104
|
"devDependencies": {
|
|
95
105
|
"@arethetypeswrong/cli": "^0.18.5",
|