@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.d.mts
CHANGED
|
@@ -896,6 +896,8 @@ interface FormSelectProps<T extends FieldValues = FieldValues> extends BaseField
|
|
|
896
896
|
}>;
|
|
897
897
|
hideError?: boolean;
|
|
898
898
|
selectSize?: 'sm' | 'default' | 'lg';
|
|
899
|
+
/** Render as dropdown (default) or visual card grid */
|
|
900
|
+
variant?: 'default' | 'card';
|
|
899
901
|
}
|
|
900
902
|
interface FormTextareaProps<T extends FieldValues = FieldValues> extends BaseFieldProps<T>, Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, 'name'> {
|
|
901
903
|
hideError?: boolean;
|
|
@@ -927,7 +929,7 @@ declare namespace FormInput {
|
|
|
927
929
|
var displayName: string;
|
|
928
930
|
}
|
|
929
931
|
|
|
930
|
-
declare function FormSelect<T extends FieldValues = FieldValues>({ name, label, description, required, disabled, className, options, placeholder, icon, hideError, selectSize, emptyText, loading, }: FormSelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
932
|
+
declare function FormSelect<T extends FieldValues = FieldValues>({ name, label, description, required, disabled, className, options, placeholder, icon, hideError, selectSize, emptyText, loading, variant, }: FormSelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
931
933
|
declare namespace FormSelect {
|
|
932
934
|
var displayName: string;
|
|
933
935
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -896,6 +896,8 @@ interface FormSelectProps<T extends FieldValues = FieldValues> extends BaseField
|
|
|
896
896
|
}>;
|
|
897
897
|
hideError?: boolean;
|
|
898
898
|
selectSize?: 'sm' | 'default' | 'lg';
|
|
899
|
+
/** Render as dropdown (default) or visual card grid */
|
|
900
|
+
variant?: 'default' | 'card';
|
|
899
901
|
}
|
|
900
902
|
interface FormTextareaProps<T extends FieldValues = FieldValues> extends BaseFieldProps<T>, Omit<React$1.TextareaHTMLAttributes<HTMLTextAreaElement>, 'name'> {
|
|
901
903
|
hideError?: boolean;
|
|
@@ -927,7 +929,7 @@ declare namespace FormInput {
|
|
|
927
929
|
var displayName: string;
|
|
928
930
|
}
|
|
929
931
|
|
|
930
|
-
declare function FormSelect<T extends FieldValues = FieldValues>({ name, label, description, required, disabled, className, options, placeholder, icon, hideError, selectSize, emptyText, loading, }: FormSelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
932
|
+
declare function FormSelect<T extends FieldValues = FieldValues>({ name, label, description, required, disabled, className, options, placeholder, icon, hideError, selectSize, emptyText, loading, variant, }: FormSelectProps<T>): react_jsx_runtime.JSX.Element;
|
|
931
933
|
declare namespace FormSelect {
|
|
932
934
|
var displayName: string;
|
|
933
935
|
}
|
package/dist/index.js
CHANGED
|
@@ -16,10 +16,10 @@ 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 PopoverPrimitive = require('@radix-ui/react-popover');
|
|
19
20
|
var RadioGroupPrimitive = require('@radix-ui/react-radio-group');
|
|
20
21
|
var AvatarPrimitive = require('@radix-ui/react-avatar');
|
|
21
22
|
var DropdownMenuPrimitive = require('@radix-ui/react-dropdown-menu');
|
|
22
|
-
var PopoverPrimitive = require('@radix-ui/react-popover');
|
|
23
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');
|
|
@@ -50,10 +50,10 @@ 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 PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
53
54
|
var RadioGroupPrimitive__namespace = /*#__PURE__*/_interopNamespace(RadioGroupPrimitive);
|
|
54
55
|
var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
|
|
55
56
|
var DropdownMenuPrimitive__namespace = /*#__PURE__*/_interopNamespace(DropdownMenuPrimitive);
|
|
56
|
-
var PopoverPrimitive__namespace = /*#__PURE__*/_interopNamespace(PopoverPrimitive);
|
|
57
57
|
var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
|
|
58
58
|
var ScrollAreaPrimitive__namespace = /*#__PURE__*/_interopNamespace(ScrollAreaPrimitive);
|
|
59
59
|
var SeparatorPrimitive__namespace = /*#__PURE__*/_interopNamespace(SeparatorPrimitive);
|
|
@@ -3239,6 +3239,22 @@ function FormInput({
|
|
|
3239
3239
|
) });
|
|
3240
3240
|
}
|
|
3241
3241
|
FormInput.displayName = "Form.Input";
|
|
3242
|
+
var Popover = PopoverPrimitive__namespace.Root;
|
|
3243
|
+
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
3244
|
+
var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3245
|
+
PopoverPrimitive__namespace.Content,
|
|
3246
|
+
{
|
|
3247
|
+
ref,
|
|
3248
|
+
align,
|
|
3249
|
+
sideOffset,
|
|
3250
|
+
className: cn(
|
|
3251
|
+
"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",
|
|
3252
|
+
className
|
|
3253
|
+
),
|
|
3254
|
+
...props
|
|
3255
|
+
}
|
|
3256
|
+
) }));
|
|
3257
|
+
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
3242
3258
|
function FormSelect({
|
|
3243
3259
|
name,
|
|
3244
3260
|
label,
|
|
@@ -3252,7 +3268,8 @@ function FormSelect({
|
|
|
3252
3268
|
hideError = false,
|
|
3253
3269
|
selectSize = "default",
|
|
3254
3270
|
emptyText = "Nenhuma op\xE7\xE3o dispon\xEDvel",
|
|
3255
|
-
loading = false
|
|
3271
|
+
loading = false,
|
|
3272
|
+
variant = "default"
|
|
3256
3273
|
}) {
|
|
3257
3274
|
const form = reactHookForm.useFormContext();
|
|
3258
3275
|
const fieldState = form.getFieldState(name, form.formState);
|
|
@@ -3263,7 +3280,19 @@ function FormSelect({
|
|
|
3263
3280
|
control: form.control,
|
|
3264
3281
|
name,
|
|
3265
3282
|
render: ({ field }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: cn("space-y-1", className), children: [
|
|
3266
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3283
|
+
variant === "card" ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
3284
|
+
CardSelect,
|
|
3285
|
+
{
|
|
3286
|
+
options,
|
|
3287
|
+
value: field.value,
|
|
3288
|
+
onChange: (v) => field.onChange(v || void 0),
|
|
3289
|
+
disabled,
|
|
3290
|
+
label,
|
|
3291
|
+
required,
|
|
3292
|
+
error: !!error,
|
|
3293
|
+
placeholder
|
|
3294
|
+
}
|
|
3295
|
+
) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
3267
3296
|
Select,
|
|
3268
3297
|
{
|
|
3269
3298
|
value: field.value ?? "",
|
|
@@ -3301,6 +3330,98 @@ function FormSelect({
|
|
|
3301
3330
|
) });
|
|
3302
3331
|
}
|
|
3303
3332
|
FormSelect.displayName = "Form.Select";
|
|
3333
|
+
function CardSelect({
|
|
3334
|
+
options,
|
|
3335
|
+
value,
|
|
3336
|
+
onChange,
|
|
3337
|
+
disabled,
|
|
3338
|
+
label,
|
|
3339
|
+
required,
|
|
3340
|
+
error,
|
|
3341
|
+
placeholder = "Selecione..."
|
|
3342
|
+
}) {
|
|
3343
|
+
const [open, setOpen] = React10__namespace.useState(false);
|
|
3344
|
+
const selected = options.find((o) => o.value === value);
|
|
3345
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Popover, { open, onOpenChange: setOpen, children: [
|
|
3346
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "relative", children: [
|
|
3347
|
+
/* @__PURE__ */ jsxRuntime.jsx(PopoverTrigger, { asChild: true, disabled, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3348
|
+
"button",
|
|
3349
|
+
{
|
|
3350
|
+
type: "button",
|
|
3351
|
+
className: cn(
|
|
3352
|
+
"flex w-full items-center justify-between rounded-md border-2 bg-background px-3 text-sm transition-colors",
|
|
3353
|
+
"focus:outline-none focus:border-primary",
|
|
3354
|
+
"disabled:cursor-not-allowed disabled:opacity-50",
|
|
3355
|
+
label ? "h-12 pt-4 pb-2" : "h-9 py-2",
|
|
3356
|
+
error ? "border-red-500" : "border-border",
|
|
3357
|
+
open && !error && "border-primary"
|
|
3358
|
+
),
|
|
3359
|
+
children: [
|
|
3360
|
+
selected ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 truncate", children: [
|
|
3361
|
+
selected.icon && /* @__PURE__ */ jsxRuntime.jsx(selected.icon, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3362
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate", children: selected.label })
|
|
3363
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-muted-foreground", children: placeholder }),
|
|
3364
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.ChevronDown, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
3365
|
+
]
|
|
3366
|
+
}
|
|
3367
|
+
) }),
|
|
3368
|
+
label && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3369
|
+
"label",
|
|
3370
|
+
{
|
|
3371
|
+
className: cn(
|
|
3372
|
+
"absolute left-3 top-[-6px] text-xs font-medium bg-background px-1 pointer-events-none",
|
|
3373
|
+
error ? "text-red-500" : "text-foreground"
|
|
3374
|
+
),
|
|
3375
|
+
children: [
|
|
3376
|
+
label,
|
|
3377
|
+
required && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-red-500 ml-0.5", children: "*" })
|
|
3378
|
+
]
|
|
3379
|
+
}
|
|
3380
|
+
)
|
|
3381
|
+
] }),
|
|
3382
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3383
|
+
PopoverContent,
|
|
3384
|
+
{
|
|
3385
|
+
align: "start",
|
|
3386
|
+
className: "p-2 overflow-y-auto",
|
|
3387
|
+
style: {
|
|
3388
|
+
width: "var(--radix-popover-trigger-width)",
|
|
3389
|
+
maxHeight: "var(--radix-popover-content-available-height)"
|
|
3390
|
+
},
|
|
3391
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-border/50", children: options.map((option) => {
|
|
3392
|
+
const isSelected = value === option.value;
|
|
3393
|
+
const isDisabled = option.disabled || disabled;
|
|
3394
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3395
|
+
"button",
|
|
3396
|
+
{
|
|
3397
|
+
type: "button",
|
|
3398
|
+
disabled: isDisabled,
|
|
3399
|
+
onClick: () => {
|
|
3400
|
+
onChange(option.value);
|
|
3401
|
+
setOpen(false);
|
|
3402
|
+
},
|
|
3403
|
+
className: cn(
|
|
3404
|
+
"flex w-full items-center gap-3 p-3 text-left transition-all",
|
|
3405
|
+
"cursor-pointer hover:bg-accent",
|
|
3406
|
+
isSelected && "bg-primary/5",
|
|
3407
|
+
isDisabled && "cursor-not-allowed opacity-50 hover:bg-transparent"
|
|
3408
|
+
),
|
|
3409
|
+
children: [
|
|
3410
|
+
option.icon && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-primary/10", children: /* @__PURE__ */ jsxRuntime.jsx(option.icon, { className: "h-5 w-5 text-primary" }) }),
|
|
3411
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
3412
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-sm font-medium leading-tight", children: option.label }),
|
|
3413
|
+
option.description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-0.5 text-xs leading-tight text-muted-foreground", children: option.description })
|
|
3414
|
+
] }),
|
|
3415
|
+
isSelected && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-5 w-5 shrink-0 items-center justify-center rounded-full bg-primary text-primary-foreground", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Check, { className: "h-3 w-3" }) })
|
|
3416
|
+
]
|
|
3417
|
+
},
|
|
3418
|
+
option.value
|
|
3419
|
+
);
|
|
3420
|
+
}) })
|
|
3421
|
+
}
|
|
3422
|
+
)
|
|
3423
|
+
] });
|
|
3424
|
+
}
|
|
3304
3425
|
function FormTextarea({
|
|
3305
3426
|
name,
|
|
3306
3427
|
label,
|
|
@@ -3862,22 +3983,6 @@ var DropdownMenuShortcut = ({
|
|
|
3862
3983
|
);
|
|
3863
3984
|
};
|
|
3864
3985
|
DropdownMenuShortcut.displayName = "DropdownMenuShortcut";
|
|
3865
|
-
var Popover = PopoverPrimitive__namespace.Root;
|
|
3866
|
-
var PopoverTrigger = PopoverPrimitive__namespace.Trigger;
|
|
3867
|
-
var PopoverContent = React10__namespace.forwardRef(({ className, align = "center", sideOffset = 4, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(PopoverPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
3868
|
-
PopoverPrimitive__namespace.Content,
|
|
3869
|
-
{
|
|
3870
|
-
ref,
|
|
3871
|
-
align,
|
|
3872
|
-
sideOffset,
|
|
3873
|
-
className: cn(
|
|
3874
|
-
"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",
|
|
3875
|
-
className
|
|
3876
|
-
),
|
|
3877
|
-
...props
|
|
3878
|
-
}
|
|
3879
|
-
) }));
|
|
3880
|
-
PopoverContent.displayName = PopoverPrimitive__namespace.Content.displayName;
|
|
3881
3986
|
var TooltipProvider = TooltipPrimitive__namespace.Provider;
|
|
3882
3987
|
var TooltipRoot = TooltipPrimitive__namespace.Root;
|
|
3883
3988
|
var TooltipTrigger = TooltipPrimitive__namespace.Trigger;
|