x-block-lib 0.3.19 → 0.3.22

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.
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
@@ -3,12 +3,18 @@ interface Props {
3
3
  version: 'v1';
4
4
  active: boolean;
5
5
  }
6
- declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<Props>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ declare let __VLS_typeProps: Props;
7
+ type __VLS_PublicProps = {
8
+ 'lock': boolean;
9
+ } & typeof __VLS_typeProps;
10
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_PublicProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
11
+ "update:lock": (lock: boolean) => void;
7
12
  ready: (...args: any[]) => void;
8
13
  change: (...args: any[]) => void;
9
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<Props>>> & {
10
- onReady?: ((...args: any[]) => any) | undefined;
14
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_PublicProps>>> & {
11
15
  onChange?: ((...args: any[]) => any) | undefined;
16
+ onReady?: ((...args: any[]) => any) | undefined;
17
+ "onUpdate:lock"?: ((lock: boolean) => any) | undefined;
12
18
  }, {}, {}>;
13
19
  export default _default;
14
20
 
@@ -0,0 +1,18 @@
1
+ type __VLS_PublicProps = {
2
+ modelValue: boolean;
3
+ };
4
+ declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<__VLS_PublicProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
5
+ "update:modelValue": (modelValue: boolean) => void;
6
+ }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<__VLS_PublicProps>>> & {
7
+ "onUpdate:modelValue"?: ((modelValue: boolean) => any) | undefined;
8
+ }, {}, {}>;
9
+ export default _default;
10
+ type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
11
+ type __VLS_TypePropsToOption<T> = {
12
+ [K in keyof T]-?: {} extends Pick<T, K> ? {
13
+ type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
14
+ } : {
15
+ type: import('vue').PropType<T[K]>;
16
+ required: true;
17
+ };
18
+ };
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}, {}>;
2
+ export default _default;
package/dist/index.js CHANGED
@@ -1,9 +1,10 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.id="x-block-lib",e.appendChild(document.createTextNode(".blocklyToolboxDiv{overflow-x:hidden;width:56px}")),document.head.appendChild(e)}}catch(d){console.error("vite-plugin-css-injected-by-js",d)}})();
2
- import { defineComponent as A, ref as N, onMounted as D, onBeforeUnmount as M, watch as C, resolveDirective as V, openBlock as U, createElementBlock as Y, withDirectives as G, createElementVNode as W } from "vue";
3
- import { storeToRefs as H } from "pinia";
4
- import { openConfirmDlg as z, openPromptDlg as X, useGlobalStore as J, useViewStack as j } from "x-essential-lib";
5
- import { d as h, j as $, O as q, E as p, u as i, M as f, C as Q, a as d, b as R, s as Z, S as u, c as L, g as O, i as m, e as I, f as b, h as g, k as B, G as v, B as ee, T as k, l as x, m as te, n as oe, o as ne } from "./blockly-kru4jhu1.js";
6
- h([
1
+ (function(){"use strict";try{if(typeof document<"u"){var o=document.createElement("style");o.id="x-block-lib",o.appendChild(document.createTextNode(".blocklyToolboxDiv{overflow-x:hidden;width:56px}.blocklyMainBackground{stroke-width:0}.blocklyToolboxCategory{margin-bottom:10px}.blocklyTreeRow{height:28px;display:flex;align-items:center;border-left-width:6px!important;border-right-width:6px!important}.blocklyTreeIcon{display:none!important}.blocklyFlyout{z-index:21}")),document.head.appendChild(o)}}catch(e){console.error("vite-plugin-css-injected-by-js",e)}})();
2
+ import { defineComponent as B, resolveComponent as b, openBlock as O, createBlock as F, unref as S, useModel as X, computed as I, withCtx as U, createVNode as h, mergeProps as se, createElementVNode as V, normalizeStyle as E, mergeModels as H, ref as Y, onMounted as le, onBeforeUnmount as ae, watch as L, resolveDirective as ie, createElementBlock as R, withDirectives as ce, createCommentVNode as G } from "vue";
3
+ import { storeToRefs as ue } from "pinia";
4
+ import { openConfirmDlg as _e, openPromptDlg as pe, useGlobalStore as fe, useViewStack as de } from "x-essential-lib";
5
+ import { d as C, j as ye, O as ge, E as p, u as i, M as f, C as me, a as y, b as j, s as he, S as u, c as w, g as k, i as T, e as K, f as v, h as m, k as W, G as M, B as be, T as x, l as J, m as $, n as Oe, o as Ce } from "./blockly-kru4jhu1.js";
6
+ var ke = "M19.36,2.72L20.78,4.14L15.06,9.85C16.13,11.39 16.28,13.24 15.38,14.44L9.06,8.12C10.26,7.22 12.11,7.37 13.65,8.44L19.36,2.72M5.93,17.57C3.92,15.56 2.69,13.16 2.35,10.92L7.23,8.83L14.67,16.27L12.58,21.15C10.34,20.81 7.94,19.58 5.93,17.57Z", ve = "M19,4H15.5L14.5,3H9.5L8.5,4H5V6H19M6,19A2,2 0 0,0 8,21H16A2,2 0 0,0 18,19V7H6V19Z", Se = "M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z", Le = "M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V10A2,2 0 0,1 6,8H15V6A3,3 0 0,0 12,3A3,3 0 0,0 9,6H7A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,17A2,2 0 0,0 14,15A2,2 0 0,0 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17Z", Te = "M21 3L3 10.53V11.5L9.84 14.16L12.5 21H13.46L21 3Z";
7
+ C([
7
8
  {
8
9
  type: "boolean_v1",
9
10
  message0: "%1",
@@ -23,10 +24,10 @@ h([
23
24
  helpUrl: "%{BKY_LOGIC_V1_BOOLEAN_HELPURL}"
24
25
  }
25
26
  ]);
26
- $.forBlock.boolean_v1 = function(t) {
27
- return [t.getFieldValue("BOOL") === "TRUE" ? "true" : "false", q.ATOMIC];
27
+ ye.forBlock.boolean_v1 = function(t) {
28
+ return [t.getFieldValue("BOOL") === "TRUE" ? "true" : "false", ge.ATOMIC];
28
29
  };
29
- const re = {
30
+ const Ie = {
30
31
  elseIfCount_: 0,
31
32
  hasElse_: !1,
32
33
  mutationToDom: function() {
@@ -150,11 +151,11 @@ const re = {
150
151
  };
151
152
  p.registerMutator(
152
153
  "if_v1_mutator",
153
- re,
154
+ Ie,
154
155
  void 0,
155
156
  ["if_else_if_v1", "if_else_v1"]
156
157
  );
157
- h([
158
+ C([
158
159
  {
159
160
  type: "if_v1",
160
161
  message0: "%{BKY_LOGIC_IF} %1",
@@ -202,7 +203,7 @@ h([
202
203
  style: "logic_blocks"
203
204
  }
204
205
  ]);
205
- const se = {
206
+ const Ee = {
206
207
  customContextMenu: function(t) {
207
208
  if (this.isInFlyout)
208
209
  return;
@@ -217,14 +218,14 @@ const se = {
217
218
  t.push({
218
219
  enabled: !0,
219
220
  text: f.VARIABLES_SET_CREATE_GET.replace("%1", o),
220
- callback: Q.callbackFactory(this, r)
221
+ callback: me.callbackFactory(this, r)
221
222
  });
222
223
  }
223
224
  }
224
225
  };
225
226
  p.registerMixin(
226
227
  "contextMenu_newGetVariableBlock_v1",
227
- se
228
+ Ee
228
229
  );
229
230
  p.register(
230
231
  "flow_control_tooltip_v1",
@@ -233,16 +234,16 @@ p.register(
233
234
  CONTINUE: "%{BKY_LOOP_V1_FLOW_CONTROL_TOOLTIP_CONTINUE}"
234
235
  })
235
236
  );
236
- const ae = /* @__PURE__ */ new Set([
237
+ const Be = /* @__PURE__ */ new Set([
237
238
  "repeat_v1",
238
239
  "for_each_v1",
239
240
  "for_v1",
240
241
  "while_until_v1"
241
- ]), le = {
242
+ ]), xe = {
242
243
  getSurroundLoop: function() {
243
244
  let t = this;
244
245
  do {
245
- if (ae.has(t.type))
246
+ if (Be.has(t.type))
246
247
  return !0;
247
248
  t = t == null ? void 0 : t.getSurroundParent();
248
249
  } while (t);
@@ -250,24 +251,24 @@ const ae = /* @__PURE__ */ new Set([
250
251
  },
251
252
  onchange: function(t) {
252
253
  const e = this.workspace;
253
- if (!e.isDragging || e.isDragging() || t.type !== d.BLOCK_MOVE && t.type !== d.BLOCK_CREATE)
254
+ if (!e.isDragging || e.isDragging() || t.type !== y.BLOCK_MOVE && t.type !== y.BLOCK_CREATE)
254
255
  return;
255
256
  const n = this.getSurroundLoop();
256
257
  if (console.log(t.type, n), this.setWarningText(
257
258
  n ? null : f.LOOP_FLOW_CONTROL_WARNING
258
259
  ), !this.isInFlyout)
259
260
  try {
260
- d.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
261
+ y.setRecordUndo(!1), this.setDisabledReason(!n, "FLOW_CONTROL_NOT_IN_LOOP");
261
262
  } finally {
262
- d.setRecordUndo(!0);
263
+ y.setRecordUndo(!0);
263
264
  }
264
265
  }
265
266
  };
266
267
  p.registerMixin(
267
268
  "flow_control_in_loop_check_v1",
268
- le
269
+ xe
269
270
  );
270
- h([
271
+ C([
271
272
  {
272
273
  type: "flow_control_v1",
273
274
  message0: "%1",
@@ -295,7 +296,7 @@ p.register(
295
296
  "VAR"
296
297
  )
297
298
  );
298
- h([
299
+ C([
299
300
  {
300
301
  type: "for_v1",
301
302
  message0: "%{BKY_LOOP_V1_FOR_TITLE}",
@@ -346,7 +347,7 @@ p.register(
346
347
  "VAR"
347
348
  )
348
349
  );
349
- h([
350
+ C([
350
351
  {
351
352
  type: "for_each_v1",
352
353
  message0: "%{BKY_LOOP_V1_FOR_EACH_TITLE}",
@@ -383,7 +384,7 @@ p.register(
383
384
  UNTIL: "%{BKY_LOOP_V1_WHILE_UNTIL_TOOLTIP_UNTIL}"
384
385
  })
385
386
  );
386
- h([
387
+ C([
387
388
  {
388
389
  type: "while_until_v1",
389
390
  message0: "%1 %2",
@@ -416,21 +417,21 @@ h([
416
417
  extensions: ["while_until_tooltip_v1"]
417
418
  }
418
419
  ]);
419
- R.setConfirm(async (t, e) => {
420
- const n = await z({
420
+ j.setConfirm(async (t, e) => {
421
+ const n = await _e({
421
422
  title: "",
422
423
  text: t
423
424
  });
424
425
  e(!!n);
425
426
  });
426
- R.setPrompt(async (t, e, n) => {
427
- const o = await X({
427
+ j.setPrompt(async (t, e, n) => {
428
+ const o = await pe({
428
429
  title: "",
429
430
  value: e
430
431
  });
431
432
  n(o);
432
433
  });
433
- const ie = (t, e, n) => {
434
+ const Ae = (t, e, n) => {
434
435
  const o = t[e];
435
436
  return o ? typeof o == "function" ? o() : Promise.resolve(o) : new Promise((r, s) => {
436
437
  (typeof queueMicrotask == "function" ? queueMicrotask : setTimeout)(
@@ -443,21 +444,21 @@ const ie = (t, e, n) => {
443
444
  );
444
445
  });
445
446
  };
446
- async function P(t) {
447
- const e = await ie(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-jrrs2wmb.js"), "./msg/zhHans/index.ts": () => import("./zhHans-jrrs2wmb.js") }), `./msg/${t}/index.ts`, 4);
448
- Z(e.default);
447
+ async function z(t) {
448
+ const e = await Ae(/* @__PURE__ */ Object.assign({ "./msg/en/index.ts": () => import("./en-jrrs2wmb.js"), "./msg/zhHans/index.ts": () => import("./zhHans-jrrs2wmb.js") }), `./msg/${t}/index.ts`, 4);
449
+ he(e.default);
449
450
  }
450
- class ce {
451
+ class Pe {
451
452
  init({ contextMenu: e = !0, shortcut: n = !0 } = {
452
453
  contextMenu: !0,
453
454
  shortcut: !0
454
455
  }) {
455
456
  e && (this.blockCopyToStorageContextMenu(), this.blockPasteFromStorageContextMenu()), n && (u.registry.unregister(
456
- L.names.COPY
457
+ w.names.COPY
457
458
  ), u.registry.unregister(
458
- L.names.CUT
459
+ w.names.CUT
459
460
  ), u.registry.unregister(
460
- L.names.PASTE
461
+ w.names.PASTE
461
462
  ), this.blockCopyToStorageShortcut(), this.blockCutToStorageShortcut(), this.blockPasteFromStorageShortcut());
462
463
  }
463
464
  blockCopyToStorageContextMenu() {
@@ -466,8 +467,8 @@ class ce {
466
467
  return f.CROSS_TAB_COPY ? f.CROSS_TAB_COPY : "Copy";
467
468
  },
468
469
  preconditionFn: function() {
469
- const n = O();
470
- return !n || !m(n) || !n.isDeletable() || !I(n) || !n.isMovable() || !b(n) ? "disabled" : "enabled";
470
+ const n = k();
471
+ return !n || !T(n) || !n.isDeletable() || !K(n) || !n.isMovable() || !v(n) ? "disabled" : "enabled";
471
472
  },
472
473
  callback: function(n) {
473
474
  var o;
@@ -476,11 +477,11 @@ class ce {
476
477
  JSON.stringify((o = n.block) == null ? void 0 : o.toCopyData())
477
478
  );
478
479
  },
479
- scopeType: g.ScopeType.BLOCK,
480
+ scopeType: m.ScopeType.BLOCK,
480
481
  id: "blockCopyToStorage",
481
482
  weight: 0
482
483
  };
483
- g.registry.register(e);
484
+ m.registry.register(e);
484
485
  }
485
486
  blockPasteFromStorageContextMenu() {
486
487
  const e = {
@@ -500,13 +501,13 @@ class ce {
500
501
  if (!o)
501
502
  return;
502
503
  const r = JSON.parse(o);
503
- r && n.workspace && B.paste(r, n.workspace);
504
+ r && n.workspace && W.paste(r, n.workspace);
504
505
  },
505
- scopeType: g.ScopeType.WORKSPACE,
506
+ scopeType: m.ScopeType.WORKSPACE,
506
507
  id: "blockPasteFromStorage",
507
508
  weight: 0
508
509
  };
509
- g.registry.register(e);
510
+ m.registry.register(e);
510
511
  }
511
512
  blockCopyToStorageShortcut() {
512
513
  const e = u.registry.createSerializedKey(
@@ -521,18 +522,18 @@ class ce {
521
522
  ), r = {
522
523
  name: "copy",
523
524
  preconditionFn: function(s) {
524
- if (s.options.readOnly || v.inProgress())
525
+ if (s.options.readOnly || M.inProgress())
525
526
  return !1;
526
- const a = O();
527
- return !(!a || !m(a) || !a.isDeletable() || !I(a) || !a.isMovable() || !b(a));
527
+ const l = k();
528
+ return !(!l || !T(l) || !l.isDeletable() || !K(l) || !l.isMovable() || !v(l));
528
529
  },
529
- callback: function(s, a) {
530
- a.preventDefault();
531
- const l = O();
532
- if (!l || !b(l))
530
+ callback: function(s, l) {
531
+ l.preventDefault();
532
+ const a = k();
533
+ if (!a || !v(a))
533
534
  return !1;
534
- const c = l.toCopyData();
535
- return c ? (s.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(c)), !0) : !1;
535
+ const _ = a.toCopyData();
536
+ return _ ? (s.hideChaff(), localStorage.setItem("blocklyStash", JSON.stringify(_)), !0) : !1;
536
537
  },
537
538
  keyCodes: [e, n, o]
538
539
  };
@@ -551,18 +552,18 @@ class ce {
551
552
  ), r = {
552
553
  name: "cut",
553
554
  preconditionFn: function(s) {
554
- if (s.options.readOnly || v.inProgress())
555
+ if (s.options.readOnly || M.inProgress())
555
556
  return !1;
556
- const a = O();
557
- return !(!a || !m(a) || !a.isDeletable() || !I(a) || !a.isMovable() || !b(a) || a.workspace.isFlyout);
557
+ const l = k();
558
+ return !(!l || !T(l) || !l.isDeletable() || !K(l) || !l.isMovable() || !v(l) || l.workspace.isFlyout);
558
559
  },
559
- callback: function(s, a) {
560
- a.preventDefault();
561
- const l = O();
562
- if (!l || !m(l) || !l.isDeletable() || !b(l))
560
+ callback: function(s, l) {
561
+ l.preventDefault();
562
+ const a = k();
563
+ if (!a || !T(a) || !a.isDeletable() || !v(a))
563
564
  return !1;
564
- const c = l.toCopyData();
565
- return c ? (localStorage.setItem("blocklyStash", JSON.stringify(c)), l instanceof ee ? l.checkAndDelete() : l.dispose(), !0) : !1;
565
+ const _ = a.toCopyData();
566
+ return _ ? (localStorage.setItem("blocklyStash", JSON.stringify(_)), a instanceof be ? a.checkAndDelete() : a.dispose(), !0) : !1;
566
567
  },
567
568
  keyCodes: [e, n, o]
568
569
  };
@@ -581,67 +582,67 @@ class ce {
581
582
  ), r = {
582
583
  name: "paste",
583
584
  preconditionFn: function(s) {
584
- if (s.options.readOnly || v.inProgress())
585
+ if (s.options.readOnly || M.inProgress())
585
586
  return !1;
586
- const a = localStorage.getItem("blocklyStash");
587
- if (!a)
588
- return !1;
589
- const l = JSON.parse(a);
590
- return !(!l || !s.isCapacityAvailable(l.typeCounts));
591
- },
592
- callback: function(s, a) {
593
- a.preventDefault();
594
587
  const l = localStorage.getItem("blocklyStash");
595
588
  if (!l)
596
589
  return !1;
597
- const c = JSON.parse(l);
598
- return c ? (B.paste(c, s), !0) : !1;
590
+ const a = JSON.parse(l);
591
+ return !(!a || !s.isCapacityAvailable(a.typeCounts));
592
+ },
593
+ callback: function(s, l) {
594
+ l.preventDefault();
595
+ const a = localStorage.getItem("blocklyStash");
596
+ if (!a)
597
+ return !1;
598
+ const _ = JSON.parse(a);
599
+ return _ ? (W.paste(_, s), !0) : !1;
599
600
  },
600
601
  keyCodes: [e, n, o]
601
602
  };
602
603
  u.registry.register(r);
603
604
  }
604
605
  }
605
- class ue {
606
+ class Re {
606
607
  init() {
607
- const e = g.registry.getItem("cleanWorkspace");
608
+ const e = m.registry.getItem("cleanWorkspace");
608
609
  e && (e.callback = function(n) {
609
610
  const o = n.workspace;
610
611
  if (!o)
611
612
  return;
612
- o.setResizesEnabled(!1), d.setGroup(!0);
613
+ o.setResizesEnabled(!1), y.setGroup(!0);
613
614
  const r = o.getTopBlocks(!0);
614
615
  let s = 0;
615
- for (let a = 0, l; l = r[a]; a++) {
616
- if (!l.isMovable())
616
+ for (let l = 0, a; a = r[l]; l++) {
617
+ if (!a.isMovable())
617
618
  continue;
618
- const c = l.getRelativeToSurfaceXY();
619
- l.moveBy(-c.x, s - c.y, ["cleanup"]), l.snapToGrid(), s = l.getRelativeToSurfaceXY().y + l.getHeightWidth().height + 100;
619
+ const _ = a.getRelativeToSurfaceXY();
620
+ a.moveBy(-_.x, s - _.y, ["cleanup"]), a.snapToGrid(), s = a.getRelativeToSurfaceXY().y + a.getHeightWidth().height + 100;
620
621
  }
621
- d.setGroup(!1), o.setResizesEnabled(!0);
622
+ y.setGroup(!1), o.setResizesEnabled(!0);
622
623
  });
623
624
  }
624
625
  }
625
- function K(t) {
626
+ function Z(t) {
626
627
  const e = t.getParent();
627
- return e && K(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
628
+ return e && Z(e) ? !0 : !e && !!(t.outputConnection || t.previousConnection);
628
629
  }
629
- class _e {
630
+ class we {
630
631
  init() {
631
- const e = g.registry.getItem("blockDisable");
632
+ const e = m.registry.getItem("blockDisable");
632
633
  e && (e.preconditionFn = function(n) {
633
634
  const o = n.block;
634
- return o && !o.isInFlyout && o.workspace.options.disable && o.isEditable() ? o.getInheritedDisabled() || K(o) ? "disabled" : "enabled" : "hidden";
635
+ return o && !o.isInFlyout && o.workspace.options.disable && o.isEditable() ? o.getInheritedDisabled() || Z(o) ? "disabled" : "enabled" : "hidden";
635
636
  });
636
637
  }
637
638
  }
638
- const pe = new ce();
639
- pe.init({ contextMenu: !0, shortcut: !0 });
640
- const fe = new ue();
641
- fe.init();
642
- const ye = new _e();
643
- ye.init();
644
- k.Classic.blockStyles = {
639
+ const Ke = new Pe();
640
+ Ke.init({ contextMenu: !0, shortcut: !0 });
641
+ const Me = new Re();
642
+ Me.init();
643
+ const Ve = new we();
644
+ Ve.init();
645
+ x.Classic.blockStyles = {
645
646
  color_blocks: {
646
647
  colourPrimary: "#a5745b",
647
648
  colourSecondary: "#ede3de",
@@ -715,7 +716,7 @@ k.Classic.blockStyles = {
715
716
  hat: ""
716
717
  }
717
718
  };
718
- k.Classic.categoryStyles = {
719
+ x.Classic.categoryStyles = {
719
720
  calc_category: {
720
721
  colour: "#757575"
721
722
  },
@@ -765,9 +766,9 @@ k.Classic.categoryStyles = {
765
766
  colour: "#a55b80"
766
767
  }
767
768
  };
768
- const de = x.defineTheme("light", {
769
+ const Fe = J.defineTheme("light", {
769
770
  name: "light",
770
- base: k.Classic,
771
+ base: x.Classic,
771
772
  componentStyles: {
772
773
  workspaceBackgroundColour: "#ffffff",
773
774
  toolboxBackgroundColour: "#eeeeee",
@@ -781,9 +782,9 @@ const de = x.defineTheme("light", {
781
782
  scrollbarOpacity: 0.4,
782
783
  cursorColour: ""
783
784
  }
784
- }), ge = x.defineTheme("dark", {
785
+ }), Ne = J.defineTheme("dark", {
785
786
  name: "dark",
786
- base: k.Classic,
787
+ base: x.Classic,
787
788
  componentStyles: {
788
789
  workspaceBackgroundColour: "#1e1e1e",
789
790
  toolboxBackgroundColour: "#272727",
@@ -798,18 +799,18 @@ const de = x.defineTheme("light", {
798
799
  cursorColour: ""
799
800
  }
800
801
  });
801
- function he(t) {
802
- const e = te();
802
+ function De(t) {
803
+ const e = $();
803
804
  switch (console.log(e), t) {
804
805
  case "light":
805
- e.setTheme(de);
806
+ e.setTheme(Fe);
806
807
  break;
807
808
  case "dark":
808
- e.setTheme(ge);
809
+ e.setTheme(Ne);
809
810
  break;
810
811
  }
811
812
  }
812
- const Oe = {
813
+ const Ue = {
813
814
  kind: "category",
814
815
  name: "%{BKY_CATEGORY_LOGIC}",
815
816
  categorystyle: "logic_category",
@@ -827,7 +828,7 @@ const Oe = {
827
828
  type: "if_v1"
828
829
  }
829
830
  ]
830
- }, be = {
831
+ }, He = {
831
832
  kind: "category",
832
833
  name: "%{BKY_CATEGORY_LOOP}",
833
834
  categorystyle: "loop_category",
@@ -849,21 +850,95 @@ const Oe = {
849
850
  type: "for_each_v1"
850
851
  }
851
852
  ]
852
- }, Ce = {
853
+ }, Ye = {
853
854
  kind: "categoryToolbox",
854
- contents: [Oe, be]
855
- }, me = { class: "position-relative w-100 h-100" }, ke = /* @__PURE__ */ A({
856
- __name: "index",
855
+ contents: [Ue, He]
856
+ }, Ge = /* @__PURE__ */ B({
857
+ __name: "cleanup",
858
+ setup(t) {
859
+ const e = () => {
860
+ const n = $();
861
+ if (!n)
862
+ return;
863
+ const o = m.registry.getItem("cleanWorkspace");
864
+ o && o.callback({ workspace: n }, new PointerEvent("dummy"));
865
+ };
866
+ return (n, o) => {
867
+ const r = b("v-btn");
868
+ return O(), F(r, {
869
+ onClick: e,
870
+ class: "mr-3",
871
+ variant: "outlined",
872
+ density: "comfortable",
873
+ icon: S(ke)
874
+ }, null, 8, ["icon"]);
875
+ };
876
+ }
877
+ }), We = /* @__PURE__ */ B({
878
+ __name: "lock",
857
879
  props: {
880
+ modelValue: { type: Boolean, required: !0 },
881
+ modelModifiers: {}
882
+ },
883
+ emits: ["update:modelValue"],
884
+ setup(t) {
885
+ const e = X(t, "modelValue");
886
+ return (n, o) => {
887
+ const r = b("v-btn");
888
+ return O(), F(r, {
889
+ onClick: o[0] || (o[0] = (s) => e.value = !e.value),
890
+ class: "mr-3",
891
+ variant: "outlined",
892
+ density: "comfortable",
893
+ icon: e.value ? S(Se) : S(Le)
894
+ }, null, 8, ["icon"]);
895
+ };
896
+ }
897
+ }), ze = /* @__PURE__ */ B({
898
+ __name: "navigator",
899
+ setup(t) {
900
+ const e = I(() => ({
901
+ maxHeight: "calc(100vh - 200px)"
902
+ }));
903
+ return (n, o) => {
904
+ const r = b("v-btn"), s = b("v-list"), l = b("v-menu");
905
+ return O(), F(l, {
906
+ "close-on-content-click": !1,
907
+ transition: "slide-y-transition",
908
+ "offset-y": ""
909
+ }, {
910
+ activator: U(({ props: a }) => [
911
+ h(r, se(a, {
912
+ variant: "outlined",
913
+ density: "comfortable",
914
+ icon: S(Te)
915
+ }), null, 16, ["icon"])
916
+ ]),
917
+ default: U(() => [
918
+ V("div", {
919
+ class: "overflow-auto",
920
+ style: E(e.value)
921
+ }, [
922
+ h(s)
923
+ ], 4)
924
+ ]),
925
+ _: 1
926
+ });
927
+ };
928
+ }
929
+ }), Xe = { class: "position-relative w-100 h-100" }, je = /* @__PURE__ */ B({
930
+ __name: "index",
931
+ props: /* @__PURE__ */ H({
858
932
  type: {},
859
933
  version: {},
860
934
  active: { type: Boolean }
861
- },
862
- emits: ["ready", "change"],
935
+ }, {
936
+ lock: { type: Boolean, required: !0 },
937
+ lockModifiers: {}
938
+ }),
939
+ emits: /* @__PURE__ */ H(["ready", "change"], ["update:lock"]),
863
940
  setup(t, { emit: e }) {
864
- const n = J(), { locale: o, dark: r } = H(n), { open: s } = j("blocklyEditorFlyout"), a = t, l = e, c = N();
865
- let y;
866
- const E = {
941
+ const n = fe(), { locale: o, dark: r } = ue(n), { open: s } = de("blocklyEditorFlyout"), l = t, a = X(t, "lock"), _ = e, A = Y(), N = {
867
942
  grid: {
868
943
  length: 2,
869
944
  snap: !0,
@@ -886,48 +961,99 @@ const Oe = {
886
961
  wheel: !0
887
962
  }
888
963
  };
889
- D(async () => {
890
- if (!c.value)
964
+ let g;
965
+ const P = Y(!1), q = I(() => ({
966
+ position: "absolute",
967
+ background: r.value ? "#0000007f" : "#ffffff7f",
968
+ top: "1px",
969
+ left: "0px",
970
+ width: "56px",
971
+ height: "100%",
972
+ pointerEvents: "none",
973
+ zIndex: 999
974
+ })), Q = I(() => ({
975
+ position: "absolute",
976
+ background: r.value ? "#0000007f" : "#ffffff7f",
977
+ top: "0px",
978
+ left: "0px",
979
+ width: "100%",
980
+ height: "100%",
981
+ pointerEvents: "none"
982
+ })), ee = I(() => ({
983
+ position: "absolute",
984
+ top: "0px",
985
+ right: "0px",
986
+ zIndex: 20
987
+ }));
988
+ le(async () => {
989
+ if (!A.value)
891
990
  return;
892
- await P(o.value);
893
- let _;
894
- a.type === "app" && a.version === "v1" && (_ = Ce), E.toolbox = _, y = oe(c.value, E), y.addChangeListener(d.disableOrphans), y.addChangeListener(F), setTimeout(() => {
895
- S(), l("ready", y);
896
- }, 1);
897
- }), M(() => {
991
+ await z(o.value);
992
+ let c;
993
+ l.type === "app" && l.version === "v1" && (c = Ye), N.toolbox = c, g = Oe(A.value, N), g.addChangeListener(y.disableOrphans), g.addChangeListener(te), _("ready", g);
994
+ }), ae(() => {
898
995
  s.value = !1;
899
996
  });
900
- function S() {
901
- y && ne(y);
997
+ function D() {
998
+ g && Ce(g);
902
999
  }
903
- function F(_) {
904
- l("change", _);
1000
+ function te(c) {
1001
+ c.type === y.BLOCK_DRAG && (c.isStart ? P.value = !0 : P.value = !1), _("change", c);
905
1002
  }
906
- return C(o, (_) => {
907
- P(_);
908
- }), C(r, (_) => {
909
- he(_ ? "dark" : "light");
910
- }), C(s, (_) => {
911
- var T;
912
- _ || (T = y.getToolbox()) == null || T.clearSelection();
913
- }), C(() => a.active, (_) => {
914
- _ && setTimeout(() => S(), 0);
915
- }), (_, T) => {
916
- const w = V("resize");
917
- return U(), Y("div", me, [
918
- G(W("div", {
1003
+ return L(o, (c) => {
1004
+ z(c);
1005
+ }), L(r, (c) => {
1006
+ De(c ? "dark" : "light");
1007
+ }), L(s, (c) => {
1008
+ var d;
1009
+ c || (d = g.getToolbox()) == null || d.clearSelection();
1010
+ }), L(
1011
+ () => l.active,
1012
+ (c) => {
1013
+ c && setTimeout(() => D(), 0);
1014
+ }
1015
+ ), (c, d) => {
1016
+ const oe = b("v-icon"), ne = ie("resize");
1017
+ return O(), R("div", Xe, [
1018
+ ce(V("div", {
919
1019
  class: "w-100 h-100",
920
1020
  ref_key: "blocklyDiv",
921
- ref: c
1021
+ ref: A,
1022
+ id: "blocklyEditor"
922
1023
  }, null, 512), [
923
- [w, S]
924
- ])
1024
+ [ne, D]
1025
+ ]),
1026
+ P.value ? (O(), R("div", {
1027
+ key: 0,
1028
+ class: "d-flex flex-column align-center justify-center",
1029
+ style: E(q.value)
1030
+ }, [
1031
+ h(oe, {
1032
+ icon: S(ve),
1033
+ size: "x-large"
1034
+ }, null, 8, ["icon"])
1035
+ ], 4)) : G("", !0),
1036
+ a.value ? (O(), R("div", {
1037
+ key: 1,
1038
+ style: E(Q.value)
1039
+ }, null, 4)) : G("", !0),
1040
+ V("div", {
1041
+ class: "d-flex align-end pt-3 pr-3",
1042
+ style: E(ee.value)
1043
+ }, [
1044
+ h(Ge),
1045
+ h(We, {
1046
+ modelValue: a.value,
1047
+ "onUpdate:modelValue": d[0] || (d[0] = (re) => a.value = re)
1048
+ }, null, 8, ["modelValue"]),
1049
+ h(ze)
1050
+ ], 4)
925
1051
  ]);
926
1052
  };
927
1053
  }
928
- }), Se = (t) => {
929
- t.component("x-blockly", ke);
930
- }, Ee = { install: Se };
1054
+ }), Je = (t) => {
1055
+ t.component("x-blockly", je);
1056
+ }, et = { install: Je };
931
1057
  export {
932
- Ee as default
1058
+ et as default
933
1059
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-block-lib",
3
3
  "private": false,
4
- "version": "0.3.19",
4
+ "version": "0.3.22",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -49,5 +49,8 @@
49
49
  "vue-i18n": "^9.13.1",
50
50
  "vue-router": "4.4.0",
51
51
  "vue-tsc": "^2.0.26"
52
+ },
53
+ "dependencies": {
54
+ "@mdi/js": "^7.4.47"
52
55
  }
53
56
  }