@yahoo/uds-v5-wip 1.36.0 → 1.37.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/config/dist/component-resolution.js +1 -1
  2. package/dist/config/dist/createConfig.d.ts +11 -75
  3. package/dist/config/dist/createConfig.js +67 -161
  4. package/dist/config/dist/defineComponent.d.ts +1 -0
  5. package/dist/config/dist/defineStyleProp.js +25 -0
  6. package/dist/config/dist/index.d.ts +1 -2
  7. package/dist/config/dist/index.js +3 -1
  8. package/dist/config/dist/preset-merge.js +0 -12
  9. package/dist/config/dist/propertyAcceptedTypes.js +17 -4
  10. package/dist/config/dist/propertyGroups.d.ts +1 -11
  11. package/dist/config/dist/propertyGroups.js +1 -19
  12. package/dist/config/dist/refs.js +1 -0
  13. package/dist/config/dist/resolveStyleProp.js +11 -2
  14. package/dist/config/dist/serialize.d.ts +10 -2
  15. package/dist/config/dist/serialize.js +3 -3
  16. package/dist/config.d.ts +1 -1
  17. package/dist/core/dist/color-opacity-map.d.ts +13 -0
  18. package/dist/core/dist/color-opacity-map.js +33 -0
  19. package/dist/core/dist/compositeStyles.d.ts +2 -1
  20. package/dist/core/dist/configurable-prop-helpers.d.ts +32 -0
  21. package/dist/core/dist/configurable-prop-helpers.js +61 -0
  22. package/dist/core/dist/createComponent.d.ts +2 -1
  23. package/dist/core/dist/createComponentExample.d.ts +2 -1
  24. package/dist/core/dist/createProvider.d.ts +2 -1
  25. package/dist/core/dist/generated/stylePropsTwMap.d.ts +2 -1
  26. package/dist/core/dist/getComponentStyles.d.ts +2 -1
  27. package/dist/core/dist/getStyles.d.ts +2 -1
  28. package/dist/core/dist/getStyles.js +3 -1
  29. package/dist/core/dist/index.d.ts +4 -1
  30. package/dist/core/dist/index.js +4 -1
  31. package/dist/core/dist/modifier-mappings.d.ts +13 -0
  32. package/dist/core/dist/modifier-mappings.js +61 -0
  33. package/dist/core/dist/resolveMotionState.d.ts +2 -1
  34. package/dist/core/dist/style-prop-data.d.ts +33 -0
  35. package/dist/{loader/dist/packages/core/dist/propMappings.js → core/dist/style-prop-data.js} +2 -93
  36. package/dist/core/dist/transformPreset.d.ts +2 -1
  37. package/dist/core/dist/withDefaultStyleProps.d.ts +2 -1
  38. package/dist/core.d.ts +4 -1
  39. package/dist/core.js +4 -1
  40. package/dist/fixtures.d.ts +3 -1
  41. package/dist/fixtures.js +3 -1
  42. package/dist/foundational-presets/dist/_virtual/_rolldown/runtime.js +13 -0
  43. package/dist/foundational-presets/dist/boldVibrant.d.ts +350 -0
  44. package/dist/foundational-presets/dist/brutalist.d.ts +350 -0
  45. package/dist/foundational-presets/dist/candy.d.ts +350 -0
  46. package/dist/foundational-presets/dist/cleanMinimalist.d.ts +350 -0
  47. package/dist/foundational-presets/dist/corporate.d.ts +350 -0
  48. package/dist/foundational-presets/dist/darkMoody.d.ts +350 -0
  49. package/dist/foundational-presets/dist/defaultPreset.d.ts +1 -1
  50. package/dist/foundational-presets/dist/defaultPreset.js +2 -312
  51. package/dist/foundational-presets/dist/forest.d.ts +350 -0
  52. package/dist/foundational-presets/dist/highContrast.d.ts +350 -0
  53. package/dist/foundational-presets/dist/lavender.d.ts +350 -0
  54. package/dist/foundational-presets/dist/luxury.d.ts +350 -0
  55. package/dist/foundational-presets/dist/monochrome.d.ts +350 -0
  56. package/dist/foundational-presets/dist/motion.d.ts +2 -1
  57. package/dist/foundational-presets/dist/neonCyber.d.ts +350 -0
  58. package/dist/foundational-presets/dist/newspaper.d.ts +350 -0
  59. package/dist/foundational-presets/dist/ocean.d.ts +350 -0
  60. package/dist/foundational-presets/dist/slate.d.ts +547 -196
  61. package/dist/foundational-presets/dist/style-props.js +1384 -0
  62. package/dist/foundational-presets/dist/sunset.d.ts +547 -196
  63. package/dist/foundational-presets/dist/terminal.d.ts +547 -196
  64. package/dist/foundational-presets/dist/warmOrganic.d.ts +547 -196
  65. package/dist/loader/dist/loader/style-transform.js +2 -1
  66. package/dist/loader/dist/packages/core/dist/color-opacity-map.js +33 -0
  67. package/dist/loader/dist/packages/core/dist/getStyles.js +3 -1
  68. package/dist/loader/dist/packages/core/dist/modifier-mappings.js +61 -0
  69. package/dist/{core/dist/propMappings.js → loader/dist/packages/core/dist/style-prop-data.js} +2 -150
  70. package/dist/tsconfig.tsbuildinfo +1 -1
  71. package/dist/utils/dist/array-utils/closestItem.d.ts +2 -1
  72. package/dist/utils/dist/array-utils/removeItem.d.ts +2 -1
  73. package/dist/utils/dist/component-style-defaults.d.ts +2 -1
  74. package/dist/utils/dist/math-utils/clamp.d.ts +2 -1
  75. package/dist/utils/dist/motion-utils/interpolate.d.ts +2 -1
  76. package/dist/utils/dist/object-utils/entries.d.ts +2 -1
  77. package/dist/utils/dist/object-utils/flattenObj.d.ts +2 -1
  78. package/dist/utils/dist/object-utils/fromEntries.d.ts +2 -1
  79. package/dist/utils/dist/object-utils/keys.d.ts +2 -1
  80. package/dist/utils/dist/object-utils/mapKeys.d.ts +2 -1
  81. package/dist/utils/dist/object-utils/mapValues.d.ts +2 -1
  82. package/dist/utils/dist/string-utils/arrayToUnion.d.ts +2 -1
  83. package/dist/utils/dist/string-utils/capitalize.d.ts +2 -1
  84. package/dist/utils/dist/string-utils/componentClassName.d.ts +2 -1
  85. package/dist/utils/dist/string-utils/createTemplate.d.ts +2 -1
  86. package/dist/utils/dist/string-utils/cssVar.d.ts +2 -1
  87. package/dist/utils/dist/string-utils/cssVars.d.ts +2 -1
  88. package/dist/utils/dist/string-utils/dedent.d.ts +2 -1
  89. package/dist/utils/dist/string-utils/indent.d.ts +2 -1
  90. package/dist/utils/dist/string-utils/join.d.ts +2 -1
  91. package/dist/utils/dist/string-utils/kebabCase.d.ts +2 -1
  92. package/dist/utils/dist/string-utils/split.d.ts +2 -1
  93. package/dist/utils/dist/string-utils/tsProperties.d.ts +2 -1
  94. package/dist/utils.d.ts +1 -1
  95. package/package.json +3 -3
  96. package/dist/core/dist/propMappings.d.ts +0 -76
