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,677 @@
1
+ import "clsx";
2
+ import { Diagnostic, DiagnosticInput, Diagnostics as Diagnostics$1, DiagnosticsMode } from "../_shared/diagnostics.js";
3
+ import { ReadonlyDeep, RequireAtLeastOne, Simplify } from "type-fest";
4
+ //#region ../../lib/foundation/src/string-map.d.ts
5
+ /**
6
+ * A string-keyed object whose values are of type `T`.
7
+ */
8
+ type StringMap<T = unknown> = Record<string, T>;
9
+ /**
10
+ * A string-keyed object with values of unknown type.
11
+ */
12
+ type AnyRecord = StringMap<unknown>;
13
+ //#endregion
14
+ //#region ../../lib/primitive/src/types/any-record.d.ts
15
+ /**
16
+ * An object type with no named properties.
17
+ *
18
+ * Unlike `{}`, this excludes arbitrary properties during type operations while
19
+ * still satisfying `extends object`.
20
+ */
21
+ type EmptyRecord = Record<never, never>;
22
+ /**
23
+ * A compound component's named sub-components, for example
24
+ * `{ Header, Content, Footer }`.
25
+ */
26
+ type SubComponentMap = Readonly<AnyRecord>;
27
+ //#endregion
28
+ //#region ../../lib/primitive/src/types/intrinsic-tag.d.ts
29
+ type IntrinsicTag = keyof HTMLElementTagNameMap;
30
+ //#endregion
31
+ //#region ../../lib/primitive/src/types/element-type.d.ts
32
+ type ElementType = IntrinsicTag | (string & {});
33
+ /**
34
+ * Resolves a component's default tag to its real DOM interface — `HTMLDialogElement` for
35
+ * `'dialog'`, `HTMLDetailsElement` for `'details'`, and so on — falling back to `HTMLElement`
36
+ * for custom-element tags or anything not in `HTMLElementTagNameMap`. Used to type
37
+ * `FactoryOptions.onElement`'s `element` param so component authors get direct, correctly-typed
38
+ * access to tag-specific native members (`dialogEl.showModal()`) without an unsafe cast.
39
+ *
40
+ * The fallback is `HTMLElement`, not the more generic `Element` — every tag reachable through
41
+ * `IntrinsicTag` extends it, and so does every custom element per spec, so members `HTMLElement`
42
+ * itself declares (`showPopover()`/`hidePopover()`/`togglePopover()`, the `popover` attribute)
43
+ * stay directly accessible even for tags with no dedicated entry in `HTMLElementTagNameMap`.
44
+ */
45
+ type ElementForTag<TDefault extends ElementType> = TDefault extends keyof HTMLElementTagNameMap ? HTMLElementTagNameMap[TDefault] : HTMLElement;
46
+ //#endregion
47
+ //#region ../../lib/primitive/src/constants/aria/known-aria-roles.d.ts
48
+ 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"];
49
+ type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
50
+ //#endregion
51
+ //#region ../../lib/primitive/src/types/primitives/index.d.ts
52
+ type Booleanish = boolean | 'true' | 'false';
53
+ type ClassName = string | string[];
54
+ type NonEmptyArray<T> = [T, ...T[]];
55
+ type Numberish = number | `${number}`;
56
+ type Primitive = string | number | boolean;
57
+ type AriaRole = KnownAriaRole | (string & {});
58
+ type IntrinsicProps = AnyRecord & {
59
+ role?: AriaRole;
60
+ };
61
+ type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
62
+ //#endregion
63
+ //#region ../../lib/primitive/src/types/contracts/cardinality.d.ts
64
+ type MinMax = {
65
+ min: number;
66
+ max: number;
67
+ };
68
+ type CardinalityInput = Partial<MinMax>;
69
+ //#endregion
70
+ //#region ../../lib/primitive/src/types/contracts/child-rule-context.d.ts
71
+ /**
72
+ * Resolved per-instance state available to a dynamic (`dynamic(...)`) child
73
+ * rule field — the same tag/props every adapter already computes before
74
+ * evaluating children, exposed so a rule can vary by them (e.g. cardinality
75
+ * that depends on the resolved `as` tag).
76
+ */
77
+ type ChildRuleContext = {
78
+ readonly tag: unknown;
79
+ readonly props: Readonly<AnyRecord>;
80
+ };
81
+ //#endregion
82
+ //#region ../../lib/primitive/src/types/contracts/children-evaluator.d.ts
83
+ /** Structural counterpart to the runtime `ChildrenEvaluator` class — `lib/primitive`
84
+ * may not depend on `lib/contract` (the layer boundary `eslint-plugin-boundaries` enforces via
85
+ * `configs/architecture.ts`), so this describes only the shape consumers actually call. Mirrors
86
+ * `AriaEngine`'s pattern. */
87
+ type ChildrenEvaluator = {
88
+ evaluate: (children: unknown[], context?: ChildRuleContext) => void;
89
+ };
90
+ //#endregion
91
+ //#region ../../lib/primitive/src/rule/rule-brand.d.ts
92
+ declare const RULE_BRAND: unique symbol;
93
+ //#endregion
94
+ //#region ../../lib/primitive/src/types/rule/dynamic-rule.d.ts
95
+ type DynamicRule<T, C = unknown> = {
96
+ readonly [RULE_BRAND]: true;
97
+ resolve(context: C): T;
98
+ };
99
+ //#endregion
100
+ //#region ../../lib/primitive/src/types/rule/rule.d.ts
101
+ type Rule<T, C = unknown> = T | DynamicRule<T, C>;
102
+ //#endregion
103
+ //#region ../../lib/primitive/src/types/contracts/child-rule-match.d.ts
104
+ type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
105
+ //#endregion
106
+ //#region ../../lib/primitive/src/types/contracts/child-rule-position.d.ts
107
+ type ChildRulePosition = 'first' | 'last' | 'any';
108
+ //#endregion
109
+ //#region ../../lib/primitive/src/types/contracts/child-rule-input.d.ts
110
+ type ChildRuleInput<T = unknown, U extends T = T> = {
111
+ name: string;
112
+ match: ChildRuleMatch<T, U>;
113
+ /**
114
+ * Either a static cardinality, or `dynamic((ctx) => ...)` to derive it from
115
+ * the resolved tag/props (e.g. a different max depending on `as`). `match`
116
+ * stays static-only — it's already a function, so a dynamic wrapper would
117
+ * be indistinguishable from the predicate itself without one.
118
+ */
119
+ cardinality?: Rule<CardinalityInput, ChildRuleContext>;
120
+ position?: ChildRulePosition;
121
+ /**
122
+ * Optional component-type reference for O(1) dispatch index.
123
+ * When provided for every rule, the matcher reads child.type instead of
124
+ * calling every match function on every child (O(n×m) → O(n+m)).
125
+ */
126
+ type?: unknown;
127
+ };
128
+ //#endregion
129
+ //#region ../../lib/primitive/src/types/validation/valid-result.d.ts
130
+ type ValidResult = {
131
+ valid: true;
132
+ };
133
+ //#endregion
134
+ //#region ../../lib/primitive/src/types/variants/string-to-boolean.d.ts
135
+ type StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T;
136
+ //#endregion
137
+ //#region ../../lib/primitive/src/types/variants/variant-value.d.ts
138
+ type VariantValue = string | string[];
139
+ //#endregion
140
+ //#region ../../lib/primitive/src/types/variants/variant-states.d.ts
141
+ type VariantStates<K extends string = string> = Record<K, VariantValue>;
142
+ //#endregion
143
+ //#region ../../lib/primitive/src/types/variants/variant-map.d.ts
144
+ type VariantMap<V extends string = string, K extends string = string> = Record<V, VariantStates<K>>;
145
+ //#endregion
146
+ //#region ../../lib/primitive/src/types/variants/variant-key.d.ts
147
+ type VariantKey<V extends VariantMap, K extends keyof V> = StringToBoolean<keyof V[K] & string>;
148
+ //#endregion
149
+ //#region ../../lib/primitive/src/types/variants/variant-selection.d.ts
150
+ /**
151
+ * A partial selection of variant states authored at factory definition time.
152
+ *
153
+ * Uses `keyof V[K]` directly (not `VariantKey`) so TypeScript can eagerly
154
+ * resolve the union at constraint-check time without deferred conditional types.
155
+ */
156
+ type VariantSelection<V extends VariantMap> = { [K in keyof V]?: keyof V[K]; };
157
+ //#endregion
158
+ //#region ../../lib/primitive/src/types/variants/default-variants.d.ts
159
+ type NormalizedVariantValue<K extends string> = string extends K ? Primitive : K extends 'true' | 'false' ? Booleanish : K extends `${number}` ? Numberish : K;
160
+ type DefaultVariants<V extends VariantMap> = { [K in keyof V]?: NormalizedVariantValue<keyof V[K] & string>; };
161
+ //#endregion
162
+ //#region ../../lib/primitive/src/types/variants/recipe-map.d.ts
163
+ /**
164
+ * A static, immutable map of named presets to partial variant selections.
165
+ *
166
+ * Presets are named bundles of variant props that callers activate by key,
167
+ * avoiding the need to repeat variant combinations at each call site.
168
+ */
169
+ type RecipeMap<V extends VariantMap = VariantMap> = Readonly<StringMap<VariantSelection<V>>>;
170
+ //#endregion
171
+ //#region ../../lib/primitive/src/types/variants/recipe-target.d.ts
172
+ type RecipeTarget<TVariants extends VariantMap = VariantMap> = VariantSelection<TVariants>;
173
+ //#endregion
174
+ //#region ../../lib/primitive/src/types/variants/compound/compound-variant.d.ts
175
+ type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
176
+ type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
177
+ type CompoundVariantConditions<V extends VariantMap> = Simplify<{ [K in keyof V]: CompoundVariantConditionValue<V, K>; }>;
178
+ type CompoundVariantRequiredConditions<V extends VariantMap> = RequireAtLeastOneIfNotEmpty<CompoundVariantConditions<V>>;
179
+ type CompoundVariantBase<V extends VariantMap> = keyof V extends never ? EmptyRecord : CompoundVariantRequiredConditions<V>;
180
+ type CompoundVariant<V extends VariantMap> = CompoundVariantBase<V> & {
181
+ class: VariantValue;
182
+ };
183
+ //#endregion
184
+ //#region ../../lib/primitive/src/types/variants/compound/cva-compounds.d.ts
185
+ interface CVACompounds<V extends VariantMap> {
186
+ compoundVariants?: readonly CompoundVariant<V>[];
187
+ }
188
+ //#endregion
189
+ //#region ../../lib/primitive/src/types/variants/compound/cva-defaults.d.ts
190
+ interface CVADefaults<V extends VariantMap> {
191
+ defaultVariants?: DefaultVariants<V>;
192
+ }
193
+ //#endregion
194
+ //#region ../../lib/primitive/src/types/variants/compound/cva-variants.d.ts
195
+ interface CVAVariants<V extends VariantMap> {
196
+ variants?: V;
197
+ }
198
+ //#endregion
199
+ //#region ../../lib/primitive/src/types/pipeline/base-class-options.d.ts
200
+ interface BaseClassOptions {
201
+ baseClassName?: ClassName;
202
+ }
203
+ //#endregion
204
+ //#region ../../lib/primitive/src/types/pipeline/class-pipeline-fn.d.ts
205
+ type ClassPipelineFn = (tag: unknown, props: AnyRecord, className?: ClassName, recipe?: string) => string | undefined;
206
+ //#endregion
207
+ //#region ../../lib/primitive/src/types/pipeline/recipe-options.d.ts
208
+ interface RecipeOptions<TVariants extends VariantMap = VariantMap> {
209
+ recipeMap?: StringMap<RecipeTarget<TVariants>>;
210
+ }
211
+ //#endregion
212
+ //#region ../../lib/primitive/src/types/pipeline/tag-map-options.d.ts
213
+ interface TagMapOptions {
214
+ tagMap?: TagMap;
215
+ }
216
+ //#endregion
217
+ //#region ../../lib/primitive/src/types/pipeline/composition-options.d.ts
218
+ type CompositionOptions<TVariants extends VariantMap = VariantMap> = Simplify<TagMapOptions & RecipeOptions<TVariants>>;
219
+ //#endregion
220
+ //#region ../../lib/primitive/src/types/pipeline/cva-system-options.d.ts
221
+ type CVASystemOptions<TVariants extends VariantMap = VariantMap> = Simplify<CVAVariants<TVariants> & CVADefaults<TVariants> & CVACompounds<TVariants>>;
222
+ //#endregion
223
+ //#region ../../lib/primitive/src/types/pipeline/style-options.d.ts
224
+ type StyleOptions<TVariants extends VariantMap = VariantMap> = Simplify<BaseClassOptions & CVASystemOptions<TVariants>>;
225
+ //#endregion
226
+ //#region ../../lib/primitive/src/types/pipeline/class-pipeline-options.d.ts
227
+ type ClassPipelineOptions<TVariants extends VariantMap = VariantMap> = Simplify<StyleOptions<TVariants> & CompositionOptions<TVariants>>;
228
+ //#endregion
229
+ //#region ../../lib/primitive/src/types/class/owned-prop-keys.d.ts
230
+ type OwnedPropKeys = ReadonlySet<string>;
231
+ //#endregion
232
+ //#region ../../lib/primitive/src/types/class/class-plugin.d.ts
233
+ type ClassPlugin<TProps extends AnyRecord = EmptyRecord> = Readonly<{
234
+ pipeline: ClassPipelineFn;
235
+ ownedKeys?: OwnedPropKeys;
236
+ readonly _pluginProps?: TProps;
237
+ }>;
238
+ //#endregion
239
+ //#region ../../lib/primitive/src/types/class/class-plugin-factory.d.ts
240
+ type ClassPluginFactory<TProps extends AnyRecord = EmptyRecord> = <V extends VariantMap>(options: ClassPipelineOptions<V>, diagnostics: Diagnostics$1) => ClassPlugin<TProps>;
241
+ /** `ClassPluginFactory` with its plugin-owned-props generic erased — the common form used
242
+ * wherever a factory's concrete plugin-props shape isn't tracked (factory generics,
243
+ * capability wiring). */
244
+ type AnyClassPluginFactory = ClassPluginFactory<AnyRecord> | undefined;
245
+ //#endregion
246
+ //#region ../../lib/primitive/src/types/aria-rule/aria-context.d.ts
247
+ type AriaContext = {
248
+ /**
249
+ * The intrinsic HTML tag being evaluated.
250
+ */
251
+ readonly tag: IntrinsicTag;
252
+ /**
253
+ * The implicit ARIA role associated with the intrinsic tag.
254
+ */
255
+ readonly implicitRole: AriaRole | undefined;
256
+ /**
257
+ * The effective ARIA role after considering the element's explicit
258
+ * `role` attribute or component-provided role.
259
+ */
260
+ readonly effectiveRole: string | undefined;
261
+ /**
262
+ * The component's props available to the ARIA policy engine.
263
+ */
264
+ readonly props: ReadonlyDeep<IntrinsicProps>;
265
+ /**
266
+ * Variant prop names declared by the component.
267
+ *
268
+ * The adapter uses these names to determine which props are intercepted
269
+ * before reaching the DOM. A rule asserting a fact about a real HTML
270
+ * attribute should therefore treat a key present here as a component
271
+ * variant rather than a DOM attribute.
272
+ *
273
+ * An empty set indicates no variant props are declared — the case for
274
+ * evaluations with no factory context, such as `AriaPolicyEngine.evaluate`.
275
+ */
276
+ readonly variantKeys: ReadonlySet<string>;
277
+ };
278
+ //#endregion
279
+ //#region ../../lib/primitive/src/types/aria-rule/fix-kind.d.ts
280
+ type RemoveAttributeFixKind = 'removeAttribute';
281
+ type InjectLiveFixKind = 'injectLive';
282
+ type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
283
+ //#endregion
284
+ //#region ../../lib/primitive/src/types/aria-rule/aria-fix.d.ts
285
+ type AriaFixResult = {
286
+ applied: false;
287
+ next: ReadonlyDeep<IntrinsicProps>;
288
+ } | {
289
+ applied: true;
290
+ next: ReadonlyDeep<IntrinsicProps>;
291
+ previous: ReadonlyDeep<IntrinsicProps>;
292
+ };
293
+ type AriaFix = {
294
+ readonly kind: FixKind;
295
+ /** The attribute a `'removeAttribute'`/`'injectLive'` fix targets — always set for those
296
+ * kinds, absent for kinds with no single-attribute target (`'removeRole'`, etc.). */
297
+ readonly attribute?: string;
298
+ readonly priority?: number;
299
+ readonly source?: string;
300
+ readonly apply: (context: AriaContext) => AriaFixResult;
301
+ };
302
+ //#endregion
303
+ //#region ../../lib/primitive/src/types/aria-rule/severity.d.ts
304
+ type Severity = 'error' | 'warning' | (string & {});
305
+ //#endregion
306
+ //#region ../../lib/primitive/src/types/aria-rule/aria-result.d.ts
307
+ type AriaInvalidBase<M extends string = string> = {
308
+ valid: false;
309
+ severity: Severity;
310
+ message?: M;
311
+ attribute?: string;
312
+ diagnostic?: DiagnosticInput;
313
+ };
314
+ type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
315
+ fixable: true;
316
+ fix: AriaFix;
317
+ };
318
+ type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
319
+ fixable: false;
320
+ };
321
+ type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
322
+ type AriaResult = ValidResult | AriaInvalidResult;
323
+ type AriaPhase = 'evaluate' | 'fix';
324
+ //#endregion
325
+ //#region ../../lib/primitive/src/types/aria-rule/aria-rule.d.ts
326
+ type AriaRule<C extends AriaContext = AriaContext> = ((context: C) => readonly AriaResult[]) & {
327
+ readonly readsProps?: readonly string[];
328
+ readonly tags?: readonly string[];
329
+ };
330
+ //#endregion
331
+ //#region ../../lib/primitive/src/types/factory/prop-normalizer.d.ts
332
+ type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
333
+ //#endregion
334
+ //#region ../../lib/primitive/src/types/factory/enforcement-options.d.ts
335
+ type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
336
+ /**
337
+ * Accepts a preset name (`'warn'`, `'throw'`, `'silent'`) or a full `Diagnostics`
338
+ * instance for custom reporting/policy. The string form needs no import from
339
+ * `@praxis-kit/diagnostics`.
340
+ */
341
+ readonly diagnostics?: Diagnostics$1 | DiagnosticsMode;
342
+ /**
343
+ * ARIA/accessibility rules evaluated against the resolved tag and props on every render.
344
+ * Each rule is a function receiving the current context and returning zero or more
345
+ * violations, some of which can carry an auto-applicable fix (see `createRemoveAttributeRule`
346
+ * and friends in `praxis-kit/contract`).
347
+ */
348
+ readonly aria?: readonly AriaRule[];
349
+ /**
350
+ * Rules that need `AriaPolicyEngine`'s fix-application/caching machinery
351
+ * (`AriaRule`'s `readsProps`, fixable `AriaFix` results) but have no
352
+ * relationship to ARIA semantics — an HTML fact or a security check like a
353
+ * dangerous-URL-scheme guard, for example. Evaluated together with `aria`
354
+ * (both run through the same engine, merged into one rule set) — this is a
355
+ * separate bucket purely so a non-ARIA rule doesn't have to sit under the
356
+ * misleading `aria` name to get the machinery it needs.
357
+ */
358
+ readonly rules?: readonly AriaRule[];
359
+ /**
360
+ * Declares which children are valid, by name, match predicate, and cardinality (e.g. "at
361
+ * least 1, at most 4 `Button` children"). Open by default — children matching no rule are
362
+ * still allowed unless `exclusiveChildren` is set.
363
+ */
364
+ readonly children?: readonly ChildRuleInput[];
365
+ /**
366
+ * When true, only children matching a `children` rule (or text, per `allowText`)
367
+ * are valid — anything else is rejected. Default: false (open — children not
368
+ * matching any rule are allowed).
369
+ */
370
+ readonly exclusiveChildren?: boolean;
371
+ /**
372
+ * When false, text/number child nodes are rejected regardless of exclusiveChildren
373
+ * or any listed rule. Default: true.
374
+ */
375
+ readonly allowText?: boolean;
376
+ /**
377
+ * Prop transforms composed with the component's own `normalize` (from `FactoryOptions`) and
378
+ * run before it. Unlike `normalize`, these live in the enforcement bucket because they
379
+ * typically encode a built-in HTML/ARIA fact rather than component-specific behavior.
380
+ */
381
+ readonly props?: readonly PropNormalizer[];
382
+ /** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
383
+ readonly allowedAs?: readonly TAllowed[];
384
+ };
385
+ //#endregion
386
+ //#region ../../lib/primitive/src/types/factory/styling-options.d.ts
387
+ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory> = {
388
+ /** Class applied to every instance regardless of variant selection. */
389
+ readonly base?: ClassName;
390
+ /**
391
+ * Named variant groups (e.g. `intent`, `size`), each mapping its possible values to a
392
+ * class string. A consumer selects a value per group as a prop (`<Button intent="primary">`).
393
+ */
394
+ readonly variants?: V;
395
+ /** Value used for a variant group when the consumer doesn't pass one explicitly. */
396
+ readonly defaults?: Partial<DefaultVariants<V>>;
397
+ /**
398
+ * Applies an extra class only when a specific *combination* of variant selections matches —
399
+ * for cases `variants` alone can't express (e.g. `intent: 'primary'` + `size: 'lg'` together
400
+ * need a class neither variant would add on its own).
401
+ */
402
+ readonly compounds?: readonly CompoundVariant<V>[];
403
+ /**
404
+ * Named bundles of variant values a component defines up front. A caller activates one by name
405
+ * through the `recipe` prop (e.g. `<Button recipe="cta">` instead of setting `intent`/`size`
406
+ * individually) — `presets` is the store, `recipe` is the selector, which is why the field and
407
+ * the prop read differently. Explicit props always win over the activated bundle. The value type
408
+ * is `RecipeMap` (see `lib/primitive/src/types/variants/recipe-map.ts`).
409
+ */
410
+ readonly presets?: TPreset;
411
+ /** Maps a resolved tag directly to a raw class string, independent of the variant system. */
412
+ readonly tags?: Readonly<TagMap>;
413
+ /**
414
+ * A `ClassPluginFactory` (e.g. the Tailwind layout pipeline) that extends class resolution
415
+ * with its own owned props, layered on top of `variants`/`presets`/`tags`.
416
+ */
417
+ readonly plugin?: TPlugin;
418
+ /**
419
+ * A cache-key → resolved-class-string lookup for every statically-known variant
420
+ * combination, skipping runtime class computation entirely when a match is found. Normally
421
+ * generated by a build-time class-extraction plugin rather than hand-authored.
422
+ */
423
+ readonly precomputedClasses?: Readonly<StringMap<string>>;
424
+ };
425
+ //#endregion
426
+ //#region ../../lib/primitive/src/types/factory/factory-options.d.ts
427
+ type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
428
+ normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
429
+ }['normalize'];
430
+ /**
431
+ * The type-erased shape of {@link FactoryOptions} — every generic parameter widened to its bound.
432
+ *
433
+ * Use it for a value that must hold *any* factory config (a registry, a generic wrapper). It
434
+ * cannot check `styling.compounds` conditions against the real variant keys/values, because it
435
+ * has forgotten what they are — for that, annotate against `FactoryOptions<...>` with the concrete
436
+ * generics (or `satisfies FactoryOptions<'button', Props, typeof variants>`), which keeps an
437
+ * invalid compound condition a type error rather than a silent no-op.
438
+ */
439
+ type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, RecipeMap<VariantMap>, AnyClassPluginFactory>;
440
+ /**
441
+ * The framework-neutral component-authoring config passed to `createContractComponent` in every
442
+ * adapter: default tag + name, own-prop defaults, a `normalize` transform, `styling` (variants,
443
+ * base classes, presets, class plugin), `enforcement` (ARIA + children contracts), `subComponents`,
444
+ * and `onElement`.
445
+ *
446
+ * `satisfies FactoryOptions<TDefault, Props, typeof variants, ...>` on a config object narrows
447
+ * `styling.compounds` conditions to the real per-variant-key shape — including resolving a
448
+ * boolean-shaped axis (`{ true, false }`) to a real `boolean` — so a condition naming a variant or
449
+ * value that does not exist is a compile error. `AnyFactoryOptions` cannot do this.
450
+ */
451
+ 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> = {
452
+ /** The intrinsic tag the component renders by default. Overridable per instance via `as`. */
453
+ readonly tag?: TDefault;
454
+ /** Display name used in diagnostics, dev tools, and generated component naming. */
455
+ readonly name?: string;
456
+ /** Values used for the component's own (non-variant) props when the consumer omits them. */
457
+ readonly defaults?: Partial<NoInfer<Props>>;
458
+ /**
459
+ * A pure `(props) => props` transform run on every render, after `enforcement.props`'s
460
+ * normalizers see the same input. Use this for component-specific prop shaping — anything
461
+ * that depends on live instance state or the real DOM element belongs in `onElement` instead.
462
+ *
463
+ * Accepts either a single transform or an array of them, mirroring the `enforcement.props`
464
+ * array convention. An array is composed left to right — each entry receives the previous
465
+ * entry's *complete* output, not a merged patch — so unlike an `enforcement.props` normalizer
466
+ * (which returns a partial patch), a later `normalize` entry can also remove a key an earlier
467
+ * one added. An empty array is treated as no transform.
468
+ */
469
+ readonly normalize?: NormalizeFn<NoInfer<Props>> | ReadonlyArray<NormalizeFn<NoInfer<Props>>>;
470
+ /** Variant groups, base classes, presets, and the optional class-resolution plugin. */
471
+ readonly styling?: StylingOptions<V, TPreset, TPlugin>;
472
+ /** ARIA rules, child-content contracts, and other runtime validation for this component. */
473
+ readonly enforcement?: EnforcementOptions<TAllowed>;
474
+ /**
475
+ * Adapter-resolved diagnostics default, spread in by `resolveAdapterCommonOptions`. Not meant to
476
+ * be set directly by component authors — use `enforcement.diagnostics` to override per component.
477
+ */
478
+ readonly diagnostics?: Diagnostics$1;
479
+ /**
480
+ * Sub-components to attach to the generated root component, producing a
481
+ * compound component API (for example, `Card.Header`, `Card.Content`,
482
+ * and `Card.Footer`). Purely additive — has no effect on
483
+ * `enforcement.children`; author child rules explicitly if the component
484
+ * needs to validate its children.
485
+ */
486
+ readonly subComponents?: SubComponentMap;
487
+ /**
488
+ * Called once per instance, when the real underlying DOM element first
489
+ * exists, in every adapter — via that adapter's own native mount
490
+ * lifecycle, never through the props/attribute pipeline. Use this for
491
+ * wiring that needs the actual element (native imperative methods like
492
+ * `dialogEl.showModal()`, native events like `close`/`cancel` that have
493
+ * no prop-based equivalent), not for anything expressible as a plain
494
+ * prop.
495
+ *
496
+ * `element` is typed to the real DOM interface of every tag the rendered
497
+ * element could actually be — `TDefault` plus whatever `enforcement.allowed`
498
+ * permits via `as` (`HTMLDialogElement` for `tag: 'dialog'`,
499
+ * `HTMLDetailsElement` for `tag: 'details'`, and so on) — no cast needed to
500
+ * reach tag-specific members. A component that leaves `allowed`
501
+ * unconstrained (any tag reachable via `as`) falls back to `HTMLElement`,
502
+ * which still covers members every element shares (`showPopover()` and
503
+ * friends); restrict `enforcement.allowed` to the tags `onElement`
504
+ * actually knows how to handle to get real narrowing.
505
+ *
506
+ * `getProps` returns the instance's *current* resolved props at call
507
+ * time — read it from inside a listener registered once at mount, rather
508
+ * than re-subscribing on every prop change.
509
+ *
510
+ * Return a cleanup function to run when the instance unmounts.
511
+ */
512
+ readonly onElement?: (element: ElementForTag<TDefault | TAllowed>, getProps: () => Readonly<Props>) => void | (() => void);
513
+ };
514
+ //#endregion
515
+ //#region ../../lib/primitive/src/types/factory/resolved-factory-options.d.ts
516
+ /**
517
+ * The fully-resolved component definition — rendering, styling, variants, and
518
+ * enforcement (child rules, ARIA rules, `allowedAs`) settled into one object.
519
+ *
520
+ * ⚠️ Complexity boundary: this type is close to "the entire resolved component
521
+ * state". Adding a whole new concern (events, refs, lifecycle, slots, context,
522
+ * SSR/hydration) should **not** just append fields here — split it into a
523
+ * composition first: `ResolvedRenderingOptions & ResolvedStylingOptions &
524
+ * ResolvedEnforcementOptions & …`.
525
+ */
526
+ type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>> = {
527
+ readonly defaultTag: TDefault;
528
+ readonly baseClassName?: ClassName;
529
+ readonly defaultProps?: Partial<Props>;
530
+ readonly tagMap?: Readonly<TagMap>;
531
+ readonly recipeMap?: TPreset;
532
+ readonly variants?: V;
533
+ readonly defaultVariants?: Partial<DefaultVariants<V>>;
534
+ readonly compoundVariants?: readonly CompoundVariant<V>[];
535
+ readonly displayName?: string;
536
+ readonly diagnostics: Diagnostics$1;
537
+ readonly variantKeys: ReadonlySet<string>;
538
+ readonly normalizeFn?: NormalizeFn<Props>;
539
+ readonly htmlPropNormalizersFn?: (tag: unknown) => readonly PropNormalizer[] | undefined;
540
+ readonly htmlChildrenEvaluatorFn?: (tag: unknown) => ChildrenEvaluator | undefined;
541
+ readonly childRules?: readonly ChildRuleInput[];
542
+ readonly exclusiveChildren?: boolean;
543
+ readonly allowText?: boolean;
544
+ readonly ariaRules?: readonly AriaRule[];
545
+ readonly allowedAs?: readonly ElementType[];
546
+ readonly precomputedClasses?: Readonly<StringMap<string>>;
547
+ };
548
+ //#endregion
549
+ //#region ../../lib/contract/src/types/aria/invalid-result-input.d.ts
550
+ /** Shared input shape for `invalidWithFix`/`invalidWithoutFix`. */
551
+ type InvalidResultInput = {
552
+ readonly severity: Severity;
553
+ readonly attribute?: string;
554
+ readonly message?: string;
555
+ readonly diagnostic?: DiagnosticInput;
556
+ };
557
+ //#endregion
558
+ //#region ../../lib/contract/src/types/aria/remove-attribute-rule-options.d.ts
559
+ /** Options for `createRemoveAttributeRule`. */
560
+ type RemoveAttributeRuleOptions = {
561
+ /** Returns true when `attribute` should be stripped for the given render. */
562
+ readonly when: (context: AriaContext) => boolean;
563
+ readonly severity?: Severity;
564
+ readonly message?: string;
565
+ /** Receives the same context `when` did, so the diagnostic can reference the offending value. */
566
+ readonly diagnostic?: (context: AriaContext) => DiagnosticInput;
567
+ readonly readsProps?: readonly string[];
568
+ readonly tags?: readonly string[];
569
+ };
570
+ //#endregion
571
+ //#region ../../lib/contract/src/aria/factories.d.ts
572
+ /**
573
+ * Builds a correctly-literal-typed `fixable: false` `AriaResult`. Exists so a rule author can
574
+ * extract shared branch logic (severity/attribute/message computed once, reused across multiple
575
+ * `return`s) without TypeScript silently widening `valid: false`/`fixable: false` to `boolean`
576
+ * the moment those values leave an object-literal-in-return-position — the widening only happens
577
+ * on plain object literals; a function's declared return type narrows unconditionally.
578
+ */
579
+ export declare function invalidWithoutFix(input: InvalidResultInput): AriaInvalidWithoutFix;
580
+ /** Same as {@link invalidWithoutFix}, for the `fixable: true` branch — requires a `fix`. */
581
+ export declare function invalidWithFix(input: InvalidResultInput & {
582
+ readonly fix: AriaFix;
583
+ }): AriaInvalidWithFix;
584
+ /**
585
+ * Builds an `AriaFix` that strips a single attribute — the shape `dangerousHrefRule`-style
586
+ * "strip this attribute when it's dangerous/redundant" rules need. A no-op (`applied: false`) when
587
+ * the attribute isn't present, so applying the fix twice (or applying it when nothing triggered it)
588
+ * is always safe. Frozen — a fix is a value object; nothing should mutate `kind`/`attribute`/`apply`
589
+ * after construction.
590
+ */
591
+ export declare function removeAttributeFix(attribute: string): AriaFix;
592
+ /**
593
+ * Convenience factory for the single most common `enforcement.aria`/`enforcement.rules` shape:
594
+ * "strip this attribute when some condition on the element's own props holds" — covers
595
+ * security-style guards (a dangerous URL scheme on `href`) and redundant-attribute rules alike,
596
+ * without hand-writing the rule function, the `AriaFix`, and the `invalidWithFix` call each time.
597
+ * A rule with no fix (a warn-only advisory) still needs the raw `AriaRule` shape directly — this
598
+ * factory is deliberately scoped to the strip-on-match case, not a general rule builder.
599
+ */
600
+ export declare function createRemoveAttributeRule(attribute: string, options: RemoveAttributeRuleOptions): AriaRule;
601
+ //#endregion
602
+ //#region ../../lib/contract/src/props/make-state-normalizer.d.ts
603
+ interface StateNormalizerConfig {
604
+ /** The sugar prop this normalizer reads, e.g. `expanded` or `readOnly`. */
605
+ readonly state: string;
606
+ /** The `aria-*` attribute it derives, e.g. `aria-expanded`. */
607
+ readonly aria: `aria-${string}`;
608
+ /** The `data-*` attribute it derives, e.g. `data-expanded`. */
609
+ readonly data: `data-${string}`;
610
+ /**
611
+ * The false-state model for this prop (see DECISIONS.md → "prop-normalizer false-state model"):
612
+ *
613
+ * - **`omit`** (default) — a falsy state emits nothing. Correct where `aria-*="false"` equals
614
+ * the attribute's default (`aria-disabled`, `aria-invalid`, `aria-busy`, `aria-readonly`,
615
+ * `aria-current`), so deriving it would be redundant.
616
+ * - **`synthesize`** — `state={false}` produces `aria-*="false"`, because an absent attribute
617
+ * ("not expandable / not a toggle / not selectable") and `="false"` ("expandable, currently
618
+ * collapsed") are announced differently by assistive technology. Used for `expanded`,
619
+ * `pressed`, `selected`.
620
+ *
621
+ * The `data-*` attribute is present-when-true under either model — style a false state via
622
+ * `[aria-*="false"]`.
623
+ */
624
+ readonly falseState?: 'omit' | 'synthesize';
625
+ }
626
+ /**
627
+ * Builds one of the eight built-in state-prop normalizers. A truthy state injects the `aria-*` /
628
+ * `data-*` pair; the false state is handled per `falseState`; an explicitly supplied `aria-*` /
629
+ * `data-*` value is never overwritten (the normalizer only fills when the key is `undefined`).
630
+ */
631
+ export declare function makeStateNormalizer({ state, aria, data, falseState }: StateNormalizerConfig): PropNormalizer;
632
+ //#endregion
633
+ //#region ../../lib/contract/src/props/index.d.ts
634
+ export declare const activeProps: PropNormalizer;
635
+ export declare const disabledProps: PropNormalizer;
636
+ export declare const expandedProps: PropNormalizer;
637
+ export declare const invalidProps: PropNormalizer;
638
+ export declare const loadingProps: PropNormalizer;
639
+ export declare const pressedProps: PropNormalizer;
640
+ export declare const readonlyProps: PropNormalizer;
641
+ export declare const selectedProps: PropNormalizer;
642
+ //#endregion
643
+ //#region ../core/src/state/contracts.d.ts
644
+ export declare const activeContract: EnforcementOptions;
645
+ export declare const disabledContract: EnforcementOptions;
646
+ export declare const expandedContract: EnforcementOptions;
647
+ export declare const invalidContract: EnforcementOptions;
648
+ export declare const loadingContract: EnforcementOptions;
649
+ export declare const pressedContract: EnforcementOptions;
650
+ export declare const readonlyContract: EnforcementOptions;
651
+ export declare const selectedContract: EnforcementOptions;
652
+ //#endregion
653
+ //#region ../core/src/state/merge-contracts.d.ts
654
+ export declare function mergeContracts(...contracts: readonly EnforcementOptions[]): EnforcementOptions;
655
+ //#endregion
656
+ //#region ../core/src/diagnostics-api.d.ts
657
+ /**
658
+ * The structural write-surface of a `Diagnostics` instance — what a consumer authoring a custom
659
+ * `styling.plugin` (or any plugin the runtime hands a `Diagnostics` to) needs to call.
660
+ *
661
+ * Exported instead of the `@praxis-kit/diagnostics` **class** type on purpose: the class carries
662
+ * `private` members, so its type is nominal — a plugin annotated against a class re-export would
663
+ * only accept an instance produced by that exact bundled copy. A structural interface has no
664
+ * identity, so any object of this shape satisfies it regardless of which entry point produced it.
665
+ */
666
+ interface Diagnostics {
667
+ /** `false` ⇒ a `Warning` would be ignored by the policy — cheap gate to skip warning-level work. */
668
+ readonly warnActive: boolean;
669
+ debug(input: DiagnosticInput): Diagnostic;
670
+ info(input: DiagnosticInput): Diagnostic;
671
+ warn(input: DiagnosticInput): Diagnostic;
672
+ error(input: DiagnosticInput): Diagnostic;
673
+ fatal(input: DiagnosticInput): Diagnostic;
674
+ report(diagnostic: Diagnostic): Diagnostic;
675
+ }
676
+ //#endregion
677
+ export type { AnyFactoryOptions, AriaContext, AriaFix, AriaFixResult, AriaPhase, AriaResult, AriaRule, Diagnostics, EnforcementOptions, FactoryOptions, FixKind, IntrinsicProps, AriaInvalidResult as InvalidResult, AriaInvalidWithFix as InvalidWithFix, AriaInvalidWithoutFix as InvalidWithoutFix, NormalizeFn, PropNormalizer, RemoveAttributeFixKind, ResolvedFactoryOptions, Severity, StateNormalizerConfig, StylingOptions, ValidResult };