UNPKG

react-admin-kit

Version:

A react based UI components for admin system

72 lines (70 loc) 2.34 kB
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2"; import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties"; var _excluded = ["type"]; import { delGlobal, myMergeOptions } from "../utils"; import BasePaginationSelect from "./components/BasePaginationSelect"; import BaseSelect from "./components/BaseSelect"; import { jsx as _jsx } from "react/jsx-runtime"; /** * select数据挂在window上作为缓存, 避免重复请求 */ export var SelectName = '@@selectData'; export var SelectStatusName = '@@selectDataIsStart'; export var SelectTotalName = '@@selectDataTotal'; export var SelectCurrentName = '@@selectDataCurrent'; function BusinessSelectBuilder(_ref) { var _ref$apis = _ref.apis, apis = _ref$apis === void 0 ? [] : _ref$apis, _ref$defaultProps = _ref.defaultProps, defaultProps = _ref$defaultProps === void 0 ? {} : _ref$defaultProps; return function (props) { var type = props.type, rest = _objectWithoutProperties(props, _excluded); var target = apis.find(function (item) { return item.type === type; }); if (!target) return null; var mergedProps = myMergeOptions(defaultProps, target.defaultProps || {}, { fieldNames: { value: 'id', label: 'name' } }); if (target.pagination) { return /*#__PURE__*/_jsx(BasePaginationSelect, _objectSpread(_objectSpread({ type: type }, mergedProps), {}, { loadFunction: target.api }, rest)); } return /*#__PURE__*/_jsx(BaseSelect, _objectSpread(_objectSpread({ type: type }, mergedProps), {}, { loadFunction: target.api }, rest)); }; } export default BusinessSelectBuilder; export var clearSelectCache = function clearSelectCache(type) { if (type) { delGlobal(SelectName, type); delGlobal(SelectStatusName, type); delGlobal(SelectTotalName, type); delGlobal(SelectCurrentName, type); } else { delGlobal(SelectName); delGlobal(SelectStatusName); delGlobal(SelectTotalName); delGlobal(SelectCurrentName); } }; // 用于生成api文档 /* istanbul ignore next */ export var BizApi = function BizApi() { return null; }; // 用于生成api文档 /* istanbul ignore next */ export var BusinessSelectSelf = function BusinessSelectSelf() { return null; };