@uoguelph/web-components 0.0.17 → 0.0.18

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.
Files changed (41) hide show
  1. package/dist/cjs/{index-c68ebbb8.js → index-52617c57.js} +7 -1
  2. package/dist/cjs/loader.cjs.js +2 -2
  3. package/dist/cjs/{uofg-back-to-top_4.cjs.entry.js → uofg-alert_6.cjs.entry.js} +161 -41
  4. package/dist/cjs/uofg-web-components.cjs.js +2 -2
  5. package/dist/collection/collection-manifest.json +3 -1
  6. package/dist/collection/components/uofg-alert/uofg-alert.css +46 -0
  7. package/dist/collection/components/uofg-alert/uofg-alert.js +20 -0
  8. package/dist/collection/components/uofg-menu/uofg-menu.js +28 -50
  9. package/dist/collection/components/uofg-modal/uofg-modal.css +80 -0
  10. package/dist/collection/components/uofg-modal/uofg-modal.js +325 -0
  11. package/dist/collection/utils/utils.js +6 -0
  12. package/dist/components/font-awesome-icon.js +10 -0
  13. package/dist/components/index.d.ts +4 -0
  14. package/dist/components/index.js +2 -0
  15. package/dist/components/index2.js +7 -10
  16. package/dist/components/uofg-alert.d.ts +11 -0
  17. package/dist/components/uofg-alert.js +40 -0
  18. package/dist/components/uofg-back-to-top.js +2 -1
  19. package/dist/components/uofg-footer.js +2 -1
  20. package/dist/components/uofg-header.js +2 -1
  21. package/dist/components/uofg-menu2.js +31 -46
  22. package/dist/components/uofg-modal.d.ts +11 -0
  23. package/dist/components/uofg-modal.js +139 -0
  24. package/dist/components/utils.js +8 -0
  25. package/dist/esm/{index-8ff56dd3.js → index-ebf79156.js} +7 -1
  26. package/dist/esm/loader.js +3 -3
  27. package/dist/esm/{uofg-back-to-top_4.entry.js → uofg-alert_6.entry.js} +160 -42
  28. package/dist/esm/uofg-web-components.js +3 -3
  29. package/dist/types/components/uofg-alert/uofg-alert.d.ts +3 -0
  30. package/dist/types/components/uofg-menu/uofg-menu.d.ts +4 -4
  31. package/dist/types/components/uofg-modal/uofg-modal.d.ts +61 -0
  32. package/dist/types/components.d.ts +91 -0
  33. package/dist/types/utils/{feature-check.d.ts → utils.d.ts} +1 -0
  34. package/dist/uofg-web-components/p-2c75433c.entry.js +1 -0
  35. package/dist/uofg-web-components/p-bc82feb9.js +2 -0
  36. package/dist/uofg-web-components/uofg-web-components.css +1 -1
  37. package/dist/uofg-web-components/uofg-web-components.esm.js +1 -1
  38. package/package.json +2 -2
  39. package/dist/collection/utils/feature-check.js +0 -2
  40. package/dist/uofg-web-components/p-19e62111.js +0 -2
  41. package/dist/uofg-web-components/p-f8060888.entry.js +0 -1
