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

34 lines
1.1 KiB
Plaintext

// src/use-spinner.ts
import { mapPropsVariants } from "@heroui/system-rsc";
import { spinner } from "@heroui/theme";
import { clsx, objectToDeps } from "@heroui/shared-utils";
import { useMemo, useCallback } from "react";
function useSpinner(originalProps) {
const [props, variantProps] = mapPropsVariants(originalProps, spinner.variantKeys);
const { children, className, classNames, label: labelProp, ...otherProps } = props;
const slots = useMemo(() => spinner({ ...variantProps }), [objectToDeps(variantProps)]);
const baseStyles = clsx(classNames == null ? void 0 : classNames.base, className);
const label = labelProp || children;
const ariaLabel = useMemo(() => {
if (label && typeof label === "string") {
return label;
}
return !otherProps["aria-label"] ? "Loading" : "";
}, [children, label, otherProps["aria-label"]]);
const getSpinnerProps = useCallback(
() => ({
"aria-label": ariaLabel,
className: slots.base({
class: baseStyles
}),
...otherProps
}),
[ariaLabel, slots, baseStyles, otherProps]
);
return { label, slots, classNames, getSpinnerProps };
}
export {
useSpinner
};