UNPKG

jiku-ui

Version:

A Component Library for Vue.js.

2 lines (1 loc) 11.7 kB
module.exports=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=91)}({0:function(t,e,i){"use strict";function n(t,e,i,n,s,o,a,r){var u,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=i,l._compiled=!0),n&&(l.functional=!0),o&&(l._scopeId="data-v-"+o),a?(u=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),s&&s.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(a)},l._ssrRegister=u):s&&(u=r?function(){s.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:s),u)if(l.functional){l._injectStyles=u;var p=l.render;l.render=function(t,e){return u.call(e),p(t,e)}}else{var c=l.beforeCreate;l.beforeCreate=c?[].concat(c,u):[u]}return{exports:t,options:l}}i.d(e,"a",(function(){return n}))},10:function(t,e){t.exports=require("jiku-ui/lib/mixins/migrating")},38:function(t,e){t.exports=require("jiku-ui/lib/utils/shared")},4:function(t,e){t.exports=require("jiku-ui/lib/mixins/emitter")},9:function(t,e){t.exports=require("jiku-ui/lib/utils/merge")},91:function(t,e,i){"use strict";i.r(e);var n=function(){var t=this,e=t.$createElement,i=t._self._c||e;return i("div",{class:["textarea"===t.type?"hn-textarea":"hn-input",t.inputSize?"hn-input--"+t.inputSize:"",{"is-disabled":t.inputDisabled,"is-exceed":t.inputExceed,"hn-input-group":t.$slots.prepend||t.$slots.append,"hn-input-group--append":t.$slots.append,"hn-input-group--prepend":t.$slots.prepend,"hn-input--prefix":t.$slots.prefix||t.prefixIcon,"hn-input--suffix":t.$slots.suffix||t.suffixIcon||t.clearable||t.showPassword}],on:{mouseenter:function(e){t.hovering=!0},mouseleave:function(e){t.hovering=!1}}},["textarea"!==t.type?[t.$slots.prepend?i("div",{staticClass:"hn-input-group__prepend"},[t._t("prepend")],2):t._e(),"textarea"!==t.type?i("input",t._b({ref:"input",staticClass:"hn-input__inner",attrs:{tabindex:t.tabindex,type:t.showPassword?t.passwordVisible?"text":"password":t.type,disabled:t.inputDisabled,readonly:t.readonly,autocomplete:t.autoComplete||t.autocomplete,"aria-label":t.label},on:{compositionstart:t.handleCompositionStart,compositionupdate:t.handleCompositionUpdate,compositionend:t.handleCompositionEnd,input:t.handleInput,focus:t.handleFocus,blur:t.handleBlur,change:t.handleChange}},"input",t.$attrs,!1)):t._e(),t.$slots.prefix||t.prefixIcon?i("span",{staticClass:"hn-input__prefix"},[t._t("prefix"),t.prefixIcon?i("i",{staticClass:"hn-input__icon",class:t.prefixIcon}):t._e()],2):t._e(),t.getSuffixVisible()?i("span",{staticClass:"hn-input__suffix"},[i("span",{staticClass:"hn-input__suffix-inner"},[t.showClear&&t.showPwdVisible&&t.isWordLimitVisible?t._e():[t._t("suffix"),t.suffixIcon?i("i",{staticClass:"hn-input__icon",class:t.suffixIcon}):t._e()],t.showClear?i("i",{staticClass:"hn-input__icon hn-icon-circle-close hn-input__clear",on:{mousedown:function(t){t.preventDefault()},click:t.clear}}):t._e(),t.showPwdVisible?i("i",{staticClass:"hn-input__icon hn-icon-view hn-input__clear",on:{click:t.handlePasswordVisible}}):t._e(),t.isWordLimitVisible?i("span",{staticClass:"hn-input__count"},[i("span",{staticClass:"hn-input__count-inner"},[t._v("\n "+t._s(t.textLength)+"/"+t._s(t.upperLimit)+"\n ")])]):t._e()],2),t.validateState?i("i",{staticClass:"hn-input__icon",class:["hn-input__validateIcon",t.validateIcon]}):t._e()]):t._e(),t.$slots.append?i("div",{staticClass:"hn-input-group__append"},[t._t("append")],2):t._e()]:i("textarea",t._b({ref:"textarea",staticClass:"hn-textarea__inner",style:t.textareaStyle,attrs:{tabindex:t.tabindex,disabled:t.inputDisabled,readonly:t.readonly,autocomplete:t.autoComplete||t.autocomplete,"aria-label":t.label},on:{compositionstart:t.handleCompositionStart,compositionupdate:t.handleCompositionUpdate,compositionend:t.handleCompositionEnd,input:t.handleInput,focus:t.handleFocus,blur:t.handleBlur,change:t.handleChange}},"textarea",t.$attrs,!1)),t.isWordLimitVisible&&"textarea"===t.type?i("span",{staticClass:"hn-input__count"},[t._v(t._s(t.textLength)+"/"+t._s(t.upperLimit))]):t._e()],2)};n._withStripped=!0;var s=i(4),o=i.n(s),a=i(10),r=i.n(a),u=void 0,l="\n height:0 !important;\n visibility:hidden !important;\n overflow:hidden !important;\n position:absolute !important;\n z-index:-1000 !important;\n top:0 !important;\n right:0 !important\n",p=["letter-spacing","line-height","padding-top","padding-bottom","font-family","font-weight","font-size","text-rendering","text-transform","width","text-indent","padding-left","padding-right","border-width","box-sizing"];function c(t){var e=window.getComputedStyle(t),i=e.getPropertyValue("box-sizing"),n=parseFloat(e.getPropertyValue("padding-bottom"))+parseFloat(e.getPropertyValue("padding-top")),s=parseFloat(e.getPropertyValue("border-bottom-width"))+parseFloat(e.getPropertyValue("border-top-width"));return{contextStyle:p.map((function(t){return t+":"+e.getPropertyValue(t)})).join(";"),paddingSize:n,borderSize:s,boxSizing:i}}function h(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;u||(u=document.createElement("textarea"),document.body.appendChild(u));var n=c(t),s=n.paddingSize,o=n.borderSize,a=n.boxSizing,r=n.contextStyle;u.setAttribute("style",r+";"+l),u.value=t.value||t.placeholder||"";var p=u.scrollHeight,h={};"border-box"===a?p+=o:"content-box"===a&&(p-=s),u.value="";var d=u.scrollHeight-s;if(null!==e){var f=d*e;"border-box"===a&&(f=f+s+o),p=Math.max(f,p),h.minHeight=f+"px"}if(null!==i){var m=d*i;"border-box"===a&&(m=m+s+o),p=Math.min(m,p)}return h.height=p+"px",u.parentNode&&u.parentNode.removeChild(u),u=null,h}var d=i(9),f=i.n(d),m=i(38),g={name:"HnInput",componentName:"HnInput",mixins:[o.a,r.a],inheritAttrs:!1,inject:{hnForm:{default:""},hnFormItem:{default:""}},data:function(){return{textareaCalcStyle:{},hovering:!1,focused:!1,isComposing:!1,passwordVisible:!1}},props:{value:[String,Number],size:String,resize:String,form:String,disabled:Boolean,readonly:Boolean,type:{type:String,default:"text"},autosize:{type:[Boolean,Object],default:!1},autocomplete:{type:String,default:"off"},autoComplete:{type:String,validator:function(t){return!0}},validateEvent:{type:Boolean,default:!0},suffixIcon:String,prefixIcon:String,label:String,clearable:{type:Boolean,default:!1},showPassword:{type:Boolean,default:!1},showWordLimit:{type:Boolean,default:!1},tabindex:String},computed:{_hnFormItemSize:function(){return(this.hnFormItem||{}).hnFormItemSize},validateState:function(){return this.hnFormItem?this.hnFormItem.validateState:""},needStatusIcon:function(){return!!this.hnForm&&this.hnForm.statusIcon},validateIcon:function(){return{validating:"hn-icon-loading",success:"hn-icon-circle-check",error:"hn-icon-circle-close"}[this.validateState]},textareaStyle:function(){return f()({},this.textareaCalcStyle,{resize:this.resize})},inputSize:function(){return this.size||this._hnFormItemSize||(this.$HEINER||{}).size},inputDisabled:function(){return this.disabled||(this.hnForm||{}).disabled},nativeInputValue:function(){return null===this.value||void 0===this.value?"":String(this.value)},showClear:function(){return this.clearable&&!this.inputDisabled&&!this.readonly&&this.nativeInputValue&&(this.focused||this.hovering)},showPwdVisible:function(){return this.showPassword&&!this.inputDisabled&&!this.readonly&&(!!this.nativeInputValue||this.focused)},isWordLimitVisible:function(){return this.showWordLimit&&this.$attrs.maxlength&&("text"===this.type||"textarea"===this.type)&&!this.inputDisabled&&!this.readonly&&!this.showPassword},upperLimit:function(){return this.$attrs.maxlength},textLength:function(){return"number"==typeof this.value?String(this.value).length:(this.value||"").length},inputExceed:function(){return this.isWordLimitVisible&&this.textLength>this.upperLimit}},watch:{value:function(t){this.$nextTick(this.resizeTextarea),this.validateEvent&&this.dispatch("HnFormItem","hn.form.change",[t])},nativeInputValue:function(){this.setNativeInputValue()},type:function(){var t=this;this.$nextTick((function(){t.setNativeInputValue(),t.resizeTextarea(),t.updateIconOffset()}))}},methods:{focus:function(){this.getInput().focus()},blur:function(){this.getInput().blur()},getMigratingConfig:function(){return{props:{icon:"icon is removed, use suffix-icon / prefix-icon instead.","on-icon-click":"on-icon-click is removed."},events:{click:"click is removed."}}},handleBlur:function(t){this.focused=!1,this.$emit("blur",t),this.validateEvent&&this.dispatch("HnFormItem","hn.form.blur",[this.value])},select:function(){this.getInput().select()},resizeTextarea:function(){if(!this.$isServer){var t=this.autosize;if("textarea"===this.type)if(t){var e=t.minRows,i=t.maxRows;this.textareaCalcStyle=h(this.$refs.textarea,e,i)}else this.textareaCalcStyle={minHeight:h(this.$refs.textarea).minHeight}}},setNativeInputValue:function(){var t=this.getInput();t&&t.value!==this.nativeInputValue&&(t.value=this.nativeInputValue)},handleFocus:function(t){this.focused=!0,this.$emit("focus",t)},handleCompositionStart:function(){this.isComposing=!0},handleCompositionUpdate:function(t){var e=t.target.value,i=e[e.length-1]||"";this.isComposing=!Object(m.isKorean)(i)},handleCompositionEnd:function(t){this.isComposing&&(this.isComposing=!1,this.handleInput(t))},handleInput:function(t){this.isComposing||t.target.value!==this.nativeInputValue&&(this.$emit("input",t.target.value),this.$nextTick(this.setNativeInputValue))},handleChange:function(t){this.$emit("change",t.target.value)},calcIconOffset:function(t){var e=[].slice.call(this.$el.querySelectorAll(".hn-input__"+t)||[]);if(e.length){for(var i=null,n=0;n<e.length;n++)if(e[n].parentNode===this.$el){i=e[n];break}if(i){var s={suffix:"append",prefix:"prepend"}[t];this.$slots[s]?i.style.transform="translateX("+("suffix"===t?"-":"")+this.$el.querySelector(".hn-input-group__"+s).offsetWidth+"px)":i.removeAttribute("style")}}},updateIconOffset:function(){this.calcIconOffset("prefix"),this.calcIconOffset("suffix")},clear:function(){this.$emit("input",""),this.$emit("change",""),this.$emit("clear")},handlePasswordVisible:function(){this.passwordVisible=!this.passwordVisible,this.focus()},getInput:function(){return this.$refs.input||this.$refs.textarea},getSuffixVisible:function(){return this.$slots.suffix||this.suffixIcon||this.showClear||this.showPassword||this.isWordLimitVisible||this.validateState&&this.needStatusIcon}},created:function(){this.$on("inputSelect",this.select)},mounted:function(){this.setNativeInputValue(),this.resizeTextarea(),this.updateIconOffset()},updated:function(){this.$nextTick(this.updateIconOffset)}},x=i(0),v=Object(x.a)(g,n,[],!1,null,null,null);v.options.__file="packages/input/src/input.vue";var b=v.exports;b.install=function(t){t.component(b.name,b)};e.default=b}}).default;