<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 https://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://rredxp.job908.com" class="hidden">中国客车信息网</a> <a href="http://web-sitemap.gglh03.com" class="hidden">亿企广告联盟</a> <a href="http://www.yutb.net" class="hidden">澳门新葡京博彩</a> <a href="http://www.braelyngenerator.net" class="hidden">太阳城娱乐城</a> <a href="http://www.zaibj.net" class="hidden">Crown-camp-marketing@zaibj.net</a> <a href="http://www.dienmaythanhlong.net" class="hidden">Sabah-Official-website-support@dienmaythanhlong.net</a> <a href="http://www.yibangyi.net" class="hidden">bet365亚洲官网</a> <a href="http://fanldq.pcwgiq.com" class="hidden">hao123网址之家</a> <a href="http://www.bigtrecords.com" class="hidden">欧洲杯竞猜</a> <a href="http://web-sitemap.35jiajiao.com" class="hidden"> 望海楼论坛</a> <a href="http://www.seezl.com" class="hidden">皇冠体育博彩</a> <a href="http://www.w-catering.com" class="hidden">2024欧洲杯竞猜</a> <a href="http://web-sitemap.cross-culturalcommunications.com" class="hidden"> 叶子猪八卦频道</a> <a href="http://www.cesametal.net" class="hidden">Asian-gaming-platform-rankings-contact@cesametal.net</a> <a href="http://mgtgqs.watashirikon.com" class="hidden">宿迁房产网</a> <a href="http://mjsowb.sweetsnnuts.com" class="hidden">椒江人力网</a> <a href="http://www.pronewport.com" class="hidden">Sun-City-Entertainment-feedback@pronewport.com</a> <a href="http://www.ruansaen.com" class="hidden">Sun-City-support@ruansaen.com</a> <a href="http://web-sitemap.25674.net" class="hidden">摩托车论坛 </a> <a href="http://www.berxwedan.net" class="hidden">Sports-betting-billing@berxwedan.net</a> <a href="https://m.facebook.com/public/✔️网址:la666.net✔️365bet即時比分✔️网址:la666.net✔️365bet即時比分.dtq" class="hidden">驻客公寓</a> <a href="https://stock.adobe.com/search/images?k=✔️最新网址:la55.net✔️线上买球app下载.tko" class="hidden">90分钟足球网</a> <a href="https://m.facebook.com/public/✔️网址:la666.net✔️科普一下最大网上赌博博彩网站推荐的百科.nkg" class="hidden">卡努努</a> <a href="https://es-la.facebook.com/public/✔️最新网址:la55.net✔️十大棋牌网赌软件网站平台介绍.crl" class="hidden">渤海证券</a> <a href="https://es-la.facebook.com/public/电竞菠菜人体育(中国)有限公司✔️最新网址:ad22.net✔️电竞菠菜人体育(中国)有限公司✔️最新网址:ad22.net✔️" class="hidden">美乐乐装修网 </a> <a href="https://es-la.facebook.com/public/>>✔️最新网址:la55.net✔️手输<<365买球下载.bsx" class="hidden">倚天中文网</a> <a href="https://stock.adobe.com/search?k=✔️官方网址:la777.net✔️8455新葡萄娱乐入口-8455新葡萄娱乐入口官方网站.iyu" class="hidden">奥远电子</a> <a href="https://stock.adobe.com/search?k=科普一下十大网投平台信誉排行榜首页的百科✔️网址:ad11.net✔️" class="hidden">中山四海家具制造有限公司</a> <a href="https://m.facebook.com/public/>>✔️最新网址:ad22.net✔️手输<<沙巴体育app.hmi" class="hidden">114上网导航 </a> <a href="https://es-la.facebook.com/public/永利app下载✔️网址:la666.net✔️.kla" class="hidden">中国地质大学(武汉)本科招生网</a> <a href="/cn/xfwmrf-753184" class="hidden">史丹利化肥股份有限公司</a> <a href="/sitemap.xml" class="hidden">站点地图</a> <a href="/html/eebvgq-152845.html" class="hidden">好时巧克力官网</a> <a href="/cn/otbpak-808689.html" class="hidden">一米工作</a> </body></html>