app/assets/build/coco/coco.js in coveragebook_components-0.19.0 vs app/assets/build/coco/coco.js in coveragebook_components-0.19.1

- old
+ new

@@ -7278,116 +7278,10 @@ } firstTime = false; }); return () => release(effectReference); } - function dispatch(el, name, detail = {}) { - el.dispatchEvent( - new CustomEvent(name, { - detail, - bubbles: true, - // Allows events to pass the shadow DOM barrier. - composed: true, - cancelable: true - }) - ); - } - function walk(el, callback) { - if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) { - Array.from(el.children).forEach((el2) => walk(el2, callback)); - return; - } - let skip = false; - callback(el, () => skip = true); - if (skip) - return; - let node = el.firstElementChild; - while (node) { - walk(node, callback, false); - node = node.nextElementSibling; - } - } - function warn(message, ...args) { - console.warn(`Alpine Warning: ${message}`, ...args); - } - var started = false; - function start() { - if (started) - warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."); - started = true; - if (!document.body) - warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"); - dispatch(document, "alpine:init"); - dispatch(document, "alpine:initializing"); - startObservingMutations(); - onElAdded((el) => initTree(el, walk)); - onElRemoved((el) => destroyTree(el)); - onAttributesAdded((el, attrs) => { - directives(el, attrs).forEach((handle) => handle()); - }); - let outNestedComponents = (el) => !closestRoot(el.parentElement, true); - Array.from(document.querySelectorAll(allSelectors().join(","))).filter(outNestedComponents).forEach((el) => { - initTree(el); - }); - dispatch(document, "alpine:initialized"); - } - var rootSelectorCallbacks = []; - var initSelectorCallbacks = []; - function rootSelectors() { - return rootSelectorCallbacks.map((fn) => fn()); - } - function allSelectors() { - return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn()); - } - function addRootSelector(selectorCallback) { - rootSelectorCallbacks.push(selectorCallback); - } - function addInitSelector(selectorCallback) { - initSelectorCallbacks.push(selectorCallback); - } - function closestRoot(el, includeInitSelectors = false) { - return findClosest(el, (element) => { - const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); - if (selectors.some((selector) => element.matches(selector))) - return true; - }); - } - function findClosest(el, callback) { - if (!el) - return; - if (callback(el)) - return el; - if (el._x_teleportBack) - el = el._x_teleportBack; - if (!el.parentElement) - return; - return findClosest(el.parentElement, callback); - } - function isRoot(el) { - return rootSelectors().some((selector) => el.matches(selector)); - } - var initInterceptors = []; - function interceptInit(callback) { - initInterceptors.push(callback); - } - function initTree(el, walker = walk, intercept = () => { - }) { - deferHandlingDirectives(() => { - walker(el, (el2, skip) => { - intercept(el2, skip); - initInterceptors.forEach((i2) => i2(el2, skip)); - directives(el2, el2.attributes).forEach((handle) => handle()); - el2._x_ignore && skip(); - }); - }); - } - function destroyTree(root, walker = walk) { - walker(root, (el) => { - cleanupAttributes(el); - cleanupElement(el); - }); - } var onAttributeAddeds = []; var onElRemoveds = []; var onElAddeds = []; function onElAdded(callback) { onElAddeds.push(callback); @@ -7517,11 +7411,10 @@ }); for (let node of removedNodes) { if (addedNodes.has(node)) continue; onElRemoveds.forEach((i2) => i2(node)); - destroyTree(node); } addedNodes.forEach((node) => { node._x_ignoreSelf = true; node._x_ignore = true; }); @@ -7596,22 +7489,22 @@ const target = objects.find( (obj) => Object.prototype.hasOwnProperty.call(obj, name) ) || objects[objects.length - 1]; const descriptor = Object.getOwnPropertyDescriptor(target, name); if ((descriptor == null ? void 0 : descriptor.set) && (descriptor == null ? void 0 : descriptor.get)) - return Reflect.set(target, name, value, thisProxy); + return descriptor.set.call(thisProxy, value) || true; return Reflect.set(target, name, value); } }; function collapseProxies() { let keys = Reflect.ownKeys(this); return keys.reduce((acc, key) => { acc[key] = Reflect.get(this, key); return acc; }, {}); } - function initInterceptors2(data2) { + function initInterceptors(data2) { let isObject2 = (val) => typeof val === "object" && !Array.isArray(val) && val !== null; let recurse = (obj, basePath = "") => { Object.entries(Object.getOwnPropertyDescriptors(obj)).forEach(([key, { value, enumerable }]) => { if (enumerable === false || value === void 0) return; @@ -7831,10 +7724,13 @@ const pos = directiveOrder.indexOf(directive2); directiveOrder.splice(pos >= 0 ? pos : directiveOrder.indexOf("DEFAULT"), 0, name); } }; } + function directiveExists(name) { + return Object.keys(directiveHandlers).includes(name); + } function directives(el, attributes, originalAttributeOverride) { attributes = Array.from(attributes); if (el._x_virtualDirectives) { let vAttributes = Object.entries(el._x_virtualDirectives).map(([name, value]) => ({ name, value })); let staticAttributes = attributesOnly(vAttributes); @@ -7970,10 +7866,136 @@ function byPriority(a2, b2) { let typeA = directiveOrder.indexOf(a2.type) === -1 ? DEFAULT : a2.type; let typeB = directiveOrder.indexOf(b2.type) === -1 ? DEFAULT : b2.type; return directiveOrder.indexOf(typeA) - directiveOrder.indexOf(typeB); } + function dispatch(el, name, detail = {}) { + el.dispatchEvent( + new CustomEvent(name, { + detail, + bubbles: true, + // Allows events to pass the shadow DOM barrier. + composed: true, + cancelable: true + }) + ); + } + function walk(el, callback) { + if (typeof ShadowRoot === "function" && el instanceof ShadowRoot) { + Array.from(el.children).forEach((el2) => walk(el2, callback)); + return; + } + let skip = false; + callback(el, () => skip = true); + if (skip) + return; + let node = el.firstElementChild; + while (node) { + walk(node, callback, false); + node = node.nextElementSibling; + } + } + function warn(message, ...args) { + console.warn(`Alpine Warning: ${message}`, ...args); + } + var started = false; + function start() { + if (started) + warn("Alpine has already been initialized on this page. Calling Alpine.start() more than once can cause problems."); + started = true; + if (!document.body) + warn("Unable to initialize. Trying to load Alpine before `<body>` is available. Did you forget to add `defer` in Alpine's `<script>` tag?"); + dispatch(document, "alpine:init"); + dispatch(document, "alpine:initializing"); + startObservingMutations(); + onElAdded((el) => initTree(el, walk)); + onElRemoved((el) => destroyTree(el)); + onAttributesAdded((el, attrs) => { + directives(el, attrs).forEach((handle) => handle()); + }); + let outNestedComponents = (el) => !closestRoot(el.parentElement, true); + Array.from(document.querySelectorAll(allSelectors().join(","))).filter(outNestedComponents).forEach((el) => { + initTree(el); + }); + dispatch(document, "alpine:initialized"); + setTimeout(() => { + warnAboutMissingPlugins(); + }); + } + var rootSelectorCallbacks = []; + var initSelectorCallbacks = []; + function rootSelectors() { + return rootSelectorCallbacks.map((fn) => fn()); + } + function allSelectors() { + return rootSelectorCallbacks.concat(initSelectorCallbacks).map((fn) => fn()); + } + function addRootSelector(selectorCallback) { + rootSelectorCallbacks.push(selectorCallback); + } + function addInitSelector(selectorCallback) { + initSelectorCallbacks.push(selectorCallback); + } + function closestRoot(el, includeInitSelectors = false) { + return findClosest(el, (element) => { + const selectors = includeInitSelectors ? allSelectors() : rootSelectors(); + if (selectors.some((selector) => element.matches(selector))) + return true; + }); + } + function findClosest(el, callback) { + if (!el) + return; + if (callback(el)) + return el; + if (el._x_teleportBack) + el = el._x_teleportBack; + if (!el.parentElement) + return; + return findClosest(el.parentElement, callback); + } + function isRoot(el) { + return rootSelectors().some((selector) => el.matches(selector)); + } + var initInterceptors2 = []; + function interceptInit(callback) { + initInterceptors2.push(callback); + } + function initTree(el, walker = walk, intercept = () => { + }) { + deferHandlingDirectives(() => { + walker(el, (el2, skip) => { + intercept(el2, skip); + initInterceptors2.forEach((i2) => i2(el2, skip)); + directives(el2, el2.attributes).forEach((handle) => handle()); + el2._x_ignore && skip(); + }); + }); + } + function destroyTree(root, walker = walk) { + walker(root, (el) => { + cleanupAttributes(el); + cleanupElement(el); + }); + } + function warnAboutMissingPlugins() { + let pluginDirectives = [ + ["ui", "dialog", ["[x-dialog], [x-popover]"]], + ["anchor", "anchor", ["[x-anchor]"]], + ["sort", "sort", ["[x-sort]"]] + ]; + pluginDirectives.forEach(([plugin2, directive2, selectors]) => { + if (directiveExists(directive2)) + return; + selectors.some((selector) => { + if (document.querySelector(selector)) { + warn(`found "${selector}", but missing ${plugin2} plugin`); + return true; + } + }); + }); + } var tickStack = []; var isHolding = false; function nextTick(callback = () => { }) { queueMicrotask(() => { @@ -8230,11 +8252,11 @@ nextTick2(() => { let hideAfterChildren = (el2) => { let carry = Promise.all([ el2._x_hidePromise, ...(el2._x_hideChildren || []).map(hideAfterChildren) - ]).then(([i2]) => i2()); + ]).then(([i2]) => i2 == null ? void 0 : i2()); delete el2._x_hidePromise; delete el2._x_hideChildren; return carry; }; hideAfterChildren(el).catch((e2) => { @@ -8661,11 +8683,11 @@ } stores[name] = value; if (typeof value === "object" && value !== null && value.hasOwnProperty("init") && typeof value.init === "function") { stores[name].init(); } - initInterceptors2(stores[name]); + initInterceptors(stores[name]); } function getStores() { return stores; } var binds = {}; @@ -8743,11 +8765,11 @@ return effect; }, get raw() { return raw; }, - version: "3.13.8", + version: "3.14.1", flushAndStopDeferringMutations, dontAutoEvaluateFunctions, disableEffectScheduling, startObservingMutations, stopObservingMutations, @@ -8949,12 +8971,14 @@ target2.appendChild(clone3); } }; mutateDom(() => { placeInDom(clone2, target, modifiers); - initTree(clone2); - clone2._x_ignore = true; + skipDuringClone(() => { + initTree(clone2); + clone2._x_ignore = true; + })(); }); el._x_teleportPutBack = () => { let target2 = getTarget(expression); mutateDom(() => { placeInDom(el._x_teleport, target2, modifiers); @@ -9020,14 +9044,16 @@ if (modifiers.includes("stop")) handler4 = wrapHandler(handler4, (next, e2) => { e2.stopPropagation(); next(e2); }); - if (modifiers.includes("self")) + if (modifiers.includes("once")) { handler4 = wrapHandler(handler4, (next, e2) => { - e2.target === el && next(e2); + next(e2); + listenerTarget.removeEventListener(event, handler4, options); }); + } if (modifiers.includes("away") || modifiers.includes("outside")) { listenerTarget = document; handler4 = wrapHandler(handler4, (next, e2) => { if (el.contains(e2.target)) return; @@ -9038,24 +9064,22 @@ if (el._x_isShown === false) return; next(e2); }); } - if (modifiers.includes("once")) { + if (modifiers.includes("self")) handler4 = wrapHandler(handler4, (next, e2) => { - next(e2); - listenerTarget.removeEventListener(event, handler4, options); + e2.target === el && next(e2); }); - } - handler4 = wrapHandler(handler4, (next, e2) => { - if (isKeyEvent(event)) { + if (isKeyEvent(event) || isClickEvent(event)) { + handler4 = wrapHandler(handler4, (next, e2) => { if (isListeningForASpecificKeyThatHasntBeenPressed(e2, modifiers)) { return; } - } - next(e2); - }); + next(e2); + }); + } listenerTarget.addEventListener(event, handler4, options); return () => { listenerTarget.removeEventListener(event, handler4, options); }; } @@ -9076,13 +9100,16 @@ return subject.replace(/([a-z])([A-Z])/g, "$1-$2").replace(/[_\s]/, "-").toLowerCase(); } function isKeyEvent(event) { return ["keydown", "keyup"].includes(event); } + function isClickEvent(event) { + return ["contextmenu", "click", "mouse"].some((i2) => event.includes(i2)); + } function isListeningForASpecificKeyThatHasntBeenPressed(e2, modifiers) { let keyModifiers = modifiers.filter((i2) => { - return !["window", "document", "prevent", "stop", "once", "capture"].includes(i2); + return !["window", "document", "prevent", "stop", "once", "capture", "self", "away", "outside", "passive"].includes(i2); }); if (keyModifiers.includes("debounce")) { let debounceIndex = keyModifiers.indexOf("debounce"); keyModifiers.splice(debounceIndex, isNumeric2((keyModifiers[debounceIndex + 1] || "invalid-wait").split("ms")[0]) ? 2 : 1); } @@ -9102,10 +9129,12 @@ if (modifier === "cmd" || modifier === "super") modifier = "meta"; return e2[`${modifier}Key`]; }); if (activelyPressedKeyModifiers.length === selectedSystemKeyModifiers.length) { + if (isClickEvent(e2.type)) + return false; if (keyToModifiers(e2.key).includes(keyModifiers[0])) return false; } } return true; @@ -9124,10 +9153,11 @@ "up": "arrow-up", "down": "arrow-down", "left": "arrow-left", "right": "arrow-right", "period": ".", + "comma": ",", "equal": "=", "minus": "-", "underscore": "_" }; modifierToKeyMap[key] = key; @@ -9178,11 +9208,11 @@ let removeListener = isCloning ? () => { } : on(el, event, modifiers, (e2) => { setValue(getInputValue(el, modifiers, e2, getValue())); }); if (modifiers.includes("fill")) { - if ([void 0, null, ""].includes(getValue()) || el.type === "checkbox" && Array.isArray(getValue())) { + if ([void 0, null, ""].includes(getValue()) || el.type === "checkbox" && Array.isArray(getValue()) || el.tagName.toLowerCase() === "select" && el.multiple) { setValue( getInputValue(el, modifiers, { target: el }, getValue()) ); } } @@ -9190,11 +9220,11 @@ el._x_removeModelListeners = {}; el._x_removeModelListeners["default"] = removeListener; cleanup(() => el._x_removeModelListeners["default"]()); if (el.form) { let removeResetListener = on(el.form, "reset", [], (e2) => { - nextTick(() => el._x_model && el._x_model.set(el.value)); + nextTick(() => el._x_model && el._x_model.set(getInputValue(el, modifiers, { target: el }, getValue()))); }); cleanup(() => removeResetListener()); } el._x_model = { get() { @@ -9230,11 +9260,11 @@ } else if (modifiers.includes("boolean")) { newValue = safeParseBoolean(event.target.value); } else { newValue = event.target.value; } - return event.target.checked ? currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); + return event.target.checked ? currentValue.includes(newValue) ? currentValue : currentValue.concat([newValue]) : currentValue.filter((el2) => !checkedAttrLooseCompare2(el2, newValue)); } else { return event.target.checked; } } else if (el.tagName.toLowerCase() === "select" && el.multiple) { if (modifiers.includes("number")) { @@ -9369,11 +9399,11 @@ let data2 = evaluate(el, expression, { scope: dataProviderContext }); if (data2 === void 0 || data2 === true) data2 = {}; injectMagics(data2, el); let reactiveData = reactive(data2); - initInterceptors2(reactiveData); + initInterceptors(reactiveData); let undo = addScopeToNode(el, reactiveData); reactiveData["init"] && evaluate(el, reactiveData["init"]); cleanup(() => { reactiveData["destroy"] && evaluate(el, reactiveData["destroy"]); undo(); @@ -15294,11 +15324,11 @@ var alpine_default = import_alpinejs.default; // ../../../package.json var package_default = { name: "coveragebook-components", - version: "0.19.0", + version: "0.19.1", repository: "git@github.com:coveragebook/coco.git", license: "NO LICENSE", author: "Mark Perkins <mark@coveragebook.com>", main: "app/assets/build/coco/coco.js", engines: { @@ -15309,13 +15339,14 @@ "build:tailwind-preset": "esbuild ./config/tailwind.preset.js --bundle --format=cjs --outdir=./app/assets/build/coco --log-level=error", "build:dev": "npm run js:dev && npm run css:dev", "css:build": "postcss ./app/assets/css/coco.css -d ./app/assets/build/coco", "css:dev": "postcss ./app/assets/css/coco.css -d ./app/assets/build/coco/dev", "css:watch": "postcss ./app/assets/css/coco.css -d ./app/assets/build/coco/dev --watch", - "js:build": "node esbuild.config.mjs", - "js:dev": "node esbuild.config.mjs --dev", - "js:watch": "node esbuild.config.mjs --watch", + "js:build": "node esbuild.mjs", + "js:dev": "node esbuild.mjs --dev", + "js:watch": "node esbuild.mjs --watch", + "js:analyse": "node lib/scripts/esbuild-meta.mjs", "lint:fix": "bundle exec standardrb --fix && prettier --write .", "lookbook:build": "cd lookbook && npm run build", prepare: "husky install", release: "release-it" }, @@ -15336,18 +15367,18 @@ tabWidth: 2, trailingComma: "es5" }, dependencies: { "@alpinejs/focus": "^3.13.2", - "@alpinejs/mask": "^3.13.5", + "@alpinejs/mask": "^3.14.1", "@alpinejs/morph": "^3.13.5", "@jaames/iro": "^5.5.2", "@percy/cli": "^1.28.8", "@tailwindcss/container-queries": "^0.1.0", "@tailwindcss/forms": "^0.5.6", "alias-hq": "^6.2.2", - alpinejs: "^3.13.8", + alpinejs: "^3.14.1", autoprefixer: "^10.4.16", "container-query-polyfill": "^1.0.2", del: "^7.1.0", esbuild: "^0.23.0", "esbuild-plugin-copy": "^2.0.2", @@ -15362,10 +15393,10 @@ "lodash.mapvalues": "^4.6.0", "lucide-static": "^0.303.0", postcss: "^8.4.38", "postcss-cli": "^11.0.0", "postcss-value-parser": "^4.2.0", - prettier: "^3.2.5", + prettier: "^3.3.3", "release-it": "^17.2.1", svgo: "^3.0.2", tailwindcss: "^3.4.3", "tippy.js": "^6.3.7" },