@solid-design-system/components 1.25.0 → 1.27.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/dist/components/es/accordion-group.js +1 -1
- package/dist/components/es/accordion.js +1 -1
- package/dist/components/es/carousel.js +1 -1
- package/dist/components/es/checkbox-group.js +1 -1
- package/dist/components/es/checkbox.js +1 -1
- package/dist/components/es/directive.js +6 -0
- package/dist/components/es/drawer.js +1 -1
- package/dist/components/es/icon.js +3 -8
- package/dist/components/es/input.js +1 -1
- package/dist/components/es/live.js +1 -1
- package/dist/components/es/notification.js +1 -0
- package/dist/components/es/radio.js +1 -1
- package/dist/components/es/solid-components2.js +1 -1
- package/dist/components/es/solid-element.js +1 -1
- package/dist/components/es/switch.js +1 -0
- package/dist/components/umd/solid-components.js +15 -15
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/icon/library.system.d.ts +3 -0
- package/dist/package/components/icon/library.system.js +7 -1
- package/dist/package/components/notification/notification.d.ts +31 -0
- package/dist/package/components/notification/notification.js +211 -0
- package/dist/package/components/switch/switch.d.ts +37 -0
- package/dist/package/components/switch/switch.js +162 -0
- package/dist/package/solid-components.d.ts +2 -0
- package/dist/package/solid-components.js +20 -16
- package/dist/package/styles/tailwind.css.js +1 -1
- package/dist/styles/solid-styles.css +1 -1
- package/dist/versioned-components/es/accordion-group.js +1 -1
- package/dist/versioned-components/es/accordion.js +1 -1
- package/dist/versioned-components/es/badge.js +1 -1
- package/dist/versioned-components/es/brandshape.js +1 -1
- package/dist/versioned-components/es/button.js +1 -1
- package/dist/versioned-components/es/carousel-item.js +1 -1
- package/dist/versioned-components/es/carousel.js +3 -3
- package/dist/versioned-components/es/checkbox-group.js +1 -1
- package/dist/versioned-components/es/checkbox.js +1 -1
- package/dist/versioned-components/es/directive.js +6 -0
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -1
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/form.js +1 -1
- package/dist/versioned-components/es/header.js +1 -1
- package/dist/versioned-components/es/icon.js +3 -8
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/input.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/live.js +1 -1
- package/dist/versioned-components/es/navigation-item.js +1 -1
- package/dist/versioned-components/es/notification.js +1 -0
- package/dist/versioned-components/es/popup.js +1 -1
- package/dist/versioned-components/es/radio-group.js +1 -1
- package/dist/versioned-components/es/radio.js +1 -1
- package/dist/versioned-components/es/solid-components2.js +1 -1
- package/dist/versioned-components/es/solid-element.js +1 -1
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/switch.js +1 -0
- package/dist/versioned-components/es/tag.js +1 -1
- package/dist/versioned-components/es/teaser.js +1 -1
- package/dist/versioned-components/es/tooltip.js +2 -2
- package/dist/versioned-components/es/video.js +1 -1
- package/dist/versioned-package/_components/button-group/button-group.d.ts +1 -1
- package/dist/versioned-package/_components/button-group/button-group.js +11 -11
- package/dist/versioned-package/components/accordion/accordion.d.ts +1 -1
- package/dist/versioned-package/components/accordion/accordion.js +2 -2
- package/dist/versioned-package/components/accordion-group/accordion-group.d.ts +1 -1
- package/dist/versioned-package/components/accordion-group/accordion-group.js +3 -3
- package/dist/versioned-package/components/badge/badge.d.ts +1 -1
- package/dist/versioned-package/components/badge/badge.js +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.d.ts +1 -1
- package/dist/versioned-package/components/brandshape/brandshape.js +1 -1
- package/dist/versioned-package/components/button/button.d.ts +1 -1
- package/dist/versioned-package/components/button/button.js +4 -4
- package/dist/versioned-package/components/carousel/carousel.d.ts +1 -1
- package/dist/versioned-package/components/carousel/carousel.js +6 -6
- package/dist/versioned-package/components/carousel-item/carousel-item.d.ts +1 -1
- package/dist/versioned-package/components/carousel-item/carousel-item.js +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.d.ts +1 -1
- package/dist/versioned-package/components/checkbox/checkbox.js +4 -4
- package/dist/versioned-package/components/checkbox-group/checkbox-group.d.ts +1 -1
- package/dist/versioned-package/components/checkbox-group/checkbox-group.js +5 -5
- package/dist/versioned-package/components/divider/divider.d.ts +1 -1
- package/dist/versioned-package/components/divider/divider.js +2 -2
- package/dist/versioned-package/components/drawer/drawer.d.ts +1 -1
- package/dist/versioned-package/components/drawer/drawer.js +2 -2
- package/dist/versioned-package/components/dropdown/dropdown.d.ts +1 -1
- package/dist/versioned-package/components/dropdown/dropdown.js +6 -6
- package/dist/versioned-package/components/header/header.d.ts +1 -1
- package/dist/versioned-package/components/header/header.js +4 -4
- package/dist/versioned-package/components/icon/icon.d.ts +1 -1
- package/dist/versioned-package/components/icon/icon.js +1 -1
- package/dist/versioned-package/components/icon/library.system.d.ts +3 -0
- package/dist/versioned-package/components/icon/library.system.js +7 -1
- package/dist/versioned-package/components/include/include.d.ts +1 -1
- package/dist/versioned-package/components/include/include.js +1 -1
- package/dist/versioned-package/components/input/input.d.ts +1 -1
- package/dist/versioned-package/components/input/input.js +4 -4
- package/dist/versioned-package/components/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- package/dist/versioned-package/components/navigation-item/navigation-item.d.ts +1 -1
- package/dist/versioned-package/components/navigation-item/navigation-item.js +3 -3
- package/dist/versioned-package/components/notification/notification.d.ts +31 -0
- package/dist/versioned-package/components/notification/notification.js +211 -0
- package/dist/versioned-package/components/popup/popup.d.ts +1 -1
- package/dist/versioned-package/components/popup/popup.js +1 -1
- package/dist/versioned-package/components/radio/radio.d.ts +1 -1
- package/dist/versioned-package/components/radio/radio.js +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.d.ts +2 -2
- package/dist/versioned-package/components/radio-group/radio-group.js +14 -14
- package/dist/versioned-package/components/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/switch/switch.d.ts +37 -0
- package/dist/versioned-package/components/switch/switch.js +162 -0
- package/dist/versioned-package/components/tag/tag.d.ts +1 -1
- package/dist/versioned-package/components/tag/tag.js +2 -2
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/components/tooltip/tooltip.d.ts +1 -1
- package/dist/versioned-package/components/tooltip/tooltip.js +5 -5
- package/dist/versioned-package/components/video/video.d.ts +1 -1
- package/dist/versioned-package/components/video/video.js +2 -2
- package/dist/versioned-package/internal/form.js +2 -2
- package/dist/versioned-package/solid-components.d.ts +2 -0
- package/dist/versioned-package/solid-components.js +20 -16
- package/dist/versioned-package/styles/form-control.styles.js +1 -1
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/versioned-styles/solid-styles.css +1 -1
- package/dist/vscode.html-custom-data.json +224 -26
- package/dist/web-types.json +373 -1
- package/package.json +3 -3
|
@@ -75,7 +75,13 @@ const icons = {
|
|
|
75
75
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
|
|
76
76
|
<path d="m57.44 29.76-37.333-24A2.667 2.667 0 0 0 16 8v48a2.668 2.668 0 0 0 2.667 2.666 2.672 2.672 0 0 0 1.45-.431l-.01.005 37.333-24a2.67 2.67 0 0 0 1.192-2.221c0-.923-.47-1.74-1.184-2.216l-.01-.006.002-.037ZM21.333 51.112V12.89l29.734 19.112-29.734 19.11Z"/>
|
|
77
77
|
</svg>
|
|
78
|
-
|
|
78
|
+
`,
|
|
79
|
+
"confirm-circle": `
|
|
80
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12 2C6.477 2 2 6.477 2 12s4.477 10 10 10 10-4.477 10-10S17.523 2 12 2Zm0 18a8 8 0 1 1 0-16 8 8 0 0 1 0 16Z"/><path d="M15.843 7.473a.999.999 0 0 0-1.367.329l-.002.004-3.667 6.223-1.757-1.753a1 1 0 0 0-1.413 1.414l-.001-.001 2.667 2.667a.997.997 0 0 0 .695.31h.128c.314-.042.578-.223.731-.479l.003-.005 4.333-7.333a1 1 0 0 0-.345-1.374l-.005-.003v.001Z"/></svg>`,
|
|
81
|
+
warning: `
|
|
82
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12.893 2.55295C12.725 2.22395 12.388 2.00195 12 2.00195C11.612 2.00195 11.275 2.22295 11.109 2.54695L2.10598 20.553C2.03998 20.683 2.00098 20.837 2.00098 21C2.00098 21.552 2.44798 21.999 2.99998 22H21C21.552 21.999 21.999 21.552 21.999 21C21.999 20.837 21.96 20.683 21.891 20.548L21.894 20.554L12.893 2.55295ZM4.61698 20L12 5.23695L19.383 20H4.61698Z"/><path d="M11 10.667V15C11 15.552 11.448 16 12 16C12.552 16 13 15.552 13 15V10.667C13 10.115 12.552 9.66695 12 9.66695C11.448 9.66695 11 10.115 11 10.667Z"/><path d="M13 18C13 18.552 12.552 19 12 19C11.448 19 11 18.552 11 18C11 17.448 11.448 17 12 17C12.552 17 13 17.448 13 18Z"/></svg>`,
|
|
83
|
+
"exclamation-circle": `
|
|
84
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M13 17C13 17.552 12.552 18 12 18C11.448 18 11 17.552 11 17C11 16.448 11.448 16 12 16C12.552 16 13 16.448 13 17Z"/><path d="M12 6C11.448 6 11 6.448 11 7V13C11 13.552 11.448 14 12 14C12.552 14 13 13.552 13 13V7C13 6.448 12.552 6 12 6Z"/><path d="M12 2C6.477 2 2 6.477 2 12C2 17.523 6.477 22 12 22C17.523 22 22 17.523 22 12C22 6.477 17.523 2 12 2ZM12 20C7.582 20 4 16.418 4 12C4 7.582 7.582 4 12 4C16.418 4 20 7.582 20 12C20 16.418 16.418 20 12 20Z"/></svg>`
|
|
79
85
|
};
|
|
80
86
|
const systemLibrary = {
|
|
81
87
|
name: "system",
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element.js';
|
|
2
|
+
export default class SdNotification extends SolidElement {
|
|
3
|
+
private autoHideTimeout;
|
|
4
|
+
private readonly localize;
|
|
5
|
+
base: HTMLElement;
|
|
6
|
+
open: boolean;
|
|
7
|
+
closable: boolean;
|
|
8
|
+
variant: 'info' | 'success' | 'error' | 'warning';
|
|
9
|
+
toastStack: 'top-right' | 'bottom-center';
|
|
10
|
+
duration: number;
|
|
11
|
+
durationIndicator: boolean;
|
|
12
|
+
private remainingDuration;
|
|
13
|
+
private startTime;
|
|
14
|
+
firstUpdated(): void;
|
|
15
|
+
private startAutoHide;
|
|
16
|
+
private onHover;
|
|
17
|
+
private onHoverEnd;
|
|
18
|
+
private handleCloseClick;
|
|
19
|
+
handleOpenChange(): Promise<void>;
|
|
20
|
+
handleDurationChange(): void;
|
|
21
|
+
show(): Promise<void>;
|
|
22
|
+
hide(): Promise<void>;
|
|
23
|
+
toast(): Promise<void>;
|
|
24
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
25
|
+
static styles: import("lit").CSSResultGroup[];
|
|
26
|
+
}
|
|
27
|
+
declare global {
|
|
28
|
+
interface HTMLElementTagNameMap {
|
|
29
|
+
'sd-notification': SdNotification;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
import { stopAnimations, animateTo } from "../../internal/animate.js";
|
|
2
|
+
import { css, html } from "lit";
|
|
3
|
+
import { customElement } from "../../internal/register-custom-element.js";
|
|
4
|
+
import { setDefaultAnimation, getAnimation } from "../../utilities/animation-registry.js";
|
|
5
|
+
import { LocalizeController } from "../../utilities/localize.js";
|
|
6
|
+
import { query, property } from "lit/decorators.js";
|
|
7
|
+
import { waitForEvent } from "../../internal/event.js";
|
|
8
|
+
import { watch } from "../../internal/watch.js";
|
|
9
|
+
import componentStyles from "../../styles/component.styles.js";
|
|
10
|
+
import cx from "classix";
|
|
11
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
12
|
+
var __defProp = Object.defineProperty;
|
|
13
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
14
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
15
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
16
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
17
|
+
if (decorator = decorators[i])
|
|
18
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
19
|
+
if (kind && result)
|
|
20
|
+
__defProp(target, key, result);
|
|
21
|
+
return result;
|
|
22
|
+
};
|
|
23
|
+
const toastStackDefault = Object.assign(document.createElement("div"), {
|
|
24
|
+
className: "sd-toast-stack sd-toast-stack--top-right"
|
|
25
|
+
});
|
|
26
|
+
const toastStackBottomCenter = Object.assign(document.createElement("div"), {
|
|
27
|
+
className: "sd-toast-stack sd-toast-stack--bottom-center"
|
|
28
|
+
});
|
|
29
|
+
let SdNotification = class extends SolidElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.localize = new LocalizeController(this);
|
|
33
|
+
this.open = false;
|
|
34
|
+
this.closable = false;
|
|
35
|
+
this.variant = "info";
|
|
36
|
+
this.toastStack = "top-right";
|
|
37
|
+
this.duration = Infinity;
|
|
38
|
+
this.durationIndicator = false;
|
|
39
|
+
this.remainingDuration = this.duration;
|
|
40
|
+
this.startTime = Date.now();
|
|
41
|
+
}
|
|
42
|
+
firstUpdated() {
|
|
43
|
+
this.base.hidden = !this.open;
|
|
44
|
+
}
|
|
45
|
+
startAutoHide() {
|
|
46
|
+
clearTimeout(this.autoHideTimeout);
|
|
47
|
+
this.startTime = Date.now();
|
|
48
|
+
this.remainingDuration = this.duration;
|
|
49
|
+
if (this.open && this.duration < Infinity) {
|
|
50
|
+
this.autoHideTimeout = window.setTimeout(() => this.hide(), this.duration);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
onHover() {
|
|
54
|
+
clearTimeout(this.autoHideTimeout);
|
|
55
|
+
if (this.duration < Infinity) {
|
|
56
|
+
this.remainingDuration -= Date.now() - this.startTime;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
onHoverEnd() {
|
|
60
|
+
this.startTime = Date.now();
|
|
61
|
+
clearTimeout(this.autoHideTimeout);
|
|
62
|
+
if (this.open && this.duration < Infinity) {
|
|
63
|
+
this.autoHideTimeout = window.setTimeout(() => {
|
|
64
|
+
this.hide();
|
|
65
|
+
}, this.remainingDuration);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
handleCloseClick() {
|
|
69
|
+
this.hide();
|
|
70
|
+
}
|
|
71
|
+
async handleOpenChange() {
|
|
72
|
+
if (this.open) {
|
|
73
|
+
this.emit("sd-show");
|
|
74
|
+
if (this.duration < Infinity) {
|
|
75
|
+
this.startAutoHide();
|
|
76
|
+
}
|
|
77
|
+
await stopAnimations(this.base);
|
|
78
|
+
this.base.hidden = false;
|
|
79
|
+
const { keyframes, options } = getAnimation(this, "notification.show", { dir: this.localize.dir() });
|
|
80
|
+
await animateTo(this.base, keyframes, options);
|
|
81
|
+
this.emit("sd-after-show");
|
|
82
|
+
} else {
|
|
83
|
+
this.emit("sd-hide");
|
|
84
|
+
clearTimeout(this.autoHideTimeout);
|
|
85
|
+
await stopAnimations(this.base);
|
|
86
|
+
const { keyframes, options } = getAnimation(this, "notification.hide", { dir: this.localize.dir() });
|
|
87
|
+
await animateTo(this.base, keyframes, options);
|
|
88
|
+
this.base.hidden = true;
|
|
89
|
+
this.emit("sd-after-hide");
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
handleDurationChange() {
|
|
93
|
+
this.startAutoHide();
|
|
94
|
+
}
|
|
95
|
+
/** Shows the notification. */
|
|
96
|
+
async show() {
|
|
97
|
+
if (this.open) {
|
|
98
|
+
return void 0;
|
|
99
|
+
}
|
|
100
|
+
this.open = true;
|
|
101
|
+
return waitForEvent(this, "sd-after-show");
|
|
102
|
+
}
|
|
103
|
+
/** Hides the notification */
|
|
104
|
+
async hide() {
|
|
105
|
+
if (!this.open) {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
this.open = false;
|
|
109
|
+
return waitForEvent(this, "sd-after-hide");
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Displays the notification as a toast notification. This will move the notification out of its position in the DOM and, when
|
|
113
|
+
* dismissed, it will be removed from the DOM completely. By storing a reference to the notification, you can reuse it by
|
|
114
|
+
* calling this method again. The returned promise will resolve after the notification is hidden.
|
|
115
|
+
*/
|
|
116
|
+
async toast() {
|
|
117
|
+
return new Promise((resolve) => {
|
|
118
|
+
const toastStack = this.toastStack === "bottom-center" ? toastStackBottomCenter : toastStackDefault;
|
|
119
|
+
if (toastStack.parentElement === null) {
|
|
120
|
+
document.body.append(toastStack);
|
|
121
|
+
}
|
|
122
|
+
toastStack.appendChild(this);
|
|
123
|
+
requestAnimationFrame(() => {
|
|
124
|
+
this.clientWidth;
|
|
125
|
+
this.show();
|
|
126
|
+
});
|
|
127
|
+
this.addEventListener(
|
|
128
|
+
"sd-after-hide",
|
|
129
|
+
() => {
|
|
130
|
+
toastStack.removeChild(this);
|
|
131
|
+
resolve();
|
|
132
|
+
if (toastStack.querySelector("sd-notification") === null) {
|
|
133
|
+
toastStack.remove();
|
|
134
|
+
}
|
|
135
|
+
},
|
|
136
|
+
{ once: true }
|
|
137
|
+
);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
render() {
|
|
141
|
+
return html`<div part="base" class="${cx("w-full overflow-hidden flex items-stretch relative m-2")}" role="alert" id="notification" aria-hidden="${this.open ? "false" : "true"}" @mouseenter="${this.onHover}" @mouseleave="${this.onHoverEnd}"><slot name="icon" part="icon" class="${cx(
|
|
142
|
+
"min-w-min flex items-center px-3 justify-center",
|
|
143
|
+
{
|
|
144
|
+
info: "bg-info",
|
|
145
|
+
success: "bg-success",
|
|
146
|
+
warning: "bg-warning",
|
|
147
|
+
error: "bg-error"
|
|
148
|
+
}[this.variant]
|
|
149
|
+
)}"><sd-icon name="${{
|
|
150
|
+
info: "info-circle",
|
|
151
|
+
success: "confirm-circle",
|
|
152
|
+
warning: "exclamation-circle",
|
|
153
|
+
error: "warning"
|
|
154
|
+
}[this.variant] || ""}" library="system" class="h-6 w-6 text-white"></sd-icon></slot><div part="content" class="${cx(
|
|
155
|
+
"h-full w-full p-1 gap-2 flex items-center justify-stretch bg-white",
|
|
156
|
+
"border-solid border-[1px] border-l-0 border-neutral-400"
|
|
157
|
+
)}"><slot part="message" class="block w-full pl-3 py-2" aria-live="polite"></slot>${this.closable ? html`<sd-button size="md" variant="tertiary" part="close-button" class="ml-auto flex flex-[0_0_auto] items-stretch" label="${this.localize.term("close")}" @click="${this.handleCloseClick}"><sd-icon name="close" library="system" color="currentColor"></sd-icon></sd-button>` : ""}</div>${this.durationIndicator ? html`<div part="duration-indicator__elapsed" id="duration-indicator__elapsed" style="${`animation-duration: ${this.duration}ms`}" class="${cx(`absolute w-0 h-[2px] bottom-0 bg-primary z-10 animate-grow`)}"></div><div part="duration-indicator__total" class="w-full h-[2px] bottom-0 absolute bg-neutral-400"></div>` : ""}</div>`;
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
SdNotification.styles = [
|
|
161
|
+
componentStyles,
|
|
162
|
+
SolidElement.styles,
|
|
163
|
+
css`:host{display:contents}#notification:hover #duration-indicator__elapsed{animation-play-state:paused!important}`
|
|
164
|
+
];
|
|
165
|
+
__decorateClass([
|
|
166
|
+
query('[part~="base"]')
|
|
167
|
+
], SdNotification.prototype, "base", 2);
|
|
168
|
+
__decorateClass([
|
|
169
|
+
property({ type: Boolean, reflect: true })
|
|
170
|
+
], SdNotification.prototype, "open", 2);
|
|
171
|
+
__decorateClass([
|
|
172
|
+
property({ type: Boolean, reflect: true })
|
|
173
|
+
], SdNotification.prototype, "closable", 2);
|
|
174
|
+
__decorateClass([
|
|
175
|
+
property({ reflect: true })
|
|
176
|
+
], SdNotification.prototype, "variant", 2);
|
|
177
|
+
__decorateClass([
|
|
178
|
+
property({ reflect: true, attribute: "toast-stack" })
|
|
179
|
+
], SdNotification.prototype, "toastStack", 2);
|
|
180
|
+
__decorateClass([
|
|
181
|
+
property({ type: Number })
|
|
182
|
+
], SdNotification.prototype, "duration", 2);
|
|
183
|
+
__decorateClass([
|
|
184
|
+
property({ type: Boolean, reflect: true, attribute: "duration-indicator" })
|
|
185
|
+
], SdNotification.prototype, "durationIndicator", 2);
|
|
186
|
+
__decorateClass([
|
|
187
|
+
watch("open", { waitUntilFirstUpdate: true })
|
|
188
|
+
], SdNotification.prototype, "handleOpenChange", 1);
|
|
189
|
+
__decorateClass([
|
|
190
|
+
watch("duration")
|
|
191
|
+
], SdNotification.prototype, "handleDurationChange", 1);
|
|
192
|
+
SdNotification = __decorateClass([
|
|
193
|
+
customElement("sd-notification")
|
|
194
|
+
], SdNotification);
|
|
195
|
+
setDefaultAnimation("notification.show", {
|
|
196
|
+
keyframes: [
|
|
197
|
+
{ opacity: 0, scale: 0.8 },
|
|
198
|
+
{ opacity: 1, scale: 1 }
|
|
199
|
+
],
|
|
200
|
+
options: { duration: 250, easing: "ease" }
|
|
201
|
+
});
|
|
202
|
+
setDefaultAnimation("notification.hide", {
|
|
203
|
+
keyframes: [
|
|
204
|
+
{ opacity: 1, scale: 1 },
|
|
205
|
+
{ opacity: 0, scale: 0.8 }
|
|
206
|
+
],
|
|
207
|
+
options: { duration: 250, easing: "ease" }
|
|
208
|
+
});
|
|
209
|
+
export {
|
|
210
|
+
SdNotification as default
|
|
211
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
import type { SolidFormControl } from '../../internal/solid-element';
|
|
3
|
+
export default class SdSwitch extends SolidElement implements SolidFormControl {
|
|
4
|
+
private readonly formControlController;
|
|
5
|
+
input: HTMLInputElement;
|
|
6
|
+
title: string;
|
|
7
|
+
name: string;
|
|
8
|
+
value: string;
|
|
9
|
+
disabled: boolean;
|
|
10
|
+
checked: boolean;
|
|
11
|
+
defaultChecked: boolean;
|
|
12
|
+
form: string;
|
|
13
|
+
required: boolean;
|
|
14
|
+
get validity(): ValidityState;
|
|
15
|
+
firstUpdated(): void;
|
|
16
|
+
private handleClick;
|
|
17
|
+
private handleBlur;
|
|
18
|
+
private handleInput;
|
|
19
|
+
private handleInvalid;
|
|
20
|
+
private handleFocus;
|
|
21
|
+
handleDisabledChange(): void;
|
|
22
|
+
handleStateChange(): void;
|
|
23
|
+
click(): void;
|
|
24
|
+
focus(options?: FocusOptions): void;
|
|
25
|
+
blur(): void;
|
|
26
|
+
checkValidity(): boolean;
|
|
27
|
+
getForm(): HTMLFormElement | null;
|
|
28
|
+
reportValidity(): boolean;
|
|
29
|
+
setCustomValidity(message: string): void;
|
|
30
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
31
|
+
static styles: import("lit").CSSResultGroup[];
|
|
32
|
+
}
|
|
33
|
+
declare global {
|
|
34
|
+
interface HTMLElementTagNameMap {
|
|
35
|
+
'sd-switch': SdSwitch;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { css, html } from "lit";
|
|
2
|
+
import { customElement } from "../../internal/register-custom-element.js";
|
|
3
|
+
import { defaultValue } from "../../internal/default-value.js";
|
|
4
|
+
import { FormControlController } from "../../internal/form.js";
|
|
5
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
6
|
+
import { live } from "lit/directives/live.js";
|
|
7
|
+
import { query, property } from "lit/decorators.js";
|
|
8
|
+
import { watch } from "../../internal/watch.js";
|
|
9
|
+
import cx from "classix";
|
|
10
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
11
|
+
var __defProp = Object.defineProperty;
|
|
12
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
13
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
14
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
15
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
16
|
+
if (decorator = decorators[i])
|
|
17
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
18
|
+
if (kind && result)
|
|
19
|
+
__defProp(target, key, result);
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
22
|
+
let SdSwitch = class extends SolidElement {
|
|
23
|
+
constructor() {
|
|
24
|
+
super(...arguments);
|
|
25
|
+
this.formControlController = new FormControlController(this, {
|
|
26
|
+
value: (control) => control.checked ? control.value || "on" : void 0,
|
|
27
|
+
defaultValue: (control) => control.defaultChecked,
|
|
28
|
+
setValue: (control, checked) => control.checked = checked
|
|
29
|
+
});
|
|
30
|
+
this.title = "";
|
|
31
|
+
this.name = "";
|
|
32
|
+
this.disabled = false;
|
|
33
|
+
this.checked = false;
|
|
34
|
+
this.defaultChecked = false;
|
|
35
|
+
this.form = "";
|
|
36
|
+
this.required = false;
|
|
37
|
+
}
|
|
38
|
+
/** Gets the validity state object */
|
|
39
|
+
get validity() {
|
|
40
|
+
return this.input.validity;
|
|
41
|
+
}
|
|
42
|
+
firstUpdated() {
|
|
43
|
+
this.formControlController.updateValidity();
|
|
44
|
+
}
|
|
45
|
+
handleClick() {
|
|
46
|
+
this.checked = !this.checked;
|
|
47
|
+
this.emit("sd-change");
|
|
48
|
+
}
|
|
49
|
+
handleBlur() {
|
|
50
|
+
this.emit("sd-blur");
|
|
51
|
+
}
|
|
52
|
+
handleInput() {
|
|
53
|
+
this.emit("sd-input");
|
|
54
|
+
}
|
|
55
|
+
handleInvalid(event) {
|
|
56
|
+
this.formControlController.setValidity(false);
|
|
57
|
+
this.formControlController.emitInvalidEvent(event);
|
|
58
|
+
}
|
|
59
|
+
handleFocus() {
|
|
60
|
+
this.emit("sd-focus");
|
|
61
|
+
}
|
|
62
|
+
handleDisabledChange() {
|
|
63
|
+
this.setAttribute("aria-disabled", this.disabled ? "true" : "false");
|
|
64
|
+
this.formControlController.setValidity(this.disabled);
|
|
65
|
+
}
|
|
66
|
+
handleStateChange() {
|
|
67
|
+
this.input.checked = this.checked;
|
|
68
|
+
this.formControlController.updateValidity();
|
|
69
|
+
}
|
|
70
|
+
/** Simulates a click on the switch. */
|
|
71
|
+
click() {
|
|
72
|
+
this.input.click();
|
|
73
|
+
}
|
|
74
|
+
/** Sets focus on the switch. */
|
|
75
|
+
focus(options) {
|
|
76
|
+
this.input.focus(options);
|
|
77
|
+
}
|
|
78
|
+
/** Removes focus from the switch. */
|
|
79
|
+
blur() {
|
|
80
|
+
this.input.blur();
|
|
81
|
+
}
|
|
82
|
+
/** Checks for validity but does not show a validation message. Returns true when valid and false when invalid. */
|
|
83
|
+
checkValidity() {
|
|
84
|
+
return this.input.checkValidity();
|
|
85
|
+
}
|
|
86
|
+
/** Gets the associated form, if one exists. */
|
|
87
|
+
getForm() {
|
|
88
|
+
return this.formControlController.getForm();
|
|
89
|
+
}
|
|
90
|
+
/** Checks for validity and shows a validation message if the control is invalid. */
|
|
91
|
+
reportValidity() {
|
|
92
|
+
return this.input.reportValidity();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Sets a custom validation message. The value provided will be shown to the user when the form is submitted. To clear
|
|
96
|
+
* the custom validation message, call this method with an empty string.
|
|
97
|
+
*/
|
|
98
|
+
setCustomValidity(message) {
|
|
99
|
+
this.input.setCustomValidity(message);
|
|
100
|
+
this.formControlController.updateValidity();
|
|
101
|
+
}
|
|
102
|
+
render() {
|
|
103
|
+
return html`<label part="base" class="${cx(
|
|
104
|
+
"group flex items-center text-base leading-normal text-black cursor-pointer",
|
|
105
|
+
this.disabled && "hover:cursor-not-allowed"
|
|
106
|
+
)}"><input id="input" class="peer absolute opacity-0 p-0 m-0 pointer-events-none" type="checkbox" title="${this.title}" name="${this.name}" value="${ifDefined(this.value)}" .checked="${live(this.checked)}" .disabled="${this.disabled}" .required="${this.required}" aria-checked="${this.checked ? "true" : "false"}" @click="${this.handleClick}" @input="${this.handleInput}" @invalid="${this.handleInvalid}" @blur="${this.handleBlur}" @focus="${this.handleFocus}"> <span id="control" part="control ${this.checked ? " control--checked" : "control--unchecked"}" class="${cx(
|
|
107
|
+
`relative flex flex-initial items-center justify-center border rounded-full h-4 w-8 transition-colors ease duration-100
|
|
108
|
+
peer-focus-visible:outline peer-focus-visible:outline-2 peer-focus-visible:outline-offset-2
|
|
109
|
+
peer-focus-visible:outline-primary`,
|
|
110
|
+
this.disabled && this.checked && "border-neutral-500 bg-neutral-500" || this.disabled && "border-neutral-500" || this.checked && "border-accent bg-accent hover:bg-accent-550 group-hover:bg-accent-550" || "border-neutral-800 bg-white hover:bg-neutral-200 group-hover:bg-neutral-200"
|
|
111
|
+
)}"><span id="thumb" part="thumb" class="${cx(
|
|
112
|
+
"w-2.5 h-2.5 rounded-full transition-transform ease-in-out duration-200",
|
|
113
|
+
this.checked && "translate-x-2 bg-white" || this.disabled && this.checked && "bg-white" || this.disabled && "-translate-x-2 bg-neutral-500" || "bg-neutral-800 -translate-x-2"
|
|
114
|
+
)}"></span> </span><span part="label" id="label" class="${cx(
|
|
115
|
+
"select-none inline-block ml-2 text-black",
|
|
116
|
+
this.disabled && "text-neutral-500" || "text-neutral-800"
|
|
117
|
+
)}"><slot></slot></span></label>`;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
SdSwitch.styles = [
|
|
121
|
+
SolidElement.styles,
|
|
122
|
+
css`:host{display:block}:host(:focus-visible){outline:0}:host([required]) #label::after{content:' *'}:host([data-user-invalid]) #label{color:rgb(var(--sd-color-error,204 25 55))}:host([data-user-invalid]) #control{border-color:rgb(var(--sd-color-error,204 25 55));background-color:rgb(var(--sd-color-error,204 25 55))}:host([data-user-invalid]) #thumb{background-color:rgb(var(--sd-white,255 255 255))}:host([data-user-invalid]) #input:hover~#control{background-color:rgb(var(--sd-color-error-400,172 25 56))}`
|
|
123
|
+
];
|
|
124
|
+
__decorateClass([
|
|
125
|
+
query("input")
|
|
126
|
+
], SdSwitch.prototype, "input", 2);
|
|
127
|
+
__decorateClass([
|
|
128
|
+
property()
|
|
129
|
+
], SdSwitch.prototype, "title", 2);
|
|
130
|
+
__decorateClass([
|
|
131
|
+
property()
|
|
132
|
+
], SdSwitch.prototype, "name", 2);
|
|
133
|
+
__decorateClass([
|
|
134
|
+
property()
|
|
135
|
+
], SdSwitch.prototype, "value", 2);
|
|
136
|
+
__decorateClass([
|
|
137
|
+
property({ type: Boolean, reflect: true })
|
|
138
|
+
], SdSwitch.prototype, "disabled", 2);
|
|
139
|
+
__decorateClass([
|
|
140
|
+
property({ type: Boolean, reflect: true })
|
|
141
|
+
], SdSwitch.prototype, "checked", 2);
|
|
142
|
+
__decorateClass([
|
|
143
|
+
defaultValue("checked")
|
|
144
|
+
], SdSwitch.prototype, "defaultChecked", 2);
|
|
145
|
+
__decorateClass([
|
|
146
|
+
property({ reflect: true })
|
|
147
|
+
], SdSwitch.prototype, "form", 2);
|
|
148
|
+
__decorateClass([
|
|
149
|
+
property({ type: Boolean, reflect: true })
|
|
150
|
+
], SdSwitch.prototype, "required", 2);
|
|
151
|
+
__decorateClass([
|
|
152
|
+
watch("disabled", { waitUntilFirstUpdate: true })
|
|
153
|
+
], SdSwitch.prototype, "handleDisabledChange", 1);
|
|
154
|
+
__decorateClass([
|
|
155
|
+
watch(["checked"], { waitUntilFirstUpdate: true })
|
|
156
|
+
], SdSwitch.prototype, "handleStateChange", 1);
|
|
157
|
+
SdSwitch = __decorateClass([
|
|
158
|
+
customElement("sd-switch")
|
|
159
|
+
], SdSwitch);
|
|
160
|
+
export {
|
|
161
|
+
SdSwitch as default
|
|
162
|
+
};
|
|
@@ -16,10 +16,12 @@ export { default as SdInclude } from './components/include/include';
|
|
|
16
16
|
export { default as SdInput } from './components/input/input';
|
|
17
17
|
export { default as SdLink } from './components/link/link';
|
|
18
18
|
export { default as SdNavigationItem } from './components/navigation-item/navigation-item';
|
|
19
|
+
export { default as SdNotification } from './components/notification/notification';
|
|
19
20
|
export { default as SdPopup } from './components/popup/popup';
|
|
20
21
|
export { default as SdRadio } from './components/radio/radio';
|
|
21
22
|
export { default as SdRadioGroup } from './components/radio-group/radio-group';
|
|
22
23
|
export { default as SdSpinner } from './components/spinner/spinner';
|
|
24
|
+
export { default as SdSwitch } from './components/switch/switch';
|
|
23
25
|
export { default as SdTag } from './components/tag/tag';
|
|
24
26
|
export { default as SdTeaser } from './components/teaser/teaser';
|
|
25
27
|
export { default as SdTooltip } from './components/tooltip/tooltip';
|
|
@@ -16,14 +16,16 @@ import { default as default16 } from "./components/include/include.js";
|
|
|
16
16
|
import { default as default17 } from "./components/input/input.js";
|
|
17
17
|
import { default as default18 } from "./components/link/link.js";
|
|
18
18
|
import { default as default19 } from "./components/navigation-item/navigation-item.js";
|
|
19
|
-
import { default as default20 } from "./components/
|
|
20
|
-
import { default as default21 } from "./components/
|
|
21
|
-
import { default as default22 } from "./components/radio
|
|
22
|
-
import { default as default23 } from "./components/
|
|
23
|
-
import { default as default24 } from "./components/
|
|
24
|
-
import { default as default25 } from "./components/
|
|
25
|
-
import { default as default26 } from "./components/
|
|
26
|
-
import { default as default27 } from "./components/
|
|
19
|
+
import { default as default20 } from "./components/notification/notification.js";
|
|
20
|
+
import { default as default21 } from "./components/popup/popup.js";
|
|
21
|
+
import { default as default22 } from "./components/radio/radio.js";
|
|
22
|
+
import { default as default23 } from "./components/radio-group/radio-group.js";
|
|
23
|
+
import { default as default24 } from "./components/spinner/spinner.js";
|
|
24
|
+
import { default as default25 } from "./components/switch/switch.js";
|
|
25
|
+
import { default as default26 } from "./components/tag/tag.js";
|
|
26
|
+
import { default as default27 } from "./components/teaser/teaser.js";
|
|
27
|
+
import { default as default28 } from "./components/tooltip/tooltip.js";
|
|
28
|
+
import { default as default29 } from "./components/video/video.js";
|
|
27
29
|
import { registerIconLibrary, unregisterIconLibrary } from "./components/icon/library.js";
|
|
28
30
|
import { LocalizeController } from "./utilities/localize.js";
|
|
29
31
|
export {
|
|
@@ -46,14 +48,16 @@ export {
|
|
|
46
48
|
default17 as SdInput,
|
|
47
49
|
default18 as SdLink,
|
|
48
50
|
default19 as SdNavigationItem,
|
|
49
|
-
default20 as
|
|
50
|
-
default21 as
|
|
51
|
-
default22 as
|
|
52
|
-
default23 as
|
|
53
|
-
default24 as
|
|
54
|
-
default25 as
|
|
55
|
-
default26 as
|
|
56
|
-
default27 as
|
|
51
|
+
default20 as SdNotification,
|
|
52
|
+
default21 as SdPopup,
|
|
53
|
+
default22 as SdRadio,
|
|
54
|
+
default23 as SdRadioGroup,
|
|
55
|
+
default24 as SdSpinner,
|
|
56
|
+
default25 as SdSwitch,
|
|
57
|
+
default26 as SdTag,
|
|
58
|
+
default27 as SdTeaser,
|
|
59
|
+
default28 as SdTooltip,
|
|
60
|
+
default29 as SdVideo,
|
|
57
61
|
registerIconLibrary,
|
|
58
62
|
unregisterIconLibrary
|
|
59
63
|
};
|