@sheetxl/react 0.8.0-beta.12 → 0.8.0-beta.13

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 (87) hide show
  1. package/browser/esm/{D2GydDzPuvIjdpok.mjs → -wQNyCnoJdQUTTfP.mjs} +1 -1
  2. package/browser/esm/{CUekkfE6uwwsdQpc.mjs → AL94cpxFjPurAMQG.mjs} +1 -1
  3. package/browser/esm/{Ck1LbcsdSfKNi6xq.mjs → B4K8rf7TAv0SBkbG.mjs} +1 -1
  4. package/browser/esm/{BapujiblfiXDlu67.mjs → BrwfFgqKdMG_-iar.mjs} +1 -1
  5. package/browser/esm/ByBGwdqhc_l75i5G.mjs +145 -0
  6. package/browser/esm/{C_LUq-BnguetvGZz.mjs → C1zqAqKQ6oa4FiTH.mjs} +2 -2
  7. package/browser/esm/C9lQPmVMIlUwXkKr.mjs +303 -0
  8. package/browser/esm/{D_usN3pWuCJU2GN-.mjs → CIrcPI7uOT93ydNn.mjs} +2 -2
  9. package/browser/esm/{DxEczXCHTerDemDP.mjs → CZsNidKZjsn0lNnA.mjs} +4 -4
  10. package/browser/esm/{DN3lqq95KY0K6f1x.mjs → CcewpxckpDrXSiZ-.mjs} +1 -1
  11. package/browser/esm/{D22NJmTiky4NL8tM.mjs → CdDvFP8Fqm8uU7Rw.mjs} +1 -1
  12. package/browser/esm/{CSFORKZ8zrVL_Y0w.mjs → CfewUx0gINn-wXt3.mjs} +1 -1
  13. package/browser/esm/{LBQDhVhz7S7i6a8i.mjs → CfvYfq6ALVqkCsdg.mjs} +1 -1
  14. package/browser/esm/CulxiChz6lj3G9lw.mjs +341 -0
  15. package/browser/esm/D5Uy22WeT7vUS36Z.mjs +19 -0
  16. package/browser/esm/{Cslk_qRdBSuJIi1O.mjs → Dd8deQ2CDMdrhzF1.mjs} +6 -6
  17. package/browser/esm/{CtGhA0kS2MCfEsHN.mjs → Dit7p67J_fDF5RDj.mjs} +3 -3
  18. package/browser/esm/{ZoS0cpNEBcv6p-Z1.mjs → DzWFl-_dCN-EOkio.mjs} +3 -3
  19. package/browser/esm/{B4mT3G7GHwgDYFGP.mjs → MIDbAwdzknMaoTU5.mjs} +2 -2
  20. package/browser/esm/{BDlpRkuBok0Uu4Hn.mjs → ao9zR4H88b7AmZEV.mjs} +1 -1
  21. package/browser/esm/chart.mjs +3 -3
  22. package/browser/esm/control.mjs +74 -73
  23. package/browser/esm/group.mjs +3 -3
  24. package/browser/esm/index.mjs +3971 -3744
  25. package/browser/esm/note.mjs +5 -5
  26. package/browser/esm/picture.mjs +2 -81
  27. package/browser/esm/sXn9faQLuh4P0TZ9.mjs +401 -0
  28. package/browser/esm/shape.mjs +2 -2
  29. package/browser/esm/slicer.mjs +112 -111
  30. package/browser/esm/{DGG1auUKsjFbAazu.mjs → u3A8I4A7GKIOLOOb.mjs} +3 -3
  31. package/browser/esm/{_6Sb6ElRcZftxMNh.mjs → x6A47UA3fzV361tO.mjs} +1 -1
  32. package/node/esm/{CalVk3o4-kX79s3v.mjs → A_4Y7EtzCWp1AG3Y.mjs} +1 -1
  33. package/node/esm/BNwVylzKMErhrx4i.mjs +406 -0
  34. package/node/esm/BPBUSXc5TVnD15By.mjs +146 -0
  35. package/node/esm/{bRD1KCpSpAYTEs50.mjs → BTT6UB5lGvPxcq3F.mjs} +1 -1
  36. package/node/esm/{DXiNwr6ZnXBe7TlG.mjs → BYiAmyF-aOOuMkD1.mjs} +1 -1
  37. package/node/esm/{YB_qExw23Ci4nMYy.mjs → BqS8o-CmPoCjHDHp.mjs} +2 -2
  38. package/node/esm/{Bi2Jwc0zpweaNzKc.mjs → CC_XgLOFPvqmFyZ_.mjs} +2 -2
  39. package/node/esm/{Apcuz4_QtBHt7G47.mjs → CMGUrHMaBDeCezK5.mjs} +1 -1
  40. package/node/esm/{DWkPWuf5ZrLRMixG.mjs → CP07qkepi21zlB0n.mjs} +15 -15
  41. package/node/esm/{CzN6c6KyxVmNvayz.mjs → CQJJMfuXl6mbgHdT.mjs} +1 -1
  42. package/node/esm/{DyetXBW7vFLJWB22.mjs → CVDVFhM7OIpaOlyN.mjs} +1 -1
  43. package/node/esm/{iL9jKJcnED6oi0B4.mjs → CVMuO9bpR5YK0pPb.mjs} +1 -1
  44. package/node/esm/{T5lfCrudsUnOTxEn.mjs → CaZG4HD3SmHvD-Tu.mjs} +1 -1
  45. package/node/esm/{DKqdv5JubgVaq-g9.mjs → CuRPfxQCj2jookWL.mjs} +1 -1
  46. package/node/esm/D8mYmUPUA6i8oFgR.mjs +19 -0
  47. package/node/esm/{MWges5ywL3aEdChp.mjs → DAUtyjkW5uSdnTli.mjs} +1 -1
  48. package/node/esm/{C0KLMCRb3sbd5Q20.mjs → DfvJ0Dpn-AP2mGtz.mjs} +5 -5
  49. package/node/esm/{DayGI0Bt57FDNbVF.mjs → DipZYwHed-W6QMtQ.mjs} +1 -1
  50. package/node/esm/{CNOLkUDURBElaaIf.mjs → NvP_j9pSsDiJ_PyY.mjs} +3 -3
  51. package/node/esm/chart.mjs +2 -2
  52. package/node/esm/control.mjs +79 -78
  53. package/node/esm/{CH1DVfFhjdd_3pw1.mjs → eecr5gnC2KqVhOzX.mjs} +2 -2
  54. package/node/esm/group.mjs +3 -3
  55. package/node/esm/index.mjs +6469 -6242
  56. package/node/esm/note.mjs +18 -18
  57. package/node/esm/picture.mjs +269 -50
  58. package/node/esm/shape.mjs +186 -580
  59. package/node/esm/slicer.mjs +51 -50
  60. package/package.json +7 -7
  61. package/resources/locales/de/picture.cmd.json +157 -0
  62. package/resources/locales/de/sheet.cmd.json +24 -2
  63. package/resources/locales/de/ui.msg.json +3 -0
  64. package/resources/locales/en/picture.cmd.json +157 -0
  65. package/resources/locales/en/sheet.cmd.json +24 -2
  66. package/resources/locales/en/ui.msg.json +3 -0
  67. package/types/src/chart/ChartCommands.d.ts +1 -1
  68. package/types/src/chart/paint/_graphics.d.ts +0 -8
  69. package/types/src/chart/paint/echarts.d.ts +1 -1
  70. package/types/src/chart/paint/index.d.ts +1 -1
  71. package/types/src/chart/paint/kinds/ChartPaintKind.d.ts +1 -1
  72. package/types/src/chart/paint/kinds/_builtIns.d.ts +0 -9
  73. package/types/src/chart/paint/toEChartsOption.d.ts +1 -1
  74. package/types/src/layer/CircularIndicatorLayer.d.ts +1 -1
  75. package/types/src/layer/HyperlinkLayer.d.ts +13 -9
  76. package/types/src/layer/_visibleCellFeatures.d.ts +11 -0
  77. package/types/src/layer/useValidationPicker.d.ts +1 -1
  78. package/types/src/movable/useFramePreview.d.ts +17 -0
  79. package/types/src/picture/PictureCommands.d.ts +8 -0
  80. package/types/src/picture/_pictureHyperlink.d.ts +13 -0
  81. package/types/src/picture/pictureCrop.d.ts +32 -0
  82. package/types/src/sheet/_hyperlinkEdit.d.ts +7 -0
  83. package/types/src/sheet/circularReferences.d.ts +1 -1
  84. package/types/src/theme/buildDocThemeCSS.d.ts +4 -1
  85. package/browser/esm/BR-AiOwuQlYh5-tr.mjs +0 -730
  86. package/browser/esm/DhYQRc8L2kALmFNz.mjs +0 -75
  87. package/node/esm/Cp1DuCae46eQKzWy.mjs +0 -76
