@lemonadejs/modal 2.2.1 → 2.3.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/README.md +18 -16
- package/dist/index.d.ts +6 -0
- package/dist/index.js +89 -1
- package/dist/style.css +14 -19
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -83,21 +83,23 @@ You can configure things such as position, size, and functionalities.
|
|
|
83
83
|
|
|
84
84
|
#### Modal Properties
|
|
85
85
|
|
|
86
|
-
| Property
|
|
87
|
-
|
|
88
|
-
| title?
|
|
89
|
-
| height?
|
|
90
|
-
| width?
|
|
91
|
-
| top?
|
|
92
|
-
| left?
|
|
93
|
-
| draggable?
|
|
94
|
-
| resizable?
|
|
95
|
-
| closed?
|
|
96
|
-
| closable?
|
|
97
|
-
| minimized?
|
|
98
|
-
| minimizable? | boolean | Enables the minimize button
|
|
99
|
-
| center?
|
|
100
|
-
| url?
|
|
86
|
+
| Property | Type | Description |
|
|
87
|
+
|--------------|---------|--------------------------------------------------------------------|
|
|
88
|
+
| title? | string | The header title of the modal |
|
|
89
|
+
| height? | number | The height of the modal in pixels |
|
|
90
|
+
| width? | number | The width of the modal in pixels |
|
|
91
|
+
| top? | number | The vertical position of the modal within its container in pixels |
|
|
92
|
+
| left? | number | The horizontal position of the modal within its container in pixels |
|
|
93
|
+
| draggable? | boolean | Determines if the modal can be dragged |
|
|
94
|
+
| resizable? | boolean | Determines if the modal can be resized |
|
|
95
|
+
| closed? | boolean | Controls the open and close state of the modal |
|
|
96
|
+
| closable? | boolean | Enables the close button |
|
|
97
|
+
| minimized? | boolean | Controls the minimized state of the modal |
|
|
98
|
+
| minimizable? | boolean | Enables the minimize button |
|
|
99
|
+
| center? | boolean | Enables rendering the modal in the center of its parent container |
|
|
100
|
+
| url? | string | The URL from which to fetch and render content |
|
|
101
|
+
| autoadjust? | boolean | Adjust the position when the modal is outside the viewport |
|
|
102
|
+
| autoclose? | boolean | Close when the modal loses focus |
|
|
101
103
|
|
|
102
104
|
#### Modal Events
|
|
103
105
|
|
|
@@ -113,4 +115,4 @@ The LemonadeJS Modal is released under the MIT.
|
|
|
113
115
|
## Other Tools
|
|
114
116
|
|
|
115
117
|
- [jSuites](https://jsuites.net/v4/)
|
|
116
|
-
- [Jspreadsheet](https://jspreadsheet.com)
|
|
118
|
+
- [Jspreadsheet Data Grid](https://jspreadsheet.com)
|
package/dist/index.d.ts
CHANGED
|
@@ -36,6 +36,12 @@ interface options {
|
|
|
36
36
|
top?: number;
|
|
37
37
|
/** Position Left */
|
|
38
38
|
left?: number;
|
|
39
|
+
/** Load the content from a remote URL */
|
|
40
|
+
url?: string;
|
|
41
|
+
/** Ensures modal will be visible on screen */
|
|
42
|
+
autoadjust?: boolean;
|
|
43
|
+
/** Responsive mode. Default is true */
|
|
44
|
+
responsive?: boolean;
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
interface instance {
|
package/dist/index.js
CHANGED
|
@@ -131,6 +131,28 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
|
|
134
|
+
const adjustTop = function() {
|
|
135
|
+
let self = this;
|
|
136
|
+
let rect = self.el.getBoundingClientRect();
|
|
137
|
+
self.el.style.marginTop = '';
|
|
138
|
+
let limit = document.documentElement.clientHeight + window.scrollY - (rect.top + rect.height);
|
|
139
|
+
if (limit < 0) {
|
|
140
|
+
self.el.style.marginTop = limit - 10 + 'px';
|
|
141
|
+
}
|
|
142
|
+
console.log(limit)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
const adjustLeft = function() {
|
|
146
|
+
let self = this;
|
|
147
|
+
self.el.style.marginLeft = '';
|
|
148
|
+
let rect = self.el.getBoundingClientRect();
|
|
149
|
+
// Make sure component will be visible on page
|
|
150
|
+
let limit = document.documentElement.clientWidth - (rect.left + rect.width);
|
|
151
|
+
if (limit < 0) {
|
|
152
|
+
self.el.style.marginLeft = limit - 10 + 'px';
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
134
156
|
const Modal = function (template) {
|
|
135
157
|
let self = this;
|
|
136
158
|
|
|
@@ -156,11 +178,30 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
156
178
|
self.left = (window.innerWidth - self.width) / 2;
|
|
157
179
|
}
|
|
158
180
|
|
|
181
|
+
// Dimensions
|
|
182
|
+
if (self.width) {
|
|
183
|
+
self.el.style.width = self.width + 'px';
|
|
184
|
+
}
|
|
185
|
+
if (self.height) {
|
|
186
|
+
self.el.style.height = self.height + 'px';
|
|
187
|
+
}
|
|
188
|
+
if (self.top) {
|
|
189
|
+
self.el.style.top = self.top + 'px';
|
|
190
|
+
}
|
|
191
|
+
if (self.left) {
|
|
192
|
+
self.el.style.left = self.left + 'px';
|
|
193
|
+
}
|
|
194
|
+
|
|
159
195
|
// Full screen
|
|
160
196
|
if (self.height > 260) {
|
|
161
197
|
self.el.classList.add('fullscreen');
|
|
162
198
|
}
|
|
163
199
|
|
|
200
|
+
// Responsive
|
|
201
|
+
if (document.documentElement.clientWidth < 800 && self.responsive !== false) {
|
|
202
|
+
self.el.setAttribute('data-responsive', true);
|
|
203
|
+
}
|
|
204
|
+
|
|
164
205
|
// Focus out of the component
|
|
165
206
|
self.el.addEventListener('focusout', function(e) {
|
|
166
207
|
if (self.autoclose === true) {
|
|
@@ -185,6 +226,15 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
185
226
|
self.closed ? Dispatch.call(self,'onclose') : Dispatch.call(self,'onopen');
|
|
186
227
|
} else if (property === 'top' || property === 'left' || property === 'width' || property === 'height') {
|
|
187
228
|
self.el.style[property] = self[property] + 'px';
|
|
229
|
+
|
|
230
|
+
// Adjust position
|
|
231
|
+
if (self.autoadjust) {
|
|
232
|
+
if (property === 'top') {
|
|
233
|
+
adjustTop.call(self);
|
|
234
|
+
} else if (property === 'left') {
|
|
235
|
+
adjustLeft.call(self);
|
|
236
|
+
}
|
|
237
|
+
}
|
|
188
238
|
}
|
|
189
239
|
}
|
|
190
240
|
|
|
@@ -245,7 +295,45 @@ if (! lemonade && typeof(require) === 'function') {
|
|
|
245
295
|
let corner = rect.width - (x - rect.left) < 40 && (y - rect.top) < 40;
|
|
246
296
|
|
|
247
297
|
if (self.minimizable === true && corner === true) {
|
|
248
|
-
self.minimized = ! self.minimized;
|
|
298
|
+
self.minimized = ! self.minimized;
|
|
299
|
+
|
|
300
|
+
// Handles minimized modal positioning
|
|
301
|
+
if (self.minimized) {
|
|
302
|
+
if (!lemonade.minimizedModals) {
|
|
303
|
+
lemonade.minimizedModals = []
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
lemonade.minimizedModals.push(self)
|
|
307
|
+
|
|
308
|
+
let rowIndex = Math.floor((lemonade.minimizedModals.length - 1) / 5)
|
|
309
|
+
let row = lemonade.minimizedModals.filter((_, i) => rowIndex === Math.floor((i) / 5))
|
|
310
|
+
|
|
311
|
+
self.left = self.el.offsetLeft
|
|
312
|
+
self.el.style.left = 10 + ((row.length - 1) * (self.width || 310))
|
|
313
|
+
self.el.style.marginBottom = rowIndex * 50
|
|
314
|
+
} else {
|
|
315
|
+
let index = lemonade.minimizedModals.indexOf(self)
|
|
316
|
+
let right = lemonade.minimizedModals.slice(index + 1)
|
|
317
|
+
|
|
318
|
+
lemonade.minimizedModals.splice(index, 1)
|
|
319
|
+
|
|
320
|
+
for (let i = 0; i < right.length; i++) {
|
|
321
|
+
let rowIndex = Math.floor((index + i + 1) / 5)
|
|
322
|
+
let column = ((i + index + 1) % 5)
|
|
323
|
+
|
|
324
|
+
if (rowIndex !== 0 && column === 0) {
|
|
325
|
+
right[i].el.style.left = 10 + ((5 - 1) * (self.width || 310))
|
|
326
|
+
right[i].el.style.marginBottom = 10 + ((rowIndex - 1) * 50)
|
|
327
|
+
} else if (rowIndex !== 0) {
|
|
328
|
+
right[i].el.style.left = right[i].el.offsetLeft - (self.width || 310)
|
|
329
|
+
} else {
|
|
330
|
+
right[i].el.style.left = right[i].el.offsetLeft - (self.width || 310)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
self.el.style.left = 'initial'
|
|
335
|
+
self.el.style.marginBottom = 0
|
|
336
|
+
}
|
|
249
337
|
} else if (self.closable === true && corner === true) {
|
|
250
338
|
self.closed = true;
|
|
251
339
|
} else if (! self.minimized) {
|
package/dist/style.css
CHANGED
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
position: absolute;
|
|
3
3
|
min-width: 150px;
|
|
4
4
|
min-height: 120px;
|
|
5
|
-
width: 300px;
|
|
6
|
-
height: 260px;
|
|
7
5
|
border-radius: 4px;
|
|
8
6
|
z-index: 9;
|
|
9
7
|
background-color: #fff;
|
|
@@ -15,25 +13,23 @@
|
|
|
15
13
|
will-change: transform;
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
.lm-modal
|
|
19
|
-
|
|
16
|
+
.lm-modal[data-responsive] {
|
|
17
|
+
width: 100% !important;
|
|
18
|
+
bottom: 0;
|
|
19
|
+
left: 0;
|
|
20
|
+
border: 0;
|
|
21
|
+
border-radius: 0;
|
|
22
|
+
transform: none;
|
|
23
|
+
animation: slide-bottom-in 0.4s forwards;
|
|
20
24
|
}
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
left: 0;
|
|
27
|
-
border: 0;
|
|
28
|
-
border-radius: 0;
|
|
29
|
-
transform: none;
|
|
30
|
-
animation: slide-bottom-in 0.4s forwards;
|
|
31
|
-
}
|
|
26
|
+
.lm-modal[data-responsive].fullscreen {
|
|
27
|
+
top: 0;
|
|
28
|
+
height: 100% !important;
|
|
29
|
+
}
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
height: 100% !important;
|
|
36
|
-
}
|
|
31
|
+
.lm-modal.moving {
|
|
32
|
+
cursor: move !important;
|
|
37
33
|
}
|
|
38
34
|
|
|
39
35
|
.lm-modal-picker {
|
|
@@ -100,7 +96,6 @@
|
|
|
100
96
|
min-height: 0;
|
|
101
97
|
height: 45px !important;
|
|
102
98
|
top: initial !important;
|
|
103
|
-
left: initial !important;
|
|
104
99
|
overflow: hidden;
|
|
105
100
|
}
|
|
106
101
|
|
package/package.json
CHANGED