New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@pluginjs/breakpoints

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pluginjs/breakpoints - npm Package Compare versions

Comparing version 0.7.8 to 0.7.9

566

dist/breakpoints.common.js
/*!
* @pluginjs/breakpoints v0.7.8 (https://pluginjs.com)
* @pluginjs/breakpoints v0.7.9 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var is = require('@pluginjs/is');
var Emitter = _interopDefault(require('@pluginjs/simple-emitter'));
var utils = require('@pluginjs/utils');
var DEFAULTS = {
// Extra small devices (portrait phones, less than 576px)
xs: {
min: 0,
max: 575
},
// Small devices (landscape phones, 576px and up)
sm: {
min: 576,
max: 767
},
// Medium devices (tablets, 768px and up)
md: {
min: 768,
max: 991
},
// Large devices (desktops, 992px and up)
lg: {
min: 992,
max: 1199
},
// Extra large devices (large desktops, 1200px and up)
xl: {
min: 1200,
max: Infinity
}
};
var ChangeEvent = {
current: null,
listeners: [],
trigger(size) {
const previous = this.current;
this.current = size;
this.listeners.forEach((obj, i) => {
obj.listener.call({
current: size,
previous
}, obj.data);
if (obj.one) {
delete this.listeners[i];
}
});
},
one(data, listener) {
return this.on(data, listener, true);
},
on(data, listener) {
let one = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (typeof listener === 'undefined' && is.isFunction(data)) {
listener = data;
data = undefined;
}
if (is.isFunction(listener)) {
this.listeners.push({
data,
listener,
one
});
}
},
off(listener) {
if (typeof listener === 'undefined') {
this.listeners = [];
} else {
this.listeners = this.listeners.filter(obj => obj.listener !== listener);
}
}
};
class MediaQuery {
constructor(media) {
this.media = media;
this.initialize();
}
initialize() {
this.emitter = new Emitter();
this.mql = window.matchMedia && window.matchMedia(this.media) || {
matches: false,
media: this.media,
addListener() {// do nothing
},
removeListener() {// do nothing
}
};
const that = this;
this.mqlListener = mql => {
const type = mql.matches && 'enter' || 'leave';
this.emitter.emit(type, that);
};
this.mql.addListener(this.mqlListener);
}
on(types, data, fn) {
let one = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
if (typeof types === 'object') {
for (const type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
this.on(type, data, types[type], one);
}
}
return this;
}
if (typeof fn === 'undefined' && is.isFunction(data)) {
fn = data;
data = undefined;
}
if (!is.isFunction(fn)) {
return this;
}
if (one) {
this.emitter.once(types, fn, data);
} else {
this.emitter.on(types, fn, data);
}
return this;
}
one(types, data, fn) {
return this.on(types, data, fn, true);
}
off(types, fn) {
let type;
if (typeof types === 'object') {
for (type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
this.off(type, types[type]);
}
}
return this;
}
if (typeof types === 'undefined') {
this.emitter.off('enter');
this.emitter.off('leave');
} else {
this.emitter.off(types, fn);
}
return this;
}
isMatched() {
return this.mql.matches;
}
destroy() {
this.emitter.off('enter');
this.emitter.off('leave');
}
}
var MediaBuilder = {
min(min) {
let unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
return `(min-width: ${min}${unit})`;
},
max(max) {
let unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
return `(max-width: ${max}${unit})`;
},
between(min, max) {
let unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'px';
return `(min-width: ${min}${unit}) and (max-width: ${max}${unit})`;
},
get(min, max) {
let unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'px';
if (min === 0) {
return this.max(max, unit);
}
if (max === Infinity) {
return this.min(min, unit);
}
return this.between(min, max, unit);
}
};
class Viewport extends MediaQuery {
constructor(name) {
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
let unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'px';
const media = MediaBuilder.get(min, max, unit);
super(media);
this.name = name;
this.min = min;
this.max = max;
this.unit = unit;
}
destroy() {
this.off();
}
}
class Size extends Viewport {
constructor(name) {
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
let unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'px';
super(name, min, max, unit);
this.changeListener = () => {
if (this.isMatched()) {
ChangeEvent.trigger(this);
}
};
if (this.isMatched()) {
ChangeEvent.current = this;
}
this.mql.addListener(this.changeListener);
}
destroy() {
this.mql.removeListener(this.changeHander);
super.destroy();
}
}
const resolveName = name => {
name = name.trim();
if (/^([\w\d]+)$/.test(name)) {
return {
at: name
};
} else if (/^([\w\d]+)\+$/.test(name)) {
return {
from: name.replace(/\+$/, '')
};
} else if (/^([\w\d]+)-$/.test(name)) {
return {
to: name.replace(/-$/, '')
};
} else if (/^([\w\d]+)-([\w\d]+)$/.test(name)) {
return {
from: name.replace(/-([\w\d]+)$/, ''),
to: name.replace(/^([\w\d]+)-/, '')
};
}
return {};
};
const getName = obj => {
const at = obj.at,
from = obj.from,
to = obj.to;
if (at) {
return at;
}
if (from && to) {
return `${from}-${to}`;
}
if (from) {
return `${from}+`;
}
if (to) {
return `${to}-`;
}
return null;
};
let sizes = {};
let viewports = {};
let _Breakpoints = function Breakpoints() {
_Breakpoints.define(...arguments);
};
_Breakpoints.defaults = DEFAULTS;
_Breakpoints = utils.merge(_Breakpoints, {
defined: false,
init() {
if (!this.defined) {
this.define(...arguments);
}
},
define(values) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// if(typeof values === 'undefined' && this.defined) {
// return
// }
if (this.defined) {
this.destroy();
}
if (!values) {
values = _Breakpoints.defaults;
}
this.options = utils.merge(options, {
unit: 'px'
});
for (const size in values) {
if (Object.prototype.hasOwnProperty.call(values, size)) {
sizes[size] = new Size(size, values[size].min, values[size].max, this.options.unit);
}
}
this.defined = true;
},
destroy() {
utils.each(sizes, (name, size) => {
size.destroy();
});
sizes = {};
viewports = {};
ChangeEvent.current = null;
},
is(size) {
const breakpoint = this.get(size);
if (!breakpoint) {
return null;
}
return breakpoint.isMatched();
},
/* get all size name */
all() {
const names = [];
utils.each(sizes, name => {
names.push(name);
});
return names;
},
getSize(name) {
if (Object.prototype.hasOwnProperty.call(sizes, name)) {
return sizes[name];
}
return null;
},
getViewport(name) {
if (Object.prototype.hasOwnProperty.call(viewports, name)) {
return viewports[name];
}
return null;
},
get(name) {
if (is.isString(name)) {
name = name.trim();
} else if (is.isObject(name)) {
name = getName(name);
}
const viewport = this.getSize(name) || this.getViewport(name);
if (viewport) {
return viewport;
}
const _resolveName = resolveName(name),
at = _resolveName.at,
from = _resolveName.from,
to = _resolveName.to;
const unit = this.options.unit;
let max = null;
let min = null;
let size;
if (at) {
size = this.getSize(at);
if (size) {
min = size.min;
max = size.max;
}
} else if (from && to) {
const fromSize = this.getSize(from);
const toSize = this.getSize(to);
if (fromSize && toSize) {
min = fromSize.min;
max = toSize.max;
}
} else if (from) {
size = this.getSize(from);
if (size) {
min = size.min;
max = Infinity;
}
} else if (to) {
size = this.getSize(to);
if (size) {
min = 0;
max = size.max;
}
}
if (!is.isNull(min) && typeof !is.isNull(max)) {
viewports[name] = new Viewport(name, min, max, unit);
return viewports[name];
}
return null;
},
getMin(name) {
const obj = this.get(name);
if (obj) {
return obj.min;
}
return null;
},
getMax(name) {
const obj = this.get(name);
if (obj) {
return obj.max;
}
return null;
},
current() {
return ChangeEvent.current;
},
getMedia(name) {
const obj = this.get(name);
if (obj) {
return obj.media;
}
return null;
},
on(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
if (size === 'change') {
fn = data;
data = types;
return ChangeEvent.on(data, fn, one);
}
const obj = this.get(size);
if (obj) {
obj.on(types, data, fn, one);
}
return this;
},
one(size, types, data, fn) {
return this.on(size, types, data, fn, true);
},
off(size, types, fn) {
if (size === 'change') {
return ChangeEvent.off(types);
}
const obj = this.get(size);
if (obj) {
obj.off(types, fn);
}
return this;
},
at(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
const name = getName({
at: size
});
return this.on(name, types, data, fn, one);
},
from(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
return this.on({
from: size
}, types, data, fn, one);
},
to(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
return this.on({
to: size
}, types, data, fn, one);
},
between(from, to, types, data, fn) {
let one = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
return this.on({
from,
to
}, types, data, fn, one);
}
});
var _Breakpoints$1 = _Breakpoints;
module.exports = _Breakpoints$1;
undefined

