@yahoo/uds-v5-wip 1.35.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 (95) 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 +55 -87
  6. package/dist/config/dist/createConfig.js +82 -158
  7. package/dist/config/dist/defineStyleProp.d.ts +45 -0
  8. package/dist/config/dist/defineStyleProp.js +25 -0
  9. package/dist/config/dist/index.d.ts +4 -2
  10. package/dist/config/dist/index.js +4 -3
  11. package/dist/config/dist/preset-merge.js +0 -12
  12. package/dist/config/dist/propertyAcceptedTypes.js +81 -9
  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 +55 -1
  16. package/dist/config/dist/resolveStyleProp.js +197 -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 +60 -0
  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/configurable-prop-helpers.d.ts +32 -0
  25. package/dist/core/dist/configurable-prop-helpers.js +61 -0
  26. package/dist/core/dist/getStyles.js +3 -1
  27. package/dist/core/dist/index.d.ts +4 -1
  28. package/dist/core/dist/index.js +4 -1
  29. package/dist/core/dist/modifier-mappings.d.ts +13 -0
  30. package/dist/core/dist/modifier-mappings.js +61 -0
  31. package/dist/core/dist/style-prop-data.d.ts +33 -0
  32. package/dist/{loader/dist/packages/core/dist/propMappings.js → core/dist/style-prop-data.js} +2 -93
  33. package/dist/core.d.ts +4 -1
  34. package/dist/core.js +4 -1
  35. package/dist/fixtures.d.ts +3 -1
  36. package/dist/fixtures.js +3 -1
  37. package/dist/foundational-presets/dist/boldVibrant.d.ts +573 -224
  38. package/dist/foundational-presets/dist/brutalist.d.ts +573 -224
  39. package/dist/foundational-presets/dist/candy.d.ts +573 -224
  40. package/dist/foundational-presets/dist/cleanMinimalist.d.ts +573 -224
  41. package/dist/foundational-presets/dist/corporate.d.ts +573 -224
  42. package/dist/foundational-presets/dist/darkMoody.d.ts +573 -224
  43. package/dist/foundational-presets/dist/defaultPreset.d.ts +197 -198
  44. package/dist/foundational-presets/dist/defaultPreset.js +2 -312
  45. package/dist/foundational-presets/dist/forest.d.ts +573 -224
  46. package/dist/foundational-presets/dist/highContrast.d.ts +573 -224
  47. package/dist/foundational-presets/dist/lavender.d.ts +573 -224
  48. package/dist/foundational-presets/dist/luxury.d.ts +573 -224
  49. package/dist/foundational-presets/dist/monochrome.d.ts +573 -224
  50. package/dist/foundational-presets/dist/motion.d.ts +1 -2
  51. package/dist/foundational-presets/dist/neonCyber.d.ts +573 -224
  52. package/dist/foundational-presets/dist/newspaper.d.ts +573 -224
  53. package/dist/foundational-presets/dist/ocean.d.ts +573 -224
  54. package/dist/foundational-presets/dist/slate.d.ts +573 -224
  55. package/dist/foundational-presets/dist/style-props.js +1384 -0
  56. package/dist/foundational-presets/dist/sunset.d.ts +573 -224
  57. package/dist/foundational-presets/dist/terminal.d.ts +573 -224
  58. package/dist/foundational-presets/dist/warmOrganic.d.ts +573 -224
  59. package/dist/loader/dist/loader/style-transform.js +2 -1
  60. package/dist/loader/dist/loader.d.ts +1 -2
  61. package/dist/loader/dist/next.d.ts +1 -2
  62. package/dist/loader/dist/packages/core/dist/color-opacity-map.js +33 -0
  63. package/dist/loader/dist/packages/core/dist/getStyles.js +3 -1
  64. package/dist/loader/dist/packages/core/dist/modifier-mappings.js +61 -0
  65. package/dist/{core/dist/propMappings.js → loader/dist/packages/core/dist/style-prop-data.js} +2 -150
  66. package/dist/presets/dist/boldVibrant.d.ts +1 -2
  67. package/dist/presets/dist/brutalist.d.ts +1 -2
  68. package/dist/presets/dist/candy.d.ts +1 -2
  69. package/dist/presets/dist/cleanMinimalist.d.ts +1 -2
  70. package/dist/presets/dist/corporate.d.ts +1 -2
  71. package/dist/presets/dist/darkMoody.d.ts +1 -2
  72. package/dist/presets/dist/defaultPreset.d.ts +1 -2
  73. package/dist/presets/dist/forest.d.ts +1 -2
  74. package/dist/presets/dist/highContrast.d.ts +1 -2
  75. package/dist/presets/dist/lavender.d.ts +1 -2
  76. package/dist/presets/dist/luxury.d.ts +1 -2
  77. package/dist/presets/dist/monochrome.d.ts +1 -2
  78. package/dist/presets/dist/neonCyber.d.ts +1 -2
  79. package/dist/presets/dist/newspaper.d.ts +1 -2
  80. package/dist/presets/dist/ocean.d.ts +1 -2
  81. package/dist/presets/dist/slate.d.ts +1 -2
  82. package/dist/presets/dist/sunset.d.ts +1 -2
  83. package/dist/presets/dist/terminal.d.ts +1 -2
  84. package/dist/presets/dist/warmOrganic.d.ts +1 -2
  85. package/dist/remotion/dist/components/image-slide.d.ts +1 -2
  86. package/dist/remotion/dist/components/lower-third.d.ts +1 -2
  87. package/dist/remotion/dist/components/quote-card.d.ts +1 -2
  88. package/dist/remotion/dist/components/split-screen.d.ts +1 -2
  89. package/dist/remotion/dist/components/stat-card.d.ts +1 -2
  90. package/dist/remotion/dist/components/text-overlay.d.ts +1 -2
  91. package/dist/remotion/dist/components/title-card.d.ts +1 -2
  92. package/dist/remotion/dist/components/typing-text.d.ts +1 -2
  93. package/dist/tsconfig.tsbuildinfo +1 -1
  94. package/package.json +3 -3
  95. package/dist/core/dist/propMappings.d.ts +0 -77
