@motor-hero/ui-kit 0.48.1 → 0.50.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
@@ -261,6 +261,8 @@ function AppShell({
261
261
  defaultCollapsed = false,
262
262
  sidebarFooter,
263
263
  banner,
264
+ sidebarClassName,
265
+ headerClassName,
264
266
  children
265
267
  }) {
266
268
  const [collapsed, setCollapsed] = useState3(defaultCollapsed);
@@ -281,18 +283,21 @@ function AppShell({
281
283
  /* @__PURE__ */ jsxs3(
282
284
  "aside",
283
285
  {
286
+ "data-slot": "sidebar",
284
287
  className: cn(
285
288
  "hidden shrink-0 flex-col border-r bg-card transition-all duration-300 md:flex",
286
- collapsed ? "w-16" : "w-60"
289
+ collapsed ? "w-16" : "w-60",
290
+ sidebarClassName
287
291
  ),
288
292
  children: [
289
- /* @__PURE__ */ jsx4("div", { className: "flex h-14 shrink-0 items-center border-b px-4", children: collapsed ? brandCollapsed ?? brand : brand }),
290
- /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto px-2 py-4", children: nav(collapsed) }),
291
- sidebarFooter && /* @__PURE__ */ jsx4("div", { className: "border-t px-3 py-2", "data-slot": "sidebar-footer", children: typeof sidebarFooter === "function" ? sidebarFooter(collapsed) : sidebarFooter }),
292
- collapsible && /* @__PURE__ */ jsx4("div", { className: "border-t p-2", children: /* @__PURE__ */ jsx4(
293
+ /* @__PURE__ */ jsx4("div", { className: "flex h-14 shrink-0 items-center border-b border-inherit px-4", "data-slot": "sidebar-brand", children: collapsed ? brandCollapsed ?? brand : brand }),
294
+ /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto px-2 py-4", "data-slot": "sidebar-content", children: nav(collapsed) }),
295
+ sidebarFooter && /* @__PURE__ */ jsx4("div", { className: "border-t border-inherit px-3 py-2", "data-slot": "sidebar-footer", children: typeof sidebarFooter === "function" ? sidebarFooter(collapsed) : sidebarFooter }),
296
+ collapsible && /* @__PURE__ */ jsx4("div", { className: "border-t border-inherit p-2", children: /* @__PURE__ */ jsx4(
293
297
  "button",
294
298
  {
295
299
  type: "button",
300
+ "data-slot": "sidebar-toggle",
296
301
  onClick: () => setCollapsed((v) => !v),
297
302
  className: "flex w-full items-center justify-center rounded-md px-2 py-2 text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground",
298
303
  "aria-label": collapsed ? "Expandir menu" : "Recolher menu",
@@ -315,14 +320,16 @@ function AppShell({
315
320
  /* @__PURE__ */ jsxs3(
316
321
  "div",
317
322
  {
323
+ "data-slot": "sidebar-drawer",
318
324
  className: cn(
319
325
  "absolute left-0 top-0 flex h-full w-64 flex-col border-r bg-card transition-transform duration-300",
320
- mobileOpen ? "translate-x-0" : "-translate-x-full"
326
+ mobileOpen ? "translate-x-0" : "-translate-x-full",
327
+ sidebarClassName
321
328
  ),
322
329
  onClick: (e) => e.stopPropagation(),
323
330
  children: [
324
- /* @__PURE__ */ jsx4("div", { className: "flex h-14 shrink-0 items-center border-b px-4", children: brand }),
325
- /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto px-2 py-4", children: nav(false, () => setMobileOpen(false)) })
331
+ /* @__PURE__ */ jsx4("div", { className: "flex h-14 shrink-0 items-center border-b border-inherit px-4", "data-slot": "sidebar-brand", children: brand }),
332
+ /* @__PURE__ */ jsx4("div", { className: "flex-1 overflow-y-auto px-2 py-4", "data-slot": "sidebar-content", children: nav(false, () => setMobileOpen(false)) })
326
333
  ]
327
334
  }
328
335
  )
@@ -331,22 +338,29 @@ function AppShell({
331
338
  ),
332
339
  /* @__PURE__ */ jsxs3("div", { className: "flex flex-1 flex-col overflow-hidden", children: [
333
340
  banner,
334
- /* @__PURE__ */ jsxs3("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4", children: [
335
- /* @__PURE__ */ jsx4(
336
- "button",
337
- {
338
- type: "button",
339
- onClick: () => setMobileOpen(true),
340
- className: "inline-flex h-9 w-9 max-sm:h-10 max-sm:w-10 items-center justify-center rounded-md border border-input bg-background shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground md:hidden",
341
- "aria-label": "Abrir menu",
342
- children: /* @__PURE__ */ jsx4(Menu, { className: "h-4 w-4" })
343
- }
344
- ),
345
- /* @__PURE__ */ jsxs3("div", { className: "ml-auto flex items-center gap-2", children: [
346
- headerActions,
347
- (user || onLogout) && /* @__PURE__ */ jsx4(UserMenu, { user, items: userMenuItems, onLogout, renderLink })
348
- ] })
349
- ] }),
341
+ /* @__PURE__ */ jsxs3(
342
+ "header",
343
+ {
344
+ "data-slot": "header",
345
+ className: cn("flex h-14 shrink-0 items-center gap-2 border-b bg-background px-4", headerClassName),
346
+ children: [
347
+ /* @__PURE__ */ jsx4(
348
+ "button",
349
+ {
350
+ type: "button",
351
+ onClick: () => setMobileOpen(true),
352
+ className: "inline-flex h-9 w-9 max-sm:h-10 max-sm:w-10 items-center justify-center rounded-md border border-input bg-background shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground md:hidden",
353
+ "aria-label": "Abrir menu",
354
+ children: /* @__PURE__ */ jsx4(Menu, { className: "h-4 w-4" })
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsxs3("div", { className: "ml-auto flex items-center gap-2", children: [
358
+ headerActions,
359
+ (user || onLogout) && /* @__PURE__ */ jsx4(UserMenu, { user, items: userMenuItems, onLogout, renderLink })
360
+ ] })
361
+ ]
362
+ }
363
+ ),
350
364
  /* @__PURE__ */ jsx4("main", { className: "flex-1 overflow-y-auto", children })
351
365
  ] })
352
366
  ] });
@@ -1970,6 +1984,7 @@ function PageHeader({ title, description, action, className }) {
1970
1984
  }
1971
1985
 
1972
1986
  // src/components/pagination.tsx
1987
+ import { useId as useId2, useState as useState11 } from "react";
1973
1988
  import { jsx as jsx23, jsxs as jsxs19 } from "react/jsx-runtime";
1974
1989
  var navButtonClass2 = "inline-flex h-8 max-sm:h-10 items-center justify-center rounded-md border border-input bg-background px-3 text-xs font-medium shadow-sm transition-colors hover:bg-accent hover:text-accent-foreground cursor-pointer disabled:pointer-events-none disabled:opacity-50";
1975
1990
  function Pagination({
@@ -1978,6 +1993,7 @@ function Pagination({
1978
1993
  hasNextPage,
1979
1994
  hasPreviousPage,
1980
1995
  totalPages,
1996
+ showPageJump = false,
1981
1997
  showPageSizeSelector = false,
1982
1998
  pageSize,
1983
1999
  onPageSizeChange,
@@ -2013,7 +2029,7 @@ function Pagination({
2013
2029
  children: "Anterior"
2014
2030
  }
2015
2031
  ),
2016
- /* @__PURE__ */ jsxs19("span", { className: "text-sm text-muted-foreground", children: [
2032
+ showPageJump && totalPages !== void 0 ? /* @__PURE__ */ jsx23(PageJumpInput, { page, totalPages, onPageChange }) : /* @__PURE__ */ jsxs19("span", { className: "text-sm text-muted-foreground", children: [
2017
2033
  "P\xE1gina ",
2018
2034
  page,
2019
2035
  totalPages ? ` de ${totalPages}` : ""
@@ -2033,6 +2049,50 @@ function Pagination({
2033
2049
  }
2034
2050
  );
2035
2051
  }
2052
+ function PageJumpInput({ page, totalPages, onPageChange }) {
2053
+ const inputId = useId2();
2054
+ const [draft, setDraft] = useState11(null);
2055
+ const [prevPage, setPrevPage] = useState11(page);
2056
+ if (page !== prevPage) {
2057
+ setPrevPage(page);
2058
+ setDraft(null);
2059
+ }
2060
+ const commit = () => {
2061
+ if (draft === null) return;
2062
+ setDraft(null);
2063
+ if (draft === "") return;
2064
+ const target = Math.max(1, Math.min(Number(draft), totalPages));
2065
+ if (target !== page) onPageChange(target);
2066
+ };
2067
+ return /* @__PURE__ */ jsxs19("span", { className: "flex items-center gap-1.5 whitespace-nowrap text-sm text-muted-foreground", children: [
2068
+ /* @__PURE__ */ jsx23("label", { htmlFor: inputId, className: "max-sm:sr-only", children: "P\xE1gina" }),
2069
+ /* @__PURE__ */ jsx23(
2070
+ "input",
2071
+ {
2072
+ id: inputId,
2073
+ type: "text",
2074
+ inputMode: "numeric",
2075
+ enterKeyHint: "go",
2076
+ autoComplete: "off",
2077
+ "aria-label": "Ir para a p\xE1gina",
2078
+ value: draft ?? String(page),
2079
+ onChange: (e) => setDraft(e.target.value.replace(/\D/g, "")),
2080
+ onFocus: (e) => e.target.select(),
2081
+ onBlur: commit,
2082
+ onKeyDown: (e) => {
2083
+ if (e.key === "Enter") commit();
2084
+ else if (e.key === "Escape") setDraft(null);
2085
+ },
2086
+ style: { width: `${String(totalPages).length + 3}ch` },
2087
+ className: "h-8 max-sm:h-10 rounded-md border border-input bg-background px-1.5 text-center text-xs font-medium tabular-nums text-foreground shadow-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring"
2088
+ }
2089
+ ),
2090
+ /* @__PURE__ */ jsxs19("span", { children: [
2091
+ "de ",
2092
+ totalPages
2093
+ ] })
2094
+ ] });
2095
+ }
2036
2096
 
2037
2097
  // src/components/password-input.tsx
2038
2098
  import { Eye, EyeOff } from "lucide-react";
@@ -2155,7 +2215,7 @@ function ResponsiveDataView({
2155
2215
  // src/components/row-actions-menu.tsx
2156
2216
  import * as DropdownMenu3 from "@radix-ui/react-dropdown-menu";
2157
2217
  import { ChevronRight as ChevronRight3, MoreVertical } from "lucide-react";
2158
- import { useState as useState12 } from "react";
2218
+ import { useState as useState13 } from "react";
2159
2219
  import { Drawer as DrawerPrimitive6 } from "vaul";
2160
2220
  import { Fragment as Fragment6, jsx as jsx27, jsxs as jsxs23 } from "react/jsx-runtime";
2161
2221
  var triggerClass = "inline-flex h-8 w-8 max-sm:h-10 max-sm:w-10 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";
@@ -2169,7 +2229,7 @@ function RowActionsMenu({
2169
2229
  renderLink = defaultRenderLink
2170
2230
  }) {
2171
2231
  const isDesktop = useIsDesktop();
2172
- const [open, setOpen] = useState12(false);
2232
+ const [open, setOpen] = useState13(false);
2173
2233
  if (actions.length === 0) return null;
2174
2234
  const trigger = /* @__PURE__ */ jsx27(
2175
2235
  "button",
@@ -2513,14 +2573,14 @@ function Toaster(props) {
2513
2573
  import { RefreshCw } from "lucide-react";
2514
2574
 
2515
2575
  // src/hooks/use-version-check.ts
2516
- import { useCallback as useCallback3, useEffect as useEffect7, useState as useState13 } from "react";
2576
+ import { useCallback as useCallback3, useEffect as useEffect7, useState as useState14 } from "react";
2517
2577
  function useVersionCheck({
2518
2578
  currentBuild,
2519
2579
  url = "/version.json",
2520
2580
  intervalMs = 6e4
2521
2581
  }) {
2522
- const [latestBuild, setLatestBuild] = useState13(null);
2523
- const [staleChecks, setStaleChecks] = useState13(0);
2582
+ const [latestBuild, setLatestBuild] = useState14(null);
2583
+ const [staleChecks, setStaleChecks] = useState14(0);
2524
2584
  useEffect7(() => {
2525
2585
  if (!currentBuild) return;
2526
2586
  let cancelled = false;
@@ -2598,7 +2658,7 @@ function UpdateBanner({
2598
2658
  }
2599
2659
 
2600
2660
  // src/hooks/use-company-subdomain.ts
2601
- import { useState as useState14 } from "react";
2661
+ import { useState as useState15 } from "react";
2602
2662
  var ALWAYS_RESERVED = ["www", "localhost"];
2603
2663
  function getSubdomain(hostname, reservedSubdomains = []) {
2604
2664
  const labels = hostname.split(".");
@@ -2631,7 +2691,7 @@ function useCompanySubdomain(opts = {}) {
2631
2691
  overrideStorageKey = "company-subdomain",
2632
2692
  reservedSubdomains = []
2633
2693
  } = opts;
2634
- const [subdomain] = useState14(() => {
2694
+ const [subdomain] = useState15(() => {
2635
2695
  if (enableOverride) {
2636
2696
  const override = resolveOverride(overrideStorageKey);
2637
2697
  if (override) return override;
@@ -2643,9 +2703,9 @@ function useCompanySubdomain(opts = {}) {
2643
2703
  }
2644
2704
 
2645
2705
  // src/hooks/use-disclosure.ts
2646
- import { useCallback as useCallback4, useState as useState15 } from "react";
2706
+ import { useCallback as useCallback4, useState as useState16 } from "react";
2647
2707
  function useDisclosure(initial = false) {
2648
- const [open, setOpen] = useState15(initial);
2708
+ const [open, setOpen] = useState16(initial);
2649
2709
  const onOpen = useCallback4(() => setOpen(true), []);
2650
2710
  const onClose = useCallback4(() => setOpen(false), []);
2651
2711
  const onToggle = useCallback4(() => setOpen((v) => !v), []);