@solibo/solibo-ui 2.2.2 → 2.2.5
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/index11.css +1 -1
- package/dist/assets/index12.css +1 -1
- package/dist/assets/index38.css +1 -1
- package/dist/assets/index53.css +1 -1
- package/dist/components/croppable/index.cjs +1 -1
- package/dist/components/croppable/index.js +251 -238
- package/dist/components/dropdown/index.cjs +1 -1
- package/dist/components/dropdown/index.js +192 -153
- package/dist/components/loading/index.cjs +1 -1
- package/dist/components/loading/index.js +19 -17
- package/dist/components/page-layout/index.cjs +1 -1
- package/dist/components/page-layout/index.js +31 -28
- package/dist/components/panel/index.cjs +1 -1
- package/dist/components/panel/index.js +29 -20
- package/dist/index.d.ts +34 -9
- package/dist/tokens.json +1 -1
- package/package.json +8 -5
|
@@ -1,359 +1,372 @@
|
|
|
1
|
-
import { jsxs as q, jsx as
|
|
2
|
-
import
|
|
3
|
-
import { useRef as
|
|
4
|
-
import { Toolbar as
|
|
5
|
-
import { Button as
|
|
6
|
-
import { Figure as
|
|
7
|
-
import { Icon as
|
|
8
|
-
import '../../assets/index38.css';const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
URL.revokeObjectURL(
|
|
12
|
-
},
|
|
13
|
-
URL.revokeObjectURL(
|
|
14
|
-
},
|
|
15
|
-
}),
|
|
16
|
-
file:
|
|
1
|
+
import { jsxs as q, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import xt from "classix";
|
|
3
|
+
import { useRef as _, useState as O, useEffect as I } from "react";
|
|
4
|
+
import { Toolbar as rr } from "../toolbar/index.js";
|
|
5
|
+
import { Button as it } from "../button/index.js";
|
|
6
|
+
import { Figure as nr } from "../figure/index.js";
|
|
7
|
+
import { Icon as er } from "../icon/index.js";
|
|
8
|
+
import '../../assets/index38.css';const j = 10, F = 0.1, or = 0.92, y = (c, l, z) => Math.min(z, Math.max(l, c)), cr = (c) => new Promise((l, z) => {
|
|
9
|
+
const u = URL.createObjectURL(c), d = new globalThis.Image();
|
|
10
|
+
d.onload = () => {
|
|
11
|
+
URL.revokeObjectURL(u), l(d);
|
|
12
|
+
}, d.onerror = () => {
|
|
13
|
+
URL.revokeObjectURL(u), z(new Error("croppable-image-load-failed"));
|
|
14
|
+
}, d.src = u;
|
|
15
|
+
}), sr = async ({
|
|
16
|
+
file: c,
|
|
17
17
|
fill: l,
|
|
18
|
-
transform:
|
|
19
|
-
viewport:
|
|
18
|
+
transform: z,
|
|
19
|
+
viewport: u
|
|
20
20
|
}) => {
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
21
|
+
const d = await cr(c), M = u.width / d.naturalWidth, tt = u.height / d.naturalHeight, D = Math.max(M, tt), G = d.naturalWidth * D, Z = d.naturalHeight * D, R = l === "width" ? Math.max(F, M / D) : l === "height" ? Math.max(F, tt / D) : F, L = y(z.zoom, R, j), v = D * L, E = G * L, J = Z * L, at = (u.width - E) / 2 + z.offset.x, T = (u.height - J) / 2 + z.offset.y, K = y(-at / v, 0, d.naturalWidth), P = y(-T / v, 0, d.naturalHeight), x = y(u.width / v, 1, Math.max(1, d.naturalWidth - K)), b = y(u.height / v, 1, Math.max(1, d.naturalHeight - P)), U = document.createElement("canvas"), A = U.getContext("2d");
|
|
22
|
+
if (!A)
|
|
23
23
|
throw new Error("croppable-image-context-missing");
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
24
|
+
U.width = Math.max(1, Math.round(x)), U.height = Math.max(1, Math.round(b)), A.drawImage(d, K, P, x, b, 0, 0, U.width, U.height);
|
|
25
|
+
const f = c.type.startsWith("image/") ? c.type : "image/jpeg", g = await new Promise((S) => {
|
|
26
|
+
U.toBlob(S, f, or);
|
|
27
27
|
});
|
|
28
|
-
if (!
|
|
28
|
+
if (!g)
|
|
29
29
|
throw new Error("croppable-image-export-failed");
|
|
30
|
-
return new globalThis.File([
|
|
30
|
+
return new globalThis.File([g], c.name, {
|
|
31
31
|
lastModified: Date.now(),
|
|
32
|
-
type:
|
|
32
|
+
type: g.type || f
|
|
33
33
|
});
|
|
34
|
-
},
|
|
35
|
-
croppable:
|
|
36
|
-
empty:
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
}, ir = "_croppable_1tvcl_1", ar = "_empty_1tvcl_15", lr = "_action_1tvcl_28", ur = "_caption_1tvcl_36", dr = "_media_1tvcl_43", pr = "_viewport_1tvcl_54", hr = "_draggable_1tvcl_66", mr = "_dragging_1tvcl_70", fr = "_inner_1tvcl_74", gr = "_standalone_1tvcl_90", a = {
|
|
35
|
+
croppable: ir,
|
|
36
|
+
empty: ar,
|
|
37
|
+
"drop-target": "_drop-target_1tvcl_23",
|
|
38
|
+
action: lr,
|
|
39
|
+
caption: ur,
|
|
40
|
+
media: dr,
|
|
41
|
+
viewport: pr,
|
|
42
|
+
draggable: hr,
|
|
43
|
+
dragging: mr,
|
|
44
|
+
inner: fr,
|
|
45
|
+
standalone: gr
|
|
46
|
+
}, wr = 192, W = {
|
|
46
47
|
offset: {
|
|
47
48
|
x: 0,
|
|
48
49
|
y: 0
|
|
49
50
|
},
|
|
50
51
|
zoom: 1
|
|
51
|
-
},
|
|
52
|
-
cancelLabel:
|
|
52
|
+
}, Wt = (c, l) => (c == null ? void 0 : c.file) === l.file && (c == null ? void 0 : c.source) === l.source && (c == null ? void 0 : c.settings) === l.settings, vr = ({
|
|
53
|
+
cancelLabel: c,
|
|
53
54
|
children: l,
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
onCroppableChange:
|
|
61
|
-
onDelete:
|
|
62
|
-
onFileChange:
|
|
63
|
-
onImageChange:
|
|
64
|
-
onSave:
|
|
55
|
+
deleteLabel: z,
|
|
56
|
+
fill: u = "none",
|
|
57
|
+
height: d,
|
|
58
|
+
image: M,
|
|
59
|
+
isDeleting: tt,
|
|
60
|
+
isSaving: D,
|
|
61
|
+
onCroppableChange: G,
|
|
62
|
+
onDelete: Z,
|
|
63
|
+
onFileChange: R,
|
|
64
|
+
onImageChange: L,
|
|
65
|
+
onSave: v,
|
|
65
66
|
onTransformChange: E,
|
|
66
|
-
|
|
67
|
-
standalone:
|
|
67
|
+
saveLabel: J,
|
|
68
|
+
standalone: at,
|
|
69
|
+
transform: T,
|
|
70
|
+
uploadLabel: K
|
|
68
71
|
}) => {
|
|
69
|
-
const
|
|
72
|
+
const P = _(null), x = _(null), b = _(null), U = _(null), A = _(0), f = _(L), g = _(null), S = _(null), B = _(null), Q = _(/* @__PURE__ */ new Map()), i = _(W), lt = _(null), [w, rt] = O(null), [ut, dt] = O(null), [bt, nt] = O(!1), [Xt, pt] = O(!1), [kt, ht] = O(W), [X, mt] = O(null), [m, Yt] = O({
|
|
70
73
|
width: 0,
|
|
71
74
|
height: 0
|
|
72
|
-
}), [
|
|
73
|
-
const t = m.width,
|
|
74
|
-
if (!t || !
|
|
75
|
+
}), [_t, ft] = O(null), [V, et] = O(null), C = (() => {
|
|
76
|
+
const t = m.width, r = m.height;
|
|
77
|
+
if (!t || !r) return {
|
|
75
78
|
width: 0,
|
|
76
79
|
height: 0,
|
|
77
|
-
minZoom:
|
|
80
|
+
minZoom: F
|
|
78
81
|
};
|
|
79
|
-
if (!
|
|
82
|
+
if (!w) return {
|
|
80
83
|
width: t,
|
|
81
|
-
height:
|
|
82
|
-
minZoom:
|
|
84
|
+
height: r,
|
|
85
|
+
minZoom: F
|
|
83
86
|
};
|
|
84
|
-
const
|
|
87
|
+
const e = t / w.width, n = r / w.height, o = Math.max(e, n), s = u === "width" ? e / o : u === "height" ? n / o : 0;
|
|
85
88
|
return {
|
|
86
|
-
width:
|
|
87
|
-
height:
|
|
88
|
-
minZoom: Math.max(
|
|
89
|
+
width: w.width * o,
|
|
90
|
+
height: w.height * o,
|
|
91
|
+
minZoom: Math.max(F, s)
|
|
89
92
|
};
|
|
90
|
-
})(), $ =
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
width:
|
|
94
|
-
height:
|
|
93
|
+
})(), $ = C.minZoom, k = T ?? kt, Y = y(k.zoom, $, j), ot = ut ?? M ?? null, zt = !l && !!M && !ut && !X, ct = !zt, Mt = l ?? (ot ? /* @__PURE__ */ p("img", { alt: "", draggable: !1, onLoad: (t) => {
|
|
94
|
+
const r = t.currentTarget;
|
|
95
|
+
r.naturalWidth && r.naturalHeight && rt({
|
|
96
|
+
width: r.naturalWidth,
|
|
97
|
+
height: r.naturalHeight
|
|
95
98
|
});
|
|
96
|
-
}, src:
|
|
97
|
-
file:
|
|
98
|
-
source:
|
|
99
|
-
settings: JSON.stringify([
|
|
99
|
+
}, src: ot }) : null), N = Mt == null, gt = {
|
|
100
|
+
file: X,
|
|
101
|
+
source: ut,
|
|
102
|
+
settings: JSON.stringify([u, Y, k.offset.x, k.offset.y, m.width, m.height])
|
|
100
103
|
};
|
|
101
|
-
|
|
102
|
-
!
|
|
103
|
-
}, [
|
|
104
|
-
const
|
|
104
|
+
I(() => {
|
|
105
|
+
!V || !M || M === V.image && M !== V.crop.source || (ft(V.crop), et(null));
|
|
106
|
+
}, [M, V]);
|
|
107
|
+
const wt = (t, r) => {
|
|
105
108
|
const {
|
|
106
|
-
maxX:
|
|
109
|
+
maxX: e,
|
|
107
110
|
maxY: n
|
|
108
|
-
} =
|
|
111
|
+
} = Dt(r);
|
|
109
112
|
return {
|
|
110
|
-
x:
|
|
111
|
-
y:
|
|
113
|
+
x: y(t.x, -e, e),
|
|
114
|
+
y: y(t.y, -n, n)
|
|
112
115
|
};
|
|
113
|
-
},
|
|
114
|
-
const
|
|
115
|
-
if (!
|
|
116
|
-
const n =
|
|
116
|
+
}, Rt = (t, r) => {
|
|
117
|
+
const e = lt.current;
|
|
118
|
+
if (!e) return null;
|
|
119
|
+
const n = e.getBoundingClientRect(), o = t - n.left - n.width / 2, s = r - n.top - n.height / 2;
|
|
117
120
|
return {
|
|
118
121
|
x: o,
|
|
119
|
-
y:
|
|
122
|
+
y: s
|
|
120
123
|
};
|
|
121
|
-
},
|
|
122
|
-
const o =
|
|
124
|
+
}, Ht = (t, r, e, n) => {
|
|
125
|
+
const o = y(r, $, j), s = y(e, $, j);
|
|
123
126
|
if (o === 0) return t;
|
|
124
|
-
const
|
|
127
|
+
const h = s / o;
|
|
125
128
|
return {
|
|
126
|
-
x: (1 -
|
|
127
|
-
y: (1 -
|
|
129
|
+
x: (1 - h) * n.x + h * t.x,
|
|
130
|
+
y: (1 - h) * n.y + h * t.y
|
|
128
131
|
};
|
|
129
|
-
},
|
|
130
|
-
const n = i.current.zoom, o =
|
|
132
|
+
}, jt = (t, r, e) => {
|
|
133
|
+
const n = i.current.zoom, o = y(t, $, j), s = i.current.offset, h = e ? Ht(s, n, o, e) : r, H = wt(h, o);
|
|
131
134
|
i.current = {
|
|
132
135
|
zoom: o,
|
|
133
|
-
offset:
|
|
134
|
-
},
|
|
136
|
+
offset: H
|
|
137
|
+
}, T || ht({
|
|
135
138
|
zoom: o,
|
|
136
|
-
offset:
|
|
139
|
+
offset: H
|
|
137
140
|
}), E == null || E({
|
|
138
141
|
zoom: o,
|
|
139
|
-
offset:
|
|
142
|
+
offset: H
|
|
140
143
|
});
|
|
141
|
-
},
|
|
142
|
-
|
|
144
|
+
}, st = (t, r, e) => {
|
|
145
|
+
S.current = {
|
|
143
146
|
zoom: t,
|
|
144
|
-
offset:
|
|
145
|
-
anchor:
|
|
146
|
-
},
|
|
147
|
-
|
|
148
|
-
const n =
|
|
149
|
-
|
|
150
|
-
const o = (n == null ? void 0 : n.zoom) ?? i.current.zoom,
|
|
151
|
-
|
|
147
|
+
offset: r,
|
|
148
|
+
anchor: e ?? null
|
|
149
|
+
}, x.current == null && (x.current = window.requestAnimationFrame(() => {
|
|
150
|
+
x.current = null;
|
|
151
|
+
const n = S.current;
|
|
152
|
+
S.current = null;
|
|
153
|
+
const o = (n == null ? void 0 : n.zoom) ?? i.current.zoom, s = (n == null ? void 0 : n.offset) ?? i.current.offset, h = (n == null ? void 0 : n.anchor) ?? null;
|
|
154
|
+
jt(o, s, h);
|
|
152
155
|
}));
|
|
153
|
-
},
|
|
154
|
-
if (N || !
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
},
|
|
158
|
-
const
|
|
159
|
-
if (!
|
|
156
|
+
}, Zt = (t) => {
|
|
157
|
+
if (N || !ct) return;
|
|
158
|
+
const r = t.ctrlKey ? 1e-3 : 25e-5, e = i.current.zoom * Math.exp(-t.deltaY * r), n = Rt(t.clientX, t.clientY);
|
|
159
|
+
st(e, i.current.offset, n);
|
|
160
|
+
}, Dt = (t) => {
|
|
161
|
+
const r = m.width, e = m.height;
|
|
162
|
+
if (!r || !e) return {
|
|
160
163
|
maxX: 0,
|
|
161
164
|
maxY: 0
|
|
162
165
|
};
|
|
163
|
-
const n =
|
|
166
|
+
const n = y(t, $, j), o = C.width * n, s = C.height * n, h = Math.max(0, (o - r) / 2), H = Math.max(0, (s - e) / 2);
|
|
164
167
|
return {
|
|
165
|
-
maxX:
|
|
166
|
-
maxY:
|
|
168
|
+
maxX: h,
|
|
169
|
+
maxY: H
|
|
167
170
|
};
|
|
168
|
-
},
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const e = t.target, r = ((o = e.files) == null ? void 0 : o[0]) ?? null;
|
|
172
|
-
if (u.current && (URL.revokeObjectURL(u.current), u.current = null), !r) {
|
|
173
|
-
at(null), ut(null), _ == null || _(null), e.value = "";
|
|
171
|
+
}, vt = (t) => {
|
|
172
|
+
if (et(null), ft(null), g.current && (URL.revokeObjectURL(g.current), g.current = null), !t) {
|
|
173
|
+
dt(null), mt(null), R == null || R(null);
|
|
174
174
|
return;
|
|
175
175
|
}
|
|
176
|
-
const
|
|
177
|
-
|
|
178
|
-
},
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
t.
|
|
184
|
-
|
|
185
|
-
|
|
176
|
+
const r = URL.createObjectURL(t);
|
|
177
|
+
g.current = r, dt(r), rt(null), mt(t), st(W.zoom, W.offset), i.current = W, R == null || R(t);
|
|
178
|
+
}, St = (t) => {
|
|
179
|
+
var r;
|
|
180
|
+
vt(((r = t.target.files) == null ? void 0 : r[0]) ?? null), t.target.value = "";
|
|
181
|
+
}, Tt = (t) => !D && (Array.from(t.items ?? []).some((r) => r.kind === "file" && r.type.startsWith("image/")) || Array.from(t.files ?? []).some((r) => r.type.startsWith("image/"))), Bt = (t) => {
|
|
182
|
+
if (t.preventDefault(), t.stopPropagation(), A.current = 0, pt(!1), D) return;
|
|
183
|
+
const r = Array.from(t.dataTransfer.files).find((e) => e.type.startsWith("image/"));
|
|
184
|
+
r && vt(r);
|
|
185
|
+
}, Pt = () => {
|
|
186
|
+
et(null), ft(null), x.current != null && (window.cancelAnimationFrame(x.current), x.current = null), S.current = null, P.current = null, b.current = null, B.current = null, Q.current.clear(), nt(!1), g.current && (URL.revokeObjectURL(g.current), g.current = null), dt(null), rt(null), mt(null), i.current = W, ht(W), E == null || E(W), R == null || R(null);
|
|
187
|
+
}, $t = (t) => {
|
|
188
|
+
t.stopPropagation(), Pt();
|
|
189
|
+
}, qt = (t) => {
|
|
190
|
+
t.stopPropagation(), Pt(), Z == null || Z();
|
|
191
|
+
}, Ft = (t) => {
|
|
192
|
+
if (!(N || !ct || t.pointerType === "mouse" && t.button !== 0)) {
|
|
186
193
|
if (t.currentTarget.setPointerCapture(t.pointerId), t.pointerType === "touch") {
|
|
187
|
-
const
|
|
188
|
-
if (
|
|
194
|
+
const r = Q.current;
|
|
195
|
+
if (r.set(t.pointerId, {
|
|
189
196
|
x: t.clientX,
|
|
190
197
|
y: t.clientY
|
|
191
|
-
}),
|
|
192
|
-
b.current = null,
|
|
193
|
-
const [
|
|
194
|
-
|
|
198
|
+
}), r.size === 2) {
|
|
199
|
+
b.current = null, P.current = null, nt(!1);
|
|
200
|
+
const [e, n] = Array.from(r.values());
|
|
201
|
+
B.current = Math.hypot(e.x - n.x, e.y - n.y);
|
|
195
202
|
return;
|
|
196
203
|
}
|
|
197
204
|
}
|
|
198
|
-
|
|
205
|
+
P.current = t.pointerId, b.current = {
|
|
199
206
|
x: t.clientX,
|
|
200
207
|
y: t.clientY,
|
|
201
208
|
originX: i.current.offset.x,
|
|
202
209
|
originY: i.current.offset.y
|
|
203
210
|
};
|
|
204
211
|
}
|
|
205
|
-
},
|
|
206
|
-
if (N || !
|
|
212
|
+
}, Gt = (t) => {
|
|
213
|
+
if (N || !ct) return;
|
|
207
214
|
if (t.pointerType === "touch") {
|
|
208
|
-
const o =
|
|
215
|
+
const o = Q.current;
|
|
209
216
|
if (!o.has(t.pointerId)) return;
|
|
210
217
|
if (o.set(t.pointerId, {
|
|
211
218
|
x: t.clientX,
|
|
212
219
|
y: t.clientY
|
|
213
220
|
}), o.size === 2) {
|
|
214
|
-
const [
|
|
215
|
-
x: (
|
|
216
|
-
y: (
|
|
221
|
+
const [s, h] = Array.from(o.values()), H = s.x - h.x, Qt = s.y - h.y, At = Math.hypot(H, Qt), Nt = {
|
|
222
|
+
x: (s.x + h.x) / 2,
|
|
223
|
+
y: (s.y + h.y) / 2
|
|
217
224
|
};
|
|
218
|
-
if (
|
|
219
|
-
const
|
|
220
|
-
|
|
225
|
+
if (B.current) {
|
|
226
|
+
const Vt = At / B.current, Ct = i.current.zoom * Vt, tr = Rt(Nt.x, Nt.y);
|
|
227
|
+
st(Ct, i.current.offset, tr);
|
|
221
228
|
}
|
|
222
|
-
|
|
229
|
+
B.current = At;
|
|
223
230
|
return;
|
|
224
231
|
}
|
|
225
232
|
}
|
|
226
|
-
if (
|
|
227
|
-
const
|
|
228
|
-
!
|
|
229
|
-
x: b.current.originX +
|
|
230
|
-
y: b.current.originY +
|
|
233
|
+
if (P.current !== t.pointerId || !b.current || !yt) return;
|
|
234
|
+
const r = t.clientX - b.current.x, e = t.clientY - b.current.y, n = Math.abs(r) + Math.abs(e);
|
|
235
|
+
!bt && n > 2 && nt(!0), !(n <= 1) && st(i.current.zoom, {
|
|
236
|
+
x: b.current.originX + r,
|
|
237
|
+
y: b.current.originY + e
|
|
231
238
|
});
|
|
232
|
-
},
|
|
233
|
-
t.pointerType === "touch" && (
|
|
239
|
+
}, Ut = (t) => {
|
|
240
|
+
t.pointerType === "touch" && (Q.current.delete(t.pointerId), Q.current.size < 2 && (B.current = null)), P.current === t.pointerId && (P.current = null, b.current = null, nt(!1));
|
|
234
241
|
};
|
|
235
|
-
|
|
236
|
-
if (!
|
|
237
|
-
const t =
|
|
242
|
+
I(() => {
|
|
243
|
+
if (!T) return;
|
|
244
|
+
const t = y(T.zoom, $, j);
|
|
238
245
|
i.current = {
|
|
239
246
|
zoom: t,
|
|
240
|
-
offset:
|
|
247
|
+
offset: wt(T.offset, t)
|
|
241
248
|
};
|
|
242
|
-
}, [
|
|
243
|
-
|
|
244
|
-
}, []),
|
|
245
|
-
const t =
|
|
249
|
+
}, [T, m.width, m.height, w == null ? void 0 : w.width, w == null ? void 0 : w.height]), I(() => () => {
|
|
250
|
+
g.current && URL.revokeObjectURL(g.current);
|
|
251
|
+
}, []), I(() => {
|
|
252
|
+
const t = lt.current;
|
|
246
253
|
if (!t) return;
|
|
247
|
-
const
|
|
254
|
+
const r = () => {
|
|
248
255
|
const o = t.getBoundingClientRect();
|
|
249
|
-
|
|
256
|
+
Yt((s) => s.width === o.width && s.height === o.height ? s : {
|
|
250
257
|
width: o.width,
|
|
251
258
|
height: o.height
|
|
252
|
-
}),
|
|
259
|
+
}), G && G(o);
|
|
253
260
|
};
|
|
254
|
-
|
|
255
|
-
const
|
|
256
|
-
if (window.addEventListener("scroll",
|
|
257
|
-
const o = () =>
|
|
261
|
+
r();
|
|
262
|
+
const e = () => r();
|
|
263
|
+
if (window.addEventListener("scroll", e, !0), typeof ResizeObserver > "u") {
|
|
264
|
+
const o = () => r();
|
|
258
265
|
return window.addEventListener("resize", o), () => {
|
|
259
|
-
window.removeEventListener("resize", o), window.removeEventListener("scroll",
|
|
266
|
+
window.removeEventListener("resize", o), window.removeEventListener("scroll", e, !0);
|
|
260
267
|
};
|
|
261
268
|
}
|
|
262
|
-
const n = new ResizeObserver(() =>
|
|
269
|
+
const n = new ResizeObserver(() => r());
|
|
263
270
|
return n.observe(t), () => {
|
|
264
|
-
n.disconnect(), window.removeEventListener("scroll",
|
|
271
|
+
n.disconnect(), window.removeEventListener("scroll", e, !0);
|
|
265
272
|
};
|
|
266
|
-
}, [
|
|
267
|
-
if (
|
|
268
|
-
const t = i.current.offset,
|
|
269
|
-
t.x ===
|
|
273
|
+
}, [G]), I(() => {
|
|
274
|
+
if (T) return;
|
|
275
|
+
const t = i.current.offset, r = wt(t, Y);
|
|
276
|
+
t.x === r.x && t.y === r.y || (i.current = {
|
|
270
277
|
zoom: i.current.zoom,
|
|
271
|
-
offset:
|
|
272
|
-
},
|
|
273
|
-
...
|
|
274
|
-
offset:
|
|
278
|
+
offset: r
|
|
279
|
+
}, ht((e) => ({
|
|
280
|
+
...e,
|
|
281
|
+
offset: r
|
|
275
282
|
})));
|
|
276
|
-
}, [
|
|
277
|
-
|
|
278
|
-
}, [
|
|
279
|
-
|
|
280
|
-
}, [
|
|
281
|
-
var
|
|
282
|
-
if (!
|
|
283
|
-
if (!
|
|
284
|
-
(
|
|
283
|
+
}, [Y, w, m.width, m.height]), I(() => {
|
|
284
|
+
ot || rt(null);
|
|
285
|
+
}, [ot]), I(() => {
|
|
286
|
+
f.current = L;
|
|
287
|
+
}, [L]), I(() => {
|
|
288
|
+
var e;
|
|
289
|
+
if (!L) return;
|
|
290
|
+
if (!X || !m.width || !m.height || l) {
|
|
291
|
+
(e = f.current) == null || e.call(f, null);
|
|
285
292
|
return;
|
|
286
293
|
}
|
|
287
294
|
let t = !0;
|
|
288
|
-
const
|
|
289
|
-
|
|
290
|
-
file:
|
|
291
|
-
fill:
|
|
295
|
+
const r = window.setTimeout(() => {
|
|
296
|
+
sr({
|
|
297
|
+
file: X,
|
|
298
|
+
fill: u,
|
|
292
299
|
transform: {
|
|
293
|
-
zoom:
|
|
294
|
-
offset:
|
|
300
|
+
zoom: Y,
|
|
301
|
+
offset: k.offset
|
|
295
302
|
},
|
|
296
303
|
viewport: m
|
|
297
304
|
}).then((n) => {
|
|
298
305
|
var o;
|
|
299
|
-
t && ((o =
|
|
306
|
+
t && ((o = f.current) == null || o.call(f, n));
|
|
300
307
|
}).catch(() => {
|
|
301
308
|
var n;
|
|
302
|
-
t && ((n =
|
|
309
|
+
t && ((n = f.current) == null || n.call(f, null));
|
|
303
310
|
});
|
|
304
311
|
}, 75);
|
|
305
312
|
return () => {
|
|
306
|
-
t = !1, window.clearTimeout(
|
|
313
|
+
t = !1, window.clearTimeout(r);
|
|
307
314
|
};
|
|
308
|
-
}, [l,
|
|
309
|
-
|
|
315
|
+
}, [l, Y, k.offset, u, X, m]), I(() => () => {
|
|
316
|
+
x.current != null && (window.cancelAnimationFrame(x.current), x.current = null);
|
|
310
317
|
}, []);
|
|
311
|
-
const
|
|
318
|
+
const Ot = Dt(Y), yt = !N && ct && (Ot.maxX > 0 || Ot.maxY > 0), It = !N && !zt && !!v && !Wt(_t, gt), Lt = !!M && !l && !!X && !Wt(_t, gt), Jt = !Lt && !N && !!(X || Z), Et = () => {
|
|
312
319
|
var t;
|
|
313
|
-
return (t =
|
|
314
|
-
},
|
|
315
|
-
t.preventDefault(), t.stopPropagation(),
|
|
320
|
+
return (t = U.current) == null ? void 0 : t.click();
|
|
321
|
+
}, Kt = (t) => {
|
|
322
|
+
t.preventDefault(), t.stopPropagation(), Et();
|
|
316
323
|
};
|
|
317
|
-
return /* @__PURE__ */ q("div", { className:
|
|
318
|
-
|
|
324
|
+
return /* @__PURE__ */ q("div", { className: xt(a.croppable, at && a.standalone, Xt && a["drop-target"]), onDragEnter: (t) => {
|
|
325
|
+
t.preventDefault(), t.stopPropagation(), A.current += 1, pt(Tt(t.dataTransfer));
|
|
326
|
+
}, onDragOver: (t) => {
|
|
327
|
+
t.preventDefault(), t.stopPropagation(), t.dataTransfer.dropEffect = Tt(t.dataTransfer) ? "copy" : "none";
|
|
328
|
+
}, onDragLeave: (t) => {
|
|
329
|
+
t.preventDefault(), t.stopPropagation(), A.current = Math.max(0, A.current - 1), A.current || pt(!1);
|
|
330
|
+
}, onDrop: Bt, onClick: () => {
|
|
331
|
+
N && Et();
|
|
319
332
|
}, "data-component": "croppable", children: [
|
|
320
|
-
/* @__PURE__ */
|
|
321
|
-
/* @__PURE__ */
|
|
322
|
-
"--croppable-height": `${
|
|
323
|
-
"--croppable-zoom":
|
|
324
|
-
"--croppable-x": `${
|
|
325
|
-
"--croppable-y": `${
|
|
326
|
-
...
|
|
327
|
-
"--croppable-image-width": `${
|
|
328
|
-
"--croppable-image-height": `${
|
|
333
|
+
/* @__PURE__ */ p("input", { accept: "image/*", onChange: St, ref: U, type: "file" }),
|
|
334
|
+
/* @__PURE__ */ p("div", { className: a.viewport, ref: lt, onDragStart: (t) => t.preventDefault(), onPointerDown: Ft, onPointerMove: Gt, onPointerUp: Ut, onPointerCancel: Ut, onWheel: Zt, style: {
|
|
335
|
+
"--croppable-height": `${d ?? wr}px`,
|
|
336
|
+
"--croppable-zoom": Y,
|
|
337
|
+
"--croppable-x": `${k.offset.x}px`,
|
|
338
|
+
"--croppable-y": `${k.offset.y}px`,
|
|
339
|
+
...w ? {
|
|
340
|
+
"--croppable-image-width": `${C.width}px`,
|
|
341
|
+
"--croppable-image-height": `${C.height}px`
|
|
329
342
|
} : null
|
|
330
|
-
}, children: N ? /* @__PURE__ */
|
|
331
|
-
/* @__PURE__ */ q(
|
|
332
|
-
|
|
333
|
-
/* @__PURE__ */
|
|
334
|
-
|
|
335
|
-
image:
|
|
336
|
-
crop:
|
|
337
|
-
}),
|
|
343
|
+
}, children: N ? /* @__PURE__ */ p("div", { className: a.empty, children: /* @__PURE__ */ p(nr, { children: /* @__PURE__ */ p(er, { name: "Image", size: "large" }) }) }) : /* @__PURE__ */ p("div", { className: xt(a.media, yt && a.draggable, yt && bt && a.dragging), children: /* @__PURE__ */ p("div", { className: xt(a.inner), children: Mt }) }) }),
|
|
344
|
+
/* @__PURE__ */ q(rr, { children: [
|
|
345
|
+
It && /* @__PURE__ */ q("span", { className: a.action, children: [
|
|
346
|
+
/* @__PURE__ */ p(it, { isLoading: D, "aria-label": J ?? "Save image", icon: "FloppyDisk", onClick: () => {
|
|
347
|
+
et({
|
|
348
|
+
image: M,
|
|
349
|
+
crop: gt
|
|
350
|
+
}), v == null || v();
|
|
338
351
|
}, variant: "primary" }),
|
|
339
|
-
|
|
352
|
+
J && /* @__PURE__ */ p("span", { className: a.caption, children: J })
|
|
340
353
|
] }),
|
|
341
|
-
!
|
|
342
|
-
/* @__PURE__ */
|
|
343
|
-
/* @__PURE__ */
|
|
354
|
+
!It && /* @__PURE__ */ q("span", { className: a.action, children: [
|
|
355
|
+
/* @__PURE__ */ p(it, { "aria-label": K, icon: "UploadSimple", onClick: Kt, variant: "secondary" }),
|
|
356
|
+
/* @__PURE__ */ p("span", { className: a.caption, children: K })
|
|
344
357
|
] }),
|
|
345
|
-
|
|
346
|
-
/* @__PURE__ */
|
|
347
|
-
|
|
358
|
+
Lt && /* @__PURE__ */ q("span", { className: a.action, children: [
|
|
359
|
+
/* @__PURE__ */ p(it, { "aria-label": c ?? "Cancel changes", icon: "X", onClick: $t, variant: "secondary" }),
|
|
360
|
+
c && /* @__PURE__ */ p("span", { className: a.caption, children: c })
|
|
348
361
|
] }),
|
|
349
|
-
|
|
350
|
-
/* @__PURE__ */
|
|
351
|
-
|
|
362
|
+
Jt && /* @__PURE__ */ q("span", { className: a.action, children: [
|
|
363
|
+
/* @__PURE__ */ p(it, { "aria-label": z ?? "Delete image", icon: "Trash", intent: "danger", isLoading: tt, onClick: qt, variant: "secondary" }),
|
|
364
|
+
z && /* @__PURE__ */ p("span", { className: a.caption, children: z })
|
|
352
365
|
] })
|
|
353
366
|
] })
|
|
354
367
|
] });
|
|
355
368
|
};
|
|
356
369
|
export {
|
|
357
|
-
|
|
370
|
+
vr as Croppable
|
|
358
371
|
};
|
|
359
372
|
//# sourceMappingURL=index.js.map
|