@@ -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,7 +1,9 @@
1
1
  import { defaultColors } from "./consts/defaultColors.js";
2
- import { PropertyGroupId } from "./propertyGroups.js";
2
+ import { ColorFn, ColorKeyword, CssAngle, CssColor, CssLength, CssPercentage, CssRatio, CssTime, CssValue, CssValueTypeName, HexColor, HslColor, RgbColor } from "./types/css-values.js";
3
+ import { AnyStyleProp, ArbitraryEntry, ArbitrarySpec, StylePropMetadata } from "./defineStyleProp.js";
4
+ import { ResolvedStyleProp, ResolvedToken } from "./resolveStyleProp.js";
3
5
  import { TokenType, VarGroupDef, VarTokenDef, VarsConfig } from "./types.js";
4
- 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";
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";
5
7
  import { SerializedConfig, TokenRef, buildReverseMap, deserializeConfig, serializeConfig } from "./serialize.js";
6
8
  import { ComponentsConfig as ComponentsConfig$1 } from "@uds/types";
7
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
- import "./resolveTokenTypes.js";
5
- import "./createConfig.js";
6
3
  import "./propertyAcceptedTypes.js";
4
+ import "./resolveTokenTypes.js";
7
5
  import "./resolveStyleProp.js";
6
+ import "./createConfig.js";
7
+ import "./defineStyleProp.js";
8
+ import "./propertyGroups.js";
8
9
  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);
@@ -12,11 +12,56 @@ const LENGTH_PCT_AUTO = {
12
12
  ],
13
13
  literals: ["auto"]
14
14
  };
15
+ const SIZING = {
16
+ types: [
17
+ "length",
18
+ "percentage",
19
+ "length-percentage"
20
+ ],
21
+ literals: [
22
+ "auto",
23
+ "min-content",
24
+ "max-content",
25
+ "fit-content"
26
+ ]
27
+ };
28
+ const SIZING_WITH_NONE = {
29
+ types: [
30
+ "length",
31
+ "percentage",
32
+ "length-percentage"
33
+ ],
34
+ literals: [
35
+ "auto",
36
+ "min-content",
37
+ "max-content",
38
+ "fit-content",
39
+ "none"
40
+ ]
41
+ };
15
42
  const LENGTH_ONLY = { types: ["length"] };
16
- const COLOR_ONLY = { types: ["color"] };
43
+ const COLOR_ONLY = {
44
+ types: ["color"],
45
+ literals: ["transparent", "currentColor"]
46
+ };
17
47
  const TIME_ONLY = { types: ["time"] };
18
48
  const NUMBER_ONLY = { types: ["number", "integer"] };
