@antdv/pro-utils
Version:
@antdv/pro-utils
138 lines (137 loc) • 4.52 kB
JavaScript
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);
var stdin_exports = {};
__export(stdin_exports, {
isArray: () => isArray,
isBrowser: () => isBrowser,
isComment: () => isComment,
isEmptyContent: () => isEmptyContent,
isEmptyElement: () => isEmptyElement,
isEmptySlot: () => isEmptySlot,
isFragment: () => isFragment,
isFunction: () => isFunction,
isImg: () => isImg,
isNil: () => isNil,
isNumeric: () => isNumeric,
isObject: () => isObject,
isString: () => isString,
isStringElement: () => isStringElement,
isSymbol: () => isSymbol,
isTemplate: () => isTemplate,
isText: () => isText,
isUrl: () => isUrl,
isValid: () => isValid,
isValidElement: () => isValidElement,
isValidElementNode: () => isValidElementNode,
isValidValue: () => isValidValue,
isVisible: () => isVisible,
isWindow: () => isWindow
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
function isNumeric(value) {
return !Number.isNaN(Number.parseFloat(value)) && Number.isFinite(value);
}
function isNil(value) {
return value === null || value === void 0;
}
function isValidValue(val) {
return val !== void 0 && val !== null;
}
function isValid(value) {
return value !== void 0 && value !== null && value !== "";
}
function isWindow(obj) {
return obj !== null && obj !== void 0 && obj === obj.window;
}
function isFunction(value) {
return typeof value === "function";
}
const isArray = Array.isArray;
const isString = (val) => typeof val === "string";
const isSymbol = (val) => typeof val === "symbol";
const isObject = (val) => val !== null && typeof val === "object";
function isFragment(node) {
return (0, import_vue.isVNode)(node) && node.type === import_vue.Fragment;
}
function isText(node) {
return (0, import_vue.isVNode)(node) && node.type === import_vue.Text;
}
function isComment(node) {
return (0, import_vue.isVNode)(node) && node.type === import_vue.Comment;
}
const TEMPLATE = "template";
function isTemplate(node) {
return (0, import_vue.isVNode)(node) && node.type === TEMPLATE;
}
function isValidElementNode(node) {
return (0, import_vue.isVNode)(node) && !isFragment(node) && !isComment(node);
}
function isEmptyContent(c) {
return c === void 0 || c === null || c === "" || Array.isArray(c) && c.length === 0;
}
function isEmptyElement(c) {
return c && (c.type === import_vue.Comment || c.type === import_vue.Fragment && c.children.length === 0 || c.type === import_vue.Text && c.children.trim() === "");
}
function isEmptySlot(c) {
return !c || c().every(isEmptyElement);
}
function isStringElement(c) {
return c && c.type === import_vue.Text;
}
function isValidElement(element) {
if (Array.isArray(element) && element.length === 1)
element = element[0];
return element && element.__v_isVNode && typeof element.type !== "symbol";
}
function isVisible(element) {
if (!element)
return false;
if (element.offsetParent)
return true;
if (element.getBBox) {
const box = element.getBBox();
if (box.width || box.height)
return true;
}
if (element.getBoundingClientRect) {
const box = element.getBoundingClientRect();
if (box.width || box.height)
return true;
}
return false;
}
function isImg(path) {
return /\w.(png|jpg|jpeg|svg|webp|gif|bmp)$/i.test(path);
}
function isUrl(path) {
if (!path) return false;
if (!path.startsWith("http")) {
return false;
}
try {
const url = new URL(path);
return !!url;
} catch (error) {
return false;
}
}
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
function isBrowser() {
return typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.matchMedia !== "undefined" && !isNode;
}