clickgo 3.1.5-dev14 → 3.1.6-dev15

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 (92) hide show
  1. package/README.md +7 -7
  2. package/dist/app/demo/app.js +28 -2
  3. package/dist/app/demo/config.json +17 -1
  4. package/dist/app/demo/form/control/box/box.js +66 -0
  5. package/dist/app/demo/form/control/box/box.xml +18 -0
  6. package/dist/app/demo/form/control/button/button.js +24 -1
  7. package/dist/app/demo/form/control/check/check.js +24 -1
  8. package/dist/app/demo/form/control/dialog/dialog.js +24 -1
  9. package/dist/app/demo/form/control/file/file.js +24 -1
  10. package/dist/app/demo/form/control/flow/flow.js +24 -1
  11. package/dist/app/demo/form/control/form/form.js +24 -1
  12. package/dist/app/demo/form/control/layout/layout.js +57 -0
  13. package/dist/app/demo/form/control/layout/layout.xml +16 -0
  14. package/dist/app/demo/form/control/list/list.js +24 -1
  15. package/dist/app/demo/form/control/list/list.xml +8 -2
  16. package/dist/app/demo/form/control/marquee/marquee.js +24 -2
  17. package/dist/app/demo/form/control/marquee/marquee.xml +2 -5
  18. package/dist/app/demo/form/control/menu/menu.js +24 -1
  19. package/dist/app/demo/form/control/monaco/monaco.js +24 -1
  20. package/dist/app/demo/form/control/nav/nav.js +52 -0
  21. package/dist/app/demo/form/control/nav/nav.xml +43 -0
  22. package/dist/app/demo/form/control/panel/panel.js +67 -0
  23. package/dist/app/demo/form/control/panel/panel.xml +11 -0
  24. package/dist/app/demo/form/control/panel/test1.js +58 -0
  25. package/dist/app/demo/form/control/panel/test1.xml +16 -0
  26. package/dist/app/demo/form/control/panel/test2.xml +3 -0
  27. package/dist/app/demo/form/control/property/property.js +24 -1
  28. package/dist/app/demo/form/control/radio/radio.js +24 -1
  29. package/dist/app/demo/form/control/scroll/scroll.js +25 -1
  30. package/dist/app/demo/form/control/scroll/scroll.xml +5 -2
  31. package/dist/app/demo/form/control/select/select.js +24 -1
  32. package/dist/app/demo/form/control/tab/tab.js +24 -1
  33. package/dist/app/demo/form/control/table/table.js +164 -0
  34. package/dist/app/demo/form/control/table/table.xml +35 -0
  35. package/dist/app/demo/form/control/text/text.js +24 -1
  36. package/dist/app/demo/form/control/vflow/vflow.js +24 -1
  37. package/dist/app/demo/form/event/form/form.js +24 -1
  38. package/dist/app/demo/form/event/other/other.js +24 -1
  39. package/dist/app/demo/form/event/screen/screen.js +24 -1
  40. package/dist/app/demo/form/event/task/task.js +24 -1
  41. package/dist/app/demo/form/main.js +84 -33
  42. package/dist/app/demo/form/main.xml +5 -0
  43. package/dist/app/demo/form/method/aform/aform.js +28 -2
  44. package/dist/app/demo/form/method/aform/sd.js +24 -1
  45. package/dist/app/demo/form/method/core/core.js +24 -1
  46. package/dist/app/demo/form/method/dom/dom.js +48 -2
  47. package/dist/app/demo/form/method/dom/dom.xml +11 -0
  48. package/dist/app/demo/form/method/form/form.js +35 -1
  49. package/dist/app/demo/form/method/form/form.xml +2 -0
  50. package/dist/app/demo/form/method/fs/fs.js +138 -4
  51. package/dist/app/demo/form/method/fs/fs.xml +11 -1
  52. package/dist/app/demo/form/method/fs/text.js +24 -1
  53. package/dist/app/demo/form/method/native/native.js +24 -1
  54. package/dist/app/demo/form/method/system/system.js +24 -1
  55. package/dist/app/demo/form/method/task/task.js +31 -4
  56. package/dist/app/demo/form/method/task/task.xml +6 -1
  57. package/dist/app/demo/form/method/theme/theme.js +24 -1
  58. package/dist/app/demo/form/method/tool/tool.js +35 -1
  59. package/dist/app/demo/form/method/zip/zip.js +29 -3
  60. package/dist/app/task/app.js +28 -2
  61. package/dist/app/task/form/bar/bar.js +24 -1
  62. package/dist/clickgo.js +33 -10
  63. package/dist/control/box.cgc +0 -0
  64. package/dist/control/common.cgc +0 -0
  65. package/dist/control/form.cgc +0 -0
  66. package/dist/control/monaco.cgc +0 -0
  67. package/dist/control/nav.cgc +0 -0
  68. package/dist/control/property.cgc +0 -0
  69. package/dist/control/table.cgc +0 -0
  70. package/dist/control/task.cgc +0 -0
  71. package/dist/global.css +1 -1
  72. package/dist/lib/control.js +53 -12
  73. package/dist/lib/control.ts +25 -5
  74. package/dist/lib/core.js +44 -45
  75. package/dist/lib/core.ts +17 -41
  76. package/dist/lib/dom.js +322 -108
  77. package/dist/lib/dom.ts +394 -127
  78. package/dist/lib/form.js +441 -58
  79. package/dist/lib/form.ts +525 -74
  80. package/dist/lib/fs.js +485 -224
  81. package/dist/lib/fs.ts +493 -287
  82. package/dist/lib/native.js +24 -1
  83. package/dist/lib/task.js +143 -136
  84. package/dist/lib/task.ts +124 -127
  85. package/dist/lib/theme.js +27 -4
  86. package/dist/lib/tool.js +19 -2
  87. package/dist/lib/tool.ts +23 -1
  88. package/dist/lib/zip.js +29 -3
  89. package/dist/lib/zip.ts +1 -1
  90. package/dist/theme/familiar.cgt +0 -0
  91. package/package.json +4 -6
  92. package/types/index.d.ts +42 -34
