praxis-kit 4.1.3 → 5.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/dist/_shared/diagnostics.d.ts +10 -1
- package/dist/_shared/diagnostics.js +12 -0
- package/dist/{chunk-R2RKHZNX.js → chunk-SKAY22CZ.js} +67 -33
- package/dist/codemod/index.js +39 -22
- package/dist/contract/index.d.ts +18 -2
- package/dist/eslint/index.js +16 -16
- package/dist/lit/index.d.ts +18 -2
- package/dist/lit/index.js +64 -33
- package/dist/preact/index.d.ts +18 -2
- package/dist/preact/index.js +66 -33
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/dist/react/legacy.d.ts +2 -2
- package/dist/react/legacy.js +1 -1
- package/dist/{react-options-XrRof248.d.ts → react-options-D6rRB2gJ.d.ts} +18 -2
- package/dist/solid/index.d.ts +18 -2
- package/dist/solid/index.js +109 -64
- package/dist/svelte/Polymorphic.svelte +146 -0
- package/dist/svelte/index.d.ts +34 -3
- package/dist/svelte/index.js +67 -33
- package/dist/vite-plugin/index.d.ts +31 -0
- package/dist/vite-plugin/index.js +32 -15
- package/dist/vue/index.d.ts +18 -2
- package/dist/vue/index.js +67 -33
- package/dist/web/index.d.ts +18 -2
- package/dist/web/index.js +64 -33
- package/package.json +60 -7
package/dist/vue/index.js
CHANGED
|
@@ -1867,17 +1867,22 @@ var RuleValidator = class _RuleValidator extends InvariantBase {
|
|
|
1867
1867
|
};
|
|
1868
1868
|
|
|
1869
1869
|
// ../../lib/contract/src/children/children-evaluator.ts
|
|
1870
|
+
var isTextLike = (child) => isString(child) || isNumber(child);
|
|
1870
1871
|
var ChildrenEvaluator = class extends InvariantBase {
|
|
1871
1872
|
#context;
|
|
1872
1873
|
#rules;
|
|
1873
1874
|
#ruleNames;
|
|
1874
1875
|
#matcher;
|
|
1875
1876
|
#ruleValidator;
|
|
1876
|
-
|
|
1877
|
+
#exclusiveChildren;
|
|
1878
|
+
#allowText;
|
|
1879
|
+
constructor(rules, diagnostics, context = "Component", options = {}) {
|
|
1877
1880
|
super(diagnostics);
|
|
1878
1881
|
this.#context = context;
|
|
1879
1882
|
this.#rules = rules.map((r) => normalizeChildRule(r));
|
|
1880
1883
|
this.#ruleNames = this.#rules.map((r) => r.name);
|
|
1884
|
+
this.#exclusiveChildren = options.exclusiveChildren ?? false;
|
|
1885
|
+
this.#allowText = options.allowText ?? true;
|
|
1881
1886
|
iterate.forEach(this.#rules, (rule) => {
|
|
1882
1887
|
const { name, position, cardinality } = rule;
|
|
1883
1888
|
if ((position === "first" || position === "last") && (cardinality.kind === "unbounded" || cardinality.max > 1)) {
|
|
@@ -1891,8 +1896,17 @@ var ChildrenEvaluator = class extends InvariantBase {
|
|
|
1891
1896
|
}
|
|
1892
1897
|
evaluate(children) {
|
|
1893
1898
|
if (!this.active) return;
|
|
1894
|
-
const {
|
|
1899
|
+
const {
|
|
1900
|
+
matrix,
|
|
1901
|
+
unexpectedIndices: rawUnexpectedIndices,
|
|
1902
|
+
ambiguousIndices
|
|
1903
|
+
} = this.#matcher.match(children);
|
|
1895
1904
|
this.#ruleValidator.validate(this.#rules, matrix, children.length);
|
|
1905
|
+
const unexpectedIndices = new Set(
|
|
1906
|
+
[...rawUnexpectedIndices].filter(
|
|
1907
|
+
(ci) => isTextLike(children[ci]) ? this.#allowText === false : this.#exclusiveChildren
|
|
1908
|
+
)
|
|
1909
|
+
);
|
|
1896
1910
|
if (unexpectedIndices.size === 0 && ambiguousIndices.size === 0) return;
|
|
1897
1911
|
const violating = [...unexpectedIndices, ...ambiguousIndices].sort((a, b) => a - b);
|
|
1898
1912
|
iterate.forEach(violating, (ci) => {
|
|
@@ -2014,8 +2028,11 @@ function metadata(name = "metadata") {
|
|
|
2014
2028
|
function firstOptional(name, tag) {
|
|
2015
2029
|
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
2016
2030
|
}
|
|
2017
|
-
function contract(children) {
|
|
2018
|
-
return { diagnostics: warnDiagnostics, children };
|
|
2031
|
+
function contract(children, options) {
|
|
2032
|
+
return { diagnostics: warnDiagnostics, children, ...options };
|
|
2033
|
+
}
|
|
2034
|
+
function closedContract(children) {
|
|
2035
|
+
return contract(children, { exclusiveChildren: true });
|
|
2019
2036
|
}
|
|
2020
2037
|
function ariaContract(aria) {
|
|
2021
2038
|
return { diagnostics: warnDiagnostics, aria };
|
|
@@ -2041,8 +2058,10 @@ var VOID_TAGS = [
|
|
|
2041
2058
|
];
|
|
2042
2059
|
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
2043
2060
|
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
2044
|
-
var listContract =
|
|
2045
|
-
|
|
2061
|
+
var listContract = closedContract([
|
|
2062
|
+
{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }
|
|
2063
|
+
]);
|
|
2064
|
+
var tableContract = closedContract([
|
|
2046
2065
|
firstOptional("caption", "caption"),
|
|
2047
2066
|
{ name: "colgroup", match: isTag("colgroup") },
|
|
2048
2067
|
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
@@ -2050,29 +2069,31 @@ var tableContract = contract([
|
|
|
2050
2069
|
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
2051
2070
|
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
2052
2071
|
]);
|
|
2053
|
-
var tableBodyContract =
|
|
2072
|
+
var tableBodyContract = closedContract([
|
|
2054
2073
|
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
2055
2074
|
]);
|
|
2056
|
-
var tableRowContract =
|
|
2075
|
+
var tableRowContract = closedContract([
|
|
2057
2076
|
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
2058
2077
|
]);
|
|
2059
|
-
var colgroupContract =
|
|
2060
|
-
|
|
2078
|
+
var colgroupContract = closedContract([
|
|
2079
|
+
{ name: "column", match: isTag("col", "template") }
|
|
2080
|
+
]);
|
|
2081
|
+
var dlContract = closedContract([
|
|
2061
2082
|
{ name: "term", match: isTag("dt") },
|
|
2062
2083
|
{ name: "description", match: isTag("dd") },
|
|
2063
2084
|
{ name: "group", match: isTag("div") },
|
|
2064
2085
|
metadata()
|
|
2065
2086
|
]);
|
|
2066
|
-
var selectContract =
|
|
2087
|
+
var selectContract = closedContract([
|
|
2067
2088
|
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
2068
2089
|
]);
|
|
2069
|
-
var optgroupContract =
|
|
2090
|
+
var optgroupContract = closedContract([
|
|
2070
2091
|
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
2071
2092
|
]);
|
|
2072
|
-
var datalistContract =
|
|
2093
|
+
var datalistContract = closedContract([
|
|
2073
2094
|
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
2074
2095
|
]);
|
|
2075
|
-
var pictureContract =
|
|
2096
|
+
var pictureContract = closedContract([
|
|
2076
2097
|
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
2077
2098
|
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
2078
2099
|
]);
|
|
@@ -2088,23 +2109,18 @@ var mediaContract = contract([
|
|
|
2088
2109
|
metadata(),
|
|
2089
2110
|
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
2090
2111
|
]);
|
|
2091
|
-
var headContract =
|
|
2112
|
+
var headContract = closedContract([
|
|
2092
2113
|
{
|
|
2093
2114
|
name: "metadata",
|
|
2094
2115
|
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
2095
2116
|
}
|
|
2096
2117
|
]);
|
|
2097
|
-
var htmlContract =
|
|
2118
|
+
var htmlContract = closedContract([
|
|
2098
2119
|
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
2099
2120
|
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
2100
2121
|
]);
|
|
2101
|
-
var voidContract = contract([]);
|
|
2102
|
-
var textOnlyContract = contract([
|
|
2103
|
-
{
|
|
2104
|
-
name: "text",
|
|
2105
|
-
match: (child) => isString(child) || isNumber(child)
|
|
2106
|
-
}
|
|
2107
|
-
]);
|
|
2122
|
+
var voidContract = contract([], { exclusiveChildren: true, allowText: false });
|
|
2123
|
+
var textOnlyContract = contract([], { exclusiveChildren: true });
|
|
2108
2124
|
var landmarkContract = ariaContract([landmarkRoleRule, landmarkNameAdvisory]);
|
|
2109
2125
|
var dialogContract = ariaContract([requireAccessibleName]);
|
|
2110
2126
|
var menuContract = ariaContract([requireAccessibleName]);
|
|
@@ -2149,9 +2165,15 @@ var htmlContracts = {
|
|
|
2149
2165
|
var htmlDiagnostics = warnDiagnostics2;
|
|
2150
2166
|
function buildEvaluatorMap() {
|
|
2151
2167
|
const map2 = /* @__PURE__ */ new Map();
|
|
2152
|
-
iterate.forEachEntry(htmlContracts, (tag, { children }) => {
|
|
2153
|
-
if (children?.length) {
|
|
2154
|
-
map2.set(
|
|
2168
|
+
iterate.forEachEntry(htmlContracts, (tag, { children, exclusiveChildren, allowText }) => {
|
|
2169
|
+
if (children?.length || exclusiveChildren || allowText === false) {
|
|
2170
|
+
map2.set(
|
|
2171
|
+
tag,
|
|
2172
|
+
new ChildrenEvaluator(children ?? [], htmlDiagnostics, `<${tag}>`, {
|
|
2173
|
+
exclusiveChildren,
|
|
2174
|
+
allowText
|
|
2175
|
+
})
|
|
2176
|
+
);
|
|
2155
2177
|
}
|
|
2156
2178
|
});
|
|
2157
2179
|
return map2;
|
|
@@ -2362,7 +2384,7 @@ function definePipeline(factory) {
|
|
|
2362
2384
|
}
|
|
2363
2385
|
|
|
2364
2386
|
// ../core/src/options/resolve-factory-options.ts
|
|
2365
|
-
import { silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2387
|
+
import { resolveDiagnostics, silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2366
2388
|
var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
|
|
2367
2389
|
function composeNormalizers(normalizers, fn) {
|
|
2368
2390
|
if (!normalizers?.length) return fn;
|
|
@@ -2383,7 +2405,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
2383
2405
|
const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
|
|
2384
2406
|
return Object.freeze({
|
|
2385
2407
|
defaultTag: options.tag ?? "div",
|
|
2386
|
-
diagnostics: enforcement?.diagnostics
|
|
2408
|
+
diagnostics: resolveDiagnostics(enforcement?.diagnostics, silentDiagnostics),
|
|
2387
2409
|
variantKeys,
|
|
2388
2410
|
...whenDefined("displayName", options.name),
|
|
2389
2411
|
...whenDefined("defaultProps", options.defaults),
|
|
@@ -2396,6 +2418,8 @@ function resolveFactoryOptions(options = {}) {
|
|
|
2396
2418
|
...whenDefined("normalizeFn", composedNormalizeFn),
|
|
2397
2419
|
...whenDefined("ariaRules", enforcement?.aria),
|
|
2398
2420
|
...whenDefined("childRules", enforcement?.children),
|
|
2421
|
+
...whenDefined("exclusiveChildren", enforcement?.exclusiveChildren),
|
|
2422
|
+
...whenDefined("allowText", enforcement?.allowText),
|
|
2399
2423
|
...whenDefined("allowedAs", enforcement?.allowedAs),
|
|
2400
2424
|
...whenDefined("precomputedClasses", styling?.precomputedClasses)
|
|
2401
2425
|
});
|
|
@@ -2580,16 +2604,22 @@ function buildCoreRuntime(normalized) {
|
|
|
2580
2604
|
}
|
|
2581
2605
|
|
|
2582
2606
|
// ../../lib/adapter-utils/src/runtime/build-engines.ts
|
|
2583
|
-
function buildEngines(diagnostics, childRules, context) {
|
|
2584
|
-
|
|
2607
|
+
function buildEngines(diagnostics, childRules, context, childrenOptions) {
|
|
2608
|
+
const { exclusiveChildren, allowText } = childrenOptions ?? {};
|
|
2609
|
+
return childRules?.length || exclusiveChildren || allowText === false ? {
|
|
2610
|
+
childrenEvaluator: new ChildrenEvaluator(childRules ?? [], diagnostics, context, {
|
|
2611
|
+
exclusiveChildren,
|
|
2612
|
+
allowText
|
|
2613
|
+
})
|
|
2614
|
+
} : {};
|
|
2585
2615
|
}
|
|
2586
2616
|
|
|
2587
2617
|
// ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
|
|
2588
|
-
import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "../_shared/diagnostics.js";
|
|
2618
|
+
import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3, resolveDiagnostics as resolveDiagnostics2 } from "../_shared/diagnostics.js";
|
|
2589
2619
|
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
|
|
2590
2620
|
return {
|
|
2591
2621
|
name: options.name ?? defaultName,
|
|
2592
|
-
diagnostics: options.enforcement?.diagnostics
|
|
2622
|
+
diagnostics: resolveDiagnostics2(options.enforcement?.diagnostics, defaultDiagnostics)
|
|
2593
2623
|
};
|
|
2594
2624
|
}
|
|
2595
2625
|
|
|
@@ -2646,7 +2676,10 @@ function buildRuntime(options) {
|
|
|
2646
2676
|
const normalized = normalizeOptions(options);
|
|
2647
2677
|
const { runtime, ownedKeys } = buildCoreRuntime(normalized);
|
|
2648
2678
|
const { diagnostics, enforcement, filterProps: userFilter, name } = normalized;
|
|
2649
|
-
const { childrenEvaluator } = buildEngines(diagnostics, enforcement?.children, name
|
|
2679
|
+
const { childrenEvaluator } = buildEngines(diagnostics, enforcement?.children, name, {
|
|
2680
|
+
exclusiveChildren: enforcement?.exclusiveChildren,
|
|
2681
|
+
allowText: enforcement?.allowText
|
|
2682
|
+
});
|
|
2650
2683
|
const filterProps = composeFilter(ownedKeys, userFilter);
|
|
2651
2684
|
const slotValidator = new SlotValidator(name, diagnostics, "VNode");
|
|
2652
2685
|
const built = {
|
|
@@ -2799,6 +2832,7 @@ function render({
|
|
|
2799
2832
|
const { vnodes: children, discarded } = normalizeChildren(slots);
|
|
2800
2833
|
if (process.env.NODE_ENV !== "production") {
|
|
2801
2834
|
childrenEvaluator?.evaluate(children);
|
|
2835
|
+
runtime.options.htmlChildrenEvaluatorFn?.(state.tag)?.evaluate(children);
|
|
2802
2836
|
}
|
|
2803
2837
|
const slotResult = tryRenderAsChild(state, children, discarded, slotValidator);
|
|
2804
2838
|
return slotResult ?? renderIntrinsic(state, runtime, slots);
|
package/dist/web/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { RequireAtLeastOne, Simplify, ReadonlyDeep } from 'type-fest';
|
|
2
|
-
import { Diagnostics, DiagnosticInput } from '../_shared/diagnostics.js';
|
|
2
|
+
import { Diagnostics, DiagnosticInput, DiagnosticsMode } from '../_shared/diagnostics.js';
|
|
3
3
|
|
|
4
4
|
type StringMap<T = unknown> = Record<string, T>;
|
|
5
5
|
type AnyRecord = StringMap<unknown>;
|
|
@@ -195,9 +195,25 @@ type AriaRule<C extends AriaContext = AriaContext> = (context: C) => readonly Ar
|
|
|
195
195
|
type PropNormalizer = (props: Readonly<AnyRecord & IntrinsicProps>) => Partial<AnyRecord & IntrinsicProps>;
|
|
196
196
|
|
|
197
197
|
type EnforcementOptions<TAllowed extends ElementType = ElementType> = {
|
|
198
|
-
|
|
198
|
+
/**
|
|
199
|
+
* Accepts a preset name (`'warn'`, `'throw'`, `'silent'`) or a full `Diagnostics`
|
|
200
|
+
* instance for custom reporting/policy. The string form needs no import from
|
|
201
|
+
* `@praxis-kit/diagnostics`.
|
|
202
|
+
*/
|
|
203
|
+
readonly diagnostics?: Diagnostics | DiagnosticsMode;
|
|
199
204
|
readonly aria?: readonly AriaRule[];
|
|
200
205
|
readonly children?: readonly ChildRuleInput[];
|
|
206
|
+
/**
|
|
207
|
+
* When true, only children matching a `children` rule (or text, per `allowText`)
|
|
208
|
+
* are valid — anything else is rejected. Default: false (open — children not
|
|
209
|
+
* matching any rule are allowed).
|
|
210
|
+
*/
|
|
211
|
+
readonly exclusiveChildren?: boolean;
|
|
212
|
+
/**
|
|
213
|
+
* When false, text/number child nodes are rejected regardless of exclusiveChildren
|
|
214
|
+
* or any listed rule. Default: true.
|
|
215
|
+
*/
|
|
216
|
+
readonly allowText?: boolean;
|
|
201
217
|
readonly props?: readonly PropNormalizer[];
|
|
202
218
|
/** Restricts the `as` prop to this set of tags. Violations route through diagnostics. */
|
|
203
219
|
readonly allowedAs?: readonly TAllowed[];
|
package/dist/web/index.js
CHANGED
|
@@ -1714,17 +1714,22 @@ var RuleValidator = class _RuleValidator extends InvariantBase {
|
|
|
1714
1714
|
};
|
|
1715
1715
|
|
|
1716
1716
|
// ../../lib/contract/src/children/children-evaluator.ts
|
|
1717
|
+
var isTextLike = (child) => isString(child) || isNumber(child);
|
|
1717
1718
|
var ChildrenEvaluator = class extends InvariantBase {
|
|
1718
1719
|
#context;
|
|
1719
1720
|
#rules;
|
|
1720
1721
|
#ruleNames;
|
|
1721
1722
|
#matcher;
|
|
1722
1723
|
#ruleValidator;
|
|
1723
|
-
|
|
1724
|
+
#exclusiveChildren;
|
|
1725
|
+
#allowText;
|
|
1726
|
+
constructor(rules, diagnostics, context = "Component", options = {}) {
|
|
1724
1727
|
super(diagnostics);
|
|
1725
1728
|
this.#context = context;
|
|
1726
1729
|
this.#rules = rules.map((r) => normalizeChildRule(r));
|
|
1727
1730
|
this.#ruleNames = this.#rules.map((r) => r.name);
|
|
1731
|
+
this.#exclusiveChildren = options.exclusiveChildren ?? false;
|
|
1732
|
+
this.#allowText = options.allowText ?? true;
|
|
1728
1733
|
iterate.forEach(this.#rules, (rule) => {
|
|
1729
1734
|
const { name, position, cardinality } = rule;
|
|
1730
1735
|
if ((position === "first" || position === "last") && (cardinality.kind === "unbounded" || cardinality.max > 1)) {
|
|
@@ -1738,8 +1743,17 @@ var ChildrenEvaluator = class extends InvariantBase {
|
|
|
1738
1743
|
}
|
|
1739
1744
|
evaluate(children) {
|
|
1740
1745
|
if (!this.active) return;
|
|
1741
|
-
const {
|
|
1746
|
+
const {
|
|
1747
|
+
matrix,
|
|
1748
|
+
unexpectedIndices: rawUnexpectedIndices,
|
|
1749
|
+
ambiguousIndices
|
|
1750
|
+
} = this.#matcher.match(children);
|
|
1742
1751
|
this.#ruleValidator.validate(this.#rules, matrix, children.length);
|
|
1752
|
+
const unexpectedIndices = new Set(
|
|
1753
|
+
[...rawUnexpectedIndices].filter(
|
|
1754
|
+
(ci) => isTextLike(children[ci]) ? this.#allowText === false : this.#exclusiveChildren
|
|
1755
|
+
)
|
|
1756
|
+
);
|
|
1743
1757
|
if (unexpectedIndices.size === 0 && ambiguousIndices.size === 0) return;
|
|
1744
1758
|
const violating = [...unexpectedIndices, ...ambiguousIndices].sort((a, b) => a - b);
|
|
1745
1759
|
iterate.forEach(violating, (ci) => {
|
|
@@ -1861,8 +1875,11 @@ function metadata(name = "metadata") {
|
|
|
1861
1875
|
function firstOptional(name, tag) {
|
|
1862
1876
|
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
1863
1877
|
}
|
|
1864
|
-
function contract(children) {
|
|
1865
|
-
return { diagnostics: warnDiagnostics, children };
|
|
1878
|
+
function contract(children, options) {
|
|
1879
|
+
return { diagnostics: warnDiagnostics, children, ...options };
|
|
1880
|
+
}
|
|
1881
|
+
function closedContract(children) {
|
|
1882
|
+
return contract(children, { exclusiveChildren: true });
|
|
1866
1883
|
}
|
|
1867
1884
|
function ariaContract(aria) {
|
|
1868
1885
|
return { diagnostics: warnDiagnostics, aria };
|
|
@@ -1888,8 +1905,10 @@ var VOID_TAGS = [
|
|
|
1888
1905
|
];
|
|
1889
1906
|
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
1890
1907
|
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
1891
|
-
var listContract =
|
|
1892
|
-
|
|
1908
|
+
var listContract = closedContract([
|
|
1909
|
+
{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }
|
|
1910
|
+
]);
|
|
1911
|
+
var tableContract = closedContract([
|
|
1893
1912
|
firstOptional("caption", "caption"),
|
|
1894
1913
|
{ name: "colgroup", match: isTag("colgroup") },
|
|
1895
1914
|
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
@@ -1897,29 +1916,31 @@ var tableContract = contract([
|
|
|
1897
1916
|
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
1898
1917
|
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1899
1918
|
]);
|
|
1900
|
-
var tableBodyContract =
|
|
1919
|
+
var tableBodyContract = closedContract([
|
|
1901
1920
|
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1902
1921
|
]);
|
|
1903
|
-
var tableRowContract =
|
|
1922
|
+
var tableRowContract = closedContract([
|
|
1904
1923
|
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
1905
1924
|
]);
|
|
1906
|
-
var colgroupContract =
|
|
1907
|
-
|
|
1925
|
+
var colgroupContract = closedContract([
|
|
1926
|
+
{ name: "column", match: isTag("col", "template") }
|
|
1927
|
+
]);
|
|
1928
|
+
var dlContract = closedContract([
|
|
1908
1929
|
{ name: "term", match: isTag("dt") },
|
|
1909
1930
|
{ name: "description", match: isTag("dd") },
|
|
1910
1931
|
{ name: "group", match: isTag("div") },
|
|
1911
1932
|
metadata()
|
|
1912
1933
|
]);
|
|
1913
|
-
var selectContract =
|
|
1934
|
+
var selectContract = closedContract([
|
|
1914
1935
|
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
1915
1936
|
]);
|
|
1916
|
-
var optgroupContract =
|
|
1937
|
+
var optgroupContract = closedContract([
|
|
1917
1938
|
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1918
1939
|
]);
|
|
1919
|
-
var datalistContract =
|
|
1940
|
+
var datalistContract = closedContract([
|
|
1920
1941
|
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1921
1942
|
]);
|
|
1922
|
-
var pictureContract =
|
|
1943
|
+
var pictureContract = closedContract([
|
|
1923
1944
|
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
1924
1945
|
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
1925
1946
|
]);
|
|
@@ -1935,23 +1956,18 @@ var mediaContract = contract([
|
|
|
1935
1956
|
metadata(),
|
|
1936
1957
|
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
1937
1958
|
]);
|
|
1938
|
-
var headContract =
|
|
1959
|
+
var headContract = closedContract([
|
|
1939
1960
|
{
|
|
1940
1961
|
name: "metadata",
|
|
1941
1962
|
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
1942
1963
|
}
|
|
1943
1964
|
]);
|
|
1944
|
-
var htmlContract =
|
|
1965
|
+
var htmlContract = closedContract([
|
|
1945
1966
|
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
1946
1967
|
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
1947
1968
|
]);
|
|
1948
|
-
var voidContract = contract([]);
|
|
1949
|
-
var textOnlyContract = contract([
|
|
1950
|
-
{
|
|
1951
|
-
name: "text",
|
|
1952
|
-
match: (child) => isString(child) || isNumber(child)
|
|
1953
|
-
}
|
|
1954
|
-
]);
|
|
1969
|
+
var voidContract = contract([], { exclusiveChildren: true, allowText: false });
|
|
1970
|
+
var textOnlyContract = contract([], { exclusiveChildren: true });
|
|
1955
1971
|
var landmarkContract = ariaContract([landmarkRoleRule, landmarkNameAdvisory]);
|
|
1956
1972
|
var dialogContract = ariaContract([requireAccessibleName]);
|
|
1957
1973
|
var menuContract = ariaContract([requireAccessibleName]);
|
|
@@ -1996,9 +2012,15 @@ var htmlContracts = {
|
|
|
1996
2012
|
var htmlDiagnostics = warnDiagnostics2;
|
|
1997
2013
|
function buildEvaluatorMap() {
|
|
1998
2014
|
const map2 = /* @__PURE__ */ new Map();
|
|
1999
|
-
iterate.forEachEntry(htmlContracts, (tag, { children }) => {
|
|
2000
|
-
if (children?.length) {
|
|
2001
|
-
map2.set(
|
|
2015
|
+
iterate.forEachEntry(htmlContracts, (tag, { children, exclusiveChildren, allowText }) => {
|
|
2016
|
+
if (children?.length || exclusiveChildren || allowText === false) {
|
|
2017
|
+
map2.set(
|
|
2018
|
+
tag,
|
|
2019
|
+
new ChildrenEvaluator(children ?? [], htmlDiagnostics, `<${tag}>`, {
|
|
2020
|
+
exclusiveChildren,
|
|
2021
|
+
allowText
|
|
2022
|
+
})
|
|
2023
|
+
);
|
|
2002
2024
|
}
|
|
2003
2025
|
});
|
|
2004
2026
|
return map2;
|
|
@@ -2209,7 +2231,7 @@ function definePipeline(factory) {
|
|
|
2209
2231
|
}
|
|
2210
2232
|
|
|
2211
2233
|
// ../core/src/options/resolve-factory-options.ts
|
|
2212
|
-
import { silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2234
|
+
import { resolveDiagnostics, silentDiagnostics } from "../_shared/diagnostics.js";
|
|
2213
2235
|
var EMPTY_VARIANT_KEYS = /* @__PURE__ */ new Set();
|
|
2214
2236
|
function composeNormalizers(normalizers, fn) {
|
|
2215
2237
|
if (!normalizers?.length) return fn;
|
|
@@ -2230,7 +2252,7 @@ function resolveFactoryOptions(options = {}) {
|
|
|
2230
2252
|
const variantKeys = styling?.variants === void 0 ? EMPTY_VARIANT_KEYS : new Set(Object.keys(styling.variants));
|
|
2231
2253
|
return Object.freeze({
|
|
2232
2254
|
defaultTag: options.tag ?? "div",
|
|
2233
|
-
diagnostics: enforcement?.diagnostics
|
|
2255
|
+
diagnostics: resolveDiagnostics(enforcement?.diagnostics, silentDiagnostics),
|
|
2234
2256
|
variantKeys,
|
|
2235
2257
|
...whenDefined("displayName", options.name),
|
|
2236
2258
|
...whenDefined("defaultProps", options.defaults),
|
|
@@ -2243,6 +2265,8 @@ function resolveFactoryOptions(options = {}) {
|
|
|
2243
2265
|
...whenDefined("normalizeFn", composedNormalizeFn),
|
|
2244
2266
|
...whenDefined("ariaRules", enforcement?.aria),
|
|
2245
2267
|
...whenDefined("childRules", enforcement?.children),
|
|
2268
|
+
...whenDefined("exclusiveChildren", enforcement?.exclusiveChildren),
|
|
2269
|
+
...whenDefined("allowText", enforcement?.allowText),
|
|
2246
2270
|
...whenDefined("allowedAs", enforcement?.allowedAs),
|
|
2247
2271
|
...whenDefined("precomputedClasses", styling?.precomputedClasses)
|
|
2248
2272
|
});
|
|
@@ -2427,16 +2451,22 @@ function buildCoreRuntime(normalized) {
|
|
|
2427
2451
|
}
|
|
2428
2452
|
|
|
2429
2453
|
// ../../lib/adapter-utils/src/runtime/build-engines.ts
|
|
2430
|
-
function buildEngines(diagnostics, childRules, context) {
|
|
2431
|
-
|
|
2454
|
+
function buildEngines(diagnostics, childRules, context, childrenOptions) {
|
|
2455
|
+
const { exclusiveChildren, allowText } = childrenOptions ?? {};
|
|
2456
|
+
return childRules?.length || exclusiveChildren || allowText === false ? {
|
|
2457
|
+
childrenEvaluator: new ChildrenEvaluator(childRules ?? [], diagnostics, context, {
|
|
2458
|
+
exclusiveChildren,
|
|
2459
|
+
allowText
|
|
2460
|
+
})
|
|
2461
|
+
} : {};
|
|
2432
2462
|
}
|
|
2433
2463
|
|
|
2434
2464
|
// ../../lib/adapter-utils/src/runtime/resolve-adapter-common-options.ts
|
|
2435
|
-
import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3 } from "../_shared/diagnostics.js";
|
|
2465
|
+
import { throwDiagnostics as throwDiagnostics2, silentDiagnostics as silentDiagnostics3, resolveDiagnostics as resolveDiagnostics2 } from "../_shared/diagnostics.js";
|
|
2436
2466
|
function resolveAdapterCommonOptions(options, defaultName = "PolymorphicComponent", defaultDiagnostics = throwDiagnostics2) {
|
|
2437
2467
|
return {
|
|
2438
2468
|
name: options.name ?? defaultName,
|
|
2439
|
-
diagnostics: options.enforcement?.diagnostics
|
|
2469
|
+
diagnostics: resolveDiagnostics2(options.enforcement?.diagnostics, defaultDiagnostics)
|
|
2440
2470
|
};
|
|
2441
2471
|
}
|
|
2442
2472
|
|
|
@@ -2594,7 +2624,8 @@ function buildRuntime(options) {
|
|
|
2594
2624
|
const { childrenEvaluator } = buildEngines(
|
|
2595
2625
|
normalized.diagnostics,
|
|
2596
2626
|
enforcement?.children,
|
|
2597
|
-
normalized.name
|
|
2627
|
+
normalized.name,
|
|
2628
|
+
{ exclusiveChildren: enforcement?.exclusiveChildren, allowText: enforcement?.allowText }
|
|
2598
2629
|
);
|
|
2599
2630
|
const filterProps = composeFilter(ownedKeys, customFilter);
|
|
2600
2631
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "praxis-kit",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./react": {
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"types": "./dist/svelte/index.d.ts",
|
|
24
24
|
"import": "./dist/svelte/index.js"
|
|
25
25
|
},
|
|
26
|
+
"./svelte/Polymorphic.svelte": {
|
|
27
|
+
"svelte": "./dist/svelte/Polymorphic.svelte"
|
|
28
|
+
},
|
|
26
29
|
"./vue": {
|
|
27
30
|
"types": "./dist/vue/index.d.ts",
|
|
28
31
|
"import": "./dist/vue/index.js"
|
|
@@ -61,6 +64,52 @@
|
|
|
61
64
|
"import": "./dist/contract/index.js"
|
|
62
65
|
}
|
|
63
66
|
},
|
|
67
|
+
"typesVersions": {
|
|
68
|
+
"*": {
|
|
69
|
+
"react": [
|
|
70
|
+
"./dist/react/index.d.ts"
|
|
71
|
+
],
|
|
72
|
+
"react/legacy": [
|
|
73
|
+
"./dist/react/legacy.d.ts"
|
|
74
|
+
],
|
|
75
|
+
"preact": [
|
|
76
|
+
"./dist/preact/index.d.ts"
|
|
77
|
+
],
|
|
78
|
+
"solid": [
|
|
79
|
+
"./dist/solid/index.d.ts"
|
|
80
|
+
],
|
|
81
|
+
"svelte": [
|
|
82
|
+
"./dist/svelte/index.d.ts"
|
|
83
|
+
],
|
|
84
|
+
"vue": [
|
|
85
|
+
"./dist/vue/index.d.ts"
|
|
86
|
+
],
|
|
87
|
+
"lit": [
|
|
88
|
+
"./dist/lit/index.d.ts"
|
|
89
|
+
],
|
|
90
|
+
"web": [
|
|
91
|
+
"./dist/web/index.d.ts"
|
|
92
|
+
],
|
|
93
|
+
"tailwind": [
|
|
94
|
+
"./dist/tailwind/index.d.ts"
|
|
95
|
+
],
|
|
96
|
+
"eslint": [
|
|
97
|
+
"./dist/eslint/index.d.ts"
|
|
98
|
+
],
|
|
99
|
+
"ts-plugin": [
|
|
100
|
+
"./dist/ts-plugin/index.d.cts"
|
|
101
|
+
],
|
|
102
|
+
"vite-plugin": [
|
|
103
|
+
"./dist/vite-plugin/index.d.ts"
|
|
104
|
+
],
|
|
105
|
+
"codemod": [
|
|
106
|
+
"./dist/codemod/index.d.ts"
|
|
107
|
+
],
|
|
108
|
+
"contract": [
|
|
109
|
+
"./dist/contract/index.d.ts"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
},
|
|
64
113
|
"bin": {
|
|
65
114
|
"praxis-codemod": "./dist/codemod/index.js"
|
|
66
115
|
},
|
|
@@ -71,7 +120,7 @@
|
|
|
71
120
|
"sideEffects": false,
|
|
72
121
|
"dependencies": {
|
|
73
122
|
"clsx": "^2.1.1",
|
|
74
|
-
"type-fest": "^5.
|
|
123
|
+
"type-fest": "^5.8.0"
|
|
75
124
|
},
|
|
76
125
|
"peerDependencies": {
|
|
77
126
|
"react": ">=18",
|
|
@@ -115,10 +164,12 @@
|
|
|
115
164
|
},
|
|
116
165
|
"devDependencies": {
|
|
117
166
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
167
|
+
"esbuild": "^0.28.1",
|
|
168
|
+
"esbuild-plugin-solid": "^0.6.0",
|
|
118
169
|
"@types/node": "^25.9.1",
|
|
119
170
|
"@types/react": "^19.2.17",
|
|
120
171
|
"@types/react-dom": "^19.0.0",
|
|
121
|
-
"@typescript-eslint/utils": "8.
|
|
172
|
+
"@typescript-eslint/utils": "8.63.0",
|
|
122
173
|
"lit": "^3.0.0",
|
|
123
174
|
"preact": "^10.25.0",
|
|
124
175
|
"react": "^19.2.7",
|
|
@@ -127,13 +178,15 @@
|
|
|
127
178
|
"svelte": "^5.56.3",
|
|
128
179
|
"ts-morph": "^28.0.0",
|
|
129
180
|
"tsup": "^8.5.1",
|
|
181
|
+
"tsx": "^4.22.5",
|
|
130
182
|
"typescript": "^6.0.3",
|
|
131
|
-
"vite": "^8.1.
|
|
183
|
+
"vite": "^8.1.4",
|
|
132
184
|
"vue": "^3.5.38",
|
|
133
|
-
"@praxis-kit/adapter-utils": "0.0.0",
|
|
134
185
|
"@praxis-kit/core": "0.0.0",
|
|
135
|
-
"@praxis-kit/
|
|
186
|
+
"@praxis-kit/adapter-utils": "0.0.0",
|
|
187
|
+
"@praxis-kit/pipeline": "0.0.0",
|
|
136
188
|
"@praxis-kit/primitive": "0.0.0",
|
|
189
|
+
"@praxis-kit/diagnostics": "0.0.0",
|
|
137
190
|
"@praxis-kit/vite-plugin": "0.0.0"
|
|
138
191
|
},
|
|
139
192
|
"publishConfig": {
|
|
@@ -173,7 +226,7 @@
|
|
|
173
226
|
"node": ">=18"
|
|
174
227
|
},
|
|
175
228
|
"scripts": {
|
|
176
|
-
"build": "rm -rf dist && tsup &&
|
|
229
|
+
"build": "rm -rf dist && tsup && tsx scripts/postbuild.ts",
|
|
177
230
|
"dev": "tsup --watch",
|
|
178
231
|
"lint": "eslint . --fix",
|
|
179
232
|
"lint:check": "eslint .",
|