ingenious-flow-designer
Version:
[演示地址](http://antd-vben5-pro.madong.tech/)
74 lines (73 loc) • 2.1 kB
JavaScript
import { j as isNumber, x as isStringNumber, c as isString, f as debugWarn, h as isClient, y as camelize, z as buildProp } from "./install-DW2-zxb6.js";
import { inject, computed, unref } from "vue";
const SCOPE = "utils/dom/style";
const classNameToArray = (cls = "") => cls.split(" ").filter((item) => !!item.trim());
const hasClass = (el, cls) => {
if (!el || !cls)
return false;
if (cls.includes(" "))
throw new Error("className should not contain space.");
return el.classList.contains(cls);
};
const addClass = (el, cls) => {
if (!el || !cls.trim())
return;
el.classList.add(...classNameToArray(cls));
};
const removeClass = (el, cls) => {
if (!el || !cls.trim())
return;
el.classList.remove(...classNameToArray(cls));
};
const getStyle = (element, styleName) => {
var _a;
if (!isClient || !element || !styleName)
return "";
let key = camelize(styleName);
if (key === "float")
key = "cssFloat";
try {
const style = element.style[key];
if (style)
return style;
const computed2 = (_a = document.defaultView) == null ? void 0 : _a.getComputedStyle(element, "");
return computed2 ? computed2[key] : "";
} catch (e) {
return element.style[key];
}
};
function addUnit(value, defaultUnit = "px") {
if (!value)
return "";
if (isNumber(value) || isStringNumber(value)) {
return `${value}${defaultUnit}`;
} else if (isString(value)) {
return value;
}
debugWarn(SCOPE, "binding value must be a string or number");
}
const componentSizes = ["", "default", "small", "large"];
const useSizeProp = buildProp({
type: String,
values: componentSizes,
required: false
});
const SIZE_INJECTION_KEY = Symbol("size");
const useGlobalSize = () => {
const injectedSize = inject(SIZE_INJECTION_KEY, {});
return computed(() => {
return unref(injectedSize.size) || "";
});
};
export {
SIZE_INJECTION_KEY as S,
addUnit as a,
useGlobalSize as b,
componentSizes as c,
addClass as d,
getStyle as g,
hasClass as h,
removeClass as r,
useSizeProp as u
};
//# sourceMappingURL=index-Bg0OtIyq.js.map