1 |
- {"version":3,"file":"dropdown.mjs","sources":["../../src/strings/dropdownComponent.ts","../../src/strings/dropdownMenuClass.ts","../../src/util/isEmptyAnchor.ts","../../src/components/dropdown.ts"],"sourcesContent":["/** @type {string} */\nconst dropdownComponent = \"Dropdown\";\nexport default dropdownComponent;\n","/**\n * Global namespace for `.dropdown-menu`.\n */\nconst dropdownMenuClass = \"dropdown-menu\";\nexport default dropdownMenuClass;\n","import { closest, getAttribute, hasAttribute } from \"@thednp/shorty\";\n\n/**\n * Checks if an *event.target* or its parent has an `href=\"#\"` value.\n * We need to prevent jumping around onclick, don't we?\n *\n * @param element the target element\n * @returns the query result\n */\nconst isEmptyAnchor = (element: HTMLElement) => {\n // `EventTarget` must be `HTMLElement`\n const parentAnchor = closest(element, \"A\");\n return (\n (element.tagName === \"A\" &&\n // anchor href starts with #\n hasAttribute(element, \"href\") &&\n (getAttribute(element, \"href\"))?.slice(-1) === \"#\") ||\n // OR a child of an anchor with href starts with #\n (parentAnchor &&\n hasAttribute(parentAnchor, \"href\") &&\n (getAttribute(parentAnchor, \"href\"))?.slice(-1) === \"#\")\n );\n};\nexport default isEmptyAnchor;\n","/* Native JavaScript for Bootstrap 5 | Dropdown\n----------------------------------------------- */\nimport {\n addClass,\n ariaExpanded,\n closest,\n createCustomEvent,\n CSS4Declaration,\n dispatchEvent,\n focus,\n focusEvent,\n getAttribute,\n getBoundingClientRect,\n getDocument,\n getDocumentElement,\n getElementsByClassName,\n getElementStyle,\n getInstance,\n hasClass,\n isHTMLElement,\n isRTL,\n keyArrowDown,\n keyArrowUp,\n KeyboardEvent,\n keydownEvent,\n keyEscape,\n keyupEvent,\n mouseclickEvent,\n mousedownEvent,\n MouseEvent,\n ObjectAssign,\n removeClass,\n setAttribute,\n setElementStyle,\n} from \"@thednp/shorty\";\n\nimport { addListener, removeListener } from \"@thednp/event-listener\";\nimport PositionObserver from \"@thednp/position-observer\";\n\nimport showClass from \"~/strings/showClass\";\nimport dataBsToggle from \"~/strings/dataBsToggle\";\nimport dropdownClasses from \"~/strings/dropdownClasses\";\nimport dropdownComponent from \"~/strings/dropdownComponent\";\nimport dropdownMenuClass from \"~/strings/dropdownMenuClass\";\nimport isEmptyAnchor from \"~/util/isEmptyAnchor\";\nimport isDisabled from \"~/util/isDisabled\";\nimport BaseComponent from \"./base-component\";\nimport type { DropdownEvent, DropdownOptions } from \"~/interface/dropdown\";\n\n// DROPDOWN PRIVATE GC\n// ===================\nconst [dropdownString, dropupString, dropstartString, dropendString] =\n dropdownClasses;\nconst dropdownSelector = `[${dataBsToggle}=\"${dropdownString}\"]`;\n\n/**\n * Static method which returns an existing `Dropdown` instance associated\n * to a target `Element`.\n */\nconst getDropdownInstance = (element: Element) =>\n getInstance<Dropdown>(element, dropdownComponent);\n\n/**\n * A `Dropdown` initialization callback.\n */\nconst dropdownInitCallback = (element: Element) => new Dropdown(element);\n\n// DROPDOWN PRIVATE GC\n// ===================\n// const dropdownMenuStartClass = `${dropdownMenuClass}-start`;\nconst dropdownMenuEndClass = `${dropdownMenuClass}-end`;\nconst verticalClass = [dropdownString, dropupString];\nconst horizontalClass = [dropstartString, dropendString];\nconst menuFocusTags = [\"A\", \"BUTTON\"];\n\nconst dropdownDefaults = {\n offset: 5, // [number] 5(px)\n display: \"dynamic\", // [dynamic|static]\n};\n\ntype DropdownEventProps = { relatedTarget: Element & EventTarget };\n\n// DROPDOWN CUSTOM EVENTS\n// ======================\nconst showDropdownEvent = createCustomEvent<DropdownEventProps, DropdownEvent>(\n `show.bs.${dropdownString}`,\n);\nconst shownDropdownEvent = createCustomEvent<DropdownEventProps, DropdownEvent>(\n `shown.bs.${dropdownString}`,\n);\nconst hideDropdownEvent = createCustomEvent<DropdownEventProps, DropdownEvent>(\n `hide.bs.${dropdownString}`,\n);\nconst hiddenDropdownEvent = createCustomEvent<\n DropdownEventProps,\n DropdownEvent\n>(`hidden.bs.${dropdownString}`);\nconst updatedDropdownEvent = createCustomEvent<\n DropdownEventProps,\n DropdownEvent\n>(`updated.bs.${dropdownString}`);\n\n// DROPDOWN PRIVATE METHODS\n// ========================\n/**\n * Apply specific style or class names to a `.dropdown-menu` to automatically\n * accomodate the layout and the page scroll.\n *\n * @param self the `Dropdown` instance\n */\nconst styleDropdown = (self: Dropdown) => {\n const { element, menu, parentElement, options } = self;\n const { offset } = options;\n // don't apply any style on mobile view\n // istanbul ignore if @preserve: this test requires a navbar\n if (getElementStyle(menu, \"position\") === \"static\") return;\n\n const RTL = isRTL(element);\n const menuEnd = hasClass(menu, dropdownMenuEndClass);\n\n // reset menu offset and position\n const resetProps = [\"margin\", \"top\", \"bottom\", \"left\", \"right\"];\n resetProps.forEach((p) => {\n const style: { [key: string]: string } = {};\n style[p] = \"\";\n setElementStyle(menu, style);\n });\n\n // set initial position class\n // take into account .btn-group parent as .dropdown\n // this requires navbar/btn-group/input-group\n let positionClass = dropdownClasses.find((c) => hasClass(parentElement, c)) ||\n /* istanbul ignore next @preserve: fallback position */\n dropdownString;\n\n const dropdownMargin: { [key: string]: number[] } = {\n dropdown: [offset, 0, 0],\n dropup: [0, 0, offset],\n dropstart: RTL ? [-1, 0, 0, offset] : [-1, offset, 0],\n dropend: RTL ? [-1, offset, 0] : [-1, 0, 0, offset],\n };\n\n const dropdownPosition: { [key: string]: Partial<CSS4Declaration> } = {\n dropdown: { top: \"100%\" },\n dropup: { top: \"auto\", bottom: \"100%\" },\n dropstart: RTL\n ? { left: \"100%\", right: \"auto\" }\n : { left: \"auto\", right: \"100%\" },\n dropend: RTL\n ? { left: \"auto\", right: \"100%\" }\n : { left: \"100%\", right: \"auto\" },\n menuStart: RTL\n ? { right: \"0\", left: \"auto\" }\n : { right: \"auto\", left: \"0\" },\n menuEnd: RTL ? { right: \"auto\", left: \"0\" } : { right: \"0\", left: \"auto\" },\n };\n\n const { offsetWidth: menuWidth, offsetHeight: menuHeight } = menu;\n\n const { clientWidth, clientHeight } = getDocumentElement(element);\n const {\n left: targetLeft,\n top: targetTop,\n width: targetWidth,\n height: targetHeight,\n } = getBoundingClientRect(element);\n\n // dropstart | dropend\n const leftFullExceed = targetLeft - menuWidth - offset < 0;\n // dropend\n const rightFullExceed =\n targetLeft + menuWidth + targetWidth + offset >= clientWidth;\n // dropstart | dropend\n const bottomExceed = targetTop + menuHeight + offset >= clientHeight;\n // dropdown\n const bottomFullExceed =\n targetTop + menuHeight + targetHeight + offset >= clientHeight;\n // dropup\n const topExceed = targetTop - menuHeight - offset < 0;\n // dropdown / dropup\n const leftExceed = ((!RTL && menuEnd) || (RTL && !menuEnd)) &&\n targetLeft + targetWidth - menuWidth < 0;\n const rightExceed = ((RTL && menuEnd) || (!RTL && !menuEnd)) &&\n targetLeft + menuWidth >= clientWidth;\n\n // recompute position\n // handle RTL as well\n if (\n horizontalClass.includes(positionClass) && leftFullExceed &&\n rightFullExceed\n ) {\n positionClass = dropdownString;\n }\n if (\n positionClass === dropstartString &&\n (!RTL ? leftFullExceed : rightFullExceed)\n ) {\n positionClass = dropendString;\n }\n if (\n positionClass === dropendString &&\n (RTL ? leftFullExceed : rightFullExceed)\n ) {\n positionClass = dropstartString;\n }\n if (positionClass === dropupString && topExceed && !bottomFullExceed) {\n positionClass = dropdownString;\n }\n if (positionClass === dropdownString && bottomFullExceed && !topExceed) {\n positionClass = dropupString;\n }\n\n // override position for horizontal classes\n if (horizontalClass.includes(positionClass) && bottomExceed) {\n ObjectAssign(dropdownPosition[positionClass], {\n top: \"auto\",\n bottom: 0,\n });\n }\n\n // override position for vertical classes\n if (verticalClass.includes(positionClass) && (leftExceed || rightExceed)) {\n // don't realign when menu is wider than window\n // in both RTL and non-RTL readability is KING\n let posAjust:\n | { left: \"auto\" | number; right: \"auto\" | number }\n | undefined = { left: \"auto\", right: \"auto\" };\n /* istanbul ignore else @preserve */\n if (!leftExceed && rightExceed && !RTL) {\n posAjust = { left: \"auto\", right: 0 };\n }\n /* istanbul ignore else @preserve */\n if (leftExceed && !rightExceed && RTL) {\n posAjust = { left: 0, right: \"auto\" };\n }\n /* istanbul ignore else @preserve */\n if (posAjust) {\n ObjectAssign(dropdownPosition[positionClass], posAjust);\n }\n }\n\n const margins: number[] = dropdownMargin[positionClass];\n setElementStyle(menu, {\n ...dropdownPosition[positionClass],\n margin: `${margins.map((x) => (x ? `${x}px` : x)).join(\" \")}`,\n });\n\n // override dropdown-menu-start | dropdown-menu-end\n if (verticalClass.includes(positionClass) && menuEnd) {\n // istanbul ignore else @preserve\n if (menuEnd) {\n const endAdjust = (!RTL && leftExceed) || (RTL && rightExceed)\n ? \"menuStart\"\n : /* istanbul ignore next @preserve */ \"menuEnd\";\n setElementStyle(menu, dropdownPosition[endAdjust]);\n }\n }\n // trigger updated event\n dispatchEvent(parentElement, updatedDropdownEvent);\n};\n\n/**\n * Returns an `Array` of focusable items in the given dropdown-menu.\n *\n * @param menu the target menu\n * @returns all children of the dropdown menu\n */\nconst getMenuItems = (menu: HTMLElement) => {\n return Array.from(menu.children)\n .map((c) => {\n if (c && menuFocusTags.includes(c.tagName)) return c as HTMLElement;\n const { firstElementChild } = c;\n if (\n firstElementChild && menuFocusTags.includes(firstElementChild.tagName)\n ) {\n return firstElementChild as HTMLElement;\n }\n return null;\n })\n .filter((c) => c);\n};\n\n/**\n * Toggles on/off the listeners for the events that close the dropdown\n * as well as event that request a new position for the dropdown.\n *\n * @param {Dropdown} self the `Dropdown` instance\n */\nconst toggleDropdownDismiss = (self: Dropdown) => {\n const { element, options, menu } = self;\n const action = self.open ? addListener : removeListener;\n const doc = getDocument(element);\n\n action(doc, mouseclickEvent, dropdownDismissHandler);\n action(doc, focusEvent, dropdownDismissHandler);\n action(doc, keydownEvent, dropdownPreventScroll);\n action(doc, keyupEvent, dropdownKeyHandler);\n\n // istanbul ignore else @preserve\n if (options.display === \"dynamic\") {\n if (self.open) self._observer.observe(menu);\n else self._observer.disconnect();\n }\n};\n\n/**\n * Returns the currently open `.dropdown` element.\n *\n * @param element target\n * @returns the query result\n */\nconst getCurrentOpenDropdown = (\n element: Element,\n): Element | undefined => {\n const currentParent = [...dropdownClasses, \"btn-group\", \"input-group\"]\n .map((c) =>\n getElementsByClassName(`${c} ${showClass}`, getDocument(element))\n )\n .find((x) => x.length);\n\n if (currentParent && currentParent.length) {\n return [...(currentParent[0].children as HTMLCollectionOf<Element>)]\n .find((x) =>\n dropdownClasses.some((c) => c === getAttribute(x, dataBsToggle))\n );\n }\n return undefined;\n};\n\n// DROPDOWN EVENT HANDLERS\n// =======================\n/**\n * Handles the `click` event for the `Dropdown` instance.\n *\n * @param e event object\n */\nconst dropdownDismissHandler = (e: MouseEvent) => {\n const { target, type } = e;\n\n // istanbul ignore if @preserve\n if (!isHTMLElement(target)) return;\n\n // some weird FF bug #409\n const element = getCurrentOpenDropdown(target);\n const self = element && getDropdownInstance(element);\n\n // istanbul ignore if @preserve\n if (!self) return;\n\n const { parentElement, menu } = self;\n\n const isForm = parentElement &&\n parentElement.contains(target) &&\n (target.tagName === \"form\" || closest(target, \"form\") !== null);\n\n if (\n [mouseclickEvent, mousedownEvent].includes(type) &&\n isEmptyAnchor(target)\n ) {\n e.preventDefault();\n }\n\n // istanbul ignore else @preserve\n if (\n !isForm && type !== focusEvent && target !== element && target !== menu\n ) {\n self.hide();\n }\n};\n\n/**\n * Handles `click` event listener for `Dropdown`.\n *\n * @param e event object\n */\nfunction dropdownClickHandler(this: HTMLElement, e: MouseEvent<HTMLElement>) {\n const self = getDropdownInstance(this);\n\n // istanbul ignore if @preserve\n if (isDisabled(this)) return;\n // istanbul ignore if @preserve\n if (!self) return;\n\n e.stopPropagation();\n self.toggle();\n // istanbul ignore else @preserve\n if (isEmptyAnchor(this)) e.preventDefault();\n}\n\n/**\n * Prevents scroll when dropdown-menu is visible.\n *\n * @param e event object\n */\nconst dropdownPreventScroll = (e: KeyboardEvent) => {\n // istanbul ignore else @preserve\n if ([keyArrowDown, keyArrowUp].includes(e.code)) e.preventDefault();\n};\n\n/**\n * Handles keyboard `keydown` events for `Dropdown`.\n *\n * @param e keyboard key\n */\nfunction dropdownKeyHandler(this: Element, e: KeyboardEvent) {\n const { code } = e;\n const element = getCurrentOpenDropdown(this) as HTMLElement;\n /* istanbul ignore if @preserve */\n if (!element) return;\n\n const self = getDropdownInstance(element);\n const { activeElement } = getDocument(element) as Document & {\n activeElement: HTMLElement;\n };\n\n // istanbul ignore if @preserve\n if (!self || !activeElement) return;\n\n const { menu, open } = self;\n const menuItems = getMenuItems(menu);\n\n // arrow up & down\n if (\n menuItems && menuItems.length && [keyArrowDown, keyArrowUp].includes(code)\n ) {\n let idx = menuItems.indexOf(activeElement);\n // istanbul ignore else @preserve\n if (activeElement === element) {\n idx = 0;\n } else if (code === keyArrowUp) {\n idx = idx > 1 ? idx - 1 : 0;\n } else if (code === keyArrowDown) {\n idx = idx < menuItems.length - 1 ? idx + 1 : idx;\n }\n // istanbul ignore else @preserve\n if (menuItems[idx]) focus(menuItems[idx] as HTMLElement);\n }\n\n if (keyEscape === code && open) {\n self.toggle();\n focus(element);\n }\n}\n\n// DROPDOWN DEFINITION\n// ===================\n/** Returns a new Dropdown instance. */\nexport default class Dropdown extends BaseComponent {\n static selector = dropdownSelector;\n static init = dropdownInitCallback;\n static getInstance = getDropdownInstance;\n declare element: HTMLElement;\n declare options: DropdownOptions;\n declare open: boolean;\n declare parentElement: HTMLElement;\n declare menu: HTMLElement;\n declare _observer: PositionObserver;\n\n /**\n * @param target Element or string selector\n * @param config the instance options\n */\n constructor(target: Element | string, config?: Partial<DropdownOptions>) {\n super(target, config);\n\n // initialization element\n const { parentElement } = this.element;\n const [menu] = getElementsByClassName<HTMLElement>(\n dropdownMenuClass,\n parentElement as ParentNode,\n );\n\n // invalidate when dropdown-menu is missing\n // istanbul ignore if @preserve\n if (!menu) return;\n\n // set targets\n this.parentElement = parentElement as HTMLElement;\n this.menu = menu;\n this._observer = new PositionObserver(\n () => styleDropdown(this),\n );\n\n // add event listener\n this._toggleEventListeners(true);\n }\n\n /**\n * Returns component name string.\n */\n get name() {\n return dropdownComponent;\n }\n /**\n * Returns component default options.\n */\n get defaults() {\n return dropdownDefaults;\n }\n\n // DROPDOWN PUBLIC METHODS\n // =======================\n /** Shows/hides the dropdown menu to the user. */\n toggle() {\n if (this.open) this.hide();\n else this.show();\n }\n\n /** Shows the dropdown menu to the user. */\n show() {\n const { element, open, menu, parentElement } = this;\n\n // istanbul ignore if @preserve\n if (open) return;\n const currentElement = getCurrentOpenDropdown(element);\n const currentInstance = currentElement &&\n getDropdownInstance(currentElement);\n if (currentInstance) currentInstance.hide();\n\n // dispatch event\n [showDropdownEvent, shownDropdownEvent, updatedDropdownEvent].forEach(\n (e) => {\n e.relatedTarget = element;\n },\n );\n\n dispatchEvent(parentElement, showDropdownEvent);\n // istanbul ignore if @preserve\n if (showDropdownEvent.defaultPrevented) return;\n\n addClass(menu, showClass);\n addClass(parentElement, showClass);\n setAttribute(element, ariaExpanded, \"true\");\n\n // change menu position\n styleDropdown(this);\n\n this.open = !open;\n\n focus(element); // focus the element\n toggleDropdownDismiss(this);\n dispatchEvent(parentElement, shownDropdownEvent);\n }\n\n /** Hides the dropdown menu from the user. */\n hide() {\n const { element, open, menu, parentElement } = this;\n\n // istanbul ignore if @preserve\n if (!open) return;\n\n [hideDropdownEvent, hiddenDropdownEvent].forEach((e) => {\n e.relatedTarget = element as HTMLElement;\n });\n\n dispatchEvent(parentElement, hideDropdownEvent);\n // istanbul ignore if @preserve\n if (hideDropdownEvent.defaultPrevented) return;\n\n removeClass(menu, showClass);\n removeClass(parentElement, showClass);\n setAttribute(element, ariaExpanded, \"false\");\n\n this.open = !open;\n // only re-attach handler if the instance is not disposed\n toggleDropdownDismiss(this);\n dispatchEvent(parentElement, hiddenDropdownEvent);\n }\n\n /**\n * Toggles on/off the `click` event listener of the `Dropdown`.\n *\n * @param add when `true`, it will add the event listener\n */\n _toggleEventListeners = (add?: boolean) => {\n const action = add ? addListener : removeListener;\n action(this.element, mouseclickEvent, dropdownClickHandler);\n };\n\n /** Removes the `Dropdown` component from the target element. */\n dispose() {\n if (this.open) this.hide();\n\n this._toggleEventListeners();\n super.dispose();\n }\n}\n"],"names":["dropdownComponent","dropdownMenuClass","isEmptyAnchor","element","parentAnchor","closest","hasAttribute","getAttribute","dropdownString","dropupString","dropstartString","dropendString","dropdownClasses","dropdownSelector","dataBsToggle","getDropdownInstance","getInstance","dropdownInitCallback","Dropdown","dropdownMenuEndClass","verticalClass","horizontalClass","menuFocusTags","dropdownDefaults","showDropdownEvent","createCustomEvent","shownDropdownEvent","hideDropdownEvent","hiddenDropdownEvent","updatedDropdownEvent","styleDropdown","self","menu","parentElement","options","offset","getElementStyle","RTL","isRTL","menuEnd","hasClass","p","style","setElementStyle","positionClass","dropdownMargin","dropdownPosition","menuWidth","menuHeight","clientWidth","clientHeight","getDocumentElement","targetLeft","targetTop","targetWidth","targetHeight","getBoundingClientRect","leftFullExceed","rightFullExceed","bottomExceed","bottomFullExceed","topExceed","leftExceed","rightExceed","ObjectAssign","posAjust","margins","x","dispatchEvent","getMenuItems","c","firstElementChild","toggleDropdownDismiss","action","addListener","removeListener","doc","getDocument","mouseclickEvent","dropdownDismissHandler","focusEvent","keydownEvent","dropdownPreventScroll","keyupEvent","dropdownKeyHandler","getCurrentOpenDropdown","currentParent","getElementsByClassName","showClass","e","target","type","isHTMLElement","isForm","mousedownEvent","dropdownClickHandler","isDisabled","keyArrowDown","keyArrowUp","code","activeElement","open","menuItems","idx","focus","keyEscape","BaseComponent","config","PositionObserver","currentElement","currentInstance","addClass","setAttribute","ariaExpanded","removeClass","add"],"mappings":";;;;;;AACA,MAAMA,KAAoB,YCApBC,KAAoB,iBCEpBC,KAAgB,CAACC,MAAyB;AAExC,QAAAC,IAAeC,GAAQF,GAAS,GAAG;AAEtC,SAAAA,EAAQ,YAAY,OAEnBG,EAAaH,GAAS,MAAM,KAC3BI,EAAaJ,GAAS,MAAM,GAAI,MAAM,EAAE,MAAM,OAEhDC,KACCE,EAAaF,GAAc,MAAM,KAChCG,EAAaH,GAAc,MAAM,GAAI,MAAM,EAAE,MAAM;A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