@elaraai/east-ui 1.0.74 → 1.0.76

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 (71) hide show
  1. package/dist/src/collections/index.d.ts +1 -0
  2. package/dist/src/collections/index.d.ts.map +1 -1
  3. package/dist/src/collections/index.js +1 -0
  4. package/dist/src/collections/index.js.map +1 -1
  5. package/dist/src/collections/sheet/bridge.d.ts +265 -0
  6. package/dist/src/collections/sheet/bridge.d.ts.map +1 -0
  7. package/dist/src/collections/sheet/bridge.js +630 -0
  8. package/dist/src/collections/sheet/bridge.js.map +1 -0
  9. package/dist/src/collections/sheet/columns.d.ts +360 -0
  10. package/dist/src/collections/sheet/columns.d.ts.map +1 -0
  11. package/dist/src/collections/sheet/columns.js +99 -0
  12. package/dist/src/collections/sheet/columns.js.map +1 -0
  13. package/dist/src/collections/sheet/index.d.ts +207 -0
  14. package/dist/src/collections/sheet/index.d.ts.map +1 -0
  15. package/dist/src/collections/sheet/index.js +126 -0
  16. package/dist/src/collections/sheet/index.js.map +1 -0
  17. package/dist/src/collections/sheet/link.d.ts +392 -0
  18. package/dist/src/collections/sheet/link.d.ts.map +1 -0
  19. package/dist/src/collections/sheet/link.js +222 -0
  20. package/dist/src/collections/sheet/link.js.map +1 -0
  21. package/dist/src/collections/sheet/registers.d.ts +131 -0
  22. package/dist/src/collections/sheet/registers.d.ts.map +1 -0
  23. package/dist/src/collections/sheet/registers.js +119 -0
  24. package/dist/src/collections/sheet/registers.js.map +1 -0
  25. package/dist/src/collections/sheet/root.d.ts +179 -0
  26. package/dist/src/collections/sheet/root.d.ts.map +1 -0
  27. package/dist/src/collections/sheet/root.js +308 -0
  28. package/dist/src/collections/sheet/root.js.map +1 -0
  29. package/dist/src/collections/sheet/types.d.ts +6601 -0
  30. package/dist/src/collections/sheet/types.d.ts.map +1 -0
  31. package/dist/src/collections/sheet/types.js +744 -0
  32. package/dist/src/collections/sheet/types.js.map +1 -0
  33. package/dist/src/component.d.ts +2500 -0
  34. package/dist/src/component.d.ts.map +1 -1
  35. package/dist/src/component.js +6 -0
  36. package/dist/src/component.js.map +1 -1
  37. package/dist/src/index.d.ts +2 -2
  38. package/dist/src/index.d.ts.map +1 -1
  39. package/dist/src/index.js +2 -2
  40. package/dist/src/index.js.map +1 -1
  41. package/dist/src/internal.d.ts +4 -2
  42. package/dist/src/internal.d.ts.map +1 -1
  43. package/dist/src/internal.js +5 -2
  44. package/dist/src/internal.js.map +1 -1
  45. package/dist/src/platform/index.d.ts +1 -1
  46. package/dist/src/platform/index.d.ts.map +1 -1
  47. package/dist/src/platform/index.js +1 -1
  48. package/dist/src/platform/index.js.map +1 -1
  49. package/dist/src/platform/slice/impl.d.ts +17 -1
  50. package/dist/src/platform/slice/impl.d.ts.map +1 -1
  51. package/dist/src/platform/slice/impl.js +60 -12
  52. package/dist/src/platform/slice/impl.js.map +1 -1
  53. package/dist/src/platform/slice/index.d.ts +155 -10
  54. package/dist/src/platform/slice/index.d.ts.map +1 -1
  55. package/dist/src/platform/slice/index.js +37 -17
  56. package/dist/src/platform/slice/index.js.map +1 -1
  57. package/dist/src/runtime/collections/index.d.ts +1 -0
  58. package/dist/src/runtime/collections/index.d.ts.map +1 -1
  59. package/dist/src/runtime/collections/index.js +1 -0
  60. package/dist/src/runtime/collections/index.js.map +1 -1
  61. package/dist/src/runtime/collections/sheet.d.ts +89 -0
  62. package/dist/src/runtime/collections/sheet.d.ts.map +1 -0
  63. package/dist/src/runtime/collections/sheet.js +65 -0
  64. package/dist/src/runtime/collections/sheet.js.map +1 -0
  65. package/dist/src/slice/index.d.ts +97 -1
  66. package/dist/src/slice/index.d.ts.map +1 -1
  67. package/dist/test/collections/sheet.examples.d.ts +56 -0
  68. package/dist/test/collections/sheet.examples.d.ts.map +1 -0
  69. package/dist/test/collections/sheet.examples.js +725 -0
  70. package/dist/test/collections/sheet.examples.js.map +1 -0
  71. package/package.json +3 -3
