@lemonadejs/modal 2.1.1 → 2.2.1
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.d.ts +15 -0
- package/dist/index.js +41 -24
- package/dist/style.css +11 -9
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -10,21 +10,36 @@ interface Modal {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
interface options {
|
|
13
|
+
/** Close the modal when it loses the focus */
|
|
14
|
+
autoclose?: boolean;
|
|
15
|
+
/** Modal is closed */
|
|
13
16
|
closed?: boolean;
|
|
17
|
+
/** Modal can be closed */
|
|
14
18
|
closable?: boolean;
|
|
19
|
+
/** Modal is minimized */
|
|
15
20
|
minimized?: boolean;
|
|
21
|
+
/** Modal can be minimized */
|
|
16
22
|
minimizable?: boolean;
|
|
23
|
+
/** Modal can be resized */
|
|
17
24
|
resizable?: boolean;
|
|
25
|
+
/** Modal can be moved from its original position */
|
|
18
26
|
draggable?: boolean;
|
|
27
|
+
/** Modal is automatic align center */
|
|
19
28
|
center?: boolean;
|
|
29
|
+
/** Title of the modal */
|
|
20
30
|
title?: string;
|
|
31
|
+
/** Width of the modal */
|
|
21
32
|
width?: number;
|
|
33
|
+
/** Height of the modal */
|
|
22
34
|
height?: number;
|
|
35
|
+
/** Position top */
|
|
23
36
|
top?: number;
|
|
37
|
+
/** Position Left */
|
|
24
38
|
left?: number;
|
|
25
39
|
}
|
|
26
40
|
|
|
27
41
|
interface instance {
|
|
42
|
+
autoclose: boolean;
|
|
28
43
|
closed: boolean;
|
|
29
44
|
closable: boolean;
|
|
30
45
|
minimized: boolean;
|
package/dist/index.js
CHANGED
|
@@ -49,6 +49,11 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
49
49
|
if (typeof(controls.action) === 'function') {
|
|
50
50
|
controls.action();
|
|
51
51
|
}
|
|
52
|
+
// Remove cursor
|
|
53
|
+
if (controls.e) {
|
|
54
|
+
controls.e.style.cursor = '';
|
|
55
|
+
controls.e.classList.remove('moving');
|
|
56
|
+
}
|
|
52
57
|
// Reset controls
|
|
53
58
|
controls = {};
|
|
54
59
|
// Reset state controls
|
|
@@ -82,8 +87,6 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
82
87
|
controls.left = left
|
|
83
88
|
controls.e.style.top = top + 'px';
|
|
84
89
|
controls.e.style.left = left + 'px';
|
|
85
|
-
controls.e.style.cursor = "move";
|
|
86
|
-
|
|
87
90
|
|
|
88
91
|
state.x = x;
|
|
89
92
|
state.y = y;
|
|
@@ -158,6 +161,15 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
158
161
|
self.el.classList.add('fullscreen');
|
|
159
162
|
}
|
|
160
163
|
|
|
164
|
+
// Focus out of the component
|
|
165
|
+
self.el.addEventListener('focusout', function(e) {
|
|
166
|
+
if (self.autoclose === true) {
|
|
167
|
+
if (!self.el.contains(e.relatedTarget)) {
|
|
168
|
+
self.closed = true;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
|
|
161
173
|
// Close and stop propagation
|
|
162
174
|
document.addEventListener('keydown', (e) => {
|
|
163
175
|
if (e.key === 'Escape' && self.closed === false) {
|
|
@@ -186,12 +198,11 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
186
198
|
// Get the position and dimensions
|
|
187
199
|
let rect = item.getBoundingClientRect();
|
|
188
200
|
|
|
189
|
-
controls =
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
}
|
|
201
|
+
controls.type = null;
|
|
202
|
+
controls.d = null;
|
|
203
|
+
controls.e = item;
|
|
204
|
+
controls.w = rect.width;
|
|
205
|
+
controls.h = rect.height;
|
|
195
206
|
|
|
196
207
|
// When resizable
|
|
197
208
|
if (self.resizable === true) {
|
|
@@ -226,16 +237,22 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
226
237
|
let item = self.el;
|
|
227
238
|
// Get the position and dimensions
|
|
228
239
|
let rect = item.getBoundingClientRect();
|
|
240
|
+
|
|
241
|
+
controls.e = item;
|
|
242
|
+
controls.w = rect.width;
|
|
243
|
+
controls.h = rect.height;
|
|
244
|
+
|
|
229
245
|
let corner = rect.width - (x - rect.left) < 40 && (y - rect.top) < 40;
|
|
230
246
|
|
|
231
|
-
if (self.
|
|
247
|
+
if (self.minimizable === true && corner === true) {
|
|
248
|
+
self.minimized = ! self.minimized;
|
|
249
|
+
} else if (self.closable === true && corner === true) {
|
|
232
250
|
self.closed = true;
|
|
233
|
-
} else if (self.
|
|
234
|
-
|
|
235
|
-
} else {
|
|
251
|
+
} else if (! self.minimized) {
|
|
252
|
+
// If is not minimized
|
|
236
253
|
if (controls.type === 'resize') {
|
|
237
254
|
// This will be the callback when finalize the resize
|
|
238
|
-
controls.action = function() {
|
|
255
|
+
controls.action = function () {
|
|
239
256
|
self.width = parseInt(item.style.width);
|
|
240
257
|
self.height = parseInt(item.style.height);
|
|
241
258
|
}
|
|
@@ -246,22 +263,22 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
246
263
|
if (!item.style.height) {
|
|
247
264
|
item.style.height = controls.h + 'px';
|
|
248
265
|
}
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
}
|
|
266
|
+
|
|
267
|
+
e.preventDefault();
|
|
268
|
+
} else if (self.draggable === true && self.title && y - rect.top < 40) {
|
|
269
|
+
// Action
|
|
270
|
+
controls.type = 'move';
|
|
271
|
+
// Callback
|
|
272
|
+
controls.action = function () {
|
|
273
|
+
self.top = parseInt(item.style.top);
|
|
274
|
+
self.left = parseInt(item.style.left);
|
|
259
275
|
}
|
|
276
|
+
controls.e.classList.add('moving');
|
|
260
277
|
}
|
|
261
278
|
}
|
|
262
279
|
}
|
|
263
280
|
|
|
264
|
-
return `<div class="lm-modal" title="{{self.title}}" closed="{{self.closed}}"
|
|
281
|
+
return `<div class="lm-modal" title="{{self.title}}" closed="{{self.closed}}" closable="{{self.closable}}" minimizable="{{self.minimizable}}" minimized="{{self.minimized}}" :top="self.top" :left="self.left" :width="self.width" :height="self.height" onmousedown="self.mousedown(e)" onmousemove="self.mousemove(e)" tabindex="-1">${template}</div>`
|
|
265
282
|
}
|
|
266
283
|
|
|
267
284
|
lemonade.setComponents({ Modal: Modal });
|
package/dist/style.css
CHANGED
|
@@ -12,6 +12,11 @@
|
|
|
12
12
|
box-shadow: 0 0 4px 3px rgba(80,80,80,.1);
|
|
13
13
|
opacity: 1;
|
|
14
14
|
transition: opacity 0.5s ease;
|
|
15
|
+
will-change: transform;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.lm-modal.moving {
|
|
19
|
+
cursor: move !important;
|
|
15
20
|
}
|
|
16
21
|
|
|
17
22
|
@media only screen and (max-width : 800px) {
|
|
@@ -82,7 +87,6 @@
|
|
|
82
87
|
font-size: 24px;
|
|
83
88
|
}
|
|
84
89
|
|
|
85
|
-
|
|
86
90
|
.lm-modal[title=""]::before {
|
|
87
91
|
display: none;
|
|
88
92
|
}
|
|
@@ -92,18 +96,16 @@
|
|
|
92
96
|
}
|
|
93
97
|
|
|
94
98
|
.lm-modal[minimized="true"] {
|
|
95
|
-
bottom:
|
|
96
|
-
min-height:
|
|
99
|
+
bottom: 10px;
|
|
100
|
+
min-height: 0;
|
|
97
101
|
height: 45px !important;
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
height: 100%;
|
|
102
|
-
cursor: pointer;
|
|
102
|
+
top: initial !important;
|
|
103
|
+
left: initial !important;
|
|
104
|
+
overflow: hidden;
|
|
103
105
|
}
|
|
104
106
|
|
|
105
107
|
.lm-modal[minimized="true"]::after {
|
|
106
|
-
content: '';
|
|
108
|
+
content: 'open_in_full';
|
|
107
109
|
}
|
|
108
110
|
|
|
109
111
|
@keyframes slide-bottom-in {
|