@sheetxl/scripting-mui 0.8.0-beta.2 → 0.8.0-beta.20
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/LICENSE.md +17 -7
- package/browser/esm/index.mjs +243 -225
- package/node/esm/index.mjs +389 -372
- package/package.json +13 -14
- package/resources/locales/de/ui.msg.json +2 -0
- package/resources/locales/en/ui.msg.json +2 -0
- package/types/src/command/InsertScriptCommandButton.d.ts +2 -1
- package/types/src/template/TemplateSelectPanel.d.ts +4 -3
- package/types/src/utils/ScriptTemplates.d.ts +27 -0
- package/types/src/utils/index.d.ts +1 -2
- package/browser/cjs/index.cjs +0 -1
- package/types/src/utils/FetchDirectory.d.ts +0 -20
- package/types/src/utils/Utils.d.ts +0 -2
package/browser/esm/index.mjs
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.
|
|
2
|
+
* @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.20
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
|
-
* License:
|
|
5
|
+
* License: MIT
|
|
6
6
|
*/
|
|
7
7
|
import e, { createElement as t, forwardRef as n, memo as r, useCallback as i, useEffect as a, useMemo as o, useReducer as s, useRef as c, useState as l } from "react";
|
|
8
8
|
import { Box as u, Button as d, CircularProgress as f, Paper as p, Typography as m, useTheme as h } from "@mui/material";
|
|
9
9
|
import { Command as g, CommandButtonType as _, DefaultCommandButtonRegistry as v, DefaultIconService as y, DynamicIcon as b, KeyCodes as x, ReactUtils as S, useCallbackRef as C, useCommandButtonEntry as w, useCommands as T, useImperativeElement as E, useTranslator as D } from "@sheetxl/utils-react";
|
|
10
|
-
import { AnimatedLoadingPanel as ee, CommandButton as O, CommandPopupButton as k, CommandToolbar as A, ExhibitDivider as j, ExhibitMenuItem as M, OverflowPalette as N,
|
|
10
|
+
import { AnimatedLoadingPanel as ee, CommandButton as O, CommandPopupButton as k, CommandToolbar as A, ExhibitDivider as j, ExhibitMenuItem as M, OverflowPalette as N, defaultRenderPopupPanel as P } from "@sheetxl/utils-mui";
|
|
11
11
|
import { DefaultTaskPaneRegistry as F, InputClipboardInjector as I, useModelSync as L, useWorkbook as R } from "@sheetxl/react";
|
|
12
12
|
import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
|
|
13
13
|
import { alpha as H } from "@mui/system";
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
|
|
14
|
+
import { listResources as U, releaseChannel as te } from "@sheetxl/utils";
|
|
15
|
+
import { VERSION as ne } from "@sheetxl/sdk";
|
|
16
|
+
import { ScriptEditor as re, ScriptingReactPlugin as ie } from "@sheetxl/scripting-react";
|
|
17
|
+
function W(e) {
|
|
17
18
|
var t, n, r = "";
|
|
18
19
|
if (typeof e == "string" || typeof e == "number") r += e;
|
|
19
|
-
else if (typeof e == "object")
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
else if (typeof e == "object") {
|
|
21
|
+
if (Array.isArray(e)) {
|
|
22
|
+
var i = e.length;
|
|
23
|
+
for (t = 0; t < i; t++) e[t] && (n = W(e[t])) && (r && (r += " "), r += n);
|
|
24
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
25
|
+
}
|
|
23
26
|
return r;
|
|
24
27
|
}
|
|
25
|
-
function
|
|
26
|
-
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t =
|
|
28
|
+
function G() {
|
|
29
|
+
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = W(e)) && (r && (r += " "), r += t);
|
|
27
30
|
return r;
|
|
28
31
|
}
|
|
29
|
-
var
|
|
32
|
+
var ae = {
|
|
30
33
|
"insertFunction.fallbackLabel": "Function",
|
|
31
34
|
"insertFunction.insertNamed": "Insert {name}",
|
|
32
35
|
"insertScript.fallbackLabel": "Insert Script",
|
|
36
|
+
"insertScript.loadFailedRetry": "Couldn’t load templates. Retry",
|
|
33
37
|
"insertScript.loading": "Loading...",
|
|
34
38
|
"runScript.executeNamed": "Execute {name}",
|
|
35
39
|
"runScript.fallbackLabel": "Macro",
|
|
@@ -39,14 +43,15 @@ var ie = {
|
|
|
39
43
|
"templateSelect.intro": "Choose from a template to provide a starting point to automate tasks or create user defined functions.",
|
|
40
44
|
"templateSelect.intro2": "Templates provide a foundation to customize and meet your specific needs.",
|
|
41
45
|
"templateSelect.loadFailed": "Failed to load scripts",
|
|
46
|
+
"templateSelect.retry": "Retry",
|
|
42
47
|
"templateSelect.title": "Script Template",
|
|
43
48
|
"templateSelect.untitled": "Untitled"
|
|
44
|
-
}, { DefaultCommandCatalogService:
|
|
49
|
+
}, { DefaultCommandCatalogService: oe } = g, se = !1;
|
|
45
50
|
function K() {
|
|
46
|
-
|
|
51
|
+
se || (se = !0, oe.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: ae }));
|
|
47
52
|
}
|
|
48
53
|
K();
|
|
49
|
-
var
|
|
54
|
+
var ce = r(n((e, n) => {
|
|
50
55
|
let { groupKey: r, ...i } = e, o = R(), s = D(), [c, d] = l([]), [f, p] = l(!1);
|
|
51
56
|
a(() => {
|
|
52
57
|
let e = o?.getScripts();
|
|
@@ -97,72 +102,67 @@ var q = r(n((e, n) => {
|
|
|
97
102
|
children: v
|
|
98
103
|
});
|
|
99
104
|
}));
|
|
100
|
-
|
|
101
|
-
var
|
|
102
|
-
let { groupKey: n, disabled: r, ...a } = e, o = T(["showScriptEditor"])[0], s = w("scriptsOptions")
|
|
105
|
+
ce.displayName = "RunScriptPopupPanel";
|
|
106
|
+
var le = r(n((e, t) => {
|
|
107
|
+
let { groupKey: n, disabled: r, ...a } = e, o = T(["showScriptEditor"])[0], s = w("scriptsOptions"), c = i((e) => {
|
|
108
|
+
let t = B(ce, {
|
|
109
|
+
disabled: r,
|
|
110
|
+
groupKey: n,
|
|
111
|
+
...e
|
|
112
|
+
});
|
|
113
|
+
return P({
|
|
114
|
+
...e,
|
|
115
|
+
children: t
|
|
116
|
+
});
|
|
117
|
+
}, [r, n]);
|
|
103
118
|
return B(k, {
|
|
104
119
|
ref: t,
|
|
105
120
|
disabled: r,
|
|
106
|
-
|
|
107
|
-
let t = B(q, {
|
|
108
|
-
disabled: r,
|
|
109
|
-
groupKey: n,
|
|
110
|
-
...e
|
|
111
|
-
});
|
|
112
|
-
return P({
|
|
113
|
-
...e,
|
|
114
|
-
children: t
|
|
115
|
-
});
|
|
116
|
-
}, [r, n]),
|
|
121
|
+
renderPopupPanel: c,
|
|
117
122
|
selected: o?.getState(),
|
|
118
123
|
label: s?.getLabel?.(),
|
|
119
124
|
tooltip: s?.getDescription?.(),
|
|
120
125
|
quickCommand: "showScriptEditor",
|
|
121
126
|
...a
|
|
122
127
|
});
|
|
123
|
-
})),
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
let n = e.
|
|
129
|
-
return n.
|
|
130
|
-
},
|
|
131
|
-
if (
|
|
132
|
-
let
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
if (!n.ok) throw new U(`Failed to retrieve directory at '${e}': ${n.statusText}`);
|
|
137
|
-
let r = await n.text();
|
|
138
|
-
if (r.trim().toLowerCase().startsWith("<!doctype html") || r.trim().toLowerCase().startsWith("<html")) throw new U(`Failed to retrieve directory at '${e}'`);
|
|
139
|
-
let i;
|
|
128
|
+
})), ue = te(ne), q = `https://unpkg.com/@sheetxl/templates-scripting${ue ? `@${ue}` : ""}/dist`, de = "templates-scripting", fe = [
|
|
129
|
+
"formula",
|
|
130
|
+
"macro",
|
|
131
|
+
"autostart"
|
|
132
|
+
], pe = (e) => typeof e == "string" && e ? e : void 0, me = (e, t) => {
|
|
133
|
+
let n = (e.split("/").pop() ?? "").replace(/\.[^/.]+$/, "");
|
|
134
|
+
return t === "formula" ? n.toUpperCase() : n.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
135
|
+
}, he = async (e, t) => {
|
|
136
|
+
if (!/\.ts$/i.test(t.path)) return null;
|
|
137
|
+
let n = fe.includes(t.icon) ? t.icon : void 0, r = ((e, t) => {
|
|
138
|
+
let n = `${e}${e.endsWith("/") ? "" : "/"}${de}/${t}`;
|
|
139
|
+
return typeof document > "u" ? n : new URL(n, document.baseURI).href;
|
|
140
|
+
})(e, t.path), i;
|
|
140
141
|
try {
|
|
141
|
-
|
|
142
|
+
let e = await fetch(r);
|
|
143
|
+
if (!e.ok || (e.headers.get("content-type") ?? "").includes("text/html")) throw Error(e.ok ? "not found" : e.statusText || String(e.status));
|
|
144
|
+
i = await e.text();
|
|
142
145
|
} catch (e) {
|
|
143
|
-
|
|
146
|
+
return console.warn(`Script template '${r}' did not load: ${e?.message ?? e}`), null;
|
|
144
147
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
163
|
-
return (await Promise.all(a)).filter((e) => e !== null);
|
|
164
|
-
}, Y = { marginRight: "4px" }, X = "1em", ue = r((e) => {
|
|
165
|
-
let { disabled: t, snippet: n, description: r, handleInsert: i, sx: a, ...o } = e, s, c = n.metadata?.icon;
|
|
148
|
+
return {
|
|
149
|
+
path: t.path,
|
|
150
|
+
title: pe(t.title) ?? me(t.path, n),
|
|
151
|
+
summary: pe(t.summary),
|
|
152
|
+
icon: n,
|
|
153
|
+
content: i
|
|
154
|
+
};
|
|
155
|
+
}, J = /* @__PURE__ */ new Map(), ge = (e = q) => {
|
|
156
|
+
let t = J.get(e);
|
|
157
|
+
return t || (t = (async () => {
|
|
158
|
+
let t = (await U("templates", de, e)).find((e) => e.meta?.schema !== void 0);
|
|
159
|
+
if (!t) throw Error(`No script templates found at '${e}'.`);
|
|
160
|
+
return Math.floor(Number(t.meta?.schema)) === 1 ? (await Promise.all(t.entries.map((t) => he(e, t)))).filter((e) => e !== null) : (console.warn(`Script template catalog at '${e}' has schema ${t.meta?.schema}; expected 1.`), []);
|
|
161
|
+
})(), J.set(e, t), t.catch(() => {
|
|
162
|
+
J.delete(e);
|
|
163
|
+
})), t;
|
|
164
|
+
}, Y = { marginRight: "4px" }, X = "1em", _e = r((e) => {
|
|
165
|
+
let { disabled: t, snippet: n, description: r, handleInsert: i, sx: a, ...o } = e, s, c = n.icon;
|
|
166
166
|
return s = B(b, c === "formula" ? {
|
|
167
167
|
iconKey: "ScriptFormula",
|
|
168
168
|
size: X,
|
|
@@ -203,7 +203,7 @@ var J = r(n((e, t) => {
|
|
|
203
203
|
},
|
|
204
204
|
children: [B(m, {
|
|
205
205
|
component: "div",
|
|
206
|
-
children: n.
|
|
206
|
+
children: n.title
|
|
207
207
|
}), B(m, {
|
|
208
208
|
variant: "caption",
|
|
209
209
|
component: "div",
|
|
@@ -212,39 +212,51 @@ var J = r(n((e, t) => {
|
|
|
212
212
|
overflow: "hidden",
|
|
213
213
|
textOverflow: "ellipsis"
|
|
214
214
|
},
|
|
215
|
-
children: n.
|
|
215
|
+
children: n.summary
|
|
216
216
|
})]
|
|
217
217
|
})
|
|
218
218
|
});
|
|
219
|
-
}),
|
|
220
|
-
let { groupKey: r, disabled: o, scriptPath: s =
|
|
219
|
+
}), ve = r(n((e, n) => {
|
|
220
|
+
let { groupKey: r, disabled: o, scriptPath: s = q, ...c } = e, d = D(), [f, p] = l([]), [m, h] = l("loading"), [g, v] = l(0), [y] = T(["insertScript"]), b = o || (y?.disabled() ?? !1);
|
|
221
221
|
a(() => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
}, [s]);
|
|
231
|
-
let
|
|
232
|
-
if (m) return B("div", { children: d("insertScript.loading") });
|
|
222
|
+
let e = !1;
|
|
223
|
+
return h("loading"), ge(s).then((t) => {
|
|
224
|
+
e || (p(t), h("ready"));
|
|
225
|
+
}, () => {
|
|
226
|
+
e || (p([]), h("error"));
|
|
227
|
+
}), () => {
|
|
228
|
+
e = !0;
|
|
229
|
+
};
|
|
230
|
+
}, [s, g]);
|
|
231
|
+
let S = i((e) => {
|
|
232
|
+
if (m === "loading") return B("div", { children: d("insertScript.loading") });
|
|
233
233
|
let n = {
|
|
234
234
|
variant: _.Menuitem,
|
|
235
235
|
groupKey: "scriptsOptions",
|
|
236
|
-
disabled:
|
|
236
|
+
disabled: b
|
|
237
237
|
}, r = (t) => {
|
|
238
|
-
|
|
239
|
-
}, i = [];
|
|
238
|
+
y?.execute(t.content), e.closeFloat?.();
|
|
239
|
+
}, i = () => v((e) => e + 1), a = [];
|
|
240
|
+
m === "error" && a.push(B(M, {
|
|
241
|
+
onMouseDown: (e) => {
|
|
242
|
+
e.button === 0 && e.preventDefault();
|
|
243
|
+
},
|
|
244
|
+
onMouseUp: (e) => {
|
|
245
|
+
e.button === 0 && i();
|
|
246
|
+
},
|
|
247
|
+
onKeyDown: (e) => {
|
|
248
|
+
e.keyCode !== x.Enter && e.keyCode !== x.Space || i();
|
|
249
|
+
},
|
|
250
|
+
children: d("insertScript.loadFailedRetry")
|
|
251
|
+
}, "retry"));
|
|
240
252
|
for (let e = 0; e < f.length; e++) {
|
|
241
253
|
let t = f[e];
|
|
242
|
-
t &&
|
|
254
|
+
t && a.push(B(_e, {
|
|
243
255
|
handleInsert: r,
|
|
244
256
|
snippet: t
|
|
245
257
|
}, t.path));
|
|
246
258
|
}
|
|
247
|
-
let
|
|
259
|
+
let o = V(u, {
|
|
248
260
|
sx: {
|
|
249
261
|
display: "flex",
|
|
250
262
|
flexDirection: "column",
|
|
@@ -252,12 +264,12 @@ var J = r(n((e, t) => {
|
|
|
252
264
|
overflow: "hidden"
|
|
253
265
|
},
|
|
254
266
|
children: [
|
|
255
|
-
|
|
267
|
+
a.length > 0 ? V(z, { children: [B(u, {
|
|
256
268
|
sx: {
|
|
257
269
|
overflow: "auto",
|
|
258
270
|
flex: "1 1 100%"
|
|
259
271
|
},
|
|
260
|
-
children:
|
|
272
|
+
children: a
|
|
261
273
|
}), B(j, { orientation: "horizontal" })] }) : null,
|
|
262
274
|
t(O, {
|
|
263
275
|
...n,
|
|
@@ -273,84 +285,82 @@ var J = r(n((e, t) => {
|
|
|
273
285
|
});
|
|
274
286
|
return P({
|
|
275
287
|
...e,
|
|
276
|
-
children:
|
|
288
|
+
children: o
|
|
277
289
|
});
|
|
278
290
|
}, [
|
|
279
|
-
|
|
291
|
+
b,
|
|
280
292
|
r,
|
|
281
293
|
m,
|
|
282
|
-
|
|
294
|
+
f,
|
|
295
|
+
y,
|
|
283
296
|
d
|
|
284
297
|
]);
|
|
285
298
|
return B(k, {
|
|
286
299
|
ref: n,
|
|
287
|
-
disabled:
|
|
300
|
+
disabled: b,
|
|
288
301
|
groupKey: r,
|
|
289
|
-
label:
|
|
290
|
-
tooltip:
|
|
291
|
-
|
|
292
|
-
icon:
|
|
302
|
+
label: y?.getLabel(r) ?? d("insertScript.fallbackLabel"),
|
|
303
|
+
tooltip: y?.getDescription(),
|
|
304
|
+
renderPopupPanel: S,
|
|
305
|
+
icon: y?.getIcon() ?? "ScriptInsert",
|
|
293
306
|
...c
|
|
294
307
|
});
|
|
295
308
|
})), Z = r(n((e, t) => {
|
|
296
|
-
let { propsCommandButton: n, ...r } = e
|
|
309
|
+
let { propsCommandButton: n, ...r } = e, i = C((e) => {
|
|
310
|
+
let { propsCommandButton: t, propsCommandPopup: n } = e;
|
|
311
|
+
return B(z, { children: V("div", {
|
|
312
|
+
style: {
|
|
313
|
+
display: "flex",
|
|
314
|
+
flex: "1 1 100%"
|
|
315
|
+
},
|
|
316
|
+
children: [
|
|
317
|
+
B("div", { children: B(N, {
|
|
318
|
+
style: {},
|
|
319
|
+
children: B(O, {
|
|
320
|
+
...t,
|
|
321
|
+
commandKey: "saveScripts"
|
|
322
|
+
})
|
|
323
|
+
}) }),
|
|
324
|
+
B("div", { style: { flex: "1 1 100%" } }),
|
|
325
|
+
B("div", { children: B(N, {
|
|
326
|
+
style: {},
|
|
327
|
+
children: B(ve, { ...t })
|
|
328
|
+
}) })
|
|
329
|
+
]
|
|
330
|
+
}) });
|
|
331
|
+
}, []);
|
|
297
332
|
return B(A, {
|
|
298
333
|
ref: t,
|
|
299
334
|
propsCommandButton: n,
|
|
300
|
-
renderToolbarPalette:
|
|
301
|
-
let { propsCommandButton: t, propsCommandPopup: n } = e;
|
|
302
|
-
return B(z, { children: V("div", {
|
|
303
|
-
style: {
|
|
304
|
-
display: "flex",
|
|
305
|
-
flex: "1 1 100%"
|
|
306
|
-
},
|
|
307
|
-
children: [
|
|
308
|
-
B("div", { children: B(N, {
|
|
309
|
-
style: {},
|
|
310
|
-
children: B(O, {
|
|
311
|
-
...t,
|
|
312
|
-
commandKey: "saveScripts"
|
|
313
|
-
})
|
|
314
|
-
}) }),
|
|
315
|
-
B("div", { style: { flex: "1 1 100%" } }),
|
|
316
|
-
B("div", { children: B(N, {
|
|
317
|
-
style: {},
|
|
318
|
-
children: B(de, { ...t })
|
|
319
|
-
}) })
|
|
320
|
-
]
|
|
321
|
-
}) });
|
|
322
|
-
}, []),
|
|
335
|
+
renderToolbarPalette: i,
|
|
323
336
|
...r
|
|
324
337
|
});
|
|
325
338
|
}));
|
|
326
339
|
Z.displayName = "ScriptEditorToolbar", K();
|
|
327
|
-
var
|
|
328
|
-
let { scriptPath: n =
|
|
340
|
+
var ye = r(n((e, t) => {
|
|
341
|
+
let { scriptPath: n = q, onScriptSelect: r, disabled: i = !1, sx: o = S.EmptyCssProperties, className: s, buttonMinWidth: c = 210, buttonMinHeight: p = 80, gap: h = 12, ...g } = e, _ = D(), [v, y] = l([]), [x, C] = l(!0), [w, T] = l(null), [E, ee] = l(0);
|
|
329
342
|
if (a(() => {
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
})();
|
|
352
|
-
}, [n, _]), x) return B(u, {
|
|
353
|
-
className: W(s, "script-select"),
|
|
343
|
+
let e = !1, t = {
|
|
344
|
+
path: null,
|
|
345
|
+
title: _("templateSelect.blankTitle"),
|
|
346
|
+
summary: _("templateSelect.blankSummary"),
|
|
347
|
+
content: ""
|
|
348
|
+
};
|
|
349
|
+
return C(!0), T(null), ge(n).then((n) => {
|
|
350
|
+
e || y([t, ...n]);
|
|
351
|
+
}, (n) => {
|
|
352
|
+
e || (y([t]), T(n instanceof Error ? n.message : _("templateSelect.loadFailed")));
|
|
353
|
+
}).finally(() => {
|
|
354
|
+
e || C(!1);
|
|
355
|
+
}), () => {
|
|
356
|
+
e = !0;
|
|
357
|
+
};
|
|
358
|
+
}, [
|
|
359
|
+
n,
|
|
360
|
+
_,
|
|
361
|
+
E
|
|
362
|
+
]), x) return B(u, {
|
|
363
|
+
className: G(s, "script-select"),
|
|
354
364
|
...g,
|
|
355
365
|
sx: [{
|
|
356
366
|
display: "flex",
|
|
@@ -363,37 +373,45 @@ var fe = r(n((e, t) => {
|
|
|
363
373
|
}, ...Array.isArray(o) ? o : []],
|
|
364
374
|
children: B(f, {})
|
|
365
375
|
});
|
|
366
|
-
let
|
|
367
|
-
w && (
|
|
368
|
-
className:
|
|
369
|
-
|
|
370
|
-
sx: [{
|
|
376
|
+
let O = null;
|
|
377
|
+
w && (O = V(u, {
|
|
378
|
+
className: "error-results",
|
|
379
|
+
sx: {
|
|
371
380
|
display: "flex",
|
|
372
|
-
justifyContent: "center",
|
|
373
|
-
alignItems: "center",
|
|
374
|
-
background: (e) => e.palette.error.light,
|
|
375
|
-
flex: "0",
|
|
376
|
-
zIndex: 1e3,
|
|
377
381
|
flexDirection: "column",
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
382
|
+
alignItems: "center",
|
|
383
|
+
flex: "none",
|
|
384
|
+
gap: .5,
|
|
385
|
+
padding: 1.5,
|
|
386
|
+
background: (e) => H(e.palette.error.main, e.palette.mode === "dark" ? .16 : .06),
|
|
387
|
+
borderTop: (e) => `1px solid ${H(e.palette.error.main, .4)}`
|
|
388
|
+
},
|
|
389
|
+
children: [
|
|
390
|
+
B(m, {
|
|
391
|
+
color: "error",
|
|
392
|
+
variant: "subtitle1",
|
|
393
|
+
component: "div",
|
|
394
|
+
children: _("templateSelect.errorTitle")
|
|
395
|
+
}),
|
|
396
|
+
B(m, {
|
|
397
|
+
variant: "body2",
|
|
398
|
+
component: "div",
|
|
399
|
+
sx: {
|
|
400
|
+
color: "text.secondary",
|
|
401
|
+
textAlign: "center"
|
|
402
|
+
},
|
|
403
|
+
children: w
|
|
404
|
+
}),
|
|
405
|
+
B(d, {
|
|
406
|
+
size: "small",
|
|
407
|
+
color: "error",
|
|
408
|
+
onClick: () => ee((e) => e + 1),
|
|
409
|
+
children: _("templateSelect.retry")
|
|
410
|
+
})
|
|
411
|
+
]
|
|
394
412
|
}));
|
|
395
|
-
let
|
|
396
|
-
let t = e.
|
|
413
|
+
let k = (e) => {
|
|
414
|
+
let t = e.icon;
|
|
397
415
|
return t === "macro" ? B(b, {
|
|
398
416
|
iconKey: "ScriptMacro",
|
|
399
417
|
size: "1em"
|
|
@@ -407,7 +425,7 @@ var fe = r(n((e, t) => {
|
|
|
407
425
|
};
|
|
408
426
|
return V(u, {
|
|
409
427
|
ref: t,
|
|
410
|
-
className:
|
|
428
|
+
className: G(s, "script-select"),
|
|
411
429
|
sx: {
|
|
412
430
|
background: (e) => e.palette.background.paper,
|
|
413
431
|
zIndex: 1e3,
|
|
@@ -483,9 +501,9 @@ var fe = r(n((e, t) => {
|
|
|
483
501
|
children: [B(m, {
|
|
484
502
|
variant: "subtitle2",
|
|
485
503
|
component: "div",
|
|
486
|
-
children: e.
|
|
487
|
-
}),
|
|
488
|
-
}), e.
|
|
504
|
+
children: e.title || _("templateSelect.untitled")
|
|
505
|
+
}), k(e)]
|
|
506
|
+
}), e.summary && B(m, {
|
|
489
507
|
variant: "body2",
|
|
490
508
|
component: "div",
|
|
491
509
|
sx: {
|
|
@@ -496,15 +514,15 @@ var fe = r(n((e, t) => {
|
|
|
496
514
|
textOverflow: "ellipsis",
|
|
497
515
|
alignItems: "flex-start"
|
|
498
516
|
},
|
|
499
|
-
children: e.
|
|
517
|
+
children: e.summary
|
|
500
518
|
})]
|
|
501
519
|
}, `${e.path}-${t}`))
|
|
502
520
|
})
|
|
503
521
|
]
|
|
504
|
-
}),
|
|
522
|
+
}), O]
|
|
505
523
|
});
|
|
506
524
|
}));
|
|
507
|
-
|
|
525
|
+
ye.displayName = "TemplateSelectPanel";
|
|
508
526
|
var Q = r(n((e, t) => {
|
|
509
527
|
let { className: n, sx: r, propsScriptEditor: s, readOnly: d = !1, frame: f, autoFocusSel: g, autoFocus: _ = !0, scripts: v, ...y } = e, b = h(), [x, S] = l(!1), w = c(!1), [T, D] = l({
|
|
510
528
|
message: "Loading",
|
|
@@ -561,7 +579,7 @@ var Q = r(n((e, t) => {
|
|
|
561
579
|
},
|
|
562
580
|
children: B(Z, {})
|
|
563
581
|
}), [b]), R = o(() => B(u, {
|
|
564
|
-
className:
|
|
582
|
+
className: G("script-status-panel", "status-panel"),
|
|
565
583
|
sx: {
|
|
566
584
|
display: "flex",
|
|
567
585
|
alignItems: "stretch",
|
|
@@ -630,7 +648,7 @@ var Q = r(n((e, t) => {
|
|
|
630
648
|
]
|
|
631
649
|
})
|
|
632
650
|
}), [T]), z = o(() => V(u, {
|
|
633
|
-
className:
|
|
651
|
+
className: G("script-editor-content"),
|
|
634
652
|
sx: {
|
|
635
653
|
display: "flex",
|
|
636
654
|
flex: "1 1 100%",
|
|
@@ -649,7 +667,7 @@ var Q = r(n((e, t) => {
|
|
|
649
667
|
position: "relative",
|
|
650
668
|
boxSizing: "border-box"
|
|
651
669
|
},
|
|
652
|
-
children: B(
|
|
670
|
+
children: B(re, {
|
|
653
671
|
ref: j,
|
|
654
672
|
loadingPanel: I,
|
|
655
673
|
readOnly: d,
|
|
@@ -677,7 +695,7 @@ var Q = r(n((e, t) => {
|
|
|
677
695
|
A
|
|
678
696
|
]), H = o(() => {
|
|
679
697
|
let e;
|
|
680
|
-
return O === null ? I : (O.source === null && (e = B(
|
|
698
|
+
return O === null ? I : (O.source === null && (e = B(ye, {
|
|
681
699
|
sx: {
|
|
682
700
|
display: "flex",
|
|
683
701
|
flex: "1 1 100%",
|
|
@@ -694,7 +712,7 @@ var Q = r(n((e, t) => {
|
|
|
694
712
|
}
|
|
695
713
|
})), B(u, {
|
|
696
714
|
tabIndex: 0,
|
|
697
|
-
className:
|
|
715
|
+
className: G("script-workspace", n),
|
|
698
716
|
sx: {
|
|
699
717
|
display: "flex",
|
|
700
718
|
flex: "1 1 100%",
|
|
@@ -759,20 +777,20 @@ var Q = r(n((e, t) => {
|
|
|
759
777
|
});
|
|
760
778
|
}));
|
|
761
779
|
Q.displayName = "ScriptWorkspace";
|
|
762
|
-
var { FocusActivation:
|
|
763
|
-
let t =
|
|
764
|
-
return t ? B(
|
|
765
|
-
spec:
|
|
780
|
+
var { FocusActivation: be, CommandScopeProvider: xe, CommandAnchorProvider: Se, useCommandScope: Ce } = g, we = { scopeName: "scriptEditor" }, Te = ({ children: e }) => {
|
|
781
|
+
let t = Ce(), n = c(null);
|
|
782
|
+
return t ? B(xe, {
|
|
783
|
+
spec: we,
|
|
766
784
|
elementRef: n,
|
|
767
785
|
region: !0,
|
|
768
|
-
children: B(
|
|
786
|
+
children: B(Ee, {
|
|
769
787
|
paneRef: n,
|
|
770
788
|
children: e
|
|
771
789
|
})
|
|
772
790
|
}) : e;
|
|
773
|
-
},
|
|
774
|
-
let n =
|
|
775
|
-
return r ? V(
|
|
791
|
+
}, Ee = ({ paneRef: e, children: t }) => {
|
|
792
|
+
let n = Ce(), r = o(() => n ? new be(n.getRoot(), n) : null, [n]);
|
|
793
|
+
return r ? V(Se, {
|
|
776
794
|
tracker: r,
|
|
777
795
|
keyBindings: !1,
|
|
778
796
|
debounce: 100,
|
|
@@ -784,11 +802,13 @@ var { FocusActivation: pe, CommandScopeProvider: me, CommandAnchorProvider: he,
|
|
|
784
802
|
children: t
|
|
785
803
|
})]
|
|
786
804
|
}) : t;
|
|
787
|
-
},
|
|
805
|
+
}, De = (e) => {
|
|
788
806
|
let { model: t, entryKey: n, frame: r, ref: i, ...a } = e, o = R() ?? t;
|
|
789
|
-
|
|
807
|
+
L(o, ["onProtectionChange"]);
|
|
808
|
+
let s = o?.getScripts().isReadOnly() ?? !1;
|
|
809
|
+
return B(Te, { children: B(Q, {
|
|
790
810
|
ref: i,
|
|
791
|
-
readOnly:
|
|
811
|
+
readOnly: s,
|
|
792
812
|
frame: r,
|
|
793
813
|
scripts: o?.getScripts(),
|
|
794
814
|
...a
|
|
@@ -815,10 +835,10 @@ var { FocusActivation: pe, CommandScopeProvider: me, CommandAnchorProvider: he,
|
|
|
815
835
|
c,
|
|
816
836
|
o,
|
|
817
837
|
r
|
|
818
|
-
]), u ? V(z, { children: [B(j, {}), B(
|
|
838
|
+
]), u ? V(z, { children: [B(j, {}), B(le, { ...n })] }) : null;
|
|
819
839
|
});
|
|
820
840
|
$.displayName = "RunScriptContribution", K();
|
|
821
|
-
var
|
|
841
|
+
var Oe = r(n((e, n) => {
|
|
822
842
|
let { ...r } = e, i = R(), o = D(), [s, c] = l([]);
|
|
823
843
|
a(() => {
|
|
824
844
|
let e = i?.getScripts();
|
|
@@ -875,36 +895,34 @@ var xe = r(n((e, n) => {
|
|
|
875
895
|
children: m
|
|
876
896
|
});
|
|
877
897
|
}));
|
|
878
|
-
|
|
879
|
-
var
|
|
880
|
-
let { disabled: n, groupKey: r, ...a } = e, o = w("customFunctionOptions")
|
|
898
|
+
Oe.displayName = "InsertFunctionPopupPanel";
|
|
899
|
+
var ke = r(n((e, t) => {
|
|
900
|
+
let { disabled: n, groupKey: r, ...a } = e, o = w("customFunctionOptions"), s = i((e) => {
|
|
901
|
+
let t = B(Oe, {
|
|
902
|
+
disabled: n,
|
|
903
|
+
groupKey: r,
|
|
904
|
+
...e
|
|
905
|
+
});
|
|
906
|
+
return P({
|
|
907
|
+
...e,
|
|
908
|
+
children: t
|
|
909
|
+
});
|
|
910
|
+
}, [n, r]);
|
|
881
911
|
return B(k, {
|
|
882
912
|
ref: t,
|
|
883
913
|
disabled: n,
|
|
884
|
-
|
|
885
|
-
let t = B(xe, {
|
|
886
|
-
disabled: n,
|
|
887
|
-
groupKey: r,
|
|
888
|
-
...e
|
|
889
|
-
});
|
|
890
|
-
return P({
|
|
891
|
-
...e,
|
|
892
|
-
children: t
|
|
893
|
-
});
|
|
894
|
-
}, [n, r]),
|
|
914
|
+
renderPopupPanel: s,
|
|
895
915
|
label: o?.getLabel?.(),
|
|
896
916
|
tooltip: o?.getDescription?.(),
|
|
897
917
|
icon: "FormulaCustom",
|
|
898
918
|
...a
|
|
899
919
|
});
|
|
900
920
|
}));
|
|
901
|
-
|
|
902
|
-
var
|
|
903
|
-
|
|
921
|
+
ke.displayName = "InsertFunctionContribution";
|
|
922
|
+
var Ae = () => {
|
|
923
|
+
ie(), y.register("plugin-scripts", { icons: {} }), F.registerTaskPane({
|
|
904
924
|
key: "scriptEditor",
|
|
905
|
-
|
|
906
|
-
getIcon: () => "ScriptRun",
|
|
907
|
-
component: be,
|
|
925
|
+
component: De,
|
|
908
926
|
keepMounted: !0
|
|
909
927
|
}, !0), v.register({ key: "scriptsOptions" }, !0), v.register({ key: "customFunctionOptions" }, !0), v.register({
|
|
910
928
|
key: "scripting.runScript.home",
|
|
@@ -924,7 +942,7 @@ var Ce = () => {
|
|
|
924
942
|
anchor: "formulaCategory.web",
|
|
925
943
|
order: 1
|
|
926
944
|
} },
|
|
927
|
-
render: (t) => e.createElement(
|
|
945
|
+
render: (t) => e.createElement(ke, { ...t })
|
|
928
946
|
}, !0);
|
|
929
947
|
};
|
|
930
|
-
export {
|
|
948
|
+
export { ve as InsertScriptCommandButton, le as RunScriptCommandButton, Z as ScriptEditorToolbar, De as ScriptTaskPane, Q as ScriptWorkspace, Ae as ScriptingPlugin };
|