@bubble-design-system/ui 1.0.1 → 1.2.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { clsx } from 'clsx';
3
- import { forwardRef, createContext, useMemo, useContext } from 'react';
3
+ import { forwardRef, createContext, useMemo, useContext, useState, useEffect, useRef } from 'react';
4
4
  import { Button as Button$1 } from '@base-ui/react/button';
5
5
  import { jsx, jsxs } from 'react/jsx-runtime';
6
6
  import { Input as Input$1 } from '@base-ui/react/input';
@@ -18,6 +18,7 @@ import { Tabs as Tabs$1 } from '@base-ui/react/tabs';
18
18
  import { Menu } from '@base-ui/react/menu';
19
19
  import { Toggle } from '@base-ui/react/toggle';
20
20
  import { ToggleGroup } from '@base-ui/react/toggle-group';
21
+ import { Popover as Popover$1 } from '@base-ui/react/popover';
21
22
 
22
23
  // src/utils/cn.ts
23
24
  function cn(...inputs) {
@@ -194,15 +195,22 @@ var SelectValue = forwardRef(
194
195
  SelectValue.displayName = "Select.Value";
195
196
  var SelectContent = forwardRef(
196
197
  ({ className, sideOffset = 6, children, ...props }, ref) => {
197
- return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(Select$1.Positioner, { sideOffset, className: "pds-select-positioner", children: /* @__PURE__ */ jsx(
198
- Select$1.Popup,
198
+ return /* @__PURE__ */ jsx(Select$1.Portal, { children: /* @__PURE__ */ jsx(
199
+ Select$1.Positioner,
199
200
  {
200
- ref,
201
- className: cn("pds-select-popup", className),
202
- ...props,
203
- children
201
+ sideOffset,
202
+ className: "pds-select-positioner",
203
+ children: /* @__PURE__ */ jsx(
204
+ Select$1.Popup,
205
+ {
206
+ ref,
207
+ className: cn("pds-select-popup", className),
208
+ ...props,
209
+ children
210
+ }
211
+ )
204
212
  }
205
- ) }) });
213
+ ) });
206
214
  }
207
215
  );
208
216
  SelectContent.displayName = "Select.Content";
@@ -321,7 +329,12 @@ Divider.displayName = "Divider";
321
329
  var ModalContent = forwardRef(
322
330
  ({ className, backdropClassName, children, ...props }, ref) => {
323
331
  return /* @__PURE__ */ jsxs(Dialog.Portal, { children: [
324
- /* @__PURE__ */ jsx(Dialog.Backdrop, { className: cn("pds-modal-backdrop", backdropClassName) }),
332
+ /* @__PURE__ */ jsx(
333
+ Dialog.Backdrop,
334
+ {
335
+ className: cn("pds-modal-backdrop", backdropClassName)
336
+ }
337
+ ),
325
338
  /* @__PURE__ */ jsx(
326
339
  Dialog.Popup,
327
340
  {
@@ -348,18 +361,16 @@ var ModalTitle = forwardRef(
348
361
  }
349
362
  );
350
363
  ModalTitle.displayName = "Modal.Title";
351
- var ModalDescription = forwardRef(
352
- ({ className, ...props }, ref) => {
353
- return /* @__PURE__ */ jsx(
354
- Dialog.Description,
355
- {
356
- ref,
357
- className: cn("pds-modal-description", className),
358
- ...props
359
- }
360
- );
361
- }
362
- );
364
+ var ModalDescription = forwardRef(({ className, ...props }, ref) => {
365
+ return /* @__PURE__ */ jsx(
366
+ Dialog.Description,
367
+ {
368
+ ref,
369
+ className: cn("pds-modal-description", className),
370
+ ...props
371
+ }
372
+ );
373
+ });
363
374
  ModalDescription.displayName = "Modal.Description";
364
375
  var Modal = {
365
376
  Root: Dialog.Root,
@@ -374,50 +385,33 @@ var ToastProvider = ({ children, ...props }) => {
374
385
  return /* @__PURE__ */ jsx(Toast$1.Provider, { ...props, children });
375
386
  };
376
387
  ToastProvider.displayName = "Toast.Provider";
377
- var ToastViewport = forwardRef(
378
- ({ className, ...props }, ref) => {
379
- return /* @__PURE__ */ jsx(
380
- Toast$1.Viewport,
381
- {
382
- ref,
383
- className: cn("pds-toast-viewport", className),
384
- style: { ["--gap"]: "12px" },
385
- ...props
386
- }
387
- );
388
- }
389
- );
388
+ var ToastViewport = forwardRef(({ className, ...props }, ref) => {
389
+ return /* @__PURE__ */ jsx(
390
+ Toast$1.Viewport,
391
+ {
392
+ ref,
393
+ className: cn("pds-toast-viewport", className),
394
+ style: { ["--gap"]: "12px" },
395
+ ...props
396
+ }
397
+ );
398
+ });
390
399
  ToastViewport.displayName = "Toast.Viewport";
391
400
  var Toaster = () => {
392
401
  const { toasts } = useToastManager();
393
- return /* @__PURE__ */ jsx(ToastViewport, { children: toasts.map((toast) => /* @__PURE__ */ jsxs(
394
- Toast$1.Root,
395
- {
396
- toast,
397
- className: "pds-toast-item",
398
- children: [
399
- toast.title ? /* @__PURE__ */ jsx(Toast$1.Title, { className: "pds-toast-title" }) : null,
400
- toast.description ? /* @__PURE__ */ jsx(Toast$1.Description, { className: "pds-toast-description" }) : null,
401
- /* @__PURE__ */ jsx(
402
- Toast$1.Close,
403
- {
404
- "aria-label": "Close",
405
- className: "pds-toast-close",
406
- children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
407
- "path",
408
- {
409
- d: "M4 4l8 8M12 4l-8 8",
410
- stroke: "currentColor",
411
- strokeWidth: "1.5",
412
- strokeLinecap: "round"
413
- }
414
- ) })
415
- }
416
- )
417
- ]
418
- },
419
- toast.id
420
- )) });
402
+ return /* @__PURE__ */ jsx(ToastViewport, { children: toasts.map((toast) => /* @__PURE__ */ jsxs(Toast$1.Root, { toast, className: "pds-toast-item", children: [
403
+ toast.title ? /* @__PURE__ */ jsx(Toast$1.Title, { className: "pds-toast-title" }) : null,
404
+ toast.description ? /* @__PURE__ */ jsx(Toast$1.Description, { className: "pds-toast-description" }) : null,
405
+ /* @__PURE__ */ jsx(Toast$1.Close, { "aria-label": "Close", className: "pds-toast-close", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
406
+ "path",
407
+ {
408
+ d: "M4 4l8 8M12 4l-8 8",
409
+ stroke: "currentColor",
410
+ strokeWidth: "1.5",
411
+ strokeLinecap: "round"
412
+ }
413
+ ) }) })
414
+ ] }, toast.id)) });
421
415
  };
422
416
  Toaster.displayName = "Toaster";
423
417
  var Toast = {
@@ -426,7 +420,14 @@ var Toast = {
426
420
  Toaster
427
421
  };
428
422
  var TooltipContent = forwardRef(
429
- ({ className, sideOffset = 6, side = "top", align = "center", children, ...props }, ref) => {
423
+ ({
424
+ className,
425
+ sideOffset = 6,
426
+ side = "top",
427
+ align = "center",
428
+ children,
429
+ ...props
430
+ }, ref) => {
430
431
  return /* @__PURE__ */ jsx(Tooltip$1.Portal, { children: /* @__PURE__ */ jsx(
431
432
  Tooltip$1.Positioner,
432
433
  {
@@ -518,21 +519,62 @@ var Tabs = Object.assign(TabsRoot, {
518
519
  var icons = {
519
520
  info: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
520
521
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
521
- /* @__PURE__ */ jsx("path", { d: "M8 7.5v4", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
522
+ /* @__PURE__ */ jsx(
523
+ "path",
524
+ {
525
+ d: "M8 7.5v4",
526
+ stroke: "currentColor",
527
+ strokeWidth: "1.5",
528
+ strokeLinecap: "round"
529
+ }
530
+ ),
522
531
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "5", r: "0.75", fill: "currentColor" })
523
532
  ] }),
524
533
  success: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
525
534
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
526
- /* @__PURE__ */ jsx("path", { d: "M5 8.5l2 2 4-4.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round" })
535
+ /* @__PURE__ */ jsx(
536
+ "path",
537
+ {
538
+ d: "M5 8.5l2 2 4-4.5",
539
+ stroke: "currentColor",
540
+ strokeWidth: "1.5",
541
+ strokeLinecap: "round",
542
+ strokeLinejoin: "round"
543
+ }
544
+ )
527
545
  ] }),
528
546
  warning: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
529
- /* @__PURE__ */ jsx("path", { d: "M8 1.75L14.5 13.5h-13L8 1.75z", stroke: "currentColor", strokeWidth: "1.5", strokeLinejoin: "round" }),
530
- /* @__PURE__ */ jsx("path", { d: "M8 6.5v3.5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
547
+ /* @__PURE__ */ jsx(
548
+ "path",
549
+ {
550
+ d: "M8 1.75L14.5 13.5h-13L8 1.75z",
551
+ stroke: "currentColor",
552
+ strokeWidth: "1.5",
553
+ strokeLinejoin: "round"
554
+ }
555
+ ),
556
+ /* @__PURE__ */ jsx(
557
+ "path",
558
+ {
559
+ d: "M8 6.5v3.5",
560
+ stroke: "currentColor",
561
+ strokeWidth: "1.5",
562
+ strokeLinecap: "round"
563
+ }
564
+ ),
531
565
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "11.75", r: "0.75", fill: "currentColor" })
532
566
  ] }),
533
567
  danger: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: [
534
568
  /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "1.5" }),
535
- /* @__PURE__ */ jsx("path", { d: "M5.5 5.5l5 5M10.5 5.5l-5 5", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
569
+ /* @__PURE__ */ jsx(
570
+ "path",
571
+ {
572
+ d: "M5.5 5.5l5 5M10.5 5.5l-5 5",
573
+ stroke: "currentColor",
574
+ strokeWidth: "1.5",
575
+ strokeLinecap: "round"
576
+ }
577
+ )
536
578
  ] })
537
579
  };
