Files
NapCatQQ/.pnpm-store/v3/files/a6/80460cd9901cf5d5c8f44dcca7efca27af2776d9e9b65438c71de446d7bcd92bd77f6aa52a2d4cc13bb41e80e7d10a7d15bf2bf2860f59cf6be9c6725f0abd
T
TanTan e311ca3275
Build NapCat Artifacts / Type Check & Test (push) Waiting to run
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

64 lines
1.8 KiB
Plaintext

// src/utils.ts
import { forwardRef as baseForwardRef } from "react";
function forwardRef(component) {
return baseForwardRef(component);
}
var toIterator = (obj) => {
return {
...obj,
[Symbol.iterator]: function() {
const keys = Object.keys(this);
let index = 0;
return {
next: () => {
if (index >= keys.length) {
return { done: true };
}
const key = keys[index];
const value = this[key];
index++;
return { value: { key, value }, done: false };
}
};
}
};
};
var mapPropsVariants = (props, variantKeys, removeVariantProps = true) => {
if (!variantKeys) {
return [props, {}];
}
const picked = variantKeys.reduce((acc, key) => {
if (key in props) {
return { ...acc, [key]: props[key] };
} else {
return acc;
}
}, {});
if (removeVariantProps) {
const omitted = Object.keys(props).filter((key) => !variantKeys.includes(key)).reduce((acc, key) => ({ ...acc, [key]: props[key] }), {});
return [omitted, picked];
} else {
return [props, picked];
}
};
var mapPropsVariantsWithCommon = (originalProps, variantKeys, commonKeys) => {
const props = Object.keys(originalProps).filter((key) => !variantKeys.includes(key) || (commonKeys == null ? void 0 : commonKeys.includes(key))).reduce((acc, key) => ({ ...acc, [key]: originalProps[key] }), {});
const variants = variantKeys.reduce(
(acc, key) => ({ ...acc, [key]: originalProps[key] }),
{}
);
return [props, variants];
};
var isHeroUIEl = (component) => {
var _a, _b, _c;
return !!((_c = (_b = (_a = component.type) == null ? void 0 : _a.render) == null ? void 0 : _b.displayName) == null ? void 0 : _c.includes("HeroUI"));
};
export {
forwardRef,
toIterator,
mapPropsVariants,
mapPropsVariantsWithCommon,
isHeroUIEl
};