@solibo/solibo-ui 0.3.28 → 0.3.30
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/assets/index.css +1 -1
- package/dist/assets/index12.css +1 -1
- package/dist/assets/index13.css +1 -1
- package/dist/assets/index14.css +1 -1
- package/dist/assets/index19.css +1 -1
- package/dist/assets/index20.css +1 -1
- package/dist/assets/index21.css +1 -1
- package/dist/assets/index22.css +1 -1
- package/dist/assets/index23.css +1 -1
- package/dist/assets/index24.css +1 -1
- package/dist/assets/index25.css +1 -1
- package/dist/assets/index26.css +1 -1
- package/dist/assets/index27.css +1 -1
- package/dist/assets/index28.css +1 -1
- package/dist/assets/index29.css +1 -1
- package/dist/assets/index30.css +1 -1
- package/dist/assets/index31.css +1 -1
- package/dist/assets/index33.css +1 -1
- package/dist/assets/index35.css +1 -1
- package/dist/assets/index38.css +1 -1
- package/dist/assets/index40.css +1 -1
- package/dist/assets/index41.css +1 -1
- package/dist/assets/index42.css +1 -1
- package/dist/assets/index43.css +1 -0
- package/dist/assets/index5.css +1 -1
- package/dist/assets/index7.css +1 -1
- package/dist/assets/styles.css +1 -1
- package/dist/components/_avatar/index.cjs +1 -1
- package/dist/components/_avatar/index.js +1 -1
- package/dist/components/_card/index.cjs +1 -1
- package/dist/components/_card/index.js +11 -11
- package/dist/components/_collapsible/index.cjs +1 -1
- package/dist/components/_collapsible/index.cjs.map +1 -1
- package/dist/components/_collapsible/index.js +3 -3
- package/dist/components/_collapsible/index.js.map +1 -1
- package/dist/components/_croppable/index.cjs +1 -1
- package/dist/components/_croppable/index.cjs.map +1 -1
- package/dist/components/_croppable/index.js +238 -159
- package/dist/components/_croppable/index.js.map +1 -1
- package/dist/components/_dropzone/index.cjs +1 -1
- package/dist/components/_dropzone/index.js +1 -1
- package/dist/components/_editor/index.cjs +25 -25
- package/dist/components/_editor/index.cjs.map +1 -1
- package/dist/components/_editor/index.js +1782 -1784
- package/dist/components/_editor/index.js.map +1 -1
- package/dist/components/_messages/index.cjs +1 -1
- package/dist/components/_messages/index.js +1 -1
- package/dist/components/_portal/index.cjs +1 -1
- package/dist/components/_portal/index.js +4 -4
- package/dist/components/_sortable/index.cjs +1 -1
- package/dist/components/_sortable/index.js +1 -1
- package/dist/components/_toasts/index.cjs +1 -1
- package/dist/components/_toasts/index.js +9 -9
- package/dist/components/_widget/index.cjs +1 -1
- package/dist/components/_widget/index.js +1 -1
- package/dist/components/accordion/index.cjs +1 -1
- package/dist/components/accordion/index.js +1 -1
- package/dist/components/aside/index.cjs +1 -1
- package/dist/components/aside/index.js +3 -3
- package/dist/components/button/index.cjs +1 -1
- package/dist/components/button/index.js +15 -15
- package/dist/components/checkbox/index.cjs +1 -1
- package/dist/components/checkbox/index.js +6 -6
- package/dist/components/controls/index.cjs +1 -1
- package/dist/components/controls/index.cjs.map +1 -1
- package/dist/components/controls/index.js +8 -8
- package/dist/components/controls/index.js.map +1 -1
- package/dist/components/dialog/index.cjs +1 -1
- package/dist/components/dialog/index.js +7 -7
- package/dist/components/form/index.cjs +1 -1
- package/dist/components/form/index.js +4 -4
- package/dist/components/header/index.cjs +1 -1
- package/dist/components/header/index.js +3 -3
- package/dist/components/input/index.cjs +1 -1
- package/dist/components/input/index.js +1 -1
- package/dist/components/layout/index.cjs +1 -1
- package/dist/components/layout/index.js +10 -10
- package/dist/components/list/index.cjs +1 -1
- package/dist/components/list/index.js +8 -8
- package/dist/components/nav/index.cjs +1 -1
- package/dist/components/nav/index.cjs.map +1 -1
- package/dist/components/nav/index.js +35 -20
- package/dist/components/nav/index.js.map +1 -1
- package/dist/components/textarea/index.cjs +1 -1
- package/dist/components/textarea/index.js +14 -14
- package/dist/components/toast/index.cjs +1 -1
- package/dist/components/toast/index.js +20 -20
- package/dist/components/toggle/index.cjs +1 -1
- package/dist/components/toggle/index.cjs.map +1 -1
- package/dist/components/toggle/index.js +9 -9
- package/dist/components/toggle/index.js.map +1 -1
- package/dist/components/toolbar/index.cjs +2 -0
- package/dist/components/toolbar/index.cjs.map +1 -0
- package/dist/components/toolbar/index.js +14 -0
- package/dist/components/toolbar/index.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/dist/styles.module-BuPl_9yN.cjs +2 -0
- package/dist/styles.module-BuPl_9yN.cjs.map +1 -0
- package/dist/styles.module-ZrsD4xw8.js +10 -0
- package/dist/styles.module-ZrsD4xw8.js.map +1 -0
- package/package.json +1 -1
- package/dist/styles.module--qoz6wR5.cjs +0 -2
- package/dist/styles.module--qoz6wR5.cjs.map +0 -1
- package/dist/styles.module-y5zmJBcz.js +0 -10
- package/dist/styles.module-y5zmJBcz.js.map +0 -1
|
@@ -1,244 +1,323 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { t as
|
|
3
|
-
import { useRef as
|
|
4
|
-
import {
|
|
1
|
+
import { jsxs as J, jsx as w } from "react/jsx-runtime";
|
|
2
|
+
import { t as rt } from "../../classix-DG18itHa.js";
|
|
3
|
+
import { useRef as y, useState as S, useEffect as E } from "react";
|
|
4
|
+
import { Button as wt } from "../button/index.js";
|
|
5
|
+
import { Figure as yt } from "../figure/index.js";
|
|
5
6
|
import { Icon as xt } from "../icon/index.js";
|
|
6
|
-
import '../../assets/
|
|
7
|
-
croppable:
|
|
8
|
-
|
|
9
|
-
media:
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import '../../assets/index22.css';const Pt = "_croppable_1ykk4_1", Yt = "_empty_1ykk4_14", Xt = "_media_1ykk4_22", At = "_overlay_1ykk4_33", Dt = "_viewport_1ykk4_41", Wt = "_draggable_1ykk4_53", Ht = "_dragging_1ykk4_57", St = "_inner_1ykk4_61", Zt = "_standalone_1ykk4_77", M = {
|
|
8
|
+
croppable: Pt,
|
|
9
|
+
empty: Yt,
|
|
10
|
+
media: Xt,
|
|
11
|
+
overlay: At,
|
|
12
|
+
viewport: Dt,
|
|
13
|
+
draggable: Wt,
|
|
14
|
+
dragging: Ht,
|
|
15
|
+
inner: St,
|
|
16
|
+
standalone: Zt
|
|
17
|
+
}, jt = 192, $ = {
|
|
14
18
|
offset: {
|
|
15
19
|
x: 0,
|
|
16
20
|
y: 0
|
|
17
21
|
},
|
|
18
22
|
zoom: 1
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
}, bt = "Select image", I = 10, Z = 0.1, Bt = 0.92, d = (u, p, _) => Math.min(_, Math.max(p, u)), Nt = (u) => new Promise((p, _) => {
|
|
24
|
+
const h = URL.createObjectURL(u), s = new globalThis.Image();
|
|
25
|
+
s.onload = () => {
|
|
26
|
+
URL.revokeObjectURL(h), p(s);
|
|
27
|
+
}, s.onerror = () => {
|
|
28
|
+
URL.revokeObjectURL(h), _(new Error("croppable-image-load-failed"));
|
|
29
|
+
}, s.src = h;
|
|
30
|
+
}), $t = async ({
|
|
31
|
+
file: u,
|
|
32
|
+
fill: p,
|
|
33
|
+
transform: _,
|
|
34
|
+
viewport: h
|
|
27
35
|
}) => {
|
|
28
|
-
const
|
|
36
|
+
const s = await Nt(u), P = h.width / s.naturalWidth, k = h.height / s.naturalHeight, x = Math.max(P, k), j = s.naturalWidth * x, R = s.naturalHeight * x, C = p === "width" ? Math.max(Z, P / x) : p === "height" ? Math.max(Z, k / x) : Z, L = d(_.zoom, C, I), g = x * L, b = j * L, F = R * L, m = (h.width - b) / 2 + _.offset.x, T = (h.height - F) / 2 + _.offset.y, Y = d((0 - m) / g, 0, s.naturalWidth), v = d((0 - T) / g, 0, s.naturalHeight), U = d(h.width / g, 1, Math.max(1, s.naturalWidth - Y)), c = d(h.height / g, 1, Math.max(1, s.naturalHeight - v)), z = document.createElement("canvas"), a = z.getContext("2d");
|
|
37
|
+
if (!a)
|
|
38
|
+
throw new Error("croppable-image-context-missing");
|
|
39
|
+
z.width = Math.max(1, Math.round(U)), z.height = Math.max(1, Math.round(c)), a.drawImage(s, Y, v, U, c, 0, 0, z.width, z.height);
|
|
40
|
+
const X = u.type.startsWith("image/") ? u.type : "image/jpeg", A = await new Promise((G) => {
|
|
41
|
+
z.toBlob(G, X, Bt);
|
|
42
|
+
});
|
|
43
|
+
if (!A)
|
|
44
|
+
throw new Error("croppable-image-export-failed");
|
|
45
|
+
return new globalThis.File([A], u.name, {
|
|
46
|
+
lastModified: Date.now(),
|
|
47
|
+
type: A.type || X
|
|
48
|
+
});
|
|
49
|
+
}, Ct = ({
|
|
50
|
+
children: u,
|
|
51
|
+
fill: p = "none",
|
|
52
|
+
height: _,
|
|
53
|
+
image: h,
|
|
54
|
+
label: s,
|
|
55
|
+
onCroppableChange: P,
|
|
56
|
+
onFileChange: k,
|
|
57
|
+
onImageChange: x,
|
|
58
|
+
onTransformChange: j,
|
|
59
|
+
transform: R,
|
|
60
|
+
standalone: C
|
|
61
|
+
}) => {
|
|
62
|
+
const L = y(null), g = y(null), b = y(null), F = y(null), m = y(x), T = y(null), Y = y(null), v = y(null), U = y(/* @__PURE__ */ new Map()), c = y($), z = y(null), [a, X] = S(null), [A, G] = S(null), [ot, tt] = S(!1), [zt, ct] = S($), [q, it] = S(null), [f, Mt] = S({
|
|
29
63
|
width: 0,
|
|
30
64
|
height: 0
|
|
31
|
-
}),
|
|
32
|
-
const t = f.width,
|
|
33
|
-
if (!t || !
|
|
65
|
+
}), B = (() => {
|
|
66
|
+
const t = f.width, n = f.height;
|
|
67
|
+
if (!t || !n) return {
|
|
34
68
|
width: 0,
|
|
35
69
|
height: 0,
|
|
36
|
-
minZoom:
|
|
70
|
+
minZoom: Z
|
|
37
71
|
};
|
|
38
|
-
if (!
|
|
72
|
+
if (!a) return {
|
|
39
73
|
width: t,
|
|
40
|
-
height:
|
|
41
|
-
minZoom:
|
|
74
|
+
height: n,
|
|
75
|
+
minZoom: Z
|
|
42
76
|
};
|
|
43
|
-
const
|
|
77
|
+
const r = t / a.width, e = n / a.height, o = Math.max(r, e), i = p === "width" ? r / o : p === "height" ? e / o : 0;
|
|
44
78
|
return {
|
|
45
|
-
width:
|
|
46
|
-
height:
|
|
47
|
-
minZoom: Math.max(
|
|
79
|
+
width: a.width * o,
|
|
80
|
+
height: a.height * o,
|
|
81
|
+
minZoom: Math.max(Z, i)
|
|
48
82
|
};
|
|
49
|
-
})(),
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
width:
|
|
53
|
-
height:
|
|
83
|
+
})(), D = B.minZoom, N = R ?? zt, W = d(N.zoom, D, I), K = A ?? h ?? null, st = !u && !!h && !A && !q, Q = !st, at = u ?? (K ? /* @__PURE__ */ w("img", { alt: "", draggable: !1, onLoad: (t) => {
|
|
84
|
+
const n = t.currentTarget;
|
|
85
|
+
n.naturalWidth && n.naturalHeight && X({
|
|
86
|
+
width: n.naturalWidth,
|
|
87
|
+
height: n.naturalHeight
|
|
54
88
|
});
|
|
55
|
-
}, src:
|
|
89
|
+
}, src: K }) : null), H = at == null, et = (t, n) => {
|
|
56
90
|
const {
|
|
57
|
-
maxX:
|
|
58
|
-
maxY:
|
|
59
|
-
} =
|
|
91
|
+
maxX: r,
|
|
92
|
+
maxY: e
|
|
93
|
+
} = ut(n);
|
|
60
94
|
return {
|
|
61
|
-
x: d(t.x, -
|
|
62
|
-
y: d(t.y, -
|
|
95
|
+
x: d(t.x, -r, r),
|
|
96
|
+
y: d(t.y, -e, e)
|
|
63
97
|
};
|
|
64
|
-
},
|
|
65
|
-
const
|
|
66
|
-
if (!
|
|
67
|
-
const
|
|
98
|
+
}, lt = (t, n) => {
|
|
99
|
+
const r = z.current;
|
|
100
|
+
if (!r) return null;
|
|
101
|
+
const e = r.getBoundingClientRect(), o = t - e.left - e.width / 2, i = n - e.top - e.height / 2;
|
|
68
102
|
return {
|
|
69
103
|
x: o,
|
|
70
|
-
y:
|
|
104
|
+
y: i
|
|
71
105
|
};
|
|
72
|
-
},
|
|
73
|
-
const o = d(
|
|
106
|
+
}, _t = (t, n, r, e) => {
|
|
107
|
+
const o = d(n, D, I), i = d(r, D, I);
|
|
74
108
|
if (o === 0) return t;
|
|
75
|
-
const
|
|
109
|
+
const l = i / o;
|
|
76
110
|
return {
|
|
77
|
-
x: (1 -
|
|
78
|
-
y: (1 -
|
|
111
|
+
x: (1 - l) * e.x + l * t.x,
|
|
112
|
+
y: (1 - l) * e.y + l * t.y
|
|
79
113
|
};
|
|
80
|
-
},
|
|
81
|
-
const
|
|
82
|
-
|
|
114
|
+
}, kt = (t, n, r) => {
|
|
115
|
+
const e = c.current.zoom, o = d(t, D, I), i = c.current.offset, l = r ? _t(i, e, o, r) : n, O = et(l, o);
|
|
116
|
+
c.current = {
|
|
83
117
|
zoom: o,
|
|
84
|
-
offset:
|
|
85
|
-
},
|
|
118
|
+
offset: O
|
|
119
|
+
}, R || ct({
|
|
86
120
|
zoom: o,
|
|
87
|
-
offset:
|
|
88
|
-
}),
|
|
121
|
+
offset: O
|
|
122
|
+
}), j == null || j({
|
|
89
123
|
zoom: o,
|
|
90
|
-
offset:
|
|
124
|
+
offset: O
|
|
91
125
|
});
|
|
92
|
-
},
|
|
93
|
-
|
|
126
|
+
}, V = (t, n, r) => {
|
|
127
|
+
Y.current = {
|
|
94
128
|
zoom: t,
|
|
95
|
-
offset:
|
|
96
|
-
anchor:
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const o = (
|
|
102
|
-
|
|
129
|
+
offset: n,
|
|
130
|
+
anchor: r ?? null
|
|
131
|
+
}, g.current == null && (g.current = window.requestAnimationFrame(() => {
|
|
132
|
+
g.current = null;
|
|
133
|
+
const e = Y.current;
|
|
134
|
+
Y.current = null;
|
|
135
|
+
const o = (e == null ? void 0 : e.zoom) ?? c.current.zoom, i = (e == null ? void 0 : e.offset) ?? c.current.offset, l = (e == null ? void 0 : e.anchor) ?? null;
|
|
136
|
+
kt(o, i, l);
|
|
103
137
|
}));
|
|
138
|
+
}, Rt = (t) => {
|
|
139
|
+
if (H || !Q) return;
|
|
140
|
+
const n = t.ctrlKey ? 1e-3 : 25e-5, r = c.current.zoom * Math.exp(-t.deltaY * n), e = lt(t.clientX, t.clientY);
|
|
141
|
+
V(r, c.current.offset, e);
|
|
104
142
|
}, ut = (t) => {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
U(n, i.current.offset, r);
|
|
108
|
-
}, F = (t) => {
|
|
109
|
-
const e = f.width, n = f.height;
|
|
110
|
-
if (!e || !n) return {
|
|
143
|
+
const n = f.width, r = f.height;
|
|
144
|
+
if (!n || !r) return {
|
|
111
145
|
maxX: 0,
|
|
112
146
|
maxY: 0
|
|
113
147
|
};
|
|
114
|
-
const
|
|
148
|
+
const e = d(t, D, I), o = B.width * e, i = B.height * e, l = Math.max(0, (o - n) / 2), O = Math.max(0, (i - r) / 2);
|
|
115
149
|
return {
|
|
116
|
-
maxX:
|
|
117
|
-
maxY:
|
|
150
|
+
maxX: l,
|
|
151
|
+
maxY: O
|
|
118
152
|
};
|
|
119
|
-
},
|
|
153
|
+
}, Lt = (t) => {
|
|
120
154
|
var o;
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
G(null),
|
|
155
|
+
const n = t.target, r = ((o = n.files) == null ? void 0 : o[0]) ?? null;
|
|
156
|
+
if (T.current && (URL.revokeObjectURL(T.current), T.current = null), !r) {
|
|
157
|
+
G(null), it(null), k == null || k(null), n.value = "";
|
|
124
158
|
return;
|
|
125
159
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
},
|
|
129
|
-
if (!(
|
|
160
|
+
const e = URL.createObjectURL(r);
|
|
161
|
+
T.current = e, G(e), X(null), it(r), V($.zoom, $.offset), c.current = $, k == null || k(r), n.value = "";
|
|
162
|
+
}, Tt = (t) => {
|
|
163
|
+
if (!(H || !Q || t.pointerType === "mouse" && t.button !== 0)) {
|
|
130
164
|
if (t.currentTarget.setPointerCapture(t.pointerId), t.pointerType === "touch") {
|
|
131
|
-
const
|
|
132
|
-
if (
|
|
165
|
+
const n = U.current;
|
|
166
|
+
if (n.set(t.pointerId, {
|
|
133
167
|
x: t.clientX,
|
|
134
168
|
y: t.clientY
|
|
135
|
-
}),
|
|
136
|
-
|
|
137
|
-
const [
|
|
138
|
-
|
|
169
|
+
}), n.size === 2) {
|
|
170
|
+
b.current = null, L.current = null, tt(!1);
|
|
171
|
+
const [r, e] = Array.from(n.values());
|
|
172
|
+
v.current = Math.hypot(r.x - e.x, r.y - e.y);
|
|
139
173
|
return;
|
|
140
174
|
}
|
|
141
175
|
}
|
|
142
|
-
|
|
176
|
+
L.current = t.pointerId, b.current = {
|
|
143
177
|
x: t.clientX,
|
|
144
178
|
y: t.clientY,
|
|
145
|
-
originX:
|
|
146
|
-
originY:
|
|
179
|
+
originX: c.current.offset.x,
|
|
180
|
+
originY: c.current.offset.y
|
|
147
181
|
};
|
|
148
182
|
}
|
|
149
|
-
},
|
|
150
|
-
if (
|
|
183
|
+
}, vt = (t) => {
|
|
184
|
+
if (H || !Q) return;
|
|
151
185
|
if (t.pointerType === "touch") {
|
|
152
|
-
const o =
|
|
186
|
+
const o = U.current;
|
|
153
187
|
if (!o.has(t.pointerId)) return;
|
|
154
188
|
if (o.set(t.pointerId, {
|
|
155
189
|
x: t.clientX,
|
|
156
190
|
y: t.clientY
|
|
157
191
|
}), o.size === 2) {
|
|
158
|
-
const [
|
|
159
|
-
x: (
|
|
160
|
-
y: (
|
|
192
|
+
const [i, l] = Array.from(o.values()), O = i.x - l.x, Et = i.y - l.y, pt = Math.hypot(O, Et), gt = {
|
|
193
|
+
x: (i.x + l.x) / 2,
|
|
194
|
+
y: (i.y + l.y) / 2
|
|
161
195
|
};
|
|
162
|
-
if (
|
|
163
|
-
const
|
|
164
|
-
|
|
196
|
+
if (v.current) {
|
|
197
|
+
const Ut = pt / v.current, Ot = c.current.zoom * Ut, It = lt(gt.x, gt.y);
|
|
198
|
+
V(Ot, c.current.offset, It);
|
|
165
199
|
}
|
|
166
|
-
|
|
200
|
+
v.current = pt;
|
|
167
201
|
return;
|
|
168
202
|
}
|
|
169
203
|
}
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
172
|
-
!
|
|
173
|
-
x:
|
|
174
|
-
y:
|
|
204
|
+
if (L.current !== t.pointerId || !b.current || !nt) return;
|
|
205
|
+
const n = t.clientX - b.current.x, r = t.clientY - b.current.y, e = Math.abs(n) + Math.abs(r);
|
|
206
|
+
!ot && e > 2 && tt(!0), !(e <= 1) && V(c.current.zoom, {
|
|
207
|
+
x: b.current.originX + n,
|
|
208
|
+
y: b.current.originY + r
|
|
175
209
|
});
|
|
176
|
-
},
|
|
177
|
-
t.pointerType === "touch" && (
|
|
210
|
+
}, ht = (t) => {
|
|
211
|
+
t.pointerType === "touch" && (U.current.delete(t.pointerId), U.current.size < 2 && (v.current = null)), L.current === t.pointerId && (L.current = null, b.current = null, tt(!1));
|
|
178
212
|
};
|
|
179
|
-
|
|
180
|
-
if (!
|
|
181
|
-
const t = d(
|
|
182
|
-
|
|
213
|
+
E(() => {
|
|
214
|
+
if (!R) return;
|
|
215
|
+
const t = d(R.zoom, D, I);
|
|
216
|
+
c.current = {
|
|
183
217
|
zoom: t,
|
|
184
|
-
offset:
|
|
218
|
+
offset: et(R.offset, t)
|
|
185
219
|
};
|
|
186
|
-
}, [
|
|
187
|
-
|
|
188
|
-
}, []),
|
|
189
|
-
const t =
|
|
220
|
+
}, [R, f.width, f.height, a == null ? void 0 : a.width, a == null ? void 0 : a.height]), E(() => () => {
|
|
221
|
+
T.current && URL.revokeObjectURL(T.current);
|
|
222
|
+
}, []), E(() => {
|
|
223
|
+
const t = z.current;
|
|
190
224
|
if (!t) return;
|
|
191
|
-
const
|
|
225
|
+
const n = () => {
|
|
192
226
|
const o = t.getBoundingClientRect();
|
|
193
|
-
|
|
227
|
+
Mt((i) => i.width === o.width && i.height === o.height ? i : {
|
|
194
228
|
width: o.width,
|
|
195
229
|
height: o.height
|
|
196
|
-
}),
|
|
230
|
+
}), P && P(o);
|
|
197
231
|
};
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
if (window.addEventListener("scroll",
|
|
201
|
-
const o = () =>
|
|
232
|
+
n();
|
|
233
|
+
const r = () => n();
|
|
234
|
+
if (window.addEventListener("scroll", r, !0), typeof ResizeObserver > "u") {
|
|
235
|
+
const o = () => n();
|
|
202
236
|
return window.addEventListener("resize", o), () => {
|
|
203
|
-
window.removeEventListener("resize", o), window.removeEventListener("scroll",
|
|
237
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", r, !0);
|
|
204
238
|
};
|
|
205
239
|
}
|
|
206
|
-
const
|
|
207
|
-
return
|
|
208
|
-
|
|
240
|
+
const e = new ResizeObserver(() => n());
|
|
241
|
+
return e.observe(t), () => {
|
|
242
|
+
e.disconnect(), window.removeEventListener("scroll", r, !0);
|
|
209
243
|
};
|
|
210
|
-
}, [
|
|
211
|
-
if (
|
|
212
|
-
const t =
|
|
213
|
-
t.x ===
|
|
214
|
-
zoom:
|
|
215
|
-
offset:
|
|
216
|
-
},
|
|
217
|
-
...
|
|
218
|
-
offset:
|
|
244
|
+
}, [P]), E(() => {
|
|
245
|
+
if (R) return;
|
|
246
|
+
const t = c.current.offset, n = et(t, W);
|
|
247
|
+
t.x === n.x && t.y === n.y || (c.current = {
|
|
248
|
+
zoom: c.current.zoom,
|
|
249
|
+
offset: n
|
|
250
|
+
}, ct((r) => ({
|
|
251
|
+
...r,
|
|
252
|
+
offset: n
|
|
219
253
|
})));
|
|
220
|
-
}, [
|
|
221
|
-
|
|
254
|
+
}, [W, a, f.width, f.height]), E(() => {
|
|
255
|
+
K || X(null);
|
|
256
|
+
}, [K]), E(() => {
|
|
257
|
+
m.current = x;
|
|
258
|
+
}, [x]), E(() => {
|
|
259
|
+
var r;
|
|
260
|
+
if (!x) return;
|
|
261
|
+
if (!q || !f.width || !f.height || u) {
|
|
262
|
+
(r = m.current) == null || r.call(m, null);
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
let t = !0;
|
|
266
|
+
const n = window.setTimeout(() => {
|
|
267
|
+
$t({
|
|
268
|
+
file: q,
|
|
269
|
+
fill: p,
|
|
270
|
+
transform: {
|
|
271
|
+
zoom: W,
|
|
272
|
+
offset: N.offset
|
|
273
|
+
},
|
|
274
|
+
viewport: f
|
|
275
|
+
}).then((e) => {
|
|
276
|
+
var o;
|
|
277
|
+
t && ((o = m.current) == null || o.call(m, e));
|
|
278
|
+
}).catch(() => {
|
|
279
|
+
var e;
|
|
280
|
+
t && ((e = m.current) == null || e.call(m, null));
|
|
281
|
+
});
|
|
282
|
+
}, 75);
|
|
283
|
+
return () => {
|
|
284
|
+
t = !1, window.clearTimeout(n);
|
|
285
|
+
};
|
|
286
|
+
}, [u, W, N.offset, p, q, f]), E(() => () => {
|
|
287
|
+
g.current != null && (window.cancelAnimationFrame(g.current), g.current = null);
|
|
222
288
|
}, []);
|
|
223
|
-
const
|
|
224
|
-
return /* @__PURE__ */ gt("div", { className: z.croppable, onClick: () => {
|
|
289
|
+
const dt = ut(W), nt = !H && Q && (dt.maxX > 0 || dt.maxY > 0), mt = () => {
|
|
225
290
|
var t;
|
|
226
|
-
|
|
291
|
+
return (t = F.current) == null ? void 0 : t.click();
|
|
292
|
+
}, ft = (t) => {
|
|
293
|
+
t.preventDefault(), t.stopPropagation(), mt();
|
|
294
|
+
};
|
|
295
|
+
return /* @__PURE__ */ J("div", { className: rt(M.croppable, C && M.standalone), onClick: () => {
|
|
296
|
+
H && mt();
|
|
227
297
|
}, "data-component": "croppable", children: [
|
|
228
|
-
/* @__PURE__ */
|
|
229
|
-
/* @__PURE__ */
|
|
230
|
-
"--croppable-height": `${
|
|
231
|
-
"--croppable-zoom":
|
|
232
|
-
"--croppable-x": `${
|
|
233
|
-
"--croppable-y": `${
|
|
234
|
-
...
|
|
235
|
-
"--croppable-image-width": `${
|
|
236
|
-
"--croppable-image-height": `${
|
|
298
|
+
/* @__PURE__ */ w("input", { accept: "image/*", onChange: Lt, ref: F, type: "file" }),
|
|
299
|
+
/* @__PURE__ */ w("div", { className: M.viewport, ref: z, onDragStart: (t) => t.preventDefault(), onPointerDown: Tt, onPointerMove: vt, onPointerUp: ht, onPointerCancel: ht, onWheel: Rt, style: {
|
|
300
|
+
"--croppable-height": `${_ ?? jt}px`,
|
|
301
|
+
"--croppable-zoom": W,
|
|
302
|
+
"--croppable-x": `${N.offset.x}px`,
|
|
303
|
+
"--croppable-y": `${N.offset.y}px`,
|
|
304
|
+
...a ? {
|
|
305
|
+
"--croppable-image-width": `${B.width}px`,
|
|
306
|
+
"--croppable-image-height": `${B.height}px`
|
|
237
307
|
} : null
|
|
238
|
-
}, children:
|
|
308
|
+
}, children: H ? /* @__PURE__ */ J("div", { className: M.empty, children: [
|
|
309
|
+
/* @__PURE__ */ w(yt, { children: /* @__PURE__ */ w(xt, { name: "image", size: "large" }) }),
|
|
310
|
+
/* @__PURE__ */ w(wt, { onClick: ft, children: s ?? bt })
|
|
311
|
+
] }) : /* @__PURE__ */ J("div", { className: rt(M.media, nt && M.draggable, nt && ot && M.dragging), children: [
|
|
312
|
+
/* @__PURE__ */ w("div", { className: rt(M.inner), children: at }),
|
|
313
|
+
st && /* @__PURE__ */ w("div", { className: M.overlay, children: /* @__PURE__ */ J("div", { className: M.empty, children: [
|
|
314
|
+
/* @__PURE__ */ w(yt, { children: /* @__PURE__ */ w(xt, { name: "image", size: "large" }) }),
|
|
315
|
+
/* @__PURE__ */ w(wt, { onClick: ft, children: s ?? bt })
|
|
316
|
+
] }) })
|
|
317
|
+
] }) })
|
|
239
318
|
] });
|
|
240
319
|
};
|
|
241
320
|
export {
|
|
242
|
-
|
|
321
|
+
Ct as Croppable
|
|
243
322
|
};
|
|
244
323
|
//# sourceMappingURL=index.js.map
|