@sheetxl/react 0.8.0-beta.21 → 0.8.0-beta.23

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 (79) hide show
  1. package/browser/esm/{Dl0ye0MfTml4mjhA.mjs → 2-8Z3hKcjFc9IUm_.mjs} +3 -3
  2. package/browser/esm/{fHDciYUZvXpLzoID.mjs → B1qMCa-WDnmPYR_C.mjs} +2 -2
  3. package/browser/esm/{zTaXN_1rvsoWg94m.mjs → B1rKvYmr4ynvDkqM.mjs} +3 -3
  4. package/browser/esm/B7RYx03rC74aIduo.mjs +264 -0
  5. package/browser/esm/{C2HjD-DbaqXq93R7.mjs → BG96UT5-ooOuigD0.mjs} +1 -1
  6. package/browser/esm/{BQur1iFrng9Y4kh4.mjs → BHukFXtx1rpfvfIy.mjs} +1 -1
  7. package/browser/esm/{BjnWnPjhT1QFkbUC.mjs → BN7pckCvCRZMPCmK.mjs} +7 -7
  8. package/browser/esm/{BzCq_Z7J2qQlY4Dp.mjs → BklsD3lkZGRSwAFi.mjs} +1 -1
  9. package/browser/esm/{CdE8JeJkTtdh5qqp.mjs → C-eTPeTwXQoqn3Lb.mjs} +2 -2
  10. package/browser/esm/{CA6w64diOtRCgr4n.mjs → C9wgyCKVT4rwQMSD.mjs} +1 -1
  11. package/browser/esm/{DG1f60gvSkz8Y3qb.mjs → CD5gjg2DVLsy6h33.mjs} +6 -6
  12. package/browser/esm/{DL2WZkJdK1lZfpJo.mjs → CEtZlL4v4JU0TDVR.mjs} +122 -122
  13. package/browser/esm/{6lfBozPNyWlFBEDn.mjs → CGEyv-QdxMuQmLqk.mjs} +1 -1
  14. package/browser/esm/{CkYId3pjG9v3XZM2.mjs → CLD7Vob5oUran-l0.mjs} +1 -1
  15. package/browser/esm/{B7TCFLHs7nnOgLMi.mjs → CXJmpmqTkVe25Ita.mjs} +2 -2
  16. package/browser/esm/{mOYnwl3MMod-yX7a.mjs → CmYMKPG-TaW2dJPu.mjs} +1 -1
  17. package/browser/esm/{_T8e_9xhVAagwkPD.mjs → CruGvs0fdtWWO_Di.mjs} +1 -1
  18. package/browser/esm/{Co65nK3fyBcyVzrS.mjs → Cw3PQMs1RDxzIo35.mjs} +2 -2
  19. package/browser/esm/{C46qV9hBGqlz6_Kt.mjs → D5r5ejlRpFFXN6TK.mjs} +4 -4
  20. package/browser/esm/{C9dHNoiKtX9PLY1g.mjs → D952mmmww4cYPatc.mjs} +1 -1
  21. package/browser/esm/{BwMC6jAg2neI4LTH.mjs → DQ5DeFNj_0mj6QMd.mjs} +1 -1
  22. package/browser/esm/{CPwcEeQtvkrESNEy.mjs → DSvlk_YzOev20rgN.mjs} +173 -160
  23. package/browser/esm/{k1IvXgw5-153QQUo.mjs → DedLmnV_HajYHYSM.mjs} +2 -2
  24. package/browser/esm/{CCL3pFmdsuwahoCR.mjs → G6Ek0k1QC1pUHvPd.mjs} +1 -1
  25. package/browser/esm/{CHgyrBEiFmspcFXV.mjs → OPWkc7t367MwVsVU.mjs} +1 -1
  26. package/browser/esm/chart.mjs +11 -11
  27. package/browser/esm/control.mjs +16 -16
  28. package/browser/esm/group.mjs +29 -29
  29. package/browser/esm/index.mjs +6524 -6512
  30. package/browser/esm/note.mjs +10 -10
  31. package/browser/esm/picture.mjs +2 -2
  32. package/browser/esm/shape.mjs +2 -2
  33. package/browser/esm/slicer.mjs +55 -50
  34. package/node/esm/{fM9xnrz0LJWdndYE.mjs → B5ae_WW6vAz2jOsn.mjs} +1 -1
  35. package/node/esm/{JrDkDzP0l4TgHusH.mjs → BD04OJgRWKiE2W1H.mjs} +1 -1
  36. package/node/esm/{uzlKB6H0b-ol8pDK.mjs → BGLOvRRJr4nt8QdO.mjs} +2 -2
  37. package/node/esm/{B2a1mRx9B8XMRd8H.mjs → BKrvkWuGTMdkvdy6.mjs} +1 -1
  38. package/node/esm/{CdKkuM4Yy04LbhRL.mjs → BMWwIbesFn8e6-Ov.mjs} +1 -1
  39. package/node/esm/{BBBfGP0lLhBFoR9F.mjs → BhgjRcXOyNKBdqUW.mjs} +5 -5
  40. package/node/esm/{DtrPF3bSD4CZC5VG.mjs → Bv0fGxNecKUr_qYS.mjs} +1 -1
  41. package/node/esm/{Mq8a4csdTfwY5CnZ.mjs → CF5ztfx05vyEMEub.mjs} +1 -1
  42. package/node/esm/{CGEbcsNJ40cYQEWX.mjs → CeSZX96RPPjn29Hw.mjs} +2 -2
  43. package/node/esm/{Bzuh8HcJcFD2dYTY.mjs → CeuVkQpY8O4nZG-k.mjs} +2 -2
  44. package/node/esm/{BQpm93aEyzN5TiU6.mjs → Csl959_HnUC4Y06N.mjs} +1 -1
  45. package/node/esm/{B4qJFO-8Vml8JbaC.mjs → Cx16BErZDzlQEXH_.mjs} +2 -2
  46. package/node/esm/{Df-nWyFJwXaVd79x.mjs → D8mwVRSclIFn5SVM.mjs} +80 -78
  47. package/node/esm/{COg8aOu0d67g_Pg5.mjs → DJyNfqgeIlJ6lOHS.mjs} +1 -1
  48. package/node/esm/{cgqViNUwnlIX8-UW.mjs → DL2RKBB2PXzdJyx_.mjs} +4 -4
  49. package/node/esm/{CNYzecnb2TInTI8p.mjs → DmHHRlyfyFWj6wvW.mjs} +1 -1
  50. package/node/esm/{8PerdW56-NyRf0pg.mjs → VFXZqkIvB9MDE2Ea.mjs} +1 -1
  51. package/node/esm/{tRhXTPxocmY7ZY3z.mjs → YC2O0ix33xKY0ShQ.mjs} +12 -12
  52. package/node/esm/chart.mjs +19 -19
  53. package/node/esm/control.mjs +16 -16
  54. package/node/esm/group.mjs +27 -27
  55. package/node/esm/{EXPN4LM0alUK5Zw7.mjs → iMUcM8KW4HIW2Ksm.mjs} +1 -1
  56. package/node/esm/index.mjs +5598 -5585
  57. package/node/esm/{BadjRr_jKKGvmEW-.mjs → k3c-0DQ1fifSFOnO.mjs} +1 -1
  58. package/node/esm/note.mjs +10 -10
  59. package/node/esm/picture.mjs +175 -162
  60. package/node/esm/shape.mjs +164 -164
  61. package/node/esm/slicer.mjs +100 -95
  62. package/node/esm/{CD1OBtF4vEthYy6e.mjs → vYeFE_eUMRqsgnkd.mjs} +1 -1
  63. package/package.json +7 -7
  64. package/types/src/cell/CornerTriangle.d.ts +2 -1
  65. package/types/src/editor/SheetCellEditorLayer.d.ts +0 -5
  66. package/types/src/editor/formulaPresentation.d.ts +4 -3
  67. package/types/src/movable/IMovableArea.d.ts +11 -0
  68. package/types/src/movable/MovableLayer.d.ts +1 -1
  69. package/types/src/sheet/IWorksheetElement.d.ts +13 -4
  70. package/types/src/theme/ExplicitTokens.d.ts +18 -0
  71. package/types/src/theme/GridColorSchemeContext.d.ts +8 -0
  72. package/types/src/theme/ThemeRootStyles.d.ts +31 -0
  73. package/types/src/theme/buildTokensCSS.d.ts +15 -0
  74. package/types/src/theme/index.d.ts +2 -4
  75. package/types/src/theme/useAppColorScheme.d.ts +4 -1
  76. package/types/src/theme/useGridColorScheme.d.ts +7 -2
  77. package/types/src/theme/useSystemColors.d.ts +0 -14
  78. package/types/src/workbook/IWorkbookElement.d.ts +36 -8
  79. package/browser/esm/BzFKdDmdCdg3cXdh.mjs +0 -262
