Files
wdi-dashboard/node_modules/@chakra-ui/theme-tools/dist/css-var.js
2024-08-16 15:06:52 +05:30

71 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-var.ts
var css_var_exports = {};
__export(css_var_exports, {
addPrefix: () => addPrefix,
cssVar: () => cssVar,
isDecimal: () => isDecimal,
toVar: () => toVar,
toVarRef: () => toVarRef
});
module.exports = __toCommonJS(css_var_exports);
function isDecimal(value) {
return !Number.isInteger(parseFloat(value.toString()));
}
function replaceWhiteSpace(value, replaceValue = "-") {
return value.replace(/\s+/g, replaceValue);
}
function escape(value) {
const valueStr = replaceWhiteSpace(value.toString());
if (valueStr.includes("\\."))
return value;
return isDecimal(value) ? valueStr.replace(".", `\\.`) : value;
}
function addPrefix(value, prefix = "") {
return [prefix, escape(value)].filter(Boolean).join("-");
}
function toVarRef(name, fallback) {
return `var(${escape(name)}${fallback ? `, ${fallback}` : ""})`;
}
function toVar(value, prefix = "") {
return `--${addPrefix(value, prefix)}`;
}
function cssVar(name, options) {
const cssVariable = toVar(name, options == null ? void 0 : options.prefix);
return {
variable: cssVariable,
reference: toVarRef(cssVariable, getFallback(options == null ? void 0 : options.fallback))
};
}
function getFallback(fallback) {
if (typeof fallback === "string")
return fallback;
return fallback == null ? void 0 : fallback.reference;
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
addPrefix,
cssVar,
isDecimal,
toVar,
toVarRef
});
//# sourceMappingURL=css-var.js.map