@lemonadejs/modal 2.4.1 → 2.4.2

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 CHANGED
@@ -4,70 +4,102 @@
4
4
  * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
5
  */
6
6
 
7
- interface Modal {
8
- (): any
9
- [key: string]: any
10
- }
7
+ declare function Modal(el: HTMLElement, options?: Modal.Options): Modal.Instance;
11
8
 
12
- interface options {
13
- // Create a backdrop
14
- backdrop?: boolean;
15
- /** Modal is closed */
16
- closed?: boolean;
17
- /** Modal is minimized */
18
- minimized?: boolean;
19
- /** Modal can be closed */
20
- closable?: boolean;
21
- /** Modal can be minimized */
22
- minimizable?: boolean;
23
- /** Modal can be resized */
24
- resizable?: boolean;
25
- /** Modal can be moved from its original position */
26
- draggable?: boolean;
27
- /** Modal is automatic align center */
28
- center?: boolean;
29
- /** Title of the modal */
30
- title?: string;
31
- /** Width of the modal */
32
- width?: number;
33
- /** Height of the modal */
34
- height?: number;
35
- /** Position top */
36
- top?: number;
37
- /** Position Left */
38
- left?: number;
39
- /** Load the content from a remote URL */
40
- url?: string;
41
- /** Responsive mode. Default is true */
42
- responsive?: boolean;
43
- /** Bring to front on focus */
44
- layers?: boolean;
45
- /** Close the modal when it loses the focus */
46
- 'auto-close'?: boolean;
47
- /** Ensures modal will be visible on screen */
48
- 'auto-adjust'?: boolean;
49
- /** Focus on the modal when open it. Default: true */
50
- focus?: boolean;
51
- }
9
+ declare namespace Modal {
10
+ interface Options {
11
+ /** Activate the backdrop when the modal is opened */
12
+ backdrop?: boolean;
13
+ /** Current visibility state of the modal */
14
+ closed?: boolean;
15
+ /** Current state of the modal */
16
+ minimized?: boolean;
17
+ /** Modal can be closed. Default: false */
18
+ closable?: boolean;
19
+ /** Modal can be minimized. Default: false */
20
+ minimizable?: boolean;
21
+ /** Modal can be resized. Default: false */
22
+ resizable?: boolean;
23
+ /** Modal can be moved from its original position. Default: false */
24
+ draggable?: boolean;
25
+ /** Modal is automatic align center during initialization */
26
+ center?: boolean;
27
+ /** Title of the modal */
28
+ title?: string;
29
+ /** Width of the modal */
30
+ width?: number;
31
+ /** Height of the modal */
32
+ height?: number;
33
+ /** Position top */
34
+ top?: number;
35
+ /** Position Left */
36
+ left?: number;
37
+ /** Load the content from a remote URL during initialization */
38
+ url?: string;
39
+ /** Responsive mode. Default is true */
40
+ responsive?: boolean;
41
+ /** Bring to front on focus */
42
+ layers?: boolean;
43
+ /** Close the modal when it loses the focus. Default: false */
44
+ 'auto-close'?: boolean;
45
+ /** Ensures modal will be visible on screen. Default: false */
46
+ 'auto-adjust'?: boolean;
47
+ /** Focus on the modal when open it. Default: true */
48
+ focus?: boolean;
49
+ /** Create scroll when the content is larger than the modal. Default: false */
50
+ overflow?: boolean;
51
+ }
52
52
 
53
- interface instance {
54
- closed: boolean;
55
- closable: boolean;
56
- minimized: boolean;
57
- minimizable: boolean;
58
- resizable: boolean;
59
- draggable: boolean;
60
- center: boolean;
61
- title: string;
62
- width: number;
63
- height: number;
64
- top: number;
65
- left: number;
66
- front: () => void;
67
- back: () => void;
68
- 'auto-close': boolean;
69
- /** Ensures modal will be visible on screen */
70
- 'auto-adjust'?: boolean;
53
+ interface Instance {
54
+ /** Backdrop is shown when the modal is opened */
55
+ backdrop?: boolean;
56
+ /** Current visibility state of the modal */
57
+ closed: boolean;
58
+ /** Current state of the modal */
59
+ minimized?: boolean;
60
+ /** Modal can be closed. */
61
+ closable?: boolean;
62
+ /** Modal can be minimized. */
63
+ minimizable?: boolean;
64
+ /** Modal can be resized. */
65
+ resizable?: boolean;
66
+ /** Modal can be moved from its original position. */
67
+ draggable?: boolean;
68
+ /** Modal is automatic align center during initialization */
69
+ center?: boolean;
70
+ /** Title of the modal */
71
+ title?: string;
72
+ /** Width of the modal */
73
+ width?: number;
74
+ /** Height of the modal */
75
+ height?: number;
76
+ /** Position top */
77
+ top?: number;
78
+ /** Position Left */
79
+ left?: number;
80
+ /** Load the content from a remote URL during initialization */
81
+ url?: string;
82
+ /** Responsive mode is active */
83
+ responsive?: boolean;
84
+ /** Bring to front on focus */
85
+ layers?: boolean;
86
+ /** Close the modal when it loses the focus. */
87
+ 'auto-close'?: boolean;
88
+ /** Ensures modal will be visible on screen. */
89
+ 'auto-adjust'?: boolean;
90
+ /** Focus on the modal when open it. */
91
+ focus?: boolean;
92
+ /** Create scroll when the content is larger than the modal. Default: false */
93
+ overflow?: boolean;
94
+ /** Open the modal */
95
+ open: () => void;
96
+ /** Close the modal */
97
+ close: () => void;
98
+ /** Send to front when layers is activated */
99
+ front: () => void;
100
+ /** Send to back when layers is activated */
101
+ back: () => void;
102
+ }
71
103
  }
72
104
 
73
- export declare function Modal(el: HTMLElement, options?: options): instance;
105
+ export default Modal;
package/dist/index.js CHANGED
@@ -31,7 +31,7 @@ if (!lemonade && typeof (require) === 'function') {
31
31
  const sendToFront = function(container) {
32
32
  let highestXIndex = defaultZIndex;
33
33
  for (let i = 0; i < modals.length; i++) {
34
- const zIndex = parseInt(modals[i].style.zIndex);
34
+ const zIndex = parseInt(modals[i].el.style.zIndex);
35
35
  if (zIndex > highestXIndex) {
36
36
  highestXIndex = zIndex;
37
37
  }
@@ -230,8 +230,12 @@ if (!lemonade && typeof (require) === 'function') {
230
230
  // Keep all modals references
231
231
  modals.push(self);
232
232
 
233
- self.back = sendToBack;
234
- self.front = sendToFront;
233
+ self.back = function() {
234
+ sendToBack(self.el);
235
+ }
236
+ self.front = function() {
237
+ sendToFront(self.el);
238
+ }
235
239
 
236
240
  self.onload = function() {
237
241
  if (self.url) {
@@ -266,8 +270,8 @@ if (!lemonade && typeof (require) === 'function') {
266
270
 
267
271
  // Initial centralize
268
272
  if (self.center === true) {
269
- self.top = (window.innerHeight - self.el.offsetHeight) / 2;
270
- self.left = (window.innerWidth - self.el.offsetWidth) / 2;
273
+ self.top = (window.innerHeight - self.height) / 2;
274
+ self.left = (window.innerWidth - self.width) / 2;
271
275
  }
272
276
 
273
277
  // Full screen
@@ -337,18 +341,18 @@ if (!lemonade && typeof (require) === 'function') {
337
341
  self.el.classList.remove('lm-modal-animation');
338
342
  }
339
343
  }
344
+
340
345
  // Call the vents
341
346
  self.closed ? Dispatch.call(self,'onclose') : Dispatch.call(self,'onopen');
342
347
  } else if (property === 'top' || property === 'left' || property === 'width' || property === 'height') {
343
348
  self.el.style[property] = self[property] + 'px';
349
+ }
344
350
 
345
- // Adjust position
351
+ // Adjust position
352
+ if (self.closed === false) {
346
353
  if (isTrue(self['auto-adjust'])) {
347
- if (property === 'top') {
348
- adjustTop.call(self);
349
- } else if (property === 'left') {
350
- adjustLeft.call(self);
351
- }
354
+ adjustTop.call(self);
355
+ adjustLeft.call(self);
352
356
  }
353
357
  }
354
358
  }
@@ -461,12 +465,15 @@ if (!lemonade && typeof (require) === 'function') {
461
465
  }
462
466
  }
463
467
 
464
- return `<div class="lm-modal" title="{{self.title}}" closed="{{self.closed}}" closable="{{self.closable}}" minimizable="{{self.minimizable}}" minimized="{{self.minimized}}" center="{{self.center}}" :top="self.top" :left="self.left" :width="self.width" :height="self.height" onmousedown="self.mousedown(e)" onmousemove="self.mousemove(e)" tabindex="-1">${template}</div>`
468
+ return `<div class="lm-modal" 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(e)" onmousemove="self.mousemove(e)" tabindex="-1">
469
+ <div class="lm-modal-title" data-icon="{{self.icon}}">{{self.title}}</div>
470
+ <div>${template}</div>
471
+ </div>`
465
472
  }
466
473
 
467
474
  lemonade.setComponents({ Modal: Modal });
468
475
 
469
- return function (root, options, template = '') {
476
+ return function (root, options, template) {
470
477
  if (typeof(root) === 'object') {
471
478
  // Keep the DOM elements
472
479
  let elements = [];
@@ -479,13 +486,13 @@ if (!lemonade && typeof (require) === 'function') {
479
486
  // Append any elements inside the modal
480
487
  if (elements.length) {
481
488
  while (elements[0]) {
482
- e.appendChild(elements[0]);
489
+ e.children[1].appendChild(elements[0]);
483
490
  elements.shift();
484
491
  }
485
492
  }
486
493
  return options;
487
494
  } else {
488
- return Modal.call(this, root)
495
+ return Modal.call(this, root);
489
496
  }
490
497
  }
491
498
  })));
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Official Type definitions for Jspreadsheet React
3
+ * https://jspreadsheet.com/v10/docs/react
4
+ * Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
+ */
6
+
7
+
8
+ import ModalComponent from './index';
9
+
10
+ interface Modal {
11
+ (): any
12
+ [key: string]: any
13
+ }
14
+
15
+ declare function Modal<Modal>(props: ModalComponent.Options): any;
16
+
17
+ export default Modal;
package/dist/style.css CHANGED
@@ -13,83 +13,55 @@
13
13
  border: 1px solid #bbb;
14
14
  outline: none;
15
15
  margin: 0;
16
+ display: flex;
17
+ flex-direction: column;
16
18
  }
