@clayui/drop-down
Version:
ClayDropDown component
39 lines (38 loc) • 1.07 kB
JavaScript
import { __NOT_PUBLIC_COLLECTION } from "@clayui/core";
import classnames from "classnames";
import React, { useCallback, useContext } from "react";
import { DropDownContext } from "./DropDownContext";
const { Collection } = __NOT_PUBLIC_COLLECTION;
const ItemList = React.forwardRef(
({ children, className, items, role = "menu", ...otherProps }, ref) => {
const { search } = useContext(DropDownContext);
const filterFn = useCallback(
(value) => value.match(new RegExp(search, "i")) !== null,
[search]
);
return /* @__PURE__ */ React.createElement(
"ul",
{
...otherProps,
className: classnames("list-unstyled", className),
ref,
role
},
/* @__PURE__ */ React.createElement(
Collection,
{
filter: filterFn,
filterKey: "textValue",
items,
passthroughKey: false
},
children
)
);
}
);
ItemList.displayName = "ClayDropDownItemList";
var ItemList_default = ItemList;
export {
ItemList_default as default
};