@duskmoon-dev/el-popover 1.5.6 → 1.6.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/dist/cjs/index.js +32 -5
- package/dist/cjs/index.js.map +3 -3
- package/dist/cjs/register.js +32 -5
- package/dist/cjs/register.js.map +3 -3
- package/dist/esm/index.js +32 -5
- package/dist/esm/index.js.map +3 -3
- package/dist/esm/register.js +32 -5
- package/dist/esm/register.js.map +3 -3
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/el-dm-popover.d.ts +3 -0
- package/dist/types/el-dm-popover.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/cjs/index.js
CHANGED
|
@@ -154,6 +154,7 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
154
154
|
_boundUpdatePosition;
|
|
155
155
|
_hoverTimeout = null;
|
|
156
156
|
_currentPlacement = "bottom";
|
|
157
|
+
_restoringFocus = false;
|
|
157
158
|
constructor() {
|
|
158
159
|
super();
|
|
159
160
|
this.attachStyles([styles, import_el_base.animationStyles]);
|
|
@@ -223,7 +224,7 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
223
224
|
this._attachTriggerEvents();
|
|
224
225
|
}
|
|
225
226
|
_attachTriggerEvents() {
|
|
226
|
-
const triggerEl = this.
|
|
227
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
227
228
|
if (!triggerEl)
|
|
228
229
|
return;
|
|
229
230
|
this._detachTriggerEvents(triggerEl);
|
|
@@ -250,18 +251,36 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
250
251
|
this.removeEventListener("mouseleave", this._handlePopoverMouseLeave);
|
|
251
252
|
}
|
|
252
253
|
_removeTriggerListeners() {
|
|
253
|
-
const triggerEl = this.
|
|
254
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
254
255
|
if (triggerEl) {
|
|
255
256
|
this._detachTriggerEvents(triggerEl);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
|
|
259
|
+
_getAssignedTriggerElement() {
|
|
259
260
|
const triggerSlot = this.shadowRoot?.querySelector('slot[name="trigger"]');
|
|
260
261
|
if (!triggerSlot)
|
|
261
262
|
return null;
|
|
262
263
|
const assigned = triggerSlot.assignedElements();
|
|
263
264
|
return assigned[0] || null;
|
|
264
265
|
}
|
|
266
|
+
_getTriggerElement() {
|
|
267
|
+
const assigned = this._getAssignedTriggerElement();
|
|
268
|
+
if (!assigned)
|
|
269
|
+
return null;
|
|
270
|
+
if (assigned.matches(this._focusableSelector)) {
|
|
271
|
+
return assigned;
|
|
272
|
+
}
|
|
273
|
+
return assigned.querySelector(this._focusableSelector) ?? assigned;
|
|
274
|
+
}
|
|
275
|
+
_focusableSelector = [
|
|
276
|
+
"a[href]",
|
|
277
|
+
"button:not([disabled])",
|
|
278
|
+
"input:not([disabled])",
|
|
279
|
+
"select:not([disabled])",
|
|
280
|
+
"textarea:not([disabled])",
|
|
281
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
282
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
283
|
+
].join(",");
|
|
265
284
|
_handleTriggerClick = () => {
|
|
266
285
|
this.toggle();
|
|
267
286
|
};
|
|
@@ -289,6 +308,8 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
289
308
|
}, 100);
|
|
290
309
|
};
|
|
291
310
|
_handleTriggerFocus = () => {
|
|
311
|
+
if (this._restoringFocus)
|
|
312
|
+
return;
|
|
292
313
|
this.show();
|
|
293
314
|
};
|
|
294
315
|
_handleTriggerBlur = () => {
|
|
@@ -322,7 +343,13 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
322
343
|
if (e.key === "Escape") {
|
|
323
344
|
this.hide();
|
|
324
345
|
const triggerEl = this._getTriggerElement();
|
|
325
|
-
triggerEl?.focus
|
|
346
|
+
if (triggerEl?.focus) {
|
|
347
|
+
this._restoringFocus = true;
|
|
348
|
+
triggerEl.focus();
|
|
349
|
+
queueMicrotask(() => {
|
|
350
|
+
this._restoringFocus = false;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
326
353
|
}
|
|
327
354
|
}
|
|
328
355
|
_handleScroll() {
|
|
@@ -457,5 +484,5 @@ function register() {
|
|
|
457
484
|
}
|
|
458
485
|
}
|
|
459
486
|
|
|
460
|
-
//# debugId=
|
|
487
|
+
//# debugId=B35C0746A542D0C164756E2164756E21
|
|
461
488
|
//# sourceMappingURL=index.js.map
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/el-dm-popover.ts", "../../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n triggerEl?.focus?.();\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
5
|
+
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n private _restoringFocus = false;\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getAssignedTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _getTriggerElement(): Element | null {\n const assigned = this._getAssignedTriggerElement();\n if (!assigned) return null;\n\n if (assigned.matches(this._focusableSelector)) {\n return assigned;\n }\n\n return assigned.querySelector(this._focusableSelector) ?? assigned;\n }\n\n private readonly _focusableSelector = [\n 'a[href]',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ].join(',');\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n if (this._restoringFocus) return;\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n if (triggerEl?.focus) {\n this._restoringFocus = true;\n triggerEl.focus();\n queueMicrotask(() => {\n this._restoringFocus = false;\n });\n }\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
6
6
|
"/**\n * @duskmoon-dev/el-popover\n *\n * DuskMoon Popover custom element\n */\n\nimport { ElDmPopover } from './el-dm-popover.js';\n\nexport { ElDmPopover };\nexport type { PopoverPlacement, PopoverTrigger } from './el-dm-popover.js';\n\n/**\n * Register the el-dm-popover custom element\n *\n * @example\n * ```ts\n * import { register } from '@duskmoon-dev/el-popover';\n * register();\n * ```\n */\nexport function register(): void {\n if (!customElements.get('el-dm-popover')) {\n customElements.define('el-dm-popover', ElDmPopover);\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBkD,IAAlD;AACkC,IAAlC;AAmBA,IAAM,aAAa,mBAAW,QAAQ,4BAA4B,EAAE,EAAE,QAAQ,UAAU,EAAE;AAE1F,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiFG,MAAM,oBAAoB,2BAAY;AAAA,SACpC,aAAa;AAAA,IAClB,MAAM,EAAE,MAAM,SAAS,SAAS,MAAM,SAAS,MA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MAAM;AAAA,QAC1B,KAAK,gBAAgB;AAAA,QACrB,KAAK,YAAY,IAAI;AAAA,OACtB;AAAA,IACH;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BASe,KAAK;AAAA;AAAA,UAErB,KAAK,QAAQ,mDAAmD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO1E;;;ACljBO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AAAA,IACxC,eAAe,OAAO,iBAAiB,WAAW;AAAA,EACpD;AAAA;",
|
|
9
|
+
"debugId": "B35C0746A542D0C164756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/cjs/register.js
CHANGED
|
@@ -154,6 +154,7 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
154
154
|
_boundUpdatePosition;
|
|
155
155
|
_hoverTimeout = null;
|
|
156
156
|
_currentPlacement = "bottom";
|
|
157
|
+
_restoringFocus = false;
|
|
157
158
|
constructor() {
|
|
158
159
|
super();
|
|
159
160
|
this.attachStyles([styles, import_el_base.animationStyles]);
|
|
@@ -223,7 +224,7 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
223
224
|
this._attachTriggerEvents();
|
|
224
225
|
}
|
|
225
226
|
_attachTriggerEvents() {
|
|
226
|
-
const triggerEl = this.
|
|
227
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
227
228
|
if (!triggerEl)
|
|
228
229
|
return;
|
|
229
230
|
this._detachTriggerEvents(triggerEl);
|
|
@@ -250,18 +251,36 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
250
251
|
this.removeEventListener("mouseleave", this._handlePopoverMouseLeave);
|
|
251
252
|
}
|
|
252
253
|
_removeTriggerListeners() {
|
|
253
|
-
const triggerEl = this.
|
|
254
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
254
255
|
if (triggerEl) {
|
|
255
256
|
this._detachTriggerEvents(triggerEl);
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
|
|
259
|
+
_getAssignedTriggerElement() {
|
|
259
260
|
const triggerSlot = this.shadowRoot?.querySelector('slot[name="trigger"]');
|
|
260
261
|
if (!triggerSlot)
|
|
261
262
|
return null;
|
|
262
263
|
const assigned = triggerSlot.assignedElements();
|
|
263
264
|
return assigned[0] || null;
|
|
264
265
|
}
|
|
266
|
+
_getTriggerElement() {
|
|
267
|
+
const assigned = this._getAssignedTriggerElement();
|
|
268
|
+
if (!assigned)
|
|
269
|
+
return null;
|
|
270
|
+
if (assigned.matches(this._focusableSelector)) {
|
|
271
|
+
return assigned;
|
|
272
|
+
}
|
|
273
|
+
return assigned.querySelector(this._focusableSelector) ?? assigned;
|
|
274
|
+
}
|
|
275
|
+
_focusableSelector = [
|
|
276
|
+
"a[href]",
|
|
277
|
+
"button:not([disabled])",
|
|
278
|
+
"input:not([disabled])",
|
|
279
|
+
"select:not([disabled])",
|
|
280
|
+
"textarea:not([disabled])",
|
|
281
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
282
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
283
|
+
].join(",");
|
|
265
284
|
_handleTriggerClick = () => {
|
|
266
285
|
this.toggle();
|
|
267
286
|
};
|
|
@@ -289,6 +308,8 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
289
308
|
}, 100);
|
|
290
309
|
};
|
|
291
310
|
_handleTriggerFocus = () => {
|
|
311
|
+
if (this._restoringFocus)
|
|
312
|
+
return;
|
|
292
313
|
this.show();
|
|
293
314
|
};
|
|
294
315
|
_handleTriggerBlur = () => {
|
|
@@ -322,7 +343,13 @@ class ElDmPopover extends import_el_base.BaseElement {
|
|
|
322
343
|
if (e.key === "Escape") {
|
|
323
344
|
this.hide();
|
|
324
345
|
const triggerEl = this._getTriggerElement();
|
|
325
|
-
triggerEl?.focus
|
|
346
|
+
if (triggerEl?.focus) {
|
|
347
|
+
this._restoringFocus = true;
|
|
348
|
+
triggerEl.focus();
|
|
349
|
+
queueMicrotask(() => {
|
|
350
|
+
this._restoringFocus = false;
|
|
351
|
+
});
|
|
352
|
+
}
|
|
326
353
|
}
|
|
327
354
|
}
|
|
328
355
|
_handleScroll() {
|
|
@@ -460,5 +487,5 @@ function register() {
|
|
|
460
487
|
// src/register.ts
|
|
461
488
|
register();
|
|
462
489
|
|
|
463
|
-
//# debugId=
|
|
490
|
+
//# debugId=E69A1A68C3DF10B964756E2164756E21
|
|
464
491
|
//# sourceMappingURL=register.js.map
|
package/dist/cjs/register.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/el-dm-popover.ts", "../../src/index.ts", "../../src/register.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n triggerEl?.focus?.();\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
5
|
+
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n private _restoringFocus = false;\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getAssignedTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _getTriggerElement(): Element | null {\n const assigned = this._getAssignedTriggerElement();\n if (!assigned) return null;\n\n if (assigned.matches(this._focusableSelector)) {\n return assigned;\n }\n\n return assigned.querySelector(this._focusableSelector) ?? assigned;\n }\n\n private readonly _focusableSelector = [\n 'a[href]',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ].join(',');\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n if (this._restoringFocus) return;\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n if (triggerEl?.focus) {\n this._restoringFocus = true;\n triggerEl.focus();\n queueMicrotask(() => {\n this._restoringFocus = false;\n });\n }\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
6
6
|
"/**\n * @duskmoon-dev/el-popover\n *\n * DuskMoon Popover custom element\n */\n\nimport { ElDmPopover } from './el-dm-popover.js';\n\nexport { ElDmPopover };\nexport type { PopoverPlacement, PopoverTrigger } from './el-dm-popover.js';\n\n/**\n * Register the el-dm-popover custom element\n *\n * @example\n * ```ts\n * import { register } from '@duskmoon-dev/el-popover';\n * register();\n * ```\n */\nexport function register(): void {\n if (!customElements.get('el-dm-popover')) {\n customElements.define('el-dm-popover', ElDmPopover);\n }\n}\n",
|
|
7
7
|
"/**\n * Auto-register el-dm-popover custom element\n *\n * @example\n * ```ts\n * import '@duskmoon-dev/el-popover/register';\n *\n * // Now you can use <el-dm-popover> in HTML\n * ```\n */\nimport { register } from './index.js';\n\nregister();\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBkD,IAAlD;AACkC,IAAlC;AAmBA,IAAM,aAAa,mBAAW,QAAQ,4BAA4B,EAAE,EAAE,QAAQ,UAAU,EAAE;AAE1F,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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,UAAU,QAAQ,OAAO,CAAC;AAAA,IAC5E,IAAI,KAAK,IAAI,SAAS,KAAK,IAAI,GAAG,iBAAiB,UAAU,SAAS,OAAO,CAAC;AAAA,IAE9E,OAAO,EAAE,GAAG,EAAE;AAAA;AAAA,EAGhB,MAAM,GAAS;AAAA,IACb,MAAM,OAAO;AAAA,IACb,IAAI,KAAK,MAAM;AAAA,MAEb,sBAAsB,MAAM;AAAA,QAC1B,KAAK,gBAAgB;AAAA,QACrB,KAAK,YAAY,IAAI;AAAA,OACtB;AAAA,IACH;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BASe,KAAK;AAAA;AAAA,UAErB,KAAK,QAAQ,mDAAmD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO1E;;;ACljBO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AAAA,IACxC,eAAe,OAAO,iBAAiB,WAAW;AAAA,EACpD;AAAA;;;ACXF,SAAS;",
|
|
10
|
+
"debugId": "E69A1A68C3DF10B964756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
package/dist/esm/index.js
CHANGED
|
@@ -108,6 +108,7 @@ class ElDmPopover extends BaseElement {
|
|
|
108
108
|
_boundUpdatePosition;
|
|
109
109
|
_hoverTimeout = null;
|
|
110
110
|
_currentPlacement = "bottom";
|
|
111
|
+
_restoringFocus = false;
|
|
111
112
|
constructor() {
|
|
112
113
|
super();
|
|
113
114
|
this.attachStyles([styles, animationStyles]);
|
|
@@ -177,7 +178,7 @@ class ElDmPopover extends BaseElement {
|
|
|
177
178
|
this._attachTriggerEvents();
|
|
178
179
|
}
|
|
179
180
|
_attachTriggerEvents() {
|
|
180
|
-
const triggerEl = this.
|
|
181
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
181
182
|
if (!triggerEl)
|
|
182
183
|
return;
|
|
183
184
|
this._detachTriggerEvents(triggerEl);
|
|
@@ -204,18 +205,36 @@ class ElDmPopover extends BaseElement {
|
|
|
204
205
|
this.removeEventListener("mouseleave", this._handlePopoverMouseLeave);
|
|
205
206
|
}
|
|
206
207
|
_removeTriggerListeners() {
|
|
207
|
-
const triggerEl = this.
|
|
208
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
208
209
|
if (triggerEl) {
|
|
209
210
|
this._detachTriggerEvents(triggerEl);
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
|
-
|
|
213
|
+
_getAssignedTriggerElement() {
|
|
213
214
|
const triggerSlot = this.shadowRoot?.querySelector('slot[name="trigger"]');
|
|
214
215
|
if (!triggerSlot)
|
|
215
216
|
return null;
|
|
216
217
|
const assigned = triggerSlot.assignedElements();
|
|
217
218
|
return assigned[0] || null;
|
|
218
219
|
}
|
|
220
|
+
_getTriggerElement() {
|
|
221
|
+
const assigned = this._getAssignedTriggerElement();
|
|
222
|
+
if (!assigned)
|
|
223
|
+
return null;
|
|
224
|
+
if (assigned.matches(this._focusableSelector)) {
|
|
225
|
+
return assigned;
|
|
226
|
+
}
|
|
227
|
+
return assigned.querySelector(this._focusableSelector) ?? assigned;
|
|
228
|
+
}
|
|
229
|
+
_focusableSelector = [
|
|
230
|
+
"a[href]",
|
|
231
|
+
"button:not([disabled])",
|
|
232
|
+
"input:not([disabled])",
|
|
233
|
+
"select:not([disabled])",
|
|
234
|
+
"textarea:not([disabled])",
|
|
235
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
236
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
237
|
+
].join(",");
|
|
219
238
|
_handleTriggerClick = () => {
|
|
220
239
|
this.toggle();
|
|
221
240
|
};
|
|
@@ -243,6 +262,8 @@ class ElDmPopover extends BaseElement {
|
|
|
243
262
|
}, 100);
|
|
244
263
|
};
|
|
245
264
|
_handleTriggerFocus = () => {
|
|
265
|
+
if (this._restoringFocus)
|
|
266
|
+
return;
|
|
246
267
|
this.show();
|
|
247
268
|
};
|
|
248
269
|
_handleTriggerBlur = () => {
|
|
@@ -276,7 +297,13 @@ class ElDmPopover extends BaseElement {
|
|
|
276
297
|
if (e.key === "Escape") {
|
|
277
298
|
this.hide();
|
|
278
299
|
const triggerEl = this._getTriggerElement();
|
|
279
|
-
triggerEl?.focus
|
|
300
|
+
if (triggerEl?.focus) {
|
|
301
|
+
this._restoringFocus = true;
|
|
302
|
+
triggerEl.focus();
|
|
303
|
+
queueMicrotask(() => {
|
|
304
|
+
this._restoringFocus = false;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
280
307
|
}
|
|
281
308
|
}
|
|
282
309
|
_handleScroll() {
|
|
@@ -415,5 +442,5 @@ export {
|
|
|
415
442
|
ElDmPopover
|
|
416
443
|
};
|
|
417
444
|
|
|
418
|
-
//# debugId=
|
|
445
|
+
//# debugId=253318364045987E64756E2164756E21
|
|
419
446
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/el-dm-popover.ts", "../../src/index.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n triggerEl?.focus?.();\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
5
|
+
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n private _restoringFocus = false;\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getAssignedTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _getTriggerElement(): Element | null {\n const assigned = this._getAssignedTriggerElement();\n if (!assigned) return null;\n\n if (assigned.matches(this._focusableSelector)) {\n return assigned;\n }\n\n return assigned.querySelector(this._focusableSelector) ?? assigned;\n }\n\n private readonly _focusableSelector = [\n 'a[href]',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ].join(',');\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n if (this._restoringFocus) return;\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n if (triggerEl?.focus) {\n this._restoringFocus = true;\n triggerEl.focus();\n queueMicrotask(() => {\n this._restoringFocus = false;\n });\n }\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
6
6
|
"/**\n * @duskmoon-dev/el-popover\n *\n * DuskMoon Popover custom element\n */\n\nimport { ElDmPopover } from './el-dm-popover.js';\n\nexport { ElDmPopover };\nexport type { PopoverPlacement, PopoverTrigger } from './el-dm-popover.js';\n\n/**\n * Register the el-dm-popover custom element\n *\n * @example\n * ```ts\n * import { register } from '@duskmoon-dev/el-popover';\n * register();\n * ```\n */\nexport function register(): void {\n if (!customElements.get('el-dm-popover')) {\n customElements.define('el-dm-popover', ElDmPopover);\n }\n}\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";AAyBA;AACA,gBAAS;AAmBT,IAAM,aAAa,WAAW,QAAQ,4BAA4B,EAAE,EAAE,QAAQ,UAAU,EAAE;AAE1F,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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BAAiB,UAAU,SAAS,OAAO,CAAC;AAAA,IAE9E,OAAO,EAAE,GAAG,EAAE;AAAA;AAAA,EAGhB,MAAM,GAAS;AAAA,IACb,MAAM,OAAO;AAAA,IACb,IAAI,KAAK,MAAM;AAAA,MAEb,sBAAsB,MAAM;AAAA,QAC1B,KAAK,gBAAgB;AAAA,QACrB,KAAK,YAAY,IAAI;AAAA,OACtB;AAAA,IACH;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BASe,KAAK;AAAA;AAAA,UAErB,KAAK,QAAQ,mDAAmD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO1E;;;ACljBO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AAAA,IACxC,eAAe,OAAO,iBAAiB,WAAW;AAAA,EACpD;AAAA;",
|
|
9
|
+
"debugId": "253318364045987E64756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/esm/register.js
CHANGED
|
@@ -108,6 +108,7 @@ class ElDmPopover extends BaseElement {
|
|
|
108
108
|
_boundUpdatePosition;
|
|
109
109
|
_hoverTimeout = null;
|
|
110
110
|
_currentPlacement = "bottom";
|
|
111
|
+
_restoringFocus = false;
|
|
111
112
|
constructor() {
|
|
112
113
|
super();
|
|
113
114
|
this.attachStyles([styles, animationStyles]);
|
|
@@ -177,7 +178,7 @@ class ElDmPopover extends BaseElement {
|
|
|
177
178
|
this._attachTriggerEvents();
|
|
178
179
|
}
|
|
179
180
|
_attachTriggerEvents() {
|
|
180
|
-
const triggerEl = this.
|
|
181
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
181
182
|
if (!triggerEl)
|
|
182
183
|
return;
|
|
183
184
|
this._detachTriggerEvents(triggerEl);
|
|
@@ -204,18 +205,36 @@ class ElDmPopover extends BaseElement {
|
|
|
204
205
|
this.removeEventListener("mouseleave", this._handlePopoverMouseLeave);
|
|
205
206
|
}
|
|
206
207
|
_removeTriggerListeners() {
|
|
207
|
-
const triggerEl = this.
|
|
208
|
+
const triggerEl = this._getAssignedTriggerElement();
|
|
208
209
|
if (triggerEl) {
|
|
209
210
|
this._detachTriggerEvents(triggerEl);
|
|
210
211
|
}
|
|
211
212
|
}
|
|
212
|
-
|
|
213
|
+
_getAssignedTriggerElement() {
|
|
213
214
|
const triggerSlot = this.shadowRoot?.querySelector('slot[name="trigger"]');
|
|
214
215
|
if (!triggerSlot)
|
|
215
216
|
return null;
|
|
216
217
|
const assigned = triggerSlot.assignedElements();
|
|
217
218
|
return assigned[0] || null;
|
|
218
219
|
}
|
|
220
|
+
_getTriggerElement() {
|
|
221
|
+
const assigned = this._getAssignedTriggerElement();
|
|
222
|
+
if (!assigned)
|
|
223
|
+
return null;
|
|
224
|
+
if (assigned.matches(this._focusableSelector)) {
|
|
225
|
+
return assigned;
|
|
226
|
+
}
|
|
227
|
+
return assigned.querySelector(this._focusableSelector) ?? assigned;
|
|
228
|
+
}
|
|
229
|
+
_focusableSelector = [
|
|
230
|
+
"a[href]",
|
|
231
|
+
"button:not([disabled])",
|
|
232
|
+
"input:not([disabled])",
|
|
233
|
+
"select:not([disabled])",
|
|
234
|
+
"textarea:not([disabled])",
|
|
235
|
+
'[contenteditable]:not([contenteditable="false"])',
|
|
236
|
+
'[tabindex]:not([tabindex="-1"])'
|
|
237
|
+
].join(",");
|
|
219
238
|
_handleTriggerClick = () => {
|
|
220
239
|
this.toggle();
|
|
221
240
|
};
|
|
@@ -243,6 +262,8 @@ class ElDmPopover extends BaseElement {
|
|
|
243
262
|
}, 100);
|
|
244
263
|
};
|
|
245
264
|
_handleTriggerFocus = () => {
|
|
265
|
+
if (this._restoringFocus)
|
|
266
|
+
return;
|
|
246
267
|
this.show();
|
|
247
268
|
};
|
|
248
269
|
_handleTriggerBlur = () => {
|
|
@@ -276,7 +297,13 @@ class ElDmPopover extends BaseElement {
|
|
|
276
297
|
if (e.key === "Escape") {
|
|
277
298
|
this.hide();
|
|
278
299
|
const triggerEl = this._getTriggerElement();
|
|
279
|
-
triggerEl?.focus
|
|
300
|
+
if (triggerEl?.focus) {
|
|
301
|
+
this._restoringFocus = true;
|
|
302
|
+
triggerEl.focus();
|
|
303
|
+
queueMicrotask(() => {
|
|
304
|
+
this._restoringFocus = false;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
280
307
|
}
|
|
281
308
|
}
|
|
282
309
|
_handleScroll() {
|
|
@@ -414,5 +441,5 @@ function register() {
|
|
|
414
441
|
// src/register.ts
|
|
415
442
|
register();
|
|
416
443
|
|
|
417
|
-
//# debugId=
|
|
444
|
+
//# debugId=56303BA4D2738BAD64756E2164756E21
|
|
418
445
|
//# sourceMappingURL=register.js.map
|
package/dist/esm/register.js.map
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/el-dm-popover.ts", "../../src/index.ts", "../../src/register.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n triggerEl?.focus?.();\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
5
|
+
"/**\n * DuskMoon Popover Element\n *\n * A contextual overlay/popup component that appears relative to a trigger element.\n * Supports multiple trigger modes, placements, and auto-flip when near viewport edges.\n *\n * @element el-dm-popover\n *\n * @attr {boolean} open - Whether the popover is visible\n * @attr {string} trigger - Trigger mode: click, hover, focus, manual\n * @attr {string} placement - Popover position relative to trigger\n * @attr {number} offset - Distance from trigger element in pixels\n * @attr {boolean} arrow - Whether to show arrow pointing to trigger\n *\n * @slot trigger - The element that triggers the popover\n * @slot - Default slot for popover content\n *\n * @fires open - Fired when popover opens\n * @fires close - Fired when popover closes\n *\n * @csspart popover - The popover container\n * @csspart content - The popover content area\n * @csspart arrow - The popover arrow\n */\n\nimport { BaseElement, css, animationStyles } from '@duskmoon-dev/el-base';\nimport { css as popoverCSS } from '@duskmoon-dev/core/components/popover';\n\nexport type PopoverPlacement =\n | 'top'\n | 'top-start'\n | 'top-end'\n | 'bottom'\n | 'bottom-start'\n | 'bottom-end'\n | 'left'\n | 'left-start'\n | 'left-end'\n | 'right'\n | 'right-start'\n | 'right-end';\n\nexport type PopoverTrigger = 'click' | 'hover' | 'focus' | 'manual';\n\n// Strip @layer wrapper for Shadow DOM compatibility\nconst coreStyles = popoverCSS.replace(/@layer\\s+components\\s*\\{/, '').replace(/\\}\\s*$/, '');\n\nconst styles = css`\n :host {\n display: inline-block;\n position: relative;\n }\n\n :host([hidden]) {\n display: none !important;\n }\n\n /* Import core popover styles */\n ${coreStyles}\n\n .popover-trigger {\n display: inline-flex;\n }\n\n /* Override core's position: absolute for JS-based positioning */\n .popover-content {\n position: fixed;\n min-width: 8rem;\n pointer-events: none;\n font-family: inherit;\n }\n\n .popover-content.show {\n pointer-events: auto;\n }\n\n /* Arrow positioning based on popover placement (data-attribute based) */\n .popover-content[data-placement^='top'] .popover-arrow {\n bottom: -0.4375rem;\n border-top: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='bottom'] .popover-arrow {\n top: -0.4375rem;\n border-bottom: none;\n border-right: none;\n }\n\n .popover-content[data-placement^='left'] .popover-arrow {\n right: -0.4375rem;\n border-bottom: none;\n border-left: none;\n }\n\n .popover-content[data-placement^='right'] .popover-arrow {\n left: -0.4375rem;\n border-top: none;\n border-right: none;\n }\n\n /* Center aligned arrows */\n .popover-content[data-placement='top'] .popover-arrow,\n .popover-content[data-placement='bottom'] .popover-arrow {\n left: 50%;\n transform: translateX(-50%) rotate(45deg);\n }\n\n .popover-content[data-placement='left'] .popover-arrow,\n .popover-content[data-placement='right'] .popover-arrow {\n top: 50%;\n transform: translateY(-50%) rotate(45deg);\n }\n\n /* Start aligned arrows */\n .popover-content[data-placement='top-start'] .popover-arrow,\n .popover-content[data-placement='bottom-start'] .popover-arrow {\n left: 1rem;\n }\n\n .popover-content[data-placement='left-start'] .popover-arrow,\n .popover-content[data-placement='right-start'] .popover-arrow {\n top: 1rem;\n }\n\n /* End aligned arrows */\n .popover-content[data-placement='top-end'] .popover-arrow,\n .popover-content[data-placement='bottom-end'] .popover-arrow {\n right: 1rem;\n left: auto;\n }\n\n .popover-content[data-placement='left-end'] .popover-arrow,\n .popover-content[data-placement='right-end'] .popover-arrow {\n bottom: 1rem;\n top: auto;\n }\n`;\n\nexport class ElDmPopover extends BaseElement {\n static properties = {\n open: { type: Boolean, reflect: true, default: false },\n trigger: { type: String, reflect: true, default: 'click' },\n placement: { type: String, reflect: true, default: 'bottom' },\n offset: { type: Number, reflect: true, default: 8 },\n arrow: { type: Boolean, reflect: true, default: true },\n };\n\n declare open: boolean;\n declare trigger: PopoverTrigger;\n declare placement: PopoverPlacement;\n declare offset: number;\n declare arrow: boolean;\n\n private _boundHandleClickOutside: (e: MouseEvent) => void;\n private _boundHandleKeyDown: (e: KeyboardEvent) => void;\n private _boundHandleScroll: () => void;\n private _boundUpdatePosition: () => void;\n private _hoverTimeout: number | null = null;\n private _currentPlacement: PopoverPlacement = 'bottom';\n private _restoringFocus = false;\n\n constructor() {\n super();\n this.attachStyles([styles, animationStyles]);\n this._boundHandleClickOutside = this._handleClickOutside.bind(this);\n this._boundHandleKeyDown = this._handleKeyDown.bind(this);\n this._boundHandleScroll = this._handleScroll.bind(this);\n this._boundUpdatePosition = this._updatePosition.bind(this);\n }\n\n connectedCallback(): void {\n super.connectedCallback();\n this._setupTriggerListeners();\n }\n\n disconnectedCallback(): void {\n super.disconnectedCallback?.();\n this._removeTriggerListeners();\n this._removeGlobalListeners();\n }\n\n /**\n * Show the popover\n */\n show(): void {\n if (this.open) return;\n this.open = true;\n this._currentPlacement = this.placement;\n this._addGlobalListeners();\n this._updatePosition();\n this._setVisible(true);\n this._updateTriggerAria(true);\n this.emit('open');\n }\n\n /**\n * Hide the popover\n */\n hide(): void {\n if (!this.open) return;\n this.open = false;\n this._removeGlobalListeners();\n this._setVisible(false);\n this._updateTriggerAria(false);\n this.emit('close');\n }\n\n /**\n * Update ARIA attributes on the trigger element\n */\n private _updateTriggerAria(expanded: boolean): void {\n const triggerEl = this._getTriggerElement();\n if (triggerEl) {\n triggerEl.setAttribute('aria-expanded', String(expanded));\n if (!triggerEl.hasAttribute('aria-haspopup')) {\n triggerEl.setAttribute('aria-haspopup', 'dialog');\n }\n }\n }\n\n /**\n * Toggle the popover visibility\n */\n toggle(): void {\n if (this.open) {\n this.hide();\n } else {\n this.show();\n }\n }\n\n private _setVisible(visible: boolean): void {\n const panel = this.shadowRoot?.querySelector('.popover-content');\n if (panel) {\n panel.classList.toggle('show', visible);\n }\n }\n\n private _setupTriggerListeners(): void {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n\n if (!triggerSlot) return;\n\n triggerSlot.addEventListener('slotchange', () => {\n this._attachTriggerEvents();\n });\n\n // Initial attachment\n this._attachTriggerEvents();\n }\n\n private _attachTriggerEvents(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (!triggerEl) return;\n\n // Remove any existing listeners first\n this._detachTriggerEvents(triggerEl);\n\n // Set initial ARIA attributes on trigger\n this._updateTriggerAria(this.open);\n\n if (this.trigger === 'click') {\n triggerEl.addEventListener('click', this._handleTriggerClick);\n } else if (this.trigger === 'hover') {\n triggerEl.addEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.addEventListener('mouseleave', this._handleTriggerMouseLeave);\n // Also track hover on the popover panel\n this.addEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.addEventListener('mouseleave', this._handlePopoverMouseLeave);\n } else if (this.trigger === 'focus') {\n triggerEl.addEventListener('focusin', this._handleTriggerFocus);\n triggerEl.addEventListener('focusout', this._handleTriggerBlur);\n }\n }\n\n private _detachTriggerEvents(triggerEl: Element): void {\n triggerEl.removeEventListener('click', this._handleTriggerClick);\n triggerEl.removeEventListener('mouseenter', this._handleTriggerMouseEnter);\n triggerEl.removeEventListener('mouseleave', this._handleTriggerMouseLeave);\n triggerEl.removeEventListener('focusin', this._handleTriggerFocus);\n triggerEl.removeEventListener('focusout', this._handleTriggerBlur);\n this.removeEventListener('mouseenter', this._handlePopoverMouseEnter);\n this.removeEventListener('mouseleave', this._handlePopoverMouseLeave);\n }\n\n private _removeTriggerListeners(): void {\n const triggerEl = this._getAssignedTriggerElement();\n if (triggerEl) {\n this._detachTriggerEvents(triggerEl);\n }\n }\n\n private _getAssignedTriggerElement(): Element | null {\n const triggerSlot = this.shadowRoot?.querySelector(\n 'slot[name=\"trigger\"]',\n ) as HTMLSlotElement | null;\n if (!triggerSlot) return null;\n const assigned = triggerSlot.assignedElements();\n return assigned[0] || null;\n }\n\n private _getTriggerElement(): Element | null {\n const assigned = this._getAssignedTriggerElement();\n if (!assigned) return null;\n\n if (assigned.matches(this._focusableSelector)) {\n return assigned;\n }\n\n return assigned.querySelector(this._focusableSelector) ?? assigned;\n }\n\n private readonly _focusableSelector = [\n 'a[href]',\n 'button:not([disabled])',\n 'input:not([disabled])',\n 'select:not([disabled])',\n 'textarea:not([disabled])',\n '[contenteditable]:not([contenteditable=\"false\"])',\n '[tabindex]:not([tabindex=\"-1\"])',\n ].join(',');\n\n private _handleTriggerClick = (): void => {\n this.toggle();\n };\n\n private _handleTriggerMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n this.show();\n };\n\n private _handleTriggerMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handlePopoverMouseEnter = (): void => {\n if (this._hoverTimeout) {\n clearTimeout(this._hoverTimeout);\n this._hoverTimeout = null;\n }\n };\n\n private _handlePopoverMouseLeave = (): void => {\n this._hoverTimeout = window.setTimeout(() => {\n this.hide();\n }, 100);\n };\n\n private _handleTriggerFocus = (): void => {\n if (this._restoringFocus) return;\n this.show();\n };\n\n private _handleTriggerBlur = (): void => {\n // Delay to allow focus to move to popover content\n setTimeout(() => {\n if (!this.contains(document.activeElement)) {\n this.hide();\n }\n }, 0);\n };\n\n private _addGlobalListeners(): void {\n document.addEventListener('click', this._boundHandleClickOutside, true);\n document.addEventListener('keydown', this._boundHandleKeyDown);\n window.addEventListener('scroll', this._boundHandleScroll, true);\n window.addEventListener('resize', this._boundUpdatePosition);\n }\n\n private _removeGlobalListeners(): void {\n document.removeEventListener('click', this._boundHandleClickOutside, true);\n document.removeEventListener('keydown', this._boundHandleKeyDown);\n window.removeEventListener('scroll', this._boundHandleScroll, true);\n window.removeEventListener('resize', this._boundUpdatePosition);\n }\n\n private _handleClickOutside(e: MouseEvent): void {\n if (this.trigger !== 'click') return;\n\n const path = e.composedPath();\n if (!path.includes(this)) {\n this.hide();\n }\n }\n\n private _handleKeyDown(e: KeyboardEvent): void {\n if (e.key === 'Escape') {\n this.hide();\n // Return focus to trigger element\n const triggerEl = this._getTriggerElement() as HTMLElement | null;\n if (triggerEl?.focus) {\n this._restoringFocus = true;\n triggerEl.focus();\n queueMicrotask(() => {\n this._restoringFocus = false;\n });\n }\n }\n }\n\n private _handleScroll(): void {\n if (this.open) {\n this._updatePosition();\n }\n }\n\n private _updatePosition(): void {\n const triggerEl = this._getTriggerElement();\n const panel = this.shadowRoot?.querySelector('.popover-content') as HTMLElement | null;\n\n if (!triggerEl || !panel) return;\n\n const triggerRect = triggerEl.getBoundingClientRect();\n const panelRect = panel.getBoundingClientRect();\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n\n // Determine the best placement with auto-flip\n const effectivePlacement = this._getEffectivePlacement(\n triggerRect,\n panelRect,\n viewportWidth,\n viewportHeight,\n );\n\n this._currentPlacement = effectivePlacement;\n\n // Calculate position based on placement\n const position = this._calculatePosition(triggerRect, panelRect, effectivePlacement);\n\n // Apply position\n panel.style.left = `${position.x}px`;\n panel.style.top = `${position.y}px`;\n panel.setAttribute('data-placement', effectivePlacement);\n }\n\n private _getEffectivePlacement(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n viewportWidth: number,\n viewportHeight: number,\n ): PopoverPlacement {\n const [mainAxis, alignment] = this.placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n // Check if there's enough space in the preferred direction\n const spaceTop = triggerRect.top;\n const spaceBottom = viewportHeight - triggerRect.bottom;\n const spaceLeft = triggerRect.left;\n const spaceRight = viewportWidth - triggerRect.right;\n\n let effectiveMainAxis = mainAxis;\n\n // Flip main axis if needed\n if (mainAxis === 'top' && spaceTop < panelRect.height + this.offset) {\n if (spaceBottom >= panelRect.height + this.offset) {\n effectiveMainAxis = 'bottom';\n }\n } else if (mainAxis === 'bottom' && spaceBottom < panelRect.height + this.offset) {\n if (spaceTop >= panelRect.height + this.offset) {\n effectiveMainAxis = 'top';\n }\n } else if (mainAxis === 'left' && spaceLeft < panelRect.width + this.offset) {\n if (spaceRight >= panelRect.width + this.offset) {\n effectiveMainAxis = 'right';\n }\n } else if (mainAxis === 'right' && spaceRight < panelRect.width + this.offset) {\n if (spaceLeft >= panelRect.width + this.offset) {\n effectiveMainAxis = 'left';\n }\n }\n\n return alignment\n ? (`${effectiveMainAxis}-${alignment}` as PopoverPlacement)\n : effectiveMainAxis;\n }\n\n private _calculatePosition(\n triggerRect: DOMRect,\n panelRect: DOMRect,\n placement: PopoverPlacement,\n ): { x: number; y: number } {\n const [mainAxis, alignment] = placement.split('-') as [\n 'top' | 'bottom' | 'left' | 'right',\n 'start' | 'end' | undefined,\n ];\n\n let x = 0;\n let y = 0;\n\n // Calculate main axis position\n switch (mainAxis) {\n case 'top':\n y = triggerRect.top - panelRect.height - this.offset;\n break;\n case 'bottom':\n y = triggerRect.bottom + this.offset;\n break;\n case 'left':\n x = triggerRect.left - panelRect.width - this.offset;\n break;\n case 'right':\n x = triggerRect.right + this.offset;\n break;\n }\n\n // Calculate cross axis position based on alignment\n if (mainAxis === 'top' || mainAxis === 'bottom') {\n switch (alignment) {\n case 'start':\n x = triggerRect.left;\n break;\n case 'end':\n x = triggerRect.right - panelRect.width;\n break;\n default:\n x = triggerRect.left + (triggerRect.width - panelRect.width) / 2;\n }\n } else {\n switch (alignment) {\n case 'start':\n y = triggerRect.top;\n break;\n case 'end':\n y = triggerRect.bottom - panelRect.height;\n break;\n default:\n y = triggerRect.top + (triggerRect.height - panelRect.height) / 2;\n }\n }\n\n // Constrain to viewport\n const viewportWidth = window.innerWidth;\n const viewportHeight = window.innerHeight;\n const padding = 8;\n\n x = Math.max(padding, Math.min(x, viewportWidth - panelRect.width - padding));\n y = Math.max(padding, Math.min(y, viewportHeight - panelRect.height - padding));\n\n return { x, y };\n }\n\n update(): void {\n super.update();\n if (this.open) {\n // Defer position update to allow DOM to render\n requestAnimationFrame(() => {\n this._updatePosition();\n this._setVisible(true);\n });\n }\n }\n\n render(): string {\n return `\n <div class=\"popover-trigger\">\n <slot name=\"trigger\"></slot>\n </div>\n <div\n class=\"popover-content\"\n part=\"popover\"\n role=\"dialog\"\n aria-modal=\"false\"\n data-placement=\"${this.placement}\"\n >\n ${this.arrow ? '<div class=\"popover-arrow\" part=\"arrow\"></div>' : ''}\n <div class=\"popover-body\" part=\"content\">\n <slot></slot>\n </div>\n </div>\n `;\n }\n}\n",
|
|
6
6
|
"/**\n * @duskmoon-dev/el-popover\n *\n * DuskMoon Popover custom element\n */\n\nimport { ElDmPopover } from './el-dm-popover.js';\n\nexport { ElDmPopover };\nexport type { PopoverPlacement, PopoverTrigger } from './el-dm-popover.js';\n\n/**\n * Register the el-dm-popover custom element\n *\n * @example\n * ```ts\n * import { register } from '@duskmoon-dev/el-popover';\n * register();\n * ```\n */\nexport function register(): void {\n if (!customElements.get('el-dm-popover')) {\n customElements.define('el-dm-popover', ElDmPopover);\n }\n}\n",
|
|
7
7
|
"/**\n * Auto-register el-dm-popover custom element\n *\n * @example\n * ```ts\n * import '@duskmoon-dev/el-popover/register';\n *\n * // Now you can use <el-dm-popover> in HTML\n * ```\n */\nimport { register } from './index.js';\n\nregister();\n"
|
|
8
8
|
],
|
|
9
|
-
"mappings": ";AAyBA;AACA,gBAAS;AAmBT,IAAM,aAAa,WAAW,QAAQ,4BAA4B,EAAE,EAAE,QAAQ,UAAU,EAAE;AAE1F,IAAM,SAAS;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAWX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AAO,CAAC;AAAA,IAC5E,IAAI,KAAK,IAAI,SAAS,KAAK,IAAI,GAAG,iBAAiB,UAAU,SAAS,OAAO,CAAC;AAAA,IAE9E,OAAO,EAAE,GAAG,EAAE;AAAA;AAAA,EAGhB,MAAM,GAAS;AAAA,IACb,MAAM,OAAO;AAAA,IACb,IAAI,KAAK,MAAM;AAAA,MAEb,sBAAsB,MAAM;AAAA,QAC1B,KAAK,gBAAgB;AAAA,QACrB,KAAK,YAAY,IAAI;AAAA,OACtB;AAAA,IACH;AAAA;AAAA,EAGF,MAAM,GAAW;AAAA,IACf,OAAO;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BASe,KAAK;AAAA;AAAA,UAErB,KAAK,QAAQ,mDAAmD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAO1E;;;ACljBO,SAAS,QAAQ,GAAS;AAAA,EAC/B,IAAI,CAAC,eAAe,IAAI,eAAe,GAAG;AAAA,IACxC,eAAe,OAAO,iBAAiB,WAAW;AAAA,EACpD;AAAA;;;ACXF,SAAS;",
|
|
10
|
+
"debugId": "56303BA4D2738BAD64756E2164756E21",
|
|
11
11
|
"names": []
|
|
12
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"fileNames":["../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/duskmoon-core.d.ts","../../../packages/base/dist/types/base-element.d.ts","../../../packages/base/dist/types/styles.d.ts","../../../packages/base/dist/types/animations.d.ts","../../../packages/base/dist/types/themes.d.ts","../../../packages/base/dist/types/mixins.d.ts","../../../packages/base/dist/types/types.d.ts","../../../packages/base/dist/types/validation.d.ts","../../../packages/base/dist/types/performance.d.ts","../../../packages/base/dist/types/index.d.ts","../src/el-dm-popover.ts","../src/index.ts","../src/register.ts"],"fileIdsList":[[60,69],[70],[71],[61,62,63,64,65,66,67,68],[61],[66]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},"29a0d2b543c1585e53e85156d0c33f9b5850d4270d957370e7f6e1abd493253a","42526b6de804c10fd86f1cf55a6c660a74ee448e381f0f78356f223b75982280","28914adcfb92fa94199e1c887da7d67a7d9d736d9571627d6b02e55ff82f577b","b0a69607a92876948c2a42e3aa6703b0d724699468ed7e3c6e2a237d119a9db9","cdacb8e4ac607a46494d1187e073382c43e7269e8bf698502a285a8ccb470925","f5091ebbd718ea236a7f503df569deb07aff0621aa8f73ed90e419de88f006aa","d3a328c0eccf652bc8b6c14515a8b848a558b9d684e15a7c0c2e15de5016df57","1b5193795ee478857bf1115fed004151284dd4da883a5a4f22e62631c3b414ad","3be01044afc63501423c361deb531d3e95f5c2677f1f7a628802bd346988d62c","78d8d1ca7d54a437702c8a8c08764b6a49f2cf2ca357d0e459bfe89a06abf50a",{"version":"66af7446d1679360b1525cee84b3ab274042e96e7909cc90de05716aeb57640c","signature":"d1a0ba6ea288dfaa2f139b34ef24cbade596684db2cce106507bb6fca65c31fe"},{"version":"36f02e97cc48560a3df82034d1d06e48fd9048d21d686089113a52504b21bee1","signature":"b27edfdfec7385437b77a189fdc7ca0981d377bd59ecb5bdf524acde393f5208"},{"version":"2c9e7956b736bb7ff45c0a667e1d8f124a01272b6b2f9ed06721aa496d554c07","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"}],"root":[60,[70,72]],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":99,"outDir":"./types","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9},"referencedMap":[[70,1],[71,2],[72,3],[69,4],[65,5],[67,6]],"latestChangedDtsFile":"./types/register.d.ts","version":"6.0.3"}
|
|
1
|
+
{"fileNames":["../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.promise.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.weakref.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2021.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.array.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.error.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.intl.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.object.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.string.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.es2022.regexp.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/.bun/typescript@6.0.3/node_modules/typescript/lib/lib.decorators.legacy.d.ts","../src/duskmoon-core.d.ts","../../../packages/base/dist/types/base-element.d.ts","../../../packages/base/dist/types/styles.d.ts","../../../packages/base/dist/types/animations.d.ts","../../../packages/base/dist/types/themes.d.ts","../../../packages/base/dist/types/mixins.d.ts","../../../packages/base/dist/types/types.d.ts","../../../packages/base/dist/types/validation.d.ts","../../../packages/base/dist/types/performance.d.ts","../../../packages/base/dist/types/index.d.ts","../src/el-dm-popover.ts","../src/index.ts","../src/register.ts"],"fileIdsList":[[60,69],[70],[71],[61,62,63,64,65,66,67,68],[61],[66]],"fileInfos":[{"version":"bcd24271a113971ba9eb71ff8cb01bc6b0f872a85c23fdbe5d93065b375933cd","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f88bedbeb09c6f5a6645cb24c7c55f1aa22d19ae96c8e6959cbd8b85a707bc6","impliedFormat":1},{"version":"7fe93b39b810eadd916be8db880dd7f0f7012a5cc6ffb62de8f62a2117fa6f1f","impliedFormat":1},{"version":"bb0074cc08b84a2374af33d8bf044b80851ccc9e719a5e202eacf40db2c31600","impliedFormat":1},{"version":"1a7daebe4f45fb03d9ec53d60008fbf9ac45a697fdc89e4ce218bc94b94f94d6","impliedFormat":1},{"version":"f94b133a3cb14a288803be545ac2683e0d0ff6661bcd37e31aaaec54fc382aed","impliedFormat":1},{"version":"f59d0650799f8782fd74cf73c19223730c6d1b9198671b1c5b3a38e1188b5953","impliedFormat":1},{"version":"8a15b4607d9a499e2dbeed9ec0d3c0d7372c850b2d5f1fb259e8f6d41d468a84","impliedFormat":1},{"version":"26e0fe14baee4e127f4365d1ae0b276f400562e45e19e35fd2d4c296684715e6","impliedFormat":1},{"version":"d6b1eba8496bdd0eed6fc8a685768fe01b2da4a0388b5fe7df558290bffcf32f","affectsGlobalScope":true,"impliedFormat":1},{"version":"7f57fc4404ff020bc45b9c620aff2b40f700b95fe31164024c453a5e3c163c54","impliedFormat":1},{"version":"eadcffda2aa84802c73938e589b9e58248d74c59cb7fcbca6474e3435ac15504","affectsGlobalScope":true,"impliedFormat":1},{"version":"105ba8ff7ba746404fe1a2e189d1d3d2e0eb29a08c18dded791af02f29fb4711","affectsGlobalScope":true,"impliedFormat":1},{"version":"00343ca5b2e3d48fa5df1db6e32ea2a59afab09590274a6cccb1dbae82e60c7c","affectsGlobalScope":true,"impliedFormat":1},{"version":"ebd9f816d4002697cb2864bea1f0b70a103124e18a8cd9645eeccc09bdf80ab4","affectsGlobalScope":true,"impliedFormat":1},{"version":"2c1afac30a01772cd2a9a298a7ce7706b5892e447bb46bdbeef720f7b5da77ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"7b0225f483e4fa685625ebe43dd584bb7973bbd84e66a6ba7bbe175ee1048b4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c0a4b8ac6ce74679c1da2b3795296f5896e31c38e888469a8e0f99dc3305de60","affectsGlobalScope":true,"impliedFormat":1},{"version":"3084a7b5f569088e0146533a00830e206565de65cae2239509168b11434cd84f","affectsGlobalScope":true,"impliedFormat":1},{"version":"c5079c53f0f141a0698faa903e76cb41cd664e3efb01cc17a5c46ec2eb0bef42","affectsGlobalScope":true,"impliedFormat":1},{"version":"32cafbc484dea6b0ab62cf8473182bbcb23020d70845b406f80b7526f38ae862","affectsGlobalScope":true,"impliedFormat":1},{"version":"fca4cdcb6d6c5ef18a869003d02c9f0fd95df8cfaf6eb431cd3376bc034cad36","affectsGlobalScope":true,"impliedFormat":1},{"version":"b93ec88115de9a9dc1b602291b85baf825c85666bf25985cc5f698073892b467","affectsGlobalScope":true,"impliedFormat":1},{"version":"f5c06dcc3fe849fcb297c247865a161f995cc29de7aa823afdd75aaaddc1419b","affectsGlobalScope":true,"impliedFormat":1},{"version":"b77e16112127a4b169ef0b8c3a4d730edf459c5f25fe52d5e436a6919206c4d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"fbffd9337146eff822c7c00acbb78b01ea7ea23987f6c961eba689349e744f8c","affectsGlobalScope":true,"impliedFormat":1},{"version":"a995c0e49b721312f74fdfb89e4ba29bd9824c770bbb4021d74d2bf560e4c6bd","affectsGlobalScope":true,"impliedFormat":1},{"version":"c7b3542146734342e440a84b213384bfa188835537ddbda50d30766f0593aff9","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce6180fa19b1cccd07ee7f7dbb9a367ac19c0ed160573e4686425060b6df7f57","affectsGlobalScope":true,"impliedFormat":1},{"version":"3f02e2476bccb9dbe21280d6090f0df17d2f66b74711489415a8aa4df73c9675","affectsGlobalScope":true,"impliedFormat":1},{"version":"45e3ab34c1c013c8ab2dc1ba4c80c780744b13b5676800ae2e3be27ae862c40c","affectsGlobalScope":true,"impliedFormat":1},{"version":"805c86f6cca8d7702a62a844856dbaa2a3fd2abef0536e65d48732441dde5b5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"e42e397f1a5a77994f0185fd1466520691456c772d06bf843e5084ceb879a0ad","affectsGlobalScope":true,"impliedFormat":1},{"version":"f4c2b41f90c95b1c532ecc874bd3c111865793b23aebcc1c3cbbabcd5d76ffb0","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab26191cfad5b66afa11b8bf935ef1cd88fabfcb28d30b2dfa6fad877d050332","affectsGlobalScope":true,"impliedFormat":1},{"version":"2088bc26531e38fb05eedac2951480db5309f6be3fa4a08d2221abb0f5b4200d","affectsGlobalScope":true,"impliedFormat":1},{"version":"cb9d366c425fea79716a8fb3af0d78e6b22ebbab3bd64d25063b42dc9f531c1e","affectsGlobalScope":true,"impliedFormat":1},{"version":"500934a8089c26d57ebdb688fc9757389bb6207a3c8f0674d68efa900d2abb34","affectsGlobalScope":true,"impliedFormat":1},{"version":"689da16f46e647cef0d64b0def88910e818a5877ca5379ede156ca3afb780ac3","affectsGlobalScope":true,"impliedFormat":1},{"version":"bc21cc8b6fee4f4c2440d08035b7ea3c06b3511314c8bab6bef7a92de58a2593","affectsGlobalScope":true,"impliedFormat":1},{"version":"7ca53d13d2957003abb47922a71866ba7cb2068f8d154877c596d63c359fed25","affectsGlobalScope":true,"impliedFormat":1},{"version":"54725f8c4df3d900cb4dac84b64689ce29548da0b4e9b7c2de61d41c79293611","affectsGlobalScope":true,"impliedFormat":1},{"version":"e5594bc3076ac29e6c1ebda77939bc4c8833de72f654b6e376862c0473199323","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f3eb332c2d73e729f3364fcc0c2b375e72a121e8157d25a82d67a138c83a95c","affectsGlobalScope":true,"impliedFormat":1},{"version":"6f4427f9642ce8d500970e4e69d1397f64072ab73b97e476b4002a646ac743b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"48915f327cd1dea4d7bd358d9dc7732f58f9e1626a29cc0c05c8c692419d9bb7","affectsGlobalScope":true,"impliedFormat":1},{"version":"b7bf9377723203b5a6a4b920164df22d56a43f593269ba6ae1fdc97774b68855","affectsGlobalScope":true,"impliedFormat":1},{"version":"db9709688f82c9e5f65a119c64d835f906efe5f559d08b11642d56eb85b79357","affectsGlobalScope":true,"impliedFormat":1},{"version":"4b25b8c874acd1a4cf8444c3617e037d444d19080ac9f634b405583fd10ce1f7","affectsGlobalScope":true,"impliedFormat":1},{"version":"37be57d7c90cf1f8112ee2636a068d8fd181289f82b744160ec56a7dc158a9f5","affectsGlobalScope":true,"impliedFormat":1},{"version":"a917a49ac94cd26b754ab84e113369a75d1a47a710661d7cd25e961cc797065f","affectsGlobalScope":true,"impliedFormat":1},{"version":"6d3261badeb7843d157ef3e6f5d1427d0eeb0af0cf9df84a62cfd29fd47ac86e","affectsGlobalScope":true,"impliedFormat":1},{"version":"195daca651dde22f2167ac0d0a05e215308119a3100f5e6268e8317d05a92526","affectsGlobalScope":true,"impliedFormat":1},{"version":"8b11e4285cd2bb164a4dc09248bdec69e9842517db4ca47c1ba913011e44ff2f","affectsGlobalScope":true,"impliedFormat":1},{"version":"0508571a52475e245b02bc50fa1394065a0a3d05277fbf5120c3784b85651799","affectsGlobalScope":true,"impliedFormat":1},{"version":"8f9af488f510c3015af3cc8c267a9e9d96c4dd38a1fdff0e11dc5a544711415b","affectsGlobalScope":true,"impliedFormat":1},{"version":"fc611fea8d30ea72c6bbfb599c9b4d393ce22e2f5bfef2172534781e7d138104","affectsGlobalScope":true,"impliedFormat":1},{"version":"1ce14b81c5cc821994aa8ec1d42b220dd41b27fcc06373bce3958af7421b77d4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b3a048b3e9302ef9a34ef4ebb9aecfb28b66abb3bce577206a79fee559c230da","affectsGlobalScope":true,"impliedFormat":1},"29a0d2b543c1585e53e85156d0c33f9b5850d4270d957370e7f6e1abd493253a","42526b6de804c10fd86f1cf55a6c660a74ee448e381f0f78356f223b75982280","28914adcfb92fa94199e1c887da7d67a7d9d736d9571627d6b02e55ff82f577b","b0a69607a92876948c2a42e3aa6703b0d724699468ed7e3c6e2a237d119a9db9","cdacb8e4ac607a46494d1187e073382c43e7269e8bf698502a285a8ccb470925","f5091ebbd718ea236a7f503df569deb07aff0621aa8f73ed90e419de88f006aa","d3a328c0eccf652bc8b6c14515a8b848a558b9d684e15a7c0c2e15de5016df57","1b5193795ee478857bf1115fed004151284dd4da883a5a4f22e62631c3b414ad","3be01044afc63501423c361deb531d3e95f5c2677f1f7a628802bd346988d62c","78d8d1ca7d54a437702c8a8c08764b6a49f2cf2ca357d0e459bfe89a06abf50a",{"version":"4a0e90cbc609d56dca79b010dfd352943870d0cd419db2f83288cf4dc5b8a761","signature":"38f542b9072edd37634c0c0f29d93ee29ba37a4918730503a771559135aefc1b"},{"version":"36f02e97cc48560a3df82034d1d06e48fd9048d21d686089113a52504b21bee1","signature":"b27edfdfec7385437b77a189fdc7ca0981d377bd59ecb5bdf524acde393f5208"},{"version":"2c9e7956b736bb7ff45c0a667e1d8f124a01272b6b2f9ed06721aa496d554c07","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"}],"root":[60,[70,72]],"options":{"composite":true,"declaration":true,"declarationMap":true,"emitDeclarationOnly":true,"esModuleInterop":true,"module":99,"outDir":"./types","rootDir":"../src","skipLibCheck":true,"sourceMap":true,"strict":true,"target":9},"referencedMap":[[70,1],[71,2],[72,3],[69,4],[65,5],[67,6]],"latestChangedDtsFile":"./types/register.d.ts","version":"6.0.3"}
|
|
@@ -64,6 +64,7 @@ export declare class ElDmPopover extends BaseElement {
|
|
|
64
64
|
private _boundUpdatePosition;
|
|
65
65
|
private _hoverTimeout;
|
|
66
66
|
private _currentPlacement;
|
|
67
|
+
private _restoringFocus;
|
|
67
68
|
constructor();
|
|
68
69
|
connectedCallback(): void;
|
|
69
70
|
disconnectedCallback(): void;
|
|
@@ -88,7 +89,9 @@ export declare class ElDmPopover extends BaseElement {
|
|
|
88
89
|
private _attachTriggerEvents;
|
|
89
90
|
private _detachTriggerEvents;
|
|
90
91
|
private _removeTriggerListeners;
|
|
92
|
+
private _getAssignedTriggerElement;
|
|
91
93
|
private _getTriggerElement;
|
|
94
|
+
private readonly _focusableSelector;
|
|
92
95
|
private _handleTriggerClick;
|
|
93
96
|
private _handleTriggerMouseEnter;
|
|
94
97
|
private _handleTriggerMouseLeave;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"el-dm-popover.d.ts","sourceRoot":"","sources":["../../src/el-dm-popover.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;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etB,OAAO,CAAC,aAAa;IAMrB,OAAO,CAAC,eAAe;IA8BvB,OAAO,CAAC,sBAAsB;IA2C9B,OAAO,CAAC,kBAAkB;IAiE1B,MAAM,IAAI,IAAI;IAWd,MAAM,IAAI,MAAM;CAmBjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duskmoon-dev/el-popover",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -39,11 +39,11 @@
|
|
|
39
39
|
"release:dry-run": "bun publish --dry-run"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@duskmoon-dev/el-base": "1.
|
|
43
|
-
"@duskmoon-dev/core": "1.17.
|
|
42
|
+
"@duskmoon-dev/el-base": "1.6.0",
|
|
43
|
+
"@duskmoon-dev/core": "1.17.2"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"typescript": "
|
|
46
|
+
"typescript": "6.0.3"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|