neo.mjs 5.16.2 → 5.16.4
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.
- package/apps/ServiceWorker.mjs +2 -2
- package/docs/app/view/MainContainer.mjs +4 -0
- package/docs/app/view/MainContainerController.mjs +7 -0
- package/docs/neo-config.json +1 -1
- package/examples/ServiceWorker.mjs +2 -2
- package/package.json +1 -1
- package/resources/scss/src/form/field/Switch.scss +21 -51
- package/src/DefaultConfig.mjs +2 -2
- package/src/main/DomEvents.mjs +19 -14
- package/src/main/addon/ResizeObserver.mjs +46 -9
- package/src/manager/DomEvent.mjs +35 -21
package/apps/ServiceWorker.mjs
CHANGED
@@ -143,6 +143,13 @@ class MainContainerController extends Component {
|
|
143
143
|
me.getReference('tutorials-treelist').filter('name', value, null);
|
144
144
|
}
|
145
145
|
|
146
|
+
/**
|
147
|
+
* @param {Object} data
|
148
|
+
*/
|
149
|
+
onNavTabContainerResize(data) {
|
150
|
+
console.log('onNavTabContainerResize', data)
|
151
|
+
}
|
152
|
+
|
146
153
|
/**
|
147
154
|
*
|
148
155
|
*/
|
package/docs/neo-config.json
CHANGED
package/package.json
CHANGED
@@ -1,14 +1,8 @@
|
|
1
1
|
.neo-switchfield {
|
2
|
-
@keyframes switch-
|
3
|
-
0% {
|
4
|
-
25% {
|
5
|
-
100% {
|
6
|
-
}
|
7
|
-
|
8
|
-
@keyframes switch-off-position {
|
9
|
-
0% {left: 50%; right: 0}
|
10
|
-
25% {left: 37.5%; right: 0}
|
11
|
-
100% {left: 0; right: 50%}
|
2
|
+
@keyframes switch-off-transform {
|
3
|
+
0% {transform: translate(100%) scaleX(1)}
|
4
|
+
25% {transform: translate(100%) scaleX(1.33)}
|
5
|
+
100% {transform: translate(0) scaleX(1)}
|
12
6
|
}
|
13
7
|
|
14
8
|
@keyframes switch-on-transform {
|
@@ -17,12 +11,6 @@
|
|
17
11
|
100% {transform: translate(100%) scaleX(1)}
|
18
12
|
}
|
19
13
|
|
20
|
-
@keyframes switch-off-transform {
|
21
|
-
0% {transform: translate(100%) scaleX(1)}
|
22
|
-
25% {transform: translate(100%) scaleX(1.33)}
|
23
|
-
100% {transform: translate(0) scaleX(1)}
|
24
|
-
}
|
25
|
-
|
26
14
|
.neo-switchfield-input {
|
27
15
|
background-clip : padding-box;
|
28
16
|
background-color: v(switchfield-background-color);
|
@@ -40,8 +28,21 @@
|
|
40
28
|
-webkit-appearance : none;
|
41
29
|
-webkit-tap-highlight-color: transparent;
|
42
30
|
|
31
|
+
&::after {
|
32
|
+
content : "\f00c\f00d";
|
33
|
+
font-family : "Font Awesome 6 Free";
|
34
|
+
font-size : 1.25rem;
|
35
|
+
font-weight : 900;
|
36
|
+
left : 0.5em;
|
37
|
+
letter-spacing: 1em;
|
38
|
+
line-height : 1.5;
|
39
|
+
position : absolute;
|
40
|
+
top : 0.15em;
|
41
|
+
z-index : 1;
|
42
|
+
}
|
43
43
|
|
44
44
|
&::before {
|
45
|
+
animation : switch-off-transform 0.25s ease-out forwards;
|
45
46
|
background-clip : padding-box;
|
46
47
|
background-color: v(switchfield-thumb-color);
|
47
48
|
border : 0.125em solid transparent;
|
@@ -56,50 +57,19 @@
|
|
56
57
|
z-index : 2;
|
57
58
|
}
|
58
59
|
|
59
|
-
&::after {
|
60
|
-
content : "\f00c\f00d";
|
61
|
-
font-family : "Font Awesome 6 Free";
|
62
|
-
font-size : 1.25rem;
|
63
|
-
font-weight : 900;
|
64
|
-
left : 0.5em;
|
65
|
-
letter-spacing: 1em;
|
66
|
-
line-height : 1.5;
|
67
|
-
position : absolute;
|
68
|
-
top : 0.15em;
|
69
|
-
z-index : 1;
|
70
|
-
}
|
71
|
-
|
72
|
-
&:focus {
|
73
|
-
background-color: v(switchfield-background-color);
|
74
|
-
border-color : transparent;
|
75
|
-
color : v(switchfield-active-color);
|
76
|
-
outline : none;
|
77
|
-
}
|
78
|
-
|
79
60
|
&:checked {
|
80
61
|
background-color: v(switchfield-checked);
|
81
|
-
border-color : transparent;
|
82
62
|
color : v(switchfield-inactive-color);
|
83
63
|
|
84
64
|
&::before {
|
65
|
+
animation : switch-on-transform 0.25s ease-out forwards;
|
85
66
|
transform-origin: left center;
|
86
67
|
}
|
87
68
|
}
|
88
69
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
&:checked::before {
|
94
|
-
animation: switch-on-position 0.25s ease-out forwards;
|
95
|
-
}
|
96
|
-
|
97
|
-
&::before {
|
98
|
-
animation: switch-off-transform 0.25s ease-out forwards;
|
99
|
-
}
|
100
|
-
|
101
|
-
&:checked::before {
|
102
|
-
animation: switch-on-transform 0.25s ease-out forwards;
|
70
|
+
&:focus {
|
71
|
+
color : v(switchfield-active-color);
|
72
|
+
outline: none;
|
103
73
|
}
|
104
74
|
}
|
105
75
|
}
|
package/src/DefaultConfig.mjs
CHANGED
@@ -245,12 +245,12 @@ const DefaultConfig = {
|
|
245
245
|
useVdomWorker: true,
|
246
246
|
/**
|
247
247
|
* buildScripts/injectPackageVersion.mjs will update this value
|
248
|
-
* @default '5.16.
|
248
|
+
* @default '5.16.4'
|
249
249
|
* @memberOf! module:Neo
|
250
250
|
* @name config.version
|
251
251
|
* @type String
|
252
252
|
*/
|
253
|
-
version: '5.16.
|
253
|
+
version: '5.16.4'
|
254
254
|
};
|
255
255
|
|
256
256
|
Object.assign(DefaultConfig, {
|
package/src/main/DomEvents.mjs
CHANGED
@@ -337,20 +337,7 @@ class DomEvents extends Base {
|
|
337
337
|
*/
|
338
338
|
getTargetData(node) {
|
339
339
|
let r = node.getBoundingClientRect?.(),
|
340
|
-
rect = {};
|
341
|
-
|
342
|
-
if (r) {
|
343
|
-
Object.assign(rect, {
|
344
|
-
bottom: r.bottom,
|
345
|
-
height: r.height,
|
346
|
-
left : r.left,
|
347
|
-
right : r.right,
|
348
|
-
top : r.top,
|
349
|
-
width : r.width,
|
350
|
-
x : r.x,
|
351
|
-
y : r.y
|
352
|
-
})
|
353
|
-
}
|
340
|
+
rect = r && this.parseDomRect(r) || {};
|
354
341
|
|
355
342
|
return {
|
356
343
|
checked : node.checked,
|
@@ -633,6 +620,24 @@ class DomEvents extends Base {
|
|
633
620
|
}
|
634
621
|
}
|
635
622
|
|
623
|
+
/**
|
624
|
+
* DOMRects are not spreadable => {...DOMRect} => {}
|
625
|
+
* @param {DOMRect} rect
|
626
|
+
* @returns {Object}
|
627
|
+
*/
|
628
|
+
parseDomRect(rect) {
|
629
|
+
return {
|
630
|
+
bottom: rect.bottom,
|
631
|
+
height: rect.height,
|
632
|
+
left : rect.left,
|
633
|
+
right : rect.right,
|
634
|
+
top : rect.top,
|
635
|
+
width : rect.width,
|
636
|
+
x : rect.x,
|
637
|
+
y : rect.y
|
638
|
+
}
|
639
|
+
}
|
640
|
+
|
636
641
|
/**
|
637
642
|
* Example for Array values: "categories[]=test1&categories[]=test2"
|
638
643
|
* @param {String} str
|
@@ -1,12 +1,13 @@
|
|
1
1
|
import Base from '../../core/Base.mjs';
|
2
|
-
import DomAccess from '../DomAccess.mjs'
|
2
|
+
import DomAccess from '../DomAccess.mjs';
|
3
|
+
import DomEvents from '../DomEvents.mjs';
|
3
4
|
|
4
5
|
/**
|
5
6
|
* @class Neo.main.addon.ResizeObserver
|
6
7
|
* @extends Neo.core.Base
|
7
8
|
* @singleton
|
8
9
|
*/
|
9
|
-
class
|
10
|
+
class NeoResizeObserver extends Base {
|
10
11
|
static config = {
|
11
12
|
/**
|
12
13
|
* @member {String} className='Neo.main.addon.ResizeObserver'
|
@@ -14,7 +15,7 @@ class ResizeObserver extends Base {
|
|
14
15
|
*/
|
15
16
|
className: 'Neo.main.addon.ResizeObserver',
|
16
17
|
/**
|
17
|
-
* @member {
|
18
|
+
* @member {ResizeObserver|null} instance=null
|
18
19
|
* @protected
|
19
20
|
*/
|
20
21
|
instance: null,
|
@@ -40,19 +41,57 @@ class ResizeObserver extends Base {
|
|
40
41
|
* @param {Object} config
|
41
42
|
*/
|
42
43
|
construct(config) {
|
44
|
+
super.construct(config);
|
45
|
+
|
43
46
|
let me = this;
|
44
47
|
|
45
|
-
me.
|
48
|
+
me.instance = new ResizeObserver(me.onResize.bind(me))
|
46
49
|
}
|
47
50
|
|
48
51
|
/**
|
49
|
-
* Internal callback for the ResizeObserver instance
|
52
|
+
* Internal callback for the ResizeObserver instance.
|
53
|
+
* See: https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry
|
50
54
|
* @param {HTMLElement[]} entries
|
51
55
|
* @param {ResizeObserver} observer
|
52
56
|
* @protected
|
53
57
|
*/
|
54
58
|
onResize(entries, observer) {
|
55
|
-
|
59
|
+
entries.forEach(entry => {
|
60
|
+
// the content of entry is not spreadable, so we need to manually convert it
|
61
|
+
// structuredClone(entry) throws a JS error => ResizeObserverEntry object could not be cloned.
|
62
|
+
|
63
|
+
let borderBoxSize = entry.borderBoxSize[0],
|
64
|
+
contentBoxSize = entry.contentBoxSize[0],
|
65
|
+
devicePixelContentBoxSize = entry.devicePixelContentBoxSize?.[0] || {}, // Not supported in Safari yet
|
66
|
+
path = DomEvents.getPathFromElement(entry.target).map(e => DomEvents.getTargetData(e));
|
67
|
+
|
68
|
+
Neo.worker.Manager.sendMessage('app', {
|
69
|
+
action : 'domEvent',
|
70
|
+
eventName: 'resize',
|
71
|
+
|
72
|
+
data: {
|
73
|
+
contentRect: DomEvents.parseDomRect(entry.contentRect),
|
74
|
+
id : entry.target.id,
|
75
|
+
path,
|
76
|
+
rect : path[0].rect,
|
77
|
+
|
78
|
+
borderBoxSize: {
|
79
|
+
blockSize : borderBoxSize.blockSize,
|
80
|
+
inlineSize: borderBoxSize.inlineSize
|
81
|
+
},
|
82
|
+
|
83
|
+
contentBoxSize: {
|
84
|
+
blockSize : contentBoxSize.blockSize,
|
85
|
+
inlineSize: contentBoxSize.inlineSize
|
86
|
+
},
|
87
|
+
|
88
|
+
devicePixelContentBoxSize: {
|
89
|
+
blockSize : devicePixelContentBoxSize.blockSize,
|
90
|
+
inlineSize: devicePixelContentBoxSize.inlineSize
|
91
|
+
}
|
92
|
+
}
|
93
|
+
})
|
94
|
+
})
|
56
95
|
}
|
57
96
|
|
58
97
|
/**
|
@@ -72,8 +111,6 @@ class ResizeObserver extends Base {
|
|
72
111
|
}
|
73
112
|
}
|
74
113
|
|
75
|
-
Neo.applyClassConfig(
|
76
|
-
|
77
|
-
let instance = Neo.applyClassConfig(ResizeObserver);
|
114
|
+
let instance = Neo.applyClassConfig(NeoResizeObserver);
|
78
115
|
|
79
116
|
export default instance;
|
package/src/manager/DomEvent.mjs
CHANGED
@@ -63,6 +63,22 @@ class DomEvent extends Base {
|
|
63
63
|
singleton: true
|
64
64
|
}
|
65
65
|
|
66
|
+
/**
|
67
|
+
*
|
68
|
+
* @param {Neo.component.Base} component
|
69
|
+
* @param {data} event
|
70
|
+
*/
|
71
|
+
addResizeObserver(component, event) {
|
72
|
+
if (!Neo.main.addon.ResizeObserver) {
|
73
|
+
console.error('For using resize domListeners, you must include main.addon.ResizeObserver.', event)
|
74
|
+
}
|
75
|
+
|
76
|
+
Neo.main.addon.ResizeObserver.register({
|
77
|
+
appName: component.appName,
|
78
|
+
id : component.id
|
79
|
+
})
|
80
|
+
}
|
81
|
+
|
66
82
|
/**
|
67
83
|
* @param {Object} event
|
68
84
|
* @protected
|
@@ -216,16 +232,16 @@ class DomEvent extends Base {
|
|
216
232
|
value.forEach(event => {
|
217
233
|
eventName = event.eventName;
|
218
234
|
|
219
|
-
if (eventName
|
220
|
-
|
221
|
-
|
235
|
+
if (eventName === 'resize') {
|
236
|
+
this.addResizeObserver(component, event)
|
237
|
+
} else if (eventName && (event.local || !globalDomEvents.includes(eventName))) {
|
222
238
|
localEvents.push({
|
223
239
|
name : eventName,
|
224
240
|
handler: 'domEventListener',
|
225
241
|
vnodeId: event.vnodeId
|
226
|
-
})
|
242
|
+
})
|
227
243
|
}
|
228
|
-
})
|
244
|
+
})
|
229
245
|
});
|
230
246
|
|
231
247
|
if (localEvents.length > 0) {
|
@@ -236,8 +252,8 @@ class DomEvent extends Base {
|
|
236
252
|
}).then(data => {
|
237
253
|
// console.log('added domListener', data);
|
238
254
|
}).catch(err => {
|
239
|
-
console.log('App: Got error attempting to add a domListener', err)
|
240
|
-
})
|
255
|
+
console.log('App: Got error attempting to add a domListener', err)
|
256
|
+
})
|
241
257
|
}
|
242
258
|
}
|
243
259
|
}
|
@@ -288,13 +304,13 @@ class DomEvent extends Base {
|
|
288
304
|
) {
|
289
305
|
alreadyRegistered = true;
|
290
306
|
}
|
291
|
-
})
|
307
|
+
})
|
292
308
|
} else {
|
293
309
|
listeners[id][eventName] = [];
|
294
310
|
}
|
295
311
|
|
296
312
|
if (alreadyRegistered === true) {
|
297
|
-
return false
|
313
|
+
return false
|
298
314
|
}
|
299
315
|
|
300
316
|
// console.log('manager.DomEvent register', eventName, config);
|
@@ -323,9 +339,7 @@ class DomEvent extends Base {
|
|
323
339
|
|
324
340
|
listeners[id][eventName].sort((a, b) => a.priority > b.priority);
|
325
341
|
|
326
|
-
|
327
|
-
|
328
|
-
return true;
|
342
|
+
return true
|
329
343
|
}
|
330
344
|
|
331
345
|
/**
|
@@ -377,7 +391,7 @@ class DomEvent extends Base {
|
|
377
391
|
}
|
378
392
|
}
|
379
393
|
}
|
380
|
-
})
|
394
|
+
})
|
381
395
|
}
|
382
396
|
|
383
397
|
// add new listeners
|
@@ -393,14 +407,14 @@ class DomEvent extends Base {
|
|
393
407
|
ownerId : component.id,
|
394
408
|
scope : domListener.scope || component,
|
395
409
|
vnodeId : domListener.vnodeId || value.vnodeId || component.id
|
396
|
-
})
|
410
|
+
})
|
397
411
|
}
|
398
|
-
})
|
412
|
+
})
|
399
413
|
});
|
400
414
|
|
401
415
|
if (component.mounted) {
|
402
416
|
setTimeout(() => {
|
403
|
-
me.mountDomListeners(component)
|
417
|
+
me.mountDomListeners(component)
|
404
418
|
}, 100)
|
405
419
|
}
|
406
420
|
} else {
|
@@ -436,12 +450,12 @@ class DomEvent extends Base {
|
|
436
450
|
) {
|
437
451
|
hasMatch = true;
|
438
452
|
targetId = path[j].id;
|
439
|
-
break
|
453
|
+
break
|
440
454
|
}
|
441
455
|
}
|
442
456
|
|
443
457
|
if (!hasMatch) {
|
444
|
-
return false
|
458
|
+
return false
|
445
459
|
}
|
446
460
|
}
|
447
461
|
|
@@ -452,7 +466,7 @@ class DomEvent extends Base {
|
|
452
466
|
}
|
453
467
|
}
|
454
468
|
|
455
|
-
return false
|
469
|
+
return false
|
456
470
|
}
|
457
471
|
|
458
472
|
/**
|
@@ -472,11 +486,11 @@ class DomEvent extends Base {
|
|
472
486
|
// delegationVdom can be undefined when dragging a proxy over the node.
|
473
487
|
// see issues/1137 for details.
|
474
488
|
if (!delegationVdom || delegationVdom.vdom && VDomUtil.findVdomChild(delegationVdom.vdom, targetId)) {
|
475
|
-
return false
|
489
|
+
return false
|
476
490
|
}
|
477
491
|
}
|
478
492
|
|
479
|
-
return true
|
493
|
+
return true
|
480
494
|
}
|
481
495
|
}
|
482
496
|
|