UNPKG

@frontierjs/web

Version:

Web modules for FrontierJS

264 lines (260 loc) 7.15 kB
// ../../node_modules/svelte/internal/index.mjs function noop() { } function assign(tar, src) { for (const k in src) tar[k] = src[k]; return tar; } function run(fn) { return fn(); } function run_all(fns) { fns.forEach(run); } function is_function(thing) { return typeof thing === "function"; } function is_empty(obj) { return Object.keys(obj).length === 0; } var render_callbacks = []; function flush_render_callbacks(fns) { const filtered = []; const targets = []; render_callbacks.forEach((c) => fns.indexOf(c) === -1 ? filtered.push(c) : targets.push(c)); targets.forEach((c) => c()); render_callbacks = filtered; } var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global; var _boolean_attributes = [ "allowfullscreen", "allowpaymentrequest", "async", "autofocus", "autoplay", "checked", "controls", "default", "defer", "disabled", "formnovalidate", "hidden", "inert", "ismap", "itemscope", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "selected" ]; var boolean_attributes = /* @__PURE__ */ new Set([..._boolean_attributes]); function destroy_component(component, detaching) { const $$ = component.$$; if ($$.fragment !== null) { flush_render_callbacks($$.after_update); run_all($$.on_destroy); $$.fragment && $$.fragment.d(detaching); $$.on_destroy = $$.fragment = null; $$.ctx = []; } } var SvelteElement; if (typeof HTMLElement === "function") { SvelteElement = class extends HTMLElement { constructor() { super(); this.attachShadow({ mode: "open" }); } connectedCallback() { const { on_mount } = this.$$; this.$$.on_disconnect = on_mount.map(run).filter(is_function); for (const key in this.$$.slotted) { this.appendChild(this.$$.slotted[key]); } } attributeChangedCallback(attr, _oldValue, newValue) { this[attr] = newValue; } disconnectedCallback() { run_all(this.$$.on_disconnect); } $destroy() { destroy_component(this, 1); this.$destroy = noop; } $on(type, callback) { if (!is_function(callback)) { return noop; } const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []); callbacks.push(callback); return () => { const index = callbacks.indexOf(callback); if (index !== -1) callbacks.splice(index, 1); }; } $set($$props) { if (this.$$set && !is_empty($$props)) { this.$$.skip_bound = true; this.$$set($$props); this.$$.skip_bound = false; } } }; } // ../../node_modules/svelte/easing/index.mjs function cubicOut(t) { const f = t - 1; return f * f * f + 1; } function quintOut(t) { return --t * t * t * t * t + 1; } // ../../node_modules/svelte/transition/index.mjs function __rest(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; } function crossfade(_a) { var { fallback } = _a, defaults = __rest(_a, ["fallback"]); const to_receive = /* @__PURE__ */ new Map(); const to_send = /* @__PURE__ */ new Map(); function crossfade2(from_node, node, params) { const { delay = 0, duration = (d2) => Math.sqrt(d2) * 30, easing = cubicOut } = assign(assign({}, defaults), params); const from = from_node.getBoundingClientRect(); const to = node.getBoundingClientRect(); const dx = from.left - to.left; const dy = from.top - to.top; const dw = from.width / to.width; const dh = from.height / to.height; const d = Math.sqrt(dx * dx + dy * dy); const style = getComputedStyle(node); const transform = style.transform === "none" ? "" : style.transform; const opacity = +style.opacity; return { delay, duration: is_function(duration) ? duration(d) : duration, easing, css: (t, u) => ` opacity: ${t * opacity}; transform-origin: top left; transform: ${transform} translate(${u * dx}px,${u * dy}px) scale(${t + (1 - t) * dw}, ${t + (1 - t) * dh}); ` }; } function transition(items, counterparts, intro) { return (node, params) => { items.set(params.key, node); return () => { if (counterparts.has(params.key)) { const other_node = counterparts.get(params.key); counterparts.delete(params.key); return crossfade2(other_node, node, params); } items.delete(params.key); return fallback && fallback(node, params, intro); }; }; } return [ transition(to_send, to_receive, false), transition(to_receive, to_send, true) ]; } // src/animations.js var [send, receive] = crossfade({ duration: (d) => Math.sqrt(d * 200), fallback(node, params) { const style = getComputedStyle(node); const transform = style.transform === "none" ? "" : style.transform; return { duration: 200, easing: quintOut, css: (t) => ` transform: ${transform} scale(${t}); opacity: ${t} ` }; } }); var crossfader = { send, receive }; function editableElement(node, editing) { const height = 4; const nodeClasses = node.className; const disabledClass = "bg-gray-100 !border-none resize-none overflow-auto shadow-none max-h-72"; if (!editing) { node.className = `${nodeClasses} ${disabledClass}`; } node.style.height = "1px"; node.style.height = height + node.scrollHeight + "px"; const onInput = () => { node.style.height = "1px"; node.style.height = height + node.scrollHeight + "px"; }; node.addEventListener("input", onInput); return { update(editing2) { if (!editing2) { node.style.height = "1px"; node.style.height = height + node.scrollHeight + "px"; return node.className = `${nodeClasses} ${disabledClass}`; } return node.className = nodeClasses; }, destroy() { node.removeEventListener("input", onInput); } }; } function slider(node) { let isDown = false; let startX; let scrollLeft; node.addEventListener("mousedown", (e) => { isDown = true; node.classList.add("active"); startX = e.pageX - node.offsetLeft; scrollLeft = node.scrollLeft; }); node.addEventListener("mouseleave", () => { isDown = false; node.classList.remove("active"); }); node.addEventListener("mouseup", () => { isDown = false; node.classList.remove("active"); }); node.addEventListener("mousemove", (e) => { if (!isDown) return; e.preventDefault(); const x = e.pageX - node.offsetLeft; const walk = x - startX; node.scrollLeft = scrollLeft - walk; }); } export { crossfader, editableElement, slider };