@motor-hero/ui-kit 0.32.0 → 0.33.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@motor-hero/ui-kit",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "Componentes React reutilizáveis para o ecossistema MotorHero — shadcn/ui + Tailwind CSS v4",
5
5
  "author": "MotorHero",
6
6
  "license": "UNLICENSED",
@@ -42,6 +42,13 @@ export interface BaseDialogProps {
42
42
  * Defaults to true; pass false to keep the plain scrim.
43
43
  */
44
44
  blurBackdrop?: boolean
45
+ /**
46
+ * Extra classes appended to the backdrop/overlay. Use it to tune the scrim
47
+ * per dialog, e.g. `bg-black/40` for a lighter tint or `bg-transparent` to
48
+ * drop the darkening and keep only the blur. Wins over the default via
49
+ * tailwind-merge.
50
+ */
51
+ backdropClassName?: string
45
52
  /**
46
53
  * Advanced: wraps the dialog's inner content (header + body + footer) inside
47
54
  * Content. Used by FormDialog to inject a <form>. Defaults to identity.
@@ -70,6 +77,7 @@ export function BaseDialog({
70
77
  className,
71
78
  modal,
72
79
  blurBackdrop = true,
80
+ backdropClassName,
73
81
  contentWrapper = (content) => content,
74
82
  }: BaseDialogProps) {
75
83
  const isDesktop = useIsDesktop()
@@ -120,18 +128,23 @@ export function BaseDialog({
120
128
  {isModal ? (
121
129
  <Dialog.Overlay
122
130
  className={cn(
123
- "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
131
+ "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
124
132
  blurBackdrop && "backdrop-blur-sm",
133
+ backdropClassName,
125
134
  )}
126
135
  />
127
136
  ) : (
128
137
  // Radix skips Dialog.Overlay when non-modal, so the backdrop is
129
138
  // rendered by hand; pointer-events-none keeps outside interactions
130
139
  // working (the reason the dialog is non-modal on desktop).
131
- blurBackdrop && (
140
+ (blurBackdrop || backdropClassName) && (
132
141
  <div
133
142
  aria-hidden
134
- className="pointer-events-none fixed inset-0 z-50 bg-black/80 backdrop-blur-sm animate-in fade-in-0"
143
+ className={cn(
144
+ "pointer-events-none fixed inset-0 z-50 bg-black/50 animate-in fade-in-0",
145
+ blurBackdrop && "backdrop-blur-sm",
146
+ backdropClassName,
147
+ )}
135
148
  />
136
149
  )
137
150
  )}
@@ -1,6 +1,8 @@
1
1
  import * as AlertDialog from "@radix-ui/react-alert-dialog"
2
2
  import type { ReactNode } from "react"
3
3
 
4
+ import { cn } from "../lib/utils"
5
+
4
6
  interface ConfirmDialogProps {
5
7
  open: boolean
6
8
  onOpenChange: (open: boolean) => void
@@ -11,6 +13,17 @@ interface ConfirmDialogProps {
11
13
  cancelLabel?: string
12
14
  loading?: boolean
13
15
  variant?: "default" | "destructive"
16
+ /**
17
+ * Applies backdrop-blur to the overlay behind the dialog.
18
+ * Defaults to true; pass false to keep the plain scrim.
19
+ */
20
+ blurBackdrop?: boolean
21
+ /**
22
+ * Extra classes appended to the backdrop/overlay. Use it to tune the scrim
23
+ * per dialog, e.g. `bg-black/40` for a lighter tint. Wins over the default
24
+ * via tailwind-merge.
25
+ */
26
+ backdropClassName?: string
14
27
  }
15
28
 
