Comparing version 2.3.2 to 2.3.3
@@ -203,3 +203,3 @@ import json2mq from 'json2mq'; | ||
var isMqMinus = !isMqArray.value && /-$/.test(mq) === true; | ||
var isMqRange = !isMqArray.value && /^\w*-\w*/.test(mq) === true; | ||
var isMqRange = !isMqArray.value && /^\w+-\w+/.test(mq) === true; | ||
var activeBreakpoints = computed(function () { | ||
@@ -206,0 +206,0 @@ if (isMqArray) return mq;else if (!isMqPlus && !isMqMinus && !isMqRange) return [mq];else { |
@@ -209,3 +209,3 @@ 'use strict'; | ||
var isMqMinus = !isMqArray.value && /-$/.test(mq) === true; | ||
var isMqRange = !isMqArray.value && /^\w*-\w*/.test(mq) === true; | ||
var isMqRange = !isMqArray.value && /^\w+-\w+/.test(mq) === true; | ||
var activeBreakpoints = vue.computed(function () { | ||
@@ -212,0 +212,0 @@ if (isMqArray) return mq;else if (!isMqPlus && !isMqMinus && !isMqRange) return [mq];else { |
@@ -210,3 +210,3 @@ (function (global, factory) { | ||
var isMqMinus = !isMqArray.value && /-$/.test(mq) === true; | ||
var isMqRange = !isMqArray.value && /^\w*-\w*/.test(mq) === true; | ||
var isMqRange = !isMqArray.value && /^\w+-\w+/.test(mq) === true; | ||
var activeBreakpoints = vue.computed(function () { | ||
@@ -213,0 +213,0 @@ if (isMqArray) return mq;else if (!isMqPlus && !isMqMinus && !isMqRange) return [mq];else { |
@@ -1,2 +0,2 @@ | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("json2mq"),require("vue")):"function"==typeof define&&define.amd?define(["json2mq","vue"],r):(e="undefined"!=typeof globalThis?globalThis:e||self)["vue3-mq"]=r(e.json2mq,e.vue)}(this,(function(e,r){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?o(Object(t),!0).forEach((function(r){a(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function l(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var n,o,u=[],i=!0,a=!1;try{for(t=t.call(e);!(i=(n=t.next()).done)&&(u.push(n.value),!r||u.length!==r);i=!0);}catch(e){a=!0,o=e}finally{try{i||null==t.return||t.return()}finally{if(a)throw o}}return u}(e,r)||c(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,r){if(e){if("string"==typeof e)return s(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?s(e,r):void 0}}function s(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var v={xs:576,sm:768,md:992,lg:1200,xl:1400,xxl:1/0},d=r.ref(""),p=r.ref({}),m=r.readonly(p),y=function(e){return d.value=e},b=r.readonly(d);function g(e){for(var r=h.length-1;r>=0;r--){var t=h[r],o=t.mql,u=t.cb;o.removeEventListener("change",u),h.splice(r,1)}var l;!function(e){for(var r in e){if(!["string","number"].includes(i(r))||!r)throw new Error("Invalid or missing breakpoint key");if("string"==typeof e[r]&&(e[r]=parseFloat(e[r].replace(/[^0-9]/g,""))),"number"!=typeof e[r]||e[r]<0)throw new Error("Invalid breakpoint value for "+r+". Please use a valid number.");if(!e[r])throw new Error("No valid breakpoint value for "+r+" was found")}}(e),l=e,p.value=l;var c=function(e){var r=Object.keys(e),t=r.map((function(r){return e[r]})),o=[0].concat(f(t.slice(0,-1)));return o.reduce((function(e,t,u){var i=Object.assign({minWidth:t},u<r.length-1?{maxWidth:o[u+1]-1}:{}),l=n.default(i);return Object.assign(e,a({},r[u],l))}),{})}(e),s=function(e){!function(e,r){var t=window.matchMedia(e),n=function(e){e.matches&&r()};h.push({mql:t,cb:n}),t.addEventListener&&"function"==typeof t.addEventListener?t.addEventListener("change",n):t.addListener("change",n);n(t)}(c[e],(function(){y(e)}))};for(var v in c)s(v)}var h=[];function q(e){var r,t=e.mqProp,n=e.isMqPlus,o=void 0===n?{value:!1}:n,u=e.isMqMinus,i=void 0===u?{value:!1}:u,a=e.isMqRange,f=void 0===a?{value:!1}:a,c=Object.entries(m.value);if(0===c.length)return[];if(o.value)t=t.replace(/\+$/,"");else if(i.value)t=t.replace(/-$/,"");else if(f.value&&(!(t=t.split("-"))||2!==t.length))throw new Error("Invalid MQ range provided");if(f.value){var s=c.find((function(e){var r=l(e,2),n=r[0];return r[1],n==t[0].trim()}));if(!s||0===s.length)throw new Error("Range from breakpoint ("+t[0].trim()+") not found");var v=c.find((function(e){var r=l(e,2),n=r[0];return r[1],n==t[1].trim()}));if(!v||0===v.length)throw new Error("Range to breakpoint ("+t[1].trim()+") not found");if(s[1]>v[1]){var d=[v,s];s=d[0],v=d[1]}r=c.filter((function(e){var r=l(e,2);r[0];var t=r[1];return t>=s[1]&&t<=v[1]}))}else{var p=c.find((function(e){var r=l(e,2),n=r[0];return r[1],n==t}));o.value?r=c.filter((function(e){var r=l(e,2);return r[0],r[1]>=p[1]})):i.value&&(r=c.filter((function(e){var r=l(e,2);return r[0],r[1]<=p[1]})))}return r.sort((function(e,r){return e[1]-r[1]})),r.map((function(e){return e[0]}))}var w={name:"MqLayout",props:{mq:{type:[String,Array]},tag:{type:String,default:"div"},group:{type:Boolean,default:!1}},setup:function(e,t){var n={name:"fade",mode:"out-in"},o=r.computed((function(){return Array.isArray(e.mq)})),a=r.computed((function(){return!o.value&&!0===/\+$/.test(e.mq)})),l=r.computed((function(){return!o.value&&!0===/-$/.test(e.mq)})),f=r.computed((function(){return!o.value&&!0===/^\w*-\w*/.test(e.mq)})),c=r.computed((function(){return o.value?e.mq:a.value||l.value||f.value?q({mqProp:e.mq,isMqPlus:a,isMqMinus:l,isMqRange:f}):[e.mq]})),s=r.computed((function(){return c.value.includes(b.value)})),v=function(n){var o=[],u=function(u){if(!e.group&&o.length>0)return{v:o};r.computed((function(){return function(e){var t=Array.isArray(e),n=!t.value&&!0===/\+$/.test(e),o=!t.value&&!0===/-$/.test(e),u=!t.value&&!0===/^\w*-\w*/.test(e);return r.computed((function(){return t?e:n||o||u?q({mqProp:e,isMqPlus:{value:n},isMqMinus:{value:o},isMqRange:{value:u}}):[e]})).value.includes(b.value)}(u.split(":")[0])})).value&&o.push(r.h(n||t.slots[u],{key:u},n?t.slots[u]():void 0))};for(var a in t.slots){var l=u(a);if("object"===i(l))return l.v}return o.length>0?o:void 0};return t.slots.default?function(){return s.value?r.h(e.tag,{},t.slots.default()):void 0}:function(){var o=u(u({},n),t.attrs),i=e.group?r.TransitionGroup:r.Transition;return r.h(i,o,v(e.tag))}}};return{install:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.breakpoints,o=void 0===n?v:n,u=t.defaultBreakpoint,i=void 0===u?"sm":u,a=!1;y(i),e.provide("updateBreakpoints",g),e.provide("mq",r.readonly(b)),e.mixin({computed:{$mq:function(){return b.value}},mounted:function(){a||(g(o),a=!0)}}),e.config.globalProperties.$mqAvailableBreakpoints=o,e.component("MqLayout",w)}}})); | ||
!function(e,r){"object"==typeof exports&&"undefined"!=typeof module?module.exports=r(require("json2mq"),require("vue")):"function"==typeof define&&define.amd?define(["json2mq","vue"],r):(e="undefined"!=typeof globalThis?globalThis:e||self)["vue3-mq"]=r(e.json2mq,e.vue)}(this,(function(e,r){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n=t(e);function o(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function u(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?o(Object(t),!0).forEach((function(r){a(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):o(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function l(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==t)return;var n,o,u=[],i=!0,a=!1;try{for(t=t.call(e);!(i=(n=t.next()).done)&&(u.push(n.value),!r||u.length!==r);i=!0);}catch(e){a=!0,o=e}finally{try{i||null==t.return||t.return()}finally{if(a)throw o}}return u}(e,r)||c(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e){return function(e){if(Array.isArray(e))return s(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,r){if(e){if("string"==typeof e)return s(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?s(e,r):void 0}}function s(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}var v={xs:576,sm:768,md:992,lg:1200,xl:1400,xxl:1/0},d=r.ref(""),p=r.ref({}),m=r.readonly(p),y=function(e){return d.value=e},b=r.readonly(d);function g(e){for(var r=h.length-1;r>=0;r--){var t=h[r],o=t.mql,u=t.cb;o.removeEventListener("change",u),h.splice(r,1)}var l;!function(e){for(var r in e){if(!["string","number"].includes(i(r))||!r)throw new Error("Invalid or missing breakpoint key");if("string"==typeof e[r]&&(e[r]=parseFloat(e[r].replace(/[^0-9]/g,""))),"number"!=typeof e[r]||e[r]<0)throw new Error("Invalid breakpoint value for "+r+". Please use a valid number.");if(!e[r])throw new Error("No valid breakpoint value for "+r+" was found")}}(e),l=e,p.value=l;var c=function(e){var r=Object.keys(e),t=r.map((function(r){return e[r]})),o=[0].concat(f(t.slice(0,-1)));return o.reduce((function(e,t,u){var i=Object.assign({minWidth:t},u<r.length-1?{maxWidth:o[u+1]-1}:{}),l=n.default(i);return Object.assign(e,a({},r[u],l))}),{})}(e),s=function(e){!function(e,r){var t=window.matchMedia(e),n=function(e){e.matches&&r()};h.push({mql:t,cb:n}),t.addEventListener&&"function"==typeof t.addEventListener?t.addEventListener("change",n):t.addListener("change",n);n(t)}(c[e],(function(){y(e)}))};for(var v in c)s(v)}var h=[];function q(e){var r,t=e.mqProp,n=e.isMqPlus,o=void 0===n?{value:!1}:n,u=e.isMqMinus,i=void 0===u?{value:!1}:u,a=e.isMqRange,f=void 0===a?{value:!1}:a,c=Object.entries(m.value);if(0===c.length)return[];if(o.value)t=t.replace(/\+$/,"");else if(i.value)t=t.replace(/-$/,"");else if(f.value&&(!(t=t.split("-"))||2!==t.length))throw new Error("Invalid MQ range provided");if(f.value){var s=c.find((function(e){var r=l(e,2),n=r[0];return r[1],n==t[0].trim()}));if(!s||0===s.length)throw new Error("Range from breakpoint ("+t[0].trim()+") not found");var v=c.find((function(e){var r=l(e,2),n=r[0];return r[1],n==t[1].trim()}));if(!v||0===v.length)throw new Error("Range to breakpoint ("+t[1].trim()+") not found");if(s[1]>v[1]){var d=[v,s];s=d[0],v=d[1]}r=c.filter((function(e){var r=l(e,2);r[0];var t=r[1];return t>=s[1]&&t<=v[1]}))}else{var p=c.find((function(e){var r=l(e,2),n=r[0];return r[1],n==t}));o.value?r=c.filter((function(e){var r=l(e,2);return r[0],r[1]>=p[1]})):i.value&&(r=c.filter((function(e){var r=l(e,2);return r[0],r[1]<=p[1]})))}return r.sort((function(e,r){return e[1]-r[1]})),r.map((function(e){return e[0]}))}var w={name:"MqLayout",props:{mq:{type:[String,Array]},tag:{type:String,default:"div"},group:{type:Boolean,default:!1}},setup:function(e,t){var n={name:"fade",mode:"out-in"},o=r.computed((function(){return Array.isArray(e.mq)})),a=r.computed((function(){return!o.value&&!0===/\+$/.test(e.mq)})),l=r.computed((function(){return!o.value&&!0===/-$/.test(e.mq)})),f=r.computed((function(){return!o.value&&!0===/^\w*-\w*/.test(e.mq)})),c=r.computed((function(){return o.value?e.mq:a.value||l.value||f.value?q({mqProp:e.mq,isMqPlus:a,isMqMinus:l,isMqRange:f}):[e.mq]})),s=r.computed((function(){return c.value.includes(b.value)})),v=function(n){var o=[],u=function(u){if(!e.group&&o.length>0)return{v:o};r.computed((function(){return function(e){var t=Array.isArray(e),n=!t.value&&!0===/\+$/.test(e),o=!t.value&&!0===/-$/.test(e),u=!t.value&&!0===/^\w+-\w+/.test(e);return r.computed((function(){return t?e:n||o||u?q({mqProp:e,isMqPlus:{value:n},isMqMinus:{value:o},isMqRange:{value:u}}):[e]})).value.includes(b.value)}(u.split(":")[0])})).value&&o.push(r.h(n||t.slots[u],{key:u},n?t.slots[u]():void 0))};for(var a in t.slots){var l=u(a);if("object"===i(l))return l.v}return o.length>0?o:void 0};return t.slots.default?function(){return s.value?r.h(e.tag,{},t.slots.default()):void 0}:function(){var o=u(u({},n),t.attrs),i=e.group?r.TransitionGroup:r.Transition;return r.h(i,o,v(e.tag))}}};return{install:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.breakpoints,o=void 0===n?v:n,u=t.defaultBreakpoint,i=void 0===u?"sm":u,a=!1;y(i),e.provide("updateBreakpoints",g),e.provide("mq",r.readonly(b)),e.mixin({computed:{$mq:function(){return b.value}},mounted:function(){a||(g(o),a=!0)}}),e.config.globalProperties.$mqAvailableBreakpoints=o,e.component("MqLayout",w)}}})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "vue3-mq", | ||
"version": "2.3.2", | ||
"version": "2.3.3", | ||
"description": "Handle media queries easily & build responsive design with Vue 3", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72686