@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
@@ -3,6 +3,7 @@ import "./array-utils/closestItem.js";
3
3
  import "./array-utils/removeItem.js";
4
4
  import "./math-utils/clamp.js";
5
5
  import "./motion-utils/interpolate.js";
6
+ import "./motion-utils/resolveMotionState.js";
6
7
  import "./object-utils/entries.js";
7
8
  import "./object-utils/flattenObj.js";
8
9
  import "./object-utils/fromEntries.js";
@@ -0,0 +1,35 @@
1
+ //#region ../utils/dist/motion-utils/resolveMotionState.d.ts
2
+ //#region src/motion-utils/resolveMotionState.d.ts
3
+ /**
4
+ * Runtime helper for codegen's `__rms(stateKeyframe, index)` calls in
5
+ * multi-layer authoring sources that use `interpolate(...)` markers
6
+ * inside per-state motion keyframes. Given a state keyframe object
7
+ * whose values are either scalars or `interpolate({ output, extrapolate })`
8
+ * markers, resolves each marker against `index` and returns a plain
9
+ * keyframe object ready to spread onto `motion.<x>` props.
10
+ *
11
+ * Inlined `InterpolateMarker` shape rather than imported from
12
+ * `@uds/config` so this stays a small leaf runtime helper.
13
+ */
14
+ interface InterpolateMarker {
15
+ __type: 'interpolate';
16
+ output: number[];
17
+ extrapolate: 'clamp' | 'extend' | 'identity';
18
+ }
19
+ /**
20
+ * Resolve a single `interpolate({ output, extrapolate })` marker against
21
+ * an integer-ish `index`. Output is a discrete lookup by index for
22
+ * `index < output.length`; beyond that, `extrapolate` chooses the
23
+ * extension rule (clamp / linear-extend / identity).
24
+ */
25
+ declare function resolveInterpolate(marker: InterpolateMarker, index: number): number;
26
+ /**
27
+ * Resolve every InterpolateMarker in a state keyframe object against
28
+ * `index`, leaving non-marker values unchanged. Used by codegen-emitted
29
+ * `__rms(...)` call sites — see
30
+ * `packages/codegen/src/build/get-styles/motion-transform.ts` for the
31
+ * call-site generation.
32
+ */
33
+ declare function resolveMotionState(stateKeyframe: Record<string, unknown>, index: number): Record<string, unknown>; //#endregion
34
+ //#endregion
35
+ export { resolveInterpolate, resolveMotionState };
@@ -0,0 +1,33 @@
1
+ //#region ../utils/dist/motion-utils/resolveMotionState.js
2
+ function isInterpolateMarker(value) {
3
+ return typeof value === "object" && value !== null && value.__type === "interpolate";
4
+ }
5
+ /**
6
+ * Resolve a single `interpolate({ output, extrapolate })` marker against
7
+ * an integer-ish `index`. Output is a discrete lookup by index for
8
+ * `index < output.length`; beyond that, `extrapolate` chooses the
9
+ * extension rule (clamp / linear-extend / identity).
10
+ */
11
+ function resolveInterpolate(marker, index) {
12
+ const { output, extrapolate } = marker;
13
+ if (index < output.length) return output[index];
14
+ if (extrapolate === "clamp") return output[output.length - 1];
15
+ if (extrapolate === "identity") return index;
16
+ const last = output[output.length - 1];
17
+ return last + (last - (output[output.length - 2] ?? last)) * (index - (output.length - 1));
18
+ }
19
+ /**
20
+ * Resolve every InterpolateMarker in a state keyframe object against
21
+ * `index`, leaving non-marker values unchanged. Used by codegen-emitted
22
+ * `__rms(...)` call sites — see
23
+ * `packages/codegen/src/build/get-styles/motion-transform.ts` for the
24
+ * call-site generation.
25
+ */
26
+ function resolveMotionState(stateKeyframe, index) {
27
+ const resolved = {};
28
+ for (const [key, value] of Object.entries(stateKeyframe)) if (isInterpolateMarker(value)) resolved[key] = resolveInterpolate(value, index);
29
+ else resolved[key] = value;
30
+ return resolved;
31
+ }
32
+ //#endregion
33
+ export { resolveInterpolate, resolveMotionState };
@@ -1,19 +1,52 @@
1
1
  //#region ../utils/dist/string-utils/componentClassName.d.ts
2
2
  //#region src/string-utils/componentClassName.d.ts
