@prioticket/design-system-web 1.0.5 → 1.0.7

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,64 +1,54 @@
1
- import { css as u, LitElement as p, html as c } from "lit";
2
- import { property as r, state as m, customElement as h } from "lit/decorators.js";
1
+ import { css as u, LitElement as b, html as l } from "lit";
2
+ import { property as r, state as m, queryAssignedElements as v, customElement as h } from "lit/decorators.js";
3
3
  import "@material/web/tabs/tabs.js";
4
4
  import "@material/web/tabs/primary-tab.js";
5
5
  import "@material/web/tabs/secondary-tab.js";
6
6
  import "@material/web/icon/icon.js";
7
- var v = Object.defineProperty, T = Object.getOwnPropertyDescriptor, o = (t, a, i, s) => {
8
- for (var e = s > 1 ? void 0 : s ? T(a, i) : a, d = t.length - 1, b; d >= 0; d--)
9
- (b = t[d]) && (e = (s ? b(a, i, e) : b(e)) || e);
10
- return s && e && v(a, i, e), e;
7
+ var y = Object.defineProperty, T = Object.getOwnPropertyDescriptor, i = (t, a, e, d) => {
8
+ for (var s = d > 1 ? void 0 : d ? T(a, e) : a, c = t.length - 1, p; c >= 0; c--)
9
+ (p = t[c]) && (s = (d ? p(a, e, s) : p(s)) || s);
10
+ return d && s && y(a, e, s), s;
11
11
  };
12
- let l = class extends p {
12
+ let n = class extends b {
13
13
  constructor() {
14
14
  super(...arguments), this.activeTabIndex = 0, this.autoActivate = !1, this.tabs = [], this.slottedTabs = [];
15
15
  }
16
- connectedCallback() {
17
- super.connectedCallback(), setTimeout(() => this.collectTabsFromSlot(), 0);
18
- }
19
16
  firstUpdated() {
20
- this.collectTabsFromSlot(), this.updateComplete.then(() => this.forceActiveTabUpdate());
17
+ this.updateTabsFromSlot();
21
18
  }
22
- collectTabsFromSlot() {
23
- const t = this.shadowRoot?.querySelector("slot");
24
- if (!t) return;
25
- const a = t.assignedElements({ flatten: !0 }), i = [];
26
- a.forEach((s) => {
27
- if (s.tagName === "PD-TAB") {
28
- const e = s;
29
- i.push({
30
- label: e.textContent?.trim() || "",
31
- icon: e.getAttribute("icon") || void 0,
32
- secondary: e.hasAttribute("secondary"),
33
- inlineIcon: e.hasAttribute("inline-icon"),
34
- ariaLabel: e.getAttribute("aria-label") || void 0
35
- });
36
- }
37
- }), this.slottedTabs = i, this.requestUpdate();
19
+ updateTabsFromSlot() {
20
+ const a = (this.assignedTabs ?? []).map((e) => ({
21
+ label: e.textContent?.trim() || "",
22
+ icon: e.getAttribute("icon") || void 0,
23
+ secondary: e.hasAttribute("secondary"),
24
+ inlineIcon: e.hasAttribute("inline-icon"),
25
+ ariaLabel: e.getAttribute("aria-label") || void 0
26
+ }));
27
+ this.slottedTabs = a, this.requestUpdate(), this.updateComplete.then(() => this.forceActiveTabUpdate());
38
28
  }
39
29
  handleSlotChange() {
40
- this.collectTabsFromSlot(), this.updateComplete.then(() => this.forceActiveTabUpdate());
30
+ this.updateTabsFromSlot();
41
31
  }
42
32
  forceActiveTabUpdate() {
43
33
  const t = this.shadowRoot?.querySelector("md-tabs");
44
34
  t && this.activeTabIndex !== void 0 && (t.activeTabIndex = this.activeTabIndex);
45
35
  }
46
36
  renderTab(t, a) {
47
- const i = t.icon ? c`<md-icon slot="icon">${t.icon}</md-icon>` : "";
48
- return t.secondary ? c`
37
+ const e = t.icon ? l`<md-icon slot="icon">${t.icon}</md-icon>` : "";
38
+ return t.secondary ? l`
49
39
  <md-secondary-tab
50
40
  ?inline-icon=${t.inlineIcon}
51
41
  aria-label=${t.ariaLabel || t.label}
52
42
  >
53
- ${i}
43
+ ${e}
54
44
  ${t.label}
55
45
  </md-secondary-tab>
56
- ` : c`
46
+ ` : l`
57
47
  <md-primary-tab
58
48
  ?inline-icon=${t.inlineIcon}
59
49
  aria-label=${t.ariaLabel || t.label}
60
50
  >
61
- ${i}
51
+ ${e}
62
52
  ${t.label}
63
53
  </md-primary-tab>
64
54
  `;
@@ -68,13 +58,13 @@ let l = class extends p {
68
58
  }
69
59
  render() {
70
60
  const t = this.tabs.length > 0 ? this.tabs : this.slottedTabs;
71
- return c`
61
+ return l`
72
62
  <md-tabs
73
63
  .activeTabIndex=${this.activeTabIndex}
74
64
  ?auto-activate=${this.autoActivate}
75
65
  @change=${this.handleChange}
76
66
  >
77
- ${t.map((a, i) => this.renderTab(a, i))}
67
+ ${t.map((a, e) => this.renderTab(a, e))}
78
68
  </md-tabs>
79
69
  <div style="display: none;">
80
70
  <slot @slotchange=${this.handleSlotChange}></slot>
@@ -90,50 +80,53 @@ let l = class extends p {
90
80
  }));
91
81
  }
92
82
  };
93
- o([
83
+ i([
94
84
  r({ type: Number, attribute: "active-tab-index" })
95
- ], l.prototype, "activeTabIndex", 2);
96
- o([
85
+ ], n.prototype, "activeTabIndex", 2);
86
+ i([
97
87
  r({ type: Boolean, attribute: "auto-activate" })
98
- ], l.prototype, "autoActivate", 2);
99
- o([
88
+ ], n.prototype, "autoActivate", 2);
89
+ i([
100
90
  r({ type: Array })
101
- ], l.prototype, "tabs", 2);
102
- o([
91
+ ], n.prototype, "tabs", 2);
92
+ i([
103
93
  m()
104
- ], l.prototype, "slottedTabs", 2);
105
- l = o([
94
+ ], n.prototype, "slottedTabs", 2);
95
+ i([
96
+ v({ flatten: !0, selector: "pd-tab" })
97
+ ], n.prototype, "assignedTabs", 2);
98
+ n = i([
106
99
  h("pd-tabs")
107
- ], l);
108
- let n = class extends p {
100
+ ], n);
101
+ let o = class extends b {
109
102
  constructor() {
110
103
  super(...arguments), this.secondary = !1, this.inlineIcon = !1, this.icon = "", this.ariaLabel = "";
111
104
  }
112
105
  render() {
113
- return c`<slot></slot>`;
106
+ return l`<slot></slot>`;
114
107
  }
115
108
  };
116
- n.styles = u`
109
+ o.styles = u`
117
110
  :host {
118
111
  display: none;
119
112
  }
120
113
  `;
121
- o([
114
+ i([
122
115
  r({ type: Boolean })
123
- ], n.prototype, "secondary", 2);
124
- o([
116
+ ], o.prototype, "secondary", 2);
117
+ i([
125
118
  r({ type: Boolean, attribute: "inline-icon" })
126
- ], n.prototype, "inlineIcon", 2);
127
- o([
119
+ ], o.prototype, "inlineIcon", 2);
120
+ i([
128
121
  r({ type: String })
129
- ], n.prototype, "icon", 2);
130
- o([
122
+ ], o.prototype, "icon", 2);
123
+ i([
131
124
  r({ type: String, attribute: "aria-label" })
132
- ], n.prototype, "ariaLabel", 2);
133
- n = o([
125
+ ], o.prototype, "ariaLabel", 2);
126
+ o = i([
134
127
  h("pd-tab")
135
- ], n);
128
+ ], o);
136
129
  export {
137
- n as PdTab,
138
- l as PdTabs
130
+ o as PdTab,
131
+ n as PdTabs
139
132
  };