@yahoo/uds-v5-wip 1.37.1 → 1.39.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 (40) hide show
  1. package/dist/config/dist/Props.d.ts +74 -0
  2. package/dist/config/dist/component-config.d.ts +201 -0
  3. package/dist/config/dist/component-refs.d.ts +98 -0
  4. package/dist/config/dist/component-resolution.d.ts +1 -1
  5. package/dist/config/dist/consts/defaultColors.d.ts +2 -1
  6. package/dist/config/dist/createComponent.d.ts +1 -0
  7. package/dist/config/dist/createComponent.js +1 -0
  8. package/dist/config/dist/createConfig.d.ts +50 -2
  9. package/dist/config/dist/createConfig.js +9 -0
  10. package/dist/config/dist/defineComponent.d.ts +24 -1
  11. package/dist/config/dist/defineComponent.js +2 -0
  12. package/dist/config/dist/defineStyleProp.d.ts +12 -1
  13. package/dist/config/dist/index.d.ts +7 -3
  14. package/dist/config/dist/index.js +3 -1
  15. package/dist/config/dist/resolveStyleProp.d.ts +15 -1
  16. package/dist/config/dist/resolveStyleProp.js +28 -0
  17. package/dist/config/dist/serialize.d.ts +2 -1
  18. package/dist/config/dist/types/css-values.d.ts +2 -1
  19. package/dist/config/dist/types.d.ts +2 -1
  20. package/dist/config.d.ts +185 -185
  21. package/dist/foundational-presets/dist/boldVibrant.d.ts +353 -352
  22. package/dist/foundational-presets/dist/brutalist.d.ts +353 -352
  23. package/dist/foundational-presets/dist/candy.d.ts +353 -352
  24. package/dist/foundational-presets/dist/cleanMinimalist.d.ts +353 -352
  25. package/dist/foundational-presets/dist/corporate.d.ts +353 -352
  26. package/dist/foundational-presets/dist/darkMoody.d.ts +353 -352
  27. package/dist/foundational-presets/dist/defaultPreset.d.ts +185 -184
  28. package/dist/foundational-presets/dist/forest.d.ts +353 -352
  29. package/dist/foundational-presets/dist/highContrast.d.ts +353 -352
  30. package/dist/foundational-presets/dist/lavender.d.ts +353 -352
  31. package/dist/foundational-presets/dist/luxury.d.ts +353 -352
  32. package/dist/foundational-presets/dist/monochrome.d.ts +353 -352
  33. package/dist/foundational-presets/dist/neonCyber.d.ts +353 -352
  34. package/dist/foundational-presets/dist/newspaper.d.ts +353 -352
  35. package/dist/foundational-presets/dist/ocean.d.ts +353 -352
  36. package/dist/foundational-presets/dist/slate.d.ts +353 -352
  37. package/dist/loader/dist/loader.d.ts +1 -2
  38. package/dist/loader/dist/next.d.ts +1 -2
  39. package/dist/tsconfig.tsbuildinfo +1 -1
  40. package/package.json +3 -3
