@yahoo/uds-create-config 5.68.4 → 5.69.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.
Files changed (34) hide show
  1. package/dist/configs/react-native-system.d.ts +18 -0
  2. package/dist/configs/system.js +2 -0
  3. package/dist/entities/native/NativeSettings.d.ts +18 -0
  4. package/dist/entities/system/Component.js +19 -1
  5. package/dist/entities/system/Settings.d.ts +72 -1
  6. package/dist/entities/system/Settings.js +58 -6
  7. package/dist/framework/Config.d.ts +11 -1
  8. package/dist/framework/Config.js +31 -2
  9. package/dist/framework/class-names.d.ts +1 -1
  10. package/dist/framework/component-states.d.ts +16 -1
  11. package/dist/framework/component-states.js +17 -1
  12. package/dist/framework/defineEntity.d.ts +2 -1
  13. package/dist/framework/defineEntity.js +1 -0
  14. package/dist/framework/plan.d.ts +5 -0
  15. package/dist/framework/plan.js +9 -2
  16. package/dist/framework/registry.d.ts +5 -0
  17. package/dist/framework/registry.js +2 -1
  18. package/dist/framework/schema-version.d.ts +1 -1
  19. package/dist/framework/schema-version.js +5 -5
  20. package/dist/index.d.ts +4 -4
  21. package/dist/index.js +4 -4
  22. package/dist/migrations/20261102143821_default_colors.d.ts +12 -0
  23. package/dist/migrations/20261102143821_default_colors.js +10 -0
  24. package/dist/spec/bake.js +35 -2
  25. package/dist/spec/cell.js +11 -2
  26. package/dist/spec/index.d.ts +2 -2
  27. package/dist/spec/index.js +2 -2
  28. package/dist/spec/preview-content.js +3 -1
  29. package/dist/spec/preview-elements.d.ts +12 -4
  30. package/dist/spec/preview-elements.js +6 -1
  31. package/dist/spec/rewrite-refs.d.ts +14 -2
  32. package/dist/spec/rewrite-refs.js +30 -10
  33. package/dist/tsconfig.tsbuildinfo +1 -1
  34. package/package.json +2 -2
@@ -76,6 +76,24 @@ declare const ReactNativeSystemDefinition: ConfigClass<{
76
76
  reason: _$zod.ZodString;
77
77
  }, _$zod_v4_core0.$strict>>>;
78
78
  }, _$zod_v4_core0.$strict>>;
