@definable/ui 0.1.31 → 0.1.32
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.js +10 -10
- package/dist/components/card.js +24 -24
- package/dist/components/command-menu.js +14 -14
- package/dist/components/command.js +5 -5
- package/dist/components/dialog.js +12 -12
- package/dist/components/drawer.js +1 -1
- package/dist/components/dropzone.js +3 -3
- package/dist/components/image-cropper-modal.js +33 -33
- package/dist/components/image-cropper.js +35 -35
- package/dist/components/input.js +1 -1
- package/dist/components/loader.js +1 -1
- package/dist/components/modal.js +28 -28
- package/dist/components/picker.js +2 -2
- package/dist/components/select.js +4 -4
- package/dist/components/selection-bar.js +1 -1
- package/dist/components/sheet.js +28 -28
- package/dist/components/slider.js +5 -5
- package/dist/components/switch.js +1 -1
- package/dist/components/table-mobile.js +37 -37
- package/dist/components/table.js +32 -32
- package/dist/components/tabs.js +1 -1
- package/dist/components/textarea.js +6 -6
- package/dist/components/tooltip.js +5 -5
- package/dist/components/use-toast.js +3 -3
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/components/alert.js
CHANGED
|
@@ -8,7 +8,7 @@ const g = p(
|
|
|
8
8
|
{
|
|
9
9
|
variants: {
|
|
10
10
|
variant: {
|
|
11
|
-
default: "bg-
|
|
11
|
+
default: "bg-secondary text-foreground",
|
|
12
12
|
destructive: "border-destructive/50 text-destructive dark:border-destructive"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
@@ -16,7 +16,7 @@ const g = p(
|
|
|
16
16
|
variant: "default"
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
),
|
|
19
|
+
), x = i.forwardRef(({ className: t, variant: r, isOpen: e, onClose: o, onConfirm: l, title: s, description: n, confirmText: m, cancelText: c, ...f }, u) => e !== void 0 && o && l && s && n ? /* @__PURE__ */ a(
|
|
20
20
|
v,
|
|
21
21
|
{
|
|
22
22
|
isOpen: e,
|
|
@@ -37,8 +37,8 @@ const g = p(
|
|
|
37
37
|
...f
|
|
38
38
|
}
|
|
39
39
|
));
|
|
40
|
-
|
|
41
|
-
const
|
|
40
|
+
x.displayName = "Alert";
|
|
41
|
+
const A = i.forwardRef(({ className: t, ...r }, e) => /* @__PURE__ */ a(
|
|
42
42
|
"h5",
|
|
43
43
|
{
|
|
44
44
|
ref: e,
|
|
@@ -46,8 +46,8 @@ const x = i.forwardRef(({ className: t, ...r }, e) => /* @__PURE__ */ a(
|
|
|
46
46
|
...r
|
|
47
47
|
}
|
|
48
48
|
));
|
|
49
|
-
|
|
50
|
-
const
|
|
49
|
+
A.displayName = "AlertTitle";
|
|
50
|
+
const N = i.forwardRef(({ className: t, ...r }, e) => /* @__PURE__ */ a(
|
|
51
51
|
"div",
|
|
52
52
|
{
|
|
53
53
|
ref: e,
|
|
@@ -55,9 +55,9 @@ const A = i.forwardRef(({ className: t, ...r }, e) => /* @__PURE__ */ a(
|
|
|
55
55
|
...r
|
|
56
56
|
}
|
|
57
57
|
));
|
|
58
|
-
|
|
58
|
+
N.displayName = "AlertDescription";
|
|
59
59
|
export {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
x as Alert,
|
|
61
|
+
N as AlertDescription,
|
|
62
|
+
A as AlertTitle
|
|
63
63
|
};
|
package/dist/components/card.js
CHANGED
|
@@ -1,61 +1,61 @@
|
|
|
1
1
|
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
-
import * as
|
|
3
|
-
import { cn as
|
|
4
|
-
const s =
|
|
2
|
+
import * as t from "react";
|
|
3
|
+
import { cn as o } from "../lib/utils.js";
|
|
4
|
+
const s = t.forwardRef(({ className: a, ...e }, r) => /* @__PURE__ */ d(
|
|
5
5
|
"div",
|
|
6
6
|
{
|
|
7
7
|
ref: r,
|
|
8
|
-
className:
|
|
9
|
-
"rounded-lg border-
|
|
10
|
-
|
|
8
|
+
className: o(
|
|
9
|
+
"rounded-lg border-light bg-card text-card-foreground ",
|
|
10
|
+
a
|
|
11
11
|
),
|
|
12
|
-
...
|
|
12
|
+
...e
|
|
13
13
|
}
|
|
14
14
|
));
|
|
15
15
|
s.displayName = "Card";
|
|
16
|
-
const i =
|
|
16
|
+
const i = t.forwardRef(({ className: a, ...e }, r) => /* @__PURE__ */ d(
|
|
17
17
|
"div",
|
|
18
18
|
{
|
|
19
19
|
ref: r,
|
|
20
|
-
className:
|
|
21
|
-
...
|
|
20
|
+
className: o("flex flex-col space-y-1.5 p-6", a),
|
|
21
|
+
...e
|
|
22
22
|
}
|
|
23
23
|
));
|
|
24
24
|
i.displayName = "CardHeader";
|
|
25
|
-
const
|
|
25
|
+
const l = t.forwardRef(({ className: a, ...e }, r) => /* @__PURE__ */ d(
|
|
26
26
|
"h3",
|
|
27
27
|
{
|
|
28
28
|
ref: r,
|
|
29
|
-
className:
|
|
30
|
-
...
|
|
29
|
+
className: o("text-lg font-semibold leading-none tracking-tight", a),
|
|
30
|
+
...e
|
|
31
31
|
}
|
|
32
32
|
));
|
|
33
|
-
|
|
34
|
-
const
|
|
33
|
+
l.displayName = "CardTitle";
|
|
34
|
+
const c = t.forwardRef(({ className: a, ...e }, r) => /* @__PURE__ */ d(
|
|
35
35
|
"p",
|
|
36
36
|
{
|
|
37
37
|
ref: r,
|
|
38
|
-
className:
|
|
39
|
-
...
|
|
38
|
+
className: o("text-sm text-muted-foreground", a),
|
|
39
|
+
...e
|
|
40
40
|
}
|
|
41
41
|
));
|
|
42
|
-
|
|
43
|
-
const m =
|
|
42
|
+
c.displayName = "CardDescription";
|
|
43
|
+
const m = t.forwardRef(({ className: a, ...e }, r) => /* @__PURE__ */ d("div", { ref: r, className: o("p-6 pt-0", a), ...e }));
|
|
44
44
|
m.displayName = "CardContent";
|
|
45
|
-
const n =
|
|
45
|
+
const n = t.forwardRef(({ className: a, ...e }, r) => /* @__PURE__ */ d(
|
|
46
46
|
"div",
|
|
47
47
|
{
|
|
48
48
|
ref: r,
|
|
49
|
-
className:
|
|
50
|
-
...
|
|
49
|
+
className: o("flex items-center p-6 pt-0", a),
|
|
50
|
+
...e
|
|
51
51
|
}
|
|
52
52
|
));
|
|
53
53
|
n.displayName = "CardFooter";
|
|
54
54
|
export {
|
|
55
55
|
s as Card,
|
|
56
56
|
m as CardContent,
|
|
57
|
-
|
|
57
|
+
c as CardDescription,
|
|
58
58
|
n as CardFooter,
|
|
59
59
|
i as CardHeader,
|
|
60
|
-
|
|
60
|
+
l as CardTitle
|
|
61
61
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as e, jsxs as n } from "react/jsx-runtime";
|
|
2
|
-
import { CommandDialog as l, Command as a, CommandInput as i, CommandList as u, CommandEmpty as h, CommandGroup as
|
|
2
|
+
import { CommandDialog as l, Command as a, CommandInput as i, CommandList as u, CommandEmpty as h, CommandGroup as d, CommandItem as s, CommandSeparator as p } from "./command.js";
|
|
3
3
|
import { useEffect as f, useCallback as g, useState as x } from "react";
|
|
4
|
-
import { Home as S, FileText as b, FolderOpen as N, Settings as
|
|
5
|
-
function
|
|
4
|
+
import { Home as S, FileText as b, FolderOpen as N, Settings as y, Search as C } from "lucide-react";
|
|
5
|
+
function w({ open: t, onOpenChange: o }) {
|
|
6
6
|
f(() => {
|
|
7
7
|
const m = (c) => {
|
|
8
8
|
c.key === "k" && (c.metaKey || c.ctrlKey) && (c.preventDefault(), o(!t));
|
|
@@ -16,9 +16,9 @@ function y({ open: t, onOpenChange: o }) {
|
|
|
16
16
|
/* @__PURE__ */ e(i, { placeholder: "Type a command or search..." }),
|
|
17
17
|
/* @__PURE__ */ n(u, { children: [
|
|
18
18
|
/* @__PURE__ */ e(h, { children: "No results found." }),
|
|
19
|
-
/* @__PURE__ */ n(
|
|
19
|
+
/* @__PURE__ */ n(d, { heading: "Suggestions", children: [
|
|
20
20
|
/* @__PURE__ */ n(
|
|
21
|
-
|
|
21
|
+
s,
|
|
22
22
|
{
|
|
23
23
|
onSelect: () => r(() => console.log("Home")),
|
|
24
24
|
children: [
|
|
@@ -28,7 +28,7 @@ function y({ open: t, onOpenChange: o }) {
|
|
|
28
28
|
}
|
|
29
29
|
),
|
|
30
30
|
/* @__PURE__ */ n(
|
|
31
|
-
|
|
31
|
+
s,
|
|
32
32
|
{
|
|
33
33
|
onSelect: () => r(() => console.log("Documents")),
|
|
34
34
|
children: [
|
|
@@ -38,7 +38,7 @@ function y({ open: t, onOpenChange: o }) {
|
|
|
38
38
|
}
|
|
39
39
|
),
|
|
40
40
|
/* @__PURE__ */ n(
|
|
41
|
-
|
|
41
|
+
s,
|
|
42
42
|
{
|
|
43
43
|
onSelect: () => r(() => console.log("Projects")),
|
|
44
44
|
children: [
|
|
@@ -49,12 +49,12 @@ function y({ open: t, onOpenChange: o }) {
|
|
|
49
49
|
)
|
|
50
50
|
] }),
|
|
51
51
|
/* @__PURE__ */ e(p, {}),
|
|
52
|
-
/* @__PURE__ */ e(
|
|
53
|
-
|
|
52
|
+
/* @__PURE__ */ e(d, { heading: "Settings", children: /* @__PURE__ */ n(
|
|
53
|
+
s,
|
|
54
54
|
{
|
|
55
55
|
onSelect: () => r(() => console.log("Settings")),
|
|
56
56
|
children: [
|
|
57
|
-
/* @__PURE__ */ e(
|
|
57
|
+
/* @__PURE__ */ e(y, { className: "mr-2 h-4 w-4" }),
|
|
58
58
|
/* @__PURE__ */ e("span", { children: "Settings" })
|
|
59
59
|
]
|
|
60
60
|
}
|
|
@@ -69,9 +69,9 @@ function E() {
|
|
|
69
69
|
"button",
|
|
70
70
|
{
|
|
71
71
|
onClick: () => o(!0),
|
|
72
|
-
className: "inline-flex items-center justify-center gap-1 rounded-md border border-input bg-
|
|
72
|
+
className: "inline-flex items-center justify-center gap-1 rounded-md border border-input bg-secondary px-4 py-2 text-sm font-medium text-foreground hover:bg-accent hover:text-accent-foreground",
|
|
73
73
|
children: [
|
|
74
|
-
/* @__PURE__ */ e(
|
|
74
|
+
/* @__PURE__ */ e(C, { className: "h-4 w-4" }),
|
|
75
75
|
/* @__PURE__ */ e("span", { children: "Search..." }),
|
|
76
76
|
/* @__PURE__ */ n("kbd", { className: "pointer-events-none ml-1 inline-flex h-5 select-none items-center gap-1 rounded border border-input bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground", children: [
|
|
77
77
|
/* @__PURE__ */ e("span", { className: "text-xs", children: "⌘" }),
|
|
@@ -80,10 +80,10 @@ function E() {
|
|
|
80
80
|
]
|
|
81
81
|
}
|
|
82
82
|
),
|
|
83
|
-
/* @__PURE__ */ e(
|
|
83
|
+
/* @__PURE__ */ e(w, { open: t, onOpenChange: o })
|
|
84
84
|
] });
|
|
85
85
|
}
|
|
86
86
|
export {
|
|
87
|
-
|
|
87
|
+
w as CommandMenu,
|
|
88
88
|
E as CommandMenuDemo
|
|
89
89
|
};
|
|
@@ -15,7 +15,7 @@ const i = r.forwardRef(({ className: e, ...a }, o) => /* @__PURE__ */ d(
|
|
|
15
15
|
}
|
|
16
16
|
));
|
|
17
17
|
i.displayName = t.displayName;
|
|
18
|
-
const
|
|
18
|
+
const b = ({
|
|
19
19
|
children: e,
|
|
20
20
|
open: a,
|
|
21
21
|
onOpenChange: o
|
|
@@ -23,7 +23,7 @@ const w = ({
|
|
|
23
23
|
"div",
|
|
24
24
|
{
|
|
25
25
|
className: s(
|
|
26
|
-
"fixed inset-0 z-50 bg-
|
|
26
|
+
"fixed inset-0 z-50 bg-secondary/80 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
|
|
27
27
|
a ? "block" : "hidden"
|
|
28
28
|
),
|
|
29
29
|
onClick: (n) => {
|
|
@@ -32,12 +32,12 @@ const w = ({
|
|
|
32
32
|
children: /* @__PURE__ */ d(
|
|
33
33
|
"div",
|
|
34
34
|
{
|
|
35
|
-
className: "fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%] overflow-hidden rounded-lg border border-
|
|
35
|
+
className: "fixed left-[50%] top-[50%] z-50 w-full max-w-lg translate-x-[-50%] translate-y-[-50%] overflow-hidden rounded-lg border border-light bg-popover shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",
|
|
36
36
|
children: e
|
|
37
37
|
}
|
|
38
38
|
)
|
|
39
39
|
}
|
|
40
|
-
), p = r.forwardRef(({ className: e, ...a }, o) => /* @__PURE__ */ m("div", { className: "flex items-center border-b border-
|
|
40
|
+
), p = r.forwardRef(({ className: e, ...a }, o) => /* @__PURE__ */ m("div", { className: "flex items-center border-b border-light px-3", "cmdk-input-wrapper": "", children: [
|
|
41
41
|
/* @__PURE__ */ d(l, { className: "mr-2 h-4 w-4 shrink-0 opacity-50" }),
|
|
42
42
|
/* @__PURE__ */ d(
|
|
43
43
|
t.Input,
|
|
@@ -105,7 +105,7 @@ const g = r.forwardRef(({ className: e, ...a }, o) => /* @__PURE__ */ d(
|
|
|
105
105
|
g.displayName = t.Item.displayName;
|
|
106
106
|
export {
|
|
107
107
|
i as Command,
|
|
108
|
-
|
|
108
|
+
b as CommandDialog,
|
|
109
109
|
f as CommandEmpty,
|
|
110
110
|
u as CommandGroup,
|
|
111
111
|
p as CommandInput,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import * as
|
|
1
|
+
import { jsx as o, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import * as l 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 w = ({ ...e }) => /* @__PURE__ */ o(a.Root, { ...e }), C = a.Trigger,
|
|
6
|
+
import { motion as n, AnimatePresence as p } from "framer-motion";
|
|
7
|
+
const w = ({ ...e }) => /* @__PURE__ */ o(a.Root, { ...e }), C = a.Trigger, g = a.Portal, R = a.Close, c = l.forwardRef(({ className: e, ...i }, t) => /* @__PURE__ */ o(
|
|
8
8
|
a.Overlay,
|
|
9
9
|
{
|
|
10
10
|
ref: t,
|
|
@@ -14,7 +14,7 @@ const w = ({ ...e }) => /* @__PURE__ */ o(a.Root, { ...e }), C = a.Trigger, p =
|
|
|
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,7 +26,7 @@ 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 f =
|
|
29
|
+
const f = l.forwardRef(({ className: e, children: i, ...t }, d) => /* @__PURE__ */ o(g, { children: /* @__PURE__ */ r(p, { mode: "wait", children: [
|
|
30
30
|
/* @__PURE__ */ o(c, {}),
|
|
31
31
|
/* @__PURE__ */ o(
|
|
32
32
|
a.Content,
|
|
@@ -34,11 +34,11 @@ const f = r.forwardRef(({ className: e, children: i, ...t }, d) => /* @__PURE__
|
|
|
34
34
|
ref: d,
|
|
35
35
|
asChild: !0,
|
|
36
36
|
...t,
|
|
37
|
-
children: /* @__PURE__ */
|
|
37
|
+
children: /* @__PURE__ */ r(
|
|
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%" },
|
|
@@ -47,7 +47,7 @@ const f = r.forwardRef(({ className: e, children: i, ...t }, d) => /* @__PURE__
|
|
|
47
47
|
transition: { duration: 0.2 },
|
|
48
48
|
children: [
|
|
49
49
|
i,
|
|
50
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ r(a.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
51
51
|
/* @__PURE__ */ o(m, { className: "h-4 w-4" }),
|
|
52
52
|
/* @__PURE__ */ o("span", { className: "sr-only", children: "Close" })
|
|
53
53
|
] })
|
|
@@ -86,7 +86,7 @@ const x = ({
|
|
|
86
86
|
}
|
|
87
87
|
);
|
|
88
88
|
x.displayName = "DialogFooter";
|
|
89
|
-
const u =
|
|
89
|
+
const u = l.forwardRef(({ className: e, ...i }, t) => /* @__PURE__ */ o(
|
|
90
90
|
a.Title,
|
|
91
91
|
{
|
|
92
92
|
ref: t,
|
|
@@ -98,7 +98,7 @@ const u = r.forwardRef(({ className: e, ...i }, t) => /* @__PURE__ */ o(
|
|
|
98
98
|
}
|
|
99
99
|
));
|
|
100
100
|
u.displayName = a.Title.displayName;
|
|
101
|
-
const N =
|
|
101
|
+
const N = l.forwardRef(({ className: e, ...i }, t) => /* @__PURE__ */ o(
|
|
102
102
|
a.Description,
|
|
103
103
|
{
|
|
104
104
|
ref: t,
|
|
@@ -115,7 +115,7 @@ export {
|
|
|
115
115
|
x as DialogFooter,
|
|
116
116
|
y as DialogHeader,
|
|
117
117
|
c as DialogOverlay,
|
|
118
|
-
|
|
118
|
+
g as DialogPortal,
|
|
119
119
|
u as DialogTitle,
|
|
120
120
|
C as DialogTrigger
|
|
121
121
|
};
|
|
@@ -60,7 +60,7 @@ const c = m.forwardRef(({ className: r, children: t, ...a }, l) => /* @__PURE__
|
|
|
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,
|
|
@@ -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
|
};
|
|
@@ -12,46 +12,46 @@ function O({
|
|
|
12
12
|
title: U = "Crop Your Image",
|
|
13
13
|
outputSize: h = 200
|
|
14
14
|
}) {
|
|
15
|
-
const [t, w] = x({ x: 0, y: 0, size: 100 }), [N, y] = x(!1), [
|
|
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, y] = 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
|
-
y(!0), X({ x: n - t.x, y:
|
|
35
|
+
y(!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,
|
|
54
|
+
}, [N, C, k, r, t]), $ = m(() => {
|
|
55
55
|
y(!1), z(!1);
|
|
56
56
|
}, []), H = m(() => {
|
|
57
57
|
if (r.width && r.height) {
|
|
@@ -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 =
|
|
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
70
|
e.width = h, e.height = h;
|
|
71
|
-
const n = a.naturalWidth / r.width,
|
|
72
|
-
|
|
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(h / 2, h / 2, h / 2, 0, Math.PI * 2), o.clip(), o.drawImage(
|
|
73
73
|
a,
|
|
74
74
|
l,
|
|
75
75
|
u,
|
|
@@ -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",
|
|
@@ -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
|
}
|
|
@@ -222,7 +222,7 @@ function O({
|
|
|
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",
|