@graupl/graupl 1.0.0-beta.24 → 1.0.0-beta.26
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/css/component/accordion.css +1 -1
- package/dist/css/component/accordion.css.map +1 -1
- package/dist/css/component/list.css +1 -1
- package/dist/css/component/list.css.map +1 -1
- package/dist/css/component.css +1 -1
- package/dist/css/component.css.map +1 -1
- package/dist/css/graupl.css +1 -1
- package/dist/css/graupl.css.map +1 -1
- package/dist/js/accordion.js +2 -2
- package/dist/js/accordion.js.map +1 -1
- package/dist/js/alert.js +2 -2
- package/dist/js/alert.js.map +1 -1
- package/dist/js/carousel.js +2 -2
- package/dist/js/carousel.js.map +1 -1
- package/dist/js/component/accordion.cjs.js +2 -2
- package/dist/js/component/accordion.cjs.js.map +1 -1
- package/dist/js/component/accordion.es.js +2 -2
- package/dist/js/component/accordion.es.js.map +1 -1
- package/dist/js/component/accordion.iife.js +2 -2
- package/dist/js/component/accordion.iife.js.map +1 -1
- package/dist/js/component/alert.cjs.js +2 -2
- package/dist/js/component/alert.cjs.js.map +1 -1
- package/dist/js/component/alert.es.js +2 -2
- package/dist/js/component/alert.es.js.map +1 -1
- package/dist/js/component/alert.iife.js +2 -2
- package/dist/js/component/alert.iife.js.map +1 -1
- package/dist/js/component/carousel.cjs.js +2 -2
- package/dist/js/component/carousel.cjs.js.map +1 -1
- package/dist/js/component/carousel.es.js +2 -2
- package/dist/js/component/carousel.es.js.map +1 -1
- package/dist/js/component/carousel.iife.js +2 -2
- package/dist/js/component/carousel.iife.js.map +1 -1
- package/dist/js/component/disclosure.cjs.js +2 -2
- package/dist/js/component/disclosure.cjs.js.map +1 -1
- package/dist/js/component/disclosure.es.js +2 -2
- package/dist/js/component/disclosure.es.js.map +1 -1
- package/dist/js/component/disclosure.iife.js +2 -2
- package/dist/js/component/disclosure.iife.js.map +1 -1
- package/dist/js/component/tabs.cjs.js +2 -2
- package/dist/js/component/tabs.cjs.js.map +1 -1
- package/dist/js/component/tabs.es.js +2 -2
- package/dist/js/component/tabs.es.js.map +1 -1
- package/dist/js/component/tabs.iife.js +2 -2
- package/dist/js/component/tabs.iife.js.map +1 -1
- package/dist/js/disclosure.js +2 -2
- package/dist/js/disclosure.js.map +1 -1
- package/dist/js/generator/accordion.cjs.js +2 -2
- package/dist/js/generator/accordion.cjs.js.map +1 -1
- package/dist/js/generator/accordion.es.js +2 -2
- package/dist/js/generator/accordion.es.js.map +1 -1
- package/dist/js/generator/accordion.iife.js +2 -2
- package/dist/js/generator/accordion.iife.js.map +1 -1
- package/dist/js/generator/alert.cjs.js +2 -2
- package/dist/js/generator/alert.cjs.js.map +1 -1
- package/dist/js/generator/alert.es.js +2 -2
- package/dist/js/generator/alert.es.js.map +1 -1
- package/dist/js/generator/alert.iife.js +2 -2
- package/dist/js/generator/alert.iife.js.map +1 -1
- package/dist/js/generator/carousel.cjs.js +2 -2
- package/dist/js/generator/carousel.cjs.js.map +1 -1
- package/dist/js/generator/carousel.es.js +2 -2
- package/dist/js/generator/carousel.es.js.map +1 -1
- package/dist/js/generator/carousel.iife.js +2 -2
- package/dist/js/generator/carousel.iife.js.map +1 -1
- package/dist/js/generator/disclosure.cjs.js +2 -2
- package/dist/js/generator/disclosure.cjs.js.map +1 -1
- package/dist/js/generator/disclosure.es.js +2 -2
- package/dist/js/generator/disclosure.es.js.map +1 -1
- package/dist/js/generator/disclosure.iife.js +2 -2
- package/dist/js/generator/disclosure.iife.js.map +1 -1
- package/dist/js/generator/tabs.cjs.js +2 -2
- package/dist/js/generator/tabs.cjs.js.map +1 -1
- package/dist/js/generator/tabs.es.js +2 -2
- package/dist/js/generator/tabs.es.js.map +1 -1
- package/dist/js/generator/tabs.iife.js +2 -2
- package/dist/js/generator/tabs.iife.js.map +1 -1
- package/dist/js/graupl.js +2 -8
- package/dist/js/graupl.js.map +1 -1
- package/dist/js/navigation.js +1 -1
- package/dist/js/navigation.js.map +1 -1
- package/dist/js/tabs.js +2 -2
- package/dist/js/tabs.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alert.iife.js","names":["isValidInstance","constructor","elements","elementsType","TypeError","key","elementType","name","status","error","isValidType","type","values","valuesType","valueType","isQuerySelector","Error","document","querySelector","isValidClassList","Array","isArray","forEach","value","obj","isValidHoverType","validTypes","includes","join","isTag","tagName","HTMLElement","tag","toLowerCase","check","isValidState","validStates","isValidEvent","validEvents","addClass","className","element","length","classList","add","removeClass","remove","selectAllFocusableElements","context","document","fn","querySelector","elements","Array","from","querySelectorAll","tabbableElements","filter","check","getAttribute","selectFirstFocusableElement","selectLastFocusableElement","selectNextFocusableElement","index","indexOf","selectPreviousFocusableElement","keyPress","event","key","keyCode","keys","Enter","Space","Escape","ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End","Tab","Object","find","preventEvent","preventDefault","stopPropagation","isValidType","initializeStorage","type","window","Graupl","getStorage","setStorage","data","clearStorage","pushToStorage","key","value","getFromStorage","removeFromStorage","isValidClassList","isValidInstance","isValidType","addClass","removeClass","keyPress","preventEvent","storage","Alert","_dom","alert","controller","_hidden","_showClass","_hideClass","_transitionClass","_transitionTimer","_key","_errors","_showEvent","CustomEvent","bubbles","detail","_hideEvent","constructor","alertElement","controllerElement","showClass","hideClass","transitionClass","transitionTimer","isHidden","key","initialize","_validate","Error","errors","join","_generateKey","_setIds","_handleClick","_handleKeydown","_handleKeyup","initializeStorage","pushToStorage","dom","id","error","console","value","check","htmlElementChecks","HTMLElement","status","push","message","showClassCheck","hideClassCheck","transitionClassCheck","transitionTimerCheck","hiddenCheck","regenerate","Math","random","toString","replace","substring","show","emit","requestAnimationFrame","dispatchEvent","hide","setTimeout","addEventListener","event","wsRE","attrName","doc","document","attr","element","op","value","attrSelector","id","TypeError","test","RangeError","checkElement","itemToCheck","Element","getElements","selector","context","elements","Document","DocumentFragment","querySelectorAll","Array","prototype","slice","call","filterAndModify","apply","filter","selected","matches","updateAttribute","add","remove","result","trim","split","forEach","item","indexOf","push","attribute","join","once","find","Alert","once","generate","options","context","document","alertSelector","forEach","alertElement","alertOptions","dataset","grauplAlertOptions","JSON","parse","replace","controllerElement","querySelector","initialize"],"sources":["../../../packages/core/src/js/validate.js","../../../packages/core/src/js/domHelpers.js","../../../packages/core/src/js/eventHandlers.js","../../../packages/core/src/js/storage.js","../../../packages/core/src/js/alert/Alert.js","../../../node_modules/@drupal/once/src/once.js","../../../packages/core/src/js/alert/generator.js"],"sourcesContent":["/**\n * Check to see if the provided elements have a specific constructor.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking instanceof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {object} constructor - The constructor to check for.\n * @param {object} elements - The element(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidInstance(constructor, elements) {\n try {\n if (typeof elements !== \"object\") {\n const elementsType = typeof elements;\n\n throw new TypeError(\n `Elements given to isValidInstance() must be inside of an object. \"${elementsType}\" given.`\n );\n }\n\n for (const key in elements) {\n if (!(elements[key] instanceof constructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `${key} must be an instance of ${constructor.name}. \"${elementType}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are of a specific type.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking typeof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {string} type - The type to check for.\n * @param {object} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidType(type, values) {\n try {\n if (typeof values !== \"object\") {\n const valuesType = typeof values;\n\n throw new TypeError(\n `Values given to isValidType() must be inside of an object. \"${valuesType}\" given.`\n );\n }\n\n for (const key in values) {\n const valueType = typeof values[key];\n\n if (valueType !== type) {\n throw new TypeError(`${key} must be a ${type}. \"${valueType}\" given.`);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided values are valid query selectors.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isQuerySelector(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isQuerySelector() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n try {\n if (values[key] === null) {\n throw new Error();\n }\n\n document.querySelector(values[key]);\n } catch {\n throw new TypeError(\n `${key} must be a valid query selector. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided value is either a string or an array of strings.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string, string[]>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidClassList(values) {\n try {\n if (typeof values !== \"object\" || Array.isArray(values)) {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidClassList() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n const type = typeof values[key];\n\n if (type !== \"string\") {\n if (Array.isArray(values[key])) {\n values[key].forEach((value) => {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `${key} must be a string or an array of strings. An array containing non-strings given.`\n );\n }\n });\n } else {\n throw new TypeError(\n `${key} must be a string or an array of strings. \"${type}\" given.`\n );\n }\n } else {\n const obj = {};\n obj[key] = values[key];\n\n isQuerySelector(obj);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid hover types.\n *\n * Available types are: `\"off\"`, `\"on\"`, and `\"dynamic\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidHoverType(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidHoverType() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validTypes = [\"off\", \"on\", \"dynamic\"];\n\n for (const key in values) {\n if (!validTypes.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validTypes.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided elements are using a specific tag.\n *\n * The elements must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `true` if the check is successful.\n *\n * @param {string} tagName - The name of the tag.\n * @param {Object<HTMLElement>} elements - The element(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isTag(tagName, elements) {\n if (\n isValidType(\"string\", { tagName }).status &&\n isValidInstance(HTMLElement, elements).status\n ) {\n const tag = tagName.toLowerCase();\n let check = true;\n\n for (const key in elements) {\n if (elements[key].tagName.toLowerCase() !== tag) check = false;\n }\n\n return check;\n } else {\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid focus states for a menu.\n *\n * Available states are: `\"none\"`, `\"self\"`, and `\"child\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidState(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidState() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validStates = [\"none\", \"self\", \"child\"];\n\n for (const key in values) {\n if (!validStates.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validStates.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid event types for a menu.\n *\n * Available events are: `\"none\"`, `\"mouse\"`, `\"keyboard\"`, and `\"character\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidEvent(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidEvent() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validEvents = [\"none\", \"mouse\", \"keyboard\", \"character\"];\n\n for (const key in values) {\n if (!validEvents.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validEvents.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n","/**\n * Add a class or array of classes to an element.\n *\n * @param {string|string[]} className - The class or classes to add.\n * @param {HTMLElement} element - The element to add the class to.\n */\nexport function addClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.add(className);\n } else {\n element.classList.add(...className);\n }\n}\n\n/**\n * Remove a class or array of classes from an element.\n *\n * @param {string|string[]} className - The class or classes to remove.\n * @param {HTMLElement} element - The element to remove the class from.\n */\nexport function removeClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.remove(className);\n } else {\n element.classList.remove(...className);\n }\n}\n\n/**\n * Select all focusable elements within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement[]} - An array of focusable elements.\n */\nexport function selectAllFocusableElements(context = document, fn = null) {\n const querySelector =\n \"a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),[tabindex]\";\n const elements = Array.from(context.querySelectorAll(querySelector));\n\n const tabbableElements = elements.filter((element) => {\n let check = true;\n\n if (element.getAttribute(\"tabindex\") === \"-1\") check = false;\n\n return check;\n });\n\n if (fn !== null) {\n return tabbableElements.filter(fn);\n } else {\n return tabbableElements;\n }\n}\n\n/**\n * Select the first focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The first focusable element or false if none found.\n */\nexport function selectFirstFocusableElement(context = document, fn = null) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n\n return tabbableElements[0] || false;\n}\n\n/**\n * Select the last focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The last focusable element or false if none found.\n */\nexport function selectLastFocusableElement(context = document, fn = null) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n\n return tabbableElements[tabbableElements.length - 1] || false;\n}\n\n/**\n * Select the next focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The next focusable element or false if none found.\n */\nexport function selectNextFocusableElement(\n element,\n context = document,\n fn = null\n) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n const index = tabbableElements.indexOf(element);\n\n return index === tabbableElements.length - 1\n ? false\n : tabbableElements[index + 1];\n}\n\n/**\n * Select the previous focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The previous focusable element or false if none found.\n */\nexport function selectPreviousFocusableElement(\n element,\n context = document,\n fn = null\n) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n const index = tabbableElements.indexOf(element);\n\n return index === 0 ? false : tabbableElements[index - 1];\n}\n","/**\n * Retrieves the pressed key from an event.\n *\n * @param {KeyboardEvent} event - The keyboard event.\n * @return {string} - The name of the key or an empty string.\n */\nexport function keyPress(event) {\n try {\n // Use event.key or event.keyCode to support older browsers.\n const key = event.key || event.keyCode;\n const keys = {\n Enter: key === \"Enter\" || key === 13,\n Space: key === \" \" || key === \"Spacebar\" || key === 32,\n Escape: key === \"Escape\" || key === \"Esc\" || key === 27,\n ArrowUp: key === \"ArrowUp\" || key === \"Up\" || key === 38,\n ArrowRight: key === \"ArrowRight\" || key === \"Right\" || key === 39,\n ArrowDown: key === \"ArrowDown\" || key === \"Down\" || key === 40,\n ArrowLeft: key === \"ArrowLeft\" || key === \"Left\" || key === 37,\n Home: key === \"Home\" || key === 36,\n End: key === \"End\" || key === 35,\n Tab: key === \"Tab\" || key === 9,\n };\n\n return Object.keys(keys).find((key) => keys[key] === true) || \"\";\n } catch {\n // Return an empty string if something goes wrong.\n return \"\";\n }\n}\n\n/**\n * Stops an event from taking action.\n *\n * @param {Event} event - The event.\n */\nexport function preventEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\n","/**\n * @file\n * Provides a system to get and store Graupl data in the browser.\n */\n\nimport { isValidType } from \"./validate.js\";\n\n/**\n * Initializes the storage system.\n *\n * @param {?string} [type = null] - The type of storage to initialize.\n */\nexport function initializeStorage(type = null) {\n window.Graupl = window.Graupl || {};\n\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = window.Graupl[type] || {};\n }\n}\n\n/**\n * Get the storage object.\n *\n * @param {?string} type - The type of storage to get.\n * @return {object} - The storage object.\n */\nexport function getStorage(type = null) {\n if (isValidType(\"string\", { type })) {\n return window.Graupl[type];\n }\n\n return window.Graupl;\n}\n\n/**\n * Set the storage object of a given type.\n *\n * @param {string} type - The type of storage to set.\n * @param {object} data - The data to set.\n */\nexport function setStorage(type, data = {}) {\n if (isValidType(\"string\", { type }) && isValidType(\"object\", { data })) {\n window.Graupl[type] = data;\n }\n}\n\n/**\n * Clear the storage object of a given type.\n *\n * @param {string} type - The type of storage to clear.\n */\nexport function clearStorage(type) {\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = {};\n }\n}\n\n/**\n * Push a value to the storage object.\n *\n * @param {string} type - The type of storage to push to.\n * @param {string} key - The key to use for the value.\n * @param {*} value - The value to store.\n */\nexport function pushToStorage(type, key, value) {\n if (isValidType(\"string\", { type, key })) {\n window.Graupl[type][key] = value;\n }\n}\n\n/**\n * Get a value from the storage object.\n *\n * @param {string }type - The type of storage to get from.\n * @param {string }key - The key to get the value from.\n * @return {*} - The value from the storage object.\n */\nexport function getFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n return window.Graupl[type][key];\n }\n\n return null;\n}\n\n/**\n * Remove a value from the storage object.\n *\n * @param {string} type - The type of storage to remove from.\n * @param {string} key - The key to remove the value from.\n */\nexport function removeFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n delete window.Graupl[type][key];\n }\n}\n\nexport default {\n initializeStorage,\n getStorage,\n setStorage,\n clearStorage,\n pushToStorage,\n getFromStorage,\n removeFromStorage,\n};\n","/**\n * @file\n * The alert class.\n */\n\nimport { isValidClassList, isValidInstance, isValidType } from \"../validate.js\";\nimport { addClass, removeClass } from \"../domHelpers.js\";\nimport { keyPress, preventEvent } from \"../eventHandlers.js\";\nimport storage from \"../storage.js\";\n\nclass Alert {\n /**\n * The HTML elements for the alert in the DOM.\n *\n * @protected\n *\n * @type {Object<HTMLElement>}\n */\n _dom = {\n alert: null,\n controller: null,\n };\n\n /**\n * A flag to determine if the alert is hidden.\n *\n * @protected\n *\n * @type {boolean}\n */\n _hidden = false;\n\n /**\n * The class to use to show the alert.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _showClass = \"\";\n\n /**\n * The class to use to hide the alert.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _hideClass = \"\";\n\n /**\n * The class to use when transitioning the alert.\n *\n * @protected\n *\n * @type {string|string[]}\n */\n _transitionClass = \"\";\n\n /**\n * The time in milliseconds the transition will take.\n *\n * @protected\n *\n * @type {number}\n */\n _transitionTimer = 150;\n\n /**\n * The key used to generate IDs throughout the carousel.\n *\n * @protected\n *\n * @type {string}\n */\n _key = \"\";\n\n /**\n * An array of error messages generated by the alert.\n *\n * @protected\n *\n * @type {string[]}\n */\n _errors = [];\n\n /**\n * The event that is triggered when the alert is shown.\n *\n * @protected\n *\n * @event grauplAlertShow\n *\n * @type {CustomEvent}\n *\n * @property {boolean} bubbles - A flag to bubble the event.\n * @property {Object<Alert>} detail - The details object container the Alert itself.\n */\n _showEvent = new CustomEvent(\"grauplAlertShow\", {\n bubbles: true,\n detail: { alert: this },\n });\n\n /**\n * The event that is triggered when the alert is hidden.\n *\n * @protected\n *\n * @event grauplAlertHide\n *\n * @type {CustomEvent}\n *\n * @property {boolean} bubbles - A flag to bubble the event.\n * @property {Object<Alert>} detail - The details object containing the Alert itself.\n */\n _hideEvent = new CustomEvent(\"grauplAlertHide\", {\n bubbles: true,\n detail: { alert: this },\n });\n\n /**\n * Constructs a new `Alert`.\n *\n * @param {object} options - The options object.\n * @param {HTMLElement} options.alertElement - The alert element.\n * @param {?HTMLElement} [options.controllerElement = null] - The controller element.\n * @param {string|string[]|null} [options.showClass = show] - The class to add when the alert is shown.\n * @param {string|string[]|null} [options.hideClass = hide] - The class to add when\n * @param {string|string[]|null} [options.transitionClass = transitioning] - The class to add when the alert is transitioning between shown and hidden.\n * @param {number} [options.transitionTimer = 150] - The time in milliseconds the transition will take.\n * @param {boolean} [options.isHidden = false] - A flag to determine the initial state of the alert.\n * @param {?string} [options.key = null] - The key used to generate IDs throughout the alert.\n * @param {boolean} [options.initialize = false] - AA flag to initialize the alert immediately upon creation.\n */\n constructor({\n alertElement,\n controllerElement = null,\n showClass = \"show\",\n hideClass = \"hide\",\n transitionClass = \"transitioning\",\n transitionTimer = 150,\n isHidden = false,\n key = null,\n initialize = false,\n }) {\n this._dom.alert = alertElement;\n this._dom.controller = controllerElement;\n this._showClass = showClass || \"\";\n this._hideClass = hideClass || \"\";\n this._transitionClass = transitionClass || \"\";\n this._transitionTimer = transitionTimer;\n this._hidden = isHidden;\n\n // Set the key.\n this._key = key || \"\";\n\n if (initialize) {\n this.initialize();\n }\n }\n\n /**\n * Initializes the alert.\n */\n initialize() {\n try {\n if (!this._validate()) {\n throw new Error(\n `Graupl Alert: cannot initialize alert. The following errors have been found:\\n - ${this.errors.join(\n \"\\n - \"\n )}`\n );\n }\n\n // Set up the DOM.\n this._generateKey();\n this._setIds();\n\n // Handle events.\n this._handleClick();\n this._handleKeydown();\n this._handleKeyup();\n\n // Set up the storage.\n storage.initializeStorage(\"alerts\");\n storage.pushToStorage(\"alerts\", this.dom.alert.id, this);\n } catch (error) {\n console.error(error);\n }\n }\n\n /**\n * The HTML elements for the alert in the DOM.\n *\n * @readonly\n *\n * @see _dom\n *\n * @type {object}\n */\n get dom() {\n return this._dom;\n }\n\n /**\n * The class to use the show the alert.\n *\n * @type {string|string[]}\n *\n * @see _showClass\n */\n get showClass() {\n return this._showClass;\n }\n\n /**\n * The class to use to hide the alert.\n *\n * @type {string|string[]}\n *\n * @see _hideClass\n */\n get hideClass() {\n return this._hideClass;\n }\n\n /**\n * The class to use when transitioning the alert.\n *\n * @type {string|string[]}\n *\n * @see _transitionClass\n */\n get transitionClass() {\n return this._transitionClass;\n }\n\n /**\n * The time in milliseconds the transition will take.\n *\n * @type {number}\n *\n * @see _transitionTimer\n */\n get transitionTimer() {\n return this._transitionTimer;\n }\n\n /**\n * The key used to generate IDs throughout the accordion.\n *\n * @type {string}\n *\n * @see _key\n */\n get key() {\n return this._key;\n }\n\n set showClass(value) {\n isValidClassList({ showClass: value });\n\n if (this._showClass !== value) {\n this._showClass = value;\n }\n }\n\n set hideClass(value) {\n isValidClassList({ hideClass: value });\n\n if (this._hideClass !== value) {\n this._hideClass = value;\n }\n }\n\n set transitionClass(value) {\n isValidClassList({ transitionClass: value });\n\n if (this._transitionClass !== value) {\n this._transitionClass = value;\n }\n }\n\n set transitionTimer(value) {\n isValidType(\"number\", { transitionTimer: value });\n\n if (this._transitionTimer !== value) {\n this._transitionTimer = value;\n }\n }\n\n set key(value) {\n isValidType(\"string\", { value });\n\n if (this._key !== value) {\n this._key = value;\n }\n }\n\n /**\n * Validates all aspects of the alert to ensure proper functionality.\n *\n * @protected\n *\n * @return {boolean} - The result of the validation.\n */\n _validate() {\n let check = true;\n\n // HTML element checks.\n let htmlElementChecks;\n\n if (this._dom.controller !== null) {\n htmlElementChecks = isValidInstance(HTMLElement, {\n alertElement: this._dom.alert,\n controllerElement: this._dom.controller,\n });\n } else {\n htmlElementChecks = isValidInstance(HTMLElement, {\n alertElement: this._dom.alert,\n });\n }\n\n if (!htmlElementChecks.status) {\n this._errors.push(htmlElementChecks.message);\n check = false;\n }\n\n // Class list checks.\n if (this._showClass !== \"\") {\n const showClassCheck = isValidClassList({ showClass: this._showClass });\n\n if (!showClassCheck.status) {\n this._errors.push(showClassCheck.message);\n check = false;\n }\n }\n\n if (this._hideClass !== \"\") {\n const hideClassCheck = isValidClassList({ hideClass: this._hideClass });\n\n if (!hideClassCheck.status) {\n this._errors.push(hideClassCheck.message);\n check = false;\n }\n }\n\n if (this._transitionClass !== \"\") {\n const transitionClassCheck = isValidClassList({\n transitionClass: this._transitionClass,\n });\n\n if (!transitionClassCheck.status) {\n this._errors.push(transitionClassCheck.message);\n check = false;\n }\n }\n\n // Transition timer check.\n const transitionTimerCheck = isValidType(\"number\", {\n transitionTimer: this._transitionTimer,\n });\n\n if (!transitionTimerCheck.status) {\n this._errors.push(transitionTimerCheck.message);\n check = false;\n }\n\n // Hidden check.\n const hiddenCheck = isValidType(\"boolean\", { isHidden: this._hidden });\n\n if (!hiddenCheck.status) {\n this._errors.push(hiddenCheck.message);\n check = false;\n }\n\n return check;\n }\n\n /**\n * Generates a key for the alert.\n *\n * @param {boolean} [regenerate = false] - A flag to determine if the key should be regenerated.\n */\n _generateKey(regenerate = false) {\n if (this.key === \"\" || regenerate) {\n this.key = Math.random()\n .toString(36)\n .replace(/[^a-z]+/g, \"\")\n .substring(0, 10);\n }\n }\n\n /**\n * Sets the IDs of the alert and it's children if they do not already exist.\n *\n * The generated IDs use the key and follow the format:\n * - alert: `alert-${key}`\n * - controller: `alert-controller-${key}`\n */\n _setIds() {\n this.dom.alert.id = this.dom.alert.id || `alert-${this.key}`;\n this.dom.controller.id =\n this.dom.controller.id || `alert-controller-${this.key}`;\n }\n\n /**\n * Shows the alert.\n *\n * @fires grauplAlertShow\n *\n * @param {boolean} [emit = true] - A toggle to emit the show event once shown.\n */\n show(emit = true) {\n if (!this._hidden) {\n return;\n }\n\n // If we're dealing with transition classes, then we need to utilize\n // requestAnimationFrame to add the transition class, remove the hide class,\n // add the show class, and finally remove the transition class.\n if (this.transitionClass !== \"\") {\n addClass(this.transitionClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n if (this.hideClass !== \"\") {\n removeClass(this.hideClass, this.dom.alert);\n }\n\n requestAnimationFrame(() => {\n if (this.showClass !== \"\") {\n addClass(this.showClass, this.dom.alert);\n }\n\n requestAnimationFrame(() => {\n removeClass(this.transitionClass, this.dom.alert);\n });\n });\n });\n } else {\n // Add the show class\n if (this.showClass !== \"\") {\n addClass(this.showClass, this.dom.alert);\n }\n\n // Remove the hide class.\n if (this.hideClass !== \"\") {\n removeClass(this.hideClass, this.dom.alert);\n }\n }\n\n this._hidden = false;\n\n if (emit) {\n this.dom.alert.dispatchEvent(this._hideEvent);\n }\n }\n\n /**\n * Hides the alert.\n *\n * @fires grauplAlertHide\n *\n * @param {boolean} [emit = true] - A toggle to emit the hide event once shown.\n */\n hide(emit = true) {\n if (this._hidden) {\n return;\n }\n // If we're dealing with transition classes, then we need to utilize\n // requestAnimationFrame to add the transition class, remove the show class,\n // add the hide class, and finally remove the transition class.\n if (this.transitionClass !== \"\") {\n addClass(this.transitionClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n if (this.showClass !== \"\") {\n removeClass(this.showClass, this.dom.alert);\n }\n\n requestAnimationFrame(() => {\n if (this.transitionTimer > 0) {\n setTimeout(() => {\n if (this.hideClass !== \"\") {\n addClass(this.hideClass, this.dom.alert);\n }\n\n requestAnimationFrame(() => {\n removeClass(this.transitionClass, this.dom.alert);\n });\n }, this.transitionTimer);\n } else {\n if (this.hideClass !== \"\") {\n addClass(this.hideClass, this.dom.alert);\n }\n\n requestAnimationFrame(() => {\n removeClass(this.transitionClass, this.dom.alert);\n });\n }\n });\n });\n } else {\n // Add the hide class\n if (this.hideClass !== \"\") {\n addClass(this.hideClass, this.dom.alert);\n }\n\n // Remove the show class.\n if (this.showClass !== \"\") {\n removeClass(this.showClass, this.dom.alert);\n }\n }\n\n this._hidden = true;\n\n if (emit) {\n this.dom.alert.dispatchEvent(this._hideEvent);\n }\n }\n\n /**\n * Handles click events throughout the alert for proper use.\n *\n * - Adds a `pointerup` listener to the controller that will hide the alert.\n *\n * @protected\n */\n _handleClick() {\n if (this.dom.controller === null) {\n return;\n }\n\n this.dom.controller.addEventListener(\"pointerup\", () => this.hide());\n }\n\n /**\n * Handles keydown events throughout the alert for proper use.\n *\n * This method exists to assist the _handleKeyup method.\n *\n * - Adds a `keydown` listener to the controller (if it exists).\n * - Blocks propagation on \"Space\" and \"Enter\" keys.\n */\n _handleKeydown() {\n if (this.dom.controller === null) {\n return;\n }\n\n this.dom.controller.addEventListener(\"keydown\", (event) => {\n const key = keyPress(event);\n\n // Prevent default behavior for space and enter keys.\n if (key === \"Space\" || key === \"Enter\") {\n preventEvent(event);\n }\n });\n }\n\n /**\n * Handles keyup events throughout the alert for proper use.\n *\n * - Adds a `keyup` listener to the controller (if it exists).\n * - Hides the alert when the user hits \"Space\" or \"Enter\".\n */\n _handleKeyup() {\n if (this.dom.controller === null) {\n return;\n }\n\n this.dom.controller.addEventListener(\"keyup\", (event) => {\n const key = keyPress(event);\n\n if (key === \"Space\" || key === \"Enter\") {\n this.hide();\n }\n });\n }\n}\n\nexport default Alert;\n","/**\n * Mark DOM elements as processed to prevent multiple initializations.\n *\n * @module @drupal/once\n *\n * @example <!-- Use as a module -->\n * <script type=\"module\">\n * import once from 'https://unpkg.com/@drupal/once/src/once.js';\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n *\n * @example <!-- Use as a regular script -->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n * @example <!-- Using a single element as input-->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * // once methods always return an array, to simplify the use with a single\n * // element use destructuring or the shift method.\n * const [myElement] = once('my-once-id', document.body);\n * const myElement = once('my-once-id', document.body).shift();\n * </script>\n */\n\n/**\n * Illegal spaces in ids.\n *\n * @private\n *\n * @type {RegExp}\n */\nconst wsRE = /[\\11\\12\\14\\15\\40]+/;\n\n/**\n * Name of the HTML attribute containing an element's once ids.\n *\n * @private\n *\n * @type {string}\n */\nconst attrName = 'data-once';\n\n/**\n * Shortcut to access the html element.\n *\n * @private\n *\n * @type {HTMLElement}\n */\nconst doc = document;\n\n/**\n * Helper to access element attributes.\n *\n * @private\n *\n * @param {Element} element\n * The Element to access the data-once attribute from.\n * @param {string} op\n * The action to take on the element.\n * @param {string} [value]\n * Optional value for setAttribute.\n *\n * @return {string|undefined|null|boolean}\n * Result of the attribute method.\n */\nfunction attr(element, op, value) {\n return element[`${op}Attribute`](attrName, value);\n}\n\n/**\n * Return the attribute selector.\n *\n * @private\n *\n * @param {string} id\n * The id passed by a call to a once() function.\n *\n * @return {string}\n * The full CSS attribute selector.\n *\n * @throws {TypeError|RangeError}\n */\nfunction attrSelector(id) {\n // Verify the validity of the once id.\n if (typeof id !== 'string') {\n throw new TypeError('once ID must be a string');\n }\n if (id === '' || wsRE.test(id)) {\n throw new RangeError('once ID must not be empty or contain spaces');\n }\n // The id is valid, return the full CSS selector.\n return `[${attrName}~=\"${id}\"]`;\n}\n\n/**\n * Verifies that an item is an instance of Element.\n *\n * This function is used during filtering to ensure only DOM elements are\n * processed. once() makes use of get/setAttribute, which are methods\n * inherited from the Element object, so only of Element can be used.\n *\n * @private\n *\n * @param {*} itemToCheck\n * The item to check.\n *\n * @return {boolean}\n * True if the item is an instance of Element\n *\n * @throws {TypeError}\n */\nfunction checkElement(itemToCheck) {\n if (!(itemToCheck instanceof Element)) {\n throw new TypeError('The element must be an instance of Element');\n }\n return true;\n}\n\n/**\n * Process arguments, query the DOM if necessary.\n *\n * @private\n *\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array with the processed Id and the list of elements to process.\n */\nfunction getElements(selector, context = doc) {\n // Assume selector is an array-like value.\n let elements = selector;\n\n // If selector is null it is most likely because of a call to querySelector\n // that didn't return a result.\n if (selector === null) {\n elements = [];\n }\n // The selector is undefined, error out.\n else if (!selector) {\n throw new TypeError('Selector must not be empty');\n }\n // Context doesn't implement querySelectorAll, error out.\n else if (\n !(\n context instanceof Document ||\n context instanceof DocumentFragment ||\n context instanceof Element\n )\n ) {\n throw new TypeError(\n 'Context must be an object of type \"Document\", \"DocumentFragment\", or \"Element\".',\n );\n }\n // This is a selector, query the elements.\n else if (typeof selector === 'string') {\n elements = context.querySelectorAll(selector);\n }\n // This is a single element.\n else if (selector instanceof Element) {\n elements = [selector];\n }\n\n // Make sure an array is returned and not a NodeList or an Array-like object.\n return Array.prototype.slice.call(elements);\n}\n\n/**\n * A helper for applying DOM changes to a filtered set of elements.\n *\n * This makes it possible to filter items that are not instances of Element,\n * then modify their DOM attributes in a single array traversal.\n *\n * @private\n *\n * @param {string} selector\n * A CSS selector to check against to each element in the array.\n * @param {Array.<Element>} elements\n * A NodeList or array of elements passed by a call to a once() function.\n * @param {function} [apply]\n * An optional function to apply on all matched elements.\n *\n * @return {Array.<Element>}\n * The array of elements that match the CSS selector.\n */\nfunction filterAndModify(selector, elements, apply) {\n return elements.filter((element) => {\n const selected = checkElement(element) && element.matches(selector);\n if (selected && apply) {\n apply(element);\n }\n return selected;\n });\n}\n\n/**\n * Add or remove an item from a list of once values.\n *\n * This function removes duplicates while adding or removing a once id in a\n * single array traversal.\n *\n * @private\n *\n * @param {Element} element\n * A space separated string of once ids from a data-drupal-once attribute.\n * @param {string} [add]\n * The once id to add to the list of values.\n * @param {string} [remove]\n * The once id to remove from the list of values.\n *\n * @return {undefined}\n * Nothing to return this is a callback in a foreach.\n */\nfunction updateAttribute(element, { add, remove }) {\n const result = [];\n if (attr(element, 'has')) {\n attr(element, 'get')\n .trim()\n .split(wsRE)\n .forEach((item) => {\n if (result.indexOf(item) < 0 && item !== remove) {\n result.push(item);\n }\n });\n }\n if (add) {\n result.push(add);\n }\n const attribute = result.join(' ');\n attr(element, attribute === '' ? 'remove' : 'set', attribute);\n}\n\n/**\n * Ensures a JavaScript callback is only executed once on a set of elements.\n *\n * Filters a NodeList or array of elements, removing those already processed\n * by a callback with a given id.\n * This method adds a `data-once` attribute on DOM elements. The value of\n * this attribute identifies if a given callback has been executed on that\n * element.\n *\n * @global\n *\n * @example <caption>Basic usage</caption>\n * const elements = once('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once('my-once-id', document.querySelector('#some-id'));\n * @example <caption>Using a single element</caption>\n * // Once always returns an array, even when passing a single element. Some\n * // forms that can be used to keep code readable.\n * // Destructuring:\n * const [myElement] = once('my-once-id', document.body);\n * // By changing the resulting array, es5 compatible.\n * const myElement = once('my-once-id', document.body).shift();\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array of elements that have not yet been processed by a once call\n * with a given id.\n */\nfunction once(id, selector, context) {\n return filterAndModify(\n `:not(${attrSelector(id)})`,\n getElements(selector, context),\n (element) => updateAttribute(element, { add: id }),\n );\n}\n\n/**\n * Removes a once id from an element's data-drupal-once attribute value.\n *\n * If a once id is removed from an element's data-drupal-once attribute value,\n * the JavaScript callback associated with that id can be executed on that\n * element again.\n *\n * @method once.remove\n *\n * @example <caption>Basic usage</caption>\n * const elements = once.remove('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.remove('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.remove('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.remove('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.remove('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.remove('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of a once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that had been processed by the provided id,\n * and are now able to be processed again.\n */\nonce.remove = (id, selector, context) => {\n return filterAndModify(\n attrSelector(id),\n getElements(selector, context),\n (element) => updateAttribute(element, { remove: id }),\n );\n};\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Behaves like {@link once} and {@link once.remove} without changing the DOM.\n * To select all DOM nodes processed by a given id, use {@link once.find}.\n *\n * @method once.filter\n *\n * @example <caption>Basic usage</caption>\n * const filteredElements = once.filter('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.filter('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.filter('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.filter('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.filter('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.filter('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.filter = (id, selector, context) =>\n filterAndModify(attrSelector(id), getElements(selector, context));\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Query the 'context' element for elements that already have the\n * corresponding once id value.\n *\n * @method once.find\n *\n * @example <caption>Basic usage</caption>\n * const oncedElements = once.find('my-once-id');\n * @example <caption>Input parameters accepted</caption>\n * // Call without parameters, return all elements with a `data-once` attribute.\n * once.find();\n * // Call without a context.\n * once.find('my-once-id');\n * // Call with a context.\n * once.find('my-once-id', document.head);\n *\n * @param {string} [id]\n * The id of the once call.\n * @param {Document|DocumentFragment|Element} [context=document]\n * Scope of the search for matching elements.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.find = (id, context) =>\n getElements(!id ? `[${attrName}]` : attrSelector(id), context);\n\nexport default once;\n","import Alert from \"./Alert.js\";\nimport once from \"@drupal/once\";\n\nconst generate = (\n options = {},\n context = document,\n alertSelector = \".alert\"\n) => {\n once(\"graupl-alert-generator\", alertSelector, context).forEach(\n (alertElement) => {\n const alertOptions = alertElement.dataset.grauplAlertOptions\n ? JSON.parse(\n alertElement.dataset.grauplAlertOptions.replace(/'/g, '\"')\n ) || {}\n : {};\n\n new Alert({\n alertElement,\n controllerElement:\n alertElement.querySelector(\".alert-dismisser\") || null,\n initialize: true,\n ...options,\n ...alertOptions,\n });\n }\n );\n};\n\nexport default generate;\n"],"x_google_ignoreList":[5],"mappings":"+BAeA,SAAgBA,EAAgBC,EAAaC,EAAU,CACrD,GAAI,CACF,GAAI,OAAOA,GAAa,SAAU,CAChC,MAAMC,EAAe,OAAOD,EAE5B,MAAM,IAAIE,UACR,qEAAqED,CAAAA,UAAY,EAIrF,UAAWE,KAAOH,EAChB,GAAI,EAAEA,EAASG,CAAAA,YAAgBJ,GAAc,CAC3C,MAAMK,EAAc,OAAOJ,EAASG,CAAAA,EACpC,MAAM,IAAID,UACR,GAAGC,CAAAA,2BAA8BJ,EAAYM,IAAAA,MAAUD,CAAAA,UAAW,EAKxE,MAAO,CACLE,OAAQ,GACRC,MAAO,YAEFA,EAAO,CACd,MAAO,CACLD,OAAQ,GACRC,MAAAA,IAoBN,SAAgBC,EAAYC,EAAMC,EAAQ,CACxC,GAAI,CACF,GAAI,OAAOA,GAAW,SAAU,CAC9B,MAAMC,EAAa,OAAOD,EAE1B,MAAM,IAAIR,UACR,+DAA+DS,CAAAA,UAAU,EAI7E,UAAWR,KAAOO,EAAQ,CACxB,MAAME,EAAY,OAAOF,EAAOP,CAAAA,EAEhC,GAAIS,IAAcH,EAChB,MAAM,IAAIP,UAAU,GAAGC,CAAAA,cAAiBM,CAAAA,MAAUG,CAAAA,UAAS,EAI/D,MAAO,CACLN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EACVC,EAAUC,SACVC,EAAgB,WACb,CACHL,EAAK,yBAA0BK,EAAeF,CAAAA,EAASG,QACpDC,GAAiB,CAChB,MAAMC,EAAeD,EAAaE,QAAQC,mBACtCC,KAAKC,MACHL,EAAaE,QAAQC,mBAAmBG,QAAQ,KAAM,GAAA,CACxD,GAAK,CAAA,EACL,CAAA,EAEJ,IAAId,EAAM,CACRQ,aAAAA,EACAO,kBACEP,EAAaQ,cAAc,kBAAA,GAAuB,KACpDC,WAAY,GACZ,GAAGd,EACH,GAAGM,EACJ"}
|
|
1
|
+
{"version":3,"file":"alert.iife.js","names":["isValidInstance","constructor","elements","elementsType","TypeError","key","elementType","name","status","error","isValidType","type","values","valuesType","valueType","isQuerySelector","Error","document","querySelector","isValidClassList","Array","isArray","forEach","value","obj","isValidHoverType","validTypes","includes","join","isTag","tagName","HTMLElement","tag","toLowerCase","check","isValidState","validStates","isValidEvent","validEvents","addClass","className","element","length","classList","add","removeClass","remove","selectAllFocusableElements","context","document","fn","querySelector","elements","Array","from","querySelectorAll","tabbableElements","filter","check","getAttribute","selectFirstFocusableElement","selectLastFocusableElement","selectNextFocusableElement","index","indexOf","selectPreviousFocusableElement","keyPress","event","key","keyCode","keys","Enter","Space","Escape","ArrowUp","ArrowRight","ArrowDown","ArrowLeft","Home","End","Tab","Object","find","preventEvent","preventDefault","stopPropagation","TransactionalValue","constructor","initialValue","options","_equals","equals","Object","is","_current","_committed","value","val","committed","isDirty","commit","reset","update","fn","isValidType","initializeStorage","type","window","Graupl","getStorage","setStorage","data","clearStorage","pushToStorage","key","value","getFromStorage","removeFromStorage","isValidInstance","isValidType","isValidClassList","isQuerySelector","isValidState","isValidEvent","storage","Component","_dom","_protectedDOMElements","_selectors","_elements","_classes","initialize","_durations","_delays","_focusState","_currentEvent","_breakpoint","_mediaQueryString","_mediaQueryList","_mediaQueryListEventCallback","event","matches","_intervals","_timeouts","_listeners","_events","_prefix","_key","_storageKey","_id","_valid","_errors","constructor","prefix","key","initializeClass","_validate","Error","name","errors","join","_generateKey","error","console","init","dom","selectors","elements","classes","durations","delays","intervals","timeouts","listeners","events","value","focusState","currentEvent","breakpoint","mediaQuery","Object","keys","length","domElements","domKey","Array","isArray","forEach","element","index","domChecks","HTMLElement","push","message","querySelectors","querySelector","querySelectorChecks","className","classListChecks","status","durationName","durationChecks","delayName","delayChecks","keyCheck","prefixCheck","regenerate","Math","random","toString","replace","substring","_setIds","_setAriaAttributes","_setCustomProps","_setDOMElementType","elementType","context","overwrite","strict","includes","from","querySelectorAll","filteredElements","filter","item","parentElement","_resetDOMElementType","_setDOMElements","_createChildElements","_handleMediaMatch","_breakpointWidth","window","matchMedia","addEventListener","_handleFocus","_handleClick","_handleKeydown","_handleKeyup","_store","initializeStorage","pushToStorage","_unstore","removeFromStorage","_setInterval","callback","delay","scope","_clearInterval","setInterval","clearInterval","_setTimeout","_clearTimeout","setTimeout","clearTimeout","_dispatchEvent","eventType","dispatchEvent","_addEventListener","type","listener","options","_removeEventListener","removeEventListener","indexOf","splice","_removeEventListeners","dispose","isValidClassList","isValidType","addClass","removeClass","keyPress","preventEvent","TransactionalValue","Component","Alert","_dom","alert","controller","_protectedDOMElements","_classes","show","hide","transition","initialize","_durations","_hidden","_events","CustomEvent","bubbles","detail","_storageKey","constructor","alertElement","controllerElement","showClass","hideClass","transitionClass","transitionDuration","showDuration","hideDuration","isHidden","prefix","key","initializeClass","value","commit","dom","_setIds","_setCustomProps","_handleClick","_handleKeydown","_handleKeyup","_store","_conseal","emit","error","console","requestAnimationFrame","_validate","booleans","booleanChecks","_errors","push","message","_valid","id","_id","_reveal","_setTimeout","removeAttribute","_dispatchEvent","setAttribute","style","setProperty","_addEventListener","event","force","preserveState","focusState","wsRE","attrName","doc","document","attr","element","op","value","attrSelector","id","TypeError","test","RangeError","checkElement","itemToCheck","Element","getElements","selector","context","elements","Document","DocumentFragment","querySelectorAll","Array","prototype","slice","call","filterAndModify","apply","filter","selected","matches","updateAttribute","add","remove","result","trim","split","forEach","item","indexOf","push","attribute","join","once","find","Alert","once","generate","options","context","document","alertSelector","forEach","alertElement","alertOptions","dataset","grauplAlertOptions","JSON","parse","replace","controllerElement","querySelector","initialize"],"sources":["../../../packages/core/src/js/validate.js","../../../packages/core/src/js/domHelpers.js","../../../packages/core/src/js/eventHandlers.js","../../../packages/core/src/js/TransactionalValue.js","../../../packages/core/src/js/storage.js","../../../packages/core/src/js/Component.js","../../../packages/core/src/js/alert/Alert.js","../../../node_modules/@drupal/once/src/once.js","../../../packages/core/src/js/alert/generator.js"],"sourcesContent":["/**\n * Check to see if the provided elements have a specific constructor.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking instanceof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {object} constructor - The constructor to check for.\n * @param {object} elements - The element(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidInstance(constructor, elements) {\n try {\n if (typeof elements !== \"object\") {\n const elementsType = typeof elements;\n\n throw new TypeError(\n `Elements given to isValidInstance() must be inside of an object. \"${elementsType}\" given.`\n );\n }\n\n for (const key in elements) {\n if (!(elements[key] instanceof constructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `${key} must be an instance of ${constructor.name}. \"${elementType}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are of a specific type.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * This is essentially just a wrapper function around checking typeof with\n * more descriptive error message to help debugging.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {string} type - The type to check for.\n * @param {object} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidType(type, values) {\n try {\n if (typeof values !== \"object\") {\n const valuesType = typeof values;\n\n throw new TypeError(\n `Values given to isValidType() must be inside of an object. \"${valuesType}\" given.`\n );\n }\n\n for (const key in values) {\n const valueType = typeof values[key];\n\n if (valueType !== type) {\n throw new TypeError(`${key} must be a ${type}. \"${valueType}\" given.`);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided values are valid query selectors.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isQuerySelector(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isQuerySelector() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n try {\n if (values[key] === null) {\n throw new Error();\n }\n\n document.querySelector(values[key]);\n } catch {\n throw new TypeError(\n `${key} must be a valid query selector. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided value is either a string or an array of strings.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string, string[]>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidClassList(values) {\n try {\n if (typeof values !== \"object\" || Array.isArray(values)) {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidClassList() must be inside of an object. \"${type}\" given.`\n );\n }\n\n for (const key in values) {\n const type = typeof values[key];\n\n if (type !== \"string\") {\n if (Array.isArray(values[key])) {\n values[key].forEach((value) => {\n if (typeof value !== \"string\") {\n throw new TypeError(\n `${key} must be a string or an array of strings. An array containing non-strings given.`\n );\n }\n });\n } else {\n throw new TypeError(\n `${key} must be a string or an array of strings. \"${type}\" given.`\n );\n }\n } else {\n const obj = {};\n obj[key] = values[key];\n\n isQuerySelector(obj);\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid hover types.\n *\n * Available types are: `\"off\"`, `\"on\"`, and `\"dynamic\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidHoverType(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidHoverType() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validTypes = [\"off\", \"on\", \"dynamic\"];\n\n for (const key in values) {\n if (!validTypes.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validTypes.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Checks to see if the provided elements are using a specific tag.\n *\n * The elements must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `true` if the check is successful.\n *\n * @param {string} tagName - The name of the tag.\n * @param {Object<HTMLElement>} elements - The element(s) to check.\n * @return {boolean} - The result of the check.\n */\nexport function isTag(tagName, elements) {\n if (\n isValidType(\"string\", { tagName }).status &&\n isValidInstance(HTMLElement, elements).status\n ) {\n const tag = tagName.toLowerCase();\n let check = true;\n\n for (const key in elements) {\n if (elements[key].tagName.toLowerCase() !== tag) check = false;\n }\n\n return check;\n } else {\n return false;\n }\n}\n\n/**\n * Check to see if the provided values are valid focus states for a menu.\n *\n * Available states are: `\"none\"`, `\"self\"`, and `\"child\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidState(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidState() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validStates = [\"none\", \"self\", \"child\"];\n\n for (const key in values) {\n if (!validStates.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validStates.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n\n/**\n * Check to see if the provided values are valid event types for a menu.\n *\n * Available events are: `\"none\"`, `\"mouse\"`, `\"keyboard\"`, and `\"character\"`.\n *\n * The values must be provided inside of an object\n * so the variable name can be retrieved in case of errors.\n *\n * Will return `{ status: true }` if the check is successful.\n *\n * @param {Object<string>} values - The value(s) to check.\n * @return {Object<boolean, string>} - The result of the check.\n */\nexport function isValidEvent(values) {\n try {\n if (typeof values !== \"object\") {\n const type = typeof values;\n\n throw new TypeError(\n `Values given to isValidEvent() must be inside of an object. \"${type}\" given.`\n );\n }\n\n const validEvents = [\"none\", \"mouse\", \"keyboard\", \"character\"];\n\n for (const key in values) {\n if (!validEvents.includes(values[key])) {\n throw new TypeError(\n `${key} must be one of the following values: ${validEvents.join(\n \", \"\n )}. \"${values[key]}\" given.`\n );\n }\n }\n\n return {\n status: true,\n error: null,\n };\n } catch (error) {\n return {\n status: false,\n error,\n };\n }\n}\n","/**\n * Add a class or array of classes to an element.\n *\n * @param {string|string[]} className - The class or classes to add.\n * @param {HTMLElement} element - The element to add the class to.\n */\nexport function addClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.add(className);\n } else {\n element.classList.add(...className);\n }\n}\n\n/**\n * Remove a class or array of classes from an element.\n *\n * @param {string|string[]} className - The class or classes to remove.\n * @param {HTMLElement} element - The element to remove the class from.\n */\nexport function removeClass(className, element) {\n // Gracefully handle empty strings or arrays.\n if (className === \"\" || className.length === 0) {\n return;\n }\n\n if (typeof className === \"string\") {\n element.classList.remove(className);\n } else {\n element.classList.remove(...className);\n }\n}\n\n/**\n * Select all focusable elements within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement[]} - An array of focusable elements.\n */\nexport function selectAllFocusableElements(context = document, fn = null) {\n const querySelector =\n \"a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),[tabindex]\";\n const elements = Array.from(context.querySelectorAll(querySelector));\n\n const tabbableElements = elements.filter((element) => {\n let check = true;\n\n if (element.getAttribute(\"tabindex\") === \"-1\") check = false;\n\n return check;\n });\n\n if (fn !== null) {\n return tabbableElements.filter(fn);\n } else {\n return tabbableElements;\n }\n}\n\n/**\n * Select the first focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The first focusable element or false if none found.\n */\nexport function selectFirstFocusableElement(context = document, fn = null) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n\n return tabbableElements[0] || false;\n}\n\n/**\n * Select the last focusable element within a given context.\n *\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The last focusable element or false if none found.\n */\nexport function selectLastFocusableElement(context = document, fn = null) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n\n return tabbableElements[tabbableElements.length - 1] || false;\n}\n\n/**\n * Select the next focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The next focusable element or false if none found.\n */\nexport function selectNextFocusableElement(\n element,\n context = document,\n fn = null\n) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n const index = tabbableElements.indexOf(element);\n\n return index === tabbableElements.length - 1\n ? false\n : tabbableElements[index + 1];\n}\n\n/**\n * Select the previous focusable element relative to the given element within a context.\n *\n * @param {HTMLElement} element - The reference element.\n * @param {HTMLElement} [context = document] - The context in which to search for focusable elements.\n * @param {?function(HTMLElement): boolean} [fn = null] - An optional addition filter function to process out focusable elements.\n * @return {HTMLElement|boolean} - The previous focusable element or false if none found.\n */\nexport function selectPreviousFocusableElement(\n element,\n context = document,\n fn = null\n) {\n const tabbableElements = selectAllFocusableElements(context, fn);\n const index = tabbableElements.indexOf(element);\n\n return index === 0 ? false : tabbableElements[index - 1];\n}\n","/**\n * Retrieves the pressed key from an event.\n *\n * @param {KeyboardEvent} event - The keyboard event.\n * @return {string} - The name of the key or an empty string.\n */\nexport function keyPress(event) {\n try {\n // Use event.key or event.keyCode to support older browsers.\n const key = event.key || event.keyCode;\n const keys = {\n Enter: key === \"Enter\" || key === 13,\n Space: key === \" \" || key === \"Spacebar\" || key === 32,\n Escape: key === \"Escape\" || key === \"Esc\" || key === 27,\n ArrowUp: key === \"ArrowUp\" || key === \"Up\" || key === 38,\n ArrowRight: key === \"ArrowRight\" || key === \"Right\" || key === 39,\n ArrowDown: key === \"ArrowDown\" || key === \"Down\" || key === 40,\n ArrowLeft: key === \"ArrowLeft\" || key === \"Left\" || key === 37,\n Home: key === \"Home\" || key === 36,\n End: key === \"End\" || key === 35,\n Tab: key === \"Tab\" || key === 9,\n };\n\n return Object.keys(keys).find((key) => keys[key] === true) || \"\";\n } catch {\n // Return an empty string if something goes wrong.\n return \"\";\n }\n}\n\n/**\n * Stops an event from taking action.\n *\n * @param {Event} event - The event.\n */\nexport function preventEvent(event) {\n event.preventDefault();\n event.stopPropagation();\n}\n","/**\n * A utility class that maintains a \"current\" value and a \"committed\" value.\n *\n * Useful when you need to:\n * - Track in-progress edits and revert to the last saved state.\n * - Compare pending and committed states.\n * - Know if a value has changed since last commit.\n *\n * @example\n * // Managing a form field\n * const username = new TransactionalValue(\"Nick\");\n * username.value = \"NickDJM\";\n * if (username.isDirty) {\n * console.log(\"Unsaved changes detected\");\n * username.commit(); // saves the new value\n * }\n *\n * @example\n * // Reverting edits\n * const counter = new TransactionalValue(10);\n * counter.value = 15;\n * counter.reset(); // reverts to 10\n */\nexport class TransactionalValue {\n /**\n * Creates a new TransactionalValue instance.\n *\n * @param {*} initialValue - The starting (and initially committed) value.\n * @param {{ equals?: function(*, *): boolean }} [options] - Optional config.\n * @param {function(*, *): boolean} [options.equals] - Custom equality comparator. Defaults to `Object.is`.\n */\n constructor(initialValue, options = {}) {\n /**\n * A comparator function used to check equality between\n * the current and committed values.\n *\n * @private\n *\n * @type {function(*, *): boolean}\n */\n this._equals = options.equals || Object.is;\n\n /**\n * The current, editable value.\n *\n * @private\n *\n * @type {*}\n */\n this._current = initialValue;\n\n /**\n * The last committed (baseline) value.\n *\n * @private\n *\n * @type {*}\n */\n this._committed = initialValue;\n }\n\n /**\n * Gets the current editable value.\n *\n * @return {*} The current value.\n *\n * @see _current\n */\n get value() {\n return this._current;\n }\n\n /**\n * Sets the current editable value.\n *\n * @param {*} val - The new value.\n */\n set value(val) {\n this._current = val;\n }\n\n /**\n * Gets the last committed (baseline) value.\n *\n * @readonly\n *\n * @return {*} The last committed value.\n *\n * @see _committed\n */\n get committed() {\n return this._committed;\n }\n\n /**\n * Checks whether the current value differs from the committed one.\n *\n * @readonly\n *\n * @return {boolean} `true` if current and committed values differ.\n */\n get isDirty() {\n return !this._equals(this._current, this._committed);\n }\n\n /**\n * Commits the current value, setting it as the new baseline.\n *\n * @return {TransactionalValue} The current instance.\n */\n commit() {\n this._committed = this._current;\n return this;\n }\n\n /**\n * Resets the current value to the committed baseline.\n *\n * @return {TransactionalValue} The current instance.\n */\n reset() {\n this._current = this._committed;\n return this;\n }\n\n /**\n * Applies a functional update to the current value.\n *\n * @param {function(*): *} fn - A function that receives the previous value and returns the new one.\n * @return {TransactionalValue} The current instance.\n *\n * @example\n * const t = new TransactionalValue(1);\n * t.update(n => n + 1); // 2\n */\n update(fn) {\n this._current = fn(this._current);\n return this;\n }\n}\n","/**\n * @file\n * Provides a system to get and store Graupl data in the browser.\n */\n\nimport { isValidType } from \"./validate.js\";\n\n/**\n * Initializes the storage system.\n *\n * @param {?string} [type = null] - The type of storage to initialize.\n */\nexport function initializeStorage(type = null) {\n window.Graupl = window.Graupl || {};\n\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = window.Graupl[type] || {};\n }\n}\n\n/**\n * Get the storage object.\n *\n * @param {?string} type - The type of storage to get.\n * @return {object} - The storage object.\n */\nexport function getStorage(type = null) {\n if (isValidType(\"string\", { type })) {\n return window.Graupl[type];\n }\n\n return window.Graupl;\n}\n\n/**\n * Set the storage object of a given type.\n *\n * @param {string} type - The type of storage to set.\n * @param {object} data - The data to set.\n */\nexport function setStorage(type, data = {}) {\n if (isValidType(\"string\", { type }) && isValidType(\"object\", { data })) {\n window.Graupl[type] = data;\n }\n}\n\n/**\n * Clear the storage object of a given type.\n *\n * @param {string} type - The type of storage to clear.\n */\nexport function clearStorage(type) {\n if (isValidType(\"string\", { type })) {\n window.Graupl[type] = {};\n }\n}\n\n/**\n * Push a value to the storage object.\n *\n * @param {string} type - The type of storage to push to.\n * @param {string} key - The key to use for the value.\n * @param {*} value - The value to store.\n */\nexport function pushToStorage(type, key, value) {\n if (isValidType(\"string\", { type, key })) {\n window.Graupl[type][key] = value;\n }\n}\n\n/**\n * Get a value from the storage object.\n *\n * @param {string }type - The type of storage to get from.\n * @param {string }key - The key to get the value from.\n * @return {*} - The value from the storage object.\n */\nexport function getFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n return window.Graupl[type][key];\n }\n\n return null;\n}\n\n/**\n * Remove a value from the storage object.\n *\n * @param {string} type - The type of storage to remove from.\n * @param {string} key - The key to remove the value from.\n */\nexport function removeFromStorage(type, key) {\n if (isValidType(\"string\", { type, key })) {\n delete window.Graupl[type][key];\n }\n}\n\nexport default {\n initializeStorage,\n getStorage,\n setStorage,\n clearStorage,\n pushToStorage,\n getFromStorage,\n removeFromStorage,\n};\n","/**\n * @file\n * A generic component class.\n */\n\nimport {\n isValidInstance,\n isValidType,\n isValidClassList,\n isQuerySelector,\n isValidState,\n isValidEvent,\n} from \"./validate.js\";\nimport storage from \"./storage.js\";\n\nclass Component {\n /**\n * The DOM elements within the component.\n *\n * @protected\n *\n * @type {Object<HTMLElement, HTMLElement[]>}\n */\n _dom = {};\n\n /**\n * The DOM elements within the component that cannot be reset or generated by the component itself.\n *\n * @protected\n *\n * @type {string[]}\n */\n _protectedDOMElements = [];\n\n /**\n * The query selectors used by the component.\n *\n * @protected\n *\n * @type {Object<string>}\n */\n _selectors = {};\n\n /**\n * The instantiated elements within the component.\n *\n * @protected\n *\n * @type {object}\n */\n _elements = {};\n\n /**\n * The CSS classes to apply when the component is in various states.\n *\n * @protected\n *\n * @type {Object<string, string[]>}\n *\n * @\n */\n _classes = {\n initialize: \"\",\n };\n\n /**\n * The duration times (in milliseconds) for various aspects throughout the component.\n *\n * @protected\n *\n * @type {Object<number>}\n */\n _durations = {};\n\n /**\n * The delay times (in milliseconds) for various aspects throughout the component.\n *\n * @protected\n *\n * @type {Object<number>}\n */\n _delays = {};\n\n /**\n * The current state of the component's focus.\n *\n * @protected\n *\n * @type {string}\n */\n _focusState = \"none\";\n\n /**\n * The last type of event triggered within the component.\n *\n * @protected\n *\n * @type {string}\n */\n _currentEvent = \"none\";\n\n /**\n * The breakoint that the component will call media query list events.\n *\n * @protected\n *\n * @type {string}\n */\n _breakpoint = \"\";\n\n /**\n * The media query to use to trigger media query list events.\n *\n * @type {string}\n */\n _mediaQueryString = \"\";\n\n /**\n * This MediaQueryList for the component.\n *\n * @protected\n *\n * @type {MediaQueryList|null}\n */\n _mediaQueryList = null;\n\n /**\n * A callback for media query list events.\n *\n * @protected\n *\n * @type {Function}\n *\n * @param {MediaQueryListEvent} event - The event.\n */\n _mediaQueryListEventCallback = (event) => {\n // Add functionality to handle media matches.\n if (event.matches) {\n // Do something.\n } else {\n // Do something else.\n }\n };\n\n /**\n * Intervals throughout the component.\n *\n * @protected\n *\n * @type {Object<Function>}\n */\n _intervals = {};\n\n /**\n * Timeouts throughout the component.\n *\n * @protected\n *\n * @type {Object<Function>}\n */\n _timeouts = {};\n\n /**\n * Event listeners throughout the component.\n *\n * @protected\n *\n * @type {object[]}\n */\n _listeners = [];\n\n /**\n * Custom events that can be triggered throughout the component.\n *\n * @protected\n *\n * @type {Object<CustomEvent>}\n */\n _events = {};\n\n /**\n * The prefix used for CSS custom properties and attributes.\n *\n * @protected\n *\n * @type {string}\n */\n _prefix = \"graupl-\";\n\n /**\n * The key used to generate IDs throughout the component.\n *\n * @protected\n *\n * @type {string}\n */\n _key = \"\";\n\n /**\n * The key used for storage.\n *\n * @protected\n *\n * @type {string}\n */\n _storageKey = \"components\";\n\n /**\n * The main ID of the component.\n *\n * @protected\n *\n * @type {string}\n */\n _id = \"\";\n\n /**\n * The validity state of the component.\n *\n * @protected\n *\n * @type {boolean}\n */\n _valid = true;\n\n /**\n * The errors found throughout the component.\n *\n * @protected\n *\n * @type {string[]}\n */\n _errors = [];\n\n /**\n * Constructs a new component.\n *\n * @param {object} [options = {}] - The options for generating the component.\n * @param {?string} [options.prefix = graupl-] - The prefix used for CSS custom properties and attributes.\n * @param {?string} [options.key = null] - The key used to generate IDs throughout the component.\n * @param {?(string|string[])} [options.initializeClass = initializing] - The class(es) to apply when the component is initializing.\n */\n constructor({\n prefix = \"graupl-\",\n key = null,\n initializeClass = \"initializing\",\n } = {}) {\n // Set the classes.\n this._classes.initialize = initializeClass || \"\";\n\n // Set the prefix and key.\n this._prefix = prefix || \"\";\n this._key = key || \"\";\n }\n\n /**\n * Initialize the component.\n */\n initialize() {\n try {\n if (!this._validate()) {\n throw new Error(\n `Graupl ${this.constructor.name}: Cannot initialize component. The following errors have been found:\\n - ${this.errors.join(\"\\n - \")}`\n );\n }\n\n this._generateKey();\n } catch (error) {\n console.error(error);\n }\n }\n init() {\n this.initialize();\n }\n\n /**\n * The DOM elements within the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _dom\n */\n get dom() {\n return this._dom;\n }\n\n /**\n * The query selectors used by the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _selectors\n */\n get selectors() {\n return this._selectors;\n }\n\n /**\n * The instantiated elements within the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _elements\n */\n get elements() {\n return this._elements;\n }\n\n /**\n * The CSS classes to apply when the component is in various states.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _classes\n */\n get classes() {\n return this._classes;\n }\n\n /**\n * The duration times (in milliseconds) for various aspects throughout the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _durations\n */\n get durations() {\n return this._durations;\n }\n\n /**\n * The delay times (in milliseconds) for various aspects throughout the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _delays\n */\n get delays() {\n return this._delays;\n }\n\n /**\n * Intervals throughout the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _intervals\n */\n get intervals() {\n return this._intervals;\n }\n\n /**\n * Timeouts throughout the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _timeouts\n */\n get timeouts() {\n return this._timeouts;\n }\n\n /**\n * Event listeners throughout the component.\n *\n * @readonly\n *\n * @type {object[]}\n *\n * @see _listeners\n */\n get listeners() {\n return this._listeners;\n }\n\n /**\n * Custom events that can be triggered throughout the component.\n *\n * @readonly\n *\n * @type {object}\n *\n * @see _events\n */\n get events() {\n return this._events;\n }\n\n /**\n * The class(es) to apply when the component is initializing.\n *\n * @type {string|string[]}\n *\n * @see _classes.initialize\n */\n get initializeClass() {\n return this._classes.initialize;\n }\n\n set initializeClass(value) {\n isValidClassList({ initializeClass: value });\n\n if (this._classes.initialize !== value) {\n this._classes.initialize = value;\n }\n }\n\n /**\n * The current state of the component's focus.\n *\n * @type {string}\n *\n * @see _focusState\n */\n get focusState() {\n return this._focusState;\n }\n\n set focusState(value) {\n isValidState({ focusState: value });\n\n if (this._focusState !== value) {\n this._focusState = value;\n }\n }\n\n /**\n * The last type of event triggered within the component.\n *\n * @type {string}\n *\n * @see _currentEvent\n */\n get currentEvent() {\n return this._currentEvent;\n }\n\n set currentEvent(value) {\n isValidEvent({ currentEvent: value });\n\n if (this._currentEvent !== value) {\n this._currentEvent = value;\n }\n }\n\n /**\n * The breakoint that the component will call media query list events.\n *\n * @type {string}\n *\n * @see _breakpoint\n */\n get breakpoint() {\n return this._breakpoint;\n }\n\n set breakpoint(value) {\n isValidType(\"string\", { breakpoint: value });\n\n if (this._breakpoint !== value) {\n this._breakpoint = value;\n }\n }\n\n /**\n * The media query to use to trigger media query list events.\n *\n * @type {string}\n *\n * @see _mediaQueryString\n */\n get mediaQuery() {\n if (this._mediaQueryString !== \"\") {\n return this._mediaQueryString;\n }\n\n return `(width <= ${this._breakpoint})`;\n }\n\n set mediaQuery(value) {\n isValidType(\"string\", { mediaQuery: value });\n\n if (this._mediaQueryString !== value) {\n this._mediaQueryString = value;\n }\n }\n\n /**\n * The prefix used for CSS custom properties and attributes.\n *\n * @readonly\n *\n * @type {string}\n *\n * @see _prefix\n */\n get prefix() {\n return this._prefix;\n }\n\n /**\n * The key used to generate IDs throughout the component.\n *\n * @readonly\n *\n * @type {string}\n *\n * @see _key\n */\n get key() {\n return this._key;\n }\n\n /**\n * An array to hold error messages.\n *\n * @readonly\n *\n * @type {string[]}\n *\n * @see _errors\n */\n get errors() {\n return this._errors;\n }\n\n /**\n * Validates all aspects of the component to ensure proper functionality.\n *\n * Keys are altered to match the arguments passed in during creation where possible.\n *\n * @protected\n *\n * @return {boolean} - The result of the validation checks.\n */\n _validate() {\n // DOM checks.\n if (Object.keys(this._dom).length > 0) {\n const domElements = {};\n\n // Loop through and add \"Element\" to the end of each key in _dom.\n for (const domKey of Object.keys(this._dom)) {\n // If we're dealing with an array, we need to check each element in the array.\n if (Array.isArray(this._dom[domKey])) {\n this._dom[domKey].forEach((element, index) => {\n domElements[`${domKey}Element[${index}]`] = element;\n });\n }\n\n domElements[`${domKey}Element`] = this._dom[domKey];\n }\n\n // Check the DOM elements.\n const domChecks = isValidInstance(HTMLElement, domElements);\n\n // Handle DOM check failure.\n if (!domChecks) {\n this._errors.push(domChecks.message);\n this._valid = false;\n }\n }\n\n // Query selector checks.\n if (Object.keys(this._selectors).length > 0) {\n const querySelectors = {};\n\n // Loop through and add \"Selector\" to the end of each key in _selectors.\n for (const querySelector of Object.keys(this._selectors)) {\n querySelectors[`${querySelector}Selector`] =\n this._selectors[querySelector];\n }\n\n // Check the query selectors.\n const querySelectorChecks = isQuerySelector(querySelectors);\n\n // Handle query selector check failure.\n if (!querySelectorChecks) {\n this._errors.push(querySelectorChecks.message);\n this._valid = false;\n }\n }\n\n // Class list checks.\n if (Object.keys(this._classes).length > 0) {\n const classes = {};\n\n // Loop through and add \"Class\" to the end of each key in _classes.\n for (const className of Object.keys(this._classes)) {\n if (this._classes[className] === \"\") {\n continue;\n }\n\n classes[`${className}Class`] = this._classes[className];\n }\n\n // Check the class lists.\n const classListChecks = isValidClassList(classes);\n\n // Handle class list check failure.\n if (!classListChecks.status) {\n this._errors.push(classListChecks.error.message);\n this._valid = false;\n }\n }\n\n // Duration checks.\n if (Object.keys(this._durations).length > 0) {\n const durations = {};\n\n // Loop through and add \"Duration\" to the end of each key in _durations.\n for (const durationName of Object.keys(this._durations)) {\n durations[`${durationName}Duration`] = this._durations[durationName];\n }\n\n // Check the durations.\n const durationChecks = isValidType(\"number\", durations);\n\n // Handle duration check failure.\n if (!durationChecks.status) {\n this._errors.push(durationChecks.error.message);\n this._valid = false;\n }\n }\n\n // Delay checks.\n if (Object.keys(this.delays).length > 0) {\n const delays = {};\n\n // Loop through and add \"Delay\" to the end of each key in delays.\n for (const delayName of Object.keys(this.delays)) {\n delays[`${delayName}Delay`] = this.delays[delayName];\n }\n\n // Check the delays.\n const delayChecks = isValidType(\"number\", delays);\n\n // Handle delay check failure.\n if (!delayChecks.status) {\n this._errors.push(delayChecks.error.message);\n this._valid = false;\n }\n }\n\n // Key check.\n if (this._key !== \"\") {\n // Check the key.\n const keyCheck = isValidType(\"string\", { key: this._key });\n\n // Handle key check failure.\n if (!keyCheck.status) {\n this._errors.push(keyCheck.error.message);\n this._valid = false;\n }\n }\n\n // Prefix check.\n if (this._prefix !== \"\") {\n const prefixCheck = isValidType(\"string\", { prefix: this._prefix });\n\n if (!prefixCheck.status) {\n this._errors.push(prefixCheck.error.message);\n this._valid = false;\n }\n }\n\n return this._valid;\n }\n\n /**\n * Generates a key for the component.\n *\n * @param {boolean} [regenerate = false] - A flag to determine if the key should be regenerated.\n */\n _generateKey(regenerate = false) {\n if (this._key === \"\" || regenerate) {\n this._key = Math.random()\n .toString(36)\n .replace(/[^a-z]+/g, \"\")\n .substring(0, 10);\n }\n }\n\n /**\n * Sets IDs throughout the component.\n */\n _setIds() {\n // Add functionality to set IDs throughout the component.\n }\n\n /**\n * Sets ARIA attributes throughout the component.\n */\n _setAriaAttributes() {\n // Add functionality to set attributes throughout the component.\n }\n\n /**\n * Sets custom props throughout the component.\n */\n _setCustomProps() {\n // Add functionality to set custom props throughout the component.\n }\n\n /**\n * Sets DOM elements throughout the component.\n *\n * Elements listed in _protectedDOMElements cannot be set using this method.\n *\n * @protected\n *\n * @param {string} elementType - The type of element to populate.\n * @param {Object<HTMLElement,boolean>} [options = {}] - The options for setting the DOM element type.\n * @param {HTMLElement} [options.context] - The element used as the base context for the querySelector.\n * @param {boolean} [options.overwrite = true] - A flag to set if the existing elements will be overwritten.\n * @param {boolean} [options.strict = true] - A flag to set if the elements must be direct children of the base.\n */\n _setDOMElementType(\n elementType,\n { context, overwrite = true, strict = true } = {}\n ) {\n // Make sure the element type is valid.\n if (typeof this.selectors[elementType] !== \"string\") {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" is not a valid element type.`\n );\n }\n\n // Make sure the element type can actually be set through this method.\n if (this._protectedDOMElements.includes(elementType)) {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" element cannot be set through _setDOMElementType because it is a protected element.`\n );\n }\n\n // Make sure the context element is actually an HTMLELement.\n isValidInstance(HTMLElement, { context });\n\n // Get the all elements matching the selector in the context.\n const domElements = Array.from(\n context.querySelectorAll(this.selectors[elementType])\n );\n\n // Filter the elements so if `strict` is true, only direct children of the context are kept.\n const filteredElements = domElements.filter((item) =>\n strict ? item.parentElement === context : true\n );\n\n if (Array.isArray(this._dom[elementType])) {\n if (overwrite) {\n this._dom[elementType] = filteredElements;\n } else {\n this._dom[elementType] = [\n ...this._dom[elementType],\n ...filteredElements,\n ];\n }\n } else {\n this._dom[elementType] = filteredElements[0] || null;\n }\n }\n\n /**\n * Resets DOM elements throughout the component.\n *\n * Elements listed in _protectedDOMElements cannot be reset using this method.\n *\n * @protected\n *\n * @param {string} elementType - The type of element to clear.\n */\n _resetDOMElementType(elementType) {\n // Make sure the element type is valid.\n if (typeof this.selectors[elementType] !== \"string\") {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" is not a valid element type.`\n );\n }\n\n // Make sure the element type can actually be reset through this method.\n if (this._protectedDOMElements.includes(elementType)) {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${elementType}\" element cannot be reset through _resetDOMElementType because it is a protected element.`\n );\n }\n\n if (Array.isArray(this._dom[elementType])) {\n this._dom[elementType] = [];\n } else {\n this._dom[elementType] = null;\n }\n }\n\n /**\n * Sets all DOM elements throughout the component.\n *\n * Utilizes _setDOMElementType and _resetDOMElementType.\n *\n * @protected\n */\n _setDOMElements() {\n // Add functionality to set DOM Elements throughout the component.\n }\n\n /**\n * Creates and initializes child elements throughout the component.\n *\n * @protected\n */\n _createChildElements() {\n // Add functionality to handle creating child elements throughout the component.\n }\n\n /**\n * Handles media match events throughout the component.\n *\n * @protected\n */\n _handleMediaMatch() {\n if (this._breakpointWidth === \"\") {\n return;\n }\n\n this._mediaQueryList = window.matchMedia(this.mediaQuery);\n this._mediaQueryList.addEventListener(\n \"change\",\n this._mediaQueryListEventCallback\n );\n this._mediaQueryListEventCallback(this._mediaQueryList);\n }\n\n /**\n * Handles focus events through the component.\n *\n * @protected\n */\n _handleFocus() {\n // Add functionality to handle focus events throughout the component.\n }\n\n /**\n * Handles click events through the component.\n *\n * @protected\n */\n _handleClick() {\n // Add functionality to handle click events throughout the component.\n }\n\n /**\n * Handles keydown events through the component.\n *\n * @protected\n */\n _handleKeydown() {\n // Add functionality to handle keydown events throughout the component.\n }\n\n /**\n * Handles keyup events through the component.\n *\n * @protected\n */\n _handleKeyup() {\n // Add functionality to handle keyup events throughout the component.\n }\n\n /**\n * Stores the component into the global Graupl storage object.\n *\n * @protected\n */\n _store() {\n // Set up the storage.\n storage.initializeStorage(this._storageKey);\n storage.pushToStorage(\n this._storageKey,\n this._id !== \"\" ? this._id : this._key,\n this\n );\n }\n\n /**\n * Removes the component from the global Graupl storage object.\n *\n * @protected\n */\n _unstore() {\n storage.removeFromStorage(\n this._storageKey,\n this._id !== \"\" ? this._id : this._key\n );\n }\n\n /**\n * Sets an interval within the component.\n *\n * @protected\n *\n * @param {Function} [callback] - The callback function.\n * @param {number} [delay] - The time (in milliseconds) of the delay.\n * @param {string} [scope = _default] - The scope of the interval (used to store the interval in _intervals).\n */\n _setInterval(callback, delay, scope = \"_default\") {\n this._clearInterval(scope);\n\n this._intervals[scope] = setInterval(callback, delay);\n }\n\n /**\n * Clears the interval within the component.\n *\n * @protected\n *\n * @param {string} [scope = _default] - The scope of the interval (used to get the interval from _intervals).\n */\n _clearInterval(scope = \"_default\") {\n clearInterval(this._intervals[scope]);\n }\n\n /**\n * Sets a timeout within the component.\n *\n * @protected\n *\n * @param {Function} [callback] - The callback function.\n * @param {number} [delay] - The time (in milliseconds) of the delay.\n * @param {string} [scope = _default] - The scope of the timeout (used to store the timeout in _timeouts).\n */\n _setTimeout(callback, delay, scope = \"_default\") {\n this._clearTimeout(scope);\n\n this._timeouts[scope] = setTimeout(callback, delay);\n }\n\n /**\n * Clears the timeout within the component.\n *\n * @protected\n *\n * @param {string} [scope = _default] - The scope of the timeout (used to get the timeout from _timeouts).\n */\n _clearTimeout(scope = \"_default\") {\n clearTimeout(this._timeouts[scope]);\n }\n\n /**\n * Dispatch a custom event on an element in the DOM.\n *\n * @param {string} eventType - The type of the event to dispatch.\n * @param {HTMLElement} element - The element to dispatch the event on.\n */\n _dispatchEvent(eventType, element) {\n // Make sure the event type exists.\n if (!Object.keys(this.events).includes(eventType)) {\n throw new Error(\n `Graupl ${this.constructor.name}: \"${eventType}\" is not a valid event type.`\n );\n }\n\n // Make sure the element is actually an HTML Element.\n isValidInstance(HTMLElement, { element });\n\n // Dispatch the event.\n element.dispatchEvent(this.events[eventType]);\n }\n\n /**\n * Add an event listener to an element and register it within the component.\n *\n * @param {string} type - The type of event to listen for.\n * @param {HTMLElement} element - The element to add the listener to.\n * @param {Function} listener - The listener callback.\n * @param {object|boolean} [options = {}] - Options to pass to the listener.\n */\n _addEventListener(type, element, listener, options = {}) {\n // Add the listener.\n element.addEventListener(type, listener, options);\n\n // Store it in the component.\n this._listeners.push({\n type,\n element,\n listener,\n options,\n });\n }\n\n /**\n * Remove an event listener to an element and unregister it within the component.\n *\n * @param {string} type - The type of event to listen for.\n * @param {HTMLElement} element - The element to add the listener to.\n * @param {Function} listener - The listener callback.\n * @param {object|boolean} [options = {}] - Options to pass to the listener.\n */\n _removeEventListener(type, element, listener, options = {}) {\n // Remove the listener.\n element.removeEventListener(type, listener, options);\n\n // Remove it from the component storage.\n const index = this._listeners.indexOf({\n type,\n element,\n listener,\n options,\n });\n\n if (index !== -1) {\n this._listeners.splice(index);\n }\n }\n\n /**\n * Removes all event listeners registered in the component.\n *\n * @protected\n */\n _removeEventListeners() {\n this._listeners.forEach(({ type, element, listener, options }) => {\n this._removeEventListener(type, element, listener, options);\n });\n }\n\n /**\n * Disposes of the current instantiated component.\n *\n * Removes all event listeners and delete's the object.\n */\n dispose() {\n this._removeEventListeners();\n this._unstore();\n\n delete this;\n }\n}\n\nexport default Component;\n","/**\n * @file\n * The alert class.\n */\n\nimport { isValidClassList, isValidType } from \"../validate.js\";\nimport { addClass, removeClass } from \"../domHelpers.js\";\nimport { keyPress, preventEvent } from \"../eventHandlers.js\";\nimport { TransactionalValue } from \"../TransactionalValue.js\";\nimport Component from \"../Component.js\";\n\nclass Alert extends Component {\n /**\n * The DOM elements within the alert.\n *\n * @protected\n *\n * @type {Object<HTMLElement>}\n *\n * @property {HTMLElement} alert - The alert element.\n * @property {HTMLElement} controller - The alert toggle element.\n */\n _dom = {\n alert: null,\n controller: null,\n };\n\n /**\n * The DOM elements within the component that cannot be reset or generated by the component itself.\n *\n * @protected\n *\n * @type {string[]}\n */\n _protectedDOMElements = [\"alert\", \"controller\"];\n\n /**\n * The CSS classes to apply when the alert is in various states.\n *\n * @protected\n *\n * @type {Object<string, string[]>}\n *\n * @property {string|string[]} open - The class(es) to apply when the alert is open.\n * @property {string|string[]} close - The class(es) to apply when the alert is closed.\n * @property {string|string[]} tranistion - The class(es) to apply when the alert is transitioning between states.\n * @property {string|string[]} initialize - The class(es) to apply when the alert is initializing.\n */\n _classes = {\n show: \"\",\n hide: \"\",\n transition: \"\",\n initialize: \"\",\n };\n\n /**\n * The duration times (in milliseconds) for variouse aspects throughout the disclosure.\n *\n * @protected\n *\n * @type {Object<number>}\n *\n * @property {number} transition - The duration time (in milliseconds) for the transition between shown and hidden states.\n * @property {number} show - The duration time (in milliseconds) for the transition from hidden to shown states.\n * @property {number} hide - The duration time (in milliseconds) for the transition from shown to hidden states.\n */\n _durations = {\n transition: 150,\n show: -1,\n hide: -1,\n };\n\n /**\n * The hidden state of the alert.\n *\n * @protected\n *\n * @type {TransactionalValue<boolean>}\n */\n _hidden = new TransactionalValue(false);\n\n /**\n * Custom events that can be triggered throughout the alert.\n *\n * @protected\n *\n * @type {Object<CustomEvent>}\n */\n _events = {\n /**\n * The event that is triggered when the alert is shown.\n *\n * @event grauplAlertShow\n *\n * @type {CustomEvent}\n *\n * @property {boolean} bubbles - A flag to bubble the event\n * @property {Object<Alert>} detail - The details object containing the alert itself.\n * @property {Alert} detail.alert - The alert.\n */\n show: new CustomEvent(\"grauplAlertShow\", {\n bubbles: true,\n detail: {\n alert: this,\n },\n }),\n /**\n * The event that is triggered when the alert is hidden.\n *\n * @event grauplAlertHide\n *\n * @type {CustomEvent}\n *\n * @property {boolean} bubbles - A flag to bubble the event\n * @property {Object<Alert>} detail - The details object containing the alert itself.\n * @property {Alert} detail.alert - The alert.\n */\n hide: new CustomEvent(\"grauplAlertHide\", {\n bubbles: true,\n detail: {\n alert: this,\n },\n }),\n };\n\n /**\n * The key used for storage.\n *\n * @protected\n *\n * @type {string}\n */\n _storageKey = \"alerts\";\n\n /**\n * Constructs a new `Alert`.\n *\n * @param {object} [options = {}] - The options object.\n * @param {HTMLElement} options.alertElement - The alert element.\n * @param {?HTMLElement} [options.controllerElement = null] - The controller element.\n * @param {string|string[]|null} [options.showClass = show] - The class(es) to apply when the alert is shown.\n * @param {string|string[]|null} [options.hideClass = hide] - The class(es) to apply when the alert is hidden.\n * @param {string|string[]|null} [options.transitionClass = transitioning] - The class(es) to apply when the alert is transitioning between states.\n * @param {number} [options.transitionDuration = 150] - The duration of the transition between \"shown\" and \"hidden\" states (in milliseconds).\n * @param {boolean} [options.showDuration = -1] - The duration of the transition from \"hidden\" to \"shown\" states (in milliseconds).\n * @param {boolean} [options.hideDuration = -1] - The duration of the transition from \"shown\" to \"hidden\" states (in milliseconds).\n * @param {boolean} [options.isHidden = false] - A flag to determine the initial state of the alert.\n * @param {?string} [options.prefix = graupl-] - The prefix used for CSS custom properties and attributes.\n * @param {?string} [options.key = null] - The key used to generate IDs throughout the alert.\n * @param {?(string|string[])} [options.initializeClass = initializing] - The class(es) to apply when the alert is initializing.\n * @param {boolean} [options.initialize = false] - A flag to initialize the alert immediately upon creation.\n */\n constructor({\n alertElement,\n controllerElement = null,\n showClass = \"show\",\n hideClass = \"hide\",\n transitionClass = \"transitioning\",\n transitionDuration = 150,\n showDuration = -1,\n hideDuration = -1,\n isHidden = false,\n prefix = \"graupl-\",\n key = null,\n initializeClass = \"initializing\",\n initialize = false,\n } = {}) {\n super({\n prefix,\n key,\n initializeClass,\n });\n\n // Set the DOM elements.\n this._dom.alert = alertElement;\n this._dom.controller = controllerElement;\n\n // Set the classes.\n this._classes.show = showClass || \"\";\n this._classes.hide = hideClass || \"\";\n this._classes.transition = transitionClass || \"\";\n\n // Set the durations.\n this._durations.transition = transitionDuration;\n this._durations.show = showDuration;\n this._durations.hide = hideDuration;\n\n // Set hidden.\n this._hidden.value = isHidden;\n this._hidden.commit();\n\n if (initialize) {\n this.initialize();\n }\n }\n\n /**\n * Initializes the alert.\n */\n initialize() {\n try {\n // Add the initialization class.\n addClass(this._classes.initialize, this.dom.alert);\n\n super.initialize();\n\n // Set up the DOM.\n this._setIds();\n this._setCustomProps();\n\n // Handle events.\n this._handleClick();\n this._handleKeydown();\n this._handleKeyup();\n\n // Store the component.\n this._store();\n\n // Handle hiding the alert by default.\n if (this.isHidden) {\n this._conseal({ emit: false, transition: false });\n }\n } catch (error) {\n console.error(error);\n } finally {\n // Remove the initialization class.\n requestAnimationFrame(() => {\n removeClass(this._classes.initialize, this.dom.alert);\n });\n }\n }\n\n /**\n * The class to use the show the alert.\n *\n * @type {string|string[]}\n *\n * @see _classes.show\n */\n get showClass() {\n return this._classes.show;\n }\n\n set showClass(value) {\n isValidClassList({ showClass: value });\n\n if (this._classes.show !== value) {\n this._classes.show = value;\n }\n }\n\n /**\n * The class to use to hide the alert.\n *\n * @type {string|string[]}\n *\n * @see _classes.hide\n */\n get hideClass() {\n return this._classes.hide;\n }\n\n set hideClass(value) {\n isValidClassList({ hideClass: value });\n\n if (this._classes.hide !== value) {\n this._classes.hide = value;\n }\n }\n\n /**\n * The class to use when transitioning the alert.\n *\n * @type {string|string[]}\n *\n * @see _classes.transition\n */\n get transitionClass() {\n return this._classes.transition;\n }\n\n set transitionClass(value) {\n isValidClassList({ transitionClass: value });\n\n if (this._classes.transition !== value) {\n this._classes.transition = value;\n }\n }\n\n /**\n * The time in milliseconds the transition will take.\n *\n * @type {number}\n *\n * @see _durations.transition\n */\n get transitionDuration() {\n return this._durations.transition;\n }\n\n set transitionDuration(value) {\n isValidType(\"number\", { transitionDuration: value });\n\n if (this._durations.transition !== value) {\n this._durations.transition = value;\n this._setCustomProps();\n }\n }\n\n /**\n * The duration time (in milliseconds) for the transition from hidden to shown states.\n *\n * If showDuration is set to -1, the transitionDuration value will be used instead.\n *\n * Setting this value will also set the --graupl-show-transition-duration CSS custom property on the disclosure.\n *\n * @type {number}\n *\n * @see _durations.show\n */\n get showDuration() {\n if (this._durations.show === -1) return this.transitionDuration;\n\n return this._durations.show;\n }\n\n set showDuration(value) {\n isValidType(\"number\", { value });\n\n if (this._durations.show !== value) {\n this._durations.show = value;\n this._setCustomProps();\n }\n }\n\n /**\n * The duration time (in milliseconds) for the transition from shown to hidden states.\n *\n * If hideDuration is set to -1, the transitionDuration value will be used instead.\n *\n * Setting this value will also set the --graupl-close-transition-duration CSS custom property on the disclosure.\n *\n * @type {number}\n *\n * @see _durations.hide\n */\n get hideDuration() {\n if (this._durations.hide === -1) return this.transitionDuration;\n\n return this._durations.hide;\n }\n\n set hideDuration(value) {\n isValidType(\"number\", { value });\n\n if (this._durations.hide !== value) {\n this._durations.hide = value;\n this._setCustomProps();\n }\n }\n\n /**\n * The hidden state of the alert.\n *\n * @readonly\n *\n * @type {boolean}\n *\n * @see _hidden\n */\n get isHidden() {\n return this._hidden.value;\n }\n\n /**\n * Validates all aspects of the alert to ensure proper functionality.\n *\n * @protected\n *\n * @return {boolean} - The result of the validation.\n */\n _validate() {\n super._validate();\n\n // Boolean checks.\n const booleans = {\n isHidden: this._hidden.value,\n };\n\n // Check the booleans.\n const booleanChecks = isValidType(\"boolean\", booleans);\n\n // Handle boolean check failure.\n if (!booleanChecks) {\n this._errors.push(booleanChecks.message);\n this._valid = false;\n }\n\n return this._valid;\n }\n\n /**\n * Sets the IDs of the alert and it's children if they do not already exist.\n *\n * The generated IDs use the key and follow the format:\n * - alert: `alert-${key}`\n * - controller: `alert-controller-${key}`\n */\n _setIds() {\n this.dom.alert.id = this.dom.alert.id || `alert-${this.key}`;\n this.dom.controller.id =\n this.dom.controller.id || `alert-controller-${this.key}`;\n\n this._id = this.dom.alert.id;\n }\n\n /**\n * Reveals the alert.\n *\n * Adds the show class and removes the hide class from the alert.\n *\n * @protected\n *\n * @fires grauplAlertShow\n *\n * @param {Object<boolean>} [options = {}] - Options for revealing the alert.\n * @param {boolean} [options.emit = true] - Emit the show event once revealed.\n * @param {boolean} [options.transition = true] - Respect the transition class.\n */\n _reveal({ emit = true, transition = true } = {}) {\n // If we're dealing with transition classes, then we need to utilize\n // requestAnimationFrame to add the transition class, remove the hide class,\n // add the show class, and finally remove the transition class.\n if (transition && this.transitionClass !== \"\") {\n addClass(this.transitionClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n removeClass(this.hideClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n addClass(this.showClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n this._setTimeout(\n () => removeClass(this.transitionClass, this.dom.alert),\n this.showDuration\n );\n });\n });\n });\n } else {\n // Add the show class\n addClass(this.showClass, this.dom.alert);\n\n // Remove the hide class.\n removeClass(this.hideClass, this.dom.alert);\n }\n\n this.dom.alert.removeAttribute(\"inert\");\n\n if (emit) {\n this._dispatchEvent(\"show\", this.dom.alert);\n }\n }\n\n /**\n * Conseals the alert.\n *\n * Adds the hide class and removes the show class from the alert.\n *\n * @protected\n *\n * @fires grauplAlertHide\n *\n * @param {Object<boolean>} [options = {}] - Options for concealing the alert.\n * @param {boolean} [options.emit = true] - Emit the show event once concealed.\n * @param {boolean} [options.transition = true] - Respect the transition class.\n */\n _conseal({ emit = true, transition = true } = {}) {\n // If we're dealing with transition classes, then we need to utilize\n // requestAnimationFrame to add the transition class, remove the show class,\n // add the hide class, and finally remove the transition class.\n if (transition && this.transitionClass !== \"\") {\n addClass(this.transitionClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n removeClass(this.showClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n addClass(this.hideClass, this.dom.alert);\n\n requestAnimationFrame(() => {\n this._setTimeout(\n () => removeClass(this.transitionClass, this.dom.alert),\n this.hideDuration\n );\n });\n });\n });\n } else {\n // Add the hide class\n addClass(this.hideClass, this.dom.alert);\n\n // Remove the show class.\n removeClass(this.showClass, this.dom.alert);\n }\n\n this.dom.alert.setAttribute(\"inert\", \"true\");\n\n if (emit) {\n this._dispatchEvent(\"hide\", this.dom.alert);\n }\n }\n\n /**\n * Sets custom props throughout the alert.\n *\n * The custom properties are:\n * - `--graupl-alert-transition-duration`,\n * - `--graupl-alert-show-transition-duration`, and\n * - `--graupl-alert-hide-transition-duration`.\n *\n * The prefix of `graupl-` can be changed by setting the alert's prefix value.\n *\n * @protected\n */\n _setCustomProps() {\n this.dom.alert.style.setProperty(\n `--${this.prefix}alert-transition-duration`,\n `${this.transitionDuration}ms`\n );\n\n this.dom.alert.style.setProperty(\n `--${this.prefix}alert-show-transition-duration`,\n `${this.showDuration}ms`\n );\n\n this.dom.alert.style.setProperty(\n `--${this.prefix}alert-hide-transition-duration`,\n `${this.hideDuration}ms`\n );\n }\n\n /**\n * Handles click events throughout the alert for proper use.\n *\n * - Adds a `pointerup` listener to the controller that will hide the alert.\n *\n * @protected\n */\n _handleClick() {\n if (this.dom.controller === null) {\n return;\n }\n\n this._addEventListener(\"pointerup\", this.dom.controller, () => this.hide());\n }\n\n /**\n * Handles keydown events throughout the alert for proper use.\n *\n * This method exists to assist the _handleKeyup method.\n *\n * - Adds a `keydown` listener to the controller (if it exists).\n * - Blocks propagation on \"Space\" and \"Enter\" keys.\n */\n _handleKeydown() {\n if (this.dom.controller === null) {\n return;\n }\n\n this._addEventListener(\"keydown\", this.dom.controller, (event) => {\n const key = keyPress(event);\n\n // Prevent default behavior for space and enter keys.\n if (key === \"Space\" || key === \"Enter\") {\n preventEvent(event);\n }\n });\n }\n\n /**\n * Handles keyup events throughout the alert for proper use.\n *\n * - Adds a `keyup` listener to the controller (if it exists).\n * - Hides the alert when the user hits \"Space\" or \"Enter\".\n */\n _handleKeyup() {\n if (this.dom.controller === null) {\n return;\n }\n\n this._addEventListener(\"keyup\", this.dom.controller, (event) => {\n const key = keyPress(event);\n\n if (key === \"Space\" || key === \"Enter\") {\n this.hide();\n }\n });\n }\n\n /**\n * Shows the alert.\n *\n * Sets the alert's focus state to \"self\", calls reveal, and sets isHidden to `false`.\n *\n * @param {Object<boolean>} [options = {}] - Options for showing the alert.\n * @param {boolean} [options.force = false] - Whether to force the show action.\n * @param {boolean} [options.preserveState = false] - Whether to preserve the hidden state.\n */\n show({ force = false, preserveState = false } = {}) {\n if (!this.isHidden && !force) return;\n\n // Set the focus state.\n this.focusState = \"self\";\n\n // Reveal the alert.\n this._reveal();\n\n // Set the hidden state.\n this._hidden.value = false;\n\n if (!preserveState) {\n this._hidden.commit();\n }\n }\n\n /**\n * Hides the alert.\n *\n * Sets the alert's focus state to \"none\", calls conceal, and sets isHidden to `true`.\n *\n * @param {Object<boolean>} [options = {}] - Options for hiding the alert.\n * @param {boolean} [options.force = false] - Whether to force the hide action.\n * @param {boolean} [options.preserveState = false] - Whether to preserve the hidden state.\n */\n hide({ force = false, preserveState = false } = {}) {\n if (this.isHidden && !force) return;\n\n // Set the focus state.\n this.focusState = \"none\";\n\n // Conceal the alert.\n this._conseal();\n\n // Set the hidden state.\n this._hidden.value = true;\n\n if (!preserveState) {\n this._hidden.commit();\n }\n }\n}\n\nexport default Alert;\n","/**\n * Mark DOM elements as processed to prevent multiple initializations.\n *\n * @module @drupal/once\n *\n * @example <!-- Use as a module -->\n * <script type=\"module\">\n * import once from 'https://unpkg.com/@drupal/once/src/once.js';\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n *\n * @example <!-- Use as a regular script -->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * const elements = once('my-once-id', 'div');\n * // Initialize elements.\n * elements.forEach(el => el.innerHTML = 'processed');\n * </script>\n * @example <!-- Using a single element as input-->\n * <script src=\"https://unpkg.com/@drupal/once\"></script>\n * <script>\n * // once methods always return an array, to simplify the use with a single\n * // element use destructuring or the shift method.\n * const [myElement] = once('my-once-id', document.body);\n * const myElement = once('my-once-id', document.body).shift();\n * </script>\n */\n\n/**\n * Illegal spaces in ids.\n *\n * @private\n *\n * @type {RegExp}\n */\nconst wsRE = /[\\11\\12\\14\\15\\40]+/;\n\n/**\n * Name of the HTML attribute containing an element's once ids.\n *\n * @private\n *\n * @type {string}\n */\nconst attrName = 'data-once';\n\n/**\n * Shortcut to access the html element.\n *\n * @private\n *\n * @type {HTMLElement}\n */\nconst doc = document;\n\n/**\n * Helper to access element attributes.\n *\n * @private\n *\n * @param {Element} element\n * The Element to access the data-once attribute from.\n * @param {string} op\n * The action to take on the element.\n * @param {string} [value]\n * Optional value for setAttribute.\n *\n * @return {string|undefined|null|boolean}\n * Result of the attribute method.\n */\nfunction attr(element, op, value) {\n return element[`${op}Attribute`](attrName, value);\n}\n\n/**\n * Return the attribute selector.\n *\n * @private\n *\n * @param {string} id\n * The id passed by a call to a once() function.\n *\n * @return {string}\n * The full CSS attribute selector.\n *\n * @throws {TypeError|RangeError}\n */\nfunction attrSelector(id) {\n // Verify the validity of the once id.\n if (typeof id !== 'string') {\n throw new TypeError('once ID must be a string');\n }\n if (id === '' || wsRE.test(id)) {\n throw new RangeError('once ID must not be empty or contain spaces');\n }\n // The id is valid, return the full CSS selector.\n return `[${attrName}~=\"${id}\"]`;\n}\n\n/**\n * Verifies that an item is an instance of Element.\n *\n * This function is used during filtering to ensure only DOM elements are\n * processed. once() makes use of get/setAttribute, which are methods\n * inherited from the Element object, so only of Element can be used.\n *\n * @private\n *\n * @param {*} itemToCheck\n * The item to check.\n *\n * @return {boolean}\n * True if the item is an instance of Element\n *\n * @throws {TypeError}\n */\nfunction checkElement(itemToCheck) {\n if (!(itemToCheck instanceof Element)) {\n throw new TypeError('The element must be an instance of Element');\n }\n return true;\n}\n\n/**\n * Process arguments, query the DOM if necessary.\n *\n * @private\n *\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array with the processed Id and the list of elements to process.\n */\nfunction getElements(selector, context = doc) {\n // Assume selector is an array-like value.\n let elements = selector;\n\n // If selector is null it is most likely because of a call to querySelector\n // that didn't return a result.\n if (selector === null) {\n elements = [];\n }\n // The selector is undefined, error out.\n else if (!selector) {\n throw new TypeError('Selector must not be empty');\n }\n // Context doesn't implement querySelectorAll, error out.\n else if (\n !(\n context instanceof Document ||\n context instanceof DocumentFragment ||\n context instanceof Element\n )\n ) {\n throw new TypeError(\n 'Context must be an object of type \"Document\", \"DocumentFragment\", or \"Element\".',\n );\n }\n // This is a selector, query the elements.\n else if (typeof selector === 'string') {\n elements = context.querySelectorAll(selector);\n }\n // This is a single element.\n else if (selector instanceof Element) {\n elements = [selector];\n }\n\n // Make sure an array is returned and not a NodeList or an Array-like object.\n return Array.prototype.slice.call(elements);\n}\n\n/**\n * A helper for applying DOM changes to a filtered set of elements.\n *\n * This makes it possible to filter items that are not instances of Element,\n * then modify their DOM attributes in a single array traversal.\n *\n * @private\n *\n * @param {string} selector\n * A CSS selector to check against to each element in the array.\n * @param {Array.<Element>} elements\n * A NodeList or array of elements passed by a call to a once() function.\n * @param {function} [apply]\n * An optional function to apply on all matched elements.\n *\n * @return {Array.<Element>}\n * The array of elements that match the CSS selector.\n */\nfunction filterAndModify(selector, elements, apply) {\n return elements.filter((element) => {\n const selected = checkElement(element) && element.matches(selector);\n if (selected && apply) {\n apply(element);\n }\n return selected;\n });\n}\n\n/**\n * Add or remove an item from a list of once values.\n *\n * This function removes duplicates while adding or removing a once id in a\n * single array traversal.\n *\n * @private\n *\n * @param {Element} element\n * A space separated string of once ids from a data-drupal-once attribute.\n * @param {string} [add]\n * The once id to add to the list of values.\n * @param {string} [remove]\n * The once id to remove from the list of values.\n *\n * @return {undefined}\n * Nothing to return this is a callback in a foreach.\n */\nfunction updateAttribute(element, { add, remove }) {\n const result = [];\n if (attr(element, 'has')) {\n attr(element, 'get')\n .trim()\n .split(wsRE)\n .forEach((item) => {\n if (result.indexOf(item) < 0 && item !== remove) {\n result.push(item);\n }\n });\n }\n if (add) {\n result.push(add);\n }\n const attribute = result.join(' ');\n attr(element, attribute === '' ? 'remove' : 'set', attribute);\n}\n\n/**\n * Ensures a JavaScript callback is only executed once on a set of elements.\n *\n * Filters a NodeList or array of elements, removing those already processed\n * by a callback with a given id.\n * This method adds a `data-once` attribute on DOM elements. The value of\n * this attribute identifies if a given callback has been executed on that\n * element.\n *\n * @global\n *\n * @example <caption>Basic usage</caption>\n * const elements = once('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once('my-once-id', document.querySelector('#some-id'));\n * @example <caption>Using a single element</caption>\n * // Once always returns an array, even when passing a single element. Some\n * // forms that can be used to keep code readable.\n * // Destructuring:\n * const [myElement] = once('my-once-id', document.body);\n * // By changing the resulting array, es5 compatible.\n * const myElement = once('my-once-id', document.body).shift();\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements.\n * @param {Document|DocumentFragment|Element} [context=document]\n * An element or document object to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * An array of elements that have not yet been processed by a once call\n * with a given id.\n */\nfunction once(id, selector, context) {\n return filterAndModify(\n `:not(${attrSelector(id)})`,\n getElements(selector, context),\n (element) => updateAttribute(element, { add: id }),\n );\n}\n\n/**\n * Removes a once id from an element's data-drupal-once attribute value.\n *\n * If a once id is removed from an element's data-drupal-once attribute value,\n * the JavaScript callback associated with that id can be executed on that\n * element again.\n *\n * @method once.remove\n *\n * @example <caption>Basic usage</caption>\n * const elements = once.remove('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.remove('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.remove('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.remove('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.remove('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.remove('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of a once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that had been processed by the provided id,\n * and are now able to be processed again.\n */\nonce.remove = (id, selector, context) => {\n return filterAndModify(\n attrSelector(id),\n getElements(selector, context),\n (element) => updateAttribute(element, { remove: id }),\n );\n};\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Behaves like {@link once} and {@link once.remove} without changing the DOM.\n * To select all DOM nodes processed by a given id, use {@link once.find}.\n *\n * @method once.filter\n *\n * @example <caption>Basic usage</caption>\n * const filteredElements = once.filter('my-once-id', '[data-myelement]');\n * @example <caption>Input parameters accepted</caption>\n * // NodeList.\n * once.filter('my-once-id', document.querySelectorAll('[data-myelement]'));\n * // Array or Array-like of Element.\n * once.filter('my-once-id', jQuery('[data-myelement]'));\n * // A CSS selector without a context.\n * once.filter('my-once-id', '[data-myelement]');\n * // A CSS selector with a context.\n * once.filter('my-once-id', '[data-myelement]', document.head);\n * // Single Element.\n * once.filter('my-once-id', document.querySelector('#some-id'));\n *\n * @param {string} id\n * The id of the once call.\n * @param {NodeList|Array.<Element>|Element|string} selector\n * A NodeList or array of elements to remove the once id from.\n * @param {Document|Element} [context=document]\n * An element to use as context for querySelectorAll.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.filter = (id, selector, context) =>\n filterAndModify(attrSelector(id), getElements(selector, context));\n\n/**\n * Finds elements that have been processed by a given once id.\n *\n * Query the 'context' element for elements that already have the\n * corresponding once id value.\n *\n * @method once.find\n *\n * @example <caption>Basic usage</caption>\n * const oncedElements = once.find('my-once-id');\n * @example <caption>Input parameters accepted</caption>\n * // Call without parameters, return all elements with a `data-once` attribute.\n * once.find();\n * // Call without a context.\n * once.find('my-once-id');\n * // Call with a context.\n * once.find('my-once-id', document.head);\n *\n * @param {string} [id]\n * The id of the once call.\n * @param {Document|DocumentFragment|Element} [context=document]\n * Scope of the search for matching elements.\n *\n * @return {Array.<Element>}\n * A filtered array of elements that have already been processed by the\n * provided once id.\n */\nonce.find = (id, context) =>\n getElements(!id ? `[${attrName}]` : attrSelector(id), context);\n\nexport default once;\n","import Alert from \"./Alert.js\";\nimport once from \"@drupal/once\";\n\nconst generate = (\n options = {},\n context = document,\n alertSelector = \".alert\"\n) => {\n once(\"graupl-alert-generator\", alertSelector, context).forEach(\n (alertElement) => {\n const alertOptions = alertElement.dataset.grauplAlertOptions\n ? JSON.parse(\n alertElement.dataset.grauplAlertOptions.replace(/'/g, '\"')\n ) || {}\n : {};\n\n new Alert({\n alertElement,\n controllerElement:\n alertElement.querySelector(\".alert-dismisser\") || null,\n initialize: true,\n ...options,\n ...alertOptions,\n });\n }\n );\n};\n\nexport default generate;\n"],"x_google_ignoreList":[7],"mappings":"+BAeA,SAAgBA,EAAgBC,EAAaC,EAAU,CACrD,GAAI,CACF,GAAI,OAAOA,GAAa,SAAU,CAChC,MAAMC,EAAe,OAAOD,EAE5B,MAAM,IAAIE,UACR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AAIQ,EAAUC,EAAS,CACnC,OAAOS,EACL,QAAQnB,EAAaC,CAAAA,CAAG,IACxBO,EAAYC,EAAUC,CAAAA,EACrBb,GAAY2B,EAAgB3B,EAAS,CAAE4B,IAAKxB,CAAAA,CAAI,CACnD,EAqCFmC,EAAKV,OAAAA,CAAUzB,EAAIQ,EAAUC,IACpBS,EACLnB,EAAaC,CAAAA,EACbO,EAAYC,EAAUC,CAAAA,EACrBb,GAAY2B,EAAgB3B,EAAS,CAAE6B,OAAQzB,CAAAA,CAAI,CACtD,EAoCFmC,EAAKf,OAAAA,CAAUpB,EAAIQ,EAAUC,IAC3BS,EAAgBnB,EAAaC,CAAAA,EAAKO,EAAYC,EAAUC,CAAAA,CAAQ,EA6BlE0B,EAAKC,KAAAA,CAAQpC,EAAIS,IACfF,EAAaP,EAAuBD,EAAaC,CAAAA,EAA/B,IAAIR,CAAAA,IAAgCiB,CAAAA,EAExD,IAAA,EAAe0B,ECpXf,EAzBMI,CACJC,EAAU,CAAA,EACVC,EAAUC,SACVC,EAAgB,WACb,CACHL,EAAK,yBAA0BK,EAAeF,CAAAA,EAASG,QACpDC,GAAiB,CAChB,MAAMC,EAAeD,EAAaE,QAAQC,mBACtCC,KAAKC,MACHL,EAAaE,QAAQC,mBAAmBG,QAAQ,KAAM,GAAA,CACxD,GAAK,CAAA,EACL,CAAA,EAEJ,IAAId,EAAM,CACRQ,aAAAA,EACAO,kBACEP,EAAaQ,cAAc,kBAAA,GAAuB,KACpDC,WAAY,GACZ,GAAGd,EACH,GAAGM,EACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
function
|
|
1
|
+
function n(t,e){t===""||t.length===0||(typeof t=="string"?e.classList.add(t):e.classList.add(...t))}function l(t,e){t===""||t.length===0||(typeof t=="string"?e.classList.remove(t):e.classList.remove(...t))}function c(t){try{const e=t.key||t.keyCode,s={Enter:e==="Enter"||e===13,Space:e===" "||e==="Spacebar"||e===32,Escape:e==="Escape"||e==="Esc"||e===27,ArrowUp:e==="ArrowUp"||e==="Up"||e===38,ArrowRight:e==="ArrowRight"||e==="Right"||e===39,ArrowDown:e==="ArrowDown"||e==="Down"||e===40,ArrowLeft:e==="ArrowLeft"||e==="Left"||e===37,Home:e==="Home"||e===36,End:e==="End"||e===35,Tab:e==="Tab"||e===9};return Object.keys(s).find(r=>s[r]===!0)||""}catch{return""}}function h(t){t.preventDefault(),t.stopPropagation()}function d(t,e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Elements given to isValidInstance() must be inside of an object. "${s}" given.`)}for(const s in e)if(!(e[s]instanceof t)){const r=typeof e[s];throw new TypeError(`${s} must be an instance of ${t.name}. "${r}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function i(t,e){try{if(typeof e!="object"){const s=typeof e;throw new TypeError(`Values given to isValidType() must be inside of an object. "${s}" given.`)}for(const s in e){const r=typeof e[s];if(r!==t)throw new TypeError(`${s} must be a ${t}. "${r}" given.`)}return{status:!0,error:null}}catch(s){return{status:!1,error:s}}}function v(t){try{if(typeof t!="object"){const e=typeof t;throw new TypeError(`Values given to isQuerySelector() must be inside of an object. "${e}" given.`)}for(const e in t)try{if(t[e]===null)throw new Error;document.querySelector(t[e])}catch{throw new TypeError(`${e} must be a valid query selector. "${t[e]}" given.`)}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function u(t){try{if(typeof t!="object"||Array.isArray(t)){const e=typeof t;throw new TypeError(`Values given to isValidClassList() must be inside of an object. "${e}" given.`)}for(const e in t){const s=typeof t[e];if(s!=="string")if(Array.isArray(t[e]))t[e].forEach(r=>{if(typeof r!="string")throw new TypeError(`${e} must be a string or an array of strings. An array containing non-strings given.`)});else throw new TypeError(`${e} must be a string or an array of strings. "${s}" given.`);else{const r={};r[e]=t[e],v(r)}}return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function E(t,e){if(i("string",{tagName:t}).status&&d(HTMLElement,e).status){const s=t.toLowerCase();let r=!0;for(const a in e)e[a].tagName.toLowerCase()!==s&&(r=!1);return r}else return!1}function P(t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidState() must be inside of an object. "${s}" given.`)}const e=["none","self","child"];for(const s in t)if(!e.includes(t[s]))throw new TypeError(`${s} must be one of the following values: ${e.join(", ")}. "${t[s]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function q(t){try{if(typeof t!="object"){const s=typeof t;throw new TypeError(`Values given to isValidEvent() must be inside of an object. "${s}" given.`)}const e=["none","mouse","keyboard","character"];for(const s in t)if(!e.includes(t[s]))throw new TypeError(`${s} must be one of the following values: ${e.join(", ")}. "${t[s]}" given.`);return{status:!0,error:null}}catch(e){return{status:!1,error:e}}}function H(t=null){window.Graupl=window.Graupl||{},i("string",{type:t})&&(window.Graupl[t]=window.Graupl[t]||{})}function R(t=null){return i("string",{type:t})?window.Graupl[t]:window.Graupl}function N(t,e={}){i("string",{type:t})&&i("object",{data:e})&&(window.Graupl[t]=e)}function U(t){i("string",{type:t})&&(window.Graupl[t]={})}function J(t,e,s){i("string",{type:t,key:e})&&(window.Graupl[t][e]=s)}function W(t,e){return i("string",{type:t,key:e})?window.Graupl[t][e]:null}function B(t,e){i("string",{type:t,key:e})&&delete window.Graupl[t][e]}var p={initializeStorage:H,getStorage:R,setStorage:N,clearStorage:U,pushToStorage:J,getFromStorage:W,removeFromStorage:B},X=class{_dom={};_protectedDOMElements=[];_selectors={};_elements={};_classes={initialize:""};_durations={};_delays={};_focusState="none";_currentEvent="none";_breakpoint="";_mediaQueryString="";_mediaQueryList=null;_mediaQueryListEventCallback=t=>{t.matches};_intervals={};_timeouts={};_listeners=[];_events={};_prefix="graupl-";_key="";_storageKey="components";_id="";_valid=!0;_errors=[];constructor({prefix:t="graupl-",key:e=null,initializeClass:s="initializing"}={}){this._classes.initialize=s||"",this._prefix=t||"",this._key=e||""}initialize(){try{if(!this._validate())throw new Error(`Graupl ${this.constructor.name}: Cannot initialize component. The following errors have been found:
|
|
2
2
|
- ${this.errors.join(`
|
|
3
|
-
- `)}`);this._generateKey(),this._setDOMElements(),this._setIds(),this._setAriaAttributes(),this.activateFirstItem(),this._handleAutoplay(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this._setTransitionDuration(),w.initializeStorage("carousels"),w.pushToStorage("carousels",this.dom.carousel.id,this)}catch(t){console.error(t)}}get dom(){return this._dom}get selectors(){return this._selectors}get activeClass(){return this._activeClass}get previousClass(){return this._previousClass}get nextClass(){return this._nextClass}get playClass(){return this._playClass}get pauseClass(){return this._pauseClass}get currentItem(){return this._currentItem}get currentCarouselItem(){return this.dom.carouselItems[this.currentItem]}get currentCarouselTab(){return this.dom.carouselTabs[this.currentItem]}get autoplay(){return this._autoplay}get transitionDelay(){return this._transitionDelay}get transitionDuration(){return this._transitionDuration}get playText(){return this._playText}get pauseText(){return this._pauseText}get prefix(){return this._prefix}get key(){return this._key}get currentAction(){return this._currentAction}get errors(){return this._errors}set currentItem(t){i("number",{value:t}),t!==this.currentItem&&(t<0?this._currentItem=0:t>=this.dom.carouselItems.length?this._currentItem=this.dom.carouselItems.length-1:this._currentItem=t,this._dom.carousel.querySelectorAll(this.selectors.carouselTab)&&this.dom.carouselItems.forEach((e,s)=>{e.setAttribute("aria-selected",s===this._currentItem)}))}set autoplay(t){i("boolean",{value:t}),this._autoplay!==t&&(this._autoplay=t)}set activeClass(t){n({activeClass:t}),this._activeClass!==t&&(this._activeClass=t)}set previousClass(t){n({previousClass:t}),this._previousClass!==t&&(this._previousClass=t)}set nextClass(t){n({nextClass:t}),this._nextClass!==t&&(this._nextClass=t)}set playClass(t){n({playClass:t}),this._playClass!==t&&(this._playClass=t)}set pauseClass(t){n({pauseClass:t}),this._pauseClass!==t&&(this._pauseClass=t)}set transitionDelay(t){i("number",{value:t}),t!==this.transitionDelay&&t>=0&&(this._currentItem=t)}set transitionDuration(t){i("number",{value:t}),this._transitionDuration!==t&&t>=0&&(this._transitionDuration=t,this._setTransitionDuration())}set playText(t){i("string",{value:t}),this._playText!==t&&(this._playText=t)}set pauseText(t){i("string",{value:t}),this._pauseText!==t&&(this._pauseText=t)}set prefix(t){i("string",{value:t}),this._prefix!==t&&(this._prefix=t)}set key(t){i("string",{value:t}),this._key!==t&&(this._key=t)}_validate(){let t=!0;const e=y(HTMLElement,{carousel:this.dom.carousel});e||(this._errors.push(e.message),t=!1);const s=I({carouselItemsSelector:this._selectors.carouselItems,carouselItemContainerSelector:this._selectors.carouselItemContainer,carouselControlsSelector:this._selectors.carouselControls,carouselControlContainerSelector:this._selectors.carouselControlContainer,carouselTabsSelector:this._selectors.carouselTabs,carouselTabContainerSelector:this._selectors.carouselTabContainer,autoplaySelector:this._selectors.autoplay,nextSelector:this._selectors.next,previousSelector:this._selectors.previous});s||(this._errors.push(s.message),t=!1);const r=i("boolean",{autoplay:this.autoplay});r||(this._errors.push(r.message),t=!1);const o=i("number",{transitionDelay:this._transitionDelay});o||(this._errors.push(o.message),t=!1);const l=i("number",{transitionDuration:this._transitionDuration});if(l||(this._errors.push(l.message),t=!1),this._activeClass!==""){const a=n({activeClass:this._activeClass});a||(this._errors.push(a.message),t=!1)}if(this._previousClass!==""){const a=n({previousClass:this._previousClass});a||(this._errors.push(a.message),t=!1)}if(this._nextClass!==""){const a=n({nextClass:this._nextClass});a||(this._errors.push(a.message),t=!1)}if(this._playClass!==""){const a=n({playClass:this._playClass});a||(this._errors.push(a.message),t=!1)}if(this._pauseClass!==""){const a=n({pauseClass:this._pauseClass});a||(this._errors.push(a.message),t=!1)}if(this._playText!==""){const a=i("string",{playText:this._playText});a||(this._errors.push(a.message),t=!1)}if(this._pauseText!==""){const a=i("string",{pauseText:this._pauseText});a||(this._errors.push(a.message),t=!1)}const f=i("string",{prefix:this._prefix});return f||(this._errors.push(f.message),t=!1),t}_setDOMElementType(t,e=this.dom.carousel,s=!0){if(typeof this.selectors[t]=="string"){if(t==="carousel")throw new Error(`Graupl Carousel: "${t}" element cannot be set through _setDOMElementType.`);if(e!==this.dom.carousel&&y(HTMLElement,{base:e}),Array.isArray(this._dom[t])){const r=Array.from(e.querySelectorAll(this.selectors[t])).filter(o=>o.parentElement===e);s?this._dom[t]=r:this._dom[t]=[...this._dom[t],...r]}else{const r=e.querySelector(this.selectors[t]);if(r&&r.parentElement!==e)return;s&&(this._dom[t]=r)}}else throw new Error(`Graupl Carousel: "${t}" is not a valid element type within the carousel.`)}_resetDOMElementType(t){if(typeof this.selectors[t]=="string"){if(t==="carousel")throw new Error(`Graupl Carousel: "${t}" element cannot be reset through _resetDOMElementType.`);Array.isArray(this._dom[t])?this._dom[t]=[]:this._dom[t]=null}else throw new Error(`Graupl Carousel: "${t}" is not a valid element type within the carousel.`)}_setDOMElements(){this._setDOMElementType("carouselItemContainer"),this._setDOMElementType("carouselControlContainer"),this._setDOMElementType("carouselTabContainer"),this.dom.carouselItemContainer&&this._setDOMElementType("carouselItems",this.dom.carouselItemContainer),this.dom.carouselControlContainer&&(this._setDOMElementType("carouselControls",this.dom.carouselControlContainer),this._setDOMElementType("autoplay",this.dom.carouselControlContainer),this._setDOMElementType("next",this.dom.carouselControlContainer),this._setDOMElementType("previous",this.dom.carouselControlContainer)),this._dom.carouselTabContainer&&this._setDOMElementType("carouselTabs",this.dom.carouselTabContainer)}_generateKey(t=!1){(this.key===""||t)&&(this.key=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10))}_setIds(){this.dom.carousel.id=this.dom.carousel.id||`carousel-${this.key}`,this.dom.carouselItems.forEach((t,e)=>{t.id=t.id||`carousel-item-${this.key}-${e}`}),this.dom.carouselTabs.forEach((t,e)=>{t.id=t.id||`carousel-tab-${this.key}-${e}`})}_setAriaAttributes(){!v("section",{carousel:this.dom.carousel})&&!this.dom.carousel.getAttribute("role")!=="region"&&this.dom.carousel.setAttribute("role","group"),this._dom.carousel.setAttribute("aria-roledescription","carousel"),this.dom.carouselTabContainer&&this.dom.carouselTabContainer.setAttribute("role","tablist"),this.dom.carouselTabs.forEach((t,e)=>{v("button",{tab:t})||t.setAttribute("role","button"),t.setAttribute("aria-selected",e===0),t.setAttribute("aria-controls",this.dom.carouselItems[e].id)})}_setInterval(){this._clearInterval(),this._autoplayInterval=setInterval(()=>{this.activateNextItem()},this.transitionDelay)}_clearInterval(){clearInterval(this._autoplayInterval)}_handleAutoplay(){this.autoplay?(u(this.pauseClass,this.dom.autoplay),c(this.playClass,this.dom.autoplay),this.dom.autoplay.setAttribute("aria-label",this.pauseText),this.dom.carousel.setAttribute("aria-live","off"),this._setInterval()):(u(this.playClass,this.dom.autoplay),c(this.pauseClass,this.dom.autoplay),this.dom.autoplay.setAttribute("aria-label",this.playText),this.dom.carousel.setAttribute("aria-live","polite"),this._clearInterval())}_handleFocus(){this.dom.carousel.addEventListener("focusin",()=>{this.autoplay&&this._clearInterval()}),this.dom.carousel.addEventListener("focusout",()=>{this.autoplay&&this._setInterval()})}_handleClick(){this.dom.next.addEventListener("pointerup",()=>{this.activateNextItem()}),this.dom.previous.addEventListener("pointerup",()=>{this.activatePreviousItem()}),this.dom.autoplay.addEventListener("pointerup",()=>{this.toggleAutoplay()}),this.dom.carouselTabs.forEach((t,e)=>{t.addEventListener("pointerup",()=>{this.currentItem>e?this._currentAction="previous":this._currentAction="next",this.activateItem(e)})})}_handleHover(){this.dom.carousel.addEventListener("pointerover",()=>{this.autoplay&&this._clearInterval()}),this.dom.carousel.addEventListener("pointerleave",()=>{this.autoplay&&this._setInterval()})}_handleKeydown(){this.dom.carouselControls.forEach(t=>{t.addEventListener("keydown",e=>{switch(h(e)){case"Space":case"Enter":p(e);break}})}),this.dom.carouselTabs.forEach(t=>{t.addEventListener("keydown",e=>{switch(h(e)){case"Space":case"Enter":p(e);break}})})}_handleKeyup(){this.dom.next.addEventListener("keyup",t=>{switch(h(t)){case"Space":case"Enter":this.activateNextItem(),p(t);break}}),this.dom.previous.addEventListener("keyup",t=>{switch(h(t)){case"Space":case"Enter":this.activatePreviousItem(),p(t);break}}),this.dom.autoplay.addEventListener("keyup",t=>{switch(h(t)){case"Space":case"Enter":this.toggleAutoplay(),p(t);break}}),this.dom.carouselTabs.forEach((t,e)=>{t.addEventListener("keyup",s=>{switch(h(s)){case"Space":case"Enter":this.activateItem(e),p(s);break}})})}_setTransitionDuration(){this.dom.carousel.style.setProperty(`--${this.prefix}carousel-transition-duration`,`${this.transitionDuration}ms`)}activateCurrentItem(){u(this.activeClass,this.currentCarouselItem),this.currentCarouselTab&&(this.currentCarouselTab.setAttribute("aria-selected",!0),u(this.activeClass,this.currentCarouselTab))}deactivateCurrentItem(){c(this.activeClass,this.currentCarouselItem),this.currentCarouselTab&&(this.currentCarouselTab.setAttribute("aria-selected",!1),c(this.activeClass,this.currentCarouselTab))}activateItem(t){const e=this.currentItem;this.dom.carousel.dataset.grauplAction=this._currentAction,this.autoplay&&this._clearInterval(),u(this.previousClass,this.currentCarouselItem),u(this.nextClass,this.dom.carouselItems[t]),requestAnimationFrame(()=>{this.deactivateCurrentItem(),this.currentItem=t,this.activateCurrentItem(),requestAnimationFrame(()=>{setTimeout(()=>{c(this.previousClass,this.dom.carouselItems[e]),c(this.nextClass,this.currentCarouselItem)},this.transitionDuration)})}),this.autoplay&&this._setInterval()}activateFirstItem(){this.activateItem(0)}activateLastItem(){this.activateItem(this.dom.carouselItems.length-1)}activateNextItem(){this._currentAction="next",this.currentItem+1>=this.dom.carouselItems.length?this.activateFirstItem():this.activateItem(this.currentItem+1)}activatePreviousItem(){this._currentAction="previous",this.currentItem-1<0?this.activateLastItem():this.activateItem(this.currentItem-1)}toggleAutoplay(){this.autoplay=!this.autoplay,this._handleAutoplay()}},W=B;const E=/[\11\12\14\15\40]+/,C="data-once",X=document;function g(t,e,s){return t[`${e}Attribute`](C,s)}function m(t){if(typeof t!="string")throw new TypeError("once ID must be a string");if(t===""||E.test(t))throw new RangeError("once ID must not be empty or contain spaces");return`[${C}~="${t}"]`}function Y(t){if(!(t instanceof Element))throw new TypeError("The element must be an instance of Element");return!0}function _(t,e=X){let s=t;if(t===null)s=[];else if(t)if(e instanceof Document||e instanceof DocumentFragment||e instanceof Element)typeof t=="string"?s=e.querySelectorAll(t):t instanceof Element&&(s=[t]);else throw new TypeError('Context must be an object of type "Document", "DocumentFragment", or "Element".');else throw new TypeError("Selector must not be empty");return Array.prototype.slice.call(s)}function b(t,e,s){return e.filter(r=>{const o=Y(r)&&r.matches(t);return o&&s&&s(r),o})}function T(t,{add:e,remove:s}){const r=[];g(t,"has")&&g(t,"get").trim().split(E).forEach(l=>{r.indexOf(l)<0&&l!==s&&r.push(l)}),e&&r.push(e);const o=r.join(" ");g(t,o===""?"remove":"set",o)}function d(t,e,s){return b(`:not(${m(t)})`,_(e,s),r=>T(r,{add:t}))}d.remove=(t,e,s)=>b(m(t),_(e,s),r=>T(r,{remove:t})),d.filter=(t,e,s)=>b(m(t),_(e,s)),d.find=(t,e)=>_(t?m(t):`[${C}]`,e);var Z=d;const N=(t={},e=document,s=".carousel")=>{Z("graupl-carousel-generator",s,e).forEach(r=>{const o=r.dataset.grauplCarouselOptions?JSON.parse(r.dataset.grauplCarouselOptions.replace(/'/g,'"'))||{}:{};new W({carouselElement:r,initialize:!0,...t,...o})})};var tt=N;module.exports=tt;
|
|
3
|
+
- `)}`);this._generateKey()}catch(t){console.error(t)}}init(){this.initialize()}get dom(){return this._dom}get selectors(){return this._selectors}get elements(){return this._elements}get classes(){return this._classes}get durations(){return this._durations}get delays(){return this._delays}get intervals(){return this._intervals}get timeouts(){return this._timeouts}get listeners(){return this._listeners}get events(){return this._events}get initializeClass(){return this._classes.initialize}set initializeClass(t){u({initializeClass:t}),this._classes.initialize!==t&&(this._classes.initialize=t)}get focusState(){return this._focusState}set focusState(t){P({focusState:t}),this._focusState!==t&&(this._focusState=t)}get currentEvent(){return this._currentEvent}set currentEvent(t){q({currentEvent:t}),this._currentEvent!==t&&(this._currentEvent=t)}get breakpoint(){return this._breakpoint}set breakpoint(t){i("string",{breakpoint:t}),this._breakpoint!==t&&(this._breakpoint=t)}get mediaQuery(){return this._mediaQueryString!==""?this._mediaQueryString:`(width <= ${this._breakpoint})`}set mediaQuery(t){i("string",{mediaQuery:t}),this._mediaQueryString!==t&&(this._mediaQueryString=t)}get prefix(){return this._prefix}get key(){return this._key}get errors(){return this._errors}_validate(){if(Object.keys(this._dom).length>0){const t={};for(const s of Object.keys(this._dom))Array.isArray(this._dom[s])&&this._dom[s].forEach((r,a)=>{t[`${s}Element[${a}]`]=r}),t[`${s}Element`]=this._dom[s];const e=d(HTMLElement,t);e||(this._errors.push(e.message),this._valid=!1)}if(Object.keys(this._selectors).length>0){const t={};for(const s of Object.keys(this._selectors))t[`${s}Selector`]=this._selectors[s];const e=v(t);e||(this._errors.push(e.message),this._valid=!1)}if(Object.keys(this._classes).length>0){const t={};for(const s of Object.keys(this._classes))this._classes[s]!==""&&(t[`${s}Class`]=this._classes[s]);const e=u(t);e.status||(this._errors.push(e.error.message),this._valid=!1)}if(Object.keys(this._durations).length>0){const t={};for(const s of Object.keys(this._durations))t[`${s}Duration`]=this._durations[s];const e=i("number",t);e.status||(this._errors.push(e.error.message),this._valid=!1)}if(Object.keys(this.delays).length>0){const t={};for(const s of Object.keys(this.delays))t[`${s}Delay`]=this.delays[s];const e=i("number",t);e.status||(this._errors.push(e.error.message),this._valid=!1)}if(this._key!==""){const t=i("string",{key:this._key});t.status||(this._errors.push(t.error.message),this._valid=!1)}if(this._prefix!==""){const t=i("string",{prefix:this._prefix});t.status||(this._errors.push(t.error.message),this._valid=!1)}return this._valid}_generateKey(t=!1){(this._key===""||t)&&(this._key=Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,10))}_setIds(){}_setAriaAttributes(){}_setCustomProps(){}_setDOMElementType(t,{context:e,overwrite:s=!0,strict:r=!0}={}){if(typeof this.selectors[t]!="string")throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid element type.`);if(this._protectedDOMElements.includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" element cannot be set through _setDOMElementType because it is a protected element.`);d(HTMLElement,{context:e});const a=Array.from(e.querySelectorAll(this.selectors[t])).filter(o=>r?o.parentElement===e:!0);Array.isArray(this._dom[t])?s?this._dom[t]=a:this._dom[t]=[...this._dom[t],...a]:this._dom[t]=a[0]||null}_resetDOMElementType(t){if(typeof this.selectors[t]!="string")throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid element type.`);if(this._protectedDOMElements.includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" element cannot be reset through _resetDOMElementType because it is a protected element.`);Array.isArray(this._dom[t])?this._dom[t]=[]:this._dom[t]=null}_setDOMElements(){}_createChildElements(){}_handleMediaMatch(){this._breakpointWidth!==""&&(this._mediaQueryList=window.matchMedia(this.mediaQuery),this._mediaQueryList.addEventListener("change",this._mediaQueryListEventCallback),this._mediaQueryListEventCallback(this._mediaQueryList))}_handleFocus(){}_handleClick(){}_handleKeydown(){}_handleKeyup(){}_store(){p.initializeStorage(this._storageKey),p.pushToStorage(this._storageKey,this._id!==""?this._id:this._key,this)}_unstore(){p.removeFromStorage(this._storageKey,this._id!==""?this._id:this._key)}_setInterval(t,e,s="_default"){this._clearInterval(s),this._intervals[s]=setInterval(t,e)}_clearInterval(t="_default"){clearInterval(this._intervals[t])}_setTimeout(t,e,s="_default"){this._clearTimeout(s),this._timeouts[s]=setTimeout(t,e)}_clearTimeout(t="_default"){clearTimeout(this._timeouts[t])}_dispatchEvent(t,e){if(!Object.keys(this.events).includes(t))throw new Error(`Graupl ${this.constructor.name}: "${t}" is not a valid event type.`);d(HTMLElement,{element:e}),e.dispatchEvent(this.events[t])}_addEventListener(t,e,s,r={}){e.addEventListener(t,s,r),this._listeners.push({type:t,element:e,listener:s,options:r})}_removeEventListener(t,e,s,r={}){e.removeEventListener(t,s,r);const a=this._listeners.indexOf({type:t,element:e,listener:s,options:r});a!==-1&&this._listeners.splice(a)}_removeEventListeners(){this._listeners.forEach(({type:t,element:e,listener:s,options:r})=>{this._removeEventListener(t,e,s,r)})}dispose(){this._removeEventListeners(),this._unstore(),delete this}},Y=X,Z=class extends Y{_dom={carousel:null,carouselItems:[],carouselItemContainer:null,carouselControls:[],carouselControlContainer:null,carouselTabs:[],carouselTabContainer:null,autoplay:null,next:null,previous:null};_protectedDOMElements=["carousel"];_selectors={carouselItems:"",carouselItemContainer:"",carouselControls:"",carouselControlContainer:"",carouselTabs:"",carouselTabContainer:"",autoplay:"",next:"",previous:""};_classes={active:"active",previous:"previous",next:"next",play:"play",pause:"pause",initialize:"initializing"};_durations={transition:250};_delays={transition:1e4};_currentItem=0;_autoplay=!0;_playText="Play";_pauseText="Pause";_currentAction="next";_storageKey="carousels";constructor({carouselElement:t,carouselItemSelector:e=".carousel-item",carouselItemContainerSelector:s=".carousel-item-container",carouselControlSelector:r=".carousel-control",carouselControlContainerSelector:a=".carousel-control-container",carouselTabSelector:o=".carousel-tab",carouselTabContainerSelector:I=".carousel-tab-container",autoplaySelector:T=".autoplay",nextSelector:k=".next",previousSelector:x=".previous",activeClass:A="active",previousClass:$="previous",nextClass:L="next",playClass:S="play",pauseClass:D="pause",autoplay:O=!0,transitionDelay:j=1e4,transitionDuration:M=500,playText:z="Play",pauseText:Q="Pause",prefix:G="graupl-",key:V=null,initializeClass:F="initializing",initialize:K=!1}){super({prefix:G,key:V,initializeClass:F}),this._dom.carousel=t,this._selectors.carouselItems=e,this._selectors.carouselItemContainer=s,this._selectors.carouselControls=r,this._selectors.carouselControlContainer=a,this._selectors.carouselTabs=o,this._selectors.carouselTabContainer=I,this._selectors.autoplay=T,this._selectors.next=k,this._selectors.previous=x,this._classes.active=A||"",this._classes.previous=$||"",this._classes.next=L||"",this._classes.play=S||"",this._classes.pause=D||"",this._autoplay=O,this._delays.transition=j,this._durations.transition=M,this._playText=z||"",this._pauseText=Q||"",K&&this.initialize()}initialize(){try{n(this._classes.initialize,this.dom.carousel),super.initialize(),this._setDOMElements(),this._setIds(),this._setAriaAttributes(),this._setCustomProps(),this.activateFirstItem(),this._handleAutoplay(),this._handleFocus(),this._handleClick(),this._handleHover(),this._handleKeydown(),this._handleKeyup(),this._store()}catch(t){console.error(t)}finally{requestAnimationFrame(()=>{l(this.initializeClass,this.dom.carousel)})}}get activeClass(){return this._classes.active}set activeClass(t){u({activeClass:t}),this._classes.active!==t&&(this._classes.active=t)}get previousClass(){return this._classes.previous}set previousClass(t){u({previousClass:t}),this._classes.previous!==t&&(this._classes.previous=t)}get nextClass(){return this._classes.next}set nextClass(t){u({nextClass:t}),this._classes.next!==t&&(this._classes.next=t)}get playClass(){return this._classes.play}set playClass(t){u({playClass:t}),this._classes.play!==t&&(this._classes.play=t)}get pauseClass(){return this._classes.pause}set pauseClass(t){u({pauseClass:t}),this._classes.pause!==t&&(this._classes.pause=t)}get currentItem(){return this._currentItem}set currentItem(t){i("number",{currentItem:t}),t!==this.currentItem&&(t<0?this._currentItem=0:t>=this.dom.carouselItems.length?this._currentItem=this.dom.carouselItems.length-1:this._currentItem=t,this._dom.carousel.querySelectorAll(this.selectors.carouselTab)&&this.dom.carouselItems.forEach((e,s)=>{e.setAttribute("aria-selected",s===this._currentItem)}))}get currentCarouselItem(){return this.dom.carouselItems[this.currentItem]}get currentCarouselTab(){return this.dom.carouselTabs[this.currentItem]}get autoplay(){return this._autoplay}set autoplay(t){i("boolean",{autoplay:t}),this._autoplay!==t&&(this._autoplay=t)}get transitionDelay(){return this._delays.transition}set transitionDelay(t){i("number",{transitionDelay:t}),t!==this.transitionDelay&&t>=0&&(this._delays.transition=t)}get transitionDuration(){return this._durations.transition}set transitionDuration(t){i("number",{transitionDuration:t}),this._durations.transition!==t&&t>=0&&(this._durations.transition=t,this._setTransitionDuration())}get playText(){return this._playText}set playText(t){i("string",{playText:t}),this._playText!==t&&(this._playText=t)}get pauseText(){return this._pauseText}set pauseText(t){i("string",{pauseText:t}),this._pauseText!==t&&(this._pauseText=t)}get currentAction(){return this._currentAction}_validate(){super._validate();const t=i("boolean",{autoplay:this._autoplay});t||(this._errors.push(t.message),this._valid=!1);const e=i("string",{playText:this._playText,pauseText:this._pauseText});return e||(this._errors.push(e.message),this._valid=!1),this._valid}_setDOMElements(){this._setDOMElementType("carouselItemContainer",{context:this.dom.carousel}),this._setDOMElementType("carouselControlContainer",{context:this.dom.carousel}),this._setDOMElementType("carouselTabContainer",{context:this.dom.carousel}),this.dom.carouselItemContainer&&this._setDOMElementType("carouselItems",{context:this.dom.carouselItemContainer}),this.dom.carouselControlContainer&&(this._setDOMElementType("carouselControls",{context:this.dom.carouselControlContainer}),this._setDOMElementType("autoplay",{context:this.dom.carouselControlContainer}),this._setDOMElementType("next",{context:this.dom.carouselControlContainer}),this._setDOMElementType("previous",{context:this.dom.carouselControlContainer})),this._dom.carouselTabContainer&&this._setDOMElementType("carouselTabs",{context:this.dom.carouselTabContainer})}_setIds(){this.dom.carousel.id=this.dom.carousel.id||`carousel-${this.key}`,this.dom.carouselItems.forEach((t,e)=>{t.id=t.id||`carousel-item-${this.key}-${e}`}),this.dom.carouselTabs.forEach((t,e)=>{t.id=t.id||`carousel-tab-${this.key}-${e}`}),this._id=this.dom.carousel.id}_setAriaAttributes(){!E("section",{carousel:this.dom.carousel})&&!this.dom.carousel.getAttribute("role")!=="region"&&this.dom.carousel.setAttribute("role","group"),this._dom.carousel.setAttribute("aria-roledescription","carousel"),this.dom.carouselTabContainer&&this.dom.carouselTabContainer.setAttribute("role","tablist"),this.dom.carouselTabs.forEach((t,e)=>{E("button",{tab:t})||t.setAttribute("role","button"),t.setAttribute("aria-selected",e===0),t.setAttribute("aria-controls",this.dom.carouselItems[e].id)})}_setCustomProps(){this.dom.carousel.style.setProperty(`--${this.prefix}carousel-transition-duration`,`${this.transitionDuration}ms`)}_handleAutoplay(){this.autoplay?(n(this.pauseClass,this.dom.autoplay),l(this.playClass,this.dom.autoplay),this.dom.autoplay.setAttribute("aria-label",this.pauseText),this.dom.carousel.setAttribute("aria-live","off"),this._setInterval(()=>this.activateNextItem(),this.transitionDelay)):(n(this.playClass,this.dom.autoplay),l(this.pauseClass,this.dom.autoplay),this.dom.autoplay.setAttribute("aria-label",this.playText),this.dom.carousel.setAttribute("aria-live","polite"),this._clearInterval())}_handleFocus(){this._addEventListener("focusin",this.dom.carousel,()=>{this.autoplay&&this._clearInterval()}),this._addEventListener("focusout",this.dom.carousel,()=>{this.autoplay&&this._setInterval(()=>this.activateNextItem(),this.transitionDelay)})}_handleClick(){this._addEventListener("pointerup",this.dom.next,()=>{this.activateNextItem()}),this._addEventListener("pointerup",this.dom.previous,()=>{this.activatePreviousItem()}),this._addEventListener("pointerup",this.dom.autoplay,()=>{this.toggleAutoplay()}),this.dom.carouselTabs.forEach((t,e)=>{this._addEventListener("pointerup",t,()=>{this.currentItem>e?this._currentAction="previous":this._currentAction="next",this.activateItem(e)})})}_handleHover(){this._addEventListener("pointerover",this.dom.carousel,()=>{this.autoplay&&this._clearInterval()}),this._addEventListener("pointerleave",this.dom.carousel,()=>{this.autoplay&&this._setInterval(()=>this.activateNextItem(),this.transitionDelay)})}_handleKeydown(){this.dom.carouselControls.forEach(t=>{this._addEventListener("keydown",t,e=>{switch(c(e)){case"Space":case"Enter":h(e);break}})}),this.dom.carouselTabs.forEach(t=>{this._addEventListener("keydown",t,e=>{switch(c(e)){case"Space":case"Enter":h(e);break}})})}_handleKeyup(){this._addEventListener("keyup",this.dom.next,t=>{switch(c(t)){case"Space":case"Enter":this.activateNextItem(),h(t);break}}),this._addEventListener("keyup",this.dom.previous,t=>{switch(c(t)){case"Space":case"Enter":this.activatePreviousItem(),h(t);break}}),this._addEventListener("keyup",this.dom.autoplay,t=>{switch(c(t)){case"Space":case"Enter":this.toggleAutoplay(),h(t);break}}),this.dom.carouselTabs.forEach((t,e)=>{this._addEventListener("keyup",t,s=>{switch(c(s)){case"Space":case"Enter":this.activateItem(e),h(s);break}})})}activateCurrentItem(){n(this.activeClass,this.currentCarouselItem),this.currentCarouselTab&&(this.currentCarouselTab.setAttribute("aria-selected",!0),n(this.activeClass,this.currentCarouselTab))}deactivateCurrentItem(){l(this.activeClass,this.currentCarouselItem),this.currentCarouselTab&&(this.currentCarouselTab.setAttribute("aria-selected",!1),l(this.activeClass,this.currentCarouselTab))}activateItem(t){const e=this.currentItem;this.dom.carousel.dataset.grauplAction=this._currentAction,this.autoplay&&this._clearInterval(),n(this.previousClass,this.currentCarouselItem),n(this.nextClass,this.dom.carouselItems[t]),requestAnimationFrame(()=>{this.deactivateCurrentItem(),this.currentItem=t,this.activateCurrentItem(),requestAnimationFrame(()=>{setTimeout(()=>{l(this.previousClass,this.dom.carouselItems[e]),l(this.nextClass,this.currentCarouselItem)},this.transitionDuration)})}),this.autoplay&&this._setInterval(()=>this.activateNextItem(),this.transitionDelay)}activateFirstItem(){this.activateItem(0)}activateLastItem(){this.activateItem(this.dom.carouselItems.length-1)}activateNextItem(){this._currentAction="next",this.currentItem+1>=this.dom.carouselItems.length?this.activateFirstItem():this.activateItem(this.currentItem+1)}activatePreviousItem(){this._currentAction="previous",this.currentItem-1<0?this.activateLastItem():this.activateItem(this.currentItem-1)}toggleAutoplay(){this.autoplay=!this.autoplay,this._handleAutoplay()}},tt=Z;const C=/[\11\12\14\15\40]+/,y="data-once",et=document;function g(t,e,s){return t[`${e}Attribute`](y,s)}function _(t){if(typeof t!="string")throw new TypeError("once ID must be a string");if(t===""||C.test(t))throw new RangeError("once ID must not be empty or contain spaces");return`[${y}~="${t}"]`}function st(t){if(!(t instanceof Element))throw new TypeError("The element must be an instance of Element");return!0}function m(t,e=et){let s=t;if(t===null)s=[];else if(t)if(e instanceof Document||e instanceof DocumentFragment||e instanceof Element)typeof t=="string"?s=e.querySelectorAll(t):t instanceof Element&&(s=[t]);else throw new TypeError('Context must be an object of type "Document", "DocumentFragment", or "Element".');else throw new TypeError("Selector must not be empty");return Array.prototype.slice.call(s)}function b(t,e,s){return e.filter(r=>{const a=st(r)&&r.matches(t);return a&&s&&s(r),a})}function w(t,{add:e,remove:s}){const r=[];g(t,"has")&&g(t,"get").trim().split(C).forEach(o=>{r.indexOf(o)<0&&o!==s&&r.push(o)}),e&&r.push(e);const a=r.join(" ");g(t,a===""?"remove":"set",a)}function f(t,e,s){return b(`:not(${_(t)})`,m(e,s),r=>w(r,{add:t}))}f.remove=(t,e,s)=>b(_(t),m(e,s),r=>w(r,{remove:t})),f.filter=(t,e,s)=>b(_(t),m(e,s)),f.find=(t,e)=>m(t?_(t):`[${y}]`,e);var rt=f;const it=(t={},e=document,s=".carousel")=>{rt("graupl-carousel-generator",s,e).forEach(r=>{const a=r.dataset.grauplCarouselOptions?JSON.parse(r.dataset.grauplCarouselOptions.replace(/'/g,'"'))||{}:{};new tt({carouselElement:r,initialize:!0,...t,...a})})};var at=it;module.exports=at;
|
|
4
4
|
|
|
5
5
|
//# sourceMappingURL=carousel.cjs.js.map
|