@lemonadejs/modal 3.2.0 → 5.0.0
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/dist/index.js +43 -26
- package/dist/style.css +10 -10
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -180,8 +180,10 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
|
|
183
|
-
document
|
|
184
|
-
|
|
183
|
+
if (typeof(document) !== "undefined") {
|
|
184
|
+
document.addEventListener('mouseup', mouseUp);
|
|
185
|
+
document.addEventListener('mousemove', mouseMove);
|
|
186
|
+
}
|
|
185
187
|
|
|
186
188
|
const isTrue = function(e) {
|
|
187
189
|
return e === true || e === 1 || e === 'true';
|
|
@@ -435,18 +437,6 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
435
437
|
|
|
436
438
|
// Native lemonade
|
|
437
439
|
self.onload = function() {
|
|
438
|
-
if (self.url) {
|
|
439
|
-
fetch(self.url)
|
|
440
|
-
.then(response => response.clone().body)
|
|
441
|
-
.then(body => {
|
|
442
|
-
let reader = body.getReader();
|
|
443
|
-
reader.read().then(function pump({done, value}) {
|
|
444
|
-
const decoder = new TextDecoder();
|
|
445
|
-
template += decoder.decode(value.buffer);
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
}
|
|
449
|
-
|
|
450
440
|
// Dimensions
|
|
451
441
|
if (self.width) {
|
|
452
442
|
self.el.style.width = self.width + 'px';
|
|
@@ -506,25 +496,31 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
506
496
|
}
|
|
507
497
|
}
|
|
508
498
|
|
|
509
|
-
// Bring to front on focus
|
|
510
|
-
if (self.layers !== false) {
|
|
511
|
-
self.el.classList.add('lm-modal-layers');
|
|
512
|
-
}
|
|
513
|
-
|
|
514
499
|
// Import content from DOM
|
|
515
500
|
if (self.content) {
|
|
516
|
-
|
|
501
|
+
if (typeof(self.content) === 'string') {
|
|
502
|
+
self.root.appendChild(document.createTextNode(self.content));
|
|
503
|
+
} else if (typeof(self.content.tagName) === 'object' && self.content.tagName) {
|
|
504
|
+
self.root.appendChild(self.content);
|
|
505
|
+
}
|
|
517
506
|
}
|
|
518
507
|
|
|
519
508
|
// Focus out of the component
|
|
520
509
|
self.el.addEventListener('focusout', function(e) {
|
|
521
|
-
if (
|
|
522
|
-
if (
|
|
510
|
+
if (! self.el.contains(e.relatedTarget)) {
|
|
511
|
+
if (isTrue(self['auto-close'])) {
|
|
523
512
|
self.closed = true;
|
|
524
513
|
}
|
|
514
|
+
// Remove focus
|
|
515
|
+
self.el.classList.remove('lm-modal-focus');
|
|
525
516
|
}
|
|
526
517
|
});
|
|
527
518
|
|
|
519
|
+
// Focus out of the component
|
|
520
|
+
self.el.addEventListener('focusin', function(e) {
|
|
521
|
+
self.el.classList.add('lm-modal-focus');
|
|
522
|
+
});
|
|
523
|
+
|
|
528
524
|
// Close and stop propagation
|
|
529
525
|
self.el.addEventListener('keydown', (e) => {
|
|
530
526
|
if (e.key === 'Escape') {
|
|
@@ -749,6 +745,8 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
749
745
|
if (self.closed === true) {
|
|
750
746
|
self.closed = false;
|
|
751
747
|
}
|
|
748
|
+
// Focus on the new modal
|
|
749
|
+
self.el.focus();
|
|
752
750
|
}
|
|
753
751
|
|
|
754
752
|
self.close = function() {
|
|
@@ -757,22 +755,41 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
757
755
|
}
|
|
758
756
|
}
|
|
759
757
|
|
|
760
|
-
if (
|
|
758
|
+
if (self.url) {
|
|
759
|
+
fetch(self.url)
|
|
760
|
+
.then(response => response.clone().body)
|
|
761
|
+
.then(body => {
|
|
762
|
+
let reader = body.getReader();
|
|
763
|
+
reader.read().then(function pump({done, value}) {
|
|
764
|
+
const decoder = new TextDecoder();
|
|
765
|
+
self.root.innerHTML = decoder.decode(value.buffer);
|
|
766
|
+
});
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
if (! template || typeof(template) !== 'string') {
|
|
761
771
|
template = '';
|
|
762
772
|
}
|
|
763
773
|
|
|
774
|
+
// Custom Root Configuration
|
|
775
|
+
self.settings = {
|
|
776
|
+
getRoot: function() {
|
|
777
|
+
return self.root;
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
|
|
764
781
|
return `<div class="lm-modal" animation="{{self.animation}}" position="{{self.position}}" closed="{{self.closed}}" closable="{{self.closable}}" minimizable="{{self.minimizable}}" minimized="{{self.minimized}}" overflow="{{self.overflow}}" :top="self.top" :left="self.left" :width="self.width" :height="self.height" onmousedown="self.mousedown" onmousemove="self.mousemove" onclick="self.click" tabindex="-1" role="modal">
|
|
765
782
|
<div class="lm-modal-title" data-title="{{self.title}}" data-icon="{{self.icon}}"><div class="lm-modal-icon">{{self.icon}}</div><div>{{self.title}}</div><div class="lm-modal-icon lm-modal-minimize" tabindex="0"></div><div class="lm-modal-icon lm-modal-close" tabindex="0"></div></div>
|
|
766
|
-
<div>${template}</div>
|
|
783
|
+
<div :ref="self.root">${template}</div>
|
|
767
784
|
</div>`
|
|
768
785
|
}
|
|
769
786
|
|
|
770
|
-
const Component = function (root, options
|
|
787
|
+
const Component = function (root, options) {
|
|
771
788
|
if (typeof(root) === 'object') {
|
|
772
789
|
// Remove elements from the DOM
|
|
773
790
|
let elements = removeElements(root);
|
|
774
791
|
// Create the modal
|
|
775
|
-
let e = lemonade.render(Modal, root, options
|
|
792
|
+
let e = lemonade.render(Modal, root, options);
|
|
776
793
|
// Add elements to the container
|
|
777
794
|
appendElements(e.children[1], elements);
|
|
778
795
|
|
package/dist/style.css
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
.lm-modal {
|
|
2
2
|
position: fixed;
|
|
3
|
-
min-width:
|
|
4
|
-
min-height:
|
|
3
|
+
min-width: 200px;
|
|
4
|
+
min-height: 200px;
|
|
5
5
|
border-radius: 5px;
|
|
6
6
|
z-index: 15;
|
|
7
7
|
background-color: var(--lm-background-color, #fff);
|
|
@@ -28,15 +28,19 @@
|
|
|
28
28
|
.lm-modal-title {
|
|
29
29
|
width: 100%;
|
|
30
30
|
border-bottom: 1px solid var(--lm-border-color, #ccc);
|
|
31
|
-
padding:
|
|
31
|
+
padding: 12px;
|
|
32
32
|
box-sizing: border-box;
|
|
33
|
-
font-size: 1.
|
|
33
|
+
font-size: 1.3em;
|
|
34
34
|
line-height: 24px;
|
|
35
35
|
user-select: none;
|
|
36
36
|
display: flex;
|
|
37
37
|
border-radius: 5px 5px 0 0;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
+
.lm-modal-focus {
|
|
41
|
+
z-index: 999;
|
|
42
|
+
}
|
|
43
|
+
|
|
40
44
|
.lm-modal > .lm-modal-title {
|
|
41
45
|
display: none;
|
|
42
46
|
}
|
|
@@ -57,9 +61,9 @@
|
|
|
57
61
|
height: 24px;
|
|
58
62
|
font-size: 24px;
|
|
59
63
|
cursor: pointer;
|
|
60
|
-
font-family: "Material Icons";
|
|
64
|
+
font-family: "Material Symbols Outlined", "Material Icons";
|
|
61
65
|
text-align: center;
|
|
62
|
-
margin-right:
|
|
66
|
+
margin-right: 8px;
|
|
63
67
|
display: none;
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -92,10 +96,6 @@
|
|
|
92
96
|
opacity: 0;
|
|
93
97
|
}
|
|
94
98
|
|
|
95
|
-
.lm-modal-layers:focus {
|
|
96
|
-
z-index: 999;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
99
|
.lm-modal[animation="false"] {
|
|
100
100
|
transition: initial;
|
|
101
101
|
}
|