@facter/ds-core 1.33.0 → 1.33.2

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,6 +16,7 @@ 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 reactDom = require('react-dom');
19
20
  var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
20
21
  var AvatarPrimitive = require('@radix-ui/react-avatar');
21
22
  var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
@@ -2531,7 +2532,7 @@ var DataTable = Object.assign(DataTableRoot, {
2531
2532
  ColumnHeader: DataTableColumnHeader
2532
2533
  });
2533
2534
  function DialogMeshEffect() {
2534
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute top-0 left-0 right-0 h-[180px] overflow-hidden rounded-t-lg pointer-events-none z-[1]", children: [
2535
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute top-0 left-0 right-0 h-[48px] overflow-hidden rounded-t-lg pointer-events-none z-[1]", children: [
2535
2536
  /* @__PURE__ */ jsxRuntime.jsx(
2536
2537
  "div",
2537
2538
  {
@@ -3518,8 +3519,10 @@ function CardSelect({
3518
3519
  const [search, setSearch] = React10__namespace.useState("");
3519
3520
  const selected = options.find((o) => o.value === value);
3520
3521
  const containerRef = React10__namespace.useRef(null);
3522
+ const dropdownRef = React10__namespace.useRef(null);
3521
3523
  const listRef = React10__namespace.useRef(null);
3522
3524
  const searchRef = React10__namespace.useRef(null);
3525
+ const [dropdownPos, setDropdownPos] = React10__namespace.useState({});
3523
3526
  const filteredOptions = React10__namespace.useMemo(() => {
3524
3527
  if (!searchable || onSearch || !search) return options;
3525
3528
  const q = search.toLowerCase();
@@ -3534,10 +3537,34 @@ function CardSelect({
3534
3537
  },
3535
3538
  [onSearch]
3536
3539
  );
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]);
3537
3563
  React10__namespace.useEffect(() => {
3538
3564
  if (!open) return;
3539
3565
  const handleClickOutside = (e) => {
3540
- if (containerRef.current && !containerRef.current.contains(e.target)) {
3566
+ const target = e.target;
3567
+ if (containerRef.current && !containerRef.current.contains(target) && (!dropdownRef.current || !dropdownRef.current.contains(target))) {
3541
3568
  setOpen(false);
3542
3569
  }
3543
3570
  };
@@ -3626,63 +3653,74 @@ function CardSelect({
3626
3653
  ]
3627
3654
  }
3628
3655
  ),
3629
- open && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "absolute left-0 top-full z-50 mt-1 w-full 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", children: [
3630
- searchable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-border", children: [
3631
- /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
3632
- /* @__PURE__ */ jsxRuntime.jsx(
3633
- "input",
3634
- {
3635
- ref: searchRef,
3636
- type: "text",
3637
- value: search,
3638
- onChange: (e) => handleSearch(e.target.value),
3639
- placeholder: searchPlaceholder,
3640
- className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
3641
- }
3642
- )
3643
- ] }),
3644
- /* @__PURE__ */ jsxRuntime.jsx(
3656
+ open && reactDom.createPortal(
3657
+ /* @__PURE__ */ jsxRuntime.jsxs(
3645
3658
  "div",
3646
3659
  {
3647
- ref: listRef,
3648
- className: "overflow-y-auto overscroll-contain max-h-[300px]",
3649
- onScroll: handleScroll,
3650
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-border/50 p-2", children: [
3651
- filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
3652
- const isSelected = value === option.value;
3653
- const isDisabled = option.disabled || disabled;
3654
- return /* @__PURE__ */ jsxRuntime.jsxs(
3655
- "button",
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",
3656
3668
  {
3657
- type: "button",
3658
- disabled: isDisabled,
3659
- onClick: () => {
3660
- onChange(option.value);
3661
- setOpen(false);
3662
- },
3663
- className: cn(
3664
- "flex w-full items-center gap-3 p-3 text-left transition-all",
3665
- "cursor-pointer hover:bg-accent",
3666
- isSelected && "bg-primary/5",
3667
- isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
3668
- ),
3669
- children: [
3670
- 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" }) }),
3671
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
3672
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
3673
- option.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
3674
- ] }),
3675
- 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" }) })
3676
- ]
3677
- },
3678
- option.value
3679
- );
3680
- }),
3681
- 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" }) })
3682
- ] })
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
+ ] }),
3678
+ /* @__PURE__ */ jsxRuntime.jsx(
3679
+ "div",
3680
+ {
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
+ ] })
3717
+ }
3718
+ )
3719
+ ]
3683
3720
  }
3684
- )
3685
- ] })
3721
+ ),
3722
+ document.body
3723
+ )
3686
3724
  ] });
3687
3725
  }
3688
3726
  function FormTextarea({