3
3
  /**
4
- * Build the base class name for a component slot.
4
+ * The four class-name accessors for a single component, with the config
5
+ * prefix + component name bound. The single source of truth for "what does
6
+ * this component's CSS class look like" — the resolved `Component` exposes
7
+ * one (`component.derived.classNames`) and the codegen emitters read it
8
+ * instead of re-deriving names, so the emitted CSS selectors and the
9
+ * generated TSX `className` strings can never drift.
10
+ */
11
+ interface ComponentClassNames {
12
+ layer(layer: string): string;
13
+ variant(layer: string, axis: string, value: string): string;
14
+ defaultProp(layer: string, prop: string): string;
15
+ compound(layer: string, conditions: Record<string, string>): string;
16
+ }
17
+ /**
18
+ * Build the {@link ComponentClassNames} accessor set for a component, binding
19
+ * `prefix` + `name` so callers supply only the per-class arguments. The prefix
20
+ * is applied here (once), wrapping the unprefixed shape the helpers below
21
+ * define — so the helpers stay the single definition of the class-name *shape*
22
+ * and this factory is the single definition of *namespacing*.
23
+ */
24
+ declare function componentClassNames(prefix: string, name: string): ComponentClassNames;
25
+ /**
26
+ * Build the base class name for a component layer.
5
27
  *
6
- * @example componentSlotClass('Switch', 'root') // "switch-root"
28
+ * @example componentLayerClass('Switch', 'root') // "switch-root"
7
29
  */
8
- declare function componentSlotClass(componentName: string, slot: string): string;
30
+ declare function componentLayerClass(componentName: string, layer: string): string;
9
31
  /**
10
- * Build the variant class name for a component slot.
32
+ * Build the variant class name for a component layer.
11
33
  *
12
34
  * @example componentVariantClass('Switch', 'root', 'size', 'lg') // "switch-root--size-lg"
13
35
  */
14
- declare function componentVariantClass(componentName: string, slot: string, axis: string, value: string): string;
36
+ declare function componentVariantClass(componentName: string, layer: string, axis: string, value: string): string;
37
+ /**
38
+ * Build the class name carrying a component's own `defaultProps` styling for a
39
+ * prop, on a layer. Emitted in `@layer base` (so it loses to an embedding
40
+ * component's anatomy in `@layer components`) and applied by the generated impl
41
+ * only when the prop is absent — so an embedded sub-component's default
42
+ * `variant`/`color` no longer overrides the parent's anatomy, while an explicit
43
+ * prop still wins via its atomic/variant class in a later layer.
44
+ *
45
+ * @example componentDefaultClass('Text', 'root', 'color') // "text-root-color-default"
46
+ */
47
+ declare function componentDefaultClass(componentName: string, layer: string, prop: string): string;
15
48
  /**
16
- * Build the compound-variant class name for a component slot.
49
+ * Build the compound-variant class name for a component layer.
17
50
  *
18
51
  * Conditions are sorted by key to guarantee a stable, deterministic name.
19
52
  *
@@ -21,6 +54,6 @@ declare function componentVariantClass(componentName: string, slot: string, axis
21
54
  * componentCompoundClass('Switch', 'root', { size: 'lg', color: 'primary' })
22
55
  * // "switch-root--color-primary_size-lg"
23
56
  */
24
- declare function componentCompoundClass(componentName: string, slot: string, conditions: Record<string, string>): string; //#endregion
57
+ declare function componentCompoundClass(componentName: string, layer: string, conditions: Record<string, string>): string; //#endregion
25
58
  //#endregion
26
- export { componentCompoundClass, componentSlotClass, componentVariantClass };
59
+ export { ComponentClassNames, componentClassNames, componentCompoundClass, componentDefaultClass, componentLayerClass, componentVariantClass };
@@ -1,23 +1,60 @@
1
1
  import { kebabCase } from "./kebabCase.js";
2
2
  //#region ../utils/dist/string-utils/componentClassName.js
