@substrate-system/dialog 0.0.4
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/LICENSE +168 -0
- package/README.md +122 -0
- package/dist/index.cjs +432 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.css +164 -0
- package/dist/index.d.ts +50 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +413 -0
- package/dist/index.js.map +7 -0
- package/dist/index.min.css +1 -0
- package/dist/index.min.js +1 -0
- package/dist/meta.json +36 -0
- package/package.json +89 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface HTMLElementTagNameMap {
|
|
3
|
+
'modal-window': ModalWindow;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
export declare class ModalWindow extends HTMLElement {
|
|
7
|
+
_buttonClose: HTMLButtonElement | null;
|
|
8
|
+
_modal: HTMLDivElement | null;
|
|
9
|
+
_modalOverlay: HTMLDivElement | null;
|
|
10
|
+
_modalScroll: HTMLDivElement | null;
|
|
11
|
+
_modalContent: HTMLDivElement | null;
|
|
12
|
+
_focusTrap1: HTMLSpanElement | null;
|
|
13
|
+
_focusTrap2: HTMLSpanElement | null;
|
|
14
|
+
_heading: HTMLElement | null;
|
|
15
|
+
static TAG: string;
|
|
16
|
+
_activeElement: HTMLElement | null;
|
|
17
|
+
_isActive: boolean;
|
|
18
|
+
_isAnimated: boolean;
|
|
19
|
+
_isHideShow: boolean;
|
|
20
|
+
_isStatic: boolean;
|
|
21
|
+
_timerForHide: number | undefined;
|
|
22
|
+
_timerForShow: number | undefined;
|
|
23
|
+
_closable: boolean;
|
|
24
|
+
constructor();
|
|
25
|
+
_buildModal(contentNodes: Node[]): void;
|
|
26
|
+
static get observedAttributes(): string[];
|
|
27
|
+
attributeChangedCallback(name: string, oldValue: string, newValue: string): void;
|
|
28
|
+
connectedCallback(): void;
|
|
29
|
+
disconnectedCallback(): void;
|
|
30
|
+
_bind(): void;
|
|
31
|
+
_addEvents(): void;
|
|
32
|
+
_removeEvents(): void;
|
|
33
|
+
_setAnimationFlag(): void;
|
|
34
|
+
_setCloseTitle(): void;
|
|
35
|
+
_setModalLabel(): void;
|
|
36
|
+
_setActiveFlag(): void;
|
|
37
|
+
_setStaticFlag(): void;
|
|
38
|
+
_focusElement(element: HTMLElement): void;
|
|
39
|
+
_focusModal(): void;
|
|
40
|
+
_isOutsideModal(element?: HTMLElement): boolean;
|
|
41
|
+
_isMotionOkay(): boolean;
|
|
42
|
+
_toggleModalDisplay(callback: () => void): void;
|
|
43
|
+
_handleClickOverlay(event: MouseEvent): void;
|
|
44
|
+
_handleClickClose(): void;
|
|
45
|
+
_handleFocusIn(): void;
|
|
46
|
+
_handleKeyDown({ key }: KeyboardEvent): void;
|
|
47
|
+
open(): void;
|
|
48
|
+
close(): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,qBAAqB;QAC3B,cAAc,EAAC,WAAW,CAAA;KAC7B;CACJ;AA4DD,qBAAa,WAAY,SAAQ,WAAW;IAExC,YAAY,EAAC,iBAAiB,GAAC,IAAI,CAAO;IAC1C,MAAM,EAAC,cAAc,GAAC,IAAI,CAAO;IACjC,aAAa,EAAC,cAAc,GAAC,IAAI,CAAO;IACxC,YAAY,EAAC,cAAc,GAAC,IAAI,CAAO;IACvC,aAAa,EAAC,cAAc,GAAC,IAAI,CAAO;IACxC,WAAW,EAAC,eAAe,GAAC,IAAI,CAAO;IACvC,WAAW,EAAC,eAAe,GAAC,IAAI,CAAO;IACvC,QAAQ,EAAC,WAAW,GAAC,IAAI,CAAO;IAEhC,MAAM,CAAC,GAAG,EAAC,MAAM,CAAiB;IAGlC,cAAc,EAAC,WAAW,GAAC,IAAI,CAAO;IACtC,SAAS,UAAQ;IACjB,WAAW,UAAO;IAClB,WAAW,UAAQ;IACnB,SAAS,UAAQ;IACjB,aAAa,EAAC,MAAM,GAAC,SAAS,CAAA;IAC9B,aAAa,EAAC,MAAM,GAAC,SAAS,CAAA;IAC9B,SAAS,EAAC,OAAO,CAAO;;IA2CxB,WAAW,CAAE,YAAY,EAAE,IAAI,EAAE;IAoEjC,MAAM,KAAK,kBAAkB,aAE5B;IAMD,wBAAwB,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IA6B1E,iBAAiB;IAQjB,oBAAoB;IAQpB,KAAK;IAkBL,UAAU;IAmBV,aAAa;IAgBb,iBAAiB;IAQjB,cAAc;IAed,cAAc;IAqBd,cAAc;IAoBd,cAAc;IAQd,aAAa,CAAE,OAAO,EAAE,WAAW;IAYnC,WAAW;IAeX,eAAe,CAAE,OAAO,CAAC,EAAE,WAAW;IAoBtC,aAAa;IAYb,mBAAmB,CAAE,QAAQ,EAAE,MAAM,IAAI;IA+FzC,mBAAmB,CAAE,KAAK,EAAE,UAAU;IAiBtC,iBAAiB;IAQjB,cAAc;IAoCd,cAAc,CAAE,EAAE,GAAG,EAAE,EAAC,aAAa;IAyBrC,IAAI;IAWJ,KAAK;CAQR"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
import { define } from "@substrate-system/web-component";
|
|
4
|
+
const ACTIVE = "active";
|
|
5
|
+
const ANIMATED = "animated";
|
|
6
|
+
const ANIMATION_DURATION = 250;
|
|
7
|
+
const ARIA_LABEL = "aria-label";
|
|
8
|
+
const CLOSE = "close";
|
|
9
|
+
const CLOSE_TITLE = "Close";
|
|
10
|
+
const DATA_HIDE = "data-modal-hide";
|
|
11
|
+
const DATA_SHOW = "data-modal-show";
|
|
12
|
+
const DATA_VISIBLE = "data-visible";
|
|
13
|
+
const EMPTY_STRING = "";
|
|
14
|
+
const ESCAPE = "escape";
|
|
15
|
+
const FALSE = "false";
|
|
16
|
+
const FOCUSIN = "focusin";
|
|
17
|
+
const HIDDEN = "hidden";
|
|
18
|
+
const KEYDOWN = "keydown";
|
|
19
|
+
const MODAL_LABEL_FALLBACK = "modal";
|
|
20
|
+
const PREFERS_REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
|
|
21
|
+
const SPACE = " ";
|
|
22
|
+
const SPACE_REGEX = /\s+/g;
|
|
23
|
+
const STATIC = "static";
|
|
24
|
+
const TAB = "tab";
|
|
25
|
+
const TRUE = "true";
|
|
26
|
+
const FOCUSABLE_SELECTORS = [
|
|
27
|
+
"[contenteditable]",
|
|
28
|
+
'[tabindex="0"]:not([disabled])',
|
|
29
|
+
"a[href]",
|
|
30
|
+
"audio[controls]",
|
|
31
|
+
"button:not([disabled])",
|
|
32
|
+
"iframe",
|
|
33
|
+
"input:not([disabled]):not([type='hidden'])",
|
|
34
|
+
"select:not([disabled])",
|
|
35
|
+
"summary",
|
|
36
|
+
"textarea:not([disabled])",
|
|
37
|
+
"video[controls]"
|
|
38
|
+
].join(",");
|
|
39
|
+
class ModalWindow extends HTMLElement {
|
|
40
|
+
static {
|
|
41
|
+
__name(this, "ModalWindow");
|
|
42
|
+
}
|
|
43
|
+
// Element references (set during build).
|
|
44
|
+
_buttonClose = null;
|
|
45
|
+
_modal = null;
|
|
46
|
+
_modalOverlay = null;
|
|
47
|
+
_modalScroll = null;
|
|
48
|
+
_modalContent = null;
|
|
49
|
+
_focusTrap1 = null;
|
|
50
|
+
_focusTrap2 = null;
|
|
51
|
+
_heading = null;
|
|
52
|
+
static TAG = "modal-window";
|
|
53
|
+
// State.
|
|
54
|
+
_activeElement = null;
|
|
55
|
+
_isActive = false;
|
|
56
|
+
_isAnimated = true;
|
|
57
|
+
_isHideShow = false;
|
|
58
|
+
_isStatic = false;
|
|
59
|
+
_timerForHide;
|
|
60
|
+
_timerForShow;
|
|
61
|
+
_closable = true;
|
|
62
|
+
// =======================
|
|
63
|
+
// Lifecycle: constructor.
|
|
64
|
+
// =======================
|
|
65
|
+
constructor() {
|
|
66
|
+
super();
|
|
67
|
+
this._bind();
|
|
68
|
+
this._closable = this.getAttribute("closable") !== "false";
|
|
69
|
+
this._heading = this.querySelector("h1, h2, h3, h4, h5, h6");
|
|
70
|
+
const contentNodes = Array.from(this.childNodes);
|
|
71
|
+
this._buildModal(contentNodes);
|
|
72
|
+
this._setAnimationFlag();
|
|
73
|
+
this._setCloseTitle();
|
|
74
|
+
this._setModalLabel();
|
|
75
|
+
this._setStaticFlag();
|
|
76
|
+
this._setActiveFlag();
|
|
77
|
+
}
|
|
78
|
+
// ============================
|
|
79
|
+
// Helper: build modal structure.
|
|
80
|
+
// ============================
|
|
81
|
+
_buildModal(contentNodes) {
|
|
82
|
+
const createFocusTrap = /* @__PURE__ */ __name(() => {
|
|
83
|
+
const trap = document.createElement("span");
|
|
84
|
+
trap.setAttribute("aria-hidden", "true");
|
|
85
|
+
trap.setAttribute("data-modal-focus-trap", "");
|
|
86
|
+
trap.tabIndex = 0;
|
|
87
|
+
return trap;
|
|
88
|
+
}, "createFocusTrap");
|
|
89
|
+
const scroll = document.createElement("div");
|
|
90
|
+
scroll.setAttribute("data-modal-scroll", "");
|
|
91
|
+
this._modalScroll = scroll;
|
|
92
|
+
const overlay = document.createElement("div");
|
|
93
|
+
overlay.setAttribute("data-modal-overlay", "");
|
|
94
|
+
this._modalOverlay = overlay;
|
|
95
|
+
const dialog = document.createElement("div");
|
|
96
|
+
dialog.setAttribute("aria-modal", "true");
|
|
97
|
+
dialog.setAttribute("data-modal-dialog", "");
|
|
98
|
+
dialog.setAttribute("role", "dialog");
|
|
99
|
+
dialog.tabIndex = -1;
|
|
100
|
+
this._modal = dialog;
|
|
101
|
+
if (this._closable) {
|
|
102
|
+
const closeBtn = document.createElement("button");
|
|
103
|
+
closeBtn.setAttribute("data-modal-close", "");
|
|
104
|
+
closeBtn.type = "button";
|
|
105
|
+
closeBtn.innerHTML = "×";
|
|
106
|
+
dialog.appendChild(closeBtn);
|
|
107
|
+
this._buttonClose = closeBtn;
|
|
108
|
+
}
|
|
109
|
+
const content = document.createElement("div");
|
|
110
|
+
content.setAttribute("data-modal-content", "");
|
|
111
|
+
this._modalContent = content;
|
|
112
|
+
contentNodes.forEach((node) => {
|
|
113
|
+
content.appendChild(node);
|
|
114
|
+
});
|
|
115
|
+
dialog.appendChild(content);
|
|
116
|
+
this._focusTrap1 = createFocusTrap();
|
|
117
|
+
this._focusTrap2 = createFocusTrap();
|
|
118
|
+
overlay.appendChild(dialog);
|
|
119
|
+
scroll.appendChild(this._focusTrap1);
|
|
120
|
+
scroll.appendChild(overlay);
|
|
121
|
+
scroll.appendChild(this._focusTrap2);
|
|
122
|
+
this.appendChild(scroll);
|
|
123
|
+
}
|
|
124
|
+
// ============================
|
|
125
|
+
// Lifecycle: watch attributes.
|
|
126
|
+
// ============================
|
|
127
|
+
static get observedAttributes() {
|
|
128
|
+
return [ACTIVE, ANIMATED, CLOSE, STATIC];
|
|
129
|
+
}
|
|
130
|
+
// ==============================
|
|
131
|
+
// Lifecycle: attributes changed.
|
|
132
|
+
// ==============================
|
|
133
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
134
|
+
if (oldValue !== newValue) {
|
|
135
|
+
if (name === ACTIVE) {
|
|
136
|
+
this._setActiveFlag();
|
|
137
|
+
}
|
|
138
|
+
if (name === ANIMATED) {
|
|
139
|
+
this._setAnimationFlag();
|
|
140
|
+
}
|
|
141
|
+
if (name === CLOSE) {
|
|
142
|
+
this._setCloseTitle();
|
|
143
|
+
}
|
|
144
|
+
if (name === STATIC) {
|
|
145
|
+
this._setStaticFlag();
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// ===========================
|
|
150
|
+
// Lifecycle: component mount.
|
|
151
|
+
// ===========================
|
|
152
|
+
connectedCallback() {
|
|
153
|
+
this._addEvents();
|
|
154
|
+
}
|
|
155
|
+
// =============================
|
|
156
|
+
// Lifecycle: component unmount.
|
|
157
|
+
// =============================
|
|
158
|
+
disconnectedCallback() {
|
|
159
|
+
this._removeEvents();
|
|
160
|
+
}
|
|
161
|
+
// ============================
|
|
162
|
+
// Helper: bind `this` context.
|
|
163
|
+
// ============================
|
|
164
|
+
_bind() {
|
|
165
|
+
const propertyNames = Object.getOwnPropertyNames(
|
|
166
|
+
Object.getPrototypeOf(this)
|
|
167
|
+
);
|
|
168
|
+
propertyNames.forEach((name) => {
|
|
169
|
+
if (typeof this[name] === "function") {
|
|
170
|
+
this[name] = this[name].bind(this);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
// ===================
|
|
175
|
+
// Helper: add events.
|
|
176
|
+
// ===================
|
|
177
|
+
_addEvents() {
|
|
178
|
+
this._removeEvents();
|
|
179
|
+
document.addEventListener(FOCUSIN, this._handleFocusIn);
|
|
180
|
+
document.addEventListener(KEYDOWN, this._handleKeyDown);
|
|
181
|
+
if (this._buttonClose) {
|
|
182
|
+
this._buttonClose.addEventListener("click", this._handleClickClose);
|
|
183
|
+
}
|
|
184
|
+
if (this._modalOverlay) {
|
|
185
|
+
this._modalOverlay.addEventListener("click", this._handleClickOverlay);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
// ======================
|
|
189
|
+
// Helper: remove events.
|
|
190
|
+
// ======================
|
|
191
|
+
_removeEvents() {
|
|
192
|
+
document.removeEventListener(FOCUSIN, this._handleFocusIn);
|
|
193
|
+
document.removeEventListener(KEYDOWN, this._handleKeyDown);
|
|
194
|
+
if (this._buttonClose) {
|
|
195
|
+
this._buttonClose.removeEventListener("click", this._handleClickClose);
|
|
196
|
+
}
|
|
197
|
+
if (this._modalOverlay) {
|
|
198
|
+
this._modalOverlay.removeEventListener("click", this._handleClickOverlay);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
// ===========================
|
|
202
|
+
// Helper: set animation flag.
|
|
203
|
+
// ===========================
|
|
204
|
+
_setAnimationFlag() {
|
|
205
|
+
this._isAnimated = this.getAttribute(ANIMATED) !== FALSE;
|
|
206
|
+
}
|
|
207
|
+
// ========================
|
|
208
|
+
// Helper: add close title.
|
|
209
|
+
// ========================
|
|
210
|
+
_setCloseTitle() {
|
|
211
|
+
const title = this.getAttribute(CLOSE) || CLOSE_TITLE;
|
|
212
|
+
if (this._buttonClose) {
|
|
213
|
+
this._buttonClose.title = title;
|
|
214
|
+
this._buttonClose.setAttribute(ARIA_LABEL, title);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
// ========================
|
|
218
|
+
// Helper: add modal label.
|
|
219
|
+
// ========================
|
|
220
|
+
_setModalLabel() {
|
|
221
|
+
let label = MODAL_LABEL_FALLBACK;
|
|
222
|
+
if (this._heading) {
|
|
223
|
+
label = this._heading.textContent || label;
|
|
224
|
+
label = label.trim().replace(SPACE_REGEX, SPACE);
|
|
225
|
+
}
|
|
226
|
+
if (this._modal) {
|
|
227
|
+
this._modal.setAttribute(ARIA_LABEL, label);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
// ========================
|
|
231
|
+
// Helper: set active flag.
|
|
232
|
+
// ========================
|
|
233
|
+
_setActiveFlag() {
|
|
234
|
+
const isActive = this.getAttribute(ACTIVE) === TRUE;
|
|
235
|
+
this._isActive = isActive;
|
|
236
|
+
this._toggleModalDisplay(() => {
|
|
237
|
+
if (this._isActive) {
|
|
238
|
+
this._focusModal();
|
|
239
|
+
}
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
// ========================
|
|
243
|
+
// Helper: set static flag.
|
|
244
|
+
// ========================
|
|
245
|
+
_setStaticFlag() {
|
|
246
|
+
this._isStatic = this.getAttribute(STATIC) === TRUE;
|
|
247
|
+
}
|
|
248
|
+
// ======================
|
|
249
|
+
// Helper: focus element.
|
|
250
|
+
// ======================
|
|
251
|
+
_focusElement(element) {
|
|
252
|
+
window.requestAnimationFrame(() => {
|
|
253
|
+
if (typeof element.focus === "function") {
|
|
254
|
+
element.focus();
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
}
|
|
258
|
+
// ====================
|
|
259
|
+
// Helper: focus modal.
|
|
260
|
+
// ====================
|
|
261
|
+
_focusModal() {
|
|
262
|
+
window.requestAnimationFrame(() => {
|
|
263
|
+
if (this._modal) {
|
|
264
|
+
this._modal.focus();
|
|
265
|
+
}
|
|
266
|
+
if (this._modalScroll) {
|
|
267
|
+
this._modalScroll.scrollTo(0, 0);
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
// =============================
|
|
272
|
+
// Helper: detect outside modal.
|
|
273
|
+
// =============================
|
|
274
|
+
_isOutsideModal(element) {
|
|
275
|
+
if (!this._isActive || !element || !this._modal) {
|
|
276
|
+
return false;
|
|
277
|
+
}
|
|
278
|
+
const hasElement = this.contains(element) || this._modal.contains(element);
|
|
279
|
+
const bool = !hasElement;
|
|
280
|
+
return bool;
|
|
281
|
+
}
|
|
282
|
+
// ===========================
|
|
283
|
+
// Helper: detect motion pref.
|
|
284
|
+
// ===========================
|
|
285
|
+
_isMotionOkay() {
|
|
286
|
+
const { matches } = window.matchMedia(PREFERS_REDUCED_MOTION);
|
|
287
|
+
return this._isAnimated && !matches;
|
|
288
|
+
}
|
|
289
|
+
// =====================
|
|
290
|
+
// Helper: toggle modal.
|
|
291
|
+
// =====================
|
|
292
|
+
_toggleModalDisplay(callback) {
|
|
293
|
+
if (!this._modalScroll) return;
|
|
294
|
+
this.setAttribute(ACTIVE, this._isActive);
|
|
295
|
+
const isModalVisible = this._modalScroll.getAttribute(DATA_VISIBLE) === TRUE;
|
|
296
|
+
const isMotionOkay = this._isMotionOkay();
|
|
297
|
+
const delay = isMotionOkay ? ANIMATION_DURATION : 0;
|
|
298
|
+
const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth;
|
|
299
|
+
const activeElement = document.activeElement;
|
|
300
|
+
if (this._isActive && activeElement) {
|
|
301
|
+
this._activeElement = activeElement;
|
|
302
|
+
}
|
|
303
|
+
if (this._isActive) {
|
|
304
|
+
this._modalScroll.setAttribute(DATA_VISIBLE, TRUE);
|
|
305
|
+
document.documentElement.style.overflow = HIDDEN;
|
|
306
|
+
if (scrollbarWidth) {
|
|
307
|
+
document.documentElement.style.paddingRight = `${scrollbarWidth}px`;
|
|
308
|
+
}
|
|
309
|
+
if (isMotionOkay) {
|
|
310
|
+
this._isHideShow = true;
|
|
311
|
+
this._modalScroll.setAttribute(DATA_SHOW, TRUE);
|
|
312
|
+
}
|
|
313
|
+
callback();
|
|
314
|
+
this._timerForShow = window.setTimeout(() => {
|
|
315
|
+
clearTimeout(this._timerForShow);
|
|
316
|
+
this._isHideShow = false;
|
|
317
|
+
this._modalScroll?.removeAttribute(DATA_SHOW);
|
|
318
|
+
}, delay);
|
|
319
|
+
} else if (isModalVisible) {
|
|
320
|
+
if (isMotionOkay) {
|
|
321
|
+
this._isHideShow = true;
|
|
322
|
+
this._modalScroll.setAttribute(DATA_HIDE, TRUE);
|
|
323
|
+
}
|
|
324
|
+
callback();
|
|
325
|
+
this._timerForHide = window.setTimeout(() => {
|
|
326
|
+
clearTimeout(this._timerForHide);
|
|
327
|
+
this._isHideShow = false;
|
|
328
|
+
this._modalScroll?.removeAttribute(DATA_HIDE);
|
|
329
|
+
this._modalScroll?.setAttribute(DATA_VISIBLE, FALSE);
|
|
330
|
+
document.documentElement.style.overflow = EMPTY_STRING;
|
|
331
|
+
document.documentElement.style.paddingRight = EMPTY_STRING;
|
|
332
|
+
}, delay);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
// =====================
|
|
336
|
+
// Event: overlay click.
|
|
337
|
+
// =====================
|
|
338
|
+
_handleClickOverlay(event) {
|
|
339
|
+
if (this._isHideShow || this._isStatic) return;
|
|
340
|
+
if (!this._closable) return;
|
|
341
|
+
const target = event.target;
|
|
342
|
+
if (target === this._modalOverlay) {
|
|
343
|
+
this.close();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
// ====================
|
|
347
|
+
// Event: close button click.
|
|
348
|
+
// ====================
|
|
349
|
+
_handleClickClose() {
|
|
350
|
+
this.close();
|
|
351
|
+
}
|
|
352
|
+
// =========================
|
|
353
|
+
// Event: focus in document.
|
|
354
|
+
// =========================
|
|
355
|
+
_handleFocusIn() {
|
|
356
|
+
if (!this._isActive || !this._modal) return;
|
|
357
|
+
const activeElement = document.activeElement;
|
|
358
|
+
const isFocusTrap1 = activeElement === this._focusTrap1;
|
|
359
|
+
const isFocusTrap2 = activeElement === this._focusTrap2;
|
|
360
|
+
const focusList = Array.from(
|
|
361
|
+
this._modal.querySelectorAll(FOCUSABLE_SELECTORS)
|
|
362
|
+
);
|
|
363
|
+
const focusItemFirst = focusList[0];
|
|
364
|
+
const focusItemLast = focusList[focusList.length - 1];
|
|
365
|
+
if (isFocusTrap1 && focusItemLast) {
|
|
366
|
+
this._focusElement(focusItemLast);
|
|
367
|
+
} else if (isFocusTrap2 && focusItemFirst) {
|
|
368
|
+
this._focusElement(focusItemFirst);
|
|
369
|
+
} else if (this._isOutsideModal(activeElement)) {
|
|
370
|
+
this._focusModal();
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
// =================
|
|
374
|
+
// Event: key press.
|
|
375
|
+
// =================
|
|
376
|
+
_handleKeyDown({ key }) {
|
|
377
|
+
if (!this._isActive) return;
|
|
378
|
+
key = key.toLowerCase();
|
|
379
|
+
if (key === ESCAPE && !this._isHideShow && !this._isStatic && this._closable) {
|
|
380
|
+
this.close();
|
|
381
|
+
}
|
|
382
|
+
if (key === TAB) {
|
|
383
|
+
this._handleFocusIn();
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
// =================
|
|
387
|
+
// Public: open modal.
|
|
388
|
+
// =================
|
|
389
|
+
open() {
|
|
390
|
+
this._isActive = true;
|
|
391
|
+
this._toggleModalDisplay(() => {
|
|
392
|
+
this._focusModal();
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
// =================
|
|
396
|
+
// Public: close modal.
|
|
397
|
+
// =================
|
|
398
|
+
close() {
|
|
399
|
+
this._isActive = false;
|
|
400
|
+
this._toggleModalDisplay(() => {
|
|
401
|
+
if (this._activeElement) {
|
|
402
|
+
this._focusElement(this._activeElement);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
console.log("Defining modal-window...");
|
|
408
|
+
define(ModalWindow.TAG, ModalWindow);
|
|
409
|
+
console.log("modal-window defined");
|
|
410
|
+
export {
|
|
411
|
+
ModalWindow
|
|
412
|
+
};
|
|
413
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/index.ts"],
|
|
4
|
+
"sourcesContent": ["import { define } from '@substrate-system/web-component'\n\n// for docuement.querySelector\ndeclare global {\n interface HTMLElementTagNameMap {\n 'modal-window':ModalWindow\n }\n}\n\n/**\n * Modal window web component.\n *\n * Opens/closes via the `active` attribute:\n * modal.setAttribute('active', 'true') // open\n * modal.setAttribute('active', 'false') // close\n * modal.removeAttribute('active') // close\n *\n * Or via methods:\n * modal.open()\n * modal.close()\n */\n\n// ==========\n// Constants.\n// ==========\n\nconst ACTIVE = 'active'\nconst ANIMATED = 'animated'\nconst ANIMATION_DURATION = 250\nconst ARIA_LABEL = 'aria-label'\nconst CLOSE = 'close'\nconst CLOSE_TITLE = 'Close'\nconst DATA_HIDE = 'data-modal-hide'\nconst DATA_SHOW = 'data-modal-show'\nconst DATA_VISIBLE = 'data-visible'\nconst EMPTY_STRING = ''\nconst ESCAPE = 'escape'\nconst FALSE = 'false'\nconst FOCUSIN = 'focusin'\nconst HIDDEN = 'hidden'\nconst KEYDOWN = 'keydown'\nconst MODAL_LABEL_FALLBACK = 'modal'\nconst PREFERS_REDUCED_MOTION = '(prefers-reduced-motion: reduce)'\nconst SPACE = ' '\nconst SPACE_REGEX = /\\s+/g\nconst STATIC = 'static'\nconst TAB = 'tab'\nconst TRUE = 'true'\n\nconst FOCUSABLE_SELECTORS = [\n '[contenteditable]',\n '[tabindex=\"0\"]:not([disabled])',\n 'a[href]',\n 'audio[controls]',\n 'button:not([disabled])',\n 'iframe',\n \"input:not([disabled]):not([type='hidden'])\",\n 'select:not([disabled])',\n 'summary',\n 'textarea:not([disabled])',\n 'video[controls]',\n].join(',')\n\n// ====================\n// The component\n// ====================\n\nexport class ModalWindow extends HTMLElement {\n // Element references (set during build).\n _buttonClose:HTMLButtonElement|null = null\n _modal:HTMLDivElement|null = null\n _modalOverlay:HTMLDivElement|null = null\n _modalScroll:HTMLDivElement|null = null\n _modalContent:HTMLDivElement|null = null\n _focusTrap1:HTMLSpanElement|null = null\n _focusTrap2:HTMLSpanElement|null = null\n _heading:HTMLElement|null = null\n\n static TAG:string = 'modal-window'\n\n // State.\n _activeElement:HTMLElement|null = null\n _isActive = false\n _isAnimated = true\n _isHideShow = false\n _isStatic = false\n _timerForHide:number|undefined\n _timerForShow:number|undefined\n _closable:boolean = true\n\n // =======================\n // Lifecycle: constructor.\n // =======================\n\n constructor () {\n super()\n\n // Bind context.\n this._bind()\n\n this._closable = this.getAttribute('closable') !== 'false'\n\n // Get heading for aria-label.\n this._heading = this.querySelector('h1, h2, h3, h4, h5, h6')\n\n // Collect all child nodes.\n const contentNodes = Array.from(this.childNodes)\n\n // Build the modal structure.\n this._buildModal(contentNodes)\n\n // Set animation flag.\n this._setAnimationFlag()\n\n // Set close title.\n this._setCloseTitle()\n\n // Set modal label.\n this._setModalLabel()\n\n // Set static flag.\n this._setStaticFlag()\n\n // Set active flag.\n this._setActiveFlag()\n }\n\n // ============================\n // Helper: build modal structure.\n // ============================\n\n _buildModal (contentNodes: Node[]) {\n // Create focus trap\n const createFocusTrap = () => {\n const trap = document.createElement('span')\n trap.setAttribute('aria-hidden', 'true')\n trap.setAttribute('data-modal-focus-trap', '')\n trap.tabIndex = 0\n return trap\n }\n\n // Create scroll container\n const scroll = document.createElement('div')\n scroll.setAttribute('data-modal-scroll', '')\n this._modalScroll = scroll\n\n // Create overlay\n const overlay = document.createElement('div')\n overlay.setAttribute('data-modal-overlay', '')\n this._modalOverlay = overlay\n\n // Create dialog\n const dialog = document.createElement('div')\n dialog.setAttribute('aria-modal', 'true')\n dialog.setAttribute('data-modal-dialog', '')\n dialog.setAttribute('role', 'dialog')\n dialog.tabIndex = -1\n this._modal = dialog\n\n // Create close button if closable\n if (this._closable) {\n const closeBtn = document.createElement('button')\n closeBtn.setAttribute('data-modal-close', '')\n closeBtn.type = 'button'\n closeBtn.innerHTML = '×'\n dialog.appendChild(closeBtn)\n this._buttonClose = closeBtn\n }\n\n // Create content wrapper\n const content = document.createElement('div')\n content.setAttribute('data-modal-content', '')\n this._modalContent = content\n\n // Move content nodes into the content wrapper\n contentNodes.forEach(node => {\n content.appendChild(node)\n })\n\n dialog.appendChild(content)\n\n // Create focus traps\n this._focusTrap1 = createFocusTrap()\n this._focusTrap2 = createFocusTrap()\n\n // Assemble structure\n overlay.appendChild(dialog)\n scroll.appendChild(this._focusTrap1)\n scroll.appendChild(overlay)\n scroll.appendChild(this._focusTrap2)\n\n // Add to component\n this.appendChild(scroll)\n }\n\n // ============================\n // Lifecycle: watch attributes.\n // ============================\n\n static get observedAttributes () {\n return [ACTIVE, ANIMATED, CLOSE, STATIC]\n }\n\n // ==============================\n // Lifecycle: attributes changed.\n // ==============================\n\n attributeChangedCallback (name: string, oldValue: string, newValue: string) {\n // Different old/new values?\n if (oldValue !== newValue) {\n // Changed [active=\"\u2026\"] value?\n if (name === ACTIVE) {\n this._setActiveFlag()\n }\n\n // Changed [animated=\"\u2026\"] value?\n if (name === ANIMATED) {\n this._setAnimationFlag()\n }\n\n // Changed [close=\"\u2026\"] value?\n if (name === CLOSE) {\n this._setCloseTitle()\n }\n\n // Changed [static=\"\u2026\"] value?\n if (name === STATIC) {\n this._setStaticFlag()\n }\n }\n }\n\n // ===========================\n // Lifecycle: component mount.\n // ===========================\n\n connectedCallback () {\n this._addEvents()\n }\n\n // =============================\n // Lifecycle: component unmount.\n // =============================\n\n disconnectedCallback () {\n this._removeEvents()\n }\n\n // ============================\n // Helper: bind `this` context.\n // ============================\n\n _bind () {\n const propertyNames = Object.getOwnPropertyNames(\n Object.getPrototypeOf(this)\n ) as (keyof ModalWindow)[]\n\n propertyNames.forEach((name) => {\n // Bind functions.\n if (typeof this[name] === 'function') {\n // @ts-expect-error bind\n this[name] = this[name].bind(this)\n }\n })\n }\n\n // ===================\n // Helper: add events.\n // ===================\n\n _addEvents () {\n // Prevent doubles.\n this._removeEvents()\n\n document.addEventListener(FOCUSIN, this._handleFocusIn)\n document.addEventListener(KEYDOWN, this._handleKeyDown)\n\n if (this._buttonClose) {\n this._buttonClose.addEventListener('click', this._handleClickClose)\n }\n if (this._modalOverlay) {\n this._modalOverlay.addEventListener('click', this._handleClickOverlay)\n }\n }\n\n // ======================\n // Helper: remove events.\n // ======================\n\n _removeEvents () {\n document.removeEventListener(FOCUSIN, this._handleFocusIn)\n document.removeEventListener(KEYDOWN, this._handleKeyDown)\n\n if (this._buttonClose) {\n this._buttonClose.removeEventListener('click', this._handleClickClose)\n }\n if (this._modalOverlay) {\n this._modalOverlay.removeEventListener('click', this._handleClickOverlay)\n }\n }\n\n // ===========================\n // Helper: set animation flag.\n // ===========================\n\n _setAnimationFlag () {\n this._isAnimated = this.getAttribute(ANIMATED) !== FALSE\n }\n\n // ========================\n // Helper: add close title.\n // ========================\n\n _setCloseTitle () {\n // Get title.\n const title = this.getAttribute(CLOSE) || CLOSE_TITLE\n\n // Set title.\n if (this._buttonClose) {\n this._buttonClose.title = title\n this._buttonClose.setAttribute(ARIA_LABEL, title)\n }\n }\n\n // ========================\n // Helper: add modal label.\n // ========================\n\n _setModalLabel () {\n // Set later.\n let label = MODAL_LABEL_FALLBACK\n\n // Heading exists?\n if (this._heading) {\n // Get text.\n label = this._heading.textContent || label\n label = label.trim().replace(SPACE_REGEX, SPACE)\n }\n\n // Set label.\n if (this._modal) {\n this._modal.setAttribute(ARIA_LABEL, label)\n }\n }\n\n // ========================\n // Helper: set active flag.\n // ========================\n\n _setActiveFlag () {\n // Get flag.\n const isActive = this.getAttribute(ACTIVE) === TRUE\n\n // Set flag.\n this._isActive = isActive\n\n // Set display.\n this._toggleModalDisplay(() => {\n // Focus modal?\n if (this._isActive) {\n this._focusModal()\n }\n })\n }\n\n // ========================\n // Helper: set static flag.\n // ========================\n\n _setStaticFlag () {\n this._isStatic = this.getAttribute(STATIC) === TRUE\n }\n\n // ======================\n // Helper: focus element.\n // ======================\n\n _focusElement (element: HTMLElement) {\n window.requestAnimationFrame(() => {\n if (typeof element.focus === 'function') {\n element.focus()\n }\n })\n }\n\n // ====================\n // Helper: focus modal.\n // ====================\n\n _focusModal () {\n window.requestAnimationFrame(() => {\n if (this._modal) {\n this._modal.focus()\n }\n if (this._modalScroll) {\n this._modalScroll.scrollTo(0, 0)\n }\n })\n }\n\n // =============================\n // Helper: detect outside modal.\n // =============================\n\n _isOutsideModal (element?: HTMLElement) {\n // Early exit.\n if (!this._isActive || !element || !this._modal) {\n return false\n }\n\n // Has element?\n const hasElement = this.contains(element) || this._modal.contains(element)\n\n // Get boolean.\n const bool = !hasElement\n\n // Expose boolean.\n return bool\n }\n\n // ===========================\n // Helper: detect motion pref.\n // ===========================\n\n _isMotionOkay () {\n // Get pref.\n const { matches } = window.matchMedia(PREFERS_REDUCED_MOTION)\n\n // Expose boolean.\n return this._isAnimated && !matches\n }\n\n // =====================\n // Helper: toggle modal.\n // =====================\n\n _toggleModalDisplay (callback: () => void) {\n if (!this._modalScroll) return\n\n // @ts-expect-error boolean\n this.setAttribute(ACTIVE, this._isActive)\n\n // Get booleans.\n const isModalVisible = this._modalScroll.getAttribute(DATA_VISIBLE) === TRUE\n const isMotionOkay = this._isMotionOkay()\n\n // Get delay.\n const delay = isMotionOkay ? ANIMATION_DURATION : 0\n\n // Get scrollbar width.\n const scrollbarWidth = window.innerWidth - document.documentElement.clientWidth\n\n // Get active element.\n const activeElement = document.activeElement as HTMLElement\n\n // Cache active element?\n if (this._isActive && activeElement) {\n this._activeElement = activeElement\n }\n\n // =============\n // Modal active?\n // =============\n\n if (this._isActive) {\n // Show modal.\n this._modalScroll.setAttribute(DATA_VISIBLE, TRUE)\n\n // Hide scrollbar.\n document.documentElement.style.overflow = HIDDEN\n\n // Add placeholder?\n if (scrollbarWidth) {\n document.documentElement.style.paddingRight = `${scrollbarWidth}px`\n }\n\n // Set flag.\n if (isMotionOkay) {\n this._isHideShow = true\n this._modalScroll.setAttribute(DATA_SHOW, TRUE)\n }\n\n // Fire callback.\n callback()\n\n // Await CSS animation.\n this._timerForShow = window.setTimeout(() => {\n // Clear.\n clearTimeout(this._timerForShow)\n\n // Remove flag.\n this._isHideShow = false\n this._modalScroll?.removeAttribute(DATA_SHOW)\n }, delay)\n } else if (isModalVisible) {\n // Set flag.\n if (isMotionOkay) {\n this._isHideShow = true\n this._modalScroll.setAttribute(DATA_HIDE, TRUE)\n }\n\n // Fire callback?\n callback()\n\n // Await CSS animation.\n this._timerForHide = window.setTimeout(() => {\n // Clear.\n clearTimeout(this._timerForHide)\n\n // Remove flag.\n this._isHideShow = false\n this._modalScroll?.removeAttribute(DATA_HIDE)\n\n // Hide modal.\n this._modalScroll?.setAttribute(DATA_VISIBLE, FALSE)\n\n // Show scrollbar.\n document.documentElement.style.overflow = EMPTY_STRING\n\n // Remove placeholder.\n document.documentElement.style.paddingRight = EMPTY_STRING\n\n // Delay.\n }, delay)\n }\n }\n\n // =====================\n // Event: overlay click.\n // =====================\n\n _handleClickOverlay (event: MouseEvent) {\n if (this._isHideShow || this._isStatic) return\n if (!this._closable) return\n\n // Get layer.\n const target = event.target as HTMLElement\n\n // Outside modal? (clicked directly on overlay, not dialog)\n if (target === this._modalOverlay) {\n this.close()\n }\n }\n\n // ====================\n // Event: close button click.\n // ====================\n\n _handleClickClose () {\n this.close()\n }\n\n // =========================\n // Event: focus in document.\n // =========================\n\n _handleFocusIn () {\n if (!this._isActive || !this._modal) return\n\n const activeElement = document.activeElement as HTMLElement\n\n // Get booleans.\n const isFocusTrap1 = activeElement === this._focusTrap1\n const isFocusTrap2 = activeElement === this._focusTrap2\n\n // Get focusable elements in modal.\n const focusList = Array.from(\n this._modal.querySelectorAll(FOCUSABLE_SELECTORS)\n ) as HTMLElement[]\n\n // Get first & last items.\n const focusItemFirst = focusList[0]\n const focusItemLast = focusList[focusList.length - 1]\n\n // Focus trap: above?\n if (isFocusTrap1 && focusItemLast) {\n this._focusElement(focusItemLast)\n\n // Focus trap: below?\n } else if (isFocusTrap2 && focusItemFirst) {\n this._focusElement(focusItemFirst)\n\n // Outside modal?\n } else if (this._isOutsideModal(activeElement)) {\n this._focusModal()\n }\n }\n\n // =================\n // Event: key press.\n // =================\n\n _handleKeyDown ({ key }:KeyboardEvent) {\n if (!this._isActive) return\n\n key = key.toLowerCase()\n\n // Escape key?\n if (\n key === ESCAPE &&\n !this._isHideShow &&\n !this._isStatic &&\n this._closable\n ) {\n this.close()\n }\n\n // Tab key?\n if (key === TAB) {\n this._handleFocusIn()\n }\n }\n\n // =================\n // Public: open modal.\n // =================\n\n open () {\n this._isActive = true\n this._toggleModalDisplay(() => {\n this._focusModal()\n })\n }\n\n // =================\n // Public: close modal.\n // =================\n\n close () {\n this._isActive = false\n this._toggleModalDisplay(() => {\n if (this._activeElement) {\n this._focusElement(this._activeElement)\n }\n })\n }\n}\n\nconsole.log('Defining modal-window...')\ndefine(ModalWindow.TAG, ModalWindow)\nconsole.log('modal-window defined')\n"],
|
|
5
|
+
"mappings": ";;AAAA,SAAS,cAAc;AA0BvB,MAAM,SAAS;AACf,MAAM,WAAW;AACjB,MAAM,qBAAqB;AAC3B,MAAM,aAAa;AACnB,MAAM,QAAQ;AACd,MAAM,cAAc;AACpB,MAAM,YAAY;AAClB,MAAM,YAAY;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A,eAAgB,EAAE,IAAI,GAAiB;AACnC,QAAI,CAAC,KAAK,UAAW;AAErB,UAAM,IAAI,YAAY;AAGtB,QACI,QAAQ,UACR,CAAC,KAAK,eACN,CAAC,KAAK,aACN,KAAK,WACP;AACE,WAAK,MAAM;AAAA,IACf;AAGA,QAAI,QAAQ,KAAK;AACb,WAAK,eAAe;AAAA,IACxB;AAAA,EACJ;AAAA;AAAA;AAAA;AAAA,EAMA,OAAQ;AACJ,SAAK,YAAY;AACjB,SAAK,oBAAoB,MAAM;AAC3B,WAAK,YAAY;AAAA,IACrB,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAMA,QAAS;AACL,SAAK,YAAY;AACjB,SAAK,oBAAoB,MAAM;AAC3B,UAAI,KAAK,gBAAgB;AACrB,aAAK,cAAc,KAAK,cAAc;AAAA,MAC1C;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAEA,QAAQ,IAAI,0BAA0B;AACtC,OAAO,YAAY,KAAK,WAAW;AACnC,QAAQ,IAAI,sBAAsB;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@media (prefers-reduced-motion:reduce){*,:after,:before{transition:none!important;animation:none!important}}@keyframes SHOW-OVERLAY{0%{opacity:0}to{opacity:1}}@keyframes SHOW-DIALOG{0%{transform:scale(.95)}to{transform:scale(1)}}@keyframes HIDE-OVERLAY{0%{opacity:1}to{opacity:0}}@keyframes HIDE-DIALOG{0%{transform:scale(1)}to{transform:scale(.95)}}[data-modal-focus-trap]{opacity:0;width:0;height:0;position:fixed;top:0;left:0;overflow:hidden}[data-modal-scroll]{width:100%;height:100%;z-index:var(--modal-overlay-z-index,100000);display:none;position:fixed;top:0;left:0;overflow:hidden auto}[data-modal-scroll][data-visible=true]{display:block}[data-modal-overlay]{background-color:var(--modal-overlay-background-color,#00000080);padding-top:var(--modal-overlay-padding-top,20px);padding-left:var(--modal-overlay-padding-left,20px);padding-right:var(--modal-overlay-padding-right,20px);padding-bottom:var(--modal-overlay-padding-bottom,20px);justify-content:center;align-items:center;width:100%;min-height:100%;display:flex}[data-modal-dialog]{background-color:var(--modal-dialog-background-color,#fff);border-radius:var(--modal-dialog-border-radius,5px);box-shadow:var(--modal-dialog-box-shadow,0 2px 5px 0 #00000080);padding-top:var(--modal-dialog-padding-top,20px);padding-left:var(--modal-dialog-padding-left,20px);padding-right:var(--modal-dialog-padding-right,20px);padding-bottom:var(--modal-dialog-padding-bottom,20px);width:var(--modal-dialog-width,500px);max-width:100%;position:relative}[data-modal-show=true] [data-modal-overlay]{animation-name:SHOW-OVERLAY;animation-duration:.25s}[data-modal-show=true] [data-modal-dialog]{animation-name:SHOW-DIALOG;animation-duration:.25s}[data-modal-hide=true] [data-modal-overlay]{opacity:0;animation-name:HIDE-OVERLAY;animation-duration:.25s}[data-modal-hide=true] [data-modal-dialog]{animation-name:HIDE-DIALOG;animation-duration:.25s;transform:scale(.95)}[data-modal-close]{appearance:none;touch-action:none;user-select:none;color:var(--modal-close-color,#fff);background-color:var(--modal-close-background-color,#000);border-radius:var(--modal-close-border-radius,50%);box-shadow:var(--modal-close-box-shadow,0 0 0 1px #fff);display:var(--modal-close-display,block);cursor:pointer;font-family:var(--modal-close-font-family,"Arial",sans-serif);font-size:var(--modal-close-font-size,23px);text-align:center;line-height:var(--modal-close-line-height,26px);width:var(--modal-close-width,26px);border:0;padding:0;position:absolute;top:0;right:0;transform:translate(40%,-40%)}[data-modal-close]:hover{color:var(--modal-close-color-hover,#000);background-color:var(--modal-close-background-color-hover,#fff);box-shadow:var(--modal-close-box-shadow-hover,0 0 0 1px #000)}@supports selector(:focus-visible){[data-modal-close]:focus-visible{color:var(--modal-close-color-hover,#000);background-color:var(--modal-close-background-color-hover,#fff);box-shadow:var(--modal-close-box-shadow-hover,0 0 0 1px #000)}}@supports not selector(:focus-visible){[data-modal-close]:focus{color:var(--modal-close-color-hover,#000);background-color:var(--modal-close-background-color-hover,#fff);box-shadow:var(--modal-close-box-shadow-hover,0 0 0 1px #000)}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var H=Object.defineProperty;var r=(n,t)=>H(n,"name",{value:t,configurable:!0});var O=Object.defineProperty,c=r((n,t)=>O(n,"name",{value:t,configurable:!0}),"__name"),v=class n extends HTMLElement{static{r(this,"WebComponent")}static{c(this,"WebComponent")}static TAG="";TAG="";_globalWildcardListeners=new Set;_namespacedWildcardListeners=new Set;static create(t){let e=class extends n{static{r(this,"CreatedClass")}static{c(this,"CreatedClass")}static TAG=t;TAG=t;render(){throw new Error("`render`should be implemented by children")}};return e.define=function(){return n.define.call(this)},e.event=function(i){return n.event.call(this,i)},e}static define(){h(this.TAG,this)}async attributeChangedCallback(t,e,i){let s=this[`handleChange_${t}`];s&&await s.call(this,e,i)}addEventListener(t,e,i){t===n.event.call(this,"*")?this._namespacedWildcardListeners.add({listener:e,options:i}):t==="*"?e&&this._globalWildcardListeners.add({listener:e,options:i}):super.addEventListener(t,e,i)}_notifyNamespacedWildcardListeners(t){if(this._namespacedWildcardListeners.size===0)return;let e=this.TAG;!e||!t.type.startsWith(`${e}:`)||this._namespacedWildcardListeners.forEach(({listener:i})=>{try{typeof i=="function"?i.call(this,t):i&&typeof i.handleEvent=="function"&&i.handleEvent(t)}catch(s){console.error("Error in namespaced wildcard event listener:",s)}})}_notifyGlobalWildcardListeners(t){this._globalWildcardListeners.size!==0&&this._globalWildcardListeners.forEach(({listener:e})=>{try{typeof e=="function"?e.call(this,t):e&&typeof e.handleEvent=="function"&&e.handleEvent(t)}catch(i){console.error("Error in global wildcard event listener:",i)}})}connectedCallback(){this.render()}qs(t){return this.querySelector(t)}qsa(t){return this.querySelectorAll(t)}static event(t){return A(this.TAG,t)}emit(t,e={}){if(t==="*")throw new Error('Do not emit the literal "*"');let{bubbles:i=!0,cancelable:s=!0,detail:o}=e,a=`${this.TAG}:${t}`,l=new CustomEvent(a,{bubbles:i,cancelable:s,detail:o}),M=this.dispatchEvent(l);return this._notifyNamespacedWildcardListeners(l),M}dispatchEvent(t){let e=super.dispatchEvent(t);return this._notifyGlobalWildcardListeners(t),e}dispatch(t,e={}){let i=new CustomEvent(t,{bubbles:e.bubbles===void 0?!0:e.bubbles,cancelable:e.cancelable===void 0?!0:e.cancelable,detail:e.detail});return this.dispatchEvent(i)}removeEventListener(t,e,i){if(t===n.event.call(this,"*")){if(e&&this._namespacedWildcardListeners){for(let s of this._namespacedWildcardListeners)if(s.listener===e){this._namespacedWildcardListeners.delete(s);break}}}else if(t==="*"){if(e&&this._globalWildcardListeners){for(let s of this._globalWildcardListeners)if(s.listener===e){this._globalWildcardListeners.delete(s);break}}}else super.removeEventListener(t,e,i)}};function A(n,t){return`${n}:${t}`}r(A,"eventName");c(A,"eventName");function p(n){return document.createElement(n).constructor!==HTMLElement}r(p,"isRegistered");c(p,"isRegistered");function h(n,t){window&&"customElements"in window&&(p(n)||customElements.define(n,t))}r(h,"define");c(h,"define");var u="active",_="animated",F=250,L="aria-label",f="close",D="Close",T="data-modal-hide",g="data-modal-show",b="data-visible",w="",W="escape",C="false",y="focusin",I="hidden",S="keydown",N="modal",k="(prefers-reduced-motion:reduce)",G=" ",R=/\s+/g,E="static",x="tab",d="true",P=["[contenteditable]",'[tabindex="0"]:not([disabled])',"a[href]","audio[controls]","button:not([disabled])","iframe","input:not([disabled]):not([type=hidden])","select:not([disabled])","summary","textarea:not([disabled])","video[controls]"].join(","),m=class extends HTMLElement{static{r(this,"ModalWindow")}_buttonClose=null;_modal=null;_modalOverlay=null;_modalScroll=null;_modalContent=null;_focusTrap1=null;_focusTrap2=null;_heading=null;static TAG="modal-window";_activeElement=null;_isActive=!1;_isAnimated=!0;_isHideShow=!1;_isStatic=!1;_timerForHide;_timerForShow;_closable=!0;constructor(){super(),this._bind(),this._closable=this.getAttribute("closable")!=="false",this._heading=this.querySelector("h1,h2,h3,h4,h5,h6");let t=Array.from(this.childNodes);this._buildModal(t),this._setAnimationFlag(),this._setCloseTitle(),this._setModalLabel(),this._setStaticFlag(),this._setActiveFlag()}_buildModal(t){let e=r(()=>{let l=document.createElement("span");return l.setAttribute("aria-hidden","true"),l.setAttribute("data-modal-focus-trap",""),l.tabIndex=0,l},"createFocusTrap"),i=document.createElement("div");i.setAttribute("data-modal-scroll",""),this._modalScroll=i;let s=document.createElement("div");s.setAttribute("data-modal-overlay",""),this._modalOverlay=s;let o=document.createElement("div");if(o.setAttribute("aria-modal","true"),o.setAttribute("data-modal-dialog",""),o.setAttribute("role","dialog"),o.tabIndex=-1,this._modal=o,this._closable){let l=document.createElement("button");l.setAttribute("data-modal-close",""),l.type="button",l.innerHTML="×",o.appendChild(l),this._buttonClose=l}let a=document.createElement("div");a.setAttribute("data-modal-content",""),this._modalContent=a,t.forEach(l=>{a.appendChild(l)}),o.appendChild(a),this._focusTrap1=e(),this._focusTrap2=e(),s.appendChild(o),i.appendChild(this._focusTrap1),i.appendChild(s),i.appendChild(this._focusTrap2),this.appendChild(i)}static get observedAttributes(){return[u,_,f,E]}attributeChangedCallback(t,e,i){e!==i&&(t===u&&this._setActiveFlag(),t===_&&this._setAnimationFlag(),t===f&&this._setCloseTitle(),t===E&&this._setStaticFlag())}connectedCallback(){this._addEvents()}disconnectedCallback(){this._removeEvents()}_bind(){Object.getOwnPropertyNames(Object.getPrototypeOf(this)).forEach(e=>{typeof this[e]=="function"&&(this[e]=this[e].bind(this))})}_addEvents(){this._removeEvents(),document.addEventListener(y,this._handleFocusIn),document.addEventListener(S,this._handleKeyDown),this._buttonClose&&this._buttonClose.addEventListener("click",this._handleClickClose),this._modalOverlay&&this._modalOverlay.addEventListener("click",this._handleClickOverlay)}_removeEvents(){document.removeEventListener(y,this._handleFocusIn),document.removeEventListener(S,this._handleKeyDown),this._buttonClose&&this._buttonClose.removeEventListener("click",this._handleClickClose),this._modalOverlay&&this._modalOverlay.removeEventListener("click",this._handleClickOverlay)}_setAnimationFlag(){this._isAnimated=this.getAttribute(_)!==C}_setCloseTitle(){let t=this.getAttribute(f)||D;this._buttonClose&&(this._buttonClose.title=t,this._buttonClose.setAttribute(L,t))}_setModalLabel(){let t=N;this._heading&&(t=this._heading.textContent||t,t=t.trim().replace(R,G)),this._modal&&this._modal.setAttribute(L,t)}_setActiveFlag(){let t=this.getAttribute(u)===d;this._isActive=t,this._toggleModalDisplay(()=>{this._isActive&&this._focusModal()})}_setStaticFlag(){this._isStatic=this.getAttribute(E)===d}_focusElement(t){requestAnimationFrame(()=>{typeof t.focus=="function"&&t.focus()})}_focusModal(){requestAnimationFrame(()=>{this._modal&&this._modal.focus(),this._modalScroll&&this._modalScroll.scrollTo(0,0)})}_isOutsideModal(t){return!this._isActive||!t||!this._modal?!1:!(this.contains(t)||this._modal.contains(t))}_isMotionOkay(){let{matches:t}=matchMedia(k);return this._isAnimated&&!t}_toggleModalDisplay(t){if(!this._modalScroll)return;this.setAttribute(u,this._isActive);let e=this._modalScroll.getAttribute(b)===d,i=this._isMotionOkay(),s=i?F:0,o=innerWidth-document.documentElement.clientWidth,a=document.activeElement;this._isActive&&a&&(this._activeElement=a),this._isActive?(this._modalScroll.setAttribute(b,d),document.documentElement.style.overflow=I,o&&(document.documentElement.style.paddingRight=`${o}px`),i&&(this._isHideShow=!0,this._modalScroll.setAttribute(g,d)),t(),this._timerForShow=setTimeout(()=>{clearTimeout(this._timerForShow),this._isHideShow=!1,this._modalScroll?.removeAttribute(g)},s)):e&&(i&&(this._isHideShow=!0,this._modalScroll.setAttribute(T,d)),t(),this._timerForHide=setTimeout(()=>{clearTimeout(this._timerForHide),this._isHideShow=!1,this._modalScroll?.removeAttribute(T),this._modalScroll?.setAttribute(b,C),document.documentElement.style.overflow=w,document.documentElement.style.paddingRight=w},s))}_handleClickOverlay(t){if(this._isHideShow||this._isStatic||!this._closable)return;t.target===this._modalOverlay&&this.close()}_handleClickClose(){this.close()}_handleFocusIn(){if(!this._isActive||!this._modal)return;let t=document.activeElement,e=t===this._focusTrap1,i=t===this._focusTrap2,s=Array.from(this._modal.querySelectorAll(P)),o=s[0],a=s[s.length-1];e&&a?this._focusElement(a):i&&o?this._focusElement(o):this._isOutsideModal(t)&&this._focusModal()}_handleKeyDown({key:t}){this._isActive&&(t=t.toLowerCase(),t===W&&!this._isHideShow&&!this._isStatic&&this._closable&&this.close(),t===x&&this._handleFocusIn())}open(){this._isActive=!0,this._toggleModalDisplay(()=>{this._focusModal()})}close(){this._isActive=!1,this._toggleModalDisplay(()=>{this._activeElement&&this._focusElement(this._activeElement)})}};console.log("Defining modal-..");h(m.TAG,m);console.log("modal-window defined");export{m as ModalWindow};
|
package/dist/meta.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"inputs": {
|
|
3
|
+
"src/index.ts": {
|
|
4
|
+
"bytes": 17109,
|
|
5
|
+
"imports": [],
|
|
6
|
+
"format": "esm"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"outputs": {
|
|
10
|
+
"dist/index.js.map": {
|
|
11
|
+
"imports": [],
|
|
12
|
+
"exports": [],
|
|
13
|
+
"inputs": {},
|
|
14
|
+
"bytes": 24829
|
|
15
|
+
},
|
|
16
|
+
"dist/index.js": {
|
|
17
|
+
"imports": [
|
|
18
|
+
{
|
|
19
|
+
"path": "@substrate-system/web-component",
|
|
20
|
+
"kind": "import-statement",
|
|
21
|
+
"external": true
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"exports": [
|
|
25
|
+
"ModalWindow"
|
|
26
|
+
],
|
|
27
|
+
"entryPoint": "src/index.ts",
|
|
28
|
+
"inputs": {
|
|
29
|
+
"src/index.ts": {
|
|
30
|
+
"bytesInOutput": 12398
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
"bytes": 12587
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|