@uoguelph/web-components 1.1.3 → 1.2.0-rc.1
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/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/{index-469a8261.js → index-06b58d35.js} +5 -5
- package/dist/cjs/{index-4e3091d0.js → index-cdb046b4.js} +134 -40
- package/dist/cjs/loader.cjs.js +5 -3
- package/dist/cjs/uofg-alert.cjs.entry.js +11 -10
- package/dist/cjs/uofg-back-to-top_5.cjs.entry.js +1374 -0
- package/dist/cjs/uofg-modal.cjs.entry.js +152 -142
- package/dist/cjs/uofg-web-components.cjs.js +6 -4
- package/dist/cjs/utils-3d4b7e2e.js +16 -0
- package/dist/collection/collection-manifest.json +2 -2
- package/dist/collection/components/uofg-alert/uofg-alert.css +1 -75
- package/dist/collection/components/uofg-alert/uofg-alert.js +15 -15
- package/dist/collection/components/uofg-back-to-top/uofg-back-to-top.css +1 -40
- package/dist/collection/components/uofg-back-to-top/uofg-back-to-top.js +66 -63
- package/dist/collection/components/uofg-card/uofg-card.css +1 -95
- package/dist/collection/components/uofg-card/uofg-card.js +42 -40
- package/dist/collection/components/uofg-footer/uofg-footer.css +1 -249
- package/dist/collection/components/uofg-footer/uofg-footer.js +132 -40
- package/dist/collection/components/uofg-header/uofg-header.css +1 -542
- package/dist/collection/components/uofg-header/uofg-header.js +238 -157
- package/dist/collection/components/uofg-menu/uofg-menu.js +414 -410
- package/dist/collection/components/uofg-modal/uofg-modal.css +1 -113
- package/dist/collection/components/uofg-modal/uofg-modal.js +393 -386
- package/dist/collection/utils/font-awesome-icon.js +4 -4
- package/dist/collection/utils/utils.js +5 -5
- package/dist/components/font-awesome-icon.js +4 -4
- package/dist/components/uofg-alert.d.ts +2 -2
- package/dist/components/uofg-alert.js +22 -21
- package/dist/components/uofg-back-to-top.d.ts +2 -2
- package/dist/components/uofg-back-to-top.js +38 -34
- package/dist/components/uofg-card.d.ts +2 -2
- package/dist/components/uofg-card.js +28 -25
- package/dist/components/uofg-footer.d.ts +2 -2
- package/dist/components/uofg-footer.js +243 -115
- package/dist/components/uofg-header.d.ts +2 -2
- package/dist/components/uofg-header.js +234 -143
- package/dist/components/uofg-menu.d.ts +2 -2
- package/dist/components/uofg-menu2.js +245 -239
- package/dist/components/uofg-modal.d.ts +2 -2
- package/dist/components/uofg-modal.js +176 -166
- package/dist/components/utils.js +4 -4
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/{index-f644a780.js → index-0b0002d2.js} +134 -40
- package/dist/esm/{index-26c6582e.js → index-e685921a.js} +5 -5
- package/dist/esm/loader.js +6 -4
- package/dist/esm/uofg-alert.entry.js +11 -10
- package/dist/esm/uofg-back-to-top_5.entry.js +1366 -0
- package/dist/esm/uofg-modal.entry.js +152 -142
- package/dist/esm/uofg-web-components.js +7 -5
- package/dist/esm/utils-379bb71a.js +12 -0
- package/dist/types/components/uofg-alert/uofg-alert.d.ts +1 -1
- package/dist/types/components/uofg-back-to-top/uofg-back-to-top.d.ts +8 -8
- package/dist/types/components/uofg-card/uofg-card.d.ts +5 -5
- package/dist/types/components/uofg-footer/uofg-footer.d.ts +6 -6
- package/dist/types/components/uofg-header/uofg-header.d.ts +30 -29
- package/dist/types/components/uofg-menu/uofg-menu.d.ts +65 -65
- package/dist/types/components/uofg-modal/uofg-modal.d.ts +70 -70
- package/dist/types/components.d.ts +1 -1
- package/dist/types/stencil-public-runtime.d.ts +8 -0
- package/dist/types/utils/font-awesome-icon.d.ts +1 -1
- package/dist/uofg-web-components/{p-afff1fb0.js → p-6fa0f8f6.js} +1 -1
- package/dist/uofg-web-components/p-7569d8f2.entry.js +1 -0
- package/dist/uofg-web-components/p-c0449c39.entry.js +1 -0
- package/dist/uofg-web-components/p-e1255160.js +1 -0
- package/dist/uofg-web-components/p-ee27db22.js +2 -0
- package/dist/uofg-web-components/p-fde6370b.entry.js +1 -0
- package/dist/uofg-web-components/uofg-web-components.css +1 -1
- package/dist/uofg-web-components/uofg-web-components.esm.js +1 -1
- package/package.json +10 -5
- package/dist/cjs/uofg-back-to-top_4.cjs.entry.js +0 -1139
- package/dist/cjs/uofg-card.cjs.entry.js +0 -21
- package/dist/cjs/utils-582c8cb9.js +0 -16
- package/dist/components/_commonjsHelpers.js +0 -15
- package/dist/esm/uofg-back-to-top_4.entry.js +0 -1132
- package/dist/esm/uofg-card.entry.js +0 -17
- package/dist/esm/utils-cfa32fa2.js +0 -12
- package/dist/uofg-web-components/p-579599fd.js +0 -2
- package/dist/uofg-web-components/p-5f29369c.entry.js +0 -1
- package/dist/uofg-web-components/p-b55cb256.entry.js +0 -1
- package/dist/uofg-web-components/p-b81838c7.entry.js +0 -1
- package/dist/uofg-web-components/p-f42ff310.entry.js +0 -1
- /package/dist/uofg-web-components/{p-826dc478.js → p-fec87f9d.js} +0 -0
|
@@ -7,404 +7,411 @@ import { getAllFocusableElements } from "../../utils/utils";
|
|
|
7
7
|
* @part dismiss-button - The button that closes the modal.
|
|
8
8
|
*/
|
|
9
9
|
export class UofgModal {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
connectedCallback() {
|
|
20
|
-
// Bind event handlers so that 'this' is always the component instance.
|
|
21
|
-
this.handleClick = this.handleClick.bind(this);
|
|
22
|
-
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
23
|
-
this.handleFocusOut = this.handleFocusOut.bind(this);
|
|
24
|
-
if (this.autoOpen) {
|
|
25
|
-
this.isOpen = true;
|
|
10
|
+
constructor() {
|
|
11
|
+
this.inertElements = [];
|
|
12
|
+
this.label = undefined;
|
|
13
|
+
this.alertDialog = false;
|
|
14
|
+
this.centered = false;
|
|
15
|
+
this.staticBackdrop = false;
|
|
16
|
+
this.autoOpen = false;
|
|
17
|
+
this.isOpen = false;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
handleClick(e) {
|
|
35
|
-
if (!this.staticBackdrop && e.target === e.currentTarget) {
|
|
36
|
-
this.isOpen = false;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
handleKeyUp(e) {
|
|
40
|
-
if (e.key === 'Escape') {
|
|
41
|
-
this.isOpen = false;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
handleFocusOut(e) {
|
|
45
|
-
var _a;
|
|
46
|
-
if (!this.isOpen)
|
|
47
|
-
return; // Don't do anything if the modal is closed.
|
|
48
|
-
const relatedTarget = e.relatedTarget;
|
|
49
|
-
// If the focus is moving outside of the modal
|
|
50
|
-
if (!this.container.contains(relatedTarget) && !this.el.contains(relatedTarget)) {
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
// If the focus is moving away from the dismiss button, focus the last focusable element in the modal.
|
|
53
|
-
if (e.target === this.dismissButton) {
|
|
54
|
-
const focusableElements = getAllFocusableElements(this.el);
|
|
55
|
-
(_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
// Otherwise, focus the dismiss button.
|
|
59
|
-
this.dismissButton.focus();
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
handleIsOpenChange(newValue) {
|
|
64
|
-
if (newValue === true) {
|
|
65
|
-
window.requestAnimationFrame(() => {
|
|
66
|
-
window.requestAnimationFrame(() => {
|
|
67
|
-
window.requestAnimationFrame(() => {
|
|
68
|
-
// Focus the container element when the modal is opened, so that the screen reader's will announce the modal when it opens.
|
|
69
|
-
this.container.focus();
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
// Mark outer elements as inert when the modal is open.
|
|
74
|
-
let current = this.el;
|
|
75
|
-
// We want to mark all elements outside of the modal as inert, so we need to traverse up the DOM tree until we reach the body element.
|
|
76
|
-
while (current !== null && current !== document.body) {
|
|
77
|
-
const parent = current.parentElement;
|
|
78
|
-
// If parent is null, then we may be inside a shadow root. If so, we get the host element and continue traversing up the DOM tree.
|
|
79
|
-
if (parent === null) {
|
|
80
|
-
const root = current.getRootNode();
|
|
81
|
-
if (root instanceof ShadowRoot) {
|
|
82
|
-
current = root.host;
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
// Bind event handlers so that 'this' is always the component instance.
|
|
21
|
+
this.handleClick = this.handleClick.bind(this);
|
|
22
|
+
this.handleKeyUp = this.handleKeyUp.bind(this);
|
|
23
|
+
this.handleFocusOut = this.handleFocusOut.bind(this);
|
|
24
|
+
if (this.autoOpen) {
|
|
25
|
+
this.isOpen = true;
|
|
85
26
|
}
|
|
86
|
-
if (parent !== null) {
|
|
87
|
-
for (const child of parent.children) {
|
|
88
|
-
if (child !== current && !child.inert) {
|
|
89
|
-
// Mark the element as inert and store it in an array so that we can remove the inert attribute when the modal closes.
|
|
90
|
-
child.inert = true;
|
|
91
|
-
this.inertElements.push(child);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
current = parent;
|
|
96
|
-
this.opened.emit();
|
|
97
|
-
}
|
|
98
27
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
// Clear the array of inert elements. This is important because we don't want to keep a reference to elements as they may be removed from the DOM and we could cause a memory leak.
|
|
105
|
-
this.inertElements = [];
|
|
106
|
-
this.closed.emit();
|
|
28
|
+
disconnectedCallback() {
|
|
29
|
+
// Just in case the modal is removed from the DOM before it is closed, make sure to remove the inert attribute from all elements that we marked as inert when the modal was opened.
|
|
30
|
+
for (const element of this.inertElements) {
|
|
31
|
+
element.removeAttribute('inert');
|
|
32
|
+
}
|
|
107
33
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
render() {
|
|
112
|
-
return (h("div", { id: "uofg-modal", class: { open: this.isOpen }, role: this.alertDialog ? 'alertdialog' : 'dialog', "aria-modal": this.isOpen ? 'true' : '', "aria-label": this.label, tabIndex: -1, onClick: this.handleClick, onKeyUp: this.handleKeyUp, onFocusout: this.handleFocusOut, ref: (el) => (this.container = el) }, h("div", { id: "uofg-modal-content", part: "content", class: { centered: this.centered } }, h("button", { id: "uofg-modal-dismiss", part: "dismiss-button", "aria-label": "Close modal", ref: (el) => (this.dismissButton = el), onClick: () => (this.isOpen = false) }, h(FontAwesomeIcon, { icon: faTimes })), h("slot", null))));
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Get the current state of the modal.
|
|
116
|
-
* @returns A promise which will resolve to true when the modal is open, or false when the modal is closed.
|
|
117
|
-
*/
|
|
118
|
-
async getState() {
|
|
119
|
-
return this.isOpen;
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Set the state of the modal.
|
|
123
|
-
* @param value The new state, set it to true to open the modal, or false to close the modal.
|
|
124
|
-
*/
|
|
125
|
-
async setState(value) {
|
|
126
|
-
this.isOpen = value;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Toggle the state of the modal.
|
|
130
|
-
* @returns A promise which will resolve to true (if the modal opened) or false (if the modal closed).
|
|
131
|
-
*/
|
|
132
|
-
async toggle() {
|
|
133
|
-
this.isOpen = !this.isOpen;
|
|
134
|
-
return this.isOpen;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Closes the modal.
|
|
138
|
-
* @returns empty Promise.
|
|
139
|
-
*/
|
|
140
|
-
async close() {
|
|
141
|
-
this.isOpen = false;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Opens the modal.
|
|
145
|
-
* @returns empty Promise.
|
|
146
|
-
*/
|
|
147
|
-
async open() {
|
|
148
|
-
this.isOpen = true;
|
|
149
|
-
}
|
|
150
|
-
static get is() { return "uofg-modal"; }
|
|
151
|
-
static get encapsulation() { return "shadow"; }
|
|
152
|
-
static get originalStyleUrls() {
|
|
153
|
-
return {
|
|
154
|
-
"$": ["uofg-modal.scss"]
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
static get styleUrls() {
|
|
158
|
-
return {
|
|
159
|
-
"$": ["uofg-modal.css"]
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
static get properties() {
|
|
163
|
-
return {
|
|
164
|
-
"label": {
|
|
165
|
-
"type": "string",
|
|
166
|
-
"mutable": false,
|
|
167
|
-
"complexType": {
|
|
168
|
-
"original": "string",
|
|
169
|
-
"resolved": "string",
|
|
170
|
-
"references": {}
|
|
171
|
-
},
|
|
172
|
-
"required": false,
|
|
173
|
-
"optional": false,
|
|
174
|
-
"docs": {
|
|
175
|
-
"tags": [],
|
|
176
|
-
"text": "The label for the modal. It is recommended that you set this to describe the modal's content.\nThis is required for accessibility."
|
|
177
|
-
},
|
|
178
|
-
"attribute": "label",
|
|
179
|
-
"reflect": false
|
|
180
|
-
},
|
|
181
|
-
"alertDialog": {
|
|
182
|
-
"type": "boolean",
|
|
183
|
-
"mutable": false,
|
|
184
|
-
"complexType": {
|
|
185
|
-
"original": "boolean",
|
|
186
|
-
"resolved": "boolean",
|
|
187
|
-
"references": {}
|
|
188
|
-
},
|
|
189
|
-
"required": false,
|
|
190
|
-
"optional": false,
|
|
191
|
-
"docs": {
|
|
192
|
-
"tags": [],
|
|
193
|
-
"text": "Used to determine whether the modal should be rendered as an alert dialog.\nThis is useful for when you want to use the modal to alert the user of something, rather than to ask the user to make a decision.\nIf this is set to true, the modal will be rendered with a role of \"alertdialog\" instead of \"dialog\"."
|
|
194
|
-
},
|
|
195
|
-
"attribute": "alert-dialog",
|
|
196
|
-
"reflect": false,
|
|
197
|
-
"defaultValue": "false"
|
|
198
|
-
},
|
|
199
|
-
"centered": {
|
|
200
|
-
"type": "boolean",
|
|
201
|
-
"mutable": false,
|
|
202
|
-
"complexType": {
|
|
203
|
-
"original": "boolean",
|
|
204
|
-
"resolved": "boolean",
|
|
205
|
-
"references": {}
|
|
206
|
-
},
|
|
207
|
-
"required": false,
|
|
208
|
-
"optional": false,
|
|
209
|
-
"docs": {
|
|
210
|
-
"tags": [],
|
|
211
|
-
"text": "Used to determine whether the modal content is centered vertically."
|
|
212
|
-
},
|
|
213
|
-
"attribute": "centered",
|
|
214
|
-
"reflect": false,
|
|
215
|
-
"defaultValue": "false"
|
|
216
|
-
},
|
|
217
|
-
"staticBackdrop": {
|
|
218
|
-
"type": "boolean",
|
|
219
|
-
"mutable": false,
|
|
220
|
-
"complexType": {
|
|
221
|
-
"original": "boolean",
|
|
222
|
-
"resolved": "boolean",
|
|
223
|
-
"references": {}
|
|
224
|
-
},
|
|
225
|
-
"required": false,
|
|
226
|
-
"optional": false,
|
|
227
|
-
"docs": {
|
|
228
|
-
"tags": [],
|
|
229
|
-
"text": "Used to determine whether clicking on the backdrop of the modal will close the modal.\nIf this is set to true, clicking on the backdrop will NOT close the modal."
|
|
230
|
-
},
|
|
231
|
-
"attribute": "static-backdrop",
|
|
232
|
-
"reflect": false,
|
|
233
|
-
"defaultValue": "false"
|
|
234
|
-
},
|
|
235
|
-
"autoOpen": {
|
|
236
|
-
"type": "boolean",
|
|
237
|
-
"mutable": false,
|
|
238
|
-
"complexType": {
|
|
239
|
-
"original": "boolean",
|
|
240
|
-
"resolved": "boolean",
|
|
241
|
-
"references": {}
|
|
242
|
-
},
|
|
243
|
-
"required": false,
|
|
244
|
-
"optional": false,
|
|
245
|
-
"docs": {
|
|
246
|
-
"tags": [],
|
|
247
|
-
"text": "Used to determine whether the modal should open automatically when the component is first rendered.\nIt is important to ensure this is only set to true for ONE modal on the page."
|
|
248
|
-
},
|
|
249
|
-
"attribute": "auto-open",
|
|
250
|
-
"reflect": false,
|
|
251
|
-
"defaultValue": "false"
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
static get states() {
|
|
256
|
-
return {
|
|
257
|
-
"isOpen": {}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
static get events() {
|
|
261
|
-
return [{
|
|
262
|
-
"method": "opened",
|
|
263
|
-
"name": "opened",
|
|
264
|
-
"bubbles": false,
|
|
265
|
-
"cancelable": false,
|
|
266
|
-
"composed": true,
|
|
267
|
-
"docs": {
|
|
268
|
-
"tags": [],
|
|
269
|
-
"text": "Dispatched whenever the modal is opened whether by user interaction or or programmatically (e.g. open())."
|
|
270
|
-
},
|
|
271
|
-
"complexType": {
|
|
272
|
-
"original": "void",
|
|
273
|
-
"resolved": "void",
|
|
274
|
-
"references": {}
|
|
34
|
+
handleClick(e) {
|
|
35
|
+
if (!this.staticBackdrop && e.target === e.currentTarget) {
|
|
36
|
+
this.isOpen = false;
|
|
275
37
|
}
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
"cancelable": false,
|
|
281
|
-
"composed": true,
|
|
282
|
-
"docs": {
|
|
283
|
-
"tags": [],
|
|
284
|
-
"text": "Dispatched whenever the modal is closed whether by user interaction or programmatically (e.g. close())."
|
|
285
|
-
},
|
|
286
|
-
"complexType": {
|
|
287
|
-
"original": "void",
|
|
288
|
-
"resolved": "void",
|
|
289
|
-
"references": {}
|
|
38
|
+
}
|
|
39
|
+
handleKeyUp(e) {
|
|
40
|
+
if (e.key === 'Escape') {
|
|
41
|
+
this.isOpen = false;
|
|
290
42
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
43
|
+
}
|
|
44
|
+
handleFocusOut(e) {
|
|
45
|
+
var _a;
|
|
46
|
+
if (!this.isOpen)
|
|
47
|
+
return; // Don't do anything if the modal is closed.
|
|
48
|
+
const relatedTarget = e.relatedTarget;
|
|
49
|
+
// If the focus is moving outside the modal
|
|
50
|
+
if (!this.container.contains(relatedTarget) && !this.el.contains(relatedTarget)) {
|
|
51
|
+
e.preventDefault();
|
|
52
|
+
// If the focus is moving away from the dismiss button, focus the last focusable element in the modal.
|
|
53
|
+
if (e.target === this.dismissButton) {
|
|
54
|
+
const focusableElements = getAllFocusableElements(this.el);
|
|
55
|
+
(_a = focusableElements[focusableElements.length - 1]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
303
56
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
"docs": {
|
|
308
|
-
"text": "Get the current state of the modal.",
|
|
309
|
-
"tags": [{
|
|
310
|
-
"name": "returns",
|
|
311
|
-
"text": "A promise which will resolve to true when the modal is open, or false when the modal is closed."
|
|
312
|
-
}]
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
"setState": {
|
|
316
|
-
"complexType": {
|
|
317
|
-
"signature": "(value: boolean) => Promise<void>",
|
|
318
|
-
"parameters": [{
|
|
319
|
-
"tags": [{
|
|
320
|
-
"name": "param",
|
|
321
|
-
"text": "value The new state, set it to true to open the modal, or false to close the modal."
|
|
322
|
-
}],
|
|
323
|
-
"text": "The new state, set it to true to open the modal, or false to close the modal."
|
|
324
|
-
}],
|
|
325
|
-
"references": {
|
|
326
|
-
"Promise": {
|
|
327
|
-
"location": "global",
|
|
328
|
-
"id": "global::Promise"
|
|
57
|
+
else {
|
|
58
|
+
// Otherwise, focus the dismiss button.
|
|
59
|
+
this.dismissButton.focus();
|
|
329
60
|
}
|
|
330
|
-
},
|
|
331
|
-
"return": "Promise<void>"
|
|
332
|
-
},
|
|
333
|
-
"docs": {
|
|
334
|
-
"text": "Set the state of the modal.",
|
|
335
|
-
"tags": [{
|
|
336
|
-
"name": "param",
|
|
337
|
-
"text": "value The new state, set it to true to open the modal, or false to close the modal."
|
|
338
|
-
}]
|
|
339
61
|
}
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
62
|
+
}
|
|
63
|
+
handleIsOpenChange(newValue) {
|
|
64
|
+
if (newValue) {
|
|
65
|
+
window.requestAnimationFrame(() => {
|
|
66
|
+
window.requestAnimationFrame(() => {
|
|
67
|
+
window.requestAnimationFrame(() => {
|
|
68
|
+
// Focus the container element when the modal is opened, so that the screen reader's will announce the modal when it opens.
|
|
69
|
+
this.container.focus();
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
// Mark outer elements as inert when the modal is open.
|
|
74
|
+
let current = this.el;
|
|
75
|
+
// We want to mark all elements outside the modal as inert, so we need to traverse up the DOM tree until we reach the body element.
|
|
76
|
+
while (current !== null && current !== document.body) {
|
|
77
|
+
const parent = current.parentElement;
|
|
78
|
+
// If parent is null, then we may be inside a shadow root. If so, we get the host element and continue traversing up the DOM tree.
|
|
79
|
+
if (parent === null) {
|
|
80
|
+
const root = current.getRootNode();
|
|
81
|
+
if (root instanceof ShadowRoot) {
|
|
82
|
+
current = root.host;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (parent !== null) {
|
|
87
|
+
for (const child of parent.children) {
|
|
88
|
+
if (child !== current && !child.inert) {
|
|
89
|
+
// Mark the element as inert and store it in an array so that we can remove the inert attribute when the modal closes.
|
|
90
|
+
child.inert = true;
|
|
91
|
+
this.inertElements.push(child);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
current = parent;
|
|
96
|
+
this.opened.emit();
|
|
349
97
|
}
|
|
350
|
-
},
|
|
351
|
-
"return": "Promise<boolean>"
|
|
352
|
-
},
|
|
353
|
-
"docs": {
|
|
354
|
-
"text": "Toggle the state of the modal.",
|
|
355
|
-
"tags": [{
|
|
356
|
-
"name": "returns",
|
|
357
|
-
"text": "A promise which will resolve to true (if the modal opened) or false (if the modal closed)."
|
|
358
|
-
}]
|
|
359
98
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
"parameters": [],
|
|
365
|
-
"references": {
|
|
366
|
-
"Promise": {
|
|
367
|
-
"location": "global",
|
|
368
|
-
"id": "global::Promise"
|
|
99
|
+
else {
|
|
100
|
+
// Remove the inert attribute from all elements that we marked as inert when the modal was opened.
|
|
101
|
+
for (const element of this.inertElements) {
|
|
102
|
+
element.removeAttribute('inert');
|
|
369
103
|
}
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
"docs": {
|
|
374
|
-
"text": "Closes the modal.",
|
|
375
|
-
"tags": [{
|
|
376
|
-
"name": "returns",
|
|
377
|
-
"text": "empty Promise."
|
|
378
|
-
}]
|
|
104
|
+
// Clear the array of inert elements. This is important because we don't want to keep a reference to elements as they may be removed from the DOM and we could cause a memory leak.
|
|
105
|
+
this.inertElements = [];
|
|
106
|
+
this.closed.emit();
|
|
379
107
|
}
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
108
|
+
// Prevent scrolling of the body when the modal is open.
|
|
109
|
+
document.body.style.overflow = newValue ? 'hidden' : '';
|
|
110
|
+
}
|
|
111
|
+
render() {
|
|
112
|
+
return (h("div", { key: 'c66f0986068658cc29b9c12715381a0fd40678c9', class: {
|
|
113
|
+
'tw-visible tw-opacity-100': this.isOpen,
|
|
114
|
+
'tw-invisible tw-opacity-0': !this.isOpen,
|
|
115
|
+
'tw-fixed tw-left-0 tw-top-0 tw-z-[1000] tw-flex tw-h-screen tw-w-screen tw-bg-black tw-bg-opacity-50 tw-transition-[opacity,visibility]': true,
|
|
116
|
+
}, role: this.alertDialog ? 'alertdialog' : 'dialog', "aria-modal": this.isOpen ? 'true' : '', "aria-label": this.label, tabIndex: -1, onClick: this.handleClick, onKeyUp: this.handleKeyUp, onFocusout: this.handleFocusOut, ref: (el) => (this.container = el) }, h("div", { key: 'f6d05f9834e3d5398aa5cd0897605d5b16014c2e', part: "content", class: {
|
|
117
|
+
'tw-visible tw-opacity-100': this.isOpen,
|
|
118
|
+
'tw-translate-y-[calc(-50%_-_50px)]': !this.isOpen && this.centered,
|
|
119
|
+
'tw-translate-y-[-50px]': (!this.isOpen && !this.centered) || (this.isOpen && this.centered),
|
|
120
|
+
'tw-z-1 tw-absolute tw-left-1/2 tw-h-fit tw-max-h-full tw-w-fit tw-max-w-full -tw-translate-x-1/2 tw-overflow-auto tw-p-8 tw-transition-transform motion-reduce:tw-transition-none': true,
|
|
121
|
+
} }, h("button", { key: 'eecbcc13c724410cb085bec5e26f6a2a4c55c32a', class: "[&>svg]:h-[1em] tw-absolute tw-right-8 tw-top-8 tw-z-[2] tw-flex tw-h-12 tw-w-12 tw-items-center tw-justify-center tw-border-0 tw-bg-transparent tw-text-3xl tw-p-2 tw-text-[var(--uofg-modal-dismiss-color,white)] [&>svg]:tw-h-[1em] [&>svg]:tw-fill-current", part: "dismiss-button", "aria-label": "Close modal", ref: (el) => (this.dismissButton = el), onClick: () => (this.isOpen = false) }, h(FontAwesomeIcon, { key: '735ceec0b5bbace91a40db729d7b530767b8593a', icon: faTimes })), h("slot", { key: 'b3b156aa4d3859a1d827a9d826a8d91b8f379f18' }))));
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get the current state of the modal.
|
|
125
|
+
* @returns A promise which will resolve to true when the modal is open, or false when the modal is closed.
|
|
126
|
+
*/
|
|
127
|
+
async getState() {
|
|
128
|
+
return this.isOpen;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Set the state of the modal.
|
|
132
|
+
* @param value The new state, set it to true to open the modal, or false to close the modal.
|
|
133
|
+
*/
|
|
134
|
+
async setState(value) {
|
|
135
|
+
this.isOpen = value;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Toggle the state of the modal.
|
|
139
|
+
* @returns A promise which will resolve to true (if the modal opened) or false (if the modal closed).
|
|
140
|
+
*/
|
|
141
|
+
async toggle() {
|
|
142
|
+
this.isOpen = !this.isOpen;
|
|
143
|
+
return this.isOpen;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Closes the modal.
|
|
147
|
+
* @returns empty Promise.
|
|
148
|
+
*/
|
|
149
|
+
async close() {
|
|
150
|
+
this.isOpen = false;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Opens the modal.
|
|
154
|
+
* @returns empty Promise.
|
|
155
|
+
*/
|
|
156
|
+
async open() {
|
|
157
|
+
this.isOpen = true;
|
|
158
|
+
}
|
|
159
|
+
static get is() { return "uofg-modal"; }
|
|
160
|
+
static get encapsulation() { return "shadow"; }
|
|
161
|
+
static get originalStyleUrls() {
|
|
162
|
+
return {
|
|
163
|
+
"$": ["uofg-modal.css"]
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
static get styleUrls() {
|
|
167
|
+
return {
|
|
168
|
+
"$": ["uofg-modal.css"]
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
static get properties() {
|
|
172
|
+
return {
|
|
173
|
+
"label": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"mutable": false,
|
|
176
|
+
"complexType": {
|
|
177
|
+
"original": "string",
|
|
178
|
+
"resolved": "string",
|
|
179
|
+
"references": {}
|
|
180
|
+
},
|
|
181
|
+
"required": false,
|
|
182
|
+
"optional": false,
|
|
183
|
+
"docs": {
|
|
184
|
+
"tags": [],
|
|
185
|
+
"text": "The label for the modal. It is recommended that you set this to describe the modal's content.\nThis is required for accessibility."
|
|
186
|
+
},
|
|
187
|
+
"attribute": "label",
|
|
188
|
+
"reflect": false
|
|
189
|
+
},
|
|
190
|
+
"alertDialog": {
|
|
191
|
+
"type": "boolean",
|
|
192
|
+
"mutable": false,
|
|
193
|
+
"complexType": {
|
|
194
|
+
"original": "boolean",
|
|
195
|
+
"resolved": "boolean",
|
|
196
|
+
"references": {}
|
|
197
|
+
},
|
|
198
|
+
"required": false,
|
|
199
|
+
"optional": false,
|
|
200
|
+
"docs": {
|
|
201
|
+
"tags": [],
|
|
202
|
+
"text": "Used to determine whether the modal should be rendered as an alert dialog.\nThis is useful for when you want to use the modal to alert the user of something, rather than to ask the user to make a decision.\nIf this is set to true, the modal will be rendered with a role of \"alertdialog\" instead of \"dialog\"."
|
|
203
|
+
},
|
|
204
|
+
"attribute": "alert-dialog",
|
|
205
|
+
"reflect": false,
|
|
206
|
+
"defaultValue": "false"
|
|
207
|
+
},
|
|
208
|
+
"centered": {
|
|
209
|
+
"type": "boolean",
|
|
210
|
+
"mutable": false,
|
|
211
|
+
"complexType": {
|
|
212
|
+
"original": "boolean",
|
|
213
|
+
"resolved": "boolean",
|
|
214
|
+
"references": {}
|
|
215
|
+
},
|
|
216
|
+
"required": false,
|
|
217
|
+
"optional": false,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": "Used to determine whether the modal content is centered vertically."
|
|
221
|
+
},
|
|
222
|
+
"attribute": "centered",
|
|
223
|
+
"reflect": false,
|
|
224
|
+
"defaultValue": "false"
|
|
225
|
+
},
|
|
226
|
+
"staticBackdrop": {
|
|
227
|
+
"type": "boolean",
|
|
228
|
+
"mutable": false,
|
|
229
|
+
"complexType": {
|
|
230
|
+
"original": "boolean",
|
|
231
|
+
"resolved": "boolean",
|
|
232
|
+
"references": {}
|
|
233
|
+
},
|
|
234
|
+
"required": false,
|
|
235
|
+
"optional": false,
|
|
236
|
+
"docs": {
|
|
237
|
+
"tags": [],
|
|
238
|
+
"text": "Used to determine whether clicking on the backdrop of the modal will close the modal.\nIf this is set to true, clicking on the backdrop will NOT close the modal."
|
|
239
|
+
},
|
|
240
|
+
"attribute": "static-backdrop",
|
|
241
|
+
"reflect": false,
|
|
242
|
+
"defaultValue": "false"
|
|
243
|
+
},
|
|
244
|
+
"autoOpen": {
|
|
245
|
+
"type": "boolean",
|
|
246
|
+
"mutable": false,
|
|
247
|
+
"complexType": {
|
|
248
|
+
"original": "boolean",
|
|
249
|
+
"resolved": "boolean",
|
|
250
|
+
"references": {}
|
|
251
|
+
},
|
|
252
|
+
"required": false,
|
|
253
|
+
"optional": false,
|
|
254
|
+
"docs": {
|
|
255
|
+
"tags": [],
|
|
256
|
+
"text": "Used to determine whether the modal should open automatically when the component is first rendered.\nIt is important to ensure this is only set to true for ONE modal on the page."
|
|
257
|
+
},
|
|
258
|
+
"attribute": "auto-open",
|
|
259
|
+
"reflect": false,
|
|
260
|
+
"defaultValue": "false"
|
|
389
261
|
}
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
static get states() {
|
|
265
|
+
return {
|
|
266
|
+
"isOpen": {}
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
static get events() {
|
|
270
|
+
return [{
|
|
271
|
+
"method": "opened",
|
|
272
|
+
"name": "opened",
|
|
273
|
+
"bubbles": false,
|
|
274
|
+
"cancelable": false,
|
|
275
|
+
"composed": true,
|
|
276
|
+
"docs": {
|
|
277
|
+
"tags": [],
|
|
278
|
+
"text": "Dispatched whenever the modal is opened whether by user interaction or programmatically (e.g. open())."
|
|
279
|
+
},
|
|
280
|
+
"complexType": {
|
|
281
|
+
"original": "void",
|
|
282
|
+
"resolved": "void",
|
|
283
|
+
"references": {}
|
|
284
|
+
}
|
|
285
|
+
}, {
|
|
286
|
+
"method": "closed",
|
|
287
|
+
"name": "closed",
|
|
288
|
+
"bubbles": false,
|
|
289
|
+
"cancelable": false,
|
|
290
|
+
"composed": true,
|
|
291
|
+
"docs": {
|
|
292
|
+
"tags": [],
|
|
293
|
+
"text": "Dispatched whenever the modal is closed whether by user interaction or programmatically (e.g. close())."
|
|
294
|
+
},
|
|
295
|
+
"complexType": {
|
|
296
|
+
"original": "void",
|
|
297
|
+
"resolved": "void",
|
|
298
|
+
"references": {}
|
|
299
|
+
}
|
|
300
|
+
}];
|
|
301
|
+
}
|
|
302
|
+
static get methods() {
|
|
303
|
+
return {
|
|
304
|
+
"getState": {
|
|
305
|
+
"complexType": {
|
|
306
|
+
"signature": "() => Promise<boolean>",
|
|
307
|
+
"parameters": [],
|
|
308
|
+
"references": {
|
|
309
|
+
"Promise": {
|
|
310
|
+
"location": "global",
|
|
311
|
+
"id": "global::Promise"
|
|
312
|
+
}
|
|
313
|
+
},
|
|
314
|
+
"return": "Promise<boolean>"
|
|
315
|
+
},
|
|
316
|
+
"docs": {
|
|
317
|
+
"text": "Get the current state of the modal.",
|
|
318
|
+
"tags": [{
|
|
319
|
+
"name": "returns",
|
|
320
|
+
"text": "A promise which will resolve to true when the modal is open, or false when the modal is closed."
|
|
321
|
+
}]
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"setState": {
|
|
325
|
+
"complexType": {
|
|
326
|
+
"signature": "(value: boolean) => Promise<void>",
|
|
327
|
+
"parameters": [{
|
|
328
|
+
"name": "value",
|
|
329
|
+
"type": "boolean",
|
|
330
|
+
"docs": "The new state, set it to true to open the modal, or false to close the modal."
|
|
331
|
+
}],
|
|
332
|
+
"references": {
|
|
333
|
+
"Promise": {
|
|
334
|
+
"location": "global",
|
|
335
|
+
"id": "global::Promise"
|
|
336
|
+
}
|
|
337
|
+
},
|
|
338
|
+
"return": "Promise<void>"
|
|
339
|
+
},
|
|
340
|
+
"docs": {
|
|
341
|
+
"text": "Set the state of the modal.",
|
|
342
|
+
"tags": [{
|
|
343
|
+
"name": "param",
|
|
344
|
+
"text": "value The new state, set it to true to open the modal, or false to close the modal."
|
|
345
|
+
}]
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
"toggle": {
|
|
349
|
+
"complexType": {
|
|
350
|
+
"signature": "() => Promise<boolean>",
|
|
351
|
+
"parameters": [],
|
|
352
|
+
"references": {
|
|
353
|
+
"Promise": {
|
|
354
|
+
"location": "global",
|
|
355
|
+
"id": "global::Promise"
|
|
356
|
+
}
|
|
357
|
+
},
|
|
358
|
+
"return": "Promise<boolean>"
|
|
359
|
+
},
|
|
360
|
+
"docs": {
|
|
361
|
+
"text": "Toggle the state of the modal.",
|
|
362
|
+
"tags": [{
|
|
363
|
+
"name": "returns",
|
|
364
|
+
"text": "A promise which will resolve to true (if the modal opened) or false (if the modal closed)."
|
|
365
|
+
}]
|
|
366
|
+
}
|
|
367
|
+
},
|
|
368
|
+
"close": {
|
|
369
|
+
"complexType": {
|
|
370
|
+
"signature": "() => Promise<void>",
|
|
371
|
+
"parameters": [],
|
|
372
|
+
"references": {
|
|
373
|
+
"Promise": {
|
|
374
|
+
"location": "global",
|
|
375
|
+
"id": "global::Promise"
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
"return": "Promise<void>"
|
|
379
|
+
},
|
|
380
|
+
"docs": {
|
|
381
|
+
"text": "Closes the modal.",
|
|
382
|
+
"tags": [{
|
|
383
|
+
"name": "returns",
|
|
384
|
+
"text": "empty Promise."
|
|
385
|
+
}]
|
|
386
|
+
}
|
|
387
|
+
},
|
|
388
|
+
"open": {
|
|
389
|
+
"complexType": {
|
|
390
|
+
"signature": "() => Promise<void>",
|
|
391
|
+
"parameters": [],
|
|
392
|
+
"references": {
|
|
393
|
+
"Promise": {
|
|
394
|
+
"location": "global",
|
|
395
|
+
"id": "global::Promise"
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
"return": "Promise<void>"
|
|
399
|
+
},
|
|
400
|
+
"docs": {
|
|
401
|
+
"text": "Opens the modal.",
|
|
402
|
+
"tags": [{
|
|
403
|
+
"name": "returns",
|
|
404
|
+
"text": "empty Promise."
|
|
405
|
+
}]
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
static get elementRef() { return "el"; }
|
|
411
|
+
static get watchers() {
|
|
412
|
+
return [{
|
|
413
|
+
"propName": "isOpen",
|
|
414
|
+
"methodName": "handleIsOpenChange"
|
|
415
|
+
}];
|
|
416
|
+
}
|
|
410
417
|
}
|