UNPKG

@knockout-js/org

Version:
33 lines (32 loc) 1.7 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 { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; import { jsx as _jsx } from "@ice/jsx-runtime/jsx-runtime"; import { Typography } from "antd"; import { useEffect, useState } from "react"; import { useDistItems } from "./"; export default function(props) { var _dictItem; var value = props.value, dataSource = props.dataSource, appCode = props.appCode, dictCode = props.dictCode, valueKey = props.valueKey, restProps = _object_without_properties(props, [ "value", "dataSource", "appCode", "dictCode", "valueKey" ]), _useDistItems = _sliced_to_array(useDistItems(dictCode, appCode, dataSource), 1), items = _useDistItems[0], _useState = _sliced_to_array(useState(), 2), dictItem = _useState[0], setDictItem = _useState[1]; useEffect(function() { setDictItem(items.find(function(item) { return 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