UNPKG

@progress/kendo-ui

Version:

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

3 lines 5.44 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`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.Inputgroupbase={}),e.kendo._globals.Core))})(this,function(e,t){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let n={id:`inputgroupbase`,name:`InputGroupBase`,category:`web`,description:`The InputGroupBase component.`,depends:[`core`]};(function(e,t){var n=window.kendo,r=n.ui,i=r.Widget,a=e.extend,o=`change`,s=`focus`,c=`click`,l=`select`,u=`.`,d=`disabled`,f=`vertical`,p=`required`,m=`after`,h=i.extend({init:function(e,t){var n=this;i.fn.init.call(n,e,t),n.options=a({},n.options,t),n._iterateMarkupItems(),n._parseItems(n.options.items),n._wrapper(),n.value(n.options.value),n._attachEvents()},options:{name:`InputGroupBase`},events:[o,s,l],ITEM_TEMPLATE:``,NS:`.kendoInputGroupBase`,groupStyles:{},destroy:function(){var t=this;this.items().each(function(t,r){var i=n.widgetInstance(e(r));i&&i.destroy()}),t.element.off(t.NS),i.fn.destroy.call(t)},item:function(t){if(this._indexIsPresent(t))return e(this.items().get(t))},items:function(){return this.wrapper.find(u+this.groupStyles.input)},enable:function(e){var t;e!==!1&&e!==!0||(t=this.element.find(u+this.groupStyles.item),this._disabledOnElements(t,!e))},enableItem:function(t,n){if(!(t!==!1&&t!==!0)){if(this._indexIsPresent(n))n=e(this.element.find(u+this.groupStyles.item).get(n));else if(n instanceof jQuery){if(n.is(`input`))n=n.closest(u+this.groupStyles.item);else if(!n.is(`li`))return}else return;this._disabledOnElements(n,!t)}},value:function(){return!1},_attachEvents:function(){var e=this;e.element.on(s+e.NS,u+e.groupStyles.input,e._focusHandler.bind(e)).on(o+e.NS,u+e.groupStyles.input,e._changeHandler.bind(e)).on(c+e.NS,u+e.groupStyles.input,e._clickHandler.bind(e))},_clickHandler:function(t){var n=e(t.target);this.trigger(l,{target:n})&&(t.preventDefault(),t.stopPropagation(),this._targetForPreventedChange=t.target)},_changeHandler:function(){return!1},_dataValRequired:function(){return!1},_disabledOnElements:function(e,t){var n=e.find(`input`);let r=e.find(`label`);t?(n.attr(d,``),n.addClass(this.groupStyles.disabled),r.addClass(this.groupStyles.disabled)):(n.prop(d,!1),n.removeClass(this.groupStyles.disabled),r.removeClass(this.groupStyles.disabled))},_focusHandler:function(t){var n=e(t.target);this.trigger(s,{target:n})},_indexIsPresent:function(e){return!isNaN(e)&&e!==null&&e!==!0&&e!==!1&&this.wrapper.find(u+this.groupStyles.input).length>e},_initializeItem:function(t,n){var r=e(this.wrapper.find(u+this.groupStyles.item).get(n)||this.ITEM_TEMPLATE);this._preInitItem(t,r),this._initItem(t,r),this._postInitItem(t,r)},_preInitItem:function(e,n){var r=n.find(u+this.groupStyles.label),i=n.find(u+this.groupStyles.input);n.closest(u+this.groupStyles.list).length===0&&this.element.append(n),e.value!==null&&e.value!==t&&i.val(e.value),e.id&&(i.attr(`id`,e.id),r.attr(`for`,e.id))},_initItem:function(t,n){var r=n.find(u+this.groupStyles.label),i=n.find(u+this.groupStyles.input),a=e.extend({},t,{rounded:this.options.inputRounded,size:this.options.inputSize});delete a.name,t.label&&r.length>0&&r.remove(),i[this.COMPONENT](a)},_postInitItem:function(e,t){var n=t.find(u+this.groupStyles.label),r=t.find(u+this.groupStyles.input);e.name&&r.attr(`name`,e.name),e.labelAfter||n.after(r.parent()),e.attributes&&t.attr(e.attributes),e.cssClass&&t.addClass(e.cssClass),e.enabled||this._disabledOnElements(t,!0),e.validation&&r.attr(e.validation)},_iterateMarkupItems:function(){var e=this.element;e.children(`li`).length>0&&e.find(`li`).each(this._markupItem.bind(this))},_markupItem:function(t,n){n.querySelector(`input`).hasAttribute(`disabled`)&&e(n).addClass(this.groupStyles.disabled)},_parseItem:function(e,r){var i=this.options,o=this._items;(typeof e==`string`||typeof e==`number`)&&(e={value:e,label:e}),e.encoded!==!1&&(e.encoded=!0),i.labelPosition===m&&(e.labelAfter=!0),e.enabled===t&&(e.enabled=i.enabled),e.id||=n.guid(),e.name=i.inputName||this.element.attr(`name`)||this.element.attr(`id`),o.length>r?o[r]=a({},o[r],e):o.push(e)},_parseItems:function(e){this._items||=[],e&&e.forEach(this._parseItem.bind(this))},_validationSettings:function(){var e=this.wrapper,t=this._items,n={};e.is(`[required]`)&&(n.required=p,e.prop(p,!1)),e.is(`[data-val=true]`)&&(n[`data-val`]=`true`,e.removeAttr(`data-val`)),e.is(`[data-val-required]`)&&(this._dataValRequired(n),e.removeAttr(`data-val-required`)),e.is(`[data-val-server]`)&&(n[`data-val-server`]=e.attr(`data-val-server`)),Object.keys(n).length>0&&(!t||t.length===0)&&e.find(`li`).each(function(){t.push({})}),t.forEach(function(e){e.validation=n})},_wrapper:function(){var e=this.wrapper=this.element,t=this._items,n=e.find(`li`),r=e.find(`input`);e.addClass(this.groupStyles.list),this.options.layout===f?e.addClass(this.groupStyles.vertical):e.addClass(this.groupStyles.horizontal),n.length>0&&r.length>0&&(n.addClass(this.groupStyles.item),r.addClass(this.groupStyles.input),e.find(`label`).addClass(this.groupStyles.label)),this._validationSettings(),t.forEach(this._initializeItem.bind(this))}});r.plugin(h)})(window.kendo.jQuery);var r=kendo;e.__meta__=n,e.default=r}); //# sourceMappingURL=kendo.inputgroupbase.min.js.map