66 lines
2.3 KiB
JavaScript
66 lines
2.3 KiB
JavaScript
"use strict";
|
|
var __defProp = Object.defineProperty;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __export = (target, all) => {
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __copyProps = (to, from, except, desc) => {
|
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
for (let key of __getOwnPropNames(from))
|
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
}
|
|
return to;
|
|
};
|
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
|
|
// src/css-calc.ts
|
|
var css_calc_exports = {};
|
|
__export(css_calc_exports, {
|
|
calc: () => calc
|
|
});
|
|
module.exports = __toCommonJS(css_calc_exports);
|
|
var import_shared_utils = require("@chakra-ui/shared-utils");
|
|
function toRef(operand) {
|
|
if ((0, import_shared_utils.isObject)(operand) && operand.reference) {
|
|
return operand.reference;
|
|
}
|
|
return String(operand);
|
|
}
|
|
var toExpr = (operator, ...operands) => operands.map(toRef).join(` ${operator} `).replace(/calc/g, "");
|
|
var add = (...operands) => `calc(${toExpr("+", ...operands)})`;
|
|
var subtract = (...operands) => `calc(${toExpr("-", ...operands)})`;
|
|
var multiply = (...operands) => `calc(${toExpr("*", ...operands)})`;
|
|
var divide = (...operands) => `calc(${toExpr("/", ...operands)})`;
|
|
var negate = (x) => {
|
|
const value = toRef(x);
|
|
if (value != null && !Number.isNaN(parseFloat(value))) {
|
|
return String(value).startsWith("-") ? String(value).slice(1) : `-${value}`;
|
|
}
|
|
return multiply(value, -1);
|
|
};
|
|
var calc = Object.assign(
|
|
(x) => ({
|
|
add: (...operands) => calc(add(x, ...operands)),
|
|
subtract: (...operands) => calc(subtract(x, ...operands)),
|
|
multiply: (...operands) => calc(multiply(x, ...operands)),
|
|
divide: (...operands) => calc(divide(x, ...operands)),
|
|
negate: () => calc(negate(x)),
|
|
toString: () => x.toString()
|
|
}),
|
|
{
|
|
add,
|
|
subtract,
|
|
multiply,
|
|
divide,
|
|
negate
|
|
}
|
|
);
|
|
// Annotate the CommonJS export names for ESM import in node:
|
|
0 && (module.exports = {
|
|
calc
|
|
});
|
|
//# sourceMappingURL=css-calc.js.map
|