wj-elements 0.1.50 → 0.1.51

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,9 +1,9 @@
1
1
  var u = Object.defineProperty;
2
2
  var m = (a, e, t) => e in a ? u(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var v = (a, e, t) => (m(a, typeof e != "symbol" ? e + "" : e, t), t);
3
+ var b = (a, e, t) => (m(a, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import h from "./wje-element.js";
5
5
  const g = ":host{--wje-tab-top: 0;--wje-tab-start: 0;--wje-tab-end: 0;--wje-tab-bottom: 0}.native-tab-group{display:flex;flex-direction:column;overflow:hidden;position:relative}.native-tab-group>header{display:flex;flex-direction:column}.native-tab-group>header>nav{display:flex}.native-tab-group>section{width:100%}.native-tab-group>section>article{scroll-snap-align:start;overflow-y:auto;overscroll-behavior-y:contain}:host([variant=top]){--wje-tab-top: auto !important;--wje-tab-writing-mode: horizontal-tb}:host([variant=top]) .native-tab-group{flex-direction:column}:host([variant=top]) nav{border-bottom:1px solid var(--wje-border-color)}:host([variant=start]){--wje-tab-start: auto !important;--wje-tab-writing-mode: vertical-rl}:host([variant=start]) .native-tab-group{flex-direction:row}:host([variant=start]) nav{flex-direction:column;border-right:1px solid var(--wje-border-color)}:host([variant=end]){--wje-tab-writing-mode: vertical-rl}:host([variant=end]) .native-tab-group{flex-direction:row-reverse}:host([variant=end]) nav{flex-direction:column;border-left:1px solid var(--wje-border-color)}:host([variant=bottom]){--wje-tab-bottom: auto !important;--wje-tab-writing-mode: horizontal-tb}:host([variant=bottom]) .native-tab-group{flex-direction:column-reverse}:host([variant=bottom]) nav{border-top:1px solid var(--wje-border-color)}";
6
- class b extends h {
6
+ class v extends h {
7
7
  /**
8
8
  * Creates an instance of TabGroup.
9
9
  *
@@ -11,7 +11,7 @@ class b extends h {
11
11
  */
12
12
  constructor() {
13
13
  super();
14
- v(this, "className", "TabGroup");
14
+ b(this, "className", "TabGroup");
15
15
  }
16
16
  /**
17
17
  * Returns the CSS styles for the component.
@@ -28,6 +28,17 @@ class b extends h {
28
28
  setupAttributes() {
29
29
  this.isShadowRoot = "open";
30
30
  }
31
+ /**
32
+ * Sets up the event listeners before the component is drawn.
33
+ * This method is called before the component is drawn.
34
+ * It is used to set up event listeners.
35
+ */
36
+ beforeDraw() {
37
+ let t = location.hash.replace("#", "");
38
+ this.getPanelAllName().includes(t) && window.addEventListener("load", (i) => {
39
+ this.setActiveTab(t);
40
+ });
41
+ }
31
42
  /**
32
43
  * Draws the component.
33
44
  *
@@ -36,25 +47,25 @@ class b extends h {
36
47
  * @param {Object} params - The parameters for drawing.
37
48
  * @returns {DocumentFragment}
38
49
  */
39
- draw(t, l, i) {
50
+ draw(t, i, n) {
40
51
  let s = document.createDocumentFragment(), r = document.createElement("div");
41
52
  r.setAttribute("part", "native"), r.classList.add("native-tab-group");
42
53
  let o = document.createElement("header");
43
54
  o.setAttribute("part", "tabs"), o.classList.add("scroll-snap-x");
44
- let c = document.createElement("nav"), n = document.createElement("section");
45
- n.setAttribute("part", "panels");
55
+ let c = document.createElement("nav"), l = document.createElement("section");
56
+ l.setAttribute("part", "panels");
46
57
  let p = document.createElement("slot"), d = document.createElement("slot");
47
- return d.setAttribute("name", "nav"), o.appendChild(c), c.appendChild(d), n.appendChild(p), r.appendChild(o), r.appendChild(n), s.appendChild(r), s;
58
+ return d.setAttribute("name", "nav"), o.appendChild(c), c.appendChild(d), l.appendChild(p), r.appendChild(o), r.appendChild(l), s.appendChild(r), s;
48
59
  }
49
60
  /**
50
61
  * Sets up the event listeners after the component is drawn.
51
62
  */
52
63
  afterDraw() {
53
- let t = this.getActiveTab(), l = t ? t[0].name : this.getTabAll()[0].panel;
54
- this.setActiveTab(l), this.addEventListener("wje:tab-change", (i) => {
55
- if (i.detail.context.hasAttribute("disabled"))
64
+ let t = this.getActiveTab(), i = t ? t[0].name : this.getTabAll()[0].panel;
65
+ this.setActiveTab(i), this.addEventListener("wje-tab:change", (n) => {
66
+ if (n.detail.context.hasAttribute("disabled"))
56
67
  return !1;
57
- this.setActiveTab(i.detail.context.panel);
68
+ this.setActiveTab(n.detail.context.panel);
58
69
  });
59
70
  }
60
71
  /**
@@ -100,8 +111,16 @@ class b extends h {
100
111
  getPanelAll() {
101
112
  return Array.from(this.querySelectorAll("wje-tab-panel"));
102
113
  }
114
+ /**
115
+ * Returns the names of all tabs.
116
+ *
117
+ * @returns {Array<string>} An array of all tab names.
118
+ */
119
+ getPanelAllName() {
120
+ return this.getPanelAll().map((t) => t.getAttribute("name"));
121
+ }
103
122
  }
104
- b.define("wje-tab-group", b);
123
+ v.define("wje-tab-group", v);
105
124
  export {
106
- b as default
125
+ v as default
107
126
  };
package/dist/wje-tab.js CHANGED
@@ -50,7 +50,7 @@ class i extends b {
50
50
  * Sets up the event listeners after the component is drawn.
51
51
  */
52
52
  afterDraw() {
53
- c.addListener(this, "click", "wje:tab-change");
53
+ c.addListener(this, "click", "wje-tab:change");
54
54
  }
55
55
  }
56
56
  i.define("wje-tab", i);
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.50",
4
+ "version": "0.1.51",
5
5
  "homepage": "https://github.com/lencys/wj-elements",
6
6
  "author": "Lukáš Ondrejček <lukas.ondrejcek@gmail.com>",
7
7
  "license": "MIT",