@yschimke/compose-design-map 1.10.0 → 1.11.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/design-map.mjs +46 -17
- package/package.json +1 -1
package/design-map.mjs
CHANGED
|
@@ -98,21 +98,19 @@ export function sourceForRef(ref) {
|
|
|
98
98
|
* its non-default seeds is missing the axes it happens to sit at, and a kit that spells its default
|
|
99
99
|
* size explicitly in a combination cell then has nothing to match against.
|
|
100
100
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (catalog.state && !props.some((p) => p.key === "state")) {
|
|
110
|
-
props.push({ key: "state", value: catalog.state });
|
|
111
|
-
}
|
|
112
|
-
return props.map((p) => ({ key: p.key, raw: p.value }));
|
|
101
|
+
function foldSeeds(catalog) {
|
|
102
|
+
// `props` names the axis; `state` is the annotation's shorthand for the one axis common enough
|
|
103
|
+
// to have its own parameter. Either is a declaration, so neither is inferred —
|
|
104
|
+
// `@CatalogVariant(state = "disabled")` says the state axis as plainly as
|
|
105
|
+
// `props = ["state=disabled"]` would.
|
|
106
|
+
const props = [...(catalog.props ?? [])];
|
|
107
|
+
if (catalog.state && !props.some((p) => p.key === "state")) {
|
|
108
|
+
props.push({ key: "state", value: catalog.state });
|
|
113
109
|
}
|
|
110
|
+
return props.map((p) => ({ key: p.key, raw: p.value }));
|
|
111
|
+
}
|
|
114
112
|
|
|
115
|
-
|
|
113
|
+
function cellSeeds(overrides) {
|
|
116
114
|
if (!overrides) return [];
|
|
117
115
|
|
|
118
116
|
const seeds = overrides.props?.length
|
|
@@ -132,13 +130,36 @@ export function variantSeeds(preview) {
|
|
|
132
130
|
return seeds;
|
|
133
131
|
}
|
|
134
132
|
|
|
133
|
+
export function variantSeeds(preview) {
|
|
134
|
+
const catalog = preview.catalog;
|
|
135
|
+
const fold = catalog?.role === "VARIANT" ? foldSeeds(catalog) : [];
|
|
136
|
+
const cell = cellSeeds(preview.overrides);
|
|
137
|
+
if (!fold.length) return cell;
|
|
138
|
+
if (!cell.length) return fold;
|
|
139
|
+
|
|
140
|
+
// BOTH: an `@OverrideVariant` cell on a `@CatalogVariant` render — the folded component's own
|
|
141
|
+
// matrix. The render sits at the product of the two axes (`type=wave` AND `progress=1.0`), so it
|
|
142
|
+
// declares both; taking either half alone would resolve to a sibling node and diff the wrong
|
|
143
|
+
// frame. Folding a component used to cost it its whole matrix for want of this.
|
|
144
|
+
//
|
|
145
|
+
// The CELL wins a key collision. Both describe the same render, but the cell's value is what the
|
|
146
|
+
// renderer actually seeded, and the fold's is the default it seeded over.
|
|
147
|
+
const seeded = new Set(cell.map((s) => s.key));
|
|
148
|
+
return [...fold.filter((s) => !seeded.has(s.key)), ...cell];
|
|
149
|
+
}
|
|
150
|
+
|
|
135
151
|
/** The name a variant render goes by, for a report and for the design-map `state` slot. */
|
|
136
152
|
function variantName(preview, seeds) {
|
|
137
153
|
const catalog = preview.catalog;
|
|
154
|
+
const cell = preview.overrides?.name;
|
|
138
155
|
if (catalog?.role === "VARIANT") {
|
|
139
|
-
|
|
156
|
+
// Named for the FOLD's own axis, not for the merged vector — `wave`, not `wave-1.0` — so a
|
|
157
|
+
// folded component's cells read as `wave-full` / `wave-quarter` under it, the same shape a
|
|
158
|
+
// top-level component's cells have.
|
|
159
|
+
const fold = catalog.state ?? foldSeeds(catalog).map((s) => s.raw).join("-");
|
|
160
|
+
return cell ? `${fold}-${cell}` : fold;
|
|
140
161
|
}
|
|
141
|
-
return
|
|
162
|
+
return cell ?? seeds.map((s) => `${s.key}=${s.raw}`).join(", ");
|
|
142
163
|
}
|
|
143
164
|
|
|
144
165
|
/**
|
|
@@ -157,10 +178,18 @@ export function variantRendersByComponent(previews) {
|
|
|
157
178
|
// An `@OverrideVariant` render is a reseed of the SAME composable, so it keeps the parent's
|
|
158
179
|
// COMPONENT role and is distinguished only by the `_VARIANT_` tag discovery puts in its id.
|
|
159
180
|
// A `@CatalogVariant` render is its own composable, so it carries the VARIANT role and an
|
|
160
|
-
// ordinary light-capture id.
|
|
181
|
+
// ordinary light-capture id.
|
|
182
|
+
//
|
|
183
|
+
// A VARIANT role with a `_VARIANT_` id is the third case, and it used to fall through both
|
|
184
|
+
// tests into the `continue` below: a folded component carrying a matrix of its own. Discovery
|
|
185
|
+
// emitted those renders all along — they were simply never projected, so the kit nodes they
|
|
186
|
+
// sit on went uncompared, and a component could not be folded without deleting its cells.
|
|
187
|
+
// Either way only the light capture participates.
|
|
161
188
|
const isOverrideVariant =
|
|
162
189
|
catalog.role === "COMPONENT" && LIGHT_VARIANT_CAPTURE.test(preview.id);
|
|
163
|
-
const isCatalogVariant =
|
|
190
|
+
const isCatalogVariant =
|
|
191
|
+
catalog.role === "VARIANT" &&
|
|
192
|
+
(LIGHT_CAPTURE.test(preview.id) || LIGHT_VARIANT_CAPTURE.test(preview.id));
|
|
164
193
|
if (!isOverrideVariant && !isCatalogVariant) continue;
|
|
165
194
|
|
|
166
195
|
// A variant that names no axis says only "this is different", which is not enough to look
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yschimke/compose-design-map",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.0",
|
|
4
4
|
"description": "Project a compose-preview discovery manifest into design-parity's design-map.json, plus a sidecar of unresolved variant declarations. Dependency-free.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|