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