@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,150 +1,198 @@
1
- import { RegisteredComposites, RegisteredModifiers, RegisteredStyleProps } from "./component-refs.js";
2
- import { ComponentConfigValue, HtmlTag, LayerInput, PropBinding } from "./component-config.js";
1
+ import { RegisteredCompositeStyles, RegisteredModifiers, RegisteredStyleProps, TagRef } from "./refs.js";
2
+ import { ColorExpression } from "./colorExpressions.js";
3
+ import { ComponentDefinition, LayerInput, PropBinding, RootTag } from "./types.js";
3
4
  import { ComponentPropsWithRef, HTMLAttributes, JSX, ReactNode } from "react";
4
5
 
5
6
  //#region ../config/dist/Props.d.ts
6
7
  //#region src/Props.d.ts
7
8
  /**
8
- * Resolve the native HTML-attribute surface for the config's root tag.
9
+ * Resolve the native HTML-attribute surface for the definition's root tag.
9
10
  *
10
11
  * - When `TTag` is a known `JSX.IntrinsicElements` key (`'a'`, `'div'`,
11
12
  * `'button'`, …), use `ComponentPropsWithRef<TTag>` so element-
12
13
  * specific attrs *and* the React 19 `ref` prop both land in the prop
13
14
  * type (`href` on `'a'`, `disabled` on `'button'`, `ref` on every
14
15
  * intrinsic).
15
- * - Otherwise (no tag captured — e.g. the root is a brace-ref or
16
- * composed-layer), fall back to the generic `HTMLAttributes<HTMLElement>`.
16
+ * - Otherwise (no tag captured — e.g. the root is a `ComponentRef`
17
+ * or composed-layer), fall back to the generic
18
+ * `HTMLAttributes<HTMLElement>`.
17
19
  */
18
- type ElementProps<TTag extends HtmlTag | undefined> = TTag extends keyof JSX.IntrinsicElements ? ComponentPropsWithRef<TTag> : HTMLAttributes<HTMLElement>;
20
+ type ElementProps<TTag extends string | undefined> = TTag extends keyof JSX.IntrinsicElements ? ComponentPropsWithRef<TTag> : HTMLAttributes<HTMLElement>;
19
21
  /**
20
22
  * Props inherited from the wrapped component when the root layer is a
21
- * component value or a `ComposedLayer` `{ component, defaultProps }`
22
- * form. Returns the wrapped component's own resolved `Props<...>`
23
- * shape so a wrapper's JSX surface inherits everything the wrapped
24
- * component accepts. Returns `{}` when the root isn't composed.
23
+ * registered `ComponentDefinition` value (e.g. `layers: { root: Box }`).
24
+ * Returns the wrapped component's own resolved `Props<...>` shape so
25
+ * a wrapper's JSX surface inherits everything the wrapped component
26
+ * accepts. Returns `{}` when the root isn't composed.
25
27
  *
26
- * Reads the `__config` slot off the layer value (or the
27
- * `ComposedLayer`'s `component` field) and recursively resolves
28
- * `Props<TInnerConfig>`. Falls back to the legacy
29
- * `RegisteredComponents[name]` lookup when the layer is the
30
- * shape so a wrapper's JSX surface inherits everything the wrapped
31
- * component accepts. Returns `{}` when the root isn't composed.
28
+ * Recursion terminates because the inner `TInner` is constrained to
29
+ * `ComponentDefinition<infer L, infer P, infer T>` — three concrete
30
+ * inferred type variables, not the bare wide `ComponentDefinition`. TS
31
+ * unfolds one step at a time and the recursive `Props<TInner>` works
32
+ * on the already-narrowed shape rather than the open structural
33
+ * interface.
32
34
  *
33
- * Reads the `__config` slot off the layer value directly. Authoring
34
- * uses bare `defineComponent`-produced values (`layers: { root: Box }`)
35
- * there's no longer a `{ component, defaultProps }` wrapper layer
36
- * to walk through.
35
+ * The outer `[TLayers] extends [Record<string, LayerInput>]` guard
36
+ * (and the corresponding wide-`R` short-circuit below) prevent the
37
+ * type from blowing the complexity budget when `TLayers` is the bare
38
+ * structural default (`Record<string, LayerInput>`) — at that point
39
+ * `R` is the full `LayerInput` union, and recursing through it would
40
+ * try to enumerate every wrapped-component shape the union admits.
37
41
  */
