app/assets/build/coco/book.js in coveragebook_components-0.6.5 vs app/assets/build/coco/book.js in coveragebook_components-0.7.0

- old
+ new

@@ -9368,19 +9368,19 @@ modifiers.includes("self") ? delete el._x_ignoreSelf : delete el._x_ignore; }); }; directive("ignore", handler); directive("effect", (el, { expression }, { effect: effect32 }) => effect32(evaluateLater(el, expression))); - function on(el, event, modifiers, callback) { + function on(el, event2, modifiers, callback) { let listenerTarget = el; let handler3 = (e2) => callback(e2); let options = {}; let wrapHandler = (callback2, wrapper) => (e2) => wrapper(callback2, e2); if (modifiers.includes("dot")) - event = dotSyntax(event); + event2 = dotSyntax(event2); if (modifiers.includes("camel")) - event = camelCase2(event); + event2 = camelCase2(event2); if (modifiers.includes("passive")) options.passive = true; if (modifiers.includes("capture")) options.capture = true; if (modifiers.includes("window")) @@ -9426,24 +9426,24 @@ }); } if (modifiers.includes("once")) { handler3 = wrapHandler(handler3, (next, e2) => { next(e2); - listenerTarget.removeEventListener(event, handler3, options); + listenerTarget.removeEventListener(event2, handler3, options); }); } handler3 = wrapHandler(handler3, (next, e2) => { - if (isKeyEvent(event)) { + if (isKeyEvent(event2)) { if (isListeningForASpecificKeyThatHasntBeenPressed(e2, modifiers)) { return; } } next(e2); }); - listenerTarget.addEventListener(event, handler3, options); + listenerTarget.addEventListener(event2, handler3, options); return () => { - listenerTarget.removeEventListener(event, handler3, options); + listenerTarget.removeEventListener(event2, handler3, options); }; } function dotSyntax(subject) { return subject.replace(/-/g, "."); } @@ -9456,12 +9456,12 @@ function kebabCase2(subject) { if ([" ", "_"].includes(subject)) return subject; return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); } - function isKeyEvent(event) { - return ["keydown", "keyup"].includes(event); + function isKeyEvent(event2) { + return ["keydown", "keyup"].includes(event2); } function isListeningForASpecificKeyThatHasntBeenPressed(e2, modifiers) { let keyModifiers = modifiers.filter((i2) => { return !["window", "document", "prevent", "stop", "once", "capture"].includes(i2); }); @@ -9555,17 +9555,17 @@ mutateDom(() => { if (!el.hasAttribute("name")) el.setAttribute("name", expression); }); } - var event = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input"; + var event2 = el.tagName.toLowerCase() === "select" || ["checkbox", "radio"].includes(el.type) || modifiers.includes("lazy") ? "change" : "input"; let removeListener = isCloning ? () => { - } : on(el, event, modifiers, (e2) => { + } : on(el, event2, modifiers, (e2) => { setValue(getInputValue(el, modifiers, e2, getValue())); }); if (modifiers.includes("fill") && [null, ""].includes(getValue())) { - el.dispatchEvent(new Event(event, {})); + el.dispatchEvent(new Event(event2, {})); } if (!el._x_removeModelListeners) el._x_removeModelListeners = {}; el._x_removeModelListeners["default"] = removeListener; cleanup2(() => el._x_removeModelListeners["default"]()); @@ -9596,31 +9596,31 @@ if (modifiers.includes("unintrusive") && document.activeElement.isSameNode(el)) return; el._x_forceModelUpdate(value); }); }); - function getInputValue(el, modifiers, event, currentValue) { + function getInputValue(el, modifiers, event2, currentValue) { return mutateDom(() => { var _a; - if (event instanceof CustomEvent && event.detail !== void 0) - return (_a = event.detail) != null ? _a : event.target.value; + if (event2 instanceof CustomEvent && event2.detail !== void 0) + return (_a = event2.detail) != null ? _a : event2.target.value; else if (el.type === "checkbox") { if (Array.isArray(currentValue)) { - let newValue = modifiers.includes("number") ? safeParseNumber(event.target.value) : event.target.value; - return event.target.checked ? currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); + let newValue = modifiers.includes("number") ? safeParseNumber(event2.target.value) : event2.target.value; + return event2.target.checked ? currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); } else { - return event.target.checked; + return event2.target.checked; } } else if (el.tagName.toLowerCase() === "select" && el.multiple) { - return modifiers.includes("number") ? Array.from(event.target.selectedOptions).map((option) => { + return modifiers.includes("number") ? Array.from(event2.target.selectedOptions).map((option) => { let rawValue = option.value || option.text; return safeParseNumber(rawValue); - }) : Array.from(event.target.selectedOptions).map((option) => { + }) : Array.from(event2.target.selectedOptions).map((option) => { return option.value || option.text; }); } else { - let rawValue = event.target.value; + let rawValue = event2.target.value; return modifiers.includes("number") ? safeParseNumber(rawValue) : modifiers.includes("trim") ? rawValue.trim() : rawValue; } }); } function safeParseNumber(rawValue) { @@ -13175,12 +13175,12 @@ function getOwnerDocument(elementOrElements) { var _element$ownerDocumen; var _normalizeToArray = normalizeToArray(elementOrElements), element = _normalizeToArray[0]; return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document; } - function isCursorOutsideInteractiveBorder(popperTreeData, event) { - var clientX = event.clientX, clientY = event.clientY; + function isCursorOutsideInteractiveBorder(popperTreeData, event2) { + var clientX = event2.clientX, clientY = event2.clientY; return popperTreeData.every(function(_ref) { var popperRect = _ref.popperRect, popperState = _ref.popperState, props = _ref.props; var interactiveBorder = props.interactiveBorder; var basePlacement = getBasePlacement2(popperState.placement); var offsetData = popperState.modifiersData.offset; @@ -13198,12 +13198,12 @@ return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight; }); } function updateTransitionEndListener(box, action, listener) { var method = action + "EventListener"; - ["transitionend", "webkitTransitionEnd"].forEach(function(event) { - box[method](event, listener); + ["transitionend", "webkitTransitionEnd"].forEach(function(event2) { + box[method](event2, listener); }); } function actualContains(parent, child) { var target = child; while (target) { @@ -13723,17 +13723,17 @@ getDocument().removeEventListener("mousemove", debouncedOnMouseMove); mouseMoveListeners = mouseMoveListeners.filter(function(listener) { return listener !== debouncedOnMouseMove; }); } - function onDocumentPress(event) { + function onDocumentPress(event2) { if (currentInput.isTouch) { - if (didTouchMove || event.type === "mousedown") { + if (didTouchMove || event2.type === "mousedown") { return; } } - var actualTarget = event.composedPath && event.composedPath()[0] || event.target; + var actualTarget = event2.composedPath && event2.composedPath()[0] || event2.target; if (instance.props.interactive && actualContains(popper2, actualTarget)) { return; } if (normalizeToArray(instance.props.triggerTarget || reference2).some(function(el) { return actualContains(el, actualTarget); @@ -13743,11 +13743,11 @@ } if (instance.state.isVisible && instance.props.trigger.indexOf("click") >= 0) { return; } } else { - invokeHook("onClickOutside", [instance, event]); + invokeHook("onClickOutside", [instance, event2]); } if (instance.props.hideOnClick === true) { instance.clearDelayTimeouts(); instance.hide(); didHideDueToDocumentMouseDown = true; @@ -13789,12 +13789,12 @@ function onTransitionedIn(duration, callback) { onTransitionEnd(duration, callback); } function onTransitionEnd(duration, callback) { var box = getDefaultTemplateChildren().box; - function listener(event) { - if (event.target === box) { + function listener(event2) { + if (event2.target === box) { updateTransitionEndListener(box, "remove", listener); callback(); } } if (duration === 0) { @@ -13851,41 +13851,41 @@ var node = _ref.node, eventType = _ref.eventType, handler3 = _ref.handler, options = _ref.options; node.removeEventListener(eventType, handler3, options); }); listeners = []; } - function onTrigger2(event) { + function onTrigger2(event2) { var _lastTriggerEvent; var shouldScheduleClickHide = false; - if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) { + if (!instance.state.isEnabled || isEventListenerStopped(event2) || didHideDueToDocumentMouseDown) { return; } var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === "focus"; - lastTriggerEvent = event; - currentTarget = event.currentTarget; + lastTriggerEvent = event2; + currentTarget = event2.currentTarget; handleAriaExpandedAttribute(); - if (!instance.state.isVisible && isMouseEvent(event)) { + if (!instance.state.isVisible && isMouseEvent(event2)) { mouseMoveListeners.forEach(function(listener) { - return listener(event); + return listener(event2); }); } - if (event.type === "click" && (instance.props.trigger.indexOf("mouseenter") < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) { + if (event2.type === "click" && (instance.props.trigger.indexOf("mouseenter") < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) { shouldScheduleClickHide = true; } else { - scheduleShow(event); + scheduleShow(event2); } - if (event.type === "click") { + if (event2.type === "click") { isVisibleFromClick = !shouldScheduleClickHide; } if (shouldScheduleClickHide && !wasFocused) { - scheduleHide(event); + scheduleHide(event2); } } - function onMouseMove(event) { - var target = event.target; + function onMouseMove(event2) { + var target = event2.target; var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper2.contains(target); - if (event.type === "mousemove" && isCursorOverReferenceOrPopper) { + if (event2.type === "mousemove" && isCursorOverReferenceOrPopper) { return; } var popperTreeData = getNestedPopperTree().concat(popper2).map(function(popper3) { var _instance$popperInsta; var instance2 = popper3._tippy; @@ -13897,37 +13897,37 @@ props }; } return null; }).filter(Boolean); - if (isCursorOutsideInteractiveBorder(popperTreeData, event)) { + if (isCursorOutsideInteractiveBorder(popperTreeData, event2)) { cleanupInteractiveMouseListeners(); - scheduleHide(event); + scheduleHide(event2); } } - function onMouseLeave(event) { - var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf("click") >= 0 && isVisibleFromClick; + function onMouseLeave(event2) { + var shouldBail = isEventListenerStopped(event2) || instance.props.trigger.indexOf("click") >= 0 && isVisibleFromClick; if (shouldBail) { return; } if (instance.props.interactive) { - instance.hideWithInteractivity(event); + instance.hideWithInteractivity(event2); return; } - scheduleHide(event); + scheduleHide(event2); } - function onBlurOrFocusOut(event) { - if (instance.props.trigger.indexOf("focusin") < 0 && event.target !== getCurrentTarget()) { + function onBlurOrFocusOut(event2) { + if (instance.props.trigger.indexOf("focusin") < 0 && event2.target !== getCurrentTarget()) { return; } - if (instance.props.interactive && event.relatedTarget && popper2.contains(event.relatedTarget)) { + if (instance.props.interactive && event2.relatedTarget && popper2.contains(event2.relatedTarget)) { return; } - scheduleHide(event); + scheduleHide(event2); } - function isEventListenerStopped(event) { - return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf("touch") >= 0 : false; + function isEventListenerStopped(event2) { + return currentInput.isTouch ? getIsCustomTouchBehavior() !== event2.type.indexOf("touch") >= 0 : false; } function createPopperInstance() { destroyPopperInstance(); var _instance$props2 = instance.props, popperOptions = _instance$props2.popperOptions, placement = _instance$props2.placement, offset2 = _instance$props2.offset, getReferenceClientRect = _instance$props2.getReferenceClientRect, moveTransition = _instance$props2.moveTransition; var arrow2 = getIsDefaultRenderFn() ? getChildren(popper2).arrow : null; @@ -14026,14 +14026,14 @@ } } function getNestedPopperTree() { return arrayFrom(popper2.querySelectorAll("[data-tippy-root]")); } - function scheduleShow(event) { + function scheduleShow(event2) { instance.clearDelayTimeouts(); - if (event) { - invokeHook("onTrigger", [instance, event]); + if (event2) { + invokeHook("onTrigger", [instance, event2]); } addDocumentPress(); var delay3 = getDelay(true); var _getNormalizedTouchSe = getNormalizedTouchSettings(), touchValue = _getNormalizedTouchSe[0], touchDelay = _getNormalizedTouchSe[1]; if (currentInput.isTouch && touchValue === "hold" && touchDelay) { @@ -14045,18 +14045,18 @@ }, delay3); } else { instance.show(); } } - function scheduleHide(event) { + function scheduleHide(event2) { instance.clearDelayTimeouts(); - invokeHook("onUntrigger", [instance, event]); + invokeHook("onUntrigger", [instance, event2]); if (!instance.state.isVisible) { removeDocumentPress(); return; } - if (instance.props.trigger.indexOf("mouseenter") >= 0 && instance.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(event.type) >= 0 && isVisibleFromClick) { + if (instance.props.trigger.indexOf("mouseenter") >= 0 && instance.props.trigger.indexOf("click") >= 0 && ["mouseleave", "mousemove"].indexOf(event2.type) >= 0 && isVisibleFromClick) { return; } var delay3 = getDelay(false); if (delay3) { hideTimeout = setTimeout(function() { @@ -14225,17 +14225,17 @@ } } else { instance.unmount(); } } - function hideWithInteractivity(event) { + function hideWithInteractivity(event2) { if (true) { warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("hideWithInteractivity")); } getDocument().addEventListener("mousemove", debouncedOnMouseMove); pushIfUnique(mouseMoveListeners, debouncedOnMouseMove); - debouncedOnMouseMove(event); + debouncedOnMouseMove(event2); } function unmount() { if (true) { warnWhen(instance.state.isDestroyed, createMemoryLeakWarning("unmount")); } @@ -14368,14 +14368,14 @@ instance.setProps({ getReferenceClientRect: null }); isInternalUpdate = false; } - function onMouseMove(event) { - var isCursorOverReference = event.target ? reference2.contains(event.target) : true; + function onMouseMove(event2) { + var isCursorOverReference = event2.target ? reference2.contains(event2.target) : true; var followCursor2 = instance.props.followCursor; - var clientX = event.clientX, clientY = event.clientY; + var clientX = event2.clientX, clientY = event2.clientY; var rect = reference2.getBoundingClientRect(); var relativeX = clientX - rect.left; var relativeY = clientY - rect.top; if (isCursorOverReference || !instance.props.interactive) { instance.setProps({ @@ -14456,18 +14456,18 @@ if (!getIsInitialBehavior()) { addListener(); } } }, - onTrigger: function onTrigger2(_2, event) { - if (isMouseEvent(event)) { + onTrigger: function onTrigger2(_2, event2) { + if (isMouseEvent(event2)) { mouseCoords = { - clientX: event.clientX, - clientY: event.clientY + clientX: event2.clientX, + clientY: event2.clientY }; } - wasFocusEvent = event.type === "focus"; + wasFocusEvent = event2.type === "focus"; }, onHidden: function onHidden2() { if (instance.props.followCursor) { unsetGetReferenceClientRect(); removeListener(); @@ -14485,12 +14485,12 @@ // libs/tippy/plugins/hide_on_esc.js var hide_on_esc_default = hideOnEsc = { name: "hideOnEsc", defaultValue: true, fn({ hide: hide2 }) { - function onKeyDown(event) { - if (event.keyCode === 27) { + function onKeyDown(event2) { + if (event2.keyCode === 27) { hide2(); } } return { onShow() { @@ -14767,12 +14767,12 @@ } }, 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) { + clearFromQueue(event2) { + if (notification.type === event2.detail.type && notification.position === "fixed" && notification.id !== event2.detail.id && notification.queuePosition < event2.detail.queuePosition) { notification.dismiss(); } } }); setData(el, { notification }); @@ -15013,29 +15013,29 @@ if (this.dropdown) { this.dropdown.show(); } }, /* confirmation */ - checkConfirmation(event) { + checkConfirmation(event2) { if (!this.confirmed) { this.approving = true; - event.preventDefault(); + event2.preventDefault(); } }, - approveAndRun(event) { + approveAndRun(event2) { if (this.approving) { - event.stopPropagation(); + event2.stopPropagation(); this.confirmed = true; this.dropdown.trigger.click(); this.dropdown.hide(); this.confirmed = false; this.approving = false; } }, - cancelConfirmation(event) { + cancelConfirmation(event2) { if (this.approving) { - event.stopPropagation(); + event2.stopPropagation(); this.approving = false; this.dropdown.hide(); } }, /* state */ @@ -15181,12 +15181,12 @@ }, clear() { this.file = null; this.$dispatch("image-uploader:clear"); }, - handleDrop(event) { - const files = event.detail.files || event.dataTransfer.files; + handleDrop(event2) { + const files = event2.detail.files || event2.dataTransfer.files; this.handleFiles(files); }, handleFiles(files) { Array.from(files).forEach((file) => this.readFile(file)); }, @@ -15208,11 +15208,94 @@ reader.readAsDataURL(file); } }; }); + // ../../components/coco/base/modal/modal.js + var modal_exports = {}; + __export(modal_exports, { + default: () => modal_default + }); + var modal_default = CocoComponent("modal", () => { + return { + open: false, + frame: null, + options: ["dismissable", "closeOnSubmit"], + init() { + 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; + }, + hide() { + this.open = false; + setTimeout(() => this.clearFrame(), 100); + }, + dismiss(event2) { + if (this.$options.dismissable) + this.hide(); + }, + clearFrame() { + this.frame.removeAttribute("src"); + this.frame.removeAttribute("complete"); + this.frame.innerHTML = ""; + }, + onFrameSubmitEnd() { + if (this.$options.closeOnSubmit && event.detail.success) { + this.hide(); + } + }, + destroy() { + this.frame.removeEventListener("turbo:submit-end", this.onFrameSubmitEnd); + }, + root: { + "x-options": "options", + "x-show": "open", + "@keydown.escape.document": "dismiss", + "@modal:hide.document": "hide" + } + }; + }); + + // ../../components/coco/base/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.$dispatch("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" + ); + } + }; + }); + // import-glob:/Users/mark/Code/coveragebook/coco/app/assets/js/base|@baseComponents/**/*.js - var modules = [button_exports, dropdown_exports, icon_exports, image_uploader_exports]; + var modules = [button_exports, dropdown_exports, icon_exports, image_uploader_exports, modal_exports, modal_dialog_exports]; var __default = modules; // base/components.js var components_default = registerComponents(__default);