import { createContext, useContext } from "solid-js"; import createModel from "../utils/createModel"; import { useClassList } from "../utils/useProps"; import { Item } from "./Item"; type ListProps = { classList?: any, class?: string, border?: boolean, size?: 'small'|'large', style?: any, head?: any, foot?: any, children?: any, render?: Function, onSelect?: Function } export type ListContextProps = { render?: Function, signal: Function[], onSelect?: Function } const ListContext = createContext(); export function List (props: ListProps) { const classList = () => useClassList(props, 'cm-list', { 'cm-list-border': props.border, [`cm-list-${props.size}`]: props.size }); const [activeKey, setActiveKey] = createModel(props, 'activeKey', ''); return
{ props.head ?
{props.head}
: null } {props.children} { props.foot ?
{props.foot}
: null }
; } List.Item = Item; export const useListContext: ()=> ListContextProps|undefined = () => useContext(ListContext);