@solid-design-system/components 1.7.0 → 1.9.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/drawer.js +1 -0
- package/dist/components/es/dropdown.js +1 -0
- package/dist/components/es/event.js +1 -0
- package/dist/components/es/popup.js +1 -0
- package/dist/components/es/solid-components2.js +1 -1
- package/dist/components/es/solid-element.js +4 -4
- package/dist/components/es/tabbable.js +1 -0
- package/dist/components/umd/solid-components.js +16 -16
- 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/dropdown/dropdown.d.ts +49 -0
- package/dist/package/components/dropdown/dropdown.js +335 -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/popup/popup.d.ts +42 -0
- package/dist/package/components/popup/popup.js +318 -0
- package/dist/package/internal/modal.d.ts +12 -0
- package/dist/package/internal/modal.js +52 -0
- package/dist/package/internal/offset.d.ts +4 -0
- package/dist/package/internal/offset.js +9 -0
- package/dist/package/internal/scroll.d.ts +3 -0
- package/dist/package/internal/scroll.js +49 -0
- package/dist/package/internal/string.d.ts +1 -0
- package/dist/package/internal/string.js +6 -0
- package/dist/package/internal/tabbable.d.ts +4 -0
- package/dist/package/internal/tabbable.js +50 -0
- package/dist/package/solid-components.d.ts +3 -0
- package/dist/package/solid-components.js +16 -10
- 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 +2 -2
- 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 -0
- package/dist/versioned-components/es/event.js +1 -0
- 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 -0
- 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/tabbable.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 +49 -0
- package/dist/versioned-package/components/dropdown/dropdown.js +335 -0
- 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 +42 -0
- package/dist/versioned-package/components/popup/popup.js +318 -0
- 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/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/offset.d.ts +4 -0
- package/dist/versioned-package/internal/offset.js +9 -0
- package/dist/versioned-package/internal/scroll.d.ts +3 -0
- package/dist/versioned-package/internal/scroll.js +49 -0
- package/dist/versioned-package/internal/string.d.ts +1 -0
- package/dist/versioned-package/internal/string.js +6 -0
- package/dist/versioned-package/internal/tabbable.d.ts +4 -0
- package/dist/versioned-package/internal/tabbable.js +50 -0
- package/dist/versioned-package/solid-components.d.ts +3 -0
- package/dist/versioned-package/solid-components.js +16 -10
- package/dist/versioned-package/styles/tailwind.css.js +1 -1
- package/dist/vscode.html-custom-data.json +731 -11
- package/dist/web-types.json +2107 -625
- package/package.json +4 -3
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import SolidElement from '../../internal/solid-element';
|
|
2
|
+
export default class SdPopup extends SolidElement {
|
|
3
|
+
private anchorEl;
|
|
4
|
+
private cleanup;
|
|
5
|
+
popup: HTMLElement;
|
|
6
|
+
private arrowEl;
|
|
7
|
+
anchor: Element | string;
|
|
8
|
+
active: boolean;
|
|
9
|
+
placement: 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'right' | 'right-start' | 'right-end' | 'left' | 'left-start' | 'left-end';
|
|
10
|
+
strategy: 'absolute' | 'fixed';
|
|
11
|
+
distance: number;
|
|
12
|
+
skidding: number;
|
|
13
|
+
arrow: boolean;
|
|
14
|
+
arrowPlacement: 'start' | 'end' | 'center' | 'anchor';
|
|
15
|
+
arrowPadding: number;
|
|
16
|
+
flip: boolean;
|
|
17
|
+
flipFallbackPlacements: string;
|
|
18
|
+
flipFallbackStrategy: 'best-fit' | 'initial';
|
|
19
|
+
flipBoundary: Element | Element[];
|
|
20
|
+
flipPadding: number;
|
|
21
|
+
shift: boolean;
|
|
22
|
+
shiftBoundary: Element | Element[];
|
|
23
|
+
shiftPadding: number;
|
|
24
|
+
autoSize: 'horizontal' | 'vertical' | 'both';
|
|
25
|
+
sync: 'width' | 'height' | 'both';
|
|
26
|
+
autoSizeBoundary: Element | Element[];
|
|
27
|
+
autoSizePadding: number;
|
|
28
|
+
connectedCallback(): Promise<void>;
|
|
29
|
+
disconnectedCallback(): void;
|
|
30
|
+
updated(changedProps: Map<string, unknown>): Promise<void>;
|
|
31
|
+
private handleAnchorChange;
|
|
32
|
+
private start;
|
|
33
|
+
private stop;
|
|
34
|
+
reposition(): void;
|
|
35
|
+
render(): import("lit-html").TemplateResult<1>;
|
|
36
|
+
static styles: import("lit").CSSResultGroup[];
|
|
37
|
+
}
|
|
38
|
+
declare global {
|
|
39
|
+
interface HTMLElementTagNameMap {
|
|
40
|
+
'sd-popup': SdPopup;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
import { autoUpdate, offset, size, flip, shift, arrow, computePosition } from "@floating-ui/dom";
|
|
2
|
+
import { css, html } from "lit";
|
|
3
|
+
import { query, property, customElement } from "lit/decorators.js";
|
|
4
|
+
import componentStyles from "../../styles/component.styles.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 SdPopup = class extends SolidElement {
|
|
19
|
+
constructor() {
|
|
20
|
+
super(...arguments);
|
|
21
|
+
this.active = false;
|
|
22
|
+
this.placement = "top";
|
|
23
|
+
this.strategy = "absolute";
|
|
24
|
+
this.distance = 0;
|
|
25
|
+
this.skidding = 0;
|
|
26
|
+
this.arrow = false;
|
|
27
|
+
this.arrowPlacement = "anchor";
|
|
28
|
+
this.arrowPadding = 10;
|
|
29
|
+
this.flip = false;
|
|
30
|
+
this.flipFallbackPlacements = "";
|
|
31
|
+
this.flipFallbackStrategy = "best-fit";
|
|
32
|
+
this.flipPadding = 0;
|
|
33
|
+
this.shift = false;
|
|
34
|
+
this.shiftPadding = 0;
|
|
35
|
+
this.autoSizePadding = 0;
|
|
36
|
+
}
|
|
37
|
+
async connectedCallback() {
|
|
38
|
+
super.connectedCallback();
|
|
39
|
+
await this.updateComplete;
|
|
40
|
+
this.start();
|
|
41
|
+
}
|
|
42
|
+
disconnectedCallback() {
|
|
43
|
+
this.stop();
|
|
44
|
+
}
|
|
45
|
+
async updated(changedProps) {
|
|
46
|
+
super.updated(changedProps);
|
|
47
|
+
if (changedProps.has("active")) {
|
|
48
|
+
if (this.active) {
|
|
49
|
+
this.start();
|
|
50
|
+
} else {
|
|
51
|
+
this.stop();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (changedProps.has("anchor")) {
|
|
55
|
+
this.handleAnchorChange();
|
|
56
|
+
}
|
|
57
|
+
if (this.active) {
|
|
58
|
+
await this.updateComplete;
|
|
59
|
+
this.reposition();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async handleAnchorChange() {
|
|
63
|
+
await this.stop();
|
|
64
|
+
if (this.anchor && typeof this.anchor === "string") {
|
|
65
|
+
const root = this.getRootNode();
|
|
66
|
+
this.anchorEl = root.getElementById(this.anchor);
|
|
67
|
+
} else if (this.anchor instanceof HTMLElement) {
|
|
68
|
+
this.anchorEl = this.anchor;
|
|
69
|
+
} else {
|
|
70
|
+
this.anchorEl = this.querySelector('[slot="anchor"]');
|
|
71
|
+
}
|
|
72
|
+
if (this.anchorEl instanceof HTMLSlotElement) {
|
|
73
|
+
this.anchorEl = this.anchorEl.assignedElements({ flatten: true })[0];
|
|
74
|
+
}
|
|
75
|
+
if (!this.anchorEl) {
|
|
76
|
+
throw new Error(
|
|
77
|
+
"Invalid anchor element: no anchor could be found using the anchor slot or the anchor attribute."
|
|
78
|
+
);
|
|
79
|
+
}
|
|
80
|
+
this.start();
|
|
81
|
+
}
|
|
82
|
+
start() {
|
|
83
|
+
if (!this.anchorEl) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
this.cleanup = autoUpdate(this.anchorEl, this.popup, () => {
|
|
87
|
+
this.reposition();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
async stop() {
|
|
91
|
+
return new Promise((resolve) => {
|
|
92
|
+
if (this.cleanup) {
|
|
93
|
+
this.cleanup();
|
|
94
|
+
this.cleanup = void 0;
|
|
95
|
+
this.removeAttribute("data-current-placement");
|
|
96
|
+
this.style.removeProperty("--auto-size-available-width");
|
|
97
|
+
this.style.removeProperty("--auto-size-available-height");
|
|
98
|
+
requestAnimationFrame(() => resolve());
|
|
99
|
+
} else {
|
|
100
|
+
resolve();
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
/** Forces the popup to recalculate and reposition itself. */
|
|
105
|
+
reposition() {
|
|
106
|
+
if (!this.active || !this.anchorEl) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const middleware = [
|
|
110
|
+
// The offset middleware goes first
|
|
111
|
+
offset({ mainAxis: this.distance, crossAxis: this.skidding })
|
|
112
|
+
];
|
|
113
|
+
if (this.sync) {
|
|
114
|
+
middleware.push(
|
|
115
|
+
size({
|
|
116
|
+
apply: ({ rects }) => {
|
|
117
|
+
const syncWidth = this.sync === "width" || this.sync === "both";
|
|
118
|
+
const syncHeight = this.sync === "height" || this.sync === "both";
|
|
119
|
+
this.popup.style.width = syncWidth ? `${rects.reference.width}px` : "";
|
|
120
|
+
this.popup.style.height = syncHeight ? `${rects.reference.height}px` : "";
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
this.popup.style.width = "";
|
|
126
|
+
this.popup.style.height = "";
|
|
127
|
+
}
|
|
128
|
+
if (this.flip) {
|
|
129
|
+
middleware.push(
|
|
130
|
+
flip({
|
|
131
|
+
boundary: this.flipBoundary,
|
|
132
|
+
// @ts-expect-error - We're converting a string attribute to an array here
|
|
133
|
+
fallbackPlacements: this.flipFallbackPlacements,
|
|
134
|
+
fallbackStrategy: this.flipFallbackStrategy === "best-fit" ? "bestFit" : "initialPlacement",
|
|
135
|
+
padding: this.flipPadding
|
|
136
|
+
})
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (this.shift) {
|
|
140
|
+
middleware.push(
|
|
141
|
+
shift({
|
|
142
|
+
boundary: this.shiftBoundary,
|
|
143
|
+
padding: this.shiftPadding
|
|
144
|
+
})
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
if (this.autoSize) {
|
|
148
|
+
middleware.push(
|
|
149
|
+
size({
|
|
150
|
+
boundary: this.autoSizeBoundary,
|
|
151
|
+
padding: this.autoSizePadding,
|
|
152
|
+
apply: ({ availableWidth, availableHeight }) => {
|
|
153
|
+
if (this.autoSize === "vertical" || this.autoSize === "both") {
|
|
154
|
+
this.style.setProperty("--auto-size-available-height", `${availableHeight}px`);
|
|
155
|
+
} else {
|
|
156
|
+
this.style.removeProperty("--auto-size-available-height");
|
|
157
|
+
}
|
|
158
|
+
if (this.autoSize === "horizontal" || this.autoSize === "both") {
|
|
159
|
+
this.style.setProperty("--auto-size-available-width", `${availableWidth}px`);
|
|
160
|
+
} else {
|
|
161
|
+
this.style.removeProperty("--auto-size-available-width");
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})
|
|
165
|
+
);
|
|
166
|
+
} else {
|
|
167
|
+
this.style.removeProperty("--auto-size-available-width");
|
|
168
|
+
this.style.removeProperty("--auto-size-available-height");
|
|
169
|
+
}
|
|
170
|
+
if (this.arrow) {
|
|
171
|
+
middleware.push(
|
|
172
|
+
arrow({
|
|
173
|
+
element: this.arrowEl,
|
|
174
|
+
padding: this.arrowPadding
|
|
175
|
+
})
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
computePosition(this.anchorEl, this.popup, {
|
|
179
|
+
placement: this.placement,
|
|
180
|
+
middleware,
|
|
181
|
+
strategy: this.strategy
|
|
182
|
+
}).then(({ x, y, middlewareData, placement }) => {
|
|
183
|
+
const isRtl = getComputedStyle(this).direction === "rtl";
|
|
184
|
+
const staticSide = { top: "bottom", right: "left", bottom: "top", left: "right" }[placement.split("-")[0]];
|
|
185
|
+
this.setAttribute("data-current-placement", placement);
|
|
186
|
+
Object.assign(this.popup.style, {
|
|
187
|
+
left: `${x}px`,
|
|
188
|
+
top: `${y}px`
|
|
189
|
+
});
|
|
190
|
+
if (this.arrow) {
|
|
191
|
+
const arrowX = middlewareData.arrow.x;
|
|
192
|
+
const arrowY = middlewareData.arrow.y;
|
|
193
|
+
let top = "";
|
|
194
|
+
let right = "";
|
|
195
|
+
let bottom = "";
|
|
196
|
+
let left = "";
|
|
197
|
+
if (this.arrowPlacement === "start") {
|
|
198
|
+
const value = typeof arrowX === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
199
|
+
top = typeof arrowY === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
200
|
+
right = isRtl ? value : "";
|
|
201
|
+
left = isRtl ? "" : value;
|
|
202
|
+
} else if (this.arrowPlacement === "end") {
|
|
203
|
+
const value = typeof arrowX === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
204
|
+
right = isRtl ? "" : value;
|
|
205
|
+
left = isRtl ? value : "";
|
|
206
|
+
bottom = typeof arrowY === "number" ? `calc(${this.arrowPadding}px - var(--arrow-padding-offset))` : "";
|
|
207
|
+
} else if (this.arrowPlacement === "center") {
|
|
208
|
+
left = typeof arrowX === "number" ? `calc(50% - var(--arrow-size-diagonal))` : "";
|
|
209
|
+
top = typeof arrowY === "number" ? `calc(50% - var(--arrow-size-diagonal))` : "";
|
|
210
|
+
} else {
|
|
211
|
+
left = typeof arrowX === "number" ? `${arrowX}px` : "";
|
|
212
|
+
top = typeof arrowY === "number" ? `${arrowY}px` : "";
|
|
213
|
+
}
|
|
214
|
+
Object.assign(this.arrowEl.style, {
|
|
215
|
+
top,
|
|
216
|
+
right,
|
|
217
|
+
bottom,
|
|
218
|
+
left,
|
|
219
|
+
[staticSide]: "calc(var(--arrow-size-diagonal) * -1)"
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
this.emit("sd-reposition");
|
|
224
|
+
}
|
|
225
|
+
render() {
|
|
226
|
+
return html`<slot name="anchor" @slotchange="${this.handleAnchorChange}"></slot><div part="popup" class="${cx("isolate", this.strategy !== "fixed" ? "absolute" : "fixed", !this.active && "hidden")}"><slot></slot>${this.arrow ? html`<div part="arrow" class="absolute rotate-45 -z-10" role="presentation"></div>` : ""}</div>`;
|
|
227
|
+
}
|
|
228
|
+
};
|
|
229
|
+
SdPopup.styles = [
|
|
230
|
+
SolidElement.styles,
|
|
231
|
+
componentStyles,
|
|
232
|
+
css`:host{--arrow-color:var(--sd-color-neutral-1000);--arrow-size:6px;--arrow-size-diagonal:calc(var(--arrow-size) * 0.7071);--arrow-padding-offset:calc(var(--arrow-size-diagonal) - var(--arrow-size));display:contents}[part=popup]{max-width:var(--auto-size-available-width,none);max-height:var(--auto-size-available-height,none)}[part=arrow]{width:calc(var(--arrow-size-diagonal) * 2);height:calc(var(--arrow-size-diagonal) * 2);background:var(--arrow-color)}`
|
|
233
|
+
];
|
|
234
|
+
__decorateClass([
|
|
235
|
+
query('[part="popup"]')
|
|
236
|
+
], SdPopup.prototype, "popup", 2);
|
|
237
|
+
__decorateClass([
|
|
238
|
+
query('[part="arrow"]')
|
|
239
|
+
], SdPopup.prototype, "arrowEl", 2);
|
|
240
|
+
__decorateClass([
|
|
241
|
+
property()
|
|
242
|
+
], SdPopup.prototype, "anchor", 2);
|
|
243
|
+
__decorateClass([
|
|
244
|
+
property({ type: Boolean, reflect: true })
|
|
245
|
+
], SdPopup.prototype, "active", 2);
|
|
246
|
+
__decorateClass([
|
|
247
|
+
property({ reflect: true })
|
|
248
|
+
], SdPopup.prototype, "placement", 2);
|
|
249
|
+
__decorateClass([
|
|
250
|
+
property({ reflect: true })
|
|
251
|
+
], SdPopup.prototype, "strategy", 2);
|
|
252
|
+
__decorateClass([
|
|
253
|
+
property({ type: Number })
|
|
254
|
+
], SdPopup.prototype, "distance", 2);
|
|
255
|
+
__decorateClass([
|
|
256
|
+
property({ type: Number })
|
|
257
|
+
], SdPopup.prototype, "skidding", 2);
|
|
258
|
+
__decorateClass([
|
|
259
|
+
property({ type: Boolean })
|
|
260
|
+
], SdPopup.prototype, "arrow", 2);
|
|
261
|
+
__decorateClass([
|
|
262
|
+
property({ attribute: "arrow-placement" })
|
|
263
|
+
], SdPopup.prototype, "arrowPlacement", 2);
|
|
264
|
+
__decorateClass([
|
|
265
|
+
property({ attribute: "arrow-padding", type: Number })
|
|
266
|
+
], SdPopup.prototype, "arrowPadding", 2);
|
|
267
|
+
__decorateClass([
|
|
268
|
+
property({ type: Boolean })
|
|
269
|
+
], SdPopup.prototype, "flip", 2);
|
|
270
|
+
__decorateClass([
|
|
271
|
+
property({
|
|
272
|
+
attribute: "flip-fallback-placements",
|
|
273
|
+
converter: {
|
|
274
|
+
fromAttribute: (value) => {
|
|
275
|
+
return value.split(" ").map((p) => p.trim()).filter((p) => p !== "");
|
|
276
|
+
},
|
|
277
|
+
toAttribute: (value) => {
|
|
278
|
+
return value.join(" ");
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
})
|
|
282
|
+
], SdPopup.prototype, "flipFallbackPlacements", 2);
|
|
283
|
+
__decorateClass([
|
|
284
|
+
property({ attribute: "flip-fallback-strategy" })
|
|
285
|
+
], SdPopup.prototype, "flipFallbackStrategy", 2);
|
|
286
|
+
__decorateClass([
|
|
287
|
+
property({ type: Object })
|
|
288
|
+
], SdPopup.prototype, "flipBoundary", 2);
|
|
289
|
+
__decorateClass([
|
|
290
|
+
property({ attribute: "flip-padding", type: Number })
|
|
291
|
+
], SdPopup.prototype, "flipPadding", 2);
|
|
292
|
+
__decorateClass([
|
|
293
|
+
property({ type: Boolean })
|
|
294
|
+
], SdPopup.prototype, "shift", 2);
|
|
295
|
+
__decorateClass([
|
|
296
|
+
property({ type: Object })
|
|
297
|
+
], SdPopup.prototype, "shiftBoundary", 2);
|
|
298
|
+
__decorateClass([
|
|
299
|
+
property({ attribute: "shift-padding", type: Number })
|
|
300
|
+
], SdPopup.prototype, "shiftPadding", 2);
|
|
301
|
+
__decorateClass([
|
|
302
|
+
property({ attribute: "auto-size" })
|
|
303
|
+
], SdPopup.prototype, "autoSize", 2);
|
|
304
|
+
__decorateClass([
|
|
305
|
+
property()
|
|
306
|
+
], SdPopup.prototype, "sync", 2);
|
|
307
|
+
__decorateClass([
|
|
308
|
+
property({ type: Object })
|
|
309
|
+
], SdPopup.prototype, "autoSizeBoundary", 2);
|
|
310
|
+
__decorateClass([
|
|
311
|
+
property({ attribute: "auto-size-padding", type: Number })
|
|
312
|
+
], SdPopup.prototype, "autoSizePadding", 2);
|
|
313
|
+
SdPopup = __decorateClass([
|
|
314
|
+
customElement("sd-popup")
|
|
315
|
+
], SdPopup);
|
|
316
|
+
export {
|
|
317
|
+
SdPopup as default
|
|
318
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function getOffset(element, parent) {
|
|
2
|
+
return {
|
|
3
|
+
top: Math.round(element.getBoundingClientRect().top - parent.getBoundingClientRect().top),
|
|
4
|
+
left: Math.round(element.getBoundingClientRect().left - parent.getBoundingClientRect().left)
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
getOffset
|
|
9
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare function lockBodyScrolling(lockingEl: HTMLElement): void;
|
|
2
|
+
export declare function unlockBodyScrolling(lockingEl: HTMLElement): void;
|
|
3
|
+
export declare function scrollIntoView(element: HTMLElement, container: HTMLElement, direction?: 'horizontal' | 'vertical' | 'both', behavior?: 'smooth' | 'auto'): void;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
}
|
|
22
|
+
function scrollIntoView(element, container, direction = "vertical", behavior = "smooth") {
|
|
23
|
+
const offset = getOffset(element, container);
|
|
24
|
+
const offsetTop = offset.top + container.scrollTop;
|
|
25
|
+
const offsetLeft = offset.left + container.scrollLeft;
|
|
26
|
+
const minX = container.scrollLeft;
|
|
27
|
+
const maxX = container.scrollLeft + container.offsetWidth;
|
|
28
|
+
const minY = container.scrollTop;
|
|
29
|
+
const maxY = container.scrollTop + container.offsetHeight;
|
|
30
|
+
if (direction === "horizontal" || direction === "both") {
|
|
31
|
+
if (offsetLeft < minX) {
|
|
32
|
+
container.scrollTo({ left: offsetLeft, behavior });
|
|
33
|
+
} else if (offsetLeft + element.clientWidth > maxX) {
|
|
34
|
+
container.scrollTo({ left: offsetLeft - container.offsetWidth + element.clientWidth, behavior });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (direction === "vertical" || direction === "both") {
|
|
38
|
+
if (offsetTop < minY) {
|
|
39
|
+
container.scrollTo({ top: offsetTop, behavior });
|
|
40
|
+
} else if (offsetTop + element.clientHeight > maxY) {
|
|
41
|
+
container.scrollTo({ top: offsetTop - container.offsetHeight + element.clientHeight, behavior });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
lockBodyScrolling,
|
|
47
|
+
scrollIntoView,
|
|
48
|
+
unlockBodyScrolling
|
|
49
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function uppercaseFirstLetter(string: string): string;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
function isTabbable(el) {
|
|
2
|
+
const tag = el.tagName.toLowerCase();
|
|
3
|
+
if (el.getAttribute("tabindex") === "-1") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (el.hasAttribute("disabled")) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (el.hasAttribute("aria-disabled") && el.getAttribute("aria-disabled") !== "false") {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (tag === "input" && el.getAttribute("type") === "radio" && !el.hasAttribute("checked")) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (el.offsetParent === null) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
if (window.getComputedStyle(el).visibility === "hidden") {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if ((tag === "audio" || tag === "video") && el.hasAttribute("controls")) {
|
|
22
|
+
return true;
|
|
23
|
+
}
|
|
24
|
+
if (el.hasAttribute("tabindex")) {
|
|
25
|
+
return true;
|
|
26
|
+
}
|
|
27
|
+
if (el.hasAttribute("contenteditable") && el.getAttribute("contenteditable") !== "false") {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
return ["button", "input", "select", "textarea", "a", "audio", "video", "summary"].includes(tag);
|
|
31
|
+
}
|
|
32
|
+
function getTabbableBoundary(root) {
|
|
33
|
+
const allElements = [];
|
|
34
|
+
function walk(el) {
|
|
35
|
+
if (el instanceof HTMLElement) {
|
|
36
|
+
allElements.push(el);
|
|
37
|
+
if (el.shadowRoot !== null && el.shadowRoot.mode === "open") {
|
|
38
|
+
walk(el.shadowRoot);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
[...el.children].forEach((e) => walk(e));
|
|
42
|
+
}
|
|
43
|
+
walk(root);
|
|
44
|
+
const start = allElements.find((el) => isTabbable(el)) ?? null;
|
|
45
|
+
const end = allElements.reverse().find((el) => isTabbable(el)) ?? null;
|
|
46
|
+
return { start, end };
|
|
47
|
+
}
|
|
48
|
+
export {
|
|
49
|
+
getTabbableBoundary
|
|
50
|
+
};
|
|
@@ -4,9 +4,12 @@ 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';
|
|
8
|
+
export { default as SdDropdown } from './components/dropdown/dropdown';
|
|
7
9
|
export { default as SdIcon } from './components/icon/icon';
|
|
8
10
|
export { default as SdInclude } from './components/include/include';
|
|
9
11
|
export { default as SdLink } from './components/link/link';
|
|
12
|
+
export { default as SdPopup } from './components/popup/popup';
|
|
10
13
|
export { default as SdSpinner } from './components/spinner/spinner';
|
|
11
14
|
export { default as SdTeaser } from './components/teaser/teaser';
|
|
12
15
|
export * from './utilities/icon-library';
|
|
@@ -4,11 +4,14 @@ 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/
|
|
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/teaser/teaser.js";
|
|
12
15
|
import { registerIconLibrary, unregisterIconLibrary } from "./components/icon/library.js";
|
|
13
16
|
import { LocalizeController } from "./utilities/localize.js";
|
|
14
17
|
export {
|
|
@@ -19,11 +22,14 @@ export {
|
|
|
19
22
|
default5 as SdBrandshape,
|
|
20
23
|
default6 as SdButton,
|
|
21
24
|
default7 as SdDivider,
|
|
22
|
-
default8 as
|
|
23
|
-
default9 as
|
|
24
|
-
default10 as
|
|
25
|
-
default11 as
|
|
26
|
-
default12 as
|
|
25
|
+
default8 as SdDrawer,
|
|
26
|
+
default9 as SdDropdown,
|
|
27
|
+
default10 as SdIcon,
|
|
28
|
+
default11 as SdInclude,
|
|
29
|
+
default12 as SdLink,
|
|
30
|
+
default13 as SdPopup,
|
|
31
|
+
default14 as SdSpinner,
|
|
32
|
+
default15 as SdTeaser,
|
|
27
33
|
registerIconLibrary,
|
|
28
34
|
unregisterIconLibrary
|
|
29
35
|
};
|