538
580
  var Alert = forwardRef(
@@ -557,27 +599,25 @@ var Alert = forwardRef(
557
599
  }
558
600
  );
559
601
  Alert.displayName = "Alert";
560
- var DropdownMenuContent = forwardRef(
561
- ({ className, sideOffset = 6, align = "start", children, ...props }, ref) => {
562
- return /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(
563
- Menu.Positioner,
564
- {
565
- sideOffset,
566
- align,
567
- className: "pds-menu-positioner",
568
- children: /* @__PURE__ */ jsx(
569
- Menu.Popup,
570
- {
571
- ref,
572
- className: cn("pds-menu-popup", className),
573
- ...props,
574
- children
575
- }
576
- )
577
- }
578
- ) });
579
- }
580
- );
602
+ var DropdownMenuContent = forwardRef(({ className, sideOffset = 6, align = "start", children, ...props }, ref) => {
603
+ return /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(
604
+ Menu.Positioner,
605
+ {
606
+ sideOffset,
607
+ align,
608
+ className: "pds-menu-positioner",
609
+ children: /* @__PURE__ */ jsx(
610
+ Menu.Popup,
611
+ {
612
+ ref,
613
+ className: cn("pds-menu-popup", className),
614
+ ...props,
615
+ children
616
+ }
617
+ )
618
+ }
619
+ ) });
620
+ });
581
621
  DropdownMenuContent.displayName = "DropdownMenu.Content";
582
622
  var DropdownMenuItem = forwardRef(
583
623
  ({ className, ...props }, ref) => {
@@ -592,48 +632,44 @@ var DropdownMenuItem = forwardRef(
592
632
  }
593
633
  );
594
634
  DropdownMenuItem.displayName = "DropdownMenu.Item";
595
- var DropdownMenuCheckboxItem = forwardRef(
596
- ({ className, children, ...props }, ref) => {
597
- return /* @__PURE__ */ jsxs(
598
- Menu.CheckboxItem,
599
- {
600
- ref,
601
- className: cn("pds-menu-item", "pds-menu-item--indented", className),
602
- ...props,
603
- children: [
604
- /* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, { className: "pds-menu-item__indicator", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
605
- "path",
606
- {
607
- d: "M3.5 8.5l3 3 6-6.5",
608
- stroke: "currentColor",
609
- strokeWidth: "2",
610
- strokeLinecap: "round",
611
- strokeLinejoin: "round"
612
- }
613
- ) }) }),
614
- children
615
- ]
616
- }
617
- );
618
- }
619
- );
635
+ var DropdownMenuCheckboxItem = forwardRef(({ className, children, ...props }, ref) => {
636
+ return /* @__PURE__ */ jsxs(
637
+ Menu.CheckboxItem,
638
+ {
639
+ ref,
640
+ className: cn("pds-menu-item", "pds-menu-item--indented", className),
641
+ ...props,
642
+ children: [
643
+ /* @__PURE__ */ jsx(Menu.CheckboxItemIndicator, { className: "pds-menu-item__indicator", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ jsx(
644
+ "path",
645
+ {
646
+ d: "M3.5 8.5l3 3 6-6.5",
647
+ stroke: "currentColor",
648
+ strokeWidth: "2",
649
+ strokeLinecap: "round",
650
+ strokeLinejoin: "round"
651
+ }
652
+ ) }) }),
653
+ children
654
+ ]
655
+ }
656
+ );
657
+ });
620
658
  DropdownMenuCheckboxItem.displayName = "DropdownMenu.CheckboxItem";
621
- var DropdownMenuRadioItem = forwardRef(
622
- ({ className, children, ...props }, ref) => {
623
- return /* @__PURE__ */ jsxs(
624
- Menu.RadioItem,
625
- {
626
- ref,
627
- className: cn("pds-menu-item", "pds-menu-item--indented", className),
628
- ...props,
629
- children: [
630
- /* @__PURE__ */ jsx(Menu.RadioItemIndicator, { className: "pds-menu-item__indicator pds-menu-item__indicator--radio", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "8" }) }) }),
631
- children
632
- ]
633
- }
634
- );
635
- }
636
- );
659
+ var DropdownMenuRadioItem = forwardRef(({ className, children, ...props }, ref) => {
660
+ return /* @__PURE__ */ jsxs(
661
+ Menu.RadioItem,
662
+ {
663
+ ref,
664
+ className: cn("pds-menu-item", "pds-menu-item--indented", className),
665
+ ...props,
666
+ children: [
667
+ /* @__PURE__ */ jsx(Menu.RadioItemIndicator, { className: "pds-menu-item__indicator pds-menu-item__indicator--radio", children: /* @__PURE__ */ jsx("svg", { viewBox: "0 0 16 16", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "8" }) }) }),
668
+ children
669
+ ]
670
+ }
671
+ );
672
+ });
637
673
  DropdownMenuRadioItem.displayName = "DropdownMenu.RadioItem";