package/dist/lib/dom.js CHANGED
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -9,12 +32,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
32
  });
10
33
  };
11
34
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.fullscreen = exports.siblingsData = exports.siblings = exports.findParentByClass = exports.findParentByData = exports.bindResize = exports.bindMove = exports.is = exports.bindDrag = exports.bindLong = exports.allowEvent = exports.bindGesture = exports.bindDown = exports.bindClick = exports.clearWatchProperty = exports.isWatchProperty = exports.watchProperty = exports.clearWatchStyle = exports.isWatchStyle = exports.watchStyle = exports.clearWatch = exports.isWatch = exports.unwatch = exports.watch = exports.clearWatchSize = exports.isWatchSize = exports.unwatchSize = exports.watchSize = exports.getStyleCount = exports.removeStyle = exports.pushStyle = exports.removeFromStyleList = exports.createToStyleList = exports.hasTouchButMouse = exports.setGlobalCursor = void 0;
13
- const clickgo = require("../clickgo");
14
- const form = require("./form");
15
- const core = require("./core");
16
- const tool = require("./tool");
17
- const topClass = ['#cg-form-list', '#cg-pop-list', '#cg-notify', '#cg-simpletask', '#cg-launcher'];
35
+ exports.fullscreen = exports.siblingsData = exports.siblings = exports.findParentByClass = exports.findParentByData = exports.bindResize = exports.bindMove = exports.is = exports.bindDrag = exports.bindLong = exports.allowEvent = exports.bindGesture = exports.bindDown = exports.bindClick = exports.getWatchInfo = exports.clearWatchProperty = exports.isWatchProperty = exports.watchProperty = exports.clearWatchStyle = exports.isWatchStyle = exports.watchStyle = exports.clearWatch = exports.isWatch = exports.unwatch = exports.watch = exports.getWatchCount = exports.clearWatchSize = exports.isWatchSize = exports.unwatchSize = exports.watchSize = exports.getWatchSizeCount = exports.getStyleCount = exports.removeStyle = exports.pushStyle = exports.removeFromStyleList = exports.createToStyleList = exports.hasTouchButMouse = exports.setGlobalCursor = exports.inPage = void 0;
36
+ const clickgo = __importStar(require("../clickgo"));
37
+ const form = __importStar(require("./form"));
38
+ const core = __importStar(require("./core"));
39
+ const tool = __importStar(require("./tool"));
40
+ const topClass = ['#cg-form-list', '#cg-pop-list', '#cg-notify', '#cg-simpletask', '#cg-launcher', '#cg-confirm'];
18
41
  function classUnfold(after, out = []) {
19
42
  const arr = [];
20
43
  for (const name of topClass) {
@@ -37,6 +60,10 @@ ${classUnfold('::selection', ['#cg-launcher'])} {background-color: rgba(0, 0, 0,
37
60
  ${classUnfold('*')}, ${classUnfold('*::after')}, ${classUnfold('*::before')} {box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}
38
61
  ${classUnfold()}, ${classUnfold('input')}, ${classUnfold('textarea')} {font-family: "Lucida Sans Unicode", "Helvetica Neue","Helvetica","PingFang SC","Hiragino Sans GB","Noto Sans CJK SC","Noto Sans CJK","Source Han Sans","WenQuanYi Micro Hei","Microsoft YaHei",sans-serif; font-size: 12px; line-height: 1; -webkit-font-smoothing: antialiased;}
39
62
  </style>`);
63
+ function inPage(el) {
64
+ return document.body.contains(el);
65
+ }
66
+ exports.inPage = inPage;
40
67
  let globalCursorStyle;
41
68
  function setGlobalCursor(type) {
42
69
  if (!globalCursorStyle) {
@@ -80,7 +107,7 @@ function removeFromStyleList(taskId) {
80
107
  (_a = document.getElementById('cg-style-task' + taskId.toString())) === null || _a === void 0 ? void 0 : _a.remove();
81
108
  }
82
109
  exports.removeFromStyleList = removeFromStyleList;
83
- function pushStyle(taskId, style, type = 'global', formId = 0) {
110
+ function pushStyle(taskId, style, type = 'global', formId = 0, panelId) {
84
111
  const el = document.querySelector(`#cg-style-task${taskId} > .cg-style-${type}`);
85
112
  if (!el) {
86
113
  return;
@@ -92,11 +119,11 @@ function pushStyle(taskId, style, type = 'global', formId = 0) {
92
119
  el.insertAdjacentHTML('beforeend', `<style data-name="${formId}">${style}</style>`);
93
120
  }
94
121
  else {
95
- el.insertAdjacentHTML('beforeend', `<style class="cg-style-form${formId}">${style}</style>`);
122
+ el.insertAdjacentHTML('beforeend', `<style class="cg-style-form${formId}" data-panel="${panelId ? panelId.toString() : ''}">${style}</style>`);
96
123
  }
97
124
  }
98
125
  exports.pushStyle = pushStyle;
99
- function removeStyle(taskId, type = 'global', formId = 0) {
126
+ function removeStyle(taskId, type = 'global', formId = 0, panelId) {
100
127
  const styleTask = document.getElementById('cg-style-task' + taskId.toString());
101
128
  if (!styleTask) {
102
129
  return;
@@ -124,7 +151,7 @@ function removeStyle(taskId, type = 'global', formId = 0) {
124
151
  }
125
152
  }
126
153
  else {
127
- const elist = styleTask.querySelectorAll('.cg-style-form' + formId.toString());
154
+ const elist = styleTask.querySelectorAll('.cg-style-form' + formId.toString() + (panelId ? '[data-panel="' + panelId.toString() + '"]' : ''));
128
155
  for (let i = 0; i < elist.length; ++i) {
129
156
  elist.item(i).remove();
130
157
  }
@@ -136,11 +163,25 @@ function getStyleCount(taskId, type) {
136
163
  }
137
164
  exports.getStyleCount = getStyleCount;
138
165
  const watchSizeList = {};
166
+ function getWatchSizeCount(taskId) {
167
+ if (!taskId) {
168
+ return Object.keys(watchSizeList).length;
169
+ }
170
+ let count = 0;
171
+ for (const id in watchSizeList) {
172
+ if (watchSizeList[id].taskId !== taskId) {
173
+ continue;
174
+ }
175
+ ++count;
176
+ }
177
+ return count;
178
+ }
179
+ exports.getWatchSizeCount = getWatchSizeCount;
139
180
  let watchSizeIndex = 0;
140
181
  const resizeObserver = new ResizeObserver(function (entries) {
141
182
  for (const entrie of entries) {
142
183
  const el = entrie.target;
143
- if (!el.offsetParent) {
184
+ if (!document.body.contains(el)) {
144
185
  resizeObserver.unobserve(el);
145
186
  if (watchSizeList[el.dataset.cgRoindex]) {
146
187
  delete watchSizeList[el.dataset.cgRoindex];
@@ -220,6 +261,20 @@ function clearWatchSize(taskId) {
220
261
  }
221
262
  exports.clearWatchSize = clearWatchSize;
222
263
  const watchList = {};
264
+ function getWatchCount(taskId) {
265
+ if (!taskId) {
266
+ return Object.keys(watchList).length;
267
+ }
268
+ let count = 0;
269
+ for (const id in watchList) {
270
+ if (watchList[id].taskId !== taskId) {
271
+ continue;
272
+ }
273
+ ++count;
274
+ }
275
+ return count;
276
+ }
277
+ exports.getWatchCount = getWatchCount;
223
278
  let watchIndex = 0;
224
279
  function watch(el, cb, mode = 'default', immediate = false, taskId) {
225
280
  if (isWatch(el)) {
@@ -262,11 +317,8 @@ function watch(el, cb, mode = 'default', immediate = false, taskId) {
262
317
  };
263
318
  break;
264
319
  }
265
- case 'default': {
320
+ case 'text': {
266
321
  moi = {
267
- 'attributeFilter': ['style', 'class'],
268
- 'attributeOldValue': true,
269
- 'attributes': true,
270
322
  'characterData': true,
271
323
  'childList': true,
272
324
  'subtree': true
@@ -274,11 +326,18 @@ function watch(el, cb, mode = 'default', immediate = false, taskId) {
274
326
  break;
275
327
  }
276
328
  default: {
277
- moi = mode;
329
+ moi = {
330
+ 'attributeFilter': ['style', 'class'],
331
+ 'attributeOldValue': true,
332
+ 'attributes': true,
333
+ 'characterData': true,
334
+ 'childList': true,
335
+ 'subtree': true
336
+ };
278
337
  }
279
338
  }
280
339
  const mo = new MutationObserver((mutations) => {
281
- if (!el.offsetParent) {
340
+ if (!document.body.contains(el)) {
282
341
  mo.disconnect();
283
342
  if (watchList[index]) {
284
343
  delete watchList[index];
@@ -338,6 +397,24 @@ function clearWatch(taskId) {
338
397
  }
339
398
  }
340
399
  exports.clearWatch = clearWatch;
400
+ const watchCgTimerHandler = function () {
401
+ for (const index in watchSizeList) {
402
+ const item = watchSizeList[index];
403
+ if (document.body.contains(item.el)) {
404
+ continue;
405
+ }
406
+ delete watchSizeList[index];
407
+ }
408
+ for (const index in watchList) {
409
+ const item = watchList[index];
410
+ if (document.body.contains(item.el)) {
411
+ continue;
412
+ }
413
+ delete watchList[index];
414
+ }
415
+ window.setTimeout(watchCgTimerHandler, 1000 * 60 * 7);
416
+ };
417
+ watchCgTimerHandler();
341
418
  const watchStyleList = {};
342
419
  let watchStyleIndex = 0;
343
420
  function watchStyle(el, name, cb, immediate = false) {
@@ -349,12 +426,11 @@ function watchStyle(el, name, cb, immediate = false) {
349
426
  return;
350
427
  }
351
428
  const formId = formWrap.dataset.formId;
352
- if (!watchStyleList[formId]) {
353
- watchStyleList[formId] = {};
354
- }
429
+ const panelWrap = findParentByData(el, 'panel-id');
430
+ const panelId = panelWrap ? panelWrap.dataset.panelId : 'default';
355
431
  const index = el.dataset.cgStyleindex;
356
432
  if (index) {
357
- const item = watchStyleList[formId][index];
433
+ const item = watchStyleList[formId][panelId][index];
358
434
  for (const n of name) {
359
435
  if (!item.names[n]) {
360
436
  item.names[n] = {
@@ -371,13 +447,19 @@ function watchStyle(el, name, cb, immediate = false) {
371
447
  }
372
448
  return;
373
449
  }
450
+ if (!watchStyleList[formId]) {
451
+ watchStyleList[formId] = {};
452
+ }
453
+ if (!watchStyleList[formId][panelId]) {
454
+ watchStyleList[formId][panelId] = {};
455
+ }
374
456
  const sd = getComputedStyle(el);
375
- watchStyleList[formId][watchStyleIndex] = {
457
+ watchStyleList[formId][panelId][watchStyleIndex] = {
376
458
  'el': el,
377
459
  'sd': sd,
378
460
  'names': {}
379
461
  };
380
- const item = watchStyleList[formId][watchStyleIndex];
462
+ const item = watchStyleList[formId][panelId][watchStyleIndex];
381
463
  for (const n of name) {
382
464
  item.names[n] = {
383
465
  'val': item.sd[n],
@@ -391,47 +473,28 @@ function watchStyle(el, name, cb, immediate = false) {
391
473
  ++watchStyleIndex;
392
474
  }
393
475
  exports.watchStyle = watchStyle;
394
- let watchStyleTimer = 0;
395
- const watchStyleHandler = function () {
396
- if (form.getFocus) {
397
- const formId = form.getFocus();
398
- if (formId && watchStyleList[formId]) {
399
- for (const index in watchStyleList[formId]) {
400
- const item = watchStyleList[formId][index];
401
- if (!item.el.offsetParent) {
402
- delete watchStyleList[formId][index];
403
- if (!Object.keys(watchStyleList[formId]).length) {
404
- delete watchStyleList[formId];
405
- }
406
- continue;
407
- }
408
- for (const name in item.names) {
409
- if (item.sd[name] === item.names[name].val) {
410
- continue;
411
- }
412
- const old = item.names[name].val;
413
- item.names[name].val = item.sd[name];
414
- for (const cb of item.names[name].cb) {
415
- cb(name, item.sd[name], old);
416
- }
417
- }
418
- }
419
- }
420
- }
421
- watchStyleTimer = requestAnimationFrame(watchStyleHandler);
422
- };
423
- watchStyleHandler();
424
476
  function isWatchStyle(el) {
425
477
  return el.dataset.cgStyleindex ? true : false;
426
478
  }
427
479
  exports.isWatchStyle = isWatchStyle;
428
- function clearWatchStyle(formId) {
480
+ function clearWatchStyle(formId, panelId) {
429
481
  if (!watchStyleList[formId]) {
430
482
  return;
431
483
  }
432
- for (const index in watchStyleList[formId]) {
433
- const item = watchStyleList[formId][index];
434
- item.el.removeAttribute('data-cg-styleindex');
484
+ for (const panel in watchStyleList[formId]) {
485
+ if (panelId) {
486
+ if (panel !== panelId.toString()) {
487
+ continue;
488
+ }
489
+ }
490
+ for (const index in watchStyleList[formId][panel]) {
491
+ const item = watchStyleList[formId][panel][index];
492
+ item.el.removeAttribute('data-cg-styleindex');
493
+ }
494
+ delete watchStyleList[formId][panel];
495
+ }
496
+ if (Object.keys(watchStyleList[formId]).length) {
497
+ return;
435
498
  }
436
499
  delete watchStyleList[formId];
437
500
  }
@@ -447,12 +510,11 @@ function watchProperty(el, name, cb, immediate = false) {
447
510
  return;
448
511
  }
449
512
  const formId = formWrap.dataset.formId;
450
- if (!watchPropertyObjects[formId]) {
451
- watchPropertyObjects[formId] = {};
452
- }
513
+ const panelWrap = findParentByData(el, 'panel-id');
514
+ const panelId = panelWrap ? panelWrap.dataset.panelId : 'default';
453
515
  const index = el.dataset.cgPropertyindex;
454
516
  if (index) {
455
- const item = watchPropertyObjects[formId][index];
517
+ const item = watchPropertyObjects[formId][panelId][index];
456
518
  for (const n of name) {
457
519
  if (!item.names[n]) {
458
520
  item.names[n] = {
@@ -469,11 +531,17 @@ function watchProperty(el, name, cb, immediate = false) {
469
531
  }
470
532
  return;
471
533
  }
472
- watchPropertyObjects[formId][watchPropertyIndex] = {
534
+ if (!watchPropertyObjects[formId]) {
535
+ watchPropertyObjects[formId] = {};
536
+ }
537
+ if (!watchPropertyObjects[formId][panelId]) {
538
+ watchPropertyObjects[formId][panelId] = {};
539
+ }
540
+ watchPropertyObjects[formId][panelId][watchPropertyIndex] = {
473
541
  'el': el,
474
542
  'names': {}
475
543
  };
476
- const item = watchPropertyObjects[formId][watchPropertyIndex];
544
+ const item = watchPropertyObjects[formId][panelId][watchPropertyIndex];
477
545
  for (const n of name) {
478
546
  item.names[n] = {
479
547
  'val': item.el[n],
@@ -487,50 +555,182 @@ function watchProperty(el, name, cb, immediate = false) {
487
555
  ++watchPropertyIndex;
488
556
  }
489
557
  exports.watchProperty = watchProperty;
490
- let watchPropertyTimer = 0;
491
- const watchPropertyHandler = function () {
492
- if (form.getFocus) {
493
- const formId = form.getFocus();
494
- if (formId && watchPropertyObjects[formId]) {
495
- for (const index in watchPropertyObjects[formId]) {
496
- const item = watchPropertyObjects[formId][index];
497
- if (!item.el.offsetParent) {
498
- delete watchPropertyObjects[formId][index];
499
- if (!Object.keys(watchPropertyObjects[formId]).length) {
500
- delete watchPropertyObjects[formId];
501
- }
502
- continue;
503
- }
504
- for (const name in item.names) {
505
- if (item.el[name] === item.names[name].val) {
506
- continue;
507
- }
508
- item.names[name].val = item.el[name];
509
- for (const cb of item.names[name].cb) {
510
- cb(name, item.el[name]);
511
- }
512
- }
513
- }
514
- }
515
- }
516
- watchPropertyTimer = requestAnimationFrame(watchPropertyHandler);
517
- };
518
- watchPropertyHandler();
519
558
  function isWatchProperty(el) {
520
559
  return el.dataset.cgPropertyindex ? true : false;
521
560
  }
522
561
  exports.isWatchProperty = isWatchProperty;
523
- function clearWatchProperty(formId) {
562
+ function clearWatchProperty(formId, panelId) {
524
563
  if (!watchPropertyObjects[formId]) {
525
564
  return;
526
565
  }
527
- for (const index in watchPropertyObjects[formId]) {
528
- const item = watchPropertyObjects[formId][index];
529
- item.el.removeAttribute('data-cg-propertyindex');
566
+ for (const panel in watchPropertyObjects[formId]) {
567
+ if (panelId) {
568
+ if (panel !== panelId.toString()) {
569
+ continue;
570
+ }
571
+ }
572
+ for (const index in watchPropertyObjects[formId][panel]) {
573
+ const item = watchPropertyObjects[formId][panel][index];
574
+ item.el.removeAttribute('data-cg-propertyindex');
575
+ }
576
+ delete watchPropertyObjects[formId][panel];
577
+ }
578
+ if (Object.keys(watchPropertyObjects[formId]).length) {
579
+ return;
530
580
  }
531
581
  delete watchPropertyObjects[formId];
532
582
  }
533
583
  exports.clearWatchProperty = clearWatchProperty;
584
+ function getWatchInfo() {
585
+ const rtn = {
586
+ 'formId': 0,
587
+ 'default': {},
588
+ 'panels': {}
589
+ };
590
+ const formId = form.getFocus();
591
+ if (!formId) {
592
+ return rtn;
593
+ }
594
+ rtn.formId = formId;
595
+ const panelIds = form.getActivePanel(formId);
596
+ const handler = (item, type, panelId) => {
597
+ var _a, _b, _c;
598
+ if (panelId) {
599
+ if (!rtn.panels[panelId]) {
600
+ rtn.panels[panelId] = {};
601
+ }
602
+ }
603
+ const ritem = panelId ? rtn.panels[panelId] : rtn.default;
604
+ const cname = (_c = (_a = item.el.dataset.cgControl) !== null && _a !== void 0 ? _a : (_b = findParentByData(item.el, 'cg-control')) === null || _b === void 0 ? void 0 : _b.dataset.cgControl) !== null && _c !== void 0 ? _c : 'unknown';
605
+ if (!ritem[cname]) {
606
+ ritem[cname] = {
607
+ 'style': {
608
+ 'count': 0,
609
+ 'list': []
610
+ },
611
+ 'property': {
612
+ 'count': 0,
613
+ 'list': []
614
+ }
615
+ };
616
+ }
617
+ ++ritem[cname][type].count;
618
+ for (const name in item.names) {
619
+ if (ritem[cname][type].list.includes(name)) {
620
+ continue;
621
+ }
622
+ ritem[cname][type].list.push(name);
623
+ }
624
+ };
625
+ if (watchStyleList[formId].default) {
626
+ for (const index in watchStyleList[formId].default) {
627
+ handler(watchStyleList[formId].default[index], 'style');
628
+ }
629
+ }
630
+ for (const id of panelIds) {
631
+ if (watchStyleList[formId][id]) {
632
+ for (const index in watchStyleList[formId][id]) {
633
+ handler(watchStyleList[formId][id][index], 'style', id.toString());
634
+ }
635
+ }
636
+ }
637
+ if (watchPropertyObjects[formId].default) {
638
+ for (const index in watchPropertyObjects[formId].default) {
639
+ handler(watchPropertyObjects[formId].default[index], 'property');
640
+ }
641
+ }
642
+ for (const id of panelIds) {
643
+ if (watchPropertyObjects[formId][id]) {
644
+ for (const index in watchPropertyObjects[formId][id]) {
645
+ handler(watchPropertyObjects[formId][id][index], 'property', id.toString());
646
+ }
647
+ }
648
+ }
649
+ return rtn;
650
+ }
651
+ exports.getWatchInfo = getWatchInfo;
652
+ let watchTimer = 0;
653
+ const watchTimerHandler = function () {
654
+ if (form.getFocus) {
655
+ const formId = form.getFocus();
656
+ if (formId) {
657
+ const panelIds = form.getActivePanel(formId);
658
+ if (watchStyleList[formId]) {
659
+ const handler = (item, panelId, index) => {
660
+ if (!document.body.contains(item.el)) {
661
+ delete watchStyleList[formId][panelId][index];
662
+ if (!Object.keys(watchStyleList[formId][panelId]).length) {
663
+ delete watchStyleList[formId][panelId];
664
+ }
665
+ if (!Object.keys(watchStyleList[formId]).length) {
666
+ delete watchStyleList[formId];
667
+ }
668
+ return;
669
+ }
670
+ for (const name in item.names) {
671
+ if (item.sd[name] === item.names[name].val) {
672
+ continue;
673
+ }
674
+ const old = item.names[name].val;
675
+ item.names[name].val = item.sd[name];
676
+ for (const cb of item.names[name].cb) {
677
+ cb(name, item.sd[name], old);
678
+ }
679
+ }
680
+ };
681
+ if (watchStyleList[formId].default) {
682
+ for (const index in watchStyleList[formId].default) {
683
+ handler(watchStyleList[formId].default[index], 'default', index);
684
+ }
685
+ }
686
+ for (const id of panelIds) {
687
+ if (watchStyleList[formId][id]) {
688
+ for (const index in watchStyleList[formId][id]) {
689
+ handler(watchStyleList[formId][id][index], id.toString(), index);
690
+ }
691
+ }
692
+ }
693
+ }
694
+ if (watchPropertyObjects[formId]) {
695
+ const handler = (item, panelId, index) => {
696
+ if (!document.body.contains(item.el)) {
697
+ delete watchPropertyObjects[formId][panelId][index];
698
+ if (!Object.keys(watchPropertyObjects[formId][panelId]).length) {
699
+ delete watchPropertyObjects[formId][panelId];
700
+ }
701
+ if (!Object.keys(watchPropertyObjects[formId]).length) {
702
+ delete watchPropertyObjects[formId];
703
+ }
704
+ return;
705
+ }
706
+ for (const name in item.names) {
707
+ if (item.el[name] === item.names[name].val) {
708
+ continue;
709
+ }
710
+ item.names[name].val = item.el[name];
711
+ for (const cb of item.names[name].cb) {
712
+ cb(name, item.el[name]);
713
+ }
714
+ }
715
+ };
716
+ if (watchPropertyObjects[formId].default) {
717
+ for (const index in watchPropertyObjects[formId].default) {
718
+ handler(watchPropertyObjects[formId].default[index], 'default', index);
719
+ }
720
+ }
721
+ for (const id of panelIds) {
722
+ if (watchPropertyObjects[formId][id]) {
723
+ for (const index in watchPropertyObjects[formId][id]) {
724
+ handler(watchPropertyObjects[formId][id][index], id.toString(), index);
725
+ }
726
+ }
727
+ }
728
+ }
729
+ }
730
+ }
731
+ watchTimer = requestAnimationFrame(watchTimerHandler);
732
+ };
733
+ watchTimerHandler();
534
734
  function bindClick(e, handler) {
535
735
  const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
536
736
  const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
@@ -562,7 +762,7 @@ function bindDown(oe, opt) {
562
762
  let isStart = false;
563
763
  let end = undefined;
564
764
  const move = function (e) {
565
- if ((!e.target || !e.target.offsetParent) && e.cancelable) {
765
+ if (!e.target || !document.body.contains(e.target) && e.cancelable) {
566
766
  e.preventDefault();
567
767
  }
568
768
  let dir = 'top';
@@ -1067,7 +1267,8 @@ exports.bindDrag = bindDrag;
1067
1267
  exports.is = clickgo.vue.reactive({
1068
1268
  'move': false,
1069
1269
  'shift': false,
1070
- 'ctrl': false
1270
+ 'ctrl': false,
1271
+ 'meta': false
1071
1272
  });
1072
1273
  window.addEventListener('keydown', function (e) {
1073
1274
  switch (e.key) {
@@ -1079,6 +1280,10 @@ window.addEventListener('keydown', function (e) {
1079
1280
  exports.is.ctrl = true;
1080
1281
  break;
1081
1282
  }
1283
+ case 'Meta': {
1284
+ exports.is.meta = true;
1285
+ break;
1286
+ }
1082
1287
  }
1083
1288
  });
1084
1289
  window.addEventListener('keyup', function (e) {
@@ -1091,6 +1296,10 @@ window.addEventListener('keyup', function (e) {
1091
1296
  exports.is.ctrl = false;
1092
1297
  break;
1093
1298
  }
1299
+ case 'Meta': {
1300
+ exports.is.meta = false;
1301
+ break;
1302
+ }
1094
1303
  }
1095
1304
  });
1096
1305
  function bindMove(e, opt) {
@@ -1104,12 +1313,12 @@ function bindMove(e, opt) {
1104
1313
  };
1105
1314
  }
1106
1315
  exports.is.move = true;
1107
- setGlobalCursor(getComputedStyle(e.target).cursor);
1316
+ setGlobalCursor(opt.cursor ? opt.cursor : getComputedStyle(e.target).cursor);
1108
1317
  let tx = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
1109
1318
  let ty = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
1110
1319
  let left, top, right, bottom;
1111
1320
  if (opt.areaObject) {
1112
- if (!(opt.areaObject instanceof HTMLElement)) {
1321
+ if (!(opt.areaObject instanceof Element)) {
1113
1322
  opt.areaObject = opt.areaObject.$el;
1114
1323
  }
1115
1324
  const areaRect = opt.areaObject.getBoundingClientRect();
@@ -1154,7 +1363,7 @@ function bindMove(e, opt) {
1154
1363
  }
1155
1364
  }
1156
1365
  if (opt.object) {
1157
- if (!(opt.object instanceof HTMLElement)) {
1366
+ if (!(opt.object instanceof Element)) {
1158
1367
  opt.object = opt.object.$el;
1159
1368
  }
1160
1369
  const rect = opt.object.getBoundingClientRect();
@@ -1396,7 +1605,7 @@ function bindResize(e, opt) {
1396
1605
  if (!opt.object) {
1397
1606
  return;
1398
1607
  }
1399
- if (!(opt.object instanceof HTMLElement)) {
1608
+ if (!(opt.object instanceof Element)) {
1400
1609
  opt.object = opt.object.$el;
1401
1610
  }
1402
1611
  const objectRect = opt.object.getBoundingClientRect();
@@ -1469,7 +1678,7 @@ function bindResize(e, opt) {
1469
1678
  });
1470
1679
  }
1471
1680
  exports.bindResize = bindResize;
1472
- function findParentByData(el, name) {
1681
+ function findParentByData(el, name, value) {
1473
1682
  let parent = el.parentNode;
1474
1683
  while (parent) {
1475
1684
  if (!parent.tagName) {
@@ -1478,7 +1687,14 @@ function findParentByData(el, name) {
1478
1687
  if (parent.tagName.toLowerCase() === 'body') {
1479
1688
  break;
1480
1689
  }
1481
- if (parent.getAttribute('data-' + name) !== null) {
1690
+ const v = parent.getAttribute('data-' + name);
1691
+ if (v !== null) {
1692
+ if (value) {
1693
+ if (value === v) {
1694
+ return parent;
1695
+ }
1696
+ continue;
1697
+ }
1482
1698
  return parent;
1483
1699
  }
1484
1700
  parent = parent.parentNode;
@@ -1547,11 +1763,9 @@ function fullscreen() {
1547
1763
  exports.fullscreen = fullscreen;
1548
1764
  document.addEventListener('visibilitychange', function () {
1549
1765
  if (document.hidden) {
1550
- cancelAnimationFrame(watchStyleTimer);
1551
- cancelAnimationFrame(watchPropertyTimer);
1766
+ cancelAnimationFrame(watchTimer);
1552
1767
  }
1553
1768
  else {
1554
- watchStyleTimer = requestAnimationFrame(watchStyleHandler);
1555
- watchPropertyTimer = requestAnimationFrame(watchPropertyHandler);
1769
+ watchTimer = requestAnimationFrame(watchTimerHandler);
1556
1770
  }
1557
1771
  });