@facter/ds-core 1.33.10 → 1.33.11

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
@@ -16,10 +16,11 @@ var DialogPrimitive = require('@radix-ui/react-dialog');
16
16
  var sonner = require('sonner');
17
17
  var SwitchPrimitives = require('@radix-ui/react-switch');
18
18
  var reactHookForm = require('react-hook-form');
19
- var PopoverPrimitive2 = require('@radix-ui/react-popover');
19
+ var reactDom = require('react-dom');
20
20
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
21
21
  var AvatarPrimitive = require('@radix-ui/react-avatar');
22
22
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
23
+ var PopoverPrimitive = require('@radix-ui/react-popover');
23
24
  var TooltipPrimitive = require('@radix-ui/react-tooltip');
24
25
  var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
25
26
  var SeparatorPrimitive = require('@radix-ui/react-separator');
@@ -50,10 +51,10 @@ var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
50
51
  var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
51
52
  var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
52
53
  var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
53
- var PopoverPrimitive2__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive2);
54
54
  var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
55
55
  var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
56
56
  var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
57
+ var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
57
58
  var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
58
59
  var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
59
60
  var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
@@ -3478,7 +3479,13 @@ function FormSelect({
3478
3479
  {
3479
3480
  value: option.value,
3480
3481
  disabled: option.disabled,
3481
- children: option.label
3482
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2", children: [
3483
+ option.icon && /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-4 w-4 text-muted-foreground" }),
3484
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3485
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: option.label }),
3486
+ option.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-muted-foreground ml-2", children: option.description })
3487
+ ] })
3488
+ ] })
3482
3489
  },
3483
3490
  option.value
3484
3491
  ))
