@sheetxl/react 0.8.0-beta.11 → 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 (141) hide show
  1. package/browser/esm/{B93LSmhnvkxNXTq-.mjs → -wQNyCnoJdQUTTfP.mjs} +1 -1
  2. package/browser/esm/{Bl2BFCQ00fotauKB.mjs → AL94cpxFjPurAMQG.mjs} +1 -1
  3. package/browser/esm/{BQYS2Yf-EAV_tBLr.mjs → B4K8rf7TAv0SBkbG.mjs} +1 -1
  4. package/browser/esm/{ClAtIfYbsUPA073B.mjs → BrwfFgqKdMG_-iar.mjs} +1 -1
  5. package/browser/esm/ByBGwdqhc_l75i5G.mjs +145 -0
  6. package/browser/esm/{DgL7Dy-Lqcr1TvW6.mjs → C1zqAqKQ6oa4FiTH.mjs} +4851 -4818
  7. package/browser/esm/C9lQPmVMIlUwXkKr.mjs +303 -0
  8. package/browser/esm/{Dnh1kpz3v1JKtRD_.mjs → CIrcPI7uOT93ydNn.mjs} +2 -2
  9. package/browser/esm/{DS66lAIM-9M-YoZQ.mjs → CZsNidKZjsn0lNnA.mjs} +112 -104
  10. package/browser/esm/{Bos4Rkp8UTF7QXUB.mjs → CcewpxckpDrXSiZ-.mjs} +1 -1
  11. package/browser/esm/{BegvsXeRs7e-9t8k.mjs → CdDvFP8Fqm8uU7Rw.mjs} +1 -1
  12. package/browser/esm/{D2u6THGErqw64KQI.mjs → CfewUx0gINn-wXt3.mjs} +1 -1
  13. package/browser/esm/{C1pc9F4Rt2C5FKUo.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/{1-LEUre9ZLG0OYYB.mjs → Dd8deQ2CDMdrhzF1.mjs} +6 -6
  17. package/browser/esm/Dit7p67J_fDF5RDj.mjs +262 -0
  18. package/browser/esm/{CPnnESfZz2jjJd82.mjs → DzWFl-_dCN-EOkio.mjs} +3 -3
  19. package/browser/esm/{94dxo1A-z8lgiiGw.mjs → MIDbAwdzknMaoTU5.mjs} +2 -2
  20. package/browser/esm/{B26QVfjer2oY2ewK.mjs → ao9zR4H88b7AmZEV.mjs} +1 -1
  21. package/browser/esm/chart.mjs +28 -27
  22. package/browser/esm/control.mjs +74 -73
  23. package/browser/esm/group.mjs +3 -3
  24. package/browser/esm/index.mjs +6195 -5307
  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/{CzRIbc-Lk__VMLKM.mjs → u3A8I4A7GKIOLOOb.mjs} +3 -3
  31. package/browser/esm/{DMdsMPT0fWBbTkNn.mjs → x6A47UA3fzV361tO.mjs} +1 -1
  32. package/node/esm/{BiaDWnN3tT7neoRL.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/{DxQZmb-j4NLUO9Af.mjs → BTT6UB5lGvPxcq3F.mjs} +1 -1
  36. package/node/esm/{JiQGhLkoL8CJpVvA.mjs → BYiAmyF-aOOuMkD1.mjs} +1 -1
  37. package/node/esm/BqS8o-CmPoCjHDHp.mjs +263 -0
  38. package/node/esm/{b-XRVRI1fYQQMkTC.mjs → CC_XgLOFPvqmFyZ_.mjs} +525 -492
  39. package/node/esm/{BaRfst1euuhquupX.mjs → CMGUrHMaBDeCezK5.mjs} +1 -1
  40. package/node/esm/{umljAT66yb3_rURh.mjs → CP07qkepi21zlB0n.mjs} +118 -110
  41. package/node/esm/{BlxXufqBBg1PtsXd.mjs → CQJJMfuXl6mbgHdT.mjs} +1 -1
  42. package/node/esm/{C_SNx7TlFEcwbYjx.mjs → CVDVFhM7OIpaOlyN.mjs} +1 -1
  43. package/node/esm/{gpD-9LDW92phhoma.mjs → CVMuO9bpR5YK0pPb.mjs} +1 -1
  44. package/node/esm/{BMVK5plvmBOAIlxP.mjs → CaZG4HD3SmHvD-Tu.mjs} +1 -1
  45. package/node/esm/{6zApGj9DozhFy-bx.mjs → CuRPfxQCj2jookWL.mjs} +1 -1
  46. package/node/esm/D8mYmUPUA6i8oFgR.mjs +19 -0
  47. package/node/esm/{Dj5FM7_-YWhCtCCt.mjs → DAUtyjkW5uSdnTli.mjs} +1 -1
  48. package/node/esm/{D_pCpfdQowV_4Aje.mjs → DfvJ0Dpn-AP2mGtz.mjs} +5 -5
  49. package/node/esm/{DTMTIrYIK1eZswsM.mjs → DipZYwHed-W6QMtQ.mjs} +1 -1
  50. package/node/esm/{Be9c1GwQkPo8Piuh.mjs → NvP_j9pSsDiJ_PyY.mjs} +3 -3
  51. package/node/esm/chart.mjs +26 -25
  52. package/node/esm/control.mjs +79 -78
  53. package/node/esm/{sigD1UFqvPlWUw_9.mjs → eecr5gnC2KqVhOzX.mjs} +2 -2
  54. package/node/esm/group.mjs +3 -3
  55. package/node/esm/index.mjs +6594 -5705
  56. package/node/esm/note.mjs +18 -18
  57. package/node/esm/picture.mjs +269 -50
  58. package/node/esm/shape.mjs +185 -578
  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 +45 -2
  63. package/resources/locales/de/ui.msg.json +3 -0
  64. package/resources/locales/de/workbook.cmd.json +6 -0
  65. package/resources/locales/en/picture.cmd.json +157 -0
  66. package/resources/locales/en/sheet.cmd.json +45 -2
  67. package/resources/locales/en/ui.msg.json +5 -0
  68. package/resources/locales/en/workbook.cmd.json +6 -0
  69. package/types/src/border/useBorders.d.ts +2 -2
  70. package/types/src/cell/CellCheckboxRenderer.d.ts +20 -0
  71. package/types/src/cell/CellContent.d.ts +68 -0
  72. package/types/src/cell/CellControlContext.d.ts +37 -0
  73. package/types/src/cell/{FormulaCellRenderer.d.ts → CellFormulaRenderer.d.ts} +5 -5
  74. package/types/src/cell/CellImageRenderer.d.ts +11 -0
  75. package/types/src/cell/CellRenderers.d.ts +190 -0
  76. package/types/src/cell/{SheetCellRenderer.d.ts → CellTextRenderer.d.ts} +9 -6
  77. package/types/src/cell/ColumnButton.d.ts +3 -3
  78. package/types/src/cell/OutlineButton.d.ts +4 -4
  79. package/types/src/cell/SheetHeaderRenderer.d.ts +1 -1
  80. package/types/src/cell/index.d.ts +8 -2
  81. package/types/src/cell/useFormulaViewAnchor.d.ts +1 -1
  82. package/types/src/cell/useInsertableCellControls.d.ts +25 -0
  83. package/types/src/chart/ChartCommands.d.ts +1 -1
  84. package/types/src/chart/ChartEditor.d.ts +2 -0
  85. package/types/src/chart/ChartElement.d.ts +14 -3
  86. package/types/src/chart/paint/_graphics.d.ts +0 -8
  87. package/types/src/chart/paint/_mode.d.ts +6 -0
  88. package/types/src/chart/paint/echarts.d.ts +6 -3
  89. package/types/src/chart/paint/index.d.ts +1 -1
  90. package/types/src/chart/paint/kinds/ChartPaintKind.d.ts +9 -1
  91. package/types/src/chart/paint/kinds/_builtIns.d.ts +0 -9
  92. package/types/src/chart/paint/toEChartsOption.d.ts +12 -1
  93. package/types/src/editableLabel/EditableLabel.d.ts +3 -1
  94. package/types/src/editor/SheetReferenceHeaderLayer.d.ts +1 -1
  95. package/types/src/editor/useFormulaHints.d.ts +1 -1
  96. package/types/src/layer/CellErrorLayer.d.ts +3 -2
  97. package/types/src/layer/CellIndicatorLayer.d.ts +31 -0
  98. package/types/src/layer/CircularIndicatorLayer.d.ts +1 -1
  99. package/types/src/layer/HeaderSelectionLayer.d.ts +4 -4
  100. package/types/src/layer/HyperlinkLayer.d.ts +12 -5
  101. package/types/src/layer/ProtectionLayer.d.ts +1 -2
  102. package/types/src/layer/SheetCellLayer.d.ts +11 -4
  103. package/types/src/layer/SheetMovableLayer.d.ts +2 -1
  104. package/types/src/layer/SheetOutlineLayer.d.ts +1 -1
  105. package/types/src/layer/TableLayer.d.ts +1 -1
  106. package/types/src/layer/TableToolbar.d.ts +1 -1
  107. package/types/src/layer/ValidationPromptLayer.d.ts +16 -4
  108. package/types/src/layer/_visibleCellFeatures.d.ts +11 -0
  109. package/types/src/layer/index.d.ts +1 -0
  110. package/types/src/layer/useValidationPicker.d.ts +1 -1
  111. package/types/src/listener/useRangeListener.d.ts +13 -7
  112. package/types/src/movable/DefaultMovable.d.ts +1 -1
  113. package/types/src/movable/MovableControl.d.ts +3 -1
  114. package/types/src/movable/MovableFrame.d.ts +2 -1
  115. package/types/src/movable/MovableLayer.d.ts +6 -3
  116. package/types/src/movable/useFramePreview.d.ts +17 -0
  117. package/types/src/picture/PictureCommands.d.ts +8 -0
  118. package/types/src/picture/_pictureHyperlink.d.ts +13 -0
  119. package/types/src/picture/pictureCrop.d.ts +32 -0
  120. package/types/src/sheet/ISheetHeaderElement.d.ts +2 -2
  121. package/types/src/sheet/IWorksheetElement.d.ts +21 -22
  122. package/types/src/sheet/SheetCommandProvider.d.ts +3 -0
  123. package/types/src/sheet/SheetOutlineElement.d.ts +2 -2
  124. package/types/src/sheet/SheetPanels.d.ts +2 -2
  125. package/types/src/sheet/_hyperlinkEdit.d.ts +7 -0
  126. package/types/src/sheet/circularReferences.d.ts +1 -1
  127. package/types/src/tabStrip/Sortable.d.ts +5 -5
  128. package/types/src/tabStrip/TabStrip.d.ts +6 -6
  129. package/types/src/tabStrip/TabStripItem.d.ts +15 -13
  130. package/types/src/taskPane/CellControlPane.d.ts +17 -0
  131. package/types/src/taskPane/index.d.ts +1 -0
  132. package/types/src/taskPane/useTaskPane.d.ts +6 -3
  133. package/types/src/theme/buildDocThemeCSS.d.ts +4 -1
  134. package/types/src/workbook/DefaultRenderers.d.ts +4 -4
  135. package/types/src/workbook/IWorkbookElement.d.ts +52 -20
  136. package/types/src/workbook/WorkbookStrip.d.ts +5 -5
  137. package/browser/esm/CRi6DQ3UXmPEv-w_.mjs +0 -729
  138. package/browser/esm/cQ6xdPFkEcuDlNTN.mjs +0 -75
  139. package/browser/esm/ugfE7YeZALQURDKF.mjs +0 -241
  140. package/node/esm/DJPgbB1X22YmhbaR.mjs +0 -242
  141. package/node/esm/DgGEHydEjD7nfsDB.mjs +0 -76
@@ -1,75 +0,0 @@
1
- /**
2
- * @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.11
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 { PictureEditor as e } from "./picture.mjs";
8
- import { jsx as t } from "react/jsx-runtime";
9
- import { DOMUtils as n, messageKey as r, t as i } from "@sheetxl/utils";
10
- import { NotifierType as a } from "@sheetxl/utils-react";
11
- var o = {
12
- renderer: (n) => {
13
- let r = n.movable.getContent();
14
- return t(e, {
15
- loadingPanel: t("div", { style: {
16
- position: "absolute",
17
- width: "100%",
18
- height: "100%"
19
- } }),
20
- picture: r,
21
- description: r.getDescription() ?? r.getName?.() ?? void 0,
22
- ...n
23
- });
24
- },
25
- commands: (e, t) => {
26
- let { sheet: o, movable: s, notifier: c } = t, l = s.getContent(), u = async (e) => {
27
- let t = await (async (e) => {
28
- let t = await Promise.resolve(c?.showBusy?.(i(r("op.setPictureResource"))) ?? null);
29
- try {
30
- let t = o.getResources().add(e);
31
- return await t.toBuffer(), t;
32
- } catch (e) {
33
- let t = e;
34
- if (typeof t != "string") {
35
- console.warn(e);
36
- let n = typeof e?.cause == "string" ? e.cause : "", r = typeof e?.message == "string" ? e.message : "";
37
- n && (r = r ? `${r} (${n})` : n), t = i("error.insertImage.unresolved", { detail: r });
38
- }
39
- return c?.showMessage?.(t, { type: a.Error }), null;
40
- } finally {
41
- t?.();
42
- }
43
- })(e);
44
- t && l.setResource(t);
45
- };
46
- e.updateCommand("changePictureFromFile", {
47
- tags: ["noTransaction", "noRepeat"],
48
- callback: async (e) => {
49
- let t = null, r = null;
50
- typeof e == "string" ? r = e : t = e ?? null, (t || (t = await n.openFileDialog(r ?? "image/*"), t)) && await u({ source: { file: await Promise.resolve(t) } });
51
- }
52
- }), e.updateCommand("changePictureFromURL", {
53
- tags: ["noTransaction", "noRepeat"],
54
- callback: async (e) => {
55
- if (!e) {
56
- let t = await c?.showInput?.({
57
- title: i("dialog.changePicture.title"),
58
- description: i("dialog.changePicture.description"),
59
- inputLabel: i("dialog.insertImage.inputLabel"),
60
- initialValue: "https://picsum.photos/360",
61
- propsInput: { style: { minWidth: "440px" } },
62
- options: [{
63
- id: "Change",
64
- label: () => i("dialog.change")
65
- }]
66
- });
67
- if (!t || t.option !== "Change") return;
68
- e = t.input;
69
- }
70
- e && await u({ source: { fetch: e } });
71
- }
72
- });
73
- }
74
- };
75
- export { o as PictureKind };
@@ -1,241 +0,0 @@
1
- /**
2
- * @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.11
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 "./Bos4Rkp8UTF7QXUB.mjs";
8
- import { forwardRef as t, memo as n, useCallback as r, useEffect as i, useLayoutEffect as a, useRef as o, useState as s } from "react";
9
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
10
- import { CommonUtils as u, defineLazyModule as d } from "@sheetxl/utils";
11
- import { useImperativeElement as ee, useMeasure as f } from "@sheetxl/utils-react";
12
- var p = d("chart:paint", () => import("./DgL7Dy-Lqcr1TvW6.mjs")), m = (e, t) => {
13
- let n = e.getElementType();
14
- if (n === "point") {
15
- let n = e.getParent();
16
- return t === n || t?.getElementType() === "point" && t.getParent() === n ? e : n;
17
- }
18
- if (n === "legendEntry") {
19
- let n = e.getParent();
20
- return t === n || t?.getElementType() === "legendEntry" ? e : n;
21
- }
22
- if (n === "dataLabel") {
23
- let n = e.getParent()?.getParent(), r = n?.getDataLabels();
24
- return r ? t === r || t?.getElementType() === "dataLabel" && t.getParent()?.getParent() === n ? e : r : e;
25
- }
26
- return e;
27
- }, h = {
28
- boxes: [],
29
- handles: []
30
- }, g = n(t((t, n) => {
31
- let { children: d, style: g, chart: _, onChartChange: v, zoom: y = 1, width: b, height: x, selection: S = null, onElementPress: C, onPointerDown: w, ...te } = t, [T, E] = s(() => u.isPromiseLike(_) ? null : _), [D, ne] = s(null), O = o(v);
32
- O.current = v;
33
- let k = o(null);
34
- i(() => {
35
- let e = !0, t = (e, t) => {
36
- ne(t), E(e), k.current !== e && (k.current = e, O.current?.(e));
37
- };
38
- if (u.isPromiseLike(_)) return _.then((n) => {
39
- e && t(n, null);
40
- }, (n) => {
41
- e && t(null, n);
42
- }), () => {
43
- e = !1;
44
- };
45
- t(_, null);
46
- }, [_]);
47
- let [A, j] = f(), M = typeof b == "number" ? b : j.width, N = typeof x == "number" ? x : j.height, P = M ? Math.round(M / y) : 0, F = N ? Math.round(N / y) : 0, I = o({
48
- width: P,
49
- height: F
50
- });
51
- I.current = {
52
- width: P,
53
- height: F
54
- };
55
- let L = r(async () => {
56
- let e = I.current;
57
- if (!T || !e.width || !e.height) return null;
58
- let t = T.getLayout(e);
59
- return t ? (await p.load()).renderChartToSVG(t) : null;
60
- }, [T]), R = o(null), z = o(null), B = o(y);
61
- B.current = y;
62
- let V = r((e, t) => {
63
- let n = R.current;
64
- if (!n) return null;
65
- let r = n.getBoundingClientRect(), i = B.current || 1;
66
- return {
67
- x: (e - r.left) / i,
68
- y: (t - r.top) / i
69
- };
70
- }, []), H = r((e, t) => {
71
- let n = z.current, r = V(e, t);
72
- return T && n && r ? T.getElementAt(r, n) : null;
73
- }, [T, V]), U = ee(n, () => ({
74
- isChartElement: () => !0,
75
- getChart: () => T,
76
- toSVG: L,
77
- getElementAt: H
78
- }), [
79
- T,
80
- L,
81
- H
82
- ]), W = e([
83
- U,
84
- A,
85
- R
86
- ]), G = o(null), K = o(null), [q, J] = s(() => p.peek() ?? null), [Y, X] = s(null), [re, ie] = s(0), [Z, ae] = s(h);
87
- i(() => T?.addListeners({ onLayoutChange: () => ie((e) => e + 1) }), [T]), i(() => {
88
- if (q) return;
89
- let e = !0;
90
- return p.load().then((t) => {
91
- e && J(t);
92
- }, (t) => {
93
- e && X(t);
94
- }), () => {
95
- e = !1;
96
- };
97
- }, [q]);
98
- let Q = r(() => {
99
- let e = z.current;
100
- ae(T && e && S && !S.isEmpty() ? ((e, t, n) => {
101
- let r = [], i = [];
102
- for (let a of n.getItems()) {
103
- if (a.getChart() !== e) continue;
104
- let o = a.getElementType();
105
- if (o === "series" || o === "dataLabels") {
106
- let n = o === "series" ? a : a.getParent(), i = o === "series" ? n.getPoints() : n.getPoints().map((e) => e.getDataLabel());
107
- for (let n of i) {
108
- let i = e.getElementBounds(n, t);
109
- i && r.push(i);
110
- }
111
- if (r.length > 0) continue;
112
- }
113
- let s = e.getElementBounds(a, t);
114
- if (s && (r.push(s), n.getItems().length === 1)) {
115
- let e = [
116
- s.x,
117
- s.x + s.width / 2,
118
- s.x + s.width
119
- ], t = [
120
- s.y,
121
- s.y + s.height / 2,
122
- s.y + s.height
123
- ];
124
- for (let n of e) for (let r of t) n === e[1] && r === t[1] || i.push({
125
- x: n,
126
- y: r
127
- });
128
- }
129
- }
130
- return {
131
- boxes: r,
132
- handles: i
133
- };
134
- })(T, e, S) : h);
135
- }, [T, S]);
136
- i(() => S?.addListeners({ onChange: Q }), [S, Q]), a(() => {
137
- let e = G.current;
138
- if (!(q && e && T && P && F)) return;
139
- let t = T.getLayout({
140
- width: P,
141
- height: F
142
- });
143
- if (z.current = t, !t) return K.current?.dispose(), K.current = null, void Q();
144
- K.current ? K.current.update(t) : K.current = q.mountChart(e, t), Q();
145
- }, [
146
- q,
147
- T,
148
- P,
149
- F,
150
- re,
151
- Q
152
- ]), i(() => () => {
153
- K.current?.dispose(), K.current = null, z.current = null;
154
- }, [T]);
155
- let oe = r((e) => {
156
- if (w?.(e), e.button !== 0 && e.button !== 2) return;
157
- let t = z.current, n = V(e.clientX, e.clientY);
158
- if (!T || !t || !n) return;
159
- let r = T.getElementAt(n, t);
160
- if (C?.({
161
- element: r,
162
- point: n,
163
- event: e
164
- }), !S) return;
165
- if (!r || r.getElementType() === "chartArea") return void S.clear();
166
- let i = m(r, S.getActive());
167
- S.isSelected(i) && S.getItems().length === 1 || S.select([i]);
168
- }, [
169
- T,
170
- S,
171
- C,
172
- w,
173
- V
174
- ]);
175
- if (T?.isDeleted()) return;
176
- let $ = Y ?? D;
177
- return l("div", {
178
- ...te,
179
- onPointerDown: oe,
180
- style: {
181
- ...b === void 0 ? {} : { width: b },
182
- ...x === void 0 ? {} : { height: x },
183
- ...g,
184
- overflow: "hidden"
185
- },
186
- ref: W,
187
- children: [
188
- $ ? c("div", {
189
- className: "chart-element-error",
190
- style: {
191
- padding: "8px",
192
- fontSize: "12px",
193
- color: "var(--sxl-color-error, #b00020)"
194
- },
195
- children: $.message
196
- }) : null,
197
- c("div", {
198
- className: "chart-element",
199
- ref: G,
200
- style: {
201
- width: P || "100%",
202
- height: F || "100%",
203
- zoom: y,
204
- position: "relative"
205
- }
206
- }),
207
- Z.boxes.length > 0 ? l("div", {
208
- className: "chart-element-selection",
209
- style: {
210
- position: "absolute",
211
- left: 0,
212
- top: 0,
213
- width: P,
214
- height: F,
215
- zoom: y,
216
- pointerEvents: "none"
217
- },
218
- children: [Z.boxes.map((e, t) => c("div", { style: {
219
- position: "absolute",
220
- left: e.x - 1,
221
- top: e.y - 1,
222
- width: Math.max(0, e.width),
223
- height: Math.max(0, e.height),
224
- border: "1px solid var(--sxl-color-primary, #1a73e8)",
225
- boxSizing: "content-box"
226
- } }, `box-${t}`)), Z.handles.map((e, t) => c("div", { style: {
227
- position: "absolute",
228
- left: e.x - 3,
229
- top: e.y - 3,
230
- width: 6,
231
- height: 6,
232
- background: "var(--sxl-color-background, #fff)",
233
- border: "1px solid var(--sxl-color-primary, #1a73e8)",
234
- boxSizing: "border-box"
235
- } }, `handle-${t}`))]
236
- }) : null
237
- ]
238
- });
239
- }));
240
- g.displayName = "ChartElement";
241
- export { m as n, g as t };
@@ -1,242 +0,0 @@
1
- /**
2
- * @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.11
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 { forwardRef as t, memo as e, useCallback as n, useEffect as r, useLayoutEffect as o, useRef as l, useState as i } from "react";
8
- import { jsx as s, jsxs as a } from "react/jsx-runtime";
9
- import { CommonUtils as c, defineLazyModule as u } from "@sheetxl/utils";
10
- import { useImperativeElement as h, useMeasure as d } from "@sheetxl/utils-react";
11
- import { useMergeRefs as g } from "react-merge-refs";
12
- var m = u("chart:paint", () => import("./b-XRVRI1fYQQMkTC.mjs")), p = (t, e) => {
13
- const n = t.getElementType();
14
- if ("point" === n) {
15
- const n = t.getParent();
16
- return e === n || "point" === e?.getElementType() && e.getParent() === n ? t : n;
17
- }
18
- if ("legendEntry" === n) {
19
- const n = t.getParent();
20
- return e === n || "legendEntry" === e?.getElementType() ? t : n;
21
- }
22
- if ("dataLabel" === n) {
23
- const n = t.getParent()?.getParent(), r = n?.getDataLabels();
24
- return r ? e === r || "dataLabel" === e?.getElementType() && e.getParent()?.getParent() === n ? t : r : t;
25
- }
26
- return t;
27
- }, f = {
28
- boxes: [],
29
- handles: []
30
- }, y = e(t((t, e) => {
31
- const { children: u, style: y, chart: x, onChartChange: b, zoom: v = 1, width: w, height: E, selection: P = null, onElementPress: L, onPointerDown: C, ...T } = t, [z, S] = i(() => c.isPromiseLike(x) ? null : x), [k, A] = i(null), D = l(b);
32
- D.current = b;
33
- const M = l(null);
34
- r(() => {
35
- let t = !0;
36
- const e = (t, e) => {
37
- A(e), S(t), M.current !== t && (M.current = t, D.current?.(t));
38
- };
39
- if (c.isPromiseLike(x)) return x.then((n) => {
40
- t && e(n, null);
41
- }, (n) => {
42
- t && e(null, n);
43
- }), () => {
44
- t = !1;
45
- };
46
- e(x, null);
47
- }, [x]);
48
- const [N, B] = d(), I = "number" == typeof w ? w : B.width, j = "number" == typeof E ? E : B.height, G = I ? Math.round(I / v) : 0, V = j ? Math.round(j / v) : 0, $ = l({
49
- width: G,
50
- height: V
51
- });
52
- $.current = {
53
- width: G,
54
- height: V
55
- };
56
- const R = n(async () => {
57
- const t = $.current;
58
- if (!z || !t.width || !t.height) return null;
59
- const e = z.getLayout(t);
60
- return e ? (await m.load()).renderChartToSVG(e) : null;
61
- }, [z]), X = l(null), Y = l(null), q = l(v);
62
- q.current = v;
63
- const F = n((t, e) => {
64
- const n = X.current;
65
- if (!n) return null;
66
- const r = n.getBoundingClientRect(), o = q.current || 1;
67
- return {
68
- x: (t - r.left) / o,
69
- y: (e - r.top) / o
70
- };
71
- }, []), H = n((t, e) => {
72
- const n = Y.current, r = F(t, e);
73
- return z && n && r ? z.getElementAt(r, n) : null;
74
- }, [z, F]), J = h(e, () => ({
75
- isChartElement: () => !0,
76
- getChart: () => z,
77
- toSVG: R,
78
- getElementAt: H
79
- }), [
80
- z,
81
- R,
82
- H
83
- ]), K = g([
84
- J,
85
- N,
86
- X
87
- ]), O = l(null), Q = l(null), [U, W] = i(() => m.peek() ?? null), [Z, _] = i(null), [tt, et] = i(0), [nt, rt] = i(f);
88
- r(() => z?.addListeners({ onLayoutChange: () => et((t) => t + 1) }), [z]), r(() => {
89
- if (U) return;
90
- let t = !0;
91
- return m.load().then((e) => {
92
- t && W(e);
93
- }, (e) => {
94
- t && _(e);
95
- }), () => {
96
- t = !1;
97
- };
98
- }, [U]);
99
- const ot = n(() => {
100
- const t = Y.current;
101
- rt(z && t && P && !P.isEmpty() ? ((t, e, n) => {
102
- const r = [], o = [];
103
- for (const l of n.getItems()) {
104
- if (l.getChart() !== t) continue;
105
- const i = l.getElementType();
106
- if ("series" === i || "dataLabels" === i) {
107
- const n = "series" === i ? l : l.getParent(), o = "series" === i ? n.getPoints() : n.getPoints().map((t) => t.getDataLabel());
108
- for (const n of o) {
109
- const o = t.getElementBounds(n, e);
110
- o && r.push(o);
111
- }
112
- if (r.length > 0) continue;
113
- }
114
- const s = t.getElementBounds(l, e);
115
- if (s && (r.push(s), 1 === n.getItems().length)) {
116
- const t = [
117
- s.x,
118
- s.x + s.width / 2,
119
- s.x + s.width
120
- ], e = [
121
- s.y,
122
- s.y + s.height / 2,
123
- s.y + s.height
124
- ];
125
- for (const n of t) for (const r of e) n === t[1] && r === e[1] || o.push({
126
- x: n,
127
- y: r
128
- });
129
- }
130
- }
131
- return {
132
- boxes: r,
133
- handles: o
134
- };
135
- })(z, t, P) : f);
136
- }, [z, P]);
137
- r(() => P?.addListeners({ onChange: ot }), [P, ot]), o(() => {
138
- const t = O.current;
139
- if (!(U && t && z && G && V)) return;
140
- const e = z.getLayout({
141
- width: G,
142
- height: V
143
- });
144
- if (Y.current = e, !e) return Q.current?.dispose(), Q.current = null, void ot();
145
- Q.current ? Q.current.update(e) : Q.current = U.mountChart(t, e), ot();
146
- }, [
147
- U,
148
- z,
149
- G,
150
- V,
151
- tt,
152
- ot
153
- ]), r(() => () => {
154
- Q.current?.dispose(), Q.current = null, Y.current = null;
155
- }, [z]);
156
- const lt = n((t) => {
157
- if (C?.(t), 0 !== t.button && 2 !== t.button) return;
158
- const e = Y.current, n = F(t.clientX, t.clientY);
159
- if (!z || !e || !n) return;
160
- const r = z.getElementAt(n, e);
161
- if (L?.({
162
- element: r,
163
- point: n,
164
- event: t
165
- }), !P) return;
166
- if (!r || "chartArea" === r.getElementType()) return void P.clear();
167
- const o = p(r, P.getActive());
168
- P.isSelected(o) && 1 === P.getItems().length || P.select([o]);
169
- }, [
170
- z,
171
- P,
172
- L,
173
- C,
174
- F
175
- ]);
176
- if (z?.isDeleted()) return;
177
- const it = Z ?? k;
178
- return a("div", {
179
- ...T,
180
- onPointerDown: lt,
181
- style: {
182
- ...void 0 !== w ? { width: w } : {},
183
- ...void 0 !== E ? { height: E } : {},
184
- ...y,
185
- overflow: "hidden"
186
- },
187
- ref: K,
188
- children: [
189
- it ? s("div", {
190
- className: "chart-element-error",
191
- style: {
192
- padding: "8px",
193
- fontSize: "12px",
194
- color: "var(--sxl-color-error, #b00020)"
195
- },
196
- children: it.message
197
- }) : null,
198
- s("div", {
199
- className: "chart-element",
200
- ref: O,
201
- style: {
202
- width: G || "100%",
203
- height: V || "100%",
204
- zoom: v,
205
- position: "relative"
206
- }
207
- }),
208
- nt.boxes.length > 0 ? a("div", {
209
- className: "chart-element-selection",
210
- style: {
211
- position: "absolute",
212
- left: 0,
213
- top: 0,
214
- width: G,
215
- height: V,
216
- zoom: v,
217
- pointerEvents: "none"
218
- },
219
- children: [nt.boxes.map((t, e) => s("div", { style: {
220
- position: "absolute",
221
- left: t.x - 1,
222
- top: t.y - 1,
223
- width: Math.max(0, t.width),
224
- height: Math.max(0, t.height),
225
- border: "1px solid var(--sxl-color-primary, #1a73e8)",
226
- boxSizing: "content-box"
227
- } }, `box-${e}`)), nt.handles.map((t, e) => s("div", { style: {
228
- position: "absolute",
229
- left: t.x - 3,
230
- top: t.y - 3,
231
- width: 6,
232
- height: 6,
233
- background: "var(--sxl-color-background, #fff)",
234
- border: "1px solid var(--sxl-color-primary, #1a73e8)",
235
- boxSizing: "border-box"
236
- } }, `handle-${e}`))]
237
- }) : null
238
- ]
239
- });
240
- }));
241
- y.displayName = "ChartElement";
242
- export { p as n, y as t };
@@ -1,76 +0,0 @@
1
- /**
2
- * @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.11
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 { PictureEditor as e } from "./picture.mjs";
8
- import { jsx as t } from "react/jsx-runtime";
9
- import { DOMUtils as i, messageKey as o, t as a } from "@sheetxl/utils";
10
- import { NotifierType as n } from "@sheetxl/utils-react";
11
- var s = {
12
- renderer: (i) => {
13
- const o = i.movable.getContent();
14
- return t(e, {
15
- loadingPanel: t("div", { style: {
16
- position: "absolute",
17
- width: "100%",
18
- height: "100%"
19
- } }),
20
- picture: o,
21
- description: o.getDescription() ?? o.getName?.() ?? void 0,
22
- ...i
23
- });
24
- },
25
- commands: (e, t) => {
26
- const { sheet: s, movable: r, notifier: l } = t, c = r.getContent(), u = async (e) => {
27
- const t = await (async (e) => {
28
- const t = await Promise.resolve(l?.showBusy?.(a(o("op.setPictureResource"))) ?? null);
29
- try {
30
- const t = s.getResources().add(e);
31
- return await t.toBuffer(), t;
32
- } catch (e) {
33
- let t = e;
34
- if ("string" != typeof t) {
35
- console.warn(e);
36
- const i = "string" == typeof e?.cause ? e.cause : "";
37
- let o = "string" == typeof e?.message ? e.message : "";
38
- i && (o = o ? `${o} (${i})` : i), t = a("error.insertImage.unresolved", { detail: o });
39
- }
40
- return l?.showMessage?.(t, { type: n.Error }), null;
41
- } finally {
42
- t?.();
43
- }
44
- })(e);
45
- t && c.setResource(t);
46
- };
47
- e.updateCommand("changePictureFromFile", {
48
- tags: ["noTransaction", "noRepeat"],
49
- callback: async (e) => {
50
- let t = null, o = null;
51
- "string" == typeof e ? o = e : t = e ?? null, (t || (t = await i.openFileDialog(o ?? "image/*"), t)) && await u({ source: { file: await Promise.resolve(t) } });
52
- }
53
- }), e.updateCommand("changePictureFromURL", {
54
- tags: ["noTransaction", "noRepeat"],
55
- callback: async (e) => {
56
- if (!e) {
57
- const t = await l?.showInput?.({
58
- title: a("dialog.changePicture.title"),
59
- description: a("dialog.changePicture.description"),
60
- inputLabel: a("dialog.insertImage.inputLabel"),
61
- initialValue: "https://picsum.photos/360",
62
- propsInput: { style: { minWidth: "440px" } },
63
- options: [{
64
- id: "Change",
65
- label: () => a("dialog.change")
66
- }]
67
- });
68
- if (!t || "Change" !== t.option) return;
69
- e = t.input;
70
- }
71
- e && await u({ source: { fetch: e } });
72
- }
73
- });
74
- }
75
- };
76
- export { s as PictureKind };