@homepages/concrete 6.2.0 → 8.0.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 +152 -0
- package/codemods/manifest.json +19 -0
- package/codemods/object-form-only.mjs +39 -0
- package/codemods/steps/list-object-form.mjs +688 -0
- package/codemods/steps/select-object-form.mjs +210 -0
- package/dist/artifact/playground/client/assets/index-Dn_xT16-.js +1101 -0
- package/dist/artifact/playground/client/index.html +1 -1
- package/dist/artifact/playground/host.mjs +14 -14
- package/dist/asset-modules.d.ts +2 -1
- package/dist/cli/check/stages/render.js +1 -1
- package/dist/cli/check/stages/sections.js +1 -1
- package/dist/fixtures/canonical.d.ts +2 -5
- package/dist/fixtures/media.js +11 -25
- package/dist/fixtures/property.js +28 -16
- package/dist/fixtures/resolve.js +31 -17
- package/dist/fixtures/rows.js +3 -83
- package/dist/fixtures.d.ts +17 -9
- package/dist/index.d.ts +9 -9
- package/dist/packages/external/concrete/package.js +1 -1
- package/dist/packages/internal/fill-bake/dist/bake-property-ref.js +32 -10
- package/dist/packages/internal/fill-bake/dist/derive-source.js +15 -4
- package/dist/packages/internal/fill-bake/dist/index.js +2 -2
- package/dist/packages/internal/fill-vocabulary/dist/origination.js +6 -61
- package/dist/packages/internal/fill-vocabulary/dist/row-reads.js +15 -0
- package/dist/packages/internal/property-facts/dist/index.js +1 -1
- package/dist/packages/internal/property-facts/dist/{property-facts-5pxZnlkh.js → property-facts-Cy7-O4p0.js} +2 -5
- package/dist/packages/internal/section-contracts/dist/catalog.js +2 -22
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +6 -1
- package/dist/packages/internal/section-contracts/dist/group-contract.js +1 -3
- package/dist/packages/internal/section-contracts/dist/index.js +0 -5
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +16 -7
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +1 -5
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +14 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +3 -28
- package/dist/packages/internal/section-contracts/dist/source-contract.js +93 -20
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +19 -9
- package/dist/packages/internal/source-resolution/dist/index.js +48 -57
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +6 -17
- package/dist/packages/internal/template-contracts/dist/facts-view.js +4 -23
- package/dist/packages/internal/template-contracts/dist/row-sources.js +20 -0
- package/dist/packages/internal/template-contracts/dist/slot-catalog.d.ts +362 -380
- package/dist/packages/internal/template-contracts/dist/slot-catalog.js +289 -293
- package/dist/primitives/slot-bindings.d.ts +7 -40
- package/dist/primitives/slot-bindings.js +10 -12
- package/dist/schema/define-schema.d.ts +1 -1
- package/dist/schema/define-schema.js +13 -1
- package/dist/schema/extract-fill-spec.js +14 -17
- package/dist/schema/fact.d.ts +2 -19
- package/dist/schema/fill-builders.d.ts +4 -3
- package/dist/schema/fill-spec.js +18 -1
- package/dist/schema/layout.d.ts +6 -8
- package/dist/schema/layout.js +3 -9
- package/dist/schema/property-facts.d.ts +17 -47
- package/dist/schema/row-fields.js +88 -0
- package/dist/schema/row-ref.d.ts +59 -0
- package/dist/schema/row-ref.js +28 -0
- package/dist/schema/runtime-values.d.ts +8 -13
- package/dist/schema/section-props.d.ts +19 -26
- package/dist/schema/section-schema.d.ts +6 -6
- package/dist/schema/section-schema.js +2 -2
- package/dist/schema/slot-builders.d.ts +247 -122
- package/dist/schema/slot-builders.js +57 -28
- package/dist/schema/slot-ref.d.ts +18 -2
- package/dist/schema/slot-ref.js +11 -3
- package/dist/schema/slot-types.d.ts +7 -7
- package/dist/schema/slot-types.js +55 -19
- package/dist/section/declare.d.ts +1 -1
- package/dist/section/section.d.ts +3 -3
- package/dist/template/logic-shim.d.ts +1 -1
- package/guide/reference/cli/INDEX.md +2 -2
- package/guide/reference/cli/build.md +1 -1
- package/guide/reference/cli/check.md +1 -1
- package/guide/reference/cli/dev.md +1 -1
- package/guide/reference/cli/property-add.md +1 -1
- package/guide/reference/cli/property-list.md +1 -1
- package/guide/reference/cli/publish.md +1 -1
- package/guide/reference/cli/upgrade.md +1 -1
- package/guide/reference/rules/INDEX.md +3 -8
- package/package.json +1 -1
- package/tsconfig.base.json +1 -0
- package/dist/artifact/playground/client/assets/index-Cqz-jjVw.js +0 -1101
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +0 -20
- package/dist/packages/internal/section-contracts/dist/row-contract.js +0 -37
- package/dist/packages/internal/section-contracts/dist/source-filter-contract.js +0 -15
- package/dist/packages/internal/template-contracts/dist/layout.js +0 -10
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { LinkKind, LinkProviderId, SourceFieldName,
|
|
2
|
-
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
3
|
-
import { TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
4
|
-
import { ImageValue, PlaybackConfig } from "./runtime-values.js";
|
|
1
|
+
import { CollectionField, LinkKind, LinkProviderId, SourceFieldName, VideoSource, WritableSourceFieldName } from "../packages/internal/template-contracts/dist/slot-catalog.js";
|
|
5
2
|
import { FillBinding, FillFor } from "./fill-builders.js";
|
|
6
3
|
import { FillMark } from "./fill-declaration.js";
|
|
7
4
|
import { ListFieldSlot, ListItemSlot } from "./slot-types.js";
|
|
8
|
-
import { RefValue, SiblingSlot, SlotRef } from "./slot-ref.js";
|
|
9
|
-
import { RowValue, SlotValue } from "./section-props.js";
|
|
10
|
-
import { LayoutRow } from "./layout.js";
|
|
5
|
+
import { RefValue, RowRef, SiblingSlot, SlotRef } from "./slot-ref.js";
|
|
11
6
|
import { ComputeBinding } from "./compute.js";
|
|
7
|
+
import { VideoValue } from "../packages/internal/template-contracts/dist/video-value.js";
|
|
8
|
+
import { TourValue } from "../packages/internal/template-contracts/dist/tour-value.js";
|
|
9
|
+
import { ImageValue, PlaybackConfig } from "./runtime-values.js";
|
|
10
|
+
import { RowOf } from "./row-ref.js";
|
|
11
|
+
import { BoundRowValue, RowValue, SlotValue } from "./section-props.js";
|
|
12
12
|
//#region src/schema/slot-builders.d.ts
|
|
13
13
|
/**
|
|
14
14
|
* Where a slot's value comes from: the `direct` literal a `fact.*` entry emits
|
|
@@ -22,7 +22,7 @@ type SlotSource = {
|
|
|
22
22
|
kind: "derived";
|
|
23
23
|
transform: string;
|
|
24
24
|
};
|
|
25
|
-
type SourceMark<HasSource extends SourceBinding | undefined> = HasSource extends SlotSource | ComputeBinding<unknown> ? {
|
|
25
|
+
type SourceMark<HasSource extends SourceBinding | undefined> = HasSource extends SlotSource | ComputeBinding<unknown> | RowRef ? {
|
|
26
26
|
source: HasSource;
|
|
27
27
|
} : HasSource extends MirrorSource ? {
|
|
28
28
|
source: ComputeBinding<unknown>;
|
|
@@ -35,27 +35,30 @@ type SourceMark<HasSource extends SourceBinding | undefined> = HasSource extends
|
|
|
35
35
|
* override exactly as a computed slot does. Nothing writes through to the upstream.
|
|
36
36
|
*/
|
|
37
37
|
type MirrorSource = SlotRef | SiblingSlot;
|
|
38
|
-
/** Everything a builder's `source:` takes: a fact, a `compute()`, a mirrored slot, or a `fill()`. */
|
|
39
|
-
type SourceBinding = SlotSource | ComputeBinding<unknown> | MirrorSource | FillBinding;
|
|
38
|
+
/** Everything a builder's `source:` takes: a fact, a row member, a `compute()`, a mirrored slot, or a `fill()`. */
|
|
39
|
+
type SourceBinding = SlotSource | RowRef | ComputeBinding<unknown> | MirrorSource | FillBinding;
|
|
40
40
|
/** The value a mirror's upstream holds — a ref's phantom, or a sibling slot's own value type. */
|
|
41
41
|
type MirroredValue<Upstream> = Upstream extends SlotRef ? RefValue<Upstream> : SlotValue<Upstream>;
|
|
42
42
|
/**
|
|
43
|
-
* The value-type check a mirror owes:
|
|
44
|
-
* to this slot kind's `CV` — what a `compute()` here must return. A
|
|
45
|
-
* join is a `compute()`, never a mirror. A mismatch demands a key no
|
|
46
|
-
* supply, so the compile error names both types. Any other `source` owes
|
|
43
|
+
* The value-type check a mirror or a row member owes: the upstream's value type must
|
|
44
|
+
* be assignable to this slot kind's `CV` — what a `compute()` here must return. A
|
|
45
|
+
* projection or a join is a `compute()`, never a mirror. A mismatch demands a key no
|
|
46
|
+
* author can supply, so the compile error names both types. Any other `source` owes
|
|
47
|
+
* nothing.
|
|
47
48
|
*/
|
|
48
49
|
type MirrorOption<HasSource, CV> = HasSource extends MirrorSource ? [MirroredValue<HasSource>] extends [CV] ? unknown : {
|
|
49
50
|
"a mirrored slot's value type must be assignable to this slot's": [upstream: MirroredValue<HasSource>, slot: CV];
|
|
51
|
+
} : HasSource extends RowRef<string, infer Member> ? [Member] extends [CV] ? unknown : {
|
|
52
|
+
"a row member's value type must be assignable to this slot's": [member: Member, slot: CV];
|
|
50
53
|
} : unknown;
|
|
51
54
|
/**
|
|
52
55
|
* The `writeback` key a builder's options must carry, decided by the slot's
|
|
53
|
-
* `source`. A direct fact binding REQUIRES the boolean —
|
|
54
|
-
* the catalog entry is writable, the literal
|
|
55
|
-
* the answer to "do edits propagate?" is visible
|
|
56
|
-
* A `compute()` binding and an unsourced (AI-filled /
|
|
57
|
-
* `writeback` key at all: nothing can write back through a
|
|
58
|
-
* propagation is meaningless for generated content.
|
|
56
|
+
* `source`. A direct fact binding or a row member REQUIRES the boolean —
|
|
57
|
+
* `true`/`false` where the catalog entry or the member is writable, the literal
|
|
58
|
+
* `false` where it is read-only, so the answer to "do edits propagate?" is visible
|
|
59
|
+
* without opening the catalog. A `compute()` binding and an unsourced (AI-filled /
|
|
60
|
+
* authored) slot admit no `writeback` key at all: nothing can write back through a
|
|
61
|
+
* derivation, and propagation is meaningless for generated content.
|
|
59
62
|
*/
|
|
60
63
|
type WritebackOption<HasSource extends SourceBinding | undefined> = HasSource extends {
|
|
61
64
|
kind: "direct";
|
|
@@ -64,6 +67,10 @@ type WritebackOption<HasSource extends SourceBinding | undefined> = HasSource ex
|
|
|
64
67
|
writeback: boolean;
|
|
65
68
|
} : {
|
|
66
69
|
writeback: false;
|
|
70
|
+
} : HasSource extends RowRef<string, unknown, infer Writable> ? [Writable] extends [true] ? {
|
|
71
|
+
writeback: boolean;
|
|
72
|
+
} : {
|
|
73
|
+
writeback: false;
|
|
67
74
|
} : {
|
|
68
75
|
writeback?: never;
|
|
69
76
|
};
|
|
@@ -89,7 +96,7 @@ interface CropConfig {
|
|
|
89
96
|
interface CommonOptions<CV = never, F = never> {
|
|
90
97
|
label: string;
|
|
91
98
|
locked?: boolean;
|
|
92
|
-
source?: SlotSource | ComputeBinding<CV> | MirrorSource | F;
|
|
99
|
+
source?: SlotSource | RowRef | ComputeBinding<CV> | MirrorSource | F;
|
|
93
100
|
writeback?: boolean;
|
|
94
101
|
placeholder?: string;
|
|
95
102
|
when?: string | readonly string[];
|
|
@@ -97,7 +104,7 @@ interface CommonOptions<CV = never, F = never> {
|
|
|
97
104
|
interface Head {
|
|
98
105
|
locked?: true;
|
|
99
106
|
label: string;
|
|
100
|
-
source?: SlotSource | ComputeBinding<unknown>;
|
|
107
|
+
source?: SlotSource | RowRef | ComputeBinding<unknown>;
|
|
101
108
|
writeback?: boolean;
|
|
102
109
|
placeholder?: string;
|
|
103
110
|
when?: string | readonly string[];
|
|
@@ -145,7 +152,12 @@ declare const text: {
|
|
|
145
152
|
source?: HasSource | undefined;
|
|
146
153
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>) => TextSlotDef<"long"> & SourceMark<HasSource> & FillMark;
|
|
147
154
|
};
|
|
148
|
-
|
|
155
|
+
/**
|
|
156
|
+
* The fill a `number` slot takes: the model ESTIMATES the figure, so only `none`
|
|
157
|
+
* binds — there is no character budget to lower and no count of one value.
|
|
158
|
+
*/
|
|
159
|
+
type NumberFill = FillFor<"none">;
|
|
160
|
+
interface NumberOptions extends CommonOptions<number | null, NumberFill> {
|
|
149
161
|
prefix?: string;
|
|
150
162
|
suffix?: string;
|
|
151
163
|
thousandsSep?: boolean;
|
|
@@ -167,31 +179,45 @@ interface NumberSlotDef extends Head {
|
|
|
167
179
|
* toggles decimal display, and `maxDigits` caps the digit count — all read by
|
|
168
180
|
* the renderer's number formatting, not enforced as an input range.
|
|
169
181
|
*
|
|
170
|
-
*
|
|
171
|
-
* `compute()
|
|
182
|
+
* A figure the platform holds is a fact: bind it (`source:` a fact, a slot or a
|
|
183
|
+
* `compute()`). `source: fill({ brief, reads })` is for a figure that is a
|
|
184
|
+
* judgement rather than a fact — an ESTIMATE the model proposes and the user
|
|
185
|
+
* confirms, such as a suggested price band. The model returns a number, rounded to
|
|
186
|
+
* a whole one unless the slot declares `decimals`; `none: true` lets it leave the
|
|
187
|
+
* slot empty. A fill takes no `cap` and no `count`, and a record row's number field
|
|
188
|
+
* takes no fill at all.
|
|
172
189
|
* @example
|
|
173
190
|
* ```ts
|
|
174
|
-
* import { fact, number } from "@homepages/concrete";
|
|
191
|
+
* import { fact, fill, number } from "@homepages/concrete";
|
|
175
192
|
*
|
|
176
193
|
* number({ source: fact.unit.sqft, writeback: true, label: "Square feet", thousandsSep: true, suffix: "sqft", maxDigits: 7 });
|
|
194
|
+
*
|
|
195
|
+
* number({
|
|
196
|
+
* label: "Suggested list price",
|
|
197
|
+
* prefix: "$",
|
|
198
|
+
* thousandsSep: true,
|
|
199
|
+
* source: fill({
|
|
200
|
+
* reads: [fact.property.units, fact.property.comparables],
|
|
201
|
+
* brief: "The most likely sale price, in whole dollars, rounded to $5,000.",
|
|
202
|
+
* }),
|
|
203
|
+
* });
|
|
177
204
|
* ```
|
|
178
205
|
*/
|
|
179
206
|
declare function number<const HasSource extends SourceBinding | undefined = undefined>(opts: NumberOptions & {
|
|
180
207
|
source?: HasSource;
|
|
181
|
-
} & WritebackOption<HasSource> & MirrorOption<HasSource, number | null>): NumberSlotDef & SourceMark<HasSource
|
|
182
|
-
/** One
|
|
208
|
+
} & WritebackOption<HasSource> & MirrorOption<HasSource, number | null>): NumberSlotDef & SourceMark<HasSource> & FillMark;
|
|
209
|
+
/** One authored select choice: a bare string (value === label) or a stored key with display text. */
|
|
183
210
|
type SelectOptionInput = string | {
|
|
184
211
|
value: string;
|
|
185
212
|
label: string;
|
|
186
213
|
};
|
|
187
|
-
interface SelectOptions extends CommonOptions<string | null> {
|
|
188
|
-
creatable?: boolean;
|
|
189
|
-
}
|
|
190
214
|
/**
|
|
191
|
-
* The serialized shape
|
|
192
|
-
* `values` (
|
|
193
|
-
* vocabulary) are mutually exclusive
|
|
194
|
-
* the slot was built with `select
|
|
215
|
+
* The serialized shape a select slot emits — a `select`-kind `SlotDef`.
|
|
216
|
+
* `values` (the authored `options`, stored under their old name) and
|
|
217
|
+
* `options.source` (a fact-derived vocabulary) are mutually exclusive: which one is
|
|
218
|
+
* present depends on whether the slot was built with `select({ options })` or
|
|
219
|
+
* `select({ source: fact.… })`. `unique` rides only on a record row's field; a
|
|
220
|
+
* list's single item hands it to the list (`list({ item })`), which stores it there.
|
|
195
221
|
*/
|
|
196
222
|
interface SelectSlotDef extends Head {
|
|
197
223
|
type: "select";
|
|
@@ -200,17 +226,24 @@ interface SelectSlotDef extends Head {
|
|
|
200
226
|
source: string;
|
|
201
227
|
};
|
|
202
228
|
creatable?: boolean;
|
|
229
|
+
unique?: true;
|
|
230
|
+
}
|
|
231
|
+
/** The one source that supplies a select's vocabulary: a direct fact binding. */
|
|
232
|
+
type FactSource = Extract<SlotSource, {
|
|
233
|
+
kind: "direct";
|
|
234
|
+
}>;
|
|
235
|
+
interface SelectFactOptions extends Omit<CommonOptions<never>, "source"> {
|
|
236
|
+
creatable?: boolean;
|
|
237
|
+
options?: never;
|
|
238
|
+
unique?: never;
|
|
203
239
|
}
|
|
204
|
-
declare function selectFn<const HasSource extends SourceBinding | undefined = undefined>(opts: SelectOptions & {
|
|
205
|
-
source?: HasSource;
|
|
206
|
-
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>): SelectSlotDef & SourceMark<HasSource>;
|
|
207
240
|
type SelectFill = FillFor<"none">;
|
|
208
|
-
interface
|
|
241
|
+
interface SelectChoiceOptions extends Omit<CommonOptions<never>, "source"> {
|
|
242
|
+
options: readonly SelectOptionInput[];
|
|
209
243
|
creatable?: boolean;
|
|
244
|
+
unique?: true;
|
|
245
|
+
source?: ComputeBinding<string | null> | MirrorSource | RowRef | SelectFill;
|
|
210
246
|
}
|
|
211
|
-
declare function selectOf<const HasSource extends SourceBinding | undefined = undefined>(values: readonly SelectOptionInput[], opts: SelectOfOptions & {
|
|
212
|
-
source?: HasSource;
|
|
213
|
-
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>): SelectSlotDef & SourceMark<HasSource> & FillMark;
|
|
214
247
|
/**
|
|
215
248
|
* The fill a `meta.display` entry takes: the model picks ONE of the entry's own
|
|
216
249
|
* cases. The brief and `reads` alone — an entry always resolves a case, so it
|
|
@@ -229,39 +262,53 @@ interface DisplayEntryInput<C extends readonly string[] = readonly string[]> {
|
|
|
229
262
|
locked?: true;
|
|
230
263
|
source?: ComputeBinding<C[number]> | DisplayFill;
|
|
231
264
|
}
|
|
232
|
-
|
|
265
|
+
interface DisplaySelectOptions<C extends readonly [string, ...string[]]> {
|
|
266
|
+
options: C;
|
|
233
267
|
locked?: boolean;
|
|
234
|
-
source?: ComputeBinding<C[number]> | DisplayFill;
|
|
235
|
-
|
|
268
|
+
source?: ComputeBinding<NoInfer<C>[number]> | DisplayFill;
|
|
269
|
+
label?: never;
|
|
270
|
+
}
|
|
236
271
|
/**
|
|
237
|
-
* The select slot
|
|
272
|
+
* The select builder: a slot, a record row's field, a list's item, or a
|
|
273
|
+
* `meta.display` entry, each declared with one options object.
|
|
238
274
|
*
|
|
239
|
-
* As a slot
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
243
|
-
*
|
|
244
|
-
* `source: fill({ brief })`, which picks this one field's key per row in the
|
|
245
|
-
* list's batched call.
|
|
275
|
+
* As a slot or field it declares exactly one set of choices:
|
|
276
|
+
* `select({ label, options: [...] })` for an authored vocabulary, or
|
|
277
|
+
* `select({ label, source: fact.… })` for one the fact supplies. A top-level select
|
|
278
|
+
* is bound (or computed) and is never filled. As a record row's field, an authored
|
|
279
|
+
* select declares its own origin like every row field: a member of the row, or its
|
|
280
|
+
* own `source: fill({ brief })`, which picks this one field's key per row in the
|
|
281
|
+
* list's batched call. Inside a list, `unique: true` says a picked value does not
|
|
282
|
+
* repeat across the rows.
|
|
246
283
|
*
|
|
247
|
-
* As a display entry
|
|
248
|
-
* `select(cases,
|
|
249
|
-
* `
|
|
250
|
-
*
|
|
251
|
-
* takes exactly
|
|
284
|
+
* As a display entry — under `display:`, with no `label` —
|
|
285
|
+
* `select({ options: cases, source: compute({ reads }, fn) })` or
|
|
286
|
+
* `select({ options: cases, source: fill({ brief }) })` declares a `meta.display`
|
|
287
|
+
* `visibility`/`variant`: the first case is the default and the failure posture,
|
|
288
|
+
* `locked: true` opts a variant out of user switching, and the entry takes exactly
|
|
289
|
+
* one origin.
|
|
252
290
|
* @example
|
|
253
291
|
* ```ts
|
|
254
292
|
* import { compute, fact, fill, select } from "@homepages/concrete";
|
|
255
293
|
*
|
|
256
|
-
* select
|
|
257
|
-
* select
|
|
258
|
-
* select(["
|
|
259
|
-
* select(["
|
|
294
|
+
* select({ label: "Status", options: ["for_sale", "sold"] });
|
|
295
|
+
* select({ label: "Listing status", source: fact.property.listing_intent, writeback: true });
|
|
296
|
+
* select({ label: "Comparable status", options: ["regular", "highlight"], source: fill({ brief: "Highlight the two or three strongest sales." }) });
|
|
297
|
+
* select({ options: ["visible", "hidden"], source: compute({ reads: [fact.tours] }, (tours) => (tours.length > 0 ? "visible" : "hidden")) });
|
|
298
|
+
* select({ options: ["classic", "editorial"], source: fill({ brief: "Prefer editorial for story-driven narratives." }) });
|
|
260
299
|
* ```
|
|
261
300
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
301
|
+
interface SelectBuilder {
|
|
302
|
+
<const C extends readonly [string, ...string[]]>(opts: DisplaySelectOptions<C>): DisplayEntryInput<C>;
|
|
303
|
+
<const HasSource extends SourceBinding | undefined = undefined>(opts: SelectChoiceOptions & {
|
|
304
|
+
source?: HasSource;
|
|
305
|
+
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>): SelectSlotDef & SourceMark<HasSource> & FillMark;
|
|
306
|
+
<const HasSource extends FactSource>(opts: SelectFactOptions & {
|
|
307
|
+
source: HasSource;
|
|
308
|
+
} & WritebackOption<HasSource>): SelectSlotDef & SourceMark<HasSource>;
|
|
309
|
+
}
|
|
310
|
+
/** The select builder — see {@link SelectBuilder}. */
|
|
311
|
+
declare const select: SelectBuilder;
|
|
265
312
|
interface UrlOptions extends CommonOptions<string | null> {
|
|
266
313
|
accepts?: LinkKind | LinkProviderId;
|
|
267
314
|
}
|
|
@@ -290,35 +337,36 @@ declare function url<const HasSource extends SourceBinding | undefined = undefin
|
|
|
290
337
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>): UrlSlotDef & SourceMark<HasSource>;
|
|
291
338
|
/** The fill a single-asset slot takes: one pick out of that type's pool, which may abstain. */
|
|
292
339
|
type AssetFill = FillFor<"none">;
|
|
293
|
-
interface
|
|
340
|
+
interface AssetRowOptions {
|
|
341
|
+
unique?: true;
|
|
342
|
+
}
|
|
343
|
+
interface ImageOptions extends CommonOptions<ImageValue | null, AssetFill>, AssetRowOptions {
|
|
294
344
|
crop?: CropConfig;
|
|
295
|
-
sourceFilter?: SourceFilter;
|
|
296
345
|
}
|
|
297
346
|
/** The serialized shape the `image` builder emits — an `image`-kind `SlotDef`. */
|
|
298
347
|
interface ImageSlotDef extends Head {
|
|
299
348
|
type: "image";
|
|
300
349
|
crop?: CropConfig;
|
|
301
|
-
|
|
350
|
+
unique?: true;
|
|
302
351
|
}
|
|
303
352
|
/**
|
|
304
353
|
* A single image slot — the resolved value is always one `ImageValue`, never a
|
|
305
354
|
* list, so it carries no count bounds (a list of them does). `crop` is the asset's
|
|
306
355
|
* contract — the editor's cropper and `<Image>`'s mobile-crop switch read it; the box
|
|
307
|
-
* the image renders in is the section's own classes.
|
|
308
|
-
* candidate pool the editor offers, routing the slot to a dedicated picker.
|
|
356
|
+
* the image renders in is the section's own classes.
|
|
309
357
|
* `source: fill({ brief })` picks one of the property's photos.
|
|
310
358
|
* @example
|
|
311
359
|
* ```ts
|
|
312
|
-
* import { image } from "@homepages/concrete";
|
|
360
|
+
* import { fill, image } from "@homepages/concrete";
|
|
313
361
|
*
|
|
314
|
-
* image({ label: "
|
|
362
|
+
* image({ label: "Hero photo", crop: { mode: "locked", aspect: 16 / 9 }, source: fill({ brief: "The strongest exterior." }) });
|
|
315
363
|
* ```
|
|
316
364
|
*/
|
|
317
365
|
declare function image<const HasSource extends SourceBinding | undefined = undefined>(opts: ImageOptions & {
|
|
318
366
|
source?: HasSource;
|
|
319
367
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, ImageValue | null>): ImageSlotDef & SourceMark<HasSource> & FillMark;
|
|
320
368
|
type VideoSources = readonly [VideoSource, ...VideoSource[]];
|
|
321
|
-
interface VideoOptions extends CommonOptions<VideoValue | null, AssetFill
|
|
369
|
+
interface VideoOptions extends CommonOptions<VideoValue | null, AssetFill>, AssetRowOptions {
|
|
322
370
|
playback?: PlaybackConfig;
|
|
323
371
|
sources?: VideoSources;
|
|
324
372
|
}
|
|
@@ -327,6 +375,7 @@ interface VideoSlotDef extends Head {
|
|
|
327
375
|
type: "video";
|
|
328
376
|
playback?: PlaybackConfig;
|
|
329
377
|
sources?: VideoSources;
|
|
378
|
+
unique?: true;
|
|
330
379
|
}
|
|
331
380
|
/**
|
|
332
381
|
* A single video slot, resolved as a `VideoValue`. Unlike `image`, there is no
|
|
@@ -345,10 +394,11 @@ interface VideoSlotDef extends Head {
|
|
|
345
394
|
declare function video<const HasSource extends SourceBinding | undefined = undefined>(opts: VideoOptions & {
|
|
346
395
|
source?: HasSource;
|
|
347
396
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, VideoValue | null>): VideoSlotDef & SourceMark<HasSource> & FillMark;
|
|
348
|
-
type TourOptions = CommonOptions<TourValue | null, AssetFill
|
|
397
|
+
type TourOptions = CommonOptions<TourValue | null, AssetFill> & AssetRowOptions;
|
|
349
398
|
/** The serialized shape the `tour` builder emits — a `tour`-kind `SlotDef`. */
|
|
350
399
|
interface TourSlotDef extends Head {
|
|
351
400
|
type: "tour";
|
|
401
|
+
unique?: true;
|
|
352
402
|
}
|
|
353
403
|
/**
|
|
354
404
|
* A single 3D-tour slot, resolved as a `TourValue`. Its own kind rather than a
|
|
@@ -372,21 +422,14 @@ interface TourSlotDef extends Head {
|
|
|
372
422
|
declare function tour<const HasSource extends SourceBinding | undefined = undefined>(opts: TourOptions & {
|
|
373
423
|
source?: HasSource;
|
|
374
424
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, TourValue | null>): TourSlotDef & SourceMark<HasSource> & FillMark;
|
|
375
|
-
type StripHead<E> = Omit<E, "locked">;
|
|
376
|
-
interface ListOptions<E> extends CommonOptions<NonNullable<SlotValue<E>>[], ListFillFor<E>> {
|
|
377
|
-
min?: number;
|
|
378
|
-
max?: number;
|
|
379
|
-
unique?: boolean;
|
|
380
|
-
title?: never;
|
|
381
|
-
layout?: never;
|
|
382
|
-
}
|
|
425
|
+
type StripHead<E> = Omit<E, "locked" | "unique">;
|
|
383
426
|
/**
|
|
384
|
-
* The serialized shape
|
|
385
|
-
* `
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* item
|
|
389
|
-
*
|
|
427
|
+
* The serialized shape a single-item list emits — a `list`-kind `SlotDef` carrying
|
|
428
|
+
* `element` (never `fields`). `element` is the bare item shape (its `locked` is
|
|
429
|
+
* stripped, since a list holds present items, not an editable slot itself).
|
|
430
|
+
* `min`/`max` bound the list's item count; `unique` says no two items hold the same
|
|
431
|
+
* value — written on the item (`select({ …, unique: true })`, `image({ …, unique: true })`),
|
|
432
|
+
* stored here — and is passed through as-authored: this module does not itself
|
|
390
433
|
* deduplicate anything.
|
|
391
434
|
*/
|
|
392
435
|
interface ListSlotDef<E> extends Head {
|
|
@@ -402,49 +445,130 @@ type ListFillFor<E> = E extends {
|
|
|
402
445
|
type: "poi";
|
|
403
446
|
} ? FillFor<"count"> : FillFor<"count" | "none">;
|
|
404
447
|
type ListRecordFill = FillFor<"count" | "none">;
|
|
405
|
-
interface ListRecordOptions<I extends Record<string, ListFieldSlot>> extends CommonOptions<RowValue<I>[], ListRecordFill> {
|
|
406
|
-
min?: number;
|
|
407
|
-
max?: number;
|
|
408
|
-
layout?: readonly LayoutRow<keyof I & string>[];
|
|
409
|
-
title?: keyof I & string;
|
|
410
|
-
unique?: never;
|
|
411
|
-
}
|
|
412
448
|
/**
|
|
413
|
-
* The serialized shape
|
|
414
|
-
* `
|
|
415
|
-
*
|
|
416
|
-
*
|
|
449
|
+
* The serialized shape a record list emits — a `list`-kind `SlotDef` carrying
|
|
450
|
+
* `fields` (never `element`), plus the record-item surface: `title` (the field whose
|
|
451
|
+
* value titles each row). Its fields' declaration order is the row's order; which of
|
|
452
|
+
* them share a row is the editor's rule.
|
|
417
453
|
*/
|
|
418
454
|
interface ListRecordSlotDef<I extends Record<string, ListFieldSlot>> extends Head {
|
|
419
455
|
type: "list";
|
|
420
456
|
fields: I;
|
|
421
|
-
layout?: (string | [string, string])[];
|
|
422
457
|
title?: string;
|
|
423
458
|
min?: number;
|
|
424
459
|
max?: number;
|
|
425
460
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
461
|
+
interface ListHeadOptions {
|
|
462
|
+
label: string;
|
|
463
|
+
locked?: boolean;
|
|
464
|
+
placeholder?: string;
|
|
465
|
+
when?: string | readonly string[];
|
|
466
|
+
min?: number;
|
|
467
|
+
max?: number;
|
|
468
|
+
}
|
|
469
|
+
/** `list({ item })`: one slot per entry. Its distinctness is the item's `unique`. */
|
|
470
|
+
interface ListItemOptions<E> extends ListHeadOptions {
|
|
471
|
+
item: E;
|
|
472
|
+
fields?: never;
|
|
473
|
+
title?: never;
|
|
474
|
+
source?: SlotSource | RowRef | ComputeBinding<NonNullable<SlotValue<E>>[]> | MirrorSource | ListFillFor<E>;
|
|
475
|
+
writeback?: boolean;
|
|
476
|
+
}
|
|
477
|
+
/** A collection a record list's rows are baked from: `fact.property.units`, `.contacts` or `.comparables`. */
|
|
478
|
+
type CollectionSource = {
|
|
479
|
+
readonly kind: "direct";
|
|
480
|
+
readonly field: CollectionField;
|
|
481
|
+
};
|
|
482
|
+
/** Where a record list's rows come from: a collection, a `compute()` or a slot holding rows, or the model. */
|
|
483
|
+
type ListRowsSource = CollectionSource | ComputeBinding<readonly object[]> | MirrorSource | ListRecordFill;
|
|
484
|
+
/**
|
|
485
|
+
* `list({ fields })`: a record per entry. `fields` receives the row reference, whose
|
|
486
|
+
* members the `source` decides (`RowOf`); `title` names the field that titles a row.
|
|
487
|
+
*/
|
|
488
|
+
interface ListFieldsOptions<HasSource, I> extends ListHeadOptions {
|
|
430
489
|
source?: HasSource;
|
|
431
|
-
|
|
490
|
+
fields: (row: RowOf<HasSource>) => I;
|
|
491
|
+
item?: never;
|
|
492
|
+
title?: NoInfer<keyof I & string>;
|
|
493
|
+
writeback?: boolean;
|
|
494
|
+
}
|
|
432
495
|
/**
|
|
433
|
-
*
|
|
434
|
-
*
|
|
435
|
-
*
|
|
436
|
-
* `list.of(poi({ label: "Restaurant" }), { max: 6, label: "Restaurants" })`)
|
|
437
|
-
* or a record of slots
|
|
438
|
-
* (`list.of({ photo: image({ label: "Photo" }), caption: text.short({ label: "Caption", cap: 80 }) }, { label: "Slides" })`).
|
|
439
|
-
* A single item emits `element`; a record emits `fields` with the optional
|
|
440
|
-
* `layout`/`title` row surface. Depth is fixed: an item is never a list, a
|
|
441
|
-
* record field is never a record, and a field-level list holds a single
|
|
442
|
-
* non-record item — each violation is a compile error here and a parse error
|
|
443
|
-
* on the wire.
|
|
496
|
+
* One baked row of a record list: the collection's identity key beside each declared
|
|
497
|
+
* field — nothing of the collection reaches a row a field does not name. A row the
|
|
498
|
+
* model or a `compute()` supplies carries the stamped `id` instead.
|
|
444
499
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
500
|
+
type DeclaredRow<HasSource, I> = HasSource extends {
|
|
501
|
+
kind: "direct";
|
|
502
|
+
field: infer C extends CollectionField;
|
|
503
|
+
} ? BoundRowValue<C, I> : RowValue<I>;
|
|
504
|
+
/** What a `fields` list's rows are typed as, carried as a phantom `SlotValue` reads. */
|
|
505
|
+
type DeclaredRowsMark<HasSource, I> = {
|
|
506
|
+
readonly __row?: DeclaredRow<HasSource, I>;
|
|
447
507
|
};
|
|
508
|
+
/**
|
|
509
|
+
* The list slot — one primitive for everything multi-item, declared with one options
|
|
510
|
+
* object and exactly one of `item` or `fields`.
|
|
511
|
+
*
|
|
512
|
+
* `item` is one slot per entry: `list({ label: "Features", item: text.short({ label: "Feature", cap: 80 }) })`.
|
|
513
|
+
* A select or media item may say `unique: true`: no two entries hold the same value.
|
|
514
|
+
*
|
|
515
|
+
* `fields` is a record per entry, written as a function of the row reference, whose
|
|
516
|
+
* members follow the list's `source`:
|
|
517
|
+
*
|
|
518
|
+
* - bound to a collection (`fact.property.units`, `.contacts`, `.comparables`), `row`
|
|
519
|
+
* offers that collection's members — `unit.beds`, `contact.headshot`, `comp.photo` —
|
|
520
|
+
* each a legal row field `source:` (with `writeback`, `true` only on a writable
|
|
521
|
+
* member) and a legal `reads` entry of a row field's `fill()` or `compute()`;
|
|
522
|
+
* - sourced by a `compute()` or another slot, `row` offers the members of that value's
|
|
523
|
+
* rows;
|
|
524
|
+
* - sourced by a `fill()`, the model writes each row, and every field declares its own
|
|
525
|
+
* `fill()`: a field reads an EARLIER field of its row by that field's const.
|
|
526
|
+
*
|
|
527
|
+
* Every row field declares its origin — a row member, a `fill()` or a `compute()`. A
|
|
528
|
+
* property fact is the same value in every row, so it is read inside a field's
|
|
529
|
+
* `reads`, never bound; `fact.unit.*` and `fact.contact.*` name the primary row.
|
|
530
|
+
* Inside a list, `unique: true` on a select or media field says its value does not
|
|
531
|
+
* repeat across the rows.
|
|
532
|
+
*
|
|
533
|
+
* Depth is fixed: an item is never a list, a record field is never a record, and a
|
|
534
|
+
* field-level list holds a single non-record item.
|
|
535
|
+
* @example
|
|
536
|
+
* ```ts
|
|
537
|
+
* import { fact, fill, image, list, number, text } from "@homepages/concrete";
|
|
538
|
+
*
|
|
539
|
+
* list({
|
|
540
|
+
* label: "Units",
|
|
541
|
+
* source: fact.property.units,
|
|
542
|
+
* writeback: false,
|
|
543
|
+
* title: "unit_label",
|
|
544
|
+
* fields: (unit) => ({
|
|
545
|
+
* unit_label: text.medium({ label: "Unit name", cap: 40, source: unit.unit_label, writeback: true }),
|
|
546
|
+
* beds: number({ label: "Beds", source: unit.beds, writeback: true }),
|
|
547
|
+
* floor_plans: list({ label: "Floor plans", source: unit.floor_plans, writeback: false, item: image({ label: "Floor plan" }) }),
|
|
548
|
+
* }),
|
|
549
|
+
* });
|
|
550
|
+
*
|
|
551
|
+
* list({
|
|
552
|
+
* label: "FAQ",
|
|
553
|
+
* source: fill({ count: 6, brief: "Questions a buyer would ask, each on a different topic." }),
|
|
554
|
+
* fields: () => {
|
|
555
|
+
* const question = text.medium({ label: "Question", cap: 72, source: fill({ brief: "One question." }) });
|
|
556
|
+
* return {
|
|
557
|
+
* question,
|
|
558
|
+
* answer: text.long({ label: "Answer", cap: 300, source: fill({ reads: [fact.description, question], brief: "Answer it." }) }),
|
|
559
|
+
* };
|
|
560
|
+
* },
|
|
561
|
+
* });
|
|
562
|
+
* ```
|
|
563
|
+
*/
|
|
564
|
+
interface ListBuilder {
|
|
565
|
+
<const E extends ListItemSlot, const HasSource extends SourceBinding | undefined = undefined>(opts: ListItemOptions<E> & {
|
|
566
|
+
source?: HasSource;
|
|
567
|
+
} & WritebackOption<HasSource> & MirrorOption<HasSource, NonNullable<SlotValue<E>>[]>): ListSlotDef<StripHead<E>> & SourceMark<HasSource> & FillMark;
|
|
568
|
+
<const I extends Record<string, ListFieldSlot>, const HasSource extends ListRowsSource | undefined = undefined>(opts: ListFieldsOptions<HasSource, I> & WritebackOption<HasSource>): ListRecordSlotDef<I> & SourceMark<HasSource> & FillMark & DeclaredRowsMark<HasSource, I>;
|
|
569
|
+
}
|
|
570
|
+
/** The list builder — see {@link ListBuilder}. */
|
|
571
|
+
declare const list: ListBuilder;
|
|
448
572
|
interface PoiOptions {
|
|
449
573
|
label: string;
|
|
450
574
|
locked?: boolean;
|
|
@@ -459,7 +583,7 @@ interface PoiSlotDef extends Head {
|
|
|
459
583
|
* A single point of interest — one platform-built place (a `PoiRow`), picked
|
|
460
584
|
* in the editor's place search. The platform owns the row's content; there is
|
|
461
585
|
* nothing to configure beyond the head. Usable standalone or as a list item
|
|
462
|
-
* (`list
|
|
586
|
+
* (`list({ label: "Restaurants", item: poi({ label: "Restaurant" }) })`).
|
|
463
587
|
* @example
|
|
464
588
|
* ```ts
|
|
465
589
|
* import { poi } from "@homepages/concrete";
|
|
@@ -468,7 +592,7 @@ interface PoiSlotDef extends Head {
|
|
|
468
592
|
* ```
|
|
469
593
|
*/
|
|
470
594
|
declare function poi(opts: PoiOptions): PoiSlotDef;
|
|
471
|
-
interface DocumentOptions {
|
|
595
|
+
interface DocumentOptions extends AssetRowOptions {
|
|
472
596
|
label: string;
|
|
473
597
|
locked?: boolean;
|
|
474
598
|
placeholder?: string;
|
|
@@ -478,6 +602,7 @@ interface DocumentOptions {
|
|
|
478
602
|
/** The serialized shape the `document` builder emits — a `document`-kind `SlotDef`. */
|
|
479
603
|
interface DocumentSlotDef extends Head {
|
|
480
604
|
type: "document";
|
|
605
|
+
unique?: true;
|
|
481
606
|
}
|
|
482
607
|
/**
|
|
483
608
|
* A single platform-hosted document — a pdf, spreadsheet, or office file the
|
|
@@ -492,7 +617,7 @@ interface DocumentSlotDef extends Head {
|
|
|
492
617
|
* property. The model sees each candidate's filename, file type, and whatever text
|
|
493
618
|
* was distilled out of it (a spreadsheet or slide deck carries none, so name the
|
|
494
619
|
* file type when it matters). Usable standalone or as a list item — a
|
|
495
|
-
* `list
|
|
620
|
+
* `list({ item: document(…) })` carries its own fill and picks a SET from the same pool.
|
|
496
621
|
* @example
|
|
497
622
|
* ```ts
|
|
498
623
|
* import { document, fill } from "@homepages/concrete";
|
|
@@ -505,4 +630,4 @@ interface DocumentSlotDef extends Head {
|
|
|
505
630
|
*/
|
|
506
631
|
declare function document(opts: DocumentOptions): DocumentSlotDef & FillMark;
|
|
507
632
|
//#endregion
|
|
508
|
-
export { CropConfig, DisplayEntryInput, DisplayFill, DocumentSlotDef, ImageSlotDef, ListRecordSlotDef, ListSlotDef, MirrorOption, MirrorSource, NumberSlotDef, PoiSlotDef, SelectOptionInput, SelectSlotDef, SlotSource, SourceBinding, SourceMark, TextSlotDef, TourSlotDef, UrlSlotDef, VideoSlotDef, WritebackOption, document, image, list, number, poi, select, text, tour, url, video };
|
|
633
|
+
export { CropConfig, DeclaredRow, DeclaredRowsMark, DisplayEntryInput, DisplayFill, DocumentSlotDef, ImageSlotDef, ListBuilder, ListRecordSlotDef, ListSlotDef, MirrorOption, MirrorSource, NumberSlotDef, PoiSlotDef, SelectBuilder, SelectOptionInput, SelectSlotDef, SlotSource, SourceBinding, SourceMark, TextSlotDef, TourSlotDef, UrlSlotDef, VideoSlotDef, WritebackOption, document, image, list, number, poi, select, text, tour, url, video };
|