quasar-framework
Version:
Simultaneously build desktop/mobile SPA websites & phone/tablet apps with VueJS
2,157 lines (1,911 loc) • 542 kB
JavaScript
/*!
* Quasar Framework v0.15.3
* (c) 2016-present Razvan Stoenescu
* Released under the MIT License.
*/
var version = "0.15.3";
function offset (el) {
if (el === window) {
return {top: 0, left: 0}
}
var ref = el.getBoundingClientRect();
var top = ref.top;
var left = ref.left;
return {top: top, left: left}
}
function style (el, property) {
return window.getComputedStyle(el).getPropertyValue(property)
}
function height (el) {
if (el === window) {
return viewport().height
}
return parseFloat(style(el, 'height'))
}
function width (el) {
if (el === window) {
return viewport().width
}
return parseFloat(style(el, 'width'))
}
function css (element, css) {
var style = element.style;
Object.keys(css).forEach(function (prop) {
style[prop] = css[prop];
});
}
function viewport () {
var
e = window,
a = 'inner';;
if (!('innerWidth' in window)) {
a = 'client';
e = document.documentElement || document.body;
}
return {
width: e[a + 'Width'],
height: e[a + 'Height']
}
}
function ready (fn) {
if (typeof fn !== 'function') {
return
}
if (document.readyState === 'complete') {
return fn()
}
document.addEventListener('DOMContentLoaded', fn, false);
}
var prefix = ['-webkit-', '-moz-', '-ms-', '-o-'];
function cssTransform (val) {
var o = {transform: val};
prefix.forEach(function (p) {
o[p + 'transform'] = val;
});
return o
}
var dom = Object.freeze({
offset: offset,
style: style,
height: height,
width: width,
css: css,
viewport: viewport,
ready: ready,
cssTransform: cssTransform
});
/* eslint-disable no-useless-escape */
/* eslint-disable no-unused-expressions */
/* eslint-disable no-mixed-operators */
var isSSR = typeof window === 'undefined';
function getUserAgent () {
return (navigator.userAgent || navigator.vendor || window.opera).toLowerCase()
}
function getMatch (userAgent, platformMatch) {
var match = /(edge)\/([\w.]+)/.exec(userAgent) ||
/(opr)[\/]([\w.]+)/.exec(userAgent) ||
/(vivaldi)[\/]([\w.]+)/.exec(userAgent) ||
/(chrome)[\/]([\w.]+)/.exec(userAgent) ||
/(iemobile)[\/]([\w.]+)/.exec(userAgent) ||
/(version)(applewebkit)[\/]([\w.]+).*(safari)[\/]([\w.]+)/.exec(userAgent) ||
/(webkit)[\/]([\w.]+).*(version)[\/]([\w.]+).*(safari)[\/]([\w.]+)/.exec(userAgent) ||
/(webkit)[\/]([\w.]+)/.exec(userAgent) ||
/(opera)(?:.*version|)[\/]([\w.]+)/.exec(userAgent) ||
/(msie) ([\w.]+)/.exec(userAgent) ||
userAgent.indexOf('trident') >= 0 && /(rv)(?::| )([\w.]+)/.exec(userAgent) ||
userAgent.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(userAgent) ||
[];
return {
browser: match[5] || match[3] || match[1] || '',
version: match[2] || match[4] || '0',
versionNumber: match[4] || match[2] || '0',
platform: platformMatch[0] || ''
}
}
function getPlatformMatch (userAgent) {
return /(ipad)/.exec(userAgent) ||
/(ipod)/.exec(userAgent) ||
/(windows phone)/.exec(userAgent) ||
/(iphone)/.exec(userAgent) ||
/(kindle)/.exec(userAgent) ||
/(silk)/.exec(userAgent) ||
/(android)/.exec(userAgent) ||
/(win)/.exec(userAgent) ||
/(mac)/.exec(userAgent) ||
/(linux)/.exec(userAgent) ||
/(cros)/.exec(userAgent) ||
/(playbook)/.exec(userAgent) ||
/(bb)/.exec(userAgent) ||
/(blackberry)/.exec(userAgent) ||
[]
}
function getPlatform () {
var
userAgent = getUserAgent(),
platformMatch = getPlatformMatch(userAgent),
matched = getMatch(userAgent, platformMatch),
browser = {};;;;
if (matched.browser) {
browser[matched.browser] = true;
browser.version = matched.version;
browser.versionNumber = parseInt(matched.versionNumber, 10);
}
if (matched.platform) {
browser[matched.platform] = true;
}
// These are all considered mobile platforms, meaning they run a mobile browser
if (browser.android || browser.bb || browser.blackberry || browser.ipad || browser.iphone ||
browser.ipod || browser.kindle || browser.playbook || browser.silk || browser['windows phone']) {
browser.mobile = true;
}
// Set iOS if on iPod, iPad or iPhone
if (browser.ipod || browser.ipad || browser.iphone) {
browser.ios = true;
}
if (browser['windows phone']) {
browser.winphone = true;
delete browser['windows phone'];
}
// These are all considered desktop platforms, meaning they run a desktop browser
if (browser.cros || browser.mac || browser.linux || browser.win) {
browser.desktop = true;
}
// Chrome, Opera 15+, Vivaldi and Safari are webkit based browsers
if (browser.chrome || browser.opr || browser.safari || browser.vivaldi) {
browser.webkit = true;
}
// IE11 has a new token so we will assign it msie to avoid breaking changes
if (browser.rv || browser.iemobile) {
matched.browser = 'ie';
browser.ie = true;
}
// Edge is officially known as Microsoft Edge, so rewrite the key to match
if (browser.edge) {
matched.browser = 'edge';
browser.edge = true;
}
// Blackberry browsers are marked as Safari on BlackBerry
if (browser.safari && browser.blackberry || browser.bb) {
matched.browser = 'blackberry';
browser.blackberry = true;
}
// Playbook browsers are marked as Safari on Playbook
if (browser.safari && browser.playbook) {
matched.browser = 'playbook';
browser.playbook = true;
}
// Opera 15+ are identified as opr
if (browser.opr) {
matched.browser = 'opera';
browser.opera = true;
}
// Stock Android browsers are marked as Safari on Android.
if (browser.safari && browser.android) {
matched.browser = 'android';
browser.android = true;
}
// Kindle browsers are marked as Safari on Kindle
if (browser.safari && browser.kindle) {
matched.browser = 'kindle';
browser.kindle = true;
}
// Kindle Silk browsers are marked as Safari on Kindle
if (browser.safari && browser.silk) {
matched.browser = 'silk';
browser.silk = true;
}
if (browser.vivaldi) {
matched.browser = 'vivaldi';
browser.vivaldi = true;
}
// Assign the name and platform variable
browser.name = matched.browser;
browser.platform = matched.platform;
if (window && window.process && window.process.versions && window.process.versions.electron) {
browser.electron = true;
}
else if (document.location.href.indexOf('chrome-extension://') === 0) {
browser.chromeExt = true;
}
else if (
window._cordovaNative ||
window.cordova ||
document.location.href.indexOf('http://') === -1
) {
browser.cordova = true;
}
return browser
}
var Platform = {
__installed: false,
install: function install (ref) {
var $q = ref.$q;
if (this.__installed) { return }
this.__installed = true;
if (isSSR) {
Platform.is = { ssr: true };
Platform.has = {
touch: false,
webStorage: false
};
Platform.within = { iframe: false };
}
else {
var webStorage;
try {
if (window.localStorage) {
webStorage = true;
}
}
catch (e) {
webStorage = false;
}
Platform.is = getPlatform();
Platform.has = {
touch: (function () { return !!('ontouchstart' in document.documentElement) || window.navigator.msMaxTouchPoints > 0; })(),
webStorage: webStorage
};
Platform.within = {
iframe: window.self !== window.top
};
}
$q.platform = Platform;
}
};
var History = {
__history: [],
add: function () {},
remove: function () {},
__installed: false,
install: function install () {
var this$1 = this;
if (this.__installed || !Platform.is.cordova || isSSR) {
return
}
this.__installed = true;
this.add = function (definition) {
this$1.__history.push(definition);
};
this.remove = function (definition) {
var index = this$1.__history.indexOf(definition);
if (index >= 0) {
this$1.__history.splice(index, 1);
}
};
document.addEventListener('deviceready', function () {
document.addEventListener('backbutton', function () {
if (this$1.__history.length) {
this$1.__history.pop().handler();
}
else {
window.history.back();
}
}, false);
});
}
}
/* eslint-disable no-extend-native, one-var, no-self-compare */
if (!Array.prototype.includes) {
Array.prototype.includes = function (searchEl, startFrom) {
var O = Object(this);
var len = parseInt(O.length, 10) || 0;
if (len === 0) {
return false
}
var n = parseInt(startFrom, 10) || 0;
var k;
if (n >= 0) {
k = n;
}
else {
k = len + n;
if (k < 0) { k = 0; }
}
var curEl;
while (k < len) {
curEl = O[k];
if (searchEl === curEl ||
(searchEl !== searchEl && curEl !== curEl)) { // NaN !== NaN
return true
}
k++;
}
return false
};
}
if (!String.prototype.startsWith) {
String.prototype.startsWith = function (str, position) {
position = position || 0;
return this.substr(position, str.length) === str
};
}
if (!String.prototype.endsWith) {
String.prototype.endsWith = function (str, position) {
var subjectString = this.toString();
if (typeof position !== 'number' || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
position = subjectString.length;
}
position -= str.length;
var lastIndex = subjectString.indexOf(str, position);
return lastIndex !== -1 && lastIndex === position
};
}
if (!isSSR && typeof Element.prototype.matches !== 'function') {
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.webkitMatchesSelector || function matches (selector) {
var
element = this,
elements = (element.document || element.ownerDocument).querySelectorAll(selector),
index = 0;;;
while (elements[index] && elements[index] !== element) {
++index;
}
return Boolean(elements[index])
};
}
if (!isSSR && typeof Element.prototype.closest !== 'function') {
Element.prototype.closest = function closest (selector) {
var el = this;
while (el && el.nodeType === 1) {
if (el.matches(selector)) {
return el
}
el = el.parentNode;
}
return null
};
}
if (!Array.prototype.find) {
Object.defineProperty(Array.prototype, 'find', {
value: function value (predicate) {
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined')
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function')
}
var value;
var
list = Object(this),
length = list.length >>> 0,
thisArg = arguments[1];;;
for (var i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value
}
}
return undefined
}
});
}
var langEn = {
lang: 'en-us',
label: {
clear: 'Clear',
ok: 'OK',
cancel: 'Cancel',
close: 'Close',
set: 'Set',
select: 'Select',
reset: 'Reset',
remove: 'Remove',
update: 'Update',
create: 'Create',
search: 'Search',
filter: 'Filter',
refresh: 'Refresh'
},
date: {
days: 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
daysShort: 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
months: 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
monthsShort: 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
firstDayOfWeek: 0, // 0-6, 0 - Sunday, 1 Monday, ...
format24h: false
},
pullToRefresh: {
pull: 'Pull down to refresh',
release: 'Release to refresh',
refresh: 'Refreshing...'
},
table: {
noData: 'No data available',
noResults: 'No matching records found',
loading: 'Loading...',
selectedRows: function (rows) {
return rows === 1
? '1 selected row.'
: (rows === 0 ? 'No' : rows) + ' selected rows.'
},
rowsPerPage: 'Rows per page:',
allRows: 'All',
pagination: function (start, end, total) {
return start + '-' + end + ' of ' + total
},
columns: 'Columns'
},
editor: {
url: 'URL',
bold: 'Bold',
italic: 'Italic',
strikethrough: 'Strikethrough',
underline: 'Underline',
unorderedList: 'Unordered List',
orderedList: 'Ordered List',
subscript: 'Subscript',
superscript: 'Superscript',
hyperlink: 'Hyperlink',
toggleFullscreen: 'Toggle Fullscreen',
quote: 'Quote',
left: 'Left align',
center: 'Center align',
right: 'Right align',
justify: 'Justify align',
print: 'Print',
outdent: 'Decrease indentation',
indent: 'Increase indentation',
removeFormat: 'Remove formatting',
formatting: 'Formatting',
fontSize: 'Font Size',
align: 'Align',
hr: 'Insert Horizontal Rule',
undo: 'Undo',
redo: 'Redo',
header1: 'Header 1',
header2: 'Header 2',
header3: 'Header 3',
header4: 'Header 4',
header5: 'Header 5',
header6: 'Header 6',
paragraph: 'Paragraph',
code: 'Code',
size1: 'Very small',
size2: 'A bit small',
size3: 'Normal',
size4: 'Medium-large',
size5: 'Big',
size6: 'Very big',
size7: 'Maximum',
defaultFont: 'Default Font'
},
tree: {
noNodes: 'No nodes available',
noResults: 'No matching nodes found'
}
}
var i18n = {
__installed: false,
install: function install (ref) {
var this$1 = this;
var $q = ref.$q;
var Vue = ref.Vue;
var lang = ref.lang;
if (this.__installed) { return }
this.__installed = true;
this.set = function (lang) {
if ( lang === void 0 ) lang = langEn;
lang.set = this$1.set;
lang.getLocale = this$1.getLocale;
if ($q.i18n) {
$q.i18n = lang;
}
else {
Vue.util.defineReactive($q, 'i18n', lang);
}
this$1.name = lang.lang;
this$1.lang = lang;
};
this.set(lang);
},
getLocale: function getLocale () {
var val =
navigator.language ||
navigator.languages[0] ||
navigator.browserLanguage ||
navigator.userLanguage ||
navigator.systemLanguage;
if (val) {
return val.toLowerCase()
}
}
}
var materialIcons = {
name: 'material',
type: {
positive: 'check_circle',
negative: 'warning',
info: 'info',
warning: 'priority_high'
},
arrow: {
up: 'arrow_upward',
right: 'arrow_forward',
down: 'arrow_downward',
left: 'arrow_back'
},
chevron: {
left: 'chevron_left',
right: 'chevron_right'
},
pullToRefresh: {
arrow: 'arrow_downward',
refresh: 'refresh'
},
search: {
icon: 'search',
clear: 'cancel',
clearInverted: 'clear'
},
carousel: {
left: 'chevron_left',
right: 'chevron_right',
quickNav: 'lens'
},
checkbox: {
checked: {
ios: 'check_circle',
mat: 'check_box'
},
unchecked: {
ios: 'radio_button_unchecked',
mat: 'check_box_outline_blank'
},
indeterminate: {
ios: 'remove_circle_outline',
mat: 'indeterminate_check_box'
}
},
chip: {
close: 'cancel'
},
chipsInput: {
add: 'send'
},
collapsible: {
icon: 'keyboard_arrow_down'
},
datetime: {
arrowLeft: 'chevron_left',
arrowRight: 'chevron_right'
},
editor: {
bold: 'format_bold',
italic: 'format_italic',
strikethrough: 'strikethrough_s',
underline: 'format_underlined',
unorderedList: 'format_list_bulleted',
orderedList: 'format_list_numbered',
subscript: 'vertical_align_bottom',
superscript: 'vertical_align_top',
hyperlink: 'link',
toggleFullscreen: 'fullscreen',
quote: 'format_quote',
left: 'format_align_left',
center: 'format_align_center',
right: 'format_align_right',
justify: 'format_align_justify',
print: 'print',
outdent: 'format_indent_decrease',
indent: 'format_indent_increase',
removeFormat: 'format_clear',
formatting: 'text_format',
fontSize: 'format_size',
align: 'format_align_left',
hr: 'remove',
undo: 'undo',
redo: 'redo',
header: 'format_size',
code: 'code',
size: 'format_size',
font: 'font_download'
},
fab: {
icon: 'add',
activeIcon: 'close'
},
input: {
showPass: 'visibility',
hidePass: 'visibility_off',
showNumber: 'keyboard',
hideNumber: 'keyboard_hide',
clear: 'cancel',
clearInverted: 'clear',
dropdown: 'arrow_drop_down'
},
pagination: {
first: 'first_page',
prev: 'keyboard_arrow_left',
next: 'keyboard_arrow_right',
last: 'last_page'
},
radio: {
checked: {
ios: 'check',
mat: 'radio_button_checked'
},
unchecked: {
ios: '',
mat: 'radio_button_unchecked'
}
},
rating: {
icon: 'grade'
},
stepper: {
done: 'check',
active: 'edit',
error: 'warning'
},
tabs: {
left: 'chevron_left',
right: 'chevron_right'
},
table: {
arrowUp: 'arrow_upward',
warning: 'warning',
prevPage: 'chevron_left',
nextPage: 'chevron_right'
},
tree: {
icon: 'play_arrow'
},
uploader: {
done: 'done',
clear: 'cancel',
clearInverted: 'clear',
add: 'add',
upload: 'cloud_upload',
expand: 'keyboard_arrow_down',
file: 'insert_drive_file'
}
}
var icons = {
__installed: false,
install: function install (ref) {
var this$1 = this;
var $q = ref.$q;
var Vue = ref.Vue;
var iconSet = ref.iconSet;
if (this.__installed) { return }
this.__installed = true;
this.set = function (iconDef) {
if ( iconDef === void 0 ) iconDef = materialIcons;
iconDef.set = this$1.set;
if ($q.icon) {
$q.icon = iconDef;
}
else {
Vue.util.defineReactive($q, 'icon', iconDef);
}
this$1.name = iconDef.name;
this$1.def = iconDef;
};
this.set(iconSet);
}
}
function bodyInit () {
var cls = [
"ios",
Platform.is.desktop ? 'desktop' : 'mobile',
Platform.has.touch ? 'touch' : 'no-touch',
("platform-" + (Platform.is.ios ? 'ios' : 'mat'))
];
Platform.within.iframe && cls.push('within-iframe');
Platform.is.cordova && cls.push('cordova');
Platform.is.electron && cls.push('electron');
if (Platform.is.ie && Platform.is.versionNumber === 11) {
cls.forEach(function (c) { return document.body.classList.add(c); });
}
else {
document.body.classList.add.apply(document.body.classList, cls);
}
if (Platform.is.ios) {
// needed for iOS button active state
document.body.addEventListener('touchstart', function () {});
}
}
function install (_Vue, opts) {
if ( opts === void 0 ) opts = {};
if (this.__installed) {
return
}
this.__installed = true;
var $q = {
version: version,
theme: "ios"
};
// required plugins
Platform.install({ $q: $q });
History.install();
i18n.install({ $q: $q, Vue: _Vue, lang: opts.i18n });
icons.install({ $q: $q, Vue: _Vue, iconSet: opts.iconSet });
if (!isSSR) {
ready(bodyInit);
}
if (opts.directives) {
Object.keys(opts.directives).forEach(function (key) {
var d = opts.directives[key];
if (d.name !== undefined && !d.name.startsWith('q-')) {
_Vue.directive(d.name, d);
}
});
}
if (opts.components) {
Object.keys(opts.components).forEach(function (key) {
var c = opts.components[key];
if (c.name !== undefined && c.name.startsWith('q-')) {
_Vue.component(c.name, c);
}
});
}
if (opts.plugins) {
Object.keys(opts.plugins).forEach(function (key) {
var p = opts.plugins[key];
if (typeof p.install === 'function') {
p.install({ $q: $q, Vue: _Vue });
}
});
}
_Vue.prototype.$q = $q;
}
var handlers = [];
var EscapeKey = {
__installed: false,
__install: function __install () {
this.__installed = true;
window.addEventListener('keyup', function (evt) {
if (handlers.length === 0) {
return
}
if (evt.which === 27 || evt.keyCode === 27) {
handlers[handlers.length - 1]();
}
});
},
register: function register (handler) {
if (Platform.is.desktop) {
if (!this.__installed) {
this.__install();
}
handlers.push(handler);
}
},
pop: function pop () {
if (Platform.is.desktop) {
handlers.pop();
}
}
}
var
toString = Object.prototype.toString,
hasOwn = Object.prototype.hasOwnProperty,
class2type = {};;;
'Boolean Number String Function Array Date RegExp Object'.split(' ').forEach(function (name) {
class2type['[object ' + name + ']'] = name.toLowerCase();
});
function type (obj) {
return obj === null ? String(obj) : class2type[toString.call(obj)] || 'object'
}
function isPlainObject (obj) {
if (!obj || type(obj) !== 'object') {
return false
}
if (obj.constructor &&
!hasOwn.call(obj, 'constructor') &&
!hasOwn.call(obj.constructor.prototype, 'isPrototypeOf')) {
return false
}
var key;
for (key in obj) {}
return key === undefined || hasOwn.call(obj, key)
}
function extend () {
var arguments$1 = arguments;
var
options, name, src, copy, copyIsArray, clone,
target = arguments[0] || {},
i = 1,
length = arguments.length,
deep = false;;;;;;;;;;
if (typeof target === 'boolean') {
deep = target;
target = arguments[1] || {};
i = 2;
}
if (Object(target) !== target && type(target) !== 'function') {
target = {};
}
if (length === i) {
target = this;
i--;
}
for (; i < length; i++) {
if ((options = arguments$1[i]) !== null) {
for (name in options) {
src = target[name];
copy = options[name];
if (target === copy) {
continue
}
if (deep && copy && (isPlainObject(copy) || (copyIsArray = type(copy) === 'array'))) {
if (copyIsArray) {
copyIsArray = false;
clone = src && type(src) === 'array' ? src : [];
}
else {
clone = src && isPlainObject(src) ? src : {};
}
target[name] = extend(deep, clone, copy);
}
else if (copy !== undefined) {
target[name] = copy;
}
}
}
}
return target
}
/* eslint prefer-promise-reject-errors: 0 */
var ModelToggleMixin = {
props: {
value: Boolean
},
data: function data () {
return {
showing: false
}
},
watch: {
value: function value (val) {
var this$1 = this;
if (this.disable && val) {
this.$emit('input', false);
return
}
this.$nextTick(function () {
if (this$1.value !== this$1.showing) {
this$1[val ? 'show' : 'hide']();
}
});
}
},
methods: {
toggle: function toggle (evt) {
return this[this.showing ? 'hide' : 'show'](evt)
},
show: function show (evt) {
var this$1 = this;
if (this.disable || this.showing) {
return this.showPromise || Promise.resolve(evt)
}
if (this.hidePromise) {
this.hidePromiseReject();
}
this.showing = true;
if (this.value === false) {
this.$emit('input', true);
}
if (this.$options.modelToggle === void 0 || this.$options.modelToggle.history) {
this.__historyEntry = {
handler: this.hide
};
History.add(this.__historyEntry);
}
if (!this.__show) {
this.$emit('show');
return Promise.resolve(evt)
}
this.showPromise = new Promise(function (resolve, reject) {
this$1.showPromiseResolve = function () {
this$1.showPromise = null;
this$1.$emit('show');
resolve(evt);
};
this$1.showPromiseReject = function () {
this$1.showPromise = null;
reject(null); // eslint prefer-promise-reject-errors: 0
};
});
this.__show(evt);
return this.showPromise || Promise.resolve(evt)
},
hide: function hide (evt) {
var this$1 = this;
if (this.disable || !this.showing) {
return this.hidePromise || Promise.resolve(evt)
}
if (this.showPromise) {
this.showPromiseReject();
}
this.showing = false;
if (this.value === true) {
this.$emit('input', false);
}
if (this.__historyEntry) {
History.remove(this.__historyEntry);
this.__historyEntry = null;
}
if (!this.__hide) {
this.$emit('hide');
return Promise.resolve()
}
this.hidePromise = new Promise(function (resolve, reject) {
this$1.hidePromiseResolve = function () {
this$1.hidePromise = null;
this$1.$emit('hide');
resolve();
};
this$1.hidePromiseReject = function () {
this$1.hidePromise = null;
reject(null);
};
});
this.__hide(evt);
return this.hidePromise || Promise.resolve(evt)
}
},
beforeDestroy: function beforeDestroy () {
if (this.showing) {
this.showPromise && this.showPromiseReject();
this.hidePromise && this.hidePromiseReject();
this.$emit('input', false);
this.__hide && this.__hide();
}
}
}
var positions = {
top: 'items-start justify-center with-backdrop',
bottom: 'items-end justify-center with-backdrop',
right: 'items-center justify-end with-backdrop',
left: 'items-center justify-start with-backdrop'
};
var positionCSS = {
maxHeight: '80vh',
height: 'auto',
boxShadow: 'none'
};
function additionalCSS (position) {
var css = {};
if (['left', 'right'].includes(position)) {
css.maxWidth = '90vw';
}
{
if (['left', 'top'].includes(position)) {
css.borderTopLeftRadius = 0;
}
if (['right', 'top'].includes(position)) {
css.borderTopRightRadius = 0;
}
if (['left', 'bottom'].includes(position)) {
css.borderBottomLeftRadius = 0;
}
if (['right', 'bottom'].includes(position)) {
css.borderBottomRightRadius = 0;
}
}
return css
}
var openedModalNumber = 0;
var QModal = {
name: 'q-modal',
mixins: [ModelToggleMixin],
provide: function provide () {
return {
__qmodal: true
}
},
props: {
position: {
type: String,
default: '',
validator: function validator (val) {
return val === '' || ['top', 'bottom', 'left', 'right'].includes(val)
}
},
transition: String,
enterClass: String,
leaveClass: String,
positionClasses: {
type: String,
default: 'flex-center'
},
contentClasses: [Object, Array, String],
contentCss: [Object, Array, String],
noBackdropDismiss: {
type: Boolean,
default: false
},
noEscDismiss: {
type: Boolean,
default: false
},
noRouteDismiss: Boolean,
minimized: Boolean,
maximized: Boolean
},
watch: {
$route: function $route () {
if (!this.noRouteDismiss) {
this.hide();
}
}
},
computed: {
modalClasses: function modalClasses () {
var cls = this.position
? positions[this.position]
: this.positionClasses;
if (this.maximized) {
return ['maximized', cls]
}
else if (this.minimized) {
return ['minimized', cls]
}
return cls
},
transitionProps: function transitionProps () {
if (this.position) {
return { name: ("q-modal-" + (this.position)) }
}
if (this.enterClass === void 0 && this.leaveClass === void 0) {
return { name: this.transition || 'q-modal' }
}
return {
enterActiveClass: this.enterClass,
leaveActiveClass: this.leaveClass
}
},
modalCss: function modalCss () {
if (this.position) {
var css = Array.isArray(this.contentCss)
? this.contentCss
: [this.contentCss];
css.unshift(extend(
{},
positionCSS,
additionalCSS(this.position)
));
return css
}
return this.contentCss
}
},
methods: {
__dismiss: function __dismiss () {
var this$1 = this;
if (this.noBackdropDismiss) {
return
}
this.hide().then(function () {
this$1.$emit('dismiss');
});
},
__show: function __show () {
var this$1 = this;
var body = document.body;
body.appendChild(this.$el);
if (openedModalNumber === 0) {
body.classList.add('with-modal');
}
EscapeKey.register(function () {
if (!this$1.noEscDismiss) {
this$1.hide().then(function () {
this$1.$emit('escape-key');
});
}
});
openedModalNumber++;
var content = this.$refs.content;
content.scrollTop = 0
;['modal-scroll', 'layout-view'].forEach(function (c) {
[].slice.call(content.getElementsByClassName(c)).forEach(function (el) {
el.scrollTop = 0;
});
});
},
__hide: function __hide () {
EscapeKey.pop();
openedModalNumber--;
if (openedModalNumber === 0) {
document.body.classList.remove('with-modal');
}
}
},
mounted: function mounted () {
if (this.value) {
this.show();
}
},
beforeDestroy: function beforeDestroy () {
if (this.$el.parentNode) {
this.$el.parentNode.removeChild(this.$el);
}
},
render: function render (h) {
var this$1 = this;
return h('transition', {
props: this.transitionProps,
on: {
afterEnter: function () {
this$1.showPromise && this$1.showPromiseResolve();
},
enterCancelled: function () {
this$1.showPromise && this$1.showPromiseReject();
},
afterLeave: function () {
this$1.hidePromise && this$1.hidePromiseResolve();
},
leaveCancelled: function () {
this$1.hidePromise && this$1.hidePromiseReject();
}
}
}, [
h('div', {
staticClass: 'modal fullscreen row',
'class': this.modalClasses,
on: {
click: this.__dismiss
},
directives: [{
name: 'show',
value: this.showing
}]
}, [
h('div', {
ref: 'content',
staticClass: 'modal-content scroll',
style: this.modalCss,
'class': this.contentClasses,
on: {
click: function click (e) {
e.stopPropagation();
},
touchstart: function touchstart (e) {
e.stopPropagation();
}
}
}, [ this.$slots.default ])
])
])
}
}
var QModalLayout = {
name: 'q-modal-layout',
inject: {
__qmodal: {
default: function default$1 () {
console.error('QModalLayout needs to be child of QModal');
}
}
},
props: {
headerStyle: [String, Object, Array],
headerClass: [String, Object, Array],
contentStyle: [String, Object, Array],
contentClass: [String, Object, Array],
footerStyle: [String, Object, Array],
footerClass: [String, Object, Array]
},
render: function render (h) {
var child = [];
if (this.$slots.header || ("ios" !== 'ios' && this.$slots.navigation)) {
child.push(h('div', {
staticClass: 'q-layout-header',
style: this.headerStyle,
'class': this.headerClass
}, [
this.$slots.header,
null
]));
}
child.push(h('div', {
staticClass: 'q-modal-layout-content col scroll',
style: this.contentStyle,
'class': this.contentClass
}, [
this.$slots.default
]));
if (this.$slots.footer || ("ios" === 'ios' && this.$slots.navigation)) {
child.push(h('div', {
staticClass: 'q-layout-footer',
style: this.footerStyle,
'class': this.footerClass
}, [
this.$slots.footer,
this.$slots.navigation
]));
}
return h('div', {
staticClass: 'q-modal-layout column absolute-full'
}, child)
}
}
var QIcon = {
name: 'q-icon',
props: {
name: String,
mat: String,
ios: String,
color: String,
size: String
},
computed: {
icon: function icon () {
return this.mat && "ios" === 'mat'
? this.mat
: (this.ios && "ios" === 'ios' ? this.ios : this.name)
},
classes: function classes () {
var cls;
var icon = this.icon;
if (!icon) {
cls = '';
}
else if (icon.startsWith('fa-')) {
// Fontawesome 4
cls = "fa " + icon;
}
else if (/^fa[s|r|l|b]{0,1} /.test(icon)) {
// Fontawesome 5
cls = icon;
}
else if (icon.startsWith('bt-')) {
cls = "bt " + icon;
}
else if (icon.startsWith('ion-') || icon.startsWith('icon-')) {
cls = "" + icon;
}
else if (icon.startsWith('mdi-')) {
cls = "mdi " + icon;
}
else {
cls = 'material-icons';
}
return this.color
? (cls + " text-" + (this.color))
: cls
},
content: function content () {
return this.classes.startsWith('material-icons')
? this.icon.replace(/ /g, '_')
: ' '
},
style: function style () {
if (this.size) {
return { fontSize: this.size }
}
}
},
render: function render (h) {
return h('i', {
staticClass: 'q-icon',
'class': this.classes,
style: this.style,
attrs: { 'aria-hidden': true }
}, [
this.content,
this.$slots.default
])
}
}
function textStyle (n) {
return n === void 0 || n < 2
? {}
: {overflow: 'hidden', display: '-webkit-box', '-webkit-box-orient': 'vertical', '-webkit-line-clamp': n}
}
var ItemMixin = {
props: {
dark: Boolean,
link: Boolean,
dense: Boolean,
sparse: Boolean,
separator: Boolean,
insetSeparator: Boolean,
multiline: Boolean,
highlight: Boolean,
icon: String,
rightIcon: String,
image: String,
rightImage: String,
avatar: String,
rightAvatar: String,
letter: String,
rightLetter: String,
label: String,
sublabel: String,
labelLines: [String, Number],
sublabelLines: [String, Number],
tag: {
type: String,
default: 'div'
}
},
computed: {
itemClasses: function itemClasses () {
return {
'q-item': true,
'q-item-division': true,
'relative-position': true,
'q-item-dark': this.dark,
'q-item-dense': this.dense,
'q-item-sparse': this.sparse,
'q-item-separator': this.separator,
'q-item-inset-separator': this.insetSeparator,
'q-item-multiline': this.multiline,
'q-item-highlight': this.highlight,
'q-item-link': this.to || this.link
}
}
}
}
var routerLinkEventName = 'qrouterlinkclick';
var evt = null;
if (!isSSR) {
try {
evt = new Event(routerLinkEventName);
}
catch (e) {
// IE doesn't support `new Event()`, so...`
evt = document.createEvent('Event');
evt.initEvent(routerLinkEventName, true, false);
}
}
var RouterLinkMixin = {
props: {
to: [String, Object],
exact: Boolean,
append: Boolean,
replace: Boolean,
event: [String, Array],
activeClass: String,
exactActiveClass: String
},
data: function data () {
return {
routerLinkEventName: routerLinkEventName
}
}
};
var QItem = {
name: 'q-item',
mixins: [
ItemMixin,
{ props: RouterLinkMixin.props }
],
props: {
active: Boolean,
link: Boolean
},
computed: {
classes: function classes () {
var cls = this.itemClasses;
return this.to !== void 0
? cls
: [{active: this.active}, cls]
}
},
render: function render (h) {
return this.to !== void 0
? h('router-link', { props: this.$props, 'class': this.classes }, [ this.$slots.default ])
: h(this.tag, { 'class': this.classes }, [ this.$slots.default ])
}
}
var QItemSeparator = {
name: 'q-item-separator',
props: {
inset: Boolean
},
render: function render (h) {
return h('div', {
staticClass: 'q-item-separator-component',
'class': {
'q-item-separator-inset-component': this.inset
}
}, [
this.$slots.default
])
}
}
function text (h, name, val, n) {
n = parseInt(n, 10);
return h('div', {
staticClass: ("q-item-" + name + (n === 1 ? ' ellipsis' : '')),
style: textStyle(n)
}, [ val ])
}
var QItemMain = {
name: 'q-item-main',
props: {
label: String,
labelLines: [String, Number],
sublabel: String,
sublabelLines: [String, Number],
inset: Boolean,
tag: {
type: String,
default: 'div'
}
},
render: function render (h) {
return h('div', {
staticClass: 'q-item-main q-item-section',
'class': {
'q-item-main-inset': this.inset
}
}, [
this.label ? text(h, 'label', this.label, this.labelLines) : null,
this.sublabel ? text(h, 'sublabel', this.sublabel, this.sublabelLines) : null,
this.$slots.default
])
}
}
var QItemSide = {
name: 'q-item-side',
props: {
right: Boolean,
icon: String,
letter: {
type: String,
validator: function (v) { return v.length === 1; }
},
inverted: Boolean, // for icon and letter only
avatar: String,
image: String,
stamp: String,
color: String,
textColor: String // only for inverted icon/letter
},
computed: {
type: function type () {
var this$1 = this;
return ['icon', 'image', 'avatar', 'letter', 'stamp'].find(function (type) { return this$1[type]; })
},
classes: function classes () {
var cls = [ ("q-item-side-" + (this.right ? 'right' : 'left')) ];
if (this.color && (!this.icon && !this.letter)) {
cls.push(("text-" + (this.color)));
}
return cls
},
typeClasses: function typeClasses () {
var cls = [ ("q-item-" + (this.type)) ];
if (this.color) {
if (this.inverted && (this.icon || this.letter)) {
cls.push(("bg-" + (this.color)));
}
else if (!this.textColor) {
cls.push(("text-" + (this.color)));
}
}
this.textColor && cls.push(("text-" + (this.textColor)));
if (this.inverted) {
this.icon && cls.push('q-item-icon-inverted');
this.letter && cls.push('q-item-letter-inverted');
}
return cls
},
imagePath: function imagePath () {
return this.image || this.avatar
}
},
render: function render (h) {
var child;
if (this.type) {
if (this.icon) {
child = h(QIcon, {
'class': this.typeClasses,
props: { name: this.icon }
}, [ this.$slots.default ]);
}
else if (this.imagePath) {
child = h('img', {
'class': this.typeClasses,
attrs: { src: this.imagePath }
});
}
else {
child = h('div', { 'class': this.typeClasses }, [ this.stamp || this.letter ]);
}
}
return h('div', {
staticClass: 'q-item-side q-item-section',
'class': this.classes
}, [
child,
this.$slots.default
])
}
}
var QItemTile = {
name: 'q-item-tile',
props: {
icon: String,
letter: Boolean,
inverted: Boolean, // for icon and letter only
image: Boolean,
avatar: Boolean,
stamp: Boolean,
label: Boolean,
sublabel: Boolean,
lines: [Number, String],
tag: {
type: String,
default: 'div'
},
color: String,
textColor: String // only for inverted icon/letter
},
computed: {
hasLines: function hasLines () {
return (this.label || this.sublabel) && this.lines
},
type: function type () {
var this$1 = this;
return ['icon', 'label', 'sublabel', 'image', 'avatar', 'letter', 'stamp'].find(function (type) { return this$1[type]; })
},
classes: function classes () {
var cls = [];
if (this.color) {
if (this.inverted) {
cls.push(("bg-" + (this.color)));
}
else if (!this.textColor) {
cls.push(("text-" + (this.color)));
}
}
this.textColor && cls.push(("text-" + (this.textColor)));
this.type && cls.push(("q-item-" + (this.type)));
if (this.inverted) {
this.icon && cls.push('q-item-icon-inverted');
this.letter && cls.push('q-item-letter-inverted');
}
if (this.hasLines && (this.lines === '1' || this.lines === 1)) {
cls.push('ellipsis');
}
return cls
},
style: function style () {
if (this.hasLines) {
return textStyle(this.lines)
}
}
},
render: function render (h) {
var data = {
'class': this.classes,
style: this.style
};
if (this.icon) {
data.props = { name: this.icon };
}
return h(this.icon ? QIcon : this.tag, data, [ this.$slots.default ])
}
}
function push (child, h, name, slot, replace, conf) {
var defaultProps = { props: { right: conf.right } };
if (slot && replace) {
child.push(h(name, defaultProps, slot));
return
}
var v = false;
for (var p in conf) {
if (conf.hasOwnProperty(p)) {
v = conf[p];
if (v !== void 0 && v !== true) {
child.push(h(name, { props: conf }));
break
}
}
}
slot && child.push(h(name, defaultProps, slot));
}
var QItemWrapper = {
name: 'q-item-wrapper',
props: {
cfg: {
type: Object,
default: function () { return ({}); }
},
slotReplace: Boolean
},
render: function render (h) {
var
cfg = this.cfg,
replace = this.slotReplace,
child = [];;;
push(child, h, QItemSide, this.$slots.left, replace, {
icon: cfg.icon,
color: cfg.leftColor,
avatar: cfg.avatar,
letter: cfg.letter,
image: cfg.image,
inverted: cfg.leftInverted,
textColor: cfg.leftTextColor
});
push(child, h, QItemMain, this.$slots.main, replace, {
label: cfg.label,
sublabel: cfg.sublabel,
labelLines: cfg.labelLines,
sublabelLines: cfg.sublabelLines,
inset: cfg.inset
});
push(child, h, QItemSide, this.$slots.right, replace, {
right: true,
icon: cfg.rightIcon,
color: cfg.rightColor,
avatar: cfg.rightAvatar,
letter: cfg.rightLetter,
image: cfg.rightImage,
stamp: cfg.stamp,
inverted: cfg.rightInverted,
textColor: cfg.rightTextColor
});
child.push(this.$slots.default);
return h(QItem, {
attrs: this.$attrs,
on: this.$listeners,
props: cfg
}, child)
}
}
var QList = {
name: 'q-list',
props: {
noBorder: Boolean,
dark: Boolean,
dense: Boolean,
sparse: Boolean,
striped: Boolean,
stripedOdd: Boolean,
separator: Boolean,
insetSeparator: Boolean,
multiline: Boolean,
highlight: Boolean,
link: Boolean
},
computed: {
classes: function classes () {
return {
'no-border': this.noBorder,
'q-list-dark': this.dark,
'q-list-dense': this.dense,
'q-list-sparse': this.sparse,
'q-list-striped': this.striped,
'q-list-striped-odd': this.stripedOdd,
'q-list-separator': this.separator,
'q-list-inset-separator': this.insetSeparator,
'q-list-multiline': this.multiline,
'q-list-highlight': this.highlight,
'q-list-link': this.link
}
}
},
render: function render (h) {
return h('div', {
staticClass: 'q-list',
'class': this.classes
}, [
this.$slots.default
])
}
}
var QListHeader = {
name: 'q-list-header',
props: {
inset: Boolean
},
render: function render (h) {
return h('div', {
staticClass: 'q-list-header',
'class': {
'q-list-header-inset': this.inset
}
}, [
this.$slots.default
])
}
}
var QActionSheet = {
name: 'q-action-sheet',
props: {
value: Boolean,
title: String,
grid: Boolean,
actions: Array,
dismissLabel: String
},
computed: {
contentCss: function contentCss () {
{
return {backgroundColor: 'transparent'}
}
}
},
render: function render (h) {
var this$1 = this;
var
child = [],
title = this.$slots.title || this.title;;
if (title) {
child.push(
h('div', {
staticClass: 'q-actionsheet-title column justify-center'
}, [ title ])
);
}
child.push(
h(
'div',
{ staticClass: 'q-actionsheet-body scroll' },
this.actions
? [
this.grid
? h('div', { staticClass: 'q-actionsheet-grid row wrap items-center justify-between' }, this.__getActions(h))
: h(QList, { staticClass: 'no-border', props: { link: true } }, this.__getActions(h))
]
: [ this.$slots.default ]
)
);
{
child = [
h('div', { staticClass: 'q-actionsheet' }, child),
h('div', { staticClass: 'q-actionsheet' }, [
h(QItem, {
props: {
link: true
},
attrs: {
tabindex: 0
},
nativeOn: {
click: this.__onCancel,
keydown: this.__onCancel
}
}, [
h(QItemMain, { staticClass: 'text-center text-primary' }, [
this.dismissLabel || this.$q.i18n.label.cancel
])
])
])
];
}
return h(QModal, {
ref: 'modal',
props: {
value: this.value,
position: 'bottom',
contentCss: this.contentCss
},
on: {
input: function (val) {
this$1.$emit('input', val);
},
show: function () {
this$1.$emit('show');
},
hide: function () {
this$1.$emit('hide');
},
dismiss: function () {
this$1.__onCancel();
},
'escape-key': function () {
this$1.hide().then(function () {
this$1.$emit('escape-key');
this$1.__onCancel();
});
}
}
}, child)
},
methods: {
show: function show () {
return this.$refs.modal.show()
},
hide: function hide () {
return this.$refs.modal.hide()
},
__getActions: function __getActions (h) {
var this$1 = this;
return this.actions.map(function (action) {
var obj;
return action.label
? h(this$1.grid ? 'div' : QItem, ( obj = {
staticClass: this$1.grid
? 'q-actionsheet-grid-item cursor-pointer relative-position column inline flex-center'
: null,
'class': action.classes,
attrs: {
tabindex: 0
}
}, obj[this$1.grid ? 'on' : 'nativeOn'] = {
click: function () { return this$1.__onOk(action); },
keydown: function () { return this$1.__onOk(action); }
}, obj), this$1.grid
? [
action.icon ? h(QIcon, { props: { name: action.icon, color: action.color } }) : null,
action.avatar ? h('img', { domProps: { src: action.avatar }, staticClass: 'avatar' }) : null,
h('span', [ action.label ])
]
: [
h(QItemSide, { props: { icon: action.icon, color: action.color, avatar: action.avatar } }),
h(QItemMain, { props: { inset: true, label: action.label } })
]
)
: h(QItemSeparator, { staticClass: 'col-12' });
}
)
},
__onOk: function __onOk (action) {
var this$1 = this;
this.hide().then(function () {
if (typeof action.handler === 'function') {
action.handler();
}
this$1.$emit('ok', action);
});
},
__onCancel: function __onCancel () {
var this$1 = this;
this.hide().then(function () {
this$1.$emit('cancel');
});
}
}
}
var units = ['B', 'kB', 'MB', 'GB', 'TB', 'PB'];
function humanStorageSize (bytes) {
var u = 0;
while (parseInt(bytes, 10) >= 1024 && u < units.length - 1) {
bytes /= 1024;
++u;
}
return ((bytes.toFixed(1)) + " " + (units[u]))
}
function capitalize (str) {
return str.charAt(0).toUpperCase() + str.slice(1)
}
function between (v, min, max) {
if (max <= min) {
return min
}
return Math.min(max, Math.max(min, v))
}
function normalizeToInterval (v, min, max) {
if (max <= min) {
return min
}
var size = (max - min + 1);
var index = v % size;
if (index < min) {
index = size + index;
}
return index
}
function pad (v, length, char) {
if ( length === void 0 ) length = 2;
if ( char === void 0 ) char = '0';
var val = '' + v;
return val.length >= length
? val
: new Array(length - val.length + 1).join(char) + val
}
var format = Object.freeze({
humanStorageSize: humanStorageSize,
capitalize: capitalize,
between: between,
normalizeToInterval: normalizeToInterval,
pad: pad
});
var
xhr = isSSR ? null : XMLHttpRequest,
send = isSSR ? null : xhr.prototype.send;;
function translate (ref) {
var p = ref.p;
var pos = ref.pos;
var active = ref.active;
var horiz = ref.horiz;
var reverse = ref.reverse;
var x = 1, y = 1;;
if (horiz) {
if (reverse) {