@sbb-esta/lyne-elements 4.5.1 → 4.6.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/calendar/{calendar.component.js → calendar/calendar.component.js} +413 -401
- package/calendar/calendar-day/calendar-day.component.js +98 -0
- package/calendar/calendar-day.js +4 -0
- package/calendar/calendar.js +5 -0
- package/calendar.js +5 -2
- package/core/styles/core.scss +1 -0
- package/core.css +1 -0
- package/custom-elements.json +19029 -18151
- package/datepicker/datepicker/datepicker.component.js +1 -1
- package/development/calendar/{calendar.component.d.ts → calendar/calendar.component.d.ts} +23 -3
- package/development/calendar/calendar/calendar.component.d.ts.map +1 -0
- package/development/calendar/calendar/calendar.component.js +1990 -0
- package/development/calendar/calendar-day/calendar-day.component.d.ts +49 -0
- package/development/calendar/calendar-day/calendar-day.component.d.ts.map +1 -0
- package/development/calendar/calendar-day/calendar-day.component.js +255 -0
- package/development/calendar/calendar-day.d.ts +5 -0
- package/development/calendar/calendar-day.d.ts.map +1 -0
- package/development/calendar/calendar-day.js +5 -0
- package/development/calendar/calendar.d.ts +5 -0
- package/development/calendar/calendar.d.ts.map +1 -0
- package/development/calendar/calendar.js +6 -0
- package/development/calendar.d.ts +2 -1
- package/development/calendar.d.ts.map +1 -1
- package/development/calendar.js +6 -3
- package/development/datepicker/datepicker/datepicker.component.d.ts.map +1 -1
- package/development/datepicker/datepicker/datepicker.component.js +2 -1
- package/development/form-field/form-field/form-field.component.js +7 -5
- package/form-field/form-field/form-field.component.js +11 -11
- package/index.d.ts +3 -1
- package/index.js +3 -1
- package/off-brand-theme.css +1 -0
- package/package.json +11 -1
- package/safety-theme.css +1 -0
- package/standard-theme.css +1 -0
- package/development/calendar/calendar.component.d.ts.map +0 -1
- package/development/calendar/calendar.component.js +0 -1957
|
@@ -1,46 +1,47 @@
|
|
|
1
1
|
var Ce = (o) => {
|
|
2
2
|
throw TypeError(o);
|
|
3
3
|
};
|
|
4
|
-
var
|
|
5
|
-
var A = (o, n, d) => (
|
|
6
|
-
import { __esDecorate as
|
|
7
|
-
import { css as Le, LitElement as
|
|
8
|
-
import { customElement as
|
|
9
|
-
import { classMap as
|
|
10
|
-
import { isArrowKeyOrPageKeysPressed as
|
|
11
|
-
import { readConfig as
|
|
12
|
-
import { SbbLanguageController as
|
|
13
|
-
import { defaultDateAdapter as
|
|
14
|
-
import { forceType as
|
|
15
|
-
import { i18nPreviousMonth as Xe, i18nNextMonth as Ze, i18nYearMonthSelection as et, i18nCalendarWeekNumber as
|
|
16
|
-
import { SbbHydrationMixin as
|
|
17
|
-
import { boxSizingStyles as lt } from "
|
|
18
|
-
import "
|
|
19
|
-
import "
|
|
20
|
-
import "
|
|
21
|
-
|
|
4
|
+
var Se = (o, n, d) => n.has(o) || Ce("Cannot " + d);
|
|
5
|
+
var A = (o, n, d) => (Se(o, n, "read from private field"), d ? d.call(o) : n.get(o)), x = (o, n, d) => n.has(o) ? Ce("Cannot add the same private member more than once") : n instanceof WeakSet ? n.add(o) : n.set(o, d), u = (o, n, d, h) => (Se(o, n, "write to private field"), h ? h.call(o, d) : n.set(o, d), d);
|
|
6
|
+
import { __esDecorate as w, __runInitializers as _ } from "tslib";
|
|
7
|
+
import { css as Le, LitElement as He, isServer as We, nothing as p, html as c } from "lit";
|
|
8
|
+
import { customElement as Be, property as Y, state as Q } from "lit/decorators.js";
|
|
9
|
+
import { classMap as J } from "lit/directives/class-map.js";
|
|
10
|
+
import { isArrowKeyOrPageKeysPressed as qe } from "../../core/a11y.js";
|
|
11
|
+
import { readConfig as Ke } from "../../core/config.js";
|
|
12
|
+
import { SbbLanguageController as Ue, SbbMediaMatcherController as Qe, SbbMediaQueryBreakpointLargeAndAbove as Ie } from "../../core/controllers.js";
|
|
13
|
+
import { defaultDateAdapter as je, YEARS_PER_PAGE as $, DAYS_PER_ROW as y, MONTHS_PER_ROW as j, YEARS_PER_ROW as G, MONTHS_PER_PAGE as Ge } from "../../core/datetime.js";
|
|
14
|
+
import { forceType as X, plainDate as Ne, handleDistinctChange as Je } from "../../core/decorators.js";
|
|
15
|
+
import { i18nPreviousMonth as Xe, i18nNextMonth as Ze, i18nYearMonthSelection as et, i18nCalendarWeekNumber as K, i18nPreviousYear as tt, i18nNextYear as at, i18nCalendarDateSelection as Re, i18nPreviousYearRange as st, i18nNextYearRange as rt } from "../../core/i18n.js";
|
|
16
|
+
import { SbbHydrationMixin as it, SbbElementInternalsMixin as nt } from "../../core/mixins.js";
|
|
17
|
+
import { boxSizingStyles as lt } from "../../core/styles.js";
|
|
18
|
+
import "../../button/secondary-button.js";
|
|
19
|
+
import "../../icon.js";
|
|
20
|
+
import "../../screen-reader-only.js";
|
|
21
|
+
import "../calendar-day/calendar-day.component.js";
|
|
22
|
+
const ot = 6048e5, Te = /* @__PURE__ */ Symbol.for("constructDateFrom");
|
|
22
23
|
function F(o, n) {
|
|
23
|
-
return typeof o == "function" ? o(n) : o && typeof o == "object" &&
|
|
24
|
+
return typeof o == "function" ? o(n) : o && typeof o == "object" && Te in o ? o[Te](n) : o instanceof Date ? new o.constructor(n) : new Date(n);
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function U(o, n) {
|
|
26
27
|
return F(n || o, o);
|
|
27
28
|
}
|
|
28
29
|
function dt(o, n, d) {
|
|
29
|
-
const
|
|
30
|
-
return isNaN(n) ? F(o, NaN) : (n &&
|
|
30
|
+
const h = U(o, d?.in);
|
|
31
|
+
return isNaN(n) ? F(o, NaN) : (n && h.setDate(h.getDate() + n), h);
|
|
31
32
|
}
|
|
32
33
|
let ct = {};
|
|
33
|
-
function
|
|
34
|
+
function Z() {
|
|
34
35
|
return ct;
|
|
35
36
|
}
|
|
36
37
|
function z(o, n) {
|
|
37
|
-
const d =
|
|
38
|
-
return
|
|
38
|
+
const d = Z(), h = n?.weekStartsOn ?? n?.locale?.options?.weekStartsOn ?? d.weekStartsOn ?? d.locale?.options?.weekStartsOn ?? 0, m = U(o, n?.in), v = m.getDay(), V = (v < h ? 7 : 0) + v - h;
|
|
39
|
+
return m.setDate(m.getDate() - V), m.setHours(0, 0, 0, 0), m;
|
|
39
40
|
}
|
|
40
41
|
function ht(o, ...n) {
|
|
41
42
|
const d = F.bind(
|
|
42
43
|
null,
|
|
43
|
-
o || n.find((
|
|
44
|
+
o || n.find((h) => typeof h == "object")
|
|
44
45
|
);
|
|
45
46
|
return n.map(d);
|
|
46
47
|
}
|
|
@@ -48,91 +49,106 @@ function bt(o, n, d) {
|
|
|
48
49
|
return dt(o, n * 7, d);
|
|
49
50
|
}
|
|
50
51
|
function _t(o, n) {
|
|
51
|
-
const d =
|
|
52
|
-
return d.setFullYear(d.getFullYear(),
|
|
52
|
+
const d = U(o, n?.in), h = d.getMonth();
|
|
53
|
+
return d.setFullYear(d.getFullYear(), h + 1, 0), d.setHours(23, 59, 59, 999), d;
|
|
53
54
|
}
|
|
54
55
|
function ut(o, n) {
|
|
55
|
-
const [d,
|
|
56
|
-
return { start: d, end:
|
|
56
|
+
const [d, h] = ht(o, n.start, n.end);
|
|
57
|
+
return { start: d, end: h };
|
|
57
58
|
}
|
|
58
59
|
function ft(o, n) {
|
|
59
|
-
const { start: d, end:
|
|
60
|
-
let
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
const O =
|
|
64
|
-
let
|
|
60
|
+
const { start: d, end: h } = ut(n?.in, o);
|
|
61
|
+
let m = +d > +h;
|
|
62
|
+
const v = z(m ? h : d, n), V = z(m ? d : h, n);
|
|
63
|
+
v.setHours(15), V.setHours(15);
|
|
64
|
+
const O = +V.getTime();
|
|
65
|
+
let D = v, M = n?.step ?? 1;
|
|
65
66
|
if (!M) return [];
|
|
66
|
-
M < 0 && (M = -M,
|
|
67
|
-
const
|
|
68
|
-
for (; +
|
|
69
|
-
|
|
70
|
-
return
|
|
67
|
+
M < 0 && (M = -M, m = !m);
|
|
68
|
+
const C = [];
|
|
69
|
+
for (; +D <= O; )
|
|
70
|
+
D.setHours(0), C.push(F(d, D)), D = bt(D, M), D.setHours(15);
|
|
71
|
+
return m ? C.reverse() : C;
|
|
71
72
|
}
|
|
72
73
|
function gt(o, n) {
|
|
73
|
-
const d =
|
|
74
|
+
const d = U(o, n?.in);
|
|
74
75
|
return d.setDate(1), d.setHours(0, 0, 0, 0), d;
|
|
75
76
|
}
|
|
77
|
+
function mt(o, n) {
|
|
78
|
+
const d = U(o, n?.in), h = d.getFullYear(), m = Z(), v = n?.firstWeekContainsDate ?? n?.locale?.options?.firstWeekContainsDate ?? m.firstWeekContainsDate ?? m.locale?.options?.firstWeekContainsDate ?? 1, V = F(n?.in || o, 0);
|
|
79
|
+
V.setFullYear(h + 1, 0, v), V.setHours(0, 0, 0, 0);
|
|
80
|
+
const O = z(V, n), D = F(n?.in || o, 0);
|
|
81
|
+
D.setFullYear(h, 0, v), D.setHours(0, 0, 0, 0);
|
|
82
|
+
const M = z(D, n);
|
|
83
|
+
return +d >= +O ? h + 1 : +d >= +M ? h : h - 1;
|
|
84
|
+
}
|
|
76
85
|
function pt(o, n) {
|
|
77
|
-
const d =
|
|
78
|
-
|
|
79
|
-
const O = z($, n), k = F(n?.in || o, 0);
|
|
80
|
-
k.setFullYear(b, 0, w), k.setHours(0, 0, 0, 0);
|
|
81
|
-
const M = z(k, n);
|
|
82
|
-
return +d >= +O ? b + 1 : +d >= +M ? b : b - 1;
|
|
86
|
+
const d = Z(), h = n?.firstWeekContainsDate ?? n?.locale?.options?.firstWeekContainsDate ?? d.firstWeekContainsDate ?? d.locale?.options?.firstWeekContainsDate ?? 1, m = mt(o, n), v = F(n?.in || o, 0);
|
|
87
|
+
return v.setFullYear(m, 0, h), v.setHours(0, 0, 0, 0), z(v, n);
|
|
83
88
|
}
|
|
84
|
-
function
|
|
85
|
-
const d =
|
|
86
|
-
return
|
|
89
|
+
function Ee(o, n) {
|
|
90
|
+
const d = U(o, n?.in), h = +z(d, n) - +pt(d, n);
|
|
91
|
+
return Math.round(h / ot) + 1;
|
|
87
92
|
}
|
|
88
|
-
function ee(o, n) {
|
|
89
|
-
|
|
90
|
-
|
|
93
|
+
const vt = Le`:host{display:block;width:max-content;--sbb-calendar-cell-size: 2.5rem;--sbb-calendar-hover-shift: .0625rem;--sbb-calendar-wide-cell-size: 4.375rem;--sbb-calendar-header-color: var(--sbb-color-granite);--sbb-calendar-header-color: light-dark(var(--sbb-color-granite), var(--sbb-color-smoke));--sbb-calendar-cell-background-color: transparent;--sbb-calendar-cell-background-color-hover: var(--sbb-background-color-3);--sbb-calendar-cell-background-color-active: var(--sbb-background-color-4);--sbb-calendar-cell-padding: .125rem;--sbb-calendar-cell-color: var(--sbb-color-2);--sbb-calendar-cell-border-radius: var(--sbb-border-radius-4x);--sbb-calendar-cell-selected-border: var(--sbb-border-width-2x) solid var(--sbb-border-color-2);--sbb-calendar-cell-selected-background-color: var(--sbb-background-color-2-inverted);--sbb-calendar-cell-disabled-height: .09375rem;--sbb-calendar-cell-disabled-width: 1.59375rem;--sbb-calendar-cell-disabled-color: var(--sbb-color-granite);--sbb-calendar-cell-disabled-color: light-dark(var(--sbb-color-granite), var(--sbb-color-smoke));--sbb-calendar-cell-transition-duration: var( --sbb-disable-animation-duration, var(--sbb-animation-duration-2x) );--sbb-calendar-cell-transition-easing-function: var(--sbb-animation-easing);--sbb-calendar-tables-gap: var(--sbb-spacing-fixed-10x);--sbb-calendar-table-animation-shift: .00625rem;--sbb-calendar-table-animation-duration: .1ms;--sbb-calendar-table-column-spaces: 12;--sbb-calendar-control-view-change-height: 2.75rem;--sbb-calendar-control-view-change-color: var(--sbb-color-3);--sbb-calendar-control-view-change-background: var(--sbb-background-color-1);--sbb-calendar-cell-year-month-width: 4.8125rem;--sbb-calendar-cell-year-month-height: 2.75rem}@media(min-width:37.5rem){:host{--sbb-calendar-cell-size: 2.75rem;--sbb-calendar-wide-cell-size: 4.8125rem;--sbb-calendar-control-view-change-height: 3rem}}:host(:is(:state(enhanced),[state--enhanced])){--sbb-calendar-cell-padding-block-end: var(--sbb-spacing-fixed-3x)}.sbb-calendar__wrapper{width:100%;display:block;transition-duration:var(--sbb-calendar-cell-transition-duration)}.sbb-calendar__controls{width:100%;display:inline-flex;align-items:center;gap:var(--sbb-spacing-fixed-2x);margin-block-end:var(--sbb-spacing-fixed-4x)}.sbb-calendar__controls-month{width:100%;display:flex;gap:var(--sbb-calendar-tables-gap)}#sbb-calendar__controls-previous,#sbb-calendar__controls-next{-webkit-tap-highlight-color:transparent}.sbb-calendar__controls-change-date{appearance:none;box-sizing:border-box;outline:none;border:none;border-radius:0;padding:0;background:none;-webkit-tap-highlight-color:transparent;color:inherit;--sbb-text-font-size: var(--sbb-text-font-size-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);display:flex;align-items:center;margin:auto;height:var(--sbb-calendar-control-view-change-height);text-transform:capitalize;cursor:var(--sbb-cursor-pointer);padding-inline:var(--sbb-spacing-fixed-5x) var(--sbb-spacing-fixed-2x);border-radius:var(--sbb-border-radius-infinity);background-color:var(--sbb-calendar-control-view-change-background);color:var(--sbb-calendar-control-view-change-color);transition-duration:var(--sbb-calendar-cell-transition-duration);transition-timing-function:var(--sbb-calendar-cell-transition-easing-function);transition-property:background-color,padding-block-end}.sbb-calendar__controls-change-date:disabled{--sbb-calendar-control-view-change-background: var(--sbb-color-milk);--sbb-calendar-control-view-change-background: light-dark( var(--sbb-color-milk), var(--sbb-color-anthracite) );--sbb-calendar-control-view-change-color: var(--sbb-color-granite);--sbb-calendar-control-view-change-color: light-dark( var(--sbb-color-granite), var(--sbb-color-aluminium) );cursor:unset}.sbb-calendar__controls-change-date:focus-visible{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width);outline-offset:var(--sbb-spacing-fixed-1x)}@media(any-hover:hover){.sbb-calendar__controls-change-date:not(:active,:disabled):hover{padding-block-end:var(--sbb-calendar-hover-shift)}}.sbb-calendar__controls-change-date:not(:disabled):active{--sbb-calendar-control-view-change-background: var(--sbb-background-color-3)}.sbb-calendar__table-month-view,.sbb-calendar__table-year-view{--sbb-calendar-table-column-spaces: 6}.sbb-calendar__table-overflow-break{contain:layout}.sbb-calendar__table-container{display:flex;gap:var(--sbb-calendar-tables-gap);margin-inline:var(--sbb-calendar-margin);--sbb-calendar-min-width: calc(7 * var(--sbb-calendar-cell-size));--sbb-calendar-overflow: calc(100% - var(--sbb-calendar-min-width));--sbb-calendar-start-offset: min( 0px, -1 * (var(--sbb-calendar-overflow) / var(--sbb-calendar-table-column-spaces)) );--sbb-calendar-margin: var(--sbb-calendar-start-offset)}:host(:is(:state(wide),[state--wide])) .sbb-calendar__table-container{--sbb-calendar-min-width: calc( 2 * 7 * var(--sbb-calendar-cell-size) + var(--sbb-calendar-tables-gap) );--sbb-calendar-margin: calc(.5 * var(--sbb-calendar-start-offset))}:host([orientation=horizontal][week-numbers]) .sbb-calendar__table-container{--sbb-calendar-min-width: calc(8 * var(--sbb-calendar-cell-size))}:host([orientation=horizontal][week-numbers]:is(:state(wide),[state--wide])) .sbb-calendar__table-container{--sbb-calendar-min-width: calc( 2 * 8 * var(--sbb-calendar-cell-size) + var(--sbb-calendar-tables-gap) )}:host([orientation=vertical]) .sbb-calendar__table-container{min-width:var(--sbb-calendar-min-width);--sbb-calendar-start-offset: 0}:host([orientation=vertical]:is(:state(wide),[state--wide])) .sbb-calendar__table-container{--sbb-calendar-min-width: calc( 13 * var(--sbb-calendar-cell-size) + var(--sbb-calendar-tables-gap) )}.sbb-calendar__table{width:100%;border-collapse:collapse;height:max-content;animation-name:show;animation-duration:var(--sbb-calendar-table-animation-duration)}.sbb-calendar__table.sbb-calendar__table-hide{--sbb-calendar-cell-transition-duration: 0ms;animation-name:hide;animation-duration:var(--sbb-calendar-table-animation-duration)}:host(:not(:is(:state(wide),[state--wide]))) .sbb-calendar__table{min-width:100%}.sbb-calendar__table-header,.sbb-calendar__table-body{text-align:center}.sbb-calendar__table-header-cell,.sbb-calendar__table-header-cell-vertical{--sbb-text-font-size: var(--sbb-text-font-size-xs);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);width:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-header-color);padding:0}:host(:not([multiple])) .sbb-calendar__table-header-cell,:host(:not([multiple])) .sbb-calendar__table-header-cell-vertical{height:var(--sbb-calendar-cell-size)}.sbb-calendar__table-header-cell-vertical{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}.sbb-calendar__table-data{position:relative;padding:0;text-align:center}.sbb-calendar__header-cell,.sbb-calendar__cell{appearance:none;box-sizing:border-box;margin:0;outline:none;border:none;border-radius:0;padding:0;background:none;-webkit-tap-highlight-color:transparent;color:inherit;--sbb-text-font-size: var(--sbb-text-font-size-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);height:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-cell-color);cursor:var(--sbb-cursor-pointer);position:relative;z-index:0}.sbb-calendar__header-cell:before,.sbb-calendar__cell:before{content:"";position:absolute;inset:var(--sbb-calendar-cell-padding);background-color:var(--sbb-calendar-cell-background-color);border-radius:var(--sbb-calendar-cell-border-radius);z-index:-1;transition-duration:var(--sbb-calendar-cell-transition-duration);transition-timing-function:var(--sbb-calendar-cell-transition-easing-function);transition-property:background-color}@media(any-hover:hover){.sbb-calendar__header-cell:not(:active,:disabled):hover,.sbb-calendar__cell:not(:active,:disabled):hover{--sbb-calendar-cell-background-color: var(--sbb-calendar-cell-background-color-hover);padding-block-end:var(--sbb-calendar-hover-shift)}}@media(any-hover:hover)and (forced-colors:active){.sbb-calendar__header-cell:not(:active,:disabled):hover:before,.sbb-calendar__cell:not(:active,:disabled):hover:before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width);--sbb-focus-outline-style: initial}}.sbb-calendar__header-cell:disabled,.sbb-calendar__cell:disabled{--sbb-calendar-cell-color: var(--sbb-calendar-cell-disabled-color);cursor:unset}.sbb-calendar__header-cell:focus-visible:before,.sbb-calendar__cell:focus-visible:before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width)}.sbb-calendar__header-cell:not(:disabled):active,.sbb-calendar__cell:not(:disabled):active{--sbb-calendar-cell-background-color: var(--sbb-calendar-cell-background-color-active)}@media(forced-colors:active){.sbb-calendar__header-cell:not(:disabled):active:before,.sbb-calendar__cell:not(:disabled):active:before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width);--sbb-focus-outline-style: initial}}.sbb-calendar__header-cell{--sbb-text-font-size: var(--sbb-text-font-size-xs);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);color:var(--sbb-calendar-header-color)}.sbb-calendar__cell{height:var(--sbb-calendar-cell-year-month-height);width:var(--sbb-calendar-cell-year-month-width)}.sbb-calendar__weekday{width:var(--sbb-calendar-cell-size)}.sbb-calendar__day-cell{padding-block-end:var(--sbb-calendar-cell-padding-block-end)}.sbb-calendar__crossed-out:after{content:"";height:var(--sbb-calendar-cell-disabled-height);width:var(--sbb-calendar-cell-disabled-width);position:absolute;background-color:var(--sbb-calendar-cell-disabled-color);top:50%;left:50%;transform:translate(-50%,-50%) rotate(-45deg)}.sbb-calendar__cell-current{--sbb-text-font-size: var(--sbb-text-font-size-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);font-weight:700}.sbb-calendar__selected:before{border:var(--sbb-calendar-cell-selected-border);border-radius:var(--sbb-calendar-cell-border-radius)}sbb-calendar-day{--sbb-calendar-day-flex-direction: row;--sbb-calendar-day-justify-content: center;--sbb-calendar-day-align-items: center;--sbb-calendar-day-extra-display: none;--sbb-calendar-day-crossed-out-top: 50%;--sbb-calendar-day-crossed-out-translate: translate(-50%, -50%) rotate(-45deg);--sbb-calendar-day-height: 2.75rem;--sbb-calendar-day-value-height: unset}@keyframes show{0%{opacity:0;transform:translateY(var(--sbb-calendar-table-animation-shift))}to{opacity:1;transform:translateY(0)}}@keyframes hide{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(var(--sbb-calendar-table-animation-shift))}}`;
|
|
94
|
+
class wt extends Event {
|
|
95
|
+
get range() {
|
|
96
|
+
return this._range;
|
|
97
|
+
}
|
|
98
|
+
constructor(n) {
|
|
99
|
+
super("monthchange", { bubbles: !0, composed: !0 }), this._range = Object.freeze(n || []);
|
|
100
|
+
}
|
|
91
101
|
}
|
|
92
|
-
const vt = Le`:host{display:block;width:max-content;--sbb-calendar-cell-size: 2.5rem;--sbb-calendar-hover-shift: .0625rem;--sbb-calendar-wide-cell-size: 4.375rem;--sbb-calendar-header-color: var(--sbb-color-granite);--sbb-calendar-header-color: light-dark(var(--sbb-color-granite), var(--sbb-color-smoke));--sbb-calendar-cell-background-color: transparent;--sbb-calendar-cell-padding: .125rem;--sbb-calendar-cell-color: var(--sbb-color-2);--sbb-calendar-cell-selected-color: var(--sbb-color-1-inverted);--sbb-calendar-cell-selected-background-color: var(--sbb-background-color-2-inverted);--sbb-calendar-cell-disabled-height: .09375rem;--sbb-calendar-cell-disabled-width: 1.59375rem;--sbb-calendar-cell-disabled-color: var(--sbb-color-granite);--sbb-calendar-cell-disabled-color: light-dark(var(--sbb-color-granite), var(--sbb-color-smoke));--sbb-calendar-cell-transition-duration: var( --sbb-disable-animation-duration, var(--sbb-animation-duration-2x) );--sbb-calendar-cell-transition-easing-function: var(--sbb-animation-easing);--sbb-calendar-tables-gap: var(--sbb-spacing-fixed-10x);--sbb-calendar-table-animation-shift: .00625rem;--sbb-calendar-table-animation-duration: .1ms;--sbb-calendar-table-column-spaces: 12;--sbb-calendar-control-view-change-height: 2.75rem;--sbb-calendar-control-view-change-color: var(--sbb-color-3);--sbb-calendar-control-view-change-background: var(--sbb-background-color-1)}@media(min-width:37.5rem){:host{--sbb-calendar-cell-size: 2.75rem;--sbb-calendar-wide-cell-size: 4.8125rem;--sbb-calendar-control-view-change-height: 3rem}}.sbb-calendar__wrapper{width:100%;display:block;transition-duration:var(--sbb-calendar-cell-transition-duration)}.sbb-calendar__controls{width:100%;display:inline-flex;align-items:center;gap:var(--sbb-spacing-fixed-2x);margin-block-end:var(--sbb-spacing-fixed-4x)}.sbb-calendar__controls-month{width:100%;display:flex;gap:var(--sbb-calendar-tables-gap)}#sbb-calendar__controls-previous,#sbb-calendar__controls-next{-webkit-tap-highlight-color:transparent}.sbb-calendar__controls-change-date{appearance:none;box-sizing:border-box;outline:none;border:none;border-radius:0;padding:0;background:none;-webkit-tap-highlight-color:transparent;color:inherit;--sbb-text-font-size: var(--sbb-text-font-size-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);display:flex;align-items:center;margin:auto;height:var(--sbb-calendar-control-view-change-height);text-transform:capitalize;cursor:var(--sbb-cursor-pointer);padding-inline:var(--sbb-spacing-fixed-5x) var(--sbb-spacing-fixed-2x);border-radius:var(--sbb-border-radius-infinity);background-color:var(--sbb-calendar-control-view-change-background);color:var(--sbb-calendar-control-view-change-color);transition-duration:var(--sbb-calendar-cell-transition-duration);transition-timing-function:var(--sbb-calendar-cell-transition-easing-function);transition-property:background-color,padding-block-end}.sbb-calendar__controls-change-date:disabled{--sbb-calendar-control-view-change-background: var(--sbb-color-milk);--sbb-calendar-control-view-change-background: light-dark( var(--sbb-color-milk), var(--sbb-color-anthracite) );--sbb-calendar-control-view-change-color: var(--sbb-color-granite);--sbb-calendar-control-view-change-color: light-dark( var(--sbb-color-granite), var(--sbb-color-aluminium) );cursor:unset}.sbb-calendar__controls-change-date:focus-visible{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width);outline-offset:var(--sbb-spacing-fixed-1x)}@media(any-hover:hover){.sbb-calendar__controls-change-date:not(:active,:disabled):hover{padding-block-end:var(--sbb-calendar-hover-shift)}}.sbb-calendar__controls-change-date:not(:disabled):active{--sbb-calendar-control-view-change-background: var(--sbb-background-color-3)}.sbb-calendar__table-month-view,.sbb-calendar__table-year-view{--sbb-calendar-table-column-spaces: 6}.sbb-calendar__table-overflow-break{contain:layout}.sbb-calendar__table-container{display:flex;gap:var(--sbb-calendar-tables-gap);margin-inline:var(--sbb-calendar-margin);--sbb-calendar-min-width: calc(7 * var(--sbb-calendar-cell-size));--sbb-calendar-overflow: calc(100% - var(--sbb-calendar-min-width));--sbb-calendar-start-offset: min( 0px, -1 * (var(--sbb-calendar-overflow) / var(--sbb-calendar-table-column-spaces)) );--sbb-calendar-margin: var(--sbb-calendar-start-offset)}:host(:is(:state(wide),[state--wide])) .sbb-calendar__table-container{--sbb-calendar-min-width: calc( 2 * 7 * var(--sbb-calendar-cell-size) + var(--sbb-calendar-tables-gap) );--sbb-calendar-margin: calc(.5 * var(--sbb-calendar-start-offset))}:host([orientation=horizontal][week-numbers]) .sbb-calendar__table-container{--sbb-calendar-min-width: calc(8 * var(--sbb-calendar-cell-size))}:host([orientation=horizontal][week-numbers]:is(:state(wide),[state--wide])) .sbb-calendar__table-container{--sbb-calendar-min-width: calc( 2 * 8 * var(--sbb-calendar-cell-size) + var(--sbb-calendar-tables-gap) )}:host([orientation=vertical]) .sbb-calendar__table-container{min-width:var(--sbb-calendar-min-width);--sbb-calendar-start-offset: 0}:host([orientation=vertical]:is(:state(wide),[state--wide])) .sbb-calendar__table-container{--sbb-calendar-min-width: calc( 13 * var(--sbb-calendar-cell-size) + var(--sbb-calendar-tables-gap) )}.sbb-calendar__table{width:100%;border-collapse:collapse;height:max-content;animation-name:show;animation-duration:var(--sbb-calendar-table-animation-duration)}.sbb-calendar__table.sbb-calendar__table-hide{--sbb-calendar-cell-transition-duration: 0ms;animation-name:hide;animation-duration:var(--sbb-calendar-table-animation-duration)}:host(:not(:is(:state(wide),[state--wide]))) .sbb-calendar__table{min-width:100%}.sbb-calendar__table-header,.sbb-calendar__table-body{text-align:center}.sbb-calendar__table-header-cell{--sbb-text-font-size: var(--sbb-text-font-size-xs);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);width:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-header-color);padding:0}:host(:not([multiple])) .sbb-calendar__table-header-cell{height:var(--sbb-calendar-cell-size)}.sbb-calendar__table-data{position:relative;padding:0;text-align:center}.sbb-calendar__header-cell,.sbb-calendar__cell{appearance:none;box-sizing:border-box;margin:0;outline:none;border:none;border-radius:0;padding:0;background:none;-webkit-tap-highlight-color:transparent;color:inherit;--sbb-text-font-size: var(--sbb-text-font-size-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);height:var(--sbb-calendar-cell-size);color:var(--sbb-calendar-cell-color);cursor:var(--sbb-cursor-pointer);position:relative;z-index:0}.sbb-calendar__header-cell:before,.sbb-calendar__cell:before{content:"";position:absolute;inset:var(--sbb-calendar-cell-padding);background-color:var(--sbb-calendar-cell-background-color);border-radius:50%;z-index:-1;transition-duration:var(--sbb-calendar-cell-transition-duration);transition-timing-function:var(--sbb-calendar-cell-transition-easing-function);transition-property:background-color}@media(any-hover:hover){.sbb-calendar__header-cell:not(.sbb-calendar__selected,:active,:disabled):hover,.sbb-calendar__cell:not(.sbb-calendar__selected,:active,:disabled):hover{--sbb-calendar-cell-background-color: var(--sbb-background-color-3);padding-block-end:var(--sbb-calendar-hover-shift)}}@media(any-hover:hover)and (forced-colors:active){.sbb-calendar__header-cell:not(.sbb-calendar__selected,:active,:disabled):hover:before,.sbb-calendar__cell:not(.sbb-calendar__selected,:active,:disabled):hover:before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width);--sbb-focus-outline-style: initial}}.sbb-calendar__header-cell:disabled,.sbb-calendar__cell:disabled{--sbb-calendar-cell-color: var(--sbb-calendar-cell-disabled-color);cursor:unset}.sbb-calendar__header-cell:focus-visible:before,.sbb-calendar__cell:focus-visible:before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width)}.sbb-calendar__header-cell:not(.sbb-calendar__selected,:disabled):active,.sbb-calendar__cell:not(.sbb-calendar__selected,:disabled):active{--sbb-calendar-cell-background-color: var(--sbb-background-color-4)}@media(forced-colors:active){.sbb-calendar__header-cell:not(.sbb-calendar__selected,:disabled):active:before,.sbb-calendar__cell:not(.sbb-calendar__selected,:disabled):active:before{outline-offset:var(--sbb-focus-outline-offset);outline:var(--sbb-focus-outline-color) var(--sbb-focus-outline-style, solid) var(--sbb-focus-outline-width);--sbb-focus-outline-style: initial}}.sbb-calendar__header-cell{--sbb-text-font-size: var(--sbb-text-font-size-xs);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);color:var(--sbb-calendar-header-color)}.sbb-calendar__weekday,.sbb-calendar__day{border-radius:50%;width:var(--sbb-calendar-cell-size)}.sbb-calendar__weekday:before,.sbb-calendar__day:before{border-radius:50%}.sbb-calendar__pill{width:var(--sbb-calendar-wide-cell-size);border-radius:var(--sbb-border-radius-infinity)}.sbb-calendar__pill:before{border-radius:var(--sbb-border-radius-infinity)}.sbb-calendar__crossed-out:after{content:"";height:var(--sbb-calendar-cell-disabled-height);width:var(--sbb-calendar-cell-disabled-width);position:absolute;background-color:var(--sbb-calendar-cell-disabled-color);top:50%;left:50%;transform:translate(-50%,-50%) rotate(-45deg)}.sbb-calendar__cell-current{--sbb-text-font-size: var(--sbb-text-font-size-s);font-family:var(--sbb-typo-font-family);font-weight:400;line-height:var(--sbb-typo-line-height-text);letter-spacing:var(--sbb-typo-letter-spacing-text);font-size:var(--sbb-text-font-size);font-weight:700}.sbb-calendar__selected{--sbb-calendar-cell-color: var(--sbb-calendar-cell-selected-color);--sbb-calendar-cell-background-color: var(--sbb-calendar-cell-selected-background-color)}@media(forced-colors:active){.sbb-calendar__selected{--sbb-calendar-cell-background-color: ButtonText !important}}@keyframes show{0%{opacity:0;transform:translateY(var(--sbb-calendar-table-animation-shift))}to{opacity:1;transform:translateY(0)}}@keyframes hide{0%{opacity:1;transform:translateY(0)}to{opacity:0;transform:translateY(var(--sbb-calendar-table-animation-shift))}}`;
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return g = class extends p {
|
|
102
|
+
let Tt = (() => {
|
|
103
|
+
var S, W, I, N, R, T, E, P, L, H, B, q, g;
|
|
104
|
+
let o = [Be("sbb-calendar")], n, d = [], h, m = it(nt(He)), v = [], V, O = [], D = [], M, C = [], ee = [], te, ae = [], se = [], re, ie = [], ne = [], le, oe = [], de = [], ce, he, be = [], _e = [], ue, fe = [], ge = [], me, pe = [], ve = [], we, ye = [], De = [], ke, Ae = [], xe = [], Ve, $e, Me = [], Ye = [], ze, Fe = [], Oe = [];
|
|
105
|
+
return g = class extends m {
|
|
97
106
|
constructor() {
|
|
98
107
|
super();
|
|
99
|
-
x(this, N);
|
|
100
|
-
x(this, C);
|
|
101
|
-
x(this, I);
|
|
102
108
|
x(this, S);
|
|
109
|
+
x(this, W);
|
|
110
|
+
x(this, I);
|
|
111
|
+
x(this, N);
|
|
103
112
|
x(this, R);
|
|
104
113
|
x(this, T);
|
|
105
114
|
x(this, E);
|
|
106
115
|
x(this, P);
|
|
107
116
|
x(this, L);
|
|
108
|
-
x(this, B);
|
|
109
117
|
x(this, H);
|
|
110
|
-
x(this,
|
|
111
|
-
|
|
118
|
+
x(this, B);
|
|
119
|
+
x(this, q);
|
|
120
|
+
u(this, S, (_(this, v), _(this, O, !1))), u(this, W, (_(this, D), _(this, C, "day"))), u(this, I, (_(this, ee), _(this, ae, null))), u(this, N, (_(this, se), _(this, ie, null))), u(this, R, (_(this, ne), _(this, oe, !1))), u(this, T, (_(this, de), _(this, be, null))), u(this, E, (_(this, _e), _(this, fe, null))), u(this, P, (_(this, ge), _(this, pe, "horizontal"))), u(this, L, (_(this, ve), _(this, ye, !1))), this._dateAdapter = (_(this, De), Ke().datetime?.dateAdapter ?? je), u(this, H, _(this, Ae, this._dateAdapter.today())), this._wideInternal = (_(this, xe), !1), u(this, B, _(this, Me, "day")), this._nextCalendarView = (_(this, Ye), "day"), this._keyboardNavigationDayViewParameters = {
|
|
112
121
|
firstDayInView: null,
|
|
113
122
|
lastDayInView: null,
|
|
114
123
|
firstMonthOffset: 0,
|
|
115
124
|
firstMonthLength: 0,
|
|
116
125
|
secondMonthOffset: 0
|
|
117
|
-
}, this._weeks = [], this._monthNames = this._dateAdapter.getMonthNames("long"), this._resetFocus = !1, this._containingFocus = !1,
|
|
126
|
+
}, this._weeks = [], this._monthNames = this._dateAdapter.getMonthNames("long"), this._enhancedVariant = !1, this._resetFocus = !1, this._containingFocus = !1, u(this, q, _(this, Fe, !1)), this._language = (_(this, Oe), new Ue(this).withHandler(() => {
|
|
118
127
|
this._monthNames = this._dateAdapter.getMonthNames("long"), this._createMonthRows();
|
|
119
|
-
})), this._mediaMatcher = new
|
|
120
|
-
[
|
|
121
|
-
}), this.
|
|
128
|
+
})), this._mediaMatcher = new Qe(this, {
|
|
129
|
+
[Ie]: () => this._init()
|
|
130
|
+
}), this._onSlotChange = () => {
|
|
131
|
+
this._enhancedVariant = Array.from(this.children).some((e) => e.localName === "sbb-calendar-day"), this.toggleState("enhanced", this._enhancedVariant), this._setTabIndex();
|
|
132
|
+
}, this._createMonthRows(), this._setWeekdays(), this.addEventListener("focusin", () => this._containingFocus = !0), this.addEventListener("focusout", () => this._containingFocus = !1), this.addEventListener("click", (e) => {
|
|
133
|
+
const t = e.target.closest("sbb-calendar-day");
|
|
134
|
+
t && this._selectDate(t.value);
|
|
135
|
+
}), this.addEventListener("keydown", (e) => {
|
|
136
|
+
e.target.localName === "sbb-calendar-day" && this._handleKeyboardEvent(e, this._mapDateToDay(e.target.value));
|
|
137
|
+
});
|
|
122
138
|
}
|
|
123
139
|
/** If set to true, two months are displayed */
|
|
124
140
|
get wide() {
|
|
125
|
-
return A(this,
|
|
141
|
+
return A(this, S);
|
|
126
142
|
}
|
|
127
143
|
set wide(e) {
|
|
128
|
-
|
|
144
|
+
u(this, S, e);
|
|
129
145
|
}
|
|
130
146
|
/** The initial view of the calendar which should be displayed on opening. */
|
|
131
147
|
get view() {
|
|
132
|
-
return A(this,
|
|
148
|
+
return A(this, W);
|
|
133
149
|
}
|
|
134
150
|
set view(e) {
|
|
135
|
-
|
|
151
|
+
u(this, W, e);
|
|
136
152
|
}
|
|
137
153
|
/**
|
|
138
154
|
* The minimum valid date. Accepts a date object or null.
|
|
@@ -142,24 +158,24 @@ let St = (() => {
|
|
|
142
158
|
return A(this, I);
|
|
143
159
|
}
|
|
144
160
|
set min(e) {
|
|
145
|
-
|
|
161
|
+
u(this, I, e);
|
|
146
162
|
}
|
|
147
163
|
/**
|
|
148
164
|
* The maximum valid date. Accepts a date object or null.
|
|
149
165
|
* Accepts an ISO8601 formatted string (e.g. 2024-12-24) as attribute.
|
|
150
166
|
*/
|
|
151
167
|
get max() {
|
|
152
|
-
return A(this,
|
|
168
|
+
return A(this, N);
|
|
153
169
|
}
|
|
154
170
|
set max(e) {
|
|
155
|
-
|
|
171
|
+
u(this, N, e);
|
|
156
172
|
}
|
|
157
173
|
/** Whether the calendar allows for multiple date selection. */
|
|
158
174
|
get multiple() {
|
|
159
175
|
return A(this, R);
|
|
160
176
|
}
|
|
161
177
|
set multiple(e) {
|
|
162
|
-
|
|
178
|
+
u(this, R, e);
|
|
163
179
|
}
|
|
164
180
|
/**
|
|
165
181
|
* The selected date: accepts a date object, or, if `multiple`, an array of dates.
|
|
@@ -179,35 +195,35 @@ let St = (() => {
|
|
|
179
195
|
return A(this, T);
|
|
180
196
|
}
|
|
181
197
|
set _selected(e) {
|
|
182
|
-
|
|
198
|
+
u(this, T, e);
|
|
183
199
|
}
|
|
184
200
|
/** A function used to filter out dates. */
|
|
185
201
|
get dateFilter() {
|
|
186
202
|
return A(this, E);
|
|
187
203
|
}
|
|
188
204
|
set dateFilter(e) {
|
|
189
|
-
|
|
205
|
+
u(this, E, e);
|
|
190
206
|
}
|
|
191
207
|
/** The orientation of days in the calendar. */
|
|
192
208
|
get orientation() {
|
|
193
209
|
return A(this, P);
|
|
194
210
|
}
|
|
195
211
|
set orientation(e) {
|
|
196
|
-
|
|
212
|
+
u(this, P, e);
|
|
197
213
|
}
|
|
198
214
|
/** Whether it has to display the week numbers in addition to week days. */
|
|
199
215
|
get weekNumbers() {
|
|
200
216
|
return A(this, L);
|
|
201
217
|
}
|
|
202
218
|
set weekNumbers(e) {
|
|
203
|
-
|
|
219
|
+
u(this, L, e);
|
|
204
220
|
}
|
|
205
221
|
/** The currently active date. */
|
|
206
222
|
get _activeDate() {
|
|
207
|
-
return A(this,
|
|
223
|
+
return A(this, H);
|
|
208
224
|
}
|
|
209
225
|
set _activeDate(e) {
|
|
210
|
-
|
|
226
|
+
u(this, H, e);
|
|
211
227
|
}
|
|
212
228
|
/** The current wide property considering property value and breakpoints. From zero to small `wide` has always to be false. */
|
|
213
229
|
set _wide(e) {
|
|
@@ -217,20 +233,23 @@ let St = (() => {
|
|
|
217
233
|
return this._wideInternal;
|
|
218
234
|
}
|
|
219
235
|
get _calendarView() {
|
|
220
|
-
return A(this,
|
|
236
|
+
return A(this, B);
|
|
221
237
|
}
|
|
222
238
|
set _calendarView(e) {
|
|
223
|
-
|
|
239
|
+
u(this, B, e);
|
|
224
240
|
}
|
|
225
241
|
/** A list of buttons corresponding to days, months or years depending on the view. */
|
|
226
242
|
get _cells() {
|
|
227
|
-
return Array.from(this.
|
|
243
|
+
return Array.from((this._calendarView === "day" ? this._getRootForQuerySelector()?.querySelectorAll("sbb-calendar-day") : this.shadowRoot?.querySelectorAll(".sbb-calendar__cell")) ?? []);
|
|
228
244
|
}
|
|
229
245
|
get _initialized() {
|
|
230
|
-
return A(this,
|
|
246
|
+
return A(this, q);
|
|
231
247
|
}
|
|
232
248
|
set _initialized(e) {
|
|
233
|
-
|
|
249
|
+
u(this, q, e);
|
|
250
|
+
}
|
|
251
|
+
_getRootForQuerySelector() {
|
|
252
|
+
return this._enhancedVariant ? this : this.shadowRoot;
|
|
234
253
|
}
|
|
235
254
|
_dateFilter(e) {
|
|
236
255
|
return this.dateFilter?.(e) ?? !0;
|
|
@@ -240,7 +259,10 @@ let St = (() => {
|
|
|
240
259
|
this._resetCalendarView(), this._init();
|
|
241
260
|
}
|
|
242
261
|
connectedCallback() {
|
|
243
|
-
super.connectedCallback(), this.resetPosition();
|
|
262
|
+
super.connectedCallback(), this.resetPosition(), this.shadowRoot?.addEventListener("slotchange", this._onSlotChange, { capture: !0 });
|
|
263
|
+
}
|
|
264
|
+
disconnectedCallback() {
|
|
265
|
+
super.disconnectedCallback(), this.shadowRoot?.removeEventListener("slotchange", this._onSlotChange, { capture: !0 });
|
|
244
266
|
}
|
|
245
267
|
/** @internal */
|
|
246
268
|
focus() {
|
|
@@ -262,14 +284,14 @@ let St = (() => {
|
|
|
262
284
|
}
|
|
263
285
|
/** Initializes the component. */
|
|
264
286
|
_init(e) {
|
|
265
|
-
if (!
|
|
287
|
+
if (!We) {
|
|
266
288
|
if (this.hydrationRequired) {
|
|
267
289
|
this.hydrationComplete.then(() => this._init());
|
|
268
290
|
return;
|
|
269
291
|
}
|
|
270
|
-
if (e && this._assignActiveDate(e), this._wide = (this._mediaMatcher.matches(
|
|
292
|
+
if (e && this._assignActiveDate(e), this._wide = (this._mediaMatcher.matches(Ie) ?? !1) && this.wide, this._weeks = this._createWeekRows(this._activeDate), this._years = this._createYearRows(), this._weekNumbers = this._createWeekNumbers(this._activeDate), this._nextMonthWeeks = [[]], this._nextMonthYears = [[]], this._wide) {
|
|
271
293
|
const t = this._dateAdapter.addCalendarMonths(this._activeDate, 1);
|
|
272
|
-
this._nextMonthWeeks = this._createWeekRows(t, !0), this._nextMonthYears = this._createYearRows(
|
|
294
|
+
this._nextMonthWeeks = this._createWeekRows(t, !0), this._nextMonthYears = this._createYearRows($), this._nextMonthWeekNumbers = this._createWeekNumbers(t);
|
|
273
295
|
}
|
|
274
296
|
this._initialized = !0;
|
|
275
297
|
}
|
|
@@ -280,9 +302,9 @@ let St = (() => {
|
|
|
280
302
|
}
|
|
281
303
|
/** Creates the array of weekdays. */
|
|
282
304
|
_setWeekdays() {
|
|
283
|
-
const e = this._dateAdapter.getDayOfWeekNames("narrow"), a = this._dateAdapter.getDayOfWeekNames("long").map((
|
|
284
|
-
long:
|
|
285
|
-
narrow: e[
|
|
305
|
+
const e = this._dateAdapter.getDayOfWeekNames("narrow"), a = this._dateAdapter.getDayOfWeekNames("long").map((r, i) => ({
|
|
306
|
+
long: r,
|
|
307
|
+
narrow: e[i]
|
|
286
308
|
})), s = this._dateAdapter.getFirstDayOfWeek();
|
|
287
309
|
this._weekdays = a.slice(s).concat(a.slice(0, s));
|
|
288
310
|
}
|
|
@@ -298,12 +320,12 @@ let St = (() => {
|
|
|
298
320
|
* Then, this array is mapped via the `getWeek` function, which returns the ISO week number for that date.
|
|
299
321
|
*/
|
|
300
322
|
_createWeekNumbers(e) {
|
|
301
|
-
return ft({ start: gt(e), end: _t(e) }, { weekStartsOn: 1 }).map((t) =>
|
|
323
|
+
return ft({ start: gt(e), end: _t(e) }, { weekStartsOn: 1 }).map((t) => Ee(t, { weekStartsOn: 1, firstWeekContainsDate: 4 }));
|
|
302
324
|
}
|
|
303
325
|
/** Creates the rows along the horizontal direction and sets the parameters used in keyboard navigation. */
|
|
304
326
|
_createWeekRows(e, t = !1) {
|
|
305
|
-
const a = this._dateAdapter.
|
|
306
|
-
return t ? (this._keyboardNavigationDayViewParameters.secondMonthOffset =
|
|
327
|
+
const a = this._dateAdapter.getNumDaysInMonth(e), s = this._dateAdapter.getFirstWeekOffset(e);
|
|
328
|
+
return t ? (this._keyboardNavigationDayViewParameters.secondMonthOffset = s, this._keyboardNavigationDayViewParameters.lastDayInView = this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), a))) : (this._keyboardNavigationDayViewParameters.firstMonthLength = a, this._keyboardNavigationDayViewParameters.firstMonthOffset = s, this._keyboardNavigationDayViewParameters.firstDayInView = this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), 1)), this._keyboardNavigationDayViewParameters.lastDayInView = this._dateAdapter.toIso8601(this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), a))), this.orientation === "horizontal" ? this._createWeekRowsHorizontal(e, a, s) : this._createWeekRowsVertical(e, a, s);
|
|
307
329
|
}
|
|
308
330
|
/**
|
|
309
331
|
* Creates the rows for each week in orientation='horizontal'.
|
|
@@ -313,22 +335,14 @@ let St = (() => {
|
|
|
313
335
|
*
|
|
314
336
|
* The result is a matrix in which every row is a week (or part of it, considering offset).
|
|
315
337
|
*/
|
|
316
|
-
_createWeekRowsHorizontal(e, t, a
|
|
317
|
-
const
|
|
318
|
-
for (let
|
|
319
|
-
|
|
320
|
-
const
|
|
321
|
-
|
|
322
|
-
value: _,
|
|
323
|
-
dateValue: c,
|
|
324
|
-
dayValue: t[l],
|
|
325
|
-
monthValue: String(this._dateAdapter.getMonth(c)),
|
|
326
|
-
yearValue: String(this._dateAdapter.getYear(c)),
|
|
327
|
-
weekValue: ee(_, { weekStartsOn: 1, firstWeekContainsDate: 4 }),
|
|
328
|
-
weekDayValue: this._dateAdapter.getDayOfWeek(c)
|
|
329
|
-
});
|
|
338
|
+
_createWeekRowsHorizontal(e, t, a) {
|
|
339
|
+
const s = [[]];
|
|
340
|
+
for (let r = 0, i = a; r < t; r++, i++) {
|
|
341
|
+
i === y && (s.push([]), i = 0);
|
|
342
|
+
const l = this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), r + 1);
|
|
343
|
+
s[s.length - 1].push(this._mapDateToDay(l));
|
|
330
344
|
}
|
|
331
|
-
return
|
|
345
|
+
return s;
|
|
332
346
|
}
|
|
333
347
|
/**
|
|
334
348
|
* Creates the rows for each week in orientation='vertical'.
|
|
@@ -344,40 +358,48 @@ let St = (() => {
|
|
|
344
358
|
* - ...
|
|
345
359
|
* - row 7: all the Sundays.
|
|
346
360
|
*/
|
|
347
|
-
_createWeekRowsVertical(e, t, a
|
|
348
|
-
const
|
|
349
|
-
for (let
|
|
350
|
-
|
|
351
|
-
const
|
|
352
|
-
i
|
|
353
|
-
value: _,
|
|
354
|
-
dateValue: c,
|
|
355
|
-
dayValue: t[l],
|
|
356
|
-
monthValue: String(this._dateAdapter.getMonth(c)),
|
|
357
|
-
yearValue: String(this._dateAdapter.getYear(c)),
|
|
358
|
-
weekValue: ee(_, { weekStartsOn: 1, firstWeekContainsDate: 4 }),
|
|
359
|
-
weekDayValue: this._dateAdapter.getDayOfWeek(c)
|
|
360
|
-
});
|
|
361
|
+
_createWeekRowsVertical(e, t, a) {
|
|
362
|
+
const s = Array.from({ length: y }, () => []);
|
|
363
|
+
for (let r = 0, i = a; r < t; r++, i++) {
|
|
364
|
+
i === y && (i = 0);
|
|
365
|
+
const l = this._dateAdapter.createDate(this._dateAdapter.getYear(e), this._dateAdapter.getMonth(e), r + 1);
|
|
366
|
+
s[i].push(this._mapDateToDay(l));
|
|
361
367
|
}
|
|
362
|
-
return
|
|
368
|
+
return s;
|
|
369
|
+
}
|
|
370
|
+
_mapDateToDay(e) {
|
|
371
|
+
const t = this._dateAdapter.toIso8601(e);
|
|
372
|
+
return {
|
|
373
|
+
value: t,
|
|
374
|
+
dateValue: e,
|
|
375
|
+
dayValue: String(this._dateAdapter.getDate(e)),
|
|
376
|
+
monthValue: String(this._dateAdapter.getMonth(e)),
|
|
377
|
+
yearValue: String(this._dateAdapter.getYear(e)),
|
|
378
|
+
weekValue: Ee(t, { weekStartsOn: 1, firstWeekContainsDate: 4 }),
|
|
379
|
+
weekDayValue: this._dateAdapter.getDayOfWeek(e)
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
/** Force the conversion to ISO8601 formatted string. */
|
|
383
|
+
_mapValueToISODate(e) {
|
|
384
|
+
return typeof e == "string" ? e : this._dateAdapter.toIso8601(e);
|
|
363
385
|
}
|
|
364
386
|
/** Creates the rows for the month selection view. */
|
|
365
387
|
_createMonthRows() {
|
|
366
|
-
const e = this._dateAdapter.getMonthNames("short"), t = new Array(12).fill(null).map((
|
|
367
|
-
value: e[
|
|
368
|
-
longValue: this._monthNames[
|
|
369
|
-
monthValue:
|
|
370
|
-
})), a = 12 /
|
|
371
|
-
for (let
|
|
372
|
-
s.push(t.slice(
|
|
388
|
+
const e = this._dateAdapter.getMonthNames("short"), t = new Array(12).fill(null).map((r, i) => ({
|
|
389
|
+
value: e[i],
|
|
390
|
+
longValue: this._monthNames[i],
|
|
391
|
+
monthValue: i + 1
|
|
392
|
+
})), a = 12 / j, s = [];
|
|
393
|
+
for (let r = 0; r < a; r++)
|
|
394
|
+
s.push(t.slice(j * r, j * (r + 1)));
|
|
373
395
|
this._months = s;
|
|
374
396
|
}
|
|
375
397
|
/** Creates the rows for the year selection view. */
|
|
376
398
|
_createYearRows(e = 0) {
|
|
377
|
-
const t = this._getStartValueYearView(), a = new Array(
|
|
378
|
-
for (let
|
|
379
|
-
|
|
380
|
-
return
|
|
399
|
+
const t = this._getStartValueYearView(), a = new Array($).fill(0).map((i, l) => t + e + l), s = $ / G, r = [];
|
|
400
|
+
for (let i = 0; i < s; i++)
|
|
401
|
+
r.push(a.slice(G * i, G * (i + 1)));
|
|
402
|
+
return r;
|
|
381
403
|
}
|
|
382
404
|
/**
|
|
383
405
|
* Calculates the first year that will be shown in the year selection panel.
|
|
@@ -391,16 +413,16 @@ let St = (() => {
|
|
|
391
413
|
*/
|
|
392
414
|
_getStartValueYearView() {
|
|
393
415
|
let e = 0;
|
|
394
|
-
this.max ? e = this._dateAdapter.getYear(this.max) -
|
|
416
|
+
this.max ? e = this._dateAdapter.getYear(this.max) - $ + 1 : this.min && (e = this._dateAdapter.getYear(this.min));
|
|
395
417
|
const t = this._dateAdapter.getYear(this._activeDate);
|
|
396
|
-
return t - ((t - e) %
|
|
418
|
+
return t - ((t - e) % $ + $) % $;
|
|
397
419
|
}
|
|
398
420
|
/** Checks if date is within the min-max range. */
|
|
399
421
|
_isDayInRange(e) {
|
|
400
422
|
if (!this.min && !this.max)
|
|
401
423
|
return !0;
|
|
402
|
-
const t = this._dateAdapter.
|
|
403
|
-
return
|
|
424
|
+
const t = this._dateAdapter.deserialize(e);
|
|
425
|
+
return this._dateAdapter.sameDate(t, this._dateAdapter.clampDate(t, this.min, this.max));
|
|
404
426
|
}
|
|
405
427
|
/** Checks if date is within the min-max range in month view. */
|
|
406
428
|
_isMonthInRange(e, t) {
|
|
@@ -456,8 +478,8 @@ let St = (() => {
|
|
|
456
478
|
* - if not, the selected dates are the new ones.
|
|
457
479
|
*/
|
|
458
480
|
_selectMultipleDates(e) {
|
|
459
|
-
const t = this._cells.filter((
|
|
460
|
-
this._selected =
|
|
481
|
+
const t = this._cells.filter((l) => !l.disabled).map((l) => this._mapValueToISODate(l.value)), a = e.map((l) => l.value).filter((l) => t.includes(l)), s = new Set(a), r = new Set(this._selected.map((l) => this._dateAdapter.toIso8601(l))), i = this._updateSelectedWithMultipleDates(a, s, r);
|
|
482
|
+
this._selected = i.map((l) => this._dateAdapter.deserialize(l)), this._emitDateSelectedEvent(this._selected.map((l) => this._dateAdapter.deserialize(l)));
|
|
461
483
|
}
|
|
462
484
|
/**
|
|
463
485
|
* Emits the dateselected event given the detail (as T or T[] based on the value of the multiple flag).
|
|
@@ -469,6 +491,10 @@ let St = (() => {
|
|
|
469
491
|
bubbles: !0
|
|
470
492
|
}));
|
|
471
493
|
}
|
|
494
|
+
_emitMonthChange() {
|
|
495
|
+
const e = (this.wide ? [...this._weeks, ...this._nextMonthWeeks] : this._weeks).flat().sort((t, a) => t.value.localeCompare(a.value));
|
|
496
|
+
this.dispatchEvent(new wt(e));
|
|
497
|
+
}
|
|
472
498
|
/**
|
|
473
499
|
* In case of multiple selection, newly added days must be added to the existing ones, without duplication.
|
|
474
500
|
* If the days to add are exactly the same as the selected ones, the set must be emptied.
|
|
@@ -496,7 +522,7 @@ let St = (() => {
|
|
|
496
522
|
}
|
|
497
523
|
/** Goes to the month identified by the shift. */
|
|
498
524
|
_goToDifferentMonth(e) {
|
|
499
|
-
this._init(this._dateAdapter.addCalendarMonths(this._activeDate, e));
|
|
525
|
+
this._init(this._dateAdapter.addCalendarMonths(this._activeDate, e)), this._emitMonthChange();
|
|
500
526
|
}
|
|
501
527
|
_goToDifferentYear(e) {
|
|
502
528
|
this._chosenYear += e, this._activeDate = this._dateAdapter.createDate(this._chosenYear, this._dateAdapter.getMonth(this._activeDate), this._dateAdapter.getDate(this._activeDate)), this._init();
|
|
@@ -541,17 +567,24 @@ let St = (() => {
|
|
|
541
567
|
return this._nextDisabled(s);
|
|
542
568
|
}
|
|
543
569
|
_handleTableBlur(e) {
|
|
544
|
-
e?.localName !== "
|
|
570
|
+
e?.localName !== "sbb-calendar-day" && this._setTabIndex();
|
|
545
571
|
}
|
|
546
572
|
_setTabIndex() {
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
573
|
+
const e = this._calendarView === "day" ? "sbb-calendar-day" : ".sbb-calendar__cell";
|
|
574
|
+
Array.from(this._getRootForQuerySelector().querySelectorAll(`${e}[tabindex="0"]`) ?? []).forEach((a) => a.tabIndex = -1);
|
|
575
|
+
const t = this._getFirstFocusable();
|
|
576
|
+
t && (t.tabIndex = 0);
|
|
550
577
|
}
|
|
551
578
|
/** Get the element in the calendar to assign focus. */
|
|
552
579
|
_getFirstFocusable() {
|
|
553
|
-
const e = this.
|
|
554
|
-
|
|
580
|
+
const e = this._getRootForQuerySelector();
|
|
581
|
+
if (this._calendarView === "day") {
|
|
582
|
+
const t = e.querySelector(":is(:state(selected),[state--selected])") ?? e.querySelector(":is(:state(current),[state--current])");
|
|
583
|
+
return t && !t.disabled ? t : this._getFirstFocusableDay();
|
|
584
|
+
} else {
|
|
585
|
+
const t = this.shadowRoot?.querySelector(".sbb-calendar__cell-current");
|
|
586
|
+
return t && !t.disabled ? t : this.shadowRoot.querySelector(".sbb-calendar__cell:not([disabled])");
|
|
587
|
+
}
|
|
555
588
|
}
|
|
556
589
|
/**
|
|
557
590
|
* In `day` view in `vertical` orientation,
|
|
@@ -561,54 +594,54 @@ let St = (() => {
|
|
|
561
594
|
* To solve this, the element with the lowest `value` is taken (ISO String are ordered).
|
|
562
595
|
*/
|
|
563
596
|
_getFirstFocusableDay() {
|
|
564
|
-
const e = Array.from(this.
|
|
597
|
+
const e = Array.from(this._getRootForQuerySelector().querySelectorAll("sbb-calendar-day:not([disabled])"));
|
|
565
598
|
if (!e || e.length === 0)
|
|
566
599
|
return null;
|
|
567
600
|
{
|
|
568
|
-
const t = e.map((a) => a.value).sort()[0];
|
|
569
|
-
return this.
|
|
601
|
+
const t = e.map((a) => this._dateAdapter.toIso8601(a.value)).sort()[0];
|
|
602
|
+
return this._getRootForQuerySelector().querySelector(`sbb-calendar-day[slot="${t}"]`);
|
|
570
603
|
}
|
|
571
604
|
}
|
|
572
605
|
_handleKeyboardEvent(e, t) {
|
|
573
|
-
|
|
574
|
-
const a = this._cells, s = a.findIndex((
|
|
575
|
-
let
|
|
576
|
-
t ?
|
|
577
|
-
const
|
|
578
|
-
|
|
606
|
+
qe(e) && e.preventDefault();
|
|
607
|
+
const a = this._cells, s = a.findIndex((l) => l === e.target);
|
|
608
|
+
let r;
|
|
609
|
+
t ? r = this._navigateByKeyboardDayView(e, s, a, t) : r = this._navigateByKeyboard(e, s, a);
|
|
610
|
+
const i = (this._enhancedVariant ? document : this.shadowRoot).activeElement;
|
|
611
|
+
r !== i && (r.tabIndex = 0, r?.focus(), i.tabIndex = -1);
|
|
579
612
|
}
|
|
580
613
|
_navigateByKeyboardDayView(e, t, a, s) {
|
|
581
|
-
const
|
|
614
|
+
const r = this.orientation === "horizontal" ? { leftRight: 1, upDown: y } : { leftRight: y, upDown: 1 }, i = t < this._keyboardNavigationDayViewParameters.firstMonthLength ? this._keyboardNavigationDayViewParameters.firstMonthOffset : this._keyboardNavigationDayViewParameters.secondMonthOffset;
|
|
582
615
|
switch (e.key) {
|
|
583
616
|
case "ArrowUp":
|
|
584
|
-
return this._findDayArrows(a, t, s.dateValue, -
|
|
617
|
+
return this._findDayArrows(a, t, s.dateValue, -r.upDown);
|
|
585
618
|
case "ArrowDown":
|
|
586
|
-
return this._findDayArrows(a, t, s.dateValue,
|
|
619
|
+
return this._findDayArrows(a, t, s.dateValue, r.upDown);
|
|
587
620
|
case "ArrowLeft":
|
|
588
|
-
return this._findDayArrows(a, t, s.dateValue, -
|
|
621
|
+
return this._findDayArrows(a, t, s.dateValue, -r.leftRight);
|
|
589
622
|
case "ArrowRight":
|
|
590
|
-
return this._findDayArrows(a, t, s.dateValue,
|
|
623
|
+
return this._findDayArrows(a, t, s.dateValue, r.leftRight);
|
|
591
624
|
case "PageUp":
|
|
592
625
|
if (this.orientation === "horizontal") {
|
|
593
|
-
const
|
|
594
|
-
return this._findDayPageUpDown(a, t, s,
|
|
626
|
+
const b = (+s.dayValue % y || y) - +s.dayValue;
|
|
627
|
+
return this._findDayPageUpDown(a, t, s, b, r.upDown);
|
|
595
628
|
} else {
|
|
596
|
-
const
|
|
597
|
-
return this._findDayPageUpDown(a, t, s,
|
|
629
|
+
const f = (Math.ceil((+s.dayValue + i) / y) - 1) * y - i + 1 - +s.dayValue;
|
|
630
|
+
return this._findDayPageUpDown(a, t, s, f, r.upDown);
|
|
598
631
|
}
|
|
599
632
|
case "PageDown":
|
|
600
633
|
if (this.orientation === "horizontal") {
|
|
601
|
-
const
|
|
602
|
-
return this._findDayPageUpDown(a, t, s,
|
|
634
|
+
const l = +s.monthValue + 1 > 12 ? 1 : +s.monthValue + 1, b = +s.monthValue + 1 > 12 ? +s.yearValue + 1 : +s.yearValue, f = this._dateAdapter.createDate(b, l, 1), k = this._dateAdapter.getDate(this._dateAdapter.addCalendarDays(f, -1)), Pe = Math.trunc((k - +s.dayValue) / y) * y;
|
|
635
|
+
return this._findDayPageUpDown(a, t, s, Pe, -r.upDown);
|
|
603
636
|
} else {
|
|
604
|
-
const
|
|
605
|
-
return this._findDayPageUpDown(a, t, s,
|
|
637
|
+
const f = Math.ceil((+s.dayValue + i) / y) * y - i - +s.dayValue;
|
|
638
|
+
return this._findDayPageUpDown(a, t, s, f, -r.upDown);
|
|
606
639
|
}
|
|
607
640
|
case "Home":
|
|
608
641
|
return this._findDayFirst(a, t, s, 1);
|
|
609
642
|
case "End": {
|
|
610
|
-
const
|
|
611
|
-
return this._findDayLast(a, t,
|
|
643
|
+
const l = +s.monthValue + 1 > 12 ? 1 : +s.monthValue + 1, b = +s.monthValue + 1 > 12 ? +s.yearValue + 1 : +s.yearValue, f = this._dateAdapter.createDate(b, l, 1);
|
|
644
|
+
return this._findDayLast(a, t, f);
|
|
612
645
|
}
|
|
613
646
|
default:
|
|
614
647
|
return a[t];
|
|
@@ -618,32 +651,32 @@ let St = (() => {
|
|
|
618
651
|
return e < this._keyboardNavigationDayViewParameters.firstDayInView || e > this._keyboardNavigationDayViewParameters.lastDayInView;
|
|
619
652
|
}
|
|
620
653
|
_findDayArrows(e, t, a, s) {
|
|
621
|
-
const
|
|
622
|
-
if (this._isDayOutOfView(
|
|
654
|
+
const r = this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(a, s));
|
|
655
|
+
if (this._isDayOutOfView(r))
|
|
623
656
|
return e[t];
|
|
624
|
-
const
|
|
625
|
-
return !
|
|
657
|
+
const i = e.find((l) => this._mapValueToISODate(l.value) === r);
|
|
658
|
+
return !i || i.disabled ? this._findDayArrows(e, t, this._dateAdapter.deserialize(r), s) : i;
|
|
626
659
|
}
|
|
627
|
-
_findDayPageUpDown(e, t, a, s,
|
|
628
|
-
const
|
|
629
|
-
if (this._isDayOutOfView(
|
|
660
|
+
_findDayPageUpDown(e, t, a, s, r) {
|
|
661
|
+
const i = this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(a.dateValue, s));
|
|
662
|
+
if (this._isDayOutOfView(i))
|
|
630
663
|
return e[t];
|
|
631
|
-
const
|
|
632
|
-
return !
|
|
664
|
+
const l = e.find((b) => this._mapValueToISODate(b.value) === i);
|
|
665
|
+
return !l || l.disabled ? this._findDayPageUpDown(e, t, a, s + r, r) : l;
|
|
633
666
|
}
|
|
634
667
|
_findDayFirst(e, t, a, s) {
|
|
635
|
-
const
|
|
636
|
-
if (this._isDayOutOfView(
|
|
668
|
+
const r = this._dateAdapter.toIso8601(this._dateAdapter.createDate(+a.yearValue, +a.monthValue, s));
|
|
669
|
+
if (this._isDayOutOfView(r))
|
|
637
670
|
return e[t];
|
|
638
|
-
const
|
|
639
|
-
return !
|
|
671
|
+
const i = e.find((l) => this._mapValueToISODate(l.value) === r);
|
|
672
|
+
return !i || i.disabled ? this._findDayFirst(e, t, a, s + 1) : i;
|
|
640
673
|
}
|
|
641
674
|
_findDayLast(e, t, a) {
|
|
642
675
|
const s = this._dateAdapter.toIso8601(this._dateAdapter.addCalendarDays(a, -1));
|
|
643
676
|
if (this._isDayOutOfView(s))
|
|
644
677
|
return e[t];
|
|
645
|
-
const
|
|
646
|
-
return !
|
|
678
|
+
const r = e.find((i) => this._mapValueToISODate(i.value) === s);
|
|
679
|
+
return !r || r.disabled ? this._findDayLast(e, t, this._dateAdapter.deserialize(s)) : r;
|
|
647
680
|
}
|
|
648
681
|
/**
|
|
649
682
|
* Gets the index of the element to move to, based on a list of elements (which can be potentially disabled),
|
|
@@ -652,24 +685,24 @@ let St = (() => {
|
|
|
652
685
|
* while in month and year view it's not due to the fixed amount of rendered cells.
|
|
653
686
|
*/
|
|
654
687
|
_navigateByKeyboard(e, t, a) {
|
|
655
|
-
const { elementIndexForWideMode: s, offsetForWideMode:
|
|
688
|
+
const { elementIndexForWideMode: s, offsetForWideMode: r, lastElementIndexForWideMode: i, verticalOffset: l } = this._calculateParametersForKeyboardNavigation(t, this._calendarView === "year");
|
|
656
689
|
switch (e.key) {
|
|
657
690
|
case "ArrowUp":
|
|
658
|
-
return this._findNext(a, t, -
|
|
691
|
+
return this._findNext(a, t, -l);
|
|
659
692
|
case "ArrowDown":
|
|
660
|
-
return this._findNext(a, t,
|
|
693
|
+
return this._findNext(a, t, l);
|
|
661
694
|
case "ArrowLeft":
|
|
662
695
|
return this._findNext(a, t, -1);
|
|
663
696
|
case "ArrowRight":
|
|
664
697
|
return this._findNext(a, t, 1);
|
|
665
698
|
case "Home":
|
|
666
|
-
return this._findFirst(a,
|
|
699
|
+
return this._findFirst(a, r);
|
|
667
700
|
case "PageUp":
|
|
668
|
-
return this._findFirstOnColumn(a, s,
|
|
701
|
+
return this._findFirstOnColumn(a, s, r, l);
|
|
669
702
|
case "PageDown":
|
|
670
|
-
return this._findLastOnColumn(a, t,
|
|
703
|
+
return this._findLastOnColumn(a, t, i, l);
|
|
671
704
|
case "End":
|
|
672
|
-
return this._findLast(a,
|
|
705
|
+
return this._findLast(a, i - 1);
|
|
673
706
|
default:
|
|
674
707
|
return a[t];
|
|
675
708
|
}
|
|
@@ -680,11 +713,11 @@ let St = (() => {
|
|
|
680
713
|
* @param isYearView Whether the displayed `view` is the year one.
|
|
681
714
|
*/
|
|
682
715
|
_calculateParametersForKeyboardNavigation(e, t) {
|
|
683
|
-
const a = t ?
|
|
716
|
+
const a = t ? $ : Ge, s = Math.trunc(e / a) * a, r = s === 0 ? e : e - a;
|
|
684
717
|
return {
|
|
685
|
-
verticalOffset: t ?
|
|
686
|
-
elementIndexForWideMode:
|
|
687
|
-
offsetForWideMode: e -
|
|
718
|
+
verticalOffset: t ? G : j,
|
|
719
|
+
elementIndexForWideMode: r,
|
|
720
|
+
offsetForWideMode: e - r,
|
|
688
721
|
lastElementIndexForWideMode: s === 0 ? a : a * 2
|
|
689
722
|
};
|
|
690
723
|
}
|
|
@@ -708,13 +741,16 @@ let St = (() => {
|
|
|
708
741
|
}
|
|
709
742
|
/** Find the first enabled element in the same column of the provided array. */
|
|
710
743
|
_findFirstOnColumn(e, t, a, s) {
|
|
711
|
-
const
|
|
712
|
-
return e[
|
|
744
|
+
const r = t % s + a;
|
|
745
|
+
return e[r].disabled ? this._findNext(e, r, s) : e[r];
|
|
713
746
|
}
|
|
714
747
|
/** Find the last enabled element in the same column of the provided array. */
|
|
715
748
|
_findLastOnColumn(e, t, a, s) {
|
|
716
|
-
const
|
|
717
|
-
return e[
|
|
749
|
+
const r = t + Math.trunc((a - t - 1) / s) * s;
|
|
750
|
+
return e[r].disabled ? this._findNext(e, r, -s) : e[r];
|
|
751
|
+
}
|
|
752
|
+
_resetCalendarViewAndEmitMonthChange(e = !1) {
|
|
753
|
+
this._resetCalendarView(e), this._emitMonthChange();
|
|
718
754
|
}
|
|
719
755
|
_resetCalendarView(e = !1) {
|
|
720
756
|
this._containingFocus && (this._resetFocus = !0), this._activeDate = (this.multiple ? this._selected.at(-1) : this._selected) ?? this._dateAdapter.today(), this._setChosenYear(), this._chosenMonth = void 0, this._init(), this._nextCalendarView = this._calendarView = this.view, e && this._startTableTransition();
|
|
@@ -722,12 +758,12 @@ let St = (() => {
|
|
|
722
758
|
/** Render the view for the day selection. */
|
|
723
759
|
_renderDayView() {
|
|
724
760
|
const e = this._wide ? this._dateAdapter.addCalendarMonths(this._activeDate, 1) : void 0;
|
|
725
|
-
return
|
|
761
|
+
return c`
|
|
726
762
|
<div class="sbb-calendar__controls">
|
|
727
763
|
${this._getArrow("left", () => this._goToDifferentMonth(-1), Xe[this._language.current], this._previousMonthDisabled())}
|
|
728
764
|
<div class="sbb-calendar__controls-month">
|
|
729
765
|
${this._createLabelForDayView(this._activeDate)}
|
|
730
|
-
${this._wide ? this._createLabelForDayView(e) :
|
|
766
|
+
${this._wide ? this._createLabelForDayView(e) : p}
|
|
731
767
|
<sbb-screen-reader-only role="status">
|
|
732
768
|
${this._createAriaLabelForDayView(this._activeDate, e)}
|
|
733
769
|
</sbb-screen-reader-only>
|
|
@@ -736,12 +772,12 @@ let St = (() => {
|
|
|
736
772
|
</div>
|
|
737
773
|
<div class="sbb-calendar__table-overflow-break">
|
|
738
774
|
<div class="sbb-calendar__table-container sbb-calendar__table-day-view">
|
|
739
|
-
${this.orientation === "horizontal" ?
|
|
775
|
+
${this.orientation === "horizontal" ? c`
|
|
740
776
|
${this._createDayTable(this._weeks, this._weekNumbers)}
|
|
741
|
-
${this._wide ? this._createDayTable(this._nextMonthWeeks, this._nextMonthWeekNumbers, !0) :
|
|
742
|
-
` :
|
|
777
|
+
${this._wide ? this._createDayTable(this._nextMonthWeeks, this._nextMonthWeekNumbers, !0) : p}
|
|
778
|
+
` : c`
|
|
743
779
|
${this._createDayTableVertical(this._weeks, this._weekNumbers)}
|
|
744
|
-
${this._wide ? this._createDayTableVertical(this._nextMonthWeeks, this._nextMonthWeekNumbers, e) :
|
|
780
|
+
${this._wide ? this._createDayTableVertical(this._nextMonthWeeks, this._nextMonthWeekNumbers, e) : p}
|
|
745
781
|
`}
|
|
746
782
|
</div>
|
|
747
783
|
</div>
|
|
@@ -750,7 +786,7 @@ let St = (() => {
|
|
|
750
786
|
/** Creates the label with the month for the daily view. */
|
|
751
787
|
_createLabelForDayView(e) {
|
|
752
788
|
const t = `${this._monthNames[this._dateAdapter.getMonth(e) - 1]} ${this._dateAdapter.getYear(e)}`;
|
|
753
|
-
return
|
|
789
|
+
return c`
|
|
754
790
|
<button
|
|
755
791
|
type="button"
|
|
756
792
|
class="sbb-calendar__date-selection sbb-calendar__controls-change-date"
|
|
@@ -773,90 +809,90 @@ let St = (() => {
|
|
|
773
809
|
}
|
|
774
810
|
/** Creates the calendar table for the daily view. */
|
|
775
811
|
_createDayTable(e, t, a = !1) {
|
|
776
|
-
const s =
|
|
777
|
-
return
|
|
812
|
+
const s = (this._wide ? [...this._weeks, ...this._nextMonthWeeks] : a ? this._nextMonthWeeks : this._weeks).flat(), r = (a ? this._nextMonthWeeks : this._weeks).flat();
|
|
813
|
+
return c`
|
|
778
814
|
<table
|
|
779
815
|
class="sbb-calendar__table"
|
|
780
|
-
@focusout=${(
|
|
781
|
-
@animationend=${(
|
|
816
|
+
@focusout=${(i) => this._handleTableBlur(i.relatedTarget)}
|
|
817
|
+
@animationend=${(i) => this._tableAnimationEnd(i)}
|
|
782
818
|
>
|
|
783
819
|
<thead class="sbb-calendar__table-header">
|
|
784
820
|
<tr>
|
|
785
|
-
${this.weekNumbers ?
|
|
786
|
-
${this._weekdays.map((
|
|
821
|
+
${this.weekNumbers ? c`<th class="sbb-calendar__table-header-cell"></th>` : p}
|
|
822
|
+
${this._weekdays.map((i, l) => c`
|
|
787
823
|
<th class="sbb-calendar__table-header-cell">
|
|
788
|
-
${this.multiple ?
|
|
824
|
+
${this.multiple ? c`
|
|
789
825
|
<button
|
|
790
826
|
class="sbb-calendar__header-cell sbb-calendar__weekday"
|
|
791
|
-
aria-label=${
|
|
827
|
+
aria-label=${i.long}
|
|
792
828
|
@click=${() => {
|
|
793
|
-
const
|
|
794
|
-
this._selectMultipleDates(
|
|
829
|
+
const b = r.filter((f) => f.weekDayValue === (l + 1) % 7);
|
|
830
|
+
this._selectMultipleDates(b);
|
|
795
831
|
}}
|
|
796
832
|
>
|
|
797
|
-
${
|
|
833
|
+
${i.narrow}
|
|
798
834
|
</button>
|
|
799
|
-
` :
|
|
800
|
-
<sbb-screen-reader-only>${
|
|
801
|
-
<span aria-hidden="true">${
|
|
835
|
+
` : c`
|
|
836
|
+
<sbb-screen-reader-only>${i.long}</sbb-screen-reader-only>
|
|
837
|
+
<span aria-hidden="true">${i.narrow}</span>
|
|
802
838
|
`}
|
|
803
839
|
</th>
|
|
804
840
|
`)}
|
|
805
841
|
</tr>
|
|
806
842
|
</thead>
|
|
807
843
|
<tbody class="sbb-calendar__table-body">
|
|
808
|
-
${e.map((
|
|
809
|
-
const
|
|
810
|
-
return
|
|
844
|
+
${e.map((i, l) => {
|
|
845
|
+
const b = y - i.length;
|
|
846
|
+
return l === 0 && b ? c`
|
|
811
847
|
<tr>
|
|
812
|
-
${this.weekNumbers ?
|
|
813
|
-
<td class="sbb-calendar__table-header-cell">
|
|
814
|
-
${this.multiple ?
|
|
848
|
+
${this.weekNumbers ? c`
|
|
849
|
+
<td class="sbb-calendar__table-header-cell-vertical">
|
|
850
|
+
${this.multiple ? c`
|
|
815
851
|
<button
|
|
816
852
|
class="sbb-calendar__header-cell sbb-calendar__weekday"
|
|
817
|
-
aria-label=${`${
|
|
853
|
+
aria-label=${`${K[this._language.current]} ${t[0]}`}
|
|
818
854
|
@click=${() => {
|
|
819
|
-
const
|
|
820
|
-
this._selectMultipleDates(
|
|
855
|
+
const f = s.filter((k) => k.weekValue === t[0]);
|
|
856
|
+
this._selectMultipleDates(f);
|
|
821
857
|
}}
|
|
822
858
|
>
|
|
823
859
|
${t[0]}
|
|
824
860
|
</button>
|
|
825
|
-
` :
|
|
861
|
+
` : c`
|
|
826
862
|
<sbb-screen-reader-only
|
|
827
|
-
>${`${
|
|
863
|
+
>${`${K[this._language.current]} ${t[0]}`}</sbb-screen-reader-only
|
|
828
864
|
>
|
|
829
865
|
<span aria-hidden="true">${t[0]}</span>
|
|
830
866
|
`}
|
|
831
867
|
</td>
|
|
832
|
-
` :
|
|
833
|
-
${[...Array(
|
|
834
|
-
${this._createDayCells(
|
|
868
|
+
` : p}
|
|
869
|
+
${[...Array(b).keys()].map(() => c`<td class="sbb-calendar__table-data"></td>`)}
|
|
870
|
+
${this._createDayCells(i)}
|
|
835
871
|
</tr>
|
|
836
|
-
` :
|
|
872
|
+
` : c`
|
|
837
873
|
<tr>
|
|
838
|
-
${this.weekNumbers ?
|
|
839
|
-
<td class="sbb-calendar__table-header-cell">
|
|
840
|
-
${this.multiple ?
|
|
874
|
+
${this.weekNumbers ? c`
|
|
875
|
+
<td class="sbb-calendar__table-header-cell-vertical">
|
|
876
|
+
${this.multiple ? c`
|
|
841
877
|
<button
|
|
842
878
|
class="sbb-calendar__header-cell sbb-calendar__weekday"
|
|
843
|
-
aria-label=${`${
|
|
879
|
+
aria-label=${`${K[this._language.current]} ${t[l]}`}
|
|
844
880
|
@click=${() => {
|
|
845
|
-
const
|
|
846
|
-
this._selectMultipleDates(
|
|
881
|
+
const f = s.filter((k) => k.weekValue === t[l]);
|
|
882
|
+
this._selectMultipleDates(f);
|
|
847
883
|
}}
|
|
848
884
|
>
|
|
849
|
-
${t[
|
|
885
|
+
${t[l]}
|
|
850
886
|
</button>
|
|
851
|
-
` :
|
|
887
|
+
` : c`
|
|
852
888
|
<sbb-screen-reader-only
|
|
853
|
-
>${`${
|
|
889
|
+
>${`${K[this._language.current]} ${t[l]}`}</sbb-screen-reader-only
|
|
854
890
|
>
|
|
855
|
-
<span aria-hidden="true">${t[
|
|
891
|
+
<span aria-hidden="true">${t[l]}</span>
|
|
856
892
|
`}
|
|
857
893
|
</td>
|
|
858
|
-
` :
|
|
859
|
-
${this._createDayCells(
|
|
894
|
+
` : p}
|
|
895
|
+
${this._createDayCells(i)}
|
|
860
896
|
</tr>
|
|
861
897
|
`;
|
|
862
898
|
})}
|
|
@@ -866,64 +902,64 @@ let St = (() => {
|
|
|
866
902
|
}
|
|
867
903
|
/** Creates the table in orientation='vertical'. */
|
|
868
904
|
_createDayTableVertical(e, t, a) {
|
|
869
|
-
const s = this._dateAdapter.
|
|
870
|
-
return
|
|
905
|
+
const s = this._dateAdapter.getFirstWeekOffset(a ?? this._activeDate), r = (this._wide ? [...this._weeks, ...this._nextMonthWeeks] : a ? this._nextMonthWeeks : this._weeks).flat();
|
|
906
|
+
return c`
|
|
871
907
|
<table
|
|
872
908
|
class="sbb-calendar__table"
|
|
873
|
-
@focusout=${(
|
|
874
|
-
@animationend=${(
|
|
909
|
+
@focusout=${(i) => this._handleTableBlur(i.relatedTarget)}
|
|
910
|
+
@animationend=${(i) => this._tableAnimationEnd(i)}
|
|
875
911
|
>
|
|
876
|
-
${this.weekNumbers ?
|
|
912
|
+
${this.weekNumbers ? c`
|
|
877
913
|
<thead class="sbb-calendar__table-header">
|
|
878
914
|
<tr>
|
|
879
|
-
${a ?
|
|
880
|
-
${t.map((
|
|
915
|
+
${a ? p : c`<th class="sbb-calendar__table-data"></th>`}
|
|
916
|
+
${t.map((i) => c`
|
|
881
917
|
<th class="sbb-calendar__table-header-cell">
|
|
882
|
-
${this.multiple ?
|
|
918
|
+
${this.multiple ? c`
|
|
883
919
|
<button
|
|
884
920
|
class="sbb-calendar__header-cell sbb-calendar__weekday"
|
|
885
|
-
aria-label=${`${
|
|
921
|
+
aria-label=${`${K[this._language.current]} ${i}`}
|
|
886
922
|
@click=${() => {
|
|
887
|
-
const
|
|
888
|
-
this._selectMultipleDates(
|
|
923
|
+
const l = r.filter((b) => b.weekValue === i);
|
|
924
|
+
this._selectMultipleDates(l);
|
|
889
925
|
}}
|
|
890
926
|
>
|
|
891
|
-
${
|
|
927
|
+
${i}
|
|
892
928
|
</button>
|
|
893
|
-
` :
|
|
929
|
+
` : c`
|
|
894
930
|
<sbb-screen-reader-only
|
|
895
|
-
>${`${
|
|
931
|
+
>${`${K[this._language.current]} ${i}`}</sbb-screen-reader-only
|
|
896
932
|
>
|
|
897
|
-
<span aria-hidden="true">${
|
|
933
|
+
<span aria-hidden="true">${i}</span>
|
|
898
934
|
`}
|
|
899
935
|
</th>
|
|
900
936
|
`)}
|
|
901
937
|
</tr>
|
|
902
938
|
</thead>
|
|
903
|
-
` :
|
|
939
|
+
` : p}
|
|
904
940
|
<tbody class="sbb-calendar__table-body">
|
|
905
|
-
${e.map((
|
|
906
|
-
const
|
|
907
|
-
return
|
|
941
|
+
${e.map((i, l) => {
|
|
942
|
+
const b = this._weekdays[l], f = this._wide ? [...i, ...this._nextMonthWeeks[l]] : i;
|
|
943
|
+
return c`
|
|
908
944
|
<tr>
|
|
909
|
-
${a ?
|
|
910
|
-
<td class="sbb-calendar__table-header-cell">
|
|
911
|
-
${this.multiple ?
|
|
945
|
+
${a ? p : c`
|
|
946
|
+
<td class="sbb-calendar__table-header-cell-vertical">
|
|
947
|
+
${this.multiple ? c`
|
|
912
948
|
<button
|
|
913
949
|
class="sbb-calendar__header-cell sbb-calendar__weekday"
|
|
914
|
-
aria-label=${
|
|
915
|
-
@click=${() => this._selectMultipleDates(
|
|
950
|
+
aria-label=${b.long}
|
|
951
|
+
@click=${() => this._selectMultipleDates(f)}
|
|
916
952
|
>
|
|
917
|
-
${
|
|
953
|
+
${b.narrow}
|
|
918
954
|
</button>
|
|
919
|
-
` :
|
|
920
|
-
<sbb-screen-reader-only>${
|
|
921
|
-
<span aria-hidden="true">${
|
|
955
|
+
` : c`
|
|
956
|
+
<sbb-screen-reader-only>${b.long}</sbb-screen-reader-only>
|
|
957
|
+
<span aria-hidden="true">${b.narrow}</span>
|
|
922
958
|
`}
|
|
923
959
|
</td>
|
|
924
960
|
`}
|
|
925
|
-
${
|
|
926
|
-
${this._createDayCells(
|
|
961
|
+
${l < s ? c`<td class="sbb-calendar__table-data"></td>` : p}
|
|
962
|
+
${this._createDayCells(i)}
|
|
927
963
|
</tr>
|
|
928
964
|
`;
|
|
929
965
|
})}
|
|
@@ -932,46 +968,22 @@ let St = (() => {
|
|
|
932
968
|
`;
|
|
933
969
|
}
|
|
934
970
|
/** Creates the cells for the daily view. */
|
|
935
|
-
_createDayCells(e
|
|
936
|
-
return e.map((
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
>
|
|
946
|
-
<button
|
|
947
|
-
class=${Q({
|
|
948
|
-
"sbb-calendar__cell": !0,
|
|
949
|
-
"sbb-calendar__day": !0,
|
|
950
|
-
"sbb-calendar__cell-current": l,
|
|
951
|
-
"sbb-calendar__selected": r,
|
|
952
|
-
"sbb-calendar__crossed-out": !s && i
|
|
953
|
-
})}
|
|
954
|
-
@click=${() => this._selectDate(a.dateValue)}
|
|
955
|
-
?disabled=${s || i}
|
|
956
|
-
value=${a.value}
|
|
957
|
-
type="button"
|
|
958
|
-
aria-label=${this._dateAdapter.getAccessibilityFormatDate(a.value)}
|
|
959
|
-
aria-pressed=${r}
|
|
960
|
-
aria-disabled=${s || i}
|
|
961
|
-
aria-current=${l ? "date" : m}
|
|
962
|
-
tabindex="-1"
|
|
963
|
-
@keydown=${(c) => this._handleKeyboardEvent(c, a)}
|
|
964
|
-
sbb-popover-close
|
|
965
|
-
>
|
|
966
|
-
${a.dayValue}
|
|
967
|
-
</button>
|
|
971
|
+
_createDayCells(e) {
|
|
972
|
+
return e.map((t) => c`
|
|
973
|
+
<td class=" sbb-calendar__table-data sbb-calendar__day-cell">
|
|
974
|
+
<slot name=${t.value}>
|
|
975
|
+
<sbb-calendar-day
|
|
976
|
+
slot=${t.value}
|
|
977
|
+
@click=${() => this._selectDate(t.dateValue)}
|
|
978
|
+
@keydown=${(a) => this._handleKeyboardEvent(a, t)}
|
|
979
|
+
></sbb-calendar-day>
|
|
980
|
+
</slot>
|
|
968
981
|
</td>
|
|
969
|
-
|
|
970
|
-
});
|
|
982
|
+
`);
|
|
971
983
|
}
|
|
972
984
|
/** Render the view for the month selection. */
|
|
973
985
|
_renderMonthView() {
|
|
974
|
-
return
|
|
986
|
+
return c`
|
|
975
987
|
<div class="sbb-calendar__controls">
|
|
976
988
|
${this._getArrow("left", () => this._goToDifferentYear(-1), tt[this._language.current], this._previousYearDisabled())}
|
|
977
989
|
<div class="sbb-calendar__controls-month">${this._createLabelForMonthView()}</div>
|
|
@@ -980,71 +992,70 @@ let St = (() => {
|
|
|
980
992
|
<div class="sbb-calendar__table-overflow-break">
|
|
981
993
|
<div class="sbb-calendar__table-container sbb-calendar__table-month-view">
|
|
982
994
|
${this._createMonthTable(this._months, this._chosenYear)}
|
|
983
|
-
${this._wide ? this._createMonthTable(this._months, this._chosenYear + 1) :
|
|
995
|
+
${this._wide ? this._createMonthTable(this._months, this._chosenYear + 1) : p}
|
|
984
996
|
</div>
|
|
985
997
|
</div>
|
|
986
998
|
`;
|
|
987
999
|
}
|
|
988
1000
|
/** Creates the label with the year for the monthly view. */
|
|
989
1001
|
_createLabelForMonthView() {
|
|
990
|
-
return
|
|
1002
|
+
return c` <button
|
|
991
1003
|
type="button"
|
|
992
1004
|
id="sbb-calendar__month-selection"
|
|
993
1005
|
class="sbb-calendar__controls-change-date"
|
|
994
|
-
aria-label=${`${
|
|
995
|
-
@click=${() => this.
|
|
1006
|
+
aria-label=${`${Re[this._language.current]} ${this._chosenYear}`}
|
|
1007
|
+
@click=${() => this._resetCalendarViewAndEmitMonthChange(!0)}
|
|
996
1008
|
>
|
|
997
|
-
${this._chosenYear} ${this._wide ? ` - ${this._chosenYear + 1}` :
|
|
1009
|
+
${this._chosenYear} ${this._wide ? ` - ${this._chosenYear + 1}` : p}
|
|
998
1010
|
<sbb-icon name="chevron-small-up-small"></sbb-icon>
|
|
999
1011
|
</button>
|
|
1000
1012
|
<sbb-screen-reader-only role="status"> ${this._chosenYear} </sbb-screen-reader-only>`;
|
|
1001
1013
|
}
|
|
1002
1014
|
/** Creates the table for the month selection view. */
|
|
1003
1015
|
_createMonthTable(e, t) {
|
|
1004
|
-
return
|
|
1016
|
+
return c`
|
|
1005
1017
|
<table
|
|
1006
1018
|
class="sbb-calendar__table"
|
|
1007
1019
|
@animationend=${(a) => this._tableAnimationEnd(a)}
|
|
1008
1020
|
>
|
|
1009
|
-
${this._wide ?
|
|
1021
|
+
${this._wide ? c`<thead class="sbb-calendar__table-header" aria-hidden="true">
|
|
1010
1022
|
<tr>
|
|
1011
|
-
<th class="sbb-calendar__table-header-cell" colspan=${
|
|
1023
|
+
<th class="sbb-calendar__table-header-cell" colspan=${j}>${t}</th>
|
|
1012
1024
|
</tr>
|
|
1013
|
-
</thead>` :
|
|
1025
|
+
</thead>` : p}
|
|
1014
1026
|
<tbody class="sbb-calendar__table-body">
|
|
1015
|
-
${e.map((a) =>
|
|
1027
|
+
${e.map((a) => c`
|
|
1016
1028
|
<tr>
|
|
1017
1029
|
${a.map((s) => {
|
|
1018
|
-
let
|
|
1030
|
+
let r;
|
|
1019
1031
|
if (this.multiple)
|
|
1020
|
-
|
|
1032
|
+
r = this._selected.find((f) => t === this._dateAdapter.getYear(f) && s.monthValue === this._dateAdapter.getMonth(f)) !== void 0;
|
|
1021
1033
|
else {
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1034
|
+
const f = this._selected ? this._dateAdapter.getMonth(this._selected) : void 0, k = this._selected ? this._dateAdapter.getYear(this._selected) : void 0;
|
|
1035
|
+
r = !!this._selected && t === k && s.monthValue === f;
|
|
1024
1036
|
}
|
|
1025
|
-
const
|
|
1026
|
-
return
|
|
1027
|
-
class=${
|
|
1037
|
+
const i = !this._isMonthInRange(s.monthValue, t), l = !this._isMonthFilteredOut(s.monthValue, t), b = t === this._dateAdapter.getYear(this._dateAdapter.today()) && this._dateAdapter.getMonth(this._dateAdapter.today()) === s.monthValue;
|
|
1038
|
+
return c` <td
|
|
1039
|
+
class=${J({
|
|
1028
1040
|
"sbb-calendar__table-data": !0,
|
|
1029
1041
|
"sbb-calendar__table-month": !0
|
|
1030
1042
|
})}
|
|
1031
1043
|
>
|
|
1032
1044
|
<button
|
|
1033
|
-
class=${
|
|
1045
|
+
class=${J({
|
|
1034
1046
|
"sbb-calendar__cell": !0,
|
|
1035
|
-
"sbb-
|
|
1036
|
-
"sbb-
|
|
1037
|
-
"sbb-
|
|
1038
|
-
"sbb-calendar__selected": i
|
|
1047
|
+
"sbb-calendar__cell-current": b,
|
|
1048
|
+
"sbb-calendar__crossed-out": !i && l,
|
|
1049
|
+
"sbb-calendar__selected": r
|
|
1039
1050
|
})}
|
|
1040
1051
|
@click=${() => this._onMonthSelection(s.monthValue, t)}
|
|
1041
|
-
?disabled=${
|
|
1052
|
+
?disabled=${i || l}
|
|
1042
1053
|
aria-label=${`${s.longValue} ${t}`}
|
|
1043
|
-
aria-pressed=${
|
|
1044
|
-
aria-disabled=${String(
|
|
1054
|
+
aria-pressed=${r}
|
|
1055
|
+
aria-disabled=${String(i || l)}
|
|
1045
1056
|
tabindex="-1"
|
|
1046
|
-
data-month=${s.monthValue ||
|
|
1047
|
-
@keydown=${(
|
|
1057
|
+
data-month=${s.monthValue || p}
|
|
1058
|
+
@keydown=${(f) => this._handleKeyboardEvent(f)}
|
|
1048
1059
|
>
|
|
1049
1060
|
${s.value}
|
|
1050
1061
|
</button>
|
|
@@ -1058,27 +1069,27 @@ let St = (() => {
|
|
|
1058
1069
|
}
|
|
1059
1070
|
/** Select the month and change the view to day selection. */
|
|
1060
1071
|
_onMonthSelection(e, t) {
|
|
1061
|
-
this._chosenMonth = e, this._nextCalendarView = "day", this._init(this._dateAdapter.createDate(t, this._chosenMonth, this._dateAdapter.getDate(this._activeDate))), this._startTableTransition();
|
|
1072
|
+
this._chosenMonth = e, this._nextCalendarView = "day", this._init(this._dateAdapter.createDate(t, this._chosenMonth, this._dateAdapter.getDate(this._activeDate))), this._startTableTransition(), this._emitMonthChange();
|
|
1062
1073
|
}
|
|
1063
1074
|
/** Render the view for the year selection. */
|
|
1064
1075
|
_renderYearView() {
|
|
1065
|
-
return
|
|
1076
|
+
return c`
|
|
1066
1077
|
<div class="sbb-calendar__controls">
|
|
1067
|
-
${this._getArrow("left", () => this._goToDifferentYearRange(
|
|
1078
|
+
${this._getArrow("left", () => this._goToDifferentYearRange(-$), st($)[this._language.current], this._previousYearRangeDisabled())}
|
|
1068
1079
|
<div class="sbb-calendar__controls-month">${this._createLabelForYearView()}</div>
|
|
1069
|
-
${this._getArrow("right", () => this._goToDifferentYearRange(
|
|
1080
|
+
${this._getArrow("right", () => this._goToDifferentYearRange($), rt($)[this._language.current], this._nextYearRangeDisabled())}
|
|
1070
1081
|
</div>
|
|
1071
1082
|
<div class="sbb-calendar__table-overflow-break">
|
|
1072
1083
|
<div class="sbb-calendar__table-container sbb-calendar__table-year-view">
|
|
1073
1084
|
${this._createYearTable(this._years)}
|
|
1074
|
-
${this._wide ? this._createYearTable(this._nextMonthYears, !0) :
|
|
1085
|
+
${this._wide ? this._createYearTable(this._nextMonthYears, !0) : p}
|
|
1075
1086
|
</div>
|
|
1076
1087
|
</div>
|
|
1077
1088
|
`;
|
|
1078
1089
|
}
|
|
1079
1090
|
/** Creates the button arrow for all the views. */
|
|
1080
1091
|
_getArrow(e, t, a, s) {
|
|
1081
|
-
return
|
|
1092
|
+
return c`<sbb-secondary-button
|
|
1082
1093
|
size="m"
|
|
1083
1094
|
icon-name="chevron-small-${e}-small"
|
|
1084
1095
|
aria-label=${a}
|
|
@@ -1090,13 +1101,13 @@ let St = (() => {
|
|
|
1090
1101
|
/** Creates the label with the year range for the yearly view. */
|
|
1091
1102
|
_createLabelForYearView() {
|
|
1092
1103
|
const e = this._years.flat()[0], t = (this._wide ? this._nextMonthYears : this._years).flat(), a = t[t.length - 1], s = `${e} - ${a}`;
|
|
1093
|
-
return
|
|
1104
|
+
return c`
|
|
1094
1105
|
<button
|
|
1095
1106
|
type="button"
|
|
1096
1107
|
id="sbb-calendar__year-selection"
|
|
1097
1108
|
class="sbb-calendar__controls-change-date"
|
|
1098
|
-
aria-label="${
|
|
1099
|
-
@click=${() => this.
|
|
1109
|
+
aria-label="${Re[this._language.current]} ${s}"
|
|
1110
|
+
@click=${() => this._resetCalendarViewAndEmitMonthChange(!0)}
|
|
1100
1111
|
>
|
|
1101
1112
|
${s}
|
|
1102
1113
|
<sbb-icon name="chevron-small-up-small"></sbb-icon>
|
|
@@ -1107,40 +1118,39 @@ let St = (() => {
|
|
|
1107
1118
|
/** Creates the table for the year selection view. */
|
|
1108
1119
|
_createYearTable(e, t = !1) {
|
|
1109
1120
|
const a = this._dateAdapter.today();
|
|
1110
|
-
return
|
|
1121
|
+
return c` <table
|
|
1111
1122
|
class="sbb-calendar__table"
|
|
1112
1123
|
@animationend=${(s) => this._tableAnimationEnd(s)}
|
|
1113
1124
|
>
|
|
1114
1125
|
<tbody class="sbb-calendar__table-body">
|
|
1115
|
-
${e.map((s) =>
|
|
1116
|
-
${s.map((
|
|
1117
|
-
let
|
|
1126
|
+
${e.map((s) => c` <tr>
|
|
1127
|
+
${s.map((r) => {
|
|
1128
|
+
let i;
|
|
1118
1129
|
if (this.multiple)
|
|
1119
|
-
|
|
1130
|
+
i = this._selected.find((k) => r === this._dateAdapter.getYear(k)) !== void 0;
|
|
1120
1131
|
else {
|
|
1121
|
-
const
|
|
1122
|
-
|
|
1132
|
+
const k = this._selected ? this._dateAdapter.getYear(this._selected) : void 0;
|
|
1133
|
+
i = !!this._selected && r === k;
|
|
1123
1134
|
}
|
|
1124
|
-
const
|
|
1125
|
-
return
|
|
1135
|
+
const l = !this._isYearInRange(r), b = !this._isYearFilteredOut(r), f = this._dateAdapter.getYear(a) === r;
|
|
1136
|
+
return c` <td class="sbb-calendar__table-data sbb-calendar__table-year">
|
|
1126
1137
|
<button
|
|
1127
|
-
class=${
|
|
1138
|
+
class=${J({
|
|
1128
1139
|
"sbb-calendar__cell": !0,
|
|
1129
|
-
"sbb-
|
|
1130
|
-
"sbb-
|
|
1131
|
-
"sbb-
|
|
1132
|
-
"sbb-calendar__selected": l
|
|
1140
|
+
"sbb-calendar__cell-current": f,
|
|
1141
|
+
"sbb-calendar__crossed-out": !l && b,
|
|
1142
|
+
"sbb-calendar__selected": i
|
|
1133
1143
|
})}
|
|
1134
|
-
@click=${() => this._onYearSelection(
|
|
1135
|
-
?disabled=${
|
|
1136
|
-
aria-label=${
|
|
1137
|
-
aria-pressed=${
|
|
1138
|
-
aria-disabled=${String(
|
|
1144
|
+
@click=${() => this._onYearSelection(r, t)}
|
|
1145
|
+
?disabled=${l || b}
|
|
1146
|
+
aria-label=${r}
|
|
1147
|
+
aria-pressed=${i}
|
|
1148
|
+
aria-disabled=${String(l || b)}
|
|
1139
1149
|
tabindex="-1"
|
|
1140
|
-
data-year=${
|
|
1141
|
-
@keydown=${(
|
|
1150
|
+
data-year=${r || p}
|
|
1151
|
+
@keydown=${(k) => this._handleKeyboardEvent(k)}
|
|
1142
1152
|
>
|
|
1143
|
-
${
|
|
1153
|
+
${r}
|
|
1144
1154
|
</button>
|
|
1145
1155
|
</td>`;
|
|
1146
1156
|
})}
|
|
@@ -1153,8 +1163,8 @@ let St = (() => {
|
|
|
1153
1163
|
this._chosenYear = t ? e - 1 : e, this._nextCalendarView = "month", this._assignActiveDate(this._dateAdapter.createDate(this._chosenYear, this._dateAdapter.getMonth(this._activeDate), this._dateAdapter.getDate(this._activeDate))), this._startTableTransition();
|
|
1154
1164
|
}
|
|
1155
1165
|
_getView() {
|
|
1156
|
-
if (
|
|
1157
|
-
return
|
|
1166
|
+
if (We || this.hydrationRequired)
|
|
1167
|
+
return c`${p}`;
|
|
1158
1168
|
switch (this._calendarView) {
|
|
1159
1169
|
case "year":
|
|
1160
1170
|
return this._renderYearView();
|
|
@@ -1172,43 +1182,45 @@ let St = (() => {
|
|
|
1172
1182
|
this.internals.states.add("transition"), this.shadowRoot?.querySelectorAll("table")?.forEach((e) => e.classList.toggle("sbb-calendar__table-hide"));
|
|
1173
1183
|
}
|
|
1174
1184
|
render() {
|
|
1175
|
-
return
|
|
1185
|
+
return c`<div class="sbb-calendar__wrapper">${this._getView()}</div>`;
|
|
1176
1186
|
}
|
|
1177
|
-
},
|
|
1178
|
-
const e = typeof Symbol == "function" && Symbol.metadata ? Object.create(
|
|
1179
|
-
|
|
1187
|
+
}, S = new WeakMap(), W = new WeakMap(), I = new WeakMap(), N = new WeakMap(), R = new WeakMap(), T = new WeakMap(), E = new WeakMap(), P = new WeakMap(), L = new WeakMap(), H = new WeakMap(), B = new WeakMap(), q = new WeakMap(), h = g, (() => {
|
|
1188
|
+
const e = typeof Symbol == "function" && Symbol.metadata ? Object.create(m[Symbol.metadata] ?? null) : void 0;
|
|
1189
|
+
V = [X(), Y({ type: Boolean })], M = [Y()], te = [Ne(), Y()], re = [Ne(), Y()], le = [X(), Je((t, a) => t._onMultipleChanged(a)), Y({ type: Boolean })], ce = [Y()], he = [Q()], ue = [Y({ attribute: "date-filter" })], me = [Y({ reflect: !0 })], we = [X(), Y({ attribute: "week-numbers", type: Boolean })], ke = [Q()], Ve = [Q()], $e = [Q()], ze = [Q()], w(g, null, V, { kind: "accessor", name: "wide", static: !1, private: !1, access: { has: (t) => "wide" in t, get: (t) => t.wide, set: (t, a) => {
|
|
1180
1190
|
t.wide = a;
|
|
1181
|
-
} }, metadata: e }, O,
|
|
1191
|
+
} }, metadata: e }, O, D), w(g, null, M, { kind: "accessor", name: "view", static: !1, private: !1, access: { has: (t) => "view" in t, get: (t) => t.view, set: (t, a) => {
|
|
1182
1192
|
t.view = a;
|
|
1183
|
-
} }, metadata: e },
|
|
1193
|
+
} }, metadata: e }, C, ee), w(g, null, te, { kind: "accessor", name: "min", static: !1, private: !1, access: { has: (t) => "min" in t, get: (t) => t.min, set: (t, a) => {
|
|
1184
1194
|
t.min = a;
|
|
1185
|
-
} }, metadata: e },
|
|
1195
|
+
} }, metadata: e }, ae, se), w(g, null, re, { kind: "accessor", name: "max", static: !1, private: !1, access: { has: (t) => "max" in t, get: (t) => t.max, set: (t, a) => {
|
|
1186
1196
|
t.max = a;
|
|
1187
|
-
} }, metadata: e },
|
|
1197
|
+
} }, metadata: e }, ie, ne), w(g, null, le, { kind: "accessor", name: "multiple", static: !1, private: !1, access: { has: (t) => "multiple" in t, get: (t) => t.multiple, set: (t, a) => {
|
|
1188
1198
|
t.multiple = a;
|
|
1189
|
-
} }, metadata: e },
|
|
1199
|
+
} }, metadata: e }, oe, de), w(g, null, ce, { kind: "setter", name: "selected", static: !1, private: !1, access: { has: (t) => "selected" in t, set: (t, a) => {
|
|
1190
1200
|
t.selected = a;
|
|
1191
|
-
} }, metadata: e }, null,
|
|
1201
|
+
} }, metadata: e }, null, v), w(g, null, he, { kind: "accessor", name: "_selected", static: !1, private: !1, access: { has: (t) => "_selected" in t, get: (t) => t._selected, set: (t, a) => {
|
|
1192
1202
|
t._selected = a;
|
|
1193
|
-
} }, metadata: e },
|
|
1203
|
+
} }, metadata: e }, be, _e), w(g, null, ue, { kind: "accessor", name: "dateFilter", static: !1, private: !1, access: { has: (t) => "dateFilter" in t, get: (t) => t.dateFilter, set: (t, a) => {
|
|
1194
1204
|
t.dateFilter = a;
|
|
1195
|
-
} }, metadata: e },
|
|
1205
|
+
} }, metadata: e }, fe, ge), w(g, null, me, { kind: "accessor", name: "orientation", static: !1, private: !1, access: { has: (t) => "orientation" in t, get: (t) => t.orientation, set: (t, a) => {
|
|
1196
1206
|
t.orientation = a;
|
|
1197
|
-
} }, metadata: e },
|
|
1207
|
+
} }, metadata: e }, pe, ve), w(g, null, we, { kind: "accessor", name: "weekNumbers", static: !1, private: !1, access: { has: (t) => "weekNumbers" in t, get: (t) => t.weekNumbers, set: (t, a) => {
|
|
1198
1208
|
t.weekNumbers = a;
|
|
1199
|
-
} }, metadata: e },
|
|
1209
|
+
} }, metadata: e }, ye, De), w(g, null, ke, { kind: "accessor", name: "_activeDate", static: !1, private: !1, access: { has: (t) => "_activeDate" in t, get: (t) => t._activeDate, set: (t, a) => {
|
|
1200
1210
|
t._activeDate = a;
|
|
1201
|
-
} }, metadata: e },
|
|
1211
|
+
} }, metadata: e }, Ae, xe), w(g, null, Ve, { kind: "setter", name: "_wide", static: !1, private: !1, access: { has: (t) => "_wide" in t, set: (t, a) => {
|
|
1202
1212
|
t._wide = a;
|
|
1203
|
-
} }, metadata: e }, null,
|
|
1213
|
+
} }, metadata: e }, null, v), w(g, null, $e, { kind: "accessor", name: "_calendarView", static: !1, private: !1, access: { has: (t) => "_calendarView" in t, get: (t) => t._calendarView, set: (t, a) => {
|
|
1204
1214
|
t._calendarView = a;
|
|
1205
|
-
} }, metadata: e },
|
|
1215
|
+
} }, metadata: e }, Me, Ye), w(g, null, ze, { kind: "accessor", name: "_initialized", static: !1, private: !1, access: { has: (t) => "_initialized" in t, get: (t) => t._initialized, set: (t, a) => {
|
|
1206
1216
|
t._initialized = a;
|
|
1207
|
-
} }, metadata: e },
|
|
1217
|
+
} }, metadata: e }, Fe, Oe), w(null, n = { value: h }, o, { kind: "class", name: h.name, metadata: e }, null, d), h = n.value, e && Object.defineProperty(h, Symbol.metadata, { enumerable: !0, configurable: !0, writable: !0, value: e });
|
|
1208
1218
|
})(), g.styles = [lt, vt], g.events = {
|
|
1209
|
-
dateselected: "dateselected"
|
|
1210
|
-
|
|
1219
|
+
dateselected: "dateselected",
|
|
1220
|
+
monthchange: "monthchange"
|
|
1221
|
+
}, _(h, d), h;
|
|
1211
1222
|
})();
|
|
1212
1223
|
export {
|
|
1213
|
-
|
|
1224
|
+
Tt as SbbCalendarElement,
|
|
1225
|
+
wt as SbbMonthChangeEvent
|
|
1214
1226
|
};
|