@@ -3511,8 +3518,11 @@ function CardSelect({
3511
3518
  const [open, setOpen] = React10__namespace.useState(false);
3512
3519
  const [search, setSearch] = React10__namespace.useState("");
3513
3520
  const selected = options.find((o) => o.value === value);
3521
+ const containerRef = React10__namespace.useRef(null);
3522
+ const dropdownRef = React10__namespace.useRef(null);
3514
3523
  const listRef = React10__namespace.useRef(null);
3515
3524
  const searchRef = React10__namespace.useRef(null);
3525
+ const [dropdownPos, setDropdownPos] = React10__namespace.useState({});
3516
3526
  const filteredOptions = React10__namespace.useMemo(() => {
3517
3527
  if (!searchable || onSearch || !search) return options;
3518
3528
  const q = search.toLowerCase();
@@ -3527,16 +3537,76 @@ function CardSelect({
3527
3537
  },
3528
3538
  [onSearch]
3529
3539
  );
3530
- const handleOpenChange = React10__namespace.useCallback(
3531
- (nextOpen) => {
3532
- setOpen(nextOpen);
3533
- if (!nextOpen) {
3534
- setSearch("");
3535
- if (onSearch) onSearch("");
3540
+ React10__namespace.useEffect(() => {
3541
+ if (!open || !containerRef.current) return;
3542
+ const updatePosition = () => {
3543
+ const rect = containerRef.current.getBoundingClientRect();
3544
+ const spaceBelow = window.innerHeight - rect.bottom;
3545
+ const estimatedHeight = 340;
3546
+ const showAbove = spaceBelow < estimatedHeight && rect.top > spaceBelow;
3547
+ setDropdownPos({
3548
+ position: "fixed",
3549
+ left: rect.left,
3550
+ width: rect.width,
3551
+ zIndex: 9999,
3552
+ ...showAbove ? { bottom: window.innerHeight - rect.top + 4 } : { top: rect.bottom + 4 }
3553
+ });
3554
+ };
3555
+ updatePosition();
3556
+ window.addEventListener("scroll", updatePosition, true);
3557
+ window.addEventListener("resize", updatePosition);
3558
+ return () => {
3559
+ window.removeEventListener("scroll", updatePosition, true);
3560
+ window.removeEventListener("resize", updatePosition);
3561
+ };
3562
+ }, [open]);
3563
+ React10__namespace.useEffect(() => {
3564
+ if (!open) return;
3565
+ const handleClickOutside = (e) => {
3566
+ const target = e.target;
3567
+ if (containerRef.current && !containerRef.current.contains(target) && (!dropdownRef.current || !dropdownRef.current.contains(target))) {
3568
+ setOpen(false);
3536
3569
  }
3537
- },
3538
- [onSearch]
3539
- );
3570
+ };
3571
+ document.addEventListener("mousedown", handleClickOutside);
3572
+ return () => document.removeEventListener("mousedown", handleClickOutside);
3573
+ }, [open]);
3574
+ React10__namespace.useEffect(() => {
3575
+ if (!open) return;
3576
+ const handleEscape = (e) => {
3577
+ if (e.key === "Escape") setOpen(false);
3578
+ };
3579
+ document.addEventListener("keydown", handleEscape);
3580
+ return () => document.removeEventListener("keydown", handleEscape);
3581
+ }, [open]);
3582
+ React10__namespace.useEffect(() => {
3583
+ if (!open) {
3584
+ setSearch("");
3585
+ if (onSearch) onSearch("");
3586
+ }
3587
+ }, [open, onSearch]);
3588
+ React10__namespace.useEffect(() => {
3589
+ if (open && searchable) {
3590
+ setTimeout(() => searchRef.current?.focus(), 0);
3591
+ }
3592
+ }, [open, searchable]);
3593
+ React10__namespace.useEffect(() => {
3594
+ const el = listRef.current;
3595
+ if (!el || !open) return;
3596
+ const handleWheel = (e) => {
3597
+ const { scrollTop, scrollHeight, clientHeight } = el;
3598
+ const isScrollable = scrollHeight > clientHeight;
3599
+ if (!isScrollable) return;
3600
+ e.preventDefault();
3601
+ e.stopPropagation();
3602
+ el.scrollTop = Math.max(
3603
+ 0,
3604
+ Math.min(scrollTop + e.deltaY, scrollHeight - clientHeight)
3605
+ );
3606
+ };
3607
+ el.addEventListener("wheel", handleWheel, { passive: false, capture: true });
3608
+ return () => el.removeEventListener("wheel", handleWheel, { capture: true });
3609
+ }, [open, filteredOptions]);
3540
3610
  const handleScroll = React10__namespace.useCallback(() => {
3541
3611
  if (!onLoadMore || !hasMore || loading) return;
3542
3612
  const el = listRef.current;
@@ -3546,119 +3616,110 @@ function CardSelect({
3546
3616
  onLoadMore();
3547
3617
  }
3548
3618
  }, [onLoadMore, hasMore, loading]);
3549
- return /* @__PURE__ */ jsxRuntime.jsxs(PopoverPrimitive2__namespace.Root, { open, onOpenChange: handleOpenChange, children: [
3550
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
3551
- /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive2__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
3552
- "button",
3553
- {
3554
- type: "button",
3555
- disabled,
3556
- className: cn(
3557
- "flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
3558
- "focus:outline-none focus:border-primary",
3559
- "disabled:cursor-not-allowed disabled:opacity-50",
3560
- label ? "h-12 pt-4 pb-2" : "h-9 py-2",
3561
- error ? "border-red-500" : "border-border",
3562
- open && !error && "border-primary"
3563
- ),
3564
- children: [
3565
- selected ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 truncate", children: [
3566
- selected.icon && /* @__PURE__ */ jsxRuntime.jsx(selected.icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3567
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: selected.label })
3568
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: placeholder }),
3569
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn("h-4 w-4 shrink-0 opacity-50 transition-transform", open && "rotate-180") })
3570
- ]
3571
- }
3572
- ) }),
3573
- label && /* @__PURE__ */ jsxRuntime.jsxs(
3574
- "label",
3575
- {
3576
- className: cn(
3577
- "absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 pointer-events-none",
3578
- error ? "text-red-500" : "text-foreground"
3579
- ),
3580
- children: [
3581
- label,
3582
- required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
3583
- ]
3584
- }
3585
- )
3586
- ] }),
3619
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: containerRef, className: "relative", children: [
3587
3620
  /* @__PURE__ */ jsxRuntime.jsxs(
3588
- PopoverPrimitive2__namespace.Content,
3621
+ "button",
3589
3622
  {
3590
- align: "start",
3591
- sideOffset: 4,
3623
+ type: "button",
3624
+ disabled,
3625
+ onClick: () => setOpen((prev) => !prev),
3592
3626
  className: cn(
3593
- "z-50 rounded-md border bg-popover text-popover-foreground shadow-lg p-0 overflow-hidden",
3594
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2"
3627
+ "flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
3628
+ "focus:outline-none focus:border-primary",
3629
+ "disabled:cursor-not-allowed disabled:opacity-50",
3630
+ label ? "h-12 pt-4 pb-2" : "h-9 py-2",
3631
+ error ? "border-red-500" : "border-border",
3632
+ open && !error && "border-primary"
3633
+ ),
3634
+ children: [
3635
+ selected ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 truncate", children: [
3636
+ selected.icon && /* @__PURE__ */ jsxRuntime.jsx(selected.icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3637
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: selected.label })
3638
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: placeholder }),
3639
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn("h-4 w-4 shrink-0 opacity-50 transition-transform", open && "rotate-180") })
3640
+ ]
3641
+ }
3642
+ ),
3643
+ label && /* @__PURE__ */ jsxRuntime.jsxs(
3644
+ "label",
3645
+ {
3646
+ className: cn(
3647
+ "absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 pointer-events-none",
3648
+ error ? "text-red-500" : "text-foreground"
3595
3649
  ),
3596
- style: { width: "var(--radix-popover-trigger-width)" },
3597
- onOpenAutoFocus: (e) => {
3598
- e.preventDefault();
3599
- if (searchable) {
3600
- searchRef.current?.focus();
3601
- }
3602
- },
3603
3650
  children: [
3604
- searchable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-border", children: [
3605
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3651
+ label,
3652
+ required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
3653
+ ]
3654
+ }
3655
+ ),
3656
+ open && reactDom.createPortal(
3657
+ /* @__PURE__ */ jsxRuntime.jsxs(
3658
+ "div",
3659
+ {
3660
+ ref: dropdownRef,
3661
+ style: dropdownPos,
3662
+ className: "rounded-md border border-border bg-popover shadow-md overflow-hidden animate-in fade-in-0 zoom-in-95 slide-in-from-top-2 duration-150",
3663
+ children: [
3664
+ searchable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-border", children: [
3665
+ /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3666
+ /* @__PURE__ */ jsxRuntime.jsx(
3667
+ "input",
3668
+ {
3669
+ ref: searchRef,
3670
+ type: "text",
3671
+ value: search,
3672
+ onChange: (e) => handleSearch(e.target.value),
3673
+ placeholder: searchPlaceholder,
3674
+ className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
3675
+ }
3676
+ )
3677
+ ] }),
3606
3678
  /* @__PURE__ */ jsxRuntime.jsx(
3607
- "input",
3679
+ "div",
3608
3680
  {
3609
- ref: searchRef,
3610
- type: "text",
3611
- value: search,
3612
- onChange: (e) => handleSearch(e.target.value),
3613
- placeholder: searchPlaceholder,
3614
- className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
3681
+ ref: listRef,
3682
+ className: "overflow-y-auto overscroll-contain max-h-[300px]",
3683
+ onScroll: handleScroll,
3684
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-border/50 p-2", children: [
3685
+ filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
3686
+ const isSelected = value === option.value;
3687
+ const isDisabled = option.disabled || disabled;
3688
+ return /* @__PURE__ */ jsxRuntime.jsxs(
3689
+ "button",
3690
+ {
3691
+ type: "button",
3692
+ disabled: isDisabled,
3693
+ onClick: () => {
3694
+ onChange(option.value);
3695
+ setOpen(false);
3696
+ },
3697
+ className: cn(
3698
+ "flex w-full items-center gap-3 p-3 text-left transition-all",
3699
+ "cursor-pointer hover:bg-accent",
3700
+ isSelected && "bg-primary/5",
3701
+ isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
3702
+ ),
3703
+ children: [
3704
+ option.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-3.5 w-3.5 text-primary" }) }),
3705
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
3706
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
3707
+ option.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
3708
+ ] }),
3709
+ isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3 w-3" }) })
3710
+ ]
3711
+ },
3712
+ option.value
3713
+ );
3714
+ }),
3715
+ loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-3", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
3716
+ ] })
3615
3717
  }
