Comparing version 3.0.2 to 4.0.0-rc.1
@@ -1,2 +0,2 @@ | ||
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,t.__proto__=e}function o(t){return 1==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);var e}function u(t){var e,n;return!1!==o(t)&&"function"==typeof(e=t.constructor)&&!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")}var i=Object.defineProperty,c=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function f(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=c(t)?function(){return[].concat(t)}:u(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 a=function(){return f("any",{},!0)},s=function(){return f("func",{type:Function},!0)},p=function(){return f("bool",{type:Boolean},!0)},l=function(){return f("string",{type:String},!0)},y=function(){return f("number",{type:Number},!0)},d=function(){return f("array",{type:Array},!0)},b=function(){return f("object",{type:Object},!0)},v=function(){return f("symbol")},g=function(){return f("integer",{type:Number})},O=function(t){return f("oneOf")},h=function(t){return f("custom")},j=function(t){return f("instanceOf",{type:t})},m=function(t){return f("oneOfType")},x=function(t){return f("arrayOf",{type:Array})},k=function(t){return f("objectOf",{type:Object})},_=function(t){return i(f("shape",{type:Object}),"loose",{get:function(){return this}})};function T(t,e,n,r,o){var u;void 0===r&&(r=!1),void 0===o&&(o=!1);var c=((u={})[r?"get":"value"]=function(){return f(e,n,o).def(r?t.defaults[e]:void 0)},u);return i(t,e,c)}var w=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,o=t.type,i=void 0===o?null:o;return T(this,t.name,{type:u(i)&&i.type?null:i},r,!!e)},e(t,null,[{key:"any",get:function(){return a()}},{key:"func",get:function(){return s().def(this.defaults.func)}},{key:"bool",get:function(){return p().def(this.defaults.bool)}},{key:"string",get:function(){return l().def(this.defaults.string)}},{key:"number",get:function(){return y().def(this.defaults.number)}},{key:"array",get:function(){return d().def(this.defaults.array)}},{key:"object",get:function(){return b().def(this.defaults.object)}},{key:"symbol",get:function(){return v()}},{key:"integer",get:function(){return g().def(this.defaults.integer)}}]),t}();function A(t){var o;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(o=function(o){function u(){return o.apply(this,arguments)||this}return r(u,o),e(u,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(e){this.defaults=!1!==e?n({},!0!==e?e:t):{}}}]),u}(w)).defaults=n({},t),o}w.defaults={},w.oneOf=O,w.custom=h,w.instanceOf=j,w.oneOfType=m,w.arrayOf=x,w.objectOf=k,w.shape=_,w.utils={toType:f,validate:function(){return!![].slice.call(arguments)}},"production"!==process.env.NODE_ENV&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");var P=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(A());Object.defineProperty(exports,"__esModule",{value:!0}),exports.any=a,exports.array=d,exports.arrayOf=x,exports.bool=p,exports.createTypes=A,exports.custom=h,exports.default=P,exports.func=s,exports.instanceOf=j,exports.integer=g,exports.number=y,exports.object=b,exports.objectOf=k,exports.oneOf=O,exports.oneOfType=m,exports.shape=_,exports.string=l,exports.symbol=v; | ||
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,o(t,e)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(t){return"[object Object]"===Object.prototype.toString.call(t)}function i(t){var e,n;return!1!==u(t)&&(void 0===(e=t.constructor)||!1!==u(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var c=Object.defineProperty,f=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(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=f(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 s=function(){return a("any",{},!0)},p=function(){return a("func",{type:Function},!0)},l=function(){return a("bool",{type:Boolean},!0)},y=function(){return a("string",{type:String},!0)},d=function(){return a("number",{type:Number},!0)},b=function(){return a("array",{type:Array},!0)},v=function(){return a("object",{type:Object},!0)},g=function(){return a("symbol")},O=function(){return a("integer",{type:Number})},h=function(t){return a("oneOf")},j=function(t){return a("custom")},m=function(t){return a("instanceOf",{type:t})},x=function(t){return a("oneOfType")},k=function(t){return a("arrayOf",{type:Array})},_=function(t){return a("objectOf",{type:Object})},P=function(t){return c(a("shape",{type:Object}),"loose",{get:function(){return this}})};function T(t,e,n,r,o){var u;void 0===r&&(r=!1),void 0===o&&(o=!1);var i=((u={})[r?"get":"value"]=function(){return a(e,n,o).def(r?t.defaults[e]:void 0)},u);return c(t,e,i)}var w=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,o=t.type,u=void 0===o?null:o;return T(this,t.name,{type:i(u)&&u.type?null:u},r,!!e)},e(t,null,[{key:"any",get:function(){return s()}},{key:"func",get:function(){return p().def(this.defaults.func)}},{key:"bool",get:function(){return l().def(this.defaults.bool)}},{key:"string",get:function(){return y().def(this.defaults.string)}},{key:"number",get:function(){return d().def(this.defaults.number)}},{key:"array",get:function(){return b().def(this.defaults.array)}},{key:"object",get:function(){return v().def(this.defaults.object)}},{key:"symbol",get:function(){return g()}},{key:"integer",get:function(){return O().def(this.defaults.integer)}}]),t}();function A(t){var o;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(o=function(o){function u(){return o.apply(this,arguments)||this}return r(u,o),e(u,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(e){this.defaults=!1!==e?n({},!0!==e?e:t):{}}}]),u}(w)).defaults=n({},t),o}w.defaults={},w.oneOf=h,w.custom=j,w.instanceOf=m,w.oneOfType=x,w.arrayOf=k,w.objectOf=_,w.shape=P,w.utils={toType:a,validate:function(){return!![].slice.call(arguments)}},"production"!==process.env.NODE_ENV&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");var N=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(A());Object.defineProperty(exports,"__esModule",{value:!0}),exports.any=s,exports.array=b,exports.arrayOf=k,exports.bool=l,exports.createTypes=A,exports.custom=j,exports.default=N,exports.func=p,exports.instanceOf=m,exports.integer=O,exports.number=d,exports.object=v,exports.objectOf=_,exports.oneOf=h,exports.oneOfType=x,exports.shape=P,exports.string=y,exports.symbol=g; | ||
//# sourceMappingURL=shim.js.map |
@@ -1,2 +0,2 @@ | ||
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,t.__proto__=e}function u(t){return 1==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);var e}function o(t){var e,n;return!1!==u(t)&&"function"==typeof(e=t.constructor)&&!1!==u(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")}var i=Object.defineProperty,c=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function f(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=c(t)?function(){return[].concat(t)}:o(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 a=function(){return f("any",{},!0)},s=function(){return f("func",{type:Function},!0)},l=function(){return f("bool",{type:Boolean},!0)},y=function(){return f("string",{type:String},!0)},p=function(){return f("number",{type:Number},!0)},d=function(){return f("array",{type:Array},!0)},b=function(){return f("object",{type:Object},!0)},v=function(){return f("symbol")},g=function(){return f("integer",{type:Number})},h=function(t){return f("oneOf")},O=function(t){return f("custom")},j=function(t){return f("instanceOf",{type:t})},m=function(t){return f("oneOfType")},k=function(t){return f("arrayOf",{type:Array})},w=function(t){return f("objectOf",{type:Object})},A=function(t){return i(f("shape",{type:Object}),"loose",{get:function(){return this}})};function _(t,e,n,r,u){var o;void 0===r&&(r=!1),void 0===u&&(u=!1);var c=((o={})[r?"get":"value"]=function(){return f(e,n,u).def(r?t.defaults[e]:void 0)},o);return i(t,e,c)}var P=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,u=t.type,i=void 0===u?null:u;return _(this,t.name,{type:o(i)&&i.type?null:i},r,!!e)},e(t,null,[{key:"any",get:function(){return a()}},{key:"func",get:function(){return s().def(this.defaults.func)}},{key:"bool",get:function(){return l().def(this.defaults.bool)}},{key:"string",get:function(){return y().def(this.defaults.string)}},{key:"number",get:function(){return p().def(this.defaults.number)}},{key:"array",get:function(){return d().def(this.defaults.array)}},{key:"object",get:function(){return b().def(this.defaults.object)}},{key:"symbol",get:function(){return v()}},{key:"integer",get:function(){return g().def(this.defaults.integer)}}]),t}();function T(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}(P)).defaults=n({},t),u}P.defaults={},P.oneOf=h,P.custom=O,P.instanceOf=j,P.oneOfType=m,P.arrayOf=k,P.objectOf=w,P.shape=A,P.utils={toType:f,validate:function(){return!![].slice.call(arguments)}},"production"!==process.env.NODE_ENV&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");var N=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(T());export default N;export{a as any,d as array,k as arrayOf,l as bool,T as createTypes,O as custom,s as func,j as instanceOf,g as integer,p as number,b as object,w as objectOf,h as oneOf,m as oneOfType,A as shape,y as string,v as symbol}; | ||
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=Object.defineProperty,f=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(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=f(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 s=function(){return a("any",{},!0)},l=function(){return a("func",{type:Function},!0)},y=function(){return a("bool",{type:Boolean},!0)},p=function(){return a("string",{type:String},!0)},d=function(){return a("number",{type:Number},!0)},b=function(){return a("array",{type:Array},!0)},v=function(){return a("object",{type:Object},!0)},g=function(){return a("symbol")},h=function(){return a("integer",{type:Number})},O=function(t){return a("oneOf")},j=function(t){return a("custom")},m=function(t){return a("instanceOf",{type:t})},k=function(t){return a("oneOfType")},w=function(t){return a("arrayOf",{type:Array})},P=function(t){return a("objectOf",{type:Object})},_=function(t){return c(a("shape",{type:Object}),"loose",{get:function(){return this}})};function T(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 a(e,n,u).def(r?t.defaults[e]:void 0)},o);return c(t,e,i)}var A=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 T(this,t.name,{type:i(o)&&o.type?null:o},r,!!e)},e(t,null,[{key:"any",get:function(){return s()}},{key:"func",get:function(){return l().def(this.defaults.func)}},{key:"bool",get:function(){return y().def(this.defaults.bool)}},{key:"string",get:function(){return p().def(this.defaults.string)}},{key:"number",get:function(){return d().def(this.defaults.number)}},{key:"array",get:function(){return b().def(this.defaults.array)}},{key:"object",get:function(){return v().def(this.defaults.object)}},{key:"symbol",get:function(){return g()}},{key:"integer",get:function(){return h().def(this.defaults.integer)}}]),t}();function N(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}(A)).defaults=n({},t),u}A.defaults={},A.oneOf=O,A.custom=j,A.instanceOf=m,A.oneOfType=k,A.arrayOf=w,A.objectOf=P,A.shape=_,A.utils={toType:a,validate:function(){return!![].slice.call(arguments)}},"production"!==process.env.NODE_ENV&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");var x=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(N());export default x;export{s as any,b as array,w as arrayOf,y as bool,N as createTypes,j as custom,l as func,m as instanceOf,h as integer,d as number,v as object,P as objectOf,O as oneOf,k as oneOfType,_ as shape,p as string,g as symbol}; | ||
//# sourceMappingURL=shim.m.js.map |
@@ -1,2 +0,2 @@ | ||
function t(t){return 1==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);var e}function e(e){var r,n;return!1!==t(e)&&"function"==typeof(r=e.constructor)&&!1!==t(n=r.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")}const r=Object.defineProperty,n=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,r={},s=!1){const a={_vueTypes_name:{value:t,writable:!0},def:{value(t){const r=this;return void 0!==t||r.default?(r.default=n(t)?()=>[].concat(t):e(t)?()=>Object.assign({},t):t,r):r}},isRequired:{get(){return this.required=!0,this}}};return s&&(a.validate={value(){}}),Object.assign(Object.defineProperties({validator:()=>!0},a),r)}const a=()=>s("any",{},!0),o=()=>s("func",{type:Function},!0),i=()=>s("bool",{type:Boolean},!0),u=()=>s("string",{type:String},!0),c=()=>s("number",{type:Number},!0),l=()=>s("array",{type:Array},!0),f=()=>s("object",{type:Object},!0),y=()=>s("symbol"),d=()=>s("integer",{type:Number}),p=t=>s("oneOf"),b=t=>s("custom"),g=t=>s("instanceOf",{type:t}),h=t=>s("oneOfType"),O=t=>s("arrayOf",{type:Array}),j=t=>s("objectOf",{type:Object}),v=t=>r(s("shape",{type:Object}),"loose",{get(){return this}});function m(t,e,n,a=!1,o=!1){return r(t,e,{[a?"get":"value"]:()=>s(e,n,o).def(a?t.defaults[e]:void 0)})}class A{static get any(){return a()}static get func(){return o().def(this.defaults.func)}static get bool(){return i().def(this.defaults.bool)}static get string(){return u().def(this.defaults.string)}static get number(){return c().def(this.defaults.number)}static get array(){return l().def(this.defaults.array)}static get object(){return f().def(this.defaults.object)}static get symbol(){return y()}static get integer(){return d().def(this.defaults.integer)}static extend(t){const{name:r,validate:n,getter:s=!1,type:a=null}=t;return m(this,r,{type:e(a)&&a.type?null:a},s,!!n)}}function T(t={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var e;return(e=class extends A{static get sensibleDefaults(){return{...this.defaults}}static set sensibleDefaults(e){this.defaults=!1!==e?!0!==e?{...e}:{...t}:{}}}).defaults={...t},e}A.defaults={},A.oneOf=p,A.custom=b,A.instanceOf=g,A.oneOfType=h,A.arrayOf=O,A.objectOf=j,A.shape=v,A.utils={toType:s,validate:(...t)=>!!t},"production"!==process.env.NODE_ENV&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");class w extends(T()){}export default w;export{a as any,l as array,O as arrayOf,i as bool,T as createTypes,b as custom,o as func,g as instanceOf,d as integer,c as number,f as object,j as objectOf,p as oneOf,h as oneOfType,v as shape,u as string,y as symbol}; | ||
function t(){return(t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function e(t){return"[object Object]"===Object.prototype.toString.call(t)}function r(t){var r,n;return!1!==e(t)&&(void 0===(r=t.constructor)||!1!==e(n=r.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}const n=Object.defineProperty,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(t,e={},n=!1){const a={_vueTypes_name:{value:t,writable:!0},def:{value(t){const e=this;return void 0!==t||e.default?(e.default=s(t)?()=>[].concat(t):r(t)?()=>Object.assign({},t):t,e):e}},isRequired:{get(){return this.required=!0,this}}};return n&&(a.validate={value(){}}),Object.assign(Object.defineProperties({validator:()=>!0},a),e)}const o=()=>a("any",{},!0),i=()=>a("func",{type:Function},!0),u=()=>a("bool",{type:Boolean},!0),c=()=>a("string",{type:String},!0),l=()=>a("number",{type:Number},!0),f=()=>a("array",{type:Array},!0),p=()=>a("object",{type:Object},!0),d=()=>a("symbol"),y=()=>a("integer",{type:Number}),b=t=>a("oneOf"),g=t=>a("custom"),h=t=>a("instanceOf",{type:t}),O=t=>a("oneOfType"),v=t=>a("arrayOf",{type:Array}),j=t=>a("objectOf",{type:Object}),m=t=>n(a("shape",{type:Object}),"loose",{get(){return this}});function w(t,e,r,s=!1,o=!1){return n(t,e,{[s?"get":"value"]:()=>a(e,r,o).def(s?t.defaults[e]:void 0)})}class T{static get any(){return o()}static get func(){return i().def(this.defaults.func)}static get bool(){return u().def(this.defaults.bool)}static get string(){return c().def(this.defaults.string)}static get number(){return l().def(this.defaults.number)}static get array(){return f().def(this.defaults.array)}static get object(){return p().def(this.defaults.object)}static get symbol(){return d()}static get integer(){return y().def(this.defaults.integer)}static extend(t){const{name:e,validate:n,getter:s=!1,type:a=null}=t;return w(this,e,{type:r(a)&&a.type?null:a},s,!!n)}}function x(e={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var r;return(r=class extends T{static get sensibleDefaults(){return t({},this.defaults)}static set sensibleDefaults(r){this.defaults=!1!==r?t({},!0!==r?r:e):{}}}).defaults=t({},e),r}T.defaults={},T.oneOf=b,T.custom=g,T.instanceOf=h,T.oneOfType=O,T.arrayOf=v,T.objectOf=j,T.shape=m,T.utils={toType:a,validate:(...t)=>!!t},"production"!==process.env.NODE_ENV&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");class A extends(x()){}export default A;export{o as any,f as array,v as arrayOf,u as bool,x as createTypes,g as custom,i as func,h as instanceOf,y as integer,l as number,p as object,j as objectOf,b as oneOf,O as oneOfType,m as shape,c as string,d as symbol}; | ||
//# sourceMappingURL=shim.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=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,t.__proto__=e}function o(t){return 1==(null!=(e=t)&&"object"==typeof e&&!1===Array.isArray(e))&&"[object Object]"===Object.prototype.toString.call(t);var e}function i(t){var e,n;return!1!==o(t)&&"function"==typeof(e=t.constructor)&&!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")}var f=Object.defineProperty,c=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function a(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=c(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 s=function(){return a("any",{},!0)},y=function(){return a("func",{type:Function},!0)},l=function(){return a("bool",{type:Boolean},!0)},p=function(){return a("string",{type:String},!0)},d=function(){return a("number",{type:Number},!0)},b=function(){return a("array",{type:Array},!0)},v=function(){return a("object",{type:Object},!0)},g=function(){return a("symbol")},O=function(){return a("integer",{type:Number})},h=function(t){return a("oneOf")},j=function(t){return a("custom")},m=function(t){return a("instanceOf",{type:t})},k=function(t){return a("oneOfType")},A=function(t){return a("arrayOf",{type:Array})},T=function(t){return a("objectOf",{type:Object})},P=function(t){return f(a("shape",{type:Object}),"loose",{get:function(){return this}})};function _(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 a(e,n,u).def(r?t.defaults[e]:void 0)},o);return f(t,e,i)}var w=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 _(this,t.name,{type:i(o)&&o.type?null:o},r,!!e)},n(t,null,[{key:"any",get:function(){return s()}},{key:"func",get:function(){return y().def(this.defaults.func)}},{key:"bool",get:function(){return l().def(this.defaults.bool)}},{key:"string",get:function(){return p().def(this.defaults.string)}},{key:"number",get:function(){return d().def(this.defaults.number)}},{key:"array",get:function(){return b().def(this.defaults.array)}},{key:"object",get:function(){return v().def(this.defaults.object)}},{key:"symbol",get:function(){return g()}},{key:"integer",get:function(){return O().def(this.defaults.integer)}}]),t}();function x(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}(w)).defaults=r({},t),e}w.defaults={},w.oneOf=h,w.custom=j,w.instanceOf=m,w.oneOfType=k,w.arrayOf=A,w.objectOf=T,w.shape=P,w.utils={toType:a,validate:function(){return!![].slice.call(arguments)}};var S=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e}(x());t.any=s,t.array=b,t.arrayOf=A,t.bool=l,t.createTypes=x,t.custom=j,t.default=S,t.func=y,t.instanceOf=m,t.integer=O,t.number=d,t.object=v,t.objectOf=T,t.oneOf=h,t.oneOfType=k,t.shape=P,t.string=p,t.symbol=g}); | ||
!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=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)}: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 y=function(){return s("any",{},!0)},l=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)},O=function(){return s("symbol")},h=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})},T=function(t){return s("oneOfType")},P=function(t){return s("arrayOf",{type:Array})},_=function(t){return s("objectOf",{type:Object})},A=function(t){return c(s("shape",{type:Object}),"loose",{get:function(){return this}})};function w(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 c(t,e,i)}var x=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 w(this,t.name,{type:f(o)&&o.type?null:o},r,!!e)},n(t,null,[{key:"any",get:function(){return y()}},{key:"func",get:function(){return l().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 O()}},{key:"integer",get:function(){return h().def(this.defaults.integer)}}]),t}();function S(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}(x)).defaults=r({},t),e}x.defaults={},x.oneOf=j,x.custom=m,x.instanceOf=k,x.oneOfType=T,x.arrayOf=P,x.objectOf=_,x.shape=A,x.utils={toType:s,validate:function(){return!![].slice.call(arguments)}};var q=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e}(S());t.any=y,t.array=v,t.arrayOf=P,t.bool=p,t.createTypes=S,t.custom=m,t.default=q,t.func=l,t.instanceOf=k,t.integer=h,t.number=b,t.object=g,t.objectOf=_,t.oneOf=j,t.oneOfType=T,t.shape=A,t.string=d,t.symbol=O}); | ||
//# sourceMappingURL=shim.umd.js.map |
@@ -1,12 +0,1 @@ | ||
import { PropType } from 'vue' | ||
export { PropType } | ||
export interface PropOptions<T = any, D = T> { | ||
type?: PropType<T> | true | null | ||
required?: boolean | ||
default?: D | ((props: Record<string, unknown>) => D) | null | undefined | ||
validator?(value: unknown): boolean | ||
} | ||
export type Prop<T = any> = | ||
@@ -35,2 +24,18 @@ | { | ||
export type PropType<T> = Prop<T> | Prop<T>[] | ||
export interface PropOptions<T = any, D = T> { | ||
type?: PropType<T> | true | null | ||
required?: boolean | ||
default?: | ||
| D | ||
| null | ||
| undefined | ||
| (() => D | null | undefined) | ||
| ((props: Record<string, unknown>) => D) | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
| object | ||
validator?(value: T): boolean | ||
} | ||
// see https://github.com/vuejs/vue-next/blob/22717772dd83b67ffaa6ad9805c6269e184c7e41/packages/runtime-core/src/componentProps.ts#L67 | ||
@@ -63,2 +68,3 @@ export type InferType<T> = T extends { type: null | true } | ||
_vueTypes_name: string | ||
type?: PropType<T> | null | ||
readonly def: ( | ||
@@ -65,0 +71,0 @@ def?: D, |
import { VueTypeDef, VueTypeValidableDef, VueProp, InferType, PropOptions } from './types'; | ||
export declare const hasOwn: (v: string | number | symbol) => boolean; | ||
export declare const hasOwn: (v: PropertyKey) => boolean; | ||
export declare function getType(fn: VueProp<any> | (() => any) | (new (...args: any[]) => any)): string; | ||
@@ -4,0 +4,0 @@ export declare function getNativeType(value: any): string; |
@@ -1,2 +0,2 @@ | ||
function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function o(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}function i(e){return 1==(null!=(t=e)&&"object"==typeof t&&!1===Array.isArray(t))&&"[object Object]"===Object.prototype.toString.call(e);var t}var u=Object.prototype,a=u.toString,f=u.hasOwnProperty,c=/^\s*function (\w+)/;function s(e){var t,r=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(r){var n=r.toString().match(c);return n?n[1]:""}return""}var l=function(e){var t,r;return!1!==i(e)&&"function"==typeof(t=e.constructor)&&!1!==i(r=t.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf")},p=function(e){return e},y=p;if("production"!==process.env.NODE_ENV){var v="undefined"!=typeof console;y=v?function(e){console.warn("[VueTypes warn]: "+e)}:p}var d=function(e,t){return f.call(e,t)},h=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},b=Array.isArray||function(e){return"[object Array]"===a.call(e)},O=function(e){return"[object Function]"===a.call(e)},g=function(e){return l(e)&&d(e,"_vueTypes_name")},m=function(e){return l(e)&&(d(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return d(e,t)}))};function j(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function _(e,t,r){var n;void 0===r&&(r=!1);var o=!0,i="";n=l(e)?e:{type:e};var u=g(n)?n._vueTypes_name+" - ":"";if(m(n)&&null!==n.type){if(void 0===n.type||!0===n.type)return o;if(!n.required&&void 0===t)return o;b(n.type)?(o=n.type.some(function(e){return!0===_(e,t,!0)}),i=n.type.map(function(e){return s(e)}).join(" or ")):o="Array"===(i=s(n))?b(t):"Object"===i?l(t):"String"===i||"Number"===i||"Boolean"===i||"Function"===i?function(e){if(null==e)return"";var t=e.constructor.toString().match(c);return t?t[1]:""}(t)===i:t instanceof n.type}if(!o){var a=u+'value "'+t+'" should be of type "'+i+'"';return!1===r?(y(a),!1):a}if(d(n,"validator")&&O(n.validator)){var f=y,p=[];if(y=function(e){p.push(e)},o=n.validator(t),y=f,!o){var v=(p.length>1?"* ":"")+p.join("\n* ");return p.length=0,!1===r?(y(v),o):v}}return o}function T(e,t){var r=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get:function(){return this.required=!0,this}},def:{value:function(e){return void 0!==e||this.default?O(e)||!0===_(this,e,!0)?(this.default=b(e)?function(){return[].concat(e)}:l(e)?function(){return Object.assign({},e)}:e,this):(y(this._vueTypes_name+' - invalid default value: "'+e+'"'),this):this}}}),n=r.validator;return O(n)&&(r.validator=j(n,r)),r}function x(e,t){var r=T(e,t);return Object.defineProperty(r,"validate",{value:function(e){return O(this.validator)&&y(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=j(e,this),this}})}function w(e,t,r){var n,i,u=(n=t,i={},Object.getOwnPropertyNames(n).forEach(function(e){i[e]=Object.getOwnPropertyDescriptor(n,e)}),Object.defineProperties({},i));if(u._vueTypes_name=e,!l(r))return u;var a,f,c=r.validator,s=o(r,["validator"]);if(O(c)){var p=u.validator;p&&(p=null!==(f=(a=p).__original)&&void 0!==f?f:a),u.validator=j(p?function(e){return p.call(this,e)&&c.call(this,e)}:c,u)}return Object.assign(u,s)}function k(e){return e.replace(/^(?!\s*$)/gm," ")}var P=function(){return x("any",{})},A=function(){return x("function",{type:Function})},E=function(){return x("boolean",{type:Boolean})},N=function(){return x("string",{type:String})},V=function(){return x("number",{type:Number})},q=function(){return x("array",{type:Array})},S=function(){return x("object",{type:Object})},F=function(){return T("integer",{type:Number,validator:function(e){return h(e)}})},D=function(){return T("symbol",{validator:function(e){return"symbol"==typeof e}})};function L(e,t){if(void 0===t&&(t="custom validation failed"),"function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return T(e.name||"<<anonymous function>>",{validator:function(r){var n=e(r);return n||y(this._vueTypes_name+" - "+t),n}})}function Y(e){if(!b(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");var t='oneOf - value should be one of "'+e.join('", "')+'".',r=e.reduce(function(e,t){if(null!=t){var r=t.constructor;-1===e.indexOf(r)&&e.push(r)}return e},[]);return T("oneOf",{type:r.length>0?r:void 0,validator:function(r){var n=-1!==e.indexOf(r);return n||y(t),n}})}function B(e){if(!b(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");for(var t=!1,r=[],n=0;n<e.length;n+=1){var o=e[n];if(m(o)){if(g(o)&&"oneOf"===o._vueTypes_name){r=r.concat(o.type);continue}if(O(o.validator)&&(t=!0),!0!==o.type&&o.type){r=r.concat(o.type);continue}}r.push(o)}return r=r.filter(function(e,t){return r.indexOf(e)===t}),T("oneOfType",t?{type:r,validator:function(t){var r=[],n=e.some(function(e){var n=_(g(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof n&&r.push(n),!0===n});return n||y("oneOfType - provided value does not match any of the "+r.length+" passed-in validators:\n"+k(r.join("\n"))),n}}:{type:r})}function M(e){return T("arrayOf",{type:Array,validator:function(t){var r,n=t.every(function(t){return!0===(r=_(e,t,!0))});return n||y("arrayOf - value validation error:\n"+k(r)),n}})}function I(e){return T("instanceOf",{type:e})}function J(e){return T("objectOf",{type:Object,validator:function(t){var r,n=Object.keys(t).every(function(n){return!0===(r=_(e,t[n],!0))});return n||y("objectOf - value validation error:\n"+k(r)),n}})}function R(e){var t=Object.keys(e),r=t.filter(function(t){var r;return!!(null===(r=e[t])||void 0===r?void 0:r.required)}),n=T("shape",{type:Object,validator:function(n){var o=this;if(!l(n))return!1;var i=Object.keys(n);if(r.length>0&&r.some(function(e){return-1===i.indexOf(e)})){var u=r.filter(function(e){return-1===i.indexOf(e)});return y(1===u.length?'shape - required property "'+u[0]+'" is not defined.':'shape - required properties "'+u.join('", "')+'" are not defined.'),!1}return i.every(function(r){if(-1===t.indexOf(r))return!0===o._vueTypes_isLoose||(y('shape - shape definition does not include a "'+r+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var i=_(e[r],n[r],!0);return"string"==typeof i&&y('shape - "'+r+'" property validation error:\n '+k(i)),!0===i})}});return Object.defineProperty(n,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(n,"loose",{get:function(){return this._vueTypes_isLoose=!0,this}}),n}var $=function(){function e(){}return e.extend=function(e){var t=this;if(b(e))return e.forEach(function(e){return t.extend(e)}),this;var r=e.name,n=e.validate,i=void 0!==n&&n,u=e.getter,a=void 0!==u&&u,f=o(e,["name","validate","getter"]);if(d(this,r))throw new TypeError('[VueTypes error]: Type "'+r+'" already defined');var c,s=f.type;return g(s)?(delete f.type,Object.defineProperty(this,r,a?{get:function(){return w(r,s,f)}}:{value:function(){var e,t=w(r,s,f);return t.validator&&(t.validator=(e=t.validator).bind.apply(e,[t].concat([].slice.call(arguments)))),t}})):(c=a?{get:function(){var e=Object.assign({},f);return i?x(r,e):T(r,e)},enumerable:!0}:{value:function(){var e,t,n=Object.assign({},f);return e=i?x(r,n):T(r,n),n.validator&&(e.validator=(t=n.validator).bind.apply(t,[e].concat([].slice.call(arguments)))),e},enumerable:!0},Object.defineProperty(this,r,c))},t(e,null,[{key:"any",get:function(){return P()}},{key:"func",get:function(){return A().def(this.defaults.func)}},{key:"bool",get:function(){return E().def(this.defaults.bool)}},{key:"string",get:function(){return N().def(this.defaults.string)}},{key:"number",get:function(){return V().def(this.defaults.number)}},{key:"array",get:function(){return q().def(this.defaults.array)}},{key:"object",get:function(){return S().def(this.defaults.object)}},{key:"integer",get:function(){return F().def(this.defaults.integer)}},{key:"symbol",get:function(){return D()}}]),e}();function z(e){var o;return void 0===e&&(e={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(o=function(o){function i(){return o.apply(this,arguments)||this}return n(i,o),t(i,null,[{key:"sensibleDefaults",get:function(){return r({},this.defaults)},set:function(t){this.defaults=!1!==t?r({},!0!==t?t:e):{}}}]),i}($)).defaults=r({},e),o}$.defaults={},$.custom=L,$.oneOf=Y,$.instanceOf=I,$.oneOfType=B,$.arrayOf=M,$.objectOf=J,$.shape=R,$.utils={validate:function(e,t){return!0===_(t,e,!0)},toType:function(e,t,r){return void 0===r&&(r=!1),r?x(e,t):T(e,t)}};var C=function(e){function t(){return e.apply(this,arguments)||this}return n(t,e),t}(z());Object.defineProperty(exports,"__esModule",{value:!0}),exports.any=P,exports.array=q,exports.arrayOf=M,exports.bool=E,exports.createTypes=z,exports.custom=L,exports.default=C,exports.fromType=w,exports.func=A,exports.instanceOf=I,exports.integer=F,exports.number=V,exports.object=S,exports.objectOf=J,exports.oneOf=Y,exports.oneOfType=B,exports.shape=R,exports.string=N,exports.symbol=D,exports.toType=T,exports.toValidableType=x,exports.validateType=_; | ||
function e(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function t(t,r,n){return r&&e(t.prototype,r),n&&e(t,n),t}function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function n(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function i(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}var a=Object.prototype,f=a.toString,c=a.hasOwnProperty,s=/^\s*function (\w+)/;function l(e){var t,r=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(r){var n=r.toString().match(s);return n?n[1]:""}return""}var p=function(e){var t,r;return!1!==u(e)&&(void 0===(t=e.constructor)||!1!==u(r=t.prototype)&&!1!==r.hasOwnProperty("isPrototypeOf"))},y=function(e){return e},v=y;if("production"!==process.env.NODE_ENV){var d="undefined"!=typeof console;v=d?function(e){console.warn("[VueTypes warn]: "+e)}:y}var h=function(e,t){return c.call(e,t)},b=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},O=Array.isArray||function(e){return"[object Array]"===f.call(e)},g=function(e){return"[object Function]"===f.call(e)},m=function(e){return p(e)&&h(e,"_vueTypes_name")},j=function(e){return p(e)&&(h(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return h(e,t)}))};function _(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function T(e,t,r){var n;void 0===r&&(r=!1);var o=!0,i="";n=p(e)?e:{type:e};var u=m(n)?n._vueTypes_name+" - ":"";if(j(n)&&null!==n.type){if(void 0===n.type||!0===n.type)return o;if(!n.required&&void 0===t)return o;O(n.type)?(o=n.type.some(function(e){return!0===T(e,t,!0)}),i=n.type.map(function(e){return l(e)}).join(" or ")):o="Array"===(i=l(n))?O(t):"Object"===i?p(t):"String"===i||"Number"===i||"Boolean"===i||"Function"===i?function(e){if(null==e)return"";var t=e.constructor.toString().match(s);return t?t[1]:""}(t)===i:t instanceof n.type}if(!o){var a=u+'value "'+t+'" should be of type "'+i+'"';return!1===r?(v(a),!1):a}if(h(n,"validator")&&g(n.validator)){var f=v,c=[];if(v=function(e){c.push(e)},o=n.validator(t),v=f,!o){var y=(c.length>1?"* ":"")+c.join("\n* ");return c.length=0,!1===r?(v(y),o):y}}return o}function x(e,t){var r=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get:function(){return this.required=!0,this}},def:{value:function(e){return void 0===e?(h(this,"default")&&delete this.default,this):g(e)||!0===T(this,e,!0)?(this.default=O(e)?function(){return[].concat(e)}:p(e)?function(){return Object.assign({},e)}:e,this):(v(this._vueTypes_name+' - invalid default value: "'+e+'"'),this)}}}),n=r.validator;return g(n)&&(r.validator=_(n,r)),r}function w(e,t){var r=x(e,t);return Object.defineProperty(r,"validate",{value:function(e){return g(this.validator)&&v(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=_(e,this),this}})}function P(e,t,r){var n,o,u=(n=t,o={},Object.getOwnPropertyNames(n).forEach(function(e){o[e]=Object.getOwnPropertyDescriptor(n,e)}),Object.defineProperties({},o));if(u._vueTypes_name=e,!p(r))return u;var a,f,c=r.validator,s=i(r,["validator"]);if(g(c)){var l=u.validator;l&&(l=null!==(f=(a=l).__original)&&void 0!==f?f:a),u.validator=_(l?function(e){return l.call(this,e)&&c.call(this,e)}:c,u)}return Object.assign(u,s)}function k(e){return e.replace(/^(?!\s*$)/gm," ")}var E=function(){return w("any",{})},N=function(){return w("function",{type:Function})},V=function(){return w("boolean",{type:Boolean})},q=function(){return w("string",{type:String})},A=function(){return w("number",{type:Number})},S=function(){return w("array",{type:Array})},F=function(){return w("object",{type:Object})},D=function(){return x("integer",{type:Number,validator:function(e){return b(e)}})},L=function(){return x("symbol",{validator:function(e){return"symbol"==typeof e}})};function Y(e,t){if(void 0===t&&(t="custom validation failed"),"function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return x(e.name||"<<anonymous function>>",{validator:function(r){var n=e(r);return n||v(this._vueTypes_name+" - "+t),n}})}function B(e){if(!O(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");var t='oneOf - value should be one of "'+e.join('", "')+'".',r=e.reduce(function(e,t){if(null!=t){var r=t.constructor;-1===e.indexOf(r)&&e.push(r)}return e},[]);return x("oneOf",{type:r.length>0?r:void 0,validator:function(r){var n=-1!==e.indexOf(r);return n||v(t),n}})}function M(e){if(!O(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");for(var t=!1,r=[],n=0;n<e.length;n+=1){var o=e[n];if(j(o)){if(m(o)&&"oneOf"===o._vueTypes_name&&o.type){r=r.concat(o.type);continue}if(g(o.validator)&&(t=!0),!0!==o.type&&o.type){r=r.concat(o.type);continue}}r.push(o)}return r=r.filter(function(e,t){return r.indexOf(e)===t}),x("oneOfType",t?{type:r,validator:function(t){var r=[],n=e.some(function(e){var n=T(m(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof n&&r.push(n),!0===n});return n||v("oneOfType - provided value does not match any of the "+r.length+" passed-in validators:\n"+k(r.join("\n"))),n}}:{type:r})}function I(e){return x("arrayOf",{type:Array,validator:function(t){var r,n=t.every(function(t){return!0===(r=T(e,t,!0))});return n||v("arrayOf - value validation error:\n"+k(r)),n}})}function J(e){return x("instanceOf",{type:e})}function R(e){return x("objectOf",{type:Object,validator:function(t){var r,n=Object.keys(t).every(function(n){return!0===(r=T(e,t[n],!0))});return n||v("objectOf - value validation error:\n"+k(r)),n}})}function $(e){var t=Object.keys(e),r=t.filter(function(t){var r;return!(null===(r=e[t])||void 0===r||!r.required)}),n=x("shape",{type:Object,validator:function(n){var o=this;if(!p(n))return!1;var i=Object.keys(n);if(r.length>0&&r.some(function(e){return-1===i.indexOf(e)})){var u=r.filter(function(e){return-1===i.indexOf(e)});return v(1===u.length?'shape - required property "'+u[0]+'" is not defined.':'shape - required properties "'+u.join('", "')+'" are not defined.'),!1}return i.every(function(r){if(-1===t.indexOf(r))return!0===o._vueTypes_isLoose||(v('shape - shape definition does not include a "'+r+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var i=T(e[r],n[r],!0);return"string"==typeof i&&v('shape - "'+r+'" property validation error:\n '+k(i)),!0===i})}});return Object.defineProperty(n,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(n,"loose",{get:function(){return this._vueTypes_isLoose=!0,this}}),n}var z=function(){function e(){}return e.extend=function(e){var t=this;if(O(e))return e.forEach(function(e){return t.extend(e)}),this;var r=e.name,n=e.validate,o=void 0!==n&&n,u=e.getter,a=void 0!==u&&u,f=i(e,["name","validate","getter"]);if(h(this,r))throw new TypeError('[VueTypes error]: Type "'+r+'" already defined');var c,s=f.type;return m(s)?(delete f.type,Object.defineProperty(this,r,a?{get:function(){return P(r,s,f)}}:{value:function(){var e,t=P(r,s,f);return t.validator&&(t.validator=(e=t.validator).bind.apply(e,[t].concat([].slice.call(arguments)))),t}})):(c=a?{get:function(){var e=Object.assign({},f);return o?w(r,e):x(r,e)},enumerable:!0}:{value:function(){var e,t,n=Object.assign({},f);return e=o?w(r,n):x(r,n),n.validator&&(e.validator=(t=n.validator).bind.apply(t,[e].concat([].slice.call(arguments)))),e},enumerable:!0},Object.defineProperty(this,r,c))},t(e,null,[{key:"any",get:function(){return E()}},{key:"func",get:function(){return N().def(this.defaults.func)}},{key:"bool",get:function(){return V().def(this.defaults.bool)}},{key:"string",get:function(){return q().def(this.defaults.string)}},{key:"number",get:function(){return A().def(this.defaults.number)}},{key:"array",get:function(){return S().def(this.defaults.array)}},{key:"object",get:function(){return F().def(this.defaults.object)}},{key:"integer",get:function(){return D().def(this.defaults.integer)}},{key:"symbol",get:function(){return L()}}]),e}();function C(e){var o;return void 0===e&&(e={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(o=function(o){function i(){return o.apply(this,arguments)||this}return n(i,o),t(i,null,[{key:"sensibleDefaults",get:function(){return r({},this.defaults)},set:function(t){this.defaults=!1!==t?r({},!0!==t?t:e):{}}}]),i}(z)).defaults=r({},e),o}z.defaults={},z.custom=Y,z.oneOf=B,z.instanceOf=J,z.oneOfType=M,z.arrayOf=I,z.objectOf=R,z.shape=$,z.utils={validate:function(e,t){return!0===T(t,e,!0)},toType:function(e,t,r){return void 0===r&&(r=!1),r?w(e,t):x(e,t)}};var G=function(e){function t(){return e.apply(this,arguments)||this}return n(t,e),t}(C());Object.defineProperty(exports,"__esModule",{value:!0}),exports.any=E,exports.array=S,exports.arrayOf=I,exports.bool=V,exports.createTypes=C,exports.custom=Y,exports.default=G,exports.fromType=P,exports.func=N,exports.instanceOf=J,exports.integer=D,exports.number=A,exports.object=F,exports.objectOf=R,exports.oneOf=B,exports.oneOfType=M,exports.shape=$,exports.string=q,exports.symbol=L,exports.toType=x,exports.toValidableType=w,exports.validateType=T; | ||
//# sourceMappingURL=vue-types.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function i(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}function o(e){return 1==(null!=(t=e)&&"object"==typeof t&&!1===Array.isArray(t))&&"[object Object]"===Object.prototype.toString.call(e);var t}var u=Object.prototype,a=u.toString,f=u.hasOwnProperty,c=/^\s*function (\w+)/;function l(e){var t,n=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(n){var r=n.toString().match(c);return r?r[1]:""}return""}var s=function(e){var t,n;return!1!==o(e)&&"function"==typeof(t=e.constructor)&&!1!==o(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")},v=function(e){return e},y=v;if("production"!==process.env.NODE_ENV){var p="undefined"!=typeof console;y=p?function(e){console.warn("[VueTypes warn]: "+e)}:v}var d=function(e,t){return f.call(e,t)},h=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},b=Array.isArray||function(e){return"[object Array]"===a.call(e)},O=function(e){return"[object Function]"===a.call(e)},g=function(e){return s(e)&&d(e,"_vueTypes_name")},m=function(e){return s(e)&&(d(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return d(e,t)}))};function j(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function _(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=s(e)?e:{type:e};var u=g(r)?r._vueTypes_name+" - ":"";if(m(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;b(r.type)?(i=r.type.some(function(e){return!0===_(e,t,!0)}),o=r.type.map(function(e){return l(e)}).join(" or ")):i="Array"===(o=l(r))?b(t):"Object"===o?s(t):"String"===o||"Number"===o||"Boolean"===o||"Function"===o?function(e){if(null==e)return"";var t=e.constructor.toString().match(c);return t?t[1]:""}(t)===o:t instanceof r.type}if(!i){var a=u+'value "'+t+'" should be of type "'+o+'"';return!1===n?(y(a),!1):a}if(d(r,"validator")&&O(r.validator)){var f=y,v=[];if(y=function(e){v.push(e)},i=r.validator(t),y=f,!i){var p=(v.length>1?"* ":"")+v.join("\n* ");return v.length=0,!1===n?(y(p),i):p}}return i}function T(e,t){var n=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get:function(){return this.required=!0,this}},def:{value:function(e){return void 0!==e||this.default?O(e)||!0===_(this,e,!0)?(this.default=b(e)?function(){return[].concat(e)}:s(e)?function(){return Object.assign({},e)}:e,this):(y(this._vueTypes_name+' - invalid default value: "'+e+'"'),this):this}}}),r=n.validator;return O(r)&&(n.validator=j(r,n)),n}function w(e,t){var n=T(e,t);return Object.defineProperty(n,"validate",{value:function(e){return O(this.validator)&&y(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=j(e,this),this}})}function k(e,t,n){var r,o,u=(r=t,o={},Object.getOwnPropertyNames(r).forEach(function(e){o[e]=Object.getOwnPropertyDescriptor(r,e)}),Object.defineProperties({},o));if(u._vueTypes_name=e,!s(n))return u;var a,f,c=n.validator,l=i(n,["validator"]);if(O(c)){var v=u.validator;v&&(v=null!==(f=(a=v).__original)&&void 0!==f?f:a),u.validator=j(v?function(e){return v.call(this,e)&&c.call(this,e)}:c,u)}return Object.assign(u,l)}function P(e){return e.replace(/^(?!\s*$)/gm," ")}var x=function(){return w("any",{})},A=function(){return w("function",{type:Function})},E=function(){return w("boolean",{type:Boolean})},N=function(){return w("string",{type:String})},q=function(){return w("number",{type:Number})},S=function(){return w("array",{type:Array})},V=function(){return w("object",{type:Object})},F=function(){return T("integer",{type:Number,validator:function(e){return h(e)}})},D=function(){return T("symbol",{validator:function(e){return"symbol"==typeof e}})};function L(e,t){if(void 0===t&&(t="custom validation failed"),"function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return T(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||y(this._vueTypes_name+" - "+t),r}})}function Y(e){if(!b(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");var t='oneOf - value should be one of "'+e.join('", "')+'".',n=e.reduce(function(e,t){if(null!=t){var n=t.constructor;-1===e.indexOf(n)&&e.push(n)}return e},[]);return T("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||y(t),r}})}function B(e){if(!b(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");for(var t=!1,n=[],r=0;r<e.length;r+=1){var i=e[r];if(m(i)){if(g(i)&&"oneOf"===i._vueTypes_name){n=n.concat(i.type);continue}if(O(i.validator)&&(t=!0),!0!==i.type&&i.type){n=n.concat(i.type);continue}}n.push(i)}return n=n.filter(function(e,t){return n.indexOf(e)===t}),T("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=_(g(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof r&&n.push(r),!0===r});return r||y("oneOfType - provided value does not match any of the "+n.length+" passed-in validators:\n"+P(n.join("\n"))),r}}:{type:n})}function I(e){return T("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=_(e,t,!0))});return r||y("arrayOf - value validation error:\n"+P(n)),r}})}function J(e){return T("instanceOf",{type:e})}function M(e){return T("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=_(e,t[r],!0))});return r||y("objectOf - value validation error:\n"+P(n)),r}})}function R(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!!(null===(n=e[t])||void 0===n?void 0:n.required)}),r=T("shape",{type:Object,validator:function(r){var i=this;if(!s(r))return!1;var o=Object.keys(r);if(n.length>0&&n.some(function(e){return-1===o.indexOf(e)})){var u=n.filter(function(e){return-1===o.indexOf(e)});return y(1===u.length?'shape - required property "'+u[0]+'" is not defined.':'shape - required properties "'+u.join('", "')+'" are not defined.'),!1}return o.every(function(n){if(-1===t.indexOf(n))return!0===i._vueTypes_isLoose||(y('shape - shape definition does not include a "'+n+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var o=_(e[n],r[n],!0);return"string"==typeof o&&y('shape - "'+n+'" property validation error:\n '+P(o)),!0===o})}});return Object.defineProperty(r,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(r,"loose",{get:function(){return this._vueTypes_isLoose=!0,this}}),r}var $=function(){function e(){}return e.extend=function(e){var t=this;if(b(e))return e.forEach(function(e){return t.extend(e)}),this;var n=e.name,r=e.validate,o=void 0!==r&&r,u=e.getter,a=void 0!==u&&u,f=i(e,["name","validate","getter"]);if(d(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return g(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return k(n,l,f)}}:{value:function(){var e,t=k(n,l,f);return t.validator&&(t.validator=(e=t.validator).bind.apply(e,[t].concat([].slice.call(arguments)))),t}})):(c=a?{get:function(){var e=Object.assign({},f);return o?w(n,e):T(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=o?w(n,r):T(n,r),r.validator&&(e.validator=(t=r.validator).bind.apply(t,[e].concat([].slice.call(arguments)))),e},enumerable:!0},Object.defineProperty(this,n,c))},t(e,null,[{key:"any",get:function(){return x()}},{key:"func",get:function(){return A().def(this.defaults.func)}},{key:"bool",get:function(){return E().def(this.defaults.bool)}},{key:"string",get:function(){return N().def(this.defaults.string)}},{key:"number",get:function(){return q().def(this.defaults.number)}},{key:"array",get:function(){return S().def(this.defaults.array)}},{key:"object",get:function(){return V().def(this.defaults.object)}},{key:"integer",get:function(){return F().def(this.defaults.integer)}},{key:"symbol",get:function(){return D()}}]),e}();function z(e){var i;return void 0===e&&(e={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(i=function(i){function o(){return i.apply(this,arguments)||this}return r(o,i),t(o,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(t){this.defaults=!1!==t?n({},!0!==t?t:e):{}}}]),o}($)).defaults=n({},e),i}$.defaults={},$.custom=L,$.oneOf=Y,$.instanceOf=J,$.oneOfType=B,$.arrayOf=I,$.objectOf=M,$.shape=R,$.utils={validate:function(e,t){return!0===_(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?w(e,t):T(e,t)}};var C=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t}(z());export default C;export{x as any,S as array,I as arrayOf,E as bool,z as createTypes,L as custom,k as fromType,A as func,J as instanceOf,F as integer,q as number,V as object,M as objectOf,Y as oneOf,B as oneOfType,R as shape,N as string,D as symbol,T as toType,w as toValidableType,_ as validateType}; | ||
function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function t(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function n(){return(n=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function r(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,i(e,t)}function i(e,t){return(i=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function o(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}function u(e){return"[object Object]"===Object.prototype.toString.call(e)}var a=Object.prototype,f=a.toString,c=a.hasOwnProperty,l=/^\s*function (\w+)/;function s(e){var t,n=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(n){var r=n.toString().match(l);return r?r[1]:""}return""}var v=function(e){var t,n;return!1!==u(e)&&(void 0===(t=e.constructor)||!1!==u(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},p=function(e){return e},y=p;if("production"!==process.env.NODE_ENV){var d="undefined"!=typeof console;y=d?function(e){console.warn("[VueTypes warn]: "+e)}:p}var h=function(e,t){return c.call(e,t)},b=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},O=Array.isArray||function(e){return"[object Array]"===f.call(e)},g=function(e){return"[object Function]"===f.call(e)},m=function(e){return v(e)&&h(e,"_vueTypes_name")},j=function(e){return v(e)&&(h(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return h(e,t)}))};function _(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function T(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=v(e)?e:{type:e};var u=m(r)?r._vueTypes_name+" - ":"";if(j(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;O(r.type)?(i=r.type.some(function(e){return!0===T(e,t,!0)}),o=r.type.map(function(e){return s(e)}).join(" or ")):i="Array"===(o=s(r))?O(t):"Object"===o?v(t):"String"===o||"Number"===o||"Boolean"===o||"Function"===o?function(e){if(null==e)return"";var t=e.constructor.toString().match(l);return t?t[1]:""}(t)===o:t instanceof r.type}if(!i){var a=u+'value "'+t+'" should be of type "'+o+'"';return!1===n?(y(a),!1):a}if(h(r,"validator")&&g(r.validator)){var f=y,c=[];if(y=function(e){c.push(e)},i=r.validator(t),y=f,!i){var p=(c.length>1?"* ":"")+c.join("\n* ");return c.length=0,!1===n?(y(p),i):p}}return i}function w(e,t){var n=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get:function(){return this.required=!0,this}},def:{value:function(e){return void 0===e?(h(this,"default")&&delete this.default,this):g(e)||!0===T(this,e,!0)?(this.default=O(e)?function(){return[].concat(e)}:v(e)?function(){return Object.assign({},e)}:e,this):(y(this._vueTypes_name+' - invalid default value: "'+e+'"'),this)}}}),r=n.validator;return g(r)&&(n.validator=_(r,n)),n}function k(e,t){var n=w(e,t);return Object.defineProperty(n,"validate",{value:function(e){return g(this.validator)&&y(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=_(e,this),this}})}function P(e,t,n){var r,i,u=(r=t,i={},Object.getOwnPropertyNames(r).forEach(function(e){i[e]=Object.getOwnPropertyDescriptor(r,e)}),Object.defineProperties({},i));if(u._vueTypes_name=e,!v(n))return u;var a,f,c=n.validator,l=o(n,["validator"]);if(g(c)){var s=u.validator;s&&(s=null!==(f=(a=s).__original)&&void 0!==f?f:a),u.validator=_(s?function(e){return s.call(this,e)&&c.call(this,e)}:c,u)}return Object.assign(u,l)}function x(e){return e.replace(/^(?!\s*$)/gm," ")}var E=function(){return k("any",{})},N=function(){return k("function",{type:Function})},q=function(){return k("boolean",{type:Boolean})},A=function(){return k("string",{type:String})},S=function(){return k("number",{type:Number})},V=function(){return k("array",{type:Array})},F=function(){return k("object",{type:Object})},D=function(){return w("integer",{type:Number,validator:function(e){return b(e)}})},L=function(){return w("symbol",{validator:function(e){return"symbol"==typeof e}})};function Y(e,t){if(void 0===t&&(t="custom validation failed"),"function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return w(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||y(this._vueTypes_name+" - "+t),r}})}function B(e){if(!O(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");var t='oneOf - value should be one of "'+e.join('", "')+'".',n=e.reduce(function(e,t){if(null!=t){var n=t.constructor;-1===e.indexOf(n)&&e.push(n)}return e},[]);return w("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||y(t),r}})}function I(e){if(!O(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");for(var t=!1,n=[],r=0;r<e.length;r+=1){var i=e[r];if(j(i)){if(m(i)&&"oneOf"===i._vueTypes_name&&i.type){n=n.concat(i.type);continue}if(g(i.validator)&&(t=!0),!0!==i.type&&i.type){n=n.concat(i.type);continue}}n.push(i)}return n=n.filter(function(e,t){return n.indexOf(e)===t}),w("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=T(m(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof r&&n.push(r),!0===r});return r||y("oneOfType - provided value does not match any of the "+n.length+" passed-in validators:\n"+x(n.join("\n"))),r}}:{type:n})}function J(e){return w("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=T(e,t,!0))});return r||y("arrayOf - value validation error:\n"+x(n)),r}})}function M(e){return w("instanceOf",{type:e})}function R(e){return w("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=T(e,t[r],!0))});return r||y("objectOf - value validation error:\n"+x(n)),r}})}function $(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!(null===(n=e[t])||void 0===n||!n.required)}),r=w("shape",{type:Object,validator:function(r){var i=this;if(!v(r))return!1;var o=Object.keys(r);if(n.length>0&&n.some(function(e){return-1===o.indexOf(e)})){var u=n.filter(function(e){return-1===o.indexOf(e)});return y(1===u.length?'shape - required property "'+u[0]+'" is not defined.':'shape - required properties "'+u.join('", "')+'" are not defined.'),!1}return o.every(function(n){if(-1===t.indexOf(n))return!0===i._vueTypes_isLoose||(y('shape - shape definition does not include a "'+n+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var o=T(e[n],r[n],!0);return"string"==typeof o&&y('shape - "'+n+'" property validation error:\n '+x(o)),!0===o})}});return Object.defineProperty(r,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(r,"loose",{get:function(){return this._vueTypes_isLoose=!0,this}}),r}var z=function(){function e(){}return e.extend=function(e){var t=this;if(O(e))return e.forEach(function(e){return t.extend(e)}),this;var n=e.name,r=e.validate,i=void 0!==r&&r,u=e.getter,a=void 0!==u&&u,f=o(e,["name","validate","getter"]);if(h(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return m(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return P(n,l,f)}}:{value:function(){var e,t=P(n,l,f);return t.validator&&(t.validator=(e=t.validator).bind.apply(e,[t].concat([].slice.call(arguments)))),t}})):(c=a?{get:function(){var e=Object.assign({},f);return i?k(n,e):w(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=i?k(n,r):w(n,r),r.validator&&(e.validator=(t=r.validator).bind.apply(t,[e].concat([].slice.call(arguments)))),e},enumerable:!0},Object.defineProperty(this,n,c))},t(e,null,[{key:"any",get:function(){return E()}},{key:"func",get:function(){return N().def(this.defaults.func)}},{key:"bool",get:function(){return q().def(this.defaults.bool)}},{key:"string",get:function(){return A().def(this.defaults.string)}},{key:"number",get:function(){return S().def(this.defaults.number)}},{key:"array",get:function(){return V().def(this.defaults.array)}},{key:"object",get:function(){return F().def(this.defaults.object)}},{key:"integer",get:function(){return D().def(this.defaults.integer)}},{key:"symbol",get:function(){return L()}}]),e}();function C(e){var i;return void 0===e&&(e={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(i=function(i){function o(){return i.apply(this,arguments)||this}return r(o,i),t(o,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(t){this.defaults=!1!==t?n({},!0!==t?t:e):{}}}]),o}(z)).defaults=n({},e),i}z.defaults={},z.custom=Y,z.oneOf=B,z.instanceOf=M,z.oneOfType=I,z.arrayOf=J,z.objectOf=R,z.shape=$,z.utils={validate:function(e,t){return!0===T(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?k(e,t):w(e,t)}};var G=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t}(C());export default G;export{E as any,V as array,J as arrayOf,q as bool,C as createTypes,Y as custom,P as fromType,N as func,M as instanceOf,D as integer,S as number,F as object,R as objectOf,B as oneOf,I as oneOfType,$ as shape,A as string,L as symbol,w as toType,k as toValidableType,T as validateType}; | ||
//# sourceMappingURL=vue-types.m.js.map |
@@ -1,2 +0,2 @@ | ||
function e(e){return 1==(null!=(t=e)&&"object"==typeof t&&!1===Array.isArray(t))&&"[object Object]"===Object.prototype.toString.call(e);var t}const t=Object.prototype,r=t.toString,n=t.hasOwnProperty,o=/^\s*function (\w+)/;function i(e){var t;const r=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(r){const e=r.toString().match(o);return e?e[1]:""}return""}const a=function(t){var r,n;return!1!==e(t)&&"function"==typeof(r=t.constructor)&&!1!==e(n=r.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")},s=e=>e;let u=s;if("production"!==process.env.NODE_ENV){const e="undefined"!=typeof console;u=e?function(e){console.warn("[VueTypes warn]: "+e)}:s}const c=(e,t)=>n.call(e,t),l=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},f=Array.isArray||function(e){return"[object Array]"===r.call(e)},d=e=>"[object Function]"===r.call(e),p=e=>a(e)&&c(e,"_vueTypes_name"),y=e=>a(e)&&(c(e,"type")||["_vueTypes_name","validator","default","required"].some(t=>c(e,t)));function v(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function h(e,t,r=!1){let n,s=!0,l="";n=a(e)?e:{type:e};const v=p(n)?n._vueTypes_name+" - ":"";if(y(n)&&null!==n.type){if(void 0===n.type||!0===n.type)return s;if(!n.required&&void 0===t)return s;f(n.type)?(s=n.type.some(e=>!0===h(e,t,!0)),l=n.type.map(e=>i(e)).join(" or ")):(l=i(n),s="Array"===l?f(t):"Object"===l?a(t):"String"===l||"Number"===l||"Boolean"===l||"Function"===l?function(e){if(null==e)return"";const t=e.constructor.toString().match(o);return t?t[1]:""}(t)===l:t instanceof n.type)}if(!s){const e=`${v}value "${t}" should be of type "${l}"`;return!1===r?(u(e),!1):e}if(c(n,"validator")&&d(n.validator)){const e=u,o=[];if(u=e=>{o.push(e)},s=n.validator(t),u=e,!s){const e=(o.length>1?"* ":"")+o.join("\n* ");return o.length=0,!1===r?(u(e),s):e}}return s}function b(e,t){const r=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get(){return this.required=!0,this}},def:{value(e){return void 0!==e||this.default?d(e)||!0===h(this,e,!0)?(this.default=f(e)?()=>[...e]:a(e)?()=>Object.assign({},e):e,this):(u(`${this._vueTypes_name} - invalid default value: "${e}"`),this):this}}}),{validator:n}=r;return d(n)&&(r.validator=v(n,r)),r}function g(e,t){const r=b(e,t);return Object.defineProperty(r,"validate",{value(e){return d(this.validator)&&u(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:\n${JSON.stringify(this)}`),this.validator=v(e,this),this}})}function O(e,t,r){const n=function(e){const t={};return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=Object.getOwnPropertyDescriptor(e,r)}),Object.defineProperties({},t)}(t);if(n._vueTypes_name=e,!a(r))return n;const{validator:o,...i}=r;if(d(o)){let{validator:e}=n;e&&(e=null!==(u=(s=e).__original)&&void 0!==u?u:s),n.validator=v(e?function(t){return e.call(this,t)&&o.call(this,t)}:o,n)}var s,u;return Object.assign(n,i)}function m(e){return e.replace(/^(?!\s*$)/gm," ")}const j=()=>g("any",{}),_=()=>g("function",{type:Function}),T=()=>g("boolean",{type:Boolean}),w=()=>g("string",{type:String}),$=()=>g("number",{type:Number}),P=()=>g("array",{type:Array}),x=()=>g("object",{type:Object}),A=()=>b("integer",{type:Number,validator:e=>l(e)}),E=()=>b("symbol",{validator:e=>"symbol"==typeof e});function N(e,t="custom validation failed"){if("function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return b(e.name||"<<anonymous function>>",{validator(r){const n=e(r);return n||u(`${this._vueTypes_name} - ${t}`),n}})}function q(e){if(!f(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");const t=`oneOf - value should be one of "${e.join('", "')}".`,r=e.reduce((e,t)=>{if(null!=t){const r=t.constructor;-1===e.indexOf(r)&&e.push(r)}return e},[]);return b("oneOf",{type:r.length>0?r:void 0,validator(r){const n=-1!==e.indexOf(r);return n||u(t),n}})}function S(e){if(!f(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");let t=!1,r=[];for(let n=0;n<e.length;n+=1){const o=e[n];if(y(o)){if(p(o)&&"oneOf"===o._vueTypes_name){r=r.concat(o.type);continue}if(d(o.validator)&&(t=!0),!0!==o.type&&o.type){r=r.concat(o.type);continue}}r.push(o)}return r=r.filter((e,t)=>r.indexOf(e)===t),b("oneOfType",t?{type:r,validator(t){const r=[],n=e.some(e=>{const n=h(p(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof n&&r.push(n),!0===n});return n||u(`oneOfType - provided value does not match any of the ${r.length} passed-in validators:\n${m(r.join("\n"))}`),n}}:{type:r})}function V(e){return b("arrayOf",{type:Array,validator(t){let r;const n=t.every(t=>(r=h(e,t,!0),!0===r));return n||u("arrayOf - value validation error:\n"+m(r)),n}})}function k(e){return b("instanceOf",{type:e})}function D(e){return b("objectOf",{type:Object,validator(t){let r;const n=Object.keys(t).every(n=>(r=h(e,t[n],!0),!0===r));return n||u("objectOf - value validation error:\n"+m(r)),n}})}function F(e){const t=Object.keys(e),r=t.filter(t=>{var r;return!!(null===(r=e[t])||void 0===r?void 0:r.required)}),n=b("shape",{type:Object,validator(n){if(!a(n))return!1;const o=Object.keys(n);if(r.length>0&&r.some(e=>-1===o.indexOf(e))){const e=r.filter(e=>-1===o.indexOf(e));return u(1===e.length?`shape - required property "${e[0]}" is not defined.`:`shape - required properties "${e.join('", "')}" are not defined.`),!1}return o.every(r=>{if(-1===t.indexOf(r))return!0===this._vueTypes_isLoose||(u(`shape - shape definition does not include a "${r}" property. Allowed keys: "${t.join('", "')}".`),!1);const o=h(e[r],n[r],!0);return"string"==typeof o&&u(`shape - "${r}" property validation error:\n ${m(o)}`),!0===o})}});return Object.defineProperty(n,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(n,"loose",{get(){return this._vueTypes_isLoose=!0,this}}),n}class L{static get any(){return j()}static get func(){return _().def(this.defaults.func)}static get bool(){return T().def(this.defaults.bool)}static get string(){return w().def(this.defaults.string)}static get number(){return $().def(this.defaults.number)}static get array(){return P().def(this.defaults.array)}static get object(){return x().def(this.defaults.object)}static get integer(){return A().def(this.defaults.integer)}static get symbol(){return E()}static extend(e){if(f(e))return e.forEach(e=>this.extend(e)),this;const{name:t,validate:r=!1,getter:n=!1,...o}=e;if(c(this,t))throw new TypeError(`[VueTypes error]: Type "${t}" already defined`);const{type:i}=o;if(p(i))return delete o.type,Object.defineProperty(this,t,n?{get:()=>O(t,i,o)}:{value(...e){const r=O(t,i,o);return r.validator&&(r.validator=r.validator.bind(r,...e)),r}});let a;return a=n?{get(){const e=Object.assign({},o);return r?g(t,e):b(t,e)},enumerable:!0}:{value(...e){const n=Object.assign({},o);let i;return i=r?g(t,n):b(t,n),n.validator&&(i.validator=n.validator.bind(i,...e)),i},enumerable:!0},Object.defineProperty(this,t,a)}}function Y(e={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var t;return(t=class extends L{static get sensibleDefaults(){return{...this.defaults}}static set sensibleDefaults(t){this.defaults=!1!==t?!0!==t?{...t}:{...e}:{}}}).defaults={...e},t}L.defaults={},L.custom=N,L.oneOf=q,L.instanceOf=k,L.oneOfType=S,L.arrayOf=V,L.objectOf=D,L.shape=F,L.utils={validate:(e,t)=>!0===h(t,e,!0),toType:(e,t,r=!1)=>r?g(e,t):b(e,t)};class B extends(Y()){}export default B;export{j as any,P as array,V as arrayOf,T as bool,Y as createTypes,N as custom,O as fromType,_ as func,k as instanceOf,A as integer,$ as number,x as object,D as objectOf,q as oneOf,S as oneOfType,F as shape,w as string,E as symbol,b as toType,g as toValidableType,h as validateType}; | ||
function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function t(e,t){if(null==e)return{};var r,n,o={},i=Object.keys(e);for(n=0;n<i.length;n++)t.indexOf(r=i[n])>=0||(o[r]=e[r]);return o}function r(e){return"[object Object]"===Object.prototype.toString.call(e)}const n=Object.prototype,o=n.toString,i=n.hasOwnProperty,a=/^\s*function (\w+)/;function s(e){var t;const r=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(r){const e=r.toString().match(a);return e?e[1]:""}return""}const u=function(e){var t,n;return!1!==r(e)&&(void 0===(t=e.constructor)||!1!==r(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},c=e=>e;let l=c;if("production"!==process.env.NODE_ENV){const e="undefined"!=typeof console;l=e?function(e){console.warn(`[VueTypes warn]: ${e}`)}:c}const f=(e,t)=>i.call(e,t),d=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},p=Array.isArray||function(e){return"[object Array]"===o.call(e)},y=e=>"[object Function]"===o.call(e),v=e=>u(e)&&f(e,"_vueTypes_name"),h=e=>u(e)&&(f(e,"type")||["_vueTypes_name","validator","default","required"].some(t=>f(e,t)));function b(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function O(e,t,r=!1){let n,o=!0,i="";n=u(e)?e:{type:e};const c=v(n)?n._vueTypes_name+" - ":"";if(h(n)&&null!==n.type){if(void 0===n.type||!0===n.type)return o;if(!n.required&&void 0===t)return o;p(n.type)?(o=n.type.some(e=>!0===O(e,t,!0)),i=n.type.map(e=>s(e)).join(" or ")):(i=s(n),o="Array"===i?p(t):"Object"===i?u(t):"String"===i||"Number"===i||"Boolean"===i||"Function"===i?function(e){if(null==e)return"";const t=e.constructor.toString().match(a);return t?t[1]:""}(t)===i:t instanceof n.type)}if(!o){const e=`${c}value "${t}" should be of type "${i}"`;return!1===r?(l(e),!1):e}if(f(n,"validator")&&y(n.validator)){const e=l,i=[];if(l=e=>{i.push(e)},o=n.validator(t),l=e,!o){const e=(i.length>1?"* ":"")+i.join("\n* ");return i.length=0,!1===r?(l(e),o):e}}return o}function g(e,t){const r=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get(){return this.required=!0,this}},def:{value(e){return void 0===e?(f(this,"default")&&delete this.default,this):y(e)||!0===O(this,e,!0)?(this.default=p(e)?()=>[...e]:u(e)?()=>Object.assign({},e):e,this):(l(`${this._vueTypes_name} - invalid default value: "${e}"`),this)}}}),{validator:n}=r;return y(n)&&(r.validator=b(n,r)),r}function m(e,t){const r=g(e,t);return Object.defineProperty(r,"validate",{value(e){return y(this.validator)&&l(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:\n${JSON.stringify(this)}`),this.validator=b(e,this),this}})}function j(e,r,n){const o=function(e){const t={};return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=Object.getOwnPropertyDescriptor(e,r)}),Object.defineProperties({},t)}(r);if(o._vueTypes_name=e,!u(n))return o;const{validator:i}=n,a=t(n,["validator"]);if(y(i)){let{validator:e}=o;e&&(e=null!==(c=(s=e).__original)&&void 0!==c?c:s),o.validator=b(e?function(t){return e.call(this,t)&&i.call(this,t)}:i,o)}var s,c;return Object.assign(o,a)}function _(e){return e.replace(/^(?!\s*$)/gm," ")}const T=()=>m("any",{}),$=()=>m("function",{type:Function}),w=()=>m("boolean",{type:Boolean}),P=()=>m("string",{type:String}),x=()=>m("number",{type:Number}),E=()=>m("array",{type:Array}),N=()=>m("object",{type:Object}),q=()=>g("integer",{type:Number,validator:e=>d(e)}),A=()=>g("symbol",{validator:e=>"symbol"==typeof e});function S(e,t="custom validation failed"){if("function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return g(e.name||"<<anonymous function>>",{validator(r){const n=e(r);return n||l(`${this._vueTypes_name} - ${t}`),n}})}function V(e){if(!p(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");const t=`oneOf - value should be one of "${e.join('", "')}".`,r=e.reduce((e,t)=>{if(null!=t){const r=t.constructor;-1===e.indexOf(r)&&e.push(r)}return e},[]);return g("oneOf",{type:r.length>0?r:void 0,validator(r){const n=-1!==e.indexOf(r);return n||l(t),n}})}function k(e){if(!p(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");let t=!1,r=[];for(let n=0;n<e.length;n+=1){const o=e[n];if(h(o)){if(v(o)&&"oneOf"===o._vueTypes_name&&o.type){r=r.concat(o.type);continue}if(y(o.validator)&&(t=!0),!0!==o.type&&o.type){r=r.concat(o.type);continue}}r.push(o)}return r=r.filter((e,t)=>r.indexOf(e)===t),g("oneOfType",t?{type:r,validator(t){const r=[],n=e.some(e=>{const n=O(v(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof n&&r.push(n),!0===n});return n||l(`oneOfType - provided value does not match any of the ${r.length} passed-in validators:\n${_(r.join("\n"))}`),n}}:{type:r})}function D(e){return g("arrayOf",{type:Array,validator(t){let r;const n=t.every(t=>(r=O(e,t,!0),!0===r));return n||l(`arrayOf - value validation error:\n${_(r)}`),n}})}function F(e){return g("instanceOf",{type:e})}function L(e){return g("objectOf",{type:Object,validator(t){let r;const n=Object.keys(t).every(n=>(r=O(e,t[n],!0),!0===r));return n||l(`objectOf - value validation error:\n${_(r)}`),n}})}function Y(e){const t=Object.keys(e),r=t.filter(t=>{var r;return!(null===(r=e[t])||void 0===r||!r.required)}),n=g("shape",{type:Object,validator(n){if(!u(n))return!1;const o=Object.keys(n);if(r.length>0&&r.some(e=>-1===o.indexOf(e))){const e=r.filter(e=>-1===o.indexOf(e));return l(1===e.length?`shape - required property "${e[0]}" is not defined.`:`shape - required properties "${e.join('", "')}" are not defined.`),!1}return o.every(r=>{if(-1===t.indexOf(r))return!0===this._vueTypes_isLoose||(l(`shape - shape definition does not include a "${r}" property. Allowed keys: "${t.join('", "')}".`),!1);const o=O(e[r],n[r],!0);return"string"==typeof o&&l(`shape - "${r}" property validation error:\n ${_(o)}`),!0===o})}});return Object.defineProperty(n,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(n,"loose",{get(){return this._vueTypes_isLoose=!0,this}}),n}class B{static get any(){return T()}static get func(){return $().def(this.defaults.func)}static get bool(){return w().def(this.defaults.bool)}static get string(){return P().def(this.defaults.string)}static get number(){return x().def(this.defaults.number)}static get array(){return E().def(this.defaults.array)}static get object(){return N().def(this.defaults.object)}static get integer(){return q().def(this.defaults.integer)}static get symbol(){return A()}static extend(e){if(p(e))return e.forEach(e=>this.extend(e)),this;const{name:r,validate:n=!1,getter:o=!1}=e,i=t(e,["name","validate","getter"]);if(f(this,r))throw new TypeError(`[VueTypes error]: Type "${r}" already defined`);const{type:a}=i;if(v(a))return delete i.type,Object.defineProperty(this,r,o?{get:()=>j(r,a,i)}:{value(...e){const t=j(r,a,i);return t.validator&&(t.validator=t.validator.bind(t,...e)),t}});let s;return s=o?{get(){const e=Object.assign({},i);return n?m(r,e):g(r,e)},enumerable:!0}:{value(...e){const t=Object.assign({},i);let o;return o=n?m(r,t):g(r,t),t.validator&&(o.validator=t.validator.bind(o,...e)),o},enumerable:!0},Object.defineProperty(this,r,s)}}function I(t={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var r;return(r=class extends B{static get sensibleDefaults(){return e({},this.defaults)}static set sensibleDefaults(r){this.defaults=!1!==r?e({},!0!==r?r:t):{}}}).defaults=e({},t),r}B.defaults={},B.custom=S,B.oneOf=V,B.instanceOf=F,B.oneOfType=k,B.arrayOf=D,B.objectOf=L,B.shape=Y,B.utils={validate:(e,t)=>!0===O(t,e,!0),toType:(e,t,r=!1)=>r?m(e,t):g(e,t)};class J extends(I()){}export default J;export{T as any,E as array,D as arrayOf,w as bool,I as createTypes,S as custom,j as fromType,$ as func,F as instanceOf,q as integer,x as number,N as object,L as objectOf,V as oneOf,k as oneOfType,Y as shape,P as string,A as symbol,g as toType,m as toValidableType,O as validateType}; | ||
//# sourceMappingURL=vue-types.modern.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).VueTypes={})}(this,function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function o(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}function u(e){return 1==(null!=(t=e)&&"object"==typeof t&&!1===Array.isArray(t))&&"[object Object]"===Object.prototype.toString.call(e);var t}var a=Object.prototype,f=a.toString,c=a.hasOwnProperty,l=/^\s*function (\w+)/;function s(e){var t,n=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(n){var r=n.toString().match(l);return r?r[1]:""}return""}var y=function(e){var t,n;return!1!==u(e)&&"function"==typeof(t=e.constructor)&&!1!==u(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf")},p=function(e){return e},v=function(e,t){return c.call(e,t)},d=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},h=Array.isArray||function(e){return"[object Array]"===f.call(e)},b=function(e){return"[object Function]"===f.call(e)},O=function(e){return y(e)&&v(e,"_vueTypes_name")},g=function(e){return y(e)&&(v(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return v(e,t)}))};function m(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function j(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=y(e)?e:{type:e};var u=O(r)?r._vueTypes_name+" - ":"";if(g(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;h(r.type)?(i=r.type.some(function(e){return!0===j(e,t,!0)}),o=r.type.map(function(e){return s(e)}).join(" or ")):i="Array"===(o=s(r))?h(t):"Object"===o?y(t):"String"===o||"Number"===o||"Boolean"===o||"Function"===o?function(e){if(null==e)return"";var t=e.constructor.toString().match(l);return t?t[1]:""}(t)===o:t instanceof r.type}if(!i){var a=u+'value "'+t+'" should be of type "'+o+'"';return!1===n?(p(a),!1):a}if(v(r,"validator")&&b(r.validator)){var f=p,c=[];if(p=function(e){c.push(e)},i=r.validator(t),p=f,!i){var d=(c.length>1?"* ":"")+c.join("\n* ");return c.length=0,!1===n?(p(d),i):d}}return i}function _(e,t){var n=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get:function(){return this.required=!0,this}},def:{value:function(e){return void 0!==e||this.default?b(e)||!0===j(this,e,!0)?(this.default=h(e)?function(){return[].concat(e)}:y(e)?function(){return Object.assign({},e)}:e,this):(p(this._vueTypes_name+' - invalid default value: "'+e+'"'),this):this}}}),r=n.validator;return b(r)&&(n.validator=m(r,n)),n}function T(e,t){var n=_(e,t);return Object.defineProperty(n,"validate",{value:function(e){return b(this.validator)&&p(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=m(e,this),this}})}function w(e,t,n){var r,i,u=(r=t,i={},Object.getOwnPropertyNames(r).forEach(function(e){i[e]=Object.getOwnPropertyDescriptor(r,e)}),Object.defineProperties({},i));if(u._vueTypes_name=e,!y(n))return u;var a,f,c=n.validator,l=o(n,["validator"]);if(b(c)){var s=u.validator;s&&(s=null!==(f=(a=s).__original)&&void 0!==f?f:a),u.validator=m(s?function(e){return s.call(this,e)&&c.call(this,e)}:c,u)}return Object.assign(u,l)}function k(e){return e.replace(/^(?!\s*$)/gm," ")}var P=function(){return T("any",{})},x=function(){return T("function",{type:Function})},A=function(){return T("boolean",{type:Boolean})},q=function(){return T("string",{type:String})},S=function(){return T("number",{type:Number})},V=function(){return T("array",{type:Array})},E=function(){return T("object",{type:Object})},N=function(){return _("integer",{type:Number,validator:function(e){return d(e)}})},F=function(){return _("symbol",{validator:function(e){return"symbol"==typeof e}})};function L(e,t){if(void 0===t&&(t="custom validation failed"),"function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return _(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||p(this._vueTypes_name+" - "+t),r}})}function Y(e){if(!h(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");var t='oneOf - value should be one of "'+e.join('", "')+'".',n=e.reduce(function(e,t){if(null!=t){var n=t.constructor;-1===e.indexOf(n)&&e.push(n)}return e},[]);return _("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||p(t),r}})}function B(e){if(!h(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");for(var t=!1,n=[],r=0;r<e.length;r+=1){var i=e[r];if(g(i)){if(O(i)&&"oneOf"===i._vueTypes_name){n=n.concat(i.type);continue}if(b(i.validator)&&(t=!0),!0!==i.type&&i.type){n=n.concat(i.type);continue}}n.push(i)}return n=n.filter(function(e,t){return n.indexOf(e)===t}),_("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=j(O(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof r&&n.push(r),!0===r});return r||p("oneOfType - provided value does not match any of the "+n.length+" passed-in validators:\n"+k(n.join("\n"))),r}}:{type:n})}function D(e){return _("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=j(e,t,!0))});return r||p("arrayOf - value validation error:\n"+k(n)),r}})}function I(e){return _("instanceOf",{type:e})}function J(e){return _("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=j(e,t[r],!0))});return r||p("objectOf - value validation error:\n"+k(n)),r}})}function M(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!!(null===(n=e[t])||void 0===n?void 0:n.required)}),r=_("shape",{type:Object,validator:function(r){var i=this;if(!y(r))return!1;var o=Object.keys(r);if(n.length>0&&n.some(function(e){return-1===o.indexOf(e)})){var u=n.filter(function(e){return-1===o.indexOf(e)});return p(1===u.length?'shape - required property "'+u[0]+'" is not defined.':'shape - required properties "'+u.join('", "')+'" are not defined.'),!1}return o.every(function(n){if(-1===t.indexOf(n))return!0===i._vueTypes_isLoose||(p('shape - shape definition does not include a "'+n+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var o=j(e[n],r[n],!0);return"string"==typeof o&&p('shape - "'+n+'" property validation error:\n '+k(o)),!0===o})}});return Object.defineProperty(r,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(r,"loose",{get:function(){return this._vueTypes_isLoose=!0,this}}),r}var R=function(){function e(){}return e.extend=function(e){var t=this;if(h(e))return e.forEach(function(e){return t.extend(e)}),this;var n=e.name,r=e.validate,i=void 0!==r&&r,u=e.getter,a=void 0!==u&&u,f=o(e,["name","validate","getter"]);if(v(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return O(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return w(n,l,f)}}:{value:function(){var e,t=w(n,l,f);return t.validator&&(t.validator=(e=t.validator).bind.apply(e,[t].concat([].slice.call(arguments)))),t}})):(c=a?{get:function(){var e=Object.assign({},f);return i?T(n,e):_(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=i?T(n,r):_(n,r),r.validator&&(e.validator=(t=r.validator).bind.apply(t,[e].concat([].slice.call(arguments)))),e},enumerable:!0},Object.defineProperty(this,n,c))},n(e,null,[{key:"any",get:function(){return P()}},{key:"func",get:function(){return x().def(this.defaults.func)}},{key:"bool",get:function(){return A().def(this.defaults.bool)}},{key:"string",get:function(){return q().def(this.defaults.string)}},{key:"number",get:function(){return S().def(this.defaults.number)}},{key:"array",get:function(){return V().def(this.defaults.array)}},{key:"object",get:function(){return E().def(this.defaults.object)}},{key:"integer",get:function(){return N().def(this.defaults.integer)}},{key:"symbol",get:function(){return F()}}]),e}();function $(e){var t;return void 0===e&&(e={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(t=function(t){function o(){return t.apply(this,arguments)||this}return i(o,t),n(o,null,[{key:"sensibleDefaults",get:function(){return r({},this.defaults)},set:function(t){this.defaults=!1!==t?r({},!0!==t?t:e):{}}}]),o}(R)).defaults=r({},e),t}R.defaults={},R.custom=L,R.oneOf=Y,R.instanceOf=I,R.oneOfType=B,R.arrayOf=D,R.objectOf=J,R.shape=M,R.utils={validate:function(e,t){return!0===j(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?T(e,t):_(e,t)}};var z=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t}($());e.any=P,e.array=V,e.arrayOf=D,e.bool=A,e.createTypes=$,e.custom=L,e.default=z,e.fromType=w,e.func=x,e.instanceOf=I,e.integer=N,e.number=S,e.object=E,e.objectOf=J,e.oneOf=Y,e.oneOfType=B,e.shape=M,e.string=q,e.symbol=F,e.toType=_,e.toValidableType=T,e.validateType=j}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).VueTypes={})}(this,function(e){function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function r(){return(r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function i(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,o(e,t)}function o(e,t){return(o=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function u(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}function a(e){return"[object Object]"===Object.prototype.toString.call(e)}var f=Object.prototype,c=f.toString,l=f.hasOwnProperty,s=/^\s*function (\w+)/;function y(e){var t,n=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(n){var r=n.toString().match(s);return r?r[1]:""}return""}var p=function(e){var t,n;return!1!==a(e)&&(void 0===(t=e.constructor)||!1!==a(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},d=function(e){return e},v=function(e,t){return l.call(e,t)},h=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},b=Array.isArray||function(e){return"[object Array]"===c.call(e)},O=function(e){return"[object Function]"===c.call(e)},g=function(e){return p(e)&&v(e,"_vueTypes_name")},m=function(e){return p(e)&&(v(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return v(e,t)}))};function j(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function T(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=p(e)?e:{type:e};var u=g(r)?r._vueTypes_name+" - ":"";if(m(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;b(r.type)?(i=r.type.some(function(e){return!0===T(e,t,!0)}),o=r.type.map(function(e){return y(e)}).join(" or ")):i="Array"===(o=y(r))?b(t):"Object"===o?p(t):"String"===o||"Number"===o||"Boolean"===o||"Function"===o?function(e){if(null==e)return"";var t=e.constructor.toString().match(s);return t?t[1]:""}(t)===o:t instanceof r.type}if(!i){var a=u+'value "'+t+'" should be of type "'+o+'"';return!1===n?(d(a),!1):a}if(v(r,"validator")&&O(r.validator)){var f=d,c=[];if(d=function(e){c.push(e)},i=r.validator(t),d=f,!i){var l=(c.length>1?"* ":"")+c.join("\n* ");return c.length=0,!1===n?(d(l),i):l}}return i}function _(e,t){var n=Object.defineProperties(t,{_vueTypes_name:{value:e,writable:!0},isRequired:{get:function(){return this.required=!0,this}},def:{value:function(e){return void 0===e?(v(this,"default")&&delete this.default,this):O(e)||!0===T(this,e,!0)?(this.default=b(e)?function(){return[].concat(e)}:p(e)?function(){return Object.assign({},e)}:e,this):(d(this._vueTypes_name+' - invalid default value: "'+e+'"'),this)}}}),r=n.validator;return O(r)&&(n.validator=j(r,n)),n}function w(e,t){var n=_(e,t);return Object.defineProperty(n,"validate",{value:function(e){return O(this.validator)&&d(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=j(e,this),this}})}function k(e,t,n){var r,i,o=(r=t,i={},Object.getOwnPropertyNames(r).forEach(function(e){i[e]=Object.getOwnPropertyDescriptor(r,e)}),Object.defineProperties({},i));if(o._vueTypes_name=e,!p(n))return o;var a,f,c=n.validator,l=u(n,["validator"]);if(O(c)){var s=o.validator;s&&(s=null!==(f=(a=s).__original)&&void 0!==f?f:a),o.validator=j(s?function(e){return s.call(this,e)&&c.call(this,e)}:c,o)}return Object.assign(o,l)}function P(e){return e.replace(/^(?!\s*$)/gm," ")}var x=function(){return w("any",{})},q=function(){return w("function",{type:Function})},A=function(){return w("boolean",{type:Boolean})},S=function(){return w("string",{type:String})},V=function(){return w("number",{type:Number})},E=function(){return w("array",{type:Array})},N=function(){return w("object",{type:Object})},F=function(){return _("integer",{type:Number,validator:function(e){return h(e)}})},L=function(){return _("symbol",{validator:function(e){return"symbol"==typeof e}})};function Y(e,t){if(void 0===t&&(t="custom validation failed"),"function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return _(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||d(this._vueTypes_name+" - "+t),r}})}function B(e){if(!b(e))throw new TypeError("[VueTypes error]: You must provide an array as argument.");var t='oneOf - value should be one of "'+e.join('", "')+'".',n=e.reduce(function(e,t){if(null!=t){var n=t.constructor;-1===e.indexOf(n)&&e.push(n)}return e},[]);return _("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||d(t),r}})}function D(e){if(!b(e))throw new TypeError("[VueTypes error]: You must provide an array as argument");for(var t=!1,n=[],r=0;r<e.length;r+=1){var i=e[r];if(m(i)){if(g(i)&&"oneOf"===i._vueTypes_name&&i.type){n=n.concat(i.type);continue}if(O(i.validator)&&(t=!0),!0!==i.type&&i.type){n=n.concat(i.type);continue}}n.push(i)}return n=n.filter(function(e,t){return n.indexOf(e)===t}),_("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=T(g(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof r&&n.push(r),!0===r});return r||d("oneOfType - provided value does not match any of the "+n.length+" passed-in validators:\n"+P(n.join("\n"))),r}}:{type:n})}function I(e){return _("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=T(e,t,!0))});return r||d("arrayOf - value validation error:\n"+P(n)),r}})}function J(e){return _("instanceOf",{type:e})}function M(e){return _("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=T(e,t[r],!0))});return r||d("objectOf - value validation error:\n"+P(n)),r}})}function R(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!(null===(n=e[t])||void 0===n||!n.required)}),r=_("shape",{type:Object,validator:function(r){var i=this;if(!p(r))return!1;var o=Object.keys(r);if(n.length>0&&n.some(function(e){return-1===o.indexOf(e)})){var u=n.filter(function(e){return-1===o.indexOf(e)});return d(1===u.length?'shape - required property "'+u[0]+'" is not defined.':'shape - required properties "'+u.join('", "')+'" are not defined.'),!1}return o.every(function(n){if(-1===t.indexOf(n))return!0===i._vueTypes_isLoose||(d('shape - shape definition does not include a "'+n+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var o=T(e[n],r[n],!0);return"string"==typeof o&&d('shape - "'+n+'" property validation error:\n '+P(o)),!0===o})}});return Object.defineProperty(r,"_vueTypes_isLoose",{writable:!0,value:!1}),Object.defineProperty(r,"loose",{get:function(){return this._vueTypes_isLoose=!0,this}}),r}var $=function(){function e(){}return e.extend=function(e){var t=this;if(b(e))return e.forEach(function(e){return t.extend(e)}),this;var n=e.name,r=e.validate,i=void 0!==r&&r,o=e.getter,a=void 0!==o&&o,f=u(e,["name","validate","getter"]);if(v(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return g(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return k(n,l,f)}}:{value:function(){var e,t=k(n,l,f);return t.validator&&(t.validator=(e=t.validator).bind.apply(e,[t].concat([].slice.call(arguments)))),t}})):(c=a?{get:function(){var e=Object.assign({},f);return i?w(n,e):_(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=i?w(n,r):_(n,r),r.validator&&(e.validator=(t=r.validator).bind.apply(t,[e].concat([].slice.call(arguments)))),e},enumerable:!0},Object.defineProperty(this,n,c))},n(e,null,[{key:"any",get:function(){return x()}},{key:"func",get:function(){return q().def(this.defaults.func)}},{key:"bool",get:function(){return A().def(this.defaults.bool)}},{key:"string",get:function(){return S().def(this.defaults.string)}},{key:"number",get:function(){return V().def(this.defaults.number)}},{key:"array",get:function(){return E().def(this.defaults.array)}},{key:"object",get:function(){return N().def(this.defaults.object)}},{key:"integer",get:function(){return F().def(this.defaults.integer)}},{key:"symbol",get:function(){return L()}}]),e}();function z(e){var t;return void 0===e&&(e={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(t=function(t){function o(){return t.apply(this,arguments)||this}return i(o,t),n(o,null,[{key:"sensibleDefaults",get:function(){return r({},this.defaults)},set:function(t){this.defaults=!1!==t?r({},!0!==t?t:e):{}}}]),o}($)).defaults=r({},e),t}$.defaults={},$.custom=Y,$.oneOf=B,$.instanceOf=J,$.oneOfType=D,$.arrayOf=I,$.objectOf=M,$.shape=R,$.utils={validate:function(e,t){return!0===T(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?w(e,t):_(e,t)}};var C=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t}(z());e.any=x,e.array=E,e.arrayOf=I,e.bool=A,e.createTypes=z,e.custom=Y,e.default=C,e.fromType=k,e.func=q,e.instanceOf=J,e.integer=F,e.number=V,e.object=N,e.objectOf=M,e.oneOf=B,e.oneOfType=D,e.shape=R,e.string=S,e.symbol=L,e.toType=_,e.toValidableType=w,e.validateType=T}); | ||
//# sourceMappingURL=vue-types.umd.js.map |
{ | ||
"name": "vue-types", | ||
"version": "3.0.2", | ||
"version": "4.0.0-rc.1", | ||
"description": "Prop types utility for Vue", | ||
@@ -53,42 +53,43 @@ "author": "Marco Solazzi", | ||
"peerDependencies": { | ||
"vue": "^3.0.0" | ||
"vue": "^2.0.0 | ^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.10.4", | ||
"@babel/plugin-proposal-optional-chaining": "7.10.4", | ||
"@types/jasmine": "3.5.11", | ||
"@types/node": "14.0.23", | ||
"@typescript-eslint/eslint-plugin": "3.6.1", | ||
"@typescript-eslint/parser": "3.6.1", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.13.8", | ||
"@babel/plugin-proposal-optional-chaining": "7.13.12", | ||
"@types/jasmine": "3.6.9", | ||
"@types/node": "14.14.37", | ||
"@typescript-eslint/eslint-plugin": "4.19.0", | ||
"@typescript-eslint/parser": "4.19.0", | ||
"babel-plugin-transform-node-env-inline": "0.4.3", | ||
"browser-sync": "2.26.12", | ||
"core-js": "3.6.5", | ||
"core-js-bundle": "3.6.5", | ||
"browser-sync": "2.26.14", | ||
"core-js": "3.9.1", | ||
"core-js-bundle": "3.9.1", | ||
"cpy-cli": "3.1.1", | ||
"cross-env": "7.0.2", | ||
"del": "5.1.0", | ||
"cross-env": "7.0.3", | ||
"del": "6.0.0", | ||
"del-cli": "3.0.1", | ||
"eslint": "7.4.0", | ||
"eslint-config-prettier": "6.11.0", | ||
"eslint": "7.23.0", | ||
"eslint-config-prettier": "8.1.0", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-prettier": "3.1.4", | ||
"eslint-plugin-vue": "6.2.2", | ||
"jasmine": "3.5.0", | ||
"karma": "5.1.0", | ||
"eslint-plugin-prettier": "3.3.1", | ||
"eslint-plugin-vue": "7.8.0", | ||
"jasmine": "3.7.0", | ||
"karma": "6.3.1", | ||
"karma-chrome-launcher": "3.1.0", | ||
"karma-jasmine": "3.3.1", | ||
"karma-sauce-launcher": "4.1.4", | ||
"karma-typescript": "5.0.3", | ||
"karma-typescript-es6-transform": "5.0.3", | ||
"microbundle": "0.12.3", | ||
"karma-jasmine": "4.0.1", | ||
"karma-sauce-launcher": "4.3.5", | ||
"karma-typescript": "5.5.1", | ||
"karma-typescript-es6-transform": "5.5.1", | ||
"microbundle": "0.13.0", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "2.0.5", | ||
"puppeteer": "5.1.0", | ||
"typescript": "3.9.6", | ||
"vue": "3.0.0-rc.7", | ||
"vue-class-component": "7.2.3", | ||
"vuepress": "1.5.2" | ||
"prettier": "2.2.1", | ||
"puppeteer": "8.0.0", | ||
"typescript": "4.2.3", | ||
"vue2": "npm:vue@2.6.12", | ||
"vue3": "npm:vue@3.0.11", | ||
"vue-class-component": "7.2.6", | ||
"vuepress": "1.8.2" | ||
}, | ||
"dependencies": { | ||
"is-plain-object": "3.0.1" | ||
"is-plain-object": "5.0.0" | ||
}, | ||
@@ -95,0 +96,0 @@ "browserslist": [ |
# vue-types | ||
> Prop type definitions for [Vue.js](http://vuejs.org). Compatible with both Vue 1.x and 2.x | ||
> Prop type definitions for [Vue.js](http://vuejs.org). | ||
@@ -45,2 +45,2 @@ <p id="badges"> | ||
Copyright (c) 2020 Marco Solazzi | ||
Copyright (c) 2021 Marco Solazzi |
@@ -8,3 +8,2 @@ { | ||
"plugin:@typescript-eslint/recommended", | ||
"prettier/@typescript-eslint", | ||
"plugin:prettier/recommended" | ||
@@ -11,0 +10,0 @@ ], |
@@ -1,2 +0,2 @@ | ||
import isPlainObject from 'is-plain-object' | ||
import { isPlainObject } from 'is-plain-object' | ||
import { typeDefaults } from './sensibles' | ||
@@ -3,0 +3,0 @@ import { VueTypesDefaults } from './types' |
@@ -1,12 +0,1 @@ | ||
import { PropType } from 'vue' | ||
export { PropType } | ||
export interface PropOptions<T = any, D = T> { | ||
type?: PropType<T> | true | null | ||
required?: boolean | ||
default?: D | ((props: Record<string, unknown>) => D) | null | undefined | ||
validator?(value: unknown): boolean | ||
} | ||
export type Prop<T = any> = | ||
@@ -35,2 +24,18 @@ | { | ||
export type PropType<T> = Prop<T> | Prop<T>[] | ||
export interface PropOptions<T = any, D = T> { | ||
type?: PropType<T> | true | null | ||
required?: boolean | ||
default?: | ||
| D | ||
| null | ||
| undefined | ||
| (() => D | null | undefined) | ||
| ((props: Record<string, unknown>) => D) | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
| object | ||
validator?(value: T): boolean | ||
} | ||
// see https://github.com/vuejs/vue-next/blob/22717772dd83b67ffaa6ad9805c6269e184c7e41/packages/runtime-core/src/componentProps.ts#L67 | ||
@@ -63,2 +68,3 @@ export type InferType<T> = T extends { type: null | true } | ||
_vueTypes_name: string | ||
type?: PropType<T> | null | ||
readonly def: ( | ||
@@ -65,0 +71,0 @@ def?: D, |
@@ -1,2 +0,2 @@ | ||
import _isPlainObject from 'is-plain-object' | ||
import { isPlainObject as _isPlainObject } from 'is-plain-object' | ||
import { | ||
@@ -273,3 +273,6 @@ VueTypeDef, | ||
value(def?: any) { | ||
if (def === undefined && !this.default) { | ||
if (def === undefined) { | ||
if (has(this, 'default')) { | ||
delete this.default | ||
} | ||
return this | ||
@@ -276,0 +279,0 @@ } |
@@ -30,3 +30,7 @@ import { Prop, VueProp, InferType, PropType } from '../types' | ||
if (isComplexType<V>(type)) { | ||
if (isVueTypeDef<V>(type) && type._vueTypes_name === 'oneOf') { | ||
if ( | ||
isVueTypeDef<V>(type) && | ||
type._vueTypes_name === 'oneOf' && | ||
type.type | ||
) { | ||
nativeChecks = nativeChecks.concat(type.type as PropType<V>) | ||
@@ -33,0 +37,0 @@ continue |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1815
295720
35
1
+ Addedis-plain-object@5.0.0(transitive)
- Removed@babel/helper-string-parser@7.25.9(transitive)
- Removed@babel/helper-validator-identifier@7.25.9(transitive)
- Removed@babel/parser@7.26.7(transitive)
- Removed@babel/types@7.26.7(transitive)
- Removed@jridgewell/sourcemap-codec@1.5.0(transitive)
- Removed@vue/compiler-core@3.5.13(transitive)
- Removed@vue/compiler-dom@3.5.13(transitive)
- Removed@vue/compiler-sfc@3.5.13(transitive)
- Removed@vue/compiler-ssr@3.5.13(transitive)
- Removed@vue/reactivity@3.5.13(transitive)
- Removed@vue/runtime-core@3.5.13(transitive)
- Removed@vue/runtime-dom@3.5.13(transitive)
- Removed@vue/server-renderer@3.5.13(transitive)
- Removed@vue/shared@3.5.13(transitive)
- Removedcsstype@3.1.3(transitive)
- Removedentities@4.5.0(transitive)
- Removedestree-walker@2.0.2(transitive)
- Removedis-plain-object@3.0.1(transitive)
- Removedmagic-string@0.30.17(transitive)
- Removednanoid@3.3.8(transitive)
- Removedpicocolors@1.1.1(transitive)
- Removedpostcss@8.5.1(transitive)
- Removedsource-map-js@1.2.1(transitive)
- Removedvue@3.5.13(transitive)
Updatedis-plain-object@5.0.0