@solid-design-system/components 1.8.0 → 1.10.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/button.js +1 -6
- package/dist/components/es/drawer.js +1 -0
- package/dist/components/es/dropdown.js +1 -1
- package/dist/components/es/solid-components2.js +1 -1
- package/dist/components/es/solid-element.js +4 -4
- package/dist/components/es/static.js +6 -0
- package/dist/components/es/tabbable.js +1 -0
- package/dist/components/es/tag.js +1 -0
- package/dist/components/umd/solid-components.js +10 -10
- package/dist/custom-elements.json +1 -1
- package/dist/package/components/drawer/drawer.d.ts +34 -0
- package/dist/package/components/drawer/drawer.js +283 -0
- package/dist/package/components/icon/library.system.d.ts +1 -0
- package/dist/package/components/icon/library.system.js +6 -1
- package/dist/package/components/tag/tag.d.ts +24 -0
- package/dist/package/components/tag/tag.js +110 -0
- package/dist/package/internal/modal.d.ts +12 -0
- package/dist/package/internal/modal.js +52 -0
- package/dist/package/internal/scroll.js +23 -1
- package/dist/package/internal/string.d.ts +1 -0
- package/dist/package/internal/string.js +6 -0
- package/dist/package/solid-components.d.ts +2 -0
- package/dist/package/solid-components.js +18 -14
- package/dist/package/styles/tailwind.css.js +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 -6
- package/dist/versioned-components/es/divider.js +1 -1
- package/dist/versioned-components/es/drawer.js +1 -0
- package/dist/versioned-components/es/dropdown.js +1 -1
- package/dist/versioned-components/es/icon.js +1 -1
- package/dist/versioned-components/es/include.js +1 -1
- package/dist/versioned-components/es/link.js +1 -1
- package/dist/versioned-components/es/popup.js +1 -1
- package/dist/versioned-components/es/solid-components2.js +1 -1
- package/dist/versioned-components/es/solid-element.js +4 -4
- package/dist/versioned-components/es/spinner.js +1 -1
- package/dist/versioned-components/es/static.js +6 -0
- package/dist/versioned-components/es/tabbable.js +1 -0
- package/dist/versioned-components/es/tag.js +1 -0
- package/dist/versioned-components/es/teaser.js +1 -1
- 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/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 +34 -0
- package/dist/versioned-package/components/drawer/drawer.js +283 -0
- 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/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 +1 -0
- package/dist/versioned-package/components/icon/library.system.js +6 -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/link/link.d.ts +1 -1
- package/dist/versioned-package/components/link/link.js +2 -2
- 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/spinner/spinner.d.ts +1 -1
- package/dist/versioned-package/components/spinner/spinner.js +1 -1
- package/dist/versioned-package/components/tag/tag.d.ts +24 -0
- package/dist/versioned-package/components/tag/tag.js +110 -0
- package/dist/versioned-package/components/teaser/teaser.js +1 -1
- package/dist/versioned-package/internal/form.js +1 -1
- package/dist/versioned-package/internal/modal.d.ts +12 -0
- package/dist/versioned-package/internal/modal.js +52 -0
- package/dist/versioned-package/internal/scroll.js +23 -1
- package/dist/versioned-package/internal/string.d.ts +1 -0
- package/dist/versioned-package/internal/string.js +6 -0
- package/dist/versioned-package/solid-components.d.ts +2 -0
- package/dist/versioned-package/solid-components.js +18 -14
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/vscode.html-custom-data.json +215 -13
- package/dist/web-types.json +612 -14
- package/package.json +3 -3
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import "../button/button.js";
|
|
2
|
+
import "../icon/icon.js";
|
|
3
|
+
import { animateTo, stopAnimations } from "../../internal/animate.js";
|
|
4
|
+
import { css, html } from "lit";
|
|
5
|
+
import { query, property, customElement } from "lit/decorators.js";
|
|
6
|
+
import { setDefaultAnimation, getAnimation } from "../../utilities/animation-registry.js";
|
|
7
|
+
import { HasSlotController } from "../../internal/slot.js";
|
|
8
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
9
|
+
import { LocalizeController } from "../../utilities/localize.js";
|
|
10
|
+
import { lockBodyScrolling, unlockBodyScrolling } from "../../internal/scroll.js";
|
|
11
|
+
import { uppercaseFirstLetter } from "../../internal/string.js";
|
|
12
|
+
import { waitForEvent } from "../../internal/event.js";
|
|
13
|
+
import { watch } from "../../internal/watch.js";
|
|
14
|
+
import componentStyles from "../../styles/component.styles.js";
|
|
15
|
+
import cx from "classix";
|
|
16
|
+
import Modal from "../../internal/modal.js";
|
|
17
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
18
|
+
var __defProp = Object.defineProperty;
|
|
19
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
20
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
21
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
22
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
23
|
+
if (decorator = decorators[i])
|
|
24
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
25
|
+
if (kind && result)
|
|
26
|
+
__defProp(target, key, result);
|
|
27
|
+
return result;
|
|
28
|
+
};
|
|
29
|
+
let SdDrawer = class extends SolidElement {
|
|
30
|
+
constructor() {
|
|
31
|
+
super(...arguments);
|
|
32
|
+
this.hasSlotController = new HasSlotController(this, "footer");
|
|
33
|
+
this.localize = new LocalizeController(this);
|
|
34
|
+
this.modal = new Modal(this);
|
|
35
|
+
this.open = false;
|
|
36
|
+
this.label = "";
|
|
37
|
+
this.placement = "end";
|
|
38
|
+
this.contained = false;
|
|
39
|
+
this.noHeader = false;
|
|
40
|
+
this.handleDocumentKeyDown = (event) => {
|
|
41
|
+
if (this.open && event.key === "Escape") {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
this.requestClose("keyboard");
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
firstUpdated() {
|
|
48
|
+
this.drawer.hidden = !this.open;
|
|
49
|
+
if (this.open) {
|
|
50
|
+
this.addOpenListeners();
|
|
51
|
+
if (!this.contained) {
|
|
52
|
+
this.modal.activate();
|
|
53
|
+
lockBodyScrolling(this);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
disconnectedCallback() {
|
|
58
|
+
super.disconnectedCallback();
|
|
59
|
+
unlockBodyScrolling(this);
|
|
60
|
+
}
|
|
61
|
+
requestClose(source) {
|
|
62
|
+
const slRequestClose = this.emit("sd-request-close", {
|
|
63
|
+
cancelable: true,
|
|
64
|
+
detail: { source }
|
|
65
|
+
});
|
|
66
|
+
if (slRequestClose.defaultPrevented) {
|
|
67
|
+
const animation = getAnimation(this, "drawer.denyClose", { dir: this.localize.dir() });
|
|
68
|
+
animateTo(this.panel, animation.keyframes, animation.options);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.hide();
|
|
72
|
+
}
|
|
73
|
+
addOpenListeners() {
|
|
74
|
+
document.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
75
|
+
}
|
|
76
|
+
removeOpenListeners() {
|
|
77
|
+
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
78
|
+
}
|
|
79
|
+
async handleOpenChange() {
|
|
80
|
+
if (this.open) {
|
|
81
|
+
this.emit("sd-show");
|
|
82
|
+
this.addOpenListeners();
|
|
83
|
+
this.originalTrigger = document.activeElement;
|
|
84
|
+
if (!this.contained) {
|
|
85
|
+
this.modal.activate();
|
|
86
|
+
lockBodyScrolling(this);
|
|
87
|
+
}
|
|
88
|
+
const autoFocusTarget = this.querySelector("[autofocus]");
|
|
89
|
+
if (autoFocusTarget) {
|
|
90
|
+
autoFocusTarget.removeAttribute("autofocus");
|
|
91
|
+
}
|
|
92
|
+
await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);
|
|
93
|
+
this.drawer.hidden = false;
|
|
94
|
+
requestAnimationFrame(() => {
|
|
95
|
+
const sdInitialFocus = this.emit("sd-initial-focus", { cancelable: true });
|
|
96
|
+
if (!sdInitialFocus.defaultPrevented) {
|
|
97
|
+
if (autoFocusTarget) {
|
|
98
|
+
autoFocusTarget.focus({ preventScroll: true });
|
|
99
|
+
} else {
|
|
100
|
+
this.panel.focus({ preventScroll: true });
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
if (autoFocusTarget) {
|
|
104
|
+
autoFocusTarget.setAttribute("autofocus", "");
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
const panelAnimation = getAnimation(this, `drawer.show${uppercaseFirstLetter(this.placement)}`, {
|
|
108
|
+
dir: this.localize.dir()
|
|
109
|
+
});
|
|
110
|
+
const overlayAnimation = getAnimation(this, "drawer.overlay.show", { dir: this.localize.dir() });
|
|
111
|
+
await Promise.all([
|
|
112
|
+
animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options),
|
|
113
|
+
animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options)
|
|
114
|
+
]);
|
|
115
|
+
this.emit("sd-after-show");
|
|
116
|
+
} else {
|
|
117
|
+
this.emit("sd-hide");
|
|
118
|
+
this.removeOpenListeners();
|
|
119
|
+
if (!this.contained) {
|
|
120
|
+
this.modal.deactivate();
|
|
121
|
+
unlockBodyScrolling(this);
|
|
122
|
+
}
|
|
123
|
+
await Promise.all([stopAnimations(this.drawer), stopAnimations(this.overlay)]);
|
|
124
|
+
const panelAnimation = getAnimation(this, `drawer.hide${uppercaseFirstLetter(this.placement)}`, {
|
|
125
|
+
dir: this.localize.dir()
|
|
126
|
+
});
|
|
127
|
+
const overlayAnimation = getAnimation(this, "drawer.overlay.hide", { dir: this.localize.dir() });
|
|
128
|
+
await Promise.all([
|
|
129
|
+
animateTo(this.overlay, overlayAnimation.keyframes, overlayAnimation.options).then(() => {
|
|
130
|
+
this.overlay.hidden = true;
|
|
131
|
+
}),
|
|
132
|
+
animateTo(this.panel, panelAnimation.keyframes, panelAnimation.options).then(() => {
|
|
133
|
+
this.panel.hidden = true;
|
|
134
|
+
})
|
|
135
|
+
]);
|
|
136
|
+
this.drawer.hidden = true;
|
|
137
|
+
this.overlay.hidden = false;
|
|
138
|
+
this.panel.hidden = false;
|
|
139
|
+
const trigger = this.originalTrigger;
|
|
140
|
+
if (typeof (trigger == null ? void 0 : trigger.focus) === "function") {
|
|
141
|
+
setTimeout(() => trigger.focus());
|
|
142
|
+
}
|
|
143
|
+
this.emit("sd-after-hide");
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
handleNoModalChange() {
|
|
147
|
+
if (this.open && !this.contained) {
|
|
148
|
+
this.modal.activate();
|
|
149
|
+
lockBodyScrolling(this);
|
|
150
|
+
}
|
|
151
|
+
if (this.open && this.contained) {
|
|
152
|
+
this.modal.deactivate();
|
|
153
|
+
unlockBodyScrolling(this);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** Shows the drawer. */
|
|
157
|
+
async show() {
|
|
158
|
+
if (this.open) {
|
|
159
|
+
return void 0;
|
|
160
|
+
}
|
|
161
|
+
this.open = true;
|
|
162
|
+
return waitForEvent(this, "sd-after-show");
|
|
163
|
+
}
|
|
164
|
+
/** Hides the drawer */
|
|
165
|
+
async hide() {
|
|
166
|
+
if (!this.open) {
|
|
167
|
+
return void 0;
|
|
168
|
+
}
|
|
169
|
+
this.open = false;
|
|
170
|
+
return waitForEvent(this, "sd-after-hide");
|
|
171
|
+
}
|
|
172
|
+
render() {
|
|
173
|
+
return html`<div part="base" class="${cx(
|
|
174
|
+
"top-0 start-0 w-full h-full pointer-events-none overflow-hidden",
|
|
175
|
+
this.contained ? "absolute" : "fixed"
|
|
176
|
+
)}"><div part="overlay" class="${cx(
|
|
177
|
+
"block top-0 left-0 right-0 bottom-0 bg-neutral-800/75 pointer-events-auto",
|
|
178
|
+
this.contained ? "absolute" : "fixed"
|
|
179
|
+
)}" @click="${() => this.requestClose("overlay")}" tabindex="-1"></div><div part="panel" class="${cx(
|
|
180
|
+
"absolute flex flex-col z-10 max-w-full max-h-full bg-white shadow-lg overflow-auto pointer-events-auto focus:outline-none",
|
|
181
|
+
{
|
|
182
|
+
end: "top-0 end-0 bottom-auto start-auto w-[--width] h-full",
|
|
183
|
+
start: "top-0 end-auto bottom-auto start-0 w-[--width] h-full"
|
|
184
|
+
}[this.placement]
|
|
185
|
+
)}" role="dialog" aria-modal="true" aria-hidden="${this.open ? "false" : "true"}" aria-label="${this.label}" aria-labelledby="${ifDefined(!this.noHeader ? "title" : void 0)}" tabindex="0">${!this.noHeader ? html`<header part="header" class="flex justify-between py-2 px-4 items-center flex-shrink-0" style="min-height:56px"><div part="title"><slot name="header" part="title" class="flex-auto text-xl m-0" id="title"></slot></div><div class="shrink-0 flex flex-wrap justify-end gap-1 ml-4 absolute top-2 right-2"><sd-button variant="tertiary" size="lg" part="close-button" @click="${() => this.requestClose("close-button")}"><sd-icon name="close" library="system"></sd-icon></sd-button></div></header>` : ""}<div part="body" class="flex-auto block px-4"><slot></slot></div><footer part="footer" class="${cx(this.hasSlotController.test("footer") ? "text-left p-4" : "hidden")}"><slot name="footer"></slot></footer></div></div>`;
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
SdDrawer.styles = [
|
|
189
|
+
SolidElement.styles,
|
|
190
|
+
css`${componentStyles}:host{--width:25rem;display:contents}:host([contained]){z-index:initial}:host(:not([contained])){z-index:var(--sd-z-index-drawer)}[part=body]{-webkit-overflow-scrolling:touch;overflow-y:scroll;scrollbar-width:none}[part=body]::-webkit-scrollbar{width:0;height:0}`
|
|
191
|
+
];
|
|
192
|
+
__decorateClass([
|
|
193
|
+
query("[part=base]")
|
|
194
|
+
], SdDrawer.prototype, "drawer", 2);
|
|
195
|
+
__decorateClass([
|
|
196
|
+
query("[part=panel]")
|
|
197
|
+
], SdDrawer.prototype, "panel", 2);
|
|
198
|
+
__decorateClass([
|
|
199
|
+
query("[part=overlay]")
|
|
200
|
+
], SdDrawer.prototype, "overlay", 2);
|
|
201
|
+
__decorateClass([
|
|
202
|
+
property({ type: Boolean, reflect: true })
|
|
203
|
+
], SdDrawer.prototype, "open", 2);
|
|
204
|
+
__decorateClass([
|
|
205
|
+
property({ attribute: "label", reflect: true })
|
|
206
|
+
], SdDrawer.prototype, "label", 2);
|
|
207
|
+
__decorateClass([
|
|
208
|
+
property({ reflect: true })
|
|
209
|
+
], SdDrawer.prototype, "placement", 2);
|
|
210
|
+
__decorateClass([
|
|
211
|
+
property({ type: Boolean, reflect: true })
|
|
212
|
+
], SdDrawer.prototype, "contained", 2);
|
|
213
|
+
__decorateClass([
|
|
214
|
+
property({ attribute: "no-header", type: Boolean })
|
|
215
|
+
], SdDrawer.prototype, "noHeader", 2);
|
|
216
|
+
__decorateClass([
|
|
217
|
+
watch("open", { waitUntilFirstUpdate: true })
|
|
218
|
+
], SdDrawer.prototype, "handleOpenChange", 1);
|
|
219
|
+
__decorateClass([
|
|
220
|
+
watch("contained", { waitUntilFirstUpdate: true })
|
|
221
|
+
], SdDrawer.prototype, "handleNoModalChange", 1);
|
|
222
|
+
SdDrawer = __decorateClass([
|
|
223
|
+
customElement("sd-drawer")
|
|
224
|
+
], SdDrawer);
|
|
225
|
+
setDefaultAnimation("drawer.showStart", {
|
|
226
|
+
keyframes: [
|
|
227
|
+
{ opacity: 0, translate: "-100%" },
|
|
228
|
+
{ opacity: 1, translate: "0" }
|
|
229
|
+
],
|
|
230
|
+
rtlKeyframes: [
|
|
231
|
+
{ opacity: 0, translate: "100%" },
|
|
232
|
+
{ opacity: 1, translate: "0" }
|
|
233
|
+
],
|
|
234
|
+
options: { duration: 250, easing: "ease" }
|
|
235
|
+
});
|
|
236
|
+
setDefaultAnimation("drawer.hideStart", {
|
|
237
|
+
keyframes: [
|
|
238
|
+
{ opacity: 1, translate: "0" },
|
|
239
|
+
{ opacity: 0, translate: "-100%" }
|
|
240
|
+
],
|
|
241
|
+
rtlKeyframes: [
|
|
242
|
+
{ opacity: 1, translate: "0" },
|
|
243
|
+
{ opacity: 0, translate: "100%" }
|
|
244
|
+
],
|
|
245
|
+
options: { duration: 250, easing: "ease" }
|
|
246
|
+
});
|
|
247
|
+
setDefaultAnimation("drawer.showEnd", {
|
|
248
|
+
keyframes: [
|
|
249
|
+
{ opacity: 0, translate: "100%" },
|
|
250
|
+
{ opacity: 1, translate: "0" }
|
|
251
|
+
],
|
|
252
|
+
rtlKeyframes: [
|
|
253
|
+
{ opacity: 0, translate: "-100%" },
|
|
254
|
+
{ opacity: 1, translate: "0" }
|
|
255
|
+
],
|
|
256
|
+
options: { duration: 250, easing: "ease" }
|
|
257
|
+
});
|
|
258
|
+
setDefaultAnimation("drawer.hideEnd", {
|
|
259
|
+
keyframes: [
|
|
260
|
+
{ opacity: 1, translate: "0" },
|
|
261
|
+
{ opacity: 0, translate: "100%" }
|
|
262
|
+
],
|
|
263
|
+
rtlKeyframes: [
|
|
264
|
+
{ opacity: 1, translate: "0" },
|
|
265
|
+
{ opacity: 0, translate: "-100%" }
|
|
266
|
+
],
|
|
267
|
+
options: { duration: 250, easing: "ease" }
|
|
268
|
+
});
|
|
269
|
+
setDefaultAnimation("drawer.denyClose", {
|
|
270
|
+
keyframes: [{ scale: 1 }, { scale: 1.01 }, { scale: 1 }],
|
|
271
|
+
options: { duration: 250 }
|
|
272
|
+
});
|
|
273
|
+
setDefaultAnimation("drawer.overlay.show", {
|
|
274
|
+
keyframes: [{ opacity: 0 }, { opacity: 1 }],
|
|
275
|
+
options: { duration: 250 }
|
|
276
|
+
});
|
|
277
|
+
setDefaultAnimation("drawer.overlay.hide", {
|
|
278
|
+
keyframes: [{ opacity: 1 }, { opacity: 0 }],
|
|
279
|
+
options: { duration: 250 }
|
|
280
|
+
});
|
|
281
|
+
export {
|
|
282
|
+
SdDrawer as default
|
|
283
|
+
};
|
|
@@ -8,7 +8,12 @@ const icons = {
|
|
|
8
8
|
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
9
9
|
<path d="M12.743 6.333c-0.188-0.195-0.452-0.316-0.743-0.316s-0.555 0.121-0.743 0.315l-0 0-9 10c-0.137 0.17-0.22 0.388-0.22 0.626 0 0.552 0.448 1 1 1 0.276 0 0.526-0.112 0.707-0.293v0l8.257-9.173 8.257 9.173c0.181 0.181 0.431 0.292 0.707 0.292 0.552 0 1-0.448 1-1 0-0.238-0.083-0.456-0.222-0.628l0.001 0.002z"></path>
|
|
10
10
|
</svg>
|
|
11
|
-
|
|
11
|
+
`,
|
|
12
|
+
close: `
|
|
13
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
14
|
+
<path d="M21.707 2.293a1 1 0 0 0-1.414 0L12 10.586 3.707 2.293a1 1 0 0 0-1.413 1.414l-.001-.001 8.293 8.293-8.293 8.293a1 1 0 0 0 0 1.414 1 1 0 0 0 1.414 0L12 13.413l8.293 8.293a1 1 0 0 0 1.414 0 1 1 0 0 0 0-1.414l-8.293-8.293 8.293-8.293a1 1 0 0 0 0-1.414z"/></svg>
|
|
15
|
+
</svg>
|
|
16
|
+
`
|
|
12
17
|
};
|
|
13
18
|
const systemLibrary = {
|
|
14
19
|
name: "system",
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
export default class SdTag extends SolidElement {
|
|
3
|
+
tag: HTMLButtonElement | HTMLLinkElement;
|
|
4
|
+
size: 'lg' | 'sm';
|
|
5
|
+
selected: boolean;
|
|
6
|
+
removable: boolean;
|
|
7
|
+
disabled: boolean;
|
|
8
|
+
href: string;
|
|
9
|
+
target: '_blank' | '_parent' | '_self' | '_top';
|
|
10
|
+
download?: string;
|
|
11
|
+
private handleBlur;
|
|
12
|
+
private handleFocus;
|
|
13
|
+
private isLink;
|
|
14
|
+
click(): void;
|
|
15
|
+
focus(options?: FocusOptions): void;
|
|
16
|
+
blur(): void;
|
|
17
|
+
render(): import("lit-html").TemplateResult;
|
|
18
|
+
static styles: import("lit").CSSResultGroup[];
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
'sd-tag': SdTag;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { query, property, customElement } from "lit/decorators.js";
|
|
3
|
+
import { literal, html } from "lit/static-html.js";
|
|
4
|
+
import { ifDefined } from "lit/directives/if-defined.js";
|
|
5
|
+
import cx from "classix";
|
|
6
|
+
import SolidElement from "../../internal/solid-element.js";
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
9
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
10
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
11
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
12
|
+
if (decorator = decorators[i])
|
|
13
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
14
|
+
if (kind && result)
|
|
15
|
+
__defProp(target, key, result);
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
let SdTag = class extends SolidElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.size = "lg";
|
|
22
|
+
this.selected = false;
|
|
23
|
+
this.removable = false;
|
|
24
|
+
this.disabled = false;
|
|
25
|
+
this.href = "";
|
|
26
|
+
}
|
|
27
|
+
handleBlur() {
|
|
28
|
+
this.emit("sd-blur");
|
|
29
|
+
}
|
|
30
|
+
handleFocus() {
|
|
31
|
+
this.emit("sd-focus");
|
|
32
|
+
}
|
|
33
|
+
isLink() {
|
|
34
|
+
return this.href ? true : false;
|
|
35
|
+
}
|
|
36
|
+
/** Simulates a click on the tag. */
|
|
37
|
+
click() {
|
|
38
|
+
this.tag.click();
|
|
39
|
+
}
|
|
40
|
+
/** Sets focus on the tag. */
|
|
41
|
+
focus(options) {
|
|
42
|
+
this.tag.focus(options);
|
|
43
|
+
}
|
|
44
|
+
/** Removes focus from the tag. */
|
|
45
|
+
blur() {
|
|
46
|
+
this.tag.blur();
|
|
47
|
+
}
|
|
48
|
+
render() {
|
|
49
|
+
const isLink = this.isLink();
|
|
50
|
+
const tag = isLink ? literal`a` : literal`button`;
|
|
51
|
+
return html`<${tag} part="base" type="${ifDefined(isLink ? void 0 : "button")}" href="${ifDefined(isLink ? this.href : void 0)}" rel="${ifDefined(isLink && this.target ? "noreferrer noopener" : void 0)}" target="${ifDefined(isLink ? this.target : void 0)}" download="${ifDefined(isLink ? this.download : void 0)}" ?disabled="${ifDefined(isLink ? void 0 : this.disabled)}" aria-disabled="${this.disabled ? "true" : "false"}" tabindex="${this.disabled ? "-1" : "0"}" @blur="${this.handleBlur}" @focus="${this.handleFocus}" class="${cx(
|
|
52
|
+
/* basic styles of the wrapper */
|
|
53
|
+
"inline-flex border box-border rounded-full items-center leading-none whitespace-nowrap focus-visible:focus-outline",
|
|
54
|
+
{
|
|
55
|
+
/* sizes, fonts */
|
|
56
|
+
lg: "h-8 text-base gap-2",
|
|
57
|
+
sm: "h-6 text-sm gap-1"
|
|
58
|
+
}[this.size],
|
|
59
|
+
{
|
|
60
|
+
/* padding */
|
|
61
|
+
lg: !this.removable ? "px-4 py-2" : "pl-4 pr-3 py-2",
|
|
62
|
+
sm: !this.removable ? "px-3 py-[5px]" : "pl-3 pr-2 py-2"
|
|
63
|
+
}[this.size],
|
|
64
|
+
/* colors */
|
|
65
|
+
!this.selected ? "border-primary text-primary hover:border-primary-500 hover:bg-neutral-100 hover:text-primary-500 disabled:border-neutral-500 disabled:text-neutral-500" : "bg-primary border-primary text-white hover:bg-primary-500 hover:border-primary-500 disabled:bg-neutral-500 disabled:border-neutral-500",
|
|
66
|
+
this.disabled && !isLink && "cursor-not-allowed"
|
|
67
|
+
)}"><slot part="content"></slot><slot part="removable-indicator" name="removable-indicator" class="${cx(
|
|
68
|
+
!this.removable && "hidden",
|
|
69
|
+
{
|
|
70
|
+
/* sizes, fonts */
|
|
71
|
+
lg: "text-base",
|
|
72
|
+
sm: "text-[12px]"
|
|
73
|
+
}[this.size]
|
|
74
|
+
)}"><sd-icon library="system" name="close" label="remove"></sd-icon></slot></${tag}>`;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
SdTag.styles = [
|
|
78
|
+
SolidElement.styles,
|
|
79
|
+
css`:host{display:inline-block}`
|
|
80
|
+
];
|
|
81
|
+
__decorateClass([
|
|
82
|
+
query("a, button")
|
|
83
|
+
], SdTag.prototype, "tag", 2);
|
|
84
|
+
__decorateClass([
|
|
85
|
+
property({ reflect: true })
|
|
86
|
+
], SdTag.prototype, "size", 2);
|
|
87
|
+
__decorateClass([
|
|
88
|
+
property({ type: Boolean, reflect: true })
|
|
89
|
+
], SdTag.prototype, "selected", 2);
|
|
90
|
+
__decorateClass([
|
|
91
|
+
property({ type: Boolean, reflect: true })
|
|
92
|
+
], SdTag.prototype, "removable", 2);
|
|
93
|
+
__decorateClass([
|
|
94
|
+
property({ type: Boolean, reflect: true })
|
|
95
|
+
], SdTag.prototype, "disabled", 2);
|
|
96
|
+
__decorateClass([
|
|
97
|
+
property()
|
|
98
|
+
], SdTag.prototype, "href", 2);
|
|
99
|
+
__decorateClass([
|
|
100
|
+
property()
|
|
101
|
+
], SdTag.prototype, "target", 2);
|
|
102
|
+
__decorateClass([
|
|
103
|
+
property()
|
|
104
|
+
], SdTag.prototype, "download", 2);
|
|
105
|
+
SdTag = __decorateClass([
|
|
106
|
+
customElement("sd-tag")
|
|
107
|
+
], SdTag);
|
|
108
|
+
export {
|
|
109
|
+
SdTag as default
|
|
110
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default class Modal {
|
|
2
|
+
element: HTMLElement;
|
|
3
|
+
tabDirection: 'forward' | 'backward';
|
|
4
|
+
constructor(element: HTMLElement);
|
|
5
|
+
activate(): void;
|
|
6
|
+
deactivate(): void;
|
|
7
|
+
isActive(): boolean;
|
|
8
|
+
checkFocus(): void;
|
|
9
|
+
handleFocusIn(): void;
|
|
10
|
+
handleKeyDown(event: KeyboardEvent): void;
|
|
11
|
+
handleKeyUp(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { getTabbableBoundary } from "./tabbable.js";
|
|
2
|
+
let activeModals = [];
|
|
3
|
+
class Modal {
|
|
4
|
+
constructor(element) {
|
|
5
|
+
this.tabDirection = "forward";
|
|
6
|
+
this.element = element;
|
|
7
|
+
this.handleFocusIn = this.handleFocusIn.bind(this);
|
|
8
|
+
this.handleKeyDown = this.handleKeyDown.bind(this);
|
|
9
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
10
|
+
}
|
|
11
|
+
activate() {
|
|
12
|
+
activeModals.push(this.element);
|
|
13
|
+
document.addEventListener("focusin", this.handleFocusIn);
|
|
14
|
+
document.addEventListener("keydown", this.handleKeyDown);
|
|
15
|
+
document.addEventListener("keyup", this.handleKeyUp);
|
|
16
|
+
}
|
|
17
|
+
deactivate() {
|
|
18
|
+
activeModals = activeModals.filter((modal) => modal !== this.element);
|
|
19
|
+
document.removeEventListener("focusin", this.handleFocusIn);
|
|
20
|
+
document.removeEventListener("keydown", this.handleKeyDown);
|
|
21
|
+
document.removeEventListener("keyup", this.handleKeyUp);
|
|
22
|
+
}
|
|
23
|
+
isActive() {
|
|
24
|
+
return activeModals[activeModals.length - 1] === this.element;
|
|
25
|
+
}
|
|
26
|
+
checkFocus() {
|
|
27
|
+
if (this.isActive()) {
|
|
28
|
+
if (!this.element.matches(":focus-within")) {
|
|
29
|
+
const { start, end } = getTabbableBoundary(this.element);
|
|
30
|
+
const target = this.tabDirection === "forward" ? start : end;
|
|
31
|
+
if (typeof (target == null ? void 0 : target.focus) === "function") {
|
|
32
|
+
target.focus({ preventScroll: true });
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
handleFocusIn() {
|
|
38
|
+
this.checkFocus();
|
|
39
|
+
}
|
|
40
|
+
handleKeyDown(event) {
|
|
41
|
+
if (event.key === "Tab" && event.shiftKey) {
|
|
42
|
+
this.tabDirection = "backward";
|
|
43
|
+
requestAnimationFrame(() => this.checkFocus());
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
handleKeyUp() {
|
|
47
|
+
this.tabDirection = "forward";
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export {
|
|
51
|
+
Modal as default
|
|
52
|
+
};
|
|
@@ -1,4 +1,24 @@
|
|
|
1
1
|
import { getOffset } from "./offset.js";
|
|
2
|
+
const locks = /* @__PURE__ */ new Set();
|
|
3
|
+
function getScrollbarWidth() {
|
|
4
|
+
const documentWidth = document.documentElement.clientWidth;
|
|
5
|
+
return Math.abs(window.innerWidth - documentWidth);
|
|
6
|
+
}
|
|
7
|
+
function lockBodyScrolling(lockingEl) {
|
|
8
|
+
locks.add(lockingEl);
|
|
9
|
+
if (!document.body.classList.contains("sd-scroll-lock")) {
|
|
10
|
+
const scrollbarWidth = getScrollbarWidth();
|
|
11
|
+
document.body.classList.add("sd-scroll-lock");
|
|
12
|
+
document.body.style.setProperty("--sd-scroll-lock-size", `${scrollbarWidth}px`);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function unlockBodyScrolling(lockingEl) {
|
|
16
|
+
locks.delete(lockingEl);
|
|
17
|
+
if (locks.size === 0) {
|
|
18
|
+
document.body.classList.remove("sd-scroll-lock");
|
|
19
|
+
document.body.style.removeProperty("--sd-scrollbar-width");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
2
22
|
function scrollIntoView(element, container, direction = "vertical", behavior = "smooth") {
|
|
3
23
|
const offset = getOffset(element, container);
|
|
4
24
|
const offsetTop = offset.top + container.scrollTop;
|
|
@@ -23,5 +43,7 @@ function scrollIntoView(element, container, direction = "vertical", behavior = "
|
|
|
23
43
|
}
|
|
24
44
|
}
|
|
25
45
|
export {
|
|
26
|
-
|
|
46
|
+
lockBodyScrolling,
|
|
47
|
+
scrollIntoView,
|
|
48
|
+
unlockBodyScrolling
|
|
27
49
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function uppercaseFirstLetter(string: string): string;
|
|
@@ -4,12 +4,14 @@ export { default as SdBadge } from './components/badge/badge';
|
|
|
4
4
|
export { default as SdBrandshape } from './components/brandshape/brandshape';
|
|
5
5
|
export { default as SdButton } from './components/button/button';
|
|
6
6
|
export { default as SdDivider } from './components/divider/divider';
|
|
7
|
+
export { default as SdDrawer } from './components/drawer/drawer';
|
|
7
8
|
export { default as SdDropdown } from './components/dropdown/dropdown';
|
|
8
9
|
export { default as SdIcon } from './components/icon/icon';
|
|
9
10
|
export { default as SdInclude } from './components/include/include';
|
|
10
11
|
export { default as SdLink } from './components/link/link';
|
|
11
12
|
export { default as SdPopup } from './components/popup/popup';
|
|
12
13
|
export { default as SdSpinner } from './components/spinner/spinner';
|
|
14
|
+
export { default as SdTag } from './components/tag/tag';
|
|
13
15
|
export { default as SdTeaser } from './components/teaser/teaser';
|
|
14
16
|
export * from './utilities/icon-library';
|
|
15
17
|
export * from './utilities/localize';
|
|
@@ -4,13 +4,15 @@ import { default as default4 } from "./components/badge/badge.js";
|
|
|
4
4
|
import { default as default5 } from "./components/brandshape/brandshape.js";
|
|
5
5
|
import { default as default6 } from "./components/button/button.js";
|
|
6
6
|
import { default as default7 } from "./components/divider/divider.js";
|
|
7
|
-
import { default as default8 } from "./components/
|
|
8
|
-
import { default as default9 } from "./components/
|
|
9
|
-
import { default as default10 } from "./components/
|
|
10
|
-
import { default as default11 } from "./components/
|
|
11
|
-
import { default as default12 } from "./components/
|
|
12
|
-
import { default as default13 } from "./components/
|
|
13
|
-
import { default as default14 } from "./components/
|
|
7
|
+
import { default as default8 } from "./components/drawer/drawer.js";
|
|
8
|
+
import { default as default9 } from "./components/dropdown/dropdown.js";
|
|
9
|
+
import { default as default10 } from "./components/icon/icon.js";
|
|
10
|
+
import { default as default11 } from "./components/include/include.js";
|
|
11
|
+
import { default as default12 } from "./components/link/link.js";
|
|
12
|
+
import { default as default13 } from "./components/popup/popup.js";
|
|
13
|
+
import { default as default14 } from "./components/spinner/spinner.js";
|
|
14
|
+
import { default as default15 } from "./components/tag/tag.js";
|
|
15
|
+
import { default as default16 } from "./components/teaser/teaser.js";
|
|
14
16
|
import { registerIconLibrary, unregisterIconLibrary } from "./components/icon/library.js";
|
|
15
17
|
import { LocalizeController } from "./utilities/localize.js";
|
|
16
18
|
export {
|
|
@@ -21,13 +23,15 @@ export {
|
|
|
21
23
|
default5 as SdBrandshape,
|
|
22
24
|
default6 as SdButton,
|
|
23
25
|
default7 as SdDivider,
|
|
24
|
-
default8 as
|
|
25
|
-
default9 as
|
|
26
|
-
default10 as
|
|
27
|
-
default11 as
|
|
28
|
-
default12 as
|
|
29
|
-
default13 as
|
|
30
|
-
default14 as
|
|
26
|
+
default8 as SdDrawer,
|
|
27
|
+
default9 as SdDropdown,
|
|
28
|
+
default10 as SdIcon,
|
|
29
|
+
default11 as SdInclude,
|
|
30
|
+
default12 as SdLink,
|
|
31
|
+
default13 as SdPopup,
|
|
32
|
+
default14 as SdSpinner,
|
|
33
|
+
default15 as SdTag,
|
|
34
|
+
default16 as SdTeaser,
|
|
31
35
|
registerIconLibrary,
|
|
32
36
|
unregisterIconLibrary
|
|
33
37
|
};
|