wj-elements 0.1.32 → 0.1.34

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.
@@ -1,7 +1,7 @@
1
1
  var w = Object.defineProperty;
2
- var v = (i, e, t) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
- var n = (i, e, t) => (v(i, typeof e != "symbol" ? e + "" : e, t), t);
4
- import f, { event as a } from "./wje-element.js";
2
+ var v = (s, o, t) => o in s ? w(s, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[o] = t;
3
+ var a = (s, o, t) => (v(s, typeof o != "symbol" ? o + "" : o, t), t);
4
+ import f, { event as n } from "./wje-element.js";
5
5
  const b = '.native-tooltip{display:flex;align-items:center;padding:var(--wje-tooltip-spacing);color:var(--wje-tooltip-color);background-color:var(--wje-tooltip-background);font-weight:var(--wje-tooltip-font-weight);font-size:var(--wje-tooltip-font-size);border-radius:var(--wje-tooltip-border-radius);line-height:var(--wje-tooltip-line-height);box-sizing:border-box;box-shadow:var(--wje-tooltip-shadow)}::slotted([slot="start"]){margin:0 .3rem 0 0}::slotted([slot="end"]){margin:0 0 0 .3rem}.arrow{position:absolute;width:10px;height:10px;background:var(--wje-tooltip-arrow-color);transform:rotate(45deg)}';
6
6
  class m extends f {
7
7
  /**
@@ -14,23 +14,24 @@ class m extends f {
14
14
  * @summary Class name
15
15
  * @type {string}
16
16
  */
17
- n(this, "className", "Tooltip");
17
+ a(this, "className", "Tooltip");
18
18
  /**
19
19
  * @summary Show tooltip
20
20
  */
21
- n(this, "onShow", () => {
22
- this.classList.add("active"), Promise.resolve(this.beforeShow(this)).then((t) => {
23
- if (!this.classList.contains("active") || !t || typeof t != "string")
21
+ a(this, "onShow", () => {
22
+ var t;
23
+ this.classList.add("active"), !((t = this.querySelector("wje-dropdown")) != null && t.classList.contains("active")) && Promise.resolve(this.beforeShow(this)).then((e) => {
24
+ if (!this.classList.contains("active") || !e || typeof e != "string")
24
25
  throw new Error("beforeShow method returned false or not string");
25
- this.native.innerHTML = t, this.popup.show(), Promise.resolve(this.afterShow(this));
26
- }).catch((t) => {
26
+ this.native.innerHTML = e, this.popup.show(), Promise.resolve(this.afterShow(this));
27
+ }).catch((e) => {
27
28
  this.classList.remove("active"), this.popup.hide();
28
29
  });
29
30
  });
30
31
  /**
31
32
  * @summary Hide tooltip
32
33
  */
33
- n(this, "onHide", () => {
34
+ a(this, "onHide", () => {
34
35
  this.classList.remove("active"), this.popup.hide();
35
36
  });
36
37
  }
@@ -69,33 +70,33 @@ class m extends f {
69
70
  * @param {Object} params - The parameters
70
71
  * @returns {Object} Document fragment
71
72
  */
72
- draw(t, s, g) {
73
- let d = document.createDocumentFragment(), o = document.createElement("wje-popup");
74
- o.setAttribute("placement", this.placement || "top"), o.setAttribute("offset", this.offset || "0");
73
+ draw(t, e, g) {
74
+ let c = document.createDocumentFragment(), r = document.createElement("wje-popup");
75
+ r.setAttribute("placement", this.placement || "top"), r.setAttribute("offset", this.offset || "0");
75
76
  let l = document.createElement("slot");
76
77
  l.setAttribute("slot", "anchor");
77
- let c = document.createElement("div");
78
- c.classList.add("arrow"), c.setAttribute("slot", "arrow");
78
+ let d = document.createElement("div");
79
+ d.classList.add("arrow"), d.setAttribute("slot", "arrow");
79
80
  let h = document.createElement("slot");
80
81
  h.setAttribute("name", "start");
81
82
  let p = document.createElement("slot");
82
83
  p.setAttribute("name", "end");
83
84
  let u = document.createElement("div");
84
85
  u.innerHTML = this.content;
85
- let r = document.createElement("div");
86
- return r.setAttribute("part", "native"), r.classList.add("native-tooltip"), r.appendChild(h), r.appendChild(u), r.appendChild(p), o.appendChild(l), o.appendChild(c), o.appendChild(r), this.mySlot = l, this.popup = o, this.native = r, d.appendChild(o), d;
86
+ let i = document.createElement("div");
87
+ return i.setAttribute("part", "native"), i.classList.add("native-tooltip"), i.appendChild(h), i.appendChild(u), i.appendChild(p), r.appendChild(l), r.appendChild(d), r.appendChild(i), this.mySlot = l, this.popup = r, this.native = i, c.appendChild(r), c;
87
88
  }
88
89
  /**
89
90
  * @summary After draw method
90
91
  */
91
92
  afterDraw() {
92
93
  let t = this.mySlot.assignedElements()[0];
93
- this.selector && (t = this.checkSelector(t)), t && (a.addListener(t, "mouseenter", null, this.onShow), a.addListener(t, "mouseleave", null, this.onHide), a.addListener(t, "click", null, this.onHide, { stopPropagation: !1 }));
94
+ this.selector && (t = this.checkSelector(t)), t && (n.addListener(t, "mouseenter", null, this.onShow), n.addListener(t, "mouseleave", null, this.onHide), n.addListener(this, "wje-dropdown:open", null, this.onHide), n.addListener(this, "wje-dropdown:close", null, this.onShow));
94
95
  }
95
96
  dispatch(t) {
96
- return new Promise((s) => {
97
- a.dispatchCustomEvent(this, t, {
98
- resolve: s
97
+ return new Promise((e) => {
98
+ n.dispatchCustomEvent(this, t, {
99
+ resolve: e
99
100
  });
100
101
  });
101
102
  }
@@ -105,8 +106,8 @@ class m extends f {
105
106
  afterShow() {
106
107
  }
107
108
  checkSelector(t) {
108
- const s = t.querySelector(this.selector);
109
- return s === null && console.error("Selector not found:", this.selector), s;
109
+ const e = t.querySelector(this.selector);
110
+ return e === null && console.error("Selector not found:", this.selector), e;
110
111
  }
111
112
  }
112
113
  m.define("wje-tooltip", m);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "wj-elements",
3
3
  "description": "WebJET Elements is a modern set of user interface tools harnessing the power of web components designed to simplify web application development.",
4
- "version": "0.1.32",
4
+ "version": "0.1.34",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",