clickgo 3.16.26 → 3.16.28

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.
Files changed (102) hide show
  1. package/README.md +1 -1
  2. package/dist/app/demo/app.js +4 -16
  3. package/dist/app/demo/config.json +4 -1
  4. package/dist/app/demo/form/control/arteditor/arteditor.js +7 -18
  5. package/dist/app/demo/form/control/button/button.js +2 -13
  6. package/dist/app/demo/form/control/check/check.js +3 -14
  7. package/dist/app/demo/form/control/content/content.js +3 -14
  8. package/dist/app/demo/form/control/daterange/daterange.js +1 -1
  9. package/dist/app/demo/form/control/delete/delete.js +3 -14
  10. package/dist/app/demo/form/control/dialog/dialog.js +2 -0
  11. package/dist/app/demo/form/control/dialog/dialog.xml +26 -12
  12. package/dist/app/demo/form/control/flow/flow.js +2 -13
  13. package/dist/app/demo/form/control/form/form.js +4 -15
  14. package/dist/app/demo/form/control/iconview/iconview.js +12 -29
  15. package/dist/app/demo/form/control/jodit/jodit.js +7 -18
  16. package/dist/app/demo/form/control/link/link.js +2 -13
  17. package/dist/app/demo/form/control/list/list.js +40 -52
  18. package/dist/app/demo/form/control/list/list.xml +20 -10
  19. package/dist/app/demo/form/control/map/map.js +17 -28
  20. package/dist/app/demo/form/control/menu/menu.js +6 -17
  21. package/dist/app/demo/form/control/mpegts/mpegts.js +1 -1
  22. package/dist/app/demo/form/control/nav/nav.js +6 -17
  23. package/dist/app/demo/form/control/novnc/novnc.js +75 -0
  24. package/dist/app/demo/form/control/novnc/novnc.xml +13 -0
  25. package/dist/app/demo/form/control/panel/panel.js +9 -20
  26. package/dist/app/demo/form/control/panel/test1.js +20 -41
  27. package/dist/app/demo/form/control/pdf/pdf.js +7 -20
  28. package/dist/app/demo/form/control/progress/progress.js +3 -12
  29. package/dist/app/demo/form/control/radio/radio.js +6 -17
  30. package/dist/app/demo/form/control/select/select.js +28 -41
  31. package/dist/app/demo/form/control/switch/switch.js +3 -14
  32. package/dist/app/demo/form/control/tab/tab.js +7 -18
  33. package/dist/app/demo/form/control/table/table.js +8 -23
  34. package/dist/app/demo/form/control/text/text.js +2 -13
  35. package/dist/app/demo/form/control/tuieditor/tuieditor.js +7 -18
  36. package/dist/app/demo/form/control/uploader/uploader.js +20 -31
  37. package/dist/app/demo/form/control/vflow/vflow.js +2 -13
  38. package/dist/app/demo/form/event/form/form.js +11 -22
  39. package/dist/app/demo/form/event/task/task.js +14 -29
  40. package/dist/app/demo/form/main.js +381 -387
  41. package/dist/app/demo/form/main.xml +3 -0
  42. package/dist/app/demo/form/method/acontrol/acontrol.js +2 -13
  43. package/dist/app/demo/form/method/aform/aform.js +41 -60
  44. package/dist/app/demo/form/method/aform/sd.js +3 -14
  45. package/dist/app/demo/form/method/core/core.js +25 -50
  46. package/dist/app/demo/form/method/dom/dom.js +35 -58
  47. package/dist/app/demo/form/method/form/form.js +106 -149
  48. package/dist/app/demo/form/method/fs/fs.js +126 -147
  49. package/dist/app/demo/form/method/native/native.js +44 -72
  50. package/dist/app/demo/form/method/storage/storage.js +9 -27
  51. package/dist/app/demo/form/method/system/system.js +16 -41
  52. package/dist/app/demo/form/method/task/task.js +18 -37
  53. package/dist/app/demo/form/method/theme/theme.js +39 -54
  54. package/dist/app/demo/form/method/tool/tool.js +22 -43
  55. package/dist/app/demo/form/method/tool/tool.xml +1 -1
  56. package/dist/app/demo/form/method/zip/zip.js +18 -29
  57. package/dist/app/demo/form/solution/backpanel/backpanel.js +10 -23
  58. package/dist/app/task/app.js +2 -13
  59. package/dist/app/task/form/bar/bar.js +32 -45
  60. package/dist/clickgo.js +1 -1
  61. package/dist/control/arteditor.cgc +0 -0
  62. package/dist/control/box.cgc +0 -0
  63. package/dist/control/captcha.cgc +0 -0
  64. package/dist/control/common.cgc +0 -0
  65. package/dist/control/desc.cgc +0 -0
  66. package/dist/control/drawer.cgc +0 -0
  67. package/dist/control/echarts.cgc +0 -0
  68. package/dist/control/form.cgc +0 -0
  69. package/dist/control/iconview.cgc +0 -0
  70. package/dist/control/jodit.cgc +0 -0
  71. package/dist/control/map.cgc +0 -0
  72. package/dist/control/monaco.cgc +0 -0
  73. package/dist/control/mpegts.cgc +0 -0
  74. package/dist/control/nav.cgc +0 -0
  75. package/dist/control/novnc.cgc +0 -0
  76. package/dist/control/page.cgc +0 -0
  77. package/dist/control/pdf.cgc +0 -0
  78. package/dist/control/property.cgc +0 -0
  79. package/dist/control/qrcode.cgc +0 -0
  80. package/dist/control/table.cgc +0 -0
  81. package/dist/control/task.cgc +0 -0
  82. package/dist/control/tplink.cgc +0 -0
  83. package/dist/control/tuieditor.cgc +0 -0
  84. package/dist/control/tuiviewer.cgc +0 -0
  85. package/dist/control/xterm.cgc +0 -0
  86. package/dist/index.js +59 -71
  87. package/dist/lib/control.js +213 -235
  88. package/dist/lib/core.js +356 -379
  89. package/dist/lib/dom.js +62 -91
  90. package/dist/lib/form.js +834 -906
  91. package/dist/lib/fs.js +834 -892
  92. package/dist/lib/native.js +32 -63
  93. package/dist/lib/storage.js +21 -33
  94. package/dist/lib/task.js +1054 -1098
  95. package/dist/lib/theme.js +102 -121
  96. package/dist/lib/tool.js +65 -98
  97. package/dist/lib/zip.js +27 -42
  98. package/dist/theme/blue.cgt +0 -0
  99. package/dist/theme/byterun.cgt +0 -0
  100. package/dist/theme/dark.cgt +0 -0
  101. package/dist/theme/light.cgt +0 -0
  102. package/package.json +1 -1
package/dist/lib/form.js CHANGED
@@ -32,15 +32,6 @@ var __importStar = (this && this.__importStar) || (function () {
32
32
  return result;
33
33
  };
34
34
  })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
35
  Object.defineProperty(exports, "__esModule", { value: true });
45
36
  exports.activePanels = exports.elements = exports.launcherRoot = exports.simpleSystemTaskRoot = exports.AbstractForm = exports.AbstractPanel = void 0;
46
37
  exports.superConfirm = superConfirm;
@@ -245,8 +236,7 @@ class AbstractCommon {
245
236
  }
