h_ui
Version:
A Vue.js 2.0 UI Components Framework
1 lines • 10.6 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("h_ui/dist/lib/util/tools.js"),require("h_ui/dist/lib/util/global.js"),require("h_ui/dist/lib/mixins/emitter.js"),require("h_ui/dist/lib/util/dom.js")):"function"==typeof define&&define.amd?define("h_ui/lib",["h_ui/dist/lib/util/tools.js","h_ui/dist/lib/util/global.js","h_ui/dist/lib/mixins/emitter.js","h_ui/dist/lib/util/dom.js"],e):"object"==typeof exports?exports["h_ui/lib"]=e(require("h_ui/dist/lib/util/tools.js"),require("h_ui/dist/lib/util/global.js"),require("h_ui/dist/lib/mixins/emitter.js"),require("h_ui/dist/lib/util/dom.js")):t["h_ui/lib"]=e(t["h_ui/dist/lib/util/tools.js"],t["h_ui/dist/lib/util/global.js"],t["h_ui/dist/lib/mixins/emitter.js"],t["h_ui/dist/lib/util/dom.js"])}(window,(function(t,e,n,i){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="/dist/lib/",n(n.s=1101)}({0:function(t,e){var n=t.exports={version:"2.6.12"};"number"==typeof __e&&(__e=n)},1:function(t,e){var n=t.exports="undefined"!=typeof window&&window.Math==Math?window:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();"number"==typeof __g&&(__g=n)},10:function(t,e){var n={}.hasOwnProperty;t.exports=function(t,e){return n.call(t,e)}},11:function(t,e,n){var i=n(5),r=n(14);t.exports=n(2)?function(t,e,n){return i.f(t,e,r(1,n))}:function(t,e,n){return t[e]=n,t}},1101:function(t,e,n){"use strict";var i=n(8);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=i(n(1102)),o=n(32);r.default.install=function(t,e){(0,o.setGlobal)(t,e),t.component("HSwitch",r.default)};var u=r.default;e.default=u},1102:function(t,e,n){"use strict";n.r(e);var i=n(770),r=n(599);for(var o in r)["default"].indexOf(o)<0&&function(t){n.d(e,t,(function(){return r[t]}))}(o);var u=n(4),s=Object(u.a)(r.default,i.a,i.b,!1,null,null,null);e.default=s.exports},12:function(t,e,n){var i=n(6);t.exports=function(t){if(!i(t))throw TypeError(t+" is not an object!");return t}},14:function(t,e){t.exports=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}}},15:function(t,e,n){var i=n(38);t.exports=function(t,e,n){return e in t?i(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.__esModule=!0,t.exports.default=t.exports},16:function(t,e,n){var i=n(27);t.exports=function(t,e,n){if(i(t),void 0===e)return t;switch(n){case 1:return function(n){return t.call(e,n)};case 2:return function(n,i){return t.call(e,n,i)};case 3:return function(n,i,r){return t.call(e,n,i,r)}}return function(){return t.apply(e,arguments)}}},17:function(t,e,n){var i=n(6);t.exports=function(t,e){if(!i(t))return t;var n,r;if(e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!i(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!i(r=n.call(t)))return r;throw TypeError("Can't convert object to primitive value")}},2:function(t,e,n){t.exports=!n(7)((function(){return 7!=Object.defineProperty({},"a",{get:function(){return 7}}).a}))},21:function(e,n){e.exports=t},24:function(t,e,n){var i=n(6),r=n(1).document,o=i(r)&&i(r.createElement);t.exports=function(t){return o?r.createElement(t):{}}},25:function(t,e,n){t.exports=!n(2)&&!n(7)((function(){return 7!=Object.defineProperty(n(24)("div"),"a",{get:function(){return 7}}).a}))},27:function(t,e){t.exports=function(t){if("function"!=typeof t)throw TypeError(t+" is not a function!");return t}},3:function(t,e,n){var i=n(1),r=n(0),o=n(16),u=n(11),s=n(10),c=function(t,e,n){var l,a,f,d=t&c.F,h=t&c.G,p=t&c.S,b=t&c.P,y=t&c.B,v=t&c.W,_=h?r:r[e]||(r[e]={}),w=_.prototype,g=h?i:p?i[e]:(i[e]||{}).prototype;for(l in h&&(n=e),n)(a=!d&&g&&void 0!==g[l])&&s(_,l)||(f=a?g[l]:n[l],_[l]=h&&"function"!=typeof g[l]?n[l]:y&&a?o(f,i):v&&g[l]==f?function(t){var e=function(e,n,i){if(this instanceof t){switch(arguments.length){case 0:return new t;case 1:return new t(e);case 2:return new t(e,n)}return new t(e,n,i)}return t.apply(this,arguments)};return e.prototype=t.prototype,e}(f):b&&"function"==typeof f?o(Function.call,f):f,b&&((_.virtual||(_.virtual={}))[l]=f,t&c.R&&w&&!w[l]&&u(w,l,f)))};c.F=1,c.G=2,c.S=4,c.P=8,c.B=16,c.W=32,c.U=64,c.R=128,t.exports=c},32:function(t,n){t.exports=e},38:function(t,e,n){t.exports=n(39)},39:function(t,e,n){n(40);var i=n(0).Object;t.exports=function(t,e,n){return i.defineProperty(t,e,n)}},4:function(t,e,n){"use strict";function i(t,e,n,i,r,o,u,s){var c,l="function"==typeof t?t.options:t;if(e&&(l.render=e,l.staticRenderFns=n,l._compiled=!0),i&&(l.functional=!0),o&&(l._scopeId="data-v-"+o),u?(c=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__),r&&r.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(u)},l._ssrRegister=c):r&&(c=s?function(){r.call(this,(l.functional?this.parent:this).$root.$options.shadowRoot)}:r),c)if(l.functional){l._injectStyles=c;var a=l.render;l.render=function(t,e){return c.call(e),a(t,e)}}else{var f=l.beforeCreate;l.beforeCreate=f?[].concat(f,c):[c]}return{exports:t,options:l}}n.d(e,"a",(function(){return i}))},40:function(t,e,n){var i=n(3);i(i.S+i.F*!n(2),"Object",{defineProperty:n(5).f})},5:function(t,e,n){var i=n(12),r=n(25),o=n(17),u=Object.defineProperty;e.f=n(2)?Object.defineProperty:function(t,e,n){if(i(t),e=o(e,!0),i(n),r)try{return u(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported!");return"value"in n&&(t[e]=n.value),t}},599:function(t,e,n){"use strict";n.r(e);var i=n(600),r=n.n(i);for(var o in i)["default"].indexOf(o)<0&&function(t){n.d(e,t,(function(){return i[t]}))}(o);e.default=r.a},6:function(t,e){t.exports=function(t){return"object"==typeof t?null!==t:"function"==typeof t}},60:function(t,e){t.exports=n},600:function(t,e,n){"use strict";var i=n(8);Object.defineProperty(e,"__esModule",{value:!0}),e.default=void 0;var r=i(n(15)),o=n(21),u=n(84),s=i(n(60)),c="h-switch",l={name:"Switchs",mixins:[s.default],props:{value:{type:[String,Number,Boolean],default:!1},disabled:{type:Boolean,default:!1},width:{type:[String,Number],default:48},height:{type:[String,Number],default:24},type:{validator:function(t){return(0,o.oneOf)(t,["info","success","warning","error"])}},size:{validator:function(t){return(0,o.oneOf)(t,["large","small","default"])}},trueValue:{type:[String,Number,Boolean],default:!0},falseValue:{type:[String,Number,Boolean],default:!1},trueColor:{type:String},falseColor:{type:String},beforeChange:{type:Function,default:function(){return!0}}},data:function(){return{currentValue:this.value===this.trueValue,slideWidth:this.height-4,slideHeight:this.height-4,slideLeft:this.width-this.height+1,isSwitchFocus:!1}},computed:{wrapClasses:function(){var t;return["".concat(c),(t={},(0,r.default)(t,"".concat(c,"-checked"),this.currentValue),(0,r.default)(t,"".concat(c,"-disabled"),this.disabled),(0,r.default)(t,"".concat(c,"-").concat(this.size),!!this.size),(0,r.default)(t,"".concat(c,"-").concat(this.type),!!this.type),(0,r.default)(t,"".concat(c,"-focused"),this.isSwitchFocus),t)]},innerClasses:function(){return"".concat(c,"-inner")},slideClasses:function(){return"slide"},styles:function(){var t={};return t.width="".concat(this.width,"px"),t.height="".concat(this.height,"px"),this.trueColor&&this.falseColor&&(t.borderColor=this.currentValue?"".concat(this.trueColor):"".concat(this.falseColor),t.backgroundColor=this.currentValue?"".concat(this.trueColor):"".concat(this.falseColor)),t},styleSlide:function(){return{width:"".concat(this.slideWidth,"px"),height:"".concat(this.slideHeight,"px"),left:this.currentValue?"".concat(this.slideLeft,"px"):"1px"}}},mounted:function(){window.$HUI&&window.$HUI.Log&&window.$HUI.Log.debug("h_ui switch lifecycle mounted"),this.updateModel(),(0,u.on)(this.$refs.core,"keyup",this.handleKeyup)},beforeDestroy:function(){window.$HUI&&window.$HUI.Log&&window.$HUI.Log.debug("h_ui switch lifecycle beforeDestroy"),(0,u.off)(this.$refs.core,"keyup",this.handleKeyup)},methods:{toggle:function(){if(this.disabled)return!1;var t=!this.currentValue,e=t?this.trueValue:this.falseValue;this.beforeChange(e)&&(this.currentValue=t,this.$emit("input",e),this.$emit("on-change",e),this.dispatch("FormItem","on-form-change",e))},focus:function(t){this.$refs.core.focus(),this.$refs.core.isFocus=!0,this.isSwitchFocus=!0,this.$emit("on-focus",t)},blur:function(t){this.$refs.core.isFocus=!1,this.isSwitchFocus=!1,this.$emit("on-blur",t)},handleKeyup:function(t){if(this.disabled)return!1;t.shiftKey||32===t.keyCode&&(t.preventDefault(),t.stopPropagation(),this.$refs.core.isFocus&&this.toggle())},updateModel:function(){this.currentValue=this.value===this.trueValue}},watch:{value:function(t){if(window.$HUI&&window.$HUI.Log&&window.$HUI.Log.debug("h_ui switch watch value change: "+t),t!==this.trueValue&&t!==this.falseValue)throw new Error("Value should be trueValue or falseValue.");this.updateModel()}}};e.default=l},7:function(t,e){t.exports=function(t){try{return!!t()}catch(t){return!0}}},770:function(t,e,n){"use strict";n.d(e,"a",(function(){return i})),n.d(e,"b",(function(){return r}));var i=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("span",{ref:"core",class:t.wrapClasses,style:t.styles,attrs:{tabindex:"0"},on:{click:t.toggle,focus:t.focus,blur:t.blur}},[n("span",{class:t.slideClasses,style:t.styleSlide}),t._v(" "),n("span",{class:t.innerClasses},[t.currentValue?t._t("open"):t._e(),t._v(" "),t.currentValue?t._e():t._t("close")],2)])},r=[];i._withStripped=!0},8:function(t,e){t.exports=function(t){return t&&t.__esModule?t:{default:t}},t.exports.__esModule=!0,t.exports.default=t.exports},84:function(t,e){t.exports=i}})}));