@yahoo/uds-create-config 1.1.1

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