@graupl/core 1.0.0-beta.14 → 1.0.0-beta.16
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/base/button.css +1 -1
- package/dist/css/base/button.css.map +1 -1
- package/dist/css/base/form.css +1 -1
- package/dist/css/base/form.css.map +1 -1
- package/dist/css/base/link.css +1 -1
- package/dist/css/base/link.css.map +1 -1
- package/dist/css/base/table.css.map +1 -1
- package/dist/css/base.css +1 -1
- package/dist/css/base.css.map +1 -1
- package/dist/css/component/accordion.css +2 -2
- package/dist/css/component/accordion.css.map +1 -1
- package/dist/css/component/alert.css +1 -1
- package/dist/css/component/alert.css.map +1 -1
- package/dist/css/component/carousel.css +1 -1
- package/dist/css/component/carousel.css.map +1 -1
- package/dist/css/component.css +2 -2
- package/dist/css/component.css.map +1 -1
- package/dist/css/graupl.css +2 -2
- package/dist/css/graupl.css.map +1 -1
- package/dist/css/layout.css +2 -2
- package/dist/css/layout.css.map +1 -1
- package/dist/css/state/focus.css +1 -1
- package/dist/css/state/focus.css.map +1 -1
- package/dist/css/state.css +1 -1
- package/dist/css/state.css.map +1 -1
- package/dist/css/theme/color.css +1 -1
- package/dist/css/theme/color.css.map +1 -1
- package/dist/css/theme.css +1 -1
- package/dist/css/theme.css.map +1 -1
- package/dist/css/utilities/border.css +1 -1
- package/dist/css/utilities/border.css.map +1 -1
- package/dist/css/utilities/color.css +1 -1
- package/dist/css/utilities/color.css.map +1 -1
- package/dist/css/utilities/gradient.css +1 -1
- package/dist/css/utilities/gradient.css.map +1 -1
- package/dist/css/utilities/order.css.map +1 -1
- package/dist/css/utilities/typography.css +1 -1
- package/dist/css/utilities/typography.css.map +1 -1
- package/dist/css/utilities/visually-hidden.css.map +1 -1
- package/dist/css/utilities.css +1 -1
- package/dist/css/utilities.css.map +1 -1
- package/dist/js/accordion.js.map +1 -1
- package/dist/js/alert.js.map +1 -1
- package/dist/js/carousel.js.map +1 -1
- package/dist/js/component/accordion.cjs.js.map +1 -1
- package/dist/js/component/accordion.es.js.map +1 -1
- package/dist/js/component/accordion.iife.js.map +1 -1
- package/dist/js/component/alert.cjs.js.map +1 -1
- package/dist/js/component/alert.es.js.map +1 -1
- package/dist/js/component/alert.iife.js.map +1 -1
- package/dist/js/component/carousel.cjs.js.map +1 -1
- package/dist/js/component/carousel.es.js.map +1 -1
- package/dist/js/component/carousel.iife.js.map +1 -1
- package/dist/js/generator/accordion.cjs.js.map +1 -1
- package/dist/js/generator/accordion.es.js.map +1 -1
- package/dist/js/generator/accordion.iife.js.map +1 -1
- package/dist/js/generator/alert.cjs.js.map +1 -1
- package/dist/js/generator/alert.es.js.map +1 -1
- package/dist/js/generator/alert.iife.js.map +1 -1
- package/dist/js/generator/carousel.cjs.js.map +1 -1
- package/dist/js/generator/carousel.es.js.map +1 -1
- package/dist/js/generator/carousel.iife.js.map +1 -1
- package/dist/js/generator/navigation.cjs.js.map +1 -1
- package/dist/js/generator/navigation.es.js.map +1 -1
- package/dist/js/generator/navigation.iife.js.map +1 -1
- package/dist/js/graupl.js.map +1 -1
- package/dist/js/navigation.js.map +1 -1
- package/package.json +1 -1
- package/src/js/domHelpers.js +5 -10
- package/src/scss/_defaults.scss +147 -29
- package/src/scss/base/button/_defaults.scss +21 -5
- package/src/scss/base/button/_mixins.scss +1 -1
- package/src/scss/base/table/_defaults.scss +15 -2
- package/src/scss/base/table/_index.scss +4 -7
- package/src/scss/component/alert/_defaults.scss +22 -5
- package/src/scss/component/alert/_index.scss +1 -1
- package/src/scss/functions/_theme.scss +14 -2
- package/src/scss/theme/color/_defaults.scss +84 -14
- package/src/scss/theme/color/_index.scss +18 -3
- package/src/scss/theme/color/_variables.scss +63 -30
- package/src/scss/theme/typography/_defaults.scss +37 -7
- package/src/scss/utilities/_template/_defaults.scss +7 -6
- package/src/scss/utilities/_template/_index.scss +2 -2
- package/src/scss/utilities/alignment/_defaults.scss +53 -15
- package/src/scss/utilities/alignment/_index.scss +4 -6
- package/src/scss/utilities/background/_defaults.scss +117 -35
- package/src/scss/utilities/background/_index.scss +8 -14
- package/src/scss/utilities/border/_defaults.scss +77 -15
- package/src/scss/utilities/border/_index.scss +73 -75
- package/src/scss/utilities/color/_defaults.scss +55 -7
- package/src/scss/utilities/color/_index.scss +143 -144
- package/src/scss/utilities/container/_defaults.scss +21 -5
- package/src/scss/utilities/container/_index.scss +2 -2
- package/src/scss/utilities/display/_defaults.scss +18 -5
- package/src/scss/utilities/display/_index.scss +2 -2
- package/src/scss/utilities/flex/_defaults.scss +88 -25
- package/src/scss/utilities/flex/_index.scss +6 -10
- package/src/scss/utilities/gradient/_defaults.scss +64 -9
- package/src/scss/utilities/gradient/_index.scss +127 -129
- package/src/scss/utilities/height/_defaults.scss +27 -2
- package/src/scss/utilities/height/_index.scss +169 -163
- package/src/scss/utilities/inset/_defaults.scss +25 -4
- package/src/scss/utilities/inset/_index.scss +3 -4
- package/src/scss/utilities/justification/_defaults.scss +53 -15
- package/src/scss/utilities/justification/_index.scss +4 -6
- package/src/scss/utilities/list/_defaults.scss +37 -10
- package/src/scss/utilities/list/_index.scss +3 -4
- package/src/scss/utilities/order/_defaults.scss +33 -2
- package/src/scss/utilities/order/_index.scss +55 -67
- package/src/scss/utilities/position/_defaults.scss +18 -5
- package/src/scss/utilities/position/_index.scss +2 -2
- package/src/scss/utilities/ratio/_defaults.scss +15 -2
- package/src/scss/utilities/ratio/_index.scss +2 -2
- package/src/scss/utilities/spacing/_defaults.scss +18 -5
- package/src/scss/utilities/spacing/_index.scss +2 -2
- package/src/scss/utilities/typography/_defaults.scss +146 -12
- package/src/scss/utilities/typography/_index.scss +854 -704
- package/src/scss/utilities/visibility/_defaults.scss +20 -5
- package/src/scss/utilities/visibility/_index.scss +2 -2
- package/src/scss/utilities/visually-hidden/_defaults.scss +1 -0
- package/src/scss/utilities/visually-hidden/_index.scss +1 -0
- package/src/scss/utilities/width/_defaults.scss +27 -2
- package/src/scss/utilities/width/_index.scss +163 -163
- package/src/scss/utilities/z-index/_defaults.scss +17 -5
- package/src/scss/utilities/z-index/_index.scss +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation.js","names":["isValidInstance","contructor","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","isValidType","initializeStorage","type","window","Graupl","getStorage","setStorage","data","clearStorage","pushToStorage","key","value","getFromStorage","removeFromStorage","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","storage","once","generate","options","context","document","navigationSelector","forEach","navigationElement","MenuConstructor","dataset","grauplMenuType","DisclosureMenu","window","undefined","console","warn","menuOptions","grauplMenuOptions","JSON","parse","replace","menuElement","querySelector","controllerElement","containerElement","menu","menuItemSelector","menuLinkSelector","submenuItemSelector","submenuToggleSelector","initializeStorage","pushToStorage","dom","id","generate","document","addEventListener"],"sources":["../../src/js/validate.js","../../src/js/storage.js","../../../../node_modules/@drupal/once/src/once.js","../../src/js/navigation/generator.js","../../src/js/navigation/index.js"],"sourcesContent":["/**\n * Check to see if the provided elements have a specific contructor.\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} contructor - 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(contructor, 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 contructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `${key} must be an instance of ${contructor.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 * @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 * 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 storage from \"../storage.js\";\nimport once from \"@drupal/once\";\n\nconst generate = (\n options = {},\n context = document,\n navigationSelector = \".navigation\"\n) => {\n once(\"graupl-navigation-generator\", navigationSelector, context).forEach(\n (navigationElement) => {\n const MenuConstructor =\n navigationElement.dataset.grauplMenuType || DisclosureMenu;\n\n if (window[MenuConstructor] === undefined) {\n console.warn(\n `Graupl navigation requires accessible-menu's ${MenuConstructor}. Please make sure to include it on this page.`\n );\n\n return;\n }\n\n const menuOptions = navigationElement.dataset.grauplMenuOptions\n ? JSON.parse(\n navigationElement.dataset.grauplMenuOptions.replace(/'/g, '\"')\n ) || {}\n : {};\n const menuElement = navigationElement.querySelector(\".menu\");\n const controllerElement =\n navigationElement.querySelector(\".navigation-toggle\") || null;\n const containerElement = controllerElement ? navigationElement : null;\n const menu = new window[MenuConstructor]({\n menuElement,\n menuItemSelector: \".menu-item\",\n menuLinkSelector: \".menu-link\",\n submenuItemSelector: \".submenu-item\",\n submenuToggleSelector: \".submenu-toggle\",\n controllerElement,\n containerElement,\n ...options,\n ...menuOptions,\n });\n\n storage.initializeStorage(\"menus\");\n storage.pushToStorage(\"menus\", menu.dom.menu.id, menu);\n }\n );\n};\n\nexport default generate;\n","import generate from \"./generator.js\";\n\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n generate();\n});\n"],"x_google_ignoreList":[2],"mappings":"YA6DA,SAAgBuC,EAAYE,EAAM7B,EAAQ,CACxC,GAAI,CACF,GAAA,OAAWA,GAAW,SAAU,CAC9B,MAAMC,EAAAA,OAAoBD,EAE1B,MAAM,IAAImD,UAAAA,+DACuDlD,CAAAA,UAAU,CAE7E,CAEA,UAAWoC,KAAOrC,EAAQ,CACxB,MAAME,EAAAA,OAAmBF,EAAOqC,CAAAA,EAEhC,GAAInC,IAAc2B,EAChB,MAAM,IAAIsB,UAAAA,GAAad,CAAAA,cAAiBR,CAAAA,MAAU3B,CAAAA,UAAS,CAE/D,CAEA,MAAO,CACLN,OAAQ,GACRC,MAAO,IACR,CACF,OAAQA,EAAO,CACd,MAAO,CACLD,OAAQ,GACRC,MAAAA,CACD,CACH,CACF,CC7EA,SAAgByH,EAAkBzF,EAAO,KAAM,CAC7CuE,OAAOrE,OAASqE,OAAOr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ACHZ,EAAkBE,QAAQQ,kBAAkBG,QAAQ,KAAM,GAAA,CAC5D,GAAK,CAAE,EACP,CAAE,EACAC,EAAcd,EAAkBe,cAAc,OAAA,EAC9CC,EACJhB,EAAkBe,cAAc,oBAAA,GAAyB,KACrDE,EAAmBD,EAAoBhB,EAAoB,KAC3DkB,EAAO,IAAIb,OAAOJ,CAAAA,EAAiB,CACvCa,YAAAA,EACAK,iBAAkB,aAClBC,iBAAkB,aAClBC,oBAAqB,gBACrBC,sBAAuB,kBACvBN,kBAAAA,EACAC,iBAAAA,EACA,GAAGtB,EACH,GAAGc,CACJ,CAAA,EAEDjB,EAAQ+B,kBAAkB,OAAA,EAC1B/B,EAAQgC,cAAc,QAASN,EAAKO,IAAIP,KAAKQ,GAAIR,CAAAA,CAErD,CAAA,CACD,EC5CDU,SAASC,iBAAiB,mBAAoB,UAAY,CACxDF,EAAAA,CACD,CAAA"}
|
|
1
|
+
{"version":3,"file":"navigation.js","names":["isValidInstance","contructor","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","isValidType","initializeStorage","type","window","Graupl","getStorage","setStorage","data","clearStorage","pushToStorage","key","value","getFromStorage","removeFromStorage","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","storage","once","generate","options","context","document","navigationSelector","forEach","navigationElement","MenuConstructor","dataset","grauplMenuType","DisclosureMenu","window","undefined","console","warn","menuOptions","grauplMenuOptions","JSON","parse","replace","menuElement","querySelector","controllerElement","containerElement","menu","menuItemSelector","menuLinkSelector","submenuItemSelector","submenuToggleSelector","initializeStorage","pushToStorage","dom","id","generate","document","addEventListener"],"sources":["../../src/js/validate.js","../../src/js/storage.js","../../../../node_modules/@drupal/once/src/once.js","../../src/js/navigation/generator.js","../../src/js/navigation/index.js"],"sourcesContent":["/**\n * Check to see if the provided elements have a specific contructor.\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} contructor - 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(contructor, 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 contructor)) {\n const elementType = typeof elements[key];\n throw new TypeError(\n `${key} must be an instance of ${contructor.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 * @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 * 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 storage from \"../storage.js\";\nimport once from \"@drupal/once\";\n\nconst generate = (\n options = {},\n context = document,\n navigationSelector = \".navigation\"\n) => {\n once(\"graupl-navigation-generator\", navigationSelector, context).forEach(\n (navigationElement) => {\n const MenuConstructor =\n navigationElement.dataset.grauplMenuType || DisclosureMenu;\n\n if (window[MenuConstructor] === undefined) {\n console.warn(\n `Graupl navigation requires accessible-menu's ${MenuConstructor}. Please make sure to include it on this page.`\n );\n\n return;\n }\n\n const menuOptions = navigationElement.dataset.grauplMenuOptions\n ? JSON.parse(\n navigationElement.dataset.grauplMenuOptions.replace(/'/g, '\"')\n ) || {}\n : {};\n const menuElement = navigationElement.querySelector(\".menu\");\n const controllerElement =\n navigationElement.querySelector(\".navigation-toggle\") || null;\n const containerElement = controllerElement ? navigationElement : null;\n const menu = new window[MenuConstructor]({\n menuElement,\n menuItemSelector: \".menu-item\",\n menuLinkSelector: \".menu-link\",\n submenuItemSelector: \".submenu-item\",\n submenuToggleSelector: \".submenu-toggle\",\n controllerElement,\n containerElement,\n ...options,\n ...menuOptions,\n });\n\n storage.initializeStorage(\"menus\");\n storage.pushToStorage(\"menus\", menu.dom.menu.id, menu);\n }\n );\n};\n\nexport default generate;\n","import generate from \"./generator.js\";\n\ndocument.addEventListener(\"DOMContentLoaded\", function () {\n generate();\n});\n"],"x_google_ignoreList":[2],"mappings":"YA6DA,SAAgBuC,EAAYE,EAAM7B,EAAQ,CACxC,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AAAA,CAAQ,EA6BlEH,EAAKF,KAAO,CAACmC,EAAI9B,IACflC,EAAagE,EAAuBxE,EAAawE,CAAAA,EAA/B,IAAI/E,CAAAA,IAAgCiD,CAAAA,EAExD,IAAA,EAAeH,EChWf,EA7CiBkC,CACfhC,EAAU,CAAE,EACZC,EAAUgC,SACV9B,EAAqB,gBAClB,CACHL,EAAK,8BAA+BK,EAAoBF,CAAAA,EAASG,QAC9DC,GAAsB,CACrB,MAAMC,EACJD,EAAkBE,QAAQC,gBAAkBC,eAE9C,GAAIC,OAAOJ,CAAAA,IAAAA,OAAgC,CACzCM,QAAQC,KACN,gDAAgDP,CAAAA,gDAClD,EAEA,MACF,CAEA,MAAMQ,EAAcT,EAAkBE,QAAQQ,kBAC1CC,KAAKC,MACHZ,EAAkBE,QAAQQ,kBAAkBG,QAAQ,KAAM,GAAA,CAC5D,GAAK,CAAE,EACP,CAAE,EACAC,EAAcd,EAAkBe,cAAc,OAAA,EAC9CC,EACJhB,EAAkBe,cAAc,oBAAA,GAAyB,KACrDE,EAAmBD,EAAoBhB,EAAoB,KAC3DkB,EAAO,IAAIb,OAAOJ,CAAAA,EAAiB,CACvCa,YAAAA,EACAK,iBAAkB,aAClBC,iBAAkB,aAClBC,oBAAqB,gBACrBC,sBAAuB,kBACvBN,kBAAAA,EACAC,iBAAAA,EACA,GAAGtB,EACH,GAAGc,CACJ,CAAA,EAEDjB,EAAQ+B,kBAAkB,OAAA,EAC1B/B,EAAQgC,cAAc,QAASN,EAAKO,IAAIP,KAAKQ,GAAIR,CAAAA,CAErD,CAAA,CACD,EC5CDU,SAASC,iBAAiB,mBAAoB,UAAY,CACxDF,EAAAA,CACD,CAAA"}
|
package/package.json
CHANGED
package/src/js/domHelpers.js
CHANGED
|
@@ -40,8 +40,7 @@ export function removeClass(className, element) {
|
|
|
40
40
|
* Select all focusable elements within a given context.
|
|
41
41
|
*
|
|
42
42
|
* @param {HTMLElement} [context = document] - The context in which to search for focusable elements.
|
|
43
|
-
*
|
|
44
|
-
* @returns {HTMLElement[]}
|
|
43
|
+
* @return {HTMLElement[]} - An array of focusable elements.
|
|
45
44
|
*/
|
|
46
45
|
export function selectAllFocusableElements(context = document) {
|
|
47
46
|
const querySelector =
|
|
@@ -63,8 +62,7 @@ export function selectAllFocusableElements(context = document) {
|
|
|
63
62
|
* Select the first focusable element within a given context.
|
|
64
63
|
*
|
|
65
64
|
* @param {HTMLElement} [context = document] - The context in which to search for focusable elements.
|
|
66
|
-
*
|
|
67
|
-
* @returns {HTMLElement|boolean} - The first focusable element or false if none found.
|
|
65
|
+
* @return {HTMLElement|boolean} - The first focusable element or false if none found.
|
|
68
66
|
*/
|
|
69
67
|
export function selectFirstFocusableElement(context = document) {
|
|
70
68
|
const tabbableElements = selectAllFocusableElements(context);
|
|
@@ -76,8 +74,7 @@ export function selectFirstFocusableElement(context = document) {
|
|
|
76
74
|
* Select the last focusable element within a given context.
|
|
77
75
|
*
|
|
78
76
|
* @param {HTMLElement} [context = document] - The context in which to search for focusable elements.
|
|
79
|
-
*
|
|
80
|
-
* @returns {HTMLElement|boolean} - The last focusable element or false if none found.
|
|
77
|
+
* @return {HTMLElement|boolean} - The last focusable element or false if none found.
|
|
81
78
|
*/
|
|
82
79
|
export function selectLastFocusableElement(context = document) {
|
|
83
80
|
const tabbableElements = selectAllFocusableElements(context);
|
|
@@ -90,8 +87,7 @@ export function selectLastFocusableElement(context = document) {
|
|
|
90
87
|
*
|
|
91
88
|
* @param {HTMLElement} element - The reference element.
|
|
92
89
|
* @param {HTMLElement} [context = document] - The context in which to search for focusable elements.
|
|
93
|
-
*
|
|
94
|
-
* @returns {HTMLElement|boolean} - The next focusable element or false if none found.
|
|
90
|
+
* @return {HTMLElement|boolean} - The next focusable element or false if none found.
|
|
95
91
|
*/
|
|
96
92
|
export function selectNextFocusableElement(element, context = document) {
|
|
97
93
|
const tabbableElements = selectAllFocusableElements(context);
|
|
@@ -107,8 +103,7 @@ export function selectNextFocusableElement(element, context = document) {
|
|
|
107
103
|
*
|
|
108
104
|
* @param {HTMLElement} element - The reference element.
|
|
109
105
|
* @param {HTMLElement} [context = document] - The context in which to search for focusable elements.
|
|
110
|
-
*
|
|
111
|
-
* @returns {HTMLElement|boolean} - The previous focusable element or false if none found.
|
|
106
|
+
* @return {HTMLElement|boolean} - The previous focusable element or false if none found.
|
|
112
107
|
*/
|
|
113
108
|
export function selectPreviousFocusableElement(element, context = document) {
|
|
114
109
|
const tabbableElements = selectAllFocusableElements(context);
|
package/src/scss/_defaults.scss
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
// They should not be used to define direct property values (i.e. font-size, color, etc.).
|
|
7
7
|
// Those should be defined as custom properties in the `_variables.scss` file.
|
|
8
8
|
|
|
9
|
+
@use "sass:list";
|
|
9
10
|
@use "sass:map";
|
|
10
11
|
|
|
11
12
|
// Prefix for custom properties and other naming conventions.
|
|
@@ -14,6 +15,13 @@ $prefix: "#{$id}-" !default;
|
|
|
14
15
|
|
|
15
16
|
// Settings.
|
|
16
17
|
$use-important: true !default;
|
|
18
|
+
$generate-base-colors: true !default;
|
|
19
|
+
$generate-base-themes: true !default;
|
|
20
|
+
$generate-base-theme-maps: true !default;
|
|
21
|
+
$generate-base-font-sizes: true !default;
|
|
22
|
+
$generate-base-font-weights: true !default;
|
|
23
|
+
$generate-state-classes: true !default;
|
|
24
|
+
$generate-base-utilities: true !default;
|
|
17
25
|
$screen-aware-utilities: true !default;
|
|
18
26
|
$theme-aware-utilities: true !default;
|
|
19
27
|
$state-aware-utilities: true !default;
|
|
@@ -24,7 +32,7 @@ $use-layers: true !default;
|
|
|
24
32
|
$content-max-width: 96ch !default;
|
|
25
33
|
|
|
26
34
|
// Screen sizes.
|
|
27
|
-
|
|
35
|
+
$-screen-sizes: (
|
|
28
36
|
xs: 0,
|
|
29
37
|
sm: 48ch,
|
|
30
38
|
md: 72ch,
|
|
@@ -32,8 +40,17 @@ $base-screen-sizes: (
|
|
|
32
40
|
xl: 156ch,
|
|
33
41
|
);
|
|
34
42
|
$custom-screen-sizes: () !default;
|
|
35
|
-
$screen-sizes:
|
|
36
|
-
|
|
43
|
+
$screen-sizes: () !default;
|
|
44
|
+
|
|
45
|
+
// @todo remove this once $custom-screen-sizes is removed
|
|
46
|
+
@if $custom-screen-sizes != () {
|
|
47
|
+
@warn "`$custom-screen-sizes` is deprecated and will be removed in a future release of Graupl. Use `$screen-sizes` instead.";
|
|
48
|
+
|
|
49
|
+
$screen-sizes: map.merge($screen-sizes, $custom-screen-sizes);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
$screen-sizes: map.merge($-screen-sizes, $screen-sizes);
|
|
53
|
+
$-screen-size-triggers: (
|
|
37
54
|
navigation-collapse: (
|
|
38
55
|
mixin: "down",
|
|
39
56
|
args: (
|
|
@@ -66,25 +83,55 @@ $base-screen-size-triggers: (
|
|
|
66
83
|
),
|
|
67
84
|
);
|
|
68
85
|
$custom-screen-size-triggers: () !default;
|
|
69
|
-
$screen-size-triggers:
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
)
|
|
86
|
+
$screen-size-triggers: () !default;
|
|
87
|
+
|
|
88
|
+
// @todo remove this once $custom-screen-size-triggers is removed
|
|
89
|
+
@if $custom-screen-size-triggers != () {
|
|
90
|
+
@warn "`$custom-screen-size-triggers` is deprecated and will be removed in a future release of Graupl. Use `$screen-size-triggers` instead.";
|
|
91
|
+
|
|
92
|
+
$screen-size-triggers: map.merge(
|
|
93
|
+
$screen-size-triggers,
|
|
94
|
+
$custom-screen-size-triggers
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
$screen-size-triggers: map.merge($-screen-size-triggers, $screen-size-triggers);
|
|
73
99
|
|
|
74
100
|
// Container sizes.
|
|
75
|
-
|
|
101
|
+
$-container-sizes: $screen-sizes;
|
|
76
102
|
$custom-container-sizes: () !default;
|
|
77
|
-
$container-sizes:
|
|
78
|
-
|
|
103
|
+
$container-sizes: () !default;
|
|
104
|
+
|
|
105
|
+
// @todo remove this once $custom-container-sizes is removed
|
|
106
|
+
@if $custom-container-sizes != () {
|
|
107
|
+
@warn "`$custom-container-sizes` is deprecated and will be removed in a future release of Graupl. Use `$container-sizes` instead.";
|
|
108
|
+
|
|
109
|
+
$container-sizes: map.merge($container-sizes, $custom-container-sizes);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
$container-sizes: map.merge($-container-sizes, $container-sizes);
|
|
113
|
+
$-container-size-triggers: $screen-size-triggers;
|
|
79
114
|
$custom-container-size-triggers: () !default;
|
|
115
|
+
$container-size-triggers: () !default;
|
|
116
|
+
|
|
117
|
+
// @todo remove this once $custom-container-size-triggers is removed
|
|
118
|
+
@if $custom-container-size-triggers != () {
|
|
119
|
+
@warn "`$custom-container-size-triggers` is deprecated and will be removed in a future release of Graupl. Use `$container-size-triggers` instead.";
|
|
120
|
+
|
|
121
|
+
$container-size-triggers: map.merge(
|
|
122
|
+
$container-size-triggers,
|
|
123
|
+
$custom-container-size-triggers
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
80
127
|
$container-size-triggers: map.merge(
|
|
81
|
-
|
|
82
|
-
$
|
|
128
|
+
$-container-size-triggers,
|
|
129
|
+
$container-size-triggers
|
|
83
130
|
);
|
|
84
131
|
|
|
85
132
|
// Spacing properties.
|
|
86
133
|
$spacer: 1rem !default;
|
|
87
|
-
|
|
134
|
+
$-spacer-multipliers: (
|
|
88
135
|
0: 0,
|
|
89
136
|
1: 0.125,
|
|
90
137
|
2: 0.25,
|
|
@@ -98,10 +145,19 @@ $base-spacer-multipliers: (
|
|
|
98
145
|
10: 10,
|
|
99
146
|
);
|
|
100
147
|
$custom-spacer-multipliers: () !default;
|
|
101
|
-
$spacer-multipliers:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
)
|
|
148
|
+
$spacer-multipliers: () !default;
|
|
149
|
+
|
|
150
|
+
// @todo remove this once $custom-spacer-multipliers is removed
|
|
151
|
+
@if $custom-spacer-multipliers != () {
|
|
152
|
+
@warn "`$custom-spacer-multipliers` is deprecated and will be removed in a future release of Graupl. Use `$spacer-multipliers` instead.";
|
|
153
|
+
|
|
154
|
+
$spacer-multipliers: map.merge(
|
|
155
|
+
$spacer-multipliers,
|
|
156
|
+
$custom-spacer-multipliers
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
$spacer-multipliers: map.merge($-spacer-multipliers, $spacer-multipliers);
|
|
105
161
|
|
|
106
162
|
// Size properties.
|
|
107
163
|
$interactive-min-width: 44px !default;
|
|
@@ -115,16 +171,25 @@ $border-style: solid !default;
|
|
|
115
171
|
// Transition properties.
|
|
116
172
|
$transition-duration-base: 100 !default;
|
|
117
173
|
$transition-timing-function: ease !default;
|
|
118
|
-
|
|
174
|
+
$-transition-durations: (
|
|
119
175
|
fast: #{$transition-duration-base * 1.5}ms,
|
|
120
176
|
default: #{$transition-duration-base * 2.5}ms,
|
|
121
177
|
slow: #{$transition-duration-base * 3}ms,
|
|
122
178
|
);
|
|
123
179
|
$custom-transition-durations: () !default;
|
|
124
|
-
$transition-durations:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
)
|
|
180
|
+
$transition-durations: () !default;
|
|
181
|
+
|
|
182
|
+
// @todo remove this once $custom-transition-durations is removed
|
|
183
|
+
@if $custom-transition-durations != () {
|
|
184
|
+
@warn "`$custom-transition-durations` is deprecated and will be removed in a future release of Graupl. Use `$transition-durations` instead.";
|
|
185
|
+
|
|
186
|
+
$transition-durations: map.merge(
|
|
187
|
+
$transition-durations,
|
|
188
|
+
$custom-transition-durations
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
$transition-durations: map.merge($-transition-durations, $transition-durations);
|
|
128
193
|
|
|
129
194
|
// Selector properties.
|
|
130
195
|
$element-selector-base: "" !default;
|
|
@@ -143,32 +208,85 @@ $container-aware-selector-prefix: "cq\\:" !default;
|
|
|
143
208
|
|
|
144
209
|
// State selectors.
|
|
145
210
|
$state-selector-base: $modifier-selector-base !default;
|
|
146
|
-
|
|
211
|
+
$-state-selectors: (
|
|
147
212
|
visited: (
|
|
148
|
-
"#{$state-selector-base}visited",
|
|
149
213
|
":visited",
|
|
150
214
|
),
|
|
151
215
|
focus: (
|
|
152
|
-
"#{$state-selector-base}focus",
|
|
153
216
|
":focus-visible",
|
|
154
217
|
),
|
|
155
218
|
hover: (
|
|
156
|
-
"#{$state-selector-base}hover",
|
|
157
219
|
":hover",
|
|
158
220
|
),
|
|
159
221
|
active: (
|
|
160
|
-
"#{$state-selector-base}active",
|
|
161
222
|
":active",
|
|
162
223
|
),
|
|
163
224
|
disabled: (
|
|
164
|
-
"#{$state-selector-base}disabled",
|
|
165
225
|
":disabled",
|
|
166
226
|
"[disabled]",
|
|
167
227
|
"[aria-disabled=true]",
|
|
168
228
|
),
|
|
169
229
|
);
|
|
230
|
+
$-state-class-selectors: (
|
|
231
|
+
visited: (
|
|
232
|
+
"#{$state-selector-base}visited",
|
|
233
|
+
),
|
|
234
|
+
focus: (
|
|
235
|
+
"#{$state-selector-base}focus",
|
|
236
|
+
),
|
|
237
|
+
hover: (
|
|
238
|
+
"#{$state-selector-base}hover",
|
|
239
|
+
),
|
|
240
|
+
active: (
|
|
241
|
+
"#{$state-selector-base}active",
|
|
242
|
+
),
|
|
243
|
+
disabled: (
|
|
244
|
+
"#{$state-selector-base}disabled",
|
|
245
|
+
),
|
|
246
|
+
);
|
|
247
|
+
|
|
248
|
+
// Merge the state class selectors with the state selectors.
|
|
249
|
+
@if $generate-state-classes {
|
|
250
|
+
@each $state, $selectors in $-state-selectors {
|
|
251
|
+
$-state-selectors: map.set(
|
|
252
|
+
$-state-selectors,
|
|
253
|
+
$state,
|
|
254
|
+
list.join($selectors, map.get($-state-class-selectors, $state))
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
170
259
|
$custom-state-selectors: () !default;
|
|
171
|
-
$state-selectors:
|
|
260
|
+
$state-selectors: () !default;
|
|
261
|
+
|
|
262
|
+
// @todo remove this once $custom-state-selectors is removed
|
|
263
|
+
@if $custom-state-selectors != () {
|
|
264
|
+
@warn "`$custom-state-selectors` is deprecated and will be removed in a future release of Graupl. Use `$state-selectors` instead.";
|
|
265
|
+
|
|
266
|
+
@each $state, $selectors in $custom-state-selectors {
|
|
267
|
+
@if map.has-key($state-selectors, $state) {
|
|
268
|
+
$state-selectors: map.set(
|
|
269
|
+
$state-selectors,
|
|
270
|
+
$state,
|
|
271
|
+
list.join(map.get($state-selectors, $state), $selectors)
|
|
272
|
+
);
|
|
273
|
+
} @else {
|
|
274
|
+
$state-selectors: map.set($state-selectors, $state, $selectors);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@each $state, $selectors in $-state-selectors {
|
|
280
|
+
@if map.has-key($state-selectors, $state) {
|
|
281
|
+
$state-selectors: map.set(
|
|
282
|
+
$state-selectors,
|
|
283
|
+
$state,
|
|
284
|
+
list.join(map.get($state-selectors, $state), $selectors)
|
|
285
|
+
);
|
|
286
|
+
} @else {
|
|
287
|
+
$state-selectors: map.set($state-selectors, $state, $selectors);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
172
290
|
|
|
173
291
|
// Utility properties.
|
|
174
292
|
$utility-selector-base: $modifier-selector-base !default;
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// Button selectors.
|
|
13
13
|
$selector-base: root-defaults.$component-selector-base !default;
|
|
14
14
|
$modifier-selector-base: root-defaults.$modifier-selector-base !default;
|
|
15
|
+
$generate-base-theme-map: root-defaults.$generate-base-theme-maps !default;
|
|
15
16
|
$button-selector-base: $selector-base !default;
|
|
16
17
|
$button-selector: "button" !default;
|
|
17
18
|
$button-link-selector-base: $modifier-selector-base !default;
|
|
@@ -33,7 +34,7 @@ $button-disabled-transform: $button-initial-transform !default;
|
|
|
33
34
|
// and primary--900 as the border colour.
|
|
34
35
|
//
|
|
35
36
|
// Secondary/tertiary buttons will use the same shade for their respective colours.
|
|
36
|
-
|
|
37
|
+
$-button-state-theme-map: (
|
|
37
38
|
color: 900,
|
|
38
39
|
border-color: 700,
|
|
39
40
|
hover-color: 100,
|
|
@@ -43,7 +44,22 @@ $base-button-state-theme-map: (
|
|
|
43
44
|
disabled-border-color: 200,
|
|
44
45
|
);
|
|
45
46
|
$custom-button-state-theme-map: () !default;
|
|
46
|
-
$button-state-theme-map:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
47
|
+
$button-state-theme-map: () !default;
|
|
48
|
+
|
|
49
|
+
// @todo remove this once $custom-button-state-theme-map is removed
|
|
50
|
+
@if $custom-button-state-theme-map != () {
|
|
51
|
+
@warn "`$custom-button-state-theme-map` is deprecated and will be removed in a future release of Graupl. Use `$button-state-theme-map` instead.";
|
|
52
|
+
|
|
53
|
+
$button-state-theme-map: map.merge(
|
|
54
|
+
$button-state-theme-map,
|
|
55
|
+
$custom-button-state-theme-map
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Merge the custom button state theme map with the default one.
|
|
60
|
+
@if $generate-base-theme-map {
|
|
61
|
+
$button-state-theme-map: map.merge(
|
|
62
|
+
$-button-state-theme-map,
|
|
63
|
+
$button-state-theme-map
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
background: $button-background;
|
|
62
62
|
color: $button-color;
|
|
63
63
|
|
|
64
|
-
@each $color
|
|
64
|
+
@each $color in theme.get-colors() {
|
|
65
65
|
// e.g. &.primary, &.secondary, &.tertiary
|
|
66
66
|
&#{defaults.$button-theme-selector-base}#{defaults.$button-theme-selector-prefix}#{$color} {
|
|
67
67
|
@each $prop, $shade in defaults.$button-state-theme-map {
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
// Table selectors.
|
|
13
13
|
$selector-base: root-defaults.$element-selector-base !default;
|
|
14
14
|
$modifier-selector-base: root-defaults.$modifier-selector-base !default;
|
|
15
|
+
$generate-base-theme-map: root-defaults.$generate-base-theme-maps !default;
|
|
15
16
|
$table-selector-base: $selector-base !default;
|
|
16
17
|
$table-selector: "table" !default;
|
|
17
18
|
$table-caption-selector-base: $selector-base !default;
|
|
@@ -53,7 +54,7 @@ $table-caption-side: bottom !default;
|
|
|
53
54
|
// and primary--100 as the header text colour.
|
|
54
55
|
//
|
|
55
56
|
// Secondary/tertiary tables will use the same shade for their respective colours.
|
|
56
|
-
|
|
57
|
+
$-table-theme-map: (
|
|
57
58
|
header-background: 700,
|
|
58
59
|
header-color: 100,
|
|
59
60
|
striped-background: 200,
|
|
@@ -65,4 +66,16 @@ $base-table-theme-map: (
|
|
|
65
66
|
highlight-color: 100,
|
|
66
67
|
);
|
|
67
68
|
$custom-table-theme-map: () !default;
|
|
68
|
-
$table-theme-map:
|
|
69
|
+
$table-theme-map: () !default;
|
|
70
|
+
|
|
71
|
+
// @todo remove this once $custom-table-theme-map is removed
|
|
72
|
+
@if $custom-table-theme-map != () {
|
|
73
|
+
@warn "`$custom-table-theme-map` is deprecated and will be removed in a future release of Graupl. Use `$table-theme-map` instead.";
|
|
74
|
+
|
|
75
|
+
$table-theme-map: map.merge($table-theme-map, $custom-table-theme-map);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Merge the custom table theme map with the default one.
|
|
79
|
+
@if $generate-base-theme-map {
|
|
80
|
+
$table-theme-map: map.merge($-table-theme-map, $table-theme-map);
|
|
81
|
+
}
|
|
@@ -223,16 +223,13 @@
|
|
|
223
223
|
@include layer(theme) {
|
|
224
224
|
// table
|
|
225
225
|
#{defaults.$table-selector-base}#{defaults.$table-selector} {
|
|
226
|
-
@each $
|
|
226
|
+
@each $color in theme.get-colors() {
|
|
227
227
|
// e.g. &.primary, &.secondary, &.tertiary,
|
|
228
228
|
// e.g. .primary, .secondary, .tertiary
|
|
229
|
-
&#{defaults.$table-theme-prefix-selector-base}#{defaults.$table-theme-prefix-selector}#{$
|
|
230
|
-
#{defaults.$table-theme-prefix-selector-base}#{defaults.$table-theme-prefix-selector}#{$
|
|
229
|
+
&#{defaults.$table-theme-prefix-selector-base}#{defaults.$table-theme-prefix-selector}#{$color},
|
|
230
|
+
#{defaults.$table-theme-prefix-selector-base}#{defaults.$table-theme-prefix-selector}#{$color} {
|
|
231
231
|
@each $prop, $key in defaults.$table-theme-map {
|
|
232
|
-
--#{root-defaults.$prefix}table-#{$prop}: #{theme.get(
|
|
233
|
-
$variant,
|
|
234
|
-
$key
|
|
235
|
-
)};
|
|
232
|
+
--#{root-defaults.$prefix}table-#{$prop}: #{theme.get($color, $key)};
|
|
236
233
|
}
|
|
237
234
|
}
|
|
238
235
|
}
|
|
@@ -6,9 +6,11 @@
|
|
|
6
6
|
// They should not be used to define direct property values (i.e. font-size, color, etc.).
|
|
7
7
|
// Those should be defined as custom properties in the `_variables.scss` file.
|
|
8
8
|
|
|
9
|
+
@use "../../defaults" as root-defaults;
|
|
9
10
|
@use "sass:map";
|
|
10
11
|
|
|
11
12
|
// Alert selectors.
|
|
13
|
+
$generate-base-theme-map: root-defaults.$generate-base-theme-maps !default;
|
|
12
14
|
$alert-selector: ".alert" !default;
|
|
13
15
|
$alert-theme-selector-prefix: "." !default;
|
|
14
16
|
$alert-body-selector: ".alert-body" !default;
|
|
@@ -29,7 +31,7 @@ $alert-transition-selector: ".transitioning" !default;
|
|
|
29
31
|
// and primary--900 as the border colour.
|
|
30
32
|
//
|
|
31
33
|
// Secondary/tertiary alerts will use the same shade for their respective colours.
|
|
32
|
-
|
|
34
|
+
$-alert-state-theme-map: (
|
|
33
35
|
color: 900,
|
|
34
36
|
background: 200,
|
|
35
37
|
border-color: 700,
|
|
@@ -43,7 +45,22 @@ $base-alert-state-theme-map: (
|
|
|
43
45
|
link-disabled-color: 400,
|
|
44
46
|
);
|
|
45
47
|
$custom-alert-state-theme-map: () !default;
|
|
46
|
-
$alert-state-theme-map:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
)
|
|
48
|
+
$alert-state-theme-map: () !default;
|
|
49
|
+
|
|
50
|
+
// @todo remove this once $custom-alert-state-theme-map is removed
|
|
51
|
+
@if $custom-alert-state-theme-map != () {
|
|
52
|
+
@warn "`$custom-alert-state-theme-map` is deprecated and will be removed in a future release of Graupl. Use `$alert-state-theme-map` instead.";
|
|
53
|
+
|
|
54
|
+
$alert-state-theme-map: map.merge(
|
|
55
|
+
$alert-state-theme-map,
|
|
56
|
+
$custom-alert-state-theme-map
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Merge the custom alert state theme map with the default one.
|
|
61
|
+
@if $generate-base-theme-map {
|
|
62
|
+
$alert-state-theme-map: map.merge(
|
|
63
|
+
$-alert-state-theme-map,
|
|
64
|
+
$alert-state-theme-map
|
|
65
|
+
);
|
|
66
|
+
}
|