@definable/ui 0.1.31 → 0.1.35
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/alert-dialog.js +15 -15
- package/dist/components/alert.js +21 -21
- package/dist/components/avatar.js +7 -7
- package/dist/components/badge.js +10 -10
- package/dist/components/button.d.ts +1 -1
- package/dist/components/button.js +20 -18
- package/dist/components/calendar.js +26 -26
- package/dist/components/card.js +27 -27
- package/dist/components/carousel.js +39 -39
- package/dist/components/checkbox.js +7 -7
- package/dist/components/collapse.js +17 -17
- package/dist/components/command-menu.js +30 -30
- package/dist/components/command.js +55 -55
- package/dist/components/confirmation-modal.js +23 -23
- package/dist/components/context-menu.js +30 -30
- package/dist/components/dialog.js +33 -33
- package/dist/components/drawer.js +7 -7
- package/dist/components/dropdown-menu.js +16 -16
- package/dist/components/dropzone.js +3 -3
- package/dist/components/image-cropper-modal.js +57 -57
- package/dist/components/image-cropper.js +45 -45
- package/dist/components/input.js +9 -9
- package/dist/components/loader.js +4 -4
- package/dist/components/loading-placeholder.js +4 -4
- package/dist/components/mention.js +18 -18
- package/dist/components/modal.js +39 -39
- package/dist/components/picker.js +30 -30
- package/dist/components/popover.js +7 -7
- package/dist/components/progress.js +13 -13
- package/dist/components/radio-group.js +19 -19
- package/dist/components/scroll-area.js +20 -20
- package/dist/components/select.js +28 -28
- package/dist/components/selection-bar.js +18 -18
- package/dist/components/separator.js +8 -8
- package/dist/components/sheet.js +28 -28
- package/dist/components/skeleton.js +8 -8
- package/dist/components/slider.js +13 -13
- package/dist/components/stepper.js +1 -1
- package/dist/components/switch.js +8 -8
- package/dist/components/table-empty.js +6 -6
- package/dist/components/table-mobile.js +36 -36
- package/dist/components/table.js +80 -80
- package/dist/components/tabs.js +16 -16
- package/dist/components/textarea.js +9 -9
- package/dist/components/tooltip.js +5 -5
- package/dist/components/use-toast.js +9 -9
- package/dist/index.js +1 -1
- package/dist/{stepper-modal-JXpOXOV2.js → stepper-modal-Bh6gsg8o.js} +79 -79
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as i, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import * as r from "react";
|
|
3
3
|
import * as a from "@radix-ui/react-dialog";
|
|
4
4
|
import { cn as s } from "../lib/utils.js";
|
|
5
5
|
import { X as m } from "lucide-react";
|
|
6
|
-
import { motion as n, AnimatePresence as
|
|
7
|
-
const
|
|
6
|
+
import { motion as n, AnimatePresence as p } from "framer-motion";
|
|
7
|
+
const b = ({ ...e }) => /* @__PURE__ */ i(a.Root, { ...e }), C = a.Trigger, f = a.Portal, R = a.Close, c = r.forwardRef(({ className: e, ...o }, t) => /* @__PURE__ */ i(
|
|
8
8
|
a.Overlay,
|
|
9
9
|
{
|
|
10
10
|
ref: t,
|
|
11
11
|
asChild: !0,
|
|
12
|
-
...
|
|
13
|
-
children: /* @__PURE__ */
|
|
12
|
+
...o,
|
|
13
|
+
children: /* @__PURE__ */ i(
|
|
14
14
|
n.div,
|
|
15
15
|
{
|
|
16
16
|
className: s(
|
|
17
|
-
"fixed inset-0 z-50 bg-
|
|
17
|
+
"fixed inset-0 z-50 bg-secondary/80 backdrop-blur-sm",
|
|
18
18
|
e
|
|
19
19
|
),
|
|
20
20
|
initial: { opacity: 0 },
|
|
@@ -26,9 +26,9 @@ const w = ({ ...e }) => /* @__PURE__ */ o(a.Root, { ...e }), C = a.Trigger, p =
|
|
|
26
26
|
}
|
|
27
27
|
));
|
|
28
28
|
c.displayName = a.Overlay.displayName;
|
|
29
|
-
const
|
|
30
|
-
/* @__PURE__ */
|
|
31
|
-
/* @__PURE__ */
|
|
29
|
+
const g = r.forwardRef(({ className: e, children: o, ...t }, d) => /* @__PURE__ */ i(f, { children: /* @__PURE__ */ l(p, { mode: "wait", children: [
|
|
30
|
+
/* @__PURE__ */ i(c, {}),
|
|
31
|
+
/* @__PURE__ */ i(
|
|
32
32
|
a.Content,
|
|
33
33
|
{
|
|
34
34
|
ref: d,
|
|
@@ -38,7 +38,7 @@ const f = r.forwardRef(({ className: e, children: i, ...t }, d) => /* @__PURE__
|
|
|
38
38
|
n.div,
|
|
39
39
|
{
|
|
40
40
|
className: s(
|
|
41
|
-
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg gap-4 border-
|
|
41
|
+
"fixed left-1/2 top-1/2 z-50 grid w-full max-w-lg gap-4 border-light bg-secondary p-6 shadow-lg rounded-lg",
|
|
42
42
|
e
|
|
43
43
|
),
|
|
44
44
|
initial: { opacity: 0, scale: 0.95, x: "-50%", y: "-50%" },
|
|
@@ -46,10 +46,10 @@ const f = r.forwardRef(({ className: e, children: i, ...t }, d) => /* @__PURE__
|
|
|
46
46
|
exit: { opacity: 0, scale: 0.95, x: "-50%", y: "-50%" },
|
|
47
47
|
transition: { duration: 0.2 },
|
|
48
48
|
children: [
|
|
49
|
-
|
|
50
|
-
/* @__PURE__ */ l(a.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-
|
|
51
|
-
/* @__PURE__ */
|
|
52
|
-
/* @__PURE__ */
|
|
49
|
+
o,
|
|
50
|
+
/* @__PURE__ */ l(a.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-white dark:ring-offset-[#1F1F20] transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-black/20 dark:focus:ring-white/20 focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-hover data-[state=open]:text-tertiary", children: [
|
|
51
|
+
/* @__PURE__ */ i(m, { className: "h-4 w-4" }),
|
|
52
|
+
/* @__PURE__ */ i("span", { className: "sr-only", children: "Close" })
|
|
53
53
|
] })
|
|
54
54
|
]
|
|
55
55
|
}
|
|
@@ -57,36 +57,36 @@ const f = r.forwardRef(({ className: e, children: i, ...t }, d) => /* @__PURE__
|
|
|
57
57
|
}
|
|
58
58
|
)
|
|
59
59
|
] }) }));
|
|
60
|
-
|
|
60
|
+
g.displayName = a.Content.displayName;
|
|
61
61
|
const y = ({
|
|
62
62
|
className: e,
|
|
63
|
-
...
|
|
64
|
-
}) => /* @__PURE__ */
|
|
63
|
+
...o
|
|
64
|
+
}) => /* @__PURE__ */ i(
|
|
65
65
|
"div",
|
|
66
66
|
{
|
|
67
67
|
className: s(
|
|
68
68
|
"flex flex-col space-y-1.5 text-center sm:text-left",
|
|
69
69
|
e
|
|
70
70
|
),
|
|
71
|
-
...
|
|
71
|
+
...o
|
|
72
72
|
}
|
|
73
73
|
);
|
|
74
74
|
y.displayName = "DialogHeader";
|
|
75
75
|
const x = ({
|
|
76
76
|
className: e,
|
|
77
|
-
...
|
|
78
|
-
}) => /* @__PURE__ */
|
|
77
|
+
...o
|
|
78
|
+
}) => /* @__PURE__ */ i(
|
|
79
79
|
"div",
|
|
80
80
|
{
|
|
81
81
|
className: s(
|
|
82
82
|
"flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
|
|
83
83
|
e
|
|
84
84
|
),
|
|
85
|
-
...
|
|
85
|
+
...o
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
88
|
x.displayName = "DialogFooter";
|
|
89
|
-
const
|
|
89
|
+
const N = r.forwardRef(({ className: e, ...o }, t) => /* @__PURE__ */ i(
|
|
90
90
|
a.Title,
|
|
91
91
|
{
|
|
92
92
|
ref: t,
|
|
@@ -94,28 +94,28 @@ const u = r.forwardRef(({ className: e, ...i }, t) => /* @__PURE__ */ o(
|
|
|
94
94
|
"text-lg font-semibold leading-none tracking-tight",
|
|
95
95
|
e
|
|
96
96
|
),
|
|
97
|
-
...
|
|
97
|
+
...o
|
|
98
98
|
}
|
|
99
99
|
));
|
|
100
|
-
|
|
101
|
-
const
|
|
100
|
+
N.displayName = a.Title.displayName;
|
|
101
|
+
const h = r.forwardRef(({ className: e, ...o }, t) => /* @__PURE__ */ i(
|
|
102
102
|
a.Description,
|
|
103
103
|
{
|
|
104
104
|
ref: t,
|
|
105
|
-
className: s("text-sm text-
|
|
106
|
-
...
|
|
105
|
+
className: s("text-sm text-tertiary", e),
|
|
106
|
+
...o
|
|
107
107
|
}
|
|
108
108
|
));
|
|
109
|
-
|
|
109
|
+
h.displayName = a.Description.displayName;
|
|
110
110
|
export {
|
|
111
|
-
|
|
111
|
+
b as Dialog,
|
|
112
112
|
R as DialogClose,
|
|
113
|
-
|
|
114
|
-
|
|
113
|
+
g as DialogContent,
|
|
114
|
+
h as DialogDescription,
|
|
115
115
|
x as DialogFooter,
|
|
116
116
|
y as DialogHeader,
|
|
117
117
|
c as DialogOverlay,
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
f as DialogPortal,
|
|
119
|
+
N as DialogTitle,
|
|
120
120
|
C as DialogTrigger
|
|
121
121
|
};
|
|
@@ -44,7 +44,7 @@ const n = ({
|
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
n.displayName = "Drawer";
|
|
47
|
-
const Y = e.Trigger,
|
|
47
|
+
const Y = e.Trigger, c = e.Portal, Z = e.Close, s = m.forwardRef(({ className: r, ...t }, a) => /* @__PURE__ */ o(
|
|
48
48
|
e.Overlay,
|
|
49
49
|
{
|
|
50
50
|
ref: a,
|
|
@@ -53,14 +53,14 @@ const Y = e.Trigger, d = e.Portal, Z = e.Close, s = m.forwardRef(({ className: r
|
|
|
53
53
|
}
|
|
54
54
|
));
|
|
55
55
|
s.displayName = e.Overlay.displayName;
|
|
56
|
-
const
|
|
56
|
+
const d = m.forwardRef(({ className: r, children: t, ...a }, l) => /* @__PURE__ */ p(c, { children: [
|
|
57
57
|
/* @__PURE__ */ o(s, {}),
|
|
58
58
|
/* @__PURE__ */ p(
|
|
59
59
|
e.Content,
|
|
60
60
|
{
|
|
61
61
|
ref: l,
|
|
62
62
|
className: i(
|
|
63
|
-
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[20px] bg-
|
|
63
|
+
"fixed inset-x-0 bottom-0 z-50 mt-24 flex h-auto flex-col rounded-t-[20px] bg-secondary",
|
|
64
64
|
r
|
|
65
65
|
),
|
|
66
66
|
...a,
|
|
@@ -71,7 +71,7 @@ const c = m.forwardRef(({ className: r, children: t, ...a }, l) => /* @__PURE__
|
|
|
71
71
|
}
|
|
72
72
|
)
|
|
73
73
|
] }));
|
|
74
|
-
|
|
74
|
+
d.displayName = "DrawerContent";
|
|
75
75
|
const f = ({
|
|
76
76
|
className: r,
|
|
77
77
|
...t
|
|
@@ -110,7 +110,7 @@ const x = m.forwardRef(({ className: r, ...t }, a) => /* @__PURE__ */ o(
|
|
|
110
110
|
e.Description,
|
|
111
111
|
{
|
|
112
112
|
ref: a,
|
|
113
|
-
className: i("text-sm text-
|
|
113
|
+
className: i("text-sm text-tertiary", r),
|
|
114
114
|
...t
|
|
115
115
|
}
|
|
116
116
|
));
|
|
@@ -118,12 +118,12 @@ x.displayName = e.Description.displayName;
|
|
|
118
118
|
export {
|
|
119
119
|
n as Drawer,
|
|
120
120
|
Z as DrawerClose,
|
|
121
|
-
|
|
121
|
+
d as DrawerContent,
|
|
122
122
|
x as DrawerDescription,
|
|
123
123
|
w as DrawerFooter,
|
|
124
124
|
f as DrawerHeader,
|
|
125
125
|
s as DrawerOverlay,
|
|
126
|
-
|
|
126
|
+
c as DrawerPortal,
|
|
127
127
|
D as DrawerTitle,
|
|
128
128
|
Y as DrawerTrigger
|
|
129
129
|
};
|
|
@@ -2,47 +2,47 @@ import { jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import * as a from "react";
|
|
3
3
|
import * as o from "@radix-ui/react-dropdown-menu";
|
|
4
4
|
import { cn as i } from "../lib/utils.js";
|
|
5
|
-
import { motion as
|
|
6
|
-
const w = o.Root, y = o.Trigger,
|
|
5
|
+
import { motion as m } from "framer-motion";
|
|
6
|
+
const w = o.Root, y = o.Trigger, x = o.Group, D = o.Separator, p = a.forwardRef(({ className: r, sideOffset: t = 4, children: n, ...d }, s) => /* @__PURE__ */ e(o.Portal, { children: /* @__PURE__ */ e(
|
|
7
7
|
o.Content,
|
|
8
8
|
{
|
|
9
9
|
ref: s,
|
|
10
|
-
sideOffset:
|
|
10
|
+
sideOffset: t,
|
|
11
11
|
...d,
|
|
12
12
|
children: /* @__PURE__ */ e(
|
|
13
|
-
|
|
13
|
+
m.div,
|
|
14
14
|
{
|
|
15
15
|
initial: { opacity: 0, scale: 0.95 },
|
|
16
16
|
animate: { opacity: 1, scale: 1 },
|
|
17
17
|
exit: { opacity: 0, scale: 0.95 },
|
|
18
18
|
transition: { duration: 0.2 },
|
|
19
19
|
className: i(
|
|
20
|
-
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-
|
|
21
|
-
|
|
20
|
+
"z-50 min-w-[8rem] overflow-hidden rounded-md border bg-card p-1 text-primary shadow-md",
|
|
21
|
+
r
|
|
22
22
|
),
|
|
23
23
|
children: n
|
|
24
24
|
}
|
|
25
25
|
)
|
|
26
26
|
}
|
|
27
27
|
) }));
|
|
28
|
-
|
|
29
|
-
const
|
|
28
|
+
p.displayName = o.Content.displayName;
|
|
29
|
+
const c = a.forwardRef(({ className: r, ...t }, n) => /* @__PURE__ */ e(
|
|
30
30
|
o.Item,
|
|
31
31
|
{
|
|
32
32
|
ref: n,
|
|
33
33
|
className: i(
|
|
34
|
-
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-
|
|
35
|
-
|
|
34
|
+
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-hover focus:text-primary data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
|
|
35
|
+
r
|
|
36
36
|
),
|
|
37
|
-
...
|
|
37
|
+
...t
|
|
38
38
|
}
|
|
39
39
|
));
|
|
40
|
-
|
|
40
|
+
c.displayName = o.Item.displayName;
|
|
41
41
|
export {
|
|
42
42
|
w as DropdownMenu,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
p as DropdownMenuContent,
|
|
44
|
+
x as DropdownMenuGroup,
|
|
45
|
+
c as DropdownMenuItem,
|
|
46
|
+
D as DropdownMenuSeparator,
|
|
47
47
|
y as DropdownMenuTrigger
|
|
48
48
|
};
|
|
@@ -2,7 +2,7 @@ import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
|
2
2
|
import { useCallback as u } from "react";
|
|
3
3
|
import { useDropzone as b } from "react-dropzone";
|
|
4
4
|
import { Upload as f } from "lucide-react";
|
|
5
|
-
function
|
|
5
|
+
function y({
|
|
6
6
|
onDrop: r,
|
|
7
7
|
children: t,
|
|
8
8
|
className: n = "",
|
|
@@ -30,7 +30,7 @@ function D({
|
|
|
30
30
|
className: n,
|
|
31
31
|
children: [
|
|
32
32
|
/* @__PURE__ */ e("input", { ...p() }),
|
|
33
|
-
c && a && /* @__PURE__ */ e("div", { className: `absolute inset-0 bg-
|
|
33
|
+
c && a && /* @__PURE__ */ e("div", { className: `absolute inset-0 bg-secondary/80 flex items-center justify-center z-10 pointer-events-none ${s}`, children: /* @__PURE__ */ o("div", { className: "border-2 border-dashed border-primary rounded-lg p-8 text-center", children: [
|
|
34
34
|
/* @__PURE__ */ e(f, { className: "h-12 w-12 mb-2 text-primary mx-auto" }),
|
|
35
35
|
/* @__PURE__ */ e("p", { className: "text-base font-medium mb-1", children: "Drop files here" })
|
|
36
36
|
] }) }),
|
|
@@ -40,5 +40,5 @@ function D({
|
|
|
40
40
|
);
|
|
41
41
|
}
|
|
42
42
|
export {
|
|
43
|
-
|
|
43
|
+
y as Dropzone
|
|
44
44
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
1
|
+
import { jsx as s, jsxs as h } from "react/jsx-runtime";
|
|
2
2
|
import { useState as x, useRef as L, useCallback as m, useEffect as E } from "react";
|
|
3
3
|
import { Button as P } from "./button.js";
|
|
4
4
|
import { Modal as q } from "./modal.js";
|
|
@@ -6,53 +6,53 @@ import { Label as T } from "./label.js";
|
|
|
6
6
|
import { RotateCcw as K, X as F, Check as G } from "lucide-react";
|
|
7
7
|
function O({
|
|
8
8
|
isOpen: g,
|
|
9
|
-
onClose:
|
|
9
|
+
onClose: y,
|
|
10
10
|
imageSrc: f,
|
|
11
11
|
onCrop: j,
|
|
12
12
|
title: U = "Crop Your Image",
|
|
13
|
-
outputSize:
|
|
13
|
+
outputSize: d = 200
|
|
14
14
|
}) {
|
|
15
|
-
const [t, w] = x({ x: 0, y: 0, size: 100 }), [N,
|
|
16
|
-
if (
|
|
17
|
-
const e =
|
|
18
|
-
let n,
|
|
19
|
-
a > 1 ? (n =
|
|
20
|
-
const l = Math.min(n,
|
|
15
|
+
const [t, w] = x({ x: 0, y: 0, size: 100 }), [N, v] = x(!1), [C, z] = x(!1), [k, X] = x({ x: 0, y: 0 }), [r, Y] = x({ width: 0, height: 0 }), D = L(null), p = L(null), A = m(() => {
|
|
16
|
+
if (p.current) {
|
|
17
|
+
const e = p.current, o = 400, a = e.naturalWidth / e.naturalHeight;
|
|
18
|
+
let n, i;
|
|
19
|
+
a > 1 ? (n = o, i = o / a) : (i = o, n = o * a), Y({ width: n, height: i });
|
|
20
|
+
const l = Math.min(n, i) * 0.6;
|
|
21
21
|
w({
|
|
22
22
|
x: (n - l) / 2,
|
|
23
|
-
y: (
|
|
23
|
+
y: (i - l) / 2,
|
|
24
24
|
size: l
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
|
-
}, []),
|
|
27
|
+
}, []), b = m((e, o) => {
|
|
28
28
|
e.preventDefault();
|
|
29
|
-
const a = e.currentTarget.getBoundingClientRect(), n = e.clientX - a.left,
|
|
30
|
-
if (
|
|
29
|
+
const a = e.currentTarget.getBoundingClientRect(), n = e.clientX - a.left, i = e.clientY - a.top;
|
|
30
|
+
if (o === "resize") {
|
|
31
31
|
z(!0);
|
|
32
|
-
const l = t.x + t.size / 2, u = t.y + t.size / 2, c = Math.sqrt((n - l) ** 2 + (
|
|
32
|
+
const l = t.x + t.size / 2, u = t.y + t.size / 2, c = Math.sqrt((n - l) ** 2 + (i - u) ** 2);
|
|
33
33
|
X({ x: c, y: 0 });
|
|
34
34
|
} else
|
|
35
|
-
|
|
35
|
+
v(!0), X({ x: n - t.x, y: i - t.y });
|
|
36
36
|
}, [t]), B = m((e) => {
|
|
37
|
-
if (!N && !
|
|
38
|
-
const
|
|
39
|
-
if (
|
|
40
|
-
const
|
|
37
|
+
if (!N && !C) return;
|
|
38
|
+
const o = e.currentTarget.getBoundingClientRect(), a = e.clientX - o.left, n = e.clientY - o.top;
|
|
39
|
+
if (C) {
|
|
40
|
+
const i = t.x + t.size / 2, l = t.y + t.size / 2, u = Math.sqrt((a - i) ** 2 + (n - l) ** 2), c = Math.max(50, Math.min(Math.min(r.width, r.height), u * 2));
|
|
41
41
|
w({
|
|
42
|
-
x: Math.max(0, Math.min(r.width - c,
|
|
42
|
+
x: Math.max(0, Math.min(r.width - c, i - c / 2)),
|
|
43
43
|
y: Math.max(0, Math.min(r.height - c, l - c / 2)),
|
|
44
44
|
size: c
|
|
45
45
|
});
|
|
46
46
|
} else if (N) {
|
|
47
|
-
const
|
|
47
|
+
const i = a - k.x, l = n - k.y, u = r.width - t.size, c = r.height - t.size;
|
|
48
48
|
w((R) => ({
|
|
49
49
|
...R,
|
|
50
|
-
x: Math.max(0, Math.min(u,
|
|
50
|
+
x: Math.max(0, Math.min(u, i)),
|
|
51
51
|
y: Math.max(0, Math.min(c, l))
|
|
52
52
|
}));
|
|
53
53
|
}
|
|
54
|
-
}, [N,
|
|
55
|
-
|
|
54
|
+
}, [N, C, k, r, t]), $ = m(() => {
|
|
55
|
+
v(!1), z(!1);
|
|
56
56
|
}, []), H = m(() => {
|
|
57
57
|
if (r.width && r.height) {
|
|
58
58
|
const e = Math.min(r.width, r.height) * 0.6;
|
|
@@ -63,13 +63,13 @@ function O({
|
|
|
63
63
|
});
|
|
64
64
|
}
|
|
65
65
|
}, [r]), W = m(() => {
|
|
66
|
-
if (!D.current || !
|
|
67
|
-
const e = D.current,
|
|
68
|
-
if (!
|
|
69
|
-
const a =
|
|
70
|
-
e.width =
|
|
71
|
-
const n = a.naturalWidth / r.width,
|
|
72
|
-
|
|
66
|
+
if (!D.current || !p.current) return;
|
|
67
|
+
const e = D.current, o = e.getContext("2d");
|
|
68
|
+
if (!o) return;
|
|
69
|
+
const a = p.current;
|
|
70
|
+
e.width = d, e.height = d;
|
|
71
|
+
const n = a.naturalWidth / r.width, i = a.naturalHeight / r.height, l = t.x * n, u = t.y * i, c = t.size * Math.min(n, i);
|
|
72
|
+
o.beginPath(), o.arc(d / 2, d / 2, d / 2, 0, Math.PI * 2), o.clip(), o.drawImage(
|
|
73
73
|
a,
|
|
74
74
|
l,
|
|
75
75
|
u,
|
|
@@ -77,21 +77,21 @@ function O({
|
|
|
77
77
|
c,
|
|
78
78
|
0,
|
|
79
79
|
0,
|
|
80
|
-
|
|
81
|
-
|
|
80
|
+
d,
|
|
81
|
+
d
|
|
82
82
|
);
|
|
83
83
|
const R = e.toDataURL("image/png");
|
|
84
|
-
j(R),
|
|
85
|
-
}, [t, r, j,
|
|
86
|
-
|
|
87
|
-
}, [
|
|
84
|
+
j(R), y();
|
|
85
|
+
}, [t, r, j, y, d]), M = m(() => {
|
|
86
|
+
v(!1), z(!1), w({ x: 0, y: 0, size: 100 }), y();
|
|
87
|
+
}, [y]), I = m((e) => {
|
|
88
88
|
e.key === "Escape" && g && (e.stopPropagation(), M());
|
|
89
89
|
}, [g, M]);
|
|
90
90
|
return E(() => {
|
|
91
91
|
if (g)
|
|
92
92
|
return document.addEventListener("keydown", I, !0), () => document.removeEventListener("keydown", I, !0);
|
|
93
93
|
}, [g, I]), E(() => {
|
|
94
|
-
g && f && (
|
|
94
|
+
g && f && (v(!1), z(!1), Y({ width: 0, height: 0 }));
|
|
95
95
|
}, [g, f]), f ? /* @__PURE__ */ s(
|
|
96
96
|
q,
|
|
97
97
|
{
|
|
@@ -100,8 +100,8 @@ function O({
|
|
|
100
100
|
title: U,
|
|
101
101
|
size: "2xl",
|
|
102
102
|
zIndexClassName: "z-[60]",
|
|
103
|
-
footer: /* @__PURE__ */
|
|
104
|
-
/* @__PURE__ */
|
|
103
|
+
footer: /* @__PURE__ */ h("div", { className: "flex items-center justify-between w-full", children: [
|
|
104
|
+
/* @__PURE__ */ h(
|
|
105
105
|
P,
|
|
106
106
|
{
|
|
107
107
|
variant: "ghost",
|
|
@@ -114,21 +114,21 @@ function O({
|
|
|
114
114
|
]
|
|
115
115
|
}
|
|
116
116
|
),
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
117
|
+
/* @__PURE__ */ h("div", { className: "flex gap-3", children: [
|
|
118
|
+
/* @__PURE__ */ h(P, { variant: "outline", onClick: M, children: [
|
|
119
119
|
/* @__PURE__ */ s(F, { className: "h-4 w-4 mr-2" }),
|
|
120
120
|
"Cancel"
|
|
121
121
|
] }),
|
|
122
|
-
/* @__PURE__ */
|
|
122
|
+
/* @__PURE__ */ h(P, { onClick: W, children: [
|
|
123
123
|
/* @__PURE__ */ s(G, { className: "h-4 w-4 mr-2" }),
|
|
124
124
|
"Crop Image"
|
|
125
125
|
] })
|
|
126
126
|
] })
|
|
127
127
|
] }),
|
|
128
|
-
children: /* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */ s("div", { className: "text-center", children: /* @__PURE__ */ s("p", { className: "text-sm text-
|
|
131
|
-
/* @__PURE__ */ s("div", { className: "flex justify-center", children: /* @__PURE__ */
|
|
128
|
+
children: /* @__PURE__ */ h("div", { className: "p-6", children: [
|
|
129
|
+
/* @__PURE__ */ h("div", { className: "space-y-6", children: [
|
|
130
|
+
/* @__PURE__ */ s("div", { className: "text-center", children: /* @__PURE__ */ s("p", { className: "text-sm text-tertiary", children: "Drag the circle to move • Drag corners to resize • Click reset to center" }) }),
|
|
131
|
+
/* @__PURE__ */ s("div", { className: "flex justify-center", children: /* @__PURE__ */ h(
|
|
132
132
|
"div",
|
|
133
133
|
{
|
|
134
134
|
className: "relative bg-gray-100 rounded-xl overflow-hidden select-none border",
|
|
@@ -140,7 +140,7 @@ function O({
|
|
|
140
140
|
/* @__PURE__ */ s(
|
|
141
141
|
"img",
|
|
142
142
|
{
|
|
143
|
-
ref:
|
|
143
|
+
ref: p,
|
|
144
144
|
src: f,
|
|
145
145
|
alt: "Crop preview",
|
|
146
146
|
className: "block",
|
|
@@ -149,7 +149,7 @@ function O({
|
|
|
149
149
|
draggable: !1
|
|
150
150
|
}
|
|
151
151
|
),
|
|
152
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ h(
|
|
153
153
|
"div",
|
|
154
154
|
{
|
|
155
155
|
className: "absolute border-2 border-white rounded-full shadow-lg cursor-move",
|
|
@@ -159,7 +159,7 @@ function O({
|
|
|
159
159
|
width: t.size,
|
|
160
160
|
height: t.size
|
|
161
161
|
},
|
|
162
|
-
onMouseDown: (e) =>
|
|
162
|
+
onMouseDown: (e) => b(e, "move"),
|
|
163
163
|
children: [
|
|
164
164
|
/* @__PURE__ */ s("div", { className: "w-full h-full rounded-full border-2 border-primary border-dashed" }),
|
|
165
165
|
/* @__PURE__ */ s(
|
|
@@ -167,7 +167,7 @@ function O({
|
|
|
167
167
|
{
|
|
168
168
|
className: "absolute w-5 h-5 bg-white border-2 border-primary rounded-full shadow-lg cursor-nw-resize -top-2.5 -right-2.5 hover:bg-primary hover:border-white transition-colors flex items-center justify-center",
|
|
169
169
|
onMouseDown: (e) => {
|
|
170
|
-
e.stopPropagation(),
|
|
170
|
+
e.stopPropagation(), b(e, "resize");
|
|
171
171
|
},
|
|
172
172
|
children: /* @__PURE__ */ s("div", { className: "w-1.5 h-1.5 bg-primary rounded-full hover:bg-white transition-colors" })
|
|
173
173
|
}
|
|
@@ -177,7 +177,7 @@ function O({
|
|
|
177
177
|
{
|
|
178
178
|
className: "absolute w-5 h-5 bg-white border-2 border-primary rounded-full shadow-lg cursor-ne-resize -bottom-2.5 -right-2.5 hover:bg-primary hover:border-white transition-colors flex items-center justify-center",
|
|
179
179
|
onMouseDown: (e) => {
|
|
180
|
-
e.stopPropagation(),
|
|
180
|
+
e.stopPropagation(), b(e, "resize");
|
|
181
181
|
},
|
|
182
182
|
children: /* @__PURE__ */ s("div", { className: "w-1.5 h-1.5 bg-primary rounded-full hover:bg-white transition-colors" })
|
|
183
183
|
}
|
|
@@ -187,7 +187,7 @@ function O({
|
|
|
187
187
|
{
|
|
188
188
|
className: "absolute w-5 h-5 bg-white border-2 border-primary rounded-full shadow-lg cursor-sw-resize -bottom-2.5 -left-2.5 hover:bg-primary hover:border-white transition-colors flex items-center justify-center",
|
|
189
189
|
onMouseDown: (e) => {
|
|
190
|
-
e.stopPropagation(),
|
|
190
|
+
e.stopPropagation(), b(e, "resize");
|
|
191
191
|
},
|
|
192
192
|
children: /* @__PURE__ */ s("div", { className: "w-1.5 h-1.5 bg-primary rounded-full hover:bg-white transition-colors" })
|
|
193
193
|
}
|
|
@@ -197,7 +197,7 @@ function O({
|
|
|
197
197
|
{
|
|
198
198
|
className: "absolute w-5 h-5 bg-white border-2 border-primary rounded-full shadow-lg cursor-se-resize -top-2.5 -left-2.5 hover:bg-primary hover:border-white transition-colors flex items-center justify-center",
|
|
199
199
|
onMouseDown: (e) => {
|
|
200
|
-
e.stopPropagation(),
|
|
200
|
+
e.stopPropagation(), b(e, "resize");
|
|
201
201
|
},
|
|
202
202
|
children: /* @__PURE__ */ s("div", { className: "w-1.5 h-1.5 bg-primary rounded-full hover:bg-white transition-colors" })
|
|
203
203
|
}
|
|
@@ -217,12 +217,12 @@ function O({
|
|
|
217
217
|
]
|
|
218
218
|
}
|
|
219
219
|
) }),
|
|
220
|
-
/* @__PURE__ */ s("div", { className: "flex justify-center", children: /* @__PURE__ */
|
|
221
|
-
/* @__PURE__ */ s(T, { className: "text-xs font-medium text-
|
|
220
|
+
/* @__PURE__ */ s("div", { className: "flex justify-center", children: /* @__PURE__ */ h("div", { className: "text-center", children: [
|
|
221
|
+
/* @__PURE__ */ s(T, { className: "text-xs font-medium text-tertiary mb-2 block", children: "Preview" }),
|
|
222
222
|
/* @__PURE__ */ s(
|
|
223
223
|
"div",
|
|
224
224
|
{
|
|
225
|
-
className: "rounded-full border-2 border-
|
|
225
|
+
className: "rounded-full border-2 border-light bg-secondary overflow-hidden mx-auto",
|
|
226
226
|
style: { width: 80, height: 80 },
|
|
227
227
|
children: /* @__PURE__ */ s(
|
|
228
228
|
"div",
|