3
3
  /**
4
- * Build the base class name for a component slot.
4
+ * Prepend the configured prefix to a component class-name body, mirroring how
5
+ * CSS variables are namespaced (`--<prefix>-…`). An empty prefix yields the
6
+ * bare, unprefixed form — parallel to the CSS-variable path's empty-prefix
7
+ * handling — so `prefix: ''` opts every component class out of namespacing.
8
+ */
9
+ function withPrefix(prefix, body) {
10
+ return prefix ? `${prefix}-${body}` : body;
11
+ }
12
+ /**
13
+ * Build the {@link ComponentClassNames} accessor set for a component, binding
14
+ * `prefix` + `name` so callers supply only the per-class arguments. The prefix
15
+ * is applied here (once), wrapping the unprefixed shape the helpers below
16
+ * define — so the helpers stay the single definition of the class-name *shape*
17
+ * and this factory is the single definition of *namespacing*.
18
+ */
19
+ function componentClassNames(prefix, name) {
20
+ return {
21
+ layer: (layer) => withPrefix(prefix, componentLayerClass(name, layer)),
22
+ variant: (layer, axis, value) => withPrefix(prefix, componentVariantClass(name, layer, axis, value)),
23
+ defaultProp: (layer, prop) => withPrefix(prefix, componentDefaultClass(name, layer, prop)),
24
+ compound: (layer, conditions) => withPrefix(prefix, componentCompoundClass(name, layer, conditions))
25
+ };
26
+ }
27
+ /**
28
+ * Build the base class name for a component layer.
5
29
  *
6
- * @example componentSlotClass('Switch', 'root') // "switch-root"
30
+ * @example componentLayerClass('Switch', 'root') // "switch-root"
7
31
  */
