@skf-design-system/ui-components 0.0.1-beta.4 → 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.
- package/README.md +26 -6
- package/custom-elements.json +18265 -0
- package/dist/components/accordion/accordion.component.d.ts +9 -5
- package/dist/components/accordion/accordion.component.js +22 -19
- package/dist/components/accordion/accordion.d.ts +1 -1
- package/dist/components/accordion/accordion.styles.js +3 -3
- package/dist/components/alert/alert.component.d.ts +7 -4
- package/dist/components/alert/alert.component.js +21 -19
- package/dist/components/alert/alert.styles.js +50 -47
- package/dist/components/button/button.component.d.ts +24 -0
- package/dist/components/button/button.component.js +80 -56
- package/dist/components/button/button.styles.js +2 -1
- package/dist/components/card/card.component.d.ts +3 -3
- package/dist/components/card/card.component.js +16 -19
- package/dist/components/card/card.styles.js +11 -3
- package/dist/components/checkbox/checkbox.component.d.ts +17 -15
- package/dist/components/checkbox/checkbox.component.js +95 -89
- package/dist/components/checkbox/checkbox.styles.js +7 -2
- package/dist/components/checkbox/checkbox.test.d.ts +1 -0
- package/dist/components/collapse/collapse.component.d.ts +9 -6
- package/dist/components/collapse/collapse.component.js +39 -36
- package/dist/components/collapse/collapse.styles.js +3 -3
- package/dist/components/collapse/collapse.test.d.ts +1 -0
- package/dist/components/divider/divider.component.d.ts +13 -10
- package/dist/components/divider/divider.component.js +34 -29
- package/dist/components/divider/divider.styles.js +1 -5
- package/dist/components/heading/heading.component.d.ts +12 -2
- package/dist/components/heading/heading.component.js +14 -14
- package/dist/components/heading/heading.styles.js +1 -1
- package/dist/components/icon/icon.component.d.ts +14 -8
- package/dist/components/icon/icon.component.js +6 -6
- package/dist/components/icon/icon.styles.js +56 -54
- package/dist/components/input/input.component.d.ts +44 -29
- package/dist/components/input/input.component.js +118 -111
- package/dist/components/link/link.component.d.ts +15 -12
- package/dist/components/link/link.component.js +7 -7
- package/dist/components/link/link.styles.js +1 -1
- package/dist/components/loader/loader.component.d.ts +7 -7
- package/dist/components/loader/loader.component.js +35 -61
- package/dist/components/loader/loader.styles.js +42 -10
- package/dist/components/logo/logo.component.d.ts +5 -3
- package/dist/components/logo/logo.component.js +8 -8
- package/dist/components/logo/logo.styles.js +2 -2
- package/dist/components/progress/progress.component.d.ts +22 -0
- package/dist/components/progress/progress.component.js +40 -0
- package/dist/components/progress/progress.d.ts +8 -0
- package/dist/components/progress/progress.js +6 -0
- package/dist/components/progress/progress.styles.d.ts +1 -0
- package/dist/components/progress/progress.styles.js +47 -0
- package/dist/components/radio/radio.component.d.ts +18 -18
- package/dist/components/radio/radio.component.js +94 -78
- package/dist/components/radio/radio.styles.js +6 -1
- package/dist/components/select/select.component.d.ts +140 -0
- package/dist/components/select/select.component.js +327 -0
- package/dist/components/select/select.controllers.d.ts +59 -0
- package/dist/components/select/select.controllers.js +172 -0
- package/dist/components/select/select.d.ts +8 -0
- package/dist/components/select/select.js +6 -0
- package/dist/components/select/select.styles.d.ts +1 -0
- package/dist/components/select/select.styles.js +131 -0
- package/dist/components/select-option/select-option.component.d.ts +77 -0
- package/dist/components/select-option/select-option.component.js +123 -0
- package/dist/components/select-option/select-option.controllers.d.ts +9 -0
- package/dist/components/select-option/select-option.d.ts +8 -0
- package/dist/components/select-option/select-option.js +6 -0
- package/dist/components/select-option/select-option.styles.d.ts +1 -0
- package/dist/components/select-option/select-option.styles.js +53 -0
- package/dist/components/select-option-group/select-option-group.component.d.ts +16 -0
- package/dist/components/select-option-group/select-option-group.component.js +31 -0
- package/dist/components/select-option-group/select-option-group.d.ts +8 -0
- package/dist/components/select-option-group/select-option-group.js +6 -0
- package/dist/components/select-option-group/select-option-group.style.d.ts +1 -0
- package/dist/components/select-option-group/select-option-group.style.js +18 -0
- package/dist/components/switch/switch.component.d.ts +2 -3
- package/dist/components/switch/switch.component.js +5 -2
- package/dist/components/switch/switch.styles.js +6 -1
- package/dist/components/switch/switch.test.d.ts +1 -0
- package/dist/components/tab/tab.component.d.ts +29 -0
- package/dist/components/tab/tab.component.js +57 -0
- package/dist/components/tab/tab.d.ts +8 -0
- package/dist/components/tab/tab.js +6 -0
- package/dist/components/tab/tab.styles.d.ts +1 -0
- package/dist/components/tab/tab.styles.js +123 -0
- package/dist/components/tab-group/tab-group.component.d.ts +43 -0
- package/dist/components/tab-group/tab-group.component.js +98 -0
- package/dist/components/tab-group/tab-group.d.ts +8 -0
- package/dist/components/tab-group/tab-group.js +6 -0
- package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
- package/dist/components/tab-group/tab-group.styles.js +75 -0
- package/dist/components/tab-panel/tab-panel.component.d.ts +19 -0
- package/dist/components/tab-panel/tab-panel.component.js +36 -0
- package/dist/components/tab-panel/tab-panel.d.ts +8 -0
- package/dist/components/tab-panel/tab-panel.js +6 -0
- package/dist/components/tab-panel/tab-panel.styles.d.ts +1 -0
- package/dist/components/tab-panel/tab-panel.styles.js +13 -0
- package/dist/components/tag/tag.component.d.ts +25 -4
- package/dist/components/tag/tag.component.js +66 -29
- package/dist/components/tag/tag.styles.js +6 -5
- package/dist/components/textarea/textarea.component.d.ts +26 -23
- package/dist/components/textarea/textarea.component.js +20 -17
- 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.styles.d.ts +1 -0
- package/dist/components/toast/toast.styles.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.styles.d.ts +2 -0
- package/dist/components/toast-item/toast-item.styles.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.styles.d.ts +1 -0
- package/dist/components/toast-wrapper/toast-wrapper.styles.js +20 -0
- package/dist/custom-elements.json +2146 -616
- package/dist/index.d.ts +8 -0
- package/dist/index.js +60 -36
- package/dist/internal/components/formBase.d.ts +19 -1
- package/dist/internal/components/formBase.js +29 -17
- package/dist/internal/components/hint/hint.component.js +12 -10
- package/dist/internal/components/hint/hint.styles.js +26 -10
- package/dist/internal/components/skf-element.d.ts +4 -4
- package/dist/internal/components/skf-element.js +15 -19
- package/dist/internal/helpers/array.d.ts +4 -0
- package/dist/internal/helpers/findMatchingTags.d.ts +2 -0
- package/dist/internal/helpers/findMatchingTags.js +12 -0
- package/dist/internal/helpers/hintSeverity.d.ts +2 -0
- package/dist/internal/helpers/hintSeverity.js +6 -0
- package/dist/internal/helpers/raiseError.d.ts +28 -0
- package/dist/internal/helpers/raiseError.js +29 -0
- package/dist/internal/helpers/watch.d.ts +27 -0
- package/dist/internal/helpers/watch.js +28 -0
- package/dist/internal/storybook/shadowRootTraverser.d.ts +16 -6
- package/dist/react/index.d.ts +9 -0
- package/dist/react/index.js +9 -0
- package/dist/react/skf-button/index.d.ts +7 -1
- package/dist/react/skf-button/index.js +5 -1
- package/dist/react/skf-progress/index.d.ts +3 -0
- package/dist/react/skf-progress/index.js +13 -0
- package/dist/react/skf-select/index.d.ts +21 -0
- package/dist/react/skf-select/index.js +21 -0
- package/dist/react/skf-select-option/index.d.ts +9 -0
- package/dist/react/skf-select-option/index.js +17 -0
- package/dist/react/skf-select-option-group/index.d.ts +3 -0
- package/dist/react/skf-select-option-group/index.js +13 -0
- package/dist/react/skf-tab/index.d.ts +12 -0
- package/dist/react/skf-tab/index.js +18 -0
- package/dist/react/skf-tab-group/index.d.ts +3 -0
- package/dist/react/skf-tab-group/index.js +13 -0
- package/dist/react/skf-tab-panel/index.d.ts +3 -0
- package/dist/react/skf-tab-panel/index.js +13 -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 +11 -7
- package/dist/types/jsx/custom-element-jsx.d.ts +166 -995
- package/dist/types/vue/index.d.ts +368 -94
- package/dist/vscode.html-custom-data.json +408 -106
- package/dist/web-types.json +932 -281
- package/package.json +39 -35
@@ -13,15 +13,36 @@ import { type CSSResultGroup } from 'lit';
|
|
13
13
|
*/
|
14
14
|
export declare class SkfTag extends SkfElement {
|
15
15
|
static styles: CSSResultGroup;
|
16
|
-
|
16
|
+
private _onClick?;
|
17
|
+
protected _onRemove?: (event: Event) => void;
|
18
|
+
/** Specifies Tag size */
|
17
19
|
size: 'sm' | 'md' | 'lg';
|
18
|
-
/**
|
20
|
+
/**
|
21
|
+
* If defined, displays leading/provided icon
|
22
|
+
* @type { "arrowDown" | "arrowDownUp" | "arrowLeft" | "arrowRight" | "arrowUp" | "article" | "artificialIntelligence" | "asset" | "attachment" | "bandCursor" | "bands" | "batteryEmpty" | "batteryFull" | "batteryLow" | "bearingFault" | "book" | "bulb" | "burger" | "cPM" | "calendar" | "calendarBooked" | "calendarEmpty" | "calendarNotBooked" | "calendarRecurring" | "caretDown" | "caretUp" | "caretUpDown" | "chat" | "check" | "checkCircle" | "checkSmall" | "chevronDown" | "chevronLeft" | "chevronRight" | "chevronUp" | "chevronUpDown" | "close" | "closeAllFaults" | "closeFault" | "closeSmall" | "columnGraph" | "comment" | "connection1" | "connection2" | "connection3" | "connection4" | "danger" | "defectFrequencies" | "defectFrequenciesAlternative" | "doubleChevronLeft" | "doubleChevronRight" | "download" | "draft" | "draftFilled" | "draftOutlined" | "dragNDrop" | "drop" | "duplicate" | "edit" | "emailFilled" | "emailOutlined" | "exclamation" | "eye" | "eyeHidden" | "eyeVisible" | "filter" | "forbidden" | "fullScreen" | "fullScreenExit" | "functionalLocation" | "harmonicCursor" | "heatmap" | "hierarchy" | "history" | "historyAlt" | "hourglassFramedFilled" | "hourglassFramedOutlined" | "hourglassOutlined" | "hz" | "iMX" | "image" | "infoCircleFilled" | "infoCircleOutlined" | "integration" | "kebab" | "link" | "listGroup" | "listItem" | "locationPin" | "lock" | "logOut" | "meatballs" | "microphone" | "minus" | "minusSmall" | "noData" | "o" | "openInNew" | "overlayBaseline" | "pDF" | "paper" | "pause" | "pieChart" | "pin" | "play" | "plus" | "powerOff" | "printer" | "proCollect" | "recAction" | "received" | "refresh" | "reorder" | "replace" | "reply" | "rewalkableRoute" | "routes" | "search" | "send" | "sensorA" | "sensorB" | "settings" | "sidebandCursor" | "singleCursor" | "spectrum" | "starFilled" | "starOutlined" | "statusCircle" | "stop" | "structuralVibration" | "sync" | "timewave" | "trash" | "trend" | "trendingUp" | "undo" | "unknownCircle" | "unknownDiamond" | "unlink" | "unlock" | "unscheduledAction" | "upload" | "user" | "viewFull" | "viewHorizontal" | "viewVertical" | "warning" | "warningCircle" | "warningDiamond" | "zoomIn" | "zoomOut" }
|
23
|
+
*/
|
19
24
|
icon?: Icon;
|
20
|
-
/**
|
25
|
+
/**
|
26
|
+
* If defined, gives the supplied appearance
|
27
|
+
* @type { "warning" | "success" | "info" | "error" | "alert" }
|
28
|
+
*/
|
21
29
|
color?: SeverityBgColor;
|
30
|
+
/** If defined, accepts a function that runs on click */
|
31
|
+
set onClick(onClickFn: ((event: Event) => void) | undefined);
|
32
|
+
get onClick(): ((event: Event) => void) | undefined;
|
33
|
+
/** If defined, accepts a function that runs on click. Self removal can be overridden by using `event.stopPropagation()`. */
|
34
|
+
set onRemove(onRemoveFn: ((event: Event) => void) | undefined);
|
35
|
+
get onRemove(): ((event: Event) => void) | undefined;
|
22
36
|
/** If true, adds trailing button to remove tag */
|
23
37
|
removable?: boolean;
|
24
38
|
/** @internal */
|
25
|
-
|
39
|
+
$removeButton: HTMLButtonElement;
|
40
|
+
connectedCallback(): void;
|
41
|
+
disconnectedCallback(): void;
|
42
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
43
|
+
protected _handleKeyDown: (e: KeyboardEvent) => void;
|
44
|
+
/** run externally provided callback (if any) first. Let click propagate to handleClick. */
|
45
|
+
protected _handleRemove: (e: Event) => void;
|
46
|
+
protected _handleClick: (e: Event) => void;
|
26
47
|
render(): import("lit").TemplateResult<1>;
|
27
48
|
}
|
@@ -1,51 +1,88 @@
|
|
1
1
|
import "../icon/icon.js";
|
2
|
-
import { SkfElement as
|
3
|
-
import
|
4
|
-
import { html as
|
5
|
-
import { property as
|
2
|
+
import { SkfElement as u } from "../../internal/components/skf-element.js";
|
3
|
+
import d from "../../styles/component.styles.js";
|
4
|
+
import { html as a, nothing as m } from "lit";
|
5
|
+
import { property as s, query as f } from "lit/decorators.js";
|
6
6
|
import { ifDefined as v } from "lit/directives/if-defined.js";
|
7
|
-
import { styles as
|
8
|
-
var
|
9
|
-
for (var t = void 0, i =
|
10
|
-
(c =
|
11
|
-
return t &&
|
7
|
+
import { styles as k } from "./tag.styles.js";
|
8
|
+
var y = Object.defineProperty, C = Object.getOwnPropertyDescriptor, r = (p, e, i, n) => {
|
9
|
+
for (var t = n > 1 ? void 0 : n ? C(e, i) : e, l = p.length - 1, c; l >= 0; l--)
|
10
|
+
(c = p[l]) && (t = (n ? c(e, i, t) : c(t)) || t);
|
11
|
+
return n && t && y(e, i, t), t;
|
12
12
|
};
|
13
|
-
const
|
13
|
+
const h = class h extends u {
|
14
14
|
constructor() {
|
15
|
-
super(...arguments), this.size = "md", this.
|
16
|
-
this.
|
15
|
+
super(...arguments), this.size = "md", this._handleKeyDown = (e) => {
|
16
|
+
(e.key === "Enter" || e.key === " ") && this.$removeButton.click();
|
17
|
+
}, this._handleRemove = (e) => {
|
18
|
+
this._onRemove && this._onRemove(e);
|
19
|
+
}, this._handleClick = (e) => {
|
20
|
+
var t;
|
21
|
+
e.stopPropagation();
|
22
|
+
const i = e.composedPath()[0];
|
23
|
+
console.log("$clickTarget", i), i.localName === "button" ? this.remove() : (t = this.onClick) == null || t.call(this, e);
|
17
24
|
};
|
18
25
|
}
|
26
|
+
set onClick(e) {
|
27
|
+
e && (this._onClick = e);
|
28
|
+
}
|
29
|
+
get onClick() {
|
30
|
+
return this._onClick;
|
31
|
+
}
|
32
|
+
set onRemove(e) {
|
33
|
+
e && (this._onRemove = e);
|
34
|
+
}
|
35
|
+
get onRemove() {
|
36
|
+
return this._onRemove;
|
37
|
+
}
|
38
|
+
connectedCallback() {
|
39
|
+
super.connectedCallback(), this.addEventListener("click", this._handleClick);
|
40
|
+
}
|
41
|
+
disconnectedCallback() {
|
42
|
+
super.disconnectedCallback(), this.removeEventListener("click", this._handleClick);
|
43
|
+
}
|
44
|
+
attributeChangedCallback(e, i, n) {
|
45
|
+
super.attributeChangedCallback(e, i, n), e === "removable" && n !== null ? this.addEventListener("keydown", this._handleKeyDown) : this.removeEventListener("keydown", this._handleKeyDown);
|
46
|
+
}
|
19
47
|
render() {
|
20
|
-
return
|
21
|
-
<div id="
|
22
|
-
${this.icon ?
|
48
|
+
return a`
|
49
|
+
<div id="root">
|
50
|
+
${this.icon ? a`<skf-icon color=${v(this.color)} name=${this.icon} size="sm"></skf-icon>` : m}
|
23
51
|
<span>
|
24
52
|
<slot></slot>
|
25
53
|
</span>
|
26
|
-
${this.removable ?
|
27
|
-
<button @click=${this.
|
28
|
-
<skf-icon name="close" size="
|
54
|
+
${this.removable ? a`
|
55
|
+
<button @click=${this._handleRemove} type="button">
|
56
|
+
<skf-icon name="close" size="xs"></skf-icon>
|
29
57
|
</button>
|
30
|
-
` :
|
58
|
+
` : m}
|
31
59
|
</div>
|
32
60
|
`;
|
33
61
|
}
|
34
62
|
};
|
35
|
-
|
36
|
-
let o =
|
63
|
+
h.styles = [d, k];
|
64
|
+
let o = h;
|
65
|
+
r([
|
66
|
+
s({ reflect: !0 })
|
67
|
+
], o.prototype, "size", 2);
|
68
|
+
r([
|
69
|
+
s()
|
70
|
+
], o.prototype, "icon", 2);
|
71
|
+
r([
|
72
|
+
s({ reflect: !0 })
|
73
|
+
], o.prototype, "color", 2);
|
37
74
|
r([
|
38
|
-
|
39
|
-
], o.prototype, "
|
75
|
+
s({ attribute: !1 })
|
76
|
+
], o.prototype, "onClick", 1);
|
40
77
|
r([
|
41
|
-
|
42
|
-
], o.prototype, "
|
78
|
+
s({ attribute: !1 })
|
79
|
+
], o.prototype, "onRemove", 1);
|
43
80
|
r([
|
44
|
-
|
45
|
-
], o.prototype, "
|
81
|
+
s({ type: Boolean, reflect: !0 })
|
82
|
+
], o.prototype, "removable", 2);
|
46
83
|
r([
|
47
|
-
|
48
|
-
], o.prototype, "
|
84
|
+
f("button")
|
85
|
+
], o.prototype, "$removeButton", 2);
|
49
86
|
export {
|
50
87
|
o as SkfTag
|
51
88
|
};
|
@@ -1,11 +1,7 @@
|
|
1
1
|
import { css as r } from "lit";
|
2
2
|
const s = r`
|
3
3
|
@layer components {
|
4
|
-
|
5
|
-
display: contents;
|
6
|
-
}
|
7
|
-
|
8
|
-
#tag {
|
4
|
+
#root {
|
9
5
|
align-items: center;
|
10
6
|
background-color: var(--_skf-tag-bg-color, var(--skf-bg-color-neutral-1));
|
11
7
|
block-size: var(--_skf-tag-height, var(--skf-size-32));
|
@@ -59,6 +55,11 @@ const s = r`
|
|
59
55
|
|
60
56
|
button {
|
61
57
|
display: flex;
|
58
|
+
|
59
|
+
&:focus-visible {
|
60
|
+
border-radius: var(--skf-border-radius-sm);
|
61
|
+
outline: var(--skf-border-width-md) solid var(--skf-interactive-border-color-focus);
|
62
|
+
}
|
62
63
|
}
|
63
64
|
}
|
64
65
|
`;
|
@@ -12,7 +12,7 @@ interface SkfTextAreaProps extends Omit<FormFieldBaseProps, 'type'> {
|
|
12
12
|
/**
|
13
13
|
* The skf-textarea is used to create a textarea. Use it inside a form element or wherever you like.
|
14
14
|
*
|
15
|
-
* @documentation See [
|
15
|
+
* @documentation See [zeroheight](https://zeroheight.com/853e936c9/p/143f9d-text-area) for design principles.
|
16
16
|
*
|
17
17
|
* @attribute {boolean} disabled - If true, sets disabled state
|
18
18
|
* @attribute {boolean} required - If true, value is required or must be checked for the form to be submittable
|
@@ -20,48 +20,51 @@ interface SkfTextAreaProps extends Omit<FormFieldBaseProps, 'type'> {
|
|
20
20
|
* @event change - Fires when the value of the input changes
|
21
21
|
* @event invalid - Fires when the input is invalid
|
22
22
|
*
|
23
|
-
* @slot The textareas label. Alternatively, you can use the `label` attribute.
|
23
|
+
* @slot - The textareas label. Alternatively, you can use the `label` attribute.
|
24
24
|
*
|
25
25
|
* @tagname skf-textarea
|
26
26
|
*/
|
27
27
|
export declare class SkfTextArea extends FormBase implements SkfTextAreaProps {
|
28
28
|
static styles: CSSResultGroup;
|
29
29
|
private customError;
|
30
|
-
/** If
|
31
|
-
cols?: number
|
32
|
-
/** If
|
30
|
+
/** If defined, sets the cols of the textarea */
|
31
|
+
cols?: number;
|
32
|
+
/** If defined, forces component to invalid state until removed. Its value is used as hint text. */
|
33
33
|
set customInvalid(value: string | undefined);
|
34
34
|
get customInvalid(): string | undefined;
|
35
|
-
/** If
|
36
|
-
debug
|
37
|
-
/**
|
38
|
-
hideLabel
|
39
|
-
/** If
|
35
|
+
/** If true, outputs helping hints in console */
|
36
|
+
debug?: boolean;
|
37
|
+
/** If true, hides the label visually */
|
38
|
+
hideLabel?: boolean;
|
39
|
+
/** If defined, displays informational text below the field */
|
40
40
|
hint?: string;
|
41
|
-
/**
|
42
|
-
label
|
43
|
-
/** If
|
41
|
+
/** If defined, sets the input's label unless the default slot is used. Alternatively, you can use the `label` attribute. */
|
42
|
+
label?: string;
|
43
|
+
/** If defined, adds name to the input-element */
|
44
44
|
name?: string;
|
45
|
-
/** If
|
45
|
+
/** If defined, sets the maximum character length to accept for this input */
|
46
46
|
maxLength?: number;
|
47
|
-
/** If
|
47
|
+
/** If defined, sets the minimum character length to accept for this input */
|
48
48
|
minLength?: number;
|
49
|
-
/** If
|
49
|
+
/** If defined, displays placeholder text */
|
50
50
|
placeholder?: string;
|
51
51
|
/** If true, makes the element not mutable, meaning the user can not edit the control */
|
52
52
|
readonly?: boolean;
|
53
|
-
/** If
|
53
|
+
/** If defined, renders an alternative A11y text for the asterisk */
|
54
54
|
requiredLabel?: string;
|
55
|
-
/** If
|
56
|
-
rows?: number
|
57
|
-
/**
|
55
|
+
/** If defined, sets the rows of the textarea */
|
56
|
+
rows?: number;
|
57
|
+
/**
|
58
|
+
* If defined, displays provided severity state
|
59
|
+
* @type {"success" | "info" | "warning" | "alert"}
|
60
|
+
*/
|
58
61
|
severity?: SkfTextAreaProps['severity'];
|
59
62
|
/** If true, displays valid state after interaction */
|
60
63
|
showValid?: boolean;
|
61
|
-
/**
|
64
|
+
/** Size of the Textarea */
|
62
65
|
size?: 'sm' | 'md';
|
63
|
-
/**
|
64
|
-
validateOn
|
66
|
+
/** Sets validation start */
|
67
|
+
validateOn: 'input' | 'change' | 'submit';
|
65
68
|
/** The current value of the text area */
|
66
69
|
value: string;
|
67
70
|
/** @internal */
|
@@ -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
|
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) => {
|
@@ -14,7 +14,7 @@ var $ = Object.defineProperty, E = Object.getOwnPropertyDescriptor, e = (h, t, s
|
|
14
14
|
};
|
15
15
|
const u = class u extends m {
|
16
16
|
constructor() {
|
17
|
-
super(...arguments), this.
|
17
|
+
super(...arguments), this.size = "md", this.validateOn = "change", this.value = "", this.invalid = !1, this._resetValue = (t) => {
|
18
18
|
var s;
|
19
19
|
t.stopPropagation(), this.value = ((s = this.getAttribute("value")) == null ? void 0 : s.trim()) ?? "", this._internals.setFormValue(this.value), this.$input.focus();
|
20
20
|
}, this._handleInput = () => {
|
@@ -22,7 +22,7 @@ const u = class u extends m {
|
|
22
22
|
};
|
23
23
|
}
|
24
24
|
set customInvalid(t) {
|
25
|
-
this.customError =
|
25
|
+
this.customError = t || "";
|
26
26
|
}
|
27
27
|
get customInvalid() {
|
28
28
|
return this.customError;
|
@@ -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 =
|
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
|
}
|
@@ -78,14 +78,15 @@ const u = class u extends m {
|
|
78
78
|
render() {
|
79
79
|
var t, s;
|
80
80
|
return p`
|
81
|
-
<div id="
|
81
|
+
<div id="root">
|
82
82
|
<label>
|
83
83
|
<div class=${this.hideLabel ? "visually-hidden" : ""} id="label">
|
84
|
-
|
84
|
+
<slot>${this.label}</slot> ${this.required ? c(this.requiredLabel) : null}
|
85
85
|
</div>
|
86
86
|
<div id="input">
|
87
87
|
<textarea
|
88
88
|
?disabled=${this.disabled}
|
89
|
+
?readonly=${this.readonly}
|
89
90
|
?required=${this.required}
|
90
91
|
.value=${this.value}
|
91
92
|
@input=${this._handleInput}
|
@@ -93,22 +94,24 @@ const u = class u extends m {
|
|
93
94
|
aria-errormessage=${n((s = this.hint) != null && s.trim() ? "hint" : v)}
|
94
95
|
aria-invalid=${!!this.invalid}
|
95
96
|
cols=${n(this.cols)}
|
96
|
-
name=${n(this.name)}
|
97
97
|
maxlength=${n(this.maxLength)}
|
98
98
|
minlength=${n(this.minLength)}
|
99
|
+
name=${n(this.name)}
|
99
100
|
placeholder=${n(this.placeholder)}
|
100
|
-
?readonly=${this.readonly}
|
101
101
|
rows=${n(this.rows)}
|
102
102
|
>
|
103
103
|
</textarea>
|
104
104
|
</div>
|
105
105
|
</label>
|
106
|
-
${this.hint && p
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
106
|
+
${this.hint && p`
|
107
|
+
<skf-hint
|
108
|
+
aria-live=${this.invalid ? "assertive" : "polite"}
|
109
|
+
id="hint"
|
110
|
+
severity=${n(_(this.severity, this.invalid))}
|
111
|
+
>
|
112
|
+
${this.customInvalid ? this.customInvalid : this.hint}
|
113
|
+
</skf-hint>
|
114
|
+
`}
|
112
115
|
</div>
|
113
116
|
`;
|
114
117
|
}
|
@@ -170,10 +173,10 @@ e([
|
|
170
173
|
r()
|
171
174
|
], i.prototype, "value", 2);
|
172
175
|
e([
|
173
|
-
|
176
|
+
b()
|
174
177
|
], i.prototype, "invalid", 2);
|
175
178
|
e([
|
176
|
-
|
179
|
+
f("textarea")
|
177
180
|
], i.prototype, "$input", 2);
|
178
181
|
function _(h, t) {
|
179
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 <skf-toast> 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,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,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
|
+
}
|