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

2 lines
40 KiB
JavaScript
Raw Normal View History

!function(t){function e(n){if(i[n])return i[n].exports;var s=i[n]={exports:{},id:n,loaded:!1};return t[n].call(s.exports,s,s.exports,e),s.loaded=!0,s.exports}var i={};return e.m=t,e.c=i,e.p="/assets/scripts/dist/",e(0)}([function(t,e,i){t.exports=i(1)},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(e,"__esModule",{value:!0}),e.Choices=void 0;var o=function(){function t(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}return function(e,i,n){return i&&t(e.prototype,i),n&&t(e,n),e}}(),r=i(2),a=i(3),c=i(4),l=n(c),u=i(5),d=n(u),h=e.Choices=function(){function t(){var e=arguments.length<=0||void 0===arguments[0]?"[data-choice]":arguments[0],i=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];if(s(this,t),(0,a.isType)("String",e)){var n=document.querySelectorAll(e);if(n.length>1)for(var o=1;o<n.length;o++){var r=n[o];new t(r,i)}}var c={items:[],addItems:!0,removeItems:!0,editItems:!1,maxItems:!1,delimiter:",",allowDuplicates:!0,allowPaste:!0,allowSearch:!0,regexFilter:!1,placeholder:!0,placeholderValue:"",prependValue:!1,appendValue:!1,selectAll:!0,templates:{},classNames:{containerOuter:"choices",containerInner:"choices__inner",input:"choices__input",inputCloned:"choices__input--cloned",list:"choices__list",listItems:"choices__list--multiple",listSingle:"choices__list--single",listDropdown:"choices__list--dropdown",item:"choices__item",itemSelectable:"choices__item--selectable",itemDisabled:"choices__item--disabled",itemOption:"choices__item--option",group:"choices__group",groupHeading:"choices__heading",activeState:"is-active",focusState:"is-focused",openState:"is-open",disabledState:"is-disabled",highlightedState:"is-highlighted",hiddenState:"is-hidden",flippedState:"is-flipped",selectedState:"is-selected"},callbackOnInit:function(){},callbackOnRender:function(){},callbackOnRemoveItem:function(){},callbackOnAddItem:function(){}};this.options=(0,a.extend)(c,i),this.store=new d.default(this.render),this.currentState={},this.prevState={},this.passedElement=(0,a.isType)("String",e)?document.querySelector(e):e,this.highlightPosition=0,this.presetItems=[],this.options.items.length?this.presetItems=this.options.items:""!==this.passedElement.value&&(this.presetItems=this.passedElement.value.split(this.options.delimiter)),this.init=this.init.bind(this),this.render=this.render.bind(this),this.destroy=this.destroy.bind(this),this.onFocus=this.onFocus.bind(this),this.onBlur=this.onBlur.bind(this),this.onKeyUp=this.onKeyUp.bind(this),this.onKeyDown=this.onKeyDown.bind(this),this.onClick=this.onClick.bind(this),this.onPaste=this.onPaste.bind(this),this.onMouseOver=this.onMouseOver.bind(this);var l="querySelector"in document&&"addEventListener"in document&&"classList"in document.createElement("div");l||console.error("Choices: Your browser doesn't support Choices");var u=["select-one","select-multiple","text"],h=this.passedElement&&u.includes(this.passedElement.type);h?this.init():console.error("Choices: Incompatible input passed")}return o(t,[{key:"handleEnter",value:function(t,e){var i=!0;if("text"===this.passedElement.type&&(this.options.addItems?this.options.maxItems&&this.options.maxItems<=this.list.children.length?i=!1:this.options.allowDuplicates===!1&&this.passedElement.value&&(i=!t.some(function(t){return t.value===e})):i=!1,i)){var n=!0;this.options.regexFilter&&(n=this.regexFilter(e)),n&&(this.addItem(e),this.clearInput(this.passedElement))}}},{key:"handleBackspace",value:function(t){if(this.options.removeItems&&t){var e=t[t.length-1],i=t.some(function(t){return t.selected===!0});this.options.editItems&&!i&&e?(this.input.value=e.value,this.removeItem(e)):(this.selectItem(e),this.removeSelectedItems())}}},{key:"onKeyDown",value:function(t){if(t.target===this.input){var e=t.ctrlKey||t.metaKey,i=46,n=8,s=13,o=65,r=27,c=38,l=40,u=this.store.getItemsFilteredByActive(),d=(t
},[]);return e}},{key:"getGroups",value:function(){var t=this.store.getState();return t.groups}},{key:"getGroupsFilteredByActive",value:function(){var t=this.getGroups(),e=this.getOptions(),i=t.filter(function(t){var i=t.active===!0&&t.disabled===!1,n=e.some(function(t){return t.active===!0&&t.disabled===!1});return!(!i||!n)},[]);return i}}]),t}();t.exports=l},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}e.__esModule=!0,e.compose=e.applyMiddleware=e.bindActionCreators=e.combineReducers=e.createStore=void 0;var s=i(7),o=n(s),r=i(12),a=n(r),c=i(14),l=n(c),u=i(15),d=n(u),h=i(16),p=n(h),f=i(13);n(f);e.createStore=o.default,e.combineReducers=a.default,e.bindActionCreators=l.default,e.applyMiddleware=d.default,e.compose=p.default},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e,i){function n(){f===p&&(f=p.slice())}function o(){return h}function c(t){if("function"!=typeof t)throw new Error("Expected listener to be a function.");var e=!0;return n(),f.push(t),function(){if(e){e=!1,n();var i=f.indexOf(t);f.splice(i,1)}}}function l(t){if(!(0,r.default)(t))throw new Error("Actions must be plain objects. Use custom middleware for async actions.");if("undefined"==typeof t.type)throw new Error('Actions may not have an undefined "type" property. Have you misspelled a constant?');if(v)throw new Error("Reducers may not dispatch actions.");try{v=!0,h=d(h,t)}finally{v=!1}for(var e=p=f,i=0;i<e.length;i++)e[i]();return t}function u(t){if("function"!=typeof t)throw new Error("Expected the nextReducer to be a function.");d=t,l({type:a.INIT})}if("function"==typeof e&&"undefined"==typeof i&&(i=e,e=void 0),"undefined"!=typeof i){if("function"!=typeof i)throw new Error("Expected the enhancer to be a function.");return i(s)(t,e)}if("function"!=typeof t)throw new Error("Expected the reducer to be a function.");var d=t,h=e,p=[],f=p,v=!1;return l({type:a.INIT}),{dispatch:l,subscribe:c,getState:o,replaceReducer:u}}e.__esModule=!0,e.ActionTypes=void 0,e.default=s;var o=i(8),r=n(o),a=e.ActionTypes={INIT:"@@redux/INIT"}},function(t,e,i){function n(t){if(!r(t)||h.call(t)!=a||o(t))return!1;var e=s(t);if(null===e)return!0;var i=u.call(e,"constructor")&&e.constructor;return"function"==typeof i&&i instanceof i&&l.call(i)==d}var s=i(9),o=i(10),r=i(11),a="[object Object]",c=Object.prototype,l=Function.prototype.toString,u=c.hasOwnProperty,d=l.call(Object),h=c.toString;t.exports=n},function(t,e){function i(t){return n(Object(t))}var n=Object.getPrototypeOf;t.exports=i},function(t,e){function i(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(i){}return e}t.exports=i},function(t,e){function i(t){return!!t&&"object"==typeof t}t.exports=i},function(t,e,i){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function s(t,e){var i=e&&e.type,n=i&&'"'+i.toString()+'"'||"an action";return'Reducer "'+t+'" returned undefined handling '+n+". To ignore an action, you must explicitly return the previous state."}function o(t){Object.keys(t).forEach(function(e){var i=t[e],n=i(void 0,{type:a.ActionTypes.INIT});if("undefined"==typeof n)throw new Error('Reducer "'+e+'" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined.');var s="@@redux/PROBE_UNKNOWN_ACTION_"+Math.random().toString(36).substring(7).split("").join(".");if("undefined"==typeof i(void 0,{type:s}))throw new Error('Reducer "'+e+'" returned undefined when probed with a random type. '+("Don't try to handle "+a.ActionTypes.INIT+' or other actions in "redux/*" ')+"namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined.")})}function r(t){for(var e=Object.keys(t),i={},n=0;n<e.length;n++){var r=e[n];"function"==typeof t[r]&&(i[r]=t[r])}var a,c=Object.keys(i);try{o(i)}catch(l){a=l}return fu