praxis-kit 1.1.1 → 2.0.1
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/{chunk-KDUNVQK2.js → chunk-ACAKUHH5.js} +531 -386
- package/dist/contract/index.d.ts +255 -0
- package/dist/contract/index.js +1370 -0
- package/dist/lit/index.d.ts +2 -1
- package/dist/lit/index.js +257 -184
- package/dist/{merge-refs-CfBqh1UO.d.ts → merge-refs-DxjWMq3U.d.ts} +2 -5
- package/dist/preact/index.d.ts +2 -5
- package/dist/preact/index.js +236 -187
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +1 -5
- package/dist/react/legacy.d.ts +2 -2
- package/dist/react/legacy.js +1 -5
- package/dist/solid/index.d.ts +2 -5
- package/dist/solid/index.js +238 -189
- package/dist/svelte/index.d.ts +3 -5
- package/dist/svelte/index.js +233 -186
- package/dist/vue/index.d.ts +2 -5
- package/dist/vue/index.js +236 -187
- package/dist/web/index.d.ts +2 -1
- package/dist/web/index.js +259 -185
- package/package.json +7 -3
package/dist/solid/index.js
CHANGED
|
@@ -17,7 +17,7 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
17
17
|
return out;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
// ../core/dist/chunk-
|
|
20
|
+
// ../core/dist/chunk-XFCAUPVZ.js
|
|
21
21
|
function makeResolveTag(defaultTag) {
|
|
22
22
|
return function tag(as) {
|
|
23
23
|
return as ?? defaultTag;
|
|
@@ -252,7 +252,11 @@ function createRuntimeObject(methods, resolved, pluginResult) {
|
|
|
252
252
|
return pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
|
|
253
253
|
}
|
|
254
254
|
function createPolymorphic(options = {}, capabilities) {
|
|
255
|
-
const
|
|
255
|
+
const baseResolved = resolveFactoryOptions(options);
|
|
256
|
+
const resolved = capabilities?.htmlPropNormalizersFn !== void 0 ? Object.freeze({
|
|
257
|
+
...baseResolved,
|
|
258
|
+
htmlPropNormalizersFn: capabilities.htmlPropNormalizersFn
|
|
259
|
+
}) : baseResolved;
|
|
256
260
|
if (process.env.NODE_ENV !== "production") validateFactoryOptions(resolved);
|
|
257
261
|
const { pluginResult, classPipeline } = resolveClassPipeline(
|
|
258
262
|
options,
|
|
@@ -260,9 +264,12 @@ function createPolymorphic(options = {}, capabilities) {
|
|
|
260
264
|
resolved.strict,
|
|
261
265
|
capabilities
|
|
262
266
|
);
|
|
267
|
+
const allAriaRules = [
|
|
268
|
+
.../* @__PURE__ */ new Set([...capabilities?.htmlAriaRules ?? [], ...resolved.ariaRules ?? []])
|
|
269
|
+
];
|
|
263
270
|
const engine = options.enforcement !== void 0 && capabilities?.AriaEngine ? new capabilities.AriaEngine(
|
|
264
271
|
resolved.strict,
|
|
265
|
-
|
|
272
|
+
allAriaRules.length ? { rules: allAriaRules } : void 0
|
|
266
273
|
) : null;
|
|
267
274
|
const methods = createRuntimeMethods(resolved, classPipeline, engine);
|
|
268
275
|
return createRuntimeObject(
|
|
@@ -581,184 +588,7 @@ function isKnownAriaRole(value) {
|
|
|
581
588
|
return isString(value) && KNOWN_ARIA_ROLES_SET.has(value);
|
|
582
589
|
}
|
|
583
590
|
|
|
584
|
-
// ../core/dist/chunk-
|
|
585
|
-
var COMPONENT_DEFAULT_TAG2 = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
586
|
-
function resolveChildTag(child) {
|
|
587
|
-
if (!isObject(child) || !("type" in child)) return void 0;
|
|
588
|
-
const t = child.type;
|
|
589
|
-
if (isString(t)) return t;
|
|
590
|
-
if (isObject(t) && COMPONENT_DEFAULT_TAG2 in t) {
|
|
591
|
-
const defaultTag = t[COMPONENT_DEFAULT_TAG2];
|
|
592
|
-
if (!isString(defaultTag)) return void 0;
|
|
593
|
-
const props = child.props;
|
|
594
|
-
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
595
|
-
return isString(as) ? as : defaultTag;
|
|
596
|
-
}
|
|
597
|
-
return void 0;
|
|
598
|
-
}
|
|
599
|
-
function isTag(...tags) {
|
|
600
|
-
const set = new Set(tags);
|
|
601
|
-
return (child) => {
|
|
602
|
-
const tag = resolveChildTag(child);
|
|
603
|
-
return tag !== void 0 && set.has(tag);
|
|
604
|
-
};
|
|
605
|
-
}
|
|
606
|
-
function isOpenContent(...blockedTags) {
|
|
607
|
-
const set = new Set(blockedTags);
|
|
608
|
-
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
|
|
609
|
-
}
|
|
610
|
-
var METADATA_TAGS = ["script", "template"];
|
|
611
|
-
var metadataMatch = isTag(...METADATA_TAGS);
|
|
612
|
-
function metadata(name = "metadata") {
|
|
613
|
-
return { name, match: metadataMatch };
|
|
614
|
-
}
|
|
615
|
-
function firstOptional(name, tag) {
|
|
616
|
-
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
617
|
-
}
|
|
618
|
-
function contract(children) {
|
|
619
|
-
return { strict: "warn", children };
|
|
620
|
-
}
|
|
621
|
-
function ariaContract(aria) {
|
|
622
|
-
return { strict: "warn", aria };
|
|
623
|
-
}
|
|
624
|
-
function firstChildContract(name, tag) {
|
|
625
|
-
return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
|
|
626
|
-
}
|
|
627
|
-
var VOID_TAGS = [
|
|
628
|
-
"area",
|
|
629
|
-
"base",
|
|
630
|
-
"br",
|
|
631
|
-
"col",
|
|
632
|
-
"embed",
|
|
633
|
-
"hr",
|
|
634
|
-
"img",
|
|
635
|
-
"input",
|
|
636
|
-
"link",
|
|
637
|
-
"meta",
|
|
638
|
-
"param",
|
|
639
|
-
"source",
|
|
640
|
-
"track",
|
|
641
|
-
"wbr"
|
|
642
|
-
];
|
|
643
|
-
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
644
|
-
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
645
|
-
var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
|
|
646
|
-
var tableContract = contract([
|
|
647
|
-
firstOptional("caption", "caption"),
|
|
648
|
-
{ name: "colgroup", match: isTag("colgroup") },
|
|
649
|
-
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
650
|
-
{ name: "tbody", match: isTag("tbody") },
|
|
651
|
-
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
652
|
-
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
653
|
-
]);
|
|
654
|
-
var tableBodyContract = contract([
|
|
655
|
-
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
656
|
-
]);
|
|
657
|
-
var tableRowContract = contract([
|
|
658
|
-
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
659
|
-
]);
|
|
660
|
-
var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
|
|
661
|
-
var dlContract = contract([
|
|
662
|
-
{ name: "term", match: isTag("dt") },
|
|
663
|
-
{ name: "description", match: isTag("dd") },
|
|
664
|
-
{ name: "group", match: isTag("div") },
|
|
665
|
-
metadata()
|
|
666
|
-
]);
|
|
667
|
-
var selectContract = contract([
|
|
668
|
-
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
669
|
-
]);
|
|
670
|
-
var optgroupContract = contract([
|
|
671
|
-
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
672
|
-
]);
|
|
673
|
-
var datalistContract = contract([
|
|
674
|
-
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
675
|
-
]);
|
|
676
|
-
var pictureContract = contract([
|
|
677
|
-
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
678
|
-
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
679
|
-
]);
|
|
680
|
-
var figureContract = contract([
|
|
681
|
-
{ name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
|
|
682
|
-
{ name: "content", match: isOpenContent("figcaption") }
|
|
683
|
-
]);
|
|
684
|
-
var detailsContract = firstChildContract("summary", "summary");
|
|
685
|
-
var fieldsetContract = firstChildContract("legend", "legend");
|
|
686
|
-
var mediaContract = contract([
|
|
687
|
-
{ name: "source", match: isTag("source") },
|
|
688
|
-
{ name: "track", match: isTag("track") },
|
|
689
|
-
metadata(),
|
|
690
|
-
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
691
|
-
]);
|
|
692
|
-
var headContract = contract([
|
|
693
|
-
{
|
|
694
|
-
name: "metadata",
|
|
695
|
-
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
696
|
-
}
|
|
697
|
-
]);
|
|
698
|
-
var htmlContract = contract([
|
|
699
|
-
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
700
|
-
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
701
|
-
]);
|
|
702
|
-
var voidContract = contract([]);
|
|
703
|
-
var textOnlyContract = contract([
|
|
704
|
-
{
|
|
705
|
-
name: "text",
|
|
706
|
-
match: (child) => isString(child) || isNumber(child)
|
|
707
|
-
}
|
|
708
|
-
]);
|
|
709
|
-
var LANDMARK_TAG_SET = new Set(LANDMARK_TAGS);
|
|
710
|
-
var removeLandmarkRoleOverride = {
|
|
711
|
-
kind: "removeRole",
|
|
712
|
-
apply: ({ props }) => {
|
|
713
|
-
if (!("role" in props)) return { applied: false, next: props };
|
|
714
|
-
const { role: _r, ...rest } = props;
|
|
715
|
-
return { applied: true, next: rest, previous: props };
|
|
716
|
-
}
|
|
717
|
-
};
|
|
718
|
-
function landmarkRoleRule({ tag, props, implicitRole }) {
|
|
719
|
-
if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
|
|
720
|
-
const role = props.role;
|
|
721
|
-
if (!role || role === implicitRole) return [];
|
|
722
|
-
return [
|
|
723
|
-
{
|
|
724
|
-
valid: false,
|
|
725
|
-
fixable: true,
|
|
726
|
-
severity: "error",
|
|
727
|
-
fix: removeLandmarkRoleOverride,
|
|
728
|
-
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
729
|
-
}
|
|
730
|
-
];
|
|
731
|
-
}
|
|
732
|
-
var landmarkContract = ariaContract([landmarkRoleRule]);
|
|
733
|
-
var CONTRACT_GROUPS = [
|
|
734
|
-
[VOID_TAGS, voidContract],
|
|
735
|
-
[TEXT_ONLY_TAGS, textOnlyContract],
|
|
736
|
-
[LANDMARK_TAGS, landmarkContract],
|
|
737
|
-
[["ul", "ol", "menu"], listContract],
|
|
738
|
-
[["audio", "video"], mediaContract],
|
|
739
|
-
[["thead", "tbody", "tfoot"], tableBodyContract]
|
|
740
|
-
];
|
|
741
|
-
function contractMap(groups) {
|
|
742
|
-
return Object.fromEntries(
|
|
743
|
-
groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
|
|
744
|
-
);
|
|
745
|
-
}
|
|
746
|
-
var htmlContracts = {
|
|
747
|
-
...contractMap(CONTRACT_GROUPS),
|
|
748
|
-
table: tableContract,
|
|
749
|
-
tr: tableRowContract,
|
|
750
|
-
colgroup: colgroupContract,
|
|
751
|
-
dl: dlContract,
|
|
752
|
-
select: selectContract,
|
|
753
|
-
optgroup: optgroupContract,
|
|
754
|
-
datalist: datalistContract,
|
|
755
|
-
picture: pictureContract,
|
|
756
|
-
figure: figureContract,
|
|
757
|
-
details: detailsContract,
|
|
758
|
-
fieldset: fieldsetContract,
|
|
759
|
-
head: headContract,
|
|
760
|
-
html: htmlContract
|
|
761
|
-
};
|
|
591
|
+
// ../core/dist/chunk-VU44HAB7.js
|
|
762
592
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
763
593
|
article: "article",
|
|
764
594
|
aside: "complementary",
|
|
@@ -787,6 +617,27 @@ function getImplicitRole(tag) {
|
|
|
787
617
|
if (tag in IMPLICIT_ROLE_RECORD2) return IMPLICIT_ROLE_RECORD2[tag];
|
|
788
618
|
return void 0;
|
|
789
619
|
}
|
|
620
|
+
var COMPONENT_DEFAULT_TAG2 = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
621
|
+
function resolveChildTag(child) {
|
|
622
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
623
|
+
const t = child.type;
|
|
624
|
+
if (isString(t)) return t;
|
|
625
|
+
if (isObject(t) && COMPONENT_DEFAULT_TAG2 in t) {
|
|
626
|
+
const defaultTag = t[COMPONENT_DEFAULT_TAG2];
|
|
627
|
+
if (!isString(defaultTag)) return void 0;
|
|
628
|
+
const props = child.props;
|
|
629
|
+
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
630
|
+
return isString(as) ? as : defaultTag;
|
|
631
|
+
}
|
|
632
|
+
return void 0;
|
|
633
|
+
}
|
|
634
|
+
function isTag(...tags) {
|
|
635
|
+
const set = new Set(tags);
|
|
636
|
+
return (child) => {
|
|
637
|
+
const tag = resolveChildTag(child);
|
|
638
|
+
return tag !== void 0 && set.has(tag);
|
|
639
|
+
};
|
|
640
|
+
}
|
|
790
641
|
var pendingAsyncWarns2 = /* @__PURE__ */ new Set();
|
|
791
642
|
var asyncWarnScheduled2 = false;
|
|
792
643
|
function flushAsyncWarns2() {
|
|
@@ -1478,8 +1329,201 @@ var invalidProps = ({
|
|
|
1478
1329
|
...dataInvalid === void 0 && { "data-invalid": "" }
|
|
1479
1330
|
};
|
|
1480
1331
|
};
|
|
1332
|
+
var readonlyProps = ({
|
|
1333
|
+
readOnly,
|
|
1334
|
+
"aria-readonly": ariaReadonly,
|
|
1335
|
+
"data-readonly": dataReadonly
|
|
1336
|
+
}) => {
|
|
1337
|
+
if (!readOnly) return {};
|
|
1338
|
+
return {
|
|
1339
|
+
...ariaReadonly === void 0 && {
|
|
1340
|
+
"aria-readonly": "true"
|
|
1341
|
+
},
|
|
1342
|
+
...dataReadonly === void 0 && {
|
|
1343
|
+
"data-readonly": ""
|
|
1344
|
+
}
|
|
1345
|
+
};
|
|
1346
|
+
};
|
|
1347
|
+
var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
|
|
1348
|
+
var removeLandmarkRoleOverride = {
|
|
1349
|
+
kind: "removeRole",
|
|
1350
|
+
apply: ({ props }) => {
|
|
1351
|
+
if (!("role" in props)) return { applied: false, next: props };
|
|
1352
|
+
const { role: _r, ...rest } = props;
|
|
1353
|
+
return { applied: true, next: rest, previous: props };
|
|
1354
|
+
}
|
|
1355
|
+
};
|
|
1356
|
+
function landmarkRoleRule({ tag, props, implicitRole }) {
|
|
1357
|
+
if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
|
|
1358
|
+
const role = props.role;
|
|
1359
|
+
if (!role || role === implicitRole) return [];
|
|
1360
|
+
return [
|
|
1361
|
+
{
|
|
1362
|
+
valid: false,
|
|
1363
|
+
fixable: true,
|
|
1364
|
+
severity: "error",
|
|
1365
|
+
fix: removeLandmarkRoleOverride,
|
|
1366
|
+
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
1367
|
+
}
|
|
1368
|
+
];
|
|
1369
|
+
}
|
|
1370
|
+
var HTML_ARIA_RULES = [landmarkRoleRule];
|
|
1371
|
+
function isOpenContent(...blockedTags) {
|
|
1372
|
+
const set = new Set(blockedTags);
|
|
1373
|
+
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
|
|
1374
|
+
}
|
|
1375
|
+
var METADATA_TAGS = ["script", "template"];
|
|
1376
|
+
var metadataMatch = isTag(...METADATA_TAGS);
|
|
1377
|
+
function metadata(name = "metadata") {
|
|
1378
|
+
return { name, match: metadataMatch };
|
|
1379
|
+
}
|
|
1380
|
+
function firstOptional(name, tag) {
|
|
1381
|
+
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
1382
|
+
}
|
|
1383
|
+
function contract(children) {
|
|
1384
|
+
return { strict: "warn", children };
|
|
1385
|
+
}
|
|
1386
|
+
function ariaContract(aria) {
|
|
1387
|
+
return { strict: "warn", aria };
|
|
1388
|
+
}
|
|
1389
|
+
function firstChildContract(name, tag) {
|
|
1390
|
+
return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
|
|
1391
|
+
}
|
|
1392
|
+
var VOID_TAGS = [
|
|
1393
|
+
"area",
|
|
1394
|
+
"base",
|
|
1395
|
+
"br",
|
|
1396
|
+
"col",
|
|
1397
|
+
"embed",
|
|
1398
|
+
"hr",
|
|
1399
|
+
"img",
|
|
1400
|
+
"input",
|
|
1401
|
+
"link",
|
|
1402
|
+
"meta",
|
|
1403
|
+
"param",
|
|
1404
|
+
"source",
|
|
1405
|
+
"track",
|
|
1406
|
+
"wbr"
|
|
1407
|
+
];
|
|
1408
|
+
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
1409
|
+
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
1410
|
+
var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
|
|
1411
|
+
var tableContract = contract([
|
|
1412
|
+
firstOptional("caption", "caption"),
|
|
1413
|
+
{ name: "colgroup", match: isTag("colgroup") },
|
|
1414
|
+
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
1415
|
+
{ name: "tbody", match: isTag("tbody") },
|
|
1416
|
+
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
1417
|
+
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1418
|
+
]);
|
|
1419
|
+
var tableBodyContract = contract([
|
|
1420
|
+
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1421
|
+
]);
|
|
1422
|
+
var tableRowContract = contract([
|
|
1423
|
+
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
1424
|
+
]);
|
|
1425
|
+
var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
|
|
1426
|
+
var dlContract = contract([
|
|
1427
|
+
{ name: "term", match: isTag("dt") },
|
|
1428
|
+
{ name: "description", match: isTag("dd") },
|
|
1429
|
+
{ name: "group", match: isTag("div") },
|
|
1430
|
+
metadata()
|
|
1431
|
+
]);
|
|
1432
|
+
var selectContract = contract([
|
|
1433
|
+
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
1434
|
+
]);
|
|
1435
|
+
var optgroupContract = contract([
|
|
1436
|
+
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1437
|
+
]);
|
|
1438
|
+
var datalistContract = contract([
|
|
1439
|
+
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1440
|
+
]);
|
|
1441
|
+
var pictureContract = contract([
|
|
1442
|
+
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
1443
|
+
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
1444
|
+
]);
|
|
1445
|
+
var figureContract = contract([
|
|
1446
|
+
{ name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
|
|
1447
|
+
{ name: "content", match: isOpenContent("figcaption") }
|
|
1448
|
+
]);
|
|
1449
|
+
var detailsContract = firstChildContract("summary", "summary");
|
|
1450
|
+
var fieldsetContract = firstChildContract("legend", "legend");
|
|
1451
|
+
var mediaContract = contract([
|
|
1452
|
+
{ name: "source", match: isTag("source") },
|
|
1453
|
+
{ name: "track", match: isTag("track") },
|
|
1454
|
+
metadata(),
|
|
1455
|
+
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
1456
|
+
]);
|
|
1457
|
+
var headContract = contract([
|
|
1458
|
+
{
|
|
1459
|
+
name: "metadata",
|
|
1460
|
+
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
1461
|
+
}
|
|
1462
|
+
]);
|
|
1463
|
+
var htmlContract = contract([
|
|
1464
|
+
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
1465
|
+
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
1466
|
+
]);
|
|
1467
|
+
var voidContract = contract([]);
|
|
1468
|
+
var textOnlyContract = contract([
|
|
1469
|
+
{
|
|
1470
|
+
name: "text",
|
|
1471
|
+
match: (child) => isString(child) || isNumber(child)
|
|
1472
|
+
}
|
|
1473
|
+
]);
|
|
1474
|
+
var landmarkContract = ariaContract([landmarkRoleRule]);
|
|
1475
|
+
var CONTRACT_GROUPS = [
|
|
1476
|
+
[VOID_TAGS, voidContract],
|
|
1477
|
+
[TEXT_ONLY_TAGS, textOnlyContract],
|
|
1478
|
+
[LANDMARK_TAGS, landmarkContract],
|
|
1479
|
+
[["ul", "ol", "menu"], listContract],
|
|
1480
|
+
[["audio", "video"], mediaContract],
|
|
1481
|
+
[["thead", "tbody", "tfoot"], tableBodyContract]
|
|
1482
|
+
];
|
|
1483
|
+
function contractMap(groups) {
|
|
1484
|
+
return Object.fromEntries(
|
|
1485
|
+
groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
|
|
1486
|
+
);
|
|
1487
|
+
}
|
|
1488
|
+
var htmlContracts = {
|
|
1489
|
+
...contractMap(CONTRACT_GROUPS),
|
|
1490
|
+
table: tableContract,
|
|
1491
|
+
tr: tableRowContract,
|
|
1492
|
+
colgroup: colgroupContract,
|
|
1493
|
+
dl: dlContract,
|
|
1494
|
+
select: selectContract,
|
|
1495
|
+
optgroup: optgroupContract,
|
|
1496
|
+
datalist: datalistContract,
|
|
1497
|
+
picture: pictureContract,
|
|
1498
|
+
figure: figureContract,
|
|
1499
|
+
details: detailsContract,
|
|
1500
|
+
fieldset: fieldsetContract,
|
|
1501
|
+
head: headContract,
|
|
1502
|
+
html: htmlContract
|
|
1503
|
+
};
|
|
1504
|
+
function buildEvaluatorMap() {
|
|
1505
|
+
const map = /* @__PURE__ */ new Map();
|
|
1506
|
+
for (const [tag, { children }] of Object.entries(htmlContracts)) {
|
|
1507
|
+
if (children?.length) {
|
|
1508
|
+
map.set(tag, new ChildrenEvaluator(children, "warn", `<${tag}>`));
|
|
1509
|
+
}
|
|
1510
|
+
}
|
|
1511
|
+
return map;
|
|
1512
|
+
}
|
|
1513
|
+
var HTML_EVALUATORS = buildEvaluatorMap();
|
|
1514
|
+
var HTML_FORM_NORMALIZERS = /* @__PURE__ */ new Map([
|
|
1515
|
+
["button", [disabledProps]],
|
|
1516
|
+
["input", [disabledProps, readonlyProps, invalidProps]],
|
|
1517
|
+
["select", [disabledProps]],
|
|
1518
|
+
["textarea", [disabledProps, readonlyProps]],
|
|
1519
|
+
["fieldset", [disabledProps]],
|
|
1520
|
+
["optgroup", [disabledProps]]
|
|
1521
|
+
]);
|
|
1522
|
+
function getHtmlPropNormalizers(tag) {
|
|
1523
|
+
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
1524
|
+
}
|
|
1481
1525
|
|
|
1482
|
-
// ../core/dist/chunk-
|
|
1526
|
+
// ../core/dist/chunk-EHCOMLJ4.js
|
|
1483
1527
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1484
1528
|
var cx = clsx;
|
|
1485
1529
|
var cva = (base, config) => (props) => {
|
|
@@ -1645,7 +1689,12 @@ function createClassPipeline(resolved) {
|
|
|
1645
1689
|
}
|
|
1646
1690
|
|
|
1647
1691
|
// ../core/dist/index.js
|
|
1648
|
-
var FULL_CAPABILITIES = {
|
|
1692
|
+
var FULL_CAPABILITIES = {
|
|
1693
|
+
createClassPipeline,
|
|
1694
|
+
AriaEngine: AriaPolicyEngine,
|
|
1695
|
+
htmlAriaRules: HTML_ARIA_RULES,
|
|
1696
|
+
htmlPropNormalizersFn: getHtmlPropNormalizers
|
|
1697
|
+
};
|
|
1649
1698
|
function createPolymorphic2(options = {}) {
|
|
1650
1699
|
return createPolymorphic(options, FULL_CAPABILITIES);
|
|
1651
1700
|
}
|
|
@@ -1783,9 +1832,11 @@ function render({
|
|
|
1783
1832
|
const known = knownRaw;
|
|
1784
1833
|
const tag = createMemo(() => resolveTag2(runtime, known.as));
|
|
1785
1834
|
const mergedProps = createMemo(() => runtime.resolveProps(rest));
|
|
1786
|
-
const normalizedProps = createMemo(
|
|
1787
|
-
|
|
1788
|
-
|
|
1835
|
+
const normalizedProps = createMemo(() => {
|
|
1836
|
+
const base = runtime.options.normalizeFn ? runtime.options.normalizeFn(mergedProps()) : mergedProps();
|
|
1837
|
+
const htmlNormalizers = runtime.options.htmlPropNormalizersFn?.(tag());
|
|
1838
|
+
return htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), base) : base;
|
|
1839
|
+
});
|
|
1789
1840
|
const resolvedClass = createMemo(
|
|
1790
1841
|
() => runtime.resolveClasses(
|
|
1791
1842
|
tag(),
|
|
@@ -1831,7 +1882,5 @@ function defineContractComponent(options) {
|
|
|
1831
1882
|
}
|
|
1832
1883
|
export {
|
|
1833
1884
|
createContractComponent,
|
|
1834
|
-
defineContractComponent
|
|
1835
|
-
disabledProps,
|
|
1836
|
-
invalidProps
|
|
1885
|
+
defineContractComponent
|
|
1837
1886
|
};
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -229,6 +229,7 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
229
229
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
230
230
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
231
231
|
}['normalize'];
|
|
232
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
|
|
232
233
|
type FactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<V> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType> = {
|
|
233
234
|
readonly tag?: TDefault;
|
|
234
235
|
readonly name?: string;
|
|
@@ -251,6 +252,7 @@ type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props ex
|
|
|
251
252
|
readonly strict: StrictMode;
|
|
252
253
|
readonly variantKeys: ReadonlySet<string>;
|
|
253
254
|
readonly normalizeFn?: NormalizeFn<Props>;
|
|
255
|
+
readonly htmlPropNormalizersFn?: (tag: unknown) => readonly PropNormalizer[] | undefined;
|
|
254
256
|
readonly childRules?: readonly ChildRuleInput[];
|
|
255
257
|
readonly ariaRules?: readonly AriaRule[];
|
|
256
258
|
readonly allowedAs?: readonly ElementType[];
|
|
@@ -294,10 +296,6 @@ declare class ChildrenEvaluator extends StrictBase {
|
|
|
294
296
|
evaluate(children: unknown[]): void;
|
|
295
297
|
}
|
|
296
298
|
|
|
297
|
-
declare const disabledProps: PropNormalizer;
|
|
298
|
-
|
|
299
|
-
declare const invalidProps: PropNormalizer;
|
|
300
|
-
|
|
301
299
|
declare function createPolymorphic<TDefault extends ElementType, Props extends AnyRecord, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>>(options?: FactoryOptions<TDefault, Props, Variants, TPreset>): PolymorphicRuntime<TDefault, Props, Variants, Extract<keyof TPreset, string>, TPreset>;
|
|
302
300
|
|
|
303
301
|
declare class SlotValidator extends StrictBase {
|
|
@@ -340,4 +338,4 @@ declare function createContractComponent<TDefault extends ElementType, Props ext
|
|
|
340
338
|
|
|
341
339
|
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
342
340
|
|
|
343
|
-
export { type BuiltRuntime, type ElementType, type EmptyRecord, type FilterPredicate, type PolymorphicGenerics, type SvelteFactoryOptions, type UnknownProps, type WithChildRules, createContractComponent, defineContractComponent
|
|
341
|
+
export { type AnyFactoryOptions, type BuiltRuntime, type ElementType, type EmptyRecord, type FilterPredicate, type PolymorphicGenerics, type SvelteFactoryOptions, type UnknownProps, type WithChildRules, createContractComponent, defineContractComponent };
|