@melony/react 0.1.50 → 0.1.52

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as React3 from 'react';
2
2
  import React3__default, { createContext, useContext, useRef, useEffect, useState, useCallback, useMemo } from 'react';
3
- import { convertEventsToMessages } from 'melony';
3
+ import { filterEventsBySlots, convertEventsToMessages } from 'melony';
4
4
  import { NuqsAdapter } from 'nuqs/adapters/react';
5
5
  import { QueryClient, QueryClientProvider, useQueryClient, useQuery, useMutation } from '@tanstack/react-query';
6
6
  import { Dialog as Dialog$1 } from '@base-ui/react/dialog';
@@ -189,210 +189,295 @@ function CardContent({ className, ...props }) {
189
189
  }
190
190
  );
191
191
  }
192
+
193
+ // src/lib/theme-utils.ts
194
+ var paddingMap = {
195
+ none: "p-0",
196
+ xs: "p-1",
197
+ sm: "p-2",
198
+ md: "p-4",
199
+ lg: "p-6",
200
+ xl: "p-8",
201
+ xxl: "p-12"
202
+ };
203
+ var marginMap = {
204
+ none: "m-0",
205
+ xs: "m-1",
206
+ sm: "m-2",
207
+ md: "m-4",
208
+ lg: "m-6",
209
+ xl: "m-8",
210
+ xxl: "m-12"
211
+ };
212
+ var gapMap = {
213
+ none: "gap-0",
214
+ xs: "gap-1",
215
+ sm: "gap-2",
216
+ md: "gap-4",
217
+ lg: "gap-6",
218
+ xl: "gap-8",
219
+ xxl: "gap-12"
220
+ };
221
+ var colorBgMap = {
222
+ primary: "bg-primary text-primary-foreground",
223
+ secondary: "bg-secondary text-secondary-foreground",
224
+ success: "bg-green-500 text-white",
225
+ danger: "bg-destructive text-destructive-foreground",
226
+ warning: "bg-yellow-500 text-white",
227
+ info: "bg-blue-500 text-white",
228
+ background: "bg-background text-foreground",
229
+ foreground: "bg-foreground text-background",
230
+ muted: "bg-muted text-muted-foreground",
231
+ mutedForeground: "bg-muted-foreground text-muted",
232
+ border: "bg-border",
233
+ transparent: "bg-transparent"
234
+ };
235
+ var colorTextMap = {
236
+ primary: "text-primary",
237
+ secondary: "text-secondary",
238
+ success: "text-green-600",
239
+ danger: "text-destructive",
240
+ warning: "text-yellow-600",
241
+ info: "text-blue-600",
242
+ background: "text-background",
243
+ foreground: "text-foreground",
244
+ muted: "text-muted-foreground",
245
+ mutedForeground: "text-muted-foreground",
246
+ border: "text-border",
247
+ transparent: "text-transparent"
248
+ };
249
+ var colorBorderMap = {
250
+ primary: "border-primary",
251
+ secondary: "border-secondary",
252
+ success: "border-green-500",
253
+ danger: "border-destructive",
254
+ warning: "border-yellow-500",
255
+ info: "border-blue-500",
256
+ background: "border-background",
257
+ foreground: "border-foreground",
258
+ muted: "border-muted",
259
+ mutedForeground: "border-muted-foreground",
260
+ border: "border-border",
261
+ transparent: "border-transparent"
262
+ };
263
+ var widthMap = {
264
+ auto: "w-auto",
265
+ full: "w-full",
266
+ min: "w-min",
267
+ max: "w-max",
268
+ "1/2": "w-1/2",
269
+ "1/3": "w-1/3",
270
+ "2/3": "w-2/3",
271
+ "1/4": "w-1/4",
272
+ "3/4": "w-3/4"
273
+ };
274
+ var shadowMap = {
275
+ none: "shadow-none",
276
+ sm: "shadow-sm",
277
+ md: "shadow-md",
278
+ lg: "shadow-lg",
279
+ xl: "shadow-xl"
280
+ };
281
+ var radiusMap = {
282
+ none: "rounded-none",
283
+ sm: "rounded-sm",
284
+ md: "rounded-md",
285
+ lg: "rounded-lg",
286
+ full: "rounded-full"
287
+ };
288
+ var alignMap = {
289
+ start: "items-start",
290
+ center: "items-center",
291
+ end: "items-end",
292
+ stretch: "items-stretch"
293
+ };
294
+ var justifyMap = {
295
+ start: "justify-start",
296
+ center: "justify-center",
297
+ end: "justify-end",
298
+ between: "justify-between",
299
+ around: "justify-around"
300
+ };
301
+ var wrapMap = {
302
+ nowrap: "flex-nowrap",
303
+ wrap: "flex-wrap",
304
+ "wrap-reverse": "flex-wrap-reverse"
305
+ };
306
+ var textSizeMap = {
307
+ none: "text-[0]",
308
+ xs: "text-xs",
309
+ sm: "text-sm",
310
+ md: "text-base",
311
+ lg: "text-lg",
312
+ xl: "text-xl",
313
+ xxl: "text-2xl"
314
+ };
315
+ var textAlignMap = {
316
+ start: "text-left",
317
+ center: "text-center",
318
+ end: "text-right",
319
+ stretch: "text-justify"
320
+ };
321
+ var fontWeightMap = {
322
+ normal: "font-normal",
323
+ medium: "font-medium",
324
+ semibold: "font-semibold",
325
+ bold: "font-bold"
326
+ };
192
327
  var Card2 = ({
193
328
  children,
194
329
  title,
195
330
  subtitle,
196
- className,
197
- style
331
+ background,
332
+ padding = "md",
333
+ radius = "md",
334
+ shadow = "md"
198
335
  }) => {
199
336
  return /* @__PURE__ */ jsxs(
200
337
  Card,
201
338
  {
202
- className: cn("min-w-96", className),
203
- style,
339
+ className: cn(
340
+ "min-w-96 relative",
341
+ background && colorBgMap[background],
342
+ radius && radiusMap[radius],
343
+ shadow && shadowMap[shadow]
344
+ ),
204
345
  children: [
205
346
  (title || subtitle) && /* @__PURE__ */ jsxs(CardHeader, { className: "pb-3", children: [
206
347
  title && /* @__PURE__ */ jsx(CardTitle, { className: "text-lg", children: title }),
207
348
  subtitle && /* @__PURE__ */ jsx(CardDescription, { children: subtitle })
208
349
  ] }),
209
- /* @__PURE__ */ jsx(CardContent, { className: "flex flex-col gap-4", children })
350
+ /* @__PURE__ */ jsx(CardContent, { className: cn("flex flex-col gap-4", paddingMap[padding]), children })
210
351
  ]
211
352
  }
212
353
  );
213
354
  };
214
355
  var Row = ({
215
356
  children,
216
- gap = "md",
217
357
  align = "start",
218
358
  justify = "start",
219
- wrap = false,
220
- className,
221
- style
359
+ wrap = "nowrap",
360
+ gap = "none",
361
+ padding = "none",
362
+ width = "full"
222
363
  }) => {
223
- const gapClasses = {
224
- xs: "gap-0",
225
- sm: "gap-1",
226
- md: "gap-2",
227
- lg: "gap-4",
228
- xl: "gap-6"
229
- };
230
- const alignClasses = {
231
- start: "items-start",
232
- center: "items-center",
233
- end: "items-end",
234
- stretch: "items-stretch"
235
- };
236
- const justifyClasses = {
237
- start: "justify-start",
238
- center: "justify-center",
239
- end: "justify-end",
240
- between: "justify-between",
241
- around: "justify-around"
242
- };
243
364
  return /* @__PURE__ */ jsx(
244
365
  "div",
245
366
  {
246
367
  className: cn(
247
- "flex flex-row w-full",
248
- gapClasses[gap] || "gap-4",
249
- alignClasses[align] || "items-start",
250
- justifyClasses[justify] || "justify-start",
251
- wrap ? "flex-wrap" : "flex-nowrap",
252
- className
368
+ "flex flex-row",
369
+ alignMap[align],
370
+ justifyMap[justify],
371
+ wrapMap[wrap],
372
+ gapMap[gap],
373
+ paddingMap[padding],
374
+ widthMap[width]
253
375
  ),
254
- style,
255
376
  children
256
377
  }
257
378
  );
258
379
  };
