@yahoo/uds-v5-wip 1.36.0 → 1.36.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 (128) hide show
  1. package/dist/_virtual/_rolldown/runtime.js +13 -0
  2. package/dist/config/dist/component-resolution.d.ts +1 -1
  3. package/dist/config/dist/component-resolution.js +1 -1
  4. package/dist/config/dist/consts/defaultColors.d.ts +1 -2
  5. package/dist/config/dist/createConfig.d.ts +12 -88
  6. package/dist/config/dist/createConfig.js +67 -161
  7. package/dist/config/dist/defineStyleProp.d.ts +1 -12
  8. package/dist/config/dist/defineStyleProp.js +25 -0
  9. package/dist/config/dist/index.d.ts +2 -3
  10. package/dist/config/dist/index.js +2 -1
  11. package/dist/config/dist/preset-merge.js +0 -12
  12. package/dist/config/dist/propertyAcceptedTypes.js +17 -4
  13. package/dist/config/dist/propertyGroups.d.ts +1 -11
  14. package/dist/config/dist/propertyGroups.js +1 -19
  15. package/dist/config/dist/resolveStyleProp.d.ts +0 -7
  16. package/dist/config/dist/resolveStyleProp.js +11 -2
  17. package/dist/config/dist/serialize.d.ts +11 -4
  18. package/dist/config/dist/serialize.js +3 -3
  19. package/dist/config/dist/types/css-values.d.ts +1 -2
  20. package/dist/config/dist/types.d.ts +1 -2
  21. package/dist/config.d.ts +184 -184
  22. package/dist/core/dist/color-opacity-map.d.ts +13 -0
  23. package/dist/core/dist/color-opacity-map.js +33 -0
  24. package/dist/core/dist/compositeStyles.d.ts +2 -1
  25. package/dist/core/dist/configurable-prop-helpers.d.ts +32 -0
  26. package/dist/core/dist/configurable-prop-helpers.js +61 -0
  27. package/dist/core/dist/createComponent.d.ts +2 -1
  28. package/dist/core/dist/createComponentExample.d.ts +2 -1
  29. package/dist/core/dist/createProvider.d.ts +2 -1
  30. package/dist/core/dist/generated/stylePropsTwMap.d.ts +2 -1
  31. package/dist/core/dist/getComponentStyles.d.ts +2 -1
  32. package/dist/core/dist/getStyles.d.ts +2 -1
  33. package/dist/core/dist/getStyles.js +3 -1
  34. package/dist/core/dist/index.d.ts +4 -1
  35. package/dist/core/dist/index.js +4 -1
  36. package/dist/core/dist/modifier-mappings.d.ts +13 -0
  37. package/dist/core/dist/modifier-mappings.js +61 -0
  38. package/dist/core/dist/resolveMotionState.d.ts +2 -1
  39. package/dist/core/dist/style-prop-data.d.ts +33 -0
  40. package/dist/{loader/dist/packages/core/dist/propMappings.js → core/dist/style-prop-data.js} +2 -93
  41. package/dist/core/dist/transformPreset.d.ts +2 -1
  42. package/dist/core/dist/withDefaultStyleProps.d.ts +2 -1
  43. package/dist/core.d.ts +4 -1
  44. package/dist/core.js +4 -1
  45. package/dist/fixtures.d.ts +3 -1
  46. package/dist/fixtures.js +3 -1
  47. package/dist/foundational-presets/dist/boldVibrant.d.ts +573 -224
  48. package/dist/foundational-presets/dist/brutalist.d.ts +573 -224
  49. package/dist/foundational-presets/dist/candy.d.ts +573 -224
  50. package/dist/foundational-presets/dist/cleanMinimalist.d.ts +573 -224
  51. package/dist/foundational-presets/dist/corporate.d.ts +573 -224
  52. package/dist/foundational-presets/dist/darkMoody.d.ts +573 -224
  53. package/dist/foundational-presets/dist/defaultPreset.d.ts +197 -198
  54. package/dist/foundational-presets/dist/defaultPreset.js +2 -312
  55. package/dist/foundational-presets/dist/forest.d.ts +573 -224
  56. package/dist/foundational-presets/dist/highContrast.d.ts +573 -224
  57. package/dist/foundational-presets/dist/lavender.d.ts +573 -224
  58. package/dist/foundational-presets/dist/luxury.d.ts +573 -224
  59. package/dist/foundational-presets/dist/monochrome.d.ts +573 -224
  60. package/dist/foundational-presets/dist/neonCyber.d.ts +573 -224
  61. package/dist/foundational-presets/dist/newspaper.d.ts +573 -224
  62. package/dist/foundational-presets/dist/ocean.d.ts +573 -224
  63. package/dist/foundational-presets/dist/slate.d.ts +350 -0
  64. package/dist/foundational-presets/dist/style-props.js +1384 -0
  65. package/dist/foundational-presets/dist/sunset.d.ts +350 -0
  66. package/dist/foundational-presets/dist/terminal.d.ts +350 -0
  67. package/dist/foundational-presets/dist/warmOrganic.d.ts +350 -0
  68. package/dist/loader/dist/loader/style-transform.js +2 -1
  69. package/dist/loader/dist/loader.d.ts +1 -2
  70. package/dist/loader/dist/next.d.ts +1 -2
  71. package/dist/loader/dist/packages/core/dist/color-opacity-map.js +33 -0
  72. package/dist/loader/dist/packages/core/dist/getStyles.js +3 -1
  73. package/dist/loader/dist/packages/core/dist/modifier-mappings.js +61 -0
  74. package/dist/{core/dist/propMappings.js → loader/dist/packages/core/dist/style-prop-data.js} +2 -150
  75. package/dist/presets/dist/boldVibrant.d.ts +1 -2
  76. package/dist/presets/dist/brutalist.d.ts +1 -2
  77. package/dist/presets/dist/candy.d.ts +1 -2
  78. package/dist/presets/dist/cleanMinimalist.d.ts +1 -2
  79. package/dist/presets/dist/corporate.d.ts +1 -2
  80. package/dist/presets/dist/darkMoody.d.ts +1 -2
  81. package/dist/presets/dist/defaultPreset.d.ts +1 -2
  82. package/dist/presets/dist/forest.d.ts +1 -2
  83. package/dist/presets/dist/highContrast.d.ts +1 -2
  84. package/dist/presets/dist/lavender.d.ts +1 -2
  85. package/dist/presets/dist/luxury.d.ts +1 -2
  86. package/dist/presets/dist/monochrome.d.ts +1 -2
  87. package/dist/presets/dist/neonCyber.d.ts +1 -2
  88. package/dist/presets/dist/newspaper.d.ts +1 -2
  89. package/dist/presets/dist/ocean.d.ts +1 -2
  90. package/dist/presets/dist/slate.d.ts +1 -2
  91. package/dist/presets/dist/sunset.d.ts +1 -2
  92. package/dist/presets/dist/terminal.d.ts +1 -2
  93. package/dist/presets/dist/warmOrganic.d.ts +1 -2
  94. package/dist/remotion/dist/components/image-slide.d.ts +1 -2
  95. package/dist/remotion/dist/components/lower-third.d.ts +1 -2
  96. package/dist/remotion/dist/components/quote-card.d.ts +1 -2
  97. package/dist/remotion/dist/components/split-screen.d.ts +1 -2
  98. package/dist/remotion/dist/components/stat-card.d.ts +1 -2
  99. package/dist/remotion/dist/components/text-overlay.d.ts +1 -2
  100. package/dist/remotion/dist/components/title-card.d.ts +1 -2
  101. package/dist/remotion/dist/components/typing-text.d.ts +1 -2
  102. package/dist/tsconfig.tsbuildinfo +1 -1
  103. package/dist/utils/dist/array-utils/closestItem.d.ts +2 -1
  104. package/dist/utils/dist/array-utils/removeItem.d.ts +2 -1
  105. package/dist/utils/dist/component-style-defaults.d.ts +2 -1
  106. package/dist/utils/dist/math-utils/clamp.d.ts +2 -1
  107. package/dist/utils/dist/motion-utils/interpolate.d.ts +2 -1
  108. package/dist/utils/dist/object-utils/entries.d.ts +2 -1
  109. package/dist/utils/dist/object-utils/flattenObj.d.ts +2 -1
  110. package/dist/utils/dist/object-utils/fromEntries.d.ts +2 -1
  111. package/dist/utils/dist/object-utils/keys.d.ts +2 -1
  112. package/dist/utils/dist/object-utils/mapKeys.d.ts +2 -1
  113. package/dist/utils/dist/object-utils/mapValues.d.ts +2 -1
  114. package/dist/utils/dist/string-utils/arrayToUnion.d.ts +2 -1
  115. package/dist/utils/dist/string-utils/capitalize.d.ts +2 -1
  116. package/dist/utils/dist/string-utils/componentClassName.d.ts +2 -1
  117. package/dist/utils/dist/string-utils/createTemplate.d.ts +2 -1
  118. package/dist/utils/dist/string-utils/cssVar.d.ts +2 -1
  119. package/dist/utils/dist/string-utils/cssVars.d.ts +2 -1
  120. package/dist/utils/dist/string-utils/dedent.d.ts +2 -1
  121. package/dist/utils/dist/string-utils/indent.d.ts +2 -1
  122. package/dist/utils/dist/string-utils/join.d.ts +2 -1
  123. package/dist/utils/dist/string-utils/kebabCase.d.ts +2 -1
  124. package/dist/utils/dist/string-utils/split.d.ts +2 -1
  125. package/dist/utils/dist/string-utils/tsProperties.d.ts +2 -1
  126. package/dist/utils.d.ts +1 -1
  127. package/package.json +3 -3
  128. package/dist/core/dist/propMappings.d.ts +0 -76
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -1 +1 @@
1
- export { };
1
+ import { ComponentsConfig } from "@uds/types";
@@ -1,4 +1,4 @@
1
- import { propMappings } from "../../core/dist/propMappings.js";
1
+ import { propMappings } from "../../core/dist/style-prop-data.js";
2
2
  import "../../core/dist/index.js";
