praxis-kit 4.0.0 → 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.
- package/dist/_shared/diagnostics.d.ts +212 -0
- package/dist/_shared/diagnostics.js +289 -0
- package/dist/{chunk-TJRHF6MS.js → chunk-DRGZ4ZI2.js} +79 -208
- package/dist/codemod/index.js +23 -15
- package/dist/contract/index.d.ts +246 -2
- package/dist/eslint/index.js +21 -17
- package/dist/lit/index.d.ts +221 -5
- package/dist/lit/index.js +74 -203
- package/dist/merge-refs-B0YcfdtP.d.ts +399 -0
- package/dist/preact/index.d.ts +234 -5
- package/dist/preact/index.js +79 -208
- package/dist/react/index.d.ts +4 -7
- package/dist/react/index.js +1 -1
- package/dist/react/legacy.d.ts +4 -7
- package/dist/react/legacy.js +1 -1
- package/dist/solid/index.d.ts +234 -5
- package/dist/solid/index.js +83 -212
- package/dist/svelte/index.d.ts +311 -5
- package/dist/svelte/index.js +83 -212
- package/dist/tailwind/index.d.ts +88 -4
- package/dist/tailwind/index.js +11 -119
- package/dist/vite-plugin/index.d.ts +138 -2
- package/dist/vue/index.d.ts +234 -5
- package/dist/vue/index.js +79 -208
- package/dist/web/index.d.ts +221 -6
- package/dist/web/index.js +74 -203
- package/package.json +3 -3
- package/dist/merge-refs-DUuHyTRO.d.ts +0 -144
package/dist/preact/index.js
CHANGED
|
@@ -566,159 +566,21 @@ var InvariantBase = class {
|
|
|
566
566
|
}
|
|
567
567
|
};
|
|
568
568
|
|
|
569
|
-
// ../../lib/diagnostics/src/category.ts
|
|
570
|
-
var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
|
|
571
|
-
DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
|
|
572
|
-
DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
|
|
573
|
-
DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
|
|
574
|
-
DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
|
|
575
|
-
DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
|
|
576
|
-
DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
|
|
577
|
-
DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
|
|
578
|
-
DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
|
|
579
|
-
DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
|
|
580
|
-
DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
|
|
581
|
-
return DiagnosticCategory2;
|
|
582
|
-
})(DiagnosticCategory || {});
|
|
583
|
-
|
|
584
|
-
// ../../lib/diagnostics/src/error.ts
|
|
585
|
-
var PraxisError = class extends Error {
|
|
586
|
-
diagnostic;
|
|
587
|
-
constructor(diagnostic) {
|
|
588
|
-
super(diagnostic.message);
|
|
589
|
-
this.name = "PraxisError";
|
|
590
|
-
this.diagnostic = diagnostic;
|
|
591
|
-
}
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
// ../../lib/diagnostics/src/severity.ts
|
|
595
|
-
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
596
|
-
Severity2[Severity2["Debug"] = 0] = "Debug";
|
|
597
|
-
Severity2[Severity2["Info"] = 1] = "Info";
|
|
598
|
-
Severity2[Severity2["Warning"] = 2] = "Warning";
|
|
599
|
-
Severity2[Severity2["Error"] = 3] = "Error";
|
|
600
|
-
Severity2[Severity2["Fatal"] = 4] = "Fatal";
|
|
601
|
-
return Severity2;
|
|
602
|
-
})(Severity || {});
|
|
603
|
-
|
|
604
|
-
// ../../lib/diagnostics/src/policy.ts
|
|
605
|
-
var DefaultPolicy = class {
|
|
606
|
-
reportThreshold;
|
|
607
|
-
throwThreshold;
|
|
608
|
-
constructor({
|
|
609
|
-
reportThreshold = 1 /* Info */,
|
|
610
|
-
throwThreshold = 4 /* Fatal */
|
|
611
|
-
} = {}) {
|
|
612
|
-
this.reportThreshold = reportThreshold;
|
|
613
|
-
this.throwThreshold = throwThreshold;
|
|
614
|
-
}
|
|
615
|
-
resolve(diagnostic) {
|
|
616
|
-
if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
|
|
617
|
-
if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
|
|
618
|
-
return 0 /* Ignore */;
|
|
619
|
-
}
|
|
620
|
-
};
|
|
621
|
-
|
|
622
|
-
// ../../lib/diagnostics/src/diagnostics.ts
|
|
623
|
-
var Diagnostics = class {
|
|
624
|
-
reporter;
|
|
625
|
-
policy;
|
|
626
|
-
// Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
|
|
627
|
-
active;
|
|
628
|
-
constructor(reporter, policy = new DefaultPolicy()) {
|
|
629
|
-
this.reporter = reporter;
|
|
630
|
-
this.policy = policy;
|
|
631
|
-
this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
|
|
632
|
-
}
|
|
633
|
-
report(diagnostic) {
|
|
634
|
-
const enforcement = this.policy.resolve(diagnostic);
|
|
635
|
-
if (enforcement === 0 /* Ignore */) return diagnostic;
|
|
636
|
-
if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
|
|
637
|
-
this.reporter.report(diagnostic);
|
|
638
|
-
return diagnostic;
|
|
639
|
-
}
|
|
640
|
-
warn(input) {
|
|
641
|
-
return this.report({ ...input, severity: 2 /* Warning */ });
|
|
642
|
-
}
|
|
643
|
-
error(input) {
|
|
644
|
-
return this.report({ ...input, severity: 3 /* Error */ });
|
|
645
|
-
}
|
|
646
|
-
info(input) {
|
|
647
|
-
return this.report({ ...input, severity: 1 /* Info */ });
|
|
648
|
-
}
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
// ../../lib/diagnostics/src/formatter.ts
|
|
652
|
-
function formatDiagnostic(diagnostic) {
|
|
653
|
-
const level = Severity[diagnostic.severity];
|
|
654
|
-
const category = DiagnosticCategory[diagnostic.category];
|
|
655
|
-
const prefix = category !== void 0 ? `[${category}] ` : "";
|
|
656
|
-
return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
// ../../lib/diagnostics/src/console-reporter.ts
|
|
660
|
-
var ConsoleReporter = class {
|
|
661
|
-
report(diagnostic) {
|
|
662
|
-
const message = formatDiagnostic(diagnostic);
|
|
663
|
-
switch (diagnostic.severity) {
|
|
664
|
-
case 0 /* Debug */:
|
|
665
|
-
console.debug(message);
|
|
666
|
-
break;
|
|
667
|
-
case 1 /* Info */:
|
|
668
|
-
console.info(message);
|
|
669
|
-
break;
|
|
670
|
-
case 2 /* Warning */:
|
|
671
|
-
console.warn(message);
|
|
672
|
-
break;
|
|
673
|
-
case 3 /* Error */:
|
|
674
|
-
case 4 /* Fatal */:
|
|
675
|
-
console.error(message);
|
|
676
|
-
break;
|
|
677
|
-
}
|
|
678
|
-
}
|
|
679
|
-
};
|
|
680
|
-
|
|
681
|
-
// ../../lib/diagnostics/src/null-reporter.ts
|
|
682
|
-
var nullReporter = {
|
|
683
|
-
report() {
|
|
684
|
-
}
|
|
685
|
-
};
|
|
686
|
-
|
|
687
|
-
// ../../lib/diagnostics/src/presets.ts
|
|
688
|
-
var ignoreAllPolicy = {
|
|
689
|
-
resolve(_) {
|
|
690
|
-
return 0 /* Ignore */;
|
|
691
|
-
}
|
|
692
|
-
};
|
|
693
|
-
var warnOnlyReporter = {
|
|
694
|
-
report(diagnostic) {
|
|
695
|
-
console.warn(formatDiagnostic(diagnostic));
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
var silentDiagnostics = new Diagnostics(nullReporter, ignoreAllPolicy);
|
|
699
|
-
var warnDiagnostics = new Diagnostics(
|
|
700
|
-
warnOnlyReporter,
|
|
701
|
-
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
|
|
702
|
-
);
|
|
703
|
-
var throwDiagnostics = new Diagnostics(
|
|
704
|
-
new ConsoleReporter(),
|
|
705
|
-
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 3 /* Error */ })
|
|
706
|
-
);
|
|
707
|
-
|
|
708
569
|
// ../../lib/contract/src/diagnostics/aria.ts
|
|
570
|
+
import { DiagnosticCategory, DiagnosticCode } from "../_shared/diagnostics.js";
|
|
709
571
|
var AriaDiagnostics = {
|
|
710
572
|
/** Generic bridge for violations produced by external AriaRule functions. */
|
|
711
573
|
fromViolation(v) {
|
|
712
574
|
return {
|
|
713
|
-
code:
|
|
714
|
-
category:
|
|
575
|
+
code: DiagnosticCode.AriaViolation,
|
|
576
|
+
category: DiagnosticCategory.ARIA,
|
|
715
577
|
message: v.message
|
|
716
578
|
};
|
|
717
579
|
},
|
|
718
580
|
attributeInvalid(key, role) {
|
|
719
581
|
return {
|
|
720
|
-
code:
|
|
721
|
-
category:
|
|
582
|
+
code: DiagnosticCode.AriaAttributeInvalid,
|
|
583
|
+
category: DiagnosticCategory.ARIA,
|
|
722
584
|
message: `"${key}" is not valid on role="${role}". It will be removed.`,
|
|
723
585
|
rationale: "Invalid ARIA attributes are ignored by assistive technology and may trigger accessibility-tree warnings in browser devtools.",
|
|
724
586
|
suggestions: [
|
|
@@ -731,8 +593,8 @@ var AriaDiagnostics = {
|
|
|
731
593
|
},
|
|
732
594
|
missingLiveRegion(role, impliedLive) {
|
|
733
595
|
return {
|
|
734
|
-
code:
|
|
735
|
-
category:
|
|
596
|
+
code: DiagnosticCode.AriaMissingLiveRegion,
|
|
597
|
+
category: DiagnosticCategory.ARIA,
|
|
736
598
|
message: `role="${role}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`,
|
|
737
599
|
rationale: "Live-region roles announce dynamic content changes to screen readers. Without aria-live the politeness level is unspecified and announcements may be silent.",
|
|
738
600
|
suggestions: [
|
|
@@ -746,8 +608,8 @@ var AriaDiagnostics = {
|
|
|
746
608
|
},
|
|
747
609
|
missingAtomic(role) {
|
|
748
610
|
return {
|
|
749
|
-
code:
|
|
750
|
-
category:
|
|
611
|
+
code: DiagnosticCode.AriaMissingAtomic,
|
|
612
|
+
category: DiagnosticCategory.ARIA,
|
|
751
613
|
message: `role="${role}" is a live region. Consider setting aria-atomic="true" if the full region should be announced as a unit, or aria-atomic="false" if only changed nodes should be read.`,
|
|
752
614
|
rationale: "aria-atomic controls whether assistive technology announces the entire live region or only the changed nodes. Omitting it leaves the behaviour browser-defined."
|
|
753
615
|
};
|
|
@@ -755,8 +617,8 @@ var AriaDiagnostics = {
|
|
|
755
617
|
relevantInvalidTokens(invalid) {
|
|
756
618
|
const quoted = invalid.map((t) => `"${t}"`).join(", ");
|
|
757
619
|
return {
|
|
758
|
-
code:
|
|
759
|
-
category:
|
|
620
|
+
code: DiagnosticCode.AriaRelevantInvalidToken,
|
|
621
|
+
category: DiagnosticCategory.ARIA,
|
|
760
622
|
message: `aria-relevant contains invalid token(s): ${quoted}. Valid tokens are: additions, removals, text, all.`,
|
|
761
623
|
rationale: "aria-relevant accepts a space-separated list of change types. Unrecognised tokens are silently ignored by assistive technology, making the attribute ineffective.",
|
|
762
624
|
suggestions: [
|
|
@@ -769,8 +631,8 @@ var AriaDiagnostics = {
|
|
|
769
631
|
},
|
|
770
632
|
relevantSuperseded() {
|
|
771
633
|
return {
|
|
772
|
-
code:
|
|
773
|
-
category:
|
|
634
|
+
code: DiagnosticCode.AriaRelevantSuperseded,
|
|
635
|
+
category: DiagnosticCategory.ARIA,
|
|
774
636
|
message: 'aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.',
|
|
775
637
|
rationale: '"all" is equivalent to "additions removals text". Combining it with other tokens is redundant and may confuse readers of the markup.',
|
|
776
638
|
suggestions: [
|
|
@@ -783,8 +645,8 @@ var AriaDiagnostics = {
|
|
|
783
645
|
},
|
|
784
646
|
missingAccessibleName(tag) {
|
|
785
647
|
return {
|
|
786
|
-
code:
|
|
787
|
-
category:
|
|
648
|
+
code: DiagnosticCode.AriaMissingAccessibleName,
|
|
649
|
+
category: DiagnosticCategory.ARIA,
|
|
788
650
|
message: `<${tag}> has no accessible name. Add aria-label or aria-labelledby.`,
|
|
789
651
|
rationale: "Elements with a landmark or interactive role must have an accessible name so that assistive technology can identify them when presenting the page outline.",
|
|
790
652
|
suggestions: [
|
|
@@ -801,8 +663,8 @@ var AriaDiagnostics = {
|
|
|
801
663
|
},
|
|
802
664
|
attributeOnPresentational(attr, tag) {
|
|
803
665
|
return {
|
|
804
|
-
code:
|
|
805
|
-
category:
|
|
666
|
+
code: DiagnosticCode.AriaAttributeOnPresentational,
|
|
667
|
+
category: DiagnosticCategory.ARIA,
|
|
806
668
|
message: `"${attr}" is not allowed on a presentational <${tag}>. Presentational elements are invisible to assistive technology.`,
|
|
807
669
|
rationale: 'role="none" and role="presentation" (including <img alt="">) remove an element from the accessibility tree. ARIA attributes on such elements are ignored by assistive technology.',
|
|
808
670
|
suggestions: [
|
|
@@ -815,8 +677,8 @@ var AriaDiagnostics = {
|
|
|
815
677
|
},
|
|
816
678
|
ariaHiddenOnFocusable(tag) {
|
|
817
679
|
return {
|
|
818
|
-
code:
|
|
819
|
-
category:
|
|
680
|
+
code: DiagnosticCode.AriaHiddenOnFocusable,
|
|
681
|
+
category: DiagnosticCategory.ARIA,
|
|
820
682
|
message: `aria-hidden="true" must not be used on focusable <${tag}> elements. Screen reader users who navigate by keyboard will encounter the element but receive no information about it.`,
|
|
821
683
|
rationale: 'aria-hidden removes an element from the accessibility tree while leaving it keyboard-reachable. This creates a "ghost" \u2014 a focusable element assistive technology cannot describe.',
|
|
822
684
|
suggestions: [
|
|
@@ -834,8 +696,8 @@ var AriaDiagnostics = {
|
|
|
834
696
|
invalidAttributeValue(attr, value, expected) {
|
|
835
697
|
const got = value === null ? "null" : value === void 0 ? "undefined" : typeof value === "string" ? `"${value}"` : String(value);
|
|
836
698
|
return {
|
|
837
|
-
code:
|
|
838
|
-
category:
|
|
699
|
+
code: DiagnosticCode.AriaInvalidAttributeValue,
|
|
700
|
+
category: DiagnosticCategory.ARIA,
|
|
839
701
|
message: `"${attr}" has an invalid value (${got}). Expected: ${expected}.`,
|
|
840
702
|
rationale: "ARIA attributes with invalid values are silently ignored by assistive technology, making the markup semantically inert.",
|
|
841
703
|
suggestions: [
|
|
@@ -848,8 +710,8 @@ var AriaDiagnostics = {
|
|
|
848
710
|
},
|
|
849
711
|
redundantAriaLevel(tag, level) {
|
|
850
712
|
return {
|
|
851
|
-
code:
|
|
852
|
-
category:
|
|
713
|
+
code: DiagnosticCode.AriaRedundantLevelAttribute,
|
|
714
|
+
category: DiagnosticCategory.ARIA,
|
|
853
715
|
message: `aria-level="${level}" is redundant on <${tag}>: the element already has an implicit heading level of ${level}. Remove the attribute.`,
|
|
854
716
|
rationale: 'Restating the implicit aria-level adds noise without semantic value. Use aria-level only to override the native heading level (e.g. aria-level="3" on <h2>).',
|
|
855
717
|
suggestions: [
|
|
@@ -862,8 +724,8 @@ var AriaDiagnostics = {
|
|
|
862
724
|
},
|
|
863
725
|
requiredProperty(attr, role) {
|
|
864
726
|
return {
|
|
865
|
-
code:
|
|
866
|
-
category:
|
|
727
|
+
code: DiagnosticCode.AriaRequiredProperty,
|
|
728
|
+
category: DiagnosticCategory.ARIA,
|
|
867
729
|
message: `"${attr}" is required for role="${role}" but is missing.`,
|
|
868
730
|
rationale: `WAI-ARIA 1.2 specifies required states and properties for certain roles. Without "${attr}", assistive technology cannot correctly communicate the element's state to users.`,
|
|
869
731
|
suggestions: [
|
|
@@ -876,8 +738,8 @@ var AriaDiagnostics = {
|
|
|
876
738
|
},
|
|
877
739
|
invalidRole(role, tag) {
|
|
878
740
|
return {
|
|
879
|
-
code:
|
|
880
|
-
category:
|
|
741
|
+
code: DiagnosticCode.AriaInvalidRole,
|
|
742
|
+
category: DiagnosticCategory.ARIA,
|
|
881
743
|
message: `Invalid role "${role ?? ""}" on <${tag}>.`,
|
|
882
744
|
rationale: "An unrecognised or misapplied ARIA role is ignored by assistive technology and may degrade the accessibility of the element."
|
|
883
745
|
};
|
|
@@ -885,11 +747,12 @@ var AriaDiagnostics = {
|
|
|
885
747
|
};
|
|
886
748
|
|
|
887
749
|
// ../../lib/contract/src/diagnostics/contract.ts
|
|
750
|
+
import { DiagnosticCategory as DiagnosticCategory2, DiagnosticCode as DiagnosticCode2 } from "../_shared/diagnostics.js";
|
|
888
751
|
var ContractDiagnostics = {
|
|
889
752
|
unexpectedChild(typeName, index, context) {
|
|
890
753
|
return {
|
|
891
|
-
code:
|
|
892
|
-
category:
|
|
754
|
+
code: DiagnosticCode2.UnexpectedChild,
|
|
755
|
+
category: DiagnosticCategory2.Contract,
|
|
893
756
|
component: context,
|
|
894
757
|
message: `${context}: unexpected child "${typeName}" at index ${index}.`
|
|
895
758
|
};
|
|
@@ -897,69 +760,69 @@ var ContractDiagnostics = {
|
|
|
897
760
|
ambiguousChild(typeName, index, ruleNames, context) {
|
|
898
761
|
const quoted = ruleNames.map((n) => `"${n}"`).join(" and ");
|
|
899
762
|
return {
|
|
900
|
-
code:
|
|
901
|
-
category:
|
|
763
|
+
code: DiagnosticCode2.AmbiguousChild,
|
|
764
|
+
category: DiagnosticCategory2.Contract,
|
|
902
765
|
component: context,
|
|
903
766
|
message: `${context}: child "${typeName}" at index ${index} matches multiple child rules: ${quoted}.`
|
|
904
767
|
};
|
|
905
768
|
},
|
|
906
769
|
cardinalityMin(ruleName, min, context) {
|
|
907
770
|
return {
|
|
908
|
-
code:
|
|
909
|
-
category:
|
|
771
|
+
code: DiagnosticCode2.CardinalityMin,
|
|
772
|
+
category: DiagnosticCategory2.Contract,
|
|
910
773
|
component: context,
|
|
911
774
|
message: `${context}: "${ruleName}" requires at least ${min}.`
|
|
912
775
|
};
|
|
913
776
|
},
|
|
914
777
|
cardinalityMax(ruleName, max, context) {
|
|
915
778
|
return {
|
|
916
|
-
code:
|
|
917
|
-
category:
|
|
779
|
+
code: DiagnosticCode2.CardinalityMax,
|
|
780
|
+
category: DiagnosticCategory2.Contract,
|
|
918
781
|
component: context,
|
|
919
782
|
message: `${context}: "${ruleName}" allows at most ${max}.`
|
|
920
783
|
};
|
|
921
784
|
},
|
|
922
785
|
positionViolation(ruleName, position, index, context) {
|
|
923
786
|
return {
|
|
924
|
-
code:
|
|
925
|
-
category:
|
|
787
|
+
code: DiagnosticCode2.PositionViolation,
|
|
788
|
+
category: DiagnosticCategory2.Contract,
|
|
926
789
|
component: context,
|
|
927
790
|
message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
|
|
928
791
|
};
|
|
929
792
|
},
|
|
930
793
|
unknownVariantDim(component, label, dim) {
|
|
931
794
|
return {
|
|
932
|
-
code:
|
|
933
|
-
category:
|
|
795
|
+
code: DiagnosticCode2.ContractUnknownVariantDim,
|
|
796
|
+
category: DiagnosticCategory2.Contract,
|
|
934
797
|
message: `${component}: ${label} references unknown variant "${dim}".`
|
|
935
798
|
};
|
|
936
799
|
},
|
|
937
800
|
unknownVariantValue(component, label, dim, value, valid) {
|
|
938
801
|
return {
|
|
939
|
-
code:
|
|
940
|
-
category:
|
|
802
|
+
code: DiagnosticCode2.ContractUnknownVariantValue,
|
|
803
|
+
category: DiagnosticCategory2.Contract,
|
|
941
804
|
message: `${component}: ${label} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
|
|
942
805
|
};
|
|
943
806
|
},
|
|
944
807
|
unknownRecipeKey(component, key) {
|
|
945
808
|
return {
|
|
946
|
-
code:
|
|
947
|
-
category:
|
|
809
|
+
code: DiagnosticCode2.ContractUnknownRecipeKey,
|
|
810
|
+
category: DiagnosticCategory2.Contract,
|
|
948
811
|
message: `${component} Unknown recipeKey "${key}" \u2014 no preset with that name exists.`
|
|
949
812
|
};
|
|
950
813
|
},
|
|
951
814
|
invalidVariantValue(component, key, value) {
|
|
952
815
|
return {
|
|
953
|
-
code:
|
|
954
|
-
category:
|
|
816
|
+
code: DiagnosticCode2.ContractInvalidVariantValue,
|
|
817
|
+
category: DiagnosticCategory2.Contract,
|
|
955
818
|
message: `${component} Variant "${key}=${value}" is not a defined value for the "${key}" dimension.`
|
|
956
819
|
};
|
|
957
820
|
},
|
|
958
821
|
allowedAsViolation(tag, allowedAs, component) {
|
|
959
822
|
const allowed = allowedAs.map((t) => `"${String(t)}"`).join(", ");
|
|
960
823
|
return {
|
|
961
|
-
code:
|
|
962
|
-
category:
|
|
824
|
+
code: DiagnosticCode2.AllowedAsViolation,
|
|
825
|
+
category: DiagnosticCategory2.Contract,
|
|
963
826
|
component,
|
|
964
827
|
message: `<${component}>: "as" prop received "${tag}" but only [${allowed}] are allowed.`
|
|
965
828
|
};
|
|
@@ -967,73 +830,75 @@ var ContractDiagnostics = {
|
|
|
967
830
|
};
|
|
968
831
|
|
|
969
832
|
// ../../lib/contract/src/diagnostics/html.ts
|
|
833
|
+
import { DiagnosticCategory as DiagnosticCategory3, DiagnosticCode as DiagnosticCode3 } from "../_shared/diagnostics.js";
|
|
970
834
|
var HtmlDiagnostics = {
|
|
971
835
|
emptyRole(tag) {
|
|
972
836
|
return {
|
|
973
|
-
code:
|
|
974
|
-
category:
|
|
837
|
+
code: DiagnosticCode3.HtmlEmptyRole,
|
|
838
|
+
category: DiagnosticCategory3.HTML,
|
|
975
839
|
message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`
|
|
976
840
|
};
|
|
977
841
|
},
|
|
978
842
|
implicitRoleRedundant(tag, implicitRole) {
|
|
979
843
|
return {
|
|
980
|
-
code:
|
|
981
|
-
category:
|
|
844
|
+
code: DiagnosticCode3.HtmlImplicitRoleRedundant,
|
|
845
|
+
category: DiagnosticCategory3.HTML,
|
|
982
846
|
message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
|
|
983
847
|
};
|
|
984
848
|
},
|
|
985
849
|
implicitRoleOverride(tag, implicitRole, role) {
|
|
986
850
|
return {
|
|
987
|
-
code:
|
|
988
|
-
category:
|
|
851
|
+
code: DiagnosticCode3.HtmlImplicitRoleOverride,
|
|
852
|
+
category: DiagnosticCategory3.HTML,
|
|
989
853
|
message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
|
|
990
854
|
};
|
|
991
855
|
},
|
|
992
856
|
standaloneRegionOverride(tag, implicitRole) {
|
|
993
857
|
return {
|
|
994
|
-
code:
|
|
995
|
-
category:
|
|
858
|
+
code: DiagnosticCode3.HtmlStandaloneRegionOverride,
|
|
859
|
+
category: DiagnosticCategory3.HTML,
|
|
996
860
|
message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
|
|
997
861
|
};
|
|
998
862
|
},
|
|
999
863
|
landmarkRoleOverride(tag, implicitRole, role) {
|
|
1000
864
|
return {
|
|
1001
|
-
code:
|
|
1002
|
-
category:
|
|
865
|
+
code: DiagnosticCode3.HtmlLandmarkRoleOverride,
|
|
866
|
+
category: DiagnosticCategory3.HTML,
|
|
1003
867
|
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
1004
868
|
};
|
|
1005
869
|
},
|
|
1006
870
|
invalidChild(child, parent, allowed) {
|
|
1007
871
|
return {
|
|
1008
|
-
code:
|
|
1009
|
-
category:
|
|
872
|
+
code: DiagnosticCode3.HtmlInvalidChild,
|
|
873
|
+
category: DiagnosticCategory3.HTML,
|
|
1010
874
|
message: `<${child}> is not a valid direct child of <${parent}>. Allowed: ${allowed}.`
|
|
1011
875
|
};
|
|
1012
876
|
}
|
|
1013
877
|
};
|
|
1014
878
|
|
|
1015
879
|
// ../../lib/contract/src/diagnostics/slot.ts
|
|
880
|
+
import { DiagnosticCategory as DiagnosticCategory4, DiagnosticCode as DiagnosticCode4 } from "../_shared/diagnostics.js";
|
|
1016
881
|
var SlotDiagnostics = {
|
|
1017
882
|
exclusive(name) {
|
|
1018
883
|
return {
|
|
1019
|
-
code:
|
|
1020
|
-
category:
|
|
884
|
+
code: DiagnosticCode4.SlotExclusive,
|
|
885
|
+
category: DiagnosticCategory4.Contract,
|
|
1021
886
|
component: name,
|
|
1022
887
|
message: `${name}: "as" and "asChild" are mutually exclusive`
|
|
1023
888
|
};
|
|
1024
889
|
},
|
|
1025
890
|
singleChildRequired(name, elementTerm) {
|
|
1026
891
|
return {
|
|
1027
|
-
code:
|
|
1028
|
-
category:
|
|
892
|
+
code: DiagnosticCode4.SlotSingleChild,
|
|
893
|
+
category: DiagnosticCategory4.Contract,
|
|
1029
894
|
component: name,
|
|
1030
895
|
message: `${name}: asChild requires a ${elementTerm} child`
|
|
1031
896
|
};
|
|
1032
897
|
},
|
|
1033
898
|
singleChildExceeded(name, elementTerm, count) {
|
|
1034
899
|
return {
|
|
1035
|
-
code:
|
|
1036
|
-
category:
|
|
900
|
+
code: DiagnosticCode4.SlotSingleChild,
|
|
901
|
+
category: DiagnosticCategory4.Contract,
|
|
1037
902
|
component: name,
|
|
1038
903
|
message: `${name}: asChild requires exactly one ${elementTerm} child, got ${count}`
|
|
1039
904
|
};
|
|
@@ -1041,16 +906,16 @@ var SlotDiagnostics = {
|
|
|
1041
906
|
discardedChildren(name, elementTerm, count) {
|
|
1042
907
|
const suffix = count === 1 ? "" : "ren";
|
|
1043
908
|
return {
|
|
1044
|
-
code:
|
|
1045
|
-
category:
|
|
909
|
+
code: DiagnosticCode4.SlotDiscardedChildren,
|
|
910
|
+
category: DiagnosticCategory4.Contract,
|
|
1046
911
|
component: name,
|
|
1047
912
|
message: `${name}: asChild discarded ${count} non-element child${suffix} \u2014 only ${elementTerm}s are valid asChild children.`
|
|
1048
913
|
};
|
|
1049
914
|
},
|
|
1050
915
|
renderFnRequired(name, received) {
|
|
1051
916
|
return {
|
|
1052
|
-
code:
|
|
1053
|
-
category:
|
|
917
|
+
code: DiagnosticCode4.SlotRenderFn,
|
|
918
|
+
category: DiagnosticCategory4.Contract,
|
|
1054
919
|
component: name,
|
|
1055
920
|
message: `${name}: asChild requires a render function as children, got ${received}`
|
|
1056
921
|
};
|
|
@@ -1985,6 +1850,9 @@ var readonlyProps = ({
|
|
|
1985
1850
|
};
|
|
1986
1851
|
};
|
|
1987
1852
|
|
|
1853
|
+
// ../core/src/html/evaluators.ts
|
|
1854
|
+
import { warnDiagnostics as warnDiagnostics2 } from "../_shared/diagnostics.js";
|
|
1855
|
+
|
|
1988
1856
|
// ../core/src/html/aria-rules.ts
|
|
1989
1857
|
var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
|
|
1990
1858
|
var removeLandmarkRoleOverride = {
|
|
@@ -2027,6 +1895,7 @@ function landmarkNameAdvisory(ctx) {
|
|
|
2027
1895
|
}
|
|
2028
1896
|
|
|
2029
1897
|
// ../core/src/html/contracts.ts
|
|
1898
|
+
import { warnDiagnostics } from "../_shared/diagnostics.js";
|
|
2030
1899
|
function isOpenContent(...blockedTags) {
|
|
2031
1900
|
const set2 = new Set(blockedTags);
|
|
2032
1901
|
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
|
|
@@ -2171,7 +2040,7 @@ var htmlContracts = {
|
|
|
2171
2040
|
};
|
|
2172
2041
|
|
|
2173
2042
|
// ../core/src/html/evaluators.ts
|
|
2174
|
-
var htmlDiagnostics =
|
|
2043
|
+
var htmlDiagnostics = warnDiagnostics2;
|
|
2175
2044
|
function buildEvaluatorMap() {
|
|
2176
2045
|
const map2 = /* @__PURE__ */ new Map();
|
|
2177
2046
|
iterate.forEachEntry(htmlContracts, (tag, { children }) => {
|
|
@@ -2230,6 +2099,7 @@ function createVariantPass(activeProps, config) {
|
|
|
2230
2099
|
}
|
|
2231
2100
|
|
|
2232
2101
|
// ../core/src/resolver/resolver.ts
|
|
2102
|
+
import { silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2233
2103
|
function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
2234
2104
|
if (allowedAs.includes(tag)) return;
|
|
2235
2105
|
if (!diagnostics) return;
|
|
@@ -2255,6 +2125,7 @@ function buildEngines(diagnostics, childRules, context) {
|
|
|
2255
2125
|
}
|
|
2256
2126
|
|
|
2257
2127
|
// ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
|
|
2128
|
+
import { throwDiagnostics, silentDiagnostics as silentDiagnostics2 } from "../_shared/diagnostics.js";
|
|
2258
2129
|
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics) {
|
|
2259
2130
|
return {
|
|
2260
2131
|
name: options.name ?? defaultName,
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { AnyFactoryOptions, ElementType, EmptyRecord, FactoryOptions, PolymorphicGenerics } from '@praxis-kit/core';
|
|
4
|
-
import { U as UnknownProps, R as ReactFactoryOptions, P as PolymorphicComponent } from '../merge-refs-DUuHyTRO.js';
|
|
5
|
-
export { E as ElementRef, a as PolymorphicProps, b as PolymorphicWithAsChild, c as PolymorphicWithRender, d as RenderCallbackProps, S as Slottable, e as SlottableProps, m as composeRefs, m as mergeRefs } from '../merge-refs-DUuHyTRO.js';
|
|
1
|
+
import { E as ElementType, U as UnknownProps, a as EmptyRecord, V as VariantMap, R as RecipeMap, C as ClassPluginFactory, A as AnyRecord, b as ReactFactoryOptions, P as PolymorphicComponent, c as PolymorphicGenerics, d as ExtractPluginProps } from '../merge-refs-B0YcfdtP.js';
|
|
2
|
+
export { e as AnyFactoryOptions, f as ElementRef, F as FactoryOptions, g as PolymorphicProps, h as PolymorphicWithAsChild, i as PolymorphicWithRender, j as RenderCallbackProps, S as Slottable, k as SlottableProps, m as composeRefs, l as defineContractComponent, m as mergeRefs } from '../merge-refs-B0YcfdtP.js';
|
|
6
3
|
import { Ref, ReactElement } from 'react';
|
|
7
|
-
import '@praxis-kit/runtime';
|
|
8
4
|
import 'type-fest';
|
|
5
|
+
import '../_shared/diagnostics.js';
|
|
9
6
|
|
|
10
7
|
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset, TAllowed>>;
|
|
11
8
|
|
|
@@ -34,4 +31,4 @@ declare function cloneSlotChild({ child, slotProps, ref }: CloneInput): ReactEle
|
|
|
34
31
|
|
|
35
32
|
declare function getChildRef(element: ReactElement): Ref<unknown> | null;
|
|
36
33
|
|
|
37
|
-
export { PolymorphicComponent, ReactFactoryOptions, Slot, cloneSlotChild, createContractComponent, getChildRef };
|
|
34
|
+
export { ElementType, EmptyRecord, PolymorphicComponent, PolymorphicGenerics, ReactFactoryOptions, Slot, cloneSlotChild, createContractComponent, getChildRef };
|
package/dist/react/index.js
CHANGED
package/dist/react/legacy.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export { AnyFactoryOptions, ElementType, EmptyRecord, FactoryOptions, PolymorphicGenerics } from '@praxis-kit/core';
|
|
4
|
-
import { U as UnknownProps, R as ReactFactoryOptions, P as PolymorphicComponent } from '../merge-refs-DUuHyTRO.js';
|
|
5
|
-
export { E as ElementRef, a as PolymorphicProps, b as PolymorphicWithAsChild, c as PolymorphicWithRender, d as RenderCallbackProps, S as Slottable, e as SlottableProps, m as mergeRefs } from '../merge-refs-DUuHyTRO.js';
|
|
1
|
+
import { E as ElementType, U as UnknownProps, a as EmptyRecord, V as VariantMap, R as RecipeMap, C as ClassPluginFactory, A as AnyRecord, b as ReactFactoryOptions, P as PolymorphicComponent, c as PolymorphicGenerics, d as ExtractPluginProps } from '../merge-refs-B0YcfdtP.js';
|
|
2
|
+
export { e as AnyFactoryOptions, f as ElementRef, F as FactoryOptions, g as PolymorphicProps, h as PolymorphicWithAsChild, i as PolymorphicWithRender, j as RenderCallbackProps, S as Slottable, k as SlottableProps, l as defineContractComponent, m as mergeRefs } from '../merge-refs-B0YcfdtP.js';
|
|
6
3
|
import * as react from 'react';
|
|
7
|
-
import '@praxis-kit/runtime';
|
|
8
4
|
import 'type-fest';
|
|
5
|
+
import '../_shared/diagnostics.js';
|
|
9
6
|
|
|
10
7
|
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends ClassPluginFactory<AnyRecord> | undefined = ClassPluginFactory<AnyRecord> | undefined, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset, TAllowed>>;
|
|
11
8
|
|
|
@@ -14,4 +11,4 @@ type SlotProps = {
|
|
|
14
11
|
};
|
|
15
12
|
declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<unknown>>;
|
|
16
13
|
|
|
17
|
-
export { PolymorphicComponent, ReactFactoryOptions, Slot, createContractComponent };
|
|
14
|
+
export { ElementType, EmptyRecord, PolymorphicComponent, PolymorphicGenerics, ReactFactoryOptions, Slot, createContractComponent };
|
package/dist/react/legacy.js
CHANGED