638
674
  var DropdownMenuLabel = forwardRef(
639
675
  ({ className, ...props }, ref) => {
@@ -648,18 +684,16 @@ var DropdownMenuLabel = forwardRef(
648
684
  }
649
685
  );
650
686
  DropdownMenuLabel.displayName = "DropdownMenu.Label";
651
- var DropdownMenuSeparator = forwardRef(
652
- ({ className, ...props }, ref) => {
653
- return /* @__PURE__ */ jsx(
654
- Menu.Separator,
655
- {
656
- ref,
657
- className: cn("pds-menu-separator", className),
658
- ...props
659
- }
660
- );
661
- }
662
- );
687
+ var DropdownMenuSeparator = forwardRef(({ className, ...props }, ref) => {
688
+ return /* @__PURE__ */ jsx(
689
+ Menu.Separator,
690
+ {
691
+ ref,
692
+ className: cn("pds-menu-separator", className),
693
+ ...props
694
+ }
695
+ );
696
+ });
663
697
  DropdownMenuSeparator.displayName = "DropdownMenu.Separator";
664
698
  var DropdownMenu = {
665
699
  Root: Menu.Root,
@@ -701,25 +735,11 @@ var CardRoot = forwardRef(
701
735
  );
702
736
  CardRoot.displayName = "Card";
703
737
  var CardHeader = forwardRef(
704
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
705
- "div",
706
- {
707
- ref,
708
- className: cn("pds-card__header", className),
709
- ...props
710
- }
711
- )
738
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("pds-card__header", className), ...props })
712
739
  );
713
740
  CardHeader.displayName = "Card.Header";
714
741
  var CardTitle = forwardRef(
715
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
716
- "h3",
717
- {
718
- ref,
719
- className: cn("pds-card__title", className),
720
- ...props
721
- }
722
- )
742
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: cn("pds-card__title", className), ...props })
723
743
  );
724
744
  CardTitle.displayName = "Card.Title";
725
745
  var CardDescription = forwardRef(
@@ -734,36 +754,15 @@ var CardDescription = forwardRef(
734
754
  );
735
755
  CardDescription.displayName = "Card.Description";
736
756
  var CardAction = forwardRef(
737
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
738
- "div",
739
- {
740
- ref,
741
- className: cn("pds-card__action", className),
742
- ...props
743
- }
744
- )
757
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("pds-card__action", className), ...props })
745
758
  );
746
759
  CardAction.displayName = "Card.Action";
747
760
  var CardBody = forwardRef(
748
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
749
- "div",
750
- {
751
- ref,
752
- className: cn("pds-card__body", className),
753
- ...props
754
- }
755
- )
761
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("pds-card__body", className), ...props })
756
762
  );
757
763
  CardBody.displayName = "Card.Body";
758
764
  var CardFooter = forwardRef(
759
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
760
- "div",
761
- {
762
- ref,
763
- className: cn("pds-card__footer", className),
764
- ...props
765
- }
766
- )
765
+ ({ className, ...props }, ref) => /* @__PURE__ */ jsx("div", { ref, className: cn("pds-card__footer", className), ...props })
767
766
  );
768
767
  CardFooter.displayName = "Card.Footer";
