@pointcloud/pcloud-components 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,35 +1,23 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  var _excluded = ["className", "popupClassName", "fieldNames", "options", "onChange", "loadData", "onLoadData", "loading"];
2
-
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
4
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
4
-
5
5
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
-
7
6
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
-
9
7
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
-
11
8
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
-
13
9
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
14
-
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
-
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
17
13
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
18
-
19
14
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
-
21
15
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
-
23
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
24
-
25
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
26
-
16
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
17
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
27
18
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
28
-
29
19
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
30
-
31
20
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
32
-
33
21
  /*
34
22
  * @Author : wangfeihu
35
23
  * @Date : 2023-05-18 13:35:38
@@ -41,70 +29,57 @@ import React, { useRef, forwardRef, useState, useEffect, useMemo, useContext } f
41
29
  import { Cascader } from 'antd';
42
30
  import { ConfigContext } from "../ConfigProvider";
43
31
  import "./index.less";
32
+
44
33
  /**
45
34
  *
46
35
  * 如何只显示选中的子节点
47
36
  */
48
37
 
49
- import { jsx as _jsx } from "react/jsx-runtime";
50
-
51
38
  function InternalCascader(props, ref) {
52
39
  var _props$className = props.className,
53
- className = _props$className === void 0 ? '' : _props$className,
54
- _props$popupClassName = props.popupClassName,
55
- popupClassName = _props$popupClassName === void 0 ? '' : _props$popupClassName,
56
- fieldNames = props.fieldNames,
57
- initOptions = props.options,
58
- onChange = props.onChange,
59
- loadData = props.loadData,
60
- onLoadData = props.onLoadData,
61
- initLoading = props.loading,
62
- otherProps = _objectWithoutProperties(props, _excluded);
63
-
40
+ className = _props$className === void 0 ? '' : _props$className,
41
+ _props$popupClassName = props.popupClassName,
42
+ popupClassName = _props$popupClassName === void 0 ? '' : _props$popupClassName,
43
+ fieldNames = props.fieldNames,
44
+ initOptions = props.options,
45
+ onChange = props.onChange,
46
+ loadData = props.loadData,
47
+ onLoadData = props.onLoadData,
48
+ initLoading = props.loading,
49
+ otherProps = _objectWithoutProperties(props, _excluded);
64
50
  var _useContext = useContext(ConfigContext),
65
- getPrefixCls = _useContext.getPrefixCls;
66
-
51
+ getPrefixCls = _useContext.getPrefixCls;
67
52
  var _useState = useState([]),
68
- _useState2 = _slicedToArray(_useState, 2),
69
- options = _useState2[0],
70
- setOptions = _useState2[1];
71
-
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ options = _useState2[0],
55
+ setOptions = _useState2[1];
72
56
  var _useState3 = useState(typeof initLoading === 'boolean' ? initLoading : true),
73
- _useState4 = _slicedToArray(_useState3, 2),
74
- loading = _useState4[0],
75
- setLoading = _useState4[1];
76
-
57
+ _useState4 = _slicedToArray(_useState3, 2),
58
+ loading = _useState4[0],
59
+ setLoading = _useState4[1];
77
60
  var loadingParamsRef = useRef(null); // 数据加载同步处理引用
78
-
79
61
  var loadingRef = useRef({
80
62
  timer: null,
81
63
  status: 'done'
82
64
  }); // options加载状态引用
83
-
84
65
  var timestamp = new Date().getTime();
85
-
86
66
  var _className = "".concat(getPrefixCls('cascader'), " d-cascader-").concat(timestamp, " ").concat(className);
87
-
88
67
  var _popupClassName = "".concat(getPrefixCls('cascader-dropdown'), " d-cascader-dropdown-").concat(timestamp, " ").concat(popupClassName);
89
-
90
68
  var _fieldNames = _objectSpread({
91
69
  label: 'label',
92
70
  value: 'value',
93
71
  children: 'children'
94
72
  }, fieldNames);
95
-
96
73
  var _loadingState = getDelayTime(loading, 600); // loading: 默认600ms,false或0表示不开启
97
74
 
75
+ var _loading = typeof initLoading === 'boolean' ? initLoading : loading;
98
76
 
99
- var _loading = typeof initLoading === 'boolean' ? initLoading : loading; // 将外部传入的options转化为统一的异步请求方法
100
-
101
-
77
+ // 将外部传入的options转化为统一的异步请求方法
102
78
  var getOptionsFun = useMemo(function () {
103
79
  return typeof initOptions === 'function' ? initOptions : function () {
104
80
  return Promise.resolve(initOptions || []);
105
81
  };
106
82
  }, [initOptions]);
107
-
108
83
  var updateOptions = function updateOptions(fun, value) {
109
84
  // 设置加载中状态
110
85
  if (_loadingState > 0) {
@@ -113,9 +88,8 @@ function InternalCascader(props, ref) {
113
88
  loadingRef.current.timer = setTimeout(function () {
114
89
  loadingRef.current.status === 'loading' && setLoading(true);
115
90
  }, _loadingState);
116
- } // 发起请求
117
-
118
-
91
+ }
92
+ // 发起请求
119
93
  loadingParamsRef.current = value;
120
94
  fun === null || fun === void 0 ? void 0 : fun(value).then(function (response) {
121
95
  if (loadingParamsRef.current === value) {
@@ -130,15 +104,11 @@ function InternalCascader(props, ref) {
130
104
  }
131
105
  });
132
106
  };
133
-
134
107
  var _loadData = function _loadData(selectedOptions) {
135
108
  var targetOption = selectedOptions[selectedOptions.length - 1];
136
109
  onLoadData && onLoadData(targetOption[_fieldNames.value], targetOption, selectedOptions);
137
-
138
110
  var _getOptions = typeof initOptions === 'function' ? initOptions : null;
139
-
140
111
  var loadFn = loadData === null ? loadData : loadData || _getOptions;
141
-
142
112
  if (typeof loadFn === 'function') {
143
113
  loadFn === null || loadFn === void 0 ? void 0 : loadFn(targetOption[_fieldNames.value], targetOption, selectedOptions).then(function (response) {
144
114
  targetOption[_fieldNames.children] = response;
@@ -150,31 +120,28 @@ function InternalCascader(props, ref) {
150
120
  });
151
121
  }
152
122
  };
153
-
154
123
  var _onChange = function _onChange(value, selectedOptions) {
155
124
  return onChange === null || onChange === void 0 ? void 0 : onChange(value, selectedOptions);
156
- }; // 初始加载数据
157
- // eslint-disable-next-line react-hooks/exhaustive-deps
158
-
125
+ };
159
126
 
127
+ // 初始加载数据
128
+ // eslint-disable-next-line react-hooks/exhaustive-deps
160
129
  useEffect(function () {
161
130
  return updateOptions(getOptionsFun);
162
- }, [getOptionsFun]); // 操作dom设置下拉菜单样式,使下拉菜单宽度与选择框保持一致
131
+ }, [getOptionsFun]);
163
132
 
