@motor-hero/ui-kit 0.29.0 → 0.31.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.29.0",
3
+ "version": "0.31.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",
@@ -37,6 +37,11 @@ export interface BaseDialogProps {
37
37
  * modal so the bottom-sheet behaves. Pass explicitly to override.
38
38
  */
39
39
  modal?: boolean
40
+ /**
41
+ * Applies backdrop-blur to the overlay behind the dialog.
42
+ * Defaults to true; pass false to keep the plain scrim.
43
+ */
44
+ blurBackdrop?: boolean
40
45
  /**
41
46
  * Advanced: wraps the dialog's inner content (header + body + footer) inside
42
47
  * Content. Used by FormDialog to inject a <form>. Defaults to identity.
@@ -64,6 +69,7 @@ export function BaseDialog({
64
69
  size = "lg",
65
70
  className,
66
71
  modal,
72
+ blurBackdrop = true,
67
73
  contentWrapper = (content) => content,
68
74
  }: BaseDialogProps) {
69
75
  const isDesktop = useIsDesktop()
@@ -106,10 +112,29 @@ export function BaseDialog({
106
112
  </>
107
113
  )
108
114
 
115
+ const isModal = modal ?? !isDesktop
116
+
109
117
  return (
110
- <Dialog.Root open={open} onOpenChange={onOpenChange} modal={modal ?? !isDesktop}>
118
+ <Dialog.Root open={open} onOpenChange={onOpenChange} modal={isModal}>
111
119
  <Dialog.Portal>
112
- <Dialog.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" />
120
+ {isModal ? (
121
+ <Dialog.Overlay
122
+ 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",
124
+ blurBackdrop && "backdrop-blur-sm",
125
+ )}
126
+ />
127
+ ) : (
128
+ // Radix skips Dialog.Overlay when non-modal, so the backdrop is
129
+ // rendered by hand; pointer-events-none keeps outside interactions
130
+ // working (the reason the dialog is non-modal on desktop).
131
+ blurBackdrop && (
132
+ <div
133
+ aria-hidden
134
+ className="pointer-events-none fixed inset-0 z-50 bg-black/80 backdrop-blur-sm animate-in fade-in-0"
135
+ />
136
+ )
137
+ )}
113
138
  <Dialog.Content
114
139
  onCloseAutoFocus={() => {
115
140
  document.body.style.pointerEvents = ""
@@ -1,5 +1,5 @@
1
1
  import * as PopoverPrimitive from "@radix-ui/react-popover"
2
- import { ChevronsUpDown } from "lucide-react"
2
+ import { ChevronsUpDown, X } from "lucide-react"
3
3
  import * as React from "react"
4
4
  import { HexColorInput, HexColorPicker } from "react-colorful"
5
5
  import { cn } from "../lib/utils"
@@ -10,6 +10,11 @@ export interface ColorPickerProps {
10
10
  onChange: (value: string) => void
11
11
  /** Trigger text shown when no color is set. */
12
12
  placeholder?: string
13
+ /**
14
+ * Show a clear (×) affordance when a color is set — emits `onChange("")`
15
+ * so the field can fall back to its default. On by default.
16
+ */
17
+ clearable?: boolean
13
18
  disabled?: boolean
14
19
  id?: string
15
20
  className?: string
@@ -29,6 +34,7 @@ export function ColorPicker({
29
34
  value,
30
35
  onChange,
31
36
  placeholder = "Selecionar cor",
37
+ clearable = true,
32
38
  disabled,
33
39
  id,
34
40
  className,
@@ -37,6 +43,14 @@ export function ColorPicker({
37
43
  }: ColorPickerProps) {
38
44
  const [open, setOpen] = React.useState(false)
39
45
  const color = value || ""
46
+ const showClear = clearable && !!color && !disabled
47
+
48
+ const clear = (event: React.SyntheticEvent) => {
49
+ // Inside the popover trigger — don't let the click also toggle it open.
50
+ event.stopPropagation()
51
+ event.preventDefault()
52
+ onChange("")
53
+ }
40
54
 
41
55
  return (
42
56
  <PopoverPrimitive.Root open={open} onOpenChange={setOpen}>
@@ -48,7 +62,7 @@ export function ColorPicker({
48
62
  aria-describedby={ariaDescribedby}
49
63
  disabled={disabled}
50
64
  className={cn(
51
- "flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
65
+ "flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors hover:border-ring/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
52
66
  className,
53
67
  )}
54
68
  >
@@ -72,7 +86,25 @@ export function ColorPicker({
72
86
  {color || placeholder}
73
87
  </span>
74
88
  </span>
75
- <ChevronsUpDown className="h-4 w-4 shrink-0 opacity-50" />
89
+ <span className="flex shrink-0 items-center gap-1">
90
+ {showClear && (
91
+ // Not a <button> — nesting one inside the trigger button is
92
+ // invalid HTML.
93
+ <span
94
+ role="button"
95
+ tabIndex={0}
96
+ aria-label="Limpar cor"
97
+ onClick={clear}
98
+ onKeyDown={(event) => {
99
+ if (event.key === "Enter" || event.key === " ") clear(event)
100
+ }}
101
+ className="rounded p-0.5 text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
102
+ >
103
+ <X className="h-3.5 w-3.5" />
104
+ </span>
105
+ )}
106
+ <ChevronsUpDown className="h-4 w-4 shrink-0 opacity-50" />
107
+ </span>
76
108
  </button>
77
109
  </PopoverPrimitive.Trigger>
78
110
  <PopoverPrimitive.Portal>
@@ -130,7 +130,7 @@ export function Combobox({
130
130
  aria-describedby={ariaDescribedby}
131
131
  disabled={disabled}
132
132
  className={cn(
133
- "flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
133
+ "flex h-9 w-full cursor-pointer items-center justify-between gap-2 rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm transition-colors hover:border-ring/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
134
134
  className,
135
135
  )}
136
136
  >
@@ -116,7 +116,7 @@ export function MultiCombobox({
116
116
  }
117
117
  }}
118
118
  className={cn(
119
- "flex min-h-9 w-full cursor-pointer flex-wrap items-center gap-1 rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
119
+ "flex min-h-9 w-full cursor-pointer flex-wrap items-center gap-1 rounded-md border border-input bg-transparent px-3 py-1.5 text-sm shadow-sm transition-colors hover:border-ring/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring aria-disabled:pointer-events-none aria-disabled:opacity-50 aria-invalid:border-destructive aria-invalid:focus-visible:ring-destructive",
120
120
  className,
121
121
  )}
122
122
  >