@sheetxl/scripting-mui 0.8.0-beta.1 → 0.8.0-beta.10

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.1
2
+ * @license @sheetxl/scripting-mui - Scripting MUI - MUI script workspace, toolbar and run-script plugin for SheetXL. - v0.8.0-beta.10
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.
@@ -7,28 +7,33 @@
7
7
  import e, { createElement as t, forwardRef as n, memo as r, useCallback as i, useEffect as a, useMemo as o, useReducer as s, useRef as c, useState as l } from "react";
8
8
  import { Box as u, Button as d, CircularProgress as f, Paper as p, Typography as m, useTheme as h } from "@mui/material";
9
9
  import { Command as g, CommandButtonType as _, DefaultCommandButtonRegistry as v, DefaultIconService as y, DynamicIcon as b, KeyCodes as x, ReactUtils as S, useCallbackRef as C, useCommandButtonEntry as w, useCommands as T, useImperativeElement as E, useTranslator as D } from "@sheetxl/utils-react";
10
- import { AnimatedLoadingPanel as ee, CommandButton as O, CommandPopupButton as k, CommandToolbar as A, ExhibitDivider as j, ExhibitMenuItem as M, OverflowPalette as N, defaultCreatePopupPanel as P, raisedSurface as F } from "@sheetxl/utils-mui";
11
- import { DefaultTaskPaneRegistry as I, InputClipboardInjector as L, useWorkbook as R } from "@sheetxl/react";
10
+ import { AnimatedLoadingPanel as ee, CommandButton as O, CommandPopupButton as k, CommandToolbar as A, ExhibitDivider as j, ExhibitMenuItem as M, OverflowPalette as N, defaultCreatePopupPanel as P } from "@sheetxl/utils-mui";
11
+ import { DefaultTaskPaneRegistry as F, InputClipboardInjector as I, useModelSync as L, useWorkbook as R } from "@sheetxl/react";
12
12
  import { Fragment as z, jsx as B, jsxs as V } from "react/jsx-runtime";
13
- import { alpha as H } from "@mui/system";
13
+ import { alpha as te } from "@mui/system";
14
+ import { VERSION as H } from "@sheetxl/sdk";
14
15
  import { ChainedError as U } from "@sheetxl/utils";
15
- import { ScriptEditor as te, ScriptingReactPlugin as ne } from "@sheetxl/scripting-react";
16
- function W(e) {
16
+ import { ScriptEditor as ne, ScriptingReactPlugin as re } from "@sheetxl/scripting-react";
17
+ function ie(e) {
17
18
  var t, n, r = "";
18
19
  if (typeof e == "string" || typeof e == "number") r += e;
19
- else if (typeof e == "object") if (Array.isArray(e)) {
20
- var i = e.length;
21
- for (t = 0; t < i; t++) e[t] && (n = W(e[t])) && (r && (r += " "), r += n);
22
- } else for (n in e) e[n] && (r && (r += " "), r += n);
20
+ else if (typeof e == "object") {
21
+ if (Array.isArray(e)) {
22
+ var i = e.length;
23
+ for (t = 0; t < i; t++) e[t] && (n = ie(e[t])) && (r && (r += " "), r += n);
24
+ } else for (n in e) e[n] && (r && (r += " "), r += n);
25
+ }
23
26
  return r;
24
27
  }
25
- function G() {
26
- for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = W(e)) && (r && (r += " "), r += t);
28
+ function W() {
29
+ for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = ie(e)) && (r && (r += " "), r += t);
27
30
  return r;
28
31
  }
29
- var re = {
32
+ var ae = {
30
33
  "insertFunction.fallbackLabel": "Function",
31
34
  "insertFunction.insertNamed": "Insert {name}",
35
+ "insertScript.fallbackLabel": "Insert Script",
36
+ "insertScript.loading": "Loading...",
32
37
  "runScript.executeNamed": "Execute {name}",
33
38
  "runScript.fallbackLabel": "Macro",
34
39
  "templateSelect.blankSummary": "Start with an empty script.",
@@ -39,12 +44,12 @@ var re = {
39
44
  "templateSelect.loadFailed": "Failed to load scripts",
40
45
  "templateSelect.title": "Script Template",
41
46
  "templateSelect.untitled": "Untitled"
42
- }, { DefaultCommandCatalogService: ie } = g, K = !1;
43
- function q() {
44
- K || (K = !0, ie.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: re }));
47
+ }, { DefaultCommandCatalogService: oe } = g, se = !1;
48
+ function G() {
49
+ se || (se = !0, oe.registerFromManifest("@sheetxl/scripting-mui", import.meta.url, { messages: ae }));
45
50
  }
