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