@@ -1,730 +0,0 @@
1
- /**
2
- * @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.12
3
- *
4
- * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
- * License: The license can be found at https://www.sheetxl.com/license.
6
- */
7
- import { t as e } from "./LBQDhVhz7S7i6a8i.mjs";
8
- import { n as t } from "./Ck1LbcsdSfKNi6xq.mjs";
9
- import { t as n } from "./CSFORKZ8zrVL_Y0w.mjs";
10
- import { t as r } from "./ZoS0cpNEBcv6p-Z1.mjs";
11
- import { Color as i, IFill as a, IGeometry as o, IStroke as s, PaintUtils as c, ShapeStyleUtils as l } from "@sheetxl/sdk";
12
- import { forwardRef as u, memo as d, useCallback as f, useEffect as p, useId as m, useMemo as h, useReducer as g, useRef as _, useState as v } from "react";
13
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
14
- import { BufferUtils as S, messageKey as ee } from "@sheetxl/utils";
15
- import { useSurfaceState as te } from "@sheetxl/grid-react";
16
- import { ReactUtils as ne, useImperativeElement as C } from "@sheetxl/utils-react";
17
- import { createPortal as w } from "react-dom";
18
- var re = 96 / 72, ie = (e, t) => {
19
- if (typeof e != "string" || !e) return null;
20
- try {
21
- return (t ? t.parseColor(e) : new i(e))?.toCSS("adaptive") ?? null;
22
- } catch {
23
- return null;
24
- }
25
- }, ae = (e) => {
26
- if (!e) return null;
27
- switch (e.type) {
28
- case a.Type.Solid: return e.color ?? null;
29
- case a.Type.Gradient: {
30
- let t = e.stops?.[0];
31
- return (typeof t == "string" ? t : t?.color) ?? null;
32
- }
33
- case a.Type.Pattern: return e.foreground ?? e.background ?? null;
34
- case a.Type.Image:
35
- default: return null;
36
- }
37
- }, T = (e) => Math.max(0, Math.min(1, e ?? 0)), oe = (e) => {
38
- let t = e.stops ?? [];
39
- if (t.length < 2) return null;
40
- let n = t.length - 1, r = [];
41
- for (let e = 0; e < t.length; e++) {
42
- let i = t[e], a = typeof i == "string" ? i : i?.color;
43
- if (!a) return null;
44
- let o = typeof i == "object" && typeof i.offset == "number" ? i.offset : e / n;
45
- r.push({
46
- offset: T(o),
47
- color: a
48
- });
49
- }
50
- if (r.sort((e, t) => e.offset - t.offset), (e.gradientType ?? a.GradientType.Linear) === a.GradientType.Linear) return {
51
- kind: "linear",
52
- angle: (((e.angle ?? 0) - 90) % 360 + 360) % 360,
53
- scaled: e.scaled ?? !0,
54
- stops: r
55
- };
56
- let i = e.focus, o = T(i?.left), s = T(i?.top), c = T(i?.right), l = T(i?.bottom);
57
- if (o > c || s > l) return null;
58
- let u = (o + c) / 2, d = (s + l) / 2, f = Math.max(u, 1 - u), p = Math.max(d, 1 - d);
59
- return {
60
- kind: "radial",
61
- cx: u,
62
- cy: d,
63
- r: Math.hypot(f, p),
64
- stops: r
65
- };
66
- }, se = l.inheritedGroupFill, ce = /[MLQCAZ]|[-+]?(?:\d+\.?\d*|\.\d+)(?:[eE][-+]?\d+)?/g, le = {
67
- M: 1,
68
- L: 1,
69
- Q: 2,
70
- C: 3,
71
- A: 1,
72
- Z: 0
73
- }, ue = (e) => String(Math.round(1e5 * e) / 1e5), de = (e) => {
74
- let t = e.match(ce) ?? [], n = [], r = [], i = [], a = {
75
- x: 0,
76
- y: 0
77
- }, o = null, s = 0, c = null;
78
- for (; s < t.length;) {
79
- let e = t[s];
80
- if (le[e] !== void 0) c = e, s++;
81
- else if (c === "M") c = "L";
82
- else if (c === null || c === "Z") break;
83
- if (c === "Z") {
84
- o &&= (r.push({
85
- from: a,
86
- to: o
87
- }), i.push(a), n.push({
88
- c,
89
- pts: []
90
- }), a = o, null);
91
- continue;
92
- }
93
- let l = c === "A" ? t.slice(s, s + 5) : void 0;
94
- l && (s += 5);
95
- let u = [];
96
- for (let e = 0; e < le[c]; e++) u.push({
97
- x: Number(t[s++]),
98
- y: Number(t[s++])
99
- });
100
- let d = u[u.length - 1];
101
- if (!d || Number.isNaN(d.x) || Number.isNaN(d.y)) break;
102
- c === "M" ? (o && i.push(a), o = d, i.push(d)) : (c === "L" && r.push({
103
- from: a,
104
- to: d
105
- }), o || (o = a, i.push(a))), n.push({
106
- c,
107
- pts: u,
108
- arc: l
109
- }), a = d;
110
- }
111
- return o && i.push(a), {
112
- cmds: n,
113
- straight: r,
114
- ends: i
115
- };
116
- }, E = (e) => {
117
- let t = [];
118
- for (let n of e) {
119
- let e = n.pts.map((e) => `${ue(e.x)} ${ue(e.y)}`).join(" ");
120
- t.push(n.c === "Z" ? "Z" : `${n.c}${n.arc ? `${n.arc.join(" ")} ` : ""}${e}`);
121
- }
122
- return t.join(" ");
123
- }, D = 1e-6, O = (e, t, n, r, i) => {
124
- let a = r ? (i - e) * t.zoom : e * t.zoom, o = ne.snapLineCenter(a, n, t.dpr);
125
- return r ? i - o / t.zoom : o / t.zoom;
126
- }, fe = (e, t, n) => {
127
- let r = de(e), i = r.ends.map((e) => ({
128
- x: e.x,
129
- y: e.y
130
- })), a = n * t.zoom, o = [];
131
- for (let e of r.straight) {
132
- let t = Math.abs(e.to.y - e.from.y) < D;
133
- t !== Math.abs(e.to.x - e.from.x) < D && o.push({
134
- seg: e,
135
- level: t,
136
- at: t ? e.from.y : e.from.x
137
- });
138
- }
139
- for (let { seg: e, level: n, at: r } of o) n ? e.from.y = e.to.y = O(r, t, a, t.flipV, t.height) : e.from.x = e.to.x = O(r, t, a, t.flipH, t.width);
140
- let s = [];
141
- return r.ends.forEach((e, t) => {
142
- let n = {
143
- x: e.x - i[t].x,
144
- y: e.y - i[t].y
145
- };
146
- n.x === 0 && n.y === 0 || s.push({
147
- at: i[t],
148
- by: n
149
- });
150
- }), {
151
- d: E(r.cmds),
152
- ends: s
153
- };
154
- }, pe = (e, t) => {
155
- if (t.length === 0) return e;
156
- let n = de(e), r = [], i = null, a = /* @__PURE__ */ new Set(), o = () => {
157
- if (!i) return;
158
- let e = null, n = 1 / 0;
159
- for (let r of t) {
160
- let t = Math.hypot(r.at.x - i.x, r.at.y - i.y);
161
- t < n && (e = r, n = t);
162
- }
163
- for (let t of r) a.has(t) || (a.add(t), t.x += e.by.x, t.y += e.by.y);
164
- r = [], i = null;
165
- };
166
- for (let e of n.cmds) {
167
- e.c === "M" && (o(), i = e.pts[0]);
168
- for (let t of e.pts) r.push(t);
169
- }
170
- return o(), E(n.cmds);
171
- }, k = /* @__PURE__ */ new WeakMap(), me = { filter: "var(--sxl-image-filter)" }, A = (e) => {
172
- let [t, n] = v(null);
173
- return p(() => {
174
- if (!e) return;
175
- let t = !0;
176
- return ((e) => {
177
- let t = k.get(e);
178
- return t || (t = (async () => {
179
- let t = await e.getExternalURI();
180
- if (t) return t;
181
- let [n, r] = await Promise.all([e.toBuffer(), e.getType()]);
182
- return `data:${r?.mime ?? "image/png"};base64,${S.arrayBufferToBase64(n)}`;
183
- })(), k.set(e, t)), t;
184
- })(e).then((r) => {
185
- t && n({
186
- resource: e,
187
- url: r
188
- });
189
- }, () => {}), () => {
190
- t = !1;
191
- };
192
- }, [e]), e && t?.resource === e ? t.url : null;
193
- }, j = (e, t, n, r) => {
194
- let i = t.stops.map((e, t) => b("stop", {
195
- offset: e.offset,
196
- stopColor: e.color
197
- }, t));
198
- if (t.kind === "linear") {
199
- let a = t.angle * Math.PI / 180, o = Math.cos(a), s = Math.sin(a);
200
- if (t.scaled) {
201
- o *= n, s *= r;
202
- let e = Math.hypot(o, s) || 1;
203
- o /= e, s /= e;
204
- }
205
- let c = (Math.abs(n * o) + Math.abs(r * s)) / 2, l = n / 2, u = r / 2;
206
- return b("linearGradient", {
207
- id: e,
208
- gradientUnits: "userSpaceOnUse",
209
- x1: l - c * o,
210
- y1: u - c * s,
211
- x2: l + c * o,
212
- y2: u + c * s,
213
- children: i
214
- }, e);
215
- }
216
- return b("radialGradient", {
217
- id: e,
218
- gradientUnits: "userSpaceOnUse",
219
- cx: t.cx * n,
220
- cy: t.cy * n,
221
- r: t.r * n,
222
- gradientTransform: `scale(1 ${r / n})`,
223
- children: i
224
- }, e);
225
- }, M = d(({ paths: e, style: t, width: n, height: r, zoom: i, grid: a, hit: s }) => {
226
- let c = m().replace(/[^A-Za-z0-9_-]/g, ""), l = A(t.image?.resource ?? null), u = ((e, t, n = 1) => {
227
- let r = (t > 0 ? t : 1) * (n > 0 ? n : 1);
228
- return Math.max(1, Math.round(Math.max(0, e || 0) * r)) / r;
229
- })(t.strokeWidth, i, a?.dpr ?? ne.getDevicePixelRatio()), d = n > 0 && r > 0, f = d ? t.gradient ?? null : null, p = d ? t.strokeGradient ?? null : null, g = t.image ? l ? `url(#${c}-image)` : null : f ? `url(#${c}-fill)` : t.fill, _ = p ? `url(#${c}-stroke)` : t.stroke, v = t.stroke !== null && u > 0, S = v ? ((e, t, n) => {
230
- if (!(e && t > 0)) return;
231
- let r = n !== "butt", i = e.map((e, n) => {
232
- let i = e * t;
233
- return r ? n % 2 == 0 ? Math.max(0, i - t) : i + t : i;
234
- });
235
- return i.length % 2 == 1 && i.push(r ? t : 0), i.map((e) => +e.toFixed(3)).join(" ");
236
- })(t.dash, u, t.lineCap) : void 0, ee = h(() => ((e, t, n) => {
237
- let r = /* @__PURE__ */ new Map();
238
- if (!t) return r;
239
- let i = /* @__PURE__ */ new Map(), a = [];
240
- for (let s of e) {
241
- if (s.layer !== o.PathLayer.Stroke) continue;
242
- let e = i.get(s.d);
243
- if (e === void 0) {
244
- let r = fe(s.d, t, n);
245
- e = r.d, i.set(s.d, e), a.push(...r.ends);
246
- }
247
- r.set(s.index, e);
248
- }
249
- for (let t of e) if (t.layer === o.PathLayer.Fill) {
250
- let e = i.get(t.d);
251
- e !== void 0 && r.set(t.index, e);
252
- } else t.layer === o.PathLayer.Marker && r.set(t.index, pe(t.d, a));
253
- return r;
254
- })(e, v ? a : null, u), [
255
- e,
256
- v,
257
- a,
258
- u
259
- ]), te = /* @__PURE__ */ new Set(), C = [];
260
- for (let n of e) {
261
- let e = `p${n.index}`, r = ee.get(n.index) ?? n.d;
262
- switch (n.layer) {
263
- case o.PathLayer.Fill:
264
- if (g === null) break;
265
- n.fill !== "norm" && te.add(n.fill), C.push(b("path", {
266
- d: r,
267
- fill: g,
268
- filter: n.fill === "norm" ? void 0 : `url(#${c}-${n.fill})`,
269
- stroke: "none",
270
- pointerEvents: s
271
- }, e));
272
- break;
273
- case o.PathLayer.Stroke: {
274
- if (!v) break;
275
- let n = 8 / (i > 0 ? i : 1);
276
- s !== "none" && n > u && C.push(b("path", {
277
- className: "shape-hit",
278
- d: r,
279
- fill: "none",
280
- stroke: "transparent",
281
- strokeWidth: n,
282
- strokeLinejoin: "round",
283
- strokeLinecap: "round",
284
- pointerEvents: "stroke"
285
- }, `${e}-hit`)), C.push(b("path", {
286
- d: r,
287
- fill: "none",
288
- stroke: _,
289
- strokeWidth: u,
290
- strokeLinejoin: t.lineJoin,
291
- strokeLinecap: t.lineCap,
292
- strokeMiterlimit: t.lineJoin === "miter" ? t.miterLimit : void 0,
293
- strokeDasharray: S,
294
- pointerEvents: s === "none" ? "none" : "visibleStroke"
295
- }, e));
296
- break;
297
- }
298
- case o.PathLayer.Marker: v && C.push(b("path", {
299
- d: r,
300
- fill: _,
301
- stroke: "none",
302
- pointerEvents: s
303
- }, e));
304
- }
305
- }
306
- let w = [];
307
- for (let e of te) {
308
- let [t, n] = o.FillTransfer[e];
309
- w.push(b("filter", {
310
- id: `${c}-${e}`,
311
- colorInterpolationFilters: "sRGB",
312
- children: x("feComponentTransfer", { children: [
313
- b("feFuncR", {
314
- type: "linear",
315
- slope: t,
316
- intercept: n
317
- }),
318
- b("feFuncG", {
319
- type: "linear",
320
- slope: t,
321
- intercept: n
322
- }),
323
- b("feFuncB", {
324
- type: "linear",
325
- slope: t,
326
- intercept: n
327
- })
328
- ] })
329
- }, e));
330
- }
331
- if (f && !t.image && w.push(j(`${c}-fill`, f, n, r)), p && v && w.push(j(`${c}-stroke`, p, n, r)), t.image && l) {
332
- let e = t.image.fill.stretch ?? {}, i = n * (e.left ?? 0) / 100, a = r * (e.top ?? 0) / 100, o = Math.max(0, n - i - n * (e.right ?? 0) / 100), s = Math.max(0, r - a - r * (e.bottom ?? 0) / 100);
333
- w.push(b("pattern", {
334
- id: `${c}-image`,
335
- patternUnits: "userSpaceOnUse",
336
- x: 0,
337
- y: 0,
338
- width: Math.max(n, 1),
339
- height: Math.max(r, 1),
340
- children: b("image", {
341
- href: l,
342
- x: i,
343
- y: a,
344
- width: o,
345
- height: s,
346
- preserveAspectRatio: "none",
347
- style: me
348
- })
349
- }, "image"));
350
- }
351
- return x(y, { children: [w.length > 0 ? b("defs", { children: w }) : null, C] });
352
- });
353
- M.displayName = "PathRun";
354
- var he = d(({ geometry: e, style: t, zoom: n, grid: r = null, hit: i }) => {
355
- let a = h(() => {
356
- let t = [];
357
- return e.forEachPath((e) => t.push(e)), t;
358
- }, [e]);
359
- return b(M, {
360
- paths: a,
361
- style: t,
362
- width: e.getWidth(),
363
- height: e.getHeight(),
364
- zoom: n,
365
- grid: r,
366
- hit: i
367
- });
368
- });
369
- he.displayName = "ShapePaths";
370
- var ge = d(({ handles: e, width: t, height: n, zoom: r, onDrag: i }) => {
371
- let a = _(null), o = _(null), [s, c] = v(!1), l = f((e) => {
372
- let t = a.current, n = t?.getScreenCTM();
373
- if (!t || !n) return null;
374
- let r = new DOMPoint(e.clientX, e.clientY).matrixTransform(n.inverse());
375
- return {
376
- x: r.x,
377
- y: r.y
378
- };
379
- }, []), u = f((e, t) => {
380
- e.button === 0 && (e.stopPropagation(), e.preventDefault(), o.current = {
381
- index: t,
382
- pointerId: e.pointerId
383
- }, e.currentTarget.setPointerCapture(e.pointerId), c(!0));
384
- }, []), d = f((e) => {
385
- let t = o.current;
386
- if (!t || t.pointerId !== e.pointerId) return;
387
- e.stopPropagation();
388
- let n = l(e);
389
- n && i(t.index, n.x, n.y, "move");
390
- }, [l, i]), p = f((e) => {
391
- let t = o.current;
392
- if (!t || t.pointerId !== e.pointerId) return;
393
- e.stopPropagation(), o.current = null, c(!1);
394
- let n = l(e);
395
- n ? i(t.index, n.x, n.y, "end") : i(t.index, 0, 0, "cancel");
396
- }, [l, i]), m = f((e) => {
397
- let t = o.current;
398
- t && t.pointerId === e.pointerId && (o.current = null, c(!1), i(t.index, 0, 0, "cancel"));
399
- }, [i]);
400
- if (!(e.length !== 0 && t > 0 && n > 0)) return null;
401
- let h = r > 0 ? r : 1, g = 4.5 / h;
402
- return b("svg", {
403
- ref: a,
404
- className: s ? "shape-handles movable-gesture" : "shape-handles",
405
- viewBox: `0 0 ${t} ${n}`,
406
- width: "100%",
407
- height: "100%",
408
- preserveAspectRatio: "none",
409
- overflow: "visible",
410
- style: {
411
- position: "absolute",
412
- left: 0,
413
- top: 0,
414
- display: "block",
415
- pointerEvents: "none",
416
- touchAction: "none"
417
- },
418
- children: e.map((e) => x("g", {
419
- className: "shape-handle",
420
- style: { "--shape-scale": h },
421
- children: [b("circle", {
422
- cx: e.x,
423
- cy: e.y,
424
- r: g,
425
- fill: "#ffc000",
426
- stroke: "#7f6000",
427
- strokeWidth: 1 / h,
428
- style: { pointerEvents: "none" }
429
- }), b("circle", {
430
- className: "shape-handle-hit",
431
- cx: e.x,
432
- cy: e.y,
433
- r: g,
434
- fill: "transparent",
435
- style: {
436
- pointerEvents: "all",
437
- cursor: "crosshair",
438
- touchAction: "none"
439
- },
440
- onPointerDown: (t) => u(t, e.index),
441
- onPointerMove: d,
442
- onPointerUp: p,
443
- onPointerCancel: m,
444
- onMouseDown: (e) => e.stopPropagation()
445
- })]
446
- }, e.index))
447
- });
448
- });
449
- ge.displayName = "ShapeHandles";
450
- var N = (e, t) => e > 0 || t > 0, P = (e, t, n) => !e || e.getWidth() === t && e.getHeight() === n ? e : N(t, n) ? e.resize(t, n) : null, _e = (e) => {
451
- let t = [];
452
- return e.forEachConnection((e) => t.push(e)), t;
453
- }, F = d(u((i, o) => {
454
- let { children: u, disabled: d, style: m, shape: y, movable: S, zoom: T = 1, isDragging: ce, onHide: le, onShow: ue, onDragZone: de, adornmentHost: E, flip: D, gesture: O, debugGeometry: fe = !1, ...pe } = i, k = t()?.getStyles() ?? null, [me, A] = g((e) => e + 1, 0);
455
- e(y, { onAnyChange: A }), e(S ?? null, {
456
- onBoundsChange: A,
457
- onSelectionChange: A
458
- });
459
- let j = y.toJSON(), { width: M, height: F, rotation: ve, content: I } = ((e) => {
460
- let [t] = te("movable-drag", null), n = e ? t?.[e.getId()] : void 0, r = n?.bounds ?? e?.getBounds();
461
- return {
462
- width: r?.width ?? 0,
463
- height: r?.height ?? 0,
464
- rotation: n?.rotation ?? (e?.getRotation() || 0),
465
- content: n?.content ?? null
466
- };
467
- })(S), L = y.getShapeType(), ye = y.getAdjustments(), R = N(M, F), [z, B] = v(null), V = _(0);
468
- p(() => {
469
- if (!R) return void B(null);
470
- let e = ++V.current, t = y.getShapeType();
471
- y.getGeometry(M, F).then((n) => {
472
- V.current === e && B(n ? {
473
- shapeType: t,
474
- geometry: n
475
- } : null);
476
- }, () => {
477
- V.current === e && B(null);
478
- });
479
- }, [
480
- y,
481
- M,
482
- F,
483
- me
484
- ]);
485
- let H = I?.shapeType !== void 0 && I.shapeType !== L ? I.shapeType : null, [U, be] = v(null);
486
- p(() => {
487
- if (!H || !R || U?.shapeType === H) return;
488
- let e = !0;
489
- return y.getGeometry(M, F, { shapeType: H }).then((t) => {
490
- e && t && be({
491
- shapeType: H,
492
- geometry: t
493
- });
494
- }, () => {}), () => {
495
- e = !1;
496
- };
497
- }, [
498
- y,
499
- H,
500
- R
501
- ]);
502
- let W = h(() => {
503
- let e = z?.shapeType === L ? z : U?.shapeType === L ? U : null;
504
- return e ? P(e.geometry, M, F)?.withAdjustments(ye) ?? null : P(z?.geometry ?? null, M, F);
505
- }, [
506
- z,
507
- U,
508
- L,
509
- ye,
510
- M,
511
- F
512
- ]), xe = f((e) => y.getResource(e), [y]);
513
- p(() => {
514
- let e = [];
515
- for (let t = S?.getParent() ?? null; t; t = t.getParent()) e.push(t.getContent().addListeners({ onAnyChange: A }));
516
- return () => {
517
- for (let t of e) t();
518
- };
519
- }, [S]);
520
- let Se = se(S), G = h(() => ((e, t, n, r) => {
521
- let i = null;
522
- try {
523
- i = t?.getTheme()?.toJSON() ?? null;
524
- } catch {
525
- i = null;
526
- }
527
- let o = l.resolve(e, i, r), { stroke: u } = o, d = (e) => ie(e, t), f = c.toConcreteFill(o.fill, d), p = c.toConcreteFill(u?.fill, d), m = ae(p), h = p?.type === a.Type.Gradient ? oe(p) ?? void 0 : void 0, g = ae(f), _ = f?.type === a.Type.Gradient ? oe(f) ?? void 0 : void 0, v;
528
- if (f?.type === a.Type.Image) {
529
- let e = f.resId === void 0 ? null : n?.(f.resId) ?? null;
530
- e && (v = {
531
- resource: e,
532
- fill: f
533
- });
534
- }
535
- return {
536
- fill: g,
537
- gradient: _,
538
- image: v,
539
- stroke: m,
540
- strokeGradient: h,
541
- strokeWidth: m ? Math.max(0, o.strokeWidth) * re : 0,
542
- lineJoin: u?.lineJoin ?? "miter",
543
- lineCap: u?.lineCap ?? "butt",
544
- miterLimit: typeof u?.miterLimit == "number" ? u.miterLimit : 18.5,
545
- dash: s.toDashLengths(u?.dash),
546
- textColor: ie(o.fontColor, t)
547
- };
548
- })(j, k, xe, Se), [
549
- j,
550
- k,
551
- xe,
552
- Se
553
- ]), [Ce, we] = v(null), Te = I?.adjustments === void 0 ? Ce ?? void 0 : I.adjustments, K = h(() => {
554
- if (H && U?.shapeType !== H) return W;
555
- let e = H ? P(U.geometry, M, F) : W;
556
- return e && Te !== void 0 ? e.withAdjustments(Te) : e;
557
- }, [
558
- W,
559
- H,
560
- U,
561
- M,
562
- F,
563
- Te
564
- ]), q = _(null), [Ee, De] = v(!1), Oe = f((e, t, n, r) => {
565
- if (r === "cancel") return q.current && (q.current = null, De(!1), O?.cancel()), void we(null);
566
- if (!K || !W) return;
567
- let i = K.adjustmentsFromHandle(e, t, n);
568
- if (r === "move") {
569
- if (O && !d) {
570
- if (!q.current) {
571
- let e = { adjustments: i };
572
- if (!O.start(ee("op.setShapeAdjustments"), (t) => {
573
- t.getContent().setAdjustments(e.adjustments);
574
- })) return;
575
- q.current = e, De(!0);
576
- }
577
- q.current.adjustments = i, O.preview({ content: { adjustments: i } });
578
- return;
579
- }
580
- we(i);
581
- return;
582
- }
583
- let a = q.current;
584
- if (a) return q.current = null, De(!1), a.adjustments = i, void O?.finish();
585
- we(null), d || y.setAdjustments(i);
586
- }, [
587
- K,
588
- W,
589
- y,
590
- d,
591
- O
592
- ]), ke = h(() => {
593
- let e = [];
594
- return K?.forEachHandle((t) => e.push(t)), e;
595
- }, [K]), Ae = C(o, () => ({ isShapeEditor: () => !0 }), []), je = D ?? S?.getFlip(), J = je?.horizontal ?? !1, Y = je?.vertical ?? !1, Me = ve % 360 != 0, Ne = h(() => !Me && N(M, F) ? {
596
- dpr: ne.getDevicePixelRatio(),
597
- zoom: T,
598
- width: M,
599
- height: F,
600
- flipH: J,
601
- flipV: Y
602
- } : null, [
603
- Me,
604
- T,
605
- M,
606
- F,
607
- J,
608
- Y
609
- ]);
610
- if (y.isDeleted() || !j) return null;
611
- let X = m?.pointerEvents === "none", Pe = X ? "none" : "visiblePainted", Fe = !X && !d && (!ce || Ee) && !!S?.isSelected(), Ie = {
612
- transform: J || Y ? `scale(${J ? -1 : 1}, ${Y ? -1 : 1})` : void 0,
613
- transformOrigin: "center"
614
- }, Z = null;
615
- Fe && ke.length > 0 && (Z = b(ge, {
616
- handles: ke,
617
- width: M,
618
- height: F,
619
- zoom: T,
620
- onDrag: Oe
621
- }), E && (Z = w(b("div", {
622
- className: "shape-adornment",
623
- style: {
624
- position: "absolute",
625
- left: 0,
626
- top: 0,
627
- width: "100%",
628
- height: "100%",
629
- ...Ie,
630
- pointerEvents: "none"
631
- },
632
- children: Z
633
- }), E)));
634
- let Le = J === Y ? void 0 : "scaleX(-1)", Q = K?.getTextRect(), $ = j.text, Re = !!$ && $.paragraphs.some((e) => e.runs.some((e) => e.text !== ""));
635
- return x("div", {
636
- className: "shape-editor",
637
- ...pe,
638
- ref: Ae,
639
- style: {
640
- width: "100%",
641
- height: "100%",
642
- position: "relative",
643
- overflow: "visible",
644
- filter: d ? "blur(1px)" : void 0,
645
- ...Ie,
646
- ...m,
647
- pointerEvents: "none"
648
- },
649
- children: [
650
- N(M, F) ? x("svg", {
651
- className: "shape-geometry",
652
- viewBox: `0 0 ${M > 0 ? M : 1 / T} ${F > 0 ? F : 1 / T}`,
653
- width: M > 0 ? "100%" : "1px",
654
- height: F > 0 ? "100%" : "1px",
655
- preserveAspectRatio: "none",
656
- overflow: "visible",
657
- style: {
658
- position: "absolute",
659
- left: 0,
660
- top: 0,
661
- display: "block",
662
- pointerEvents: "none",
663
- filter: Fe ? "drop-shadow(1px 1px 2px rgba(0,0,0,.15))" : void 0
664
- },
665
- children: [K ? b(he, {
666
- geometry: K,
667
- style: G,
668
- zoom: T,
669
- grid: Ne,
670
- hit: Pe
671
- }) : null, fe && K && Q ? x("g", {
672
- pointerEvents: "none",
673
- children: [b("rect", {
674
- x: Q.l,
675
- y: Q.t,
676
- width: Math.max(0, Q.r - Q.l),
677
- height: Math.max(0, Q.b - Q.t),
678
- fill: "none",
679
- stroke: "#c00",
680
- strokeWidth: 1 / T,
681
- strokeDasharray: `${4 / T} ${2 / T}`
682
- }), _e(K).map((e) => b("rect", {
683
- x: e.x - 3 / T,
684
- y: e.y - 3 / T,
685
- width: 6 / T,
686
- height: 6 / T,
687
- fill: "#0a0"
688
- }, e.index))]
689
- }) : null]
690
- }) : null,
691
- Re && Q ? b("div", {
692
- className: "shape-text-frame",
693
- style: {
694
- position: "absolute",
695
- left: Q.l,
696
- top: Q.t,
697
- width: Math.max(0, Q.r - Q.l),
698
- height: Math.max(0, Q.b - Q.t),
699
- zoom: T,
700
- transform: Le,
701
- transformOrigin: "center",
702
- pointerEvents: X ? "none" : "auto",
703
- color: G.textColor ?? void 0
704
- },
705
- children: b(n, {
706
- movable: S,
707
- disabled: !0,
708
- style: {
709
- fontFamily: "Calibri, Carlito, sans-serif",
710
- fontSize: "11pt",
711
- lineHeight: 1.2,
712
- padding: 0
713
- },
714
- contentStyle: {
715
- padding: 0,
716
- overflow: "hidden"
717
- },
718
- children: b(r, {
719
- text: $,
720
- styles: k,
721
- color: G.textColor
722
- })
723
- })
724
- }) : null,
725
- Z
726
- ]
727
- });
728
- }));
729
- F.displayName = "ShapeEditor";
730
- export { F as t };