<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://ppartk.74sdf25a.com" class="hidden">爱唱</a> <a href="http://www.sqwyhws.com" class="hidden">ag-Asia-Travel-Group-support@sqwyhws.com</a> <a href="http://web-sitemap.fydyms.net" class="hidden">分级基金网</a> <a href="http://yhaafq.sunwavecentre.com" class="hidden">拳皇小游戏</a> <a href="http://wkoqtw.zgcbg.net" class="hidden">麦德龙(中国)官方网上商城</a> <a href="http://www.dp120.com" class="hidden">Sun-City-official-website-hr@dp120.com</a> <a href="http://www.katarre.com" class="hidden">欧洲杯买球</a> <a href="http://qjevbq.whtmy.com" class="hidden">大众影评网</a> <a href="http://www.551yule.com" class="hidden">体育平台</a> <a href="http://www.izuanhui.net" class="hidden">买球平台</a> <a href="http://www.cceweb.net" class="hidden">Casino-platform-service@cceweb.net</a> <a href="http://www.w-catering.com" class="hidden">2024欧洲杯竞猜</a> <a href="http://www.ruansaen.com" class="hidden">Sun-City-support@ruansaen.com</a> <a href="http://bsiggn.xingyoupg.com" class="hidden">鹰潭天气预报</a> <a href="http://www.castingmoldingmachine.com" class="hidden">New-Portuguese-gambling-official-website-info@castingmoldingmachine.com</a> <a href="http://www.cesametal.net" class="hidden">Asian-gaming-platform-rankings-contact@cesametal.net</a> <a href="http://www.tdwang.net" class="hidden">体育博彩</a> <a href="http://web-sitemap.gameuno.net" class="hidden">长城电脑官网</a> <a href="http://nqxtno.yifucn.com" class="hidden">华龙期货</a> <a href="http://www.tdwang.net" class="hidden">Crown-cash-sales@tdwang.net</a> <a href="https://tw.dictionary.yahoo.com/dictionary?p=网上赌博推荐靠谱的赌博软件(关于网上赌博推荐靠谱的赌博软件的简介)✔️网址:la66.net✔️" class="hidden">星际传奇</a> <a href="https://es-la.facebook.com/public/✔️最新网址:ad22.net✔️双色球100%的出号规律✔️最新网址:ad22.net✔️双色球100%的出号规律.ayq" class="hidden">荔枝台</a> <a href="https://m.facebook.com/public/澳门唯一正规官方网站-维基百科✔️最新网址:la55.net✔️" class="hidden">齐云社区</a> <a href="https://stock.adobe.com/search/images?k=✔️官方网址:la777.net✔️365betapp手机版下载" class="hidden">手机定位</a> <a href="https://m.facebook.com/public/澳门皇冠赌场皇冠游戏>>✔️网址:la66.net✔️手输<<.lje" class="hidden">VOGUE时尚网时尚品牌库</a> <a href="https://www.deep6gear.com/catalogsearch/result/?q=✔️最新网址:la55.net✔️沙巴体育结算平台" class="hidden">乐之邦 MUSILAND</a> <a href="https://www.deep6gear.com/catalogsearch/result/?q=✔️网址:la66.net✔️科普一下在线赌博排名靠谱的赌博网站的百科.yxq" class="hidden">龙游房产网</a> <a href="https://stock.adobe.com/search/images?k=>>✔️网址:la66.net✔️手输<<买球推荐软件app排名.nes" class="hidden">中威电子</a> <a href="https://es-la.facebook.com/public/信誉彩票平台排行榜(关于信誉彩票平台排行榜的简介)✔️官方网址:la777.net✔️" class="hidden">专业泰语学习网站</a> <a href="https://m.facebook.com/public/十大赌博靠谱信誉平台✔️网址:la66.net✔️十大赌博靠谱信誉平台✔️网址:la66.net✔️.gmt" class="hidden">中原工学院</a> <a href="/CN/fzzdrl-984248.html" class="hidden">财经头条网</a> <a href="/sttcs/hot-news/sandboy.html" class="hidden">虎扑篮球视频中心</a> <a href="/sttcs/hot-news/piddle.html" class="hidden">ASP300源码</a> <a href="/html/qhhuai-198032.html" class="hidden">海口新闻网</a> <a href="/news/hkpztz-200641.html" class="hidden">辽宁新闻频道</a> </body></html>