import { Dynamic } from "solid-js/web";
import { mergeProps, Show, createSignal } from "solid-js";

import config from "../base/config"


import "./select.css"

function selectOption(e) {
    console.log(e.target.getAttribute('code'))
    setActSelect(e.target.getAttribute('code'))
}

function table(props) {
    const parentProps = mergeProps(props);
    const [actSelect, setActSelect] = createSignal(0);
    // 监听parops更新
    return <div className="local_select">
        <div className="title_select">
            <i className="icon_select iconfont icon-arrow-down"></i>
            {parentProps.title}
        </div>
        <For each={parentProps.list}>
            {(li, i) => (
                <div classList={{ 'option_select': true, 'option_act_select': li.code == actSelect() }} code={li.code} onClick={selectOption} >{li.name}</div>
            )}
        </For>
    </div>
}

export default table;
