UNPKG

jiku-ui

Version:

A Component Library for Vue.js.

2 lines (1 loc) 4.83 kB
module.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=135)}({0:function(e,t,n){"use strict";function i(e,t,n,i,r,o,a,l){var s,f="function"==typeof e?e.options:e;if(t&&(f.render=t,f.staticRenderFns=n,f._compiled=!0),i&&(f.functional=!0),o&&(f._scopeId="data-v-"+o),a?(s=function(e){(e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(a)},f._ssrRegister=s):r&&(s=l?function(){r.call(this,(f.functional?this.parent:this).$root.$options.shadowRoot)}:r),s)if(f.functional){f._injectStyles=s;var d=f.render;f.render=function(e,t){return s.call(t),d(e,t)}}else{var u=f.beforeCreate;f.beforeCreate=u?[].concat(u,s):[s]}return{exports:e,options:f}}n.d(t,"a",(function(){return i}))},135:function(e,t,n){"use strict";n.r(t);var i=function(){var e=this.$createElement;return(this._self._c||e)("form",{staticClass:"hn-form",class:[this.labelPosition?"hn-form--label-"+this.labelPosition:"",{"hn-form--inline":this.inline}]},[this._t("default")],2)};i._withStripped=!0;var r=n(9),o=n.n(r),a={name:"HnForm",componentName:"HnForm",provide:function(){return{hnForm:this}},props:{model:Object,rules:Object,labelPosition:String,labelWidth:String,labelSuffix:{type:String,default:""},inline:Boolean,inlineMessage:Boolean,statusIcon:Boolean,showMessage:{type:Boolean,default:!0},size:String,disabled:Boolean,validateOnRuleChange:{type:Boolean,default:!0},hideRequiredAsterisk:{type:Boolean,default:!1}},watch:{rules:function(){this.fields.forEach((function(e){e.removeValidateEvents(),e.addValidateEvents()})),this.validateOnRuleChange&&this.validate((function(){}))}},computed:{autoLabelWidth:function(){if(!this.potentialLabelWidthArr.length)return 0;var e=Math.max.apply(Math,this.potentialLabelWidthArr);return e?e+"px":""}},data:function(){return{fields:[],potentialLabelWidthArr:[]}},created:function(){var e=this;this.$on("hn.form.addField",(function(t){t&&e.fields.push(t)})),this.$on("hn.form.removeField",(function(t){t.prop&&e.fields.splice(e.fields.indexOf(t),1)}))},methods:{resetFields:function(){this.model?this.fields.forEach((function(e){e.resetField()})):console.warn("[Heiner Warn][Form]model is required for resetFields to work.")},clearValidate:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=e.length?"string"==typeof e?this.fields.filter((function(t){return e===t.prop})):this.fields.filter((function(t){return e.indexOf(t.prop)>-1})):this.fields;t.forEach((function(e){e.clearValidate()}))},validate:function(e){var t=this;if(this.model){var n=void 0;"function"!=typeof e&&window.Promise&&(n=new window.Promise((function(t,n){e=function(e){e?t(e):n(e)}})));var i=!0,r=0;0===this.fields.length&&e&&e(!0);var a={};return this.fields.forEach((function(n){n.validate("",(function(n,l){n&&(i=!1),a=o()({},a,l),"function"==typeof e&&++r===t.fields.length&&e(i,a)}))})),n||void 0}console.warn("[Heiner Warn][Form]model is required for validate to work!")},validateField:function(e,t){e=[].concat(e);var n=this.fields.filter((function(t){return-1!==e.indexOf(t.prop)}));n.length?n.forEach((function(e){e.validate("",t)})):console.warn("[Heiner Warn]please pass correct props!")},getLabelWidthIndex:function(e){var t=this.potentialLabelWidthArr.indexOf(e);if(-1===t)throw new Error("[HeinerForm]unpected width ",e);return t},registerLabelWidth:function(e,t){if(e&&t){var n=this.getLabelWidthIndex(t);this.potentialLabelWidthArr.splice(n,1,e)}else e&&this.potentialLabelWidthArr.push(e)},deregisterLabelWidth:function(e){var t=this.getLabelWidthIndex(e);this.potentialLabelWidthArr.splice(t,1)}}},l=n(0),s=Object(l.a)(a,i,[],!1,null,null,null);s.options.__file="packages/form/src/form.vue";var f=s.exports;f.install=function(e){e.component(f.name,f)};t.default=f},9:function(e,t){e.exports=require("jiku-ui/lib/utils/merge")}}).default;