import type * as React from "react"; import { listItem, type ListItemVariantProps } from "@seed-design/css/recipes/list-item"; import { Primitive, type PrimitiveProps } from "@seed-design/react-primitive"; import { forwardRef } from "react"; import { createSlotRecipeContext } from "../../utils/createSlotRecipeContext"; import { handleRadius, withStyleProps, type StyleProps } from "../../utils/styled"; import { VStack, type VStackProps } from "../Stack"; import { useCheckboxContext } from "@seed-design/react-checkbox"; import { createWithStateProps } from "../../utils/createWithStateProps"; import { useRadioGroupItemContext } from "@seed-design/react-radio-group"; import { useSwitchContext } from "@seed-design/react-switch"; const { withContext, withProvider } = createSlotRecipeContext(listItem); const withStateProps = createWithStateProps([ { useContext: useCheckboxContext, strict: false }, { useContext: useRadioGroupItemContext, strict: false }, { useContext: useSwitchContext, strict: false }, ]); export interface ListRootProps extends Omit< VStackProps, "bleed" | "bleedX" | "bleedY" | "bleedTop" | "bleedRight" | "bleedBottom" | "bleedLeft" > { itemBorderRadius?: StyleProps["borderRadius"]; } export const ListRoot = forwardRef( ({ as = "ul", style, itemBorderRadius, ...props }, ref) => { return ( } style={ { ...style, "--list-item-border-radius": handleRadius(itemBorderRadius), } as React.CSSProperties } {...props} /> ); }, ); export interface ListItemProps extends PrimitiveProps, Pick, React.HTMLAttributes, ListItemVariantProps {} export const ListItem = withProvider( withStateProps(withStyleProps(Primitive.li)), "root", ); export interface ListContentProps extends PrimitiveProps, Pick, React.HTMLAttributes {} export const ListContent = withContext( withStateProps(withStyleProps(Primitive.div)), "content", ); export interface ListPrefixProps extends PrimitiveProps, Pick, React.HTMLAttributes {} export const ListPrefix = withContext( withStateProps(withStyleProps(Primitive.div)), "prefix", ); export interface ListSuffixProps extends PrimitiveProps, Pick, React.HTMLAttributes {} export const ListSuffix = withContext( withStateProps(withStyleProps(Primitive.div)), "suffix", ); export interface ListTitleProps extends PrimitiveProps, React.HTMLAttributes {} export const ListTitle = withContext( withStateProps(Primitive.div), "title", ); export interface ListDetailProps extends PrimitiveProps, React.HTMLAttributes {} export const ListDetail = withContext( withStateProps(Primitive.div), "detail", );