-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathGroupItem.tsx
More file actions
42 lines (36 loc) · 1.23 KB
/
GroupItem.tsx
File metadata and controls
42 lines (36 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import React from "react";
import { twMerge } from "tailwind-merge";
import Item from "./Item";
import { useSelectContext } from "./SelectProvider";
import { GroupOption } from "./type";
interface GroupItemProps {
item: GroupOption;
primaryColor: string;
}
const GroupItem: React.FC<GroupItemProps> = ({ item, primaryColor }) => {
const { classNames, formatGroupLabel } = useSelectContext();
return (
<>
{item.options.length > 0 && (
<>
{formatGroupLabel ? (
<>{formatGroupLabel(item)}</>
) : (
<div
className={twMerge(
"pr-2 py-2 cursor-default select-none truncate font-bold text-gray-700",
classNames?.listGroupLabel
)}
>
{item.label}
</div>
)}
{item.options.map((item, index) => (
<Item primaryColor={primaryColor} key={index} item={item} />
))}
</>
)}
</>
);
};
export default GroupItem;