@sbb-esta/lyne-elements 1.15.1 → 1.16.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.
- package/README.md +6 -6
- package/core/styles/scrollbar.scss +44 -0
- package/core/styles/standard-theme.scss +1 -0
- package/custom-elements.json +20 -0
- package/development/form-field/form-field/form-field.d.ts +2 -0
- package/development/form-field/form-field/form-field.d.ts.map +1 -1
- package/development/form-field/form-field.js +44 -4
- package/development/tabs/tab-group/tab-group.d.ts.map +1 -1
- package/development/tabs/tab-group.js +7 -2
- package/form-field/form-field/form-field.d.ts +2 -0
- package/form-field/form-field/form-field.d.ts.map +1 -1
- package/form-field/form-field.js +155 -132
- package/package.json +13 -5
- package/scrollbar.css +158 -0
- package/standard-theme.css +159 -0
- package/table.css +217 -0
- package/tabs/tab-group/tab-group.d.ts.map +1 -1
- package/tabs/tab-group.js +62 -60
package/tabs/tab-group.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
throw TypeError(
|
|
1
|
+
var S = (a) => {
|
|
2
|
+
throw TypeError(a);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var y = (
|
|
4
|
+
var I = (a, r, l) => r.has(a) || S("Cannot " + l);
|
|
5
|
+
var y = (a, r, l) => (I(a, r, "read from private field"), l ? l.call(a) : r.get(a)), z = (a, r, l) => r.has(a) ? S("Cannot add the same private member more than once") : r instanceof WeakSet ? r.add(a) : r.set(a, l), _ = (a, r, l, c) => (I(a, r, "write to private field"), c ? c.call(a, l) : r.set(a, l), l);
|
|
6
6
|
import { __runInitializers as h, __esDecorate as m } from "tslib";
|
|
7
7
|
import { MutationController as w } from "@lit-labs/observers/mutation-controller.js";
|
|
8
8
|
import { ResizeController as E } from "@lit-labs/observers/resize-controller.js";
|
|
@@ -20,7 +20,7 @@ const F = k`*,:before,:after{box-sizing:border-box}:host{--sbb-tab-group-animati
|
|
|
20
20
|
};
|
|
21
21
|
let B = 0, ot = (() => {
|
|
22
22
|
var b, d;
|
|
23
|
-
let
|
|
23
|
+
let a = [$("sbb-tab-group")], r, l = [], c, p = U(R), v = [], g, A, x = [], T = [];
|
|
24
24
|
var f = (d = class extends p {
|
|
25
25
|
constructor() {
|
|
26
26
|
super(...arguments);
|
|
@@ -38,15 +38,16 @@ let B = 0, ot = (() => {
|
|
|
38
38
|
skipInitial: !0,
|
|
39
39
|
callback: (t) => this._onTabContentElementResize(t)
|
|
40
40
|
}), this._size = "l", _(this, b, h(this, x, 0)), this._selectedTabChanged = (h(this, T), new j(this, f.events.didChange)), this._onContentSlotChange = () => {
|
|
41
|
+
var i, e;
|
|
41
42
|
this._tabContentElement = this.shadowRoot.querySelector("div.tab-content");
|
|
42
|
-
const t = this._getTabs().filter((
|
|
43
|
-
t.length && (t.forEach((
|
|
43
|
+
const t = this._getTabs().filter((s) => !this._tabs.includes(s));
|
|
44
|
+
t.length && (t.forEach((s) => this._configure(s)), this._tabs = this._tabs.concat(t), (e = (i = t.find((s) => s.active)) == null ? void 0 : i.tabGroupActions) == null || e.select());
|
|
44
45
|
}, this._onTabsSlotChange = () => {
|
|
45
46
|
const t = this._getTabs();
|
|
46
|
-
t.length < this._tabs.length && (this._tabs.filter((
|
|
47
|
-
var
|
|
48
|
-
(
|
|
49
|
-
}), this._tabs = t), this._tabs.forEach((
|
|
47
|
+
t.length < this._tabs.length && (this._tabs.filter((e) => !t.includes(e)).forEach((e) => {
|
|
48
|
+
var s;
|
|
49
|
+
(s = e.tab) == null || s.remove();
|
|
50
|
+
}), this._tabs = t), this._tabs.forEach((i) => i.setAttribute("data-size", this.size));
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
53
|
/** Size variant, either s, l or xl. */
|
|
@@ -69,34 +70,34 @@ let B = 0, ot = (() => {
|
|
|
69
70
|
connectedCallback() {
|
|
70
71
|
super.connectedCallback();
|
|
71
72
|
const t = this._abort.signal;
|
|
72
|
-
this.addEventListener("keydown", (
|
|
73
|
+
this.addEventListener("keydown", (i) => this._handleKeyDown(i), { signal: t });
|
|
73
74
|
}
|
|
74
75
|
firstUpdated(t) {
|
|
75
|
-
super.firstUpdated(t), this._tabs = this._getTabs(), this._tabs.forEach((
|
|
76
|
+
super.firstUpdated(t), this._tabs = this._getTabs(), this._tabs.forEach((i) => this._configure(i)), this._initSelection(), this._tabGroupResizeObserver.observe(this._tabGroupElement);
|
|
76
77
|
}
|
|
77
78
|
/**
|
|
78
79
|
* Disables a tab by index.
|
|
79
80
|
* @param tabIndex The index of the tab you want to disable.
|
|
80
81
|
*/
|
|
81
82
|
disableTab(t) {
|
|
82
|
-
var
|
|
83
|
-
(
|
|
83
|
+
var i, e;
|
|
84
|
+
(e = (i = this._tabs[t]) == null ? void 0 : i.tabGroupActions) == null || e.disable();
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
86
87
|
* Enables a tab by index.
|
|
87
88
|
* @param tabIndex The index of the tab you want to enable.
|
|
88
89
|
*/
|
|
89
90
|
enableTab(t) {
|
|
90
|
-
var
|
|
91
|
-
(
|
|
91
|
+
var i, e;
|
|
92
|
+
(e = (i = this._tabs[t]) == null ? void 0 : i.tabGroupActions) == null || e.enable();
|
|
92
93
|
}
|
|
93
94
|
/**
|
|
94
95
|
* Activates a tab by index.
|
|
95
96
|
* @param tabIndex The index of the tab you want to activate.
|
|
96
97
|
*/
|
|
97
98
|
activateTab(t) {
|
|
98
|
-
var
|
|
99
|
-
(
|
|
99
|
+
var i, e;
|
|
100
|
+
(e = (i = this._tabs[t]) == null ? void 0 : i.tabGroupActions) == null || e.select();
|
|
100
101
|
}
|
|
101
102
|
_getTabs() {
|
|
102
103
|
return Array.from(this.children ?? []).filter((t) => /^sbb-tab-label$/u.test(t.localName));
|
|
@@ -112,77 +113,78 @@ let B = 0, ot = (() => {
|
|
|
112
113
|
return `sbb-tab-panel-${++B}`;
|
|
113
114
|
}
|
|
114
115
|
_initSelection() {
|
|
115
|
-
var t,
|
|
116
|
-
this.initialSelectedIndex >= 0 && this.initialSelectedIndex < this._tabs.length && !this._tabs[this.initialSelectedIndex].disabled ? (t = this._tabs[this.initialSelectedIndex].tabGroupActions) == null || t.select() : (
|
|
116
|
+
var t, i, e;
|
|
117
|
+
this.initialSelectedIndex >= 0 && this.initialSelectedIndex < this._tabs.length && !this._tabs[this.initialSelectedIndex].disabled ? (t = this._tabs[this.initialSelectedIndex].tabGroupActions) == null || t.select() : (e = (i = this._enabledTabs()[0]) == null ? void 0 : i.tabGroupActions) == null || e.select();
|
|
117
118
|
}
|
|
118
119
|
_onTabAttributesChange(t) {
|
|
119
|
-
var
|
|
120
|
-
for (const
|
|
121
|
-
if (
|
|
120
|
+
var i, e, s;
|
|
121
|
+
for (const n of t) {
|
|
122
|
+
if (n.type !== "attributes")
|
|
122
123
|
return;
|
|
123
|
-
const o =
|
|
124
|
-
|
|
124
|
+
const o = n.target;
|
|
125
|
+
n.attributeName === "disabled" && (o.hasAttribute("disabled") && o !== this._selectedTab ? (i = o.tabGroupActions) == null || i.disable() : o.disabled && ((e = o.tabGroupActions) == null || e.enable())), n.attributeName === "active" && (o.hasAttribute("active") && !o.disabled ? (s = o.tabGroupActions) == null || s.select() : o === this._selectedTab && o.toggleAttribute("active", !0));
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
_onTabGroupElementResize(t) {
|
|
128
|
-
for (const
|
|
129
|
-
const
|
|
130
|
-
for (const
|
|
131
|
-
|
|
129
|
+
for (const i of t) {
|
|
130
|
+
const e = i.target.firstElementChild.assignedElements();
|
|
131
|
+
for (const s of e)
|
|
132
|
+
s.toggleAttribute("data-has-divider", s === e[0] || s.offsetLeft === e[0].offsetLeft), this.style.setProperty("--sbb-tab-group-width", `${this._tabGroupElement.clientWidth}px`);
|
|
132
133
|
}
|
|
133
134
|
}
|
|
134
135
|
_onTabContentElementResize(t) {
|
|
135
|
-
|
|
136
|
-
const i
|
|
137
|
-
|
|
138
|
-
|
|
136
|
+
if (this._tabContentElement)
|
|
137
|
+
for (const i of t) {
|
|
138
|
+
const e = Math.floor(i.contentRect.height);
|
|
139
|
+
this._tabContentElement.style.height = `${e}px`;
|
|
140
|
+
}
|
|
139
141
|
}
|
|
140
142
|
_configure(t) {
|
|
141
|
-
var
|
|
143
|
+
var i;
|
|
142
144
|
t.tabGroupActions = {
|
|
143
145
|
activate: () => {
|
|
144
|
-
var
|
|
145
|
-
t.toggleAttribute("active", !0), t.active = !0, t.tabIndex = 0, t.setAttribute("aria-selected", "true"), (
|
|
146
|
+
var e;
|
|
147
|
+
t.toggleAttribute("active", !0), t.active = !0, t.tabIndex = 0, t.setAttribute("aria-selected", "true"), (e = t.tab) == null || e.toggleAttribute("active", !0);
|
|
146
148
|
},
|
|
147
149
|
deactivate: () => {
|
|
148
|
-
var
|
|
149
|
-
t.removeAttribute("active"), t.active = !1, t.tabIndex = -1, t.setAttribute("aria-selected", "false"), (
|
|
150
|
+
var e;
|
|
151
|
+
t.removeAttribute("active"), t.active = !1, t.tabIndex = -1, t.setAttribute("aria-selected", "false"), (e = t.tab) == null || e.removeAttribute("active");
|
|
150
152
|
},
|
|
151
153
|
disable: () => {
|
|
152
|
-
var
|
|
153
|
-
t.disabled || (t.hasAttribute("disabled") || t.toggleAttribute("disabled", !0), t.disabled = !0, t.tabIndex = -1, t.setAttribute("aria-selected", "false"), (
|
|
154
|
+
var e, s, n;
|
|
155
|
+
t.disabled || (t.hasAttribute("disabled") || t.toggleAttribute("disabled", !0), t.disabled = !0, t.tabIndex = -1, t.setAttribute("aria-selected", "false"), (e = t.tab) == null || e.removeAttribute("active"), t.active && (t.removeAttribute("active"), t.active = !1, (n = (s = this._enabledTabs()[0]) == null ? void 0 : s.tabGroupActions) == null || n.select()));
|
|
154
156
|
},
|
|
155
157
|
enable: () => {
|
|
156
158
|
t.disabled && (t.removeAttribute("disabled"), t.disabled = !1);
|
|
157
159
|
},
|
|
158
160
|
select: () => {
|
|
159
|
-
var
|
|
161
|
+
var e, s;
|
|
160
162
|
if (t !== this._selectedTab && !t.disabled) {
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
+
const n = this._selectedTab;
|
|
164
|
+
n && ((e = n.tabGroupActions) == null || e.deactivate(), this._tabContentResizeObserver.unobserve(n.tab)), (s = t.tabGroupActions) == null || s.activate(), this._selectedTab = t, this._tabContentResizeObserver.observe(t.tab);
|
|
163
165
|
const o = this._tabs;
|
|
164
166
|
this._selectedTabChanged.emit({
|
|
165
167
|
activeIndex: o.findIndex((u) => u === t),
|
|
166
168
|
activeTabLabel: t,
|
|
167
169
|
activeTab: t.tab,
|
|
168
|
-
previousIndex: o.findIndex((u) => u ===
|
|
169
|
-
previousTabLabel:
|
|
170
|
-
previousTab:
|
|
170
|
+
previousIndex: o.findIndex((u) => u === n),
|
|
171
|
+
previousTabLabel: n,
|
|
172
|
+
previousTab: n == null ? void 0 : n.tab
|
|
171
173
|
});
|
|
172
174
|
}
|
|
173
175
|
}
|
|
174
|
-
}, ((
|
|
175
|
-
var
|
|
176
|
-
(
|
|
176
|
+
}, ((i = t.nextElementSibling) == null ? void 0 : i.localName) === "sbb-tab" && (t.tab = t.nextElementSibling, t.tab.id = this._assignId(), t.tab instanceof q && (t.tab.tabIndex = 0, t.tab.configure())), t.tabIndex = -1, t.disabled = t.hasAttribute("disabled"), t.active = t.hasAttribute("active") && !t.disabled, t.setAttribute("role", "tab"), t.setAttribute("aria-selected", String(t.active)), t.addEventListener("click", () => {
|
|
177
|
+
var e;
|
|
178
|
+
(e = t.tabGroupActions) == null || e.select();
|
|
177
179
|
}), t.tab && (t.setAttribute("aria-controls", t.tab.id), t.tab.setAttribute("role", "tabpanel"), t.tab.toggleAttribute("active", t.active)), this._tabAttributeObserver.observe(t), t.slot = "tab-bar";
|
|
178
180
|
}
|
|
179
181
|
_handleKeyDown(t) {
|
|
180
|
-
var
|
|
181
|
-
const
|
|
182
|
-
if (!(!
|
|
182
|
+
var e, s, n;
|
|
183
|
+
const i = this._enabledTabs();
|
|
184
|
+
if (!(!i || // don't trap nested handling
|
|
183
185
|
t.target !== this && t.target.parentElement !== this) && N(t)) {
|
|
184
|
-
const o =
|
|
185
|
-
(
|
|
186
|
+
const o = i.findIndex((G) => G.active), u = K(t, o, i.length);
|
|
187
|
+
(s = (e = i[u]) == null ? void 0 : e.tabGroupActions) == null || s.select(), (n = i[u]) == null || n.focus(), t.preventDefault();
|
|
186
188
|
}
|
|
187
189
|
}
|
|
188
190
|
render() {
|
|
@@ -202,11 +204,11 @@ let B = 0, ot = (() => {
|
|
|
202
204
|
}
|
|
203
205
|
}, b = new WeakMap(), c = d, (() => {
|
|
204
206
|
const t = typeof Symbol == "function" && Symbol.metadata ? Object.create(p[Symbol.metadata] ?? null) : void 0;
|
|
205
|
-
g = [C()], A = [P(), C({ attribute: "initial-selected-index", type: Number })], m(d, null, g, { kind: "setter", name: "size", static: !1, private: !1, access: { has: (
|
|
206
|
-
|
|
207
|
-
} }, metadata: t }, null, v), m(d, null, A, { kind: "accessor", name: "initialSelectedIndex", static: !1, private: !1, access: { has: (
|
|
208
|
-
|
|
209
|
-
} }, metadata: t }, x, T), m(null, r = { value: c },
|
|
207
|
+
g = [C()], A = [P(), C({ attribute: "initial-selected-index", type: Number })], m(d, null, g, { kind: "setter", name: "size", static: !1, private: !1, access: { has: (i) => "size" in i, set: (i, e) => {
|
|
208
|
+
i.size = e;
|
|
209
|
+
} }, metadata: t }, null, v), m(d, null, A, { kind: "accessor", name: "initialSelectedIndex", static: !1, private: !1, access: { has: (i) => "initialSelectedIndex" in i, get: (i) => i.initialSelectedIndex, set: (i, e) => {
|
|
210
|
+
i.initialSelectedIndex = e;
|
|
211
|
+
} }, metadata: t }, x, T), m(null, r = { value: c }, a, { kind: "class", name: c.name, metadata: t }, null, l), f = c = r.value, t && Object.defineProperty(c, Symbol.metadata, { enumerable: !0, configurable: !0, writable: !0, value: t });
|
|
210
212
|
})(), d.styles = F, d.events = {
|
|
211
213
|
didChange: "didChange"
|
|
212
214
|
}, h(c, l), d);
|