app/assets/build/coco/app.js in coveragebook_components-0.12.2 vs app/assets/build/coco/app.js in coveragebook_components-0.13.0

- old
+ new

@@ -6193,28 +6193,17 @@ "subheading-2": ["24px", "32px"], "subheading-3": ["20px", "28px"], "subheading-4": ["16px", "24px"] }; module.exports = { - app: { - colors: __spreadValues(__spreadValues({}, colors), colorAliases), - screens, - fontSize, - fontFamily: { - displaySans: "proxima-nova", - bodySans: "proxima-nova", - displaySerif: "merriweather" - } - }, - book: { - colors: __spreadValues(__spreadValues({}, colors), colorAliases), - screens, - fontSize, - fontFamily: { - displaySans: "proxima-nova", - bodySans: "proxima-nova" - } + colors: __spreadValues(__spreadValues({}, colors), colorAliases), + screens, + fontSize, + fontFamily: { + displaySans: "proxima-nova", + bodySans: "proxima-nova", + displaySerif: "merriweather" } }; } }); @@ -14043,14 +14032,56 @@ return html2canvas2; }); } }); + // helpers/alpine.js + 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 (error2) { + if (throwOnError) { + throw error2; + } else { + return null; + } + } + } + function getData(el) { + const root = Alpine.closestRoot(el); + return root ? Alpine.$data(root) : null; + } + function setData(el, newData) { + const data2 = getData(el); + return data2 ? Object.assign(data2, newData) : null; + } + + // helpers/location.js + 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); + } + } + // ../../../package.json var package_default = { name: "coveragebook-components", - version: "0.12.2", + version: "0.13.0", repository: "git@github.com:coveragebook/coco.git", license: "NO LICENSE", author: "Mark Perkins <mark@coveragebook.com>", type: "module", main: "index.js", @@ -14097,27 +14128,27 @@ "alias-hq": "^6.2.2", alpinejs: "^3.13.2", autoprefixer: "^10.4.16", "container-query-polyfill": "^1.0.2", del: "^7.1.0", - esbuild: "^0.19.9", + esbuild: "^0.19.11", "esbuild-plugin-copy": "^2.0.2", "fast-glob": "^3.3.1", "fast-sort": "^3.2.1", html2canvas: "^1.4.1", husky: "^8.0.3", "js-cookie": "^3.0.5", - "lint-staged": "^15.1.0", + "lint-staged": "^15.2.0", lodash: "^4.17.21", "lucide-static": "^0.294.0", postcss: "^8.4.31", "postcss-cli": "^10.1.0", "postcss-value-parser": "^4.2.0", - prettier: "^3.1.0", - "release-it": "^15.10.3", + prettier: "^3.1.1", + "release-it": "^17.0.1", svgo: "^3.0.2", - tailwindcss: "^3.3.5", + tailwindcss: "^3.4.0", "tippy.js": "^6.3.7" }, "release-it": { github: { release: true @@ -20405,41 +20436,10 @@ document.documentElement.style.paddingRight = paddingRight; }; } var module_default6 = src_default6; - // helpers/alpine.js - 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 (error2) { - if (throwOnError) { - throw error2; - } else { - return null; - } - } - } - function getData(el) { - const root = Alpine.closestRoot(el); - return root ? Alpine.$data(root) : null; - } - function setData(el, newData) { - const data2 = getData(el); - return data2 ? Object.assign(data2, newData) : null; - } - // helpers/lang.js function nameFunction(name, body) { return { [name](...args) { return body.apply(this, args); @@ -20475,11 +20475,11 @@ } } return bytes; } - // libs/alpine/directives/undo.js + // base/alpine/directives/undo.js function undo_default(Alpine3) { const maxHistorySize = 100; Alpine3.directive("undo", (el, { expression }, { evaluate: evaluate2 }) => { const data2 = getData(el); const history = Alpine3.reactive({ @@ -20545,11 +20545,11 @@ }); setData(el, { history }); }); } - // libs/alpine/directives/options.js + // base/alpine/directives/options.js var import_lodash = __toESM(require_lodash(), 1); // helpers/dom.js function castAttributeValue(value) { if (value === "false") { @@ -20565,11 +20565,11 @@ } function isNode(o3) { return typeof Node === "object" ? o3 instanceof Node : o3 && typeof o3 === "object" && typeof o3.nodeType === "number" && typeof o3.nodeName === "string"; } - // libs/alpine/directives/options.js + // base/alpine/directives/options.js function options_default(Alpine3) { Alpine3.directive( "options", (el, { expression }, { evaluate: evaluate2, effect: effect7, cleanup: cleanup2 }) => { const optionNames = evaluate2(expression); @@ -23699,11 +23699,11 @@ tippy.setDefaultProps({ render }); var tippy_esm_default = tippy; - // libs/tippy/plugins/hide_on_esc.js + // base/tippy/plugins/hide_on_esc.js var hide_on_esc_default = hideOnEsc = { name: "hideOnEsc", defaultValue: true, fn({ hide: hide2 }) { function onKeyDown(event) { @@ -23720,20 +23720,20 @@ } }; } }; - // libs/tippy/index.js + // base/tippy/index.js tippy_esm_default.setDefaultProps({ theme: null, allowHTML: true, arrow: ROUND_ARROW + ROUND_ARROW, plugins: [hide_on_esc_default, followCursor] }); var tippy_default = tippy_esm_default; - // libs/alpine/utils/tippy_modifiers.js + // base/alpine/utils/tippy_modifiers.js function tippyModifiers(modifiers) { if (modifiers.length === 0) return {}; const config = { plugins: [] @@ -23758,11 +23758,11 @@ config.placement = getModifierArgument("placement"); } return config; } - // libs/alpine/directives/tooltip.js + // base/alpine/directives/tooltip.js function tooltip_default(Alpine3) { Alpine3.directive( "tooltip", (el, { modifiers, expression }, { evaluate: evaluate2, evaluateLater: evaluateLater2, effect: effect7 }) => { const config = tippyModifiers(modifiers); @@ -23814,22 +23814,22 @@ }); } ).before("bind"); } - // libs/alpine/directives/destroy.js + // base/alpine/directives/destroy.js function destroy_default(Alpine3) { Alpine3.directive( "destroy", (el, { expression }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { const clean2 = evaluateLater2(expression); cleanup2(() => clean2()); } ); } - // libs/alpine/directives/dropdown.js + // base/alpine/directives/dropdown.js function dropdown_default(Alpine3) { Alpine3.directive( "dropdown", (el, { value, modifiers, expression }, { evaluate: evaluate2, effect: effect7 }) => { if (value) @@ -23886,11 +23886,11 @@ } } ).before("bind"); } - // libs/alpine/directives/dimensions.js + // base/alpine/directives/dimensions.js function dimensions_default(Alpine3) { Alpine3.directive( "dimensions", (el, { value, modifiers, expression }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { if (value) @@ -23923,11 +23923,11 @@ }); } ); } - // libs/alpine/directives/notification.js + // base/alpine/directives/notification.js function notification_default(Alpine3) { let notificationId = 0; let queuePosition = 0; Alpine3.directive("notification", (el, { expression }, { evaluate: evaluate2 }) => { notificationId++; @@ -23998,11 +23998,11 @@ setData(el, { notification }); evaluate2("notification.init"); }).before("init"); } - // libs/alpine/index.js + // base/alpine/index.js window.Alpine = module_default; module_default.plugin(module_default5); module_default.plugin(module_default6); module_default.plugin(module_default2); module_default.plugin(module_default3); @@ -24014,45 +24014,20 @@ module_default.plugin(dropdown_default); module_default.plugin(dimensions_default); module_default.plugin(notification_default); var alpine_default2 = module_default; - // helpers/location.js - 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); - } - } + // base/setup.js + console.info("Initializing Coco JS", package_default.version); - // app/setup.js - window.addEventListener("app:navigate", (event) => { - const url = event.detail.url; - if (url) { - delete event.detail.url; - navigateTo(url, event.detail); - } + // ../../components/coco/app/application_layout/application_layout.js + var application_layout_exports = {}; + __export(application_layout_exports, { + default: () => application_layout_default }); - function setAppHeightProperty() { - document.documentElement.style.setProperty( - "--app-height", - `${window.innerHeight}px` - ); - } - window.addEventListener("resize", setAppHeightProperty); - setAppHeightProperty(); - // ../../components/coco/shared/button/button.js - var button_exports = {}; - __export(button_exports, { - default: () => button_default - }); - - // shared/coco.js + // base/coco.js function CocoComponent(name, fn3) { const func = nameFunction(name, (...args) => { const data2 = fn3(...args); Object.defineProperties(data2, { $parent: { @@ -24066,619 +24041,25 @@ }); func.component = true; return func; } - // ../../components/coco/shared/button/button.js - var import_lodash2 = __toESM(require_lodash(), 1); - var button_default = CocoComponent("button", (data2 = {}) => { - return __spreadProps(__spreadValues({ - options: ["state", "confirm", "size", "disabled", "collapsible"], - isCollapsed: false, - approving: false, - confirmed: true, - lastState: null, - stateTooltips: data2.tooltips || {}, - tooltipText: null - }, data2.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; - 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 = (0, import_lodash2.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 content2 = this.$refs[`${state}Content`]; - return content2 ? content2.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/shared/button/button_dropdown.js - var button_dropdown_exports = {}; - __export(button_dropdown_exports, { - default: () => button_dropdown_default - }); - var button_dropdown_default = CocoComponent("buttonDropdown", () => { + // ../../components/coco/app/application_layout/application_layout.js + var application_layout_default = CocoComponent("appLayout", (opts) => { return { - dropdown: null, - button: null, + banner: false, init() { - this.$nextTick(() => { - this.button = getComponent(this.$el.querySelector(".coco-button")); - }); + this.banner = opts.banner; }, - 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)" + hideBanner() { + this.banner = false; + this.$el.remove(); } }; }); - // ../../components/coco/shared/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((t3) => t3); - 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/shared/dropdown/dropdown.js - var dropdown_exports = {}; - __export(dropdown_exports, { - default: () => dropdown_default2 - }); - var dropdown_default2 = CocoComponent("dropdown", () => { - return {}; - }); - - // ../../components/coco/shared/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/shared/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); - } - }; - }); - - // ../../components/coco/shared/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.clearFrame(); - this.$dispatch("modal:hidden"); - }, 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/shared/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/shared/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}" - } - }; - }); - - // ../../components/coco/shared/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(", "); - } - } - - // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/shared|@sharedComponents/**/*.js - var modules = [button_exports, button_dropdown_exports, button_group_exports, dropdown_exports, icon_exports, image_uploader_exports, modal_exports, modal_dialog_exports, modal_lightbox_exports, poll_controller_exports]; - var __default = modules; - - // shared/components.js - var components_default = registerComponents(__default); - - // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/book|@bookComponents/**/*.js - var modules2 = []; - var __default2 = modules2; - - // book/components.js - var components_default2 = registerComponents(__default2); - - // ../../components/coco/app/blocks/header/header.js + // ../../components/coco/app/header/header.js var header_exports = {}; __export(header_exports, { default: () => header_default }); var header_default = CocoComponent("appHeader", () => { @@ -24688,11 +24069,11 @@ this.drawerOpen = !this.drawerOpen; } }; }); - // ../../components/coco/app/blocks/nav_drawer/nav_drawer.js + // ../../components/coco/app/nav_drawer/nav_drawer.js var nav_drawer_exports = {}; __export(nav_drawer_exports, { default: () => nav_drawer_default }); var nav_drawer_default = CocoComponent("appNavDrawer", () => { @@ -24714,11 +24095,11 @@ this.drawerOpen = false; } }; }); - // ../../components/coco/app/blocks/plan_picker/plan_picker.js + // ../../components/coco/app/plan_picker/plan_picker.js var plan_picker_exports = {}; __export(plan_picker_exports, { default: () => plan_picker_default }); var plan_picker_default = CocoComponent("appPlanPicker", () => { @@ -24763,11 +24144,11 @@ return this.slider.position >= this.slider.items.length - this.slider.itemsPerPage; } }; }); - // ../../components/coco/app/blocks/sidebar_nav/item/item.js + // ../../components/coco/app/sidebar_nav/item/item.js var item_exports = {}; __export(item_exports, { default: () => item_default }); var item_default = CocoComponent("appSidebarNavItem", () => { @@ -24836,11 +24217,11 @@ return this.mobileLayout ? "top" : "right-start"; } }; }); - // ../../components/coco/app/blocks/sidebar_nav/menu/menu.js + // ../../components/coco/app/sidebar_nav/menu/menu.js var menu_exports = {}; __export(menu_exports, { default: () => menu_default }); var menu_default = CocoComponent("appSidebarNavMenu", () => { @@ -24851,17 +24232,17 @@ } } }; }); - // ../../components/coco/app/blocks/sidebar_nav/navbar/navbar.js + // ../../components/coco/app/sidebar_nav/navbar/navbar.js var navbar_exports = {}; __export(navbar_exports, { default: () => navbar_default }); var import_tokens = __toESM(require_tokens(), 1); - var mobileMaxWidth = parseInt(import_tokens.default.app.screens.sm, 10); + var mobileMaxWidth = parseInt(import_tokens.default.screens.sm, 10); var navbar_default = CocoComponent("appSidebarNav", () => { return { sizeObserver: null, mobileLayout: true, init() { @@ -24879,11 +24260,11 @@ this.sizeObserver && this.sizeObserver.disconnect(); } }; }); - // ../../components/coco/app/blocks/slide_editor/slide_editor.js + // ../../components/coco/app/slide_editor/slide_editor.js var slide_editor_exports = {}; __export(slide_editor_exports, { default: () => slide_editor_default }); @@ -24970,11 +24351,11 @@ } function getEventDetail(obj) { return obj instanceof CustomEvent ? obj.detail : obj; } - // ../../components/coco/app/blocks/slide_editor/slide_editor.js + // ../../components/coco/app/slide_editor/slide_editor.js var slide_editor_default = CocoComponent("appSlideEditor", (data2) => { const initialData = { layout: data2.layout, title: data2.title, text1: data2.text1, @@ -25036,11 +24417,11 @@ this[name] = value; this.$nextTick(() => this.updateTextareaSizes()); }, updateTextareaSizes() { const inputs = this.$root.querySelectorAll( - "[data-component='app-seamless-textarea']" + "[data-component='seamless-textarea']" ); Array.from(inputs).forEach((el) => getData(el).onResize()); }, setLayout(layout) { this.layout = layout; @@ -25184,16 +24565,553 @@ thumbnailImage: { "x-effect": "syncFileInput($el, thumbnailFile)" } } }); }); - // ../../components/coco/app/elements/alert/alert.js + // ../../components/coco/buttons/button/button.js + var button_exports = {}; + __export(button_exports, { + default: () => button_default + }); + var import_lodash2 = __toESM(require_lodash(), 1); + var button_default = CocoComponent("button", (data2 = {}) => { + return __spreadProps(__spreadValues({ + options: ["state", "confirm", "size", "disabled", "collapsible"], + isCollapsed: false, + approving: false, + confirmed: true, + lastState: null, + stateTooltips: data2.tooltips || {}, + tooltipText: null + }, data2.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; + 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 = (0, import_lodash2.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 content2 = this.$refs[`${state}Content`]; + return content2 ? content2.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((t3) => t3); + 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((g3) => g3).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; + }); + } + }; + }); + + // ../../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); + } + }; + }); + + // ../../components/coco/layout/page/page.js + var page_exports = {}; + __export(page_exports, { + default: () => page_default + }); + var page_default = CocoComponent("pageLayout", () => { + return {}; + }); + + // ../../components/coco/messaging/alert/alert.js var alert_exports = {}; __export(alert_exports, { default: () => alert_default }); - var alert_default = CocoComponent("appAlert", () => { + var alert_default = CocoComponent("alertMessage", () => { return { alert: null, dismissed: false, forceMultiLine: false, dismissDuration: 300, @@ -25230,11 +25148,367 @@ ":class": "{'force-multi-line': forceMultiLine}" } }; }); - // ../../components/coco/app/elements/color_picker/color_picker.js + // ../../components/coco/messaging/notice/notice.js + var notice_exports = {}; + __export(notice_exports, { + default: () => notice_default + }); + var notice_default = CocoComponent("notice", () => { + return {}; + }); + + // ../../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 + }); + + // ../../../node_modules/js-cookie/dist/js.cookie.mjs + function assign(target) { + for (var i3 = 1; i3 < arguments.length; i3++) { + var source = arguments[i3]; + for (var key in source) { + target[key] = source[key]; + } + } + return target; + } + var defaultConverter = { + read: function(value) { + if (value[0] === '"') { + value = value.slice(1, -1); + } + return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); + }, + write: function(value) { + return encodeURIComponent(value).replace( + /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, + decodeURIComponent + ); + } + }; + function init(converter, defaultAttributes) { + function set3(name, value, attributes) { + if (typeof document === "undefined") { + return; + } + attributes = assign({}, defaultAttributes, attributes); + if (typeof attributes.expires === "number") { + attributes.expires = new Date(Date.now() + attributes.expires * 864e5); + } + if (attributes.expires) { + attributes.expires = attributes.expires.toUTCString(); + } + name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); + var stringifiedAttributes = ""; + for (var attributeName in attributes) { + if (!attributes[attributeName]) { + continue; + } + stringifiedAttributes += "; " + attributeName; + if (attributes[attributeName] === true) { + continue; + } + stringifiedAttributes += "=" + attributes[attributeName].split(";")[0]; + } + return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes; + } + function get3(name) { + if (typeof document === "undefined" || arguments.length && !name) { + return; + } + var cookies = document.cookie ? document.cookie.split("; ") : []; + var jar = {}; + for (var i3 = 0; i3 < cookies.length; i3++) { + var parts = cookies[i3].split("="); + var value = parts.slice(1).join("="); + try { + var found = decodeURIComponent(parts[0]); + jar[found] = converter.read(value, found); + if (name === found) { + break; + } + } catch (e3) { + } + } + return name ? jar[name] : jar; + } + return Object.create( + { + set: set3, + get: get3, + remove: function(name, attributes) { + set3( + name, + "", + assign({}, attributes, { + expires: -1 + }) + ); + }, + withAttributes: function(attributes) { + return init(this.converter, assign({}, this.attributes, attributes)); + }, + withConverter: function(converter2) { + return init(assign({}, this.converter, converter2), this.attributes); + } + }, + { + attributes: { value: Object.freeze(defaultAttributes) }, + converter: { value: Object.freeze(converter) } + } + ); + } + var api = init(defaultConverter, { path: "/" }); + + // ../../components/coco/messaging/system_banner/system_banner.js + 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) { + api.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/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.clearFrame(); + this.$dispatch("modal:hidden"); + }, 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}" + } + }; + }); + + // ../../components/coco/pickers/color_picker/color_picker.js var color_picker_exports = {}; __export(color_picker_exports, { default: () => color_picker_default }); @@ -26942,12 +27216,12 @@ })(ui = iro2.ui || (iro2.ui = {})); })(iro || (iro = {})); var iro$1 = iro; var iro_es_default = iro$1; - // ../../components/coco/app/elements/color_picker/color_picker.js - var color_picker_default = CocoComponent("appColorPicker", ({ selected }) => { + // ../../components/coco/pickers/color_picker/color_picker.js + var color_picker_default = CocoComponent("colorPicker", ({ selected }) => { return { selectedColor: selected, display: selected, updating: false, invalid: false, @@ -27022,52 +27296,16 @@ this.cleanupColorWheel(); } }; }); - // ../../components/coco/app/elements/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("appColorPickerButton", ({ 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/app/elements/confirm_panel/confirm_panel.js - var confirm_panel_exports = {}; - __export(confirm_panel_exports, { - default: () => confirm_panel_default - }); - var confirm_panel_default = CocoComponent("appConfirmPanel", () => { - return { - confirm() { - this.$dispatch("confirmation:confirm"); - }, - cancel() { - this.$dispatch("confirmation:cancel"); - } - }; - }); - - // ../../components/coco/app/elements/image_picker/image_picker.js + // ../../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("appImagePicker", ({ src }) => { + var image_picker_default = CocoComponent("imagePicker", ({ src }) => { return { image: { name: basename(src), file: null, data: src @@ -27109,107 +27347,89 @@ this.uploader.openPicker(); } }; }); - // ../../components/coco/app/elements/image_picker_button/image_picker_button.js - var image_picker_button_exports = {}; - __export(image_picker_button_exports, { - default: () => image_picker_button_default + // ../../components/coco/utilities/dropdown/dropdown.js + var dropdown_exports = {}; + __export(dropdown_exports, { + default: () => dropdown_default2 }); - var image_picker_button_default = CocoComponent("appImagePickerButton", ({ src }) => { + 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 { - selectedImage: { - name: basename(src), - file: null, - data: src + polling: false, + frame: null, + pollTimer: null, + get interval() { + return parseInt(this.$root.dataset.interval || 0, 10); }, - getPicker() { - return getData( - this.$root.querySelector("[data-role='image-picker'").firstElementChild - ); + init() { + this.frame = document.getElementById("polling-controller-frame"); + this.observer = new MutationObserver(() => this.onUpdate()); + this.observer.observe(this.$el, { attributes: true }); }, - handleExternalDrop(event) { - this.readFile(event.dataTransfer.files[0]); + startPolling() { + if (this.interval > 0 && !this.polling) { + this.polling = true; + this.queuePollRequest(500); + } }, - 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(); - } + onUpdate() { + this.$nextTick(() => { + this.$dispatch("dom-updates:complete", { html: document }); }); - reader.readAsDataURL(file); + this.queuePollRequest(); }, - clearSelectedImage() { - this.dropdown.hide(); - this.selectedImage = { name: null, data: null, file: null }; + queuePollRequest(wait) { + if (this.pollTimer) + clearTimeout(this.pollTimer); + if (this.interval > 0 && this.polling) { + this.pollTimer = setTimeout( + () => this.reloadFrame(), + wait || this.interval + ); + } }, - setSelectedImage(image) { - this.dropdown.hide(); - this.selectedImage = image; - }, - onDropdownMount({ detail }) { - this.dropdown = detail.dropdown; - this.getPicker().setImage(this.selectedImage, true); - } - }; - }); - - // ../../components/coco/app/elements/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("appLayoutPickerButton", ({ selected }) => { - return { - selectedLayout: selected, - getPicker() { - return getData( - this.$root.querySelector("[data-role='layout-picker']").firstElementChild + reloadFrame() { + this.frame.addEventListener( + "turbo:before-fetch-request", + addStreamHeaders, + { once: true } ); + window.Turbo.visit(location.href, { + frame: this.frame.id, + action: "replace" + }); }, - getButton() { - return getData(this.$root.querySelector(".layout-picker-trigger")); - }, - init() { - this.$watch("selectedLayout", () => this.getButton().hideDropdown()); + 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/app/elements/menu_button/menu_button.js - var menu_button_exports = {}; - __export(menu_button_exports, { - default: () => menu_button_default - }); - var menu_button_default = CocoComponent("appMenuButton", () => { - return {}; - }); - - // ../../components/coco/app/elements/notice/notice.js - var notice_exports = {}; - __export(notice_exports, { - default: () => notice_default - }); - var notice_default = CocoComponent("appNotice", () => { - return {}; - }); - - // ../../components/coco/app/elements/seamless_textarea/seamless_textarea.js + // ../../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("appSeamlessTextarea", () => { + var seamless_textarea_default = CocoComponent("seamlessTextarea", () => { return { height: null, observer: null, value: null, options: ["multiline", "focus"], @@ -27235,278 +27455,31 @@ } } }; }); - // ../../components/coco/app/elements/snackbar/snackbar.js - var snackbar_exports = {}; - __export(snackbar_exports, { - default: () => snackbar_default - }); - var snackbar_default = CocoComponent("appSnackbar", () => { - 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" - } - }; - }); + // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js|@components/**/*.js + var modules = [application_layout_exports, header_exports, nav_drawer_exports, plan_picker_exports, item_exports, menu_exports, navbar_exports, slide_editor_exports, 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, icon_exports, image_uploader_exports, page_exports, alert_exports, notice_exports, snackbar_exports, system_banner_exports, toast_exports, modal_exports, modal_dialog_exports, modal_lightbox_exports, color_picker_exports, image_picker_exports, dropdown_exports, poll_controller_exports, seamless_textarea_exports]; + var __default = modules; - // ../../components/coco/app/elements/system_banner/system_banner.js - var system_banner_exports = {}; - __export(system_banner_exports, { - default: () => system_banner_default - }); - - // ../../../node_modules/js-cookie/dist/js.cookie.mjs - function assign(target) { - for (var i3 = 1; i3 < arguments.length; i3++) { - var source = arguments[i3]; - for (var key in source) { - target[key] = source[key]; - } + // app.js + registerComponents(__default); + window.addEventListener("app:navigate", (event) => { + const url = event.detail.url; + if (url) { + delete event.detail.url; + navigateTo(url, event.detail); } - return target; - } - var defaultConverter = { - read: function(value) { - if (value[0] === '"') { - value = value.slice(1, -1); - } - return value.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent); - }, - write: function(value) { - return encodeURIComponent(value).replace( - /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g, - decodeURIComponent - ); - } - }; - function init(converter, defaultAttributes) { - function set3(name, value, attributes) { - if (typeof document === "undefined") { - return; - } - attributes = assign({}, defaultAttributes, attributes); - if (typeof attributes.expires === "number") { - attributes.expires = new Date(Date.now() + attributes.expires * 864e5); - } - if (attributes.expires) { - attributes.expires = attributes.expires.toUTCString(); - } - name = encodeURIComponent(name).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape); - var stringifiedAttributes = ""; - for (var attributeName in attributes) { - if (!attributes[attributeName]) { - continue; - } - stringifiedAttributes += "; " + attributeName; - if (attributes[attributeName] === true) { - continue; - } - stringifiedAttributes += "=" + attributes[attributeName].split(";")[0]; - } - return document.cookie = name + "=" + converter.write(value, name) + stringifiedAttributes; - } - function get3(name) { - if (typeof document === "undefined" || arguments.length && !name) { - return; - } - var cookies = document.cookie ? document.cookie.split("; ") : []; - var jar = {}; - for (var i3 = 0; i3 < cookies.length; i3++) { - var parts = cookies[i3].split("="); - var value = parts.slice(1).join("="); - try { - var found = decodeURIComponent(parts[0]); - jar[found] = converter.read(value, found); - if (name === found) { - break; - } - } catch (e3) { - } - } - return name ? jar[name] : jar; - } - return Object.create( - { - set: set3, - get: get3, - remove: function(name, attributes) { - set3( - name, - "", - assign({}, attributes, { - expires: -1 - }) - ); - }, - withAttributes: function(attributes) { - return init(this.converter, assign({}, this.attributes, attributes)); - }, - withConverter: function(converter2) { - return init(assign({}, this.converter, converter2), this.attributes); - } - }, - { - attributes: { value: Object.freeze(defaultAttributes) }, - converter: { value: Object.freeze(converter) } - } + }); + function setAppHeightProperty() { + document.documentElement.style.setProperty( + "--app-height", + `${window.innerHeight}px` ); } - var api = init(defaultConverter, { path: "/" }); - - // ../../components/coco/app/elements/system_banner/system_banner.js - var system_banner_default = CocoComponent("appSystemBanner", (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) { - api.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/app/elements/toast/toast.js - var toast_exports = {}; - __export(toast_exports, { - default: () => toast_default - }); - var toast_default = CocoComponent("appToast", () => { - 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/app/elements/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((g3) => g3).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; - }); - } - }; - }); - - // ../../components/coco/app/layouts/application/application.js - var application_exports = {}; - __export(application_exports, { - default: () => application_default - }); - var application_default = CocoComponent("appLayout", (opts) => { - return { - banner: false, - init() { - this.banner = opts.banner; - }, - hideBanner() { - this.banner = false; - this.$el.remove(); - } - }; - }); - - // ../../components/coco/app/layouts/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/app|@appComponents/**/*.js - var modules3 = [header_exports, nav_drawer_exports, plan_picker_exports, item_exports, menu_exports, navbar_exports, slide_editor_exports, alert_exports, color_picker_exports, color_picker_button_exports, confirm_panel_exports, image_picker_exports, image_picker_button_exports, layout_picker_button_exports, menu_button_exports, notice_exports, seamless_textarea_exports, snackbar_exports, system_banner_exports, toast_exports, toolbar_exports, application_exports, page_exports]; - var __default3 = modules3; - - // app/components.js - var components_default3 = registerComponents(__default3); - - // app.js - console.info("Initializing Coco JS", package_default.version); + window.addEventListener("resize", setAppHeightProperty); + setAppHeightProperty(); alpine_default2.start(); })(); /*! Bundled license information: lodash/lodash.js: @@ -27554,16 +27527,16 @@ * focus-trap 6.9.4 * @license MIT, https://github.com/focus-trap/focus-trap/blob/master/LICENSE *) *) +js-cookie/dist/js.cookie.mjs: + (*! js-cookie v3.0.5 | MIT *) + @jaames/iro/dist/iro.es.js: (*! * iro.js v5.5.2 * 2016-2021 James Daniel * Licensed under MPL 2.0 * github.com/jaames/iro.js *) - -js-cookie/dist/js.cookie.mjs: - (*! js-cookie v3.0.5 | MIT *) */