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
|
@@ -578,159 +578,21 @@ var InvariantBase = class {
|
|
|
578
578
|
}
|
|
579
579
|
};
|
|
580
580
|
|
|
581
|
-
// ../../lib/diagnostics/src/category.ts
|
|
582
|
-
var DiagnosticCategory = /* @__PURE__ */ ((DiagnosticCategory2) => {
|
|
583
|
-
DiagnosticCategory2[DiagnosticCategory2["Contract"] = 0] = "Contract";
|
|
584
|
-
DiagnosticCategory2[DiagnosticCategory2["HTML"] = 1] = "HTML";
|
|
585
|
-
DiagnosticCategory2[DiagnosticCategory2["ARIA"] = 2] = "ARIA";
|
|
586
|
-
DiagnosticCategory2[DiagnosticCategory2["Composition"] = 3] = "Composition";
|
|
587
|
-
DiagnosticCategory2[DiagnosticCategory2["Rendering"] = 4] = "Rendering";
|
|
588
|
-
DiagnosticCategory2[DiagnosticCategory2["Accessibility"] = 5] = "Accessibility";
|
|
589
|
-
DiagnosticCategory2[DiagnosticCategory2["Performance"] = 6] = "Performance";
|
|
590
|
-
DiagnosticCategory2[DiagnosticCategory2["Internal"] = 7] = "Internal";
|
|
591
|
-
DiagnosticCategory2[DiagnosticCategory2["Deprecation"] = 8] = "Deprecation";
|
|
592
|
-
DiagnosticCategory2[DiagnosticCategory2["Lint"] = 9] = "Lint";
|
|
593
|
-
return DiagnosticCategory2;
|
|
594
|
-
})(DiagnosticCategory || {});
|
|
595
|
-
|
|
596
|
-
// ../../lib/diagnostics/src/error.ts
|
|
597
|
-
var PraxisError = class extends Error {
|
|
598
|
-
diagnostic;
|
|
599
|
-
constructor(diagnostic) {
|
|
600
|
-
super(diagnostic.message);
|
|
601
|
-
this.name = "PraxisError";
|
|
602
|
-
this.diagnostic = diagnostic;
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
|
|
606
|
-
// ../../lib/diagnostics/src/severity.ts
|
|
607
|
-
var Severity = /* @__PURE__ */ ((Severity2) => {
|
|
608
|
-
Severity2[Severity2["Debug"] = 0] = "Debug";
|
|
609
|
-
Severity2[Severity2["Info"] = 1] = "Info";
|
|
610
|
-
Severity2[Severity2["Warning"] = 2] = "Warning";
|
|
611
|
-
Severity2[Severity2["Error"] = 3] = "Error";
|
|
612
|
-
Severity2[Severity2["Fatal"] = 4] = "Fatal";
|
|
613
|
-
return Severity2;
|
|
614
|
-
})(Severity || {});
|
|
615
|
-
|
|
616
|
-
// ../../lib/diagnostics/src/policy.ts
|
|
617
|
-
var DefaultPolicy = class {
|
|
618
|
-
reportThreshold;
|
|
619
|
-
throwThreshold;
|
|
620
|
-
constructor({
|
|
621
|
-
reportThreshold = 1 /* Info */,
|
|
622
|
-
throwThreshold = 4 /* Fatal */
|
|
623
|
-
} = {}) {
|
|
624
|
-
this.reportThreshold = reportThreshold;
|
|
625
|
-
this.throwThreshold = throwThreshold;
|
|
626
|
-
}
|
|
627
|
-
resolve(diagnostic) {
|
|
628
|
-
if (diagnostic.severity >= this.throwThreshold) return 2 /* Throw */;
|
|
629
|
-
if (diagnostic.severity >= this.reportThreshold) return 1 /* Report */;
|
|
630
|
-
return 0 /* Ignore */;
|
|
631
|
-
}
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
// ../../lib/diagnostics/src/diagnostics.ts
|
|
635
|
-
var Diagnostics = class {
|
|
636
|
-
reporter;
|
|
637
|
-
policy;
|
|
638
|
-
// Pre-computed at construction time: true if Warning-level diagnostics are not ignored.
|
|
639
|
-
active;
|
|
640
|
-
constructor(reporter, policy = new DefaultPolicy()) {
|
|
641
|
-
this.reporter = reporter;
|
|
642
|
-
this.policy = policy;
|
|
643
|
-
this.active = policy.resolve({ severity: 2 /* Warning */ }) !== 0 /* Ignore */;
|
|
644
|
-
}
|
|
645
|
-
report(diagnostic) {
|
|
646
|
-
const enforcement = this.policy.resolve(diagnostic);
|
|
647
|
-
if (enforcement === 0 /* Ignore */) return diagnostic;
|
|
648
|
-
if (enforcement === 2 /* Throw */) throw new PraxisError(diagnostic);
|
|
649
|
-
this.reporter.report(diagnostic);
|
|
650
|
-
return diagnostic;
|
|
651
|
-
}
|
|
652
|
-
warn(input) {
|
|
653
|
-
return this.report({ ...input, severity: 2 /* Warning */ });
|
|
654
|
-
}
|
|
655
|
-
error(input) {
|
|
656
|
-
return this.report({ ...input, severity: 3 /* Error */ });
|
|
657
|
-
}
|
|
658
|
-
info(input) {
|
|
659
|
-
return this.report({ ...input, severity: 1 /* Info */ });
|
|
660
|
-
}
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
// ../../lib/diagnostics/src/formatter.ts
|
|
664
|
-
function formatDiagnostic(diagnostic) {
|
|
665
|
-
const level = Severity[diagnostic.severity];
|
|
666
|
-
const category = DiagnosticCategory[diagnostic.category];
|
|
667
|
-
const prefix = category !== void 0 ? `[${category}] ` : "";
|
|
668
|
-
return `${level} ${diagnostic.code}: ${prefix}${diagnostic.message}`;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
// ../../lib/diagnostics/src/console-reporter.ts
|
|
672
|
-
var ConsoleReporter = class {
|
|
673
|
-
report(diagnostic) {
|
|
674
|
-
const message = formatDiagnostic(diagnostic);
|
|
675
|
-
switch (diagnostic.severity) {
|
|
676
|
-
case 0 /* Debug */:
|
|
677
|
-
console.debug(message);
|
|
678
|
-
break;
|
|
679
|
-
case 1 /* Info */:
|
|
680
|
-
console.info(message);
|
|
681
|
-
break;
|
|
682
|
-
case 2 /* Warning */:
|
|
683
|
-
console.warn(message);
|
|
684
|
-
break;
|
|
685
|
-
case 3 /* Error */:
|
|
686
|
-
case 4 /* Fatal */:
|
|
687
|
-
console.error(message);
|
|
688
|
-
break;
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
};
|
|
692
|
-
|
|
693
|
-
// ../../lib/diagnostics/src/null-reporter.ts
|
|
694
|
-
var nullReporter = {
|
|
695
|
-
report() {
|
|
696
|
-
}
|
|
697
|
-
};
|
|
698
|
-
|
|
699
|
-
// ../../lib/diagnostics/src/presets.ts
|
|
700
|
-
var ignoreAllPolicy = {
|
|
701
|
-
resolve(_) {
|
|
702
|
-
return 0 /* Ignore */;
|
|
703
|
-
}
|
|
704
|
-
};
|
|
705
|
-
var warnOnlyReporter = {
|
|
706
|
-
report(diagnostic) {
|
|
707
|
-
console.warn(formatDiagnostic(diagnostic));
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
var silentDiagnostics = new Diagnostics(nullReporter, ignoreAllPolicy);
|
|
711
|
-
var warnDiagnostics = new Diagnostics(
|
|
712
|
-
warnOnlyReporter,
|
|
713
|
-
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 4 /* Fatal */ })
|
|
714
|
-
);
|
|
715
|
-
var throwDiagnostics = new Diagnostics(
|
|
716
|
-
new ConsoleReporter(),
|
|
717
|
-
new DefaultPolicy({ reportThreshold: 2 /* Warning */, throwThreshold: 3 /* Error */ })
|
|
718
|
-
);
|
|
719
|
-
|
|
720
581
|
// ../../lib/contract/src/diagnostics/aria.ts
|
|
582
|
+
import { DiagnosticCategory, DiagnosticCode } from "./_shared/diagnostics.js";
|
|
721
583
|
var AriaDiagnostics = {
|
|
722
584
|
/** Generic bridge for violations produced by external AriaRule functions. */
|
|
723
585
|
fromViolation(v) {
|
|
724
586
|
return {
|
|
725
|
-
code:
|
|
726
|
-
category:
|
|
587
|
+
code: DiagnosticCode.AriaViolation,
|
|
588
|
+
category: DiagnosticCategory.ARIA,
|
|
727
589
|
message: v.message
|
|
728
590
|
};
|
|
729
591
|
},
|
|
730
592
|
attributeInvalid(key, role) {
|
|
731
593
|
return {
|
|
732
|
-
code:
|
|
733
|
-
category:
|
|
594
|
+
code: DiagnosticCode.AriaAttributeInvalid,
|
|
595
|
+
category: DiagnosticCategory.ARIA,
|
|
734
596
|
message: `"${key}" is not valid on role="${role}". It will be removed.`,
|
|
735
597
|
rationale: "Invalid ARIA attributes are ignored by assistive technology and may trigger accessibility-tree warnings in browser devtools.",
|
|
736
598
|
suggestions: [
|
|
@@ -743,8 +605,8 @@ var AriaDiagnostics = {
|
|
|
743
605
|
},
|
|
744
606
|
missingLiveRegion(role, impliedLive) {
|
|
745
607
|
return {
|
|
746
|
-
code:
|
|
747
|
-
category:
|
|
608
|
+
code: DiagnosticCode.AriaMissingLiveRegion,
|
|
609
|
+
category: DiagnosticCategory.ARIA,
|
|
748
610
|
message: `role="${role}" implies aria-live="${impliedLive}" but it is missing. It has been injected.`,
|
|
749
611
|
rationale: "Live-region roles announce dynamic content changes to screen readers. Without aria-live the politeness level is unspecified and announcements may be silent.",
|
|
750
612
|
suggestions: [
|
|
@@ -758,8 +620,8 @@ var AriaDiagnostics = {
|
|
|
758
620
|
},
|
|
759
621
|
missingAtomic(role) {
|
|
760
622
|
return {
|
|
761
|
-
code:
|
|
762
|
-
category:
|
|
623
|
+
code: DiagnosticCode.AriaMissingAtomic,
|
|
624
|
+
category: DiagnosticCategory.ARIA,
|
|
763
625
|
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.`,
|
|
764
626
|
rationale: "aria-atomic controls whether assistive technology announces the entire live region or only the changed nodes. Omitting it leaves the behaviour browser-defined."
|
|
765
627
|
};
|
|
@@ -767,8 +629,8 @@ var AriaDiagnostics = {
|
|
|
767
629
|
relevantInvalidTokens(invalid) {
|
|
768
630
|
const quoted = invalid.map((t) => `"${t}"`).join(", ");
|
|
769
631
|
return {
|
|
770
|
-
code:
|
|
771
|
-
category:
|
|
632
|
+
code: DiagnosticCode.AriaRelevantInvalidToken,
|
|
633
|
+
category: DiagnosticCategory.ARIA,
|
|
772
634
|
message: `aria-relevant contains invalid token(s): ${quoted}. Valid tokens are: additions, removals, text, all.`,
|
|
773
635
|
rationale: "aria-relevant accepts a space-separated list of change types. Unrecognised tokens are silently ignored by assistive technology, making the attribute ineffective.",
|
|
774
636
|
suggestions: [
|
|
@@ -781,8 +643,8 @@ var AriaDiagnostics = {
|
|
|
781
643
|
},
|
|
782
644
|
relevantSuperseded() {
|
|
783
645
|
return {
|
|
784
|
-
code:
|
|
785
|
-
category:
|
|
646
|
+
code: DiagnosticCode.AriaRelevantSuperseded,
|
|
647
|
+
category: DiagnosticCategory.ARIA,
|
|
786
648
|
message: 'aria-relevant includes "all" alongside other tokens. "all" supersedes additions, removals, and text \u2014 use aria-relevant="all" alone.',
|
|
787
649
|
rationale: '"all" is equivalent to "additions removals text". Combining it with other tokens is redundant and may confuse readers of the markup.',
|
|
788
650
|
suggestions: [
|
|
@@ -795,8 +657,8 @@ var AriaDiagnostics = {
|
|
|
795
657
|
},
|
|
796
658
|
missingAccessibleName(tag) {
|
|
797
659
|
return {
|
|
798
|
-
code:
|
|
799
|
-
category:
|
|
660
|
+
code: DiagnosticCode.AriaMissingAccessibleName,
|
|
661
|
+
category: DiagnosticCategory.ARIA,
|
|
800
662
|
message: `<${tag}> has no accessible name. Add aria-label or aria-labelledby.`,
|
|
801
663
|
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.",
|
|
802
664
|
suggestions: [
|
|
@@ -813,8 +675,8 @@ var AriaDiagnostics = {
|
|
|
813
675
|
},
|
|
814
676
|
attributeOnPresentational(attr, tag) {
|
|
815
677
|
return {
|
|
816
|
-
code:
|
|
817
|
-
category:
|
|
678
|
+
code: DiagnosticCode.AriaAttributeOnPresentational,
|
|
679
|
+
category: DiagnosticCategory.ARIA,
|
|
818
680
|
message: `"${attr}" is not allowed on a presentational <${tag}>. Presentational elements are invisible to assistive technology.`,
|
|
819
681
|
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.',
|
|
820
682
|
suggestions: [
|
|
@@ -827,8 +689,8 @@ var AriaDiagnostics = {
|
|
|
827
689
|
},
|
|
828
690
|
ariaHiddenOnFocusable(tag) {
|
|
829
691
|
return {
|
|
830
|
-
code:
|
|
831
|
-
category:
|
|
692
|
+
code: DiagnosticCode.AriaHiddenOnFocusable,
|
|
693
|
+
category: DiagnosticCategory.ARIA,
|
|
832
694
|
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.`,
|
|
833
695
|
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.',
|
|
834
696
|
suggestions: [
|
|
@@ -846,8 +708,8 @@ var AriaDiagnostics = {
|
|
|
846
708
|
invalidAttributeValue(attr, value, expected) {
|
|
847
709
|
const got = value === null ? "null" : value === void 0 ? "undefined" : typeof value === "string" ? `"${value}"` : String(value);
|
|
848
710
|
return {
|
|
849
|
-
code:
|
|
850
|
-
category:
|
|
711
|
+
code: DiagnosticCode.AriaInvalidAttributeValue,
|
|
712
|
+
category: DiagnosticCategory.ARIA,
|
|
851
713
|
message: `"${attr}" has an invalid value (${got}). Expected: ${expected}.`,
|
|
852
714
|
rationale: "ARIA attributes with invalid values are silently ignored by assistive technology, making the markup semantically inert.",
|
|
853
715
|
suggestions: [
|
|
@@ -860,8 +722,8 @@ var AriaDiagnostics = {
|
|
|
860
722
|
},
|
|
861
723
|
redundantAriaLevel(tag, level) {
|
|
862
724
|
return {
|
|
863
|
-
code:
|
|
864
|
-
category:
|
|
725
|
+
code: DiagnosticCode.AriaRedundantLevelAttribute,
|
|
726
|
+
category: DiagnosticCategory.ARIA,
|
|
865
727
|
message: `aria-level="${level}" is redundant on <${tag}>: the element already has an implicit heading level of ${level}. Remove the attribute.`,
|
|
866
728
|
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>).',
|
|
867
729
|
suggestions: [
|
|
@@ -874,8 +736,8 @@ var AriaDiagnostics = {
|
|
|
874
736
|
},
|
|
875
737
|
requiredProperty(attr, role) {
|
|
876
738
|
return {
|
|
877
|
-
code:
|
|
878
|
-
category:
|
|
739
|
+
code: DiagnosticCode.AriaRequiredProperty,
|
|
740
|
+
category: DiagnosticCategory.ARIA,
|
|
879
741
|
message: `"${attr}" is required for role="${role}" but is missing.`,
|
|
880
742
|
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.`,
|
|
881
743
|
suggestions: [
|
|
@@ -888,8 +750,8 @@ var AriaDiagnostics = {
|
|
|
888
750
|
},
|
|
889
751
|
invalidRole(role, tag) {
|
|
890
752
|
return {
|
|
891
|
-
code:
|
|
892
|
-
category:
|
|
753
|
+
code: DiagnosticCode.AriaInvalidRole,
|
|
754
|
+
category: DiagnosticCategory.ARIA,
|
|
893
755
|
message: `Invalid role "${role ?? ""}" on <${tag}>.`,
|
|
894
756
|
rationale: "An unrecognised or misapplied ARIA role is ignored by assistive technology and may degrade the accessibility of the element."
|
|
895
757
|
};
|
|
@@ -897,11 +759,12 @@ var AriaDiagnostics = {
|
|
|
897
759
|
};
|
|
898
760
|
|
|
899
761
|
// ../../lib/contract/src/diagnostics/contract.ts
|
|
762
|
+
import { DiagnosticCategory as DiagnosticCategory2, DiagnosticCode as DiagnosticCode2 } from "./_shared/diagnostics.js";
|
|
900
763
|
var ContractDiagnostics = {
|
|
901
764
|
unexpectedChild(typeName, index, context) {
|
|
902
765
|
return {
|
|
903
|
-
code:
|
|
904
|
-
category:
|
|
766
|
+
code: DiagnosticCode2.UnexpectedChild,
|
|
767
|
+
category: DiagnosticCategory2.Contract,
|
|
905
768
|
component: context,
|
|
906
769
|
message: `${context}: unexpected child "${typeName}" at index ${index}.`
|
|
907
770
|
};
|
|
@@ -909,69 +772,69 @@ var ContractDiagnostics = {
|
|
|
909
772
|
ambiguousChild(typeName, index, ruleNames, context) {
|
|
910
773
|
const quoted = ruleNames.map((n) => `"${n}"`).join(" and ");
|
|
911
774
|
return {
|
|
912
|
-
code:
|
|
913
|
-
category:
|
|
775
|
+
code: DiagnosticCode2.AmbiguousChild,
|
|
776
|
+
category: DiagnosticCategory2.Contract,
|
|
914
777
|
component: context,
|
|
915
778
|
message: `${context}: child "${typeName}" at index ${index} matches multiple child rules: ${quoted}.`
|
|
916
779
|
};
|
|
917
780
|
},
|
|
918
781
|
cardinalityMin(ruleName, min, context) {
|
|
919
782
|
return {
|
|
920
|
-
code:
|
|
921
|
-
category:
|
|
783
|
+
code: DiagnosticCode2.CardinalityMin,
|
|
784
|
+
category: DiagnosticCategory2.Contract,
|
|
922
785
|
component: context,
|
|
923
786
|
message: `${context}: "${ruleName}" requires at least ${min}.`
|
|
924
787
|
};
|
|
925
788
|
},
|
|
926
789
|
cardinalityMax(ruleName, max, context) {
|
|
927
790
|
return {
|
|
928
|
-
code:
|
|
929
|
-
category:
|
|
791
|
+
code: DiagnosticCode2.CardinalityMax,
|
|
792
|
+
category: DiagnosticCategory2.Contract,
|
|
930
793
|
component: context,
|
|
931
794
|
message: `${context}: "${ruleName}" allows at most ${max}.`
|
|
932
795
|
};
|
|
933
796
|
},
|
|
934
797
|
positionViolation(ruleName, position, index, context) {
|
|
935
798
|
return {
|
|
936
|
-
code:
|
|
937
|
-
category:
|
|
799
|
+
code: DiagnosticCode2.PositionViolation,
|
|
800
|
+
category: DiagnosticCategory2.Contract,
|
|
938
801
|
component: context,
|
|
939
802
|
message: `${context}: "${ruleName}" must be ${position}, got index ${index}`
|
|
940
803
|
};
|
|
941
804
|
},
|
|
942
805
|
unknownVariantDim(component, label, dim) {
|
|
943
806
|
return {
|
|
944
|
-
code:
|
|
945
|
-
category:
|
|
807
|
+
code: DiagnosticCode2.ContractUnknownVariantDim,
|
|
808
|
+
category: DiagnosticCategory2.Contract,
|
|
946
809
|
message: `${component}: ${label} references unknown variant "${dim}".`
|
|
947
810
|
};
|
|
948
811
|
},
|
|
949
812
|
unknownVariantValue(component, label, dim, value, valid) {
|
|
950
813
|
return {
|
|
951
|
-
code:
|
|
952
|
-
category:
|
|
814
|
+
code: DiagnosticCode2.ContractUnknownVariantValue,
|
|
815
|
+
category: DiagnosticCategory2.Contract,
|
|
953
816
|
message: `${component}: ${label} sets "${dim}" to unknown value "${value}" (valid: ${valid.join(", ")}).`
|
|
954
817
|
};
|
|
955
818
|
},
|
|
956
819
|
unknownRecipeKey(component, key) {
|
|
957
820
|
return {
|
|
958
|
-
code:
|
|
959
|
-
category:
|
|
821
|
+
code: DiagnosticCode2.ContractUnknownRecipeKey,
|
|
822
|
+
category: DiagnosticCategory2.Contract,
|
|
960
823
|
message: `${component} Unknown recipeKey "${key}" \u2014 no preset with that name exists.`
|
|
961
824
|
};
|
|
962
825
|
},
|
|
963
826
|
invalidVariantValue(component, key, value) {
|
|
964
827
|
return {
|
|
965
|
-
code:
|
|
966
|
-
category:
|
|
828
|
+
code: DiagnosticCode2.ContractInvalidVariantValue,
|
|
829
|
+
category: DiagnosticCategory2.Contract,
|
|
967
830
|
message: `${component} Variant "${key}=${value}" is not a defined value for the "${key}" dimension.`
|
|
968
831
|
};
|
|
969
832
|
},
|
|
970
833
|
allowedAsViolation(tag, allowedAs, component) {
|
|
971
834
|
const allowed = allowedAs.map((t) => `"${String(t)}"`).join(", ");
|
|
972
835
|
return {
|
|
973
|
-
code:
|
|
974
|
-
category:
|
|
836
|
+
code: DiagnosticCode2.AllowedAsViolation,
|
|
837
|
+
category: DiagnosticCategory2.Contract,
|
|
975
838
|
component,
|
|
976
839
|
message: `<${component}>: "as" prop received "${tag}" but only [${allowed}] are allowed.`
|
|
977
840
|
};
|
|
@@ -979,73 +842,75 @@ var ContractDiagnostics = {
|
|
|
979
842
|
};
|
|
980
843
|
|
|
981
844
|
// ../../lib/contract/src/diagnostics/html.ts
|
|
845
|
+
import { DiagnosticCategory as DiagnosticCategory3, DiagnosticCode as DiagnosticCode3 } from "./_shared/diagnostics.js";
|
|
982
846
|
var HtmlDiagnostics = {
|
|
983
847
|
emptyRole(tag) {
|
|
984
848
|
return {
|
|
985
|
-
code:
|
|
986
|
-
category:
|
|
849
|
+
code: DiagnosticCode3.HtmlEmptyRole,
|
|
850
|
+
category: DiagnosticCategory3.HTML,
|
|
987
851
|
message: `<${tag}> has an explicit empty role="". Omit the attribute instead.`
|
|
988
852
|
};
|
|
989
853
|
},
|
|
990
854
|
implicitRoleRedundant(tag, implicitRole) {
|
|
991
855
|
return {
|
|
992
|
-
code:
|
|
993
|
-
category:
|
|
856
|
+
code: DiagnosticCode3.HtmlImplicitRoleRedundant,
|
|
857
|
+
category: DiagnosticCategory3.HTML,
|
|
994
858
|
message: `<${tag}> already has implicit role="${implicitRole}". Avoid redundant role assignment.`
|
|
995
859
|
};
|
|
996
860
|
},
|
|
997
861
|
implicitRoleOverride(tag, implicitRole, role) {
|
|
998
862
|
return {
|
|
999
|
-
code:
|
|
1000
|
-
category:
|
|
863
|
+
code: DiagnosticCode3.HtmlImplicitRoleOverride,
|
|
864
|
+
category: DiagnosticCategory3.HTML,
|
|
1001
865
|
message: `<${tag}> should not override its implicit role="${implicitRole}" with role="${role}".`
|
|
1002
866
|
};
|
|
1003
867
|
},
|
|
1004
868
|
standaloneRegionOverride(tag, implicitRole) {
|
|
1005
869
|
return {
|
|
1006
|
-
code:
|
|
1007
|
-
category:
|
|
870
|
+
code: DiagnosticCode3.HtmlStandaloneRegionOverride,
|
|
871
|
+
category: DiagnosticCategory3.HTML,
|
|
1008
872
|
message: `<${tag}> is a self-contained element with implicit role="${implicitRole}". Assigning role="region" has been removed.`
|
|
1009
873
|
};
|
|
1010
874
|
},
|
|
1011
875
|
landmarkRoleOverride(tag, implicitRole, role) {
|
|
1012
876
|
return {
|
|
1013
|
-
code:
|
|
1014
|
-
category:
|
|
877
|
+
code: DiagnosticCode3.HtmlLandmarkRoleOverride,
|
|
878
|
+
category: DiagnosticCategory3.HTML,
|
|
1015
879
|
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
1016
880
|
};
|
|
1017
881
|
},
|
|
1018
882
|
invalidChild(child, parent, allowed) {
|
|
1019
883
|
return {
|
|
1020
|
-
code:
|
|
1021
|
-
category:
|
|
884
|
+
code: DiagnosticCode3.HtmlInvalidChild,
|
|
885
|
+
category: DiagnosticCategory3.HTML,
|
|
1022
886
|
message: `<${child}> is not a valid direct child of <${parent}>. Allowed: ${allowed}.`
|
|
1023
887
|
};
|
|
1024
888
|
}
|
|
1025
889
|
};
|
|
1026
890
|
|
|
1027
891
|
// ../../lib/contract/src/diagnostics/slot.ts
|
|
892
|
+
import { DiagnosticCategory as DiagnosticCategory4, DiagnosticCode as DiagnosticCode4 } from "./_shared/diagnostics.js";
|
|
1028
893
|
var SlotDiagnostics = {
|
|
1029
894
|
exclusive(name) {
|
|
1030
895
|
return {
|
|
1031
|
-
code:
|
|
1032
|
-
category:
|
|
896
|
+
code: DiagnosticCode4.SlotExclusive,
|
|
897
|
+
category: DiagnosticCategory4.Contract,
|
|
1033
898
|
component: name,
|
|
1034
899
|
message: `${name}: "as" and "asChild" are mutually exclusive`
|
|
1035
900
|
};
|
|
1036
901
|
},
|
|
1037
902
|
singleChildRequired(name, elementTerm) {
|
|
1038
903
|
return {
|
|
1039
|
-
code:
|
|
1040
|
-
category:
|
|
904
|
+
code: DiagnosticCode4.SlotSingleChild,
|
|
905
|
+
category: DiagnosticCategory4.Contract,
|
|
1041
906
|
component: name,
|
|
1042
907
|
message: `${name}: asChild requires a ${elementTerm} child`
|
|
1043
908
|
};
|
|
1044
909
|
},
|
|
1045
910
|
singleChildExceeded(name, elementTerm, count) {
|
|
1046
911
|
return {
|
|
1047
|
-
code:
|
|
1048
|
-
category:
|
|
912
|
+
code: DiagnosticCode4.SlotSingleChild,
|
|
913
|
+
category: DiagnosticCategory4.Contract,
|
|
1049
914
|
component: name,
|
|
1050
915
|
message: `${name}: asChild requires exactly one ${elementTerm} child, got ${count}`
|
|
1051
916
|
};
|
|
@@ -1053,16 +918,16 @@ var SlotDiagnostics = {
|
|
|
1053
918
|
discardedChildren(name, elementTerm, count) {
|
|
1054
919
|
const suffix = count === 1 ? "" : "ren";
|
|
1055
920
|
return {
|
|
1056
|
-
code:
|
|
1057
|
-
category:
|
|
921
|
+
code: DiagnosticCode4.SlotDiscardedChildren,
|
|
922
|
+
category: DiagnosticCategory4.Contract,
|
|
1058
923
|
component: name,
|
|
1059
924
|
message: `${name}: asChild discarded ${count} non-element child${suffix} \u2014 only ${elementTerm}s are valid asChild children.`
|
|
1060
925
|
};
|
|
1061
926
|
},
|
|
1062
927
|
renderFnRequired(name, received) {
|
|
1063
928
|
return {
|
|
1064
|
-
code:
|
|
1065
|
-
category:
|
|
929
|
+
code: DiagnosticCode4.SlotRenderFn,
|
|
930
|
+
category: DiagnosticCategory4.Contract,
|
|
1066
931
|
component: name,
|
|
1067
932
|
message: `${name}: asChild requires a render function as children, got ${received}`
|
|
1068
933
|
};
|
|
@@ -1997,6 +1862,9 @@ var readonlyProps = ({
|
|
|
1997
1862
|
};
|
|
1998
1863
|
};
|
|
1999
1864
|
|
|
1865
|
+
// ../core/src/html/evaluators.ts
|
|
1866
|
+
import { warnDiagnostics as warnDiagnostics2 } from "./_shared/diagnostics.js";
|
|
1867
|
+
|
|
2000
1868
|
// ../core/src/html/aria-rules.ts
|
|
2001
1869
|
var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
|
|
2002
1870
|
var removeLandmarkRoleOverride = {
|
|
@@ -2039,6 +1907,7 @@ function landmarkNameAdvisory(ctx) {
|
|
|
2039
1907
|
}
|
|
2040
1908
|
|
|
2041
1909
|
// ../core/src/html/contracts.ts
|
|
1910
|
+
import { warnDiagnostics } from "./_shared/diagnostics.js";
|
|
2042
1911
|
function isOpenContent(...blockedTags) {
|
|
2043
1912
|
const set2 = new Set(blockedTags);
|
|
2044
1913
|
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set2.has(child.type));
|
|
@@ -2183,7 +2052,7 @@ var htmlContracts = {
|
|
|
2183
2052
|
};
|
|
2184
2053
|
|
|
2185
2054
|
// ../core/src/html/evaluators.ts
|
|
2186
|
-
var htmlDiagnostics =
|
|
2055
|
+
var htmlDiagnostics = warnDiagnostics2;
|
|
2187
2056
|
function buildEvaluatorMap() {
|
|
2188
2057
|
const map2 = /* @__PURE__ */ new Map();
|
|
2189
2058
|
iterate.forEachEntry(htmlContracts, (tag, { children }) => {
|
|
@@ -2242,6 +2111,7 @@ function createVariantPass(activeProps, config) {
|
|
|
2242
2111
|
}
|
|
2243
2112
|
|
|
2244
2113
|
// ../core/src/resolver/resolver.ts
|
|
2114
|
+
import { silentDiagnostics } from "./_shared/diagnostics.js";
|
|
2245
2115
|
function enforceAllowedAs(tag, allowedAs, diagnostics, displayName) {
|
|
2246
2116
|
if (allowedAs.includes(tag)) return;
|
|
2247
2117
|
if (!diagnostics) return;
|
|
@@ -2262,6 +2132,7 @@ function buildEngines(diagnostics, childRules, context) {
|
|
|
2262
2132
|
}
|
|
2263
2133
|
|
|
2264
2134
|
// ../../lib/adapter-utils/src/resolve-adapter-common-options.ts
|
|
2135
|
+
import { throwDiagnostics, silentDiagnostics as silentDiagnostics2 } from "./_shared/diagnostics.js";
|
|
2265
2136
|
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics) {
|
|
2266
2137
|
return {
|
|
2267
2138
|
name: options.name ?? defaultName,
|
package/dist/codemod/index.js
CHANGED
|
@@ -12,7 +12,11 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
12
12
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
13
13
|
});
|
|
14
14
|
var __commonJS = (cb, mod) => function __require2() {
|
|
15
|
-
|
|
15
|
+
try {
|
|
16
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
throw mod = 0, e;
|
|
19
|
+
}
|
|
16
20
|
};
|
|
17
21
|
var __copyProps = (to, from, except, desc) => {
|
|
18
22
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -211604,9 +211608,9 @@ var require_commonjs = __commonJS({
|
|
|
211604
211608
|
}
|
|
211605
211609
|
});
|
|
211606
211610
|
|
|
211607
|
-
// ../../node_modules/.pnpm/brace-expansion@5.0.
|
|
211611
|
+
// ../../node_modules/.pnpm/brace-expansion@5.0.7/node_modules/brace-expansion/dist/commonjs/index.js
|
|
211608
211612
|
var require_commonjs2 = __commonJS({
|
|
211609
|
-
"../../node_modules/.pnpm/brace-expansion@5.0.
|
|
211613
|
+
"../../node_modules/.pnpm/brace-expansion@5.0.7/node_modules/brace-expansion/dist/commonjs/index.js"(exports) {
|
|
211610
211614
|
"use strict";
|
|
211611
211615
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
211612
211616
|
exports.EXPANSION_MAX = void 0;
|
|
@@ -211682,17 +211686,19 @@ var require_commonjs2 = __commonJS({
|
|
|
211682
211686
|
}
|
|
211683
211687
|
function expand_(str, max, isTop) {
|
|
211684
211688
|
const expansions = [];
|
|
211685
|
-
|
|
211686
|
-
|
|
211687
|
-
|
|
211688
|
-
|
|
211689
|
-
|
|
211690
|
-
|
|
211691
|
-
|
|
211692
|
-
|
|
211693
|
-
|
|
211689
|
+
for (; ; ) {
|
|
211690
|
+
const m = (0, balanced_match_1.balanced)("{", "}", str);
|
|
211691
|
+
if (!m)
|
|
211692
|
+
return [str];
|
|
211693
|
+
const pre = m.pre;
|
|
211694
|
+
if (/\$$/.test(m.pre)) {
|
|
211695
|
+
const post2 = m.post.length ? expand_(m.post, max, false) : [""];
|
|
211696
|
+
for (let k = 0; k < post2.length && k < max; k++) {
|
|
211697
|
+
const expansion = pre + "{" + m.body + "}" + post2[k];
|
|
211698
|
+
expansions.push(expansion);
|
|
211699
|
+
}
|
|
211700
|
+
return expansions;
|
|
211694
211701
|
}
|
|
211695
|
-
} else {
|
|
211696
211702
|
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
211697
211703
|
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
211698
211704
|
const isSequence = isNumericSequence || isAlphaSequence;
|
|
@@ -211700,10 +211706,12 @@ var require_commonjs2 = __commonJS({
|
|
|
211700
211706
|
if (!isSequence && !isOptions) {
|
|
211701
211707
|
if (m.post.match(/,(?!,).*\}/)) {
|
|
211702
211708
|
str = m.pre + "{" + m.body + escClose + m.post;
|
|
211703
|
-
|
|
211709
|
+
isTop = true;
|
|
211710
|
+
continue;
|
|
211704
211711
|
}
|
|
211705
211712
|
return [str];
|
|
211706
211713
|
}
|
|
211714
|
+
const post = m.post.length ? expand_(m.post, max, false) : [""];
|
|
211707
211715
|
let n;
|
|
211708
211716
|
if (isSequence) {
|
|
211709
211717
|
n = m.body.split(/\.\./);
|
|
@@ -211767,8 +211775,8 @@ var require_commonjs2 = __commonJS({
|
|
|
211767
211775
|
}
|
|
211768
211776
|
}
|
|
211769
211777
|
}
|
|
211778
|
+
return expansions;
|
|
211770
211779
|
}
|
|
211771
|
-
return expansions;
|
|
211772
211780
|
}
|
|
211773
211781
|
}
|
|
211774
211782
|
});
|