praxis-kit 6.6.1 → 7.3.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 +1 -0
- package/dist/_shared/diagnostics.js +1 -0
- package/dist/{chunk-6JILZ6GQ.js → chunk-EIKPSL26.js} +126 -40
- package/dist/codemod/index.js +121 -72
- package/dist/contract/index.d.ts +82 -3
- package/dist/contract/index.js +75 -0
- package/dist/eslint/index.js +16 -16
- package/dist/guards/index.d.ts +21 -1
- package/dist/guards/index.js +33 -5
- package/dist/html/index.d.ts +5 -2
- package/dist/html/index.js +17 -14
- package/dist/lit/index.d.ts +34 -3
- package/dist/lit/index.js +143 -43
- package/dist/preact/index.d.ts +34 -3
- package/dist/preact/index.js +167 -65
- package/dist/react/index.d.ts +5 -3
- package/dist/react/index.js +34 -8
- package/dist/react/legacy.d.ts +2 -2
- package/dist/react/legacy.js +17 -3
- package/dist/{react-options-BUBVohU6.d.ts → react-options-DLDsA4Tn.d.ts} +32 -3
- package/dist/solid/index.d.ts +34 -3
- package/dist/solid/index.js +163 -51
- package/dist/svelte/Polymorphic.svelte +15 -1
- package/dist/svelte/index.d.ts +44 -10
- package/dist/svelte/index.js +75 -41
- package/dist/tailwind/index.js +31 -0
- package/dist/ts-plugin/index.cjs +5 -2
- package/dist/vite-plugin/index.d.ts +1 -0
- package/dist/vue/index.d.ts +34 -3
- package/dist/vue/index.js +179 -71
- package/dist/web/index.d.ts +34 -3
- package/dist/web/index.js +154 -47
- package/package.json +8 -8
package/dist/solid/index.js
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
// ../../lib/adapter-utils/src/invariant.ts
|
|
2
|
+
function panic(message) {
|
|
3
|
+
throw new Error(message);
|
|
4
|
+
}
|
|
5
|
+
function invariant(condition, message) {
|
|
6
|
+
if (!condition) panic(message);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// ../../lib/adapter-utils/src/runtime/apply-display-name.ts
|
|
10
|
+
function applyDisplayName(component, name) {
|
|
11
|
+
Object.assign(component, { displayName: name ?? "PolymorphicComponent" });
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ../../lib/adapter-utils/src/runtime/define-component.ts
|
|
15
|
+
function defineContractComponent(options) {
|
|
16
|
+
return (factory) => factory(options);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// ../../lib/adapter-utils/src/runtime/assemble-compound-component.ts
|
|
20
|
+
function assembleCompoundComponent(root, subComponents) {
|
|
21
|
+
if (!subComponents) return root;
|
|
22
|
+
return Object.assign(root, subComponents);
|
|
23
|
+
}
|
|
24
|
+
|
|
1
25
|
// ../../lib/primitive/src/tag/resolve-tag.ts
|
|
2
26
|
function makeResolveTag(defaultTag) {
|
|
3
27
|
return function tag(as) {
|
|
@@ -8,6 +32,11 @@ function makeResolveTag(defaultTag) {
|
|
|
8
32
|
// ../../lib/primitive/src/rule/rule-brand.ts
|
|
9
33
|
var RULE_BRAND = /* @__PURE__ */ Symbol("praxis-kit/dynamic-rule");
|
|
10
34
|
|
|
35
|
+
// ../../lib/primitive/src/rule/dynamic.ts
|
|
36
|
+
function dynamic(resolve) {
|
|
37
|
+
return { [RULE_BRAND]: true, resolve };
|
|
38
|
+
}
|
|
39
|
+
|
|
11
40
|
// ../../lib/primitive/src/guards/foundational/is-defined.ts
|
|
12
41
|
function isUndefined(value) {
|
|
13
42
|
return value === void 0;
|
|
@@ -21,7 +50,7 @@ function isNonNull(value) {
|
|
|
21
50
|
return value != null;
|
|
22
51
|
}
|
|
23
52
|
function isNullish(value) {
|
|
24
|
-
return isNull(value) || value
|
|
53
|
+
return isNull(value) || isUndefined(value);
|
|
25
54
|
}
|
|
26
55
|
|
|
27
56
|
// ../../lib/primitive/src/utils/type-guards.ts
|
|
@@ -35,10 +64,13 @@ function isString(value) {
|
|
|
35
64
|
function isNumber(value) {
|
|
36
65
|
return typeof value === "number";
|
|
37
66
|
}
|
|
67
|
+
function isFunction(value) {
|
|
68
|
+
return typeof value === "function";
|
|
69
|
+
}
|
|
38
70
|
|
|
39
71
|
// ../../lib/primitive/src/rule/is-dynamic-rule.ts
|
|
40
72
|
function isDynamicRule(rule) {
|
|
41
|
-
return isObject(rule, true) && rule
|
|
73
|
+
return isObject(rule, true) && Reflect.get(rule, RULE_BRAND) === true;
|
|
42
74
|
}
|
|
43
75
|
|
|
44
76
|
// ../../lib/primitive/src/rule/resolve-rule.ts
|
|
@@ -598,6 +630,24 @@ var ROLE_RESTRICTED_ATTRIBUTES = /* @__PURE__ */ new Map([
|
|
|
598
630
|
]
|
|
599
631
|
]);
|
|
600
632
|
|
|
633
|
+
// ../../lib/primitive/src/constants/html/void-tags.ts
|
|
634
|
+
var VOID_TAGS = [
|
|
635
|
+
"area",
|
|
636
|
+
"base",
|
|
637
|
+
"br",
|
|
638
|
+
"col",
|
|
639
|
+
"embed",
|
|
640
|
+
"hr",
|
|
641
|
+
"img",
|
|
642
|
+
"input",
|
|
643
|
+
"link",
|
|
644
|
+
"meta",
|
|
645
|
+
"param",
|
|
646
|
+
"source",
|
|
647
|
+
"track",
|
|
648
|
+
"wbr"
|
|
649
|
+
];
|
|
650
|
+
|
|
601
651
|
// ../../lib/primitive/src/guards/aria/is-aria-attribute.ts
|
|
602
652
|
function isGlobalAriaAttribute(attr) {
|
|
603
653
|
return GLOBAL_ARIA_ATTRIBUTES.has(attr);
|
|
@@ -650,17 +700,17 @@ var COMPONENT_DEFAULT_TAG = /* @__PURE__ */ Symbol.for("praxis.component-default
|
|
|
650
700
|
// ../../lib/primitive/src/guards/children/is-tag.ts
|
|
651
701
|
function getAsProp(child) {
|
|
652
702
|
if (!isObject(child) || !("props" in child)) return void 0;
|
|
653
|
-
const props = child
|
|
703
|
+
const { props } = child;
|
|
654
704
|
if (!isObject(props)) return void 0;
|
|
655
|
-
const as = props
|
|
705
|
+
const as = Reflect.get(props, "as");
|
|
656
706
|
return isString(as) && as !== "" ? as : void 0;
|
|
657
707
|
}
|
|
658
708
|
function getTag(child) {
|
|
659
709
|
if (!isObject(child) || !("type" in child)) return void 0;
|
|
660
|
-
const t = child
|
|
710
|
+
const { type: t } = child;
|
|
661
711
|
if (isString(t)) return t;
|
|
662
712
|
if (typeof t === "function" || isObject(t)) {
|
|
663
|
-
const defaultTag = t
|
|
713
|
+
const defaultTag = Reflect.get(t, COMPONENT_DEFAULT_TAG);
|
|
664
714
|
if (!isString(defaultTag)) return void 0;
|
|
665
715
|
return getAsProp(child) ?? defaultTag;
|
|
666
716
|
}
|
|
@@ -680,14 +730,34 @@ function isTag(...args) {
|
|
|
680
730
|
return tag !== void 0 && set2.has(tag);
|
|
681
731
|
}
|
|
682
732
|
|
|
683
|
-
// ../../lib/adapter-utils/src/runtime/
|
|
684
|
-
function
|
|
685
|
-
|
|
733
|
+
// ../../lib/adapter-utils/src/runtime/finalize-component.ts
|
|
734
|
+
function finalizeComponent(component, defaultTag, subComponents) {
|
|
735
|
+
if (typeof defaultTag === "string") {
|
|
736
|
+
Object.assign(component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
|
|
737
|
+
}
|
|
738
|
+
return assembleCompoundComponent(component, subComponents);
|
|
686
739
|
}
|
|
687
740
|
|
|
688
|
-
// ../../lib/adapter-utils/src/runtime/
|
|
689
|
-
|
|
690
|
-
|
|
741
|
+
// ../../lib/adapter-utils/src/runtime/is-factory-options-like.ts
|
|
742
|
+
var FACTORY_OPTIONS_FIELD_VALIDATORS = {
|
|
743
|
+
tag: (v) => v === void 0 || isString(v),
|
|
744
|
+
name: (v) => v === void 0 || isString(v),
|
|
745
|
+
defaults: (v) => v === void 0 || isObject(v),
|
|
746
|
+
normalize: (v) => v === void 0 || isFunction(v),
|
|
747
|
+
styling: (v) => v === void 0 || isObject(v),
|
|
748
|
+
enforcement: (v) => v === void 0 || isObject(v),
|
|
749
|
+
diagnostics: (v) => v === void 0 || isObject(v),
|
|
750
|
+
subComponents: (v) => v === void 0 || isObject(v),
|
|
751
|
+
onElement: (v) => v === void 0 || isFunction(v)
|
|
752
|
+
};
|
|
753
|
+
function isFactoryOptionsLike(options, extraFieldValidators) {
|
|
754
|
+
if (!isObject(options)) return false;
|
|
755
|
+
const validators = { ...FACTORY_OPTIONS_FIELD_VALIDATORS, ...extraFieldValidators };
|
|
756
|
+
for (const [key, value] of Object.entries(options)) {
|
|
757
|
+
const validate = validators[key];
|
|
758
|
+
if (!validate || !validate(value)) return false;
|
|
759
|
+
}
|
|
760
|
+
return true;
|
|
691
761
|
}
|
|
692
762
|
|
|
693
763
|
// ../../lib/contract/src/aria/aria-role-policy.ts
|
|
@@ -1588,7 +1658,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1588
1658
|
const cached = _AriaPolicyEngine.#removeAttributeFixCache.get(attr);
|
|
1589
1659
|
if (cached) return cached;
|
|
1590
1660
|
const fix = {
|
|
1591
|
-
kind:
|
|
1661
|
+
kind: "removeAttribute",
|
|
1662
|
+
attribute: attr,
|
|
1592
1663
|
apply: ({ props }) => {
|
|
1593
1664
|
if (!(attr in props)) return { applied: false, next: props };
|
|
1594
1665
|
return { applied: true, next: omitProp(props, attr), previous: props };
|
|
@@ -1859,7 +1930,8 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1859
1930
|
if (!impliedLive) return NO_VIOLATIONS2;
|
|
1860
1931
|
if ("aria-live" in props) return NO_VIOLATIONS2;
|
|
1861
1932
|
const injectLive = {
|
|
1862
|
-
kind:
|
|
1933
|
+
kind: "injectLive",
|
|
1934
|
+
attribute: "aria-live",
|
|
1863
1935
|
apply: (ctx) => ({
|
|
1864
1936
|
applied: true,
|
|
1865
1937
|
next: { ...ctx.props, "aria-live": impliedLive },
|
|
@@ -1928,6 +2000,23 @@ var AriaPolicyEngine = class _AriaPolicyEngine extends InvariantBase {
|
|
|
1928
2000
|
}
|
|
1929
2001
|
};
|
|
1930
2002
|
|
|
2003
|
+
// ../../lib/contract/src/aria/factories.ts
|
|
2004
|
+
function removeProp(props, key) {
|
|
2005
|
+
const next = { ...props };
|
|
2006
|
+
delete next[key];
|
|
2007
|
+
return next;
|
|
2008
|
+
}
|
|
2009
|
+
function removeAttributeFix(attribute) {
|
|
2010
|
+
return Object.freeze({
|
|
2011
|
+
kind: "removeAttribute",
|
|
2012
|
+
attribute,
|
|
2013
|
+
apply: ({ props }) => {
|
|
2014
|
+
if (!(attribute in props)) return { applied: false, next: props };
|
|
2015
|
+
return { applied: true, next: removeProp(props, attribute), previous: props };
|
|
2016
|
+
}
|
|
2017
|
+
});
|
|
2018
|
+
}
|
|
2019
|
+
|
|
1931
2020
|
// ../../lib/contract/src/children/get-type-name.ts
|
|
1932
2021
|
function getTypeName(value) {
|
|
1933
2022
|
if (value === null) return "null";
|
|
@@ -2246,22 +2335,6 @@ import { warnDiagnostics as warnDiagnostics2 } from "../_shared/diagnostics.js";
|
|
|
2246
2335
|
|
|
2247
2336
|
// ../core/src/html/contracts/categories.ts
|
|
2248
2337
|
var METADATA_TAGS = ["script", "template"];
|
|
2249
|
-
var VOID_TAGS = [
|
|
2250
|
-
"area",
|
|
2251
|
-
"base",
|
|
2252
|
-
"br",
|
|
2253
|
-
"col",
|
|
2254
|
-
"embed",
|
|
2255
|
-
"hr",
|
|
2256
|
-
"img",
|
|
2257
|
-
"input",
|
|
2258
|
-
"link",
|
|
2259
|
-
"meta",
|
|
2260
|
-
"param",
|
|
2261
|
-
"source",
|
|
2262
|
-
"track",
|
|
2263
|
-
"wbr"
|
|
2264
|
-
];
|
|
2265
2338
|
var TEXT_ONLY_TAGS = [
|
|
2266
2339
|
"option",
|
|
2267
2340
|
"script",
|
|
@@ -2385,20 +2458,6 @@ var INPUT_MUTUALLY_EXCLUSIVE_POLICIES = [
|
|
|
2385
2458
|
|
|
2386
2459
|
// ../core/src/html/spec/validators/attribute-type-validator.ts
|
|
2387
2460
|
var DEFAULT_INPUT_TYPE = "text";
|
|
2388
|
-
function omit(props, key) {
|
|
2389
|
-
const next = { ...props };
|
|
2390
|
-
delete next[key];
|
|
2391
|
-
return next;
|
|
2392
|
-
}
|
|
2393
|
-
function removeAttributeFix(attribute) {
|
|
2394
|
-
return {
|
|
2395
|
-
kind: `removeAttribute:${attribute}`,
|
|
2396
|
-
apply: ({ props }) => {
|
|
2397
|
-
if (!(attribute in props)) return { applied: false, next: props };
|
|
2398
|
-
return { applied: true, next: omit(props, attribute), previous: props };
|
|
2399
|
-
}
|
|
2400
|
-
};
|
|
2401
|
-
}
|
|
2402
2461
|
function createInputAttributeTypeRule({
|
|
2403
2462
|
attribute,
|
|
2404
2463
|
allowedTypes
|
|
@@ -2851,7 +2910,7 @@ function getChildProp(child, key) {
|
|
|
2851
2910
|
if (!isVNodeLike(child)) return void 0;
|
|
2852
2911
|
const { props } = child;
|
|
2853
2912
|
if (!isObject(props)) return void 0;
|
|
2854
|
-
return props
|
|
2913
|
+
return Reflect.get(props, key);
|
|
2855
2914
|
}
|
|
2856
2915
|
|
|
2857
2916
|
// ../core/src/html/contracts/aria/landmarks.ts
|
|
@@ -2904,6 +2963,13 @@ function isLabelableControl(child) {
|
|
|
2904
2963
|
const type = getChildProp(child, "type");
|
|
2905
2964
|
return !isString(type) || type !== "hidden";
|
|
2906
2965
|
}
|
|
2966
|
+
function hasAccessibleNameProp(props) {
|
|
2967
|
+
return "aria-label" in props || "aria-labelledby" in props;
|
|
2968
|
+
}
|
|
2969
|
+
function isNonEmptyTextChild(child) {
|
|
2970
|
+
if (isNumber(child)) return true;
|
|
2971
|
+
return isString(child) && child.trim().length > 0;
|
|
2972
|
+
}
|
|
2907
2973
|
var labelContract = contract([
|
|
2908
2974
|
{ name: "control", match: isLabelableControl, cardinality: { max: 1 } },
|
|
2909
2975
|
{ name: "nested-label", match: isTag("label"), cardinality: { max: 0 } },
|
|
@@ -2911,6 +2977,13 @@ var labelContract = contract([
|
|
|
2911
2977
|
name: "other-interactive-content",
|
|
2912
2978
|
match: isTag(...OTHER_INTERACTIVE_TAGS),
|
|
2913
2979
|
cardinality: { max: 0 }
|
|
2980
|
+
},
|
|
2981
|
+
{
|
|
2982
|
+
name: "accessible-name",
|
|
2983
|
+
match: isNonEmptyTextChild,
|
|
2984
|
+
cardinality: dynamic(
|
|
2985
|
+
(ctx) => hasAccessibleNameProp(ctx.props) ? { min: 0 } : { min: 1 }
|
|
2986
|
+
)
|
|
2914
2987
|
}
|
|
2915
2988
|
]);
|
|
2916
2989
|
|
|
@@ -3486,6 +3559,9 @@ function composeFilter(ownedKeys, filterProps) {
|
|
|
3486
3559
|
return (key, variantKeys) => defaultFilter(key, variantKeys) || filterProps(key, variantKeys);
|
|
3487
3560
|
}
|
|
3488
3561
|
|
|
3562
|
+
// ../../adapters/solid/src/create-contract-component.ts
|
|
3563
|
+
import { mergeProps as mergeProps2, onCleanup } from "solid-js";
|
|
3564
|
+
|
|
3489
3565
|
// ../../adapters/solid/src/slot/slot-validator.ts
|
|
3490
3566
|
var SlotValidator = class extends InvariantBase {
|
|
3491
3567
|
#name;
|
|
@@ -3533,6 +3609,13 @@ function buildRuntime(options) {
|
|
|
3533
3609
|
};
|
|
3534
3610
|
}
|
|
3535
3611
|
|
|
3612
|
+
// ../../adapters/solid/src/is-polymorphic-component.ts
|
|
3613
|
+
function isPolymorphicComponent(value) {
|
|
3614
|
+
if (!isFunction(value)) return false;
|
|
3615
|
+
if (!("displayName" in value)) return true;
|
|
3616
|
+
return value.displayName === void 0 || isString(value.displayName);
|
|
3617
|
+
}
|
|
3618
|
+
|
|
3536
3619
|
// ../../adapters/solid/src/render.tsx
|
|
3537
3620
|
import { createComponent as _$createComponent } from "solid-js/web";
|
|
3538
3621
|
import { mergeProps as _$mergeProps } from "solid-js/web";
|
|
@@ -3629,7 +3712,10 @@ function render({
|
|
|
3629
3712
|
}));
|
|
3630
3713
|
}
|
|
3631
3714
|
if (process.env.NODE_ENV !== "production") {
|
|
3632
|
-
createEffect(() => runtime.options.htmlChildrenEvaluatorFn?.(tag())?.evaluate(toChildArray(known.children)
|
|
3715
|
+
createEffect(() => runtime.options.htmlChildrenEvaluatorFn?.(tag())?.evaluate(toChildArray(known.children), {
|
|
3716
|
+
tag: tag(),
|
|
3717
|
+
props: normalizedProps()
|
|
3718
|
+
}));
|
|
3633
3719
|
}
|
|
3634
3720
|
const slotResult = tryRenderAsChild(known, filteredProps, resolvedClass, slotValidator);
|
|
3635
3721
|
if (slotResult !== null) return slotResult;
|
|
@@ -3644,20 +3730,46 @@ function render({
|
|
|
3644
3730
|
}, () => domProps()));
|
|
3645
3731
|
}
|
|
3646
3732
|
|
|
3733
|
+
// ../../adapters/solid/src/to-solid-factory-options.ts
|
|
3734
|
+
var SOLID_FIELD_VALIDATORS = {
|
|
3735
|
+
filterProps: (v) => v === void 0 || isFunction(v)
|
|
3736
|
+
};
|
|
3737
|
+
function isSolidFactoryOptions(options) {
|
|
3738
|
+
return isFactoryOptionsLike(options, SOLID_FIELD_VALIDATORS);
|
|
3739
|
+
}
|
|
3740
|
+
|
|
3647
3741
|
// ../../adapters/solid/src/create-contract-component.ts
|
|
3648
3742
|
function createContractComponent(options) {
|
|
3743
|
+
invariant(isSolidFactoryOptions(options), "options is not a valid SolidFactoryOptions object");
|
|
3649
3744
|
const bundle = buildRuntime(options);
|
|
3745
|
+
const { onElement } = options;
|
|
3650
3746
|
const Component = (props) => {
|
|
3747
|
+
const propsWithRef = onElement ? mergeProps2(props, {
|
|
3748
|
+
get ref() {
|
|
3749
|
+
const consumerRef = props.ref;
|
|
3750
|
+
return (el) => {
|
|
3751
|
+
if (typeof consumerRef === "function") consumerRef(el);
|
|
3752
|
+
const cleanup = onElement(el, () => props);
|
|
3753
|
+
if (cleanup) onCleanup(cleanup);
|
|
3754
|
+
};
|
|
3755
|
+
}
|
|
3756
|
+
}) : props;
|
|
3651
3757
|
return render({
|
|
3652
3758
|
...bundle,
|
|
3653
|
-
props
|
|
3759
|
+
props: propsWithRef
|
|
3654
3760
|
});
|
|
3655
3761
|
};
|
|
3656
3762
|
applyDisplayName(Component, options.name);
|
|
3657
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3763
|
+
const assembled = finalizeComponent(
|
|
3764
|
+
Component,
|
|
3765
|
+
bundle.runtime.options.defaultTag,
|
|
3766
|
+
options.subComponents
|
|
3767
|
+
);
|
|
3768
|
+
invariant(
|
|
3769
|
+
isPolymorphicComponent(assembled),
|
|
3770
|
+
"Generated component failed to satisfy the PolymorphicComponent shape"
|
|
3771
|
+
);
|
|
3772
|
+
return assembled;
|
|
3661
3773
|
}
|
|
3662
3774
|
export {
|
|
3663
3775
|
createContractComponent,
|
|
@@ -130,7 +130,21 @@
|
|
|
130
130
|
if (process.env.NODE_ENV === 'production' || !hostEl) return
|
|
131
131
|
const childArray = Array.from(hostEl.childNodes)
|
|
132
132
|
bundle.childrenEvaluator?.evaluate(childArray, { tag, props: normalizedProps })
|
|
133
|
-
bundle.runtime.options.htmlChildrenEvaluatorFn
|
|
133
|
+
bundle.runtime.options.htmlChildrenEvaluatorFn
|
|
134
|
+
?.(tag)
|
|
135
|
+
?.evaluate(childArray, { tag, props: normalizedProps })
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
const onElement = $derived(bundle.onElement)
|
|
139
|
+
|
|
140
|
+
// Unlike the effect above, this runs in every environment (not dev-only) — onElement is a
|
|
141
|
+
// real runtime feature, not a diagnostic. Re-runs (cleaning up the previous call first, via
|
|
142
|
+
// the returned teardown) whenever hostEl changes identity, e.g. the resolved tag changes and
|
|
143
|
+
// Svelte mounts a new host element.
|
|
144
|
+
$effect(() => {
|
|
145
|
+
if (!hostEl) return
|
|
146
|
+
const cleanup = onElement?.(hostEl, () => normalizedProps)
|
|
147
|
+
return () => cleanup?.()
|
|
134
148
|
})
|
|
135
149
|
}
|
|
136
150
|
</script>
|
package/dist/svelte/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import { Diagnostics, DiagnosticInput, DiagnosticsMode } from '../_shared/diagno
|
|
|
4
4
|
type StringMap<T = unknown> = Record<string, T>;
|
|
5
5
|
type AnyRecord = StringMap<unknown>;
|
|
6
6
|
type EmptyRecord = Record<never, never>;
|
|
7
|
+
/** A compound component's named sub-components, e.g. `{ Header, Content, Footer }`. */
|
|
8
|
+
type SubComponentMap = Readonly<AnyRecord>;
|
|
7
9
|
|
|
8
10
|
type IntrinsicTag = keyof HTMLElementTagNameMap;
|
|
9
11
|
|
|
@@ -29,13 +31,6 @@ type MinMax = {
|
|
|
29
31
|
};
|
|
30
32
|
type CardinalityInput = Partial<MinMax>;
|
|
31
33
|
|
|
32
|
-
/** Structural counterpart to `@praxis-kit/contract`'s `ChildrenEvaluator` class — `lib/primitive`
|
|
33
|
-
* may not depend on `lib/contract` (see `primitive-no-upper-layers` in .dependency-cruiser.cjs),
|
|
34
|
-
* so this describes only the shape consumers actually call. Mirrors `AriaEngine`'s pattern. */
|
|
35
|
-
type ChildrenEvaluator$1 = {
|
|
36
|
-
evaluate: (children: unknown[]) => void;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
34
|
/**
|
|
40
35
|
* Resolved per-instance state available to a dynamic (`dynamic(...)`) child
|
|
41
36
|
* rule field — the same tag/props every adapter already computes before
|
|
@@ -47,6 +42,13 @@ type ChildRuleContext = {
|
|
|
47
42
|
readonly props: Readonly<AnyRecord>;
|
|
48
43
|
};
|
|
49
44
|
|
|
45
|
+
/** Structural counterpart to `@praxis-kit/contract`'s `ChildrenEvaluator` class — `lib/primitive`
|
|
46
|
+
* may not depend on `lib/contract` (see `primitive-no-upper-layers` in .dependency-cruiser.cjs),
|
|
47
|
+
* so this describes only the shape consumers actually call. Mirrors `AriaEngine`'s pattern. */
|
|
48
|
+
type ChildrenEvaluator$1 = {
|
|
49
|
+
evaluate: (children: unknown[], context?: ChildRuleContext) => void;
|
|
50
|
+
};
|
|
51
|
+
|
|
50
52
|
declare const RULE_BRAND: unique symbol;
|
|
51
53
|
|
|
52
54
|
type DynamicRule<T, C = unknown> = {
|
|
@@ -131,6 +133,7 @@ interface PolymorphicGenerics<TDefault extends ElementType = ElementType, Props
|
|
|
131
133
|
preset: TPreset;
|
|
132
134
|
allowed: TAllowed;
|
|
133
135
|
}
|
|
136
|
+
type PropsOf<T extends PolymorphicGenerics> = T['props'];
|
|
134
137
|
|
|
135
138
|
type RequireAtLeastOneIfNotEmpty<T> = keyof T extends never ? EmptyRecord : RequireAtLeastOne<T>;
|
|
136
139
|
type CompoundVariantConditionValue<V extends VariantMap, K extends keyof V> = VariantKey<V, K> | NonEmptyArray<VariantKey<V, K>>;
|
|
@@ -200,8 +203,8 @@ type AriaContext = {
|
|
|
200
203
|
readonly props: ReadonlyDeep<IntrinsicProps>;
|
|
201
204
|
};
|
|
202
205
|
|
|
203
|
-
type RemoveAttributeFixKind =
|
|
204
|
-
type InjectLiveFixKind =
|
|
206
|
+
type RemoveAttributeFixKind = 'removeAttribute';
|
|
207
|
+
type InjectLiveFixKind = 'injectLive';
|
|
205
208
|
type FixKind = 'removeRole' | 'setRole' | 'normalizeRelevantAll' | RemoveAttributeFixKind | InjectLiveFixKind;
|
|
206
209
|
|
|
207
210
|
type AriaFixResult = {
|
|
@@ -214,6 +217,9 @@ type AriaFixResult = {
|
|
|
214
217
|
};
|
|
215
218
|
type AriaFix = {
|
|
216
219
|
readonly kind: FixKind;
|
|
220
|
+
/** The attribute a `'removeAttribute'`/`'injectLive'` fix targets — always set for those
|
|
221
|
+
* kinds, absent for kinds with no single-attribute target (`'removeRole'`, etc.). */
|
|
222
|
+
readonly attribute?: string;
|
|
217
223
|
readonly priority?: number;
|
|
218
224
|
readonly source?: string;
|
|
219
225
|
readonly apply: (context: AriaContext) => AriaFixResult;
|
|
@@ -307,6 +313,30 @@ type FactoryOptions<TDefault extends ElementType = ElementType, Props extends An
|
|
|
307
313
|
* be set directly by component authors — use `enforcement.diagnostics` to override per component.
|
|
308
314
|
*/
|
|
309
315
|
readonly diagnostics?: Diagnostics;
|
|
316
|
+
/**
|
|
317
|
+
* Sub-components to attach to the generated root component, producing a
|
|
318
|
+
* compound component API (for example, `Card.Header`, `Card.Content`,
|
|
319
|
+
* and `Card.Footer`). Purely additive — has no effect on
|
|
320
|
+
* `enforcement.children`; author child rules explicitly if the component
|
|
321
|
+
* needs to validate its children.
|
|
322
|
+
*/
|
|
323
|
+
readonly subComponents?: SubComponentMap;
|
|
324
|
+
/**
|
|
325
|
+
* Called once per instance, when the real underlying DOM element first
|
|
326
|
+
* exists, in every adapter — via that adapter's own native mount
|
|
327
|
+
* lifecycle, never through the props/attribute pipeline. Use this for
|
|
328
|
+
* wiring that needs the actual element (native imperative methods like
|
|
329
|
+
* `dialogEl.showModal()`, native events like `close`/`cancel` that have
|
|
330
|
+
* no prop-based equivalent), not for anything expressible as a plain
|
|
331
|
+
* prop.
|
|
332
|
+
*
|
|
333
|
+
* `getProps` returns the instance's *current* resolved props at call
|
|
334
|
+
* time — read it from inside a listener registered once at mount, rather
|
|
335
|
+
* than re-subscribing on every prop change.
|
|
336
|
+
*
|
|
337
|
+
* Return a cleanup function to run when the instance unmounts.
|
|
338
|
+
*/
|
|
339
|
+
readonly onElement?: (element: Element, getProps: () => Readonly<Props>) => void | (() => void);
|
|
310
340
|
};
|
|
311
341
|
|
|
312
342
|
type ResolvedFactoryOptions<TDefault extends ElementType = ElementType, Props extends AnyRecord = EmptyRecord, V extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<V> = Readonly<EmptyRecord>> = {
|
|
@@ -421,12 +451,16 @@ type SvelteFactoryOptions<TDefault extends ElementType, Props extends UnknownPro
|
|
|
421
451
|
|
|
422
452
|
type TypedRuntime<G extends PolymorphicGenerics> = ReturnType<typeof createPolymorphic2<DefaultOf<G>, PropsOf<G>, VariantsOf<G>, RecipeOf<G>>>;
|
|
423
453
|
|
|
454
|
+
type OnElementFn<Props = unknown> = (element: Element, getProps: () => Readonly<Props>) => void | (() => void);
|
|
424
455
|
type BuiltRuntime<G extends PolymorphicGenerics = PolymorphicGenerics, TOptions extends WithChildRules = WithChildRules> = BuiltChildrenEvaluator<TOptions> & {
|
|
425
456
|
runtime: TypedRuntime<G>;
|
|
426
457
|
filterProps: FilterPredicate;
|
|
427
458
|
slotValidator: SlotValidator;
|
|
459
|
+
onElement?: OnElementFn<PropsOf<G>>;
|
|
428
460
|
};
|
|
429
461
|
|
|
430
|
-
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TOptions extends WithChildRules = SvelteFactoryOptions<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>>(options: SvelteFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & TOptions
|
|
462
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends AnyClassPluginFactory = AnyClassPluginFactory, TSubComponents extends Readonly<AnyRecord> = EmptyRecord, TOptions extends WithChildRules = SvelteFactoryOptions<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>>(options: SvelteFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin> & TOptions & {
|
|
463
|
+
readonly subComponents?: TSubComponents;
|
|
464
|
+
}): BuiltRuntime<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset>, TOptions> & TSubComponents;
|
|
431
465
|
|
|
432
466
|
export { type AnyFactoryOptions, type BuiltRuntime, type ElementType, type EmptyRecord, type FilterPredicate, type PolymorphicGenerics, type SvelteFactoryOptions, type UnknownProps, type WithChildRules, createContractComponent, defineContractComponent };
|