@@ -4,6 +4,7 @@ import { IWorkbook, IWorkbookIO, IMovable, ITable, IPivotTable } from '@sheetxl/
4
4
  import { LoadingPanelProps, ErrorPanelProps, RenderFloatPanel, FloatPanelProps, FloatReference, RenderSlotFn, ThemeMode, Command } from '@sheetxl/utils-react';
5
5
  import { WorksheetElementProps, IWorksheetElement, OpaqueSheetElementProps } from '../sheet';
6
6
  import { SheetEditable } from '../editor';
7
+ import { ExplicitTokens } from '../theme';
7
8
  import { CommandContext } from '../frame';
8
9
  import { WorkbookStripProps } from './WorkbookStrip';
9
10
  /**
@@ -97,17 +98,44 @@ export interface WorkbookElementProps extends Omit<React.HTMLAttributes<HTMLDivE
97
98
  */
98
99
  workbook?: IWorkbook | Promise<IWorkbook> | IWorkbookIO.ReadOptions;
99
100
  /**
100
- * Controlled override for the app (chrome) light/dark scheme. When omitted, the workbook self-sources
101
- * it from the shared appearance preference (`ThemeStateKey.Mode`). With no preference set it is light,
102
- * unless the page puts a `dark`/`light` class on `<html>`/`<body>` or a `ThemeModeFallbackContext`
103
- * above says otherwise (`'system'` follows the OS, as Studio does).
101
+ * Controlled override for the app (chrome) light/dark scheme. `'auto'` follows the page: a
102
+ * `dark`/`light` class on `<html>`/`<body>`, else the OS.
103
+ *
104
+ * When omitted, the workbook self-sources it from the shared appearance preference
105
+ * (`ThemeStateKey.Mode`). With no preference set it is light, unless the page puts a `dark`/`light` class
106
+ * on `<html>`/`<body>` or a `ThemeModeFallbackContext` above says otherwise.
104
107
  */
