app/assets/build/coco/app.js in coveragebook_components-0.7.1 vs app/assets/build/coco/app.js in coveragebook_components-0.7.2

- old
+ new

@@ -4589,11 +4589,11 @@ var rand = nativeRandom(); return nativeMin(lower + rand * (upper - lower + freeParseFloat("1e-" + ((rand + "").length - 1))), upper); } return baseRandom(lower, upper); } - var camelCase6 = createCompounder(function(result2, word, index) { + var camelCase5 = createCompounder(function(result2, word, index) { word = word.toLowerCase(); return result2 + (index ? capitalize2(word) : word); }); function capitalize2(string) { return upperFirst(toString(string).toLowerCase()); @@ -4617,11 +4617,11 @@ } function escapeRegExp(string) { string = toString(string); return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar, "\\$&") : string; } - var kebabCase5 = createCompounder(function(result2, word, index) { + var kebabCase4 = createCompounder(function(result2, word, index) { return result2 + (index ? "-" : "") + word.toLowerCase(); }); var lowerCase = createCompounder(function(result2, word, index) { return result2 + (index ? " " : "") + word.toLowerCase(); }); @@ -5201,11 +5201,11 @@ lodash.extend = assignIn; lodash.extendWith = assignInWith; mixin(lodash, lodash); lodash.add = add2; lodash.attempt = attempt; - lodash.camelCase = camelCase6; + lodash.camelCase = camelCase5; lodash.capitalize = capitalize2; lodash.ceil = ceil; lodash.clamp = clamp2; lodash.clone = clone2; lodash.cloneDeep = cloneDeep; @@ -5280,11 +5280,11 @@ lodash.isTypedArray = isTypedArray; lodash.isUndefined = isUndefined; lodash.isWeakMap = isWeakMap; lodash.isWeakSet = isWeakSet; lodash.join = join; - lodash.kebabCase = kebabCase5; + lodash.kebabCase = kebabCase4; lodash.last = last; lodash.lastIndexOf = lastIndexOf; lodash.lowerCase = lowerCase; lodash.lowerFirst = lowerFirst; lodash.lt = lt2; @@ -14030,11 +14030,11 @@ // ../../../package.json var package_default = { name: "coveragebook-components", type: "module", - version: "0.7.1", + version: "0.7.2", main: "index.js", repository: "git@github.com:coveragebook/coco.git", author: "Mark Perkins <mark@coveragebook.com>", license: "NO LICENSE", browserslist: [ @@ -20062,12 +20062,40 @@ }); }); } var M2 = l2; - // libs/alpine/plugins/options.js - var import_lodash = __toESM(require_lodash(), 1); + // helpers/alpine.js + function registerComponents(components) { + document.addEventListener("alpine:init", () => { + components.forEach((module) => { + if (module.default && module.default.component === true) { + Alpine.data(module.default.name, module.default); + } + }); + }); + 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) { + const data2 = getData(el); + return data2 ? Object.assign(data2, newData) : null; + } // helpers/lang.js function nameFunction(name, body) { return { [name](...args) { @@ -20104,10 +20132,83 @@ } } return bytes; } + // libs/alpine/directives/undo.js + function undo_default(Alpine3) { + const maxHistorySize = 100; + Alpine3.directive("undo", (el, { expression }, { evaluate: evaluate2 }) => { + const data2 = getData(el); + const history = Alpine3.reactive({ + stack: [], + stackPos: -1, + adding: false, + clear() { + history.stack.length = 0; + history.stackPos = -1; + }, + add(name, newValue, oldValue) { + if (!history.adding && newValue !== oldValue) { + if (history.stackPos < history.stackSize - 1) { + const stack = Alpine3.raw(history.stack); + history.stack = stack.slice(0, history.stackPos + 1); + } + history.stack.push({ name, newValue, oldValue }); + if (history.stackSize > maxHistorySize) { + history.stack.pop(); + } else { + history.stackPos++; + } + } + }, + undo() { + if (!data2.undo) { + console.error("Missing `undo` method"); + return; + } + if (history.undoable) { + history.adding = true; + const entry = history.stack[history.stackPos]; + data2.undo(entry.name, entry.oldValue); + history.stackPos--; + this.$nextTick(() => history.adding = false); + } + }, + redo() { + if (!data2.redo) { + console.error("Missing `redo` method"); + return; + } + if (history.redoable) { + history.adding = true; + history.stackPos++; + const entry = history.stack[history.stackPos]; + data2.redo(entry.name, entry.newValue); + this.$nextTick(() => history.adding = false); + } + }, + get undoable() { + return history.stackPos >= 0; + }, + get redoable() { + return history.stackPos < history.stackSize - 1; + }, + get stackSize() { + return history.stack.length; + }, + get stackMemoryUsage() { + return roughSizeOfObject(history.stack); + } + }); + setData(el, { history }); + }); + } + + // libs/alpine/directives/options.js + var import_lodash = __toESM(require_lodash(), 1); + // helpers/dom.js function getHiddenElementDimensions(el, display = "block") { let size2; if (el.style.display === "none") { el.style.display = display; @@ -20132,42 +20233,11 @@ } function isNode(o3) { return typeof Node === "object" ? o3 instanceof Node : o3 && typeof o3 === "object" && typeof o3.nodeType === "number" && typeof o3.nodeName === "string"; } - // helpers/alpine.js - function registerComponents(components) { - document.addEventListener("alpine:init", () => { - components.forEach((module) => { - if (module.default && module.default.component === true) { - Alpine.data(module.default.name, module.default); - } - }); - }); - 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) { - const data2 = getData(el); - return data2 ? Object.assign(data2, newData) : null; - } - - // libs/alpine/plugins/options.js + // libs/alpine/directives/options.js function options_default(Alpine3) { Alpine3.directive( "options", (el, { expression }, { evaluate: evaluate2, effect: effect7, cleanup: cleanup2 }) => { const optionNames = evaluate2(expression); @@ -23335,11 +23405,11 @@ config.placement = getModifierArgument("placement"); } return config; } - // libs/alpine/plugins/tooltip.js + // libs/alpine/directives/tooltip.js function tooltip_default(Alpine3) { Alpine3.directive( "tooltip", (el, { modifiers, expression }, { evaluate: evaluate2, evaluateLater: evaluateLater2, effect: effect7 }) => { const config = tippyModifiers(modifiers); @@ -23391,11 +23461,22 @@ }); } ).before("bind"); } - // libs/alpine/plugins/dropdown.js + // libs/alpine/directives/destroy.js + function destroy_default(Alpine3) { + Alpine3.directive( + "destroy", + (el, { expression }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { + const clean2 = evaluateLater2(expression); + cleanup2(() => clean2()); + } + ); + } + + // libs/alpine/directives/dropdown.js function dropdown_default(Alpine3) { Alpine3.directive( "dropdown", (el, { value, modifiers, expression }, { evaluate: evaluate2, effect: effect7 }) => { if (value) @@ -23451,22 +23532,11 @@ } } ).before("bind"); } - // libs/alpine/plugins/destroy.js - function destroy_default(Alpine3) { - Alpine3.directive( - "destroy", - (el, { expression }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { - const clean2 = evaluateLater2(expression); - cleanup2(() => clean2()); - } - ); - } - - // libs/alpine/plugins/dimensions.js + // libs/alpine/directives/dimensions.js function dimensions_default(Alpine3) { Alpine3.directive( "dimensions", (el, { value, modifiers, expression }, { evaluateLater: evaluateLater2, cleanup: cleanup2 }) => { if (value) @@ -23499,11 +23569,11 @@ }); } ); } - // libs/alpine/plugins/notification.js + // libs/alpine/directives/notification.js function notification_default(Alpine3) { let notificationId = 0; let queuePosition = 0; Alpine3.directive("notification", (el, { expression }, { evaluate: evaluate2 }) => { notificationId++; @@ -23575,243 +23645,32 @@ evaluate2("notification.init"); }).before("init"); } // libs/alpine/index.js - module_default.plugin(module_default2); + window.Alpine = module_default; + module_default.plugin(M2); module_default.plugin(module_default5); + module_default.plugin(module_default6); + module_default.plugin(module_default2); module_default.plugin(module_default3); module_default.plugin(module_default4); - module_default.plugin(module_default6); - module_default.plugin(M2); + module_default.plugin(undo_default); module_default.plugin(options_default); module_default.plugin(tooltip_default); - module_default.plugin(dropdown_default); module_default.plugin(destroy_default); + module_default.plugin(dropdown_default); module_default.plugin(dimensions_default); module_default.plugin(notification_default); - window.Alpine = module_default; var alpine_default2 = module_default; // ../../components/coco/base/button/button.js var button_exports = {}; __export(button_exports, { default: () => button_default }); - // base/mixins/attrs.js - function withAttrs(props = {}) { - return function(component) { - return Object.assign( - component, - Alpine.reactive({ - getAttr(name) { - return this.$root.getAttribute(name); - }, - setAttr(name, value) { - this.$root.setAttribute(name, value); - return this; - }, - hasAttr(name) { - return this.$root.hasAttribute(name); - }, - removeAttr(name) { - component.$root.removeAttribute(name); - return this; - }, - assertAttr(name, testValue) { - return this.$root.getAttribute(name) === String(testValue); - }, - refuteAttr(name, testValue) { - return !this.assertAttr(name, testValue); - }, - getData(name) { - return this.getAttr(`data-${name}`); - }, - setData(name, value) { - return this.setAttr(`data-${name}`, value); - }, - hasData(name) { - return this.hasAttr(`data-${name}`); - }, - removeData(name) { - return this.removeAttr(`data-${name}`); - }, - assertData(name, testValue) { - return this.assertAttr(`data-${name}`, testValue); - }, - refuteData(name, testValue) { - return !this.assertData(name, testValue); - } - }) - ); - }; - } - - // base/mixins/options.js - var import_lodash2 = __toESM(require_lodash(), 1); - function withOptions(props = {}) { - return function(component) { - if (!component.options) { - return component; - } - const el = component.$root; - const oldDestroy = component.destroy; - const optionsProps = component.options || {}; - const optionsAttrs = Object.keys(optionsProps).map( - (name) => `data-${(0, import_lodash2.kebabCase)(name)}` - ); - Object.keys(optionsProps).forEach((name) => { - const attrName = `data-${(0, import_lodash2.kebabCase)(name)}`; - if (el.hasAttribute(attrName)) { - component.options[name] = el.getAttribute(attrName); - } - }); - let attrObserver = new MutationObserver((mutationsList) => { - for (const mutation of mutationsList) { - if (mutation.type !== "attributes" || !optionsAttrs.includes(mutation.attributeName)) { - return; - } - const propName = (0, import_lodash2.camelCase)(mutation.attributeName.replace("data-", "")); - let value = mutation.target.getAttribute(mutation.attributeName); - switch (value) { - case "true": - value = true; - break; - case "false": - value = false; - break; - } - component.options[propName] = value; - } - }); - Object.assign( - component, - Alpine.reactive({ - destroy() { - attrObserver.disconnect(); - attrObserver = null; - if (oldDestroy) { - oldDestroy.call(this); - } - } - }) - ); - attrObserver.observe(el, { attributes: true }); - component.$watch("options", (options, oldOptions) => { - for (const [key, value] of Object.entries(options)) { - el.setAttribute(`data-${(0, import_lodash2.kebabCase)(key)}`, value); - if (component.onOptionChange) { - component.onOptionChange(key, value); - } - } - }); - return component; - }; - } - - // base/mixins/size-observer.js - function withSizeObserver(props = {}) { - return function(component) { - const resizeTarget = props.target || component.$root; - const oldDestroy = component.destroy; - const sizeObserver = Alpine.reactive({ - observer: null, - handler(target) { - if (component.onResize) { - component.onResize(target.contentRect, target); - } - } - }); - sizeObserver.observer = new ResizeObserver( - (entries) => sizeObserver.handler(entries[0]) - ); - Object.assign(component, { - destroy() { - sizeObserver.observer.disconnect(); - sizeObserver.observer = null; - if (oldDestroy) { - oldDestroy.call(this); - } - } - }); - sizeObserver.observer.observe(resizeTarget); - return component; - }; - } - - // base/mixins/undo.js - function withUndo(props = {}) { - function withUndoMixin(component) { - const maxHistorySize = props.maxEntries || 100; - const history = Alpine.reactive({ - stack: [], - stackPos: -1, - adding: false, - clear() { - history.stack.length = 0; - history.stackPos = -1; - }, - add(name, newValue, oldValue) { - if (!history.adding && newValue !== oldValue) { - if (history.stackPos < history.stackSize - 1) { - const stack = Alpine.raw(history.stack); - history.stack = stack.slice(0, history.stackPos + 1); - } - history.stack.push({ name, newValue, oldValue }); - if (history.stackSize > maxHistorySize) { - history.stack.pop(); - } else { - history.stackPos++; - } - } - }, - undo() { - if (!component.undo) { - console.error("Missing `undo` method"); - return; - } - if (history.undoable) { - history.adding = true; - const entry = history.stack[history.stackPos]; - component.undo(entry.name, entry.oldValue); - history.stackPos--; - this.$nextTick(() => history.adding = false); - } - }, - redo() { - if (!component.redo) { - console.error("Missing `redo` method"); - return; - } - if (history.redoable) { - history.adding = true; - history.stackPos++; - const entry = history.stack[history.stackPos]; - component.redo(entry.name, entry.newValue); - this.$nextTick(() => history.adding = false); - } - }, - get undoable() { - return history.stackPos >= 0; - }, - get redoable() { - return history.stackPos < history.stackSize - 1; - }, - get stackSize() { - return history.stack.length; - }, - get stackMemoryUsage() { - return roughSizeOfObject(history.stack); - } - }); - return Object.assign(component, { history }); - } - withUndoMixin.props = ["history"]; - return withUndoMixin; - } - // coco.js function CocoComponent(name, fn3) { const func = nameFunction(name, (...args) => { const data2 = fn3(...args); Object.defineProperties(data2, { @@ -23820,41 +23679,20 @@ return getData(this.$root.parentElement); } } }); data2.$options = {}; - if (data2.use === false) - return data2; - const originalInit = data2.init; - const mixins = [withAttrs(), withOptions(), ...data2.use || []]; - mixins.forEach((mixin) => { - if (mixin.props) { - mixin.props.forEach((prop) => { - if (!data2[prop]) { - data2[prop] = null; - } - }); - } - }); - return Object.assign(data2, { - init() { - mixins.forEach((mixin) => mixin(this)); - if (originalInit) { - originalInit.call(this); - } - } - }); + return data2; }); func.component = true; return func; } // ../../components/coco/base/button/button.js - var import_lodash3 = __toESM(require_lodash(), 1); + var import_lodash2 = __toESM(require_lodash(), 1); var button_default = CocoComponent("button", (data2 = {}) => { return __spreadProps(__spreadValues({ - use: false, options: ["state", "confirm", "size", "disabled", "collapsible"], isCollapsed: false, approving: false, confirmed: true, lastState: null, @@ -23948,11 +23786,11 @@ set loading(value) { this.$options.state = value === true ? "loading" : "default"; }, setState(name) { this.lastState = this.state; - this.$options.state = (0, import_lodash3.camelCase)(name); + this.$options.state = (0, import_lodash2.camelCase)(name); }, resetState() { this.$options.state = this.lastState || "default"; this.lastState = this.$options.state; }, @@ -24002,13 +23840,11 @@ var dropdown_exports = {}; __export(dropdown_exports, { default: () => dropdown_default2 }); var dropdown_default2 = CocoComponent("dropdown", () => { - return { - use: false - }; + return {}; }); // ../../components/coco/base/icon/icon.js var icon_exports = {}; __export(icon_exports, { @@ -24357,13 +24193,11 @@ image2: { name: data2.image2, data: data2.image2 } }; - return __spreadProps(__spreadValues({ - use: [withUndo()] - }, initialData), { + return __spreadProps(__spreadValues({}, initialData), { saved: __spreadValues({}, initialData), saving: false, ready: false, dragging: false, errors: [], @@ -26377,11 +26211,10 @@ var iro_es_default = iro$1; // ../../components/coco/app/elements/color_picker/color_picker.js var color_picker_default = CocoComponent("appColorPicker", ({ selected }) => { return { - use: false, selectedColor: selected, display: selected, updating: false, invalid: false, colorWheel: { @@ -26498,11 +26331,10 @@ __export(image_picker_exports, { default: () => image_picker_default }); var image_picker_default = CocoComponent("appImagePicker", ({ src }) => { return { - use: [], image: { name: basename(src), file: null, data: src }, @@ -26637,11 +26469,10 @@ __export(seamless_textarea_exports, { default: () => seamless_textarea_default }); var seamless_textarea_default = CocoComponent("appSeamlessTextarea", () => { return { - use: [withSizeObserver()], height: null, observer: null, value: null, options: ["multiline", "focus"], init() { @@ -26655,14 +26486,12 @@ }); }, onResize() { const textarea = this.$refs.textarea; if (textarea) { - const styles = window.getComputedStyle(textarea); - const fontSize = styles.getPropertyValue("font-size"); textarea.style.height = "4px"; - let newHeight = textarea.scrollHeight; + const newHeight = textarea.scrollHeight; textarea.style.height = `${newHeight}px`; if (this.height !== newHeight) { this.height = newHeight; } } @@ -26675,11 +26504,10 @@ __export(snackbar_exports, { default: () => snackbar_default }); var snackbar_default = CocoComponent("appSnackbar", () => { return { - use: false, notificationType: "snackbar", options: ["show", "dismiss", "showDelay", "dismissDelay", "position"], root: { "x-options": "options", "x-notification": "notificationType", @@ -26711,10 +26539,9 @@ __export(toast_exports, { default: () => toast_default }); var toast_default = CocoComponent("appToast", () => { return { - use: false, notificationType: "toast", options: ["show", "dismiss", "showDelay", "dismissDelay", "position"], root: { "x-options": "options", "x-notification": "notificationType",