This commit is contained in:
2026-05-25 17:08:18 +08:00
parent df501f6151
commit f1259b71b5
9178 changed files with 1626125 additions and 0 deletions
@@ -0,0 +1,32 @@
export function toArray(value) {
if (Array.isArray(value)) {
return value;
}
return value !== undefined ? [value] : [];
}
export const isClient = typeof window !== 'undefined' && window.document && window.document.documentElement;
/** Is client side and not jsdom */
export const isBrowserClient = process.env.NODE_ENV !== 'test' && isClient;
export function hasValue(value) {
return value !== undefined && value !== null;
}
/** combo mode no value judgment function */
export function isComboNoValue(value) {
return !value && value !== 0;
}
function isTitleType(title) {
return ['string', 'number'].includes(typeof title);
}
export function getTitle(item) {
let title = undefined;
if (item) {
if (isTitleType(item.title)) {
title = item.title.toString();
} else if (isTitleType(item.label)) {
title = item.label.toString();
}
}
return title;
}