@elaraai/east-ui 1.0.73 → 1.0.75
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/dist/src/collections/index.d.ts +1 -0
- package/dist/src/collections/index.d.ts.map +1 -1
- package/dist/src/collections/index.js +1 -0
- package/dist/src/collections/index.js.map +1 -1
- package/dist/src/collections/sheet/bridge.d.ts +265 -0
- package/dist/src/collections/sheet/bridge.d.ts.map +1 -0
- package/dist/src/collections/sheet/bridge.js +630 -0
- package/dist/src/collections/sheet/bridge.js.map +1 -0
- package/dist/src/collections/sheet/columns.d.ts +360 -0
- package/dist/src/collections/sheet/columns.d.ts.map +1 -0
- package/dist/src/collections/sheet/columns.js +99 -0
- package/dist/src/collections/sheet/columns.js.map +1 -0
- package/dist/src/collections/sheet/index.d.ts +207 -0
- package/dist/src/collections/sheet/index.d.ts.map +1 -0
- package/dist/src/collections/sheet/index.js +126 -0
- package/dist/src/collections/sheet/index.js.map +1 -0
- package/dist/src/collections/sheet/link.d.ts +392 -0
- package/dist/src/collections/sheet/link.d.ts.map +1 -0
- package/dist/src/collections/sheet/link.js +222 -0
- package/dist/src/collections/sheet/link.js.map +1 -0
- package/dist/src/collections/sheet/registers.d.ts +131 -0
- package/dist/src/collections/sheet/registers.d.ts.map +1 -0
- package/dist/src/collections/sheet/registers.js +119 -0
- package/dist/src/collections/sheet/registers.js.map +1 -0
- package/dist/src/collections/sheet/root.d.ts +179 -0
- package/dist/src/collections/sheet/root.d.ts.map +1 -0
- package/dist/src/collections/sheet/root.js +308 -0
- package/dist/src/collections/sheet/root.js.map +1 -0
- package/dist/src/collections/sheet/types.d.ts +6601 -0
- package/dist/src/collections/sheet/types.d.ts.map +1 -0
- package/dist/src/collections/sheet/types.js +744 -0
- package/dist/src/collections/sheet/types.js.map +1 -0
- package/dist/src/component.d.ts +2500 -0
- package/dist/src/component.d.ts.map +1 -1
- package/dist/src/component.js +6 -0
- package/dist/src/component.js.map +1 -1
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/internal.d.ts +4 -2
- package/dist/src/internal.d.ts.map +1 -1
- package/dist/src/internal.js +5 -2
- package/dist/src/internal.js.map +1 -1
- package/dist/src/platform/index.d.ts +1 -1
- package/dist/src/platform/index.d.ts.map +1 -1
- package/dist/src/platform/index.js +1 -1
- package/dist/src/platform/index.js.map +1 -1
- package/dist/src/platform/slice/impl.d.ts +17 -1
- package/dist/src/platform/slice/impl.d.ts.map +1 -1
- package/dist/src/platform/slice/impl.js +60 -12
- package/dist/src/platform/slice/impl.js.map +1 -1
- package/dist/src/platform/slice/index.d.ts +155 -10
- package/dist/src/platform/slice/index.d.ts.map +1 -1
- package/dist/src/platform/slice/index.js +37 -17
- package/dist/src/platform/slice/index.js.map +1 -1
- package/dist/src/runtime/collections/index.d.ts +1 -0
- package/dist/src/runtime/collections/index.d.ts.map +1 -1
- package/dist/src/runtime/collections/index.js +1 -0
- package/dist/src/runtime/collections/index.js.map +1 -1
- package/dist/src/runtime/collections/sheet.d.ts +89 -0
- package/dist/src/runtime/collections/sheet.d.ts.map +1 -0
- package/dist/src/runtime/collections/sheet.js +65 -0
- package/dist/src/runtime/collections/sheet.js.map +1 -0
- package/dist/src/slice/index.d.ts +97 -1
- package/dist/src/slice/index.d.ts.map +1 -1
- package/dist/test/collections/sheet.examples.d.ts +56 -0
- package/dist/test/collections/sheet.examples.d.ts.map +1 -0
- package/dist/test/collections/sheet.examples.js +725 -0
- package/dist/test/collections/sheet.examples.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,131 @@
|
|
|
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.register` and `Sheet.driver` — registers are the grammar's
|
|
7
|
+
* vocabulary, projected from the host's rows through accessors reified once
|
|
8
|
+
* (Plan's `derive` move, `Sheet Spec.md` §3.3). There is no attribute bag:
|
|
9
|
+
* a value another declaration needs is read off a TYPED row by an accessor.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type EastType, type ExprType, type SubtypeExprOrValue, ArrayType, DictType, FunctionType, OptionType, StringType, StructType } from "@elaraai/east";
|
|
14
|
+
import { StatusValueType } from "../../feedback/status/types.js";
|
|
15
|
+
import { SheetRegisterMemberType } from "./types.js";
|
|
16
|
+
/** A built register — its members, as an expression. What `Sheet.register.*` returns and `registers={…}` takes. */
|
|
17
|
+
export type SheetRegisterValue = ExprType<ArrayType<SheetRegisterMemberType>>;
|
|
18
|
+
/**
|
|
19
|
+
* The accessors `Sheet.register.members` reifies over one data ENTRY — its
|
|
20
|
+
* value and its key (`(_v, k) => k` is the normal spelling over a `Dict`;
|
|
21
|
+
* over an `Array` the key is the index, printed).
|
|
22
|
+
*
|
|
23
|
+
* @typeParam T - The data's element type
|
|
24
|
+
* @property kind - The member kind (`"machine"`, `"line"`, `"family"`)
|
|
25
|
+
* @property key - What the grammar resolves — accessor
|
|
26
|
+
* @property label - What a chip prints — accessor
|
|
27
|
+
* @property aliases - Alternative spellings — accessor returning the field's array
|
|
28
|
+
* @property meta - Chip meta — accessor returning the field's `Option`
|
|
29
|
+
* @property parent - The parent key — accessor returning the field's `Option`
|
|
30
|
+
* @property tone - An `enum` member's valence — accessor returning the field's `Option`
|
|
31
|
+
*/
|
|
32
|
+
export interface SheetMembersConfig<T extends EastType> {
|
|
33
|
+
/** The member kind. */
|
|
34
|
+
kind: string;
|
|
35
|
+
/** What the grammar resolves. */
|
|
36
|
+
key: (value: ExprType<T>, key: ExprType<StringType>) => SubtypeExprOrValue<StringType>;
|
|
37
|
+
/** What a chip prints. */
|
|
38
|
+
label: (value: ExprType<T>, key: ExprType<StringType>) => SubtypeExprOrValue<StringType>;
|
|
39
|
+
/** Alternative spellings the grammar also resolves. */
|
|
40
|
+
aliases?: (value: ExprType<T>, key: ExprType<StringType>) => SubtypeExprOrValue<ArrayType<StringType>>;
|
|
41
|
+
/** Chip meta — return the field's `Option`. */
|
|
42
|
+
meta?: (value: ExprType<T>, key: ExprType<StringType>) => SubtypeExprOrValue<OptionType<StringType>>;
|
|
43
|
+
/** The parent key — return the field's `Option`. */
|
|
44
|
+
parent?: (value: ExprType<T>, key: ExprType<StringType>) => SubtypeExprOrValue<OptionType<StringType>>;
|
|
45
|
+
/** The valence dot — return the field's `Option`. */
|
|
46
|
+
tone?: (value: ExprType<T>, key: ExprType<StringType>) => SubtypeExprOrValue<OptionType<StatusValueType>>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Projects the host's rows into register members — `Sheet.register.members`.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* The accessors are reified ONCE into a describe function which the map
|
|
53
|
+
* then CALLS (`shared/reify.ts`, `EAST_UI_PROP_PATTERNS.md`). Duplicate keys
|
|
54
|
+
* fold, first occurrence wins — a countable-by-attribute kind (`"CNC lathe"`
|
|
55
|
+
* from every machine of that family) declares one member per distinct value.
|
|
56
|
+
*
|
|
57
|
+
* @typeParam T - The data's element type
|
|
58
|
+
* @param data - The rows — an `Array<T>` or a `Dict<String, T>` value or expression
|
|
59
|
+
* @param config - The accessors ({@link SheetMembersConfig})
|
|
60
|
+
* @returns The members, as an expression
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* Sheet.register.members(machines, { kind: "machine", key: m => m.code, label: m => m.code,
|
|
65
|
+
* meta: m => some(m.family), parent: m => some(m.line) })
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare function createMembers<T extends EastType>(data: SubtypeExprOrValue<ArrayType<T>> | SubtypeExprOrValue<DictType<StringType, T>>, config: SheetMembersConfig<T>): SheetRegisterValue;
|
|
69
|
+
/**
|
|
70
|
+
* Joins member sets of different kinds into one register — `Sheet.register.concat`.
|
|
71
|
+
*
|
|
72
|
+
* @param parts - The member sets, in order
|
|
73
|
+
* @returns The concatenated members
|
|
74
|
+
*/
|
|
75
|
+
export declare function concatMembers(parts: SheetRegisterValue[]): SheetRegisterValue;
|
|
76
|
+
/**
|
|
77
|
+
* The accessors `Sheet.driver` reifies over one driver row.
|
|
78
|
+
*
|
|
79
|
+
* @typeParam D - The driver's row type
|
|
80
|
+
*/
|
|
81
|
+
export interface SheetDriverConfig<D extends StructType> {
|
|
82
|
+
/** The member key — what the driver column's cell stores. */
|
|
83
|
+
key: (row: ExprType<D>) => SubtypeExprOrValue<StringType>;
|
|
84
|
+
/** What a chip / candidate prints. */
|
|
85
|
+
label: (row: ExprType<D>) => SubtypeExprOrValue<StringType>;
|
|
86
|
+
/** Alternative spellings. */
|
|
87
|
+
aliases?: (row: ExprType<D>) => SubtypeExprOrValue<ArrayType<StringType>>;
|
|
88
|
+
/** Chip meta — return the field's `Option`. */
|
|
89
|
+
meta?: (row: ExprType<D>) => SubtypeExprOrValue<OptionType<StringType>>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* The driver declaration — the column, its data, the row type `D` every
|
|
93
|
+
* driver-reading accessor is typed by, and the reified key lookup.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* The typed parts (`rowType`, `data`, `keyFn`) never reach the IR: the root
|
|
97
|
+
* applies a column's `uom` / `sides` accessors over `data` and the bridge
|
|
98
|
+
* folds `data` into the `ctx.driver` lookup. Only `column` and `members`
|
|
99
|
+
* ride ({@link SheetDriverType}).
|
|
100
|
+
*
|
|
101
|
+
*/
|
|
102
|
+
export interface SheetDriverValue {
|
|
103
|
+
/** The driver column's key — must be a `lookup` column on a `String` field. */
|
|
104
|
+
readonly column: string;
|
|
105
|
+
/** The driver's row type (erased here; the builders that read the driver's row take it explicitly). */
|
|
106
|
+
readonly rowType: StructType;
|
|
107
|
+
/** The driver rows. */
|
|
108
|
+
readonly data: ExprType<ArrayType<StructType>>;
|
|
109
|
+
/** The reified key accessor. */
|
|
110
|
+
readonly keyFn: ExprType<FunctionType<[StructType], StringType>>;
|
|
111
|
+
/** The driver's register members. */
|
|
112
|
+
readonly members: SheetRegisterValue;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Declares the driver — `Sheet.driver(column, data, { key, label })`: the
|
|
116
|
+
* `lookup` column whose member decides what the row does, with its data,
|
|
117
|
+
* so `D` reaches every `uom` / `sides` accessor and `ctx.driver` (§3.3).
|
|
118
|
+
*
|
|
119
|
+
* @typeParam D - The driver's row type (inferred from `data`)
|
|
120
|
+
* @param column - The driver column's key
|
|
121
|
+
* @param data - The driver rows — an `Array<D>` value or expression
|
|
122
|
+
* @param config - The accessors ({@link SheetDriverConfig})
|
|
123
|
+
* @returns The driver declaration the `driver` prop takes
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```ts
|
|
127
|
+
* Sheet.driver("activity", activities, { key: a => a.name, label: a => a.name })
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
export declare function createDriver<D extends StructType>(column: string, data: SubtypeExprOrValue<ArrayType<D>>, config: SheetDriverConfig<D>): SheetDriverValue;
|
|
131
|
+
//# sourceMappingURL=registers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registers.d.ts","sourceRoot":"","sources":["../../../../src/collections/sheet/registers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EACH,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,kBAAkB,EAGvB,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EAEV,UAAU,EACV,UAAU,EAEb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;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CAAC,CAAC,CAAC;IAC/C,gCAAgC;IAChC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC;IACjE,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,kBAAkB,CAAC;CACxC;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,UAAU,EAC7C,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,kBAAkB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EACtC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC,GAC7B,gBAAgB,CAiBlB"}
|
|
@@ -0,0 +1,119 @@
|
|
|
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.register` and `Sheet.driver` — registers are the grammar's
|
|
7
|
+
* vocabulary, projected from the host's rows through accessors reified once
|
|
8
|
+
* (Plan's `derive` move, `Sheet Spec.md` §3.3). There is no attribute bag:
|
|
9
|
+
* a value another declaration needs is read off a TYPED row by an accessor.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { East, Expr, ArrayType, DictType, FunctionType, OptionType, SetType, StringType, StructType, none, } from "@elaraai/east";
|
|
14
|
+
import { StatusValueType } from "../../feedback/status/types.js";
|
|
15
|
+
import { SheetRegisterMemberType } from "./types.js";
|
|
16
|
+
import { SheetRegisterMembersType } from "./link.js";
|
|
17
|
+
/** Fold duplicate keys, keeping the FIRST occurrence in declaration order. */
|
|
18
|
+
const dedupeMembers = East.function([SheetRegisterMembersType], SheetRegisterMembersType, ($, ms) => {
|
|
19
|
+
const out = $.let([], SheetRegisterMembersType);
|
|
20
|
+
const seen = $.let(new Set(), SetType(StringType));
|
|
21
|
+
$.for(ms, ($2, m, _i, _label) => {
|
|
22
|
+
$2.if(seen.has(m.key).not(), ($3) => {
|
|
23
|
+
$3(seen.insert(m.key));
|
|
24
|
+
$3(out.pushLast(m));
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
return out;
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* Projects the host's rows into register members — `Sheet.register.members`.
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* The accessors are reified ONCE into a describe function which the map
|
|
34
|
+
* then CALLS (`shared/reify.ts`, `EAST_UI_PROP_PATTERNS.md`). Duplicate keys
|
|
35
|
+
* fold, first occurrence wins — a countable-by-attribute kind (`"CNC lathe"`
|
|
36
|
+
* from every machine of that family) declares one member per distinct value.
|
|
37
|
+
*
|
|
38
|
+
* @typeParam T - The data's element type
|
|
39
|
+
* @param data - The rows — an `Array<T>` or a `Dict<String, T>` value or expression
|
|
40
|
+
* @param config - The accessors ({@link SheetMembersConfig})
|
|
41
|
+
* @returns The members, as an expression
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* Sheet.register.members(machines, { kind: "machine", key: m => m.code, label: m => m.code,
|
|
46
|
+
* meta: m => some(m.family), parent: m => some(m.line) })
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function createMembers(data, config) {
|
|
50
|
+
const expr = East.value(data);
|
|
51
|
+
const t = Expr.type(expr);
|
|
52
|
+
if (t.type !== "Array" && t.type !== "Dict") {
|
|
53
|
+
throw new Error(`Sheet.register.members: data must be an Array or a Dict<String, T> — got a ${t.type}`);
|
|
54
|
+
}
|
|
55
|
+
if (t.type === "Dict" && t.key.type !== "String") {
|
|
56
|
+
throw new Error("Sheet.register.members: a keyed register must be a Dict<String, T> — its keys ride to the accessors as the second argument");
|
|
57
|
+
}
|
|
58
|
+
const elem = t.value;
|
|
59
|
+
const cfg = config;
|
|
60
|
+
const describe = East.function([elem, StringType], SheetRegisterMemberType, (_$, v, k) => ({
|
|
61
|
+
key: cfg.key(v, k),
|
|
62
|
+
label: cfg.label(v, k),
|
|
63
|
+
kind: cfg.kind,
|
|
64
|
+
aliases: cfg.aliases !== undefined ? cfg.aliases(v, k) : East.value([], ArrayType(StringType)),
|
|
65
|
+
meta: cfg.meta !== undefined ? cfg.meta(v, k) : East.value(none, OptionType(StringType)),
|
|
66
|
+
parent: cfg.parent !== undefined ? cfg.parent(v, k) : East.value(none, OptionType(StringType)),
|
|
67
|
+
tone: cfg.tone !== undefined ? cfg.tone(v, k) : East.value(none, OptionType(StatusValueType)),
|
|
68
|
+
}));
|
|
69
|
+
const list = t.type === "Dict"
|
|
70
|
+
? expr.toArray((_$, v, k) => describe(v, k))
|
|
71
|
+
: expr.map((_$, v, i) => describe(v, East.print(i)));
|
|
72
|
+
return dedupeMembers(list);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Joins member sets of different kinds into one register — `Sheet.register.concat`.
|
|
76
|
+
*
|
|
77
|
+
* @param parts - The member sets, in order
|
|
78
|
+
* @returns The concatenated members
|
|
79
|
+
*/
|
|
80
|
+
export function concatMembers(parts) {
|
|
81
|
+
if (parts.length === 0)
|
|
82
|
+
return East.value([], SheetRegisterMembersType);
|
|
83
|
+
return parts.slice(1).reduce((acc, p) => acc.concat(p), parts[0]);
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Declares the driver — `Sheet.driver(column, data, { key, label })`: the
|
|
87
|
+
* `lookup` column whose member decides what the row does, with its data,
|
|
88
|
+
* so `D` reaches every `uom` / `sides` accessor and `ctx.driver` (§3.3).
|
|
89
|
+
*
|
|
90
|
+
* @typeParam D - The driver's row type (inferred from `data`)
|
|
91
|
+
* @param column - The driver column's key
|
|
92
|
+
* @param data - The driver rows — an `Array<D>` value or expression
|
|
93
|
+
* @param config - The accessors ({@link SheetDriverConfig})
|
|
94
|
+
* @returns The driver declaration the `driver` prop takes
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```ts
|
|
98
|
+
* Sheet.driver("activity", activities, { key: a => a.name, label: a => a.name })
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export function createDriver(column, data, config) {
|
|
102
|
+
const expr = East.value(data);
|
|
103
|
+
const t = Expr.type(expr);
|
|
104
|
+
if (t.type !== "Array" || t.value.type !== "Struct") {
|
|
105
|
+
throw new Error(`Sheet.driver("${column}"): data must be an Array of structs — got a ${t.type}`);
|
|
106
|
+
}
|
|
107
|
+
const rowType = t.value;
|
|
108
|
+
const cfg = config;
|
|
109
|
+
const keyFn = East.function([rowType], StringType, (_$, d) => cfg.key(d));
|
|
110
|
+
const members = createMembers(expr, {
|
|
111
|
+
kind: column,
|
|
112
|
+
key: (d) => keyFn(d),
|
|
113
|
+
label: (d) => cfg.label(d),
|
|
114
|
+
...(cfg.aliases !== undefined ? { aliases: (d) => cfg.aliases(d) } : {}),
|
|
115
|
+
...(cfg.meta !== undefined ? { meta: (d) => cfg.meta(d) } : {}),
|
|
116
|
+
});
|
|
117
|
+
return { column, rowType, data: expr, keyFn, members };
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=registers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registers.js","sourceRoot":"","sources":["../../../../src/collections/sheet/registers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAIH,IAAI,EACJ,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,OAAO,EACP,UAAU,EACV,UAAU,EACV,IAAI,GACP,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AAoCrD,8EAA8E;AAC9E,MAAM,aAAa,GAAG,IAAI,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4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* `Sheet.Root` — assembles the whole sheet value against the `Sheet` arm of
|
|
7
|
+
* `component.ts` (`Sheet Spec.md` §4.6): resolves the row source (both
|
|
8
|
+
* arms), describes every column against the row type, compiles the typed
|
|
9
|
+
* bridge (§4.8), builds each column's wire value, compiles `onUpdate` into
|
|
10
|
+
* the edit channel (§4.7), and refuses every mistake of §3.12 naming the
|
|
11
|
+
* column and the remedy.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
import { type ExprType, type SubtypeExprOrValue, ArrayType, AsyncFunctionType, BooleanType, DictType, FunctionType, IntegerType, NullType, OptionType, StringType, StructType } from "@elaraai/east";
|
|
16
|
+
import { UIComponentType } from "../../component.js";
|
|
17
|
+
import { SliceBindType } from "../../platform/slice/index.js";
|
|
18
|
+
import { type SliceAffordanceLiteral } from "../../contracts/slice-affordances.js";
|
|
19
|
+
import { DensityType, type DensityLiteral } from "../../style/interaction.js";
|
|
20
|
+
import { StatusValueType, type StatusValueLiteral } from "../../feedback/status/types.js";
|
|
21
|
+
import { type PagedSource } from "../../contracts/source.js";
|
|
22
|
+
import type { DataRowType } from "../table/index.js";
|
|
23
|
+
import { SheetViewType, SheetSelectionType, type SheetContextOf, type SheetProposalOf, type SheetEditOf } from "./types.js";
|
|
24
|
+
import type { SheetColumnSpec, SheetFieldKey } from "./columns.js";
|
|
25
|
+
import type { SheetDriverValue, SheetRegisterValue } from "./registers.js";
|
|
26
|
+
/** The keys of a row struct whose field is a `String` — what `id` may name. */
|
|
27
|
+
export type SheetStringField<R extends StructType> = {
|
|
28
|
+
[K in SheetFieldKey<R>]: R["fields"][K] extends StringType ? K : never;
|
|
29
|
+
}[SheetFieldKey<R>];
|
|
30
|
+
/**
|
|
31
|
+
* One row proposer — a synchronous or asynchronous East function over
|
|
32
|
+
* `Sheet.Types.Context(R, D)` to `Array<Sheet.Types.Proposal(R)>` (§3.6).
|
|
33
|
+
* The driver type is checked at build time against the sheet's driver.
|
|
34
|
+
*
|
|
35
|
+
* @typeParam R - The host's row type
|
|
36
|
+
*/
|
|
37
|
+
export type SheetProposerInput<R extends StructType> = SubtypeExprOrValue<FunctionType<[SheetContextOf<R, any>], ArrayType<SheetProposalOf<R>>>> | SubtypeExprOrValue<AsyncFunctionType<[SheetContextOf<R, any>], ArrayType<SheetProposalOf<R>>>>;
|
|
38
|
+
/**
|
|
39
|
+
* The copilot's row-proposal declaration (B§5.2).
|
|
40
|
+
*
|
|
41
|
+
* @typeParam R - The host's row type
|
|
42
|
+
* @property ahead - At most this many proposed rows below the anchor (default 2)
|
|
43
|
+
* @property triggers - Column keys whose commit re-asks the proposers (default: every editable column)
|
|
44
|
+
* @property ghost - Draw proposed rows as hatched ghosts (default `true`)
|
|
45
|
+
* @property propose - The proposers; the first that returns rows wins
|
|
46
|
+
*/
|
|
47
|
+
export interface SheetSuggestInput<R extends StructType> {
|
|
48
|
+
/** At most this many proposed rows below the anchor. */
|
|
49
|
+
ahead?: SubtypeExprOrValue<IntegerType> | number;
|
|
50
|
+
/** Column keys whose commit re-asks the proposers. */
|
|
51
|
+
triggers?: SheetFieldKey<R>[];
|
|
52
|
+
/** Draw proposed rows as hatched ghosts. */
|
|
53
|
+
ghost?: boolean;
|
|
54
|
+
/** The proposers; the first that returns rows wins. */
|
|
55
|
+
propose: SheetProposerInput<R>[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The options of `Sheet.Root` / the `<Sheet>` tag's props beside `data` and
|
|
59
|
+
* `columns` (§3).
|
|
60
|
+
*
|
|
61
|
+
* @typeParam R - The host's row type
|
|
62
|
+
* @property id - The `String` field that identifies a row (required on a positional source; a keyed paged source's key is its id)
|
|
63
|
+
* @property owned - Rows the upstream system owns: no copilot, stamped columns read-only — an accessor
|
|
64
|
+
* @property driver - The driver declaration (`Sheet.driver`)
|
|
65
|
+
* @property registers - Register name → members (`Sheet.register.*`)
|
|
66
|
+
* @property suggest - The row-proposal declaration
|
|
67
|
+
* @property slice - The bound slice whose narrowing the lens draws; the rail mounts `affordances`
|
|
68
|
+
* @property affordances - Rail affordances when `slice` is set (default `["search"]`; `brush` / `legend` / `breakdown` refused)
|
|
69
|
+
* @property views - The saved views
|
|
70
|
+
* @property activeView - The active view's id
|
|
71
|
+
* @property onViewsChange - Views changed
|
|
72
|
+
* @property onUpdate - The whole collection with the edit applied (inline arm only)
|
|
73
|
+
* @property onEdit - The raw edit event, typed over the row (either arm)
|
|
74
|
+
* @property onSelect - The ring moved
|
|
75
|
+
* @property selection - Controlled selection (§3.14)
|
|
76
|
+
* @property newRowId - Overrides the renderer's id minting for inserted rows
|
|
77
|
+
* @property readOnly - The whole sheet is read-only
|
|
78
|
+
* @property blanks - Padding rows below the last real one (default 18)
|
|
79
|
+
* @property density - Row rhythm
|
|
80
|
+
* @property footer - Footer items
|
|
81
|
+
* @property style - Sizing and the gutter width
|
|
82
|
+
*/
|
|
83
|
+
export interface SheetOptions<R extends StructType> {
|
|
84
|
+
/** The `String` field that identifies a row. */
|
|
85
|
+
id?: SheetStringField<R>;
|
|
86
|
+
/** Rows the upstream system owns — an accessor. */
|
|
87
|
+
owned?: (row: ExprType<R>) => SubtypeExprOrValue<BooleanType>;
|
|
88
|
+
/** The driver declaration. */
|
|
89
|
+
driver?: SheetDriverValue;
|
|
90
|
+
/** Register name → members. */
|
|
91
|
+
registers?: Record<string, SheetRegisterValue>;
|
|
92
|
+
/** The row-proposal declaration. */
|
|
93
|
+
suggest?: SheetSuggestInput<R>;
|
|
94
|
+
/** The bound slice whose narrowing the lens draws. */
|
|
95
|
+
slice?: SubtypeExprOrValue<SliceBindType>;
|
|
96
|
+
/** Rail affordances when `slice` is set. */
|
|
97
|
+
affordances?: SliceAffordanceLiteral[];
|
|
98
|
+
/** The saved views. */
|
|
99
|
+
views?: SubtypeExprOrValue<ArrayType<SheetViewType>>;
|
|
100
|
+
/** The active view's id. */
|
|
101
|
+
activeView?: SubtypeExprOrValue<OptionType<StringType>>;
|
|
102
|
+
/** Views changed. */
|
|
103
|
+
onViewsChange?: SubtypeExprOrValue<FunctionType<[ArrayType<SheetViewType>], NullType>>;
|
|
104
|
+
/** The whole collection with the edit applied (inline arm only). */
|
|
105
|
+
onUpdate?: SubtypeExprOrValue<FunctionType<[ArrayType<R>], NullType>>;
|
|
106
|
+
/** The raw edit event, typed over the row. */
|
|
107
|
+
onEdit?: SubtypeExprOrValue<FunctionType<[SheetEditOf<R>], NullType>>;
|
|
108
|
+
/** The ring moved. */
|
|
109
|
+
onSelect?: SubtypeExprOrValue<FunctionType<[SheetSelectionType], NullType>>;
|
|
110
|
+
/** Controlled selection. */
|
|
111
|
+
selection?: SubtypeExprOrValue<OptionType<SheetSelectionType>>;
|
|
112
|
+
/** Overrides the renderer's id minting for inserted rows. */
|
|
113
|
+
newRowId?: SubtypeExprOrValue<FunctionType<[], StringType>>;
|
|
114
|
+
/** The whole sheet is read-only. */
|
|
115
|
+
readOnly?: SubtypeExprOrValue<BooleanType> | boolean;
|
|
116
|
+
/** Padding rows below the last real one. */
|
|
117
|
+
blanks?: SubtypeExprOrValue<IntegerType> | number;
|
|
118
|
+
/** Row rhythm. */
|
|
119
|
+
density?: DensityLiteral | SubtypeExprOrValue<DensityType>;
|
|
120
|
+
/** Footer items. */
|
|
121
|
+
footer?: {
|
|
122
|
+
/** The footer text. */
|
|
123
|
+
text: SubtypeExprOrValue<StringType>;
|
|
124
|
+
/** Optional status tint. */
|
|
125
|
+
tone?: StatusValueLiteral | SubtypeExprOrValue<StatusValueType>;
|
|
126
|
+
}[];
|
|
127
|
+
/** Sizing and the gutter width. */
|
|
128
|
+
style?: {
|
|
129
|
+
/** Definite height (`"fill"` fills the parent). */
|
|
130
|
+
height?: SubtypeExprOrValue<StringType>;
|
|
131
|
+
/** Max-height cap. */
|
|
132
|
+
maxHeight?: SubtypeExprOrValue<StringType>;
|
|
133
|
+
/** The gutter width, a CSS px size. */
|
|
134
|
+
gutterWidth?: SubtypeExprOrValue<StringType>;
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/** A whole-value bind handle (`State.bind` / `Data.bind`) over `Array<R>` — accepted as `data`. */
|
|
138
|
+
export interface SheetBindHandle<R extends StructType> {
|
|
139
|
+
/** The handle's read. */
|
|
140
|
+
read: (...args: never[]) => ExprType<ArrayType<R>>;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Creates the Sheet root — the whole planning spreadsheet.
|
|
144
|
+
*
|
|
145
|
+
* @typeParam T - The inline data's type (an `Array<R>` value or expression)
|
|
146
|
+
* @param data - The rows: an `Array<R>` value or expression, a whole-value bind handle, or a paged source
|
|
147
|
+
* @param columns - The columns, keyed by the row's fields ({@link SheetColumnSpec})
|
|
148
|
+
* @param options - Everything else ({@link SheetOptions})
|
|
149
|
+
* @returns An East expression of `UIComponentType`
|
|
150
|
+
*
|
|
151
|
+
* @remarks
|
|
152
|
+
* `id` is required on a positional source. `onUpdate` is refused on the
|
|
153
|
+
* paged arm (there is no collection to rebuild — route `onEdit` events to
|
|
154
|
+
* the dataset you page from). A `Dict` inline is refused: a sorted map would
|
|
155
|
+
* sit rows in key order, not the planner's.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* import { East, ArrayType, DateTimeType, FloatType, OptionType, StringType, StructType, none } from "@elaraai/east";
|
|
160
|
+
* import { Reactive, Sheet, State, UIComponentType } from "@elaraai/east-ui/internal";
|
|
161
|
+
*
|
|
162
|
+
* const JobType = StructType({ id: StringType, start: OptionType(DateTimeType), task: StringType, qty: OptionType(FloatType) });
|
|
163
|
+
*
|
|
164
|
+
* const example = East.function([], UIComponentType, (_$) => Reactive.Root(East.function([], UIComponentType, ($) => {
|
|
165
|
+
* const jobs = $.let(State.bind([ArrayType(JobType)], "jobs", [{ id: "j1", start: none, task: "Machining", qty: none }]));
|
|
166
|
+
* return Sheet.Root(jobs.read(), {
|
|
167
|
+
* start: Sheet.column.date(JobType, { header: "Start" }),
|
|
168
|
+
* task: Sheet.column.text(JobType, { header: "Task" }),
|
|
169
|
+
* qty: Sheet.column.quantity(JobType, { header: "Qty" }),
|
|
170
|
+
* }, { id: "id", onUpdate: jobs.write });
|
|
171
|
+
* })));
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
export declare function createSheet<T extends SubtypeExprOrValue<ArrayType<StructType>>>(data: T, columns: SheetColumnSpec<DataRowType<T>>, options: SheetOptions<DataRowType<T>>): ExprType<UIComponentType>;
|
|
175
|
+
/** The whole-value bind handle — `data={jobs}` builds the same IR as `data={jobs.read()}`. */
|
|
176
|
+
export declare function createSheet<R extends StructType>(data: SheetBindHandle<R>, columns: SheetColumnSpec<R>, options: SheetOptions<R>): ExprType<UIComponentType>;
|
|
177
|
+
/** The PAGED arm — positional (`Array<R>` windows) or keyed (`Dict<String, R>` windows, the key is the id). */
|
|
178
|
+
export declare function createSheet<R extends StructType>(data: PagedSource<ArrayType<R>> | PagedSource<DictType<StringType, R>>, columns: SheetColumnSpec<R>, options?: SheetOptions<R>): ExprType<UIComponentType>;
|
|
179
|
+
//# sourceMappingURL=root.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../../../../src/collections/sheet/root.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;GASG;AAEH,OAAO,EAEH,KAAK,QAAQ,EACb,KAAK,kBAAkB,EAEvB,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,WAAW,EACX,QAAQ,EACR,UAAU,EACV,UAAU,EACV,UAAU,EAKb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAmB,MAAM,+BAA+B,CAAC;AAC/E,OAAO,EAAuB,KAAK,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AACxG,OAAO,E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