UNPKG

vue-types

Version:
3 lines (2 loc) 4.21 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).VueTypes={})}(this,function(t){function e(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 n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function r(){return(r=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 u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t){return"[object Object]"===Object.prototype.toString.call(t)}function f(t){var e,n;return!1!==i(t)&&(void 0===(e=t.constructor)||!1!==i(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var c={silent:!1},a=Object.defineProperty,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function y(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=s(t)?function(){return[].concat(t)}:f(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 y("any",{},!0)},p=function(){return y("func",{type:Function},!0)},d=function(){return y("bool",{type:Boolean},!0)},b=function(){return y("string",{type:String},!0)},g=function(){return y("number",{type:Number},!0)},v=function(){return y("array",{type:Array},!0)},O=function(){return y("object",{type:Object},!0)},h=function(){return y("symbol")},j=function(){return y("integer",{type:Number})},m=function(t){return y("oneOf")},k=function(t){return y("custom")},T=function(t){return y("instanceOf",{type:t})},P=function(t){return y("oneOfType")},_=function(t){return y("arrayOf",{type:Array})},A=function(t){return y("objectOf",{type:Object})},w=function(t){return a(y("shape",{type:Object}),"loose",{get:function(){return this}})};function x(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 y(e,n,u).def(r?t.defaults[e]:void 0)},o);return a(t,e,i)}var S=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 x(this,t.name,{type:f(o)&&o.type?null:o},r,!!e)},n(t,null,[{key:"any",get:function(){return l()}},{key:"func",get:function(){return p().def(this.defaults.func)}},{key:"bool",get:function(){return d().def(this.defaults.bool)}},{key:"string",get:function(){return b().def(this.defaults.string)}},{key:"number",get:function(){return g().def(this.defaults.number)}},{key:"array",get:function(){return v().def(this.defaults.array)}},{key:"object",get:function(){return O().def(this.defaults.object)}},{key:"symbol",get:function(){return h()}},{key:"integer",get:function(){return j().def(this.defaults.integer)}}]),t}()).defaults={},t.config=c,t.oneOf=m,t.custom=k,t.instanceOf=T,t.oneOfType=P,t.arrayOf=_,t.objectOf=A,t.shape=w,t.utils={toType:y,validate:function(){return!![].slice.call(arguments)}},t}();function q(t){var e;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(e=function(e){function o(){return e.apply(this,arguments)||this}return u(o,e),n(o,null,[{key:"sensibleDefaults",get:function(){return r({},this.defaults)},set:function(e){this.defaults=!1!==e?r({},!0!==e?e:t):{}}}]),o}(S)).defaults=r({},t),e}var N=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e}(q());t.any=l,t.array=v,t.arrayOf=_,t.bool=d,t.config=c,t.createTypes=q,t.custom=k,t.default=N,t.func=p,t.instanceOf=T,t.integer=j,t.number=g,t.object=O,t.objectOf=A,t.oneOf=m,t.oneOfType=P,t.shape=w,t.string=b,t.symbol=h}); //# sourceMappingURL=shim.umd.js.map