105
- colorScheme?: ThemeMode;
108
+ colorScheme?: ThemeMode | 'auto';
106
109
  /**
107
- * Controlled override for the grid-body scheme (stays light in a dark app when *Enable Dark Grid* is
108
- * off). When omitted, derived from {@link colorScheme} + the `ThemeStateKey.DarkGrid` preference.
110
+ * Controlled override for the grid-body scheme. `'auto'` follows the page as {@link colorScheme} does.
111
+ *
112
+ * When omitted, the grid follows {@link colorScheme} only if *Enable Dark Grid*
113
+ * (`ThemeStateKey.DarkGrid`) is on, so by default it stays light in a dark app. Pass it to make the grid
114
+ * dark with the page.
115
+ */
116
+ gridColorScheme?: ThemeMode | 'auto';
117
+ /**
118
+ * Token values for this workbook, per mode and surface: the React form of a stylesheet in
119
+ * `@layer sxl-overrides`, scoped to this instance.
120
+ *
121
+ * ```tsx
122
+ * <WorkbookElement
123
+ * colorScheme="auto"
124
+ * gridColorScheme="auto"
125
+ * tokens={{
126
+ * dark: {
127
+ * app: { 'color-base-100': '#14102c', 'color-base-200': '#14102c', 'color-primary': '#6e9bff' },
128
+ * header: { 'color-base-100': '#1a1538', 'color-base-300': '#312b55' }
129
+ * }
130
+ * }}
131
+ * />
132
+ * ```
133
+ *
134
+ * @remarks
135
+ * An `app` value reaches the grid and headers too in that mode; state a `grid` or `header` cell to make
136
+ * that surface differ. Pass a stable object: a new reference rebuilds the stylesheet.
109
137
  */