@@ -0,0 +1,139 @@
1
+ import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
2
+ import { F as FontAwesomeIcon } from './font-awesome-icon.js';
3
+ import { p as faTimes } from './index2.js';
4
+ import { g as getAllFocusableElements } from './utils.js';
5
+
6
+ const uofgModalCss = ":host{visibility:visible !important;position:relative !important}:focus-visible{outline:2px solid #ffc72a}*{box-sizing:border-box}#uofg-modal{display:flex;position:fixed;top:0;left:0;z-index:10000;width:100vw;height:100vh;background-color:rgba(0, 0, 0, 0.5);visibility:hidden;opacity:0;padding:2rem;transition-duration:0.3s;transition-timing-function:ease-in-out;transition-property:visibility, opacity}#uofg-modal #uofg-modal-dismiss{display:flex;justify-content:center;align-items:center;position:absolute;top:0;right:0;padding:0.5rem;height:3.5rem;width:3.5rem;font-size:2rem;line-height:1;color:var(--uofg-modal-dismiss-color, #fff);background-color:transparent;border:none;cursor:pointer;z-index:2}#uofg-modal #uofg-modal-dismiss>svg{display:block;height:1em;fill:currentColor}#uofg-modal>#uofg-modal-content{position:absolute;left:50%;transition:transform 0.3s ease-in-out;transform:translate(-50%, -50px);z-index:1}@media (prefers-reduced-motion: reduce){#uofg-modal>#uofg-modal-content{transition:none}}#uofg-modal>#uofg-modal-content.centered{top:50%;transform:translate(-50%, calc(-50% - 50px))}#uofg-modal.open{visibility:visible;opacity:1}#uofg-modal.open #uofg-modal-content{visibility:visible;opacity:1;transform:translate(-50%, 0)}#uofg-modal.open #uofg-modal-content.centered{transform:translate(-50%, -50%)}";
7
+
8
+ const UofgModal$1 = /*@__PURE__*/ proxyCustomElement(class UofgModal extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.__registerHost();
12
+ this.__attachShadow();
13
+ this.label = undefined;
14
+ this.alertDialog = false;
15
+ this.centered = false;
16
+ this.staticBackdrop = false;
17
+ this.autoOpen = false;
18
+ this.isOpen = false;
19
+ }
20
+ connectedCallback() {
21
+ // Bind event handlers so that 'this' is always the component instance.
22
+ this.handleClick = this.handleClick.bind(this);
23
+ this.handleKeyUp = this.handleKeyUp.bind(this);
24
+ this.handleKeyDown = this.handleKeyDown.bind(this);
25
+ if (this.autoOpen) {
26
+ this.isOpen = true;
27
+ }
28
+ }
29
+ handleClick(e) {
30
+ if (!this.staticBackdrop && e.target === e.currentTarget) {
31
+ this.isOpen = false;
32
+ }
33
+ }
34
+ handleKeyUp(e) {
35
+ if (e.key === 'Escape') {
36
+ this.isOpen = false;
37
+ }
38
+ }
39
+ handleKeyDown(e) {
40
+ if (e.key === 'Tab') {
41
+ const focusableElements = getAllFocusableElements(this.el);
42
+ const firstFocusable = this.dismissButton; // The dismiss button is always the first focusable element in the modal.
43
+ const lastFocusable = focusableElements[focusableElements.length - 1];
44
+ if (e.target === firstFocusable && e.shiftKey) {
45
+ e.preventDefault();
46
+ lastFocusable === null || lastFocusable === void 0 ? void 0 : lastFocusable.focus();
47
+ }
48
+ else if (e.target === lastFocusable && !e.shiftKey) {
49
+ e.preventDefault();
50
+ firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
51
+ }
52
+ }
53
+ }
54
+ handleIsOpenChange(newValue) {
55
+ if (newValue === true) {
56
+ window.requestAnimationFrame(() => {
57
+ window.requestAnimationFrame(() => {
58
+ window.requestAnimationFrame(() => {
59
+ this.dismissButton.focus();
60
+ });
61
+ });
62
+ });
63
+ }
64
+ }
65
+ render() {
66
+ return (h("div", { id: "uofg-modal", class: { open: this.isOpen }, role: this.isOpen ? (this.alertDialog ? 'alertdialog' : 'dialog') : '', "aria-modal": this.isOpen, "aria-label": this.label, "aria-hidden": !this.isOpen, tabIndex: -1, onClick: this.handleClick, onKeyUp: this.handleKeyUp, onKeyDown: this.handleKeyDown }, h("div", { id: "uofg-modal-content", class: { centered: this.centered } }, h("button", { id: "uofg-modal-dismiss", "aria-label": "Close modal", ref: (el) => (this.dismissButton = el), onClick: () => (this.isOpen = false) }, h(FontAwesomeIcon, { icon: faTimes })), h("slot", null))));
67
+ }
68
+ /**
69
+ * Get the current state of the modal.
70
+ * @returns A promise which will resolve to true when the modal is open, or false when the modal is closed.
71
+ */
72
+ async getState() {
73
+ return this.isOpen;
74
+ }
75
+ /**
76
+ * Set the state of the modal.
77
+ * @param value The new state, set it to true to open the modal, or false to close the modal.
78
+ */
79
+ async setState(value) {
80
+ this.isOpen = value;
81
+ }
82
+ /**
83
+ * Toggle the state of the modal.
84
+ * @returns A promise which will resolve to true (if the modal opened) or false (if the modal closed).
85
+ */
86
+ async toggle() {
87
+ this.isOpen = !this.isOpen;
88
+ return this.isOpen;
89
+ }
90
+ /**
91
+ * Closes the modal.
92
+ * @returns empty Promise.
93
+ */
94
+ async close() {
95
+ this.isOpen = false;
96
+ }
97
+ /**
98
+ * Opens the modal.
99
+ * @returns empty Promise.
100
+ */
101
+ async open() {
102
+ this.isOpen = true;
103
+ }
104
+ get el() { return this; }
105
+ static get watchers() { return {
106
+ "isOpen": ["handleIsOpenChange"]
107
+ }; }
108
+ static get style() { return uofgModalCss; }
109
+ }, [1, "uofg-modal", {
110
+ "label": [1],
111
+ "alertDialog": [4, "alert-dialog"],
112
+ "centered": [4],
113
+ "staticBackdrop": [4, "static-backdrop"],
114
+ "autoOpen": [4, "auto-open"],
115
+ "isOpen": [32],
116
+ "getState": [64],
117
+ "setState": [64],
118
+ "toggle": [64],
119
+ "close": [64],
120
+ "open": [64]
121
+ }]);
122
+ function defineCustomElement$1() {
123
+ if (typeof customElements === "undefined") {
124
+ return;
125
+ }
126
+ const components = ["uofg-modal"];
127
+ components.forEach(tagName => { switch (tagName) {
128
+ case "uofg-modal":
129
+ if (!customElements.get(tagName)) {
130
+ customElements.define(tagName, UofgModal$1);
131
+ }
132
+ break;
133
+ } });
134
+ }
135
+
136
+ const UofgModal = UofgModal$1;
137
+ const defineCustomElement = defineCustomElement$1;
138
+
139
+ export { UofgModal, defineCustomElement };
@@ -0,0 +1,8 @@
1
+ const WEB_ANIMATIONS_SUPPORTED = 'animate' in HTMLElement.prototype;
2
+ const PREFERS_REDUCED_MOTION = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
3
+ const getAllFocusableElements = (container) => {
4
+ const query = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], audio[controls], video[controls], details, summary, [tabindex]:not([tabindex="-1"])';
5
+ return Array.from(container.querySelectorAll(query));
6
+ };
7
+
8
+ export { PREFERS_REDUCED_MOTION as P, WEB_ANIMATIONS_SUPPORTED as W, getAllFocusableElements as g };
@@ -917,7 +917,9 @@ const patch = (oldVNode, newVNode) => {
917
917
  isSvgMode = tag === 'svg' ? true : tag === 'foreignObject' ? false : isSvgMode;
918
918
  }
