@skf-design-system/ui-components 1.0.0-alpha.27 → 1.0.0-alpha.28

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 (91) hide show
  1. package/README.md +26 -6
  2. package/custom-elements.json +18265 -0
  3. package/dist/components/alert/alert.component.js +20 -18
  4. package/dist/components/alert/alert.styles.js +50 -47
  5. package/dist/components/button/button.component.d.ts +24 -0
  6. package/dist/components/button/button.component.js +79 -55
  7. package/dist/components/button/button.styles.js +1 -0
  8. package/dist/components/checkbox/checkbox.component.d.ts +3 -8
  9. package/dist/components/checkbox/checkbox.component.js +95 -90
  10. package/dist/components/checkbox/checkbox.styles.js +2 -2
  11. package/dist/components/input/input.component.d.ts +10 -0
  12. package/dist/components/input/input.component.js +89 -82
  13. package/dist/components/progress/progress.component.d.ts +22 -0
  14. package/dist/components/progress/progress.component.js +40 -0
  15. package/dist/components/progress/progress.d.ts +8 -0
  16. package/dist/components/progress/progress.js +6 -0
  17. package/dist/components/progress/progress.styles.d.ts +1 -0
  18. package/dist/components/progress/progress.styles.js +47 -0
  19. package/dist/components/radio/radio.component.d.ts +4 -6
  20. package/dist/components/radio/radio.component.js +93 -77
  21. package/dist/components/select/select.component.d.ts +5 -2
  22. package/dist/components/select/select.component.js +103 -88
  23. package/dist/components/select/select.controllers.js +5 -2
  24. package/dist/components/switch/switch.component.js +4 -1
  25. package/dist/components/tab/tab.component.d.ts +29 -0
  26. package/dist/components/tab/tab.component.js +57 -0
  27. package/dist/components/tab/tab.d.ts +8 -0
  28. package/dist/components/tab/tab.js +6 -0
  29. package/dist/components/tab/tab.styles.d.ts +1 -0
  30. package/dist/components/tab/tab.styles.js +123 -0
  31. package/dist/components/tab-group/tab-group.component.d.ts +43 -0
  32. package/dist/components/tab-group/tab-group.component.js +98 -0
  33. package/dist/components/tab-group/tab-group.d.ts +8 -0
  34. package/dist/components/tab-group/tab-group.js +6 -0
  35. package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
  36. package/dist/components/tab-group/tab-group.styles.js +75 -0
  37. package/dist/components/tab-panel/tab-panel.component.d.ts +19 -0
  38. package/dist/components/tab-panel/tab-panel.component.js +36 -0
  39. package/dist/components/tab-panel/tab-panel.d.ts +8 -0
  40. package/dist/components/tab-panel/tab-panel.js +6 -0
  41. package/dist/components/tab-panel/tab-panel.styles.d.ts +1 -0
  42. package/dist/components/tab-panel/tab-panel.styles.js +13 -0
  43. package/dist/components/textarea/textarea.component.js +5 -5
  44. package/dist/components/toast/toast.component.d.ts +35 -0
  45. package/dist/components/toast/toast.component.js +52 -0
  46. package/dist/components/toast/toast.d.ts +8 -0
  47. package/dist/components/toast/toast.js +6 -0
  48. package/dist/components/toast/toast.singleton.d.ts +26 -0
  49. package/dist/components/toast/toast.singleton.js +53 -0
  50. package/dist/components/toast/toast.styles.d.ts +1 -0
  51. package/dist/components/toast/toast.styles.js +9 -0
  52. package/dist/components/toast-item/toast-item.component.d.ts +21 -0
  53. package/dist/components/toast-item/toast-item.component.js +65 -0
  54. package/dist/components/toast-item/toast-item.d.ts +6 -0
  55. package/dist/components/toast-item/toast-item.js +2 -0
  56. package/dist/components/toast-item/toast-item.styles.d.ts +2 -0
  57. package/dist/components/toast-item/toast-item.styles.js +16 -0
  58. package/dist/components/toast-wrapper/toast-wrapper.component.d.ts +24 -0
  59. package/dist/components/toast-wrapper/toast-wrapper.component.js +37 -0
  60. package/dist/components/toast-wrapper/toast-wrapper.d.ts +8 -0
  61. package/dist/components/toast-wrapper/toast-wrapper.js +6 -0
  62. package/dist/components/toast-wrapper/toast-wrapper.styles.d.ts +1 -0
  63. package/dist/components/toast-wrapper/toast-wrapper.styles.js +20 -0
  64. package/dist/custom-elements.json +1167 -311
  65. package/dist/index.d.ts +5 -0
  66. package/dist/index.js +57 -42
  67. package/dist/internal/components/formBase.d.ts +1 -0
  68. package/dist/internal/components/formBase.js +11 -11
  69. package/dist/internal/helpers/watch.d.ts +27 -0
  70. package/dist/internal/helpers/watch.js +28 -0
  71. package/dist/react/index.d.ts +6 -0
  72. package/dist/react/index.js +6 -0
  73. package/dist/react/skf-button/index.d.ts +7 -1
  74. package/dist/react/skf-button/index.js +5 -1
  75. package/dist/react/skf-progress/index.d.ts +3 -0
  76. package/dist/react/skf-progress/index.js +13 -0
  77. package/dist/react/skf-tab/index.d.ts +12 -0
  78. package/dist/react/skf-tab/index.js +18 -0
  79. package/dist/react/skf-tab-group/index.d.ts +3 -0
  80. package/dist/react/skf-tab-group/index.js +13 -0
  81. package/dist/react/skf-tab-panel/index.d.ts +3 -0
  82. package/dist/react/skf-tab-panel/index.js +13 -0
  83. package/dist/react/skf-toast/index.d.ts +3 -0
  84. package/dist/react/skf-toast/index.js +13 -0
  85. package/dist/react/skf-toast-wrapper/index.d.ts +3 -0
  86. package/dist/react/skf-toast-wrapper/index.js +13 -0
  87. package/dist/types/jsx/custom-element-jsx.d.ts +115 -1096
  88. package/dist/types/vue/index.d.ts +147 -8
  89. package/dist/vscode.html-custom-data.json +116 -16
  90. package/dist/web-types.json +304 -35
  91. package/package.json +27 -27
