praxis-kit 4.0.3 → 4.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.
- package/dist/_shared/diagnostics.d.ts +14 -17
- package/dist/{chunk-DRGZ4ZI2.js → chunk-R2RKHZNX.js} +968 -634
- package/dist/contract/index.d.ts +39 -27
- package/dist/lit/index.d.ts +42 -30
- package/dist/lit/index.js +653 -413
- package/dist/preact/index.d.ts +45 -31
- package/dist/preact/index.js +1009 -685
- package/dist/react/index.d.ts +24 -11
- package/dist/react/index.js +21 -143
- package/dist/react/legacy.d.ts +3 -3
- package/dist/react/legacy.js +28 -147
- package/dist/{merge-refs-B0YcfdtP.d.ts → react-options-XrRof248.d.ts} +156 -100
- package/dist/solid/index.d.ts +45 -31
- package/dist/solid/index.js +521 -296
- package/dist/svelte/index.d.ts +55 -34
- package/dist/svelte/index.js +504 -296
- package/dist/tailwind/index.d.ts +29 -22
- package/dist/vite-plugin/index.d.ts +10 -12
- package/dist/vue/index.d.ts +45 -31
- package/dist/vue/index.js +898 -693
- package/dist/web/index.d.ts +43 -31
- package/dist/web/index.js +652 -406
- package/package.json +3 -3
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Ref, PropsWithChildren, ReactElement, ComponentType, JSX, ReactNode } from 'react';
|
|
2
2
|
import { RequireAtLeastOne, Simplify, ReadonlyDeep, NonEmptyTuple } from 'type-fest';
|
|
3
3
|
import { Diagnostics, DiagnosticInput } from './_shared/diagnostics.js';
|
|
4
4
|
|
|
5
5
|
type StringMap<T = unknown> = Record<string, T>;
|
|
6
6
|
type AnyRecord = StringMap<unknown>;
|
|
7
|
+
type EmptyRecord = Record<never, never>;
|
|
7
8
|
|
|
8
9
|
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
9
10
|
|
|
@@ -14,7 +15,6 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
|
14
15
|
|
|
15
16
|
type Booleanish = boolean | 'true' | 'false';
|
|
16
17
|
type ClassName = string | string[];
|
|
17
|
-
type EmptyRecord = Record<never, never>;
|
|
18
18
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
19
19
|
type Numberish = number | `${number}`;
|
|
20
20
|
type Primitive = string | number | boolean;
|
|
@@ -51,34 +51,16 @@ type ValidResult = {
|
|
|
51
51
|
valid: true;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
55
|
-
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
56
|
-
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
57
|
-
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
58
|
-
}>;
|
|
59
|
-
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
60
|
-
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
61
|
-
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
62
|
-
class: VariantValue;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
interface CVACompounds<V extends VariantMap> {
|
|
66
|
-
compoundVariants?: readonly CompoundVariant<V>[];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface CVADefaults<V extends VariantMap> {
|
|
70
|
-
defaultVariants?: DefaultVariants<V>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
interface CVAVariants<V extends VariantMap> {
|
|
74
|
-
variants?: V;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
54
|
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
55
|
+
|
|
78
56
|
type VariantValue = string | string[];
|
|
57
|
+
|
|
79
58
|
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
59
|
+
|
|
80
60
|
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
61
|
+
|
|
81
62
|
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
63
|
+
|
|
82
64
|
/**
|
|
83
65
|
* A partial selection of variant states authored at factory definition time.
|
|
84
66
|
*
|
|
@@ -88,14 +70,17 @@ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof
|
|
|
88
70
|
type VariantSelection<V extends VariantMap> = {
|
|
89
71
|
[K in keyof V]?: keyof V[K];
|
|
90
72
|
};
|
|
73
|
+
|
|
91
74
|
/** The full optional prop surface exposed to callers for a given variant map. */
|
|
92
75
|
type VariantProps<V extends VariantMap> = {
|
|
93
76
|
[K in keyof V]?: VariantKey<V, K>;
|
|
94
77
|
};
|
|
78
|
+
|
|
95
79
|
type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
96
80
|
type DefaultVariants<V extends VariantMap> = {
|
|
97
81
|
[K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
|
|
98
82
|
};
|
|
83
|
+
|
|
99
84
|
/**
|
|
100
85
|
* A static, immutable map of named presets to partial variant selections.
|
|
101
86
|
*
|
|
@@ -103,7 +88,9 @@ type DefaultVariants<V extends VariantMap> = {
|
|
|
103
88
|
* avoiding the need to repeat variant combinations at each call site.
|
|
104
89
|
*/
|
|
105
90
|
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
91
|
+
|
|
106
92
|
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
93
|
+
|
|
107
94
|
interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TAllowed extends ElementType = ElementType> {
|
|
108
95
|
default: TDefault;
|
|
109
96
|
props: Props;
|
|
@@ -117,6 +104,29 @@ type AllowedOf<T extends PolymorphicGenerics> = T['allowed'];
|
|
|
117
104
|
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
118
105
|
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
119
106
|
|
|
107
|
+
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
108
|
+
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
109
|
+
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
110
|
+
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
111
|
+
}>;
|
|
112
|
+
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
113
|
+
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
114
|
+
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
115
|
+
class: VariantValue;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
interface CVACompounds<V extends VariantMap> {
|
|
119
|
+
compoundVariants?: readonly CompoundVariant<V>[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface CVADefaults<V extends VariantMap> {
|
|
123
|
+
defaultVariants?: DefaultVariants<V>;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
interface CVAVariants<V extends VariantMap> {
|
|
127
|
+
variants?: V;
|
|
128
|
+
}
|
|
129
|
+
|
|
120
130
|
interface BaseClassOptions {
|
|
121
131
|
baseClassName?: ClassName;
|
|
122
132
|
}
|
|
@@ -148,7 +158,11 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
|
148
158
|
}>;
|
|
149
159
|
|
|
150
160
|
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
|
|
151
|
-
|
|
161
|
+
/** `ClassPluginFactory` with its plugin-owned-props generic erased — the common form used
|
|
162
|
+
* wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
|
|
163
|
+
* capability wiring). */
|
|
164
|
+
type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
|
|
165
|
+
type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
|
|
152
166
|
|
|
153
167
|
type AriaContext = {
|
|
154
168
|
readonly tag: IntrinsicTag;
|
|
@@ -208,7 +222,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
208
222
|
readonly allowedAs?: readonly TAllowed[];
|
|
209
223
|
};
|
|
210
224
|
|
|
211
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends
|
|
225
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
|
|
212
226
|
readonly base?: ClassName;
|
|
213
227
|
readonly variants?: V;
|
|
214
228
|
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
@@ -222,8 +236,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
222
236
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
223
237
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
224
238
|
}['normalize'];
|
|
225
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>,
|
|
226
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends
|
|
239
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
|
|
240
|
+
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TAllowed extends ElementType = ElementType> = {
|
|
227
241
|
readonly tag?: TDefault;
|
|
228
242
|
readonly name?: string;
|
|
229
243
|
readonly defaults?: Partial<NoInfer<Props>>;
|
|
@@ -258,7 +272,12 @@ interface ComponentDefinition {
|
|
|
258
272
|
diagnostics: Diagnostic[];
|
|
259
273
|
}
|
|
260
274
|
|
|
261
|
-
|
|
275
|
+
declare function mergeRefs<T>(...refs: (Ref<T> | null | undefined)[]): Ref<T> | null;
|
|
276
|
+
|
|
277
|
+
type SlottableProps = PropsWithChildren;
|
|
278
|
+
declare function Slottable({ children }: SlottableProps): ReactElement;
|
|
279
|
+
|
|
280
|
+
type UnknownProps = AnyRecord;
|
|
262
281
|
type SlotComponent = ComponentType<UnknownProps>;
|
|
263
282
|
|
|
264
283
|
/**
|
|
@@ -267,80 +286,96 @@ type SlotComponent = ComponentType<UnknownProps>;
|
|
|
267
286
|
*
|
|
268
287
|
* Typed loosely to accommodate any element tag the user chooses.
|
|
269
288
|
*/
|
|
270
|
-
type RenderCallbackProps = Readonly<
|
|
271
|
-
|
|
272
|
-
type SlottableProps = PropsWithChildren;
|
|
273
|
-
declare function Slottable({ children }: SlottableProps): ReactElement;
|
|
289
|
+
type RenderCallbackProps = Readonly<AnyRecord>;
|
|
274
290
|
|
|
275
|
-
/** Structural subset of `CompiledComponentArtifact` consumed by the React adapter. */
|
|
276
|
-
interface CompiledArtifact {
|
|
277
|
-
readonly definition: ComponentDefinition;
|
|
278
|
-
readonly precomputed?: {
|
|
279
|
-
readonly variantLookup?: Record<string, string>;
|
|
280
|
-
};
|
|
281
|
-
}
|
|
282
291
|
/**
|
|
283
|
-
*
|
|
284
|
-
*
|
|
292
|
+
* Maps a polymorphic element type to the instance type exposed through `ref`.
|
|
293
|
+
*
|
|
294
|
+
* Intrinsic HTML elements resolve to their corresponding DOM element type;
|
|
295
|
+
* custom React components currently fall back to `unknown`.
|
|
285
296
|
*/
|
|
286
|
-
type ReactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined, TAllowed extends ElementType = ElementType> = FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin, TAllowed> & {
|
|
287
|
-
/** Component used to render the asChild slot. Defaults to the built-in Slot. */
|
|
288
|
-
slotComponent?: SlotComponent;
|
|
289
|
-
/**
|
|
290
|
-
* Return true for any prop key that should be consumed but not forwarded to the DOM.
|
|
291
|
-
* The adapter strips nothing by default — implementations decide what is safe to drop.
|
|
292
|
-
* Receives `runtime.options.variantKeys` as a convenience if needed.
|
|
293
|
-
*/
|
|
294
|
-
filterProps?: (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
295
|
-
/** Pre-compiled artifact from `@praxis-kit/runtime`'s compiler. When provided, replaces the stub
|
|
296
|
-
* definition and enables the precomputed variant lookup fast path. */
|
|
297
|
-
artifact?: CompiledArtifact;
|
|
298
|
-
};
|
|
299
|
-
|
|
300
|
-
/** Maps a core ElementType to its DOM instance type for ref inference. */
|
|
301
297
|
type ElementRef<T extends ElementType> = T extends IntrinsicTag ? HTMLElementTagNameMap[T] : unknown;
|
|
302
|
-
/**
|
|
298
|
+
/**
|
|
299
|
+
* React's intrinsic JSX props for a given element.
|
|
300
|
+
*
|
|
301
|
+
* Custom components intentionally fall back to `UnknownProps`; the component's
|
|
302
|
+
* own prop model defines their accepted props instead.
|
|
303
|
+
*/
|
|
303
304
|
type IntrinsicJSXProps<T extends ElementType> = T extends IntrinsicTag ? JSX.IntrinsicElements[T] : UnknownProps;
|
|
304
305
|
/**
|
|
305
|
-
*
|
|
306
|
-
*
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
* `
|
|
310
|
-
* would cause `Omit<IntrinsicJSXProps<TAs>, string>` to remove all HTML props.
|
|
306
|
+
* Removes index signatures while preserving explicitly named properties.
|
|
307
|
+
*
|
|
308
|
+
* This prevents generic fallback constraints such as `Record<string, unknown>`
|
|
309
|
+
* from collapsing `keyof T` to `string`, which would cause
|
|
310
|
+
* `Omit<IntrinsicJSXProps<T>, keyof ...>` to remove every intrinsic prop.
|
|
311
311
|
*/
|
|
312
312
|
type StripIndexSignature<T> = {
|
|
313
313
|
[K in keyof T as string extends K ? never : K]: T[K];
|
|
314
314
|
};
|
|
315
|
+
/** Props explicitly declared by the component. */
|
|
315
316
|
type ComponentProps<G extends PolymorphicGenerics> = StripIndexSignature<PropsOf<G>>;
|
|
317
|
+
/** Variant props generated from the component's variant definitions. */
|
|
316
318
|
type ComponentVariants<G extends PolymorphicGenerics> = StripIndexSignature<VariantProps<VariantsOf<G>>>;
|
|
319
|
+
/**
|
|
320
|
+
* Props owned by the component itself.
|
|
321
|
+
*
|
|
322
|
+
* These take precedence over intrinsic HTML props when names overlap.
|
|
323
|
+
*/
|
|
317
324
|
type OwnedProps<G extends PolymorphicGenerics> = ComponentProps<G> & ComponentVariants<G>;
|
|
318
325
|
/**
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
*
|
|
326
|
+
* Polymorphic rendering controls.
|
|
327
|
+
*
|
|
328
|
+
* These describe *how* the component renders rather than the data it owns.
|
|
322
329
|
*
|
|
323
|
-
* `
|
|
324
|
-
*
|
|
330
|
+
* `children` and `asChild` are intentionally omitted so each render mode
|
|
331
|
+
* can provide its own stricter contract.
|
|
325
332
|
*/
|
|
326
333
|
type PolymorphicControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = {
|
|
334
|
+
/**
|
|
335
|
+
* Restrict `as` to `allowedAs` when configured.
|
|
336
|
+
*
|
|
337
|
+
* Without `allowedAs`, `AllowedOf<G>` resolves to `ElementType`,
|
|
338
|
+
* so the intersection becomes `TAs`.
|
|
339
|
+
*/
|
|
327
340
|
as?: TAs & AllowedOf<G>;
|
|
341
|
+
/**
|
|
342
|
+
* Explicit `undefined` keeps wrapper components compatible with
|
|
343
|
+
* `exactOptionalPropertyTypes`.
|
|
344
|
+
*/
|
|
328
345
|
className?: ClassName | undefined;
|
|
329
346
|
recipe?: keyof RecipeOf<G>;
|
|
347
|
+
/** Ref type follows the resolved element. */
|
|
330
348
|
ref?: Ref<ElementRef<TAs>>;
|
|
331
349
|
};
|
|
332
|
-
/**
|
|
350
|
+
/**
|
|
351
|
+
* Complete set of props owned by the component.
|
|
352
|
+
*
|
|
353
|
+
* Used primarily as the exclusion list when inheriting intrinsic JSX props.
|
|
354
|
+
*/
|
|
333
355
|
type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = OwnedProps<G> & PolymorphicControlProps<G, TAs>;
|
|
356
|
+
/**
|
|
357
|
+
* Intrinsic JSX props after removing every prop owned by the component.
|
|
358
|
+
*
|
|
359
|
+
* Component props always win over intrinsic props with the same name.
|
|
360
|
+
*/
|
|
334
361
|
type IntrinsicPropsWithoutOwned<G extends PolymorphicGenerics, TAs extends ElementType> = Omit<IntrinsicJSXProps<TAs>, keyof ControlProps<G, TAs> | 'children'>;
|
|
335
|
-
|
|
336
|
-
|
|
362
|
+
/**
|
|
363
|
+
* Base props shared by every render mode.
|
|
364
|
+
*
|
|
365
|
+
* Render modes contribute only their discriminants (`asChild`, `render`,
|
|
366
|
+
* `children`, etc.).
|
|
367
|
+
*/
|
|
368
|
+
type BaseProps<G extends PolymorphicGenerics, TAs extends ElementType> = IntrinsicPropsWithoutOwned<G, TAs> & ControlProps<G, TAs>;
|
|
369
|
+
/** Standard rendering (`asChild` absent or false). */
|
|
337
370
|
type NormalRenderMode = {
|
|
338
371
|
asChild?: false;
|
|
339
372
|
children?: ReactNode | undefined;
|
|
340
373
|
};
|
|
341
374
|
/**
|
|
342
|
-
*
|
|
343
|
-
*
|
|
375
|
+
* Slot rendering.
|
|
376
|
+
*
|
|
377
|
+
* Requires one or more React elements and forbids `as`, since the child
|
|
378
|
+
* determines the rendered element.
|
|
344
379
|
*/
|
|
345
380
|
type SlotRenderMode = {
|
|
346
381
|
asChild: true;
|
|
@@ -348,17 +383,12 @@ type SlotRenderMode = {
|
|
|
348
383
|
children: ReactElement | NonEmptyTuple<ReactElement>;
|
|
349
384
|
};
|
|
350
385
|
/**
|
|
351
|
-
*
|
|
352
|
-
* (className, ref, filtered component props) and returns the target element.
|
|
386
|
+
* Render callback.
|
|
353
387
|
*
|
|
354
|
-
*
|
|
355
|
-
*
|
|
356
|
-
* Unlike `asChild`, the render callback does not auto-merge conflicting event
|
|
357
|
-
* handlers — spread position determines precedence.
|
|
388
|
+
* The callback receives fully resolved props (classes, refs, filtered props)
|
|
389
|
+
* and is responsible for rendering the target element.
|
|
358
390
|
*
|
|
359
|
-
*
|
|
360
|
-
* <Button render={(p) => <a href="/home" {...p} />} size="lg" />
|
|
361
|
-
* ```
|
|
391
|
+
* This provides the flexibility of `asChild` without `cloneElement`.
|
|
362
392
|
*/
|
|
363
393
|
type CallbackRenderMode = {
|
|
364
394
|
render: (props: RenderCallbackProps) => ReactElement;
|
|
@@ -366,26 +396,29 @@ type CallbackRenderMode = {
|
|
|
366
396
|
children?: never;
|
|
367
397
|
};
|
|
368
398
|
/**
|
|
369
|
-
*
|
|
399
|
+
* Standard polymorphic props.
|
|
400
|
+
*
|
|
401
|
+
* HTML attributes are inferred from `as`.
|
|
402
|
+
*/
|
|
403
|
+
type PolymorphicProps<G extends PolymorphicGenerics, TAs extends ElementType = DefaultOf<G>> = Simplify<BaseProps<G, TAs> & NormalRenderMode>;
|
|
404
|
+
/**
|
|
405
|
+
* Slot rendering props.
|
|
370
406
|
*
|
|
371
|
-
*
|
|
372
|
-
* the `as` prop value; control props win on key conflicts.
|
|
407
|
+
* Requires one or more ReactElement children.
|
|
373
408
|
*/
|
|
374
|
-
type
|
|
409
|
+
type PolymorphicWithAsChild<G extends PolymorphicGenerics, TAs extends ElementType = DefaultOf<G>> = Simplify<BaseProps<G, TAs> & SlotRenderMode>;
|
|
375
410
|
/**
|
|
376
|
-
*
|
|
377
|
-
* children are required. Multiple children are permitted for the Slottable
|
|
378
|
-
* sibling pattern where one child is a `<Slottable>` wrapper.
|
|
411
|
+
* Render callback props.
|
|
379
412
|
*/
|
|
380
|
-
type
|
|
381
|
-
type PolymorphicWithRender<G extends PolymorphicGenerics, TAs extends ElementType = DefaultOf<G>> = Simplify<SharedProps<G, TAs> & CallbackRenderMode>;
|
|
413
|
+
type PolymorphicWithRender<G extends PolymorphicGenerics, TAs extends ElementType = DefaultOf<G>> = Simplify<BaseProps<G, TAs> & CallbackRenderMode>;
|
|
382
414
|
/**
|
|
383
|
-
* A polymorphic component
|
|
415
|
+
* A polymorphic React component.
|
|
384
416
|
*
|
|
385
|
-
*
|
|
386
|
-
*
|
|
387
|
-
*
|
|
388
|
-
*
|
|
417
|
+
* Overloads form a discriminated union:
|
|
418
|
+
*
|
|
419
|
+
* • `render` → render callback
|
|
420
|
+
* • `asChild` → Slot rendering
|
|
421
|
+
* • otherwise → normal rendering
|
|
389
422
|
*/
|
|
390
423
|
type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
391
424
|
<TAs extends ElementType = DefaultOf<G>>(props: PolymorphicWithRender<G, TAs>): ReactElement;
|
|
@@ -394,6 +427,29 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
|
394
427
|
displayName?: string;
|
|
395
428
|
};
|
|
396
429
|
|
|
397
|
-
|
|
430
|
+
/** Structural subset of `CompiledComponentArtifact` consumed by the React adapter. */
|
|
431
|
+
interface CompiledArtifact {
|
|
432
|
+
readonly definition: ComponentDefinition;
|
|
433
|
+
readonly precomputed?: {
|
|
434
|
+
readonly variantLookup?: Record<string, string>;
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
/**
|
|
438
|
+
* Extends FactoryOptions with React-specific configuration.
|
|
439
|
+
* slotComponent is intentionally not in core — it is a React rendering concern.
|
|
440
|
+
*/
|
|
441
|
+
type ReactFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TAllowed extends ElementType = ElementType> = FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin, TAllowed> & {
|
|
442
|
+
/** Component used to render the asChild slot. Defaults to the built-in Slot. */
|
|
443
|
+
slotComponent?: SlotComponent;
|
|
444
|
+
/**
|
|
445
|
+
* Return true for any prop key that should be consumed but not forwarded to the DOM.
|
|
446
|
+
* The adapter strips nothing by default — implementations decide what is safe to drop.
|
|
447
|
+
* Receives `runtime.options.variantKeys` as a convenience if needed.
|
|
448
|
+
*/
|
|
449
|
+
filterProps?: (key: string, variantKeys: ReadonlySet<string>) => boolean;
|
|
450
|
+
/** Pre-compiled artifact from `@praxis-kit/runtime`'s compiler. When provided, replaces the stub
|
|
451
|
+
* definition and enables the precomputed variant lookup fast path. */
|
|
452
|
+
artifact?: CompiledArtifact;
|
|
453
|
+
};
|
|
398
454
|
|
|
399
|
-
export { type
|
|
455
|
+
export { type AnyClassPluginFactory as A, type ElementType as E, type FactoryOptions as F, type PolymorphicComponent as P, type RecipeMap as R, Slottable as S, type UnknownProps as U, type VariantMap as V, type EmptyRecord as a, type ReactFactoryOptions as b, type PolymorphicGenerics as c, type ExtractPluginProps as d, type AnyFactoryOptions as e, type ElementRef as f, type PolymorphicProps as g, type PolymorphicWithAsChild as h, type PolymorphicWithRender as i, type RenderCallbackProps as j, type SlottableProps as k, defineContractComponent as l, mergeRefs as m };
|
package/dist/solid/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import { JSX } from 'solid-js';
|
|
|
4
4
|
|
|
5
5
|
type StringMap<T = unknown> = Record<string, T>;
|
|
6
6
|
type AnyRecord = StringMap<unknown>;
|
|
7
|
+
type EmptyRecord = Record<never, never>;
|
|
7
8
|
|
|
8
9
|
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
9
10
|
|
|
@@ -14,7 +15,6 @@ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
|
14
15
|
|
|
15
16
|
type Booleanish = boolean | 'true' | 'false';
|
|
16
17
|
type ClassName = string | string[];
|
|
17
|
-
type EmptyRecord = Record<never, never>;
|
|
18
18
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
19
19
|
type Numberish = number | `${number}`;
|
|
20
20
|
type Primitive = string | number | boolean;
|
|
@@ -51,34 +51,16 @@ type ValidResult = {
|
|
|
51
51
|
valid: true;
|
|
52
52
|
};
|
|
53
53
|
|
|
54
|
-
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
55
|
-
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
56
|
-
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
57
|
-
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
58
|
-
}>;
|
|
59
|
-
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
60
|
-
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
61
|
-
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
62
|
-
class: VariantValue;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
interface CVACompounds<V extends VariantMap> {
|
|
66
|
-
compoundVariants?: readonly CompoundVariant<V>[];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
interface CVADefaults<V extends VariantMap> {
|
|
70
|
-
defaultVariants?: DefaultVariants<V>;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
interface CVAVariants<V extends VariantMap> {
|
|
74
|
-
variants?: V;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
54
|
type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
|
|
55
|
+
|
|
78
56
|
type VariantValue = string | string[];
|
|
57
|
+
|
|
79
58
|
type VariantStates<K extends string = string> = Record<K, VariantValue>;
|
|
59
|
+
|
|
80
60
|
type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
|
|
61
|
+
|
|
81
62
|
type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
|
|
63
|
+
|
|
82
64
|
/**
|
|
83
65
|
* A partial selection of variant states authored at factory definition time.
|
|
84
66
|
*
|
|
@@ -88,14 +70,17 @@ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof
|
|
|
88
70
|
type VariantSelection<V extends VariantMap> = {
|
|
89
71
|
[K in keyof V]?: keyof V[K];
|
|
90
72
|
};
|
|
73
|
+
|
|
91
74
|
/** The full optional prop surface exposed to callers for a given variant map. */
|
|
92
75
|
type VariantProps<V extends VariantMap> = {
|
|
93
76
|
[K in keyof V]?: VariantKey<V, K>;
|
|
94
77
|
};
|
|
78
|
+
|
|
95
79
|
type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
|
|
96
80
|
type DefaultVariants<V extends VariantMap> = {
|
|
97
81
|
[K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>;
|
|
98
82
|
};
|
|
83
|
+
|
|
99
84
|
/**
|
|
100
85
|
* A static, immutable map of named presets to partial variant selections.
|
|
101
86
|
*
|
|
@@ -103,7 +88,9 @@ type DefaultVariants<V extends VariantMap> = {
|
|
|
103
88
|
* avoiding the need to repeat variant combinations at each call site.
|
|
104
89
|
*/
|
|
105
90
|
type RecipeMap<V extends VariantMap = VariantMap> = Readonly<Record<string, VariantSelection<V>>>;
|
|
91
|
+
|
|
106
92
|
type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
|
|
93
|
+
|
|
107
94
|
interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props extends AnyRecord = AnyRecord, Variants extends Readonly<VariantMap> = Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TAllowed extends ElementType = ElementType> {
|
|
108
95
|
default: TDefault;
|
|
109
96
|
props: Props;
|
|
@@ -116,6 +103,29 @@ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
|
|
|
116
103
|
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
117
104
|
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
118
105
|
|
|
106
|
+
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
107
|
+
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
108
|
+
type CompoundVariantConditions<V extends VariantMap> = Simplify<{
|
|
109
|
+
[K in keyof V]: CompoundVariantConditionValue<V, K>;
|
|
110
|
+
}>;
|
|
111
|
+
type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
|
|
112
|
+
type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
|
|
113
|
+
type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
|
|
114
|
+
class: VariantValue;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
interface CVACompounds<V extends VariantMap> {
|
|
118
|
+
compoundVariants?: readonly CompoundVariant<V>[];
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
interface CVADefaults<V extends VariantMap> {
|
|
122
|
+
defaultVariants?: DefaultVariants<V>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
interface CVAVariants<V extends VariantMap> {
|
|
126
|
+
variants?: V;
|
|
127
|
+
}
|
|
128
|
+
|
|
119
129
|
interface BaseClassOptions {
|
|
120
130
|
baseClassName?: ClassName;
|
|
121
131
|
}
|
|
@@ -147,7 +157,11 @@ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
|
|
|
147
157
|
}>;
|
|
148
158
|
|
|
149
159
|
type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
|
|
150
|
-
|
|
160
|
+
/** `ClassPluginFactory` with its plugin-owned-props generic erased — the common form used
|
|
161
|
+
* wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
|
|
162
|
+
* capability wiring). */
|
|
163
|
+
type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
|
|
164
|
+
type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? EmptyRecord : T : EmptyRecord;
|
|
151
165
|
|
|
152
166
|
type AriaContext = {
|
|
153
167
|
readonly tag: IntrinsicTag;
|
|
@@ -207,7 +221,7 @@ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
|
207
221
|
readonly allowedAs?: readonly TAllowed[];
|
|
208
222
|
};
|
|
209
223
|
|
|
210
|
-
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends
|
|
224
|
+
type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
|
|
211
225
|
readonly base?: ClassName;
|
|
212
226
|
readonly variants?: V;
|
|
213
227
|
readonly defaults?: Partial<DefaultVariants<V>>;
|
|
@@ -221,8 +235,8 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
221
235
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
222
236
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
223
237
|
}['normalize'];
|
|
224
|
-
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>,
|
|
225
|
-
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends
|
|
238
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
|
|
239
|
+
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TAllowed extends ElementType = ElementType> = {
|
|
226
240
|
readonly tag?: TDefault;
|
|
227
241
|
readonly name?: string;
|
|
228
242
|
readonly defaults?: Partial<NoInfer<Props>>;
|
|
@@ -233,11 +247,11 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
233
247
|
|
|
234
248
|
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
235
249
|
|
|
236
|
-
type UnknownProps =
|
|
250
|
+
type UnknownProps = AnyRecord;
|
|
237
251
|
type SolidElement = JSX.Element;
|
|
238
252
|
type SlotRenderFn = (props: UnknownProps) => SolidElement;
|
|
239
253
|
|
|
240
|
-
type SolidFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends
|
|
254
|
+
type SolidFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & {
|
|
241
255
|
/**
|
|
242
256
|
* Return true for any prop key that should be consumed but not forwarded to the DOM.
|
|
243
257
|
* Receives `runtime.options.variantKeys` as a convenience if needed.
|
|
@@ -271,6 +285,6 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
|
271
285
|
displayName?: string;
|
|
272
286
|
};
|
|
273
287
|
|
|
274
|
-
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends
|
|
288
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory>(options: SolidFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>>;
|
|
275
289
|
|
|
276
290
|
export { type AnyFactoryOptions, type ElementRef, type ElementType, type EmptyRecord, type PolymorphicComponent, type PolymorphicGenerics, type PolymorphicProps, type SolidFactoryOptions, createContractComponent, defineContractComponent };
|