@homepages/concrete 1.0.0 → 1.0.1

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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @homepages/concrete
2
2
 
3
+ ## 1.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - c36b03f: A section can draw a unit's floor plans again. A record list bound to the property's units keeps each row's `floor_plans` assignment list on the bound row (`slot.units.value[n].floor_plans`), typed from the units projection, where binding used to reduce it to the `image` kind's `null`. A render function receives only bindings, so before this no section had a way to read which plans belong to which unit. The row field's own binding (`bindItems(slot.units)[n].fields.floor_plans`) is unchanged.
8
+
3
9
  ## 1.0.0
4
10
 
5
11
  ### Major Changes
@@ -4,6 +4,10 @@
4
4
  "1.0.0": {
5
5
  "codemods": [],
6
6
  "manual": []
7
+ },
8
+ "1.0.1": {
9
+ "codemods": [],
10
+ "manual": []
7
11
  }
8
12
  }
9
13
  }
@@ -1,5 +1,5 @@
1
1
  //#region package.json
2
- var version = "1.0.0";
2
+ var version = "1.0.1";
3
3
 
4
4
  //#endregion
5
5
  export { version };
@@ -1,3 +1,5 @@
1
+ import { CollectionField } from "../packages/internal/template-contracts/dist/slot-catalog.js";
2
+ import { CollectionRowValues } from "../schema/fact.js";
1
3
  import { SectionSchemaShape } from "../schema/section-schema.js";
2
4
  import { RowValue, SlotValue } from "../schema/section-props.js";
3
5
  //#region src/primitives/slot-bindings.d.ts
@@ -7,13 +9,31 @@ import { RowValue, SlotValue } from "../schema/section-props.js";
7
9
  * declared-fields row (`RowValue`) — row normalization keeps the
8
10
  * editor-stamped `id` plus each DECLARED field and drops everything else, so a
9
11
  * whole-row-baked slot's projection-only fields (which `SlotValue` types on
10
- * the raw slot value) never survive into a binding. Read those off the raw
11
- * prop, never off a binding's value.
12
+ * the raw slot value) never survive into a binding.
13
+ *
14
+ * One exception, because a section's render receives bindings and nothing
15
+ * else: a declared `image` field that a whole-row-baked collection projects as
16
+ * a LIST — a unit's `floor_plans`, its ordered floor-plan assignments — keeps
17
+ * that list on the bound row, typed from the projection. The field's own
18
+ * `FieldBinding` still holds the `image` kind's value, so the primitives read
19
+ * it exactly as before.
12
20
  */
13
21
  type BoundSlotValue<D> = D extends {
22
+ type: "list";
23
+ source: {
24
+ kind: "direct";
25
+ field: infer F extends CollectionField;
26
+ };
27
+ fields: infer I;
28
+ } ? BoundBakedRow<F, I>[] : D extends {
14
29
  type: "list";
15
30
  fields: infer I;
16
31
  } ? RowValue<I>[] : SlotValue<D>;
32
+ type ProjectedImageListKeys<F extends CollectionField, I> = { [K in keyof I & keyof CollectionRowValues[F]]: I[K] extends {
33
+ type: "image";
34
+ } ? CollectionRowValues[F][K] extends readonly unknown[] ? K : never : never; }[keyof I & keyof CollectionRowValues[F]];
35
+ /** One bound row of a whole-row-baked record list: the declared-fields row, with its projected image lists kept. */
36
+ type BoundBakedRow<F extends CollectionField, I> = Omit<RowValue<I>, ProjectedImageListKeys<F, I>> & { [K in ProjectedImageListKeys<F, I>]: CollectionRowValues[F][K]; };
17
37
  /**
18
38
  * One slot: its id, the definition the section declared for it, and its runtime value.
19
39
  *
@@ -93,4 +113,4 @@ declare function bindItems<D extends {
93
113
  type: "list";
94
114
  }>(binding: SlotBinding<D> | FieldBinding<D>): ItemBinding<D>[];
95
115
  //#endregion
96
- export { BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems };
116
+ export { BoundBakedRow, BoundSlotValue, FieldBinding, ItemBinding, RowBinding, SlotBinding, SlotBindingMap, bindItems };
@@ -73,7 +73,10 @@ function normalizeTour(value) {
73
73
  function normalizeRow(fields, row) {
74
74
  const source = isRecord(row) ? row : {};
75
75
  const normalized = { id: stringField(source.id) };
76
- for (const [field, def] of Object.entries(fields)) normalized[field] = normalizeValue(def, source[field]);
76
+ for (const [field, def] of Object.entries(fields)) {
77
+ const value = source[field];
78
+ normalized[field] = def.type === "image" && Array.isArray(value) ? value.filter(isRecord) : normalizeValue(def, value);
79
+ }
77
80
  return normalized;
78
81
  }
79
82
  function normalizeValue(def, value) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@homepages/concrete",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Concrete, the HomePages template framework: the authoring API, the contract primitives, the styles, the lint preset and the `concrete` command in one package that owns its whole toolchain.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",