@@ -0,0 +1,98 @@
1
+ import "../card/card.js";
2
+ import { SkfElement as c } from "../../internal/components/skf-element.js";
3
+ import b from "../../styles/component.styles.js";
4
+ import { html as f } from "lit";
5
+ import { property as o, queryAssignedElements as p } from "lit/decorators.js";
6
+ import { classMap as u } from "lit/directives/class-map.js";
7
+ import { styles as y } from "./tab-group.styles.js";
8
+ var g = Object.defineProperty, i = (h, t, s, r) => {
9
+ for (var e = void 0, n = h.length - 1, d; n >= 0; n--)
10
+ (d = h[n]) && (e = d(t, s, e) || e);
11
+ return e && g(t, s, e), e;
12
+ };
13
+ const l = class l extends c {
14
+ constructor() {
15
+ super(...arguments), this.defaultSelected = 0, this.noBorder = !1, this.noPadding = !1, this.stretch = !1, this.variant = "expanded", this._handleKeyDown = (t) => {
16
+ if (["ArrowLeft", "ArrowRight"].includes(t.key)) {
17
+ const s = this._getKeyDownNextTab(t.key);
18
+ s.focus({ preventScroll: !0 }), this._selectTab(s);
19
+ }
20
+ }, this._handleTabSelected = (t) => {
21
+ const s = t.detail.tab;
22
+ this._selectTab(s);
23
+ }, this._selectTab = (t) => {
24
+ this.tabs.forEach((s) => {
25
+ const r = this.panels.find((e) => e.name === s.panel);
26
+ s.selected = s === t, r && (r.active = s === t);
27
+ });
28
+ }, this._syncTabsAndPanels = () => {
29
+ this.tabs.forEach((t, s) => {
30
+ const r = (s + 1).toString();
31
+ t.id = t.id ? t.id : `skf-tab-${r}`, t.selected = this.defaultSelected === s;
32
+ const e = this.panels.find((n) => n.name === t.panel);
33
+ e && (e.id = e.id ? e.id : `skf-tab-panel-${r}`, t.setAttribute("aria-controls", e.id), e.setAttribute("aria-labelledby", t.id), e.active = t.selected);
34
+ });
35
+ };
36
+ }
37
+ firstUpdated() {
38
+ this.addEventListener("skf-tab-select", this._handleTabSelected), this._syncTabsAndPanels();
39
+ }
40
+ updated(t) {
41
+ t.has("variant") && this.tabs.forEach((s) => {
42
+ s.variant = this.variant;
43
+ });
44
+ }
45
+ /** @internal */
46
+ _getKeyDownNextTab(t) {
47
+ const e = (this.tabs.findIndex((d) => d.selected) + (t === "ArrowRight" ? 1 : -1)) % this.tabs.length;
48
+ return this.tabs[e < 0 ? this.tabs.length - 1 : e];
49
+ }
50
+ render() {
51
+ return f`
52
+ <div
53
+ @keydown=${this._handleKeyDown}
54
+ class=${u({
55
+ "tab-group": !0,
56
+ "tab-group--compressed": this.variant === "compressed",
57
+ "tab-group--expanded": this.variant === "expanded",
58
+ "tab-group--no-border": this.noBorder,
59
+ "tab-group--no-padding": this.noPadding,
60
+ "tab-group--stretch": this.stretch
61
+ })}
62
+ >
63
+ <div class="tab-group__tabs" role="tablist">
64
+ <slot name="tabs"></slot>
65
+ </div>
66
+ <div class="tab-group__body">
67
+ <slot></slot>
68
+ </div>
69
+ </div>
70
+ `;
71
+ }
72
+ };
73
+ l.styles = [b, y];
74
+ let a = l;
75
+ i([
76
+ o({ type: Number, attribute: "default-selected" })
77
+ ], a.prototype, "defaultSelected");
78
+ i([
79
+ o({ type: Boolean, attribute: "no-border" })
80
+ ], a.prototype, "noBorder");
81
+ i([
82
+ o({ type: Boolean, attribute: "no-padding" })
83
+ ], a.prototype, "noPadding");
84
+ i([
85
+ o({ type: Boolean })
86
+ ], a.prototype, "stretch");
87
+ i([
88
+ o({ reflect: !0 })
89
+ ], a.prototype, "variant");
90
+ i([
91
+ p({ slot: "tabs" })
92
+ ], a.prototype, "tabs");
93
+ i([
94
+ p()
95
+ ], a.prototype, "panels");
96
+ export {
97
+ a as SkfTabGroup
98
+ };
@@ -0,0 +1,8 @@
1
+ import { SkfTabGroup } from './tab-group.component';
2
+ export * from './tab-group.component';
3
+ export default SkfTabGroup;
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'skf-tab-group': SkfTabGroup;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { SkfTabGroup as f } from "./tab-group.component.js";
2
+ f.define("skf-tab-group");
3
+ export {
4
+ f as SkfTabGroup,
5
+ f as default
6
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,75 @@
1
+ import { css as r } from "lit";
2
+ const a = r`
3
+ /* stylelint-disable selector-class-pattern */
4
+ @layer components {
5
+ :host {
6
+ contain: layout;
7
+ }
8
+
9
+ :host([stretch]) {
10
+ block-size: 100%;
11
+ }
12
+
13
+ /**
14
+ * Root
15
+ */
16
+ .tab-group {
17
+ background-color: var(--skf-bg-color-neutral-1);
18
+ }
19
+
20
+ .tab-group--expanded {
21
+ border: var(
22
+ --_skf-tab-group-border,
23
+ var(--skf-border-width-sm) solid var(--skf-border-color-tertiary)
24
+ );
25
+ border-end-end-radius: var(--skf-border-radius-sm);
26
+ border-end-start-radius: var(--skf-border-radius-sm);
27
+ box-shadow: var(--skf-shadow-md);
28
+
29
+ ::slotted(skf-tab) {
30
+ flex: 1;
31
+ }
32
+ }
33
+
34
+ .tab-group--no-border {
35
+ --_skf-tab-group-border: none;
36
+ }
37
+
38
+ .tab-group--stretch {
39
+ block-size: inherit;
40
+ display: flex;
41
+ flex-direction: column;
42
+ }
43
+
44
+ /**
45
+ * Tabs
46
+ */
47
+ .tab-group__tabs {
48
+ display: flex;
49
+
50
+ .tab-group--compressed & {
51
+ gap: var(--skf-spacing-100);
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Body
57
+ */
58
+ .tab-group__body {
59
+ padding-block: var(--_skf-tab-group-body-padding-block, var(--skf-spacing-100) 0);
60
+
61
+ .tab-group--stretch & {
62
+ overflow-y: auto;
63
+ }
64
+
65
+ .tab-group--expanded:not(.tab-group--no-padding) & {
66
+ --_skf-tab-group-body-padding-block: var(--skf-spacing-100);
67
+
68
+ padding-inline: var(--skf-spacing-100);
69
+ }
70
+ }
71
+ }
72
+ `;
73
+ export {
74
+ a as styles
75
+ };
@@ -0,0 +1,19 @@
1
+ import { SkfElement } from '@internal/components/skf-element';
2
+ import { type CSSResultGroup } from 'lit';
3
+ /**
4
+ * The `<skf-tab-panel>` is a component that displays a list of actions or options.
5
+ *
6
+ * @slot - The tab panel's content
7
+ *
8
+ * @tagname skf-tab-panel
9
+ */
10
+ export declare class SkfTabPanel extends SkfElement {
11
+ static styles: CSSResultGroup;
12
+ /** The tab panel's name. */
13
+ name: string;
14
+ active: boolean;
15
+ constructor();
16
+ /** @internal */
17
+ handleActiveChanged(): void;
18
+ render(): import("lit").TemplateResult<1>;
19
+ }
@@ -0,0 +1,36 @@
1
+ import { SkfElement as c } from "../../internal/components/skf-element.js";
2
+ import { watch as h } from "../../internal/helpers/watch.js";
3
+ import l from "../../styles/component.styles.js";
4
+ import { html as v } from "lit";
5
+ import { property as f, state as d } from "lit/decorators.js";
6
+ import { styles as y } from "./tab-panel.styles.js";
7
+ var u = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, a = (n, r, s, o) => {
8
+ for (var t = o > 1 ? void 0 : o ? _(r, s) : r, i = n.length - 1, p; i >= 0; i--)
9
+ (p = n[i]) && (t = (o ? p(r, s, t) : p(t)) || t);
10
+ return o && t && u(r, s, t), t;
11
+ };
12
+ const m = class m extends c {
13
+ constructor() {
14
+ super(), this.name = "", this.active = !1, this.role = "tabpanel";
15
+ }
16
+ handleActiveChanged() {
17
+ this.ariaHidden = this.active ? "false" : "true", this.tabIndex = this.active ? 0 : -1;
18
+ }
19
+ render() {
20
+ return v`<slot></slot>`;
21
+ }
22
+ };
23
+ m.styles = [l, y];
24
+ let e = m;
25
+ a([
26
+ f()
27
+ ], e.prototype, "name", 2);
28
+ a([
29
+ d()
30
+ ], e.prototype, "active", 2);
31
+ a([
32
+ h("active")
33
+ ], e.prototype, "handleActiveChanged", 1);
34
+ export {
35
+ e as SkfTabPanel
36
+ };
@@ -0,0 +1,8 @@
1
+ import { SkfTabPanel } from './tab-panel.component';
2
+ export * from './tab-panel.component';
3
+ export default SkfTabPanel;
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'skf-tab-panel': SkfTabPanel;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { SkfTabPanel as a } from "./tab-panel.component.js";
2
+ a.define("skf-tab-panel");
3
+ export {
4
+ a as SkfTabPanel,
5
+ a as default
6
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,13 @@
1
+ import { css as i } from "lit";
2
+ const s = i`
3
+ :host {
4
+ content-visibility: hidden;
5
+ }
6
+
7
+ :host([aria-hidden='false']) {
8
+ content-visibility: visible;
9
+ }
10
+ `;
11
+ export {
12
+ s as styles
13
+ };
@@ -4,7 +4,7 @@ import "../../internal/components/hint/hint.js";
4
4
  import { Asterisk as c } from "../../internal/templates/asterisk.js";
5
5
  import y from "../../styles/component.styles.js";
6
6
  import { html as p, nothing as v } from "lit";
7
- import { property as r, state as f, query as b } from "lit/decorators.js";
7
+ import { property as r, state as b, query as f } from "lit/decorators.js";
8
8
  import { ifDefined as n } from "lit/directives/if-defined.js";
9
9
  import g from "./textarea.styles.js";
10
10
  var $ = Object.defineProperty, E = Object.getOwnPropertyDescriptor, e = (h, t, s, a) => {
@@ -46,7 +46,7 @@ const u = class u extends m {
46
46
  attributeChangedCallback(t, s, a) {
47
47
  if (super.attributeChangedCallback(t, s, a), t === "value" && this._internals.setFormValue(a), t === "custom-invalid")
48
48
  if (typeof a == "string") {
49
- const o = String(a).trim();
49
+ const o = this.withFallback(a);
50
50
  this.pristine = !1, this._internals.setValidity({ customError: !0 }, o), this.invalid = !0, this.hint = o, this.checkValidity();
51
51
  } else
52
52
  this._internals.setValidity({}), this.validateInput();
@@ -69,7 +69,7 @@ const u = class u extends m {
69
69
  const o = this.hasAttribute(l) ? this.getAttribute(l) : this.$input.validationMessage;
70
70
  this._internals.setValidity(
71
71
  { [this.validationError]: !0, customError: this._internals.validity.customError },
72
- o ?? ""
72
+ this.withFallback(o)
73
73
  ), this.invalid && this.customErrorDisplay && this.checkValidity();
74
74
  }
75
75
  }
@@ -173,10 +173,10 @@ e([
173
173
  r()
174
174
  ], i.prototype, "value", 2);
175
175
  e([
176
- f()
176
+ b()
177
177
  ], i.prototype, "invalid", 2);
178
178
  e([
179
- b("textarea")
179
+ f("textarea")
180
180
  ], i.prototype, "$input", 2);
181
181
  function _(h, t) {
182
182
  return t ? "error" : h;
@@ -0,0 +1,35 @@
1
+ import { SkfElement } from '@internal/components/skf-element';
2
+ import { type CSSResultGroup } from 'lit';
3
+ /**
4
+ * SkfToast is the only component a user (developer) interacts with to create a toast notification. Once rendered it will invoke a singleton instance to manage the toast notifications.
5
+ * The singleton instance will create a new toast notification (using SkfAlert) and append it to SkfToastWrapper (or append SkfToastWrapper if it doesn't exist yet) and mount that to the DOM.
6
+ * Once a toast notification is created, it will be removed after a set amount of time (if not set as a closeable SkfToast) together with the original SkfToast.
7
+ * Once the queue in the singleton is empty, the SkfToastWrapper will be removed from the DOM.
8
+ */
9
+ /**
10
+ * A simple toast component that displays a message to the user. Use by appending a &lt;skf-toast&gt; tag to the DOM. Position in DOM is irrelevant.
11
+ *
12
+ * @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/98e432-toast) for design principles
13
+ *
14
+ * @slot - The component's placeholder content
15
+ *
16
+ * @tagname skf-toast
17
+ */
18
+ export declare class SkfToast extends SkfElement {
19
+ static styles: CSSResultGroup;
20
+ private _singleton?;
21
+ /** If provided, adds a close button to the toast and will not disapear until user actively dismisses it. */
22
+ closeable: boolean;
23
+ debug: boolean;
24
+ /** Severity of the toast. */
25
+ severity: 'info' | 'success' | 'warning' | 'error';
26
+ /** Time in seconds before the toast disappears. */
27
+ timer: number;
28
+ /** offsets where toasts emerge vertically */
29
+ topOffset?: number;
30
+ /** @internal */
31
+ _slottedText: Node[];
32
+ constructor();
33
+ firstUpdated(): void;
34
+ render(): import("lit").TemplateResult<1>;
35
+ }
@@ -0,0 +1,52 @@
1
+ import { Singleton as h } from "./toast.singleton.js";
2
+ import { SkfElement as d } from "../../internal/components/skf-element.js";
3
+ import { html as f } from "lit";
4
+ import { property as s, queryAssignedNodes as y } from "lit/decorators.js";
5
+ import { styles as a } from "./toast.styles.js";
6
+ var u = Object.defineProperty, o = (l, i, n, b) => {
7
+ for (var e = void 0, r = l.length - 1, m; r >= 0; r--)
8
+ (m = l[r]) && (e = m(i, n, e) || e);
9
+ return e && u(i, n, e), e;
10
+ };
11
+ const p = class p extends d {
12
+ constructor() {
13
+ super(), this.closeable = !1, this.debug = !1, this.severity = "info", this.timer = 5, this._singleton = void 0;
14
+ }
15
+ firstUpdated() {
16
+ this._singleton = new h(this.getRootNode()), this._singleton.addData({
17
+ text: this._slottedText.map((i) => i.textContent).join(),
18
+ timer: this.timer = this.timer && this.timer < 5 ? 5 : this.timer,
19
+ closeable: this.closeable,
20
+ originEl: this,
21
+ severity: this.severity,
22
+ topOffset: this.topOffset,
23
+ debug: this.debug
24
+ });
25
+ }
26
+ render() {
27
+ return f`<slot></slot>`;
28
+ }
29
+ };
30
+ p.styles = [a];
31
+ let t = p;
32
+ o([
33
+ s({ type: Boolean })
34
+ ], t.prototype, "closeable");
35
+ o([
36
+ s({ type: Boolean })
37
+ ], t.prototype, "debug");
38
+ o([
39
+ s()
40
+ ], t.prototype, "severity");
41
+ o([
42
+ s({ type: Number })
43
+ ], t.prototype, "timer");
44
+ o([
45
+ s({ type: Number })
46
+ ], t.prototype, "topOffset");
47
+ o([
48
+ y()
49
+ ], t.prototype, "_slottedText");
50
+ export {
51
+ t as SkfToast
52
+ };
@@ -0,0 +1,8 @@
1
+ import { SkfToast } from './toast.component';
2
+ export * from './toast.component';
3
+ export default SkfToast;
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'skf-toast': SkfToast;
7
+ }
8
+ }
@@ -0,0 +1,6 @@
1
+ import { SkfToast as t } from "./toast.component.js";
2
+ t.define("skf-toast");
3
+ export {
4
+ t as SkfToast,
5
+ t as default
6
+ };
@@ -0,0 +1,26 @@
1
+ import '@components/toast-item/toast-item.js';
2
+ import '@components/toast-wrapper/toast-wrapper.js';
3
+ import type { SkfToast } from '@components/toast/toast.component.js';
4
+ interface ToastData {
5
+ text: string;
6
+ timer: number;
7
+ closeable: boolean;
8
+ topOffset?: number;
9
+ originEl: SkfToast;
10
+ severity: 'info' | 'success' | 'warning' | 'error';
11
+ debug: boolean;
12
+ }
13
+ export declare class Singleton {
14
+ private static instance?;
15
+ data: ToastData[];
16
+ root: Document;
17
+ usePopover: boolean;
18
+ constructor(root: Document);
19
+ hasToasts(): boolean;
20
+ popToast(): ToastData | undefined;
21
+ getData(): ToastData[];
22
+ setData(data: ToastData[]): void;
23
+ addData(data: ToastData): void;
24
+ udpateUI(): void;
25
+ }
26
+ export {};
@@ -0,0 +1,53 @@
1
+ import "../toast-item/toast-item.js";
2
+ import "../toast-wrapper/toast-wrapper.js";
3
+ class a {
4
+ constructor(t) {
5
+ if (this.data = [], this.root = t, this.usePopover = !0, this.root.nodeType !== Node.DOCUMENT_NODE)
6
+ throw new Error("Root node must be a document node");
7
+ return a.instance || (a.instance = this), a.instance;
8
+ }
9
+ hasToasts() {
10
+ return this.data.length > 0;
11
+ }
12
+ popToast() {
13
+ return this.data.pop();
14
+ }
15
+ getData() {
16
+ return this.data;
17
+ }
18
+ setData(t) {
19
+ this.data = t;
20
+ }
21
+ addData(t) {
22
+ this.data = [...this.data, t], this.udpateUI();
23
+ }
24
+ udpateUI() {
25
+ const t = c(this.root, this.usePopover);
26
+ this.usePopover && t.showPopover(), u();
27
+ function u() {
28
+ const n = new a(document);
29
+ for (; n.hasToasts(); ) {
30
+ const e = n.popToast();
31
+ if (!e) return;
32
+ e.debug && (t.debug = !0);
33
+ const o = document.createElement("skf-toast-item");
34
+ o.timer = e.timer, o.severity = e.severity, o.icon = "warning", e.closeable && o.setAttribute("closeable", "true"), o.originEl = e.originEl, o.innerText = String(e.text);
35
+ const s = document.createElement("div");
36
+ s.classList.add("toast-item-wrapper"), s.appendChild(o), t.prepend(s);
37
+ }
38
+ }
39
+ function c(n, e) {
40
+ var p;
41
+ const s = ((p = new a(document).getData()[0]) == null ? void 0 : p.topOffset) ?? null, i = n.querySelector("body");
42
+ let r = i == null ? void 0 : i.querySelector("skf-toast-wrapper");
43
+ if (!r) {
44
+ if (r = document.createElement("skf-toast-wrapper"), !r) throw new Error("Could not create toast wrapper element");
45
+ e && r.setAttribute("popover", "auto"), s && r.setAttribute("top-offset", s.toString()), document.body.appendChild(r);
46
+ }
47
+ return r;
48
+ }
49
+ }
50
+ }
51
+ export {
52
+ a as Singleton
53
+ };
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,9 @@
1
+ import { css as s } from "lit";
2
+ const t = s`
3
+ :host {
4
+ display: none;
5
+ }
6
+ `;
7
+ export {
8
+ t as styles
9
+ };
@@ -0,0 +1,21 @@
1
+ import { SkfAlert } from '@components/alert/alert.component.js';
2
+ export declare class SkfToastItem extends SkfAlert {
3
+ static styles: import("lit").CSSResultGroup[];
4
+ protected _closeableInitialState: boolean;
5
+ protected _parentAnimationDiv: HTMLDivElement | null;
6
+ /** If not cloaseable, timeout id for the toast */
7
+ private _currentTimeoutId;
8
+ /** If not closseable, time left on the timer when the mouse enters the toast */
9
+ private _timeleft;
10
+ /** If not closseable, time when the timeout started */
11
+ private _timeoutStarted;
12
+ originEl: HTMLElement | null;
13
+ timer: number;
14
+ constructor();
15
+ firstUpdated(): void;
16
+ _animateIn(): void;
17
+ _handleMouseEnter: () => void;
18
+ _handleMouseLeave: () => void;
19
+ _removeToast: () => void;
20
+ get parentAnimationDiv(): HTMLDivElement;
21
+ }
@@ -0,0 +1,65 @@
1
+ import { SkfAlert as l } from "../alert/alert.component.js";
2
+ import { MOTION_DURATIONS as h } from "@skf-design-system/ui-assets";
3
+ import { property as u } from "lit/decorators.js";
4
+ import p from "./toast-item.styles.js";
5
+ var d = Object.defineProperty, f = (a, t, e, m) => {
6
+ for (var i = void 0, r = a.length - 1, o; r >= 0; r--)
7
+ (o = a[r]) && (i = o(t, e, i) || i);
8
+ return i && d(t, e, i), i;
9
+ };
10
+ const n = class n extends l {
11
+ constructor() {
12
+ super(), this.timer = 0, this._handleMouseEnter = () => {
13
+ this._closeableInitialState || (this.closeable = !0, this._timeleft = this.timer * 1e3 - (Date.now() - this._timeoutStarted), this._currentTimeoutId && clearTimeout(this._currentTimeoutId));
14
+ }, this._handleMouseLeave = () => {
15
+ this._closeableInitialState || (this.closeable = this._closeableInitialState, this._currentTimeoutId = setTimeout(this._removeToast, this._timeleft));
16
+ }, this._removeToast = () => {
17
+ const e = this.parentAnimationDiv.animate(
18
+ [
19
+ { gridTemplateRows: "1fr", opacity: 1 },
20
+ { gridTemplateRows: "0fr", opacity: 0 }
21
+ ],
22
+ {
23
+ duration: h.normal,
24
+ fill: "forwards"
25
+ }
26
+ );
27
+ e.onfinish = () => {
28
+ this.originEl && this.originEl.remove(), this.parentAnimationDiv.remove();
29
+ };
30
+ }, this.originEl = null, this._parentAnimationDiv = this.parentElement, this._currentTimeoutId = null, this._timeleft = 0, this._timeoutStarted = 0, this._closeableInitialState = !!this.closeable;
31
+ }
32
+ firstUpdated() {
33
+ this.addEventListener("skf-alert-close", this._removeToast), this.closeable || (this.addEventListener("mouseenter", this._handleMouseEnter), this.addEventListener("mouseout", this._handleMouseLeave)), this._animateIn();
34
+ }
35
+ _animateIn() {
36
+ const t = this.parentAnimationDiv;
37
+ "vibrate" in navigator && navigator.vibrate(500);
38
+ const e = t.animate(
39
+ [
40
+ { gridTemplateRows: "0fr", opacity: 0 },
41
+ { gridTemplateRows: "1fr", opacity: 1 }
42
+ ],
43
+ {
44
+ duration: h.slow,
45
+ fill: "forwards"
46
+ }
47
+ );
48
+ e.onfinish = () => {
49
+ this.timer > 0 && !this.closeable && (this._timeoutStarted = Date.now(), this._currentTimeoutId = setTimeout(this._removeToast, this.timer * 1e3));
50
+ };
51
+ }
52
+ get parentAnimationDiv() {
53
+ const t = this.parentElement;
54
+ if (!t) throw new Error("Parent animation div not found");
55
+ return t;
56
+ }
57
+ };
58
+ n.styles = [l.styles, p];
59
+ let s = n;
60
+ f([
61
+ u({ type: Number, reflect: !0 })
62
+ ], s.prototype, "timer");
63
+ export {
64
+ s as SkfToastItem
65
+ };
@@ -0,0 +1,6 @@
1
+ import { SkfToastItem } from './toast-item.component.js';
2
+ declare global {
3
+ interface HTMLElementTagNameMap {
4
+ 'skf-toast-item': SkfToastItem;
5
+ }
6
+ }
@@ -0,0 +1,2 @@
1
+ import { SkfToastItem as t } from "./toast-item.component.js";
2
+ t.define("skf-toast-item");
@@ -0,0 +1,2 @@
1
+ declare const _default: import("lit").CSSResult;
2
+ export default _default;
@@ -0,0 +1,16 @@
1
+ import { css as r } from "lit";
2
+ const s = r`
3
+ :host {
4
+ overflow: hidden;
5
+ padding-block-end: 3px;
6
+ }
7
+
8
+ #root {
9
+ background-color: var(--skf-bg-color-neutral-1);
10
+ border-inline-start: var(--skf-size-8) solid
11
+ var(--_skf-alert-border-color, var(--skf-border-color-primary));
12
+ }
13
+ `;
14
+ export {
15
+ s as default
16
+ };
@@ -0,0 +1,24 @@
1
+ import type { SkfAlert } from '@components/alert/alert.component.js';
2
+ import { SkfElement } from '@internal/components/skf-element';
3
+ import { type CSSResultGroup } from 'lit';
4
+ /**
5
+ * The `<skf-toast-wrapper>` is a component without UI that positions where the toast shows up on the screen. The toast-wrapper is used internally by the toast component.
6
+ *
7
+ * @documentation See [InVision DSM](https://skf.invisionapp.com/dsm/ab-skf/4-web-applications/nav/5fa7caf78c01200018354495/asset/6229d63d9fe16020a60657e5) for design principles
8
+ *
9
+ * @slot - The alert components that the toast creates will render here.
10
+ *
11
+ * @tagname skf-toast-wrapper
12
+ */
13
+ export declare class SkfToastWrapper extends SkfElement {
14
+ static styles: CSSResultGroup;
15
+ debug: boolean;
16
+ /** @internal */
17
+ _slottedChildren: SkfAlert[];
18
+ /** @internal */
19
+ topOffset?: number;
20
+ firstUpdated(): void;
21
+ /** @internal */
22
+ _handleSlotChange: () => void;
23
+ render(): import("lit").TemplateResult<1>;
24
+ }