@yahoo/uds-v5-wip 1.61.0 → 1.62.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 (117) hide show
  1. package/dist/config/dist/AssetGroup.d.ts +75 -0
  2. package/dist/config/dist/AssetGroup.js +114 -0
  3. package/dist/config/dist/Component.d.ts +309 -0
  4. package/dist/config/dist/Component.js +897 -0
  5. package/dist/config/dist/ComponentGroup.d.ts +21 -0
  6. package/dist/config/dist/ComponentGroup.js +46 -0
  7. package/dist/config/dist/CompositeStyle.d.ts +28 -0
  8. package/dist/config/dist/CompositeStyle.js +52 -0
  9. package/dist/config/dist/Config.d.ts +422 -0
  10. package/dist/config/dist/Config.js +1426 -0
  11. package/dist/config/dist/Mode.d.ts +42 -0
  12. package/dist/config/dist/Mode.js +81 -0
  13. package/dist/config/dist/Modifier.d.ts +52 -0
  14. package/dist/config/dist/Modifier.js +97 -0
  15. package/dist/config/dist/MotionDef.d.ts +50 -0
  16. package/dist/config/dist/MotionDef.js +97 -0
  17. package/dist/config/dist/Props.d.ts +235 -126
  18. package/dist/config/dist/Provider.d.ts +21 -0
  19. package/dist/config/dist/Provider.js +14 -0
  20. package/dist/config/dist/StyleProp.d.ts +113 -0
  21. package/dist/config/dist/StyleProp.js +197 -0
  22. package/dist/config/dist/Token.d.ts +56 -0
  23. package/dist/config/dist/Token.js +112 -0
  24. package/dist/config/dist/TokenGroup.d.ts +33 -0
  25. package/dist/config/dist/TokenGroup.js +68 -0
  26. package/dist/config/dist/asset-kind.d.ts +56 -0
  27. package/dist/config/dist/asset-kind.js +29 -0
  28. package/dist/config/dist/brands.d.ts +31 -0
  29. package/dist/config/dist/brands.js +20 -0
  30. package/dist/config/dist/captureCallerPath.d.ts +49 -0
  31. package/dist/config/dist/captureCallerPath.js +95 -0
  32. package/dist/config/dist/colorExpressions.d.ts +132 -0
  33. package/dist/config/dist/colorExpressions.js +148 -0
  34. package/dist/config/dist/defineAssetGroup.d.ts +158 -0
  35. package/dist/config/dist/defineAssetGroup.js +263 -0
  36. package/dist/config/dist/defineProvider.d.ts +30 -0
  37. package/dist/config/dist/defineProvider.js +60 -0
  38. package/dist/config/dist/element-marker.d.ts +55 -0
  39. package/dist/config/dist/element-marker.js +113 -0
  40. package/dist/config/dist/entity-utils.d.ts +27 -0
  41. package/dist/config/dist/entity-utils.js +105 -0
  42. package/dist/config/dist/factories.d.ts +707 -0
  43. package/dist/config/dist/factories.js +393 -0
  44. package/dist/config/dist/foreign-component-name.js +42 -0
  45. package/dist/config/dist/index.d.ts +30 -21
  46. package/dist/config/dist/index.js +26 -14
  47. package/dist/config/dist/interpolate.d.ts +21 -0
  48. package/dist/config/dist/interpolate.js +10 -0
  49. package/dist/config/dist/markers.d.ts +218 -0
  50. package/dist/config/dist/markers.js +67 -0
  51. package/dist/config/dist/refs.d.ts +143 -69
  52. package/dist/config/dist/refs.js +95 -113
  53. package/dist/config/dist/token-override-rows.d.ts +67 -0
  54. package/dist/config/dist/token-override-rows.js +223 -0
  55. package/dist/config/dist/tokenValueType.js +138 -0
  56. package/dist/config/dist/types/css-properties.d.ts +132 -122
  57. package/dist/config/dist/types/css-property-keywords.d.ts +157 -0
  58. package/dist/config/dist/types/css-property-keywords.js +616 -0
  59. package/dist/config/dist/types/css-values.d.ts +18 -16
  60. package/dist/config/dist/types.d.ts +688 -66
  61. package/dist/config/dist/units.d.ts +15 -0
  62. package/dist/config/dist/units.js +16 -0
  63. package/dist/config.d.ts +31 -22
  64. package/dist/config.js +28 -16
  65. package/dist/loader/dist/loader/artifacts.js +26 -9
  66. package/dist/loader/dist/loader.d.ts +11 -23
  67. package/dist/loader/dist/loader.js +54 -99
  68. package/dist/loader/dist/next.js +3 -3
  69. package/dist/loader/dist/transform-runner.js +1 -8
  70. package/dist/loader/dist/unplugin.d.ts +2 -2
  71. package/dist/loader/dist/unplugin.js +2 -2
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/dist/utils/dist/index.js +1 -0
  74. package/dist/utils/dist/motion-utils/resolveMotionState.d.ts +35 -0
  75. package/dist/utils/dist/motion-utils/resolveMotionState.js +33 -0
  76. package/dist/utils/dist/string-utils/componentClassName.d.ts +41 -8
  77. package/dist/utils/dist/string-utils/componentClassName.js +48 -11
  78. package/dist/utils.d.ts +3 -2
  79. package/dist/utils.js +3 -2
  80. package/package.json +3 -3
  81. package/dist/codegen/dist/loader/getLoaderArtifacts.js +0 -2
  82. package/dist/config/dist/bindRender.d.ts +0 -16
  83. package/dist/config/dist/bindRender.js +0 -310
  84. package/dist/config/dist/className.d.ts +0 -54
  85. package/dist/config/dist/className.js +0 -77
  86. package/dist/config/dist/component-config.d.ts +0 -862
  87. package/dist/config/dist/component-config.js +0 -163
  88. package/dist/config/dist/component-refs.d.ts +0 -121
  89. package/dist/config/dist/createConfig.d.ts +0 -456
  90. package/dist/config/dist/createConfig.js +0 -503
  91. package/dist/config/dist/createStyler.d.ts +0 -35
  92. package/dist/config/dist/createStyler.js +0 -93
  93. package/dist/config/dist/defineComponent.d.ts +0 -317
  94. package/dist/config/dist/defineComponent.js +0 -264
  95. package/dist/config/dist/defineCompositeStyle.d.ts +0 -93
  96. package/dist/config/dist/defineCompositeStyle.js +0 -18
  97. package/dist/config/dist/defineMotionConfig.d.ts +0 -152
  98. package/dist/config/dist/definePreview.d.ts +0 -45
  99. package/dist/config/dist/definePreview.js +0 -35
  100. package/dist/config/dist/defineStyleProp.d.ts +0 -289
  101. package/dist/config/dist/defineStyleProp.js +0 -61
  102. package/dist/config/dist/merge-utils.js +0 -51
  103. package/dist/config/dist/propertyAcceptedTypes.d.ts +0 -19
  104. package/dist/config/dist/propertyAcceptedTypes.js +0 -220
  105. package/dist/config/dist/resolveCompoundProps.d.ts +0 -65
  106. package/dist/config/dist/resolveCompoundProps.js +0 -120
  107. package/dist/config/dist/resolveStyleProp.d.ts +0 -157
  108. package/dist/config/dist/resolveStyleProp.js +0 -260
  109. package/dist/config/dist/runtime-registry.js +0 -37
  110. package/dist/config/dist/serialize.d.ts +0 -47
  111. package/dist/config/dist/serialize.js +0 -111
  112. package/dist/config/dist/sniffTokenType.d.ts +0 -7
  113. package/dist/config/dist/sniffTokenType.js +0 -67
  114. package/dist/config/dist/style-prop-runtime.d.ts +0 -75
  115. package/dist/config/dist/style-prop-runtime.js +0 -390
  116. package/dist/loader/dist/loader/internal-meta.js +0 -59
  117. package/dist/loader/dist/loader/lower-new-api-primitive.js +0 -252