79
+ defaults: _$zod.ZodOptional<_$zod.ZodObject<{
80
+ background: _$zod.ZodOptional<_$zod.ZodUnion<readonly [_$zod.ZodUnion<readonly [_$zod.ZodString, _$zod.ZodObject<{
81
+ __ref: _$zod.ZodString;
82
+ }, _$zod_v4_core0.$strip>]>, _$zod.ZodObject<{
83
+ value: _$zod.ZodUnion<readonly [_$zod.ZodString, _$zod.ZodObject<{
84
+ __ref: _$zod.ZodString;
85
+ }, _$zod_v4_core0.$strip>]>;
86
+ output: _$zod.ZodOptional<_$zod.ZodBoolean>;
87
+ }, _$zod_v4_core0.$strict>]>>;
88
+ color: _$zod.ZodOptional<_$zod.ZodUnion<readonly [_$zod.ZodUnion<readonly [_$zod.ZodString, _$zod.ZodObject<{
89
+ __ref: _$zod.ZodString;
90
+ }, _$zod_v4_core0.$strip>]>, _$zod.ZodObject<{
91
+ value: _$zod.ZodUnion<readonly [_$zod.ZodString, _$zod.ZodObject<{
92
+ __ref: _$zod.ZodString;
93
+ }, _$zod_v4_core0.$strip>]>;
94
+ output: _$zod.ZodOptional<_$zod.ZodBoolean>;
95
+ }, _$zod_v4_core0.$strict>]>>;
96
+ }, _$zod_v4_core0.$strict>>;
79
97
  }, "css" | "playground" | "canvas"> & {
80
98
  canvas: _$zod.ZodOptional<_$zod.ZodObject<{
81
99
  packageAliases: _$zod.ZodOptional<_$zod.ZodRecord<_$zod.ZodString, _$zod.ZodString>>;
@@ -35,6 +35,7 @@ import { variantValuesListWithBodiesMigration } from "../migrations/202610271844
35
35
  import { lintIgnoreMigration } from "../migrations/20261027205147_lint_ignore.js";
36
36
  import { componentMapPropsMigration } from "../migrations/20261030134149_component_map_props.js";
37
37
  import { layerPrefixMigration } from "../migrations/20261030163028_layer_prefix.js";
38
+ import { defaultColorsMigration } from "../migrations/20261102143821_default_colors.js";
38
39
  import { CanvasRole } from "../entities/system/CanvasRole.js";
39
40
  import { GlobalStyle } from "../entities/system/GlobalStyle.js";
40
41
  import { Guidance } from "../entities/system/Guidance.js";
@@ -203,5 +204,6 @@ if (!registeredSchemaMigrations().has(20261027184442)) registerSchemaMigrations(
203
204
  if (!registeredSchemaMigrations().has(20261027205147)) registerSchemaMigrations(lintIgnoreMigration);
204
205
  if (!registeredSchemaMigrations().has(20261030134149)) registerSchemaMigrations(componentMapPropsMigration);
205
206
  if (!registeredSchemaMigrations().has(20261030163028)) registerSchemaMigrations(layerPrefixMigration);
207
+ if (!registeredSchemaMigrations().has(20261102143821)) registerSchemaMigrations(defaultColorsMigration);
206
208
  //#endregion
207
209
  export { System };
@@ -65,6 +65,24 @@ declare const NativeSettings: EntityClass<z.ZodObject<Omit<{
65
65
  reason: z.ZodString;
66
66
  }, z.core.$strict>>>;
67
67
  }, z.core.$strict>>;
68
+ defaults: z.ZodOptional<z.ZodObject<{
69
+ background: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
70
+ __ref: z.ZodString;
71
+ }, z.core.$strip>]>, z.ZodObject<{
72
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
73
+ __ref: z.ZodString;
74
+ }, z.core.$strip>]>;
75
+ output: z.ZodOptional<z.ZodBoolean>;
76
+ }, z.core.$strict>]>>;
77
+ color: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
78
+ __ref: z.ZodString;
79
+ }, z.core.$strip>]>, z.ZodObject<{
80
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
81
+ __ref: z.ZodString;
82
+ }, z.core.$strip>]>;
83
+ output: z.ZodOptional<z.ZodBoolean>;
84
+ }, z.core.$strict>]>>;
85
+ }, z.core.$strict>>;
68
86
  }, "css" | "playground" | "canvas"> & {
69
87
  canvas: z.ZodOptional<z.ZodObject<{
70
88
  packageAliases: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -152,6 +152,19 @@ function freeLayerKey(config, path, hint = "el") {
152
152
  return `${hint}${ordinal}`;
153
153
  }
154
154
  /**
155
+ * The name a duplicate of the layer `source` takes: its name without a trailing number, numbered
156
+ * from 2 past every name the component already holds, so `box` copies to `box2` and `box2` to
157
+ * `box3` rather than `box21`.
158
+ */
159
+ function duplicateLayerKey({ config, path, source }) {
160
+ const body = config.resolve("component", path)?.toJSON();
161
+ const taken = new Set([...Object.keys(body?.layers ?? {}), ...Object.keys(body?.anatomy ?? {})]);
162
+ const base = source.replace(/\d+$/, "") || source;
163
+ let ordinal = 2;
164
+ while (taken.has(`${base}${ordinal}`)) ordinal += 1;
165
+ return `${base}${ordinal}`;
166
+ }
167
+ /**
155
168
  * A `kind:path` marker string as the ref it means.
156
169
  *
157
170
  * A spec element stores its type as a marker (`component:primitives/Box`), and `element` accepts a
@@ -2026,6 +2039,7 @@ function withoutProps(conditions, names) {
2026
2039
  }
2027
2040
  const ComponentEntity = defineEntity({
2028
2041
  kind: "component",
2042
+ parts: true,
2029
2043
  rebaseLinkedBody: (args) => {
2030
2044
  const body = { ...translateLinkedStyleBags({
2031
2045
  ...args,
@@ -2427,7 +2441,11 @@ count: z.number().int().min(1).max(50).optional() }).prefault({})
2427
2441
  let next = config;
2428
2442
  let previous = source;
2429
2443
  for (let n = 0; n < count; n++) {
2430
- const key = freeLayerKey(next, path, source);
2444
+ const key = duplicateLayerKey({
2445
+ config: next,
2446
+ path,
2447
+ source
2448
+ });
2431
2449
  const siblings = (next.resolve("component", path)?.toJSON())?.anatomy?.[parent]?.children ?? [];
2432
2450
  const index = siblings.indexOf(previous) + 1;
2433
2451
  next = next.run([{
@@ -121,6 +121,59 @@ declare const LintSectionDefinition: SubEntityClass<z.ZodObject<{
121
121
  }, z.core.$strict>>;
122
122
  interface LintSectionClass extends Named<typeof LintSectionDefinition> {}
123
123
  declare const LintSection: LintSectionClass;
124
+ /** A default colour: a CSS colour as written, or a token, which follows the modes it is painted
125
+ * under. `refTo` rather than the `Token` class, which imports back into this module. */
126
+ declare const defaultColorValue: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
127
+ __ref: z.ZodString;
128
+ }, z.core.$strip>]>;
129
+ type DefaultColorValue = z.output<typeof defaultColorValue>;
130
+ /** A default colour on its own, or with `output` saying whether the stylesheet's body rule carries
131
+ * it. */
132
+ declare const defaultColor: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
133
+ __ref: z.ZodString;
134
+ }, z.core.$strip>]>, z.ZodObject<{
135
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
136
+ __ref: z.ZodString;
137
+ }, z.core.$strip>]>;
138
+ output: z.ZodOptional<z.ZodBoolean>;
139
+ }, z.core.$strict>]>;
140
+ /** The `defaults` section — the background and text colour a system's components sit on. */
141
+ declare const DefaultsSectionDefinition: SubEntityClass<z.ZodObject<{
142
+ background: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
143
+ __ref: z.ZodString;
144
+ }, z.core.$strip>]>, z.ZodObject<{
145
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
146
+ __ref: z.ZodString;
147
+ }, z.core.$strip>]>;
148
+ output: z.ZodOptional<z.ZodBoolean>;
149
+ }, z.core.$strict>]>>;
150
+ color: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
151
+ __ref: z.ZodString;
152
+ }, z.core.$strip>]>, z.ZodObject<{
153
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
154
+ __ref: z.ZodString;
155
+ }, z.core.$strip>]>;
156
+ output: z.ZodOptional<z.ZodBoolean>;
157
+ }, z.core.$strict>]>>;
158
+ }, z.core.$strict>>;
159
+ interface DefaultsSectionClass extends Named<typeof DefaultsSectionDefinition> {}
160
+ declare const DefaultsSection: DefaultsSectionClass;
161
+ /** One default colour in its long form: the value, and whether the body rule carries it. */
162
+ interface DefaultColor {
163
+ readonly value: DefaultColorValue;
164
+ readonly output: boolean;
165
+ }
166
+ /** A system's default colours, each in its long form; an unset one is absent. */
167
+ interface DefaultColors {
168
+ readonly background?: DefaultColor;
169
+ readonly color?: DefaultColor;
170
+ }
171
+ /** A default colour as authored: the value alone, or `{ value, output }`. */
172
+ type AuthoredDefaultColor = z.output<typeof defaultColor>;
173
+ /** One default colour in its long form, whichever form it was written in. */
174
+ declare function defaultColorOf(authored: AuthoredDefaultColor | undefined): DefaultColor | undefined;
175
+ /** The `defaults` section as every reader takes it, whichever form each colour was written in. */
176
+ declare function defaultColorsOf(config: Config): DefaultColors;
124
177
  /**
125
178
  * {@link derivedInputDir} over paths alone, for a build that has walked its source graph but not yet
126
179
  * written the `file` rows the computed `inputDir` reads. `components` are the config-relative paths
@@ -175,6 +228,24 @@ declare const SettingsDefinition: EntityClass<z.ZodObject<{
175
228
  reason: z.ZodString;
176
229
  }, z.core.$strict>>>;
177
230
  }, z.core.$strict>>;
231
+ defaults: z.ZodOptional<z.ZodObject<{
232
+ background: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
233
+ __ref: z.ZodString;
234
+ }, z.core.$strip>]>, z.ZodObject<{
235
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
236
+ __ref: z.ZodString;
237
+ }, z.core.$strip>]>;
238
+ output: z.ZodOptional<z.ZodBoolean>;
239
+ }, z.core.$strict>]>>;
240
+ color: z.ZodOptional<z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
241
+ __ref: z.ZodString;
242
+ }, z.core.$strip>]>, z.ZodObject<{
243
+ value: z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
244
+ __ref: z.ZodString;
245
+ }, z.core.$strip>]>;
246
+ output: z.ZodOptional<z.ZodBoolean>;
247
+ }, z.core.$strict>]>>;
248
+ }, z.core.$strict>>;
178
249
  }, z.core.$strict>, z.ZodObject<Record<never, never>, z.core.$strip>, "settings", {}, {
179
250
  /**
180
251
  * The directory this system's component files are laid out beneath, always defined:
@@ -189,4 +260,4 @@ declare const SettingsDefinition: EntityClass<z.ZodObject<{
189
260
  interface SettingsClass extends Named<typeof SettingsDefinition> {}
190
261
  declare const Settings: SettingsClass;
191
262
  //#endregion
192
- export { BuildSection, BuildSectionClass, CSS_DEFAULTS, CssPrefix, CssSection, CssSectionClass, LintSection, LintSectionClass, PLAYGROUND_DEFAULTS, PlaygroundSection, PlaygroundSectionClass, Settings, SettingsClass, SystemSection, SystemSectionClass, classPrefixOf, cssPrefixes, deriveInputDir, layerPrefixOf, prefixed, varPrefixOf };
263
+ export { AuthoredDefaultColor, BuildSection, BuildSectionClass, CSS_DEFAULTS, CssPrefix, CssSection, CssSectionClass, DefaultColor, DefaultColorValue, DefaultColors, DefaultsSection, DefaultsSectionClass, LintSection, LintSectionClass, PLAYGROUND_DEFAULTS, PlaygroundSection, PlaygroundSectionClass, Settings, SettingsClass, SystemSection, SystemSectionClass, classPrefixOf, cssPrefixes, defaultColorOf, defaultColorsOf, deriveInputDir, layerPrefixOf, prefixed, varPrefixOf };
@@ -1,4 +1,4 @@
1
- import { splitRef } from "../../framework/utils/refs.js";
1
+ import { refTo, splitRef } from "../../framework/utils/refs.js";
2
2
  import { defineEntity } from "../../framework/defineEntity.js";
3
3
  import { defineSubEntity } from "../../framework/defineSubEntity.js";
4
4
  import { createSliceMemo } from "../../framework/memo.js";
@@ -23,8 +23,9 @@ import { z } from "zod";
23
23
  * field, and a clone emits only what the system chose. The defaults are the `*_DEFAULTS` constants
24
24
  * beside each section, which the readers fall back to.
25
25
  *
26
- * Not borrowed and not refed today. `linkable: false` is a statement about this kind, not about
27
- * singletons: a consumer's `link: '*'` must not inherit a source's build directories or CSS prefix.
26
+ * Not borrowed and not refed. A `defaults` colour may ref a token, so renaming that token cascades
27
+ * into it. `linkable: false` is a statement about this kind, not about singletons: a consumer's
28
+ * `link: '*'` must not inherit a source's build directories or CSS prefix.
28
29
  */
