@epoch32/visage 1.1.3 → 1.1.4

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.
Files changed (51) hide show
  1. package/dist/api/index.js +55 -4085
  2. package/dist/charts/index.js +48 -2806
  3. package/dist/devtools/index.js +18 -4771
  4. package/dist/dom/index.js +32 -1639
  5. package/dist/form/index.js +13 -1498
  6. package/dist/index-061jf06a.js +848 -0
  7. package/dist/index-0madxn60.js +442 -0
  8. package/dist/index-1xtrtz1t.js +256 -0
  9. package/dist/index-2zz0g2n2.js +212 -0
  10. package/dist/index-5s255b3w.js +303 -0
  11. package/dist/index-6kfe1nr4.js +1179 -0
  12. package/dist/index-8czhpea8.js +338 -0
  13. package/dist/index-8x8xz80v.js +727 -0
  14. package/dist/index-921pn75b.js +0 -0
  15. package/dist/index-965ryh36.js +537 -0
  16. package/dist/index-9fvarkrx.js +98 -0
  17. package/dist/index-a4xns6cc.js +219 -0
  18. package/dist/index-b5wc752a.js +1696 -0
  19. package/dist/index-df5e614s.js +334 -0
  20. package/dist/index-dyvgtp43.js +1094 -0
  21. package/dist/index-grhdtcb5.js +234 -0
  22. package/dist/index-h6tjqk6e.js +158 -0
  23. package/dist/index-js199er4.js +101 -0
  24. package/dist/index-x2rs3vab.js +124 -0
  25. package/dist/index-y9bq7h9g.js +1162 -0
  26. package/dist/index-zr6cvset.js +2092 -0
  27. package/dist/index.d.ts +1 -1
  28. package/dist/index.js +458 -11920
  29. package/dist/jsx-runtime/index.js +13 -1719
  30. package/dist/query/index.js +47 -2505
  31. package/dist/router/index.js +25 -1945
  32. package/dist/rpc/index.js +39 -3567
  33. package/dist/server/index.js +11 -1256
  34. package/dist/signals/index.js +52 -1160
  35. package/dist/style/index.js +77 -2429
  36. package/dist/template/index.js +7 -1232
  37. package/dist/ui/index.d.ts +1 -1
  38. package/dist/ui/index.js +150 -4249
  39. package/dist/ui/tabs.d.ts +23 -1
  40. package/dist/virtual/index.js +12 -2044
  41. package/dist/vite/index.js +5 -744
  42. package/package.json +2 -2
  43. package/src/dom/render.ts +20 -7
  44. package/src/index.ts +2 -0
  45. package/src/signals/computed.ts +19 -12
  46. package/src/signals/effect.ts +7 -7
  47. package/src/signals/signal.ts +16 -12
  48. package/src/signals/system.ts +50 -21
  49. package/src/ui/index.ts +2 -0
  50. package/src/ui/tabs.tsx +211 -10
  51. package/src/ui/utils.ts +1 -3
