Comparing version 4.0.0-rc.2 to 4.0.0-rc.3
@@ -12,2 +12,3 @@ import { toType, toValidableType, validateType, fromType } from './utils'; | ||
import shape from './validators/shape'; | ||
import { config } from './config'; | ||
declare function createTypes(defs?: Partial<VueTypesDefaults>): { | ||
@@ -107,6 +108,6 @@ new (): {}; | ||
}; | ||
export default class VueTypes extends VueTypes_base { | ||
export default class VueTypes/*#__PURE__*/ extends VueTypes_base { | ||
} | ||
export { any, func, bool, string, number, array, integer, symbol, object, custom, oneOf, oneOfType, arrayOf, instanceOf, objectOf, shape, createTypes, toType, toValidableType, validateType, fromType, }; | ||
export { any, func, bool, string, number, array, integer, symbol, object, custom, oneOf, oneOfType, arrayOf, instanceOf, objectOf, shape, createTypes, toType, toValidableType, validateType, fromType, config, }; | ||
export declare type VueTypesInterface = ReturnType<typeof createTypes>; | ||
export { VueTypeDef, VueTypeValidableDef, VueTypeShape, VueTypeLooseShape }; | ||
export type { VueTypeDef, VueTypeValidableDef, VueTypeShape, VueTypeLooseShape }; |
@@ -0,3 +1,5 @@ | ||
import { config } from './config'; | ||
import { VueTypesDefaults } from './types'; | ||
export { VueTypeDef, VueTypeValidableDef } from './types'; | ||
export { config }; | ||
export declare const any: () => any; | ||
@@ -97,3 +99,3 @@ export declare const func: <T = any>() => T; | ||
}; | ||
export default class VueTypes extends VueTypes_base { | ||
export default class VueTypes/*#__PURE__*/ extends VueTypes_base { | ||
} |
@@ -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,u(t,e)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t){return"[object Object]"===Object.prototype.toString.call(t)}function i(t){var e,n;return!1!==o(t)&&(void 0===(e=t.constructor)||!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var c={silent:!1},f=Object.defineProperty,a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e,n){void 0===e&&(e={}),void 0===n&&(n=!1);var r={_vueTypes_name:{value:t,writable:!0},def:{value:function(t){var e=this;return void 0!==t||e.default?(e.default=a(t)?function(){return[].concat(t)}:i(t)?function(){return Object.assign({},t)}:t,e):e}},isRequired:{get:function(){return this.required=!0,this}}};return n&&(r.validate={value:function(){}}),Object.assign(Object.defineProperties({validator:function(){return!0}},r),e)}var l=function(){return s("any",{},!0)},y=function(){return s("func",{type:Function},!0)},p=function(){return s("bool",{type:Boolean},!0)},d=function(){return s("string",{type:String},!0)},b=function(){return s("number",{type:Number},!0)},v=function(){return s("array",{type:Array},!0)},g=function(){return s("object",{type:Object},!0)},h=function(){return s("symbol")},O=function(){return s("integer",{type:Number})},j=function(t){return s("oneOf")},m=function(t){return s("custom")},k=function(t){return s("instanceOf",{type:t})},w=function(t){return s("oneOfType")},P=function(t){return s("arrayOf",{type:Array})},_=function(t){return s("objectOf",{type:Object})},T=function(t){return f(s("shape",{type:Object}),"loose",{get:function(){return this}})};function A(t,e,n,r,u){var o;void 0===r&&(r=!1),void 0===u&&(u=!1);var i=((o={})[r?"get":"value"]=function(){return s(e,n,u).def(r?t.defaults[e]:void 0)},o);return f(t,e,i)}var N=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,u=t.type,o=void 0===u?null:u;return A(this,t.name,{type:i(o)&&o.type?null:o},r,!!e)},e(t,null,[{key:"any",get:function(){return l()}},{key:"func",get:function(){return y().def(this.defaults.func)}},{key:"bool",get:function(){return p().def(this.defaults.bool)}},{key:"string",get:function(){return d().def(this.defaults.string)}},{key:"number",get:function(){return b().def(this.defaults.number)}},{key:"array",get:function(){return v().def(this.defaults.array)}},{key:"object",get:function(){return g().def(this.defaults.object)}},{key:"symbol",get:function(){return h()}},{key:"integer",get:function(){return O().def(this.defaults.integer)}}]),t}();function x(t){var u;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(u=function(u){function o(){return u.apply(this,arguments)||this}return r(o,u),e(o,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(e){this.defaults=!1!==e?n({},!0!==e?e:t):{}}}]),o}(N)).defaults=n({},t),u}N.defaults={},N.config=c,N.oneOf=j,N.custom=m,N.instanceOf=k,N.oneOfType=w,N.arrayOf=P,N.objectOf=_,N.shape=T,N.utils={toType:s,validate:function(){return!![].slice.call(arguments)}},"production"!==process.env.NODE_ENV&&!1===c.silent&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://github.com/dwightjack/vue-types#production-build to learn how to configure VueTypes for usage in multiple environments.");var S=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(x());export default S;export{l as any,v as array,P as arrayOf,p as bool,x as createTypes,m as custom,y as func,k as instanceOf,O as integer,b as number,g as object,_ as objectOf,j as oneOf,w as oneOfType,T as shape,d as string,h as symbol}; | ||
function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function e(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}function n(){return(n=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function r(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,u(t,e)}function u(t,e){return(u=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function o(t){return"[object Object]"===Object.prototype.toString.call(t)}function i(t){var e,n;return!1!==o(t)&&(void 0===(e=t.constructor)||!1!==o(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var c={silent:!1},f=Object.defineProperty,a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function s(t,e,n){void 0===e&&(e={}),void 0===n&&(n=!1);var r={_vueTypes_name:{value:t,writable:!0},def:{value:function(t){var e=this;return void 0!==t||e.default?(e.default=a(t)?function(){return[].concat(t)}:i(t)?function(){return Object.assign({},t)}:t,e):e}},isRequired:{get:function(){return this.required=!0,this}}};return n&&(r.validate={value:function(){}}),Object.assign(Object.defineProperties({validator:function(){return!0}},r),e)}var l=function(){return s("any",{},!0)},y=function(){return s("func",{type:Function},!0)},p=function(){return s("bool",{type:Boolean},!0)},d=function(){return s("string",{type:String},!0)},b=function(){return s("number",{type:Number},!0)},v=function(){return s("array",{type:Array},!0)},g=function(){return s("object",{type:Object},!0)},h=function(){return s("symbol")},O=function(){return s("integer",{type:Number})},j=function(t){return s("oneOf")},m=function(t){return s("custom")},k=function(t){return s("instanceOf",{type:t})},w=function(t){return s("oneOfType")},P=function(t){return s("arrayOf",{type:Array})},_=function(t){return s("objectOf",{type:Object})},T=function(t){return f(s("shape",{type:Object}),"loose",{get:function(){return this}})};function A(t,e,n,r,u){var o;void 0===r&&(r=!1),void 0===u&&(u=!1);var i=((o={})[r?"get":"value"]=function(){return s(e,n,u).def(r?t.defaults[e]:void 0)},o);return f(t,e,i)}var N=function(){var t;return(t=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,u=t.type,o=void 0===u?null:u;return A(this,t.name,{type:i(o)&&o.type?null:o},r,!!e)},e(t,null,[{key:"any",get:function(){return l()}},{key:"func",get:function(){return y().def(this.defaults.func)}},{key:"bool",get:function(){return p().def(this.defaults.bool)}},{key:"string",get:function(){return d().def(this.defaults.string)}},{key:"number",get:function(){return b().def(this.defaults.number)}},{key:"array",get:function(){return v().def(this.defaults.array)}},{key:"object",get:function(){return g().def(this.defaults.object)}},{key:"symbol",get:function(){return h()}},{key:"integer",get:function(){return O().def(this.defaults.integer)}}]),t}()).defaults={},t.config=c,t.oneOf=j,t.custom=m,t.instanceOf=k,t.oneOfType=w,t.arrayOf=P,t.objectOf=_,t.shape=T,t.utils={toType:s,validate:function(){return!![].slice.call(arguments)}},t}();function x(t){var u;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(u=function(u){function o(){return u.apply(this,arguments)||this}return r(o,u),e(o,null,[{key:"sensibleDefaults",get:function(){return n({},this.defaults)},set:function(e){this.defaults=!1!==e?n({},!0!==e?e:t):{}}}]),o}(N)).defaults=n({},t),u}"production"!==process.env.NODE_ENV&&!1===c.silent&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://dwightjack.github.io/vue-types/guide/installation.html#production-build to learn how to configure VueTypes for usage in multiple environments.");var S=function(t){function e(){return t.apply(this,arguments)||this}return r(e,t),e}(x());export default S;export{l as any,v as array,P as arrayOf,p as bool,c as config,x as createTypes,m as custom,y as func,k as instanceOf,O as integer,b as number,g as object,_ as objectOf,j as oneOf,w as oneOfType,T as shape,d as string,h as symbol}; | ||
//# sourceMappingURL=shim.m.js.map |
@@ -1,2 +0,2 @@ | ||
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={silent:!1},s=Object.defineProperty,a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function o(t,e={},n=!1){const s={_vueTypes_name:{value:t,writable:!0},def:{value(t){const e=this;return void 0!==t||e.default?(e.default=a(t)?()=>[].concat(t):r(t)?()=>Object.assign({},t):t,e):e}},isRequired:{get(){return this.required=!0,this}}};return n&&(s.validate={value(){}}),Object.assign(Object.defineProperties({validator:()=>!0},s),e)}const i=()=>o("any",{},!0),u=()=>o("func",{type:Function},!0),c=()=>o("bool",{type:Boolean},!0),l=()=>o("string",{type:String},!0),f=()=>o("number",{type:Number},!0),p=()=>o("array",{type:Array},!0),d=()=>o("object",{type:Object},!0),y=()=>o("symbol"),b=()=>o("integer",{type:Number}),g=t=>o("oneOf"),h=t=>o("custom"),O=t=>o("instanceOf",{type:t}),v=t=>o("oneOfType"),j=t=>o("arrayOf",{type:Array}),m=t=>o("objectOf",{type:Object}),w=t=>s(o("shape",{type:Object}),"loose",{get(){return this}});function T(t,e,r,n=!1,a=!1){return s(t,e,{[n?"get":"value"]:()=>o(e,r,a).def(n?t.defaults[e]:void 0)})}class x{static get any(){return i()}static get func(){return u().def(this.defaults.func)}static get bool(){return c().def(this.defaults.bool)}static get string(){return l().def(this.defaults.string)}static get number(){return f().def(this.defaults.number)}static get array(){return p().def(this.defaults.array)}static get object(){return d().def(this.defaults.object)}static get symbol(){return y()}static get integer(){return b().def(this.defaults.integer)}static extend(t){const{name:e,validate:n,getter:s=!1,type:a=null}=t;return T(this,e,{type:r(a)&&a.type?null:a},s,!!n)}}function A(e={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var r;return(r=class extends x{static get sensibleDefaults(){return t({},this.defaults)}static set sensibleDefaults(r){this.defaults=!1!==r?t({},!0!==r?r:e):{}}}).defaults=t({},e),r}x.defaults={},x.config=n,x.oneOf=g,x.custom=h,x.instanceOf=O,x.oneOfType=v,x.arrayOf=j,x.objectOf=m,x.shape=w,x.utils={toType:o,validate:(...t)=>!!t},"production"!==process.env.NODE_ENV&&!1===n.silent&&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 P extends(A()){}export default P;export{i as any,p as array,j as arrayOf,c as bool,A as createTypes,h as custom,u as func,O as instanceOf,b as integer,f as number,d as object,m as objectOf,g as oneOf,v as oneOfType,w as shape,l 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={silent:!1},s=Object.defineProperty,a=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function i(t,e={},n=!1){const s={_vueTypes_name:{value:t,writable:!0},def:{value(t){const e=this;return void 0!==t||e.default?(e.default=a(t)?()=>[].concat(t):r(t)?()=>Object.assign({},t):t,e):e}},isRequired:{get(){return this.required=!0,this}}};return n&&(s.validate={value(){}}),Object.assign(Object.defineProperties({validator:()=>!0},s),e)}const o=()=>i("any",{},!0),u=()=>i("func",{type:Function},!0),c=()=>i("bool",{type:Boolean},!0),l=()=>i("string",{type:String},!0),f=()=>i("number",{type:Number},!0),d=()=>i("array",{type:Array},!0),p=()=>i("object",{type:Object},!0),y=()=>i("symbol"),b=()=>i("integer",{type:Number}),g=t=>i("oneOf"),h=t=>i("custom"),O=t=>i("instanceOf",{type:t}),v=t=>i("oneOfType"),j=t=>i("arrayOf",{type:Array}),m=t=>i("objectOf",{type:Object}),w=t=>s(i("shape",{type:Object}),"loose",{get(){return this}});function T(t,e,r,n=!1,a=!1){return s(t,e,{[n?"get":"value"]:()=>i(e,r,a).def(n?t.defaults[e]:void 0)})}const x=(()=>{var t;return(t=class{static get any(){return o()}static get func(){return u().def(this.defaults.func)}static get bool(){return c().def(this.defaults.bool)}static get string(){return l().def(this.defaults.string)}static get number(){return f().def(this.defaults.number)}static get array(){return d().def(this.defaults.array)}static get object(){return p().def(this.defaults.object)}static get symbol(){return y()}static get integer(){return b().def(this.defaults.integer)}static extend(t){const{name:e,validate:n,getter:s=!1,type:a=null}=t;return T(this,e,{type:r(a)&&a.type?null:a},s,!!n)}}).defaults={},t.config=n,t.oneOf=g,t.custom=h,t.instanceOf=O,t.oneOfType=v,t.arrayOf=j,t.objectOf=m,t.shape=w,t.utils={toType:i,validate:(...t)=>!!t},t})();function A(e={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var r;return(r=class extends x{static get sensibleDefaults(){return t({},this.defaults)}static set sensibleDefaults(r){this.defaults=!1!==r?t({},!0!==r?r:e):{}}}).defaults=t({},e),r}"production"!==process.env.NODE_ENV&&!1===n.silent&&console.warn("You are using the production shimmed version of VueTypes in a development build. Refer to https://dwightjack.github.io/vue-types/guide/installation.html#production-build to learn how to configure VueTypes for usage in multiple environments.");class P extends(A()){}export default P;export{o as any,d as array,j as arrayOf,c as bool,n as config,A as createTypes,h as custom,u as func,O as instanceOf,b as integer,f as number,p as object,m as objectOf,g as oneOf,v as oneOfType,w as shape,l as string,y 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||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)},g=function(){return s("array",{type:Array},!0)},v=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 g().def(this.defaults.array)}},{key:"object",get:function(){return v().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.config={silent:!1},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=g,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=v,t.objectOf=_,t.oneOf=j,t.oneOfType=T,t.shape=A,t.string=d,t.symbol=O}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t||self).VueTypes={})}(this,function(t){function e(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}function r(){return(r=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t}).apply(this,arguments)}function u(t,e){t.prototype=Object.create(e.prototype),t.prototype.constructor=t,o(t,e)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(t){return"[object Object]"===Object.prototype.toString.call(t)}function f(t){var e,n;return!1!==i(t)&&(void 0===(e=t.constructor)||!1!==i(n=e.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))}var c={silent:!1},a=Object.defineProperty,s=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)};function y(t,e,n){void 0===e&&(e={}),void 0===n&&(n=!1);var r={_vueTypes_name:{value:t,writable:!0},def:{value:function(t){var e=this;return void 0!==t||e.default?(e.default=s(t)?function(){return[].concat(t)}:f(t)?function(){return Object.assign({},t)}:t,e):e}},isRequired:{get:function(){return this.required=!0,this}}};return n&&(r.validate={value:function(){}}),Object.assign(Object.defineProperties({validator:function(){return!0}},r),e)}var l=function(){return y("any",{},!0)},p=function(){return y("func",{type:Function},!0)},d=function(){return y("bool",{type:Boolean},!0)},b=function(){return y("string",{type:String},!0)},g=function(){return y("number",{type:Number},!0)},v=function(){return y("array",{type:Array},!0)},O=function(){return y("object",{type:Object},!0)},h=function(){return y("symbol")},j=function(){return y("integer",{type:Number})},m=function(t){return y("oneOf")},k=function(t){return y("custom")},T=function(t){return y("instanceOf",{type:t})},P=function(t){return y("oneOfType")},_=function(t){return y("arrayOf",{type:Array})},A=function(t){return y("objectOf",{type:Object})},w=function(t){return a(y("shape",{type:Object}),"loose",{get:function(){return this}})};function x(t,e,n,r,u){var o;void 0===r&&(r=!1),void 0===u&&(u=!1);var i=((o={})[r?"get":"value"]=function(){return y(e,n,u).def(r?t.defaults[e]:void 0)},o);return a(t,e,i)}var S=function(){var t;return(t=function(){function t(){}return t.extend=function(t){var e=t.validate,n=t.getter,r=void 0!==n&&n,u=t.type,o=void 0===u?null:u;return x(this,t.name,{type:f(o)&&o.type?null:o},r,!!e)},n(t,null,[{key:"any",get:function(){return l()}},{key:"func",get:function(){return p().def(this.defaults.func)}},{key:"bool",get:function(){return d().def(this.defaults.bool)}},{key:"string",get:function(){return b().def(this.defaults.string)}},{key:"number",get:function(){return g().def(this.defaults.number)}},{key:"array",get:function(){return v().def(this.defaults.array)}},{key:"object",get:function(){return O().def(this.defaults.object)}},{key:"symbol",get:function(){return h()}},{key:"integer",get:function(){return j().def(this.defaults.integer)}}]),t}()).defaults={},t.config=c,t.oneOf=m,t.custom=k,t.instanceOf=T,t.oneOfType=P,t.arrayOf=_,t.objectOf=A,t.shape=w,t.utils={toType:y,validate:function(){return!![].slice.call(arguments)}},t}();function q(t){var e;return void 0===t&&(t={func:function(){},bool:!0,string:"",number:0,array:function(){return[]},object:function(){return{}},integer:0}),(e=function(e){function o(){return e.apply(this,arguments)||this}return u(o,e),n(o,null,[{key:"sensibleDefaults",get:function(){return r({},this.defaults)},set:function(e){this.defaults=!1!==e?r({},!0!==e?e:t):{}}}]),o}(S)).defaults=r({},t),e}var N=function(t){function e(){return t.apply(this,arguments)||this}return u(e,t),e}(q());t.any=l,t.array=v,t.arrayOf=_,t.bool=d,t.config=c,t.createTypes=q,t.custom=k,t.default=N,t.func=p,t.instanceOf=T,t.integer=j,t.number=g,t.object=O,t.objectOf=A,t.oneOf=m,t.oneOfType=P,t.shape=w,t.string=b,t.symbol=h}); | ||
//# sourceMappingURL=shim.umd.js.map |
@@ -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,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={silent:!1},f=Object.prototype,c=f.toString,l=f.hasOwnProperty,s=/^\s*function (\w+)/;function v(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!==u(e)&&(void 0===(t=e.constructor)||!1!==u(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},y=function(e){return e},d=y;if("production"!==process.env.NODE_ENV){var h="undefined"!=typeof console;d=h?function(e){!1===a.silent&&console.warn("[VueTypes warn]: "+e)}:y}var b=function(e,t){return l.call(e,t)},O=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},g=Array.isArray||function(e){return"[object Array]"===c.call(e)},m=function(e){return"[object Function]"===c.call(e)},j=function(e){return p(e)&&b(e,"_vueTypes_name")},_=function(e){return p(e)&&(b(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return b(e,t)}))};function T(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function w(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=p(e)?e:{type:e};var u=j(r)?r._vueTypes_name+" - ":"";if(_(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;g(r.type)?(i=r.type.some(function(e){return!0===w(e,t,!0)}),o=r.type.map(function(e){return v(e)}).join(" or ")):i="Array"===(o=v(r))?g(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(b(r,"validator")&&m(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 k(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?(b(this,"default")&&delete this.default,this):m(e)||!0===w(this,e,!0)?(this.default=g(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 m(r)&&(n.validator=T(r,n)),n}function P(e,t){var n=k(e,t);return Object.defineProperty(n,"validate",{value:function(e){return m(this.validator)&&d(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=T(e,this),this}})}function x(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,!p(n))return u;var a,f,c=n.validator,l=o(n,["validator"]);if(m(c)){var s=u.validator;s&&(s=null!==(f=(a=s).__original)&&void 0!==f?f:a),u.validator=T(s?function(e){return s.call(this,e)&&c.call(this,e)}:c,u)}return Object.assign(u,l)}function E(e){return e.replace(/^(?!\s*$)/gm," ")}var N=function(){return P("any",{})},q=function(){return P("function",{type:Function})},A=function(){return P("boolean",{type:Boolean})},S=function(){return P("string",{type:String})},V=function(){return P("number",{type:Number})},F=function(){return P("array",{type:Array})},D=function(){return P("object",{type:Object})},L=function(){return k("integer",{type:Number,validator:function(e){return O(e)}})},Y=function(){return k("symbol",{validator:function(e){return"symbol"==typeof e}})};function B(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 k(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||d(this._vueTypes_name+" - "+t),r}})}function I(e){if(!g(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 k("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||d(t),r}})}function J(e){if(!g(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(_(i)){if(j(i)&&"oneOf"===i._vueTypes_name&&i.type){n=n.concat(i.type);continue}if(m(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}),k("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=w(j(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"+E(n.join("\n"))),r}}:{type:n})}function M(e){return k("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=w(e,t,!0))});return r||d("arrayOf - value validation error:\n"+E(n)),r}})}function R(e){return k("instanceOf",{type:e})}function $(e){return k("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=w(e,t[r],!0))});return r||d("objectOf - value validation error:\n"+E(n)),r}})}function z(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!(null===(n=e[t])||void 0===n||!n.required)}),r=k("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=w(e[n],r[n],!0);return"string"==typeof o&&d('shape - "'+n+'" property validation error:\n '+E(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 C=function(){function e(){}return e.extend=function(e){var t=this;if(g(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(b(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return j(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return x(n,l,f)}}:{value:function(){var e,t=x(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?P(n,e):k(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=i?P(n,r):k(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 N()}},{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 F().def(this.defaults.array)}},{key:"object",get:function(){return D().def(this.defaults.object)}},{key:"integer",get:function(){return L().def(this.defaults.integer)}},{key:"symbol",get:function(){return Y()}}]),e}();function G(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}(C)).defaults=n({},e),i}C.defaults={},C.config=a,C.custom=B,C.oneOf=I,C.instanceOf=R,C.oneOfType=J,C.arrayOf=M,C.objectOf=$,C.shape=z,C.utils={validate:function(e,t){return!0===w(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?P(e,t):k(e,t)}};var H=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t}(G());export default H;export{N as any,F as array,M as arrayOf,A as bool,G as createTypes,B as custom,x as fromType,q as func,R as instanceOf,L as integer,V as number,D as object,$ as objectOf,I as oneOf,J as oneOfType,z as shape,S as string,Y as symbol,k as toType,P as toValidableType,w 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={silent:!1},f=["validator"],c=Object.prototype,l=c.toString,s=c.hasOwnProperty,v=/^\s*function (\w+)/;function p(e){var t,n=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(n){var r=n.toString().match(v);return r?r[1]:""}return""}var y=function(e){var t,n;return!1!==u(e)&&(void 0===(t=e.constructor)||!1!==u(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},d=function(e){return e},h=d;if("production"!==process.env.NODE_ENV){var b="undefined"!=typeof console;h=b?function(e){!1===a.silent&&console.warn("[VueTypes warn]: "+e)}:d}var O=function(e,t){return s.call(e,t)},g=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},m=Array.isArray||function(e){return"[object Array]"===l.call(e)},j=function(e){return"[object Function]"===l.call(e)},_=function(e){return y(e)&&O(e,"_vueTypes_name")},T=function(e){return y(e)&&(O(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return O(e,t)}))};function w(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function k(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=y(e)?e:{type:e};var u=_(r)?r._vueTypes_name+" - ":"";if(T(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;m(r.type)?(i=r.type.some(function(e){return!0===k(e,t,!0)}),o=r.type.map(function(e){return p(e)}).join(" or ")):i="Array"===(o=p(r))?m(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(v);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?(h(a),!1):a}if(O(r,"validator")&&j(r.validator)){var f=h,c=[];if(h=function(e){c.push(e)},i=r.validator(t),h=f,!i){var l=(c.length>1?"* ":"")+c.join("\n* ");return c.length=0,!1===n?(h(l),i):l}}return i}function P(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?(O(this,"default")&&delete this.default,this):j(e)||!0===k(this,e,!0)?(this.default=m(e)?function(){return[].concat(e)}:y(e)?function(){return Object.assign({},e)}:e,this):(h(this._vueTypes_name+' - invalid default value: "'+e+'"'),this)}}}),r=n.validator;return j(r)&&(n.validator=w(r,n)),n}function x(e,t){var n=P(e,t);return Object.defineProperty(n,"validate",{value:function(e){return j(this.validator)&&h(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=w(e,this),this}})}function E(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,c,l=n.validator,s=o(n,f);if(j(l)){var v=u.validator;v&&(v=null!==(c=(a=v).__original)&&void 0!==c?c:a),u.validator=w(v?function(e){return v.call(this,e)&&l.call(this,e)}:l,u)}return Object.assign(u,s)}function N(e){return e.replace(/^(?!\s*$)/gm," ")}var q=function(){return x("any",{})},A=function(){return x("function",{type:Function})},S=function(){return x("boolean",{type:Boolean})},V=function(){return x("string",{type:String})},F=function(){return x("number",{type:Number})},D=function(){return x("array",{type:Array})},L=function(){return x("object",{type:Object})},Y=function(){return P("integer",{type:Number,validator:function(e){return g(e)}})},B=function(){return P("symbol",{validator:function(e){return"symbol"==typeof e}})};function I(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 P(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||h(this._vueTypes_name+" - "+t),r}})}function J(e){if(!m(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 P("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||h(t),r}})}function M(e){if(!m(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(T(i)){if(_(i)&&"oneOf"===i._vueTypes_name&&i.type){n=n.concat(i.type);continue}if(j(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}),P("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=k(_(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof r&&n.push(r),!0===r});return r||h("oneOfType - provided value does not match any of the "+n.length+" passed-in validators:\n"+N(n.join("\n"))),r}}:{type:n})}function R(e){return P("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=k(e,t,!0))});return r||h("arrayOf - value validation error:\n"+N(n)),r}})}function $(e){return P("instanceOf",{type:e})}function z(e){return P("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=k(e,t[r],!0))});return r||h("objectOf - value validation error:\n"+N(n)),r}})}function C(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!(null===(n=e[t])||void 0===n||!n.required)}),r=P("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 h(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||(h('shape - shape definition does not include a "'+n+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var o=k(e[n],r[n],!0);return"string"==typeof o&&h('shape - "'+n+'" property validation error:\n '+N(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 G=["name","validate","getter"],H=function(){var e;return(e=function(){function e(){}return e.extend=function(e){var t=this;if(m(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,G);if(O(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return _(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return E(n,l,f)}}:{value:function(){var e,t=E(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?x(n,e):P(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=i?x(n,r):P(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 q()}},{key:"func",get:function(){return A().def(this.defaults.func)}},{key:"bool",get:function(){return S().def(this.defaults.bool)}},{key:"string",get:function(){return V().def(this.defaults.string)}},{key:"number",get:function(){return F().def(this.defaults.number)}},{key:"array",get:function(){return D().def(this.defaults.array)}},{key:"object",get:function(){return L().def(this.defaults.object)}},{key:"integer",get:function(){return Y().def(this.defaults.integer)}},{key:"symbol",get:function(){return B()}}]),e}()).defaults={},e.config=a,e.custom=I,e.oneOf=J,e.instanceOf=$,e.oneOfType=M,e.arrayOf=R,e.objectOf=z,e.shape=C,e.utils={validate:function(e,t){return!0===k(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?x(e,t):P(e,t)}},e}();function K(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}(H)).defaults=n({},e),i}var Q=function(e){function t(){return e.apply(this,arguments)||this}return r(t,e),t}(K());export default Q;export{q as any,D as array,R as arrayOf,S as bool,a as config,K as createTypes,I as custom,E as fromType,A as func,$ as instanceOf,Y as integer,F as number,L as object,z as objectOf,J as oneOf,M as oneOfType,C as shape,V as string,B as symbol,P as toType,x as toValidableType,k as validateType}; | ||
//# sourceMappingURL=vue-types.m.js.map |
@@ -1,2 +0,2 @@ | ||
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={silent:!1},o=Object.prototype,i=o.toString,a=o.hasOwnProperty,s=/^\s*function (\w+)/;function u(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(s);return e?e[1]:""}return""}const l=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 f=c;if("production"!==process.env.NODE_ENV){const e="undefined"!=typeof console;f=e?function(e){!1===n.silent&&console.warn(`[VueTypes warn]: ${e}`)}:c}const d=(e,t)=>a.call(e,t),p=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},y=Array.isArray||function(e){return"[object Array]"===i.call(e)},v=e=>"[object Function]"===i.call(e),h=e=>l(e)&&d(e,"_vueTypes_name"),b=e=>l(e)&&(d(e,"type")||["_vueTypes_name","validator","default","required"].some(t=>d(e,t)));function g(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function O(e,t,r=!1){let n,o=!0,i="";n=l(e)?e:{type:e};const a=h(n)?n._vueTypes_name+" - ":"";if(b(n)&&null!==n.type){if(void 0===n.type||!0===n.type)return o;if(!n.required&&void 0===t)return o;y(n.type)?(o=n.type.some(e=>!0===O(e,t,!0)),i=n.type.map(e=>u(e)).join(" or ")):(i=u(n),o="Array"===i?y(t):"Object"===i?l(t):"String"===i||"Number"===i||"Boolean"===i||"Function"===i?function(e){if(null==e)return"";const t=e.constructor.toString().match(s);return t?t[1]:""}(t)===i:t instanceof n.type)}if(!o){const e=`${a}value "${t}" should be of type "${i}"`;return!1===r?(f(e),!1):e}if(d(n,"validator")&&v(n.validator)){const e=f,i=[];if(f=e=>{i.push(e)},o=n.validator(t),f=e,!o){const e=(i.length>1?"* ":"")+i.join("\n* ");return i.length=0,!1===r?(f(e),o):e}}return o}function m(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?(d(this,"default")&&delete this.default,this):v(e)||!0===O(this,e,!0)?(this.default=y(e)?()=>[...e]:l(e)?()=>Object.assign({},e):e,this):(f(`${this._vueTypes_name} - invalid default value: "${e}"`),this)}}}),{validator:n}=r;return v(n)&&(r.validator=g(n,r)),r}function j(e,t){const r=m(e,t);return Object.defineProperty(r,"validate",{value(e){return v(this.validator)&&f(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:\n${JSON.stringify(this)}`),this.validator=g(e,this),this}})}function _(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,!l(n))return o;const{validator:i}=n,a=t(n,["validator"]);if(v(i)){let{validator:e}=o;e&&(e=null!==(u=(s=e).__original)&&void 0!==u?u:s),o.validator=g(e?function(t){return e.call(this,t)&&i.call(this,t)}:i,o)}var s,u;return Object.assign(o,a)}function T(e){return e.replace(/^(?!\s*$)/gm," ")}const $=()=>j("any",{}),w=()=>j("function",{type:Function}),P=()=>j("boolean",{type:Boolean}),x=()=>j("string",{type:String}),E=()=>j("number",{type:Number}),N=()=>j("array",{type:Array}),q=()=>j("object",{type:Object}),A=()=>m("integer",{type:Number,validator:e=>p(e)}),S=()=>m("symbol",{validator:e=>"symbol"==typeof e});function V(e,t="custom validation failed"){if("function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return m(e.name||"<<anonymous function>>",{validator(r){const n=e(r);return n||f(`${this._vueTypes_name} - ${t}`),n}})}function k(e){if(!y(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 m("oneOf",{type:r.length>0?r:void 0,validator(r){const n=-1!==e.indexOf(r);return n||f(t),n}})}function D(e){if(!y(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(b(o)){if(h(o)&&"oneOf"===o._vueTypes_name&&o.type){r=r.concat(o.type);continue}if(v(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),m("oneOfType",t?{type:r,validator(t){const r=[],n=e.some(e=>{const n=O(h(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof n&&r.push(n),!0===n});return n||f(`oneOfType - provided value does not match any of the ${r.length} passed-in validators:\n${T(r.join("\n"))}`),n}}:{type:r})}function F(e){return m("arrayOf",{type:Array,validator(t){let r;const n=t.every(t=>(r=O(e,t,!0),!0===r));return n||f(`arrayOf - value validation error:\n${T(r)}`),n}})}function L(e){return m("instanceOf",{type:e})}function Y(e){return m("objectOf",{type:Object,validator(t){let r;const n=Object.keys(t).every(n=>(r=O(e,t[n],!0),!0===r));return n||f(`objectOf - value validation error:\n${T(r)}`),n}})}function B(e){const t=Object.keys(e),r=t.filter(t=>{var r;return!(null===(r=e[t])||void 0===r||!r.required)}),n=m("shape",{type:Object,validator(n){if(!l(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 f(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||(f(`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&&f(`shape - "${r}" property validation error:\n ${T(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 I{static get any(){return $()}static get func(){return w().def(this.defaults.func)}static get bool(){return P().def(this.defaults.bool)}static get string(){return x().def(this.defaults.string)}static get number(){return E().def(this.defaults.number)}static get array(){return N().def(this.defaults.array)}static get object(){return q().def(this.defaults.object)}static get integer(){return A().def(this.defaults.integer)}static get symbol(){return S()}static extend(e){if(y(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(d(this,r))throw new TypeError(`[VueTypes error]: Type "${r}" already defined`);const{type:a}=i;if(h(a))return delete i.type,Object.defineProperty(this,r,o?{get:()=>_(r,a,i)}:{value(...e){const t=_(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?j(r,e):m(r,e)},enumerable:!0}:{value(...e){const t=Object.assign({},i);let o;return o=n?j(r,t):m(r,t),t.validator&&(o.validator=t.validator.bind(o,...e)),o},enumerable:!0},Object.defineProperty(this,r,s)}}function J(t={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var r;return(r=class extends I{static get sensibleDefaults(){return e({},this.defaults)}static set sensibleDefaults(r){this.defaults=!1!==r?e({},!0!==r?r:t):{}}}).defaults=e({},t),r}I.defaults={},I.config=n,I.custom=V,I.oneOf=k,I.instanceOf=L,I.oneOfType=D,I.arrayOf=F,I.objectOf=Y,I.shape=B,I.utils={validate:(e,t)=>!0===O(t,e,!0),toType:(e,t,r=!1)=>r?j(e,t):m(e,t)};class M extends(J()){}export default M;export{$ as any,N as array,F as arrayOf,P as bool,J as createTypes,V as custom,_ as fromType,w as func,L as instanceOf,A as integer,E as number,q as object,Y as objectOf,k as oneOf,D as oneOfType,B as shape,x as string,S as symbol,m as toType,j as toValidableType,O 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={silent:!1},o=["validator"],i=Object.prototype,a=i.toString,s=i.hasOwnProperty,u=/^\s*function (\w+)/;function c(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(u);return e?e[1]:""}return""}const l=function(e){var t,n;return!1!==r(e)&&(void 0===(t=e.constructor)||!1!==r(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},f=e=>e;let d=f;if("production"!==process.env.NODE_ENV){const e="undefined"!=typeof console;d=e?function(e){!1===n.silent&&console.warn(`[VueTypes warn]: ${e}`)}:f}const p=(e,t)=>s.call(e,t),y=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},v=Array.isArray||function(e){return"[object Array]"===a.call(e)},h=e=>"[object Function]"===a.call(e),b=e=>l(e)&&p(e,"_vueTypes_name"),g=e=>l(e)&&(p(e,"type")||["_vueTypes_name","validator","default","required"].some(t=>p(e,t)));function O(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function m(e,t,r=!1){let n,o=!0,i="";n=l(e)?e:{type:e};const a=b(n)?n._vueTypes_name+" - ":"";if(g(n)&&null!==n.type){if(void 0===n.type||!0===n.type)return o;if(!n.required&&void 0===t)return o;v(n.type)?(o=n.type.some(e=>!0===m(e,t,!0)),i=n.type.map(e=>c(e)).join(" or ")):(i=c(n),o="Array"===i?v(t):"Object"===i?l(t):"String"===i||"Number"===i||"Boolean"===i||"Function"===i?function(e){if(null==e)return"";const t=e.constructor.toString().match(u);return t?t[1]:""}(t)===i:t instanceof n.type)}if(!o){const e=`${a}value "${t}" should be of type "${i}"`;return!1===r?(d(e),!1):e}if(p(n,"validator")&&h(n.validator)){const e=d,i=[];if(d=e=>{i.push(e)},o=n.validator(t),d=e,!o){const e=(i.length>1?"* ":"")+i.join("\n* ");return i.length=0,!1===r?(d(e),o):e}}return o}function j(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?(p(this,"default")&&delete this.default,this):h(e)||!0===m(this,e,!0)?(this.default=v(e)?()=>[...e]:l(e)?()=>Object.assign({},e):e,this):(d(`${this._vueTypes_name} - invalid default value: "${e}"`),this)}}}),{validator:n}=r;return h(n)&&(r.validator=O(n,r)),r}function _(e,t){const r=j(e,t);return Object.defineProperty(r,"validate",{value(e){return h(this.validator)&&d(`${this._vueTypes_name} - calling .validate() will overwrite the current custom validator function. Validator info:\n${JSON.stringify(this)}`),this.validator=O(e,this),this}})}function T(e,r,n){const i=function(e){const t={};return Object.getOwnPropertyNames(e).forEach(r=>{t[r]=Object.getOwnPropertyDescriptor(e,r)}),Object.defineProperties({},t)}(r);if(i._vueTypes_name=e,!l(n))return i;const{validator:a}=n,s=t(n,o);if(h(a)){let{validator:e}=i;e&&(e=null!==(c=(u=e).__original)&&void 0!==c?c:u),i.validator=O(e?function(t){return e.call(this,t)&&a.call(this,t)}:a,i)}var u,c;return Object.assign(i,s)}function $(e){return e.replace(/^(?!\s*$)/gm," ")}const w=()=>_("any",{}),P=()=>_("function",{type:Function}),x=()=>_("boolean",{type:Boolean}),E=()=>_("string",{type:String}),N=()=>_("number",{type:Number}),q=()=>_("array",{type:Array}),A=()=>_("object",{type:Object}),S=()=>j("integer",{type:Number,validator:e=>y(e)}),V=()=>j("symbol",{validator:e=>"symbol"==typeof e});function k(e,t="custom validation failed"){if("function"!=typeof e)throw new TypeError("[VueTypes error]: You must provide a function as argument");return j(e.name||"<<anonymous function>>",{validator(r){const n=e(r);return n||d(`${this._vueTypes_name} - ${t}`),n}})}function D(e){if(!v(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 j("oneOf",{type:r.length>0?r:void 0,validator(r){const n=-1!==e.indexOf(r);return n||d(t),n}})}function F(e){if(!v(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(g(o)){if(b(o)&&"oneOf"===o._vueTypes_name&&o.type){r=r.concat(o.type);continue}if(h(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),j("oneOfType",t?{type:r,validator(t){const r=[],n=e.some(e=>{const n=m(b(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof n&&r.push(n),!0===n});return n||d(`oneOfType - provided value does not match any of the ${r.length} passed-in validators:\n${$(r.join("\n"))}`),n}}:{type:r})}function L(e){return j("arrayOf",{type:Array,validator(t){let r;const n=t.every(t=>(r=m(e,t,!0),!0===r));return n||d(`arrayOf - value validation error:\n${$(r)}`),n}})}function Y(e){return j("instanceOf",{type:e})}function B(e){return j("objectOf",{type:Object,validator(t){let r;const n=Object.keys(t).every(n=>(r=m(e,t[n],!0),!0===r));return n||d(`objectOf - value validation error:\n${$(r)}`),n}})}function I(e){const t=Object.keys(e),r=t.filter(t=>{var r;return!(null===(r=e[t])||void 0===r||!r.required)}),n=j("shape",{type:Object,validator(n){if(!l(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 d(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||(d(`shape - shape definition does not include a "${r}" property. Allowed keys: "${t.join('", "')}".`),!1);const o=m(e[r],n[r],!0);return"string"==typeof o&&d(`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}const J=["name","validate","getter"],M=(()=>{var e;return(e=class{static get any(){return w()}static get func(){return P().def(this.defaults.func)}static get bool(){return x().def(this.defaults.bool)}static get string(){return E().def(this.defaults.string)}static get number(){return N().def(this.defaults.number)}static get array(){return q().def(this.defaults.array)}static get object(){return A().def(this.defaults.object)}static get integer(){return S().def(this.defaults.integer)}static get symbol(){return V()}static extend(e){if(v(e))return e.forEach(e=>this.extend(e)),this;const{name:r,validate:n=!1,getter:o=!1}=e,i=t(e,J);if(p(this,r))throw new TypeError(`[VueTypes error]: Type "${r}" already defined`);const{type:a}=i;if(b(a))return delete i.type,Object.defineProperty(this,r,o?{get:()=>T(r,a,i)}:{value(...e){const t=T(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?_(r,e):j(r,e)},enumerable:!0}:{value(...e){const t=Object.assign({},i);let o;return o=n?_(r,t):j(r,t),t.validator&&(o.validator=t.validator.bind(o,...e)),o},enumerable:!0},Object.defineProperty(this,r,s)}}).defaults={},e.config=n,e.custom=k,e.oneOf=D,e.instanceOf=Y,e.oneOfType=F,e.arrayOf=L,e.objectOf=B,e.shape=I,e.utils={validate:(e,t)=>!0===m(t,e,!0),toType:(e,t,r=!1)=>r?_(e,t):j(e,t)},e})();function R(t={func:()=>{},bool:!0,string:"",number:0,array:()=>[],object:()=>({}),integer:0}){var r;return(r=class extends M{static get sensibleDefaults(){return e({},this.defaults)}static set sensibleDefaults(r){this.defaults=!1!==r?e({},!0!==r?r:t):{}}}).defaults=e({},t),r}class z extends(R()){}export default z;export{w as any,q as array,L as arrayOf,x as bool,n as config,R as createTypes,k as custom,T as fromType,P as func,Y as instanceOf,S as integer,N as number,A as object,B as objectOf,D as oneOf,F as oneOfType,I as shape,E as string,V as symbol,j as toType,_ as toValidableType,m 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||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={},$.config={silent:!1},$.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}); | ||
!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={silent:!1},c=["validator"],l=Object.prototype,s=l.toString,y=l.hasOwnProperty,p=/^\s*function (\w+)/;function d(e){var t,n=null!==(t=null==e?void 0:e.type)&&void 0!==t?t:e;if(n){var r=n.toString().match(p);return r?r[1]:""}return""}var v=function(e){var t,n;return!1!==a(e)&&(void 0===(t=e.constructor)||!1!==a(n=t.prototype)&&!1!==n.hasOwnProperty("isPrototypeOf"))},h=function(e){return e},b=function(e,t){return y.call(e,t)},O=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},g=Array.isArray||function(e){return"[object Array]"===s.call(e)},m=function(e){return"[object Function]"===s.call(e)},j=function(e){return v(e)&&b(e,"_vueTypes_name")},T=function(e){return v(e)&&(b(e,"type")||["_vueTypes_name","validator","default","required"].some(function(t){return b(e,t)}))};function _(e,t){return Object.defineProperty(e.bind(t),"__original",{value:e})}function w(e,t,n){var r;void 0===n&&(n=!1);var i=!0,o="";r=v(e)?e:{type:e};var u=j(r)?r._vueTypes_name+" - ":"";if(T(r)&&null!==r.type){if(void 0===r.type||!0===r.type)return i;if(!r.required&&void 0===t)return i;g(r.type)?(i=r.type.some(function(e){return!0===w(e,t,!0)}),o=r.type.map(function(e){return d(e)}).join(" or ")):i="Array"===(o=d(r))?g(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(p);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?(h(a),!1):a}if(b(r,"validator")&&m(r.validator)){var f=h,c=[];if(h=function(e){c.push(e)},i=r.validator(t),h=f,!i){var l=(c.length>1?"* ":"")+c.join("\n* ");return c.length=0,!1===n?(h(l),i):l}}return i}function k(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?(b(this,"default")&&delete this.default,this):m(e)||!0===w(this,e,!0)?(this.default=g(e)?function(){return[].concat(e)}:v(e)?function(){return Object.assign({},e)}:e,this):(h(this._vueTypes_name+' - invalid default value: "'+e+'"'),this)}}}),r=n.validator;return m(r)&&(n.validator=_(r,n)),n}function P(e,t){var n=k(e,t);return Object.defineProperty(n,"validate",{value:function(e){return m(this.validator)&&h(this._vueTypes_name+" - calling .validate() will overwrite the current custom validator function. Validator info:\n"+JSON.stringify(this)),this.validator=_(e,this),this}})}function x(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,!v(n))return o;var a,f,l=n.validator,s=u(n,c);if(m(l)){var y=o.validator;y&&(y=null!==(f=(a=y).__original)&&void 0!==f?f:a),o.validator=_(y?function(e){return y.call(this,e)&&l.call(this,e)}:l,o)}return Object.assign(o,s)}function q(e){return e.replace(/^(?!\s*$)/gm," ")}var A=function(){return P("any",{})},S=function(){return P("function",{type:Function})},V=function(){return P("boolean",{type:Boolean})},E=function(){return P("string",{type:String})},N=function(){return P("number",{type:Number})},F=function(){return P("array",{type:Array})},L=function(){return P("object",{type:Object})},Y=function(){return k("integer",{type:Number,validator:function(e){return O(e)}})},B=function(){return k("symbol",{validator:function(e){return"symbol"==typeof e}})};function D(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 k(e.name||"<<anonymous function>>",{validator:function(n){var r=e(n);return r||h(this._vueTypes_name+" - "+t),r}})}function I(e){if(!g(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 k("oneOf",{type:n.length>0?n:void 0,validator:function(n){var r=-1!==e.indexOf(n);return r||h(t),r}})}function J(e){if(!g(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(T(i)){if(j(i)&&"oneOf"===i._vueTypes_name&&i.type){n=n.concat(i.type);continue}if(m(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}),k("oneOfType",t?{type:n,validator:function(t){var n=[],r=e.some(function(e){var r=w(j(e)&&"oneOf"===e._vueTypes_name?e.type||null:e,t,!0);return"string"==typeof r&&n.push(r),!0===r});return r||h("oneOfType - provided value does not match any of the "+n.length+" passed-in validators:\n"+q(n.join("\n"))),r}}:{type:n})}function M(e){return k("arrayOf",{type:Array,validator:function(t){var n,r=t.every(function(t){return!0===(n=w(e,t,!0))});return r||h("arrayOf - value validation error:\n"+q(n)),r}})}function R(e){return k("instanceOf",{type:e})}function $(e){return k("objectOf",{type:Object,validator:function(t){var n,r=Object.keys(t).every(function(r){return!0===(n=w(e,t[r],!0))});return r||h("objectOf - value validation error:\n"+q(n)),r}})}function z(e){var t=Object.keys(e),n=t.filter(function(t){var n;return!(null===(n=e[t])||void 0===n||!n.required)}),r=k("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 h(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||(h('shape - shape definition does not include a "'+n+'" property. Allowed keys: "'+t.join('", "')+'".'),!1);var o=w(e[n],r[n],!0);return"string"==typeof o&&h('shape - "'+n+'" property validation error:\n '+q(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 C=["name","validate","getter"],G=function(){var e;return(e=function(){function e(){}return e.extend=function(e){var t=this;if(g(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,C);if(b(this,n))throw new TypeError('[VueTypes error]: Type "'+n+'" already defined');var c,l=f.type;return j(l)?(delete f.type,Object.defineProperty(this,n,a?{get:function(){return x(n,l,f)}}:{value:function(){var e,t=x(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?P(n,e):k(n,e)},enumerable:!0}:{value:function(){var e,t,r=Object.assign({},f);return e=i?P(n,r):k(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 A()}},{key:"func",get:function(){return S().def(this.defaults.func)}},{key:"bool",get:function(){return V().def(this.defaults.bool)}},{key:"string",get:function(){return E().def(this.defaults.string)}},{key:"number",get:function(){return N().def(this.defaults.number)}},{key:"array",get:function(){return F().def(this.defaults.array)}},{key:"object",get:function(){return L().def(this.defaults.object)}},{key:"integer",get:function(){return Y().def(this.defaults.integer)}},{key:"symbol",get:function(){return B()}}]),e}()).defaults={},e.config=f,e.custom=D,e.oneOf=I,e.instanceOf=R,e.oneOfType=J,e.arrayOf=M,e.objectOf=$,e.shape=z,e.utils={validate:function(e,t){return!0===w(t,e,!0)},toType:function(e,t,n){return void 0===n&&(n=!1),n?P(e,t):k(e,t)}},e}();function H(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}(G)).defaults=r({},e),t}var K=function(e){function t(){return e.apply(this,arguments)||this}return i(t,e),t}(H());e.any=A,e.array=F,e.arrayOf=M,e.bool=V,e.config=f,e.createTypes=H,e.custom=D,e.default=K,e.fromType=x,e.func=S,e.instanceOf=R,e.integer=Y,e.number=N,e.object=L,e.objectOf=$,e.oneOf=I,e.oneOfType=J,e.shape=z,e.string=E,e.symbol=B,e.toType=k,e.toValidableType=P,e.validateType=w}); | ||
//# sourceMappingURL=vue-types.umd.js.map |
{ | ||
"name": "vue-types", | ||
"version": "4.0.0-rc.2", | ||
"version": "4.0.0-rc.3", | ||
"description": "Prop types utility for Vue", | ||
"author": "Marco Solazzi", | ||
"license": "MIT", | ||
"homepage": "https://github.com/dwightjack/vue-types", | ||
"main": "dist/vue-types.js", | ||
"homepage": "https://dwightjack.github.io/vue-types/", | ||
"main": "dist/vue-types.cjs", | ||
"type": "module", | ||
"source": [ | ||
@@ -18,5 +19,15 @@ "src/index.ts", | ||
"esmodule": "dist/vue-types.modern.js", | ||
"exports": { | ||
".": { | ||
"require": "./dist/vue-types.cjs", | ||
"default": "./dist/vue-types.modern.js" | ||
}, | ||
"./shim": { | ||
"require": "./dist/shim.cjs", | ||
"default": "./dist/shim.modern.js" | ||
} | ||
}, | ||
"types": "dist/index.d.ts", | ||
"engines": { | ||
"node": ">=10.15.0" | ||
"node": ">=12.16.0" | ||
}, | ||
@@ -34,9 +45,8 @@ "files": [ | ||
"build:ts": "microbundle --external=vue --tsconfig=./tsconfig.build.json --format=modern,es", | ||
"build:cjs": "microbundle --external=vue --tsconfig=./tsconfig.build.json -i src/index.cjs.ts -o dist/vue-types.js --no-pkg-main --format=cjs", | ||
"build:shim:cjs": "microbundle --external=vue --tsconfig=./tsconfig.build.json -i src/shim.cjs.ts -o dist/shim.js --no-pkg-main --format=cjs", | ||
"build:cjs": "microbundle --external=vue --tsconfig=./tsconfig.build.json -i src/index.cjs.ts -o dist/vue-types.cjs --no-pkg-main --format=cjs", | ||
"build:shim:cjs": "microbundle --external=vue --tsconfig=./tsconfig.build.json -i src/shim.cjs.ts -o dist/shim.cjs --no-pkg-main --format=cjs", | ||
"build:umd": "cross-env NODE_ENV=production microbundle --external=vue --tsconfig=./tsconfig.build.json --format=umd", | ||
"test": "karma start karma.conf.js --single-run --browsers ChromeHeadless", | ||
"test:saucelab": "karma start karma-sauce.conf.js --single-run", | ||
"lint": "eslint '{src,test,.}/**/*.{ts,js}'", | ||
"examples": "cross-env NODE_ENV=development node ./scripts/run-examples.js", | ||
"test": "jest", | ||
"lint": "eslint '{src,__tests__,.}/**/*.{ts,js,cjs}'", | ||
"examples": "cross-env NODE_ENV=development node ./scripts/run-examples.cjs", | ||
"docs:dev": "vuepress dev docs", | ||
@@ -58,5 +68,5 @@ "docs:build": "cross-env NODE_ENV=production vuepress build docs" | ||
"devDependencies": { | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.13.8", | ||
"@babel/plugin-proposal-optional-chaining": "7.13.12", | ||
"@types/jasmine": "3.6.9", | ||
"@babel/plugin-proposal-nullish-coalescing-operator": "7.14.2", | ||
"@babel/plugin-proposal-optional-chaining": "7.14.2", | ||
"@types/jest": "26.0.23", | ||
"@types/node": "14.14.37", | ||
@@ -67,4 +77,2 @@ "@typescript-eslint/eslint-plugin": "4.19.0", | ||
"browser-sync": "2.26.14", | ||
"core-js": "3.9.1", | ||
"core-js-bundle": "3.9.1", | ||
"cpy-cli": "3.1.1", | ||
@@ -79,17 +87,10 @@ "cross-env": "7.0.3", | ||
"eslint-plugin-vue": "7.8.0", | ||
"jasmine": "3.7.0", | ||
"karma": "6.3.1", | ||
"karma-chrome-launcher": "3.1.0", | ||
"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", | ||
"jest": "27.0.4", | ||
"microbundle": "0.13.1", | ||
"npm-run-all": "4.1.5", | ||
"prettier": "2.2.1", | ||
"puppeteer": "8.0.0", | ||
"ts-jest": "27.0.3", | ||
"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" | ||
@@ -99,11 +100,3 @@ }, | ||
"is-plain-object": "5.0.0" | ||
}, | ||
"browserslist": [ | ||
"last 3 versions", | ||
"Safari >= 10", | ||
"not ie <= 8", | ||
"Edge >= 12", | ||
"iOS >= 10", | ||
"Android >= 4.4" | ||
] | ||
} | ||
} |
@@ -18,3 +18,3 @@ # vue-types | ||
**Note: This document is for VueTypes 2 and above. If you are looking for an older version, refer to the `v1` branch.** | ||
**Note: This document is for VueTypes 4. If you are looking for an older versions, refer to the `v1~v3` branches.** | ||
@@ -46,2 +46,2 @@ ## Introduction | ||
Copyright (c) 2021 Marco Solazzi | ||
Copyright (c) 2016 - present Marco Solazzi |
224
src/index.ts
@@ -42,130 +42,131 @@ import { | ||
class BaseVueTypes { | ||
static defaults: Partial<VueTypesDefaults> = {} | ||
const BaseVueTypes = /*#__PURE__*/ (() => | ||
class BaseVueTypes { | ||
static defaults: Partial<VueTypesDefaults> = {} | ||
static sensibleDefaults: Partial<VueTypesDefaults> | boolean | ||
static sensibleDefaults: Partial<VueTypesDefaults> | boolean | ||
static config = config | ||
static config = config | ||
static get any() { | ||
return any() | ||
} | ||
static get func() { | ||
return func().def(this.defaults.func) | ||
} | ||
static get bool() { | ||
return bool().def(this.defaults.bool) | ||
} | ||
static get string() { | ||
return string().def(this.defaults.string) | ||
} | ||
static get number() { | ||
return number().def(this.defaults.number) | ||
} | ||
static get array() { | ||
return array().def(this.defaults.array) | ||
} | ||
static get object() { | ||
return object().def(this.defaults.object) | ||
} | ||
static get integer() { | ||
return integer().def(this.defaults.integer) | ||
} | ||
static get symbol() { | ||
return symbol() | ||
} | ||
static get any() { | ||
return any() | ||
} | ||
static get func() { | ||
return func().def(this.defaults.func) | ||
} | ||
static get bool() { | ||
return bool().def(this.defaults.bool) | ||
} | ||
static get string() { | ||
return string().def(this.defaults.string) | ||
} | ||
static get number() { | ||
return number().def(this.defaults.number) | ||
} | ||
static get array() { | ||
return array().def(this.defaults.array) | ||
} | ||
static get object() { | ||
return object().def(this.defaults.object) | ||
} | ||
static get integer() { | ||
return integer().def(this.defaults.integer) | ||
} | ||
static get symbol() { | ||
return symbol() | ||
} | ||
static readonly custom = custom | ||
static readonly oneOf = oneOf | ||
static readonly instanceOf = instanceOf | ||
static readonly oneOfType = oneOfType | ||
static readonly arrayOf = arrayOf | ||
static readonly objectOf = objectOf | ||
static readonly shape = shape | ||
static readonly custom = custom | ||
static readonly oneOf = oneOf | ||
static readonly instanceOf = instanceOf | ||
static readonly oneOfType = oneOfType | ||
static readonly arrayOf = arrayOf | ||
static readonly objectOf = objectOf | ||
static readonly shape = shape | ||
static extend<T>(props: ExtendProps | ExtendProps[]): T { | ||
if (isArray(props)) { | ||
props.forEach((p) => this.extend(p)) | ||
return this as any | ||
} | ||
static extend<T>(props: ExtendProps | ExtendProps[]): T { | ||
if (isArray(props)) { | ||
props.forEach((p) => this.extend(p)) | ||
return this as any | ||
} | ||
const { name, validate = false, getter = false, ...opts } = props | ||
const { name, validate = false, getter = false, ...opts } = props | ||
if (has(this, name as any)) { | ||
throw new TypeError(`[VueTypes error]: Type "${name}" already defined`) | ||
} | ||
if (has(this, name as any)) { | ||
throw new TypeError(`[VueTypes error]: Type "${name}" already defined`) | ||
} | ||
const { type } = opts | ||
if (isVueTypeDef(type)) { | ||
// we are using as base type a vue-type object | ||
const { type } = opts | ||
if (isVueTypeDef(type)) { | ||
// we are using as base type a vue-type object | ||
// detach the original type | ||
// we are going to inherit the parent data. | ||
delete opts.type | ||
// detach the original type | ||
// we are going to inherit the parent data. | ||
delete opts.type | ||
if (getter) { | ||
if (getter) { | ||
return Object.defineProperty(this, name, { | ||
get: () => fromType(name, type, opts as Omit<ExtendProps, 'type'>), | ||
}) | ||
} | ||
return Object.defineProperty(this, name, { | ||
get: () => fromType(name, type, opts as Omit<ExtendProps, 'type'>), | ||
value(...args: unknown[]) { | ||
const t = fromType(name, type, opts as Omit<ExtendProps, 'type'>) | ||
if (t.validator) { | ||
t.validator = t.validator.bind(t, ...args) | ||
} | ||
return t | ||
}, | ||
}) | ||
} | ||
return Object.defineProperty(this, name, { | ||
value(...args: unknown[]) { | ||
const t = fromType(name, type, opts as Omit<ExtendProps, 'type'>) | ||
if (t.validator) { | ||
t.validator = t.validator.bind(t, ...args) | ||
} | ||
return t | ||
}, | ||
}) | ||
} | ||
let descriptor: PropertyDescriptor | ||
if (getter) { | ||
descriptor = { | ||
get() { | ||
const typeOptions = Object.assign({}, opts as PropOptions<T>) | ||
if (validate) { | ||
return toValidableType<T>(name, typeOptions) | ||
} | ||
return toType<T>(name, typeOptions) | ||
}, | ||
enumerable: true, | ||
let descriptor: PropertyDescriptor | ||
if (getter) { | ||
descriptor = { | ||
get() { | ||
const typeOptions = Object.assign({}, opts as PropOptions<T>) | ||
if (validate) { | ||
return toValidableType<T>(name, typeOptions) | ||
} | ||
return toType<T>(name, typeOptions) | ||
}, | ||
enumerable: true, | ||
} | ||
} else { | ||
descriptor = { | ||
value(...args: T[]) { | ||
const typeOptions = Object.assign({}, opts as PropOptions<T>) | ||
let ret: VueTypeDef<T> | ||
if (validate) { | ||
ret = toValidableType<T>(name, typeOptions) | ||
} else { | ||
ret = toType<T>(name, typeOptions) | ||
} | ||
if (typeOptions.validator) { | ||
ret.validator = typeOptions.validator.bind(ret, ...args) | ||
} | ||
return ret | ||
}, | ||
enumerable: true, | ||
} | ||
} | ||
} else { | ||
descriptor = { | ||
value(...args: T[]) { | ||
const typeOptions = Object.assign({}, opts as PropOptions<T>) | ||
let ret: VueTypeDef<T> | ||
if (validate) { | ||
ret = toValidableType<T>(name, typeOptions) | ||
} else { | ||
ret = toType<T>(name, typeOptions) | ||
} | ||
if (typeOptions.validator) { | ||
ret.validator = typeOptions.validator.bind(ret, ...args) | ||
} | ||
return ret | ||
}, | ||
enumerable: true, | ||
} | ||
return Object.defineProperty(this, name, descriptor) | ||
} | ||
return Object.defineProperty(this, name, descriptor) | ||
} | ||
static utils = { | ||
validate<T, U>(value: T, type: U) { | ||
return validateType<U, T>(type, value, true) === true | ||
}, | ||
toType<T = unknown>( | ||
name: string, | ||
obj: PropOptions<T>, | ||
validable = false, | ||
): VueTypeDef<T> | VueTypeValidableDef<T> { | ||
return validable ? toValidableType<T>(name, obj) : toType<T>(name, obj) | ||
}, | ||
} | ||
})() | ||
static utils = { | ||
validate<T, U>(value: T, type: U) { | ||
return validateType<U, T>(type, value, true) === true | ||
}, | ||
toType<T = unknown>( | ||
name: string, | ||
obj: PropOptions<T>, | ||
validable = false, | ||
): VueTypeDef<T> | VueTypeValidableDef<T> { | ||
return validable ? toValidableType<T>(name, obj) : toType<T>(name, obj) | ||
}, | ||
} | ||
} | ||
function createTypes(defs: Partial<VueTypesDefaults> = typeDefaults()) { | ||
@@ -193,3 +194,3 @@ return class extends BaseVueTypes { | ||
export default class VueTypes extends createTypes() {} | ||
export default class VueTypes /*#__PURE__*/ extends createTypes() {} | ||
@@ -218,5 +219,6 @@ export { | ||
fromType, | ||
config, | ||
} | ||
export type VueTypesInterface = ReturnType<typeof createTypes> | ||
export { VueTypeDef, VueTypeValidableDef, VueTypeShape, VueTypeLooseShape } | ||
export type { VueTypeDef, VueTypeValidableDef, VueTypeShape, VueTypeLooseShape } |
105
src/shim.ts
@@ -62,2 +62,4 @@ import { isPlainObject } from 'is-plain-object' | ||
export { config } | ||
export const any = () => type('any', {}, true) | ||
@@ -112,54 +114,55 @@ export const func = <T = any>() => type<T>('func', { type: Function }, true) | ||
class BaseVueTypes { | ||
static defaults: Partial<VueTypesDefaults> = {} | ||
const BaseVueTypes = /*#__PURE__*/ (() => | ||
class BaseVueTypes { | ||
static defaults: Partial<VueTypesDefaults> = {} | ||
static sensibleDefaults: Partial<VueTypesDefaults> | boolean | ||
static sensibleDefaults: Partial<VueTypesDefaults> | boolean | ||
static config = config | ||
static config = config | ||
static get any() { | ||
return any() | ||
} | ||
static get func() { | ||
return func().def(this.defaults.func) | ||
} | ||
static get bool() { | ||
return bool().def(this.defaults.bool) | ||
} | ||
static get string() { | ||
return string().def(this.defaults.string) | ||
} | ||
static get number() { | ||
return number().def(this.defaults.number) | ||
} | ||
static get array() { | ||
return array().def(this.defaults.array) | ||
} | ||
static get object() { | ||
return object().def(this.defaults.object) | ||
} | ||
static get symbol() { | ||
return symbol() | ||
} | ||
static get integer() { | ||
return integer().def(this.defaults.integer) | ||
} | ||
static oneOf = oneOf | ||
static custom = custom | ||
static instanceOf = instanceOf | ||
static oneOfType = oneOfType | ||
static arrayOf = arrayOf | ||
static objectOf = objectOf | ||
static shape = shape | ||
static extend<T = any>(props): T { | ||
const { name, validate, getter = false, type = null } = props | ||
// If we are inheriting from a custom type, let's ignore the type property | ||
const extType = isPlainObject(type) && type.type ? null : type | ||
return createValidator(this, name, { type: extType }, getter, !!validate) | ||
} | ||
static utils = { | ||
toType: type as (...args: any[]) => any, | ||
validate: (...args: any[]) => !!args, | ||
} | ||
} | ||
static get any() { | ||
return any() | ||
} | ||
static get func() { | ||
return func().def(this.defaults.func) | ||
} | ||
static get bool() { | ||
return bool().def(this.defaults.bool) | ||
} | ||
static get string() { | ||
return string().def(this.defaults.string) | ||
} | ||
static get number() { | ||
return number().def(this.defaults.number) | ||
} | ||
static get array() { | ||
return array().def(this.defaults.array) | ||
} | ||
static get object() { | ||
return object().def(this.defaults.object) | ||
} | ||
static get symbol() { | ||
return symbol() | ||
} | ||
static get integer() { | ||
return integer().def(this.defaults.integer) | ||
} | ||
static oneOf = oneOf | ||
static custom = custom | ||
static instanceOf = instanceOf | ||
static oneOfType = oneOfType | ||
static arrayOf = arrayOf | ||
static objectOf = objectOf | ||
static shape = shape | ||
static extend<T = any>(props): T { | ||
const { name, validate, getter = false, type = null } = props | ||
// If we are inheriting from a custom type, let's ignore the type property | ||
const extType = isPlainObject(type) && type.type ? null : type | ||
return createValidator(this, name, { type: extType }, getter, !!validate) | ||
} | ||
static utils = { | ||
toType: type as (...args: any[]) => any, | ||
validate: (...args: any[]) => !!args, | ||
} | ||
})() | ||
@@ -192,3 +195,3 @@ export function createTypes(defs: Partial<VueTypesDefaults> = typeDefaults()) { | ||
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.', | ||
'You are using the production shimmed version of VueTypes in a development build. Refer to https://dwightjack.github.io/vue-types/guide/installation.html#production-build to learn how to configure VueTypes for usage in multiple environments.', | ||
) | ||
@@ -198,2 +201,2 @@ } | ||
export default class VueTypes extends createTypes() {} | ||
export default class VueTypes /*#__PURE__*/ extends createTypes() {} |
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
301426
26
1848
Yes