praxis-kit 4.1.2 → 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/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
- constructor(rules, diagnostics, context = "Component") {
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 { matrix, unexpectedIndices, ambiguousIndices } = this.#matcher.match(children);
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 = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
2045
- var tableContract = contract([
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 = contract([
2072
+ var tableBodyContract = closedContract([
2054
2073
  { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
2055
2074
  ]);
2056
- var tableRowContract = contract([
2075
+ var tableRowContract = closedContract([
2057
2076
  { name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
2058
2077
  ]);
2059
- var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
2060
- var dlContract = contract([
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 = contract([
2087
+ var selectContract = closedContract([
2067
2088
  { name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
2068
2089
  ]);
2069
- var optgroupContract = contract([
2090
+ var optgroupContract = closedContract([
2070
2091
  { name: "option", match: isTag("option", ...METADATA_TAGS) }
2071
2092
  ]);
2072
- var datalistContract = contract([
2093
+ var datalistContract = closedContract([
2073
2094
  { name: "option", match: isTag("option", ...METADATA_TAGS) }
2074
2095
  ]);
2075
- var pictureContract = contract([
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 = contract([
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 = contract([
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(tag, new ChildrenEvaluator(children, htmlDiagnostics, `<${tag}>`));
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 ?? silentDiagnostics,
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
- return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
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 ?? defaultDiagnostics
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);
@@ -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
- readonly diagnostics?: Diagnostics;
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
- constructor(rules, diagnostics, context = "Component") {
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 { matrix, unexpectedIndices, ambiguousIndices } = this.#matcher.match(children);
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 = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
1892
- var tableContract = contract([
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 = contract([
1919
+ var tableBodyContract = closedContract([
1901
1920
  { name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
1902
1921
  ]);
1903
- var tableRowContract = contract([
1922
+ var tableRowContract = closedContract([
1904
1923
  { name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
1905
1924
  ]);
1906
- var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
1907
- var dlContract = contract([
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 = contract([
1934
+ var selectContract = closedContract([
1914
1935
  { name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
1915
1936
  ]);
1916
- var optgroupContract = contract([
1937
+ var optgroupContract = closedContract([
1917
1938
  { name: "option", match: isTag("option", ...METADATA_TAGS) }
1918
1939
  ]);
1919
- var datalistContract = contract([
1940
+ var datalistContract = closedContract([
1920
1941
  { name: "option", match: isTag("option", ...METADATA_TAGS) }
1921
1942
  ]);
1922
- var pictureContract = contract([
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 = contract([
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 = contract([
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(tag, new ChildrenEvaluator(children, htmlDiagnostics, `<${tag}>`));
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 ?? silentDiagnostics,
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
- return childRules?.length ? { childrenEvaluator: new ChildrenEvaluator(childRules, diagnostics, context) } : {};
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 ?? defaultDiagnostics
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": "4.1.2",
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"
@@ -39,6 +42,7 @@
39
42
  "types": "./dist/tailwind/index.d.ts",
40
43
  "import": "./dist/tailwind/index.js"
41
44
  },
45
+ "./tailwind.css": "./dist/tailwind/safelist.css",
42
46
  "./eslint": {
43
47
  "types": "./dist/eslint/index.d.ts",
44
48
  "import": "./dist/eslint/index.js"
@@ -60,6 +64,52 @@
60
64
  "import": "./dist/contract/index.js"
61
65
  }
62
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
+ },
63
113
  "bin": {
64
114
  "praxis-codemod": "./dist/codemod/index.js"
65
115
  },
@@ -70,7 +120,7 @@
70
120
  "sideEffects": false,
71
121
  "dependencies": {
72
122
  "clsx": "^2.1.1",
73
- "type-fest": "^5.7.0"
123
+ "type-fest": "^5.8.0"
74
124
  },
75
125
  "peerDependencies": {
76
126
  "react": ">=18",
@@ -114,10 +164,12 @@
114
164
  },
115
165
  "devDependencies": {
116
166
  "@sveltejs/vite-plugin-svelte": "^7.0.0",
167
+ "esbuild": "^0.28.1",
168
+ "esbuild-plugin-solid": "^0.6.0",
117
169
  "@types/node": "^25.9.1",
118
170
  "@types/react": "^19.2.17",
119
171
  "@types/react-dom": "^19.0.0",
120
- "@typescript-eslint/utils": "8.60.0",
172
+ "@typescript-eslint/utils": "8.63.0",
121
173
  "lit": "^3.0.0",
122
174
  "preact": "^10.25.0",
123
175
  "react": "^19.2.7",
@@ -126,13 +178,16 @@
126
178
  "svelte": "^5.56.3",
127
179
  "ts-morph": "^28.0.0",
128
180
  "tsup": "^8.5.1",
181
+ "tsx": "^4.22.5",
129
182
  "typescript": "^6.0.3",
130
- "vite": "^8.1.3",
183
+ "vite": "^8.1.4",
131
184
  "vue": "^3.5.38",
132
- "@praxis-kit/adapter-utils": "0.0.0",
133
185
  "@praxis-kit/core": "0.0.0",
186
+ "@praxis-kit/adapter-utils": "0.0.0",
187
+ "@praxis-kit/pipeline": "0.0.0",
188
+ "@praxis-kit/primitive": "0.0.0",
134
189
  "@praxis-kit/diagnostics": "0.0.0",
135
- "@praxis-kit/primitive": "0.0.0"
190
+ "@praxis-kit/vite-plugin": "0.0.0"
136
191
  },
137
192
  "publishConfig": {
138
193
  "access": "public"
@@ -171,7 +226,7 @@
171
226
  "node": ">=18"
172
227
  },
173
228
  "scripts": {
174
- "build": "rm -rf dist && tsup && node scripts/postbuild.mjs",
229
+ "build": "rm -rf dist && tsup && tsx scripts/postbuild.ts",
175
230
  "dev": "tsup --watch",
176
231
  "lint": "eslint . --fix",
177
232
  "lint:check": "eslint .",