@sheetxl/scripting-mui 0.8.0-beta.2 → 0.8.0-beta.21
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/node/esm/index.mjs
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
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.21
|
|
3
3
|
*
|
|
4
4
|
* (C) 2026-present SheetXL Inc. & Michael T. Ford
|
|
5
|
-
* License:
|
|
5
|
+
* License: MIT
|
|
6
6
|
*/
|
|
7
|
-
import e, { createElement as t, forwardRef as r, memo as n, useCallback as i, useEffect as o, useMemo as
|
|
7
|
+
import e, { createElement as t, forwardRef as r, memo as n, useCallback as i, useEffect as o, useMemo as l, useReducer as a, useRef as s, useState as c } from "react";
|
|
8
8
|
import d from "clsx";
|
|
9
|
-
import { Box as p, Button as
|
|
10
|
-
import { Command as
|
|
11
|
-
import { AnimatedLoadingPanel as
|
|
12
|
-
import { DefaultTaskPaneRegistry as
|
|
13
|
-
import { Fragment as
|
|
14
|
-
import { alpha as
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
|
|
9
|
+
import { Box as p, Button as u, CircularProgress as m, Paper as f, Typography as h, 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 K, useImperativeElement as N, useTranslator as D } from "@sheetxl/utils-react";
|
|
11
|
+
import { AnimatedLoadingPanel as T, CommandButton as $, CommandPopupButton as P, CommandToolbar as I, ExhibitDivider as E, ExhibitMenuItem as L, OverflowPalette as R, defaultRenderPopupPanel as M } from "@sheetxl/utils-mui";
|
|
12
|
+
import { DefaultTaskPaneRegistry as z, InputClipboardInjector as O, useModelSync as B, useWorkbook as A } from "@sheetxl/react";
|
|
13
|
+
import { Fragment as U, jsx as W, jsxs as H } from "react/jsx-runtime";
|
|
14
|
+
import { alpha as j } from "@mui/system";
|
|
15
|
+
import { listResources as q, releaseChannel as G } from "@sheetxl/utils";
|
|
16
|
+
import { VERSION as Z } from "@sheetxl/sdk";
|
|
17
|
+
import { ScriptEditor as _, ScriptingReactPlugin as J } from "@sheetxl/scripting-react";
|
|
18
|
+
var Q = {
|
|
18
19
|
"insertFunction.fallbackLabel": "Function",
|
|
19
20
|
"insertFunction.insertNamed": "Insert {name}",
|
|
20
21
|
"insertScript.fallbackLabel": "Insert Script",
|
|
22
|
+
"insertScript.loadFailedRetry": "Couldn’t load templates. Retry",
|
|
21
23
|
"insertScript.loading": "Loading...",
|
|
22
24
|
"runScript.executeNamed": "Execute {name}",
|
|
23
25
|
"runScript.fallbackLabel": "Macro",
|
|
@@ -27,41 +29,42 @@ var Z = {
|
|
|
27
29
|
"templateSelect.intro": "Choose from a template to provide a starting point to automate tasks or create user defined functions.",
|
|
28
30
|
"templateSelect.intro2": "Templates provide a foundation to customize and meet your specific needs.",
|
|
29
31
|
"templateSelect.loadFailed": "Failed to load scripts",
|
|
32
|
+
"templateSelect.retry": "Retry",
|
|
30
33
|
"templateSelect.title": "Script Template",
|
|
31
34
|
"templateSelect.untitled": "Untitled"
|
|
32
|
-
}, { DefaultCommandCatalogService:
|
|
33
|
-
function
|
|
34
|
-
|
|
35
|
+
}, { DefaultCommandCatalogService: V } = g, X = !1;
|
|
36
|
+
function Y() {
|
|
37
|
+
X || (X = !0, V.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: Q }));
|
|
35
38
|
}
|
|
36
|
-
|
|
37
|
-
var
|
|
38
|
-
const { groupKey: n, ...i } = e,
|
|
39
|
+
Y();
|
|
40
|
+
var ee = n(r((e, r) => {
|
|
41
|
+
const { groupKey: n, ...i } = e, l = A(), a = D(), [s, d] = c([]), [u, m] = c(!1);
|
|
39
42
|
o(() => {
|
|
40
|
-
const e =
|
|
43
|
+
const e = l?.getScripts();
|
|
41
44
|
if (!e) return;
|
|
42
45
|
(async () => {
|
|
43
|
-
|
|
46
|
+
m(!0);
|
|
44
47
|
const t = await e.searchFunctions({ type: "macro" });
|
|
45
|
-
d(t),
|
|
48
|
+
d(t), m(!1);
|
|
46
49
|
})();
|
|
47
|
-
}, [
|
|
48
|
-
const
|
|
50
|
+
}, [l]);
|
|
51
|
+
const f = {
|
|
49
52
|
variant: y.Menuitem,
|
|
50
53
|
groupKey: "scriptsOptions",
|
|
51
54
|
shortcut: void 0
|
|
52
|
-
},
|
|
53
|
-
for (let e = 0; e <
|
|
55
|
+
}, h = [], x = s ? s.length : 0;
|
|
56
|
+
for (let e = 0; e < x; e++) {
|
|
54
57
|
const t = s[e];
|
|
55
|
-
|
|
56
|
-
...
|
|
58
|
+
h.push(W($, {
|
|
59
|
+
...f,
|
|
57
60
|
commandKey: "executeScript",
|
|
58
61
|
commandState: { declaration: t },
|
|
59
|
-
propsTooltip: { description:
|
|
60
|
-
icon:
|
|
61
|
-
label: t.getName() ??
|
|
62
|
+
propsTooltip: { description: a("runScript.executeNamed", { name: t.getName() ?? a("runScript.fallbackLabel") }) },
|
|
63
|
+
icon: W(v, { iconKey: "ScriptMacro" }),
|
|
64
|
+
label: t.getName() ?? a("runScript.fallbackLabel")
|
|
62
65
|
}, `macro-${t.getName()}-${e}`));
|
|
63
66
|
}
|
|
64
|
-
const
|
|
67
|
+
const g = H(p, {
|
|
65
68
|
ref: r,
|
|
66
69
|
sx: {
|
|
67
70
|
display: "flex",
|
|
@@ -69,105 +72,100 @@ var X = n(r((e, r) => {
|
|
|
69
72
|
flex: "1 1 100%",
|
|
70
73
|
overflow: "hidden"
|
|
71
74
|
},
|
|
72
|
-
children: [
|
|
75
|
+
children: [h.length > 0 ? H(U, { children: [W(p, {
|
|
73
76
|
sx: {
|
|
74
77
|
overflow: "auto",
|
|
75
78
|
flex: "1 1 100%"
|
|
76
79
|
},
|
|
77
|
-
children:
|
|
78
|
-
}),
|
|
79
|
-
...
|
|
80
|
+
children: h
|
|
81
|
+
}), W(E, { orientation: "horizontal" })] }) : null, t($, {
|
|
82
|
+
...f,
|
|
80
83
|
key: "show-editor",
|
|
81
84
|
commandKey: "showScriptEditor"
|
|
82
85
|
})]
|
|
83
86
|
});
|
|
84
|
-
return
|
|
87
|
+
return M({
|
|
85
88
|
...i,
|
|
86
|
-
children:
|
|
89
|
+
children: g
|
|
87
90
|
});
|
|
88
91
|
}));
|
|
89
|
-
|
|
90
|
-
var
|
|
91
|
-
const { groupKey: r, disabled: n, ...o } = e,
|
|
92
|
-
|
|
92
|
+
ee.displayName = "RunScriptPopupPanel";
|
|
93
|
+
var te = n(r((e, t) => {
|
|
94
|
+
const { groupKey: r, disabled: n, ...o } = e, l = K(["showScriptEditor"])[0], a = F("scriptsOptions"), s = i((e) => {
|
|
95
|
+
const t = W(ee, {
|
|
96
|
+
disabled: n,
|
|
97
|
+
groupKey: r,
|
|
98
|
+
...e
|
|
99
|
+
});
|
|
100
|
+
return M({
|
|
101
|
+
...e,
|
|
102
|
+
children: t
|
|
103
|
+
});
|
|
104
|
+
}, [n, r]);
|
|
105
|
+
return W(P, {
|
|
93
106
|
ref: t,
|
|
94
107
|
disabled: n,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
...e
|
|
100
|
-
});
|
|
101
|
-
return z({
|
|
102
|
-
...e,
|
|
103
|
-
children: t
|
|
104
|
-
});
|
|
105
|
-
}, [n, r]),
|
|
106
|
-
selected: a?.getState(),
|
|
107
|
-
label: l?.getLabel?.(),
|
|
108
|
-
tooltip: l?.getDescription?.(),
|
|
108
|
+
renderPopupPanel: s,
|
|
109
|
+
selected: l?.getState(),
|
|
110
|
+
label: a?.getLabel?.(),
|
|
111
|
+
tooltip: a?.getDescription?.(),
|
|
109
112
|
quickCommand: "showScriptEditor",
|
|
110
113
|
...o
|
|
111
114
|
});
|
|
112
|
-
})),
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
return r.
|
|
119
|
-
},
|
|
120
|
-
if (
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
if (!r.ok) throw new q(`Failed to retrieve directory at '${e}': ${r.statusText}`);
|
|
126
|
-
const n = await r.text();
|
|
127
|
-
if (n.trim().toLowerCase().startsWith("<!doctype html") || n.trim().toLowerCase().startsWith("<html")) throw new q(`Failed to retrieve directory at '${e}'`);
|
|
115
|
+
})), re = G(Z), ne = `https://unpkg.com/@sheetxl/templates-scripting${re ? `@${re}` : ""}/dist`, ie = "templates-scripting", oe = [
|
|
116
|
+
"formula",
|
|
117
|
+
"macro",
|
|
118
|
+
"autostart"
|
|
119
|
+
], le = (e) => "string" == typeof e && e ? e : void 0, ae = (e, t) => {
|
|
120
|
+
const r = (e.split("/").pop() ?? "").replace(/\.[^/.]+$/, "");
|
|
121
|
+
return "formula" === t ? r.toUpperCase() : r.replace(/([a-z])([A-Z])/g, "$1 $2").replace(/[-_]+/g, " ").trim().replace(/\b\w/g, (e) => e.toUpperCase());
|
|
122
|
+
}, se = async (e, t) => {
|
|
123
|
+
if (!/\.ts$/i.test(t.path)) return null;
|
|
124
|
+
const r = oe.includes(t.icon) ? t.icon : void 0, n = ((e, t) => {
|
|
125
|
+
const r = `${e}${e.endsWith("/") ? "" : "/"}${ie}/${t}`;
|
|
126
|
+
return "undefined" == typeof document ? r : new URL(r, document.baseURI).href;
|
|
127
|
+
})(e, t.path);
|
|
128
128
|
let i;
|
|
129
129
|
try {
|
|
130
|
-
|
|
130
|
+
const e = await fetch(n);
|
|
131
|
+
if (!e.ok || (e.headers.get("content-type") ?? "").includes("text/html")) throw new Error(e.ok ? "not found" : e.statusText || String(e.status));
|
|
132
|
+
i = await e.text();
|
|
131
133
|
} catch (e) {
|
|
132
|
-
|
|
134
|
+
return console.warn(`Script template '${n}' did not load: ${e?.message ?? e}`), null;
|
|
133
135
|
}
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const { disabled: t, snippet: r, description: n, handleInsert: i, sx: o, ...a } = e;
|
|
156
|
-
let l;
|
|
157
|
-
const s = r.metadata?.icon;
|
|
158
|
-
return l = j(v, "formula" === s ? {
|
|
136
|
+
return {
|
|
137
|
+
path: t.path,
|
|
138
|
+
title: le(t.title) ?? ae(t.path, r),
|
|
139
|
+
summary: le(t.summary),
|
|
140
|
+
icon: r,
|
|
141
|
+
content: i
|
|
142
|
+
};
|
|
143
|
+
}, ce = /* @__PURE__ */ new Map(), de = (e = ne) => {
|
|
144
|
+
let t = ce.get(e);
|
|
145
|
+
return t || (t = (async () => {
|
|
146
|
+
const t = (await q("templates", ie, e)).find((e) => void 0 !== e.meta?.schema);
|
|
147
|
+
if (!t) throw new Error(`No script templates found at '${e}'.`);
|
|
148
|
+
return 1 !== Math.floor(Number(t.meta?.schema)) ? (console.warn(`Script template catalog at '${e}' has schema ${t.meta?.schema}; expected 1.`), []) : (await Promise.all(t.entries.map((t) => se(e, t)))).filter((e) => null !== e);
|
|
149
|
+
})(), ce.set(e, t), t.catch(() => {
|
|
150
|
+
ce.delete(e);
|
|
151
|
+
})), t;
|
|
152
|
+
}, pe = { marginRight: "4px" }, ue = "1em", me = n((e) => {
|
|
153
|
+
const { disabled: t, snippet: r, description: n, handleInsert: i, sx: o, ...l } = e;
|
|
154
|
+
let a;
|
|
155
|
+
const s = r.icon;
|
|
156
|
+
return a = W(v, "formula" === s ? {
|
|
159
157
|
iconKey: "ScriptFormula",
|
|
160
|
-
size:
|
|
161
|
-
style:
|
|
158
|
+
size: ue,
|
|
159
|
+
style: pe
|
|
162
160
|
} : "macro" === s ? {
|
|
163
161
|
iconKey: "ScriptMacro",
|
|
164
|
-
size:
|
|
165
|
-
style:
|
|
162
|
+
size: ue,
|
|
163
|
+
style: pe
|
|
166
164
|
} : {
|
|
167
165
|
iconKey: "ScriptAutoRun",
|
|
168
|
-
size:
|
|
169
|
-
style:
|
|
170
|
-
}),
|
|
166
|
+
size: ue,
|
|
167
|
+
style: pe
|
|
168
|
+
}), W(L, {
|
|
171
169
|
sx: {
|
|
172
170
|
maxWidth: "460px",
|
|
173
171
|
display: "flex",
|
|
@@ -175,7 +173,7 @@ var Y = n(r((e, t) => {
|
|
|
175
173
|
...o
|
|
176
174
|
},
|
|
177
175
|
disabled: t,
|
|
178
|
-
icon:
|
|
176
|
+
icon: a,
|
|
179
177
|
onMouseDown: (e) => {
|
|
180
178
|
0 === e.button && e.preventDefault();
|
|
181
179
|
},
|
|
@@ -185,7 +183,7 @@ var Y = n(r((e, t) => {
|
|
|
185
183
|
onKeyDown: (e) => {
|
|
186
184
|
e.keyCode !== w.Enter && e.keyCode !== w.Space || i(r);
|
|
187
185
|
},
|
|
188
|
-
...
|
|
186
|
+
...l,
|
|
189
187
|
children: H(p, {
|
|
190
188
|
sx: {
|
|
191
189
|
display: "flex",
|
|
@@ -193,50 +191,62 @@ var Y = n(r((e, t) => {
|
|
|
193
191
|
flexDirection: "column",
|
|
194
192
|
overflow: "hidden"
|
|
195
193
|
},
|
|
196
|
-
children: [
|
|
194
|
+
children: [W(h, {
|
|
197
195
|
component: "div",
|
|
198
|
-
children: r.
|
|
199
|
-
}),
|
|
196
|
+
children: r.title
|
|
197
|
+
}), W(h, {
|
|
200
198
|
variant: "caption",
|
|
201
199
|
component: "div",
|
|
202
200
|
sx: {
|
|
203
|
-
color: (e) =>
|
|
201
|
+
color: (e) => j(e.palette.text.secondary ?? e.palette.text.primary, .6),
|
|
204
202
|
overflow: "hidden",
|
|
205
203
|
textOverflow: "ellipsis"
|
|
206
204
|
},
|
|
207
|
-
children: r.
|
|
205
|
+
children: r.summary
|
|
208
206
|
})]
|
|
209
207
|
})
|
|
210
208
|
});
|
|
211
|
-
}),
|
|
212
|
-
const { groupKey: n, disabled:
|
|
209
|
+
}), fe = n(r((e, r) => {
|
|
210
|
+
const { groupKey: n, disabled: l, scriptPath: a = ne, ...s } = e, d = D(), [u, m] = c([]), [f, h] = c("loading"), [x, g] = c(0), [S] = K(["insertScript"]), b = l || (S?.disabled() ?? !1);
|
|
213
211
|
o(() => {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
}, [
|
|
223
|
-
const
|
|
224
|
-
if (
|
|
212
|
+
let e = !1;
|
|
213
|
+
return h("loading"), de(a).then((t) => {
|
|
214
|
+
e || (m(t), h("ready"));
|
|
215
|
+
}, () => {
|
|
216
|
+
e || (m([]), h("error"));
|
|
217
|
+
}), () => {
|
|
218
|
+
e = !0;
|
|
219
|
+
};
|
|
220
|
+
}, [a, x]);
|
|
221
|
+
const v = i((e) => {
|
|
222
|
+
if ("loading" === f) return W("div", { children: d("insertScript.loading") });
|
|
225
223
|
const r = {
|
|
226
224
|
variant: y.Menuitem,
|
|
227
225
|
groupKey: "scriptsOptions",
|
|
228
|
-
disabled:
|
|
226
|
+
disabled: b
|
|
229
227
|
}, n = (t) => {
|
|
230
|
-
|
|
231
|
-
}, i = [];
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
228
|
+
S?.execute(t.content), e.closeFloat?.();
|
|
229
|
+
}, i = () => g((e) => e + 1), o = [];
|
|
230
|
+
"error" === f && o.push(W(L, {
|
|
231
|
+
onMouseDown: (e) => {
|
|
232
|
+
0 === e.button && e.preventDefault();
|
|
233
|
+
},
|
|
234
|
+
onMouseUp: (e) => {
|
|
235
|
+
0 === e.button && i();
|
|
236
|
+
},
|
|
237
|
+
onKeyDown: (e) => {
|
|
238
|
+
e.keyCode !== w.Enter && e.keyCode !== w.Space || i();
|
|
239
|
+
},
|
|
240
|
+
children: d("insertScript.loadFailedRetry")
|
|
241
|
+
}, "retry"));
|
|
242
|
+
for (let e = 0; e < u.length; e++) {
|
|
243
|
+
const t = u[e];
|
|
244
|
+
t && o.push(W(me, {
|
|
235
245
|
handleInsert: n,
|
|
236
246
|
snippet: t
|
|
237
247
|
}, t.path));
|
|
238
248
|
}
|
|
239
|
-
const
|
|
249
|
+
const l = H(p, {
|
|
240
250
|
sx: {
|
|
241
251
|
display: "flex",
|
|
242
252
|
flexDirection: "column",
|
|
@@ -244,106 +254,105 @@ var Y = n(r((e, t) => {
|
|
|
244
254
|
overflow: "hidden"
|
|
245
255
|
},
|
|
246
256
|
children: [
|
|
247
|
-
|
|
257
|
+
o.length > 0 ? H(U, { children: [W(p, {
|
|
248
258
|
sx: {
|
|
249
259
|
overflow: "auto",
|
|
250
260
|
flex: "1 1 100%"
|
|
251
261
|
},
|
|
252
|
-
children:
|
|
253
|
-
}),
|
|
254
|
-
t(
|
|
262
|
+
children: o
|
|
263
|
+
}), W(E, { orientation: "horizontal" })] }) : null,
|
|
264
|
+
t($, {
|
|
255
265
|
...r,
|
|
256
266
|
key: "showKeyboardShortcuts",
|
|
257
267
|
commandKey: "showKeyboardShortcuts"
|
|
258
268
|
}),
|
|
259
|
-
t(
|
|
269
|
+
t($, {
|
|
260
270
|
...r,
|
|
261
271
|
key: "scriptingHelp",
|
|
262
272
|
commandKey: "scriptingHelp"
|
|
263
273
|
})
|
|
264
274
|
]
|
|
265
275
|
});
|
|
266
|
-
return
|
|
276
|
+
return M({
|
|
267
277
|
...e,
|
|
268
|
-
children:
|
|
278
|
+
children: l
|
|
269
279
|
});
|
|
270
280
|
}, [
|
|
271
|
-
|
|
281
|
+
b,
|
|
272
282
|
n,
|
|
273
|
-
|
|
274
|
-
|
|
283
|
+
f,
|
|
284
|
+
u,
|
|
285
|
+
S,
|
|
275
286
|
d
|
|
276
287
|
]);
|
|
277
|
-
return
|
|
288
|
+
return W(P, {
|
|
278
289
|
ref: r,
|
|
279
|
-
disabled:
|
|
290
|
+
disabled: b,
|
|
280
291
|
groupKey: n,
|
|
281
|
-
label:
|
|
282
|
-
tooltip:
|
|
283
|
-
|
|
284
|
-
icon:
|
|
292
|
+
label: S?.getLabel(n) ?? d("insertScript.fallbackLabel"),
|
|
293
|
+
tooltip: S?.getDescription(),
|
|
294
|
+
renderPopupPanel: v,
|
|
295
|
+
icon: S?.getIcon() ?? "ScriptInsert",
|
|
285
296
|
...s
|
|
286
297
|
});
|
|
287
|
-
})),
|
|
288
|
-
const { propsCommandButton: r, ...n } = e
|
|
289
|
-
|
|
298
|
+
})), he = n(r((e, t) => {
|
|
299
|
+
const { propsCommandButton: r, ...n } = e, i = C((e) => {
|
|
300
|
+
const { propsCommandButton: t, propsCommandPopup: r } = e;
|
|
301
|
+
return W(U, { children: H("div", {
|
|
302
|
+
style: {
|
|
303
|
+
display: "flex",
|
|
304
|
+
flex: "1 1 100%"
|
|
305
|
+
},
|
|
306
|
+
children: [
|
|
307
|
+
W("div", { children: W(R, {
|
|
308
|
+
style: {},
|
|
309
|
+
children: W($, {
|
|
310
|
+
...t,
|
|
311
|
+
commandKey: "saveScripts"
|
|
312
|
+
})
|
|
313
|
+
}) }),
|
|
314
|
+
W("div", { style: { flex: "1 1 100%" } }),
|
|
315
|
+
W("div", { children: W(R, {
|
|
316
|
+
style: {},
|
|
317
|
+
children: W(fe, { ...t })
|
|
318
|
+
}) })
|
|
319
|
+
]
|
|
320
|
+
}) });
|
|
321
|
+
}, []);
|
|
322
|
+
return W(I, {
|
|
290
323
|
ref: t,
|
|
291
324
|
propsCommandButton: r,
|
|
292
|
-
renderToolbarPalette:
|
|
293
|
-
const { propsCommandButton: t, propsCommandPopup: r } = e;
|
|
294
|
-
return j(W, { children: H("div", {
|
|
295
|
-
style: {
|
|
296
|
-
display: "flex",
|
|
297
|
-
flex: "1 1 100%"
|
|
298
|
-
},
|
|
299
|
-
children: [
|
|
300
|
-
j("div", { children: j(R, {
|
|
301
|
-
style: {},
|
|
302
|
-
children: j(I, {
|
|
303
|
-
...t,
|
|
304
|
-
commandKey: "saveScripts"
|
|
305
|
-
})
|
|
306
|
-
}) }),
|
|
307
|
-
j("div", { style: { flex: "1 1 100%" } }),
|
|
308
|
-
j("div", { children: j(R, {
|
|
309
|
-
style: {},
|
|
310
|
-
children: j(le, { ...t })
|
|
311
|
-
}) })
|
|
312
|
-
]
|
|
313
|
-
}) });
|
|
314
|
-
}, []),
|
|
325
|
+
renderToolbarPalette: i,
|
|
315
326
|
...n
|
|
316
327
|
});
|
|
317
328
|
}));
|
|
318
|
-
|
|
319
|
-
var
|
|
320
|
-
const { scriptPath: r =
|
|
329
|
+
he.displayName = "ScriptEditorToolbar", Y();
|
|
330
|
+
var xe = n(r((e, t) => {
|
|
331
|
+
const { scriptPath: r = ne, onScriptSelect: n, disabled: i = !1, sx: l = k.EmptyCssProperties, className: a, buttonMinWidth: s = 210, buttonMinHeight: f = 80, gap: x = 12, ...g } = e, y = D(), [S, b] = c([]), [w, C] = c(!0), [F, K] = c(null), [N, T] = c(0);
|
|
321
332
|
if (o(() => {
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
className: d(l, "script-select"),
|
|
346
|
-
...x,
|
|
333
|
+
let e = !1;
|
|
334
|
+
const t = {
|
|
335
|
+
path: null,
|
|
336
|
+
title: y("templateSelect.blankTitle"),
|
|
337
|
+
summary: y("templateSelect.blankSummary"),
|
|
338
|
+
content: ""
|
|
339
|
+
};
|
|
340
|
+
return C(!0), K(null), de(r).then((r) => {
|
|
341
|
+
e || b([t, ...r]);
|
|
342
|
+
}, (r) => {
|
|
343
|
+
e || (b([t]), K(r instanceof Error ? r.message : y("templateSelect.loadFailed")));
|
|
344
|
+
}).finally(() => {
|
|
345
|
+
e || C(!1);
|
|
346
|
+
}), () => {
|
|
347
|
+
e = !0;
|
|
348
|
+
};
|
|
349
|
+
}, [
|
|
350
|
+
r,
|
|
351
|
+
y,
|
|
352
|
+
N
|
|
353
|
+
]), w) return W(p, {
|
|
354
|
+
className: d(a, "script-select"),
|
|
355
|
+
...g,
|
|
347
356
|
sx: [{
|
|
348
357
|
display: "flex",
|
|
349
358
|
justifyContent: "center",
|
|
@@ -351,61 +360,69 @@ var ce = n(r((e, t) => {
|
|
|
351
360
|
height: "100%",
|
|
352
361
|
background: (e) => e.palette.background.paper,
|
|
353
362
|
zIndex: 1e3,
|
|
354
|
-
...Array.isArray(
|
|
355
|
-
}, ...Array.isArray(
|
|
356
|
-
children:
|
|
363
|
+
...Array.isArray(l) ? {} : l
|
|
364
|
+
}, ...Array.isArray(l) ? l : []],
|
|
365
|
+
children: W(m, {})
|
|
357
366
|
});
|
|
358
|
-
let
|
|
359
|
-
F && (
|
|
360
|
-
className:
|
|
361
|
-
|
|
362
|
-
sx: [{
|
|
367
|
+
let $ = null;
|
|
368
|
+
F && ($ = H(p, {
|
|
369
|
+
className: "error-results",
|
|
370
|
+
sx: {
|
|
363
371
|
display: "flex",
|
|
364
|
-
justifyContent: "center",
|
|
365
|
-
alignItems: "center",
|
|
366
|
-
background: (e) => e.palette.error.light,
|
|
367
|
-
flex: "0",
|
|
368
|
-
zIndex: 1e3,
|
|
369
372
|
flexDirection: "column",
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
373
|
+
alignItems: "center",
|
|
374
|
+
flex: "none",
|
|
375
|
+
gap: .5,
|
|
376
|
+
padding: 1.5,
|
|
377
|
+
background: (e) => j(e.palette.error.main, "dark" === e.palette.mode ? .16 : .06),
|
|
378
|
+
borderTop: (e) => `1px solid ${j(e.palette.error.main, .4)}`
|
|
379
|
+
},
|
|
380
|
+
children: [
|
|
381
|
+
W(h, {
|
|
382
|
+
color: "error",
|
|
383
|
+
variant: "subtitle1",
|
|
384
|
+
component: "div",
|
|
385
|
+
children: y("templateSelect.errorTitle")
|
|
386
|
+
}),
|
|
387
|
+
W(h, {
|
|
388
|
+
variant: "body2",
|
|
389
|
+
component: "div",
|
|
390
|
+
sx: {
|
|
391
|
+
color: "text.secondary",
|
|
392
|
+
textAlign: "center"
|
|
393
|
+
},
|
|
394
|
+
children: F
|
|
395
|
+
}),
|
|
396
|
+
W(u, {
|
|
397
|
+
size: "small",
|
|
398
|
+
color: "error",
|
|
399
|
+
onClick: () => T((e) => e + 1),
|
|
400
|
+
children: y("templateSelect.retry")
|
|
401
|
+
})
|
|
402
|
+
]
|
|
386
403
|
}));
|
|
387
|
-
const
|
|
388
|
-
const t = e.
|
|
389
|
-
return "macro" === t ?
|
|
404
|
+
const P = (e) => {
|
|
405
|
+
const t = e.icon;
|
|
406
|
+
return "macro" === t ? W(v, {
|
|
390
407
|
iconKey: "ScriptMacro",
|
|
391
408
|
size: "1em"
|
|
392
|
-
}) : "formula" === t ?
|
|
409
|
+
}) : "formula" === t ? W(v, {
|
|
393
410
|
iconKey: "ScriptFormula",
|
|
394
411
|
size: "1em"
|
|
395
|
-
}) : "autostart" === t ?
|
|
412
|
+
}) : "autostart" === t ? W(v, {
|
|
396
413
|
iconKey: "ScriptAutoRun",
|
|
397
414
|
size: "1em"
|
|
398
415
|
}) : null;
|
|
399
416
|
};
|
|
400
417
|
return H(p, {
|
|
401
418
|
ref: t,
|
|
402
|
-
className: d(
|
|
419
|
+
className: d(a, "script-select"),
|
|
403
420
|
sx: {
|
|
404
421
|
background: (e) => e.palette.background.paper,
|
|
405
422
|
zIndex: 1e3,
|
|
406
|
-
...
|
|
423
|
+
...l
|
|
407
424
|
},
|
|
408
|
-
...
|
|
425
|
+
...g,
|
|
409
426
|
children: [H(p, {
|
|
410
427
|
className: "script-select-content",
|
|
411
428
|
sx: {
|
|
@@ -414,40 +431,40 @@ var ce = n(r((e, t) => {
|
|
|
414
431
|
flex: "1 1 auto"
|
|
415
432
|
},
|
|
416
433
|
children: [
|
|
417
|
-
|
|
434
|
+
W(h, {
|
|
418
435
|
variant: "h6",
|
|
419
436
|
gutterBottom: !0,
|
|
420
437
|
children: y("templateSelect.title")
|
|
421
438
|
}),
|
|
422
|
-
|
|
439
|
+
W(h, {
|
|
423
440
|
variant: "body2",
|
|
424
441
|
component: "div",
|
|
425
442
|
gutterBottom: !0,
|
|
426
443
|
sx: { color: "text.secondary" },
|
|
427
444
|
children: y("templateSelect.intro")
|
|
428
445
|
}),
|
|
429
|
-
|
|
446
|
+
W(h, {
|
|
430
447
|
variant: "body2",
|
|
431
448
|
component: "div",
|
|
432
449
|
gutterBottom: !0,
|
|
433
450
|
sx: { color: "text.secondary" },
|
|
434
451
|
children: y("templateSelect.intro2")
|
|
435
452
|
}),
|
|
436
|
-
|
|
453
|
+
W(p, {
|
|
437
454
|
sx: {
|
|
438
455
|
display: "grid",
|
|
439
456
|
gridTemplateColumns: `repeat(auto-fill, minmax(${s}px, 1fr))`,
|
|
440
|
-
gap: `${
|
|
457
|
+
gap: `${x}px`,
|
|
441
458
|
padding: 2,
|
|
442
459
|
paddingLeft: "0px",
|
|
443
460
|
paddingRight: "0px"
|
|
444
461
|
},
|
|
445
|
-
children: S.map((e, t) => H(
|
|
462
|
+
children: S.map((e, t) => H(u, {
|
|
446
463
|
variant: "outlined",
|
|
447
464
|
disabled: i,
|
|
448
465
|
sx: {
|
|
449
466
|
minWidth: s,
|
|
450
|
-
minHeight:
|
|
467
|
+
minHeight: f,
|
|
451
468
|
display: "flex",
|
|
452
469
|
flexDirection: "column",
|
|
453
470
|
justifyContent: "flex-start",
|
|
@@ -472,12 +489,12 @@ var ce = n(r((e, t) => {
|
|
|
472
489
|
width: "100%",
|
|
473
490
|
marginBottom: .5
|
|
474
491
|
},
|
|
475
|
-
children: [
|
|
492
|
+
children: [W(h, {
|
|
476
493
|
variant: "subtitle2",
|
|
477
494
|
component: "div",
|
|
478
|
-
children: e.
|
|
479
|
-
}),
|
|
480
|
-
}), e.
|
|
495
|
+
children: e.title || y("templateSelect.untitled")
|
|
496
|
+
}), P(e)]
|
|
497
|
+
}), e.summary && W(h, {
|
|
481
498
|
variant: "body2",
|
|
482
499
|
component: "div",
|
|
483
500
|
sx: {
|
|
@@ -488,49 +505,49 @@ var ce = n(r((e, t) => {
|
|
|
488
505
|
textOverflow: "ellipsis",
|
|
489
506
|
alignItems: "flex-start"
|
|
490
507
|
},
|
|
491
|
-
children: e.
|
|
508
|
+
children: e.summary
|
|
492
509
|
})]
|
|
493
510
|
}, `${e.path}-${t}`))
|
|
494
511
|
})
|
|
495
512
|
]
|
|
496
|
-
}),
|
|
513
|
+
}), $]
|
|
497
514
|
});
|
|
498
515
|
}));
|
|
499
|
-
|
|
500
|
-
var
|
|
501
|
-
const { className: r, sx: n, propsScriptEditor:
|
|
516
|
+
xe.displayName = "TemplateSelectPanel";
|
|
517
|
+
var ge = n(r((e, t) => {
|
|
518
|
+
const { className: r, sx: n, propsScriptEditor: a, readOnly: u = !1, frame: m, autoFocusSel: g, autoFocus: y = !0, scripts: S, ...b } = e, v = x(), [w, k] = c(!1), F = s(!1), [K, D] = c({
|
|
502
519
|
message: "Loading",
|
|
503
520
|
cursor: "",
|
|
504
521
|
dirty: !1
|
|
505
|
-
}), [
|
|
522
|
+
}), [$, P] = c(null);
|
|
506
523
|
o(() => {
|
|
507
524
|
let e = !1;
|
|
508
|
-
return
|
|
525
|
+
return P(null), async function() {
|
|
509
526
|
if (S && (await S.start(), !e)) {
|
|
510
527
|
const e = S.getModules().getItems()[0]?.getSource();
|
|
511
|
-
|
|
528
|
+
P({ source: e || null });
|
|
512
529
|
}
|
|
513
530
|
}(), () => {
|
|
514
531
|
e = !0;
|
|
515
532
|
};
|
|
516
533
|
}, [S]);
|
|
517
|
-
const
|
|
518
|
-
|
|
534
|
+
const I = i((e) => {
|
|
535
|
+
D((t) => ({
|
|
519
536
|
...t,
|
|
520
537
|
...e
|
|
521
538
|
}));
|
|
522
|
-
}, []), E = s(null), [
|
|
523
|
-
if (
|
|
524
|
-
if (
|
|
525
|
-
const t = E.current?.querySelectorAll?.(
|
|
539
|
+
}, []), E = s(null), [L, R] = c(null), M = s(null), z = C((e) => {
|
|
540
|
+
if (L) return L.focus(e), !0;
|
|
541
|
+
if (g) {
|
|
542
|
+
const t = E.current?.querySelectorAll?.(g);
|
|
526
543
|
if (t && t.length > 0) return t[0]?.focus?.(e), !0;
|
|
527
544
|
}
|
|
528
545
|
return E.current?.focus?.(e), !1;
|
|
529
546
|
}, [
|
|
530
|
-
|
|
531
|
-
|
|
547
|
+
L,
|
|
548
|
+
g,
|
|
532
549
|
y
|
|
533
|
-
]), O =
|
|
550
|
+
]), O = l(() => W(T, {
|
|
534
551
|
transitionDelay: "160ms",
|
|
535
552
|
style: {
|
|
536
553
|
position: "absolute",
|
|
@@ -538,7 +555,7 @@ var de = n(r((e, t) => {
|
|
|
538
555
|
height: "100%"
|
|
539
556
|
},
|
|
540
557
|
transparentBackground: !1
|
|
541
|
-
}), []),
|
|
558
|
+
}), []), B = l(() => W(f, {
|
|
542
559
|
elevation: 1,
|
|
543
560
|
tabIndex: 0,
|
|
544
561
|
sx: {
|
|
@@ -551,8 +568,8 @@ var de = n(r((e, t) => {
|
|
|
551
568
|
marginTop: (e) => e.spacing(1),
|
|
552
569
|
marginBottom: (e) => e.spacing(1)
|
|
553
570
|
},
|
|
554
|
-
children:
|
|
555
|
-
}), [v]),
|
|
571
|
+
children: W(he, {})
|
|
572
|
+
}), [v]), A = l(() => W(p, {
|
|
556
573
|
className: d("script-status-panel", "status-panel"),
|
|
557
574
|
sx: {
|
|
558
575
|
display: "flex",
|
|
@@ -576,7 +593,7 @@ var de = n(r((e, t) => {
|
|
|
576
593
|
justifyContent: "center"
|
|
577
594
|
},
|
|
578
595
|
children: [
|
|
579
|
-
|
|
596
|
+
W(h, {
|
|
580
597
|
component: "div",
|
|
581
598
|
sx: {
|
|
582
599
|
userSelect: "none",
|
|
@@ -587,9 +604,9 @@ var de = n(r((e, t) => {
|
|
|
587
604
|
color: (e) => e.palette.text.secondary
|
|
588
605
|
},
|
|
589
606
|
variant: "caption",
|
|
590
|
-
children:
|
|
607
|
+
children: K.message
|
|
591
608
|
}),
|
|
592
|
-
|
|
609
|
+
W(h, {
|
|
593
610
|
component: "div",
|
|
594
611
|
sx: {
|
|
595
612
|
userSelect: "none",
|
|
@@ -600,9 +617,9 @@ var de = n(r((e, t) => {
|
|
|
600
617
|
color: (e) => e.palette.text.secondary
|
|
601
618
|
},
|
|
602
619
|
variant: "caption",
|
|
603
|
-
children:
|
|
620
|
+
children: K.dirty ? "Unsaved" : ""
|
|
604
621
|
}),
|
|
605
|
-
|
|
622
|
+
W(h, {
|
|
606
623
|
component: "div",
|
|
607
624
|
sx: {
|
|
608
625
|
userSelect: "none",
|
|
@@ -617,11 +634,11 @@ var de = n(r((e, t) => {
|
|
|
617
634
|
color: (e) => e.palette.text.secondary
|
|
618
635
|
},
|
|
619
636
|
variant: "caption",
|
|
620
|
-
children:
|
|
637
|
+
children: K.cursor
|
|
621
638
|
})
|
|
622
639
|
]
|
|
623
640
|
})
|
|
624
|
-
}), [
|
|
641
|
+
}), [K]), U = l(() => H(p, {
|
|
625
642
|
className: d("script-editor-content"),
|
|
626
643
|
sx: {
|
|
627
644
|
display: "flex",
|
|
@@ -631,8 +648,8 @@ var de = n(r((e, t) => {
|
|
|
631
648
|
boxSizing: "border-box"
|
|
632
649
|
},
|
|
633
650
|
children: [
|
|
634
|
-
|
|
635
|
-
|
|
651
|
+
B,
|
|
652
|
+
W(p, {
|
|
636
653
|
sx: {
|
|
637
654
|
display: "flex",
|
|
638
655
|
flex: "1 1 100%",
|
|
@@ -641,35 +658,35 @@ var de = n(r((e, t) => {
|
|
|
641
658
|
position: "relative",
|
|
642
659
|
boxSizing: "border-box"
|
|
643
660
|
},
|
|
644
|
-
children:
|
|
661
|
+
children: W(_, {
|
|
645
662
|
ref: E,
|
|
646
663
|
loadingPanel: O,
|
|
647
|
-
readOnly:
|
|
648
|
-
frame:
|
|
664
|
+
readOnly: u,
|
|
665
|
+
frame: m,
|
|
649
666
|
scripts: S,
|
|
650
667
|
autoFocus: y,
|
|
651
|
-
onStatusChange:
|
|
668
|
+
onStatusChange: I,
|
|
652
669
|
darkMode: "dark" === v.palette.mode,
|
|
653
|
-
...
|
|
670
|
+
...a
|
|
654
671
|
})
|
|
655
672
|
}),
|
|
656
|
-
|
|
673
|
+
A
|
|
657
674
|
]
|
|
658
675
|
}), [
|
|
659
676
|
v,
|
|
677
|
+
B,
|
|
660
678
|
A,
|
|
661
|
-
M,
|
|
662
679
|
w,
|
|
663
680
|
O,
|
|
664
|
-
m,
|
|
665
|
-
l,
|
|
666
|
-
y,
|
|
667
|
-
x,
|
|
668
681
|
u,
|
|
669
|
-
|
|
670
|
-
|
|
682
|
+
a,
|
|
683
|
+
y,
|
|
684
|
+
g,
|
|
685
|
+
m,
|
|
686
|
+
I
|
|
687
|
+
]), j = l(() => {
|
|
671
688
|
let e;
|
|
672
|
-
return null ===
|
|
689
|
+
return null === $ ? O : (null === $.source && (e = W(xe, {
|
|
673
690
|
sx: {
|
|
674
691
|
display: "flex",
|
|
675
692
|
flex: "1 1 100%",
|
|
@@ -680,11 +697,11 @@ var de = n(r((e, t) => {
|
|
|
680
697
|
width: "100%",
|
|
681
698
|
height: "100%"
|
|
682
699
|
},
|
|
683
|
-
disabled:
|
|
700
|
+
disabled: u,
|
|
684
701
|
onScriptSelect: (e) => {
|
|
685
|
-
E.current?.insertSnippet(e.content),
|
|
702
|
+
E.current?.insertSnippet(e.content), P({ source: e.content ?? "" }), requestAnimationFrame(() => E.current?.focus());
|
|
686
703
|
}
|
|
687
|
-
})),
|
|
704
|
+
})), W(p, {
|
|
688
705
|
tabIndex: 0,
|
|
689
706
|
className: d("script-workspace", r),
|
|
690
707
|
sx: {
|
|
@@ -706,7 +723,7 @@ var de = n(r((e, t) => {
|
|
|
706
723
|
position: "relative",
|
|
707
724
|
display: "flex"
|
|
708
725
|
},
|
|
709
|
-
children: [
|
|
726
|
+
children: [W(p, {
|
|
710
727
|
sx: {
|
|
711
728
|
display: "flex",
|
|
712
729
|
flex: "1 1 100%",
|
|
@@ -714,24 +731,24 @@ var de = n(r((e, t) => {
|
|
|
714
731
|
minHeight: 0,
|
|
715
732
|
visibility: e ? "hidden" : "visible"
|
|
716
733
|
},
|
|
717
|
-
children:
|
|
734
|
+
children: U
|
|
718
735
|
}), e]
|
|
719
736
|
})
|
|
720
737
|
}));
|
|
721
738
|
}, [
|
|
722
|
-
|
|
723
|
-
|
|
739
|
+
B,
|
|
740
|
+
U,
|
|
724
741
|
r,
|
|
725
|
-
|
|
742
|
+
$,
|
|
726
743
|
O,
|
|
727
|
-
|
|
728
|
-
]), q =
|
|
744
|
+
u
|
|
745
|
+
]), q = N(t, () => ({
|
|
729
746
|
isScriptWorkspaceElement: () => !0,
|
|
730
747
|
focus: (e) => {
|
|
731
|
-
|
|
748
|
+
z(e);
|
|
732
749
|
}
|
|
733
750
|
}), []);
|
|
734
|
-
return
|
|
751
|
+
return W(p, {
|
|
735
752
|
sx: {
|
|
736
753
|
display: "flex",
|
|
737
754
|
flexDirection: "row",
|
|
@@ -742,58 +759,60 @@ var de = n(r((e, t) => {
|
|
|
742
759
|
ref: q,
|
|
743
760
|
...b,
|
|
744
761
|
onFocus: (e) => {
|
|
745
|
-
k(!0), F.current = !0, q.current?.contains(e.target) && e.target !== q.current && R(e.target), e.relatedTarget && !
|
|
762
|
+
k(!0), F.current = !0, q.current?.contains(e.target) && e.target !== q.current && R(e.target), e.relatedTarget && !M.current && (M.current = e.relatedTarget), b?.onFocus?.(e);
|
|
746
763
|
},
|
|
747
764
|
onBlur: (e) => {
|
|
748
|
-
q?.current?.contains(e.relatedTarget) || q?.current === e.relatedTarget || (
|
|
765
|
+
q?.current?.contains(e.relatedTarget) || q?.current === e.relatedTarget || (M.current = null, F.current = !1, k(!1)), b?.onBlur?.(e);
|
|
749
766
|
},
|
|
750
|
-
children:
|
|
767
|
+
children: j
|
|
751
768
|
});
|
|
752
769
|
}));
|
|
753
|
-
|
|
754
|
-
var { FocusActivation:
|
|
755
|
-
const t =
|
|
756
|
-
return t ?
|
|
757
|
-
spec:
|
|
770
|
+
ge.displayName = "ScriptWorkspace";
|
|
771
|
+
var { FocusActivation: ye, CommandScopeProvider: Se, CommandAnchorProvider: be, useCommandScope: ve } = g, we = { scopeName: "scriptEditor" }, ke = ({ children: e }) => {
|
|
772
|
+
const t = ve(), r = s(null);
|
|
773
|
+
return t ? W(Se, {
|
|
774
|
+
spec: we,
|
|
758
775
|
elementRef: r,
|
|
759
776
|
region: !0,
|
|
760
|
-
children:
|
|
777
|
+
children: W(Ce, {
|
|
761
778
|
paneRef: r,
|
|
762
779
|
children: e
|
|
763
780
|
})
|
|
764
781
|
}) : e;
|
|
765
|
-
},
|
|
766
|
-
const r =
|
|
767
|
-
return n ? H(
|
|
782
|
+
}, Ce = ({ paneRef: e, children: t }) => {
|
|
783
|
+
const r = ve(), n = l(() => r ? new ye(r.getRoot(), r) : null, [r]);
|
|
784
|
+
return n ? H(be, {
|
|
768
785
|
tracker: n,
|
|
769
786
|
keyBindings: !1,
|
|
770
787
|
debounce: 100,
|
|
771
788
|
elementRef: e,
|
|
772
|
-
children: [
|
|
789
|
+
children: [W(O, {}), W("div", {
|
|
773
790
|
className: "script-editor-pane",
|
|
774
791
|
style: { display: "contents" },
|
|
775
792
|
ref: e,
|
|
776
793
|
children: t
|
|
777
794
|
})]
|
|
778
795
|
}) : t;
|
|
779
|
-
},
|
|
780
|
-
const { model: t, entryKey: r, frame: n, ref: i, ...o } = e,
|
|
781
|
-
|
|
796
|
+
}, Fe = (e) => {
|
|
797
|
+
const { model: t, entryKey: r, frame: n, ref: i, ...o } = e, l = A() ?? t;
|
|
798
|
+
B(l, ["onProtectionChange"]);
|
|
799
|
+
const a = l?.getScripts().isReadOnly() ?? !1;
|
|
800
|
+
return W(ke, { children: W(ge, {
|
|
782
801
|
ref: i,
|
|
783
|
-
readOnly: a
|
|
802
|
+
readOnly: a,
|
|
784
803
|
frame: n,
|
|
785
|
-
scripts:
|
|
804
|
+
scripts: l?.getScripts(),
|
|
786
805
|
...o
|
|
787
806
|
}) });
|
|
788
|
-
},
|
|
789
|
-
const { alwaysShow: t = !1, ...r } = e, [n, i] =
|
|
807
|
+
}, Ke = n((e) => {
|
|
808
|
+
const { alwaysShow: t = !1, ...r } = e, [n, i] = a((e) => e + 1, 0), [l] = K(["showScriptEditor"], { onChange: () => i() }), s = A(), [d, p] = c(t);
|
|
790
809
|
return o(() => {
|
|
791
810
|
if (t) return void p(!0);
|
|
792
811
|
const e = s?.getScripts();
|
|
793
|
-
if (!e || !
|
|
812
|
+
if (!e || !l) return void p(!1);
|
|
794
813
|
const r = async () => {
|
|
795
814
|
let t = !1;
|
|
796
|
-
|
|
815
|
+
l.getState() || (t = ((await e.searchFunctions({ type: "macro" }))?.length ?? 0) > 0), p(t || !!l.getState());
|
|
797
816
|
};
|
|
798
817
|
r();
|
|
799
818
|
const n = e.addListeners({ onChange: () => {
|
|
@@ -805,13 +824,13 @@ var { FocusActivation: pe, CommandScopeProvider: me, CommandAnchorProvider: ue,
|
|
|
805
824
|
}, [
|
|
806
825
|
t,
|
|
807
826
|
s,
|
|
808
|
-
|
|
827
|
+
l,
|
|
809
828
|
n
|
|
810
|
-
]), d ? H(
|
|
829
|
+
]), d ? H(U, { children: [W(E, {}), W(te, { ...r })] }) : null;
|
|
811
830
|
});
|
|
812
|
-
|
|
813
|
-
var
|
|
814
|
-
const { ...n } = e, i =
|
|
831
|
+
Ke.displayName = "RunScriptContribution", Y();
|
|
832
|
+
var Ne = n(r((e, r) => {
|
|
833
|
+
const { ...n } = e, i = A(), l = D(), [a, s] = c([]);
|
|
815
834
|
o(() => {
|
|
816
835
|
const e = i?.getScripts();
|
|
817
836
|
if (!e) return;
|
|
@@ -831,19 +850,19 @@ var be = n(r((e, r) => {
|
|
|
831
850
|
const d = {
|
|
832
851
|
variant: y.Menuitem,
|
|
833
852
|
shortcut: void 0
|
|
834
|
-
},
|
|
835
|
-
for (let e = 0; e <
|
|
836
|
-
const t =
|
|
837
|
-
|
|
853
|
+
}, u = [], m = a ? a.length : 0;
|
|
854
|
+
for (let e = 0; e < m; e++) {
|
|
855
|
+
const t = a[e];
|
|
856
|
+
u.push(W($, {
|
|
838
857
|
...d,
|
|
839
858
|
commandKey: "insertFunction",
|
|
840
859
|
commandState: t,
|
|
841
|
-
propsTooltip: { description:
|
|
842
|
-
icon:
|
|
843
|
-
label: t.getName() ??
|
|
860
|
+
propsTooltip: { description: l("insertFunction.insertNamed", { name: t.getName() ?? l("insertFunction.fallbackLabel") }) },
|
|
861
|
+
icon: W(v, { iconKey: "FormulaCustom" }),
|
|
862
|
+
label: t.getName() ?? l("insertFunction.fallbackLabel")
|
|
844
863
|
}, `function-${t.getName()}-${e}`));
|
|
845
864
|
}
|
|
846
|
-
const
|
|
865
|
+
const f = H(p, {
|
|
847
866
|
ref: r,
|
|
848
867
|
sx: {
|
|
849
868
|
display: "flex",
|
|
@@ -851,62 +870,60 @@ var be = n(r((e, r) => {
|
|
|
851
870
|
flex: "1 1 100%",
|
|
852
871
|
overflow: "hidden"
|
|
853
872
|
},
|
|
854
|
-
children: [
|
|
873
|
+
children: [u.length > 0 ? H(U, { children: [W(p, {
|
|
855
874
|
sx: {
|
|
856
875
|
overflow: "auto",
|
|
857
876
|
flex: "1 1 100%"
|
|
858
877
|
},
|
|
859
|
-
children:
|
|
860
|
-
}),
|
|
878
|
+
children: u
|
|
879
|
+
}), W(E, { orientation: "horizontal" })] }) : null, t($, {
|
|
861
880
|
...d,
|
|
862
881
|
key: "show-editor",
|
|
863
882
|
commandKey: "showScriptEditor"
|
|
864
883
|
})]
|
|
865
884
|
});
|
|
866
|
-
return
|
|
885
|
+
return M({
|
|
867
886
|
...n,
|
|
868
|
-
children:
|
|
887
|
+
children: f
|
|
869
888
|
});
|
|
870
889
|
}));
|
|
871
|
-
|
|
872
|
-
var
|
|
873
|
-
const { disabled: r, groupKey: n, ...o } = e,
|
|
874
|
-
|
|
890
|
+
Ne.displayName = "InsertFunctionPopupPanel";
|
|
891
|
+
var De = n(r((e, t) => {
|
|
892
|
+
const { disabled: r, groupKey: n, ...o } = e, l = F("customFunctionOptions"), a = i((e) => {
|
|
893
|
+
const t = W(Ne, {
|
|
894
|
+
disabled: r,
|
|
895
|
+
groupKey: n,
|
|
896
|
+
...e
|
|
897
|
+
});
|
|
898
|
+
return M({
|
|
899
|
+
...e,
|
|
900
|
+
children: t
|
|
901
|
+
});
|
|
902
|
+
}, [r, n]);
|
|
903
|
+
return W(P, {
|
|
875
904
|
ref: t,
|
|
876
905
|
disabled: r,
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
groupKey: n,
|
|
881
|
-
...e
|
|
882
|
-
});
|
|
883
|
-
return z({
|
|
884
|
-
...e,
|
|
885
|
-
children: t
|
|
886
|
-
});
|
|
887
|
-
}, [r, n]),
|
|
888
|
-
label: a?.getLabel?.(),
|
|
889
|
-
tooltip: a?.getDescription?.(),
|
|
906
|
+
renderPopupPanel: a,
|
|
907
|
+
label: l?.getLabel?.(),
|
|
908
|
+
tooltip: l?.getDescription?.(),
|
|
890
909
|
icon: "FormulaCustom",
|
|
891
910
|
...o
|
|
892
911
|
});
|
|
893
912
|
}));
|
|
894
|
-
|
|
895
|
-
var
|
|
896
|
-
J(), b.register("plugin-scripts", { icons: {} }),
|
|
913
|
+
De.displayName = "InsertFunctionContribution";
|
|
914
|
+
var Te = () => {
|
|
915
|
+
J(), b.register("plugin-scripts", { icons: {} }), z.registerTaskPane({
|
|
897
916
|
key: "scriptEditor",
|
|
898
|
-
|
|
899
|
-
getIcon: () => "ScriptRun",
|
|
900
|
-
component: ye,
|
|
917
|
+
component: Fe,
|
|
901
918
|
keepMounted: !0
|
|
902
919
|
}, !0), S.register({ key: "scriptsOptions" }, !0), S.register({ key: "customFunctionOptions" }, !0), S.register({
|
|
903
920
|
key: "scripting.runScript.home",
|
|
904
921
|
contributions: { homeToolbar: {} },
|
|
905
|
-
render: (t) => e.createElement(
|
|
922
|
+
render: (t) => e.createElement(Ke, { ...t })
|
|
906
923
|
}, !0), S.register({
|
|
907
924
|
key: "scripting.runScript.view",
|
|
908
925
|
contributions: { viewToolbar: { order: 10 } },
|
|
909
|
-
render: (t) => e.createElement(
|
|
926
|
+
render: (t) => e.createElement(Ke, {
|
|
910
927
|
...t,
|
|
911
928
|
groupKey: "view",
|
|
912
929
|
alwaysShow: !0
|
|
@@ -917,7 +934,7 @@ var we = () => {
|
|
|
917
934
|
anchor: "formulaCategory.web",
|
|
918
935
|
order: 1
|
|
919
936
|
} },
|
|
920
|
-
render: (t) => e.createElement(
|
|
937
|
+
render: (t) => e.createElement(De, { ...t })
|
|
921
938
|
}, !0);
|
|
922
939
|
};
|
|
923
|
-
export {
|
|
940
|
+
export { fe as InsertScriptCommandButton, te as RunScriptCommandButton, he as ScriptEditorToolbar, Fe as ScriptTaskPane, ge as ScriptWorkspace, Te as ScriptingPlugin };
|