@yahoo/uds-create-config 1.1.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.
Files changed (130) hide show
  1. package/dist/AssetGroup.d.ts +77 -0
  2. package/dist/AssetGroup.js +125 -0
  3. package/dist/Component.d.ts +308 -0
  4. package/dist/Component.js +896 -0
  5. package/dist/ComponentGroup.d.ts +20 -0
  6. package/dist/ComponentGroup.js +46 -0
  7. package/dist/CompositeStyle.d.ts +27 -0
  8. package/dist/CompositeStyle.js +52 -0
  9. package/dist/Config.d.ts +423 -0
  10. package/dist/Config.js +1429 -0
  11. package/dist/Mode.d.ts +41 -0
  12. package/dist/Mode.js +81 -0
  13. package/dist/Modifier.d.ts +51 -0
  14. package/dist/Modifier.js +97 -0
  15. package/dist/MotionDef.d.ts +49 -0
  16. package/dist/MotionDef.js +97 -0
  17. package/dist/Props.d.ts +317 -0
  18. package/dist/Props.js +35 -0
  19. package/dist/Provider.d.ts +20 -0
  20. package/dist/Provider.js +14 -0
  21. package/dist/StyleProp.d.ts +112 -0
  22. package/dist/StyleProp.js +197 -0
  23. package/dist/Token.d.ts +55 -0
  24. package/dist/Token.js +112 -0
  25. package/dist/TokenGroup.d.ts +32 -0
  26. package/dist/TokenGroup.js +68 -0
  27. package/dist/asset-kind.d.ts +55 -0
  28. package/dist/asset-kind.js +29 -0
  29. package/dist/brands.d.ts +30 -0
  30. package/dist/brands.js +20 -0
  31. package/dist/captureCallerPath.d.ts +48 -0
  32. package/dist/captureCallerPath.js +95 -0
  33. package/dist/colorExpressions.d.ts +131 -0
  34. package/dist/colorExpressions.js +148 -0
  35. package/dist/defineAssetGroup.d.ts +166 -0
  36. package/dist/defineAssetGroup.js +264 -0
  37. package/dist/defineProvider.d.ts +29 -0
  38. package/dist/defineProvider.js +60 -0
  39. package/dist/element-marker.d.ts +54 -0
  40. package/dist/element-marker.js +113 -0
  41. package/dist/entity-utils.d.ts +56 -0
  42. package/dist/entity-utils.js +105 -0
  43. package/dist/factories.d.ts +707 -0
  44. package/dist/factories.js +393 -0
  45. package/dist/foreign-component-name.d.ts +21 -0
  46. package/dist/foreign-component-name.js +42 -0
  47. package/dist/index.d.ts +32 -0
  48. package/dist/index.js +28 -0
  49. package/dist/interpolate.d.ts +20 -0
  50. package/dist/interpolate.js +10 -0
  51. package/dist/jsx/__fixtures__/cross-component-preview.d.ts +3 -0
  52. package/dist/jsx/__fixtures__/cross-component-preview.js +15 -0
  53. package/dist/jsx/jsx-dev-runtime.d.ts +15 -0
  54. package/dist/jsx/jsx-dev-runtime.js +11 -0
  55. package/dist/jsx/jsx-runtime.d.ts +48 -0
  56. package/dist/jsx/jsx-runtime.js +305 -0
  57. package/dist/markers.d.ts +217 -0
  58. package/dist/markers.js +67 -0
  59. package/dist/refs.d.ts +158 -0
  60. package/dist/refs.js +104 -0
  61. package/dist/renderer/RendererErrorBoundary.d.ts +26 -0
  62. package/dist/renderer/RendererErrorBoundary.js +30 -0
  63. package/dist/renderer/UdsRenderer.d.ts +80 -0
  64. package/dist/renderer/UdsRenderer.js +33 -0
  65. package/dist/renderer/assetRenderable.d.ts +13 -0
  66. package/dist/renderer/assetRenderable.js +13 -0
  67. package/dist/renderer/index.d.ts +14 -0
  68. package/dist/renderer/index.js +14 -0
  69. package/dist/renderer/makeRegistry.d.ts +34 -0
  70. package/dist/renderer/makeRegistry.js +52 -0
  71. package/dist/renderer/makeUdsRenderer.d.ts +29 -0
  72. package/dist/renderer/makeUdsRenderer.js +35 -0
  73. package/dist/renderer/primitives/FragmentRenderer.d.ts +12 -0
  74. package/dist/renderer/primitives/FragmentRenderer.js +11 -0
  75. package/dist/renderer/primitives/SlotRenderer.d.ts +21 -0
  76. package/dist/renderer/primitives/SlotRenderer.js +20 -0
  77. package/dist/renderer/wrapRegistry.d.ts +64 -0
  78. package/dist/renderer/wrapRegistry.js +39 -0
  79. package/dist/renderer/wrappers/component-slots.d.ts +41 -0
  80. package/dist/renderer/wrappers/component-slots.js +66 -0
  81. package/dist/renderer/wrappers/event-bridge.d.ts +20 -0
  82. package/dist/renderer/wrappers/event-bridge.js +78 -0
  83. package/dist/renderer/wrappers/hex-normalize.d.ts +14 -0
  84. package/dist/renderer/wrappers/hex-normalize.js +35 -0
  85. package/dist/renderer/wrappers/html-aliases.d.ts +24 -0
  86. package/dist/renderer/wrappers/html-aliases.js +62 -0
  87. package/dist/renderer/wrappers/inline-styles.d.ts +16 -0
  88. package/dist/renderer/wrappers/inline-styles.js +104 -0
  89. package/dist/renderer/wrappers/slot-resolution.d.ts +25 -0
  90. package/dist/renderer/wrappers/slot-resolution.js +68 -0
  91. package/dist/renderer/wrappers/void-elements.d.ts +23 -0
  92. package/dist/renderer/wrappers/void-elements.js +28 -0
  93. package/dist/spec/apply-forced-modifiers.d.ts +19 -0
  94. package/dist/spec/apply-forced-modifiers.js +49 -0
  95. package/dist/spec/asset-jsx.d.ts +48 -0
  96. package/dist/spec/asset-jsx.js +48 -0
  97. package/dist/spec/collapse-text-labels.d.ts +44 -0
  98. package/dist/spec/collapse-text-labels.js +107 -0
  99. package/dist/spec/empty-node-slots.d.ts +51 -0
  100. package/dist/spec/empty-node-slots.js +141 -0
  101. package/dist/spec/index.d.ts +10 -0
  102. package/dist/spec/index.js +10 -0
  103. package/dist/spec/jsxToSpec.d.ts +48 -0
  104. package/dist/spec/jsxToSpec.js +506 -0
  105. package/dist/spec/layer-props.d.ts +52 -0
  106. package/dist/spec/layer-props.js +149 -0
  107. package/dist/spec/preview-controls.d.ts +44 -0
  108. package/dist/spec/preview-controls.js +139 -0
  109. package/dist/spec/slot-refs.d.ts +39 -0
  110. package/dist/spec/slot-refs.js +56 -0
  111. package/dist/spec/specToJsx.d.ts +35 -0
  112. package/dist/spec/specToJsx.js +127 -0
  113. package/dist/token-override-rows.d.ts +66 -0
  114. package/dist/token-override-rows.js +223 -0
  115. package/dist/tokenValueType.d.ts +34 -0
  116. package/dist/tokenValueType.js +138 -0
  117. package/dist/tsconfig.tsbuildinfo +1 -0
  118. package/dist/types/css-properties.d.ts +232 -0
  119. package/dist/types/css-properties.js +14 -0
  120. package/dist/types/css-property-keywords.d.ts +156 -0
  121. package/dist/types/css-property-keywords.js +616 -0
  122. package/dist/types/css-values.d.ts +63 -0
  123. package/dist/types/css-values.js +16 -0
  124. package/dist/types.d.ts +708 -0
  125. package/dist/types.js +12 -0
  126. package/dist/units.d.ts +14 -0
  127. package/dist/units.js +16 -0
  128. package/dist/utils/index.d.ts +4 -0
  129. package/dist/utils/index.js +4 -0
  130. package/package.json +81 -0
