UNPKG

quasar

Version:

Build high-performance VueJS user interfaces (SPA, PWA, SSR, Mobile and Desktop) in record time

2,013 lines (1,727 loc) 851 kB
/*! * Quasar Framework v1.2.5 * (c) 2015-present Razvan Stoenescu * Released under the MIT License. */ (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('vue')) : typeof define === 'function' && define.amd ? define(['vue'], factory) : (global = global || self, global.Quasar = factory(global.Vue)); }(this, function (Vue) { 'use strict'; if (Vue === void 0) { console.error('[ Quasar ] Vue is required to run. Please add a script tag for it before loading Quasar.') return } Vue = Vue && Vue.hasOwnProperty('default') ? Vue['default'] : Vue; /* eslint-disable no-useless-escape */ var isSSR = typeof window === 'undefined'; var fromSSR = false; var onSSR = isSSR; function getMatch (userAgent, platformMatch) { var match = /(edge|edga|edgios)\/([\w.]+)/.exec(userAgent) || /(opr)[\/]([\w.]+)/.exec(userAgent) || /(vivaldi)[\/]([\w.]+)/.exec(userAgent) || /(chrome|crios)[\/]([\w.]+)/.exec(userAgent) || /(iemobile)[\/]([\w.]+)/.exec(userAgent) || /(version)(applewebkit)[\/]([\w.]+).*(safari)[\/]([\w.]+)/.exec(userAgent) || /(webkit)[\/]([\w.]+).*(version)[\/]([\w.]+).*(safari)[\/]([\w.]+)/.exec(userAgent) || /(firefox|fxios)[\/]([\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 (userAgent) { var 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; } var knownMobiles = browser.android || browser.ios || browser.bb || browser.blackberry || browser.ipad || browser.iphone || browser.ipod || browser.kindle || browser.playbook || browser.silk || browser['windows phone']; // These are all considered mobile platforms, meaning they run a mobile browser if (knownMobiles === true || userAgent.indexOf('mobile') > -1) { browser.mobile = true; if (browser.edga || browser.edgios) { browser.edge = true; matched.browser = 'edge'; } else if (browser.crios) { browser.chrome = true; matched.browser = 'chrome'; } else if (browser.fxios) { browser.firefox = true; matched.browser = 'firefox'; } } // If it's not mobile we should consider it's desktop platform, meaning it runs a desktop browser // It's a workaround for anonymized user agents // (browser.cros || browser.mac || browser.linux || browser.win) else { browser.desktop = 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']; } // Chrome, Opera 15+, Vivaldi and Safari are webkit based browsers if ( browser.chrome || browser.opr || browser.safari || browser.vivaldi || // we expect unknown, non iOS mobile browsers to be webkit based ( browser.mobile === true && browser.ios !== true && knownMobiles !== true ) ) { 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; } // 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 (isSSR === false) { if (window.process && window.process.versions && window.process.versions.electron) { browser.electron = true; } else if (document.location.href.indexOf('-extension://') > -1) { browser.bex = true; } else if (window.Capacitor !== void 0) { browser.capacitor = true; browser.nativeMobile = true; browser.nativeMobileWrapper = 'capacitor'; } else if (window._cordovaNative !== void 0 || window.cordova !== void 0) { browser.cordova = true; browser.nativeMobile = true; browser.nativeMobileWrapper = 'cordova'; } fromSSR = browser.nativeMobile === void 0 && browser.electron === void 0 && !!document.querySelector('[data-server-rendered]'); if (fromSSR === true) { onSSR = true; } } return browser } var userAgent = isSSR === false ? (navigator.userAgent || navigator.vendor || window.opera).toLowerCase() : ''; var ssrClient = { has: { touch: false, webStorage: false }, within: { iframe: false } }; // We export "client" for hydration error-free parts, // like touch directives who do not (and must NOT) wait // for the client takeover; // Do NOT import this directly in your app, unless you really know // what you are doing. var client = isSSR === false ? { userAgent: userAgent, is: getPlatform(userAgent), has: { touch: (function () { return 'ontouchstart' in window || window.navigator.maxTouchPoints > 0; } )(), webStorage: (function () { try { if (window.localStorage) { return true } } catch (e) {} return false })() }, within: { iframe: window.self !== window.top } } : ssrClient; var Platform = { install: function install ($q, queues) { var this$1 = this; if (isSSR === true) { // we're on server-side, so we push // to the server queue instead of // applying directly queues.server.push(function (q, ctx) { q.platform = this$1.parseSSR(ctx.ssr); }); } else if (fromSSR === true) { // must match with server-side before // client taking over in order to prevent // hydration errors Object.assign(this, client, ssrClient); // takeover should increase accuracy for // the rest of the props; we also avoid // hydration errors queues.takeover.push(function (q) { onSSR = fromSSR = false; Object.assign(q.platform, client); }); // we need to make platform reactive // for the takeover phase Vue.util.defineReactive($q, 'platform', this); } else { // we don't have any business with SSR, so // directly applying... Object.assign(this, client); $q.platform = this; } } }; if (isSSR === true) { Platform.parseSSR = function (/* ssrContext */ ssr) { var userAgent = (ssr.req.headers['user-agent'] || ssr.req.headers['User-Agent'] || '').toLowerCase(); return Object.assign({}, client, {userAgent: userAgent, is: getPlatform(userAgent)}) }; } /* eslint-disable no-extend-native, one-var, no-self-compare */ function assign (target, firstSource) { var arguments$1 = arguments; if (target === undefined || target === null) { throw new TypeError('Cannot convert first argument to object') } var to = Object(target); for (var i = 1; i < arguments.length; i++) { var nextSource = arguments$1[i]; if (nextSource === undefined || nextSource === null) { continue } var keysArray = Object.keys(Object(nextSource)); for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { var nextKey = keysArray[nextIndex]; var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); if (desc !== undefined && desc.enumerable) { to[nextKey] = nextSource[nextKey]; } } } return to } if (!Object.assign) { Object.defineProperty(Object, 'assign', { enumerable: false, configurable: true, writable: true, value: assign }); } if (!Number.isInteger) { Number.isInteger = function (value) { return typeof value === 'number' && isFinite(value) && Math.floor(value) === value }; } 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 === false) { if (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 (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 }; } // from:https://github.com/jserz/js_piece/blob/master/DOM/ChildNode/remove()/remove().md (function (arr) { arr.forEach(function (item) { if (item.hasOwnProperty('remove')) { return } Object.defineProperty(item, 'remove', { configurable: true, enumerable: true, writable: true, value: function value () { if (this.parentNode !== null) { this.parentNode.removeChild(this); } } }); }); })([Element.prototype, CharacterData.prototype, DocumentType.prototype]); } 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 version = "1.2.5"; var listenOpts = { hasPassive: false, passiveCapture: true, notPassiveCapture: true }; try { var opts = Object.defineProperty({}, 'passive', { get: function get () { Object.assign(listenOpts, { hasPassive: true, passive: { passive: true }, notPassive: { passive: false }, passiveCapture: { passive: true, capture: true }, notPassiveCapture: { passive: false, capture: true } }); } }); window.addEventListener('qtest', null, opts); window.removeEventListener('qtest', null, opts); } catch (e) {} function leftClick (e) { return e.button === 0 } function middleClick (e) { return e.button === 1 } function rightClick (e) { return e.button === 2 } function position (e) { if (e.touches && e.touches[0]) { e = e.touches[0]; } else if (e.changedTouches && e.changedTouches[0]) { e = e.changedTouches[0]; } else if (e.targetTouches && e.targetTouches[0]) { e = e.targetTouches[0]; } return { top: e.clientY, left: e.clientX } } function getEventPath (e) { if (e.path) { return e.path } if (e.composedPath) { return e.composedPath() } var path = []; var el = e.target; while (el) { path.push(el); if (el.tagName === 'HTML') { path.push(document); path.push(window); return path } el = el.parentElement; } } // Reasonable defaults var LINE_HEIGHT = 40, PAGE_HEIGHT = 800; function getMouseWheelDistance (e) { var assign; var x = e.deltaX, y = e.deltaY; if ((x || y) && e.deltaMode) { var multiplier = e.deltaMode === 1 ? LINE_HEIGHT : PAGE_HEIGHT; x *= multiplier; y *= multiplier; } if (e.shiftKey && !x) { (assign = [x, y], y = assign[0], x = assign[1]); } return { x: x, y: y } } function stop (e) { e.stopPropagation(); } function prevent (e) { e.cancelable !== false && e.preventDefault(); } function stopAndPrevent (e) { e.cancelable !== false && e.preventDefault(); e.stopPropagation(); } function preventDraggable (el, status) { if (el === void 0 || (status === true && el.__dragPrevented === true)) { return } var fn = status === true ? function (el) { el.__dragPrevented = true; el.addEventListener('dragstart', prevent, listenOpts.notPassiveCapture); } : function (el) { delete el.__dragPrevented; el.removeEventListener('dragstart', prevent, listenOpts.notPassiveCapture); }; el.querySelectorAll('a, img').forEach(fn); } function create (name, ref) { if ( ref === void 0 ) ref = {}; var bubbles = ref.bubbles; if ( bubbles === void 0 ) bubbles = false; var cancelable = ref.cancelable; if ( cancelable === void 0 ) cancelable = false; try { return new Event(name, { bubbles: bubbles, cancelable: cancelable }) } catch (e) { // IE doesn't support `new Event()`, so...` var evt = document.createEvent('Event'); evt.initEvent(name, bubbles, cancelable); return evt } } var event = { listenOpts: listenOpts, leftClick: leftClick, middleClick: middleClick, rightClick: rightClick, position: position, getEventPath: getEventPath, getMouseWheelDistance: getMouseWheelDistance, stop: stop, prevent: prevent, stopAndPrevent: stopAndPrevent, preventDraggable: preventDraggable, create: create }; function debounce (fn, wait, immediate) { if ( wait === void 0 ) wait = 250; var timeout; function debounced (/* ...args */) { var this$1 = this; var args = arguments; var later = function () { timeout = null; if (!immediate) { fn.apply(this$1, args); } }; clearTimeout(timeout); if (immediate && !timeout) { fn.apply(this, args); } timeout = setTimeout(later, wait); } debounced.cancel = function () { clearTimeout(timeout); }; return debounced } var SIZE_LIST = ['sm', 'md', 'lg', 'xl']; var Screen = { width: 0, height: 0, sizes: { sm: 600, md: 1024, lg: 1440, xl: 1920 }, lt: { sm: true, md: true, lg: true, xl: true }, gt: { xs: false, sm: false, md: false, lg: false }, xs: true, sm: false, md: false, lg: false, xl: false, setSizes: function setSizes () {}, setDebounce: function setDebounce () {}, install: function install ($q, queues) { var this$1 = this; if (isSSR === true) { $q.screen = this; return } var update = function (force) { if (window.innerHeight !== this$1.height) { this$1.height = window.innerHeight; } var w = window.innerWidth; if (w !== this$1.width) { this$1.width = w; } else if (force !== true) { return } var s = this$1.sizes; this$1.gt.xs = w >= s.sm; this$1.gt.sm = w >= s.md; this$1.gt.md = w >= s.lg; this$1.gt.lg = w >= s.xl; this$1.lt.sm = w < s.sm; this$1.lt.md = w < s.md; this$1.lt.lg = w < s.lg; this$1.lt.xl = w < s.xl; this$1.xs = this$1.lt.sm; this$1.sm = this$1.gt.xs && this$1.lt.md; this$1.md = this$1.gt.sm && this$1.lt.lg; this$1.lg = this$1.gt.md && this$1.lt.xl; this$1.xl = this$1.gt.lg; }; var updateEvt, updateSizes = {}, updateDebounce = 16; this.setSizes = function (sizes) { SIZE_LIST.forEach(function (name) { if (sizes[name] !== void 0) { updateSizes[name] = sizes[name]; } }); }; this.setDebounce = function (deb) { updateDebounce = deb; }; var start = function () { var style = getComputedStyle(document.body); // if css props available if (style.getPropertyValue('--q-size-sm')) { SIZE_LIST.forEach(function (name) { this$1.sizes[name] = parseInt(style.getPropertyValue(("--q-size-" + name)), 10); }); } this$1.setSizes = function (sizes) { SIZE_LIST.forEach(function (name) { if (sizes[name]) { this$1.sizes[name] = sizes[name]; } }); update(true); }; this$1.setDebounce = function (delay) { var fn = function () { update(); }; updateEvt && window.removeEventListener('resize', updateEvt, listenOpts.passive); updateEvt = delay > 0 ? debounce(fn, delay) : fn; window.addEventListener('resize', updateEvt, listenOpts.passive); }; this$1.setDebounce(updateDebounce); if (Object.keys(updateSizes).length > 0) { this$1.setSizes(updateSizes); updateSizes = void 0; // free up memory } else { update(); } }; if (fromSSR === true) { queues.takeover.push(start); } else { start(); } Vue.util.defineReactive($q, 'screen', this); } }; var getTrue = function () { return true; }; var History = { __history: [], add: function () {}, remove: function () {}, install: function install ($q, cfg) { var this$1 = this; if (isSSR === true || $q.platform.is.cordova !== true) { return } this.add = function (entry) { if (entry.condition === void 0) { entry.condition = getTrue; } this$1.__history.push(entry); }; this.remove = function (entry) { var index = this$1.__history.indexOf(entry); if (index >= 0) { this$1.__history.splice(index, 1); } }; var exit = cfg.cordova === void 0 || cfg.cordova.backButtonExit !== false; document.addEventListener('deviceready', function () { document.addEventListener('backbutton', function () { if (this$1.__history.length) { var entry = this$1.__history[this$1.__history.length - 1]; if (entry.condition() === true) { this$1.__history.pop(); entry.handler(); } } else if (exit && window.location.hash === '#/') { navigator.app.exitApp(); } else { window.history.back(); } }, false); }); } }; var langEn = { isoName: 'en-us', nativeName: 'English (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 }, table: { noData: 'No data available', noResults: 'No matching records found', loading: 'Loading...', selectedRecords: function (rows) { return rows === 1 ? '1 record selected.' : (rows === 0 ? 'No' : rows) + ' records selected.' }, recordsPerPage: 'Records 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', viewSource: 'View Source' }, tree: { noNodes: 'No nodes available', noResults: 'No matching nodes found' } }; var lang = { install: function install ($q, queues, lang) { var this$1 = this; if (isSSR === true) { queues.server.push(function (q, ctx) { var opt = { lang: q.lang.isoName, dir: q.lang.rtl === true ? 'rtl' : 'ltr' }, fn = ctx.ssr.setHtmlAttrs; if (typeof fn === 'function') { fn(opt); } else { ctx.ssr.Q_HTML_ATTRS = Object.keys(opt) .map(function (key) { return (key + "=" + (opt[key])); }) .join(' '); } }); } this.set = function (lang) { if ( lang === void 0 ) lang = langEn; lang.set = this$1.set; lang.getLocale = this$1.getLocale; lang.rtl = lang.rtl || false; if (isSSR === false) { var el = document.documentElement; el.setAttribute('dir', lang.rtl ? 'rtl' : 'ltr'); el.setAttribute('lang', lang.isoName); } if (isSSR === true || $q.lang !== void 0) { $q.lang = lang; } else { Vue.util.defineReactive($q, 'lang', lang); } this$1.isoName = lang.isoName; this$1.nativeName = lang.nativeName; this$1.props = lang; }; this.set(lang); }, getLocale: function getLocale () { if (isSSR === true) { return } var val = navigator.language || navigator.languages[0] || navigator.browserLanguage || navigator.userLanguage || navigator.systemLanguage; if (val) { return val.toLowerCase() } } }; function rgbToHex (ref) { var r = ref.r; var g = ref.g; var b = ref.b; var a = ref.a; var alpha = a !== void 0; r = Math.round(r); g = Math.round(g); b = Math.round(b); if ( r > 255 || g > 255 || b > 255 || (alpha && a > 100) ) { throw new TypeError('Expected 3 numbers below 256 (and optionally one below 100)') } a = alpha ? (Math.round(255 * a / 100) | 1 << 8).toString(16).slice(1) : ''; return '#' + ((b | g << 8 | r << 16) | 1 << 24).toString(16).slice(1) + a } function rgbToString (ref) { var r = ref.r; var g = ref.g; var b = ref.b; var a = ref.a; return ("rgb" + (a !== void 0 ? 'a' : '') + "(" + r + "," + g + "," + b + (a !== void 0 ? ',' + (a / 100) : '') + ")") } function stringToRgb (str) { if (typeof str !== 'string') { throw new TypeError('Expected a string') } str = str.replace(/ /g, ''); if (str.startsWith('#')) { return hexToRgb(str) } var model = str.substring(str.indexOf('(') + 1, str.length - 1).split(','); return { r: parseInt(model[0], 10), g: parseInt(model[1], 10), b: parseInt(model[2], 10), a: model[3] !== void 0 ? parseFloat(model[3]) * 100 : void 0 } } function hexToRgb (hex) { if (typeof hex !== 'string') { throw new TypeError('Expected a string') } hex = hex.replace(/^#/, ''); if (hex.length === 3) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; } else if (hex.length === 4) { hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3]; } var num = parseInt(hex, 16); return hex.length > 6 ? { r: num >> 24 & 255, g: num >> 16 & 255, b: num >> 8 & 255, a: Math.round((num & 255) / 2.55) } : { r: num >> 16, g: num >> 8 & 255, b: num & 255 } } function hsvToRgb (ref) { var h = ref.h; var s = ref.s; var v = ref.v; var a = ref.a; var r, g, b, i, f, p, q, t; s = s / 100; v = v / 100; h = h / 360; i = Math.floor(h * 6); f = h * 6 - i; p = v * (1 - s); q = v * (1 - f * s); t = v * (1 - (1 - f) * s); switch (i % 6) { case 0: r = v; g = t; b = p; break case 1: r = q; g = v; b = p; break case 2: r = p; g = v; b = t; break case 3: r = p; g = q; b = v; break case 4: r = t; g = p; b = v; break case 5: r = v; g = p; b = q; break } return { r: Math.round(r * 255), g: Math.round(g * 255), b: Math.round(b * 255), a: a } } function rgbToHsv (ref) { var r = ref.r; var g = ref.g; var b = ref.b; var a = ref.a; var max = Math.max(r, g, b), min = Math.min(r, g, b), d = max - min, h, s = (max === 0 ? 0 : d / max), v = max / 255; switch (max) { case min: h = 0; break case r: h = (g - b) + d * (g < b ? 6 : 0); h /= 6 * d; break case g: h = (b - r) + d * 2; h /= 6 * d; break case b: h = (r - g) + d * 4; h /= 6 * d; break } return { h: Math.round(h * 360), s: Math.round(s * 100), v: Math.round(v * 100), a: a } } var reRGBA = /^\s*rgb(a)?\s*\((\s*(\d+)\s*,\s*?){2}(\d+)\s*,?\s*([01]?\.?\d*?)?\s*\)\s*$/; function textToRgb (color) { if (typeof color !== 'string') { throw new TypeError('Expected a string') } var m = reRGBA.exec(color); if (m) { var rgb = { r: Math.min(255, parseInt(m[2], 10)), g: Math.min(255, parseInt(m[3], 10)), b: Math.min(255, parseInt(m[4], 10)) }; if (m[1]) { rgb.a = Math.min(1, parseFloat(m[5])); } return rgb } return hexToRgb(color) } /* works as darken if percent < 0 */ function lighten (color, percent) { if (typeof color !== 'string') { throw new TypeError('Expected a string as color') } if (typeof percent !== 'number') { throw new TypeError('Expected a numeric percent') } var rgb = textToRgb(color), t = percent < 0 ? 0 : 255, p = Math.abs(percent) / 100, R = rgb.r, G = rgb.g, B = rgb.b; return '#' + ( 0x1000000 + (Math.round((t - R) * p) + R) * 0x10000 + (Math.round((t - G) * p) + G) * 0x100 + (Math.round((t - B) * p) + B) ).toString(16).slice(1) } function luminosity (color) { if (typeof color !== 'string' && (!color || color.r === void 0)) { throw new TypeError('Expected a string or a {r, g, b} object as color') } var rgb = typeof color === 'string' ? textToRgb(color) : color, r = rgb.r / 255, g = rgb.g / 255, b = rgb.b / 255, R = r <= 0.03928 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4), G = g <= 0.03928 ? g / 12.92 : Math.pow((g + 0.055) / 1.055, 2.4), B = b <= 0.03928 ? b / 12.92 : Math.pow((b + 0.055) / 1.055, 2.4); return 0.2126 * R + 0.7152 * G + 0.0722 * B } function setBrand (color, value, element) { if ( element === void 0 ) element = document.body; if (typeof color !== 'string') { throw new TypeError('Expected a string as color') } if (typeof value !== 'string') { throw new TypeError('Expected a string as value') } if (!(element instanceof Element)) { throw new TypeError('Expected a DOM element') } element.style.setProperty(("--q-color-" + color), value); switch (color) { case 'negative': case 'warning': element.style.setProperty(("--q-color-" + color + "-l"), lighten(value, 46)); break case 'light': element.style.setProperty(("--q-color-" + color + "-d"), lighten(value, -10)); } } function getBrand (color, element) { if ( element === void 0 ) element = document.body; if (typeof color !== 'string') { throw new TypeError('Expected a string as color') } if (!(element instanceof Element)) { throw new TypeError('Expected a DOM element') } return getComputedStyle(element).getPropertyValue(("--q-color-" + color)).trim() || null } var colors = { rgbToHex: rgbToHex, hexToRgb: hexToRgb, hsvToRgb: hsvToRgb, rgbToHsv: rgbToHsv, textToRgb: textToRgb, lighten: lighten, luminosity: luminosity, setBrand: setBrand, getBrand: getBrand }; function getMobilePlatform (is) { if (is.ios === true) { return 'ios' } if (is.android === true) { return 'android' } } function getBodyClasses (ref, cfg) { var is = ref.is; var has = ref.has; var within = ref.within; var cls = [ is.desktop === true ? 'desktop' : 'mobile', ((has.touch === false ? 'no-' : '') + "touch") ]; if (is.mobile === true) { var mobile = getMobilePlatform(is); mobile !== void 0 && cls.push('platform-' + mobile); } if (is.nativeMobile === true) { var type = is.nativeMobileWrapper; cls.push(type); cls.push('native-mobile'); if ( is.ios === true && (cfg[type] === void 0 || cfg[type].iosStatusBarPadding !== false) ) { cls.push('q-ios-padding'); } } else if (is.electron === true) { cls.push('electron'); } else if (is.bex === true) { cls.push('bex'); } within.iframe === true && cls.push('within-iframe'); return cls } function clientApply (cls) { if (client.is.ie === true && client.is.versionNumber === 11) { cls.forEach(function (c) { return document.body.classList.add(c); }); } else { document.body.classList.add.apply(document.body.classList, cls); } } // SSR takeover corrections function clientUpdate () { var cls = []; if (client.has.touch === true) { document.body.classList.remove('no-touch'); cls.push('touch'); } client.within.iframe === true && cls.push('within-iframe'); cls.length > 0 && clientApply(cls); } function setColors (brand) { for (var color in brand) { setBrand(color, brand[color]); } } var Body = { install: function install (queues, cfg) { if (isSSR === true) { queues.server.push(function (q, ctx) { var cls = getBodyClasses(q.platform, cfg), fn = ctx.ssr.setBodyClasses; if (typeof fn === 'function') { fn(cls); } else { ctx.ssr.Q_BODY_CLASSES = cls.join(' '); } }); } else { if (fromSSR === true) { clientUpdate(); } else { clientApply(getBodyClasses(client, cfg)); } cfg.brand !== void 0 && setColors(cfg.brand); if (client.is.ios === true) { // needed for iOS button active state document.body.addEventListener('touchstart', function () {}); } } } }; var materialIcons = { name: 'material-icons', type: { positive: 'check_circle', negative: 'warning', info: 'info', warning: 'priority_high' }, arrow: { up: 'arrow_upward', right: 'arrow_forward', down: 'arrow_downward', left: 'arrow_back', dropdown: 'arrow_drop_down' }, chevron: { left: 'chevron_left', right: 'chevron_right' }, colorPicker: { spectrum: 'gradient', tune: 'tune', palette: 'style' }, pullToRefresh: { icon: 'refresh' }, carousel: { left: 'chevron_left', right: 'chevron_right', navigationIcon: 'lens', thumbnails: 'view_carousel' }, chip: { remove: 'cancel', selected: 'check' }, datetime: { arrowLeft: 'chevron_left', arrowRight: 'chevron_right', now: 'access_time', today: 'today' }, 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', viewSource: 'code' }, expansionItem: { icon: 'keyboard_arrow_down', denseIcon: 'arrow_drop_down' }, fab: { icon: 'add', activeIcon: 'close' }, field: { clear: 'cancel', error: 'error' }, pagination: { first: 'first_page', prev: 'keyboard_arrow_left', next: 'keyboard_arrow_right', last: 'last_page' }, rating: { icon: 'grade' }, stepper: { done: 'check', active: 'edit', error: 'warning' }, tabs: { left: 'chevron_left', right: 'chevron_right', up: 'keyboard_arrow_up', down: 'keyboard_arrow_down' }, table: { arrowUp: 'arrow_upward', warning: 'warning', prevPage: 'chevron_left', nextPage: 'chevron_right' }, tree: { icon: 'play_arrow' }, uploader: { done: 'done', clear: 'clear', add: 'add_box', upload: 'cloud_upload', removeQueue: 'clear_all', removeUploaded: 'done_all' } }; var iconSet = { __installed: false, install: function install ($q, iconSet) { var this$1 = this; this.set = function (iconDef) { if ( iconDef === void 0 ) iconDef = materialIcons; iconDef.set = this$1.set; if (isSSR === true || $q.iconSet !== void 0) { $q.iconSet = iconDef; } else { Vue.util.defineReactive($q, 'iconSet', iconDef); } this$1.name = iconDef.name; this$1.def = iconDef; }; this.set(iconSet); } }; var queues = { server: [], // on SSR update takeover: [] // on client takeover }; var $q = { version: version }; function install (Vue, opts) { if ( opts === void 0 ) opts = {}; if (this.__installed) { return } this.__installed = true; var cfg = opts.config || {}; // required plugins Platform.install($q, queues); Body.install(queues, cfg); Screen.install($q, queues); History.install($q, cfg); lang.install($q, queues, opts.lang); iconSet.install($q, opts.iconSet); if (isSSR === true) { Vue.mixin({ beforeCreate: function beforeCreate () { this.$q = this.$root.$options.$q; } }); } else { Vue.prototype.$q = $q; } opts.components && Object.keys(opts.components).forEach(function (key) { var c = opts.components[key]; if (typeof c === 'function') { Vue.component(c.options.name, c); } }); opts.directives && Object.keys(opts.directives).forEach(function (key) { var d = opts.directives[key]; if (d.name !== undefined && d.unbind !== void 0) { Vue.directive(d.name, d); } }); if (opts.plugins) { var param = { $q: $q, queues: queues, cfg: cfg }; Object.keys(opts.plugins).forEach(function (key) { var p = opts.plugins[key]; if (typeof p.install === 'function' && p !== Platform && p !== Screen) { p.install(param); } }); } } 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) { return max <= min ? min : Math.min(max, Math.max(min, v)) } function normalizeToInterval (v, min, max) { if (max <= min) { return min } var size = (max - min + 1); var index = min + (v - min) % size; if (index < min) { index = size + index; } return index === 0 ? 0 : index // fix for (-a % a) => -0 } function pad (v, length, char) { if ( length === void 0 ) length = 2; if ( char === void 0 ) char = '0'; if (v === void 0 || v === null) { return v } var val = '' + v; return val.length >= length ? val : new Array(length - val.length + 1).join(char) + val } var format = { humanStorageSize: humanStorageSize, capitalize: capitalize, between: between, normalizeToInterval: normalizeToInterval, pad: pad }; var xhr = isSSR ? null : XMLHttpRequest, send = isSSR ? null : xhr.prototype.send, stackStart = [], stackStop = []; var highjackCount = 0; function translate (ref) { var p = ref.p; var pos = ref.pos; var active = ref.active; var horiz = ref.horiz; var reverse = ref.reverse; var dir = ref.dir; var x = 1, y = 1; if (horiz) { if (reverse) { x = -1; } if (pos === 'bottom') { y = -1; } return { transform: ("translate3d(" + (x * (p - 100)) + "%," + (active ? 0 : y * -200) + "%,0)") } } if (reverse) { y = -1; } if (pos === 'right') { x = -1; } return { transform: ("translate3d(" + (active ? 0 : dir * x * -200) + "%," + (y * (p - 100)) + "%,0)") } } function inc (p, amount) { if (typeof amount !== 'number') { if (p < 25) { amount = Math.random() * 3 + 3; } else if (p < 65) { amount = Math.random() * 3; } else if (p < 85) { amount = Math.random() * 2; } else if (p < 99) { amount = 0.6; } else { amount = 0; } } return between(p + amount, 0, 100) } function highjackAjax (start, stop) { stackStart.push(start); stackStop.push(stop); highjackCount++; if (highjackCount > 1) { return } function endHandler () { stackStop.forEach(function (fn) { fn(); }); } xhr.prototype.send = function (/* ...args */) { stackStart.forEach(function (fn) { fn(); }); this.addEventListener('loadend', endHandler, false); send.apply(this, arguments); }; } function restoreAjax (start, stop) { stackStart.splice(stackStart.indexOf(start), 1); stackStop.splice(stackStop.indexOf(stop), 1); highjackCount = Math.max(0, highjackCount - 1); if (!highjackCount) { xhr.prototype.send = send; } } var QAjaxBar = Vue.extend({ name: 'QAjaxBar', props: { position: { type: String, default: 'top', validator: function validator (val) { return ['top', 'right', 'bottom', 'left'].includes(val) } }, size: { type: String, default: '2px' }, color: { type: String, default: 'red' }, skipHijack: Boolean, reverse: Boolean }, data: function data () { return { calls: 0, progress: 0, onScreen: false, animate: true } }, computed: { classes: function classes () { return "q-loading-bar q-loading-bar--" + (this.position) + " bg-" + (this.color) + (this.animate === true ? '' : ' no-transition') }, style: function style () { var active = this.onScreen; var o = translate({ p: this.progress, pos: this.position, active: active, horiz: this.horizontal, reverse: this.$q.lang.rtl && ['top', 'bottom'].includes(this.position) ? !this.reverse : this.reverse, dir: this.$q.lang.rtl ? -1 : 1 }); o[this.sizeProp] = this.size; o.opacity = active ? 1 : 0; return o }, horizontal: function horizontal () { return this.position === 'top' || this.position === 'bottom' }, sizeProp: function sizeProp () { return this.horizontal ? 'height' : 'width' } }, methods: { start: function start (speed) { var this$1 = this; if ( speed === void 0 ) speed = 300; var oldSpeed = this.speed; this.speed = Math.max(0, speed) || 0; this.calls++; if (this.calls > 1) { if (oldSpeed === 0 && speed > 0) { this.__work(); } else if (oldSpeed > 0 && speed <= 0) { clearTimeout(this.timer); } return } clearTimeout(this.timer); this.$emit('start'); this.progress = 0; if (this.onScreen === true) { return } this.onScreen = true; this.animate = false; this.timer = setTimeout(function () { this$1.animate = true; speed > 0 && this$1.__work(); }, 100); }, increment: function increment (amount) { this.calls > 0 && (this.progress = inc(this.progress, amount)); }, stop: function stop () { var this$1 = this; this.calls = Math.max(0, this.calls - 1); if (this.calls > 0) { return } clearTimeout(this.timer); this.$emit('stop'); var end = function () { this$1.animate = true; this$1.progress = 100; this$1.timer = setTimeout(function () { this$1.onScreen = false; }, 1000); }; if (this.progress === 0) { this.timer = setTimeout(end, 1); } else { end(); } }, __work: function __work () { var this$1 = this; if (this.progress < 100) { this.timer = setTimeout(function () { this$1.increment(); this$1.__work(); }, this.speed); } } }, mounted: function mounted () { if (this.skipHijack !== true) { this.hijacked = true; highjackAjax(this.start, this.stop); } }, beforeDestroy: function beforeDestroy () { clearTimeout(this.timer); this.hijacked && restoreAjax(this.start, this.stop); }, render: function render (h) { return h('div', { class: this.classes, style: this.style }) } }); var sizes = { xs: 18, sm: 24, md: 32, lg: 38, xl: 46 }; var SizeMixin = { props: { size: String }, computed: { sizeStyle: function sizeStyle () { if (this.size !== void 0) { return { fontSize: this.size in sizes ? ((sizes[this.size]) + "px") : this.size } } } } }; function slot (vm, slotName) { return vm.$scopedSlots[slotName] !== void 0 ? vm.$scopedSlots[slotName]() : void 0 } var QIcon = Vue.extend({ name: 'QIcon', mixins: [ SizeMixin ], props: { name: String, color: String, left: Boolean, right: Boolean }, computed: { type: function type () { var cls; var icon = this.name; if (!icon) { return { cls: void 0, content: void 0 } } var commonCls = 'q-icon' + (this.left === true ? ' on-left' : '') + (this.right === true ? ' on-right' : ''); if (icon.startsWith('img:') === true) { return { img: true, cls: commonCls, src: icon.substring(4) } } var content = ' '; if (/^fa[s|r|l|b|d]{0,1} /.test(icon) || icon.startsWith('icon-') === true) { cls = icon; } else if (icon.startsWith('bt-') === true) { cls = "bt " + icon; } else if (icon.startsWith('eva-') === true) { cls = "eva " + icon; } else if (/^ion-(md|ios|logo)/.test(icon) === true) { cls = "ionicons " + icon; } else if (icon.startsWith('ion-') === tr