praxis-kit 4.0.1 → 4.0.3

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.
@@ -1,5 +1,6 @@
1
1
  import { ComponentType, PropsWithChildren, ReactElement, JSX, Ref, ReactNode } from 'react';
2
- import { Except, RequireAtLeastOne, Simplify, ReadonlyDeep, NonEmptyTuple } from 'type-fest';
2
+ import { RequireAtLeastOne, Simplify, ReadonlyDeep, NonEmptyTuple } from 'type-fest';
3
+ import { Diagnostics, DiagnosticInput } from './_shared/diagnostics.js';
3
4
 
4
5
  type StringMap<T = unknown> = Record<string, T>;
5
6
  type AnyRecord = StringMap<unknown>;
@@ -23,159 +24,6 @@ type IntrinsicProps = AnyRecord & {
23
24
  };
24
25
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
25
26
 
26
- declare enum DiagnosticCategory {
27
- Contract = 0,
28
- HTML = 1,
29
- ARIA = 2,
30
- Composition = 3,
31
- Rendering = 4,
32
- Accessibility = 5,
33
- Performance = 6,
34
- Internal = 7,
35
- Deprecation = 8,
36
- Lint = 9
37
- }
38
-
39
- declare enum DiagnosticCode {
40
- MissingRequiredChild = "COMP1001",
41
- InvalidParent = "COMP1002",
42
- InvalidChild = "COMP1003",
43
- UnexpectedChild = "COMP1004",
44
- AmbiguousChild = "COMP1005",
45
- CardinalityMin = "COMP1006",
46
- CardinalityMax = "COMP1007",
47
- PositionViolation = "COMP1008",
48
- AllowedAsViolation = "COMP1009",
49
- SlotExclusive = "SLOT1001",
50
- SlotSingleChild = "SLOT1002",
51
- SlotDiscardedChildren = "SLOT1003",
52
- SlotRenderFn = "SLOT1004",
53
- MissingAriaRelationship = "ARIA2001",
54
- AriaViolation = "ARIA2002",
55
- AriaAttributeInvalid = "ARIA2003",
56
- AriaMissingLiveRegion = "ARIA2004",
57
- AriaMissingAtomic = "ARIA2005",
58
- AriaRelevantInvalidToken = "ARIA2006",
59
- AriaRelevantSuperseded = "ARIA2007",
60
- AriaInvalidRole = "ARIA2008",
61
- AriaMissingAccessibleName = "ARIA2009",
62
- AriaAttributeOnPresentational = "ARIA2010",
63
- AriaHiddenOnFocusable = "ARIA2011",
64
- AriaRequiredProperty = "ARIA2012",
65
- AriaInvalidAttributeValue = "ARIA2013",
66
- AriaRedundantLevelAttribute = "ARIA2014",
67
- InvalidHeadingHierarchy = "HTML3001",
68
- HtmlEmptyRole = "HTML3002",
69
- HtmlImplicitRoleRedundant = "HTML3003",
70
- HtmlImplicitRoleOverride = "HTML3004",
71
- HtmlStandaloneRegionOverride = "HTML3005",
72
- HtmlLandmarkRoleOverride = "HTML3006",
73
- HtmlInvalidChild = "HTML3007",
74
- InvalidRenderingTarget = "RENDER4001",
75
- LintDeadCompoundKey = "LINT5001",
76
- LintDeadCompoundValue = "LINT5002",
77
- LintDeadCompoundNonLiteral = "LINT5003",
78
- LintMissingStrict = "LINT5004",
79
- LintInvalidDefaultKey = "LINT5005",
80
- LintInvalidDefaultValue = "LINT5006",
81
- LintInvalidDefaultNonLiteral = "LINT5007",
82
- LintNegativeMin = "LINT5008",
83
- LintNegativeMax = "LINT5009",
84
- LintMaxLessThanMin = "LINT5010",
85
- LintZeroMax = "LINT5011",
86
- LintMultipleFirst = "LINT5012",
87
- LintMultipleLast = "LINT5013",
88
- LintMinSumExceedsCapacity = "LINT5014",
89
- LintCardinalityViolation = "LINT5015",
90
- LintAriaTagOverride = "LINT5016",
91
- ContractUnknownVariantDim = "COMP1010",
92
- ContractUnknownVariantValue = "COMP1011",
93
- ContractUnknownRecipeKey = "COMP1012",
94
- ContractInvalidVariantValue = "COMP1013",
95
- TailwindMultipleDisplayProps = "CSS6001",
96
- TailwindReservedLayoutLiteral = "CSS6002",
97
- TailwindDeadVariantClass = "CSS6003",
98
- PluginInvalidShape = "PLUGIN7001",
99
- PluginPipelineReturnType = "PLUGIN7002",
100
- InternalError = "INTERNAL9000"
101
- }
102
-
103
- type MetadataMap = AnyRecord;
104
- type NodeId = string;
105
-
106
- interface Diagnostic$1 {
107
- code: string;
108
- message: string;
109
- severity: 'error' | 'warning' | 'info';
110
- }
111
-
112
- type CapabilityMap = StringMap<boolean>;
113
-
114
- interface SourcePosition {
115
- line: number;
116
- col: number;
117
- }
118
- interface SourceLocation {
119
- file: string;
120
- start: SourcePosition;
121
- end?: SourcePosition;
122
- }
123
-
124
- declare enum Severity$1 {
125
- Debug = 0,
126
- Info = 1,
127
- Warning = 2,
128
- Error = 3,
129
- Fatal = 4
130
- }
131
-
132
- interface DiagnosticSuggestion {
133
- title: string;
134
- description?: string;
135
- fix?: string;
136
- }
137
-
138
- type Context = AnyRecord;
139
- type Metadata = AnyRecord;
140
- interface Diagnostic {
141
- code: DiagnosticCode;
142
- severity: Severity$1;
143
- category: DiagnosticCategory;
144
- message: string;
145
- rationale?: string;
146
- component?: string;
147
- contract?: string;
148
- location?: SourceLocation;
149
- suggestions?: DiagnosticSuggestion[];
150
- context?: Context;
151
- metadata?: Metadata;
152
- }
153
-
154
- declare enum Enforcement {
155
- Ignore = 0,
156
- Report = 1,
157
- Throw = 2
158
- }
159
- interface DiagnosticPolicy {
160
- resolve(diagnostic: Diagnostic): Enforcement;
161
- }
162
-
163
- interface DiagnosticReporter {
164
- report(diagnostic: Diagnostic): void;
165
- }
166
-
167
- type DiagnosticInput = Except<Diagnostic, 'severity'>;
168
- declare class Diagnostics {
169
- private readonly reporter;
170
- private readonly policy;
171
- readonly active: boolean;
172
- constructor(reporter: DiagnosticReporter, policy?: DiagnosticPolicy);
173
- report(diagnostic: Diagnostic): Diagnostic;
174
- warn(input: DiagnosticInput): Diagnostic;
175
- error(input: DiagnosticInput): Diagnostic;
176
- info(input: DiagnosticInput): Diagnostic;
177
- }
178
-
179
27
  type MinMax = {
180
28
  min: number;
181
29
  max: number;
@@ -384,6 +232,17 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
384
232
  readonly enforcement?: EnforcementOptions<TAllowed>;
385
233
  };
