UNPKG

react-admin-kit

Version:

A react based UI components for admin system

58 lines (56 loc) 1.84 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 BaseTreeSelect from "./BaseTreeSelect"; import { jsx as _jsx } from "react/jsx-runtime"; /** * 数据挂在window上作为缓存, 避免重复请求 */ export var CacheName = '@@treeSelectData'; export var CacheStatusName = '@@treeSelectDataIsStart'; function BusinessTreeSelectBuilder(_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' } }); return /*#__PURE__*/_jsx(BaseTreeSelect, _objectSpread(_objectSpread({ type: type }, mergedProps), {}, { loadFunction: target.api }, rest)); }; } export default BusinessTreeSelectBuilder; export var clearTreeSelectCache = function clearTreeSelectCache(type) { if (type) { delGlobal(CacheName, type); delGlobal(CacheStatusName, type); } else { delGlobal(CacheName); delGlobal(CacheStatusName); } }; // 用于生成api文档 /* istanbul ignore next */ export var BizTreeApi = function BizTreeApi() { return null; }; // 用于生成api文档 /* istanbul ignore next */ export var BusinessTreeSelectSelf = function BusinessTreeSelectSelf() { return null; };