UNPKG

@progress/kendo-ui

Version:

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

3 lines 6.83 kB
/* @license */ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports,require(`kendo.core.min.js`),require(`kendo.floatinglabel.min.js`)):typeof define==`function`&&define.amd?define([`exports`,`kendo.core.min`,`kendo.floatinglabel.min`],t):(e=typeof globalThis<`u`?globalThis:e||self,t((e.kendo=e.kendo||{},e.kendo._globals=e.kendo._globals||{},e.kendo._globals.Textarea={}),e.kendo._globals.Core,e.kendo._globals.Floatinglabel))})(this,function(e,t,n){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let r=kendo.jQuery;function i({widget:e,wrapper:t,options:n,prefixInsertBefore:i,suffixInsertAfter:a}){var o=n.prefixOptions,s=n.suffixOptions,c=o.template||o.icon,l=s.template||s.icon,a=a||i,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;o&&c&&(p=t.children(`.k-input-prefix`),p[0]||(n._isInInlineAIPrompt&&(d=u||`horizontal`),p=r(`<span class="k-input-prefix k-input-prefix-${d}" />`),i?p.insertBefore(i):p.prependTo(t)),o.icon&&p.html(kendo.html.renderIcon({icon:o.icon,iconClass:o.iconClass})),o.template&&p.html(kendo.template(o.template)({})),o.separator&&r(f).insertAfter(p)),s&&l&&(m=t.children(`.k-input-suffix`),m[0]||(m=r(`<span class="k-input-suffix k-input-suffix-${d}" />`).appendTo(t),a?m.insertAfter(a):m.appendTo(t)),s.icon&&m.html(kendo.html.renderIcon({icon:s.icon,iconClass:s.iconClass})),s.template&&m.html(kendo.template(s.template)({})),s.separator&&r(f).insertBefore(m)),e._prefixContainer=p,e._suffixContainer=m}let a={id:`textarea`,name:`TextArea`,category:`web`,description:`The TextArea widget represents a multi-line plain-text editing control which enables you to style and provide a floating label functionality to textarea elements`,depends:[`core`,`floatinglabel`]};(function(e,t){var n=window.kendo,r=n.ui.Widget,a=n.ui,o=e.isPlainObject,s=`.kendoTextArea`,c=`change`,l=`disabled`,u=`readonly`,d=`k-input-inner`,f=`k-focus`,p=`k-label k-input-label`,m=`k-floating-label`,h=`k-disabled`,g=`k-readonly`,_=`aria-disabled`,v=`k-textarea-container`,y=r.extend({init:function(a,o){var s=this;r.fn.init.call(s,a,o),o=e.extend(!0,{},o),s.options.value=o.value||s.element.val(),s.options.readonly=o.readonly===t?!!s.element.attr(`readonly`):o.readonly,s.options.enable=o.enable===t?!s.element.attr(`disabled`):o.enable,s.options.placeholder=o.placeholder||s.element.attr(`placeholder`),s.options.maxLength=o.maxLength||s.element.attr(`maxlength`),s.options.inputMode=o.inputMode||s.element.attr(`inputmode`)||`text`,s.options.value.replace(/\s/g,``).length||(s.options.value=``,s.element.val(``)),s.value(s.options.value),s._wrapper(),s._label(),s._editable({readonly:s.options.readonly,disable:!s.options.enable}),s._applyAttributes(),s._applyCssClasses(),s.element.attr(`autocomplete`,`off`),s.element.attr(`inputmode`,s.options.inputMode),i({widget:s,wrapper:s.wrapper,options:s.options}),s.floatingLabel&&s.floatingLabel.refresh(),n.notify(s)},events:[c],attributes:[`maxLength`,`rows`,`placeholder`],options:{name:`TextArea`,value:``,readonly:!1,enable:!0,placeholder:``,label:null,resizable:`none`,maxLength:null,maxRows:null,rows:1,rounded:t,size:t,fillMode:t,resize:`none`,overflow:`auto`,layoutFlow:`vertical`,prefixOptions:{separator:!0},suffixOptions:{separator:!0}},_applyCssClasses:function(e){let t=this,i=t.options,a=n.cssProperties.getValidClass({widget:i.name,propName:`resize`,value:i.resize}),o=n.cssProperties.getValidClass({widget:i.name,propName:`overflow`,value:i.overflow}),s=n.cssProperties.getValidClass({widget:i.name,propName:`layoutFlow`,value:i.layoutFlow});r.fn._applyCssClasses.call(t),!a&&(i.resize===`none`||i.resize===`auto`)&&(a=`k-resize-none`),o&&=`!`+o,e||=`addClass`,t.element[e](a),t.element[e](o),t.element[e](d),t.wrapper[e](s),i.layoutFlow==`vertical`&&t.element[e](`!k-flex-none`)},_applyAttributes:function(){var e=this,t,n={};for(t in e.attributes)n[e.attributes[t]]=e.options[e.attributes[t]];e.element.attr(n)},value:function(e){var n=this;if(e===t)return n._value;n._value=e,n.element.val(e)},readonly:function(e){var n=this;this._editable({readonly:e===t?!0:e,disable:!1}),n.floatingLabel&&n.floatingLabel.readonly(e===t?!0:e)},enable:function(e){var n=this;if(this._editable({readonly:!1,disable:!(e=e===t?!0:e)}),n.floatingLabel){let r=e===t?!0:e;n.floatingLabel.enable(r)}},focus:function(){this.element[0].focus()},updateAutoHeight:function(){let e=this,t=e.element,n=e.options;if(n.resize===`auto`&&n.maxRows){let e=getComputedStyle(t[0]),r=parseInt(e.lineHeight,10)||16,i=(parseInt(e.paddingTop,10)||0)+(parseInt(e.paddingBottom,10)||0),a=n.rows*r+i,o=n.maxRows*r+i;t.css({height:a+`px`});let s=t[0].scrollHeight;t.css({maxHeight:o+`px`,height:s+`px`})}},destroy:function(){var e=this;e._applyCssClasses(`removeClass`),e.floatingLabel&&e.floatingLabel.destroy(),e._inputLabel&&=(e._inputLabel.remove(),null),e.element[0].style.cssText=e.wrapper[0].style.cssText,e.element.off(s),e.element.unwrap(),e.wrapper=null,r.fn.destroy.call(e)},setOptions:function(e){var t=this;t.destroy(),t.init(t.element,e)},_editable:function(e){var t=this,n=t.element,r=t.wrapper,i=e.disable,a=e.readonly;n.off(s),!a&&!i?(n.prop(l,!1).prop(u,!1).attr(_,!1),r.removeClass(h).removeClass(g),n.on(`focusin`+s,t._focusin.bind(t)),n.on(`focusout`+s,t._focusout.bind(t)),n.on(`input`+s,t._input.bind(t))):(n.attr(l,i).attr(u,a).attr(_,i),r.toggleClass(h,i).toggleClass(g,a))},_label:function(){var t=this,r=t.element,i=t.options,a=r.attr(`id`),s,c;i.label!==null&&(s=o(i.label)?i.label.floating:!1,c=o(i.label)?i.label.content:i.label,s&&(t._floatingLabelContainer=t.wrapper.wrap(`<span></span>`).parent(),t.floatingLabel=new n.ui.FloatingLabel(t._floatingLabelContainer,{widget:t}),t._floatingLabelContainer.addClass(v)),n.isFunction(c)&&(c=c.call(t)),c||=``,a||(a=i.name+`_`+n.guid(),r.attr(`id`,a)),t._inputLabel=e(`<label class='`+(s?m:p)+`' for='`+a+`'>`+c+`</label>'`)[s?`insertAfter`:`insertBefore`](t.wrapper))},_focusin:function(){this.wrapper.addClass(f)},_focusout:function(){var e=this,t=e._value,n=e.element.val();e.wrapper.removeClass(f),t===null&&(t=``),t!==n&&(e._value=n,e.trigger(c))},_input:function(){this.updateAutoHeight()},_wrapper:function(){var e=this,t=e.element,n=t[0],r=t.wrap(`<span class='k-input k-textarea'></span>`).parent();r[0].style.cssText=n.style.cssText,n.style.width=``,e.wrapper=r.addClass(n.className).removeClass(`input-validation-error`)}});n.cssProperties.registerPrefix(`TextArea`,`k-input-`),n.cssProperties.registerValues(`TextArea`,[{prop:`rounded`,values:n.cssProperties.roundedValues.concat([[`full`,`full`]])}]),a.plugin(y)})(window.kendo.jQuery);var o=kendo;e.__meta__=a,e.default=o}); //# sourceMappingURL=kendo.textarea.min.js.map