@knockout-js/org
Version:
Knockout组织相关组件
72 lines (71 loc) • 3.4 kB
JavaScript
import { _ as _async_to_generator } from "@swc/helpers/_/_async_to_generator";
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 { _ as _ts_generator } from "@swc/helpers/_/_ts_generator";
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 function(props) {
var dictCode = props.dictCode, dataSource = props.dataSource, appCode = props.appCode, changeValue = props.changeValue, restProps = _object_without_properties(props, [
"dictCode",
"dataSource",
"appCode",
"changeValue"
]), _useDistItems = _sliced_to_array(useDistItems(dictCode, appCode, dataSource), 2), items = _useDistItems[0], itemsReload = _useDistItems[1], _useState = _sliced_to_array(useState(false), 2), loading = _useState[0], setLoading = _useState[1], _useState1 = _sliced_to_array(useState([]), 2), options = _useState1[0], setOptions = _useState1[1];
useEffect(function() {
setOptions(items.map(function(item) {
return {
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: function(menu) {
return /*#__PURE__*/ _jsxs(_Fragment, {
children: [
menu,
/*#__PURE__*/ _jsx("div", {
className: styles.selectActions,
children: /*#__PURE__*/ _jsx(ReloadOutlined, {
rev: undefined,
onClick: /*#__PURE__*/ _async_to_generator(function() {
return _ts_generator(this, function(_state) {
switch(_state.label){
case 0:
setLoading(true);
return [
4,
itemsReload()
];
case 1:
_state.sent();
setLoading(false);
return [
2
];
}
});
})
})
})
]
});
}
}));
};
//# sourceMappingURL=select.js.map