{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./scripts/js2/chip-input.js","webpack:///./scripts/js2/index.js"],"names":[],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA,kDAA0C,gCAAgC;AAC1E;AACA;;AAEA;AACA;AACA;AACA,gEAAwD,kBAAkB;AAC1E;AACA,yDAAiD,cAAc;AAC/D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,iDAAyC,iCAAiC;AAC1E,wHAAgH,mBAAmB,EAAE;AACrI;AACA;;AAEA;AACA;AACA;AACA,mCAA2B,0BAA0B,EAAE;AACvD,yCAAiC,eAAe;AAChD;AACA;AACA;;AAEA;AACA,8DAAsD,+DAA+D;;AAErH;AACA;;;AAGA;AACA;;;;;;;;;;;;;AClFA;AAAA;AAAe;AACf;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,+DAA+D,MAAM;AACrE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;;AAEA;AACA;AACA;AACA;AACA,KAAK;AACL,4BAA4B,MAAM;AAClC;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,qDAAqD,MAAM;AAC3D;;AAEA;AACA;AACA;;AAEA;AACA,qEAAqE,MAAM;AAC3E;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,mCAAmC;AACnC,OAAO;AACP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,KAAK;AACL;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;;ACnLA;AAAA;AAAuC;;AAEvC,sDAAS,0B","file":"bundle.dev.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","export default class ChipInput {\r\n constructor(root) {\r\n if (!root.dataset.initialized) {\r\n this.input = root\r\n this.inputName = this.input.name\r\n this.input.removeAttribute('name')\r\n this.wrapper = document.createElement('div')\r\n this.chipWrapper = document.createElement('div')\r\n this.values = []\r\n\r\n root.parentElement.replaceChild(this.wrapper, this.input)\r\n this.wrapper.appendChild(this.input)\r\n this.wrapper.appendChild(this.chipWrapper)\r\n this.wrapper.classList.add('chip-input-wrapper')\r\n this.chipWrapper.classList.add('chip-array')\r\n\r\n this.initialize()\r\n this.input.dataset.initialized = true\r\n\r\n this.insertDefaults()\r\n }\r\n }\r\n\r\n initialize() {\r\n this.input.value = ''\r\n this.input.addEventListener('change', evt => {\r\n this.addValue(evt.target.value)\r\n evt.target.value = ''\r\n })\r\n }\r\n\r\n getText(value) {\r\n return value\r\n }\r\n\r\n addValue(value, chipWrapper) {\r\n if (!this.input.dataset.noTrim || this.input.dataset.noTrim === \"0\") {\r\n value = value.trim()\r\n }\r\n if (!this.values.find(v => v.value == value)) {\r\n this.values.push(value)\r\n return this.addChip(chipWrapper || this.chipWrapper, value)\r\n }\r\n return null\r\n }\r\n\r\n removeValue(value) {\r\n const index = this.values.findIndex(n => n == value)\r\n if (index > -1) {\r\n this.removeChip(value)\r\n this.values.splice(index, 1)\r\n }\r\n }\r\n\r\n getChip(value) {\r\n return this.chipWrapper.querySelector(`.chip[data-value=\"${value}\"]`)\r\n }\r\n\r\n addChip(chipWrapper, value) {\r\n const wrapper = chipWrapper.appendChild(document.createElement('span'))\r\n wrapper.classList.add('chip')\r\n wrapper.dataset.value = value\r\n const badge = wrapper.appendChild(document.createElement('span'))\r\n badge.textContent = this.getText(value)\r\n badge.classList.add('badge', 'badge-pill')\r\n const remove = badge.appendChild(document.createElement('span'))\r\n remove.classList.add('remove', 'fas', 'fa-times-circle', 'text-light')\r\n const input = wrapper.appendChild(document.createElement('input'))\r\n input.type = 'hidden'\r\n input.value = value\r\n input.name = this.inputName\r\n remove.addEventListener('click', evt => {\r\n this.removeValue(evt.target.closest('.chip').dataset.value)\r\n })\r\n return wrapper\r\n }\r\n\r\n removeChip(value) {\r\n const chip = this.getChip(value)\r\n if (chip) {\r\n chip.remove()\r\n } else {\r\n console.error(`Chip ${value} not found`)\r\n }\r\n }\r\n\r\n insertDefaults() {\r\n const sep = this.input.dataset.separator ? new RegExp(this.input.dataset.separator) : ','\r\n for (let value of this.input.dataset.defaults.split(sep)) {\r\n if (value) {\r\n this.addValue(value)\r\n }\r\n }\r\n }\r\n\r\n static initialize(classes = '.chip-input') {\r\n for (let node of document.querySelectorAll('select'+classes)) {\r\n new ChipInputSelect(node)\r\n }\r\n for (let node of document.querySelectorAll('input[type=\"text\"]'+classes)) {\r\n new ChipInputText(node)\r\n }\r\n }\r\n}\r\n\r\nclass ChipInputText extends ChipInput {\r\n}\r\n\r\nclass ChipInputSelect extends ChipInput {\r\n initialize() {\r\n super.initialize()\r\n if (this.input.dataset.grouped) {\r\n for (let optgroup of this.input.querySelectorAll('optgroup')) {\r\n const wrapper = document.createElement('div')\r\n wrapper.classList.add('chip-group', 'd-none')\r\n wrapper.dataset.label = optgroup.label\r\n const label = wrapper.appendChild(document.createElement('label'))\r\n label.textContent = optgroup.label\r\n const chips = wrapper.appendChild(document.createElement('div'))\r\n chips.classList.add('chip-array')\r\n this.chipWrapper.appendChild(wrapper)\r\n }\r\n }\r\n }\r\n\r\n getText(value) {\r\n const option = this.getOption(value)\r\n return option.textContent\r\n //const optgroup = this.getOptgroupLabel(value)\r\n //return (optgroup ? optgroup+': ' : '') + option.textContent\r\n }\r\n\r\n getOption(value) {\r\n return this.input.querySelector(`option[value=\"${value}\"]`)\r\n }\r\n\r\n getOptgroup(value) {\r\n return this.getOption(value).closest('optgroup')\r\n }\r\n\r\n getChipGroup(label) {\r\n return this.chipWrapper.querySelector(`.chip-group[data-label=\"${label}\"]`)\r\n }\r\n\r\n addValue(value) {\r\n const wrapper = this.input.dataset.grouped ? this.getChipGroup(this.getOptgroup(value).label).querySelector('.chip-array') : this.chipWrapper\r\n const chip = super.addValue(value, wrapper)\r\n if (chip) {\r\n const option = this.getOption(value)\r\n option.disabled = true\r\n if (this.input.dataset.selectBehaviour === 'check') {\r\n option.innerHTML = \"✓ \" + option.innerHTML\r\n } else if (this.input.dataset.selectBehaviour === 'hide') {\r\n option.classList.add('d-none')\r\n }\r\n if (option.dataset.chipClasses) {\r\n chip.querySelector('.badge').classList.add(...option.dataset.chipClasses.split(' '))\r\n }\r\n if (this.input.dataset.grouped) {\r\n this.getChipGroup(this.getOptgroup(value).label).classList.remove('d-none')\r\n }\r\n }\r\n }\r\n\r\n removeValue(value) {\r\n super.removeValue(value)\r\n const option = this.getOption(value)\r\n option.disabled = false\r\n if (this.input.dataset.selectBehaviour === 'check') {\r\n option.innerHTML = option.innerHTML.slice(2)\r\n } else if (this.input.dataset.selectBehaviour === 'hide') {\r\n option.classList.remove('d-none')\r\n }\r\n if (this.input.dataset.grouped) {\r\n const optgroup = this.getOptgroup(value)\r\n const chipGroup = this.getChipGroup(optgroup.label)\r\n chipGroup.classList.toggle('d-none', chipGroup.querySelector('.chip') == null)\r\n }\r\n }\r\n}\r\n","import ChipInput from './chip-input.js'\r\n\r\nChipInput.initialize('.chip-input')"],"sourceRoot":""}