110
- gridColorScheme?: ThemeMode;
138
+ tokens?: ExplicitTokens;
111
139
  /**
112
140
  * Callback for when the workbook is loaded (first render). Useful for hiding/showing
113
141
  * loading panels.
@@ -1,262 +0,0 @@
1
- /**
2
- * @license @sheetxl/react - React - React components needed to build advanced grid and spreadsheet UIs. - v0.8.0-beta.21
3
- *
4
- * (C) 2026-present SheetXL Inc. & Michael T. Ford
5
- * License: SheetXL EULA — https://www.sheetxl.com/eula
6
- */
7
- import { t as e } from "./_T8e_9xhVAagwkPD.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 ee } from "@sheetxl/utils";
11
- import { useImperativeElement as te, useMeasure as ne, usePendingRender as re, usePersistentState as d, useResolvedThemeMode as f } from "@sheetxl/utils-react";
12
- var p = {
13
- Mode: "themeMode",
14
- DarkGrid: "enableDarkGrid",
15
- DarkImages: "enableDarkImages"
16
- }, m = {
17
- [p.Mode]: null,
18
- [p.DarkGrid]: !1,
19
- [p.DarkImages]: !1
20
- }, h = (e) => {
21
- let [t] = d(p.Mode, m[p.Mode]), [n] = d(p.DarkGrid, m[p.DarkGrid]), { themeMode: r } = f({ mode: e ?? t ?? void 0 });
22
- return e || (r === "dark" && n ? "dark" : "light");
23
- }, g = () => {
24
- let [e] = d(p.Mode, m[p.Mode]), { themeMode: t } = f({ mode: e ?? void 0 });
25
- return t;
26
- }, _ = ee("chart:paint", () => import("./Dl0ye0MfTml4mjhA.mjs")), v = (e, t) => {
27
- let n = e.getElementType();
28
- if (n === "point") {
29
- let n = e.getParent();
30
- return t === n || t?.getElementType() === "point" && t.getParent() === n ? e : n;
31
- }
32
- if (n === "legendEntry") {
33
- let n = e.getParent();
34
- return t === n || t?.getElementType() === "legendEntry" ? e : n;
35
- }
36
- if (n === "dataLabel") {
37
- let n = e.getParent()?.getParent(), r = n?.getDataLabels();
38
- return r ? t === r || t?.getElementType() === "dataLabel" && t.getParent()?.getParent() === n ? e : r : e;
39
- }
40
- return e;
41
- }, y = {
42
- boxes: [],
43
- handles: []
44
- }, b = n(t((t, n) => {
45
- let { children: ee, style: d, chart: f, onChartChange: p, zoom: m = 1, width: h, height: b, selection: x = null, colorScheme: ie, onElementPress: S, onPointerDown: C, ...w } = t, [T, ae] = s(() => u.isPromiseLike(f) ? null : f), [E, oe] = s(null), D = o(p);
46
- D.current = p;
47
- let O = o(null);
48
- i(() => {
49
- let e = !0, t = (e, t) => {
50
- oe(t), ae(e), O.current !== e && (O.current = e, D.current?.(e));
51
- };
52
- if (u.isPromiseLike(f)) return f.then((n) => {
53
- e && t(n, null);
54
- }, (n) => {
55
- e && t(null, n);
56
- }), () => {
57
- e = !1;
58
- };
59
- t(f, null);
60
- }, [f]);
61
- let [k, A] = ne(), j = typeof h == "number" ? h : A.width, M = typeof b == "number" ? b : A.height, N = j ? Math.round(j / m) : 0, P = M ? Math.round(M / m) : 0, F = o({
62
- width: N,
63
- height: P
64
- });
65
- F.current = {
66
- width: N,
67
- height: P
68
- };
69
- let I = g(), L = (ie ?? I) === "dark", R = r(async (e) => {
70
- let t = F.current;
71
- if (!T || !t.width || !t.height) return null;
72
- let n = T.getLayout(t);
73
- return n ? (await _.load()).renderChartToSVG(n, { darkMode: e?.darkMode ?? !1 }) : null;
74
- }, [T]), z = o(null), B = o(null), V = o(m);
75
- V.current = m;
76
- let H = r((e, t) => {
77
- let n = z.current;
78
- if (!n) return null;
79
- let r = n.getBoundingClientRect(), i = V.current || 1;
80
- return {
81
- x: (e - r.left) / i,
82
- y: (t - r.top) / i
83
- };
84
- }, []), U = r((e, t) => {
85
- let n = B.current, r = H(e, t);
86
- return T && n && r ? T.getElementAt(r, n) : null;
87
- }, [T, H]), W = te(n, () => ({
88
- isChartElement: () => !0,
89
- getChart: () => T,
90
- toSVG: R,
91
- getElementAt: U
92
- }), [
93
- T,
94
- R,
95
- U
96
- ]), G = e([
97
- W,
98
- k,
99
- z
100
- ]), K = o(null), q = o(null), [J, Y] = s(() => _.peek() ?? null), [X, se] = s(null), [ce, le] = s(0), [Z, ue] = s(y);
101
- i(() => T?.addListeners({ onLayoutChange: () => le((e) => e + 1) }), [T]), re(!(X || E || J && T)), i(() => {
102
- if (J) return;
103
- let e = !0;
104
- return _.load().then((t) => {
105
- e && Y(t);
106
- }, (t) => {
107
- e && se(t);
108
- }), () => {
109
- e = !1;
110
- };
111
- }, [J]);
112
- let Q = r(() => {
113
- let e = B.current;
114
- ue(T && e && x && !x.isEmpty() ? ((e, t, n) => {
115
- let r = [], i = [];
116
- for (let a of n.getItems()) {
117
- if (a.getChart() !== e) continue;
118
- let o = a.getElementType();
119
- if (o === "series" || o === "dataLabels") {
120
- let n = o === "series" ? a : a.getParent(), i = o === "series" ? n.getPoints() : n.getPoints().map((e) => e.getDataLabel());
121
- for (let n of i) {
122
- let i = e.getElementBounds(n, t);
123
- i && r.push(i);
124
- }
125
- if (r.length > 0) continue;
126
- }
127
- let s = e.getElementBounds(a, t);
128
- if (s && (r.push(s), n.getItems().length === 1)) {
129
- let e = [
130
- s.x,
131
- s.x + s.width / 2,
132
- s.x + s.width
133
- ], t = [
134
- s.y,
135
- s.y + s.height / 2,
136
- s.y + s.height
137
- ];
138
- for (let n of e) for (let r of t) n === e[1] && r === t[1] || i.push({
139
- x: n,
140
- y: r
141
- });
142
- }
143
- }
144
- return {
145
- boxes: r,
146
- handles: i
147
- };
148
- })(T, e, x) : y);
149
- }, [T, x]);
150
- i(() => x?.addListeners({ onChange: Q }), [x, Q]), a(() => {
151
- let e = K.current;
152
- if (!(J && e && T && N && P)) return;
153
- let t = T.getLayout({
154
- width: N,
155
- height: P
156
- });
157
- if (B.current = t, !t) return q.current?.dispose(), q.current = null, e.style.backgroundColor = "", void Q();
158
- let n = t.chartArea.fill === void 0;
159
- e.style.backgroundColor = n ? `var(--sxl-color-base-100, ${L ? "#121212" : "#FFFFFF"})` : "", e.style.borderRadius = n ? `${t.chartArea.cornerRadius}px` : "";
160
- let r = {
161
- darkMode: L,
162
- background: "transparent"
163
- };
164
- q.current ? q.current.update(t, r) : q.current = J.mountChart(e, t, r), Q();
165
- }, [
166
- J,
167
- T,
168
- N,
169
- P,
170
- ce,
171
- L,
172
- Q
173
- ]), i(() => () => {
174
- q.current?.dispose(), q.current = null, B.current = null;
175
- }, [T]);
176
- let de = r((e) => {
177
- if (C?.(e), e.button !== 0 && e.button !== 2) return;
178
- let t = B.current, n = H(e.clientX, e.clientY);
179
- if (!T || !t || !n) return;
180
- let r = T.getElementAt(n, t);
181
- if (S?.({
182
- element: r,
183
- point: n,
184
- event: e
185
- }), !x) return;
186
- if (!r || r.getElementType() === "chartArea") return void x.clear();
187
- let i = v(r, x.getActive());
188
- x.isSelected(i) && x.getItems().length === 1 || x.select([i]);
189
- }, [
190
- T,
191
- x,
192
- S,
193
- C,
194
- H
195
- ]);
196
- if (T?.isDeleted()) return;
197
- let $ = X ?? E;
198
- return l("div", {
199
- ...w,
200
- onPointerDown: de,
201
- style: {
202
- ...h === void 0 ? {} : { width: h },
203
- ...b === void 0 ? {} : { height: b },
204
- ...d,
205
- overflow: "hidden"
206
- },
207
- ref: G,
208
- children: [
209
- $ ? c("div", {
210
- className: "sxl-chart-element-error",
211
- style: {
212
- padding: "8px",
213
- fontSize: "12px",
214
- color: "var(--sxl-color-error, #b00020)"
215
- },
216
- children: $.message
217
- }) : null,
218
- c("div", {
219
- className: "sxl-chart-element",
220
- ref: K,
221
- style: {
222
- width: N || "100%",
223
- height: P || "100%",
224
- zoom: m,
225
- position: "relative"
226
- }
227
- }),
228
- Z.boxes.length > 0 ? l("div", {
229
- className: "sxl-chart-element-selection",
230
- style: {
231
- position: "absolute",
232
- left: 0,
233
- top: 0,
234
- width: N,
235
- height: P,
236
- zoom: m,
237
- pointerEvents: "none"
238
- },
239
- children: [Z.boxes.map((e, t) => c("div", { style: {
240
- position: "absolute",
241
- left: e.x - 1,
242
- top: e.y - 1,
243
- width: Math.max(0, e.width),
244
- height: Math.max(0, e.height),
245
- border: "1px solid var(--sxl-color-primary, #1a73e8)",
246
- boxSizing: "content-box"
247
- } }, `box-${t}`)), Z.handles.map((e, t) => c("div", { style: {
248
- position: "absolute",
249
- left: e.x - 3,
250
- top: e.y - 3,
251
- width: 6,
252
- height: 6,
253
- background: "var(--sxl-color-base-100, #fff)",
254
- border: "1px solid var(--sxl-color-primary, #1a73e8)",
255
- boxSizing: "border-box"
256
- } }, `handle-${t}`))]
257
- }) : null
258
- ]
259
- });
260
- }));
261
- b.displayName = "ChartElement";
262
- export { m as a, h as i, v as n, p as o, g as r, b as t };