praxis-kit 0.1.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 (45) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +77 -0
  3. package/dist/_shared/diagnostics.d.ts +312 -0
  4. package/dist/_shared/diagnostics.js +360 -0
  5. package/dist/build-runtime-CJ_nQEaZ.js +5065 -0
  6. package/dist/codemod/index.d.ts +2 -0
  7. package/dist/codemod/index.js +176520 -0
  8. package/dist/contract/index.d.ts +677 -0
  9. package/dist/contract/index.js +341 -0
  10. package/dist/eslint/index.d.ts +90 -0
  11. package/dist/eslint/index.js +1047 -0
  12. package/dist/guards/index.d.ts +78 -0
  13. package/dist/guards/index.js +118 -0
  14. package/dist/html/index.d.ts +151 -0
  15. package/dist/html/index.js +1244 -0
  16. package/dist/index-BIBd_iPD.d.ts +951 -0
  17. package/dist/lit/index.d.ts +862 -0
  18. package/dist/lit/index.js +4893 -0
  19. package/dist/preact/index.d.ts +796 -0
  20. package/dist/preact/index.js +5043 -0
  21. package/dist/react/index.d.ts +28 -0
  22. package/dist/react/index.js +205 -0
  23. package/dist/react/legacy.d.ts +29 -0
  24. package/dist/react/legacy.js +80 -0
  25. package/dist/solid/index.d.ts +728 -0
  26. package/dist/solid/index.js +4821 -0
  27. package/dist/svelte/Polymorphic.svelte +190 -0
  28. package/dist/svelte/_polymorphic-runtime.d.ts +102 -0
  29. package/dist/svelte/_polymorphic-runtime.js +371 -0
  30. package/dist/svelte/index.d.ts +994 -0
  31. package/dist/svelte/index.js +4482 -0
  32. package/dist/tailwind/index.d.ts +197 -0
  33. package/dist/tailwind/index.js +767 -0
  34. package/dist/tailwind/safelist.css +20 -0
  35. package/dist/ts-plugin/index.cjs +166 -0
  36. package/dist/ts-plugin/index.d.cts +9 -0
  37. package/dist/utils/index.d.ts +19 -0
  38. package/dist/utils/index.js +21 -0
  39. package/dist/vite-plugin/index.d.ts +200 -0
  40. package/dist/vite-plugin/index.js +2106 -0
  41. package/dist/vue/index.d.ts +729 -0
  42. package/dist/vue/index.js +4945 -0
  43. package/dist/web/index.d.ts +832 -0
  44. package/dist/web/index.js +4868 -0
  45. package/package.json +258 -0
