@motor-hero/ui-kit 0.29.0 → 0.30.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/components/color-picker.d.ts +6 -1
- package/dist/components/color-picker.d.ts.map +1 -1
- package/dist/index.cjs +29 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +30 -5
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/color-picker.tsx +35 -3
- package/src/components/combobox.tsx +1 -1
- package/src/components/multi-combobox.tsx +1 -1
package/package.json
CHANGED
|
@@ -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
|
-
<
|
|
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
|
>
|