praxis-kit 1.1.0 → 2.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/README.md +196 -0
- package/dist/{chunk-KDUNVQK2.js → chunk-ACAKUHH5.js} +531 -386
- package/dist/contract/index.d.ts +130 -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 +3 -3
- 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 +6 -2
package/dist/lit/index.d.ts
CHANGED
|
@@ -216,6 +216,7 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
216
216
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
217
217
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
218
218
|
}['normalize'];
|
|
219
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
|
|
219
220
|
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> = {
|
|
220
221
|
readonly tag?: TDefault;
|
|
221
222
|
readonly name?: string;
|
|
@@ -301,4 +302,4 @@ declare function defineContractComponent<O extends FactoryOptions>(options: O):
|
|
|
301
302
|
*/
|
|
302
303
|
declare function renderToString(component: LitContractComponent, props?: UnknownProps, innerHTML?: string): string;
|
|
303
304
|
|
|
304
|
-
export { type LitContractComponent, type LitFactoryOptions, createContractComponent, defineContractComponent, renderToString };
|
|
305
|
+
export { type AnyFactoryOptions, type LitContractComponent, type LitFactoryOptions, createContractComponent, defineContractComponent, renderToString };
|
package/dist/lit/index.js
CHANGED
|
@@ -12,7 +12,7 @@ function applyFilter(props, filterProps, variantKeys) {
|
|
|
12
12
|
return out;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
// ../core/dist/chunk-
|
|
15
|
+
// ../core/dist/chunk-XFCAUPVZ.js
|
|
16
16
|
function makeResolveTag(defaultTag) {
|
|
17
17
|
return function tag(as) {
|
|
18
18
|
return as ?? defaultTag;
|
|
@@ -247,7 +247,11 @@ function createRuntimeObject(methods, resolved, pluginResult) {
|
|
|
247
247
|
return pluginResult ? { ...methods, options: resolved, hasStyling: true, classPlugin: pluginResult } : { ...methods, options: resolved };
|
|
248
248
|
}
|
|
249
249
|
function createPolymorphic(options = {}, capabilities) {
|
|
250
|
-
const
|
|
250
|
+
const baseResolved = resolveFactoryOptions(options);
|
|
251
|
+
const resolved = capabilities?.htmlPropNormalizersFn !== void 0 ? Object.freeze({
|
|
252
|
+
...baseResolved,
|
|
253
|
+
htmlPropNormalizersFn: capabilities.htmlPropNormalizersFn
|
|
254
|
+
}) : baseResolved;
|
|
251
255
|
if (process.env.NODE_ENV !== "production") validateFactoryOptions(resolved);
|
|
252
256
|
const { pluginResult, classPipeline } = resolveClassPipeline(
|
|
253
257
|
options,
|
|
@@ -255,9 +259,12 @@ function createPolymorphic(options = {}, capabilities) {
|
|
|
255
259
|
resolved.strict,
|
|
256
260
|
capabilities
|
|
257
261
|
);
|
|
262
|
+
const allAriaRules = [
|
|
263
|
+
.../* @__PURE__ */ new Set([...capabilities?.htmlAriaRules ?? [], ...resolved.ariaRules ?? []])
|
|
264
|
+
];
|
|
258
265
|
const engine = options.enforcement !== void 0 && capabilities?.AriaEngine ? new capabilities.AriaEngine(
|
|
259
266
|
resolved.strict,
|
|
260
|
-
|
|
267
|
+
allAriaRules.length ? { rules: allAriaRules } : void 0
|
|
261
268
|
) : null;
|
|
262
269
|
const methods = createRuntimeMethods(resolved, classPipeline, engine);
|
|
263
270
|
return createRuntimeObject(
|
|
@@ -573,184 +580,7 @@ function isStandaloneTag(tag) {
|
|
|
573
580
|
return STANDALONE_ROLES_SET.has(IMPLICIT_ROLE_RECORD[tag]);
|
|
574
581
|
}
|
|
575
582
|
|
|
576
|
-
// ../core/dist/chunk-
|
|
577
|
-
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
578
|
-
function resolveChildTag(child) {
|
|
579
|
-
if (!isObject(child) || !("type" in child)) return void 0;
|
|
580
|
-
const t = child.type;
|
|
581
|
-
if (isString(t)) return t;
|
|
582
|
-
if (isObject(t) && COMPONENT_DEFAULT_TAG in t) {
|
|
583
|
-
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
584
|
-
if (!isString(defaultTag)) return void 0;
|
|
585
|
-
const props = child.props;
|
|
586
|
-
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
587
|
-
return isString(as) ? as : defaultTag;
|
|
588
|
-
}
|
|
589
|
-
return void 0;
|
|
590
|
-
}
|
|
591
|
-
function isTag(...tags) {
|
|
592
|
-
const set = new Set(tags);
|
|
593
|
-
return (child) => {
|
|
594
|
-
const tag = resolveChildTag(child);
|
|
595
|
-
return tag !== void 0 && set.has(tag);
|
|
596
|
-
};
|
|
597
|
-
}
|
|
598
|
-
function isOpenContent(...blockedTags) {
|
|
599
|
-
const set = new Set(blockedTags);
|
|
600
|
-
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
|
|
601
|
-
}
|
|
602
|
-
var METADATA_TAGS = ["script", "template"];
|
|
603
|
-
var metadataMatch = isTag(...METADATA_TAGS);
|
|
604
|
-
function metadata(name = "metadata") {
|
|
605
|
-
return { name, match: metadataMatch };
|
|
606
|
-
}
|
|
607
|
-
function firstOptional(name, tag) {
|
|
608
|
-
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
609
|
-
}
|
|
610
|
-
function contract(children) {
|
|
611
|
-
return { strict: "warn", children };
|
|
612
|
-
}
|
|
613
|
-
function ariaContract(aria) {
|
|
614
|
-
return { strict: "warn", aria };
|
|
615
|
-
}
|
|
616
|
-
function firstChildContract(name, tag) {
|
|
617
|
-
return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
|
|
618
|
-
}
|
|
619
|
-
var VOID_TAGS = [
|
|
620
|
-
"area",
|
|
621
|
-
"base",
|
|
622
|
-
"br",
|
|
623
|
-
"col",
|
|
624
|
-
"embed",
|
|
625
|
-
"hr",
|
|
626
|
-
"img",
|
|
627
|
-
"input",
|
|
628
|
-
"link",
|
|
629
|
-
"meta",
|
|
630
|
-
"param",
|
|
631
|
-
"source",
|
|
632
|
-
"track",
|
|
633
|
-
"wbr"
|
|
634
|
-
];
|
|
635
|
-
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
636
|
-
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
637
|
-
var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
|
|
638
|
-
var tableContract = contract([
|
|
639
|
-
firstOptional("caption", "caption"),
|
|
640
|
-
{ name: "colgroup", match: isTag("colgroup") },
|
|
641
|
-
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
642
|
-
{ name: "tbody", match: isTag("tbody") },
|
|
643
|
-
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
644
|
-
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
645
|
-
]);
|
|
646
|
-
var tableBodyContract = contract([
|
|
647
|
-
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
648
|
-
]);
|
|
649
|
-
var tableRowContract = contract([
|
|
650
|
-
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
651
|
-
]);
|
|
652
|
-
var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
|
|
653
|
-
var dlContract = contract([
|
|
654
|
-
{ name: "term", match: isTag("dt") },
|
|
655
|
-
{ name: "description", match: isTag("dd") },
|
|
656
|
-
{ name: "group", match: isTag("div") },
|
|
657
|
-
metadata()
|
|
658
|
-
]);
|
|
659
|
-
var selectContract = contract([
|
|
660
|
-
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
661
|
-
]);
|
|
662
|
-
var optgroupContract = contract([
|
|
663
|
-
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
664
|
-
]);
|
|
665
|
-
var datalistContract = contract([
|
|
666
|
-
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
667
|
-
]);
|
|
668
|
-
var pictureContract = contract([
|
|
669
|
-
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
670
|
-
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
671
|
-
]);
|
|
672
|
-
var figureContract = contract([
|
|
673
|
-
{ name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
|
|
674
|
-
{ name: "content", match: isOpenContent("figcaption") }
|
|
675
|
-
]);
|
|
676
|
-
var detailsContract = firstChildContract("summary", "summary");
|
|
677
|
-
var fieldsetContract = firstChildContract("legend", "legend");
|
|
678
|
-
var mediaContract = contract([
|
|
679
|
-
{ name: "source", match: isTag("source") },
|
|
680
|
-
{ name: "track", match: isTag("track") },
|
|
681
|
-
metadata(),
|
|
682
|
-
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
683
|
-
]);
|
|
684
|
-
var headContract = contract([
|
|
685
|
-
{
|
|
686
|
-
name: "metadata",
|
|
687
|
-
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
688
|
-
}
|
|
689
|
-
]);
|
|
690
|
-
var htmlContract = contract([
|
|
691
|
-
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
692
|
-
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
693
|
-
]);
|
|
694
|
-
var voidContract = contract([]);
|
|
695
|
-
var textOnlyContract = contract([
|
|
696
|
-
{
|
|
697
|
-
name: "text",
|
|
698
|
-
match: (child) => isString(child) || isNumber(child)
|
|
699
|
-
}
|
|
700
|
-
]);
|
|
701
|
-
var LANDMARK_TAG_SET = new Set(LANDMARK_TAGS);
|
|
702
|
-
var removeLandmarkRoleOverride = {
|
|
703
|
-
kind: "removeRole",
|
|
704
|
-
apply: ({ props }) => {
|
|
705
|
-
if (!("role" in props)) return { applied: false, next: props };
|
|
706
|
-
const { role: _r, ...rest } = props;
|
|
707
|
-
return { applied: true, next: rest, previous: props };
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
function landmarkRoleRule({ tag, props, implicitRole }) {
|
|
711
|
-
if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
|
|
712
|
-
const role = props.role;
|
|
713
|
-
if (!role || role === implicitRole) return [];
|
|
714
|
-
return [
|
|
715
|
-
{
|
|
716
|
-
valid: false,
|
|
717
|
-
fixable: true,
|
|
718
|
-
severity: "error",
|
|
719
|
-
fix: removeLandmarkRoleOverride,
|
|
720
|
-
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
721
|
-
}
|
|
722
|
-
];
|
|
723
|
-
}
|
|
724
|
-
var landmarkContract = ariaContract([landmarkRoleRule]);
|
|
725
|
-
var CONTRACT_GROUPS = [
|
|
726
|
-
[VOID_TAGS, voidContract],
|
|
727
|
-
[TEXT_ONLY_TAGS, textOnlyContract],
|
|
728
|
-
[LANDMARK_TAGS, landmarkContract],
|
|
729
|
-
[["ul", "ol", "menu"], listContract],
|
|
730
|
-
[["audio", "video"], mediaContract],
|
|
731
|
-
[["thead", "tbody", "tfoot"], tableBodyContract]
|
|
732
|
-
];
|
|
733
|
-
function contractMap(groups) {
|
|
734
|
-
return Object.fromEntries(
|
|
735
|
-
groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
|
|
736
|
-
);
|
|
737
|
-
}
|
|
738
|
-
var htmlContracts = {
|
|
739
|
-
...contractMap(CONTRACT_GROUPS),
|
|
740
|
-
table: tableContract,
|
|
741
|
-
tr: tableRowContract,
|
|
742
|
-
colgroup: colgroupContract,
|
|
743
|
-
dl: dlContract,
|
|
744
|
-
select: selectContract,
|
|
745
|
-
optgroup: optgroupContract,
|
|
746
|
-
datalist: datalistContract,
|
|
747
|
-
picture: pictureContract,
|
|
748
|
-
figure: figureContract,
|
|
749
|
-
details: detailsContract,
|
|
750
|
-
fieldset: fieldsetContract,
|
|
751
|
-
head: headContract,
|
|
752
|
-
html: htmlContract
|
|
753
|
-
};
|
|
583
|
+
// ../core/dist/chunk-VU44HAB7.js
|
|
754
584
|
var IMPLICIT_ROLE_RECORD2 = {
|
|
755
585
|
article: "article",
|
|
756
586
|
aside: "complementary",
|
|
@@ -779,6 +609,27 @@ function getImplicitRole(tag) {
|
|
|
779
609
|
if (tag in IMPLICIT_ROLE_RECORD2) return IMPLICIT_ROLE_RECORD2[tag];
|
|
780
610
|
return void 0;
|
|
781
611
|
}
|
|
612
|
+
var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol("praxis.component-default-tag");
|
|
613
|
+
function resolveChildTag(child) {
|
|
614
|
+
if (!isObject(child) || !("type" in child)) return void 0;
|
|
615
|
+
const t = child.type;
|
|
616
|
+
if (isString(t)) return t;
|
|
617
|
+
if (isObject(t) && COMPONENT_DEFAULT_TAG in t) {
|
|
618
|
+
const defaultTag = t[COMPONENT_DEFAULT_TAG];
|
|
619
|
+
if (!isString(defaultTag)) return void 0;
|
|
620
|
+
const props = child.props;
|
|
621
|
+
const as = isObject(props) && "as" in props ? props.as : void 0;
|
|
622
|
+
return isString(as) ? as : defaultTag;
|
|
623
|
+
}
|
|
624
|
+
return void 0;
|
|
625
|
+
}
|
|
626
|
+
function isTag(...tags) {
|
|
627
|
+
const set = new Set(tags);
|
|
628
|
+
return (child) => {
|
|
629
|
+
const tag = resolveChildTag(child);
|
|
630
|
+
return tag !== void 0 && set.has(tag);
|
|
631
|
+
};
|
|
632
|
+
}
|
|
782
633
|
var pendingAsyncWarns2 = /* @__PURE__ */ new Set();
|
|
783
634
|
var asyncWarnScheduled2 = false;
|
|
784
635
|
function flushAsyncWarns2() {
|
|
@@ -1448,8 +1299,223 @@ var ChildrenEvaluator = class extends StrictBase {
|
|
|
1448
1299
|
this.invariant(errors.length === 0, this.#matchBuilder.toError(errors).message);
|
|
1449
1300
|
}
|
|
1450
1301
|
};
|
|
1302
|
+
var disabledProps = ({
|
|
1303
|
+
disabled,
|
|
1304
|
+
"aria-disabled": ariaDisabled,
|
|
1305
|
+
"data-disabled": dataDisabled
|
|
1306
|
+
}) => {
|
|
1307
|
+
if (!disabled) return {};
|
|
1308
|
+
return {
|
|
1309
|
+
...ariaDisabled === void 0 && { "aria-disabled": "true" },
|
|
1310
|
+
...dataDisabled === void 0 && { "data-disabled": "" }
|
|
1311
|
+
};
|
|
1312
|
+
};
|
|
1313
|
+
var invalidProps = ({
|
|
1314
|
+
invalid,
|
|
1315
|
+
"aria-invalid": ariaInvalid,
|
|
1316
|
+
"data-invalid": dataInvalid
|
|
1317
|
+
}) => {
|
|
1318
|
+
if (!invalid) return {};
|
|
1319
|
+
return {
|
|
1320
|
+
...ariaInvalid === void 0 && { "aria-invalid": "true" },
|
|
1321
|
+
...dataInvalid === void 0 && { "data-invalid": "" }
|
|
1322
|
+
};
|
|
1323
|
+
};
|
|
1324
|
+
var readonlyProps = ({
|
|
1325
|
+
readOnly,
|
|
1326
|
+
"aria-readonly": ariaReadonly,
|
|
1327
|
+
"data-readonly": dataReadonly
|
|
1328
|
+
}) => {
|
|
1329
|
+
if (!readOnly) return {};
|
|
1330
|
+
return {
|
|
1331
|
+
...ariaReadonly === void 0 && {
|
|
1332
|
+
"aria-readonly": "true"
|
|
1333
|
+
},
|
|
1334
|
+
...dataReadonly === void 0 && {
|
|
1335
|
+
"data-readonly": ""
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
};
|
|
1339
|
+
var LANDMARK_TAG_SET = /* @__PURE__ */ new Set(["article", "aside", "footer", "header", "main", "nav"]);
|
|
1340
|
+
var removeLandmarkRoleOverride = {
|
|
1341
|
+
kind: "removeRole",
|
|
1342
|
+
apply: ({ props }) => {
|
|
1343
|
+
if (!("role" in props)) return { applied: false, next: props };
|
|
1344
|
+
const { role: _r, ...rest } = props;
|
|
1345
|
+
return { applied: true, next: rest, previous: props };
|
|
1346
|
+
}
|
|
1347
|
+
};
|
|
1348
|
+
function landmarkRoleRule({ tag, props, implicitRole }) {
|
|
1349
|
+
if (!LANDMARK_TAG_SET.has(tag) || !implicitRole) return [];
|
|
1350
|
+
const role = props.role;
|
|
1351
|
+
if (!role || role === implicitRole) return [];
|
|
1352
|
+
return [
|
|
1353
|
+
{
|
|
1354
|
+
valid: false,
|
|
1355
|
+
fixable: true,
|
|
1356
|
+
severity: "error",
|
|
1357
|
+
fix: removeLandmarkRoleOverride,
|
|
1358
|
+
message: `<${tag}> has a fixed landmark role="${implicitRole}". role="${role}" overrides it and confuses assistive technology. The override has been removed.`
|
|
1359
|
+
}
|
|
1360
|
+
];
|
|
1361
|
+
}
|
|
1362
|
+
var HTML_ARIA_RULES = [landmarkRoleRule];
|
|
1363
|
+
function isOpenContent(...blockedTags) {
|
|
1364
|
+
const set = new Set(blockedTags);
|
|
1365
|
+
return (child) => isObject(child) && "type" in child && (!isString(child.type) || !set.has(child.type));
|
|
1366
|
+
}
|
|
1367
|
+
var METADATA_TAGS = ["script", "template"];
|
|
1368
|
+
var metadataMatch = isTag(...METADATA_TAGS);
|
|
1369
|
+
function metadata(name = "metadata") {
|
|
1370
|
+
return { name, match: metadataMatch };
|
|
1371
|
+
}
|
|
1372
|
+
function firstOptional(name, tag) {
|
|
1373
|
+
return { name, match: isTag(tag), cardinality: { max: 1 }, position: "first" };
|
|
1374
|
+
}
|
|
1375
|
+
function contract(children) {
|
|
1376
|
+
return { strict: "warn", children };
|
|
1377
|
+
}
|
|
1378
|
+
function ariaContract(aria) {
|
|
1379
|
+
return { strict: "warn", aria };
|
|
1380
|
+
}
|
|
1381
|
+
function firstChildContract(name, tag) {
|
|
1382
|
+
return contract([firstOptional(name, tag), { name: "content", match: isOpenContent(tag) }]);
|
|
1383
|
+
}
|
|
1384
|
+
var VOID_TAGS = [
|
|
1385
|
+
"area",
|
|
1386
|
+
"base",
|
|
1387
|
+
"br",
|
|
1388
|
+
"col",
|
|
1389
|
+
"embed",
|
|
1390
|
+
"hr",
|
|
1391
|
+
"img",
|
|
1392
|
+
"input",
|
|
1393
|
+
"link",
|
|
1394
|
+
"meta",
|
|
1395
|
+
"param",
|
|
1396
|
+
"source",
|
|
1397
|
+
"track",
|
|
1398
|
+
"wbr"
|
|
1399
|
+
];
|
|
1400
|
+
var TEXT_ONLY_TAGS = ["option", "script", "style", "textarea", "title"];
|
|
1401
|
+
var LANDMARK_TAGS = ["article", "aside", "footer", "header", "main", "nav"];
|
|
1402
|
+
var listContract = contract([{ name: "list-item", match: isTag("li", ...METADATA_TAGS) }]);
|
|
1403
|
+
var tableContract = contract([
|
|
1404
|
+
firstOptional("caption", "caption"),
|
|
1405
|
+
{ name: "colgroup", match: isTag("colgroup") },
|
|
1406
|
+
{ name: "thead", match: isTag("thead"), cardinality: { max: 1 } },
|
|
1407
|
+
{ name: "tbody", match: isTag("tbody") },
|
|
1408
|
+
{ name: "tfoot", match: isTag("tfoot"), cardinality: { max: 1 } },
|
|
1409
|
+
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1410
|
+
]);
|
|
1411
|
+
var tableBodyContract = contract([
|
|
1412
|
+
{ name: "table-row", match: isTag("tr", ...METADATA_TAGS) }
|
|
1413
|
+
]);
|
|
1414
|
+
var tableRowContract = contract([
|
|
1415
|
+
{ name: "table-cell", match: isTag("td", "th", ...METADATA_TAGS) }
|
|
1416
|
+
]);
|
|
1417
|
+
var colgroupContract = contract([{ name: "column", match: isTag("col", "template") }]);
|
|
1418
|
+
var dlContract = contract([
|
|
1419
|
+
{ name: "term", match: isTag("dt") },
|
|
1420
|
+
{ name: "description", match: isTag("dd") },
|
|
1421
|
+
{ name: "group", match: isTag("div") },
|
|
1422
|
+
metadata()
|
|
1423
|
+
]);
|
|
1424
|
+
var selectContract = contract([
|
|
1425
|
+
{ name: "option", match: isTag("option", "optgroup", "hr", ...METADATA_TAGS) }
|
|
1426
|
+
]);
|
|
1427
|
+
var optgroupContract = contract([
|
|
1428
|
+
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1429
|
+
]);
|
|
1430
|
+
var datalistContract = contract([
|
|
1431
|
+
{ name: "option", match: isTag("option", ...METADATA_TAGS) }
|
|
1432
|
+
]);
|
|
1433
|
+
var pictureContract = contract([
|
|
1434
|
+
{ name: "source", match: isTag("source", ...METADATA_TAGS) },
|
|
1435
|
+
{ name: "image", match: isTag("img"), cardinality: { min: 1, max: 1 }, position: "last" }
|
|
1436
|
+
]);
|
|
1437
|
+
var figureContract = contract([
|
|
1438
|
+
{ name: "caption", match: isTag("figcaption"), cardinality: { max: 1 } },
|
|
1439
|
+
{ name: "content", match: isOpenContent("figcaption") }
|
|
1440
|
+
]);
|
|
1441
|
+
var detailsContract = firstChildContract("summary", "summary");
|
|
1442
|
+
var fieldsetContract = firstChildContract("legend", "legend");
|
|
1443
|
+
var mediaContract = contract([
|
|
1444
|
+
{ name: "source", match: isTag("source") },
|
|
1445
|
+
{ name: "track", match: isTag("track") },
|
|
1446
|
+
metadata(),
|
|
1447
|
+
{ name: "content", match: isOpenContent("source", "track", ...METADATA_TAGS) }
|
|
1448
|
+
]);
|
|
1449
|
+
var headContract = contract([
|
|
1450
|
+
{
|
|
1451
|
+
name: "metadata",
|
|
1452
|
+
match: isTag("base", "link", "meta", "noscript", "script", "style", "template", "title")
|
|
1453
|
+
}
|
|
1454
|
+
]);
|
|
1455
|
+
var htmlContract = contract([
|
|
1456
|
+
{ name: "head", match: isTag("head"), cardinality: { min: 1, max: 1 }, position: "first" },
|
|
1457
|
+
{ name: "body", match: isTag("body"), cardinality: { min: 1, max: 1 } }
|
|
1458
|
+
]);
|
|
1459
|
+
var voidContract = contract([]);
|
|
1460
|
+
var textOnlyContract = contract([
|
|
1461
|
+
{
|
|
1462
|
+
name: "text",
|
|
1463
|
+
match: (child) => isString(child) || isNumber(child)
|
|
1464
|
+
}
|
|
1465
|
+
]);
|
|
1466
|
+
var landmarkContract = ariaContract([landmarkRoleRule]);
|
|
1467
|
+
var CONTRACT_GROUPS = [
|
|
1468
|
+
[VOID_TAGS, voidContract],
|
|
1469
|
+
[TEXT_ONLY_TAGS, textOnlyContract],
|
|
1470
|
+
[LANDMARK_TAGS, landmarkContract],
|
|
1471
|
+
[["ul", "ol", "menu"], listContract],
|
|
1472
|
+
[["audio", "video"], mediaContract],
|
|
1473
|
+
[["thead", "tbody", "tfoot"], tableBodyContract]
|
|
1474
|
+
];
|
|
1475
|
+
function contractMap(groups) {
|
|
1476
|
+
return Object.fromEntries(
|
|
1477
|
+
groups.flatMap(([tags, enforcement]) => tags.map((tag) => [tag, enforcement]))
|
|
1478
|
+
);
|
|
1479
|
+
}
|
|
1480
|
+
var htmlContracts = {
|
|
1481
|
+
...contractMap(CONTRACT_GROUPS),
|
|
1482
|
+
table: tableContract,
|
|
1483
|
+
tr: tableRowContract,
|
|
1484
|
+
colgroup: colgroupContract,
|
|
1485
|
+
dl: dlContract,
|
|
1486
|
+
select: selectContract,
|
|
1487
|
+
optgroup: optgroupContract,
|
|
1488
|
+
datalist: datalistContract,
|
|
1489
|
+
picture: pictureContract,
|
|
1490
|
+
figure: figureContract,
|
|
1491
|
+
details: detailsContract,
|
|
1492
|
+
fieldset: fieldsetContract,
|
|
1493
|
+
head: headContract,
|
|
1494
|
+
html: htmlContract
|
|
1495
|
+
};
|
|
1496
|
+
function buildEvaluatorMap() {
|
|
1497
|
+
const map = /* @__PURE__ */ new Map();
|
|
1498
|
+
for (const [tag, { children }] of Object.entries(htmlContracts)) {
|
|
1499
|
+
if (children?.length) {
|
|
1500
|
+
map.set(tag, new ChildrenEvaluator(children, "warn", `<${tag}>`));
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
return map;
|
|
1504
|
+
}
|
|
1505
|
+
var HTML_EVALUATORS = buildEvaluatorMap();
|
|
1506
|
+
var HTML_FORM_NORMALIZERS = /* @__PURE__ */ new Map([
|
|
1507
|
+
["button", [disabledProps]],
|
|
1508
|
+
["input", [disabledProps, readonlyProps, invalidProps]],
|
|
1509
|
+
["select", [disabledProps]],
|
|
1510
|
+
["textarea", [disabledProps, readonlyProps]],
|
|
1511
|
+
["fieldset", [disabledProps]],
|
|
1512
|
+
["optgroup", [disabledProps]]
|
|
1513
|
+
]);
|
|
1514
|
+
function getHtmlPropNormalizers(tag) {
|
|
1515
|
+
return typeof tag === "string" ? HTML_FORM_NORMALIZERS.get(tag) : void 0;
|
|
1516
|
+
}
|
|
1451
1517
|
|
|
1452
|
-
// ../core/dist/chunk-
|
|
1518
|
+
// ../core/dist/chunk-EHCOMLJ4.js
|
|
1453
1519
|
var falsyToString = (value) => typeof value === "boolean" ? `${value}` : value === 0 ? "0" : value;
|
|
1454
1520
|
var cx = clsx;
|
|
1455
1521
|
var cva = (base, config) => (props) => {
|
|
@@ -1615,7 +1681,12 @@ function createClassPipeline(resolved) {
|
|
|
1615
1681
|
}
|
|
1616
1682
|
|
|
1617
1683
|
// ../core/dist/index.js
|
|
1618
|
-
var FULL_CAPABILITIES = {
|
|
1684
|
+
var FULL_CAPABILITIES = {
|
|
1685
|
+
createClassPipeline,
|
|
1686
|
+
AriaEngine: AriaPolicyEngine,
|
|
1687
|
+
htmlAriaRules: HTML_ARIA_RULES,
|
|
1688
|
+
htmlPropNormalizersFn: getHtmlPropNormalizers
|
|
1689
|
+
};
|
|
1619
1690
|
function createPolymorphic2(options = {}) {
|
|
1620
1691
|
return createPolymorphic(options, FULL_CAPABILITIES);
|
|
1621
1692
|
}
|
|
@@ -1752,7 +1823,9 @@ function resolveHostState(bundle, props) {
|
|
|
1752
1823
|
const { as, className, variantKey, ...rest } = props;
|
|
1753
1824
|
const tag = bundle.runtime.resolveTag(as);
|
|
1754
1825
|
const mergedProps = bundle.runtime.resolveProps(rest);
|
|
1755
|
-
const
|
|
1826
|
+
const baseProps = bundle.runtime.options.normalizeFn ? bundle.runtime.options.normalizeFn(mergedProps) : mergedProps;
|
|
1827
|
+
const htmlNormalizers = bundle.runtime.options.htmlPropNormalizersFn?.(tag);
|
|
1828
|
+
const normalizedProps = htmlNormalizers?.length ? htmlNormalizers.reduce((acc, fn) => ({ ...acc, ...fn(acc) }), baseProps) : baseProps;
|
|
1756
1829
|
const resolvedClass = bundle.runtime.resolveClasses(
|
|
1757
1830
|
tag,
|
|
1758
1831
|
normalizedProps,
|
|
@@ -227,6 +227,7 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
227
227
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
228
228
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
229
229
|
}['normalize'];
|
|
230
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
|
|
230
231
|
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> = {
|
|
231
232
|
readonly tag?: TDefault;
|
|
232
233
|
readonly name?: string;
|
|
@@ -236,10 +237,6 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
236
237
|
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
237
238
|
};
|
|
238
239
|
|
|
239
|
-
declare const disabledProps: PropNormalizer;
|
|
240
|
-
|
|
241
|
-
declare const invalidProps: PropNormalizer;
|
|
242
|
-
|
|
243
240
|
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
244
241
|
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
245
242
|
|
|
@@ -371,4 +368,4 @@ type PolymorphicComponent<G extends PolymorphicGenerics> = {
|
|
|
371
368
|
|
|
372
369
|
declare function mergeRefs<T>(...refs: (Ref<T> | null | undefined)[]): Ref<T> | null;
|
|
373
370
|
|
|
374
|
-
export { type AnyRecord as A, type ElementType as E, type FactoryOptions as F, type PresetMap as P, type ReactFactoryOptions as R, Slottable as S, type UnknownProps as U, type VariantMap as V, type EmptyRecord as a, type PolymorphicComponent as b, type PolymorphicGenerics as c, type
|
|
371
|
+
export { type AnyRecord as A, type ElementType as E, type FactoryOptions as F, type PresetMap as P, type ReactFactoryOptions as R, Slottable as S, type UnknownProps as U, type VariantMap as V, type EmptyRecord as a, type PolymorphicComponent as b, type PolymorphicGenerics as c, type AnyFactoryOptions as d, type ElementRef as e, type PolymorphicProps as f, type PolymorphicWithAsChild as g, type PolymorphicWithRender as h, type RenderCallbackProps as i, type SlottableProps as j, mergeRefs as m };
|
package/dist/preact/index.d.ts
CHANGED
|
@@ -226,6 +226,7 @@ type StylingOptions<V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPre
|
|
|
226
226
|
type NormalizeFn<Props extends AnyRecord = AnyRecord> = {
|
|
227
227
|
normalize(props: Readonly<Props & IntrinsicProps>): Props & IntrinsicProps;
|
|
228
228
|
}['normalize'];
|
|
229
|
+
type AnyFactoryOptions = FactoryOptions<ElementType, AnyRecord, VariantMap, PresetMap<VariantMap>, AnyRecord>;
|
|
229
230
|
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> = {
|
|
230
231
|
readonly tag?: TDefault;
|
|
231
232
|
readonly name?: string;
|
|
@@ -235,10 +236,6 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
235
236
|
readonly enforcement?: EnforcementOptions<TAllowed>;
|
|
236
237
|
};
|
|
237
238
|
|
|
238
|
-
declare const disabledProps: PropNormalizer;
|
|
239
|
-
|
|
240
|
-
declare const invalidProps: PropNormalizer;
|
|
241
|
-
|
|
242
239
|
type DefaultOf<T extends PolymorphicGenerics> = T['default'];
|
|
243
240
|
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
244
241
|
|
|
@@ -289,4 +286,4 @@ type SlottableProps = {
|
|
|
289
286
|
};
|
|
290
287
|
declare function Slottable({ children }: SlottableProps): AnyVNode;
|
|
291
288
|
|
|
292
|
-
export { type ElementRef, type PolymorphicComponent, type PolymorphicProps, type PolymorphicWithAsChild, type PreactFactoryOptions, Slottable, createContractComponent, defineContractComponent
|
|
289
|
+
export { type AnyFactoryOptions, type ElementRef, type ElementType, type EmptyRecord, type PolymorphicComponent, type PolymorphicGenerics, type PolymorphicProps, type PolymorphicWithAsChild, type PreactFactoryOptions, Slottable, createContractComponent, defineContractComponent };
|