clickgo 3.0.0-dev

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 (145) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +75 -0
  3. package/dist/app/demo/config.json +106 -0
  4. package/dist/app/demo/form/control/block/block.css +1 -0
  5. package/dist/app/demo/form/control/block/block.scss +17 -0
  6. package/dist/app/demo/form/control/block/block.xml +7 -0
  7. package/dist/app/demo/form/control/button/button.css +1 -0
  8. package/dist/app/demo/form/control/button/button.js +27 -0
  9. package/dist/app/demo/form/control/button/button.scss +18 -0
  10. package/dist/app/demo/form/control/button/button.xml +126 -0
  11. package/dist/app/demo/form/control/check/check.js +12 -0
  12. package/dist/app/demo/form/control/check/check.xml +13 -0
  13. package/dist/app/demo/form/control/dialog/dialog.js +8 -0
  14. package/dist/app/demo/form/control/dialog/dialog.xml +26 -0
  15. package/dist/app/demo/form/control/file/file.js +23 -0
  16. package/dist/app/demo/form/control/file/file.xml +25 -0
  17. package/dist/app/demo/form/control/form/form.css +1 -0
  18. package/dist/app/demo/form/control/form/form.js +38 -0
  19. package/dist/app/demo/form/control/form/form.scss +9 -0
  20. package/dist/app/demo/form/control/form/form.xml +28 -0
  21. package/dist/app/demo/form/control/greatview/greatview.css +1 -0
  22. package/dist/app/demo/form/control/greatview/greatview.js +92 -0
  23. package/dist/app/demo/form/control/greatview/greatview.scss +22 -0
  24. package/dist/app/demo/form/control/greatview/greatview.xml +89 -0
  25. package/dist/app/demo/form/control/img/img.xml +16 -0
  26. package/dist/app/demo/form/control/label/label.xml +11 -0
  27. package/dist/app/demo/form/control/list/list.css +1 -0
  28. package/dist/app/demo/form/control/list/list.js +194 -0
  29. package/dist/app/demo/form/control/list/list.scss +7 -0
  30. package/dist/app/demo/form/control/list/list.xml +91 -0
  31. package/dist/app/demo/form/control/loading/loading.xml +8 -0
  32. package/dist/app/demo/form/control/marquee/marquee.js +30 -0
  33. package/dist/app/demo/form/control/marquee/marquee.xml +36 -0
  34. package/dist/app/demo/form/control/menu/menu.js +8 -0
  35. package/dist/app/demo/form/control/menu/menu.xml +122 -0
  36. package/dist/app/demo/form/control/monaco/monaco.js +113 -0
  37. package/dist/app/demo/form/control/monaco/monaco.xml +27 -0
  38. package/dist/app/demo/form/control/overflow/overflow.css +1 -0
  39. package/dist/app/demo/form/control/overflow/overflow.js +70 -0
  40. package/dist/app/demo/form/control/overflow/overflow.scss +18 -0
  41. package/dist/app/demo/form/control/overflow/overflow.xml +98 -0
  42. package/dist/app/demo/form/control/property/property.js +129 -0
  43. package/dist/app/demo/form/control/property/property.xml +6 -0
  44. package/dist/app/demo/form/control/radio/radio.js +7 -0
  45. package/dist/app/demo/form/control/radio/radio.xml +12 -0
  46. package/dist/app/demo/form/control/scroll/scroll.js +14 -0
  47. package/dist/app/demo/form/control/scroll/scroll.xml +35 -0
  48. package/dist/app/demo/form/control/select/select.js +91 -0
  49. package/dist/app/demo/form/control/select/select.xml +74 -0
  50. package/dist/app/demo/form/control/tab/tab.js +75 -0
  51. package/dist/app/demo/form/control/tab/tab.xml +22 -0
  52. package/dist/app/demo/form/control/text/text.js +53 -0
  53. package/dist/app/demo/form/control/text/text.xml +37 -0
  54. package/dist/app/demo/form/control/view/view.css +1 -0
  55. package/dist/app/demo/form/control/view/view.js +73 -0
  56. package/dist/app/demo/form/control/view/view.scss +18 -0
  57. package/dist/app/demo/form/control/view/view.xml +94 -0
  58. package/dist/app/demo/form/event/form/form.css +1 -0
  59. package/dist/app/demo/form/event/form/form.js +129 -0
  60. package/dist/app/demo/form/event/form/form.scss +24 -0
  61. package/dist/app/demo/form/event/form/form.xml +16 -0
  62. package/dist/app/demo/form/event/screen/screen.js +51 -0
  63. package/dist/app/demo/form/event/screen/screen.xml +9 -0
  64. package/dist/app/demo/form/event/task/task.js +78 -0
  65. package/dist/app/demo/form/event/task/task.xml +20 -0
  66. package/dist/app/demo/form/main.css +1 -0
  67. package/dist/app/demo/form/main.js +25 -0
  68. package/dist/app/demo/form/main.scss +9 -0
  69. package/dist/app/demo/form/main.xml +49 -0
  70. package/dist/app/demo/form/method/core/core.js +25 -0
  71. package/dist/app/demo/form/method/core/core.xml +7 -0
  72. package/dist/app/demo/form/method/dom/dom.css +1 -0
  73. package/dist/app/demo/form/method/dom/dom.js +163 -0
  74. package/dist/app/demo/form/method/dom/dom.scss +10 -0
  75. package/dist/app/demo/form/method/dom/dom.xml +55 -0
  76. package/dist/app/demo/form/method/form/form.css +1 -0
  77. package/dist/app/demo/form/method/form/form.js +217 -0
  78. package/dist/app/demo/form/method/form/form.scss +3 -0
  79. package/dist/app/demo/form/method/form/form.xml +56 -0
  80. package/dist/app/demo/form/method/form/test.xml +5 -0
  81. package/dist/app/demo/form/method/fs/fs.js +88 -0
  82. package/dist/app/demo/form/method/fs/fs.xml +8 -0
  83. package/dist/app/demo/form/method/fs/text.js +15 -0
  84. package/dist/app/demo/form/method/fs/text.xml +3 -0
  85. package/dist/app/demo/form/method/task/locale1.json +3 -0
  86. package/dist/app/demo/form/method/task/locale2.json +3 -0
  87. package/dist/app/demo/form/method/task/task.js +153 -0
  88. package/dist/app/demo/form/method/task/task.xml +57 -0
  89. package/dist/app/demo/form/method/theme/theme.js +74 -0
  90. package/dist/app/demo/form/method/theme/theme.xml +9 -0
  91. package/dist/app/demo/form/method/tool/tool.js +64 -0
  92. package/dist/app/demo/form/method/tool/tool.xml +26 -0
  93. package/dist/app/demo/form/method/zip/zip.js +99 -0
  94. package/dist/app/demo/form/method/zip/zip.xml +12 -0
  95. package/dist/app/demo/global.css +3 -0
  96. package/dist/app/demo/res/icon.svg +1 -0
  97. package/dist/app/demo/res/img.jpg +0 -0
  98. package/dist/app/demo/res/r-1.svg +1 -0
  99. package/dist/app/demo/res/r-2.svg +1 -0
  100. package/dist/app/demo/res/sql.svg +1 -0
  101. package/dist/app/demo/res/txt.svg +1 -0
  102. package/dist/app/demo/res/zip.svg +1 -0
  103. package/dist/app/task/config.json +29 -0
  104. package/dist/app/task/form/bar/bar.js +299 -0
  105. package/dist/app/task/form/bar/bar.xml +47 -0
  106. package/dist/app/task/form/desktop/desktop.xml +1 -0
  107. package/dist/app/task/locale/en.json +11 -0
  108. package/dist/app/task/locale/ja.json +11 -0
  109. package/dist/app/task/locale/sc.json +11 -0
  110. package/dist/app/task/locale/tc.json +11 -0
  111. package/dist/clickgo.js +41 -0
  112. package/dist/clickgo.ts +51 -0
  113. package/dist/control/common.cgc +0 -0
  114. package/dist/control/form.cgc +0 -0
  115. package/dist/control/monaco.cgc +0 -0
  116. package/dist/control/property.cgc +0 -0
  117. package/dist/control/task.cgc +0 -0
  118. package/dist/global.css +1 -0
  119. package/dist/icon.png +0 -0
  120. package/dist/index.js +88 -0
  121. package/dist/index.ts +92 -0
  122. package/dist/lib/control.js +365 -0
  123. package/dist/lib/control.ts +428 -0
  124. package/dist/lib/core.js +668 -0
  125. package/dist/lib/core.ts +732 -0
  126. package/dist/lib/dom.js +1471 -0
  127. package/dist/lib/dom.ts +1785 -0
  128. package/dist/lib/form.js +2101 -0
  129. package/dist/lib/form.ts +2496 -0
  130. package/dist/lib/fs.js +849 -0
  131. package/dist/lib/fs.ts +995 -0
  132. package/dist/lib/native.js +138 -0
  133. package/dist/lib/native.ts +219 -0
  134. package/dist/lib/task.js +686 -0
  135. package/dist/lib/task.ts +842 -0
  136. package/dist/lib/theme.js +159 -0
  137. package/dist/lib/theme.ts +196 -0
  138. package/dist/lib/tool.js +501 -0
  139. package/dist/lib/tool.ts +620 -0
  140. package/dist/lib/zip.js +352 -0
  141. package/dist/lib/zip.ts +434 -0
  142. package/dist/theme/familiar.cgt +0 -0
  143. package/package.json +27 -0
  144. package/types/dev.d.ts +30 -0
  145. package/types/index.d.ts +673 -0