3
3
  //#region ../config/dist/component-resolution.js
4
4
  /**
@@ -1,5 +1,4 @@
1
1
  //#region ../config/dist/consts/defaultColors.d.ts
2
- //#region src/consts/defaultColors.d.ts
3
2
  declare const defaultColors: {
4
3
  inherit: string;
5
4
  current: string;
@@ -248,6 +247,6 @@ declare const defaultColors: {
248
247
  'rose-800': string;
249
248
  'rose-900': string;
250
249
  'rose-950': string;
251
- }; //#endregion
250
+ };
252
251
  //#endregion
253
252
  export { defaultColors };
@@ -1,11 +1,9 @@
1
1
  import { AnyStyleProp } from "./defineStyleProp.js";
2
- import { PropertyGroupId } from "./propertyGroups.js";
3
- import { TokenType, VarsConfig } from "./types.js";
4
2
  import { ResolvedStyleProp } from "./resolveStyleProp.js";
5
- import { BaseModifierProp, ComponentsConfig, CompositeStylesConfig, ConfigurableProp, ModifierProp, MotionPreset, RemotionComponentDef, RemotionConfig, RemotionTransitionDef, StyleProp } from "@uds/types";
3
+ import { TokenType, VarsConfig } from "./types.js";
4
+ import { BaseModifierProp, ComponentsConfig, CompositeStylesConfig, ConfigurableProp, ModifierProp, MotionPreset, RemotionComponentDef, RemotionConfig, RemotionTransitionDef } from "@uds/types";
6
5
 
7
6
  //#region ../config/dist/createConfig.d.ts
8
- //#region src/createConfig.d.ts
9
7
  type MotionPresetsDef = Record<string, MotionPreset>;
10
8
  type MotionAliasValue<TMotion> = TMotion extends Record<string, infer V> ? Extract<V, string> : never;
11
9
  type EmptyMotion = {};
@@ -78,22 +76,12 @@ type GetModifierFromInput<I extends ModesInput> = { [SetKey in keyof I]: { [OptK
78
76
  } ? M extends ModifierNameShape ? M : never : OptKey extends string ? `_${OptKey}` : never }[keyof I[SetKey]['options']] }[keyof I];
79
77
  /** Reject any input whose derived/explicit modifiers collide with reserved names. */