259
380
  var Col = ({
260
381
  children,
261
- gap = "sm",
262
382
  align = "start",
263
383
  justify = "start",
264
- width,
265
- height,
266
- padding,
267
- overflow,
268
- position = "static",
269
- className,
270
- style
384
+ gap = "none",
385
+ width = "auto",
386
+ height = "auto",
387
+ padding = "none",
388
+ background,
389
+ radius
271
390
  }) => {
272
- const gapClasses = {
273
- xs: "gap-1",
274
- sm: "gap-2",
275
- md: "gap-4",
276
- lg: "gap-6",
277
- xl: "gap-8"
278
- };
279
- const alignClasses = {
280
- start: "items-start",
281
- center: "items-center",
282
- end: "items-end",
283
- stretch: "items-stretch"
284
- };
285
- const justifyClasses = {
286
- start: "justify-start",
287
- center: "justify-center",
288
- end: "justify-end",
289
- between: "justify-between",
290
- around: "justify-around"
291
- };
292
- const overflowClasses = {
293
- auto: "overflow-auto",
294
- hidden: "overflow-hidden",
295
- scroll: "overflow-scroll",
296
- visible: "overflow-visible"
297
- };
298
- const positionClasses = {
299
- static: "static",
300
- relative: "relative",
301
- absolute: "absolute",
302
- fixed: "fixed",
303
- sticky: "sticky"
304
- };
305
391
  return /* @__PURE__ */ jsx(
306
392
  "div",
307
393
  {
308
394
  className: cn(
309
395
  "flex flex-col",
310
- gapClasses[gap] || "gap-2",
311
- alignClasses[align] || "items-start",
312
- justifyClasses[justify] || "justify-start",
313
- overflow && overflowClasses[overflow],
314
- position && positionClasses[position],
315
- className
396
+ alignMap[align],
397
+ justifyMap[justify],
398
+ gapMap[gap],
399
+ paddingMap[padding],
400
+ widthMap[width],
401
+ height === "full" && "h-full",
402
+ background && colorBgMap[background],
403
+ radius && radiusMap[radius]
316
404
  ),
317
- style: {
318
- width,
319
- height,
320
- padding,
321
- ...style
322
- },
323
405
  children
324
406
  }
325
407
  );
326
408
  };
327
409
  var Box = ({
328
410
  children,
329
- padding = "md",
330
- margin,
411
+ padding = "none",
412
+ margin = "none",
331
413
  background,
332
414
  border = false,
333
- borderRadius,
334
- width,
335
- height,
336
- overflow = "visible",
337
- className,
338
- style
415
+ borderColor = "border",
416
+ radius = "none",
417
+ width = "auto",
418
+ height = "auto",
419
+ shadow = "none"
339
420
  }) => {
340
- const paddingClasses = {
341
- xs: "p-1",
342
- sm: "p-2",
343
- md: "p-4",
344
- lg: "p-6",
345
- xl: "p-8"
346
- };
347
- const overflowClasses = {
348
- auto: "overflow-auto",
349
- hidden: "overflow-hidden",
350
- scroll: "overflow-scroll",
351
- visible: "overflow-visible"
421
+ return /* @__PURE__ */ jsx(
422
+ "div",
423
+ {
424
+ className: cn(
425
+ "relative",
426
+ paddingMap[padding],
427
+ marginMap[margin],
428
+ background && colorBgMap[background],
429
+ border && "border",
430
+ border && colorBorderMap[borderColor],
431
+ radiusMap[radius],
432
+ widthMap[width],
433
+ height === "full" && "h-full",
434
+ shadowMap[shadow]
435
+ ),
436
+ children
437
+ }
438
+ );
439
+ };
440
+ var Float = ({
441
+ children,
442
+ position = "top-right",
443
+ offsetX = "none",
444
+ offsetY = "none",
445
+ showOnHover = false
446
+ }) => {
447
+ const positionClasses = {
448
+ "top-left": "top-0 left-0",
449
+ "top-right": "top-0 right-0",
450
+ "bottom-left": "bottom-0 left-0",
451
+ "bottom-right": "bottom-0 right-0",
452
+ "center": "top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2"
352
453
  };
454
+ const marginXClass = position.endsWith("left") ? marginMap[offsetX].replace("m-", "ml-") : marginMap[offsetX].replace("m-", "mr-");
455
+ const marginYClass = position.startsWith("top") ? marginMap[offsetY].replace("m-", "mt-") : marginMap[offsetY].replace("m-", "mb-");
353
456
  return /* @__PURE__ */ jsx(
354
457
  "div",
355
458
  {
356
459
  className: cn(
357
- paddingClasses[padding] || "p-4",
358
- border && "border rounded-md",
359
- overflowClasses[overflow],
360
- className
460
+ "absolute z-10",
461
+ positionClasses[position],
462
+ marginXClass,
463
+ marginYClass,
464
+ showOnHover && "opacity-0 group-hover:opacity-100 transition-opacity"
361
465
  ),
362
- style: {
363
- margin,
364
- background: background ?? void 0,
365
- borderRadius,
366
- width,
367
- height,
368
- ...style
369
- },
370
466
  children
371
467
  }
372
468
  );
373
469
  };
374
470
  var Spacer = ({
375
471
  size = "md",
376
- direction = "vertical",
377
- className,
378
- style
472
+ direction = "vertical"
379
473
  }) => {
380
- const sizeClasses = {
381
- xs: "p-0.5",
382
- sm: "p-1",
383
- md: "p-2",
384
- lg: "p-4",
385
- xl: "p-8"
386
- };
387
474
  return /* @__PURE__ */ jsx(
388
475
  "div",
389
476
  {
390
477
  className: cn(
391
478
  direction === "vertical" ? "w-full" : "h-full",
392
- sizeClasses[size] || "p-2",
393
- className
394
- ),
395
- style
479
+ paddingMap[size]
480
+ )
396
481
  }
397
482
  );
398
483
  };
