@motor-hero/ui-kit 0.20.1 → 0.22.1
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 +23 -0
- package/dist/components/color-picker.d.ts.map +1 -0
- package/dist/index.cjs +210 -130
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +215 -136
- package/dist/index.js.map +1 -1
- package/package.json +2 -1
- package/src/components/color-picker.tsx +100 -0
- package/src/components/row-actions-menu.tsx +2 -2
- package/src/index.ts +2 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
|
2
|
+
import { ChevronsUpDown } from "lucide-react"
|
|
3
|
+
import * as React from "react"
|
|
4
|
+
import { HexColorInput, HexColorPicker } from "react-colorful"
|
|
5
|
+
import { cn } from "../lib/utils"
|
|
6
|
+
|
|
7
|
+
export interface ColorPickerProps {
|
|
8
|
+
/** Current color as a hex string (e.g. `#8f27c2`). */
|
|
9
|
+
value?: string | null
|
|
10
|
+
onChange: (value: string) => void
|
|
11
|
+
/** Trigger text shown when no color is set. */
|
|
12
|
+
placeholder?: string
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
id?: string
|
|
15
|
+
className?: string
|
|
16
|
+
"aria-invalid"?: boolean | "true" | "false"
|
|
17
|
+
"aria-describedby"?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Color picker — a brand swatch trigger opening a Popover with a
|
|
22
|
+
* saturation/hue area (react-colorful) and a hex input.
|
|
23
|
+
*
|
|
24
|
+
* Controlled via `value`/`onChange` (hex string, with leading `#`). Forwards
|
|
25
|
+
* `aria-invalid`/`aria-describedby` from FormField and shows a destructive
|
|
26
|
+
* border when invalid, matching the other kit inputs.
|
|
27
|
+
*/
|
|
28
|
+
export function ColorPicker({
|
|
29
|
+
value,
|
|
30
|
+
onChange,
|
|
31
|
+
placeholder = "Selecionar cor",
|
|
32
|
+
disabled,
|
|
33
|
+
id,
|
|
34
|
+
className,
|
|
35
|
+
"aria-invalid": ariaInvalid,
|
|
36
|
+
"aria-describedby": ariaDescribedby,
|
|
37
|
+
}: ColorPickerProps) {
|
|
38
|
+
const [open, setOpen] = React.useState(false)
|
|
39
|
+
const color = value || ""
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<PopoverPrimitive.Root open={open} onOpenChange={setOpen} modal>
|
|
43
|
+
<PopoverPrimitive.Trigger asChild>
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
id={id}
|
|
47
|
+
aria-invalid={ariaInvalid}
|
|
48
|
+
aria-describedby={ariaDescribedby}
|
|
49
|
+
disabled={disabled}
|
|
50
|
+
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",
|
|
52
|
+
className,
|
|
53
|
+
)}
|
|
54
|
+
>
|
|
55
|
+
<span className="flex items-center gap-2 truncate">
|
|
56
|
+
<span
|
|
57
|
+
aria-hidden
|
|
58
|
+
className={cn(
|
|
59
|
+
"h-5 w-5 shrink-0 rounded border border-border",
|
|
60
|
+
!color && "bg-[length:8px_8px] bg-[position:0_0,4px_4px]",
|
|
61
|
+
)}
|
|
62
|
+
style={
|
|
63
|
+
color
|
|
64
|
+
? { backgroundColor: color }
|
|
65
|
+
: {
|
|
66
|
+
backgroundImage:
|
|
67
|
+
"linear-gradient(45deg,var(--color-muted) 25%,transparent 25%,transparent 75%,var(--color-muted) 75%),linear-gradient(45deg,var(--color-muted) 25%,transparent 25%,transparent 75%,var(--color-muted) 75%)",
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
<span className={cn("truncate", !color && "text-muted-foreground")}>
|
|
72
|
+
{color || placeholder}
|
|
73
|
+
</span>
|
|
74
|
+
</span>
|
|
75
|
+
<ChevronsUpDown className="h-4 w-4 shrink-0 opacity-50" />
|
|
76
|
+
</button>
|
|
77
|
+
</PopoverPrimitive.Trigger>
|
|
78
|
+
<PopoverPrimitive.Portal>
|
|
79
|
+
<PopoverPrimitive.Content
|
|
80
|
+
align="start"
|
|
81
|
+
sideOffset={4}
|
|
82
|
+
className="z-50 w-56 rounded-md border bg-popover p-3 text-popover-foreground shadow-md"
|
|
83
|
+
>
|
|
84
|
+
<div className="mh-color-picker flex flex-col gap-3">
|
|
85
|
+
<HexColorPicker color={color} onChange={onChange} />
|
|
86
|
+
<div className="flex items-center gap-2">
|
|
87
|
+
<span className="text-sm text-muted-foreground">#</span>
|
|
88
|
+
<HexColorInput
|
|
89
|
+
color={color}
|
|
90
|
+
onChange={onChange}
|
|
91
|
+
prefixed={false}
|
|
92
|
+
className="flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm uppercase shadow-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
|
|
93
|
+
/>
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
96
|
+
</PopoverPrimitive.Content>
|
|
97
|
+
</PopoverPrimitive.Portal>
|
|
98
|
+
</PopoverPrimitive.Root>
|
|
99
|
+
)
|
|
100
|
+
}
|
|
@@ -58,7 +58,7 @@ export function RowActionsMenu({
|
|
|
58
58
|
|
|
59
59
|
if (isDesktop) {
|
|
60
60
|
return (
|
|
61
|
-
<DropdownMenu.Root open={open} onOpenChange={setOpen}>
|
|
61
|
+
<DropdownMenu.Root open={open} onOpenChange={setOpen} modal={false}>
|
|
62
62
|
<DropdownMenu.Trigger asChild>{trigger}</DropdownMenu.Trigger>
|
|
63
63
|
<DropdownMenu.Portal>
|
|
64
64
|
<DropdownMenu.Content
|
|
@@ -70,7 +70,7 @@ export function RowActionsMenu({
|
|
|
70
70
|
const cls = cn(
|
|
71
71
|
itemClass,
|
|
72
72
|
action.destructive &&
|
|
73
|
-
|
|
73
|
+
"text-destructive focus:bg-destructive/10",
|
|
74
74
|
)
|
|
75
75
|
return action.href ? (
|
|
76
76
|
<DropdownMenu.Item
|
package/src/index.ts
CHANGED
|
@@ -28,6 +28,8 @@ export { SearchInput } from "./components/search-input"
|
|
|
28
28
|
export { PasswordInput } from "./components/password-input"
|
|
29
29
|
export { Combobox } from "./components/combobox"
|
|
30
30
|
export type { ComboboxOption, ComboboxProps } from "./components/combobox"
|
|
31
|
+
export { ColorPicker } from "./components/color-picker"
|
|
32
|
+
export type { ColorPickerProps } from "./components/color-picker"
|
|
31
33
|
export { StatCard } from "./components/stat-card"
|
|
32
34
|
export { DataTableWrapper } from "./components/data-table-wrapper"
|
|
33
35
|
export { MobileCardList } from "./components/mobile-card-list"
|