app/assets/build/coco/coco.js in coveragebook_components-0.17.7 vs app/assets/build/coco/coco.js in coveragebook_components-0.18.0

- old
+ new

@@ -15439,11 +15439,11 @@ var alpine_default = import_alpinejs.default; // ../../../package.json var package_default = { name: "coveragebook-components", - version: "0.17.7", + version: "0.18.0", repository: "git@github.com:coveragebook/coco.git", license: "NO LICENSE", author: "Mark Perkins <mark@coveragebook.com>", main: "app/assets/build/coco/coco.js", engines: { @@ -16193,10 +16193,116 @@ }); 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 }); @@ -16399,10 +16505,10 @@ } }; }); // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@components/messaging/**/*.js -var modules7 = [alert_exports, notice_exports, snackbar_exports, system_banner_exports, toast_exports, tooltip_exports]; +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, {