@@ -416,27 +501,30 @@ function Separator({
416
501
  }
417
502
  var Divider = ({
418
503
  orientation = "horizontal",
419
- className,
420
- style
504
+ color = "border",
505
+ margin = "md"
421
506
  }) => {
422
507
  return /* @__PURE__ */ jsx(
423
508
  Separator,
424
509
  {
425
510
  orientation,
426
- className: cn("my-4", className),
427
- style
511
+ className: cn(
512
+ marginMap[margin],
513
+ colorBgMap[color]
514
+ )
428
515
  }
429
516
  );
430
517
  };
431
- var List = ({ children, width, className, style }) => {
518
+ var List = ({ children, padding = "none", gap = "none", flex, overflow }) => {
432
519
  return /* @__PURE__ */ jsx(
433
520
  "div",
434
521
  {
435
- className: cn("flex flex-col list-none p-0 m-0", className),
436
- style: {
437
- width,
438
- ...style
439
- },
522
+ className: cn(
523
+ "flex flex-col list-none m-0",
524
+ paddingMap[padding],
525
+ gapMap[gap]
526
+ ),
527
+ style: { flex, overflow },
440
528
  children
441
529
  }
442
530
  );
@@ -450,6 +538,9 @@ var useMelony = (options) => {
450
538
  const { initialEvents } = options || {};
451
539
  const prevInitialEventsRef = useRef(void 0);
452
540
  useEffect(() => {
541
+ if (initialEvents && initialEvents === client.getState().events) {
542
+ return;
543
+ }
453
544
  const currentSerialized = initialEvents ? JSON.stringify(initialEvents) : void 0;
454
545
  if (currentSerialized !== prevInitialEventsRef.current) {
455
546
  if (initialEvents) {
@@ -464,46 +555,15 @@ var useMelony = (options) => {
464
555
  };
465
556
  var ListItem = ({
466
557
  children,
467
- orientation = "horizontal",
468
- gap = "md",
469
- align,
470
- justify = "start",
471
558
  onClickAction,
472
- width,
473
- padding = "md",
474
- className,
475
- style
559
+ gap = "sm",
560
+ padding = "sm",
561
+ background,
562
+ radius = "md",
563
+ align = "center"
476
564
  }) => {
477
565
  const { sendEvent } = useMelony();
478
- const paddingClasses = {
479
- xs: "px-1.5 py-1",
480
- sm: "px-2 py-1.5",
481
- md: "px-3 py-1.5",
482
- lg: "px-4 py-3",
483
- xl: "px-6 py-4"
484
- };
485
566
  const isInteractive = !!onClickAction;
486
- const gapClasses = {
487
- xs: "gap-1",
488
- sm: "gap-2",
489
- md: "gap-3",
490
- lg: "gap-4",
491
- xl: "gap-6"
492
- };
493
- const resolvedAlign = align ?? (orientation === "vertical" ? "start" : "center");
494
- const alignClasses = {
495
- start: "items-start",
496
- center: "items-center",
497
- end: "items-end",
498
- stretch: "items-stretch"
499
- };
500
- const justifyClasses = {
501
- start: "justify-start",
502
- center: "justify-center",
503
- end: "justify-end",
504
- between: "justify-between",
505
- around: "justify-around"
506
- };
507
567
  const handleClick = () => {
508
568
  if (onClickAction) {
509
569
  sendEvent(onClickAction);
@@ -514,29 +574,23 @@ var ListItem = ({
514
574
  {
515
575
  onClick: isInteractive ? handleClick : void 0,
516
576
  className: cn(
517
- "flex rounded-md transition-colors text-sm",
518
- orientation === "horizontal" ? "flex-row" : "flex-col",
519
- gapClasses[gap] || "gap-3",
520
- alignClasses[resolvedAlign],
521
- justifyClasses[justify],
522
- paddingClasses[padding] || "px-3 py-2",
523
- isInteractive ? "cursor-pointer hover:bg-muted" : "cursor-default",
524
- className
577
+ "flex flex-row transition-colors text-sm",
578
+ paddingMap[padding],
579
+ background ? colorBgMap[background] : isInteractive && "hover:bg-muted",
580
+ radiusMap[radius],
581
+ isInteractive ? "cursor-pointer" : "cursor-default"
525
582
  ),
526
- style: {
527
- width,
528
- ...style
529
- },
530
- children
583
+ children: /* @__PURE__ */ jsx(Row, { align, gap, children })
531
584
  }
532
585
  );
533
586
  };
534
587
  var Image = ({
535
588
  src,
536
589
  alt,
537
- size = "sm",
538
- className,
539
- style
590
+ width = "auto",
591
+ height,
592
+ radius = "md",
593
+ objectFit = "cover"
540
594
  }) => {
541
595
  const [hasError, setHasError] = useState(false);
542
596
  const [isLoading, setIsLoading] = useState(true);
@@ -567,11 +621,6 @@ var Image = ({
567
621
  };
568
622
  const currentImage = gallery[currentIndex] || { src, alt };
569
623
  const hasMultiple = gallery.length > 1;
570
- const sizes = {
571
- sm: "h-11",
572
- md: "h-22",
573
- lg: "h-44"
574
- };
575
624
  const handleError = () => {
576
625
  setHasError(true);
577
626
  setIsLoading(false);
@@ -584,11 +633,11 @@ var Image = ({
584
633
  "div",
585
634
  {
586
635
  className: cn(
587
- "flex items-center justify-center rounded-md border bg-muted text-muted-foreground",
588
- sizes[size] || "h-11 w-11",
589
- className
636
+ "flex items-center justify-center bg-muted text-muted-foreground",
637
+ widthMap[width],
638
+ radiusMap[radius]
590
639
  ),
591
- style,
640
+ style: { height: height || "100px" },
592
641
  children: /* @__PURE__ */ jsx("span", { className: "text-[10px]", children: "Error" })
593
642
  }
594
643
  );
@@ -599,10 +648,11 @@ var Image = ({
599
648
  {
600
649
  ref: triggerRef,
601
650
  className: cn(
602
- "relative overflow-hidden rounded-md border cursor-pointer",
603
- className
651
+ "relative overflow-hidden cursor-pointer",
652
+ widthMap[width],
653
+ radiusMap[radius]
604
654
  ),
605
- style,
655
+ style: { height },
606
656
  children: [
607
657
  /* @__PURE__ */ jsx(
608
658
  "img",
@@ -612,9 +662,10 @@ var Image = ({
612
662
  onError: handleError,
613
663
  onLoad: handleLoad,
614
664
  className: cn(
615
- "block h-auto w-full transition-opacity duration-200 hover:opacity-90",
665
+ "block w-full transition-opacity duration-200 hover:opacity-90",
616
666
  isLoading ? "opacity-0" : "opacity-100",
617
- sizes[size]
667
+ objectFit === "cover" ? "object-cover" : objectFit === "contain" ? "object-contain" : "object-fill",
668
+ height ? "h-full" : "h-auto"
618
669
  )
619
670
  }
620
671
  ),
@@ -679,9 +730,8 @@ var Video = ({
679
730
  loop = false,
680
731
  muted = false,
681
732
  aspectRatio = "16/9",
682
- width = "100%",
683
- className,
684
- style
733
+ width = "full",
734
+ radius = "lg"
685
735
  }) => {
686
736
  const aspectRatios = {
687
737
  "16/9": "aspect-video",
@@ -693,14 +743,11 @@ var Video = ({
693
743
  "div",
694
744
  {
695
745
  className: cn(
696
- "relative overflow-hidden rounded-lg bg-black shadow-sm",
746
+ "relative overflow-hidden bg-black shadow-sm",
697
747
  aspectRatios[aspectRatio] || "aspect-video",
698
- className
748
+ widthMap[width],
749
+ radiusMap[radius]
699
750
  ),
700
- style: {
701
- width: typeof width === "number" ? `${width}px` : width,
702
- ...style
703
- },
704
751
  children: /* @__PURE__ */ jsx(
705
752
  "video",
706
753
  {
@@ -719,37 +766,24 @@ var Video = ({
719
766
  };
720
767
  var Icon = ({
721
768
  name,
722
- size,
723
- color,
724
- className,
725
- style
769
+ size = "md",
770
+ color = "foreground"
726
771
  }) => {
727
772
  const IconComponent = ICONS[name];
728
773
  if (!IconComponent) return null;
729
774
  const sizeMap = {
730
- xs: 12,
731
775
  sm: 16,
732
776
  md: 20,
733
- lg: 24,
734
- xl: 28,
735
- xxl: 32
777
+ lg: 24
736
778
  };
737
- const resolvedSize = typeof size === "string" && size in sizeMap ? sizeMap[size] : typeof size === "number" ? size : 20;
738
- return /* @__PURE__ */ jsx(
739
- "div",
779
+ const resolvedSize = typeof size === "number" ? size : sizeMap[size] || 20;
780
+ return /* @__PURE__ */ jsx("div", { className: cn("inline-flex items-center justify-center", colorTextMap[color]), children: /* @__PURE__ */ jsx(
781
+ IconComponent,
740
782
  {
741
- className: cn("inline-flex items-center justify-center", className),
742
- style,
743
- children: /* @__PURE__ */ jsx(
744
- IconComponent,
745
- {
746
- size: resolvedSize,
747
- color: color || "currentColor",
748
- strokeWidth: 1.5
749
- }
750
- )
783
+ size: resolvedSize,
784
+ strokeWidth: 1.5
751
785
  }
752
- );
786
+ ) });
753
787
  };
754
788
  var badgeVariants = cva(
755
789
  "h-5 gap-1 rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium transition-all has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&>svg]:size-3! inline-flex items-center justify-center w-fit whitespace-nowrap shrink-0 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-colors overflow-hidden group/badge",
@@ -793,24 +827,26 @@ function Badge({
793
827
  var Badge2 = ({
794
828
  label,
795
829
  variant = "primary",
796
- className,
797
- style
830
+ size = "md"
798
831
  }) => {
799
832
  const variantMap = {
800
833
  primary: "default",
801
834
  secondary: "secondary",
802
835
  danger: "destructive",
803
836
  success: "default",
804
- // Mapping success to default/primary
805
- warning: "secondary"
806
- // Mapping warning to secondary
837
+ warning: "secondary",
838
+ outline: "outline"
839
+ };
840
+ const sizeClasses = {
841
+ sm: "text-[10px] px-1.5 py-0",
842
+ md: "text-xs px-2.5 py-0.5",
843
+ lg: "text-sm px-3 py-1"
807
844
  };
808
845
  return /* @__PURE__ */ jsx(
809
846
  Badge,
810
847
  {
811
848
  variant: variantMap[variant] || "default",
812
- className,
813
- style,
849
+ className: sizeClasses[size],
814
850
  children: label
815
851
  }
816
852
  );
@@ -818,21 +854,20 @@ var Badge2 = ({
818
854
  var Chart = ({
819
855
  data,
820
856
  chartType = "bar",
821
- size = "md",
857
+ title,
858
+ height = 250,
822
859
  showValues = false,
823
860
  showGrid = false,
824
- showTooltips = true,
825
- className,
826
- style
861
+ showTooltips = true
827
862
  }) => {
828
863
  const [tooltip, setTooltip] = useState(null);
829
864
  if (!Array.isArray(data)) {
830
- return /* @__PURE__ */ jsx("div", { className: "p-4 text-destructive border border-destructive/20 rounded-md bg-destructive/5", children: "Error: Chart data must be an array" });
865
+ return /* @__PURE__ */ jsx("div", { className: "p-4 text-destructive border border-destructive/20 rounded-md bg-destructive/5 text-sm", children: "Error: Chart data must be an array" });
831
866
  }
832
867
  const maxValue = Math.max(...data.map((d) => d.value), 1);
833
868
  const padding = { top: 40, right: 20, bottom: 40, left: 20 };
834
- const chartWidth = size === "sm" ? 300 : size === "md" ? 450 : size === "lg" ? 600 : 800;
835
- const chartHeight = size === "sm" ? 150 : size === "md" ? 250 : size === "lg" ? 350 : 450;
869
+ const chartHeight = height;
870
+ const chartWidth = 600;
836
871
  const defaultColors = [
837
872
  "hsl(var(--primary))",
838
873
  "hsl(var(--chart-1, 217 91% 60%))",
@@ -905,7 +940,7 @@ var Chart = ({
905
940
  const totalBarSpace = chartWidth - padding.left - padding.right;
906
941
  const barSpacing = data.length > 1 ? totalBarSpace * 0.1 / data.length : 0;
907
942
  const actualBarWidth = (totalBarSpace - barSpacing * (data.length + 1)) / data.length;
908
- return /* @__PURE__ */ jsxs("svg", { width: chartWidth, height: chartHeight + padding.bottom, className: "overflow-visible", children: [
943
+ return /* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${chartWidth} ${chartHeight + padding.bottom}`, className: "w-full h-auto overflow-visible", children: [
909
944
  renderGrid(),
910
945
  data.map((item, index) => {
911
946
  const barHeight = item.value / maxValue * chartHeight;
@@ -948,7 +983,7 @@ var Chart = ({
948
983
  ...item
949
984
  }));
950
985
  const pathData = points.map((p, i) => `${i === 0 ? "M" : "L"} ${p.x} ${p.y}`).join(" ");
951
- return /* @__PURE__ */ jsxs("svg", { width: chartWidth, height: chartHeight + padding.bottom, className: "overflow-visible", children: [
986
+ return /* @__PURE__ */ jsxs("svg", { viewBox: `0 0 ${chartWidth} ${chartHeight + padding.bottom}`, className: "w-full h-auto overflow-visible", children: [
952
987
  renderGrid(),
953
988
  /* @__PURE__ */ jsx("path", { d: pathData, fill: "none", stroke: getColor(0), strokeWidth: 3, className: "transition-all" }),
954
989
  points.map((point, index) => /* @__PURE__ */ jsxs("g", { children: [
@@ -989,46 +1024,27 @@ var Chart = ({
989
1024
  return renderBarChart();
990
1025
  }
991
1026
  };
992
- return /* @__PURE__ */ jsx("div", { className: cn("py-4 overflow-x-auto", className), style, children: renderChart() });
1027
+ return /* @__PURE__ */ jsxs("div", { className: "py-4 w-full", children: [
1028
+ title && /* @__PURE__ */ jsx("div", { className: "text-sm font-semibold mb-4 text-center", children: title }),
1029
+ renderChart()
1030
+ ] });
993
1031
  };
994
1032
  var Text = ({
995
1033
  value,
996
1034
  size = "md",
997
1035
  weight = "normal",
998
1036
  align = "start",
999
- className,
1000
- style
1037
+ color = "foreground"
1001
1038
  }) => {
1002
- const sizeClasses = {
1003
- xs: "text-xs",
1004
- sm: "text-sm",
1005
- md: "text-base",
1006
- lg: "text-lg",
1007
- xl: "text-xl"
1008
- };
1009
- const weightClasses = {
1010
- light: "font-light",
1011
- normal: "font-normal",
1012
- medium: "font-medium",
1013
- semibold: "font-semibold",
1014
- bold: "font-bold"
1015
- };
1016
- const alignClasses = {
1017
- start: "text-left",
1018
- center: "text-center",
1019
- end: "text-right",
1020
- stretch: "text-justify"
1021
- };
1022
1039
  return /* @__PURE__ */ jsx(
1023
1040
  "span",
1024
1041
  {
1025
1042
  className: cn(
1026
- sizeClasses[size] || "text-base",
1027
- weightClasses[weight] || "font-normal",
1028
- alignClasses[align] || "text-left",
1029
- className
1043
+ textSizeMap[size],
1044
+ fontWeightMap[weight],
1045
+ textAlignMap[align],
1046
+ colorTextMap[color]
1030
1047
  ),
1031
- style,
1032
1048
  children: value
1033
1049
  }
1034
1050
  );
@@ -1036,8 +1052,8 @@ var Text = ({
1036
1052
  var Heading = ({
1037
1053
  value,
1038
1054
  level = 2,
1039
- className,
1040
- style
1055
+ color = "foreground",
1056
+ align = "start"
1041
1057
  }) => {
1042
1058
  const Tag = `h${level}`;
1043
1059
  const levelClasses = {
@@ -1053,10 +1069,9 @@ var Heading = ({
1053
1069
  {
1054
1070
  className: cn(
1055
1071
  levelClasses[Tag] || levelClasses.h2,
1056
- "text-foreground",
1057
- className
1072
+ colorTextMap[color],
1073
+ textAlignMap[align]
1058
1074
  ),
1059
- style,
1060
1075
  children: value
1061
1076
  }
1062
1077
  );
@@ -1133,13 +1148,12 @@ var Input2 = ({
1133
1148
  inputType = "text",
1134
1149
  placeholder,
1135
1150
  defaultValue,
1136
- value,
1137
1151
  label,
1138
1152
  name,
1139
1153
  disabled,
1140
- onChangeAction,
1141
- className,
1142
- style
1154
+ required,
1155
+ width = "full",
1156
+ onChangeAction
1143
1157
  }) => {
1144
1158
  const { sendEvent } = useMelony();
1145
1159
  const handleChange = (e) => {
@@ -1153,8 +1167,11 @@ var Input2 = ({
1153
1167
  });
1154
1168
  }
1155
1169
  };
1156
- return /* @__PURE__ */ jsxs(Field, { className: cn("w-full", className), style, children: [
1157
- label && /* @__PURE__ */ jsx(FieldTitle, { children: label }),
1170
+ return /* @__PURE__ */ jsxs(Field, { className: cn(widthMap[width]), children: [
1171
+ label && /* @__PURE__ */ jsxs(FieldTitle, { children: [
1172
+ label,
1173
+ required && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-1", children: "*" })
1174
+ ] }),
1158
1175
  /* @__PURE__ */ jsx(
1159
1176
  Input,
1160
1177
  {
@@ -1163,9 +1180,9 @@ var Input2 = ({
1163
1180
  id: name,
1164
1181
  placeholder,
1165
1182
  defaultValue,
1166
- value,
1167
1183
  disabled,
1168
- onChange: handleChange
1184
+ onChange: handleChange,
1185
+ required
1169
1186
  }
1170
1187
  )
1171
1188
  ] });
@@ -1186,14 +1203,13 @@ function Textarea({ className, ...props }) {
1186
1203
  var Textarea2 = ({
1187
1204
  placeholder,
1188
1205
  defaultValue,
1189
- value,
1190
1206
  label,
1191
1207
  name,
1192
1208
  disabled,
1193
1209
  rows,
1194
- onChangeAction,
1195
- className,
1196
- style
1210
+ required,
1211
+ width = "full",
1212
+ onChangeAction
1197
1213
  }) => {
1198
1214
  const { sendEvent } = useMelony();
1199
1215
  const handleChange = (e) => {
@@ -1207,8 +1223,11 @@ var Textarea2 = ({
1207
1223
  });
1208
1224
  }
1209
1225
  };
1210
- return /* @__PURE__ */ jsxs(Field, { className: cn("w-full", className), style, children: [
1211
- label && /* @__PURE__ */ jsx(FieldTitle, { children: label }),
1226
+ return /* @__PURE__ */ jsxs(Field, { className: cn(widthMap[width]), children: [
1227
+ label && /* @__PURE__ */ jsxs(FieldTitle, { children: [
1228
+ label,
1229
+ required && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-1", children: "*" })
1230
+ ] }),
1212
1231
  /* @__PURE__ */ jsx(
1213
1232
  Textarea,
1214
1233
  {
@@ -1216,10 +1235,10 @@ var Textarea2 = ({
1216
1235
  id: name,
1217
1236
  placeholder,
1218
1237
  defaultValue,
1219
- value,
1220
1238
  disabled,
1221
1239
  rows,
1222
- onChange: handleChange
1240
+ onChange: handleChange,
1241
+ required
1223
1242
  }
1224
1243
  )
1225
1244
  ] });
@@ -1362,14 +1381,13 @@ function SelectScrollDownButton({
1362
1381
  var Select2 = ({
1363
1382
  options,
1364
1383
  defaultValue,
1365
- value,
1366
1384
  label,
1367
1385
  name,
1368
1386
  disabled,
1387
+ required,
1388
+ width = "full",
1369
1389
  placeholder,
1370
- onChangeAction,
1371
- className,
1372
- style
1390
+ onChangeAction
1373
1391
  }) => {
1374
1392
  const { sendEvent } = useMelony();
1375
1393
  const handleValueChange = (val) => {
@@ -1383,15 +1401,18 @@ var Select2 = ({
1383
1401
  });
1384
1402
  }
1385
1403
  };
1386
- return /* @__PURE__ */ jsxs(Field, { className: cn("w-full", className), style, children: [
1387
- label && /* @__PURE__ */ jsx(FieldTitle, { children: label }),
1404
+ return /* @__PURE__ */ jsxs(Field, { className: cn(widthMap[width]), children: [
1405
+ label && /* @__PURE__ */ jsxs(FieldTitle, { children: [
1406
+ label,
1407
+ required && /* @__PURE__ */ jsx("span", { className: "text-destructive ml-1", children: "*" })
1408
+ ] }),
1388
1409
  /* @__PURE__ */ jsxs(
1389
1410
  Select,
1390
1411
  {
1391
1412
  defaultValue,
1392
- value,
1393
1413
  disabled,
1394
- onValueChange: (value2) => handleValueChange(value2 || ""),
1414
+ onValueChange: (value) => handleValueChange(value || ""),
1415
+ required,
1395
1416
  children: [
1396
1417
  /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, {}) }),
1397
1418
  /* @__PURE__ */ jsx(SelectContent, { children: options.map((option) => /* @__PURE__ */ jsx(SelectItem, { value: option.value, children: option.label }, option.value)) })
@@ -1404,15 +1425,18 @@ var Label2 = ({
1404
1425
  value,
1405
1426
  htmlFor,
1406
1427
  required,
1407
- className,
1408
- style
1428
+ size = "md",
1429
+ color = "foreground"
1409
1430
  }) => {
1410
1431
  return /* @__PURE__ */ jsxs(
1411
1432
  Label,
1412
1433
  {
1413
1434
  htmlFor,
1414
- className: cn("flex items-center gap-1", className),
1415
- style,
1435
+ className: cn(
1436
+ "flex items-center gap-1",
1437
+ textSizeMap[size],
1438
+ colorTextMap[color]
1439
+ ),
1416
1440
  children: [
1417
1441
  value,
1418
1442
  required && /* @__PURE__ */ jsx("span", { className: "text-destructive", children: "*" })
@@ -1424,11 +1448,8 @@ var Checkbox = ({
1424
1448
  label,
1425
1449
  name,
1426
1450
  checked,
1427
- defaultChecked,
1428
1451
  disabled,
1429
- onChangeAction,
1430
- className,
1431
- style
1452
+ onChangeAction
1432
1453
  }) => {
1433
1454
  const { sendEvent } = useMelony();
1434
1455
  const handleChange = (e) => {
@@ -1442,7 +1463,7 @@ var Checkbox = ({
1442
1463
  });
1443
1464
  }
1444
1465
  };
1445
- return /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-2", className), style, children: [
1466
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1446
1467
  /* @__PURE__ */ jsx(
1447
1468
  "input",
1448
1469
  {
@@ -1450,7 +1471,6 @@ var Checkbox = ({
1450
1471
  name,
1451
1472
  id: name,
1452
1473
  checked,
1453
- defaultChecked,
1454
1474
  disabled,
1455
1475
  onChange: handleChange,
1456
1476
  className: "h-4 w-4 rounded border-gray-300 text-primary focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
@@ -1461,10 +1481,8 @@ var Checkbox = ({
1461
1481
  {
1462
1482
  htmlFor: name,
1463
1483
  value: label,
1464
- className: cn(
1465
- "cursor-pointer select-none text-sm font-medium leading-none",
1466
- disabled && "cursor-not-allowed opacity-50"
1467
- )
1484
+ color: disabled ? "muted" : "foreground",
1485
+ size: "sm"
1468
1486
  }
1469
1487
  )
1470
1488
  ] });
@@ -1699,19 +1717,11 @@ var ColorPicker = ({
1699
1717
  name,
1700
1718
  label,
1701
1719
  defaultValue = "#000000",
1702
- value: controlledValue,
1703
1720
  onChangeAction,
1704
- disabled,
1705
- className,
1706
- style
1721
+ disabled
1707
1722
  }) => {
1708
1723
  const { sendEvent } = useMelony();
1709
- const [color, setColor] = useState(controlledValue || defaultValue);
1710
- useEffect(() => {
1711
- if (controlledValue !== void 0) {
1712
- setColor(controlledValue);
1713
- }
1714
- }, [controlledValue]);
1724
+ const [color, setColor] = useState(defaultValue);
1715
1725
  const handleColorChange = (newColor) => {
1716
1726
  setColor(newColor);
1717
1727
  if (onChangeAction) {
@@ -1724,7 +1734,7 @@ var ColorPicker = ({
1724
1734
  });
1725
1735
  }
1726
1736
  };
1727
- return /* @__PURE__ */ jsxs(Field, { className: cn("w-full", className), style, children: [
1737
+ return /* @__PURE__ */ jsxs(Field, { className: "w-full", children: [
1728
1738
  label && /* @__PURE__ */ jsx(FieldTitle, { children: label }),
1729
1739
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
1730
1740
  /* @__PURE__ */ jsxs(Popover, { children: [
@@ -1791,13 +1801,10 @@ var RadioGroup = ({
1791
1801
  name,
1792
1802
  options,
1793
1803
  defaultValue,
1794
- value,
1795
1804
  label,
1796
1805
  disabled,
1797
1806
  orientation = "vertical",
1798
- onChangeAction,
1799
- className,
1800
- style
1807
+ onChangeAction
1801
1808
  }) => {
1802
1809
  const { sendEvent } = useMelony();
1803
1810
  const handleChange = (e) => {
@@ -1811,8 +1818,8 @@ var RadioGroup = ({
1811
1818
  });
1812
1819
  }
1813
1820
  };
1814
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col gap-3", className), style, children: [
1815
- label && /* @__PURE__ */ jsx(Label2, { value: label, className: "text-sm font-semibold" }),
1821
+ return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3", children: [
1822
+ label && /* @__PURE__ */ jsx(Label2, { value: label }),
1816
1823
  /* @__PURE__ */ jsx(
1817
1824
  "div",
1818
1825
  {
@@ -1835,8 +1842,7 @@ var RadioGroup = ({
1835
1842
  name,
1836
1843
  id: radioId,
1837
1844
  value: option.value,
1838
- defaultChecked: defaultValue === option.value ? true : void 0,
1839
- checked: value === option.value,
1845
+ defaultChecked: defaultValue === option.value,
1840
1846
  disabled: isDisabled,
1841
1847
  onChange: handleChange,
1842
1848
  className: "h-4 w-4 border-gray-300 text-primary focus:ring-primary disabled:cursor-not-allowed disabled:opacity-50"
@@ -1847,10 +1853,8 @@ var RadioGroup = ({
1847
1853
  {
1848
1854
  htmlFor: radioId,
1849
1855
  value: option.label,
1850
- className: cn(
1851
- "cursor-pointer select-none text-sm font-medium leading-none",
1852
- isDisabled && "cursor-not-allowed opacity-50"
1853
- )
1856
+ size: "sm",
1857
+ color: isDisabled ? "muted" : "foreground"
1854
1858
  }
1855
1859
  )
1856
1860
  ]
@@ -1907,26 +1911,34 @@ function Button({
1907
1911
  );
1908
1912
  }
1909
1913
  var Button2 = ({
1910
- type,
1914
+ type = "button",
1911
1915
  label,
1912
1916
  variant = "primary",
1913
- size = "default",
1917
+ size = "md",
1914
1918
  disabled = false,
1915
- fullWidth = false,
1919
+ width,
1916
1920
  onClickAction,
1917
- className,
1918
- style
1921
+ justify = "center"
1919
1922
  }) => {
1920
1923
  const { sendEvent } = useMelony();
1921
1924
  const variantMap = {
1922
1925
  primary: "default",
1923
1926
  secondary: "secondary",
1924
1927
  danger: "destructive",
1928
+ success: "default",
1929
+ // We might want a custom success style later
1925
1930
  outline: "outline",
1926
1931
  ghost: "ghost",
1927
- link: "link",
1928
- success: "default"
1929
- // Success doesn't have a direct shadcn mapping in base variant, default is usually primary
1932
+ link: "link"
1933
+ };
1934
+ const widthMap2 = {
1935
+ full: "w-full",
1936
+ auto: "w-auto",
1937
+ "1/2": "w-1/2",
1938
+ "1/3": "w-1/3",
1939
+ "2/3": "w-2/3",
1940
+ "1/4": "w-1/4",
1941
+ "3/4": "w-3/4"
1930
1942
  };
1931
1943
  return /* @__PURE__ */ jsx(
1932
1944
  Button,
@@ -1935,8 +1947,7 @@ var Button2 = ({
1935
1947
  variant: variantMap[variant] || "default",
1936
1948
  size: size === "md" ? "default" : size,
1937
1949
  disabled,
1938
- className: cn(fullWidth ? "w-full" : void 0, className),
1939
- style,
1950
+ className: cn(width && widthMap2[width], justifyMap[justify]),
1940
1951
  onClick: () => {
1941
1952
  if (onClickAction) {
1942
1953
  sendEvent(onClickAction);
@@ -1951,10 +1962,9 @@ var Upload = ({
1951
1962
  multiple = false,
1952
1963
  accept,
1953
1964
  onUploadAction,
1954
- className,
1955
- style,
1956
1965
  initialFiles,
1957
- mode = "append"
1966
+ mode = "append",
1967
+ disabled
1958
1968
  }) => {
1959
1969
  const { sendEvent, events } = useMelony();
1960
1970
  const fileInputRef = useRef(null);
@@ -2024,7 +2034,7 @@ var Upload = ({
2024
2034
  }
2025
2035
  }
2026
2036
  };
2027
- return /* @__PURE__ */ jsxs("div", { className: cn("relative inline-block", className), style, children: [
2037
+ return /* @__PURE__ */ jsxs("div", { className: "relative inline-block", children: [
2028
2038
  /* @__PURE__ */ jsx(
2029
2039
  "input",
2030
2040
  {
@@ -2034,11 +2044,11 @@ var Upload = ({
2034
2044
  multiple,
2035
2045
  accept,
2036
2046
  className: "hidden",
2037
- disabled: isUploading
2047
+ disabled: isUploading || disabled
2038
2048
  }
2039
2049
  ),
2040
2050
  /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2 mb-2 items-center", children: [
2041
- showInitialFiles && initialFiles?.map((file, index) => /* @__PURE__ */ jsx(Image, { src: file.url, alt: file.name, size: "md" }, index)),
2051
+ showInitialFiles && initialFiles?.map((file, index) => /* @__PURE__ */ jsx(Image, { src: file.url, alt: file.name, width: "min", radius: "md" }, index)),
2042
2052
  displayEvents.map(
2043
2053
  (event, index) => event.ui ? /* @__PURE__ */ jsx(UIRenderer, { node: event.ui }, index) : null
2044
2054
  ),
@@ -2046,12 +2056,11 @@ var Upload = ({
2046
2056
  Button,
2047
2057
  {
2048
2058
  type: "button",
2049
- disabled: isUploading,
2059
+ disabled: isUploading || disabled,
2050
2060
  onClick: () => fileInputRef.current?.click(),
2051
- className: "gap-2",
2052
- variant: status === "error" ? "destructive" : status === "success" ? "outline" : "default",
2061
+ variant: "default",
2053
2062
  children: [
2054
- isUploading ? /* @__PURE__ */ jsx(IconLoader2, { className: "h-4 w-4 animate-spin" }) : status === "success" ? /* @__PURE__ */ jsx(IconCheck, { className: "h-4 w-4 text-green-500" }) : status === "error" ? /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(IconUpload, { className: "h-4 w-4" }),
2063
+ isUploading ? /* @__PURE__ */ jsx(IconLoader2, { className: "h-4 w-4 animate-spin mr-2" }) : status === "success" ? /* @__PURE__ */ jsx(IconCheck, { className: "h-4 w-4 text-green-500 mr-2" }) : status === "error" ? /* @__PURE__ */ jsx(IconX, { className: "h-4 w-4 mr-2" }) : /* @__PURE__ */ jsx(IconUpload, { className: "h-4 w-4 mr-2" }),
2055
2064
  status === "success" ? "Uploaded" : status === "error" ? "Failed" : label
2056
2065
  ]
2057
2066
  }
@@ -2062,8 +2071,7 @@ var Upload = ({
2062
2071
  var Form = ({
2063
2072
  children,
2064
2073
  onSubmitAction,
2065
- className,
2066
- style
2074
+ gap = "md"
2067
2075
  }) => {
2068
2076
  const { sendEvent } = useMelony();
2069
2077
  const [isSubmitted, setIsSubmitted] = useState(false);
@@ -2077,7 +2085,7 @@ var Form = ({
2077
2085
  });
2078
2086
  if (onSubmitAction) {
2079
2087
  setIsSubmitted(true);
2080
- if ("type" in onSubmitAction) {
2088
+ if (typeof onSubmitAction === "object" && "type" in onSubmitAction) {
2081
2089
  sendEvent({
2082
2090
  ...onSubmitAction,
2083
2091
  data: {
@@ -2085,7 +2093,7 @@ var Form = ({
2085
2093
  ...data
2086
2094
  }
2087
2095
  });
2088
- } else {
2096
+ } else if (typeof onSubmitAction === "function") {
2089
2097
  sendEvent(onSubmitAction(data));
2090
2098
  }
2091
2099
  }
@@ -2094,13 +2102,13 @@ var Form = ({
2094
2102
  "form",
2095
2103
  {
2096
2104
  onSubmit: handleSubmit,
2097
- className: cn("w-full", className),
2098
- style,
2105
+ className: "w-full",
2099
2106
  children: /* @__PURE__ */ jsx("fieldset", { disabled: isSubmitted, className: "m-0 border-0 p-0", children: /* @__PURE__ */ jsx(
2100
2107
  "div",
2101
2108
  {
2102
2109
  className: cn(
2103
- "flex flex-col gap-4 transition-opacity",
2110
+ "flex flex-col transition-opacity",
2111
+ gapMap[gap],
2104
2112
  isSubmitted && "opacity-60 pointer-events-none"
2105
2113
  ),
2106
2114
  children
@@ -2129,6 +2137,7 @@ function UIRenderer({ node }) {
2129
2137
  spacer: Spacer,
2130
2138
  divider: Divider,
2131
2139
  box: Box,
2140
+ float: Float,
2132
2141
  image: Image,
2133
2142
  video: Video,
2134
2143
  icon: Icon,
@@ -2148,8 +2157,7 @@ function UIRenderer({ node }) {
2148
2157
  ] });
2149
2158
  }
2150
2159
  const renderedChildren = children?.map((child, i) => /* @__PURE__ */ jsx(UIRenderer, { node: child }, i));
2151
- const componentProps = { ...props };
2152
- return /* @__PURE__ */ jsx(Component, { ...componentProps, children: renderedChildren });
2160
+ return /* @__PURE__ */ jsx(Component, { ...props, children: renderedChildren });
2153
2161
  }
2154
2162
  var MelonyContext = createContext(
2155
2163
  void 0
@@ -2204,8 +2212,8 @@ var MelonyContextProviderInner = ({
2204
2212
  window.history.replaceState(null, "", url);
2205
2213
  } else {
2206
2214
  window.history.pushState(null, "", url);
2207
- window.dispatchEvent(new PopStateEvent("popstate"));
2208
2215
  }
2216
+ window.dispatchEvent(new PopStateEvent("popstate"));
2209
2217
  }
2210
2218
  return true;
2211
2219
  }
@@ -3007,6 +3015,16 @@ var useThreads = () => {
3007
3015
  }
3008
3016
  return context;
3009
3017
  };
3018
+ var useSurface = (options) => {
3019
+ const { events } = useMelony();
3020
+ const surfaceEvents = useMemo(() => {
3021
+ const filtered = events.filter((event) => event.surface === options.name);
3022
+ return filterEventsBySlots(filtered);
3023
+ }, [events, options.name]);
3024
+ return {
3025
+ events: surfaceEvents
3026
+ };
3027
+ };
3010
3028
  function Composer({
3011
3029
  value,
3012
3030
  onChange,
@@ -3304,8 +3322,7 @@ function Composer({
3304
3322
  ] }) });
3305
3323
  }
3306
3324
  function StarterPrompts({
3307
- prompts,
3308
- onPromptClick
3325
+ prompts
3309
3326
  }) {
3310
3327
  if (!prompts || prompts.length === 0) {
3311
3328
  return null;
@@ -3323,32 +3340,15 @@ function StarterPrompts({
3323
3340
  role: "user",
3324
3341
  data: { content: item.prompt }
3325
3342
  },
3326
- className: "w-full justify-start"
3343
+ justify: "start"
3327
3344
  },
3328
3345
  index
3329
3346
  )) })
3330
3347
  ] });
3331
3348
  }
3332
3349
  function MessageContent({ events }) {
3333
- const firstSlotIndexes = /* @__PURE__ */ new Map();
3334
- const latestSlotIndexes = /* @__PURE__ */ new Map();
3335
- events.forEach((event, index) => {
3336
- if (event.slot) {
3337
- if (!firstSlotIndexes.has(event.slot)) {
3338
- firstSlotIndexes.set(event.slot, index);
3339
- }
3340
- latestSlotIndexes.set(event.slot, index);
3341
- }
3342
- });
3343
- return /* @__PURE__ */ jsx(Fragment, { children: events.map((event, index) => {
3344
- let displayEvent = event;
3345
- if (event.slot) {
3346
- if (firstSlotIndexes.get(event.slot) !== index) {
3347
- return null;
3348
- }
3349
- const latestIndex = latestSlotIndexes.get(event.slot);
3350
- displayEvent = events[latestIndex];
3351
- }
3350
+ const displayEvents = useMemo(() => filterEventsBySlots(events), [events]);
3351
+ return /* @__PURE__ */ jsx(Fragment, { children: displayEvents.map((displayEvent, index) => {
3352
3352
  if (displayEvent.type === "text-delta") {
3353
3353
  return /* @__PURE__ */ jsx("span", { children: displayEvent.data?.delta }, index);
3354
3354
  }
@@ -3419,10 +3419,8 @@ function MessageList({
3419
3419
  ] });
3420
3420
  }
3421
3421
  function Thread({
3422
- className,
3423
3422
  placeholder = "Type a message...",
3424
3423
  starterPrompts: localStarterPrompts,
3425
- onStarterPromptClick,
3426
3424
  options: localOptions,
3427
3425
  autoFocus = false,
3428
3426
  defaultSelectedIds
@@ -3438,9 +3436,14 @@ function Thread({
3438
3436
  } = useMelony({
3439
3437
  initialEvents: threadEvents
3440
3438
  });
3441
- const messages = initialMessages.filter(
3442
- (x) => ["user", "assistant"].includes(x.role)
3443
- );
3439
+ const messages = useMemo(() => {
3440
+ return initialMessages.map((msg) => ({
3441
+ ...msg,
3442
+ content: msg.content.filter((event) => !event.surface)
3443
+ })).filter(
3444
+ (msg) => ["user", "assistant"].includes(msg.role) && msg.content.length > 0
3445
+ );
3446
+ }, [initialMessages]);
3444
3447
  const starterPrompts = localStarterPrompts ?? config?.starterPrompts;
3445
3448
  const options = localOptions ?? config?.options;
3446
3449
  const fileAttachments = config?.fileAttachments;
@@ -3473,18 +3476,11 @@ function Thread({
3473
3476
  }
3474
3477
  });
3475
3478
  };
3476
- const handleStarterPromptClick = (prompt) => {
3477
- if (onStarterPromptClick) {
3478
- onStarterPromptClick(prompt);
3479
- } else {
3480
- handleSubmit(void 0, prompt);
3481
- }
3482
- };
3483
3479
  const showStarterPrompts = messages.length === 0 && starterPrompts && starterPrompts.length > 0 && !isLoadingEvents;
3484
3480
  return /* @__PURE__ */ jsxs(
3485
3481
  "div",
3486
3482
  {
3487
- className: cn("relative flex flex-col h-full bg-background", className),
3483
+ className: "relative flex flex-col h-full bg-background flex-1 overflow-hidden",
3488
3484
  children: [
3489
3485
  /* @__PURE__ */ jsxs("div", { className: "flex-1 overflow-y-auto p-4 pb-36", children: [
3490
3486
  /* @__PURE__ */ jsx(
@@ -3498,8 +3494,7 @@ function Thread({
3498
3494
  showStarterPrompts && /* @__PURE__ */ jsx(
3499
3495
  StarterPrompts,
3500
3496
  {
3501
- prompts: starterPrompts,
3502
- onPromptClick: handleStarterPromptClick
3497
+ prompts: starterPrompts
3503
3498
  }
3504
3499
  ),
3505
3500
  /* @__PURE__ */ jsx(
@@ -3598,7 +3593,7 @@ var Dropdown = ({
3598
3593
  ] }, item.label)) })
3599
3594
  ] });
3600
3595
  };
3601
- var ThreadList = ({ className }) => {
3596
+ var ThreadList = ({ padding, background, gap, radius = "md" }) => {
3602
3597
  const { threads, activeThreadId, deleteThread } = useThreads();
3603
3598
  const sortedThreads = React3.useMemo(() => {
3604
3599
  return [...threads].sort((a, b) => {
@@ -3614,8 +3609,8 @@ var ThreadList = ({ className }) => {
3614
3609
  console.error("Failed to delete thread:", error);
3615
3610
  }
3616
3611
  };
3617
- return /* @__PURE__ */ jsx(List, { className, children: sortedThreads.map((thread) => {
3618
- const isActive = thread.id === activeThreadId;
3612
+ return /* @__PURE__ */ jsx(List, { padding, gap, flex: "1", overflow: "scroll", children: sortedThreads.map((thread) => {
3613
+ thread.id === activeThreadId;
3619
3614
  return /* @__PURE__ */ jsxs(
3620
3615
  ListItem,
3621
3616
  {
@@ -3625,7 +3620,10 @@ var ThreadList = ({ className }) => {
3625
3620
  url: `?threadId=${thread.id}`
3626
3621
  }
3627
3622
  },
3628
- className: isActive ? "bg-muted text-foreground group" : "hover:bg-muted/50 text-muted-foreground hover:text-foreground group",
3623
+ background,
3624
+ radius,
3625
+ padding,
3626
+ gap,
3629
3627
  children: [
3630
3628
  /* @__PURE__ */ jsx("div", { className: "flex-1 min-w-0", children: /* @__PURE__ */ jsx("p", { className: "text-sm font-medium truncate", children: thread.title || `Thread ${thread.id.slice(0, 8)}` }) }),
3631
3629
  /* @__PURE__ */ jsx("div", { className: "shrink-0 flex items-center opacity-0 group-hover:opacity-100 transition-opacity", children: /* @__PURE__ */ jsx(
@@ -3725,13 +3723,15 @@ function PopupChat({
3725
3723
  placeholder,
3726
3724
  starterPrompts,
3727
3725
  options,
3728
- className: "h-full",
3729
3726
  defaultSelectedIds
3730
3727
  }
3731
3728
  ) : /* @__PURE__ */ jsx(
3732
3729
  ThreadList,
3733
3730
  {
3734
- className: "h-full"
3731
+ padding: "md",
3732
+ gap: "md",
3733
+ background: "muted",
3734
+ radius: "md"
3735
3735
  }
3736
3736
  ) })
3737
3737
  ] }),
@@ -3749,9 +3749,10 @@ function PopupChat({
3749
3749
  )
3750
3750
  ] });
3751
3751
  }
3752
- function Sidebar({ side, children, className }) {
3752
+ function Sidebar({ side, children, width = "1/4" }) {
3753
3753
  const { leftCollapsed, rightCollapsed } = useSidebar();
3754
3754
  const collapsed = side === "left" ? leftCollapsed : rightCollapsed;
3755
+ const widthClass = widthMap[width];
3755
3756
  return /* @__PURE__ */ jsx(
3756
3757
  "div",
3757
3758
  {
@@ -3759,8 +3760,9 @@ function Sidebar({ side, children, className }) {
3759
3760
  "flex-shrink-0 border-border bg-background transition-all duration-300 ease-in-out overflow-hidden flex flex-col",
3760
3761
  side === "left" ? "border-r" : "border-l",
3761
3762
  collapsed ? "w-0 border-r-0 border-l-0 min-w-0" : "",
3762
- !collapsed && className
3763
+ !collapsed && widthClass
3763
3764
  ),
3765
+ style: !collapsed && !widthClass ? { width } : void 0,
3764
3766
  children: /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-hidden min-h-0 flex flex-col", children })
3765
3767
  }
3766
3768
  );
@@ -3789,6 +3791,10 @@ function FullChat({
3789
3791
  ) }) })
3790
3792
  ] });
3791
3793
  }
3794
+ function Surface({ name, children }) {
3795
+ const { events } = useSurface({ name });
3796
+ return /* @__PURE__ */ jsx(Fragment, { children: children(events) });
3797
+ }
3792
3798
  function SidebarToggle({ side, className }) {
3793
3799
  const {
3794
3800
  leftCollapsed,
@@ -3828,13 +3834,7 @@ function SidebarToggle({ side, className }) {
3828
3834
  }
3829
3835
  return null;
3830
3836
  }
3831
- var ThreadPopover = ({
3832
- className,
3833
- buttonClassName,
3834
- buttonVariant = "ghost",
3835
- buttonSize = "icon",
3836
- emptyState
3837
- }) => {
3837
+ var ThreadPopover = ({}) => {
3838
3838
  const [isOpen, setIsOpen] = React3.useState(false);
3839
3839
  useHotkeys(
3840
3840
  "h",
@@ -3853,20 +3853,19 @@ var ThreadPopover = ({
3853
3853
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
3854
3854
  Button,
3855
3855
  {
3856
- variant: buttonVariant,
3857
- size: buttonSize,
3858
- className: cn(buttonClassName),
3856
+ variant: "ghost",
3857
+ size: "icon",
3859
3858
  children: /* @__PURE__ */ jsx(IconHistory, { className: "size-4" })
3860
3859
  }
3861
3860
  ) }),
3862
3861
  /* @__PURE__ */ jsx(
3863
3862
  PopoverContent,
3864
3863
  {
3865
- className: cn("w-80 p-0", className),
3864
+ className: "w-80 p-0",
3866
3865
  side: "bottom",
3867
3866
  align: "start",
3868
3867
  sideOffset: 8,
3869
- children: /* @__PURE__ */ jsx("div", { className: "flex flex-col h-[400px]", children: /* @__PURE__ */ jsx(ThreadList, { emptyState, className: "h-full" }) })
3868
+ children: /* @__PURE__ */ jsx("div", { className: "flex flex-col h-[400px]", children: /* @__PURE__ */ jsx(ThreadList, {}) })
3870
3869
  }
3871
3870
  )
3872
3871
  ] });
@@ -3957,7 +3956,9 @@ function ThemeToggle() {
3957
3956
  );
3958
3957
  }
3959
3958
  var CreateThreadListItem = ({
3960
- className
3959
+ padding = "sm",
3960
+ background,
3961
+ radius = "md"
3961
3962
  }) => {
3962
3963
  const { createThread } = useThreads();
3963
3964
  const [isCreating, setIsCreating] = React3.useState(false);
@@ -3994,7 +3995,9 @@ var CreateThreadListItem = ({
3994
3995
  url: "?"
3995
3996
  }
3996
3997
  },
3997
- className: cn(className, "border roudned-lg"),
3998
+ padding,
3999
+ background,
4000
+ radius,
3998
4001
  children: [
3999
4002
  /* @__PURE__ */ jsx(IconPlus, { className: "size-4" }),
4000
4003
  "New chat"
@@ -4003,6 +4006,6 @@ var CreateThreadListItem = ({
4003
4006
  );
4004
4007
  };
4005
4008
 
4006
- export { AccountButton, AuthContext, AuthProvider, Badge2 as Badge, Box, Button2 as Button, Card2 as Card, Chart, ChatHeader, Checkbox, Col, ColorPicker, Composer, CreateThreadButton, CreateThreadListItem, Divider, Dropdown, Form, FullChat, Heading, Hidden, Image, Input2 as Input, Label2 as Label, List, ListItem, MelonyContext, MelonyProvider, PopupChat, RadioGroup, Row, Select2 as Select, Sidebar, SidebarContext, SidebarProvider, SidebarToggle, Spacer, Text, Textarea2 as Textarea, ThemeProvider, ThemeToggle, Thread, ThreadContext, ThreadList, ThreadPopover, ThreadProvider, UIRenderer, Upload, WelcomeScreen, useAuth, useMelony, useScreenSize, useSidebar, useTheme, useThreads };
4009
+ export { AccountButton, AuthContext, AuthProvider, Badge2 as Badge, Box, Button2 as Button, Card2 as Card, Chart, ChatHeader, Checkbox, Col, ColorPicker, Composer, CreateThreadButton, CreateThreadListItem, Divider, Dropdown, Float, Form, FullChat, Heading, Hidden, Image, Input2 as Input, Label2 as Label, List, ListItem, MelonyContext, MelonyProvider, PopupChat, RadioGroup, Row, Select2 as Select, Sidebar, SidebarContext, SidebarProvider, SidebarToggle, Spacer, Surface, Text, Textarea2 as Textarea, ThemeProvider, ThemeToggle, Thread, ThreadContext, ThreadList, ThreadPopover, ThreadProvider, UIRenderer, Upload, WelcomeScreen, useAuth, useMelony, useScreenSize, useSidebar, useSurface, useTheme, useThreads };
4007
4010
  //# sourceMappingURL=index.js.map
4008
4011
  //# sourceMappingURL=index.js.map