@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
3 lines • 36.1 kB
JavaScript
/* @license */
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require("kendo.list.min.js"),require("kendo.mobile.scroller.min.js"),require("kendo.virtuallist.min.js"),require("kendo.html.chip.min.js"),require("kendo.html.chiplist.min.js"),require("kendo.html.button.min.js"),require("kendo.core.min.js")):typeof define==`function`&&define.amd?define([`exports`,`kendo.list.min`,`kendo.mobile.scroller.min`,`kendo.virtuallist.min`,`kendo.html.chip.min`,`kendo.html.chiplist.min`,`kendo.html.button.min`,`kendo.core.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Multiselect={}),e.kendo._globals.List,e.kendo._globals.MobileScroller,e.kendo._globals.Virtuallist,e.kendo._globals.HtmlChip,e.kendo._globals.HtmlChiplist,e.kendo._globals.HtmlButton,e.kendo._globals.Core))})(this,function(e,t,n,r,i,a,o,s){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let c=kendo.jQuery;function l({widget:e,wrapper:t,options:n,prefixInsertBefore:r,suffixInsertAfter:i}){var a=n.prefixOptions,o=n.suffixOptions,s=a.template||a.icon,l=o.template||o.icon,i=i||r,u=n.layoutFlow,d=u?u==`vertical`?`horizontal`:`vertical`:`horizontal`,f=`<span class="k-input-separator k-input-separator-${u==`vertical`?`horizontal`:`vertical`}"></span>`,p,m;a&&s&&(p=t.children(`.k-input-prefix`),p[0]||(n._isInInlineAIPrompt&&(d=u||`horizontal`),p=c(`<span class="k-input-prefix k-input-prefix-${d}" />`),r?p.insertBefore(r):p.prependTo(t)),a.icon&&p.html(kendo.html.renderIcon({icon:a.icon,iconClass:a.iconClass})),a.template&&p.html(kendo.template(a.template)({})),a.separator&&c(f).insertAfter(p)),o&&l&&(m=t.children(`.k-input-suffix`),m[0]||(m=c(`<span class="k-input-suffix k-input-suffix-${d}" />`).appendTo(t),i?m.insertAfter(i):m.appendTo(t)),o.icon&&m.html(kendo.html.renderIcon({icon:o.icon,iconClass:o.iconClass})),o.template&&m.html(kendo.template(o.template)({})),o.separator&&c(f).insertBefore(m)),e._prefixContainer=p,e._suffixContainer=m}let u={id:`multiselect`,name:`MultiSelect`,category:`web`,description:`The MultiSelect widget allows the selection from pre-defined values.`,depends:[`list`,`html.chip`,`html.chiplist`,`html.button`],features:[{id:`mobile-scroller`,name:`Mobile scroller`,description:`Support for kinetic scrolling in mobile device`,depends:[`mobile.scroller`]},{id:`virtualization`,name:`VirtualList`,description:`Support for virtualization`,depends:[`virtuallist`]}]};(function(e,t){var n=window.kendo,r=n.ui,i=r.List,a=n.htmlEncode,o=n.html,s=e.extend({A:65},n.keys),c=n._activeElement,u=n.data.ObservableArray,d=`id`,f=`.k-chip`,p=`accept`,m=`filter`,h=`rebind`,g=`open`,_=`close`,v=`change`,y=`progress`,b=`select`,x=`deselect`,S=`selectAllChange`,C=`aria-disabled`,w=`aria-readonly`,T=`aria-expanded`,E=`aria-hidden`,D=`aria-activedescendant`,O=`k-focus`,k=`k-selected`,A=`k-hover`,j=`k-disabled`,M=`k-no-click`,N=`disabled`,P=`readonly`,F=`off`,I=`.kendoMultiSelect`,L=`click`+I,R=`keydown`+I,z=`mouseenter`+I,B=`mouseleave`+I,V=z+` `+B,H=/"/g,U=Array.isArray,W=[`font-family`,`font-size`,`font-stretch`,`font-style`,`font-weight`,`letter-spacing`,`text-transform`,`line-height`],G=i.extend({init:function(t,r){var a=this,o,s;a.ns=I,i.fn.init.call(a,t,r),a.options.summarizeAfter!==null&&a.options.tagMode===`single`&&(a.options.summarizeAfter=null),a._optionsMap={},a._customOptions={},a.options.inputMode=a.options.inputMode||a.element.attr(`inputmode`)||`text`,!n.isPresent(a.options.readonly)&&a.element.attr(`readonly`)?a.options.readonly=!0:n.isPresent(a.options.readonly)||(a.options.readonly=!1),a._wrapper(),a._inputValuesContainer(),a._tagList(),a._input(),a._textContainer(),a._clearButton(),a._arrowButton(),a._tabindex(a.input),t=a.element.attr(`multiple`,`multiple`).hide(),r=a.options,r.placeholder||=t.data(`placeholder`),o=t.attr(d),o||=n.guid(),o&&(a._tagID=o+`_tag_active`,o+=`_taglist`,a.tagList.attr(d,o)),a._initialOpen=!0,r.label&&this._label(),a._aria(),a._dataSource(),a._ignoreCase(),a._popup(),a._tagTemplate(),a.requireValueMapper(a.options),a._initList(),a.listView.content.removeClass(`k-list-scroller`),a._aria(),a.options.virtual&&a.listView.one(`listBound`,function(){a._aria()}),a.listView.bind(`dataBound`,function(){a._aria()}),a._reset(),a._enable(),a._placeholder(),r.autoBind?a.dataSource.fetch():r.value&&a._preselect(r.value),s=e(a.element).parents(`fieldset`).is(`:disabled`),s&&a.enable(!1),a._toggleCloseVisibility(),a._applyCssClasses(),l({widget:a,wrapper:a.wrapper,options:a.options,prefixInsertBefore:a._inputValuesContainer,suffixInsertAfter:r.clearButton?a._clear:a.element.find(`k-input-values`)}),a.floatingLabel&&a.floatingLabel.refresh(),n.notify(a),i.fn.endInit.call(a)},options:{name:`MultiSelect`,tagMode:`multiple`,enabled:!0,autoBind:!0,autoClose:!0,readonly:null,highlightFirst:!0,dataTextField:``,dataValueField:``,filter:`startswith`,ignoreCase:!0,minLength:1,messages:{singleTag:`item(s) selected`,clear:`clear`,deleteTag:`delete`,noData:`No data found.`,downArrow:`select`,selectAll:`Select all`},enforceMinLength:!1,delay:100,downArrow:!1,value:null,maxSelectedItems:null,placeholder:``,height:200,animation:{},virtual:!1,itemTemplate:``,tagTemplate:``,groupTemplate:e=>a(e),fixedGroupTemplate:e=>a(e),prefixOptions:{separator:!0},suffixOptions:{separator:!0},clearButton:!0,autoWidth:!1,popup:null,size:t,fillMode:t,rounded:t,label:null,adaptiveTitle:null,adaptiveSubtitle:null,selectAll:!1,checkboxes:!1,summarizeAfter:10},events:[g,_,v,b,x,S,`filtering`,`dataBinding`,`dataBound`,`kendoKeydown`],setDataSource:function(e){this.options.dataSource=e,this._state=``,this._dataSource(),this.persistTagList=!1,this.listView.setDataSource(this.dataSource),this.options.autoBind&&this.dataSource.fetch()},setOptions:function(e){var t=this._listOptions(e);i.fn.setOptions.call(this,e),this.listView.setOptions(t),e.selectAll===!1?this._removeSelectAllHeader():e.selectAll===!0&&this.listView.bound()&&(this._renderSelectAllHeader(),this._updateSelectAllHeader()),this._accessors(),this._aria(),this._tagTemplate(),this._placeholder(),this._clearButton(),this._arrowButton()},currentTag:function(e){var n=this;if(e!==t)n._currentTag&&(n._currentTag.removeClass(O).removeAttr(d),n._currentTag.find(`.k-chip-action`).attr(E,!0),n.input.removeAttr(D)),e&&(e.addClass(O).attr(d,n._tagID),e.find(`.k-chip-action`).removeAttr(E),n.input.attr(D,n._tagID)),n._currentTag=e;else return n._currentTag},dataItems:function(){return this.listView.selectedDataItems()},destroy:function(){var e=this,t=e.ns;clearTimeout(e._busy),clearTimeout(e._typingTimeout),e.filterInput&&e.filterInput.off(t),e.wrapper.off(t),e.tagList.off(t),e.input.off(t),e._clear.off(t),i.fn.destroy.call(e)},_onActionSheetCreate:function(){var e=this;e.filterInput.on(`keydown`+I,e,e._keydown.bind(e)).on(`input`+I,e._search.bind(e)).on(`paste`+I,e._search.bind(e)).attr({role:`combobox`,"aria-expanded":!1,"aria-controls":e.input.attr(`aria-controls`),"aria-autocomplete":e.input.attr(`aria-autocomplete`),"aria-describedby":e.input.attr(`aria-describedby`),placeholder:e.options.placeholder}),e.popup.bind(`activate`,()=>{e.filterInput.val(e.input.val()),e.filterInput.trigger(`focus`)}),e.popup.bind(`deactivate`,()=>{e.input.trigger(`focus`)})},_aria:function(){var e=this,t=e.ul,n=t.length?t[0].id:null,r=this.options.filter===`none`?`none`:`list`,i=e.tagList.attr(d);n&&(e.input.attr({role:`combobox`,"aria-expanded":!1,"aria-controls":n,"aria-autocomplete":r,"aria-describedby":i}),e._ariaLabel(e._focused))},_updateSelectedVirtualDataItemsIndexes:function(){let e=this,n=e.listView,r=n?._selectedIndexes,i=n?._selectedDataItems,a=e?._customOptions||{},o=e._optionsMap||{};r&&i&&r.forEach((n,r)=>{let s=e.options.dataValueField,c=i[r],l=o[c[s]];a[c[s]]=l===t?a[c[s]]:l})},_activateItem:function(){this.popup.visible()&&i.fn._activateItem.call(this),this.currentTag(null)},_listOptions:function(t){var r=this,o=i.fn._listOptions.call(r,e.extend(t,{selectedItemChange:r._selectedItemChange.bind(r),selectable:`multiple`})),s=this.options.itemTemplate||this.options.template,c=o.itemTemplate||s||o.template;return c||=e=>a(n.getter(o.dataTextField)(e)),o.template=c,r.options.checkboxes&&(o.checkboxes=!0),o},_setListValue:function(){i.fn._setListValue.call(this,this._initialValues.slice(0))},_listChange:function(e){var n=this.dataSource.flatView(),r=this._optionsMap,i=this._value;this._state===h&&(this._state=``);for(var a=0;a<e.added.length;a++)if(r[i(e.added[a].dataItem)]===t){this._render(n);break}this._selectValue(e.added,e.removed)},_selectedItemChange:function(e){var t=e.items,n,r;for(r=0;r<t.length;r++)n=t[r],this.tagList.children(f).eq(n.index).children(`span`).first().html(this.tagTextTemplate(n.item))},_wrapperMousedown:function(t){var r=this,i=t.target.nodeName.toLowerCase()!==`input`,a=e(t.target),o=a.closest(`.k-input-button, .k-chip`).children(`[class*='-i-chevron-down']`)[0],s=a.closest(`[class*='-i-x']`)[0];i&&!(s&&n.support.mobileOS)&&t.cancelable&&t.preventDefault(),s||(o&&r.popup.visible()?r.toggle(!1):(r.input[0]!==c()&&i&&r.input.trigger(`focus`),r.options.minLength===1&&!r.popup.visible()&&r.open()))},_inputFocus:function(){let e=this;e._placeholder(),e.wrapper.addClass(O)},_inputFocusout:function(e){var t=this;t.filterInput&&e.relatedTarget===t.filterInput[0]||(clearTimeout(t._typingTimeout),t.wrapper.removeClass(O),t.tagList.children(f).removeClass(O),t._placeholder(),t.close(),t._state===m&&(t._state=p,t.listView.skipUpdate(!0)),t.listView.bound()&&t.listView.isFiltered()&&(t.persistTagList=!0,t._clearFilter()),t.element.trigger(`blur`))},_removeTag:function(n,r,i){var a=this,o=a._state;i===t&&(i=n.index());var s=a.listView,c=s.value()[i],l=a.listView.selectedDataItems()[i],u=a._customOptions[c],d=s.items().toArray(),f,h;if(a.trigger(x,{dataItem:l,item:n})){a._close();return}u===t&&(o===p||o===m)&&(u=a._optionsMap[c]);var g=function(){a.currentTag(null),r&&a._change(),a._refreshTagListAria(),a._close()};u===t&&s.select().length?(a.persistTagList=!1,s.select(s.select()[i]).done(g)):(f=a.element[0].children[u],f&&(f.selected=!1),s.removeAt(i),s._removedAddedIndexes&&s._removedAddedIndexes.splice(i,1),h=d[u],h&&(e(h).removeClass(`k-selected`).attr(`aria-selected`,!1),a.options.checkboxes&&e(h).find(`input.k-checkbox`).prop(`checked`,!1).removeClass(`k-checked`)),a.options.tagMode===`single`?a._updateTagListHTML():a.options.summarizeAfter===null?n.remove():a._updateTagListHTML(),g()),this._placeholder()},_removeOverflowTag:function(e,t){let n=this,r=n.options.summarizeAfter,i=n.listView,a=i.select().slice(r);if(!a.length){if(i.value().length<=r)return;let e=i._values.splice(r);i._dataItems.splice(r);for(let t=0;t<e.length;t++)n._setOption(e[t],!1);n.currentTag(null),n._updateTagListHTML(),n._placeholder(),t&&n._change(),n._close();return}n.persistTagList=!1,i.select(a).done(function(){n.currentTag(null),n._placeholder(),t&&n._change(),n._close()})},_tagListClick:function(t){t.preventDefault(),t.stopPropagation();var n=e(t.currentTarget);n.is(`[class*='-i-x-circle']`)&&(this._removeTag(n.closest(f),!0),this.focus())},_clearValue:function(){var e=this;e._clearAllValues(),e.input.val(``),e._prev=``,e._state===m&&(e._state=p,e.options.enforceMinLength||e._filterSource()),e.focus(),e._hideClear()},_clearAllValues:function(){let e=this;e.currentTag(null),e.persistTagList=!1,e._clearSingleTagValue(),e._updateTagListHTML(),e._placeholder(),e._change(),e._updateSelectAllHeader()},_removeLastTag:function(){let e=this,t=e.tagList.children(f).last();if(t&&t[0]){let n=e.options.summarizeAfter;n!==null&&t.index()===n&&e.listView.value().length>n?e._removeOverflowTag(t,!0):e._removeTag(t,!0),e._updateSelectAllHeader()}},_clearSingleTagValue:function(){let e=this,t=e.dataItems(),n=e.tagList.children(f),r=e.persistTagList;for(let r=0;r<t.length;r+=1)if(e.trigger(x,{dataItem:t[r],item:n.first()})){e._close();return}r&&(e.persistTagList=!1),e.listView.value([]),e.persistTagList=r},_focusHandler:function(){var e=this.input,t=c();e[0]===t||this.input.trigger(`focus`)},_editable:function(t){var n=this,r=t.disable,i=t.readonly,a=n.wrapper.off(I),o=n.tagList.off(I),s=n.input.off(I);!i&&!r?(a.removeClass(j).removeClass(M).on(V,n._toggleHover).on(`mousedown`+I+` touchend`+I,n._wrapperMousedown.bind(n)).on(L,n._focusHandler.bind(n)),n.input.on(R,n,n._keydown.bind(n)).on(`paste`+I,n._search.bind(n)).on(`input`+I,n._search.bind(n)).on(`focus`+I,n._inputFocus.bind(n)).on(`focusout`+I,n._inputFocusout.bind(n)),n._clear.on(L+` touchend`+I,n._clearValue.bind(n)),s.prop(N,!1).prop(P,!1).attr(C,!1).attr(w,!1),n.element.prop(N,!1),o.on(z,f,function(){e(this).addClass(A)}).on(B,f,function(){e(this).removeClass(A)}).on(L+` touchend`+I,`.k-chip .k-icon,.k-chip .k-svg-icon`,n._tagListClick.bind(n)),n.list.off(L,`.k-list-sticky-header-item`),n.list.on(L,`.k-list-sticky-header-item`,n._onSelectAllClick.bind(n))):(a.toggleClass(j,r).toggleClass(M,i),s.attr(N,r).attr(P,i).attr(C,r).attr(w,i),n.element.prop(N,r),n.list.off(L+` touchend`+I,`.k-list-sticky-header-item`))},_close:function(){var e=this;e.options.autoClose?e.close():e.popup.position()},_filterSource:function(e,t){t||=this._retrieveData,this._retrieveData=!1,i.fn._filterSource.call(this,e,t)},close:function(){this._activeItem=null,this._selectAllFocused=!1,this.list.find(`.k-list-sticky-header-item`).removeClass(O),this.input.removeAttr(D),this.popup.close()},open:function(){var t=this,n=t.input.val().toLowerCase(),r=t.listView.dataSource.filter(),i=``;r&&r.filters.length>0&&(i=(r.filters[0].value||``).toString().toLowerCase()),t._request&&(t._retrieveData=!1),t._retrieveData||!t.listView.bound()||t._state===p&&n!==i?(t._open=!0,t._state=h,t.listView.skipUpdate(!0),t.persistTagList=!(t._initialOpen&&!t.listView.bound()),t._filterSource(),t._focusItem()):t._allowOpening()&&(t._initialOpen&&!t.options.autoBind&&!t.options.virtual&&t.options.value&&!e.isPlainObject(t.options.value[0])&&t.value(t.value()||t._initialValues),t.popup._hovered=!0,t._initialOpen=!1,t.popup.open({altTarget:t.wrapper.add(t.element).add(t.input)}),t.options.selectAll&&t._updateSelectAllHeader(),t.options.checkboxes&&t._syncListCheckboxes(),t._focusItem())},toggle:function(e){e=e===t?!this.popup.visible():e,this[e?g:_]()},refresh:function(){this.listView.refresh(),this._updateTagListHTML(),this._updateSelectAllHeader(),this._placeholder()},_floatCheck:function(){return!this.listView||!(this.value()&&this.value().length)&&!this.popup.visible()},_listBound:function(){var e=this,t=e.dataSource.flatView();e._render(t),e._renderFooter(),e._renderNoData(),e._toggleNoData(!t.length),e.options.selectAll&&(e._renderSelectAllHeader(),e._updateSelectAllHeader()),e.options.checkboxes&&e._syncListCheckboxes(),e._resizePopup(),e._open&&(e._open=!1,e.toggle(e._allowOpening())),e.listView._preventFocus||e.popup.position(),e._updateItemFocus(),e.options?.virtual?.mapValueTo===`dataItem`&&e._updateSelectedVirtualDataItemsIndexes(),e._touchScroller&&e._touchScroller.reset(),e._hideBusy(),e.trigger(`dataBound`)},_updateItemFocus:function(){var e=this,n=e.dataSource.flatView(),r=e.listView.skip(),i=r===t||r===0;e.listView._preventFocus||n.length&&i&&(e.options.highlightFirst?e.listView.focusFirst():e.listView.focus(-1))},_inputValue:function(){var e=this,t=e.filterInput&&c()===e.filterInput[0]?e.filterInput.val():e.input.val();return e.options.placeholder===t&&(t=``),t},value:function(e){var n=this,r=n.listView,i=r.value().slice(),a=n.options.maxSelectedItems,o=r.bound()&&r.isFiltered();if(e===t)return i;n.persistTagList=!1,n.requireValueMapper(n.options,e),e=n._normalizeValues(e),a!==null&&e.length>a&&(e=e.slice(0,a)),o&&n._clearFilter(),r.value(e),n._old=n._valueBeforeCascade=e.slice(),o||n._fetchData(),n._toggleCloseVisibility()},_preselect:function(t,r){var i=this;!U(t)&&!(t instanceof n.data.ObservableArray)&&(t=[t]),(e.isPlainObject(t[0])||t[0]instanceof n.data.ObservableObject||!i.options.dataValueField)&&(i.dataSource.data(t),i.value(r||i._initialValues),i._retrieveData=!0)},_setOption:function(e,t){var n=this.element[0].children[this._optionsMap[e]];n&&(n.selected=t)},_fetchData:function(){var e=this,t=!!e.dataSource.view().length;e.listView.value().length===0||e._request||(e._retrieveData||!e._fetch&&!t)&&(e._fetch=!0,e._retrieveData=!1,e.dataSource.read().done(function(){e._fetch=!1}))},_isBound:function(){return this.listView.bound()&&!this._retrieveData},_dataSource:function(){var e=this,t=e.element,r=e.options,i=r.dataSource||{};i=U(i)?{data:i}:i,i.select=t,i.fields=[{field:r.dataTextField},{field:r.dataValueField}],e.dataSource&&e._refreshHandler?e._unbindDataSource():(e._progressHandler=e._showBusy,e._endRequestHandler=e._hideBusy,e._errorHandler=function(){e._hideBusy()}),e.dataSource=n.data.DataSource.create(i).bind(y,e._progressHandler).bind(`requestEnd`,e._endRequestHandler).bind(`error`,e._errorHandler)},_reset:function(){var t=this,n=t.element,r=n.attr(`form`),i=r?e(`#`+r):n.closest(`form`);i[0]&&(t._resetHandler=function(){setTimeout(function(){t.value(t._initialValues),t._placeholder()})},t._form=i.on(`reset`,t._resetHandler))},_initValue:function(){var e=this.options.value||this.element.val();this._old=this._initialValues=this._normalizeValues(e)},_normalizeValues:function(t){var n=this;return t===null?t=[]:t&&e.isPlainObject(t)?t=[n._value(t)]:t&&e.isPlainObject(t[0])?t=e.map(t,function(e){return n._value(e)}):!U(t)&&!(t instanceof u)?t=[t]:U(t)&&(t=t.slice()),t},_change:function(){var e=this,t=e.value();K(t,e._old)||(e._old=t.slice(),e.trigger(v),e.element.trigger(v)),e.popup.position(),e._toggleCloseVisibility()},_click:function(e){var t=this,n=e.item;e.preventDefault(),t._select(n).done(function(){t._activeItem=n,t._change(),t._close()})},_getActiveItem:function(){return this._activeItem||e(this.listView.items()[this._getSelectedIndices().length-1])||this.listView.focus()},_getSelectedIndices:function(){return this.listView._selectedIndices||this.listView._selectedIndexes},_keydown:function(r){var i=this,a=r.keyCode,o=i._currentTag,c=i.listView,l=i.input.val(),u=n.support.isRtl(i.wrapper),d=i.popup.visible(),m=0,h,g=!1;if(a!==s.ENTER&&(this._multipleSelection=!1),a===s.DOWN){if(r.preventDefault(),!d){i.open(),c.focus()||c.focusFirst(),r.stopPropagation();return}i._selectAllFocused?(i.list.find(`.k-list-sticky-header-item`).removeClass(O),i._selectAllFocused=!1,i.input.removeAttr(D),c.focusFirst()):c.focus()?(!i._activeItem&&r.shiftKey&&(i._activeItem=c.focus(),m=-1),h=c.getElementIndex(i._getActiveItem().first()),c.focusNext(),c.focus()?r.shiftKey&&!i.options.virtual&&(this._multipleSelection=!0,i._selectRange(h,c.getElementIndex(c.focus().first())+m)):c.focusLast()):c.focusFirst(),g=!0}else if(a===s.UP)d&&(i._selectAllFocused?(i.list.find(`.k-list-sticky-header-item`).removeClass(O),i._selectAllFocused=!1,i.input.removeAttr(D),i.close()):i.options.selectAll&&c.focus()&&c.getElementIndex(c.focus())===0?(c.focus(-1),i.list.find(`.k-list-sticky-header-item`).addClass(O),i._selectAllFocused=!0,i.input.attr(D,i.element[0].id+`_selectAll`)):(!i._activeItem&&r.shiftKey&&(i._activeItem=c.focus(),m=1),h=c.getElementIndex(i._getActiveItem().first()),c.focusPrev(),c.focus()?r.shiftKey&&!i.options.virtual&&(this._multipleSelection=!0,i._selectRange(h,c.getElementIndex(c.focus().first())+m)):i.close())),g=!0,r.preventDefault();else if(a===s.LEFT&&!u||a===s.RIGHT&&u)l||(o=o?o.prev(f):i.tagList.children(f).last(),o[0]&&i.currentTag(o)),g=!0;else if(a===s.RIGHT&&!u||a===s.LEFT&&u)!l&&o&&(o=o.next(f),i.currentTag(o[0]?o:null)),g=!0;else if(r.ctrlKey&&!r.altKey&&a===s.A&&d&&!i.options.virtual)this._multipleSelection=!0,this._getSelectedIndices().length===c.items().length&&(i._activeItem=null),c.items().length&&(i._selectRange(0,c.items().length-1),i._updateSelectAllHeader()),g=!0;else if(a===s.ENTER&&d)if(i._selectAllFocused)i._onSelectAllClick({preventDefault:e.noop}),r.preventDefault(),g=!0;else{if(!c.focus()){r.stopPropagation();return}if(r.preventDefault(),this._multipleSelection&&(this._multipleSelection=!1,c.focus().hasClass(k))){i._close(),r.stopPropagation();return}i._select(c.focus()).done(function(){i._change(),i._close()}),g=!0}else if(a===s.SPACEBAR&&r.ctrlKey&&d&&i._selectAllFocused)i._onSelectAllClick({preventDefault:e.noop}),r.preventDefault(),g=!0;else if(a===s.SPACEBAR&&r.ctrlKey&&d&&!i._selectAllFocused)i._activeItem&&c.focus()&&c.focus()[0]===i._activeItem[0]&&(i._activeItem=null),e(c.focus()).hasClass(k)||(i._activeItem=c.focus()),i._select(c.focus()).done(function(){i._change()}),g=!0,r.preventDefault();else if(a===s.SPACEBAR&&r.shiftKey&&d&&!i.options.virtual){var _=c.getElementIndex(i._getActiveItem()),v=c.getElementIndex(c.focus());_!==t&&v!==t&&i._selectRange(_,v),g=!0,r.preventDefault()}else if(a===s.ESC){if(d)r.preventDefault();else if(i.options.tagMode===`single`){var y=c.value().length-1;if(y>=0){var b=i.tagList.children(f).last();i._removeTag(b,!1,y),i._change()}}else i._clearAllValues();i.close(),g=!0}else if(a===s.HOME)d?c.focus()?(r.ctrlKey&&r.shiftKey&&!i.options.virtual&&i._selectRange(c.getElementIndex(c.focus()[0]),0),c.focusFirst()):i.close():l||(o=i.tagList.children(f).first()[0],o&&i.currentTag(e(o))),g=!0;else if(a===s.END)d?c.focus()?(r.ctrlKey&&r.shiftKey&&!i.options.virtual&&i._selectRange(c.getElementIndex(c.focus()[0]),c.items().length-1),c.focusLast()):i.close():l||(o=i.tagList.children(f).last()[0],o&&i.currentTag(e(o))),g=!0;else if(a===s.DELETE&&!l){if(i._state=p,i.options.tagMode===`single`){i._clearAllValues(),i._close(),r.stopPropagation();return}if(o&&o[0]){let e=i.options.summarizeAfter;e!==null&&o.index()===e&&c.value().length>e?i._removeOverflowTag(o,!0):i._removeTag(o,!0),i._updateSelectAllHeader()}g=!0}else if(a===s.BACKSPACE&&!l&&i.options.tagMode===`single`){i._state=p,i._clearAllValues(),i._close(),r.stopPropagation();return}else if(a===s.BACKSPACE&&!l){if(i._state=p,!o)i._removeLastTag();else if(o[0]){let e=i.options.summarizeAfter;e!==null&&o.index()===e&&c.value().length>e?i._removeOverflowTag(o,!0):i._removeTag(o,!0),i._updateSelectAllHeader()}g=!0}else if(i.popup.visible()&&(a===s.PAGEDOWN||a===s.PAGEUP)){r.preventDefault();var x=a===s.PAGEDOWN?1:-1;c.scrollWith(x*c.screenHeight()),g=!0}else clearTimeout(i._typingTimeout),i._search(),g=!0;g&&r.stopPropagation()},_placeholder:function(){let e=this,t=e.input,n=c(),r=t[0]===n;this.listView.selectedDataItems().length>0?t.removeAttr(`placeholder`):t.attr(`placeholder`,e.options.placeholder),(!r||e.options.autoClose)&&t.val(``),e._prev=t.val()},_option:function(e,r,i){var a=`<option`;return e!==t&&(e+=``,e.indexOf(`"`)!==-1&&(e=e.replace(H,`"`)),a+=` value="`+e+`"`),i&&(a+=` selected`),a+=`>`,r!==t&&(a+=n.htmlEncode(r)),a+=`</option>`},_render:function(e){var t=this.listView.selectedDataItems(),n=this.listView.value(),r=e.length,i,a=``,o,s,c;n.length!==t.length&&(t=this._buildSelectedItems(n));var l={},u={};for(c=0;c<r;c++)o=e[c],s=this._value(o),i=this._selectedItemIndex(s,t),i!==-1&&t.splice(i,1),u[s]=c,a+=this._option(s,this._text(o),i!==-1);if(t.length)for(c=0;c<t.length;c++)o=t[c],s=this._value(o),l[s]=r,u[s]=r,r+=1,a+=this._option(s,this._text(o),!0);this._customOptions=l,this._optionsMap=u,this.element.html(a)},_buildSelectedItems:function(e){for(var t=this.options.dataValueField,n=this.options.dataTextField,r=[],i,a=0;a<e.length;a++)i={},i[t]=e[a],i[n]=e[a],r.push(i);return r},_selectedItemIndex:function(e,t){for(var n=this._value,r=0;r<t.length;r++)if(e===n(t[r]))return r;return-1},_search:function(e){let t=this;if(e===!0){t._performSearch();return}clearTimeout(t._typingTimeout),t._typingTimeout=setTimeout(function(){t._performSearch()},t.options.delay)},_performSearch:function(){var e=this,t=e._inputValue();e._prev!==t&&(e._prev=t,e.search(t),e._toggleCloseVisibility())},_toggleCloseVisibility:function(){this.value().length||this.input.val()&&this.input.val()!==this.options.placeholder?this._showClear():this._hideClear()},_allowOpening:function(){return this._allowSelection()&&i.fn._allowOpening.call(this)},_allowSelection:function(){var e=this.options.maxSelectedItems;return e===null||e>this.listView.value().length},updatePersistTagList:function(e,t){this.persistTagList.added&&this.persistTagList.added.length===t.length&&this.persistTagList.removed&&this.persistTagList.removed.length===e.length?this.persistTagList=!1:(this.listView._removedAddedIndexes=this._old.slice(),this.persistTagList={added:e,removed:t})},_selectValue:function(e,t){var r=this,i=r.dataSource.total(),a=r.tagList,o=r._value,s,c,l;if(this.persistTagList){this.updatePersistTagList(e,t),r._refreshTagListAria();return}if(r._effectiveTagMode()===`multiple`)if(r.options.summarizeAfter!==null){for(r._updateTagListHTML(),l=t.length-1;l>-1;l--)r._setOption(o(t[l].dataItem),!1);for(l=0;l<e.length;l++)r._setOption(o(e[l].dataItem),!0)}else{for(l=t.length-1;l>-1;l--)s=t[l],a.children(f).length&&(a[0].removeChild(a[0].children[s.position]),r._setOption(o(s.dataItem),!1));for(l=0;l<e.length;l++)c=e[l],r.tagList.append(r.tagTemplate(c.dataItem)),r._setOption(o(c.dataItem),!0);n.applyStylesFromKendoAttributes(r.tagList,[`background-color`])}else{for((!r._maxTotal||r._maxTotal<i)&&(r._maxTotal=i),this._updateTagListHTML(),l=t.length-1;l>-1;l--)r._setOption(o(t[l].dataItem),!1);for(l=0;l<e.length;l++)r._setOption(o(e[l].dataItem),!0)}r._refreshTagListAria(),r._refreshFloatingLabel(),r._placeholder(),r.options.selectAll&&r._updateSelectAllHeader(),r.options.checkboxes&&r._syncListCheckboxes()},_refreshTagListAria:function(){var t=this;o.renderChipList(t.tagList,e.extend({selectable:t.value().length===0?`none`:`multiple`},t.options))},_updateTagListHTML:function(){let t=this,r=t.dataSource.total(),i=t.tagList,s=t.listView.value().length;if(i.children(f).each(function(t,n){e(n).remove()}),t.options.summarizeAfter!==null&&s>=t.options.summarizeAfter){let r=t.dataItems(),i=t.options.summarizeAfter,s=r.slice(0,i),c=r.length-i;for(let e of s)t.tagList.append(t.tagTemplate(e));c>0&&t.tagList.append(o.renderChip(`<span unselectable="on"></span>`,e.extend({},t.options,{enabled:!0,text:`+`+c+` `+a(t.options.messages.singleTag),attr:{unselectable:`on`,"aria-selected":!0,role:`option`,"aria-keyshortcuts":`Enter`},removable:!1,removableAttr:{},icon:`chevron-down`,iconAttr:{unselectable:`on`,"aria-hidden":!0,"aria-label":`open`}}))),n.applyStylesFromKendoAttributes(t.tagList,[`background-color`])}else if(t._effectiveTagMode()===`multiple`){let e=t.dataItems();for(let n=0;n<e.length;n++)t.tagList.append(t.tagTemplate(e[n]));n.applyStylesFromKendoAttributes(t.tagList,[`background-color`])}else{let e=t.value();if(!e.length){t._refreshTagListAria();return}t.tagList.append(t.tagTemplate({values:e,dataItems:t.dataItems(),maxTotal:t._maxTotal,currentTotal:r})),n.applyStylesFromKendoAttributes(t.tagList,[`background-color`])}t._refreshTagListAria()},_select:function(t){var n=e.Deferred().resolve();if(!t)return n;var r=this,i=r.listView,a=i.dataItemByIndex(i.getElementIndex(t)),o=r.options.checkboxes?t.find(`input.k-checkbox`).prop(`checked`):t.hasClass(`k-selected`);return r._state===h&&(r._state=``),!r._allowSelection()&&!o?n:r.trigger(o?x:b,{dataItem:a,item:t})?(r._close(),n):o&&r.options.virtual&&r.options.checkboxes?(r._deselectItemDirect(t,a),n):(r.persistTagList=!1,i.select(t).done(function(){r._placeholder(),r._state===m&&(r._state=p,i.skipUpdate(!0))}))},_selectIndices:function(t){let n=this.listView,r=this;n.select(t).done(function(){t.forEach(function(t){var i=n.dataItemByIndex(t),a=n.items()[t],o=e(a).hasClass(`k-selected`);r.trigger(o?b:x,{dataItem:i,item:e(a)})}),r._change()})},_selectRange:function(e,t){var n=this,r=this.options.maxSelectedItems,i=this._getSelectedIndices().slice(),a=[],o;if(i.length-1===t-e)return n._selectIndices(i);if(e<t)for(o=e;o<=t;o++)a.push(o);else for(o=e;o>=t;o--)a.push(o);for(r!==null&&a.length>r&&(a=a.slice(0,r)),o=0;o<a.length;o++){var s=a[o];this._getSelectedIndices().indexOf(s)==-1?i.push(s):i.splice(i.indexOf(s),1)}if(i.length)return n.persistTagList=!1,n._selectIndices(i)},_input:function(){var t=this,n=t.element,r=n[0].accessKey,i=t._inputValuesContainer.children(`input.k-input-inner`);i[0]||(i=e(`<input class="k-input-inner" />`).appendTo(t._inputValuesContainer)),n.removeAttr(`accesskey`),i.attr(`data-validate`,`false`),i.attr(`inputmode`,t.options.inputMode),t._focused=t.input=i.attr({autocomplete:F,title:n[0].title}),i.attr(`placeholder`,t.options.placeholder),r&&t._focused.attr(`accesskey`,r)},_inputValuesContainer:function(){var t=this,n=t.wrapper.children(`.k-input-values`);n[0]||(n=e(`<div class="k-input-values"></div>`).appendTo(t.wrapper)),t._inputValuesContainer=n},_tagList:function(){var t=this,n=t.options,r=t._inputValuesContainer.children(`.k-chip-list`);r[0]||(r=e(o.renderChipList(`<div unselectable="on" class="k-selection-multiple" />`,e.extend({selectable:`none`},n))).appendTo(t._inputValuesContainer)),t.tagList=r},_tagTemplate:function(){var t=this,r=t.options,i=r.tagTemplate,s=r.dataSource,c=r.tagMode===`multiple`,l=r.messages.singleTag,u,d,f;t.element[0].length&&!s&&(r.dataTextField=r.dataTextField||`text`,r.dataValueField=r.dataValueField||`value`),d=e=>a(n.getter(r.dataTextField)(e)),f=({values:e})=>`${e.length} ${a(l)}`,u=c?d:f,t.tagTextTemplate=i=i?n.template(i):u,t.tagTemplate=function(n){return o.renderChip(`<span unselectable="on"></span>`,e.extend({},r,{enabled:!0,text:i(n),attr:{unselectable:`on`,"aria-selected":!0,role:`option`,"aria-keyshortcuts":c?`Enter Delete`:`Enter`},removable:c,removableAttr:{unselectable:`on`,"aria-hidden":!0,"aria-label":t.options.messages.deleteTag,title:t.options.messages.deleteTag},icon:c?``:`chevron-down`,iconAttr:{unselectable:`on`,"aria-hidden":!0,"aria-label":`open`}}))}},_popup:function(){i.fn._popup.call(this),this.popup.element.addClass(`k-multiselect-popup`)},_clearButton:function(){i.fn._clearButton.call(this),this.options.clearButton&&this._clear.insertAfter(this._inputValuesContainer)},_arrowButton:function(){var t=a(this.options.messages.downArrow),n=e(o.renderButton(`<button type="button" aria-label="`+t+`" class="k-input-button"></button>`,e.extend({},this.options,{icon:`chevron-down`,rounded:null})));this._arrow&&=(this._arrow.remove(),null),this.options.downArrow&&(this._arrow=n.attr({tabIndex:-1}),this._arrow.appendTo(this.wrapper))},_textContainer:function(){var t=n.getComputedStyles(this.input[0],W);t.position=`absolute`,t.visibility=`hidden`,t.top=-3333,t.left=-3333,this._span=e(`<span/>`).css(t).appendTo(this.wrapper)},_wrapper:function(){var e=this,t=e.element,n=t.parent(`span.k-multiselect`);n[0]||(n=t.wrap(`<span class="k-multiselect k-input" unselectable="on" />`).parent(),n[0].style.cssText=t[0].style.cssText),e.wrapper=n.addClass(t[0].className).removeClass(`input-validation-error`).css(`display`,``)},_renderSelectAllHeader:function(){let e=this;e._removeSelectAllHeader();let t=e.element[0].id+`_selectAll`,n=e.options.messages.selectAll,r=e.options.checkboxes?`<span class="k-checkbox-wrap"><input class="k-checkbox" type="checkbox" aria-label="`+a(n)+`"></span>`:``,i=e.options.checkboxes?``:` role="button"`,o=`<div class="k-list-sticky-header"><div class="k-list-sticky-header-item" id="`+t+`"`+i+`>`+r+`<span class="k-list-item-text">`+a(n)+`</span></div></div>`;e.list.prepend(o)},_removeSelectAllHeader:function(){this.list.children(`.k-list-sticky-header`).remove()},_syncListCheckboxes:function(){this.listView.items().each(function(){let t=e(this),n=t.attr(`aria-selected`)===`true`;t.find(`input.k-checkbox`).toggleClass(`k-checked`,n).prop(`checked`,n)})},_selectAllState:function(){let e=this,t=e._listSelectedCount(),n=e.dataSource.total();return t===0?`unchecked`:t>=n?`checked`:`indeterminate`},_updateSelectAllHeader:function(){let e=this;if(!e.options.selectAll)return;let t=e.list.find(`.k-list-sticky-header`);if(!t.length)return;let n=e._selectAllState();if(e.options.checkboxes){let e=t.find(`input.k-checkbox`),r=n===`checked`?`true`:n===`indeterminate`?`mixed`:`false`;e.toggleClass(`k-checked`,n===`checked`).toggleClass(`k-indeterminate`,n===`indeterminate`).prop(`checked`,n===`checked`).attr(`aria-checked`,r)}else t.find(`.k-list-sticky-header-item`).toggleClass(k,n===`checked`)},_focusSelectAllHeader:function(){let e=this,t=e.list.find(`.k-list-sticky-header-item`);t.length&&(e.listView.focus(-1),t.addClass(O),e._selectAllFocused=!0,e.input.attr(D,e.element[0].id+`_selectAll`))},_onSelectAllClick:function(e){let t=this;e.preventDefault();let n=t._selectAllState();t.trigger(S,{checked:n!==`checked`})||(n===`checked`?(t._deselectAllItems(),t._updateTagListHTML(),t._placeholder(),t._updateSelectAllHeader(),t._change(),t._close(),t._clearFilterOnAutoClose(),t.options.autoClose||t._focusSelectAllHeader()):t._selectAllItems().done(function(){t._change(),t._close(),t._clearFilterOnAutoClose(),t.options.autoClose||t._focusSelectAllHeader()}))},_clearFilterOnAutoClose:function(){let e=this;e.options.autoClose&&(e._state===m&&(e._state=p,e.listView.skipUpdate(!0)),e.listView.bound()&&e.listView.isFiltered()&&(e.persistTagList=!0,e._clearFilter()))},_deselectItemDirect:function(e,t){let n=this,r=n.listView,i=n._value,a=i(t),o=r._values.indexOf(a);o>-1&&(r._values.splice(o,1),r._selectedDataItems.splice(o,1),r._selectedIndexes.splice(o,1)),n.options.checkboxes&&(e.find(`input.k-checkbox`).prop(`checked`,!1).removeClass(`k-checked`),e.attr(`aria-selected`,!1)),n._effectiveTagMode()===`multiple`?o>-1&&(n.tagList.children(f).eq(o).remove(),n._setOption(a,!1)):n._updateTagListHTML(),n._placeholder(),n._updateSelectAllHeader()},_selectAllItems:function(){let t=this,n=t.listView,r=t.dataSource.flatView(),i=n.value(),a=t._value,o=t.options.maxSelectedItems,s=!!t.options.virtual,c=s&&n.skip()||0,l=s?t.dataSource.total():r.length,u={};for(let e=0;e<i.length;e++)u[i[e]]=!0;let d=[];for(let e=0;e<r.length;e++){let t=c+e;t<l&&!u[a(r[e])]&&d.push(t)}if(o!==null){let t=o-i.length;if(t<=0)return e.Deferred().resolve();d=d.slice(0,t)}return d.length?(t.persistTagList=!1,s&&(n._preventFocus=!0),n.select(d).done(function(){s&&(n._preventFocus=!1);let r=n.skip()||0;for(let i=0;i<d.length;i++){let a=d[i],o=n.dataItemByIndex(a),s=a-r,c=e(n.items()[s]);t.trigger(b,{dataItem:o,item:c})}})):e.Deferred().resolve()},_deselectAllItems:function(){let t=this,n=t.listView,r=t.dataSource.flatView(),i=t._value,a=n.value(),o={},s=[];if(t.options.virtual){t.persistTagList=!1,n._values=[],n._selectedDataItems=[],n._selectedIndexes=[],n.value([]),n.items().each(function(){let t=e(this);t.attr(`aria-selected`,`false`).removeClass(`k-selected`),t.find(`input.k-checkbox`).prop(`checked`,!1).removeClass(`k-checked`)});return}for(let e=0;e<r.length;e++)o[i(r[e])]=!0;for(let e=0;e<a.length;e++)o[a[e]]||s.push(a[e]);let c=n.selectedDataItems().filter(function(e){return!o[i(e)]});t.persistTagList=!1,n.value([]),c.length?n.selectedDataItems(c):s.length&&n.setValue(s)},_listSelectedCount:function(){return this.options.virtual?this.listView.value().length:Math.max(0,this.listView.value().length-Object.keys(this._customOptions).length)},_effectiveTagMode:function(){return this.options.summarizeAfter!==null&&this._listSelectedCount()>=this.options.summarizeAfter?`single`:this.options.tagMode},_closeHandler:function(e){this.trigger(_)?e.preventDefault():(this.input.attr(T,!1),this.ul.attr(E,!0),this._selectAllFocused&&(this.list.find(`.k-list-sticky-header-item`).removeClass(O),this._selectAllFocused=!1,this.input.removeAttr(D)))},_openHandler:function(e){this._adjustListWidth(),this.trigger(g)?e.preventDefault():(this.input.attr(T,!0),this.ul.attr(E,!1))}});function K(e,t){var n;if(e===null||t===null)return e===t;if(n=e.length,n!==t.length)return!1;for(;n--;)if(e[n]!==t[n])return!1;return!0}r.plugin(G),n.cssProperties.registerPrefix(`MultiSelect`,`k-input-`),n.cssProperties.registerValues(`MultiSelect`,[{prop:`rounded`,values:n.cssProperties.roundedValues.concat([[`full`,`full`]])}])})(window.kendo.jQuery);var d=kendo;e.__meta__=u,e.default=d});
//# sourceMappingURL=kendo.multiselect.min.js.map