@@ -0,0 +1,74 @@
1
+ import { RegisteredStyleProps } from "./component-refs.js";
2
+ import { ComponentConfigValue, HtmlTag, LayerInput, PropBinding } from "./component-config.js";
3
+ import { ComponentPropsWithoutRef, HTMLAttributes, JSX } from "react";
4
+
5
+ //#region ../config/dist/Props.d.ts
6
+ //#region src/Props.d.ts
7
+ /**
8
+ * Resolve the native HTML-attribute surface for the config's root tag.
9
+ *
10
+ * - When `TTag` is a known `JSX.IntrinsicElements` key (`'a'`, `'div'`,
11
+ * `'button'`, …), use `ComponentPropsWithoutRef<TTag>` so element-
12
+ * specific attrs land in the prop type (`href` on `'a'`, `disabled`
13
+ * on `'button'`, etc.).
14
+ * - Otherwise (no tag captured — e.g. the root is a brace-ref or
15
+ * composed-layer), fall back to the generic `HTMLAttributes<HTMLElement>`.
16
+ */
17
+ type ElementProps<TTag extends HtmlTag | undefined> = TTag extends keyof JSX.IntrinsicElements ? ComponentPropsWithoutRef<TTag> : HTMLAttributes<HTMLElement>;
18
+ /**
19
+ * Resolve the allowed-value union for one registered style prop.
20
+ * Falls back to `string` when the prop registered no tokens (codegen
21
+ * emits `never` for that case).
22
+ */
23
+ type StylePropValue<K extends keyof RegisteredStyleProps> = [RegisteredStyleProps[K]] extends [never] ? string : RegisteredStyleProps[K];
24
+ /**
25
+ * Extract the registered style-prop name from a binding value:
26
+ * - `'{bg}'` → `'bg'`
27
+ * - `{ styleProp: '{bg}' }` → `'bg'`
28
+ * Returns `never` for non-matching forms.
29
+ */
30
+ type StylePropRefName<TBinding> = TBinding extends `{${infer N}}` ? N extends keyof RegisteredStyleProps & string ? N : never : TBinding extends {
31
+ styleProp: `{${infer N}}`;
32
+ } ? N extends keyof RegisteredStyleProps & string ? N : never : never;
33
+ /**
34
+ * Walk the config's `props` block and produce one optional JSX prop
35
+ * per entry.
36
+ */
37
+ type PropsFromConfig<TProps> = { [K in keyof TProps]?: StylePropRefName<TProps[K]> extends never ? unknown : StylePropValue<Extract<StylePropRefName<TProps[K]>, keyof RegisteredStyleProps>> };
38
+ /**
39
+ * Force TypeScript to fully evaluate a mapped/conditional type so the
40
+ * hover display shows the resolved shape (`bg?: 'brand' | 'accent'`)
41
+ * instead of the unevaluated type expression
42
+ * (`PropsFromConfig<{ readonly bg: '{bg}' }>`).
43
+ */
44
+ type Prettify<T> = { [K in keyof T]: T[K] } & {};
45
+ /**
46
+ * Standard `data-*` attributes are valid on every HTML element by spec.
47
+ * React 19's bundled types don't carry an index signature for them, so
48
+ * we add one here — keeps `<Box data-test="x" />` valid without forcing
49
+ * authors to register every test attribute as a config-declared prop.
50
+ */
51
+ interface DataAttrs {
52
+ [key: `data-${string}`]: unknown;
53
+ }
54
+ /**
55
+ * Public derived-props type.
56
+ *
57
+ * Four layers:
58
+ * 1. `PropsFromConfig<TConfig['props']>` — the config's declared props.
59
+ * 2. `ElementProps<TTag>` — native attrs narrowed to the root tag when
60
+ * statically known (e.g. `href` on `'a'`), otherwise generic
61
+ * `HTMLAttributes<HTMLElement>`. Anything colliding with (1) is
62
+ * stripped out so custom props' value unions don't get widened.
63
+ * 3. `DataAttrs` — permissive `data-*` index signature.
64
+ * 4. Polymorphic `as` prop (open-ended `string` for now).
65
+ */
66
+ type Props<TConfig extends ComponentConfigValue<Record<string, LayerInput>, Record<string, PropBinding>, HtmlTag | undefined>> = TConfig extends ComponentConfigValue<Record<string, LayerInput>, infer TProps extends Record<string, PropBinding>, infer TTag extends HtmlTag | undefined> ? Prettify<PropsFromConfig<TProps> & Omit<ElementProps<TTag>, keyof TProps> & DataAttrs & {
67
+ as?: string;
68
+ }> : never;
69
+ /**
70
+ * `Props<typeof boxConfig>` for the common 'use the config's inferred
71
+ * type' invocation. Keeps `box.tsx` from having to repeat the generic.
72
+ */
73
+ //#endregion
74
+ export { Props };
@@ -0,0 +1,201 @@
1
+ import { ComponentRef, CompositeRef, RegisteredComponents, StylePropRef } from "./component-refs.js";
2
+ import { ReactNode } from "react";
3
+
4
+ //#region ../config/dist/component-config.d.ts
5
+ //#region src/component-config.d.ts
6
+ /**
7
+ * HTML tag literal. The TypeScript type is `string` (any tag name);
8
+ * runtime renders it via `React.createElement(tag, ...)`.
9
+ *
10
+ * Kept as `string` instead of `keyof JSX.IntrinsicElements` so the type
11
+ * doesn't pull a 200-key union into every layer position. Editors still
12
+ * autocomplete tag names from JSX.
13
+ */
14
+ type HtmlTag = string;
15
+ /**
16
+ * Object form for a primitive (HTML-tag) layer that needs locked attrs
17
+ * or default CSS-property values.
18
+ */
19
+ interface PrimitiveLayer {
20
+ tag: HtmlTag;
21
+ /** HTML attributes always applied to this layer (e.g. `role="alert"`). */
22
+ attrs?: Record<string, unknown>;
23
+ /** Default style-prop values for this layer. */
24
+ defaultProps?: Record<string, unknown>;
25
+ }
26
+ /**
27
+ * Object form for a layer that's a composed React component (registered
28
+ * via `.registerComponents({...})`). The `component` field is a brace-ref
29
+ * narrowed against `RegisteredComponents`. `defaultProps` is narrowed
30
+ * per-component so authors can only pass props the referenced component
31
+ * actually accepts.
32
+ *
33
+ * Codegen emits `RegisteredComponents[K]` as the component's resolved
34
+ * prop shape (e.g. `{ backgroundColor: RegisteredStyleProps['bg']; … }`).
35
+ * `Partial<RegisteredComponents[K]>` lets `defaultProps` narrow against
36
+ * that shape. Without registered components, the union is `never` (so
37
+ * package-internal authoring sites don't have to deal with this shape).
38
+ */
39
+ type ComposedLayer = { [K in keyof RegisteredComponents & string]: {
40
+ component: `{${K}}`;
41
+ defaultProps?: Partial<RegisteredComponents[K]>;
42
+ } }[keyof RegisteredComponents & string];
43
+ /**
44
+ * Allowed forms for a single layer's value. Authors usually pick the
45
+ * shorthand (a bare tag string or a brace-ref); the object forms exist
46
+ * for the cases that need `attrs` or `defaultProps`.
47
+ */
48
+ type LayerInput = HtmlTag | ComponentRef | PrimitiveLayer | ComposedLayer;
49
+ /**
50
+ * Bind a registered style prop to a specific layer. The style prop's
51
+ * resolved class name is added to that layer's `className` bundle at
52
+ * render time.
53
+ *
54
+ * `styleProp` is narrowed against `RegisteredStyleProps`. `layer` is a
55
+ * string at this level — the consuming type (`ComponentConfig.props`)
56
+ * narrows it against the component's own `layers` keys.
57
+ */
58
+ interface StylePropBinding {
59
+ layer: string;
60
+ styleProp: StylePropRef;
61
+ }
62
+ /**
63
+ * Extract the root tag literal from a `layers` map when it can be read
64
+ * statically. Returns the string literal `'a' | 'div' | …` when:
65
+ *
66
+ * - `layers.root` is a bare tag string (`'a'`), or
67
+ * - `layers.root` is `{ tag: 'a', attrs?: … }`.
68
+ *
69
+ * Returns `undefined` when `layers.root` is a brace-ref (`'{Box}'`), a
70
+ * `{ component: '{Box}' }` form, or not present. `Props<TConfig>` reads
71
+ * this and substitutes `React.ComponentPropsWithoutRef<TTag>` for the
72
+ * generic `HTMLAttributes<HTMLElement>` when narrowable.
73
+ */
74
+ type RootTag<TLayers> = TLayers extends {
75
+ root: infer R;
76
+ } ? R extends HtmlTag ? R extends `{${string}}` ? undefined : R : R extends {
77
+ tag: infer T extends HtmlTag;
78
+ } ? T : undefined : undefined;
79
+ /**
80
+ * Bind a registered composite to a single layer. Multi-layer composites
81
+ * use the `CompositeBinding` shape instead (see below).
82
+ */
83
+ interface SingleLayerCompositeBinding {
84
+ layer: string;
85
+ composite: CompositeRef;
86
+ }
87
+ /**
88
+ * Multi-layer composite binding — explicit composite-layer → component-
89
+ * layer mapping. The composite declares its own internal layer names
90
+ * (`default`, `label`, …) and this binding tells the framework which
91
+ * component layer each one maps to.
92
+ */
93
+ interface CompositeBinding {
94
+ composite: CompositeRef;
95
+ layers: Record<string, string>;
96
+ }
97
+ /**
98
+ * Forward an existing surface key from one of the component's layers as
99
+ * a public JSX prop. If the target layer is a primitive, `from` is an
100
+ * HTML attr / event name; if it's a composed component, `from` is one
101
+ * of that component's existing props.
102
+ *
103
+ * `from` is a bare string (no braces) — the leading-brace check on the
104
+ * binding shape's `from` is how the framework dispatches "bind a
105
+ * registered thing" vs "forward an existing surface key".
106
+ */
107
+ interface SurfaceForward {
108
+ layer: string;
109
+ from: string;
110
+ }
111
+ /**
112
+ * Boolean prop — toggled on/off, no value beyond presence. Useful for
113
+ * `loading`, `disabled`, `selected`. Each layer's bundle gets a
114
+ * data-attribute (`data-loading="true"`) the consumer can target.
115
+ */
116
+ interface BoolMarker {
117
+ readonly __kind: 'bool';
118
+ }
119
+ /**
120
+ * Enum prop — the value picks one entry from a map. Each entry can
121
+ * declare per-layer style overrides. Mirrors today's `variants.X`
122
+ * surface but co-located with other prop bindings.
123
+ */
124
+ interface EnumMarker<TValues extends Record<string, unknown>> {
125
+ readonly __kind: 'enum';
126
+ readonly values: TValues;
127
+ }
128
+ /**
129
+ * Shorthand binding form — a brace-ref string standing in for the
130
+ * verbose object. `'{bg}'` means "bind the registered style prop `bg`
131
+ * to the *root* layer".
132
+ *
133
+ * Only legal in the primitive form `defineComponent('div', { props: { bg: '{bg}' } })`,
134
+ * where the root layer is unambiguous. In the verbose form
135
+ * `defineComponent({ layers: {...}, props: {...} })` authors must use
136
+ * the explicit long-form `{ layer, styleProp: '{bg}' }` binding so
137
+ * the target layer is named at the call site.
138
+ */
139
+ type StylePropShorthand = StylePropRef;
140
+ /**
141
+ * All allowed shapes for a single entry in the verbose form's `props`
142
+ * block. Verbose form (with explicit `layers`) requires the long-form
143
+ * `{ layer, styleProp }` binding — no shorthand. The shorthand
144
+ * `'{bg}'` is allowed only in the primitive form's props (see
145
+ * `PrimitivePropBinding`).
146
+ */
147
+ type VerbosePropBinding = StylePropBinding | SingleLayerCompositeBinding | CompositeBinding | SurfaceForward | BoolMarker | EnumMarker<any>;
148
+ /**
149
+ * All allowed shapes for a single entry in the primitive form's `props`
150
+ * block. Primitive form adds the `StylePropShorthand` brace-ref
151
+ * (`'{bg}'`) on top of every verbose form — the root layer is
152
+ * unambiguous so the shorthand resolves trivially.
153
+ */
154
+ type PrimitivePropBinding = StylePropShorthand | VerbosePropBinding;
155
+ /**
156
+ * Union of every legal prop-binding shape across both forms. Read-side
157
+ * helpers (`Props<TConfig>`, runtime resolution) accept this widest
158
+ * union; authoring-side input types (`ComponentConfigInput`) take the
159
+ * tighter `VerbosePropBinding`.
160
+ */
161
+ type PropBinding = PrimitivePropBinding;
162
+ /**
163
+ * Marker for a boolean JSX prop. Use inside the `props` block:
164
+ *
165
+ * props: {
166
+ * loading: bool(),
167
+ * disabled: bool(),
168
+ * }
169
+ */
170
+ /**
171
+ * Branded shape returned by `defineComponent({...})`. Carries `layers`,
172
+ * `props`, AND a phantom `__tag` slot as const-narrowed types so
173
+ * downstream type-only imports (`import type { AlertConfig } from
174
+ * './alert.config'`) thread the full shape through to
175
+ * `Props<typeof config>` — per-prop literal binding values (e.g.
176
+ * `'{bg}'`) survive for `Props<TConfig>` to resolve against
177
+ * `RegisteredStyleProps`, and the root tag survives for HTML-attribute
178
+ * narrowing via `React.ComponentPropsWithoutRef<TTag>`.
179
+ *
180
+ * `__tag` is a *phantom* type slot — there is no runtime field. It's
181
+ * derived from either the primitive-form first arg (`defineComponent('a',
182
+ * …)`) or from `layers.root` via `RootTag<TLayers>` for the verbose form.
183
+ * When the root isn't a literal tag (brace-ref / composed layer), it's
184
+ * `undefined` and `Props<TConfig>` falls back to `HTMLAttributes<HTMLElement>`.
185
+ *
186
+ * The component's name is supplied at registration time, not here.
187
+ */
188
+ interface ComponentConfigValue<TLayers extends Record<string, LayerInput>, TProps extends Record<string, PropBinding> = Record<string, PropBinding>, TTag extends HtmlTag | undefined = RootTag<TLayers>> {
189
+ readonly __kind: 'componentConfig';
190
+ readonly __tag?: TTag;
191
+ readonly layers: TLayers;
192
+ readonly props?: TProps;
193
+ readonly defaultProps?: Record<string, unknown>;
194
+ }
195
+ /**
196
+ * The bundle passed to the render function for each layer — a ready-to-
197
+ * spread object with `className` and any forwarded attrs. The render
198
+ * function destructures `props.<layerName>` into the JSX position.
199
+ */
200
+ //#endregion
201
+ export { BoolMarker, ComponentConfigValue, ComposedLayer, CompositeBinding, EnumMarker, HtmlTag, LayerInput, PrimitiveLayer, PrimitivePropBinding, PropBinding, RootTag, SingleLayerCompositeBinding, StylePropBinding, StylePropShorthand, SurfaceForward, VerbosePropBinding };
@@ -0,0 +1,98 @@
1
+ //#region ../config/dist/component-refs.d.ts
2
+ //#region src/component-refs.d.ts
3
+ /**
4
+ * Augmentable registries + template-literal ref types for the
5
+ * component-API surface.
6
+ *
7
+ * Codegen runs `uds build` and populates the four interfaces below in
8
+ * each consumer app's `.uds/uds-env.d.ts`. The template-literal types
9
+ * derived from them narrow brace-ref strings against what's actually
10
+ * registered — `'{Box}'` typechecks only if `Box` is a real
11
+ * `RegisteredComponents` key, `'{bg}'` only if `bg` is a real
12
+ * `RegisteredStyleProps` key, etc.
13
+ *
14
+ * Without the augmentation loaded (e.g. inside `@uds/config`'s own
15
+ * test files), each registry is `{}` and the corresponding ref type
16
+ * collapses to `never`. Helpers downstream are expected to fail open
17
+ * in that case so package-internal authoring sites don't all error.
18
+ */
19
+ /**
20
+ * Registered components. Each key is the component name (the brace-ref
21
+ * identifier — `'{Box}'`); each value is the component's resolved prop
22
+ * shape, e.g.
23
+ *
24
+ * export interface RegisteredComponents {
25
+ * Box2: {
26
+ * backgroundColor: RegisteredStyleProps['bg'];
27
+ * color: RegisteredStyleProps['color'];
28
+ * };
29
+ * Spinner: {};
30
+ * }
31
+ *
32
+ * Composed layers use `Partial<RegisteredComponents[K]>` on
33
+ * `defaultProps` for type-safe completion when nesting components
34
+ * inside other components' configs.
35
+ *
36
+ * Populated by codegen from `uds.config.ts`'s `.registerComponents({...})`
37
+ * call.
38
+ */
39
+ interface RegisteredComponents {}
40
+ /**
41
+ * Registered style props. Key is the JSX prop name (the brace-ref
42
+ * identifier — `'{bg}'`); value is the string-literal union of
43
+ * allowed token names for that prop, e.g.
44
+ *
45
+ * export interface RegisteredStyleProps {
46
+ * bg: 'brand' | 'accent' | 'primary';
47
+ * color: 'brand' | 'on-brand';
48
+ * }
49
+ *
50
+ * Components reference these directly when wiring JSX-prop types:
51
+ * `bg?: RegisteredStyleProps['bg']`. Downstream `Props<TConfig>`
52
+ * resolves the shorthand `'{bg}'` against this map.
53
+ *
54
+ * Populated by codegen from `uds.config.ts`'s `.registerStyleProps({...})`
55
+ * call. A `never` value means the prop registered no tokens
56
+ * (arbitrary-only); the consumer should widen those to `string`.
57
+ */
58
+ interface RegisteredStyleProps {}
59
+ /**
60
+ * Registered composite-style names. Each key is the composite identifier
61
+ * (the brace-ref — `'{elevation}'`, `'{severity}'`); value is `void`.
62
+ *
63
+ * Populated by codegen from `uds.config.ts`'s `.registerComposites({...})`
64
+ * call.
65
+ */
66
+ interface RegisteredComposites {}
67
+ /**
68
+ * Registered motion-preset names. Each key is the preset identifier
69
+ * (`'{fadeIn}'`); value is `void`.
70
+ *
71
+ * Populated by codegen from `uds.config.ts`'s `.defineMotion({...})`
72
+ * (motion has no separate `.registerMotion` step today; the entries
73
+ * come directly from `defineMotion` keys).
74
+ */
75
+ /**
76
+ * Brace-wrapped reference to a registered React component. Falls open
77
+ * to `'{${string}}'` when the registry is unaugmented (e.g. inside
78
+ * `@uds/config`'s own tests, where codegen hasn't populated the
79
+ * interface). Consumer apps load the codegen-emitted augmentation and
80
+ * get narrow `'{Box}' | '{Text}' | …` autocomplete.
81
+ */
82
+ type ComponentRef = [keyof RegisteredComponents] extends [never] ? `{${string}}` : `{${Extract<keyof RegisteredComponents, string>}}`;
83
+ /**
84
+ * Brace-wrapped reference to a registered style prop. Falls open when
85
+ * unaugmented (see {@link ComponentRef}).
86
+ */
87
+ type StylePropRef = [keyof RegisteredStyleProps] extends [never] ? `{${string}}` : `{${Extract<keyof RegisteredStyleProps, string>}}`;
88
+ /**
89
+ * Brace-wrapped reference to a registered composite style. Falls open
90
+ * when unaugmented.
91
+ */
92
+ type CompositeRef = [keyof RegisteredComposites] extends [never] ? `{${string}}` : `{${Extract<keyof RegisteredComposites, string>}}`;
93
+ /**
94
+ * Brace-wrapped reference to a registered motion preset. Falls open
95
+ * when unaugmented.
96
+ */
97
+ //#endregion
98
+ export { ComponentRef, CompositeRef, RegisteredComponents, RegisteredComposites, RegisteredStyleProps, StylePropRef };
@@ -1 +1 @@
1
- import { ComponentsConfig } from "@uds/types";
1
+ export { };
@@ -1,4 +1,5 @@
1
1
  //#region ../config/dist/consts/defaultColors.d.ts
