@internetarchive/modal-manager 1.0.3-alpha.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +1 -1
- package/.github/workflows/gh-pages-main.yml +1 -1
- package/.github/workflows/pr-preview.yml +1 -1
- package/dist/src/assets/ia-logo-icon.d.ts +2 -0
- package/dist/src/assets/ia-logo-icon.js +30 -0
- package/dist/src/assets/ia-logo-icon.js.map +1 -0
- package/dist/src/modal-template.js +2 -2
- package/dist/src/modal-template.js.map +1 -1
- package/dist/src/shoelace/active-elements.js +1 -0
- package/dist/src/shoelace/active-elements.js.map +1 -1
- package/dist/src/shoelace/modal.js +1 -0
- package/dist/src/shoelace/modal.js.map +1 -1
- package/dist/src/shoelace/tabbable.js +1 -0
- package/dist/src/shoelace/tabbable.js.map +1 -1
- package/dist/test/modal-manager.test.js +12 -17
- package/dist/test/modal-manager.test.js.map +1 -1
- package/dist/test/modal-template.test.js +23 -12
- package/dist/test/modal-template.test.js.map +1 -1
- package/package.json +1 -1
- package/src/assets/ia-logo-icon.ts +30 -0
- package/src/modal-template.ts +2 -2
- package/src/shoelace/active-elements.ts +1 -0
- package/src/shoelace/modal.ts +1 -0
- package/src/shoelace/tabbable.ts +1 -0
- package/test/modal-manager.test.ts +14 -17
- package/test/modal-template.test.ts +13 -0
package/.github/workflows/ci.yml
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
export default html `
|
|
3
|
+
<svg
|
|
4
|
+
class="ia-logo"
|
|
5
|
+
viewBox="0 0 27 30"
|
|
6
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
7
|
+
aria-labelledby="logoTitleID logoDescID"
|
|
8
|
+
>
|
|
9
|
+
<title id="logoTitleID">Internet Archive logo</title>
|
|
10
|
+
<desc id="logoDescID">
|
|
11
|
+
A line drawing of the Internet Archive headquarters building façade.
|
|
12
|
+
</desc>
|
|
13
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
14
|
+
<mask id="mask-2" class="fill-color">
|
|
15
|
+
<path
|
|
16
|
+
d="M26.6666667,28.6046512 L26.6666667,30 L0,30 L0.000283687943,28.6046512 L26.6666667,28.6046512 Z M25.6140351,26.5116279 L25.6140351,28.255814 L1.05263158,28.255814 L1.05263158,26.5116279 L25.6140351,26.5116279 Z M3.62469203,7.6744186 L3.91746909,7.82153285 L4.0639977,10.1739544 L4.21052632,13.9963932 L4.21052632,17.6725617 L4.0639977,22.255044 L4.03962296,25.3421929 L3.62469203,25.4651163 L2.16024641,25.4651163 L1.72094074,25.3421929 L1.55031755,22.255044 L1.40350877,17.6970339 L1.40350877,14.0211467 L1.55031755,10.1739544 L1.68423854,7.80887484 L1.98962322,7.6744186 L3.62469203,7.6744186 Z M24.6774869,7.6744186 L24.9706026,7.82153285 L25.1168803,10.1739544 L25.2631579,13.9963932 L25.2631579,17.6725617 L25.1168803,22.255044 L25.0927809,25.3421929 L24.6774869,25.4651163 L23.2130291,25.4651163 L22.7736357,25.3421929 L22.602418,22.255044 L22.4561404,17.6970339 L22.4561404,14.0211467 L22.602418,10.1739544 L22.7369262,7.80887484 L23.0420916,7.6744186 L24.6774869,7.6744186 Z M9.94042303,7.6744186 L10.2332293,7.82153285 L10.3797725,10.1739544 L10.5263158,13.9963932 L10.5263158,17.6725617 L10.3797725,22.255044 L10.3556756,25.3421929 L9.94042303,25.4651163 L8.47583122,25.4651163 L8.0362015,25.3421929 L7.86556129,22.255044 L7.71929825,17.6970339 L7.71929825,14.0211467 L7.86556129,10.1739544 L8.00005604,7.80887484 L8.30491081,7.6744186 L9.94042303,7.6744186 Z M18.0105985,7.6744186 L18.3034047,7.82153285 L18.449948,10.1739544 L18.5964912,13.9963932 L18.5964912,17.6725617 L18.449948,22.255044 L18.425851,25.3421929 L18.0105985,25.4651163 L16.5460067,25.4651163 L16.1066571,25.3421929 L15.9357367,22.255044 L15.7894737,17.6970339 L15.7894737,14.0211467 L15.9357367,10.1739544 L16.0702315,7.80887484 L16.3753664,7.6744186 L18.0105985,7.6744186 Z M25.6140351,4.53488372 L25.6140351,6.97674419 L1.05263158,6.97674419 L1.05263158,4.53488372 L25.6140351,4.53488372 Z M13.0806755,0 L25.9649123,2.93331338 L25.4484139,3.8372093 L0.771925248,3.8372093 L0,3.1041615 L13.0806755,0 Z"
|
|
17
|
+
id="path-1"
|
|
18
|
+
></path>
|
|
19
|
+
</mask>
|
|
20
|
+
<use class="fill-color" xlink:href="#path-1"></use>
|
|
21
|
+
<g mask="url(#mask-2)" class="fill-color">
|
|
22
|
+
<path
|
|
23
|
+
d="M0,0 L26.6666667,0 L26.6666667,30 L0,30 L0,0 Z"
|
|
24
|
+
id="swatch"
|
|
25
|
+
></path>
|
|
26
|
+
</g>
|
|
27
|
+
</g>
|
|
28
|
+
</svg>
|
|
29
|
+
`;
|
|
30
|
+
//# sourceMappingURL=ia-logo-icon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ia-logo-icon.js","sourceRoot":"","sources":["../../../src/assets/ia-logo-icon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3B,eAAe,IAAI,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BlB,CAAC","sourcesContent":["import { html } from 'lit';\n\nexport default html`\n <svg\n class=\"ia-logo\"\n viewBox=\"0 0 27 30\"\n xmlns=\"http://www.w3.org/2000/svg\"\n aria-labelledby=\"logoTitleID logoDescID\"\n >\n <title id=\"logoTitleID\">Internet Archive logo</title>\n <desc id=\"logoDescID\">\n A line drawing of the Internet Archive headquarters building façade.\n </desc>\n <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n <mask id=\"mask-2\" class=\"fill-color\">\n <path\n d=\"M26.6666667,28.6046512 L26.6666667,30 L0,30 L0.000283687943,28.6046512 L26.6666667,28.6046512 Z M25.6140351,26.5116279 L25.6140351,28.255814 L1.05263158,28.255814 L1.05263158,26.5116279 L25.6140351,26.5116279 Z M3.62469203,7.6744186 L3.91746909,7.82153285 L4.0639977,10.1739544 L4.21052632,13.9963932 L4.21052632,17.6725617 L4.0639977,22.255044 L4.03962296,25.3421929 L3.62469203,25.4651163 L2.16024641,25.4651163 L1.72094074,25.3421929 L1.55031755,22.255044 L1.40350877,17.6970339 L1.40350877,14.0211467 L1.55031755,10.1739544 L1.68423854,7.80887484 L1.98962322,7.6744186 L3.62469203,7.6744186 Z M24.6774869,7.6744186 L24.9706026,7.82153285 L25.1168803,10.1739544 L25.2631579,13.9963932 L25.2631579,17.6725617 L25.1168803,22.255044 L25.0927809,25.3421929 L24.6774869,25.4651163 L23.2130291,25.4651163 L22.7736357,25.3421929 L22.602418,22.255044 L22.4561404,17.6970339 L22.4561404,14.0211467 L22.602418,10.1739544 L22.7369262,7.80887484 L23.0420916,7.6744186 L24.6774869,7.6744186 Z M9.94042303,7.6744186 L10.2332293,7.82153285 L10.3797725,10.1739544 L10.5263158,13.9963932 L10.5263158,17.6725617 L10.3797725,22.255044 L10.3556756,25.3421929 L9.94042303,25.4651163 L8.47583122,25.4651163 L8.0362015,25.3421929 L7.86556129,22.255044 L7.71929825,17.6970339 L7.71929825,14.0211467 L7.86556129,10.1739544 L8.00005604,7.80887484 L8.30491081,7.6744186 L9.94042303,7.6744186 Z M18.0105985,7.6744186 L18.3034047,7.82153285 L18.449948,10.1739544 L18.5964912,13.9963932 L18.5964912,17.6725617 L18.449948,22.255044 L18.425851,25.3421929 L18.0105985,25.4651163 L16.5460067,25.4651163 L16.1066571,25.3421929 L15.9357367,22.255044 L15.7894737,17.6970339 L15.7894737,14.0211467 L15.9357367,10.1739544 L16.0702315,7.80887484 L16.3753664,7.6744186 L18.0105985,7.6744186 Z M25.6140351,4.53488372 L25.6140351,6.97674419 L1.05263158,6.97674419 L1.05263158,4.53488372 L25.6140351,4.53488372 Z M13.0806755,0 L25.9649123,2.93331338 L25.4484139,3.8372093 L0.771925248,3.8372093 L0,3.1041615 L13.0806755,0 Z\"\n id=\"path-1\"\n ></path>\n </mask>\n <use class=\"fill-color\" xlink:href=\"#path-1\"></use>\n <g mask=\"url(#mask-2)\" class=\"fill-color\">\n <path\n d=\"M0,0 L26.6666667,0 L26.6666667,30 L0,30 L0,0 Z\"\n id=\"swatch\"\n ></path>\n </g>\n </g>\n </svg>\n`;\n"]}
|
|
@@ -3,8 +3,8 @@ import { LitElement, html, css, nothing } from 'lit';
|
|
|
3
3
|
import { property, customElement } from 'lit/decorators.js';
|
|
4
4
|
import '@internetarchive/ia-activity-indicator/ia-activity-indicator';
|
|
5
5
|
import '@internetarchive/icon-close';
|
|
6
|
-
import iaIcon from '@internetarchive/icon-ia-logo/index.js';
|
|
7
6
|
import { ModalConfig } from './modal-config';
|
|
7
|
+
import IALogoIcon from './assets/ia-logo-icon';
|
|
8
8
|
let ModalTemplate = class ModalTemplate extends LitElement {
|
|
9
9
|
constructor() {
|
|
10
10
|
super(...arguments);
|
|
@@ -24,7 +24,7 @@ let ModalTemplate = class ModalTemplate extends LitElement {
|
|
|
24
24
|
<header style="background-color: ${this.config.headerColor}">
|
|
25
25
|
${this.config.showCloseButton ? this.closeButtonTemplate : ''}
|
|
26
26
|
${this.config.showHeaderLogo
|
|
27
|
-
? html `<div class="logo-icon">${
|
|
27
|
+
? html `<div class="logo-icon">${IALogoIcon}</div>`
|
|
28
28
|
: nothing}
|
|
29
29
|
${this.config.title
|
|
30
30
|
? html `<h1 class="title">${this.config.title}</h1>`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-template.js","sourceRoot":"","sources":["../../src/modal-template.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,8DA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;QACnE,MAAM,gBAAgB,GAAG,GAAG,CAAA,sCAAsC,CAAC;QACnE,MAAM,eAAe,GAAG,GAAG,CAAA,qCAAqC,CAAC;QAEjE,MAAM,eAAe,GAAG,GAAG,CAAA,qCAAqC,CAAC;QACjE,MAAM,kBAAkB,GAAG,GAAG,CAAA,wCAAwC,CAAC;QACvE,MAAM,kBAAkB,GAAG,GAAG,CAAA,wCAAwC,CAAC;QACvE,MAAM,iBAAiB,GAAG,GAAG,CAAA,uCAAuC,CAAC;QAErE,OAAO,GAAG,CAAA;;;iBAGG,mBAAmB;kBAClB,mBAAmB;;;;;;;;;;;;;;;;yBAgBZ,iBAAiB;;sBAEpB,iBAAiB;;;;;;;8BAOT,iBAAiB,UAAU,iBAAiB;kBACxD,WAAW;;;0BAGH,2BAA2B;;;;;;qBAMhC,aAAa;;uBAEX,eAAe;;;;;;;;qBAQjB,gBAAgB;uBACd,kBAAkB;;;;;kCAKP,iBAAiB,UAAU,iBAAiB;kBAC5D,WAAW;;+BAEE,kBAAkB,MAAM,YAAY;;;;;;;;8CAQrB,oBAAoB;;4BAEtC,YAAY;;;;qBAInB,gBAAgB;;;uBAGd,kBAAkB;;;;;;;;qBAQpB,eAAe;uBACb,iBAAiB;;;;;;;;iBAQvB,aAAa;kBACZ,aAAa;;;;;;;;;sBAST,aAAa;uBACZ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+C/B,CAAC;IACJ,CAAC;CACF,CAAA;AA7Q6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyC;AAPzD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAoRzB;SApRY,aAAa","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\n\nimport '@internetarchive/ia-activity-indicator/ia-activity-indicator';\nimport '@internetarchive/icon-close';\nimport iaIcon from '@internetarchive/icon-ia-logo/index.js';\n\nimport { ModalConfig } from './modal-config';\n\n@customElement('modal-template')\nexport class ModalTemplate extends LitElement {\n /**\n * The ModalConfig that displayed the template\n *\n * @type {ModalConfig}\n * @memberof ModalTemplate\n */\n @property({ type: Object }) config: ModalConfig = new ModalConfig();\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"modal-wrapper\">\n <div class=\"modal-container\">\n <header style=\"background-color: ${this.config.headerColor}\">\n ${this.config.showCloseButton ? this.closeButtonTemplate : ''}\n ${this.config.showHeaderLogo\n ? html`<div class=\"logo-icon\">${iaIcon}</div>`\n : nothing}\n ${this.config.title\n ? html`<h1 class=\"title\">${this.config.title}</h1>`\n : ''}\n ${this.config.subtitle\n ? html`<h2 class=\"subtitle\">${this.config.subtitle}</h2>`\n : ''}\n </header>\n <section\n class=\"modal-body\"\n style=\"background-color: ${this.config.bodyColor}\"\n >\n <div class=\"content\">\n <div\n class=\"processing-logo ${this.config.showProcessingIndicator\n ? ''\n : 'hidden'}\"\n >\n <ia-activity-indicator\n .mode=${this.config.processingImageMode}\n ></ia-activity-indicator>\n </div>\n ${this.config.headline\n ? html` <h1 class=\"headline\">${this.config.headline}</h1> `\n : ''}\n ${this.config.message\n ? html` <p class=\"message\">${this.config.message}</p> `\n : ''}\n\n <div class=\"slot-container\">\n <slot> </slot>\n </div>\n </div>\n </section>\n </div>\n </div>\n `;\n }\n\n /**\n * Dispatch the `closeButtonPressed` event to the consumer\n *\n * @private\n * @memberof ModalTemplate\n */\n private handleCloseButton(e: Event): void {\n e.preventDefault();\n if (\n e.type === 'keydown' &&\n (e as KeyboardEvent).key !== ' ' &&\n (e as KeyboardEvent).key !== 'Enter'\n ) {\n return;\n }\n const event = new Event('closeButtonPressed');\n this.dispatchEvent(event);\n }\n\n /**\n * The close button template\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof ModalTemplate\n */\n private get closeButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n class=\"close-button\"\n @click=${this.handleCloseButton}\n @keydown=${this.handleCloseButton}\n >\n <ia-icon-close></ia-icon-close>\n </button>\n `;\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;\n\n const processingImageSize = css`var(--processingImageSize, 7.5rem)`;\n\n const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;\n const modalBorder = css`var(--modalBorder, 2px solid black)`;\n // if the content of the modal is too big to fit on screen, this sets the bottom margin\n // it's not exact, but a close estimation\n const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;\n const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;\n const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;\n\n const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;\n const scrollOffset = css`var(--modalScrollOffset, 5px)`;\n\n const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;\n const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;\n const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;\n const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;\n\n const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;\n const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;\n const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;\n const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;\n\n return css`\n .processing-logo {\n margin: auto;\n width: ${processingImageSize};\n height: ${processingImageSize};\n }\n\n .processing-logo.hidden {\n height: 1rem;\n }\n\n .processing-logo.hidden ia-activity-indicator {\n display: none;\n }\n\n .modal-wrapper {\n outline: none;\n }\n\n .modal-container {\n border-radius: ${modalCornerRadius};\n width: 100%;\n margin-top: ${modalTopMarginCss};\n }\n\n header {\n position: relative;\n background-color: #36a483;\n color: white;\n border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;\n border: ${modalBorder};\n border-bottom: 0;\n text-align: center;\n padding-bottom: ${modalHeaderBottomPaddingCss};\n }\n\n .title {\n margin: 0;\n padding: 0;\n font-size: ${titleFontSize};\n font-weight: bold;\n line-height: ${titleLineHeight};\n }\n\n .subtitle {\n margin: 0;\n padding: 0;\n font-weight: normal;\n padding-top: 0;\n font-size: ${subtitleFontSize};\n line-height: ${subtitleLineHeight};\n }\n\n .modal-body {\n background-color: #f5f5f7;\n border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});\n border: ${modalBorder};\n border-top: 0;\n padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;\n color: #333;\n margin-bottom: 2.5rem;\n min-height: 5rem;\n }\n\n .content {\n overflow-y: auto;\n max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));\n min-height: 5rem;\n padding: 0 0 calc(${scrollOffset}) 0;\n }\n\n .headline {\n font-size: ${headlineFontSize};\n font-weight: bold;\n text-align: center;\n line-height: ${headlineLineHeight};\n margin: 0;\n padding: 0;\n }\n\n .message {\n margin: 1rem 0 0 0;\n text-align: center;\n font-size: ${messageFontSize};\n line-height: ${messageLineHeight};\n }\n\n .logo-icon {\n border-radius: 100%;\n border: 3px solid #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 2px 2px 0 rgba(0, 0, 0, 0.08);\n width: ${modalLogoSize};\n height: ${modalLogoSize};\n margin: -2.9rem auto 0.5rem auto;\n background-color: black;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .logo-icon svg {\n width: calc(${modalLogoSize} * 0.65);\n height: calc(${modalLogoSize} * 0.65);\n }\n\n .logo-icon svg .fill-color {\n fill: white;\n }\n\n .logo-icon svg .stroke-color {\n stroke: red;\n }\n\n .close-button {\n position: absolute;\n right: 1.2rem;\n top: 1.2rem;\n width: 2rem;\n height: 2rem;\n border-radius: 100%;\n border: 0;\n padding: 0;\n cursor: pointer;\n background-color: white;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 4px 4px 0 rgba(0, 0, 0, 0.08);\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n\n slot::slotted(.sr-only) {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"modal-template.js","sourceRoot":"","sources":["../../src/modal-template.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAA6B,OAAO,EAAE,MAAM,KAAK,CAAC;AAChF,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,8DAA8D,CAAC;AACtE,OAAO,6BAA6B,CAAC;AAErC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAGxC,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,UAAU;IAAtC;;QACL;;;;;WAKG;QACyB,WAAM,GAAgB,IAAI,WAAW,EAAE,CAAC;IA6QtE,CAAC;IA3QC,kBAAkB;IAClB,MAAM;QACJ,OAAO,IAAI,CAAA;;;6CAG8B,IAAI,CAAC,MAAM,CAAC,WAAW;cACtD,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC,EAAE;cAC3D,IAAI,CAAC,MAAM,CAAC,cAAc;YAC1B,CAAC,CAAC,IAAI,CAAA,0BAA0B,UAAU,QAAQ;YAClD,CAAC,CAAC,OAAO;cACT,IAAI,CAAC,MAAM,CAAC,KAAK;YACjB,CAAC,CAAC,IAAI,CAAA,qBAAqB,IAAI,CAAC,MAAM,CAAC,KAAK,OAAO;YACnD,CAAC,CAAC,EAAE;c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AAgB;;;uBAGd,kBAAkB;;;;;;;;qBAQpB,eAAe;uBACb,iBAAiB;;;;;;;;iBAQvB,aAAa;kBACZ,aAAa;;;;;;;;;sBAST,aAAa;uBACZ,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA+C/B,CAAC;IACJ,CAAC;CACF,CAAA;AA7Q6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAyC;AAPzD,aAAa;IADzB,aAAa,CAAC,gBAAgB,CAAC;GACnB,aAAa,CAoRzB;SApRY,aAAa","sourcesContent":["import { LitElement, html, css, CSSResult, TemplateResult, nothing } from 'lit';\nimport { property, customElement } from 'lit/decorators.js';\n\nimport '@internetarchive/ia-activity-indicator/ia-activity-indicator';\nimport '@internetarchive/icon-close';\n\nimport { ModalConfig } from './modal-config';\nimport IALogoIcon from './assets/ia-logo-icon';\n\n@customElement('modal-template')\nexport class ModalTemplate extends LitElement {\n /**\n * The ModalConfig that displayed the template\n *\n * @type {ModalConfig}\n * @memberof ModalTemplate\n */\n @property({ type: Object }) config: ModalConfig = new ModalConfig();\n\n /** @inheritdoc */\n render(): TemplateResult {\n return html`\n <div class=\"modal-wrapper\">\n <div class=\"modal-container\">\n <header style=\"background-color: ${this.config.headerColor}\">\n ${this.config.showCloseButton ? this.closeButtonTemplate : ''}\n ${this.config.showHeaderLogo\n ? html`<div class=\"logo-icon\">${IALogoIcon}</div>`\n : nothing}\n ${this.config.title\n ? html`<h1 class=\"title\">${this.config.title}</h1>`\n : ''}\n ${this.config.subtitle\n ? html`<h2 class=\"subtitle\">${this.config.subtitle}</h2>`\n : ''}\n </header>\n <section\n class=\"modal-body\"\n style=\"background-color: ${this.config.bodyColor}\"\n >\n <div class=\"content\">\n <div\n class=\"processing-logo ${this.config.showProcessingIndicator\n ? ''\n : 'hidden'}\"\n >\n <ia-activity-indicator\n .mode=${this.config.processingImageMode}\n ></ia-activity-indicator>\n </div>\n ${this.config.headline\n ? html` <h1 class=\"headline\">${this.config.headline}</h1> `\n : ''}\n ${this.config.message\n ? html` <p class=\"message\">${this.config.message}</p> `\n : ''}\n\n <div class=\"slot-container\">\n <slot> </slot>\n </div>\n </div>\n </section>\n </div>\n </div>\n `;\n }\n\n /**\n * Dispatch the `closeButtonPressed` event to the consumer\n *\n * @private\n * @memberof ModalTemplate\n */\n private handleCloseButton(e: Event): void {\n e.preventDefault();\n if (\n e.type === 'keydown' &&\n (e as KeyboardEvent).key !== ' ' &&\n (e as KeyboardEvent).key !== 'Enter'\n ) {\n return;\n }\n const event = new Event('closeButtonPressed');\n this.dispatchEvent(event);\n }\n\n /**\n * The close button template\n *\n * @readonly\n * @private\n * @type {TemplateResult}\n * @memberof ModalTemplate\n */\n private get closeButtonTemplate(): TemplateResult {\n return html`\n <button\n type=\"button\"\n class=\"close-button\"\n @click=${this.handleCloseButton}\n @keydown=${this.handleCloseButton}\n >\n <ia-icon-close></ia-icon-close>\n </button>\n `;\n }\n\n /** @inheritdoc */\n static get styles(): CSSResult {\n const modalLogoSize = css`var(--modalLogoSize, 6.5rem)`;\n\n const processingImageSize = css`var(--processingImageSize, 7.5rem)`;\n\n const modalCornerRadius = css`var(--modalCornerRadius, 1rem)`;\n const modalBorder = css`var(--modalBorder, 2px solid black)`;\n // if the content of the modal is too big to fit on screen, this sets the bottom margin\n // it's not exact, but a close estimation\n const modalBottomMarginCss = css`var(--modalBottomMargin, 2.5rem)`;\n const modalTopMarginCss = css`var(--modalTopMargin, 5rem)`;\n const modalHeaderBottomPaddingCss = css`var(--modalHeaderBottomPadding, 0.5em)`;\n\n const modalBottomPadding = css`var(--modalBottomPadding, 2rem)`;\n const scrollOffset = css`var(--modalScrollOffset, 5px)`;\n\n const titleFontSize = css`var(--modalTitleFontSize, 1.8rem)`;\n const subtitleFontSize = css`var(--modalSubtitleFontSize, 1.4rem)`;\n const headlineFontSize = css`var(--modalHeadlineFontSize, 1.6rem)`;\n const messageFontSize = css`var(--modalMessageFontSize, 1.4rem)`;\n\n const titleLineHeight = css`var(--modalTitleLineHeight, normal)`;\n const subtitleLineHeight = css`var(--modalSubtitleLineHeight, normal)`;\n const headlineLineHeight = css`var(--modalHeadlineLineHeight, normal)`;\n const messageLineHeight = css`var(--modalMessageLineHeight, normal)`;\n\n return css`\n .processing-logo {\n margin: auto;\n width: ${processingImageSize};\n height: ${processingImageSize};\n }\n\n .processing-logo.hidden {\n height: 1rem;\n }\n\n .processing-logo.hidden ia-activity-indicator {\n display: none;\n }\n\n .modal-wrapper {\n outline: none;\n }\n\n .modal-container {\n border-radius: ${modalCornerRadius};\n width: 100%;\n margin-top: ${modalTopMarginCss};\n }\n\n header {\n position: relative;\n background-color: #36a483;\n color: white;\n border-radius: calc(${modalCornerRadius}) calc(${modalCornerRadius}) 0 0;\n border: ${modalBorder};\n border-bottom: 0;\n text-align: center;\n padding-bottom: ${modalHeaderBottomPaddingCss};\n }\n\n .title {\n margin: 0;\n padding: 0;\n font-size: ${titleFontSize};\n font-weight: bold;\n line-height: ${titleLineHeight};\n }\n\n .subtitle {\n margin: 0;\n padding: 0;\n font-weight: normal;\n padding-top: 0;\n font-size: ${subtitleFontSize};\n line-height: ${subtitleLineHeight};\n }\n\n .modal-body {\n background-color: #f5f5f7;\n border-radius: 0 0 calc(${modalCornerRadius}) calc(${modalCornerRadius});\n border: ${modalBorder};\n border-top: 0;\n padding: 0 1rem calc(${modalBottomPadding} - ${scrollOffset}) 1rem;\n color: #333;\n margin-bottom: 2.5rem;\n min-height: 5rem;\n }\n\n .content {\n overflow-y: auto;\n max-height: calc(100vh - (16.5rem + ${modalBottomMarginCss}));\n min-height: 5rem;\n padding: 0 0 calc(${scrollOffset}) 0;\n }\n\n .headline {\n font-size: ${headlineFontSize};\n font-weight: bold;\n text-align: center;\n line-height: ${headlineLineHeight};\n margin: 0;\n padding: 0;\n }\n\n .message {\n margin: 1rem 0 0 0;\n text-align: center;\n font-size: ${messageFontSize};\n line-height: ${messageLineHeight};\n }\n\n .logo-icon {\n border-radius: 100%;\n border: 3px solid #fff;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 2px 2px 0 rgba(0, 0, 0, 0.08);\n width: ${modalLogoSize};\n height: ${modalLogoSize};\n margin: -2.9rem auto 0.5rem auto;\n background-color: black;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .logo-icon svg {\n width: calc(${modalLogoSize} * 0.65);\n height: calc(${modalLogoSize} * 0.65);\n }\n\n .logo-icon svg .fill-color {\n fill: white;\n }\n\n .logo-icon svg .stroke-color {\n stroke: red;\n }\n\n .close-button {\n position: absolute;\n right: 1.2rem;\n top: 1.2rem;\n width: 2rem;\n height: 2rem;\n border-radius: 100%;\n border: 0;\n padding: 0;\n cursor: pointer;\n background-color: white;\n box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.18),\n 0 4px 4px 0 rgba(0, 0, 0, 0.08);\n }\n\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n\n slot::slotted(.sr-only) {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n border: 0;\n }\n `;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"active-elements.js","sourceRoot":"","sources":["../../../src/shoelace/active-elements.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,MAAM,SAAS,CAAC,CAAC,cAAc,CAC7B,gBAAgC,QAAQ,CAAC,aAAa;IAEtD,IAAI,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO;IAElE,MAAM,aAAa,CAAC;IAEpB,IACE,YAAY,IAAI,aAAa;QAC7B,aAAa,CAAC,UAAU;QACxB,aAAa,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,EAC1C;QACA,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;KAC/D;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/**\n * Use a generator so we can iterate and possibly break early.\n * @example\n * // to operate like a regular array. This kinda nullifies generator benefits, but worth knowing if you need the whole array.\n * const allActiveElements = [...activeElements()]\n *\n * // Early return\n * for (const activeElement of activeElements()) {\n * if (<cond>) {\n * break; // Break the loop, dont need to iterate over the whole array or store an array in memory!\n * }\n * }\n */\nexport function* activeElements(\n activeElement: Element | null = document.activeElement\n): Generator<Element> {\n if (activeElement === null || activeElement === undefined) return;\n\n yield activeElement;\n\n if (\n 'shadowRoot' in activeElement &&\n activeElement.shadowRoot &&\n activeElement.shadowRoot.mode !== 'closed'\n ) {\n yield* activeElements(activeElement.shadowRoot.activeElement);\n }\n}\n\nexport function getDeepestActiveElement() {\n return [...activeElements()].pop();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"active-elements.js","sourceRoot":"","sources":["../../../src/shoelace/active-elements.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B;;;;;;;;;;;;GAYG;AACH,MAAM,SAAS,CAAC,CAAC,cAAc,CAC7B,gBAAgC,QAAQ,CAAC,aAAa;IAEtD,IAAI,aAAa,KAAK,IAAI,IAAI,aAAa,KAAK,SAAS;QAAE,OAAO;IAElE,MAAM,aAAa,CAAC;IAEpB,IACE,YAAY,IAAI,aAAa;QAC7B,aAAa,CAAC,UAAU;QACxB,aAAa,CAAC,UAAU,CAAC,IAAI,KAAK,QAAQ,EAC1C;QACA,KAAK,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;KAC/D;AACH,CAAC;AAED,MAAM,UAAU,uBAAuB;IACrC,OAAO,CAAC,GAAG,cAAc,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC;AACrC,CAAC","sourcesContent":["/* istanbul ignore file */\n/**\n * Use a generator so we can iterate and possibly break early.\n * @example\n * // to operate like a regular array. This kinda nullifies generator benefits, but worth knowing if you need the whole array.\n * const allActiveElements = [...activeElements()]\n *\n * // Early return\n * for (const activeElement of activeElements()) {\n * if (<cond>) {\n * break; // Break the loop, dont need to iterate over the whole array or store an array in memory!\n * }\n * }\n */\nexport function* activeElements(\n activeElement: Element | null = document.activeElement\n): Generator<Element> {\n if (activeElement === null || activeElement === undefined) return;\n\n yield activeElement;\n\n if (\n 'shadowRoot' in activeElement &&\n activeElement.shadowRoot &&\n activeElement.shadowRoot.mode !== 'closed'\n ) {\n yield* activeElements(activeElement.shadowRoot.activeElement);\n }\n}\n\nexport function getDeepestActiveElement() {\n return [...activeElements()].pop();\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sourceRoot":"","sources":["../../../src/shoelace/modal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEpD,IAAI,YAAY,GAAkB,EAAE,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,KAAK;IAQxB,YAAY,OAAoB;QANhC,wBAAmB,GAAY,KAAK,CAAC;QACrC,iBAAY,GAA2B,SAAS,CAAC;QACjD,iBAAY,GAAuB,IAAI,CAAC;QACxC,kBAAa,GAAuB,IAAI,CAAC;QA0DjC,kBAAa,GAAG,GAAG,EAAE;YAC3B,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;gBAAE,OAAO;YAC7B,IAAI,CAAC,UAAU,EAAE,CAAC;QACpB,CAAC,CAAC;QAWM,kBAAa,GAAG,CAAC,KAAoB,EAAE,EAAE;;YAC/C,IAAI,KAAK,CAAC,GAAG,KAAK,KAAK,IAAI,IAAI,CAAC,mBAAmB;gBAAE,OAAO;YAC5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AAC;gBAC1D,MAAM,MAAM,GAAG,IAAI,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;gBAE7D,IAAI,OAAO,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAA,KAAK,UAAU,EAAE;oBACvC,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC;oBAC3B,MAAM,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC,CAAC;iBACxC;aACF;SACF;IACH,CAAC;IAOO,2BAA2B,CAAC,OAAoB;QACtD,OAAO,CACL,IAAI,CAAC,4BAA4B,CAAC,QAAQ,CACxC,OAAO,CAAC,OAAO,CAAC,WAAW,EAAE,CAC9B,IAAI,OAAO,CAAC,YAAY,CAAC,UAAU,CAAC;QACrC,+IAA+I;SAChJ,CAAC;IACJ,CAAC;CAoFF","sourcesContent":["/* istanbul ignore file */\nimport { activeElements, getDeepestActiveElement } from './active-elements.js';\nimport { getTabbableElements } from './tabbable.js';\n\nlet activeModals: HTMLElement[] = [];\n\nexport default class Modal {\n element: HTMLElement;\n isExternalActivated: boolean = false;\n tabDirection: 'forward' | 'backward' = 'forward';\n currentFocus: HTMLElement | null = null;\n previousFocus: HTMLElement | null = null;\n elementsWithTabbableControls: string[];\n\n constructor(element: HTMLElement) {\n this.element = element;\n\n this.elementsWithTabbableControls = ['iframe'];\n }\n\n /** Activates focus trapping. */\n activate() {\n activeModals.push(this.element);\n document.addEventListener('focusin', this.handleFocusIn);\n document.addEventListener('keydown', this.handleKeyDown);\n document.addEventListener('keyup', this.handleKeyUp);\n }\n\n /** Deactivates focus trapping. */\n deactivate() {\n activeModals = activeModals.filter(modal => modal !== this.element);\n this.currentFocus = null;\n document.removeEventListener('focusin', this.handleFocusIn);\n document.removeEventListener('keydown', this.handleKeyDown);\n document.removeEventListener('keyup', this.handleKeyUp);\n }\n\n /** Determines if this modal element is currently active or not. */\n isActive() {\n // The \"active\" modal is always the most recent one shown\n return activeModals[activeModals.length - 1] === this.element;\n }\n\n /** Activates external modal behavior and temporarily disables focus trapping. */\n activateExternal() {\n this.isExternalActivated = true;\n }\n\n /** Deactivates external modal behavior and re-enables focus trapping. */\n deactivateExternal() {\n this.isExternalActivated = false;\n }\n\n private checkFocus() {\n if (this.isActive() && !this.isExternalActivated) {\n const tabbableElements = getTabbableElements(this.element);\n if (!this.element.matches(':focus-within')) {\n const start = tabbableElements[0];\n const end = tabbableElements[tabbableElements.length - 1];\n const target = this.tabDirection === 'forward' ? start : end;\n\n if (typeof target?.focus === 'function') {\n this.currentFocus = target;\n target.focus({ preventScroll: false });\n }\n }\n }\n }\n\n private handleFocusIn = () => {\n if (!this.isActive()) return;\n this.checkFocus();\n };\n\n private possiblyHasTabbableChildren(element: HTMLElement) {\n return (\n this.elementsWithTabbableControls.includes(\n element.tagName.toLowerCase()\n ) || element.hasAttribute('controls')\n // Should we add a data-attribute for people to set just in case they have an element where we don't know if it has possibly tabbable elements?\n );\n }\n\n private handleKeyDown = (event: KeyboardEvent) => {\n if (event.key !== 'Tab' || this.isExternalActivated) return;\n if (!this.isActive()) return;\n\n // Because sometimes focus can actually be taken over from outside sources,\n // we don't want to rely on `this.currentFocus`. Instead we check the actual `activeElement` and\n // recurse through shadowRoots.\n const currentActiveElement = getDeepestActiveElement();\n this.previousFocus = currentActiveElement as HTMLElement | null;\n\n if (\n this.previousFocus &&\n this.possiblyHasTabbableChildren(this.previousFocus)\n ) {\n return;\n }\n\n if (event.shiftKey) {\n this.tabDirection = 'backward';\n } else {\n this.tabDirection = 'forward';\n }\n\n const tabbableElements = getTabbableElements(this.element);\n\n let currentFocusIndex = tabbableElements.findIndex(\n el => el === currentActiveElement\n );\n\n this.previousFocus = this.currentFocus;\n\n const addition = this.tabDirection === 'forward' ? 1 : -1;\n\n // eslint-disable-next-line\n while (true) {\n if (currentFocusIndex + addition >= tabbableElements.length) {\n currentFocusIndex = 0;\n } else if (currentFocusIndex + addition < 0) {\n currentFocusIndex = tabbableElements.length - 1;\n } else {\n currentFocusIndex += addition;\n }\n\n this.previousFocus = this.currentFocus;\n const nextFocus =\n /** @type {HTMLElement} */ tabbableElements[currentFocusIndex];\n\n // This is a special case. We need to make sure we're not calling .focus() if we're already focused on an element\n // that possibly has \"controls\"\n if (this.tabDirection === 'backward') {\n if (\n this.previousFocus &&\n this.possiblyHasTabbableChildren(this.previousFocus)\n ) {\n return;\n }\n }\n\n if (nextFocus && this.possiblyHasTabbableChildren(nextFocus)) {\n return;\n }\n\n event.preventDefault();\n this.currentFocus = nextFocus;\n this.currentFocus?.focus({ preventScroll: false });\n\n // Check to make sure focus actually changed. It may not always be the next focus, we just don't want it to be the previousFocus.\n const allActiveElements = [...activeElements()];\n if (\n allActiveElements.includes(this.currentFocus) ||\n !allActiveElements.includes(this.previousFocus!)\n ) {\n break;\n }\n }\n\n setTimeout(() => this.checkFocus());\n };\n\n private handleKeyUp = () => {\n this.tabDirection = 'forward';\n };\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tabbable.js","sourceRoot":"","sources":["../../../src/shoelace/tabbable.ts"],"names":[],"mappings":"AAAA,uGAAuG;AACvG,wFAAwF;AACxF,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAgC,CAAC;AAErE,SAAS,sBAAsB,CAAC,EAAe;IAC7C,IAAI,aAAa,GAAoC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAE9E,IAAI,CAAC,aAAa,EAAE;QAClB,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAClD,gBAAgB,CAAC,GAAG,CAAC,EAAE,EAAE,aAAa,CAAC,CAAC;KACzC;IAED,OAAO,aAAa,CAAC;AACvB,CAAC;AAED,SAAS,SAAS,CAAC,EAAe;IAChC,4DAA4D;IAC5D,IAAI,iBAAiB,IAAI,EAAE,IAAI,OAAO,EAAE,CAAC,iBA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AAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,EAAE,CAAC,IAAI,UAAU,CAAC,EAAE,CAAC,EAAE;gBACpD,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;aAC3B;YAED,IACE,EAAE,YAAY,eAAe;gBAC7B,oCAAoC,CAAC,EAAE,EAAE,IAAI,CAAC,EAC9C;gBACA,EAAE,CAAC,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,OAAO,CAC5C,CAAC,UAAmB,EAAE,EAAE;oBACtB,IAAI,CAAC,UAAsC,CAAC,CAAC;gBAC/C,CAAC,CACF,CAAC;aACH;YAED,IAAI,EAAE,CAAC,UAAU,KAAK,IAAI,IAAI,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,MAAM,EAAE;gBAC3D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,CAAC;aACrB;SACF;QAED,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAkB,EAAE;YACxD,IAAI,CAAC,CAAC,CAAC,CAAC;SACT;IACH,CAAC;IAED,0CAA0C;IAC1C,IAAI,CAAC,IAAI,CAAC,CAAC;IAEX,yHAAyH;IACzH,uCAAuC;IACvC,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACpC,iCAAiC;QACjC,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1D,MAAM,SAAS,GAAG,MAAM,CAAC,CAAC,CAAC,YAAY,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1D,OAAO,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["// Cached compute style calls. This is specifically for browsers that dont support `checkVisibility()`.\n// computedStyle calls are \"live\" so they only need to be retrieved once for an element.\nconst computedStyleMap = new WeakMap<Element, CSSStyleDeclaration>();\n\nfunction getCachedComputedStyle(el: HTMLElement): CSSStyleDeclaration {\n let computedStyle: undefined | CSSStyleDeclaration = computedStyleMap.get(el);\n\n if (!computedStyle) {\n computedStyle = window.getComputedStyle(el, null);\n computedStyleMap.set(el, computedStyle);\n }\n\n return computedStyle;\n}\n\nfunction isVisible(el: HTMLElement): boolean {\n // This is the fastest check, but isn't supported in Safari.\n if ('checkVisibility' in el && typeof el['checkVisibility'] === 'function') {\n // Opacity is focusable, visibility is not.\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n return (el as any)['checkVisibility']({\n checkOpacity: false,\n checkVisibilityCSS: true,\n });\n }\n\n // Fallback \"polyfill\" for \"checkVisibility\"\n const computedStyle = getCachedComputedStyle(el as HTMLElement);\n\n return (\n computedStyle.visibility !== 'hidden' && computedStyle.display !== 'none'\n );\n}\n\n// While this behavior isn't standard in Safari / Chrome yet, I think it's the most reasonable\n// way of handling tabbable overflow areas. Browser sniffing seems gross, and it's the most\n// accessible way of handling overflow areas. [Konnor]\nfunction isOverflowingAndTabbable(el: HTMLElement): boolean {\n const computedStyle = getCachedComputedStyle(el);\n\n const { overflowY, overflowX } = computedStyle;\n\n if (overflowY === 'scroll' || overflowX === 'scroll') {\n return true;\n }\n\n if (overflowY !== 'auto' || overflowX !== 'auto') {\n return false;\n }\n\n // Always overflow === \"auto\" by this point\n const isOverflowingY = el.scrollHeight > el.clientHeight;\n\n if (isOverflowingY && overflowY === 'auto') {\n return true;\n }\n\n const isOverflowingX = el.scrollWidth > el.clientWidth;\n\n if (isOverflowingX && overflowX === 'auto') {\n return true;\n }\n\n return false;\n}\n\n/** Determines if the specified element is tabbable using heuristics inspired by https://github.com/focus-trap/tabbable */\nfunction isTabbable(el: HTMLElement) {\n const tag = el.tagName.toLowerCase();\n\n const tabindex = Number(el.getAttribute('tabindex'));\n const hasTabindex = el.hasAttribute('tabindex');\n\n // elements with a tabindex attribute that is either NaN or <= -1 are not tabbable\n if (hasTabindex && (isNaN(tabindex) || tabindex <= -1)) {\n return false;\n }\n\n // Elements with a disabled attribute are not tabbable\n if (el.hasAttribute('disabled')) {\n return false;\n }\n\n // If any parents have \"inert\", we aren't \"tabbable\"\n if (el.closest('[inert]')) {\n return false;\n }\n\n // Radios without a checked attribute are not tabbable\n if (\n tag === 'input' &&\n el.getAttribute('type') === 'radio' &&\n !el.hasAttribute('checked')\n ) {\n return false;\n }\n\n if (!isVisible(el)) {\n return false;\n }\n\n // Audio and video elements with the controls attribute are tabbable\n if ((tag === 'audio' || tag === 'video') && el.hasAttribute('controls')) {\n return true;\n }\n\n // Elements with a tabindex other than -1 are tabbable\n if (el.hasAttribute('tabindex')) {\n return true;\n }\n\n // Elements with a contenteditable attribute are tabbable\n if (\n el.hasAttribute('contenteditable') &&\n el.getAttribute('contenteditable') !== 'false'\n ) {\n return true;\n }\n\n // At this point, the following elements are considered tabbable\n const isNativelyTabbable = [\n 'button',\n 'input',\n 'select',\n 'textarea',\n 'a',\n 'audio',\n 'video',\n 'summary',\n 'iframe',\n ].includes(tag);\n\n if (isNativelyTabbable) {\n return true;\n }\n\n // We save the overflow checks for last, because they're the most expensive\n return isOverflowingAndTabbable(el);\n}\n\n/**\n * Returns the first and last bounding elements that are tabbable. This is more performant than checking every single\n * element because it short-circuits after finding the first and last ones.\n */\nexport function getTabbableBoundary(root: HTMLElement | ShadowRoot) {\n const tabbableElements = getTabbableElements(root);\n\n // Find the first and last tabbable elements\n const start = tabbableElements[0] ?? null;\n const end = tabbableElements[tabbableElements.length - 1] ?? null;\n\n return { start, end };\n}\n\n/**\n * This looks funky. Basically a slot's children will always be picked up *if* they're within the `root` element.\n * However, there is an edge case when, if the `root` is wrapped by another shadow DOM, it won't grab the children.\n * This fixes that fun edge case.\n */\nfunction getSlottedChildrenOutsideRootElement(\n slotElement: HTMLSlotElement,\n root: HTMLElement | ShadowRoot\n) {\n return (\n (slotElement.getRootNode({ composed: true }) as ShadowRoot | null)?.host !==\n root\n );\n}\n\nexport function getTabbableElements(root: HTMLElement | ShadowRoot) {\n const walkedEls = new WeakMap();\n const tabbableElements: HTMLElement[] = [];\n\n function walk(el: HTMLElement | ShadowRoot) {\n if (el instanceof Element) {\n // if the element has \"inert\" we can just no-op it.\n if (el.hasAttribute('inert') || el.closest('[inert]')) {\n return;\n }\n\n if (walkedEls.has(el)) {\n return;\n }\n walkedEls.set(el, true);\n\n if (!tabbableElements.includes(el) && isTabbable(el)) {\n tabbableElements.push(el);\n }\n\n if (\n el instanceof HTMLSlotElement &&\n getSlottedChildrenOutsideRootElement(el, root)\n ) {\n el.assignedElements({ flatten: true }).forEach(\n (assignedEl: Element) => {\n walk(assignedEl as HTMLElement | ShadowRoot);\n }\n );\n }\n\n if (el.shadowRoot !== null && el.shadowRoot.mode === 'open') {\n walk(el.shadowRoot);\n }\n }\n\n for (const e of Array.from(el.children) as HTMLElement[]) {\n walk(e);\n }\n }\n\n // Collect all elements including the root\n walk(root);\n\n // Is this worth having? Most sorts will always add increased overhead. And positive tabindexes shouldn't really be used.\n // So is it worth being right? Or fast?\n return tabbableElements.sort((a, b) => {\n // Make sure we sort by tabindex.\n const aTabindex = Number(a.getAttribute('tabindex')) || 0;\n const bTabindex = Number(b.getAttribute('tabindex')) || 0;\n return bTabindex - aTabindex;\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tabbable.js","sourceRoot":"","sources":["../../../src/shoelace/tabbable.ts"],"names":[],"mappings":"AAAA,0BAA0B;AAC1B,uGAAuG;AACvG,wFAAwF;AACxF,MAAM,gBAAgB,GAAG,IAAI,OAAO,EAAgC,CAAC;AAErE,SAAS,sBAAsB,CAAC,EAAe;IAC7C,IAAI,aAAa,GAAoC,gBAAgB,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAE9E,IAAI,CAAC,aAAa,EAAE;QAClB,aAAa,GAAG,MAAM,CAAC,gBAAgB,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;QAClD,gBAAgB,CAAC,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C,IAAI,CAAC,CAAC;QAC1D,OAAO,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["/* istanbul ignore file */\n// Cached compute style calls. This is specifically for browsers that dont support `checkVisibility()`.\n// computedStyle calls are \"live\" so they only need to be retrieved once for an element.\nconst computedStyleMap = new WeakMap<Element, CSSStyleDeclaration>();\n\nfunction getCachedComputedStyle(el: HTMLElement): CSSStyleDeclaration {\n let computedStyle: undefined | CSSStyleDeclaration = computedStyleMap.get(el);\n\n if (!computedStyle) {\n computedStyle = window.getComputedStyle(el, null);\n computedStyleMap.set(el, computedStyle);\n }\n\n return computedStyle;\n}\n\nfunction isVisible(el: HTMLElement): boolean {\n // This is the fastest check, but isn't supported in Safari.\n if ('checkVisibility' in el && typeof el['checkVisibility'] === 'function') {\n // Opacity is focusable, visibility is not.\n /* eslint-disable-next-line @typescript-eslint/no-explicit-any */\n return (el as any)['checkVisibility']({\n checkOpacity: false,\n checkVisibilityCSS: true,\n });\n }\n\n // Fallback \"polyfill\" for \"checkVisibility\"\n const computedStyle = getCachedComputedStyle(el as HTMLElement);\n\n return (\n computedStyle.visibility !== 'hidden' && computedStyle.display !== 'none'\n );\n}\n\n// While this behavior isn't standard in Safari / Chrome yet, I think it's the most reasonable\n// way of handling tabbable overflow areas. Browser sniffing seems gross, and it's the most\n// accessible way of handling overflow areas. [Konnor]\nfunction isOverflowingAndTabbable(el: HTMLElement): boolean {\n const computedStyle = getCachedComputedStyle(el);\n\n const { overflowY, overflowX } = computedStyle;\n\n if (overflowY === 'scroll' || overflowX === 'scroll') {\n return true;\n }\n\n if (overflowY !== 'auto' || overflowX !== 'auto') {\n return false;\n }\n\n // Always overflow === \"auto\" by this point\n const isOverflowingY = el.scrollHeight > el.clientHeight;\n\n if (isOverflowingY && overflowY === 'auto') {\n return true;\n }\n\n const isOverflowingX = el.scrollWidth > el.clientWidth;\n\n if (isOverflowingX && overflowX === 'auto') {\n return true;\n }\n\n return false;\n}\n\n/** Determines if the specified element is tabbable using heuristics inspired by https://github.com/focus-trap/tabbable */\nfunction isTabbable(el: HTMLElement) {\n const tag = el.tagName.toLowerCase();\n\n const tabindex = Number(el.getAttribute('tabindex'));\n const hasTabindex = el.hasAttribute('tabindex');\n\n // elements with a tabindex attribute that is either NaN or <= -1 are not tabbable\n if (hasTabindex && (isNaN(tabindex) || tabindex <= -1)) {\n return false;\n }\n\n // Elements with a disabled attribute are not tabbable\n if (el.hasAttribute('disabled')) {\n return false;\n }\n\n // If any parents have \"inert\", we aren't \"tabbable\"\n if (el.closest('[inert]')) {\n return false;\n }\n\n // Radios without a checked attribute are not tabbable\n if (\n tag === 'input' &&\n el.getAttribute('type') === 'radio' &&\n !el.hasAttribute('checked')\n ) {\n return false;\n }\n\n if (!isVisible(el)) {\n return false;\n }\n\n // Audio and video elements with the controls attribute are tabbable\n if ((tag === 'audio' || tag === 'video') && el.hasAttribute('controls')) {\n return true;\n }\n\n // Elements with a tabindex other than -1 are tabbable\n if (el.hasAttribute('tabindex')) {\n return true;\n }\n\n // Elements with a contenteditable attribute are tabbable\n if (\n el.hasAttribute('contenteditable') &&\n el.getAttribute('contenteditable') !== 'false'\n ) {\n return true;\n }\n\n // At this point, the following elements are considered tabbable\n const isNativelyTabbable = [\n 'button',\n 'input',\n 'select',\n 'textarea',\n 'a',\n 'audio',\n 'video',\n 'summary',\n 'iframe',\n ].includes(tag);\n\n if (isNativelyTabbable) {\n return true;\n }\n\n // We save the overflow checks for last, because they're the most expensive\n return isOverflowingAndTabbable(el);\n}\n\n/**\n * Returns the first and last bounding elements that are tabbable. This is more performant than checking every single\n * element because it short-circuits after finding the first and last ones.\n */\nexport function getTabbableBoundary(root: HTMLElement | ShadowRoot) {\n const tabbableElements = getTabbableElements(root);\n\n // Find the first and last tabbable elements\n const start = tabbableElements[0] ?? null;\n const end = tabbableElements[tabbableElements.length - 1] ?? null;\n\n return { start, end };\n}\n\n/**\n * This looks funky. Basically a slot's children will always be picked up *if* they're within the `root` element.\n * However, there is an edge case when, if the `root` is wrapped by another shadow DOM, it won't grab the children.\n * This fixes that fun edge case.\n */\nfunction getSlottedChildrenOutsideRootElement(\n slotElement: HTMLSlotElement,\n root: HTMLElement | ShadowRoot\n) {\n return (\n (slotElement.getRootNode({ composed: true }) as ShadowRoot | null)?.host !==\n root\n );\n}\n\nexport function getTabbableElements(root: HTMLElement | ShadowRoot) {\n const walkedEls = new WeakMap();\n const tabbableElements: HTMLElement[] = [];\n\n function walk(el: HTMLElement | ShadowRoot) {\n if (el instanceof Element) {\n // if the element has \"inert\" we can just no-op it.\n if (el.hasAttribute('inert') || el.closest('[inert]')) {\n return;\n }\n\n if (walkedEls.has(el)) {\n return;\n }\n walkedEls.set(el, true);\n\n if (!tabbableElements.includes(el) && isTabbable(el)) {\n tabbableElements.push(el);\n }\n\n if (\n el instanceof HTMLSlotElement &&\n getSlottedChildrenOutsideRootElement(el, root)\n ) {\n el.assignedElements({ flatten: true }).forEach(\n (assignedEl: Element) => {\n walk(assignedEl as HTMLElement | ShadowRoot);\n }\n );\n }\n\n if (el.shadowRoot !== null && el.shadowRoot.mode === 'open') {\n walk(el.shadowRoot);\n }\n }\n\n for (const e of Array.from(el.children) as HTMLElement[]) {\n walk(e);\n }\n }\n\n // Collect all elements including the root\n walk(root);\n\n // Is this worth having? Most sorts will always add increased overhead. And positive tabindexes shouldn't really be used.\n // So is it worth being right? Or fast?\n return tabbableElements.sort((a, b) => {\n // Make sure we sort by tabindex.\n const aTabindex = Number(a.getAttribute('tabindex')) || 0;\n const bTabindex = Number(b.getAttribute('tabindex')) || 0;\n return bTabindex - aTabindex;\n });\n}\n"]}
|
|
@@ -122,29 +122,23 @@ describe('Modal Manager', () => {
|
|
|
122
122
|
yield elementUpdated(el);
|
|
123
123
|
expect(callbackCalled).to.equal(false);
|
|
124
124
|
}));
|
|
125
|
-
it('
|
|
125
|
+
it('mode is set to closed when close button is pressed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
126
|
var _c, _d;
|
|
127
127
|
const el = (yield fixture(html `
|
|
128
128
|
<modal-manager></modal-manager>
|
|
129
129
|
`));
|
|
130
130
|
const config = new ModalConfig();
|
|
131
|
-
|
|
132
|
-
const callback = () => {
|
|
133
|
-
callbackCalled = true;
|
|
134
|
-
};
|
|
135
|
-
el.showModal({
|
|
136
|
-
config,
|
|
137
|
-
userClosedModalCallback: callback,
|
|
138
|
-
});
|
|
131
|
+
el.showModal({ config });
|
|
139
132
|
yield elementUpdated(el);
|
|
133
|
+
expect(el.mode).to.equal('open');
|
|
140
134
|
const modal = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('modal-template');
|
|
141
135
|
const closeButton = (_d = modal === null || modal === void 0 ? void 0 : modal.shadowRoot) === null || _d === void 0 ? void 0 : _d.querySelector('.close-button');
|
|
142
136
|
const clickEvent = new MouseEvent('click');
|
|
143
137
|
closeButton === null || closeButton === void 0 ? void 0 : closeButton.dispatchEvent(clickEvent);
|
|
144
138
|
yield elementUpdated(el);
|
|
145
|
-
expect(
|
|
139
|
+
expect(el.mode).to.equal('closed');
|
|
146
140
|
}));
|
|
147
|
-
it('mode is set to closed when close button
|
|
141
|
+
it('mode is set to closed when close button gets spacebar pressed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
148
142
|
var _e, _f;
|
|
149
143
|
const el = (yield fixture(html `
|
|
150
144
|
<modal-manager></modal-manager>
|
|
@@ -155,12 +149,13 @@ describe('Modal Manager', () => {
|
|
|
155
149
|
expect(el.mode).to.equal('open');
|
|
156
150
|
const modal = (_e = el.shadowRoot) === null || _e === void 0 ? void 0 : _e.querySelector('modal-template');
|
|
157
151
|
const closeButton = (_f = modal === null || modal === void 0 ? void 0 : modal.shadowRoot) === null || _f === void 0 ? void 0 : _f.querySelector('.close-button');
|
|
158
|
-
|
|
159
|
-
|
|
152
|
+
// Close with keyboard
|
|
153
|
+
const spacebarEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
154
|
+
closeButton === null || closeButton === void 0 ? void 0 : closeButton.dispatchEvent(spacebarEvent);
|
|
160
155
|
yield elementUpdated(el);
|
|
161
156
|
expect(el.mode).to.equal('closed');
|
|
162
157
|
}));
|
|
163
|
-
it('mode
|
|
158
|
+
it('mode remains open when close button gets non-button keypress', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
159
|
var _g, _h;
|
|
165
160
|
const el = (yield fixture(html `
|
|
166
161
|
<modal-manager></modal-manager>
|
|
@@ -172,10 +167,10 @@ describe('Modal Manager', () => {
|
|
|
172
167
|
const modal = (_g = el.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelector('modal-template');
|
|
173
168
|
const closeButton = (_h = modal === null || modal === void 0 ? void 0 : modal.shadowRoot) === null || _h === void 0 ? void 0 : _h.querySelector('.close-button');
|
|
174
169
|
// Close with keyboard
|
|
175
|
-
const
|
|
176
|
-
closeButton === null || closeButton === void 0 ? void 0 : closeButton.dispatchEvent(
|
|
170
|
+
const keyboardEvent = new KeyboardEvent('keydown', { key: '.' });
|
|
171
|
+
closeButton === null || closeButton === void 0 ? void 0 : closeButton.dispatchEvent(keyboardEvent);
|
|
177
172
|
yield elementUpdated(el);
|
|
178
|
-
expect(el.mode).to.equal('
|
|
173
|
+
expect(el.mode).to.equal('open');
|
|
179
174
|
}));
|
|
180
175
|
it('allows the user to close by clicking on the backdrop if configured to', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
181
176
|
var _j;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-manager.test.js","sourceRoot":"","sources":["../../test/modal-manager.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3C,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,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AK,aAAL,KAAK,uBAAL,KAAK,CAAE,UAAU,0CAAE,aAA4B,CAAC;QAEtE,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE5C,YAAY;QACZ,EAAE,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC3B,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,sCAAsC;QACtC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE5C,cAAc;QACd,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,SAAS,EAAE;YACjD,GAAG,EAAE,KAAK;YACV,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACtC,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,sCAAsC;QACtC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, oneEvent, elementUpdated } from '@open-wc/testing';\nimport { TemplateResult, html } from 'lit';\n\nimport '../src/modal-manager';\nimport { ModalConfig } from '../src/modal-config';\nimport { ModalManager } from '../src/modal-manager';\nimport { ModalManagerMode } from '../src/modal-manager-mode';\nimport { ModalManagerInterface } from '../src/modal-manager-interface';\n\nimport { getTabbableElements } from '../src/shoelace/tabbable';\n\ndescribe('Modal Manager', () => {\n it('defaults to closed', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n expect(el.mode).to.equal('closed');\n });\n\n it('can be closed by calling closeModal', async () => {\n const el = (await fixture(html`\n <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>\n `)) as ModalManager;\n\n el.customModalContent = 'foo' as unknown as TemplateResult;\n await elementUpdated(el);\n\n expect(el.customModalContent).to.equal('foo');\n el.closeModal();\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n expect(el.customModalContent).to.equal(undefined);\n });\n\n it('can be closed by clicking on the backdrop', async () => {\n const el = (await fixture(html`\n <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>\n `)) as ModalManager;\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n\n backdrop?.dispatchEvent(clickEvent);\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it('emits a modeChanged event when opening', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n\n setTimeout(() => {\n el.showModal({ config });\n });\n const response = await oneEvent(el, 'modeChanged', false);\n expect(response.detail.mode).to.equal(ModalManagerMode.Open);\n });\n\n it('emits a modeChanged event when closing', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n setTimeout(() => {\n el.closeModal();\n });\n const response = await oneEvent(el, 'modeChanged', false);\n expect(response.detail.mode).to.equal(ModalManagerMode.Closed);\n });\n\n it('can show a modal', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n expect(el.mode).to.equal(ModalManagerMode.Open);\n });\n\n it('sets the --containerHeight CSS property when the window resizes', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n const event = new Event('resize');\n const propBefore = el.style.getPropertyValue('--containerHeight');\n expect(propBefore).to.equal('');\n window.dispatchEvent(event);\n await elementUpdated(el);\n const propAfter = el.style.getPropertyValue('--containerHeight');\n expect(propAfter).to.not.equal('');\n });\n\n it('calls the userClosedModalCallback when the user taps the backdrop', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n let callbackCalled = false;\n const callback = (): void => {\n callbackCalled = true;\n };\n el.showModal({\n config,\n userClosedModalCallback: callback,\n });\n await elementUpdated(el);\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n backdrop?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(callbackCalled).to.equal(true);\n });\n\n it('does not call the userClosedModalCallback when the modal just closes', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n let callbackCalled = false;\n const callback = (): void => {\n callbackCalled = true;\n };\n el.showModal({\n config,\n userClosedModalCallback: callback,\n });\n await elementUpdated(el);\n el.closeModal();\n await elementUpdated(el);\n expect(callbackCalled).to.equal(false);\n });\n\n it('calls the userClosedModalCallback when the user taps the backdrop', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n let callbackCalled = false;\n const callback = (): void => {\n callbackCalled = true;\n };\n el.showModal({\n config,\n userClosedModalCallback: callback,\n });\n await elementUpdated(el);\n\n const modal = el.shadowRoot?.querySelector('modal-template');\n const closeButton = modal?.shadowRoot?.querySelector('.close-button');\n const clickEvent = new MouseEvent('click');\n closeButton?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(callbackCalled).to.equal(true);\n });\n\n it('mode is set to closed when close button is pressed', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n const modal = el.shadowRoot?.querySelector('modal-template');\n const closeButton = modal?.shadowRoot?.querySelector('.close-button');\n const clickEvent = new MouseEvent('click');\n closeButton?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it('mode is set to closed when close button gets spacebar pressed', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n const modal = el.shadowRoot?.querySelector('modal-template');\n const closeButton = modal?.shadowRoot?.querySelector('.close-button');\n\n // Close with keyboard\n const spacebarEvent = new KeyboardEvent('keydown', { key: ' ' });\n closeButton?.dispatchEvent(spacebarEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it('allows the user to close by clicking on the backdrop if configured to', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n config.closeOnBackdropClick = true;\n el.showModal({ config });\n await elementUpdated(el);\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n backdrop?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it(\"doesn't allow the user to close by clicking on the backdrop if configured to\", async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManagerInterface;\n\n const config = new ModalConfig();\n config.closeOnBackdropClick = false;\n el.showModal({ config });\n await elementUpdated(el);\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n backdrop?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(el.getMode()).to.equal('open');\n });\n\n it('ia logo should not visible on modal', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManagerInterface;\n\n const config = new ModalConfig();\n config.showHeaderLogo = false;\n el.showModal({ config });\n await elementUpdated(el);\n\n const logoIcon = el.shadowRoot?.querySelector('.logo-icon');\n expect(logoIcon).to.not.exist;\n });\n\n it('should trap Tab key', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n // Tab once to focus\n const tabEvent = new KeyboardEvent('keydown', { key: 'Tab' });\n document.dispatchEvent(tabEvent);\n await elementUpdated(el);\n\n // Should be only one tabbable element\n const modal = el.shadowRoot?.querySelector('modal-template') as HTMLElement;\n const tabbableElements = getTabbableElements(modal);\n expect(tabbableElements?.length).to.equal(1);\n\n const closeButton = modal?.shadowRoot?.querySelector(\n '.close-button'\n ) as HTMLElement;\n const activeElement = modal?.shadowRoot?.activeElement as HTMLElement;\n\n expect(activeElement).to.equal(closeButton);\n\n // Tab again\n el.dispatchEvent(tabEvent);\n await elementUpdated(el);\n\n // Should be only one tabbable element\n expect(activeElement).to.equal(closeButton);\n\n // Shift + Tab\n const shiftTabEvent = new KeyboardEvent('keydown', {\n key: 'Tab',\n shiftKey: true,\n });\n document.dispatchEvent(shiftTabEvent);\n await elementUpdated(el);\n\n // Should be only one tabbable element\n expect(activeElement).to.equal(closeButton);\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"modal-manager.test.js","sourceRoot":"","sources":["../../test/modal-manager.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAkB,IAAI,EAAE,MAAM,KAAK,CAAC;AAE3C,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAG7D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,oBAAoB,EAAE,GAAS,EAAE;QAClC,MAAM,EAAE,GAAG,CAAC,MAAM,OAAO,CAAC,IAAI,CAAA;;KAE7B,CAAC,CAAiB,CAAC;QAEpB,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CA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CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAE5C,cAAc;QACd,MAAM,aAAa,GAAG,IAAI,aAAa,CAAC,SAAS,EAAE;YACjD,GAAG,EAAE,KAAK;YACV,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC;QACtC,MAAM,cAAc,CAAC,EAAE,CAAC,CAAC;QAEzB,sCAAsC;QACtC,MAAM,CAAC,aAAa,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, oneEvent, elementUpdated } from '@open-wc/testing';\nimport { TemplateResult, html } from 'lit';\n\nimport '../src/modal-manager';\nimport { ModalConfig } from '../src/modal-config';\nimport { ModalManager } from '../src/modal-manager';\nimport { ModalManagerMode } from '../src/modal-manager-mode';\nimport { ModalManagerInterface } from '../src/modal-manager-interface';\n\nimport { getTabbableElements } from '../src/shoelace/tabbable';\n\ndescribe('Modal Manager', () => {\n it('defaults to closed', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n expect(el.mode).to.equal('closed');\n });\n\n it('can be closed by calling closeModal', async () => {\n const el = (await fixture(html`\n <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>\n `)) as ModalManager;\n\n el.customModalContent = 'foo' as unknown as TemplateResult;\n await elementUpdated(el);\n\n expect(el.customModalContent).to.equal('foo');\n el.closeModal();\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n expect(el.customModalContent).to.equal(undefined);\n });\n\n it('can be closed by clicking on the backdrop', async () => {\n const el = (await fixture(html`\n <modal-manager .mode=${ModalManagerMode.Open}></modal-manager>\n `)) as ModalManager;\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n\n backdrop?.dispatchEvent(clickEvent);\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it('emits a modeChanged event when opening', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n\n setTimeout(() => {\n el.showModal({ config });\n });\n const response = await oneEvent(el, 'modeChanged', false);\n expect(response.detail.mode).to.equal(ModalManagerMode.Open);\n });\n\n it('emits a modeChanged event when closing', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n setTimeout(() => {\n el.closeModal();\n });\n const response = await oneEvent(el, 'modeChanged', false);\n expect(response.detail.mode).to.equal(ModalManagerMode.Closed);\n });\n\n it('can show a modal', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n expect(el.mode).to.equal(ModalManagerMode.Open);\n });\n\n it('sets the --containerHeight CSS property when the window resizes', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n const event = new Event('resize');\n const propBefore = el.style.getPropertyValue('--containerHeight');\n expect(propBefore).to.equal('');\n window.dispatchEvent(event);\n await elementUpdated(el);\n const propAfter = el.style.getPropertyValue('--containerHeight');\n expect(propAfter).to.not.equal('');\n });\n\n it('calls the userClosedModalCallback when the user taps the backdrop', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n let callbackCalled = false;\n const callback = (): void => {\n callbackCalled = true;\n };\n el.showModal({\n config,\n userClosedModalCallback: callback,\n });\n await elementUpdated(el);\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n backdrop?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(callbackCalled).to.equal(true);\n });\n\n it('does not call the userClosedModalCallback when the modal just closes', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n let callbackCalled = false;\n const callback = (): void => {\n callbackCalled = true;\n };\n el.showModal({\n config,\n userClosedModalCallback: callback,\n });\n await elementUpdated(el);\n el.closeModal();\n await elementUpdated(el);\n expect(callbackCalled).to.equal(false);\n });\n\n it('mode is set to closed when close button is pressed', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n const modal = el.shadowRoot?.querySelector('modal-template');\n const closeButton = modal?.shadowRoot?.querySelector('.close-button');\n const clickEvent = new MouseEvent('click');\n closeButton?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it('mode is set to closed when close button gets spacebar pressed', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n const modal = el.shadowRoot?.querySelector('modal-template');\n const closeButton = modal?.shadowRoot?.querySelector('.close-button');\n\n // Close with keyboard\n const spacebarEvent = new KeyboardEvent('keydown', { key: ' ' });\n closeButton?.dispatchEvent(spacebarEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it('mode remains open when close button gets non-button keypress', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n const modal = el.shadowRoot?.querySelector('modal-template');\n const closeButton = modal?.shadowRoot?.querySelector('.close-button');\n\n // Close with keyboard\n const keyboardEvent = new KeyboardEvent('keydown', { key: '.' });\n closeButton?.dispatchEvent(keyboardEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n });\n\n it('allows the user to close by clicking on the backdrop if configured to', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n config.closeOnBackdropClick = true;\n el.showModal({ config });\n await elementUpdated(el);\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n backdrop?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(el.mode).to.equal('closed');\n });\n\n it(\"doesn't allow the user to close by clicking on the backdrop if configured to\", async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManagerInterface;\n\n const config = new ModalConfig();\n config.closeOnBackdropClick = false;\n el.showModal({ config });\n await elementUpdated(el);\n\n const backdrop = el.shadowRoot?.querySelector('.backdrop');\n const clickEvent = new MouseEvent('click');\n backdrop?.dispatchEvent(clickEvent);\n\n await elementUpdated(el);\n\n expect(el.getMode()).to.equal('open');\n });\n\n it('ia logo should not visible on modal', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManagerInterface;\n\n const config = new ModalConfig();\n config.showHeaderLogo = false;\n el.showModal({ config });\n await elementUpdated(el);\n\n const logoIcon = el.shadowRoot?.querySelector('.logo-icon');\n expect(logoIcon).to.not.exist;\n });\n\n it('should trap Tab key', async () => {\n const el = (await fixture(html`\n <modal-manager></modal-manager>\n `)) as ModalManager;\n\n const config = new ModalConfig();\n el.showModal({ config });\n await elementUpdated(el);\n\n expect(el.mode).to.equal('open');\n\n // Tab once to focus\n const tabEvent = new KeyboardEvent('keydown', { key: 'Tab' });\n document.dispatchEvent(tabEvent);\n await elementUpdated(el);\n\n // Should be only one tabbable element\n const modal = el.shadowRoot?.querySelector('modal-template') as HTMLElement;\n const tabbableElements = getTabbableElements(modal);\n expect(tabbableElements?.length).to.equal(1);\n\n const closeButton = modal?.shadowRoot?.querySelector(\n '.close-button'\n ) as HTMLElement;\n const activeElement = modal?.shadowRoot?.activeElement as HTMLElement;\n\n expect(activeElement).to.equal(closeButton);\n\n // Tab again\n el.dispatchEvent(tabEvent);\n await elementUpdated(el);\n\n // Should be only one tabbable element\n expect(activeElement).to.equal(closeButton);\n\n // Shift + Tab\n const shiftTabEvent = new KeyboardEvent('keydown', {\n key: 'Tab',\n shiftKey: true,\n });\n document.dispatchEvent(shiftTabEvent);\n await elementUpdated(el);\n\n // Should be only one tabbable element\n expect(activeElement).to.equal(closeButton);\n });\n});\n"]}
|
|
@@ -38,39 +38,50 @@ describe('Modal Template', () => {
|
|
|
38
38
|
const response = yield oneEvent(el, 'closeButtonPressed', false);
|
|
39
39
|
expect(response).to.exist;
|
|
40
40
|
}));
|
|
41
|
+
it('emits closeButtonPressed event when close button gets spacebar pressed', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
var _g;
|
|
43
|
+
const el = yield fixture(html ` <modal-template></modal-template> `);
|
|
44
|
+
const closeButton = (_g = el.shadowRoot) === null || _g === void 0 ? void 0 : _g.querySelector('.close-button');
|
|
45
|
+
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
46
|
+
setTimeout(() => {
|
|
47
|
+
closeButton === null || closeButton === void 0 ? void 0 : closeButton.dispatchEvent(clickEvent);
|
|
48
|
+
});
|
|
49
|
+
const response = yield oneEvent(el, 'closeButtonPressed', false);
|
|
50
|
+
expect(response).to.exist;
|
|
51
|
+
}));
|
|
41
52
|
it('shows the processing indicator if configured to', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
var
|
|
53
|
+
var _h, _j;
|
|
43
54
|
const config = new ModalConfig();
|
|
44
55
|
config.showProcessingIndicator = true;
|
|
45
56
|
const el = yield fixture(html `
|
|
46
57
|
<modal-template .config=${config}></modal-template>
|
|
47
58
|
`);
|
|
48
|
-
const processingLogo = (
|
|
49
|
-
const classList = (
|
|
59
|
+
const processingLogo = (_h = el.shadowRoot) === null || _h === void 0 ? void 0 : _h.querySelector('.processing-logo');
|
|
60
|
+
const classList = (_j = processingLogo === null || processingLogo === void 0 ? void 0 : processingLogo.classList) !== null && _j !== void 0 ? _j : [];
|
|
50
61
|
expect('hidden' in classList).to.equal(false);
|
|
51
62
|
}));
|
|
52
63
|
it('shows the close button if configured to', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
-
var
|
|
64
|
+
var _k;
|
|
54
65
|
const config = new ModalConfig();
|
|
55
66
|
config.showCloseButton = true;
|
|
56
67
|
const el = yield fixture(html `
|
|
57
68
|
<modal-template .config=${config}></modal-template>
|
|
58
69
|
`);
|
|
59
|
-
const closeButton = (
|
|
70
|
+
const closeButton = (_k = el.shadowRoot) === null || _k === void 0 ? void 0 : _k.querySelector('.close-button');
|
|
60
71
|
expect(closeButton).to.exist;
|
|
61
72
|
}));
|
|
62
73
|
it('hides the close button if configured to', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
-
var
|
|
74
|
+
var _l;
|
|
64
75
|
const config = new ModalConfig();
|
|
65
76
|
config.showCloseButton = false;
|
|
66
77
|
const el = yield fixture(html `
|
|
67
78
|
<modal-template .config=${config}></modal-template>
|
|
68
79
|
`);
|
|
69
|
-
const closeButton = (
|
|
80
|
+
const closeButton = (_l = el.shadowRoot) === null || _l === void 0 ? void 0 : _l.querySelector('.close-button');
|
|
70
81
|
expect(closeButton).to.not.exist;
|
|
71
82
|
}));
|
|
72
83
|
it('shows the properties from the config', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
-
var
|
|
84
|
+
var _m, _o, _p, _q;
|
|
74
85
|
const config = new ModalConfig();
|
|
75
86
|
config.title = html `Boop`;
|
|
76
87
|
config.subtitle = html `Bop`;
|
|
@@ -79,10 +90,10 @@ describe('Modal Template', () => {
|
|
|
79
90
|
const el = yield fixture(html `
|
|
80
91
|
<modal-template .config=${config}></modal-template>
|
|
81
92
|
`);
|
|
82
|
-
const title = (
|
|
83
|
-
const subtitle = (
|
|
84
|
-
const headline = (
|
|
85
|
-
const message = (
|
|
93
|
+
const title = (_m = el.shadowRoot) === null || _m === void 0 ? void 0 : _m.querySelector('h1');
|
|
94
|
+
const subtitle = (_o = el.shadowRoot) === null || _o === void 0 ? void 0 : _o.querySelector('h2');
|
|
95
|
+
const headline = (_p = el.shadowRoot) === null || _p === void 0 ? void 0 : _p.querySelector('.headline');
|
|
96
|
+
const message = (_q = el.shadowRoot) === null || _q === void 0 ? void 0 : _q.querySelector('.message');
|
|
86
97
|
expect(title).to.exist;
|
|
87
98
|
expect(title === null || title === void 0 ? void 0 : title.innerText).to.equal('Boop');
|
|
88
99
|
expect(subtitle).to.exist;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal-template.test.js","sourceRoot":"","sources":["../../test/modal-template.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAElD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,mCAAmC,EAAE,GAAS,EAAE;;QACjD,MAAM,EAAE,GAAG,MAAM,OAAO,CAAC,IAAI,CAAA,qCAAqC,CAAC,CAAC;QAEpE,MAAM,cAAc,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,kBAAkB,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,WAAW,CAAC,CAAC;QAC3D,MAAM,OAAO,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,MAAA,EAAE,CAAC,UAAU,0CAAE,aAAa,CAAC,UAAU,CAAgB,CAAC;QAEtE,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC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M,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC1B,MAAM,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE9C,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, oneEvent } from '@open-wc/testing';\nimport { html } from 'lit';\nimport '../src/modal-template';\nimport { ModalConfig } from '../src/modal-config';\n\ndescribe('Modal Template', () => {\n it('has correct default configuration', async () => {\n const el = await fixture(html` <modal-template></modal-template> `);\n\n const processingLogo = el.shadowRoot?.querySelector('.processing-logo');\n const headline = el.shadowRoot?.querySelector('.headline');\n const message = el.shadowRoot?.querySelector('.message');\n const title = el.shadowRoot?.querySelector('h1.title') as HTMLElement;\n\n expect(headline).to.not.exist;\n expect(message).to.not.exist;\n expect(title).to.not.exist;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n expect('hidden' in processingLogo!.classList);\n });\n\n it('does not show the title if one not provided', async () => {\n const config = new ModalConfig();\n config.title = undefined;\n\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const title = el.shadowRoot?.querySelector('h1.title');\n expect(title).to.not.exist;\n });\n\n it('emits closeButtonPressed event when close button is pressed', async () => {\n const el = await fixture(html` <modal-template></modal-template> `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n const clickEvent = new MouseEvent('click');\n\n setTimeout(() => {\n closeButton?.dispatchEvent(clickEvent);\n });\n const response = await oneEvent(el, 'closeButtonPressed', false);\n expect(response).to.exist;\n });\n\n it('shows the processing indicator if configured to', async () => {\n const config = new ModalConfig();\n config.showProcessingIndicator = true;\n\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const processingLogo = el.shadowRoot?.querySelector('.processing-logo');\n const classList = processingLogo?.classList ?? [];\n expect('hidden' in classList).to.equal(false);\n });\n\n it('shows the close button if configured to', async () => {\n const config = new ModalConfig();\n config.showCloseButton = true;\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n expect(closeButton).to.exist;\n });\n\n it('hides the close button if configured to', async () => {\n const config = new ModalConfig();\n config.showCloseButton = false;\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n expect(closeButton).to.not.exist;\n });\n\n it('shows the properties from the config', async () => {\n const config = new ModalConfig();\n config.title = html`Boop`;\n config.subtitle = html`Bop`;\n config.headline = html`Foo`;\n config.message = html`Bar`;\n\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const title = el.shadowRoot?.querySelector('h1');\n const subtitle = el.shadowRoot?.querySelector('h2');\n\n const headline = el.shadowRoot?.querySelector('.headline');\n const message = el.shadowRoot?.querySelector('.message');\n\n expect(title).to.exist;\n expect(title?.innerText).to.equal('Boop');\n\n expect(subtitle).to.exist;\n expect(subtitle?.innerText).to.equal('Bop');\n\n expect(headline).to.exist;\n expect(headline?.textContent).to.equal('Foo');\n\n expect(message).to.exist;\n expect(message?.textContent).to.equal('Bar');\n });\n});\n"]}
|
|
1
|
+
{"version":3,"file":"modal-template.test.js","sourceRoot":"","sources":["../../test/modal-template.test.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA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CAAC,KAAK,CAAC;QAC1B,MAAM,CAAC,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAE9C,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QACzB,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { fixture, expect, oneEvent } from '@open-wc/testing';\nimport { html } from 'lit';\nimport '../src/modal-template';\nimport { ModalConfig } from '../src/modal-config';\n\ndescribe('Modal Template', () => {\n it('has correct default configuration', async () => {\n const el = await fixture(html` <modal-template></modal-template> `);\n\n const processingLogo = el.shadowRoot?.querySelector('.processing-logo');\n const headline = el.shadowRoot?.querySelector('.headline');\n const message = el.shadowRoot?.querySelector('.message');\n const title = el.shadowRoot?.querySelector('h1.title') as HTMLElement;\n\n expect(headline).to.not.exist;\n expect(message).to.not.exist;\n expect(title).to.not.exist;\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n expect('hidden' in processingLogo!.classList);\n });\n\n it('does not show the title if one not provided', async () => {\n const config = new ModalConfig();\n config.title = undefined;\n\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const title = el.shadowRoot?.querySelector('h1.title');\n expect(title).to.not.exist;\n });\n\n it('emits closeButtonPressed event when close button is pressed', async () => {\n const el = await fixture(html` <modal-template></modal-template> `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n const clickEvent = new MouseEvent('click');\n\n setTimeout(() => {\n closeButton?.dispatchEvent(clickEvent);\n });\n const response = await oneEvent(el, 'closeButtonPressed', false);\n expect(response).to.exist;\n });\n\n it('emits closeButtonPressed event when close button gets spacebar pressed', async () => {\n const el = await fixture(html` <modal-template></modal-template> `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n const clickEvent = new KeyboardEvent('keydown', { key: ' ' });\n\n setTimeout(() => {\n closeButton?.dispatchEvent(clickEvent);\n });\n const response = await oneEvent(el, 'closeButtonPressed', false);\n expect(response).to.exist;\n });\n\n it('shows the processing indicator if configured to', async () => {\n const config = new ModalConfig();\n config.showProcessingIndicator = true;\n\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const processingLogo = el.shadowRoot?.querySelector('.processing-logo');\n const classList = processingLogo?.classList ?? [];\n expect('hidden' in classList).to.equal(false);\n });\n\n it('shows the close button if configured to', async () => {\n const config = new ModalConfig();\n config.showCloseButton = true;\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n expect(closeButton).to.exist;\n });\n\n it('hides the close button if configured to', async () => {\n const config = new ModalConfig();\n config.showCloseButton = false;\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const closeButton = el.shadowRoot?.querySelector('.close-button');\n expect(closeButton).to.not.exist;\n });\n\n it('shows the properties from the config', async () => {\n const config = new ModalConfig();\n config.title = html`Boop`;\n config.subtitle = html`Bop`;\n config.headline = html`Foo`;\n config.message = html`Bar`;\n\n const el = await fixture(html`\n <modal-template .config=${config}></modal-template>\n `);\n\n const title = el.shadowRoot?.querySelector('h1');\n const subtitle = el.shadowRoot?.querySelector('h2');\n\n const headline = el.shadowRoot?.querySelector('.headline');\n const message = el.shadowRoot?.querySelector('.message');\n\n expect(title).to.exist;\n expect(title?.innerText).to.equal('Boop');\n\n expect(subtitle).to.exist;\n expect(subtitle?.innerText).to.equal('Bop');\n\n expect(headline).to.exist;\n expect(headline?.textContent).to.equal('Foo');\n\n expect(message).to.exist;\n expect(message?.textContent).to.equal('Bar');\n });\n});\n"]}
|
package/package.json
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { html } from 'lit';
|
|
2
|
+
|
|
3
|
+
export default html`
|
|
4
|
+
<svg
|
|
5
|
+
class="ia-logo"
|
|
6
|
+
viewBox="0 0 27 30"
|
|
7
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
8
|
+
aria-labelledby="logoTitleID logoDescID"
|
|
9
|
+
>
|
|
10
|
+
<title id="logoTitleID">Internet Archive logo</title>
|
|
11
|
+
<desc id="logoDescID">
|
|
12
|
+
A line drawing of the Internet Archive headquarters building façade.
|
|
13
|
+
</desc>
|
|
14
|
+
<g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
|
|
15
|
+
<mask id="mask-2" class="fill-color">
|
|
16
|
+
<path
|
|
17
|
+
d="M26.6666667,28.6046512 L26.6666667,30 L0,30 L0.000283687943,28.6046512 L26.6666667,28.6046512 Z M25.6140351,26.5116279 L25.6140351,28.255814 L1.05263158,28.255814 L1.05263158,26.5116279 L25.6140351,26.5116279 Z M3.62469203,7.6744186 L3.91746909,7.82153285 L4.0639977,10.1739544 L4.21052632,13.9963932 L4.21052632,17.6725617 L4.0639977,22.255044 L4.03962296,25.3421929 L3.62469203,25.4651163 L2.16024641,25.4651163 L1.72094074,25.3421929 L1.55031755,22.255044 L1.40350877,17.6970339 L1.40350877,14.0211467 L1.55031755,10.1739544 L1.68423854,7.80887484 L1.98962322,7.6744186 L3.62469203,7.6744186 Z M24.6774869,7.6744186 L24.9706026,7.82153285 L25.1168803,10.1739544 L25.2631579,13.9963932 L25.2631579,17.6725617 L25.1168803,22.255044 L25.0927809,25.3421929 L24.6774869,25.4651163 L23.2130291,25.4651163 L22.7736357,25.3421929 L22.602418,22.255044 L22.4561404,17.6970339 L22.4561404,14.0211467 L22.602418,10.1739544 L22.7369262,7.80887484 L23.0420916,7.6744186 L24.6774869,7.6744186 Z M9.94042303,7.6744186 L10.2332293,7.82153285 L10.3797725,10.1739544 L10.5263158,13.9963932 L10.5263158,17.6725617 L10.3797725,22.255044 L10.3556756,25.3421929 L9.94042303,25.4651163 L8.47583122,25.4651163 L8.0362015,25.3421929 L7.86556129,22.255044 L7.71929825,17.6970339 L7.71929825,14.0211467 L7.86556129,10.1739544 L8.00005604,7.80887484 L8.30491081,7.6744186 L9.94042303,7.6744186 Z M18.0105985,7.6744186 L18.3034047,7.82153285 L18.449948,10.1739544 L18.5964912,13.9963932 L18.5964912,17.6725617 L18.449948,22.255044 L18.425851,25.3421929 L18.0105985,25.4651163 L16.5460067,25.4651163 L16.1066571,25.3421929 L15.9357367,22.255044 L15.7894737,17.6970339 L15.7894737,14.0211467 L15.9357367,10.1739544 L16.0702315,7.80887484 L16.3753664,7.6744186 L18.0105985,7.6744186 Z M25.6140351,4.53488372 L25.6140351,6.97674419 L1.05263158,6.97674419 L1.05263158,4.53488372 L25.6140351,4.53488372 Z M13.0806755,0 L25.9649123,2.93331338 L25.4484139,3.8372093 L0.771925248,3.8372093 L0,3.1041615 L13.0806755,0 Z"
|
|
18
|
+
id="path-1"
|
|
19
|
+
></path>
|
|
20
|
+
</mask>
|
|
21
|
+
<use class="fill-color" xlink:href="#path-1"></use>
|
|
22
|
+
<g mask="url(#mask-2)" class="fill-color">
|
|
23
|
+
<path
|
|
24
|
+
d="M0,0 L26.6666667,0 L26.6666667,30 L0,30 L0,0 Z"
|
|
25
|
+
id="swatch"
|
|
26
|
+
></path>
|
|
27
|
+
</g>
|
|
28
|
+
</g>
|
|
29
|
+
</svg>
|
|
30
|
+
`;
|
package/src/modal-template.ts
CHANGED
|
@@ -3,9 +3,9 @@ import { property, customElement } from 'lit/decorators.js';
|
|
|
3
3
|
|
|
4
4
|
import '@internetarchive/ia-activity-indicator/ia-activity-indicator';
|
|
5
5
|
import '@internetarchive/icon-close';
|
|
6
|
-
import iaIcon from '@internetarchive/icon-ia-logo/index.js';
|
|
7
6
|
|
|
8
7
|
import { ModalConfig } from './modal-config';
|
|
8
|
+
import IALogoIcon from './assets/ia-logo-icon';
|
|
9
9
|
|
|
10
10
|
@customElement('modal-template')
|
|
11
11
|
export class ModalTemplate extends LitElement {
|
|
@@ -25,7 +25,7 @@ export class ModalTemplate extends LitElement {
|
|
|
25
25
|
<header style="background-color: ${this.config.headerColor}">
|
|
26
26
|
${this.config.showCloseButton ? this.closeButtonTemplate : ''}
|
|
27
27
|
${this.config.showHeaderLogo
|
|
28
|
-
? html`<div class="logo-icon">${
|
|
28
|
+
? html`<div class="logo-icon">${IALogoIcon}</div>`
|
|
29
29
|
: nothing}
|
|
30
30
|
${this.config.title
|
|
31
31
|
? html`<h1 class="title">${this.config.title}</h1>`
|
package/src/shoelace/modal.ts
CHANGED
package/src/shoelace/tabbable.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
1
2
|
// Cached compute style calls. This is specifically for browsers that dont support `checkVisibility()`.
|
|
2
3
|
// computedStyle calls are "live" so they only need to be retrieved once for an element.
|
|
3
4
|
const computedStyleMap = new WeakMap<Element, CSSStyleDeclaration>();
|
|
@@ -151,22 +151,17 @@ describe('Modal Manager', () => {
|
|
|
151
151
|
expect(callbackCalled).to.equal(false);
|
|
152
152
|
});
|
|
153
153
|
|
|
154
|
-
it('
|
|
154
|
+
it('mode is set to closed when close button is pressed', async () => {
|
|
155
155
|
const el = (await fixture(html`
|
|
156
156
|
<modal-manager></modal-manager>
|
|
157
157
|
`)) as ModalManager;
|
|
158
158
|
|
|
159
159
|
const config = new ModalConfig();
|
|
160
|
-
|
|
161
|
-
const callback = (): void => {
|
|
162
|
-
callbackCalled = true;
|
|
163
|
-
};
|
|
164
|
-
el.showModal({
|
|
165
|
-
config,
|
|
166
|
-
userClosedModalCallback: callback,
|
|
167
|
-
});
|
|
160
|
+
el.showModal({ config });
|
|
168
161
|
await elementUpdated(el);
|
|
169
162
|
|
|
163
|
+
expect(el.mode).to.equal('open');
|
|
164
|
+
|
|
170
165
|
const modal = el.shadowRoot?.querySelector('modal-template');
|
|
171
166
|
const closeButton = modal?.shadowRoot?.querySelector('.close-button');
|
|
172
167
|
const clickEvent = new MouseEvent('click');
|
|
@@ -174,10 +169,10 @@ describe('Modal Manager', () => {
|
|
|
174
169
|
|
|
175
170
|
await elementUpdated(el);
|
|
176
171
|
|
|
177
|
-
expect(
|
|
172
|
+
expect(el.mode).to.equal('closed');
|
|
178
173
|
});
|
|
179
174
|
|
|
180
|
-
it('mode is set to closed when close button
|
|
175
|
+
it('mode is set to closed when close button gets spacebar pressed', async () => {
|
|
181
176
|
const el = (await fixture(html`
|
|
182
177
|
<modal-manager></modal-manager>
|
|
183
178
|
`)) as ModalManager;
|
|
@@ -190,15 +185,17 @@ describe('Modal Manager', () => {
|
|
|
190
185
|
|
|
191
186
|
const modal = el.shadowRoot?.querySelector('modal-template');
|
|
192
187
|
const closeButton = modal?.shadowRoot?.querySelector('.close-button');
|
|
193
|
-
|
|
194
|
-
|
|
188
|
+
|
|
189
|
+
// Close with keyboard
|
|
190
|
+
const spacebarEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
191
|
+
closeButton?.dispatchEvent(spacebarEvent);
|
|
195
192
|
|
|
196
193
|
await elementUpdated(el);
|
|
197
194
|
|
|
198
195
|
expect(el.mode).to.equal('closed');
|
|
199
196
|
});
|
|
200
197
|
|
|
201
|
-
it('mode
|
|
198
|
+
it('mode remains open when close button gets non-button keypress', async () => {
|
|
202
199
|
const el = (await fixture(html`
|
|
203
200
|
<modal-manager></modal-manager>
|
|
204
201
|
`)) as ModalManager;
|
|
@@ -213,12 +210,12 @@ describe('Modal Manager', () => {
|
|
|
213
210
|
const closeButton = modal?.shadowRoot?.querySelector('.close-button');
|
|
214
211
|
|
|
215
212
|
// Close with keyboard
|
|
216
|
-
const
|
|
217
|
-
closeButton?.dispatchEvent(
|
|
213
|
+
const keyboardEvent = new KeyboardEvent('keydown', { key: '.' });
|
|
214
|
+
closeButton?.dispatchEvent(keyboardEvent);
|
|
218
215
|
|
|
219
216
|
await elementUpdated(el);
|
|
220
217
|
|
|
221
|
-
expect(el.mode).to.equal('
|
|
218
|
+
expect(el.mode).to.equal('open');
|
|
222
219
|
});
|
|
223
220
|
|
|
224
221
|
it('allows the user to close by clicking on the backdrop if configured to', async () => {
|
|
@@ -44,6 +44,19 @@ describe('Modal Template', () => {
|
|
|
44
44
|
expect(response).to.exist;
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
+
it('emits closeButtonPressed event when close button gets spacebar pressed', async () => {
|
|
48
|
+
const el = await fixture(html` <modal-template></modal-template> `);
|
|
49
|
+
|
|
50
|
+
const closeButton = el.shadowRoot?.querySelector('.close-button');
|
|
51
|
+
const clickEvent = new KeyboardEvent('keydown', { key: ' ' });
|
|
52
|
+
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
closeButton?.dispatchEvent(clickEvent);
|
|
55
|
+
});
|
|
56
|
+
const response = await oneEvent(el, 'closeButtonPressed', false);
|
|
57
|
+
expect(response).to.exist;
|
|
58
|
+
});
|
|
59
|
+
|
|
47
60
|
it('shows the processing indicator if configured to', async () => {
|
|
48
61
|
const config = new ModalConfig();
|
|
49
62
|
config.showProcessingIndicator = true;
|