@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.
Files changed (108) hide show
  1. package/dist/assets/index.css +1 -1
  2. package/dist/assets/index12.css +1 -1
  3. package/dist/assets/index13.css +1 -1
  4. package/dist/assets/index14.css +1 -1
  5. package/dist/assets/index19.css +1 -1
  6. package/dist/assets/index20.css +1 -1
  7. package/dist/assets/index21.css +1 -1
  8. package/dist/assets/index22.css +1 -1
  9. package/dist/assets/index23.css +1 -1
  10. package/dist/assets/index24.css +1 -1
  11. package/dist/assets/index25.css +1 -1
  12. package/dist/assets/index26.css +1 -1
  13. package/dist/assets/index27.css +1 -1
  14. package/dist/assets/index28.css +1 -1
  15. package/dist/assets/index29.css +1 -1
  16. package/dist/assets/index30.css +1 -1
  17. package/dist/assets/index31.css +1 -1
  18. package/dist/assets/index33.css +1 -1
  19. package/dist/assets/index35.css +1 -1
  20. package/dist/assets/index38.css +1 -1
  21. package/dist/assets/index40.css +1 -1
  22. package/dist/assets/index41.css +1 -1
  23. package/dist/assets/index42.css +1 -1
  24. package/dist/assets/index43.css +1 -0
  25. package/dist/assets/index5.css +1 -1
  26. package/dist/assets/index7.css +1 -1
  27. package/dist/assets/styles.css +1 -1
  28. package/dist/components/_avatar/index.cjs +1 -1
  29. package/dist/components/_avatar/index.js +1 -1
  30. package/dist/components/_card/index.cjs +1 -1
  31. package/dist/components/_card/index.js +11 -11
  32. package/dist/components/_collapsible/index.cjs +1 -1
  33. package/dist/components/_collapsible/index.cjs.map +1 -1
  34. package/dist/components/_collapsible/index.js +3 -3
  35. package/dist/components/_collapsible/index.js.map +1 -1
  36. package/dist/components/_croppable/index.cjs +1 -1
  37. package/dist/components/_croppable/index.cjs.map +1 -1
  38. package/dist/components/_croppable/index.js +238 -159
  39. package/dist/components/_croppable/index.js.map +1 -1
  40. package/dist/components/_dropzone/index.cjs +1 -1
  41. package/dist/components/_dropzone/index.js +1 -1
  42. package/dist/components/_editor/index.cjs +25 -25
  43. package/dist/components/_editor/index.cjs.map +1 -1
  44. package/dist/components/_editor/index.js +1782 -1784
  45. package/dist/components/_editor/index.js.map +1 -1
  46. package/dist/components/_messages/index.cjs +1 -1
  47. package/dist/components/_messages/index.js +1 -1
  48. package/dist/components/_portal/index.cjs +1 -1
  49. package/dist/components/_portal/index.js +4 -4
  50. package/dist/components/_sortable/index.cjs +1 -1
  51. package/dist/components/_sortable/index.js +1 -1
  52. package/dist/components/_toasts/index.cjs +1 -1
  53. package/dist/components/_toasts/index.js +9 -9
  54. package/dist/components/_widget/index.cjs +1 -1
  55. package/dist/components/_widget/index.js +1 -1
  56. package/dist/components/accordion/index.cjs +1 -1
  57. package/dist/components/accordion/index.js +1 -1
  58. package/dist/components/aside/index.cjs +1 -1
  59. package/dist/components/aside/index.js +3 -3
  60. package/dist/components/button/index.cjs +1 -1
  61. package/dist/components/button/index.js +15 -15
  62. package/dist/components/checkbox/index.cjs +1 -1
  63. package/dist/components/checkbox/index.js +6 -6
  64. package/dist/components/controls/index.cjs +1 -1
  65. package/dist/components/controls/index.cjs.map +1 -1
  66. package/dist/components/controls/index.js +8 -8
  67. package/dist/components/controls/index.js.map +1 -1
  68. package/dist/components/dialog/index.cjs +1 -1
  69. package/dist/components/dialog/index.js +7 -7
  70. package/dist/components/form/index.cjs +1 -1
  71. package/dist/components/form/index.js +4 -4
  72. package/dist/components/header/index.cjs +1 -1
  73. package/dist/components/header/index.js +3 -3
  74. package/dist/components/input/index.cjs +1 -1
  75. package/dist/components/input/index.js +1 -1
  76. package/dist/components/layout/index.cjs +1 -1
  77. package/dist/components/layout/index.js +10 -10
  78. package/dist/components/list/index.cjs +1 -1
  79. package/dist/components/list/index.js +8 -8
  80. package/dist/components/nav/index.cjs +1 -1
  81. package/dist/components/nav/index.cjs.map +1 -1
  82. package/dist/components/nav/index.js +35 -20
  83. package/dist/components/nav/index.js.map +1 -1
  84. package/dist/components/textarea/index.cjs +1 -1
  85. package/dist/components/textarea/index.js +14 -14
  86. package/dist/components/toast/index.cjs +1 -1
  87. package/dist/components/toast/index.js +20 -20
  88. package/dist/components/toggle/index.cjs +1 -1
  89. package/dist/components/toggle/index.cjs.map +1 -1
  90. package/dist/components/toggle/index.js +9 -9
  91. package/dist/components/toggle/index.js.map +1 -1
  92. package/dist/components/toolbar/index.cjs +2 -0
  93. package/dist/components/toolbar/index.cjs.map +1 -0
  94. package/dist/components/toolbar/index.js +14 -0
  95. package/dist/components/toolbar/index.js.map +1 -0
  96. package/dist/index.cjs +1 -1
  97. package/dist/index.d.ts +13 -1
  98. package/dist/index.js +16 -14
  99. package/dist/index.js.map +1 -1
  100. package/dist/styles.module-BuPl_9yN.cjs +2 -0
  101. package/dist/styles.module-BuPl_9yN.cjs.map +1 -0
  102. package/dist/styles.module-ZrsD4xw8.js +10 -0
  103. package/dist/styles.module-ZrsD4xw8.js.map +1 -0
  104. package/package.json +1 -1
  105. package/dist/styles.module--qoz6wR5.cjs +0 -2
  106. package/dist/styles.module--qoz6wR5.cjs.map +0 -1
  107. package/dist/styles.module-y5zmJBcz.js +0 -10
  108. package/dist/styles.module-y5zmJBcz.js.map +0 -1
