@skf-design-system/ui-components 1.0.0-beta.3 → 1.0.0-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -6
- package/dist/components/alert/alert.component.js +20 -18
- package/dist/components/alert/alert.styles.js +50 -47
- package/dist/components/button/button.component.d.ts +2 -0
- package/dist/components/button/button.component.js +5 -5
- package/dist/components/checkbox/checkbox.styles.js +6 -1
- package/dist/components/icon/icon.styles.js +56 -54
- package/dist/components/input/input.component.d.ts +9 -0
- package/dist/components/input/input.component.js +32 -24
- package/dist/components/radio/radio.styles.js +7 -2
- package/dist/components/select/select.component.d.ts +5 -2
- package/dist/components/select/select.component.js +99 -86
- package/dist/components/select/select.controllers.js +5 -2
- package/dist/components/select/select.styles.js +15 -0
- package/dist/components/select-option/select-option.component.d.ts +2 -2
- package/dist/components/select-option/select-option.component.js +16 -10
- package/dist/components/switch/switch.styles.js +5 -0
- package/dist/components/toast/toast.component.d.ts +35 -0
- package/dist/components/toast/toast.component.js +52 -0
- package/dist/components/toast/toast.d.ts +8 -0
- package/dist/components/toast/toast.js +6 -0
- package/dist/components/toast/toast.singleton.d.ts +26 -0
- package/dist/components/toast/toast.singleton.js +53 -0
- package/dist/components/toast/toast.style.d.ts +1 -0
- package/dist/components/toast/toast.style.js +9 -0
- package/dist/components/toast-item/toast-item.component.d.ts +21 -0
- package/dist/components/toast-item/toast-item.component.js +65 -0
- package/dist/components/toast-item/toast-item.d.ts +6 -0
- package/dist/components/toast-item/toast-item.js +2 -0
- package/dist/components/toast-item/toast-item.style.d.ts +2 -0
- package/dist/components/toast-item/toast-item.style.js +16 -0
- package/dist/components/toast-wrapper/toast-wrapper.component.d.ts +24 -0
- package/dist/components/toast-wrapper/toast-wrapper.component.js +37 -0
- package/dist/components/toast-wrapper/toast-wrapper.d.ts +8 -0
- package/dist/components/toast-wrapper/toast-wrapper.js +6 -0
- package/dist/components/toast-wrapper/toast-wrapper.style.d.ts +1 -0
- package/dist/components/toast-wrapper/toast-wrapper.style.js +20 -0
- package/dist/custom-elements.json +450 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.js +43 -40
- package/dist/internal/components/hint/hint.component.js +12 -10
- package/dist/internal/components/hint/hint.styles.js +26 -10
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/react/skf-toast/index.d.ts +3 -0
- package/dist/react/skf-toast/index.js +13 -0
- package/dist/react/skf-toast-wrapper/index.d.ts +3 -0
- package/dist/react/skf-toast-wrapper/index.js +13 -0
- package/dist/styles/form-field.styles.js +4 -0
- package/dist/types/jsx/custom-element-jsx.d.ts +41 -3
- package/dist/types/vue/index.d.ts +42 -2
- package/dist/vscode.html-custom-data.json +40 -1
- package/dist/web-types.json +90 -4
- package/package.json +3 -3
@@ -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,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.style.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,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
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { SkfElement as h } from "../../internal/components/skf-element.js";
|
2
|
+
import d from "../../styles/component.styles.js";
|
3
|
+
import { html as m } from "lit";
|
4
|
+
import { property as p, queryAssignedElements as a } from "lit/decorators.js";
|
5
|
+
import { styles as u } from "./toast-wrapper.style.js";
|
6
|
+
var y = Object.defineProperty, r = (l, i, n, g) => {
|
7
|
+
for (var t = void 0, o = l.length - 1, f; o >= 0; o--)
|
8
|
+
(f = l[o]) && (t = f(i, n, t) || t);
|
9
|
+
return t && y(i, n, t), t;
|
10
|
+
};
|
11
|
+
const s = class s extends h {
|
12
|
+
constructor() {
|
13
|
+
super(...arguments), this.debug = !1, this._handleSlotChange = () => {
|
14
|
+
this._slottedChildren.length === 0 && this.remove();
|
15
|
+
};
|
16
|
+
}
|
17
|
+
firstUpdated() {
|
18
|
+
this._handleSlotChange(), this.topOffset && this.style.setProperty("--skf-toast-offset-top", `${this.topOffset.toString()}px`);
|
19
|
+
}
|
20
|
+
render() {
|
21
|
+
return m`<slot @slotchange=${this._handleSlotChange}></slot>`;
|
22
|
+
}
|
23
|
+
};
|
24
|
+
s.styles = [d, u];
|
25
|
+
let e = s;
|
26
|
+
r([
|
27
|
+
p({ type: Boolean, reflect: !0 })
|
28
|
+
], e.prototype, "debug");
|
29
|
+
r([
|
30
|
+
a()
|
31
|
+
], e.prototype, "_slottedChildren");
|
32
|
+
r([
|
33
|
+
p({ type: Number, reflect: !0 })
|
34
|
+
], e.prototype, "topOffset");
|
35
|
+
export {
|
36
|
+
e as SkfToastWrapper
|
37
|
+
};
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { css as s } from "lit";
|
2
|
+
const t = s`
|
3
|
+
:host {
|
4
|
+
all: unset;
|
5
|
+
display: flex;
|
6
|
+
flex-direction: column;
|
7
|
+
gap: calc(0.5rem - 3px);
|
8
|
+
inline-size: min(calc(100% - var(--skf-spacing-200)), 520px);
|
9
|
+
inset: var(--skf-toast-offset-top, var(--skf-spacing-100)) 0 auto;
|
10
|
+
margin-inline: auto;
|
11
|
+
position: fixed;
|
12
|
+
}
|
13
|
+
|
14
|
+
::slotted(.toast-item-wrapper) {
|
15
|
+
display: grid;
|
16
|
+
}
|
17
|
+
`;
|
18
|
+
export {
|
19
|
+
t as styles
|
20
|
+
};
|