@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.
Files changed (36) hide show
  1. package/calendar/{calendar.component.js → calendar/calendar.component.js} +413 -401
  2. package/calendar/calendar-day/calendar-day.component.js +98 -0
  3. package/calendar/calendar-day.js +4 -0
  4. package/calendar/calendar.js +5 -0
  5. package/calendar.js +5 -2
  6. package/core/styles/core.scss +1 -0
  7. package/core.css +1 -0
  8. package/custom-elements.json +19029 -18151
  9. package/datepicker/datepicker/datepicker.component.js +1 -1
  10. package/development/calendar/{calendar.component.d.ts → calendar/calendar.component.d.ts} +23 -3
  11. package/development/calendar/calendar/calendar.component.d.ts.map +1 -0
  12. package/development/calendar/calendar/calendar.component.js +1990 -0
  13. package/development/calendar/calendar-day/calendar-day.component.d.ts +49 -0
  14. package/development/calendar/calendar-day/calendar-day.component.d.ts.map +1 -0
  15. package/development/calendar/calendar-day/calendar-day.component.js +255 -0
  16. package/development/calendar/calendar-day.d.ts +5 -0
  17. package/development/calendar/calendar-day.d.ts.map +1 -0
  18. package/development/calendar/calendar-day.js +5 -0
  19. package/development/calendar/calendar.d.ts +5 -0
  20. package/development/calendar/calendar.d.ts.map +1 -0
  21. package/development/calendar/calendar.js +6 -0
  22. package/development/calendar.d.ts +2 -1
  23. package/development/calendar.d.ts.map +1 -1
  24. package/development/calendar.js +6 -3
  25. package/development/datepicker/datepicker/datepicker.component.d.ts.map +1 -1
  26. package/development/datepicker/datepicker/datepicker.component.js +2 -1
  27. package/development/form-field/form-field/form-field.component.js +7 -5
  28. package/form-field/form-field/form-field.component.js +11 -11
  29. package/index.d.ts +3 -1
  30. package/index.js +3 -1
  31. package/off-brand-theme.css +1 -0
  32. package/package.json +11 -1
  33. package/safety-theme.css +1 -0
  34. package/standard-theme.css +1 -0
  35. package/development/calendar/calendar.component.d.ts.map +0 -1
  36. package/development/calendar/calendar.component.js +0 -1957