42
+ /**
43
+ * One-level prop-shape extraction for a composed root layer. Mirrors
44
+ * `Props<TInner>` without re-invoking `Props` recursively — the
45
+ * recursion was the main culprit behind TS2590 "union too complex"
46
+ * during codegen typechecks, where dozens of `defineComponent` call
47
+ * sites with overlapping prop shapes pushed the inference budget
48
+ * over. One level of prop inheritance covers every real wrapper
49
+ * shape (Box → HStack, Box → Pressable, Box → Input); a deeper
50
+ * chain (Pressable → Button) still picks up Box's surface via the
51
+ * already-flattened intermediate, because each step's `props` field
52
+ * already carries the merged-and-flattened bindings from the chain
53
+ * methods' `MergeChainConfig`.
54
+ */
55
+ type ComposedRootShape<TLayers extends Record<string, LayerInput>, TProps extends Record<string, PropBinding>, TTag extends string | undefined> = PropsFromBindings<TProps, TLayers> & Omit<ElementProps<EffectiveTagPlain<TTag, TLayers>>, keyof TProps> & DataAttrs;
56
+ /**
57
+ * Plain tag computation for `ComposedRootShape` — no `defaultProps.as`
58
+ * override (the inner def's own `defaultProps.as` doesn't influence
59
+ * the outer JSX surface; only its layers + props + captured TTag do).
60
+ */
61
+ type EffectiveTagPlain<TTag, TLayers> = string extends TTag ? RootTag<TLayers> : [TTag] extends [undefined] ? RootTag<TLayers> : TTag extends string ? TTag : RootTag<TLayers>;
38
62
  type ComposedRootProps<TLayers> = TLayers extends {
39
63
  root: infer R;
40
- } ? R extends {
41
- readonly __config: infer TInnerConfig extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined>;
42
- } ? Props<TInnerConfig> : {} : {};
64
+ } ? LayerInput extends R ? {} : R extends ComponentDefinition<infer InnerLayers, infer InnerProps, infer InnerTag> ? ComposedRootShape<InnerLayers, InnerProps, InnerTag> : {} : {};
43
65
  /**
44
66
  * Resolve the allowed-value union for one registered style prop.
45
67
  * Falls back to `string` when the prop registered no tokens (codegen
46
- * emits `never` for that case).
68
+ * emits `never` for that case). Always widened with `ColorExpression`
69
+ * so the sanctioned `mix(...)` / `darken(...)` / `lighten(...)` color
70
+ * helpers type-check at every style-prop position.
47
71
  */
48
- type StylePropValue<K extends keyof RegisteredStyleProps> = [RegisteredStyleProps[K]] extends [never] ? string : RegisteredStyleProps[K];
72
+ type StylePropValue<K extends keyof RegisteredStyleProps> = [RegisteredStyleProps[K]] extends [never] ? string | ColorExpression : RegisteredStyleProps[K] | ColorExpression;
49
73
  /**
50
- * Extract the registered style-prop name from a `StylePropMarker`
51
- * binding — `{ __kind: 'styleProp', ref: 'bg', layer }` → `'bg'`.
52
- * Returns `never` for non-matching forms.
74
+ * Extract the registered style-prop name from a `StylePropRef` binding —
75
+ * `{ __kind: 'styleProp', ref: 'bg', layer? }` → `'bg'`. Returns `never`
76
+ * for non-matching forms.
53
77
  */
54
78
  type StylePropRefName<TBinding> = TBinding extends {
55
79
  readonly __kind: 'styleProp';
56
80
  readonly ref: infer N;
57
81
  } ? N extends keyof RegisteredStyleProps & string ? N : never : never;
58
82
  /**
59
- * Extract the registered composite-group name from a `composite()`
60
- * marker binding:
61
- * - `{ __kind: 'composite', ref: 'textVariant' }` → `'textVariant'`
62
- * (the marker stores the bare name — no brace-ref wrapping; the
63
- * `composite()` call's position already establishes the
64
- * composite-ref context.)
83
+ * Extract the registered composite-group name from a `CompositeRef`
84
+ * binding — `{ __kind: 'composite', ref: 'textVariant' }` → `'textVariant'`.
65
85
  * Returns `never` for non-matching forms.
66
86
  */
67
87
  type CompositeRefName<TBinding> = TBinding extends {
68
88
  readonly __kind: 'composite';
69
89
  readonly ref: infer N;
70
- } ? N extends keyof RegisteredComposites & string ? N : never : never;
90
+ } ? N extends keyof RegisteredCompositeStyles & string ? N : never : never;
71
91
  /**
72
92
  * Resolve the allowed-value union for a registered composite group —
73
93
  * the union of `styles` keys. Falls back to `string` when the
74
- * registry isn't populated (e.g. inside `@uds/config`'s own tests
75
- * where codegen-emitted augmentation isn't loaded).
94
+ * registry isn't populated (e.g. inside `@uds/config`'s own
95
+ * tests where codegen-emitted augmentation isn't loaded).
76
96
  */
