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