16
29
  export function ConfirmDialog({
@@ -23,11 +36,19 @@ export function ConfirmDialog({
23
36
  cancelLabel = "Cancelar",
24
37
  loading = false,
25
38
  variant = "default",
39
+ blurBackdrop = true,
40
+ backdropClassName,
26
41
  }: ConfirmDialogProps) {
27
42
  return (
28
43
  <AlertDialog.Root open={open} onOpenChange={onOpenChange}>
29
44
  <AlertDialog.Portal>
30
- <AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0" />
45
+ <AlertDialog.Overlay
46
+ className={cn(
47
+ "fixed inset-0 z-50 bg-black/50 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
48
+ blurBackdrop && "backdrop-blur-sm",
49
+ backdropClassName,
50
+ )}
51
+ />
31
52
  <AlertDialog.Content className="fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg -translate-x-1/2 -translate-y-1/2 gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg">
32
53
  <div className="flex flex-col space-y-2 text-center sm:text-left">
33
54
  <AlertDialog.Title className="text-lg font-semibold">{title}</AlertDialog.Title>
@@ -1,31 +1,78 @@
1
- interface PaginationProps {
1
+ export interface PaginationProps {
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
+ /** Exibe o seletor de itens por página. Use com `pageSize`, `onPageSizeChange` e `pageSizeOptions`. */
9
+ showPageSizeSelector?: boolean
10
+ pageSize?: number
11
+ onPageSizeChange?: (size: number) => void
12
+ pageSizeOptions?: number[]
6
13
  className?: string
7
14
  }
8
15
 
9
- export function Pagination({ page, onPageChange, hasNextPage, hasPreviousPage, className }: PaginationProps) {
16
+ const navButtonClass =
17
+ "inline-flex h-8 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"
18
+
19
+ export function Pagination({
20
+ page,
21
+ onPageChange,
22
+ hasNextPage,
23
+ hasPreviousPage,
24
+ totalPages,
25
+ showPageSizeSelector = false,
26
+ pageSize,
27
+ onPageSizeChange,
28
+ pageSizeOptions,
29
+ className,
30
+ }: PaginationProps) {
10
31
  return (
11
- <div className={`flex items-center justify-end gap-4 ${className ?? ""}`}>
12
- <button
13
- type="button"
14
- onClick={() => onPageChange(page - 1)}
15
- disabled={!hasPreviousPage}
16
- className="inline-flex h-8 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"
17
- >
18
- Anterior
19
- </button>
20
- <span className="text-sm text-muted-foreground">Página {page}</span>
21
- <button
22
- type="button"
23
- onClick={() => onPageChange(page + 1)}
24
- disabled={!hasNextPage}
25
- className="inline-flex h-8 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"
26
- >
27
- Próximo
28
- </button>
32
+ <div
33
+ className={`flex items-center ${showPageSizeSelector ? "justify-between" : "justify-end"} gap-4 ${className ?? ""}`}
34
+ >
35
+ {showPageSizeSelector && (
36
+ <div className="flex items-center gap-2">
37
+ <label htmlFor="pagination-page-size" className="text-sm text-muted-foreground">
38
+ Itens por página
39
+ </label>
40
+ <select
41
+ id="pagination-page-size"
42
+ value={pageSize}
43
+ onChange={(e) => onPageSizeChange?.(Number(e.target.value))}
44
+ className="h-8 rounded-md border border-input bg-background px-2 text-xs font-medium shadow-sm transition-colors hover:bg-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring cursor-pointer"
45
+ >
46
+ {(pageSizeOptions ?? []).map((size) => (
47
+ <option key={size} value={size}>
48
+ {size}
49
+ </option>
50
+ ))}
51
+ </select>
52
+ </div>
53
+ )}
54
+ <div className="flex items-center gap-4">
55
+ <button
56
+ type="button"
57
+ onClick={() => onPageChange(page - 1)}
58
+ disabled={!hasPreviousPage}
59
+ className={navButtonClass}
60
+ >
61
+ Anterior
62
+ </button>
63
+ <span className="text-sm text-muted-foreground">
64
+ Página {page}
65
+ {totalPages ? ` de ${totalPages}` : ""}
66
+ </span>
67
+ <button
68
+ type="button"
69
+ onClick={() => onPageChange(page + 1)}
70
+ disabled={!hasNextPage}
71
+ className={navButtonClass}
72
+ >
73
+ Próximo
74
+ </button>
75
+ </div>
29
76
  </div>
30
77
  )
31
78
  }
package/src/index.ts CHANGED
@@ -25,6 +25,7 @@ export { FormDialogLayout, FormDialog } from "./components/form-dialog"
25
25
  export type { FormDialogProps, FormDialogSize } from "./components/form-dialog"
26
26
  export { AuthCard } from "./components/auth-card"
27
27
  export { Pagination } from "./components/pagination"
28
+ export type { PaginationProps } from "./components/pagination"
28
29
  export { TableSkeleton } from "./components/table-skeleton"
29
30
  export { SearchInput } from "./components/search-input"
30
31
  export { PasswordInput } from "./components/password-input"