@simple-base/solid 0.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/dist/index.js ADDED
@@ -0,0 +1,941 @@
1
+ import { Portal, createComponent, effect, insert, memo, mergeProps, spread, template, use } from "solid-js/web";
2
+ import { For, Show, createContext, createEffect, createMemo, createSignal, createUniqueId, on, onCleanup, onMount, splitProps, useContext } from "solid-js";
3
+ import { cn } from "cn";
4
+ import { badgeDefaults, buttonDefaults } from "@simple-base/contracts";
5
+ import * as combobox from "@zag-js/combobox";
6
+ import { mergeProps as mergeProps$1, normalizeProps, useMachine } from "@zag-js/solid";
7
+ import * as select from "@zag-js/select";
8
+ //#region src/components/AlertDialog.tsx
9
+ var _tmpl$$10 = /*#__PURE__*/ template(`<dialog>`);
10
+ var _tmpl$2$3 = /*#__PURE__*/ template(`<div>`);
11
+ var _tmpl$3$3 = /*#__PURE__*/ template(`<p>`);
12
+ var _tmpl$4$3 = /*#__PURE__*/ template(`<h3>`);
13
+ const AlertDialogContext = createContext(null);
14
+ function useAlertDialog() {
15
+ const context = useContext(AlertDialogContext);
16
+ if (!context) throw new Error("useAlertDialog must be used within an AlertDialogRoot");
17
+ return context;
18
+ }
19
+ function AlertDialogRoot(props) {
20
+ const [local, rest] = splitProps(props, ["class"]);
21
+ const id = createUniqueId();
22
+ const titleId = `${id}-title`;
23
+ const descriptionId = `${id}-description`;
24
+ return createComponent(AlertDialogContext.Provider, {
25
+ value: {
26
+ titleId,
27
+ descriptionId
28
+ },
29
+ get children() {
30
+ var _el$ = _tmpl$$10();
31
+ spread(_el$, mergeProps(rest, {
32
+ "role": "alertdialog",
33
+ "aria-labelledby": titleId,
34
+ "aria-describedby": descriptionId,
35
+ get ["class"]() {
36
+ return cn("sb-alert-dialog", local.class);
37
+ }
38
+ }), false, false);
39
+ return _el$;
40
+ }
41
+ });
42
+ }
43
+ function AlertDialogIcon(props) {
44
+ const [local, rest] = splitProps(props, ["class", "aria-hidden"]);
45
+ return (() => {
46
+ var _el$2 = _tmpl$2$3();
47
+ spread(_el$2, mergeProps(rest, {
48
+ get ["aria-hidden"]() {
49
+ return local["aria-hidden"] ?? true;
50
+ },
51
+ get ["class"]() {
52
+ return cn("sb-alert-dialog-icon", local.class);
53
+ }
54
+ }), false, false);
55
+ return _el$2;
56
+ })();
57
+ }
58
+ function AlertDialogContent(props) {
59
+ const [local, rest] = splitProps(props, ["class"]);
60
+ return (() => {
61
+ var _el$3 = _tmpl$2$3();
62
+ spread(_el$3, mergeProps(rest, { get ["class"]() {
63
+ return cn("sb-alert-dialog-content", local.class);
64
+ } }), false, false);
65
+ return _el$3;
66
+ })();
67
+ }
68
+ function AlertDialogKicker(props) {
69
+ const [local, rest] = splitProps(props, ["class"]);
70
+ return (() => {
71
+ var _el$4 = _tmpl$3$3();
72
+ spread(_el$4, mergeProps(rest, { get ["class"]() {
73
+ return cn("sb-alert-dialog-kicker", local.class);
74
+ } }), false, false);
75
+ return _el$4;
76
+ })();
77
+ }
78
+ function AlertDialogTitle(props) {
79
+ const { titleId } = useAlertDialog();
80
+ const [local, rest] = splitProps(props, ["class"]);
81
+ return (() => {
82
+ var _el$5 = _tmpl$4$3();
83
+ spread(_el$5, mergeProps(rest, {
84
+ "id": titleId,
85
+ get ["class"]() {
86
+ return cn("sb-alert-dialog-title", local.class);
87
+ }
88
+ }), false, false);
89
+ return _el$5;
90
+ })();
91
+ }
92
+ function AlertDialogDescription(props) {
93
+ const { descriptionId } = useAlertDialog();
94
+ const [local, rest] = splitProps(props, ["class"]);
95
+ return (() => {
96
+ var _el$6 = _tmpl$3$3();
97
+ spread(_el$6, mergeProps(rest, {
98
+ "id": descriptionId,
99
+ get ["class"]() {
100
+ return cn("sb-alert-dialog-description", local.class);
101
+ }
102
+ }), false, false);
103
+ return _el$6;
104
+ })();
105
+ }
106
+ function AlertDialogActions(props) {
107
+ const [local, rest] = splitProps(props, ["class"]);
108
+ return (() => {
109
+ var _el$7 = _tmpl$2$3();
110
+ spread(_el$7, mergeProps(rest, { get ["class"]() {
111
+ return cn("sb-alert-dialog-actions", local.class);
112
+ } }), false, false);
113
+ return _el$7;
114
+ })();
115
+ }
116
+ const AlertDialog = Object.assign(AlertDialogRoot, {
117
+ Icon: AlertDialogIcon,
118
+ Content: AlertDialogContent,
119
+ Kicker: AlertDialogKicker,
120
+ Title: AlertDialogTitle,
121
+ Description: AlertDialogDescription,
122
+ Actions: AlertDialogActions
123
+ });
124
+ //#endregion
125
+ //#region src/components/Badge.tsx
126
+ var _tmpl$$9 = /*#__PURE__*/ template(`<span>`);
127
+ function Badge(props) {
128
+ const [local, rest] = splitProps(props, [
129
+ "class",
130
+ "variant",
131
+ "size"
132
+ ]);
133
+ return (() => {
134
+ var _el$ = _tmpl$$9();
135
+ spread(_el$, mergeProps(rest, {
136
+ get ["class"]() {
137
+ return cn("sb-badge", local.class);
138
+ },
139
+ get ["data-variant"]() {
140
+ return local.variant ?? badgeDefaults.variant;
141
+ },
142
+ get ["data-size"]() {
143
+ return local.size ?? badgeDefaults.size;
144
+ }
145
+ }), false, false);
146
+ return _el$;
147
+ })();
148
+ }
149
+ //#endregion
150
+ //#region src/components/Button.tsx
151
+ var _tmpl$$8 = /*#__PURE__*/ template(`<button>`);
152
+ function Button(props) {
153
+ const [local, rest] = splitProps(props, [
154
+ "class",
155
+ "variant",
156
+ "size"
157
+ ]);
158
+ return (() => {
159
+ var _el$ = _tmpl$$8();
160
+ spread(_el$, mergeProps(rest, {
161
+ get ["class"]() {
162
+ return cn("sb-button", local.class);
163
+ },
164
+ get ["data-variant"]() {
165
+ return local.variant ?? buttonDefaults.variant;
166
+ },
167
+ get ["data-size"]() {
168
+ return local.size ?? buttonDefaults.size;
169
+ }
170
+ }), false, false);
171
+ return _el$;
172
+ })();
173
+ }
174
+ //#endregion
175
+ //#region src/components/Switch.tsx
176
+ var _tmpl$$7 = /*#__PURE__*/ template(`<input>`);
177
+ function Switch(props) {
178
+ const [local, rest] = splitProps(props, ["class"]);
179
+ return (() => {
180
+ var _el$ = _tmpl$$7();
181
+ spread(_el$, mergeProps(rest, {
182
+ "type": "checkbox",
183
+ "role": "switch",
184
+ get ["class"]() {
185
+ return cn("sb-switch", local.class);
186
+ }
187
+ }), false, false);
188
+ return _el$;
189
+ })();
190
+ }
191
+ //#endregion
192
+ //#region src/components/Checkbox.tsx
193
+ var _tmpl$$6 = /*#__PURE__*/ template(`<input>`);
194
+ function Checkbox(props) {
195
+ const [local, rest] = splitProps(props, ["class"]);
196
+ return (() => {
197
+ var _el$ = _tmpl$$6();
198
+ spread(_el$, mergeProps(rest, {
199
+ "type": "checkbox",
200
+ get ["class"]() {
201
+ return cn("sb-checkbox", local.class);
202
+ }
203
+ }), false, false);
204
+ return _el$;
205
+ })();
206
+ }
207
+ //#endregion
208
+ //#region src/components/Input.tsx
209
+ var _tmpl$$5 = /*#__PURE__*/ template(`<input>`);
210
+ function Input(props) {
211
+ const [local, rest] = splitProps(props, ["class"]);
212
+ return (() => {
213
+ var _el$ = _tmpl$$5();
214
+ spread(_el$, mergeProps(rest, { get ["class"]() {
215
+ return cn("sb-input", local.class);
216
+ } }), false, false);
217
+ return _el$;
218
+ })();
219
+ }
220
+ //#endregion
221
+ //#region src/components/Radio.tsx
222
+ var _tmpl$$4 = /*#__PURE__*/ template(`<input>`);
223
+ function Radio(props) {
224
+ const [local, rest] = splitProps(props, ["class"]);
225
+ return (() => {
226
+ var _el$ = _tmpl$$4();
227
+ spread(_el$, mergeProps(rest, {
228
+ "type": "radio",
229
+ get ["class"]() {
230
+ return cn("sb-radio", local.class);
231
+ }
232
+ }), false, false);
233
+ return _el$;
234
+ })();
235
+ }
236
+ //#endregion
237
+ //#region src/components/TextArea.tsx
238
+ var _tmpl$$3 = /*#__PURE__*/ template(`<textarea>`);
239
+ function TextArea(props) {
240
+ const [local, rest] = splitProps(props, ["class"]);
241
+ return (() => {
242
+ var _el$ = _tmpl$$3();
243
+ spread(_el$, mergeProps(rest, { get ["class"]() {
244
+ return cn("sb-textarea", local.class);
245
+ } }), false, false);
246
+ return _el$;
247
+ })();
248
+ }
249
+ //#endregion
250
+ //#region src/mergeWidgetProps.ts
251
+ const hyphenate = (property) => property.startsWith("--") ? property : property.replace(/[A-Z]/g, (char) => `-${char.toLowerCase()}`);
252
+ const serializeStyle = (style) => {
253
+ if (typeof style === "string") return style;
254
+ let css = "";
255
+ for (const property in style) {
256
+ const value = style[property];
257
+ if (value == null || value === "") continue;
258
+ const declaration = `${hyphenate(property)}: ${value}`;
259
+ css = css ? `${css};${declaration}` : declaration;
260
+ }
261
+ return css;
262
+ };
263
+ const composeStyles = (widgetStyle, consumerStyle) => {
264
+ if (consumerStyle == null) return widgetStyle;
265
+ if (widgetStyle == null) return consumerStyle;
266
+ const widgetCss = serializeStyle(widgetStyle);
267
+ const consumerCss = serializeStyle(consumerStyle);
268
+ if (!widgetCss) return consumerStyle;
269
+ if (!consumerCss) return widgetStyle;
270
+ return `${widgetCss};${consumerCss}`;
271
+ };
272
+ function mergeWidgetProps(behavior, props) {
273
+ const normalized = new Proxy(props, { get(target, key, receiver) {
274
+ const value = Reflect.get(target, key, receiver);
275
+ if (typeof key === "string" && key.startsWith("on") && Array.isArray(value) && typeof value[0] === "function") return (event) => value[0](value[1], event);
276
+ return value;
277
+ } });
278
+ const { style: widgetStyle, ...behaviorProps } = behavior;
279
+ const { style: consumerStyle, ...consumerProps } = normalized;
280
+ const merged = mergeProps$1(behaviorProps, consumerProps);
281
+ const style = composeStyles(widgetStyle, consumerStyle);
282
+ return style === void 0 ? merged : {
283
+ ...merged,
284
+ style
285
+ };
286
+ }
287
+ //#endregion
288
+ //#region src/components/Combobox.tsx
289
+ var _tmpl$$2 = /*#__PURE__*/ template(`<div>`);
290
+ var _tmpl$2$2 = /*#__PURE__*/ template(`<label>`);
291
+ var _tmpl$3$2 = /*#__PURE__*/ template(`<input>`);
292
+ var _tmpl$4$2 = /*#__PURE__*/ template(`<button>`);
293
+ var _tmpl$5$2 = /*#__PURE__*/ template(`<ul>`);
294
+ var _tmpl$6$2 = /*#__PURE__*/ template(`<li>`);
295
+ const ComboboxContext = createContext(null);
296
+ function useCombobox() {
297
+ const context = useContext(ComboboxContext);
298
+ if (!context) throw new Error("useCombobox must be used within a Combobox");
299
+ return context;
300
+ }
301
+ function ComboboxRoot(props) {
302
+ const [local, rest] = splitProps(props, [
303
+ "class",
304
+ "children",
305
+ "id",
306
+ "label",
307
+ "name",
308
+ "placeholder",
309
+ "options",
310
+ "value",
311
+ "disabled",
312
+ "placement",
313
+ "invalid",
314
+ "required",
315
+ "onValueChange",
316
+ "onOpenChange"
317
+ ]);
318
+ const [query, setQuery] = createSignal("");
319
+ const options = createMemo(() => {
320
+ const search = query().toLowerCase();
321
+ return local.options.filter((option) => option.label.toLowerCase().includes(search));
322
+ });
323
+ const collection = createMemo(() => combobox.collection({
324
+ items: options(),
325
+ itemToValue: (item) => item.value,
326
+ itemToString: (item) => item.label,
327
+ isItemDisabled: (item) => item.disabled ?? false
328
+ }));
329
+ const positioning = createMemo(() => local.placement ? { placement: local.placement } : void 0);
330
+ const service = useMachine(combobox.machine, {
331
+ get id() {
332
+ return local.id;
333
+ },
334
+ get ids() {
335
+ return { root: local.id };
336
+ },
337
+ get name() {
338
+ return local.name;
339
+ },
340
+ get placeholder() {
341
+ return local.placeholder;
342
+ },
343
+ get disabled() {
344
+ return local.disabled;
345
+ },
346
+ get invalid() {
347
+ return local.invalid;
348
+ },
349
+ get required() {
350
+ return local.required;
351
+ },
352
+ get value() {
353
+ if (local.value === void 0) return void 0;
354
+ return local.value === "" ? [] : [local.value];
355
+ },
356
+ get positioning() {
357
+ return positioning();
358
+ },
359
+ get collection() {
360
+ return collection();
361
+ },
362
+ onOpenChange({ open, reason }) {
363
+ if (open && reason !== "input-change") setQuery("");
364
+ local.onOpenChange?.(open);
365
+ },
366
+ onInputValueChange({ inputValue, reason }) {
367
+ setQuery(reason === "input-change" ? inputValue : "");
368
+ },
369
+ onValueChange({ value }) {
370
+ local.onValueChange(value[0] ?? "");
371
+ }
372
+ });
373
+ const api = createMemo(() => combobox.connect(service, normalizeProps));
374
+ return createComponent(ComboboxContext.Provider, {
375
+ value: {
376
+ label: () => local.label,
377
+ options,
378
+ api
379
+ },
380
+ get children() {
381
+ var _el$ = _tmpl$$2();
382
+ spread(_el$, mergeProps(() => mergeWidgetProps(api().getRootProps(), rest), { get ["class"]() {
383
+ return cn("sb-combobox", local.class);
384
+ } }), false, true);
385
+ insert(_el$, () => local.children);
386
+ return _el$;
387
+ }
388
+ });
389
+ }
390
+ function ComboboxLabel(props) {
391
+ const { api, label } = useCombobox();
392
+ const [local, rest] = splitProps(props, ["class", "children"]);
393
+ return (() => {
394
+ var _el$2 = _tmpl$2$2();
395
+ spread(_el$2, mergeProps(() => mergeWidgetProps(api().getLabelProps(), rest), { get ["class"]() {
396
+ return cn("sb-combobox-label", local.class);
397
+ } }), false, true);
398
+ insert(_el$2, () => local.children ?? label());
399
+ return _el$2;
400
+ })();
401
+ }
402
+ function ComboboxControl(props) {
403
+ const { api } = useCombobox();
404
+ const [local, rest] = splitProps(props, ["class", "children"]);
405
+ return (() => {
406
+ var _el$3 = _tmpl$$2();
407
+ spread(_el$3, mergeProps(() => mergeWidgetProps(api().getControlProps(), rest), { get ["class"]() {
408
+ return cn("sb-combobox-control", local.class);
409
+ } }), false, true);
410
+ insert(_el$3, () => local.children);
411
+ return _el$3;
412
+ })();
413
+ }
414
+ function ComboboxInput(props) {
415
+ const { api, label } = useCombobox();
416
+ const [local, rest] = splitProps(props, ["class"]);
417
+ return (() => {
418
+ var _el$4 = _tmpl$3$2();
419
+ spread(_el$4, mergeProps({ get ["aria-label"]() {
420
+ return label();
421
+ } }, () => mergeWidgetProps(api().getInputProps(), rest), { get ["class"]() {
422
+ return cn("sb-combobox-input", local.class);
423
+ } }), false, false);
424
+ return _el$4;
425
+ })();
426
+ }
427
+ function ComboboxTrigger(props) {
428
+ const { api } = useCombobox();
429
+ const [local, rest] = splitProps(props, ["class", "children"]);
430
+ return (() => {
431
+ var _el$5 = _tmpl$4$2();
432
+ spread(_el$5, mergeProps(() => mergeWidgetProps(api().getTriggerProps(), rest), { get ["class"]() {
433
+ return cn("sb-combobox-trigger", local.class);
434
+ } }), false, true);
435
+ insert(_el$5, () => local.children);
436
+ return _el$5;
437
+ })();
438
+ }
439
+ function ComboboxPortal(props) {
440
+ return createComponent(Portal, {
441
+ get mount() {
442
+ return props.mount;
443
+ },
444
+ get children() {
445
+ return props.children;
446
+ }
447
+ });
448
+ }
449
+ function ComboboxPositioner(props) {
450
+ const { api } = useCombobox();
451
+ const [local, rest] = splitProps(props, ["class", "children"]);
452
+ return (() => {
453
+ var _el$6 = _tmpl$$2();
454
+ spread(_el$6, mergeProps(() => mergeWidgetProps(api().getPositionerProps(), rest), { get ["class"]() {
455
+ return cn("sb-combobox-positioner", local.class);
456
+ } }), false, true);
457
+ insert(_el$6, () => local.children);
458
+ return _el$6;
459
+ })();
460
+ }
461
+ function ComboboxContent(props) {
462
+ const { api } = useCombobox();
463
+ const [local, rest] = splitProps(props, ["class", "children"]);
464
+ return (() => {
465
+ var _el$7 = _tmpl$$2();
466
+ spread(_el$7, mergeProps({ get hidden() {
467
+ return !api().open;
468
+ } }, rest, { get ["class"]() {
469
+ return cn("sb-combobox-content", local.class);
470
+ } }), false, true);
471
+ insert(_el$7, () => local.children);
472
+ return _el$7;
473
+ })();
474
+ }
475
+ function ComboboxList(props) {
476
+ const { api, options, label } = useCombobox();
477
+ const [local, rest] = splitProps(props, ["class", "children"]);
478
+ return (() => {
479
+ var _el$8 = _tmpl$5$2();
480
+ spread(_el$8, mergeProps({ get ["aria-label"]() {
481
+ return label();
482
+ } }, () => mergeWidgetProps(api().getContentProps(), rest), { get ["class"]() {
483
+ return cn("sb-combobox-list", local.class);
484
+ } }), false, true);
485
+ insert(_el$8, createComponent(For, {
486
+ get each() {
487
+ return options();
488
+ },
489
+ children: (option) => local.children(option)
490
+ }));
491
+ return _el$8;
492
+ })();
493
+ }
494
+ function ComboboxEmpty(props) {
495
+ const { api, options } = useCombobox();
496
+ const [local, rest] = splitProps(props, ["class", "children"]);
497
+ return createComponent(Show, {
498
+ get when() {
499
+ return memo(() => !!api().open)() && options().length === 0;
500
+ },
501
+ get children() {
502
+ var _el$9 = _tmpl$$2();
503
+ spread(_el$9, mergeProps(rest, {
504
+ "role": "status",
505
+ get ["class"]() {
506
+ return cn("sb-combobox-empty", local.class);
507
+ }
508
+ }), false, true);
509
+ insert(_el$9, () => local.children);
510
+ return _el$9;
511
+ }
512
+ });
513
+ }
514
+ function ComboboxItem(props) {
515
+ const { api } = useCombobox();
516
+ const [local, rest] = splitProps(props, ["class", "option"]);
517
+ return (() => {
518
+ var _el$0 = _tmpl$6$2();
519
+ spread(_el$0, mergeProps(() => mergeWidgetProps(api().getItemProps({ item: local.option }), rest), { get ["class"]() {
520
+ return cn("sb-combobox-item", local.class);
521
+ } }), false, true);
522
+ insert(_el$0, () => local.option.label);
523
+ return _el$0;
524
+ })();
525
+ }
526
+ const Combobox = Object.assign(ComboboxRoot, {
527
+ Root: ComboboxRoot,
528
+ Label: ComboboxLabel,
529
+ Control: ComboboxControl,
530
+ Input: ComboboxInput,
531
+ Trigger: ComboboxTrigger,
532
+ Portal: ComboboxPortal,
533
+ Positioner: ComboboxPositioner,
534
+ Content: ComboboxContent,
535
+ List: ComboboxList,
536
+ Empty: ComboboxEmpty,
537
+ Item: ComboboxItem
538
+ });
539
+ //#endregion
540
+ //#region src/components/Select.tsx
541
+ var _tmpl$$1 = /*#__PURE__*/ template(`<div><select>`);
542
+ var _tmpl$2$1 = /*#__PURE__*/ template(`<option>`);
543
+ var _tmpl$3$1 = /*#__PURE__*/ template(`<label>`);
544
+ var _tmpl$4$1 = /*#__PURE__*/ template(`<div>`);
545
+ var _tmpl$5$1 = /*#__PURE__*/ template(`<button>`);
546
+ var _tmpl$6$1 = /*#__PURE__*/ template(`<span>`);
547
+ var _tmpl$7$1 = /*#__PURE__*/ template(`<ul>`);
548
+ var _tmpl$8$1 = /*#__PURE__*/ template(`<li>`);
549
+ const SelectContext = createContext(null);
550
+ function useSelect() {
551
+ const context = useContext(SelectContext);
552
+ if (!context) throw new Error("useSelect must be used within a Select");
553
+ return context;
554
+ }
555
+ function SelectRoot(props) {
556
+ const [local, rest] = splitProps(props, [
557
+ "class",
558
+ "children",
559
+ "id",
560
+ "label",
561
+ "name",
562
+ "placeholder",
563
+ "options",
564
+ "value",
565
+ "disabled",
566
+ "placement",
567
+ "invalid",
568
+ "required",
569
+ "onValueChange",
570
+ "onOpenChange"
571
+ ]);
572
+ const collection = createMemo(() => select.collection({
573
+ items: local.options,
574
+ itemToValue: (item) => item.value,
575
+ itemToString: (item) => item.label,
576
+ isItemDisabled: (item) => item.disabled ?? false
577
+ }));
578
+ const positioning = createMemo(() => local.placement ? { placement: local.placement } : void 0);
579
+ const service = useMachine(select.machine, {
580
+ get id() {
581
+ return local.id;
582
+ },
583
+ get ids() {
584
+ return { root: local.id };
585
+ },
586
+ get name() {
587
+ return local.name;
588
+ },
589
+ get disabled() {
590
+ return local.disabled;
591
+ },
592
+ get invalid() {
593
+ return local.invalid;
594
+ },
595
+ get required() {
596
+ return local.required;
597
+ },
598
+ get value() {
599
+ if (local.value === void 0) return void 0;
600
+ return local.value === "" ? [] : [local.value];
601
+ },
602
+ get positioning() {
603
+ return positioning();
604
+ },
605
+ get collection() {
606
+ return collection();
607
+ },
608
+ onOpenChange({ open }) {
609
+ local.onOpenChange?.(open);
610
+ },
611
+ onValueChange({ value }) {
612
+ local.onValueChange(value[0] ?? "");
613
+ }
614
+ });
615
+ const api = createMemo(() => select.connect(service, normalizeProps));
616
+ let hiddenSelect;
617
+ const syncHiddenSelect = () => {
618
+ hiddenSelect.value = api().value[0] ?? "";
619
+ };
620
+ createEffect(on([collection, () => api().value], syncHiddenSelect));
621
+ onMount(() => {
622
+ const form = hiddenSelect.form;
623
+ let resetFrame = 0;
624
+ const handleReset = () => {
625
+ cancelAnimationFrame(resetFrame);
626
+ resetFrame = requestAnimationFrame(syncHiddenSelect);
627
+ };
628
+ form?.addEventListener("reset", handleReset);
629
+ onCleanup(() => {
630
+ form?.removeEventListener("reset", handleReset);
631
+ cancelAnimationFrame(resetFrame);
632
+ });
633
+ });
634
+ return createComponent(SelectContext.Provider, {
635
+ value: {
636
+ label: () => local.label,
637
+ placeholder: () => local.placeholder,
638
+ options: () => local.options,
639
+ api
640
+ },
641
+ get children() {
642
+ var _el$ = _tmpl$$1(), _el$2 = _el$.firstChild;
643
+ spread(_el$, mergeProps(() => mergeWidgetProps(api().getRootProps(), rest), { get ["class"]() {
644
+ return cn("sb-select-root", local.class);
645
+ } }), false, true);
646
+ use((element) => {
647
+ hiddenSelect = element;
648
+ }, _el$2);
649
+ spread(_el$2, mergeProps(() => api().getHiddenSelectProps()), false, true);
650
+ insert(_el$2, createComponent(For, {
651
+ get each() {
652
+ return local.options;
653
+ },
654
+ children: (option) => (() => {
655
+ var _el$3 = _tmpl$2$1();
656
+ insert(_el$3, () => option.label);
657
+ effect(() => _el$3.value = option.value);
658
+ return _el$3;
659
+ })()
660
+ }));
661
+ insert(_el$, () => local.children, null);
662
+ return _el$;
663
+ }
664
+ });
665
+ }
666
+ function SelectLabel(props) {
667
+ const { api, label } = useSelect();
668
+ const [local, rest] = splitProps(props, ["class", "children"]);
669
+ return (() => {
670
+ var _el$4 = _tmpl$3$1();
671
+ spread(_el$4, mergeProps(() => mergeWidgetProps(api().getLabelProps(), rest), { get ["class"]() {
672
+ return cn("sb-select-label", local.class);
673
+ } }), false, true);
674
+ insert(_el$4, () => local.children ?? label());
675
+ return _el$4;
676
+ })();
677
+ }
678
+ function SelectControl(props) {
679
+ const { api } = useSelect();
680
+ const [local, rest] = splitProps(props, ["class", "children"]);
681
+ return (() => {
682
+ var _el$5 = _tmpl$4$1();
683
+ spread(_el$5, mergeProps(() => mergeWidgetProps(api().getControlProps(), rest), { get ["class"]() {
684
+ return cn("sb-select-control", local.class);
685
+ } }), false, true);
686
+ insert(_el$5, () => local.children);
687
+ return _el$5;
688
+ })();
689
+ }
690
+ function SelectTrigger(props) {
691
+ const { api, label } = useSelect();
692
+ const [local, rest] = splitProps(props, ["class", "children"]);
693
+ return (() => {
694
+ var _el$6 = _tmpl$5$1();
695
+ spread(_el$6, mergeProps({ get ["aria-label"]() {
696
+ return label();
697
+ } }, () => mergeWidgetProps(api().getTriggerProps(), rest), { get ["class"]() {
698
+ return cn("sb-select-trigger", local.class);
699
+ } }), false, true);
700
+ insert(_el$6, () => local.children);
701
+ return _el$6;
702
+ })();
703
+ }
704
+ function SelectValueText(props) {
705
+ const { api, placeholder } = useSelect();
706
+ const [local, rest] = splitProps(props, ["class", "children"]);
707
+ return (() => {
708
+ var _el$7 = _tmpl$6$1();
709
+ spread(_el$7, mergeProps(() => mergeWidgetProps(api().getValueTextProps(), rest), { get ["class"]() {
710
+ return cn("sb-select-value-text", local.class);
711
+ } }), false, true);
712
+ insert(_el$7, () => local.children ?? (api().valueAsString || placeholder()));
713
+ return _el$7;
714
+ })();
715
+ }
716
+ function SelectIndicator(props) {
717
+ const { api } = useSelect();
718
+ const [local, rest] = splitProps(props, ["class", "children"]);
719
+ return (() => {
720
+ var _el$8 = _tmpl$6$1();
721
+ spread(_el$8, mergeProps(() => mergeWidgetProps(api().getIndicatorProps(), rest), {
722
+ "aria-hidden": "true",
723
+ get ["class"]() {
724
+ return cn("sb-select-indicator", local.class);
725
+ }
726
+ }), false, true);
727
+ insert(_el$8, () => local.children);
728
+ return _el$8;
729
+ })();
730
+ }
731
+ function SelectPortal(props) {
732
+ return createComponent(Portal, {
733
+ get mount() {
734
+ return props.mount;
735
+ },
736
+ get children() {
737
+ return props.children;
738
+ }
739
+ });
740
+ }
741
+ function SelectPositioner(props) {
742
+ const { api } = useSelect();
743
+ const [local, rest] = splitProps(props, ["class", "children"]);
744
+ return (() => {
745
+ var _el$9 = _tmpl$4$1();
746
+ spread(_el$9, mergeProps(() => mergeWidgetProps(api().getPositionerProps(), rest), { get ["class"]() {
747
+ return cn("sb-select-positioner", local.class);
748
+ } }), false, true);
749
+ insert(_el$9, () => local.children);
750
+ return _el$9;
751
+ })();
752
+ }
753
+ function SelectContent(props) {
754
+ const { api } = useSelect();
755
+ const [local, rest] = splitProps(props, ["class", "children"]);
756
+ return (() => {
757
+ var _el$0 = _tmpl$4$1();
758
+ spread(_el$0, mergeProps({ get hidden() {
759
+ return !api().open;
760
+ } }, rest, { get ["class"]() {
761
+ return cn("sb-select-content", local.class);
762
+ } }), false, true);
763
+ insert(_el$0, () => local.children);
764
+ return _el$0;
765
+ })();
766
+ }
767
+ function SelectList(props) {
768
+ const { api, options, label } = useSelect();
769
+ const [local, rest] = splitProps(props, ["class", "children"]);
770
+ return (() => {
771
+ var _el$1 = _tmpl$7$1();
772
+ spread(_el$1, mergeProps({ get ["aria-label"]() {
773
+ return label();
774
+ } }, () => mergeWidgetProps(api().getContentProps(), rest), { get ["class"]() {
775
+ return cn("sb-select-list", local.class);
776
+ } }), false, true);
777
+ insert(_el$1, createComponent(For, {
778
+ get each() {
779
+ return options();
780
+ },
781
+ children: (option) => local.children(option)
782
+ }));
783
+ return _el$1;
784
+ })();
785
+ }
786
+ function SelectEmpty(props) {
787
+ const { api, options } = useSelect();
788
+ const [local, rest] = splitProps(props, ["class", "children"]);
789
+ return createComponent(Show, {
790
+ get when() {
791
+ return memo(() => !!api().open)() && options().length === 0;
792
+ },
793
+ get children() {
794
+ var _el$10 = _tmpl$4$1();
795
+ spread(_el$10, mergeProps(rest, {
796
+ "role": "status",
797
+ get ["class"]() {
798
+ return cn("sb-select-empty", local.class);
799
+ }
800
+ }), false, true);
801
+ insert(_el$10, () => local.children);
802
+ return _el$10;
803
+ }
804
+ });
805
+ }
806
+ function SelectItem(props) {
807
+ const { api } = useSelect();
808
+ const [local, rest] = splitProps(props, ["class", "option"]);
809
+ return (() => {
810
+ var _el$11 = _tmpl$8$1();
811
+ spread(_el$11, mergeProps(() => mergeWidgetProps(api().getItemProps({ item: local.option }), rest), { get ["class"]() {
812
+ return cn("sb-select-item", local.class);
813
+ } }), false, true);
814
+ insert(_el$11, () => local.option.label);
815
+ return _el$11;
816
+ })();
817
+ }
818
+ const Select = Object.assign(SelectRoot, {
819
+ Root: SelectRoot,
820
+ Label: SelectLabel,
821
+ Control: SelectControl,
822
+ Trigger: SelectTrigger,
823
+ ValueText: SelectValueText,
824
+ Indicator: SelectIndicator,
825
+ Portal: SelectPortal,
826
+ Positioner: SelectPositioner,
827
+ Content: SelectContent,
828
+ List: SelectList,
829
+ Empty: SelectEmpty,
830
+ Item: SelectItem
831
+ });
832
+ //#endregion
833
+ //#region src/components/Table.tsx
834
+ var _tmpl$ = /*#__PURE__*/ template(`<table>`);
835
+ var _tmpl$2 = /*#__PURE__*/ template(`<div>`);
836
+ var _tmpl$3 = /*#__PURE__*/ template(`<caption>`);
837
+ var _tmpl$4 = /*#__PURE__*/ template(`<thead>`);
838
+ var _tmpl$5 = /*#__PURE__*/ template(`<tbody>`);
839
+ var _tmpl$6 = /*#__PURE__*/ template(`<tfoot>`);
840
+ var _tmpl$7 = /*#__PURE__*/ template(`<tr>`);
841
+ var _tmpl$8 = /*#__PURE__*/ template(`<th>`);
842
+ var _tmpl$9 = /*#__PURE__*/ template(`<td>`);
843
+ function TableRoot(props) {
844
+ const [local, rest] = splitProps(props, ["class"]);
845
+ return (() => {
846
+ var _el$ = _tmpl$();
847
+ spread(_el$, mergeProps(rest, { get ["class"]() {
848
+ return cn("sb-table", local.class);
849
+ } }), false, false);
850
+ return _el$;
851
+ })();
852
+ }
853
+ function TableWrap(props) {
854
+ const [local, rest] = splitProps(props, ["class"]);
855
+ return (() => {
856
+ var _el$2 = _tmpl$2();
857
+ spread(_el$2, mergeProps(rest, { get ["class"]() {
858
+ return cn("sb-table-wrap", local.class);
859
+ } }), false, false);
860
+ return _el$2;
861
+ })();
862
+ }
863
+ function TableCaption(props) {
864
+ return (() => {
865
+ var _el$3 = _tmpl$3();
866
+ spread(_el$3, props, false, false);
867
+ return _el$3;
868
+ })();
869
+ }
870
+ function TableHeader(props) {
871
+ return (() => {
872
+ var _el$4 = _tmpl$4();
873
+ spread(_el$4, props, false, false);
874
+ return _el$4;
875
+ })();
876
+ }
877
+ function TableBody(props) {
878
+ return (() => {
879
+ var _el$5 = _tmpl$5();
880
+ spread(_el$5, props, false, false);
881
+ return _el$5;
882
+ })();
883
+ }
884
+ function TableFooter(props) {
885
+ return (() => {
886
+ var _el$6 = _tmpl$6();
887
+ spread(_el$6, props, false, false);
888
+ return _el$6;
889
+ })();
890
+ }
891
+ function TableRow(props) {
892
+ return (() => {
893
+ var _el$7 = _tmpl$7();
894
+ spread(_el$7, props, false, false);
895
+ return _el$7;
896
+ })();
897
+ }
898
+ function TableColumnHeader(props) {
899
+ const [local, rest] = splitProps(props, ["scope"]);
900
+ return (() => {
901
+ var _el$8 = _tmpl$8();
902
+ spread(_el$8, mergeProps(rest, { get scope() {
903
+ return local.scope ?? "col";
904
+ } }), false, false);
905
+ return _el$8;
906
+ })();
907
+ }
908
+ function TableRowHeader(props) {
909
+ const [local, rest] = splitProps(props, ["scope"]);
910
+ return (() => {
911
+ var _el$9 = _tmpl$8();
912
+ spread(_el$9, mergeProps(rest, { get scope() {
913
+ return local.scope ?? "row";
914
+ } }), false, false);
915
+ return _el$9;
916
+ })();
917
+ }
918
+ function TableCell(props) {
919
+ const [local, rest] = splitProps(props, ["variant"]);
920
+ return (() => {
921
+ var _el$0 = _tmpl$9();
922
+ spread(_el$0, mergeProps(rest, { get ["data-variant"]() {
923
+ return local.variant;
924
+ } }), false, false);
925
+ return _el$0;
926
+ })();
927
+ }
928
+ const Table = Object.assign(TableRoot, {
929
+ Root: TableRoot,
930
+ Wrap: TableWrap,
931
+ Caption: TableCaption,
932
+ Header: TableHeader,
933
+ Body: TableBody,
934
+ Footer: TableFooter,
935
+ Row: TableRow,
936
+ ColumnHeader: TableColumnHeader,
937
+ RowHeader: TableRowHeader,
938
+ Cell: TableCell
939
+ });
940
+ //#endregion
941
+ export { AlertDialog, Badge, Button, Checkbox, Combobox, Input, Radio, Select, Switch, Table, TextArea };