919
919
  {
920
- {
920
+ if (tag === 'slot')
921
+ ;
922
+ else {
921
923
  // either this is the first render of an element OR it's an update
922
924
  // AND we already know it's possible it could have changed
923
925
  // this updates the element's css classes, attrs, props, listeners, etc.
@@ -1495,12 +1497,16 @@ const connectedCallback = (elm) => {
1495
1497
  const disconnectedCallback = (elm) => {
1496
1498
  if ((plt.$flags$ & 1 /* PLATFORM_FLAGS.isTmpDisconnected */) === 0) {
1497
1499
  const hostRef = getHostRef(elm);
1500
+ const instance = hostRef.$lazyInstance$ ;
1498
1501
  {
1499
1502
  if (hostRef.$rmListeners$) {
1500
1503
  hostRef.$rmListeners$.map((rmListener) => rmListener());
1501
1504
  hostRef.$rmListeners$ = undefined;
1502
1505
  }
1503
1506
  }
1507
+ {
1508
+ safeCall(instance, 'disconnectedCallback');
1509
+ }
1504
1510
  }
1505
1511
  };
1506
1512
  const bootstrapLazy = (lazyBundles, options = {}) => {
@@ -1,9 +1,9 @@
1
- import { b as bootstrapLazy } from './index-8ff56dd3.js';
2
- export { s as setNonce } from './index-8ff56dd3.js';
1
+ import { b as bootstrapLazy } from './index-ebf79156.js';
2
+ export { s as setNonce } from './index-ebf79156.js';
3
3
 
4
4
  const defineCustomElements = (win, options) => {
5
5
  if (typeof window === 'undefined') return Promise.resolve();
6
- return bootstrapLazy([["uofg-back-to-top_4",[[1,"uofg-header",{"pageTitle":[1,"page-title"],"pageUrl":[1,"page-url"],"isFullSize":[32],"pageSpecificContent":[32]},[[9,"resize","updateFullSize"]]],[1,"uofg-back-to-top",{"threshold":[2],"isVisible":[32]},[[9,"scroll","onScroll"]]],[1,"uofg-footer"],[0,"uofg-menu",{"autoCollapse":[4,"auto-collapse"],"isExpanded":[32],"getExpanded":[64],"setExpanded":[64],"toggle":[64],"collapse":[64],"expand":[64]},[[0,"onChildListChange","handleChildListChange"]]]]]], options);
6
+ return bootstrapLazy([["uofg-alert_6",[[1,"uofg-header",{"pageTitle":[1,"page-title"],"pageUrl":[1,"page-url"],"isFullSize":[32],"pageSpecificContent":[32]},[[9,"resize","updateFullSize"]]],[1,"uofg-alert"],[1,"uofg-back-to-top",{"threshold":[2],"isVisible":[32]},[[9,"scroll","onScroll"]]],[1,"uofg-footer"],[1,"uofg-modal",{"label":[1],"alertDialog":[4,"alert-dialog"],"centered":[4],"staticBackdrop":[4,"static-backdrop"],"autoOpen":[4,"auto-open"],"isOpen":[32],"getState":[64],"setState":[64],"toggle":[64],"close":[64],"open":[64]}],[0,"uofg-menu",{"autoCollapse":[4,"auto-collapse"],"isExpanded":[32],"getExpanded":[64],"setExpanded":[64],"toggle":[64],"collapse":[64],"expand":[64]}]]]], options);
7
7
  };
8
8
 
9
9
  export { defineCustomElements };
@@ -1,4 +1,4 @@
1
- import { h, r as registerInstance, g as getElement, c as createEvent, H as Host } from './index-8ff56dd3.js';
1
+ import { h, r as registerInstance, g as getElement, c as createEvent, H as Host } from './index-ebf79156.js';
2
2
 
3
3
  const FontAwesomeIcon = props => {
4
4
  const width = props.icon.icon[0];
@@ -7,6 +7,24 @@ const FontAwesomeIcon = props => {
7
7
  return (h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: `0 0 ${width} ${height}` }, Array.isArray(iconPathData) ? (iconPathData.map(path => h("path", { d: path }))) : (h("path", { d: iconPathData }))));
8
8
  };
9
9
 
10
+ var faCircleExclamation = {
11
+ prefix: 'far',
12
+ iconName: 'circle-exclamation',
13
+ icon: [512, 512, ["exclamation-circle"], "f06a", "M256 48a208 208 0 1 1 0 416 208 208 0 1 1 0-416zm0 464A256 256 0 1 0 256 0a256 256 0 1 0 0 512zm0-384c-13.3 0-24 10.7-24 24V264c0 13.3 10.7 24 24 24s24-10.7 24-24V152c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z"]
14
+ };
15
+
16
+ const uofgAlertCss = ":host{display:block}*{box-sizing:border-box}#uofg-alert{display:flex;flex-direction:column;font-size:2rem}#uofg-alert #uofg-alert-title{display:flex;align-items:center;font-size:2.25rem;padding:2rem;color:white;background-color:#C10631}#uofg-alert #uofg-alert-title>svg{margin-right:1rem;fill:currentColor;height:1.5em}#uofg-alert #uofg-alert-body{display:flex;flex-direction:column;padding:1.5rem 2rem;background-color:white}#uofg-alert #uofg-alert-body slot[name=subtitle]::slotted(*){font-size:2rem;margin-bottom:2rem;font-weight:bold}#uofg-alert #uofg-alert-body slot[name=message]::slotted(*){font-size:1.6rem}#uofg-alert #uofg-alert-footer{display:flex;padding:1rem 2rem;background-color:#DDDDDD;font-size:1.4rem}";
17
+
18
+ const UofgAlert = class {
19
+ constructor(hostRef) {
20
+ registerInstance(this, hostRef);
21
+ }
22
+ render() {
23
+ return (h("div", { id: "uofg-alert" }, h("div", { id: "uofg-alert-title" }, h(FontAwesomeIcon, { icon: faCircleExclamation }), h("slot", { name: "title" })), h("div", { id: "uofg-alert-body" }, h("slot", { name: "subtitle" }), h("slot", { name: "message" })), h("div", { id: "uofg-alert-footer" }, h("slot", { name: "footer" }))));
24
+ }
25
+ };
26
+ UofgAlert.style = uofgAlertCss;
27
+
10
28
  var faTrees = {
11
29
  prefix: 'fas',
12
30
  iconName: 'trees',
@@ -78,6 +96,12 @@ var faMagnifyingGlass = {
78
96
  icon: [512, 512, [128269, "search"], "f002", "M416 208c0 45.9-14.9 88.3-40 122.7L502.6 457.4c12.5 12.5 12.5 32.8 0 45.3s-32.8 12.5-45.3 0L330.7 376c-34.4 25.2-76.8 40-122.7 40C93.1 416 0 322.9 0 208S93.1 0 208 0S416 93.1 416 208zM208 352a144 144 0 1 0 0-288 144 144 0 1 0 0 288z"]
79
97
  };
80
98
  var faSearch = faMagnifyingGlass;
99
+ var faXmark = {
100
+ prefix: 'fas',
101
+ iconName: 'xmark',
102
+ icon: [384, 512, [128473, 10005, 10006, 10060, 215, "close", "multiply", "remove", "times"], "f00d", "M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"]
103
+ };
104
+ var faTimes = faXmark;
81
105
  var faBriefcase = {
82
106
  prefix: 'fas',
83
107
  iconName: 'briefcase',
@@ -307,17 +331,13 @@ UofgHeader.style = uofgHeaderCss;
307
331
 
308
332
  const WEB_ANIMATIONS_SUPPORTED = 'animate' in HTMLElement.prototype;
309
333
  const PREFERS_REDUCED_MOTION = window.matchMedia('(prefers-reduced-motion: reduce)').matches;
334
+ const getAllFocusableElements = (container) => {
335
+ const query = 'a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [contenteditable], audio[controls], video[controls], details, summary, [tabindex]:not([tabindex="-1"])';
336
+ return Array.from(container.querySelectorAll(query));
337
+ };
310
338
 
311
339
  const DURATION_REGEX = /^(\d*\.?\d+)(s|ms)$/;
312
340
  const EASING_FUNCTION_REGEX = /^cubic-bezier\((\s*-?\d*\.?\d+\s*,){3}\s*-?\d*\.?\d+\s*\)$|^steps\(\s*\d+\s*(,\s*(start|end))?\s*\)$/;
313
- const observer = new MutationObserver(mutations => {
314
- for (const mutation of mutations) {
315
- mutation.target.dispatchEvent(new CustomEvent('childListChange', { bubbles: false }));
316
- }
317
- });
318
- const observerConfig = {
319
- childList: true,
320
- };
321
341
  const UofgMenu = class {
322
342
  constructor(hostRef) {
323
343
  registerInstance(this, hostRef);
@@ -329,50 +349,31 @@ const UofgMenu = class {
329
349
  this.button = null;
330
350
  this.content = null;
331
351
  this.contentComputedStyle = null;
352
+ this.observer = new MutationObserver(this.handleMutation);
332
353
  this.isExpanded = false;
333
354
  this.autoCollapse = false;
334
355
  }
335
356
  connectedCallback() {
336
357
  // Bind functions so that "this" correctly refers to the component's instance.
337
- this.handleChildListChange = this.handleChildListChange.bind(this);
338
- this.updateButton = this.updateButton.bind(this);
339
- this.updateContent = this.updateContent.bind(this);
340
- this.handleButtonClick = this.handleButtonClick.bind(this);
358
+ this.handleMutation = this.handleMutation.bind(this);
359
+ this.handleClick = this.handleClick.bind(this);
341
360
  this.handleFocusout = this.handleFocusout.bind(this);
342
361
  this.handleKeyUp = this.handleKeyUp.bind(this);
343
362
  this.computedStyle = window.getComputedStyle(this.el);
344
- this.isExpanded = false;
345
- this.handleChildListChange();
346
- observer.observe(this.el, observerConfig);
363
+ this.handleMutation();
364
+ this.observer.observe(this.el, { childList: true });
347
365
  }
348
- handleChildListChange() {
349
- this.updateButton();
350
- this.updateContent();
366
+ disconnectedCallback() {
367
+ this.observer.disconnect();
351
368
  }
352
- handleKeyUp(e) {
353
- if (e.key === 'Escape') {
354
- this.isExpanded = false;
355
- if (e.target !== this.button) {
356
- e.stopPropagation();
357
- this.isExpanded = false;
358
- this.button && this.button.focus();
359
- }
360
- }
361
- }
362
- updateButton() {
363
- var _a, _b, _c;
369
+ handleMutation() {
370
+ // Update the button element
364
371
  const button = this.el.querySelector('[slot="button"]');
365
- // Clean up the old button before setting the new one
366
- (_a = this.button) === null || _a === void 0 ? void 0 : _a.removeEventListener('click', this.handleButtonClick);
367
- (_b = this.button) === null || _b === void 0 ? void 0 : _b.removeAttribute('aria-expanded');
368
- (_c = this.button) === null || _c === void 0 ? void 0 : _c.removeAttribute('aria-haspopup');
369
372
  // Set up the new button
370
373
  button === null || button === void 0 ? void 0 : button.setAttribute('aria-expanded', this.isExpanded ? 'true' : 'false');
371
374
  button === null || button === void 0 ? void 0 : button.setAttribute('aria-haspopup', 'true');
372
- button === null || button === void 0 ? void 0 : button.addEventListener('click', this.handleButtonClick);
373
375
  this.button = button;
374
- }
375
- updateContent() {
376
+ // Update the content element
376
377
  const content = this.el.querySelector('[slot="content"]');
377
378
  if (content == null) {
378
379
  this.content = null;
@@ -384,8 +385,22 @@ const UofgMenu = class {
384
385
  this.contentComputedStyle = window.getComputedStyle(this.content);
385
386
  }
386
387
  }
387
- handleButtonClick() {
388
- this.isExpanded = !this.isExpanded;
388
+ handleKeyUp(e) {
389
+ if (e.key === 'Escape') {
390
+ this.isExpanded = false;
391
+ if (e.target !== this.button) {
392
+ e.stopPropagation();
393
+ this.isExpanded = false;
394
+ this.button && this.button.focus();
395
+ }
396
+ }
397
+ }
398
+ handleClick(e) {
399
+ //Check if the click was on the button or a descendant of the button
400
+ if (this.button && this.button.contains(e.target)) {
401
+ this.isExpanded = !this.isExpanded;
402
+ return;
403
+ }
389
404
  }
390
405
  handleFocusout(e) {
391
406
  if (this.autoCollapse && !this.el.contains(e.relatedTarget)) {
@@ -511,7 +526,7 @@ const UofgMenu = class {
511
526
  };
512
527
  }
513
528
  render() {
514
- return (h(Host, { tabindex: -1, "data-expanded": this.isExpanded, onFocusout: this.handleFocusout, onKeyUp: this.handleKeyUp }));
529
+ return (h(Host, { "data-expanded": this.isExpanded, tabindex: -1, onFocusout: this.handleFocusout, onKeyUp: this.handleKeyUp, onClick: this.handleClick }));
515
530
  }
516
531
  /**
517
532
  * Get the current expanded state of the menu.
@@ -555,4 +570,107 @@ const UofgMenu = class {
555
570
  }; }
556
571
  };
557
572
 
558
- export { UofgBackToTop as uofg_back_to_top, UofgFooter as uofg_footer, UofgHeader as uofg_header, UofgMenu as uofg_menu };
573
+ const uofgModalCss = ":host{visibility:visible !important;position:relative !important}:focus-visible{outline:2px solid #ffc72a}*{box-sizing:border-box}#uofg-modal{display:flex;position:fixed;top:0;left:0;z-index:10000;width:100vw;height:100vh;background-color:rgba(0, 0, 0, 0.5);visibility:hidden;opacity:0;padding:2rem;transition-duration:0.3s;transition-timing-function:ease-in-out;transition-property:visibility, opacity}#uofg-modal #uofg-modal-dismiss{display:flex;justify-content:center;align-items:center;position:absolute;top:0;right:0;padding:0.5rem;height:3.5rem;width:3.5rem;font-size:2rem;line-height:1;color:var(--uofg-modal-dismiss-color, #fff);background-color:transparent;border:none;cursor:pointer;z-index:2}#uofg-modal #uofg-modal-dismiss>svg{display:block;height:1em;fill:currentColor}#uofg-modal>#uofg-modal-content{position:absolute;left:50%;transition:transform 0.3s ease-in-out;transform:translate(-50%, -50px);z-index:1}@media (prefers-reduced-motion: reduce){#uofg-modal>#uofg-modal-content{transition:none}}#uofg-modal>#uofg-modal-content.centered{top:50%;transform:translate(-50%, calc(-50% - 50px))}#uofg-modal.open{visibility:visible;opacity:1}#uofg-modal.open #uofg-modal-content{visibility:visible;opacity:1;transform:translate(-50%, 0)}#uofg-modal.open #uofg-modal-content.centered{transform:translate(-50%, -50%)}";
574
+
575
+ const UofgModal = class {
576
+ constructor(hostRef) {
577
+ registerInstance(this, hostRef);
578
+ this.label = undefined;
579
+ this.alertDialog = false;
580
+ this.centered = false;
581
+ this.staticBackdrop = false;
582
+ this.autoOpen = false;
583
+ this.isOpen = false;
584
+ }
585
+ connectedCallback() {
586
+ // Bind event handlers so that 'this' is always the component instance.
587
+ this.handleClick = this.handleClick.bind(this);
588
+ this.handleKeyUp = this.handleKeyUp.bind(this);
589
+ this.handleKeyDown = this.handleKeyDown.bind(this);
590
+ if (this.autoOpen) {
591
+ this.isOpen = true;
592
+ }
593
+ }
594
+ handleClick(e) {
595
+ if (!this.staticBackdrop && e.target === e.currentTarget) {
596
+ this.isOpen = false;
597
+ }
598
+ }
599
+ handleKeyUp(e) {
600
+ if (e.key === 'Escape') {
601
+ this.isOpen = false;
602
+ }
603
+ }
604
+ handleKeyDown(e) {
605
+ if (e.key === 'Tab') {
606
+ const focusableElements = getAllFocusableElements(this.el);
607
+ const firstFocusable = this.dismissButton; // The dismiss button is always the first focusable element in the modal.
608
+ const lastFocusable = focusableElements[focusableElements.length - 1];
609
+ if (e.target === firstFocusable && e.shiftKey) {
610
+ e.preventDefault();
611
+ lastFocusable === null || lastFocusable === void 0 ? void 0 : lastFocusable.focus();
612
+ }
613
+ else if (e.target === lastFocusable && !e.shiftKey) {
614
+ e.preventDefault();
615
+ firstFocusable === null || firstFocusable === void 0 ? void 0 : firstFocusable.focus();
616
+ }
617
+ }
618
+ }
619
+ handleIsOpenChange(newValue) {
620
+ if (newValue === true) {
621
+ window.requestAnimationFrame(() => {
622
+ window.requestAnimationFrame(() => {
623
+ window.requestAnimationFrame(() => {
624
+ this.dismissButton.focus();
625
+ });
626
+ });
627
+ });
628
+ }
629
+ }
630
+ render() {
631
+ return (h("div", { id: "uofg-modal", class: { open: this.isOpen }, role: this.isOpen ? (this.alertDialog ? 'alertdialog' : 'dialog') : '', "aria-modal": this.isOpen, "aria-label": this.label, "aria-hidden": !this.isOpen, tabIndex: -1, onClick: this.handleClick, onKeyUp: this.handleKeyUp, onKeyDown: this.handleKeyDown }, h("div", { id: "uofg-modal-content", class: { centered: this.centered } }, h("button", { id: "uofg-modal-dismiss", "aria-label": "Close modal", ref: (el) => (this.dismissButton = el), onClick: () => (this.isOpen = false) }, h(FontAwesomeIcon, { icon: faTimes })), h("slot", null))));
632
+ }
633
+ /**
634
+ * Get the current state of the modal.
635
+ * @returns A promise which will resolve to true when the modal is open, or false when the modal is closed.
636
+ */
637
+ async getState() {
638
+ return this.isOpen;
639
+ }
640
+ /**
641
+ * Set the state of the modal.
642
+ * @param value The new state, set it to true to open the modal, or false to close the modal.
643
+ */
644
+ async setState(value) {
645
+ this.isOpen = value;
646
+ }
647
+ /**
648
+ * Toggle the state of the modal.
649
+ * @returns A promise which will resolve to true (if the modal opened) or false (if the modal closed).
650
+ */
651
+ async toggle() {
652
+ this.isOpen = !this.isOpen;
653
+ return this.isOpen;
654
+ }
655
+ /**
656
+ * Closes the modal.
657
+ * @returns empty Promise.
658
+ */
659
+ async close() {
660
+ this.isOpen = false;
661
+ }
662
+ /**
663
+ * Opens the modal.
664
+ * @returns empty Promise.
665
+ */
666
+ async open() {
667
+ this.isOpen = true;
668
+ }
669
+ get el() { return getElement(this); }
670
+ static get watchers() { return {
671
+ "isOpen": ["handleIsOpenChange"]
672
+ }; }
673
+ };
674
+ UofgModal.style = uofgModalCss;
675
+
676
+ export { UofgAlert as uofg_alert, UofgBackToTop as uofg_back_to_top, UofgFooter as uofg_footer, UofgHeader as uofg_header, UofgMenu as uofg_menu, UofgModal as uofg_modal };
@@ -1,5 +1,5 @@
1
- import { p as promiseResolve, b as bootstrapLazy } from './index-8ff56dd3.js';
2
- export { s as setNonce } from './index-8ff56dd3.js';
1
+ import { p as promiseResolve, b as bootstrapLazy } from './index-ebf79156.js';
2
+ export { s as setNonce } from './index-ebf79156.js';
3
3
 
4
4
  /*
5
5
  Stencil Client Patch Browser v4.0.1 | MIT Licensed | https://stenciljs.com
@@ -14,5 +14,5 @@ const patchBrowser = () => {
14
14
  };
15
15
 
16
16
  patchBrowser().then(options => {
17
- return bootstrapLazy([["uofg-back-to-top_4",[[1,"uofg-header",{"pageTitle":[1,"page-title"],"pageUrl":[1,"page-url"],"isFullSize":[32],"pageSpecificContent":[32]},[[9,"resize","updateFullSize"]]],[1,"uofg-back-to-top",{"threshold":[2],"isVisible":[32]},[[9,"scroll","onScroll"]]],[1,"uofg-footer"],[0,"uofg-menu",{"autoCollapse":[4,"auto-collapse"],"isExpanded":[32],"getExpanded":[64],"setExpanded":[64],"toggle":[64],"collapse":[64],"expand":[64]},[[0,"onChildListChange","handleChildListChange"]]]]]], options);
17
+ return bootstrapLazy([["uofg-alert_6",[[1,"uofg-header",{"pageTitle":[1,"page-title"],"pageUrl":[1,"page-url"],"isFullSize":[32],"pageSpecificContent":[32]},[[9,"resize","updateFullSize"]]],[1,"uofg-alert"],[1,"uofg-back-to-top",{"threshold":[2],"isVisible":[32]},[[9,"scroll","onScroll"]]],[1,"uofg-footer"],[1,"uofg-modal",{"label":[1],"alertDialog":[4,"alert-dialog"],"centered":[4],"staticBackdrop":[4,"static-backdrop"],"autoOpen":[4,"auto-open"],"isOpen":[32],"getState":[64],"setState":[64],"toggle":[64],"close":[64],"open":[64]}],[0,"uofg-menu",{"autoCollapse":[4,"auto-collapse"],"isExpanded":[32],"getExpanded":[64],"setExpanded":[64],"toggle":[64],"collapse":[64],"expand":[64]}]]]], options);
18
18
  });
@@ -0,0 +1,3 @@
1
+ export declare class UofgAlert {
2
+ render(): any;
3
+ }
@@ -26,12 +26,12 @@ export declare class UofgMenu {
26
26
  private button;
27
27
  private content;
28
28
  private contentComputedStyle;
29
+ private observer;
29
30
  connectedCallback(): void;
30
- private handleChildListChange;
31
+ disconnectedCallback(): void;
32
+ private handleMutation;
31
33
  private handleKeyUp;
32
- private updateButton;
33
- private updateContent;
34
- private handleButtonClick;
34
+ private handleClick;
35
35
  private handleFocusout;
36
36
  handleIsExpandedChange(newValue: boolean): void;
37
37
  private getAnimationType;
@@ -0,0 +1,61 @@
1
+ export declare class UofgModal {
2
+ /**
3
+ * The label for the modal. It is recommended that you set this to describe the modal's content.
4
+ * This is required for accessibility.
5
+ */
6
+ label: string;
7
+ /**
8
+ * Used to determine whether the modal should be rendered as an alert dialog.
9
+ * This 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.
10
+ * If this is set to true, the modal will be rendered with a role of "alertdialog" instead of "dialog".
11
+ */
12
+ alertDialog: boolean;
13
+ /**
14
+ * Used to determine whether the modal content is centered vertically.
15
+ */
16
+ centered: boolean;
17
+ /**
18
+ * Used to determine whether clicking on the backdrop of the modal will close the modal.
19
+ * If this is set to true, clicking on the backdrop will NOT close the modal.
20
+ */
21
+ staticBackdrop: boolean;
22
+ /**
23
+ * Used to determine whether the modal should open automatically when the component is first rendered.
24
+ * It is important to ensure this is only set to true for ONE modal on the page.
25
+ */
26
+ autoOpen: boolean;
27
+ isOpen: boolean;
28
+ el: HTMLUofgModalElement;
29
+ private dismissButton;
30
+ connectedCallback(): void;
31
+ handleClick(e: MouseEvent): void;
32
+ handleKeyUp(e: KeyboardEvent): void;
33
+ handleKeyDown(e: KeyboardEvent): void;
34
+ handleIsOpenChange(newValue: boolean): void;
35
+ render(): any;
36
+ /**
37
+ * Get the current state of the modal.
38
+ * @returns A promise which will resolve to true when the modal is open, or false when the modal is closed.
39
+ */
40
+ getState(): Promise<boolean>;
41
+ /**
42
+ * Set the state of the modal.
43
+ * @param value The new state, set it to true to open the modal, or false to close the modal.
44
+ */
45
+ setState(value: boolean): Promise<void>;
46
+ /**
47
+ * Toggle the state of the modal.
48
+ * @returns A promise which will resolve to true (if the modal opened) or false (if the modal closed).
49
+ */
50
+ toggle(): Promise<boolean>;
51
+ /**
52
+ * Closes the modal.
53
+ * @returns empty Promise.
54
+ */
55
+ close(): Promise<void>;
56
+ /**
57
+ * Opens the modal.
58
+ * @returns empty Promise.
59
+ */
60
+ open(): Promise<void>;
61
+ }