46
- q();
47
- var J = r(n((e, n) => {
51
+ G();
52
+ var ce = r(n((e, n) => {
48
53
  let { groupKey: r, ...i } = e, o = R(), s = D(), [c, d] = l([]), [f, p] = l(!1);
49
54
  a(() => {
50
55
  let e = o?.getScripts();
@@ -95,42 +100,42 @@ var J = r(n((e, n) => {
95
100
  children: v
96
101
  });
97
102
  }));
98
- J.displayName = "RunScriptPopupPanel";
99
- var ae = r(n((e, t) => {
100
- let { groupKey: n, disabled: r, ...a } = e, o = T(["showScriptEditor"])[0], s = w("scriptsOptions");
103
+ ce.displayName = "RunScriptPopupPanel";
104
+ var K = r(n((e, t) => {
105
+ let { groupKey: n, disabled: r, ...a } = e, o = T(["showScriptEditor"])[0], s = w("scriptsOptions"), c = i((e) => {
106
+ let t = B(ce, {
107
+ disabled: r,
108
+ groupKey: n,
109
+ ...e
110
+ });
111
+ return P({
112
+ ...e,
113
+ children: t
114
+ });
115
+ }, [r, n]);
101
116
  return B(k, {
102
117
  ref: t,
103
118
  disabled: r,
104
- createPopupPanel: i((e) => {
105
- let t = B(J, {
106
- disabled: r,
107
- groupKey: n,
108
- ...e
109
- });
110
- return P({
111
- ...e,
112
- children: t
113
- });
114
- }, [r, n]),
119
+ createPopupPanel: c,
115
120
  selected: o?.getState(),
116
121
  label: s?.getLabel?.(),
117
122
  tooltip: s?.getDescription?.(),
118
123
  quickCommand: "showScriptEditor",
119
124
  ...a
120
125
  });
121
- })), oe = "https://unpkg.com/@sheetxl/scripting-templates/dist", se = (e, t) => {
126
+ })), le = /^\d+\.\d+\.\d+-([0-9A-Za-z-]+)/.exec(H)?.[1], q = `https://unpkg.com/@sheetxl/templates-scripting${le ? `@${le}` : ""}/dist`, J = (e, t) => {
122
127
  try {
123
128
  return new URL(t).href;
124
129
  } catch {}
125
130
  if (t.startsWith("/") || /^[a-zA-Z]:/.test(t)) return t;
126
131
  let n = e.startsWith("http") ? e : `file:///${e.replace(/\\/g, "/")}`;
127
132
  return n.endsWith("/") || (n += "/"), new URL(t, n).href;
128
- }, ce = (e) => {
133
+ }, ue = (e) => {
129
134
  if (e.metadata?.name) return e.metadata.name;
130
135
  let t = (e.path.split("/").pop() || "").replace(/\.[^/.]+$/, "");
131
136
  return e.metadata?.icon === "formula" ? t.toUpperCase() : (t = t.replace(/([a-z])([A-Z])/g, "$1 $2"), t.replace(/[-_]/g, " ").trim().split(/\s+/).map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" "));
132
- }, le = async (e) => {
133
- let t = se(e, "./manifest.json"), n = await fetch(t);
137
+ }, de = async (e) => {
138
+ let t = J(e, "./manifest.json"), n = await fetch(t);
134
139
  if (!n.ok) throw new U(`Failed to retrieve directory at '${e}': ${n.statusText}`);
135
140
  let r = await n.text();
136
141
  if (r.trim().toLowerCase().startsWith("<!doctype html") || r.trim().toLowerCase().startsWith("<html")) throw new U(`Failed to retrieve directory at '${e}'`);
@@ -142,11 +147,11 @@ var ae = r(n((e, t) => {
142
147
  }
143
148
  let a = i.map(async (t) => {
144
149
  try {
145
- let n = se(e, t.path), r = await fetch(n);
150
+ let n = J(e, t.path), r = await fetch(n);
146
151
  if (!r.ok) throw Error(`Failed to fetch file at '${t.path}': ${r.statusText}`);
147
152
  let i = await r.text(), a = t.metadata;
148
153
  return a?.title || (a = {
149
- title: ce(t),
154
+ title: ue(t),
150
155
  ...a
151
156
  }), {
152
157
  path: t.path,
@@ -159,7 +164,7 @@ var ae = r(n((e, t) => {
159
164
  return null;
160
165
  });
161
166
  return (await Promise.all(a)).filter((e) => e !== null);
162
- }, Y = { marginRight: "4px" }, X = "1em", ue = r((e) => {
167
+ }, Y = { marginRight: "4px" }, X = "1em", fe = r((e) => {
163
168
  let { disabled: t, snippet: n, description: r, handleInsert: i, sx: a, ...o } = e, s, c = n.metadata?.icon;
164
169
  return s = B(b, c === "formula" ? {
165
170
  iconKey: "ScriptFormula",
@@ -206,7 +211,7 @@ var ae = r(n((e, t) => {
206
211
  variant: "caption",
207
212
  component: "div",
208
213
  sx: {
209
- color: (e) => H(e.palette.text.secondary ?? e.palette.text.primary, .6),
214
+ color: (e) => te(e.palette.text.secondary ?? e.palette.text.primary, .6),
210
215
  overflow: "hidden",
211
216
  textOverflow: "ellipsis"
212
217
  },
@@ -214,30 +219,30 @@ var ae = r(n((e, t) => {
214
219
  })]
215
220
  })
216
221
  });
217
- }), de = r(n((e, n) => {
218
- let { groupKey: r, disabled: o, scriptPath: s = oe, ...c } = e, [d, f] = l([]), [p, m] = l(!0), [h] = T(["insertScript"]);
222
+ }), pe = r(n((e, n) => {
223
+ let { groupKey: r, disabled: o, scriptPath: s = q, ...c } = e, d = D(), [f, p] = l([]), [m, h] = l(!0), [g] = T(["insertScript"]), v = o || (g?.disabled() ?? !1);
219
224
  a(() => {
220
225
  (async () => {
221
226
  try {
222
- let e = await le(s);
223
- f(e);
227
+ let e = await de(s);
228
+ p(e);
224
229
  } catch {} finally {
225
- m(!1);
230
+ h(!1);
226
231
  }
227
232
  })();
228
233
  }, [s]);
229
- let g = i((e) => {
230
- if (p) return B("div", { children: "Loading..." });
234
+ let y = i((e) => {
235
+ if (m) return B("div", { children: d("insertScript.loading") });
231
236
  let n = {
232
237
  variant: _.Menuitem,
233
238
  groupKey: "scriptsOptions",
234
- disabled: o
239
+ disabled: v
235
240
  }, r = (t) => {
236
- h?.execute(t.content), e.closeFloat?.();
241
+ g?.execute(t.content), e.closeFloat?.();
237
242
  }, i = [];
238
- for (let e = 0; e < d.length; e++) {
239
- let t = d[e];
240
- t && i.push(B(ue, {
243
+ for (let e = 0; e < f.length; e++) {
244
+ let t = f[e];
245
+ t && i.push(B(fe, {
241
246
  handleInsert: r,
242
247
  snippet: t
243
248
  }, t.path));
@@ -274,81 +279,82 @@ var ae = r(n((e, t) => {
274
279
  children: a
275
280
  });
276
281
  }, [
277
- o,
282
+ v,
278
283
  r,
279
- p,
280
- h
284
+ m,
285
+ g,
286
+ d
281
287
  ]);
282
288
  return B(k, {
283
289
  ref: n,
284
- disabled: o,
290
+ disabled: v,
285
291
  groupKey: r,
286
- label: h?.getLabel(r) ?? "Insert Script",
287
- tooltip: h?.getDescription(),
288
- createPopupPanel: g,
289
- icon: h?.getIcon() ?? "ScriptInsert",
292
+ label: g?.getLabel(r) ?? d("insertScript.fallbackLabel"),
293
+ tooltip: g?.getDescription(),
294
+ createPopupPanel: y,
295
+ icon: g?.getIcon() ?? "ScriptInsert",
290
296
  ...c
291
297
  });
292
298
  })), Z = r(n((e, t) => {
293
- let { propsCommandButton: n, ...r } = e;
299
+ let { propsCommandButton: n, ...r } = e, i = C((e) => {
300
+ let { propsCommandButton: t, propsCommandPopup: n } = e;
301
+ return B(z, { children: V("div", {
302
+ style: {
303
+ display: "flex",
304
+ flex: "1 1 100%"
305
+ },
306
+ children: [
307
+ B("div", { children: B(N, {
308
+ style: {},
309
+ children: B(O, {
310
+ ...t,
311
+ commandKey: "saveScripts"
312
+ })
313
+ }) }),
314
+ B("div", { style: { flex: "1 1 100%" } }),
315
+ B("div", { children: B(N, {
316
+ style: {},
317
+ children: B(pe, { ...t })
318
+ }) })
319
+ ]
320
+ }) });
321
+ }, []);
294
322
  return B(A, {
295
323
  ref: t,
296
324
  propsCommandButton: n,
297
- renderToolbarPalette: C((e) => {
298
- let { propsCommandButton: t, propsCommandPopup: n } = e;
299
- return B(z, { children: V("div", {
300
- style: {
301
- display: "flex",
302
- flex: "1 1 100%"
303
- },
304
- children: [
305
- B("div", { children: B(N, {
306
- style: {},
307
- children: B(O, {
308
- ...t,
309
- commandKey: "saveScripts"
310
- })
311
- }) }),
312
- B("div", { style: { flex: "1 1 100%" } }),
313
- B("div", { children: B(N, {
314
- style: {},
315
- children: B(de, { ...t })
316
- }) })
317
- ]
318
- }) });
319
- }, []),
325
+ renderToolbarPalette: i,
320
326
  ...r
321
327
  });
322
328
  }));
323
- Z.displayName = "ScriptEditorToolbar", q();
324
- var fe = r(n((e, t) => {
325
- let { scriptPath: n = oe, onScriptSelect: r, sx: i = S.EmptyCssProperties, className: o, buttonMinWidth: s = 210, buttonMinHeight: c = 80, gap: p = 12, ...h } = e, g = D(), [_, v] = l([]), [y, x] = l(!0), [C, w] = l(null);
329
+ Z.displayName = "ScriptEditorToolbar", G();
330
+ var me = r(n((e, t) => {
331
+ let { scriptPath: n = q, onScriptSelect: r, disabled: i = !1, sx: o = S.EmptyCssProperties, className: s, buttonMinWidth: c = 210, buttonMinHeight: p = 80, gap: h = 12, ...g } = e, _ = D(), [v, y] = l([]), [x, C] = l(!0), [w, T] = l(null);
326
332
  if (a(() => {
327
333
  (async () => {
328
334
  let e = [{
329
335
  path: null,
330
336
  metadata: {
331
- title: g("templateSelect.blankTitle"),
332
- summary: g("templateSelect.blankSummary")
337
+ title: _("templateSelect.blankTitle"),
338
+ summary: _("templateSelect.blankSummary")
333
339
  },
334
340
  content: ""
335
341
  }];
336
342
  try {
337
- x(!0), w(null);
338
- let t = await le(n);
343
+ C(!0), T(null);
344
+ let t = await de(n);
339
345
  for (let n = 0; n < t.length; n++) {
340
346
  let r = t[n];
341
347
  r && e.push(r);
342
348
  }
343
349
  } catch (e) {
344
- w(e instanceof Error ? e.message : g("templateSelect.loadFailed")), e instanceof U || console.error("Error loading scripts:", e);
350
+ T(e instanceof Error ? e.message : _("templateSelect.loadFailed")), e instanceof U || console.error("Error loading scripts:", e);
345
351
  } finally {
346
- v(e), x(!1);
352
+ y(e), C(!1);
347
353
  }
348
354
  })();
349
- }, [n, g]), y) return B(u, {
350
- className: G(o, "script-select"),
351
- ...h,
355
+ }, [n, _]), x) return B(u, {
356
+ className: W(s, "script-select"),
357
+ ...g,
352
358
  sx: [{
353
359
  display: "flex",
354
360
  justifyContent: "center",
@@ -356,15 +362,14 @@ var fe = r(n((e, t) => {
356
362
  height: "100%",
357
363
  background: (e) => e.palette.background.paper,
358
364
  zIndex: 1e3,
359
- backgroundImage: F,
360
- ...Array.isArray(i) ? {} : i
361
- }, ...Array.isArray(i) ? i : []],
365
+ ...Array.isArray(o) ? {} : o
366
+ }, ...Array.isArray(o) ? o : []],
362
367
  children: B(f, {})
363
368
  });
364
- let T = null;
365
- C && (T = V(u, {
366
- className: G(o, "script-select", "error-results"),
367
- ...h,
369
+ let E = null;
370
+ w && (E = V(u, {
371
+ className: W(s, "script-select", "error-results"),
372
+ ...g,
368
373
  sx: [{
369
374
  display: "flex",
370
375
  justifyContent: "center",
@@ -376,22 +381,21 @@ var fe = r(n((e, t) => {
376
381
  padding: (e) => e.spacing(1),
377
382
  border: (e) => `1px solid ${e.palette.error.main}`,
378
383
  borderBottomLeftRadius: 1,
379
- borderBottomRightRadius: 1,
380
- backgroundImage: F
381
- }, ...Array.isArray(i) ? i : [i]],
384
+ borderBottomRightRadius: 1
385
+ }, ...Array.isArray(o) ? o : [o]],
382
386
  children: [B(m, {
383
387
  color: "error",
384
388
  variant: "h6",
385
389
  component: "div",
386
390
  gutterBottom: !0,
387
- children: g("templateSelect.errorTitle")
391
+ children: _("templateSelect.errorTitle")
388
392
  }), B(m, {
389
393
  color: "error",
390
394
  component: "div",
391
- children: C
395
+ children: w
392
396
  })]
393
397
  }));
394
- let E = (e) => {
398
+ let ee = (e) => {
395
399
  let t = e.metadata?.icon;
396
400
  return t === "macro" ? B(b, {
397
401
  iconKey: "ScriptMacro",
@@ -406,14 +410,13 @@ var fe = r(n((e, t) => {
406
410
  };
407
411
  return V(u, {
408
412
  ref: t,
409
- className: G(o, "script-select"),
413
+ className: W(s, "script-select"),
410
414
  sx: {
411
415
  background: (e) => e.palette.background.paper,
412
416
  zIndex: 1e3,
413
- backgroundImage: F,
414
- ...i
417
+ ...o
415
418
  },
416
- ...h,
419
+ ...g,
417
420
  children: [V(u, {
418
421
  className: "script-select-content",
419
422
  sx: {
@@ -425,36 +428,37 @@ var fe = r(n((e, t) => {
425
428
  B(m, {
426
429
  variant: "h6",
427
430
  gutterBottom: !0,
428
- children: g("templateSelect.title")
431
+ children: _("templateSelect.title")
429
432
  }),
430
433
  B(m, {
431
434
  variant: "body2",
432
435
  component: "div",
433
436
  gutterBottom: !0,
434
437
  sx: { color: "text.secondary" },
435
- children: g("templateSelect.intro")
438
+ children: _("templateSelect.intro")
436
439
  }),
437
440
  B(m, {
438
441
  variant: "body2",
439
442
  component: "div",
440
443
  gutterBottom: !0,
441
444
  sx: { color: "text.secondary" },
442
- children: g("templateSelect.intro2")
445
+ children: _("templateSelect.intro2")
443
446
  }),
444
447
  B(u, {
445
448
  sx: {
446
449
  display: "grid",
447
- gridTemplateColumns: `repeat(auto-fill, minmax(${s}px, 1fr))`,
448
- gap: `${p}px`,
450
+ gridTemplateColumns: `repeat(auto-fill, minmax(${c}px, 1fr))`,
451
+ gap: `${h}px`,
449
452
  padding: 2,
450
453
  paddingLeft: "0px",
451
454
  paddingRight: "0px"
452
455
  },
453
- children: _.map((e, t) => V(d, {
456
+ children: v.map((e, t) => V(d, {
454
457
  variant: "outlined",
458
+ disabled: i,
455
459
  sx: {
456
- minWidth: s,
457
- minHeight: c,
460
+ minWidth: c,
461
+ minHeight: p,
458
462
  display: "flex",
459
463
  flexDirection: "column",
460
464
  justifyContent: "flex-start",
@@ -482,8 +486,8 @@ var fe = r(n((e, t) => {
482
486
  children: [B(m, {
483
487
  variant: "subtitle2",
484
488
  component: "div",
485
- children: e.metadata?.title || e.path?.split("/").pop()?.replace(/\.\w+$/, "") || g("templateSelect.untitled")
486
- }), E(e)]
489
+ children: e.metadata?.title || e.path?.split("/").pop()?.replace(/\.\w+$/, "") || _("templateSelect.untitled")
490
+ }), ee(e)]
487
491
  }), e.metadata?.summary && B(m, {
488
492
  variant: "body2",
489
493
  component: "div",
@@ -500,10 +504,10 @@ var fe = r(n((e, t) => {
500
504
  }, `${e.path}-${t}`))
501
505
  })
502
506
  ]
503
- }), T]
507
+ }), E]
504
508
  });
505
509
  }));
506
- fe.displayName = "TemplateSelectPanel";
510
+ me.displayName = "TemplateSelectPanel";
507
511
  var Q = r(n((e, t) => {
508
512
  let { className: n, sx: r, propsScriptEditor: s, readOnly: d = !1, frame: f, autoFocusSel: g, autoFocus: _ = !0, scripts: v, ...y } = e, b = h(), [x, S] = l(!1), w = c(!1), [T, D] = l({
509
513
  message: "Loading",
@@ -560,7 +564,7 @@ var Q = r(n((e, t) => {
560
564
  },
561
565
  children: B(Z, {})
562
566
  }), [b]), R = o(() => B(u, {
563
- className: G("script-status-panel", "status-panel"),
567
+ className: W("script-status-panel", "status-panel"),
564
568
  sx: {
565
569
  display: "flex",
566
570
  alignItems: "stretch",
@@ -629,7 +633,7 @@ var Q = r(n((e, t) => {
629
633
  ]
630
634
  })
631
635
  }), [T]), z = o(() => V(u, {
632
- className: G("script-editor-content"),
636
+ className: W("script-editor-content"),
633
637
  sx: {
634
638
  display: "flex",
635
639
  flex: "1 1 100%",
@@ -648,7 +652,7 @@ var Q = r(n((e, t) => {
648
652
  position: "relative",
649
653
  boxSizing: "border-box"
650
654
  },
651
- children: B(te, {
655
+ children: B(ne, {
652
656
  ref: j,
653
657
  loadingPanel: I,
654
658
  readOnly: d,
@@ -674,9 +678,9 @@ var Q = r(n((e, t) => {
674
678
  g,
675
679
  f,
676
680
  A
677
- ]), H = o(() => {
681
+ ]), te = o(() => {
678
682
  let e;
679
- return O === null ? I : (O.source === null && (e = B(fe, {
683
+ return O === null ? I : (O.source === null && (e = B(me, {
680
684
  sx: {
681
685
  display: "flex",
682
686
  flex: "1 1 100%",
@@ -687,12 +691,13 @@ var Q = r(n((e, t) => {
687
691
  width: "100%",
688
692
  height: "100%"
689
693
  },
694
+ disabled: d,
690
695
  onScriptSelect: (e) => {
691
696
  j.current?.insertSnippet(e.content), k({ source: e.content ?? "" }), requestAnimationFrame(() => j.current?.focus());
692
697
  }
693
698
  })), B(u, {
694
699
  tabIndex: 0,
695
- className: G("script-workspace", n),
700
+ className: W("script-workspace", n),
696
701
  sx: {
697
702
  display: "flex",
698
703
  flex: "1 1 100%",
@@ -729,8 +734,9 @@ var Q = r(n((e, t) => {
729
734
  z,
730
735
  n,
731
736
  O,
732
- I
733
- ]), U = E(t, () => ({
737
+ I,
738
+ d
739
+ ]), H = E(t, () => ({
734
740
  isScriptWorkspaceElement: () => !0,
735
741
  focus: (e) => {
736
742
  F(e);
@@ -744,50 +750,52 @@ var Q = r(n((e, t) => {
744
750
  position: "relative",
745
751
  ...r
746
752
  },
747
- ref: U,
753
+ ref: H,
748
754
  ...y,
749
755
  onFocus: (e) => {
750
- S(!0), w.current = !0, U.current?.contains(e.target) && e.target !== U.current && N(e.target), e.relatedTarget && !P.current && (P.current = e.relatedTarget), y?.onFocus?.(e);
756
+ S(!0), w.current = !0, H.current?.contains(e.target) && e.target !== H.current && N(e.target), e.relatedTarget && !P.current && (P.current = e.relatedTarget), y?.onFocus?.(e);
751
757
  },
752
758
  onBlur: (e) => {
753
- U?.current?.contains(e.relatedTarget) || U?.current === e.relatedTarget || (P.current = null, w.current = !1, S(!1)), y?.onBlur?.(e);
759
+ H?.current?.contains(e.relatedTarget) || H?.current === e.relatedTarget || (P.current = null, w.current = !1, S(!1)), y?.onBlur?.(e);
754
760
  },
755
- children: H
761
+ children: te
756
762
  });
757
763
  }));
758
764
  Q.displayName = "ScriptWorkspace";
759
- var { FocusActivation: pe, CommandScopeProvider: me, CommandAnchorProvider: he, useCommandScope: ge } = g, _e = { scopeName: "scriptEditor" }, ve = ({ children: e }) => {
760
- let t = ge(), n = c(null);
761
- return t ? B(me, {
762
- spec: _e,
765
+ var { FocusActivation: he, CommandScopeProvider: ge, CommandAnchorProvider: _e, useCommandScope: ve } = g, ye = { scopeName: "scriptEditor" }, be = ({ children: e }) => {
766
+ let t = ve(), n = c(null);
767
+ return t ? B(ge, {
768
+ spec: ye,
763
769
  elementRef: n,
764
770
  region: !0,
765
- children: B(ye, {
771
+ children: B(xe, {
766
772
  paneRef: n,
767
773
  children: e
768
774
  })
769
775
  }) : e;
770
- }, ye = ({ paneRef: e, children: t }) => {
771
- let n = ge(), r = o(() => n ? new pe(n.getRoot(), n) : null, [n]);
772
- return r ? V(he, {
776
+ }, xe = ({ paneRef: e, children: t }) => {
777
+ let n = ve(), r = o(() => n ? new he(n.getRoot(), n) : null, [n]);
778
+ return r ? V(_e, {
773
779
  tracker: r,
774
780
  keyBindings: !1,
775
781
  debounce: 100,
776
782
  elementRef: e,
777
- children: [B(L, {}), B("div", {
783
+ children: [B(I, {}), B("div", {
778
784
  className: "script-editor-pane",
779
785
  style: { display: "contents" },
780
786
  ref: e,
781
787
  children: t
782
788
  })]
783
789
  }) : t;
784
- }, be = (e) => {
785
- let { model: t, entryKey: n, frame: r, ref: i, ...a } = e;
786
- return B(ve, { children: B(Q, {
790
+ }, Se = (e) => {
791
+ let { model: t, entryKey: n, frame: r, ref: i, ...a } = e, o = R() ?? t;
792
+ L(o, ["onProtectionChange"]);
793
+ let s = o?.getScripts().isReadOnly() ?? !1;
794
+ return B(be, { children: B(Q, {
787
795
  ref: i,
788
- readOnly: !1,
796
+ readOnly: s,
789
797
  frame: r,
790
- scripts: (R() ?? t)?.getScripts(),
798
+ scripts: o?.getScripts(),
791
799
  ...a
792
800
  }) });
793
801
  }, $ = r((e) => {
@@ -812,10 +820,10 @@ var { FocusActivation: pe, CommandScopeProvider: me, CommandAnchorProvider: he,
812
820
  c,
813
821
  o,
814
822
  r
815
- ]), u ? V(z, { children: [B(j, {}), B(ae, { ...n })] }) : null;
823
+ ]), u ? V(z, { children: [B(j, {}), B(K, { ...n })] }) : null;
816
824
  });
817
- $.displayName = "RunScriptContribution", q();
818
- var xe = r(n((e, n) => {
825
+ $.displayName = "RunScriptContribution", G();
826
+ var Ce = r(n((e, n) => {
819
827
  let { ...r } = e, i = R(), o = D(), [s, c] = l([]);
820
828
  a(() => {
821
829
  let e = i?.getScripts();
@@ -872,36 +880,36 @@ var xe = r(n((e, n) => {
872
880
  children: m
873
881
  });
874
882
  }));
875
- xe.displayName = "InsertFunctionPopupPanel";
876
- var Se = r(n((e, t) => {
877
- let { disabled: n, groupKey: r, ...a } = e, o = w("customFunctionOptions");
883
+ Ce.displayName = "InsertFunctionPopupPanel";
884
+ var we = r(n((e, t) => {
885
+ let { disabled: n, groupKey: r, ...a } = e, o = w("customFunctionOptions"), s = i((e) => {
886
+ let t = B(Ce, {
887
+ disabled: n,
888
+ groupKey: r,
889
+ ...e
890
+ });
891
+ return P({
892
+ ...e,
893
+ children: t
894
+ });
895
+ }, [n, r]);
878
896
  return B(k, {
879
897
  ref: t,
880
898
  disabled: n,
881
- createPopupPanel: i((e) => {
882
- let t = B(xe, {
883
- disabled: n,
884
- groupKey: r,
885
- ...e
886
- });
887
- return P({
888
- ...e,
889
- children: t
890
- });
891
- }, [n, r]),
899
+ createPopupPanel: s,
892
900
  label: o?.getLabel?.(),
893
901
  tooltip: o?.getDescription?.(),
894
902
  icon: "FormulaCustom",
895
903
  ...a
896
904
  });
897
905
  }));
898
- Se.displayName = "InsertFunctionContribution";
899
- var Ce = () => {
900
- ne(), y.register("plugin-scripts", { icons: {} }), I.registerTaskPane({
906
+ we.displayName = "InsertFunctionContribution";
907
+ var Te = () => {
908
+ re(), y.register("plugin-scripts", { icons: {} }), F.registerTaskPane({
901
909
  key: "scriptEditor",
902
910
  getTitle: () => "Script (Typescript)",
903
911
  getIcon: () => "ScriptRun",
904
- component: be,
912
+ component: Se,
905
913
  keepMounted: !0
906
914
  }, !0), v.register({ key: "scriptsOptions" }, !0), v.register({ key: "customFunctionOptions" }, !0), v.register({
907
915
  key: "scripting.runScript.home",
@@ -921,7 +929,7 @@ var Ce = () => {
921
929
  anchor: "formulaCategory.web",
922
930
  order: 1
923
931
  } },
924
- render: (t) => e.createElement(Se, { ...t })
932
+ render: (t) => e.createElement(we, { ...t })
925
933
  }, !0);
926
934
  };
927
- export { de as InsertScriptCommandButton, ae as RunScriptCommandButton, Z as ScriptEditorToolbar, be as ScriptTaskPane, Q as ScriptWorkspace, Ce as ScriptingPlugin };
935
+ export { pe as InsertScriptCommandButton, K as RunScriptCommandButton, Z as ScriptEditorToolbar, Se as ScriptTaskPane, Q as ScriptWorkspace, Te as ScriptingPlugin };