praxis-kit 1.1.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/LICENSE +21 -0
- package/dist/chunk-KDUNVQK2.js +2059 -0
- package/dist/codemod/index.d.ts +21 -0
- package/dist/codemod/index.js +241955 -0
- package/dist/eslint/index.d.ts +84 -0
- package/dist/eslint/index.js +1068 -0
- package/dist/lit/index.d.ts +304 -0
- package/dist/lit/index.js +1887 -0
- package/dist/merge-refs-CfBqh1UO.d.ts +374 -0
- package/dist/preact/index.d.ts +292 -0
- package/dist/preact/index.js +2062 -0
- package/dist/react/index.d.ts +27 -0
- package/dist/react/index.js +197 -0
- package/dist/react/legacy.d.ts +21 -0
- package/dist/react/legacy.js +209 -0
- package/dist/solid/index.d.ts +287 -0
- package/dist/solid/index.js +1837 -0
- package/dist/svelte/index.d.ts +343 -0
- package/dist/svelte/index.js +1723 -0
- package/dist/tailwind/index.d.ts +138 -0
- package/dist/tailwind/index.js +508 -0
- package/dist/ts-plugin/index.cjs +191 -0
- package/dist/ts-plugin/index.d.cts +10 -0
- package/dist/vite-plugin/index.d.ts +395 -0
- package/dist/vite-plugin/index.js +1329 -0
- package/dist/vue/index.d.ts +309 -0
- package/dist/vue/index.js +1922 -0
- package/dist/web/index.d.ts +302 -0
- package/dist/web/index.js +1858 -0
- package/package.json +176 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { E as ElementType, U as UnknownProps, V as VariantMap, P as PresetMap, a as EmptyRecord, A as AnyRecord, R as ReactFactoryOptions, b as PolymorphicComponent, c as PolymorphicGenerics, F as FactoryOptions } from '../merge-refs-CfBqh1UO.js';
|
|
2
|
+
export { d as ElementRef, e as PolymorphicProps, f as PolymorphicWithAsChild, g as PolymorphicWithRender, h as RenderCallbackProps, S as Slottable, i as SlottableProps, j as disabledProps, k as invalidProps, m as mergeRefs } from '../merge-refs-CfBqh1UO.js';
|
|
3
|
+
import { Ref, ReactElement } from 'react';
|
|
4
|
+
import 'type-fest';
|
|
5
|
+
|
|
6
|
+
declare function createAriaEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
7
|
+
|
|
8
|
+
declare function defineContractComponent<O extends FactoryOptions>(options: O): <R>(factory: (options: O) => R) => R;
|
|
9
|
+
|
|
10
|
+
declare function createChildrenEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
11
|
+
|
|
12
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset, TAllowed>>;
|
|
13
|
+
|
|
14
|
+
declare function createContractedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
15
|
+
|
|
16
|
+
declare function createPolymorphicComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
17
|
+
|
|
18
|
+
type SlotProps = {
|
|
19
|
+
ref?: Ref<unknown> | null;
|
|
20
|
+
[key: string]: unknown;
|
|
21
|
+
};
|
|
22
|
+
declare function Slot({ ref, children, ...slotProps }: SlotProps): ReactElement;
|
|
23
|
+
declare namespace Slot {
|
|
24
|
+
var displayName: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { PolymorphicComponent, ReactFactoryOptions, Slot, createAriaEnforcedComponent, createChildrenEnforcedComponent, createContractComponent, createContractedComponent, createPolymorphicComponent, defineContractComponent };
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_DEFAULT_TAG,
|
|
3
|
+
SLOT_NAME,
|
|
4
|
+
SlotValidator,
|
|
5
|
+
Slottable,
|
|
6
|
+
applyDisplayName,
|
|
7
|
+
applySlot,
|
|
8
|
+
buildEngines,
|
|
9
|
+
buildRuntime,
|
|
10
|
+
cloneWithProps,
|
|
11
|
+
composeFilter,
|
|
12
|
+
createContractedPolymorphic,
|
|
13
|
+
createPolymorphic,
|
|
14
|
+
disabledProps,
|
|
15
|
+
invalidProps,
|
|
16
|
+
isFunction,
|
|
17
|
+
isPlainObject,
|
|
18
|
+
mergeRefs,
|
|
19
|
+
mergeSlotProps,
|
|
20
|
+
render
|
|
21
|
+
} from "../chunk-KDUNVQK2.js";
|
|
22
|
+
|
|
23
|
+
// ../../adapters/react/src/current/slot/cloneSlotChild.ts
|
|
24
|
+
import { Fragment } from "react";
|
|
25
|
+
|
|
26
|
+
// ../../adapters/react/src/current/slot/composeRefs.ts
|
|
27
|
+
function isReactWarningGetter(getter) {
|
|
28
|
+
return isFunction(getter) && "isReactWarning" in getter;
|
|
29
|
+
}
|
|
30
|
+
function hasWarningGetter(obj, key) {
|
|
31
|
+
return isPlainObject(obj) && isReactWarningGetter(Object.getOwnPropertyDescriptor(obj, key)?.get);
|
|
32
|
+
}
|
|
33
|
+
function getElementRef(element) {
|
|
34
|
+
const el = element;
|
|
35
|
+
return isPlainObject(el) ? el.ref ?? null : null;
|
|
36
|
+
}
|
|
37
|
+
function getPropsRef(element) {
|
|
38
|
+
const props = element.props;
|
|
39
|
+
return isPlainObject(props) ? props.ref ?? null : null;
|
|
40
|
+
}
|
|
41
|
+
function getChildRef(element) {
|
|
42
|
+
return hasWarningGetter(element.props, "ref") ? getElementRef(element) : getPropsRef(element);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// ../../adapters/react/src/current/slot/cloneSlotChild.ts
|
|
46
|
+
function cloneSlotChild({ child, slotProps, ref }) {
|
|
47
|
+
const childProps = child.props;
|
|
48
|
+
const isFragment = child.type === Fragment;
|
|
49
|
+
const childRef = isFragment ? null : getChildRef(child);
|
|
50
|
+
const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
|
|
51
|
+
const merged = mergeSlotProps(slotProps, childProps);
|
|
52
|
+
return cloneWithProps(child, merged, mergedRef);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ../../adapters/react/src/current/slot/Slot.tsx
|
|
56
|
+
function Slot({ ref = null, children, ...slotProps }) {
|
|
57
|
+
return applySlot(children, slotProps, ref, cloneSlotChild);
|
|
58
|
+
}
|
|
59
|
+
Slot.displayName = SLOT_NAME;
|
|
60
|
+
|
|
61
|
+
// ../../adapters/react/src/current/normalize-children.ts
|
|
62
|
+
import { isValidElement } from "react";
|
|
63
|
+
function normalizeChildren(children) {
|
|
64
|
+
if (isValidElement(children)) return [children];
|
|
65
|
+
if (Array.isArray(children)) return children.filter(isValidElement);
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ../../adapters/react/src/current/create-aria-enforced-component.ts
|
|
70
|
+
function createAriaEnforcedComponent(options) {
|
|
71
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
72
|
+
const strict = options.enforcement?.strict ?? "throw";
|
|
73
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
74
|
+
const runtime = createContractedPolymorphic(options);
|
|
75
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
76
|
+
const slotValidator = new SlotValidator(name, strict);
|
|
77
|
+
function Component({ ref, ...props }) {
|
|
78
|
+
return render({
|
|
79
|
+
runtime,
|
|
80
|
+
props,
|
|
81
|
+
ref: ref ?? null,
|
|
82
|
+
slotComponent,
|
|
83
|
+
normalizeChildren,
|
|
84
|
+
filterProps,
|
|
85
|
+
slotValidator
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
applyDisplayName(Component, name);
|
|
89
|
+
return Component;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// ../../adapters/react/src/current/define-contract-component.ts
|
|
93
|
+
function defineContractComponent(options) {
|
|
94
|
+
return (factory) => factory(options);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// ../../adapters/react/src/current/create-children-enforced-component.ts
|
|
98
|
+
function createChildrenEnforcedComponent(options) {
|
|
99
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
100
|
+
const strict = options.enforcement?.strict ?? "throw";
|
|
101
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
102
|
+
const runtime = createPolymorphic(options);
|
|
103
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
104
|
+
const slotValidator = new SlotValidator(name, strict);
|
|
105
|
+
const { childrenEvaluator } = buildEngines(strict, options.enforcement?.children, name);
|
|
106
|
+
function Component({ ref, ...props }) {
|
|
107
|
+
return render({
|
|
108
|
+
runtime,
|
|
109
|
+
props,
|
|
110
|
+
ref: ref ?? null,
|
|
111
|
+
slotComponent,
|
|
112
|
+
normalizeChildren,
|
|
113
|
+
filterProps,
|
|
114
|
+
slotValidator,
|
|
115
|
+
...childrenEvaluator !== void 0 && { childrenEvaluator }
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
applyDisplayName(Component, name);
|
|
119
|
+
return Component;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// ../../adapters/react/src/current/create-contract-component.ts
|
|
123
|
+
function createContractComponent(options) {
|
|
124
|
+
const bundle = buildRuntime(
|
|
125
|
+
options,
|
|
126
|
+
Slot,
|
|
127
|
+
normalizeChildren
|
|
128
|
+
);
|
|
129
|
+
function Component({ ref, ...props }) {
|
|
130
|
+
return render({ ...bundle, props, ref: ref ?? null });
|
|
131
|
+
}
|
|
132
|
+
applyDisplayName(Component, options.name);
|
|
133
|
+
if (typeof bundle.runtime.options.defaultTag === "string") {
|
|
134
|
+
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: bundle.runtime.options.defaultTag });
|
|
135
|
+
}
|
|
136
|
+
return Component;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// ../../adapters/react/src/current/create-contracted-component.ts
|
|
140
|
+
function createContractedComponent(options) {
|
|
141
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
142
|
+
const strict = options.enforcement?.strict ?? "throw";
|
|
143
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
144
|
+
const runtime = createContractedPolymorphic(options);
|
|
145
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
146
|
+
const slotValidator = new SlotValidator(name, strict);
|
|
147
|
+
const { childrenEvaluator } = buildEngines(strict, options.enforcement?.children, name);
|
|
148
|
+
function Component({ ref, ...props }) {
|
|
149
|
+
return render({
|
|
150
|
+
runtime,
|
|
151
|
+
props,
|
|
152
|
+
ref: ref ?? null,
|
|
153
|
+
slotComponent,
|
|
154
|
+
normalizeChildren,
|
|
155
|
+
filterProps,
|
|
156
|
+
slotValidator,
|
|
157
|
+
...childrenEvaluator !== void 0 && { childrenEvaluator }
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
applyDisplayName(Component, name);
|
|
161
|
+
return Component;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// ../../adapters/react/src/current/create-polymorphic-component.ts
|
|
165
|
+
function createPolymorphicComponent(options) {
|
|
166
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
167
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
168
|
+
const runtime = createPolymorphic(options);
|
|
169
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
170
|
+
const slotValidator = new SlotValidator(name, "throw");
|
|
171
|
+
function Component({ ref, ...props }) {
|
|
172
|
+
return render({
|
|
173
|
+
runtime,
|
|
174
|
+
props,
|
|
175
|
+
ref: ref ?? null,
|
|
176
|
+
slotComponent,
|
|
177
|
+
normalizeChildren,
|
|
178
|
+
filterProps,
|
|
179
|
+
slotValidator
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
applyDisplayName(Component, name);
|
|
183
|
+
return Component;
|
|
184
|
+
}
|
|
185
|
+
export {
|
|
186
|
+
Slot,
|
|
187
|
+
Slottable,
|
|
188
|
+
createAriaEnforcedComponent,
|
|
189
|
+
createChildrenEnforcedComponent,
|
|
190
|
+
createContractComponent,
|
|
191
|
+
createContractedComponent,
|
|
192
|
+
createPolymorphicComponent,
|
|
193
|
+
defineContractComponent,
|
|
194
|
+
disabledProps,
|
|
195
|
+
invalidProps,
|
|
196
|
+
mergeRefs
|
|
197
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { E as ElementType, U as UnknownProps, V as VariantMap, P as PresetMap, a as EmptyRecord, A as AnyRecord, R as ReactFactoryOptions, b as PolymorphicComponent, c as PolymorphicGenerics } from '../merge-refs-CfBqh1UO.js';
|
|
2
|
+
export { d as ElementRef, e as PolymorphicProps, f as PolymorphicWithAsChild, g as PolymorphicWithRender, h as RenderCallbackProps, S as Slottable, i as SlottableProps, j as disabledProps, k as invalidProps, m as mergeRefs } from '../merge-refs-CfBqh1UO.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import 'type-fest';
|
|
5
|
+
|
|
6
|
+
declare function createAriaEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
7
|
+
|
|
8
|
+
declare function createChildrenEnforcedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
9
|
+
|
|
10
|
+
declare function createContractComponent<TDefault extends ElementType, Props extends UnknownProps = EmptyRecord, Variants extends Readonly<VariantMap> = Readonly<EmptyRecord>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord, TAllowed extends ElementType = ElementType>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps, TAllowed>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset, TAllowed>>;
|
|
11
|
+
|
|
12
|
+
declare function createContractedComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
13
|
+
|
|
14
|
+
declare function createPolymorphicComponent<TDefault extends ElementType, Props extends UnknownProps, Variants extends Readonly<VariantMap>, TPreset extends PresetMap<Variants> = Readonly<EmptyRecord>, TPluginProps extends AnyRecord = EmptyRecord>(options: ReactFactoryOptions<TDefault, Props, Variants, TPreset, TPluginProps>): PolymorphicComponent<PolymorphicGenerics<TDefault, Props & TPluginProps, Variants, TPreset>>;
|
|
15
|
+
|
|
16
|
+
type SlotProps = {
|
|
17
|
+
[key: string]: unknown;
|
|
18
|
+
};
|
|
19
|
+
declare const Slot: react.ForwardRefExoticComponent<Omit<SlotProps, "ref"> & react.RefAttributes<unknown>>;
|
|
20
|
+
|
|
21
|
+
export { PolymorphicComponent, ReactFactoryOptions, Slot, createAriaEnforcedComponent, createChildrenEnforcedComponent, createContractComponent, createContractedComponent, createPolymorphicComponent };
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import {
|
|
2
|
+
COMPONENT_DEFAULT_TAG,
|
|
3
|
+
SLOT_NAME,
|
|
4
|
+
SlotValidator,
|
|
5
|
+
Slottable,
|
|
6
|
+
applyDisplayName,
|
|
7
|
+
applySlot,
|
|
8
|
+
buildEngines,
|
|
9
|
+
buildRuntime,
|
|
10
|
+
cloneWithProps,
|
|
11
|
+
composeFilter,
|
|
12
|
+
createContractedPolymorphic,
|
|
13
|
+
createPolymorphic,
|
|
14
|
+
disabledProps,
|
|
15
|
+
invalidProps,
|
|
16
|
+
isFunction,
|
|
17
|
+
isPlainObject,
|
|
18
|
+
mergeRefs,
|
|
19
|
+
mergeSlotProps,
|
|
20
|
+
render
|
|
21
|
+
} from "../chunk-KDUNVQK2.js";
|
|
22
|
+
|
|
23
|
+
// ../../adapters/react/src/legacy/create-aria-enforced-component.ts
|
|
24
|
+
import { forwardRef as forwardRef2 } from "react";
|
|
25
|
+
|
|
26
|
+
// ../../adapters/react/src/legacy/slot/Slot.tsx
|
|
27
|
+
import { forwardRef } from "react";
|
|
28
|
+
|
|
29
|
+
// ../../adapters/react/src/legacy/slot/cloneSlotChild.ts
|
|
30
|
+
import { Fragment } from "react";
|
|
31
|
+
|
|
32
|
+
// ../../adapters/react/src/legacy/slot/composeRefs.ts
|
|
33
|
+
function isReactWarningGetter(getter) {
|
|
34
|
+
return isFunction(getter) && "isReactWarning" in getter;
|
|
35
|
+
}
|
|
36
|
+
function hasWarningGetter(obj, key) {
|
|
37
|
+
return isPlainObject(obj) && isReactWarningGetter(Object.getOwnPropertyDescriptor(obj, key)?.get);
|
|
38
|
+
}
|
|
39
|
+
function getElementRef(element) {
|
|
40
|
+
const el = element;
|
|
41
|
+
return isPlainObject(el) ? el.ref ?? null : null;
|
|
42
|
+
}
|
|
43
|
+
function getPropsRef(element) {
|
|
44
|
+
const props = element.props;
|
|
45
|
+
return isPlainObject(props) ? props.ref ?? null : null;
|
|
46
|
+
}
|
|
47
|
+
function getChildRef(element) {
|
|
48
|
+
return hasWarningGetter(element, "ref") ? getPropsRef(element) : getElementRef(element);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// ../../adapters/react/src/legacy/slot/cloneSlotChild.ts
|
|
52
|
+
function cloneSlotChild({ child, slotProps, ref }) {
|
|
53
|
+
const childProps = child.props;
|
|
54
|
+
const isFragment = child.type === Fragment;
|
|
55
|
+
const childRef = isFragment ? null : getChildRef(child);
|
|
56
|
+
const mergedRef = isFragment ? null : mergeRefs(ref, childRef);
|
|
57
|
+
const merged = mergeSlotProps(slotProps, childProps);
|
|
58
|
+
return cloneWithProps(child, merged, mergedRef);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// ../../adapters/react/src/legacy/slot/Slot.tsx
|
|
62
|
+
var Slot = forwardRef(function Slot2({ children, ...slotProps }, ref) {
|
|
63
|
+
return applySlot(children, slotProps, ref, cloneSlotChild);
|
|
64
|
+
});
|
|
65
|
+
Slot.displayName = SLOT_NAME;
|
|
66
|
+
|
|
67
|
+
// ../../adapters/react/src/legacy/normalize-children.ts
|
|
68
|
+
import { Children, isValidElement } from "react";
|
|
69
|
+
function normalizeChildren(children) {
|
|
70
|
+
return Children.toArray(children).filter(isValidElement);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ../../adapters/react/src/legacy/create-aria-enforced-component.ts
|
|
74
|
+
function createAriaEnforcedComponent(options) {
|
|
75
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
76
|
+
const strict = options.enforcement?.strict ?? "throw";
|
|
77
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
78
|
+
const runtime = createContractedPolymorphic(options);
|
|
79
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
80
|
+
const slotValidator = new SlotValidator(name, strict);
|
|
81
|
+
const Component = forwardRef2(
|
|
82
|
+
function PolymorphicComponent(props, ref) {
|
|
83
|
+
return render({
|
|
84
|
+
runtime,
|
|
85
|
+
props,
|
|
86
|
+
ref,
|
|
87
|
+
slotComponent,
|
|
88
|
+
normalizeChildren,
|
|
89
|
+
filterProps,
|
|
90
|
+
slotValidator
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
applyDisplayName(Component, name);
|
|
95
|
+
return Component;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ../../adapters/react/src/legacy/create-children-enforced-component.ts
|
|
99
|
+
import { forwardRef as forwardRef3 } from "react";
|
|
100
|
+
function createChildrenEnforcedComponent(options) {
|
|
101
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
102
|
+
const strict = options.enforcement?.strict ?? "throw";
|
|
103
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
104
|
+
const runtime = createPolymorphic(options);
|
|
105
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
106
|
+
const slotValidator = new SlotValidator(name, strict);
|
|
107
|
+
const { childrenEvaluator } = buildEngines(strict, options.enforcement?.children, name);
|
|
108
|
+
const Component = forwardRef3(
|
|
109
|
+
function PolymorphicComponent(props, ref) {
|
|
110
|
+
return render({
|
|
111
|
+
runtime,
|
|
112
|
+
props,
|
|
113
|
+
ref,
|
|
114
|
+
slotComponent,
|
|
115
|
+
normalizeChildren,
|
|
116
|
+
filterProps,
|
|
117
|
+
slotValidator,
|
|
118
|
+
...childrenEvaluator !== void 0 && { childrenEvaluator }
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
applyDisplayName(Component, name);
|
|
123
|
+
return Component;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ../../adapters/react/src/legacy/create-contract-component.ts
|
|
127
|
+
import { forwardRef as forwardRef4 } from "react";
|
|
128
|
+
function createContractComponent(options) {
|
|
129
|
+
const bundle = buildRuntime(
|
|
130
|
+
options,
|
|
131
|
+
Slot,
|
|
132
|
+
normalizeChildren
|
|
133
|
+
);
|
|
134
|
+
const Component = forwardRef4(
|
|
135
|
+
function PolymorphicComponent(props, ref) {
|
|
136
|
+
return render({ ...bundle, props, ref });
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
applyDisplayName(Component, options.name);
|
|
140
|
+
if (typeof bundle.runtime.options.defaultTag === "string") {
|
|
141
|
+
Object.assign(Component, { [COMPONENT_DEFAULT_TAG]: bundle.runtime.options.defaultTag });
|
|
142
|
+
}
|
|
143
|
+
return Component;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ../../adapters/react/src/legacy/create-contracted-component.ts
|
|
147
|
+
import { forwardRef as forwardRef5 } from "react";
|
|
148
|
+
function createContractedComponent(options) {
|
|
149
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
150
|
+
const strict = options.enforcement?.strict ?? "throw";
|
|
151
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
152
|
+
const runtime = createContractedPolymorphic(options);
|
|
153
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
154
|
+
const slotValidator = new SlotValidator(name, strict);
|
|
155
|
+
const { childrenEvaluator } = buildEngines(strict, options.enforcement?.children, name);
|
|
156
|
+
const Component = forwardRef5(
|
|
157
|
+
function PolymorphicComponent(props, ref) {
|
|
158
|
+
return render({
|
|
159
|
+
runtime,
|
|
160
|
+
props,
|
|
161
|
+
ref,
|
|
162
|
+
slotComponent,
|
|
163
|
+
normalizeChildren,
|
|
164
|
+
filterProps,
|
|
165
|
+
slotValidator,
|
|
166
|
+
...childrenEvaluator !== void 0 && { childrenEvaluator }
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
);
|
|
170
|
+
applyDisplayName(Component, name);
|
|
171
|
+
return Component;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
// ../../adapters/react/src/legacy/create-polymorphic-component.ts
|
|
175
|
+
import { forwardRef as forwardRef6 } from "react";
|
|
176
|
+
function createPolymorphicComponent(options) {
|
|
177
|
+
const name = options.name ?? "PolymorphicComponent";
|
|
178
|
+
const slotComponent = options.slotComponent ?? Slot;
|
|
179
|
+
const runtime = createPolymorphic(options);
|
|
180
|
+
const filterProps = composeFilter(/* @__PURE__ */ new Set(), options.filterProps);
|
|
181
|
+
const slotValidator = new SlotValidator(name, "throw");
|
|
182
|
+
const Component = forwardRef6(
|
|
183
|
+
function PolymorphicComponent(props, ref) {
|
|
184
|
+
return render({
|
|
185
|
+
runtime,
|
|
186
|
+
props,
|
|
187
|
+
ref,
|
|
188
|
+
slotComponent,
|
|
189
|
+
normalizeChildren,
|
|
190
|
+
filterProps,
|
|
191
|
+
slotValidator
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
applyDisplayName(Component, name);
|
|
196
|
+
return Component;
|
|
197
|
+
}
|
|
198
|
+
export {
|
|
199
|
+
Slot,
|
|
200
|
+
Slottable,
|
|
201
|
+
createAriaEnforcedComponent,
|
|
202
|
+
createChildrenEnforcedComponent,
|
|
203
|
+
createContractComponent,
|
|
204
|
+
createContractedComponent,
|
|
205
|
+
createPolymorphicComponent,
|
|
206
|
+
disabledProps,
|
|
207
|
+
invalidProps,
|
|
208
|
+
mergeRefs
|
|
209
|
+
};
|