praxis-kit 4.0.3 → 4.1.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/_shared/diagnostics.d.ts +14 -17
- package/dist/{chunk-DRGZ4ZI2.js → chunk-R2RKHZNX.js} +968 -634
- package/dist/contract/index.d.ts +39 -27
- package/dist/lit/index.d.ts +42 -30
- package/dist/lit/index.js +653 -413
- package/dist/preact/index.d.ts +45 -31
- package/dist/preact/index.js +1009 -685
- package/dist/react/index.d.ts +24 -11
- package/dist/react/index.js +21 -143
- package/dist/react/legacy.d.ts +3 -3
- package/dist/react/legacy.js +28 -147
- package/dist/{merge-refs-B0YcfdtP.d.ts → react-options-XrRof248.d.ts} +156 -100
- package/dist/solid/index.d.ts +45 -31
- package/dist/solid/index.js +521 -296
- package/dist/svelte/index.d.ts +55 -34
- package/dist/svelte/index.js +504 -296
- package/dist/tailwind/index.d.ts +29 -22
- package/dist/vite-plugin/index.d.ts +10 -12
- package/dist/vue/index.d.ts +45 -31
- package/dist/vue/index.js +898 -693
- package/dist/web/index.d.ts +43 -31
- package/dist/web/index.js +652 -406
- package/package.json +3 -3
package/dist/react/index.d.ts
CHANGED
|
@@ -1,10 +1,28 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { e as AnyFactoryOptions, f as ElementRef, F as FactoryOptions, g as PolymorphicProps, h as PolymorphicWithAsChild, i as PolymorphicWithRender, j as RenderCallbackProps, S as Slottable, k as SlottableProps, m as composeRefs, l as defineContractComponent, m as mergeRefs } from '../
|
|
3
|
-
import
|
|
1
|
+
import { U as UnknownProps, E as ElementType, a as EmptyRecord, V as VariantMap, R as RecipeMap, A as AnyClassPluginFactory, b as ReactFactoryOptions, P as PolymorphicComponent, c as PolymorphicGenerics, d as ExtractPluginProps } from '../react-options-XrRof248.js';
|
|
2
|
+
export { e as AnyFactoryOptions, f as ElementRef, F as FactoryOptions, g as PolymorphicProps, h as PolymorphicWithAsChild, i as PolymorphicWithRender, j as RenderCallbackProps, S as Slottable, k as SlottableProps, m as composeRefs, l as defineContractComponent, m as mergeRefs } from '../react-options-XrRof248.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactElement, Ref } from 'react';
|
|
4
5
|
import 'type-fest';
|
|
5
6
|
import '../_shared/diagnostics.js';
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Canonical ref representation used internally.
|
|
10
|
+
*
|
|
11
|
+
* All helpers normalize missing refs (`undefined`) to `null`, so callers only
|
|
12
|
+
* need to handle two states: a ref exists, or it does not.
|
|
13
|
+
*/
|
|
14
|
+
type NormalizedRef = Ref<unknown> | null;
|
|
15
|
+
/**
|
|
16
|
+
* Input accepted by the clone operation before props, refs, and event handlers
|
|
17
|
+
* are merged into their final form.
|
|
18
|
+
*/
|
|
19
|
+
type CloneInput = {
|
|
20
|
+
child: ReactElement;
|
|
21
|
+
slotProps: UnknownProps;
|
|
22
|
+
ref: NormalizedRef;
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
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, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset, TAllowed>>;
|
|
8
26
|
|
|
9
27
|
type SlotProps = {
|
|
10
28
|
ref?: Ref<unknown> | null;
|
|
@@ -12,15 +30,10 @@ type SlotProps = {
|
|
|
12
30
|
};
|
|
13
31
|
declare function Slot({ ref, children, ...slotProps }: SlotProps): ReactElement;
|
|
14
32
|
declare namespace Slot {
|
|
15
|
-
var displayName:
|
|
33
|
+
var displayName: "Slot";
|
|
16
34
|
}
|
|
17
35
|
|
|
18
|
-
|
|
19
|
-
child: ReactElement;
|
|
20
|
-
slotProps: UnknownProps;
|
|
21
|
-
ref: Ref<unknown> | null;
|
|
22
|
-
};
|
|
23
|
-
declare function cloneSlotChild({ child, slotProps, ref }: CloneInput): ReactElement;
|
|
36
|
+
declare const cloneSlotChild: ({ child, slotProps, ref }: CloneInput) => react.ReactElement;
|
|
24
37
|
|
|
25
38
|
/**
|
|
26
39
|
* Cross-version ref extraction for React 19 elements.
|
package/dist/react/index.js
CHANGED
|
@@ -1,67 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AriaPolicyEngine,
|
|
3
2
|
COMPONENT_DEFAULT_TAG,
|
|
4
3
|
SLOT_NAME,
|
|
5
|
-
SlotValidator,
|
|
6
4
|
Slottable,
|
|
7
|
-
applyAria,
|
|
8
|
-
applyAttributes,
|
|
9
5
|
applyDisplayName,
|
|
10
|
-
applyFilterProps,
|
|
11
|
-
applyPropNormalizers,
|
|
12
|
-
applyRef,
|
|
13
6
|
applySlot,
|
|
14
|
-
|
|
15
|
-
buildEngines,
|
|
16
|
-
buildStylePipeline,
|
|
17
|
-
cloneWithProps,
|
|
7
|
+
buildRuntime,
|
|
18
8
|
defineContractComponent,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
isFunction,
|
|
24
|
-
isPlainObject,
|
|
25
|
-
joinClasses,
|
|
26
|
-
makeRenderAsChild,
|
|
9
|
+
getElementRef,
|
|
10
|
+
getPropsRef,
|
|
11
|
+
hasWarningGetter,
|
|
12
|
+
makeCloneSlotChild,
|
|
27
13
|
mergeRefs,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
renderWithCallback,
|
|
31
|
-
resolveAdapterCommonOptions
|
|
32
|
-
} from "../chunk-DRGZ4ZI2.js";
|
|
33
|
-
|
|
34
|
-
// ../../adapters/react/src/current/slot/cloneSlotChild.ts
|
|
35
|
-
import { Fragment } from "react";
|
|
14
|
+
render
|
|
15
|
+
} from "../chunk-R2RKHZNX.js";
|
|
36
16
|
|
|
37
17
|
// ../../adapters/react/src/current/slot/composeRefs.ts
|
|
38
|
-
function isReactWarningGetter(getter) {
|
|
39
|
-
return isFunction(getter) && "isReactWarning" in getter;
|
|
40
|
-
}
|
|
41
|
-
function hasWarningGetter(obj, key) {
|
|
42
|
-
return isPlainObject(obj) && isReactWarningGetter(Object.getOwnPropertyDescriptor(obj, key)?.get);
|
|
43
|
-
}
|
|
44
|
-
function getElementRef(element) {
|
|
45
|
-
const el = element;
|
|
46
|
-
return isPlainObject(el) ? el.ref ?? null : null;
|
|
47
|
-
}
|
|
48
|
-
function getPropsRef(element) {
|
|
49
|
-
const props = element.props;
|
|
50
|
-
return isPlainObject(props) ? props.ref ?? null : null;
|
|
51
|
-
}
|
|
52
18
|
function getChildRef(element) {
|
|
53
19
|
return hasWarningGetter(element.props, "ref") ? getElementRef(element) : getPropsRef(element);
|
|
54
20
|
}
|
|
55
21
|
|
|
56
22
|
// ../../adapters/react/src/current/slot/cloneSlotChild.ts
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const merged = mergeSlotProps(slotProps, childProps);
|
|
63
|
-
return cloneWithProps(child, merged, mergedRef);
|
|
23
|
+
var cloneSlotChild = makeCloneSlotChild(getChildRef);
|
|
24
|
+
|
|
25
|
+
// ../../adapters/react/src/current/slot/Slot.tsx
|
|
26
|
+
function Slot({ ref = null, children, ...slotProps }) {
|
|
27
|
+
return applySlot(children, slotProps, ref, cloneSlotChild);
|
|
64
28
|
}
|
|
29
|
+
Slot.displayName = SLOT_NAME;
|
|
65
30
|
|
|
66
31
|
// ../../adapters/react/src/current/normalize-children.ts
|
|
67
32
|
import { isValidElement } from "react";
|
|
@@ -71,111 +36,24 @@ function normalizeChildren(children) {
|
|
|
71
36
|
return [];
|
|
72
37
|
}
|
|
73
38
|
|
|
39
|
+
// ../../adapters/react/src/current/build-runtime.ts
|
|
40
|
+
function buildRuntime2(options) {
|
|
41
|
+
return buildRuntime(options, Slot, normalizeChildren);
|
|
42
|
+
}
|
|
43
|
+
|
|
74
44
|
// ../../adapters/react/src/current/create-contract-component.ts
|
|
75
|
-
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
76
45
|
function createContractComponent(options) {
|
|
77
|
-
const
|
|
78
|
-
const displayName = resolved.name;
|
|
79
|
-
const defaultTag = options.tag ?? "div";
|
|
80
|
-
const artifact = options.artifact;
|
|
81
|
-
const definition = artifact?.definition ?? buildDefinition(displayName, defaultTag);
|
|
82
|
-
const variantKeys = new Set(Object.keys(options.styling?.variants ?? {}));
|
|
83
|
-
const domDefaults = options.defaults;
|
|
84
|
-
const stylePipeline = buildStylePipeline(
|
|
85
|
-
options.styling?.variants,
|
|
86
|
-
options.styling?.presets,
|
|
87
|
-
options.styling?.defaults ?? {},
|
|
88
|
-
options.styling?.compounds,
|
|
89
|
-
artifact?.precomputed?.variantLookup
|
|
90
|
-
);
|
|
91
|
-
const base = options.styling?.base !== void 0 ? flattenClassName(options.styling.base) : void 0;
|
|
92
|
-
const filterFn = options.filterProps;
|
|
93
|
-
const allowedAs = options.enforcement?.allowedAs;
|
|
94
|
-
const normalizeFn = options.normalize;
|
|
95
|
-
const enforcementNormalizers = options.enforcement?.props;
|
|
96
|
-
const classPlugin = options.styling?.plugin !== void 0 ? options.styling.plugin(
|
|
97
|
-
options.styling,
|
|
98
|
-
resolved.diagnostics
|
|
99
|
-
) : void 0;
|
|
100
|
-
const pluginKeys = classPlugin?.ownedKeys ?? EMPTY_SET;
|
|
101
|
-
const { childrenEvaluator: explicitEvaluator } = buildEngines(
|
|
102
|
-
resolved.diagnostics,
|
|
103
|
-
options.enforcement?.children,
|
|
104
|
-
displayName
|
|
105
|
-
);
|
|
106
|
-
const ariaEngine = options.enforcement !== void 0 ? new AriaPolicyEngine(resolved.diagnostics) : void 0;
|
|
107
|
-
const slotValidator = new SlotValidator(displayName, resolved.diagnostics, "React element");
|
|
108
|
-
const renderAsChild = makeRenderAsChild(cloneSlotChild);
|
|
46
|
+
const bundle = buildRuntime2(options);
|
|
109
47
|
function Component({ ref, ...props }) {
|
|
110
|
-
|
|
111
|
-
as,
|
|
112
|
-
asChild,
|
|
113
|
-
render,
|
|
114
|
-
children,
|
|
115
|
-
className: callerClassName,
|
|
116
|
-
recipe,
|
|
117
|
-
...ownProps
|
|
118
|
-
} = props;
|
|
119
|
-
const tag = typeof as === "string" ? as : defaultTag;
|
|
120
|
-
if (allowedAs !== void 0) enforceAllowedAs(tag, allowedAs, resolved.diagnostics, displayName);
|
|
121
|
-
const rawBaseProps = domDefaults !== void 0 ? { ...domDefaults, ...ownProps } : ownProps;
|
|
122
|
-
const normalizedProps = applyPropNormalizers(tag, rawBaseProps, enforcementNormalizers);
|
|
123
|
-
const baseProps = normalizeFn !== void 0 ? normalizeFn(normalizedProps) : normalizedProps;
|
|
124
|
-
const pluginProps = {};
|
|
125
|
-
const propsForExtraction = pluginKeys.size > 0 ? Object.fromEntries(
|
|
126
|
-
Object.entries(baseProps).filter(([k]) => {
|
|
127
|
-
if (pluginKeys.has(k)) {
|
|
128
|
-
pluginProps[k] = baseProps[k];
|
|
129
|
-
return false;
|
|
130
|
-
}
|
|
131
|
-
return true;
|
|
132
|
-
})
|
|
133
|
-
) : baseProps;
|
|
134
|
-
const rootDec = extractDecoration(propsForExtraction, variantKeys);
|
|
135
|
-
const decoration = applyAria(
|
|
136
|
-
Object.keys(rootDec).length > 0 ? { root: rootDec } : {},
|
|
137
|
-
tag,
|
|
138
|
-
ariaEngine
|
|
139
|
-
);
|
|
140
|
-
if (process.env.NODE_ENV !== "production") {
|
|
141
|
-
const childEval = explicitEvaluator ?? getHtmlChildrenEvaluator(tag);
|
|
142
|
-
childEval?.evaluate(normalizeChildren(children));
|
|
143
|
-
}
|
|
144
|
-
const recipeName = typeof recipe === "string" ? recipe : void 0;
|
|
145
|
-
const { variantClasses, compoundClasses } = stylePipeline ? stylePipeline.execute(decoration, recipeName) : { variantClasses: [], compoundClasses: [] };
|
|
146
|
-
const rawClassName = joinClasses(base, ...variantClasses, ...compoundClasses, callerClassName);
|
|
147
|
-
const className = classPlugin !== void 0 ? classPlugin.pipeline(tag, pluginProps, rawClassName, recipeName) : rawClassName;
|
|
148
|
-
if (asChild === true) {
|
|
149
|
-
if (typeof as === "string") {
|
|
150
|
-
slotValidator.assertExclusive();
|
|
151
|
-
} else {
|
|
152
|
-
return renderAsChild(children, className, ref);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
let finalDecoration = className ? applyAttributes("root", { className }, decoration, variantKeys) : decoration;
|
|
156
|
-
finalDecoration = applyFilterProps(finalDecoration, filterFn, variantKeys);
|
|
157
|
-
finalDecoration = applyRef(finalDecoration, ref);
|
|
158
|
-
if (typeof render === "function")
|
|
159
|
-
return renderWithCallback(
|
|
160
|
-
render,
|
|
161
|
-
finalDecoration["root"]?.attributes ?? {},
|
|
162
|
-
className,
|
|
163
|
-
ref
|
|
164
|
-
);
|
|
165
|
-
return renderNormally(definition, tag, finalDecoration, children);
|
|
48
|
+
return render({ ...bundle, props, ref: ref ?? null });
|
|
166
49
|
}
|
|
167
50
|
applyDisplayName(Component, options.name);
|
|
51
|
+
const defaultTag = bundle.runtime.options.defaultTag;
|
|
168
52
|
if (typeof defaultTag === "string") {
|
|
169
53
|
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
|
|
170
54
|
}
|
|
171
55
|
return Component;
|
|
172
56
|
}
|
|
173
|
-
|
|
174
|
-
// ../../adapters/react/src/current/slot/Slot.tsx
|
|
175
|
-
function Slot({ ref = null, children, ...slotProps }) {
|
|
176
|
-
return applySlot(children, slotProps, ref, cloneSlotChild);
|
|
177
|
-
}
|
|
178
|
-
Slot.displayName = SLOT_NAME;
|
|
179
57
|
export {
|
|
180
58
|
Slot,
|
|
181
59
|
Slottable,
|
package/dist/react/legacy.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { E as ElementType, U as UnknownProps, a as EmptyRecord, V as VariantMap, R as RecipeMap,
|
|
2
|
-
export { e as AnyFactoryOptions, f as ElementRef, F as FactoryOptions, g as PolymorphicProps, h as PolymorphicWithAsChild, i as PolymorphicWithRender, j as RenderCallbackProps, S as Slottable, k as SlottableProps, l as defineContractComponent, m as mergeRefs } from '../
|
|
1
|
+
import { E as ElementType, U as UnknownProps, a as EmptyRecord, V as VariantMap, R as RecipeMap, A as AnyClassPluginFactory, b as ReactFactoryOptions, P as PolymorphicComponent, c as PolymorphicGenerics, d as ExtractPluginProps } from '../react-options-XrRof248.js';
|
|
2
|
+
export { e as AnyFactoryOptions, f as ElementRef, F as FactoryOptions, g as PolymorphicProps, h as PolymorphicWithAsChild, i as PolymorphicWithRender, j as RenderCallbackProps, S as Slottable, k as SlottableProps, l as defineContractComponent, m as mergeRefs } from '../react-options-XrRof248.js';
|
|
3
3
|
import * as react from 'react';
|
|
4
4
|
import 'type-fest';
|
|
5
5
|
import '../_shared/diagnostics.js';
|
|
6
6
|
|
|
7
|
-
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends RecipeMap<Variants> = Readonly<EmptyRecord>, TPlugin extends
|
|
7
|
+
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, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPlugin, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & ExtractPluginProps<TPlugin>, Variants, TPreset, TAllowed>>;
|
|
8
8
|
|
|
9
9
|
type SlotProps = {
|
|
10
10
|
[key: string]: unknown;
|
package/dist/react/legacy.js
CHANGED
|
@@ -1,70 +1,39 @@
|
|
|
1
1
|
import {
|
|
2
|
-
AriaPolicyEngine,
|
|
3
2
|
COMPONENT_DEFAULT_TAG,
|
|
4
3
|
SLOT_NAME,
|
|
5
|
-
SlotValidator,
|
|
6
4
|
Slottable,
|
|
7
|
-
applyAria,
|
|
8
|
-
applyAttributes,
|
|
9
5
|
applyDisplayName,
|
|
10
|
-
applyFilterProps,
|
|
11
|
-
applyPropNormalizers,
|
|
12
|
-
applyRef,
|
|
13
6
|
applySlot,
|
|
14
|
-
|
|
15
|
-
buildEngines,
|
|
16
|
-
buildStylePipeline,
|
|
17
|
-
cloneWithProps,
|
|
7
|
+
buildRuntime,
|
|
18
8
|
defineContractComponent,
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
isPlainObject,
|
|
25
|
-
joinClasses,
|
|
26
|
-
makeRenderAsChild,
|
|
9
|
+
getElementRef,
|
|
10
|
+
getPropsRef,
|
|
11
|
+
hasWarningGetter,
|
|
12
|
+
isString,
|
|
13
|
+
makeCloneSlotChild,
|
|
27
14
|
mergeRefs,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
renderWithCallback,
|
|
31
|
-
resolveAdapterCommonOptions
|
|
32
|
-
} from "../chunk-DRGZ4ZI2.js";
|
|
15
|
+
render
|
|
16
|
+
} from "../chunk-R2RKHZNX.js";
|
|
33
17
|
|
|
34
18
|
// ../../adapters/react/src/legacy/create-contract-component.ts
|
|
35
|
-
import { forwardRef } from "react";
|
|
19
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
36
20
|
|
|
37
|
-
// ../../adapters/react/src/legacy/slot/
|
|
38
|
-
import {
|
|
21
|
+
// ../../adapters/react/src/legacy/slot/Slot.tsx
|
|
22
|
+
import { forwardRef } from "react";
|
|
39
23
|
|
|
40
24
|
// ../../adapters/react/src/legacy/slot/composeRefs.ts
|
|
41
|
-
function isReactWarningGetter(getter) {
|
|
42
|
-
return isFunction(getter) && "isReactWarning" in getter;
|
|
43
|
-
}
|
|
44
|
-
function hasWarningGetter(obj, key) {
|
|
45
|
-
return isPlainObject(obj) && isReactWarningGetter(Object.getOwnPropertyDescriptor(obj, key)?.get);
|
|
46
|
-
}
|
|
47
|
-
function getElementRef(element) {
|
|
48
|
-
const el = element;
|
|
49
|
-
return isPlainObject(el) ? el.ref ?? null : null;
|
|
50
|
-
}
|
|
51
|
-
function getPropsRef(element) {
|
|
52
|
-
const props = element.props;
|
|
53
|
-
return isPlainObject(props) ? props.ref ?? null : null;
|
|
54
|
-
}
|
|
55
25
|
function getChildRef(element) {
|
|
56
26
|
return hasWarningGetter(element, "ref") ? getPropsRef(element) : getElementRef(element);
|
|
57
27
|
}
|
|
58
28
|
|
|
59
29
|
// ../../adapters/react/src/legacy/slot/cloneSlotChild.ts
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
}
|
|
30
|
+
var cloneSlotChild = makeCloneSlotChild(getChildRef);
|
|
31
|
+
|
|
32
|
+
// ../../adapters/react/src/legacy/slot/Slot.tsx
|
|
33
|
+
var Slot = forwardRef(function Slot2({ children, ...slotProps }, ref) {
|
|
34
|
+
return applySlot(children, slotProps, ref, cloneSlotChild);
|
|
35
|
+
});
|
|
36
|
+
Slot.displayName = SLOT_NAME;
|
|
68
37
|
|
|
69
38
|
// ../../adapters/react/src/legacy/normalize-children.ts
|
|
70
39
|
import { Children, isValidElement } from "react";
|
|
@@ -72,112 +41,24 @@ function normalizeChildren(children) {
|
|
|
72
41
|
return Children.toArray(children).filter(isValidElement);
|
|
73
42
|
}
|
|
74
43
|
|
|
44
|
+
// ../../adapters/react/src/legacy/build-runtime.ts
|
|
45
|
+
function buildRuntime2(options) {
|
|
46
|
+
return buildRuntime(options, Slot, normalizeChildren);
|
|
47
|
+
}
|
|
48
|
+
|
|
75
49
|
// ../../adapters/react/src/legacy/create-contract-component.ts
|
|
76
|
-
var EMPTY_SET = /* @__PURE__ */ new Set();
|
|
77
50
|
function createContractComponent(options) {
|
|
78
|
-
const
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const artifact = options.artifact;
|
|
82
|
-
const definition = artifact?.definition ?? buildDefinition(displayName, defaultTag);
|
|
83
|
-
const variantKeys = new Set(Object.keys(options.styling?.variants ?? {}));
|
|
84
|
-
const domDefaults = options.defaults;
|
|
85
|
-
const stylePipeline = buildStylePipeline(
|
|
86
|
-
options.styling?.variants,
|
|
87
|
-
options.styling?.presets,
|
|
88
|
-
options.styling?.defaults ?? {},
|
|
89
|
-
options.styling?.compounds,
|
|
90
|
-
artifact?.precomputed?.variantLookup
|
|
91
|
-
);
|
|
92
|
-
const base = options.styling?.base !== void 0 ? flattenClassName(options.styling.base) : void 0;
|
|
93
|
-
const filterFn = options.filterProps;
|
|
94
|
-
const allowedAs = options.enforcement?.allowedAs;
|
|
95
|
-
const normalizeFn = options.normalize;
|
|
96
|
-
const enforcementNormalizers = options.enforcement?.props;
|
|
97
|
-
const classPlugin = options.styling?.plugin !== void 0 ? options.styling.plugin(
|
|
98
|
-
options.styling,
|
|
99
|
-
resolved.diagnostics
|
|
100
|
-
) : void 0;
|
|
101
|
-
const pluginKeys = classPlugin?.ownedKeys ?? EMPTY_SET;
|
|
102
|
-
const { childrenEvaluator: explicitEvaluator } = buildEngines(
|
|
103
|
-
resolved.diagnostics,
|
|
104
|
-
options.enforcement?.children,
|
|
105
|
-
displayName
|
|
106
|
-
);
|
|
107
|
-
const ariaEngine = options.enforcement !== void 0 ? new AriaPolicyEngine(resolved.diagnostics) : void 0;
|
|
108
|
-
const slotValidator = new SlotValidator(displayName, resolved.diagnostics, "React element");
|
|
109
|
-
const renderAsChild = makeRenderAsChild(cloneSlotChild);
|
|
110
|
-
const Component = forwardRef(function Component2(props, ref) {
|
|
111
|
-
const {
|
|
112
|
-
as,
|
|
113
|
-
asChild,
|
|
114
|
-
render,
|
|
115
|
-
children,
|
|
116
|
-
className: callerClassName,
|
|
117
|
-
recipe,
|
|
118
|
-
...ownProps
|
|
119
|
-
} = props;
|
|
120
|
-
const tag = typeof as === "string" ? as : defaultTag;
|
|
121
|
-
if (allowedAs !== void 0) enforceAllowedAs(tag, allowedAs, resolved.diagnostics, displayName);
|
|
122
|
-
const rawBaseProps = domDefaults !== void 0 ? { ...domDefaults, ...ownProps } : ownProps;
|
|
123
|
-
const normalizedProps = applyPropNormalizers(tag, rawBaseProps, enforcementNormalizers);
|
|
124
|
-
const baseProps = normalizeFn !== void 0 ? normalizeFn(normalizedProps) : normalizedProps;
|
|
125
|
-
const pluginProps = {};
|
|
126
|
-
const propsForExtraction = pluginKeys.size > 0 ? Object.fromEntries(
|
|
127
|
-
Object.entries(baseProps).filter(([k]) => {
|
|
128
|
-
if (pluginKeys.has(k)) {
|
|
129
|
-
pluginProps[k] = baseProps[k];
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
return true;
|
|
133
|
-
})
|
|
134
|
-
) : baseProps;
|
|
135
|
-
const rootDec = extractDecoration(propsForExtraction, variantKeys);
|
|
136
|
-
const decoration = applyAria(
|
|
137
|
-
Object.keys(rootDec).length > 0 ? { root: rootDec } : {},
|
|
138
|
-
tag,
|
|
139
|
-
ariaEngine
|
|
140
|
-
);
|
|
141
|
-
if (process.env.NODE_ENV !== "production") {
|
|
142
|
-
const childEval = explicitEvaluator ?? getHtmlChildrenEvaluator(tag);
|
|
143
|
-
childEval?.evaluate(normalizeChildren(children));
|
|
144
|
-
}
|
|
145
|
-
const recipeName = typeof recipe === "string" ? recipe : void 0;
|
|
146
|
-
const { variantClasses, compoundClasses } = stylePipeline ? stylePipeline.execute(decoration, recipeName) : { variantClasses: [], compoundClasses: [] };
|
|
147
|
-
const rawClassName = joinClasses(base, ...variantClasses, ...compoundClasses, callerClassName);
|
|
148
|
-
const className = classPlugin !== void 0 ? classPlugin.pipeline(tag, pluginProps, rawClassName, recipeName) : rawClassName;
|
|
149
|
-
if (asChild === true) {
|
|
150
|
-
if (typeof as === "string") {
|
|
151
|
-
slotValidator.assertExclusive();
|
|
152
|
-
} else {
|
|
153
|
-
return renderAsChild(children, className, ref);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
let finalDecoration = className ? applyAttributes("root", { className }, decoration, variantKeys) : decoration;
|
|
157
|
-
finalDecoration = applyFilterProps(finalDecoration, filterFn, variantKeys);
|
|
158
|
-
finalDecoration = applyRef(finalDecoration, ref);
|
|
159
|
-
if (typeof render === "function")
|
|
160
|
-
return renderWithCallback(
|
|
161
|
-
render,
|
|
162
|
-
finalDecoration["root"]?.attributes ?? {},
|
|
163
|
-
className,
|
|
164
|
-
ref
|
|
165
|
-
);
|
|
166
|
-
return renderNormally(definition, tag, finalDecoration, children);
|
|
51
|
+
const bundle = buildRuntime2(options);
|
|
52
|
+
const Component = forwardRef2(function Component2(props, ref) {
|
|
53
|
+
return render({ ...bundle, props, ref });
|
|
167
54
|
});
|
|
168
55
|
applyDisplayName(Component, options.name);
|
|
169
|
-
|
|
56
|
+
const defaultTag = bundle.runtime.options.defaultTag;
|
|
57
|
+
if (isString(defaultTag)) {
|
|
170
58
|
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: defaultTag });
|
|
171
59
|
}
|
|
172
60
|
return Component;
|
|
173
61
|
}
|
|
174
|
-
|
|
175
|
-
// ../../adapters/react/src/legacy/slot/Slot.tsx
|
|
176
|
-
import { forwardRef as forwardRef2 } from "react";
|
|
177
|
-
var Slot = forwardRef2(function Slot2({ children, ...slotProps }, ref) {
|
|
178
|
-
return applySlot(children, slotProps, ref, cloneSlotChild);
|
|
179
|
-
});
|
|
180
|
-
Slot.displayName = SLOT_NAME;
|
|
181
62
|
export {
|
|
182
63
|
Slot,
|
|
183
64
|
Slottable,
|