@@ -0,0 +1,727 @@
1
+ import {
2
+ isSignal2,
3
+ computed2,
4
+ onCleanup2,
5
+ createContext2,
6
+ useContext2,
7
+ signal2
8
+ } from "./index-6kfe1nr4.js";
9
+ import {
10
+ Show2,
11
+ Portal2
12
+ } from "./index-5s255b3w.js";
13
+ import {
14
+ Fragment2,
15
+ jsx2,
16
+ jsxs2
17
+ } from "./index-9fvarkrx.js";
18
+
19
+ // src/ui/utils.ts
20
+ var idCounter = 0;
21
+ function createId2(prefix = "visage") {
22
+ return `${prefix}-${++idCounter}`;
23
+ }
24
+ function createControllableSignal2(options) {
25
+ const isControlled = typeof options.value === "function";
26
+ const internal = signal2(options.defaultValue, { internal: true });
27
+ const getter = computed2(() => {
28
+ if (isControlled) {
29
+ const externalVal = options.value();
30
+ if (externalVal !== undefined)
31
+ return externalVal;
32
+ }
33
+ return internal();
34
+ }, { internal: true });
35
+ const setter = (next) => {
36
+ const currentVal = getter();
37
+ const nextVal = typeof next === "function" ? next(currentVal) : next;
38
+ internal.set(nextVal);
39
+ if (options.onChange && nextVal !== currentVal) {
40
+ options.onChange(nextVal);
41
+ }
42
+ };
43
+ return [getter, setter];
44
+ }
45
+ function trapFocus2(container, event) {
46
+ if (event.key !== "Tab")
47
+ return;
48
+ const focusables = container.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
49
+ if (focusables.length === 0) {
50
+ event.preventDefault();
51
+ return;
52
+ }
53
+ const first = focusables[0];
54
+ const last = focusables[focusables.length - 1];
55
+ if (event.shiftKey) {
56
+ if (document.activeElement === first) {
57
+ last.focus();
58
+ event.preventDefault();
59
+ }
60
+ } else {
61
+ if (document.activeElement === last) {
62
+ first.focus();
63
+ event.preventDefault();
64
+ }
65
+ }
66
+ }
67
+ function onClickOutside2(elements, handler) {
68
+ const listener = (event) => {
69
+ const target = event.target;
70
+ if (!target)
71
+ return;
72
+ const list = Array.isArray(elements) ? elements : [elements];
73
+ const isInside = list.some((el) => el?.contains(target));
74
+ if (!isInside) {
75
+ handler(event);
76
+ }
77
+ };
78
+ if (typeof document !== "undefined") {
79
+ document.addEventListener("mousedown", listener, true);
80
+ document.addEventListener("touchstart", listener, true);
81
+ }
82
+ return () => {
83
+ if (typeof document !== "undefined") {
84
+ document.removeEventListener("mousedown", listener, true);
85
+ document.removeEventListener("touchstart", listener, true);
86
+ }
87
+ };
88
+ }
89
+
90
+ // src/ui/tabs.tsx
91
+ var TabsContext = createContext2(null);
92
+ function useTabsContext2() {
93
+ return useContext2(TabsContext);
94
+ }
95
+ function TabsRoot(props) {
96
+ const [value, setValue] = createControllableSignal2({
97
+ value: props.value,
98
+ defaultValue: props.defaultValue ?? (props.items && props.items.length > 0 ? props.items[0]?.value : ""),
99
+ onChange: props.onValueChange
100
+ });
101
+ const baseId = createId2("tabs");
102
+ const orientation = props.orientation ?? "horizontal";
103
+ const activationMode = props.activationMode ?? "automatic";
104
+ const ctx = {
105
+ value,
106
+ setValue,
107
+ orientation,
108
+ activationMode,
109
+ baseId
110
+ };
111
+ const {
112
+ as: Tag = "div",
113
+ value: _v,
114
+ defaultValue: _dv,
115
+ onValueChange: _ovc,
116
+ orientation: _ori,
117
+ activationMode: _am,
118
+ items,
119
+ listClass,
120
+ triggerClass,
121
+ contentClass,
122
+ children,
123
+ class: className,
124
+ style,
125
+ ...rest
126
+ } = props;
127
+ return TabsContext.Provider({
128
+ value: ctx,
129
+ children: () => /* @__PURE__ */ jsxs2(Tag, {
130
+ "data-orientation": orientation,
131
+ class: className,
132
+ style,
133
+ ...rest,
134
+ children: [
135
+ items ? /* @__PURE__ */ jsxs2(Fragment2, {
136
+ children: [
137
+ /* @__PURE__ */ jsx2(TabsList2, {
138
+ class: listClass,
139
+ children: items.map((item) => /* @__PURE__ */ jsxs2(TabsTrigger2, {
140
+ value: item.value,
141
+ disabled: item.disabled,
142
+ class: triggerClass,
143
+ children: [
144
+ item.icon ? /* @__PURE__ */ jsx2("span", {
145
+ class: "tab-icon",
146
+ style: { display: "inline-flex", alignItems: "center" },
147
+ children: typeof item.icon === "function" ? item.icon() : item.icon
148
+ }) : null,
149
+ typeof item.label === "function" ? item.label() : item.label
150
+ ]
151
+ }))
152
+ }),
153
+ items.map((item) => /* @__PURE__ */ jsx2(TabsContent2, {
154
+ value: item.value,
155
+ class: contentClass,
156
+ children: typeof item.content === "function" ? item.content() : item.content
157
+ }))
158
+ ]
159
+ }) : null,
160
+ children
161
+ ]
162
+ })
163
+ });
164
+ }
165
+ function TabsList2(props) {
166
+ const ctx = useContext2(TabsContext);
167
+ const handleKeyDown = (e) => {
168
+ if (props.onKeyDown)
169
+ props.onKeyDown(e);
170
+ if (e.defaultPrevented)
171
+ return;
172
+ const target = e.target;
173
+ if (target?.getAttribute("role") !== "tab")
174
+ return;
175
+ const list = target.closest('[role="tablist"]');
176
+ if (!list)
177
+ return;
178
+ const tabs = Array.from(list.querySelectorAll('[role="tab"]:not([disabled])'));
179
+ const index = tabs.indexOf(target);
180
+ if (index === -1)
181
+ return;
182
+ let nextIndex = index;
183
+ const isHorizontal = (ctx?.orientation ?? "horizontal") === "horizontal";
184
+ const prevKey = isHorizontal ? "ArrowLeft" : "ArrowUp";
185
+ const nextKey = isHorizontal ? "ArrowRight" : "ArrowDown";
186
+ if (e.key === prevKey) {
187
+ nextIndex = index === 0 ? tabs.length - 1 : index - 1;
188
+ e.preventDefault();
189
+ } else if (e.key === nextKey) {
190
+ nextIndex = index === tabs.length - 1 ? 0 : index + 1;
191
+ e.preventDefault();
192
+ } else if (e.key === "Home") {
193
+ nextIndex = 0;
194
+ e.preventDefault();
195
+ } else if (e.key === "End") {
196
+ nextIndex = tabs.length - 1;
197
+ e.preventDefault();
198
+ }
199
+ if (nextIndex !== index) {
200
+ const nextTab = tabs[nextIndex];
201
+ nextTab.focus();
202
+ if (ctx?.activationMode === "automatic") {
203
+ const val = nextTab.getAttribute("data-value");
204
+ if (val)
205
+ ctx.setValue(val);
206
+ }
207
+ }
208
+ };
209
+ const { as: Tag = "div", children, onKeyDown, class: className, style, ...rest } = props;
210
+ return /* @__PURE__ */ jsx2(Tag, {
211
+ role: "tablist",
212
+ "aria-orientation": ctx?.orientation ?? "horizontal",
213
+ class: className,
214
+ style,
215
+ onKeyDown: handleKeyDown,
216
+ ...rest,
217
+ children
218
+ });
219
+ }
220
+ function TabsTrigger2(props) {
221
+ const ctx = useContext2(TabsContext);
222
+ const isSelected = () => ctx ? ctx.value() === props.value : false;
223
+ const handleClick = (e) => {
224
+ if (props.onClick)
225
+ props.onClick(e);
226
+ if (!e.defaultPrevented && ctx) {
227
+ ctx.setValue(props.value);
228
+ }
229
+ };
230
+ const {
231
+ value,
232
+ disabled,
233
+ as: Tag = "button",
234
+ children,
235
+ onClick,
236
+ class: className,
237
+ style,
238
+ ...rest
239
+ } = props;
240
+ return /* @__PURE__ */ jsx2(Tag, {
241
+ id: ctx ? `${ctx.baseId}-trigger-${value}` : undefined,
242
+ type: Tag === "button" ? "button" : undefined,
243
+ role: "tab",
244
+ "aria-selected": () => String(isSelected()),
245
+ "aria-controls": ctx ? `${ctx.baseId}-panel-${value}` : undefined,
246
+ "data-state": () => isSelected() ? "active" : "inactive",
247
+ "data-active": () => isSelected() ? "true" : "false",
248
+ "data-value": value,
249
+ tabIndex: () => isSelected() ? 0 : -1,
250
+ disabled,
251
+ class: () => [className, isSelected() ? "active" : ""].filter(Boolean).join(" "),
252
+ style,
253
+ onClick: handleClick,
254
+ ...rest,
255
+ children
256
+ });
257
+ }
258
+ function TabsContent2(props) {
259
+ const ctx = useContext2(TabsContext);
260
+ const isSelected = () => ctx ? ctx.value() === props.value : false;
261
+ const { value, forceMount, as: Tag = "div", children, class: className, style, ...rest } = props;
262
+ if (forceMount) {
263
+ return /* @__PURE__ */ jsx2(Tag, {
264
+ id: ctx ? `${ctx.baseId}-panel-${value}` : undefined,
265
+ role: "tabpanel",
266
+ "aria-labelledby": ctx ? `${ctx.baseId}-trigger-${value}` : undefined,
267
+ "data-state": () => isSelected() ? "active" : "inactive",
268
+ hidden: () => !isSelected(),
269
+ tabIndex: 0,
270
+ class: className,
271
+ style,
272
+ ...rest,
273
+ children
274
+ });
275
+ }
276
+ return /* @__PURE__ */ jsx2(Show2, {
277
+ when: isSelected,
278
+ children: /* @__PURE__ */ jsx2(Tag, {
279
+ id: ctx ? `${ctx.baseId}-panel-${value}` : undefined,
280
+ role: "tabpanel",
281
+ "aria-labelledby": ctx ? `${ctx.baseId}-trigger-${value}` : undefined,
282
+ "data-state": "active",
283
+ tabIndex: 0,
284
+ class: className,
285
+ style,
286
+ ...rest,
287
+ children
288
+ })
289
+ });
290
+ }
291
+ function createTabs2(options = {}) {
292
+ const activeSignal = typeof options.value === "function" ? options.value : signal2(options.defaultValue ?? "");
293
+ const value = activeSignal;
294
+ const setValue = (next) => {
295
+ if (isSignal2(activeSignal)) {
296
+ activeSignal.set(next);
297
+ }
298
+ if (options.onValueChange) {
299
+ options.onValueChange(next);
300
+ }
301
+ };
302
+ const baseId = createId2("tabs");
303
+ const orientation = options.orientation ?? "horizontal";
304
+ const activationMode = options.activationMode ?? "automatic";
305
+ const Root = (props) => {
306
+ const { as: Tag = "div", class: className, style, children, ...rest } = props;
307
+ return /* @__PURE__ */ jsx2(Tag, {
308
+ "data-orientation": orientation,
309
+ class: className,
310
+ style,
311
+ ...rest,
312
+ children
313
+ });
314
+ };
315
+ const List = (props) => {
316
+ const { as: Tag = "div", children, onKeyDown, class: className, style, ...rest } = props;
317
+ const handleKeyDown = (e) => {
318
+ if (onKeyDown)
319
+ onKeyDown(e);
320
+ if (e.defaultPrevented)
321
+ return;
322
+ const target = e.target;
323
+ if (target?.getAttribute("role") !== "tab")
324
+ return;
325
+ const list = target.closest('[role="tablist"]');
326
+ if (!list)
327
+ return;
328
+ const tabs = Array.from(list.querySelectorAll('[role="tab"]:not([disabled])'));
329
+ const index = tabs.indexOf(target);
330
+ if (index === -1)
331
+ return;
332
+ let nextIndex = index;
333
+ const isHorizontal = orientation === "horizontal";
334
+ const prevKey = isHorizontal ? "ArrowLeft" : "ArrowUp";
335
+ const nextKey = isHorizontal ? "ArrowRight" : "ArrowDown";
336
+ if (e.key === prevKey) {
337
+ nextIndex = index === 0 ? tabs.length - 1 : index - 1;
338
+ e.preventDefault();
339
+ } else if (e.key === nextKey) {
340
+ nextIndex = index === tabs.length - 1 ? 0 : index + 1;
341
+ e.preventDefault();
342
+ } else if (e.key === "Home") {
343
+ nextIndex = 0;
344
+ e.preventDefault();
345
+ } else if (e.key === "End") {
346
+ nextIndex = tabs.length - 1;
347
+ e.preventDefault();
348
+ }
349
+ if (nextIndex !== index) {
350
+ const nextTab = tabs[nextIndex];
351
+ nextTab.focus();
352
+ if (activationMode === "automatic") {
353
+ const val = nextTab.getAttribute("data-value");
354
+ if (val)
355
+ setValue(val);
356
+ }
357
+ }
358
+ };
359
+ return /* @__PURE__ */ jsx2(Tag, {
360
+ role: "tablist",
361
+ "aria-orientation": orientation,
362
+ class: className,
363
+ style,
364
+ onKeyDown: handleKeyDown,
365
+ ...rest,
366
+ children
367
+ });
368
+ };
369
+ const Trigger = (props) => {
370
+ const isSelected = () => value() === props.value;
371
+ const handleClick = (e) => {
372
+ if (props.onClick)
373
+ props.onClick(e);
374
+ if (!e.defaultPrevented) {
375
+ setValue(props.value);
376
+ }
377
+ };
378
+ const {
379
+ value: tabVal,
380
+ disabled,
381
+ as: Tag = "button",
382
+ children,
383
+ onClick,
384
+ class: className,
385
+ style,
386
+ ...rest
387
+ } = props;
388
+ return /* @__PURE__ */ jsx2(Tag, {
389
+ id: `${baseId}-trigger-${tabVal}`,
390
+ type: Tag === "button" ? "button" : undefined,
391
+ role: "tab",
392
+ "aria-selected": () => String(isSelected()),
393
+ "aria-controls": `${baseId}-panel-${tabVal}`,
394
+ "data-state": () => isSelected() ? "active" : "inactive",
395
+ "data-active": () => isSelected() ? "true" : "false",
396
+ "data-value": tabVal,
397
+ tabIndex: () => isSelected() ? 0 : -1,
398
+ disabled,
399
+ class: () => [className, isSelected() ? "active" : ""].filter(Boolean).join(" "),
400
+ style,
401
+ onClick: handleClick,
402
+ ...rest,
403
+ children
404
+ });
405
+ };
406
+ const Content = (props) => {
407
+ const isSelected = () => value() === props.value;
408
+ const {
409
+ value: tabVal,
410
+ forceMount,
411
+ as: Tag = "div",
412
+ children,
413
+ class: className,
414
+ style,
415
+ ...rest
416
+ } = props;
417
+ if (forceMount) {
418
+ return /* @__PURE__ */ jsx2(Tag, {
419
+ id: `${baseId}-panel-${tabVal}`,
420
+ role: "tabpanel",
421
+ "aria-labelledby": `${baseId}-trigger-${tabVal}`,
422
+ "data-state": () => isSelected() ? "active" : "inactive",
423
+ hidden: () => !isSelected(),
424
+ tabIndex: 0,
425
+ class: className,
426
+ style,
427
+ ...rest,
428
+ children
429
+ });
430
+ }
431
+ return /* @__PURE__ */ jsx2(Show2, {
432
+ when: isSelected,
433
+ children: /* @__PURE__ */ jsx2(Tag, {
434
+ id: `${baseId}-panel-${tabVal}`,
435
+ role: "tabpanel",
436
+ "aria-labelledby": `${baseId}-trigger-${tabVal}`,
437
+ "data-state": "active",
438
+ tabIndex: 0,
439
+ class: className,
440
+ style,
441
+ ...rest,
442
+ children
443
+ })
444
+ });
445
+ };
446
+ return {
447
+ value,
448
+ setValue,
449
+ Root,
450
+ List,
451
+ Trigger,
452
+ Content
453
+ };
454
+ }
455
+ var Tabs2 = Object.assign(TabsRoot, {
456
+ Root: TabsRoot,
457
+ List: TabsList2,
458
+ Trigger: TabsTrigger2,
459
+ Content: TabsContent2,
460
+ create: createTabs2
461
+ });
462
+
463
+ // src/ui/tooltip.tsx
464
+ var TooltipContext = createContext2(null);
465
+ function useTooltipContext2() {
466
+ return useContext2(TooltipContext);
467
+ }
468
+ function TooltipRoot(props) {
469
+ const [open, setOpen] = createControllableSignal2({
470
+ value: props.open,
471
+ defaultValue: props.defaultOpen ?? false,
472
+ onChange: props.onOpenChange
473
+ });
474
+ const tooltipId = createId2("tooltip");
475
+ const triggerRef = { current: null };
476
+ const ctx = {
477
+ open,
478
+ setOpen,
479
+ openDelay: props.openDelay ?? 150,
480
+ closeDelay: props.closeDelay ?? 100,
481
+ tooltipId,
482
+ triggerRef
483
+ };
484
+ if (props.content !== undefined) {
485
+ return TooltipContext.Provider({
486
+ value: ctx,
487
+ children: () => /* @__PURE__ */ jsxs2("span", {
488
+ class: "visage-tooltip-root",
489
+ style: { position: "relative", display: "inline-flex", alignItems: "center" },
490
+ children: [
491
+ /* @__PURE__ */ jsx2(TooltipTrigger2, {
492
+ as: props.triggerAs ?? "button",
493
+ class: props.triggerClass,
494
+ style: {
495
+ background: "transparent",
496
+ border: "none",
497
+ padding: 0,
498
+ display: "inline-flex",
499
+ alignItems: "center",
500
+ cursor: "help"
501
+ },
502
+ children: typeof props.children === "function" ? props.children() : props.children
503
+ }),
504
+ /* @__PURE__ */ jsx2(TooltipContent2, {
505
+ side: props.side,
506
+ class: props.contentClass,
507
+ style: props.contentStyle,
508
+ portalled: props.portalled ?? false,
509
+ children: typeof props.content === "function" ? props.content() : props.content
510
+ })
511
+ ]
512
+ })
513
+ });
514
+ }
515
+ return TooltipContext.Provider({
516
+ value: ctx,
517
+ children: props.children
518
+ });
519
+ }
520
+ function TooltipTrigger2(props) {
521
+ const ctx = useContext2(TooltipContext);
522
+ let openTimer = null;
523
+ let closeTimer = null;
524
+ const clearTimers = () => {
525
+ if (openTimer)
526
+ clearTimeout(openTimer);
527
+ if (closeTimer)
528
+ clearTimeout(closeTimer);
529
+ openTimer = null;
530
+ closeTimer = null;
531
+ };
532
+ const handleMouseEnter = (e) => {
533
+ if (props.onMouseEnter)
534
+ props.onMouseEnter(e);
535
+ clearTimers();
536
+ if (!ctx)
537
+ return;
538
+ if (ctx.openDelay > 0) {
539
+ openTimer = setTimeout(() => ctx.setOpen(true), ctx.openDelay);
540
+ } else {
541
+ ctx.setOpen(true);
542
+ }
543
+ };
544
+ const handleMouseLeave = (e) => {
545
+ if (props.onMouseLeave)
546
+ props.onMouseLeave(e);
547
+ clearTimers();
548
+ if (!ctx)
549
+ return;
550
+ if (ctx.closeDelay > 0) {
551
+ closeTimer = setTimeout(() => ctx.setOpen(false), ctx.closeDelay);
552
+ } else {
553
+ ctx.setOpen(false);
554
+ }
555
+ };
556
+ const handleFocus = (e) => {
557
+ if (props.onFocus)
558
+ props.onFocus(e);
559
+ clearTimers();
560
+ ctx?.setOpen(true);
561
+ };
562
+ const handleBlur = (e) => {
563
+ if (props.onBlur)
564
+ props.onBlur(e);
565
+ clearTimers();
566
+ ctx?.setOpen(false);
567
+ };
568
+ onCleanup2(clearTimers);
569
+ const {
570
+ as: Tag = "button",
571
+ children,
572
+ onMouseEnter,
573
+ onMouseLeave,
574
+ onFocus,
575
+ onBlur,
576
+ class: className,
577
+ style,
578
+ ...rest
579
+ } = props;
580
+ return /* @__PURE__ */ jsx2(Tag, {
581
+ ref: (el) => {
582
+ if (ctx)
583
+ ctx.triggerRef.current = el;
584
+ },
585
+ type: Tag === "button" ? "button" : undefined,
586
+ tabIndex: Tag === "button" ? undefined : 0,
587
+ "aria-describedby": ctx?.tooltipId,
588
+ "data-state": () => ctx?.open() ? "open" : "closed",
589
+ class: className,
590
+ style: { display: "inline-flex", alignItems: "center", ...style },
591
+ onMouseEnter: handleMouseEnter,
592
+ onMouseLeave: handleMouseLeave,
593
+ onFocus: handleFocus,
594
+ onBlur: handleBlur,
595
+ ...rest,
596
+ children
597
+ });
598
+ }
599
+ function TooltipPortal2(props) {
600
+ return /* @__PURE__ */ jsx2(Portal2, {
601
+ mount: props.mount,
602
+ children: props.children
603
+ });
604
+ }
605
+ function TooltipContent2(props) {
606
+ const ctx = useContext2(TooltipContext);
607
+ const isOpen = () => ctx ? ctx.open() : false;
608
+ const {
609
+ forceMount,
610
+ as: Tag = "div",
611
+ children,
612
+ class: className,
613
+ style,
614
+ portalled = true,
615
+ mount,
616
+ ...rest
617
+ } = props;
618
+ const content = forceMount ? /* @__PURE__ */ jsx2(Tag, {
619
+ id: ctx?.tooltipId,
620
+ role: "tooltip",
621
+ "data-state": () => isOpen() ? "open" : "closed",
622
+ hidden: () => !isOpen(),
623
+ class: className,
624
+ style,
625
+ ...rest,
626
+ children
627
+ }) : /* @__PURE__ */ jsx2(Show2, {
628
+ when: isOpen,
629
+ children: /* @__PURE__ */ jsx2(Tag, {
630
+ id: ctx?.tooltipId,
631
+ role: "tooltip",
632
+ "data-state": "open",
633
+ class: className,
634
+ style,
635
+ ...rest,
636
+ children
637
+ })
638
+ });
639
+ return portalled ? /* @__PURE__ */ jsx2(Portal2, {
640
+ mount,
641
+ children: content
642
+ }) : content;
643
+ }
644
+ var Tooltip3 = Object.assign(TooltipRoot, {
645
+ Root: TooltipRoot,
646
+ Trigger: TooltipTrigger2,
647
+ Portal: TooltipPortal2,
648
+ Content: TooltipContent2
649
+ });
650
+
651
+ // src/ui/switch.tsx
652
+ function SwitchRoot(props) {
653
+ const [checked, setChecked] = createControllableSignal2({
654
+ value: props.checked,
655
+ defaultValue: props.defaultChecked ?? false,
656
+ onChange: props.onCheckedChange
657
+ });
658
+ const toggle = () => {
659
+ const isDisabled = typeof props.disabled === "function" ? props.disabled() : Boolean(props.disabled);
660
+ if (isDisabled)
661
+ return;
662
+ setChecked(!checked());
663
+ };
664
+ const handleClick = (e) => {
665
+ if (props.onClick)
666
+ props.onClick(e);
667
+ if (!e.defaultPrevented) {
668
+ toggle();
669
+ }
670
+ };
671
+ const handleKeyDown = (e) => {
672
+ if (props.onKeyDown)
673
+ props.onKeyDown(e);
674
+ if (e.key === "Enter" || e.key === " ") {
675
+ e.preventDefault();
676
+ toggle();
677
+ }
678
+ };
679
+ const {
680
+ checked: _c,
681
+ defaultChecked: _dc,
682
+ onCheckedChange: _occ,
683
+ disabled,
684
+ required,
685
+ name,
686
+ value,
687
+ thumbClass,
688
+ thumbStyle,
689
+ as: Tag = "button",
690
+ children,
691
+ onClick,
692
+ onKeyDown,
693
+ class: className,
694
+ style,
695
+ ...rest
696
+ } = props;
697
+ return /* @__PURE__ */ jsx2(Tag, {
698
+ type: Tag === "button" ? "button" : undefined,
699
+ role: "switch",
700
+ "aria-checked": checked,
701
+ "data-state": () => checked() ? "checked" : "unchecked",
702
+ disabled,
703
+ class: className,
704
+ style,
705
+ onClick: handleClick,
706
+ onKeyDown: handleKeyDown,
707
+ ...rest,
708
+ children: children !== undefined ? typeof children === "function" ? children() : children : /* @__PURE__ */ jsx2(SwitchThumb2, {
709
+ class: thumbClass,
710
+ style: thumbStyle
711
+ })
712
+ });
713
+ }
714
+ function SwitchThumb2(props) {
715
+ const { as: Tag = "span", class: className, style, ...rest } = props;
716
+ return /* @__PURE__ */ jsx2(Tag, {
717
+ class: className,
718
+ style,
719
+ ...rest
720
+ });
721
+ }
722
+ var Switch2 = Object.assign(SwitchRoot, {
723
+ Root: SwitchRoot,
724
+ Thumb: SwitchThumb2
725
+ });
726
+
727
+ export { createId2, createControllableSignal2, trapFocus2, onClickOutside2, useTabsContext2, TabsList2, TabsTrigger2, TabsContent2, createTabs2, Tabs2, useTooltipContext2, TooltipTrigger2, TooltipPortal2, TooltipContent2, Tooltip3, SwitchThumb2, Switch2 };