@@ -0,0 +1,728 @@
1
+ import "clsx";
2
+ import { DiagnosticCode, DiagnosticInput, Diagnostics, DiagnosticsMode } from "../_shared/diagnostics.js";
3
+ import { JSX } from "solid-js";
4
+ import { OmitIndexSignature, ReadonlyDeep, RequireAtLeastOne, Simplify } from "type-fest";
5
+ //#region ../../lib/foundation/src/string-map.d.ts
6
+ /**
7
+ * A string-keyed object whose values are of type `T`.
8
+ */
9
+ type StringMap<T = unknown> = Record<string, T>;
10
+ /**
11
+ * A string-keyed object with values of unknown type.
12
+ */
13
+ type AnyRecord = StringMap<unknown>;
14
+ //#endregion
15
+ //#region ../../lib/primitive/src/types/any-record.d.ts
16
+ /**
17
+ * An object type with no named properties.
18
+ *
19
+ * Unlike `{}`, this excludes arbitrary properties during type operations while
20
+ * still satisfying `extends object`.
21
+ */
22
+ type EmptyRecord = Record<never, never>;
23
+ /**
24
+ * A compound component's named sub-components, for example
25
+ * `{ Header, Content, Footer }`.
26
+ */
27
+ type SubComponentMap = Readonly<AnyRecord>;
28
+ /**
29
+ * Default `Variants` type for components that declare no variants.
30
+ *
31
+ * Structurally identical to `Readonly<EmptyRecord>`, but named separately so
32
+ * editor hovers remain self-descriptive.
33
+ */
34
+ type NoVariants = Readonly<EmptyRecord>;
35
+ /**
36
+ * Default `TPreset` type for components that declare no named presets.
37
+ *
38
+ * Structurally identical to `Readonly<EmptyRecord>`, but named separately so
39
+ * editor hovers remain self-descriptive.
40
+ */
41
+ type NoPreset = Readonly<EmptyRecord>;
42
+ /**
43
+ * Fallback for `ExtractPluginProps<TPlugin>` when a plugin contributes no
44
+ * props, including the no-plugin case.
45
+ *
46
+ * Structurally identical to `EmptyRecord`, but named separately so editor
47
+ * hovers remain self-descriptive.
48
+ */
49
+ type NoPluginProps = EmptyRecord;
50
+ /**
51
+ * Determines whether an object type should be treated as empty.
52
+ *
53
+ * `keyof T` ignores call and construct signatures...
54
+ */
55
+ type IsEmptyRecord<T extends object> = T extends ((...args: never[]) => unknown) ? false : T extends (new (...args: never[]) => unknown) ? false : keyof T extends never ? true : false;
56
+ /**
57
+ * Merges two object types while eliding empty operands.
58
+ *
59
+ * If either operand is {@link EmptyRecord}, the other operand is returned
60
+ * directly instead of producing intersections such as
61
+ * `Component & EmptyRecord` in editor hovers.
62
+ *
63
+ * Unlike a homomorphic mapped type (for example `Simplify<T>`), this preserves
64
+ * call and construct signatures. Many component types are callable objects,
65
+ * and mapped types silently discard those signatures.
66
+ *
67
+ * @remarks
68
+ * Instantiate `MergeRecords` directly. Introducing an intermediate alias for
69
+ * one operand (for example `type C = PolymorphicComponent<G>`) can prevent
70
+ * `IsEmptyRecord` from evaluating eagerly, which breaks assignability under
71
+ * `exactOptionalPropertyTypes`.
72
+ */
73
+ type MergeRecords<A extends object, B extends object> = IsEmptyRecord<A> extends true ? B : IsEmptyRecord<B> extends true ? A : A & B;
74
+ //#endregion
75
+ //#region ../../lib/primitive/src/types/intrinsic-tag.d.ts
76
+ type IntrinsicTag = keyof HTMLElementTagNameMap;
77
+ //#endregion
78
+ //#region ../../lib/primitive/src/types/element-type.d.ts
79
+ type ElementType = IntrinsicTag | (string & {});
80
+ /**
81
+ * Resolves a component's default tag to its real DOM interface — `HTMLDialogElement` for
82
+ * `'dialog'`, `HTMLDetailsElement` for `'details'`, and so on — falling back to `HTMLElement`
83
+ * for custom-element tags or anything not in `HTMLElementTagNameMap`. Used to type
84
+ * `FactoryOptions.onElement`'s `element` param so component authors get direct, correctly-typed
85
+ * access to tag-specific native members (`dialogEl.showModal()`) without an unsafe cast.
86
+ *
87
+ * The fallback is `HTMLElement`, not the more generic `Element` — every tag reachable through
88
+ * `IntrinsicTag` extends it, and so does every custom element per spec, so members `HTMLElement`
89
+ * itself declares (`showPopover()`/`hidePopover()`/`togglePopover()`, the `popover` attribute)
90
+ * stay directly accessible even for tags with no dedicated entry in `HTMLElementTagNameMap`.
91
+ */
92
+ type ElementForTag<TDefault extends ElementType> = TDefault extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TDefault] : HTMLElement;
93
+ //#endregion
94
+ //#region ../../lib/primitive/src/constants/aria/known-aria-roles.d.ts
95
+ declare const KNOWN_ARIA_ROLES: readonly ["alert", "alertdialog", "application", "article", "banner", "blockquote", "button", "caption", "cell", "checkbox", "code", "columnheader", "combobox", "complementary", "contentinfo", "definition", "deletion", "dialog", "document", "emphasis", "feed", "figure", "form", "generic", "grid", "gridcell", "group", "heading", "img", "insertion", "link", "list", "listbox", "listitem", "log", "main", "marquee", "math", "menu", "menubar", "menuitem", "menuitemcheckbox", "menuitemradio", "meter", "navigation", "none", "note", "option", "paragraph", "presentation", "progressbar", "radio", "radiogroup", "region", "row", "rowgroup", "rowheader", "scrollbar", "search", "searchbox", "separator", "slider", "spinbutton", "status", "strong", "subscript", "superscript", "switch", "tab", "table", "tablist", "tabpanel", "term", "textbox", "time", "timer", "toolbar", "tooltip", "tree", "treegrid", "treeitem"];
96
+ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
97
+ //#endregion
98
+ //#region ../../lib/primitive/src/types/primitives/index.d.ts
99
+ type Booleanish = boolean | 'true' | 'false';
100
+ type ClassName = string | string[];
101
+ type NonEmptyArray<T> = [T, ...T[]];
102
+ type Numberish = number | `${number}`;
103
+ type Primitive = string | number | boolean;
104
+ type AriaRole = KnownAriaRole | (string & {});
105
+ type IntrinsicProps = AnyRecord & {
106
+ role?: AriaRole;
107
+ };
108
+ type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
109
+ //#endregion
110
+ //#region ../../lib/primitive/src/types/contracts/cardinality.d.ts
111
+ type MinMax = {
112
+ min: number;
113
+ max: number;
114
+ };
115
+ type CardinalityInput = Partial<MinMax>;
116
+ //#endregion
117
+ //#region ../../lib/primitive/src/types/contracts/child-rule-context.d.ts
118
+ /**
119
+ * Resolved per-instance state available to a dynamic (`dynamic(...)`) child
120
+ * rule field — the same tag/props every adapter already computes before
121
+ * evaluating children, exposed so a rule can vary by them (e.g. cardinality
122
+ * that depends on the resolved `as` tag).
123
+ */
124
+ type ChildRuleContext = {
125
+ readonly tag: unknown;
126
+ readonly props: Readonly<AnyRecord>;
127
+ };
128
+ //#endregion
129
+ //#region ../../lib/primitive/src/rule/rule-brand.d.ts
130
+ declare const RULE_BRAND: unique symbol;
131
+ //#endregion
132
+ //#region ../../lib/primitive/src/types/rule/dynamic-rule.d.ts
133
+ type DynamicRule<T, C = unknown> = {
134
+ readonly [RULE_BRAND]: true;
135
+ resolve(context: C): T;
136
+ };
137
+ //#endregion
138
+ //#region ../../lib/primitive/src/types/rule/rule.d.ts
139
+ type Rule<T, C = unknown> = T | DynamicRule<T, C>;
140
+ //#endregion
141
+ //#region ../../lib/primitive/src/types/contracts/child-rule-match.d.ts
142
+ type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
143
+ //#endregion
144
+ //#region ../../lib/primitive/src/types/contracts/child-rule-position.d.ts
145
+ type ChildRulePosition = 'first' | 'last' | 'any';
146
+ //#endregion
147
+ //#region ../../lib/primitive/src/types/contracts/child-rule-input.d.ts
148
+ type ChildRuleInput<T = unknown, U extends T = T> = {
149
+ name: string;
150
+ match: ChildRuleMatch<T, U>;
151
+ /**
152
+ * Either a static cardinality, or `dynamic((ctx) => ...)` to derive it from
153
+ * the resolved tag/props (e.g. a different max depending on `as`). `match`
154
+ * stays static-only — it's already a function, so a dynamic wrapper would
155
+ * be indistinguishable from the predicate itself without one.
156
+ */
157
+ cardinality?: Rule<CardinalityInput, ChildRuleContext>;
158
+ position?: ChildRulePosition;
159
+ /**
160
+ * Optional component-type reference for O(1) dispatch index.
161
+ * When provided for every rule, the matcher reads child.type instead of
162
+ * calling every match function on every child (O(n×m) → O(n+m)).
163
+ */
164
+ type?: unknown;
165
+ };
166
+ //#endregion
167
+ //#region ../../lib/primitive/src/types/validation/valid-result.d.ts
168
+ type ValidResult = {
169
+ valid: true;
170
+ };
171
+ //#endregion
172
+ //#region ../../lib/primitive/src/types/variants/string-to-boolean.d.ts
173
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
174
+ //#endregion
175
+ //#region ../../lib/primitive/src/types/variants/variant-value.d.ts
176
+ type VariantValue = string | string[];
177
+ //#endregion
178
+ //#region ../../lib/primitive/src/types/variants/variant-states.d.ts
179
+ type VariantStates<K extends string = string> = Record<K, VariantValue>;
180
+ //#endregion
181
+ //#region ../../lib/primitive/src/types/variants/variant-map.d.ts
182
+ type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
183
+ //#endregion
184
+ //#region ../../lib/primitive/src/types/variants/variant-key.d.ts
185
+ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
186
+ //#endregion
187
+ //#region ../../lib/primitive/src/types/variants/variant-selection.d.ts
188
+ /**
189
+ * A partial selection of variant states authored at factory definition time.
190
+ *
191
+ * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
192
+ * resolve the union at constraint-check time without deferred conditional types.
193
+ */
194
+ type VariantSelection<V extends VariantMap> = { [K in keyof V]?: keyof V[K]; };
195
+ //#endregion
196
+ //#region ../../lib/primitive/src/types/variants/variant-props.d.ts
197
+ /** The full optional prop surface exposed to callers for a given variant map. */
198
+ type VariantProps<V extends VariantMap> = { [K in keyof V]?: VariantKey<V, K>; };
199
+ //#endregion
200
+ //#region ../../lib/primitive/src/types/variants/default-variants.d.ts
201
+ type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
202
+ type DefaultVariants<V extends VariantMap> = { [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>; };
203
+ //#endregion
204
+ //#region ../../lib/primitive/src/types/variants/recipe-map.d.ts
205
+ /**
206
+ * A static, immutable map of named presets to partial variant selections.
207
+ *
208
+ * Presets are named bundles of variant props that callers activate by key,
209
+ * avoiding the need to repeat variant combinations at each call site.
210
+ */
211
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<StringMap<VariantSelection<V>>>;
212
+ //#endregion
213
+ //#region ../../lib/primitive/src/types/variants/recipe-target.d.ts
214
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
215
+ //#endregion
216
+ //#region ../../lib/primitive/src/types/variants/polymorphic-generics.d.ts
217
+ /**
218
+ * The framework-neutral descriptor for a single praxis-kit component's contract — every render
219
+ * mechanism (tag resolution, prop merging, classes, ARIA) and every framework adapter's
220
+ * component type is built from this one shape. Deliberately just data: five type parameters and
221
+ * their corresponding properties, with no notion of JSX, call signatures, refs, or any
222
+ * framework-specific rendering concern. Each adapter (React, Vue, Svelte, Solid, Lit, Web) builds
223
+ * its own idiomatic component type on top of a `PolymorphicGenerics<...>` instantiation — see
224
+ * `PolymorphicComponent<G>` (`adapters/react/src/shared/types/polymorphic-props.ts`) for the
225
+ * React example — rather than this interface knowing anything about any of them.
226
+ *
227
+ * Use the `*Of<T>` accessor aliases below (`DefaultOf<G>`, `PropsOf<G>`, etc.) to read a single
228
+ * field back out of an already-resolved `G`, instead of indexing `G['default']` etc. directly at
229
+ * call sites — same rationale as any accessor: the property name stays an implementation detail,
230
+ * and every reader benefits together if it ever needs to change.
231
+ */
232
+ interface PolymorphicGenerics<
233
+ /**
234
+ * The element/tag this component renders as when the consumer doesn't override it via `as`
235
+ * (`AllowedOf<G>` permitting) — e.g. `'button'`, `'div'`. Defaults to the widest `ElementType`
236
+ * so a generic `PolymorphicGenerics` reference (with nothing else specified) still compiles.
237
+ */
238
+ TDefault extends ElementType = ElementType,
239
+ /**
240
+ * The props this specific component declares — its own contract, before variants are mixed
241
+ * in. Defaults to `AnyRecord` for the same "still compiles unspecified" reason as `TDefault`.
242
+ */
243
+ Props extends AnyRecord = AnyRecord,
244
+ /**
245
+ * This component's variant definitions (e.g. `{ intent: { primary: ..., ghost: ... } }`).
246
+ * Constrained to `Readonly<VariantMap>` — not the wider `AnyRecord` — specifically so `TPreset`
247
+ * below can be expressed as `RecipeMap<Variants>` and get real per-variant-key checking,
248
+ * instead of falling back to an unconstrained `RecipeMap<VariantMap>`.
249
+ */
250
+ Variants extends Readonly<VariantMap> = Readonly<VariantMap>,
251
+ /**
252
+ * Named presets (`RecipeMap<Variants>`) — bundles of variant selections a consumer activates
253
+ * by key instead of repeating the same variant combination at every call site. Tied to
254
+ * `Variants`, not `AnyRecord`, precisely so a preset can only ever select keys/values that
255
+ * `Variants` actually defines — an invalid preset is a type error, not a silent no-op.
256
+ * Defaults to `Readonly<EmptyRecord>` (no presets), which is the common case: a component can
257
+ * have variants without necessarily defining any named presets over them, and most don't.
258
+ */
259
+ TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>,
260
+ /**
261
+ * The set of elements/tags a consumer is allowed to switch to via `as`. Defaults to the widest
262
+ * `ElementType`, under which `AllowedOf<G>` imposes no restriction at all (see
263
+ * `PolymorphicControlProps.as`'s own comment in the React adapter for the concrete effect this
264
+ * has at a component's actual call site).
265
+ */
266
+ TAllowed extends ElementType = ElementType> {
267
+ default: TDefault;
268
+ props: Props;
269
+ variants: Variants;
270
+ preset: TPreset;
271
+ allowed: TAllowed;
272
+ }
273
+ /** This component's variant definitions. See `PolymorphicGenerics`'s `Variants` parameter. */
274
+ type VariantsOf<T extends PolymorphicGenerics> = T['variants'];
275
+ /** This component's named presets. See `PolymorphicGenerics`'s `TPreset` parameter. */
276
+ type RecipeOf<T extends PolymorphicGenerics> = T['preset'];
277
+ /** The element/tag this component renders as by default. See `PolymorphicGenerics`'s `TDefault`
278
+ * parameter. */
279
+ type DefaultOf<T extends PolymorphicGenerics> = T['default'];
280
+ /** This component's own declared props, before variants are mixed in. See `PolymorphicGenerics`'s
281
+ * `Props` parameter. */
282
+ type PropsOf<T extends PolymorphicGenerics> = T['props'];
283
+ //#endregion
284
+ //#region ../../lib/primitive/src/types/variants/compound/compound-variant.d.ts
285
+ type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
286
+ type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
287
+ type CompoundVariantConditions<V extends VariantMap> = Simplify<{ [K in keyof V]: CompoundVariantConditionValue<V, K>; }>;
288
+ type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
289
+ type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
290
+ type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
291
+ class: VariantValue;
292
+ };
293
+ //#endregion
294
+ //#region ../../lib/primitive/src/types/variants/compound/cva-compounds.d.ts
295
+ interface CVACompounds<V extends VariantMap> {
296
+ compoundVariants?: readonly CompoundVariant<V>[];
297
+ }
298
+ //#endregion
299
+ //#region ../../lib/primitive/src/types/variants/compound/cva-defaults.d.ts
300
+ interface CVADefaults<V extends VariantMap> {
301
+ defaultVariants?: DefaultVariants<V>;
302
+ }
303
+ //#endregion
304
+ //#region ../../lib/primitive/src/types/variants/compound/cva-variants.d.ts
305
+ interface CVAVariants<V extends VariantMap> {
306
+ variants?: V;
307
+ }
308
+ //#endregion
309
+ //#region ../../lib/primitive/src/types/pipeline/base-class-options.d.ts
310
+ interface BaseClassOptions {
311
+ baseClassName?: ClassName;
312
+ }
313
+ //#endregion
314
+ //#region ../../lib/primitive/src/types/pipeline/class-pipeline-fn.d.ts
315
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string | undefined;
316
+ //#endregion
317
+ //#region ../../lib/primitive/src/types/pipeline/recipe-options.d.ts
318
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
319
+ recipeMap?: StringMap<RecipeTarget<TVariants>>;
320
+ }
321
+ //#endregion
322
+ //#region ../../lib/primitive/src/types/pipeline/tag-map-options.d.ts
323
+ interface TagMapOptions {
324
+ tagMap?: TagMap;
325
+ }
326
+ //#endregion
327
+ //#region ../../lib/primitive/src/types/pipeline/composition-options.d.ts
328
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
329
+ //#endregion
330
+ //#region ../../lib/primitive/src/types/pipeline/cva-system-options.d.ts
331
+ type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
332
+ //#endregion
333
+ //#region ../../lib/primitive/src/types/pipeline/style-options.d.ts
334
+ type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
335
+ //#endregion
336
+ //#region ../../lib/primitive/src/types/pipeline/class-pipeline-options.d.ts
337
+ type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
338
+ //#endregion
339
+ //#region ../../lib/primitive/src/types/class/owned-prop-keys.d.ts
340
+ type OwnedPropKeys = ReadonlySet<string>;
341
+ //#endregion
342
+ //#region ../../lib/primitive/src/types/class/class-plugin.d.ts
343
+ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
344
+ pipeline: ClassPipelineFn;
345
+ ownedKeys?: OwnedPropKeys;
346
+ readonly _pluginProps?: TProps;
347
+ }>;
348
+ //#endregion
349
+ //#region ../../lib/primitive/src/types/class/class-plugin-factory.d.ts
350
+ type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics) => ClassPlugin<TProps>;
351
+ /** `ClassPluginFactory` with its plugin-owned-props generic erased — the common form used
352
+ * wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
353
+ * capability wiring). */
354
+ type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
355
+ type ExtractPluginProps<TPlugin extends AnyClassPluginFactory> = TPlugin extends ClassPluginFactory<infer T> ? string extends keyof T ? NoPluginProps : T : NoPluginProps;
356
+ //#endregion
357
+ //#region ../../lib/primitive/src/types/aria-rule/aria-context.d.ts
358
+ type AriaContext = {
359
+ /**
360
+ * The intrinsic HTML tag being evaluated.
361
+ */
362
+ readonly tag: IntrinsicTag;
363
+ /**
364
+ * The implicit ARIA role associated with the intrinsic tag.
365
+ */
366
+ readonly implicitRole: AriaRole | undefined;
367
+ /**
368
+ * The effective ARIA role after considering the element's explicit
369
+ * `role` attribute or component-provided role.
370
+ */
371
+ readonly effectiveRole: string | undefined;
372
+ /**
373
+ * The component's props available to the ARIA policy engine.
374
+ */
375
+ readonly props: ReadonlyDeep<IntrinsicProps>;
376
+ /**
377
+ * Variant prop names declared by the component.
378
+ *
379
+ * The adapter uses these names to determine which props are intercepted
380
+ * before reaching the DOM. A rule asserting a fact about a real HTML
381
+ * attribute should therefore treat a key present here as a component
382
+ * variant rather than a DOM attribute.
383
+ *
384
+ * An empty set indicates no variant props are declared — the case for
385
+ * evaluations with no factory context, such as `AriaPolicyEngine.evaluate`.
386
+ */
387
+ readonly variantKeys: ReadonlySet<string>;
388
+ };
389
+ //#endregion
390
+ //#region ../../lib/primitive/src/types/aria-rule/fix-kind.d.ts
391
+ type RemoveAttributeFixKind = 'removeAttribute';
392
+ type InjectLiveFixKind = 'injectLive';
393
+ type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
394
+ //#endregion
395
+ //#region ../../lib/primitive/src/types/aria-rule/aria-fix.d.ts
396
+ type AriaFixResult = {
397
+ applied: false;
398
+ next: ReadonlyDeep<IntrinsicProps>;
399
+ } | {
400
+ applied: true;
401
+ next: ReadonlyDeep<IntrinsicProps>;
402
+ previous: ReadonlyDeep<IntrinsicProps>;
403
+ };
404
+ type AriaFix = {
405
+ readonly kind: FixKind;
406
+ /** The attribute a `'removeAttribute'`/`'injectLive'` fix targets — always set for those
407
+ * kinds, absent for kinds with no single-attribute target (`'removeRole'`, etc.). */
408
+ readonly attribute?: string;
409
+ readonly priority?: number;
410
+ readonly source?: string;
411
+ readonly apply: (context: AriaContext) => AriaFixResult;
412
+ };
413
+ //#endregion
414
+ //#region ../../lib/primitive/src/types/aria-rule/severity.d.ts
415
+ type Severity = 'error' | 'warning' | (string & {});
416
+ //#endregion
417
+ //#region ../../lib/primitive/src/types/aria-rule/aria-result.d.ts
418
+ type AriaInvalidBase<M extends string = string> = {
419
+ valid: false;
420
+ severity: Severity;
421
+ message?: M;
422
+ attribute?: string;
423
+ diagnostic?: DiagnosticInput;
424
+ };
425
+ type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
426
+ fixable: true;
427
+ fix: AriaFix;
428
+ };
429
+ type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
430
+ fixable: false;
431
+ };
432
+ type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
433
+ type AriaResult = ValidResult | AriaInvalidResult;
434
+ //#endregion
435
+ //#region ../../lib/primitive/src/types/aria-rule/aria-rule.d.ts
436
+ type AriaRule<C extends AriaContext = AriaContext> = ((context: C) => readonly AriaResult[]) & {
437
+ readonly readsProps?: readonly string[];
438
+ readonly tags?: readonly string[];
439
+ };
440
+ //#endregion
441
+ //#region ../../lib/primitive/src/types/factory/prop-normalizer.d.ts
442
+ type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
443
+ //#endregion
444
+ //#region ../../lib/primitive/src/types/factory/enforcement-options.d.ts
445
+ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
446
+ /**
447
+ * Accepts a preset name (`'warn'`, `'throw'`, `'silent'`) or a full `Diagnostics`
448
+ * instance for custom reporting/policy. The string form needs no import from
449
+ * `@praxis-kit/diagnostics`.
450
+ */
451
+ readonly diagnostics?: Diagnostics | DiagnosticsMode;
452
+ /**
453
+ * ARIA/accessibility rules evaluated against the resolved tag and props on every render.
454
+ * Each rule is a function receiving the current context and returning zero or more
455
+ * violations, some of which can carry an auto-applicable fix (see `createRemoveAttributeRule`
456
+ * and friends in `praxis-kit/contract`).
457
+ */
458
+ readonly aria?: readonly AriaRule[];
459
+ /**
460
+ * Rules that need `AriaPolicyEngine`'s fix-application/caching machinery
461
+ * (`AriaRule`'s `readsProps`, fixable `AriaFix` results) but have no
462
+ * relationship to ARIA semantics — an HTML fact or a security check like a
463
+ * dangerous-URL-scheme guard, for example. Evaluated together with `aria`
464
+ * (both run through the same engine, merged into one rule set) — this is a
465
+ * separate bucket purely so a non-ARIA rule doesn't have to sit under the
466
+ * misleading `aria` name to get the machinery it needs.
467
+ */
468
+ readonly rules?: readonly AriaRule[];
469
+ /**
470
+ * Declares which children are valid, by name, match predicate, and cardinality (e.g. "at
471
+ * least 1, at most 4 `Button` children"). Open by default — children matching no rule are
472
+ * still allowed unless `exclusiveChildren` is set.
473
+ */
474
+ readonly children?: readonly ChildRuleInput[];
475
+ /**
476
+ * When true, only children matching a `children` rule (or text, per `allowText`)
477
+ * are valid — anything else is rejected. Default: false (open — children not
478
+ * matching any rule are allowed).
479
+ */
480
+ readonly exclusiveChildren?: boolean;
481
+ /**
482
+ * When false, text/number child nodes are rejected regardless of exclusiveChildren
483
+ * or any listed rule. Default: true.
484
+ */
485
+ readonly allowText?: boolean;
486
+ /**
487
+ * Prop transforms composed with the component's own `normalize` (from `FactoryOptions`) and
488
+ * run before it. Unlike `normalize`, these live in the enforcement bucket because they
489
+ * typically encode a built-in HTML/ARIA fact rather than component-specific behavior.
490
+ */
491
+ readonly props?: readonly PropNormalizer[];
492
+ /** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
493
+ readonly allowedAs?: readonly TAllowed[];
494
+ };
495
+ //#endregion
496
+ //#region ../../lib/primitive/src/types/factory/styling-options.d.ts
497
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
498
+ /** Class applied to every instance regardless of variant selection. */
499
+ readonly base?: ClassName;
500
+ /**
501
+ * Named variant groups (e.g. `intent`, `size`), each mapping its possible values to a
502
+ * class string. A consumer selects a value per group as a prop (`<Button intent="primary">`).
503
+ */
504
+ readonly variants?: V;
505
+ /** Value used for a variant group when the consumer doesn't pass one explicitly. */
506
+ readonly defaults?: Partial<DefaultVariants<V>>;
507
+ /**
508
+ * Applies an extra class only when a specific *combination* of variant selections matches —
509
+ * for cases `variants` alone can't express (e.g. `intent: 'primary'` + `size: 'lg'` together
510
+ * need a class neither variant would add on its own).
511
+ */
512
+ readonly compounds?: readonly CompoundVariant<V>[];
513
+ /**
514
+ * Named bundles of variant values a component defines up front. A caller activates one by name
515
+ * through the `recipe` prop (e.g. `<Button recipe="cta">` instead of setting `intent`/`size`
516
+ * individually) — `presets` is the store, `recipe` is the selector, which is why the field and
517
+ * the prop read differently. Explicit props always win over the activated bundle. The value type
518
+ * is `RecipeMap` (see `lib/primitive/src/types/variants/recipe-map.ts`).
519
+ */
520
+ readonly presets?: TPreset;
521
+ /** Maps a resolved tag directly to a raw class string, independent of the variant system. */
522
+ readonly tags?: Readonly<TagMap>;
523
+ /**
524
+ * A `ClassPluginFactory` (e.g. the Tailwind layout pipeline) that extends class resolution
525
+ * with its own owned props, layered on top of `variants`/`presets`/`tags`.
526
+ */
527
+ readonly plugin?: TPlugin;
528
+ /**
529
+ * A cache-key → resolved-class-string lookup for every statically-known variant
530
+ * combination, skipping runtime class computation entirely when a match is found. Normally
531
+ * generated by a build-time class-extraction plugin rather than hand-authored.
532
+ */
533
+ readonly precomputedClasses?: Readonly<StringMap<string>>;
534
+ };
535
+ //#endregion
536
+ //#region ../../lib/primitive/src/types/factory/factory-options.d.ts
537
+ type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
538
+ normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
539
+ }['normalize'];
540
+ /**
541
+ * The type-erased shape of {@link FactoryOptions} — every generic parameter widened to its bound.
542
+ *
543
+ * Use it for a value that must hold *any* factory config (a registry, a generic wrapper). It
544
+ * cannot check `styling.compounds` conditions against the real variant keys/values, because it
545
+ * has forgotten what they are — for that, annotate against `FactoryOptions<...>` with the concrete
546
+ * generics (or `satisfies FactoryOptions<'button', Props, typeof variants>`), which keeps an
547
+ * invalid compound condition a type error rather than a silent no-op.
548
+ */
549
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
550
+ /**
551
+ * The framework-neutral component-authoring config passed to `createContractComponent` in every
552
+ * adapter: default tag + name, own-prop defaults, a `normalize` transform, `styling` (variants,
553
+ * base classes, presets, class plugin), `enforcement` (ARIA + children contracts), `subComponents`,
554
+ * and `onElement`.
555
+ *
556
+ * `satisfies FactoryOptions<TDefault, Props, typeof variants, ...>` on a config object narrows
557
+ * `styling.compounds` conditions to the real per-variant-key shape — including resolving a
558
+ * boolean-shaped axis (`{ true, false }`) to a real `boolean` — so a condition naming a variant or
559
+ * value that does not exist is a compile error. `AnyFactoryOptions` cannot do this.
560
+ */
561
+ 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> = {
562
+ /** The intrinsic tag the component renders by default. Overridable per instance via `as`. */
563
+ readonly tag?: TDefault;
564
+ /** Display name used in diagnostics, dev tools, and generated component naming. */
565
+ readonly name?: string;
566
+ /** Values used for the component's own (non-variant) props when the consumer omits them. */
567
+ readonly defaults?: Partial<NoInfer<Props>>;
568
+ /**
569
+ * A pure `(props) => props` transform run on every render, after `enforcement.props`'s
570
+ * normalizers see the same input. Use this for component-specific prop shaping — anything
571
+ * that depends on live instance state or the real DOM element belongs in `onElement` instead.
572
+ *
573
+ * Accepts either a single transform or an array of them, mirroring the `enforcement.props`
574
+ * array convention. An array is composed left to right — each entry receives the previous
575
+ * entry's *complete* output, not a merged patch — so unlike an `enforcement.props` normalizer
576
+ * (which returns a partial patch), a later `normalize` entry can also remove a key an earlier
577
+ * one added. An empty array is treated as no transform.
578
+ */
579
+ readonly normalize?: NormalizeFn<NoInfer<Props>> | ReadonlyArray<NormalizeFn<NoInfer<Props>>>;
580
+ /** Variant groups, base classes, presets, and the optional class-resolution plugin. */
581
+ readonly styling?: StylingOptions<V, TPreset, TPlugin>;
582
+ /** ARIA rules, child-content contracts, and other runtime validation for this component. */
583
+ readonly enforcement?: EnforcementOptions<TAllowed>;
584
+ /**
585
+ * Adapter-resolved diagnostics default, spread in by `resolveAdapterCommonOptions`. Not meant to
586
+ * be set directly by component authors — use `enforcement.diagnostics` to override per component.
587
+ */
588
+ readonly diagnostics?: Diagnostics;
589
+ /**
590
+ * Sub-components to attach to the generated root component, producing a
591
+ * compound component API (for example, `Card.Header`, `Card.Content`,
592
+ * and `Card.Footer`). Purely additive — has no effect on
593
+ * `enforcement.children`; author child rules explicitly if the component
594
+ * needs to validate its children.
595
+ */
596
+ readonly subComponents?: SubComponentMap;
597
+ /**
598
+ * Called once per instance, when the real underlying DOM element first
599
+ * exists, in every adapter — via that adapter's own native mount
600
+ * lifecycle, never through the props/attribute pipeline. Use this for
601
+ * wiring that needs the actual element (native imperative methods like
602
+ * `dialogEl.showModal()`, native events like `close`/`cancel` that have
603
+ * no prop-based equivalent), not for anything expressible as a plain
604
+ * prop.
605
+ *
606
+ * `element` is typed to the real DOM interface of every tag the rendered
607
+ * element could actually be — `TDefault` plus whatever `enforcement.allowed`
608
+ * permits via `as` (`HTMLDialogElement` for `tag: 'dialog'`,
609
+ * `HTMLDetailsElement` for `tag: 'details'`, and so on) — no cast needed to
610
+ * reach tag-specific members. A component that leaves `allowed`
611
+ * unconstrained (any tag reachable via `as`) falls back to `HTMLElement`,
612
+ * which still covers members every element shares (`showPopover()` and
613
+ * friends); restrict `enforcement.allowed` to the tags `onElement`
614
+ * actually knows how to handle to get real narrowing.
615
+ *
616
+ * `getProps` returns the instance's *current* resolved props at call
617
+ * time — read it from inside a listener registered once at mount, rather
618
+ * than re-subscribing on every prop change.
619
+ *
620
+ * Return a cleanup function to run when the instance unmounts.
621
+ */
622
+ readonly onElement?: (element: ElementForTag<TDefault | TAllowed>, getProps: () => Readonly<Props>) => void | (() => void);
623
+ };
624
+ //#endregion
625
+ //#region ../../lib/adapter-utils/src/runtime/define-component.d.ts
626
+ export declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
627
+ //#endregion
628
+ //#region ../../adapters/solid/src/types/primitives.d.ts
629
+ type UnknownProps = AnyRecord;
630
+ type SolidElement = JSX.Element;
631
+ //#endregion
632
+ //#region ../../adapters/solid/src/solid-options.d.ts
633
+ type SolidFactoryOptions<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends RecipeMap<Variants> = NoPreset, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = FactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & {
634
+ /**
635
+ * Return true for any prop key that should be consumed but not forwarded to the DOM.
636
+ * Receives `runtime.options.variantKeys` as a convenience if needed.
637
+ */
638
+ filterProps?: (key: string, variantKeys: ReadonlySet<string>) => boolean;
639
+ };
640
+ //#endregion
641
+ //#region ../../adapters/solid/src/types/polymorphic-props.d.ts
642
+ type ElementRef<T extends ElementType> = T extends IntrinsicTag ? HTMLElementTagNameMap[T] : unknown;
643
+ type IntrinsicJSXProps<T extends ElementType> = T extends IntrinsicTag ? JSX.IntrinsicElements[T] : UnknownProps;
644
+ type ControlProps<G extends PolymorphicGenerics, TAs extends ElementType> = OmitIndexSignature<PropsOf<G>> & OmitIndexSignature<VariantProps<VariantsOf<G>>> & {
645
+ as?: TAs;
646
+ class?: ClassName | undefined;
647
+ recipe?: keyof RecipeOf<G>;
648
+ ref?: (el: ElementRef<TAs>) => void;
649
+ };
650
+ type SharedProps<G extends PolymorphicGenerics, TAs extends ElementType> = Omit<IntrinsicJSXProps<TAs>, keyof ControlProps<G, TAs> | 'children' | 'ref'> & ControlProps<G, TAs>;
651
+ /**
652
+ * Props an `asChild` render function receives once defaults, variant classes, and ARIA role
653
+ * resolution have all run (see `buildSlotProps` in `render.tsx`). `class` is narrowed to a
654
+ * resolved `string`, not the wider `ClassName` a caller may pass in. `ref` is typed for spreading
655
+ * straight onto a concrete element, unlike `AsChildProps.ref`'s bare `unknown`. `role` is
656
+ * intentionally left off the type entirely — a render function that needs it casts locally.
657
+ *
658
+ * The `ref`/`role` reasoning (contravariance, why every representation of `role` fails to spread
659
+ * onto Solid's per-element JSX types) is real design intent, not obvious from the type alone — see
660
+ * `DECISIONS.md` → "`adapters/solid` — `ResolvedSlotProps`'s `ref`/`role` typing" for the full case.
661
+ */
662
+ type ResolvedSlotProps<G extends PolymorphicGenerics> = Partial<OmitIndexSignature<PropsOf<G>>> & OmitIndexSignature<VariantProps<VariantsOf<G>>> & {
663
+ class?: string | undefined;
664
+ ref?: (el: Element) => void;
665
+ };
666
+ /** An `asChild` render function, receiving the fully-resolved `ResolvedSlotProps<G>`. */
667
+ type SlotRenderFn<G extends PolymorphicGenerics> = (props: ResolvedSlotProps<G>) => SolidElement;
668
+ type AsChildProps<G extends PolymorphicGenerics> = Partial<OmitIndexSignature<PropsOf<G>>> & OmitIndexSignature<VariantProps<VariantsOf<G>>> & {
669
+ as?: never;
670
+ asChild: true;
671
+ children: SlotRenderFn<G>;
672
+ class?: ClassName | undefined;
673
+ recipe?: keyof RecipeOf<G>;
674
+ ref?: unknown;
675
+ };
676
+ type PolymorphicProps<G extends PolymorphicGenerics, TAs extends ElementType = DefaultOf<G>> = Simplify<(SharedProps<G, TAs> & {
677
+ asChild?: false;
678
+ children?: unknown;
679
+ }) | AsChildProps<G>>;
680
+ type PolymorphicComponent<G extends PolymorphicGenerics> = {
681
+ <TAs extends ElementType = DefaultOf<G>>(props: PolymorphicProps<G, TAs>): JSX.Element;
682
+ /**
683
+ * Non-generic fallback overload used for type extraction.
684
+ *
685
+ * TypeScript resolves conditional types such as
686
+ * `ComponentProps<typeof Component>` against only the final overload.
687
+ * Anchoring that overload to the default element preserves correct prop
688
+ * inference for tools such as Storybook and `ComponentProps`.
689
+ */
690
+ (props: PolymorphicProps<G, DefaultOf<G>>): JSX.Element;
691
+ displayName?: string;
692
+ };
693
+ /**
694
+ * A component's full prop contract — naming symmetry with React's/Preact's `ContractProps<T,
695
+ * Mode>`, not a fix for a gap: Solid has no version of the
696
+ * overload-resolution ceiling those two adapters need a marker to work around. `PolymorphicProps<G,
697
+ * TAs>` already folds both render modes into one unioned type (rather than two separate types the
698
+ * way React/Preact split them), and `PolymorphicComponent<G>`'s fallback overload already returns
699
+ * that whole union — so this alias is just `PolymorphicProps<G>` under a familiar name.
700
+ */
701
+ type ContractProps<G extends PolymorphicGenerics> = PolymorphicProps<G>;
702
+ //#endregion
703
+ //#region ../../adapters/solid/src/create-contract-component.d.ts
704
+ /**
705
+ * Creates a polymorphic Solid component with praxis-kit contracts applied.
706
+ *
707
+ * ```tsx
708
+ * const Button = createContractComponent({
709
+ * tag: 'button',
710
+ * name: 'Button',
711
+ * styling: {
712
+ * base: 'btn',
713
+ * variants: { intent: { primary: 'btn--primary', ghost: 'btn--ghost' } },
714
+ * defaults: { intent: 'primary' },
715
+ * },
716
+ * })
717
+ *
718
+ * <Button intent="ghost" as="a" href="/home">Home</Button>
719
+ * ```
720
+ *
721
+ * `ref` is forwarded as an ordinary Solid ref callback. Pass `subComponents` to attach named
722
+ * sub-components (`Card.Header`) and `onElement` to run setup once the real DOM element exists.
723
+ */
724
+ export declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = NoVariants, TPreset extends RecipeMap<Variants> = NoPreset, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TSubComponents extends Readonly<AnyRecord> = EmptyRecord>(options: SolidFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & {
725
+ readonly subComponents?: TSubComponents;
726
+ }): MergeRecords<PolymorphicComponent<PolymorphicGenerics<TDefault, MergeRecords<Props, ExtractPluginProps<TPlugin>>, Variants, TPreset>>, TSubComponents>;
727
+ //#endregion
728
+ export type { AnyFactoryOptions, ContractProps, ElementRef, ElementType, EmptyRecord, FactoryOptions, PolymorphicComponent, PolymorphicGenerics, PolymorphicProps, ResolvedSlotProps, SlotRenderFn, SolidFactoryOptions };