4

dist/breakpoints.common.min.js
/*!
* @pluginjs/breakpoints v0.7.8 (https://pluginjs.com)
* @pluginjs/breakpoints v0.7.9 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}var is=require("@pluginjs/is"),Emitter=_interopDefault(require("@pluginjs/simple-emitter")),utils=require("@pluginjs/utils"),DEFAULTS={xs:{min:0,max:575},sm:{min:576,max:767},md:{min:768,max:991},lg:{min:992,max:1199},xl:{min:1200,max:1/0}},ChangeEvent={current:null,listeners:[],trigger(t){const e=this.current;this.current=t,this.listeners.forEach((i,s)=>{i.listener.call({current:t,previous:e},i.data),i.one&&delete this.listeners[s]})},one(t,e){return this.on(t,e,!0)},on(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];void 0===e&&is.isFunction(t)&&(e=t,t=void 0),is.isFunction(e)&&this.listeners.push({data:t,listener:e,one:i})},off(t){this.listeners=void 0===t?[]:this.listeners.filter(e=>e.listener!==t)}};class MediaQuery{constructor(t){this.media=t,this.initialize()}initialize(){this.emitter=new Emitter,this.mql=window.matchMedia&&window.matchMedia(this.media)||{matches:!1,media:this.media,addListener(){},removeListener(){}};const t=this;this.mqlListener=(e=>{const i=e.matches?"enter":"leave";this.emitter.emit(i,t)}),this.mql.addListener(this.mqlListener)}on(t,e,i){let s=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("object"==typeof t){for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.on(i,e,t[i],s);return this}return void 0===i&&is.isFunction(e)&&(i=e,e=void 0),is.isFunction(i)?(s?this.emitter.once(t,i,e):this.emitter.on(t,i,e),this):this}one(t,e,i){return this.on(t,e,i,!0)}off(t,e){let i;if("object"==typeof t){for(i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.off(i,t[i]);return this}return void 0===t?(this.emitter.off("enter"),this.emitter.off("leave")):this.emitter.off(t,e),this}isMatched(){return this.mql.matches}destroy(){this.emitter.off("enter"),this.emitter.off("leave")}}var MediaBuilder={min(t){return`(min-width: ${t}${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"px"})`},max(t){return`(max-width: ${t}${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"px"})`},between(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"px";return`(min-width: ${t}${i}) and (max-width: ${e}${i})`},get(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"px";return 0===t?this.max(e,i):e===1/0?this.min(t,i):this.between(t,e,i)}};class Viewport extends MediaQuery{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"px";super(MediaBuilder.get(e,i,s)),this.name=t,this.min=e,this.max=i,this.unit=s}destroy(){this.off()}}class Size extends Viewport{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:"px"),this.changeListener=(()=>{this.isMatched()&&ChangeEvent.trigger(this)}),this.isMatched()&&(ChangeEvent.current=this),this.mql.addListener(this.changeListener)}destroy(){this.mql.removeListener(this.changeHander),super.destroy()}}const resolveName=t=>(t=t.trim(),/^([\w\d]+)$/.test(t)?{at:t}:/^([\w\d]+)\+$/.test(t)?{from:t.replace(/\+$/,"")}:/^([\w\d]+)-$/.test(t)?{to:t.replace(/-$/,"")}:/^([\w\d]+)-([\w\d]+)$/.test(t)?{from:t.replace(/-([\w\d]+)$/,""),to:t.replace(/^([\w\d]+)-/,"")}:{}),getName=t=>{const e=t.at,i=t.from,s=t.to;return e||(i&&s?`${i}-${s}`:i?`${i}+`:s?`${s}-`:null)};let sizes={},viewports={},_Breakpoints=function(){_Breakpoints.define(...arguments)};_Breakpoints.defaults=DEFAULTS;var _Breakpoints$1=_Breakpoints=utils.merge(_Breakpoints,{defined:!1,init(){this.defined||this.define(...arguments)},define(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.defined&&this.destroy(),t||(t=_Breakpoints.defaults),this.options=utils.merge(e,{unit:"px"});for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(sizes[e]=new Size(e,t[e].min,t[e].max,this.options.unit));this.defined=!0},destroy(){utils.each(sizes,(t,e)=>{e.destroy()}),sizes={},viewports={},ChangeEvent.current=null},is(t){const e=this.get(t);return e?e.isMatched():null},all(){const t=[];return utils.each(sizes,e=>{t.push(e)}),t},getSize:t=>Object.prototype.hasOwnProperty.call(sizes,t)?sizes[t]:null,getViewport:t=>Object.prototype.hasOwnProperty.call(viewports,t)?viewports[t]:null,get(t){is.isString(t)?t=t.trim():is.isObject(t)&&(t=getName(t));const e=this.getSize(t)||this.getViewport(t);if(e)return e;const i=resolveName(t),s=i.at,n=i.from,r=i.to,o=this.options.unit;let h,l=null,a=null;if(s)(h=this.getSize(s))&&(a=h.min,l=h.max);else if(n&&r){const t=this.getSize(n),e=this.getSize(r);t&&e&&(a=t.min,l=e.max)}else n?(h=this.getSize(n))&&(a=h.min,l=1/0):r&&(h=this.getSize(r))&&(a=0,l=h.max);return!is.isNull(a)&&(is.isNull(l),1)?(viewports[t]=new Viewport(t,a,l,o),viewports[t]):null},getMin(t){const e=this.get(t);return e?e.min:null},getMax(t){const e=this.get(t);return e?e.max:null},current:()=>ChangeEvent.current,getMedia(t){const e=this.get(t);return e?e.media:null},on(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if("change"===t)return s=i,i=e,ChangeEvent.on(i,s,n);const r=this.get(t);return r&&r.on(e,i,s,n),this},one(t,e,i,s){return this.on(t,e,i,s,!0)},off(t,e,i){if("change"===t)return ChangeEvent.off(e);const s=this.get(t);return s&&s.off(e,i),this},at(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=getName({at:t});return this.on(r,e,i,s,n)},from(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this.on({from:t},e,i,s,n)},to(t,e,i,s){let n=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this.on({to:t},e,i,s,n)},between(t,e,i,s,n){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return this.on({from:t,to:e},i,s,n,r)}});module.exports=_Breakpoints$1;
undefined
/*!
* @pluginjs/breakpoints v0.7.8 (https://pluginjs.com)
* @pluginjs/breakpoints v0.7.9 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
import { isFunction, isObject, isString, isNull } from '@pluginjs/is';
import Emitter from '@pluginjs/simple-emitter';
import { merge, each } from '@pluginjs/utils';
var DEFAULTS = {
// Extra small devices (portrait phones, less than 576px)
xs: {
min: 0,
max: 575
},
// Small devices (landscape phones, 576px and up)
sm: {
min: 576,
max: 767
},
// Medium devices (tablets, 768px and up)
md: {
min: 768,
max: 991
},
// Large devices (desktops, 992px and up)
lg: {
min: 992,
max: 1199
},
// Extra large devices (large desktops, 1200px and up)
xl: {
min: 1200,
max: Infinity
}
};
var ChangeEvent = {
current: null,
listeners: [],
trigger(size) {
const previous = this.current;
this.current = size;
this.listeners.forEach((obj, i) => {
obj.listener.call({
current: size,
previous
}, obj.data);
if (obj.one) {
delete this.listeners[i];
}
});
},
one(data, listener) {
return this.on(data, listener, true);
},
on(data, listener) {
let one = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (typeof listener === 'undefined' && isFunction(data)) {
listener = data;
data = undefined;
}
if (isFunction(listener)) {
this.listeners.push({
data,
listener,
one
});
}
},
off(listener) {
if (typeof listener === 'undefined') {
this.listeners = [];
} else {
this.listeners = this.listeners.filter(obj => obj.listener !== listener);
}
}
};
class MediaQuery {
constructor(media) {
this.media = media;
this.initialize();
}
initialize() {
this.emitter = new Emitter();
this.mql = window.matchMedia && window.matchMedia(this.media) || {
matches: false,
media: this.media,
addListener() {// do nothing
},
removeListener() {// do nothing
}
};
const that = this;
this.mqlListener = mql => {
const type = mql.matches && 'enter' || 'leave';
this.emitter.emit(type, that);
};
this.mql.addListener(this.mqlListener);
}
on(types, data, fn) {
let one = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
if (typeof types === 'object') {
for (const type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
this.on(type, data, types[type], one);
}
}
return this;
}
if (typeof fn === 'undefined' && isFunction(data)) {
fn = data;
data = undefined;
}
if (!isFunction(fn)) {
return this;
}
if (one) {
this.emitter.once(types, fn, data);
} else {
this.emitter.on(types, fn, data);
}
return this;
}
one(types, data, fn) {
return this.on(types, data, fn, true);
}
off(types, fn) {
let type;
if (typeof types === 'object') {
for (type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
this.off(type, types[type]);
}
}
return this;
}
if (typeof types === 'undefined') {
this.emitter.off('enter');
this.emitter.off('leave');
} else {
this.emitter.off(types, fn);
}
return this;
}
isMatched() {
return this.mql.matches;
}
destroy() {
this.emitter.off('enter');
this.emitter.off('leave');
}
}
var MediaBuilder = {
min(min) {
let unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
return `(min-width: ${min}${unit})`;
},
max(max) {
let unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
return `(max-width: ${max}${unit})`;
},
between(min, max) {
let unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'px';
return `(min-width: ${min}${unit}) and (max-width: ${max}${unit})`;
},
get(min, max) {
let unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'px';
if (min === 0) {
return this.max(max, unit);
}
if (max === Infinity) {
return this.min(min, unit);
}
return this.between(min, max, unit);
}
};
class Viewport extends MediaQuery {
constructor(name) {
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
let unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'px';
const media = MediaBuilder.get(min, max, unit);
super(media);
this.name = name;
this.min = min;
this.max = max;
this.unit = unit;
}
destroy() {
this.off();
}
}
class Size extends Viewport {
constructor(name) {
let min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
let max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
let unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'px';
super(name, min, max, unit);
this.changeListener = () => {
if (this.isMatched()) {
ChangeEvent.trigger(this);
}
};
if (this.isMatched()) {
ChangeEvent.current = this;
}
this.mql.addListener(this.changeListener);
}
destroy() {
this.mql.removeListener(this.changeHander);
super.destroy();
}
}
const resolveName = name => {
name = name.trim();
if (/^([\w\d]+)$/.test(name)) {
return {
at: name
};
} else if (/^([\w\d]+)\+$/.test(name)) {
return {
from: name.replace(/\+$/, '')
};
} else if (/^([\w\d]+)-$/.test(name)) {
return {
to: name.replace(/-$/, '')
};
} else if (/^([\w\d]+)-([\w\d]+)$/.test(name)) {
return {
from: name.replace(/-([\w\d]+)$/, ''),
to: name.replace(/^([\w\d]+)-/, '')
};
}
return {};
};
const getName = obj => {
const at = obj.at,
from = obj.from,
to = obj.to;
if (at) {
return at;
}
if (from && to) {
return `${from}-${to}`;
}
if (from) {
return `${from}+`;
}
if (to) {
return `${to}-`;
}
return null;
};
let sizes = {};
let viewports = {};
let _Breakpoints = function Breakpoints() {
_Breakpoints.define(...arguments);
};
_Breakpoints.defaults = DEFAULTS;
_Breakpoints = merge(_Breakpoints, {
defined: false,
init() {
if (!this.defined) {
this.define(...arguments);
}
},
define(values) {
let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// if(typeof values === 'undefined' && this.defined) {
// return
// }
if (this.defined) {
this.destroy();
}
if (!values) {
values = _Breakpoints.defaults;
}
this.options = merge(options, {
unit: 'px'
});
for (const size in values) {
if (Object.prototype.hasOwnProperty.call(values, size)) {
sizes[size] = new Size(size, values[size].min, values[size].max, this.options.unit);
}
}
this.defined = true;
},
destroy() {
each(sizes, (name, size) => {
size.destroy();
});
sizes = {};
viewports = {};
ChangeEvent.current = null;
},
is(size) {
const breakpoint = this.get(size);
if (!breakpoint) {
return null;
}
return breakpoint.isMatched();
},
/* get all size name */
all() {
const names = [];
each(sizes, name => {
names.push(name);
});
return names;
},
getSize(name) {
if (Object.prototype.hasOwnProperty.call(sizes, name)) {
return sizes[name];
}
return null;
},
getViewport(name) {
if (Object.prototype.hasOwnProperty.call(viewports, name)) {
return viewports[name];
}
return null;
},
get(name) {
if (isString(name)) {
name = name.trim();
} else if (isObject(name)) {
name = getName(name);
}
const viewport = this.getSize(name) || this.getViewport(name);
if (viewport) {
return viewport;
}
const _resolveName = resolveName(name),
at = _resolveName.at,
from = _resolveName.from,
to = _resolveName.to;
const unit = this.options.unit;
let max = null;
let min = null;
let size;
if (at) {
size = this.getSize(at);
if (size) {
min = size.min;
max = size.max;
}
} else if (from && to) {
const fromSize = this.getSize(from);
const toSize = this.getSize(to);
if (fromSize && toSize) {
min = fromSize.min;
max = toSize.max;
}
} else if (from) {
size = this.getSize(from);
if (size) {
min = size.min;
max = Infinity;
}
} else if (to) {
size = this.getSize(to);
if (size) {
min = 0;
max = size.max;
}
}
if (!isNull(min) && typeof !isNull(max)) {
viewports[name] = new Viewport(name, min, max, unit);
return viewports[name];
}
return null;
},
getMin(name) {
const obj = this.get(name);
if (obj) {
return obj.min;
}
return null;
},
getMax(name) {
const obj = this.get(name);
if (obj) {
return obj.max;
}
return null;
},
current() {
return ChangeEvent.current;
},
getMedia(name) {
const obj = this.get(name);
if (obj) {
return obj.media;
}
return null;
},
on(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
if (size === 'change') {
fn = data;
data = types;
return ChangeEvent.on(data, fn, one);
}
const obj = this.get(size);
if (obj) {
obj.on(types, data, fn, one);
}
return this;
},
one(size, types, data, fn) {
return this.on(size, types, data, fn, true);
},
off(size, types, fn) {
if (size === 'change') {
return ChangeEvent.off(types);
}
const obj = this.get(size);
if (obj) {
obj.off(types, fn);
}
return this;
},
at(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
const name = getName({
at: size
});
return this.on(name, types, data, fn, one);
},
from(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
return this.on({
from: size
}, types, data, fn, one);
},
to(size, types, data, fn) {
let one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
return this.on({
to: size
}, types, data, fn, one);
},
between(from, to, types, data, fn) {
let one = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
return this.on({
from,
to
}, types, data, fn, one);
}
});
var _Breakpoints$1 = _Breakpoints;
export default _Breakpoints$1;
undefined
/*!
* @pluginjs/breakpoints v0.7.8 (https://pluginjs.com)
* @pluginjs/breakpoints v0.7.9 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
import{isFunction,isObject,isString,isNull}from"@pluginjs/is";import Emitter from"@pluginjs/simple-emitter";import{merge,each}from"@pluginjs/utils";var DEFAULTS={xs:{min:0,max:575},sm:{min:576,max:767},md:{min:768,max:991},lg:{min:992,max:1199},xl:{min:1200,max:1/0}},ChangeEvent={current:null,listeners:[],trigger(t){const e=this.current;this.current=t,this.listeners.forEach((i,n)=>{i.listener.call({current:t,previous:e},i.data),i.one&&delete this.listeners[n]})},one(t,e){return this.on(t,e,!0)},on(t,e){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];void 0===e&&isFunction(t)&&(e=t,t=void 0),isFunction(e)&&this.listeners.push({data:t,listener:e,one:i})},off(t){this.listeners=void 0===t?[]:this.listeners.filter(e=>e.listener!==t)}};class MediaQuery{constructor(t){this.media=t,this.initialize()}initialize(){this.emitter=new Emitter,this.mql=window.matchMedia&&window.matchMedia(this.media)||{matches:!1,media:this.media,addListener(){},removeListener(){}};const t=this;this.mqlListener=(e=>{const i=e.matches?"enter":"leave";this.emitter.emit(i,t)}),this.mql.addListener(this.mqlListener)}on(t,e,i){let n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("object"==typeof t){for(const i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.on(i,e,t[i],n);return this}return void 0===i&&isFunction(e)&&(i=e,e=void 0),isFunction(i)?(n?this.emitter.once(t,i,e):this.emitter.on(t,i,e),this):this}one(t,e,i){return this.on(t,e,i,!0)}off(t,e){let i;if("object"==typeof t){for(i in t)Object.prototype.hasOwnProperty.call(t,i)&&this.off(i,t[i]);return this}return void 0===t?(this.emitter.off("enter"),this.emitter.off("leave")):this.emitter.off(t,e),this}isMatched(){return this.mql.matches}destroy(){this.emitter.off("enter"),this.emitter.off("leave")}}var MediaBuilder={min(t){return`(min-width: ${t}${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"px"})`},max(t){return`(max-width: ${t}${arguments.length>1&&void 0!==arguments[1]?arguments[1]:"px"})`},between(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"px";return`(min-width: ${t}${i}) and (max-width: ${e}${i})`},get(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"px";return 0===t?this.max(e,i):e===1/0?this.min(t,i):this.between(t,e,i)}};class Viewport extends MediaQuery{constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"px";super(MediaBuilder.get(e,i,n)),this.name=t,this.min=e,this.max=i,this.unit=n}destroy(){this.off()}}class Size extends Viewport{constructor(t){super(t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,arguments.length>3&&void 0!==arguments[3]?arguments[3]:"px"),this.changeListener=(()=>{this.isMatched()&&ChangeEvent.trigger(this)}),this.isMatched()&&(ChangeEvent.current=this),this.mql.addListener(this.changeListener)}destroy(){this.mql.removeListener(this.changeHander),super.destroy()}}const resolveName=t=>(t=t.trim(),/^([\w\d]+)$/.test(t)?{at:t}:/^([\w\d]+)\+$/.test(t)?{from:t.replace(/\+$/,"")}:/^([\w\d]+)-$/.test(t)?{to:t.replace(/-$/,"")}:/^([\w\d]+)-([\w\d]+)$/.test(t)?{from:t.replace(/-([\w\d]+)$/,""),to:t.replace(/^([\w\d]+)-/,"")}:{}),getName=t=>{const e=t.at,i=t.from,n=t.to;return e||(i&&n?`${i}-${n}`:i?`${i}+`:n?`${n}-`:null)};let sizes={},viewports={},_Breakpoints=function(){_Breakpoints.define(...arguments)};_Breakpoints.defaults=DEFAULTS;var _Breakpoints$1=_Breakpoints=merge(_Breakpoints,{defined:!1,init(){this.defined||this.define(...arguments)},define(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.defined&&this.destroy(),t||(t=_Breakpoints.defaults),this.options=merge(e,{unit:"px"});for(const e in t)Object.prototype.hasOwnProperty.call(t,e)&&(sizes[e]=new Size(e,t[e].min,t[e].max,this.options.unit));this.defined=!0},destroy(){each(sizes,(t,e)=>{e.destroy()}),sizes={},viewports={},ChangeEvent.current=null},is(t){const e=this.get(t);return e?e.isMatched():null},all(){const t=[];return each(sizes,e=>{t.push(e)}),t},getSize:t=>Object.prototype.hasOwnProperty.call(sizes,t)?sizes[t]:null,getViewport:t=>Object.prototype.hasOwnProperty.call(viewports,t)?viewports[t]:null,get(t){isString(t)?t=t.trim():isObject(t)&&(t=getName(t));const e=this.getSize(t)||this.getViewport(t);if(e)return e;const i=resolveName(t),n=i.at,s=i.from,r=i.to,o=this.options.unit;let h,l=null,a=null;if(n)(h=this.getSize(n))&&(a=h.min,l=h.max);else if(s&&r){const t=this.getSize(s),e=this.getSize(r);t&&e&&(a=t.min,l=e.max)}else s?(h=this.getSize(s))&&(a=h.min,l=1/0):r&&(h=this.getSize(r))&&(a=0,l=h.max);return!isNull(a)&&(isNull(l),1)?(viewports[t]=new Viewport(t,a,l,o),viewports[t]):null},getMin(t){const e=this.get(t);return e?e.min:null},getMax(t){const e=this.get(t);return e?e.max:null},current:()=>ChangeEvent.current,getMedia(t){const e=this.get(t);return e?e.media:null},on(t,e,i,n){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if("change"===t)return n=i,i=e,ChangeEvent.on(i,n,s);const r=this.get(t);return r&&r.on(e,i,n,s),this},one(t,e,i,n){return this.on(t,e,i,n,!0)},off(t,e,i){if("change"===t)return ChangeEvent.off(e);const n=this.get(t);return n&&n.off(e,i),this},at(t,e,i,n){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];const r=getName({at:t});return this.on(r,e,i,n,s)},from(t,e,i,n){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this.on({from:t},e,i,n,s)},to(t,e,i,n){let s=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this.on({to:t},e,i,n,s)},between(t,e,i,n,s){let r=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return this.on({from:t,to:e},i,n,s,r)}});export default _Breakpoints$1;
undefined
/*!
* @pluginjs/breakpoints v0.7.8 (https://pluginjs.com)
* @pluginjs/breakpoints v0.7.9 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@pluginjs/is'), require('@pluginjs/simple-emitter'), require('@pluginjs/utils')) :
typeof define === 'function' && define.amd ? define(['@pluginjs/is', '@pluginjs/simple-emitter', '@pluginjs/utils'], factory) :
(global['@pluginjs/breakpoints'] = factory(global['@pluginjs/is'],global['@pluginjs/simple-emitter'],global['@pluginjs/utils']));
}(this, (function (is,Emitter,utils) { 'use strict';
Emitter = Emitter && Emitter.hasOwnProperty('default') ? Emitter['default'] : Emitter;
function _typeof(obj) {
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
}
subClass.prototype = Object.create(superClass && superClass.prototype, {
constructor: {
value: subClass,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf(subClass, superClass);
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
return o.__proto__ || Object.getPrototypeOf(o);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
function _possibleConstructorReturn(self, call) {
if (call && (typeof call === "object" || typeof call === "function")) {
return call;
}
return _assertThisInitialized(self);
}
function _superPropBase(object, property) {
while (!Object.prototype.hasOwnProperty.call(object, property)) {
object = _getPrototypeOf(object);
if (object === null) break;
}
return object;
}
function _get(target, property, receiver) {
if (typeof Reflect !== "undefined" && Reflect.get) {
_get = Reflect.get;
} else {
_get = function _get(target, property, receiver) {
var base = _superPropBase(target, property);
if (!base) return;
var desc = Object.getOwnPropertyDescriptor(base, property);
if (desc.get) {
return desc.get.call(receiver);
}
return desc.value;
};
}
return _get(target, property, receiver || target);
}
var DEFAULTS = {
// Extra small devices (portrait phones, less than 576px)
xs: {
min: 0,
max: 575
},
// Small devices (landscape phones, 576px and up)
sm: {
min: 576,
max: 767
},
// Medium devices (tablets, 768px and up)
md: {
min: 768,
max: 991
},
// Large devices (desktops, 992px and up)
lg: {
min: 992,
max: 1199
},
// Extra large devices (large desktops, 1200px and up)
xl: {
min: 1200,
max: Infinity
}
};
var ChangeEvent = {
current: null,
listeners: [],
trigger: function trigger(size) {
var _this = this;
var previous = this.current;
this.current = size;
this.listeners.forEach(function (obj, i) {
obj.listener.call({
current: size,
previous: previous
}, obj.data);
if (obj.one) {
delete _this.listeners[i];
}
});
},
one: function one(data, listener) {
return this.on(data, listener, true);
},
on: function on(data, listener) {
var one = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
if (typeof listener === 'undefined' && is.isFunction(data)) {
listener = data;
data = undefined;
}
if (is.isFunction(listener)) {
this.listeners.push({
data: data,
listener: listener,
one: one
});
}
},
off: function off(listener) {
if (typeof listener === 'undefined') {
this.listeners = [];
} else {
this.listeners = this.listeners.filter(function (obj) {
return obj.listener !== listener;
});
}
}
};
var MediaQuery =
/*#__PURE__*/
function () {
function MediaQuery(media) {
_classCallCheck(this, MediaQuery);
this.media = media;
this.initialize();
}
_createClass(MediaQuery, [{
key: "initialize",
value: function initialize() {
var _this = this;
this.emitter = new Emitter();
this.mql = window.matchMedia && window.matchMedia(this.media) || {
matches: false,
media: this.media,
addListener: function addListener() {// do nothing
},
removeListener: function removeListener() {// do nothing
}
};
var that = this;
this.mqlListener = function (mql) {
var type = mql.matches && 'enter' || 'leave';
_this.emitter.emit(type, that);
};
this.mql.addListener(this.mqlListener);
}
}, {
key: "on",
value: function on(types, data, fn) {
var one = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
if (_typeof(types) === 'object') {
for (var type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
this.on(type, data, types[type], one);
}
}
return this;
}
if (typeof fn === 'undefined' && is.isFunction(data)) {
fn = data;
data = undefined;
}
if (!is.isFunction(fn)) {
return this;
}
if (one) {
this.emitter.once(types, fn, data);
} else {
this.emitter.on(types, fn, data);
}
return this;
}
}, {
key: "one",
value: function one(types, data, fn) {
return this.on(types, data, fn, true);
}
}, {
key: "off",
value: function off(types, fn) {
var type;
if (_typeof(types) === 'object') {
for (type in types) {
if (Object.prototype.hasOwnProperty.call(types, type)) {
this.off(type, types[type]);
}
}
return this;
}
if (typeof types === 'undefined') {
this.emitter.off('enter');
this.emitter.off('leave');
} else {
this.emitter.off(types, fn);
}
return this;
}
}, {
key: "isMatched",
value: function isMatched() {
return this.mql.matches;
}
}, {
key: "destroy",
value: function destroy() {
this.emitter.off('enter');
this.emitter.off('leave');
}
}]);
return MediaQuery;
}();
var MediaBuilder = {
min: function min(_min) {
var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
return "(min-width: ".concat(_min).concat(unit, ")");
},
max: function max(_max) {
var unit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'px';
return "(max-width: ".concat(_max).concat(unit, ")");
},
between: function between(min, max) {
var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'px';
return "(min-width: ".concat(min).concat(unit, ") and (max-width: ").concat(max).concat(unit, ")");
},
get: function get(min, max) {
var unit = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'px';
if (min === 0) {
return this.max(max, unit);
}
if (max === Infinity) {
return this.min(min, unit);
}
return this.between(min, max, unit);
}
};
var Viewport =
/*#__PURE__*/
function (_MediaQuery) {
_inherits(Viewport, _MediaQuery);
function Viewport(name) {
var _this;
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
var unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'px';
_classCallCheck(this, Viewport);
var media = MediaBuilder.get(min, max, unit);
_this = _possibleConstructorReturn(this, _getPrototypeOf(Viewport).call(this, media));
_this.name = name;
_this.min = min;
_this.max = max;
_this.unit = unit;
return _this;
}
_createClass(Viewport, [{
key: "destroy",
value: function destroy() {
this.off();
}
}]);
return Viewport;
}(MediaQuery);
var Size =
/*#__PURE__*/
function (_Viewport) {
_inherits(Size, _Viewport);
function Size(name) {
var _this2;
var min = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
var max = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Infinity;
var unit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'px';
_classCallCheck(this, Size);
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(Size).call(this, name, min, max, unit));
_this2.changeListener = function () {
if (_this2.isMatched()) {
ChangeEvent.trigger(_assertThisInitialized(_assertThisInitialized(_this2)));
}
};
if (_this2.isMatched()) {
ChangeEvent.current = _assertThisInitialized(_assertThisInitialized(_this2));
}
_this2.mql.addListener(_this2.changeListener);
return _this2;
}
_createClass(Size, [{
key: "destroy",
value: function destroy() {
this.mql.removeListener(this.changeHander);
_get(_getPrototypeOf(Size.prototype), "destroy", this).call(this);
}
}]);
return Size;
}(Viewport);
var resolveName = function resolveName(name) {
name = name.trim();
if (/^([\w\d]+)$/.test(name)) {
return {
at: name
};
} else if (/^([\w\d]+)\+$/.test(name)) {
return {
from: name.replace(/\+$/, '')
};
} else if (/^([\w\d]+)-$/.test(name)) {
return {
to: name.replace(/-$/, '')
};
} else if (/^([\w\d]+)-([\w\d]+)$/.test(name)) {
return {
from: name.replace(/-([\w\d]+)$/, ''),
to: name.replace(/^([\w\d]+)-/, '')
};
}
return {};
};
var getName = function getName(obj) {
var at = obj.at,
from = obj.from,
to = obj.to;
if (at) {
return at;
}
if (from && to) {
return "".concat(from, "-").concat(to);
}
if (from) {
return "".concat(from, "+");
}
if (to) {
return "".concat(to, "-");
}
return null;
};
var sizes = {};
var viewports = {};
var _Breakpoints2 = function Breakpoints() {
var _Breakpoints;
(_Breakpoints = _Breakpoints2).define.apply(_Breakpoints, arguments);
};
_Breakpoints2.defaults = DEFAULTS;
_Breakpoints2 = utils.merge(_Breakpoints2, {
defined: false,
init: function init() {
if (!this.defined) {
this.define.apply(this, arguments);
}
},
define: function define(values) {
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
// if(typeof values === 'undefined' && this.defined) {
// return
// }
if (this.defined) {
this.destroy();
}
if (!values) {
values = _Breakpoints2.defaults;
}
this.options = utils.merge(options, {
unit: 'px'
});
for (var size in values) {
if (Object.prototype.hasOwnProperty.call(values, size)) {
sizes[size] = new Size(size, values[size].min, values[size].max, this.options.unit);
}
}
this.defined = true;
},
destroy: function destroy() {
utils.each(sizes, function (name, size) {
size.destroy();
});
sizes = {};
viewports = {};
ChangeEvent.current = null;
},
is: function is$$1(size) {
var breakpoint = this.get(size);
if (!breakpoint) {
return null;
}
return breakpoint.isMatched();
},
/* get all size name */
all: function all() {
var names = [];
utils.each(sizes, function (name) {
names.push(name);
});
return names;
},
getSize: function getSize(name) {
if (Object.prototype.hasOwnProperty.call(sizes, name)) {
return sizes[name];
}
return null;
},
getViewport: function getViewport(name) {
if (Object.prototype.hasOwnProperty.call(viewports, name)) {
return viewports[name];
}
return null;
},
get: function get(name) {
if (is.isString(name)) {
name = name.trim();
} else if (is.isObject(name)) {
name = getName(name);
}
var viewport = this.getSize(name) || this.getViewport(name);
if (viewport) {
return viewport;
}
var _resolveName = resolveName(name),
at = _resolveName.at,
from = _resolveName.from,
to = _resolveName.to;
var unit = this.options.unit;
var max = null;
var min = null;
var size;
if (at) {
size = this.getSize(at);
if (size) {
min = size.min;
max = size.max;
}
} else if (from && to) {
var fromSize = this.getSize(from);
var toSize = this.getSize(to);
if (fromSize && toSize) {
min = fromSize.min;
max = toSize.max;
}
} else if (from) {
size = this.getSize(from);
if (size) {
min = size.min;
max = Infinity;
}
} else if (to) {
size = this.getSize(to);
if (size) {
min = 0;
max = size.max;
}
}
if (!is.isNull(min) && _typeof(!is.isNull(max))) {
viewports[name] = new Viewport(name, min, max, unit);
return viewports[name];
}
return null;
},
getMin: function getMin(name) {
var obj = this.get(name);
if (obj) {
return obj.min;
}
return null;
},
getMax: function getMax(name) {
var obj = this.get(name);
if (obj) {
return obj.max;
}
return null;
},
current: function current() {
return ChangeEvent.current;
},
getMedia: function getMedia(name) {
var obj = this.get(name);
if (obj) {
return obj.media;
}
return null;
},
on: function on(size, types, data, fn) {
var one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
if (size === 'change') {
fn = data;
data = types;
return ChangeEvent.on(data, fn, one);
}
var obj = this.get(size);
if (obj) {
obj.on(types, data, fn, one);
}
return this;
},
one: function one(size, types, data, fn) {
return this.on(size, types, data, fn, true);
},
off: function off(size, types, fn) {
if (size === 'change') {
return ChangeEvent.off(types);
}
var obj = this.get(size);
if (obj) {
obj.off(types, fn);
}
return this;
},
at: function at(size, types, data, fn) {
var one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
var name = getName({
at: size
});
return this.on(name, types, data, fn, one);
},
from: function from(size, types, data, fn) {
var one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
return this.on({
from: size
}, types, data, fn, one);
},
to: function to(size, types, data, fn) {
var one = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
return this.on({
to: size
}, types, data, fn, one);
},
between: function between(from, to, types, data, fn) {
var one = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;
return this.on({
from: from,
to: to
}, types, data, fn, one);
}
});
var _Breakpoints2$1 = _Breakpoints2;
return _Breakpoints2$1;
})));
undefined
/*!
* @pluginjs/breakpoints v0.7.8 (https://pluginjs.com)
* @pluginjs/breakpoints v0.7.9 (https://pluginjs.com)
* Copyright 2019 Creation Studio Limited
* Released under the GPL-3.0 License.
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@pluginjs/is"),require("@pluginjs/simple-emitter"),require("@pluginjs/utils")):"function"==typeof define&&define.amd?define(["@pluginjs/is","@pluginjs/simple-emitter","@pluginjs/utils"],e):t["@pluginjs/breakpoints"]=e(t["@pluginjs/is"],t["@pluginjs/simple-emitter"],t["@pluginjs/utils"])}(this,function(t,e,n){"use strict";function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function o(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function u(t,e,n){return e&&o(t.prototype,e),n&&o(t,n),t}function s(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&a(t,e)}function c(t){return(c=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function a(t,e){return(a=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function f(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?f(t):e}function h(t,e,n){return(h="undefined"!=typeof Reflect&&Reflect.get?Reflect.get:function(t,e,n){var i=function(t,e){for(;!Object.prototype.hasOwnProperty.call(t,e)&&null!==(t=c(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(n):r.value}})(t,e,n||t)}e=e&&e.hasOwnProperty("default")?e.default:e;var d={xs:{min:0,max:575},sm:{min:576,max:767},md:{min:768,max:991},lg:{min:992,max:1199},xl:{min:1200,max:1/0}},p={current:null,listeners:[],trigger:function(t){var e=this,n=this.current;this.current=t,this.listeners.forEach(function(i,r){i.listener.call({current:t,previous:n},i.data),i.one&&delete e.listeners[r]})},one:function(t,e){return this.on(t,e,!0)},on:function(e,n){var i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];void 0===n&&t.isFunction(e)&&(n=e,e=void 0),t.isFunction(n)&&this.listeners.push({data:e,listener:n,one:i})},off:function(t){this.listeners=void 0===t?[]:this.listeners.filter(function(e){return e.listener!==t})}},m=function(){function n(t){r(this,n),this.media=t,this.initialize()}return u(n,[{key:"initialize",value:function(){var t=this;this.emitter=new e,this.mql=window.matchMedia&&window.matchMedia(this.media)||{matches:!1,media:this.media,addListener:function(){},removeListener:function(){}};var n=this;this.mqlListener=function(e){var i=e.matches?"enter":"leave";t.emitter.emit(i,n)},this.mql.addListener(this.mqlListener)}},{key:"on",value:function(e,n,r){var o=arguments.length>3&&void 0!==arguments[3]&&arguments[3];if("object"===i(e)){for(var u in e)Object.prototype.hasOwnProperty.call(e,u)&&this.on(u,n,e[u],o);return this}return void 0===r&&t.isFunction(n)&&(r=n,n=void 0),t.isFunction(r)?(o?this.emitter.once(e,r,n):this.emitter.on(e,r,n),this):this}},{key:"one",value:function(t,e,n){return this.on(t,e,n,!0)}},{key:"off",value:function(t,e){var n;if("object"===i(t)){for(n in t)Object.prototype.hasOwnProperty.call(t,n)&&this.off(n,t[n]);return this}return void 0===t?(this.emitter.off("enter"),this.emitter.off("leave")):this.emitter.off(t,e),this}},{key:"isMatched",value:function(){return this.mql.matches}},{key:"destroy",value:function(){this.emitter.off("enter"),this.emitter.off("leave")}}]),n}(),v={min:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"px";return"(min-width: ".concat(t).concat(e,")")},max:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"px";return"(max-width: ".concat(t).concat(e,")")},between:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"px";return"(min-width: ".concat(t).concat(n,") and (max-width: ").concat(e).concat(n,")")},get:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"px";return 0===t?this.max(e,n):e===1/0?this.min(t,n):this.between(t,e,n)}},g=function(t){function e(t){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"px";r(this,e);var s=v.get(i,o,u);return(n=l(this,c(e).call(this,s))).name=t,n.min=i,n.max=o,n.unit=u,n}return s(e,m),u(e,[{key:"destroy",value:function(){this.off()}}]),e}(),y=function(t){function e(t){var n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1/0,u=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"px";return r(this,e),(n=l(this,c(e).call(this,t,i,o,u))).changeListener=function(){n.isMatched()&&p.trigger(f(f(n)))},n.isMatched()&&(p.current=f(f(n))),n.mql.addListener(n.changeListener),n}return s(e,g),u(e,[{key:"destroy",value:function(){this.mql.removeListener(this.changeHander),h(c(e.prototype),"destroy",this).call(this)}}]),e}(),w=function(t){var e=t.at,n=t.from,i=t.to;return e||(n&&i?"".concat(n,"-").concat(i):n?"".concat(n,"+"):i?"".concat(i,"-"):null)},b={},j={},x=function(){var t;(t=x).define.apply(t,arguments)};return x.defaults=d,x=n.merge(x,{defined:!1,init:function(){this.defined||this.define.apply(this,arguments)},define:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};for(var i in this.defined&&this.destroy(),t||(t=x.defaults),this.options=n.merge(e,{unit:"px"}),t)Object.prototype.hasOwnProperty.call(t,i)&&(b[i]=new y(i,t[i].min,t[i].max,this.options.unit));this.defined=!0},destroy:function(){n.each(b,function(t,e){e.destroy()}),b={},j={},p.current=null},is:function(t){var e=this.get(t);return e?e.isMatched():null},all:function(){var t=[];return n.each(b,function(e){t.push(e)}),t},getSize:function(t){return Object.prototype.hasOwnProperty.call(b,t)?b[t]:null},getViewport:function(t){return Object.prototype.hasOwnProperty.call(j,t)?j[t]:null},get:function(e){t.isString(e)?e=e.trim():t.isObject(e)&&(e=w(e));var n=this.getSize(e)||this.getViewport(e);if(n)return n;var r,o=function(t){return t=t.trim(),/^([\w\d]+)$/.test(t)?{at:t}:/^([\w\d]+)\+$/.test(t)?{from:t.replace(/\+$/,"")}:/^([\w\d]+)-$/.test(t)?{to:t.replace(/-$/,"")}:/^([\w\d]+)-([\w\d]+)$/.test(t)?{from:t.replace(/-([\w\d]+)$/,""),to:t.replace(/^([\w\d]+)-/,"")}:{}}(e),u=o.at,s=o.from,c=o.to,a=this.options.unit,f=null,l=null;if(u)(r=this.getSize(u))&&(l=r.min,f=r.max);else if(s&&c){var h=this.getSize(s),d=this.getSize(c);h&&d&&(l=h.min,f=d.max)}else s?(r=this.getSize(s))&&(l=r.min,f=1/0):c&&(r=this.getSize(c))&&(l=0,f=r.max);return!t.isNull(l)&&i(!t.isNull(f))?(j[e]=new g(e,l,f,a),j[e]):null},getMin:function(t){var e=this.get(t);return e?e.min:null},getMax:function(t){var e=this.get(t);return e?e.max:null},current:function(){return p.current},getMedia:function(t){var e=this.get(t);return e?e.media:null},on:function(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];if("change"===t)return i=n,n=e,p.on(n,i,r);var o=this.get(t);return o&&o.on(e,n,i,r),this},one:function(t,e,n,i){return this.on(t,e,n,i,!0)},off:function(t,e,n){if("change"===t)return p.off(e);var i=this.get(t);return i&&i.off(e,n),this},at:function(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4],o=w({at:t});return this.on(o,e,n,i,r)},from:function(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this.on({from:t},e,n,i,r)},to:function(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]&&arguments[4];return this.on({to:t},e,n,i,r)},between:function(t,e,n,i,r){var o=arguments.length>5&&void 0!==arguments[5]&&arguments[5];return this.on({from:t,to:e},n,i,r,o)}})});
undefined

@@ -14,3 +14,3 @@ {

},
"version": "0.7.8",
"version": "0.7.9",
"category": "utils",

@@ -37,12 +37,12 @@ "main": "dist/breakpoints.common.js",

"dependencies": {
"@pluginjs/emitter": "^0.7.8",
"@pluginjs/factory": "^0.7.8",
"@pluginjs/is": "^0.7.7",
"@pluginjs/simple-emitter": "^0.7.7",
"@pluginjs/utils": "^0.7.8"
"@pluginjs/emitter": "^0.7.9",
"@pluginjs/factory": "^0.7.9",
"@pluginjs/is": "^0.7.8",
"@pluginjs/simple-emitter": "^0.7.8",
"@pluginjs/utils": "^0.7.9"
},
"devDependencies": {
"@babel/core": "^7.4.3",
"@pluginjs/browserslist-config": "^1.2.4",
"@pluginjs/cli": "^0.7.7",
"@babel/core": "^7.4.4",
"@pluginjs/browserslist-config": "^1.2.5",
"@pluginjs/cli": "^0.7.8",
"babel-jest": "*",

@@ -72,4 +72,3 @@ "jest": "*",

"extends @pluginjs/browserslist-config"
],
"gitHead": "290fd3939aca081ceab305e0d4157ee0d52b45bf"
]
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc