@lemonadejs/modal 2.7.2 → 2.8.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 +60 -1
- package/dist/index.js +56 -47
- package/dist/style.css +5 -5
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -62,6 +62,65 @@ export default function App() {
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
Quick example with React
|
|
66
|
+
|
|
67
|
+
```jsx
|
|
68
|
+
import React, { useRef } from 'react';
|
|
69
|
+
import Modal from '@lemonadejs/modal/dist/react';
|
|
70
|
+
import '@lemonadejs/modal/dist/style.css';
|
|
71
|
+
|
|
72
|
+
export default function App() {
|
|
73
|
+
const modal = useRef();
|
|
74
|
+
|
|
75
|
+
const toggle = () => {
|
|
76
|
+
modal.current.closed = !modal.current.closed;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div>
|
|
81
|
+
<Modal center={true} width={400} height={200} title="My window modal" ref={modal}>
|
|
82
|
+
<div style={{ display: 'flex', flexDirection: 'column', justifyContent: 'center', padding: '10px' }}>
|
|
83
|
+
<p>Quick example!</p>
|
|
84
|
+
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor...</div>
|
|
85
|
+
</div>
|
|
86
|
+
</Modal>
|
|
87
|
+
<input type="button" value="Toggle Modal" id="button" onClick={toggle} />
|
|
88
|
+
</div>
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
Quick example with Vue
|
|
94
|
+
|
|
95
|
+
```vue
|
|
96
|
+
<template>
|
|
97
|
+
<Modal ref='modal' :center="true" :width="400" :height="200" title="My window modal" >
|
|
98
|
+
<div style="display: flex; flex-direction: column; justify-content: center; padding: 10px;">
|
|
99
|
+
<p>Quick example!</p>
|
|
100
|
+
<div>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor...</div>
|
|
101
|
+
</div>
|
|
102
|
+
</Modal>
|
|
103
|
+
<input type="button" value="Toggle Modal" id="button" @click="toggleModal" />
|
|
104
|
+
</template>
|
|
105
|
+
<script>
|
|
106
|
+
import Modal from '@lemonadejs/modal/dist/vue';
|
|
107
|
+
import '@lemonadejs/modal/dist/style.css'
|
|
108
|
+
|
|
109
|
+
export default {
|
|
110
|
+
name: 'App',
|
|
111
|
+
components: {
|
|
112
|
+
Modal,
|
|
113
|
+
},
|
|
114
|
+
methods: {
|
|
115
|
+
toggleModal() {
|
|
116
|
+
console.log(this.$refs.modal);
|
|
117
|
+
this.$refs.modal.current.closed = !this.$refs.modal.current.closed;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
</script>
|
|
122
|
+
```
|
|
123
|
+
|
|
65
124
|
Programmatical - Quick example with Javascript
|
|
66
125
|
|
|
67
126
|
```html
|
|
@@ -139,5 +198,5 @@ The LemonadeJS Modal is released under the MIT.
|
|
|
139
198
|
|
|
140
199
|
## Other Tools
|
|
141
200
|
|
|
142
|
-
- [jSuites](https://jsuites.net/
|
|
201
|
+
- [jSuites](https://jsuites.net/docs)
|
|
143
202
|
- [Jspreadsheet Data Grid](https://jspreadsheet.com)
|
package/dist/index.js
CHANGED
|
@@ -280,7 +280,10 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
280
280
|
|
|
281
281
|
if (self.position) {
|
|
282
282
|
if (self.position === 'absolute') {
|
|
283
|
-
|
|
283
|
+
let w = document.documentElement.offsetWidth;
|
|
284
|
+
if (w > viewportWidth) {
|
|
285
|
+
viewportWidth = w;
|
|
286
|
+
}
|
|
284
287
|
} else if (self.position !== 'center') {
|
|
285
288
|
margin = 0;
|
|
286
289
|
}
|
|
@@ -318,7 +321,10 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
318
321
|
|
|
319
322
|
if (self.position) {
|
|
320
323
|
if (self.position === 'absolute') {
|
|
321
|
-
|
|
324
|
+
let h = document.documentElement.offsetHeight;
|
|
325
|
+
if (h > viewportHeight) {
|
|
326
|
+
viewportHeight = h;
|
|
327
|
+
}
|
|
322
328
|
} else if (self.position !== 'center') {
|
|
323
329
|
margin = 0;
|
|
324
330
|
}
|
|
@@ -428,7 +434,7 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
428
434
|
if (self.backdrop === true) {
|
|
429
435
|
backdrop = document.createElement('div');
|
|
430
436
|
backdrop.classList.add('lm-modal-backdrop');
|
|
431
|
-
backdrop.addEventListener('
|
|
437
|
+
backdrop.addEventListener('click', function() {
|
|
432
438
|
self.closed = true;
|
|
433
439
|
})
|
|
434
440
|
}
|
|
@@ -565,50 +571,18 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
565
571
|
}
|
|
566
572
|
|
|
567
573
|
self.mousedown = function(e) {
|
|
568
|
-
// Get mouse coordinates
|
|
569
|
-
let [x,y] = getCoords(e);
|
|
570
|
-
controls.x = x;
|
|
571
|
-
controls.y = y;
|
|
572
|
-
// Root element of the component
|
|
573
|
-
let item = self.el;
|
|
574
|
-
// Get the position and dimensions
|
|
575
|
-
let rect = item.getBoundingClientRect();
|
|
576
|
-
|
|
577
|
-
controls.e = item;
|
|
578
|
-
controls.w = rect.width;
|
|
579
|
-
controls.h = rect.height;
|
|
580
|
-
|
|
581
|
-
let corner = (y - rect.top) < 40 && rect.width - (x - rect.left) < 34;
|
|
582
|
-
|
|
583
|
-
// Check if the click in on close
|
|
584
|
-
if (isTrue(self.closable)) {
|
|
585
|
-
if (corner) {
|
|
586
|
-
self.closed = true;
|
|
587
|
-
|
|
588
|
-
if (isTrue(self.minimizable)) {
|
|
589
|
-
removeMini(self);
|
|
590
|
-
}
|
|
591
|
-
return;
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
corner = (y - rect.top) < 40 && rect.width - (x - rect.left) < 65;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
// Check if the click in on minimize
|
|
598
|
-
if (isTrue(self.minimizable)) {
|
|
599
|
-
if (corner) {
|
|
600
|
-
// Handles minimized modal positioning
|
|
601
|
-
if (self.minimized === true) {
|
|
602
|
-
removeMini(self);
|
|
603
|
-
} else {
|
|
604
|
-
setMini(self);
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
return;
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
|
|
611
574
|
if (! self.minimized) {
|
|
575
|
+
// Get mouse coordinates
|
|
576
|
+
let [x,y] = getCoords(e);
|
|
577
|
+
controls.x = x;
|
|
578
|
+
controls.y = y;
|
|
579
|
+
// Root element of the component
|
|
580
|
+
let item = self.el;
|
|
581
|
+
// Get the position and dimensions
|
|
582
|
+
let rect = item.getBoundingClientRect();
|
|
583
|
+
controls.e = item;
|
|
584
|
+
controls.w = rect.width;
|
|
585
|
+
controls.h = rect.height;
|
|
612
586
|
// If is not minimized
|
|
613
587
|
if (controls.type === 'resize') {
|
|
614
588
|
// Make sure the width and height is defined for the modal
|
|
@@ -642,6 +616,41 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
642
616
|
}
|
|
643
617
|
}
|
|
644
618
|
|
|
619
|
+
self.click = function(e) {
|
|
620
|
+
// Get mouse coordinates
|
|
621
|
+
let [x,y] = getCoords(e);
|
|
622
|
+
// Get the position and dimensions
|
|
623
|
+
let rect = self.el.getBoundingClientRect();
|
|
624
|
+
// Right
|
|
625
|
+
let right = rect.width - (x - rect.left);
|
|
626
|
+
// Corner
|
|
627
|
+
let corner = (y - rect.top) < 40 && right > 10 && right < 34;
|
|
628
|
+
// Check if the click in on close
|
|
629
|
+
if (isTrue(self.closable)) {
|
|
630
|
+
if (corner) {
|
|
631
|
+
self.closed = true;
|
|
632
|
+
|
|
633
|
+
if (isTrue(self.minimizable)) {
|
|
634
|
+
removeMini(self);
|
|
635
|
+
}
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
|
|
639
|
+
corner = (y - rect.top) < 40 && right > 10 && right < 65;
|
|
640
|
+
}
|
|
641
|
+
// Check if the click in on minimize
|
|
642
|
+
if (isTrue(self.minimizable)) {
|
|
643
|
+
if (corner) {
|
|
644
|
+
// Handles minimized modal positioning
|
|
645
|
+
if (self.minimized === true) {
|
|
646
|
+
removeMini(self);
|
|
647
|
+
} else {
|
|
648
|
+
setMini(self);
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
|
|
645
654
|
self.open = function() {
|
|
646
655
|
if (self.closed === true) {
|
|
647
656
|
self.closed = false;
|
|
@@ -654,7 +663,7 @@ if (!lemonade && typeof (require) === 'function') {
|
|
|
654
663
|
}
|
|
655
664
|
}
|
|
656
665
|
|
|
657
|
-
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
|
|
666
|
+
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">
|
|
658
667
|
<div class="lm-modal-title" data-icon="{{self.icon}}">{{self.title}}</div>
|
|
659
668
|
<div>${template}</div>
|
|
660
669
|
</div>`
|
package/dist/style.css
CHANGED
|
@@ -4,27 +4,27 @@
|
|
|
4
4
|
min-height: 240px;
|
|
5
5
|
border-radius: 5px;
|
|
6
6
|
z-index: 15;
|
|
7
|
-
background-color: #fff;
|
|
7
|
+
background-color: var(--lm-background-color, #fff);
|
|
8
8
|
box-sizing: border-box;
|
|
9
9
|
box-shadow: 0 0 12px rgb(0 0 0 / 22%);
|
|
10
10
|
opacity: 1;
|
|
11
11
|
will-change: transform;
|
|
12
|
-
border: 1px solid #
|
|
12
|
+
border: 1px solid var(--lm-border-color, #ccc);
|
|
13
13
|
outline: none;
|
|
14
14
|
margin: 0;
|
|
15
15
|
display: flex;
|
|
16
16
|
flex-direction: column;
|
|
17
17
|
transition: opacity 0.4s ease, top 0.4s ease, left 0.4s ease, width 0.4s ease, height 0.4s ease;
|
|
18
|
+
color: var(--lm-font-color, #000);
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
.lm-modal-title {
|
|
21
22
|
width: 100%;
|
|
22
|
-
border-bottom: 1px solid #
|
|
23
|
+
border-bottom: 1px solid var(--lm-border-color, #ccc);
|
|
23
24
|
padding: 10px;
|
|
24
25
|
box-sizing: border-box;
|
|
25
26
|
font-size: 1.2em;
|
|
26
27
|
line-height: 24px;
|
|
27
|
-
background: #fff;
|
|
28
28
|
user-select: none;
|
|
29
29
|
display: flex;
|
|
30
30
|
border-radius: 5px;
|
|
@@ -170,4 +170,4 @@
|
|
|
170
170
|
min-width: initial;
|
|
171
171
|
min-height: initial;
|
|
172
172
|
overflow: hidden;
|
|
173
|
-
}
|
|
173
|
+
}
|