80
78
  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;
81
- /**
82
- * Convert the authored object-keyed input into the internal `ModeGroup[]` shape.
83
- * Derives `_${optionKey}` modifiers when no explicit `modifier` is provided.
84
- * Never sets `default: true` — the new API has no concept of a default option;
85
- * downstream consumers treat "no option active" as the implicit default.
86
- */
87
79
  interface ModifierDef {
88
80
  modifier: ModifierNameShape;
89
81
  selector: string;
90
82
  /** Description for AI prompt generation (e.g. "Apply styles on elevation-1 surfaces") */
91
83
  description?: string;
92
84
  }
93
- interface ArbitraryTokenGroup {
94
- properties: string[];
95
- pattern: string | string[];
96
- }
97
85
  type AtomicTokenValue<M extends ModifierNameShape> = {
98
86
  name: string;
99
87
  value: string;
@@ -153,29 +141,20 @@ interface AtomicToken<M extends ModifierNameShape = ModifierNameShape> {
153
141
  */
154
142
  cssPrefix?: string;
155
143
  }
156
- /** Merge two token structures */
157
- 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 };
158
- /**
159
- * Derive token types directly from defineVars namespaces. Each var namespace
160
- * key becomes a property on `tokens.*` with the namespace's token names.
161
- *
162
- * NOTE: We intentionally do NOT add a `Record<string, Record<string, string>>`
163
- * index-signature fallback here. The fallback used to support property-name
164
- * access (e.g. `tokens.borderRadius.*` for the `radius` namespace scoped to
165
- * `borderRadius`), but it caused TypeScript to silently widen every
166
- * `tokens.<ns>.<name>` access to `string` — typos like
167
- * `tokens.borderColor.aksjdf` would not be flagged. With the fallback removed,
168
- * accesses must use the defineVars namespace key (e.g. `tokens.radius.full`,
169
- * not `tokens.borderRadius.full`); both forms remain valid at runtime.
170
- */
171
- type VarsToTokens<TVars extends VarsConfig> = { [K in keyof TVars]: { [T in Exclude<keyof TVars[K], '$type' | '$description'>]: string } };
172
144
  /** Empty tokens type for initial state */
173
145
  type EmptyTokens = {};
174
146
  /** Empty vars type for initial state */
175
147
  type EmptyVars = {};
148
+ /**
149
+ * Derive the runtime `tokens` accessor type from a `defineVars` map. Each
150
+ * namespace becomes `tokens[ns][tokenName] = string`. `$type` /
151
+ * `$description` keys are excluded — they're authoring metadata, not tokens.
152
+ */
153
+ type VarsToTokens<TVars extends VarsConfig> = { [K in keyof TVars]: { [T in Exclude<keyof TVars[K], '$type' | '$description'>]: string } };
154
+ /** Shallow merge of two token-shape records (later wins on collisions). */
155
+ 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 };
176
156
  /** Build a structured token reference object from atomic tokens */
177
157
  declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<string, Record<string, string>>;
178
- /** Build a structured composite-styles reference object for use in defineModifiers context */
179
158
  /** Global styles definition — CSS selector → style props */
180
159
  type GlobalStylesDef = Record<string, Record<string, any>>;
181
160
  /** CSS properties for the example wrapper element */
