Files
NapCatQQ/.pnpm-store/v3/files/a0/b3681b58d28ac651fe416b6103d0a368d409e0162f978de28fc6f22c53dbfb9d9a203aadc0789916a017e5618485b1a81b42a67784c2ee49aa446f788d4132
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

82 lines
2.3 KiB
Plaintext

"use client";
// src/use-pagination-item.ts
import { useMemo } from "react";
import { handleLinkClick, useRouter } from "@react-aria/utils";
import { clsx, dataAttr, chain, mergeProps } from "@heroui/shared-utils";
import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
import { useHover, usePress } from "@react-aria/interactions";
import { useFocusRing } from "@react-aria/focus";
function usePaginationItem(props) {
const {
as,
ref,
value,
children,
isActive,
isDisabled,
onPress,
onClick,
getAriaLabel,
className,
...otherProps
} = props;
const isLink = !!(props == null ? void 0 : props.href);
const Component = as || isLink ? "a" : "li";
const shouldFilterDOMProps = typeof Component === "string";
const domRef = useDOMRef(ref);
const router = useRouter();
const ariaLabel = useMemo(
() => isActive ? `${getAriaLabel == null ? void 0 : getAriaLabel(value)} active` : getAriaLabel == null ? void 0 : getAriaLabel(value),
[value, isActive]
);
const { isPressed, pressProps } = usePress({
isDisabled,
onPress
});
const { focusProps, isFocused, isFocusVisible } = useFocusRing({});
const { isHovered, hoverProps } = useHover({ isDisabled });
const getItemProps = (props2 = {}) => {
return {
ref: domRef,
role: "button",
tabIndex: isDisabled ? -1 : 0,
"aria-label": ariaLabel,
"aria-current": dataAttr(isActive),
"aria-disabled": dataAttr(isDisabled),
"data-disabled": dataAttr(isDisabled),
"data-active": dataAttr(isActive),
"data-focus": dataAttr(isFocused),
"data-hover": dataAttr(isHovered),
"data-pressed": dataAttr(isPressed),
"data-focus-visible": dataAttr(isFocusVisible),
...mergeProps(
props2,
pressProps,
focusProps,
hoverProps,
filterDOMProps(otherProps, {
enabled: shouldFilterDOMProps
})
),
className: clsx(className, props2.className),
onClick: (e) => {
chain(pressProps == null ? void 0 : pressProps.onClick, onClick)(e);
handleLinkClick(e, router, props2.href, props2.routerOptions);
}
};
};
return {
Component,
children,
ariaLabel,
isFocused,
isFocusVisible,
getItemProps
};
}
export {
usePaginationItem
};