@codeperate/cdp-ui-library
Version:
Codeperate UI Library
1,748 lines (1,586 loc) • 258 kB
JavaScript
import { getRenderingRef, forceUpdate, h, Host, Build, createEvent, proxyCustomElement } from '@stencil/core/internal/client';
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
const appendToMap = (map, propName, value) => {
const items = map.get(propName);
if (!items) {
map.set(propName, [value]);
}
else if (!items.includes(value)) {
items.push(value);
}
};
const debounce$1 = (fn, ms) => {
let timeoutId;
return (...args) => {
if (timeoutId) {
clearTimeout(timeoutId);
}
timeoutId = setTimeout(() => {
timeoutId = 0;
fn(...args);
}, ms);
};
};
/**
* Check if a possible element isConnected.
* The property might not be there, so we check for it.
*
* We want it to return true if isConnected is not a property,
* otherwise we would remove these elements and would not update.
*
* Better leak in Edge than to be useless.
*/
const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
const cleanupElements = debounce$1((map) => {
for (let key of map.keys()) {
map.set(key, map.get(key).filter(isConnected));
}
}, 2000);
const stencilSubscription = ({ on }) => {
const elmsToUpdate = new Map();
if (typeof getRenderingRef === 'function') {
// If we are not in a stencil project, we do nothing.
// This function is not really exported by @stencil/core.
on('dispose', () => {
elmsToUpdate.clear();
});
on('get', (propName) => {
const elm = getRenderingRef();
if (elm) {
appendToMap(elmsToUpdate, propName, elm);
}
});
on('set', (propName) => {
const elements = elmsToUpdate.get(propName);
if (elements) {
elmsToUpdate.set(propName, elements.filter(forceUpdate));
}
cleanupElements(elmsToUpdate);
});
on('reset', () => {
elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
cleanupElements(elmsToUpdate);
});
}
};
const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
let states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
const handlers = {
dispose: [],
get: [],
set: [],
reset: [],
};
const reset = () => {
states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
handlers.reset.forEach((cb) => cb());
};
const dispose = () => {
// Call first dispose as resetting the state would
// cause less updates ;)
handlers.dispose.forEach((cb) => cb());
reset();
};
const get = (propName) => {
handlers.get.forEach((cb) => cb(propName));
return states.get(propName);
};
const set = (propName, value) => {
const oldValue = states.get(propName);
if (shouldUpdate(value, oldValue, propName)) {
states.set(propName, value);
handlers.set.forEach((cb) => cb(propName, value, oldValue));
}
};
const state = (typeof Proxy === 'undefined'
? {}
: new Proxy(defaultState, {
get(_, propName) {
return get(propName);
},
ownKeys(_) {
return Array.from(states.keys());
},
getOwnPropertyDescriptor() {
return {
enumerable: true,
configurable: true,
};
},
has(_, propName) {
return states.has(propName);
},
set(_, propName, value) {
set(propName, value);
return true;
},
}));
const on = (eventName, callback) => {
handlers[eventName].push(callback);
return () => {
removeFromArray(handlers[eventName], callback);
};
};
const onChange = (propName, cb) => {
const unSet = on('set', (key, newValue) => {
if (key === propName) {
cb(newValue);
}
});
const unReset = on('reset', () => cb(defaultState[propName]));
return () => {
unSet();
unReset();
};
};
const use = (...subscriptions) => subscriptions.forEach((subscription) => {
if (subscription.set) {
on('set', subscription.set);
}
if (subscription.get) {
on('get', subscription.get);
}
if (subscription.reset) {
on('reset', subscription.reset);
}
});
const forceUpdate = (key) => {
const oldValue = states.get(key);
handlers.set.forEach((cb) => cb(key, oldValue, oldValue));
};
return {
state,
get,
set,
on,
onChange,
use,
dispose,
reset,
forceUpdate,
};
};
const removeFromArray = (array, item) => {
const index = array.indexOf(item);
if (index >= 0) {
array[index] = array[array.length - 1];
array.length--;
}
};
const createStore = (defaultState, shouldUpdate) => {
const map = createObservableMap(defaultState, shouldUpdate);
stencilSubscription(map);
return map;
};
const createRouter = (opts) => {
var _a;
const win = window;
const url = new URL(win.location.href);
const parseURL = (_a = opts === null || opts === void 0 ? void 0 : opts.parseURL) !== null && _a !== void 0 ? _a : DEFAULT_PARSE_URL;
const { state, onChange, dispose } = createStore({
url,
activePath: parseURL(url)
}, (newV, oldV, prop) => {
if (prop === 'url') {
return newV.href !== oldV.href;
}
return newV !== oldV;
});
const push = (href) => {
history.pushState(null, null, href);
const url = new URL(href, document.baseURI);
state.url = url;
state.activePath = parseURL(url);
};
const match = (routes) => {
const { activePath } = state;
for (let route of routes) {
const params = matchPath(activePath, route.path);
if (params) {
if (route.to != null) {
const to = (typeof route.to === 'string')
? route.to
: route.to(activePath);
push(to);
return match(routes);
}
else {
return { params, route };
}
}
}
return undefined;
};
const navigationChanged = () => {
const url = new URL(win.location.href);
state.url = url;
state.activePath = parseURL(url);
};
const Switch = (_, childrenRoutes) => {
const result = match(childrenRoutes);
if (result) {
if (typeof result.route.jsx === 'function') {
return result.route.jsx(result.params);
}
else {
return result.route.jsx;
}
}
};
const disposeRouter = () => {
win.removeEventListener('popstate', navigationChanged);
dispose();
};
const router = {
Switch,
get url() {
return state.url;
},
get activePath() {
return state.activePath;
},
push,
onChange: onChange,
dispose: disposeRouter,
};
// Initial update
navigationChanged();
// Listen URL changes
win.addEventListener('popstate', navigationChanged);
return router;
};
const matchPath = (pathname, path) => {
if (typeof path === 'string') {
if (path === pathname) {
return {};
}
}
else if (typeof path === 'function') {
const params = path(pathname);
if (params) {
return params === true
? {}
: { ...params };
}
}
else {
const results = path.exec(pathname);
if (results) {
path.lastIndex = 0;
return { ...results };
}
}
return undefined;
};
const DEFAULT_PARSE_URL = (url) => {
return url.pathname.toLowerCase();
};
createRouter();
function deepAssign(newObj, currentObj) {
if (!newObj)
return currentObj;
for (const [key, value] of Object.entries(newObj)) {
if (!currentObj[key]) {
continue;
}
if (typeof value == 'object' && value && value.constructor.name === 'Object') {
newObj[key] = deepAssign(newObj[key], currentObj[key]);
}
}
return Object.assign(Object.assign({}, currentObj), newObj);
}
const CdpAccordion$1 = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.props = { display: false };
this.defaultConfig = {
classList: {
content: 'transition-all duration-500 overflow-hidden',
expanded: 'expanded',
},
maxHeight: '100vh',
toggle: true,
};
}
toggle() {
this.props = Object.assign(Object.assign({}, this.props), { display: !this.props.display });
}
componentWillLoad() {
this._config = deepAssign(this.config, this.defaultConfig);
}
render() {
const { classList, maxHeight, toggle } = this._config;
const { display } = this.props;
const hostClass = display ? classList.expanded : '';
return (h(Host, { class: hostClass }, h("div", { onClick: () => (toggle ? this.toggle() : null) }, h("slot", { name: "accordion" })), h("div", { ref: el => (this.contentEl = el), class: classList.content, style: { maxHeight: display ? maxHeight : '0' } }, h("slot", null))));
}
get rootEl() { return this; }
};
const CdpMenu$1 = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
this._config = {};
this.defaultConfig = {
sensitivity: 0.5,
background: true,
classList: {
host: 'h-full block relative <md:w-0',
container: '<md:transition-transform <md:translate-x-[-100%] transform sticky h-screen w-full top-0 overflow-y-auto',
background: '<md:fixed md:hidden w-screen h-screen bg-black bg-opacity-50',
},
};
this.props = {
display: false,
};
this.translateX = 0;
this.moveHandler = (e) => {
if (e instanceof TouchEvent)
this.finalXPos = e.touches[0].clientX;
this.offsetX = (this.finalXPos - this.initXPos) * this._config.sensitivity;
if (this.offsetX <= 0)
this.offsetX = 0;
if (this.offsetX >= 100)
this.offsetX = 100;
this.translateX = this.offsetX;
this.setTranslateX();
};
}
touchDownHandler(e) {
if (this.containerEl.contains(e.target))
return;
if (Build.isBrowser) {
const transform = getComputedStyle(this.containerEl).transform;
const matrix = new WebKitCSSMatrix(transform);
if (matrix.m41 >= 0)
return;
}
this.initXPos = e.touches[0].clientX;
addEventListener('touchmove', this.moveHandler, { passive: false });
}
touchUpHandler() {
removeEventListener('touchmove', this.moveHandler);
if (this.translateX <= 50) {
this.close();
}
if (this.translateX > 50) {
this.open();
}
}
open() {
this._props.display = true;
}
close() {
this._props.display = false;
}
setTranslateX() {
if (this.containerEl)
this.containerEl.style.transform = `translateX(${this.translateX - 100}%)`;
}
removeTranslateX() {
if (this.containerEl) {
this.containerEl.style.transform = null;
this.translateX = 0;
}
}
componentWillLoad() {
this._config = deepAssign(this.config, this.defaultConfig);
this.createProxy();
}
createProxy() {
var _a;
const set = (target, prop, value, receiver) => {
this.props = Object.assign(Object.assign({}, target), { [prop]: value });
return Reflect.set(target, prop, value, receiver);
};
this._props = new Proxy(this.props, (_a = this._config.proxyHandler) !== null && _a !== void 0 ? _a : { set });
}
configChangeHandler(n) {
if (n.display) {
this.translateX = 100;
this.setTranslateX();
}
if (!n.display)
this.removeTranslateX();
}
render() {
const { classList, width, background } = this._config;
const { display } = this.props;
return (h(Host, { class: `${classList.host}` }, display && background ? h("div", { class: `${classList.background}`, onClick: () => this.close() }) : '', h("div", { ref: el => (this.containerEl = el), class: `${classList.container}`, style: width ? { width: width } : {} }, h("slot", null))));
}
get rootEl() { return this; }
static get watchers() { return {
"props": ["configChangeHandler"]
}; }
};
/**
* Tokenize input string.
*/
function lexer(str) {
var tokens = [];
var i = 0;
while (i < str.length) {
var char = str[i];
if (char === "*" || char === "+" || char === "?") {
tokens.push({ type: "MODIFIER", index: i, value: str[i++] });
continue;
}
if (char === "\\") {
tokens.push({ type: "ESCAPED_CHAR", index: i++, value: str[i++] });
continue;
}
if (char === "{") {
tokens.push({ type: "OPEN", index: i, value: str[i++] });
continue;
}
if (char === "}") {
tokens.push({ type: "CLOSE", index: i, value: str[i++] });
continue;
}
if (char === ":") {
var name = "";
var j = i + 1;
while (j < str.length) {
var code = str.charCodeAt(j);
if (
// `0-9`
(code >= 48 && code <= 57) ||
// `A-Z`
(code >= 65 && code <= 90) ||
// `a-z`
(code >= 97 && code <= 122) ||
// `_`
code === 95) {
name += str[j++];
continue;
}
break;
}
if (!name)
throw new TypeError("Missing parameter name at " + i);
tokens.push({ type: "NAME", index: i, value: name });
i = j;
continue;
}
if (char === "(") {
var count = 1;
var pattern = "";
var j = i + 1;
if (str[j] === "?") {
throw new TypeError("Pattern cannot start with \"?\" at " + j);
}
while (j < str.length) {
if (str[j] === "\\") {
pattern += str[j++] + str[j++];
continue;
}
if (str[j] === ")") {
count--;
if (count === 0) {
j++;
break;
}
}
else if (str[j] === "(") {
count++;
if (str[j + 1] !== "?") {
throw new TypeError("Capturing groups are not allowed at " + j);
}
}
pattern += str[j++];
}
if (count)
throw new TypeError("Unbalanced pattern at " + i);
if (!pattern)
throw new TypeError("Missing pattern at " + i);
tokens.push({ type: "PATTERN", index: i, value: pattern });
i = j;
continue;
}
tokens.push({ type: "CHAR", index: i, value: str[i++] });
}
tokens.push({ type: "END", index: i, value: "" });
return tokens;
}
/**
* Parse a string for the raw tokens.
*/
function parse(str, options) {
if (options === void 0) { options = {}; }
var tokens = lexer(str);
var _a = options.prefixes, prefixes = _a === void 0 ? "./" : _a;
var defaultPattern = "[^" + escapeString(options.delimiter || "/#?") + "]+?";
var result = [];
var key = 0;
var i = 0;
var path = "";
var tryConsume = function (type) {
if (i < tokens.length && tokens[i].type === type)
return tokens[i++].value;
};
var mustConsume = function (type) {
var value = tryConsume(type);
if (value !== undefined)
return value;
var _a = tokens[i], nextType = _a.type, index = _a.index;
throw new TypeError("Unexpected " + nextType + " at " + index + ", expected " + type);
};
var consumeText = function () {
var result = "";
var value;
// tslint:disable-next-line
while ((value = tryConsume("CHAR") || tryConsume("ESCAPED_CHAR"))) {
result += value;
}
return result;
};
while (i < tokens.length) {
var char = tryConsume("CHAR");
var name = tryConsume("NAME");
var pattern = tryConsume("PATTERN");
if (name || pattern) {
var prefix = char || "";
if (prefixes.indexOf(prefix) === -1) {
path += prefix;
prefix = "";
}
if (path) {
result.push(path);
path = "";
}
result.push({
name: name || key++,
prefix: prefix,
suffix: "",
pattern: pattern || defaultPattern,
modifier: tryConsume("MODIFIER") || ""
});
continue;
}
var value = char || tryConsume("ESCAPED_CHAR");
if (value) {
path += value;
continue;
}
if (path) {
result.push(path);
path = "";
}
var open = tryConsume("OPEN");
if (open) {
var prefix = consumeText();
var name_1 = tryConsume("NAME") || "";
var pattern_1 = tryConsume("PATTERN") || "";
var suffix = consumeText();
mustConsume("CLOSE");
result.push({
name: name_1 || (pattern_1 ? key++ : ""),
pattern: name_1 && !pattern_1 ? defaultPattern : pattern_1,
prefix: prefix,
suffix: suffix,
modifier: tryConsume("MODIFIER") || ""
});
continue;
}
mustConsume("END");
}
return result;
}
/**
* Escape a regular expression string.
*/
function escapeString(str) {
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, "\\$1");
}
/**
* Get the flags for a regexp from the options.
*/
function flags(options) {
return options && options.sensitive ? "" : "i";
}
/**
* Pull out keys from a regexp.
*/
function regexpToRegexp(path, keys) {
if (!keys)
return path;
var groupsRegex = /\((?:\?<(.*?)>)?(?!\?)/g;
var index = 0;
var execResult = groupsRegex.exec(path.source);
while (execResult) {
keys.push({
// Use parenthesized substring match if available, index otherwise
name: execResult[1] || index++,
prefix: "",
suffix: "",
modifier: "",
pattern: ""
});
execResult = groupsRegex.exec(path.source);
}
return path;
}
/**
* Transform an array into a regexp.
*/
function arrayToRegexp(paths, keys, options) {
var parts = paths.map(function (path) { return pathToRegexp(path, keys, options).source; });
return new RegExp("(?:" + parts.join("|") + ")", flags(options));
}
/**
* Create a path regexp from string input.
*/
function stringToRegexp(path, keys, options) {
return tokensToRegexp(parse(path, options), keys, options);
}
/**
* Expose a function for taking tokens and returning a RegExp.
*/
function tokensToRegexp(tokens, keys, options) {
if (options === void 0) { options = {}; }
var _a = options.strict, strict = _a === void 0 ? false : _a, _b = options.start, start = _b === void 0 ? true : _b, _c = options.end, end = _c === void 0 ? true : _c, _d = options.encode, encode = _d === void 0 ? function (x) { return x; } : _d;
var endsWith = "[" + escapeString(options.endsWith || "") + "]|$";
var delimiter = "[" + escapeString(options.delimiter || "/#?") + "]";
var route = start ? "^" : "";
// Iterate over the tokens and create our regexp string.
for (var _i = 0, tokens_1 = tokens; _i < tokens_1.length; _i++) {
var token = tokens_1[_i];
if (typeof token === "string") {
route += escapeString(encode(token));
}
else {
var prefix = escapeString(encode(token.prefix));
var suffix = escapeString(encode(token.suffix));
if (token.pattern) {
if (keys)
keys.push(token);
if (prefix || suffix) {
if (token.modifier === "+" || token.modifier === "*") {
var mod = token.modifier === "*" ? "?" : "";
route += "(?:" + prefix + "((?:" + token.pattern + ")(?:" + suffix + prefix + "(?:" + token.pattern + "))*)" + suffix + ")" + mod;
}
else {
route += "(?:" + prefix + "(" + token.pattern + ")" + suffix + ")" + token.modifier;
}
}
else {
route += "(" + token.pattern + ")" + token.modifier;
}
}
else {
route += "(?:" + prefix + suffix + ")" + token.modifier;
}
}
}
if (end) {
if (!strict)
route += delimiter + "?";
route += !options.endsWith ? "$" : "(?=" + endsWith + ")";
}
else {
var endToken = tokens[tokens.length - 1];
var isEndDelimited = typeof endToken === "string"
? delimiter.indexOf(endToken[endToken.length - 1]) > -1
: // tslint:disable-next-line
endToken === undefined;
if (!strict) {
route += "(?:" + delimiter + "(?=" + endsWith + "))?";
}
if (!isEndDelimited) {
route += "(?=" + delimiter + "|" + endsWith + ")";
}
}
return new RegExp(route, flags(options));
}
/**
* Normalize the given path string, returning a regular expression.
*
* An empty array can be passed in for the keys, which will hold the
* placeholder key descriptions. For example, using `/user/:id`, `keys` will
* contain `[{ name: 'id', delimiter: '/', optional: false, repeat: false }]`.
*/
function pathToRegexp(path, keys, options) {
if (path instanceof RegExp)
return regexpToRegexp(path, keys);
if (Array.isArray(path))
return arrayToRegexp(path, keys, options);
return stringToRegexp(path, keys, options);
}
var __rest = (undefined && undefined.__rest) || function (s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
const CdpMenuList$1 = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.defaultConfig = {
menuItems: [],
anchorPropsFn: null,
classList: {
host: 'grid grid-cols-1 gap-y-2 auto-rows-min',
menuItem: 'py-2 px-4 hover:bg-light-blue-600 hover:text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4 cursor-pointer',
menuItemActive: 'py-2 px-4 bg-light-blue-600 text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4 cursor-pointer',
subMenuItem: 'py-1 px-4 hover:bg-light-blue-600 hover:text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4',
subMenuItemActive: 'py-1 px-4 bg-light-blue-600 text-white rounded-md grid grid-cols-[max-content,1fr,max-content] items-center gap-4',
subMenuWrapper: 'grid grid-cols-1 gap-y-1 mt-2 pl-4',
},
};
}
componentWillLoad() {
this._config = deepAssign(this.config, this.defaultConfig);
}
isActive(href, activePath) {
const regex = pathToRegexp(href);
if (activePath.match(regex))
return true;
return false;
}
render() {
const { classList, anchorPropsFn, menuItems } = this._config;
const activePath = this.props.activePath;
return (h(Host, { class: classList.host }, menuItems.map((_a) => {
var { name, isActive, icon, indicator } = _a, props = __rest(_a, ["name", "isActive", "icon", "indicator"]);
let href = props['href'];
let expand = props['expand'];
let active = isActive ? isActive(activePath) : this.isActive(href, activePath);
if (props['nested'])
return (h("cdp-accordion", { props: { display: expand ? expand : active }, config: { toggle: !href } }, h("a", Object.assign({ slot: "accordion", class: active ? classList.menuItemActive : classList.menuItem }, (href ? anchorPropsFn(href) : {})), icon ? icon(active) : '', name, indicator ? indicator(active) : ''), h("div", { class: classList.subMenuWrapper }, props['nested'].map(({ name, href, indicator, icon, isActive }) => {
let active = isActive ? isActive(activePath) : this.isActive(href, activePath);
return (h("a", Object.assign({}, anchorPropsFn(href), { class: active ? classList.subMenuItemActive : classList.subMenuItem }), icon ? icon(active) : '', name, indicator ? indicator(active) : ''));
}))));
return (h("a", Object.assign({}, anchorPropsFn(href), { class: active ? classList.menuItemActive : classList.menuItem }), icon ? icon(active) : '', name, indicator ? indicator(active) : ''));
})));
}
get rootEl() { return this; }
};
const CdpModal$1 = class extends HTMLElement {
constructor() {
super();
this.__registerHost();
this.opened = createEvent(this, "opened", 7);
this.closed = createEvent(this, "closed", 7);
this.props = {};
this.defaultConfig = {
classList: {
host: 'absolute h-full w-full flex items-center justify-center left-0 top-0 bg-black bg-opacity-80 backdrop-filter',
},
animation: {
open: 'animated animate-zoom-in',
close: 'animated animate-zoom-out',
},
bgClose: true,
};
}
animationendHandler() {
const { display } = this.props;
if (!display)
this.closedFn();
else
this.openedFn();
}
openedFn() {
this.opened.emit();
this.animeClass = '';
}
closedFn() {
this.computedDisplay = false;
this.closed.emit();
this.animeClass = '';
}
open() {
const { open } = this._config.animation;
this.computedDisplay = true;
if (open)
this.animeClass = open;
else
this.openedFn();
}
close() {
const { close } = this._config.animation;
if (close)
this.animeClass = close;
else
this.closedFn();
}
propsHandler(n, o) {
if (n.display && !o.display)
this.open();
if (!n.display && o.display)
this.close();
}
configChangeHandler() {
this._config = deepAssign(this.config, this.defaultConfig);
}
componentWillLoad() {
this.configChangeHandler();
this.computedDisplay = this.props.display;
if (this.props.display)
this.open();
}
componentDidRender() {
const { open, close } = this._config.animation;
if (this.rootEl) {
if (open)
open.split(' ').forEach(val => this.rootEl.children[0].classList.remove(val));
if (close)
close.split(' ').forEach(val => this.rootEl.children[0].classList.remove(val));
if (this.animeClass)
this.animeClass.split(' ').forEach(val => this.rootEl.children[0].classList.add(val));
}
}
bgCloseHandler(e) {
if (this._config.bgClose && e.target == this.rootEl)
this.props = Object.assign(Object.assign({}, this.props), { display: false });
}
render() {
const { classList } = this._config;
const hostClass = classList.host + (this.computedDisplay ? '' : ' !hidden');
return (h(Host, { class: hostClass, onClick: e => this.bgCloseHandler(e) }, h("slot", null)));
}
get rootEl() { return this; }
static get watchers() { return {
"props": ["propsHandler"],
"config": ["configChangeHandler"]
}; }
};
/**
* SSR Window 3.0.0
* Better handling for window object in SSR environment
* https://github.com/nolimits4web/ssr-window
*
* Copyright 2020, Vladimir Kharlampidi
*
* Licensed under MIT
*
* Released on: November 9, 2020
*/
/* eslint-disable no-param-reassign */
function isObject$1(obj) {
return (obj !== null &&
typeof obj === 'object' &&
'constructor' in obj &&
obj.constructor === Object);
}
function extend$1(target, src) {
if (target === void 0) { target = {}; }
if (src === void 0) { src = {}; }
Object.keys(src).forEach(function (key) {
if (typeof target[key] === 'undefined')
target[key] = src[key];
else if (isObject$1(src[key]) &&
isObject$1(target[key]) &&
Object.keys(src[key]).length > 0) {
extend$1(target[key], src[key]);
}
});
}
var ssrDocument = {
body: {},
addEventListener: function () { },
removeEventListener: function () { },
activeElement: {
blur: function () { },
nodeName: '',
},
querySelector: function () {
return null;
},
querySelectorAll: function () {
return [];
},
getElementById: function () {
return null;
},
createEvent: function () {
return {
initEvent: function () { },
};
},
createElement: function () {
return {
children: [],
childNodes: [],
style: {},
setAttribute: function () { },
getElementsByTagName: function () {
return [];
},
};
},
createElementNS: function () {
return {};
},
importNode: function () {
return null;
},
location: {
hash: '',
host: '',
hostname: '',
href: '',
origin: '',
pathname: '',
protocol: '',
search: '',
},
};
function getDocument() {
var doc = typeof document !== 'undefined' ? document : {};
extend$1(doc, ssrDocument);
return doc;
}
var ssrWindow = {
document: ssrDocument,
navigator: {
userAgent: '',
},
location: {
hash: '',
host: '',
hostname: '',
href: '',
origin: '',
pathname: '',
protocol: '',
search: '',
},
history: {
replaceState: function () { },
pushState: function () { },
go: function () { },
back: function () { },
},
CustomEvent: function CustomEvent() {
return this;
},
addEventListener: function () { },
removeEventListener: function () { },
getComputedStyle: function () {
return {
getPropertyValue: function () {
return '';
},
};
},
Image: function () { },
Date: function () { },
screen: {},
setTimeout: function () { },
clearTimeout: function () { },
matchMedia: function () {
return {};
},
requestAnimationFrame: function (callback) {
if (typeof setTimeout === 'undefined') {
callback();
return null;
}
return setTimeout(callback, 0);
},
cancelAnimationFrame: function (id) {
if (typeof setTimeout === 'undefined') {
return;
}
clearTimeout(id);
},
};
function getWindow$1() {
var win = typeof window !== 'undefined' ? window : {};
extend$1(win, ssrWindow);
return win;
}
/**
* Dom7 3.0.0
* Minimalistic JavaScript library for DOM manipulation, with a jQuery-compatible API
* https://framework7.io/docs/dom7.html
*
* Copyright 2020, Vladimir Kharlampidi
*
* Licensed under MIT
*
* Released on: November 9, 2020
*/
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = 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 _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct) return false;
if (Reflect.construct.sham) return false;
if (typeof Proxy === "function") return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function () {}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) _setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? new Map() : undefined;
_wrapNativeSuper = function _wrapNativeSuper(Class) {
if (Class === null || !_isNativeFunction(Class)) return Class;
if (typeof Class !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class)) return _cache.get(Class);
_cache.set(Class, Wrapper);
}
function Wrapper() {
return _construct(Class, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class);
};
return _wrapNativeSuper(Class);
}
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
/* eslint-disable no-proto */
function makeReactive(obj) {
var proto = obj.__proto__;
Object.defineProperty(obj, '__proto__', {
get: function get() {
return proto;
},
set: function set(value) {
proto.__proto__ = value;
}
});
}
var Dom7 = /*#__PURE__*/function (_Array) {
_inheritsLoose(Dom7, _Array);
function Dom7(items) {
var _this;
_this = _Array.call.apply(_Array, [this].concat(items)) || this;
makeReactive(_assertThisInitialized(_this));
return _this;
}
return Dom7;
}( /*#__PURE__*/_wrapNativeSuper(Array));
function arrayFlat(arr) {
if (arr === void 0) {
arr = [];
}
var res = [];
arr.forEach(function (el) {
if (Array.isArray(el)) {
res.push.apply(res, arrayFlat(el));
} else {
res.push(el);
}
});
return res;
}
function arrayFilter(arr, callback) {
return Array.prototype.filter.call(arr, callback);
}
function arrayUnique(arr) {
var uniqueArray = [];
for (var i = 0; i < arr.length; i += 1) {
if (uniqueArray.indexOf(arr[i]) === -1) uniqueArray.push(arr[i]);
}
return uniqueArray;
}
function qsa(selector, context) {
if (typeof selector !== 'string') {
return [selector];
}
var a = [];
var res = context.querySelectorAll(selector);
for (var i = 0; i < res.length; i += 1) {
a.push(res[i]);
}
return a;
}
function $(selector, context) {
var window = getWindow$1();
var document = getDocument();
var arr = [];
if (!context && selector instanceof Dom7) {
return selector;
}
if (!selector) {
return new Dom7(arr);
}
if (typeof selector === 'string') {
var html = selector.trim();
if (html.indexOf('<') >= 0 && html.indexOf('>') >= 0) {
var toCreate = 'div';
if (html.indexOf('<li') === 0) toCreate = 'ul';
if (html.indexOf('<tr') === 0) toCreate = 'tbody';
if (html.indexOf('<td') === 0 || html.indexOf('<th') === 0) toCreate = 'tr';
if (html.indexOf('<tbody') === 0) toCreate = 'table';
if (html.indexOf('<option') === 0) toCreate = 'select';
var tempParent = document.createElement(toCreate);
tempParent.innerHTML = html;
for (var i = 0; i < tempParent.childNodes.length; i += 1) {
arr.push(tempParent.childNodes[i]);
}
} else {
arr = qsa(selector.trim(), context || document);
} // arr = qsa(selector, document);
} else if (selector.nodeType || selector === window || selector === document) {
arr.push(selector);
} else if (Array.isArray(selector)) {
if (selector instanceof Dom7) return selector;
arr = selector;
}
return new Dom7(arrayUnique(arr));
}
$.fn = Dom7.prototype;
function addClass() {
for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
classes[_key] = arguments[_key];
}
var classNames = arrayFlat(classes.map(function (c) {
return c.split(' ');
}));
this.forEach(function (el) {
var _el$classList;
(_el$classList = el.classList).add.apply(_el$classList, classNames);
});
return this;
}
function removeClass() {
for (var _len2 = arguments.length, classes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
classes[_key2] = arguments[_key2];
}
var classNames = arrayFlat(classes.map(function (c) {
return c.split(' ');
}));
this.forEach(function (el) {
var _el$classList2;
(_el$classList2 = el.classList).remove.apply(_el$classList2, classNames);
});
return this;
}
function toggleClass() {
for (var _len3 = arguments.length, classes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
classes[_key3] = arguments[_key3];
}
var classNames = arrayFlat(classes.map(function (c) {
return c.split(' ');
}));
this.forEach(function (el) {
classNames.forEach(function (className) {
el.classList.toggle(className);
});
});
}
function hasClass() {
for (var _len4 = arguments.length, classes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
classes[_key4] = arguments[_key4];
}
var classNames = arrayFlat(classes.map(function (c) {
return c.split(' ');
}));
return arrayFilter(this, function (el) {
return classNames.filter(function (className) {
return el.classList.contains(className);
}).length > 0;
}).length > 0;
}
function attr(attrs, value) {
if (arguments.length === 1 && typeof attrs === 'string') {
// Get attr
if (this[0]) return this[0].getAttribute(attrs);
return undefined;
} // Set attrs
for (var i = 0; i < this.length; i += 1) {
if (arguments.length === 2) {
// String
this[i].setAttribute(attrs, value);
} else {
// Object
for (var attrName in attrs) {
this[i][attrName] = attrs[attrName];
this[i].setAttribute(attrName, attrs[attrName]);
}
}
}
return this;
}
function removeAttr(attr) {
for (var i = 0; i < this.length; i += 1) {
this[i].removeAttribute(attr);
}
return this;
}
function transform(transform) {
for (var i = 0; i < this.length; i += 1) {
this[i].style.transform = transform;
}
return this;
}
function transition$1(duration) {
for (var i = 0; i < this.length; i += 1) {
this[i].style.transitionDuration = typeof duration !== 'string' ? duration + "ms" : duration;
}
return this;
}
function on() {
for (var _len5 = arguments.length, args = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
args[_key5] = arguments[_key5];
}
var eventType = args[0],
targetSelector = args[1],
listener = args[2],
capture = args[3];
if (typeof args[1] === 'function') {
eventType = args[0];
listener = args[1];
capture = args[2];
targetSelector = undefined;
}
if (!capture) capture = false;
function handleLiveEvent(e) {
var target = e.target;
if (!target) return;
var eventData = e.target.dom7EventData || [];
if (eventData.indexOf(e) < 0) {
eventData.unshift(e);
}
if ($(target).is(targetSelector)) listener.apply(target, eventData);else {
var _parents = $(target).parents(); // eslint-disable-line
for (var k = 0; k < _parents.length; k += 1) {
if ($(_parents[k]).is(targetSelector)) listener.apply(_parents[k], eventData);
}
}
}
function handleEvent(e) {
var eventData = e && e.target ? e.target.dom7EventData || [] : [];
if (eventData.indexOf(e) < 0) {
eventData.unshift(e);
}
listener.apply(this, eventData);
}
var events = eventType.split(' ');
var j;
for (var i = 0; i < this.length; i += 1) {
var el = this[i];
if (!targetSelector) {
for (j = 0; j < events.length; j += 1) {
var event = events[j];
if (!el.dom7Listeners) el.dom7Listeners = {};
if (!el.dom7Listeners[event]) el.dom7Listeners[event] = [];
el.dom7Listeners[event].push({
listener: listener,
proxyListener: handleEvent
});
el.addEventListener(event, handleEvent, capture);
}
} else {
// Live events
for (j = 0; j < events.length; j += 1) {
var _event = events[j];
if (!el.dom7LiveListeners) el.dom7LiveListeners = {};
if (!el.dom7LiveListeners[_event]) el.dom7LiveListeners[_event] = [];
el.dom7LiveListeners[_event].push({
listener: listener,
proxyListener: handleLiveEvent
});
el.addEventListener(_event, handleLiveEvent, capture);
}
}
}
return this;
}
function off() {
for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) {
args[_key6] = arguments[_key6];
}
var eventType = args[0],
targetSelector = args[1],
listener = args[2],
capture = args[3];
if (typeof args[1] === 'function') {
eventType = args[0];
listener = args[1];
capture = args[2];
targetSelector = undefined;
}
if (!capture) capture = false;
var events = eventType.split(' ');
for (var i = 0; i < events.length; i += 1) {
var event = events[i];
for (var j = 0; j < this.length; j += 1) {
var el = this[j];
var handlers = void 0;
if (!targetSelector && el.dom7Listeners) {
handlers = el.dom7Listeners[event];
} else if (targetSelector && el.dom7LiveListeners) {
handlers = el.dom7LiveListeners[event];
}
if (handlers && handlers.length) {
for (var k = handlers.length - 1; k >= 0; k -= 1) {
var handler = handlers[k];
if (listener && handler.listener === listener) {
el.removeEventListener(event, handler.proxyListener, capture);
handlers.splice(k, 1);
} else if (listener && handler.listener && handler.listener.dom7proxy && handler.listener.dom7proxy === listener) {
el.removeEventListener(event, handler.proxyListener, capture);
handlers.splice(k, 1);
} else if (!listener) {
el.removeEventListener(event, handler.proxyListener, capture);
handlers.splice(k, 1);
}
}
}
}
}
return this;
}
function trigger() {
var window = getWindow$1();
for (var _len9 = arguments.length, args = new Array(_len9), _key9 = 0; _key9 < _len9; _key9++) {
args[_key9] = arguments[_key9];
}
var events = args[0].split(' ');
var eventData = args[1];
for (var i = 0; i < events.length; i += 1) {
var event = events[i];
for (var j = 0; j < this.length; j += 1) {
var el = this[j];
if (window.CustomEvent) {
var evt = new window.CustomEvent(event, {
detail: eventData,
bubbles: true,
cancelable: true
});
el.dom7EventData = args.filter(function (data, dataIndex) {
return dataIndex > 0;
});
el.dispatchEvent(evt);
el.dom7EventData = [];
delete el.dom7EventData;
}
}
}
return this;
}
function transitionEnd$1(callback) {
var dom = this;
function fireCallBack(e) {
if (e.target !== this) return;
callback.call(this, e);
dom.off('transitionend', fireCallBack);
}
if (callback) {
dom.on('transitionend', fireCallBack);
}
return this;
}
function outerWidth(includeMargins) {
if (this.length > 0) {
if (includeMargins) {
var _styles = this.styles();
return this[0].offsetWidth + parseFloat(_styles.getPropertyValue('margin-right')) + parseFloat(_styles.getPropertyValue('margin-left'));
}
return this[0].offsetWidth;
}
return null;
}
function outerHeight(includeMargins) {
if (this.length > 0) {
if (includeMargins) {
var _styles2 = this.styles();
return this[0].offsetHeight + parseFloat(_styles2.getPropertyValue('margin-top')) + parseFloat(_styles2.getPropertyValue('margin-bottom'));
}
return this[0].offsetHeight;
}
return null;
}
function offset$2() {
if (this.length > 0) {
var window = getWindow$1();
var document = getDocument();
var el = this[0];
var box = el.getBoundingClientRect();
var body = document.body;
var clientTop = el.clientTop || body.clientTop || 0;
var clientLeft = el.clientLeft || body.clientLeft || 0;
var scrollTop = el === window ? window.scrollY : el.scrollTop;
var scrollLeft = el === window ? window.scrollX : el.scrollLeft;
return {
top: box.top + scrollTop - clientTop,
left: box.left + scrollLeft - clientLeft
};
}
return null;
}
function styles() {
var window = getWindow$1();
if (this[0]) return window.getComputedStyle(this[0], null);
return {};
}
function css(props, value) {
var window = getWindow$1();
var i;
if (arguments.length === 1) {
if (typeof props === 'string') {
// .css('width')
if (this[0]) return window.getComputedStyle(this[0], null).getPropertyValue(props);
} else {
// .css({ width: '100px' })
for (i = 0; i < this.length; i += 1) {
for (var _prop in props) {
this[i].style[_prop] = props[_prop];
}
}
return this;
}
}
if (arguments.length === 2 && typeof props === 'string') {
// .css('width', '100px')
for (i = 0; i < this.length; i += 1) {
this[i].style[props] = value;
}
return this;
}
return this;
}
function each(callback) {
if (!callback) return this;
this.forEach(function (el, index) {
callback.apply(el, [el, index]);
});
return this;
}
function filter(callback) {
var result = arrayFilter(this, callback);
return $(result);
}
function html(html) {
if (typeof html === 'undefined') {
return this[0] ? this[0].innerHTML : null;
}
for (var i = 0; i < this.length; i += 1) {
this[i].innerHTML = html;
}
return this;
}
function text(text) {
if (typeof text === 'undefined') {
return this[0] ? this[0].textContent.trim() : null;
}
for (var i = 0; i < this.length; i += 1) {
this[i].textContent = text;
}
return this;
}
function is(selector) {
var window = getWindow$1();
var document = getDocument();
var el = this[0];
var compareWith;
var i;
if (!el || typeof selector === 'undefined') return false;
if (typeof selector === 'string') {
if (el.matches) return el.matches(selector);
if (el.webkitMatchesSelector) return el.webkitMatchesSelector(selector);
if (el.msMatchesSelector) return el.msMatchesSelector(selector);
compareWith = $(selector);
for (i = 0; i < compareWith.length; i += 1) {
if (compareWith[i] === el) return true;
}
return false;
}
if (selector === document) {
return el === document;
}
if (selector === window) {
return el === window;
}
if (selector.nodeType || selector instanceof Dom7) {
compareWith = selector.nodeType ? [selector] : selector;
for (i = 0; i < compareWith.length; i += 1) {
if (compareWith[i] === el) return true;
}
return false;
}
return false;
}
function index() {
var child = this[0];
var i;
if (child) {
i = 0; // eslint-disable-next-line
while ((child = child.previousSibling) !== null) {
if (child.nodeType === 1) i += 1;
}
return i;
}
return undefined;
}
function eq(index) {
if (typeof index === 'undefined') return this;
var length = this.length;
if (index > length - 1) {
return $([]);
}
if (index < 0) {
var returnIndex = length + index;
if (returnIndex < 0) return $([]);
return $([this[returnIndex]]);
}
return $([this[index]]);
}
function append() {
var newChild;
var document = getDocument();
for (var k = 0; k < arguments.length; k += 1) {
newChild = k < 0 || arguments.length <= k ? und