Choices/public/assets/scripts/choices.min.js

58 lines
88 KiB
JavaScript
Raw Normal View History

2019-02-09 19:14:16 +01:00
/*! choices.js v5.0.0 | (c) 2019 Josh Johnson | https://github.com/jshjohnson/Choices#readme */
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Choices=t():e.Choices=t()}(window,function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/public/assets/scripts/",n(n.s=9)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.doKeysMatch=t.cloneObject=t.existsInArray=t.isIE11=t.fetchFromObject=t.reduceToValues=t.getWindowHeight=t.regexFilter=t.dispatchEvent=t.sortByScore=t.sortByAlpha=t.calcWidthOfInput=t.strToEl=t.stripHTML=t.isScrolledIntoView=t.getAdjacentEl=t.findAncestorByAttrName=t.findAncestor=t.wrap=t.extend=t.isElement=t.isType=t.getType=t.generateId=t.generateChars=t.getRandomNumber=void 0;var i=function(e,t){return Math.floor(Math.random()*(t-e)+e)};t.getRandomNumber=i;var r=function(e){for(var t="",n=0;n<e;n++){t+=i(0,36).toString(36)}return t};t.generateChars=r;t.generateId=function(e,t){var n=e.id||e.name&&"".concat(e.name,"-").concat(r(2))||r(4);return n=n.replace(/(:|\.|\[|\]|,)/g,""),n="".concat(t,"-").concat(n)};var o=function(e){return Object.prototype.toString.call(e).slice(8,-1)};t.getType=o;var s=function(e,t){var n=o(t);return null!=t&&n===e};t.isType=s;t.isElement=function(e){return e instanceof Element};t.extend=function e(){for(var t={},n=arguments.length,i=function(n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(s("Object",n[i])?t[i]=e(!0,t[i],n[i]):t[i]=n[i])},r=0;r<n;r++){var o=arguments[r];s("Object",o)&&i(o)}return t};t.wrap=function(e,t){return t=t||document.createElement("div"),e.nextSibling?e.parentNode.insertBefore(t,e.nextSibling):e.parentNode.appendChild(t),t.appendChild(e)};t.findAncestor=function(e,t){for(;(e=e.parentElement)&&!e.classList.contains(t););return e};t.findAncestorByAttrName=function(e,t){for(var n=e;n;){if(n.hasAttribute(t))return n;n=n.parentElement}return null};t.getAdjacentEl=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e&&t){var i=e.parentNode.parentNode,r=Array.from(i.querySelectorAll(t)),o=r.indexOf(e);return r[o+(n>0?1:-1)]}};t.isScrolledIntoView=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1;if(e)return n>0?t.scrollTop+t.offsetHeight>=e.offsetTop+e.offsetHeight:e.offsetTop>=t.scrollTop};var a=function(e){return e.replace(/&/g,"&amp;").replace(/>/g,"&rt;").replace(/</g,"&lt;").replace(/"/g,"&quot;")};t.stripHTML=a;var l,c=(l=document.createElement("div"),function(e){var t,n=e.trim();for(l.innerHTML=n,t=l.children[0];l.firstChild;)l.removeChild(l.firstChild);return t});t.strToEl=c;t.calcWidthOfInput=function(e,t){var n=e.value||e.placeholder,i=e.offsetWidth;if(n){var r=c("<span>".concat(a(n),"</span>"));if(r.style.position="absolute",r.style.padding="0",r.style.top="-9999px",r.style.left="-9999px",r.style.width="auto",r.style.whiteSpace="pre",document.body.contains(e)&&window.getComputedStyle){var o=window.getComputedStyle(e);o&&(r.style.fontSize=o.fontSize,r.style.fontFamily=o.fontFamily,r.style.fontWeight=o.fontWeight,r.style.fontStyle=o.fontStyle,r.style.letterSpacing=o.letterSpacing,r.style.textTransform=o.textTransform,r.style.padding=o.padding)}document.body.appendChild(r),requestAni
/*!
* Fuse.js v3.4.1 - Lightweight fuzzy-search (http://fusejs.io)
*
* Copyright (c) 2012-2017 Kirollos Risk (http://kiro.me)
* All Rights Reserved. Apache Software License 2.0
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
var i;i=function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s="./src/index.js")}({"./src/bitap/bitap_matched_indices.js":
/*!********************************************!*\
!*** ./src/bitap/bitap_matched_indices.js ***!
\********************************************/
/*! no static exports found */function(e,t){e.exports=((e=[],t=1)=>{let n=[],i=-1,r=-1,o=0;for(let s=e.length;o<s;o+=1){let s=e[o];s&&-1===i?i=o:s||-1===i||((r=o-1)-i+1>=t&&n.push([i,r]),i=-1)}return e[o-1]&&o-i>=t&&n.push([i,o-1]),n})},"./src/bitap/bitap_pattern_alphabet.js":
/*!*********************************************!*\
!*** ./src/bitap/bitap_pattern_alphabet.js ***!
\*********************************************/
/*! no static exports found */function(e,t){e.exports=(e=>{let t={},n=e.length;for(let i=0;i<n;i+=1)t[e.charAt(i)]=0;for(let i=0;i<n;i+=1)t[e.charAt(i)]|=1<<n-i-1;return t})},"./src/bitap/bitap_regex_search.js":
/*!*****************************************!*\
!*** ./src/bitap/bitap_regex_search.js ***!
\*****************************************/
/*! no static exports found */function(e,t){const n=/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g;e.exports=((e,t,i=/ +/g)=>{let r=new RegExp(t.replace(n,"\\$&").replace(i,"|")),o=e.match(r),s=!!o,a=[];if(s)for(let t=0,n=o.length;t<n;t+=1){let n=o[t];a.push([e.indexOf(n),n.length-1])}return{score:s?.5:1,isMatch:s,matchedIndices:a}})},"./src/bitap/bitap_score.js":
/*!**********************************!*\
!*** ./src/bitap/bitap_score.js ***!
\**********************************/
/*! no static exports found */function(e,t){e.exports=((e,{errors:t=0,currentLocation:n=0,expectedLocation:i=0,distance:r=100})=>{const o=t/e.length,s=Math.abs(i-n);return r?o+s/r:s?1:o})},"./src/bitap/bitap_search.js":
/*!***********************************!*\
!*** ./src/bitap/bitap_search.js ***!
\***********************************/
/*! no static exports found */function(e,t,n){const i=n(/*! ./bitap_score */"./src/bitap/bitap_score.js"),r=n(/*! ./bitap_matched_indices */"./src/bitap/bitap_matched_indices.js");e.exports=((e,t,n,{location:o=0,distance:s=100,threshold:a=.6,findAllMatches:l=!1,minMatchCharLength:c=1})=>{const u=o,h=e.length;let d=a,f=e.indexOf(t,u);const p=t.length,v=[];for(let e=0;e<h;e+=1)v[e]=0;if(-1!==f){let n=i(t,{errors:0,currentLocation:f,expectedLocation:u,distance:s});if(d=Math.min(n,d),-1!==(f=e.lastIndexOf(t,u+p))){let e=i(t,{errors:0,currentLocation:f,expectedLocation:u,distance:s});d=Math.min(e,d)}}f=-1;let m=[],g=1,_=p+h;const y=1<<p-1;for(let r=0;r<p;r+=1){let o=0,a=_;for(;o<a;){i(t,{errors:r,currentLocation:u+a,expectedLocation:u,distance:s})<=d?o=a:_=a,a=Math.floor((_-o)/2+o)}_=a;let c=Math.max(1,u-a+1),b=l?h:Math.min(u+a,h)+p,E=Array(b+2);E[b+1]=(1<<r)-1;for(let o=b;o>=c;o-=1){let a=o-1,l=n[e.charAt(a)];if(l&&(v[a]=1),E[o]=(E[o+1]<<1|1)&l,0!==r&&(E[o]|=(m[o+1]|m[o])<<1|1|m[o+1]),E[o]&y&&(g=i(t,{errors:r,currentLocation:a,expectedLocation:u,distance:s}))<=d){if(d=g,(f=a)<=u)break;c=Math.max(1,2*u-f)}}if(i(t,{errors:r+1,currentLocation:u,expectedLocation:u,distance:s})>d)break;m=E}return{isMatch:f>=0,score:0===g?.001:g,matchedIndices:r(v,c)}})},"./src/bitap/index.js":
/*!****************************!*\
!*** ./src/bitap/index.js ***!
\****************************/
/*! no static exports found */function(e,t,n){const i=n(/*! ./bitap_regex_search */"./src/bitap/bitap_regex_search.js"),r=n(/*! ./bitap_search */"./src/bitap/bitap_search.js"),o=n(/*! ./bitap_pattern_alphabet */"./src/bitap/bitap_pattern_alphabet.js");e.exports=class{constructor(e,{location:t=0,distance:n=100,threshold:i=.6,maxPatternLength:r=32,isCaseSensitive:s=!1,tokenSeparator:a=/ +/g,findAllMatches:l=!1,minMatchCharLength:c=1}){this.options={location:t,distance:n,threshold:i,maxPatternLength:r,isCaseSensitive:s,tokenSeparator:a,findAllMatches:l,minMatchCharLength:c},this.pattern=this.options.isCaseSensitive?e:e.toLowerCase(),this.pattern.length<=r&&(this.patternAlphabet=o(this.pattern))}search(e){if(this.options.isCaseSensitive||(e=e.toLowerCase()),this.pattern===e)return{isMatch:!0,score:0,matchedIndices:[[0,e.length-1]]};const{maxPatternLength:t,tokenSeparator:n}=this.options;if(this.pattern.length>t)return i(e,this.pattern,n);const{location:o,distance:s,threshold:a,findAllMatches:l,minMatchCharLength:c}=this.options;return r(e,this.pattern,this.patternAlphabet,{location:o,distance:s,threshold:a,findAllMatches:l,minMatchCharLength:c})}}},"./src/helpers/deep_value.js":
/*!***********************************!*\
!*** ./src/helpers/deep_value.js ***!
\***********************************/
/*! no static exports found */function(e,t,n){const i=n(/*! ./is_array */"./src/helpers/is_array.js"),r=(e,t,n)=>{if(t){const o=t.indexOf(".");let s=t,a=null;-1!==o&&(s=t.slice(0,o),a=t.slice(o+1));const l=e[s];if(null!=l)if(a||"string"!=typeof l&&"number"!=typeof l)if(i(l))for(let e=0,t=l.length;e<t;e+=1)r(l[e],a,n);else a&&r(l,a,n);else n.push(l.toString())}else n.push(e);return n};e.exports=((e,t)=>r(e,t,[]))},"./src/helpers/is_array.js":
/*!*********************************!*\
!*** ./src/helpers/is_array.js ***!
\*********************************/
/*! no static exports found */function(e,t){e.exports=(e=>Array.isArray?Array.isArray(e):"[object Array]"===Object.prototype.toString.call(e))},"./src/index.js":
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/*! no static exports found */function(e,t,n){const i=n(/*! ./bitap */"./src/bitap/index.js"),r=n(/*! ./helpers/deep_value */"./src/helpers/deep_value.js"),o=n(/*! ./helpers/is_array */"./src/helpers/is_array.js");e.exports=class{constructor(e,{location:t=0,distance:n=100,threshold:i=.6,maxPatternLength:o=32,caseSensitive:s=!1,tokenSeparator:a=/ +/g,findAllMatches:l=!1,minMatchCharLength:c=1,id:u=null,keys:h=[],shouldSort:d=!0,getFn:f=r,sortFn:p=((e,t)=>e.score-t.score),tokenize:v=!1,matchAllTokens:m=!1,includeMatches:g=!1,includeScore:_=!1,verbose:y=!1}){this.options={location:t,distance:n,threshold:i,maxPatternLength:o,isCaseSensitive:s,tokenSeparator:a,findAllMatches:l,minMatchCharLength:c,id:u,keys:h,includeMatches:g,includeScore:_,shouldSort:d,getFn:f,sortFn:p,verbose:y,tokenize:v,matchAllTokens:m},this.setCollection(e)}setCollection(e){return this.list=e,e}search(e,t={limit:!1}){this._log(`---------\nSearch pattern: "${e}"`);const{tokenSearchers:n,fullSearcher:i}=this._prepareSearchers(e);let{weights:r,results:o}=this._search(n,i);return this._computeScore(r,o),this.options.shouldSort&&this._sort(o),t.limit&&"number"==typeof t.limit&&(o=o.slice(0,t.limit)),this._format(o)}_prepareSearchers(e=""){const t=[];if(this.options.tokenize){const n=e.split(this.options.tokenSeparator);for(let e=0,r=n.length;e<r;e+=1)t.push(new i(n[e],this.options))}return{tokenSearchers:t,fullSearcher:new i(e,this.options)}}_search(e=[],t){const n=this.list,i={},r=[];if("string"==typeof n[0]){for(let o=0,s=n.length;o<s;o+=1)this._analyze({key:"",value:n[o],record:o,index:o},{resultMap:i,results:r,tokenSearchers:e,fullSearcher:t});return{weights:null,results:r}}const o={};for(let s=0,a=n.length;s<a;s+=1){let a=n[s];for(let n=0,l=this.options.keys.length;n<l;n+=1){let l=this.options.keys[n];if("string"!=typeof l){if(o[l.name]={weight:1-l.weight||1},l.weight<=0||l.weight>1)throw new Error("Key weight has to be > 0 and <= 1");l=l.name}else o[l]={weight:1};this._analyze({key:l,value:this.options.getFn(a,l),record:a,index:s},{resultMap:i,results:r,tokenSearchers:e,fullSearcher:t})}}return{weights:o,results:r}}_analyze({key:e,arrayIndex:t=-1,value:n,record:i,index:r},{tokenSearchers:s=[],fullSearcher:a=[],resultMap:l={},results:c=[]}){if(null==n)return;let u=!1,h=-1,d=0;if("string"==typeof n){this._log(`\nKey: ${""===e?"-":e}`);let o=a.search(n);if(this._log(`Full text: "${n}", score: ${o.score}`),this.options.tokenize){let e=n.split(this.options.tokenSeparator),t=[];for(let n=0;n<s.length;n+=1){let i=s[n];this._log(`\nPattern: "${i.pattern}"`);let r=!1;for(let n=0;n<e.length;n+=1){let o=e[n],s=i.search(o),a={};s.isMatch?(a[o]=s.score,u=!0,r=!0,t.push(s.score)):(a[o]=1,this.options.matchAllTokens||t.push(1)),this._log(`Token: "${o}", score: ${a[o]}`)}r&&(d+=1)}h=t[0];let i=t.length;for(let e=1;e<i;e+=1)h+=t[e];h/=i,this._log("Token score average:",h)}let f=o.score;h>-1&&(f=(f+h)/2),this._log("Score average:",f);let p=!this.options.tokenize||!this.options.matchAllTokens||d>=s.length;if(this._log(`\nCheck Matches: ${p}`),(u||o.isMatch)&&p){let s=l[r];s?s.output.push({key:e,arrayIndex:t,value:n,score:f,matchedIndices:o.matchedIndices}):(l[r]={item:i,output:[{key:e,arrayIndex:t,value:n,score:f,matchedIndices:o.matchedIndices}]},c.push(l[r]))}}else if(o(n))for(let t=0,o=n.length;t<o;t+=1)this._analyze({key:e,arrayIndex:t,value:n[t],record:i,index:r},{resultMap:l,results:c,tokenSearchers:s,fullSearcher:a})}_computeScore(e,t){this._log("\n\nComputing score:\n");for(let n=0,i=t.length;n<i;n+=1){const i=t[n].output,r=i.length;let o=1,s=1;for(let t=0;t<r;t+=1){let n=e?e[i[t].key].weight:1,r=(1===n?i[t].score:i[t].score||.001)*n;1!==n?s=Math.min(s,r):(i[t].nScore=r,o*=r)}t[n].score=1===s?o:s,this._log(t[n])}}_sort(e){this._log("\n\nSorting...."),e.sort(this.options.sortFn)}_format(e){const t=[];if(this.options.verbose){let t=[];this._log("\n\nOutput:\n\n",JSON.stringify(e,function(e,n){if("object"==typeof n&&null!==n){if(-1!==t.indexOf(n))return;t.push(n)}return n})),t=null}let n=[];this.options.includeMatches&&n.push((e,t)=>{const n=e.output;t.matches=[];f
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
!function(){"use strict";var n={}.hasOwnProperty;function r(){for(var e=[],t=0;t<arguments.length;t++){var i=arguments[t];if(i){var o=typeof i;if("string"===o||"number"===o)e.push(i);else if(Array.isArray(i)&&i.length){var s=r.apply(null,i);s&&e.push(s)}else if("object"===o)for(var a in i)n.call(i,a)&&i[a]&&e.push(a)}}return e.join(" ")}e.exports?(r.default=r,e.exports=r):void 0===(i=function(){return r}.apply(t,[]))||(e.exports=i)}()},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.clearChoices=t.activateChoices=t.filterChoices=t.addChoice=void 0;var i=n(1);t.addChoice=function(e){var t=e.value,n=e.label,r=e.id,o=e.groupId,s=e.disabled,a=e.elementId,l=e.customProperties,c=e.placeholder,u=e.keyCode;return{type:i.ACTION_TYPES.ADD_CHOICE,value:t,label:n,id:r,groupId:o,disabled:s,elementId:a,customProperties:l,placeholder:c,keyCode:u}};t.filterChoices=function(e){return{type:i.ACTION_TYPES.FILTER_CHOICES,results:e}};t.activateChoices=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return{type:i.ACTION_TYPES.ACTIVATE_CHOICES,active:e}};t.clearChoices=function(){return{type:i.ACTION_TYPES.CLEAR_CHOICES}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.highlightItem=t.removeItem=t.addItem=void 0;var i=n(1);t.addItem=function(e){var t=e.value,n=e.label,r=e.id,o=e.choiceId,s=e.groupId,a=e.customProperties,l=e.placeholder,c=e.keyCode;return{type:i.ACTION_TYPES.ADD_ITEM,value:t,label:n,id:r,choiceId:o,groupId:s,customProperties:a,placeholder:l,keyCode:c}};t.removeItem=function(e,t){return{type:i.ACTION_TYPES.REMOVE_ITEM,id:e,choiceId:t}};t.highlightItem=function(e,t){return{type:i.ACTION_TYPES.HIGHLIGHT_ITEM,id:e,highlighted:t}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.addGroup=void 0;var i=n(1);t.addGroup=function(e,t,n,r){return{type:i.ACTION_TYPES.ADD_GROUP,value:e,id:t,active:n,disabled:r}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.resetTo=t.clearAll=void 0;t.clearAll=function(){return{type:"CLEAR_ALL"}};t.resetTo=function(e){return{type:"RESET_TO",state:e}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setIsLoading=void 0;t.setIsLoading=function(e){return{type:"SET_IS_LOADING",isLoading:e}}}])});