@facter/ds-core 1.33.1 → 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 +92 -54
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +92 -54
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
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');
|
|
@@ -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
|
-
|
|
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 &&
|
|
3630
|
-
|
|
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:
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
children:
|
|
3651
|
-
|
|
3652
|
-
|
|
3653
|
-
|
|
3654
|
-
|
|
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
|
-
|
|
3658
|
-
|
|
3659
|
-
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
|
|
3668
|
-
|
|
3669
|
-
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3677
|
-
|
|
3678
|
-
|
|
3679
|
-
|
|
3680
|
-
|
|
3681
|
-
|
|
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({
|