@@ -0,0 +1,1471 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ 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.isWatchStyle = exports.watchStyle = exports.clearWatch = exports.unwatch = exports.watch = exports.clearWatchSize = exports.unwatchSize = exports.watchSize = exports.getSize = exports.getStyleCount = exports.removeStyle = exports.pushStyle = exports.removeFromStyleList = exports.createToStyleList = exports.hasTouchButMouse = exports.setGlobalCursor = void 0;
4
+ const form = require("./form");
5
+ const core = require("./core");
6
+ const topClass = ['#cg-form-list', '#cg-pop-list', '#cg-system', '#cg-simpletask'];
7
+ function classUnfold(after) {
8
+ const arr = [];
9
+ for (const name of topClass) {
10
+ arr.push(name + (after ? (' ' + after) : ''));
11
+ }
12
+ return arr.join(', ');
13
+ }
14
+ const styleList = document.createElement('div');
15
+ styleList.style.display = 'none';
16
+ document.getElementsByTagName('body')[0].appendChild(styleList);
17
+ styleList.insertAdjacentHTML('beforeend', '<style id=\'cg-global-cursor\'></style>');
18
+ styleList.insertAdjacentHTML('beforeend', `<style id='cg-global'>
19
+ ${classUnfold()} {-webkit-user-select: none; user-select: none; position: fixed; left: 0; top: 0; width: 0; height: 0; cursor: default; box-sizing: border-box;}
20
+ ${classUnfold('img')} {vertical-align: bottom;}
21
+ ${classUnfold('::selection')} {background-color: rgba(0, 0, 0, .1);}
22
+ ${classUnfold('*')}, ${classUnfold('*::after')}, ${classUnfold('*::before')} {box-sizing: border-box; -webkit-tap-highlight-color: rgba(0, 0, 0, 0); flex-shrink: 0;}
23
+ ${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;}
24
+ </style>`);
25
+ let globalCursorStyle;
26
+ function setGlobalCursor(type) {
27
+ if (!globalCursorStyle) {
28
+ globalCursorStyle = document.getElementById('cg-global-cursor');
29
+ }
30
+ if (type) {
31
+ globalCursorStyle.innerHTML = `* {cursor: ${type} !important;}`;
32
+ }
33
+ else {
34
+ globalCursorStyle.innerHTML = '';
35
+ }
36
+ }
37
+ exports.setGlobalCursor = setGlobalCursor;
38
+ let lastTouchTime = 0;
39
+ document.addEventListener('touchstart', function () {
40
+ lastTouchTime = Date.now();
41
+ return;
42
+ }, {
43
+ 'passive': true
44
+ });
45
+ function hasTouchButMouse(e) {
46
+ if (e instanceof TouchEvent) {
47
+ return false;
48
+ }
49
+ if ((e.pointerType === 'touch') && (e.type === 'contextmenu')) {
50
+ return true;
51
+ }
52
+ const now = Date.now();
53
+ if (now - lastTouchTime < 1000 * 60) {
54
+ return true;
55
+ }
56
+ return false;
57
+ }
58
+ exports.hasTouchButMouse = hasTouchButMouse;
59
+ function createToStyleList(taskId) {
60
+ styleList.insertAdjacentHTML('beforeend', `<div id="cg-style-task${taskId}"><style class="cg-style-global"></style><div class="cg-style-control"></div><div class="cg-style-theme"></div><div class="cg-style-form"></div></div>`);
61
+ }
62
+ exports.createToStyleList = createToStyleList;
63
+ function removeFromStyleList(taskId) {
64
+ var _a;
65
+ (_a = document.getElementById('cg-style-task' + taskId.toString())) === null || _a === void 0 ? void 0 : _a.remove();
66
+ }
67
+ exports.removeFromStyleList = removeFromStyleList;
68
+ function pushStyle(taskId, style, type = 'global', formId = 0) {
69
+ const el = document.querySelector(`#cg-style-task${taskId} > .cg-style-${type}`);
70
+ if (!el) {
71
+ return;
72
+ }
73
+ if (type === 'global') {
74
+ el.innerHTML = style;
75
+ }
76
+ else if (type === 'theme' || type === 'control') {
77
+ el.insertAdjacentHTML('beforeend', `<style data-name="${formId}">${style}</style>`);
78
+ }
79
+ else {
80
+ el.insertAdjacentHTML('beforeend', `<style class="cg-style-form${formId}">${style}</style>`);
81
+ }
82
+ }
83
+ exports.pushStyle = pushStyle;
84
+ function removeStyle(taskId, type = 'global', formId = 0) {
85
+ const styleTask = document.getElementById('cg-style-task' + taskId.toString());
86
+ if (!styleTask) {
87
+ return;
88
+ }
89
+ if (type === 'global') {
90
+ const el = styleTask.querySelector(`.cg-style-global`);
91
+ if (!el) {
92
+ return;
93
+ }
94
+ el.innerHTML = '';
95
+ }
96
+ else if (type === 'theme' || type === 'control') {
97
+ if (formId === 0) {
98
+ const el = styleTask.querySelector(`.cg-style-${type}`);
99
+ if (!el) {
100
+ return;
101
+ }
102
+ el.innerHTML = '';
103
+ }
104
+ else {
105
+ const elist = styleTask.querySelectorAll(`.cg-style-${type} > [data-name='${formId}']`);
106
+ for (let i = 0; i < elist.length; ++i) {
107
+ elist.item(i).remove();
108
+ }
109
+ }
110
+ }
111
+ else {
112
+ const elist = styleTask.querySelectorAll('.cg-style-form' + formId.toString());
113
+ for (let i = 0; i < elist.length; ++i) {
114
+ elist.item(i).remove();
115
+ }
116
+ }
117
+ }
118
+ exports.removeStyle = removeStyle;
119
+ function getStyleCount(taskId, type) {
120
+ return document.querySelectorAll(`#cg-style-task${taskId} > .cg-style-${type} > style`).length;
121
+ }
122
+ exports.getStyleCount = getStyleCount;
123
+ function getSize(el) {
124
+ const rect = el.getBoundingClientRect();
125
+ const cs = getComputedStyle(el);
126
+ const border = {
127
+ 'top': parseFloat(cs.borderTopWidth),
128
+ 'right': parseFloat(cs.borderRightWidth),
129
+ 'bottom': parseFloat(cs.borderBottomWidth),
130
+ 'left': parseFloat(cs.borderLeftWidth)
131
+ };
132
+ const padding = {
133
+ 'top': parseFloat(cs.paddingTop),
134
+ 'right': parseFloat(cs.paddingRight),
135
+ 'bottom': parseFloat(cs.paddingBottom),
136
+ 'left': parseFloat(cs.paddingLeft)
137
+ };
138
+ return {
139
+ 'top': rect.top,
140
+ 'right': rect.right,
141
+ 'bottom': rect.bottom,
142
+ 'left': rect.left,
143
+ 'width': rect.width,
144
+ 'height': rect.height,
145
+ 'padding': padding,
146
+ 'border': border,
147
+ 'clientWidth': rect.width - border.left - border.right,
148
+ 'clientHeight': rect.height - border.top - border.bottom,
149
+ 'innerWidth': rect.width - border.left - border.right - padding.left - padding.right,
150
+ 'innerHeight': rect.height - border.top - border.bottom - padding.top - padding.bottom,
151
+ 'scrollWidth': el.scrollWidth,
152
+ 'scrollHeight': el.scrollHeight
153
+ };
154
+ }
155
+ exports.getSize = getSize;
156
+ const watchSizeList = [];
157
+ function watchSize(el, cb, immediate = false, taskId) {
158
+ const fsize = getSize(el);
159
+ for (const item of watchSizeList) {
160
+ if (item.el === el) {
161
+ return fsize;
162
+ }
163
+ }
164
+ if (immediate) {
165
+ const r = cb(fsize);
166
+ if (r instanceof Promise) {
167
+ r.catch(function (e) {
168
+ console.log(e);
169
+ });
170
+ }
171
+ }
172
+ const resizeObserver = new window.ResizeObserver(function () {
173
+ const size = getSize(el);
174
+ if (Number.isNaN(size.clientWidth)) {
175
+ return;
176
+ }
177
+ const r = cb(size);
178
+ if (r instanceof Promise) {
179
+ r.catch(function (e) {
180
+ console.log(e);
181
+ });
182
+ }
183
+ });
184
+ resizeObserver.observe(el);
185
+ watchSizeList.push({
186
+ 'el': el,
187
+ 'ro': resizeObserver,
188
+ 'taskId': taskId
189
+ });
190
+ return fsize;
191
+ }
192
+ exports.watchSize = watchSize;
193
+ function unwatchSize(el, taskId) {
194
+ for (let i = 0; i < watchSizeList.length; ++i) {
195
+ const item = watchSizeList[i];
196
+ if (item.el !== el) {
197
+ continue;
198
+ }
199
+ if (taskId && taskId !== item.taskId) {
200
+ return;
201
+ }
202
+ if (item.el.offsetParent) {
203
+ item.ro.unobserve(item.el);
204
+ }
205
+ watchSizeList.splice(i, 1);
206
+ --i;
207
+ return;
208
+ }
209
+ }
210
+ exports.unwatchSize = unwatchSize;
211
+ function clearWatchSize(taskId) {
212
+ if (!taskId) {
213
+ return;
214
+ }
215
+ for (let i = 0; i < watchSizeList.length; ++i) {
216
+ const item = watchSizeList[i];
217
+ if (taskId !== item.taskId) {
218
+ continue;
219
+ }
220
+ if (item.el.offsetParent) {
221
+ item.ro.unobserve(item.el);
222
+ }
223
+ watchSizeList.splice(i, 1);
224
+ --i;
225
+ }
226
+ }
227
+ exports.clearWatchSize = clearWatchSize;
228
+ function cgClearWatchSize() {
229
+ for (let i = 0; i < watchSizeList.length; ++i) {
230
+ const item = watchSizeList[i];
231
+ if (item.el.offsetParent) {
232
+ continue;
233
+ }
234
+ watchSizeList.splice(i, 1);
235
+ --i;
236
+ }
237
+ }
238
+ setInterval(cgClearWatchSize, 1000 * 60 * 5);
239
+ const watchList = [];
240
+ function watch(el, cb, mode = 'default', immediate = false, taskId) {
241
+ if (immediate) {
242
+ cb();
243
+ }
244
+ let moi;
245
+ switch (mode) {
246
+ case 'child': {
247
+ moi = {
248
+ 'childList': true
249
+ };
250
+ break;
251
+ }
252
+ case 'childsub': {
253
+ moi = {
254
+ 'childList': true,
255
+ 'subtree': true
256
+ };
257
+ break;
258
+ }
259
+ case 'style': {
260
+ moi = {
261
+ 'attributeFilter': ['style', 'class'],
262
+ 'attributeOldValue': true,
263
+ 'attributes': true
264
+ };
265
+ break;
266
+ }
267
+ case 'default': {
268
+ moi = {
269
+ 'attributeFilter': ['style', 'class'],
270
+ 'attributeOldValue': true,
271
+ 'attributes': true,
272
+ 'characterData': true,
273
+ 'childList': true,
274
+ 'subtree': true
275
+ };
276
+ break;
277
+ }
278
+ default: {
279
+ moi = mode;
280
+ }
281
+ }
282
+ const mo = new MutationObserver(cb);
283
+ mo.observe(el, moi);
284
+ watchList.push({
285
+ 'el': el,
286
+ 'mo': mo,
287
+ 'taskId': taskId
288
+ });
289
+ }
290
+ exports.watch = watch;
291
+ function unwatch(el, taskId) {
292
+ for (let i = 0; i < watchList.length; ++i) {
293
+ const item = watchList[i];
294
+ if (item.el !== el) {
295
+ continue;
296
+ }
297
+ if (taskId && taskId !== item.taskId) {
298
+ return;
299
+ }
300
+ if (item.el.offsetParent) {
301
+ item.mo.disconnect();
302
+ }
303
+ watchList.splice(i, 1);
304
+ --i;
305
+ return;
306
+ }
307
+ }
308
+ exports.unwatch = unwatch;
309
+ function clearWatch(taskId) {
310
+ if (!taskId) {
311
+ return;
312
+ }
313
+ for (let i = 0; i < watchList.length; ++i) {
314
+ const item = watchList[i];
315
+ if (taskId !== item.taskId) {
316
+ continue;
317
+ }
318
+ if (item.el.offsetParent) {
319
+ item.mo.disconnect();
320
+ }
321
+ watchList.splice(i, 1);
322
+ --i;
323
+ }
324
+ }
325
+ exports.clearWatch = clearWatch;
326
+ function cgClearWatch() {
327
+ for (let i = 0; i < watchList.length; ++i) {
328
+ const item = watchList[i];
329
+ if (item.el.offsetParent) {
330
+ continue;
331
+ }
332
+ watchList.splice(i, 1);
333
+ --i;
334
+ }
335
+ }
336
+ setInterval(cgClearWatch, 1000 * 60 * 5);
337
+ const watchStyleObjects = [];
338
+ function watchStyle(el, name, cb, immediate = false) {
339
+ if (typeof name === 'string') {
340
+ name = [name];
341
+ }
342
+ for (const item of watchStyleObjects) {
343
+ if (item.el !== el) {
344
+ continue;
345
+ }
346
+ for (const n of name) {
347
+ if (!item.names[n]) {
348
+ item.names[n] = {
349
+ 'old': item.sd[n],
350
+ 'cb': [cb]
351
+ };
352
+ }
353
+ else {
354
+ item.names[n].cb.push(cb);
355
+ }
356
+ if (immediate) {
357
+ cb(n, item.sd[n]);
358
+ }
359
+ }
360
+ return;
361
+ }
362
+ const sd = getComputedStyle(el);
363
+ watchStyleObjects.push({
364
+ 'el': el,
365
+ 'sd': sd,
366
+ 'names': {}
367
+ });
368
+ const item = watchStyleObjects[watchStyleObjects.length - 1];
369
+ for (const n of name) {
370
+ item.names[n] = {
371
+ 'old': item.sd[n],
372
+ 'cb': [cb]
373
+ };
374
+ if (immediate) {
375
+ cb(n, item.sd[n]);
376
+ }
377
+ }
378
+ }
379
+ exports.watchStyle = watchStyle;
380
+ const watchStyleRAF = function () {
381
+ for (let i = 0; i < watchStyleObjects.length; ++i) {
382
+ const item = watchStyleObjects[i];
383
+ if (watchStyleObjects[i].sd.flex === '') {
384
+ watchStyleObjects.splice(i, 1);
385
+ --i;
386
+ continue;
387
+ }
388
+ for (const name in item.names) {
389
+ if (item.sd[name] === item.names[name].old) {
390
+ continue;
391
+ }
392
+ item.names[name].old = item.sd[name];
393
+ for (const cb of item.names[name].cb) {
394
+ cb(name, item.sd[name]);
395
+ }
396
+ }
397
+ }
398
+ requestAnimationFrame(watchStyleRAF);
399
+ };
400
+ watchStyleRAF();
401
+ function isWatchStyle(el) {
402
+ for (const item of watchStyleObjects) {
403
+ if (item.el !== el) {
404
+ continue;
405
+ }
406
+ return true;
407
+ }
408
+ return false;
409
+ }
410
+ exports.isWatchStyle = isWatchStyle;
411
+ function bindDown(oe, opt) {
412
+ var _a;
413
+ if (hasTouchButMouse(oe)) {
414
+ return;
415
+ }
416
+ let ox, oy;
417
+ if (oe instanceof MouseEvent) {
418
+ ox = oe.clientX;
419
+ oy = oe.clientY;
420
+ }
421
+ else {
422
+ ox = oe.touches[0].clientX;
423
+ oy = oe.touches[0].clientY;
424
+ }
425
+ let isStart = false;
426
+ let end = undefined;
427
+ const move = function (e) {
428
+ if (!e.target || !e.target.offsetParent) {
429
+ e.preventDefault();
430
+ }
431
+ let dir = 'top';
432
+ const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
433
+ const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
434
+ if (x === ox && y === oy) {
435
+ return;
436
+ }
437
+ const xx = x - ox;
438
+ const xy = y - oy;
439
+ if (Math.abs(xy) > Math.abs(xx)) {
440
+ if (xy < 0) {
441
+ dir = 'top';
442
+ }
443
+ else {
444
+ dir = 'bottom';
445
+ }
446
+ }
447
+ else {
448
+ if (xx < 0) {
449
+ dir = 'left';
450
+ }
451
+ else {
452
+ dir = 'right';
453
+ }
454
+ }
455
+ ox = x;
456
+ oy = y;
457
+ if (!isStart) {
458
+ isStart = true;
459
+ if (opt.start && (opt.start(e) === false)) {
460
+ if (e instanceof MouseEvent) {
461
+ window.removeEventListener('mousemove', move);
462
+ window.removeEventListener('mouseup', end);
463
+ }
464
+ else {
465
+ oe.target.removeEventListener('touchmove', move);
466
+ oe.target.removeEventListener('touchend', end);
467
+ oe.target.removeEventListener('touchcancel', end);
468
+ }
469
+ return;
470
+ }
471
+ }
472
+ if (opt.move && (opt.move(e, dir) === false)) {
473
+ if (e instanceof MouseEvent) {
474
+ window.removeEventListener('mousemove', move);
475
+ window.removeEventListener('mouseup', end);
476
+ }
477
+ else {
478
+ if (oe.target) {
479
+ oe.target.removeEventListener('touchmove', move);
480
+ oe.target.removeEventListener('touchend', end);
481
+ oe.target.removeEventListener('touchcancel', end);
482
+ }
483
+ }
484
+ return;
485
+ }
486
+ };
487
+ end = function (e) {
488
+ var _a, _b;
489
+ if (e instanceof MouseEvent) {
490
+ window.removeEventListener('mousemove', move);
491
+ window.removeEventListener('mouseup', end);
492
+ }
493
+ else {
494
+ if (oe.target) {
495
+ oe.target.removeEventListener('touchmove', move);
496
+ oe.target.removeEventListener('touchend', end);
497
+ oe.target.removeEventListener('touchcancel', end);
498
+ }
499
+ }
500
+ (_a = opt.up) === null || _a === void 0 ? void 0 : _a.call(opt, e);
501
+ if (isStart) {
502
+ (_b = opt.end) === null || _b === void 0 ? void 0 : _b.call(opt, e);
503
+ }
504
+ };
505
+ if (oe instanceof MouseEvent) {
506
+ window.addEventListener('mousemove', move, {
507
+ 'passive': false
508
+ });
509
+ window.addEventListener('mouseup', end);
510
+ }
511
+ else {
512
+ oe.target.addEventListener('touchmove', move, {
513
+ 'passive': false
514
+ });
515
+ oe.target.addEventListener('touchend', end);
516
+ oe.target.addEventListener('touchcancel', end);
517
+ }
518
+ (_a = opt.down) === null || _a === void 0 ? void 0 : _a.call(opt, oe);
519
+ }
520
+ exports.bindDown = bindDown;
521
+ const bindGestureData = {
522
+ 'el': null,
523
+ 'xx': 0,
524
+ 'xy': 0,
525
+ 'tx': 0,
526
+ 'ty': 0,
527
+ 'dir': null,
528
+ 'timers': {
529
+ 'ani': 0,
530
+ 'sleep': 0
531
+ }
532
+ };
533
+ function clearGestureData() {
534
+ bindGestureData.xx = 0;
535
+ bindGestureData.xy = 0;
536
+ bindGestureData.tx = 0;
537
+ bindGestureData.ty = 0;
538
+ }
539
+ function bindGestureAnimation(opt) {
540
+ var _a;
541
+ if (!bindGestureData.el) {
542
+ return;
543
+ }
544
+ const speed = 6;
545
+ const gestureElement = document.getElementById('cg-gesture');
546
+ const dirs = (_a = opt.dirs) !== null && _a !== void 0 ? _a : ['top', 'bottom'];
547
+ if (bindGestureData.tx > bindGestureData.xx) {
548
+ bindGestureData.xx += speed;
549
+ if (bindGestureData.xx > bindGestureData.tx) {
550
+ bindGestureData.xx = bindGestureData.tx;
551
+ }
552
+ }
553
+ else {
554
+ bindGestureData.xx -= speed;
555
+ if (bindGestureData.xx < bindGestureData.tx) {
556
+ bindGestureData.xx = bindGestureData.tx;
557
+ }
558
+ }
559
+ if (bindGestureData.ty > bindGestureData.xy) {
560
+ bindGestureData.xy += speed;
561
+ if (bindGestureData.xy > bindGestureData.ty) {
562
+ bindGestureData.xy = bindGestureData.ty;
563
+ }
564
+ }
565
+ else {
566
+ bindGestureData.xy -= speed;
567
+ if (bindGestureData.xy < bindGestureData.ty) {
568
+ bindGestureData.xy = bindGestureData.ty;
569
+ }
570
+ }
571
+ const xxAbs = Math.abs(bindGestureData.xx);
572
+ const xyAbs = Math.abs(bindGestureData.xy);
573
+ if ((!dirs.includes('top') && !dirs.includes('bottom')) || ((xxAbs > xyAbs) && (dirs.includes('left') || dirs.includes('right')))) {
574
+ if (bindGestureData.xx < 0) {
575
+ if (!dirs.includes('left')) {
576
+ gestureElement.style.opacity = '0';
577
+ clearGestureData();
578
+ return;
579
+ }
580
+ gestureElement.style.opacity = '1';
581
+ if (xxAbs === 90) {
582
+ bindGestureData.dir = 'left';
583
+ gestureElement.classList.add('done');
584
+ }
585
+ else {
586
+ bindGestureData.dir = null;
587
+ gestureElement.classList.remove('done');
588
+ }
589
+ gestureElement.style.top = (opt.rect.top + ((opt.rect.height - 20) / 2)).toString() + 'px';
590
+ gestureElement.style.left = (opt.rect.left - 10 + (xxAbs / 1.5)).toString() + 'px';
591
+ gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
592
+ }
593
+ else {
594
+ if (!dirs.includes('right')) {
595
+ gestureElement.style.opacity = '0';
596
+ clearGestureData();
597
+ return;
598
+ }
599
+ gestureElement.style.opacity = '1';
600
+ if (xxAbs === 90) {
601
+ bindGestureData.dir = 'right';
602
+ gestureElement.classList.add('done');
603
+ }
604
+ else {
605
+ bindGestureData.dir = null;
606
+ gestureElement.classList.remove('done');
607
+ }
608
+ gestureElement.style.top = (opt.rect.top + ((opt.rect.height - 20) / 2)).toString() + 'px';
609
+ gestureElement.style.left = (opt.rect.left + opt.rect.width - 10 - (xxAbs / 1.5)).toString() + 'px';
610
+ gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
611
+ }
612
+ }
613
+ else {
614
+ if (bindGestureData.xy < 0) {
615
+ if (!dirs.includes('top')) {
616
+ gestureElement.style.opacity = '0';
617
+ clearGestureData();
618
+ return;
619
+ }
620
+ gestureElement.style.opacity = '1';
621
+ if (xyAbs === 90) {
622
+ bindGestureData.dir = 'top';
623
+ gestureElement.classList.add('done');
624
+ }
625
+ else {
626
+ bindGestureData.dir = null;
627
+ gestureElement.classList.remove('done');
628
+ }
629
+ gestureElement.style.left = (opt.rect.left + ((opt.rect.width - 20) / 2)).toString() + 'px';
630
+ gestureElement.style.top = (opt.rect.top - 10 + (xyAbs / 1.5)).toString() + 'px';
631
+ gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
632
+ }
633
+ else {
634
+ if (!dirs.includes('bottom')) {
635
+ gestureElement.style.opacity = '0';
636
+ clearGestureData();
637
+ return;
638
+ }
639
+ gestureElement.style.opacity = '1';
640
+ if (xyAbs === 90) {
641
+ bindGestureData.dir = 'bottom';
642
+ gestureElement.classList.add('done');
643
+ }
644
+ else {
645
+ bindGestureData.dir = null;
646
+ gestureElement.classList.remove('done');
647
+ }
648
+ gestureElement.style.left = (opt.rect.left + ((opt.rect.width - 20) / 2)).toString() + 'px';
649
+ gestureElement.style.top = (opt.rect.top + opt.rect.height - 10 - (xyAbs / 1.5)).toString() + 'px';
650
+ gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
651
+ }
652
+ }
653
+ if (bindGestureData.xx === bindGestureData.tx && bindGestureData.xy === bindGestureData.ty) {
654
+ bindGestureData.timers.ani = 0;
655
+ bindGestureData.timers.sleep = window.setTimeout(() => {
656
+ clearGestureData();
657
+ bindGestureData.timers.sleep = 0;
658
+ gestureElement.style.opacity = '0';
659
+ if (!bindGestureData.dir) {
660
+ return;
661
+ }
662
+ opt.handler(bindGestureData.dir);
663
+ }, 500);
664
+ return;
665
+ }
666
+ bindGestureData.timers.ani = requestAnimationFrame(() => {
667
+ bindGestureAnimation(opt);
668
+ });
669
+ }
670
+ function bindGesture(e, opt) {
671
+ var _a, _b, _c, _d, _e;
672
+ const gestureElement = document.getElementById('cg-gesture');
673
+ const el = (_b = (_a = e.currentTarget) !== null && _a !== void 0 ? _a : e.target) !== null && _b !== void 0 ? _b : opt.el;
674
+ if (!el) {
675
+ return;
676
+ }
677
+ let rect;
678
+ if (e.rect) {
679
+ rect = e.rect;
680
+ }
681
+ else if (opt.rect) {
682
+ rect = opt.rect;
683
+ }
684
+ else {
685
+ if (!(el.getBoundingClientRect)) {
686
+ return;
687
+ }
688
+ rect = el.getBoundingClientRect();
689
+ }
690
+ const dirs = (_c = opt.dirs) !== null && _c !== void 0 ? _c : ['top', 'bottom'];
691
+ if ((e instanceof MouseEvent || e instanceof TouchEvent) && !(e instanceof WheelEvent)) {
692
+ const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
693
+ const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
694
+ let dir = null;
695
+ bindDown(e, {
696
+ move: (e) => {
697
+ e.preventDefault();
698
+ if (bindGestureData.timers.ani !== 0) {
699
+ cancelAnimationFrame(bindGestureData.timers.ani);
700
+ bindGestureData.timers.ani = 0;
701
+ }
702
+ if (bindGestureData.timers.sleep !== 0) {
703
+ clearTimeout(bindGestureData.timers.sleep);
704
+ bindGestureData.timers.sleep = 0;
705
+ }
706
+ const nx = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
707
+ const ny = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
708
+ const xx = nx - x;
709
+ const xy = ny - y;
710
+ let xxAbs = Math.abs(xx);
711
+ let xyAbs = Math.abs(xy);
712
+ if ((!dirs.includes('top') && !dirs.includes('bottom')) || ((xxAbs > xyAbs) && (dirs.includes('left') || dirs.includes('right')))) {
713
+ if (xx > 0) {
714
+ if (!dirs.includes('left')) {
715
+ gestureElement.style.opacity = '0';
716
+ return;
717
+ }
718
+ gestureElement.style.opacity = '1';
719
+ if (xxAbs > 90) {
720
+ xxAbs = 90;
721
+ dir = 'left';
722
+ gestureElement.classList.add('done');
723
+ }
724
+ else {
725
+ dir = null;
726
+ gestureElement.classList.remove('done');
727
+ }
728
+ gestureElement.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
729
+ gestureElement.style.left = (rect.left - 10 + (xxAbs / 1.5)).toString() + 'px';
730
+ gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
731
+ }
732
+ else {
733
+ if (!dirs.includes('right')) {
734
+ gestureElement.style.opacity = '0';
735
+ return;
736
+ }
737
+ gestureElement.style.opacity = '1';
738
+ if (xxAbs > 90) {
739
+ xxAbs = 90;
740
+ dir = 'right';
741
+ gestureElement.classList.add('done');
742
+ }
743
+ else {
744
+ dir = null;
745
+ gestureElement.classList.remove('done');
746
+ }
747
+ gestureElement.style.top = (rect.top + ((rect.height - 20) / 2)).toString() + 'px';
748
+ gestureElement.style.left = (rect.left + rect.width - 10 - (xxAbs / 1.5)).toString() + 'px';
749
+ gestureElement.style.transform = 'scale(' + (xxAbs / 90).toString() + ')';
750
+ }
751
+ }
752
+ else {
753
+ if (xy > 0) {
754
+ if (!dirs.includes('top')) {
755
+ gestureElement.style.opacity = '0';
756
+ return;
757
+ }
758
+ gestureElement.style.opacity = '1';
759
+ if (xyAbs > 90) {
760
+ xyAbs = 90;
761
+ dir = 'top';
762
+ gestureElement.classList.add('done');
763
+ }
764
+ else {
765
+ dir = null;
766
+ gestureElement.classList.remove('done');
767
+ }
768
+ gestureElement.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
769
+ gestureElement.style.top = (rect.top - 10 + (xyAbs / 1.5)).toString() + 'px';
770
+ gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
771
+ }
772
+ else {
773
+ if (!dirs.includes('bottom')) {
774
+ gestureElement.style.opacity = '0';
775
+ return;
776
+ }
777
+ gestureElement.style.opacity = '1';
778
+ if (xyAbs > 90) {
779
+ xyAbs = 90;
780
+ dir = 'bottom';
781
+ gestureElement.classList.add('done');
782
+ }
783
+ else {
784
+ dir = null;
785
+ gestureElement.classList.remove('done');
786
+ }
787
+ gestureElement.style.left = (rect.left + ((rect.width - 20) / 2)).toString() + 'px';
788
+ gestureElement.style.top = (rect.top + rect.height - 10 - (xyAbs / 1.5)).toString() + 'px';
789
+ gestureElement.style.transform = 'scale(' + (xyAbs / 90).toString() + ')';
790
+ }
791
+ }
792
+ },
793
+ end: () => {
794
+ gestureElement.style.opacity = '0';
795
+ if (!dir) {
796
+ return;
797
+ }
798
+ opt.handler(dir);
799
+ }
800
+ });
801
+ }
802
+ else {
803
+ if (bindGestureData.el !== el) {
804
+ bindGestureData.el = el;
805
+ bindGestureData.xx = 0;
806
+ bindGestureData.xy = 0;
807
+ }
808
+ let x = 0, y = 0;
809
+ if (e instanceof WheelEvent) {
810
+ e.preventDefault();
811
+ if (Math.abs(e.deltaX) < 5 && Math.abs(e.deltaY) < 5) {
812
+ return;
813
+ }
814
+ x = Math.round(e.deltaX / 3);
815
+ y = Math.round(e.deltaY / 3);
816
+ if (e.direction === 'h') {
817
+ x = y;
818
+ y = 0;
819
+ }
820
+ else if (e.direction === 'v') {
821
+ y = x;
822
+ x = 0;
823
+ }
824
+ }
825
+ else {
826
+ x = (_d = e.x) !== null && _d !== void 0 ? _d : 0;
827
+ y = (_e = e.y) !== null && _e !== void 0 ? _e : 0;
828
+ }
829
+ let tx = bindGestureData.tx + x;
830
+ if (tx > 90) {
831
+ tx = 90;
832
+ }
833
+ else if (tx < -90) {
834
+ tx = -90;
835
+ }
836
+ let ty = bindGestureData.ty + y;
837
+ if (ty > 90) {
838
+ ty = 90;
839
+ }
840
+ else if (ty < -90) {
841
+ ty = -90;
842
+ }
843
+ bindGestureData.tx = tx;
844
+ bindGestureData.ty = ty;
845
+ if (bindGestureData.timers.ani !== 0) {
846
+ cancelAnimationFrame(bindGestureData.timers.ani);
847
+ bindGestureData.timers.ani = 0;
848
+ }
849
+ if (bindGestureData.timers.sleep !== 0) {
850
+ clearTimeout(bindGestureData.timers.sleep);
851
+ bindGestureData.timers.sleep = 0;
852
+ }
853
+ bindGestureAnimation({
854
+ 'rect': rect,
855
+ 'dirs': opt.dirs,
856
+ 'handler': opt.handler
857
+ });
858
+ }
859
+ }
860
+ exports.bindGesture = bindGesture;
861
+ let lastLongTime = 0;
862
+ function allowEvent(e) {
863
+ const now = Date.now();
864
+ if (now - lastLongTime < 5) {
865
+ return false;
866
+ }
867
+ const current = e.currentTarget;
868
+ if (current.dataset.cgDisabled !== undefined) {
869
+ return false;
870
+ }
871
+ if (findParentByData(current, 'cg-disabled')) {
872
+ return false;
873
+ }
874
+ return true;
875
+ }
876
+ exports.allowEvent = allowEvent;
877
+ function bindLong(e, long) {
878
+ if (hasTouchButMouse(e)) {
879
+ return;
880
+ }
881
+ const tx = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
882
+ const ty = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
883
+ let ox = 0;
884
+ let oy = 0;
885
+ let isLong = false;
886
+ let timer = window.setTimeout(() => {
887
+ clearTimeout(timer);
888
+ timer = undefined;
889
+ if (ox <= 1 && oy <= 1) {
890
+ isLong = true;
891
+ const rtn = long(e);
892
+ if (rtn instanceof Promise) {
893
+ rtn.catch((e) => {
894
+ throw e;
895
+ });
896
+ }
897
+ }
898
+ }, 300);
899
+ bindDown(e, {
900
+ move: (e) => {
901
+ const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
902
+ const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
903
+ ox = Math.abs(x - tx);
904
+ oy = Math.abs(y - ty);
905
+ },
906
+ up: () => {
907
+ if (timer !== undefined) {
908
+ clearTimeout(timer);
909
+ timer = undefined;
910
+ }
911
+ else if (isLong) {
912
+ lastLongTime = Date.now();
913
+ }
914
+ }
915
+ });
916
+ }
917
+ exports.bindLong = bindLong;
918
+ function bindDrag(e, opt) {
919
+ let otop = 0;
920
+ let oleft = 0;
921
+ let nel = null;
922
+ bindMove(e, {
923
+ 'object': opt.el,
924
+ 'start': function () {
925
+ const rect = opt.el.getBoundingClientRect();
926
+ form.showDrag();
927
+ form.moveDrag({
928
+ 'top': rect.top,
929
+ 'left': rect.left,
930
+ 'width': rect.width,
931
+ 'height': rect.height,
932
+ 'icon': true
933
+ });
934
+ otop = rect.top;
935
+ oleft = rect.left;
936
+ },
937
+ 'move': function (ox, oy, x, y) {
938
+ const ntop = otop + oy;
939
+ const nleft = oleft + ox;
940
+ form.moveDrag({
941
+ 'top': ntop,
942
+ 'left': nleft,
943
+ 'icon': false
944
+ });
945
+ otop = ntop;
946
+ oleft = nleft;
947
+ const els = document.elementsFromPoint(x, y);
948
+ for (const el of els) {
949
+ if (el.dataset.cgDrop === undefined) {
950
+ continue;
951
+ }
952
+ if (el === opt.el) {
953
+ continue;
954
+ }
955
+ if (el === nel) {
956
+ return;
957
+ }
958
+ if (nel !== null) {
959
+ nel.removeAttribute('data-cg-hover');
960
+ nel.dispatchEvent(new CustomEvent('dragleave', {
961
+ 'detail': {
962
+ 'value': opt.data
963
+ }
964
+ }));
965
+ }
966
+ el.dataset.cgHover = '';
967
+ nel = el;
968
+ nel.dispatchEvent(new CustomEvent('dragenter', {
969
+ 'detail': {
970
+ 'value': opt.data
971
+ }
972
+ }));
973
+ return;
974
+ }
975
+ form.moveDrag({
976
+ 'icon': true
977
+ });
978
+ if (nel === null) {
979
+ return;
980
+ }
981
+ nel.removeAttribute('data-cg-hover');
982
+ nel.dispatchEvent(new CustomEvent('dragleave', {
983
+ 'detail': {
984
+ 'value': opt.data
985
+ }
986
+ }));
987
+ nel = null;
988
+ },
989
+ 'end': function () {
990
+ form.hideDrag();
991
+ if (nel === null) {
992
+ return;
993
+ }
994
+ nel.removeAttribute('data-cg-hover');
995
+ nel.dispatchEvent(new CustomEvent('drop', {
996
+ 'detail': {
997
+ 'value': opt.data
998
+ }
999
+ }));
1000
+ }
1001
+ });
1002
+ }
1003
+ exports.bindDrag = bindDrag;
1004
+ exports.is = Vue.reactive({
1005
+ 'move': false,
1006
+ 'shift': false,
1007
+ 'ctrl': false
1008
+ });
1009
+ window.addEventListener('keydown', function (e) {
1010
+ switch (e.key) {
1011
+ case 'Shift': {
1012
+ exports.is.shift = true;
1013
+ break;
1014
+ }
1015
+ case 'Control': {
1016
+ exports.is.ctrl = true;
1017
+ break;
1018
+ }
1019
+ }
1020
+ });
1021
+ window.addEventListener('keyup', function (e) {
1022
+ switch (e.key) {
1023
+ case 'Shift': {
1024
+ exports.is.shift = false;
1025
+ break;
1026
+ }
1027
+ case 'Control': {
1028
+ exports.is.ctrl = false;
1029
+ break;
1030
+ }
1031
+ }
1032
+ });
1033
+ function bindMove(e, opt) {
1034
+ var _a, _b, _c, _d;
1035
+ if (hasTouchButMouse(e)) {
1036
+ return {
1037
+ 'left': 0,
1038
+ 'top': 0,
1039
+ 'right': 0,
1040
+ 'bottom': 0
1041
+ };
1042
+ }
1043
+ exports.is.move = true;
1044
+ setGlobalCursor(getComputedStyle(e.target).cursor);
1045
+ let tx = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
1046
+ let ty = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
1047
+ let left, top, right, bottom;
1048
+ if (opt.areaObject) {
1049
+ if (!(opt.areaObject instanceof HTMLElement)) {
1050
+ opt.areaObject = opt.areaObject.$el;
1051
+ }
1052
+ const areaRect = opt.areaObject.getBoundingClientRect();
1053
+ const areaStyle = getComputedStyle(opt.areaObject);
1054
+ left = areaRect.left + parseFloat(areaStyle.borderLeftWidth) + parseFloat(areaStyle.paddingLeft);
1055
+ top = areaRect.top + parseFloat(areaStyle.borderTopWidth) + parseFloat(areaStyle.paddingTop);
1056
+ right = areaRect.left + areaRect.width - (parseFloat(areaStyle.borderRightWidth)
1057
+ + parseFloat(areaStyle.paddingRight));
1058
+ bottom = areaRect.top + areaRect.height - (parseFloat(areaStyle.borderRightWidth)
1059
+ + parseFloat(areaStyle.paddingRight));
1060
+ }
1061
+ else {
1062
+ const area = core.getAvailArea();
1063
+ left = (_a = opt.left) !== null && _a !== void 0 ? _a : area.left;
1064
+ top = (_b = opt.top) !== null && _b !== void 0 ? _b : area.top;
1065
+ right = (_c = opt.right) !== null && _c !== void 0 ? _c : area.width;
1066
+ bottom = (_d = opt.bottom) !== null && _d !== void 0 ? _d : area.height;
1067
+ }
1068
+ if (opt.offsetLeft) {
1069
+ left += opt.offsetLeft;
1070
+ }
1071
+ if (opt.offsetTop) {
1072
+ top += opt.offsetTop;
1073
+ }
1074
+ if (opt.offsetRight) {
1075
+ right += opt.offsetRight;
1076
+ }
1077
+ if (opt.offsetBottom) {
1078
+ bottom += opt.offsetBottom;
1079
+ }
1080
+ let isBorder = false;
1081
+ let objectLeft, objectTop, objectWidth, objectHeight;
1082
+ let offsetLeft = 0, offsetTop = 0, offsetRight = 0, offsetBottom = 0;
1083
+ const moveTimes = [];
1084
+ bindDown(e, {
1085
+ start: () => {
1086
+ var _a, _b, _c, _d;
1087
+ if (opt.start) {
1088
+ if (opt.start(tx, ty) === false) {
1089
+ setGlobalCursor();
1090
+ return false;
1091
+ }
1092
+ }
1093
+ if (opt.object) {
1094
+ if (!(opt.object instanceof HTMLElement)) {
1095
+ opt.object = opt.object.$el;
1096
+ }
1097
+ const rect = opt.object.getBoundingClientRect();
1098
+ objectLeft = rect.left;
1099
+ objectTop = rect.top;
1100
+ objectWidth = rect.width;
1101
+ objectHeight = rect.height;
1102
+ }
1103
+ else {
1104
+ objectLeft = (_a = opt.objectLeft) !== null && _a !== void 0 ? _a : 0;
1105
+ objectTop = (_b = opt.objectTop) !== null && _b !== void 0 ? _b : 0;
1106
+ objectWidth = (_c = opt.objectWidth) !== null && _c !== void 0 ? _c : 0;
1107
+ objectHeight = (_d = opt.objectHeight) !== null && _d !== void 0 ? _d : 0;
1108
+ }
1109
+ if (objectWidth > 0) {
1110
+ offsetLeft = tx - objectLeft;
1111
+ }
1112
+ if (objectHeight > 0) {
1113
+ offsetTop = ty - objectTop;
1114
+ }
1115
+ offsetRight = objectWidth - offsetLeft;
1116
+ offsetBottom = objectHeight - offsetTop;
1117
+ },
1118
+ move: (e, dir) => {
1119
+ var _a, _b, _c;
1120
+ let x, y;
1121
+ x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
1122
+ y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
1123
+ if (x === tx && y === ty) {
1124
+ return;
1125
+ }
1126
+ let inBorderTop = false, inBorderRight = false, inBorderBottom = false, inBorderLeft = false;
1127
+ const nowLeft = x - offsetLeft;
1128
+ const nowRight = x + offsetRight;
1129
+ if (nowLeft <= left) {
1130
+ inBorderLeft = true;
1131
+ if (nowLeft < left && x < tx) {
1132
+ if (tx - offsetLeft > left) {
1133
+ x = left + offsetLeft;
1134
+ }
1135
+ else {
1136
+ x = tx;
1137
+ }
1138
+ }
1139
+ }
1140
+ else if (offsetRight !== 0) {
1141
+ if (nowRight >= right) {
1142
+ inBorderRight = true;
1143
+ if (nowRight > right && x > tx) {
1144
+ if (tx + offsetRight < right) {
1145
+ x = right - offsetRight;
1146
+ }
1147
+ else {
1148
+ x = tx;
1149
+ }
1150
+ }
1151
+ }
1152
+ }
1153
+ else if (offsetRight === 0) {
1154
+ const r1 = right - 1;
1155
+ if (x >= r1) {
1156
+ inBorderRight = true;
1157
+ if (x > r1 && x > tx) {
1158
+ if (tx < r1) {
1159
+ x = r1;
1160
+ }
1161
+ else {
1162
+ x = tx;
1163
+ }
1164
+ }
1165
+ }
1166
+ }
1167
+ const nowTop = y - offsetTop;
1168
+ const nowBottom = y + offsetBottom;
1169
+ if (nowTop <= top) {
1170
+ inBorderTop = true;
1171
+ if (nowTop < top && y < ty) {
1172
+ if (ty - offsetTop > top) {
1173
+ y = top + offsetTop;
1174
+ }
1175
+ else {
1176
+ y = ty;
1177
+ }
1178
+ }
1179
+ }
1180
+ else if (offsetBottom !== 0) {
1181
+ if (nowBottom >= bottom) {
1182
+ inBorderBottom = true;
1183
+ if (nowBottom > bottom && y > ty) {
1184
+ if (ty + offsetBottom < bottom) {
1185
+ y = bottom - offsetBottom;
1186
+ }
1187
+ else {
1188
+ y = ty;
1189
+ }
1190
+ }
1191
+ }
1192
+ }
1193
+ else if (offsetBottom === 0) {
1194
+ const b1 = bottom - 1;
1195
+ if (y >= b1) {
1196
+ inBorderBottom = true;
1197
+ if (y > b1 && y > ty) {
1198
+ if (ty < b1) {
1199
+ y = b1;
1200
+ }
1201
+ else {
1202
+ y = ty;
1203
+ }
1204
+ }
1205
+ }
1206
+ }
1207
+ let border = '';
1208
+ if (inBorderTop || inBorderRight || inBorderBottom || inBorderLeft) {
1209
+ if (inBorderTop) {
1210
+ if (x - left <= 20) {
1211
+ border = 'lt';
1212
+ }
1213
+ else if (right - x <= 20) {
1214
+ border = 'tr';
1215
+ }
1216
+ else {
1217
+ border = 't';
1218
+ }
1219
+ }
1220
+ else if (inBorderRight) {
1221
+ if (y - top <= 20) {
1222
+ border = 'tr';
1223
+ }
1224
+ else if (bottom - y <= 20) {
1225
+ border = 'rb';
1226
+ }
1227
+ else {
1228
+ border = 'r';
1229
+ }
1230
+ }
1231
+ else if (inBorderBottom) {
1232
+ if (right - x <= 20) {
1233
+ border = 'rb';
1234
+ }
1235
+ else if (x - left <= 20) {
1236
+ border = 'bl';
1237
+ }
1238
+ else {
1239
+ border = 'b';
1240
+ }
1241
+ }
1242
+ else if (inBorderLeft) {
1243
+ if (y - top <= 20) {
1244
+ border = 'lt';
1245
+ }
1246
+ else if (bottom - y <= 20) {
1247
+ border = 'bl';
1248
+ }
1249
+ else {
1250
+ border = 'l';
1251
+ }
1252
+ }
1253
+ if (!isBorder) {
1254
+ isBorder = true;
1255
+ (_a = opt.borderIn) === null || _a === void 0 ? void 0 : _a.call(opt, x, y, border, e);
1256
+ }
1257
+ }
1258
+ else {
1259
+ if (isBorder) {
1260
+ isBorder = false;
1261
+ (_b = opt.borderOut) === null || _b === void 0 ? void 0 : _b.call(opt);
1262
+ }
1263
+ }
1264
+ const ox = x - tx;
1265
+ const oy = y - ty;
1266
+ moveTimes.push({
1267
+ 'time': Date.now(),
1268
+ 'ox': ox,
1269
+ 'oy': oy
1270
+ });
1271
+ (_c = opt.move) === null || _c === void 0 ? void 0 : _c.call(opt, ox, oy, x, y, border, dir, e);
1272
+ tx = x;
1273
+ ty = y;
1274
+ },
1275
+ up: (e) => {
1276
+ var _a;
1277
+ exports.is.move = false;
1278
+ setGlobalCursor();
1279
+ (_a = opt.up) === null || _a === void 0 ? void 0 : _a.call(opt, moveTimes, e);
1280
+ },
1281
+ end: (e) => {
1282
+ var _a;
1283
+ (_a = opt.end) === null || _a === void 0 ? void 0 : _a.call(opt, moveTimes, e);
1284
+ }
1285
+ });
1286
+ if (opt.showRect) {
1287
+ form.showRectangle(tx, ty, {
1288
+ 'left': left,
1289
+ 'top': top,
1290
+ 'width': right - left,
1291
+ 'height': bottom - top
1292
+ });
1293
+ setTimeout(() => {
1294
+ form.hideRectangle();
1295
+ }, 3000);
1296
+ }
1297
+ return {
1298
+ 'left': left,
1299
+ 'top': top,
1300
+ 'right': right,
1301
+ 'bottom': bottom
1302
+ };
1303
+ }
1304
+ exports.bindMove = bindMove;
1305
+ function bindResize(e, opt) {
1306
+ var _a, _b;
1307
+ if (hasTouchButMouse(e)) {
1308
+ return;
1309
+ }
1310
+ opt.minWidth = (_a = opt.minWidth) !== null && _a !== void 0 ? _a : 0;
1311
+ opt.minHeight = (_b = opt.minHeight) !== null && _b !== void 0 ? _b : 0;
1312
+ const x = e instanceof MouseEvent ? e.clientX : e.touches[0].clientX;
1313
+ const y = e instanceof MouseEvent ? e.clientY : e.touches[0].clientY;
1314
+ let offsetLeft, offsetTop, offsetRight, offsetBottom;
1315
+ let left, top, right, bottom;
1316
+ if (opt.objectLeft === undefined
1317
+ || opt.objectTop === undefined
1318
+ || opt.objectWidth === undefined
1319
+ || opt.objectHeight === undefined) {
1320
+ if (!opt.object) {
1321
+ return;
1322
+ }
1323
+ if (!(opt.object instanceof HTMLElement)) {
1324
+ opt.object = opt.object.$el;
1325
+ }
1326
+ const objectRect = opt.object.getBoundingClientRect();
1327
+ opt.objectLeft = objectRect.left;
1328
+ opt.objectTop = objectRect.top;
1329
+ opt.objectWidth = objectRect.width;
1330
+ opt.objectHeight = objectRect.height;
1331
+ }
1332
+ if (opt.border === 'tr' || opt.border === 'r' || opt.border === 'rb') {
1333
+ left = opt.objectLeft + opt.minWidth;
1334
+ offsetLeft = x - (opt.objectLeft + opt.objectWidth);
1335
+ offsetRight = offsetLeft;
1336
+ if (opt.maxWidth) {
1337
+ right = opt.objectLeft + opt.maxWidth;
1338
+ }
1339
+ }
1340
+ else if (opt.border === 'bl' || opt.border === 'l' || opt.border === 'lt') {
1341
+ right = opt.objectLeft + opt.objectWidth - opt.minWidth;
1342
+ offsetLeft = x - opt.objectLeft;
1343
+ offsetRight = offsetLeft;
1344
+ if (opt.maxWidth) {
1345
+ left = opt.objectLeft + opt.objectWidth - opt.maxWidth;
1346
+ }
1347
+ }
1348
+ if (opt.border === 'rb' || opt.border === 'b' || opt.border === 'bl') {
1349
+ top = opt.objectTop + opt.minHeight;
1350
+ offsetTop = y - (opt.objectTop + opt.objectHeight);
1351
+ offsetBottom = offsetTop;
1352
+ if (opt.maxHeight) {
1353
+ bottom = opt.objectTop + opt.maxHeight;
1354
+ }
1355
+ }
1356
+ else if (opt.border === 'lt' || opt.border === 't' || opt.border === 'tr') {
1357
+ bottom = opt.objectTop + opt.objectHeight - opt.minHeight;
1358
+ offsetTop = y - opt.objectTop;
1359
+ offsetBottom = offsetTop;
1360
+ if (opt.maxHeight) {
1361
+ top = opt.objectTop + opt.objectHeight - opt.maxHeight;
1362
+ }
1363
+ }
1364
+ bindMove(e, {
1365
+ 'left': left,
1366
+ 'top': top,
1367
+ 'right': right,
1368
+ 'bottom': bottom,
1369
+ 'offsetLeft': offsetLeft,
1370
+ 'offsetTop': offsetTop,
1371
+ 'offsetRight': offsetRight,
1372
+ 'offsetBottom': offsetBottom,
1373
+ 'start': opt.start,
1374
+ 'move': function (ox, oy, x, y, border) {
1375
+ var _a;
1376
+ if (opt.border === 'tr' || opt.border === 'r' || opt.border === 'rb') {
1377
+ opt.objectWidth += ox;
1378
+ }
1379
+ else if (opt.border === 'bl' || opt.border === 'l' || opt.border === 'lt') {
1380
+ opt.objectWidth -= ox;
1381
+ opt.objectLeft += ox;
1382
+ }
1383
+ if (opt.border === 'rb' || opt.border === 'b' || opt.border === 'bl') {
1384
+ opt.objectHeight += oy;
1385
+ }
1386
+ else if (opt.border === 'lt' || opt.border === 't' || opt.border === 'tr') {
1387
+ opt.objectHeight -= oy;
1388
+ opt.objectTop += oy;
1389
+ }
1390
+ (_a = opt.move) === null || _a === void 0 ? void 0 : _a.call(opt, opt.objectLeft, opt.objectTop, opt.objectWidth, opt.objectHeight, x, y, border);
1391
+ },
1392
+ 'end': opt.end
1393
+ });
1394
+ }
1395
+ exports.bindResize = bindResize;
1396
+ function findParentByData(el, name) {
1397
+ let parent = el.parentNode;
1398
+ while (parent) {
1399
+ if (!parent.tagName) {
1400
+ continue;
1401
+ }
1402
+ if (parent.tagName.toLowerCase() === 'body') {
1403
+ break;
1404
+ }
1405
+ if (parent.getAttribute('data-' + name) !== null) {
1406
+ return parent;
1407
+ }
1408
+ parent = parent.parentNode;
1409
+ }
1410
+ return null;
1411
+ }
1412
+ exports.findParentByData = findParentByData;
1413
+ function findParentByClass(el, name) {
1414
+ let parent = el.parentNode;
1415
+ while (parent) {
1416
+ if (!parent.tagName) {
1417
+ continue;
1418
+ }
1419
+ if (parent.tagName.toLowerCase() === 'body') {
1420
+ break;
1421
+ }
1422
+ if (parent.classList.contains(name)) {
1423
+ return parent;
1424
+ }
1425
+ parent = parent.parentNode;
1426
+ }
1427
+ return null;
1428
+ }
1429
+ exports.findParentByClass = findParentByClass;
1430
+ function siblings(el) {
1431
+ if (!el.parentNode) {
1432
+ return [];
1433
+ }
1434
+ const list = [];
1435
+ for (let i = 0; i < el.parentNode.children.length; ++i) {
1436
+ const e = el.parentNode.children.item(i);
1437
+ if (e === el) {
1438
+ continue;
1439
+ }
1440
+ list.push(e);
1441
+ }
1442
+ return list;
1443
+ }
1444
+ exports.siblings = siblings;
1445
+ function siblingsData(el, name) {
1446
+ const list = siblings(el);
1447
+ const olist = [];
1448
+ for (const item of list) {
1449
+ if (item.getAttribute('data-' + name) === null) {
1450
+ continue;
1451
+ }
1452
+ olist.push(item);
1453
+ }
1454
+ return olist;
1455
+ }
1456
+ exports.siblingsData = siblingsData;
1457
+ function fullscreen() {
1458
+ const he = document.getElementsByTagName('html')[0];
1459
+ if (he.webkitRequestFullscreen) {
1460
+ he.webkitRequestFullscreen();
1461
+ return true;
1462
+ }
1463
+ else if (he.requestFullscreen) {
1464
+ he.requestFullscreen();
1465
+ return true;
1466
+ }
1467
+ else {
1468
+ return false;
1469
+ }
1470
+ }
1471
+ exports.fullscreen = fullscreen;