@nordhealth/components 4.16.0 → 4.17.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.
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownSubmenu.js","sources":["../src/dropdown-submenu/DropdownSubmenu.ts"],"sourcesContent":["import type Dropdown from '../dropdown/Dropdown.js'\nimport type Popout from '../popout/Popout.js'\nimport { html, LitElement } from 'lit'\nimport { customElement, property, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { EventController } from '../common/controllers/EventController.js'\nimport componentStyle from '../common/styles/Component.css'\nimport style from './DropdownSubmenu.css'\nimport '../popout/Popout.js'\n\nlet popoutCounter = 0\n\n/**\n * Dropdown submenu nests a secondary menu within a parent dropdown.\n * The trigger slot contains the item that opens the submenu, and the default slot contains the submenu items.\n *\n * Supports both hover (non-touch) and click (touch-devices/accessibility) interactions.\n *\n * On small screens, uses mobile stack navigation: tapping a submenu trigger replaces the\n * dropdown's visible content with the submenu's items and shows a back button.\n *\n * @status ready\n * @category action\n *\n * @slot trigger - The element that opens the submenu (typically nord-dropdown-item).\n * @slot - The submenu content items.\n *\n * @fires {NordEvent} open - Forwarded from the internal nord-popout.\n * @fires {NordEvent} close - Forwarded from the internal nord-popout.\n * @fires {CustomEvent} nord-submenu-navigate - Fired when mobile stack navigation activates this submenu.\n */\n@customElement('nord-dropdown-submenu')\nexport default class DropdownSubmenu extends LitElement {\n static styles = [componentStyle, style]\n\n @query('nord-popout')\n private popout?: Popout\n\n @property({ reflect: true, type: Boolean, attribute: 'mobile-active' })\n mobileActive = false\n\n private readonly popoutId = `nord-dropdown-submenu-popout-${++popoutCounter}`\n private events = new EventController(this)\n private currentTriggerElement: HTMLElement | null = null\n private popoutOpen = false\n private readonly mobileMediaQuery = window.matchMedia('(max-width: 35.9375em)')\n @state() private isSmallScreen = this.mobileMediaQuery.matches\n private parentDropdownAlwaysFloating = false\n\n private get shouldUseMobileStack(): boolean {\n return this.isSmallScreen && !this.parentDropdownAlwaysFloating\n }\n\n private get parentDropdown(): Dropdown | null {\n return this.closest<Dropdown>('nord-dropdown')\n }\n\n private get isInSubmenuStack(): boolean {\n const parent = this.parentDropdown\n if (!parent)\n return false\n return parent.submenuStackRef.includes(this)\n }\n\n private get isDeepestInStack(): boolean {\n const parent = this.parentDropdown\n if (!parent)\n return false\n return parent.deepestSubmenu === this\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n // Set aria-haspopup on trigger before first render\n const triggerElement = this.querySelector<HTMLElement>('[slot=\"trigger\"]')\n triggerElement?.setAttribute('aria-haspopup', 'menu')\n\n // Read alwaysFloating from parent dropdown\n const parentDropdown = this.closest<Dropdown>('nord-dropdown')\n if (parentDropdown) {\n this.parentDropdownAlwaysFloating = parentDropdown.alwaysFloating\n // Close this submenu when a sibling regular item is hovered\n this.events.listen(parentDropdown, 'mouseover', this.handleParentDropdownMouseOver)\n }\n\n // Listen for screen size changes (use correct breakpoint)\n this.events.listen(this.mobileMediaQuery, 'change', (event: MediaQueryListEvent) => {\n this.isSmallScreen = event.matches\n this.requestUpdate()\n })\n }\n\n render() {\n // Mobile stack navigation: show content inline when active\n if (this.shouldUseMobileStack && this.mobileActive) {\n // Add active class for any submenu in the stack, and is-deepest-active for the deepest one\n return html`\n <slot name=\"trigger\"></slot>\n <div class=${classMap({\n 'n-dropdown-submenu-content': true,\n 'active': this.isInSubmenuStack,\n 'is-deepest-active': this.isDeepestInStack,\n })} @keydown=${this.handleContentKeydown}>\n <slot></slot>\n </div>\n `\n }\n\n // Desktop/always-floating mode: show popout\n return html`\n <slot\n name=\"trigger\"\n aria-controls=${this.popoutId}\n @slotchange=${this.handleTriggerSlotChange}\n ></slot>\n <nord-popout\n id=${this.popoutId}\n position=\"inline-end\"\n always-floating\n @open=${this.handlePopoutOpen}\n @close=${this.handlePopoutClose}\n >\n <div\n class=\"n-dropdown-submenu-content\"\n @keydown=${this.handleContentKeydown}\n >\n <slot></slot>\n </div>\n </nord-popout>\n `\n }\n\n private handleTriggerSlotChange() {\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]')\n const triggerElement = slot?.assignedElements()[0] as HTMLElement | undefined\n\n // Remove listeners from previous trigger element\n if (this.currentTriggerElement && this.currentTriggerElement !== triggerElement) {\n this.currentTriggerElement.removeEventListener('mouseenter', this.handleTriggerMouseEnter)\n this.currentTriggerElement.removeEventListener('click', this.handleTriggerClick)\n this.currentTriggerElement.removeEventListener('keydown', this.handleTriggerKeydown)\n }\n\n this.currentTriggerElement = triggerElement ?? null\n\n if (!triggerElement)\n return\n\n triggerElement.setAttribute('aria-haspopup', 'menu')\n\n const isTouchDevice = !window.matchMedia('(hover: hover)').matches\n\n // Non-touch devices: hover to open\n this.events.listen(triggerElement, 'mouseenter', this.handleTriggerMouseEnter)\n // Non-touch devices or small screens: click to navigate/open\n if (!isTouchDevice || this.isSmallScreen) {\n this.events.listen(triggerElement, 'click', this.handleTriggerClick)\n }\n // Keyboard: arrow keys for navigation\n this.events.listen(triggerElement, 'keydown', this.handleTriggerKeydown)\n }\n\n private handleTriggerMouseEnter = () => {\n // On mobile, don't open popout on hover — only on click\n if (this.shouldUseMobileStack)\n return\n\n this.closeOtherSubmenus()\n this.popout?.show()\n }\n\n private handleTriggerClick = (event: MouseEvent) => {\n event.preventDefault()\n event.stopImmediatePropagation()\n\n if (this.shouldUseMobileStack) {\n this.navigateIntoSubmenu()\n return\n }\n\n this.closeOtherSubmenus()\n this.popout?.show()\n }\n\n private handleTriggerKeydown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowRight' || event.key === 'Enter') {\n event.preventDefault()\n\n if (this.shouldUseMobileStack) {\n this.navigateIntoSubmenu()\n return\n }\n\n this.closeOtherSubmenus()\n this.popout?.show()\n this.updateComplete.then(() => {\n this.querySelector<HTMLElement>('nord-dropdown-item')?.focus()\n })\n }\n }\n\n private handleContentKeydown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowLeft') {\n event.preventDefault()\n event.stopPropagation()\n\n if (this.shouldUseMobileStack && this.mobileActive) {\n this.closest<Dropdown>('nord-dropdown')?.navigateBack()\n return\n }\n\n this.popout?.hide(true)\n }\n }\n\n private handlePopoutOpen = () => {\n this.popoutOpen = true\n this.closeOtherSubmenus()\n }\n\n private handlePopoutClose = (event: Event) => {\n event.stopPropagation()\n this.popoutOpen = false\n }\n\n private handleParentDropdownMouseOver = (event: MouseEvent) => {\n // Don't close on mouseover during mobile stack navigation\n if (this.shouldUseMobileStack)\n return\n\n const target = event.target as HTMLElement\n const isRegularDropdownItem = target.tagName === 'NORD-DROPDOWN-ITEM' && !this.contains(target)\n if (isRegularDropdownItem && this.popoutOpen) {\n event.stopImmediatePropagation()\n this.popout?.hide()\n }\n }\n\n private closeOtherSubmenus() {\n // Don't close siblings during mobile stack navigation\n if (this.shouldUseMobileStack)\n return\n\n // Find the immediate parent container (dropdown or submenu)\n const immediateParent = this.parentElement?.closest('nord-dropdown, nord-dropdown-submenu')\n if (!immediateParent)\n return\n\n // Close only siblings at the same level\n Array.from(\n immediateParent.querySelectorAll<DropdownSubmenu>(':scope > nord-dropdown-submenu'),\n ).forEach((sibling) => {\n if (sibling !== this)\n sibling.close()\n })\n }\n\n /**\n * Deactivate mobile stack navigation (remove from stack).\n * @internal\n */\n deactivateMobile() {\n this.mobileActive = false\n\n // Clear aria-expanded that may have been set by Popout during hover\n const triggerSlot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]')\n const triggerElement = triggerSlot?.assignedElements()[0] as HTMLElement | undefined\n triggerElement?.removeAttribute('aria-expanded')\n }\n\n /**\n * Read trigger text for back button title in Dropdown.\n * @internal\n */\n get label(): string {\n const triggerSlot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]')\n return triggerSlot?.assignedElements()[0]?.textContent?.trim() ?? ''\n }\n\n /**\n * Close the submenu programmatically.\n * Returns a promise that resolves when the close animation completes.\n */\n close(): Promise<TransitionEvent | void> {\n if (this.mobileActive) {\n this.deactivateMobile()\n return Promise.resolve()\n }\n\n if (!this.popout) {\n return Promise.reject(new Error('DropdownSubmenu: popout component not found or not ready'))\n }\n return this.popout.hide()\n }\n\n /**\n * Navigate into this submenu using mobile stack navigation.\n * @internal\n */\n private navigateIntoSubmenu() {\n this.mobileActive = true\n this.dispatchEvent(\n new CustomEvent('nord-submenu-navigate', { bubbles: true, detail: { submenu: this } }),\n )\n this.updateComplete.then(() => {\n // Focus on first submenu item (not back button in header)\n const contentDiv = this.querySelector('.n-dropdown-submenu-content')\n const firstItem = contentDiv?.querySelector<HTMLElement>('nord-dropdown-item')\n firstItem?.focus()\n })\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-dropdown-submenu': DropdownSubmenu\n }\n}\n"],"names":["popoutCounter","DropdownSubmenu","LitElement","constructor","this","mobileActive","popoutId","events","EventController","currentTriggerElement","popoutOpen","mobileMediaQuery","window","matchMedia","isSmallScreen","matches","parentDropdownAlwaysFloating","handleTriggerMouseEnter","shouldUseMobileStack","closeOtherSubmenus","_a","popout","show","handleTriggerClick","event","preventDefault","stopImmediatePropagation","navigateIntoSubmenu","handleTriggerKeydown","key","updateComplete","then","querySelector","focus","handleContentKeydown","stopPropagation","closest","navigateBack","_b","hide","handlePopoutOpen","handlePopoutClose","handleParentDropdownMouseOver","target","tagName","contains","parentDropdown","isInSubmenuStack","parent","submenuStackRef","includes","isDeepestInStack","deepestSubmenu","connectedCallback","super","triggerElement","setAttribute","alwaysFloating","listen","requestUpdate","render","html","classMap","active","handleTriggerSlotChange","slot","shadowRoot","assignedElements","removeEventListener","isTouchDevice","immediateParent","parentElement","Array","from","querySelectorAll","forEach","sibling","close","deactivateMobile","triggerSlot","removeAttribute","label","_d","textContent","_c","trim","Promise","resolve","reject","Error","dispatchEvent","CustomEvent","bubbles","detail","submenu","contentDiv","firstItem","styles","componentStyle","style","__decorate","query","prototype","property","reflect","type","Boolean","attribute","state","customElement"],"mappings":"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6B,QAAf3D,EAAAhB,KAAK8D,kBAAU,IAAA9C,OAAA,EAAAA,EAAEY,cAA+B,wBACpE,OAA8D,QAAvDkD,EAA+C,kBAA/C5C,EAAAyC,aAAW,EAAXA,EAAaZ,mBAAmB,yBAAIgB,mBAAW,IAAAC,OAAA,EAAAA,EAAEC,cAAM,IAAAH,EAAAA,EAAI,EACnE,CAMD,KAAAL,GACE,OAAIzE,KAAKC,cACPD,KAAK0E,mBACEQ,QAAQC,WAGZnF,KAAKiB,OAGHjB,KAAKiB,OAAOkB,OAFV+C,QAAQE,OAAO,IAAIC,MAAM,4DAGnC,CAMO,mBAAA9D,GACNvB,KAAKC,cAAe,EACpBD,KAAKsF,cACH,IAAIC,YAAY,wBAAyB,CAAEC,SAAS,EAAMC,OAAQ,CAAEC,QAAS1F,SAE/EA,KAAK0B,eAAeC,MAAK,KAEvB,MAAMgE,EAAa3F,KAAK4B,cAAc,+BAChCgE,EAAYD,aAAU,EAAVA,EAAY/D,cAA2B,sBACzDgE,SAAAA,EAAW/D,OAAO,GAErB,GAtRMhC,EAAAgG,OAAS,CAACC,EAAgBC,GAGzBC,EAAA,CADPC,EAAM,gBACgBpG,EAAAqG,UAAA,cAAA,GAGvBF,EAAA,CADCG,EAAS,CAAEC,SAAS,EAAMC,KAAMC,QAASC,UAAW,mBACjC1G,EAAAqG,UAAA,oBAAA,GAOHF,EAAA,CAAhBQ,KAA6D3G,EAAAqG,UAAA,qBAAA,GAd3CrG,EAAemG,EAAA,CADnCS,EAAc,0BACM5G,SAAAA"}
1
+ {"version":3,"file":"DropdownSubmenu.js","sources":["../src/dropdown-submenu/DropdownSubmenu.ts"],"sourcesContent":["import type Dropdown from '../dropdown/Dropdown.js'\nimport type Popout from '../popout/Popout.js'\nimport { html, LitElement } from 'lit'\nimport { customElement, query, state } from 'lit/decorators.js'\nimport { classMap } from 'lit/directives/class-map.js'\nimport { EventController } from '../common/controllers/EventController.js'\nimport componentStyle from '../common/styles/Component.css'\nimport style from './DropdownSubmenu.css'\nimport '../popout/Popout.js'\n\nlet popoutCounter = 0\n\n/**\n * Dropdown submenu nests a secondary menu within a parent dropdown.\n * The trigger slot contains the item that opens the submenu, and the default slot contains the submenu items.\n *\n * Supports both hover (non-touch) and click (touch-devices/accessibility) interactions.\n *\n * On small screens, uses mobile stack navigation: tapping a submenu trigger replaces the\n * dropdown's visible content with the submenu's items and shows a back button.\n *\n * @status ready\n * @category action\n *\n * @slot trigger - The element that opens the submenu (typically nord-dropdown-item).\n * @slot - The submenu content items.\n *\n * @fires {NordEvent} open - Forwarded from the internal nord-popout.\n * @fires {NordEvent} close - Forwarded from the internal nord-popout.\n * @fires {CustomEvent} nord-submenu-navigate - Fired when mobile stack navigation activates this submenu.\n */\n@customElement('nord-dropdown-submenu')\nexport default class DropdownSubmenu extends LitElement {\n static styles = [componentStyle, style]\n\n @query('nord-popout')\n private popout?: Popout\n\n /** @internal */\n @state() private mobileActive = false\n\n private readonly popoutId = `nord-dropdown-submenu-popout-${++popoutCounter}`\n private events = new EventController(this)\n private currentTriggerElement: HTMLElement | null = null\n private popoutOpen = false\n private readonly mobileMediaQuery = window.matchMedia('(max-width: 35.9375em)')\n @state() private isSmallScreen = this.mobileMediaQuery.matches\n @state() private parentDropdownAlwaysFloating = false\n private parentObserver?: MutationObserver\n\n private get shouldUseMobileStack(): boolean {\n return this.isSmallScreen && !this.parentDropdownAlwaysFloating\n }\n\n private get parentDropdown(): Dropdown | null {\n return this.closest<Dropdown>('nord-dropdown')\n }\n\n private get isInSubmenuStack(): boolean {\n const parent = this.parentDropdown\n if (!parent)\n return false\n return parent.submenuStackRef.includes(this)\n }\n\n private get isDeepestInStack(): boolean {\n const parent = this.parentDropdown\n if (!parent)\n return false\n return parent.deepestSubmenu === this\n }\n\n connectedCallback() {\n super.connectedCallback()\n\n // Set aria-haspopup on trigger before first render\n const triggerElement = this.querySelector<HTMLElement>('[slot=\"trigger\"]')\n triggerElement?.setAttribute('aria-haspopup', 'menu')\n\n // Read alwaysFloating from parent dropdown\n const parentDropdown = this.closest<Dropdown>('nord-dropdown')\n if (parentDropdown) {\n this.parentDropdownAlwaysFloating = parentDropdown.alwaysFloating\n // Close this submenu when a sibling regular item is hovered\n this.events.listen(parentDropdown, 'mouseover', this.handleParentDropdownMouseOver)\n\n // Observe always-floating attribute on parent dropdown for reactivity\n this.parentObserver = new MutationObserver((mutations) => {\n for (const mutation of mutations) {\n if (mutation.attributeName === 'always-floating') {\n this.parentDropdownAlwaysFloating = parentDropdown.alwaysFloating\n }\n }\n })\n this.parentObserver.observe(parentDropdown, {\n attributes: true,\n attributeFilter: ['always-floating'],\n })\n }\n\n // Listen for screen size changes (use correct breakpoint)\n this.events.listen(this.mobileMediaQuery, 'change', (event: MediaQueryListEvent) => {\n this.isSmallScreen = event.matches\n this.requestUpdate()\n })\n }\n\n disconnectedCallback() {\n super.disconnectedCallback()\n this.parentObserver?.disconnect()\n }\n\n render() {\n // Mobile stack navigation: show content inline when active\n if (this.shouldUseMobileStack && this.mobileActive) {\n // Add active class for any submenu in the stack, and is-deepest-active for the deepest one\n return html`\n <slot name=\"trigger\"></slot>\n <div class=${classMap({\n 'n-dropdown-submenu-content': true,\n 'active': this.isInSubmenuStack,\n 'is-deepest-active': this.isDeepestInStack,\n })} @keydown=${this.handleContentKeydown}>\n <slot></slot>\n </div>\n `\n }\n\n // Desktop/always-floating mode: show popout\n return html`\n <slot\n name=\"trigger\"\n aria-controls=${this.popoutId}\n @slotchange=${this.handleTriggerSlotChange}\n ></slot>\n <nord-popout\n id=${this.popoutId}\n position=\"inline-end\"\n always-floating\n @open=${this.handlePopoutOpen}\n @close=${this.handlePopoutClose}\n >\n <div\n class=\"n-dropdown-submenu-content\"\n @keydown=${this.handleContentKeydown}\n >\n <slot></slot>\n </div>\n </nord-popout>\n `\n }\n\n private handleTriggerSlotChange() {\n const slot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]')\n const triggerElement = slot?.assignedElements()[0] as HTMLElement | undefined\n\n // Remove listeners from previous trigger element\n if (this.currentTriggerElement && this.currentTriggerElement !== triggerElement) {\n this.currentTriggerElement.removeEventListener('mouseenter', this.handleTriggerMouseEnter)\n this.currentTriggerElement.removeEventListener('click', this.handleTriggerClick)\n this.currentTriggerElement.removeEventListener('keydown', this.handleTriggerKeydown)\n }\n\n this.currentTriggerElement = triggerElement ?? null\n\n if (!triggerElement)\n return\n\n triggerElement.setAttribute('aria-haspopup', 'menu')\n\n const isTouchDevice = !window.matchMedia('(hover: hover)').matches\n\n // Non-touch devices: hover to open\n this.events.listen(triggerElement, 'mouseenter', this.handleTriggerMouseEnter)\n // Non-touch devices or small screens: click to navigate/open\n if (!isTouchDevice || this.isSmallScreen) {\n this.events.listen(triggerElement, 'click', this.handleTriggerClick)\n }\n // Keyboard: arrow keys for navigation\n this.events.listen(triggerElement, 'keydown', this.handleTriggerKeydown)\n }\n\n private handleTriggerMouseEnter = () => {\n // On mobile, don't open popout on hover — only on click\n if (this.shouldUseMobileStack)\n return\n\n this.closeOtherSubmenus()\n this.popout?.show()\n }\n\n private handleTriggerClick = (event: MouseEvent) => {\n event.preventDefault()\n event.stopImmediatePropagation()\n\n if (this.shouldUseMobileStack) {\n this.navigateIntoSubmenu()\n return\n }\n\n this.closeOtherSubmenus()\n this.popout?.show()\n }\n\n private handleTriggerKeydown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowRight' || event.key === 'Enter') {\n event.preventDefault()\n\n if (this.shouldUseMobileStack) {\n this.navigateIntoSubmenu()\n return\n }\n\n this.closeOtherSubmenus()\n this.popout?.show()\n this.updateComplete.then(() => {\n this.querySelector<HTMLElement>('nord-dropdown-item')?.focus()\n })\n }\n }\n\n private handleContentKeydown = (event: KeyboardEvent) => {\n if (event.key === 'ArrowLeft') {\n event.preventDefault()\n event.stopPropagation()\n\n if (this.shouldUseMobileStack && this.mobileActive) {\n this.closest<Dropdown>('nord-dropdown')?.navigateBack()\n return\n }\n\n this.popout?.hide(true)\n }\n }\n\n private handlePopoutOpen = () => {\n this.popoutOpen = true\n this.closeOtherSubmenus()\n }\n\n private handlePopoutClose = (event: Event) => {\n event.stopPropagation()\n this.popoutOpen = false\n }\n\n private handleParentDropdownMouseOver = (event: MouseEvent) => {\n // Don't close on mouseover during mobile stack navigation\n if (this.shouldUseMobileStack)\n return\n\n const target = event.target as HTMLElement\n const isRegularDropdownItem = target.tagName === 'NORD-DROPDOWN-ITEM' && !this.contains(target)\n if (isRegularDropdownItem && this.popoutOpen) {\n event.stopImmediatePropagation()\n this.popout?.hide()\n }\n }\n\n private closeOtherSubmenus() {\n // Don't close siblings during mobile stack navigation\n if (this.shouldUseMobileStack)\n return\n\n // Find the immediate parent container (dropdown or submenu)\n const immediateParent = this.parentElement?.closest('nord-dropdown, nord-dropdown-submenu')\n if (!immediateParent)\n return\n\n // Close only siblings at the same level\n Array.from(\n immediateParent.querySelectorAll<DropdownSubmenu>(':scope > nord-dropdown-submenu'),\n ).forEach((sibling) => {\n if (sibling !== this)\n sibling.close()\n })\n }\n\n /**\n * Deactivate mobile stack navigation (remove from stack).\n * @internal\n */\n deactivateMobile() {\n this.mobileActive = false\n\n // NATIVELY REMOVE THE ATTRIBUTE FROM THE HOST\n this.removeAttribute('mobile-active')\n\n // Clear aria-expanded that may have been set by Popout during hover\n const triggerSlot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]')\n const triggerElement = triggerSlot?.assignedElements()[0] as HTMLElement | undefined\n triggerElement?.removeAttribute('aria-expanded')\n }\n\n /**\n * Read trigger text for back button title in Dropdown.\n * @internal\n */\n get label(): string {\n const triggerSlot = this.shadowRoot?.querySelector<HTMLSlotElement>('slot[name=\"trigger\"]')\n return triggerSlot?.assignedElements()[0]?.textContent?.trim() ?? ''\n }\n\n /**\n * Close the submenu programmatically.\n * Returns a promise that resolves when the close animation completes.\n */\n close(): Promise<TransitionEvent | void> {\n if (this.mobileActive) {\n this.deactivateMobile()\n return Promise.resolve()\n }\n\n if (!this.popout) {\n return Promise.reject(new Error('DropdownSubmenu: popout component not found or not ready'))\n }\n return this.popout.hide()\n }\n\n /**\n * Navigate into this submenu using mobile stack navigation.\n * @internal\n */\n private navigateIntoSubmenu() {\n this.mobileActive = true\n this.setAttribute('mobile-active', '')\n this.dispatchEvent(\n new CustomEvent('nord-submenu-navigate', { bubbles: true, detail: { submenu: this } }),\n )\n this.updateComplete.then(() => {\n // Focus on first submenu item (not back button in header)\n const contentDiv = this.querySelector('.n-dropdown-submenu-content')\n const firstItem = contentDiv?.querySelector<HTMLElement>('nord-dropdown-item')\n firstItem?.focus()\n })\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'nord-dropdown-submenu': DropdownSubmenu\n }\n}\n"],"names":["popoutCounter","DropdownSubmenu","LitElement","constructor","this","mobileActive","popoutId","events","EventController","currentTriggerElement","popoutOpen","mobileMediaQuery","window","matchMedia","isSmallScreen","matches","parentDropdownAlwaysFloating","handleTriggerMouseEnter","shouldUseMobileStack","closeOtherSubmenus","_a","popout","show","handleTriggerClick","event","preventDefault","stopImmediatePropagation","navigateIntoSubmenu","handleTriggerKeydown","key","updateComplete","then","querySelector","focus","handleContentKeydown","stopPropagation","closest","navigateBack","_b","hide","handlePopoutOpen","handlePopoutClose","handleParentDropdownMouseOver","target","tagName","contains","parentDropdown","isInSubmenuStack","parent","submenuStackRef","includes","isDeepestInStack","deepestSubmenu","connectedCallback","super","triggerElement","setAttribute","alwaysFloating","listen","parentObserver","MutationObserver","mutations","mutation","attributeName","observe","attributes","attributeFilter","requestUpdate","disconnectedCallback","disconnect","render","html","classMap","active","handleTriggerSlotChange","slot","shadowRoot","assignedElements","removeEventListener","isTouchDevice","immediateParent","parentElement","Array","from","querySelectorAll","forEach","sibling","close","deactivateMobile","removeAttribute","triggerSlot","label","_d","textContent","_c","trim","Promise","resolve","reject","Error","dispatchEvent","CustomEvent","bubbles","detail","submenu","contentDiv","firstItem","styles","componentStyle","style","__decorate","query","prototype","state","customElement"],"mappings":"8iEAUA,I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