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

42 lines
1.5 KiB
Plaintext

"use client";
// src/use-skeleton.ts
import { mapPropsVariants } from "@heroui/system";
import { skeleton } from "@heroui/theme";
import { clsx, dataAttr, objectToDeps } from "@heroui/shared-utils";
import { useMemo } from "react";
import { useProviderContext } from "@heroui/system";
function useSkeleton(originalProps) {
var _a, _b;
const globalContext = useProviderContext();
const [props, variantProps] = mapPropsVariants(originalProps, skeleton.variantKeys);
const { as, children, isLoaded = false, className, classNames, ...otherProps } = props;
const Component = as || "div";
const disableAnimation = (_b = (_a = originalProps.disableAnimation) != null ? _a : globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _b : false;
const slots = useMemo(
() => skeleton({
...variantProps,
disableAnimation
}),
[objectToDeps(variantProps), disableAnimation, children]
);
const baseStyles = clsx(classNames == null ? void 0 : classNames.base, className);
const getSkeletonProps = (props2 = {}) => {
return {
"data-loaded": dataAttr(isLoaded),
className: slots.base({ class: clsx(baseStyles, props2 == null ? void 0 : props2.className) }),
...otherProps
};
};
const getContentProps = (props2 = {}) => {
return {
className: slots.content({ class: clsx(classNames == null ? void 0 : classNames.content, props2 == null ? void 0 : props2.className) })
};
};
return { Component, children, slots, classNames, getSkeletonProps, getContentProps };
}
export {
useSkeleton
};