29
30
  const systemFields = z.strictObject({
30
31
  /**
@@ -222,6 +223,55 @@ const LintSection = defineSubEntity({
222
223
  singleton: true,
223
224
  fields: lintFields
224
225
  });
226
+ /** A default colour: a CSS colour as written, or a token, which follows the modes it is painted
227
+ * under. `refTo` rather than the `Token` class, which imports back into this module. */
228
+ const defaultColorValue = z.union([z.string().min(1), refTo("token")]);
229
+ /** A default colour on its own, or with `output` saying whether the stylesheet's body rule carries
230
+ * it. */
231
+ const defaultColor = z.union([defaultColorValue, z.strictObject({
232
+ value: defaultColorValue,
233
+ output: z.boolean().optional()
234
+ })]);
235
+ const defaultsFields = z.strictObject({
236
+ background: defaultColor.meta({
237
+ title: "Background",
238
+ valueType: "color",
239
+ description: "The background this system's components sit on: a CSS colour (`#ffffff`) or a token (`Token.ref('color/surface')`). The stylesheet sets it on `body`, and Create paints it behind a component's matrix cells, under the modes picked there. `{ value, output: false }` keeps it out of the stylesheet. Unset, neither paints one."
240
+ }).optional(),
241
+ color: defaultColor.meta({
242
+ title: "Text color",
243
+ valueType: "color",
244
+ description: "The text colour this system's components inherit: a CSS colour or a token. The stylesheet sets it on `body`, and Create applies it to a component's matrix cells, under the modes picked there. `{ value, output: false }` keeps it out of the stylesheet. Unset, neither sets one."
245
+ }).optional()
246
+ });
247
+ const DefaultsSection = defineSubEntity({
248
+ name: "defaults",
249
+ label: "Defaults",
250
+ singleton: true,
251
+ fields: defaultsFields
252
+ });
253
+ /** One default colour in its long form, whichever form it was written in. */
254
+ function defaultColorOf(authored) {
255
+ if (authored === void 0) return void 0;
256
+ if (typeof authored === "object" && "value" in authored) return {
257
+ value: authored.value,
258
+ output: authored.output ?? true
259
+ };
260
+ return {
261
+ value: authored,
262
+ output: true
263
+ };
264
+ }
265
+ /** The `defaults` section as every reader takes it, whichever form each colour was written in. */
266
+ function defaultColorsOf(config) {
267
+ const defaults = Settings.get(config)?.defaults;
268
+ const background = defaultColorOf(defaults?.background);
269
+ const color = defaultColorOf(defaults?.color);
270
+ return {
271
+ ...background ? { background } : {},
272
+ ...color ? { color } : {}
273
+ };
274
+ }
225
275
  /** The folders of a path, file name dropped. */
226
276
  const foldersOf = (file) => file.split("/").slice(0, -1);
227
277
  /** The folders every one of `lists` starts with. */
@@ -322,14 +372,16 @@ const Settings = defineEntity({
322
372
  build: buildFields.meta({ title: "Build" }).optional(),
323
373
  css: cssFields.meta({ title: "CSS" }).optional(),
324
374
  playground: playgroundFields.meta({ title: "Playground" }).optional(),
325
- lint: lintFields.meta({ title: "Lint" }).optional()
375
+ lint: lintFields.meta({ title: "Lint" }).optional(),
376
+ defaults: defaultsFields.meta({ title: "Defaults" }).optional()
326
377
  }),
327
378
  subEntities: {
328
379
  system: SystemSection,
329
380
  build: BuildSection,
330
381
  css: CssSection,
331
382
  playground: PlaygroundSection,
332
- lint: LintSection
383
+ lint: LintSection,
384
+ defaults: DefaultsSection
333
385
  },
334
386
  computed: {
335
387
  /**
@@ -340,4 +392,4 @@ const Settings = defineEntity({
340
392
  inputDir: ({ member, config }) => resolveInputDir(member.build) ?? derivedInputDir(config) }
341
393
  });
342
394
  //#endregion
343
- export { BuildSection, CSS_DEFAULTS, CssSection, LintSection, PLAYGROUND_DEFAULTS, PlaygroundSection, Settings, SystemSection, classPrefixOf, cssPrefixes, deriveInputDir, layerPrefixOf, prefixed, varPrefixOf };
395
+ export { BuildSection, CSS_DEFAULTS, CssSection, DefaultsSection, LintSection, PLAYGROUND_DEFAULTS, PlaygroundSection, Settings, SystemSection, classPrefixOf, cssPrefixes, defaultColorOf, defaultColorsOf, deriveInputDir, layerPrefixOf, prefixed, varPrefixOf };
@@ -74,7 +74,7 @@ interface RecordedSource {
74
74
  * The dense-counter `2` a short-lived scheme stamped before the chain existed reads as the mint
75
75
  * that replaced it (see `detectedWireVersion`).
76
76
  */
77
- declare const SERIALIZED_CONFIG_VERSION = 20261030163028;
77
+ declare const SERIALIZED_CONFIG_VERSION = 20261102143821;
78
78
  interface SerializedConfig {
79
79
  /** See {@link SERIALIZED_CONFIG_VERSION}. Always written; a stored artifact may lack it. */
80
80
  readonly version: number;
@@ -1382,6 +1382,16 @@ declare class Config {
1382
1382
  * subgroup (`color/brand/primary`) belongs to `color` too. Getting either wrong is silent: one drags
1383
1383
  * an unrelated group along, the other skips half of what the user sees under the heading.
1384
1384
  */
1385
+ /**
1386
+ * The parts a rename of `from` to `to` moves with it, for a kind that declares
1387
+ * {@link EntityKind.parts}: every item named under `from`, at any depth.
1388
+ */
1389
+ private partMoves;
1390
+ /** The parts renaming `path` to `to` would move with it — see {@link EntityKind.parts}. */
1391
+ renamedParts(kind: string, path: string, to: string): {
1392
+ from: string;
1393
+ to: string;
1394
+ }[];
1385
1395
  private groupMembers;
1386
1396
  /**
1387
1397
  * The declared group nodes nested under `group`, at any depth. Sub-groups are stored apart from a
@@ -2169,10 +2169,23 @@ var Config = class Config {
2169
2169
  if (borrowed !== void 0 && isRef(storedBody) && pathOf(storedBody) === patch.path) reject("UNSUPPORTED", `Cannot rename ${patch.kind} "${patch.path}" — it carries "${borrowed}"'s own name for it. Place it at a path of your own to name it, or link it as a value.`);
2170
2170
  const { value } = extension ? extensionChange(entry, patch.kind, patch.to, extension, false) : itemChange(entry, patch.kind, patch.to, stored);
2171
2171
  const moved = snapshot.withRenamed(patch.kind, "item", patch.path, patch.to, value);
2172
- return this.cascadeRename(moved, `${patch.kind}:${patch.path}`, `${patch.kind}:${patch.to}`, this.entityOf(patch.kind)?.sourceIdentity ? {
2172
+ let next = this.cascadeRename(moved, `${patch.kind}:${patch.path}`, `${patch.kind}:${patch.to}`, this.entityOf(patch.kind)?.sourceIdentity ? {
2173
2173
  from: patch.path,
2174
2174
  to: patch.to
2175
2175
  } : void 0);
2176
+ const parts = this.partMoves(snapshot, entry, patch.path, patch.to);
2177
+ for (const part of parts) {
2178
+ const taken = snapshot.get(patch.kind, part.to);
2179
+ if (taken && !isMintedRow(taken.toJSON())) reject("ALREADY_EXISTS", `Cannot rename ${patch.kind} "${patch.path}" to "${patch.to}" — its part "${part.from}" would land on the ${patch.kind} already at "${part.to}".`);
2180
+ }
2181
+ for (const part of parts) {
2182
+ const current = next.get(patch.kind, part.from);
2183
+ if (!current) continue;
2184
+ const { value } = itemChange(entry, patch.kind, part.to, current.toJSON());
2185
+ next = next.withRenamed(patch.kind, "item", part.from, part.to, value);
2186
+ next = this.cascadeRename(next, `${patch.kind}:${part.from}`, `${patch.kind}:${part.to}`);
2187
+ }
2188
+ return next;
2176
2189
  }
2177
2190
  const updateSchema = dataSchema(entry.schemas, "update");
2178
2191
  if (!updateSchema) reject("UNSUPPORTED", `${patch.kind} has no update operation`);
@@ -2796,6 +2809,22 @@ var Config = class Config {
2796
2809
  * subgroup (`color/brand/primary`) belongs to `color` too. Getting either wrong is silent: one drags
2797
2810
  * an unrelated group along, the other skips half of what the user sees under the heading.
2798
2811
  */
2812
+ /**
2813
+ * The parts a rename of `from` to `to` moves with it, for a kind that declares
2814
+ * {@link EntityKind.parts}: every item named under `from`, at any depth.
2815
+ */
2816
+ partMoves(snapshot, entry, from, to) {
2817
+ if (!entry.parts || from === to) return [];
2818
+ return this.groupMembers(snapshot, entry.name, from).map(({ path }) => ({
2819
+ from: path,
2820
+ to: `${to}${path.slice(from.length)}`
2821
+ }));
2822
+ }
2823
+ /** The parts renaming `path` to `to` would move with it — see {@link EntityKind.parts}. */
2824
+ renamedParts(kind, path, to) {
2825
+ const entry = this.entityOf(kind);
2826
+ return entry ? this.partMoves(this.state.snapshot, entry, path, to) : [];
2827
+ }
2799
2828
  groupMembers(snapshot, kind, group) {
2800
2829
  const members = [];
2801
2830
  for (const [path, entity] of snapshot.slice(kind).items) if (path.startsWith(`${group}/`)) members.push({
@@ -6362,7 +6391,7 @@ var Config = class Config {
6362
6391
  * links from the provided sources. A declared `linkedKind` with no provided source throws. */
6363
6392
  hydrateFrom(stored, options) {
6364
6393
  const claimed = schemaVersionOf(stored);
6365
- if (claimed > 20261030163028) throw new SchemaVersionTooNew(claimed);
6394
+ if (claimed > 20261102143821) throw new SchemaVersionTooNew(claimed);
6366
6395
  const wire = upgradeSerializedConfig(stored);
6367
6396
  if (!Array.isArray(wire.ownedKinds) || typeof wire.items !== "object" || wire.items === null) throw new ConfigFormatError(`Config "${stored.name ?? "system-config"}" cannot be hydrated: this is not a serialized config-v2 config (no "ownedKinds"/"items"). A pre-cutover build artifact converts through the registered cutover migration — import the config type's module (e.g. \`configs/system\`) before hydrating.`);
6368
6397
  const leftover = wire.options;
@@ -1,5 +1,5 @@
1
1
  import { Config } from "./Config.js";
2
- import { ComponentState, UDS_FORCE_STATES, componentStateDefaults, componentStates } from "./component-states.js";
2
+ import { ComponentState, UDS_FORCE_STATES, componentStateDefaults, componentStates, instanceStatePins } from "./component-states.js";
3
3
 
4
4
  //#region src/framework/class-names.d.ts
5
5
  /** `HStack` → `hstack`, `AvatarItem` → `avatar-item`. A dash only between a lower/digit and an
@@ -36,5 +36,20 @@ declare function componentStates(config: Config, path: string): readonly Compone
36
36
  * variant state with no default has no rest value, so a rule naming one of its values waits for one.
37
37
  */
38
38
  declare function componentStateDefaults(config: Config, path: string): Record<string, string | boolean>;
39
+ /**
40
+ * The states a placed instance is pinned in, read off its props: its pins under
41
+ * {@link UDS_FORCE_STATES}, and a value stored under a state's own name where no pin names that
42
+ * state. The render reads a stored instance the same way, so a surface showing the pins shows what
43
+ * paints.
44
+ */
45
+ declare function instanceStatePins({
46
+ config,
47
+ path,
48
+ props
49
+ }: {
50
+ config: Config;
51
+ path: string;
52
+ props: Readonly<Record<string, unknown>> | undefined;
53
+ }): Record<string, unknown>;
39
54
  //#endregion
40
- export { ComponentState, UDS_FORCE_STATES, componentStateDefaults, componentStates };
55
+ export { ComponentState, UDS_FORCE_STATES, componentStateDefaults, componentStates, instanceStatePins };
@@ -49,5 +49,21 @@ function componentStateDefaults(config, path) {
49
49
  else if (state.default !== void 0) out[state.name] = state.default;
50
50
  return out;
51
51
  }
52
+ /**
53
+ * The states a placed instance is pinned in, read off its props: its pins under
54
+ * {@link UDS_FORCE_STATES}, and a value stored under a state's own name where no pin names that
55
+ * state. The render reads a stored instance the same way, so a surface showing the pins shows what
56
+ * paints.
57
+ */
58
+ function instanceStatePins({ config, path, props }) {
59
+ const held = props?.[UDS_FORCE_STATES];
60
+ const pins = held && typeof held === "object" && !Array.isArray(held) ? held : {};
61
+ const out = {};
62
+ for (const { name } of componentStates(config, path)) if (props?.[name] !== void 0) out[name] = props[name];
63
+ return {
64
+ ...out,
65
+ ...pins
66
+ };
67
+ }
52
68
  //#endregion
53
- export { UDS_FORCE_STATES, componentStateDefaults, componentStates };
69
+ export { UDS_FORCE_STATES, componentStateDefaults, componentStates, instanceStatePins };
@@ -316,7 +316,8 @@ declare function defineEntity<F extends FieldsSchema, G extends FieldsSchema = z
316
316
  * mean the ref has to say which.
317
317
  */
318
318
  bareMember?: string; /** Whether a leaf names an item on its own — see {@link EntityKind.uniqueLeaves}. */
319
- uniqueLeaves?: boolean; /** For a source kind: how a pin's source joins this config. See {@link EntityKind.sourceType}. */
319
+ uniqueLeaves?: boolean; /** Whether an item nested under another is a part of it — see {@link EntityKind.parts}. */
320
+ parts?: boolean; /** For a source kind: how a pin's source joins this config. See {@link EntityKind.sourceType}. */
320
321
  sourceType?: (body: Record<string, unknown>) => SourceType; /** This config answers for every item of the kind. See {@link EntityKind.answeredHere}. */
321
322
  answeredHere?: boolean;
322
323
  /**
@@ -131,6 +131,7 @@ function defineEntity(spec) {
131
131
  styleBags: spec.styleBags,
132
132
  rewriteName: spec.rewriteName,
133
133
  uniqueLeaves: spec.uniqueLeaves,
134
+ parts: spec.parts,
134
135
  authoredValue: spec.authoredValue,
135
136
  mentionFields: spec.mentionFields,
136
137
  invariants: spec.invariants,
@@ -32,6 +32,11 @@ interface RenamePlan {
32
32
  /** Rows that use the entity through a source, whose body names it there. The cascade can't rewrite
33
33
  * them, so after the rename they name a path this config no longer holds. */
34
34
  readonly throughSource: readonly EntityAddress[];
35
+ /** The parts that move with it, each to its place under the new path. Absent when there are none. */
36
+ readonly moves?: readonly {
37
+ readonly from: string;
38
+ readonly to: string;
39
+ }[];
35
40
  /** Why the rename would be refused. `undefined` when it would go through. */
36
41
  readonly blocked?: string;
37
42
  }
@@ -34,6 +34,9 @@ function blockedBy(attempt) {
34
34
  throw error;
35
35
  }
36
36
  }
37
+ function unique(refs) {
38
+ return [...new Set(refs)];
39
+ }
37
40
  function addresses(targets) {
38
41
  return targets.map((target) => {
39
42
  const { kind, qualifiedPath } = splitRef(target);
@@ -50,13 +53,17 @@ function planRename({ config, kind, path, to }) {
50
53
  path,
51
54
  to
52
55
  }]));
53
- const throughSource = config.sourceDependentsOf(kind, path);
56
+ const moves = config.renamedParts(kind, path, to);
57
+ const moving = [path, ...moves.map((move) => move.from)];
58
+ const throughSource = unique(moving.flatMap((from) => config.sourceDependentsOf(kind, from)));
54
59
  const drawn = new Set(throughSource);
60
+ const moved = new Set(moving.map((from) => `${kind}:${from}`));
55
61
  return {
56
62
  from: path,
57
63
  to,
58
- rewrites: addresses(config.dependentsOf(kind, path).filter((ref) => !drawn.has(ref))),
64
+ rewrites: addresses(unique(moving.flatMap((from) => config.dependentsOf(kind, from))).filter((ref) => !drawn.has(ref) && !moved.has(ref))),
59
65
  throughSource: addresses(throughSource),
66
+ ...moves.length > 0 ? { moves } : {},
60
67
  ...blocked === void 0 ? {} : { blocked }
61
68
  };
62
69
  }
@@ -330,6 +330,11 @@ interface EntityKind {
330
330
  * leaf, since neither can hold a slash.
331
331
  */
332
332
  readonly uniqueLeaves?: boolean;
333
+ /**
334
+ * Whether an item named under another item of the kind is a part of it — `Card/Header` of `Card`.
335
+ * A rename of the item then moves its parts to the new path with it, and their refs follow.
336
+ */
337
+ readonly parts?: boolean;
333
338
  /**
334
339
  * An extra authored form for a value whose domain is this kind, beside the leaf and the ref every
335
340
  * domain takes. Asked when a ref domain's schema is built, with the target the domain names and the
@@ -30,7 +30,7 @@ function titleCase(kind) {
30
30
  return kind.split(/[-_]/).filter(Boolean).map((word) => word.charAt(0).toUpperCase() + word.slice(1)).join(" ");
31
31
  }
32
32
  function buildKind(spec) {
33
- const { name, prepareLinkedBody, rebaseLinkedBody, layerKeys, fields, groupFields, subEntities = {}, computed, label, labelPlural, schemas: userSchemas, derived, sourceIdentity, sourceOrigin, authoredRefs, linkable, localGroupFields, emergentGroups, singleton = false, bareMember, sourceResolution, bulkAdopts, bulkExcludes, bulkOverlay, bulkDirectives, bulkOverlayWrite, nameEdges, rewriteName, styleBags, uniqueLeaves, authoredValue, mentionFields, invariants, structuralBody, authoredBody, sourceType, answeredHere } = spec;
33
+ const { name, prepareLinkedBody, rebaseLinkedBody, layerKeys, fields, groupFields, subEntities = {}, computed, label, labelPlural, schemas: userSchemas, derived, sourceIdentity, sourceOrigin, authoredRefs, linkable, localGroupFields, emergentGroups, singleton = false, bareMember, sourceResolution, bulkAdopts, bulkExcludes, bulkOverlay, bulkDirectives, bulkOverlayWrite, nameEdges, rewriteName, styleBags, uniqueLeaves, parts, authoredValue, mentionFields, invariants, structuralBody, authoredBody, sourceType, answeredHere } = spec;
34
34
  const allComputed = {
35
35
  sources: ({ member, config }) => sourceSlugs(member, config),
36
36
  borrowedFrom: ({ config, path }) => config.borrowedFrom(name, path),
@@ -79,6 +79,7 @@ function buildKind(spec) {
79
79
  rewriteName,
80
80
  styleBags,
81
81
  ...uniqueLeaves ? { uniqueLeaves } : {},
82
+ ...parts ? { parts } : {},
82
83
  ...authoredValue ? { authoredValue } : {},
83
84
  ...mentionFields?.length ? { mentionFields } : {},
84
85
  ...invariants ? { invariants } : {},
@@ -15,7 +15,7 @@ import { Patch, SerializedConfig } from "./Config.js";
15
15
  * sets this constant to its own older timestamp; the merge ref then carries a registered migration
16
16
  * newer than the constant, and the assertion fails until the author re-mints.
17
17
  */
18
- declare const CURRENT_SCHEMA_VERSION = 20261030163028;
18
+ declare const CURRENT_SCHEMA_VERSION = 20261102143821;
19
19
  /** What the walkers need to see of an envelope — loose on purpose, so a typed `SerializedConfig`
20
20
  * and a raw old-shape record both flow in without casts. */
21
21
  interface VersionStamped {
@@ -13,7 +13,7 @@ import { ConfigFormatError } from "./rejection.js";
13
13
  * sets this constant to its own older timestamp; the merge ref then carries a registered migration
14
14
  * newer than the constant, and the assertion fails until the author re-mints.
15
15
  */
16
- const CURRENT_SCHEMA_VERSION = 20261030163028;
16
+ const CURRENT_SCHEMA_VERSION = 20261102143821;
17
17
  /** The mint that moved `options` into the `settings` kind — restated here, rather than imported
18
18
  * from the migration that owns it, because that migration imports this module. */
19
19
  const SETTINGS_AS_KIND_VERSION = 20260908171448;
@@ -45,7 +45,7 @@ function registerSchemaMigrations(...migrations) {
45
45
  for (const migration of migrations) {
46
46
  if (migration.version !== 1 && !isMintTimestamp(migration.version)) throw new Error(`Schema migration version ${migration.version} is not a mint timestamp — mint one with \`date +%Y%m%d%H%M%S\`, like a supabase migration.`);
47
47
  if (REGISTERED.has(migration.version)) throw new Error(`A schema migration at version ${migration.version} is already registered.`);
48
- if (migration.version > 20261030163028) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
48
+ if (migration.version > 20261102143821) throw new Error(`Schema migration ${migration.version} is newer than CURRENT_SCHEMA_VERSION (${CURRENT_SCHEMA_VERSION}) — a stale branch merged, or the mint forgot to bump the constant. Re-mint: set CURRENT_SCHEMA_VERSION to the newest migration version.`);
49
49
  REGISTERED.set(migration.version, migration);
50
50
  }
51
51
  }
@@ -102,7 +102,7 @@ function pendingFor(version, target, options) {
102
102
  * Already-current input passes through untouched — same reference, so hot paths pay nothing.
103
103
  */
104
104
  function upgradeSerializedConfig(json, options) {
105
- const target = options?.target ?? 20261030163028;
105
+ const target = options?.target ?? 20261102143821;
106
106
  const version = detectedWireVersion(json);
107
107
  if (version > target) throw new SchemaVersionTooNew(version, target);
108
108
  const raw = json;
@@ -160,7 +160,7 @@ function upgradedSources(json, options) {
160
160
  * meaning under the current schema and replay skips it — reported by the caller, not swallowed here.
161
161
  */
162
162
  function upgradePatch(patch, writtenAt, options) {
163
- const target = options?.target ?? 20261030163028;
163
+ const target = options?.target ?? 20261102143821;
164
164
  if (writtenAt > target) throw new SchemaVersionTooNew(writtenAt, target);
165
165
  let current = patch;
166
166
  for (const migration of pendingFor(writtenAt, target, options)) {
@@ -179,7 +179,7 @@ function upgradePatch(patch, writtenAt, options) {
179
179
  * stamp would cause.
180
180
  */
181
181
  function upgradeDraftEntries(draft, options) {
182
- const target = options?.target ?? 20261030163028;
182
+ const target = options?.target ?? 20261102143821;
183
183
  const entries = [];
184
184
  const held = [];
185
185
  const retired = [];