@sheetxl/scripting-mui 0.7.28-beta.4 → 0.8.0-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/esm/index.mjs +182 -174
- package/node/esm/index.mjs +227 -221
- package/package.json +12 -13
- package/resources/locales/de/ui.msg.json +2 -0
- package/resources/locales/en/ui.msg.json +2 -0
- package/types/src/template/TemplateSelectPanel.d.ts +5 -0
- package/types/src/utils/Utils.d.ts +1 -1
- package/browser/cjs/index.cjs +0 -1
package/node/esm/index.mjs
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.
|
|
2
|
+
* @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.10
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
5
|
* License: The license can be found at https://www.sheetxl.com/license.
|
|
6
6
|
*/
|
|
7
7
|
import e, { createElement as t, forwardRef as r, memo as n, useCallback as i, useEffect as o, useMemo as a, useReducer as l, useRef as s, useState as c } from "react";
|
|
8
8
|
import d from "clsx";
|
|
9
|
-
import { Box as p, Button as m, CircularProgress as u, Paper as h, Typography as f, useTheme as
|
|
10
|
-
import { Command as
|
|
11
|
-
import { AnimatedLoadingPanel as
|
|
12
|
-
import { DefaultTaskPaneRegistry as A, InputClipboardInjector as O, useWorkbook as M } from "@sheetxl/react";
|
|
9
|
+
import { Box as p, Button as m, CircularProgress as u, Paper as h, Typography as f, useTheme as x } from "@mui/material";
|
|
10
|
+
import { Command as g, CommandButtonType as y, DefaultCommandButtonRegistry as S, DefaultIconService as b, DynamicIcon as v, KeyCodes as w, ReactUtils as k, useCallbackRef as C, useCommandButtonEntry as F, useCommands as N, useImperativeElement as T, useTranslator as K } from "@sheetxl/utils-react";
|
|
11
|
+
import { AnimatedLoadingPanel as D, CommandButton as I, CommandPopupButton as L, CommandToolbar as P, ExhibitDivider as $, ExhibitMenuItem as E, OverflowPalette as R, defaultCreatePopupPanel as z } from "@sheetxl/utils-mui";
|
|
12
|
+
import { DefaultTaskPaneRegistry as A, InputClipboardInjector as B, useModelSync as O, useWorkbook as M } from "@sheetxl/react";
|
|
13
13
|
import { Fragment as W, jsx as j, jsxs as H } from "react/jsx-runtime";
|
|
14
14
|
import { alpha as U } from "@mui/system";
|
|
15
|
-
import {
|
|
15
|
+
import { VERSION as q } from "@sheetxl/sdk";
|
|
16
|
+
import { ChainedError as Z } from "@sheetxl/utils";
|
|
16
17
|
import { ScriptEditor as G, ScriptingReactPlugin as J } from "@sheetxl/scripting-react";
|
|
17
|
-
var
|
|
18
|
+
var _ = {
|
|
18
19
|
"insertFunction.fallbackLabel": "Function",
|
|
19
20
|
"insertFunction.insertNamed": "Insert {name}",
|
|
21
|
+
"insertScript.fallbackLabel": "Insert Script",
|
|
22
|
+
"insertScript.loading": "Loading...",
|
|
20
23
|
"runScript.executeNamed": "Execute {name}",
|
|
21
24
|
"runScript.fallbackLabel": "Macro",
|
|
22
25
|
"templateSelect.blankSummary": "Start with an empty script.",
|
|
@@ -27,12 +30,12 @@ var Z = {
|
|
|
27
30
|
"templateSelect.loadFailed": "Failed to load scripts",
|
|
28
31
|
"templateSelect.title": "Script Template",
|
|
29
32
|
"templateSelect.untitled": "Untitled"
|
|
30
|
-
}, { DefaultCommandCatalogService:
|
|
31
|
-
function
|
|
32
|
-
|
|
33
|
+
}, { DefaultCommandCatalogService: Q } = g, V = !1;
|
|
34
|
+
function X() {
|
|
35
|
+
V || (V = !0, Q.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: _ }));
|
|
33
36
|
}
|
|
34
|
-
|
|
35
|
-
var
|
|
37
|
+
X();
|
|
38
|
+
var Y = n(r((e, r) => {
|
|
36
39
|
const { groupKey: n, ...i } = e, a = M(), l = K(), [s, d] = c([]), [m, u] = c(!1);
|
|
37
40
|
o(() => {
|
|
38
41
|
const e = a?.getScripts();
|
|
@@ -47,19 +50,19 @@ var X = n(r((e, r) => {
|
|
|
47
50
|
variant: y.Menuitem,
|
|
48
51
|
groupKey: "scriptsOptions",
|
|
49
52
|
shortcut: void 0
|
|
50
|
-
}, f = [],
|
|
51
|
-
for (let e = 0; e <
|
|
53
|
+
}, f = [], x = s ? s.length : 0;
|
|
54
|
+
for (let e = 0; e < x; e++) {
|
|
52
55
|
const t = s[e];
|
|
53
|
-
f.push(j(
|
|
56
|
+
f.push(j(I, {
|
|
54
57
|
...h,
|
|
55
58
|
commandKey: "executeScript",
|
|
56
59
|
commandState: { declaration: t },
|
|
57
60
|
propsTooltip: { description: l("runScript.executeNamed", { name: t.getName() ?? l("runScript.fallbackLabel") }) },
|
|
58
|
-
icon: j(
|
|
61
|
+
icon: j(v, { iconKey: "ScriptMacro" }),
|
|
59
62
|
label: t.getName() ?? l("runScript.fallbackLabel")
|
|
60
63
|
}, `macro-${t.getName()}-${e}`));
|
|
61
64
|
}
|
|
62
|
-
const
|
|
65
|
+
const g = H(p, {
|
|
63
66
|
ref: r,
|
|
64
67
|
sx: {
|
|
65
68
|
display: "flex",
|
|
@@ -73,7 +76,7 @@ var X = n(r((e, r) => {
|
|
|
73
76
|
flex: "1 1 100%"
|
|
74
77
|
},
|
|
75
78
|
children: f
|
|
76
|
-
}), j(
|
|
79
|
+
}), j($, { orientation: "horizontal" })] }) : null, t(I, {
|
|
77
80
|
...h,
|
|
78
81
|
key: "show-editor",
|
|
79
82
|
commandKey: "showScriptEditor"
|
|
@@ -81,48 +84,48 @@ var X = n(r((e, r) => {
|
|
|
81
84
|
});
|
|
82
85
|
return z({
|
|
83
86
|
...i,
|
|
84
|
-
children:
|
|
87
|
+
children: g
|
|
85
88
|
});
|
|
86
89
|
}));
|
|
87
|
-
|
|
88
|
-
var
|
|
89
|
-
const { groupKey: r, disabled: n, ...o } = e, a = N(["showScriptEditor"])[0], l = F("scriptsOptions")
|
|
90
|
-
|
|
90
|
+
Y.displayName = "RunScriptPopupPanel";
|
|
91
|
+
var ee = n(r((e, t) => {
|
|
92
|
+
const { groupKey: r, disabled: n, ...o } = e, a = N(["showScriptEditor"])[0], l = F("scriptsOptions"), s = i((e) => {
|
|
93
|
+
const t = j(Y, {
|
|
94
|
+
disabled: n,
|
|
95
|
+
groupKey: r,
|
|
96
|
+
...e
|
|
97
|
+
});
|
|
98
|
+
return z({
|
|
99
|
+
...e,
|
|
100
|
+
children: t
|
|
101
|
+
});
|
|
102
|
+
}, [n, r]);
|
|
103
|
+
return j(L, {
|
|
91
104
|
ref: t,
|
|
92
105
|
disabled: n,
|
|
93
|
-
createPopupPanel:
|
|
94
|
-
const t = j(X, {
|
|
95
|
-
disabled: n,
|
|
96
|
-
groupKey: r,
|
|
97
|
-
...e
|
|
98
|
-
});
|
|
99
|
-
return z({
|
|
100
|
-
...e,
|
|
101
|
-
children: t
|
|
102
|
-
});
|
|
103
|
-
}, [n, r]),
|
|
106
|
+
createPopupPanel: s,
|
|
104
107
|
selected: a?.getState(),
|
|
105
108
|
label: l?.getLabel?.(),
|
|
106
109
|
tooltip: l?.getDescription?.(),
|
|
107
110
|
quickCommand: "showScriptEditor",
|
|
108
111
|
...o
|
|
109
112
|
});
|
|
110
|
-
})),
|
|
113
|
+
})), te = /^\d+\.\d+\.\d+-([0-9A-Za-z-]+)/.exec(q)?.[1], re = `https://unpkg.com/@sheetxl/templates-scripting${te ? `@${te}` : ""}/dist`, ne = (e, t) => {
|
|
111
114
|
try {
|
|
112
115
|
return new URL(t).href;
|
|
113
116
|
} catch {}
|
|
114
117
|
if (t.startsWith("/") || /^[a-zA-Z]:/.test(t)) return t;
|
|
115
118
|
let r = e.startsWith("http") ? e : `file:///${e.replace(/\\/g, "/")}`;
|
|
116
119
|
return r.endsWith("/") || (r += "/"), new URL(t, r).href;
|
|
117
|
-
},
|
|
120
|
+
}, ie = (e) => {
|
|
118
121
|
if (e.metadata?.name) return e.metadata.name;
|
|
119
122
|
let t = (e.path.split("/").pop() || "").replace(/\.[^/.]+$/, "");
|
|
120
123
|
return "formula" === e.metadata?.icon ? t.toUpperCase() : (t = t.replace(/([a-z])([A-Z])/g, "$1 $2"), t.replace(/[-_]/g, " ").trim().split(/\s+/).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "));
|
|
121
|
-
},
|
|
122
|
-
const t =
|
|
123
|
-
if (!r.ok) throw new
|
|
124
|
+
}, oe = async (e) => {
|
|
125
|
+
const t = ne(e, "./manifest.json"), r = await fetch(t);
|
|
126
|
+
if (!r.ok) throw new Z(`Failed to retrieve directory at '${e}': ${r.statusText}`);
|
|
124
127
|
const n = await r.text();
|
|
125
|
-
if (n.trim().toLowerCase().startsWith("<!doctype html") || n.trim().toLowerCase().startsWith("<html")) throw new
|
|
128
|
+
if (n.trim().toLowerCase().startsWith("<!doctype html") || n.trim().toLowerCase().startsWith("<html")) throw new Z(`Failed to retrieve directory at '${e}'`);
|
|
126
129
|
let i;
|
|
127
130
|
try {
|
|
128
131
|
i = JSON.parse(n);
|
|
@@ -131,12 +134,12 @@ var Y = n(r((e, t) => {
|
|
|
131
134
|
}
|
|
132
135
|
const o = i.map(async (t) => {
|
|
133
136
|
try {
|
|
134
|
-
const r =
|
|
137
|
+
const r = ne(e, t.path), n = await fetch(r);
|
|
135
138
|
if (!n.ok) throw new Error(`Failed to fetch file at '${t.path}': ${n.statusText}`);
|
|
136
139
|
const i = await n.text();
|
|
137
140
|
let o = t.metadata;
|
|
138
141
|
return o?.title || (o = {
|
|
139
|
-
title:
|
|
142
|
+
title: ie(t),
|
|
140
143
|
...o
|
|
141
144
|
}), {
|
|
142
145
|
path: t.path,
|
|
@@ -149,23 +152,23 @@ var Y = n(r((e, t) => {
|
|
|
149
152
|
return null;
|
|
150
153
|
});
|
|
151
154
|
return (await Promise.all(o)).filter((e) => null !== e);
|
|
152
|
-
},
|
|
155
|
+
}, ae = { marginRight: "4px" }, le = "1em", se = n((e) => {
|
|
153
156
|
const { disabled: t, snippet: r, description: n, handleInsert: i, sx: o, ...a } = e;
|
|
154
157
|
let l;
|
|
155
158
|
const s = r.metadata?.icon;
|
|
156
|
-
return l = j(
|
|
159
|
+
return l = j(v, "formula" === s ? {
|
|
157
160
|
iconKey: "ScriptFormula",
|
|
158
|
-
size:
|
|
159
|
-
style:
|
|
161
|
+
size: le,
|
|
162
|
+
style: ae
|
|
160
163
|
} : "macro" === s ? {
|
|
161
164
|
iconKey: "ScriptMacro",
|
|
162
|
-
size:
|
|
163
|
-
style:
|
|
165
|
+
size: le,
|
|
166
|
+
style: ae
|
|
164
167
|
} : {
|
|
165
168
|
iconKey: "ScriptAutoRun",
|
|
166
|
-
size:
|
|
167
|
-
style:
|
|
168
|
-
}), j(
|
|
169
|
+
size: le,
|
|
170
|
+
style: ae
|
|
171
|
+
}), j(E, {
|
|
169
172
|
sx: {
|
|
170
173
|
maxWidth: "460px",
|
|
171
174
|
display: "flex",
|
|
@@ -206,30 +209,30 @@ var Y = n(r((e, t) => {
|
|
|
206
209
|
})]
|
|
207
210
|
})
|
|
208
211
|
});
|
|
209
|
-
}),
|
|
210
|
-
const { groupKey: n, disabled: a, scriptPath: l =
|
|
212
|
+
}), ce = n(r((e, r) => {
|
|
213
|
+
const { groupKey: n, disabled: a, scriptPath: l = re, ...s } = e, d = K(), [m, u] = c([]), [h, f] = c(!0), [x] = N(["insertScript"]), g = a || (x?.disabled() ?? !1);
|
|
211
214
|
o(() => {
|
|
212
215
|
(async () => {
|
|
213
216
|
try {
|
|
214
|
-
const e = await
|
|
215
|
-
|
|
217
|
+
const e = await oe(l);
|
|
218
|
+
u(e);
|
|
216
219
|
} catch (e) {} finally {
|
|
217
|
-
|
|
220
|
+
f(!1);
|
|
218
221
|
}
|
|
219
222
|
})();
|
|
220
223
|
}, [l]);
|
|
221
|
-
const
|
|
222
|
-
if (
|
|
224
|
+
const S = i((e) => {
|
|
225
|
+
if (h) return j("div", { children: d("insertScript.loading") });
|
|
223
226
|
const r = {
|
|
224
227
|
variant: y.Menuitem,
|
|
225
228
|
groupKey: "scriptsOptions",
|
|
226
|
-
disabled:
|
|
229
|
+
disabled: g
|
|
227
230
|
}, n = (t) => {
|
|
228
|
-
|
|
231
|
+
x?.execute(t.content), e.closeFloat?.();
|
|
229
232
|
}, i = [];
|
|
230
|
-
for (let e = 0; e <
|
|
231
|
-
const t =
|
|
232
|
-
t && i.push(j(
|
|
233
|
+
for (let e = 0; e < m.length; e++) {
|
|
234
|
+
const t = m[e];
|
|
235
|
+
t && i.push(j(se, {
|
|
233
236
|
handleInsert: n,
|
|
234
237
|
snippet: t
|
|
235
238
|
}, t.path));
|
|
@@ -248,13 +251,13 @@ var Y = n(r((e, t) => {
|
|
|
248
251
|
flex: "1 1 100%"
|
|
249
252
|
},
|
|
250
253
|
children: i
|
|
251
|
-
}), j(
|
|
252
|
-
t(
|
|
254
|
+
}), j($, { orientation: "horizontal" })] }) : null,
|
|
255
|
+
t(I, {
|
|
253
256
|
...r,
|
|
254
257
|
key: "showKeyboardShortcuts",
|
|
255
258
|
commandKey: "showKeyboardShortcuts"
|
|
256
259
|
}),
|
|
257
|
-
t(
|
|
260
|
+
t(I, {
|
|
258
261
|
...r,
|
|
259
262
|
key: "scriptingHelp",
|
|
260
263
|
commandKey: "scriptingHelp"
|
|
@@ -266,80 +269,81 @@ var Y = n(r((e, t) => {
|
|
|
266
269
|
children: o
|
|
267
270
|
});
|
|
268
271
|
}, [
|
|
269
|
-
|
|
272
|
+
g,
|
|
270
273
|
n,
|
|
271
|
-
|
|
272
|
-
|
|
274
|
+
h,
|
|
275
|
+
x,
|
|
276
|
+
d
|
|
273
277
|
]);
|
|
274
|
-
return j(
|
|
278
|
+
return j(L, {
|
|
275
279
|
ref: r,
|
|
276
|
-
disabled:
|
|
280
|
+
disabled: g,
|
|
277
281
|
groupKey: n,
|
|
278
|
-
label:
|
|
279
|
-
tooltip:
|
|
280
|
-
createPopupPanel:
|
|
281
|
-
icon:
|
|
282
|
+
label: x?.getLabel(n) ?? d("insertScript.fallbackLabel"),
|
|
283
|
+
tooltip: x?.getDescription(),
|
|
284
|
+
createPopupPanel: S,
|
|
285
|
+
icon: x?.getIcon() ?? "ScriptInsert",
|
|
282
286
|
...s
|
|
283
287
|
});
|
|
284
|
-
})),
|
|
285
|
-
const { propsCommandButton: r, ...n } = e
|
|
286
|
-
|
|
288
|
+
})), de = n(r((e, t) => {
|
|
289
|
+
const { propsCommandButton: r, ...n } = e, i = C((e) => {
|
|
290
|
+
const { propsCommandButton: t, propsCommandPopup: r } = e;
|
|
291
|
+
return j(W, { children: H("div", {
|
|
292
|
+
style: {
|
|
293
|
+
display: "flex",
|
|
294
|
+
flex: "1 1 100%"
|
|
295
|
+
},
|
|
296
|
+
children: [
|
|
297
|
+
j("div", { children: j(R, {
|
|
298
|
+
style: {},
|
|
299
|
+
children: j(I, {
|
|
300
|
+
...t,
|
|
301
|
+
commandKey: "saveScripts"
|
|
302
|
+
})
|
|
303
|
+
}) }),
|
|
304
|
+
j("div", { style: { flex: "1 1 100%" } }),
|
|
305
|
+
j("div", { children: j(R, {
|
|
306
|
+
style: {},
|
|
307
|
+
children: j(ce, { ...t })
|
|
308
|
+
}) })
|
|
309
|
+
]
|
|
310
|
+
}) });
|
|
311
|
+
}, []);
|
|
312
|
+
return j(P, {
|
|
287
313
|
ref: t,
|
|
288
314
|
propsCommandButton: r,
|
|
289
|
-
renderToolbarPalette:
|
|
290
|
-
const { propsCommandButton: t, propsCommandPopup: r } = e;
|
|
291
|
-
return j(W, { children: H("div", {
|
|
292
|
-
style: {
|
|
293
|
-
display: "flex",
|
|
294
|
-
flex: "1 1 100%"
|
|
295
|
-
},
|
|
296
|
-
children: [
|
|
297
|
-
j("div", { children: j(R, {
|
|
298
|
-
style: {},
|
|
299
|
-
children: j(D, {
|
|
300
|
-
...t,
|
|
301
|
-
commandKey: "saveScripts"
|
|
302
|
-
})
|
|
303
|
-
}) }),
|
|
304
|
-
j("div", { style: { flex: "1 1 100%" } }),
|
|
305
|
-
j("div", { children: j(R, {
|
|
306
|
-
style: {},
|
|
307
|
-
children: j(le, { ...t })
|
|
308
|
-
}) })
|
|
309
|
-
]
|
|
310
|
-
}) });
|
|
311
|
-
}, []),
|
|
315
|
+
renderToolbarPalette: i,
|
|
312
316
|
...n
|
|
313
317
|
});
|
|
314
318
|
}));
|
|
315
|
-
|
|
316
|
-
var
|
|
317
|
-
const { scriptPath: r =
|
|
319
|
+
de.displayName = "ScriptEditorToolbar", X();
|
|
320
|
+
var pe = n(r((e, t) => {
|
|
321
|
+
const { scriptPath: r = re, onScriptSelect: n, disabled: i = !1, sx: a = k.EmptyCssProperties, className: l, buttonMinWidth: s = 210, buttonMinHeight: h = 80, gap: x = 12, ...g } = e, y = K(), [S, b] = c([]), [w, C] = c(!0), [F, N] = c(null);
|
|
318
322
|
if (o(() => {
|
|
319
323
|
(async () => {
|
|
320
324
|
const e = [{
|
|
321
325
|
path: null,
|
|
322
326
|
metadata: {
|
|
323
|
-
title:
|
|
324
|
-
summary:
|
|
327
|
+
title: y("templateSelect.blankTitle"),
|
|
328
|
+
summary: y("templateSelect.blankSummary")
|
|
325
329
|
},
|
|
326
330
|
content: ""
|
|
327
331
|
}];
|
|
328
332
|
try {
|
|
329
|
-
|
|
330
|
-
const t = await
|
|
333
|
+
C(!0), N(null);
|
|
334
|
+
const t = await oe(r);
|
|
331
335
|
for (let r = 0; r < t.length; r++) {
|
|
332
336
|
const n = t[r];
|
|
333
337
|
n && e.push(n);
|
|
334
338
|
}
|
|
335
339
|
} catch (e) {
|
|
336
|
-
|
|
340
|
+
N(e instanceof Error ? e.message : y("templateSelect.loadFailed")), e instanceof Z || console.error("Error loading scripts:", e);
|
|
337
341
|
} finally {
|
|
338
|
-
|
|
342
|
+
b(e), C(!1);
|
|
339
343
|
}
|
|
340
344
|
})();
|
|
341
|
-
}, [r,
|
|
342
|
-
className: d(
|
|
345
|
+
}, [r, y]), w) return j(p, {
|
|
346
|
+
className: d(l, "script-select"),
|
|
343
347
|
...g,
|
|
344
348
|
sx: [{
|
|
345
349
|
display: "flex",
|
|
@@ -348,14 +352,13 @@ var ce = n(r((e, t) => {
|
|
|
348
352
|
height: "100%",
|
|
349
353
|
background: (e) => e.palette.background.paper,
|
|
350
354
|
zIndex: 1e3,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
}, ...Array.isArray(i) ? i : []],
|
|
355
|
+
...Array.isArray(a) ? {} : a
|
|
356
|
+
}, ...Array.isArray(a) ? a : []],
|
|
354
357
|
children: j(u, {})
|
|
355
358
|
});
|
|
356
|
-
let
|
|
357
|
-
|
|
358
|
-
className: d(
|
|
359
|
+
let T = null;
|
|
360
|
+
F && (T = H(p, {
|
|
361
|
+
className: d(l, "script-select", "error-results"),
|
|
359
362
|
...g,
|
|
360
363
|
sx: [{
|
|
361
364
|
display: "flex",
|
|
@@ -368,42 +371,40 @@ var ce = n(r((e, t) => {
|
|
|
368
371
|
padding: (e) => e.spacing(1),
|
|
369
372
|
border: (e) => `1px solid ${e.palette.error.main}`,
|
|
370
373
|
borderBottomLeftRadius: 1,
|
|
371
|
-
borderBottomRightRadius: 1
|
|
372
|
-
|
|
373
|
-
}, ...Array.isArray(i) ? i : [i]],
|
|
374
|
+
borderBottomRightRadius: 1
|
|
375
|
+
}, ...Array.isArray(a) ? a : [a]],
|
|
374
376
|
children: [j(f, {
|
|
375
377
|
color: "error",
|
|
376
378
|
variant: "h6",
|
|
377
379
|
component: "div",
|
|
378
380
|
gutterBottom: !0,
|
|
379
|
-
children:
|
|
381
|
+
children: y("templateSelect.errorTitle")
|
|
380
382
|
}), j(f, {
|
|
381
383
|
color: "error",
|
|
382
384
|
component: "div",
|
|
383
|
-
children:
|
|
385
|
+
children: F
|
|
384
386
|
})]
|
|
385
387
|
}));
|
|
386
|
-
const
|
|
388
|
+
const D = (e) => {
|
|
387
389
|
const t = e.metadata?.icon;
|
|
388
|
-
return "macro" === t ? j(
|
|
390
|
+
return "macro" === t ? j(v, {
|
|
389
391
|
iconKey: "ScriptMacro",
|
|
390
392
|
size: "1em"
|
|
391
|
-
}) : "formula" === t ? j(
|
|
393
|
+
}) : "formula" === t ? j(v, {
|
|
392
394
|
iconKey: "ScriptFormula",
|
|
393
395
|
size: "1em"
|
|
394
|
-
}) : "autostart" === t ? j(
|
|
396
|
+
}) : "autostart" === t ? j(v, {
|
|
395
397
|
iconKey: "ScriptAutoRun",
|
|
396
398
|
size: "1em"
|
|
397
399
|
}) : null;
|
|
398
400
|
};
|
|
399
401
|
return H(p, {
|
|
400
402
|
ref: t,
|
|
401
|
-
className: d(
|
|
403
|
+
className: d(l, "script-select"),
|
|
402
404
|
sx: {
|
|
403
405
|
background: (e) => e.palette.background.paper,
|
|
404
406
|
zIndex: 1e3,
|
|
405
|
-
|
|
406
|
-
...i
|
|
407
|
+
...a
|
|
407
408
|
},
|
|
408
409
|
...g,
|
|
409
410
|
children: [H(p, {
|
|
@@ -417,36 +418,37 @@ var ce = n(r((e, t) => {
|
|
|
417
418
|
j(f, {
|
|
418
419
|
variant: "h6",
|
|
419
420
|
gutterBottom: !0,
|
|
420
|
-
children:
|
|
421
|
+
children: y("templateSelect.title")
|
|
421
422
|
}),
|
|
422
423
|
j(f, {
|
|
423
424
|
variant: "body2",
|
|
424
425
|
component: "div",
|
|
425
426
|
gutterBottom: !0,
|
|
426
427
|
sx: { color: "text.secondary" },
|
|
427
|
-
children:
|
|
428
|
+
children: y("templateSelect.intro")
|
|
428
429
|
}),
|
|
429
430
|
j(f, {
|
|
430
431
|
variant: "body2",
|
|
431
432
|
component: "div",
|
|
432
433
|
gutterBottom: !0,
|
|
433
434
|
sx: { color: "text.secondary" },
|
|
434
|
-
children:
|
|
435
|
+
children: y("templateSelect.intro2")
|
|
435
436
|
}),
|
|
436
437
|
j(p, {
|
|
437
438
|
sx: {
|
|
438
439
|
display: "grid",
|
|
439
|
-
gridTemplateColumns: `repeat(auto-fill, minmax(${
|
|
440
|
-
gap: `${
|
|
440
|
+
gridTemplateColumns: `repeat(auto-fill, minmax(${s}px, 1fr))`,
|
|
441
|
+
gap: `${x}px`,
|
|
441
442
|
padding: 2,
|
|
442
443
|
paddingLeft: "0px",
|
|
443
444
|
paddingRight: "0px"
|
|
444
445
|
},
|
|
445
|
-
children:
|
|
446
|
+
children: S.map((e, t) => H(m, {
|
|
446
447
|
variant: "outlined",
|
|
448
|
+
disabled: i,
|
|
447
449
|
sx: {
|
|
448
|
-
minWidth:
|
|
449
|
-
minHeight:
|
|
450
|
+
minWidth: s,
|
|
451
|
+
minHeight: h,
|
|
450
452
|
display: "flex",
|
|
451
453
|
flexDirection: "column",
|
|
452
454
|
justifyContent: "flex-start",
|
|
@@ -474,8 +476,8 @@ var ce = n(r((e, t) => {
|
|
|
474
476
|
children: [j(f, {
|
|
475
477
|
variant: "subtitle2",
|
|
476
478
|
component: "div",
|
|
477
|
-
children: e.metadata?.title || e.path?.split("/").pop()?.replace(/\.\w+$/, "") ||
|
|
478
|
-
}),
|
|
479
|
+
children: e.metadata?.title || e.path?.split("/").pop()?.replace(/\.\w+$/, "") || y("templateSelect.untitled")
|
|
480
|
+
}), D(e)]
|
|
479
481
|
}), e.metadata?.summary && j(f, {
|
|
480
482
|
variant: "body2",
|
|
481
483
|
component: "div",
|
|
@@ -492,44 +494,44 @@ var ce = n(r((e, t) => {
|
|
|
492
494
|
}, `${e.path}-${t}`))
|
|
493
495
|
})
|
|
494
496
|
]
|
|
495
|
-
}),
|
|
497
|
+
}), T]
|
|
496
498
|
});
|
|
497
499
|
}));
|
|
498
|
-
|
|
499
|
-
var
|
|
500
|
-
const { className: r, sx: n, propsScriptEditor: l, readOnly: m = !1, frame: u, autoFocusSel:
|
|
500
|
+
pe.displayName = "TemplateSelectPanel";
|
|
501
|
+
var me = n(r((e, t) => {
|
|
502
|
+
const { className: r, sx: n, propsScriptEditor: l, readOnly: m = !1, frame: u, autoFocusSel: g, autoFocus: y = !0, scripts: S, ...b } = e, v = x(), [w, k] = c(!1), F = s(!1), [N, K] = c({
|
|
501
503
|
message: "Loading",
|
|
502
504
|
cursor: "",
|
|
503
505
|
dirty: !1
|
|
504
|
-
}), [
|
|
506
|
+
}), [I, L] = c(null);
|
|
505
507
|
o(() => {
|
|
506
508
|
let e = !1;
|
|
507
|
-
return
|
|
509
|
+
return L(null), async function() {
|
|
508
510
|
if (S && (await S.start(), !e)) {
|
|
509
511
|
const e = S.getModules().getItems()[0]?.getSource();
|
|
510
|
-
|
|
512
|
+
L({ source: e || null });
|
|
511
513
|
}
|
|
512
514
|
}(), () => {
|
|
513
515
|
e = !0;
|
|
514
516
|
};
|
|
515
517
|
}, [S]);
|
|
516
|
-
const
|
|
518
|
+
const P = i((e) => {
|
|
517
519
|
K((t) => ({
|
|
518
520
|
...t,
|
|
519
521
|
...e
|
|
520
522
|
}));
|
|
521
|
-
}, []),
|
|
522
|
-
if (
|
|
523
|
-
if (
|
|
524
|
-
const t =
|
|
523
|
+
}, []), $ = s(null), [E, R] = c(null), z = s(null), A = C((e) => {
|
|
524
|
+
if (E) return E.focus(e), !0;
|
|
525
|
+
if (g) {
|
|
526
|
+
const t = $.current?.querySelectorAll?.(g);
|
|
525
527
|
if (t && t.length > 0) return t[0]?.focus?.(e), !0;
|
|
526
528
|
}
|
|
527
|
-
return
|
|
529
|
+
return $.current?.focus?.(e), !1;
|
|
528
530
|
}, [
|
|
529
|
-
|
|
530
|
-
|
|
531
|
+
E,
|
|
532
|
+
g,
|
|
531
533
|
y
|
|
532
|
-
]),
|
|
534
|
+
]), B = a(() => j(D, {
|
|
533
535
|
transitionDelay: "160ms",
|
|
534
536
|
style: {
|
|
535
537
|
position: "absolute",
|
|
@@ -550,8 +552,8 @@ var de = n(r((e, t) => {
|
|
|
550
552
|
marginTop: (e) => e.spacing(1),
|
|
551
553
|
marginBottom: (e) => e.spacing(1)
|
|
552
554
|
},
|
|
553
|
-
children: j(
|
|
554
|
-
}), [
|
|
555
|
+
children: j(de, {})
|
|
556
|
+
}), [v]), M = a(() => j(p, {
|
|
555
557
|
className: d("script-status-panel", "status-panel"),
|
|
556
558
|
sx: {
|
|
557
559
|
display: "flex",
|
|
@@ -564,7 +566,7 @@ var de = n(r((e, t) => {
|
|
|
564
566
|
paddingTop: "1px",
|
|
565
567
|
minHeight: "calc(1em + 8px)",
|
|
566
568
|
margin: 0,
|
|
567
|
-
borderTop: `solid 1px ${
|
|
569
|
+
borderTop: `solid 1px ${v.palette.divider}`
|
|
568
570
|
},
|
|
569
571
|
children: H("div", {
|
|
570
572
|
style: {
|
|
@@ -641,34 +643,34 @@ var de = n(r((e, t) => {
|
|
|
641
643
|
boxSizing: "border-box"
|
|
642
644
|
},
|
|
643
645
|
children: j(G, {
|
|
644
|
-
ref:
|
|
645
|
-
loadingPanel:
|
|
646
|
+
ref: $,
|
|
647
|
+
loadingPanel: B,
|
|
646
648
|
readOnly: m,
|
|
647
649
|
frame: u,
|
|
648
650
|
scripts: S,
|
|
649
651
|
autoFocus: y,
|
|
650
|
-
onStatusChange:
|
|
651
|
-
darkMode: "dark" ===
|
|
652
|
+
onStatusChange: P,
|
|
653
|
+
darkMode: "dark" === v.palette.mode,
|
|
652
654
|
...l
|
|
653
655
|
})
|
|
654
656
|
}),
|
|
655
657
|
M
|
|
656
658
|
]
|
|
657
659
|
}), [
|
|
658
|
-
|
|
660
|
+
v,
|
|
659
661
|
O,
|
|
660
662
|
M,
|
|
661
663
|
w,
|
|
662
|
-
|
|
664
|
+
B,
|
|
663
665
|
m,
|
|
664
666
|
l,
|
|
665
667
|
y,
|
|
666
|
-
|
|
668
|
+
g,
|
|
667
669
|
u,
|
|
668
|
-
|
|
670
|
+
P
|
|
669
671
|
]), U = a(() => {
|
|
670
672
|
let e;
|
|
671
|
-
return null ===
|
|
673
|
+
return null === I ? B : (null === I.source && (e = j(pe, {
|
|
672
674
|
sx: {
|
|
673
675
|
display: "flex",
|
|
674
676
|
flex: "1 1 100%",
|
|
@@ -679,8 +681,9 @@ var de = n(r((e, t) => {
|
|
|
679
681
|
width: "100%",
|
|
680
682
|
height: "100%"
|
|
681
683
|
},
|
|
684
|
+
disabled: m,
|
|
682
685
|
onScriptSelect: (e) => {
|
|
683
|
-
|
|
686
|
+
$.current?.insertSnippet(e.content), L({ source: e.content ?? "" }), requestAnimationFrame(() => $.current?.focus());
|
|
684
687
|
}
|
|
685
688
|
})), j(p, {
|
|
686
689
|
tabIndex: 0,
|
|
@@ -696,7 +699,7 @@ var de = n(r((e, t) => {
|
|
|
696
699
|
outline: "none"
|
|
697
700
|
},
|
|
698
701
|
onPointerDown: (e) => {
|
|
699
|
-
e.isDefaultPrevented() ||
|
|
702
|
+
e.isDefaultPrevented() || $.current?.focus();
|
|
700
703
|
},
|
|
701
704
|
children: H(p, {
|
|
702
705
|
sx: {
|
|
@@ -720,12 +723,13 @@ var de = n(r((e, t) => {
|
|
|
720
723
|
O,
|
|
721
724
|
W,
|
|
722
725
|
r,
|
|
723
|
-
|
|
724
|
-
|
|
726
|
+
I,
|
|
727
|
+
B,
|
|
728
|
+
m
|
|
725
729
|
]), q = T(t, () => ({
|
|
726
730
|
isScriptWorkspaceElement: () => !0,
|
|
727
731
|
focus: (e) => {
|
|
728
|
-
|
|
732
|
+
A(e);
|
|
729
733
|
}
|
|
730
734
|
}), []);
|
|
731
735
|
return j(p, {
|
|
@@ -737,52 +741,54 @@ var de = n(r((e, t) => {
|
|
|
737
741
|
...n
|
|
738
742
|
},
|
|
739
743
|
ref: q,
|
|
740
|
-
...
|
|
744
|
+
...b,
|
|
741
745
|
onFocus: (e) => {
|
|
742
|
-
k(!0), F.current = !0, q.current?.contains(e.target) && e.target !== q.current && R(e.target), e.relatedTarget && !z.current && (z.current = e.relatedTarget),
|
|
746
|
+
k(!0), F.current = !0, q.current?.contains(e.target) && e.target !== q.current && R(e.target), e.relatedTarget && !z.current && (z.current = e.relatedTarget), b?.onFocus?.(e);
|
|
743
747
|
},
|
|
744
748
|
onBlur: (e) => {
|
|
745
|
-
q?.current?.contains(e.relatedTarget) || q?.current === e.relatedTarget || (z.current = null, F.current = !1, k(!1)),
|
|
749
|
+
q?.current?.contains(e.relatedTarget) || q?.current === e.relatedTarget || (z.current = null, F.current = !1, k(!1)), b?.onBlur?.(e);
|
|
746
750
|
},
|
|
747
751
|
children: U
|
|
748
752
|
});
|
|
749
753
|
}));
|
|
750
|
-
|
|
751
|
-
var { FocusActivation:
|
|
752
|
-
const t =
|
|
753
|
-
return t ? j(
|
|
754
|
-
spec:
|
|
754
|
+
me.displayName = "ScriptWorkspace";
|
|
755
|
+
var { FocusActivation: ue, CommandScopeProvider: he, CommandAnchorProvider: fe, useCommandScope: xe } = g, ge = { scopeName: "scriptEditor" }, ye = ({ children: e }) => {
|
|
756
|
+
const t = xe(), r = s(null);
|
|
757
|
+
return t ? j(he, {
|
|
758
|
+
spec: ge,
|
|
755
759
|
elementRef: r,
|
|
756
760
|
region: !0,
|
|
757
|
-
children: j(
|
|
761
|
+
children: j(Se, {
|
|
758
762
|
paneRef: r,
|
|
759
763
|
children: e
|
|
760
764
|
})
|
|
761
765
|
}) : e;
|
|
762
|
-
},
|
|
763
|
-
const r =
|
|
764
|
-
return n ? H(
|
|
766
|
+
}, Se = ({ paneRef: e, children: t }) => {
|
|
767
|
+
const r = xe(), n = a(() => r ? new ue(r.getRoot(), r) : null, [r]);
|
|
768
|
+
return n ? H(fe, {
|
|
765
769
|
tracker: n,
|
|
766
770
|
keyBindings: !1,
|
|
767
771
|
debounce: 100,
|
|
768
772
|
elementRef: e,
|
|
769
|
-
children: [j(
|
|
773
|
+
children: [j(B, {}), j("div", {
|
|
770
774
|
className: "script-editor-pane",
|
|
771
775
|
style: { display: "contents" },
|
|
772
776
|
ref: e,
|
|
773
777
|
children: t
|
|
774
778
|
})]
|
|
775
779
|
}) : t;
|
|
776
|
-
},
|
|
777
|
-
const { model: t, entryKey: r, frame: n, ref: i, ...o } = e;
|
|
778
|
-
|
|
780
|
+
}, be = (e) => {
|
|
781
|
+
const { model: t, entryKey: r, frame: n, ref: i, ...o } = e, a = M() ?? t;
|
|
782
|
+
O(a, ["onProtectionChange"]);
|
|
783
|
+
const l = a?.getScripts().isReadOnly() ?? !1;
|
|
784
|
+
return j(ye, { children: j(me, {
|
|
779
785
|
ref: i,
|
|
780
|
-
readOnly:
|
|
786
|
+
readOnly: l,
|
|
781
787
|
frame: n,
|
|
782
|
-
scripts:
|
|
788
|
+
scripts: a?.getScripts(),
|
|
783
789
|
...o
|
|
784
790
|
}) });
|
|
785
|
-
},
|
|
791
|
+
}, ve = n((e) => {
|
|
786
792
|
const { alwaysShow: t = !1, ...r } = e, [n, i] = l((e) => e + 1, 0), [a] = N(["showScriptEditor"], { onChange: () => i() }), s = M(), [d, p] = c(t);
|
|
787
793
|
return o(() => {
|
|
788
794
|
if (t) return void p(!0);
|
|
@@ -804,10 +810,10 @@ var { FocusActivation: pe, CommandScopeProvider: me, CommandAnchorProvider: ue,
|
|
|
804
810
|
s,
|
|
805
811
|
a,
|
|
806
812
|
n
|
|
807
|
-
]), d ? H(W, { children: [j(
|
|
813
|
+
]), d ? H(W, { children: [j($, {}), j(ee, { ...r })] }) : null;
|
|
808
814
|
});
|
|
809
|
-
|
|
810
|
-
var
|
|
815
|
+
ve.displayName = "RunScriptContribution", X();
|
|
816
|
+
var we = n(r((e, r) => {
|
|
811
817
|
const { ...n } = e, i = M(), a = K(), [l, s] = c([]);
|
|
812
818
|
o(() => {
|
|
813
819
|
const e = i?.getScripts();
|
|
@@ -831,12 +837,12 @@ var ve = n(r((e, r) => {
|
|
|
831
837
|
}, m = [], u = l ? l.length : 0;
|
|
832
838
|
for (let e = 0; e < u; e++) {
|
|
833
839
|
const t = l[e];
|
|
834
|
-
m.push(j(
|
|
840
|
+
m.push(j(I, {
|
|
835
841
|
...d,
|
|
836
842
|
commandKey: "insertFunction",
|
|
837
843
|
commandState: t,
|
|
838
844
|
propsTooltip: { description: a("insertFunction.insertNamed", { name: t.getName() ?? a("insertFunction.fallbackLabel") }) },
|
|
839
|
-
icon: j(
|
|
845
|
+
icon: j(v, { iconKey: "FormulaCustom" }),
|
|
840
846
|
label: t.getName() ?? a("insertFunction.fallbackLabel")
|
|
841
847
|
}, `function-${t.getName()}-${e}`));
|
|
842
848
|
}
|
|
@@ -854,7 +860,7 @@ var ve = n(r((e, r) => {
|
|
|
854
860
|
flex: "1 1 100%"
|
|
855
861
|
},
|
|
856
862
|
children: m
|
|
857
|
-
}), j(
|
|
863
|
+
}), j($, { orientation: "horizontal" })] }) : null, t(I, {
|
|
858
864
|
...d,
|
|
859
865
|
key: "show-editor",
|
|
860
866
|
commandKey: "showScriptEditor"
|
|
@@ -865,45 +871,45 @@ var ve = n(r((e, r) => {
|
|
|
865
871
|
children: h
|
|
866
872
|
});
|
|
867
873
|
}));
|
|
868
|
-
|
|
869
|
-
var
|
|
870
|
-
const { disabled: r, groupKey: n, ...o } = e, a = F("customFunctionOptions")
|
|
871
|
-
|
|
874
|
+
we.displayName = "InsertFunctionPopupPanel";
|
|
875
|
+
var ke = n(r((e, t) => {
|
|
876
|
+
const { disabled: r, groupKey: n, ...o } = e, a = F("customFunctionOptions"), l = i((e) => {
|
|
877
|
+
const t = j(we, {
|
|
878
|
+
disabled: r,
|
|
879
|
+
groupKey: n,
|
|
880
|
+
...e
|
|
881
|
+
});
|
|
882
|
+
return z({
|
|
883
|
+
...e,
|
|
884
|
+
children: t
|
|
885
|
+
});
|
|
886
|
+
}, [r, n]);
|
|
887
|
+
return j(L, {
|
|
872
888
|
ref: t,
|
|
873
889
|
disabled: r,
|
|
874
|
-
createPopupPanel:
|
|
875
|
-
const t = j(ve, {
|
|
876
|
-
disabled: r,
|
|
877
|
-
groupKey: n,
|
|
878
|
-
...e
|
|
879
|
-
});
|
|
880
|
-
return z({
|
|
881
|
-
...e,
|
|
882
|
-
children: t
|
|
883
|
-
});
|
|
884
|
-
}, [r, n]),
|
|
890
|
+
createPopupPanel: l,
|
|
885
891
|
label: a?.getLabel?.(),
|
|
886
892
|
tooltip: a?.getDescription?.(),
|
|
887
893
|
icon: "FormulaCustom",
|
|
888
894
|
...o
|
|
889
895
|
});
|
|
890
896
|
}));
|
|
891
|
-
|
|
892
|
-
var
|
|
893
|
-
J(),
|
|
897
|
+
ke.displayName = "InsertFunctionContribution";
|
|
898
|
+
var Ce = () => {
|
|
899
|
+
J(), b.register("plugin-scripts", { icons: {} }), A.registerTaskPane({
|
|
894
900
|
key: "scriptEditor",
|
|
895
901
|
getTitle: () => "Script (Typescript)",
|
|
896
902
|
getIcon: () => "ScriptRun",
|
|
897
|
-
component:
|
|
903
|
+
component: be,
|
|
898
904
|
keepMounted: !0
|
|
899
905
|
}, !0), S.register({ key: "scriptsOptions" }, !0), S.register({ key: "customFunctionOptions" }, !0), S.register({
|
|
900
906
|
key: "scripting.runScript.home",
|
|
901
907
|
contributions: { homeToolbar: {} },
|
|
902
|
-
render: (t) => e.createElement(
|
|
908
|
+
render: (t) => e.createElement(ve, { ...t })
|
|
903
909
|
}, !0), S.register({
|
|
904
910
|
key: "scripting.runScript.view",
|
|
905
911
|
contributions: { viewToolbar: { order: 10 } },
|
|
906
|
-
render: (t) => e.createElement(
|
|
912
|
+
render: (t) => e.createElement(ve, {
|
|
907
913
|
...t,
|
|
908
914
|
groupKey: "view",
|
|
909
915
|
alwaysShow: !0
|
|
@@ -914,7 +920,7 @@ var we = () => {
|
|
|
914
920
|
anchor: "formulaCategory.web",
|
|
915
921
|
order: 1
|
|
916
922
|
} },
|
|
917
|
-
render: (t) => e.createElement(
|
|
923
|
+
render: (t) => e.createElement(ke, { ...t })
|
|
918
924
|
}, !0);
|
|
919
925
|
};
|
|
920
|
-
export {
|
|
926
|
+
export { ce as InsertScriptCommandButton, ee as RunScriptCommandButton, de as ScriptEditorToolbar, be as ScriptTaskPane, me as ScriptWorkspace, Ce as ScriptingPlugin };
|