@homepages/concrete 6.1.0 → 7.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 +166 -0
- package/codemods/manifest.json +17 -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-D8eepVr-.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 +75 -32
- 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 +31 -8
- 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 -1
- 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 +0 -4
- package/dist/packages/internal/section-contracts/dist/choose-select-contract.js +4 -4
- package/dist/packages/internal/section-contracts/dist/display-evidence-contract.js +2 -1
- package/dist/packages/internal/section-contracts/dist/fill-spec-view.js +5 -1
- package/dist/packages/internal/section-contracts/dist/group-contract.js +1 -3
- package/dist/packages/internal/section-contracts/dist/index.js +0 -1
- package/dist/packages/internal/section-contracts/dist/list-fill-contract.js +3 -3
- package/dist/packages/internal/section-contracts/dist/list-scalar-contract.js +1 -5
- package/dist/packages/internal/section-contracts/dist/name-title-contract.js +2 -2
- package/dist/packages/internal/section-contracts/dist/pooling-field-contract.js +3 -1
- package/dist/packages/internal/section-contracts/dist/row-fill-contract.js +14 -0
- package/dist/packages/internal/section-contracts/dist/runners.js +0 -5
- package/dist/packages/internal/section-contracts/dist/source-contract.js +80 -4
- package/dist/packages/internal/section-contracts/dist/writer-reads-fact-contract.js +12 -6
- package/dist/packages/internal/source-resolution/dist/index.js +57 -20
- package/dist/packages/internal/template-contracts/dist/facts-view.d.ts +16 -17
- package/dist/packages/internal/template-contracts/dist/facts-view.js +6 -18
- package/dist/packages/internal/template-contracts/dist/row-sources.js +26 -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 -289
- 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 +32 -17
- package/dist/schema/extract-fill-spec.js +15 -13
- package/dist/schema/fact.d.ts +2 -19
- package/dist/schema/fill-builders.d.ts +4 -3
- package/dist/schema/fill-spec.js +9 -1
- package/dist/schema/layout.d.ts +6 -8
- package/dist/schema/layout.js +3 -9
- package/dist/schema/property-facts.d.ts +16 -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 +222 -117
- 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 +1 -2
- 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/row-contract.js +0 -37
- 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[];
|
|
@@ -179,19 +186,18 @@ interface NumberSlotDef extends Head {
|
|
|
179
186
|
declare function number<const HasSource extends SourceBinding | undefined = undefined>(opts: NumberOptions & {
|
|
180
187
|
source?: HasSource;
|
|
181
188
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, number | null>): NumberSlotDef & SourceMark<HasSource>;
|
|
182
|
-
/** One
|
|
189
|
+
/** One authored select choice: a bare string (value === label) or a stored key with display text. */
|
|
183
190
|
type SelectOptionInput = string | {
|
|
184
191
|
value: string;
|
|
185
192
|
label: string;
|
|
186
193
|
};
|
|
187
|
-
interface SelectOptions extends CommonOptions<string | null> {
|
|
188
|
-
creatable?: boolean;
|
|
189
|
-
}
|
|
190
194
|
/**
|
|
191
|
-
* The serialized shape
|
|
192
|
-
* `values` (
|
|
193
|
-
* vocabulary) are mutually exclusive
|
|
194
|
-
* the slot was built with `select
|
|
195
|
+
* The serialized shape a select slot emits — a `select`-kind `SlotDef`.
|
|
196
|
+
* `values` (the authored `options`, stored under their old name) and
|
|
197
|
+
* `options.source` (a fact-derived vocabulary) are mutually exclusive: which one is
|
|
198
|
+
* present depends on whether the slot was built with `select({ options })` or
|
|
199
|
+
* `select({ source: fact.… })`. `unique` rides only on a record row's field; a
|
|
200
|
+
* list's single item hands it to the list (`list({ item })`), which stores it there.
|
|
195
201
|
*/
|
|
196
202
|
interface SelectSlotDef extends Head {
|
|
197
203
|
type: "select";
|
|
@@ -200,17 +206,24 @@ interface SelectSlotDef extends Head {
|
|
|
200
206
|
source: string;
|
|
201
207
|
};
|
|
202
208
|
creatable?: boolean;
|
|
209
|
+
unique?: true;
|
|
210
|
+
}
|
|
211
|
+
/** The one source that supplies a select's vocabulary: a direct fact binding. */
|
|
212
|
+
type FactSource = Extract<SlotSource, {
|
|
213
|
+
kind: "direct";
|
|
214
|
+
}>;
|
|
215
|
+
interface SelectFactOptions extends Omit<CommonOptions<never>, "source"> {
|
|
216
|
+
creatable?: boolean;
|
|
217
|
+
options?: never;
|
|
218
|
+
unique?: never;
|
|
203
219
|
}
|
|
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
220
|
type SelectFill = FillFor<"none">;
|
|
208
|
-
interface
|
|
221
|
+
interface SelectChoiceOptions extends Omit<CommonOptions<never>, "source"> {
|
|
222
|
+
options: readonly SelectOptionInput[];
|
|
209
223
|
creatable?: boolean;
|
|
224
|
+
unique?: true;
|
|
225
|
+
source?: ComputeBinding<string | null> | MirrorSource | RowRef | SelectFill;
|
|
210
226
|
}
|
|
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
227
|
/**
|
|
215
228
|
* The fill a `meta.display` entry takes: the model picks ONE of the entry's own
|
|
216
229
|
* cases. The brief and `reads` alone — an entry always resolves a case, so it
|
|
@@ -229,39 +242,53 @@ interface DisplayEntryInput<C extends readonly string[] = readonly string[]> {
|
|
|
229
242
|
locked?: true;
|
|
230
243
|
source?: ComputeBinding<C[number]> | DisplayFill;
|
|
231
244
|
}
|
|
232
|
-
|
|
245
|
+
interface DisplaySelectOptions<C extends readonly [string, ...string[]]> {
|
|
246
|
+
options: C;
|
|
233
247
|
locked?: boolean;
|
|
234
|
-
source?: ComputeBinding<C[number]> | DisplayFill;
|
|
235
|
-
|
|
248
|
+
source?: ComputeBinding<NoInfer<C>[number]> | DisplayFill;
|
|
249
|
+
label?: never;
|
|
250
|
+
}
|
|
236
251
|
/**
|
|
237
|
-
* The select slot
|
|
252
|
+
* The select builder: a slot, a record row's field, a list's item, or a
|
|
253
|
+
* `meta.display` entry, each declared with one options object.
|
|
238
254
|
*
|
|
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.
|
|
255
|
+
* As a slot or field it declares exactly one set of choices:
|
|
256
|
+
* `select({ label, options: [...] })` for an authored vocabulary, or
|
|
257
|
+
* `select({ label, source: fact.… })` for one the fact supplies. A top-level select
|
|
258
|
+
* is bound (or computed) and is never filled. As a record row's field, an authored
|
|
259
|
+
* select declares its own origin like every row field: a member of the row, or its
|
|
260
|
+
* own `source: fill({ brief })`, which picks this one field's key per row in the
|
|
261
|
+
* list's batched call. Inside a list, `unique: true` says a picked value does not
|
|
262
|
+
* repeat across the rows.
|
|
246
263
|
*
|
|
247
|
-
* As a display entry
|
|
248
|
-
* `select(cases,
|
|
249
|
-
* `
|
|
250
|
-
*
|
|
251
|
-
* takes exactly
|
|
264
|
+
* As a display entry — under `display:`, with no `label` —
|
|
265
|
+
* `select({ options: cases, source: compute({ reads }, fn) })` or
|
|
266
|
+
* `select({ options: cases, source: fill({ brief }) })` declares a `meta.display`
|
|
267
|
+
* `visibility`/`variant`: the first case is the default and the failure posture,
|
|
268
|
+
* `locked: true` opts a variant out of user switching, and the entry takes exactly
|
|
269
|
+
* one origin.
|
|
252
270
|
* @example
|
|
253
271
|
* ```ts
|
|
254
272
|
* import { compute, fact, fill, select } from "@homepages/concrete";
|
|
255
273
|
*
|
|
256
|
-
* select
|
|
257
|
-
* select
|
|
258
|
-
* select(["
|
|
259
|
-
* select(["
|
|
274
|
+
* select({ label: "Status", options: ["for_sale", "sold"] });
|
|
275
|
+
* select({ label: "Listing status", source: fact.property.listing_intent, writeback: true });
|
|
276
|
+
* select({ label: "Comparable status", options: ["regular", "highlight"], source: fill({ brief: "Highlight the two or three strongest sales." }) });
|
|
277
|
+
* select({ options: ["visible", "hidden"], source: compute({ reads: [fact.tours] }, (tours) => (tours.length > 0 ? "visible" : "hidden")) });
|
|
278
|
+
* select({ options: ["classic", "editorial"], source: fill({ brief: "Prefer editorial for story-driven narratives." }) });
|
|
260
279
|
* ```
|
|
261
280
|
*/
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
281
|
+
interface SelectBuilder {
|
|
282
|
+
<const C extends readonly [string, ...string[]]>(opts: DisplaySelectOptions<C>): DisplayEntryInput<C>;
|
|
283
|
+
<const HasSource extends SourceBinding | undefined = undefined>(opts: SelectChoiceOptions & {
|
|
284
|
+
source?: HasSource;
|
|
285
|
+
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>): SelectSlotDef & SourceMark<HasSource> & FillMark;
|
|
286
|
+
<const HasSource extends FactSource>(opts: SelectFactOptions & {
|
|
287
|
+
source: HasSource;
|
|
288
|
+
} & WritebackOption<HasSource>): SelectSlotDef & SourceMark<HasSource>;
|
|
289
|
+
}
|
|
290
|
+
/** The select builder — see {@link SelectBuilder}. */
|
|
291
|
+
declare const select: SelectBuilder;
|
|
265
292
|
interface UrlOptions extends CommonOptions<string | null> {
|
|
266
293
|
accepts?: LinkKind | LinkProviderId;
|
|
267
294
|
}
|
|
@@ -290,35 +317,36 @@ declare function url<const HasSource extends SourceBinding | undefined = undefin
|
|
|
290
317
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, string | null>): UrlSlotDef & SourceMark<HasSource>;
|
|
291
318
|
/** The fill a single-asset slot takes: one pick out of that type's pool, which may abstain. */
|
|
292
319
|
type AssetFill = FillFor<"none">;
|
|
293
|
-
interface
|
|
320
|
+
interface AssetRowOptions {
|
|
321
|
+
unique?: true;
|
|
322
|
+
}
|
|
323
|
+
interface ImageOptions extends CommonOptions<ImageValue | null, AssetFill>, AssetRowOptions {
|
|
294
324
|
crop?: CropConfig;
|
|
295
|
-
sourceFilter?: SourceFilter;
|
|
296
325
|
}
|
|
297
326
|
/** The serialized shape the `image` builder emits — an `image`-kind `SlotDef`. */
|
|
298
327
|
interface ImageSlotDef extends Head {
|
|
299
328
|
type: "image";
|
|
300
329
|
crop?: CropConfig;
|
|
301
|
-
|
|
330
|
+
unique?: true;
|
|
302
331
|
}
|
|
303
332
|
/**
|
|
304
333
|
* A single image slot — the resolved value is always one `ImageValue`, never a
|
|
305
334
|
* list, so it carries no count bounds (a list of them does). `crop` is the asset's
|
|
306
335
|
* 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.
|
|
336
|
+
* the image renders in is the section's own classes.
|
|
309
337
|
* `source: fill({ brief })` picks one of the property's photos.
|
|
310
338
|
* @example
|
|
311
339
|
* ```ts
|
|
312
|
-
* import { image } from "@homepages/concrete";
|
|
340
|
+
* import { fill, image } from "@homepages/concrete";
|
|
313
341
|
*
|
|
314
|
-
* image({ label: "
|
|
342
|
+
* image({ label: "Hero photo", crop: { mode: "locked", aspect: 16 / 9 }, source: fill({ brief: "The strongest exterior." }) });
|
|
315
343
|
* ```
|
|
316
344
|
*/
|
|
317
345
|
declare function image<const HasSource extends SourceBinding | undefined = undefined>(opts: ImageOptions & {
|
|
318
346
|
source?: HasSource;
|
|
319
347
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, ImageValue | null>): ImageSlotDef & SourceMark<HasSource> & FillMark;
|
|
320
348
|
type VideoSources = readonly [VideoSource, ...VideoSource[]];
|
|
321
|
-
interface VideoOptions extends CommonOptions<VideoValue | null, AssetFill
|
|
349
|
+
interface VideoOptions extends CommonOptions<VideoValue | null, AssetFill>, AssetRowOptions {
|
|
322
350
|
playback?: PlaybackConfig;
|
|
323
351
|
sources?: VideoSources;
|
|
324
352
|
}
|
|
@@ -327,6 +355,7 @@ interface VideoSlotDef extends Head {
|
|
|
327
355
|
type: "video";
|
|
328
356
|
playback?: PlaybackConfig;
|
|
329
357
|
sources?: VideoSources;
|
|
358
|
+
unique?: true;
|
|
330
359
|
}
|
|
331
360
|
/**
|
|
332
361
|
* A single video slot, resolved as a `VideoValue`. Unlike `image`, there is no
|
|
@@ -345,10 +374,11 @@ interface VideoSlotDef extends Head {
|
|
|
345
374
|
declare function video<const HasSource extends SourceBinding | undefined = undefined>(opts: VideoOptions & {
|
|
346
375
|
source?: HasSource;
|
|
347
376
|
} & WritebackOption<HasSource> & MirrorOption<HasSource, VideoValue | null>): VideoSlotDef & SourceMark<HasSource> & FillMark;
|
|
348
|
-
type TourOptions = CommonOptions<TourValue | null, AssetFill
|
|
377
|
+
type TourOptions = CommonOptions<TourValue | null, AssetFill> & AssetRowOptions;
|
|
349
378
|
/** The serialized shape the `tour` builder emits — a `tour`-kind `SlotDef`. */
|
|
350
379
|
interface TourSlotDef extends Head {
|
|
351
380
|
type: "tour";
|
|
381
|
+
unique?: true;
|
|
352
382
|
}
|
|
353
383
|
/**
|
|
354
384
|
* A single 3D-tour slot, resolved as a `TourValue`. Its own kind rather than a
|
|
@@ -372,21 +402,14 @@ interface TourSlotDef extends Head {
|
|
|
372
402
|
declare function tour<const HasSource extends SourceBinding | undefined = undefined>(opts: TourOptions & {
|
|
373
403
|
source?: HasSource;
|
|
374
404
|
} & 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
|
-
}
|
|
405
|
+
type StripHead<E> = Omit<E, "locked" | "unique">;
|
|
383
406
|
/**
|
|
384
|
-
* The serialized shape
|
|
385
|
-
* `
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
* item
|
|
389
|
-
*
|
|
407
|
+
* The serialized shape a single-item list emits — a `list`-kind `SlotDef` carrying
|
|
408
|
+
* `element` (never `fields`). `element` is the bare item shape (its `locked` is
|
|
409
|
+
* stripped, since a list holds present items, not an editable slot itself).
|
|
410
|
+
* `min`/`max` bound the list's item count; `unique` says no two items hold the same
|
|
411
|
+
* value — written on the item (`select({ …, unique: true })`, `image({ …, unique: true })`),
|
|
412
|
+
* stored here — and is passed through as-authored: this module does not itself
|
|
390
413
|
* deduplicate anything.
|
|
391
414
|
*/
|
|
392
415
|
interface ListSlotDef<E> extends Head {
|
|
@@ -402,49 +425,130 @@ type ListFillFor<E> = E extends {
|
|
|
402
425
|
type: "poi";
|
|
403
426
|
} ? FillFor<"count"> : FillFor<"count" | "none">;
|
|
404
427
|
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
428
|
/**
|
|
413
|
-
* The serialized shape
|
|
414
|
-
* `
|
|
415
|
-
*
|
|
416
|
-
*
|
|
429
|
+
* The serialized shape a record list emits — a `list`-kind `SlotDef` carrying
|
|
430
|
+
* `fields` (never `element`), plus the record-item surface: `title` (the field whose
|
|
431
|
+
* value titles each row). Its fields' declaration order is the row's order; which of
|
|
432
|
+
* them share a row is the editor's rule.
|
|
417
433
|
*/
|
|
418
434
|
interface ListRecordSlotDef<I extends Record<string, ListFieldSlot>> extends Head {
|
|
419
435
|
type: "list";
|
|
420
436
|
fields: I;
|
|
421
|
-
layout?: (string | [string, string])[];
|
|
422
437
|
title?: string;
|
|
423
438
|
min?: number;
|
|
424
439
|
max?: number;
|
|
425
440
|
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
441
|
+
interface ListHeadOptions {
|
|
442
|
+
label: string;
|
|
443
|
+
locked?: boolean;
|
|
444
|
+
placeholder?: string;
|
|
445
|
+
when?: string | readonly string[];
|
|
446
|
+
min?: number;
|
|
447
|
+
max?: number;
|
|
448
|
+
}
|
|
449
|
+
/** `list({ item })`: one slot per entry. Its distinctness is the item's `unique`. */
|
|
450
|
+
interface ListItemOptions<E> extends ListHeadOptions {
|
|
451
|
+
item: E;
|
|
452
|
+
fields?: never;
|
|
453
|
+
title?: never;
|
|
454
|
+
source?: SlotSource | RowRef | ComputeBinding<NonNullable<SlotValue<E>>[]> | MirrorSource | ListFillFor<E>;
|
|
455
|
+
writeback?: boolean;
|
|
456
|
+
}
|
|
457
|
+
/** A collection a record list's rows are baked from: `fact.property.units`, `.contacts` or `.comparables`. */
|
|
458
|
+
type CollectionSource = {
|
|
459
|
+
readonly kind: "direct";
|
|
460
|
+
readonly field: CollectionField;
|
|
461
|
+
};
|
|
462
|
+
/** Where a record list's rows come from: a collection, a `compute()` or a slot holding rows, or the model. */
|
|
463
|
+
type ListRowsSource = CollectionSource | ComputeBinding<readonly object[]> | MirrorSource | ListRecordFill;
|
|
464
|
+
/**
|
|
465
|
+
* `list({ fields })`: a record per entry. `fields` receives the row reference, whose
|
|
466
|
+
* members the `source` decides (`RowOf`); `title` names the field that titles a row.
|
|
467
|
+
*/
|
|
468
|
+
interface ListFieldsOptions<HasSource, I> extends ListHeadOptions {
|
|
430
469
|
source?: HasSource;
|
|
431
|
-
|
|
470
|
+
fields: (row: RowOf<HasSource>) => I;
|
|
471
|
+
item?: never;
|
|
472
|
+
title?: NoInfer<keyof I & string>;
|
|
473
|
+
writeback?: boolean;
|
|
474
|
+
}
|
|
432
475
|
/**
|
|
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.
|
|
476
|
+
* One baked row of a record list: the collection's identity key beside each declared
|
|
477
|
+
* field — nothing of the collection reaches a row a field does not name. A row the
|
|
478
|
+
* model or a `compute()` supplies carries the stamped `id` instead.
|
|
444
479
|
*/
|
|
445
|
-
|
|
446
|
-
|
|
480
|
+
type DeclaredRow<HasSource, I> = HasSource extends {
|
|
481
|
+
kind: "direct";
|
|
482
|
+
field: infer C extends CollectionField;
|
|
483
|
+
} ? BoundRowValue<C, I> : RowValue<I>;
|
|
484
|
+
/** What a `fields` list's rows are typed as, carried as a phantom `SlotValue` reads. */
|
|
485
|
+
type DeclaredRowsMark<HasSource, I> = {
|
|
486
|
+
readonly __row?: DeclaredRow<HasSource, I>;
|
|
447
487
|
};
|
|
488
|
+
/**
|
|
489
|
+
* The list slot — one primitive for everything multi-item, declared with one options
|
|
490
|
+
* object and exactly one of `item` or `fields`.
|
|
491
|
+
*
|
|
492
|
+
* `item` is one slot per entry: `list({ label: "Features", item: text.short({ label: "Feature", cap: 80 }) })`.
|
|
493
|
+
* A select or media item may say `unique: true`: no two entries hold the same value.
|
|
494
|
+
*
|
|
495
|
+
* `fields` is a record per entry, written as a function of the row reference, whose
|
|
496
|
+
* members follow the list's `source`:
|
|
497
|
+
*
|
|
498
|
+
* - bound to a collection (`fact.property.units`, `.contacts`, `.comparables`), `row`
|
|
499
|
+
* offers that collection's members — `unit.beds`, `contact.headshot`, `comp.photo` —
|
|
500
|
+
* each a legal row field `source:` (with `writeback`, `true` only on a writable
|
|
501
|
+
* member) and a legal `reads` entry of a row field's `fill()` or `compute()`;
|
|
502
|
+
* - sourced by a `compute()` or another slot, `row` offers the members of that value's
|
|
503
|
+
* rows;
|
|
504
|
+
* - sourced by a `fill()`, the model writes each row, and every field declares its own
|
|
505
|
+
* `fill()`: a field reads an EARLIER field of its row by that field's const.
|
|
506
|
+
*
|
|
507
|
+
* Every row field declares its origin — a row member, a `fill()` or a `compute()`. A
|
|
508
|
+
* property fact is the same value in every row, so it is read inside a field's
|
|
509
|
+
* `reads`, never bound; `fact.unit.*` and `fact.contact.*` name the primary row.
|
|
510
|
+
* Inside a list, `unique: true` on a select or media field says its value does not
|
|
511
|
+
* repeat across the rows.
|
|
512
|
+
*
|
|
513
|
+
* Depth is fixed: an item is never a list, a record field is never a record, and a
|
|
514
|
+
* field-level list holds a single non-record item.
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* import { fact, fill, image, list, number, text } from "@homepages/concrete";
|
|
518
|
+
*
|
|
519
|
+
* list({
|
|
520
|
+
* label: "Units",
|
|
521
|
+
* source: fact.property.units,
|
|
522
|
+
* writeback: false,
|
|
523
|
+
* title: "unit_label",
|
|
524
|
+
* fields: (unit) => ({
|
|
525
|
+
* unit_label: text.medium({ label: "Unit name", cap: 40, source: unit.unit_label, writeback: true }),
|
|
526
|
+
* beds: number({ label: "Beds", source: unit.beds, writeback: true }),
|
|
527
|
+
* floor_plans: list({ label: "Floor plans", source: unit.floor_plans, writeback: false, item: image({ label: "Floor plan" }) }),
|
|
528
|
+
* }),
|
|
529
|
+
* });
|
|
530
|
+
*
|
|
531
|
+
* list({
|
|
532
|
+
* label: "FAQ",
|
|
533
|
+
* source: fill({ count: 6, brief: "Questions a buyer would ask, each on a different topic." }),
|
|
534
|
+
* fields: () => {
|
|
535
|
+
* const question = text.medium({ label: "Question", cap: 72, source: fill({ brief: "One question." }) });
|
|
536
|
+
* return {
|
|
537
|
+
* question,
|
|
538
|
+
* answer: text.long({ label: "Answer", cap: 300, source: fill({ reads: [fact.description, question], brief: "Answer it." }) }),
|
|
539
|
+
* };
|
|
540
|
+
* },
|
|
541
|
+
* });
|
|
542
|
+
* ```
|
|
543
|
+
*/
|
|
544
|
+
interface ListBuilder {
|
|
545
|
+
<const E extends ListItemSlot, const HasSource extends SourceBinding | undefined = undefined>(opts: ListItemOptions<E> & {
|
|
546
|
+
source?: HasSource;
|
|
547
|
+
} & WritebackOption<HasSource> & MirrorOption<HasSource, NonNullable<SlotValue<E>>[]>): ListSlotDef<StripHead<E>> & SourceMark<HasSource> & FillMark;
|
|
548
|
+
<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>;
|
|
549
|
+
}
|
|
550
|
+
/** The list builder — see {@link ListBuilder}. */
|
|
551
|
+
declare const list: ListBuilder;
|
|
448
552
|
interface PoiOptions {
|
|
449
553
|
label: string;
|
|
450
554
|
locked?: boolean;
|
|
@@ -459,7 +563,7 @@ interface PoiSlotDef extends Head {
|
|
|
459
563
|
* A single point of interest — one platform-built place (a `PoiRow`), picked
|
|
460
564
|
* in the editor's place search. The platform owns the row's content; there is
|
|
461
565
|
* nothing to configure beyond the head. Usable standalone or as a list item
|
|
462
|
-
* (`list
|
|
566
|
+
* (`list({ label: "Restaurants", item: poi({ label: "Restaurant" }) })`).
|
|
463
567
|
* @example
|
|
464
568
|
* ```ts
|
|
465
569
|
* import { poi } from "@homepages/concrete";
|
|
@@ -468,7 +572,7 @@ interface PoiSlotDef extends Head {
|
|
|
468
572
|
* ```
|
|
469
573
|
*/
|
|
470
574
|
declare function poi(opts: PoiOptions): PoiSlotDef;
|
|
471
|
-
interface DocumentOptions {
|
|
575
|
+
interface DocumentOptions extends AssetRowOptions {
|
|
472
576
|
label: string;
|
|
473
577
|
locked?: boolean;
|
|
474
578
|
placeholder?: string;
|
|
@@ -478,6 +582,7 @@ interface DocumentOptions {
|
|
|
478
582
|
/** The serialized shape the `document` builder emits — a `document`-kind `SlotDef`. */
|
|
479
583
|
interface DocumentSlotDef extends Head {
|
|
480
584
|
type: "document";
|
|
585
|
+
unique?: true;
|
|
481
586
|
}
|
|
482
587
|
/**
|
|
483
588
|
* A single platform-hosted document — a pdf, spreadsheet, or office file the
|
|
@@ -492,7 +597,7 @@ interface DocumentSlotDef extends Head {
|
|
|
492
597
|
* property. The model sees each candidate's filename, file type, and whatever text
|
|
493
598
|
* was distilled out of it (a spreadsheet or slide deck carries none, so name the
|
|
494
599
|
* file type when it matters). Usable standalone or as a list item — a
|
|
495
|
-
* `list
|
|
600
|
+
* `list({ item: document(…) })` carries its own fill and picks a SET from the same pool.
|
|
496
601
|
* @example
|
|
497
602
|
* ```ts
|
|
498
603
|
* import { document, fill } from "@homepages/concrete";
|
|
@@ -505,4 +610,4 @@ interface DocumentSlotDef extends Head {
|
|
|
505
610
|
*/
|
|
506
611
|
declare function document(opts: DocumentOptions): DocumentSlotDef & FillMark;
|
|
507
612
|
//#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 };
|
|
613
|
+
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 };
|