@@ -0,0 +1,98 @@
1
+ import { __esDecorate as d, __runInitializers as h } from "tslib";
2
+ import { css as y, html as f } from "lit";
3
+ import { customElement as g, property as p, state as m } from "lit/decorators.js";
4
+ import { SbbButtonLikeBaseElement as _ } from "../../core/base-elements.js";
5
+ import { readConfig as x } from "../../core/config/config.js";
6
+ import { SbbPropertyWatcherController as S } from "../../core/controllers.js";
7
+ import { defaultDateAdapter as D } from "../../core/datetime/native-date-adapter.js";
8
+ import { SbbDisabledMixin as k } from "../../core/mixins.js";
9
+ import { boxSizingStyles as A } from "../../core/styles.js";
10
+ const w = y`:host{display:block;--sbb-calendar-day-width: 2.75rem;--sbb-calendar-day-height: 3rem;--sbb-calendar-day-cell-background-color: var(--sbb-calendar-cell-background-color);--sbb-calendar-day-selected-border: none;--sbb-calendar-day-transition-duration: var( --sbb-disable-animation-duration, var(--sbb-animation-duration-2x) );--sbb-calendar-day-transition-easing-function: var(--sbb-animation-easing);--sbb-calendar-day-cursor: var(--sbb-cursor-pointer);--sbb-calendar-day-border-radius: var(--sbb-border-radius-4x);--sbb-calendar-day-flex-direction: column;--sbb-calendar-day-justify-content: initial;--sbb-calendar-day-align-items: initial;--sbb-calendar-day-value-height: var(--sbb-spacing-fixed-6x);--sbb-calendar-day-extra-display: block;--sbb-calendar-day-extra-height: var(--sbb-spacing-fixed-4x);--sbb-calendar-day-crossed-out-top: 33%;--sbb-calendar-day-crossed-out-translate: translate(-50%, -33%) rotate(-45deg)}:host(:is(:state(selected),[state--selected])){--sbb-calendar-day-selected-border: var(--sbb-border-width-2x) solid var(--sbb-border-color-2)}:host(:disabled){--sbb-calendar-cell-color: var(--sbb-calendar-cell-disabled-color);--sbb-calendar-day-cursor: unset}:host(:focus-visible){outline:0}:host(:not(:disabled):active){--sbb-calendar-day-cell-background-color: var(--sbb-calendar-cell-background-color-active)}.sbb-calendar-day{--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;flex-direction:var(--sbb-calendar-day-flex-direction);justify-content:var(--sbb-calendar-day-justify-content);align-items:var(--sbb-calendar-day-align-items);height:var(--sbb-calendar-day-height);width:var(--sbb-calendar-day-width);padding:var(--sbb-calendar-cell-padding);padding-block-end:var(--sbb-calendar-day-cell-padding-hover, var(--sbb-calendar-cell-padding));margin:auto;color:var(--sbb-calendar-cell-color);cursor:var(--sbb-calendar-day-cursor);position:relative;z-index:0}.sbb-calendar-day:before{content:"";position:absolute;inset:0;background-color:var(--sbb-calendar-day-cell-background-color);border:var(--sbb-calendar-day-selected-border);border-radius:var(--sbb-calendar-day-border-radius);z-index:-1;transition-duration:var(--sbb-calendar-day-transition-duration);transition-timing-function:var(--sbb-calendar-day-transition-easing-function);transition-property:background-color}:host(:focus-visible) .sbb-calendar-day: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)}@media(forced-colors:active){:host(:not(:disabled):active) .sbb-calendar-day: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}}@media(any-hover:hover){:host(:not(:active,:disabled):hover) .sbb-calendar-day{--sbb-calendar-day-cell-background-color: var(--sbb-calendar-cell-background-color-hover);--sbb-calendar-day-cell-padding-hover: calc( .0625rem + var(--sbb-calendar-cell-padding) )}}@media(any-hover:hover)and (forced-colors:active){:host(:not(:active,:disabled):hover) .sbb-calendar-day: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-day__value{height:var(--sbb-calendar-day-value-height)}:host(:is(:state(current),[state--current])) .sbb-calendar-day__value{font-weight:700}:host(:is(:state(crossed-out),[state--crossed-out])) .sbb-calendar-day__value: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);inset-block-start:var(--sbb-calendar-day-crossed-out-top);inset-inline-start:50%;transform:var(--sbb-calendar-day-crossed-out-translate)}.sbb-calendar-day__extra{display:var(--sbb-calendar-day-extra-display);height:var(--sbb-calendar-day-extra-height);padding:var(--sbb-calendar-cell-padding)}::slotted(*){height:1rem}`;
11
+ let T = (() => {
12
+ var s;
13
+ let v = [g("sbb-calendar-day")], o, n = [], r, b = k(_), l = [], c, u;
14
+ return s = class extends b {
15
+ set slot(e) {
16
+ super.slot = e, this.value = this.dateAdapter.deserialize(e);
17
+ }
18
+ get slot() {
19
+ return super.slot;
20
+ }
21
+ /** Value of the calendar-day element. */
22
+ set value(e) {
23
+ const a = this.dateAdapter.getValidDateOrNull(this.dateAdapter.deserialize(e));
24
+ if (a) {
25
+ this._value = a;
26
+ const t = this.dateAdapter.sameDate(a, this.dateAdapter.today());
27
+ this.toggleState("current", t), this.internals.ariaCurrent = t ? "date" : null, this.internals.ariaLabel = this.dateAdapter.getAccessibilityFormatDate(a);
28
+ const i = this._getParent();
29
+ i && (this._setDisabledFilteredState(i), this._setSelectedState(i));
30
+ }
31
+ }
32
+ get value() {
33
+ return this._value;
34
+ }
35
+ constructor() {
36
+ super(), this.dateAdapter = (h(this, l), x().datetime?.dateAdapter ?? D), this._value = null, this.addController(new S(this, () => this._getParent(), {
37
+ dateFilter: (e) => this._setDisabledFilteredState(e),
38
+ min: (e) => this._setDisabledFilteredState(e),
39
+ max: (e) => this._setDisabledFilteredState(e),
40
+ selected: (e) => this._setSelectedState(e)
41
+ }));
42
+ }
43
+ /**
44
+ * Intentionally empty, as buttons are not targeted by form reset.
45
+ * @internal
46
+ */
47
+ formResetCallback() {
48
+ }
49
+ /**
50
+ * Intentionally empty, as buttons are not targeted by form restore.
51
+ * @internal
52
+ */
53
+ formStateRestoreCallback(e, a) {
54
+ }
55
+ connectedCallback() {
56
+ super.connectedCallback(), this.tabIndex = -1;
57
+ }
58
+ /**
59
+ * The component is used as the default day cell within the `sbb-calendar`,
60
+ * or, if extra content is needed, it can be slotted.
61
+ */
62
+ _getParent() {
63
+ return this.closest?.("sbb-calendar") ?? this.getRootNode?.()?.host?.closest("sbb-calendar");
64
+ }
65
+ _setSelectedState(e) {
66
+ const a = e.multiple ? e.selected.some((t) => this.dateAdapter.sameDate(this.value, t)) : !!e.selected && this.dateAdapter.compareDate(this.value, e.selected) === 0;
67
+ this.toggleState("selected", a), this.internals.ariaPressed = String(a);
68
+ }
69
+ _setDisabledFilteredState(e) {
70
+ const a = !this._isActiveDate(e.dateFilter), t = !this._isDayInRange(e.min, e.max);
71
+ this.disabled = a || t, this.internals.ariaDisabled = String(this.disabled), this.toggleState("crossed-out", a && !t);
72
+ }
73
+ _isActiveDate(e) {
74
+ return e?.(this.value) ?? !0;
75
+ }
76
+ _isDayInRange(e, a) {
77
+ return !e && !a ? !0 : this.dateAdapter.sameDate(this.value, this.dateAdapter.clampDate(this.value, e, a));
78
+ }
79
+ renderTemplate() {
80
+ return f` <span class="sbb-calendar-day__value" aria-hidden="true">
81
+ ${this.dateAdapter.getDate(this.value)}
82
+ </span>
83
+ <span class="sbb-calendar-day__extra">
84
+ <slot></slot>
85
+ </span>`;
86
+ }
87
+ }, r = s, (() => {
88
+ const e = typeof Symbol == "function" && Symbol.metadata ? Object.create(b[Symbol.metadata] ?? null) : void 0;
89
+ c = [p()], u = [m()], d(s, null, c, { kind: "setter", name: "slot", static: !1, private: !1, access: { has: (a) => "slot" in a, set: (a, t) => {
90
+ a.slot = t;
91
+ } }, metadata: e }, null, l), d(s, null, u, { kind: "setter", name: "value", static: !1, private: !1, access: { has: (a) => "value" in a, set: (a, t) => {
92
+ a.value = t;
93
+ } }, metadata: e }, null, l), d(null, o = { value: r }, v, { kind: "class", name: r.name, metadata: e }, null, n), r = o.value, e && Object.defineProperty(r, Symbol.metadata, { enumerable: !0, configurable: !0, writable: !0, value: e });
94
+ })(), s.styles = [A, w], h(r, n), r;
95
+ })();
96
+ export {
97
+ T as SbbCalendarDayElement
98
+ };
@@ -0,0 +1,4 @@
1
+ import { SbbCalendarDayElement as r } from "./calendar-day/calendar-day.component.js";
2
+ export {
3
+ r as SbbCalendarDayElement
4
+ };
@@ -0,0 +1,5 @@
1
+ import { SbbCalendarElement as b, SbbMonthChangeEvent as t } from "./calendar/calendar.component.js";
2
+ export {
3
+ b as SbbCalendarElement,
4
+ t as SbbMonthChangeEvent
5
+ };
package/calendar.js CHANGED
@@ -1,4 +1,7 @@
1
- import { SbbCalendarElement as a } from "./calendar/calendar.component.js";
1
+ import { SbbCalendarElement as a, SbbMonthChangeEvent as b } from "./calendar/calendar/calendar.component.js";
2
+ import { SbbCalendarDayElement as t } from "./calendar/calendar-day/calendar-day.component.js";
2
3
  export {
3
- a as SbbCalendarElement
4
+ t as SbbCalendarDayElement,
5
+ a as SbbCalendarElement,
6
+ b as SbbMonthChangeEvent
4
7
  };
@@ -363,6 +363,7 @@ html {
363
363
  white-space: break-spaces;
364
364
  overflow-y: auto;
365
365
  min-height: calc((var(--sbb-typo-line-height-text) * 1em));
366
+ height: 100%;
366
367
  }
367
368
 
368
369
  &[size='l'] :where(textarea) {
package/core.css CHANGED
@@ -1824,6 +1824,7 @@ html {
1824
1824
  white-space: break-spaces;
1825
1825
  overflow-y: auto;
1826
1826
  min-height: calc(var(--sbb-typo-line-height-text) * 1em);
1827
+ height: 100%;
1827
1828
  }
1828
1829
  :is(sbb-form-field, sbb-timetable-form-field)[size=l] :where(textarea) {
1829
1830
  padding-block-end: 0.34375rem;