@facter/ds-core 1.10.0 → 1.11.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.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +125 -20
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +124 -19
- 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';
|
|
20
21
|
import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
|
|
21
22
|
import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|
22
23
|
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,6 +3208,22 @@ 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;
|
|
3211
3227
|
function FormSelect({
|
|
3212
3228
|
name,
|
|
3213
3229
|
label,
|
|
@@ -3221,7 +3237,8 @@ function FormSelect({
|
|
|
3221
3237
|
hideError = false,
|
|
3222
3238
|
selectSize = "default",
|
|
3223
3239
|
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
3224
|
-
loading = false
|
|
3240
|
+
loading = false,
|
|
3241
|
+
variant = "default"
|
|
3225
3242
|
}) {
|
|
3226
3243
|
const form = useFormContext();
|
|
3227
3244
|
const fieldState = form.getFieldState(name, form.formState);
|
|
@@ -3232,7 +3249,19 @@ function FormSelect({
|
|
|
3232
3249
|
control: form.control,
|
|
3233
3250
|
name,
|
|
3234
3251
|
render: ({ field }) => /* @__PURE__ */ jsxs("div", { className: cn("space-y-1", className), children: [
|
|
3235
|
-
/* @__PURE__ */ jsx(
|
|
3252
|
+
variant === "card" ? /* @__PURE__ */ jsx(
|
|
3253
|
+
CardSelect,
|
|
3254
|
+
{
|
|
3255
|
+
options,
|
|
3256
|
+
value: field.value,
|
|
3257
|
+
onChange: (v) => field.onChange(v || void 0),
|
|
3258
|
+
disabled,
|
|
3259
|
+
label,
|
|
3260
|
+
required,
|
|
3261
|
+
error: !!error,
|
|
3262
|
+
placeholder
|
|
3263
|
+
}
|
|
3264
|
+
) : /* @__PURE__ */ jsx(
|
|
3236
3265
|
Select,
|
|
3237
3266
|
{
|
|
3238
3267
|
value: field.value ?? "",
|
|
@@ -3270,6 +3299,98 @@ function FormSelect({
|
|
|
3270
3299
|
) });
|
|
3271
3300
|
}
|
|
3272
3301
|
FormSelect.displayName = "Form.Select";
|
|
3302
|
+
function CardSelect({
|
|
3303
|
+
options,
|
|
3304
|
+
value,
|
|
3305
|
+
onChange,
|
|
3306
|
+
disabled,
|
|
3307
|
+
label,
|
|
3308
|
+
required,
|
|
3309
|
+
error,
|
|
3310
|
+
placeholder = "Selecione..."
|
|
3311
|
+
}) {
|
|
3312
|
+
const [open, setOpen] = React10.useState(false);
|
|
3313
|
+
const selected = options.find((o) => o.value === value);
|
|
3314
|
+
return /* @__PURE__ */ jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
3315
|
+
/* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3316
|
+
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsxs(
|
|
3317
|
+
"button",
|
|
3318
|
+
{
|
|
3319
|
+
type: "button",
|
|
3320
|
+
className: cn(
|
|
3321
|
+
"flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
|
|
3322
|
+
"focus:outline-none focus:border-primary",
|
|
3323
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
3324
|
+
label ? "h-12 pt-4 pb-2" : "h-9 py-2",
|
|
3325
|
+
error ? "border-red-500" : "border-border",
|
|
3326
|
+
open && !error && "border-primary"
|
|
3327
|
+
),
|
|
3328
|
+
children: [
|
|
3329
|
+
selected ? /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 truncate", children: [
|
|
3330
|
+
selected.icon && /* @__PURE__ */ jsx(selected.icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3331
|
+
/* @__PURE__ */ jsx("span", { className: "truncate", children: selected.label })
|
|
3332
|
+
] }) : /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: placeholder }),
|
|
3333
|
+
/* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
3334
|
+
]
|
|
3335
|
+
}
|
|
3336
|
+
) }),
|
|
3337
|
+
label && /* @__PURE__ */ jsxs(
|
|
3338
|
+
"label",
|
|
3339
|
+
{
|
|
3340
|
+
className: cn(
|
|
3341
|
+
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 pointer-events-none",
|
|
3342
|
+
error ? "text-red-500" : "text-foreground"
|
|
3343
|
+
),
|
|
3344
|
+
children: [
|
|
3345
|
+
label,
|
|
3346
|
+
required && /* @__PURE__ */ jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3347
|
+
]
|
|
3348
|
+
}
|
|
3349
|
+
)
|
|
3350
|
+
] }),
|
|
3351
|
+
/* @__PURE__ */ jsx(
|
|
3352
|
+
PopoverContent,
|
|
3353
|
+
{
|
|
3354
|
+
align: "start",
|
|
3355
|
+
className: "p-2 overflow-y-auto",
|
|
3356
|
+
style: {
|
|
3357
|
+
width: "var(--radix-popover-trigger-width)",
|
|
3358
|
+
maxHeight: "var(--radix-popover-content-available-height)"
|
|
3359
|
+
},
|
|
3360
|
+
children: /* @__PURE__ */ jsx("div", { className: "divide-y divide-border/50", children: options.map((option) => {
|
|
3361
|
+
const isSelected = value === option.value;
|
|
3362
|
+
const isDisabled = option.disabled || disabled;
|
|
3363
|
+
return /* @__PURE__ */ jsxs(
|
|
3364
|
+
"button",
|
|
3365
|
+
{
|
|
3366
|
+
type: "button",
|
|
3367
|
+
disabled: isDisabled,
|
|
3368
|
+
onClick: () => {
|
|
3369
|
+
onChange(option.value);
|
|
3370
|
+
setOpen(false);
|
|
3371
|
+
},
|
|
3372
|
+
className: cn(
|
|
3373
|
+
"flex w-full items-center gap-3 p-3 text-left transition-all",
|
|
3374
|
+
"cursor-pointer hover:bg-accent",
|
|
3375
|
+
isSelected && "bg-primary/5",
|
|
3376
|
+
isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
|
|
3377
|
+
),
|
|
3378
|
+
children: [
|
|
3379
|
+
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" }) }),
|
|
3380
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3381
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
|
|
3382
|
+
option.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
|
|
3383
|
+
] }),
|
|
3384
|
+
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" }) })
|
|
3385
|
+
]
|
|
3386
|
+
},
|
|
3387
|
+
option.value
|
|
3388
|
+
);
|
|
3389
|
+
}) })
|
|
3390
|
+
}
|
|
3391
|
+
)
|
|
3392
|
+
] });
|
|
3393
|
+
}
|
|
3273
3394
|
function FormTextarea({
|
|
3274
3395
|
name,
|
|
3275
3396
|
label,
|
|
@@ -3831,22 +3952,6 @@ var DropdownMenuShortcut = ({
|
|
|
3831
3952
|
);
|
|
3832
3953
|
};
|
|
3833
3954
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
3834
|
-
var Popover = PopoverPrimitive.Root;
|
|
3835
|
-
var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
3836
|
-
var PopoverContent = React10.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsx(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx(
|
|
3837
|
-
PopoverPrimitive.Content,
|
|
3838
|
-
{
|
|
3839
|
-
ref,
|
|
3840
|
-
align,
|
|
3841
|
-
sideOffset,
|
|
3842
|
-
className: cn(
|
|
3843
|
-
"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",
|
|
3844
|
-
className
|
|
3845
|
-
),
|
|
3846
|
-
...props
|
|
3847
|
-
}
|
|
3848
|
-
) }));
|
|
3849
|
-
PopoverContent.displayName = PopoverPrimitive.Content.displayName;
|
|
3850
3955
|
var TooltipProvider = TooltipPrimitive.Provider;
|
|
3851
3956
|
var TooltipRoot = TooltipPrimitive.Root;
|
|
3852
3957
|
var TooltipTrigger = TooltipPrimitive.Trigger;
|