@primer/behaviors 0.0.0-2022031145415 → 0.0.0-202218135849
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.
|
@@ -3,13 +3,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const focus_trap_js_1 = require("../focus-trap.js");
|
|
4
4
|
class ModalDialogElement extends HTMLElement {
|
|
5
5
|
constructor() {
|
|
6
|
-
var _a, _b;
|
|
6
|
+
var _a, _b, _c;
|
|
7
7
|
super();
|
|
8
|
-
(_a = this.querySelector('.
|
|
9
|
-
(_b = document.body.querySelector(`.js-dialog-show-${this.id}`)) === null || _b === void 0 ? void 0 : _b.addEventListener('click',
|
|
8
|
+
(_a = this.querySelector('.Overlay-closeButton')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => this.close());
|
|
9
|
+
(_b = document.body.querySelector(`.js-dialog-show-${this.id}`)) === null || _b === void 0 ? void 0 : _b.addEventListener('click', event => {
|
|
10
10
|
event.stopPropagation();
|
|
11
11
|
this.show();
|
|
12
12
|
});
|
|
13
|
+
if ((_c = this.parentElement) === null || _c === void 0 ? void 0 : _c.classList.contains('Overlay-backdrop')) {
|
|
14
|
+
this.overlayBackdrop = this.parentElement;
|
|
15
|
+
this.overlayBackdrop.classList.add('Overlay-hidden');
|
|
16
|
+
}
|
|
13
17
|
}
|
|
14
18
|
connectedCallback() {
|
|
15
19
|
if (!this.hasAttribute('role'))
|
|
@@ -33,27 +37,21 @@ class ModalDialogElement extends HTMLElement {
|
|
|
33
37
|
}
|
|
34
38
|
show() {
|
|
35
39
|
var _a;
|
|
36
|
-
const
|
|
37
|
-
if (
|
|
40
|
+
const isOpen = this.hasAttribute('open');
|
|
41
|
+
if (isOpen)
|
|
38
42
|
return;
|
|
39
|
-
this.classList.remove('hidden');
|
|
40
43
|
this.setAttribute('open', '');
|
|
41
|
-
|
|
42
|
-
this.parentElement.classList.add('active');
|
|
43
|
-
}
|
|
44
|
+
(_a = this.overlayBackdrop) === null || _a === void 0 ? void 0 : _a.classList.remove('Overlay-hidden');
|
|
44
45
|
document.body.style.overflow = 'hidden';
|
|
45
46
|
this.abortController = (0, focus_trap_js_1.focusTrap)(this);
|
|
46
47
|
}
|
|
47
48
|
close() {
|
|
48
49
|
var _a, _b;
|
|
49
|
-
const
|
|
50
|
-
if (
|
|
50
|
+
const isOpen = this.hasAttribute('open');
|
|
51
|
+
if (!isOpen)
|
|
51
52
|
return;
|
|
52
|
-
this.classList.add('hidden');
|
|
53
53
|
this.removeAttribute('open');
|
|
54
|
-
|
|
55
|
-
this.parentElement.classList.remove('active');
|
|
56
|
-
}
|
|
54
|
+
(_a = this.overlayBackdrop) === null || _a === void 0 ? void 0 : _a.classList.add('Overlay-hidden');
|
|
57
55
|
document.body.style.overflow = 'initial';
|
|
58
56
|
(_b = this.abortController) === null || _b === void 0 ? void 0 : _b.abort();
|
|
59
57
|
}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { focusTrap } from '../focus-trap.js';
|
|
2
2
|
class ModalDialogElement extends HTMLElement {
|
|
3
3
|
constructor() {
|
|
4
|
-
var _a, _b;
|
|
4
|
+
var _a, _b, _c;
|
|
5
5
|
super();
|
|
6
|
-
(_a = this.querySelector('.
|
|
7
|
-
(_b = document.body.querySelector(`.js-dialog-show-${this.id}`)) === null || _b === void 0 ? void 0 : _b.addEventListener('click',
|
|
6
|
+
(_a = this.querySelector('.Overlay-closeButton')) === null || _a === void 0 ? void 0 : _a.addEventListener('click', () => this.close());
|
|
7
|
+
(_b = document.body.querySelector(`.js-dialog-show-${this.id}`)) === null || _b === void 0 ? void 0 : _b.addEventListener('click', event => {
|
|
8
8
|
event.stopPropagation();
|
|
9
9
|
this.show();
|
|
10
10
|
});
|
|
11
|
+
if ((_c = this.parentElement) === null || _c === void 0 ? void 0 : _c.classList.contains('Overlay-backdrop')) {
|
|
12
|
+
this.overlayBackdrop = this.parentElement;
|
|
13
|
+
this.overlayBackdrop.classList.add('Overlay-hidden');
|
|
14
|
+
}
|
|
11
15
|
}
|
|
12
16
|
connectedCallback() {
|
|
13
17
|
if (!this.hasAttribute('role'))
|
|
@@ -31,27 +35,21 @@ class ModalDialogElement extends HTMLElement {
|
|
|
31
35
|
}
|
|
32
36
|
show() {
|
|
33
37
|
var _a;
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
38
|
+
const isOpen = this.hasAttribute('open');
|
|
39
|
+
if (isOpen)
|
|
36
40
|
return;
|
|
37
|
-
this.classList.remove('hidden');
|
|
38
41
|
this.setAttribute('open', '');
|
|
39
|
-
|
|
40
|
-
this.parentElement.classList.add('active');
|
|
41
|
-
}
|
|
42
|
+
(_a = this.overlayBackdrop) === null || _a === void 0 ? void 0 : _a.classList.remove('Overlay-hidden');
|
|
42
43
|
document.body.style.overflow = 'hidden';
|
|
43
44
|
this.abortController = focusTrap(this);
|
|
44
45
|
}
|
|
45
46
|
close() {
|
|
46
47
|
var _a, _b;
|
|
47
|
-
const
|
|
48
|
-
if (
|
|
48
|
+
const isOpen = this.hasAttribute('open');
|
|
49
|
+
if (!isOpen)
|
|
49
50
|
return;
|
|
50
|
-
this.classList.add('hidden');
|
|
51
51
|
this.removeAttribute('open');
|
|
52
|
-
|
|
53
|
-
this.parentElement.classList.remove('active');
|
|
54
|
-
}
|
|
52
|
+
(_a = this.overlayBackdrop) === null || _a === void 0 ? void 0 : _a.classList.add('Overlay-hidden');
|
|
55
53
|
document.body.style.overflow = 'initial';
|
|
56
54
|
(_b = this.abortController) === null || _b === void 0 ? void 0 : _b.abort();
|
|
57
55
|
}
|