8
- function componentSlotClass(componentName, slot) {
9
- return `${kebabCase(componentName)}-${slot}`;
32
+ function componentLayerClass(componentName, layer) {
33
+ return `${kebabCase(componentName)}-${layer}`;
10
34
  }
11
35
  /**
12
- * Build the variant class name for a component slot.
36
+ * Build the variant class name for a component layer.
13
37
  *
14
38
  * @example componentVariantClass('Switch', 'root', 'size', 'lg') // "switch-root--size-lg"
15
39
  */
16
- function componentVariantClass(componentName, slot, axis, value) {
17
- return `${kebabCase(componentName)}-${slot}--${axis}-${value}`;
40
+ function componentVariantClass(componentName, layer, axis, value) {
41
+ return `${kebabCase(componentName)}-${layer}--${axis}-${value}`;
42
+ }
43
+ /**
44
+ * Build the class name carrying a component's own `defaultProps` styling for a
45
+ * prop, on a layer. Emitted in `@layer base` (so it loses to an embedding
46
+ * component's anatomy in `@layer components`) and applied by the generated impl
47
+ * only when the prop is absent — so an embedded sub-component's default
48
+ * `variant`/`color` no longer overrides the parent's anatomy, while an explicit
49
+ * prop still wins via its atomic/variant class in a later layer.
50
+ *
51
+ * @example componentDefaultClass('Text', 'root', 'color') // "text-root-color-default"
52
+ */
53
+ function componentDefaultClass(componentName, layer, prop) {
54
+ return `${kebabCase(componentName)}-${layer}-${prop}-default`;
18
55
  }
19
56
  /**
20
- * Build the compound-variant class name for a component slot.
57
+ * Build the compound-variant class name for a component layer.
21
58
  *
22
59
  * Conditions are sorted by key to guarantee a stable, deterministic name.
23
60
  *
@@ -25,9 +62,9 @@ function componentVariantClass(componentName, slot, axis, value) {
25
62
  * componentCompoundClass('Switch', 'root', { size: 'lg', color: 'primary' })
26
63
  * // "switch-root--color-primary_size-lg"
27
64
  */
28
- function componentCompoundClass(componentName, slot, conditions) {
65
+ function componentCompoundClass(componentName, layer, conditions) {
29
66
  const suffix = Object.entries(conditions).sort(([a], [b]) => a.localeCompare(b)).map(([a, v]) => `${a}-${v}`).join("_");
30
- return `${kebabCase(componentName)}-${slot}--${suffix}`;
67
+ return `${kebabCase(componentName)}-${layer}--${suffix}`;
31
68
  }
32
69
  //#endregion
33
- export { componentCompoundClass, componentSlotClass, componentVariantClass };
70
+ export { componentClassNames, componentCompoundClass, componentDefaultClass, componentLayerClass, componentVariantClass };
package/dist/utils.d.ts CHANGED
@@ -3,6 +3,7 @@ import { closestItem } from "./utils/dist/array-utils/closestItem.js";
3
3
  import { removeItem } from "./utils/dist/array-utils/removeItem.js";
4
4
  import { clamp } from "./utils/dist/math-utils/clamp.js";
5
5
  import { interpolate } from "./utils/dist/motion-utils/interpolate.js";
6
+ import { resolveInterpolate, resolveMotionState } from "./utils/dist/motion-utils/resolveMotionState.js";
6
7
  import { entries } from "./utils/dist/object-utils/entries.js";
7
8
  import { flattenObj } from "./utils/dist/object-utils/flattenObj.js";
8
9
  import { fromEntries } from "./utils/dist/object-utils/fromEntries.js";
@@ -11,7 +12,7 @@ import { mapKeys } from "./utils/dist/object-utils/mapKeys.js";
11
12
  import { mapValues } from "./utils/dist/object-utils/mapValues.js";
12
13
  import { arrayToUnion } from "./utils/dist/string-utils/arrayToUnion.js";
13
14
  import { capitalize } from "./utils/dist/string-utils/capitalize.js";
14
- import { componentCompoundClass, componentSlotClass, componentVariantClass } from "./utils/dist/string-utils/componentClassName.js";
15
+ import { ComponentClassNames, componentClassNames, componentCompoundClass, componentDefaultClass, componentLayerClass, componentVariantClass } from "./utils/dist/string-utils/componentClassName.js";
15
16
  import { createTemplate, interfaceTemplate, template, typeTemplate } from "./utils/dist/string-utils/createTemplate.js";
16
17
  import { KebabCase, kebabCase } from "./utils/dist/string-utils/kebabCase.js";
17
18
  import { CssVar, CssVarName, cssVar, cssVarDeclarations, cssVarName, safeTokenName } from "./utils/dist/string-utils/cssVar.js";
@@ -21,4 +22,4 @@ import { indent } from "./utils/dist/string-utils/indent.js";
21
22
  import { join } from "./utils/dist/string-utils/join.js";
22
23
  import { split } from "./utils/dist/string-utils/split.js";
23
24
  import { tsProperties, tsTypes } from "./utils/dist/string-utils/tsProperties.js";
24
- export { ComponentStyleDefaultsInput, CssVar, CssVarName, KebabCase, applyComponentStyleDefaults, arrayToUnion, capitalize, clamp, closestItem, componentCompoundClass, componentSlotClass, componentVariantClass, createTemplate, cssVar, cssVarDeclarations, cssVarName, cssVars, dedent, dedentTS, entries, flattenObj, fromEntries, indent, interfaceTemplate, interpolate, join, kebabCase, keys, mapKeys, mapValues, removeItem, safeTokenName, split, template, tsProperties, tsTypes, typeTemplate };
25
+ export { ComponentClassNames, ComponentStyleDefaultsInput, CssVar, CssVarName, KebabCase, applyComponentStyleDefaults, arrayToUnion, capitalize, clamp, closestItem, componentClassNames, componentCompoundClass, componentDefaultClass, componentLayerClass, componentVariantClass, createTemplate, cssVar, cssVarDeclarations, cssVarName, cssVars, dedent, dedentTS, entries, flattenObj, fromEntries, indent, interfaceTemplate, interpolate, join, kebabCase, keys, mapKeys, mapValues, removeItem, resolveInterpolate, resolveMotionState, safeTokenName, split, template, tsProperties, tsTypes, typeTemplate };
package/dist/utils.js CHANGED
@@ -3,6 +3,7 @@ import { closestItem } from "./utils/dist/array-utils/closestItem.js";
3
3
  import { removeItem } from "./utils/dist/array-utils/removeItem.js";
4
4
  import { clamp } from "./utils/dist/math-utils/clamp.js";
5
5
  import { interpolate } from "./utils/dist/motion-utils/interpolate.js";
6
+ import { resolveInterpolate, resolveMotionState } from "./utils/dist/motion-utils/resolveMotionState.js";
6
7
  import { entries } from "./utils/dist/object-utils/entries.js";
7
8
  import { flattenObj } from "./utils/dist/object-utils/flattenObj.js";
8
9
  import { fromEntries } from "./utils/dist/object-utils/fromEntries.js";
@@ -12,7 +13,7 @@ import { mapValues } from "./utils/dist/object-utils/mapValues.js";
12
13
  import { arrayToUnion } from "./utils/dist/string-utils/arrayToUnion.js";
13
14
  import { capitalize } from "./utils/dist/string-utils/capitalize.js";
14
15
  import { kebabCase } from "./utils/dist/string-utils/kebabCase.js";
15
- import { componentCompoundClass, componentSlotClass, componentVariantClass } from "./utils/dist/string-utils/componentClassName.js";
16
+ import { componentClassNames, componentCompoundClass, componentDefaultClass, componentLayerClass, componentVariantClass } from "./utils/dist/string-utils/componentClassName.js";
16
17
  import { createTemplate, interfaceTemplate, template, typeTemplate } from "./utils/dist/string-utils/createTemplate.js";
17
18
  import { cssVar, cssVarDeclarations, cssVarName, safeTokenName } from "./utils/dist/string-utils/cssVar.js";
18
19
  import { cssVars } from "./utils/dist/string-utils/cssVars.js";
@@ -22,4 +23,4 @@ import { join } from "./utils/dist/string-utils/join.js";
22
23
  import { split } from "./utils/dist/string-utils/split.js";
23
24
  import { tsProperties, tsTypes } from "./utils/dist/string-utils/tsProperties.js";
24
25
  import "./utils/dist/index.js";
25
- export { applyComponentStyleDefaults, arrayToUnion, capitalize, clamp, closestItem, componentCompoundClass, componentSlotClass, componentVariantClass, createTemplate, cssVar, cssVarDeclarations, cssVarName, cssVars, dedent, dedentTS, entries, flattenObj, fromEntries, indent, interfaceTemplate, interpolate, join, kebabCase, keys, mapKeys, mapValues, removeItem, safeTokenName, split, template, tsProperties, tsTypes, typeTemplate };
26
+ export { applyComponentStyleDefaults, arrayToUnion, capitalize, clamp, closestItem, componentClassNames, componentCompoundClass, componentDefaultClass, componentLayerClass, componentVariantClass, createTemplate, cssVar, cssVarDeclarations, cssVarName, cssVars, dedent, dedentTS, entries, flattenObj, fromEntries, indent, interfaceTemplate, interpolate, join, kebabCase, keys, mapKeys, mapValues, removeItem, resolveInterpolate, resolveMotionState, safeTokenName, split, template, tsProperties, tsTypes, typeTemplate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yahoo/uds-v5-wip",
3
- "version": "1.61.0",
3
+ "version": "1.62.0",
4
4
  "description": "Universal Design System",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -65,8 +65,8 @@
65
65
  "@babel/traverse": "^7.29.0",
66
66
  "@babel/types": "^7.29.0",
67
67
  "@modelcontextprotocol/sdk": "^1.27.1",
68
- "@uds/cli": "npm:@yahoo/uds-v5-wip-cli@1.61.0",
69
- "@uds/types": "npm:@yahoo/uds-v5-wip-types@1.61.0",
68
+ "@uds/cli": "npm:@yahoo/uds-v5-wip-cli@1.62.0",
69
+ "@uds/types": "npm:@yahoo/uds-v5-wip-types@1.62.0",
70
70
  "clsx": "^2.1.1",
71
71
  "react-day-picker": "^9.14.0",
72
72
  "unplugin": "^3.0.0",
@@ -1,2 +0,0 @@
1
- import "../../../utils/dist/index.js";
2
- import "../../../config/dist/index.js";
@@ -1,16 +0,0 @@
1
- import { LayerBundle, LayerInput } from "./component-config.js";
2
-
3
- //#region ../config/dist/bindRender.d.ts
4
- //#region src/bindRender.d.ts
5
- /**
6
- * Arguments handed to the user's render function. `props` is keyed by
7
- * the component's layer names; `children` is React's standard
8
- * children. Extra incoming props that aren't claimed by the config
9
- * arrive on the same object.
10
- */
11
- interface CreateComponentRenderArgs<TLayers extends Record<string, LayerInput>> {
12
- props: { [K in keyof TLayers]: LayerBundle };
13
- [key: string]: unknown;
14
- } //#endregion
15
- //#endregion
16
- export { CreateComponentRenderArgs };
@@ -1,310 +0,0 @@
1
- import { buildStylePropClassName } from "./className.js";
2
- import { kebabCase } from "../../utils/dist/string-utils/kebabCase.js";
3
- import { componentCompoundClass, componentSlotClass, componentVariantClass } from "../../utils/dist/string-utils/componentClassName.js";
4
- import "../../utils/dist/index.js";
5
- import { getRegisteredComposite, getRegisteredStyleProp } from "./runtime-registry.js";
6
- //#region ../config/dist/bindRender.js
7
- /**
8
- * **NEW-API ONLY** — internal runtime for `defineComponent`-authored
9
- * configs. Binds a config to a React render function and walks the
10
- * `layers` / `props` blocks on every render to produce `LayerBundle`s.
11
- *
12
- * Does NOT touch any legacy `createComponent` / `defineComponents`
13
- * code path. The legacy `createComponent` factory lives in
14
- * `@uds/components` and has its own runtime (className composition
15
- * via `getStyles` / `processStyleProps`).
16
- *
17
- * Render-time behavior:
18
- *
19
- * 1. The framework walks each entry in `config.layers` and builds a
20
- * `LayerBundle` per layer — a `className` string plus any HTML
21
- * attrs / forwarded props. Primitive layers with `defaultProps`
22
- * pick up the deterministic `componentName-layerName` @utility
23
- * class (the same one codegen emits from those defaults).
24
- *
25
- * 2. Incoming JSX props are partitioned per the `props` config:
26
- * style-prop bindings → contribute classes to a specific layer's
27
- * bundle; composite bindings → expand to multiple layers' bundles;
28
- * surface forwards → land verbatim on the target layer's bundle;
29
- * bool/enum markers → contribute data-attrs or per-layer overrides.
30
- *
31
- * 3. The render function receives `{ props, children, ...rest }` where
32
- * `props.<layer>` is the computed bundle for that layer and
33
- * `...rest` carries any props that weren't claimed by the config.
34
- *
35
- * Exported surface: `bindRender` (consumed by `defineComponent.ts`).
36
- */
37
- /**
38
- * Type-guard: a `StylePropMarker` is the helper-emitted binding with
39
- * `__kind: 'styleProp'`, `layer`, and `ref` (bare registered style-
40
- * prop name). Authored via `styleProp(ref).on(layer)`.
41
- */
42
- function isStylePropMarker(binding) {
43
- return typeof binding === "object" && binding !== null && binding.__kind === "styleProp" && typeof binding.ref === "string" && typeof binding.layer === "string";
44
- }
45
- /**
46
- * Type-guard: a `StringMarker` carries only `__kind: 'string'`.
47
- * Authored via `string()` — parallel to `bool()`, but the JSX value
48
- * is a string written verbatim into `data-<kebab-name>="<value>"` on
49
- * every layer's bundle.
50
- */
51
- function isStringMarker(binding) {
52
- return typeof binding === "object" && binding !== null && binding.__kind === "string";
53
- }
54
- /**
55
- * Type-guard: an `EnumMarker` carries the `__kind: 'enum'` brand and a
56
- * `values` map (axis-value → per-layer style map). Authored via
57
- * `enums({...})` in the `props` block of a verbose-form
58
- * `defineComponent` call.
59
- */
60
- function isEnumMarker(binding) {
61
- return typeof binding === "object" && binding !== null && binding.__kind === "enum";
62
- }
63
- /**
64
- * Type-guard: a `BoolMarker` carries only the `__kind: 'bool'` brand.
65
- * Authored via `bool()` in the `props` block (e.g. `loading: bool()`).
66
- */
67
- function isBoolMarker(binding) {
68
- return typeof binding === "object" && binding !== null && binding.__kind === "bool";
69
- }
70
- /**
71
- * Type-guard: a `SlotMarker` carries `__kind: 'slot'`, a `layer` name,
72
- * and optionally an `as` target. Authored via `slot('layer')` or
73
- * `slot('layer', { as: 'propName' })`.
74
- */
75
- function isSlotMarker(binding) {
76
- return typeof binding === "object" && binding !== null && binding.__kind === "slot" && typeof binding.layer === "string";
77
- }
78
- /**
79
- * Type-guard: a `CompositeMarker` carries `__kind: 'composite'` and a
80
- * brace-ref `ref` field pointing at a registered composite group.
81
- * Authored via `composite('{textVariant}')` in the `props` block —
82
- * the implicit-root-layer shorthand for composite bindings.
83
- */
84
- function isCompositeMarker(binding) {
85
- return typeof binding === "object" && binding !== null && binding.__kind === "composite" && typeof binding.ref === "string";
86
- }
87
- /**
88
- * Type-guard: a layer value is a component value (a `defineComponent`
89
- * result). Recognized by the `__config` brand attached to every bound
90
- * component. Stand-alone primitives (a `string` tag, `{ tag, attrs }`)
91
- * never carry `__config` so the discriminator is unambiguous.
92
- */
93
- function isComposedComponentValue(value) {
94
- return typeof value === "function" && "__config" in value;
95
- }
96
- /**
97
- * Append a className to a layer bundle, joining with a space if a class
98
- * was already accumulated. Empty / falsy contributions are dropped.
99
- */
100
- function appendClassName(bundle, className) {
101
- if (!className) return;
102
- const existing = bundle.className;
103
- bundle.className = existing ? `${existing} ${className}` : className;
104
- }
105
- /**
106
- * Build an initial `LayerBundle` for a layer.
107
- *
108
- * - `PrimitiveLayer.attrs` — locked HTML attrs (`role="alert"`,
109
- * `aria-live="polite"`, …) seeded onto the bundle so the rendered
110
- * element carries them.
111
- * - Bare-tag string layers (`'div'`), bare component-value layers
112
- * (`{ root: Card }`) — bundle starts empty; per-layer base styles
113
- * come from the config's top-level `base: { <layer>: {...} }`
114
- * block in a later pass.
115
- */
116
- function buildLayerBundle(layer, _layerName, _componentName) {
117
- const bundle = {};
118
- if (layer === null || layer === void 0) return bundle;
119
- if (isComposedComponentValue(layer)) return bundle;
120
- if (typeof layer !== "object") return bundle;
121
- if ("tag" in layer) {
122
- const { attrs } = layer;
123
- if (attrs) for (const [key, value] of Object.entries(attrs)) bundle[key] = value;
124
- }
125
- return bundle;
126
- }
127
- /**
128
- * Internal: bind a config to a render function and return a React.FC.
129
- * Shared by `createComponent` (public, type-explicit two-arg form) and
130
- * `defineComponent` (primitive auto-render + chained `.render()`).
131
- */
132
- function bindRender(config, render, options) {
133
- const Component = (incomingProps) => {
134
- const componentName = config.__componentName;
135
- const configDefaults = config.defaultProps;
136
- const effectiveProps = configDefaults ? {
137
- ...configDefaults,
138
- ...incomingProps
139
- } : incomingProps;
140
- const bundles = {};
141
- for (const [layerName, layerValue] of Object.entries(config.layers)) bundles[layerName] = buildLayerBundle(layerValue, layerName, componentName);
142
- const baseBlock = config.base;
143
- if (baseBlock && componentName) for (const layerName of Object.keys(baseBlock)) {
144
- const target = bundles[layerName];
145
- if (!target) continue;
146
- appendClassName(target, componentSlotClass(componentName, layerName));
147
- }
148
- const claimedKeys = /* @__PURE__ */ new Set();
149
- const propsBlock = config.props;
150
- if (propsBlock) for (const [jsxPropKey, binding] of Object.entries(propsBlock)) {
151
- const incoming = effectiveProps[jsxPropKey];
152
- if (isStylePropMarker(binding)) {
153
- claimedKeys.add(jsxPropKey);
154
- if (incoming === void 0 || incoming === null || incoming === false) continue;
155
- const styleProp = getRegisteredStyleProp(binding.ref);
156
- if (!styleProp) continue;
157
- const target = bundles[binding.layer];
158
- if (!target) continue;
159
- const className = buildStylePropClassName(styleProp, incoming);
160
- if (className) appendClassName(target, className);
161
- continue;
162
- }
163
- if (isEnumMarker(binding)) {
164
- claimedKeys.add(jsxPropKey);
165
- if (incoming === void 0 || incoming === null || !componentName) continue;
166
- const valueKey = String(incoming);
167
- const perLayerStyles = binding.values[valueKey];
168
- if (typeof perLayerStyles !== "object" || perLayerStyles === null) continue;
169
- for (const layerName of Object.keys(perLayerStyles)) {
170
- const target = bundles[layerName];
171
- if (!target) continue;
172
- appendClassName(target, componentVariantClass(componentName, layerName, jsxPropKey, valueKey));
173
- }
174
- continue;
175
- }
176
- if (isSlotMarker(binding)) {
177
- if (!binding.layer) continue;
178
- claimedKeys.add(jsxPropKey);
179
- if (incoming === void 0 || incoming === null) continue;
180
- const target = bundles[binding.layer];
181
- if (!target) continue;
182
- target[binding.prop ?? "children"] = incoming;
183
- continue;
184
- }
185
- if (isCompositeMarker(binding)) {
186
- claimedKeys.add(jsxPropKey);
187
- if (incoming === void 0 || incoming === null) continue;
188
- const refName = binding.ref;
189
- if (!refName) continue;
190
- const composite = getRegisteredComposite(refName);
191
- if (!composite) continue;
192
- const valueKey = String(incoming);
193
- if (!composite.styles[valueKey]) continue;
194
- const rootBundle = bundles.root;
195
- if (!rootBundle) continue;
196
- appendClassName(rootBundle, `${refName}-${valueKey.replace(/\./g, "_").replace(/\//g, "-")}`);
197
- continue;
198
- }
199
- if (isBoolMarker(binding)) {
200
- claimedKeys.add(jsxPropKey);
201
- if (!incoming) continue;
202
- const attrName = `data-${kebabCase(jsxPropKey)}`;
203
- for (const layerName of Object.keys(bundles)) {
204
- const target = bundles[layerName];
205
- if (target) target[attrName] = "true";
206
- }
207
- continue;
208
- }
209
- if (isStringMarker(binding)) {
210
- claimedKeys.add(jsxPropKey);
211
- if (incoming === void 0 || incoming === null || incoming === "") continue;
212
- const attrName = `data-${kebabCase(jsxPropKey)}`;
213
- const attrValue = String(incoming);
214
- for (const layerName of Object.keys(bundles)) {
215
- const target = bundles[layerName];
216
- if (target) target[attrName] = attrValue;
217
- }
218
- }
219
- }
220
- const compoundProps = config.compoundProps;
221
- if (compoundProps && componentName) for (const entry of compoundProps) {
222
- const conditions = {};
223
- let match = true;
224
- for (const [conditionKey, conditionValue] of Object.entries(entry.when)) {
225
- const incoming = effectiveProps[conditionKey];
226
- if (incoming === void 0 || incoming === null) {
227
- match = false;
228
- break;
229
- }
230
- const incomingStr = String(incoming);
231
- if (incomingStr !== String(conditionValue)) {
232
- match = false;
233
- break;
234
- }
235
- conditions[conditionKey] = incomingStr;
236
- }
237
- if (!match) continue;
238
- for (const [layerName, layerOverride] of Object.entries(entry.layers)) {
239
- const target = bundles[layerName];
240
- if (!target) continue;
241
- if (layerOverride?.__kind === "hidden") {
242
- target.__hidden = true;
243
- continue;
244
- }
245
- appendClassName(target, componentCompoundClass(componentName, layerName, conditions));
246
- }
247
- }
248
- const layerPropsValue = effectiveProps.layerProps;
249
- if (typeof layerPropsValue === "object" && layerPropsValue !== null && !Array.isArray(layerPropsValue)) {
250
- claimedKeys.add("layerProps");
251
- for (const [layerName, overrides] of Object.entries(layerPropsValue)) {
252
- if (typeof overrides !== "object" || overrides === null || Array.isArray(overrides)) continue;
253
- const bundle = bundles[layerName];
254
- if (!bundle) continue;
255
- for (const [propKey, propValue] of Object.entries(overrides)) {
256
- if (propKey.startsWith("_")) {
257
- if (typeof propValue !== "object" || propValue === null) continue;
258
- const variantName = propKey.slice(1);
259
- for (const [innerKey, innerValue] of Object.entries(propValue)) {
260
- const styleProp = getRegisteredStyleProp(innerKey);
261
- if (!styleProp) continue;
262
- const className = buildStylePropClassName(styleProp, innerValue);
263
- if (className) appendClassName(bundle, `${variantName}:${className}`);
264
- }
265
- continue;
266
- }
267
- const styleProp = getRegisteredStyleProp(propKey);
268
- if (styleProp) {
269
- if (propValue === void 0 || propValue === null || propValue === false) continue;
270
- const className = buildStylePropClassName(styleProp, propValue);
271
- if (className) appendClassName(bundle, className);
272
- continue;
273
- }
274
- if (propKey === "className" && typeof propValue === "string") {
275
- appendClassName(bundle, propValue);
276
- continue;
277
- }
278
- bundle[propKey] = propValue;
279
- }
280
- }
281
- }
282
- const rootBundleForMods = bundles.root;
283
- for (const [key, value] of Object.entries(effectiveProps)) {
284
- if (!key.startsWith("_")) continue;
285
- if (claimedKeys.has(key)) continue;
286
- claimedKeys.add(key);
287
- if (!rootBundleForMods) continue;
288
- if (typeof value !== "object" || value === null) continue;
289
- const variantName = key.slice(1);
290
- for (const [innerKey, innerValue] of Object.entries(value)) {
291
- const styleProp = getRegisteredStyleProp(innerKey);
292
- if (!styleProp) continue;
293
- const baseClass = buildStylePropClassName(styleProp, innerValue);
294
- if (!baseClass) continue;
295
- appendClassName(rootBundleForMods, `${variantName}:${baseClass}`);
296
- }
297
- }
298
- const passthrough = {};
299
- for (const [key, value] of Object.entries(effectiveProps)) if (!claimedKeys.has(key)) passthrough[key] = value;
300
- return render({
301
- ...passthrough,
302
- props: bundles
303
- });
304
- };
305
- const displayName = options?.displayName || render.displayName || render.name?.trim() || void 0;
306
- if (displayName) Component.displayName = displayName;
307
- return Component;
308
- }
309
- //#endregion
310
- export { bindRender };