77
- type CompositeValue<K extends keyof RegisteredComposites> = RegisteredComposites[K] extends {
97
+ type CompositeValue<K extends keyof RegisteredCompositeStyles> = RegisteredCompositeStyles[K] extends {
78
98
  styles: infer S;
79
99
  } ? keyof S & string : string;
80
100
  /**
81
- * Detect a `slot('layer')` / `slot('layer/prop')` marker. Authoring
82
- * surface stamps `__kind: 'slot'` on the value so the render-fn
83
- * arg can be typed as `ReactNode` slot props always route their
84
- * value into a layer's children (or named slot prop), so a node is
85
- * the only thing they can legally carry.
86
- */
87
- /**
88
- * Resolve the JSX-value type for a `slot('layer/prop')` marker by
89
- * looking up `prop` on the target layer's surface:
101
+ * Resolve the JSX-value type for a slot ref by looking up the target
102
+ * layer's prop. Mirrors main's `SlotPropValue` but reads
103
+ * `layerProp` instead of `prop` (the config slot ref carries
104
+ * `layerProp` as the target prop name).
90
105
  *
91
- * - **Composed-component layer** — read `Props<TInnerConfig>[prop]`,
92
- * so `slot('button/onClick')` types as the click-handler the
93
- * wrapped component declares.
94
- * - **HTML-tag layer** (bare-tag `'div'` or `{ tag: 'a', attrs }`) —
95
- * read `ComponentPropsWithRef<tag>[prop]`, so `slot('link/href')`
106
+ * - **Composed-component layer** — read
107
+ * `Props<TInnerDef>[layerProp]`, so `slot('button/onClick')` types
108
+ * as the click-handler the wrapped component declares.
109
+ * - **HTML-tag layer** (bare-tag `'div'`, `TagRef<'a'>`, or
110
+ * `{ tag: 'a', attrs }`) — read
111
+ * `ComponentPropsWithRef<tag>[layerProp]`, so `slot('link/href')`
96
112
  * types as `string | undefined`.
97
- * - Unknown layer / unknown prop falls back to `ReactNode` (the
98
- * common case for slots and a safe default when the type system
99
- * can't pinpoint).
113
+ * - Unknown layer / unknown prop falls back to `ReactNode`.
100
114
  */
101
115
  type SlotTargetKey<A> = [A] extends [string] ? A : 'children';
116
+ /** Resolve a layer's HTML tag literal (`'a' | 'div' | ...`) when statically readable. */
117
+ type LayerTag<L> = L extends string ? L : L extends TagRef<infer T> ? T : L extends {
118
+ tag: infer T extends string;
119
+ } ? T : L extends {
120
+ tag: TagRef<infer T>;
121
+ } ? T : never;
122
+ /**
123
+ * Read prop `K` off `T` if present, else fall back to `ReactNode`. Used
124
+ * to look up a slot's target-layer prop without crashing on
125
+ * mismatched keys.
126
+ */
127
+ type ReadOrNode<T, K> = K extends keyof T ? T[K] : ReactNode;
102
128
  type SlotPropValue<TBinding, TLayers> = TBinding extends {
103
129
  readonly __kind: 'slot';
104
130
  readonly layer: infer L extends keyof TLayers & string;
105
- readonly prop?: infer A;
106
- } ? TLayers[L] extends {
107
- readonly __config: infer TInner extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined>;
108
- } ? SlotTargetKey<A> extends keyof Props<TInner> ? Props<TInner>[SlotTargetKey<A> & keyof Props<TInner>] : ReactNode : TLayers[L] extends keyof JSX.IntrinsicElements ? SlotTargetKey<A> extends keyof ComponentPropsWithRef<TLayers[L]> ? ComponentPropsWithRef<TLayers[L]>[SlotTargetKey<A> & keyof ComponentPropsWithRef<TLayers[L]>] : ReactNode : TLayers[L] extends {
109
- readonly tag: infer T extends keyof JSX.IntrinsicElements;
110
- } ? SlotTargetKey<A> extends keyof ComponentPropsWithRef<T> ? ComponentPropsWithRef<T>[SlotTargetKey<A> & keyof ComponentPropsWithRef<T>] : ReactNode : ReactNode : ReactNode;
131
+ readonly layerProp?: infer A;
132
+ } ? TLayers[L] extends ((props: infer P) => unknown) ? ReadOrNode<P, SlotTargetKey<A>> : TLayers[L] extends ComponentDefinition<infer InnerLayers, infer InnerProps, infer InnerTag> ? ReadOrNode<ComposedRootShape<InnerLayers, InnerProps, InnerTag>, SlotTargetKey<A>> : LayerTag<TLayers[L]> extends infer TT extends keyof JSX.IntrinsicElements ? ReadOrNode<ComponentPropsWithRef<TT>, SlotTargetKey<A>> : ReactNode : ReactNode;
111
133
  type IsSlotMarker<TBinding> = TBinding extends {
112
134
  readonly __kind: 'slot';
113
135
  } ? true : false;
114
136
  /**
115
- * Walk the config's `props` block and produce one optional JSX prop
116
- * per entry:
117
- *
118
- * - `slot('layer/prop')` markers narrow to the value type the target
119
- * layer exposes under `prop` — see {@link SlotPropValue}.
120
- * - `styleProp(ref)` markers narrow to the registered token union.
121
- * - `composite(ref)` markers narrow to the composite group's `styles`
122
- * keys union.
123
- * - Anything unrecognized stays open as `unknown`.
137
+ * Resolve the JSX value type for one prop binding. Pulled out so
138
+ * `PropsFromBindings` can apply it twice — once for required keys
139
+ * (no `?`) and once for optional keys.
124
140
  */