133
+ // 操作dom设置下拉菜单样式,使下拉菜单宽度与选择框保持一致
164
134
  useEffect(function () {
165
135
  var dSelectDropDom = document.querySelector(".d-cascader-dropdown-".concat(timestamp));
166
-
167
136
  if (dSelectDropDom) {
168
137
  updateDropDom(dSelectDropDom, timestamp);
169
138
  } else {
170
139
  var observer = new MutationObserver(function (mutations) {
171
140
  var _ref = mutations[0] || {},
172
- addedNodes = _ref.addedNodes;
173
-
141
+ addedNodes = _ref.addedNodes;
174
142
  for (var i = 0; i < addedNodes.length; i++) {
175
143
  if (typeof addedNodes[i]['querySelector'] === 'function') {
176
144
  var _dSelectDropDom = addedNodes[i]['querySelector'](".d-cascader-dropdown-".concat(timestamp));
177
-
178
145
  if (_dSelectDropDom) {
179
146
  observer.disconnect();
180
147
  updateDropDom(_dSelectDropDom, timestamp);
@@ -190,7 +157,7 @@ function InternalCascader(props, ref) {
190
157
  };
191
158
  }
192
159
  }, [timestamp]);
193
- return /*#__PURE__*/_jsx(Cascader, _objectSpread(_objectSpread({}, otherProps), {}, {
160
+ return /*#__PURE__*/React.createElement(Cascader, _extends({}, otherProps, {
194
161
  ref: ref,
195
162
  fieldNames: _fieldNames,
196
163
  loadData: _loadData,
@@ -200,12 +167,11 @@ function InternalCascader(props, ref) {
200
167
  loading: _loading,
201
168
  onChange: _onChange
202
169
  }));
203
- } // 获取延时时间,默认800ms,true代表默认时间,false代表0
204
-
170
+ }
205
171
 
172
+ // 获取延时时间,默认800ms,true代表默认时间,false代表0
206
173
  function getDelayTime(value) {
207
174
  var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 800;
208
-
209
175
  if (value === true) {
210
176
  return defaultValue;
211
177
  } else if (value === false) {
@@ -214,15 +180,14 @@ function getDelayTime(value) {
214
180
  return typeof value === 'number' ? Number(value) || 0 : defaultValue;
215
181
  }
216
182
  }
217
-
218
183
  function updateDropDom(dSelectDropDom, timestamp) {
219
184
  var dSelectDom = document.querySelector(".d-cascader-".concat(timestamp));
220
185
  var dSelectDropFirstMenu = dSelectDropDom.querySelector('ul.ant-cascader-menu');
221
-
222
186
  if (dSelectDom) {
223
187
  // 获取选择框宽度并恢复其初始样式
224
188
  dSelectDropDom.style.minWidth = "".concat(dSelectDom.clientWidth, "px");
225
- dSelectDropFirstMenu.style.minWidth = "".concat(dSelectDom.clientWidth, "px"); // className && dSelectDom.setAttribute('class', className.replace(`d-cascader-${timestamp}`, ''));
189
+ dSelectDropFirstMenu.style.minWidth = "".concat(dSelectDom.clientWidth, "px");
190
+ // className && dSelectDom.setAttribute('class', className.replace(`d-cascader-${timestamp}`, ''));
226
191
  // dSelectDropDom.setAttribute('class', dSelectDropDom.className.replace(`d-cascader-dropdown-${timestamp}`, ''));
227
192
  }
228
193
  }
@@ -1,27 +1,13 @@
1
1
  var _excluded = ["className", "onChange", "onCompositionStart", "onCompositionEnd", "value", "debounce", "enableCompose"];
2
-
3
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
2
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
9
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
-
11
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
-
13
5
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
-
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
-
17
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
-
6
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
7
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
19
8
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
-
21
9
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
-
23
10
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
24
-
25
11
  /*
26
12
  * @Author : wangfeihu
27
13
  * @Date : 2023-05-16 10:08:26
@@ -32,41 +18,33 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
32
18
  import React, { useRef, forwardRef, useState, useContext } from 'react';
33
19
  import { Input } from 'antd';
34
20
  import { ConfigContext } from "../ConfigProvider";
35
- import { jsx as _jsx } from "react/jsx-runtime";
36
-
37
21
  function InternalInput(props, ref) {
38
22
  var _props$className = props.className,
39
- className = _props$className === void 0 ? '' : _props$className,
40
- onChange = props.onChange,
41
- onCompositionStart = props.onCompositionStart,
42
- onCompositionEnd = props.onCompositionEnd,
43
- initValue = props.value,
44
- _props$debounce = props.debounce,
45
- debounce = _props$debounce === void 0 ? false : _props$debounce,
46
- _props$enableCompose = props.enableCompose,
47
- enableCompose = _props$enableCompose === void 0 ? true : _props$enableCompose,
48
- otherProps = _objectWithoutProperties(props, _excluded);
49
-
23
+ className = _props$className === void 0 ? '' : _props$className,
24
+ onChange = props.onChange,
25
+ onCompositionStart = props.onCompositionStart,
26
+ onCompositionEnd = props.onCompositionEnd,
27
+ initValue = props.value,
28
+ _props$debounce = props.debounce,
29
+ debounce = _props$debounce === void 0 ? false : _props$debounce,
30
+ _props$enableCompose = props.enableCompose,
31
+ enableCompose = _props$enableCompose === void 0 ? true : _props$enableCompose,
32
+ otherProps = _objectWithoutProperties(props, _excluded);
50
33
  var _useContext = useContext(ConfigContext),
51
- getPrefixCls = _useContext.getPrefixCls;
52
-
34
+ getPrefixCls = _useContext.getPrefixCls;
53
35
  var _useState = useState(initValue),
54
- _useState2 = _slicedToArray(_useState, 2),
55
- value = _useState2[0],
56
- setValue = _useState2[1];
57
-
36
+ _useState2 = _slicedToArray(_useState, 2),
37
+ value = _useState2[0],
38
+ setValue = _useState2[1];
58
39
  var _useState3 = useState(false),
59
- _useState4 = _slicedToArray(_useState3, 2),
60
- composeFlag = _useState4[0],
61
- setComposeFlag = _useState4[1];
62
-
40
+ _useState4 = _slicedToArray(_useState3, 2),
41
+ composeFlag = _useState4[0],
42
+ setComposeFlag = _useState4[1];
63
43
  var debounceRef = useRef();
44
+ var _className = "".concat(getPrefixCls('input'), " ").concat(className);
64
45
 
65
- var _className = "".concat(getPrefixCls('input'), " ").concat(className); // debounce: 默认800ms,false或0表示不开启
66
-
67
-
46
+ // debounce: 默认800ms,false或0表示不开启
68
47
  var _debounce = getDebounceTime(debounce);
69
-
70
48
  var emitChange = function emitChange(_value, e) {
71
49
  if (_debounce > 0) {
72
50
  clearTimeout(debounceRef.current);
@@ -76,32 +54,30 @@ function InternalInput(props, ref) {
76
54
  } else {
77
55
  onChange === null || onChange === void 0 ? void 0 : onChange(_value, e);
78
56
  }
79
- }; // 监听用户onChange事件(如果正在进行合成输入,则不响应用户事件)
80
-
57
+ };
81
58
 
59
+ // 监听用户onChange事件(如果正在进行合成输入,则不响应用户事件)
82
60
  var _onChange = function _onChange(e) {
83
61
  var _value = e.target.value;
84
62
  setValue(_value);
85
63
  if (!composeFlag) emitChange(_value, e);
86
- }; // 监听合成输入开始事件(执行用户事件并置合成标记为true)
87
-
64
+ };
88
65
 
66
+ // 监听合成输入开始事件(执行用户事件并置合成标记为true)
89
67
  var _onCompositionStart = function _onCompositionStart(e) {
90
68
  onCompositionStart === null || onCompositionStart === void 0 ? void 0 : onCompositionStart(e);
91
69
  enableCompose && setComposeFlag(true);
92
- }; // 监听合成输入结束事件(执行用户事件并置合成标记为false,同时触发用户onChange事件)
93
-
70
+ };
94
71
 
72
+ // 监听合成输入结束事件(执行用户事件并置合成标记为false,同时触发用户onChange事件)
95
73
  var _onCompositionEnd = function _onCompositionEnd(e) {
96
74
  onCompositionEnd === null || onCompositionEnd === void 0 ? void 0 : onCompositionEnd(e);
97
-
98
75
  if (enableCompose) {
99
76
  setComposeFlag(false);
100
77
  emitChange(e.target.value, e);
101
78
  }
102
79
  };
103
-
104
- return /*#__PURE__*/_jsx(Input, _objectSpread(_objectSpread({}, otherProps), {}, {
80
+ return /*#__PURE__*/React.createElement(Input, _extends({}, otherProps, {
105
81
  className: _className,
106
82
  ref: ref,
107
83
  value: value,
@@ -109,12 +85,11 @@ function InternalInput(props, ref) {
109
85
  onCompositionStart: _onCompositionStart,
110
86
  onCompositionEnd: _onCompositionEnd
111
87
  }));
112
- } // 获取防抖超时时间,debounce: 默认800ms,false或0表示不开启
113
-
88
+ }
114
89
 
90
+ // 获取防抖超时时间,debounce: 默认800ms,false或0表示不开启
115
91
  function getDebounceTime(debounce) {
116
92
  var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 800;
117
-
118
93
  if (debounce === true) {
119
94
  return defaultValue;
120
95
  } else if (debounce === false) {
@@ -123,6 +98,5 @@ function getDebounceTime(debounce) {
123
98
  return typeof debounce === 'number' ? debounce : defaultValue;
124
99
  }
125
100
  }
126
-
127
101
  var DInput = /*#__PURE__*/forwardRef(InternalInput);
128
102
  export default DInput;
@@ -1,27 +1,19 @@
1
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
1
2
  var _excluded = ["className", "popupClassName", "fieldNames", "searchValue", "filterOption", "options", "onSearch", "loading", "debounce"];
2
-
3
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
3
4
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
-
5
5
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
6
-
7
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
8
-
6
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
8
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
9
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
10
-
11
10
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
12
-
13
11
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
14
-
15
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
16
-
17
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
18
-
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
19
14
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
20
-
21
15
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
22
-
23
16
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
24
-
25
17
  /*
26
18
  * @Author : wangfeihu
27
19
  * @Date : 2023-05-17 08:41:25
@@ -32,42 +24,33 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
32
24
  import React, { forwardRef, useEffect, useRef, useState, useMemo, useContext } from 'react';
33
25
  import { Select } from 'antd';
34
26
  import { ConfigContext } from "../ConfigProvider";
35
- import { jsx as _jsx } from "react/jsx-runtime";
36
-
37
27
  function InternalSelect(props, ref) {
38
28
  var _props$className = props.className,
39
- className = _props$className === void 0 ? '' : _props$className,
40
- _props$popupClassName = props.popupClassName,
41
- popupClassName = _props$popupClassName === void 0 ? '' : _props$popupClassName,
42
- fieldNames = props.fieldNames,
43
- searchValue = props.searchValue,
44
- filterOption = props.filterOption,
45
- initOptions = props.options,
46
- onSearch = props.onSearch,
47
- initLoading = props.loading,
48
- _props$debounce = props.debounce,
49
- debounce = _props$debounce === void 0 ? false : _props$debounce,
50
- otherProps = _objectWithoutProperties(props, _excluded);
51
-
29
+ className = _props$className === void 0 ? '' : _props$className,
30
+ _props$popupClassName = props.popupClassName,
31
+ popupClassName = _props$popupClassName === void 0 ? '' : _props$popupClassName,
32
+ fieldNames = props.fieldNames,
33
+ searchValue = props.searchValue,
34
+ filterOption = props.filterOption,
35
+ initOptions = props.options,
36
+ onSearch = props.onSearch,
37
+ initLoading = props.loading,
38
+ _props$debounce = props.debounce,
39
+ debounce = _props$debounce === void 0 ? false : _props$debounce,
40
+ otherProps = _objectWithoutProperties(props, _excluded);
52
41
  var _useContext = useContext(ConfigContext),
53
- getPrefixCls = _useContext.getPrefixCls;
54
-
42
+ getPrefixCls = _useContext.getPrefixCls;
55
43
  var _useState = useState([]),
56
- _useState2 = _slicedToArray(_useState, 2),
57
- options = _useState2[0],
58
- setOptions = _useState2[1];
59
-
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ options = _useState2[0],
46
+ setOptions = _useState2[1];
60
47
  var _useState3 = useState(typeof initLoading === 'boolean' ? initLoading : true),
61
- _useState4 = _slicedToArray(_useState3, 2),
62
- loading = _useState4[0],
63
- setLoading = _useState4[1];
64
-
48
+ _useState4 = _slicedToArray(_useState3, 2),
49
+ loading = _useState4[0],
50
+ setLoading = _useState4[1];
65
51
  var _className = "".concat(getPrefixCls('select'), " ").concat(className);
66
-
67
52
  var _popupClassName = "".concat(getPrefixCls('select-dropdown'), " ").concat(popupClassName);
68
-
69
53
  var debounceRef = useRef(null); // 防抖处理引用
70
-
71
54
  var loadingRef = useRef({
72
55
  timer: null,
73
56
  status: 'done'
@@ -79,23 +62,16 @@ function InternalSelect(props, ref) {
79
62
  value: 'value',
80
63
  children: 'children'
81
64
  }, fieldNames);
82
-
83
65
  var _showSearch = !!onSearch;
84
-
85
66
  var _debounce = getDelayTime(debounce);
86
-
87
67
  var _loadingState = getDelayTime(initLoading, 600);
88
-
89
68
  var _loading = typeof initLoading === 'boolean' ? initLoading : loading;
90
-
91
69
  var _filterOption = getFilterOption(!_showSearch, filterOption, _fieldNames);
92
-
93
70
  var getOptions = useMemo(function () {
94
71
  return typeof initOptions === 'function' ? initOptions : function (params) {
95
72
  return Promise.resolve(initOptions || []);
96
73
  };
97
74
  }, [initOptions]);
98
-
99
75
  var _onSearch = function _onSearch(value) {
100
76
  if (onSearch) {
101
77
  if (_debounce > 0) {
@@ -108,7 +84,6 @@ function InternalSelect(props, ref) {
108
84
  }
109
85
  }
110
86
  };
111
-
112
87
  var updateOptions = function updateOptions(fun, value) {
113
88
  // 设置加载中状态
114
89
  if (_loadingState > 0) {
@@ -117,12 +92,13 @@ function InternalSelect(props, ref) {
117
92
  loadingRef.current.timer = setTimeout(function () {
118
93
  loadingRef.current.status === 'loading' && setLoading(true);
119
94
  }, _loadingState);
120
- } // 记录请求参数,清空options
121
-
95
+ }
122
96
 
97
+ // 记录请求参数,清空options
123
98
  loadingParamsRef.current = value;
124
- setOptions([]); // 发起请求
99
+ setOptions([]);
125
100
 
101
+ // 发起请求
126
102
  fun === null || fun === void 0 ? void 0 : fun(value).then(function (response) {
127
103
  if (loadingParamsRef.current === value) {
128
104
  setOptions(response);
@@ -135,18 +111,18 @@ function InternalSelect(props, ref) {
135
111
  loadingRef.current.status = 'done';
136
112
  }
137
113
  });
138
- }; // eslint-disable-next-line react-hooks/exhaustive-deps
139
-
114
+ };
140
115
 
116
+ // eslint-disable-next-line react-hooks/exhaustive-deps
141
117
  useEffect(function () {
142
118
  return updateOptions(getOptions, searchValue);
143
119
  }, [getOptions, searchValue]);
144
- return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({
120
+ return /*#__PURE__*/React.createElement(Select, _extends({
145
121
  allowClear: true,
146
122
  filterOption: _filterOption,
147
123
  showSearch: _showSearch,
148
124
  searchValue: searchValue
149
- }, otherProps), {}, {
125
+ }, otherProps, {
150
126
  ref: ref,
151
127
  className: _className,
152
128
  popupClassName: _popupClassName,
@@ -155,12 +131,11 @@ function InternalSelect(props, ref) {
155
131
  loading: _loading,
156
132
  options: options
157
133
  }));
158
- } // 获取延时时间,默认800ms,true代表默认时间,false代表0
159
-
134
+ }
160
135
 
136
+ // 获取延时时间,默认800ms,true代表默认时间,false代表0
161
137
  function getDelayTime(value) {
162
138
  var defaultValue = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 800;
163
-
164
139
  if (value === true) {
165
140
  return defaultValue;
166
141
  } else if (value === false) {
@@ -168,20 +143,18 @@ function getDelayTime(value) {
168
143
  } else {
169
144
  return typeof value === 'number' ? Number(value) || 0 : defaultValue;
170
145
  }
171
- } // 获取默认本地搜索方法
172
-
146
+ }
173
147
 
148
+ // 获取默认本地搜索方法
174
149
  function getFilterOption(showSearch, filterOption, fieldNames) {
175
150
  if (filterOption) {
176
151
  return filterOption;
177
152
  } else {
178
153
  return showSearch && function (value, option) {
179
154
  var _option$fieldNames$la;
180
-
181
155
  return (_option$fieldNames$la = option[fieldNames.label]) === null || _option$fieldNames$la === void 0 ? void 0 : _option$fieldNames$la.includes(value);
182
156
  };
183
157
  }
184
158
  }
185
-
186
159
  var DSelect = /*#__PURE__*/forwardRef(InternalSelect);
187
160
  export default DSelect;