2
+ //#region src/consts/defaultColors.d.ts
2
3
  declare const defaultColors: {
3
4
  inherit: string;
4
5
  current: string;
@@ -247,6 +248,6 @@ declare const defaultColors: {
247
248
  'rose-800': string;
248
249
  'rose-900': string;
249
250
  'rose-950': string;
250
- };
251
+ }; //#endregion
251
252
  //#endregion
252
253
  export { defaultColors };
@@ -0,0 +1 @@
1
+ import { ReactNode } from "react";
@@ -0,0 +1 @@
1
+ import "react";
@@ -1,9 +1,12 @@
1
+ import { ComponentConfigValue } from "./component-config.js";
2
+ import { BoundComponent } from "./defineComponent.js";
1
3
  import { AnyStyleProp } from "./defineStyleProp.js";
2
- import { ResolvedStyleProp } from "./resolveStyleProp.js";
3
4
  import { TokenType, VarsConfig } from "./types.js";
5
+ import { ResolvedStyleProp } from "./resolveStyleProp.js";
4
6
  import { BaseModifierProp, ComponentsConfig, CompositeStylesConfig, ConfigurableProp, ModifierProp, MotionPreset, RemotionComponentDef, RemotionConfig, RemotionTransitionDef } from "@uds/types";
5
7
 
