@motor-hero/ui-kit 0.17.0 → 0.19.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/README.md +41 -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/theme-provider.d.ts +3 -1
- package/dist/components/theme-provider.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 +302 -96
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +295 -91
- package/dist/index.js.map +1 -1
- package/dist/lib/tenant-theme.d.ts +15 -0
- package/dist/lib/tenant-theme.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/components/combobox.tsx +1 -20
- package/src/components/row-actions-menu.tsx +113 -36
- package/src/components/theme-provider.tsx +18 -8
- package/src/components/user-menu.tsx +157 -48
- package/src/hooks/use-is-desktop.ts +26 -0
- package/src/index.ts +3 -0
- package/src/lib/tenant-theme.ts +42 -0
package/dist/index.cjs
CHANGED
|
@@ -56,18 +56,41 @@ __export(index_exports, {
|
|
|
56
56
|
ThemeProvider: () => ThemeProvider,
|
|
57
57
|
Toaster: () => Toaster,
|
|
58
58
|
UserMenu: () => UserMenu,
|
|
59
|
+
applyTenantTheme: () => applyTenantTheme,
|
|
59
60
|
cn: () => cn,
|
|
60
61
|
defaultRenderLink: () => defaultRenderLink,
|
|
61
62
|
extractApiError: () => extractApiError,
|
|
62
63
|
toast: () => import_sonner2.toast,
|
|
63
64
|
useCustomToast: () => useCustomToast,
|
|
64
65
|
useDisclosure: () => useDisclosure,
|
|
66
|
+
useIsDesktop: () => useIsDesktop,
|
|
65
67
|
useTheme: () => useTheme
|
|
66
68
|
});
|
|
67
69
|
module.exports = __toCommonJS(index_exports);
|
|
68
70
|
|
|
69
71
|
// src/components/theme-provider.tsx
|
|
70
72
|
var import_react = require("react");
|
|
73
|
+
|
|
74
|
+
// src/lib/tenant-theme.ts
|
|
75
|
+
var VAR_MAP = {
|
|
76
|
+
primary: "--color-primary",
|
|
77
|
+
primaryForeground: "--color-primary-foreground",
|
|
78
|
+
secondary: "--color-secondary",
|
|
79
|
+
secondaryForeground: "--color-secondary-foreground",
|
|
80
|
+
accent: "--color-accent",
|
|
81
|
+
accentForeground: "--color-accent-foreground",
|
|
82
|
+
ring: "--color-ring"
|
|
83
|
+
};
|
|
84
|
+
function applyTenantTheme(root, tenantTheme, mode) {
|
|
85
|
+
const tokens = tenantTheme ? mode === "dark" ? { ...tenantTheme.light, ...tenantTheme.dark } : tenantTheme.light : {};
|
|
86
|
+
for (const key of Object.keys(VAR_MAP)) {
|
|
87
|
+
const value = tokens[key];
|
|
88
|
+
if (value) root.style.setProperty(VAR_MAP[key], value);
|
|
89
|
+
else root.style.removeProperty(VAR_MAP[key]);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// src/components/theme-provider.tsx
|
|
71
94
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
72
95
|
var initialState = {
|
|
73
96
|
theme: "system",
|
|
@@ -78,6 +101,7 @@ function ThemeProvider({
|
|
|
78
101
|
children,
|
|
79
102
|
defaultTheme = "system",
|
|
80
103
|
storageKey = "ui-theme",
|
|
104
|
+
tenantTheme,
|
|
81
105
|
...props
|
|
82
106
|
}) {
|
|
83
107
|
const [theme, setTheme] = (0, import_react.useState)(
|
|
@@ -85,14 +109,20 @@ function ThemeProvider({
|
|
|
85
109
|
);
|
|
86
110
|
(0, import_react.useEffect)(() => {
|
|
87
111
|
const root = window.document.documentElement;
|
|
88
|
-
|
|
112
|
+
const applyResolved = (resolved) => {
|
|
113
|
+
root.classList.remove("light", "dark");
|
|
114
|
+
root.classList.add(resolved);
|
|
115
|
+
applyTenantTheme(root, tenantTheme, resolved);
|
|
116
|
+
};
|
|
89
117
|
if (theme === "system") {
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
|
|
118
|
+
const mql = window.matchMedia("(prefers-color-scheme: dark)");
|
|
119
|
+
applyResolved(mql.matches ? "dark" : "light");
|
|
120
|
+
const onChange = (e) => applyResolved(e.matches ? "dark" : "light");
|
|
121
|
+
mql.addEventListener("change", onChange);
|
|
122
|
+
return () => mql.removeEventListener("change", onChange);
|
|
93
123
|
}
|
|
94
|
-
|
|
95
|
-
}, [theme]);
|
|
124
|
+
applyResolved(theme);
|
|
125
|
+
}, [theme, tenantTheme]);
|
|
96
126
|
const value = {
|
|
97
127
|
theme,
|
|
98
128
|
setTheme: (theme2) => {
|
|
@@ -614,9 +644,11 @@ PasswordInput.displayName = "PasswordInput";
|
|
|
614
644
|
var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"), 1);
|
|
615
645
|
var import_cmdk = require("cmdk");
|
|
616
646
|
var import_lucide_react4 = require("lucide-react");
|
|
617
|
-
var
|
|
647
|
+
var React5 = __toESM(require("react"), 1);
|
|
618
648
|
var import_vaul = require("vaul");
|
|
619
|
-
|
|
649
|
+
|
|
650
|
+
// src/hooks/use-is-desktop.ts
|
|
651
|
+
var React4 = __toESM(require("react"), 1);
|
|
620
652
|
var DESKTOP_QUERY = "(min-width: 640px)";
|
|
621
653
|
function useIsDesktop() {
|
|
622
654
|
const [isDesktop, setIsDesktop] = React4.useState(
|
|
@@ -631,6 +663,9 @@ function useIsDesktop() {
|
|
|
631
663
|
}, []);
|
|
632
664
|
return isDesktop;
|
|
633
665
|
}
|
|
666
|
+
|
|
667
|
+
// src/components/combobox.tsx
|
|
668
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
634
669
|
function Combobox({
|
|
635
670
|
options,
|
|
636
671
|
value,
|
|
@@ -644,7 +679,7 @@ function Combobox({
|
|
|
644
679
|
"aria-invalid": ariaInvalid,
|
|
645
680
|
"aria-describedby": ariaDescribedby
|
|
646
681
|
}) {
|
|
647
|
-
const [open, setOpen] =
|
|
682
|
+
const [open, setOpen] = React5.useState(false);
|
|
648
683
|
const isDesktop = useIsDesktop();
|
|
649
684
|
const selected = options.find((option) => option.value === value);
|
|
650
685
|
const trigger = /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
|
|
@@ -923,7 +958,7 @@ function Toaster(props) {
|
|
|
923
958
|
|
|
924
959
|
// src/components/app-shell.tsx
|
|
925
960
|
var import_lucide_react6 = require("lucide-react");
|
|
926
|
-
var
|
|
961
|
+
var import_react6 = require("react");
|
|
927
962
|
|
|
928
963
|
// src/components/sidebar-nav.tsx
|
|
929
964
|
var import_react4 = require("react");
|
|
@@ -972,6 +1007,8 @@ function SidebarNav({
|
|
|
972
1007
|
// src/components/user-menu.tsx
|
|
973
1008
|
var DropdownMenu2 = __toESM(require("@radix-ui/react-dropdown-menu"), 1);
|
|
974
1009
|
var import_lucide_react5 = require("lucide-react");
|
|
1010
|
+
var import_react5 = require("react");
|
|
1011
|
+
var import_vaul2 = require("vaul");
|
|
975
1012
|
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
976
1013
|
function initials(user) {
|
|
977
1014
|
const source = user?.name?.trim() || user?.email?.trim();
|
|
@@ -981,6 +1018,7 @@ function initials(user) {
|
|
|
981
1018
|
return source.slice(0, 2).toUpperCase();
|
|
982
1019
|
}
|
|
983
1020
|
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";
|
|
1021
|
+
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";
|
|
984
1022
|
function UserMenu({
|
|
985
1023
|
user,
|
|
986
1024
|
items = [],
|
|
@@ -989,51 +1027,151 @@ function UserMenu({
|
|
|
989
1027
|
renderLink = defaultRenderLink,
|
|
990
1028
|
align = "end"
|
|
991
1029
|
}) {
|
|
1030
|
+
const isDesktop = useIsDesktop();
|
|
1031
|
+
const [open, setOpen] = (0, import_react5.useState)(false);
|
|
992
1032
|
const label = initials(user);
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1033
|
+
const trigger = /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1034
|
+
"button",
|
|
1035
|
+
{
|
|
1036
|
+
type: "button",
|
|
1037
|
+
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",
|
|
1038
|
+
"aria-label": "Menu do usu\xE1rio",
|
|
1039
|
+
"data-testid": "user-menu",
|
|
1040
|
+
children: user?.avatarUrl ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1041
|
+
"img",
|
|
1042
|
+
{
|
|
1043
|
+
src: user.avatarUrl,
|
|
1044
|
+
alt: user.name ?? user.email ?? "Avatar",
|
|
1045
|
+
className: "h-full w-full object-cover"
|
|
1046
|
+
}
|
|
1047
|
+
) : label ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("span", { children: label }) : /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react5.User, { className: "h-4 w-4" })
|
|
1048
|
+
}
|
|
1049
|
+
);
|
|
1050
|
+
const userInfo = (user?.name || user?.email) && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "px-2 py-1.5", children: [
|
|
1051
|
+
user.name && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "truncate text-sm font-medium", children: user.name }),
|
|
1052
|
+
user.email && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("p", { className: "truncate text-xs text-muted-foreground", children: user.email })
|
|
1053
|
+
] });
|
|
1054
|
+
if (isDesktop) {
|
|
1055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(DropdownMenu2.Root, { open, onOpenChange: setOpen, children: [
|
|
1056
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropdownMenu2.Trigger, { asChild: true, children: trigger }),
|
|
1057
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropdownMenu2.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1058
|
+
DropdownMenu2.Content,
|
|
1059
|
+
{
|
|
1060
|
+
align,
|
|
1061
|
+
sideOffset: 6,
|
|
1062
|
+
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",
|
|
1063
|
+
children: [
|
|
1064
|
+
userInfo && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1065
|
+
userInfo,
|
|
1066
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropdownMenu2.Separator, { className: "-mx-1 my-1 h-px bg-border" })
|
|
1015
1067
|
] }),
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
item.label
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1068
|
+
items.map(
|
|
1069
|
+
(item) => item.href ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropdownMenu2.Item, { asChild: true, children: renderLink({
|
|
1070
|
+
href: item.href,
|
|
1071
|
+
className: itemClass,
|
|
1072
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1073
|
+
item.icon,
|
|
1074
|
+
item.label
|
|
1075
|
+
] })
|
|
1076
|
+
}) }, item.label) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1077
|
+
DropdownMenu2.Item,
|
|
1078
|
+
{
|
|
1079
|
+
className: itemClass,
|
|
1080
|
+
onClick: item.onClick,
|
|
1081
|
+
children: [
|
|
1082
|
+
item.icon,
|
|
1083
|
+
item.label
|
|
1084
|
+
]
|
|
1085
|
+
},
|
|
1086
|
+
item.label
|
|
1087
|
+
)
|
|
1088
|
+
),
|
|
1089
|
+
onLogout && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1090
|
+
items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(DropdownMenu2.Separator, { className: "-mx-1 my-1 h-px bg-border" }),
|
|
1091
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1092
|
+
DropdownMenu2.Item,
|
|
1093
|
+
{
|
|
1094
|
+
className: cn(
|
|
1095
|
+
itemClass,
|
|
1096
|
+
"text-destructive focus:bg-destructive/10"
|
|
1097
|
+
),
|
|
1098
|
+
onClick: onLogout,
|
|
1099
|
+
children: [
|
|
1100
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react5.LogOut, { className: "h-4 w-4" }),
|
|
1101
|
+
logoutLabel
|
|
1102
|
+
]
|
|
1103
|
+
}
|
|
1104
|
+
)
|
|
1032
1105
|
] })
|
|
1033
|
-
]
|
|
1034
|
-
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1106
|
+
]
|
|
1107
|
+
}
|
|
1108
|
+
) })
|
|
1109
|
+
] });
|
|
1110
|
+
}
|
|
1111
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_vaul2.Drawer.Root, { open, onOpenChange: setOpen, children: [
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_vaul2.Drawer.Trigger, { asChild: true, children: trigger }),
|
|
1113
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_vaul2.Drawer.Portal, { children: [
|
|
1114
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_vaul2.Drawer.Overlay, { className: "fixed inset-0 z-50 bg-black/80" }),
|
|
1115
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_vaul2.Drawer.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: [
|
|
1116
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_vaul2.Drawer.Title, { className: "sr-only", children: "Menu do usu\xE1rio" }),
|
|
1117
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "mx-auto my-3 h-1.5 w-12 shrink-0 rounded-full bg-muted" }),
|
|
1118
|
+
userInfo && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1119
|
+
userInfo,
|
|
1120
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "-mx-1 my-1 h-px bg-border" })
|
|
1121
|
+
] }),
|
|
1122
|
+
items.map(
|
|
1123
|
+
(item) => item.href ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
1124
|
+
"span",
|
|
1125
|
+
{
|
|
1126
|
+
onClick: () => setOpen(false),
|
|
1127
|
+
onKeyDown: () => setOpen(false),
|
|
1128
|
+
children: renderLink({
|
|
1129
|
+
href: item.href,
|
|
1130
|
+
className: sheetItemClass,
|
|
1131
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1132
|
+
item.icon,
|
|
1133
|
+
item.label
|
|
1134
|
+
] })
|
|
1135
|
+
})
|
|
1136
|
+
},
|
|
1137
|
+
item.label
|
|
1138
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1139
|
+
"button",
|
|
1140
|
+
{
|
|
1141
|
+
type: "button",
|
|
1142
|
+
className: sheetItemClass,
|
|
1143
|
+
onClick: () => {
|
|
1144
|
+
item.onClick?.();
|
|
1145
|
+
setOpen(false);
|
|
1146
|
+
},
|
|
1147
|
+
children: [
|
|
1148
|
+
item.icon,
|
|
1149
|
+
item.label
|
|
1150
|
+
]
|
|
1151
|
+
},
|
|
1152
|
+
item.label
|
|
1153
|
+
)
|
|
1154
|
+
),
|
|
1155
|
+
onLogout && /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(import_jsx_runtime24.Fragment, { children: [
|
|
1156
|
+
items.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "-mx-1 my-1 h-px bg-border" }),
|
|
1157
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
1158
|
+
"button",
|
|
1159
|
+
{
|
|
1160
|
+
type: "button",
|
|
1161
|
+
className: cn(sheetItemClass, "text-destructive"),
|
|
1162
|
+
onClick: () => {
|
|
1163
|
+
onLogout();
|
|
1164
|
+
setOpen(false);
|
|
1165
|
+
},
|
|
1166
|
+
children: [
|
|
1167
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(import_lucide_react5.LogOut, { className: "h-4 w-4" }),
|
|
1168
|
+
logoutLabel
|
|
1169
|
+
]
|
|
1170
|
+
}
|
|
1171
|
+
)
|
|
1172
|
+
] })
|
|
1173
|
+
] })
|
|
1174
|
+
] })
|
|
1037
1175
|
] });
|
|
1038
1176
|
}
|
|
1039
1177
|
|
|
@@ -1055,8 +1193,8 @@ function AppShell({
|
|
|
1055
1193
|
defaultCollapsed = false,
|
|
1056
1194
|
children
|
|
1057
1195
|
}) {
|
|
1058
|
-
const [collapsed, setCollapsed] = (0,
|
|
1059
|
-
const [mobileOpen, setMobileOpen] = (0,
|
|
1196
|
+
const [collapsed, setCollapsed] = (0, import_react6.useState)(defaultCollapsed);
|
|
1197
|
+
const [mobileOpen, setMobileOpen] = (0, import_react6.useState)(false);
|
|
1060
1198
|
const nav = (isCollapsed, onNavigate) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
1061
1199
|
SidebarNav,
|
|
1062
1200
|
{
|
|
@@ -1145,8 +1283,12 @@ function AppShell({
|
|
|
1145
1283
|
// src/components/row-actions-menu.tsx
|
|
1146
1284
|
var DropdownMenu3 = __toESM(require("@radix-ui/react-dropdown-menu"), 1);
|
|
1147
1285
|
var import_lucide_react7 = require("lucide-react");
|
|
1286
|
+
var import_react7 = require("react");
|
|
1287
|
+
var import_vaul3 = require("vaul");
|
|
1148
1288
|
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
1289
|
+
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";
|
|
1149
1290
|
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";
|
|
1291
|
+
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";
|
|
1150
1292
|
function RowActionsMenu({
|
|
1151
1293
|
actions,
|
|
1152
1294
|
disabled = false,
|
|
@@ -1154,49 +1296,111 @@ function RowActionsMenu({
|
|
|
1154
1296
|
label = "A\xE7\xF5es",
|
|
1155
1297
|
renderLink = defaultRenderLink
|
|
1156
1298
|
}) {
|
|
1299
|
+
const isDesktop = useIsDesktop();
|
|
1300
|
+
const [open, setOpen] = (0, import_react7.useState)(false);
|
|
1157
1301
|
if (actions.length === 0) return null;
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
/* @__PURE__ */ (0, import_jsx_runtime26.
|
|
1170
|
-
DropdownMenu3.
|
|
1171
|
-
{
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1302
|
+
const trigger = /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1303
|
+
"button",
|
|
1304
|
+
{
|
|
1305
|
+
type: "button",
|
|
1306
|
+
disabled,
|
|
1307
|
+
"aria-label": label,
|
|
1308
|
+
className: triggerClass,
|
|
1309
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_lucide_react7.MoreVertical, { className: "h-4 w-4" })
|
|
1310
|
+
}
|
|
1311
|
+
);
|
|
1312
|
+
if (isDesktop) {
|
|
1313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(DropdownMenu3.Root, { open, onOpenChange: setOpen, children: [
|
|
1314
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropdownMenu3.Trigger, { asChild: true, children: trigger }),
|
|
1315
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(DropdownMenu3.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1316
|
+
DropdownMenu3.Content,
|
|
1317
|
+
{
|
|
1318
|
+
align,
|
|
1319
|
+
sideOffset: 6,
|
|
1320
|
+
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",
|
|
1321
|
+
children: actions.map((action) => {
|
|
1322
|
+
const cls = cn(
|
|
1323
|
+
itemClass2,
|
|
1324
|
+
action.destructive && "text-destructive focus:bg-destructive/10"
|
|
1325
|
+
);
|
|
1326
|
+
return action.href ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1327
|
+
DropdownMenu3.Item,
|
|
1328
|
+
{
|
|
1329
|
+
asChild: true,
|
|
1330
|
+
disabled: action.disabled,
|
|
1331
|
+
children: renderLink({
|
|
1332
|
+
href: action.href,
|
|
1333
|
+
className: cls,
|
|
1334
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1335
|
+
action.icon,
|
|
1336
|
+
action.label
|
|
1337
|
+
] })
|
|
1338
|
+
})
|
|
1339
|
+
},
|
|
1182
1340
|
action.label
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1341
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
1342
|
+
DropdownMenu3.Item,
|
|
1343
|
+
{
|
|
1344
|
+
className: cls,
|
|
1345
|
+
disabled: action.disabled,
|
|
1346
|
+
onClick: action.onClick,
|
|
1347
|
+
children: [
|
|
1348
|
+
action.icon,
|
|
1349
|
+
action.label
|
|
1350
|
+
]
|
|
1351
|
+
},
|
|
1352
|
+
action.label
|
|
1353
|
+
);
|
|
1354
|
+
})
|
|
1355
|
+
}
|
|
1356
|
+
) })
|
|
1357
|
+
] });
|
|
1358
|
+
}
|
|
1359
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_vaul3.Drawer.Root, { open, onOpenChange: setOpen, children: [
|
|
1360
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_vaul3.Drawer.Trigger, { asChild: true, children: trigger }),
|
|
1361
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_vaul3.Drawer.Portal, { children: [
|
|
1362
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_vaul3.Drawer.Overlay, { className: "fixed inset-0 z-50 bg-black/80" }),
|
|
1363
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_vaul3.Drawer.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: [
|
|
1364
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(import_vaul3.Drawer.Title, { className: "sr-only", children: label }),
|
|
1365
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "mx-auto my-3 h-1.5 w-12 shrink-0 rounded-full bg-muted" }),
|
|
1366
|
+
actions.map((action) => {
|
|
1367
|
+
const cls = cn(
|
|
1368
|
+
sheetItemClass2,
|
|
1369
|
+
action.destructive && "text-destructive"
|
|
1370
|
+
);
|
|
1371
|
+
const inner = /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(import_jsx_runtime26.Fragment, { children: [
|
|
1372
|
+
action.icon,
|
|
1373
|
+
action.label
|
|
1374
|
+
] });
|
|
1375
|
+
return action.href ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1376
|
+
"span",
|
|
1186
1377
|
{
|
|
1187
|
-
|
|
1378
|
+
onClick: () => setOpen(false),
|
|
1379
|
+
onKeyDown: () => setOpen(false),
|
|
1380
|
+
children: renderLink({
|
|
1381
|
+
href: action.href,
|
|
1382
|
+
className: cls,
|
|
1383
|
+
children: inner
|
|
1384
|
+
})
|
|
1385
|
+
},
|
|
1386
|
+
action.label
|
|
1387
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
1388
|
+
"button",
|
|
1389
|
+
{
|
|
1390
|
+
type: "button",
|
|
1188
1391
|
disabled: action.disabled,
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
action.
|
|
1192
|
-
|
|
1193
|
-
|
|
1392
|
+
className: cls,
|
|
1393
|
+
onClick: () => {
|
|
1394
|
+
action.onClick?.();
|
|
1395
|
+
setOpen(false);
|
|
1396
|
+
},
|
|
1397
|
+
children: inner
|
|
1194
1398
|
},
|
|
1195
1399
|
action.label
|
|
1196
1400
|
);
|
|
1197
1401
|
})
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1402
|
+
] })
|
|
1403
|
+
] })
|
|
1200
1404
|
] });
|
|
1201
1405
|
}
|
|
1202
1406
|
|
|
@@ -1210,20 +1414,20 @@ function extractApiError(err, fallbackMessage = "Ocorreu um erro inesperado.") {
|
|
|
1210
1414
|
}
|
|
1211
1415
|
|
|
1212
1416
|
// src/hooks/use-disclosure.ts
|
|
1213
|
-
var
|
|
1417
|
+
var import_react8 = require("react");
|
|
1214
1418
|
function useDisclosure(initial = false) {
|
|
1215
|
-
const [open, setOpen] = (0,
|
|
1216
|
-
const onOpen = (0,
|
|
1217
|
-
const onClose = (0,
|
|
1218
|
-
const onToggle = (0,
|
|
1419
|
+
const [open, setOpen] = (0, import_react8.useState)(initial);
|
|
1420
|
+
const onOpen = (0, import_react8.useCallback)(() => setOpen(true), []);
|
|
1421
|
+
const onClose = (0, import_react8.useCallback)(() => setOpen(false), []);
|
|
1422
|
+
const onToggle = (0, import_react8.useCallback)(() => setOpen((v) => !v), []);
|
|
1219
1423
|
return { open, onOpen, onClose, onToggle, setOpen };
|
|
1220
1424
|
}
|
|
1221
1425
|
|
|
1222
1426
|
// src/hooks/use-toast.ts
|
|
1223
1427
|
var import_sonner2 = require("sonner");
|
|
1224
|
-
var
|
|
1428
|
+
var import_react9 = require("react");
|
|
1225
1429
|
function useCustomToast() {
|
|
1226
|
-
const showToast = (0,
|
|
1430
|
+
const showToast = (0, import_react9.useCallback)(
|
|
1227
1431
|
(title, description, status = "success") => {
|
|
1228
1432
|
switch (status) {
|
|
1229
1433
|
case "success":
|
|
@@ -1272,12 +1476,14 @@ function useCustomToast() {
|
|
|
1272
1476
|
ThemeProvider,
|
|
1273
1477
|
Toaster,
|
|
1274
1478
|
UserMenu,
|
|
1479
|
+
applyTenantTheme,
|
|
1275
1480
|
cn,
|
|
1276
1481
|
defaultRenderLink,
|
|
1277
1482
|
extractApiError,
|
|
1278
1483
|
toast,
|
|
1279
1484
|
useCustomToast,
|
|
1280
1485
|
useDisclosure,
|
|
1486
|
+
useIsDesktop,
|
|
1281
1487
|
useTheme
|
|
1282
1488
|
});
|
|
1283
1489
|
//# sourceMappingURL=index.cjs.map
|