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

- old
+ new

@@ -14030,11 +14030,11 @@ // ../../../package.json var package_default = { name: "coveragebook-components", type: "module", - version: "0.6.5", + version: "0.7.0", main: "index.js", repository: "git@github.com:coveragebook/coco.git", author: "Mark Perkins <mark@coveragebook.com>", license: "NO LICENSE", browserslist: [ @@ -17958,19 +17958,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 = (e3) => callback(e3); let options = {}; let wrapHandler = (callback2, wrapper) => (e3) => wrapper(callback2, e3); 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")) @@ -18016,24 +18016,24 @@ }); } if (modifiers.includes("once")) { handler3 = wrapHandler(handler3, (next, e3) => { next(e3); - listenerTarget.removeEventListener(event, handler3, options); + listenerTarget.removeEventListener(event2, handler3, options); }); } handler3 = wrapHandler(handler3, (next, e3) => { - if (isKeyEvent(event)) { + if (isKeyEvent(event2)) { if (isListeningForASpecificKeyThatHasntBeenPressed(e3, modifiers)) { return; } } next(e3); }); - 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, "."); } @@ -18046,12 +18046,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(e3, modifiers) { let keyModifiers = modifiers.filter((i3) => { return !["window", "document", "prevent", "stop", "once", "capture"].includes(i3); }); @@ -18145,17 +18145,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, (e3) => { + } : on(el, event2, modifiers, (e3) => { setValue(getInputValue(el, modifiers, e3, 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"]()); @@ -18186,31 +18186,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) { @@ -21808,12 +21808,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; @@ -21831,12 +21831,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) { @@ -22356,17 +22356,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); @@ -22376,11 +22376,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; @@ -22422,12 +22422,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) { @@ -22484,41 +22484,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; @@ -22530,37 +22530,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; @@ -22659,14 +22659,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) { @@ -22678,18 +22678,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() { @@ -22858,17 +22858,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")); } @@ -23048,12 +23048,12 @@ if (instance.props.showOnCreate && !shownOnCreate) { shownOnCreate = true; prepareInstance(instance, references[0]); } }, - onTrigger: function onTrigger2(instance, event) { - prepareInstance(instance, event.currentTarget); + onTrigger: function onTrigger2(instance, event2) { + prepareInstance(instance, event2.currentTarget); } }; } }; var singleton = tippy(div(), Object.assign({}, removeProperties(optionalProps, ["overrides"]), { @@ -23164,14 +23164,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({ @@ -23252,18 +23252,18 @@ if (!getIsInitialBehavior()) { addListener(); } } }, - onTrigger: function onTrigger2(_3, event) { - if (isMouseEvent(event)) { + onTrigger: function onTrigger2(_3, 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(); @@ -23281,12 +23281,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() { @@ -23563,12 +23563,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 }); @@ -23910,29 +23910,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 */ @@ -24078,12 +24078,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)); }, @@ -24105,12 +24105,95 @@ 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); @@ -24245,12 +24328,12 @@ function formatHex(str) { return `#${str.toUpperCase().replace("#", "")}`; } // helpers/turbo_events.js - function wasSuccessful(event) { - return getEventDetail(event).success; + function wasSuccessful(event2) { + return getEventDetail(event2).success; } function getEventDetail(obj) { return obj instanceof CustomEvent ? obj.detail : obj; } @@ -24329,16 +24412,16 @@ Array.from(inputs).forEach((el) => getData(el).onResize()); }, setLayout(layout) { this.layout = layout; }, - handleImageDrop(event) { + handleImageDrop(event2) { this.dragging = false; if (this.bgImagePicker) { - this.bgImagePicker.handleExternalDrop(event); + this.bgImagePicker.handleExternalDrop(event2); } else { - event.preventDefault(); + event2.preventDefault(); } }, async save() { this.clearErrors(); this.saving = true; @@ -24396,13 +24479,13 @@ if (file && file instanceof File) { dataTransfer.items.add(file); } input.files = dataTransfer.files; }, - handleSlideClick(event) { - if (Array.from(event.target.classList).includes("slide-text")) { - event.target.querySelector("textarea").focus(); + handleSlideClick(event2) { + if (Array.from(event2.target.classList).includes("slide-text")) { + event2.target.querySelector("textarea").focus(); } }, get blankTextAreasList() { return ["title", "text1", "text2"].map((textareaName) => this[textareaName] === "" ? textareaName : "").join(" ").trim(); }, @@ -25788,12 +25871,12 @@ y3, 0 /* Start */ ); if (result !== false) { - SECONDARY_EVENTS.forEach(function(event) { - document.addEventListener(event, this$1, { passive: false }); + SECONDARY_EVENTS.forEach(function(event2) { + document.addEventListener(event2, this$1, { passive: false }); }); } break; case "mousemove": case "touchmove": @@ -25810,12 +25893,12 @@ x3, y3, 2 /* End */ ); - SECONDARY_EVENTS.forEach(function(event) { - document.removeEventListener(event, this$1, { passive: false }); + SECONDARY_EVENTS.forEach(function(event2) { + document.removeEventListener(event2, this$1, { passive: false }); }); break; } }; return IroComponentWrapper2; @@ -26477,11 +26560,11 @@ getPicker() { return getData( this.$root.querySelector("[data-role='image-picker'").firstElementChild ); }, - handleExternalDrop(event) { - this.readFile(event.dataTransfer.files[0]); + handleExternalDrop(event2) { + this.readFile(event2.dataTransfer.files[0]); }, readFile(file) { const reader = new FileReader(); reader.addEventListener("load", () => { this.selectedImage = {