17
19
 
18
- .lm-modal-backdrop {
19
- position: fixed;
20
- top: 0;
21
- left: 0;
22
- width: 100vw;
23
- height: 100vh;
24
- background-color: #00000020;
25
- z-index: 999;
26
- }
27
-
28
- .lm-modal-layers:focus {
29
- z-index: 999;
30
- }
31
-
32
- .lm-modal-animation {
33
- transform: none;
34
- animation: slide-bottom-in 0.4s forwards;
35
- }
36
-
37
- .lm-modal[data-responsive].fullscreen {
38
- top: 0;
39
- height: 100% !important;
40
- }
41
-
42
- .lm-modal.moving {
43
- cursor: move !important;
44
- }
45
-
46
- .lm-modal-picker {
47
- width: 100% !important;
48
- height: 260px !important;
49
- left: 0;
50
- bottom: 0;
51
- border: 0;
52
- border-radius: 0;
53
- transform: none;
54
- }
55
-
56
- .lm-modal[title]::before {
57
- content: attr(title);
58
- display: block;
59
- position: relative;
20
+ .lm-modal-title {
60
21
  width: 100%;
61
22
  border-bottom: 1px solid #e9e9e9;
62
23
  padding: 10px;
63
24
  box-sizing: border-box;
64
25
  font-size: 1.2em;
65
26
  line-height: 24px;
27
+ position: sticky;
28
+ top: 0;
29
+ background: #fff;
30
+ user-select: none;
31
+ display: flex;
32
+ border-radius: 5px;
66
33
  }
67
34
 
68
- .lm-modal::after {
69
- font-family: 'Material Icons';
70
- cursor: pointer;
35
+ .lm-modal-title:empty {
36
+ display: none;
71
37
  }
72
38
 
73
- .lm-modal[closable="true"]::after {
74
- content: 'close';
75
- display: block;
76
- position: absolute;
77
- top: 10px;
78
- right: 10px;
39
+ .lm-modal-title[data-icon]::before {
40
+ content: attr(data-icon);
41
+ width: 24px;
42
+ height: 24px;
79
43
  font-size: 24px;
44
+ font-family: "Material Icons";
45
+ margin-right: 5px;
80
46
  }
81
47
 
82
- .lm-modal[minimizable="true"]::after {
83
- content: '\2500';
84
- display: block;
48
+ .lm-modal[closable="true"] .lm-modal-title::after {
49
+ content: 'close';
50
+ width: 24px;
51
+ height: 24px;
52
+ font-size: 24px;
53
+ font-family: "Material Icons";
85
54
  position: absolute;
86
- top: 10px;
87
55
  right: 10px;
88
- font-size: 24px;
56
+ cursor: pointer;
89
57
  }
90
58
 
91
- .lm-modal[title=""]::before {
92
- display: none;
59
+ .lm-modal[minimizable="true"] .lm-modal-title::after {
60
+ content: '\2500';
61
+ width: 24px;
62
+ height: 24px;
63
+ font-size: 24px;
64
+ font-family: "Material Icons";
93
65
  }
94
66
 
95
67
  .lm-modal[closed="true"] {
@@ -119,4 +91,56 @@
119
91
 
120
92
  .lm-modal.hide {
121
93
  opacity: 0;
94
+ }
95
+
96
+ .lm-modal-layers:focus {
97
+ z-index: 999;
98
+ }
99
+
100
+ .lm-modal-animation {
101
+ transform: none;
102
+ animation: slide-bottom-in 0.4s forwards;
103
+ }
104
+
105
+ .lm-modal[data-responsive].fullscreen {
106
+ top: 0;
107
+ height: 100% !important;
108
+ }
109
+
110
+ .lm-modal.moving {
111
+ cursor: move !important;
112
+ }
113
+
114
+ .lm-modal-backdrop {
115
+ position: fixed;
116
+ top: 0;
117
+ left: 0;
118
+ width: 100vw;
119
+ height: 100vh;
120
+ background-color: #00000020;
121
+ z-index: 999;
122
+ }
123
+
124
+ .lm-modal > div:last-child {
125
+ width: 100%;
126
+ height: 100%;
127
+ }
128
+
129
+ .lm-modal[overflow="true"] > div:last-child {
130
+ overflow: auto;
131
+ scrollbar-width: thin;
132
+ scrollbar-color: #333 transparent;
133
+ }
134
+
135
+ .lm-modal > div:last-child::-webkit-scrollbar {
136
+ width: 12px;
137
+ height: 12px;
138
+ }
139
+
140
+ .lm-modal > div:last-child::-webkit-scrollbar-track {
141
+ background: #eee;
142
+ }
143
+
144
+ .lm-modal > div:last-child::-webkit-scrollbar-thumb {
145
+ background: #888;
122
146
  }
package/package.json CHANGED
@@ -17,5 +17,5 @@
17
17
  },
18
18
  "main": "dist/index.js",
19
19
  "types": "dist/index.d.ts",
20
- "version": "2.4.1"
20
+ "version": "2.4.2"
21
21
  }