@@ -205,23 +184,10 @@ interface UdsConfigData {
205
184
  preflight: boolean;
206
185
  prefix: string;
207
186
  remotion?: RemotionConfig;
208
- arbitraryTokens?: ArbitraryTokenGroup[];
209
187
  buildOptions?: BuildOptions;
210
188
  examples?: Record<string, ExampleDef>;
211
189
  designPrinciples?: string[];
212
190
  vars?: VarsConfig;
213
- /**
214
- * Map each ConfigurableProp to its generated CSS class prefix.
215
- * Set via `defineClassNames()`. Falls back to kebab-case of the property name.
216
- */
217
- classNames?: Record<string, string>;
218
- /**
219
- * Map each var namespace to the property group IDs it feeds.
220
- * Set via `defineScopes()`. This is the canonical source for
221
- * "which tokens can this property use" — the Studio UI reads and
222
- * edits this via draft patches.
223
- */
224
- scopes?: Record<string, string[]>;
225
191
  /**
226
192
  * Token names contributed by any composed preset, keyed by namespace.
227
193
  *
@@ -292,7 +258,6 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
292
258
  defineCompositeStyles<const M extends CompositeStylesConfig>(params: M | ((ctx: {
293
259
  tokens: TTokens;
294
260
  }) => M)): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles & M, TModeModifiers, TVars>;
295
- defineArbitraryTokens(params: ArbitraryTokenGroup[]): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
296
261
  /**
297
262
  * Register style props, keyed by the JSX prop name consumers will use.
298
263
  * Calls accumulate — later `.registerStyleProps({...})` calls merge into
@@ -343,52 +308,11 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
343
308
  defineRemotionTransitions(params: Record<string, RemotionTransitionDef> | ((ctx: {
344
309
  tokens: TTokens;
345
310
  }) => Record<string, RemotionTransitionDef>)): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
346
- defineVars<const TVarsNew extends VarsConfig<[TModeModifiers] extends [never] ? `_${string}` : TModeModifiers>>(vars: TVarsNew): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars & TVarsNew>;
347
- /**
348
- * Map each ConfigurableProp to a CSS class prefix.
349
- * Falls back to kebab-case of the property name when not specified.
350
- * Typically called once by the foundational preset — consumers rarely touch this.
351
- *
352
- * @example
353
- * ```ts
354
- * uds.defineClassNames({
355
- * color: 'text',
356
- * bg: 'bg',
357
- * borderColor: 'border-color',
358
- * spacing: 'p',
359
- * gap: 'gap',
360
- * borderRadius: 'rounded',
361
- * })
362
- * ```
363
- */
364
- defineClassNames(classNames: { [K in StyleProp]?: string }): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
365
- /**
366
- * Map var namespaces to property groups, defining which tokens each property
367
- * group can reference. This is the canonical scope definition — the Studio UI
368
- * renders it as checkboxes per token group.
369
- *
370
- * @example
371
- * ```ts
372
- * uds
373
- * .defineVars({
374
- * color: { brand: { value: '#1167f4' } },
375
- * spacing: { sm: { value: '4px' } },
376
- * })
377
- * .defineScopes({
378
- * color: ['textColor', 'background', 'borderColor', 'ringColor'],
379
- * spacing: ['padding', 'gap', 'margin'],
380
- * })
381
- * ```
382
- */
383
- defineScopes(scopes: [keyof TVars] extends [never] ? Record<string, PropertyGroupId[]> : { [K in keyof TVars]?: PropertyGroupId[] }): ConfigResult<TModifier, MergeTokens<TTokens, VarsToTokens<TVars>>, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
311
+ 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>;
384
312
  }
385
313
  type AnyUdsConfig = UdsConfig<ModifierNameShape, any, any, any, any, any, any>;
386
314
  /** Extract the raw config data from a builder instance */
387
315
  declare function resolveConfig(config: AnyUdsConfig): UdsConfigData;
388
- /**
389
- * Resolve configuration with all token references replaced by their raw values.
390
- * Useful for tools that need the actual values (e.g. anatomy generation).
391
- */
392
316
  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;
