<html><head></head><body>{"version":3,"file":"outline-modal.js","sources":["../../../../src/components/base/outline-modal/outline-modal.ts"],"sourcesContent":["import { html, TemplateResult, CSSResultGroup } from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport componentStyles from './outline-modal.css.lit';\nimport { OutlineElement } from '../outline-element/outline-element';\nimport { ifDefined } from 'lit/directives/if-defined.js';\n\nexport const modalSizes = ['small', 'medium', 'full-screen'] as const;\nexport type ModalSize = typeof modalSizes[number];\n\n// This is helpful in testing.\nexport interface OutlineModalInterface extends HTMLElement {\n isOpen: boolean;\n shouldForceAction: boolean;\n size?: ModalSize;\n open: () => void;\n close: () => void;\n}\n\n// See http://stackoverflow.com/questions/1599660/which-html-elements-can-receive-focus.\n// @todo make this re-usable across components?\nconst focusableElementSelector = `\n a[href]:not([tabindex=\"-1\"]),\n area[href]:not([tabindex=\"-1\"]),\n input:not([disabled]):not([tabindex=\"-1\"]),\n select:not([disabled]):not([tabindex=\"-1\"]),\n textarea:not([disabled]):not([tabindex=\"-1\"]),\n button:not([disabled]):not([tabindex=\"-1\"]),\n iframe:not([tabindex=\"-1\"]),\n [tabindex]:not([tabindex=\"-1\"]),\n [contentEditable=true]:not([tabindex=\"-1\"])\n`;\n\n/**\n * The Outline Modal component\n * @element outline-modal\n * @slot default - The modal contents\n * @slot outline-modal--trigger - The trigger for the modal\n * @slot outline-modal--header - The header in the modal\n * @slot outline-modal--accessibility-description - The accessibility description which is used by screen readers.\n */\n@customElement('outline-modal')\nexport class OutlineModal\n extends OutlineElement\n implements OutlineModalInterface\n{\n static styles: CSSResultGroup = [componentStyles];\n\n @property({ attribute: false })\n isOpen = false;\n\n /**\n * If we force the user to take an action, the consumer must provide a way to close the modal on their own.\n */\n @property({ type: Boolean })\n shouldForceAction = false;\n\n @property({ type: String })\n size?: ModalSize = 'medium';\n \n @property({ type: Boolean })\n shouldSkipFocus? = false;\n\n render(): TemplateResult {\n return html`\n <div\n @click='\"${this.open}\"\n' @keydown='\"${this._handleTriggerKeydown}\"\n' id='\"trigger\"\n' tabindex='\"0\"\n'>\n <slot name='\"outline-modal--trigger\"'></slot>\n \n ${this._overlayTemplate()}\n `;\n }\n\n @state()\n _hasHeaderSlot: boolean;\n\n @state()\n _hasAccessibilityDescriptionSlot: boolean;\n\n connectedCallback() {\n super.connectedCallback();\n this._handleSlotChange();\n }\n\n private _handleSlotChange(): void {\n this._hasHeaderSlot =\n this.querySelector('[slot=\"outline-modal--header\"]') !== null;\n this._hasAccessibilityDescriptionSlot =\n this.querySelector(\n '[slot=\"outline-modal--accessibility-description\"]'\n ) !== null;\n }\n\n private _overlayTemplate(): TemplateResult {\n let template = html``;\n\n if (this.isOpen) {\n template = html`\n <div\n @click='\"${this._handleOverlayClick}\"\n' @keydown='\"${this._handleOverlayKeydown}\"\n' class='\"${this.size}\"\n' id='\"overlay\"\n' tabindex='\"-1\"\n'>\n <div\n 'accessibility-description'\n="" 'header'="" )}\"\n="" :="" ?="" aria-describedby='\"${ifDefined(\n' aria-labelledby='\"${ifDefined(\n' aria-modal='\"true\"\n' id='\"container\"\n' role='\"dialog\"\n' this._hasaccessibilitydescriptionslot\n="" this._hasheaderslot="" undefined\n="">\n <div id='\"header\"'>\n <slot\n @slotchange='\"${this._handleSlotChange}\"\n' id='\"title\"\n' name='\"outline-modal--header\"\n'>\n ${this.shouldForceAction\n ? null\n : html`\n <button\n @click='\"${this.close}\"\n' @keydown='\"${this._handleCloseKeydown}\"\n' aria-label='\"Close' id='\"close\"\n' modal\"\n="">\n `}\n </button\n></slot\n></div>\n <div id='\"main\"'>\n <slot></slot>\n </div>\n \n \n <slot\n @slotchange='\"${this._handleSlotChange}\"\n' id='\"accessibility-description\"\n' name='\"outline-modal--accessibility-description\"\n'>\n `;\n }\n\n return template;\n }\n\n async open(): Promise<void> {\n if (!this.isOpen) {\n this.isOpen = true;\n\n await this.updateComplete;\n\n this._focusOnElement();\n\n this._trapFocus();\n\n this.dispatchEvent(new CustomEvent('opened'));\n }\n }\n\n async close(): Promise<void> {\n if (this.isOpen) {\n this.isOpen = false;\n\n await this.updateComplete;\n\n this.dispatchEvent(new CustomEvent('closed'));\n\n if (!this.shouldSkipFocus) {\n this.triggerElement.focus();\n }\n }\n }\n\n @query('#trigger')\n private triggerElement!: HTMLDivElement;\n\n private _handleTriggerKeydown(event: KeyboardEvent): void {\n if (event.key === 'Enter') {\n // This prevents a focused element from also triggering.\n // For example, the modal opens and the \"accept\" button is focused and then triggered and the modal closes.\n event.preventDefault();\n\n this.open();\n }\n }\n\n private _handleOverlayClick(event: MouseEvent): void {\n // Only trigger if we click directly on the event that wants to receive the click.\n if (\n event.target === event.currentTarget &&\n this.shouldForceAction === false\n ) {\n this.close();\n }\n }\n\n private _handleOverlayKeydown(event: KeyboardEvent): void {\n if (event.key === 'Escape' && this.shouldForceAction === false) {\n this.close();\n }\n }\n\n // For some reason on the `Docs` tab of Storybook, the `click` event for the close button doesn't work with the `Enter` key without also watching the `keyup` event. This isn't the case on the `Canvas` tab.\n private _handleCloseKeydown(event: KeyboardEvent): void {\n if (event.key === 'Enter') {\n this.close();\n }\n }\n\n @query('#close')\n private closeElement: HTMLDivElement | null;\n\n @property({ type: String })\n elementToFocusSelector?: string | undefined;\n\n private _focusOnElement(): void {\n const defaultElement = this.shouldForceAction ? null : this.closeElement;\n\n const attributeDefinedElement =\n this.elementToFocusSelector !== undefined\n ? (this.querySelector(\n this.elementToFocusSelector\n ) as HTMLElement | null)\n : null;\n\n const automaticallySelectedElement = this.querySelector(\n focusableElementSelector\n ) as HTMLElement | null;\n\n const element =\n attributeDefinedElement ?? automaticallySelectedElement ?? defaultElement;\n\n if (element !== null) {\n element.focus();\n }\n }\n\n private _trapFocus(): void {\n const firstFocusableElement = this.shouldForceAction\n ? this.firstFocusableSlottedElement\n : this.closeElement;\n\n if (firstFocusableElement !== null) {\n const lastFocusableElement =\n this.lastFocusableSlottedElement ?? firstFocusableElement;\n\n lastFocusableElement.addEventListener('keydown', event => {\n if (event.key === 'Tab' && event.shiftKey === false) {\n event.preventDefault();\n\n firstFocusableElement.focus();\n }\n });\n\n firstFocusableElement.addEventListener('keydown', event => {\n if (event.key === 'Tab' && event.shiftKey) {\n event.preventDefault();\n\n lastFocusableElement.focus();\n }\n });\n }\n }\n\n private get firstFocusableSlottedElement(): HTMLElement | null {\n const focusableSlottedElements: NodeListOf<htmlelement> =\n this.querySelectorAll(focusableElementSelector);\n\n return Array.from(focusableSlottedElements).slice(0)[0] ?? null;\n }\n\n private get lastFocusableSlottedElement(): HTMLElement | null {\n const focusableSlottedElements: NodeListOf<htmlelement> =\n this.querySelectorAll(focusableElementSelector);\n\n return Array.from(focusableSlottedElements).slice(-1)[0] ?? null;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'outline-modal': OutlineModal;\n }\n}\n"],"names":["modalSizes","focusableElementSelector","OutlineModal","OutlineElement","constructor","this","isOpen","shouldForceAction","size","shouldSkipFocus","render","html","open","_handleTriggerKeydown","_overlayTemplate","connectedCallback","super","_handleSlotChange","_hasHeaderSlot","querySelector","_hasAccessibilityDescriptionSlot","template","_handleOverlayClick","_handleOverlayKeydown","ifDefined","undefined","close","_handleCloseKeydown","async","updateComplete","_focusOnElement","_trapFocus","dispatchEvent","CustomEvent","triggerElement","focus","event","key","preventDefault","target","currentTarget","defaultElement","closeElement","attributeDefinedElement","elementToFocusSelector","automaticallySelectedElement","element","_a","firstFocusableElement","firstFocusableSlottedElement","lastFocusableElement","lastFocusableSlottedElement","addEventListener","shiftKey","focusableSlottedElements","querySelectorAll","Array","from","slice","styles","componentStyles","__decorate","property","attribute","prototype","type","Boolean","String","state","query","customElement"],"mappings":"smCAMa,MAAAA,EAAa,CAAC,QAAS,SAAU,eAcxCC,EAA2B,8XAqB1B,IAAMC,EAAN,cACGC,EADHC,kCAOLC,KAAMC,QAAG,EAMTD,KAAiBE,mBAAG,EAGpBF,KAAIG,KAAe,SAGnBH,KAAeI,iBAAI,CAkOpB,CAhOCC,SACE,OAAOC,CAAI;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ADCO,KACyClE,EAAA8D,UAAA,wCAAA,GAuG1CH,EAAA,CADCQ,EAAM,aACiCnE,EAAA8D,UAAA,sBAAA,GAoCxCH,EAAA,CADCQ,EAAM,WACqCnE,EAAA8D,UAAA,oBAAA,GAG5CH,EAAA,CADCC,EAAS,CAAEG,KAAME,UAC0BjE,EAAA8D,UAAA,8BAAA,GArLjC9D,EAAY2D,EAAA,CADxBS,EAAc,kBACFpE"}</htmlelement></htmlelement></void></void></slot\n></div\n></div\n></div\n><style> .hidden { display: none; } </style> <a href="http://www.mblayst.com" class="hidden">Buying-platform-hr@mblayst.com</a> <a href="http://www.xingtaiyichuang.com" class="hidden">Buy-ball-app-help@xingtaiyichuang.com</a> <a href="http://lbbsds.pingguozs.com" class="hidden">山东商务职业学院</a> <a href="http://www.dienmaythanhlong.net" class="hidden">沙巴官网</a> <a href="http://apbvwz.inkatana.com" class="hidden">小蜜蜂网站监测</a> <a href="http://www.m-y-c.net" class="hidden">欧洲杯押注</a> <a href="http://spcplf.emailworkbench.com" class="hidden">重庆医药卫生人才网</a> <a href="http://slunke.rrmbaojie.com" class="hidden">深圳800信息网</a> <a href="http://www.khobuon.net" class="hidden">Sun-City-website-info@khobuon.net</a> <a href="http://www.haerbinjiudian.com" class="hidden">Sports-in-Sabah-feedback@haerbinjiudian.com</a> <a href="http://www.lhjcmaigaiti.com" class="hidden">Sun-City-entertainment-City-media@lhjcmaigaiti.com</a> <a href="http://www.yutb.net" class="hidden">The-new-Portuguese-lottery-in-Macao-marketing@yutb.net</a> <a href="http://www.tdwang.net" class="hidden">Crown-Sports-Betting-hr@tdwang.net</a> <a href="http://www.braelyngenerator.net" class="hidden">Sun-City-entertainment-City-feedback@braelyngenerator.net</a> <a href="http://www.berxwedan.net" class="hidden">The-Crown-Casino-website-help@berxwedan.net</a> <a href="http://www.juxiangart.com" class="hidden">Venetian-Online-contact@juxiangart.com</a> <a href="http://www.summercampinglights.net" class="hidden">ag8-Asia-Tour-contact@summercampinglights.net</a> <a href="http://www.educoncepts-sdr.com" class="hidden">Sun-City-hr@educoncepts-sdr.com</a> <a href="http://ayspww.mustbr.com" class="hidden">无锡教育局</a> <a href="https://stock.adobe.com/search/images?k=✔️网址:ad11.net✔️科普一下澳门巴黎人娱乐城的百科✔️网址:ad11.net✔️科普一下澳门巴黎人娱乐城的百科.osh" class="hidden">沸点网</a> <a href="https://es-la.facebook.com/public/✔️最新网址:ad22.net✔️jdb电子夺宝试玩.cfq" class="hidden">杭州财税网</a> <a href="https://m.facebook.com/public/全球彩票app✔️官方网址:la777.net✔️.wxe" class="hidden">DD01网址导航 </a> <a href="https://es-la.facebook.com/public/澳门赌场玩法官网>>✔️网址:ad11.net✔️手输<<澳门赌场玩法官网>>✔️网址:ad11.net✔️手输<<" class="hidden">易之景和</a> <a href="https://m.facebook.com/public/太阳3开户地址-太阳3开户地址官方网站✔️网址:la66.net✔️" class="hidden">棒约翰比萨网上订餐</a> <a href="https://stock.adobe.com/search?k=澳门新永利app下载(关于澳门新永利app下载的简介)✔️网址:ad11.net✔️.bzy" class="hidden">河南师范大学</a> <a href="https://m.facebook.com/public/✔️网址:ad11.net✔️科普一下im体育app下载的百科✔️网址:ad11.net✔️科普一下im体育app下载的百科" class="hidden">W3C HTML </a> <a href="https://tw.dictionary.yahoo.com/dictionary?p=信誉网上赌博中文博彩网站(关于信誉网上赌博中文博彩网站的简介)✔️网址:la666.net✔️.oqz" class="hidden">图片联盟 </a> <a href="https://m.facebook.com/public/科普一下冰球突破豪华版下载app的百科✔️网址:ad11.net✔️" class="hidden">金山铁路最新时刻表</a> <a href="https://stock.adobe.com/search?k=冰球突破正规网站>>✔️官方网址:la777.net✔️手输<<冰球突破正规网站>>✔️官方网址:la777.net✔️手输<<.npb" class="hidden">中国青年网-军事频道</a> <a href="/sttcs/hot-news/Acholoe.html" class="hidden">商业电讯</a> <a href="/CN/fabffk-483242" class="hidden">中国第二重型机械集团公司 </a> <a href="/cn/ssqwqv-101230" class="hidden">广西易登网</a> <a href="/cn/sxcehp-613870.html" class="hidden">橘汁仙剑网</a> <a href="/html/vjqpdx-452669.html" class="hidden">华企商学院全员学习系统</a> </body></html>