UNPKG

vue-types

Version:
3 lines (2 loc) 4.36 kB
function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t){return"[object Object]"===Object.prototype.toString.call(t)}function i(t){var e,n;return!1!==o(t)&&(void 0===(e=t.constructor)||!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var c={silent:!1},f=Object.defineProperty,a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e,n){void 0===e&&(e={}),void 0===n&&(n=!1);var r={_vueTypes_name:{value:t,writable:!0},def:{value:function(t){var e=this;return void 0!==t||e.default?(e.default=a(t)?function(){return[].concat(t)}:i(t)?function(){return Object.assign({},t)}:t,e):e}},isRequired:{get:function(){return this.required=!0,this}}};return n&&(r.validate={value:function(){}}),Object.assign(Object.defineProperties({validator:function(){return!0}},r),e)}var l=function(){return s("any",{},!0)},y=function(){return s("func",{type:Function},!0)},p=function(){return s("bool",{type:Boolean},!0)},d=function(){return s("string",{type:String},!0)},b=function(){return s("number",{type:Number},!0)},v=function(){return s("array",{type:Array},!0)},g=function(){return s("object",{type:Object},!0)},h=function(){return s("symbol")},O=function(){return s("integer",{type:Number})},j=function(t){return s("oneOf")},m=function(t){return s("custom")},k=function(t){return s("instanceOf",{type:t})},w=function(t){return s("oneOfType")},P=function(t){return s("arrayOf",{type:Array})},_=function(t){return s("objectOf",{type:Object})},T=function(t){return f(s("shape",{type:Object}),"loose",{get:function(){return this}})};function A(t,e,n,r,u){var o;void 0===r&&(r=!1),void 0===u&&(u=!1);var i=((o={})[r?"get":"value"]=function(){return s(e,n,u).def(r?t.defaults[e]:void 0)},o);return f(t,e,i)}var N=function(){var t;return(t=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,u=t.type,o=void 0===u?null:u;return A(this,t.name,{type:i(o)&&o.type?null:o},r,!!e)},e(t,null,[{key:"any",get:function(){return l()}},{key:"func",get:function(){return y().def(this.defaults.func)}},{key:"bool",get:function(){return p().def(this.defaults.bool)}},{key:"string",get:function(){return d().def(this.defaults.string)}},{key:"number",get:function(){return b().def(this.defaults.number)}},{key:"array",get:function(){return v().def(this.defaults.array)}},{key:"object",get:function(){return g().def(this.defaults.object)}},{key:"symbol",get:function(){return h()}},{key:"integer",get:function(){return O().def(this.defaults.integer)}}]),t}()).defaults={},t.config=c,t.oneOf=j,t.custom=m,t.instanceOf=k,t.oneOfType=w,t.arrayOf=P,t.objectOf=_,t.shape=T,t.utils={toType:s,validate:function(){return!![].slice.call(arguments)}},t}();function x(t){var u;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(u=function(u){function o(){return u.apply(this,arguments)||this}return r(o,u),e(o,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(e){this.defaults=!1!==e?n({},!0!==e?e:t):{}}}]),o}(N)).defaults=n({},t),u}"production"!==process.env.NODE_ENV&&!1===c.silent&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://dwightjack.github.io/vue-types/guide/installation.html#production-build to learn how to configure VueTypes for usage in multiple environments.");var S=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(x());export default S;export{l as any,v as array,P as arrayOf,p as bool,c as config,x as createTypes,m as custom,y as func,k as instanceOf,O as integer,b as number,g as object,_ as objectOf,j as oneOf,w as oneOfType,T as shape,d as string,h as symbol}; //# sourceMappingURL=shim.m.js.map