@yahoo/uds-v5-wip 1.61.0 → 1.62.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 (117) hide show
  1. package/dist/config/dist/AssetGroup.d.ts +75 -0
  2. package/dist/config/dist/AssetGroup.js +114 -0
  3. package/dist/config/dist/Component.d.ts +309 -0
  4. package/dist/config/dist/Component.js +897 -0
  5. package/dist/config/dist/ComponentGroup.d.ts +21 -0
  6. package/dist/config/dist/ComponentGroup.js +46 -0
  7. package/dist/config/dist/CompositeStyle.d.ts +28 -0
  8. package/dist/config/dist/CompositeStyle.js +52 -0
  9. package/dist/config/dist/Config.d.ts +422 -0
  10. package/dist/config/dist/Config.js +1426 -0
  11. package/dist/config/dist/Mode.d.ts +42 -0
  12. package/dist/config/dist/Mode.js +81 -0
  13. package/dist/config/dist/Modifier.d.ts +52 -0
  14. package/dist/config/dist/Modifier.js +97 -0
  15. package/dist/config/dist/MotionDef.d.ts +50 -0
  16. package/dist/config/dist/MotionDef.js +97 -0
  17. package/dist/config/dist/Props.d.ts +235 -126
  18. package/dist/config/dist/Provider.d.ts +21 -0
  19. package/dist/config/dist/Provider.js +14 -0
  20. package/dist/config/dist/StyleProp.d.ts +113 -0
  21. package/dist/config/dist/StyleProp.js +197 -0
  22. package/dist/config/dist/Token.d.ts +56 -0
  23. package/dist/config/dist/Token.js +112 -0
  24. package/dist/config/dist/TokenGroup.d.ts +33 -0
  25. package/dist/config/dist/TokenGroup.js +68 -0
  26. package/dist/config/dist/asset-kind.d.ts +56 -0
  27. package/dist/config/dist/asset-kind.js +29 -0
  28. package/dist/config/dist/brands.d.ts +31 -0
  29. package/dist/config/dist/brands.js +20 -0
  30. package/dist/config/dist/captureCallerPath.d.ts +49 -0
  31. package/dist/config/dist/captureCallerPath.js +95 -0
  32. package/dist/config/dist/colorExpressions.d.ts +132 -0
  33. package/dist/config/dist/colorExpressions.js +148 -0
  34. package/dist/config/dist/defineAssetGroup.d.ts +158 -0
  35. package/dist/config/dist/defineAssetGroup.js +263 -0
  36. package/dist/config/dist/defineProvider.d.ts +30 -0
  37. package/dist/config/dist/defineProvider.js +60 -0
  38. package/dist/config/dist/element-marker.d.ts +55 -0
  39. package/dist/config/dist/element-marker.js +113 -0
  40. package/dist/config/dist/entity-utils.d.ts +27 -0
  41. package/dist/config/dist/entity-utils.js +105 -0
  42. package/dist/config/dist/factories.d.ts +707 -0
  43. package/dist/config/dist/factories.js +393 -0
  44. package/dist/config/dist/foreign-component-name.js +42 -0
  45. package/dist/config/dist/index.d.ts +30 -21
  46. package/dist/config/dist/index.js +26 -14
  47. package/dist/config/dist/interpolate.d.ts +21 -0
  48. package/dist/config/dist/interpolate.js +10 -0
  49. package/dist/config/dist/markers.d.ts +218 -0
  50. package/dist/config/dist/markers.js +67 -0
  51. package/dist/config/dist/refs.d.ts +143 -69
  52. package/dist/config/dist/refs.js +95 -113
  53. package/dist/config/dist/token-override-rows.d.ts +67 -0
  54. package/dist/config/dist/token-override-rows.js +223 -0
  55. package/dist/config/dist/tokenValueType.js +138 -0
  56. package/dist/config/dist/types/css-properties.d.ts +132 -122
  57. package/dist/config/dist/types/css-property-keywords.d.ts +157 -0
  58. package/dist/config/dist/types/css-property-keywords.js +616 -0
  59. package/dist/config/dist/types/css-values.d.ts +18 -16
  60. package/dist/config/dist/types.d.ts +688 -66
  61. package/dist/config/dist/units.d.ts +15 -0
  62. package/dist/config/dist/units.js +16 -0
  63. package/dist/config.d.ts +31 -22
  64. package/dist/config.js +28 -16
  65. package/dist/loader/dist/loader/artifacts.js +26 -9
  66. package/dist/loader/dist/loader.d.ts +11 -23
  67. package/dist/loader/dist/loader.js +54 -99
  68. package/dist/loader/dist/next.js +3 -3
  69. package/dist/loader/dist/transform-runner.js +1 -8
  70. package/dist/loader/dist/unplugin.d.ts +2 -2
  71. package/dist/loader/dist/unplugin.js +2 -2
  72. package/dist/tsconfig.tsbuildinfo +1 -1
  73. package/dist/utils/dist/index.js +1 -0
  74. package/dist/utils/dist/motion-utils/resolveMotionState.d.ts +35 -0
  75. package/dist/utils/dist/motion-utils/resolveMotionState.js +33 -0
  76. package/dist/utils/dist/string-utils/componentClassName.d.ts +41 -8
  77. package/dist/utils/dist/string-utils/componentClassName.js +48 -11
  78. package/dist/utils.d.ts +3 -2
  79. package/dist/utils.js +3 -2
  80. package/package.json +3 -3
  81. package/dist/codegen/dist/loader/getLoaderArtifacts.js +0 -2
  82. package/dist/config/dist/bindRender.d.ts +0 -16
  83. package/dist/config/dist/bindRender.js +0 -310
  84. package/dist/config/dist/className.d.ts +0 -54
  85. package/dist/config/dist/className.js +0 -77
  86. package/dist/config/dist/component-config.d.ts +0 -862
  87. package/dist/config/dist/component-config.js +0 -163
  88. package/dist/config/dist/component-refs.d.ts +0 -121
  89. package/dist/config/dist/createConfig.d.ts +0 -456
  90. package/dist/config/dist/createConfig.js +0 -503
  91. package/dist/config/dist/createStyler.d.ts +0 -35
  92. package/dist/config/dist/createStyler.js +0 -93
  93. package/dist/config/dist/defineComponent.d.ts +0 -317
  94. package/dist/config/dist/defineComponent.js +0 -264
  95. package/dist/config/dist/defineCompositeStyle.d.ts +0 -93
  96. package/dist/config/dist/defineCompositeStyle.js +0 -18
  97. package/dist/config/dist/defineMotionConfig.d.ts +0 -152
  98. package/dist/config/dist/definePreview.d.ts +0 -45
  99. package/dist/config/dist/definePreview.js +0 -35
  100. package/dist/config/dist/defineStyleProp.d.ts +0 -289
  101. package/dist/config/dist/defineStyleProp.js +0 -61
  102. package/dist/config/dist/merge-utils.js +0 -51
  103. package/dist/config/dist/propertyAcceptedTypes.d.ts +0 -19
  104. package/dist/config/dist/propertyAcceptedTypes.js +0 -220
  105. package/dist/config/dist/resolveCompoundProps.d.ts +0 -65
  106. package/dist/config/dist/resolveCompoundProps.js +0 -120
  107. package/dist/config/dist/resolveStyleProp.d.ts +0 -157
  108. package/dist/config/dist/resolveStyleProp.js +0 -260
  109. package/dist/config/dist/runtime-registry.js +0 -37
  110. package/dist/config/dist/serialize.d.ts +0 -47
  111. package/dist/config/dist/serialize.js +0 -111
  112. package/dist/config/dist/sniffTokenType.d.ts +0 -7
  113. package/dist/config/dist/sniffTokenType.js +0 -67
  114. package/dist/config/dist/style-prop-runtime.d.ts +0 -75
  115. package/dist/config/dist/style-prop-runtime.js +0 -390
  116. package/dist/loader/dist/loader/internal-meta.js +0 -59
  117. package/dist/loader/dist/loader/lower-new-api-primitive.js +0 -252