393
317
  interface InterpolateMarker {
394
318
  __type: 'interpolate';
@@ -398,4 +322,4 @@ interface InterpolateMarker {
398
322
  declare function darker(color: string, amount: number): string;
399
323
  declare function lighter(color: string, amount: number): string;
400
324
  //#endregion
401
- export { ArbitraryTokenGroup, AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig };
325
+ export { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig };
@@ -1,13 +1,12 @@
1
1
  import { kebabCase } from "../../utils/dist/string-utils/kebabCase.js";
2
2
  import { safeTokenName } from "../../utils/dist/string-utils/cssVar.js";
3
3
  import "../../utils/dist/index.js";
4
- import { getConfigurablePropMapping } from "../../core/dist/propMappings.js";
4
+ import { getConfigurablePropMapping } from "../../core/dist/configurable-prop-helpers.js";
5
5
  import "../../core/dist/index.js";
6
6
  import { buildMotionReference, resolveComponentMotionAliases, validateComponentVariants } from "./component-resolution.js";
7
- import { applyPresetToData, deepMerge, mergeAtomic } from "./preset-merge.js";
8
- import { expandPropertyGroups } from "./propertyGroups.js";
9
7
  import { resolveTokenType, sniffTokenTypeFromValue } from "./resolveTokenTypes.js";
10
8
  import { resolveStyleProp } from "./resolveStyleProp.js";
9
+ import { applyPresetToData, deepMerge, mergeAtomic } from "./preset-merge.js";
11
10
  //#region ../config/dist/createConfig.js
12
11
  /** biome-ignore-all lint/suspicious/noExplicitAny: necessary for dynamic builder to work correctly */
13
12
  /**
@@ -139,44 +138,59 @@ function varGroupToTokens(varGroup, knownModifiers) {
139
138
  };
140
139
  }
141
140
  /**
142
- * Sort properties so the one matching the cssPrefix comes last.
143
- * `buildVarToTokenMap` uses "last wins", so this ensures e.g. `color.brand`
144
- * beats `shadowColor.brand` when both reference `var(--uds-color-brand)`.
141
+ * For each var namespace, derive the list of style-prop names that consume
142
+ * it by inverting `registerStyleProps(...).values`. A styleProp with
143
+ * `values: ['{bg}', '{global}']` is recorded as consuming `bg` and `global`;
144
+ * a `{ ref: '{bg}', namespace: 'background' }` namespaced ref counts the
145
+ * same. Token-key refs like `'{spacing.4}'` also count toward `spacing`.
145
146
  */
146
- function sortPropertiesByPrefixMatch(properties, namespace, cssPfx) {
147
- return properties.slice().sort((a, b) => {
148
- return (a === namespace || kebabCase(a) === cssPfx ? 1 : 0) - (b === namespace || kebabCase(b) === cssPfx ? 1 : 0);
149
- });
147
+ function buildNamespaceConsumers(styleProps) {
148
+ const result = /* @__PURE__ */ new Map();
149
+ if (!styleProps) return result;
150
+ const refRe = /^\{([^.{}]+)/;
151
+ const addConsumer = (namespace, propName) => {
152
+ const list = result.get(namespace);
153
+ if (!list) {
154
+ result.set(namespace, [propName]);
155
+ return;
156
+ }
157
+ if (!list.includes(propName)) list.push(propName);
158
+ };
159
+ for (const [propName, prop] of Object.entries(styleProps)) for (const entry of prop.values ?? []) {
160
+ let raw;
161
+ if (typeof entry === "string") raw = entry;
162
+ else if (entry !== null && typeof entry === "object" && "ref" in entry && typeof entry.ref === "string") raw = entry.ref;
163
+ if (!raw) continue;
164
+ const match = refRe.exec(raw);
165
+ if (!match || !match[1]) continue;
166
+ addConsumer(match[1], propName);
167
+ }
168
+ return result;
150
169
  }
151
170
  /**
152
- * Synthesize AtomicToken[] from defineScopes + defineVars data.
153
- *
154
- * For each namespace in `scopes`, expands property group IDs into
155
- * ConfigurableProps, extracts tokens from the matching var namespace,
156
- * and produces an AtomicToken group.
171
+ * Synthesize AtomicToken[] from defineVars + registerStyleProps data. For
172
+ * each var namespace, emits an AtomicToken group whose `properties` list is
173
+ * the set of style props that reference that namespace (or any key inside
174
+ * it) via their `values` field. Replaces the older
175
+ * `synthesizeAtomicFromScopesAndVars` once a config has retired
176
+ * `defineScopes` in favor of per-prop `defineStyleProp({ values })`.
157
177
  */
158
- function synthesizeAtomicFromScopesAndVars(vars, scopes, modes) {
178
+ function synthesizeAtomicFromVarsAndStyleProps(vars, styleProps, modes) {
159
179
  const knownModifiers = /* @__PURE__ */ new Set();
160
180
  for (const mode of modes) for (const option of mode.options) knownModifiers.add(option.modifier);
181
+ const consumers = buildNamespaceConsumers(styleProps);
161
182
  const result = [];
162
- for (const [namespace, groupIds] of Object.entries(scopes)) {
163
- const varGroup = vars[namespace];
164
- if (!varGroup) continue;
165
- const properties = expandPropertyGroups(groupIds);
166
- if (properties.length === 0) continue;
183
+ for (const [namespace, varGroup] of Object.entries(vars)) {
167
184
  const { tokens, groupType, groupDescription } = varGroupToTokens(varGroup, knownModifiers);
168
- const cssPfx = (properties.includes(namespace) ? getConfigurablePropMapping(namespace) : void 0)?.defaultVarPrefix ?? kebabCase(namespace);
169
- const sorted = sortPropertiesByPrefixMatch(properties, namespace, cssPfx);
170
- const resolvedGroupType = resolveTokenType({
171
- explicit: groupType,
172
- scopes: groupIds
173
- });
185
+ const properties = consumers.get(namespace) ?? [];
186
+ const cssPfx = kebabCase(namespace);
187
+ const resolvedGroupType = resolveTokenType({ explicit: groupType });
174
188
  if (resolvedGroupType && resolvedGroupType !== "string") for (const token of tokens) {
175
189
  if (token.type) continue;
176
190
  if (sniffTokenTypeFromValue(token.value) === "string") token.type = "string";
177
191
  }
178
192
  result.push({
179
- properties: sorted,
193
+ properties,
180
194
  tokens,
181
195
  namespace,
182
196
  cssPrefix: cssPfx,
@@ -184,65 +198,6 @@ function synthesizeAtomicFromScopesAndVars(vars, scopes, modes) {
184
198
  ...groupDescription ? { description: groupDescription } : {}
185
199
  });
186
200
  }
187
- return disambiguateOverlappingProperties(result, scopes);
188
- }
189
- /**
190
- * When multiple scope namespaces reference the **same** property group
191
- * (e.g. `rotate`, `scale`, `skew`, `translate` all mapping to `['transform']`),
192
- * each namespace's AtomicToken gets ALL properties from that group, causing
193
- * last-write-wins collisions in CSS generation.
194
- *
195
- * This function partitions those shared-group properties among namespaces
196
- * using longest camelCase prefix matching. Cross-group overlaps (e.g.
197
- * `color` and `bg` both including the `bg` property via different groups)
198
- * are intentional cascading and left untouched.
199
- */
200
- function disambiguateOverlappingProperties(tokens, scopes) {
201
- const groupToNamespaces = /* @__PURE__ */ new Map();
202
- for (const [ns, groupIds] of Object.entries(scopes)) for (const gid of groupIds) {
203
- const list = groupToNamespaces.get(gid) ?? [];
204
- list.push(ns);
205
- groupToNamespaces.set(gid, list);
206
- }
207
- const contestedGroups = /* @__PURE__ */ new Map();
208
- for (const [gid, nsList] of groupToNamespaces) if (nsList.length > 1) contestedGroups.set(gid, nsList);
209
- if (contestedGroups.size === 0) return tokens;
210
- const propOwner = /* @__PURE__ */ new Map();
211
- for (const [gid, nsList] of contestedGroups) {
212
- const groupProps = expandPropertyGroups([gid]);
213
- const assignments = /* @__PURE__ */ new Map();
214
- const nsWithMatch = /* @__PURE__ */ new Set();
215
- for (const prop of groupProps) {
216
- let bestNs = "";
217
- let bestLen = 0;
218
- for (const ns of nsList) if (prop === ns || prop.startsWith(ns) && prop.length > ns.length) {
219
- if (ns.length > bestLen) {
220
- bestNs = ns;
221
- bestLen = ns.length;
222
- }
223
- }
224
- if (bestNs) {
225
- assignments.set(prop, bestNs);
226
- nsWithMatch.add(bestNs);
227
- }
228
- }
229
- if (nsWithMatch.size < 2) continue;
230
- for (const [prop, ns] of assignments) propOwner.set(prop, ns);
231
- }
232
- if (propOwner.size === 0) return tokens;
233
- const namespaces = Object.keys(scopes);
234
- const result = [];
235
- for (const token of tokens) {
236
- const ns = namespaces.find((n) => token.cssPrefix === kebabCase(n)) ?? "";
237
- const filtered = token.properties.filter((prop) => {
238
- const owner = propOwner.get(prop);
239
- return !owner || owner === ns;
240
- });
241
- if (filtered.length > 0) result.push({
242
- ...token,
243
- properties: filtered
244
- });
245
- }
246
201
  return result;
247
202
  }
248
203
  /** Extract the raw config data from a builder instance */
@@ -259,19 +214,16 @@ function resolveConfig(config) {
259
214
  globalStyles: config.globalStyles ?? {},
260
215
  preflight: config.preflight ?? true,
261
216
  prefix: config.prefix ?? "uds",
262
- arbitraryTokens: config.arbitraryTokens,
263
217
  remotion: config.remotion,
264
218
  buildOptions: config.buildOptions,
265
219
  examples: config.examples,
266
220
  designPrinciples: config.designPrinciples,
267
221
  vars: config.vars,
268
- classNames: config.classNames,
269
- scopes: config.scopes,
270
222
  presetTokenNames: config.presetTokenNames,
271
223
  styleProps: config.styleProps
272
224
  };
273
- if (configData.vars && configData.scopes) {
274
- const synthesized = synthesizeAtomicFromScopesAndVars(configData.vars, configData.scopes, configData.modes);
225
+ if (configData.vars) {
226
+ const synthesized = synthesizeAtomicFromVarsAndStyleProps(configData.vars, configData.styleProps, configData.modes);
275
227
  const atomic = mergeAtomic(configData.atomic, synthesized, "merge");
276
228
  configData = {
277
229
  ...configData,
@@ -333,13 +285,10 @@ function resolvePresetData(input) {
333
285
  globalStyles: input.globalStyles ?? {},
334
286
  preflight: input.preflight ?? true,
335
287
  prefix: input.prefix ?? "uds",
336
- arbitraryTokens: input.arbitraryTokens,
337
288
  remotion: input.remotion,
338
289
  examples: input.examples,
339
290
  designPrinciples: input.designPrinciples,
340
291
  vars: input.vars,
341
- classNames: input.classNames,
342
- scopes: input.scopes,
343
292
  presetTokenNames: input.presetTokenNames
344
293
  };
345
294
  }
@@ -347,52 +296,32 @@ function extractVarReferences(value) {
347
296
  if (typeof value !== "string") return [];
348
297
  return value.match(/var\([^()]+\)/g) ?? [];
349
298
  }
350
- function collectRequiredTokensFromObject(value, varToToken, out) {
299
+ function collectRequiredTokensFromObject(value, out) {
351
300
  if (value == null) return;
352
301
  if (typeof value === "string") {
353
302
  const refs = extractVarReferences(value);
354
- for (const ref of refs) {
355
- const token = varToToken.get(ref);
356
- if (token) out.add(token);
357
- }
303
+ for (const ref of refs) out.add(ref);
358
304
  return;
359
305
  }
360
306
  if (Array.isArray(value)) {
361
- for (const item of value) collectRequiredTokensFromObject(item, varToToken, out);
307
+ for (const item of value) collectRequiredTokensFromObject(item, out);
362
308
  return;
363
309
  }
364
- if (typeof value === "object") for (const child of Object.values(value)) collectRequiredTokensFromObject(child, varToToken, out);
365
- }
366
- function buildVarToTokenMap(data) {
367
- const tokenReference = buildTokenReference(data.atomic, data.prefix);
368
- const map = /* @__PURE__ */ new Map();
369
- for (const [prop, tokens] of Object.entries(tokenReference)) for (const [tokenName, tokenRef] of Object.entries(tokens)) map.set(tokenRef, `${prop}.${tokenName}`);
370
- return map;
310
+ if (typeof value === "object") for (const child of Object.values(value)) collectRequiredTokensFromObject(child, out);
371
311
  }
372
- function collectRequiredTokens(sourceData, components, motion) {
312
+ /**
313
+ * Collect the set of `var(--uds-X-Y)` references a component preset uses, so
314
+ * downstream `compose()` calls can verify the target config emits those
315
+ * variables. Storing raw var refs (instead of `propName.tokenKey` pairs)
316
+ * decouples the check from prop/namespace association lookups — only the
317
+ * actual CSS variable surface needs to be compatible.
318
+ */
319
+ function collectRequiredTokens(_sourceData, components, motion) {
373
320
  const out = /* @__PURE__ */ new Set();
374
- const varToToken = buildVarToTokenMap(sourceData);
375
- collectRequiredTokensFromObject(components, varToToken, out);
376
- if (motion) collectRequiredTokensFromObject(motion, varToToken, out);
321
+ collectRequiredTokensFromObject(components, out);
322
+ if (motion) collectRequiredTokensFromObject(motion, out);
377
323
  return Array.from(out).sort();
378
324
  }
379
- function availableTokenNames(data) {
380
- const names = /* @__PURE__ */ new Set();
381
- for (const group of data.atomic) for (const token of group.tokens) {
382
- for (const prop of group.properties) names.add(`${prop}.${token.name}`);
383
- if (group.cssPrefix) names.add(`${group.cssPrefix}.${token.name}`);
384
- if (group.namespace && group.namespace !== group.cssPrefix) names.add(`${group.namespace}.${token.name}`);
385
- }
386
- return names;
387
- }
388
- function validatePresetRequiredTokens(base, preset) {
389
- if (preset.requiredTokens.length === 0) return;
390
- const available = availableTokenNames(base);
391
- const missing = preset.requiredTokens.filter((name) => !available.has(name));
392
- if (missing.length === 0) return;
393
- const presetLabel = preset.name ? `"${preset.name}"` : "component preset";
394
- throw new Error(`Cannot compose ${presetLabel}: missing required tokens in current preset: ${missing.join(", ")}`);
395
- }
396
325
  function buildComponentsAccessor(components) {
397
326
  const accessor = {};
398
327
  for (const [name, config] of Object.entries(components)) {
@@ -489,14 +418,14 @@ function createConfigBuilder(data, extensions) {
489
418
  }
490
419
  }, extensions);
491
420
  },
492
- defineArbitraryTokens(params) {
493
- return next({ arbitraryTokens: [...data.arbitraryTokens ?? [], ...params] });
494
- },
495
421
  registerStyleProps(props) {
496
- return next({ styleProps: {
422
+ const mergedStyleProps = {
497
423
  ...data.styleProps ?? {},
498
424
  ...props
499
- } });
425
+ };
426
+ const updates = { styleProps: mergedStyleProps };
427
+ if (data.vars) updates.atomic = mergeAtomic([], synthesizeAtomicFromVarsAndStyleProps(data.vars, mergedStyleProps, data.modes ?? []), "override");
428
+ return next(updates);
500
429
  },
501
430
  defineMotion(presets) {
502
431
  const tokenReference = buildTokenReference(data.atomic, data.prefix);
@@ -550,7 +479,6 @@ function createConfigBuilder(data, extensions) {
550
479
  },
551
480
  compose(...presets) {
552
481
  return createConfigBuilder(presets.reduce((acc, preset) => {
553
- if (isComponentDefinition(preset)) validatePresetRequiredTokens(acc, preset);
554
482
  return applyPresetToData(acc, resolvePresetData(preset));
555
483
  }, data), extensions);
556
484
  },
@@ -590,7 +518,6 @@ function createConfigBuilder(data, extensions) {
590
518
  globalStyles: input.globalStyles ?? data.globalStyles,
591
519
  preflight: input.preflight ?? data.preflight,
592
520
  prefix: input.prefix ?? data.prefix,
593
- arbitraryTokens: input.arbitraryTokens ?? data.arbitraryTokens,
594
521
  examples: input.examples ?? data.examples,
595
522
  designPrinciples: input.designPrinciples ?? data.designPrinciples,
596
523
  vars: input.vars ?? data.vars,
@@ -673,32 +600,11 @@ function createConfigBuilder(data, extensions) {
673
600
  ...merged[namespace] ?? {},
674
601
  ...group
675
602
  };
676
- const updates = { vars: merged };
677
- if (data.scopes && Object.keys(data.scopes).length > 0) {
678
- const synthesized = synthesizeAtomicFromScopesAndVars(merged, data.scopes, data.modes ?? []);
679
- updates.atomic = mergeAtomic(data.atomic, synthesized, "merge");
680
- }
681
- return createConfigBuilder({
682
- ...data,
683
- ...updates
684
- }, extensions);
685
- },
686
- defineClassNames(classNames) {
687
- return next({ classNames: {
688
- ...data.classNames,
689
- ...classNames
690
- } });
691
- },
692
- defineScopes(scopes) {
693
- const mergedScopes = {
694
- ...data.scopes,
695
- ...scopes
603
+ const synthesized = synthesizeAtomicFromVarsAndStyleProps(merged, data.styleProps, data.modes ?? []);
604
+ const updates = {
605
+ vars: merged,
606
+ atomic: mergeAtomic(data.atomic, synthesized, "merge")
696
607
  };
697
- const updates = { scopes: mergedScopes };
698
- if (data.vars && Object.keys(data.vars).length > 0) {
699
- const synthesized = synthesizeAtomicFromScopesAndVars(data.vars, mergedScopes, data.modes ?? []);
700
- updates.atomic = mergeAtomic(data.atomic ?? [], synthesized, "merge");
701
- }
702
608
  return createConfigBuilder({
703
609
  ...data,
704
610
  ...updates
@@ -1,4 +1,4 @@
1
- import { CssValueTypeName } from "./types/css-values.js";
1
+ import { CssValue, CssValueTypeName } from "./types/css-values.js";
2
2
 
3
3
  //#region ../config/dist/defineStyleProp.d.ts
4
4
  /** Runtime input type for `toCss` based on the entry's `type`. */
@@ -22,20 +22,10 @@ type ArbitraryEntry = { [T in CssValueTypeName]: {
22
22
  * - An array of {@link ArbitraryEntry} for multi-shape acceptance.
23
23
  */
24
24
  type ArbitrarySpec = CssValueTypeName | readonly ArbitraryEntry[];
25
- /**
26
- * The literal-keyword subset of values a property accepts, derived from
27
- * {@link CssPropertyValues}[P]. For custom CSS properties (`--*`) the value
28
- * type is governed by the required `cssType` field instead, so any string
29
- * is accepted at the type level.
30
- */
31
25
  type StylePropMetadata = {
32
26
  label?: string;
33
27
  description?: string;
34
28
  };
35
- /**
36
- * A finalized style prop. Returned by `defineStyleProp(spec).metadata(meta)`.
37
- * Consumers wrap these in `uds.registerStyleProps({ <propName>: ... })`.
38
- */
39
29
  /**
40
30
  * Structurally-loose form of {@link StyleProp}. Any concrete `StyleProp<P>`
41
31
  * is assignable to this. Used at registration / resolution boundaries where
@@ -51,6 +41,5 @@ interface AnyStyleProp {
51
41
  readonly cssType?: CssValueTypeName;
52
42
  readonly metadata: StylePropMetadata;
53
43
  }
54
- /** Intermediate builder — the only callable method is `.metadata()`. */
55
44
  //#endregion
56
45
  export { AnyStyleProp, ArbitraryEntry, ArbitrarySpec, StylePropMetadata };
@@ -0,0 +1,25 @@
1
+ //#region ../config/dist/defineStyleProp.js
2
+ const CUSTOM_PROPERTY_PREFIX = "--";
3
+ /**
4
+ * Author a style prop. Returns a builder whose `.metadata({...})` finalizes
5
+ * the {@link StyleProp} record. Pure — no global registration.
6
+ */
7
+ function defineStyleProp(spec) {
8
+ const { cssProperty, classPrefix, values, arbitrary, cssType } = spec;
9
+ const isCustomProperty = cssProperty.startsWith(CUSTOM_PROPERTY_PREFIX);
10
+ if (isCustomProperty && cssType === void 0) throw new Error(`defineStyleProp: cssType is required for custom CSS properties (got cssProperty=${JSON.stringify(cssProperty)}).`);
11
+ if (!isCustomProperty && cssType !== void 0) throw new Error(`defineStyleProp: cssType is only allowed for custom CSS properties (--*). Got cssProperty=${JSON.stringify(cssProperty)} with cssType=${JSON.stringify(cssType)}.`);
12
+ return { metadata(meta = {}) {
13
+ return {
14
+ kind: "styleProp",
15
+ cssProperty,
16
+ classPrefix,
17
+ values: values ?? [],
18
+ arbitrary,
19
+ cssType,
20
+ metadata: meta
21
+ };
22
+ } };
23
+ }
24
+ //#endregion
25
+ export { defineStyleProp };
@@ -1,10 +1,9 @@
1
1
  import { defaultColors } from "./consts/defaultColors.js";
2
2
  import { ColorFn, ColorKeyword, CssAngle, CssColor, CssLength, CssPercentage, CssRatio, CssTime, CssValue, CssValueTypeName, HexColor, HslColor, RgbColor } from "./types/css-values.js";
3
3
  import { AnyStyleProp, ArbitraryEntry, ArbitrarySpec, StylePropMetadata } from "./defineStyleProp.js";
4
- import { PropertyGroupId } from "./propertyGroups.js";
5
- import { TokenType, VarGroupDef, VarTokenDef, VarsConfig } from "./types.js";
6
- import { ArbitraryTokenGroup, AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig } from "./createConfig.js";
7
4
  import { ResolvedStyleProp, ResolvedToken } from "./resolveStyleProp.js";
5
+ import { TokenType, VarGroupDef, VarTokenDef, VarsConfig } from "./types.js";
6
+ import { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig } from "./createConfig.js";
8
7
  import { SerializedConfig, TokenRef, buildReverseMap, deserializeConfig, serializeConfig } from "./serialize.js";
9
8
  import { ComponentsConfig as ComponentsConfig$1 } from "@uds/types";
10
9
  export { type ComponentsConfig$1 as ComponentsConfig };
@@ -1,8 +1,9 @@
1
1
  import "./consts/defaultColors.js";
2
2
  import "./component-resolution.js";
3
- import "./propertyGroups.js";
4
3
  import "./propertyAcceptedTypes.js";
5
4
  import "./resolveTokenTypes.js";
6
5
  import "./resolveStyleProp.js";
7
6
  import "./createConfig.js";
7
+ import "./defineStyleProp.js";
8
+ import "./propertyGroups.js";
8
9
  import "./serialize.js";