@sbb-esta/lyne-elements 0.52.0 → 0.52.1
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/accordion.js +54 -54
- package/action-group.js +3 -3
- package/alert/alert-group.js +22 -22
- package/alert/alert.js +22 -22
- package/autocomplete.js +126 -126
- package/breadcrumb/breadcrumb-group/breadcrumb-group.d.ts.map +1 -1
- package/breadcrumb/breadcrumb-group.js +70 -69
- package/breadcrumb/breadcrumb.js +17 -17
- package/calendar.js +423 -423
- package/card/card-badge.js +17 -17
- package/card/card.js +2 -2
- package/card/common.js +30 -30
- package/checkbox/checkbox-group.js +17 -17
- package/checkbox/checkbox.js +34 -34
- package/clock.js +83 -83
- package/container/sticky-bar.js +16 -16
- package/core/a11y.js +91 -91
- package/core/base-elements.js +87 -88
- package/core/controllers.js +40 -40
- package/core/datetime.js +34 -36
- package/core/dom.js +26 -26
- package/core/eventing.js +33 -33
- package/core/mixins.js +122 -122
- package/core/overlay/overlay.d.ts.map +1 -1
- package/core/overlay.js +55 -50
- package/core/testing/event-spy.d.ts +1 -1
- package/core/testing/wait-for-image-ready.d.ts +4 -0
- package/core/testing/wait-for-image-ready.d.ts.map +1 -0
- package/core/testing.d.ts +1 -0
- package/core/testing.d.ts.map +1 -1
- package/core/testing.js +42 -31
- package/custom-elements.json +70 -4
- package/datepicker/common.js +55 -55
- package/datepicker/datepicker-toggle.js +94 -94
- package/datepicker/datepicker.js +144 -144
- package/development/accordion.js +2 -3
- package/development/action-group.js +2 -3
- package/development/alert/alert-group.js +2 -3
- package/development/alert/alert.js +2 -3
- package/development/autocomplete.js +2 -3
- package/development/breadcrumb/breadcrumb-group/breadcrumb-group.d.ts.map +1 -1
- package/development/breadcrumb/breadcrumb-group.js +5 -5
- package/development/breadcrumb/breadcrumb.js +2 -3
- package/development/button/button-link.js +2 -3
- package/development/button/button-static.js +2 -3
- package/development/button/button.js +2 -3
- package/development/button/common.js +2 -3
- package/development/button/mini-button.js +2 -3
- package/development/button/secondary-button-link.js +2 -3
- package/development/button/secondary-button-static.js +2 -3
- package/development/button/secondary-button.js +2 -3
- package/development/button/tertiary-button-link.js +2 -3
- package/development/button/tertiary-button-static.js +2 -3
- package/development/button/tertiary-button.js +2 -3
- package/development/button/transparent-button-link.js +2 -3
- package/development/button/transparent-button-static.js +2 -3
- package/development/button/transparent-button.js +2 -3
- package/development/calendar.js +2 -3
- package/development/card/card-badge.js +2 -3
- package/development/card/card-button.js +2 -3
- package/development/card/card-link.js +2 -3
- package/development/card/card.js +2 -3
- package/development/card/common.js +2 -3
- package/development/checkbox/checkbox-group.js +2 -3
- package/development/checkbox/checkbox.js +2 -3
- package/development/chip.js +2 -3
- package/development/clock.js +2 -3
- package/development/container/container.js +2 -3
- package/development/container/sticky-bar.js +2 -3
- package/development/core/base-elements.js +4 -7
- package/development/core/mixins.js +7 -13
- package/development/core/overlay/overlay.d.ts.map +1 -1
- package/development/core/overlay.js +9 -3
- package/development/core/testing/event-spy.d.ts +1 -1
- package/development/core/testing/wait-for-image-ready.d.ts +4 -0
- package/development/core/testing/wait-for-image-ready.d.ts.map +1 -0
- package/development/core/testing.d.ts +1 -0
- package/development/core/testing.d.ts.map +1 -1
- package/development/core/testing.js +17 -1
- package/development/datepicker/common.js +2 -3
- package/development/datepicker/datepicker-next-day.js +2 -3
- package/development/datepicker/datepicker-previous-day.js +2 -3
- package/development/datepicker/datepicker-toggle.js +2 -3
- package/development/datepicker/datepicker.js +2 -3
- package/development/dialog/dialog-actions.js +2 -3
- package/development/dialog/dialog-content.js +2 -3
- package/development/dialog/dialog-title.js +2 -3
- package/development/dialog/dialog.js +2 -3
- package/development/divider.js +2 -3
- package/development/expansion-panel/expansion-panel-content.js +2 -3
- package/development/expansion-panel/expansion-panel-header.js +2 -3
- package/development/expansion-panel/expansion-panel.js +2 -3
- package/development/file-selector.js +2 -3
- package/development/footer.js +2 -3
- package/development/form-error.js +2 -3
- package/development/form-field/form-field-clear.js +2 -3
- package/development/form-field/form-field.js +2 -3
- package/development/header/common.js +2 -3
- package/development/header/header-button.js +2 -3
- package/development/header/header-link.js +2 -3
- package/development/header/header.js +2 -3
- package/development/icon.js +4 -7
- package/development/image/image.d.ts +12 -3
- package/development/image/image.d.ts.map +1 -1
- package/development/image.js +41 -24
- package/development/journey-header.js +2 -3
- package/development/lead-container.js +2 -3
- package/development/link/block-link-button.js +2 -3
- package/development/link/block-link-static.js +2 -3
- package/development/link/block-link.js +2 -3
- package/development/link/common.js +3 -5
- package/development/link/link-button.js +2 -3
- package/development/link/link-static.js +2 -3
- package/development/link/link.js +2 -3
- package/development/link-list.js +2 -3
- package/development/loading-indicator.js +2 -3
- package/development/logo.js +2 -3
- package/development/map-container.js +2 -3
- package/development/menu/common.js +2 -3
- package/development/menu/menu-button.js +2 -3
- package/development/menu/menu-link.js +2 -3
- package/development/menu/menu.js +2 -3
- package/development/message.js +2 -3
- package/development/navigation/common.js +2 -3
- package/development/navigation/navigation-button.js +2 -3
- package/development/navigation/navigation-link.js +2 -3
- package/development/navigation/navigation-list.js +2 -3
- package/development/navigation/navigation-marker.js +2 -3
- package/development/navigation/navigation-section.js +2 -3
- package/development/navigation/navigation.js +2 -3
- package/development/notification.js +2 -3
- package/development/option/optgroup.js +2 -3
- package/development/option/option.js +2 -3
- package/development/overlay.js +3 -5
- package/development/popover/popover-trigger.js +2 -3
- package/development/popover/popover.js +2 -3
- package/development/radio-button/radio-button-group.js +2 -3
- package/development/radio-button/radio-button.js +2 -3
- package/development/screen-reader-only.js +2 -3
- package/development/select.js +2 -3
- package/development/selection-panel.js +2 -3
- package/development/signet.js +2 -3
- package/development/skiplink-list.js +2 -3
- package/development/slider.js +2 -3
- package/development/status.js +2 -3
- package/development/stepper/step-label.js +2 -3
- package/development/stepper/step.js +2 -3
- package/development/stepper/stepper/stepper.d.ts +1 -1
- package/development/stepper/stepper/stepper.d.ts.map +1 -1
- package/development/stepper/stepper.js +5 -6
- package/development/tabs/tab-group.js +2 -3
- package/development/tabs/tab-title.js +2 -3
- package/development/tag/tag-group.js +2 -3
- package/development/tag/tag.js +2 -3
- package/development/teaser-hero.js +2 -3
- package/development/teaser-paid.js +2 -3
- package/development/teaser.js +2 -3
- package/development/time-input.js +2 -3
- package/development/timetable-occupancy-icon.js +2 -3
- package/development/timetable-occupancy.js +2 -3
- package/development/title.js +3 -5
- package/development/toast.js +2 -3
- package/development/toggle/toggle-option.js +3 -5
- package/development/toggle/toggle.js +2 -3
- package/development/toggle-check.js +10 -3
- package/development/train/train-blocked-passage.js +2 -3
- package/development/train/train-formation.js +2 -3
- package/development/train/train-wagon.js +2 -3
- package/development/train/train.js +2 -3
- package/development/visual-checkbox.js +2 -3
- package/dialog/dialog-title.js +20 -20
- package/dialog/dialog.js +66 -66
- package/expansion-panel/expansion-panel-header.js +20 -20
- package/expansion-panel/expansion-panel.js +60 -60
- package/file-selector.js +91 -91
- package/form-field/form-field-clear.js +12 -12
- package/form-field/form-field.js +111 -111
- package/header/header.js +53 -53
- package/icon.js +107 -107
- package/image/image.d.ts +12 -3
- package/image/image.d.ts.map +1 -1
- package/image.js +118 -105
- package/journey-header.js +29 -29
- package/map-container.js +23 -23
- package/menu/menu.js +91 -91
- package/navigation/common.js +16 -16
- package/navigation/navigation-marker.js +34 -34
- package/navigation/navigation-section.js +83 -83
- package/navigation/navigation.js +87 -87
- package/notification.js +52 -52
- package/option/optgroup.js +45 -45
- package/option/option.js +108 -108
- package/overlay.js +5 -5
- package/package.json +1 -1
- package/popover/popover.js +110 -110
- package/radio-button/radio-button-group.js +93 -93
- package/radio-button/radio-button.js +84 -84
- package/select.js +178 -178
- package/selection-panel.js +44 -44
- package/slider.js +58 -58
- package/status.js +6 -6
- package/stepper/step-label.js +19 -19
- package/stepper/step.js +31 -31
- package/stepper/stepper/stepper.d.ts +1 -1
- package/stepper/stepper/stepper.d.ts.map +1 -1
- package/stepper/stepper.js +48 -48
- package/tabs/tab-group.js +67 -67
- package/tag/tag-group.js +8 -8
- package/tag/tag.js +27 -27
- package/teaser-paid.js +12 -12
- package/time-input.js +73 -73
- package/timetable-occupancy-icon.js +26 -26
- package/timetable-occupancy.js +9 -9
- package/toast.js +38 -38
- package/toggle/toggle-option.js +33 -33
- package/toggle/toggle.js +46 -46
- package/toggle-check.js +14 -14
- package/train/train-formation.js +36 -37
- package/train/train-wagon.js +30 -30
- package/train/train.js +13 -13
package/header/header.js
CHANGED
|
@@ -1,59 +1,59 @@
|
|
|
1
1
|
import { css as h, LitElement as c, isServer as b, html as f } from "lit";
|
|
2
|
-
import { property as
|
|
2
|
+
import { property as l, state as v, customElement as u } from "lit/decorators.js";
|
|
3
3
|
import { SbbFocusVisibleWithinController as m } from "../core/a11y.js";
|
|
4
4
|
import { findReferencedElement as p } from "../core/dom.js";
|
|
5
5
|
import { SbbHydrationMixin as g } from "../core/mixins.js";
|
|
6
6
|
import "../logo.js";
|
|
7
|
-
const
|
|
8
|
-
var
|
|
9
|
-
for (var
|
|
10
|
-
(
|
|
11
|
-
return
|
|
7
|
+
const w = h`*,:before,:after{box-sizing:border-box}:host{--sbb-logo-height: 1rem;--sbb-header-position: fixed;--sbb-header-transition-duration: var( --sbb-disable-animation-zero-time, var(--sbb-animation-duration-6x) );--sbb-header-inset-inline-end: 0;display:block;height:var(--sbb-header-height)}@media (min-width: 52.5rem){:host{--sbb-logo-height: 1.25rem}}:host([hide-on-scroll]){--sbb-header-position: absolute}:host([hide-on-scroll][data-fixed]){--sbb-header-position: fixed;--sbb-header-animation-name: hide;--sbb-header-transform: translate3d(0, -100%, 0);--sbb-header-inset-inline-end: var(--sbb-scrollbar-width, 0)}:host([hide-on-scroll][data-fixed][data-animated]){--sbb-header-transition-timing: cubic-bezier(.4, 0, 1, 1)}:host([hide-on-scroll][data-fixed][data-visible]){--sbb-header-animation-name: show;--sbb-header-transform: translate3d(0, 0, 0);--sbb-header-transition-timing: cubic-bezier(0, 0, .2, 1)}:host([hide-on-scroll][data-fixed][data-has-visible-focus-within]){--sbb-header-transition-duration: 0;--sbb-header-transform: translate3d(0, 0, 0)}.sbb-header{position:var(--sbb-header-position);inset:0 var(--sbb-header-inset-inline-end) auto 0;background:var(--sbb-color-white);z-index:var(--sbb-header-z-index, 10);transform:var(--sbb-header-transform);transition-property:box-shadow;transition-duration:var(--sbb-header-transition-duration);transition-timing-function:var(--sbb-header-transition-timing);animation-name:var(--sbb-header-animation-name);animation-duration:var(--sbb-header-transition-duration);animation-timing-function:var(--sbb-header-transition-timing)}:host(:is([data-shadow],[data-has-visible-focus-within][data-fixed])) .sbb-header{box-shadow:var(--sbb-shadow-elevation-level-9-shadow-2-offset-x) var(--sbb-shadow-elevation-level-9-shadow-2-offset-y) var(--sbb-shadow-elevation-level-9-shadow-2-blur) var(--sbb-shadow-elevation-level-9-shadow-2-spread) var(--sbb-shadow-elevation-level-9-soft-2-color),var(--sbb-shadow-elevation-level-9-shadow-1-offset-x) var(--sbb-shadow-elevation-level-9-shadow-1-offset-y) var(--sbb-shadow-elevation-level-9-shadow-1-blur) var(--sbb-shadow-elevation-level-9-shadow-1-spread) var(--sbb-shadow-elevation-level-9-soft-1-color)}@media (forced-colors: active){.sbb-header{border-block-end:var(--sbb-border-width-1x) solid CanvasText}}.sbb-header__wrapper{display:flex;align-items:center;justify-content:flex-start;height:var(--sbb-header-height)}:host(:not([expanded])) .sbb-header__wrapper{padding-inline:var(--sbb-layout-base-offset-responsive);margin-inline:auto;width:100%}@media (min-width: 90rem){:host(:not([expanded])) .sbb-header__wrapper{max-width:calc(var(--sbb-layout-base-page-max-width) + 2 * var(--sbb-layout-base-offset-responsive))}}:host([expanded]) .sbb-header__wrapper{padding-inline:var(--sbb-spacing-responsive-xxs)}.sbb-header__logo{flex:0 0 auto;margin-inline-start:auto;padding-inline-start:var(--sbb-spacing-responsive-s)}::slotted(:is(sbb-header-button,sbb-header-link):first-child){margin-inline-start:var(--sbb-header-first-item-margin-inline-start)}::slotted(*){flex:0 0 auto}::slotted(.sbb-header-shrinkable){flex-shrink:1;min-width:0}::slotted(.sbb-header-spacer){flex-grow:1}::slotted(a[slot=logo]){display:block;padding-block:var(--sbb-spacing-fixed-3x);position:relative;outline:none!important}::slotted(a[slot=logo]):before{content:"";display:block;position:absolute;inset:var(--sbb-spacing-fixed-3x) 0}::slotted(a[slot=logo]:focus-visible:not([data-focus-origin=mouse],[data-focus-origin=touch])):before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) solid var(--sbb-focus-outline-width);outline-offset:var(--sbb-spacing-fixed-3x);border-radius:1px}@keyframes show{0%{transform:translate3d(0,-100%,0)}to{transform:translateZ(0)}}@keyframes hide{0%{transform:translateZ(0)}to{transform:translate3d(0,-100%,0)}}`;
|
|
8
|
+
var x = Object.defineProperty, y = Object.getOwnPropertyDescriptor, r = (e, t, s, a) => {
|
|
9
|
+
for (var i = a > 1 ? void 0 : a ? y(t, s) : t, n = e.length - 1, d; n >= 0; n--)
|
|
10
|
+
(d = e[n]) && (i = (a ? d(t, s, i) : d(i)) || i);
|
|
11
|
+
return a && i && x(t, s, i), i;
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
let
|
|
13
|
+
const _ = "[aria-controls][aria-expanded='true']";
|
|
14
|
+
let o = class extends g(c) {
|
|
15
15
|
constructor() {
|
|
16
|
-
super(...arguments), this.expanded = !1, this.
|
|
16
|
+
super(...arguments), this.expanded = !1, this.b = b ? null : document, this.hideOnScroll = !1, this.f = !0, this.d = 0;
|
|
17
17
|
}
|
|
18
18
|
set scrollOrigin(e) {
|
|
19
|
-
const t = this.
|
|
20
|
-
this.
|
|
19
|
+
const t = this.b;
|
|
20
|
+
this.b = e, this.i(this.b, t);
|
|
21
21
|
}
|
|
22
22
|
get scrollOrigin() {
|
|
23
|
-
return this.
|
|
23
|
+
return this.b;
|
|
24
24
|
}
|
|
25
|
-
|
|
25
|
+
i(e, t) {
|
|
26
26
|
if (e !== t) {
|
|
27
|
-
this.
|
|
28
|
-
const s = this.
|
|
29
|
-
this.
|
|
27
|
+
this.h(e);
|
|
28
|
+
const s = this.e("scrollTop");
|
|
29
|
+
this.d = s <= 0 ? 0 : s;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
/** If `hideOnScroll` is set, checks the element to hook the listener on, and possibly add it.*/
|
|
33
33
|
connectedCallback() {
|
|
34
|
-
super.connectedCallback(), this.
|
|
34
|
+
super.connectedCallback(), this.h(this.scrollOrigin), new m(this);
|
|
35
35
|
}
|
|
36
36
|
/** Removes the scroll listener, if previously attached. */
|
|
37
37
|
disconnectedCallback() {
|
|
38
38
|
var e;
|
|
39
|
-
super.disconnectedCallback(), (e = this.
|
|
39
|
+
super.disconnectedCallback(), (e = this.c) == null || e.abort();
|
|
40
40
|
}
|
|
41
41
|
/** Sets the value of `_scrollElement` and `_scrollFunction` and possibly adds the function on the correct element. */
|
|
42
|
-
|
|
42
|
+
h(e) {
|
|
43
43
|
var t, s;
|
|
44
|
-
(t = this.
|
|
44
|
+
(t = this.c) == null || t.abort(), this.c = new AbortController(), this.a = p(e) || (b ? null : document), this.g = this.j.bind(this), (s = this.a) == null || s.addEventListener("scroll", this.g, {
|
|
45
45
|
passive: !0,
|
|
46
|
-
signal: this.
|
|
46
|
+
signal: this.c.signal
|
|
47
47
|
});
|
|
48
48
|
}
|
|
49
49
|
/** Returns the correct function to attach on scroll. */
|
|
50
|
-
|
|
51
|
-
return this.hideOnScroll ? this.
|
|
50
|
+
j() {
|
|
51
|
+
return this.hideOnScroll ? this.k() : this.l();
|
|
52
52
|
}
|
|
53
53
|
/** Returns the requested property of the scrollContext. */
|
|
54
|
-
|
|
54
|
+
e(e) {
|
|
55
55
|
var t;
|
|
56
|
-
return this.
|
|
56
|
+
return this.a instanceof Document ? this.a.documentElement[e] || this.a.body[e] : ((t = this.a) == null ? void 0 : t[e]) || 0;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* Sets the correct value for `scrollTop`, then:
|
|
@@ -61,27 +61,27 @@ let i = class extends g(c) {
|
|
|
61
61
|
* - hides the header, remove the shadow and possibly close any open menu on the header if it is not visible anymore;
|
|
62
62
|
* - shows the header and re-apply the shadow if the element/document has been scrolled up.
|
|
63
63
|
*/
|
|
64
|
-
|
|
65
|
-
const e = this.
|
|
66
|
-
this.
|
|
64
|
+
k() {
|
|
65
|
+
const e = this.e("scrollTop");
|
|
66
|
+
this.e("scrollHeight") - window.innerHeight - e <= 0 || (this.toggleAttribute("data-shadow", e !== 0), e > this.offsetHeight && e > 0 && this.d < e && this.m(), e > this.offsetHeight * 2 ? (this.f = !1, e > 0 && this.d < e ? ["data-shadow", "data-visible"].forEach((t) => this.removeAttribute(t)) : ["data-fixed", "data-shadow", "data-animated", "data-visible"].forEach(
|
|
67
67
|
(t) => this.toggleAttribute(t, !0)
|
|
68
|
-
)) : (e === 0 && (this.
|
|
68
|
+
)) : (e === 0 && (this.f = !0), this.f && ["data-shadow", "data-animated", "data-fixed", "data-visible"].forEach(
|
|
69
69
|
(t) => this.removeAttribute(t)
|
|
70
|
-
)), this.
|
|
70
|
+
)), this.d = e <= 0 ? 0 : e);
|
|
71
71
|
}
|
|
72
72
|
/** Apply the shadow if the element/document has been scrolled down. */
|
|
73
|
-
|
|
74
|
-
this.toggleAttribute("data-shadow", this.
|
|
73
|
+
l() {
|
|
74
|
+
this.toggleAttribute("data-shadow", this.e("scrollTop") !== 0);
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
m() {
|
|
77
77
|
if (this.hasAttribute("data-has-visible-focus-within"))
|
|
78
78
|
return;
|
|
79
79
|
const e = Array.from(
|
|
80
|
-
this.querySelectorAll(
|
|
80
|
+
this.querySelectorAll(_)
|
|
81
81
|
);
|
|
82
82
|
for (const t of e) {
|
|
83
|
-
const s = t.getAttribute("aria-controls"),
|
|
84
|
-
typeof (
|
|
83
|
+
const s = t.getAttribute("aria-controls"), a = document.getElementById(s);
|
|
84
|
+
typeof (a == null ? void 0 : a.close) == "function" && a.close();
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
render() {
|
|
@@ -99,22 +99,22 @@ let i = class extends g(c) {
|
|
|
99
99
|
`;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
],
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
],
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
],
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
],
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
],
|
|
102
|
+
o.styles = w;
|
|
103
|
+
r([
|
|
104
|
+
l({ reflect: !0, type: Boolean })
|
|
105
|
+
], o.prototype, "expanded", 2);
|
|
106
|
+
r([
|
|
107
|
+
l({ attribute: "scroll-origin" })
|
|
108
|
+
], o.prototype, "scrollOrigin", 1);
|
|
109
|
+
r([
|
|
110
|
+
l({ attribute: "hide-on-scroll", reflect: !0, type: Boolean })
|
|
111
|
+
], o.prototype, "hideOnScroll", 2);
|
|
112
|
+
r([
|
|
113
|
+
v()
|
|
114
|
+
], o.prototype, "f", 2);
|
|
115
|
+
o = r([
|
|
116
|
+
u("sbb-header")
|
|
117
|
+
], o);
|
|
118
118
|
export {
|
|
119
|
-
|
|
119
|
+
o as SbbHeaderElement
|
|
120
120
|
};
|
package/icon.js
CHANGED
|
@@ -1,174 +1,174 @@
|
|
|
1
|
-
import { state as g, property as
|
|
2
|
-
import { css as
|
|
3
|
-
import { unsafeHTML as
|
|
1
|
+
import { state as g, property as f, customElement as $ } from "lit/decorators.js";
|
|
2
|
+
import { css as S, LitElement as _, html as d, nothing as p } from "lit";
|
|
3
|
+
import { unsafeHTML as I } from "lit/directives/unsafe-html.js";
|
|
4
4
|
import { until as A } from "lit/directives/until.js";
|
|
5
|
-
import { hostAttributes as
|
|
6
|
-
import { readConfig as
|
|
7
|
-
const
|
|
8
|
-
if (
|
|
9
|
-
if (
|
|
5
|
+
import { hostAttributes as N } from "./core/decorators.js";
|
|
6
|
+
import { readConfig as E } from "./core/config.js";
|
|
7
|
+
const L = (t) => typeof t == "string", w = (t) => {
|
|
8
|
+
if (t.nodeType === 1) {
|
|
9
|
+
if (t.nodeName.toLowerCase() === "script")
|
|
10
10
|
return !1;
|
|
11
|
-
for (let
|
|
12
|
-
const o =
|
|
13
|
-
if (
|
|
11
|
+
for (let e = 0; e < t.attributes.length; e++) {
|
|
12
|
+
const o = t.attributes[e].name;
|
|
13
|
+
if (L(o) && o.toLowerCase().indexOf("on") === 0)
|
|
14
14
|
return !1;
|
|
15
15
|
}
|
|
16
|
-
for (let
|
|
17
|
-
if (!
|
|
16
|
+
for (let e = 0; e < t.childNodes.length; e++)
|
|
17
|
+
if (!w(t.childNodes[e]))
|
|
18
18
|
return !1;
|
|
19
19
|
}
|
|
20
20
|
return !0;
|
|
21
|
-
}, P = (
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
for (let i =
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
return
|
|
28
|
-
}, m = "https://icons.app.sbb.ch/", C = (/* @__PURE__ */ new Map()).set("default", `${m}icons/`).set("picto", `${m}picto/`), v = /* @__PURE__ */ new Map(), O = (
|
|
29
|
-
var
|
|
30
|
-
const
|
|
31
|
-
if (
|
|
21
|
+
}, P = (t, e = !0, o = !1) => {
|
|
22
|
+
const s = document.createElement("div");
|
|
23
|
+
s.innerHTML = t;
|
|
24
|
+
for (let i = s.childNodes.length - 1; i >= 0; i--)
|
|
25
|
+
s.childNodes[i].nodeName.toLowerCase() !== "svg" && s.removeChild(s.childNodes[i]);
|
|
26
|
+
const r = s.firstElementChild;
|
|
27
|
+
return r && r.nodeName.toLowerCase() === "svg" && (o && !r.classList.contains("color-immutable") && r.classList.add("color-immutable"), e === !1 || w(r)) ? s.innerHTML : "";
|
|
28
|
+
}, m = "https://icons.app.sbb.ch/", C = (/* @__PURE__ */ new Map()).set("default", `${m}icons/`).set("picto", `${m}picto/`), v = /* @__PURE__ */ new Map(), O = (t, e, o) => {
|
|
29
|
+
var b;
|
|
30
|
+
const s = E().icon ?? {}, r = ((b = s.namespaces) == null ? void 0 : b.get(t)) ?? C.get(t);
|
|
31
|
+
if (r === void 0)
|
|
32
32
|
throw Error(
|
|
33
|
-
`Unable to find the namespace "${
|
|
33
|
+
`Unable to find the namespace "${t}". Please register your custom namespace.`
|
|
34
34
|
);
|
|
35
|
-
const i = `${
|
|
36
|
-
let
|
|
37
|
-
if (!
|
|
35
|
+
const i = `${r}${e}.svg`;
|
|
36
|
+
let n = v.get(i);
|
|
37
|
+
if (!n)
|
|
38
38
|
if (typeof fetch < "u" && typeof document < "u")
|
|
39
|
-
|
|
40
|
-
namespace:
|
|
41
|
-
name:
|
|
39
|
+
n = (s.interceptor ?? ((l) => l.request()))({
|
|
40
|
+
namespace: t,
|
|
41
|
+
name: e,
|
|
42
42
|
url: i,
|
|
43
43
|
request: () => fetch(i).then((l) => {
|
|
44
44
|
if (l.ok)
|
|
45
45
|
return l.text().then((c) => (c && (c = P(c, o)), c));
|
|
46
|
-
throw new Error("Failed to load icon " +
|
|
46
|
+
throw new Error("Failed to load icon " + t + ":" + e);
|
|
47
47
|
}).catch((l) => {
|
|
48
48
|
throw Error(l);
|
|
49
49
|
})
|
|
50
|
-
}), v.set(i,
|
|
50
|
+
}), v.set(i, n);
|
|
51
51
|
else
|
|
52
52
|
return Promise.resolve("");
|
|
53
|
-
return
|
|
54
|
-
}, x =
|
|
55
|
-
var z = Object.defineProperty, M = Object.getOwnPropertyDescriptor,
|
|
56
|
-
for (var
|
|
57
|
-
(
|
|
58
|
-
return
|
|
53
|
+
return n;
|
|
54
|
+
}, x = S`*,:before,:after{box-sizing:border-box}:host{display:inline-block;line-height:0;-webkit-tap-highlight-color:transparent}:host([data-empty]){--sbb-icon-default-dimension: 0}:host([data-empty][data-namespace=default][name$=-small]){--sbb-icon-default-dimension: var(--sbb-size-icon-ui-small)}:host([data-empty][data-namespace=default][name$=-medium]){--sbb-icon-default-dimension: var(--sbb-size-icon-ui-medium)}:host([data-empty][data-namespace=default][name$=-large]){--sbb-icon-default-dimension: var(--sbb-size-icon-ui-large)}svg{width:var(--sbb-icon-svg-width, var(--sbb-icon-default-dimension));height:var(--sbb-icon-svg-height, var(--sbb-icon-default-dimension));stroke:var(--sbb-icon-svg-stroke-color);stroke-width:var(--sbb-icon-svg-stroke-width)}svg:not(.color-immutable) [fill]:not([fill=none]){fill:currentcolor}svg:not(.color-immutable) [stroke]:not([stroke=none]){stroke:currentcolor}svg:not(.color-immutable)>:where(path,polygon,polyline):where(:not([stroke]):not([fill])),svg:not(.color-immutable) :where(:not([stroke]):not([fill])) :where(path,polygon,polyline):where(:not([stroke]):not([fill])){fill:currentcolor}`;
|
|
55
|
+
var z = Object.defineProperty, M = Object.getOwnPropertyDescriptor, h = (t, e, o, s) => {
|
|
56
|
+
for (var r = s > 1 ? void 0 : s ? M(e, o) : e, i = t.length - 1, n; i >= 0; i--)
|
|
57
|
+
(n = t[i]) && (r = (s ? n(e, o, r) : n(r)) || r);
|
|
58
|
+
return s && r && z(e, o, r), r;
|
|
59
59
|
};
|
|
60
|
-
let
|
|
60
|
+
let a = class extends _ {
|
|
61
61
|
constructor() {
|
|
62
|
-
super(...arguments), this.
|
|
62
|
+
super(...arguments), this.b = a.a, this.noSanitize = !1;
|
|
63
63
|
}
|
|
64
|
-
async loadSvgIcon(
|
|
65
|
-
if (!
|
|
64
|
+
async loadSvgIcon(t) {
|
|
65
|
+
if (!t)
|
|
66
66
|
return;
|
|
67
|
-
const [
|
|
68
|
-
this.
|
|
69
|
-
const
|
|
70
|
-
this.
|
|
67
|
+
const [e, o] = this.d(t);
|
|
68
|
+
this.b = e, this.setAttribute("data-namespace", this.b);
|
|
69
|
+
const s = this.fetchSvgIcon(this.b, o);
|
|
70
|
+
this.c = s.then((r) => I(r));
|
|
71
71
|
try {
|
|
72
|
-
this.toggleAttribute("data-empty", !await
|
|
72
|
+
this.toggleAttribute("data-empty", !await s);
|
|
73
73
|
} catch {
|
|
74
74
|
this.toggleAttribute("data-empty", !0);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
async fetchSvgIcon(
|
|
78
|
-
return await O(
|
|
77
|
+
async fetchSvgIcon(t, e) {
|
|
78
|
+
return await O(t, e, !this.noSanitize);
|
|
79
79
|
}
|
|
80
|
-
|
|
81
|
-
if (!
|
|
80
|
+
d(t) {
|
|
81
|
+
if (!t)
|
|
82
82
|
return ["", ""];
|
|
83
|
-
const
|
|
84
|
-
switch (
|
|
83
|
+
const e = t.split(":");
|
|
84
|
+
switch (e.length) {
|
|
85
85
|
case 1:
|
|
86
|
-
return [
|
|
86
|
+
return [a.a, e[0]];
|
|
87
87
|
case 2:
|
|
88
|
-
return
|
|
88
|
+
return e;
|
|
89
89
|
default:
|
|
90
|
-
throw Error(`Invalid icon name: "${
|
|
90
|
+
throw Error(`Invalid icon name: "${t}"`);
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
firstUpdated(
|
|
94
|
-
super.firstUpdated(
|
|
93
|
+
firstUpdated(t) {
|
|
94
|
+
super.firstUpdated(t), this.setAttribute("role", this.getAttribute("role") ?? "img");
|
|
95
95
|
}
|
|
96
96
|
render() {
|
|
97
|
-
return
|
|
97
|
+
return d`<span class="sbb-icon-inner"
|
|
98
98
|
>${A(
|
|
99
|
-
this.
|
|
99
|
+
this.c,
|
|
100
100
|
// To reserve space, we need an empty svg to apply dimension to.
|
|
101
|
-
|
|
101
|
+
d`<svg width="0" height="0"></svg>`
|
|
102
102
|
)}</span
|
|
103
103
|
>`;
|
|
104
104
|
}
|
|
105
105
|
};
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
a.styles = x;
|
|
107
|
+
a.a = "default";
|
|
108
|
+
h([
|
|
109
109
|
g()
|
|
110
|
-
],
|
|
111
|
-
|
|
110
|
+
], a.prototype, "b", 2);
|
|
111
|
+
h([
|
|
112
112
|
g()
|
|
113
|
-
],
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
],
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
"data-namespace":
|
|
113
|
+
], a.prototype, "c", 2);
|
|
114
|
+
h([
|
|
115
|
+
f({ attribute: "no-sanitize", type: Boolean })
|
|
116
|
+
], a.prototype, "noSanitize", 2);
|
|
117
|
+
a = h([
|
|
118
|
+
N({
|
|
119
|
+
"data-namespace": a.a,
|
|
120
120
|
"data-empty": ""
|
|
121
121
|
})
|
|
122
|
-
],
|
|
123
|
-
var U = Object.defineProperty, j = Object.getOwnPropertyDescriptor,
|
|
124
|
-
for (var
|
|
125
|
-
(
|
|
126
|
-
return
|
|
122
|
+
], a);
|
|
123
|
+
var U = Object.defineProperty, j = Object.getOwnPropertyDescriptor, y = (t, e, o, s) => {
|
|
124
|
+
for (var r = s > 1 ? void 0 : s ? j(e, o) : e, i = t.length - 1, n; i >= 0; i--)
|
|
125
|
+
(n = t[i]) && (r = (s ? n(e, o, r) : n(r)) || r);
|
|
126
|
+
return s && r && U(e, o, r), r;
|
|
127
127
|
};
|
|
128
|
-
let
|
|
128
|
+
let u = class extends a {
|
|
129
129
|
constructor() {
|
|
130
|
-
super(...arguments), this.
|
|
130
|
+
super(...arguments), this.a = "";
|
|
131
131
|
}
|
|
132
|
-
async fetchSvgIcon(
|
|
133
|
-
return this.getAttribute("aria-label") === this.
|
|
132
|
+
async fetchSvgIcon(t, e) {
|
|
133
|
+
return this.getAttribute("aria-label") === this.a && this.removeAttribute("aria-label"), this.a = `Icon ${e.replace(/-/g, " ")}`, this.getAttribute("aria-hidden") === "false" && !this.hasAttribute("aria-label") && e && this.setAttribute("aria-label", this.a), super.fetchSvgIcon(t, e);
|
|
134
134
|
}
|
|
135
|
-
willUpdate(
|
|
136
|
-
super.willUpdate(
|
|
135
|
+
willUpdate(t) {
|
|
136
|
+
super.willUpdate(t), t.has("name") && this.loadSvgIcon(this.name);
|
|
137
137
|
}
|
|
138
|
-
firstUpdated(
|
|
139
|
-
super.firstUpdated(
|
|
138
|
+
firstUpdated(t) {
|
|
139
|
+
super.firstUpdated(t), this.hasAttribute("aria-hidden") || this.setAttribute("aria-hidden", "true");
|
|
140
140
|
}
|
|
141
141
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
],
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
],
|
|
148
|
-
var T = Object.defineProperty, q = (
|
|
149
|
-
for (var
|
|
150
|
-
(
|
|
151
|
-
return
|
|
142
|
+
y([
|
|
143
|
+
f({ reflect: !0 })
|
|
144
|
+
], u.prototype, "name", 2);
|
|
145
|
+
u = y([
|
|
146
|
+
$("sbb-icon")
|
|
147
|
+
], u);
|
|
148
|
+
var T = Object.defineProperty, q = (t, e, o, s) => {
|
|
149
|
+
for (var r = void 0, i = t.length - 1, n; i >= 0; i--)
|
|
150
|
+
(n = t[i]) && (r = n(e, o, r) || r);
|
|
151
|
+
return r && T(e, o, r), r;
|
|
152
152
|
};
|
|
153
|
-
const J = (
|
|
154
|
-
class
|
|
155
|
-
renderIconSlot(
|
|
156
|
-
return
|
|
153
|
+
const J = (t) => {
|
|
154
|
+
class e extends t {
|
|
155
|
+
renderIconSlot(s) {
|
|
156
|
+
return d`
|
|
157
157
|
<slot name="icon">
|
|
158
|
-
${this.iconName ?
|
|
158
|
+
${this.iconName ? d`<sbb-icon name=${this.iconName} class=${s || p}></sbb-icon>` : p}
|
|
159
159
|
</slot>
|
|
160
160
|
`;
|
|
161
161
|
}
|
|
162
162
|
}
|
|
163
163
|
return q([
|
|
164
|
-
|
|
165
|
-
],
|
|
164
|
+
f({ attribute: "icon-name", reflect: !0 })
|
|
165
|
+
], e.prototype, "iconName"), e;
|
|
166
166
|
};
|
|
167
167
|
export {
|
|
168
|
-
|
|
169
|
-
|
|
168
|
+
a as SbbIconBase,
|
|
169
|
+
u as SbbIconElement,
|
|
170
170
|
J as SbbIconNameMixin,
|
|
171
171
|
O as getSvgContent,
|
|
172
|
-
|
|
172
|
+
w as isValid,
|
|
173
173
|
P as validateContent
|
|
174
174
|
};
|
package/image/image.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ export interface InterfaceImageAttributesSizesConfigMediaQuery {
|
|
|
21
21
|
/**
|
|
22
22
|
* It displays an image.
|
|
23
23
|
*
|
|
24
|
+
* @event {Event} load - Emits when the image has been loaded.
|
|
25
|
+
* @event {Event} error - Emits when the image loading ended in an error.
|
|
24
26
|
* @cssprop [--sbb-image-aspect-ratio=auto] - Can be used to override `aspectRatio` property.
|
|
25
27
|
* This way we can have, for example, an image component with an aspect
|
|
26
28
|
* ratio of 4/3 in smaller viewports and 16/9 in larger viewports.
|
|
@@ -29,6 +31,10 @@ export interface InterfaceImageAttributesSizesConfigMediaQuery {
|
|
|
29
31
|
*/
|
|
30
32
|
export declare class SbbImageElement extends LitElement {
|
|
31
33
|
static styles: CSSResultGroup;
|
|
34
|
+
static readonly events: {
|
|
35
|
+
readonly error: "error";
|
|
36
|
+
readonly load: "load";
|
|
37
|
+
};
|
|
32
38
|
private _captionElement?;
|
|
33
39
|
private _linksInCaption?;
|
|
34
40
|
private _config;
|
|
@@ -217,16 +223,19 @@ export declare class SbbImageElement extends LitElement {
|
|
|
217
223
|
* other values: 'free', '1-1', '1-2', '2-1', '2-3', '3-2', '3-4', '4-3', '4-5', '5-4', '9-16'
|
|
218
224
|
*/
|
|
219
225
|
aspectRatio: 'free' | '1-1' | '1-2' | '2-1' | '2-3' | '3-2' | '3-4' | '4-3' | '4-5' | '5-4' | '9-16' | '16-9';
|
|
226
|
+
/** Whether the image is finished loading or failed to load. */
|
|
227
|
+
get complete(): boolean;
|
|
228
|
+
connectedCallback(): void;
|
|
229
|
+
protected updated(changedProperties: PropertyValues<this>): void;
|
|
230
|
+
protected firstUpdated(changedProperties: PropertyValues<this>): Promise<void>;
|
|
220
231
|
private _logPerformanceMarks;
|
|
221
232
|
private _matchMediaQueryDesignToken;
|
|
222
233
|
private _addFocusAbilityToLinksInCaption;
|
|
223
234
|
private _prepareImageUrl;
|
|
224
235
|
private _preparePictureSizeConfigs;
|
|
225
236
|
private _createMediaQueryString;
|
|
226
|
-
connectedCallback(): void;
|
|
227
|
-
protected render(): TemplateResult;
|
|
228
|
-
protected updated(changedProperties: PropertyValues<this>): void;
|
|
229
237
|
private _imageLoaded;
|
|
238
|
+
protected render(): TemplateResult;
|
|
230
239
|
}
|
|
231
240
|
declare global {
|
|
232
241
|
interface HTMLElementTagNameMap {
|
package/image/image.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/elements/image/image.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,KAAK,cAAc,EAEnB,UAAU,EAEV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAQb,MAAM,WAAW,mCAAmC;IAClD,WAAW,EAAE,6CAA6C,EAAE,CAAC;CAC9D;AAED,MAAM,WAAW,6CAA6C;IAC5D,KAAK,EAAE;QACL,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,YAAY,EAAE,6CAA6C,EAAE,CAAC;CAC/D;AAED,MAAM,WAAW,6CAA6C;IAC5D,gBAAgB,EAAE,MAAM,CAAC;IACzB,qBAAqB,EAAE;QACrB,eAAe,EAAE,OAAO,CAAC;QACzB,KAAK,EAAE,MAAM,CAAC;KACf,CAAC;IACF,iBAAiB,EAAE,KAAK,CAAC;CAC1B;AAkGD
|
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/elements/image/image.ts"],"names":[],"mappings":"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"}
|