386
234
 
235
+ type MetadataMap = AnyRecord;
236
+ type NodeId = string;
237
+
238
+ interface Diagnostic {
239
+ code: string;
240
+ message: string;
241
+ severity: 'error' | 'warning' | 'info';
242
+ }
243
+
244
+ type CapabilityMap = StringMap<boolean>;
245
+
387
246
  declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
388
247
 
389
248
  interface ComponentIdentity {
@@ -396,7 +255,7 @@ interface ComponentDefinition {
396
255
  identity: ComponentIdentity;
397
256
  capabilities: CapabilityMap;
398
257
  metadata: MetadataMap;
399
- diagnostics: Diagnostic$1[];
258
+ diagnostics: Diagnostic[];
400
259
  }
401
260
 
402
261
  type UnknownProps = Record<string, unknown>;
@@ -1,4 +1,5 @@
1
- import { Except, RequireAtLeastOne, Simplify, ReadonlyDeep, OmitIndexSignature } from 'type-fest';
1
+ import { RequireAtLeastOne, Simplify, ReadonlyDeep, OmitIndexSignature } from 'type-fest';
2
+ import { Diagnostics, DiagnosticInput } from '../_shared/diagnostics.js';
2
3
  import { ComponentChildren, VNode, ComponentType, JSX, Ref } from 'preact';
3
4
 
4
5
  type StringMap<T = unknown> = Record<string, T>;
@@ -23,148 +24,6 @@ type IntrinsicProps = AnyRecord & {
23
24
  };
24
25
  type TagMap = Partial<Record<IntrinsicTag | (string & {}), ClassName>>;
25
26
 
26
- declare enum DiagnosticCategory {
27
- Contract = 0,
28
- HTML = 1,
29
- ARIA = 2,
30
- Composition = 3,
31
- Rendering = 4,
32
- Accessibility = 5,
33
- Performance = 6,
34
- Internal = 7,
35
- Deprecation = 8,
36
- Lint = 9
37
- }
38
-
39
- declare enum DiagnosticCode {
40
- MissingRequiredChild = "COMP1001",
41
- InvalidParent = "COMP1002",
42
- InvalidChild = "COMP1003",
43
- UnexpectedChild = "COMP1004",
44
- AmbiguousChild = "COMP1005",
45
- CardinalityMin = "COMP1006",
46
- CardinalityMax = "COMP1007",
47
- PositionViolation = "COMP1008",
48
- AllowedAsViolation = "COMP1009",
49
- SlotExclusive = "SLOT1001",
50
- SlotSingleChild = "SLOT1002",
51
- SlotDiscardedChildren = "SLOT1003",
52
- SlotRenderFn = "SLOT1004",
53
- MissingAriaRelationship = "ARIA2001",
54
- AriaViolation = "ARIA2002",
55
- AriaAttributeInvalid = "ARIA2003",
56
- AriaMissingLiveRegion = "ARIA2004",
57
- AriaMissingAtomic = "ARIA2005",
58
- AriaRelevantInvalidToken = "ARIA2006",
59
- AriaRelevantSuperseded = "ARIA2007",
60
- AriaInvalidRole = "ARIA2008",
61
- AriaMissingAccessibleName = "ARIA2009",
62
- AriaAttributeOnPresentational = "ARIA2010",
63
- AriaHiddenOnFocusable = "ARIA2011",
64
- AriaRequiredProperty = "ARIA2012",
65
- AriaInvalidAttributeValue = "ARIA2013",
66
- AriaRedundantLevelAttribute = "ARIA2014",
67
- InvalidHeadingHierarchy = "HTML3001",
68
- HtmlEmptyRole = "HTML3002",
69
- HtmlImplicitRoleRedundant = "HTML3003",
70
- HtmlImplicitRoleOverride = "HTML3004",
71
- HtmlStandaloneRegionOverride = "HTML3005",
72
- HtmlLandmarkRoleOverride = "HTML3006",
73
- HtmlInvalidChild = "HTML3007",
74
- InvalidRenderingTarget = "RENDER4001",
75
- LintDeadCompoundKey = "LINT5001",
76
- LintDeadCompoundValue = "LINT5002",
77
- LintDeadCompoundNonLiteral = "LINT5003",
78
- LintMissingStrict = "LINT5004",
79
- LintInvalidDefaultKey = "LINT5005",
80
- LintInvalidDefaultValue = "LINT5006",
81
- LintInvalidDefaultNonLiteral = "LINT5007",
82
- LintNegativeMin = "LINT5008",
83
- LintNegativeMax = "LINT5009",
84
- LintMaxLessThanMin = "LINT5010",
85
- LintZeroMax = "LINT5011",
86
- LintMultipleFirst = "LINT5012",
87
- LintMultipleLast = "LINT5013",
88
- LintMinSumExceedsCapacity = "LINT5014",
89
- LintCardinalityViolation = "LINT5015",
90
- LintAriaTagOverride = "LINT5016",
91
- ContractUnknownVariantDim = "COMP1010",
92
- ContractUnknownVariantValue = "COMP1011",
93
- ContractUnknownRecipeKey = "COMP1012",
94
- ContractInvalidVariantValue = "COMP1013",
95
- TailwindMultipleDisplayProps = "CSS6001",
96
- TailwindReservedLayoutLiteral = "CSS6002",
97
- TailwindDeadVariantClass = "CSS6003",
98
- PluginInvalidShape = "PLUGIN7001",
99
- PluginPipelineReturnType = "PLUGIN7002",
100
- InternalError = "INTERNAL9000"
101
- }
102
-
103
- interface SourcePosition {
104
- line: number;
105
- col: number;
106
- }
107
- interface SourceLocation {
108
- file: string;
109
- start: SourcePosition;
110
- end?: SourcePosition;
111
- }
112
-
113
- declare enum Severity$1 {
114
- Debug = 0,
115
- Info = 1,
116
- Warning = 2,
117
- Error = 3,
118
- Fatal = 4
119
- }
120
-
121
- interface DiagnosticSuggestion {
122
- title: string;
123
- description?: string;
124
- fix?: string;
125
- }
126
-
127
- type Context = AnyRecord;
128
- type Metadata = AnyRecord;
129
- interface Diagnostic {
130
- code: DiagnosticCode;
131
- severity: Severity$1;
132
- category: DiagnosticCategory;
133
- message: string;
134
- rationale?: string;
135
- component?: string;
136
- contract?: string;
137
- location?: SourceLocation;
138
- suggestions?: DiagnosticSuggestion[];
139
- context?: Context;
140
- metadata?: Metadata;
141
- }
142
-
143
- declare enum Enforcement {
144
- Ignore = 0,
145
- Report = 1,
146
- Throw = 2
147
- }
148
- interface DiagnosticPolicy {
149
- resolve(diagnostic: Diagnostic): Enforcement;
150
- }
151
-
152
- interface DiagnosticReporter {
153
- report(diagnostic: Diagnostic): void;
154
- }
155
-
156
- type DiagnosticInput = Except<Diagnostic, 'severity'>;
157
- declare class Diagnostics {
158
- private readonly reporter;
159
- private readonly policy;
160
- readonly active: boolean;
161
- constructor(reporter: DiagnosticReporter, policy?: DiagnosticPolicy);
162
- report(diagnostic: Diagnostic): Diagnostic;
163
- warn(input: DiagnosticInput): Diagnostic;
164
- error(input: DiagnosticInput): Diagnostic;
165
- info(input: DiagnosticInput): Diagnostic;
166
- }
167
-
168
27
  type MinMax = {
169
28
  min: number;
170
29
  max: number;