@@ -1,456 +0,0 @@
1
- import { InterpolateMarker, MotionPreset } from "./defineMotionConfig.js";
2
- import { ComponentConfigValue } from "./component-config.js";
3
- import { DefinedPreview } from "./definePreview.js";
4
- import { CompositeStylesConfig, DefinedCompositeStyle } from "./defineCompositeStyle.js";
5
- import { BoundComponent } from "./defineComponent.js";
6
- import { AnyStyleProp } from "./defineStyleProp.js";
7
- import { TokenType, VarsConfig } from "./types.js";
8
- import { ResolvedStyleProp } from "./resolveStyleProp.js";
9
- import * as _$react from "react";
10
- import { BaseModifierProp, ModifierProp } from "@uds/types";
11
-
12
- //#region ../config/dist/createConfig.d.ts
13
- //#region src/createConfig.d.ts
14
- type MotionPresetsDef = Record<string, MotionPreset>;
15
- type EmptyMotion = {};
16
- type EmptyCompositeStyles = {};
17
- /**
18
- * Transform composite-styles config type into the reference shape passed to
19
- * `defineModifiers`. Walks `T[K]['styles'][V]` so the modifier callback can
20
- * write `compositeStyles.elevation['1'].className` (flat for ergonomics).
21
- *
22
- * Kept for the legacy callback API. New code should prefer the brace-ref
23
- * form for selector authoring:
24
- *
25
- * ```ts
26
- * .defineModifiers([
27
- * { modifier: '_onElevated', selector: '{composite/elevation/1}' },
28
- * ])
29
- * ```
30
- *
31
- * The `{composite/<group>/<value>}` ref expands to a container style query
32
- * at `defineModifiers` time. See [[UDS-1644]].
33
- */
34
- type CompositeStylesReference<T> = { [K in keyof T]: T[K] extends {
35
- styles: infer S;
36
- } ? { [V in keyof S]: {
37
- className: string;
38
- } } : never };
39
- type ModifierNameShape = `_${string}`;
40
- /**
41
- * Check if a modifier overlaps with base reserved modifiers (not including custom ones)
42
- * BaseModifierProp excludes CustomModifierNames to prevent circular dependency
43
- */
44
- type IsReservedModifier<T> = T extends BaseModifierProp ? true : false;
45
- /** Check if any modifier in the union is reserved */
46
- type HasReservedModifier<T> = T extends any ? IsReservedModifier<T> extends true ? true : never : never;
47
- interface ModeOption {
48
- name: string;
49
- /** Optional human-readable label for Studio. Falls back to `name`. */
50
- label?: string;
51
- modifier: ModifierNameShape;
52
- /** Description for AI prompt generation (e.g. "Apply styles in dark mode") */
53
- description?: string;
54
- css?: string;
55
- media?: string;
56
- default?: true;
57
- }
58
- interface ModeGroup {
59
- name: string;
60
- /** Optional human-readable label for Studio. Falls back to `name`. */
61
- label?: string;
62
- options: ModeOption[];
63
- }
64
- /** Single option within a mode set, as authored. */
65
- interface ModeOptionInput {
66
- /** Optional human-readable label for Studio. Falls back to the option key. */
67
- label?: string;
68
- /**
69
- * Optional explicit modifier string. When omitted, derived as `_${optionKey}`.
70
- * Use this when the option key and modifier must differ (e.g. `xxl` → `_2xl`).
71
- */
72
- modifier?: ModifierNameShape;
73
- /** CSS selector applied when this option is active (e.g. `.dark`). */
74
- css?: string;
75
- /** Media query applied when this option is active. */
76
- media?: string;
77
- }
78
- /** Single mode set, as authored. */
79
- interface ModeSetInput {
80
- /** Optional human-readable label for Studio. Falls back to the set key. */
81
- label?: string;
82
- options: Record<string, ModeOptionInput>;
83
- }
84
- /** Object-keyed input shape accepted by `defineModes`. */
85
- type ModesInput = Record<string, ModeSetInput>;
86
- /**
87
- * Extract the union of modifier strings produced by an authored `ModesInput`.
88
- * Uses an explicit `modifier` when present; otherwise derives `_${optionKey}`.
89
- * Drives both the reserved-modifier guard and the modifier types that flow
90
- * through subsequent builder calls.
91
- */
92
- type GetModifierFromInput<I extends ModesInput> = { [SetKey in keyof I]: { [OptKey in keyof I[SetKey]['options']]: I[SetKey]['options'][OptKey] extends {
93
- modifier: infer M;
94
- } ? M extends ModifierNameShape ? M : never : OptKey extends string ? `_${OptKey}` : never }[keyof I[SetKey]['options']] }[keyof I];
95
- /** Reject any input whose derived/explicit modifiers collide with reserved names. */
96
- type CheckForReservedModifiersInput<I extends ModesInput> = true extends HasReservedModifier<GetModifierFromInput<I>> ? 'ERROR: Cannot use reserved modifier names from ModifierProp. Please use a different modifier name.' : I;
97
- /**
98
- * Convert the authored object-keyed input into the internal `ModeGroup[]` shape.
99
- * Derives `_${optionKey}` modifiers when no explicit `modifier` is provided.
100
- * Never sets `default: true` — the new API has no concept of a default option;
101
- * downstream consumers treat "no option active" as the implicit default.
102
- */
103
- declare function convertModesInputToGroups(input: ModesInput): ModeGroup[];
104
- interface ModifierDef {
105
- modifier: ModifierNameShape;
106
- selector: string;
107
- /** Description for AI prompt generation (e.g. "Apply styles on elevation-1 surfaces") */
108
- description?: string;
109
- }
110
- type AtomicTokenValue<M extends ModifierNameShape> = {
111
- name: string;
112
- /**
113
- * The token's authored value. Either a CSS literal (`'#1167f4'`,
114
- * `'1rem'`) or a `TokenMarker` from `token('ns/name')` pointing at
115
- * another registered token. Downstream emitters resolve markers to
116
- * `var(--<prefix>-<ns>-<name>)` aliases at CSS-generation time.
117
- */
118
- value: string | {
119
- readonly __kind: 'token';
120
- readonly ref: string;
121
- };
122
- /**
123
- * Resolved DTCG-aligned token type. Populated per-token only when the
124
- * token overrides the group-level `type` (e.g. a `'string'`-typed
125
- * `transparent` sitting inside a `'color'` namespace).
126
- */
127
- type?: TokenType;
128
- modifiers?: Partial<Record<M, string>>;
129
- };
130
- interface AtomicToken<M extends ModifierNameShape = ModifierNameShape> {
131
- properties: string[];
132
- tokens: AtomicTokenValue<M>[];
133
- /**
134
- * Resolved DTCG-aligned token type for the whole group. Set from
135
- * `$type` on `defineVars`, or inferred from `defineScopes` / value sniff
136
- * during config resolution.
137
- */
138
- type?: TokenType;
139
- /**
140
- * Free-form group description surfaced in Studio. Mirrors `$description`
141
- * on the source `defineVars` namespace; not used by the runtime / CSS
142
- * generator.
143
- */
144
- description?: string;
145
- /**
146
- * Original `defineVars` namespace key, verbatim — e.g. `borderColor`,
147
- * `spectrum`, `fontSize`. Distinct from {@link cssPrefix}, which is
148
- * the kebab-cased form used in CSS-variable names. The Studio uses
149
- * this to label tokens with the same identifier the author wrote in
150
- * their config (`borderColor/accent`, not `border-color/accent`).
151
- *
152
- * Optional for backwards compatibility — older serialized configs
153
- * predate the field; consumers should fall back to {@link cssPrefix}
154
- * (kebab-cased) when this is absent.
155
- */
156
- namespace?: string;
157
- /**
158
- * Optional CSS variable prefix override
159
- *
160
- * By default, the prefix is determined by the property type:
161
- * - color/bg/borderColor → '--color-*'
162
- * - spacing → '--spacing-*'
163
- * - fontFamily → '--font-*'
164
- *
165
- * Use this to customize the namespace for specific tokens.
166
- *
167
- * @example
168
- * ```ts
169
- * {
170
- * properties: ['color'],
171
- * cssPrefix: 'text', // Creates '--text-*' instead of '--color-*'
172
- * tokens: [{ name: 'brand', value: '#3b82f6' }]
173
- * }
174
- * ```
175
- */
176
- cssPrefix?: string;
177
- }
178
- /** Empty tokens type for initial state */
179
- type EmptyTokens = {};
180
- /** Empty vars type for initial state */
181
- type EmptyVars = {};
182
- /**
183
- * Derive the runtime `tokens` accessor type from a `defineVars` map. Each
184
- * namespace becomes `tokens[ns][tokenName] = string`. `$type` /
185
- * `$description` keys are excluded — they're authoring metadata, not tokens.
186
- */
187
- type VarsToTokens<TVars extends VarsConfig> = { [K in keyof TVars]: { [T in Exclude<keyof TVars[K], '$type' | '$description'>]: string } };
188
- /** Shallow merge of two token-shape records (later wins on collisions). */
189
- type MergeTokens<A, B> = { [K in keyof A | keyof B]: K extends keyof B ? K extends keyof A ? A[K] & B[K] : B[K] : K extends keyof A ? A[K] : never };
190
- /** Build a structured token reference object from atomic tokens */
191
- declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<string, Record<string, string>>;
192
- /** Build a structured composite-styles reference object for use in defineModifiers context */
193
- declare function buildCompositeStylesReference(compositeStyles: CompositeStylesConfig): Record<string, Record<string, {
194
- className: string;
195
- }>>;
196
- /** Global styles definition — CSS selector → style props */
197
- type GlobalStylesDef = Record<string, Record<string, any>>;
198
- /** CSS properties for the example wrapper element */
199
- type ExampleLayoutStyles = Record<string, string>;
200
- /** Single example entry — either iterates a variant axis or shows a static example */
201
- interface ExampleEntryDef<TAxis extends string = string> {
202
- each?: TAxis;
203
- layout?: ExampleLayoutStyles;
204
- props?: Record<string, Record<string, unknown>>;
205
- }
206
- /** Map of example keys (e.g. 'default', 'anatomy') to their definitions */
207
- type ExampleDef<TAxis extends string = string> = Record<string, ExampleEntryDef<TAxis>>;
208
- /** Build options that can be set in uds.config.ts via .buildOptions() */
209
- interface BuildOptions {
210
- skipCssVariables?: boolean;
211
- preflight?: boolean;
212
- /**
213
- * Scope every emitted CSS selector under this class name. The emitter's
214
- * `:root` block becomes `.<cssScope>`; mode/theme blocks (e.g. `.dark` or
215
- * `[data-theme="slate"]`) keep their ancestor selector and append `.<cssScope>`
216
- * so they still apply when the attribute is on `<html>`. Utility classes
217
- * are nested under `.<cssScope>` so two UDS-powered packages on the same
218
- * page do not collide.
219
- *
220
- * Wrap the embedded UI in `<div className="<cssScope>">` to activate.
221
- */
222
- cssScope?: string;
223
- }
224
- /** Internal data shape — accessible via resolveConfig() */
225
- interface UdsConfigData {
226
- modes: ModeGroup[];
227
- modifiers: ModifierDef[];
228
- atomic: AtomicToken<ModifierNameShape>[];
229
- compositeStyles: CompositeStylesConfig;
230
- motion: MotionPresetsDef;
231
- /**
232
- * Components registered via `.registerComponents({...})`. Authored
233
- * elsewhere via `defineComponent('Name', config)` and imported into
234
- * the config. The canonical input for codegen + runtime.
235
- *
236
- * Map keyed by component name (e.g. `Box`, `Alert`); each value is the
237
- * `ComponentConfigValue` branded record carrying `layers`, `props`,
238
- * `defaultProps`, `base`, `compoundProps`.
239
- */
240
- components: Record<string, ComponentConfigValue<any, any, any>>;
241
- globalStyles: GlobalStylesDef;
242
- preflight: boolean;
243
- prefix: string;
244
- buildOptions?: BuildOptions;
245
- examples?: Record<string, ExampleDef>;
246
- designPrinciples?: string[];
247
- vars?: VarsConfig;
248
- /**
249
- * Style props registered via `.registerStyleProps([...])`. Authored
250
- * elsewhere via `defineStyleProp(...)` and imported into the config.
251
- * The canonical input for codegen + runtime in the new architecture.
252
- *
253
- * Map keyed by JSX prop name (e.g. `bg`, `padding`); each value is the
254
- * style-prop record carrying `cssProperty`, `classPrefix`, `values`, etc.
255
- */
256
- styleProps?: Record<string, AnyStyleProp>;
257
- /**
258
- * Resolved style props — every registered style prop run through
259
- * `resolveStyleProp(propName, prop, config)` at `resolveConfig` time.
260
- * Each entry carries the prop's filtered token list, literal keywords,
261
- * arbitrary spec, and metadata. Codegen + runtime consume this instead
262
- * of walking the raw style-prop records.
263
- */
264
- resolvedStyleProps?: ResolvedStyleProp[];
265
- /**
266
- * Bound React component references for any registered entry that
267
- * came in as a bound component (primitive shorthand result or
268
- * `.render(fn)` output). Populated alongside `components` by
269
- * `.registerComponents({...})` and read by `resolveConfig` to seed
270
- * the module-level runtime registry so `defineComponent('{Box}', {})`
271
- * shorthand authoring can look the component up at render time
272
- * without a `.render(fn)` boilerplate.
273
- *
274
- * Raw-config entries (verbose-form `defineComponent({...})` values
275
- * passed in without `.render()`) don't appear here — they have no FC
276
- * to register.
277
- */
278
- componentInstances?: Record<string, _$react.ComponentType<any>>;
279
- /**
280
- * Previews registered via `.registerPreviews({ Name: definePreview(jsx) })`.
281
- * Map keyed by component name (matching `components`); each value
282
- * is a `DefinedPreview` carrying the authored JSX element and any
283
- * metadata attached via the `.metadata({...})` chain.
284
- *
285
- * Codegen reads this map's call-site source (via ts-morph) and walks
286
- * each JSX expression through `jsxToSpec` to populate
287
- * `manifest.preview[name]`. The runtime value itself is mostly inert
288
- * — Studio's catalog and docs's `[slug]` page consume the manifest,
289
- * not this slot.
290
- */
291
- previews?: Record<string, DefinedPreview>;
292
- }
293
- type PresetMergeMode = 'preserve' | 'merge' | 'override';
294
- interface ComponentConfigMergeStrategy {
295
- tokens?: PresetMergeMode;
296
- modes?: PresetMergeMode;
297
- modifiers?: PresetMergeMode;
298
- motion?: PresetMergeMode;
299
- components?: PresetMergeMode;
300
- globalStyles?: PresetMergeMode;
301
- examples?: PresetMergeMode;
302
- }
303
- /** Helper type: builder result includes both the UdsConfig interface and any extensions */
304
- type ConfigResult<TModifier extends ModifierNameShape, TTokens, TMotion, TExt extends Record<string, any> = {}, TCompositeStyles = EmptyCompositeStyles, TModeModifiers extends ModifierNameShape = never, TVars extends VarsConfig = EmptyVars> = UdsConfig<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars> & TExt;
305
- interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens = EmptyTokens, TMotion = EmptyMotion, TExt extends Record<string, any> = {}, TCompositeStyles = EmptyCompositeStyles, TModeModifiers extends ModifierNameShape = never, TVars extends VarsConfig = EmptyVars> {
306
- modes: ModeGroup[];
307
- atomic: AtomicToken<ModifierNameShape>[];
308
- components: Record<string, ComponentConfigValue<any, any, any>>;
309
- preflight(enabled?: boolean): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
310
- prefix(value: string): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
311
- buildOptions(options: BuildOptions): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
312
- defineModes<const NewModes extends ModesInput>(params: CheckForReservedModifiersInput<NewModes>): ConfigResult<TModifier | GetModifierFromInput<NewModes>, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers | GetModifierFromInput<NewModes>, TVars>;
313
- defineModifiers<const Defs extends readonly ModifierDef[]>(params: Defs | ((ctx: {
314
- tokens: TTokens;
315
- compositeStyles: CompositeStylesReference<TCompositeStyles>;
316
- }) => Defs)): ConfigResult<TModifier | Defs[number]['modifier'], TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers | Defs[number]['modifier'], TVars>;
317
- defineCompositeStyles<const M extends CompositeStylesConfig>(params: M | ((ctx: {
318
- tokens: TTokens;
319
- }) => M)): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles & M, TModeModifiers, TVars>;
320
- /**
321
- * Register composite styles authored via `defineCompositeStyle({...})`.
322
- * Mirrors `.registerStyleProps({...})` and `.registerComponents({...})`:
323
- * one factory call per composite, then a single registration step on
324
- * the builder. Calls accumulate — later registrations merge into the
325
- * same `compositeStyles` map that `.defineCompositeStyles({...})`
326
- * populates.
327
- *
328
- * Composites authored this way don't see the `tokens` context the
329
- * inline `defineCompositeStyles((ctx) => ...)` callback receives —
330
- * authors reference tokens by name (`'brand'`, `'sm'`) or brace-ref
331
- * (`'{spacing/4}'`). The resolver expands these the same way it does
332
- * for any other style-prop value.
333
- *
334
- * @example
335
- * ```ts
336
- * // packages/.../text-variant.ts
337
- * export const textVariant = defineCompositeStyle({
338
- * label: 'Text Variant',
339
- * styles: { body: { fontSize: '[1rem]', fontWeight: 'normal' } },
340
- * });
341
- *
342
- * // apps/<consumer>/uds.config.ts
343
- * udsBuilder.registerComposites({ textVariant });
344
- * ```
345
- */
346
- registerComposites<const M extends Record<string, DefinedCompositeStyle>>(composites: M): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles & { [K in keyof M]: {
347
- label: string;
348
- styles: M[K]['styles'];
349
- } }, TModeModifiers, TVars>;
350
- /**
351
- * Register style props, keyed by the JSX prop name consumers will use.
352
- * Calls accumulate — later `.registerStyleProps({...})` calls merge into
353
- * the existing map (later keys overwrite earlier ones with the same name).
354
- *
355
- * @example
356
- * ```ts
357
- * uds.registerStyleProps({
358
- * bg: {
359
- * cssProperty: 'background-color',
360
- * classPrefix: 'bg',
361
- * values: ['{global}', '{spectrum}', '{bg}'],
362
- * label: 'Background',
363
- * },
364
- * padding: {
365
- * cssProperty: 'padding',
366
- * classPrefix: 'p',
367
- * arbitrary: 'length-percentage',
368
- * values: ['{spacing}'],
369
- * label: 'Padding',
370
- * },
371
- * });
372
- * ```
373
- */
374
- registerStyleProps<const Props extends Record<string, AnyStyleProp>>(props: Props): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
375
- /**
376
- * Register components authored with `defineComponent(...)`. Calls
377
- * accumulate — later `.registerComponents({...})` calls merge into
378
- * the existing map (later keys overwrite earlier ones with the same
379
- * name).
380
- *
381
- * Accepts either form returned by `defineComponent`:
382
- * - The pure-data config value from the bare verbose form
383
- * (`defineComponent({ layers, props })`).
384
- * - A bound component from the primitive form
385
- * (`defineComponent('div', { props })`) or the chained
386
- * `.render(fn)` builder — the framework extracts the underlying
387
- * config from the non-enumerable `__config` slot.
388
- *
389
- * @example
390
- * ```ts
391
- * import { Box } from './src/uds/components/box'; // primitive
392
- * import { alertConfig } from './src/uds/components/alert.config'; // verbose pure-data
393
- *
394
- * uds.registerComponents({ Box, Alert: alertConfig });
395
- * ```
396
- */
397
- registerComponents<const TConfigs extends Record<string, ComponentConfigValue<any, any, any> | BoundComponent<ComponentConfigValue<any, any, any>, any> | (_$react.FC<any> & {
398
- readonly __config: ComponentConfigValue<any, any, any>;
399
- })>>(configs: TConfigs): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
400
- /**
401
- * Register catalog / docs preview tiles. Each key must match a name
402
- * registered via `.registerComponents({...})`; each value must be a
403
- * `definePreview(jsx)` result.
404
- *
405
- * Calls accumulate. Later registrations merge into the existing map
406
- * (later keys overwrite earlier ones with the same name). Codegen
407
- * reads the call-site source via ts-morph and walks each JSX
408
- * expression through `jsxToSpec` to populate `manifest.preview[name]`.
409
- *
410
- * @example
411
- * ```ts
412
- * import { Box, VStack } from './src/uds/components';
413
- *
414
- * const BoxPreview = definePreview(
415
- * <Box bg="tertiary" spacing="6">Box</Box>,
416
- * );
417
- *
418
- * const VStackPreview = definePreview(
419
- * <VStack gap="3">
420
- * <Box>1</Box>
421
- * <Box>2</Box>
422
- * </VStack>,
423
- * ).metadata({ description: 'Vertical stack' });
424
- *
425
- * uds.registerComponents({ Box, VStack }).registerPreviews({
426
- * Box: BoxPreview,
427
- * VStack: VStackPreview,
428
- * });
429
- * ```
430
- */
431
- registerPreviews<const TPreviews extends Record<string, DefinedPreview>>(previews: TPreviews): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
432
- defineMotion<const M extends MotionPresetsDef>(presets: M | ((tokens: TTokens) => M)): ConfigResult<TModifier, TTokens, { [K in keyof M]: string }, TExt, TCompositeStyles, TModeModifiers, TVars>;
433
- defineGlobalStyles(params: GlobalStylesDef | ((tokens: TTokens) => GlobalStylesDef)): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
434
- defineDesignPrinciples(principles: string[]): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
435
- extend<const NewExt extends Record<string, any>>(ext: NewExt): ConfigResult<TModifier, TTokens, TMotion, TExt & NewExt, TCompositeStyles, TModeModifiers, TVars>;
436
- defineVars<const TVarsNew extends VarsConfig<[TModeModifiers] extends [never] ? `_${string}` : TModeModifiers>>(vars: TVarsNew): ConfigResult<TModifier, MergeTokens<TTokens, VarsToTokens<TVars & TVarsNew>>, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars & TVarsNew>;
437
- }
438
- type AnyUdsConfig = UdsConfig<ModifierNameShape, any, any, any, any, any, any>;
439
- /** Extract the raw config data from a builder instance */
440
- declare function resolveConfig(config: AnyUdsConfig): UdsConfigData;
441
- declare function createConfigBuilder<TModifier extends ModifierNameShape = ModifierProp, TTokens = EmptyTokens, TMotion = EmptyMotion, TExt extends Record<string, any> = {}, TCompositeStyles = EmptyCompositeStyles, TModeModifiers extends ModifierNameShape = never, TVars extends VarsConfig = EmptyVars>(data: UdsConfigData, extensions?: TExt): UdsConfig<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars> & TExt;
442
- declare function interpolate(config: {
443
- output: number[];
444
- extrapolate?: 'clamp' | 'extend' | 'identity';
445
- }): InterpolateMarker;
446
- /**
447
- * Convert a px value to rem (assuming 16px base).
448
- *
449
- * @example rem(14) // '0.875rem'
450
- */
451
- declare function rem(px: number): string;
452
- declare function darker(color: string, amount: number): string;
453
- declare function lighter(color: string, amount: number): string;
454
- declare const uds: UdsConfig<ModifierProp, EmptyTokens, EmptyMotion, {}, EmptyCompositeStyles, never, EmptyVars>; //#endregion
455
- //#endregion
456
- export { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfigMergeStrategy, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, PresetMergeMode, UdsConfig, UdsConfigData, buildCompositeStylesReference, buildTokenReference, convertModesInputToGroups, createConfigBuilder, darker, interpolate, lighter, rem, resolveConfig, uds };