@motor-hero/ui-kit 0.16.1 → 0.18.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/components/combobox.d.ts +13 -0
- package/dist/components/combobox.d.ts.map +1 -1
- package/dist/components/row-actions-menu.d.ts +1 -1
- package/dist/components/row-actions-menu.d.ts.map +1 -1
- package/dist/components/user-menu.d.ts +1 -1
- package/dist/components/user-menu.d.ts.map +1 -1
- package/dist/hooks/use-is-desktop.d.ts +7 -0
- package/dist/hooks/use-is-desktop.d.ts.map +1 -0
- package/dist/index.cjs +362 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +356 -156
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/components/combobox.tsx +108 -70
- package/src/components/row-actions-menu.tsx +113 -36
- package/src/components/user-menu.tsx +157 -48
- package/src/hooks/use-is-desktop.ts +26 -0
- package/src/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -546,7 +546,27 @@ PasswordInput.displayName = "PasswordInput";
|
|
|
546
546
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
547
547
|
import { Command as CommandPrimitive } from "cmdk";
|
|
548
548
|
import { Check, ChevronsUpDown, Search } from "lucide-react";
|
|
549
|
+
import * as React5 from "react";
|
|
550
|
+
import { Drawer as DrawerPrimitive } from "vaul";
|
|
551
|
+
|
|
552
|
+
// src/hooks/use-is-desktop.ts
|
|
549
553
|
import * as React4 from "react";
|
|
554
|
+
var DESKTOP_QUERY = "(min-width: 640px)";
|
|
555
|
+
function useIsDesktop() {
|
|
556
|
+
const [isDesktop, setIsDesktop] = React4.useState(
|
|
557
|
+
() => typeof window !== "undefined" ? window.matchMedia(DESKTOP_QUERY).matches : true
|
|
558
|
+
);
|
|
559
|
+
React4.useEffect(() => {
|
|
560
|
+
const mql = window.matchMedia(DESKTOP_QUERY);
|
|
561
|
+
const onChange = () => setIsDesktop(mql.matches);
|
|
562
|
+
onChange();
|
|
563
|
+
mql.addEventListener("change", onChange);
|
|
564
|
+
return () => mql.removeEventListener("change", onChange);
|
|
565
|
+
}, []);
|
|
566
|
+
return isDesktop;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// src/components/combobox.tsx
|
|
550
570
|
import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
551
571
|
function Combobox({
|
|
552
572
|
options,
|
|
@@ -561,84 +581,94 @@ function Combobox({
|
|
|
561
581
|
"aria-invalid": ariaInvalid,
|
|
562
582
|
"aria-describedby": ariaDescribedby
|
|
563
583
|
}) {
|
|
564
|
-
const [open, setOpen] =
|
|
584
|
+
const [open, setOpen] = React5.useState(false);
|
|
585
|
+
const isDesktop = useIsDesktop();
|
|
565
586
|
const selected = options.find((option) => option.value === value);
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
children:
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
587
|
+
const trigger = /* @__PURE__ */ jsxs14(
|
|
588
|
+
"button",
|
|
589
|
+
{
|
|
590
|
+
type: "button",
|
|
591
|
+
id,
|
|
592
|
+
role: "combobox",
|
|
593
|
+
"aria-expanded": open,
|
|
594
|
+
"aria-invalid": ariaInvalid,
|
|
595
|
+
"aria-describedby": ariaDescribedby,
|
|
596
|
+
disabled,
|
|
597
|
+
className: cn(
|
|
598
|
+
"flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
|
|
599
|
+
className
|
|
600
|
+
),
|
|
601
|
+
children: [
|
|
602
|
+
/* @__PURE__ */ jsx16("span", { className: cn("truncate", !selected && "text-muted-foreground"), children: selected ? selected.label : placeholder }),
|
|
603
|
+
/* @__PURE__ */ jsx16(ChevronsUpDown, { className: "h-4 w-4 shrink-0 opacity-50" })
|
|
604
|
+
]
|
|
605
|
+
}
|
|
606
|
+
);
|
|
607
|
+
const command = /* @__PURE__ */ jsxs14(CommandPrimitive, { className: "flex h-full w-full flex-col overflow-hidden", children: [
|
|
608
|
+
/* @__PURE__ */ jsxs14("div", { className: "flex items-center border-b px-3", children: [
|
|
609
|
+
/* @__PURE__ */ jsx16(Search, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
610
|
+
/* @__PURE__ */ jsx16(
|
|
611
|
+
CommandPrimitive.Input,
|
|
612
|
+
{
|
|
613
|
+
placeholder: searchPlaceholder,
|
|
614
|
+
className: "flex h-11 w-full bg-transparent py-2 text-base outline-none placeholder:text-muted-foreground sm:h-9 sm:text-sm"
|
|
615
|
+
}
|
|
616
|
+
)
|
|
617
|
+
] }),
|
|
618
|
+
/* @__PURE__ */ jsxs14(CommandPrimitive.List, { className: "max-h-[50vh] overflow-y-auto overflow-x-hidden p-1 sm:max-h-60", children: [
|
|
619
|
+
/* @__PURE__ */ jsx16(CommandPrimitive.Empty, { className: "py-6 text-center text-sm text-muted-foreground", children: emptyMessage }),
|
|
620
|
+
options.map((option) => /* @__PURE__ */ jsxs14(
|
|
621
|
+
CommandPrimitive.Item,
|
|
622
|
+
{
|
|
623
|
+
value: option.label,
|
|
624
|
+
disabled: option.disabled,
|
|
625
|
+
onSelect: () => {
|
|
626
|
+
onChange(option.value);
|
|
627
|
+
setOpen(false);
|
|
628
|
+
},
|
|
629
|
+
className: "relative flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-2.5 text-sm outline-none data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 sm:py-1.5",
|
|
630
|
+
children: [
|
|
603
631
|
/* @__PURE__ */ jsx16(
|
|
604
|
-
|
|
632
|
+
Check,
|
|
605
633
|
{
|
|
606
|
-
|
|
607
|
-
|
|
634
|
+
className: cn(
|
|
635
|
+
"h-4 w-4 shrink-0",
|
|
636
|
+
value === option.value ? "opacity-100" : "opacity-0"
|
|
637
|
+
)
|
|
608
638
|
}
|
|
609
|
-
)
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
}
|
|
641
|
-
|
|
639
|
+
),
|
|
640
|
+
/* @__PURE__ */ jsx16("span", { className: "truncate", children: option.label })
|
|
641
|
+
]
|
|
642
|
+
},
|
|
643
|
+
option.value
|
|
644
|
+
))
|
|
645
|
+
] })
|
|
646
|
+
] });
|
|
647
|
+
if (isDesktop) {
|
|
648
|
+
return /* @__PURE__ */ jsxs14(PopoverPrimitive.Root, { open, onOpenChange: setOpen, modal: true, children: [
|
|
649
|
+
/* @__PURE__ */ jsx16(PopoverPrimitive.Trigger, { asChild: true, children: trigger }),
|
|
650
|
+
/* @__PURE__ */ jsx16(PopoverPrimitive.Portal, { children: /* @__PURE__ */ jsx16(
|
|
651
|
+
PopoverPrimitive.Content,
|
|
652
|
+
{
|
|
653
|
+
align: "start",
|
|
654
|
+
sideOffset: 4,
|
|
655
|
+
className: "z-50 overflow-hidden rounded-md border bg-popover p-0 text-popover-foreground shadow-md",
|
|
656
|
+
style: { width: "var(--radix-popover-trigger-width)" },
|
|
657
|
+
children: command
|
|
658
|
+
}
|
|
659
|
+
) })
|
|
660
|
+
] });
|
|
661
|
+
}
|
|
662
|
+
return /* @__PURE__ */ jsxs14(DrawerPrimitive.Root, { open, onOpenChange: setOpen, children: [
|
|
663
|
+
/* @__PURE__ */ jsx16(DrawerPrimitive.Trigger, { asChild: true, children: trigger }),
|
|
664
|
+
/* @__PURE__ */ jsxs14(DrawerPrimitive.Portal, { children: [
|
|
665
|
+
/* @__PURE__ */ jsx16(DrawerPrimitive.Overlay, { className: "fixed inset-0 z-50 bg-black/80" }),
|
|
666
|
+
/* @__PURE__ */ jsxs14(DrawerPrimitive.Content, { className: "fixed inset-x-0 bottom-0 z-50 mt-24 flex max-h-[85vh] flex-col rounded-t-2xl border bg-popover text-popover-foreground outline-none", children: [
|
|
667
|
+
/* @__PURE__ */ jsx16(DrawerPrimitive.Title, { className: "sr-only", children: placeholder }),
|
|
668
|
+
/* @__PURE__ */ jsx16("div", { className: "mx-auto my-3 h-1.5 w-12 shrink-0 rounded-full bg-muted" }),
|
|
669
|
+
command
|
|
670
|
+
] })
|
|
671
|
+
] })
|
|
642
672
|
] });
|
|
643
673
|
}
|
|
644
674
|
|
|
@@ -830,7 +860,7 @@ function Toaster(props) {
|
|
|
830
860
|
|
|
831
861
|
// src/components/app-shell.tsx
|
|
832
862
|
import { ChevronLeft, ChevronRight, Menu } from "lucide-react";
|
|
833
|
-
import { useState as
|
|
863
|
+
import { useState as useState6 } from "react";
|
|
834
864
|
|
|
835
865
|
// src/components/sidebar-nav.tsx
|
|
836
866
|
import { Fragment as Fragment3 } from "react";
|
|
@@ -879,6 +909,8 @@ function SidebarNav({
|
|
|
879
909
|
// src/components/user-menu.tsx
|
|
880
910
|
import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
|
|
881
911
|
import { LogOut, User } from "lucide-react";
|
|
912
|
+
import { useState as useState5 } from "react";
|
|
913
|
+
import { Drawer as DrawerPrimitive2 } from "vaul";
|
|
882
914
|
import { Fragment as Fragment5, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
|
|
883
915
|
function initials(user) {
|
|
884
916
|
const source = user?.name?.trim() || user?.email?.trim();
|
|
@@ -888,6 +920,7 @@ function initials(user) {
|
|
|
888
920
|
return source.slice(0, 2).toUpperCase();
|
|
889
921
|
}
|
|
890
922
|
var itemClass = "flex w-full cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent focus:bg-accent";
|
|
923
|
+
var sheetItemClass = "flex w-full cursor-pointer select-none items-center gap-3 rounded-md px-3 py-3 text-base outline-none transition-colors hover:bg-accent active:bg-accent";
|
|
891
924
|
function UserMenu({
|
|
892
925
|
user,
|
|
893
926
|
items = [],
|
|
@@ -896,51 +929,151 @@ function UserMenu({
|
|
|
896
929
|
renderLink = defaultRenderLink,
|
|
897
930
|
align = "end"
|
|
898
931
|
}) {
|
|
932
|
+
const isDesktop = useIsDesktop();
|
|
933
|
+
const [open, setOpen] = useState5(false);
|
|
899
934
|
const label = initials(user);
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
935
|
+
const trigger = /* @__PURE__ */ jsx24(
|
|
936
|
+
"button",
|
|
937
|
+
{
|
|
938
|
+
type: "button",
|
|
939
|
+
className: "inline-flex h-9 w-9 items-center justify-center overflow-hidden rounded-full border border-input bg-background text-xs font-semibold shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
|
|
940
|
+
"aria-label": "Menu do usu\xE1rio",
|
|
941
|
+
"data-testid": "user-menu",
|
|
942
|
+
children: user?.avatarUrl ? /* @__PURE__ */ jsx24(
|
|
943
|
+
"img",
|
|
944
|
+
{
|
|
945
|
+
src: user.avatarUrl,
|
|
946
|
+
alt: user.name ?? user.email ?? "Avatar",
|
|
947
|
+
className: "h-full w-full object-cover"
|
|
948
|
+
}
|
|
949
|
+
) : label ? /* @__PURE__ */ jsx24("span", { children: label }) : /* @__PURE__ */ jsx24(User, { className: "h-4 w-4" })
|
|
950
|
+
}
|
|
951
|
+
);
|
|
952
|
+
const userInfo = (user?.name || user?.email) && /* @__PURE__ */ jsxs20("div", { className: "px-2 py-1.5", children: [
|
|
953
|
+
user.name && /* @__PURE__ */ jsx24("p", { className: "truncate text-sm font-medium", children: user.name }),
|
|
954
|
+
user.email && /* @__PURE__ */ jsx24("p", { className: "truncate text-xs text-muted-foreground", children: user.email })
|
|
955
|
+
] });
|
|
956
|
+
if (isDesktop) {
|
|
957
|
+
return /* @__PURE__ */ jsxs20(DropdownMenu2.Root, { open, onOpenChange: setOpen, children: [
|
|
958
|
+
/* @__PURE__ */ jsx24(DropdownMenu2.Trigger, { asChild: true, children: trigger }),
|
|
959
|
+
/* @__PURE__ */ jsx24(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsxs20(
|
|
960
|
+
DropdownMenu2.Content,
|
|
961
|
+
{
|
|
962
|
+
align,
|
|
963
|
+
sideOffset: 6,
|
|
964
|
+
className: "z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",
|
|
965
|
+
children: [
|
|
966
|
+
userInfo && /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
967
|
+
userInfo,
|
|
968
|
+
/* @__PURE__ */ jsx24(DropdownMenu2.Separator, { className: "-mx-1 my-1 h-px bg-border" })
|
|
922
969
|
] }),
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
item.label
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
970
|
+
items.map(
|
|
971
|
+
(item) => item.href ? /* @__PURE__ */ jsx24(DropdownMenu2.Item, { asChild: true, children: renderLink({
|
|
972
|
+
href: item.href,
|
|
973
|
+
className: itemClass,
|
|
974
|
+
children: /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
975
|
+
item.icon,
|
|
976
|
+
item.label
|
|
977
|
+
] })
|
|
978
|
+
}) }, item.label) : /* @__PURE__ */ jsxs20(
|
|
979
|
+
DropdownMenu2.Item,
|
|
980
|
+
{
|
|
981
|
+
className: itemClass,
|
|
982
|
+
onClick: item.onClick,
|
|
983
|
+
children: [
|
|
984
|
+
item.icon,
|
|
985
|
+
item.label
|
|
986
|
+
]
|
|
987
|
+
},
|
|
988
|
+
item.label
|
|
989
|
+
)
|
|
990
|
+
),
|
|
991
|
+
onLogout && /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
992
|
+
items.length > 0 && /* @__PURE__ */ jsx24(DropdownMenu2.Separator, { className: "-mx-1 my-1 h-px bg-border" }),
|
|
993
|
+
/* @__PURE__ */ jsxs20(
|
|
994
|
+
DropdownMenu2.Item,
|
|
995
|
+
{
|
|
996
|
+
className: cn(
|
|
997
|
+
itemClass,
|
|
998
|
+
"text-destructive focus:bg-destructive/10"
|
|
999
|
+
),
|
|
1000
|
+
onClick: onLogout,
|
|
1001
|
+
children: [
|
|
1002
|
+
/* @__PURE__ */ jsx24(LogOut, { className: "h-4 w-4" }),
|
|
1003
|
+
logoutLabel
|
|
1004
|
+
]
|
|
1005
|
+
}
|
|
1006
|
+
)
|
|
939
1007
|
] })
|
|
940
|
-
]
|
|
941
|
-
|
|
942
|
-
}
|
|
943
|
-
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
) })
|
|
1011
|
+
] });
|
|
1012
|
+
}
|
|
1013
|
+
return /* @__PURE__ */ jsxs20(DrawerPrimitive2.Root, { open, onOpenChange: setOpen, children: [
|
|
1014
|
+
/* @__PURE__ */ jsx24(DrawerPrimitive2.Trigger, { asChild: true, children: trigger }),
|
|
1015
|
+
/* @__PURE__ */ jsxs20(DrawerPrimitive2.Portal, { children: [
|
|
1016
|
+
/* @__PURE__ */ jsx24(DrawerPrimitive2.Overlay, { className: "fixed inset-0 z-50 bg-black/80" }),
|
|
1017
|
+
/* @__PURE__ */ jsxs20(DrawerPrimitive2.Content, { className: "fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-2xl border bg-popover p-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-popover-foreground outline-none", children: [
|
|
1018
|
+
/* @__PURE__ */ jsx24(DrawerPrimitive2.Title, { className: "sr-only", children: "Menu do usu\xE1rio" }),
|
|
1019
|
+
/* @__PURE__ */ jsx24("div", { className: "mx-auto my-3 h-1.5 w-12 shrink-0 rounded-full bg-muted" }),
|
|
1020
|
+
userInfo && /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
1021
|
+
userInfo,
|
|
1022
|
+
/* @__PURE__ */ jsx24("div", { className: "-mx-1 my-1 h-px bg-border" })
|
|
1023
|
+
] }),
|
|
1024
|
+
items.map(
|
|
1025
|
+
(item) => item.href ? /* @__PURE__ */ jsx24(
|
|
1026
|
+
"span",
|
|
1027
|
+
{
|
|
1028
|
+
onClick: () => setOpen(false),
|
|
1029
|
+
onKeyDown: () => setOpen(false),
|
|
1030
|
+
children: renderLink({
|
|
1031
|
+
href: item.href,
|
|
1032
|
+
className: sheetItemClass,
|
|
1033
|
+
children: /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
1034
|
+
item.icon,
|
|
1035
|
+
item.label
|
|
1036
|
+
] })
|
|
1037
|
+
})
|
|
1038
|
+
},
|
|
1039
|
+
item.label
|
|
1040
|
+
) : /* @__PURE__ */ jsxs20(
|
|
1041
|
+
"button",
|
|
1042
|
+
{
|
|
1043
|
+
type: "button",
|
|
1044
|
+
className: sheetItemClass,
|
|
1045
|
+
onClick: () => {
|
|
1046
|
+
item.onClick?.();
|
|
1047
|
+
setOpen(false);
|
|
1048
|
+
},
|
|
1049
|
+
children: [
|
|
1050
|
+
item.icon,
|
|
1051
|
+
item.label
|
|
1052
|
+
]
|
|
1053
|
+
},
|
|
1054
|
+
item.label
|
|
1055
|
+
)
|
|
1056
|
+
),
|
|
1057
|
+
onLogout && /* @__PURE__ */ jsxs20(Fragment5, { children: [
|
|
1058
|
+
items.length > 0 && /* @__PURE__ */ jsx24("div", { className: "-mx-1 my-1 h-px bg-border" }),
|
|
1059
|
+
/* @__PURE__ */ jsxs20(
|
|
1060
|
+
"button",
|
|
1061
|
+
{
|
|
1062
|
+
type: "button",
|
|
1063
|
+
className: cn(sheetItemClass, "text-destructive"),
|
|
1064
|
+
onClick: () => {
|
|
1065
|
+
onLogout();
|
|
1066
|
+
setOpen(false);
|
|
1067
|
+
},
|
|
1068
|
+
children: [
|
|
1069
|
+
/* @__PURE__ */ jsx24(LogOut, { className: "h-4 w-4" }),
|
|
1070
|
+
logoutLabel
|
|
1071
|
+
]
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] })
|
|
1075
|
+
] })
|
|
1076
|
+
] })
|
|
944
1077
|
] });
|
|
945
1078
|
}
|
|
946
1079
|
|
|
@@ -962,8 +1095,8 @@ function AppShell({
|
|
|
962
1095
|
defaultCollapsed = false,
|
|
963
1096
|
children
|
|
964
1097
|
}) {
|
|
965
|
-
const [collapsed, setCollapsed] =
|
|
966
|
-
const [mobileOpen, setMobileOpen] =
|
|
1098
|
+
const [collapsed, setCollapsed] = useState6(defaultCollapsed);
|
|
1099
|
+
const [mobileOpen, setMobileOpen] = useState6(false);
|
|
967
1100
|
const nav = (isCollapsed, onNavigate) => /* @__PURE__ */ jsx25(
|
|
968
1101
|
SidebarNav,
|
|
969
1102
|
{
|
|
@@ -1052,8 +1185,12 @@ function AppShell({
|
|
|
1052
1185
|
// src/components/row-actions-menu.tsx
|
|
1053
1186
|
import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
|
|
1054
1187
|
import { MoreVertical } from "lucide-react";
|
|
1188
|
+
import { useState as useState7 } from "react";
|
|
1189
|
+
import { Drawer as DrawerPrimitive3 } from "vaul";
|
|
1055
1190
|
import { Fragment as Fragment6, jsx as jsx26, jsxs as jsxs22 } from "react/jsx-runtime";
|
|
1191
|
+
var triggerClass = "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50";
|
|
1056
1192
|
var itemClass2 = "flex w-full cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none transition-colors hover:bg-accent focus:bg-accent data-[disabled]:pointer-events-none data-[disabled]:opacity-50";
|
|
1193
|
+
var sheetItemClass2 = "flex w-full cursor-pointer select-none items-center gap-3 rounded-md px-3 py-3 text-base outline-none transition-colors hover:bg-accent active:bg-accent disabled:pointer-events-none disabled:opacity-50";
|
|
1057
1194
|
function RowActionsMenu({
|
|
1058
1195
|
actions,
|
|
1059
1196
|
disabled = false,
|
|
@@ -1061,49 +1198,111 @@ function RowActionsMenu({
|
|
|
1061
1198
|
label = "A\xE7\xF5es",
|
|
1062
1199
|
renderLink = defaultRenderLink
|
|
1063
1200
|
}) {
|
|
1201
|
+
const isDesktop = useIsDesktop();
|
|
1202
|
+
const [open, setOpen] = useState7(false);
|
|
1064
1203
|
if (actions.length === 0) return null;
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
/* @__PURE__ */
|
|
1077
|
-
DropdownMenu3.
|
|
1078
|
-
{
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1204
|
+
const trigger = /* @__PURE__ */ jsx26(
|
|
1205
|
+
"button",
|
|
1206
|
+
{
|
|
1207
|
+
type: "button",
|
|
1208
|
+
disabled,
|
|
1209
|
+
"aria-label": label,
|
|
1210
|
+
className: triggerClass,
|
|
1211
|
+
children: /* @__PURE__ */ jsx26(MoreVertical, { className: "h-4 w-4" })
|
|
1212
|
+
}
|
|
1213
|
+
);
|
|
1214
|
+
if (isDesktop) {
|
|
1215
|
+
return /* @__PURE__ */ jsxs22(DropdownMenu3.Root, { open, onOpenChange: setOpen, children: [
|
|
1216
|
+
/* @__PURE__ */ jsx26(DropdownMenu3.Trigger, { asChild: true, children: trigger }),
|
|
1217
|
+
/* @__PURE__ */ jsx26(DropdownMenu3.Portal, { children: /* @__PURE__ */ jsx26(
|
|
1218
|
+
DropdownMenu3.Content,
|
|
1219
|
+
{
|
|
1220
|
+
align,
|
|
1221
|
+
sideOffset: 6,
|
|
1222
|
+
className: "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95",
|
|
1223
|
+
children: actions.map((action) => {
|
|
1224
|
+
const cls = cn(
|
|
1225
|
+
itemClass2,
|
|
1226
|
+
action.destructive && "text-destructive focus:bg-destructive/10"
|
|
1227
|
+
);
|
|
1228
|
+
return action.href ? /* @__PURE__ */ jsx26(
|
|
1229
|
+
DropdownMenu3.Item,
|
|
1230
|
+
{
|
|
1231
|
+
asChild: true,
|
|
1232
|
+
disabled: action.disabled,
|
|
1233
|
+
children: renderLink({
|
|
1234
|
+
href: action.href,
|
|
1235
|
+
className: cls,
|
|
1236
|
+
children: /* @__PURE__ */ jsxs22(Fragment6, { children: [
|
|
1237
|
+
action.icon,
|
|
1238
|
+
action.label
|
|
1239
|
+
] })
|
|
1240
|
+
})
|
|
1241
|
+
},
|
|
1089
1242
|
action.label
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1243
|
+
) : /* @__PURE__ */ jsxs22(
|
|
1244
|
+
DropdownMenu3.Item,
|
|
1245
|
+
{
|
|
1246
|
+
className: cls,
|
|
1247
|
+
disabled: action.disabled,
|
|
1248
|
+
onClick: action.onClick,
|
|
1249
|
+
children: [
|
|
1250
|
+
action.icon,
|
|
1251
|
+
action.label
|
|
1252
|
+
]
|
|
1253
|
+
},
|
|
1254
|
+
action.label
|
|
1255
|
+
);
|
|
1256
|
+
})
|
|
1257
|
+
}
|
|
1258
|
+
) })
|
|
1259
|
+
] });
|
|
1260
|
+
}
|
|
1261
|
+
return /* @__PURE__ */ jsxs22(DrawerPrimitive3.Root, { open, onOpenChange: setOpen, children: [
|
|
1262
|
+
/* @__PURE__ */ jsx26(DrawerPrimitive3.Trigger, { asChild: true, children: trigger }),
|
|
1263
|
+
/* @__PURE__ */ jsxs22(DrawerPrimitive3.Portal, { children: [
|
|
1264
|
+
/* @__PURE__ */ jsx26(DrawerPrimitive3.Overlay, { className: "fixed inset-0 z-50 bg-black/80" }),
|
|
1265
|
+
/* @__PURE__ */ jsxs22(DrawerPrimitive3.Content, { className: "fixed inset-x-0 bottom-0 z-50 flex flex-col rounded-t-2xl border bg-popover p-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-popover-foreground outline-none", children: [
|
|
1266
|
+
/* @__PURE__ */ jsx26(DrawerPrimitive3.Title, { className: "sr-only", children: label }),
|
|
1267
|
+
/* @__PURE__ */ jsx26("div", { className: "mx-auto my-3 h-1.5 w-12 shrink-0 rounded-full bg-muted" }),
|
|
1268
|
+
actions.map((action) => {
|
|
1269
|
+
const cls = cn(
|
|
1270
|
+
sheetItemClass2,
|
|
1271
|
+
action.destructive && "text-destructive"
|
|
1272
|
+
);
|
|
1273
|
+
const inner = /* @__PURE__ */ jsxs22(Fragment6, { children: [
|
|
1274
|
+
action.icon,
|
|
1275
|
+
action.label
|
|
1276
|
+
] });
|
|
1277
|
+
return action.href ? /* @__PURE__ */ jsx26(
|
|
1278
|
+
"span",
|
|
1093
1279
|
{
|
|
1094
|
-
|
|
1280
|
+
onClick: () => setOpen(false),
|
|
1281
|
+
onKeyDown: () => setOpen(false),
|
|
1282
|
+
children: renderLink({
|
|
1283
|
+
href: action.href,
|
|
1284
|
+
className: cls,
|
|
1285
|
+
children: inner
|
|
1286
|
+
})
|
|
1287
|
+
},
|
|
1288
|
+
action.label
|
|
1289
|
+
) : /* @__PURE__ */ jsx26(
|
|
1290
|
+
"button",
|
|
1291
|
+
{
|
|
1292
|
+
type: "button",
|
|
1095
1293
|
disabled: action.disabled,
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
action.
|
|
1099
|
-
|
|
1100
|
-
|
|
1294
|
+
className: cls,
|
|
1295
|
+
onClick: () => {
|
|
1296
|
+
action.onClick?.();
|
|
1297
|
+
setOpen(false);
|
|
1298
|
+
},
|
|
1299
|
+
children: inner
|
|
1101
1300
|
},
|
|
1102
1301
|
action.label
|
|
1103
1302
|
);
|
|
1104
1303
|
})
|
|
1105
|
-
}
|
|
1106
|
-
|
|
1304
|
+
] })
|
|
1305
|
+
] })
|
|
1107
1306
|
] });
|
|
1108
1307
|
}
|
|
1109
1308
|
|
|
@@ -1117,9 +1316,9 @@ function extractApiError(err, fallbackMessage = "Ocorreu um erro inesperado.") {
|
|
|
1117
1316
|
}
|
|
1118
1317
|
|
|
1119
1318
|
// src/hooks/use-disclosure.ts
|
|
1120
|
-
import { useCallback, useState as
|
|
1319
|
+
import { useCallback, useState as useState8 } from "react";
|
|
1121
1320
|
function useDisclosure(initial = false) {
|
|
1122
|
-
const [open, setOpen] =
|
|
1321
|
+
const [open, setOpen] = useState8(initial);
|
|
1123
1322
|
const onOpen = useCallback(() => setOpen(true), []);
|
|
1124
1323
|
const onClose = useCallback(() => setOpen(false), []);
|
|
1125
1324
|
const onToggle = useCallback(() => setOpen((v) => !v), []);
|
|
@@ -1184,6 +1383,7 @@ export {
|
|
|
1184
1383
|
toast,
|
|
1185
1384
|
useCustomToast,
|
|
1186
1385
|
useDisclosure,
|
|
1386
|
+
useIsDesktop,
|
|
1187
1387
|
useTheme
|
|
1188
1388
|
};
|
|
1189
1389
|
//# sourceMappingURL=index.js.map
|