125
- type PropsFromConfig<TProps, TLayers> = { [K in keyof TProps]?: IsSlotMarker<TProps[K]> extends true ? SlotPropValue<TProps[K], TLayers> : StylePropRefName<TProps[K]> extends never ? CompositeRefName<TProps[K]> extends never ? unknown : CompositeValue<Extract<CompositeRefName<TProps[K]>, keyof RegisteredComposites>> : StylePropValue<Extract<StylePropRefName<TProps[K]>, keyof RegisteredStyleProps>> };
141
+ type ResolveBindingValue<TBinding, TLayers> = TBinding extends {
142
+ readonly __transformOut: infer Out;
143
+ } ? (value: Out) => void : IsSlotMarker<TBinding> extends true ? SlotPropValue<TBinding, TLayers> : StylePropRefName<TBinding> extends never ? CompositeRefName<TBinding> extends never ? TBinding extends {
144
+ readonly __kind: 'boolean';
145
+ } ? boolean : TBinding extends {
146
+ readonly __kind: 'string';
147
+ } ? string : TBinding extends {
148
+ readonly __kind: 'number';
149
+ } ? number : TBinding extends {
150
+ readonly __kind: 'variant';
151
+ readonly values: infer V;
152
+ } ? V extends readonly (string | number)[] ? V[number] : keyof V & string : unknown : CompositeValue<Extract<CompositeRefName<TBinding>, keyof RegisteredCompositeStyles>> : StylePropValue<Extract<StylePropRefName<TBinding>, keyof RegisteredStyleProps>>;
126
153
  /**
127
- * Force TypeScript to fully evaluate a mapped/conditional type so the
128
- * hover display shows the resolved shape (`bg?: 'brand' | 'accent'`)
129
- * instead of the unevaluated type expression
130
- * (`PropsFromConfig<{ readonly bg: StylePropMarker<'root', 'bg'> }>`).
154
+ * Keys of `TProps` whose binding carries `__required: true` these
155
+ * surface on the JSX side without the trailing `?` so callers must
156
+ * pass a value.
131
157
  */
132
- type Prettify<T> = { [K in keyof T]: T[K] } & {};
158
+ type RequiredBindingKeys<TProps> = { [K in keyof TProps]: TProps[K] extends {
159
+ readonly __required: true;
160
+ } ? K : never }[keyof TProps];
133
161
  /**
134
- * `layerProps={{ overlay: { bg: '...' }, panel: { width: '...' } }}` the
135
- * value-type for one layer. If the layer is a defined component (carries a
136
- * `__config` slot), use that component's full `Props<...>` surface so style
137
- * props, modifiers, and HTML attrs all autocomplete. Otherwise (a bare
138
- * HTML-tag string layer), widen to a permissive style-prop bag.
162
+ * Style-prop names bound by the definition the `ref` of every
163
+ * `styleProp(...)` entry in the `props` block (`never` for non-style
164
+ * bindings, which drop out of the union).
139
165
  */
140
- type LayerPropsValue<TLayer> = TLayer extends {
141
- readonly __config: infer TInner extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined>;
142
- } ? Partial<Props<TInner>> : Partial<HTMLAttributes<HTMLElement>> & { [K in keyof RegisteredStyleProps]?: StylePropValue<K> };
166
+ type BoundStylePropNames<TProps> = { [K in keyof TProps]: StylePropRefName<TProps[K]> }[keyof TProps] & string;
143
167
  /**
144
- * `{ overlay?: ..., panel?: ..., dismiss?: ..., ... }` — every layer in
145
- * `TLayers` is reachable.
168
+ * Opacity companions for the bound color props. `defineStyleProp(...)
169
+ * .withOpacity({ as })` registers a `${base}Opacity` sibling in
170
+ * `RegisteredStyleProps` that pairs with its base color prop at the same
171
+ * style position (`borderColor` → `borderColorOpacity`). A component that
172
+ * binds the base prop should accept the companion too — both on its JSX
173
+ * surface and inside modifier bodies (`_hover: { borderColorOpacity }`),
174
+ * which read their key set from this binding-derived bag rather than from
175
+ * the full `RegisteredStyleProps` map that tag layers get.
176
+ *
177
+ * The `& keyof RegisteredStyleProps` intersection keeps only siblings that
178
+ * were actually registered, so a bound base prop without a `.withOpacity()`
179
+ * pair (e.g. `borderTopColor`) contributes nothing.
146
180
  */
