app/assets/build/coco/book.js in coveragebook_components-0.8.9 vs app/assets/build/coco/book.js in coveragebook_components-0.9.0

- old
+ new

@@ -11813,10 +11813,21 @@ } }); }); 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) { @@ -15059,14 +15070,15 @@ return; const data2 = getData(el); const settings = tippyModifiers(modifiers); const result = expression ? evaluate2(expression) : {}; const directiveConfig = isObject2(result) ? result : {}; - let _a = directiveConfig, { triggerTarget, contentTarget } = _a, config = __objRest(_a, ["triggerTarget", "contentTarget"]); + let _a = directiveConfig, { triggerTarget, contentTarget, anchorTarget } = _a, config = __objRest(_a, ["triggerTarget", "contentTarget", "anchorTarget"]); contentTarget = contentTarget || el.querySelector("[x-dropdown\\:content]"); 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, @@ -15078,11 +15090,11 @@ el.__x_dropdown.show(); } } }); setData(el, mixin); - const dropdown = el.__x_dropdown = tippy_default(el, __spreadValues(__spreadValues({ + const dropdown = el.__x_dropdown = tippy_default(anchorTarget, __spreadValues(__spreadValues({ theme: "coco-app-dropdown", placement: "bottom-start", offset: [0, 0], trigger: "click", interactive: true, @@ -15270,15 +15282,17 @@ isCollapsed: false, approving: false, confirmed: true, lastState: null, stateTooltips: data2.tooltips || {}, - tooltipText: null, - dropdown: null + 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; } }); @@ -15302,30 +15316,22 @@ this.tooltipText = tooltipForState || labelText || defaultContent; } else { this.tooltipText = tooltipForState || defaultContent; } }, - showTooltip() { + shouldShowTooltip() { return !!this.tooltipText; }, get disabled() { return this.$options.disabled === true; }, set disabled(value) { this.$options.disabled = value; }, - /* dropdown */ - hideDropdown() { - if (this.dropdown) { - this.dropdown.hide(); - } + get tippyInstance() { + return this.$root.__x_tippy; }, - showDropdown() { - if (this.dropdown) { - this.dropdown.show(); - } - }, /* confirmation */ checkConfirmation(event) { if (!this.confirmed) { this.approving = true; event.preventDefault(); @@ -15400,19 +15406,42 @@ }, /* bindings */ root: { "x-options": "options", "x-tooltip": "tooltipText", - "x-effect": "setTooltipText", - "@confirmation:confirm": "approveAndRun", - "@confirmation:cancel": "cancelConfirmation", - "@dropdown:show": "setState('active')", - "@dropdown:hide": "resetState()" + "x-effect": "setTooltipText" } }); }); + // ../../components/coco/base/button/button_dropdown.js + var button_dropdown_exports = {}; + __export(button_dropdown_exports, { + default: () => button_dropdown_default + }); + var button_dropdown_default = CocoComponent("buttonDropdown", (data2 = {}) => { + 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(); + } + } + }; + }); + // ../../components/coco/base/dropdown/dropdown.js var dropdown_exports = {}; __export(dropdown_exports, { default: () => dropdown_default2 }); @@ -15753,10 +15782,10 @@ headers.Accept = ["text/vnd.turbo-stream.html", headers.Accept].join(", "); } } // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@baseComponents/**/*.js - var modules = [button_exports, dropdown_exports, icon_exports, image_uploader_exports, modal_exports, modal_dialog_exports, modal_lightbox_exports, poll_controller_exports]; + var modules = [button_exports, button_dropdown_exports, dropdown_exports, icon_exports, image_uploader_exports, modal_exports, modal_dialog_exports, modal_lightbox_exports, poll_controller_exports]; var __default = modules; // base/components.js var components_default = registerComponents(__default);