@@ -0,0 +1,708 @@
1
+ import { ComponentRef, CompositeRef, ModeRef, TagRef, TokenGroupRef, TokenRef } from "./refs.js";
2
+ import { ColorExpression } from "./colorExpressions.js";
3
+ import { CssPropertyName, CssPropertyValues } from "./types/css-properties.js";
4
+ import { IconAssetMetadata } from "./defineAssetGroup.js";
5
+
6
+ //#region src/types.d.ts
7
+ /**
8
+ * CSS value-type names used to tag a token. The scaffold leaves the
9
+ * union open so token-type tightening (a closed CSS-value-type union)
10
+ * lands as a follow-up — needs to ship with type-narrowing on
11
+ * `defineStyleProp({ values: ... })` to be useful.
12
+ */
13
+ type TokenType = string;
14
+ /**
15
+ * What a token's `value` can hold:
16
+ *
17
+ * - A literal — `string` (`'#1167f4'`, `'1rem'`), `number`, `boolean`.
18
+ * - A `token('ns/name')` marker pointing at another token.
19
+ * - A structured `ColorExpression` — `mix(...)`, `alpha(...)`,
20
+ * `linearGradient(...)`, `radialGradient(...)`. Codegen resolves the
21
+ * expression to a CSS function call (`color-mix(...)`,
22
+ * `linear-gradient(...)`) via `resolveColorExpression`.
23
+ */
24
+ type TokenValue = string | number | boolean | TokenRef | ColorExpression;
25
+ type TokenModifierKey = `_${string}`;
26
+ type TokenModifierValue = TokenValue | TokenDefinition;
27
+ /**
28
+ * Authored shape for one token. Modifier values live as flat `_${key}`
29
+ * properties on the same object — matches the doc's example
30
+ * `{ value: '#1167f4', _dark: '#88bcfb' }` and the wire format.
31
+ *
32
+ * `Token` normalizes flat keys into a `modifiers` map at construction
33
+ * time so consumers reading the class instance work with the
34
+ * doc-described class shape.
35
+ */
36
+ type TokenDefinition = {
37
+ value: TokenValue;
38
+ type?: TokenType;
39
+ } & { [K in `_${string}`]?: TokenModifierValue };
40
+ /**
41
+ * Authored shape — the bare tokens record. Mirrors the old `@yahoo/uds-create-config`
42
+ * `defineTokenGroup(tokens)` signature: input is the tokens map; group
43
+ * metadata (label / description) is attached separately via the
44
+ * registration call, not nested under a wrapper.
45
+ */
46
+ /**
47
+ * A token group: a tokens record + optional Studio-facing metadata.
48
+ * Mirrors main's `TokenGroupDef`. The parent record key in
49
+ * `registerTokenGroups({...})` carries the namespace, so it doesn't
50
+ * appear here. Tokens nest under `tokens` so a token named `'label'`
51
+ * (or any meta key) can never collide with group metadata.
52
+ */
53
+ interface TokenGroupDefinition {
54
+ tokens: Record<string, TokenDefinition>;
55
+ label?: string;
56
+ description?: string;
57
+ }
58
+ /**
59
+ * Alias for the on-disk wire shape — structurally identical to
60
+ * `TokenGroupDefinition`. Used as the return type of
61
+ * `TokenGroup.toJSON()` so the serialization intent reads at call
62
+ * sites; consumers reading `config.json` see `SerializedTokenGroup`,
63
+ * authors writing `registerTokenGroups` see `TokenGroupDefinition`.
64
+ */
65
+ type SerializedTokenGroup = TokenGroupDefinition;
66
+ interface ModifierDefinition {
67
+ selector?: string | CompositeRef | ModeRef;
68
+ media?: string;
69
+ description?: string;
70
+ }
71
+ interface ModeOptionDefinition {
72
+ /**
73
+ * Modifier the option contributes. Defaults to `_${optionName}` —
74
+ * `colorMode: { options: { light: {...}, dark: {...} } }` produces
75
+ * modifiers `_light` and `_dark` without restating them. Override
76
+ * when the option name and the desired modifier should differ.
77
+ */
78
+ modifier?: TokenModifierKey;
79
+ label?: string;
80
+ description?: string;
81
+ /**
82
+ * CSS selector text the option produces — for `colorMode/dark`,
83
+ * `'.dark'` so consumers can write `<html class="dark">` and have
84
+ * the dark-mode tokens apply. Mirrors the old
85
+ * `@yahoo/uds-create-config` `ModeOptionInput.css` field name.
86
+ */
87
+ css?: string;
88
+ media?: string;
89
+ }
90
+ type ModeDefinition = Record<string, ModeOptionDefinition>;
91
+ type CompositeStyleObject = Record<string, unknown>;
92
+ interface CompositeStyleDefinition {
93
+ label: string;
94
+ description?: string;
95
+ /**
96
+ * Named style variants keyed by variant name. Mirrors the old
97
+ * `@yahoo/uds-create-config` `defineCompositeStyle({ styles })` field name —
98
+ * authors write `styles: { sm: {...}, md: {...} }`.
99
+ */
100
+ styles: Record<string, CompositeStyleObject>;
101
+ }
102
+ /**
103
+ * Any CSS property name `defineStyleProp` can target. Standard
104
+ * property names come from the `CssPropertyValues` registry; custom
105
+ * CSS properties (`--*`) are open template strings.
106
+ */
107
+ type StylePropProperty = CssPropertyName | `--${string}`;
108
+ /**
109
+ * Literal-keyword subset accepted by a CSS property. For standard
110
+ * properties, falls out of `CssPropertyValues[P]`. For custom CSS
111
+ * properties (`--*`), open string — narrowing happens via the
112
+ * `cssType` field on the style-prop spec.
113
+ */
114
+ type LiteralFor<P extends StylePropProperty> = [P] extends [CssPropertyName] ? Extract<CssPropertyValues[P], string> : string;
115
+ /**
116
+ * Author-friendly alias for a CSS keyword. `alias` is what the JSX
117
+ * value site uses (`flexDirection="col"`); `value` is the underlying
118
+ * CSS the prop resolves to.
119
+ *
120
+ * - `string` — a single CSS keyword (`'column'`).
121
+ * - `Record<string, string>` — a multi-property emission, used to
122
+ * write vendor-prefixed pairs (`{ '-webkit-user-select': 'none',
123
+ * 'user-select': 'none' }`) so a single utility class sets both at
124
+ * once and matches Tailwind's built-in body byte-for-byte (avoids
125
+ * cascade overrides).
126
+ *
127
+ * `value` is kept un-narrowed here — per-property narrowing via
128
+ * `LiteralFor<P>` would explode the union across every CSS property
129
+ * and hit TS's "too complex" limit.
130
+ */
131
+ interface ValueAlias {
132
+ alias: string | boolean | number;
133
+ value: string | Record<string, string>;
134
+ }
135
+ /**
136
+ * A single entry in a style-prop's `values` array. Narrowed against
137
+ * the chosen `cssProperty` so authoring sites like
138
+ * `values: ['banana']` on a `border-color` prop error at compile time.
139
+ *
140
+ * - `TokenGroupRef` — pulls every token in the named namespace
141
+ * into the prop's accepted value set.
142
+ * - `LiteralFor<P>` — a CSS keyword the property accepts per spec
143
+ * (e.g. `'transparent'` for `border-color`).
144
+ * - `number` — bare numeric values where CSS itself accepts numbers
145
+ * (e.g. `line-clamp: 3`).
146
+ * - `ValueAlias<P>` — `{ alias, value }` pair for Tailwind-style
147
+ * shorthands; the alias appears at the JSX value site and resolves
148
+ * to the underlying CSS keyword at emit time.
149
+ */
150
+ type ValuesEntry<P extends StylePropProperty = StylePropProperty> = TokenGroupRef | LiteralFor<P> | number | ValueAlias;
151
+ interface ArbitrarySpec {
152
+ type?: TokenType;
153
+ }
154
+ /**
155
+ * One entry in a multi-shape `arbitrary` array. `toCss` lets the prop
156
+ * coerce a runtime value into the actual CSS string (e.g. wrapping a
157
+ * raw `'1px'` in `var(--...)` or stitching multi-property output). The
158
+ * `regex` variant accepts any string matching a pattern instead of
159
+ * binding to a named value type.
160
+ */
161
+ type ArbitraryEntry = {
162
+ type: TokenType;
163
+ toCss?: (value: unknown) => string;
164
+ } | {
165
+ type: 'regex';
166
+ pattern: RegExp;
167
+ toCss?: (value: string) => string;
168
+ };
169
+ /**
170
+ * Author-time shape for `arbitrary`. Four forms:
171
+ * - `true` — accept any bracketed value, passed through verbatim into the
172
+ * prop's `cssProperty` (`arbitrary: true` → `blur="[blur(6px)]"` →
173
+ * `filter: blur(6px)`). Use when the bracket already carries the full CSS
174
+ * value and needs no data-type validation or transform.
175
+ * - bare `TokenType` string (`arbitrary: 'length-percentage'`) —
176
+ * shorthand for `{ type: ... }`.
177
+ * - `ArbitrarySpec` object (`arbitrary: { type: 'color' }`).
178
+ * - `ArbitraryEntry[]` for multi-shape props that accept several
179
+ * value-type variants (e.g. `grid-template-rows` taking integers,
180
+ * length-percentages, and full track lists).
181
+ * Normalized at `StyleProp` construction time (`true` → `{}`).
182
+ */
183
+ type ArbitraryInput = boolean | TokenType | ArbitrarySpec | readonly ArbitraryEntry[];
184
+ /**
185
+ * Authored shape attached by `defineStyleProp(spec).withOpacity({...})`.
186
+ * Declares a paired opacity sibling style-prop: the parent emits
187
+ * `${classPrefix}-${tokenName}` for the bare value AND
188
+ * `${classPrefix}-${tokenName}${separator}${opacityValue}` when the
189
+ * sibling prop is set. The sibling itself is registered alongside the
190
+ * parent at `registerStyleProps` time.
191
+ *
192
+ * `ref` (deprecated alias for `as`) is kept for back-compat with sites
193
+ * that read the opacity pair as `{ ref }` — codegen's `extractClasses.ts`
194
+ * checks `opacityPair.ref` directly.
195
+ */
196
+ interface OpacityPairSpec {
197
+ /** JSX-prop name for the opacity sibling (e.g. `'bgOpacity'`). */
198
+ as: string;
199
+ /** Token group the opacity sibling pulls values from. */
200
+ values: TokenGroupRef;
201
+ /**
202
+ * Class-name separator between the parent's token suffix and the
203
+ * opacity value. Defaults to `'_'`. Pass `'/'` for Tailwind-flavored
204
+ * output (`bg-primary/75`).
205
+ */
206
+ separator?: string;
207
+ /** Back-compat alias of `as`. New code should use `as`. */
208
+ ref?: string;
209
+ }
210
+ /**
211
+ * Authoring metadata attached via `defineStyleProp(spec).metadata({...})`.
212
+ * Consumed by codegen prompt artifacts and Studio's UI. Kept open
213
+ * (`Readonly<Record<string, unknown>>`) — `label` / `description` are
214
+ * the conventional fields but the slot doesn't enforce.
215
+ */
216
+ type StylePropMetadata = Readonly<Record<string, unknown>>;
217
+ /**
218
+ * Authoring metadata attached via
219
+ * `defineComponent(...).config(...).metadata({...})`. `description`
220
+ * shows up in codegen's AI prompt artifact next to the component name;
221
+ * `events` lists React/HTML event handler names the component supports
222
+ * (`'focus'`, `'press'`, etc.) — when unset, the synthesizer falls
223
+ * back to the standard React event roster. `deprecated` keeps a component
224
+ * out of the AI prompt artifact while leaving it registered and renderable.
225
+ */
226
+ interface ComponentMetadata {
227
+ /**
228
+ * Human-facing display name for Studio's palette. Defaults to the
229
+ * component's registered name when absent. Lets two components present
230
+ * the same label (e.g. both "Badge") while keeping distinct, stable
231
+ * identities (`uds:Badge` vs `uds:StudioBadge`) — identity stays the
232
+ * registered name, never this label.
233
+ */
234
+ readonly label?: string;
235
+ readonly description?: string;
236
+ readonly events?: readonly string[];
237
+ /**
238
+ * Marks the component as deprecated. Deprecated components are omitted
239
+ * from codegen's AI prompt artifact so the model won't reach for them in
240
+ * new work — they remain fully registered and renderable everywhere else.
241
+ */
242
+ readonly deprecated?: boolean;
243
+ }
244
+ /**
245
+ * Authored shape for `defineStyleProp`. `P` is the CSS property name
246
+ * (or names, when `cssProperty` is an array of side-shorthand props)
247
+ * — `values` narrows against `LiteralFor<P>` so unsupported keywords
248
+ * surface at the authoring site.
249
+ *
250
+ * No default for `P`: the wide case would force TypeScript to
251
+ * materialize `Extract<CssPropertyValues[CssPropertyName], string>`
252
+ * (a giant union) at every reference site. Wide-typed consumers
253
+ * (`Config.styleProps`, the wire format) use `AnyStylePropDefinition`
254
+ * instead.
255
+ */
256
+ interface StylePropDefinition<P extends StylePropProperty> {
257
+ cssProperty: P | readonly P[];
258
+ classPrefix: string;
259
+ /**
260
+ * Token-group refs + literal keywords + bare numbers the prop accepts.
261
+ * Optional — `values: []` (or omitting it) is meaningful for props
262
+ * that only take arbitrary `[...]` escape values (e.g. `motion`).
263
+ */
264
+ values?: readonly ValuesEntry<P>[];
265
+ arbitrary?: ArbitraryInput;
266
+ /**
267
+ * Marks the prop as emitting a *negative* value: the resolved token or
268
+ * arbitrary value is wrapped in `calc(<value> * -1)` at emit time, so
269
+ * `offsetTop="3"` (a `negative` prop) paints
270
+ * `margin-top: calc(var(--uds-spacing-3) * -1)`. This flag is the single
271
+ * source of negativity — both the build-time emitter (`prepareCss`) and
272
+ * the runtime injector (`renderGetStyles`) read it, replacing the old
273
+ * `classPrefix.startsWith('-')` heuristic. It's also the structured signal
274
+ * the MCP / AI guidance / spec lint use to identify overlap-prone props.
275
+ *
276
+ * Negative props conventionally still use a `-`-led `classPrefix` (`-mt`)
277
+ * so the utility reads as a Tailwind negative class (`.-mt-3`) and stays
278
+ * distinct from a positive sibling (`marginTop` → `.mt-3`) — but the prefix
279
+ * only *names* the class; this flag *drives* the negation.
280
+ */
281
+ negative?: boolean;
282
+ cssType?: TokenType;
283
+ metadata?: StylePropMetadata;
284
+ opacityPair?: OpacityPairSpec;
285
+ /**
286
+ * Optional value coercion the renderer applies after token resolution.
287
+ * Takes the resolved value (number for bare-numeric tokens, string
288
+ * otherwise) and returns the final CSS string. Lets props like
289
+ * `gridTemplateColumns` accept `12` and emit
290
+ * `repeat(12, minmax(0, 1fr))`.
291
+ */
292
+ transform?: (value: string | number) => string;
293
+ }
294
+ /**
295
+ * Wide structural shape used by `Config.registerStyleProps` and the
296
+ * `StyleProp` class storage. Any concretely-narrowed
297
+ * `StylePropDefinition<P>` is assignable to this. `values` is the
298
+ * un-narrowed marker/literal/number union — runtime treats every
299
+ * entry uniformly, so the narrowing in `StylePropDefinition<P>` is
300
+ * purely an authoring-time check.
301
+ */
302
+ interface AnyStylePropDefinition {
303
+ cssProperty: StylePropProperty | readonly StylePropProperty[];
304
+ classPrefix: string;
305
+ values?: readonly (TokenGroupRef | string | number | ValueAlias)[];
306
+ arbitrary?: ArbitraryInput;
307
+ /** See {@link StylePropDefinition.negative} — emit `calc(<value> * -1)`. */
308
+ negative?: boolean;
309
+ cssType?: TokenType;
310
+ metadata?: StylePropMetadata;
311
+ opacityPair?: OpacityPairSpec;
312
+ transform?: (value: string | number) => string;
313
+ }
314
+ type MotionKeyframes = Record<string, Record<string, unknown>>;
315
+ interface MotionTransition {
316
+ duration?: number | string;
317
+ delay?: number | string;
318
+ ease?: string | readonly number[];
319
+ [key: string]: unknown;
320
+ }
321
+ interface MotionStateKeyframe {
322
+ [key: string]: unknown;
323
+ }
324
+ interface CssMotionDefinition {
325
+ runtime: 'css';
326
+ keyframes: MotionKeyframes;
327
+ transition?: MotionTransition;
328
+ /**
329
+ * Open index signature for `animation-*` CSS shorthand fields the
330
+ * old `@yahoo/uds-create-config` placed directly on the motion def
331
+ * (`animationDuration`, `animationTimingFunction`, etc.). Codegen
332
+ * reads them off the toJSON'd shape and folds them into the emitted
333
+ * `animation: ...` declaration alongside the keyframes/transition.
334
+ */
335
+ [key: string]: unknown;
336
+ }
337
+ interface JsMotionDefinition {
338
+ runtime: 'js';
339
+ initial?: MotionStateKeyframe;
340
+ animate?: MotionStateKeyframe;
341
+ /**
342
+ * Exit keyframes — applied when the host element unmounts. Requires
343
+ * the consumer to render the slot conditionally so the JS runtime
344
+ * (`motion/react`'s `<AnimatePresence>`) can play the exit before the
345
+ * node detaches.
346
+ */
347
+ exit?: MotionStateKeyframe;
348
+ transition?: MotionTransition;
349
+ /** Keyframes applied while the element is hovered. */
350
+ whileHover?: MotionStateKeyframe;
351
+ /** Keyframes applied while the element is actively pressed. */
352
+ whileTap?: MotionStateKeyframe;
353
+ }
354
+ type MotionDefinitionInput = CssMotionDefinition | JsMotionDefinition;
355
+ /**
356
+ * Layer-with-overrides shape — the old `@yahoo/uds-create-config` authoring form
357
+ * where a layer carries its tag and its per-layer overrides
358
+ * (`defaultProps`, `base`, etc.) inline. Codegen reads `tag` to set
359
+ * the layer's element and the remaining fields contribute to the
360
+ * layer's emitted styles. Used in tests + legacy configs; the
361
+ * structured marker forms (`tag('div')` etc.) are preferred for new
362
+ * code because they round-trip cleanly through JSON.
363
+ */
364
+ interface LayerWithOverrides {
365
+ tag: string | TagRef | ComponentRef;
366
+ defaultProps?: Record<string, unknown>;
367
+ base?: Record<string, unknown>;
368
+ [key: string]: unknown;
369
+ }
370
+ /**
371
+ * What can appear as a layer's value in `defineComponent`'s `layers`
372
+ * map. Five authoring forms:
373
+ *
374
+ * - bare tag name string — `'div'`, `'span'`. The old `@yahoo/uds-create-config`
375
+ * layer syntax; `Component` normalizes to a `TagRef` at construction.
376
+ * - `TagRef` — `tag('div')` marker form (equivalent to the bare
377
+ * string; both produce the same on-disk shape).
378
+ * - `ComponentRef` — string-keyed reference to a registered
379
+ * component (`component('Box')`).
380
+ * - `ComponentDefinition` value — the registered component itself
381
+ * (`{ root: Box, trigger: Pressable }`). Identity-keyed; codegen
382
+ * resolves it back to a component name via its
383
+ * `configToName` reverse map at type-narrowing + class-extraction
384
+ * time. Permits ergonomic `.layers({ root: Box })` authoring.
385
+ * - `LayerWithOverrides` — `{ tag, defaultProps?, base?, ... }`. The
386
+ * old layer-with-overrides shape; `Component` lifts `tag` onto
387
+ * `Layer.tag` and leaves the remaining fields on the layer entry
388
+ * for codegen to read.
389
+ */
390
+ type LayerInput = string | TagRef | ComponentRef | ComponentDefinition | LayerWithOverrides;
391
+ type BaseStyles = Record<string, Record<string, unknown>>;
392
+ interface CompoundPropsEntry {
393
+ when: Record<string, unknown>;
394
+ layers: Record<string, unknown>;
395
+ }
396
+ /**
397
+ * Per-layer framer-motion spec a component carries inline. Mirrors
398
+ * main's `SlotMotion`: every field is `unknown` because the framer-
399
+ * motion API surface is wide and we don't want to lock authoring to
400
+ * a particular `motion/react` version. Codegen passes the value
401
+ * through to the runtime renderer.
402
+ */
403
+ interface SlotMotion {
404
+ readonly runtime?: 'js' | 'css';
405
+ readonly initial?: unknown;
406
+ readonly animate?: unknown;
407
+ readonly exit?: unknown;
408
+ readonly transition?: unknown;
409
+ readonly whileHover?: unknown;
410
+ readonly whileTap?: unknown;
411
+ readonly drag?: unknown;
412
+ readonly dragConstraints?: unknown;
413
+ readonly dragElastic?: unknown;
414
+ }
415
+ /**
416
+ * Component-level motion field. Three shapes:
417
+ * - `string` — alias of a `registerMotion({...})` preset.
418
+ * - `{ runtime, ... }` — inline `SlotMotion` applied to the root.
419
+ * - `Record<string, SlotMotion>` — per-layer record keyed by layer
420
+ * name (`{ icon: {...}, menu: {...} }`); each layer animates
421
+ * independently with its own framer config.
422
+ */
423
+ type ComponentMotionValue = string | SlotMotion | Record<string, SlotMotion>;
424
+ type PropBinding = unknown;
425
+ /**
426
+ * Extract the literal HTML tag from a `layers` map when it can be read
427
+ * statically. Returns the bare-tag literal (`'a' | 'div' | ...`) when:
428
+ *
429
+ * - `layers.root` is a bare tag string (`'a'`),
430
+ * - `layers.root` is a `TagRef<'a'>` marker,
431
+ * - `layers.root` is a `LayerWithOverrides` (`{ tag: 'a', ... }`) where
432
+ * `tag` is a bare string or `TagRef`, or
433
+ * - `layers.root` is a value-extend wrapper carrying its own captured
434
+ * root tag (recurses one level so `defineComponent(Box)` inherits
435
+ * Box's `'div'` root tag).
436
+ *
437
+ * Returns `undefined` when `layers.root` is a value-extend wrapper
438
+ * without a captured tag, or when the field is absent. `Props<T>`
439
+ * reads this and substitutes `ComponentPropsWithRef<TTag>` for the
440
+ * generic `HTMLAttributes<HTMLElement>` when narrowable.
441
+ */
442
+ type RootTag<TLayers> = TLayers extends {
443
+ root: infer R;
444
+ } ? R extends string ? R : R extends {
445
+ __kind: 'tag';
446
+ ref: infer T extends string;
447
+ } ? T : R extends {
448
+ tag: infer T extends string;
449
+ } ? T : R extends {
450
+ tag: {
451
+ __kind: 'tag';
452
+ ref: infer T extends string;
453
+ };
454
+ } ? T : R extends {
455
+ defaultProps: {
456
+ as: infer A extends string;
457
+ };
458
+ } ? A : R extends ComponentDefinition<Record<string, LayerInput>, Record<string, PropBinding>, infer TInnerTag> ? TInnerTag : undefined : undefined;
459
+ /**
460
+ * Structural shape of a `defineComponent` config. Parameterized over its
461
+ * `layers`, `props`, and the resolved root tag so a wrapping `Props<T>`
462
+ * walker can read each piece independently without unfolding the wide
463
+ * structural surface at every recursion.
464
+ *
465
+ * Defaults match the historic open shape so existing 70+ use sites that
466
+ * write `ComponentDefinition` un-parameterized continue to typecheck —
467
+ * the narrow forms only kick in when authoring chains thread literal
468
+ * generics through (`defineComponent('div')` → `TTag = 'div'`).
469
+ */
470
+ interface ComponentDefinition<TLayers extends Record<string, LayerInput> = Record<string, LayerInput>, TProps extends Record<string, PropBinding> = Record<string, PropBinding>, TTag extends string | undefined = string | undefined> {
471
+ layers: TLayers;
472
+ props?: TProps;
473
+ base?: BaseStyles;
474
+ defaultProps?: Record<string, unknown>;
475
+ compoundProps?: readonly CompoundPropsEntry[];
476
+ motion?: ComponentMotionValue;
477
+ /**
478
+ * Phantom slot — populated only as a type marker (never read at
479
+ * runtime) so `RootTag<TLayers>` callers can fall back to this when
480
+ * the layer's root is a value-extend wrapper. The value-extend chain
481
+ * threads its captured `TTag` through here.
482
+ */
483
+ readonly __tag?: TTag;
484
+ }
485
+ /**
486
+ * Authored shape for a component's preview block — attached via
487
+ * `defineComponent({...}).preview({...})`. Carries the data Studio +
488
+ * codegen need to render a component tile: `defaultProps` is the
489
+ * baseline JSX prop bag; `matrix` declares the axes for the canvas
490
+ * grid view. Stored verbatim on `Component.preview` and round-trips
491
+ * through JSON unchanged.
492
+ *
493
+ * Named `PreviewDefinition` to match the package's `*Definition`
494
+ * convention and avoid confusion with json-render's `spec` (the
495
+ * canvas-renderable tree that lives at `ManifestPreviewEntry.spec`).
496
+ *
497
+ * `matrix.columns` / `matrix.rows` are typed as `unknown[]` — concrete
498
+ * axis-entry shapes (prop-axis, modifier-axis) belong to the renderer
499
+ * surface, not the authoring contract.
500
+ */
501
+ interface PreviewDefinition<TProps extends Record<string, unknown> = Record<string, unknown>> {
502
+ /**
503
+ * Authored — passed to `.preview({ defaultProps })`. Narrowed against
504
+ * the component's resolved JSX prop shape so callback params
505
+ * (`onSubmit: (event) => ...`) infer from the component's declared
506
+ * `TExtra` rather than collapsing to `any`. Falls back to the wide
507
+ * `Record<string, unknown>` when the call site doesn't supply a
508
+ * `TProps` generic (Studio + codegen consume the loose shape).
509
+ */
510
+ readonly defaultProps?: Partial<TProps>;
511
+ /** Authored — passed to `.preview({ matrix })`. Drives the canvas grid view. */
512
+ readonly matrix?: {
513
+ readonly columns?: readonly unknown[];
514
+ readonly rows?: readonly unknown[];
515
+ };
516
+ /**
517
+ * Codegen-extracted — parsed json-render spec from
518
+ * `defaultProps.children` JSX. Studio's canvas + docs read this to
519
+ * render the preview tile. Plain JSON (no functions / React elements).
520
+ */
521
+ readonly spec?: Readonly<Record<string, unknown>>;
522
+ }
523
+ /**
524
+ * Wire shape for a component — what lands in `config.json`. The
525
+ * authored `ComponentDefinition` plus the two enrichments that aren't
526
+ * authored at the call site: `preview` (added by the `.preview()`
527
+ * chain) and `sourceFilePath` (stack-walked by `captureCallerPath` at
528
+ * `defineComponent` time). Kept separate from `ComponentDefinition`
529
+ * so IDE completions inside `defineComponent({...})` don't suggest
530
+ * fields the author can't write directly.
531
+ */
532
+ interface SerializedComponent extends ComponentDefinition {
533
+ preview?: PreviewDefinition;
534
+ /**
535
+ * Path of the file that defined the component. Relative to
536
+ * `meta.projectRoot` when `Config.toJSON({ projectRoot })` is used
537
+ * (CLI's path) — keeps `config.json` portable across machines.
538
+ * Absolute when serialized without a `projectRoot`.
539
+ */
540
+ sourceFilePath?: string;
541
+ /**
542
+ * Set on a sub-part — name of the parent that owns it. Mirrors
543
+ * `Component.derived.subcomponentOf`. The authored relationship is
544
+ * declared on the parent via `.subcomponents({...})`; this field is
545
+ * the wire-format echo so `Config.fromJSON` can rebuild the linkage
546
+ * without re-running the original `.subcomponents` chain.
547
+ */
548
+ subcomponentOf?: string;
549
+ /**
550
+ * Name of the component this one value-extends via `defineComponent(Source)`.
551
+ * Mirrors `Component.extendsFrom`; lets consumers diff a child's props
552
+ * against the parent's instead of re-listing the inherited surface.
553
+ */
554
+ extendsFrom?: string;
555
+ /**
556
+ * Set on a parent — child names declared via `.subcomponents({...})`.
557
+ * Mirrors `Component.derived.subcomponents`.
558
+ */
559
+ subcomponents?: readonly string[];
560
+ }
561
+ /**
562
+ * Authored shape for a component group — a labeled bundle of
563
+ * registered components surfaced together in the Studio palette,
564
+ * codegen catalog, and AI prompt.
565
+ *
566
+ * `components` is keyed by the registration name (same surface as
567
+ * `registerComponents`); each value is a plain `ComponentDefinition`.
568
+ * Registration flattens these into `Config.components` and stamps
569
+ * `componentGroup` on each member's `Component.derived`.
570
+ *
571
+ * The serialized form (`SerializedComponentGroup`) replaces
572
+ * `components: Record<string, ComponentDefinition>` with
573
+ * `components: readonly string[]` — names only — because the
574
+ * definitions themselves live under `config.components` on disk.
575
+ */
576
+ interface ComponentGroupDefinition {
577
+ label: string;
578
+ description?: string;
579
+ components: Record<string, ComponentDefinition>;
580
+ }
581
+ interface SerializedComponentGroup {
582
+ label: string;
583
+ description?: string;
584
+ components: readonly string[];
585
+ }
586
+ /**
587
+ * One font-class asset member — a pure-JSON data record (no FC to
588
+ * render), mirroring `@yahoo/uds-fonts`' `FontDeclarationConfig`. The
589
+ * structural contract the font-class member guard enforces is
590
+ * `fontFamily` + `declarations[]`; everything else (`fallback`,
591
+ * weights/axes, `isVariableFont`, …) rides along through the open
592
+ * index so the registered record stays faithful to the source map
593
+ * without `@yahoo/uds-create-config` depending on the font package's types.
594
+ */
595
+ interface FontAssetMember {
596
+ /** CSS-facing family name (`'YA Sans VF'`). */
597
+ readonly fontFamily: string;
598
+ /**
599
+ * `@font-face` source declarations (CDN URLs, weights/axes) — pure
600
+ * JSON the browser loader derives `@font-face` rules from.
601
+ */
602
+ readonly declarations: readonly Record<string, unknown>[];
603
+ readonly [key: string]: unknown;
604
+ }
605
+ /**
606
+ * Wire shape for one asset group, discriminated by `assetKind` from
607
+ * day one so future asset classes extend the union without a wire
608
+ * migration. The member shape is per-class:
609
+ *
610
+ * - `'icon'` — `members` is a member-*name* list. The React
611
+ * components ship in the consumer bundle, so the serialized form
612
+ * only needs names (mirrors `SerializedComponentGroup.components`).
613
+ * - `'font'` — `members` is the full member-*record* map. Font
614
+ * members are already plain JSON and the browser `@font-face`
615
+ * loader needs the records themselves.
616
+ */
617
+ interface SerializedIconAssetGroup {
618
+ assetKind: 'icon';
619
+ label: string;
620
+ description?: string;
621
+ /** Source-library version shown in the Assets UI (e.g. `2.1.1`). */
622
+ version?: string;
623
+ /** Named size → px. The picker's size options are these keys. */
624
+ sizes: Readonly<Record<string, number>>;
625
+ /** Group-level variant superset (declared or harvested union). */
626
+ variants: readonly string[];
627
+ /**
628
+ * Authoring component for code export (`'Icon'`) — lets code views
629
+ * serialize a placed asset node as `<Icon name="Trophy" … />` and
630
+ * round-trip it. Also the component a placed member renders through on
631
+ * the canvas. Omitted for a component-less group (members render bare).
632
+ */
633
+ component?: string;
634
+ members: readonly string[];
635
+ /**
636
+ * Per-member harvested metadata (each icon's own variants, category,
637
+ * tags), keyed by asset name. Carried on the wire so the browser picker
638
+ * can narrow ragged variants and search tags/category from the resolved
639
+ * config alone — without introspecting live member components. Omitted
640
+ * when no member carried metadata (e.g. a metadata-less library).
641
+ */
642
+ memberMetadata?: Readonly<Record<string, IconAssetMetadata>>;
643
+ }
644
+ interface SerializedFontAssetGroup {
645
+ assetKind: 'font';
646
+ label: string;
647
+ description?: string;
648
+ /** Source-library version shown in the Assets UI (e.g. `2.1.1`). */
649
+ version?: string;
650
+ members: Readonly<Record<string, FontAssetMember>>;
651
+ }
652
+ type SerializedAssetGroup = SerializedIconAssetGroup | SerializedFontAssetGroup;
653
+ type GlobalStylesDef = Record<string, Record<string, unknown>>;
654
+ /**
655
+ * Build-time knobs settable via `config.configure({ buildOptions })`. Read
656
+ * by the codegen pipeline (`@yahoo/uds-create-codegen`) and the CLI to gate
657
+ * artifact emission. Authored on the config instance, propagated as-is.
658
+ */
659
+ interface BuildOptions {
660
+ skipCssVariables?: boolean;
661
+ preflight?: boolean;
662
+ /**
663
+ * Scope every emitted CSS selector under this class name. The
664
+ * emitter's `:root` block becomes `.<cssScope>`; mode/theme blocks
665
+ * (e.g. `.dark` or `[data-theme="slate"]`) append `.<cssScope>` so
666
+ * they still apply when the attribute is on `<html>`. Utility
667
+ * classes nest under `.<cssScope>` so two UDS-powered packages on
668
+ * the same page don't collide.
669
+ */
670
+ cssScope?: string;
671
+ }
672
+ /**
673
+ * `Config.toJSON()` produces this shape. Mirrors authored fields exactly
674
+ * — derived data is never serialized. The `{ __kind, ref }` marker shape
675
+ * appears wherever a position can hold either a literal or a cross-ref.
676
+ */
677
+ interface SerializedConfig {
678
+ schemaVersion: number;
679
+ builtAt?: string;
680
+ prefix: string;
681
+ /** Registry namespace that prefixes component `registryKey`s
682
+ * (`<namespace>:<Component>`). Absent for un-namespaced configs.
683
+ * Declared via `configure({ namespace })`. */
684
+ namespace?: string;
685
+ preflight: boolean;
686
+ designPrinciples?: readonly string[];
687
+ globalStyles?: GlobalStylesDef;
688
+ /** Raw CSS strings included verbatim via `config.includeCss()` (e.g.
689
+ * `@font-face` blocks). Emitted after compilation, ahead of generated CSS. */
690
+ rawCss?: readonly string[];
691
+ modes?: Record<string, ModeDefinition>;
692
+ modifiers?: Record<string, ModifierDefinition>;
693
+ tokenGroups?: Record<string, SerializedTokenGroup>;
694
+ styleProps?: Record<string, AnyStylePropDefinition>;
695
+ compositeStyles?: Record<string, CompositeStyleDefinition>;
696
+ motion?: Record<string, MotionDefinitionInput>;
697
+ components?: Record<string, SerializedComponent>;
698
+ componentGroups?: Record<string, SerializedComponentGroup>;
699
+ /**
700
+ * Registered asset groups, keyed by slug. Optional — old
701
+ * `config.json` files without it hydrate to an empty map; no
702
+ * `schemaVersion` bump.
703
+ */
704
+ assetGroups?: Record<string, SerializedAssetGroup>;
705
+ providers?: Record<string, Record<string, never>>;
706
+ }
707
+ //#endregion
708
+ export { AnyStylePropDefinition, ArbitraryEntry, ArbitrarySpec, BaseStyles, BuildOptions, ComponentDefinition, ComponentGroupDefinition, ComponentMetadata, ComponentMotionValue, CompositeStyleDefinition, CompositeStyleObject, CompoundPropsEntry, CssMotionDefinition, FontAssetMember, GlobalStylesDef, JsMotionDefinition, LayerInput, LiteralFor, ModeDefinition, ModeOptionDefinition, ModifierDefinition, MotionDefinitionInput, MotionKeyframes, MotionStateKeyframe, MotionTransition, OpacityPairSpec, PreviewDefinition, PropBinding, RootTag, SerializedAssetGroup, SerializedComponent, SerializedComponentGroup, SerializedConfig, SerializedFontAssetGroup, SerializedIconAssetGroup, SerializedTokenGroup, SlotMotion, StylePropDefinition, StylePropMetadata, StylePropProperty, TokenDefinition, TokenGroupDefinition, TokenModifierKey, TokenModifierValue, TokenType, TokenValue, ValuesEntry };