Files
NapCatQQ/.pnpm-store/v3/files/58/cad9f3f60903e1fa112377777d039c4ff4d56ec9d95fcb5e3cb842ac995d1a0d5e12c2bcc9e24895562ad1c44157e1e4467cdbf85eb5161cc9a99828f09368
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

95 lines
2.5 KiB
Plaintext

"use client";
// src/use-listbox.ts
import { useListBox as useAriaListbox } from "@react-aria/listbox";
import { useProviderContext } from "@heroui/system";
import { listbox } from "@heroui/theme";
import { useListState } from "@react-stately/list";
import { filterDOMProps, useDOMRef } from "@heroui/react-utils";
import { useMemo } from "react";
import { clsx } from "@heroui/shared-utils";
function useListbox(props) {
var _a;
const globalContext = useProviderContext();
const {
ref,
as,
state: propState,
variant,
color,
onAction,
children,
onSelectionChange,
disableAnimation = (_a = globalContext == null ? void 0 : globalContext.disableAnimation) != null ? _a : false,
itemClasses,
className,
topContent,
bottomContent,
emptyContent = "No items.",
hideSelectedIcon = false,
hideEmptyContent = false,
shouldHighlightOnFocus = false,
classNames,
...otherProps
} = props;
const Component = as || "ul";
const shouldFilterDOMProps = typeof Component === "string";
const domRef = useDOMRef(ref);
const innerState = useListState({ ...props, children, onSelectionChange });
const state = propState || innerState;
const { listBoxProps } = useAriaListbox({ ...props, onAction }, state, domRef);
const slots = useMemo(() => listbox({ className }), [className]);
const baseStyles = clsx(classNames == null ? void 0 : classNames.base, className);
const getBaseProps = (props2 = {}) => {
return {
ref: domRef,
"data-slot": "base",
className: slots.base({ class: baseStyles }),
...filterDOMProps(otherProps, {
enabled: shouldFilterDOMProps
}),
...props2
};
};
const getListProps = (props2 = {}) => {
return {
"data-slot": "list",
className: slots.list({ class: classNames == null ? void 0 : classNames.list }),
...listBoxProps,
...props2
};
};
const getEmptyContentProps = (props2 = {}) => {
return {
"data-slot": "empty-content",
children: emptyContent,
className: slots.emptyContent({ class: classNames == null ? void 0 : classNames.emptyContent }),
...props2
};
};
return {
Component,
state,
variant,
color,
slots,
classNames,
topContent,
bottomContent,
emptyContent,
hideEmptyContent,
shouldHighlightOnFocus,
hideSelectedIcon,
disableAnimation,
className,
itemClasses,
getBaseProps,
getListProps,
getEmptyContentProps
};
}
export {
useListbox
};