x4js 2.0.11 → 2.0.13

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 (109) hide show
  1. package/README.md +15 -15
  2. package/lib/README.txt +15 -15
  3. package/lib/cjs/x4.css +1 -1
  4. package/lib/cjs/x4.js +1 -1
  5. package/lib/esm/x4.css +1 -1
  6. package/lib/esm/x4.mjs +1 -1
  7. package/lib/src/components/base.scss +25 -26
  8. package/lib/src/components/boxes/boxes.module.scss +37 -37
  9. package/lib/src/components/boxes/boxes.ts +129 -125
  10. package/lib/src/components/breadcrumb/breadcrumb.scss +28 -0
  11. package/lib/src/components/breadcrumb/breadcrumb.ts +84 -0
  12. package/lib/src/components/breadcrumb/chevron-right.svg +1 -0
  13. package/lib/src/components/btngroup/btngroup.module.scss +28 -28
  14. package/lib/src/components/btngroup/btngroup.ts +119 -101
  15. package/lib/src/components/button/button.module.scss +154 -153
  16. package/lib/src/components/button/button.ts +117 -117
  17. package/lib/src/components/calendar/calendar.module.scss +162 -162
  18. package/lib/src/components/calendar/calendar.ts +326 -325
  19. package/lib/src/components/checkbox/check.svg +3 -3
  20. package/lib/src/components/checkbox/checkbox.module.scss +141 -141
  21. package/lib/src/components/checkbox/checkbox.ts +125 -124
  22. package/lib/src/components/colorinput/colorinput.module.scss +64 -64
  23. package/lib/src/components/colorinput/colorinput.ts +90 -87
  24. package/lib/src/components/colorpicker/colorpicker.module.scss +132 -132
  25. package/lib/src/components/colorpicker/colorpicker.ts +481 -476
  26. package/lib/src/components/combobox/combobox.module.scss +123 -120
  27. package/lib/src/components/combobox/combobox.ts +192 -190
  28. package/lib/src/components/combobox/updown.svg +3 -3
  29. package/lib/src/components/components.ts +34 -0
  30. package/lib/src/components/dialog/dialog.module.scss +71 -71
  31. package/lib/src/components/dialog/dialog.ts +94 -92
  32. package/lib/src/components/form/form.module.scss +34 -34
  33. package/lib/src/components/form/form.ts +41 -36
  34. package/lib/src/components/grid/datastore.ts +1298 -0
  35. package/lib/src/components/grid/gridview.ts +1108 -0
  36. package/lib/src/components/grid/memdb.ts +325 -0
  37. package/lib/src/components/header/header.module.scss +39 -39
  38. package/lib/src/components/header/header.ts +129 -123
  39. package/lib/src/components/icon/icon.module.scss +29 -29
  40. package/lib/src/components/icon/icon.ts +136 -134
  41. package/lib/src/components/image/image.module.scss +20 -20
  42. package/lib/src/components/image/image.ts +68 -66
  43. package/lib/src/components/input/input.module.scss +69 -69
  44. package/lib/src/components/input/input.ts +275 -274
  45. package/lib/src/components/label/label.module.scss +58 -52
  46. package/lib/src/components/label/label.ts +64 -55
  47. package/lib/src/components/link/link.ts +78 -0
  48. package/lib/src/components/listbox/listbox.module.scss +103 -103
  49. package/lib/src/components/listbox/listbox.ts +431 -427
  50. package/lib/src/components/menu/menu.module.scss +107 -107
  51. package/lib/src/components/menu/menu.ts +171 -168
  52. package/lib/src/components/messages/messages.module.scss +48 -47
  53. package/lib/src/components/messages/messages.ts +68 -63
  54. package/lib/src/components/normalize.scss +386 -386
  55. package/lib/src/components/notification/notification.module.scss +81 -81
  56. package/lib/src/components/notification/notification.ts +109 -108
  57. package/lib/src/components/panel/panel.module.scss +47 -47
  58. package/lib/src/components/panel/panel.ts +57 -56
  59. package/lib/src/components/popup/popup.module.scss +43 -43
  60. package/lib/src/components/popup/popup.ts +396 -395
  61. package/lib/src/components/progress/progress.module.scss +56 -56
  62. package/lib/src/components/progress/progress.ts +43 -42
  63. package/lib/src/components/rating/rating.module.scss +22 -22
  64. package/lib/src/components/rating/rating.ts +131 -125
  65. package/lib/src/components/shared.scss +90 -76
  66. package/lib/src/components/sizers/sizer.module.scss +89 -89
  67. package/lib/src/components/sizers/sizer.ts +123 -119
  68. package/lib/src/components/slider/slider.module.scss +70 -70
  69. package/lib/src/components/slider/slider.ts +147 -142
  70. package/lib/src/components/switch/switch.module.scss +126 -126
  71. package/lib/src/components/switch/switch.ts +61 -55
  72. package/lib/src/components/tabs/tabs.module.scss +46 -46
  73. package/lib/src/components/tabs/tabs.ts +168 -157
  74. package/lib/src/components/textarea/textarea.module.scss +59 -59
  75. package/lib/src/components/textarea/textarea.ts +60 -54
  76. package/lib/src/components/textedit/textedit.module.scss +113 -113
  77. package/lib/src/components/textedit/textedit.ts +83 -82
  78. package/lib/src/components/themes.scss +81 -77
  79. package/lib/src/components/tooltips/tooltips.scss +50 -50
  80. package/lib/src/components/tooltips/tooltips.ts +103 -102
  81. package/lib/src/components/treeview/treeview.module.scss +115 -115
  82. package/lib/src/components/treeview/treeview.ts +410 -403
  83. package/lib/src/components/viewport/viewport.module.scss +24 -24
  84. package/lib/src/components/viewport/viewport.ts +41 -38
  85. package/lib/src/core/component.ts +1002 -979
  86. package/lib/src/core/core_application.ts +44 -0
  87. package/lib/src/core/core_colors.ts +249 -249
  88. package/lib/src/core/core_dom.ts +471 -471
  89. package/lib/src/core/core_dragdrop.ts +200 -200
  90. package/lib/src/core/core_element.ts +97 -97
  91. package/lib/src/core/core_events.ts +149 -149
  92. package/lib/src/core/core_i18n.ts +377 -377
  93. package/lib/src/core/core_router.ts +221 -221
  94. package/lib/src/core/core_styles.ts +214 -214
  95. package/lib/src/core/core_svg.ts +550 -550
  96. package/lib/src/core/core_tools.ts +688 -673
  97. package/lib/src/demo/assets/radio.svg +3 -3
  98. package/lib/src/demo/index.html +11 -11
  99. package/lib/src/demo/main.scss +21 -21
  100. package/lib/src/demo/main.tsx +323 -323
  101. package/lib/src/types/scss.d.ts +4 -4
  102. package/lib/src/types/x4react.d.ts +8 -8
  103. package/lib/src/x4.scss +18 -18
  104. package/lib/src/x4.ts +31 -60
  105. package/lib/styles/x4.css +1 -1
  106. package/lib/types/x4js.d.ts +100 -49
  107. package/package.json +2 -3
  108. package/src/x4.ts +31 -60
  109. package/lib/output.d.ts +0 -1472
