@facter/ds-core 1.33.10 → 1.34.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 +57 -30
- package/dist/index.d.ts +57 -30
- package/dist/index.js +892 -526
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +697 -331
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -16,11 +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
|
|
19
|
+
var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
20
|
+
var PopoverPrimitive = require('@radix-ui/react-popover');
|
|
20
21
|
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
21
22
|
var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
22
23
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
23
|
-
var TooltipPrimitive = require('@radix-ui/react-tooltip');
|
|
24
24
|
var ScrollAreaPrimitive = require('@radix-ui/react-scroll-area');
|
|
25
25
|
var SeparatorPrimitive = require('@radix-ui/react-separator');
|
|
26
26
|
var reactSlot = require('@radix-ui/react-slot');
|
|
@@ -50,11 +50,11 @@ var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
|
50
50
|
var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimitive);
|
|
51
51
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
52
52
|
var SwitchPrimitives__namespace = /*#__PURE__*/_interopNamespace(SwitchPrimitives);
|
|
53
|
-
var
|
|
53
|
+
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
54
|
+
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
54
55
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
55
56
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
56
57
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
57
|
-
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
58
58
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
59
59
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
60
60
|
|
|
@@ -196,6 +196,7 @@ var Input = React10__namespace.forwardRef(
|
|
|
196
196
|
label,
|
|
197
197
|
icon: Icon2,
|
|
198
198
|
required,
|
|
199
|
+
labelSuffix,
|
|
199
200
|
containerClassName,
|
|
200
201
|
labelClassName,
|
|
201
202
|
...props
|
|
@@ -240,7 +241,7 @@ var Input = React10__namespace.forwardRef(
|
|
|
240
241
|
"label",
|
|
241
242
|
{
|
|
242
243
|
className: cn(
|
|
243
|
-
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 cursor-pointer",
|
|
244
|
+
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 cursor-pointer inline-flex items-center gap-1",
|
|
244
245
|
error ? "text-red-500" : "text-foreground",
|
|
245
246
|
Icon2 && "left-10",
|
|
246
247
|
labelClassName
|
|
@@ -248,7 +249,8 @@ var Input = React10__namespace.forwardRef(
|
|
|
248
249
|
onClick: focusInput,
|
|
249
250
|
children: [
|
|
250
251
|
label,
|
|
251
|
-
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
252
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" }),
|
|
253
|
+
labelSuffix
|
|
252
254
|
]
|
|
253
255
|
}
|
|
254
256
|
),
|
|
@@ -3256,232 +3258,487 @@ function FormFieldProvider({ name, children }) {
|
|
|
3256
3258
|
);
|
|
3257
3259
|
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldContext.Provider, { value, children });
|
|
3258
3260
|
}
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
case "money":
|
|
3274
|
-
if (!digits) return "";
|
|
3275
|
-
const cents = parseInt(digits, 10) / 100;
|
|
3276
|
-
return new Intl.NumberFormat("pt-BR", {
|
|
3277
|
-
style: "currency",
|
|
3278
|
-
currency: "BRL"
|
|
3279
|
-
}).format(cents);
|
|
3280
|
-
case "percent":
|
|
3281
|
-
if (!digits) return "";
|
|
3282
|
-
const percent = parseInt(digits, 10) / 100;
|
|
3283
|
-
return `${percent.toFixed(2)}%`;
|
|
3284
|
-
case "plate":
|
|
3285
|
-
const upper = value.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
3286
|
-
if (upper.length <= 3) return upper;
|
|
3287
|
-
if (upper.length <= 7) {
|
|
3288
|
-
return upper.replace(/([A-Z]{3})(\d{0,1})([A-Z0-9]{0,1})(\d{0,2})/, "$1-$2$3$4");
|
|
3289
|
-
}
|
|
3290
|
-
return upper.slice(0, 7).replace(/([A-Z]{3})(\d{0,1})([A-Z0-9]{0,1})(\d{0,2})/, "$1-$2$3$4");
|
|
3291
|
-
case "date":
|
|
3292
|
-
return digits.replace(/(\d{2})(\d)/, "$1/$2").replace(/(\d{2})(\d)/, "$1/$2").slice(0, 10);
|
|
3293
|
-
case "time":
|
|
3294
|
-
return digits.replace(/(\d{2})(\d{0,2})/, "$1:$2").slice(0, 5);
|
|
3295
|
-
case "datetime":
|
|
3296
|
-
const dateTime = digits.replace(/(\d{2})(\d)/, "$1/$2").replace(/(\d{2})(\d)/, "$1/$2").replace(/(\d{4})(\d)/, "$1 $2").replace(/(\d{2})(\d{0,2})$/, "$1:$2");
|
|
3297
|
-
return dateTime.slice(0, 16);
|
|
3298
|
-
default:
|
|
3299
|
-
return value;
|
|
3300
|
-
}
|
|
3301
|
-
}
|
|
3302
|
-
function getMaxLength(mask) {
|
|
3303
|
-
switch (mask) {
|
|
3304
|
-
case "phone":
|
|
3305
|
-
return 15;
|
|
3306
|
-
case "cpf":
|
|
3307
|
-
return 14;
|
|
3308
|
-
case "cnpj":
|
|
3309
|
-
return 18;
|
|
3310
|
-
case "cep":
|
|
3311
|
-
return 9;
|
|
3312
|
-
case "plate":
|
|
3313
|
-
return 8;
|
|
3314
|
-
case "date":
|
|
3315
|
-
return 10;
|
|
3316
|
-
case "time":
|
|
3317
|
-
return 5;
|
|
3318
|
-
case "datetime":
|
|
3319
|
-
return 16;
|
|
3320
|
-
default:
|
|
3321
|
-
return void 0;
|
|
3322
|
-
}
|
|
3323
|
-
}
|
|
3324
|
-
function parseValue(displayValue, mask) {
|
|
3325
|
-
if (!displayValue) return void 0;
|
|
3326
|
-
switch (mask) {
|
|
3327
|
-
case "money":
|
|
3328
|
-
const moneyDigits = displayValue.replace(/\D/g, "");
|
|
3329
|
-
return moneyDigits ? parseInt(moneyDigits, 10) / 100 : void 0;
|
|
3330
|
-
case "percent":
|
|
3331
|
-
const percentDigits = displayValue.replace(/\D/g, "");
|
|
3332
|
-
return percentDigits ? parseInt(percentDigits, 10) / 100 : void 0;
|
|
3333
|
-
default:
|
|
3334
|
-
return displayValue || void 0;
|
|
3261
|
+
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
3262
|
+
var TooltipRoot = TooltipPrimitive__namespace.Root;
|
|
3263
|
+
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
3264
|
+
var TooltipPortal = TooltipPrimitive__namespace.Portal;
|
|
3265
|
+
var TooltipArrow = React10__namespace.forwardRef(({ className, variant = "light", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3266
|
+
TooltipPrimitive__namespace.Arrow,
|
|
3267
|
+
{
|
|
3268
|
+
ref,
|
|
3269
|
+
className: cn(
|
|
3270
|
+
"z-50",
|
|
3271
|
+
variant === "dark" ? "fill-popover" : "fill-background",
|
|
3272
|
+
className
|
|
3273
|
+
),
|
|
3274
|
+
...props
|
|
3335
3275
|
}
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
|
|
3348
|
-
|
|
3349
|
-
|
|
3350
|
-
maxLength,
|
|
3351
|
-
...inputProps
|
|
3352
|
-
}) {
|
|
3353
|
-
const form = reactHookForm.useFormContext();
|
|
3354
|
-
const fieldState = form.getFieldState(name, form.formState);
|
|
3355
|
-
const error = fieldState.error?.message;
|
|
3356
|
-
const getInputType = React10__namespace.useCallback(() => {
|
|
3357
|
-
if (["money", "percent", "phone", "cpf", "cnpj", "cep"].includes(mask || "")) {
|
|
3358
|
-
return "tel";
|
|
3359
|
-
}
|
|
3360
|
-
return type;
|
|
3361
|
-
}, [mask, type]);
|
|
3362
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldProvider, { name, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3363
|
-
reactHookForm.Controller,
|
|
3364
|
-
{
|
|
3365
|
-
control: form.control,
|
|
3366
|
-
name,
|
|
3367
|
-
render: ({ field }) => {
|
|
3368
|
-
const getDisplayValue = () => {
|
|
3369
|
-
if (field.value === void 0 || field.value === null) return "";
|
|
3370
|
-
if (mask) {
|
|
3371
|
-
return applyMask(String(field.value), mask);
|
|
3372
|
-
}
|
|
3373
|
-
return String(field.value);
|
|
3374
|
-
};
|
|
3375
|
-
const handleChange = (e) => {
|
|
3376
|
-
let newValue = e.target.value;
|
|
3377
|
-
if (mask) {
|
|
3378
|
-
newValue = applyMask(newValue, mask);
|
|
3379
|
-
const parsed = parseValue(newValue, mask);
|
|
3380
|
-
field.onChange(parsed);
|
|
3381
|
-
} else {
|
|
3382
|
-
field.onChange(newValue || void 0);
|
|
3383
|
-
}
|
|
3384
|
-
};
|
|
3385
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-1", className), children: [
|
|
3386
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3387
|
-
Input,
|
|
3388
|
-
{
|
|
3389
|
-
...inputProps,
|
|
3390
|
-
ref: field.ref,
|
|
3391
|
-
name: field.name,
|
|
3392
|
-
value: getDisplayValue(),
|
|
3393
|
-
onChange: handleChange,
|
|
3394
|
-
onBlur: field.onBlur,
|
|
3395
|
-
disabled,
|
|
3396
|
-
type: getInputType(),
|
|
3397
|
-
label,
|
|
3398
|
-
required,
|
|
3399
|
-
error: !!error,
|
|
3400
|
-
icon,
|
|
3401
|
-
inputSize,
|
|
3402
|
-
maxLength: maxLength ?? getMaxLength(mask)
|
|
3403
|
-
}
|
|
3404
|
-
),
|
|
3405
|
-
description && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground px-1", children: description }),
|
|
3406
|
-
!hideError && error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500 px-1", children: error })
|
|
3407
|
-
] });
|
|
3276
|
+
));
|
|
3277
|
+
TooltipArrow.displayName = "TooltipArrow";
|
|
3278
|
+
var tooltipContentVariants = classVarianceAuthority.cva(
|
|
3279
|
+
"z-50 overflow-hidden rounded-lg shadow-lg outline-none animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",
|
|
3280
|
+
{
|
|
3281
|
+
variants: {
|
|
3282
|
+
variant: {
|
|
3283
|
+
light: "bg-background text-foreground border border-border",
|
|
3284
|
+
dark: "bg-popover text-popover-foreground border border-border"
|
|
3285
|
+
},
|
|
3286
|
+
size: {
|
|
3287
|
+
sm: "max-w-[200px] p-2",
|
|
3288
|
+
md: "max-w-[280px] p-3",
|
|
3289
|
+
lg: "max-w-[360px] p-4"
|
|
3408
3290
|
}
|
|
3291
|
+
},
|
|
3292
|
+
defaultVariants: {
|
|
3293
|
+
variant: "light",
|
|
3294
|
+
size: "md"
|
|
3409
3295
|
}
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3422
|
-
|
|
3423
|
-
|
|
3424
|
-
selectSize = "default",
|
|
3425
|
-
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
3426
|
-
loading = false,
|
|
3427
|
-
variant = "default",
|
|
3428
|
-
searchable = false,
|
|
3429
|
-
onSearch,
|
|
3430
|
-
onLoadMore,
|
|
3431
|
-
hasMore,
|
|
3432
|
-
searchPlaceholder = "Buscar..."
|
|
3433
|
-
}) {
|
|
3434
|
-
const form = reactHookForm.useFormContext();
|
|
3435
|
-
const fieldState = form.getFieldState(name, form.formState);
|
|
3436
|
-
const error = fieldState.error?.message;
|
|
3437
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldProvider, { name, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3438
|
-
reactHookForm.Controller,
|
|
3296
|
+
}
|
|
3297
|
+
);
|
|
3298
|
+
var TooltipContent = React10__namespace.forwardRef(
|
|
3299
|
+
({
|
|
3300
|
+
className,
|
|
3301
|
+
variant = "light",
|
|
3302
|
+
size = "md",
|
|
3303
|
+
sideOffset = 8,
|
|
3304
|
+
showArrow = true,
|
|
3305
|
+
onDismiss,
|
|
3306
|
+
children,
|
|
3307
|
+
...props
|
|
3308
|
+
}, ref) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3309
|
+
TooltipPrimitive__namespace.Content,
|
|
3439
3310
|
{
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3311
|
+
ref,
|
|
3312
|
+
sideOffset,
|
|
3313
|
+
className: cn(tooltipContentVariants({ variant, size }), className),
|
|
3314
|
+
...props,
|
|
3315
|
+
children: [
|
|
3316
|
+
onDismiss && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3317
|
+
"button",
|
|
3445
3318
|
{
|
|
3446
|
-
|
|
3447
|
-
|
|
3448
|
-
|
|
3449
|
-
|
|
3450
|
-
label,
|
|
3451
|
-
required,
|
|
3452
|
-
error: !!error,
|
|
3453
|
-
placeholder,
|
|
3454
|
-
searchable,
|
|
3455
|
-
onSearch,
|
|
3456
|
-
onLoadMore,
|
|
3457
|
-
hasMore,
|
|
3458
|
-
loading,
|
|
3459
|
-
emptyText,
|
|
3460
|
-
searchPlaceholder
|
|
3319
|
+
onClick: onDismiss,
|
|
3320
|
+
className: "absolute top-2 right-2 p-1 rounded-full transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",
|
|
3321
|
+
"aria-label": "Fechar",
|
|
3322
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3.5 w-3.5" })
|
|
3461
3323
|
}
|
|
3462
|
-
)
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
|
|
3467
|
-
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3324
|
+
),
|
|
3325
|
+
children,
|
|
3326
|
+
showArrow && /* @__PURE__ */ jsxRuntime.jsx(TooltipArrow, { variant: variant ?? "light", width: 12, height: 6 })
|
|
3327
|
+
]
|
|
3328
|
+
}
|
|
3329
|
+
) })
|
|
3330
|
+
);
|
|
3331
|
+
TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
|
|
3332
|
+
var TooltipHeader = React10__namespace.forwardRef(
|
|
3333
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col gap-1", className), ...props })
|
|
3334
|
+
);
|
|
3335
|
+
TooltipHeader.displayName = "TooltipHeader";
|
|
3336
|
+
var TooltipTitle = React10__namespace.forwardRef(
|
|
3337
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3338
|
+
"h4",
|
|
3339
|
+
{
|
|
3340
|
+
ref,
|
|
3341
|
+
className: cn("text-sm font-semibold leading-tight", className),
|
|
3342
|
+
...props
|
|
3343
|
+
}
|
|
3344
|
+
)
|
|
3345
|
+
);
|
|
3346
|
+
TooltipTitle.displayName = "TooltipTitle";
|
|
3347
|
+
var TooltipDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3348
|
+
"p",
|
|
3349
|
+
{
|
|
3350
|
+
ref,
|
|
3351
|
+
className: cn("text-xs leading-relaxed text-muted-foreground", className),
|
|
3352
|
+
...props
|
|
3353
|
+
}
|
|
3354
|
+
));
|
|
3355
|
+
TooltipDescription.displayName = "TooltipDescription";
|
|
3356
|
+
var TooltipActions = React10__namespace.forwardRef(
|
|
3357
|
+
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3358
|
+
"div",
|
|
3359
|
+
{
|
|
3360
|
+
ref,
|
|
3361
|
+
className: cn("flex items-center gap-2 mt-3", className),
|
|
3362
|
+
...props
|
|
3363
|
+
}
|
|
3364
|
+
)
|
|
3365
|
+
);
|
|
3366
|
+
TooltipActions.displayName = "TooltipActions";
|
|
3367
|
+
var tooltipActionVariants = classVarianceAuthority.cva(
|
|
3368
|
+
"inline-flex items-center justify-center text-xs font-medium rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
3369
|
+
{
|
|
3370
|
+
variants: {
|
|
3371
|
+
variant: {
|
|
3372
|
+
primary: "bg-primary text-primary-foreground hover:bg-primary/90 px-3 py-1.5",
|
|
3373
|
+
secondary: "bg-transparent text-muted-foreground hover:text-foreground hover:underline px-2 py-1.5",
|
|
3374
|
+
outline: "border border-border bg-background text-foreground hover:bg-muted px-3 py-1.5"
|
|
3375
|
+
}
|
|
3376
|
+
},
|
|
3377
|
+
defaultVariants: {
|
|
3378
|
+
variant: "primary"
|
|
3379
|
+
}
|
|
3380
|
+
}
|
|
3381
|
+
);
|
|
3382
|
+
var TooltipAction = React10__namespace.forwardRef(
|
|
3383
|
+
({ className, variant = "primary", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3384
|
+
"button",
|
|
3385
|
+
{
|
|
3386
|
+
ref,
|
|
3387
|
+
className: cn(tooltipActionVariants({ variant }), className),
|
|
3388
|
+
...props
|
|
3389
|
+
}
|
|
3390
|
+
)
|
|
3391
|
+
);
|
|
3392
|
+
TooltipAction.displayName = "TooltipAction";
|
|
3393
|
+
var TooltipIcon = React10__namespace.forwardRef(
|
|
3394
|
+
({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3395
|
+
"div",
|
|
3396
|
+
{
|
|
3397
|
+
ref,
|
|
3398
|
+
className: cn(
|
|
3399
|
+
"flex items-center justify-center w-10 h-10 rounded-full mb-3 bg-muted",
|
|
3400
|
+
className
|
|
3401
|
+
),
|
|
3402
|
+
...props,
|
|
3403
|
+
children
|
|
3404
|
+
}
|
|
3405
|
+
)
|
|
3406
|
+
);
|
|
3407
|
+
TooltipIcon.displayName = "TooltipIcon";
|
|
3408
|
+
var SimpleTooltip = ({
|
|
3409
|
+
children,
|
|
3410
|
+
content,
|
|
3411
|
+
variant = "light",
|
|
3412
|
+
side = "top",
|
|
3413
|
+
align = "center",
|
|
3414
|
+
delayDuration = 200,
|
|
3415
|
+
open,
|
|
3416
|
+
defaultOpen,
|
|
3417
|
+
onOpenChange
|
|
3418
|
+
}) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3419
|
+
TooltipRoot,
|
|
3420
|
+
{
|
|
3421
|
+
open,
|
|
3422
|
+
defaultOpen,
|
|
3423
|
+
onOpenChange,
|
|
3424
|
+
delayDuration,
|
|
3425
|
+
children: [
|
|
3426
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children }),
|
|
3427
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { variant, side, align, size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: content }) })
|
|
3428
|
+
]
|
|
3429
|
+
}
|
|
3430
|
+
);
|
|
3431
|
+
SimpleTooltip.displayName = "SimpleTooltip";
|
|
3432
|
+
var Tooltip = Object.assign(TooltipRoot, {
|
|
3433
|
+
Provider: TooltipProvider,
|
|
3434
|
+
Trigger: TooltipTrigger,
|
|
3435
|
+
Portal: TooltipPortal,
|
|
3436
|
+
Content: TooltipContent,
|
|
3437
|
+
Arrow: TooltipArrow,
|
|
3438
|
+
Header: TooltipHeader,
|
|
3439
|
+
Title: TooltipTitle,
|
|
3440
|
+
Description: TooltipDescription,
|
|
3441
|
+
Actions: TooltipActions,
|
|
3442
|
+
Action: TooltipAction,
|
|
3443
|
+
Icon: TooltipIcon,
|
|
3444
|
+
Simple: SimpleTooltip
|
|
3445
|
+
});
|
|
3446
|
+
var FormLabel = React10__namespace.forwardRef(
|
|
3447
|
+
({ className, required, children, ...props }, ref) => {
|
|
3448
|
+
const fieldContext = useFormFieldContextOptional();
|
|
3449
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3450
|
+
"label",
|
|
3451
|
+
{
|
|
3452
|
+
ref,
|
|
3453
|
+
htmlFor: fieldContext?.id,
|
|
3454
|
+
className: cn(
|
|
3455
|
+
"text-sm font-medium leading-none",
|
|
3456
|
+
fieldContext?.error && "text-red-500",
|
|
3457
|
+
className
|
|
3458
|
+
),
|
|
3459
|
+
...props,
|
|
3460
|
+
children: [
|
|
3461
|
+
children,
|
|
3462
|
+
(required || fieldContext?.isRequired) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3463
|
+
]
|
|
3464
|
+
}
|
|
3465
|
+
);
|
|
3466
|
+
}
|
|
3467
|
+
);
|
|
3468
|
+
FormLabel.displayName = "Form.Label";
|
|
3469
|
+
var FormDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
3470
|
+
const fieldContext = useFormFieldContextOptional();
|
|
3471
|
+
if (fieldContext?.error) {
|
|
3472
|
+
return null;
|
|
3473
|
+
}
|
|
3474
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3475
|
+
"p",
|
|
3476
|
+
{
|
|
3477
|
+
ref,
|
|
3478
|
+
className: cn("text-xs text-muted-foreground", className),
|
|
3479
|
+
...props
|
|
3480
|
+
}
|
|
3481
|
+
);
|
|
3482
|
+
});
|
|
3483
|
+
FormDescription.displayName = "Form.Description";
|
|
3484
|
+
var FormError = React10__namespace.forwardRef(
|
|
3485
|
+
({ className, message, children, ...props }, ref) => {
|
|
3486
|
+
const fieldContext = useFormFieldContextOptional();
|
|
3487
|
+
const errorMessage = message ?? fieldContext?.error;
|
|
3488
|
+
if (!errorMessage && !children) {
|
|
3489
|
+
return null;
|
|
3490
|
+
}
|
|
3491
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3492
|
+
"p",
|
|
3493
|
+
{
|
|
3494
|
+
ref,
|
|
3495
|
+
className: cn("text-xs text-red-500", className),
|
|
3496
|
+
...props,
|
|
3497
|
+
children: children || errorMessage
|
|
3498
|
+
}
|
|
3499
|
+
);
|
|
3500
|
+
}
|
|
3501
|
+
);
|
|
3502
|
+
FormError.displayName = "Form.Error";
|
|
3503
|
+
var FormFieldWrapper = React10__namespace.forwardRef(({ className, label, description, required, error, children, ...props }, ref) => {
|
|
3504
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn("space-y-1", className), ...props, children: [
|
|
3505
|
+
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, children: label }),
|
|
3506
|
+
children,
|
|
3507
|
+
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: description }),
|
|
3508
|
+
error && /* @__PURE__ */ jsxRuntime.jsx(FormError, { message: error })
|
|
3509
|
+
] });
|
|
3510
|
+
});
|
|
3511
|
+
FormFieldWrapper.displayName = "Form.FieldWrapper";
|
|
3512
|
+
function FieldTooltipIcon({ tooltip }) {
|
|
3513
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(TooltipRoot, { delayDuration: 200, children: [
|
|
3514
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Info, { className: "h-3 w-3 text-primary cursor-help shrink-0" }) }),
|
|
3515
|
+
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { side: "top", size: "md", children: typeof tooltip === "string" ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: tooltip }) : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-0.5", children: [
|
|
3516
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs font-semibold leading-snug", children: tooltip.title }),
|
|
3517
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground leading-snug", children: tooltip.description })
|
|
3518
|
+
] }) })
|
|
3519
|
+
] });
|
|
3520
|
+
}
|
|
3521
|
+
function applyMask(value, mask) {
|
|
3522
|
+
const digits = value.replace(/\D/g, "");
|
|
3523
|
+
switch (mask) {
|
|
3524
|
+
case "phone":
|
|
3525
|
+
if (digits.length <= 10) {
|
|
3526
|
+
return digits.replace(/(\d{2})(\d{4})(\d{0,4})/, "($1) $2-$3").trim();
|
|
3527
|
+
}
|
|
3528
|
+
return digits.replace(/(\d{2})(\d{5})(\d{0,4})/, "($1) $2-$3").trim();
|
|
3529
|
+
case "cpf":
|
|
3530
|
+
return digits.replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d{1,2})$/, "$1-$2");
|
|
3531
|
+
case "cnpj":
|
|
3532
|
+
return digits.replace(/(\d{2})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1.$2").replace(/(\d{3})(\d)/, "$1/$2").replace(/(\d{4})(\d{1,2})$/, "$1-$2");
|
|
3533
|
+
case "cep":
|
|
3534
|
+
return digits.replace(/(\d{5})(\d{0,3})/, "$1-$2");
|
|
3535
|
+
case "money":
|
|
3536
|
+
if (!digits) return "";
|
|
3537
|
+
const cents = parseInt(digits, 10) / 100;
|
|
3538
|
+
return new Intl.NumberFormat("pt-BR", {
|
|
3539
|
+
style: "currency",
|
|
3540
|
+
currency: "BRL"
|
|
3541
|
+
}).format(cents);
|
|
3542
|
+
case "percent":
|
|
3543
|
+
if (!digits) return "";
|
|
3544
|
+
const percent = parseInt(digits, 10) / 100;
|
|
3545
|
+
return `${percent.toFixed(2)}%`;
|
|
3546
|
+
case "plate":
|
|
3547
|
+
const upper = value.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
3548
|
+
if (upper.length <= 3) return upper;
|
|
3549
|
+
if (upper.length <= 7) {
|
|
3550
|
+
return upper.replace(/([A-Z]{3})(\d{0,1})([A-Z0-9]{0,1})(\d{0,2})/, "$1-$2$3$4");
|
|
3551
|
+
}
|
|
3552
|
+
return upper.slice(0, 7).replace(/([A-Z]{3})(\d{0,1})([A-Z0-9]{0,1})(\d{0,2})/, "$1-$2$3$4");
|
|
3553
|
+
case "date":
|
|
3554
|
+
return digits.replace(/(\d{2})(\d)/, "$1/$2").replace(/(\d{2})(\d)/, "$1/$2").slice(0, 10);
|
|
3555
|
+
case "time":
|
|
3556
|
+
return digits.replace(/(\d{2})(\d{0,2})/, "$1:$2").slice(0, 5);
|
|
3557
|
+
case "datetime":
|
|
3558
|
+
const dateTime = digits.replace(/(\d{2})(\d)/, "$1/$2").replace(/(\d{2})(\d)/, "$1/$2").replace(/(\d{4})(\d)/, "$1 $2").replace(/(\d{2})(\d{0,2})$/, "$1:$2");
|
|
3559
|
+
return dateTime.slice(0, 16);
|
|
3560
|
+
default:
|
|
3561
|
+
return value;
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
function getMaxLength(mask) {
|
|
3565
|
+
switch (mask) {
|
|
3566
|
+
case "phone":
|
|
3567
|
+
return 15;
|
|
3568
|
+
case "cpf":
|
|
3569
|
+
return 14;
|
|
3570
|
+
case "cnpj":
|
|
3571
|
+
return 18;
|
|
3572
|
+
case "cep":
|
|
3573
|
+
return 9;
|
|
3574
|
+
case "plate":
|
|
3575
|
+
return 8;
|
|
3576
|
+
case "date":
|
|
3577
|
+
return 10;
|
|
3578
|
+
case "time":
|
|
3579
|
+
return 5;
|
|
3580
|
+
case "datetime":
|
|
3581
|
+
return 16;
|
|
3582
|
+
default:
|
|
3583
|
+
return void 0;
|
|
3584
|
+
}
|
|
3585
|
+
}
|
|
3586
|
+
function parseValue(displayValue, mask) {
|
|
3587
|
+
if (!displayValue) return void 0;
|
|
3588
|
+
switch (mask) {
|
|
3589
|
+
case "money":
|
|
3590
|
+
const moneyDigits = displayValue.replace(/\D/g, "");
|
|
3591
|
+
return moneyDigits ? parseInt(moneyDigits, 10) / 100 : void 0;
|
|
3592
|
+
case "percent":
|
|
3593
|
+
const percentDigits = displayValue.replace(/\D/g, "");
|
|
3594
|
+
return percentDigits ? parseInt(percentDigits, 10) / 100 : void 0;
|
|
3595
|
+
default:
|
|
3596
|
+
return displayValue || void 0;
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
function FormInput({
|
|
3600
|
+
name,
|
|
3601
|
+
label,
|
|
3602
|
+
description,
|
|
3603
|
+
tooltip,
|
|
3604
|
+
required,
|
|
3605
|
+
disabled,
|
|
3606
|
+
className,
|
|
3607
|
+
mask,
|
|
3608
|
+
icon,
|
|
3609
|
+
showPasswordToggle = true,
|
|
3610
|
+
inputSize = "default",
|
|
3611
|
+
hideError = false,
|
|
3612
|
+
type = "text",
|
|
3613
|
+
maxLength,
|
|
3614
|
+
...inputProps
|
|
3615
|
+
}) {
|
|
3616
|
+
const form = reactHookForm.useFormContext();
|
|
3617
|
+
const fieldState = form.getFieldState(name, form.formState);
|
|
3618
|
+
const error = fieldState.error?.message;
|
|
3619
|
+
const getInputType = React10__namespace.useCallback(() => {
|
|
3620
|
+
if (["money", "percent", "phone", "cpf", "cnpj", "cep"].includes(mask || "")) {
|
|
3621
|
+
return "tel";
|
|
3622
|
+
}
|
|
3623
|
+
return type;
|
|
3624
|
+
}, [mask, type]);
|
|
3625
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldProvider, { name, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3626
|
+
reactHookForm.Controller,
|
|
3627
|
+
{
|
|
3628
|
+
control: form.control,
|
|
3629
|
+
name,
|
|
3630
|
+
render: ({ field }) => {
|
|
3631
|
+
const getDisplayValue = () => {
|
|
3632
|
+
if (field.value === void 0 || field.value === null) return "";
|
|
3633
|
+
if (mask) {
|
|
3634
|
+
return applyMask(String(field.value), mask);
|
|
3635
|
+
}
|
|
3636
|
+
return String(field.value);
|
|
3637
|
+
};
|
|
3638
|
+
const handleChange = (e) => {
|
|
3639
|
+
let newValue = e.target.value;
|
|
3640
|
+
if (mask) {
|
|
3641
|
+
newValue = applyMask(newValue, mask);
|
|
3642
|
+
const parsed = parseValue(newValue, mask);
|
|
3643
|
+
field.onChange(parsed);
|
|
3644
|
+
} else {
|
|
3645
|
+
field.onChange(newValue || void 0);
|
|
3646
|
+
}
|
|
3647
|
+
};
|
|
3648
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-1", className), children: [
|
|
3649
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3650
|
+
Input,
|
|
3651
|
+
{
|
|
3652
|
+
...inputProps,
|
|
3653
|
+
ref: field.ref,
|
|
3654
|
+
name: field.name,
|
|
3655
|
+
value: getDisplayValue(),
|
|
3656
|
+
onChange: handleChange,
|
|
3657
|
+
onBlur: field.onBlur,
|
|
3658
|
+
disabled,
|
|
3659
|
+
type: getInputType(),
|
|
3660
|
+
label,
|
|
3661
|
+
required,
|
|
3662
|
+
error: !!error,
|
|
3663
|
+
icon,
|
|
3664
|
+
inputSize,
|
|
3665
|
+
maxLength: maxLength ?? getMaxLength(mask),
|
|
3666
|
+
labelSuffix: tooltip ? /* @__PURE__ */ jsxRuntime.jsx(FieldTooltipIcon, { tooltip }) : void 0
|
|
3667
|
+
}
|
|
3668
|
+
),
|
|
3669
|
+
description && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground px-1", children: description }),
|
|
3670
|
+
!hideError && error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500 px-1", children: error })
|
|
3671
|
+
] });
|
|
3672
|
+
}
|
|
3673
|
+
}
|
|
3674
|
+
) });
|
|
3675
|
+
}
|
|
3676
|
+
FormInput.displayName = "Form.Input";
|
|
3677
|
+
var Popover = PopoverPrimitive__namespace.Root;
|
|
3678
|
+
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
3679
|
+
var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3680
|
+
PopoverPrimitive__namespace.Content,
|
|
3681
|
+
{
|
|
3682
|
+
ref,
|
|
3683
|
+
align,
|
|
3684
|
+
sideOffset,
|
|
3685
|
+
className: cn(
|
|
3686
|
+
"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",
|
|
3687
|
+
className
|
|
3688
|
+
),
|
|
3689
|
+
...props
|
|
3690
|
+
}
|
|
3691
|
+
) }));
|
|
3692
|
+
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
3693
|
+
function FormSelect({
|
|
3694
|
+
name,
|
|
3695
|
+
label,
|
|
3696
|
+
description,
|
|
3697
|
+
tooltip,
|
|
3698
|
+
required,
|
|
3699
|
+
disabled,
|
|
3700
|
+
className,
|
|
3701
|
+
options,
|
|
3702
|
+
placeholder = "Selecione...",
|
|
3703
|
+
hideError = false,
|
|
3704
|
+
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
3705
|
+
loading = false,
|
|
3706
|
+
searchable = false,
|
|
3707
|
+
onSearch,
|
|
3708
|
+
onLoadMore,
|
|
3709
|
+
hasMore,
|
|
3710
|
+
searchPlaceholder = "Buscar...",
|
|
3711
|
+
dropdownPosition = "bottom"
|
|
3712
|
+
}) {
|
|
3713
|
+
const form = reactHookForm.useFormContext();
|
|
3714
|
+
const fieldState = form.getFieldState(name, form.formState);
|
|
3715
|
+
const error = fieldState.error?.message;
|
|
3716
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldProvider, { name, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3717
|
+
reactHookForm.Controller,
|
|
3718
|
+
{
|
|
3719
|
+
control: form.control,
|
|
3720
|
+
name,
|
|
3721
|
+
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-1", className), children: [
|
|
3722
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3723
|
+
SelectDropdown,
|
|
3724
|
+
{
|
|
3725
|
+
options,
|
|
3726
|
+
value: field.value,
|
|
3727
|
+
onChange: (v) => field.onChange(v || void 0),
|
|
3728
|
+
disabled,
|
|
3729
|
+
label,
|
|
3730
|
+
tooltip,
|
|
3471
3731
|
required,
|
|
3472
3732
|
error: !!error,
|
|
3473
|
-
icon,
|
|
3474
|
-
selectSize,
|
|
3475
3733
|
placeholder,
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
))
|
|
3734
|
+
searchable,
|
|
3735
|
+
onSearch,
|
|
3736
|
+
onLoadMore,
|
|
3737
|
+
hasMore,
|
|
3738
|
+
loading,
|
|
3739
|
+
emptyText,
|
|
3740
|
+
searchPlaceholder,
|
|
3741
|
+
dropdownPosition
|
|
3485
3742
|
}
|
|
3486
3743
|
),
|
|
3487
3744
|
description && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground px-1", children: description }),
|
|
@@ -3491,12 +3748,13 @@ function FormSelect({
|
|
|
3491
3748
|
) });
|
|
3492
3749
|
}
|
|
3493
3750
|
FormSelect.displayName = "Form.Select";
|
|
3494
|
-
function
|
|
3751
|
+
function SelectDropdown({
|
|
3495
3752
|
options,
|
|
3496
3753
|
value,
|
|
3497
3754
|
onChange,
|
|
3498
3755
|
disabled,
|
|
3499
3756
|
label,
|
|
3757
|
+
tooltip,
|
|
3500
3758
|
required,
|
|
3501
3759
|
error,
|
|
3502
3760
|
placeholder = "Selecione...",
|
|
@@ -3506,11 +3764,13 @@ function CardSelect({
|
|
|
3506
3764
|
hasMore,
|
|
3507
3765
|
loading,
|
|
3508
3766
|
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
3509
|
-
searchPlaceholder = "Buscar..."
|
|
3767
|
+
searchPlaceholder = "Buscar...",
|
|
3768
|
+
dropdownPosition = "bottom"
|
|
3510
3769
|
}) {
|
|
3511
3770
|
const [open, setOpen] = React10__namespace.useState(false);
|
|
3512
3771
|
const [search, setSearch] = React10__namespace.useState("");
|
|
3513
3772
|
const selected = options.find((o) => o.value === value);
|
|
3773
|
+
const contentRef = React10__namespace.useRef(null);
|
|
3514
3774
|
const listRef = React10__namespace.useRef(null);
|
|
3515
3775
|
const searchRef = React10__namespace.useRef(null);
|
|
3516
3776
|
const filteredOptions = React10__namespace.useMemo(() => {
|
|
@@ -3521,9 +3781,9 @@ function CardSelect({
|
|
|
3521
3781
|
);
|
|
3522
3782
|
}, [options, search, searchable, onSearch]);
|
|
3523
3783
|
const handleSearch = React10__namespace.useCallback(
|
|
3524
|
-
(
|
|
3525
|
-
setSearch(
|
|
3526
|
-
if (onSearch) onSearch(
|
|
3784
|
+
(val) => {
|
|
3785
|
+
setSearch(val);
|
|
3786
|
+
if (onSearch) onSearch(val);
|
|
3527
3787
|
},
|
|
3528
3788
|
[onSearch]
|
|
3529
3789
|
);
|
|
@@ -3546,9 +3806,36 @@ function CardSelect({
|
|
|
3546
3806
|
onLoadMore();
|
|
3547
3807
|
}
|
|
3548
3808
|
}, [onLoadMore, hasMore, loading]);
|
|
3549
|
-
|
|
3809
|
+
React10__namespace.useEffect(() => {
|
|
3810
|
+
if (!open) return;
|
|
3811
|
+
let cancelled = false;
|
|
3812
|
+
let removeHandler;
|
|
3813
|
+
requestAnimationFrame(() => {
|
|
3814
|
+
if (cancelled) return;
|
|
3815
|
+
const content = contentRef.current;
|
|
3816
|
+
const list = listRef.current;
|
|
3817
|
+
if (!content || !list) return;
|
|
3818
|
+
const handleWheel = (e) => {
|
|
3819
|
+
if (!content.contains(e.target)) return;
|
|
3820
|
+
const { scrollTop, scrollHeight, clientHeight } = list;
|
|
3821
|
+
if (scrollHeight <= clientHeight) return;
|
|
3822
|
+
e.preventDefault();
|
|
3823
|
+
e.stopPropagation();
|
|
3824
|
+
list.scrollTop = Math.max(0, Math.min(scrollTop + e.deltaY, scrollHeight - clientHeight));
|
|
3825
|
+
};
|
|
3826
|
+
document.addEventListener("wheel", handleWheel, { passive: false, capture: true });
|
|
3827
|
+
removeHandler = () => document.removeEventListener("wheel", handleWheel, { capture: true });
|
|
3828
|
+
});
|
|
3829
|
+
return () => {
|
|
3830
|
+
cancelled = true;
|
|
3831
|
+
removeHandler?.();
|
|
3832
|
+
};
|
|
3833
|
+
}, [open]);
|
|
3834
|
+
const side = dropdownPosition === "top" ? "top" : "bottom";
|
|
3835
|
+
const avoidCollisions = dropdownPosition === "auto";
|
|
3836
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
3550
3837
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
3551
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3838
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3552
3839
|
"button",
|
|
3553
3840
|
{
|
|
3554
3841
|
type: "button",
|
|
@@ -3574,30 +3861,36 @@ function CardSelect({
|
|
|
3574
3861
|
"label",
|
|
3575
3862
|
{
|
|
3576
3863
|
className: cn(
|
|
3577
|
-
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1
|
|
3864
|
+
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 inline-flex items-center gap-1",
|
|
3865
|
+
tooltip ? "pointer-events-auto" : "pointer-events-none",
|
|
3578
3866
|
error ? "text-red-500" : "text-foreground"
|
|
3579
3867
|
),
|
|
3580
3868
|
children: [
|
|
3581
3869
|
label,
|
|
3582
|
-
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3870
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" }),
|
|
3871
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(FieldTooltipIcon, { tooltip })
|
|
3583
3872
|
]
|
|
3584
3873
|
}
|
|
3585
3874
|
)
|
|
3586
3875
|
] }),
|
|
3587
3876
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3588
|
-
|
|
3877
|
+
PopoverContent,
|
|
3589
3878
|
{
|
|
3879
|
+
ref: contentRef,
|
|
3880
|
+
side,
|
|
3590
3881
|
align: "start",
|
|
3591
3882
|
sideOffset: 4,
|
|
3592
|
-
|
|
3593
|
-
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3883
|
+
avoidCollisions,
|
|
3884
|
+
collisionPadding: 16,
|
|
3885
|
+
className: "p-0 overflow-hidden flex flex-col",
|
|
3886
|
+
style: {
|
|
3887
|
+
width: "var(--radix-popover-trigger-width)",
|
|
3888
|
+
maxHeight: "min(340px, var(--radix-popover-content-available-height, 340px))"
|
|
3889
|
+
},
|
|
3597
3890
|
onOpenAutoFocus: (e) => {
|
|
3598
3891
|
e.preventDefault();
|
|
3599
3892
|
if (searchable) {
|
|
3600
|
-
searchRef.current?.focus();
|
|
3893
|
+
setTimeout(() => searchRef.current?.focus(), 0);
|
|
3601
3894
|
}
|
|
3602
3895
|
},
|
|
3603
3896
|
children: [
|
|
@@ -3619,10 +3912,9 @@ function CardSelect({
|
|
|
3619
3912
|
"div",
|
|
3620
3913
|
{
|
|
3621
3914
|
ref: listRef,
|
|
3622
|
-
className: "overflow-y-auto overscroll-contain",
|
|
3623
|
-
style: { maxHeight: "min(300px, var(--radix-popover-content-available-height, 300px))" },
|
|
3915
|
+
className: "overflow-y-auto overscroll-contain min-h-0 flex-1",
|
|
3624
3916
|
onScroll: handleScroll,
|
|
3625
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
3917
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-1", children: [
|
|
3626
3918
|
filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
|
|
3627
3919
|
const isSelected = value === option.value;
|
|
3628
3920
|
const isDisabled = option.disabled || disabled;
|
|
@@ -3633,21 +3925,361 @@ function CardSelect({
|
|
|
3633
3925
|
disabled: isDisabled,
|
|
3634
3926
|
onClick: () => {
|
|
3635
3927
|
onChange(option.value);
|
|
3636
|
-
|
|
3928
|
+
setOpen(false);
|
|
3637
3929
|
},
|
|
3638
3930
|
className: cn(
|
|
3639
|
-
"flex w-full items-center gap-
|
|
3640
|
-
"cursor-pointer hover:bg-accent",
|
|
3641
|
-
isSelected && "bg-
|
|
3642
|
-
isDisabled && "
|
|
3931
|
+
"flex w-full items-center gap-2 rounded-sm px-2 text-left text-sm outline-none",
|
|
3932
|
+
"cursor-pointer hover:bg-accent hover:text-accent-foreground",
|
|
3933
|
+
isSelected && "bg-accent/50",
|
|
3934
|
+
isDisabled && "pointer-events-none opacity-50",
|
|
3935
|
+
option.description ? "py-2" : "py-1.5"
|
|
3936
|
+
),
|
|
3937
|
+
children: [
|
|
3938
|
+
option.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-3 w-3 text-primary" }) }),
|
|
3939
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3940
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "block leading-tight", children: option.label }),
|
|
3941
|
+
option.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs leading-tight text-muted-foreground", children: option.description })
|
|
3942
|
+
] }),
|
|
3943
|
+
isSelected && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 shrink-0 text-primary" })
|
|
3944
|
+
]
|
|
3945
|
+
},
|
|
3946
|
+
option.value
|
|
3947
|
+
);
|
|
3948
|
+
}),
|
|
3949
|
+
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" }) })
|
|
3950
|
+
] })
|
|
3951
|
+
}
|
|
3952
|
+
)
|
|
3953
|
+
]
|
|
3954
|
+
}
|
|
3955
|
+
)
|
|
3956
|
+
] });
|
|
3957
|
+
}
|
|
3958
|
+
function FormMultiSelect({
|
|
3959
|
+
name,
|
|
3960
|
+
label,
|
|
3961
|
+
description,
|
|
3962
|
+
tooltip,
|
|
3963
|
+
required,
|
|
3964
|
+
disabled,
|
|
3965
|
+
className,
|
|
3966
|
+
options,
|
|
3967
|
+
placeholder = "Selecione...",
|
|
3968
|
+
hideError = false,
|
|
3969
|
+
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
3970
|
+
loading = false,
|
|
3971
|
+
searchable = false,
|
|
3972
|
+
searchPlaceholder = "Buscar...",
|
|
3973
|
+
clearable = true,
|
|
3974
|
+
maxVisibleChips = 3,
|
|
3975
|
+
dropdownPosition = "bottom"
|
|
3976
|
+
}) {
|
|
3977
|
+
const form = reactHookForm.useFormContext();
|
|
3978
|
+
const fieldState = form.getFieldState(name, form.formState);
|
|
3979
|
+
const error = fieldState.error?.message;
|
|
3980
|
+
return /* @__PURE__ */ jsxRuntime.jsx(FormFieldProvider, { name, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3981
|
+
reactHookForm.Controller,
|
|
3982
|
+
{
|
|
3983
|
+
control: form.control,
|
|
3984
|
+
name,
|
|
3985
|
+
render: ({ field }) => {
|
|
3986
|
+
const values = Array.isArray(field.value) ? field.value : [];
|
|
3987
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-1", className), children: [
|
|
3988
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3989
|
+
MultiSelectDropdown,
|
|
3990
|
+
{
|
|
3991
|
+
options,
|
|
3992
|
+
value: values,
|
|
3993
|
+
onChange: (v) => field.onChange(v),
|
|
3994
|
+
disabled,
|
|
3995
|
+
label,
|
|
3996
|
+
tooltip,
|
|
3997
|
+
required,
|
|
3998
|
+
error: !!error,
|
|
3999
|
+
placeholder,
|
|
4000
|
+
searchable,
|
|
4001
|
+
loading,
|
|
4002
|
+
emptyText,
|
|
4003
|
+
searchPlaceholder,
|
|
4004
|
+
clearable,
|
|
4005
|
+
maxVisibleChips,
|
|
4006
|
+
dropdownPosition
|
|
4007
|
+
}
|
|
4008
|
+
),
|
|
4009
|
+
description && !error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-muted-foreground px-1", children: description }),
|
|
4010
|
+
!hideError && error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500 px-1", children: error })
|
|
4011
|
+
] });
|
|
4012
|
+
}
|
|
4013
|
+
}
|
|
4014
|
+
) });
|
|
4015
|
+
}
|
|
4016
|
+
FormMultiSelect.displayName = "Form.MultiSelect";
|
|
4017
|
+
function MultiSelectDropdown({
|
|
4018
|
+
options,
|
|
4019
|
+
value,
|
|
4020
|
+
onChange,
|
|
4021
|
+
disabled,
|
|
4022
|
+
label,
|
|
4023
|
+
tooltip,
|
|
4024
|
+
required,
|
|
4025
|
+
error,
|
|
4026
|
+
placeholder = "Selecione...",
|
|
4027
|
+
searchable,
|
|
4028
|
+
loading,
|
|
4029
|
+
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
4030
|
+
searchPlaceholder = "Buscar...",
|
|
4031
|
+
clearable = true,
|
|
4032
|
+
maxVisibleChips = 3,
|
|
4033
|
+
dropdownPosition = "bottom"
|
|
4034
|
+
}) {
|
|
4035
|
+
const [open, setOpen] = React10__namespace.useState(false);
|
|
4036
|
+
const [search, setSearch] = React10__namespace.useState("");
|
|
4037
|
+
const [computedMax, setComputedMax] = React10__namespace.useState(maxVisibleChips);
|
|
4038
|
+
const [prevValueKey, setPrevValueKey] = React10__namespace.useState(() => value.join(","));
|
|
4039
|
+
const contentRef = React10__namespace.useRef(null);
|
|
4040
|
+
const listRef = React10__namespace.useRef(null);
|
|
4041
|
+
const searchRef = React10__namespace.useRef(null);
|
|
4042
|
+
const chipsRef = React10__namespace.useRef(null);
|
|
4043
|
+
const selectedOptions = React10__namespace.useMemo(
|
|
4044
|
+
() => options.filter((o) => value.includes(o.value)),
|
|
4045
|
+
[options, value]
|
|
4046
|
+
);
|
|
4047
|
+
const valueKey = value.join(",");
|
|
4048
|
+
if (valueKey !== prevValueKey) {
|
|
4049
|
+
setPrevValueKey(valueKey);
|
|
4050
|
+
setComputedMax(maxVisibleChips);
|
|
4051
|
+
}
|
|
4052
|
+
React10__namespace.useLayoutEffect(() => {
|
|
4053
|
+
const container = chipsRef.current;
|
|
4054
|
+
if (!container || selectedOptions.length === 0) return;
|
|
4055
|
+
const containerRect = container.getBoundingClientRect();
|
|
4056
|
+
const containerWidth = containerRect.width;
|
|
4057
|
+
const chips = container.querySelectorAll("[data-chip]");
|
|
4058
|
+
if (chips.length === 0 || containerWidth === 0) return;
|
|
4059
|
+
const gap = 4;
|
|
4060
|
+
const buffer = 4;
|
|
4061
|
+
const badge = container.querySelector("[data-badge]");
|
|
4062
|
+
const badgeWidth = badge ? badge.getBoundingClientRect().width : 28;
|
|
4063
|
+
const availableWidth = containerWidth - buffer;
|
|
4064
|
+
let usedWidth = 0;
|
|
4065
|
+
let fits = 0;
|
|
4066
|
+
for (let i = 0; i < chips.length; i++) {
|
|
4067
|
+
const chipWidth = chips[i].getBoundingClientRect().width;
|
|
4068
|
+
const widthWithGap = fits > 0 ? chipWidth + gap : chipWidth;
|
|
4069
|
+
const remaining = selectedOptions.length - (fits + 1);
|
|
4070
|
+
const needsBadge = remaining > 0;
|
|
4071
|
+
const badgeSpace = needsBadge ? badgeWidth + gap : 0;
|
|
4072
|
+
if (usedWidth + widthWithGap + badgeSpace > availableWidth && fits > 0) {
|
|
4073
|
+
break;
|
|
4074
|
+
}
|
|
4075
|
+
usedWidth += widthWithGap;
|
|
4076
|
+
fits++;
|
|
4077
|
+
}
|
|
4078
|
+
const newMax = Math.max(1, fits);
|
|
4079
|
+
if (newMax !== computedMax) {
|
|
4080
|
+
setComputedMax(newMax);
|
|
4081
|
+
}
|
|
4082
|
+
});
|
|
4083
|
+
const filteredOptions = React10__namespace.useMemo(() => {
|
|
4084
|
+
if (!searchable || !search) return options;
|
|
4085
|
+
const q = search.toLowerCase();
|
|
4086
|
+
return options.filter(
|
|
4087
|
+
(o) => o.label.toLowerCase().includes(q) || o.description?.toLowerCase().includes(q)
|
|
4088
|
+
);
|
|
4089
|
+
}, [options, search, searchable]);
|
|
4090
|
+
const toggleOption = React10__namespace.useCallback(
|
|
4091
|
+
(optionValue) => {
|
|
4092
|
+
if (value.includes(optionValue)) {
|
|
4093
|
+
onChange(value.filter((v) => v !== optionValue));
|
|
4094
|
+
} else {
|
|
4095
|
+
onChange([...value, optionValue]);
|
|
4096
|
+
}
|
|
4097
|
+
},
|
|
4098
|
+
[value, onChange]
|
|
4099
|
+
);
|
|
4100
|
+
const handleClearAll = React10__namespace.useCallback(
|
|
4101
|
+
(e) => {
|
|
4102
|
+
e.stopPropagation();
|
|
4103
|
+
onChange([]);
|
|
4104
|
+
},
|
|
4105
|
+
[onChange]
|
|
4106
|
+
);
|
|
4107
|
+
const handleRemoveChip = React10__namespace.useCallback(
|
|
4108
|
+
(e, optionValue) => {
|
|
4109
|
+
e.stopPropagation();
|
|
4110
|
+
onChange(value.filter((v) => v !== optionValue));
|
|
4111
|
+
},
|
|
4112
|
+
[value, onChange]
|
|
4113
|
+
);
|
|
4114
|
+
const handleOpenChange = React10__namespace.useCallback((nextOpen) => {
|
|
4115
|
+
setOpen(nextOpen);
|
|
4116
|
+
if (!nextOpen) {
|
|
4117
|
+
setSearch("");
|
|
4118
|
+
}
|
|
4119
|
+
}, []);
|
|
4120
|
+
React10__namespace.useEffect(() => {
|
|
4121
|
+
if (!open) return;
|
|
4122
|
+
let cancelled = false;
|
|
4123
|
+
let removeHandler;
|
|
4124
|
+
requestAnimationFrame(() => {
|
|
4125
|
+
if (cancelled) return;
|
|
4126
|
+
const content = contentRef.current;
|
|
4127
|
+
const list = listRef.current;
|
|
4128
|
+
if (!content || !list) return;
|
|
4129
|
+
const handleWheel = (e) => {
|
|
4130
|
+
if (!content.contains(e.target)) return;
|
|
4131
|
+
const { scrollTop, scrollHeight, clientHeight } = list;
|
|
4132
|
+
if (scrollHeight <= clientHeight) return;
|
|
4133
|
+
e.preventDefault();
|
|
4134
|
+
e.stopPropagation();
|
|
4135
|
+
list.scrollTop = Math.max(0, Math.min(scrollTop + e.deltaY, scrollHeight - clientHeight));
|
|
4136
|
+
};
|
|
4137
|
+
document.addEventListener("wheel", handleWheel, { passive: false, capture: true });
|
|
4138
|
+
removeHandler = () => document.removeEventListener("wheel", handleWheel, { capture: true });
|
|
4139
|
+
});
|
|
4140
|
+
return () => {
|
|
4141
|
+
cancelled = true;
|
|
4142
|
+
removeHandler?.();
|
|
4143
|
+
};
|
|
4144
|
+
}, [open]);
|
|
4145
|
+
const side = dropdownPosition === "top" ? "top" : "bottom";
|
|
4146
|
+
const avoidCollisions = dropdownPosition === "auto";
|
|
4147
|
+
const visibleChips = selectedOptions.slice(0, computedMax);
|
|
4148
|
+
const overflowCount = selectedOptions.length - computedMax;
|
|
4149
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: handleOpenChange, children: [
|
|
4150
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
4151
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4152
|
+
"button",
|
|
4153
|
+
{
|
|
4154
|
+
type: "button",
|
|
4155
|
+
disabled,
|
|
4156
|
+
className: cn(
|
|
4157
|
+
"flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
|
|
4158
|
+
"focus:outline-none focus:border-primary",
|
|
4159
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
4160
|
+
label ? "min-h-[3rem] pt-4 pb-1.5" : "min-h-[2.25rem] py-1.5",
|
|
4161
|
+
error ? "border-red-500" : "border-border",
|
|
4162
|
+
open && !error && "border-primary"
|
|
4163
|
+
),
|
|
4164
|
+
children: [
|
|
4165
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { ref: chipsRef, className: "flex gap-1 items-center flex-1 overflow-hidden", children: selectedOptions.length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
4166
|
+
visibleChips.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4167
|
+
"span",
|
|
4168
|
+
{
|
|
4169
|
+
"data-chip": true,
|
|
4170
|
+
className: "inline-flex items-center gap-1 max-w-[150px] shrink-0 rounded-sm bg-primary/10 px-1.5 py-0.5 text-xs font-medium text-primary",
|
|
4171
|
+
children: [
|
|
4172
|
+
option.icon && /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-3 w-3 shrink-0" }),
|
|
4173
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: option.label }),
|
|
4174
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4175
|
+
lucideReact.X,
|
|
4176
|
+
{
|
|
4177
|
+
className: "h-3 w-3 shrink-0 cursor-pointer hover:text-destructive",
|
|
4178
|
+
onClick: (e) => handleRemoveChip(e, option.value)
|
|
4179
|
+
}
|
|
4180
|
+
)
|
|
4181
|
+
]
|
|
4182
|
+
},
|
|
4183
|
+
option.value
|
|
4184
|
+
)),
|
|
4185
|
+
overflowCount > 0 && /* @__PURE__ */ jsxRuntime.jsxs("span", { "data-badge": true, className: "inline-flex items-center justify-center h-5 min-w-5 px-1.5 shrink-0 rounded-full bg-gray-100 text-gray-500 text-[10px] font-medium", children: [
|
|
4186
|
+
"+",
|
|
4187
|
+
overflowCount
|
|
4188
|
+
] })
|
|
4189
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: placeholder }) }),
|
|
4190
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-1 ml-1 shrink-0", children: [
|
|
4191
|
+
clearable && selectedOptions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4192
|
+
lucideReact.X,
|
|
4193
|
+
{
|
|
4194
|
+
className: "h-4 w-4 text-muted-foreground hover:text-foreground cursor-pointer",
|
|
4195
|
+
onClick: handleClearAll
|
|
4196
|
+
}
|
|
4197
|
+
),
|
|
4198
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: cn("h-4 w-4 opacity-50 transition-transform", open && "rotate-180") })
|
|
4199
|
+
] })
|
|
4200
|
+
]
|
|
4201
|
+
}
|
|
4202
|
+
) }),
|
|
4203
|
+
label && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4204
|
+
"label",
|
|
4205
|
+
{
|
|
4206
|
+
className: cn(
|
|
4207
|
+
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 inline-flex items-center gap-1",
|
|
4208
|
+
tooltip ? "pointer-events-auto" : "pointer-events-none",
|
|
4209
|
+
error ? "text-red-500" : "text-foreground"
|
|
4210
|
+
),
|
|
4211
|
+
children: [
|
|
4212
|
+
label,
|
|
4213
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" }),
|
|
4214
|
+
tooltip && /* @__PURE__ */ jsxRuntime.jsx(FieldTooltipIcon, { tooltip })
|
|
4215
|
+
]
|
|
4216
|
+
}
|
|
4217
|
+
)
|
|
4218
|
+
] }),
|
|
4219
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
4220
|
+
PopoverContent,
|
|
4221
|
+
{
|
|
4222
|
+
ref: contentRef,
|
|
4223
|
+
side,
|
|
4224
|
+
align: "start",
|
|
4225
|
+
sideOffset: 4,
|
|
4226
|
+
avoidCollisions,
|
|
4227
|
+
collisionPadding: 16,
|
|
4228
|
+
className: "p-0 overflow-hidden flex flex-col",
|
|
4229
|
+
style: {
|
|
4230
|
+
width: "var(--radix-popover-trigger-width)",
|
|
4231
|
+
maxHeight: "min(340px, var(--radix-popover-content-available-height, 340px))"
|
|
4232
|
+
},
|
|
4233
|
+
onOpenAutoFocus: (e) => {
|
|
4234
|
+
e.preventDefault();
|
|
4235
|
+
if (searchable) {
|
|
4236
|
+
setTimeout(() => searchRef.current?.focus(), 0);
|
|
4237
|
+
}
|
|
4238
|
+
},
|
|
4239
|
+
children: [
|
|
4240
|
+
searchable && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 px-3 py-2 border-b border-border", children: [
|
|
4241
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Search, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
4242
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4243
|
+
"input",
|
|
4244
|
+
{
|
|
4245
|
+
ref: searchRef,
|
|
4246
|
+
type: "text",
|
|
4247
|
+
value: search,
|
|
4248
|
+
onChange: (e) => setSearch(e.target.value),
|
|
4249
|
+
placeholder: searchPlaceholder,
|
|
4250
|
+
className: "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground"
|
|
4251
|
+
}
|
|
4252
|
+
)
|
|
4253
|
+
] }),
|
|
4254
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
4255
|
+
"div",
|
|
4256
|
+
{
|
|
4257
|
+
ref: listRef,
|
|
4258
|
+
className: "overflow-y-auto overscroll-contain min-h-0 flex-1",
|
|
4259
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-1", children: [
|
|
4260
|
+
filteredOptions.length === 0 && !loading ? /* @__PURE__ */ jsxRuntime.jsx("p", { className: "py-4 text-center text-sm text-muted-foreground", children: emptyText }) : filteredOptions.map((option) => {
|
|
4261
|
+
const isSelected = value.includes(option.value);
|
|
4262
|
+
const isDisabled = option.disabled || disabled;
|
|
4263
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4264
|
+
"button",
|
|
4265
|
+
{
|
|
4266
|
+
type: "button",
|
|
4267
|
+
disabled: isDisabled,
|
|
4268
|
+
onClick: () => toggleOption(option.value),
|
|
4269
|
+
className: cn(
|
|
4270
|
+
"flex w-full items-center gap-2 rounded-sm px-2 text-left text-sm outline-none",
|
|
4271
|
+
"cursor-pointer hover:bg-accent hover:text-accent-foreground",
|
|
4272
|
+
isSelected && "bg-accent/50",
|
|
4273
|
+
isDisabled && "pointer-events-none opacity-50",
|
|
4274
|
+
option.description ? "py-2" : "py-1.5"
|
|
3643
4275
|
),
|
|
3644
4276
|
children: [
|
|
3645
|
-
option.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-
|
|
4277
|
+
option.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-3 w-3 text-primary" }) }),
|
|
3646
4278
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3647
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
3648
|
-
option.description && /* @__PURE__ */ jsxRuntime.jsx("
|
|
4279
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "block leading-tight", children: option.label }),
|
|
4280
|
+
option.description && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "block text-xs leading-tight text-muted-foreground", children: option.description })
|
|
3649
4281
|
] }),
|
|
3650
|
-
isSelected && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4282
|
+
isSelected && /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-4 w-4 shrink-0 text-primary" })
|
|
3651
4283
|
]
|
|
3652
4284
|
},
|
|
3653
4285
|
option.value
|
|
@@ -3951,82 +4583,16 @@ function FormRadioGroup({
|
|
|
3951
4583
|
]
|
|
3952
4584
|
},
|
|
3953
4585
|
option.value
|
|
3954
|
-
);
|
|
3955
|
-
})
|
|
3956
|
-
}
|
|
3957
|
-
),
|
|
3958
|
-
!hideError && error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
3959
|
-
] })
|
|
3960
|
-
}
|
|
3961
|
-
) });
|
|
3962
|
-
}
|
|
3963
|
-
FormRadioGroup.displayName = "Form.RadioGroup";
|
|
3964
|
-
var FormLabel = React10__namespace.forwardRef(
|
|
3965
|
-
({ className, required, children, ...props }, ref) => {
|
|
3966
|
-
const fieldContext = useFormFieldContextOptional();
|
|
3967
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3968
|
-
"label",
|
|
3969
|
-
{
|
|
3970
|
-
ref,
|
|
3971
|
-
htmlFor: fieldContext?.id,
|
|
3972
|
-
className: cn(
|
|
3973
|
-
"text-sm font-medium leading-none",
|
|
3974
|
-
fieldContext?.error && "text-red-500",
|
|
3975
|
-
className
|
|
4586
|
+
);
|
|
4587
|
+
})
|
|
4588
|
+
}
|
|
3976
4589
|
),
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
children,
|
|
3980
|
-
(required || fieldContext?.isRequired) && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3981
|
-
]
|
|
3982
|
-
}
|
|
3983
|
-
);
|
|
3984
|
-
}
|
|
3985
|
-
);
|
|
3986
|
-
FormLabel.displayName = "Form.Label";
|
|
3987
|
-
var FormDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
3988
|
-
const fieldContext = useFormFieldContextOptional();
|
|
3989
|
-
if (fieldContext?.error) {
|
|
3990
|
-
return null;
|
|
3991
|
-
}
|
|
3992
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
3993
|
-
"p",
|
|
3994
|
-
{
|
|
3995
|
-
ref,
|
|
3996
|
-
className: cn("text-xs text-muted-foreground", className),
|
|
3997
|
-
...props
|
|
3998
|
-
}
|
|
3999
|
-
);
|
|
4000
|
-
});
|
|
4001
|
-
FormDescription.displayName = "Form.Description";
|
|
4002
|
-
var FormError = React10__namespace.forwardRef(
|
|
4003
|
-
({ className, message, children, ...props }, ref) => {
|
|
4004
|
-
const fieldContext = useFormFieldContextOptional();
|
|
4005
|
-
const errorMessage = message ?? fieldContext?.error;
|
|
4006
|
-
if (!errorMessage && !children) {
|
|
4007
|
-
return null;
|
|
4590
|
+
!hideError && error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-xs text-red-500", children: error })
|
|
4591
|
+
] })
|
|
4008
4592
|
}
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
ref,
|
|
4013
|
-
className: cn("text-xs text-red-500", className),
|
|
4014
|
-
...props,
|
|
4015
|
-
children: children || errorMessage
|
|
4016
|
-
}
|
|
4017
|
-
);
|
|
4018
|
-
}
|
|
4019
|
-
);
|
|
4020
|
-
FormError.displayName = "Form.Error";
|
|
4021
|
-
var FormFieldWrapper = React10__namespace.forwardRef(({ className, label, description, required, error, children, ...props }, ref) => {
|
|
4022
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: cn("space-y-1", className), ...props, children: [
|
|
4023
|
-
label && /* @__PURE__ */ jsxRuntime.jsx(FormLabel, { required, children: label }),
|
|
4024
|
-
children,
|
|
4025
|
-
description && /* @__PURE__ */ jsxRuntime.jsx(FormDescription, { children: description }),
|
|
4026
|
-
error && /* @__PURE__ */ jsxRuntime.jsx(FormError, { message: error })
|
|
4027
|
-
] });
|
|
4028
|
-
});
|
|
4029
|
-
FormFieldWrapper.displayName = "Form.FieldWrapper";
|
|
4593
|
+
) });
|
|
4594
|
+
}
|
|
4595
|
+
FormRadioGroup.displayName = "Form.RadioGroup";
|
|
4030
4596
|
function FormRoot({
|
|
4031
4597
|
form,
|
|
4032
4598
|
onSubmit,
|
|
@@ -4050,6 +4616,7 @@ var Form = Object.assign(FormRoot, {
|
|
|
4050
4616
|
// Campos com auto-bind
|
|
4051
4617
|
Input: FormInput,
|
|
4052
4618
|
Select: FormSelect,
|
|
4619
|
+
MultiSelect: FormMultiSelect,
|
|
4053
4620
|
Textarea: FormTextarea,
|
|
4054
4621
|
Checkbox: FormCheckbox,
|
|
4055
4622
|
Switch: FormSwitch,
|
|
@@ -4223,207 +4790,6 @@ var DropdownMenuShortcut = ({
|
|
|
4223
4790
|
);
|
|
4224
4791
|
};
|
|
4225
4792
|
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,
|
|
4230
|
-
{
|
|
4231
|
-
ref,
|
|
4232
|
-
align,
|
|
4233
|
-
sideOffset,
|
|
4234
|
-
className: cn(
|
|
4235
|
-
"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",
|
|
4236
|
-
className
|
|
4237
|
-
),
|
|
4238
|
-
...props
|
|
4239
|
-
}
|
|
4240
|
-
) }));
|
|
4241
|
-
PopoverContent.displayName = PopoverPrimitive2__namespace.Content.displayName;
|
|
4242
|
-
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
4243
|
-
var TooltipRoot = TooltipPrimitive__namespace.Root;
|
|
4244
|
-
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|
|
4245
|
-
var TooltipPortal = TooltipPrimitive__namespace.Portal;
|
|
4246
|
-
var TooltipArrow = React10__namespace.forwardRef(({ className, variant = "light", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4247
|
-
TooltipPrimitive__namespace.Arrow,
|
|
4248
|
-
{
|
|
4249
|
-
ref,
|
|
4250
|
-
className: cn(
|
|
4251
|
-
"z-50",
|
|
4252
|
-
variant === "dark" ? "fill-popover" : "fill-background",
|
|
4253
|
-
className
|
|
4254
|
-
),
|
|
4255
|
-
...props
|
|
4256
|
-
}
|
|
4257
|
-
));
|
|
4258
|
-
TooltipArrow.displayName = "TooltipArrow";
|
|
4259
|
-
var tooltipContentVariants = classVarianceAuthority.cva(
|
|
4260
|
-
"z-50 overflow-hidden rounded-lg shadow-lg outline-none animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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",
|
|
4261
|
-
{
|
|
4262
|
-
variants: {
|
|
4263
|
-
variant: {
|
|
4264
|
-
light: "bg-background text-foreground border border-border",
|
|
4265
|
-
dark: "bg-popover text-popover-foreground border border-border"
|
|
4266
|
-
},
|
|
4267
|
-
size: {
|
|
4268
|
-
sm: "max-w-[200px] p-2",
|
|
4269
|
-
md: "max-w-[280px] p-3",
|
|
4270
|
-
lg: "max-w-[360px] p-4"
|
|
4271
|
-
}
|
|
4272
|
-
},
|
|
4273
|
-
defaultVariants: {
|
|
4274
|
-
variant: "light",
|
|
4275
|
-
size: "md"
|
|
4276
|
-
}
|
|
4277
|
-
}
|
|
4278
|
-
);
|
|
4279
|
-
var TooltipContent = React10__namespace.forwardRef(
|
|
4280
|
-
({
|
|
4281
|
-
className,
|
|
4282
|
-
variant = "light",
|
|
4283
|
-
size = "md",
|
|
4284
|
-
sideOffset = 8,
|
|
4285
|
-
showArrow = true,
|
|
4286
|
-
onDismiss,
|
|
4287
|
-
children,
|
|
4288
|
-
...props
|
|
4289
|
-
}, ref) => /* @__PURE__ */ jsxRuntime.jsx(TooltipPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4290
|
-
TooltipPrimitive__namespace.Content,
|
|
4291
|
-
{
|
|
4292
|
-
ref,
|
|
4293
|
-
sideOffset,
|
|
4294
|
-
className: cn(tooltipContentVariants({ variant, size }), className),
|
|
4295
|
-
...props,
|
|
4296
|
-
children: [
|
|
4297
|
-
onDismiss && /* @__PURE__ */ jsxRuntime.jsx(
|
|
4298
|
-
"button",
|
|
4299
|
-
{
|
|
4300
|
-
onClick: onDismiss,
|
|
4301
|
-
className: "absolute top-2 right-2 p-1 rounded-full transition-colors hover:bg-muted text-muted-foreground hover:text-foreground",
|
|
4302
|
-
"aria-label": "Fechar",
|
|
4303
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-3.5 w-3.5" })
|
|
4304
|
-
}
|
|
4305
|
-
),
|
|
4306
|
-
children,
|
|
4307
|
-
showArrow && /* @__PURE__ */ jsxRuntime.jsx(TooltipArrow, { variant: variant ?? "light", width: 12, height: 6 })
|
|
4308
|
-
]
|
|
4309
|
-
}
|
|
4310
|
-
) })
|
|
4311
|
-
);
|
|
4312
|
-
TooltipContent.displayName = TooltipPrimitive__namespace.Content.displayName;
|
|
4313
|
-
var TooltipHeader = React10__namespace.forwardRef(
|
|
4314
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("flex flex-col gap-1", className), ...props })
|
|
4315
|
-
);
|
|
4316
|
-
TooltipHeader.displayName = "TooltipHeader";
|
|
4317
|
-
var TooltipTitle = React10__namespace.forwardRef(
|
|
4318
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4319
|
-
"h4",
|
|
4320
|
-
{
|
|
4321
|
-
ref,
|
|
4322
|
-
className: cn("text-sm font-semibold leading-tight", className),
|
|
4323
|
-
...props
|
|
4324
|
-
}
|
|
4325
|
-
)
|
|
4326
|
-
);
|
|
4327
|
-
TooltipTitle.displayName = "TooltipTitle";
|
|
4328
|
-
var TooltipDescription = React10__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4329
|
-
"p",
|
|
4330
|
-
{
|
|
4331
|
-
ref,
|
|
4332
|
-
className: cn("text-xs leading-relaxed text-muted-foreground", className),
|
|
4333
|
-
...props
|
|
4334
|
-
}
|
|
4335
|
-
));
|
|
4336
|
-
TooltipDescription.displayName = "TooltipDescription";
|
|
4337
|
-
var TooltipActions = React10__namespace.forwardRef(
|
|
4338
|
-
({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4339
|
-
"div",
|
|
4340
|
-
{
|
|
4341
|
-
ref,
|
|
4342
|
-
className: cn("flex items-center gap-2 mt-3", className),
|
|
4343
|
-
...props
|
|
4344
|
-
}
|
|
4345
|
-
)
|
|
4346
|
-
);
|
|
4347
|
-
TooltipActions.displayName = "TooltipActions";
|
|
4348
|
-
var tooltipActionVariants = classVarianceAuthority.cva(
|
|
4349
|
-
"inline-flex items-center justify-center text-xs font-medium rounded-md transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",
|
|
4350
|
-
{
|
|
4351
|
-
variants: {
|
|
4352
|
-
variant: {
|
|
4353
|
-
primary: "bg-primary text-primary-foreground hover:bg-primary/90 px-3 py-1.5",
|
|
4354
|
-
secondary: "bg-transparent text-muted-foreground hover:text-foreground hover:underline px-2 py-1.5",
|
|
4355
|
-
outline: "border border-border bg-background text-foreground hover:bg-muted px-3 py-1.5"
|
|
4356
|
-
}
|
|
4357
|
-
},
|
|
4358
|
-
defaultVariants: {
|
|
4359
|
-
variant: "primary"
|
|
4360
|
-
}
|
|
4361
|
-
}
|
|
4362
|
-
);
|
|
4363
|
-
var TooltipAction = React10__namespace.forwardRef(
|
|
4364
|
-
({ className, variant = "primary", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4365
|
-
"button",
|
|
4366
|
-
{
|
|
4367
|
-
ref,
|
|
4368
|
-
className: cn(tooltipActionVariants({ variant }), className),
|
|
4369
|
-
...props
|
|
4370
|
-
}
|
|
4371
|
-
)
|
|
4372
|
-
);
|
|
4373
|
-
TooltipAction.displayName = "TooltipAction";
|
|
4374
|
-
var TooltipIcon = React10__namespace.forwardRef(
|
|
4375
|
-
({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
4376
|
-
"div",
|
|
4377
|
-
{
|
|
4378
|
-
ref,
|
|
4379
|
-
className: cn(
|
|
4380
|
-
"flex items-center justify-center w-10 h-10 rounded-full mb-3 bg-muted",
|
|
4381
|
-
className
|
|
4382
|
-
),
|
|
4383
|
-
...props,
|
|
4384
|
-
children
|
|
4385
|
-
}
|
|
4386
|
-
)
|
|
4387
|
-
);
|
|
4388
|
-
TooltipIcon.displayName = "TooltipIcon";
|
|
4389
|
-
var SimpleTooltip = ({
|
|
4390
|
-
children,
|
|
4391
|
-
content,
|
|
4392
|
-
variant = "light",
|
|
4393
|
-
side = "top",
|
|
4394
|
-
align = "center",
|
|
4395
|
-
delayDuration = 200,
|
|
4396
|
-
open,
|
|
4397
|
-
defaultOpen,
|
|
4398
|
-
onOpenChange
|
|
4399
|
-
}) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4400
|
-
TooltipRoot,
|
|
4401
|
-
{
|
|
4402
|
-
open,
|
|
4403
|
-
defaultOpen,
|
|
4404
|
-
onOpenChange,
|
|
4405
|
-
delayDuration,
|
|
4406
|
-
children: [
|
|
4407
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipTrigger, { asChild: true, children }),
|
|
4408
|
-
/* @__PURE__ */ jsxRuntime.jsx(TooltipContent, { variant, side, align, size: "sm", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs", children: content }) })
|
|
4409
|
-
]
|
|
4410
|
-
}
|
|
4411
|
-
);
|
|
4412
|
-
SimpleTooltip.displayName = "SimpleTooltip";
|
|
4413
|
-
var Tooltip = Object.assign(TooltipRoot, {
|
|
4414
|
-
Provider: TooltipProvider,
|
|
4415
|
-
Trigger: TooltipTrigger,
|
|
4416
|
-
Portal: TooltipPortal,
|
|
4417
|
-
Content: TooltipContent,
|
|
4418
|
-
Arrow: TooltipArrow,
|
|
4419
|
-
Header: TooltipHeader,
|
|
4420
|
-
Title: TooltipTitle,
|
|
4421
|
-
Description: TooltipDescription,
|
|
4422
|
-
Actions: TooltipActions,
|
|
4423
|
-
Action: TooltipAction,
|
|
4424
|
-
Icon: TooltipIcon,
|
|
4425
|
-
Simple: SimpleTooltip
|
|
4426
|
-
});
|
|
4427
4793
|
var AuthLayoutContext = React10__namespace.createContext({
|
|
4428
4794
|
imagePosition: "left"
|
|
4429
4795
|
});
|