@lemonadejs/modal 3.2.0 → 3.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.
Files changed (2) hide show
  1. package/dist/index.js +29 -18
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * pin the modal to the left panel
3
3
  */
4
- if (!lemonade && typeof (require) === 'function') {
4
+ if (! lemonade && typeof (require) === 'function') {
5
5
  var lemonade = require('lemonadejs');
6
6
  }
7
7
 
@@ -435,18 +435,6 @@ if (!lemonade && typeof (require) === 'function') {
435
435
 
436
436
  // Native lemonade
437
437
  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
438
  // Dimensions
451
439
  if (self.width) {
452
440
  self.el.style.width = self.width + 'px';
@@ -513,7 +501,11 @@ if (!lemonade && typeof (require) === 'function') {
513
501
 
514
502
  // Import content from DOM
515
503
  if (self.content) {
516
- self.el.children[1].appendChild(self.content);
504
+ if (typeof(self.content) === 'string') {
505
+ self.root.appendChild(document.createTextNode(self.content));
506
+ } else if (typeof(self.content.tagName) === 'object' && self.content.tagName) {
507
+ self.root.appendChild(self.content);
508
+ }
517
509
  }
518
510
 
519
511
  // Focus out of the component
@@ -757,22 +749,41 @@ if (!lemonade && typeof (require) === 'function') {
757
749
  }
758
750
  }
759
751
 
760
- if (! template) {
752
+ if (self.url) {
753
+ fetch(self.url)
754
+ .then(response => response.clone().body)
755
+ .then(body => {
756
+ let reader = body.getReader();
757
+ reader.read().then(function pump({done, value}) {
758
+ const decoder = new TextDecoder();
759
+ self.root.innerHTML = decoder.decode(value.buffer);
760
+ });
761
+ });
762
+ }
763
+
764
+ if (! template || typeof(template) !== 'string') {
761
765
  template = '';
762
766
  }
763
767
 
768
+ // Custom Root Configuration
769
+ self.settings = {
770
+ getRoot: function() {
771
+ return self.root;
772
+ }
773
+ }
774
+
764
775
  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
776
  <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>
777
+ <div :ref="self.root">${template}</div>
767
778
  </div>`
768
779
  }
769
780
 
770
- const Component = function (root, options, template) {
781
+ const Component = function (root, options) {
771
782
  if (typeof(root) === 'object') {
772
783
  // Remove elements from the DOM
773
784
  let elements = removeElements(root);
774
785
  // Create the modal
775
- let e = lemonade.render(Modal, root, options, template);
786
+ let e = lemonade.render(Modal, root, options);
776
787
  // Add elements to the container
777
788
  appendElements(e.children[1], elements);
778
789
 
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": "3.2.0"
20
+ "version": "3.3.0"
21
21
  }