@@ -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,8 +1,7 @@
1
1
  import { AnyStyleProp } from "./defineStyleProp.js";
2
- import { PropertyGroupId } from "./propertyGroups.js";
3
2
  import { TokenType, VarsConfig } from "./types.js";
4
3
  import { ResolvedStyleProp } from "./resolveStyleProp.js";
5
- import { BaseModifierProp, ComponentsConfig, CompositeStylesConfig, ConfigurableProp, ModifierProp, MotionPreset, RemotionComponentDef, RemotionConfig, RemotionTransitionDef, StyleProp } from "@uds/types";
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
7
  //#region src/createConfig.d.ts
@@ -90,10 +89,6 @@ interface ModifierDef {
90
89
  /** Description for AI prompt generation (e.g. "Apply styles on elevation-1 surfaces") */
91
90
  description?: string;
92
91
  }
93
- interface ArbitraryTokenGroup {
94
- properties: string[];
95
- pattern: string | string[];
96
- }
97
92
  type AtomicTokenValue<M extends ModifierNameShape> = {
98
93
  name: string;
99
94
  value: string;
@@ -153,26 +148,18 @@ interface AtomicToken<M extends ModifierNameShape = ModifierNameShape> {
153
148
  */
154
149
  cssPrefix?: string;
155
150
  }
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
151
  /** Empty tokens type for initial state */
173
152
  type EmptyTokens = {};
174
153
  /** Empty vars type for initial state */
175
154
  type EmptyVars = {};
155
+ /**
156
+ * Derive the runtime `tokens` accessor type from a `defineVars` map. Each
157
+ * namespace becomes `tokens[ns][tokenName] = string`. `$type` /
158
+ * `$description` keys are excluded — they're authoring metadata, not tokens.
159
+ */
160
+ type VarsToTokens<TVars extends VarsConfig> = { [K in keyof TVars]: { [T in Exclude<keyof TVars[K], '$type' | '$description'>]: string } };
161
+ /** Shallow merge of two token-shape records (later wins on collisions). */
162
+ 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
163
  /** Build a structured token reference object from atomic tokens */
177
164
  declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<string, Record<string, string>>;
178
165
  /** Build a structured composite-styles reference object for use in defineModifiers context */
@@ -205,23 +192,10 @@ interface UdsConfigData {
205
192
  preflight: boolean;
206
193
  prefix: string;
207
194
  remotion?: RemotionConfig;
208
- arbitraryTokens?: ArbitraryTokenGroup[];
209
195
  buildOptions?: BuildOptions;
210
196
  examples?: Record<string, ExampleDef>;
211
197
  designPrinciples?: string[];
212
198
  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
199
  /**
226
200
  * Token names contributed by any composed preset, keyed by namespace.
227
201
  *
@@ -292,7 +266,6 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
292
266
  defineCompositeStyles<const M extends CompositeStylesConfig>(params: M | ((ctx: {
293
267
  tokens: TTokens;
294
268
  }) => M)): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles & M, TModeModifiers, TVars>;
295
- defineArbitraryTokens(params: ArbitraryTokenGroup[]): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
296
269
  /**
297
270
  * Register style props, keyed by the JSX prop name consumers will use.
298
271
  * Calls accumulate — later `.registerStyleProps({...})` calls merge into
@@ -343,44 +316,7 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
343
316
  defineRemotionTransitions(params: Record<string, RemotionTransitionDef> | ((ctx: {
344
317
  tokens: TTokens;
345
318
  }) => 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>;
319
+ 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
320
  }
385
321
  type AnyUdsConfig = UdsConfig<ModifierNameShape, any, any, any, any, any, any>;
386
322
  /** Extract the raw config data from a builder instance */
@@ -398,4 +334,4 @@ interface InterpolateMarker {
398
334
  declare function darker(color: string, amount: number): string;
399
335
  declare function lighter(color: string, amount: number): string;
400
336
  //#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 };
337
+ 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
@@ -0,0 +1 @@
1
+ export { };
@@ -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,9 +1,8 @@
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
4
  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";
5
+ 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";
7
6
  import { ResolvedStyleProp, ResolvedToken } from "./resolveStyleProp.js";
8
7
  import { SerializedConfig, TokenRef, buildReverseMap, deserializeConfig, serializeConfig } from "./serialize.js";
9
8
  import { ComponentsConfig as ComponentsConfig$1 } from "@uds/types";
@@ -1,8 +1,10 @@
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";
9
+ import "./refs.js";
8
10
  import "./serialize.js";
@@ -148,16 +148,7 @@ function applyPresetToData(base, preset, strategy) {
148
148
  };
149
149
  const mergedExamples = base.examples || preset.examples ? mergeRecordByKey(base.examples ?? {}, preset.examples ?? {}, s.examples) : void 0;
150
150
  const mergedPrinciples = base.designPrinciples || preset.designPrinciples ? [...base.designPrinciples ?? [], ...preset.designPrinciples ?? []] : void 0;
151
- const mergedArbitraryTokens = base.arbitraryTokens || preset.arbitraryTokens ? [...base.arbitraryTokens ?? [], ...preset.arbitraryTokens ?? []] : void 0;
152
151
  const mergedVars = base.vars || preset.vars ? mergeRecordByKey(base.vars ?? {}, preset.vars ?? {}, "merge") : void 0;
153
- const mergedClassNames = base.classNames || preset.classNames ? {
154
- ...base.classNames,
155
- ...preset.classNames
156
- } : void 0;
157
- const mergedScopes = base.scopes || preset.scopes ? {
158
- ...base.scopes,
159
- ...preset.scopes
160
- } : void 0;
161
152
  const merged = {
162
153
  ...base,
163
154
  modes: mergeModes(base.modes, preset.modes, s.modes),
@@ -171,12 +162,9 @@ function applyPresetToData(base, preset, strategy) {
171
162
  components: mergeRecordByKey(base.components, preset.components, s.components),
172
163
  globalStyles: mergeRecordByKey(base.globalStyles, preset.globalStyles, s.globalStyles),
173
164
  remotion: mergeRemotionConfig(base.remotion, preset.remotion),
174
- arbitraryTokens: mergedArbitraryTokens,
175
165
  examples: mergedExamples,
176
166
  designPrinciples: mergedPrinciples,
177
167
  vars: mergedVars,
178
- classNames: mergedClassNames,
179
- scopes: mergedScopes,
180
168
  presetTokenNames: mergePresetTokenNames(base, preset)
181
169
  };
182
170
  validateComponentVariants(merged.components);
@@ -57,7 +57,10 @@ const CSS_WIDE_KEYWORDS = new Set([
57
57
  "initial",
58
58
  "unset",
59
59
  "revert",
60
- "revert-layer"
60
+ "revert-layer",
61
+ "transparent",
62
+ "currentColor",
63
+ "currentcolor"
61
64
  ]);
62
65
  const LENGTH_PCT_PROPS = [
63
66
  "gap",
@@ -184,11 +187,21 @@ const PROPERTY_ACCEPTED_TYPES = new Map([
184
187
  ] }],
185
188
  ["font-family", { types: ["font-family"] }],
186
189
  ["transition-timing-function", { types: ["easing-function"] }],
187
- ["box-shadow", { types: ["shadow"] }],
188
- ["text-shadow", { types: ["shadow"] }],
190
+ ["box-shadow", {
191
+ types: ["shadow"],
192
+ literals: ["none"]
193
+ }],
194
+ ["text-shadow", {
195
+ types: ["shadow"],
196
+ literals: ["none"]
197
+ }],
189
198
  ["list-style-image", { types: ["url", "image"] }],
190
199
  ["aspect-ratio", { types: ["ratio", "number"] }],
191
- ["opacity", { types: ["number", "percentage"] }]
200
+ ["opacity", { types: ["number", "percentage"] }],
201
+ ["z-index", {
202
+ types: ["integer", "number"],
203
+ literals: ["auto"]
204
+ }]
192
205
  ]);
193
206
  /**
194
207
  * Whether a token with the given detected value type AND raw string value
@@ -1,11 +1 @@
1
- import { ConfigurableProp } from "@uds/types";
2
-
3
- //#region ../config/dist/propertyGroups.d.ts
4
- //#region src/propertyGroups.d.ts
5
- type PropertyGroupId = 'textColor' | 'background' | 'borderColor' | 'outlineColor' | 'ringColor' | 'divideColor' | 'shadowColor' | 'svgFill' | 'svgStroke' | 'caretColor' | 'textDecorationColor' | 'opacity' | 'colorOpacity' | 'bgOpacity' | 'borderColorOpacity' | 'divideColorOpacity' | 'outlineColorOpacity' | 'ringColorOpacity' | 'textDecorationColorOpacity' | 'svgFillOpacity' | 'svgStrokeOpacity' | 'shadowColorOpacity' | 'caretColorOpacity' | 'fontFamily' | 'fontSize' | 'fontWeight' | 'lineHeight' | 'letterSpacing' | 'blur' | 'backdropBlur' | 'animation' | 'shadow' | 'textShadow' | 'zIndex' | 'borderWidth' | 'borderRadius' | 'outlineWidth' | 'divideWidth' | 'ringWidth' | 'padding' | 'margin' | 'offset' | 'gap' | 'indent' | 'scrollSnapGap' | 'scrollSnapSpacing' | 'tableBorderSpacing' | 'width' | 'height' | 'aspectRatio' | 'positionPlacement' | 'flex' | 'transform' | 'strokeWidth';
6
- /**
7
- * A logical grouping of ConfigurableProps with a human-readable label.
8
- * Used by the Studio UI to let users scope token groups to specific properties.
9
- */
10
- //#endregion
11
- export { PropertyGroupId };
1
+ import { ConfigurableProp } from "@uds/types";
@@ -394,7 +394,7 @@ const ALL_PROPERTY_GROUPS = [
394
394
  properties: ["strokeWidth"]
395
395
  }
396
396
  ];
397
- const groupById = new Map(ALL_PROPERTY_GROUPS.map((g) => [g.id, g]));
397
+ new Map(ALL_PROPERTY_GROUPS.map((g) => [g.id, g]));
398
398
  const propToGroupId = /* @__PURE__ */ new Map();
399
399
  for (const group of ALL_PROPERTY_GROUPS) for (const prop of group.properties) propToGroupId.set(prop, group.id);
400
400
  const COLOR_GROUPS = [
@@ -411,22 +411,4 @@ const COLOR_GROUPS = [
411
411
  "textDecorationColor"
412
412
  ];
413
413
  [...COLOR_GROUPS], [...COLOR_GROUPS], [...COLOR_GROUPS];
414
- /**
415
- * Given an array of group IDs, returns the flat union of all their
416
- * member ConfigurableProps (deduplicated).
417
- */
418
- function expandPropertyGroups(groupIds) {
419
- const seen = /* @__PURE__ */ new Set();
420
- const result = [];
421
- for (const id of groupIds) {
422
- const group = groupById.get(id);
423
- if (!group) continue;
424
- for (const prop of group.properties) if (!seen.has(prop)) {
425
- seen.add(prop);
426
- result.push(prop);
427
- }
428
- }
429
- return result;
430
- }
431
414
  //#endregion
432
- export { expandPropertyGroups };
@@ -0,0 +1 @@
1
+ import "../../utils/dist/index.js";