@facter/ds-core 1.12.0 → 1.14.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 +126 -119
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -118
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.mjs
CHANGED
|
@@ -17,10 +17,10 @@ import { toast as toast$1, Toaster as Toaster$1 } from 'sonner';
|
|
|
17
17
|
import * as SwitchPrimitives from '@radix-ui/react-switch';
|
|
18
18
|
import { FormProvider, useFormContext, Controller } from 'react-hook-form';
|
|
19
19
|
export { FormProvider, useFormContext } from 'react-hook-form';
|
|
20
|
-
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
21
20
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
22
21
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
23
22
|
import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
|
|
23
|
+
import * as PopoverPrimitive from '@radix-ui/react-popover';
|
|
24
24
|
import * as TooltipPrimitive from '@radix-ui/react-tooltip';
|
|
25
25
|
import * as ScrollAreaPrimitive from '@radix-ui/react-scroll-area';
|
|
26
26
|
import * as SeparatorPrimitive from '@radix-ui/react-separator';
|
|
@@ -3208,22 +3208,6 @@ function FormInput({
|
|
|
3208
3208
|
) });
|
|
3209
3209
|
}
|
|
3210
3210
|
FormInput.displayName = "Form.Input";
|
|
3211
|
-
var Popover = PopoverPrimitive.Root;
|
|
3212
|
-
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
3213
|
-
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
3214
|
-
PopoverPrimitive.Content,
|
|
3215
|
-
{
|
|
3216
|
-
ref,
|
|
3217
|
-
align,
|
|
3218
|
-
sideOffset,
|
|
3219
|
-
className: cn(
|
|
3220
|
-
"z-50 w-auto rounded-md border bg-popover p-4 text-popover-foreground shadow-lg outline-none 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=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
3221
|
-
className
|
|
3222
|
-
),
|
|
3223
|
-
...props
|
|
3224
|
-
}
|
|
3225
|
-
) }));
|
|
3226
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
3227
3211
|
function FormSelect({
|
|
3228
3212
|
name,
|
|
3229
3213
|
label,
|
|
@@ -3331,6 +3315,7 @@ function CardSelect({
|
|
|
3331
3315
|
const [open, setOpen] = React10.useState(false);
|
|
3332
3316
|
const [search, setSearch] = React10.useState("");
|
|
3333
3317
|
const selected = options.find((o) => o.value === value);
|
|
3318
|
+
const containerRef = React10.useRef(null);
|
|
3334
3319
|
const listRef = React10.useRef(null);
|
|
3335
3320
|
const searchRef = React10.useRef(null);
|
|
3336
3321
|
const filteredOptions = React10.useMemo(() => {
|
|
@@ -3347,6 +3332,24 @@ function CardSelect({
|
|
|
3347
3332
|
},
|
|
3348
3333
|
[onSearch]
|
|
3349
3334
|
);
|
|
3335
|
+
React10.useEffect(() => {
|
|
3336
|
+
if (!open) return;
|
|
3337
|
+
const handleClickOutside = (e) => {
|
|
3338
|
+
if (containerRef.current && !containerRef.current.contains(e.target)) {
|
|
3339
|
+
setOpen(false);
|
|
3340
|
+
}
|
|
3341
|
+
};
|
|
3342
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
3343
|
+
return () => document.removeEventListener("mousedown", handleClickOutside);
|
|
3344
|
+
}, [open]);
|
|
3345
|
+
React10.useEffect(() => {
|
|
3346
|
+
if (!open) return;
|
|
3347
|
+
const handleEscape = (e) => {
|
|
3348
|
+
if (e.key === "Escape") setOpen(false);
|
|
3349
|
+
};
|
|
3350
|
+
document.addEventListener("keydown", handleEscape);
|
|
3351
|
+
return () => document.removeEventListener("keydown", handleEscape);
|
|
3352
|
+
}, [open]);
|
|
3350
3353
|
React10.useEffect(() => {
|
|
3351
3354
|
if (!open) {
|
|
3352
3355
|
setSearch("");
|
|
@@ -3367,112 +3370,100 @@ function CardSelect({
|
|
|
3367
3370
|
onLoadMore();
|
|
3368
3371
|
}
|
|
3369
3372
|
}, [onLoadMore, hasMore, loading]);
|
|
3370
|
-
return /* @__PURE__ */ jsxs(
|
|
3371
|
-
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3372
|
-
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsxs(
|
|
3373
|
-
"button",
|
|
3374
|
-
{
|
|
3375
|
-
type: "button",
|
|
3376
|
-
className: cn(
|
|
3377
|
-
"flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
|
|
3378
|
-
"focus:outline-none focus:border-primary",
|
|
3379
|
-
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
3380
|
-
label ? "h-12 pt-4 pb-2" : "h-9 py-2",
|
|
3381
|
-
error ? "border-red-500" : "border-border",
|
|
3382
|
-
open && !error && "border-primary"
|
|
3383
|
-
),
|
|
3384
|
-
children: [
|
|
3385
|
-
selected ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 truncate", children: [
|
|
3386
|
-
selected.icon && /* @__PURE__ */ jsx(selected.icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3387
|
-
/* @__PURE__ */ jsx("span", { className: "truncate", children: selected.label })
|
|
3388
|
-
] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: placeholder }),
|
|
3389
|
-
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
3390
|
-
]
|
|
3391
|
-
}
|
|
3392
|
-
) }),
|
|
3393
|
-
label && /* @__PURE__ */ jsxs(
|
|
3394
|
-
"label",
|
|
3395
|
-
{
|
|
3396
|
-
className: cn(
|
|
3397
|
-
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 pointer-events-none",
|
|
3398
|
-
error ? "text-red-500" : "text-foreground"
|
|
3399
|
-
),
|
|
3400
|
-
children: [
|
|
3401
|
-
label,
|
|
3402
|
-
required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3403
|
-
]
|
|
3404
|
-
}
|
|
3405
|
-
)
|
|
3406
|
-
] }),
|
|
3373
|
+
return /* @__PURE__ */ jsxs("div", { ref: containerRef, className: "relative", children: [
|
|
3407
3374
|
/* @__PURE__ */ jsxs(
|
|
3408
|
-
|
|
3375
|
+
"button",
|
|
3409
3376
|
{
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3377
|
+
type: "button",
|
|
3378
|
+
disabled,
|
|
3379
|
+
onClick: () => setOpen((prev) => !prev),
|
|
3380
|
+
className: cn(
|
|
3381
|
+
"flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
|
|
3382
|
+
"focus:outline-none focus:border-primary",
|
|
3383
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
3384
|
+
label ? "h-12 pt-4 pb-2" : "h-9 py-2",
|
|
3385
|
+
error ? "border-red-500" : "border-border",
|
|
3386
|
+
open && !error && "border-primary"
|
|
3387
|
+
),
|
|
3416
3388
|
children: [
|
|
3417
|
-
|
|
3418
|
-
/* @__PURE__ */ jsx(
|
|
3419
|
-
/* @__PURE__ */ jsx(
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
ref: searchRef,
|
|
3423
|
-
type: "text",
|
|
3424
|
-
value: search,
|
|
3425
|
-
onChange: (e) => handleSearch(e.target.value),
|
|
3426
|
-
placeholder: searchPlaceholder,
|
|
3427
|
-
className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
3428
|
-
}
|
|
3429
|
-
)
|
|
3430
|
-
] }),
|
|
3431
|
-
/* @__PURE__ */ jsx(
|
|
3432
|
-
"div",
|
|
3433
|
-
{
|
|
3434
|
-
ref: listRef,
|
|
3435
|
-
className: "overflow-y-auto overscroll-contain",
|
|
3436
|
-
style: { maxHeight: searchable ? "calc(var(--radix-popover-content-available-height) - 45px)" : "var(--radix-popover-content-available-height)" },
|
|
3437
|
-
onScroll: handleScroll,
|
|
3438
|
-
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-border/50 p-2", children: [
|
|
3439
|
-
filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
|
|
3440
|
-
const isSelected = value === option.value;
|
|
3441
|
-
const isDisabled = option.disabled || disabled;
|
|
3442
|
-
return /* @__PURE__ */ jsxs(
|
|
3443
|
-
"button",
|
|
3444
|
-
{
|
|
3445
|
-
type: "button",
|
|
3446
|
-
disabled: isDisabled,
|
|
3447
|
-
onClick: () => {
|
|
3448
|
-
onChange(option.value);
|
|
3449
|
-
setOpen(false);
|
|
3450
|
-
},
|
|
3451
|
-
className: cn(
|
|
3452
|
-
"flex w-full items-center gap-3 p-3 text-left transition-all",
|
|
3453
|
-
"cursor-pointer hover:bg-accent",
|
|
3454
|
-
isSelected && "bg-primary/5",
|
|
3455
|
-
isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
|
|
3456
|
-
),
|
|
3457
|
-
children: [
|
|
3458
|
-
option.icon && /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsx(option.icon, { className: "h-5 w-5 text-primary" }) }),
|
|
3459
|
-
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3460
|
-
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
|
|
3461
|
-
option.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
|
|
3462
|
-
] }),
|
|
3463
|
-
isSelected && /* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) })
|
|
3464
|
-
]
|
|
3465
|
-
},
|
|
3466
|
-
option.value
|
|
3467
|
-
);
|
|
3468
|
-
}),
|
|
3469
|
-
loading && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-3", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
|
|
3470
|
-
] })
|
|
3471
|
-
}
|
|
3472
|
-
)
|
|
3389
|
+
selected ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 truncate", children: [
|
|
3390
|
+
selected.icon && /* @__PURE__ */ jsx(selected.icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3391
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: selected.label })
|
|
3392
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: placeholder }),
|
|
3393
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: cn("h-4 w-4 shrink-0 opacity-50 transition-transform", open && "rotate-180") })
|
|
3473
3394
|
]
|
|
3474
3395
|
}
|
|
3475
|
-
)
|
|
3396
|
+
),
|
|
3397
|
+
label && /* @__PURE__ */ jsxs(
|
|
3398
|
+
"label",
|
|
3399
|
+
{
|
|
3400
|
+
className: cn(
|
|
3401
|
+
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 pointer-events-none",
|
|
3402
|
+
error ? "text-red-500" : "text-foreground"
|
|
3403
|
+
),
|
|
3404
|
+
children: [
|
|
3405
|
+
label,
|
|
3406
|
+
required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3407
|
+
]
|
|
3408
|
+
}
|
|
3409
|
+
),
|
|
3410
|
+
open && /* @__PURE__ */ 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: [
|
|
3411
|
+
searchable && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-border", children: [
|
|
3412
|
+
/* @__PURE__ */ jsx(Search, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3413
|
+
/* @__PURE__ */ jsx(
|
|
3414
|
+
"input",
|
|
3415
|
+
{
|
|
3416
|
+
ref: searchRef,
|
|
3417
|
+
type: "text",
|
|
3418
|
+
value: search,
|
|
3419
|
+
onChange: (e) => handleSearch(e.target.value),
|
|
3420
|
+
placeholder: searchPlaceholder,
|
|
3421
|
+
className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
3422
|
+
}
|
|
3423
|
+
)
|
|
3424
|
+
] }),
|
|
3425
|
+
/* @__PURE__ */ jsx(
|
|
3426
|
+
"div",
|
|
3427
|
+
{
|
|
3428
|
+
ref: listRef,
|
|
3429
|
+
className: "overflow-y-auto overscroll-contain max-h-[300px]",
|
|
3430
|
+
onScroll: handleScroll,
|
|
3431
|
+
children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-border/50 p-2", children: [
|
|
3432
|
+
filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
|
|
3433
|
+
const isSelected = value === option.value;
|
|
3434
|
+
const isDisabled = option.disabled || disabled;
|
|
3435
|
+
return /* @__PURE__ */ jsxs(
|
|
3436
|
+
"button",
|
|
3437
|
+
{
|
|
3438
|
+
type: "button",
|
|
3439
|
+
disabled: isDisabled,
|
|
3440
|
+
onClick: () => {
|
|
3441
|
+
onChange(option.value);
|
|
3442
|
+
setOpen(false);
|
|
3443
|
+
},
|
|
3444
|
+
className: cn(
|
|
3445
|
+
"flex w-full items-center gap-3 p-3 text-left transition-all",
|
|
3446
|
+
"cursor-pointer hover:bg-accent",
|
|
3447
|
+
isSelected && "bg-primary/5",
|
|
3448
|
+
isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
|
|
3449
|
+
),
|
|
3450
|
+
children: [
|
|
3451
|
+
option.icon && /* @__PURE__ */ jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsx(option.icon, { className: "h-5 w-5 text-primary" }) }),
|
|
3452
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3453
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
|
|
3454
|
+
option.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
|
|
3455
|
+
] }),
|
|
3456
|
+
isSelected && /* @__PURE__ */ jsx("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsx(Check, { className: "h-3 w-3" }) })
|
|
3457
|
+
]
|
|
3458
|
+
},
|
|
3459
|
+
option.value
|
|
3460
|
+
);
|
|
3461
|
+
}),
|
|
3462
|
+
loading && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center py-3", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
|
|
3463
|
+
] })
|
|
3464
|
+
}
|
|
3465
|
+
)
|
|
3466
|
+
] })
|
|
3476
3467
|
] });
|
|
3477
3468
|
}
|
|
3478
3469
|
function FormTextarea({
|
|
@@ -4036,6 +4027,22 @@ var DropdownMenuShortcut = ({
|
|
|
4036
4027
|
);
|
|
4037
4028
|
};
|
|
4038
4029
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
4030
|
+
var Popover = PopoverPrimitive.Root;
|
|
4031
|
+
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
4032
|
+
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
4033
|
+
PopoverPrimitive.Content,
|
|
4034
|
+
{
|
|
4035
|
+
ref,
|
|
4036
|
+
align,
|
|
4037
|
+
sideOffset,
|
|
4038
|
+
className: cn(
|
|
4039
|
+
"z-50 w-auto rounded-md border bg-popover p-4 text-popover-foreground shadow-lg outline-none 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=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
|
|
4040
|
+
className
|
|
4041
|
+
),
|
|
4042
|
+
...props
|
|
4043
|
+
}
|
|
4044
|
+
) }));
|
|
4045
|
+
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
4039
4046
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
4040
4047
|
var TooltipRoot = TooltipPrimitive.Root;
|
|
4041
4048
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|