@sprawlify/solid 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-C4aQI7lE.jsx +18 -0
- package/dist/chunk-CKcAJnC7.js +18 -0
- package/dist/collapsible-Cg7zPadX.js +129 -0
- package/dist/collapsible-CjuC6xYl.jsx +117 -0
- package/dist/collection-BiyRTWsX.js +219 -0
- package/dist/collection-BlnS2UQy.jsx +219 -0
- package/dist/components/accordion/index.d.ts +69 -0
- package/dist/components/accordion/index.js +183 -0
- package/dist/components/accordion/index.jsx +157 -0
- package/dist/components/angle-slider/index.d.ts +74 -0
- package/dist/components/angle-slider/index.js +155 -0
- package/dist/components/angle-slider/index.jsx +144 -0
- package/dist/components/avatar/index.d.ts +49 -0
- package/dist/components/avatar/index.js +95 -0
- package/dist/components/avatar/index.jsx +88 -0
- package/dist/components/bottom-sheet/index.d.ts +80 -0
- package/dist/components/bottom-sheet/index.js +218 -0
- package/dist/components/bottom-sheet/index.jsx +177 -0
- package/dist/components/carousel/index.d.ts +98 -0
- package/dist/components/carousel/index.js +207 -0
- package/dist/components/carousel/index.jsx +192 -0
- package/dist/components/checkbox/index.d.ts +138 -0
- package/dist/components/checkbox/index.js +265 -0
- package/dist/components/checkbox/index.jsx +247 -0
- package/dist/components/client-only/index.d.ts +10 -0
- package/dist/components/client-only/index.js +24 -0
- package/dist/components/client-only/index.jsx +15 -0
- package/dist/components/clipboard/index.d.ts +72 -0
- package/dist/components/clipboard/index.js +149 -0
- package/dist/components/clipboard/index.jsx +132 -0
- package/dist/components/collapsible/index.d.ts +60 -0
- package/dist/components/collapsible/index.js +8 -0
- package/dist/components/collapsible/index.jsx +8 -0
- package/dist/components/collection/index.d.ts +3 -0
- package/dist/components/collection/index.js +4 -0
- package/dist/components/collection/index.jsx +4 -0
- package/dist/components/field/index.d.ts +201 -0
- package/dist/components/field/index.js +9 -0
- package/dist/components/field/index.jsx +9 -0
- package/dist/components/fieldset/index.d.ts +109 -0
- package/dist/components/fieldset/index.js +8 -0
- package/dist/components/fieldset/index.jsx +8 -0
- package/dist/components/presence/index.d.ts +5 -0
- package/dist/components/presence/index.js +8 -0
- package/dist/components/presence/index.jsx +8 -0
- package/dist/components/select/index.d.ts +134 -0
- package/dist/components/select/index.js +361 -0
- package/dist/components/select/index.jsx +310 -0
- package/dist/compose-refs-CzyOb8yH.jsx +20 -0
- package/dist/compose-refs-vsrTrt13.js +20 -0
- package/dist/create-split-props-CQVsvhvg.jsx +41 -0
- package/dist/factory-B6RK6SH4.d.ts +14 -0
- package/dist/factory-CEdj72aS.js +47 -0
- package/dist/field-C_WuoXOj.js +287 -0
- package/dist/field-CphvciGc.jsx +259 -0
- package/dist/fieldset-BG-0ZqWT.jsx +167 -0
- package/dist/fieldset-D1BO0LmU.js +182 -0
- package/dist/index-C3ATynHc.d.ts +23 -0
- package/dist/index-DXheKbqg.d.ts +76 -0
- package/dist/index-NWiNyxpL.d.ts +38 -0
- package/dist/index-vSwYtc2L.d.ts +38 -0
- package/dist/index.d.ts +5 -29
- package/dist/index.js +4 -511
- package/dist/index.jsx +4 -497
- package/dist/presence-Bfjusgm3.js +79 -0
- package/dist/presence-arWh1hVd.jsx +66 -0
- package/dist/providers-CHqGPEsc.jsx +82 -0
- package/dist/providers-CQkAUunr.js +96 -0
- package/dist/render-strategy-COrlrUuR.js +12 -0
- package/dist/render-strategy-CZDG_yDi.jsx +12 -0
- package/dist/render-strategy-CtRkdWei.d.ts +9 -0
- package/dist/run-if-fn-DRWB51JE.jsx +421 -0
- package/dist/run-if-fn-eYlaegHy.js +421 -0
- package/dist/types-bQRbEioA.d.ts +9 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +2 -1
- package/dist/utils/index.jsx +2 -1
- package/dist/utils-DYer-9SY.js +0 -0
- package/dist/utils-DrvO4Hk3.jsx +0 -0
- package/package.json +62 -2
- /package/dist/{utils-DSKoW7eB.jsx → create-context-PS2j4mEo.js} +0 -0
- /package/dist/{utils-GEMuT7an.js → create-context-h3cXiEld.jsx} +0 -0
- /package/dist/{index-C_ThrXdH.d.ts → index-B0YoIRC4.d.ts} +0 -0
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
import { t as __export } from "../../chunk-C4aQI7lE.jsx";
|
|
2
|
+
import { a as useMachine, i as mergeProps$1, r as normalizeProps, t as runIfFn } from "../../run-if-fn-DRWB51JE.jsx";
|
|
3
|
+
import { t as createContext$1 } from "../../create-context-h3cXiEld.jsx";
|
|
4
|
+
import { i as useLocaleContext, o as useEnvironmentContext } from "../../providers-CHqGPEsc.jsx";
|
|
5
|
+
import { n as sprawlify, t as createSplitProps } from "../../create-split-props-CQVsvhvg.jsx";
|
|
6
|
+
import "../../render-strategy-CZDG_yDi.jsx";
|
|
7
|
+
import { t as composeRefs } from "../../compose-refs-CzyOb8yH.jsx";
|
|
8
|
+
import { a as splitPresenceProps, i as usePresence, n as usePresenceContext, t as PresenceProvider } from "../../presence-arWh1hVd.jsx";
|
|
9
|
+
import "../../fieldset-BG-0ZqWT.jsx";
|
|
10
|
+
import { m as useFieldContext } from "../../field-CphvciGc.jsx";
|
|
11
|
+
import { n as useListCollection, o as createListCollection } from "../../collection-BlnS2UQy.jsx";
|
|
12
|
+
import { Index, Show, createMemo, createUniqueId } from "solid-js";
|
|
13
|
+
import * as select from "@sprawlify/primitives/machines/select";
|
|
14
|
+
import { anatomy as selectAnatomy } from "@sprawlify/primitives/machines/select";
|
|
15
|
+
|
|
16
|
+
//#region src/components/select/use-select-context.ts
|
|
17
|
+
const [SelectProvider, useSelectContext] = createContext$1({
|
|
18
|
+
hookName: "useSelectContext",
|
|
19
|
+
providerName: "<SelectProvider />"
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/components/select/select-clear-trigger.tsx
|
|
24
|
+
const SelectClearTrigger = (props) => {
|
|
25
|
+
const select$1 = useSelectContext();
|
|
26
|
+
const mergedProps = mergeProps$1(() => select$1().getClearTriggerProps(), props);
|
|
27
|
+
return <sprawlify.button {...mergedProps} />;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/components/select/select-content.tsx
|
|
32
|
+
const SelectContent = (props) => {
|
|
33
|
+
const select$1 = useSelectContext();
|
|
34
|
+
const presenceApi = usePresenceContext();
|
|
35
|
+
const mergedProps = mergeProps$1(() => select$1().getContentProps(), () => presenceApi().presenceProps, props);
|
|
36
|
+
return <Show when={!presenceApi().unmounted}>
|
|
37
|
+
<sprawlify.div {...mergedProps} ref={composeRefs(presenceApi().ref, props.ref)} />
|
|
38
|
+
</Show>;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/components/select/select-context.tsx
|
|
43
|
+
const SelectContext = (props) => props.children(useSelectContext());
|
|
44
|
+
|
|
45
|
+
//#endregion
|
|
46
|
+
//#region src/components/select/select-control.tsx
|
|
47
|
+
const SelectControl = (props) => {
|
|
48
|
+
const select$1 = useSelectContext();
|
|
49
|
+
const mergedProps = mergeProps$1(() => select$1().getControlProps(), props);
|
|
50
|
+
return <sprawlify.div {...mergedProps} />;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/components/select/select-hidden-select.tsx
|
|
55
|
+
const SelectHiddenSelect = (props) => {
|
|
56
|
+
const select$1 = useSelectContext();
|
|
57
|
+
const mergedProps = mergeProps$1(() => select$1().getHiddenSelectProps(), props);
|
|
58
|
+
const isValueEmpty = createMemo(() => select$1().value.length === 0);
|
|
59
|
+
const field = useFieldContext();
|
|
60
|
+
return <sprawlify.select aria-describedby={field?.().ariaDescribedby} {...mergedProps}>
|
|
61
|
+
<Show when={isValueEmpty()}>
|
|
62
|
+
<option value="" />
|
|
63
|
+
</Show>
|
|
64
|
+
<Index each={select$1().collection.items}>
|
|
65
|
+
{(item) => <option value={select$1().collection.getItemValue(item()) ?? ""} disabled={select$1().collection.getItemDisabled(item())}>
|
|
66
|
+
{select$1().collection.stringifyItem(item())}
|
|
67
|
+
</option>}
|
|
68
|
+
</Index>
|
|
69
|
+
</sprawlify.select>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/components/select/select-indicator.tsx
|
|
74
|
+
const SelectIndicator = (props) => {
|
|
75
|
+
const select$1 = useSelectContext();
|
|
76
|
+
const mergedProps = mergeProps$1(() => select$1().getIndicatorProps(), props);
|
|
77
|
+
return <sprawlify.div {...mergedProps} />;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region src/components/select/use-select-item-context.ts
|
|
82
|
+
const [SelectItemProvider, useSelectItemContext] = createContext$1({
|
|
83
|
+
hookName: "useSelectItemContext",
|
|
84
|
+
providerName: "<SelectItemProvider />"
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/components/select/use-select-item-props-context.ts
|
|
89
|
+
const [SelectItemPropsProvider, useSelectItemPropsContext] = createContext$1({
|
|
90
|
+
hookName: "useSelectItemPropsContext",
|
|
91
|
+
providerName: "<SelectItemPropsProvider />"
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
//#endregion
|
|
95
|
+
//#region src/components/select/select-item.tsx
|
|
96
|
+
const SelectItem = (props) => {
|
|
97
|
+
const [itemProps, localProps] = createSplitProps()(props, ["item", "persistFocus"]);
|
|
98
|
+
const select$1 = useSelectContext();
|
|
99
|
+
const mergedProps = mergeProps$1(() => select$1().getItemProps(itemProps), localProps);
|
|
100
|
+
const itemState = createMemo(() => select$1().getItemState(itemProps));
|
|
101
|
+
return <SelectItemPropsProvider value={itemProps}>
|
|
102
|
+
<SelectItemProvider value={itemState}>
|
|
103
|
+
<sprawlify.div {...mergedProps} />
|
|
104
|
+
</SelectItemProvider>
|
|
105
|
+
</SelectItemPropsProvider>;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region src/components/select/select-item-context.tsx
|
|
110
|
+
const SelectItemContext = (props) => props.children(useSelectItemContext());
|
|
111
|
+
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/components/select/use-select-item-group-props-context.ts
|
|
114
|
+
const [SelectItemGroupPropsProvider, useSelectItemGroupPropsContext] = createContext$1({
|
|
115
|
+
hookName: "useSelectItemGroupPropsContext",
|
|
116
|
+
providerName: "<SelectItemGroupPropsProvider />"
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
//#endregion
|
|
120
|
+
//#region src/components/select/select-item-group.tsx
|
|
121
|
+
const SelectItemGroup = (props) => {
|
|
122
|
+
const [_itemGroupProps, localProps] = createSplitProps()(props, ["id"]);
|
|
123
|
+
const select$1 = useSelectContext();
|
|
124
|
+
const itemGroupProps = mergeProps$1({ id: createUniqueId() }, _itemGroupProps);
|
|
125
|
+
const mergedProps = mergeProps$1(() => select$1().getItemGroupProps(itemGroupProps), localProps);
|
|
126
|
+
return <SelectItemGroupPropsProvider value={itemGroupProps}>
|
|
127
|
+
<sprawlify.div {...mergedProps} />
|
|
128
|
+
</SelectItemGroupPropsProvider>;
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region src/components/select/select-item-group-label.tsx
|
|
133
|
+
const SelectItemGroupLabel = (props) => {
|
|
134
|
+
const select$1 = useSelectContext();
|
|
135
|
+
const itemGroupProps = useSelectItemGroupPropsContext();
|
|
136
|
+
const mergedProps = mergeProps$1(() => select$1().getItemGroupLabelProps({ htmlFor: itemGroupProps.id }), props);
|
|
137
|
+
return <sprawlify.div {...mergedProps} />;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
//#endregion
|
|
141
|
+
//#region src/components/select/select-item-indicator.tsx
|
|
142
|
+
const SelectItemIndicator = (props) => {
|
|
143
|
+
const select$1 = useSelectContext();
|
|
144
|
+
const itemProps = useSelectItemPropsContext();
|
|
145
|
+
const mergedProps = mergeProps$1(() => select$1().getItemIndicatorProps(itemProps), props);
|
|
146
|
+
return <sprawlify.div {...mergedProps} />;
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
//#endregion
|
|
150
|
+
//#region src/components/select/select-item-text.tsx
|
|
151
|
+
const SelectItemText = (props) => {
|
|
152
|
+
const select$1 = useSelectContext();
|
|
153
|
+
const itemProps = useSelectItemPropsContext();
|
|
154
|
+
const mergedProps = mergeProps$1(() => select$1().getItemTextProps(itemProps), props);
|
|
155
|
+
return <sprawlify.span {...mergedProps} />;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
//#endregion
|
|
159
|
+
//#region src/components/select/select-label.tsx
|
|
160
|
+
const SelectLabel = (props) => {
|
|
161
|
+
const select$1 = useSelectContext();
|
|
162
|
+
const mergedProps = mergeProps$1(() => select$1().getLabelProps(), props);
|
|
163
|
+
return <sprawlify.label {...mergedProps} />;
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
//#endregion
|
|
167
|
+
//#region src/components/select/select-list.tsx
|
|
168
|
+
const SelectList = (props) => {
|
|
169
|
+
const select$1 = useSelectContext();
|
|
170
|
+
const mergedProps = mergeProps$1(() => select$1().getListProps(), props);
|
|
171
|
+
return <sprawlify.div {...mergedProps} />;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/components/select/select-positioner.tsx
|
|
176
|
+
const SelectPositioner = (props) => {
|
|
177
|
+
const select$1 = useSelectContext();
|
|
178
|
+
const presenceApi = usePresenceContext();
|
|
179
|
+
const mergedProps = mergeProps$1(() => select$1().getPositionerProps(), props);
|
|
180
|
+
return <Show when={!presenceApi().unmounted}>
|
|
181
|
+
<sprawlify.div {...mergedProps} />
|
|
182
|
+
</Show>;
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region src/components/select/use-select.ts
|
|
187
|
+
const useSelect = (props) => {
|
|
188
|
+
const id = createUniqueId();
|
|
189
|
+
const locale = useLocaleContext();
|
|
190
|
+
const environment = useEnvironmentContext();
|
|
191
|
+
const field = useFieldContext();
|
|
192
|
+
const machineProps = createMemo(() => ({
|
|
193
|
+
id,
|
|
194
|
+
ids: {
|
|
195
|
+
label: field?.().ids.label,
|
|
196
|
+
hiddenSelect: field?.().ids.control
|
|
197
|
+
},
|
|
198
|
+
disabled: field?.().disabled,
|
|
199
|
+
readOnly: field?.().readOnly,
|
|
200
|
+
invalid: field?.().invalid,
|
|
201
|
+
required: field?.().required,
|
|
202
|
+
dir: locale().dir,
|
|
203
|
+
getRootNode: environment().getRootNode,
|
|
204
|
+
...runIfFn(props)
|
|
205
|
+
}));
|
|
206
|
+
const service = useMachine(select.machine, machineProps);
|
|
207
|
+
return createMemo(() => select.connect(service, normalizeProps));
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
//#endregion
|
|
211
|
+
//#region src/components/select/select-root.tsx
|
|
212
|
+
const SelectRoot = (props) => {
|
|
213
|
+
const [presenceProps, selectProps] = splitPresenceProps(props);
|
|
214
|
+
const [useSelectProps, localProps] = createSplitProps()(selectProps, [
|
|
215
|
+
"closeOnSelect",
|
|
216
|
+
"collection",
|
|
217
|
+
"composite",
|
|
218
|
+
"defaultHighlightedValue",
|
|
219
|
+
"defaultOpen",
|
|
220
|
+
"defaultValue",
|
|
221
|
+
"deselectable",
|
|
222
|
+
"disabled",
|
|
223
|
+
"form",
|
|
224
|
+
"highlightedValue",
|
|
225
|
+
"id",
|
|
226
|
+
"ids",
|
|
227
|
+
"invalid",
|
|
228
|
+
"loopFocus",
|
|
229
|
+
"multiple",
|
|
230
|
+
"name",
|
|
231
|
+
"onFocusOutside",
|
|
232
|
+
"onHighlightChange",
|
|
233
|
+
"onInteractOutside",
|
|
234
|
+
"onOpenChange",
|
|
235
|
+
"onPointerDownOutside",
|
|
236
|
+
"onSelect",
|
|
237
|
+
"onValueChange",
|
|
238
|
+
"open",
|
|
239
|
+
"positioning",
|
|
240
|
+
"readOnly",
|
|
241
|
+
"required",
|
|
242
|
+
"scrollToIndexFn",
|
|
243
|
+
"value"
|
|
244
|
+
]);
|
|
245
|
+
const select$1 = useSelect(useSelectProps);
|
|
246
|
+
const presenceApi = usePresence(mergeProps$1(() => ({ present: select$1().open }), presenceProps));
|
|
247
|
+
const mergedProps = mergeProps$1(() => select$1().getRootProps(), localProps);
|
|
248
|
+
return <SelectProvider value={select$1}>
|
|
249
|
+
<PresenceProvider value={presenceApi}>
|
|
250
|
+
<sprawlify.div {...mergedProps} />
|
|
251
|
+
</PresenceProvider>
|
|
252
|
+
</SelectProvider>;
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/components/select/select-root-provider.tsx
|
|
257
|
+
const SelectRootProvider = (props) => {
|
|
258
|
+
const [presenceProps, selectProps] = splitPresenceProps(props);
|
|
259
|
+
const [{ value: select$1 }, localProps] = createSplitProps()(selectProps, ["value"]);
|
|
260
|
+
const presence = usePresence(mergeProps$1(() => ({ present: select$1().open }), presenceProps));
|
|
261
|
+
const mergedProps = mergeProps$1(() => select$1().getRootProps(), localProps);
|
|
262
|
+
return <SelectProvider value={select$1}>
|
|
263
|
+
<PresenceProvider value={presence}>
|
|
264
|
+
<sprawlify.div {...mergedProps} />
|
|
265
|
+
</PresenceProvider>
|
|
266
|
+
</SelectProvider>;
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
//#endregion
|
|
270
|
+
//#region src/components/select/select-trigger.tsx
|
|
271
|
+
const SelectTrigger = (props) => {
|
|
272
|
+
const select$1 = useSelectContext();
|
|
273
|
+
const mergedProps = mergeProps$1(() => select$1().getTriggerProps(), props);
|
|
274
|
+
return <sprawlify.button {...mergedProps} />;
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
//#endregion
|
|
278
|
+
//#region src/components/select/select-value-text.tsx
|
|
279
|
+
const SelectValueText = (props) => {
|
|
280
|
+
const select$1 = useSelectContext();
|
|
281
|
+
const mergedProps = mergeProps$1(() => select$1().getValueTextProps(), props);
|
|
282
|
+
return <sprawlify.span {...mergedProps}>{select$1().valueAsString || props.placeholder}</sprawlify.span>;
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
//#endregion
|
|
286
|
+
//#region src/components/select/select.ts
|
|
287
|
+
var select_exports = /* @__PURE__ */ __export({
|
|
288
|
+
ClearTrigger: () => SelectClearTrigger,
|
|
289
|
+
Content: () => SelectContent,
|
|
290
|
+
Context: () => SelectContext,
|
|
291
|
+
Control: () => SelectControl,
|
|
292
|
+
HiddenSelect: () => SelectHiddenSelect,
|
|
293
|
+
Indicator: () => SelectIndicator,
|
|
294
|
+
Item: () => SelectItem,
|
|
295
|
+
ItemContext: () => SelectItemContext,
|
|
296
|
+
ItemGroup: () => SelectItemGroup,
|
|
297
|
+
ItemGroupLabel: () => SelectItemGroupLabel,
|
|
298
|
+
ItemIndicator: () => SelectItemIndicator,
|
|
299
|
+
ItemText: () => SelectItemText,
|
|
300
|
+
Label: () => SelectLabel,
|
|
301
|
+
List: () => SelectList,
|
|
302
|
+
Positioner: () => SelectPositioner,
|
|
303
|
+
Root: () => SelectRoot,
|
|
304
|
+
RootProvider: () => SelectRootProvider,
|
|
305
|
+
Trigger: () => SelectTrigger,
|
|
306
|
+
ValueText: () => SelectValueText
|
|
307
|
+
});
|
|
308
|
+
|
|
309
|
+
//#endregion
|
|
310
|
+
export { select_exports as Select, SelectClearTrigger, SelectContent, SelectContext, SelectControl, SelectHiddenSelect, SelectIndicator, SelectItem, SelectItemContext, SelectItemGroup, SelectItemGroupLabel, SelectItemIndicator, SelectItemText, SelectLabel, SelectList, SelectPositioner, SelectRoot, SelectRootProvider, SelectTrigger, SelectValueText, createListCollection, selectAnatomy, useListCollection, useSelect, useSelectContext, useSelectItemContext };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createEffect } from "solid-js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/compose-refs.ts
|
|
4
|
+
const isRefFn = (ref) => typeof ref === "function";
|
|
5
|
+
const setRefs = (refs, node) => {
|
|
6
|
+
for (const ref of refs) if (isRefFn(ref)) ref(node);
|
|
7
|
+
};
|
|
8
|
+
function composeRefs(...refs) {
|
|
9
|
+
let node = null;
|
|
10
|
+
createEffect(() => {
|
|
11
|
+
setRefs(refs, node);
|
|
12
|
+
});
|
|
13
|
+
return (el) => {
|
|
14
|
+
node = el;
|
|
15
|
+
setRefs(refs, el);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { composeRefs as t };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { createEffect } from "solid-js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/compose-refs.ts
|
|
4
|
+
const isRefFn = (ref) => typeof ref === "function";
|
|
5
|
+
const setRefs = (refs, node) => {
|
|
6
|
+
for (const ref of refs) if (isRefFn(ref)) ref(node);
|
|
7
|
+
};
|
|
8
|
+
function composeRefs(...refs) {
|
|
9
|
+
let node = null;
|
|
10
|
+
createEffect(() => {
|
|
11
|
+
setRefs(refs, node);
|
|
12
|
+
});
|
|
13
|
+
return (el) => {
|
|
14
|
+
node = el;
|
|
15
|
+
setRefs(refs, el);
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//#endregion
|
|
20
|
+
export { composeRefs as t };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { i as mergeProps$1 } from "./run-if-fn-DRWB51JE.jsx";
|
|
2
|
+
import { Show, splitProps } from "solid-js";
|
|
3
|
+
import { Dynamic } from "solid-js/web";
|
|
4
|
+
|
|
5
|
+
//#region src/components/factory.tsx
|
|
6
|
+
const withAsProp = (Component) => {
|
|
7
|
+
const SprawlifyComponent = (props) => {
|
|
8
|
+
const [localProps, parentProps] = splitProps(props, ["asChild"]);
|
|
9
|
+
return <Show when={localProps.asChild} fallback={<Dynamic component={Component} {...parentProps} />}>
|
|
10
|
+
{(asChild) => {
|
|
11
|
+
const propsFn = (userProps) => {
|
|
12
|
+
const [, restProps] = splitProps(parentProps, ["ref"]);
|
|
13
|
+
return mergeProps$1(restProps, userProps);
|
|
14
|
+
};
|
|
15
|
+
return asChild()(propsFn);
|
|
16
|
+
}}
|
|
17
|
+
</Show>;
|
|
18
|
+
};
|
|
19
|
+
return SprawlifyComponent;
|
|
20
|
+
};
|
|
21
|
+
function jsxFactory() {
|
|
22
|
+
const cache = /* @__PURE__ */ new Map();
|
|
23
|
+
return new Proxy(withAsProp, {
|
|
24
|
+
apply(_target, _thisArg, argArray) {
|
|
25
|
+
return withAsProp(argArray[0]);
|
|
26
|
+
},
|
|
27
|
+
get(_, element) {
|
|
28
|
+
const asElement = element;
|
|
29
|
+
if (!cache.has(asElement)) cache.set(asElement, withAsProp(asElement));
|
|
30
|
+
return cache.get(asElement);
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
const sprawlify = jsxFactory();
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/utils/create-split-props.ts
|
|
38
|
+
const createSplitProps = () => (props, keys) => splitProps(props, keys);
|
|
39
|
+
|
|
40
|
+
//#endregion
|
|
41
|
+
export { sprawlify as n, createSplitProps as t };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { JSX } from "solid-js";
|
|
2
|
+
|
|
3
|
+
//#region src/components/factory.d.ts
|
|
4
|
+
type ElementType = keyof JSX.IntrinsicElements;
|
|
5
|
+
type ParentProps$1<T extends ElementType> = (userProps?: JSX.IntrinsicElements[T]) => JSX.HTMLAttributes<any>;
|
|
6
|
+
type PolymorphicProps<T extends ElementType> = {
|
|
7
|
+
/**
|
|
8
|
+
* Use the provided child element as the default rendered element, combining their props and behavior.
|
|
9
|
+
*/
|
|
10
|
+
asChild?: (props: ParentProps$1<T>) => JSX.Element;
|
|
11
|
+
};
|
|
12
|
+
type HTMLProps<E$1 extends ElementType> = JSX.IntrinsicElements[E$1];
|
|
13
|
+
//#endregion
|
|
14
|
+
export { PolymorphicProps as n, HTMLProps as t };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { i as mergeProps$2 } from "./run-if-fn-eYlaegHy.js";
|
|
2
|
+
import { Show, splitProps } from "solid-js";
|
|
3
|
+
import { Dynamic, createComponent, mergeProps as mergeProps$1 } from "solid-js/web";
|
|
4
|
+
|
|
5
|
+
//#region src/utils/create-split-props.ts
|
|
6
|
+
const createSplitProps = () => (props, keys) => splitProps(props, keys);
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
//#region src/components/factory.tsx
|
|
10
|
+
const withAsProp = (Component) => {
|
|
11
|
+
const SprawlifyComponent = (props) => {
|
|
12
|
+
const [localProps, parentProps] = splitProps(props, ["asChild"]);
|
|
13
|
+
return createComponent(Show, {
|
|
14
|
+
get when() {
|
|
15
|
+
return localProps.asChild;
|
|
16
|
+
},
|
|
17
|
+
get fallback() {
|
|
18
|
+
return createComponent(Dynamic, mergeProps$1({ component: Component }, parentProps));
|
|
19
|
+
},
|
|
20
|
+
children: (asChild) => {
|
|
21
|
+
const propsFn = (userProps) => {
|
|
22
|
+
const [, restProps] = splitProps(parentProps, ["ref"]);
|
|
23
|
+
return mergeProps$2(restProps, userProps);
|
|
24
|
+
};
|
|
25
|
+
return asChild()(propsFn);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
return SprawlifyComponent;
|
|
30
|
+
};
|
|
31
|
+
function jsxFactory() {
|
|
32
|
+
const cache = /* @__PURE__ */ new Map();
|
|
33
|
+
return new Proxy(withAsProp, {
|
|
34
|
+
apply(_target, _thisArg, argArray) {
|
|
35
|
+
return withAsProp(argArray[0]);
|
|
36
|
+
},
|
|
37
|
+
get(_, element) {
|
|
38
|
+
const asElement = element;
|
|
39
|
+
if (!cache.has(asElement)) cache.set(asElement, withAsProp(asElement));
|
|
40
|
+
return cache.get(asElement);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const sprawlify = jsxFactory();
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { createSplitProps as n, sprawlify as t };
|