app/assets/build/coco/book.js in coveragebook_components-0.7.1 vs app/assets/build/coco/book.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 = clamp;
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;
@@ -11472,12 +11472,29 @@
});
});
}
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 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) {
@@ -11492,11 +11509,105 @@
if (typeof str != "string")
return false;
return !isNaN(str) && // use type coercion to parse the _entirety_ of the string (`parseFloat` alone does not do this)...
!isNaN(parseFloat(str));
}
+ function roughSizeOfObject(object) {
+ const objectList = [];
+ const stack = [object];
+ let bytes = 0;
+ while (stack.length) {
+ const value = stack.pop();
+ if (typeof value === "boolean") {
+ bytes += 4;
+ } else if (typeof value === "string") {
+ bytes += value.length * 2;
+ } else if (typeof value === "number") {
+ bytes += 8;
+ } else if (typeof value === "object" && objectList.indexOf(value) === -1) {
+ objectList.push(value);
+ for (var i2 in value) {
+ stack.push(value[i2]);
+ }
+ }
+ }
+ 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 castAttributeValue(value) {
if (value === "false") {
return false;
}
@@ -11510,31 +11621,11 @@
}
function isNode(o2) {
return typeof Node === "object" ? o2 instanceof Node : o2 && typeof o2 === "object" && typeof o2.nodeType === "number" && typeof o2.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 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);
@@ -14539,11 +14630,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);
@@ -14595,11 +14686,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)
@@ -14655,22 +14757,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)
@@ -14703,11 +14794,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++;
@@ -14779,142 +14870,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;
- };
- }
-
// coco.js
function CocoComponent(name, fn3) {
const func = nameFunction(name, (...args) => {
const data2 = fn3(...args);
Object.defineProperties(data2, {
@@ -14923,41 +14904,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,
@@ -15051,11 +15011,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;
},
@@ -15105,12 +15065,10 @@
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, {