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EAAKzB,SAASqB,EAAczB,IAAIgC,OACzC,EAAK5B,SAASqB,EAAczB,IAAM,CAAC,EAAKI,SAASqB,EAAczB,MAEjE,EAAKI,SAASqB,EAAczB,IAAIgC,KAAKH,MAhBlCD,EAAI,EAAGA,EAAIF,EAAYO,OAAQL,GAAK,EAAG,EAAvCA,GA4BTM,OAAOC,OAAOhC,KAAKC,UAAUgC,SAAQ,SAACC,GACpCA,EAAIC,OAFS,SAACD,GAAD,YAA8B,IAAbA,EAAIL,KAAuB,CAACK,GAAOA,EAEpDC,CAAOD,W,mBAlEpBxB","sources":["webpack:///./components/select/javascripts/select.js","webpack:///./javascripts/dom/select.js","webpack:///./javascripts/helpers/baseModule.js"],"sourcesContent":["import BaseModule from '../../../javascripts/helpers/baseModule';\n\nexport default class Select extends BaseModule {\n  constructor(element) {\n    super(element, element.getAttribute('data-js-module'));\n    this.getElements([{ id: 'select', selector: 'select' }]);\n\n    this.initEventListeners();\n  }\n\n  initEventListeners() {\n    this.elements.self.addEventListener('change', (e) => {\n      if (e.target.value !== '') {\n        this.elements.self.classList.add('select--has-value');\n      } else {\n        this.elements.self.classList.remove('select--has-value');\n      }\n    });\n  }\n}\n","/**\n * This methods selects Elements from a specific context by a selector\n * @param {string} selector Selector of the element to find\n * @param {Element|HTMLDocument} [element] Context of the selectable\n * @returns {Array<Element>} Am array with selected Elements\n */\nexport default (selector, element = window.document) =>\n  [].slice.call(element.querySelectorAll(selector));\n","import select from '../dom/select';\n\nclass BaseModule {\n  constructor(element, id) {\n    this.id = id;\n    this.elements = {\n      self: element\n    };\n\n    this.setInitialized();\n  }\n\n  setInitialized() {\n    if (this.elements.self) {\n      this.elements.self.setAttribute('data-js-module-initialized', true);\n    }\n  }\n\n  setUnInitialized() {\n    if (this.elements.self) {\n      this.elements.self.removeAttribute('data-js-module-initialized');\n    }\n  }\n\n  /**\n   * Selects DOMElements of a module with a specific data attribute (`data-js-element=\"${module}__${selector}\"`)\n   * Receives an object where the id param is the key in the elements cache\n   * The selector param of the config is the selector part in the query-selector described above\n   * @param {Object} config Configuration object in a key value format\n   * @returns {void}\n   */\n  getElements(config) {\n    const elementsConfig = config.map((elementConfig) => ({\n      ...elementConfig,\n      selector: `${this.id}__${elementConfig.selector}`\n    }));\n\n    const domElements = select('[data-js-element]', this.elements.self);\n\n    for (let i = 0; i < domElements.length; i += 1) {\n      const domElement = domElements[i];\n      const elementConfigCandidates = elementsConfig.filter(\n        (singleConfig) =>\n          domElement.getAttribute('data-js-element') === singleConfig.selector\n      );\n\n      const [elementConfig] = elementConfigCandidates;\n\n      if (elementConfig) {\n        if (typeof this.elements[elementConfig.id] === 'undefined') {\n          this.elements[elementConfig.id] = domElement;\n        } else {\n          if (typeof this.elements[elementConfig.id].push === 'undefined') {\n            this.elements[elementConfig.id] = [this.elements[elementConfig.id]];\n          }\n          this.elements[elementConfig.id].push(domElement);\n        }\n      }\n    }\n\n    /*\n     * Append a attribute \"asList\" to each element/s in this.elements\n     * which is always an array no matter if element/s is an array\n     * or a single HTMLElement\n     */\n\n    const asList = (obj) => (typeof obj.push === 'undefined' ? [obj] : obj);\n    Object.values(this.elements).forEach((obj) => {\n      obj.asList = asList(obj); // eslint-disable-line no-param-reassign\n    });\n  }\n}\n\nexport default BaseModule;\n"],"names":["Select","element","getAttribute","getElements","id","selector","initEventListeners","this","elements","self","addEventListener","e","target","value","classList","add","remove","BaseModule","window","document","slice","call","querySelectorAll","setInitialized","setAttribute","removeAttribute","config","elementsConfig","map","elementConfig","domElements","select","i","domElement","filter","singleConfig","push","length","Object","values","forEach","obj","asList"],"sourceRoot":""}