3616
3718
  )
3617
- ] }),
3618
- /* @__PURE__ */ jsxRuntime.jsx(
3619
- "div",
3620
- {
3621
- ref: listRef,
3622
- className: "overflow-y-auto overscroll-contain",
3623
- style: { maxHeight: "min(300px, var(--radix-popover-content-available-height, 300px))" },
3624
- onScroll: handleScroll,
3625
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-border/50 p-2", children: [
3626
- filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
3627
- const isSelected = value === option.value;
3628
- const isDisabled = option.disabled || disabled;
3629
- return /* @__PURE__ */ jsxRuntime.jsxs(
3630
- "button",
3631
- {
3632
- type: "button",
3633
- disabled: isDisabled,
3634
- onClick: () => {
3635
- onChange(option.value);
3636
- handleOpenChange(false);
3637
- },
3638
- className: cn(
3639
- "flex w-full items-center gap-3 p-3 text-left transition-all",
3640
- "cursor-pointer hover:bg-accent",
3641
- isSelected && "bg-primary/5",
3642
- isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
3643
- ),
3644
- children: [
3645
- option.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-7 w-7 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-3.5 w-3.5 text-primary" }) }),
3646
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
3647
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
3648
- option.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
3649
- ] }),
3650
- isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3 w-3" }) })
3651
- ]
3652
- },
3653
- option.value
3654
- );
3655
- }),
3656
- loading && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center justify-center py-3", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
3657
- ] })
3658
- }
3659
- )
3660
- ]
3661
- }
3719
+ ]
3720
+ }
3721
+ ),
3722
+ document.body
3662
3723
  )
3663
3724
  ] });
3664
3725
  }
@@ -4223,10 +4284,10 @@ var DropdownMenuShortcut = ({
4223
4284
  );
4224
4285
  };
4225
4286
  DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
4226
- var Popover = PopoverPrimitive2__namespace.Root;
4227
- var PopoverTrigger = PopoverPrimitive2__namespace.Trigger;
4228
- var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
4229
- PopoverPrimitive2__namespace.Content,
4287
+ var Popover = PopoverPrimitive__namespace.Root;
4288
+ var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
4289
+ var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
4290
+ PopoverPrimitive__namespace.Content,
4230
4291
  {
4231
4292
  ref,
4232
4293
  align,
@@ -4238,7 +4299,7 @@ var PopoverContent = React10__namespace.forwardRef(({ className, align = "center
4238
4299
  ...props
4239
4300
  }
4240
4301
  ) }));
4241
- PopoverContent.displayName = PopoverPrimitive2__namespace.Content.displayName;
4302
+ PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
4242
4303
  var TooltipProvider = TooltipPrimitive__namespace.Provider;
4243
4304
  var TooltipRoot = TooltipPrimitive__namespace.Root;
4244
4305
  var TooltipTrigger = TooltipPrimitive__namespace.Trigger;