246
237
  get l() {
247
238
  return (key, data) => {
248
- var _a, _b, _c, _d;
249
- const loc = (_d = (_b = (_a = task.list[this.taskId].locale.data[this.locale]) === null || _a === void 0 ? void 0 : _a[key]) !== null && _b !== void 0 ? _b : (_c = task.list[this.taskId].locale.data['en']) === null || _c === void 0 ? void 0 : _c[key]) !== null && _d !== void 0 ? _d : '[LocaleError]' + key;
239
+ const loc = task.list[this.taskId].locale.data[this.locale]?.[key] ?? task.list[this.taskId].locale.data['en']?.[key] ?? '[LocaleError]' + key;
250
240
  if (!data) {
251
241
  return loc;
252
242
  }
@@ -339,30 +329,23 @@ class AbstractPanel extends AbstractCommon {
339
329
  set formHashData(v) {
340
330
  this.rootForm.formHashData = v;
341
331
  }
342
- formHashBack() {
343
- return __awaiter(this, void 0, void 0, function* () {
344
- yield this.rootForm.formHashBack();
345
- });
332
+ async formHashBack() {
333
+ await this.rootForm.formHashBack();
346
334
  }
347
335
  sendToRootPanel(data) {
348
336
  this.rootPanel.send(data);
349
337
  }
350
- enterStep(list) {
351
- return __awaiter(this, void 0, void 0, function* () {
352
- return this.rootForm.enterStep(list);
353
- });
338
+ async enterStep(list) {
339
+ return this.rootForm.enterStep(list);
354
340
  }
355
- doneStep() {
356
- return __awaiter(this, void 0, void 0, function* () {
357
- yield this.rootForm.doneStep();
358
- });
341
+ async doneStep() {
342
+ await this.rootForm.doneStep();
359
343
  }
360
344
  clearQs() {
361
345
  this.qs = {};
362
346
  }
363
347
  get formFocus() {
364
- var _a;
365
- return (_a = this.rootForm.formFocus) !== null && _a !== void 0 ? _a : false;
348
+ return this.rootForm.formFocus ?? false;
366
349
  }
367
350
  onShow() {
368
351
  return;
@@ -435,50 +418,48 @@ class AbstractForm extends AbstractCommon {
435
418
  ready(cb) {
436
419
  cb();
437
420
  }
438
- formHashBack() {
439
- return __awaiter(this, void 0, void 0, function* () {
440
- const v = this;
441
- if (Date.now() - v.$data._lastFormHashData > 300) {
442
- v.$data._formHashData = {};
443
- }
444
- if (!v.$data._historyHash.length) {
445
- if (v.$data._formHash) {
446
- if (this.inStep) {
447
- if (!(yield clickgo.form.confirm({
448
- 'taskId': this.taskId,
449
- 'content': info.locale[this.locale].confirmExitStep
450
- }))) {
451
- return;
452
- }
453
- this._inStep = false;
454
- this.refs.form.stepHide();
455
- }
456
- v.$data._formHash = '';
457
- core.trigger('formHashChange', this.taskId, this.formId, '', v.$data._formHashData);
458
- return;
459
- }
460
- return;
461
- }
462
- const parent = v.$data._historyHash[v.$data._historyHash.length - 1];
463
- if (this.inStep) {
464
- if (this._stepValues.includes(parent)) {
465
- this.refs.form.stepValue = parent;
466
- }
467
- else {
468
- if (!(yield clickgo.form.confirm({
421
+ async formHashBack() {
422
+ const v = this;
423
+ if (Date.now() - v.$data._lastFormHashData > 300) {
424
+ v.$data._formHashData = {};
425
+ }
426
+ if (!v.$data._historyHash.length) {
427
+ if (v.$data._formHash) {
428
+ if (this.inStep) {
429
+ if (!await clickgo.form.confirm({
469
430
  'taskId': this.taskId,
470
431
  'content': info.locale[this.locale].confirmExitStep
471
- }))) {
432
+ })) {
472
433
  return;
473
434
  }
474
435
  this._inStep = false;
475
436
  this.refs.form.stepHide();
476
437
  }
438
+ v.$data._formHash = '';
439
+ core.trigger('formHashChange', this.taskId, this.formId, '', v.$data._formHashData);
440
+ return;
477
441
  }
478
- v.$data._formHash = parent;
479
- v.$data._historyHash.splice(-1);
480
- core.trigger('formHashChange', this.taskId, this.formId, parent, v.$data._formHashData);
481
- });
442
+ return;
443
+ }
444
+ const parent = v.$data._historyHash[v.$data._historyHash.length - 1];
445
+ if (this.inStep) {
446
+ if (this._stepValues.includes(parent)) {
447
+ this.refs.form.stepValue = parent;
448
+ }
449
+ else {
450
+ if (!await clickgo.form.confirm({
451
+ 'taskId': this.taskId,
452
+ 'content': info.locale[this.locale].confirmExitStep
453
+ })) {
454
+ return;
455
+ }
456
+ this._inStep = false;
457
+ this.refs.form.stepHide();
458
+ }
459
+ }
460
+ v.$data._formHash = parent;
461
+ v.$data._historyHash.splice(-1);
462
+ core.trigger('formHashChange', this.taskId, this.formId, parent, v.$data._formHashData);
482
463
  }
483
464
  sendToPanel(panel, data) {
484
465
  panel.send(data);
@@ -495,25 +476,23 @@ class AbstractForm extends AbstractCommon {
495
476
  get inStep() {
496
477
  return this._inStep;
497
478
  }
498
- enterStep(list) {
499
- return __awaiter(this, void 0, void 0, function* () {
500
- if (this._inStep) {
501
- return false;
502
- }
503
- if (list[0].value !== this.formHash) {
504
- return false;
505
- }
506
- this._inStep = true;
507
- this._stepValues.length = 0;
508
- for (const item of list) {
509
- this._stepValues.push(item.value);
510
- }
511
- this.refs.form.stepData = list;
512
- this.refs.form.stepValue = this.formHash;
513
- yield this.nextTick();
514
- this.refs.form.stepShow();
515
- return true;
516
- });
479
+ async enterStep(list) {
480
+ if (this._inStep) {
481
+ return false;
482
+ }
483
+ if (list[0].value !== this.formHash) {
484
+ return false;
485
+ }
486
+ this._inStep = true;
487
+ this._stepValues.length = 0;
488
+ for (const item of list) {
489
+ this._stepValues.push(item.value);
490
+ }
491
+ this.refs.form.stepData = list;
492
+ this.refs.form.stepValue = this.formHash;
493
+ await this.nextTick();
494
+ this.refs.form.stepShow();
495
+ return true;
517
496
  }
518
497
  updateStep(index, value) {
519
498
  if (this._inStep) {
@@ -525,14 +504,12 @@ class AbstractForm extends AbstractCommon {
525
504
  this._stepValues[index] = value;
526
505
  return true;
527
506
  }
528
- doneStep() {
529
- return __awaiter(this, void 0, void 0, function* () {
530
- if (!this._inStep) {
531
- return;
532
- }
533
- this._inStep = false;
534
- yield this.refs.form.stepDone();
535
- });
507
+ async doneStep() {
508
+ if (!this._inStep) {
509
+ return;
510
+ }
511
+ this._inStep = false;
512
+ await this.refs.form.stepDone();
536
513
  }
537
514
  show() {
538
515
  const v = this;
@@ -554,16 +531,14 @@ class AbstractForm extends AbstractCommon {
554
531
  v.$refs.form.$data.isShow = true;
555
532
  }
556
533
  }
557
- showDialog() {
558
- return __awaiter(this, void 0, void 0, function* () {
559
- task.list[this.taskId].runtime.dialogFormIds.push(this.formId);
560
- this.show();
561
- this.topMost = true;
562
- return new Promise((resolve) => {
563
- this.cgDialogCallback = () => {
564
- resolve(this.dialogResult);
565
- };
566
- });
534
+ async showDialog() {
535
+ task.list[this.taskId].runtime.dialogFormIds.push(this.formId);
536
+ this.show();
537
+ this.topMost = true;
538
+ return new Promise((resolve) => {
539
+ this.cgDialogCallback = () => {
540
+ resolve(this.dialogResult);
541
+ };
567
542
  });
568
543
  }
569
544
  hide() {
@@ -794,8 +769,7 @@ exports.elements = {
794
769
  },
795
770
  'computed': {
796
771
  'search': function () {
797
- var _a, _b;
798
- return (_b = (_a = info.locale[core.config.locale]) === null || _a === void 0 ? void 0 : _a.search) !== null && _b !== void 0 ? _b : info.locale['en'].search;
772
+ return info.locale[core.config.locale]?.search ?? info.locale['en'].search;
799
773
  },
800
774
  'list': function () {
801
775
  if (this.name === '') {
@@ -837,26 +811,22 @@ exports.elements = {
837
811
  this.closeFolder();
838
812
  }
839
813
  },
840
- iconClick: function (e, item) {
841
- return __awaiter(this, void 0, void 0, function* () {
842
- if (this.md !== e.pageX + e.pageY) {
843
- return;
844
- }
845
- hideLauncher();
846
- yield clickgo.task.run(item.path, {
847
- 'icon': item.icon
848
- });
814
+ iconClick: async function (e, item) {
815
+ if (this.md !== e.pageX + e.pageY) {
816
+ return;
817
+ }
818
+ hideLauncher();
819
+ await clickgo.task.run(item.path, {
820
+ 'icon': item.icon
849
821
  });
850
822
  },
851
- subIconClick: function (e, item) {
852
- return __awaiter(this, void 0, void 0, function* () {
853
- if (this.md !== e.pageX + e.pageY) {
854
- return;
855
- }
856
- hideLauncher();
857
- yield clickgo.task.run(item.path, {
858
- 'icon': item.icon
859
- });
823
+ subIconClick: async function (e, item) {
824
+ if (this.md !== e.pageX + e.pageY) {
825
+ return;
826
+ }
827
+ hideLauncher();
828
+ await clickgo.task.run(item.path, {
829
+ 'icon': item.icon
860
830
  });
861
831
  },
862
832
  closeFolder: function () {
@@ -903,7 +873,6 @@ exports.elements = {
903
873
  });
904
874
  },
905
875
  folderNameChange: function (e) {
906
- var _a;
907
876
  const input = e.target;
908
877
  const val = input.value.trim();
909
878
  if (val === '') {
@@ -911,7 +880,7 @@ exports.elements = {
911
880
  return;
912
881
  }
913
882
  this.folderName = val;
914
- core.trigger('launcherFolderNameChanged', (_a = this.folderItem.id) !== null && _a !== void 0 ? _a : '', val);
883
+ core.trigger('launcherFolderNameChanged', this.folderItem.id ?? '', val);
915
884
  }
916
885
  },
917
886
  'mounted': function () {
@@ -932,7 +901,7 @@ exports.elements = {
932
901
  `</div>`;
933
902
  this.confirm.style.display = 'none';
934
903
  document.getElementById('cg-confirm-cancel').addEventListener('click', () => {
935
- superConfirmHandler === null || superConfirmHandler === void 0 ? void 0 : superConfirmHandler(false);
904
+ superConfirmHandler?.(false);
936
905
  this.confirm.style.display = 'none';
937
906
  const fid = getMaxZIndexID();
938
907
  if (fid) {
@@ -940,7 +909,7 @@ exports.elements = {
940
909
  }
941
910
  });
942
911
  document.getElementById('cg-confirm-ok').addEventListener('click', () => {
943
- superConfirmHandler === null || superConfirmHandler === void 0 ? void 0 : superConfirmHandler(true);
912
+ superConfirmHandler?.(true);
944
913
  this.confirm.style.display = 'none';
945
914
  const fid = getMaxZIndexID();
946
915
  if (fid) {
@@ -952,15 +921,14 @@ exports.elements = {
952
921
  exports.elements.init();
953
922
  function superConfirm(html) {
954
923
  return new Promise((resolve) => {
955
- var _a, _b, _c, _d;
956
924
  if (superConfirmHandler !== undefined) {
957
925
  resolve(false);
958
926
  return;
959
927
  }
960
928
  exports.elements.confirm.style.display = 'flex';
961
929
  document.getElementById('cg-confirm-content').innerHTML = html;
962
- document.getElementById('cg-confirm-cancel').innerHTML = (_b = (_a = info.locale[core.config.locale]) === null || _a === void 0 ? void 0 : _a.cancel) !== null && _b !== void 0 ? _b : info.locale['en'].cancel;
963
- document.getElementById('cg-confirm-ok').innerHTML = (_d = (_c = info.locale[core.config.locale]) === null || _c === void 0 ? void 0 : _c.ok) !== null && _d !== void 0 ? _d : info.locale['en'].ok;
930
+ document.getElementById('cg-confirm-cancel').innerHTML = info.locale[core.config.locale]?.cancel ?? info.locale['en'].cancel;
931
+ document.getElementById('cg-confirm-ok').innerHTML = info.locale[core.config.locale]?.ok ?? info.locale['en'].ok;
964
932
  superConfirmHandler = (result) => {
965
933
  superConfirmHandler = undefined;
966
934
  resolve(result);
@@ -1121,8 +1089,7 @@ function getFocus() {
1121
1089
  }
1122
1090
  exports.activePanels = {};
1123
1091
  function getActivePanel(formId) {
1124
- var _a;
1125
- return (_a = exports.activePanels[formId]) !== null && _a !== void 0 ? _a : [];
1092
+ return exports.activePanels[formId] ?? [];
1126
1093
  }
1127
1094
  function removeActivePanel(panelId, formId, taskId) {
1128
1095
  if (!taskId) {
@@ -1198,26 +1165,23 @@ function getHash(formId) {
1198
1165
  }
1199
1166
  return item.vroot.$data._formHash;
1200
1167
  }
1201
- function hashBack(formId) {
1202
- return __awaiter(this, void 0, void 0, function* () {
1203
- const taskId = getTaskId(formId);
1204
- if (taskId === 0) {
1205
- return false;
1206
- }
1207
- const t = task.list[taskId];
1208
- if (!t) {
1209
- return false;
1210
- }
1211
- const item = task.list[taskId].forms[formId];
1212
- if (!item) {
1213
- return false;
1214
- }
1215
- yield item.vroot.formHashBack();
1216
- return true;
1217
- });
1168
+ async function hashBack(formId) {
1169
+ const taskId = getTaskId(formId);
1170
+ if (taskId === 0) {
1171
+ return false;
1172
+ }
1173
+ const t = task.list[taskId];
1174
+ if (!t) {
1175
+ return false;
1176
+ }
1177
+ const item = task.list[taskId].forms[formId];
1178
+ if (!item) {
1179
+ return false;
1180
+ }
1181
+ await item.vroot.formHashBack();
1182
+ return true;
1218
1183
  }
1219
1184
  function changeFocus(formId = 0) {
1220
- var _a;
1221
1185
  if (typeof formId === 'string') {
1222
1186
  formId = parseInt(formId);
1223
1187
  }
@@ -1245,7 +1209,7 @@ function changeFocus(formId = 0) {
1245
1209
  if (el.children.item(0).dataset.cgMin !== undefined) {
1246
1210
  min(formId);
1247
1211
  }
1248
- const taskId = parseInt((_a = el.getAttribute('data-task-id')) !== null && _a !== void 0 ? _a : '0');
1212
+ const taskId = parseInt(el.getAttribute('data-task-id') ?? '0');
1249
1213
  const t = task.list[taskId];
1250
1214
  if (t.runtime.dialogFormIds.length) {
1251
1215
  const dialogFormId = t.runtime.dialogFormIds[t.runtime.dialogFormIds.length - 1];
@@ -1288,7 +1252,6 @@ function changeFocus(formId = 0) {
1288
1252
  }
1289
1253
  }
1290
1254
  function getMaxZIndexID(out = {}) {
1291
- var _a, _b;
1292
1255
  let zIndex = 0;
1293
1256
  let formId = null;
1294
1257
  for (let i = 0; i < exports.elements.list.children.length; ++i) {
@@ -1308,11 +1271,11 @@ function getMaxZIndexID(out = {}) {
1308
1271
  if (tid === task.systemTaskInfo.taskId) {
1309
1272
  continue;
1310
1273
  }
1311
- if ((_a = out.taskIds) === null || _a === void 0 ? void 0 : _a.includes(tid)) {
1274
+ if (out.taskIds?.includes(tid)) {
1312
1275
  continue;
1313
1276
  }
1314
1277
  const fid = parseInt(formWrap.getAttribute('data-form-id'));
1315
- if ((_b = out.formIds) === null || _b === void 0 ? void 0 : _b.includes(fid)) {
1278
+ if (out.formIds?.includes(fid)) {
1316
1279
  continue;
1317
1280
  }
1318
1281
  if (z > zIndex) {
@@ -1323,7 +1286,6 @@ function getMaxZIndexID(out = {}) {
1323
1286
  return formId;
1324
1287
  }
1325
1288
  function getRectByBorder(border) {
1326
- var _a, _b, _c, _d;
1327
1289
  const area = core.getAvailArea();
1328
1290
  let width, height, left, top;
1329
1291
  if (typeof border === 'string') {
@@ -1390,10 +1352,10 @@ function getRectByBorder(border) {
1390
1352
  }
1391
1353
  }
1392
1354
  else {
1393
- width = (_a = border.width) !== null && _a !== void 0 ? _a : area.width;
1394
- height = (_b = border.height) !== null && _b !== void 0 ? _b : area.height;
1395
- left = (_c = border.left) !== null && _c !== void 0 ? _c : area.left;
1396
- top = (_d = border.top) !== null && _d !== void 0 ? _d : area.top;
1355
+ width = border.width ?? area.width;
1356
+ height = border.height ?? area.height;
1357
+ left = border.left ?? area.left;
1358
+ top = border.top ?? area.top;
1397
1359
  }
1398
1360
  return {
1399
1361
  'width': width,
@@ -1423,13 +1385,12 @@ function showCircular(x, y) {
1423
1385
  });
1424
1386
  }
1425
1387
  function moveRectangle(border) {
1426
- var _a, _b, _c, _d;
1427
- const dataReady = (_a = exports.elements.rectangle.getAttribute('data-ready')) !== null && _a !== void 0 ? _a : '0';
1388
+ const dataReady = exports.elements.rectangle.getAttribute('data-ready') ?? '0';
1428
1389
  if (dataReady === '0') {
1429
1390
  return;
1430
1391
  }
1431
- const dataBorder = (_b = exports.elements.rectangle.getAttribute('data-border')) !== null && _b !== void 0 ? _b : '';
1432
- const setDataBorder = typeof border === 'string' ? border : `o-${border.left}-${(_c = border.top) !== null && _c !== void 0 ? _c : 'n'}-${border.width}-${(_d = border.height) !== null && _d !== void 0 ? _d : 'n'}`;
1392
+ const dataBorder = exports.elements.rectangle.getAttribute('data-border') ?? '';
1393
+ const setDataBorder = typeof border === 'string' ? border : `o-${border.left}-${border.top ?? 'n'}-${border.width}-${border.height ?? 'n'}`;
1433
1394
  if (dataBorder === setDataBorder) {
1434
1395
  return;
1435
1396
  }
@@ -1524,7 +1485,7 @@ function alert(content, type) {
1524
1485
  const el = document.createElement('div');
1525
1486
  const y = alertBottom;
1526
1487
  el.classList.add('cg-alert-wrap');
1527
- el.classList.add('cg-' + (type !== null && type !== void 0 ? type : 'default'));
1488
+ el.classList.add('cg-' + (type ?? 'default'));
1528
1489
  el.setAttribute('data-alertid', nid.toString());
1529
1490
  el.style.transform = `translateY(${y + 10}px)`;
1530
1491
  el.style.opacity = '0';
@@ -1565,13 +1526,12 @@ function alert(content, type) {
1565
1526
  let notifyBottom = -10;
1566
1527
  let notifyId = 0;
1567
1528
  function notify(opt) {
1568
- var _a;
1569
1529
  const nid = ++notifyId;
1570
- let timeout = 5000;
1571
- const maxTimeout = 60000 * 10;
1530
+ let timeout = 5_000;
1531
+ const maxTimeout = 60_000 * 10;
1572
1532
  if (opt.timeout !== undefined) {
1573
1533
  if (opt.timeout <= 0) {
1574
- timeout = 5000;
1534
+ timeout = 5_000;
1575
1535
  }
1576
1536
  else if (opt.timeout > maxTimeout) {
1577
1537
  timeout = maxTimeout;
@@ -1599,7 +1559,7 @@ function notify(opt) {
1599
1559
  el.style.transform = `translateY(${y}px) translateX(280px)`;
1600
1560
  el.style.opacity = '0';
1601
1561
  el.classList.add((opt.title && opt.content) ? 'cg-notify-full' : 'cg-notify-only');
1602
- el.innerHTML = `<div class="cg-notify-icon cg-${tool.escapeHTML((_a = opt.type) !== null && _a !== void 0 ? _a : 'primary')}"></div>` +
1562
+ el.innerHTML = `<div class="cg-notify-icon cg-${tool.escapeHTML(opt.type ?? 'primary')}"></div>` +
1603
1563
  '<div style="flex: 1;">' +
1604
1564
  (opt.title ? `<div class="cg-notify-title">${tool.escapeHTML(opt.title)}</div>` : '') +
1605
1565
  (opt.content ? `<div class="cg-notify-content">${tool.escapeHTML(opt.content).replace(/\r\n/g, '\n').replace(/\r/g, '\n').replace(/\n/g, '<br>')}</div>` +
@@ -1697,9 +1657,8 @@ function removeFromPop(el) {
1697
1657
  exports.elements.popList.removeChild(el);
1698
1658
  }
1699
1659
  function refreshPopPosition(el, pop, direction, size = {}) {
1700
- var _a, _b;
1701
- const width = (_a = size.width) !== null && _a !== void 0 ? _a : pop.offsetWidth;
1702
- const height = (_b = size.height) !== null && _b !== void 0 ? _b : pop.offsetHeight;
1660
+ const width = size.width ?? pop.offsetWidth;
1661
+ const height = size.height ?? pop.offsetHeight;
1703
1662
  let left, top;
1704
1663
  if (typeof direction === 'string') {
1705
1664
  const bcr = el.getBoundingClientRect();
@@ -1784,7 +1743,6 @@ function refreshPopPosition(el, pop, direction, size = {}) {
1784
1743
  }
1785
1744
  let lastShowPopTime = 0;
1786
1745
  function showPop(el, pop, direction, opt = {}) {
1787
- var _a, _b, _c, _d;
1788
1746
  if (!(el instanceof Element)) {
1789
1747
  if (!el.$el) {
1790
1748
  return;
@@ -1797,9 +1755,9 @@ function showPop(el, pop, direction, opt = {}) {
1797
1755
  }
1798
1756
  pop = pop.$el;
1799
1757
  }
1800
- (_a = opt.null) !== null && _a !== void 0 ? _a : (opt.null = false);
1801
- (_b = opt.size) !== null && _b !== void 0 ? _b : (opt.size = {});
1802
- (_c = opt.flow) !== null && _c !== void 0 ? _c : (opt.flow = true);
1758
+ opt.null ??= false;
1759
+ opt.size ??= {};
1760
+ opt.flow ??= true;
1803
1761
  if (!pop && !opt.null) {
1804
1762
  return;
1805
1763
  }
@@ -1831,7 +1789,7 @@ function showPop(el, pop, direction, opt = {}) {
1831
1789
  return;
1832
1790
  }
1833
1791
  const parentPop = dom.findParentByData(el, 'cg-pop');
1834
- if ((parentPop === null || parentPop === void 0 ? void 0 : parentPop.dataset.cgLevel) !== undefined) {
1792
+ if (parentPop?.dataset.cgLevel !== undefined) {
1835
1793
  const nextlevel = parseInt(parentPop.dataset.cgLevel) + 1;
1836
1794
  if (popInfo.elList[nextlevel]) {
1837
1795
  hidePop(popInfo.elList[nextlevel]);
@@ -1849,7 +1807,7 @@ function showPop(el, pop, direction, opt = {}) {
1849
1807
  pop.removeAttribute('data-cg-pop-none');
1850
1808
  popInfo.list.push(pop);
1851
1809
  popInfo.elList.push(el);
1852
- popInfo.wayList.push((_d = opt.way) !== null && _d !== void 0 ? _d : 'normal');
1810
+ popInfo.wayList.push(opt.way ?? 'normal');
1853
1811
  popInfo.time.push(Date.now());
1854
1812
  pop.dataset.cgLevel = (popInfo.list.length - 1).toString();
1855
1813
  el.dataset.cgLevel = (popInfo.elList.length - 1).toString();
@@ -1964,7 +1922,6 @@ function isJustPop(el) {
1964
1922
  return true;
1965
1923
  }
1966
1924
  function doFocusAndPopEvent(e) {
1967
- var _a, _b;
1968
1925
  if (dom.hasTouchButMouse(e)) {
1969
1926
  return;
1970
1927
  }
@@ -1972,7 +1929,7 @@ function doFocusAndPopEvent(e) {
1972
1929
  if (!target) {
1973
1930
  return;
1974
1931
  }
1975
- const paths = (_a = e.path) !== null && _a !== void 0 ? _a : (e.composedPath ? e.composedPath() : []);
1932
+ const paths = e.path ?? (e.composedPath ? e.composedPath() : []);
1976
1933
  let isCgPopOpen = null;
1977
1934
  for (const item of paths) {
1978
1935
  if (!item.tagName) {
@@ -1983,7 +1940,7 @@ function doFocusAndPopEvent(e) {
1983
1940
  continue;
1984
1941
  }
1985
1942
  if (item.classList.contains('cg-form-wrap')) {
1986
- const formId = parseInt((_b = item.getAttribute('data-form-id')) !== null && _b !== void 0 ? _b : '0');
1943
+ const formId = parseInt(item.getAttribute('data-form-id') ?? '0');
1987
1944
  changeFocus(formId);
1988
1945
  if (isCgPopOpen) {
1989
1946
  if (!isJustPop(isCgPopOpen)) {
@@ -2040,7 +1997,6 @@ function remove(formId) {
2040
1997
  }
2041
1998
  task.list[taskId].forms[formId].vroot.$refs.form.$data.isShow = false;
2042
1999
  setTimeout(function () {
2043
- var _a;
2044
2000
  const fid = getMaxZIndexID({
2045
2001
  'formIds': [formId]
2046
2002
  });
@@ -2055,7 +2011,7 @@ function remove(formId) {
2055
2011
  }
2056
2012
  task.list[taskId].forms[formId].vapp.unmount();
2057
2013
  task.list[taskId].forms[formId].vapp._container.remove();
2058
- (_a = exports.elements.popList.querySelector('[data-form-id="' + formId.toString() + '"]')) === null || _a === void 0 ? void 0 : _a.remove();
2014
+ exports.elements.popList.querySelector('[data-form-id="' + formId.toString() + '"]')?.remove();
2059
2015
  if (io > -1) {
2060
2016
  task.list[taskId].forms[formId].vroot.cgDialogCallback();
2061
2017
  }
@@ -2074,7 +2030,6 @@ function remove(formId) {
2074
2030
  return true;
2075
2031
  }
2076
2032
  function removePanel(id, vapp, el) {
2077
- var _a;
2078
2033
  const formWrap = dom.findParentByClass(el, 'cg-form-wrap');
2079
2034
  if (!formWrap) {
2080
2035
  return false;
@@ -2090,7 +2045,7 @@ function removePanel(id, vapp, el) {
2090
2045
  const tid = parseInt(taskId);
2091
2046
  vapp.unmount();
2092
2047
  vapp._container.remove();
2093
- (_a = el.querySelector('[data-panel-id="' + id.toString() + '"]')) === null || _a === void 0 ? void 0 : _a.remove();
2048
+ el.querySelector('[data-panel-id="' + id.toString() + '"]')?.remove();
2094
2049
  dom.removeStyle(tid, 'form', formId, id);
2095
2050
  dom.clearWatchStyle(formId, id);
2096
2051
  dom.clearWatchProperty(formId, id);
@@ -2117,718 +2072,699 @@ function getForm(taskId, formId) {
2117
2072
  }
2118
2073
  return form;
2119
2074
  }
2120
- function createPanel(rootPanel_1, cls_1) {
2121
- return __awaiter(this, arguments, void 0, function* (rootPanel, cls, opt = {}, taskId) {
2122
- var _a;
2123
- if (rootPanel.element.dataset.cgControl !== 'panel') {
2124
- const err = new Error('form.createPanel: -0');
2125
- core.trigger('error', 0, 0, err, err.message);
2126
- throw err;
2127
- }
2128
- const formWrap = dom.findParentByData(rootPanel.element, 'form-id');
2129
- if (!formWrap) {
2130
- const err = new Error('form.createPanel: -0');
2131
- core.trigger('error', 0, 0, err, err.message);
2132
- throw err;
2133
- }
2134
- const formId = parseInt(formWrap.dataset.formId);
2135
- if (!taskId) {
2136
- const err = new Error('form.createPanel: -1');
2137
- core.trigger('error', 0, 0, err, err.message);
2138
- throw err;
2139
- }
2140
- const t = task.list[taskId];
2141
- if (!t) {
2142
- const err = new Error('form.createPanel: -2');
2143
- core.trigger('error', 0, 0, err, err.message);
2144
- throw err;
2145
- }
2146
- let layout = '';
2147
- if (opt.layout) {
2148
- layout = opt.layout;
2149
- }
2150
- let style = '';
2151
- let prep = '';
2152
- if (opt.style) {
2153
- style = opt.style;
2154
- }
2155
- let filename = '';
2156
- if (typeof cls === 'string') {
2157
- filename = tool.urlResolve((_a = opt.path) !== null && _a !== void 0 ? _a : '/', cls);
2158
- if (!layout) {
2159
- const l = t.app.files[filename + '.xml'];
2160
- if (typeof l !== 'string') {
2161
- const err = new Error('form.createPanel: -3');
2162
- core.trigger('error', 0, 0, err, err.message);
2163
- throw err;
2164
- }
2165
- layout = l;
2166
- }
2167
- if (!style) {
2168
- const s = t.app.files[filename + '.css'];
2169
- if (typeof s === 'string') {
2170
- style = s;
2171
- }
2172
- }
2173
- cls = class extends AbstractPanel {
2174
- get filename() {
2175
- return filename + '.js';
2176
- }
2177
- get taskId() {
2178
- return t.id;
2179
- }
2180
- };
2181
- }
2182
- const panelId = ++info.lastPanelId;
2183
- const panel = new cls();
2184
- if (!filename) {
2185
- filename = panel.filename;
2186
- }
2187
- const lio = filename.lastIndexOf('/');
2188
- const path = filename.slice(0, lio);
2075
+ async function createPanel(rootPanel, cls, opt = {}, taskId) {
2076
+ if (rootPanel.element.dataset.cgControl !== 'panel') {
2077
+ const err = new Error('form.createPanel: -0');
2078
+ core.trigger('error', 0, 0, err, err.message);
2079
+ throw err;
2080
+ }
2081
+ const formWrap = dom.findParentByData(rootPanel.element, 'form-id');
2082
+ if (!formWrap) {
2083
+ const err = new Error('form.createPanel: -0');
2084
+ core.trigger('error', 0, 0, err, err.message);
2085
+ throw err;
2086
+ }
2087
+ const formId = parseInt(formWrap.dataset.formId);
2088
+ if (!taskId) {
2089
+ const err = new Error('form.createPanel: -1');
2090
+ core.trigger('error', 0, 0, err, err.message);
2091
+ throw err;
2092
+ }
2093
+ const t = task.list[taskId];
2094
+ if (!t) {
2095
+ const err = new Error('form.createPanel: -2');
2096
+ core.trigger('error', 0, 0, err, err.message);
2097
+ throw err;
2098
+ }
2099
+ let layout = '';
2100
+ if (opt.layout) {
2101
+ layout = opt.layout;
2102
+ }
2103
+ let style = '';
2104
+ let prep = '';
2105
+ if (opt.style) {
2106
+ style = opt.style;
2107
+ }
2108
+ let filename = '';
2109
+ if (typeof cls === 'string') {
2110
+ filename = tool.urlResolve(opt.path ?? '/', cls);
2189
2111
  if (!layout) {
2190
- const l = t.app.files[filename.slice(0, -2) + 'xml'];
2112
+ const l = t.app.files[filename + '.xml'];
2191
2113
  if (typeof l !== 'string') {
2192
- const err = new Error('form.createPanel: -4');
2114
+ const err = new Error('form.createPanel: -3');
2193
2115
  core.trigger('error', 0, 0, err, err.message);
2194
2116
  throw err;
2195
2117
  }
2196
2118
  layout = l;
2197
2119
  }
2198
2120
  if (!style) {
2199
- const s = t.app.files[filename.slice(0, -2) + 'css'];
2121
+ const s = t.app.files[filename + '.css'];
2200
2122
  if (typeof s === 'string') {
2201
2123
  style = s;
2202
2124
  }
2203
2125
  }
2204
- if (style) {
2205
- const r = tool.stylePrepend(style);
2206
- prep = r.prep;
2207
- style = yield tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
2208
- }
2209
- layout = tool.purify(layout);
2210
- layout = tool.layoutAddTagClassAndReTagName(layout, true);
2211
- const prepList = ['cg-task' + t.id.toString() + '_'];
2212
- if (prep !== '') {
2213
- prepList.push(prep);
2214
- }
2215
- layout = tool.layoutClassPrepend(layout, prepList);
2216
- layout = tool.eventsAttrWrap(layout);
2217
- if (layout.includes('<teleport')) {
2218
- layout = tool.teleportGlue(layout, formId);
2219
- }
2220
- const components = control.buildComponents(t.id, formId, path);
2221
- if (!components) {
2222
- const err = new Error('form.createPanel: -5');
2126
+ cls = class extends AbstractPanel {
2127
+ get filename() {
2128
+ return filename + '.js';
2129
+ }
2130
+ get taskId() {
2131
+ return t.id;
2132
+ }
2133
+ };
2134
+ }
2135
+ const panelId = ++info.lastPanelId;
2136
+ const panel = new cls();
2137
+ if (!filename) {
2138
+ filename = panel.filename;
2139
+ }
2140
+ const lio = filename.lastIndexOf('/');
2141
+ const path = filename.slice(0, lio);
2142
+ if (!layout) {
2143
+ const l = t.app.files[filename.slice(0, -2) + 'xml'];
2144
+ if (typeof l !== 'string') {
2145
+ const err = new Error('form.createPanel: -4');
2223
2146
  core.trigger('error', 0, 0, err, err.message);
2224
2147
  throw err;
2225
2148
  }
2226
- const idata = {};
2227
- const cdata = Object.entries(panel);
2228
- for (const item of cdata) {
2229
- if (item[0] === 'access') {
2230
- continue;
2231
- }
2232
- idata[item[0]] = item[1];
2233
- }
2234
- const prot = tool.getClassPrototype(panel);
2235
- const methods = prot.method;
2236
- const computed = prot.access;
2237
- computed.formId = {
2238
- get: function () {
2239
- return formId;
2149
+ layout = l;
2150
+ }
2151
+ if (!style) {
2152
+ const s = t.app.files[filename.slice(0, -2) + 'css'];
2153
+ if (typeof s === 'string') {
2154
+ style = s;
2155
+ }
2156
+ }
2157
+ if (style) {
2158
+ const r = tool.stylePrepend(style);
2159
+ prep = r.prep;
2160
+ style = await tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
2161
+ }
2162
+ layout = tool.purify(layout);
2163
+ layout = tool.layoutAddTagClassAndReTagName(layout, true);
2164
+ const prepList = ['cg-task' + t.id.toString() + '_'];
2165
+ if (prep !== '') {
2166
+ prepList.push(prep);
2167
+ }
2168
+ layout = tool.layoutClassPrepend(layout, prepList);
2169
+ layout = tool.eventsAttrWrap(layout);
2170
+ if (layout.includes('<teleport')) {
2171
+ layout = tool.teleportGlue(layout, formId);
2172
+ }
2173
+ const components = control.buildComponents(t.id, formId, path);
2174
+ if (!components) {
2175
+ const err = new Error('form.createPanel: -5');
2176
+ core.trigger('error', 0, 0, err, err.message);
2177
+ throw err;
2178
+ }
2179
+ const idata = {};
2180
+ const cdata = Object.entries(panel);
2181
+ for (const item of cdata) {
2182
+ if (item[0] === 'access') {
2183
+ continue;
2184
+ }
2185
+ idata[item[0]] = item[1];
2186
+ }
2187
+ const prot = tool.getClassPrototype(panel);
2188
+ const methods = prot.method;
2189
+ const computed = prot.access;
2190
+ computed.formId = {
2191
+ get: function () {
2192
+ return formId;
2193
+ },
2194
+ set: function () {
2195
+ notify({
2196
+ 'title': 'Error',
2197
+ 'content': `The software tries to modify the system variable "formId".\nPath: ${this.filename}`,
2198
+ 'type': 'danger'
2199
+ });
2200
+ return;
2201
+ }
2202
+ };
2203
+ computed.panelId = {
2204
+ get: function () {
2205
+ return panelId;
2206
+ },
2207
+ set: function () {
2208
+ notify({
2209
+ 'title': 'Error',
2210
+ 'content': `The software tries to modify the system variable "panelId".\nPath: ${this.filename}`,
2211
+ 'type': 'danger'
2212
+ });
2213
+ return;
2214
+ }
2215
+ };
2216
+ computed.path = {
2217
+ get: function () {
2218
+ return path;
2219
+ },
2220
+ set: function () {
2221
+ notify({
2222
+ 'title': 'Error',
2223
+ 'content': `The software tries to modify the system variable "path".\nPath: ${this.filename}`,
2224
+ 'type': 'danger'
2225
+ });
2226
+ return;
2227
+ }
2228
+ };
2229
+ computed.prep = {
2230
+ get: function () {
2231
+ return prep;
2232
+ },
2233
+ set: function () {
2234
+ notify({
2235
+ 'title': 'Error',
2236
+ 'content': `The software tries to modify the system variable "prep".\nPath: ${this.filename}`,
2237
+ 'type': 'danger'
2238
+ });
2239
+ return;
2240
+ }
2241
+ };
2242
+ computed.rootForm = {
2243
+ get: function () {
2244
+ return t.forms[formId].vroot;
2245
+ },
2246
+ set: function () {
2247
+ notify({
2248
+ 'title': 'Error',
2249
+ 'content': `The software tries to modify the system variable "rootForm".\nPath: ${this.filename}`,
2250
+ 'type': 'danger'
2251
+ });
2252
+ return;
2253
+ }
2254
+ };
2255
+ computed.rootPanel = {
2256
+ get: function () {
2257
+ return rootPanel;
2258
+ },
2259
+ set: function () {
2260
+ notify({
2261
+ 'title': 'Error',
2262
+ 'content': `The software tries to modify the system variable "rootPanel".\nPath: ${this.filename}`,
2263
+ 'type': 'danger'
2264
+ });
2265
+ return;
2266
+ }
2267
+ };
2268
+ rootPanel.element.insertAdjacentHTML('beforeend', `<div data-panel-id="${panelId.toString()}"></div>`);
2269
+ if (style) {
2270
+ dom.pushStyle(t.id, style, 'form', formId, panelId);
2271
+ }
2272
+ const mel = rootPanel.element.children.item(rootPanel.element.children.length - 1);
2273
+ mel.style.position = 'absolute';
2274
+ mel.style.display = 'none';
2275
+ const rtn = await new Promise(function (resolve) {
2276
+ const vapp = clickgo.vue.createApp({
2277
+ 'template': layout.replace(/^<cg-panel([\s\S]+)-panel>$/, '<cg-layout$1-layout>'),
2278
+ 'data': function () {
2279
+ return tool.clone(idata);
2240
2280
  },
2241
- set: function () {
2242
- notify({
2243
- 'title': 'Error',
2244
- 'content': `The software tries to modify the system variable "formId".\nPath: ${this.filename}`,
2245
- 'type': 'danger'
2246
- });
2247
- return;
2248
- }
2249
- };
2250
- computed.panelId = {
2251
- get: function () {
2252
- return panelId;
2281
+ 'methods': methods,
2282
+ 'computed': computed,
2283
+ 'beforeCreate': panel.onBeforeCreate,
2284
+ 'created': function () {
2285
+ if (panel.access) {
2286
+ this.access = tool.clone(panel.access);
2287
+ }
2288
+ this.onCreated();
2253
2289
  },
2254
- set: function () {
2255
- notify({
2256
- 'title': 'Error',
2257
- 'content': `The software tries to modify the system variable "panelId".\nPath: ${this.filename}`,
2258
- 'type': 'danger'
2259
- });
2260
- return;
2261
- }
2262
- };
2263
- computed.path = {
2264
- get: function () {
2265
- return path;
2290
+ 'beforeMount': function () {
2291
+ this.onBeforeMount();
2266
2292
  },
2267
- set: function () {
2268
- notify({
2269
- 'title': 'Error',
2270
- 'content': `The software tries to modify the system variable "path".\nPath: ${this.filename}`,
2271
- 'type': 'danger'
2293
+ 'mounted': async function () {
2294
+ await this.$nextTick();
2295
+ mel.children.item(0).style.flex = '1';
2296
+ resolve({
2297
+ 'vapp': vapp,
2298
+ 'vroot': this
2272
2299
  });
2273
- return;
2274
- }
2275
- };
2276
- computed.prep = {
2277
- get: function () {
2278
- return prep;
2279
2300
  },
2280
- set: function () {
2281
- notify({
2282
- 'title': 'Error',
2283
- 'content': `The software tries to modify the system variable "prep".\nPath: ${this.filename}`,
2284
- 'type': 'danger'
2285
- });
2286
- return;
2287
- }
2288
- };
2289
- computed.rootForm = {
2290
- get: function () {
2291
- return t.forms[formId].vroot;
2301
+ 'beforeUpdate': function () {
2302
+ this.onBeforeUpdate();
2292
2303
  },
2293
- set: function () {
2294
- notify({
2295
- 'title': 'Error',
2296
- 'content': `The software tries to modify the system variable "rootForm".\nPath: ${this.filename}`,
2297
- 'type': 'danger'
2298
- });
2299
- return;
2300
- }
2301
- };
2302
- computed.rootPanel = {
2303
- get: function () {
2304
- return rootPanel;
2304
+ 'updated': async function () {
2305
+ await this.$nextTick();
2306
+ this.onUpdated();
2305
2307
  },
2306
- set: function () {
2307
- notify({
2308
- 'title': 'Error',
2309
- 'content': `The software tries to modify the system variable "rootPanel".\nPath: ${this.filename}`,
2310
- 'type': 'danger'
2311
- });
2312
- return;
2313
- }
2314
- };
2315
- rootPanel.element.insertAdjacentHTML('beforeend', `<div data-panel-id="${panelId.toString()}"></div>`);
2316
- if (style) {
2317
- dom.pushStyle(t.id, style, 'form', formId, panelId);
2318
- }
2319
- const mel = rootPanel.element.children.item(rootPanel.element.children.length - 1);
2320
- mel.style.position = 'absolute';
2321
- mel.style.display = 'none';
2322
- const rtn = yield new Promise(function (resolve) {
2323
- const vapp = clickgo.vue.createApp({
2324
- 'template': layout.replace(/^<cg-panel([\s\S]+)-panel>$/, '<cg-layout$1-layout>'),
2325
- 'data': function () {
2326
- return tool.clone(idata);
2327
- },
2328
- 'methods': methods,
2329
- 'computed': computed,
2330
- 'beforeCreate': panel.onBeforeCreate,
2331
- 'created': function () {
2332
- if (panel.access) {
2333
- this.access = tool.clone(panel.access);
2334
- }
2335
- this.onCreated();
2336
- },
2337
- 'beforeMount': function () {
2338
- this.onBeforeMount();
2339
- },
2340
- 'mounted': function () {
2341
- return __awaiter(this, void 0, void 0, function* () {
2342
- yield this.$nextTick();
2343
- mel.children.item(0).style.flex = '1';
2344
- resolve({
2345
- 'vapp': vapp,
2346
- 'vroot': this
2347
- });
2348
- });
2349
- },
2350
- 'beforeUpdate': function () {
2351
- this.onBeforeUpdate();
2352
- },
2353
- 'updated': function () {
2354
- return __awaiter(this, void 0, void 0, function* () {
2355
- yield this.$nextTick();
2356
- this.onUpdated();
2357
- });
2358
- },
2359
- 'beforeUnmount': function () {
2360
- this.onBeforeUnmount();
2361
- },
2362
- 'unmounted': function () {
2363
- return __awaiter(this, void 0, void 0, function* () {
2364
- yield this.$nextTick();
2365
- this.onUnmounted();
2366
- });
2367
- }
2368
- });
2369
- vapp.config.errorHandler = function (err, vm, info) {
2370
- notify({
2371
- 'title': 'Runtime Error',
2372
- 'content': `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`,
2373
- 'type': 'danger'
2374
- });
2375
- console.error('Runtime Error [form.createPanel.errorHandler]', `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`, err, info);
2376
- core.trigger('error', vm.taskId, vm.formId, err, info + '(-3,' + vm.taskId + ',' + vm.formId + ')');
2377
- };
2378
- for (const key in components) {
2379
- vapp.component(key, components[key]);
2380
- }
2381
- try {
2382
- vapp.mount(mel);
2383
- }
2384
- catch (err) {
2385
- notify({
2386
- 'title': 'Runtime Error',
2387
- 'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
2388
- 'type': 'danger'
2389
- });
2390
- console.error('Runtime Error [form.createPanel.mount]', `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`, err);
2391
- core.trigger('error', t.id, formId, err, err.message);
2308
+ 'beforeUnmount': function () {
2309
+ this.onBeforeUnmount();
2310
+ },
2311
+ 'unmounted': async function () {
2312
+ await this.$nextTick();
2313
+ this.onUnmounted();
2392
2314
  }
2393
2315
  });
2394
- yield tool.sleep(34);
2316
+ vapp.config.errorHandler = function (err, vm, info) {
2317
+ notify({
2318
+ 'title': 'Runtime Error',
2319
+ 'content': `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`,
2320
+ 'type': 'danger'
2321
+ });
2322
+ console.error('Runtime Error [form.createPanel.errorHandler]', `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`, err, info);
2323
+ core.trigger('error', vm.taskId, vm.formId, err, info + '(-3,' + vm.taskId + ',' + vm.formId + ')');
2324
+ };
2325
+ for (const key in components) {
2326
+ vapp.component(key, components[key]);
2327
+ }
2395
2328
  try {
2396
- yield panel.onMounted.call(rtn.vroot);
2329
+ vapp.mount(mel);
2397
2330
  }
2398
2331
  catch (err) {
2399
- core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create panel mounted error: -6.');
2400
- try {
2401
- rtn.vapp.unmount();
2402
- }
2403
- catch (err) {
2404
- const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.createPanel, unmount.`;
2405
- notify({
2406
- 'title': 'Panel Unmount Error',
2407
- 'content': msg,
2408
- 'type': 'danger'
2409
- });
2410
- console.log('Panel Unmount Error', msg, err);
2411
- }
2412
- rtn.vapp._container.remove();
2413
- dom.clearWatchStyle(rtn.vroot.formId, panelId);
2414
- dom.clearWatchProperty(rtn.vroot.formId, panelId);
2415
- dom.clearWatchPosition(rtn.vroot.formId, panelId);
2416
- dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId, panelId);
2417
- throw err;
2332
+ notify({
2333
+ 'title': 'Runtime Error',
2334
+ 'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
2335
+ 'type': 'danger'
2336
+ });
2337
+ console.error('Runtime Error [form.createPanel.mount]', `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`, err);
2338
+ core.trigger('error', t.id, formId, err, err.message);
2418
2339
  }
2419
- return {
2420
- 'id': panelId,
2421
- 'vapp': rtn.vapp,
2422
- 'vroot': rtn.vroot
2423
- };
2424
2340
  });
2425
- }
2426
- function create(cls_1, data_1) {
2427
- return __awaiter(this, arguments, void 0, function* (cls, data, opt = {}, taskId) {
2428
- var _a, _b;
2429
- if (!taskId) {
2430
- const err = new Error('form.create: -1');
2431
- core.trigger('error', 0, 0, err, err.message);
2432
- throw err;
2433
- }
2434
- const t = task.list[taskId];
2435
- if (!t) {
2436
- const err = new Error('form.create: -2');
2437
- core.trigger('error', 0, 0, err, err.message);
2438
- throw err;
2439
- }
2440
- let layout = '';
2441
- if (opt.layout) {
2442
- layout = opt.layout;
2443
- }
2444
- let style = '';
2445
- let prep = '';
2446
- if (opt.style) {
2447
- style = opt.style;
2448
- }
2449
- let filename = '';
2450
- if (typeof cls === 'string') {
2451
- filename = tool.urlResolve((_a = opt.path) !== null && _a !== void 0 ? _a : '/', cls);
2452
- if (!layout) {
2453
- const l = t.app.files[filename + '.xml'];
2454
- if (typeof l !== 'string') {
2455
- const err = new Error('form.create: -3');
2456
- core.trigger('error', 0, 0, err, err.message);
2457
- throw err;
2458
- }
2459
- layout = l;
2460
- }
2461
- if (!style) {
2462
- const s = t.app.files[filename + '.css'];
2463
- if (typeof s === 'string') {
2464
- style = s;
2465
- }
2466
- }
2467
- cls = class extends AbstractForm {
2468
- get filename() {
2469
- return filename + '.js';
2470
- }
2471
- get taskId() {
2472
- return t.id;
2473
- }
2474
- };
2341
+ await tool.sleep(34);
2342
+ try {
2343
+ await panel.onMounted.call(rtn.vroot);
2344
+ }
2345
+ catch (err) {
2346
+ core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create panel mounted error: -6.');
2347
+ try {
2348
+ rtn.vapp.unmount();
2475
2349
  }
2476
- const formId = ++info.lastId;
2477
- const frm = new cls();
2478
- if (!filename) {
2479
- filename = frm.filename;
2350
+ catch (err) {
2351
+ const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.createPanel, unmount.`;
2352
+ notify({
2353
+ 'title': 'Panel Unmount Error',
2354
+ 'content': msg,
2355
+ 'type': 'danger'
2356
+ });
2357
+ console.log('Panel Unmount Error', msg, err);
2480
2358
  }
2481
- const lio = filename.lastIndexOf('/');
2482
- const path = filename.slice(0, lio);
2359
+ rtn.vapp._container.remove();
2360
+ dom.clearWatchStyle(rtn.vroot.formId, panelId);
2361
+ dom.clearWatchProperty(rtn.vroot.formId, panelId);
2362
+ dom.clearWatchPosition(rtn.vroot.formId, panelId);
2363
+ dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId, panelId);
2364
+ throw err;
2365
+ }
2366
+ return {
2367
+ 'id': panelId,
2368
+ 'vapp': rtn.vapp,
2369
+ 'vroot': rtn.vroot
2370
+ };
2371
+ }
2372
+ async function create(cls, data, opt = {}, taskId) {
2373
+ if (!taskId) {
2374
+ const err = new Error('form.create: -1');
2375
+ core.trigger('error', 0, 0, err, err.message);
2376
+ throw err;
2377
+ }
2378
+ const t = task.list[taskId];
2379
+ if (!t) {
2380
+ const err = new Error('form.create: -2');
2381
+ core.trigger('error', 0, 0, err, err.message);
2382
+ throw err;
2383
+ }
2384
+ let layout = '';
2385
+ if (opt.layout) {
2386
+ layout = opt.layout;
2387
+ }
2388
+ let style = '';
2389
+ let prep = '';
2390
+ if (opt.style) {
2391
+ style = opt.style;
2392
+ }
2393
+ let filename = '';
2394
+ if (typeof cls === 'string') {
2395
+ filename = tool.urlResolve(opt.path ?? '/', cls);
2483
2396
  if (!layout) {
2484
- const l = t.app.files[filename.slice(0, -2) + 'xml'];
2397
+ const l = t.app.files[filename + '.xml'];
2485
2398
  if (typeof l !== 'string') {
2486
- const err = new Error('form.create: -4');
2399
+ const err = new Error('form.create: -3');
2487
2400
  core.trigger('error', 0, 0, err, err.message);
2488
2401
  throw err;
2489
2402
  }
2490
2403
  layout = l;
2491
2404
  }
2492
2405
  if (!style) {
2493
- const s = t.app.files[filename.slice(0, -2) + 'css'];
2406
+ const s = t.app.files[filename + '.css'];
2494
2407
  if (typeof s === 'string') {
2495
2408
  style = s;
2496
2409
  }
2497
2410
  }
2498
- if (style) {
2499
- const r = tool.stylePrepend(style);
2500
- prep = r.prep;
2501
- style = yield tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
2502
- }
2503
- layout = tool.purify(layout);
2504
- layout = tool.layoutAddTagClassAndReTagName(layout, true);
2505
- const prepList = ['cg-task' + t.id.toString() + '_'];
2506
- if (prep !== '') {
2507
- prepList.push(prep);
2508
- }
2509
- layout = tool.layoutClassPrepend(layout, prepList);
2510
- layout = tool.eventsAttrWrap(layout);
2511
- if (layout.includes('<teleport')) {
2512
- layout = tool.teleportGlue(layout, formId);
2513
- }
2514
- const components = control.buildComponents(t.id, formId, path);
2515
- if (!components) {
2516
- const err = new Error('form.create: -5');
2517
- core.trigger('error', 0, 0, err, err.message);
2518
- throw err;
2519
- }
2520
- const idata = {};
2521
- const cdata = Object.entries(frm);
2522
- for (const item of cdata) {
2523
- if (item[0] === 'access') {
2524
- continue;
2411
+ cls = class extends AbstractForm {
2412
+ get filename() {
2413
+ return filename + '.js';
2525
2414
  }
2526
- idata[item[0]] = item[1];
2527
- }
2528
- idata._formFocus = false;
2529
- if (clickgo.isNative() && (formId === 1) && !clickgo.isImmersion() && !clickgo.hasFrame()) {
2530
- idata.isNativeSync = true;
2531
- }
2532
- const prot = tool.getClassPrototype(frm);
2533
- const methods = prot.method;
2534
- const computed = prot.access;
2535
- computed.formId = {
2536
- get: function () {
2537
- return formId;
2538
- },
2539
- set: function () {
2540
- notify({
2541
- 'title': 'Error',
2542
- 'content': `The software tries to modify the system variable "formId".\nPath: ${this.filename}`,
2543
- 'type': 'danger'
2544
- });
2545
- return;
2415
+ get taskId() {
2416
+ return t.id;
2546
2417
  }
2547
2418
  };
2548
- computed.path = {
2549
- get: function () {
2550
- return path;
2551
- },
2552
- set: function () {
2553
- notify({
2554
- 'title': 'Error',
2555
- 'content': `The software tries to modify the system variable "path".\nPath: ${this.filename}`,
2556
- 'type': 'danger'
2557
- });
2558
- return;
2419
+ }
2420
+ const formId = ++info.lastId;
2421
+ const frm = new cls();
2422
+ if (!filename) {
2423
+ filename = frm.filename;
2424
+ }
2425
+ const lio = filename.lastIndexOf('/');
2426
+ const path = filename.slice(0, lio);
2427
+ if (!layout) {
2428
+ const l = t.app.files[filename.slice(0, -2) + 'xml'];
2429
+ if (typeof l !== 'string') {
2430
+ const err = new Error('form.create: -4');
2431
+ core.trigger('error', 0, 0, err, err.message);
2432
+ throw err;
2433
+ }
2434
+ layout = l;
2435
+ }
2436
+ if (!style) {
2437
+ const s = t.app.files[filename.slice(0, -2) + 'css'];
2438
+ if (typeof s === 'string') {
2439
+ style = s;
2440
+ }
2441
+ }
2442
+ if (style) {
2443
+ const r = tool.stylePrepend(style);
2444
+ prep = r.prep;
2445
+ style = await tool.styleUrl2DataUrl(path + '/', r.style, t.app.files);
2446
+ }
2447
+ layout = tool.purify(layout);
2448
+ layout = tool.layoutAddTagClassAndReTagName(layout, true);
2449
+ const prepList = ['cg-task' + t.id.toString() + '_'];
2450
+ if (prep !== '') {
2451
+ prepList.push(prep);
2452
+ }
2453
+ layout = tool.layoutClassPrepend(layout, prepList);
2454
+ layout = tool.eventsAttrWrap(layout);
2455
+ if (layout.includes('<teleport')) {
2456
+ layout = tool.teleportGlue(layout, formId);
2457
+ }
2458
+ const components = control.buildComponents(t.id, formId, path);
2459
+ if (!components) {
2460
+ const err = new Error('form.create: -5');
2461
+ core.trigger('error', 0, 0, err, err.message);
2462
+ throw err;
2463
+ }
2464
+ const idata = {};
2465
+ const cdata = Object.entries(frm);
2466
+ for (const item of cdata) {
2467
+ if (item[0] === 'access') {
2468
+ continue;
2469
+ }
2470
+ idata[item[0]] = item[1];
2471
+ }
2472
+ idata._formFocus = false;
2473
+ if (clickgo.isNative() && (formId === 1) && !clickgo.isImmersion() && !clickgo.hasFrame()) {
2474
+ idata.isNativeSync = true;
2475
+ }
2476
+ const prot = tool.getClassPrototype(frm);
2477
+ const methods = prot.method;
2478
+ const computed = prot.access;
2479
+ computed.formId = {
2480
+ get: function () {
2481
+ return formId;
2482
+ },
2483
+ set: function () {
2484
+ notify({
2485
+ 'title': 'Error',
2486
+ 'content': `The software tries to modify the system variable "formId".\nPath: ${this.filename}`,
2487
+ 'type': 'danger'
2488
+ });
2489
+ return;
2490
+ }
2491
+ };
2492
+ computed.path = {
2493
+ get: function () {
2494
+ return path;
2495
+ },
2496
+ set: function () {
2497
+ notify({
2498
+ 'title': 'Error',
2499
+ 'content': `The software tries to modify the system variable "path".\nPath: ${this.filename}`,
2500
+ 'type': 'danger'
2501
+ });
2502
+ return;
2503
+ }
2504
+ };
2505
+ computed.prep = {
2506
+ get: function () {
2507
+ return prep;
2508
+ },
2509
+ set: function () {
2510
+ notify({
2511
+ 'title': 'Error',
2512
+ 'content': `The software tries to modify the system variable "prep".\nPath: ${this.filename}`,
2513
+ 'type': 'danger'
2514
+ });
2515
+ return;
2516
+ }
2517
+ };
2518
+ idata._bottomMost = false;
2519
+ computed.bottomMost = {
2520
+ get: function () {
2521
+ return this._bottomMost;
2522
+ },
2523
+ set: function (v) {
2524
+ if (v) {
2525
+ this._bottomMost = true;
2526
+ this.$el.dataset.cgBottomMost = '';
2527
+ if (this._topMost) {
2528
+ this._topMost = false;
2529
+ }
2530
+ this.$refs.form.$data.zIndex = ++info.bottomLastZIndex;
2559
2531
  }
2560
- };
2561
- computed.prep = {
2562
- get: function () {
2563
- return prep;
2564
- },
2565
- set: function () {
2566
- notify({
2567
- 'title': 'Error',
2568
- 'content': `The software tries to modify the system variable "prep".\nPath: ${this.filename}`,
2569
- 'type': 'danger'
2570
- });
2571
- return;
2532
+ else {
2533
+ this._bottomMost = false;
2534
+ this.$el.removeAttribute('data-cg-bottom-most');
2535
+ this.$refs.form.$data.zIndex = ++info.lastZIndex;
2572
2536
  }
2573
- };
2574
- idata._bottomMost = false;
2575
- computed.bottomMost = {
2576
- get: function () {
2577
- return this._bottomMost;
2578
- },
2579
- set: function (v) {
2580
- if (v) {
2581
- this._bottomMost = true;
2582
- this.$el.dataset.cgBottomMost = '';
2583
- if (this._topMost) {
2584
- this._topMost = false;
2585
- }
2586
- this.$refs.form.$data.zIndex = ++info.bottomLastZIndex;
2587
- }
2588
- else {
2537
+ }
2538
+ };
2539
+ idata._topMost = false;
2540
+ computed.topMost = {
2541
+ get: function () {
2542
+ return this._topMost;
2543
+ },
2544
+ set: function (v) {
2545
+ if (v) {
2546
+ this._topMost = true;
2547
+ if (this._bottomMost) {
2589
2548
  this._bottomMost = false;
2590
2549
  this.$el.removeAttribute('data-cg-bottom-most');
2591
- this.$refs.form.$data.zIndex = ++info.lastZIndex;
2592
2550
  }
2593
- }
2594
- };
2595
- idata._topMost = false;
2596
- computed.topMost = {
2597
- get: function () {
2598
- return this._topMost;
2599
- },
2600
- set: function (v) {
2601
- if (v) {
2602
- this._topMost = true;
2603
- if (this._bottomMost) {
2604
- this._bottomMost = false;
2605
- this.$el.removeAttribute('data-cg-bottom-most');
2606
- }
2607
- if (!this._formFocus) {
2608
- changeFocus(this.formId);
2609
- }
2610
- else {
2611
- this.$refs.form.$data.zIndex = ++info.topLastZIndex;
2612
- }
2551
+ if (!this._formFocus) {
2552
+ changeFocus(this.formId);
2613
2553
  }
2614
2554
  else {
2615
- this._topMost = false;
2616
- this.$refs.form.$data.zIndex = ++info.lastZIndex;
2617
- }
2618
- }
2619
- };
2620
- idata._historyHash = [];
2621
- idata._formHash = '';
2622
- computed.formHash = {
2623
- get: function () {
2624
- return this._formHash;
2625
- },
2626
- set: function (v) {
2627
- if (v === this._formHash) {
2628
- return;
2555
+ this.$refs.form.$data.zIndex = ++info.topLastZIndex;
2629
2556
  }
2630
- if (Date.now() - this._lastFormHashData > 300) {
2631
- this._formHashData = {};
2632
- }
2633
- if (this.inStep) {
2634
- (() => __awaiter(this, void 0, void 0, function* () {
2635
- if (this._stepValues.includes(v)) {
2636
- this.$refs.form.stepValue = v;
2637
- }
2638
- else {
2639
- if (!(yield clickgo.form.confirm({
2640
- 'taskId': this.taskId,
2641
- 'content': info.locale[this.locale].confirmExitStep
2642
- }))) {
2643
- return;
2644
- }
2645
- this._inStep = false;
2646
- this.$refs.form.stepHide();
2647
- }
2648
- if (this._formHash) {
2649
- this._historyHash.push(this._formHash);
2650
- }
2651
- this._formHash = v;
2652
- core.trigger('formHashChange', t.id, formId, v, this._formHashData);
2653
- }))();
2654
- return;
2655
- }
2656
- if (this._formHash) {
2657
- this._historyHash.push(this._formHash);
2658
- }
2659
- this._formHash = v;
2660
- core.trigger('formHashChange', t.id, formId, v, this._formHashData);
2661
- }
2662
- };
2663
- idata._lastFormHashData = 0;
2664
- idata._formHashData = {};
2665
- computed.formHashData = {
2666
- get: function () {
2667
- return this._formHashData;
2668
- },
2669
- set: function (v) {
2670
- this._formHashData = v;
2671
- this._lastFormHashData = Date.now();
2672
2557
  }
2673
- };
2674
- idata._showInSystemTask = true;
2675
- computed.showInSystemTask = {
2676
- get: function () {
2677
- return this._showInSystemTask;
2678
- },
2679
- set: function (v) {
2680
- this._showInSystemTask = v;
2681
- core.trigger('formShowInSystemTaskChange', t.id, formId, v);
2558
+ else {
2559
+ this._topMost = false;
2560
+ this.$refs.form.$data.zIndex = ++info.lastZIndex;
2682
2561
  }
2683
- };
2684
- const cbs = [];
2685
- methods.ready = function (cb) {
2686
- if (this.isReady) {
2687
- cb();
2562
+ }
2563
+ };
2564
+ idata._historyHash = [];
2565
+ idata._formHash = '';
2566
+ computed.formHash = {
2567
+ get: function () {
2568
+ return this._formHash;
2569
+ },
2570
+ set: function (v) {
2571
+ if (v === this._formHash) {
2688
2572
  return;
2689
2573
  }
2690
- cbs.push(cb);
2691
- };
2692
- exports.elements.list.insertAdjacentHTML('beforeend', `<div class="cg-form-wrap" data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
2693
- exports.elements.popList.insertAdjacentHTML('beforeend', `<div data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
2694
- if (style) {
2695
- dom.pushStyle(t.id, style, 'form', formId);
2696
- }
2697
- const el = exports.elements.list.children.item(exports.elements.list.children.length - 1);
2698
- const rtn = yield new Promise(function (resolve) {
2699
- const vapp = clickgo.vue.createApp({
2700
- 'template': layout.replace(/^<cg-form/, '<cg-form ref="form"'),
2701
- 'data': function () {
2702
- return tool.clone(idata);
2703
- },
2704
- 'methods': methods,
2705
- 'computed': computed,
2706
- 'beforeCreate': frm.onBeforeCreate,
2707
- 'created': function () {
2708
- if (frm.access) {
2709
- this.access = tool.clone(frm.access);
2574
+ if (Date.now() - this._lastFormHashData > 300) {
2575
+ this._formHashData = {};
2576
+ }
2577
+ if (this.inStep) {
2578
+ (async () => {
2579
+ if (this._stepValues.includes(v)) {
2580
+ this.$refs.form.stepValue = v;
2710
2581
  }
2711
- this.onCreated();
2712
- },
2713
- 'beforeMount': function () {
2714
- this.onBeforeMount();
2715
- },
2716
- 'mounted': function () {
2717
- return __awaiter(this, void 0, void 0, function* () {
2718
- yield this.$nextTick();
2719
- if (this.$refs.form.icon) {
2720
- const icon = yield fs.getContent(this.$refs.form.icon, undefined, taskId);
2721
- this.$refs.form.iconDataUrl = (icon instanceof Blob) ? yield tool.blob2DataUrl(icon) : '';
2582
+ else {
2583
+ if (!await clickgo.form.confirm({
2584
+ 'taskId': this.taskId,
2585
+ 'content': info.locale[this.locale].confirmExitStep
2586
+ })) {
2587
+ return;
2722
2588
  }
2723
- resolve({
2724
- 'vapp': vapp,
2725
- 'vroot': this
2726
- });
2727
- });
2728
- },
2729
- 'beforeUpdate': function () {
2730
- this.onBeforeUpdate();
2731
- },
2732
- 'updated': function () {
2733
- return __awaiter(this, void 0, void 0, function* () {
2734
- yield this.$nextTick();
2735
- this.onUpdated();
2736
- });
2737
- },
2738
- 'beforeUnmount': function () {
2739
- this.onBeforeUnmount();
2740
- },
2741
- 'unmounted': function () {
2742
- return __awaiter(this, void 0, void 0, function* () {
2743
- yield this.$nextTick();
2744
- this.onUnmounted();
2745
- });
2746
- }
2747
- });
2748
- vapp.config.errorHandler = function (err, vm, info) {
2749
- notify({
2750
- 'title': 'Runtime Error',
2751
- 'content': `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`,
2752
- 'type': 'danger'
2753
- });
2754
- console.error('Runtime Error [form.create.errorHandler]', `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`, err, info);
2755
- core.trigger('error', vm.taskId, vm.formId, err, info + '(-3,' + vm.taskId + ',' + vm.formId + ')');
2756
- };
2757
- for (const key in components) {
2758
- vapp.component(key, components[key]);
2589
+ this._inStep = false;
2590
+ this.$refs.form.stepHide();
2591
+ }
2592
+ if (this._formHash) {
2593
+ this._historyHash.push(this._formHash);
2594
+ }
2595
+ this._formHash = v;
2596
+ core.trigger('formHashChange', t.id, formId, v, this._formHashData);
2597
+ })();
2598
+ return;
2759
2599
  }
2760
- try {
2761
- vapp.mount(el);
2600
+ if (this._formHash) {
2601
+ this._historyHash.push(this._formHash);
2762
2602
  }
2763
- catch (err) {
2764
- notify({
2765
- 'title': 'Runtime Error',
2766
- 'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
2767
- 'type': 'danger'
2603
+ this._formHash = v;
2604
+ core.trigger('formHashChange', t.id, formId, v, this._formHashData);
2605
+ }
2606
+ };
2607
+ idata._lastFormHashData = 0;
2608
+ idata._formHashData = {};
2609
+ computed.formHashData = {
2610
+ get: function () {
2611
+ return this._formHashData;
2612
+ },
2613
+ set: function (v) {
2614
+ this._formHashData = v;
2615
+ this._lastFormHashData = Date.now();
2616
+ }
2617
+ };
2618
+ idata._showInSystemTask = true;
2619
+ computed.showInSystemTask = {
2620
+ get: function () {
2621
+ return this._showInSystemTask;
2622
+ },
2623
+ set: function (v) {
2624
+ this._showInSystemTask = v;
2625
+ core.trigger('formShowInSystemTaskChange', t.id, formId, v);
2626
+ }
2627
+ };
2628
+ const cbs = [];
2629
+ methods.ready = function (cb) {
2630
+ if (this.isReady) {
2631
+ cb();
2632
+ return;
2633
+ }
2634
+ cbs.push(cb);
2635
+ };
2636
+ exports.elements.list.insertAdjacentHTML('beforeend', `<div class="cg-form-wrap" data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
2637
+ exports.elements.popList.insertAdjacentHTML('beforeend', `<div data-form-id="${formId.toString()}" data-task-id="${t.id.toString()}"></div>`);
2638
+ if (style) {
2639
+ dom.pushStyle(t.id, style, 'form', formId);
2640
+ }
2641
+ const el = exports.elements.list.children.item(exports.elements.list.children.length - 1);
2642
+ const rtn = await new Promise(function (resolve) {
2643
+ const vapp = clickgo.vue.createApp({
2644
+ 'template': layout.replace(/^<cg-form/, '<cg-form ref="form"'),
2645
+ 'data': function () {
2646
+ return tool.clone(idata);
2647
+ },
2648
+ 'methods': methods,
2649
+ 'computed': computed,
2650
+ 'beforeCreate': frm.onBeforeCreate,
2651
+ 'created': function () {
2652
+ if (frm.access) {
2653
+ this.access = tool.clone(frm.access);
2654
+ }
2655
+ this.onCreated();
2656
+ },
2657
+ 'beforeMount': function () {
2658
+ this.onBeforeMount();
2659
+ },
2660
+ 'mounted': async function () {
2661
+ await this.$nextTick();
2662
+ if (this.$refs.form.icon) {
2663
+ const icon = await fs.getContent(this.$refs.form.icon, undefined, taskId);
2664
+ this.$refs.form.iconDataUrl = (icon instanceof Blob) ? await tool.blob2DataUrl(icon) : '';
2665
+ }
2666
+ resolve({
2667
+ 'vapp': vapp,
2668
+ 'vroot': this
2768
2669
  });
2769
- console.error('Runtime Error [form.create.mount]', `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`, err);
2770
- core.trigger('error', t.id, formId, err, err.message);
2670
+ },
2671
+ 'beforeUpdate': function () {
2672
+ this.onBeforeUpdate();
2673
+ },
2674
+ 'updated': async function () {
2675
+ await this.$nextTick();
2676
+ this.onUpdated();
2677
+ },
2678
+ 'beforeUnmount': function () {
2679
+ this.onBeforeUnmount();
2680
+ },
2681
+ 'unmounted': async function () {
2682
+ await this.$nextTick();
2683
+ this.onUnmounted();
2771
2684
  }
2772
2685
  });
2773
- const nform = {
2774
- 'id': formId,
2775
- 'vapp': rtn.vapp,
2776
- 'vroot': rtn.vroot,
2777
- 'closed': false
2686
+ vapp.config.errorHandler = function (err, vm, info) {
2687
+ notify({
2688
+ 'title': 'Runtime Error',
2689
+ 'content': `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`,
2690
+ 'type': 'danger'
2691
+ });
2692
+ console.error('Runtime Error [form.create.errorHandler]', `Message: ${err.message}\nTask id: ${vm.taskId}\nForm id: ${vm.formId}`, err, info);
2693
+ core.trigger('error', vm.taskId, vm.formId, err, info + '(-3,' + vm.taskId + ',' + vm.formId + ')');
2778
2694
  };
2779
- t.forms[formId] = nform;
2780
- yield tool.sleep(34);
2695
+ for (const key in components) {
2696
+ vapp.component(key, components[key]);
2697
+ }
2781
2698
  try {
2782
- yield frm.onMounted.call(rtn.vroot, data !== null && data !== void 0 ? data : {});
2699
+ vapp.mount(el);
2783
2700
  }
2784
2701
  catch (err) {
2785
- core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error: -6.');
2786
- delete t.forms[formId];
2787
- try {
2788
- rtn.vapp.unmount();
2789
- }
2790
- catch (err) {
2791
- const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.create, unmount.`;
2792
- notify({
2793
- 'title': 'Form Unmount Error',
2794
- 'content': msg,
2795
- 'type': 'danger'
2796
- });
2797
- console.log('Form Unmount Error', msg, err);
2798
- }
2799
- rtn.vapp._container.remove();
2800
- (_b = exports.elements.popList.querySelector('[data-form-id="' + rtn.vroot.formId + '"]')) === null || _b === void 0 ? void 0 : _b.remove();
2801
- dom.clearWatchStyle(rtn.vroot.formId);
2802
- dom.clearWatchProperty(rtn.vroot.formId);
2803
- dom.clearWatchPosition(rtn.vroot.formId);
2804
- native.clear(formId, t.id);
2805
- dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
2806
- throw err;
2807
- }
2808
- core.trigger('formCreated', t.id, formId, rtn.vroot.$refs.form.title, rtn.vroot.$refs.form.iconDataUrl, rtn.vroot.showInSystemTask);
2809
- if (rtn.vroot.isNativeSync) {
2810
- yield native.invoke('cg-set-size', native.getToken(), rtn.vroot.$refs.form.$el.offsetWidth, rtn.vroot.$refs.form.$el.offsetHeight);
2811
- window.addEventListener('resize', function () {
2812
- rtn.vroot.$refs.form.setPropData('width', window.innerWidth);
2813
- rtn.vroot.$refs.form.setPropData('height', window.innerHeight);
2702
+ notify({
2703
+ 'title': 'Runtime Error',
2704
+ 'content': `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`,
2705
+ 'type': 'danger'
2814
2706
  });
2707
+ console.error('Runtime Error [form.create.mount]', `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}`, err);
2708
+ core.trigger('error', t.id, formId, err, err.message);
2815
2709
  }
2816
- rtn.vroot.isReady = true;
2817
- for (const cb of cbs) {
2818
- cb.call(rtn.vroot);
2819
- }
2820
- return rtn.vroot;
2821
2710
  });
2711
+ const nform = {
2712
+ 'id': formId,
2713
+ 'vapp': rtn.vapp,
2714
+ 'vroot': rtn.vroot,
2715
+ 'closed': false
2716
+ };
2717
+ t.forms[formId] = nform;
2718
+ await tool.sleep(34);
2719
+ try {
2720
+ await frm.onMounted.call(rtn.vroot, data ?? {});
2721
+ }
2722
+ catch (err) {
2723
+ core.trigger('error', rtn.vroot.taskId, rtn.vroot.formId, err, 'Create form mounted error: -6.');
2724
+ delete t.forms[formId];
2725
+ try {
2726
+ rtn.vapp.unmount();
2727
+ }
2728
+ catch (err) {
2729
+ const msg = `Message: ${err.message}\nTask id: ${t.id}\nForm id: ${formId}\nFunction: form.create, unmount.`;
2730
+ notify({
2731
+ 'title': 'Form Unmount Error',
2732
+ 'content': msg,
2733
+ 'type': 'danger'
2734
+ });
2735
+ console.log('Form Unmount Error', msg, err);
2736
+ }
2737
+ rtn.vapp._container.remove();
2738
+ exports.elements.popList.querySelector('[data-form-id="' + rtn.vroot.formId + '"]')?.remove();
2739
+ dom.clearWatchStyle(rtn.vroot.formId);
2740
+ dom.clearWatchProperty(rtn.vroot.formId);
2741
+ dom.clearWatchPosition(rtn.vroot.formId);
2742
+ native.clear(formId, t.id);
2743
+ dom.removeStyle(rtn.vroot.taskId, 'form', rtn.vroot.formId);
2744
+ throw err;
2745
+ }
2746
+ core.trigger('formCreated', t.id, formId, rtn.vroot.$refs.form.title, rtn.vroot.$refs.form.iconDataUrl, rtn.vroot.showInSystemTask);
2747
+ if (rtn.vroot.isNativeSync) {
2748
+ await native.invoke('cg-set-size', native.getToken(), rtn.vroot.$refs.form.$el.offsetWidth, rtn.vroot.$refs.form.$el.offsetHeight);
2749
+ window.addEventListener('resize', function () {
2750
+ rtn.vroot.$refs.form.setPropData('width', window.innerWidth);
2751
+ rtn.vroot.$refs.form.setPropData('height', window.innerHeight);
2752
+ });
2753
+ }
2754
+ rtn.vroot.isReady = true;
2755
+ for (const cb of cbs) {
2756
+ cb.call(rtn.vroot);
2757
+ }
2758
+ return rtn.vroot;
2822
2759
  }
2823
2760
  function dialog(opt) {
2824
2761
  return new Promise(function (resolve) {
2825
- var _a, _b, _c, _d, _e;
2826
2762
  if (typeof opt === 'string') {
2827
2763
  opt = {
2828
2764
  'content': opt
2829
2765
  };
2830
2766
  }
2831
- const filename = tool.urlResolve((_a = opt.path) !== null && _a !== void 0 ? _a : '/', './tmp' + (Math.random() * 100000000000000).toFixed() + '.js');
2767
+ const filename = tool.urlResolve(opt.path ?? '/', './tmp' + (Math.random() * 100000000000000).toFixed() + '.js');
2832
2768
  const nopt = opt;
2833
2769
  const taskId = nopt.taskId;
2834
2770
  if (!taskId) {
@@ -2841,14 +2777,13 @@ function dialog(opt) {
2841
2777
  return;
2842
2778
  }
2843
2779
  const locale = t.locale.lang || core.config.locale;
2844
- (_b = nopt.buttons) !== null && _b !== void 0 ? _b : (nopt.buttons = [(_d = (_c = info.locale[locale]) === null || _c === void 0 ? void 0 : _c.ok) !== null && _d !== void 0 ? _d : info.locale['en'].ok]);
2780
+ nopt.buttons ??= [info.locale[locale]?.ok ?? info.locale['en'].ok];
2845
2781
  const cls = class extends AbstractForm {
2846
2782
  constructor() {
2847
- var _a, _b;
2848
2783
  super(...arguments);
2849
2784
  this.buttons = nopt.buttons;
2850
- this.data = (_a = nopt.data) !== null && _a !== void 0 ? _a : {};
2851
- this.methods = (_b = nopt.methods) !== null && _b !== void 0 ? _b : {};
2785
+ this.data = nopt.data ?? {};
2786
+ this.methods = nopt.methods ?? {};
2852
2787
  }
2853
2788
  get filename() {
2854
2789
  return filename;
@@ -2878,7 +2813,7 @@ function dialog(opt) {
2878
2813
  }
2879
2814
  };
2880
2815
  create(cls, undefined, {
2881
- 'layout': `<form title="${(_e = nopt.title) !== null && _e !== void 0 ? _e : 'dialog'}" min="false" max="false" resize="false" height="0" width="0" border="${nopt.title ? 'normal' : 'plain'}" direction="v"><dialog :buttons="buttons" @select="select"${nopt.direction ? ` direction="${nopt.direction}"` : ''}${nopt.gutter ? ` gutter="${nopt.gutter}"` : ''}>${nopt.content}</dialog></form>`,
2816
+ 'layout': `<form title="${nopt.title ?? 'dialog'}" min="false" max="false" resize="false" height="0" width="0" border="${nopt.title ? 'normal' : 'plain'}" direction="v"><dialog :buttons="buttons" @select="select"${nopt.direction ? ` direction="${nopt.direction}"` : ''}${nopt.gutter ? ` gutter="${nopt.gutter}"` : ''}>${nopt.content}</dialog></form>`,
2882
2817
  'style': nopt.style
2883
2818
  }, t.id).then((frm) => {
2884
2819
  if (typeof frm === 'number') {
@@ -2895,100 +2830,93 @@ function dialog(opt) {
2895
2830
  });
2896
2831
  });
2897
2832
  }
2898
- function confirm(opt) {
2899
- return __awaiter(this, void 0, void 0, function* () {
2900
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2901
- if (typeof opt === 'string') {
2902
- opt = {
2903
- 'content': opt
2904
- };
2905
- }
2906
- const taskId = opt.taskId;
2907
- if (!taskId) {
2908
- return false;
2909
- }
2910
- const t = task.list[taskId];
2911
- if (!t) {
2912
- return false;
2913
- }
2914
- const locale = t.locale.lang || core.config.locale;
2915
- const buttons = [(_b = (_a = info.locale[locale]) === null || _a === void 0 ? void 0 : _a.no) !== null && _b !== void 0 ? _b : info.locale['en'].no, (_d = (_c = info.locale[locale]) === null || _c === void 0 ? void 0 : _c.yes) !== null && _d !== void 0 ? _d : info.locale['en'].yes];
2916
- if (opt.cancel) {
2917
- buttons.unshift((_f = (_e = info.locale[locale]) === null || _e === void 0 ? void 0 : _e.cancel) !== null && _f !== void 0 ? _f : info.locale['en'].cancel);
2918
- }
2919
- const res = yield dialog({
2920
- 'taskId': taskId,
2921
- 'title': opt.title,
2922
- 'content': opt.content,
2923
- 'buttons': buttons
2924
- });
2925
- if (res === ((_h = (_g = info.locale[locale]) === null || _g === void 0 ? void 0 : _g.yes) !== null && _h !== void 0 ? _h : info.locale['en'].yes)) {
2926
- return true;
2927
- }
2928
- if (res === ((_k = (_j = info.locale[locale]) === null || _j === void 0 ? void 0 : _j.cancel) !== null && _k !== void 0 ? _k : info.locale['en'].cancel)) {
2929
- return 0;
2930
- }
2833
+ async function confirm(opt) {
2834
+ if (typeof opt === 'string') {
2835
+ opt = {
2836
+ 'content': opt
2837
+ };
2838
+ }
2839
+ const taskId = opt.taskId;
2840
+ if (!taskId) {
2841
+ return false;
2842
+ }
2843
+ const t = task.list[taskId];
2844
+ if (!t) {
2931
2845
  return false;
2846
+ }
2847
+ const locale = t.locale.lang || core.config.locale;
2848
+ const buttons = [info.locale[locale]?.no ?? info.locale['en'].no, info.locale[locale]?.yes ?? info.locale['en'].yes];
2849
+ if (opt.cancel) {
2850
+ buttons.unshift(info.locale[locale]?.cancel ?? info.locale['en'].cancel);
2851
+ }
2852
+ const res = await dialog({
2853
+ 'taskId': taskId,
2854
+ 'title': opt.title,
2855
+ 'content': opt.content,
2856
+ 'buttons': buttons
2932
2857
  });
2858
+ if (res === (info.locale[locale]?.yes ?? info.locale['en'].yes)) {
2859
+ return true;
2860
+ }
2861
+ if (res === (info.locale[locale]?.cancel ?? info.locale['en'].cancel)) {
2862
+ return 0;
2863
+ }
2864
+ return false;
2933
2865
  }
2934
- function prompt(opt) {
2935
- return __awaiter(this, void 0, void 0, function* () {
2936
- var _a, _b, _c, _d, _e;
2937
- if (typeof opt === 'string') {
2938
- opt = {
2939
- 'content': opt
2940
- };
2941
- }
2942
- const taskId = opt.taskId;
2943
- if (!taskId) {
2944
- return '';
2945
- }
2946
- const t = task.list[taskId];
2947
- if (!t) {
2948
- return '';
2949
- }
2950
- const locale = t.locale.lang || core.config.locale;
2951
- const buttons = [(_b = (_a = info.locale[locale]) === null || _a === void 0 ? void 0 : _a.ok) !== null && _b !== void 0 ? _b : info.locale['en'].ok];
2952
- const cancelBtn = (_d = (_c = info.locale[locale]) === null || _c === void 0 ? void 0 : _c.cancel) !== null && _d !== void 0 ? _d : info.locale['en'].cancel;
2953
- if (opt.cancel === true || opt.cancel === undefined) {
2954
- buttons.unshift(cancelBtn);
2955
- }
2956
- const res = yield dialog({
2957
- 'taskId': taskId,
2958
- 'title': opt.title,
2959
- 'direction': 'v',
2960
- 'gutter': 10,
2961
- 'content': '<block>' + opt.content + '</block><text v-model="data.text" />',
2962
- 'data': {
2963
- 'text': (_e = opt.text) !== null && _e !== void 0 ? _e : ''
2964
- },
2965
- 'select': function (e, button) {
2966
- var _a;
2967
- const event = {
2968
- 'go': true,
2969
- preventDefault: function () {
2970
- this.go = false;
2971
- },
2972
- 'detail': {
2973
- 'button': button,
2974
- 'value': this.data.text
2975
- }
2976
- };
2977
- (_a = opt.select) === null || _a === void 0 ? void 0 : _a.call(this, event, button);
2978
- if (!event.go) {
2979
- e.preventDefault();
2980
- }
2981
- if (e.detail.button === cancelBtn) {
2982
- this.dialogResult = '';
2983
- return;
2866
+ async function prompt(opt) {
2867
+ if (typeof opt === 'string') {
2868
+ opt = {
2869
+ 'content': opt
2870
+ };
2871
+ }
2872
+ const taskId = opt.taskId;
2873
+ if (!taskId) {
2874
+ return '';
2875
+ }
2876
+ const t = task.list[taskId];
2877
+ if (!t) {
2878
+ return '';
2879
+ }
2880
+ const locale = t.locale.lang || core.config.locale;
2881
+ const buttons = [info.locale[locale]?.ok ?? info.locale['en'].ok];
2882
+ const cancelBtn = info.locale[locale]?.cancel ?? info.locale['en'].cancel;
2883
+ if (opt.cancel === true || opt.cancel === undefined) {
2884
+ buttons.unshift(cancelBtn);
2885
+ }
2886
+ const res = await dialog({
2887
+ 'taskId': taskId,
2888
+ 'title': opt.title,
2889
+ 'direction': 'v',
2890
+ 'gutter': 10,
2891
+ 'content': '<block>' + opt.content + '</block><text v-model="data.text" />',
2892
+ 'data': {
2893
+ 'text': opt.text ?? ''
2894
+ },
2895
+ 'select': function (e, button) {
2896
+ const event = {
2897
+ 'go': true,
2898
+ preventDefault: function () {
2899
+ this.go = false;
2900
+ },
2901
+ 'detail': {
2902
+ 'button': button,
2903
+ 'value': this.data.text
2984
2904
  }
2985
- this.dialogResult = this.data.text;
2986
- },
2987
- 'buttons': buttons,
2988
- 'autoDialogResult': false
2989
- });
2990
- return res;
2905
+ };
2906
+ opt.select?.call(this, event, button);
2907
+ if (!event.go) {
2908
+ e.preventDefault();
2909
+ }
2910
+ if (e.detail.button === cancelBtn) {
2911
+ this.dialogResult = '';
2912
+ return;
2913
+ }
2914
+ this.dialogResult = this.data.text;
2915
+ },
2916
+ 'buttons': buttons,
2917
+ 'autoDialogResult': false
2991
2918
  });
2919
+ return res;
2992
2920
  }
2993
2921
  function flash(formId, taskId) {
2994
2922
  if (!taskId) {