@@ -1,390 +0,0 @@
1
- //#region ../config/dist/style-prop-runtime.js
2
- function resolveTokenMarker(marker, configPrefix) {
3
- const ref = marker.ref;
4
- const slashIdx = ref.indexOf("/");
5
- if (slashIdx <= 0 || slashIdx >= ref.length - 1) return ref;
6
- const ns = ref.slice(0, slashIdx);
7
- const name = ref.slice(slashIdx + 1);
8
- const cssPrefix = ns.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
9
- const cssName = name.replace(/\./g, "_").replace(/\//g, "-");
10
- return `var(${configPrefix ? `--${configPrefix}-${cssPrefix}-${cssName}` : `--${cssPrefix}-${cssName}`})`;
11
- }
12
- const BUILT_IN_PSEUDO = {
13
- _after: "after:",
14
- _hover: "hover:",
15
- _focus: "focus:",
16
- _focusWithin: "focus-within:",
17
- _focusVisible: "focus-visible:",
18
- _active: "active:",
19
- _visited: "visited:",
20
- _target: "target:",
21
- _first: "first:",
22
- _last: "last:",
23
- _only: "only:",
24
- _odd: "odd:",
25
- _even: "even:",
26
- _firstOfType: "first-of-type:",
27
- _lastOfType: "last-of-type:",
28
- _onlyOfType: "only-of-type:",
29
- _empty: "empty:",
30
- _disabled: "disabled:",
31
- _enabled: "enabled:",
32
- _checked: "checked:",
33
- _indeterminate: "indeterminate:",
34
- _default: "default:",
35
- _required: "required:",
36
- _valid: "valid:",
37
- _invalid: "invalid:",
38
- _inRange: "in-range:",
39
- _outOfRange: "out-of-range:",
40
- _placeholderShown: "placeholder-shown:",
41
- _autofill: "autofill:",
42
- _readonly: "read-only:",
43
- _file: "file:",
44
- _selection: "selection:",
45
- _backdrop: "backdrop:",
46
- _motionReduce: "motion-reduce:",
47
- _motionSafe: "motion-safe:",
48
- _contrastMore: "contrast-more:",
49
- _contrastLess: "contrast-less:",
50
- _forcedColors: "forced-colors:",
51
- _placeholder: "placeholder:",
52
- _ariaBusy: "aria-busy:",
53
- _ariaChecked: "aria-checked:",
54
- _ariaHidden: "aria-hidden:",
55
- _ariaPressed: "aria-pressed:",
56
- _ariaReadonly: "aria-readonly:",
57
- _ariaRequired: "aria-required:",
58
- _ariaSelected: "aria-selected:",
59
- _ariaCurrent: "aria-[current]:",
60
- _ariaDisabled: "aria-disabled:",
61
- _ariaExpanded: "aria-expanded:",
62
- _dataDisabled: "data-[disabled=true]:",
63
- _dataStateOpen: "data-[state=open]:",
64
- _dataStateClosed: "data-[state=closed]:",
65
- _startingStyle: "starting-style:",
66
- _scrollbar: "*::-webkit-scrollbar:",
67
- _scrollbarThumb: "*::-webkit-scrollbar-thumb:",
68
- _scrollbarTrack: "*::-webkit-scrollbar-track:"
69
- };
70
- /** Pseudo-suffix derived from a built-in tailwind prefix (`hover:` → `:hover`).
71
- * Returns null for prefixes that aren't simple pseudo-classes (data-, aria-,
72
- * pseudo-element ::, at-rules). */
73
- function pseudoSuffixForBuiltIn(prefix) {
74
- if (prefix.includes("::") || prefix.startsWith("*")) return null;
75
- if (prefix.startsWith("data-[") || prefix.startsWith("aria-")) return null;
76
- return `:${prefix.slice(0, -1)}`;
77
- }
78
- function kebabCase(s) {
79
- return s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
80
- }
81
- function buildStylePropRuntime(config) {
82
- return {
83
- styleProps: buildStylePropsMap(config.resolvedStyleProps ?? []),
84
- modifiers: buildModifiersMap(config),
85
- composites: buildCompositesMap(config)
86
- };
87
- }
88
- function buildStylePropsMap(resolved) {
89
- const out = {};
90
- for (const entry of resolved) {
91
- if (!entry.classPrefix && !entry.pairedWith) continue;
92
- const cssProperty = Array.isArray(entry.cssProperty) ? entry.cssProperty[0] : entry.cssProperty;
93
- if (typeof cssProperty !== "string" || cssProperty.length === 0) continue;
94
- const firstToken = entry.tokens[0];
95
- let varPrefix;
96
- if (firstToken?.cssVar) {
97
- const stripped = firstToken.cssVar.startsWith("--") ? firstToken.cssVar.slice(2) : firstToken.cssVar;
98
- const suffix = `-${firstToken.safeName}`;
99
- varPrefix = stripped.endsWith(suffix) ? stripped.slice(0, -suffix.length) : stripped;
100
- }
101
- const literalAliases = {};
102
- let hasAliases = false;
103
- if (entry.literalAliases) {
104
- for (const [key, value] of Object.entries(entry.literalAliases)) if (typeof value === "string") {
105
- literalAliases[key] = value;
106
- hasAliases = true;
107
- }
108
- }
109
- const styleEntry = {
110
- classPrefix: entry.classPrefix,
111
- cssProperty,
112
- ...varPrefix ? { varPrefix } : {},
113
- ...entry.pairedWith ? { pairedWith: entry.pairedWith } : {},
114
- ...entry.separator ? { separator: entry.separator } : {},
115
- ...hasAliases ? { literalAliases } : {}
116
- };
117
- out[entry.propName] = styleEntry;
118
- }
119
- return out;
120
- }
121
- function buildModifiersMap(config) {
122
- const out = {};
123
- for (const [propName, prefix] of Object.entries(BUILT_IN_PSEUDO)) {
124
- const suffix = pseudoSuffixForBuiltIn(prefix);
125
- out[propName] = suffix ? {
126
- tailwindPrefix: prefix,
127
- kind: "pseudo",
128
- selector: suffix
129
- } : {
130
- tailwindPrefix: prefix,
131
- kind: "ancestor",
132
- selector: complexBuiltInSelector(prefix)
133
- };
134
- }
135
- for (const group of config.modes ?? []) for (const option of group.options) {
136
- if (option.default) continue;
137
- const propName = option.modifier;
138
- const tailwindPrefix = `${propName.slice(1)}:`;
139
- if (option.css) out[propName] = {
140
- tailwindPrefix,
141
- kind: "ancestor",
142
- selector: option.css
143
- };
144
- else if (option.media) out[propName] = {
145
- tailwindPrefix,
146
- kind: "at-rule",
147
- selector: `@media ${option.media}`
148
- };
149
- }
150
- for (const def of config.modifiers ?? []) {
151
- const propName = def.modifier;
152
- out[propName] = {
153
- tailwindPrefix: `${propName.slice(1)}:`,
154
- kind: def.selector.trimStart().startsWith("@") ? "at-rule" : "ancestor",
155
- selector: def.selector
156
- };
157
- }
158
- return out;
159
- }
160
- /** Convert a complex built-in tailwind prefix to a CSS selector fragment. */
161
- function complexBuiltInSelector(prefix) {
162
- const dataMatch = prefix.match(/^data-\[([^=]+)=([^\]]+)\]:$/);
163
- if (dataMatch) return `[data-${dataMatch[1]}="${dataMatch[2]}"]`;
164
- const ariaMatch = prefix.match(/^aria-([a-z-]+):$/);
165
- if (ariaMatch) return `[aria-${ariaMatch[1]}="true"]`;
166
- const ariaBracket = prefix.match(/^aria-\[([^\]]+)\]:$/);
167
- if (ariaBracket) return `[aria-${ariaBracket[1]}]`;
168
- if (prefix.startsWith("*")) return prefix.slice(1, -1);
169
- return prefix.slice(0, -1);
170
- }
171
- function buildCompositesMap(config) {
172
- const out = {};
173
- const composites = config.compositeStyles;
174
- if (!composites) return out;
175
- for (const [groupName, group] of Object.entries(composites)) {
176
- const styles = group.styles;
177
- if (!styles) continue;
178
- out[groupName] = { ...styles };
179
- }
180
- return out;
181
- }
182
- /** Detect arbitrary `[value]` syntax. */
183
- const ARBITRARY_RE = /^\[(.+)\]$/;
184
- function processStyleProps(props, runtime, opts = {}) {
185
- const classes = [];
186
- const dynamicRules = [];
187
- let effectiveProps = props;
188
- let markerClasses;
189
- let compositeMarkers;
190
- const expansion = expandComposites(props, runtime.composites);
191
- if (expansion) {
192
- effectiveProps = expansion.expanded;
193
- markerClasses = expansion.markers;
194
- compositeMarkers = expansion.compositeMarkers;
195
- }
196
- if (markerClasses) for (const marker of markerClasses) classes.push(applyModifierPrefix(marker, opts.modifier));
197
- if (compositeMarkers && compositeMarkers.length > 0) for (const { group, value } of compositeMarkers) {
198
- const containerRule = buildCompositeContainerRule(group, value, opts.modifier);
199
- if (containerRule) dynamicRules.push(containerRule);
200
- const propRule = buildCompositeMarkerRule(group, value, opts.modifier, runtime.modifiers);
201
- if (propRule) dynamicRules.push(propRule);
202
- }
203
- for (const key in effectiveProps) {
204
- if (!Object.hasOwn(effectiveProps, key)) continue;
205
- const value = effectiveProps[key];
206
- if (value === void 0 || value === null || value === false) continue;
207
- if (key.startsWith("_")) {
208
- const modifier = runtime.modifiers[key];
209
- if (!modifier || !isStyleObject(value)) continue;
210
- const inner = processStyleProps(value, runtime, { modifier: opts.modifier ? `${opts.modifier}${modifier.tailwindPrefix}` : modifier.tailwindPrefix });
211
- if (inner.className) classes.push(inner.className);
212
- dynamicRules.push(...inner.dynamicRules);
213
- continue;
214
- }
215
- const entry = runtime.styleProps[key];
216
- if (!entry) continue;
217
- if (entry.pairedWith) continue;
218
- const opacityProp = findOpacitySibling(key, runtime.styleProps);
219
- const opacityValue = opacityProp !== void 0 ? effectiveProps[opacityProp] : void 0;
220
- if (typeof value === "string" && ARBITRARY_RE.test(value)) {
221
- const fullClass = applyModifierPrefix(buildArbitraryClass(entry, value, opacityValue), opts.modifier);
222
- classes.push(fullClass);
223
- const arbitraryRule = buildArbitraryRule(fullClass, entry, value, opacityValue, opts.modifier, runtime.modifiers);
224
- if (arbitraryRule) dynamicRules.push(arbitraryRule);
225
- continue;
226
- }
227
- if (value === true) {
228
- classes.push(applyModifierPrefix(entry.classPrefix, opts.modifier));
229
- continue;
230
- }
231
- let effectiveValue = String(value);
232
- if (entry.literalAliases && effectiveValue in entry.literalAliases) {
233
- const aliased = entry.literalAliases[effectiveValue];
234
- if (aliased !== void 0) effectiveValue = aliased;
235
- }
236
- if (opacityValue !== void 0 && opacityProp !== void 0) {
237
- const sep = runtime.styleProps[opacityProp]?.separator ?? entry.separator ?? "_";
238
- const cls = applyModifierPrefix(buildTokenClass(entry, `${effectiveValue}${sep}${opacityValue}`), opts.modifier);
239
- classes.push(cls);
240
- if (entry.varPrefix) {
241
- const rule = buildOpacityMixRule(cls, entry, effectiveValue, String(opacityValue), opts.modifier, runtime.modifiers);
242
- if (rule) dynamicRules.push(rule);
243
- }
244
- continue;
245
- }
246
- classes.push(applyModifierPrefix(buildTokenClass(entry, effectiveValue), opts.modifier));
247
- }
248
- return {
249
- className: classes.filter(Boolean).join(" "),
250
- dynamicRules
251
- };
252
- }
253
- function isStyleObject(value) {
254
- return typeof value === "object" && value !== null && !Array.isArray(value);
255
- }
256
- function findOpacitySibling(parentProp, styleProps) {
257
- for (const candidateName in styleProps) if (styleProps[candidateName]?.pairedWith === parentProp) return candidateName;
258
- }
259
- /** Build a token-value class, e.g. `bg-brand` or `bg-elevation-1`. Applies the
260
- * same safe-token-name normalization codegen uses (`.` → `_`, `/` → `-`). */
261
- function buildTokenClass(entry, value) {
262
- if (entry.classPrefix === "") return value;
263
- if (value === "") return entry.classPrefix;
264
- const safe = value.replace(/\./g, "_").replace(/\//g, "-");
265
- return entry.classPrefix === value ? safe : `${entry.classPrefix}-${safe}`;
266
- }
267
- /** Build the arbitrary-value class, e.g. `bg-[#ef4444]` or `bg-[#ef4444]/60`. */
268
- function buildArbitraryClass(entry, value, opacityValue) {
269
- const base = `${entry.classPrefix}-${value}`;
270
- if (opacityValue === void 0 || opacityValue === null) return base;
271
- return `${base}/${opacityValue}`;
272
- }
273
- function applyModifierPrefix(cls, modifier) {
274
- return modifier ? `${modifier}${cls}` : cls;
275
- }
276
- /** Build the runtime CSS rule for an arbitrary-value class. */
277
- function buildArbitraryRule(fullClass, entry, rawValue, opacityValue, modifier, modifiers) {
278
- const match = rawValue.match(ARBITRARY_RE);
279
- if (!match) return null;
280
- const inside = match[1];
281
- let cssValue = inside;
282
- if (opacityValue !== void 0 && opacityValue !== null) cssValue = `color-mix(in srgb, ${inside} ${opacityValue}%, transparent)`;
283
- return buildDynamicRule(fullClass, entry.cssProperty, cssValue, modifier, modifiers);
284
- }
285
- /** Build the runtime CSS rule for a color/opacity token-pair fallback. */
286
- function buildOpacityMixRule(fullClass, entry, baseValue, opacityValue, modifier, modifiers) {
287
- if (!entry.varPrefix) return null;
288
- const cssValue = `color-mix(in srgb, var(${`--${entry.varPrefix}-${baseValue.replace(/[./]/g, "_")}`}) ${opacityValue}%, transparent)`;
289
- return buildDynamicRule(fullClass, entry.cssProperty, cssValue, modifier, modifiers);
290
- }
291
- /** Assemble a {@link DynamicRule} from a class + value + accumulated modifier prefix. */
292
- function buildDynamicRule(fullClass, cssProperty, cssValue, modifier, modifiers) {
293
- const cssProp = kebabCase(cssProperty);
294
- let ancestorParts = "";
295
- let pseudoParts = "";
296
- let atRule;
297
- if (modifier) {
298
- const parts = modifier.split(":").filter(Boolean).map((p) => `${p}:`);
299
- for (const part of parts) {
300
- const resolved = modifiers[`_${part.slice(0, -1)}`];
301
- if (!resolved) continue;
302
- if (resolved.kind === "pseudo") pseudoParts += resolved.selector;
303
- else if (resolved.kind === "ancestor") ancestorParts += `${resolved.selector} `;
304
- else if (resolved.kind === "at-rule") atRule = resolved.selector;
305
- }
306
- }
307
- const escaped = escapeClassName(fullClass);
308
- const selector = `${ancestorParts}.${escaped}${pseudoParts}`;
309
- return atRule ? {
310
- className: fullClass,
311
- selector,
312
- cssProperty: cssProp,
313
- cssValue,
314
- atRule
315
- } : {
316
- className: fullClass,
317
- selector,
318
- cssProperty: cssProp,
319
- cssValue
320
- };
321
- }
322
- /** CSS class-name escape — matches `CSS.escape` semantics enough for runtime use. */
323
- function escapeClassName(name) {
324
- return name.replace(/[^a-zA-Z0-9_-]/g, (c) => `\\${c}`);
325
- }
326
- /**
327
- * Build a dynamic CSS rule that sets `--uds-composite-<group>: <value>` on
328
- * the host element. The host selector is the composite marker class (which
329
- * also gets pushed onto the className), so the rule reads:
330
- *
331
- * - Unconditional: `.elevation-1 { --uds-composite-elevation: 1 }`
332
- * - Modifier-conditional: `.hover\:elevation-1:hover { ... }`
333
- *
334
- * Descendants react via `@container style(--uds-composite-elevation: 1) &`
335
- * — see `buildCompositeStylesReference` and the auto-registered
336
- * `_on<Group><Value>` modifiers for the descendant selector form.
337
- */
338
- function buildCompositeMarkerRule(group, value, modifier, modifiers) {
339
- const groupSafe = group.replace(/[./]/g, "-");
340
- const valueSafe = value.replace(/[./]/g, "-");
341
- return buildDynamicRule(applyModifierPrefix(`${groupSafe}-${valueSafe}`, modifier), `--uds-composite-${groupSafe}`, valueSafe, modifier, modifiers);
342
- }
343
- /**
344
- * Build an unconditional `container-type: style` rule targeting the
345
- * composite marker class. Required for descendant `@container style()`
346
- * queries to match against this host — without it the queries have no
347
- * container to anchor on. The rule is unconditional (no modifier scope)
348
- * because we want descendants to be able to query the host's state at
349
- * any time, including under modifier branches.
350
- */
351
- function buildCompositeContainerRule(group, value, modifier) {
352
- const fullClass = applyModifierPrefix(`${group.replace(/[./]/g, "-")}-${value.replace(/[./]/g, "-")}`, modifier);
353
- return {
354
- className: fullClass,
355
- selector: `.${escapeClassName(fullClass)}`,
356
- cssProperty: "container-type",
357
- cssValue: "style"
358
- };
359
- }
360
- function expandComposites(props, composites) {
361
- let result = null;
362
- const markers = [];
363
- const compositeMarkers = [];
364
- for (const groupName in composites) {
365
- if (!Object.hasOwn(composites, groupName)) continue;
366
- const propValue = props[groupName];
367
- if (propValue === void 0 || propValue === null) continue;
368
- const variants = composites[groupName];
369
- if (!variants) continue;
370
- const variantStyles = variants[String(propValue)];
371
- if (!variantStyles) continue;
372
- if (!result) result = { ...props };
373
- delete result[groupName];
374
- compositeMarkers.push({
375
- group: groupName,
376
- value: String(propValue)
377
- });
378
- for (const [propName, value] of Object.entries(variantStyles)) if (value !== null && typeof value === "object" && value.__kind === "token" && typeof value.ref === "string") result[propName] = resolveTokenMarker(value, void 0);
379
- else result[propName] = value;
380
- markers.push(`${groupName}-${String(propValue).replace(/[./]/g, "-")}`);
381
- }
382
- if (!result) return null;
383
- return {
384
- expanded: result,
385
- markers,
386
- compositeMarkers
387
- };
388
- }
389
- //#endregion
390
- export { BUILT_IN_PSEUDO, buildStylePropRuntime, processStyleProps };
@@ -1,59 +0,0 @@
1
- import path from "node:path";
2
- import * as t from "@babel/types";
3
- //#region ../loader/dist/loader/internal-meta.js
4
- function hashToNumericId(value) {
5
- let hash = 2166136261;
6
- for (let i = 0; i < value.length; i += 1) {
7
- hash ^= value.charCodeAt(i);
8
- hash = Math.imul(hash, 16777619);
9
- }
10
- return String(hash >>> 0);
11
- }
12
- function buildUdsId(meta) {
13
- return hashToNumericId([
14
- meta.componentName ?? "",
15
- meta.slotName ?? "",
16
- meta.sourceRef
17
- ].join("|"));
18
- }
19
- function buildSourceRef(resourcePath, projectRoot, location) {
20
- return `${path.relative(projectRoot, resourcePath).replaceAll(path.sep, "/")}:${location.line}:${location.column + 1}`;
21
- }
22
- function getJsxStringAttributeValue(nodePath, attrName) {
23
- const attribute = nodePath.node.attributes.find((attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === attrName && attr.value?.type === "StringLiteral");
24
- if (!attribute || attribute.value?.type !== "StringLiteral") return null;
25
- return attribute.value.value;
26
- }
27
- function upsertInternalStringProp(nodePath, propName, value) {
28
- const existing = nodePath.node.attributes.find((attr) => attr.type === "JSXAttribute" && attr.name?.type === "JSXIdentifier" && attr.name.name === propName);
29
- if (existing) {
30
- existing.value = t.stringLiteral(value);
31
- return;
32
- }
33
- nodePath.node.attributes.push(t.jsxAttribute(t.jsxIdentifier(propName), t.stringLiteral(value)));
34
- }
35
- /**
36
- * Inject `data-uds-id` + `data-uds-source` metadata onto a JSX
37
- * opening element so the devtools panel / anatomy view can locate
38
- * each element back to its source position.
39
- */
40
- function injectInternalUdsProps(nodePath, resourcePath, projectRoot, fallback = {}) {
41
- const effectiveResourcePath = resourcePath || nodePath?.hub?.file?.opts?.filename || "";
42
- if (!effectiveResourcePath) return;
43
- const start = nodePath.node.loc?.start;
44
- if (!start?.line || start.column === void 0) return;
45
- const sourceRef = buildSourceRef(effectiveResourcePath, projectRoot, {
46
- line: start.line,
47
- column: start.column
48
- });
49
- const udsId = buildUdsId({
50
- componentName: getJsxStringAttributeValue(nodePath, "data-uds-component") ?? fallback.componentName,
51
- slotName: getJsxStringAttributeValue(nodePath, "data-uds-slot") ?? fallback.slotName,
52
- sourceRef
53
- });
54
- if (!udsId) return;
55
- upsertInternalStringProp(nodePath, "data-uds-id", udsId);
56
- upsertInternalStringProp(nodePath, "data-uds-source", sourceRef);
57
- }
58
- //#endregion
59
- export { injectInternalUdsProps };