@motor-hero/ui-kit 0.30.0 → 0.32.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/base-dialog.d.ts +6 -1
- package/dist/components/base-dialog.d.ts.map +1 -1
- package/dist/components/color-picker.d.ts +6 -1
- package/dist/components/color-picker.d.ts.map +1 -1
- package/dist/index.cjs +31 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/base-dialog.tsx +27 -2
- package/src/components/color-picker.tsx +25 -14
package/package.json
CHANGED
|
@@ -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={
|
|
118
|
+
<Dialog.Root open={open} onOpenChange={onOpenChange} modal={isModal}>
|
|
111
119
|
<Dialog.Portal>
|
|
112
|
-
|
|
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,7 +1,11 @@
|
|
|
1
1
|
import * as PopoverPrimitive from "@radix-ui/react-popover"
|
|
2
2
|
import { ChevronsUpDown, X } from "lucide-react"
|
|
3
3
|
import * as React from "react"
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
HexAlphaColorPicker,
|
|
6
|
+
HexColorInput,
|
|
7
|
+
HexColorPicker,
|
|
8
|
+
} from "react-colorful"
|
|
5
9
|
import { cn } from "../lib/utils"
|
|
6
10
|
|
|
7
11
|
export interface ColorPickerProps {
|
|
@@ -15,6 +19,11 @@ export interface ColorPickerProps {
|
|
|
15
19
|
* so the field can fall back to its default. On by default.
|
|
16
20
|
*/
|
|
17
21
|
clearable?: boolean
|
|
22
|
+
/**
|
|
23
|
+
* Accept an alpha channel — the picker gains an opacity slider and the
|
|
24
|
+
* value may be an 8-digit hex (`#RRGGBBAA`). Off by default.
|
|
25
|
+
*/
|
|
26
|
+
alpha?: boolean
|
|
18
27
|
disabled?: boolean
|
|
19
28
|
id?: string
|
|
20
29
|
className?: string
|
|
@@ -35,6 +44,7 @@ export function ColorPicker({
|
|
|
35
44
|
onChange,
|
|
36
45
|
placeholder = "Selecionar cor",
|
|
37
46
|
clearable = true,
|
|
47
|
+
alpha = false,
|
|
38
48
|
disabled,
|
|
39
49
|
id,
|
|
40
50
|
className,
|
|
@@ -69,18 +79,14 @@ export function ColorPicker({
|
|
|
69
79
|
<span className="flex items-center gap-2 truncate">
|
|
70
80
|
<span
|
|
71
81
|
aria-hidden
|
|
72
|
-
className=
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
backgroundImage:
|
|
81
|
-
"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%)",
|
|
82
|
-
}
|
|
83
|
-
}
|
|
82
|
+
className="h-5 w-5 shrink-0 rounded border border-border bg-[length:8px_8px] bg-[position:0_0,4px_4px]"
|
|
83
|
+
style={{
|
|
84
|
+
// The checkerboard stays under the color layer so a
|
|
85
|
+
// translucent value reads as translucent in the swatch.
|
|
86
|
+
backgroundImage: `${
|
|
87
|
+
color ? `linear-gradient(${color},${color}),` : ""
|
|
88
|
+
}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%)`,
|
|
89
|
+
}}
|
|
84
90
|
/>
|
|
85
91
|
<span className={cn("truncate", !color && "text-muted-foreground")}>
|
|
86
92
|
{color || placeholder}
|
|
@@ -114,13 +120,18 @@ export function ColorPicker({
|
|
|
114
120
|
className="z-50 w-56 rounded-md border bg-popover p-3 text-popover-foreground shadow-md"
|
|
115
121
|
>
|
|
116
122
|
<div className="mh-color-picker flex flex-col gap-3">
|
|
117
|
-
|
|
123
|
+
{alpha ? (
|
|
124
|
+
<HexAlphaColorPicker color={color} onChange={onChange} />
|
|
125
|
+
) : (
|
|
126
|
+
<HexColorPicker color={color} onChange={onChange} />
|
|
127
|
+
)}
|
|
118
128
|
<div className="flex items-center gap-2">
|
|
119
129
|
<span className="text-sm text-muted-foreground">#</span>
|
|
120
130
|
<HexColorInput
|
|
121
131
|
color={color}
|
|
122
132
|
onChange={onChange}
|
|
123
133
|
prefixed={false}
|
|
134
|
+
alpha={alpha}
|
|
124
135
|
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"
|
|
125
136
|
/>
|
|
126
137
|
</div>
|