147
- type LayerPropsMap<TLayers extends Record<string, LayerInput>> = { [K in keyof TLayers]?: LayerPropsValue<TLayers[K]> };
181
+ type OpacityCompanionProps<TProps> = { [O in `${BoundStylePropNames<TProps>}Opacity` & keyof RegisteredStyleProps]?: StylePropValue<O> };
182
+ /**
183
+ * Walk the definition's `props` block and produce a JSX prop per entry.
184
+ * Bindings carry `__required: true` when the author chained
185
+ * `.required()`; those keys land in the required half of the resulting
186
+ * prop bag. Every other key stays optional. The opacity companions of any
187
+ * bound color prop ride along via `OpacityCompanionProps`.
188
+ */
189
+ type PropsFromBindings<TProps, TLayers> = { [K in keyof TProps as K extends RequiredBindingKeys<TProps> ? K : never]: ResolveBindingValue<TProps[K], TLayers> } & { [K in keyof TProps as K extends RequiredBindingKeys<TProps> ? never : K]?: ResolveBindingValue<TProps[K], TLayers> } & OpacityCompanionProps<TProps>;
190
+ /**
191
+ * Force TypeScript to fully evaluate a mapped/conditional type so the
192
+ * hover display shows the resolved shape (`bg?: 'brand' | 'accent'`)
193
+ * instead of the unevaluated type expression.
194
+ */
195
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
148
196
  /**
149
197
  * Standard `data-*` attributes are valid on every HTML element by spec.
150
198
  * React 19's bundled types don't carry an index signature for them, so
@@ -154,57 +202,118 @@ type LayerPropsMap<TLayers extends Record<string, LayerInput>> = { [K in keyof T
154
202
  interface DataAttrs {
155
203
  [key: `data-${string}`]: unknown;
156
204
  }
205
+ /**
206
+ * `layerProps={{ root: { bg: '...' }, ... }}` — per-layer JSX prop
207
+ * overrides. Same shape main exposes: each value is the layer
208
+ * component's own `Props<...>` (when the layer is a composed
209
+ * component) or a wide style+attr bag (when the layer is a bare HTML
210
+ * tag).
211
+ */
212
+ type LayerPropsValue<TLayer> = TLayer extends ComponentDefinition<infer InnerLayers, infer InnerProps, infer InnerTag> ? Partial<Props<ComponentDefinition<InnerLayers, InnerProps, InnerTag>>> : Partial<HTMLAttributes<HTMLElement>> & { [K in keyof RegisteredStyleProps]?: StylePropValue<K> };
213
+ type LayerPropsMap<TLayers extends Record<string, LayerInput>> = { [K in keyof TLayers]?: LayerPropsValue<TLayers[K]> };
214
+ /**
215
+ * Per-layer `base` styles. Same target-narrowing as `LayerPropsValue`
216
+ * but adds `_<modifier>` keys for tag layers — `base: { root: { _hover:
217
+ * {...} } }` is a common authoring pattern and modifiers aren't part
218
+ * of the JSX `layerProps` shape, so we expose them here only.
219
+ *
220
+ * Composed-component layers already carry modifiers via `Props<...>`
221
+ * (see `PropsBase`'s wrapping `RegisteredModifiers`), so that branch
222
+ * passes through unchanged.
223
+ */
224
+ /**
225
+ * Per-tag-layer styles bag. Combines:
226
+ * - HTML attrs valid on every element
227
+ * - Each registered style prop with its token-union value (plus
228
+ * `[bracket]` literals and an open-string escape so unregistered
229
+ * runtime values still typecheck — autocomplete still shows the
230
+ * token union via the `string & {}` hint pattern)
231
+ * - Each registered composite-style binding (e.g. `variant`,
232
+ * `elevation`) so layers that wrap a composite-bound component
233
+ * can set the composite value
234
+ * - A `Record<string, unknown>` index signature that only kicks in
235
+ * when the augmentable registries are empty (consumer tests in
236
+ * `@uds/config` / `@uds/codegen` run without codegen-emitted
237
+ * augmentation). Detected via the `[keyof X] extends [never]`
238
+ * "empty registry" probe; in real consumer apps the registries
239
+ * are populated and the open index signature drops out.
240
+ */
241
+ type TagLayerStylesBag = [keyof RegisteredStyleProps] extends [never] ? Record<string, unknown> : Partial<HTMLAttributes<HTMLElement>> & { [K in keyof RegisteredStyleProps]?: StylePropValue<K> | `[${string}]` | (string & {}) } & { [K in keyof RegisteredCompositeStyles]?: CompositeValue<K> };
242
+ type BaseLayerStyles<TLayer> = TLayer extends ComponentDefinition<infer InnerLayers, infer InnerProps, infer InnerTag> ? Partial<Props<ComponentDefinition<InnerLayers, InnerProps, InnerTag>>> : TagLayerStylesBag & RegisteredModifiers<TagLayerStylesBag>;
157
243
  /**
158
244
  * Component prop surface without modifiers — the "base" type that
159
- * `Props<TConfig>` wraps with `RegisteredModifiers<PropsBase<TConfig>>`.
245
+ * `Props<TDef>` wraps with `RegisteredModifiers<PropsBase<TDef>>`.
160
246
  *
161
- * Splitting the modifier layer out breaks a self-reference cycle:
162
- * TS can resolve `RegisteredModifiers<PropsBase<TConfig>>` because
247
+ * Splitting the modifier layer out breaks a self-reference cycle: TS
248
+ * can resolve `RegisteredModifiers<PropsBase<TDef>>` because
163
249
  * PropsBase doesn't reference itself, but
164
- * `RegisteredModifiers<Props<TConfig>>` directly inside `Props<TConfig>`
250
+ * `RegisteredModifiers<Props<TDef>>` directly inside `Props<TDef>`
165
251
  * leaves TS unable to materialize the recursive shape and the
166
252
  * modifier keys collapse to nothing at consumer call sites.
253
+ */
254
+ /**
255
+ * Effective root tag for `PropsBase`. Resolution order:
167
256
  *
168
- * Modifier values consequently autocomplete against the component's
169
- * full top-level surface but don't carry recursive modifier nesting
170
- * (`_hover={{ _focus: { ... } }}` won't typecheck through this path).
171
- * Codegen-emitted `Registered${Name}Props` keeps the recursive shape
172
- * because it self-references through a *named* alias the compiler
173
- * can name-resolve lazily `Props<TConfig>` can't replicate that.
174
- */
175
- type PropsBase<TConfig extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined>> = TConfig extends ComponentConfigValue<infer TLayers extends Record<string, LayerInput>, infer TProps extends Record<string, PropBinding>, infer TTag extends HtmlTag | undefined> ? PropsFromConfig<TProps, TLayers> & Omit<ComposedRootProps<TLayers>, keyof TProps> & Omit<ElementProps<TTag>, keyof TProps | keyof ComposedRootProps<TLayers>> & DataAttrs & {
257
+ * 1. `defaultProps.as` value-extend chains thread the polymorphic
258
+ * tag here (`defineComponent(Box).config({ defaultProps: { as:
259
+ * 'input' } })` makes `Input`'s JSX surface `<input>`-shaped).
260
+ * 2. Explicit `TTag` from the def's third generic — set when a chain
261
+ * captures the tag literal directly into the synthesized
262
+ * `ComponentDefinition<..., ..., TTag>`. Falls back when the def's
263
+ * `TTag` is the wide default `string | undefined`.
264
+ * 3. `RootTag<TLayers>` derived from the root layer (bare-tag string
265
+ * `'div'`, `TagRef<'a'>`, `{ tag: 'a', ... }`, or an inner
266
+ * definition's captured tag).
267
+ */
268
+ type EffectiveTag<TDef, TTag, TLayers> = TDef extends {
269
+ defaultProps: {
270
+ as: infer A extends keyof JSX.IntrinsicElements;
271
+ };
272
+ } ? A : string extends TTag ? RootTag<TLayers> : [TTag] extends [undefined] ? RootTag<TLayers> : TTag extends string ? TTag : RootTag<TLayers>;
273
+ type PropsBase<TDef extends ComponentDefinition<Record<string, LayerInput>, Record<string, PropBinding>, string | undefined>> = TDef extends ComponentDefinition<infer TLayers extends Record<string, LayerInput>, infer TProps extends Record<string, PropBinding>, infer TTag extends string | undefined> ? PropsFromBindings<TProps, TLayers> & Omit<ComposedRootProps<TLayers>, keyof TProps | 'children'> & Omit<ElementProps<EffectiveTag<TDef, TTag, TLayers>>, keyof TProps | keyof ComposedRootProps<TLayers>> & DataAttrs & {
176
274
  as?: keyof JSX.IntrinsicElements;
177
275
  layerProps?: LayerPropsMap<TLayers>;
178
276
  } : never;
179
277
  /**
180
278
  * Public derived-props type.
181
279
  *
182
- * Layers — same shape codegen emits for `Registered${Name}Props` in
183
- * `uds-env.d.ts` so `React.ComponentProps<typeof Box>` resolves to a
184
- * type structurally equivalent to `RegisteredBoxProps<'div'>`:
280
+ * Layers:
281
+ * 1. `PropsFromBindings<TProps, TLayers>` config-declared props.
282
+ * 2. `ComposedRootProps<TLayers>` the wrapped component's prop
283
+ * surface when the root layer is a `ComponentDefinition` value,
284
+ * minus `children` (a multi-layer component must declare its own
285
+ * content slot rather than inherit the root's).
286
+ * 3. `ElementProps<TTag>` — native HTML attrs narrowed to the root
287
+ * tag (or the wrapper's `defaultProps.as` for value-extends).
288
+ * Anything colliding with (1) or (2) is stripped out.
289
+ * 4. `DataAttrs` — permissive `data-*` index signature.
290
+ * 5. `RegisteredModifiers<PropsBase<TDef>>` — narrowed `_<modifier>`
291
+ * keys with `Partial<...>` values. Augmented by codegen.
292
+ * 6. Polymorphic `as` prop.
185
293
  *
186
- * 1. `PropsFromConfig<TConfig['props']>` the config's declared props.
187
- * 2. `ComposedRootProps<TLayers>` the wrapped component's registered
188
- * prop shape when the root layer is a ComposedLayer
189
- * (`{ component: '{Box}' }`). Falls back to `{}` otherwise.
190
- * 3. `Omit<ComponentPropsWithRef<TTag>, ...>` native attrs narrowed
191
- * to the root tag (or the wrapper's `defaultProps.as` for value-
192
- * extends — captured as TTag at defineComponent time). Anything
193
- * colliding with (1) or (2) is stripped out.
194
- * 4. `DataAttrs` permissive `data-*` index signature (React's
195
- * `ComponentPropsWithRef` doesn't carry this).
196
- * 5. `RegisteredModifiers<PropsBase<TConfig>>` narrowed
197
- * `_<modifier>` keys with `Partial<...>` values. Augmented by
198
- * codegen from `BUILT_IN_PSEUDO` + config-defined modes + custom
199
- * modifiers.
200
- * 6. Polymorphic `as` prop `keyof JSX.IntrinsicElements` so the
201
- * value is a real tag name, matching codegen's emission.
202
- */
203
- type Props<TConfig extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined>> = Prettify<PropsBase<TConfig> & RegisteredModifiers<PropsBase<TConfig>>>;
204
- /**
205
- * `Props<typeof boxConfig>` for the common 'use the config's inferred
206
- * type' invocation. Keeps `box.tsx` from having to repeat the generic.
207
- */
208
- type PropsOf<TConfig> = TConfig extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined> ? Props<TConfig> : never; //#endregion
294
+ * The first conditional short-circuits to a permissive shape when
295
+ * `TDef` is too wide (no concrete `layers` map yet). Without this,
296
+ * the eagerly-evaluated `ComponentBuilder<{layers: L}>` at the
297
+ * `defineComponent.layers` static-method declaration sometimes
298
+ * pushes the TS inference budget over the "union too complex" wall
299
+ * during package-wide typechecks (`@uds/codegen` builds saw this
300
+ * at `factories.ts:853`).
301
+ */
302
+ type Props<TDef extends ComponentDefinition<Record<string, LayerInput>, Record<string, PropBinding>, string | undefined>> = TDef extends {
303
+ layers: Record<string, LayerInput>;
304
+ } ? Record<string, LayerInput> extends TDef['layers'] ? PermissiveProps : Prettify<PropsBase<TDef> & RegisteredModifiers<PropsBase<TDef>>> : PermissiveProps;
305
+ /**
306
+ * Permissive prop bag used as the bail-out shape when `Props<TDef>`
307
+ * can't narrow against a concrete `layers` map (mirrors the
308
+ * `FC<any>` slot the pre-Props builder used to carry).
309
+ */
310
+ type PermissiveProps = HTMLAttributes<HTMLElement> & DataAttrs & Record<string, any> & {
311
+ as?: keyof JSX.IntrinsicElements;
312
+ };
313
+ /**
314
+ * `Props<typeof boxConfig>` for the common 'use the definition's inferred
315
+ * type' invocation. Keeps consumers from having to repeat the generic.
316
+ */
317
+ //#endregion
209
318
  //#endregion
210
- export { Props, PropsOf };
319
+ export { BaseLayerStyles, DataAttrs, LayerPropsMap, LayerTag, Props, PropsFromBindings, SlotPropValue };
@@ -0,0 +1,21 @@
1
+ import { FC, ReactNode } from "react";
2
+
3
+ //#region ../config/dist/Provider.d.ts
4
+ //#region src/Provider.d.ts
5
+ declare class Provider {
6
+ readonly name: string;
7
+ readonly component: FC<{
8
+ children: ReactNode;
9
+ }>;
10
+ constructor(args: {
11
+ name: string;
12
+ component: FC<{
13
+ children: ReactNode;
14
+ }>;
15
+ });
16
+ toJSON(): {
17
+ name: string;
18
+ };
19
+ } //#endregion
20
+ //#endregion
21
+ export { Provider };
@@ -0,0 +1,14 @@
1
+ //#region ../config/dist/Provider.js
2
+ var Provider = class {
3
+ name;
4
+ component;
5
+ constructor(args) {
6
+ this.name = args.name;
7
+ this.component = args.component;
8
+ }
9
+ toJSON() {
10
+ return { name: this.name };
11
+ }
12
+ };
13
+ //#endregion
14
+ export { Provider };
@@ -0,0 +1,113 @@
1
+ import { AnyStylePropDefinition, ArbitraryEntry, ArbitrarySpec, OpacityPairSpec, StylePropMetadata, StylePropProperty, TokenType } from "./types.js";
2
+ import { Token } from "./Token.js";
3
+
4
+ //#region ../config/dist/StyleProp.d.ts
5
+ //#region src/StyleProp.d.ts
6
+ type StorageValuesEntry = NonNullable<AnyStylePropDefinition['values']>[number];
7
+ type StyleTokenLookup = (groupName: string) => Iterable<Token>;
8
+ declare class StyleProp {
9
+ #private;
10
+ readonly name: string;
11
+ readonly cssProperty: StylePropProperty | readonly StylePropProperty[];
12
+ readonly classPrefix: string;
13
+ readonly values: readonly StorageValuesEntry[];
14
+ readonly arbitrary?: ArbitrarySpec | readonly ArbitraryEntry[];
15
+ /**
16
+ * When true, the prop emits its value negated (`calc(<value> * -1)`) — the
17
+ * single source of negativity, read by the emitter, the runtime injector,
18
+ * and the MCP/guidance/lint. See {@link StylePropDefinition.negative}.
19
+ */
20
+ readonly negative: boolean;
21
+ readonly cssType?: TokenType;
22
+ readonly metadata: StylePropMetadata;
23
+ readonly opacityPair?: OpacityPairSpec;
24
+ /**
25
+ * Optional value→CSS adapter (`gridTemplateColumns`'s `4` →
26
+ * `repeat(4, minmax(0, 1fr))`). Applied to enumerated `values` when deriving
27
+ * the utility-class body, so the native emitter produces real CSS without a
28
+ * Tailwind built-in. Keyword strings (`'none'`) pass through unchanged.
29
+ */
30
+ readonly transform?: (value: string | number) => string;
31
+ /**
32
+ * Build the utility-class name a style prop emits for a given
33
+ * JSX-level value. Single source of truth shared by codegen
34
+ * (`@utility` emission), loader (build-time class derivation), and
35
+ * the runtime renderer — all three must agree byte-for-byte.
36
+ *
37
+ * Conventions (the `prefix` namespaces the whole utility body the same
38
+ * way component classes and CSS variables are namespaced; empty prefix
39
+ * yields the bare form):
40
+ * - `classPrefix === ''` → the value IS the class body (`display="block"`
41
+ * → `.yos-block`).
42
+ * - Boolean `true` → bare `classPrefix` body (`<Box border>` →
43
+ * `.yos-border`, never `.border-true`). Falsy → `undefined` (caller
44
+ * omits the class).
45
+ * - Bracketed arbitrary values (`'[#abc]'`) pass through verbatim.
46
+ * - Otherwise `${classPrefix}-${safeTokenName(value)}` where
47
+ * safeTokenName maps `.` → `_` and `/` → `-`.
48
+ *
49
+ * Static so callers without a StyleProp instance (loader's
50
+ * className builder, codegen's safelist scanner) can derive a class
51
+ * from just the prefix + value pair. Instance callers reach
52
+ * `styleProp.classNameFor(value)`, which supplies the owning Config's
53
+ * prefix automatically.
54
+ */
55
+ static classNameFor(styleProp: {
56
+ classPrefix: string;
57
+ }, value: unknown, prefix?: string): string | undefined;
58
+ /** Instance form of {@link StyleProp.classNameFor} — supplies the owning
59
+ * Config's class-name prefix. */
60
+ classNameFor(value: unknown): string | undefined;
61
+ /** The `classPrefix` namespaced with the owning Config's prefix
62
+ * (`bg` → `yos-bg`). The wildcard `@utility` emitter needs the
63
+ * prefixed stem (`yos-bg-*`) since it has no concrete value to run
64
+ * through {@link classNameFor}. Empty when this prop has no class
65
+ * prefix (value-as-class props emit no wildcard utility). */
66
+ get prefixedClassPrefix(): string;
67
+ constructor(args: {
68
+ name: string;
69
+ definition: AnyStylePropDefinition;
70
+ tokenLookup: StyleTokenLookup;
71
+ prefixGetter?: () => string;
72
+ });
73
+ get derived(): {
74
+ readonly keywords: ReadonlyMap<string | number | boolean, string | Record<string, string>>;
75
+ readonly tokens: readonly Token[];
76
+ };
77
+ /**
78
+ * Token-group namespaces this prop consumes. Used by
79
+ * `TokenGroup.derived.styleProperties` to answer the reverse question.
80
+ */
81
+ consumedTokenGroups(): readonly string[];
82
+ /**
83
+ * The values this prop accepts, split by how each is written at the JSX site:
84
+ * - `tokens` — token names from the prop's token groups (`gap="2"`).
85
+ * - `keywords` — literal CSS keywords written verbatim (`display="flex"`).
86
+ * - `aliases` — short keys resolving to a CSS keyword (`flexDirection="col"`
87
+ * → `column`).
88
+ * A bracketed `[...]` arbitrary literal is governed by `this.arbitrary`, not
89
+ * enumerated here. Rendered by `uds_get_style_prop` / `uds_list_style_props`;
90
+ * `accepts()` validates against the same set.
91
+ */
92
+ allowedValues(): {
93
+ tokens: readonly string[];
94
+ keywords: readonly string[];
95
+ aliases: readonly {
96
+ alias: string;
97
+ value: string;
98
+ }[];
99
+ };
100
+ /**
101
+ * Whether a JSX-site value is accepted: a token name, a literal keyword, an
102
+ * alias key, or a bracketed `[...]` literal when the prop enables `arbitrary`
103
+ * values. The validation primitive behind `uds_validate_props` — a non-token
104
+ * keyword prop (`display`) and an arbitrary-only prop (`fontSize`) both work,
105
+ * not just token-group props.
106
+ */
107
+ accepts(value: string): boolean;
108
+ toJSON(): AnyStylePropDefinition & {
109
+ name: string;
110
+ };
111
+ } //#endregion
112
+ //#endregion
113
+ export { StyleProp };