@@ -0,0 +1,744 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ /**
6
+ * `Sheet` IR — the UIComponent-free types of the planning spreadsheet
7
+ * (`libs/east-ui/docs/proposals/Sheet Spec.md` §4).
8
+ *
9
+ * A sheet's rows are the host's structs, projected by the factory into a
10
+ * CLOSED wire row — an id, an `owned` flag and one cell per declared column
11
+ * — through the columns' reified accessors (the Table `valueFn` move, the
12
+ * Plan `derive` move). The host's row type `R` and the driver's row type `D`
13
+ * never appear here: everything the author writes over them is bridged by
14
+ * the factory into the closed context / cell / edit types below (§4.8), so
15
+ * the `Sheet` arm of `UIComponentType` references {@link SheetRootType}
16
+ * directly, like `Calendar` and `Blend`.
17
+ *
18
+ * This file holds only plain data and closed function types — no
19
+ * `UIComponentType` — so `component.ts` imports it without a cycle. The
20
+ * author-facing TYPED constructors (`Sheet.Types.Context(R, D)`, `Fill(T)`,
21
+ * `Patch(R)`, `Proposal(R)`, `Edit(R)`, `CheckContext(R)`) live here too:
22
+ * they are type-level twins of the wire types, instantiated per row type
23
+ * (the `Plan.Types.Series(R)` pattern).
24
+ *
25
+ * @packageDocumentation
26
+ */
27
+ import { ArrayType, AsyncFunctionType, BooleanType, DateTimeType, DictType, EastTypeType, FloatType, FunctionType, IntegerType, NullType, OptionType, StringType, StructType, VariantType, } from "@elaraai/east";
28
+ import { StatusValueType } from "../../feedback/status/types.js";
29
+ import { TickFormatType } from "../../format/types.js";
30
+ import { DensityType } from "../../style/interaction.js";
31
+ import { RowSourceType } from "../../contracts/source.js";
32
+ import { SliceChromeType, SliceStateType } from "../../platform/slice/index.js";
33
+ // ============================================================================
34
+ // Links — members, the typed link value, the cell
35
+ // ============================================================================
36
+ /**
37
+ * One member of a link half — what the link grammar resolves a token to
38
+ * (B§4.1).
39
+ *
40
+ * @remarks
41
+ * A member is never a bare string the host has to re-parse: a code that
42
+ * resolved against the register is `identified`, a `M2140-45` span is a
43
+ * `range` the register expands, a `4 × CNC lathe` count is `counted`, `TBC` is
44
+ * the dashed `placeholder`, and anything the grammar did not recognise is
45
+ * kept verbatim as `text` — typed entry is never blocked.
46
+ *
47
+ * @property identified - A register code (`"M2140"`)
48
+ * @property range - A span of codes, `from` to `to` (`"M2140-45"`, the upper bound completed)
49
+ * @property counted - A count of a countable member (`{ n: 4, key: "CNC lathe" }`)
50
+ * @property placeholder - The `TBC` placeholder
51
+ * @property text - Free text the grammar kept as typed
52
+ */
53
+ export const SheetMemberType = VariantType({
54
+ identified: StructType({ key: StringType }),
55
+ range: StructType({ from: StringType, to: StringType }),
56
+ counted: StructType({ n: IntegerType, key: StringType }),
57
+ placeholder: NullType,
58
+ text: StringType,
59
+ });
60
+ /**
61
+ * The typed link value — a directed hyperedge between two sets of members
62
+ * (B§4).
63
+ *
64
+ * @remarks
65
+ * A destination-only link is `from: []`; a source-only link is `to: []`, so
66
+ * the single-set data of B§4.2 needs no migration. The renderer's grammar is
67
+ * the kind's parse / print pair (`Sheet.link.parse` / `Sheet.link.print`).
68
+ *
69
+ * @property from - The source members
70
+ * @property to - The destination members
71
+ */
72
+ export const SheetLinkType = StructType({
73
+ from: ArrayType(SheetMemberType),
74
+ to: ArrayType(SheetMemberType),
75
+ });
76
+ /**
77
+ * One cell of the wire row — the Table's literal cell (#206) plus the
78
+ * typed link.
79
+ *
80
+ * @remarks
81
+ * `Null` is the blank cell. A scalar column's cell is the field's value at
82
+ * the column kind's primitive; a `set` / `link` column's cell is a
83
+ * {@link SheetLinkType} value, never a string.
84
+ *
85
+ * @property Null - The blank cell
86
+ * @property Boolean - A boolean value
87
+ * @property Integer - An integer value
88
+ * @property Float - A float value (a `quantity` column's cell)
89
+ * @property String - A string value (text · lookup · reference · enum · stamped)
90
+ * @property DateTime - A UTC-midnight date (a `date` column's cell)
91
+ * @property Link - A typed link (a `set` / `link` column's cell)
92
+ */
93
+ export const SheetCellType = VariantType({
94
+ Null: NullType,
95
+ Boolean: BooleanType,
96
+ Integer: IntegerType,
97
+ Float: FloatType,
98
+ String: StringType,
99
+ DateTime: DateTimeType,
100
+ Link: SheetLinkType,
101
+ });
102
+ /**
103
+ * One wire row — the closed projection of a host row.
104
+ *
105
+ * @remarks
106
+ * `cells` carries one entry per DECLARED column, always present (a blank
107
+ * cell is `Null`); a field of the host's row with no column never crosses
108
+ * the wire — the bridge (§4.8) reads it off the real row instead. Blank
109
+ * padding rows are renderer state, never rows.
110
+ *
111
+ * @property id - The row identity (the `id` field, or a keyed source's key)
112
+ * @property owned - `true` ⇒ the row belongs to the upstream system: no copilot, stamped columns read-only
113
+ * @property cells - Column key → cell, one entry per declared column
114
+ */
115
+ export const SheetRowType = StructType({
116
+ id: StringType,
117
+ owned: BooleanType,
118
+ cells: DictType(StringType, SheetCellType),
119
+ });
120
+ /**
121
+ * The sheet's own row COLLECTION — wire rows in sheet order.
122
+ *
123
+ * @remarks
124
+ * The Sheet is POSITIONAL like the Table: the planner's order is the source's
125
+ * order, so the collection is an `Array` (a `Dict` inline is refused at
126
+ * build time — a sorted map would sit rows in key order).
127
+ */
128
+ export const SheetRowsCollectionType = ArrayType(SheetRowType);
129
+ /**
130
+ * How a sheet's rows arrive — inline, or a window at a time — the shared
131
+ * row-source contract (#567 / #576) at the sheet's row collection.
132
+ */
133
+ export const SheetRowsType = RowSourceType(SheetRowsCollectionType);
134
+ // ============================================================================
135
+ // Registers and the driver
136
+ // ============================================================================
137
+ /**
138
+ * One register member — the grammar's vocabulary, and nothing else.
139
+ *
140
+ * @remarks
141
+ * There is no attribute bag: what a declaration needs from a driver row
142
+ * (`uom`, `sides`) is read by an accessor at build time and stored per driver
143
+ * key on the column that needs it ({@link SheetColumnKindType}); what a
144
+ * provider needs (`ctx.driver`) is the typed row, looked up by the bridge.
145
+ *
146
+ * @property key - What the grammar resolves (`"M2140"`, `"Line 2"`, `"CNC lathe"`)
147
+ * @property label - What a chip prints
148
+ * @property kind - The member kind (`"machine"` · `"line"` · `"family"` · `"activity"` · …)
149
+ * @property aliases - Alternative spellings the grammar also resolves (`"the 2 line"`)
150
+ * @property meta - Chip meta, shown when a half holds one chip (`"CNC lathe"`, `"line · 96"`)
151
+ * @property parent - A member's parent key — countable → identified resolution and "enumerate"
152
+ * @property tone - An `enum` member's valence dot
153
+ */
154
+ export const SheetRegisterMemberType = StructType({
155
+ key: StringType,
156
+ label: StringType,
157
+ kind: StringType,
158
+ aliases: ArrayType(StringType),
159
+ meta: OptionType(StringType),
160
+ parent: OptionType(StringType),
161
+ tone: OptionType(StatusValueType),
162
+ });
163
+ /**
164
+ * One register — a list of members a column resolves against.
165
+ *
166
+ * @property members - The members, in declaration order
167
+ */
168
+ export const SheetRegisterType = StructType({
169
+ members: ArrayType(SheetRegisterMemberType),
170
+ });
171
+ /**
172
+ * The driver — the `lookup` column whose member decides what the row does
173
+ * (B§1), with its members.
174
+ *
175
+ * @property column - The driver column's key
176
+ * @property members - The driver's register members
177
+ */
178
+ export const SheetDriverType = StructType({
179
+ column: StringType,
180
+ members: ArrayType(SheetRegisterMemberType),
181
+ });
182
+ // ============================================================================
183
+ // Link-column vocabulary — halves, sides, locks, counted members
184
+ // ============================================================================
185
+ /**
186
+ * One half of a link.
187
+ *
188
+ * @property from - The source half
189
+ * @property to - The destination half
190
+ */
191
+ export const SheetHalfType = VariantType({ from: NullType, to: NullType });
192
+ /**
193
+ * Which halves of a link column a driver member makes live (B§4.2) —
194
+ * `Sheet.Types.Sides`, the type a driver row's `sides` field carries.
195
+ *
196
+ * @property both - Both halves live
197
+ * @property from - Only the source half
198
+ * @property to - Only the destination half
199
+ * @property in - In place: the minus glyph, neither half moves anything
200
+ */
201
+ export const SheetSidesValueType = VariantType({ both: NullType, from: NullType, to: NullType, in: NullType });
202
+ /**
203
+ * How a `String`-backed link column writes its commit back (B§4.2).
204
+ *
205
+ * @property asTyped - The planner's text, verbatim
206
+ * @property canonical - Rewritten to register labels (evaluated by the renderer)
207
+ */
208
+ export const SheetStoreType = VariantType({ asTyped: NullType, canonical: NullType });
209
+ /**
210
+ * One member kind a link column accepts, and how (B§4.1).
211
+ *
212
+ * @property kind - The register member kind (`"machine"`, `"line"`, `"family"`, `"range"`)
213
+ * @property identified - The kind resolves by code (bare digits try the code prefix)
214
+ * @property countable - The kind takes the counted form (`N x kind`)
215
+ * @property resolvesTo - What a counted member of this kind resolves to later (`"machine"`)
216
+ */
217
+ export const SheetMemberKindType = StructType({
218
+ kind: StringType,
219
+ identified: BooleanType,
220
+ countable: BooleanType,
221
+ resolvesTo: OptionType(StringType),
222
+ });
223
+ /**
224
+ * The counted-member grammar a link column declares (B§4.1).
225
+ *
226
+ * @property forms - The accepted forms (`"N x kind"`, `"kind x N"`)
227
+ * @property ops - The multiplication tokens (`"x"`, `"X"`, `"*"`, `"×"`)
228
+ * @property appliesTo - Which member kinds may be counted (`"countable"`)
229
+ */
230
+ export const SheetMultipleType = StructType({
231
+ forms: ArrayType(StringType),
232
+ ops: ArrayType(StringType),
233
+ appliesTo: StringType,
234
+ });
235
+ /**
236
+ * One lock rule — the tag a half shows when the driver's sides value makes
237
+ * it read-only (B§4.2).
238
+ *
239
+ * @property half - The locked half
240
+ * @property when - The driver's sides value that locks it
241
+ * @property label - The lock tag text (`"external"`, `"in place"`)
242
+ */
243
+ export const SheetSideLockType = StructType({
244
+ half: SheetHalfType,
245
+ when: SheetSidesValueType,
246
+ label: StringType,
247
+ });
248
+ /**
249
+ * A link column's sides declaration — the driver's `sides` accessor APPLIED
250
+ * over the driver data, plus the lock rules.
251
+ *
252
+ * @remarks
253
+ * The accessor itself never reaches the wire: the builder reifies it against
254
+ * the driver's row type and the root evaluates it once per driver member, so
255
+ * the renderer looks a row's sides up by its driver key.
256
+ *
257
+ * @property byDriver - Driver member key → the sides value
258
+ * @property locks - The lock rules
259
+ */
260
+ export const SheetSidesType = StructType({
261
+ byDriver: DictType(StringType, SheetSidesValueType),
262
+ locks: ArrayType(SheetSideLockType),
263
+ });
264
+ /**
265
+ * A count of a countable member — the `n × CNC lathe` form (B§4.5) —
266
+ * `Sheet.Types.Counted`, what an arity rule proposes.
267
+ *
268
+ * @property n - The count
269
+ * @property key - The countable member's key
270
+ */
271
+ export const SheetCountedType = StructType({ n: IntegerType, key: StringType });
272
+ // ============================================================================
273
+ // The copilot — the WIRE context, fills, proposals, providers
274
+ // ============================================================================
275
+ /**
276
+ * The WIRE copilot context — what the renderer hands a bridged provider.
277
+ *
278
+ * @remarks
279
+ * The bridge (§4.8) rebuilds the author's typed context from it: `row` is
280
+ * decoded over the REAL source row (`rowById(rowId, offset)`), every entry of
281
+ * `rows` over its own (`rowsOffset + index`), and `driver` through the
282
+ * driver lookup — so a field of the host's row that has no column keeps its
283
+ * value in every provider, check, edit event and patch.
284
+ *
285
+ * @property rowIndex - Sheet position among REAL (resident) rows
286
+ * @property rowId - The row's id — the source lookup's argument
287
+ * @property offset - The row's source offset — the paged arm's `page` lookup
288
+ * @property row - The row as it would be if the open editor committed
289
+ * @property rows - The resident sheet, real rows in sheet order
290
+ * @property rowsOffset - The source offset of `rows[0]` (`0` on the inline arm)
291
+ * @property partial - `true` on a paged sheet whose source is not exhausted
292
+ * @property driver - The resolved driver member's key
293
+ * @property today - UTC midnight — so providers stay pure
294
+ */
295
+ export const SheetContextType = StructType({
296
+ rowIndex: IntegerType,
297
+ rowId: StringType,
298
+ offset: IntegerType,
299
+ row: DictType(StringType, SheetCellType),
300
+ rows: ArrayType(SheetRowType),
301
+ rowsOffset: IntegerType,
302
+ partial: BooleanType,
303
+ driver: OptionType(StringType),
304
+ today: DateTimeType,
305
+ });
306
+ /**
307
+ * The WIRE fill — one proposed cell value with its provenance (B§5.1).
308
+ *
309
+ * @property value - The proposed cell
310
+ * @property meta - The provenance line the strip prints
311
+ */
312
+ export const SheetFillType = StructType({ value: SheetCellType, meta: StringType });
313
+ /**
314
+ * The WIRE proposal — one proposed row as the cells a patch set, with its
315
+ * provenance (B§5.2).
316
+ *
317
+ * @property cells - The set fields, encoded; a field the patch left `none` is absent
318
+ * @property meta - The provenance line
319
+ */
320
+ export const SheetProposalType = StructType({ cells: DictType(StringType, SheetCellType), meta: StringType });
321
+ /**
322
+ * One fill provider on the wire — synchronous, or asynchronous (a model
323
+ * call). The factory picks the arm from the author's function value's East
324
+ * type and bridges it (§4.8).
325
+ *
326
+ * @property sync - Runs inline within the kind's latency
327
+ * @property async - The strip shows a pending chip; the result lands reactively, latest wins
328
+ */
329
+ export const SheetProviderType = VariantType({
330
+ sync: FunctionType([SheetContextType], OptionType(SheetFillType)),
331
+ async: AsyncFunctionType([SheetContextType], OptionType(SheetFillType)),
332
+ });
333
+ /**
334
+ * One row proposer on the wire — synchronous, or asynchronous.
335
+ *
336
+ * @property sync - Runs inline
337
+ * @property async - Pending chip; latest wins
338
+ */
339
+ export const SheetProposerType = VariantType({
340
+ sync: FunctionType([SheetContextType], ArrayType(SheetProposalType)),
341
+ async: AsyncFunctionType([SheetContextType], ArrayType(SheetProposalType)),
342
+ });
343
+ /**
344
+ * The copilot's row-proposal declaration (B§5.2).
345
+ *
346
+ * @property ahead - At most this many proposed rows below the anchor
347
+ * @property triggers - Column keys whose commit re-asks the proposers
348
+ * @property ghost - Draw proposed rows as hatched ghosts (the default)
349
+ * @property propose - The proposers, first that returns rows wins
350
+ */
351
+ export const SheetSuggestType = StructType({
352
+ ahead: IntegerType,
353
+ triggers: ArrayType(StringType),
354
+ ghost: BooleanType,
355
+ propose: ArrayType(SheetProposerType),
356
+ });
357
+ // ============================================================================
358
+ // Checks and arity — the WIRE check context
359
+ // ============================================================================
360
+ /**
361
+ * The WIRE check context — what a bridged member check receives (B§2).
362
+ *
363
+ * @property rowIndex - Sheet position among real rows
364
+ * @property rowId - The row's id (the source lookup's argument)
365
+ * @property offset - The row's source offset
366
+ * @property row - The row as it would be if the editor committed
367
+ * @property half - The half being edited
368
+ * @property member - The resolved member under check
369
+ */
370
+ export const SheetCheckContextType = StructType({
371
+ rowIndex: IntegerType,
372
+ rowId: StringType,
373
+ offset: IntegerType,
374
+ row: DictType(StringType, SheetCellType),
375
+ half: SheetHalfType,
376
+ member: SheetMemberType,
377
+ });
378
+ /**
379
+ * One member check on a link column.
380
+ *
381
+ * @property exists - The grammar's own: the member must resolve in the register
382
+ * @property custom - An author rule — `some(message)` flags the member, `none` passes
383
+ */
384
+ export const SheetCheckType = VariantType({
385
+ exists: NullType,
386
+ custom: FunctionType([SheetCheckContextType], OptionType(StringType)),
387
+ });
388
+ /**
389
+ * A link column's arity rule — how many members a half should hold, and
390
+ * which countable member to propose when none are named (B§4.6).
391
+ *
392
+ * @property half - The half the rule counts
393
+ * @property implied - The bridged rule over the wire context
394
+ */
395
+ export const SheetArityType = StructType({
396
+ half: SheetHalfType,
397
+ implied: FunctionType([SheetContextType], OptionType(SheetCountedType)),
398
+ });
399
+ // ============================================================================
400
+ // Column kinds
401
+ // ============================================================================
402
+ /**
403
+ * The column kind — what a column parses, displays and proposes (§3.2).
404
+ *
405
+ * @remarks
406
+ * Every function stored here takes the CLOSED context / cell types; the
407
+ * author's typed functions are bridged into them by the factory. The
408
+ * accessors that read the driver's row (`uom`, `sides.value`) are not stored
409
+ * at all — the builder reifies them against the driver's row type, the root
410
+ * applies them over the driver data, and they land as dictionaries keyed by
411
+ * the driver member's key.
412
+ *
413
+ * @property text - Free text
414
+ * @property date - A UTC-midnight date; `base` names the column relative entry counts from, `format` a display pattern
415
+ * @property quantity - A float with a unit per driver member (`uom`) and a display format
416
+ * @property integer - A whole number
417
+ * @property lookup - A scored register lookup — the driver column names the driver's register
418
+ * @property reference - A lookup over a flat member list
419
+ * @property enum - An upper-cased register word with a valence dot
420
+ * @property set - Comma members, the link grammar without an arrow
421
+ * @property link - `from > to` — the split cell (§3.4)
422
+ * @property stamped - A read-only code an upstream system owns
423
+ * @property custom - An author parse / print pair over the field's own payload
424
+ */
425
+ export const SheetColumnKindType = VariantType({
426
+ text: NullType,
427
+ date: StructType({ base: OptionType(StringType), format: OptionType(StringType) }),
428
+ quantity: StructType({ uom: OptionType(DictType(StringType, StringType)), format: OptionType(TickFormatType) }),
429
+ integer: NullType,
430
+ lookup: StructType({ register: StringType }),
431
+ reference: StructType({ register: StringType }),
432
+ enum: StructType({ register: StringType }),
433
+ set: StructType({
434
+ register: StringType,
435
+ members: ArrayType(SheetMemberKindType),
436
+ multiple: OptionType(SheetMultipleType),
437
+ store: SheetStoreType,
438
+ }),
439
+ link: StructType({
440
+ register: StringType,
441
+ members: ArrayType(SheetMemberKindType),
442
+ multiple: OptionType(SheetMultipleType),
443
+ sides: OptionType(SheetSidesType),
444
+ arity: OptionType(SheetArityType),
445
+ check: ArrayType(SheetCheckType),
446
+ store: SheetStoreType,
447
+ }),
448
+ stamped: StructType({ owner: OptionType(StringType) }),
449
+ custom: StructType({
450
+ accepts: StringType,
451
+ parse: FunctionType([StringType, SheetContextType], OptionType(SheetCellType)),
452
+ print: FunctionType([SheetCellType], StringType),
453
+ }),
454
+ });
455
+ /**
456
+ * One declared column.
457
+ *
458
+ * @remarks
459
+ * `dataType` is the row field's static type and `payloadType` the kind's
460
+ * payload (a custom kind's primitive), both as type values, so the renderer
461
+ * parses and prints without the host types (the Table `dataType` / `valueType`
462
+ * precedent). `editable` is `false` for a stamped column, a `value`-projected
463
+ * column, or by option.
464
+ *
465
+ * @property key - The column key — the row field it sits on
466
+ * @property header - The header line
467
+ * @property sub - The grey second header line
468
+ * @property width - CSS width
469
+ * @property kind - The column kind
470
+ * @property dataType - The row field's static type
471
+ * @property payloadType - The kind's payload type
472
+ * @property editable - Whether the sheet writes the column
473
+ * @property fill - The fill providers; the first that yields wins
474
+ */
475
+ export const SheetColumnType = StructType({
476
+ key: StringType,
477
+ header: StringType,
478
+ sub: OptionType(StringType),
479
+ width: OptionType(StringType),
480
+ kind: SheetColumnKindType,
481
+ dataType: EastTypeType,
482
+ payloadType: EastTypeType,
483
+ editable: BooleanType,
484
+ fill: ArrayType(SheetProviderType),
485
+ });
486
+ // ============================================================================
487
+ // Views, edits, selection, footer, style
488
+ // ============================================================================
489
+ /**
490
+ * One saved view — a slice-state snapshot plus the lens's context and reveals
491
+ * (B§8), evaluated live.
492
+ *
493
+ * @property id - Stable identity
494
+ * @property name - The tab name
495
+ * @property narrowing - The slice state the view was made with
496
+ * @property context - The lens's band width (`0` · `1` · `3`)
497
+ * @property reveals - Revealed row indices
498
+ */
499
+ export const SheetViewType = StructType({
500
+ id: StringType,
501
+ name: StringType,
502
+ narrowing: SliceStateType,
503
+ context: IntegerType,
504
+ reveals: ArrayType(IntegerType),
505
+ });
506
+ /**
507
+ * Where an edit came from — provenance a host can measure copilot uptake by (B§1).
508
+ *
509
+ * @property typed - The planner typed it
510
+ * @property pasted - A paste
511
+ * @property fill - A copilot fill was taken
512
+ * @property row - A row fill (⌘⏎)
513
+ * @property pattern - A proposed row was taken
514
+ */
515
+ export const SheetSourceType = VariantType({
516
+ typed: NullType,
517
+ pasted: NullType,
518
+ fill: NullType,
519
+ row: NullType,
520
+ pattern: NullType,
521
+ });
522
+ /**
523
+ * The WIRE edit event — a raw commit / insert / remove carrying the wire row
524
+ * (§3.7). The author sees the typed twin, `Sheet.Types.Edit(R)`, through the
525
+ * bridge.
526
+ *
527
+ * @property commit - One cell committed: the row AFTER the commit, and its source offset
528
+ * @property insert - A row appended after `afterRowId` (`none` ⇒ at the end)
529
+ * @property remove - Rows removed by id
530
+ */
531
+ export const SheetEditType = VariantType({
532
+ commit: StructType({ rowId: StringType, offset: IntegerType, key: StringType, row: SheetRowType, source: SheetSourceType }),
533
+ insert: StructType({ afterRowId: OptionType(StringType), row: SheetRowType, source: SheetSourceType }),
534
+ remove: StructType({ rowIds: ArrayType(StringType) }),
535
+ });
536
+ /**
537
+ * The selection ring's position — `Sheet.Types.Selection`.
538
+ *
539
+ * @property rowId - The selected row (`none` ⇒ a blank padding row or nothing)
540
+ * @property key - The selected column
541
+ */
542
+ export const SheetSelectionType = StructType({
543
+ rowId: OptionType(StringType),
544
+ key: OptionType(StringType),
545
+ });
546
+ /**
547
+ * One footer item (B§9).
548
+ *
549
+ * @property text - The footer text
550
+ * @property tone - Optional status tint
551
+ */
552
+ export const SheetFooterItemType = StructType({
553
+ text: StringType,
554
+ tone: OptionType(StatusValueType),
555
+ });
556
+ /**
557
+ * The Sheet style — uniform sizing (#320) and the gutter width.
558
+ *
559
+ * @property height - Definite height (`"fill"` fills the parent); the rows scroll within
560
+ * @property maxHeight - Max-height cap; content-sized up to it, then scrolls
561
+ * @property gutterWidth - The row-number gutter width, a CSS px size
562
+ */
563
+ export const SheetStyleType = StructType({
564
+ height: OptionType(StringType),
565
+ maxHeight: OptionType(StringType),
566
+ gutterWidth: OptionType(StringType),
567
+ });
568
+ // ============================================================================
569
+ // Root
570
+ // ============================================================================
571
+ /**
572
+ * The Sheet root IR — the whole planning spreadsheet, a CLOSED struct the
573
+ * `Sheet` arm of `UIComponentType` references directly.
574
+ *
575
+ * @remarks
576
+ * `onUpdate` never reaches the wire: the factory compiles it into `onEdit`
577
+ * (§4.7), and a typed `onEdit` is bridged into the same closed function
578
+ * (§4.8). `selection` present makes the selection controlled (§3.14).
579
+ *
580
+ * @property rows - The row source: inline wire rows, or a paged source of them
581
+ * @property columns - The declared columns, in order
582
+ * @property registers - Register name → register
583
+ * @property driver - The driver column and its members
584
+ * @property suggest - The row-proposal declaration
585
+ * @property slice - The slice chrome (search / filter / cohort); the lens reads the bound state
586
+ * @property views - The saved views
587
+ * @property activeView - The active view's id
588
+ * @property onViewsChange - Views changed (snapshot, rename, reorder, close)
589
+ * @property onEdit - The raw edit channel (`onUpdate` compiles to it)
590
+ * @property onSelect - The ring moved
591
+ * @property selection - Controlled selection when `some`
592
+ * @property newRowId - Overrides the renderer's id minting for inserted rows
593
+ * @property readOnly - The whole sheet is read-only
594
+ * @property blanks - Padding rows below the last real one (default 18)
595
+ * @property density - Row rhythm
596
+ * @property footer - Footer items
597
+ * @property style - Sizing and the gutter width
598
+ */
599
+ export const SheetRootType = StructType({
600
+ rows: SheetRowsType,
601
+ columns: ArrayType(SheetColumnType),
602
+ registers: DictType(StringType, SheetRegisterType),
603
+ driver: OptionType(SheetDriverType),
604
+ suggest: OptionType(SheetSuggestType),
605
+ slice: OptionType(SliceChromeType),
606
+ views: ArrayType(SheetViewType),
607
+ activeView: OptionType(StringType),
608
+ onViewsChange: OptionType(FunctionType([ArrayType(SheetViewType)], NullType)),
609
+ onEdit: OptionType(FunctionType([SheetEditType], NullType)),
610
+ onSelect: OptionType(FunctionType([SheetSelectionType], NullType)),
611
+ selection: OptionType(SheetSelectionType),
612
+ newRowId: OptionType(FunctionType([], StringType)),
613
+ readOnly: OptionType(BooleanType),
614
+ blanks: OptionType(IntegerType),
615
+ density: OptionType(DensityType),
616
+ footer: ArrayType(SheetFooterItemType),
617
+ style: OptionType(SheetStyleType),
618
+ });
619
+ // ============================================================================
620
+ // The TYPED constructors — the author's side (the `Plan.Types.Series(R)` pattern)
621
+ // ============================================================================
622
+ /**
623
+ * `Sheet.Types.Context(R, D)` — the copilot context as the author sees it:
624
+ * the host's row, the resident rows and the driver's row, all typed.
625
+ *
626
+ * @remarks
627
+ * A constructor rather than a generic wire type, so the row type lives
628
+ * structurally in a provider's signature: a provider written for one sheet
629
+ * is a compile error on another. Omit `D` on a sheet without a driver —
630
+ * `driver` is then `Option<Null>`, always `none`.
631
+ *
632
+ * @typeParam R - The host's row type
633
+ * @typeParam D - The driver's row type
634
+ * @param rowType - The row type value
635
+ * @param driverType - The driver's row type value (default `NullType`)
636
+ * @returns The concrete context `StructType`
637
+ *
638
+ * @property rowIndex - Sheet position among REAL (resident) rows
639
+ * @property row - The row as it would be if the open editor committed — the host's struct
640
+ * @property rows - The resident sheet, real rows in sheet order
641
+ * @property partial - `true` on a paged sheet whose source is not exhausted
642
+ * @property driver - The driver's row for `row` — typed, no attribute bag
643
+ * @property today - UTC midnight — so providers stay pure
644
+ */
645
+ export function SheetContextTypeFor(rowType, driverType) {
646
+ return StructType({
647
+ rowIndex: IntegerType,
648
+ row: rowType,
649
+ rows: ArrayType(rowType),
650
+ partial: BooleanType,
651
+ driver: OptionType((driverType ?? NullType)),
652
+ today: DateTimeType,
653
+ });
654
+ }
655
+ /**
656
+ * `Sheet.Types.Fill(T)` — one proposed value of a column's payload with its
657
+ * provenance, as a provider returns it.
658
+ *
659
+ * @typeParam T - The column kind's payload type (§3.2)
660
+ * @param payloadType - The payload type value
661
+ * @returns The concrete fill `StructType`
662
+ *
663
+ * @property value - The proposed value
664
+ * @property meta - The provenance line the strip prints
665
+ */
666
+ export function SheetFillTypeFor(payloadType) {
667
+ return StructType({ value: payloadType, meta: StringType });
668
+ }
669
+ /**
670
+ * `Sheet.Types.Patch(R)` — a row patch: every field of `R` as an `Option`,
671
+ * `none` meaning "left blank".
672
+ *
673
+ * @remarks
674
+ * Built with `Sheet.patch(R, { … })`, which takes the literal-record form of
675
+ * `R`'s fields and fills the omitted ones with `none`. The runner encodes the
676
+ * set fields that have editable columns; a set field with no column, a
677
+ * stamped column or a `value`-projected column is ignored.
678
+ *
679
+ * @typeParam R - The host's row type
680
+ * @param rowType - The row type value
681
+ * @returns The concrete patch `StructType`
682
+ */
683
+ export function SheetPatchTypeFor(rowType) {
684
+ const fields = {};
685
+ for (const [name, type] of Object.entries(rowType.fields)) {
686
+ fields[name] = OptionType(type);
687
+ }
688
+ return StructType(fields);
689
+ }
690
+ /**
691
+ * `Sheet.Types.Proposal(R)` — one proposed row: a patch plus its provenance.
692
+ *
693
+ * @typeParam R - The host's row type
694
+ * @param rowType - The row type value
695
+ * @returns The concrete proposal `StructType`
696
+ *
697
+ * @property patch - The fields the proposal sets (`Sheet.patch(R, …)`)
698
+ * @property meta - The provenance line
699
+ */
700
+ export function SheetProposalTypeFor(rowType) {
701
+ return StructType({ patch: SheetPatchTypeFor(rowType), meta: StringType });
702
+ }
703
+ /**
704
+ * `Sheet.Types.Edit(R)` — the raw edit event typed over the host's row
705
+ * (§3.7): `commit` carries the row AFTER the commit, `insert` the new row,
706
+ * `remove` the ids.
707
+ *
708
+ * @typeParam R - The host's row type
709
+ * @param rowType - The row type value
710
+ * @returns The concrete edit `VariantType`
711
+ *
712
+ * @property commit - One cell committed: `{ rowId, key, row, source }`
713
+ * @property insert - A row inserted after `afterRowId` (`none` ⇒ at the end): `{ afterRowId, row, source }`
714
+ * @property remove - Rows removed: `{ rowIds }`
715
+ */
716
+ export function SheetEditTypeFor(rowType) {
717
+ return VariantType({
718
+ commit: StructType({ rowId: StringType, key: StringType, row: rowType, source: SheetSourceType }),
719
+ insert: StructType({ afterRowId: OptionType(StringType), row: rowType, source: SheetSourceType }),
720
+ remove: StructType({ rowIds: ArrayType(StringType) }),
721
+ });
722
+ }
723
+ /**
724
+ * `Sheet.Types.CheckContext(R)` — what an author's member check sees (§3.4):
725
+ * the typed row, the half and the resolved member.
726
+ *
727
+ * @typeParam R - The host's row type
728
+ * @param rowType - The row type value
729
+ * @returns The concrete check-context `StructType`
730
+ *
731
+ * @property rowIndex - Sheet position among real rows
732
+ * @property row - The row as it would be if the editor committed
733
+ * @property half - The half being edited
734
+ * @property member - The resolved member under check
735
+ */
736
+ export function SheetCheckContextTypeFor(rowType) {
737
+ return StructType({
738
+ rowIndex: IntegerType,
739
+ row: rowType,
740
+ half: SheetHalfType,
741
+ member: SheetMemberType,
742
+ });
743
+ }
744
+ //# sourceMappingURL=types.js.map