@motor-hero/ui-kit 0.17.0 → 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/index.js CHANGED
@@ -546,9 +546,11 @@ 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 React4 from "react";
549
+ import * as React5 from "react";
550
550
  import { Drawer as DrawerPrimitive } from "vaul";
551
- import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
551
+
552
+ // src/hooks/use-is-desktop.ts
553
+ import * as React4 from "react";
552
554
  var DESKTOP_QUERY = "(min-width: 640px)";
553
555
  function useIsDesktop() {
554
556
  const [isDesktop, setIsDesktop] = React4.useState(
@@ -563,6 +565,9 @@ function useIsDesktop() {
563
565
  }, []);
564
566
  return isDesktop;
565
567
  }
568
+
569
+ // src/components/combobox.tsx
570
+ import { jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
566
571
  function Combobox({
567
572
  options,
568
573
  value,
@@ -576,7 +581,7 @@ function Combobox({
576
581
  "aria-invalid": ariaInvalid,
577
582
  "aria-describedby": ariaDescribedby
578
583
  }) {
579
- const [open, setOpen] = React4.useState(false);
584
+ const [open, setOpen] = React5.useState(false);
580
585
  const isDesktop = useIsDesktop();
581
586
  const selected = options.find((option) => option.value === value);
582
587
  const trigger = /* @__PURE__ */ jsxs14(
@@ -855,7 +860,7 @@ function Toaster(props) {
855
860
 
856
861
  // src/components/app-shell.tsx
857
862
  import { ChevronLeft, ChevronRight, Menu } from "lucide-react";
858
- import { useState as useState4 } from "react";
863
+ import { useState as useState6 } from "react";
859
864
 
860
865
  // src/components/sidebar-nav.tsx
861
866
  import { Fragment as Fragment3 } from "react";
@@ -904,6 +909,8 @@ function SidebarNav({
904
909
  // src/components/user-menu.tsx
905
910
  import * as DropdownMenu2 from "@radix-ui/react-dropdown-menu";
906
911
  import { LogOut, User } from "lucide-react";
912
+ import { useState as useState5 } from "react";
913
+ import { Drawer as DrawerPrimitive2 } from "vaul";
907
914
  import { Fragment as Fragment5, jsx as jsx24, jsxs as jsxs20 } from "react/jsx-runtime";
908
915
  function initials(user) {
909
916
  const source = user?.name?.trim() || user?.email?.trim();
@@ -913,6 +920,7 @@ function initials(user) {
913
920
  return source.slice(0, 2).toUpperCase();
914
921
  }
915
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";
916
924
  function UserMenu({
917
925
  user,
918
926
  items = [],
@@ -921,51 +929,151 @@ function UserMenu({
921
929
  renderLink = defaultRenderLink,
922
930
  align = "end"
923
931
  }) {
932
+ const isDesktop = useIsDesktop();
933
+ const [open, setOpen] = useState5(false);
924
934
  const label = initials(user);
925
- return /* @__PURE__ */ jsxs20(DropdownMenu2.Root, { children: [
926
- /* @__PURE__ */ jsx24(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx24(
927
- "button",
928
- {
929
- type: "button",
930
- 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-1 focus-visible:ring-ring",
931
- "aria-label": "Menu do usu\xE1rio",
932
- "data-testid": "user-menu",
933
- children: user?.avatarUrl ? /* @__PURE__ */ jsx24("img", { src: user.avatarUrl, alt: user.name ?? user.email ?? "Avatar", className: "h-full w-full object-cover" }) : label ? /* @__PURE__ */ jsx24("span", { children: label }) : /* @__PURE__ */ jsx24(User, { className: "h-4 w-4" })
934
- }
935
- ) }),
936
- /* @__PURE__ */ jsx24(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsxs20(
937
- DropdownMenu2.Content,
938
- {
939
- align,
940
- sideOffset: 6,
941
- 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",
942
- children: [
943
- (user?.name || user?.email) && /* @__PURE__ */ jsxs20(Fragment5, { children: [
944
- /* @__PURE__ */ jsxs20("div", { className: "px-2 py-1.5", children: [
945
- user.name && /* @__PURE__ */ jsx24("p", { className: "truncate text-sm font-medium", children: user.name }),
946
- user.email && /* @__PURE__ */ jsx24("p", { className: "truncate text-xs text-muted-foreground", children: user.email })
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" })
947
969
  ] }),
948
- /* @__PURE__ */ jsx24(DropdownMenu2.Separator, { className: "-mx-1 my-1 h-px bg-border" })
949
- ] }),
950
- items.map(
951
- (item) => item.href ? /* @__PURE__ */ jsx24(DropdownMenu2.Item, { asChild: true, children: renderLink({ href: item.href, className: itemClass, children: /* @__PURE__ */ jsxs20(Fragment5, { children: [
952
- item.icon,
953
- item.label
954
- ] }) }) }, item.label) : /* @__PURE__ */ jsxs20(DropdownMenu2.Item, { className: itemClass, onClick: item.onClick, children: [
955
- item.icon,
956
- item.label
957
- ] }, item.label)
958
- ),
959
- onLogout && /* @__PURE__ */ jsxs20(Fragment5, { children: [
960
- items.length > 0 && /* @__PURE__ */ jsx24(DropdownMenu2.Separator, { className: "-mx-1 my-1 h-px bg-border" }),
961
- /* @__PURE__ */ jsxs20(DropdownMenu2.Item, { className: cn(itemClass, "text-destructive focus:bg-destructive/10"), onClick: onLogout, children: [
962
- /* @__PURE__ */ jsx24(LogOut, { className: "h-4 w-4" }),
963
- logoutLabel
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
+ )
964
1007
  ] })
965
- ] })
966
- ]
967
- }
968
- ) })
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
+ ] })
969
1077
  ] });
970
1078
  }
971
1079
 
@@ -987,8 +1095,8 @@ function AppShell({
987
1095
  defaultCollapsed = false,
988
1096
  children
989
1097
  }) {
990
- const [collapsed, setCollapsed] = useState4(defaultCollapsed);
991
- const [mobileOpen, setMobileOpen] = useState4(false);
1098
+ const [collapsed, setCollapsed] = useState6(defaultCollapsed);
1099
+ const [mobileOpen, setMobileOpen] = useState6(false);
992
1100
  const nav = (isCollapsed, onNavigate) => /* @__PURE__ */ jsx25(
993
1101
  SidebarNav,
994
1102
  {
@@ -1077,8 +1185,12 @@ function AppShell({
1077
1185
  // src/components/row-actions-menu.tsx
1078
1186
  import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
1079
1187
  import { MoreVertical } from "lucide-react";
1188
+ import { useState as useState7 } from "react";
1189
+ import { Drawer as DrawerPrimitive3 } from "vaul";
1080
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";
1081
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";
1082
1194
  function RowActionsMenu({
1083
1195
  actions,
1084
1196
  disabled = false,
@@ -1086,49 +1198,111 @@ function RowActionsMenu({
1086
1198
  label = "A\xE7\xF5es",
1087
1199
  renderLink = defaultRenderLink
1088
1200
  }) {
1201
+ const isDesktop = useIsDesktop();
1202
+ const [open, setOpen] = useState7(false);
1089
1203
  if (actions.length === 0) return null;
1090
- return /* @__PURE__ */ jsxs22(DropdownMenu3.Root, { children: [
1091
- /* @__PURE__ */ jsx26(DropdownMenu3.Trigger, { asChild: true, children: /* @__PURE__ */ jsx26(
1092
- "button",
1093
- {
1094
- type: "button",
1095
- disabled,
1096
- "aria-label": label,
1097
- className: "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-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50",
1098
- children: /* @__PURE__ */ jsx26(MoreVertical, { className: "h-4 w-4" })
1099
- }
1100
- ) }),
1101
- /* @__PURE__ */ jsx26(DropdownMenu3.Portal, { children: /* @__PURE__ */ jsx26(
1102
- DropdownMenu3.Content,
1103
- {
1104
- align,
1105
- sideOffset: 6,
1106
- 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",
1107
- children: actions.map((action) => {
1108
- const cls = cn(itemClass2, action.destructive && "text-destructive focus:bg-destructive/10");
1109
- return action.href ? /* @__PURE__ */ jsx26(DropdownMenu3.Item, { asChild: true, disabled: action.disabled, children: renderLink({
1110
- href: action.href,
1111
- className: cls,
1112
- children: /* @__PURE__ */ jsxs22(Fragment6, { children: [
1113
- action.icon,
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
+ },
1114
1242
  action.label
1115
- ] })
1116
- }) }, action.label) : /* @__PURE__ */ jsxs22(
1117
- DropdownMenu3.Item,
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",
1118
1279
  {
1119
- className: cls,
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",
1120
1293
  disabled: action.disabled,
1121
- onClick: action.onClick,
1122
- children: [
1123
- action.icon,
1124
- action.label
1125
- ]
1294
+ className: cls,
1295
+ onClick: () => {
1296
+ action.onClick?.();
1297
+ setOpen(false);
1298
+ },
1299
+ children: inner
1126
1300
  },
1127
1301
  action.label
1128
1302
  );
1129
1303
  })
1130
- }
1131
- ) })
1304
+ ] })
1305
+ ] })
1132
1306
  ] });
1133
1307
  }
1134
1308
 
@@ -1142,9 +1316,9 @@ function extractApiError(err, fallbackMessage = "Ocorreu um erro inesperado.") {
1142
1316
  }
1143
1317
 
1144
1318
  // src/hooks/use-disclosure.ts
1145
- import { useCallback, useState as useState5 } from "react";
1319
+ import { useCallback, useState as useState8 } from "react";
1146
1320
  function useDisclosure(initial = false) {
1147
- const [open, setOpen] = useState5(initial);
1321
+ const [open, setOpen] = useState8(initial);
1148
1322
  const onOpen = useCallback(() => setOpen(true), []);
1149
1323
  const onClose = useCallback(() => setOpen(false), []);
1150
1324
  const onToggle = useCallback(() => setOpen((v) => !v), []);
@@ -1209,6 +1383,7 @@ export {
1209
1383
  toast,
1210
1384
  useCustomToast,
1211
1385
  useDisclosure,
1386
+ useIsDesktop,
1212
1387
  useTheme
1213
1388
  };
1214
1389
  //# sourceMappingURL=index.js.map