6
8
  //#region ../config/dist/createConfig.d.ts
9
+ //#region src/createConfig.d.ts
7
10
  type MotionPresetsDef = Record<string, MotionPreset>;
8
11
  type MotionAliasValue<TMotion> = TMotion extends Record<string, infer V> ? Extract<V, string> : never;
9
12
  type EmptyMotion = {};
@@ -76,6 +79,12 @@ type GetModifierFromInput<I extends ModesInput> = { [SetKey in keyof I]: { [OptK
76
79
  } ? M extends ModifierNameShape ? M : never : OptKey extends string ? `_${OptKey}` : never }[keyof I[SetKey]['options']] }[keyof I];
77
80
  /** Reject any input whose derived/explicit modifiers collide with reserved names. */
78
81
  type CheckForReservedModifiersInput<I extends ModesInput> = true extends HasReservedModifier<GetModifierFromInput<I>> ? 'ERROR: Cannot use reserved modifier names from ModifierProp. Please use a different modifier name.' : I;
82
+ /**
83
+ * Convert the authored object-keyed input into the internal `ModeGroup[]` shape.
84
+ * Derives `_${optionKey}` modifiers when no explicit `modifier` is provided.
85
+ * Never sets `default: true` — the new API has no concept of a default option;
86
+ * downstream consumers treat "no option active" as the implicit default.
87
+ */
79
88
  interface ModifierDef {
80
89
  modifier: ModifierNameShape;
81
90
  selector: string;
@@ -155,6 +164,7 @@ type VarsToTokens<TVars extends VarsConfig> = { [K in keyof TVars]: { [T in Excl
155
164
  type MergeTokens<A, B> = { [K in keyof A | keyof B]: K extends keyof B ? K extends keyof A ? A[K] & B[K] : B[K] : K extends keyof A ? A[K] : never };
156
165
  /** Build a structured token reference object from atomic tokens */
157
166
  declare function buildTokenReference(atomic: AtomicToken<ModifierNameShape>[], configPrefix: string): Record<string, Record<string, string>>;
167
+ /** Build a structured composite-styles reference object for use in defineModifiers context */
158
168
  /** Global styles definition — CSS selector → style props */
159
169
  type GlobalStylesDef = Record<string, Record<string, any>>;
160
170
  /** CSS properties for the example wrapper element */
@@ -217,6 +227,17 @@ interface UdsConfigData {
217
227
  * of walking the raw style-prop records.
218
228
  */
219
229
  resolvedStyleProps?: ResolvedStyleProp[];
230
+ /**
231
+ * Components registered via `.registerComponents({...})`. Authored
232
+ * elsewhere via `defineComponent('Name', config)` and imported into
233
+ * the config. The canonical input for codegen + runtime in the new
234
+ * layers-shape architecture.
235
+ *
236
+ * Map keyed by component name (e.g. `Box`, `Alert`); each value is the
237
+ * `ComponentConfigValue` branded record carrying `layers`, `props`,
238
+ * `defaultProps`.
239
+ */
240
+ componentConfigs?: Record<string, ComponentConfigValue<any, any, any>>;
220
241
  }
221
242
  interface ComponentConfig<TComponents extends ComponentsConfig<string> = ComponentsConfig<string>, TMotion extends MotionPresetsDef | undefined = MotionPresetsDef | undefined> {
222
243
  name?: string;
@@ -283,6 +304,29 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
283
304
  * ```
284
305
  */
285
306
  registerStyleProps<const Props extends Record<string, AnyStyleProp>>(props: Props): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
307
+ /**
308
+ * Register components authored with `defineComponent(...)`. Calls
309
+ * accumulate — later `.registerComponents({...})` calls merge into
310
+ * the existing map (later keys overwrite earlier ones with the same
311
+ * name).
312
+ *
313
+ * Accepts either form returned by `defineComponent`:
314
+ * - The pure-data config value from the bare verbose form
315
+ * (`defineComponent({ layers, props })`).
316
+ * - A bound component from the primitive form
317
+ * (`defineComponent('div', { props })`) or the chained
318
+ * `.render(fn)` builder — the framework extracts the underlying
319
+ * config from the non-enumerable `__config` slot.
320
+ *
321
+ * @example
322
+ * ```ts
323
+ * import { Box } from './src/uds/components/box'; // primitive
324
+ * import { alertConfig } from './src/uds/components/alert.config'; // verbose pure-data
325
+ *
326
+ * uds.registerComponents({ Box, Alert: alertConfig });
327
+ * ```
328
+ */
329
+ registerComponents<const TConfigs extends Record<string, ComponentConfigValue<any, any, any> | BoundComponent<ComponentConfigValue<any, any, any>, any>>>(configs: TConfigs): ConfigResult<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars>;
286
330
  defineMotion<const M extends MotionPresetsDef>(presets: M | ((tokens: TTokens) => M)): ConfigResult<TModifier, TTokens, { [K in keyof M]: string }, TExt, TCompositeStyles, TModeModifiers, TVars>;
287
331
  defineComponents(params: ComponentsConfig<MotionAliasValue<TMotion> | string> | ((ctx: {
288
332
  tokens: TTokens;
@@ -313,6 +357,10 @@ interface UdsConfig<TModifier extends ModifierNameShape = ModifierProp, TTokens
313
357
  type AnyUdsConfig = UdsConfig<ModifierNameShape, any, any, any, any, any, any>;
314
358
  /** Extract the raw config data from a builder instance */
315
359
  declare function resolveConfig(config: AnyUdsConfig): UdsConfigData;
360
+ /**
361
+ * Resolve configuration with all token references replaced by their raw values.
362
+ * Useful for tools that need the actual values (e.g. anatomy generation).
363
+ */
316
364
  declare function createConfigBuilder<TModifier extends ModifierNameShape = ModifierProp, TTokens = EmptyTokens, TMotion = EmptyMotion, TExt extends Record<string, any> = {}, TCompositeStyles = EmptyCompositeStyles, TModeModifiers extends ModifierNameShape = never, TVars extends VarsConfig = EmptyVars>(data: UdsConfigData, extensions?: TExt): UdsConfig<TModifier, TTokens, TMotion, TExt, TCompositeStyles, TModeModifiers, TVars> & TExt;
317
365
  interface InterpolateMarker {
318
366
  __type: 'interpolate';
@@ -322,4 +370,4 @@ interface InterpolateMarker {
322
370
  declare function darker(color: string, amount: number): string;
323
371
  declare function lighter(color: string, amount: number): string;
324
372
  //#endregion
325
- export { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig };
373
+ export { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, SingleComponentDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig };
@@ -427,6 +427,15 @@ function createConfigBuilder(data, extensions) {
427
427
  if (data.vars) updates.atomic = mergeAtomic([], synthesizeAtomicFromVarsAndStyleProps(data.vars, mergedStyleProps, data.modes ?? []), "override");
428
428
  return next(updates);
429
429
  },
430
+ registerComponents(configs) {
431
+ const normalized = {};
432
+ for (const [name, entry] of Object.entries(configs)) if (typeof entry === "function" && "__config" in entry) normalized[name] = entry.__config;
433
+ else normalized[name] = entry;
434
+ return next({ componentConfigs: {
435
+ ...data.componentConfigs ?? {},
436
+ ...normalized
437
+ } });
438
+ },
430
439
  defineMotion(presets) {
431
440
  const tokenReference = buildTokenReference(data.atomic, data.prefix);
432
441
  const resolved = typeof presets === "function" ? presets(tokenReference) : presets;
@@ -1 +1,24 @@
1
- export { };
1
+ import { ComponentConfigValue, HtmlTag, LayerInput } from "./component-config.js";
2
+ import { Props } from "./Props.js";
3
+ import { ReactNode } from "react";
4
+
5
+ //#region ../config/dist/defineComponent.d.ts
6
+ //#region src/defineComponent.d.ts
7
+ /**
8
+ * A React component bound to a `defineComponent` config, with the
9
+ * source config attached as a phantom type slot. Tools (codegen,
10
+ * devtools) recover the config at runtime via the non-enumerable
11
+ * `__config` property; the type slot lets consumers read it at the
12
+ * type level too — `Props<typeof Box['__config']>`.
13
+ */
14
+ type BoundComponent<TConfig extends ComponentConfigValue<Record<string, LayerInput>, any, HtmlTag | undefined>, TExtra extends Record<string, unknown> = {}> = React.FC<Props<TConfig> & TExtra> & {
15
+ readonly __config: TConfig;
16
+ };
17
+ /**
18
+ * A `defineComponent({...})` config value with a `.render(fn)` builder
19
+ * method bolted on. The builder is non-enumerable so JSON serialization
20
+ * still produces pure data — codegen can read `__kind`, `layers`,
21
+ * `props`, and `defaultProps` without seeing the render hook.
22
+ */
23
+ //#endregion
24
+ export { BoundComponent };
@@ -0,0 +1,2 @@
1
+ import "./createComponent.js";
2
+ import "react";
@@ -1,4 +1,4 @@
1
- import { CssValue, CssValueTypeName } from "./types/css-values.js";
1
+ import { CssValueTypeName } from "./types/css-values.js";
2
2
 
3
3
  //#region ../config/dist/defineStyleProp.d.ts
4
4
  /** Runtime input type for `toCss` based on the entry's `type`. */
@@ -22,10 +22,20 @@ type ArbitraryEntry = { [T in CssValueTypeName]: {
22
22
  * - An array of {@link ArbitraryEntry} for multi-shape acceptance.
23
23
  */
24
24
  type ArbitrarySpec = CssValueTypeName | readonly ArbitraryEntry[];
25
+ /**
26
+ * The literal-keyword subset of values a property accepts, derived from
27
+ * {@link CssPropertyValues}[P]. For custom CSS properties (`--*`) the value
28
+ * type is governed by the required `cssType` field instead, so any string
29
+ * is accepted at the type level.
30
+ */
25
31
  type StylePropMetadata = {
26
32
  label?: string;
27
33
  description?: string;
28
34
  };
35
+ /**
36
+ * A finalized style prop. Returned by `defineStyleProp(spec).metadata(meta)`.
37
+ * Consumers wrap these in `uds.registerStyleProps({ <propName>: ... })`.
38
+ */
29
39
  /**
30
40
  * Structurally-loose form of {@link StyleProp}. Any concrete `StyleProp<P>`
31
41
  * is assignable to this. Used at registration / resolution boundaries where
@@ -41,5 +51,6 @@ interface AnyStyleProp {
41
51
  readonly cssType?: CssValueTypeName;
42
52
  readonly metadata: StylePropMetadata;
43
53
  }
54
+ /** Intermediate builder — the only callable method is `.metadata()`. */
44
55
  //#endregion
45
56
  export { AnyStyleProp, ArbitraryEntry, ArbitrarySpec, StylePropMetadata };
@@ -1,9 +1,13 @@
1
- import { defaultColors } from "./consts/defaultColors.js";
1
+ import { ComponentRef, CompositeRef, RegisteredComponents, RegisteredComposites, RegisteredStyleProps, StylePropRef } from "./component-refs.js";
2
+ import { BoolMarker, ComponentConfigValue, ComposedLayer, CompositeBinding, EnumMarker, HtmlTag, LayerInput, PrimitiveLayer, PrimitivePropBinding, PropBinding, RootTag, SingleLayerCompositeBinding, StylePropBinding, StylePropShorthand, SurfaceForward, VerbosePropBinding } from "./component-config.js";
3
+ import { Props } from "./Props.js";
4
+ import { BoundComponent } from "./defineComponent.js";
2
5
  import { ColorFn, ColorKeyword, CssAngle, CssColor, CssLength, CssPercentage, CssRatio, CssTime, CssValue, CssValueTypeName, HexColor, HslColor, RgbColor } from "./types/css-values.js";
3
6
  import { AnyStyleProp, ArbitraryEntry, ArbitrarySpec, StylePropMetadata } from "./defineStyleProp.js";
4
- import { ResolvedStyleProp, ResolvedToken } from "./resolveStyleProp.js";
5
7
  import { TokenType, VarGroupDef, VarTokenDef, VarsConfig } from "./types.js";
6
- import { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig } from "./createConfig.js";
8
+ import { AtomicToken, BuildOptions, CheckForReservedModifiersInput, ComponentConfig, DefineComponentInput, DefineComponentMotionInput, ExampleDef, ExampleEntryDef, ExampleLayoutStyles, GetModifierFromInput, GlobalStylesDef, InterpolateMarker, ModeGroup, ModeOption, ModeOptionInput, ModeSetInput, ModesInput, ModifierDef, MotionPresetsDef, SingleComponentDef, UdsConfig, UdsConfigData, buildTokenReference, createConfigBuilder, darker, lighter, resolveConfig } from "./createConfig.js";
9
+ import { ResolvedStyleProp, ResolvedToken } from "./resolveStyleProp.js";
10
+ import { defaultColors } from "./consts/defaultColors.js";
7
11
  import { SerializedConfig, TokenRef, buildReverseMap, deserializeConfig, serializeConfig } from "./serialize.js";
8
12
  import { ComponentsConfig as ComponentsConfig$1 } from "@uds/types";
9
13
  export { type ComponentsConfig$1 as ComponentsConfig };
@@ -1,9 +1,11 @@
1
- import "./consts/defaultColors.js";
2
1
  import "./component-resolution.js";
2
+ import "./consts/defaultColors.js";
3
+ import "./createComponent.js";
3
4
  import "./propertyAcceptedTypes.js";
4
5
  import "./resolveTokenTypes.js";
5
6
  import "./resolveStyleProp.js";
6
7
  import "./createConfig.js";
8
+ import "./defineComponent.js";
7
9
  import "./defineStyleProp.js";
8
10
  import "./propertyGroups.js";
9
11
  import "./refs.js";
@@ -1,6 +1,7 @@
1
1
  import { CssValueTypeName } from "./types/css-values.js";
2
2
  import { ArbitrarySpec, StylePropMetadata } from "./defineStyleProp.js";
3
3
  //#region ../config/dist/resolveStyleProp.d.ts
4
+ //#region src/resolveStyleProp.d.ts
4
5
  interface ResolvedToken {
5
6
  /** The token's raw key, e.g. `'brand'`. */
6
7
  readonly name: string;
@@ -47,9 +48,22 @@ interface ResolvedStyleProp {
47
48
  readonly cssProperty: string;
48
49
  readonly classPrefix: string;
49
50
  readonly tokens: readonly ResolvedToken[];
50
- readonly literals: readonly string[];
51
+ readonly literals: readonly (string | number | boolean)[];
52
+ /** Alias → CSS-value map for `{ alias, value }` entries in `values`.
53
+ * When an author writes `flexDirection='col'`, the CSS emitter looks
54
+ * this up to write `flex-direction: column` instead of `flex-direction: col`.
55
+ * Object values represent composite styles (`truncate=true` mapping to
56
+ * three CSS properties at once). Only populated when at least one
57
+ * entry used the alias form. */
58
+ readonly literalAliases?: Readonly<Record<string, string | Readonly<Record<string, string>>>>;
51
59
  readonly arbitrary: ArbitrarySpec | undefined;
52
60
  readonly metadata: StylePropMetadata;
53
61
  }
62
+ /**
63
+ * Structurally-loose input shape for the resolver. Any `StyleProp<P>` from
64
+ * `defineStyleProp` is assignable to this. Defined locally so the
65
+ * resolver's signature doesn't expand `ValuesEntry<P>` over the full CSS
66
+ * property union (TS2590).
67
+ */
54
68
  //#endregion
55
69
  export { ResolvedStyleProp, ResolvedToken };