@@ -1,244 +1,323 @@
1
- import { jsxs as gt, jsx as p } from "react/jsx-runtime";
2
- import { t as nt } from "../../classix-DG18itHa.js";
3
- import { useRef as l, useState as L, useEffect as O } from "react";
4
- import { Figure as wt } from "../figure/index.js";
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/index23.css';const yt = "_croppable_1mlwb_1", bt = "_viewport_1mlwb_21", zt = "_media_1mlwb_34", Mt = "_draggable_1mlwb_45", _t = "_dragging_1mlwb_49", Rt = "_inner_1mlwb_53", z = {
7
- croppable: yt,
8
- viewport: bt,
9
- media: zt,
10
- draggable: Mt,
11
- dragging: _t,
12
- inner: Rt
13
- }, It = 192, X = {
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
- }, M = 10, W = 0.1, d = (v, Y, E) => Math.min(E, Math.max(Y, v)), Ut = ({
20
- children: v,
21
- fill: Y = "none",
22
- height: E,
23
- onCroppableChange: Z,
24
- onFileChange: g,
25
- onTransformChange: A,
26
- transform: h
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 _ = l(null), w = l(null), a = l(null), $ = l(null), x = l(null), P = l(null), R = l(null), D = l(/* @__PURE__ */ new Map()), i = l(X), S = l(null), [u, k] = L(null), [q, G] = L(null), [K, j] = L(!1), [ot, V] = L(X), [f, ct] = L({
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
- }), I = (() => {
32
- const t = f.width, e = f.height;
33
- if (!t || !e) return {
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: W
70
+ minZoom: Z
37
71
  };
38
- if (!u) return {
72
+ if (!a) return {
39
73
  width: t,
40
- height: e,
41
- minZoom: W
74
+ height: n,
75
+ minZoom: Z
42
76
  };
43
- const n = t / u.width, r = e / u.height, o = Math.max(n, r), c = Y === "width" ? n / o : Y === "height" ? r / o : 0;
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: u.width * o,
46
- height: u.height * o,
47
- minZoom: Math.max(W, c)
79
+ width: a.width * o,
80
+ height: a.height * o,
81
+ minZoom: Math.max(Z, i)
48
82
  };
49
- })(), y = I.minZoom, B = h ?? ot, T = d(B.zoom, y, M), J = v ?? (q ? /* @__PURE__ */ p("img", { draggable: !1, onLoad: (t) => {
50
- const e = t.currentTarget;
51
- e.naturalWidth && e.naturalHeight && k({
52
- width: e.naturalWidth,
53
- height: e.naturalHeight
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: q }) : null), b = J == null, N = (t, e) => {
89
+ }, src: K }) : null), H = at == null, et = (t, n) => {
56
90
  const {
57
- maxX: n,
58
- maxY: r
59
- } = F(e);
91
+ maxX: r,
92
+ maxY: e
93
+ } = ut(n);
60
94
  return {
61
- x: d(t.x, -n, n),
62
- y: d(t.y, -r, r)
95
+ x: d(t.x, -r, r),
96
+ y: d(t.y, -e, e)
63
97
  };
64
- }, Q = (t, e) => {
65
- const n = S.current;
66
- if (!n) return null;
67
- const r = n.getBoundingClientRect(), o = t - r.left - r.width / 2, c = e - r.top - r.height / 2;
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: c
104
+ y: i
71
105
  };
72
- }, it = (t, e, n, r) => {
73
- const o = d(e, y, M), c = d(n, y, M);
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 s = c / o;
109
+ const l = i / o;
76
110
  return {
77
- x: (1 - s) * r.x + s * t.x,
78
- y: (1 - s) * r.y + s * t.y
111
+ x: (1 - l) * e.x + l * t.x,
112
+ y: (1 - l) * e.y + l * t.y
79
113
  };
80
- }, st = (t, e, n) => {
81
- const r = i.current.zoom, o = d(t, y, M), c = i.current.offset, s = n ? it(c, r, o, n) : e, m = N(s, o);
82
- i.current = {
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: m
85
- }, h || V({
118
+ offset: O
119
+ }, R || ct({
86
120
  zoom: o,
87
- offset: m
88
- }), A == null || A({
121
+ offset: O
122
+ }), j == null || j({
89
123
  zoom: o,
90
- offset: m
124
+ offset: O
91
125
  });
92
- }, U = (t, e, n) => {
93
- P.current = {
126
+ }, V = (t, n, r) => {
127
+ Y.current = {
94
128
  zoom: t,
95
- offset: e,
96
- anchor: n ?? null
97
- }, w.current == null && (w.current = window.requestAnimationFrame(() => {
98
- w.current = null;
99
- const r = P.current;
100
- P.current = null;
101
- const o = (r == null ? void 0 : r.zoom) ?? i.current.zoom, c = (r == null ? void 0 : r.offset) ?? i.current.offset, s = (r == null ? void 0 : r.anchor) ?? null;
102
- st(o, c, s);
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
- if (b) return;
106
- const e = t.ctrlKey ? 1e-3 : 25e-5, n = i.current.zoom * Math.exp(-t.deltaY * e), r = Q(t.clientX, t.clientY);
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 r = d(t, y, M), o = I.width * r, c = I.height * r, s = Math.max(0, (o - e) / 2), m = Math.max(0, (c - n) / 2);
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: s,
117
- maxY: m
150
+ maxX: l,
151
+ maxY: O
118
152
  };
119
- }, lt = (t) => {
153
+ }, Lt = (t) => {
120
154
  var o;
121
- const e = t.target, n = ((o = e.files) == null ? void 0 : o[0]) ?? null;
122
- if (x.current && (URL.revokeObjectURL(x.current), x.current = null), !n) {
123
- G(null), g == null || g(null), e.value = "";
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 r = URL.createObjectURL(n);
127
- x.current = r, G(r), k(null), U(X.zoom, X.offset), i.current = X, g == null || g(n), e.value = "";
128
- }, at = (t) => {
129
- if (!(b || t.pointerType === "mouse" && t.button !== 0)) {
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 e = D.current;
132
- if (e.set(t.pointerId, {
165
+ const n = U.current;
166
+ if (n.set(t.pointerId, {
133
167
  x: t.clientX,
134
168
  y: t.clientY
135
- }), e.size === 2) {
136
- a.current = null, _.current = null, j(!1);
137
- const [n, r] = Array.from(e.values());
138
- R.current = Math.hypot(n.x - r.x, n.y - r.y);
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
- _.current = t.pointerId, a.current = {
176
+ L.current = t.pointerId, b.current = {
143
177
  x: t.clientX,
144
178
  y: t.clientY,
145
- originX: i.current.offset.x,
146
- originY: i.current.offset.y
179
+ originX: c.current.offset.x,
180
+ originY: c.current.offset.y
147
181
  };
148
182
  }
149
- }, ft = (t) => {
150
- if (b) return;
183
+ }, vt = (t) => {
184
+ if (H || !Q) return;
151
185
  if (t.pointerType === "touch") {
152
- const o = D.current;
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 [c, s] = Array.from(o.values()), m = c.x - s.x, dt = c.y - s.y, et = Math.hypot(m, dt), rt = {
159
- x: (c.x + s.x) / 2,
160
- y: (c.y + s.y) / 2
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 (R.current) {
163
- const ht = et / R.current, mt = i.current.zoom * ht, pt = Q(rt.x, rt.y);
164
- U(mt, i.current.offset, pt);
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
- R.current = et;
200
+ v.current = pt;
167
201
  return;
168
202
  }
169
203
  }
170
- if (_.current !== t.pointerId || !a.current || !H) return;
171
- const e = t.clientX - a.current.x, n = t.clientY - a.current.y, r = Math.abs(e) + Math.abs(n);
172
- !K && r > 2 && j(!0), !(r <= 1) && U(i.current.zoom, {
173
- x: a.current.originX + e,
174
- y: a.current.originY + n
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
- }, C = (t) => {
177
- t.pointerType === "touch" && (D.current.delete(t.pointerId), D.current.size < 2 && (R.current = null)), _.current === t.pointerId && (_.current = null, a.current = null, j(!1));
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
- O(() => {
180
- if (!h) return;
181
- const t = d(h.zoom, y, M);
182
- i.current = {
213
+ E(() => {
214
+ if (!R) return;
215
+ const t = d(R.zoom, D, I);
216
+ c.current = {
183
217
  zoom: t,
184
- offset: N(h.offset, t)
218
+ offset: et(R.offset, t)
185
219
  };
186
- }, [h, f.width, f.height, u == null ? void 0 : u.width, u == null ? void 0 : u.height]), O(() => () => {
187
- x.current && URL.revokeObjectURL(x.current);
188
- }, []), O(() => {
189
- const t = S.current;
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 e = () => {
225
+ const n = () => {
192
226
  const o = t.getBoundingClientRect();
193
- ct((c) => c.width === o.width && c.height === o.height ? c : {
227
+ Mt((i) => i.width === o.width && i.height === o.height ? i : {
194
228
  width: o.width,
195
229
  height: o.height
196
- }), Z && Z(o);
230
+ }), P && P(o);
197
231
  };
198
- e();
199
- const n = () => e();
200
- if (window.addEventListener("scroll", n, !0), typeof ResizeObserver > "u") {
201
- const o = () => e();
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", n, !0);
237
+ window.removeEventListener("resize", o), window.removeEventListener("scroll", r, !0);
204
238
  };
205
239
  }
206
- const r = new ResizeObserver(() => e());
207
- return r.observe(t), () => {
208
- r.disconnect(), window.removeEventListener("scroll", n, !0);
240
+ const e = new ResizeObserver(() => n());
241
+ return e.observe(t), () => {
242
+ e.disconnect(), window.removeEventListener("scroll", r, !0);
209
243
  };
210
- }, [Z]), O(() => {
211
- if (h) return;
212
- const t = i.current.offset, e = N(t, T);
213
- t.x === e.x && t.y === e.y || (i.current = {
214
- zoom: i.current.zoom,
215
- offset: e
216
- }, V((n) => ({
217
- ...n,
218
- offset: e
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
- }, [T, u, f.width, f.height]), O(() => () => {
221
- w.current != null && (window.cancelAnimationFrame(w.current), w.current = null);
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 tt = F(T), H = !b && (tt.maxX > 0 || tt.maxY > 0);
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
- b && ((t = $.current) == null || t.click());
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__ */ p("input", { accept: "image/*", onChange: lt, ref: $, type: "file" }),
229
- /* @__PURE__ */ p("div", { className: z.viewport, ref: S, onDragStart: (t) => t.preventDefault(), onPointerDown: at, onPointerMove: ft, onPointerUp: C, onPointerCancel: C, onWheel: ut, style: {
230
- "--croppable-height": `${E ?? It}px`,
231
- "--croppable-zoom": T,
232
- "--croppable-x": `${B.offset.x}px`,
233
- "--croppable-y": `${B.offset.y}px`,
234
- ...u ? {
235
- "--croppable-image-width": `${I.width}px`,
236
- "--croppable-image-height": `${I.height}px`
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: b ? /* @__PURE__ */ p(wt, { children: /* @__PURE__ */ p(xt, { name: "image" }) }) : /* @__PURE__ */ p("div", { className: nt(z.media, H && z.draggable, H && K && z.dragging), children: /* @__PURE__ */ p("div", { className: nt(z.inner), children: J }) }) })
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
- Ut as Croppable
321
+ Ct as Croppable
243
322
  };
244
323
  //# sourceMappingURL=index.js.map