@motor-hero/ui-kit 0.49.0 → 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.
@@ -1,10 +1,8 @@
1
- export interface PaginationProps {
1
+ interface PaginationBaseProps {
2
2
  page: number;
3
3
  onPageChange: (page: number) => void;
4
4
  hasNextPage: boolean;
5
5
  hasPreviousPage: boolean;
6
- /** Total de páginas. Quando informado, o rótulo vira "Página {page} de {totalPages}". */
7
- totalPages?: number;
8
6
  /** Exibe o seletor de itens por página. Use com `pageSize`, `onPageSizeChange` e `pageSizeOptions`. */
9
7
  showPageSizeSelector?: boolean;
10
8
  pageSize?: number;
@@ -12,5 +10,16 @@ export interface PaginationProps {
12
10
  pageSizeOptions?: number[];
13
11
  className?: string;
14
12
  }
15
- export declare function Pagination({ page, onPageChange, hasNextPage, hasPreviousPage, totalPages, showPageSizeSelector, pageSize, onPageSizeChange, pageSizeOptions, className, }: PaginationProps): import("react").JSX.Element;
13
+ type PageJumpProps = {
14
+ /** Total de páginas. Quando informado, o rótulo vira "Página {page} de {totalPages}". */
15
+ totalPages?: number;
16
+ showPageJump?: false;
17
+ } | {
18
+ totalPages: number;
19
+ /** Torna o número da página editável para pular direto a uma página. Exige `totalPages`. */
20
+ showPageJump: true;
21
+ };
22
+ export type PaginationProps = PaginationBaseProps & PageJumpProps;
23
+ export declare function Pagination({ page, onPageChange, hasNextPage, hasPreviousPage, totalPages, showPageJump, showPageSizeSelector, pageSize, onPageSizeChange, pageSizeOptions, className, }: PaginationProps): import("react").JSX.Element;
24
+ export {};
16
25
  //# sourceMappingURL=pagination.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../src/components/pagination.tsx"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IACpC,WAAW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AAM,eAAe,GAAG,mBAAmB,GAAG,aAAa,CAAA;AAMjE,wBAAgB,UAAU,CAAC,EACzB,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,YAAoB,EACpB,oBAA4B,EAC5B,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,SAAS,GACV,EAAE,eAAe,+BAuDjB"}
package/dist/index.cjs CHANGED
@@ -2064,6 +2064,7 @@ function PageHeader({ title, description, action, className }) {
2064
2064
  }
2065
2065
 
2066
2066
  // src/components/pagination.tsx
2067
+ var import_react7 = require("react");
2067
2068
  var import_jsx_runtime23 = require("react/jsx-runtime");
2068
2069
  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";
2069
2070
  function Pagination({
@@ -2072,6 +2073,7 @@ function Pagination({
2072
2073
  hasNextPage,
2073
2074
  hasPreviousPage,
2074
2075
  totalPages,
2076
+ showPageJump = false,
2075
2077
  showPageSizeSelector = false,
2076
2078
  pageSize,
2077
2079
  onPageSizeChange,
@@ -2107,7 +2109,7 @@ function Pagination({
2107
2109
  children: "Anterior"
2108
2110
  }
2109
2111
  ),
2110
- /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "text-sm text-muted-foreground", children: [
2112
+ showPageJump && totalPages !== void 0 ? /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(PageJumpInput, { page, totalPages, onPageChange }) : /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "text-sm text-muted-foreground", children: [
2111
2113
  "P\xE1gina ",
2112
2114
  page,
2113
2115
  totalPages ? ` de ${totalPages}` : ""
@@ -2127,6 +2129,50 @@ function Pagination({
2127
2129
  }
2128
2130
  );
2129
2131
  }
2132
+ function PageJumpInput({ page, totalPages, onPageChange }) {
2133
+ const inputId = (0, import_react7.useId)();
2134
+ const [draft, setDraft] = (0, import_react7.useState)(null);
2135
+ const [prevPage, setPrevPage] = (0, import_react7.useState)(page);
2136
+ if (page !== prevPage) {
2137
+ setPrevPage(page);
2138
+ setDraft(null);
2139
+ }
2140
+ const commit = () => {
2141
+ if (draft === null) return;
2142
+ setDraft(null);
2143
+ if (draft === "") return;
2144
+ const target = Math.max(1, Math.min(Number(draft), totalPages));
2145
+ if (target !== page) onPageChange(target);
2146
+ };
2147
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { className: "flex items-center gap-1.5 whitespace-nowrap text-sm text-muted-foreground", children: [
2148
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("label", { htmlFor: inputId, className: "max-sm:sr-only", children: "P\xE1gina" }),
2149
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2150
+ "input",
2151
+ {
2152
+ id: inputId,
2153
+ type: "text",
2154
+ inputMode: "numeric",
2155
+ enterKeyHint: "go",
2156
+ autoComplete: "off",
2157
+ "aria-label": "Ir para a p\xE1gina",
2158
+ value: draft ?? String(page),
2159
+ onChange: (e) => setDraft(e.target.value.replace(/\D/g, "")),
2160
+ onFocus: (e) => e.target.select(),
2161
+ onBlur: commit,
2162
+ onKeyDown: (e) => {
2163
+ if (e.key === "Enter") commit();
2164
+ else if (e.key === "Escape") setDraft(null);
2165
+ },
2166
+ style: { width: `${String(totalPages).length + 3}ch` },
2167
+ 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"
2168
+ }
2169
+ ),
2170
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)("span", { children: [
2171
+ "de ",
2172
+ totalPages
2173
+ ] })
2174
+ ] });
2175
+ }
2130
2176
 
2131
2177
  // src/components/password-input.tsx
2132
2178
  var import_lucide_react11 = require("lucide-react");
@@ -2249,7 +2295,7 @@ function ResponsiveDataView({
2249
2295
  // src/components/row-actions-menu.tsx
2250
2296
  var DropdownMenu3 = __toESM(require("@radix-ui/react-dropdown-menu"), 1);
2251
2297
  var import_lucide_react12 = require("lucide-react");
2252
- var import_react7 = require("react");
2298
+ var import_react8 = require("react");
2253
2299
  var import_vaul6 = require("vaul");
2254
2300
  var import_jsx_runtime27 = require("react/jsx-runtime");
2255
2301
  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";
@@ -2263,7 +2309,7 @@ function RowActionsMenu({
2263
2309
  renderLink = defaultRenderLink
2264
2310
  }) {
2265
2311
  const isDesktop = useIsDesktop();
2266
- const [open, setOpen] = (0, import_react7.useState)(false);
2312
+ const [open, setOpen] = (0, import_react8.useState)(false);
2267
2313
  if (actions.length === 0) return null;
2268
2314
  const trigger = /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
2269
2315
  "button",
@@ -2607,15 +2653,15 @@ function Toaster(props) {
2607
2653
  var import_lucide_react13 = require("lucide-react");
2608
2654
 
2609
2655
  // src/hooks/use-version-check.ts
2610
- var import_react8 = require("react");
2656
+ var import_react9 = require("react");
2611
2657
  function useVersionCheck({
2612
2658
  currentBuild,
2613
2659
  url = "/version.json",
2614
2660
  intervalMs = 6e4
2615
2661
  }) {
2616
- const [latestBuild, setLatestBuild] = (0, import_react8.useState)(null);
2617
- const [staleChecks, setStaleChecks] = (0, import_react8.useState)(0);
2618
- (0, import_react8.useEffect)(() => {
2662
+ const [latestBuild, setLatestBuild] = (0, import_react9.useState)(null);
2663
+ const [staleChecks, setStaleChecks] = (0, import_react9.useState)(0);
2664
+ (0, import_react9.useEffect)(() => {
2619
2665
  if (!currentBuild) return;
2620
2666
  let cancelled = false;
2621
2667
  const check = async () => {
@@ -2646,7 +2692,7 @@ function useVersionCheck({
2646
2692
  document.removeEventListener("visibilitychange", onVisible);
2647
2693
  };
2648
2694
  }, [currentBuild, url, intervalMs]);
2649
- const reload = (0, import_react8.useCallback)(() => window.location.reload(), []);
2695
+ const reload = (0, import_react9.useCallback)(() => window.location.reload(), []);
2650
2696
  return { updateAvailable: latestBuild !== null, staleChecks, latestBuild, reload };
2651
2697
  }
2652
2698
 
@@ -2692,7 +2738,7 @@ function UpdateBanner({
2692
2738
  }
2693
2739
 
2694
2740
  // src/hooks/use-company-subdomain.ts
2695
- var import_react9 = require("react");
2741
+ var import_react10 = require("react");
2696
2742
  var ALWAYS_RESERVED = ["www", "localhost"];
2697
2743
  function getSubdomain(hostname, reservedSubdomains = []) {
2698
2744
  const labels = hostname.split(".");
@@ -2725,7 +2771,7 @@ function useCompanySubdomain(opts = {}) {
2725
2771
  overrideStorageKey = "company-subdomain",
2726
2772
  reservedSubdomains = []
2727
2773
  } = opts;
2728
- const [subdomain] = (0, import_react9.useState)(() => {
2774
+ const [subdomain] = (0, import_react10.useState)(() => {
2729
2775
  if (enableOverride) {
2730
2776
  const override = resolveOverride(overrideStorageKey);
2731
2777
  if (override) return override;
@@ -2737,20 +2783,20 @@ function useCompanySubdomain(opts = {}) {
2737
2783
  }
2738
2784
 
2739
2785
  // src/hooks/use-disclosure.ts
2740
- var import_react10 = require("react");
2786
+ var import_react11 = require("react");
2741
2787
  function useDisclosure(initial = false) {
2742
- const [open, setOpen] = (0, import_react10.useState)(initial);
2743
- const onOpen = (0, import_react10.useCallback)(() => setOpen(true), []);
2744
- const onClose = (0, import_react10.useCallback)(() => setOpen(false), []);
2745
- const onToggle = (0, import_react10.useCallback)(() => setOpen((v) => !v), []);
2788
+ const [open, setOpen] = (0, import_react11.useState)(initial);
2789
+ const onOpen = (0, import_react11.useCallback)(() => setOpen(true), []);
2790
+ const onClose = (0, import_react11.useCallback)(() => setOpen(false), []);
2791
+ const onToggle = (0, import_react11.useCallback)(() => setOpen((v) => !v), []);
2746
2792
  return { open, onOpen, onClose, onToggle, setOpen };
2747
2793
  }
2748
2794
 
2749
2795
  // src/hooks/use-toast.ts
2750
2796
  var import_sonner2 = require("sonner");
2751
- var import_react11 = require("react");
2797
+ var import_react12 = require("react");
2752
2798
  function useCustomToast() {
2753
- const showToast = (0, import_react11.useCallback)(
2799
+ const showToast = (0, import_react12.useCallback)(
2754
2800
  (title, description, status = "success") => {
2755
2801
  switch (status) {
2756
2802
  case "success":