praxis-kit 1.1.0 → 2.0.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.
- package/README.md +196 -0
- package/dist/{chunk-KDUNVQK2.js → chunk-ACAKUHH5.js} +531 -386
- package/dist/contract/index.d.ts +130 -0
- package/dist/contract/index.js +1370 -0
- package/dist/lit/index.d.ts +2 -1
- package/dist/lit/index.js +257 -184
- package/dist/{merge-refs-CfBqh1UO.d.ts → merge-refs-DxjWMq3U.d.ts} +2 -5
- package/dist/preact/index.d.ts +2 -5
- package/dist/preact/index.js +236 -187
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +1 -5
- package/dist/react/legacy.d.ts +3 -3
- package/dist/react/legacy.js +1 -5
- package/dist/solid/index.d.ts +2 -5
- package/dist/solid/index.js +238 -189
- package/dist/svelte/index.d.ts +3 -5
- package/dist/svelte/index.js +233 -186
- package/dist/vue/index.d.ts +2 -5
- package/dist/vue/index.js +236 -187
- package/dist/web/index.d.ts +2 -1
- package/dist/web/index.js +259 -185
- package/package.json +6 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { ReadonlyDeep } from 'type-fest';
|
|
2
|
+
|
|
3
|
+
type AnyRecord = Record<string, unknown>;
|
|
4
|
+
|
|
5
|
+
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
6
|
+
|
|
7
|
+
type ElementType = IntrinsicTag | (string & {});
|
|
8
|
+
|
|
9
|
+
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"];
|
|
10
|
+
type KnownAriaRole = (typeof KNOWN_ARIA_ROLES)[number];
|
|
11
|
+
|
|
12
|
+
type AriaRole = KnownAriaRole | (string & {});
|
|
13
|
+
|
|
14
|
+
type IntrinsicProps = AnyRecord & {
|
|
15
|
+
role?: AriaRole;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type StrictMode = boolean | 'warn' | 'async-warn' | 'throw';
|
|
19
|
+
|
|
20
|
+
type CardinalityInput = {
|
|
21
|
+
min?: number;
|
|
22
|
+
max?: number;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
type ChildRuleMatch<T, U extends T = T> = (child: T) => child is U;
|
|
26
|
+
|
|
27
|
+
type ChildRulePosition = 'first' | 'last' | 'any';
|
|
28
|
+
|
|
29
|
+
type ChildRuleInput<T = unknown, U extends T = T> = {
|
|
30
|
+
name: string;
|
|
31
|
+
match: ChildRuleMatch<T, U>;
|
|
32
|
+
cardinality?: CardinalityInput;
|
|
33
|
+
position?: ChildRulePosition;
|
|
34
|
+
/**
|
|
35
|
+
* Optional component-type reference for O(1) dispatch index.
|
|
36
|
+
* When provided for every rule, the matcher reads child.type instead of
|
|
37
|
+
* calling every match function on every child (O(n×m) → O(n+m)).
|
|
38
|
+
*/
|
|
39
|
+
type?: unknown;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
type ValidResult = {
|
|
43
|
+
valid: true;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
type AriaContext = {
|
|
47
|
+
readonly tag: IntrinsicTag;
|
|
48
|
+
readonly implicitRole: AriaRole | undefined;
|
|
49
|
+
readonly effectiveRole: string | undefined;
|
|
50
|
+
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type RemoveAttributeFixKind = `removeAttribute:${string}`;
|
|
54
|
+
type InjectLiveFixKind = `injectLive:${string}`;
|
|
55
|
+
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
56
|
+
|
|
57
|
+
type AriaFixResult = {
|
|
58
|
+
applied: false;
|
|
59
|
+
next: ReadonlyDeep<IntrinsicProps>;
|
|
60
|
+
} | {
|
|
61
|
+
applied: true;
|
|
62
|
+
next: ReadonlyDeep<IntrinsicProps>;
|
|
63
|
+
previous: ReadonlyDeep<IntrinsicProps>;
|
|
64
|
+
};
|
|
65
|
+
type AriaFix = {
|
|
66
|
+
readonly kind: FixKind;
|
|
67
|
+
readonly priority?: number;
|
|
68
|
+
readonly source?: string;
|
|
69
|
+
readonly apply: (context: AriaContext) => AriaFixResult;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type Severity = 'error' | 'warning' | (string & {});
|
|
73
|
+
|
|
74
|
+
type AriaInvalidBase<M extends string = string> = {
|
|
75
|
+
valid: false;
|
|
76
|
+
severity: Severity;
|
|
77
|
+
message: M;
|
|
78
|
+
attribute?: string;
|
|
79
|
+
};
|
|
80
|
+
type AriaInvalidWithFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
81
|
+
fixable: true;
|
|
82
|
+
fix: AriaFix;
|
|
83
|
+
};
|
|
84
|
+
type AriaInvalidWithoutFix<M extends string = string> = AriaInvalidBase<M> & {
|
|
85
|
+
fixable: false;
|
|
86
|
+
};
|
|
87
|
+
type AriaInvalidResult<M extends string = string> = AriaInvalidWithFix<M> | AriaInvalidWithoutFix<M>;
|
|
88
|
+
type AriaResult = ValidResult | AriaInvalidResult;
|
|
89
|
+
|
|
90
|
+
type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly AriaResult[];
|
|
91
|
+
|
|
92
|
+
type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
|
|
93
|
+
|
|
94
|
+
type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
95
|
+
readonly strict?: StrictMode;
|
|
96
|
+
readonly aria?: readonly AriaRule[];
|
|
97
|
+
readonly children?: readonly ChildRuleInput[];
|
|
98
|
+
readonly props?: readonly PropNormalizer[];
|
|
99
|
+
/** Restricts the `as` prop to this set of tags. Violations route through strict mode. */
|
|
100
|
+
readonly allowedAs?: readonly TAllowed[];
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
declare const activeProps: PropNormalizer;
|
|
104
|
+
|
|
105
|
+
declare const disabledProps: PropNormalizer;
|
|
106
|
+
|
|
107
|
+
declare const expandedProps: PropNormalizer;
|
|
108
|
+
|
|
109
|
+
declare const invalidProps: PropNormalizer;
|
|
110
|
+
|
|
111
|
+
declare const loadingProps: PropNormalizer;
|
|
112
|
+
|
|
113
|
+
declare const pressedProps: PropNormalizer;
|
|
114
|
+
|
|
115
|
+
declare const readonlyProps: PropNormalizer;
|
|
116
|
+
|
|
117
|
+
declare const selectedProps: PropNormalizer;
|
|
118
|
+
|
|
119
|
+
declare const activeContract: EnforcementOptions;
|
|
120
|
+
declare const disabledContract: EnforcementOptions;
|
|
121
|
+
declare const expandedContract: EnforcementOptions;
|
|
122
|
+
declare const invalidContract: EnforcementOptions;
|
|
123
|
+
declare const loadingContract: EnforcementOptions;
|
|
124
|
+
declare const pressedContract: EnforcementOptions;
|
|
125
|
+
declare const readonlyContract: EnforcementOptions;
|
|
126
|
+
declare const selectedContract: EnforcementOptions;
|
|
127
|
+
|
|
128
|
+
declare function mergeContracts(...contracts: readonly EnforcementOptions[]): EnforcementOptions;
|
|
129
|
+
|
|
130
|
+
export { type PropNormalizer, activeContract, activeProps, disabledContract, disabledProps, expandedContract, expandedProps, invalidContract, invalidProps, loadingContract, loadingProps, mergeContracts, pressedContract, pressedProps, readonlyContract, readonlyProps, selectedContract, selectedProps };
|