var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __commonJS = (cb, mod) => function __require() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod )); // ../../../config/tokens.js var require_tokens = __commonJS({ "../../../config/tokens.js"(exports, module) { var colors = { transparent: "transparent", current: "currentColor", black: "#000000", white: "#FFFFFF", coco: { gray: { 50: "#F9FAFB", 100: "#F3F4F6", 200: "#E5E7EB", 300: "#D1D5DB", 400: "#9CA3AF", 500: "#6B7280", 600: "#4B5563", 700: "#374151", 800: "#1F2937", 900: "#111827" } }, gray: { transparent: { 50: "rgba(0, 12, 39, 0.06)", 100: "rgba(0, 12, 39, 0.1)", 200: "rgba(0, 12, 39, 0.18)" } }, green: { 50: "#E8F3F1", 100: "#D1E7E2", 200: "#A3CFC5", 300: "#76B8AA", 400: "#48A08D", 500: "#1A8871", 600: "#137464", 700: "#0D6159", 800: "#084C4E", 900: "#013C43" }, red: { 50: "#FEF2F2", 100: "#FEE2E2", 200: "#FECACA", 300: "#FCA5A5", 400: "#F87171", 500: "#EF4444", 600: "#DC2626", 700: "#B91C1C", 800: "#991B1B", 900: "#7F1D1D" }, amber: { 50: "#FFFBEB", 100: "#FEF3C7", 200: "#FDE68A", 300: "#FCD34D", 400: "#FBBF24", 500: "#F59E0B", 600: "#D97706", 700: "#B45309", 800: "#92400E", 900: "#78350F" }, blue: { 50: "#F0F9FF", 100: "#E0F2FE", 200: "#BAE6FD", 300: "#7DD3FC", 400: "#38BDF8", 500: "#0EA5E9", 600: "#0284C7", 700: "#0369A1", 800: "#075985", 900: "#0C4A6E" }, teal: { 50: "#F0FDFA", 100: "#CCFBF1", 200: "#99F6E4", 300: "#5EEAD4", 400: "#2DD4BF", 500: "#14B8A6", 600: "#0D9488", 700: "#0F766E", 800: "#115E59", 900: "#134E4A" } }; var colorAliases = { primary: { ...colors.green }, positive: { ...colors.green }, negative: { ...colors.red }, warning: { ...colors.amber }, info: { ...colors.blue }, background: { header: { DEFAULT: "#427484" }, light: { 1: colors.white, 2: colors.coco.gray[50], 3: colors.coco.gray[100] }, dark: { 1: colors.coco.gray[900], 2: colors.coco.gray[800], 3: colors.coco.gray[700] }, primary: { DEFAULT: colors.green[500], light: colors.green[100] }, negative: { DEFAULT: colors.red[600], light: colors.red[100] }, warning: { DEFAULT: colors.amber[500], light: colors.amber[50] }, positive: { DEFAULT: colors.green[500], light: colors.green[100] }, info: { DEFAULT: colors.blue[600], light: colors.blue[100] } }, content: { dark: { 1: colors.coco.gray[900], 2: colors.coco.gray[800], 3: colors.coco.gray[600], muted: colors.coco.gray[400] }, light: { 1: colors.white, 2: colors.coco.gray[200], muted: colors.coco.gray[400] }, primary: { DEFAULT: colors.green[500], dark: colors.green[600], inverse: colors.green[300], "inverse-vivid": "#009979" }, negative: { DEFAULT: colors.red[600], dark: colors.red[700], inverse: colors.red[300] }, warning: { DEFAULT: colors.amber[600], dark: colors.amber[700], inverse: colors.amber[300] }, positive: { DEFAULT: colors.green[500], dark: colors.green[600], inverse: colors.green[300] }, info: { DEFAULT: colors.blue[600], dark: colors.blue[700], inverse: colors.blue[300] } } }; var screens = { xs: "380px", sm: "576px", md: "768px", lg: "992px", xl: "1200px", "2xl": "1400px", "3xl": "1600px", max: "1800px", "max-sm": { max: "576px" }, "max-md": { max: "768px" }, "max-lg": { max: "992px" }, "max-xl": { max: "1200px" }, "max-2xl": { max: "1400px" }, "max-max": { max: "1800px" }, letterbox: { raw: "(max-height: 760px) and (min-width: 576px)" }, print: { raw: "print" } // Note: PDFs are rendered at a viewport width of 1280px }; var fontSize = { "para-xs": ["12px", "16px"], "para-sm": ["14px", "20px"], "para-md": ["16px", "24px"], "para-lg": ["18px", "27px"], "label-xxs": ["10px", "12px"], "label-xs": ["12px", "14px"], "label-sm": ["14px", "16px"], "label-md": ["16px", "20px"], "label-lg": ["18px", "24px"], "display-1": ["96px", "96px"], "display-2": ["80px", "84px"], "display-3": ["64px", "68px"], "display-4": ["48px", "52px"], "relaxed-display-1": ["96px", "104px"], "relaxed-display-2": ["80px", "88px"], "relaxed-display-3": ["64px", "72px"], "relaxed-display-4": ["48px", "56px"], "heading-1": ["40px", "48px"], "heading-2": ["32px", "40px"], "heading-3": ["28px", "36px"], "heading-4": ["24px", "30px"], "heading-5": ["20px", "24px"], "heading-6": ["16px", "20px"], "subheading-1": ["32px", "40px"], "subheading-2": ["24px", "32px"], "subheading-3": ["20px", "28px"], "subheading-4": ["16px", "24px"] }; module.exports = { colors: { ...colors, ...colorAliases }, screens, fontSize, fontFamily: { displaySans: "proxima-nova", bodySans: "proxima-nova", displaySerif: "merriweather" } }; } }); // base/polyfills.js import "container-query-polyfill"; // helpers/alpine.js var alpine_exports = {}; __export(alpine_exports, { getComponent: () => getComponent, getData: () => getData, registerComponents: () => registerComponents, setData: () => setData }); function registerComponents(components) { document.addEventListener("alpine:init", () => { components.forEach((module) => { if (module.default && module.default.component === true) { Alpine.data(module.default.name, module.default); } }); }); return components; } function getComponent(el, throwOnError = false) { try { return Alpine.$data(el); } catch (error) { if (throwOnError) { throw error; } else { return null; } } } function getData(el) { const root = Alpine.closestRoot(el); return root ? Alpine.$data(root) : null; } function setData(el, newData) { const data = getData(el); return data ? Object.assign(data, newData) : null; } // helpers/color.js var color_exports = {}; __export(color_exports, { formatHex: () => formatHex, isDark: () => isDark, isLight: () => isLight, isValidHex: () => isValidHex }); function isDark(color) { let r; let g; let b; let hsp; color = +`0x${color.slice(1).replace(color.length < 5 && /./g, "$&$&")}`; r = color >> 16; g = color >> 8 & 255; b = color & 255; hsp = Math.sqrt(0.299 * (r * r) + 0.587 * (g * g) + 0.114 * (b * b)); if (hsp > 127.5) { return false; } return true; } function isLight(color) { return !isDark(color); } function isValidHex(color) { if (!color || typeof color !== "string") return false; if (color.substring(0, 1) === "#") color = color.substring(1); switch (color.length) { case 3: return /^[0-9A-F]{3}$/i.test(color); case 6: return /^[0-9A-F]{6}$/i.test(color); case 8: return /^[0-9A-F]{8}$/i.test(color); default: return false; } } function formatHex(str) { return `#${str.toUpperCase().replace("#", "")}`; } // helpers/dom.js var dom_exports = {}; __export(dom_exports, { castAttributeValue: () => castAttributeValue, isNode: () => isNode }); // helpers/lang.js var lang_exports = {}; __export(lang_exports, { camelCase: () => camelCase, isNumeric: () => isNumeric, isObject: () => isObject, kebabCase: () => kebabCase, keyBy: () => keyBy, mapValues: () => mapValues, nameFunction: () => nameFunction, roughSizeOfObject: () => roughSizeOfObject }); import camelCase from "lodash.camelcase"; import kebabCase from "lodash.kebabcase"; import mapValues from "lodash.mapvalues"; import keyBy from "lodash.keyby"; function nameFunction(name, body) { return { [name](...args) { return body.apply(this, args); } }[name]; } function isObject(thing) { return typeof thing === "object" && thing !== null; } function isNumeric(str) { if (typeof str != "string") return false; return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)... !isNaN(parseFloat(str)); } function roughSizeOfObject(object) { const objectList = []; const stack = [object]; let bytes = 0; while (stack.length) { const value = stack.pop(); if (typeof value === "boolean") { bytes += 4; } else if (typeof value === "string") { bytes += value.length * 2; } else if (typeof value === "number") { bytes += 8; } else if (typeof value === "object" && objectList.indexOf(value) === -1) { objectList.push(value); for (var i in value) { stack.push(value[i]); } } } return bytes; } // helpers/dom.js function castAttributeValue(value) { if (value === "false") { return false; } if (value === "true") { return true; } if (isNumeric(value)) { return parseInt(value, 10); } return value; } function isNode(o) { return typeof Node === "object" ? o instanceof Node : o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string"; } // helpers/location.js var location_exports = {}; __export(location_exports, { navigateTo: () => navigateTo }); function navigateTo(url, options = {}) { if (window.Turbo && options.turbo === true) { delete options.turbo; turboOptions = Object.assign({ action: "advance" }, options); window.Turbo.visit(url, turboOptions); } else { location.assign(url); } } // helpers/path.js var path_exports = {}; __export(path_exports, { basename: () => basename, dirname: () => dirname, stripExtension: () => stripExtension }); function stripExtension(filename) { return filename.substring(0, filename.lastIndexOf(".")) || filename; } function dirname(path) { return path ? path.match(/.*\//) : path; } function basename(path) { return path ? path.replace(/.*\//, "") : path; } // helpers/index.js var helpers_default = { ...alpine_exports, ...color_exports, ...dom_exports, ...lang_exports, ...location_exports, ...path_exports }; // base/tippy/index.js import tippy, { createSingleton, followCursor, roundArrow, hideAll } from "tippy.js"; // base/tippy/plugins/hide_on_esc.js var hideOnEsc = { name: "hideOnEsc", defaultValue: true, fn({ hide }) { function onKeyDown(event) { if (event.keyCode === 27) { hide(); } } return { onShow() { document.addEventListener("keydown", onKeyDown); }, onHide() { document.removeEventListener("keydown", onKeyDown); } }; } }; var hide_on_esc_default = hideOnEsc; // base/tippy/index.js tippy.setDefaultProps({ theme: null, allowHTML: true, arrow: roundArrow + roundArrow, plugins: [hide_on_esc_default, followCursor] }); var tippy_default = tippy; // base/alpine/index.js import Alpine2 from "alpinejs"; import morph from "@alpinejs/morph"; import mask from "@alpinejs/mask"; import focus from "@alpinejs/focus"; // base/alpine/directives/undo.js function undo_default(Alpine3) { const maxHistorySize = 100; Alpine3.directive("undo", (el, { expression }, { evaluate }) => { const data = getData(el); const history = Alpine3.reactive({ stack: [], stackPos: -1, adding: false, clear() { history.stack.length = 0; history.stackPos = -1; }, add(name, newValue, oldValue) { if (!history.adding && newValue !== oldValue) { if (history.stackPos < history.stackSize - 1) { const stack = Alpine3.raw(history.stack); history.stack = stack.slice(0, history.stackPos + 1); } history.stack.push({ name, newValue, oldValue }); if (history.stackSize > maxHistorySize) { history.stack.pop(); } else { history.stackPos++; } } }, undo() { if (!data.undo) { console.error("Missing `undo` method"); return; } if (history.undoable) { history.adding = true; const entry = history.stack[history.stackPos]; data.undo(entry.name, entry.oldValue); history.stackPos--; this.$nextTick(() => history.adding = false); } }, redo() { if (!data.redo) { console.error("Missing `redo` method"); return; } if (history.redoable) { history.adding = true; history.stackPos++; const entry = history.stack[history.stackPos]; data.redo(entry.name, entry.newValue); this.$nextTick(() => history.adding = false); } }, get undoable() { return history.stackPos >= 0; }, get redoable() { return history.stackPos < history.stackSize - 1; }, get stackSize() { return history.stack.length; }, get stackMemoryUsage() { return roughSizeOfObject(history.stack); } }); setData(el, { history }); }); } // base/alpine/directives/options.js function options_default(Alpine3) { Alpine3.directive( "options", (el, { expression }, { evaluate, effect, cleanup }) => { const optionNames = evaluate(expression); const optionsData = buildOptionsData(el, optionNames); const optionAttrs = optionsData.map((option) => option.attr); const data = setData( el, Alpine3.reactive({ $options: toPairs(optionsData) }) ); effect(() => { Object.entries(data.$options).forEach(([key, value]) => { Alpine3.mutateDom(() => { const attrName = `data-${kebabCase(key)}`; if (value === null) { el.removeAttribute(attrName); } else { el.setAttribute(attrName, value); } }); }); }); const attrObserver = new MutationObserver((mutationsList) => { for (const mutation of mutationsList) { const attrName = mutation.attributeName; if (mutation.type !== "attributes" || !optionAttrs.includes(attrName)) { return; } const value = mutation.target.getAttribute(attrName); const option = camelCase(attrName.replace("data-", "")); data.$options[option] = castAttributeValue(value); } }).observe(el, { attributes: true }); cleanup(() => { attrObserver && attrObserver.disconnect(); }); } ).before("bind"); } function buildOptionsData(el, optionNames) { return optionNames.map((name) => { const key = camelCase(name); const attr = `data-${kebabCase(name)}`; let value = null; if (el.hasAttribute(attr)) { const strValue = el.getAttribute(attr); value = castAttributeValue(strValue); } return { name, key, attr, value }; }); } function toPairs(optionsData) { return mapValues(keyBy(optionsData, "key"), "value"); } // base/alpine/utils/tippy_modifiers.js function tippyModifiers(modifiers) { if (modifiers.length === 0) return {}; const config = { plugins: [] }; const getModifierArgument = (modifier) => { return modifiers[modifiers.indexOf(modifier) + 1]; }; if (modifiers.includes("duration")) { config.duration = parseInt(getModifierArgument("duration")); } if (modifiers.includes("delay")) { const delay = getModifierArgument("delay"); config.delay = delay.includes("-") ? delay.split("-").map((n) => parseInt(n)) : parseInt(delay); } if (modifiers.includes("debounce") && config.interactive) { config.interactiveDebounce = parseInt(getModifierArgument("debounce")); } if (modifiers.includes("theme")) { config.theme = getModifierArgument("theme"); } if (modifiers.includes("placement")) { config.placement = getModifierArgument("placement"); } return config; } // base/alpine/directives/tooltip.js function tooltip_default(Alpine3) { Alpine3.directive( "tooltip", (el, { modifiers, expression }, { evaluate, evaluateLater, effect }) => { const config = tippyModifiers(modifiers); if (!el.__x_tippy) { el.__x_tippy = tippy_default(el, { theme: "coco-tooltip", ...config }); } let initialContent = null; const enableTooltip = () => el.__x_tippy.enable(); const disableTooltip = () => el.__x_tippy.disable(); const setupTooltip = (content) => { if (!content) { disableTooltip(); } else { enableTooltip(); el.__x_tippy.setContent(content); initialContent = initialContent || content; } }; if (modifiers.includes("raw")) { setupTooltip(expression); } else { const getContent = evaluateLater(expression); effect(() => { getContent((content) => { if (typeof content === "object" && content !== null) { el.__x_tippy.setProps(content); initialContent = initialContent || content.content; enableTooltip(); } else { setupTooltip(content); } }); }); } setData(el, { tooltip: { setContent(content) { setupTooltip(content); }, disable: () => disableTooltip(), enable: () => enableTooltip(), reset() { if (initialContent) setupTooltip(initialContent); } } }); } ).before("bind"); } // base/alpine/directives/destroy.js function destroy_default(Alpine3) { Alpine3.directive( "destroy", (el, { expression }, { evaluateLater, cleanup }) => { const clean = evaluateLater(expression); cleanup(() => clean()); } ); } // base/alpine/directives/dropdown.js function dropdown_default(Alpine3) { Alpine3.directive( "dropdown", (el, { value, modifiers, expression }, { evaluate }) => { if (value) return; const data = getData(el); const settings = tippyModifiers(modifiers); const result = expression ? evaluate(expression) : {}; const directiveConfig = isObject(result) ? result : {}; let { triggerTarget, contentTarget, anchorTarget, flip, ...config } = directiveConfig; contentTarget = contentTarget || el.querySelector("[x-dropdown\\:content]"); const content = isNode(contentTarget) ? contentTarget.firstElementChild : contentTarget; triggerTarget = triggerTarget || el.querySelector("[x-dropdown\\:trigger]") || el; anchorTarget = anchorTarget || el.querySelector("[x-dropdown\\:anchor]") || el; if (!el.__x_dropdown) { const mixin = Alpine3.reactive({ dropdown: { open: false, trigger: triggerTarget, content: contentTarget, hide() { el.__x_dropdown.hide(); }, show() { el.__x_dropdown.show(); } } }); setData(el, mixin); const dropdown = el.__x_dropdown = tippy_default(anchorTarget, { theme: "coco-app-dropdown", placement: "bottom-start", offset: [0, 0], trigger: "click", interactive: true, animation: false, maxWidth: 380, popperOptions: { modifiers: [{ name: "flip", enabled: flip !== false }] }, triggerTarget, content, onShow: (...args) => { mixin.dropdown.open = true; data.$dispatch("dropdown:show", { dropdown: el.__x_dropdown }); }, onHide: (...args) => { mixin.dropdown.open = false; data.$dispatch("dropdown:hide", { dropdown: el.__x_dropdown }); }, onMount() { data.$dispatch("dropdown:mount", { dropdown: el.__x_dropdown }); }, onCreate() { data.$dispatch("dropdown:create", { dropdown: el.__x_dropdown }); }, ...settings, ...config }); } } ).before("bind"); } // base/alpine/directives/dimensions.js function dimensions_default(Alpine3) { Alpine3.directive( "dimensions", (el, { value, modifiers, expression }, { evaluateLater, cleanup }) => { if (value) return; const data = getData(el); let target; if (modifiers.includes("parent")) { target = el.parentNode; } else { target = el.querySelector("[x-dimensions\\:target]") || el; } const evaluate = evaluateLater(expression); const sizeObserver = new ResizeObserver((entries) => { const dimensions = entries[0].contentRect; evaluate(() => { }, { scope: { dimensions: { width: dimensions.width, height: dimensions.height, x: dimensions.x, y: dimensions.y } } }); }); sizeObserver.observe(target); cleanup(() => { sizeObserver && sizeObserver.disconnect(); }); } ); } // base/alpine/directives/notification.js function notification_default(Alpine3) { let notificationId = 0; let queuePosition = 0; Alpine3.directive("notification", (el, { expression }, { evaluate }) => { notificationId++; const data = getData(el); const type = evaluate(expression); const options = evaluate("$options"); const notification = Alpine3.reactive({ id: notificationId, type, autoShow: options.show, showDelay: options.showDelay, shown: false, autoDismiss: options.dismiss, dismissDelay: options.dismissDelay, dismissed: false, dismissTimer: null, position: options.position, queuePosition: 0, init() { data.$dispatch(`${type}:init`, { id: notification.id, type: notification.type, [type]: notification }); if (notification.autoShow) { setTimeout(() => notification.show(), notification.showDelay); } }, show() { if (!notification.shown) { notification.queuePosition = queuePosition++; notification.startAutoDismiss(); notification.shown = true; data.$dispatch(`${type}:show`, { id: notification.id, queuePosition: notification.queuePosition, type: notification.type, [type]: notification }); } }, dismiss() { notification.dismissed = true; notification.clearAutoDismiss(); data.$dispatch(`${type}:dismiss`, { id: notification.id, [type]: notification }); setTimeout(() => el.remove(), 500); }, startAutoDismiss() { if (notification.autoDismiss === true) { notification.dismissTimer = setTimeout( () => notification.dismiss(), notification.dismissDelay ); } }, clearAutoDismiss() { clearTimeout(notification.dismissTimer); }, clearFromQueue(event) { if (notification.type === event.detail.type && notification.position === "fixed" && notification.id !== event.detail.id && notification.queuePosition < event.detail.queuePosition) { notification.dismiss(); } } }); setData(el, { notification }); evaluate("notification.init"); }).before("init"); } // base/alpine/index.js window.Alpine = Alpine2; Alpine2.plugin(mask); Alpine2.plugin(focus); Alpine2.plugin(morph); Alpine2.plugin(undo_default); Alpine2.plugin(options_default); Alpine2.plugin(tooltip_default); Alpine2.plugin(destroy_default); Alpine2.plugin(dropdown_default); Alpine2.plugin(dimensions_default); Alpine2.plugin(notification_default); var alpine_default = Alpine2; // ../../../package.json var package_default = { name: "coveragebook-components", version: "0.18.7", repository: "git@github.com:coveragebook/coco.git", license: "NO LICENSE", author: "Mark Perkins ", main: "app/assets/build/coco/coco.js", engines: { node: "20.x" }, scripts: { build: "npm run js:build && npm run css:build npm run build:tailwind-preset && npm run lookbook:build", "build:tailwind-preset": "esbuild ./config/tailwind.preset.js --bundle --format=cjs --outdir=./app/assets/build/coco --log-level=error", "build:dev": "npm run js:dev && npm run css:dev", "css:build": "postcss ./app/assets/css/coco.css -d ./app/assets/build/coco", "css:dev": "postcss ./app/assets/css/coco.css -d ./app/assets/build/coco/dev", "css:watch": "postcss ./app/assets/css/coco.css -d ./app/assets/build/coco/dev --watch", "js:build": "node esbuild.config.mjs", "js:dev": "node esbuild.config.mjs --dev", "js:watch": "node esbuild.config.mjs --watch", "lint:fix": "bundle exec standardrb --fix && prettier --write .", "lookbook:build": "cd lookbook && npm run build", prepare: "husky install", release: "release-it" }, "lint-staged": { "**/*": [ "prettier --write --ignore-unknown" ], "(**/*.(rb|rake))|Gemfile|Rakefile": [ "standardrb --fix" ] }, browserslist: [ "defaults" ], prettier: { semi: true, singleQuote: false, tabWidth: 2, trailingComma: "es5" }, dependencies: { "@alpinejs/focus": "^3.13.2", "@alpinejs/mask": "^3.13.5", "@alpinejs/morph": "^3.13.5", "@jaames/iro": "^5.5.2", "@percy/cli": "^1.28.8", "@tailwindcss/container-queries": "^0.1.0", "@tailwindcss/forms": "^0.5.6", "alias-hq": "^6.2.2", alpinejs: "^3.13.8", autoprefixer: "^10.4.16", "container-query-polyfill": "^1.0.2", del: "^7.1.0", esbuild: "^0.22.0", "esbuild-plugin-copy": "^2.0.2", "fast-glob": "^3.3.1", "fast-sort": "^3.2.1", husky: "^9.0.11", "js-cookie": "^3.0.5", "lint-staged": "^15.2.2", "lodash.camelcase": "^4.3.0", "lodash.kebabcase": "^4.1.1", "lodash.keyby": "^4.6.0", "lodash.mapvalues": "^4.6.0", "lucide-static": "^0.303.0", postcss: "^8.4.38", "postcss-cli": "^11.0.0", "postcss-value-parser": "^4.2.0", prettier: "^3.2.5", "release-it": "^17.2.1", svgo: "^3.0.2", tailwindcss: "^3.4.3", "tippy.js": "^6.3.7" }, "release-it": { github: { release: true }, npm: { publish: false }, hooks: { "before:init": [ "npm install", "bundle install", "bundle exec rake coco:test" ], "after:bump": [ "npm run lint:fix", "npm run build" ], "after:version:bump": "bundle exec rake coco:gem:bump_version[${version}] && bundle && cd lookbook && bundle", "after:release": "rake coco:gem:release[${version}]" } } }; // coco/coco.js var Coco = { version: package_default.version, start() { if (this._started) { throw new Error("Coco has already been started!"); } console.info("Initializing Coco JS", package_default.version); registerComponents(this._components); window.Alpine = alpine_default; alpine_default.start(); }, registerComponents(components) { this._components.push(...components); }, _components: [], _started: false }; var coco_default = Coco; // coco/component.js function CocoComponent(name, fn) { const func = nameFunction(name, (...args) => { const data = fn(...args); Object.defineProperties(data, { $parent: { get() { return getData(this.$root.parentElement); } } }); data.$options = {}; return data; }); func.component = true; return func; } var component_default = CocoComponent; // coco.js var import_tokens = __toESM(require_tokens()); // ../../components/coco/buttons/button/button.js var button_exports = {}; __export(button_exports, { default: () => button_default }); var button_default = CocoComponent("button", (data = {}) => { return { options: ["state", "confirm", "size", "disabled", "collapsible"], isCollapsed: false, approving: false, confirmed: true, lastState: null, stateTooltips: data.tooltips || {}, tooltipText: null, ...data.props || {}, init() { this.lastState = this.state; this.checkConfirmation = this.checkConfirmation.bind(this); this.approveAndRun = this.approveAndRun.bind(this); this.shouldShowTooltip = this.shouldShowTooltip.bind(this); this.$nextTick(() => { if (this.$options.confirm) { this.confirmed = false; } }); this.$watch("collapsed", (collapsed) => { if (collapsed && !this.collapsible) { this.collapsed = false; return; } this.$root.setAttribute("data-collapsed", collapsed ? "true" : "false"); }); }, setTooltipText() { if (this.disabled) { this.tooltipText = null; return; } const defaultContent = this.$el.getAttribute("data-tippy-content"); const tooltipForState = this.stateTooltips[this.state]; if (this.collapsed) { const labelText = this.getContentForState(this.state); this.tooltipText = tooltipForState || labelText || defaultContent; } else { this.tooltipText = tooltipForState || defaultContent; } }, shouldShowTooltip() { return !!this.tooltipText; }, get disabled() { return this.$options.disabled === true; }, set disabled(value) { this.$options.disabled = value; }, get tippyInstance() { return this.$root.__x_tippy; }, /* confirmation */ checkConfirmation(event) { if (!this.confirmed) { this.approving = true; event.preventDefault(); } }, approveAndRun(event) { if (this.approving) { event.stopPropagation(); this.confirmed = true; if (this.dropdown.trigger.getAttribute("type") === "submit") { this.$root.closest("form").requestSubmit(); } else { this.dropdown.trigger.click(); } this.dropdown.hide(); this.confirmed = false; this.approving = false; } }, cancelConfirmation(event) { if (this.approving) { event.stopPropagation(); this.approving = false; this.dropdown.hide(); } }, /* state */ get state() { return this.$options.state || "default"; }, set state(name) { this.setState(name); }, get loading() { return this.state === "loading"; }, set loading(value) { this.$options.state = value === true ? "loading" : "default"; }, setState(name) { this.lastState = this.state; this.$options.state = camelCase(name); }, resetState() { this.$options.state = this.lastState || "default"; this.lastState = this.$options.state; }, toggleState(state1, state2 = this.laststate) { this.state = this.state === state1 ? state2 : state1; }, getContentForState(state) { const content = this.$refs[`${state}Content`]; return content ? content.innerText : null; }, hasIconForState(state) { return !!this.$refs[`${state}Icon`]; }, hasContentForState(state) { return !!this.getContentForState(state); }, showIcon(state) { return state === this.state || !this.hasIconForState(this.state) && state === "default"; }, showContent(state) { return state === this.state || !this.hasContentForState(this.state) && state === "default"; }, /* collapsing */ get collapsed() { return this.isCollapsed; }, set collapsed(value) { this.isCollapsed = this.collapsible ? value : false; }, get collapsible() { return this.$options.collapsible !== false && this.hasIconForState(this.$options.state || "default"); }, /* bindings */ root: { "x-options": "options", "x-tooltip": "tooltipText", "x-effect": "setTooltipText", ":disabled": "disabled" } }; }); // ../../components/coco/buttons/button/button_dropdown.js var button_dropdown_exports = {}; __export(button_dropdown_exports, { default: () => button_dropdown_default }); var button_dropdown_default = CocoComponent("buttonDropdown", () => { return { dropdown: null, button: null, init() { this.$nextTick(() => { this.button = getComponent(this.$el.querySelector(".coco-button")); }); }, hideDropdown() { if (this.dropdown) { this.dropdown.hide(); } }, showDropdown() { if (this.dropdown) { this.dropdown.show(); } }, /* bindings */ root: { "@dropdown:show": "button.setState('active')", "@dropdown:hide": "button.resetState()", "@confirmation:confirm": "button.approveAndRun($event)", "@confirmation:cancel": "button.cancelConfirmation($event)" } }; }); // ../../components/coco/buttons/button_group/button_group.js var button_group_exports = {}; __export(button_group_exports, { default: () => button_group_default }); var button_group_default = CocoComponent("appButtonGroup", () => { return { options: ["collapsible"], ready: false, containerWidth: 0, contentWidth: 0, collapsed: false, singletonTooltip: null, tooltipInstances: [], get collapsible() { return this.$options.collapsible !== false; }, get buttons() { const buttonElements = this.$el.querySelectorAll( "[data-component='button']" ); return Array.from(buttonElements).map((el) => getComponent(el)); }, get parent() { return this.$root.parentElement; }, init() { if (this.collapsible) { this.$nextTick(() => { this.onResize(); this.createSingletonTooltip(); this.ready = true; }); } else { this.ready = true; } this.$watch("collapsed", (value) => { this.buttons.forEach((button) => { button.isCollapsed = value; }); this.$nextTick(() => this.createSingletonTooltip()); }); }, createSingletonTooltip() { this.destroySingletonTooltip(); this.tooltipInstances = this.buttons.map((button) => { if (button.tippyInstance && button.shouldShowTooltip && button.shouldShowTooltip()) { return button.tippyInstance; } }).filter((t) => t); this.singletonTooltip = createSingleton(this.tooltipInstances, { theme: "coco-tooltip", delay: 100, moveTransition: "transform 0.1s ease-out" }); }, destroySingletonTooltip() { if (this.singletonTooltip && this.singletonTooltip.destroy) { this.singletonTooltip.destroy(); this.singletonTooltip = null; this.tooltipInstances.forEach((tooltip) => tooltip.destroy()); this.tooltipInstances = []; } }, onResize() { if (!this.collapsible) return; this.containerWidth = Math.ceil(this.parent.offsetWidth); if (this.collapsed) { if (this.containerWidth > this.contentWidth) { this.collapsed = false; } } else { if (this.containerWidth < this.contentWidth) { this.collapsed = true; } else { const contentWidth = Math.ceil(this.$refs.buttons.scrollWidth); this.contentWidth = contentWidth; } } }, destroy() { if (this.singletonTooltip) { this.singletonTooltip.destroy(); this.singletonTooltip = null; } } }; }); // ../../components/coco/buttons/color_picker_button/color_picker_button.js var color_picker_button_exports = {}; __export(color_picker_button_exports, { default: () => color_picker_button_default }); var color_picker_button_default = CocoComponent("colorPickerButton", ({ selected }) => { selected = selected ? "#" + selected.replace("#", "") : "#FFFFFF"; return { selectedColor: selected, getPicker() { return getData( this.$root.querySelector("[data-role='color-picker']").firstElementChild ); }, onDropdownMount() { this.getPicker().setSelectedColor(this.selectedColor); } }; }); // ../../components/coco/buttons/confirm_panel/confirm_panel.js var confirm_panel_exports = {}; __export(confirm_panel_exports, { default: () => confirm_panel_default }); var confirm_panel_default = CocoComponent("confirmPanel", () => { return { confirm() { this.$dispatch("confirmation:confirm"); }, cancel() { this.$dispatch("confirmation:cancel"); } }; }); // ../../components/coco/buttons/image_picker_button/image_picker_button.js var image_picker_button_exports = {}; __export(image_picker_button_exports, { default: () => image_picker_button_default }); var image_picker_button_default = CocoComponent("imagePickerButton", ({ src }) => { return { selectedImage: { name: basename(src), file: null, data: src }, getPicker() { return getData( this.$root.querySelector("[data-role='image-picker'").firstElementChild ); }, handleExternalDrop(event) { this.readFile(event.dataTransfer.files[0]); }, readFile(file) { const reader = new FileReader(); reader.addEventListener("load", () => { const selectedImage = { name: file.name, file, data: reader.result }; this.$dispatch("image-picker:change", { image: selectedImage }); this.selectedImage = selectedImage; if (this.dropdown) { this.dropdown.hide(); } }); reader.readAsDataURL(file); }, clearSelectedImage() { this.dropdown.hide(); this.selectedImage = { name: null, data: null, file: null }; }, setSelectedImage(image) { this.dropdown.hide(); this.selectedImage = image; }, onDropdownMount({ detail }) { this.dropdown = detail.dropdown; this.getPicker().setImage(this.selectedImage, true); } }; }); // ../../components/coco/buttons/layout_picker_button/layout_picker_button.js var layout_picker_button_exports = {}; __export(layout_picker_button_exports, { default: () => layout_picker_button_default }); var layout_picker_button_default = CocoComponent("layoutPickerButton", ({ selected }) => { return { selectedLayout: selected, getPicker() { return getData( this.$root.querySelector("[data-role='layout-picker']").firstElementChild ); }, getButton() { return getData(this.$root.querySelector(".layout-picker-trigger")); }, init() { this.$watch("selectedLayout", () => this.getButton().hideDropdown()); } }; }); // ../../components/coco/buttons/menu_button/menu_button.js var menu_button_exports = {}; __export(menu_button_exports, { default: () => menu_button_default }); var menu_button_default = CocoComponent("menuButton", () => { return {}; }); // ../../components/coco/buttons/toolbar/toolbar.js var toolbar_exports = {}; __export(toolbar_exports, { default: () => toolbar_default }); var toolbar_default = CocoComponent("appToolbar", () => { return { ready: false, startSectionWidth: null, endSectionWidth: null, get startGroupEl() { return this.$refs.startSection.firstElementChild; }, get endGroupEl() { return this.$refs.endSection.firstElementChild; }, get groups() { return [this.startGroupEl, this.endGroupEl].filter((g) => g).map((el) => getComponent(el, false)); }, init() { const toolbarWidth = this.$el.offsetWidth; let startSectionWidth = 0; let endSectionWidth = 0; if (this.startGroupEl) { startSectionWidth = Math.ceil( this.startGroupEl.offsetWidth / toolbarWidth * 100 ); } if (this.endGroupEl) { endSectionWidth = Math.ceil( this.endGroupEl.offsetWidth / toolbarWidth * 100 ); } this.$nextTick(() => { this.startSectionWidth = `${startSectionWidth}%`; this.endSectionWidth = `${endSectionWidth}%`; this.groups.forEach((group) => group.onResize()); this.ready = true; }); } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/buttons/**/*.js var modules = [button_exports, button_dropdown_exports, button_group_exports, color_picker_button_exports, confirm_panel_exports, image_picker_button_exports, layout_picker_button_exports, menu_button_exports, toolbar_exports]; var __default = modules; // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/embeds/**/*.js var modules2 = []; var __default2 = modules2; // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/fields/**/*.js var modules3 = []; var __default3 = modules3; // ../../components/coco/images/icon/icon.js var icon_exports = {}; __export(icon_exports, { default: () => icon_default }); var icon_default = CocoComponent("icon", () => { return { options: ["style", "spin"], get spin() { return this.$options.spin; }, set spin(val) { this.$options.spin = val; }, get fill() { return this.$options.style === "fill"; }, set fill(val) { this.$options.style = val === true ? "fill" : "line"; }, root: { "x-options": "options" } }; }); // ../../components/coco/images/image_uploader/image_uploader.js var image_uploader_exports = {}; __export(image_uploader_exports, { default: () => image_uploader_default }); var image_uploader_default = CocoComponent("imageUploader", ({ click, drop }) => { return { file: null, errors: [], active: false, clickable: click, droppable: drop, input: null, get fileName() { return this.file && this.file.name; }, get fileType() { return this.file && this.file.type; }, get fileSize() { return this.file && this.file.size; }, get fileData() { return this.file && this.file.data; }, init() { this.input = this.$refs.input; this.$watch("file", (file) => { const dataTransfer = new DataTransfer(); if (file && file.file instanceof File) { dataTransfer.items.add(file.file); } this.input.files = dataTransfer.files; }); }, setFile(file) { this.file = file; }, openPicker() { this.input.click(); }, clear() { this.file = null; this.input.value = null; this.$dispatch("image-uploader:clear"); }, handleDrop(event) { const files = event.detail.files || event.dataTransfer.files; this.handleFiles(files); }, handleFiles(files) { Array.from(files).forEach((file) => this.readFile(file)); }, readFile(file) { const reader = new FileReader(); reader.addEventListener("load", () => { this.file = { name: file.name, size: file.size, type: file.type, file, data: reader.result }; this.$dispatch("image-uploader:load", { file: this.file }); }); reader.addEventListener("error", () => { this.errors.push(`Error reading file: ${file.name}`); }); reader.readAsDataURL(file); } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/images/**/*.js var modules4 = [icon_exports, image_uploader_exports]; var __default4 = modules4; // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/indicators/**/*.js var modules5 = []; var __default5 = modules5; // ../../components/coco/layout/page/page.js var page_exports = {}; __export(page_exports, { default: () => page_default }); var page_default = CocoComponent("pageLayout", () => { return {}; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/layout/**/*.js var modules6 = [page_exports]; var __default6 = modules6; // ../../components/coco/messaging/alert/alert.js var alert_exports = {}; __export(alert_exports, { default: () => alert_default }); var alert_default = CocoComponent("alertMessage", () => { return { alert: null, dismissed: false, forceMultiLine: false, dismissDuration: 300, init() { this.checkSingleLineWrap = Alpine.throttle( this.checkSingleLineWrap.bind(this), 200 ); }, dismiss() { if (this.$options.dismissable) { this.$dispatch("alert:dismiss", { alert: this, duration: this.dismissDuration }); this.dismissed = true; setTimeout(() => this.remove(), this.dismissDuration); } }, remove() { this.$nextTick(() => this.$dispatch("alert:removed", { alert: this })); this.$root.remove(); }, checkSingleLineWrap({ height }) { this.forceMultiLine = false; if (height > 24 && this.$options.singleLine) { this.$nextTick(() => { this.forceMultiLine = true; }); } }, root: { "x-options": '["dismissable", "singleLine", "dismissAfterAction"]', ":class": "{'force-multi-line': forceMultiLine}" } }; }); // ../../components/coco/messaging/notice/notice.js var notice_exports = {}; __export(notice_exports, { default: () => notice_default }); var notice_default = CocoComponent("notice", () => { return {}; }); // ../../components/coco/messaging/popover/popover.js var popover_exports = {}; __export(popover_exports, { default: () => popover_default }); var popover_default = CocoComponent("popover", ({ target, trigger, options = {} }) => { return { targetEl: null, open: false, init() { this.targetEl = target ? document.querySelector(target) : this.$el.parentElement; if (this.targetEl) { this.targetEl.coco_popover = this; if (trigger == "click") { this.targetEl.style.cursor = "pointer"; } this.$nextTick(() => { const content = this.$el.firstElementChild; content.__popover_target = this.targetEl; tippy_default(this.targetEl, { trigger, theme: this.theme, maxWidth: "none", interactive: true, allowHTML: true, appendTo: () => document.body, content: () => content, onShown: () => { this.open = true; }, onHidden: () => { this.open = false; }, ...options }); }); } else { console.error(`Popover target '${target} not found.'`); } }, show(event) { if (!event || this.eventTarget(event) === this.targetEl && this.popoverInstance) { this.popoverInstance.show(); } }, hide(event) { if (!event || this.eventTarget(event) === this.targetEl && this.popoverInstance) { this.popoverInstance.hide(); } }, toggle(event) { if (!event || this.eventTarget(event) === this.targetEl && this.popoverInstance) { this.open ? this.popoverInstance.hide() : this.popoverInstance.show(); } }, destroy() { if (this.popoverInstance) { this.popoverInstance.destroy(); } }, eventTarget(event) { if (event.detail.target) { if (typeof event.detail.target === "string") { return document.querySelector(event.detail.target); } else { return event.detail.target; } } else { return event.target; } }, get theme() { return `coco-popover-${this.$root.getAttribute("data-theme")}`; }, get popoverInstance() { if (this.targetEl) { return this.targetEl._tippy; } } }; }); // ../../components/coco/messaging/popover/popover_content.js var popover_content_exports = {}; __export(popover_content_exports, { default: () => popover_content_default }); var popover_content_default = CocoComponent("popoverContent", () => { return { init() { this.hide = this.hide.bind(this); this.show = this.show.bind(this); this.toggle = this.toggle.bind(this); }, hide() { this.$dispatch("popover:hide", { target: this.$root.__popover_target }); }, show() { this.$dispatch("popover:show", { target: this.$root.__popover_target }); }, toggle() { this.$dispatch("popover:toggle", { target: this.$root.__popover_target }); } }; }); // ../../components/coco/messaging/snackbar/snackbar.js var snackbar_exports = {}; __export(snackbar_exports, { default: () => snackbar_default }); var snackbar_default = CocoComponent("snackbar", () => { return { notificationType: "snackbar", options: ["show", "dismiss", "showDelay", "dismissDelay", "position"], root: { "x-options": "options", "x-notification": "notificationType", "x-show": "notification.shown && !notification.dismissed", "@mouseover": "notification.clearAutoDismiss", "@mouseout": "notification.startAutoDismiss", "@snackbar:show.document": "notification.clearFromQueue", "x-transition:enter": "snackbar-enter", "x-transition:enter-start": "snackbar-enter-start", "x-transition:enter-end": "snackbar-enter-end", "x-transition:leave": "snackbar-leave", "x-transition:leave-start": "snackbar-leave-start", "x-transition:leave-end": "snackbar-leave-end" } }; }); // ../../components/coco/messaging/system_banner/system_banner.js var system_banner_exports = {}; __export(system_banner_exports, { default: () => system_banner_default }); import Cookies from "js-cookie"; var system_banner_default = CocoComponent("systemBanner", (opts = {}) => { return { cookieName: null, cookieValue: null, cookieExpiry: null, init() { this.cookieName = opts.cookieName; this.cookieValue = opts.cookieValue; this.cookieExpiry = opts.cookieExpiry; }, onDismiss() { this.$dispatch("banner:dismiss", { banner: this }); if (this.shouldSetCookie) { Cookies.set(this.cookieName, this.cookieValue, { expires: this.cookieExpiry }); } }, remove() { this.$root.remove(); }, get shouldSetCookie() { return Number.isInteger(this.cookieExpiry); }, root: { "@alert:dismiss": "onDismiss", "@alert:removed": "remove" } }; }); // ../../components/coco/messaging/toast/toast.js var toast_exports = {}; __export(toast_exports, { default: () => toast_default }); var toast_default = CocoComponent("toast", () => { return { notificationType: "toast", options: ["show", "dismiss", "showDelay", "dismissDelay", "position"], root: { "x-options": "options", "x-notification": "notificationType", "x-show": "notification.shown && !notification.dismissed", "x-transition:enter": "toast-enter", "x-transition:enter-start": "toast-enter-start", "x-transition:enter-end": "toast-enter-end", "x-transition:leave": "toast-leave", "x-transition:leave-start": "toast-leave-start", "x-transition:leave-end": "toast-leave-end", "@mouseover": "notification.clearAutoDismiss", "@mouseout": "notification.startAutoDismiss", "@alert:dismiss": "notification.dismiss", "@toast:show.document": "notification.clearFromQueue" } }; }); // ../../components/coco/messaging/tooltip/tooltip.js var tooltip_exports = {}; __export(tooltip_exports, { default: () => tooltip_default2 }); var tooltip_default2 = CocoComponent("tooltip", () => { return { init() { tippy_default(this.$el, { theme: "coco-tooltip", appendTo: () => document.body }); } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/messaging/**/*.js var modules7 = [alert_exports, notice_exports, popover_exports, popover_content_exports, snackbar_exports, system_banner_exports, toast_exports, tooltip_exports]; var __default7 = modules7; // ../../components/coco/modals/modal/modal.js var modal_exports = {}; __export(modal_exports, { default: () => modal_default }); var modal_default = CocoComponent("modal", () => { return { open: false, frame: null, modal: null, options: ["dismissable", "closeOnSubmit"], init() { this.modal = this; this.onFrameSubmitEnd = this.onFrameSubmitEnd.bind(this); this.frame = this.$el.closest("turbo-frame"); this.frame.addEventListener("turbo:submit-end", this.onFrameSubmitEnd); this.$nextTick(() => this.show()); }, show() { this.open = true; hideAll(); setTimeout(() => { this.$dispatch("modal:shown"); }, 400); }, hide() { this.open = false; setTimeout(() => { this.$dispatch("modal:hidden"); this.clearFrame(); }, 200); }, dismiss(event) { if (this.$options.dismissable) this.hide(); }, visit(url) { navigateTo(url, { frame: this.frame.id, turbo: true }); }, scrollTo(pos) { setTimeout(() => { this.$root.scrollTop = pos + this.contentOffsetTop; }, 10); }, clearFrame() { this.frame.removeAttribute("src"); this.frame.removeAttribute("complete"); this.frame.innerHTML = ""; }, onFrameSubmitEnd(event) { if (this.$options.closeOnSubmit && event.detail.success) { this.hide(); } }, destroy() { this.frame.removeEventListener("turbo:submit-end", this.onFrameSubmitEnd); }, get contentOffsetTop() { return parseInt( window.getComputedStyle(this.$refs.container).paddingTop, 10 ); }, root: { "x-options": "options", "x-show": "open", "@keydown.escape.document": "dismiss", "@modal:hide.document": "hide" }, overlay: { "x-show": "open", "x-transition:enter": "overlay-enter", "x-transition:enter-start": "overlay-enter-start", "x-transition:enter-end": "overlay-enter-end", "x-transition:leave": "overlay-leave", "x-transition:leave-start": "overlay-leave-start", "x-transition:leave-end": "overlay-leave-end" }, container: { "x-show": "open", "x-transition:enter": "container-enter", "x-transition:enter-start": "container-enter-start", "x-transition:enter-end": "container-enter-end", "x-transition:leave": "container-leave", "x-transition:leave-start": "container-leave-start", "x-transition:leave-end": "container-leave-end" } }; }); // ../../components/coco/modals/modal_dialog/modal_dialog.js var modal_dialog_exports = {}; __export(modal_dialog_exports, { default: () => modal_dialog_default }); var modal_dialog_default = CocoComponent("modalDialog", () => { return { frame: null, init() { this.onFrameLoad = this.onFrameLoad.bind(this); this.frame = this.$el.closest("turbo-frame"); if (this.frame) { this.frame.addEventListener("turbo:frame-load", this.onFrameLoad); } }, close() { this.modal.hide(); }, onFrameLoad() { this.$focus.focus(this.firstInput); }, destroy() { if (this.frame) { this.frame.removeEventListener("turbo:frame-load", this.onFrameLoad); } }, get firstInput() { return this.$root.querySelector( "input:not([type=hidden]), textarea, select" ); } }; }); // ../../components/coco/modals/modal_lightbox/modal_lightbox.js var modal_lightbox_exports = {}; __export(modal_lightbox_exports, { default: () => modal_lightbox_default }); var modal_lightbox_default = CocoComponent("modalLightbox", () => { return { loaded: false, init() { if (this.img.complete && this.img.naturalHeight !== 0) { this.imageLoaded(); } }, close() { this.modal.hide(); }, imageLoaded() { this.loaded = true; setTimeout(() => { const scrollTop = parseInt(this.img.dataset.scrollTop, 10); if (!isNaN(scrollTop) && scrollTop !== 0) { this.modal.scrollTo(scrollTop); } }, 200); }, get img() { return this.$refs.media.querySelector("img"); }, root: { ":class": "{loaded}" } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/modals/**/*.js var modules8 = [modal_exports, modal_dialog_exports, modal_lightbox_exports]; var __default8 = modules8; // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/navigation/**/*.js var modules9 = []; var __default9 = modules9; // ../../components/coco/pickers/color_picker/color_picker.js var color_picker_exports = {}; __export(color_picker_exports, { default: () => color_picker_default }); import iro from "@jaames/iro"; var color_picker_default = CocoComponent("colorPicker", ({ selected }) => { return { selectedColor: selected, display: selected, updating: false, invalid: false, colorWheel: { show: false, instance: null, interacting: false }, getColorWheelToggle() { return getComponent(this.$refs.display.querySelector(".coco-button")); }, init() { this.initColorWheel(); this.$watch("display", (value) => { if (!this.updating) { if (isValidHex(value)) { this.invalid = false; this.selectedColor = formatHex(value); } else { this.invalid = true; } } }); this.$watch("selectedColor", (value) => { const hex = formatHex(value); this.updating = true; this.display = hex; if (this.colorWheel.instance) { this.colorWheel.instance.color.hexString = hex; } this.$dispatch("color-picker:select", { selectedColor: this.selectedColor }); this.$nextTick(() => this.updating = false); }); }, setSelectedColor(color) { this.selectedColor = color; this.invalid = false; }, toggleAdvancedView() { this.colorWheel.show = !this.colorWheel.show; }, initColorWheel() { this.cleanupColorWheel(); const colorWheel = new iro.ColorPicker(this.$refs.colorWheel, { width: this.$refs.swatches.clientWidth, color: this.selectedColor }); colorWheel.on("input:end", (color) => { if (!this.updating) { this.selectedColor = color.hexString; this.invalid = false; } }); this.colorWheel.instance = colorWheel; }, onResize() { if (this.colorWheel.instance) { this.colorWheel.instance.resize(this.$refs.swatches.clientWidth); } }, toggleColorWheel() { this.colorWheel.show = !this.colorWheel.show; }, cleanupColorWheel() { this.colorWheel.instance = null; this.$refs.colorWheel.innerHTML = ""; }, destroy() { this.getColorWheelToggle().resetState(); this.cleanupColorWheel(); } }; }); // ../../components/coco/pickers/image_picker/image_picker.js var image_picker_exports = {}; __export(image_picker_exports, { default: () => image_picker_default }); var image_picker_default = CocoComponent("imagePicker", ({ src }) => { return { image: { name: basename(src), file: null, data: src }, get name() { return this.image.name; }, get src() { return this.image.data; }, get hasImage() { return !!this.src; }, get uploader() { return getComponent(this.$refs.uploader.firstElementChild); }, setImage(file, silent = false) { this.image = { file: file.file, name: file.name, data: file.data }; this.uploader.setFile(file); if (silent === false) { this.$dispatch("image-picker:select", { image: this.image }); } }, clearImage(silent = false) { this.uploader.clear(); this.image = { name: null, data: null, file: null }; if (silent === false) { this.$dispatch("image-picker:clear"); } }, browseFiles() { this.uploader.openPicker(); }, replaceImage() { this.uploader.openPicker(); } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/pickers/**/*.js var modules10 = [color_picker_exports, image_picker_exports]; var __default10 = modules10; // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/typography/**/*.js var modules11 = []; var __default11 = modules11; // ../../components/coco/utilities/dropdown/dropdown.js var dropdown_exports = {}; __export(dropdown_exports, { default: () => dropdown_default2 }); var dropdown_default2 = CocoComponent("dropdown", () => { return {}; }); // ../../components/coco/utilities/poll_controller/poll_controller.js var poll_controller_exports = {}; __export(poll_controller_exports, { default: () => poll_controller_default }); var poll_controller_default = CocoComponent("pollController", () => { return { polling: false, frame: null, pollTimer: null, get interval() { return parseInt(this.$root.dataset.interval || 0, 10); }, init() { this.frame = document.getElementById("polling-controller-frame"); this.observer = new MutationObserver(() => this.onUpdate()); this.observer.observe(this.$el, { attributes: true }); }, startPolling() { if (this.interval > 0 && !this.polling) { this.polling = true; this.queuePollRequest(500); } }, onUpdate() { this.$nextTick(() => { this.$dispatch("dom-updates:complete", { html: document }); }); this.queuePollRequest(); }, queuePollRequest(wait) { if (this.pollTimer) clearTimeout(this.pollTimer); if (this.interval > 0 && this.polling) { this.pollTimer = setTimeout( () => this.reloadFrame(), wait || this.interval ); } }, reloadFrame() { this.frame.addEventListener( "turbo:before-fetch-request", addStreamHeaders, { once: true } ); window.Turbo.visit(location.href, { frame: this.frame.id, action: "replace" }); }, destroy() { this.observer.disconnect(); this.polling = false; } }; }); function addStreamHeaders(event) { const { headers } = event.detail.fetchOptions || {}; if (headers) { headers.Accept = ["text/vnd.turbo-stream.html", headers.Accept].join(", "); } } // ../../components/coco/utilities/seamless_textarea/seamless_textarea.js var seamless_textarea_exports = {}; __export(seamless_textarea_exports, { default: () => seamless_textarea_default }); var seamless_textarea_default = CocoComponent("seamlessTextarea", () => { return { height: null, observer: null, value: null, options: ["multiline", "focus"], init() { this.value = this.$refs.textarea.value; this.$nextTick(() => { this.onResize(); if (this.$options.focus) { this.$refs.textarea.focus(); this.$refs.textarea.selectionStart = this.$refs.textarea.value.length; } }); }, onResize() { const textarea = this.$refs.textarea; if (textarea) { textarea.style.height = "4px"; const newHeight = textarea.scrollHeight; textarea.style.height = `${newHeight}px`; if (this.height !== newHeight) { this.height = newHeight; } } } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/utilities/**/*.js var modules12 = [dropdown_exports, poll_controller_exports, seamless_textarea_exports]; var __default12 = modules12; // base/components.js var components_default = [ ...__default, ...__default2, ...__default3, ...__default4, ...__default5, ...__default6, ...__default7, ...__default8, ...__default9, ...__default10, ...__default11, ...__default12 ]; // coco.js coco_default.registerComponents(components_default); var coco_default2 = coco_default; var export_tokens = import_tokens.default; export { coco_default as Coco, component_default as CocoComponent, coco_default2 as default, helpers_default as helpers, tippy_default as tippy, export_tokens as tokens };