UNPKG

@knockout-js/org

Version:
52 lines (51 loc) 2.1 kB
import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; import { _ as _object_without_properties } from "@swc/helpers/_/_object_without_properties"; import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@ice/jsx-runtime/jsx-runtime"; import { ReloadOutlined } from "@ant-design/icons"; import { Select } from "antd"; import { useEffect, useState } from "react"; import styles from "./index.module.css"; import { useDistItems } from "./"; export default ((props)=>{ const { dictCode, dataSource, appCode, changeValue } = props, restProps = _object_without_properties(props, [ "dictCode", "dataSource", "appCode", "changeValue" ]), [items, itemsReload] = useDistItems(dictCode, appCode, dataSource), [loading, setLoading] = useState(false), [options, setOptions] = useState([]); useEffect(()=>{ setOptions(items.map((item)=>({ label: item.name, value: item[changeValue !== null && changeValue !== void 0 ? changeValue : 'code'], data: item }))); }, [ items ]); return /*#__PURE__*/ _jsx(Select, _object_spread_props(_object_spread({ style: { width: '100%' } }, restProps), { loading: loading, options: options, dropdownRender: (menu)=>/*#__PURE__*/ _jsxs(_Fragment, { children: [ menu, /*#__PURE__*/ _jsx("div", { className: styles.selectActions, children: /*#__PURE__*/ _jsx(ReloadOutlined, { rev: undefined, onClick: async ()=>{ setLoading(true); await itemsReload(); setLoading(false); } }) }) ] }) })); }); //# sourceMappingURL=select.js.map