UNPKG

@progress/kendo-ui

Version:

This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.

3 lines 3.97 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`),require(`kendo.html.chip.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`,`kendo.html.chip.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Chip={}),e.kendo._globals.Core,e.kendo._globals.HtmlChip))})(this,function(e,t,n){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let r={id:`chip`,name:`Chip`,category:`web`,docsCategory:`navigation`,description:`Displays a Chip that represents an input, attribute or an action`,depends:[`core`,`html.chip`]};(function(e,t){var n=window.kendo,r=n.ui.Widget,i=n.html,a=n.ui,o=n.keys,s=`select`,c=`click`,l=`remove`,u=`.kendoChip`,d=`.`,f={widget:`k-chip`,iconElement:`k-chip-icon`,removeIconElement:`k-chip-remove-action`,selected:`k-selected`,disabled:`k-disabled`,focus:`k-focus`,avatarClass:`k-chip-avatar`},p=r.extend({init:function(a,o){var s=this;r.fn.init.call(s,a,o),i.renderChip(a,e.extend({},s.options)),o=s.options,s.wrapper=s.element.closest(`.k-chip`),s._enabled=s.options.enabled=o.enabled===t?!s.element.is(`[disabled]`):o.enabled,s._selected=s.options.selected,s._selectable=s.options.selectable,s._setTabIndex(),s._applyAriaAttributes(),s._bindEvents(),n.notify(s)},options:{name:`Chip`,enabled:!0,selectable:!1,selected:!1,removable:!1,icon:``,iconClass:``,avatarClass:``,label:``,removeIcon:`x-circle`,removeIconClass:``,fillMode:t,rounded:t,size:t,themeColor:t},events:[s,c,l],destroy:function(){var e=this;e.wrapper.off(u),r.fn.destroy.call(e)},setOptions:function(e){var t=this;t.wrapper.off(u),t.element.insertBefore(t.wrapper),t.wrapper.remove(),r.fn.setOptions.call(t,e),t.element.empty(),i.renderChip(t.element,t.options),t.wrapper=t.element.closest(`.k-chip`),t._setTabIndex(),t._applyAriaAttributes(),t._bindEvents()},enable:function(e){var n=this;if(e===t)return n._enabled;n._enabled=e!==!1,n.wrapper.toggleClass(f.disabled,!n._enabled),n.wrapper.attr(`aria-disabled`,!n._enabled)},select:function(e){var n=this;if(e==t)return n._selected;e=e!==!1,n._selectable&&(n._selected=e,n.wrapper.toggleClass(f.selected,e)),n._applyAriaAttributes()},focus:function(){this._enabled&&this.wrapper.trigger(`focus`)},_bindEvents:function(){var e=this,t=e._click.bind(e),n=e._remove.bind(e),r=e._keydown.bind(e);e.wrapper.on(c+` touchend`+u,t).on(c+` touchend`+u,d+f.removeIconElement,n).on(`keydown`+u,r)},_click:function(e){var t=this;if(!t.enable()){e.preventDefault();return}t.trigger(c,{originalEvent:e})||t._triggerSelect(t,e)},_remove:function(e){e.preventDefault(),e.stopPropagation();var t=this;if(!t.enable()){e.preventDefault();return}t.trigger(l,{originalEvent:e})},_triggerSelect:function(e,t){var n=this;!n._selectable||!n._enabled||n.trigger(s,{originalEvent:t})||n._toggleSelect()},_toggleSelect:function(){var e=this;e.select(!e.select())},_keydown:function(t){var n=this,r=e(t.target),i=t.keyCode;if(i===o.ENTER||i===o.SPACEBAR){if(!n.enable()){t.preventDefault();return}if(n.trigger(c,{originalEvent:t}))return;n._triggerSelect(r,t),i===o.SPACEBAR&&t.preventDefault()}else (i===o.DELETE||i===o.BACKSPACE)&&n.options.removable&&n.trigger(l,{originalEvent:t})},_setTabIndex:function(){var t=this,n=t.enable()?t.options.tabindex||`0`:`-1`;t.options.attributes&&t.options.attributes.class&&(t.options.attributes.class=`${t.wrapper.attr(`class`)||``} ${t.options.attributes.class}`),t.wrapper.attr(e.extend({},t.options.attributes,{tabindex:n,ariaSelectedAttributeName:null}))},_applyAriaAttributes:function(){var e=this,t=(e.options.attributes||{}).role||`button`;e.wrapper.attr(`role`,t),e._selectable&&t==`button`&&e.wrapper.attr(`aria-pressed`,e._selected),e.wrapper.attr(`aria-disabled`,e.enable()===!1)}});a.plugin(p)})(window.kendo.jQuery);var i=kendo;e.__meta__=r,e.default=i}); //# sourceMappingURL=kendo.chip.min.js.map