@knockout-js/org
Version:
Knockout组织相关组件
30 lines (29 loc) • 1.39 kB
JavaScript
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 } from "@ice/jsx-runtime/jsx-runtime";
import { Typography } from "antd";
import { useEffect, useState } from "react";
import { useDistItems } from "./";
export default ((props)=>{
var _dictItem;
const { value, dataSource, appCode, dictCode, valueKey } = props, restProps = _object_without_properties(props, [
"value",
"dataSource",
"appCode",
"dictCode",
"valueKey"
]), [items] = useDistItems(dictCode, appCode, dataSource), [dictItem, setDictItem] = useState();
useEffect(()=>{
setDictItem(items.find((item)=>item[valueKey !== null && valueKey !== void 0 ? valueKey : 'code'] === value));
}, [
value,
valueKey,
items
]);
var _dictItem_name, _ref;
return /*#__PURE__*/ _jsx(Typography.Text, _object_spread_props(_object_spread({}, restProps), {
children: (_ref = (_dictItem_name = (_dictItem = dictItem) === null || _dictItem === void 0 ? void 0 : _dictItem.name) !== null && _dictItem_name !== void 0 ? _dictItem_name : value) !== null && _ref !== void 0 ? _ref : ''
}));
});
//# sourceMappingURL=text.js.map