19
49
  const ANGLE_ONLY = { types: ["angle"] };
50
+ /**
51
+ * CSS-wide keywords — accepted on every CSS property per the CSS spec.
52
+ * Synthesizer marks these as `$type: 'string'` so they don't match the
53
+ * property's type-based accept rule; they pass via this set instead.
54
+ */
55
+ const CSS_WIDE_KEYWORDS = new Set([
56
+ "inherit",
57
+ "initial",
58
+ "unset",
59
+ "revert",
60
+ "revert-layer",
61
+ "transparent",
62
+ "currentColor",
63
+ "currentcolor"
64
+ ]);
20
65
  const LENGTH_PCT_PROPS = [
21
66
  "gap",
22
67
  "column-gap",
@@ -72,14 +117,15 @@ const LENGTH_PCT_AUTO_PROPS = [
72
117
  "left",
73
118
  "inset",
74
119
  "inset-block",
75
- "inset-inline",
120
+ "inset-inline"
121
+ ];
122
+ const SIZING_PROPS = [
76
123
  "width",
77
124
  "height",
78
125
  "min-width",
79
- "min-height",
80
- "max-width",
81
- "max-height"
126
+ "min-height"
82
127
  ];
128
+ const SIZING_WITH_NONE_PROPS = ["max-width", "max-height"];
83
129
  const LENGTH_ONLY_PROPS = [
84
130
  "border-width",
85
131
  "border-top-width",
@@ -124,9 +170,11 @@ const NUMBER_PROPS = [
124
170
  "-webkit-line-clamp"
125
171
  ];
126
172
  const ANGLE_PROPS = ["rotate"];
127
- new Map([
173
+ const PROPERTY_ACCEPTED_TYPES = new Map([
128
174
  ...LENGTH_PCT_PROPS.map((p) => [p, LENGTH_PCT]),
129
175
  ...LENGTH_PCT_AUTO_PROPS.map((p) => [p, LENGTH_PCT_AUTO]),
176
+ ...SIZING_PROPS.map((p) => [p, SIZING]),
177
+ ...SIZING_WITH_NONE_PROPS.map((p) => [p, SIZING_WITH_NONE]),
130
178
  ...LENGTH_ONLY_PROPS.map((p) => [p, LENGTH_ONLY]),
131
179
  ...COLOR_PROPS.map((p) => [p, COLOR_ONLY]),
132
180
  ...TIME_PROPS.map((p) => [p, TIME_ONLY]),
@@ -139,10 +187,34 @@ new Map([
139
187
  ] }],
140
188
  ["font-family", { types: ["font-family"] }],
141
189
  ["transition-timing-function", { types: ["easing-function"] }],
142
- ["box-shadow", { types: ["shadow"] }],
143
- ["text-shadow", { types: ["shadow"] }],
190
+ ["box-shadow", {
191
+ types: ["shadow"],
192
+ literals: ["none"]
193
+ }],
194
+ ["text-shadow", {
195
+ types: ["shadow"],
196
+ literals: ["none"]
197
+ }],
144
198
  ["list-style-image", { types: ["url", "image"] }],
145
199
  ["aspect-ratio", { types: ["ratio", "number"] }],
146
- ["opacity", { types: ["number", "percentage"] }]
200
+ ["opacity", { types: ["number", "percentage"] }],
201
+ ["z-index", {
202
+ types: ["integer", "number"],
203
+ literals: ["auto"]
204
+ }]
147
205
  ]);
206
+ /**
207
+ * Whether a token with the given detected value type AND raw string value
208
+ * is accepted by the CSS property. Returns `true` for any property not in
209
+ * the table.
210
+ */
211
+ function isTokenAcceptedByProperty(cssProperty, valueType, rawValue) {
212
+ if (CSS_WIDE_KEYWORDS.has(rawValue)) return true;
213
+ const entry = PROPERTY_ACCEPTED_TYPES.get(cssProperty);
214
+ if (!entry) return true;
215
+ if (valueType && entry.types?.includes(valueType)) return true;
216
+ if (entry.literals?.includes(rawValue)) return true;
217
+ return false;
218
+ }
148
219
  //#endregion
220
+ export { PROPERTY_ACCEPTED_TYPES, isTokenAcceptedByProperty };
@@ -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 };
@@ -1 +1,55 @@
1
- export { };
1
+ import { CssValueTypeName } from "./types/css-values.js";
2
+ import { ArbitrarySpec, StylePropMetadata } from "./defineStyleProp.js";
3
+ //#region ../config/dist/resolveStyleProp.d.ts
4
+ interface ResolvedToken {
5
+ /** The token's raw key, e.g. `'brand'`. */
6
+ readonly name: string;
7
+ /** Resolved CSS value, e.g. `'#1167f4'` or `'1rem'`. */
8
+ readonly value: string;
9
+ /** Detected CSS value type, used for filtering. `undefined` if not detectable. */
10
+ readonly valueType: CssValueTypeName | undefined;
11
+ /** The token group's namespace (or cssPrefix fallback) the token came from. */
12
+ readonly group: string;
13
+ /**
14
+ * Style-prop-local namespace, set only when the token was sourced via a
15
+ * {@link NamespacedGroupRef}. Used to disambiguate when two groups feed
16
+ * the same prop and share keys.
17
+ */
18
+ readonly namespace?: string;
19
+ /**
20
+ * The user-facing key the consumer writes in JSX. For un-namespaced
21
+ * groups this is just `name`; for namespaced groups, `'${namespace}.${name}'`.
22
+ */
23
+ readonly qualifiedName: string;
24
+ /**
25
+ * The token name with characters that aren't class-name-safe replaced
26
+ * (e.g. `/` → `_`, `.` → `_`). Used as the trailing segment of generated
27
+ * `@utility` class names and CSS variable names. Mirrors
28
+ * `safeTokenName` from `@uds/utils`.
29
+ */
30
+ readonly safeName: string;
31
+ /**
32
+ * Full CSS variable reference for this token at config-build time, e.g.
33
+ * `'--uds-bg-brand'`. Built as `--{config.prefix}-{group.cssPrefix}-{safeName}`,
34
+ * falling back to omit the config prefix when it's empty.
35
+ */
36
+ readonly cssVar: string;
37
+ /**
38
+ * Per-modifier value overrides carried verbatim from the source
39
+ * `AtomicTokenValue`. Used by CSS-gen to emit mode override blocks
40
+ * (e.g. `.dark { --uds-bg-brand: ... }`).
41
+ */
42
+ readonly modifiers?: Record<string, string>;
43
+ }
44
+ interface ResolvedStyleProp {
45
+ /** The JSX prop name — the map key from `registerStyleProps({...})`. */
46
+ readonly propName: string;
47
+ readonly cssProperty: string;
48
+ readonly classPrefix: string;
49
+ readonly tokens: readonly ResolvedToken[];
50
+ readonly literals: readonly string[];
51
+ readonly arbitrary: ArbitrarySpec | undefined;
52
+ readonly metadata: StylePropMetadata;
53
+ }
54
+ //#endregion
55
+ export { ResolvedStyleProp, ResolvedToken };
@@ -1,2 +1,197 @@
1
- import "./resolveTokenTypes.js";
2
- import "./propertyAcceptedTypes.js";
1
+ import { safeTokenName } from "../../utils/dist/string-utils/cssVar.js";
2
+ import "../../utils/dist/index.js";
3
+ import { isTokenAcceptedByProperty } from "./propertyAcceptedTypes.js";
4
+ import { sniffTokenTypeFromValue } from "./resolveTokenTypes.js";
5
+ //#region ../config/dist/resolveStyleProp.js
6
+ /**
7
+ * Resolve a {@link StyleProp} authored via `defineStyleProp` against the
8
+ * active UDS config, producing a flat list of accepted tokens, literal
9
+ * keywords, and the arbitrary spec — the data that downstream codegen
10
+ * consumes to populate `Custom*` interfaces and emit utility CSS.
11
+ *
12
+ * Filtering invariant: a token is exposed in the resolved pool only when
13
+ * its detected CSS value type is accepted by the prop's `cssProperty`,
14
+ * per {@link PROPERTY_ACCEPTED_TYPES}. Properties absent from that table
15
+ * accept every token.
16
+ *
17
+ * The resolver is pure — given the same `(StyleProp, UdsConfigData)` input
18
+ * it returns the same output. Group lookups are by `namespace` (with a
19
+ * fallback to `cssPrefix`) on the resolved config's `atomic` array.
20
+ */
21
+ /**
22
+ * Map the legacy 8-entry `TokenType` enum to a {@link CssValueTypeName}.
23
+ * The `'dimension'` case is ambiguous (length vs. percentage); callers
24
+ * disambiguate by sniffing the value string.
25
+ */
26
+ function tokenTypeToValueType(t) {
27
+ switch (t) {
28
+ case "color": return "color";
29
+ case "dimension": return "length-percentage";
30
+ case "number": return "number";
31
+ case "fontFamily": return "font-family";
32
+ case "fontWeight": return "font-weight";
33
+ case "duration": return "time";
34
+ case "strokeStyle": return "string";
35
+ case "string": return "string";
36
+ default: return;
37
+ }
38
+ }
39
+ /**
40
+ * A value looks like a CSS shadow when it combines at least one length
41
+ * (offset/blur/spread) with a color reference. Catches both single-shadow
42
+ * (`'0 1px 2px rgba(...)'`) and multi-shadow (`'..., ...'`) forms, plus
43
+ * inset shadows. Used to refine `'string'`-typed tokens to the more precise
44
+ * `'shadow'` value type so they pass the runtime filter on `box-shadow` /
45
+ * `text-shadow` props.
46
+ */
47
+ const SHADOW_LENGTH_RE = /(?:^|[\s,])-?\d+(?:\.\d+)?(?:px|rem|em|ch|ex)/i;
48
+ const SHADOW_COLOR_RE = /(?:rgba?|hsla?|color|oklch|oklab|lch|lab|hwb)\(|#[0-9a-fA-F]{3,8}\b/;
49
+ function looksLikeShadow(value) {
50
+ const trimmed = value.trim();
51
+ return SHADOW_LENGTH_RE.test(trimmed) && SHADOW_COLOR_RE.test(trimmed);
52
+ }
53
+ /**
54
+ * Detect a token's CSS value type. Resolution order:
55
+ * 1. Per-token `type` override.
56
+ * 2. Group-level `type`.
57
+ * 3. Value sniff via {@link sniffTokenTypeFromValue}.
58
+ *
59
+ * When the resolved type is `'length-percentage'` and the raw value ends in
60
+ * `%`, narrow to `'percentage'`; otherwise narrow to `'length'`. When the
61
+ * resolved type is `'string'` but the value looks like a shadow expression,
62
+ * narrow to `'shadow'`.
63
+ */
64
+ function detectTokenValueType(token, group) {
65
+ const explicit = token.type ?? group.type;
66
+ let resolved;
67
+ if (explicit) resolved = tokenTypeToValueType(explicit);
68
+ else {
69
+ const sniffed = sniffTokenTypeFromValue(token.value);
70
+ resolved = sniffed ? tokenTypeToValueType(sniffed) : void 0;
71
+ }
72
+ if (resolved === "length-percentage") {
73
+ const trimmed = token.value.trim();
74
+ if (trimmed.endsWith("%")) return "percentage";
75
+ if (/(deg|rad|grad|turn)$/.test(trimmed)) return "angle";
76
+ if (/(ms|s)$/.test(trimmed)) return "time";
77
+ return "length";
78
+ }
79
+ if (resolved === "string") {
80
+ if (looksLikeShadow(token.value)) return "shadow";
81
+ if (/^\d+(?:\.\d+)?\s*\/\s*\d+(?:\.\d+)?$/.test(token.value.trim())) return "ratio";
82
+ }
83
+ return resolved;
84
+ }
85
+ const REF_RE = /^\{([^.{}]+)(?:\.([^.{}]+))?\}$/;
86
+ /**
87
+ * Parse a string ref like `'{palette}'` or `'{spacing.4}'`. Returns
88
+ * `undefined` for any string that isn't a brace ref (so the caller can
89
+ * treat it as a literal keyword).
90
+ */
91
+ function parseGroupRef(raw) {
92
+ const m = REF_RE.exec(raw);
93
+ if (!m) return void 0;
94
+ const [, group, key] = m;
95
+ if (!group) return void 0;
96
+ return key !== void 0 ? {
97
+ group,
98
+ key
99
+ } : { group };
100
+ }
101
+ function findGroup(atomic, name) {
102
+ return atomic.find((g) => g.namespace === name || g.cssPrefix === name);
103
+ }
104
+ function isNamespacedRef(entry) {
105
+ return typeof entry === "object" && entry !== null && "ref" in entry && "namespace" in entry;
106
+ }
107
+ /**
108
+ * Build `--{configPrefix}-{varPrefix}-{safeName}` (or omit the configPrefix
109
+ * when empty). Mirrors `buildTokenVarName` in `@uds/codegen/css/prepareCss`.
110
+ */
111
+ function buildCssVar(configPrefix, varPrefix, safeName) {
112
+ return configPrefix ? `--${configPrefix}-${varPrefix}-${safeName}` : `--${varPrefix}-${safeName}`;
113
+ }
114
+ function resolveGroupTokens(group, cssProperty, configPrefix, namespace) {
115
+ const groupName = group.namespace ?? group.cssPrefix ?? "";
116
+ const varPrefix = group.cssPrefix ?? group.namespace ?? "";
117
+ const out = [];
118
+ for (const token of group.tokens) {
119
+ const valueType = detectTokenValueType(token, group);
120
+ if (!isTokenAcceptedByProperty(cssProperty, valueType, token.value)) continue;
121
+ const safeName = safeTokenName(token.name);
122
+ out.push({
123
+ name: token.name,
124
+ value: token.value,
125
+ valueType,
126
+ group: groupName,
127
+ namespace,
128
+ qualifiedName: namespace !== void 0 ? `${namespace}.${token.name}` : token.name,
129
+ safeName,
130
+ cssVar: buildCssVar(configPrefix, varPrefix, safeName),
131
+ modifiers: token.modifiers
132
+ });
133
+ }
134
+ return out;
135
+ }
136
+ /**
137
+ * Resolve a style prop against the given resolved UDS config. Unknown group
138
+ * refs are silently dropped from `tokens` (callers can detect this by
139
+ * comparing input refs vs. resolved tokens if they need to surface a
140
+ * config-build warning).
141
+ *
142
+ * @param propName - The JSX prop name (the map key from `registerStyleProps`).
143
+ */
144
+ function resolveStyleProp(propName, styleProp, config) {
145
+ const { cssProperty, classPrefix, values, arbitrary, metadata } = styleProp;
146
+ const configPrefix = config.prefix;
147
+ const tokens = [];
148
+ const literals = [];
149
+ for (const entry of values ?? []) {
150
+ if (typeof entry === "string") {
151
+ const parsed = parseGroupRef(entry);
152
+ if (!parsed) {
153
+ literals.push(entry);
154
+ continue;
155
+ }
156
+ const group = findGroup(config.atomic, parsed.group);
157
+ if (!group) continue;
158
+ if (parsed.key !== void 0) {
159
+ const token = group.tokens.find((t) => t.name === parsed.key);
160
+ if (!token) continue;
161
+ const valueType = detectTokenValueType(token, group);
162
+ if (!isTokenAcceptedByProperty(cssProperty, valueType, token.value)) continue;
163
+ const safeName = safeTokenName(token.name);
164
+ const varPrefix = group.cssPrefix ?? group.namespace ?? parsed.group;
165
+ tokens.push({
166
+ name: token.name,
167
+ value: token.value,
168
+ valueType,
169
+ group: group.namespace ?? group.cssPrefix ?? parsed.group,
170
+ qualifiedName: token.name,
171
+ safeName,
172
+ cssVar: buildCssVar(configPrefix, varPrefix, safeName),
173
+ modifiers: token.modifiers
174
+ });
175
+ } else tokens.push(...resolveGroupTokens(group, cssProperty, configPrefix));
176
+ continue;
177
+ }
178
+ if (isNamespacedRef(entry)) {
179
+ const parsed = parseGroupRef(entry.ref);
180
+ if (!parsed || parsed.key !== void 0) continue;
181
+ const group = findGroup(config.atomic, parsed.group);
182
+ if (!group) continue;
183
+ tokens.push(...resolveGroupTokens(group, cssProperty, configPrefix, entry.namespace));
184
+ }
185
+ }
186
+ return {
187
+ propName,
188
+ cssProperty,
189
+ classPrefix,
190
+ tokens,
191
+ literals,
192
+ arbitrary,
193
+ metadata: metadata ?? {}
194
+ };
195
+ }
196
+ //#endregion
197
+ export { resolveStyleProp };
@@ -1,8 +1,8 @@
1
- import { ArbitraryTokenGroup, AtomicToken, ExampleDef, ModeGroup, ModifierDef, MotionPresetsDef, UdsConfig } from "./createConfig.js";
1
+ import { VarsConfig } from "./types.js";
2
+ import { AtomicToken, ExampleDef, ModeGroup, ModifierDef, MotionPresetsDef, UdsConfig } from "./createConfig.js";
2
3
  import { CompositeStylesConfig } from "@uds/types";
3
4
 
4
5
  //#region ../config/dist/serialize.d.ts
5
- //#region src/serialize.d.ts
6
6
  type ModifierNameShape = `_${string}`;
7
7
  type TokenRef = {
8
8
  $ref: string;
@@ -10,6 +10,14 @@ type TokenRef = {
10
10
  interface SerializedConfig {
11
11
  modes: ModeGroup[];
12
12
  modifiers?: ModifierDef[];
13
+ /**
14
+ * Verbatim `defineVars` input. Authoritative source for CSS variable
15
+ * declarations downstream. `atomic` carries derived (property × token)
16
+ * data for utility-class generation; `vars` carries the original
17
+ * namespace-keyed input. New code should rely on `vars`; `atomic` is
18
+ * still emitted for legacy consumers.
19
+ */
20
+ vars?: VarsConfig;
13
21
  atomic: AtomicToken<ModifierNameShape>[];
14
22
  compositeStyles?: CompositeStylesConfig;
15
23
  /**
@@ -18,7 +26,6 @@ interface SerializedConfig {
18
26
  * until they're rewritten. New code should populate `compositeStyles`.
19
27
  */
20
28
  macros?: Record<string, Record<string, Record<string, unknown>>>;
21
- arbitraryTokens?: ArbitraryTokenGroup[];
22
29
  motion?: MotionPresetsDef;
23
30
  components: SerializedComponentsDef;
24
31
  globalStyles?: Record<string, Record<string, SerializedValue>>;
@@ -60,6 +67,6 @@ declare function serializeConfig(config: UdsConfig): SerializedConfig;
60
67
  * Resolves `$ref` markers back to `var()` strings using the atomic token
61
68
  * definitions, then reconstructs the builder chain.
62
69
  */
63
- declare function deserializeConfig(data: SerializedConfig): UdsConfig; //#endregion
70
+ declare function deserializeConfig(data: SerializedConfig): UdsConfig;
64
71
  //#endregion
65
72
  export { SerializedConfig, TokenRef, buildReverseMap, deserializeConfig, serializeConfig };
@@ -1,6 +1,6 @@
1
1
  import { safeTokenName } from "../../utils/dist/string-utils/cssVar.js";
2
2
  import "../../utils/dist/index.js";
3
- import { getConfigurablePropMapping } from "../../core/dist/propMappings.js";
3
+ import { getConfigurablePropMapping } from "../../core/dist/configurable-prop-helpers.js";
4
4
  import "../../core/dist/index.js";
5
5
  import { buildTokenReference, createConfigBuilder, resolveConfig } from "./createConfig.js";
6
6
  //#region ../config/dist/serialize.js
@@ -107,9 +107,9 @@ function serializeConfig(config) {
107
107
  return {
108
108
  modes: data.modes,
109
109
  modifiers: data.modifiers.length > 0 ? data.modifiers : void 0,
110
+ vars: data.vars && Object.keys(data.vars).length > 0 ? data.vars : void 0,
110
111
  atomic: data.atomic,
111
112
  compositeStyles: Object.keys(data.compositeStyles).length > 0 ? data.compositeStyles : void 0,
112
- arbitraryTokens: data.arbitraryTokens && data.arbitraryTokens.length > 0 ? data.arbitraryTokens : void 0,
113
113
  motion: Object.keys(data.motion).length > 0 ? data.motion : void 0,
114
114
  components,
115
115
  globalStyles: Object.keys(globalStyles).length > 0 ? globalStyles : void 0,
@@ -150,13 +150,13 @@ function deserializeConfig(data) {
150
150
  let config = createConfigBuilder({
151
151
  modes: data.modes,
152
152
  modifiers: data.modifiers ?? [],
153
+ vars: data.vars,
153
154
  atomic: data.atomic,
154
155
  compositeStyles: data.compositeStyles ?? upgradeLegacyMacros(data.macros),
155
156
  motion: data.motion ?? {},
156
157
  components,
157
158
  preflight: data.preflight,
158
159
  prefix: data.prefix ?? "uds",
159
- arbitraryTokens: data.arbitraryTokens,
160
160
  remotion: void 0,
161
161
  globalStyles: {},
162
162
  presetTokenNames: data.presetTokenNames
@@ -0,0 +1,60 @@
1
+ //#region ../config/dist/types/css-values.d.ts
2
+ /**
3
+ * CSS value-type primitives — building blocks used by {@link CssPropertyValues}
4
+ * in `./css-properties` and by `defineStyleProp` to constrain authored values.
5
+ *
6
+ * Each entry in {@link CssValue} corresponds to a CSS value type name from the
7
+ * CSS specs (length, percentage, color, time, etc.). The CSS-wide keywords
8
+ * (`inherit`, `initial`, `unset`, `revert`) are bundled into {@link ColorKeyword}
9
+ * because color is the most common channel for them; properties that accept
10
+ * those keywords on non-color value types are expected to list them locally.
11
+ *
12
+ * Note: named colors (`red`, `blue`, etc.) are intentionally NOT in the union —
13
+ * authors should use a token, a hex code, or a function form (`rgb(...)`, etc.).
14
+ */
15
+ /** CSS-wide keywords accepted on color-valued properties. */
16
+ type ColorKeyword = 'transparent' | 'currentColor' | 'inherit' | 'initial' | 'unset' | 'revert';
17
+ type HexColor = `#${string}`;
18
+ type RgbColor = `rgb(${string})` | `rgba(${string})`;
19
+ type HslColor = `hsl(${string})` | `hsla(${string})`;
20
+ type ColorFn = `color(${string})` | `lab(${string})` | `lch(${string})` | `oklab(${string})` | `oklch(${string})`;
21
+ type CssColor = HexColor | RgbColor | HslColor | ColorFn | ColorKeyword;
22
+ type CssLength = `${number}px` | `${number}rem` | `${number}em` | `${number}ch` | `${number}ex` | `${number}vh` | `${number}vw` | `${number}vmin` | `${number}vmax` | 0;
23
+ type CssPercentage = `${number}%`;
24
+ type CssAngle = `${number}deg` | `${number}rad` | `${number}grad` | `${number}turn`;
25
+ type CssTime = `${number}ms` | `${number}s`;
26
+ type CssRatio = `${number}/${number}`;
27
+ /**
28
+ * Registry of CSS value types, keyed by their spec-defined names.
29
+ *
30
+ * Used in two places:
31
+ * 1. As the source of truth for what shapes count as e.g. a "length" or a
32
+ * "color" when validating token values and `defineStyleProp` `arbitrary`
33
+ * specs.
34
+ * 2. By {@link import('./css-properties').CssPropertyValues}, which composes
35
+ * these entries (plus per-property keywords) into the union accepted by
36
+ * each CSS property.
37
+ */
38
+ type CssValue = {
39
+ color: CssColor;
40
+ length: CssLength;
41
+ percentage: CssPercentage;
42
+ 'length-percentage': CssLength | CssPercentage;
43
+ number: number;
44
+ integer: number;
45
+ angle: CssAngle;
46
+ time: CssTime;
47
+ ratio: CssRatio;
48
+ image: string;
49
+ url: `url(${string})`;
50
+ 'font-weight': number | 'normal' | 'bold' | 'lighter' | 'bolder';
51
+ 'font-family': string;
52
+ 'easing-function': 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'step-start' | 'step-end' | `cubic-bezier(${string})` | `steps(${string})`;
53
+ shadow: string;
54
+ gradient: string;
55
+ ident: string;
56
+ string: string;
57
+ };
58
+ type CssValueTypeName = keyof CssValue;
59
+ //#endregion
60
+ export { ColorFn, ColorKeyword, CssAngle, CssColor, CssLength, CssPercentage, CssRatio, CssTime, CssValue, CssValueTypeName, HexColor, HslColor, RgbColor };
@@ -1,5 +1,4 @@
1
1
  //#region ../config/dist/types.d.ts
2
- //#region src/types.d.ts
3
2
  /**
4
3
  * Scalar DTCG-aligned token types. Composite types (shadow, gradient,
5
4
  * typography, border, transition, cubicBezier) are intentionally deferred
@@ -60,6 +59,6 @@ type VarGroupDef<M extends `_${string}` = `_${string}`> = {
60
59
  * spacing: { $type: 'dimension', 1: { value: '0.25rem' }, 2: { value: '0.5rem' } },
61
60
  * }
62
61
  */
63
- type VarsConfig<M extends `_${string}` = `_${string}`> = Record<string, VarGroupDef<M>>; //#endregion
62
+ type VarsConfig<M extends `_${string}` = `_${string}`> = Record<string, VarGroupDef<M>>;
64
63
  //#endregion
65
64
  export { TokenType, VarGroupDef, VarTokenDef, VarsConfig };