769
768
  var Card = Object.assign(CardRoot, {
@@ -942,7 +941,1071 @@ GridCol.displayName = "Grid.Col";
942
941
  var Grid = Object.assign(GridRoot, {
943
942
  Col: GridCol
944
943
  });
944
+ var PopoverContent = forwardRef(
945
+ ({
946
+ className,
947
+ side = "bottom",
948
+ align = "center",
949
+ sideOffset = 10,
950
+ showArrow = true,
951
+ children,
952
+ ...props
953
+ }, ref) => {
954
+ return /* @__PURE__ */ jsx(Popover$1.Portal, { children: /* @__PURE__ */ jsx(
955
+ Popover$1.Positioner,
956
+ {
957
+ side,
958
+ align,
959
+ sideOffset,
960
+ className: "pds-popover-positioner",
961
+ children: /* @__PURE__ */ jsxs(
962
+ Popover$1.Popup,
963
+ {
964
+ ref,
965
+ className: cn("pds-popover-popup", className),
966
+ ...props,
967
+ children: [
968
+ showArrow && /* @__PURE__ */ jsx(Popover$1.Arrow, { className: "pds-popover-arrow" }),
969
+ children
970
+ ]
971
+ }
972
+ )
973
+ }
974
+ ) });
975
+ }
976
+ );
977
+ PopoverContent.displayName = "Popover.Content";
978
+ var PopoverTitle = forwardRef(
979
+ ({ className, ...props }, ref) => {
980
+ return /* @__PURE__ */ jsx(
981
+ Popover$1.Title,
982
+ {
983
+ ref,
984
+ className: cn("pds-popover-title", className),
985
+ ...props
986
+ }
987
+ );
988
+ }
989
+ );
990
+ PopoverTitle.displayName = "Popover.Title";
991
+ var PopoverDescription = forwardRef(({ className, ...props }, ref) => {
992
+ return /* @__PURE__ */ jsx(
993
+ Popover$1.Description,
994
+ {
995
+ ref,
996
+ className: cn("pds-popover-description", className),
997
+ ...props
998
+ }
999
+ );
1000
+ });
1001
+ PopoverDescription.displayName = "Popover.Description";
1002
+ var PopoverHeader = forwardRef(
1003
+ ({ className, ...props }, ref) => {
1004
+ return /* @__PURE__ */ jsx(
1005
+ "div",
1006
+ {
1007
+ ref,
1008
+ className: cn("pds-popover__header", className),
1009
+ ...props
1010
+ }
1011
+ );
1012
+ }
1013
+ );
1014
+ PopoverHeader.displayName = "Popover.Header";
1015
+ var PopoverBody = forwardRef(
1016
+ ({ className, ...props }, ref) => {
1017
+ return /* @__PURE__ */ jsx(
1018
+ "div",
1019
+ {
1020
+ ref,
1021
+ className: cn("pds-popover__body", className),
1022
+ ...props
1023
+ }
1024
+ );
1025
+ }
1026
+ );
1027
+ PopoverBody.displayName = "Popover.Body";
1028
+ var PopoverFooter = forwardRef(
1029
+ ({ className, ...props }, ref) => {
1030
+ return /* @__PURE__ */ jsx(
1031
+ "div",
1032
+ {
1033
+ ref,
1034
+ className: cn("pds-popover__footer", className),
1035
+ ...props
1036
+ }
1037
+ );
1038
+ }
1039
+ );
1040
+ PopoverFooter.displayName = "Popover.Footer";
1041
+ var Popover = {
1042
+ Root: Popover$1.Root,
1043
+ Trigger: Popover$1.Trigger,
1044
+ Content: PopoverContent,
1045
+ Title: PopoverTitle,
1046
+ Description: PopoverDescription,
1047
+ Close: Popover$1.Close,
1048
+ Header: PopoverHeader,
1049
+ Body: PopoverBody,
1050
+ Footer: PopoverFooter
1051
+ };
1052
+ function SearchIcon() {
1053
+ return /* @__PURE__ */ jsxs(
1054
+ "svg",
1055
+ {
1056
+ width: "14",
1057
+ height: "14",
1058
+ viewBox: "0 0 14 14",
1059
+ fill: "none",
1060
+ "aria-hidden": "true",
1061
+ children: [
1062
+ /* @__PURE__ */ jsx(
1063
+ "circle",
1064
+ {
1065
+ cx: "6.2",
1066
+ cy: "6.2",
1067
+ r: "4.3",
1068
+ stroke: "currentColor",
1069
+ strokeWidth: "1.4"
1070
+ }
1071
+ ),
1072
+ /* @__PURE__ */ jsx(
1073
+ "path",
1074
+ {
1075
+ d: "M9.5 9.5L13 13",
1076
+ stroke: "currentColor",
1077
+ strokeWidth: "1.4",
1078
+ strokeLinecap: "round"
1079
+ }
1080
+ )
1081
+ ]
1082
+ }
1083
+ );
1084
+ }
1085
+ function ChevronLeftIcon() {
1086
+ return /* @__PURE__ */ jsx(
1087
+ "svg",
1088
+ {
1089
+ width: "12",
1090
+ height: "12",
1091
+ viewBox: "0 0 12 12",
1092
+ fill: "none",
1093
+ "aria-hidden": "true",
1094
+ children: /* @__PURE__ */ jsx(
1095
+ "path",
1096
+ {
1097
+ d: "M7.5 2L4 6l3.5 4",
1098
+ stroke: "currentColor",
1099
+ strokeWidth: "1.6",
1100
+ strokeLinecap: "round",
1101
+ strokeLinejoin: "round"
1102
+ }
1103
+ )
1104
+ }
1105
+ );
1106
+ }
1107
+ function ChevronRightIcon() {
1108
+ return /* @__PURE__ */ jsx(
1109
+ "svg",
1110
+ {
1111
+ width: "12",
1112
+ height: "12",
1113
+ viewBox: "0 0 12 12",
1114
+ fill: "none",
1115
+ "aria-hidden": "true",
1116
+ children: /* @__PURE__ */ jsx(
1117
+ "path",
1118
+ {
1119
+ d: "M4.5 2L8 6l-3.5 4",
1120
+ stroke: "currentColor",
1121
+ strokeWidth: "1.6",
1122
+ strokeLinecap: "round",
1123
+ strokeLinejoin: "round"
1124
+ }
1125
+ )
1126
+ }
1127
+ );
1128
+ }
1129
+ function SortIcon({ direction }) {
1130
+ return /* @__PURE__ */ jsxs("span", { className: "pds-datatable__sort-icon", "aria-hidden": "true", children: [
1131
+ /* @__PURE__ */ jsx("svg", { width: "7", height: "4", viewBox: "0 0 7 4", fill: "none", children: /* @__PURE__ */ jsx(
1132
+ "path",
1133
+ {
1134
+ d: "M0 4L3.5 0L7 4H0Z",
1135
+ fill: direction === "asc" ? "var(--color-text-brand)" : "currentColor"
1136
+ }
1137
+ ) }),
1138
+ /* @__PURE__ */ jsx(
1139
+ "svg",
1140
+ {
1141
+ width: "7",
1142
+ height: "4",
1143
+ viewBox: "0 0 7 4",
1144
+ fill: "none",
1145
+ style: { opacity: direction === "desc" ? 1 : 0.3 },
1146
+ children: /* @__PURE__ */ jsx(
1147
+ "path",
1148
+ {
1149
+ d: "M0 0L3.5 4L7 0H0Z",
1150
+ fill: direction === "desc" ? "var(--color-text-brand)" : "currentColor"
1151
+ }
1152
+ )
1153
+ }
1154
+ )
1155
+ ] });
1156
+ }
1157
+ function renderCell(value) {
1158
+ if (value === null || value === void 0) return "\u2014";
1159
+ if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
1160
+ return value;
1161
+ }
1162
+ return String(value);
1163
+ }
1164
+ function DataTable({
1165
+ columns,
1166
+ data,
1167
+ selectable = true,
1168
+ searchable = true,
1169
+ pageSize = 10,
1170
+ actions,
1171
+ className
1172
+ }) {
1173
+ const [query, setQuery] = useState("");
1174
+ const [selected, setSelected] = useState(/* @__PURE__ */ new Set());
1175
+ const [sort, setSort] = useState(
1176
+ { key: null, dir: "asc" }
1177
+ );
1178
+ const [page, setPage] = useState(1);
1179
+ const filtered = useMemo(() => {
1180
+ let rows = data;
1181
+ if (query.trim()) {
1182
+ const q = query.toLowerCase();
1183
+ rows = rows.filter(
1184
+ (row) => columns.some((col) => {
1185
+ const v = row[col.key];
1186
+ return v != null && String(v).toLowerCase().includes(q);
1187
+ })
1188
+ );
1189
+ }
1190
+ if (sort.key) {
1191
+ const key = sort.key;
1192
+ rows = [...rows].sort((a, b) => {
1193
+ const av = a[key] ?? "";
1194
+ const bv = b[key] ?? "";
1195
+ const cmp = String(av).localeCompare(String(bv), void 0, {
1196
+ numeric: true
1197
+ });
1198
+ return sort.dir === "asc" ? cmp : -cmp;
1199
+ });
1200
+ }
1201
+ return rows;
1202
+ }, [data, query, sort, columns]);
1203
+ const totalPages = Math.max(1, Math.ceil(filtered.length / pageSize));
1204
+ const pageData = filtered.slice((page - 1) * pageSize, page * pageSize);
1205
+ const allSelected = pageData.length > 0 && pageData.every((r) => selected.has(r.id));
1206
+ const someSelected = pageData.some((r) => selected.has(r.id));
1207
+ const toggleAll = () => {
1208
+ const next = new Set(selected);
1209
+ if (allSelected) {
1210
+ pageData.forEach((r) => next.delete(r.id));
1211
+ } else {
1212
+ pageData.forEach((r) => next.add(r.id));
1213
+ }
1214
+ setSelected(next);
1215
+ };
1216
+ const toggleRow = (id) => {
1217
+ const next = new Set(selected);
1218
+ if (next.has(id)) next.delete(id);
1219
+ else next.add(id);
1220
+ setSelected(next);
1221
+ };
1222
+ const toggleSort = (key) => {
1223
+ setSort(
1224
+ (s) => s.key === key ? { key, dir: s.dir === "asc" ? "desc" : "asc" } : { key, dir: "asc" }
1225
+ );
1226
+ setPage(1);
1227
+ };
1228
+ const onSearch = (e) => {
1229
+ setQuery(e.target.value);
1230
+ setPage(1);
1231
+ };
1232
+ const startItem = filtered.length === 0 ? 0 : (page - 1) * pageSize + 1;
1233
+ const endItem = Math.min(page * pageSize, filtered.length);
1234
+ const pageNums = (() => {
1235
+ if (totalPages <= 5) {
1236
+ return Array.from({ length: totalPages }, (_, i) => i + 1);
1237
+ }
1238
+ if (page <= 3) return [1, 2, 3, 4, 5];
1239
+ if (page >= totalPages - 2) {
1240
+ return [
1241
+ totalPages - 4,
1242
+ totalPages - 3,
1243
+ totalPages - 2,
1244
+ totalPages - 1,
1245
+ totalPages
1246
+ ];
1247
+ }
1248
+ return [page - 2, page - 1, page, page + 1, page + 2];
1249
+ })();
1250
+ return /* @__PURE__ */ jsxs("div", { className: cn("pds-datatable", className), children: [
1251
+ (searchable || actions) && /* @__PURE__ */ jsxs("div", { className: "pds-datatable__toolbar", children: [
1252
+ searchable && /* @__PURE__ */ jsxs("div", { className: "pds-datatable__search", children: [
1253
+ /* @__PURE__ */ jsx("span", { className: "pds-datatable__search-icon", children: /* @__PURE__ */ jsx(SearchIcon, {}) }),
1254
+ /* @__PURE__ */ jsx(
1255
+ "input",
1256
+ {
1257
+ className: "pds-datatable__search-input",
1258
+ type: "search",
1259
+ placeholder: "Search\u2026",
1260
+ value: query,
1261
+ onChange: onSearch,
1262
+ "aria-label": "Search table"
1263
+ }
1264
+ )
1265
+ ] }),
1266
+ selected.size > 0 && /* @__PURE__ */ jsxs("span", { className: "pds-datatable__bulk-label", children: [
1267
+ selected.size,
1268
+ " selected"
1269
+ ] }),
1270
+ actions && /* @__PURE__ */ jsx("div", { className: "pds-datatable__toolbar-right", children: actions })
1271
+ ] }),
1272
+ /* @__PURE__ */ jsx("div", { className: "pds-datatable__wrap", children: /* @__PURE__ */ jsxs(
1273
+ "table",
1274
+ {
1275
+ className: cn(
1276
+ "pds-datatable__table",
1277
+ selectable && "pds-datatable__table--selectable"
1278
+ ),
1279
+ "aria-label": "Data table",
1280
+ children: [
1281
+ /* @__PURE__ */ jsx("thead", { className: "pds-datatable__thead", children: /* @__PURE__ */ jsxs("tr", { className: "pds-datatable__row", children: [
1282
+ selectable && /* @__PURE__ */ jsx(
1283
+ "th",
1284
+ {
1285
+ className: "pds-datatable__th pds-datatable__check-col",
1286
+ "aria-label": "Select all",
1287
+ children: /* @__PURE__ */ jsx(
1288
+ Checkbox,
1289
+ {
1290
+ size: "sm",
1291
+ checked: allSelected,
1292
+ indeterminate: someSelected && !allSelected,
1293
+ onCheckedChange: toggleAll
1294
+ }
1295
+ )
1296
+ }
1297
+ ),
1298
+ columns.map((col) => {
1299
+ const sortable = col.sortable !== false;
1300
+ const isSorted = sort.key === col.key;
1301
+ return /* @__PURE__ */ jsxs(
1302
+ "th",
1303
+ {
1304
+ className: cn(
1305
+ "pds-datatable__th",
1306
+ sortable && "pds-datatable__th--sort",
1307
+ isSorted && "pds-datatable__th--sorted"
1308
+ ),
1309
+ onClick: sortable ? () => toggleSort(col.key) : void 0,
1310
+ style: col.width ? { width: col.width } : void 0,
1311
+ "aria-sort": isSorted ? sort.dir === "asc" ? "ascending" : "descending" : void 0,
1312
+ children: [
1313
+ col.label,
1314
+ sortable && /* @__PURE__ */ jsx(SortIcon, { direction: isSorted ? sort.dir : null })
1315
+ ]
1316
+ },
1317
+ col.key
1318
+ );
1319
+ })
1320
+ ] }) }),
1321
+ /* @__PURE__ */ jsx("tbody", { className: "pds-datatable__tbody", children: pageData.length === 0 ? /* @__PURE__ */ jsx("tr", { className: "pds-datatable__row", children: /* @__PURE__ */ jsx(
1322
+ "td",
1323
+ {
1324
+ className: "pds-datatable__td pds-datatable__empty",
1325
+ colSpan: columns.length + (selectable ? 1 : 0),
1326
+ children: "No results found"
1327
+ }
1328
+ ) }) : pageData.map((row) => {
1329
+ const isSel = selected.has(row.id);
1330
+ return /* @__PURE__ */ jsxs(
1331
+ "tr",
1332
+ {
1333
+ className: cn(
1334
+ "pds-datatable__row",
1335
+ isSel && "pds-datatable__row--selected"
1336
+ ),
1337
+ "aria-selected": isSel,
1338
+ onClick: selectable ? () => toggleRow(row.id) : void 0,
1339
+ children: [
1340
+ selectable && /* @__PURE__ */ jsx(
1341
+ "td",
1342
+ {
1343
+ className: "pds-datatable__td pds-datatable__check-col",
1344
+ onClick: (e) => e.stopPropagation(),
1345
+ children: /* @__PURE__ */ jsx(
1346
+ Checkbox,
1347
+ {
1348
+ size: "sm",
1349
+ checked: isSel,
1350
+ onCheckedChange: () => toggleRow(row.id)
1351
+ }
1352
+ )
1353
+ }
1354
+ ),
1355
+ columns.map((col) => /* @__PURE__ */ jsx(
1356
+ "td",
1357
+ {
1358
+ className: cn(
1359
+ "pds-datatable__td",
1360
+ col.muted && "pds-datatable__td--muted",
1361
+ col.mono && "pds-datatable__td--mono"
1362
+ ),
1363
+ children: col.render ? col.render(
1364
+ row[col.key],
1365
+ row
1366
+ ) : renderCell(
1367
+ row[col.key]
1368
+ )
1369
+ },
1370
+ col.key
1371
+ ))
1372
+ ]
1373
+ },
1374
+ row.id
1375
+ );
1376
+ }) })
1377
+ ]
1378
+ }
1379
+ ) }),
1380
+ /* @__PURE__ */ jsxs("div", { className: "pds-datatable__footer", children: [
1381
+ /* @__PURE__ */ jsx("span", { className: "pds-datatable__page-info", children: filtered.length === 0 ? "No results" : `${startItem}\u2013${endItem} of ${filtered.length}` }),
1382
+ /* @__PURE__ */ jsxs(
1383
+ "div",
1384
+ {
1385
+ className: "pds-datatable__pagination",
1386
+ role: "navigation",
1387
+ "aria-label": "Pagination",
1388
+ children: [
1389
+ /* @__PURE__ */ jsx(
1390
+ "button",
1391
+ {
1392
+ type: "button",
1393
+ className: "pds-datatable__page-btn",
1394
+ onClick: () => setPage((p) => Math.max(1, p - 1)),
1395
+ disabled: page <= 1,
1396
+ "aria-label": "Previous page",
1397
+ children: /* @__PURE__ */ jsx(ChevronLeftIcon, {})
1398
+ }
1399
+ ),
1400
+ pageNums.map((p) => /* @__PURE__ */ jsx(
1401
+ "button",
1402
+ {
1403
+ type: "button",
1404
+ className: cn(
1405
+ "pds-datatable__page-btn",
1406
+ p === page && "pds-datatable__page-btn--active"
1407
+ ),
1408
+ onClick: () => setPage(p),
1409
+ "aria-current": p === page ? "page" : void 0,
1410
+ children: p
1411
+ },
1412
+ p
1413
+ )),
1414
+ /* @__PURE__ */ jsx(
1415
+ "button",
1416
+ {
1417
+ type: "button",
1418
+ className: "pds-datatable__page-btn",
1419
+ onClick: () => setPage((p) => Math.min(totalPages, p + 1)),
1420
+ disabled: page >= totalPages,
1421
+ "aria-label": "Next page",
1422
+ children: /* @__PURE__ */ jsx(ChevronRightIcon, {})
1423
+ }
1424
+ )
1425
+ ]
1426
+ }
1427
+ )
1428
+ ] })
1429
+ ] });
1430
+ }
1431
+ function SearchIcon2({ size = 16 }) {
1432
+ return /* @__PURE__ */ jsxs(
1433
+ "svg",
1434
+ {
1435
+ width: size,
1436
+ height: size,
1437
+ viewBox: "0 0 16 16",
1438
+ fill: "none",
1439
+ "aria-hidden": "true",
1440
+ children: [
1441
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "4.5", stroke: "currentColor", strokeWidth: "1.5" }),
1442
+ /* @__PURE__ */ jsx(
1443
+ "path",
1444
+ {
1445
+ d: "M10.5 10.5L14 14",
1446
+ stroke: "currentColor",
1447
+ strokeWidth: "1.5",
1448
+ strokeLinecap: "round"
1449
+ }
1450
+ )
1451
+ ]
1452
+ }
1453
+ );
1454
+ }
1455
+ function XSmallIcon({ size = 10 }) {
1456
+ return /* @__PURE__ */ jsx(
1457
+ "svg",
1458
+ {
1459
+ width: size,
1460
+ height: size,
1461
+ viewBox: "0 0 10 10",
1462
+ fill: "none",
1463
+ "aria-hidden": "true",
1464
+ children: /* @__PURE__ */ jsx(
1465
+ "path",
1466
+ {
1467
+ d: "M2 2l6 6M8 2L2 8",
1468
+ stroke: "currentColor",
1469
+ strokeWidth: "1.6",
1470
+ strokeLinecap: "round"
1471
+ }
1472
+ )
1473
+ }
1474
+ );
1475
+ }
1476
+ function useCommandPalette() {
1477
+ const [open, setOpen] = useState(false);
1478
+ useEffect(() => {
1479
+ const handler = (e) => {
1480
+ if ((e.metaKey || e.ctrlKey) && e.key === "k") {
1481
+ e.preventDefault();
1482
+ setOpen((o) => !o);
1483
+ }
1484
+ };
1485
+ window.addEventListener("keydown", handler);
1486
+ return () => window.removeEventListener("keydown", handler);
1487
+ }, []);
1488
+ return { open, setOpen };
1489
+ }
1490
+ function CommandPalette({
1491
+ open,
1492
+ onOpenChange,
1493
+ groups = [],
1494
+ placeholder = "Type to search",
1495
+ onSelect,
1496
+ className
1497
+ }) {
1498
+ const [query, setQuery] = useState("");
1499
+ const [activeIndex, setActiveIndex] = useState(0);
1500
+ const [prevOpen, setPrevOpen] = useState(open);
1501
+ const [prevQuery, setPrevQuery] = useState(query);
1502
+ const inputRef = useRef(null);
1503
+ if (open !== prevOpen) {
1504
+ setPrevOpen(open);
1505
+ if (open) {
1506
+ setQuery("");
1507
+ setActiveIndex(0);
1508
+ setPrevQuery("");
1509
+ }
1510
+ }
1511
+ if (query !== prevQuery) {
1512
+ setPrevQuery(query);
1513
+ setActiveIndex(0);
1514
+ }
1515
+ const filteredGroups = useMemo(() => {
1516
+ if (!query.trim()) return groups;
1517
+ const q = query.toLowerCase();
1518
+ return groups.map((group) => ({
1519
+ ...group,
1520
+ items: group.items.filter(
1521
+ (item) => item.label.toLowerCase().includes(q) || item.description && item.description.toLowerCase().includes(q) || item.keywords && item.keywords.some((k) => k.toLowerCase().includes(q))
1522
+ )
1523
+ })).filter((group) => group.items.length > 0);
1524
+ }, [groups, query]);
1525
+ const allItems = useMemo(
1526
+ () => filteredGroups.flatMap((group) => group.items),
1527
+ [filteredGroups]
1528
+ );
1529
+ const selectItem = (item) => {
1530
+ item.onSelect?.();
1531
+ onSelect?.(item);
1532
+ onOpenChange(false);
1533
+ };
1534
+ const onKeyDown = (e) => {
1535
+ if (e.key === "ArrowDown") {
1536
+ e.preventDefault();
1537
+ setActiveIndex((i) => Math.min(allItems.length - 1, i + 1));
1538
+ } else if (e.key === "ArrowUp") {
1539
+ e.preventDefault();
1540
+ setActiveIndex((i) => Math.max(0, i - 1));
1541
+ } else if (e.key === "Enter") {
1542
+ e.preventDefault();
1543
+ const item = allItems[activeIndex];
1544
+ if (item) selectItem(item);
1545
+ }
1546
+ };
1547
+ let flatIndex = 0;
1548
+ return /* @__PURE__ */ jsx(Dialog.Root, { open, onOpenChange, children: /* @__PURE__ */ jsxs(Dialog.Portal, { children: [
1549
+ /* @__PURE__ */ jsx(Dialog.Backdrop, { className: "pds-command-palette-backdrop" }),
1550
+ /* @__PURE__ */ jsxs(
1551
+ Dialog.Popup,
1552
+ {
1553
+ className: cn("pds-command-palette", className),
1554
+ "aria-label": "Command palette",
1555
+ initialFocus: inputRef,
1556
+ children: [
1557
+ /* @__PURE__ */ jsxs("div", { className: "pds-command-palette__search", children: [
1558
+ /* @__PURE__ */ jsx("span", { className: "pds-command-palette__search-icon", children: /* @__PURE__ */ jsx(SearchIcon2, { size: 16 }) }),
1559
+ /* @__PURE__ */ jsx(
1560
+ "input",
1561
+ {
1562
+ ref: inputRef,
1563
+ className: "pds-command-palette__input",
1564
+ type: "text",
1565
+ placeholder,
1566
+ value: query,
1567
+ onChange: (e) => setQuery(e.target.value),
1568
+ onKeyDown,
1569
+ role: "combobox",
1570
+ "aria-autocomplete": "list",
1571
+ "aria-expanded": "true"
1572
+ }
1573
+ ),
1574
+ query && /* @__PURE__ */ jsx(
1575
+ "button",
1576
+ {
1577
+ type: "button",
1578
+ className: "pds-command-palette__clear",
1579
+ onClick: () => setQuery(""),
1580
+ "aria-label": "Clear",
1581
+ children: /* @__PURE__ */ jsx(XSmallIcon, {})
1582
+ }
1583
+ )
1584
+ ] }),
1585
+ /* @__PURE__ */ jsx("div", { className: "pds-command-palette__list", role: "listbox", children: allItems.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "pds-command-palette__empty", children: [
1586
+ /* @__PURE__ */ jsx(SearchIcon2, { size: 20 }),
1587
+ 'No results for "',
1588
+ query,
1589
+ '"'
1590
+ ] }) : filteredGroups.map((group, gi) => /* @__PURE__ */ jsxs(
1591
+ "div",
1592
+ {
1593
+ className: "pds-command-palette__group",
1594
+ role: "group",
1595
+ "aria-label": group.label,
1596
+ children: [
1597
+ group.label && /* @__PURE__ */ jsx("div", { className: "pds-command-palette__group-label", children: group.label }),
1598
+ group.items.map((item) => {
1599
+ const thisIndex = flatIndex++;
1600
+ const isActive = thisIndex === activeIndex;
1601
+ return /* @__PURE__ */ jsxs(
1602
+ "button",
1603
+ {
1604
+ type: "button",
1605
+ role: "option",
1606
+ "aria-selected": isActive,
1607
+ className: cn(
1608
+ "pds-command-palette__item",
1609
+ isActive && "pds-command-palette__item--active"
1610
+ ),
1611
+ onMouseEnter: () => setActiveIndex(thisIndex),
1612
+ onClick: () => selectItem(item),
1613
+ children: [
1614
+ item.icon && /* @__PURE__ */ jsx(
1615
+ "span",
1616
+ {
1617
+ className: "pds-command-palette__item-icon",
1618
+ "aria-hidden": "true",
1619
+ children: item.icon
1620
+ }
1621
+ ),
1622
+ /* @__PURE__ */ jsxs("span", { className: "pds-command-palette__item-body", children: [
1623
+ /* @__PURE__ */ jsx("span", { className: "pds-command-palette__item-label", children: item.label }),
1624
+ item.description && /* @__PURE__ */ jsx("span", { className: "pds-command-palette__item-desc", children: item.description })
1625
+ ] }),
1626
+ item.shortcut && /* @__PURE__ */ jsx(
1627
+ "span",
1628
+ {
1629
+ className: "pds-command-palette__shortcut",
1630
+ "aria-label": `Shortcut: ${item.shortcut}`,
1631
+ children: item.shortcut.split("+").map((key, ki) => /* @__PURE__ */ jsx(
1632
+ "kbd",
1633
+ {
1634
+ className: "pds-command-palette__kbd",
1635
+ children: key
1636
+ },
1637
+ ki
1638
+ ))
1639
+ }
1640
+ )
1641
+ ]
1642
+ },
1643
+ item.id
1644
+ );
1645
+ })
1646
+ ]
1647
+ },
1648
+ group.label ?? gi
1649
+ )) }),
1650
+ /* @__PURE__ */ jsxs("div", { className: "pds-command-palette__footer", "aria-hidden": "true", children: [
1651
+ /* @__PURE__ */ jsxs("span", { className: "pds-command-palette__hint", children: [
1652
+ /* @__PURE__ */ jsx("kbd", { className: "pds-command-palette__kbd", children: "\u2191" }),
1653
+ /* @__PURE__ */ jsx("kbd", { className: "pds-command-palette__kbd", children: "\u2193" }),
1654
+ " navigate"
1655
+ ] }),
1656
+ /* @__PURE__ */ jsxs("span", { className: "pds-command-palette__hint", children: [
1657
+ /* @__PURE__ */ jsx("kbd", { className: "pds-command-palette__kbd", children: "\u21B5" }),
1658
+ " select"
1659
+ ] }),
1660
+ /* @__PURE__ */ jsxs("span", { className: "pds-command-palette__hint", children: [
1661
+ /* @__PURE__ */ jsx("kbd", { className: "pds-command-palette__kbd", children: "Esc" }),
1662
+ " close"
1663
+ ] })
1664
+ ] })
1665
+ ]
1666
+ }
1667
+ )
1668
+ ] }) });
1669
+ }
1670
+ function ChatSendIcon() {
1671
+ return /* @__PURE__ */ jsx(
1672
+ "svg",
1673
+ {
1674
+ width: 16,
1675
+ height: 16,
1676
+ viewBox: "0 0 16 16",
1677
+ fill: "none",
1678
+ "aria-hidden": "true",
1679
+ children: /* @__PURE__ */ jsx(
1680
+ "path",
1681
+ {
1682
+ d: "M2.5 8h11M9 3.5L13.5 8 9 12.5",
1683
+ stroke: "currentColor",
1684
+ strokeWidth: "1.7",
1685
+ strokeLinecap: "round",
1686
+ strokeLinejoin: "round"
1687
+ }
1688
+ )
1689
+ }
1690
+ );
1691
+ }
1692
+ function ChatPaperclipIcon() {
1693
+ return /* @__PURE__ */ jsx(
1694
+ "svg",
1695
+ {
1696
+ width: 16,
1697
+ height: 16,
1698
+ viewBox: "0 0 16 16",
1699
+ fill: "none",
1700
+ "aria-hidden": "true",
1701
+ children: /* @__PURE__ */ jsx(
1702
+ "path",
1703
+ {
1704
+ d: "M13.2 7.2L7.5 12.9a3.5 3.5 0 0 1-4.95-4.95l6.36-6.36a2.2 2.2 0 0 1 3.11 3.11L5.66 10.9a.88.88 0 0 1-1.24-1.24l5.3-5.3",
1705
+ stroke: "currentColor",
1706
+ strokeWidth: "1.4",
1707
+ strokeLinecap: "round",
1708
+ strokeLinejoin: "round"
1709
+ }
1710
+ )
1711
+ }
1712
+ );
1713
+ }
1714
+ function ChatSmileIcon() {
1715
+ return /* @__PURE__ */ jsxs(
1716
+ "svg",
1717
+ {
1718
+ width: 16,
1719
+ height: 16,
1720
+ viewBox: "0 0 16 16",
1721
+ fill: "none",
1722
+ "aria-hidden": "true",
1723
+ children: [
1724
+ /* @__PURE__ */ jsx("circle", { cx: "8", cy: "8", r: "6.2", stroke: "currentColor", strokeWidth: "1.4" }),
1725
+ /* @__PURE__ */ jsx(
1726
+ "path",
1727
+ {
1728
+ d: "M5.5 9.8c.4.9 2.6 1.4 3 0",
1729
+ stroke: "currentColor",
1730
+ strokeWidth: "1.4",
1731
+ strokeLinecap: "round"
1732
+ }
1733
+ ),
1734
+ /* @__PURE__ */ jsx("circle", { cx: "6", cy: "6.8", r: "0.8", fill: "currentColor" }),
1735
+ /* @__PURE__ */ jsx("circle", { cx: "10", cy: "6.8", r: "0.8", fill: "currentColor" })
1736
+ ]
1737
+ }
1738
+ );
1739
+ }
1740
+ function ChatDeliveryIcon({ status }) {
1741
+ if (status === "sending") {
1742
+ return /* @__PURE__ */ jsx(
1743
+ "svg",
1744
+ {
1745
+ width: 14,
1746
+ height: 14,
1747
+ viewBox: "0 0 14 14",
1748
+ fill: "none",
1749
+ "aria-hidden": "true",
1750
+ children: /* @__PURE__ */ jsx(
1751
+ "circle",
1752
+ {
1753
+ cx: "7",
1754
+ cy: "7",
1755
+ r: "5.2",
1756
+ stroke: "currentColor",
1757
+ strokeWidth: "1.4",
1758
+ strokeDasharray: "2.5 2"
1759
+ }
1760
+ )
1761
+ }
1762
+ );
1763
+ }
1764
+ if (status === "sent") {
1765
+ return /* @__PURE__ */ jsx(
1766
+ "svg",
1767
+ {
1768
+ width: 14,
1769
+ height: 14,
1770
+ viewBox: "0 0 14 14",
1771
+ fill: "none",
1772
+ "aria-hidden": "true",
1773
+ children: /* @__PURE__ */ jsx(
1774
+ "path",
1775
+ {
1776
+ d: "M3 7.2l2.4 2.4L11 4.6",
1777
+ stroke: "currentColor",
1778
+ strokeWidth: "1.6",
1779
+ strokeLinecap: "round",
1780
+ strokeLinejoin: "round"
1781
+ }
1782
+ )
1783
+ }
1784
+ );
1785
+ }
1786
+ return /* @__PURE__ */ jsxs(
1787
+ "svg",
1788
+ {
1789
+ width: 18,
1790
+ height: 14,
1791
+ viewBox: "0 0 18 14",
1792
+ fill: "none",
1793
+ "aria-label": status === "read" ? "Read" : "Delivered",
1794
+ children: [
1795
+ /* @__PURE__ */ jsx(
1796
+ "path",
1797
+ {
1798
+ d: "M1.5 7.2l2.4 2.4L9.5 4.6",
1799
+ stroke: "currentColor",
1800
+ strokeWidth: "1.5",
1801
+ strokeLinecap: "round",
1802
+ strokeLinejoin: "round"
1803
+ }
1804
+ ),
1805
+ /* @__PURE__ */ jsx(
1806
+ "path",
1807
+ {
1808
+ d: "M5.5 7.2l2.4 2.4 5.6-5",
1809
+ stroke: "currentColor",
1810
+ strokeWidth: "1.5",
1811
+ strokeLinecap: "round",
1812
+ strokeLinejoin: "round"
1813
+ }
1814
+ )
1815
+ ]
1816
+ }
1817
+ );
1818
+ }
1819
+ var ChatThread = forwardRef(
1820
+ ({ className, ...props }, ref) => {
1821
+ return /* @__PURE__ */ jsx("div", { ref, className: cn("pds-chat-thread", className), ...props });
1822
+ }
1823
+ );
1824
+ ChatThread.displayName = "ChatThread";
1825
+ var ChatDateDivider = forwardRef(
1826
+ ({ className, children, ...props }, ref) => {
1827
+ return /* @__PURE__ */ jsx(
1828
+ "div",
1829
+ {
1830
+ ref,
1831
+ role: "separator",
1832
+ className: cn("pds-chat-divider", className),
1833
+ ...props,
1834
+ children: /* @__PURE__ */ jsx("span", { className: "pds-chat-divider__label", children })
1835
+ }
1836
+ );
1837
+ }
1838
+ );
1839
+ ChatDateDivider.displayName = "ChatDateDivider";
1840
+ var ChatMessage = forwardRef(
1841
+ ({
1842
+ side = "received",
1843
+ name,
1844
+ avatar,
1845
+ time,
1846
+ status,
1847
+ reactions,
1848
+ position = "solo",
1849
+ className,
1850
+ children,
1851
+ ...props
1852
+ }, ref) => {
1853
+ const isSent = side === "sent";
1854
+ const showMeta = position === "solo" || position === "first";
1855
+ const showAvatar = !isSent && avatar && (position === "solo" || position === "last");
1856
+ const showStatus = isSent && status && (position === "solo" || position === "last");
1857
+ return /* @__PURE__ */ jsxs(
1858
+ "div",
1859
+ {
1860
+ ref,
1861
+ className: cn(
1862
+ "pds-chat-msg",
1863
+ `pds-chat-msg--${side}`,
1864
+ `pds-chat-msg--${position}`,
1865
+ className
1866
+ ),
1867
+ ...props,
1868
+ children: [
1869
+ showMeta && /* @__PURE__ */ jsxs("div", { className: "pds-chat-msg__meta-row", children: [
1870
+ !isSent && name && /* @__PURE__ */ jsx("span", { className: "pds-chat-msg__name", children: name }),
1871
+ time && /* @__PURE__ */ jsx("span", { className: "pds-chat-msg__time", children: time })
1872
+ ] }),
1873
+ /* @__PURE__ */ jsxs("div", { className: "pds-chat-msg__row", children: [
1874
+ !isSent && /* @__PURE__ */ jsx("div", { className: "pds-chat-msg__avatar-slot", children: showAvatar && avatar }),
1875
+ /* @__PURE__ */ jsxs("div", { className: "pds-chat-msg__bubble-col", children: [
1876
+ /* @__PURE__ */ jsx(
1877
+ "div",
1878
+ {
1879
+ className: cn(
1880
+ "pds-chat-bubble",
1881
+ `pds-chat-bubble--${side}`,
1882
+ `pds-chat-bubble--${position}`
1883
+ ),
1884
+ children
1885
+ }
1886
+ ),
1887
+ reactions && reactions.length > 0 && /* @__PURE__ */ jsx("div", { className: "pds-chat-reactions", children: reactions.map((reaction, index) => /* @__PURE__ */ jsxs(
1888
+ "button",
1889
+ {
1890
+ type: "button",
1891
+ className: cn(
1892
+ "pds-chat-reaction",
1893
+ reaction.mine && "pds-chat-reaction--mine"
1894
+ ),
1895
+ children: [
1896
+ /* @__PURE__ */ jsx("span", { children: reaction.emoji }),
1897
+ reaction.count !== void 0 && reaction.count > 1 && /* @__PURE__ */ jsx("span", { className: "pds-chat-reaction__count", children: reaction.count })
1898
+ ]
1899
+ },
1900
+ index
1901
+ )) })
1902
+ ] })
1903
+ ] }),
1904
+ showStatus && /* @__PURE__ */ jsxs(
1905
+ "div",
1906
+ {
1907
+ className: cn(
1908
+ "pds-chat-msg__status",
1909
+ status === "read" && "pds-chat-msg__status--read"
1910
+ ),
1911
+ children: [
1912
+ /* @__PURE__ */ jsx(ChatDeliveryIcon, { status }),
1913
+ /* @__PURE__ */ jsx("span", { className: "pds-chat-msg__status-label", children: status })
1914
+ ]
1915
+ }
1916
+ )
1917
+ ]
1918
+ }
1919
+ );
1920
+ }
1921
+ );
1922
+ ChatMessage.displayName = "ChatMessage";
1923
+ function ChatCompose({
1924
+ value,
1925
+ onChange,
1926
+ onSend,
1927
+ placeholder = "Write a message\u2026",
1928
+ avatar,
1929
+ disabled,
1930
+ className
1931
+ }) {
1932
+ const [internalValue, setInternalValue] = useState("");
1933
+ const textareaRef = useRef(null);
1934
+ const isControlled = value !== void 0;
1935
+ const text = isControlled ? value : internalValue;
1936
+ useEffect(() => {
1937
+ const textarea = textareaRef.current;
1938
+ if (!textarea) return;
1939
+ textarea.style.height = "auto";
1940
+ textarea.style.height = `${Math.min(textarea.scrollHeight, 120)}px`;
1941
+ }, [text]);
1942
+ function handleChange(event) {
1943
+ if (!isControlled) setInternalValue(event.target.value);
1944
+ onChange?.(event);
1945
+ }
1946
+ function send() {
1947
+ const trimmed = text.trim();
1948
+ if (!trimmed) return;
1949
+ onSend?.(trimmed);
1950
+ if (!isControlled) setInternalValue("");
1951
+ }
1952
+ function handleKeyDown(event) {
1953
+ if (event.key === "Enter" && !event.shiftKey) {
1954
+ event.preventDefault();
1955
+ send();
1956
+ }
1957
+ }
1958
+ const canSend = text.trim().length > 0;
1959
+ return /* @__PURE__ */ jsxs("div", { className: cn("pds-chat-compose", className), children: [
1960
+ avatar && /* @__PURE__ */ jsx("div", { className: "pds-chat-compose__avatar", children: avatar }),
1961
+ /* @__PURE__ */ jsxs("div", { className: "pds-chat-compose__field", children: [
1962
+ /* @__PURE__ */ jsx(
1963
+ "button",
1964
+ {
1965
+ type: "button",
1966
+ className: "pds-chat-compose__icon-btn",
1967
+ "aria-label": "Attach file",
1968
+ children: /* @__PURE__ */ jsx(ChatPaperclipIcon, {})
1969
+ }
1970
+ ),
1971
+ /* @__PURE__ */ jsx(
1972
+ "textarea",
1973
+ {
1974
+ ref: textareaRef,
1975
+ className: "pds-chat-compose__textarea",
1976
+ value: text,
1977
+ onChange: handleChange,
1978
+ onKeyDown: handleKeyDown,
1979
+ placeholder,
1980
+ disabled,
1981
+ rows: 1,
1982
+ "aria-label": "Message"
1983
+ }
1984
+ ),
1985
+ /* @__PURE__ */ jsx(
1986
+ "button",
1987
+ {
1988
+ type: "button",
1989
+ className: "pds-chat-compose__icon-btn",
1990
+ "aria-label": "Add emoji",
1991
+ children: /* @__PURE__ */ jsx(ChatSmileIcon, {})
1992
+ }
1993
+ )
1994
+ ] }),
1995
+ /* @__PURE__ */ jsx(
1996
+ "button",
1997
+ {
1998
+ type: "button",
1999
+ className: cn("pds-chat-send", canSend && "pds-chat-send--active"),
2000
+ onClick: send,
2001
+ disabled: disabled || !canSend,
2002
+ "aria-label": "Send message",
2003
+ children: /* @__PURE__ */ jsx(ChatSendIcon, {})
2004
+ }
2005
+ )
2006
+ ] });
2007
+ }
945
2008
 
946
- export { Alert, Avatar, Badge, Button, Card, Checkbox, Container, Divider, DropdownMenu, Grid, Input, Modal, Radio, RadioGroup, Segmented, Select, Skeleton, StatusPill, Switch, Tabs, Textarea, Toast, Tooltip, cn, useToastManager as useToast };
2009
+ export { Alert, Avatar, Badge, Button, Card, ChatCompose, ChatDateDivider, ChatMessage, ChatThread, Checkbox, CommandPalette, Container, DataTable, Divider, DropdownMenu, Grid, Input, Modal, Popover, Radio, RadioGroup, Segmented, Select, Skeleton, StatusPill, Switch, Tabs, Textarea, Toast, Tooltip, cn, useCommandPalette, useToastManager as useToast };
947
2010
  //# sourceMappingURL=index.js.map
948
2011
  //# sourceMappingURL=index.js.map