@@ -1,471 +1,471 @@
1
- /**
2
- * ___ ___ __
3
- * \ \/ / / _
4
- * \ / /_| |_
5
- * / \____ _|
6
- * /__/\__\ |_|
7
- *
8
- * @file core_dom.ts
9
- * @author Etienne Cochard
10
- *
11
- * @copyright (c) 2024 R-libre ingenierie
12
- *
13
- * Use of this source code is governed by an MIT-style license
14
- * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
- **/
16
-
17
- /** @ignore this events must be defined on domNode (do not bubble) */
18
- export const unbubbleEvents = {
19
- mouseleave: 1, mouseenter: 1, load: 1, unload: 1, scroll: 1, focus: 1, blur: 1, rowexit: 1, beforeunload: 1, stop: 1,
20
- dragdrop: 1, dragenter: 1, dragexit: 1, draggesture: 1, dragover: 1, contextmenu: 1, created: 2, removed: 2, sizechange: 2
21
- };
22
-
23
- export type DOMEventHandler = ( ev: Event ) => void;
24
- type EventEntry = Record<string,DOMEventHandler | DOMEventHandler[]>;
25
-
26
- const event_handlers = new WeakMap<Node,EventEntry>( );
27
-
28
- /**
29
- * handle dom mutations
30
- */
31
-
32
- let mutObserver: MutationObserver = null;
33
-
34
- const observeMutation = (mutations: MutationRecord[], observer: MutationObserver): void => {
35
-
36
- const sendEvent = ( node: Node, code: "created" | "removed" ) => {
37
- // console.log( "notify", node, code );
38
-
39
- const store = event_handlers.get( node );
40
- if ( store && store[code] ) {
41
- node.dispatchEvent( new Event( code, {} ) );
42
- }
43
- }
44
-
45
- const notify = ( node: Node, create: boolean ) => {
46
-
47
- if( create ) {
48
- sendEvent( node, "created" );
49
- }
50
-
51
- for( let c=node.firstChild; c; c=c.nextSibling ) {
52
- notify( c, create );
53
- }
54
-
55
- if( !create ) {
56
- sendEvent( node, "removed" );
57
- }
58
- }
59
-
60
-
61
- for (const mutation of mutations) {
62
- if( mutation.type=="childList" ) {
63
- if( mutation.addedNodes ) {
64
- mutation.addedNodes.forEach( node => {
65
- notify( node, true );
66
- } );
67
- }
68
-
69
- if( mutation.removedNodes ) {
70
- mutation.removedNodes.forEach( node => {
71
- notify( node, false );
72
- } );
73
- }
74
- }
75
- }
76
- }
77
-
78
-
79
-
80
- /**
81
- *
82
- */
83
-
84
- let sizeObserver: ResizeObserver = null;
85
-
86
- function observeSize(entries: ResizeObserverEntry[]) {
87
- entries.forEach((entry) => {
88
- let dom = entry.target as HTMLElement;
89
- if (dom.offsetParent !== null) {
90
- dom.dispatchEvent( new Event('resized') );
91
- }
92
- });
93
- }
94
-
95
- /**
96
- *
97
- */
98
-
99
- export function dispatchEvent(ev: Event) {
100
-
101
- let target = ev.target as Node,
102
- noup = (unbubbleEvents as any)[ev.type] === 2;
103
-
104
- while (target) {
105
- const store = event_handlers.get( target );
106
- if ( store ) {
107
- const callback = store[ev.type];
108
- if( callback ) {
109
- if( Array.isArray(callback) ) {
110
- callback.some( c => c( ev ) );
111
- }
112
- else {
113
- callback( ev );
114
- }
115
-
116
- if (ev.stopPropagation || ev.defaultPrevented || noup) {
117
- break;
118
- }
119
- }
120
- }
121
-
122
- target = target.parentNode;
123
-
124
- // no need to go above
125
- if (target == document) {
126
- break;
127
- }
128
- }
129
- }
130
-
131
- /**
132
- *
133
- */
134
-
135
- export function addEvent( node: Node, name: string, handler: DOMEventHandler, prepend = false ) {
136
-
137
- if( name=="removed" || name=="created" ) {
138
- if( !mutObserver ) {
139
- mutObserver = new MutationObserver( observeMutation )
140
- mutObserver.observe( document.body, {childList: true,subtree: true} );
141
- }
142
- }
143
- else if( name=="resized" ) {
144
- if (!sizeObserver) {
145
- sizeObserver = new ResizeObserver( observeSize );
146
- }
147
-
148
- sizeObserver.observe( node as Element );
149
- }
150
-
151
-
152
- let store = event_handlers.get( node );
153
- if( !store ) {
154
- store = {}
155
- event_handlers.set( node, store );
156
- }
157
-
158
- if( !store[name] ) {
159
- store[name] = handler;
160
- node.addEventListener( name, dispatchEvent );
161
- }
162
- else {
163
- const entry = store[name];
164
- if( Array.isArray(entry) ) {
165
- entry.push( handler );
166
- }
167
- else {
168
- store[name] = [entry,handler];
169
- }
170
- }
171
- }
172
-
173
- /**
174
- *
175
- */
176
-
177
- export interface GlobalDOMEvents {
178
-
179
- /**
180
- * Fires when the user aborts the download.
181
- * @param ev The event.
182
- */
183
-
184
- abort?: (ev: UIEvent) => any;
185
- animationcancel?: (ev: AnimationEvent) => any;
186
- animationend?: (ev: AnimationEvent) => any;
187
- animationiteration?: (ev: AnimationEvent) => any;
188
- animationstart?: (ev: AnimationEvent) => any;
189
- auxclick?: (ev: MouseEvent) => any;
190
-
191
- /**
192
- * Fires when the object loses the input focus.
193
- * @param ev The focus event.
194
- */
195
- blur?: (ev: FocusEvent) => any;
196
- cancel?: (ev: Event) => any;
197
-
198
- /**
199
- * Occurs when playback is possible, but would require further buffering.
200
- * @param ev The event.
201
- */
202
- canplay?: (ev: Event) => any;
203
- canplaythrough?: (ev: Event) => any;
204
- /**
205
- * Fires when the contents of the object or selection have changed.
206
- * @param ev The event.
207
- */
208
- change?: (ev: Event) => any;
209
- /**
210
- * Fires when the user clicks the left mouse button on the object
211
- * @param ev The mouse event.
212
- */
213
- click?: (ev: MouseEvent) => any;
214
- close?: (ev: Event) => any;
215
- /**
216
- * Fires when the user clicks the right mouse button in the client area, opening the context menu.
217
- * @param ev The mouse event.
218
- */
219
- contextmenu?: (ev: MouseEvent) => any;
220
- cuechange?: (ev: Event) => any;
221
- /**
222
- * Fires when the user double-clicks the object.
223
- * @param ev The mouse event.
224
- */
225
- dblclick?: (ev: MouseEvent) => any;
226
- /**
227
- * Fires on the source object continuously during a drag operation.
228
- * @param ev The event.
229
- */
230
- drag?: (ev: DragEvent) => any;
231
- /**
232
- * Fires on the source object when the user releases the mouse at the close of a drag operation.
233
- * @param ev The event.
234
- */
235
- dragend?: (ev: DragEvent) => any;
236
- /**
237
- * Fires on the target element when the user drags the object to a valid drop target.
238
- * @param ev The drag event.
239
- */
240
- dragenter?: (ev: DragEvent) => any;
241
- dragexit?: (ev: Event) => any;
242
- /**
243
- * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation.
244
- * @param ev The drag event.
245
- */
246
- dragleave?: (ev: DragEvent) => any;
247
- /**
248
- * Fires on the target element continuously while the user drags the object over a valid drop target.
249
- * @param ev The event.
250
- */
251
- dragover?: (ev: DragEvent) => any;
252
- /**
253
- * Fires on the source object when the user starts to drag a text selection or selected object.
254
- * @param ev The event.
255
- */
256
- dragstart?: (ev: DragEvent) => any;
257
- drop?: (ev: DragEvent) => any;
258
- /**
259
- * Occurs when the duration attribute is updated.
260
- * @param ev The event.
261
- */
262
- durationchange?: (ev: Event) => any;
263
- /**
264
- * Occurs when the media element is reset to its initial state.
265
- * @param ev The event.
266
- */
267
- emptied?: (ev: Event) => any;
268
- /**
269
- * Occurs when the end of playback is reached.
270
- * @param ev The event
271
- */
272
- ended?: (ev: Event) => any;
273
- /**
274
- * Fires when an error occurs during object loading.
275
- * @param ev The event.
276
- */
277
- error?: OnErrorEventHandler;
278
- /**
279
- * Fires when the object receives focus.
280
- * @param ev The event.
281
- */
282
- focusin?: (ev: FocusEvent) => any;
283
- focusout?: (ev: FocusEvent) => any;
284
- focus?: (ev: FocusEvent) => any;
285
- gotpointercapture?: (ev: PointerEvent) => any;
286
- input?: (ev: Event) => any;
287
- invalid?: (ev: Event) => any;
288
- /**
289
- * Fires when the user presses a key.
290
- * @param ev The keyboard event
291
- */
292
- keydown?: (ev: KeyboardEvent) => any;
293
- /**
294
- * Fires when the user presses an alphanumeric key.
295
- * @param ev The event.
296
- */
297
- keypress?: (ev: KeyboardEvent) => any;
298
- /**
299
- * Fires when the user releases a key.
300
- * @param ev The keyboard event
301
- */
302
- keyup?: (ev: KeyboardEvent) => any;
303
- /**
304
- * Fires immediately after the browser loads the object.
305
- * @param ev The event.
306
- */
307
- load?: (ev: Event) => any;
308
- /**
309
- * Occurs when media data is loaded at the current playback position.
310
- * @param ev The event.
311
- */
312
- loadeddata?: (ev: Event) => any;
313
- /**
314
- * Occurs when the duration and dimensions of the media have been determined.
315
- * @param ev The event.
316
- */
317
- loadedmetadata?: (ev: Event) => any;
318
- /**
319
- * Occurs when Internet Explorer begins looking for media data.
320
- * @param ev The event.
321
- */
322
- loadstart?: (ev: Event) => any;
323
- lostpointercapture?: (ev: PointerEvent) => any;
324
- /**
325
- * Fires when the user clicks the object with either mouse button.
326
- * @param ev The mouse event.
327
- */
328
- mousedown?: (ev: MouseEvent) => any;
329
- mouseenter?: (ev: MouseEvent) => any;
330
- mouseleave?: (ev: MouseEvent) => any;
331
- /**
332
- * Fires when the user moves the mouse over the object.
333
- * @param ev The mouse event.
334
- */
335
- mousemove?: (ev: MouseEvent) => any;
336
- /**
337
- * Fires when the user moves the mouse pointer outside the boundaries of the object.
338
- * @param ev The mouse event.
339
- */
340
- mouseout?: (ev: MouseEvent) => any;
341
- /**
342
- * Fires when the user moves the mouse pointer into the object.
343
- * @param ev The mouse event.
344
- */
345
- mouseover?: (ev: MouseEvent) => any;
346
- /**
347
- * Fires when the user releases a mouse button while the mouse is over the object.
348
- * @param ev The mouse event.
349
- */
350
- mouseup?: (ev: MouseEvent) => any;
351
- /**
352
- * Occurs when playback is paused.
353
- * @param ev The event.
354
- */
355
- pause?: (ev: Event) => any;
356
- /**
357
- * Occurs when the play method is requested.
358
- * @param ev The event.
359
- */
360
- play?: (ev: Event) => any;
361
- /**
362
- * Occurs when the audio or video has started playing.
363
- * @param ev The event.
364
- */
365
- playing?: (ev: Event) => any;
366
- pointercancel?: (ev: PointerEvent) => any;
367
- pointerdown?: (ev: PointerEvent) => any;
368
- pointerenter?: (ev: PointerEvent) => any;
369
- pointerleave?: (ev: PointerEvent) => any;
370
- pointermove?: (ev: PointerEvent) => any;
371
- pointerout?: (ev: PointerEvent) => any;
372
- pointerover?: (ev: PointerEvent) => any;
373
- pointerup?: (ev: PointerEvent) => any;
374
- /**
375
- * Occurs to indicate progress while downloading media data.
376
- * @param ev The event.
377
- */
378
- progress?: (ev: ProgressEvent) => any;
379
- /**
380
- * Occurs when the playback rate is increased or decreased.
381
- * @param ev The event.
382
- */
383
- ratechange?: (ev: Event) => any;
384
- /**
385
- * Fires when the user resets a form.
386
- * @param ev The event.
387
- */
388
- reset?: (ev: Event) => any;
389
- //resize?: (ev: UIEvent) => any; remove to avoid errors with sizechange event
390
-
391
- /**
392
- * Fires when the user repositions the scroll box in the scroll bar on the object.
393
- * @param ev The event.
394
- */
395
- scroll?: (ev: Event) => any;
396
- securitypolicyviolation?: (ev: SecurityPolicyViolationEvent) => any;
397
- /**
398
- * Occurs when the seek operation ends.
399
- * @param ev The event.
400
- */
401
- seeked?: (ev: Event) => any;
402
- /**
403
- * Occurs when the current playback position is moved.
404
- * @param ev The event.
405
- */
406
- seeking?: (ev: Event) => any;
407
- /**
408
- * Fires when the current selection changes.
409
- * @param ev The event.
410
- */
411
- select?: (ev: Event) => any;
412
- selectionchange?: (ev: Event) => any;
413
- selectstart?: (ev: Event) => any;
414
- /**
415
- * Occurs when the download has stopped.
416
- * @param ev The event.
417
- */
418
- stalled?: (ev: Event) => any;
419
- submit?: (ev: Event) => any;
420
-
421
- /**
422
- * Occurs if the load operation has been intentionally halted.
423
- * @param ev The event.
424
- */
425
- suspend?: (ev: Event) => any;
426
-
427
- /**
428
- * Occurs to indicate the current playback position.
429
- * @param ev The event.
430
- */
431
- timeupdate?: (ev: Event) => any;
432
- toggle?: (ev: Event) => any;
433
- touchcancel?: (ev: TouchEvent) => any;
434
- touchend?: (ev: TouchEvent) => any;
435
- touchmove?: (ev: TouchEvent) => any;
436
- touchstart?: (ev: TouchEvent) => any;
437
- transitioncancel?: (ev: TransitionEvent) => any;
438
- transitionend?: (ev: TransitionEvent) => any;
439
- transitionrun?: (ev: TransitionEvent) => any;
440
- transitionstart?: (ev: TransitionEvent) => any;
441
-
442
- /**
443
- * Occurs when the volume is changed, or playback is muted or unmuted.
444
- * @param ev The event.
445
- */
446
- volumechange?: (ev: Event) => any;
447
-
448
- /**
449
- * Occurs when playback stops because the next frame of a video resource is not available.
450
- * @param ev The event.
451
- */
452
- waiting?: (ev: Event) => any;
453
- wheel?: (ev: WheelEvent) => any;
454
-
455
- /**
456
- * custom x4 events
457
- */
458
-
459
- resized?: (ev: Event) => void; // occurs when size changed
460
- created?: ( ev: Event ) => void; // occurs when inserted in the dom
461
- removed?: ( ev: Event ) => void; // occurs when removed from dom
462
- }
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
471
-
1
+ /**
2
+ * ___ ___ __
3
+ * \ \/ / / _
4
+ * \ / /_| |_
5
+ * / \____ _|
6
+ * /__/\__\ |_|
7
+ *
8
+ * @file core_dom.ts
9
+ * @author Etienne Cochard
10
+ *
11
+ * @copyright (c) 2024 R-libre ingenierie
12
+ *
13
+ * Use of this source code is governed by an MIT-style license
14
+ * that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.
15
+ **/
16
+
17
+ /** @ignore this events must be defined on domNode (do not bubble) */
18
+ export const unbubbleEvents = {
19
+ mouseleave: 1, mouseenter: 1, load: 1, unload: 1, scroll: 1, focus: 1, blur: 1, rowexit: 1, beforeunload: 1, stop: 1,
20
+ dragdrop: 1, dragenter: 1, dragexit: 1, draggesture: 1, dragover: 1, contextmenu: 1, created: 2, removed: 2, sizechange: 2
21
+ };
22
+
23
+ export type DOMEventHandler = ( ev: Event ) => void;
24
+ type EventEntry = Record<string,DOMEventHandler | DOMEventHandler[]>;
25
+
26
+ const event_handlers = new WeakMap<Node,EventEntry>( );
27
+
28
+ /**
29
+ * handle dom mutations
30
+ */
31
+
32
+ let mutObserver: MutationObserver = null;
33
+
34
+ const observeMutation = (mutations: MutationRecord[], observer: MutationObserver): void => {
35
+
36
+ const sendEvent = ( node: Node, code: "created" | "removed" ) => {
37
+ // console.log( "notify", node, code );
38
+
39
+ const store = event_handlers.get( node );
40
+ if ( store && store[code] ) {
41
+ node.dispatchEvent( new Event( code, {} ) );
42
+ }
43
+ }
44
+
45
+ const notify = ( node: Node, create: boolean ) => {
46
+
47
+ if( create ) {
48
+ sendEvent( node, "created" );
49
+ }
50
+
51
+ for( let c=node.firstChild; c; c=c.nextSibling ) {
52
+ notify( c, create );
53
+ }
54
+
55
+ if( !create ) {
56
+ sendEvent( node, "removed" );
57
+ }
58
+ }
59
+
60
+
61
+ for (const mutation of mutations) {
62
+ if( mutation.type=="childList" ) {
63
+ if( mutation.addedNodes ) {
64
+ mutation.addedNodes.forEach( node => {
65
+ notify( node, true );
66
+ } );
67
+ }
68
+
69
+ if( mutation.removedNodes ) {
70
+ mutation.removedNodes.forEach( node => {
71
+ notify( node, false );
72
+ } );
73
+ }
74
+ }
75
+ }
76
+ }
77
+
78
+
79
+
80
+ /**
81
+ *
82
+ */
83
+
84
+ let sizeObserver: ResizeObserver = null;
85
+
86
+ function observeSize(entries: ResizeObserverEntry[]) {
87
+ entries.forEach((entry) => {
88
+ let dom = entry.target as HTMLElement;
89
+ if (dom.offsetParent !== null) {
90
+ dom.dispatchEvent( new Event('resized') );
91
+ }
92
+ });
93
+ }
94
+
95
+ /**
96
+ *
97
+ */
98
+
99
+ export function dispatchEvent(ev: Event) {
100
+
101
+ let target = ev.target as Node,
102
+ noup = (unbubbleEvents as any)[ev.type] === 2;
103
+
104
+ while (target) {
105
+ const store = event_handlers.get( target );
106
+ if ( store ) {
107
+ const callback = store[ev.type];
108
+ if( callback ) {
109
+ if( Array.isArray(callback) ) {
110
+ callback.some( c => c( ev ) );
111
+ }
112
+ else {
113
+ callback( ev );
114
+ }
115
+
116
+ if (ev.stopPropagation || ev.defaultPrevented || noup) {
117
+ break;
118
+ }
119
+ }
120
+ }
121
+
122
+ target = target.parentNode;
123
+
124
+ // no need to go above
125
+ if (target == document) {
126
+ break;
127
+ }
128
+ }
129
+ }
130
+
131
+ /**
132
+ *
133
+ */
134
+
135
+ export function addEvent( node: Node, name: string, handler: DOMEventHandler, prepend = false ) {
136
+
137
+ if( name=="removed" || name=="created" ) {
138
+ if( !mutObserver ) {
139
+ mutObserver = new MutationObserver( observeMutation )
140
+ mutObserver.observe( document.body, {childList: true,subtree: true} );
141
+ }
142
+ }
143
+ else if( name=="resized" ) {
144
+ if (!sizeObserver) {
145
+ sizeObserver = new ResizeObserver( observeSize );
146
+ }
147
+
148
+ sizeObserver.observe( node as Element );
149
+ }
150
+
151
+
152
+ let store = event_handlers.get( node );
153
+ if( !store ) {
154
+ store = {}
155
+ event_handlers.set( node, store );
156
+ }
157
+
158
+ if( !store[name] ) {
159
+ store[name] = handler;
160
+ node.addEventListener( name, dispatchEvent );
161
+ }
162
+ else {
163
+ const entry = store[name];
164
+ if( Array.isArray(entry) ) {
165
+ entry.push( handler );
166
+ }
167
+ else {
168
+ store[name] = [entry,handler];
169
+ }
170
+ }
171
+ }
172
+
173
+ /**
174
+ *
175
+ */
176
+
177
+ export interface GlobalDOMEvents {
178
+
179
+ /**
180
+ * Fires when the user aborts the download.
181
+ * @param ev The event.
182
+ */
183
+
184
+ abort?: (ev: UIEvent) => any;
185
+ animationcancel?: (ev: AnimationEvent) => any;
186
+ animationend?: (ev: AnimationEvent) => any;
187
+ animationiteration?: (ev: AnimationEvent) => any;
188
+ animationstart?: (ev: AnimationEvent) => any;
189
+ auxclick?: (ev: MouseEvent) => any;
190
+
191
+ /**
192
+ * Fires when the object loses the input focus.
193
+ * @param ev The focus event.
194
+ */
195
+ blur?: (ev: FocusEvent) => any;
196
+ cancel?: (ev: Event) => any;
197
+
198
+ /**
199
+ * Occurs when playback is possible, but would require further buffering.
200
+ * @param ev The event.
201
+ */
202
+ canplay?: (ev: Event) => any;
203
+ canplaythrough?: (ev: Event) => any;
204
+ /**
205
+ * Fires when the contents of the object or selection have changed.
206
+ * @param ev The event.
207
+ */
208
+ change?: (ev: Event) => any;
209
+ /**
210
+ * Fires when the user clicks the left mouse button on the object
211
+ * @param ev The mouse event.
212
+ */
213
+ click?: (ev: MouseEvent) => any;
214
+ close?: (ev: Event) => any;
215
+ /**
216
+ * Fires when the user clicks the right mouse button in the client area, opening the context menu.
217
+ * @param ev The mouse event.
218
+ */
219
+ contextmenu?: (ev: MouseEvent) => any;
220
+ cuechange?: (ev: Event) => any;
221
+ /**
222
+ * Fires when the user double-clicks the object.
223
+ * @param ev The mouse event.
224
+ */
225
+ dblclick?: (ev: MouseEvent) => any;
226
+ /**
227
+ * Fires on the source object continuously during a drag operation.
228
+ * @param ev The event.
229
+ */
230
+ drag?: (ev: DragEvent) => any;
231
+ /**
232
+ * Fires on the source object when the user releases the mouse at the close of a drag operation.
233
+ * @param ev The event.
234
+ */
235
+ dragend?: (ev: DragEvent) => any;
236
+ /**
237
+ * Fires on the target element when the user drags the object to a valid drop target.
238
+ * @param ev The drag event.
239
+ */
240
+ dragenter?: (ev: DragEvent) => any;
241
+ dragexit?: (ev: Event) => any;
242
+ /**
243
+ * Fires on the target object when the user moves the mouse out of a valid drop target during a drag operation.
244
+ * @param ev The drag event.
245
+ */
246
+ dragleave?: (ev: DragEvent) => any;
247
+ /**
248
+ * Fires on the target element continuously while the user drags the object over a valid drop target.
249
+ * @param ev The event.
250
+ */
251
+ dragover?: (ev: DragEvent) => any;
252
+ /**
253
+ * Fires on the source object when the user starts to drag a text selection or selected object.
254
+ * @param ev The event.
255
+ */
256
+ dragstart?: (ev: DragEvent) => any;
257
+ drop?: (ev: DragEvent) => any;
258
+ /**
259
+ * Occurs when the duration attribute is updated.
260
+ * @param ev The event.
261
+ */
262
+ durationchange?: (ev: Event) => any;
263
+ /**
264
+ * Occurs when the media element is reset to its initial state.
265
+ * @param ev The event.
266
+ */
267
+ emptied?: (ev: Event) => any;
268
+ /**
269
+ * Occurs when the end of playback is reached.
270
+ * @param ev The event
271
+ */
272
+ ended?: (ev: Event) => any;
273
+ /**
274
+ * Fires when an error occurs during object loading.
275
+ * @param ev The event.
276
+ */
277
+ error?: OnErrorEventHandler;
278
+ /**
279
+ * Fires when the object receives focus.
280
+ * @param ev The event.
281
+ */
282
+ focusin?: (ev: FocusEvent) => any;
283
+ focusout?: (ev: FocusEvent) => any;
284
+ focus?: (ev: FocusEvent) => any;
285
+ gotpointercapture?: (ev: PointerEvent) => any;
286
+ input?: (ev: Event) => any;
287
+ invalid?: (ev: Event) => any;
288
+ /**
289
+ * Fires when the user presses a key.
290
+ * @param ev The keyboard event
291
+ */
292
+ keydown?: (ev: KeyboardEvent) => any;
293
+ /**
294
+ * Fires when the user presses an alphanumeric key.
295
+ * @param ev The event.
296
+ */
297
+ keypress?: (ev: KeyboardEvent) => any;
298
+ /**
299
+ * Fires when the user releases a key.
300
+ * @param ev The keyboard event
301
+ */
302
+ keyup?: (ev: KeyboardEvent) => any;
303
+ /**
304
+ * Fires immediately after the browser loads the object.
305
+ * @param ev The event.
306
+ */
307
+ load?: (ev: Event) => any;
308
+ /**
309
+ * Occurs when media data is loaded at the current playback position.
310
+ * @param ev The event.
311
+ */
312
+ loadeddata?: (ev: Event) => any;
313
+ /**
314
+ * Occurs when the duration and dimensions of the media have been determined.
315
+ * @param ev The event.
316
+ */
317
+ loadedmetadata?: (ev: Event) => any;
318
+ /**
319
+ * Occurs when Internet Explorer begins looking for media data.
320
+ * @param ev The event.
321
+ */
322
+ loadstart?: (ev: Event) => any;
323
+ lostpointercapture?: (ev: PointerEvent) => any;
324
+ /**
325
+ * Fires when the user clicks the object with either mouse button.
326
+ * @param ev The mouse event.
327
+ */
328
+ mousedown?: (ev: MouseEvent) => any;
329
+ mouseenter?: (ev: MouseEvent) => any;
330
+ mouseleave?: (ev: MouseEvent) => any;
331
+ /**
332
+ * Fires when the user moves the mouse over the object.
333
+ * @param ev The mouse event.
334
+ */
335
+ mousemove?: (ev: MouseEvent) => any;
336
+ /**
337
+ * Fires when the user moves the mouse pointer outside the boundaries of the object.
338
+ * @param ev The mouse event.
339
+ */
340
+ mouseout?: (ev: MouseEvent) => any;
341
+ /**
342
+ * Fires when the user moves the mouse pointer into the object.
343
+ * @param ev The mouse event.
344
+ */
345
+ mouseover?: (ev: MouseEvent) => any;
346
+ /**
347
+ * Fires when the user releases a mouse button while the mouse is over the object.
348
+ * @param ev The mouse event.
349
+ */
350
+ mouseup?: (ev: MouseEvent) => any;
351
+ /**
352
+ * Occurs when playback is paused.
353
+ * @param ev The event.
354
+ */
355
+ pause?: (ev: Event) => any;
356
+ /**
357
+ * Occurs when the play method is requested.
358
+ * @param ev The event.
359
+ */
360
+ play?: (ev: Event) => any;
361
+ /**
362
+ * Occurs when the audio or video has started playing.
363
+ * @param ev The event.
364
+ */
365
+ playing?: (ev: Event) => any;
366
+ pointercancel?: (ev: PointerEvent) => any;
367
+ pointerdown?: (ev: PointerEvent) => any;
368
+ pointerenter?: (ev: PointerEvent) => any;
369
+ pointerleave?: (ev: PointerEvent) => any;
370
+ pointermove?: (ev: PointerEvent) => any;
371
+ pointerout?: (ev: PointerEvent) => any;
372
+ pointerover?: (ev: PointerEvent) => any;
373
+ pointerup?: (ev: PointerEvent) => any;
374
+ /**
375
+ * Occurs to indicate progress while downloading media data.
376
+ * @param ev The event.
377
+ */
378
+ progress?: (ev: ProgressEvent) => any;
379
+ /**
380
+ * Occurs when the playback rate is increased or decreased.
381
+ * @param ev The event.
382
+ */
383
+ ratechange?: (ev: Event) => any;
384
+ /**
385
+ * Fires when the user resets a form.
386
+ * @param ev The event.
387
+ */
388
+ reset?: (ev: Event) => any;
389
+ //resize?: (ev: UIEvent) => any; remove to avoid errors with sizechange event
390
+
391
+ /**
392
+ * Fires when the user repositions the scroll box in the scroll bar on the object.
393
+ * @param ev The event.
394
+ */
395
+ scroll?: (ev: Event) => any;
396
+ securitypolicyviolation?: (ev: SecurityPolicyViolationEvent) => any;
397
+ /**
398
+ * Occurs when the seek operation ends.
399
+ * @param ev The event.
400
+ */
401
+ seeked?: (ev: Event) => any;
402
+ /**
403
+ * Occurs when the current playback position is moved.
404
+ * @param ev The event.
405
+ */
406
+ seeking?: (ev: Event) => any;
407
+ /**
408
+ * Fires when the current selection changes.
409
+ * @param ev The event.
410
+ */
411
+ select?: (ev: Event) => any;
412
+ selectionchange?: (ev: Event) => any;
413
+ selectstart?: (ev: Event) => any;
414
+ /**
415
+ * Occurs when the download has stopped.
416
+ * @param ev The event.
417
+ */
418
+ stalled?: (ev: Event) => any;
419
+ submit?: (ev: Event) => any;
420
+
421
+ /**
422
+ * Occurs if the load operation has been intentionally halted.
423
+ * @param ev The event.
424
+ */
425
+ suspend?: (ev: Event) => any;
426
+
427
+ /**
428
+ * Occurs to indicate the current playback position.
429
+ * @param ev The event.
430
+ */
431
+ timeupdate?: (ev: Event) => any;
432
+ toggle?: (ev: Event) => any;
433
+ touchcancel?: (ev: TouchEvent) => any;
434
+ touchend?: (ev: TouchEvent) => any;
435
+ touchmove?: (ev: TouchEvent) => any;
436
+ touchstart?: (ev: TouchEvent) => any;
437
+ transitioncancel?: (ev: TransitionEvent) => any;
438
+ transitionend?: (ev: TransitionEvent) => any;
439
+ transitionrun?: (ev: TransitionEvent) => any;
440
+ transitionstart?: (ev: TransitionEvent) => any;
441
+
442
+ /**
443
+ * Occurs when the volume is changed, or playback is muted or unmuted.
444
+ * @param ev The event.
445
+ */
446
+ volumechange?: (ev: Event) => any;
447
+
448
+ /**
449
+ * Occurs when playback stops because the next frame of a video resource is not available.
450
+ * @param ev The event.
451
+ */
452
+ waiting?: (ev: Event) => any;
453
+ wheel?: (ev: WheelEvent) => any;
454
+
455
+ /**
456
+ * custom x4 events
457
+ */
458
+
459
+ resized?: (ev: Event) => void; // occurs when size changed
460
+ created?: ( ev: Event ) => void; // occurs when inserted in the dom
461
+ removed?: ( ev: Event ) => void; // occurs when removed from dom
462
+ }
463
+
464
+
465
+
466
+
467
+
468
+
469
+
470
+
471
+