@nutui/nutui-react-taro 1.3.5 → 1.3.7

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.
Files changed (129) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/esm/Audio.js +4 -4
  3. package/dist/esm/Calendar.js +4 -4
  4. package/dist/esm/CalendarItem.js +3 -3
  5. package/dist/esm/DatePicker.js +4 -4
  6. package/dist/esm/Drag.js +3 -4
  7. package/dist/esm/Elevator.js +2 -4
  8. package/dist/esm/Menu.js +2 -2
  9. package/dist/esm/MenuItem.js +2 -2
  10. package/dist/esm/NoticeBar.js +3 -3
  11. package/dist/esm/Picker.js +3 -3
  12. package/dist/esm/Popover.js +3 -3
  13. package/dist/esm/Range.js +3 -3
  14. package/dist/esm/SearchBar.js +3 -2
  15. package/dist/esm/Signature.js +3 -2
  16. package/dist/esm/Swipe.js +3 -3
  17. package/dist/esm/actionsheet.taro-360d8d34.js +15 -25
  18. package/dist/esm/address.taro-f16cef31.js +151 -219
  19. package/dist/esm/animatingnumbers.taro-6f40a2e9.js +13 -41
  20. package/dist/esm/{audio.taro-29f5568f.js → audio.taro-57d4f0da.js} +33 -60
  21. package/dist/esm/avatar.taro-ec620cdd.js +25 -50
  22. package/dist/esm/avatargroup-5b2584d9.js +2 -9
  23. package/dist/esm/backtop.taro-aa8b2bc5.js +29 -55
  24. package/dist/esm/badge.taro-38684262.js +9 -20
  25. package/dist/esm/barrage.taro-d86c367a.js +8 -21
  26. package/dist/esm/button.taro-a9ebb937.js +22 -37
  27. package/dist/esm/{calendar.taro-438940bd.js → calendar.taro-533b3219.js} +13 -24
  28. package/dist/esm/{calendaritem.taro-11333579.js → calendaritem.taro-fe5dd4bd.js} +71 -183
  29. package/dist/esm/card.taro-1bc35ebe.js +14 -20
  30. package/dist/esm/cascader.taro-77100fb4.js +77 -197
  31. package/dist/esm/cell.taro-a4c3bb7b.js +20 -30
  32. package/dist/esm/cellgroup.taro-8c87bf08.js +6 -12
  33. package/dist/esm/checkbox.taro-104557c1.js +27 -48
  34. package/dist/esm/checkboxgroup.taro-3d380042.js +12 -30
  35. package/dist/esm/circleprogress.taro-3c89a157.js +14 -41
  36. package/dist/esm/col.taro-2a437387.js +11 -22
  37. package/dist/esm/collapse.taro-72e58ba2.js +11 -27
  38. package/dist/esm/collapseitem-75843a5e.js +33 -47
  39. package/dist/esm/configprovider-3e87d67a.js +2 -6
  40. package/dist/esm/configprovider.taro-6c7b3056.js +4 -14
  41. package/dist/esm/countdown.taro-f2d9ffed.js +37 -74
  42. package/dist/esm/{datepicker.taro-1acec61f.js → datepicker.taro-49a4cf0c.js} +43 -104
  43. package/dist/esm/dialog.taro-492e2b9a.js +27 -58
  44. package/dist/esm/divider.taro-5236fe6a.js +8 -15
  45. package/dist/esm/drag.taro-0717c783.js +153 -0
  46. package/dist/esm/{elevator.taro-8e385785.js → elevator.taro-443253ec.js} +99 -124
  47. package/dist/esm/empty.taro-ab9c4f03.js +11 -24
  48. package/dist/esm/fixednav.taro-582322a1.js +16 -27
  49. package/dist/esm/grid.taro-5d75c0ad.js +13 -28
  50. package/dist/esm/griditem.taro-866cd288.js +18 -34
  51. package/dist/esm/icon-8dc4de10.js +11 -21
  52. package/dist/esm/icon.taro-1d0d4fb7.js +11 -21
  53. package/dist/esm/imagepreview.taro-1199e977.js +36 -71
  54. package/dist/esm/indicator.taro-183ea169.js +9 -20
  55. package/dist/esm/infiniteloading.taro-b95e62bf.js +23 -49
  56. package/dist/esm/input.taro-2453d7c4.js +62 -106
  57. package/dist/esm/inputnumber.taro-0cf7c1b7.js +25 -52
  58. package/dist/esm/layout.taro-358f014f.js +0 -6
  59. package/dist/esm/{menu.taro-9345dcfd.js → menu.taro-f8ca86db.js} +24 -42
  60. package/dist/esm/{menuitem.taro-fc0961b7.js → menuitem.taro-7bf564c9.js} +32 -57
  61. package/dist/esm/navbar.taro-c931c078.js +18 -34
  62. package/dist/esm/{noticebar.taro-1fa04a96.js → noticebar.taro-332691f9.js} +55 -107
  63. package/dist/esm/notify.taro-d9c48fae.js +18 -34
  64. package/dist/esm/numberkeyboard.taro-53c350b8.js +21 -52
  65. package/dist/esm/nutui-react.es.js +18 -18
  66. package/dist/esm/offsetContext-0e3d04b3.js +0 -3
  67. package/dist/esm/overlay.taro-be45fed5.js +12 -23
  68. package/dist/esm/pagination.taro-62bbd23f.js +38 -71
  69. package/dist/esm/{picker.taro-6a4dad23.js → picker.taro-f003b725.js} +95 -186
  70. package/dist/esm/{popover.taro-eddd0bd2.js → popover.taro-7e5dff8c.js} +33 -76
  71. package/dist/esm/popup.taro-33d0bbc8.js +40 -72
  72. package/dist/esm/price.taro-97393d8f.js +7 -24
  73. package/dist/esm/progress.taro-623bc807.js +23 -31
  74. package/dist/esm/pulltorefresh.taro-e66c78ad.js +29 -92
  75. package/dist/esm/radio.taro-95d43860.js +24 -47
  76. package/dist/esm/radiogroup.taro-b5dad516.js +14 -24
  77. package/dist/esm/{range.taro-515d37a4.js → range.taro-fc7c0b6a.js} +50 -133
  78. package/dist/esm/rate.taro-69c85081.js +21 -39
  79. package/dist/esm/row.taro-cec13a7e.js +7 -16
  80. package/dist/esm/{searchbar.taro-f134fb96.js → searchbar.taro-0d3c0081.js} +55 -70
  81. package/dist/esm/shortpassword.taro-2e96ca22.js +29 -56
  82. package/dist/esm/sidenavbar.taro-87f056cd.js +9 -16
  83. package/dist/esm/sidenavbaritem.taro-77e077f4.js +4 -11
  84. package/dist/esm/signature.taro-59b3b3ab.js +146 -0
  85. package/dist/esm/skeleton.taro-b9ff84b9.js +13 -23
  86. package/dist/esm/step.taro-f1057500.js +12 -28
  87. package/dist/esm/steps.taro-943f4fbb.js +6 -14
  88. package/dist/esm/sticky.taro-30d4e453.js +0 -7
  89. package/dist/esm/subsidenavbar.taro-2c1fcf16.js +7 -22
  90. package/dist/esm/{swipe.taro-dfb9a049.js → swipe.taro-83bc248f.js} +98 -91
  91. package/dist/esm/swiper.taro-f314d67a.js +110 -196
  92. package/dist/esm/swiperitem-d00e7513.js +2 -12
  93. package/dist/esm/switch.taro-be5eb823.js +13 -27
  94. package/dist/esm/tabbar.taro-da72fa2c.js +13 -25
  95. package/dist/esm/tabbaritem.taro-94cd62c2.js +15 -23
  96. package/dist/esm/table.taro-7ac89a6c.js +19 -39
  97. package/dist/esm/tabpane.taro-95aa185b.js +4 -10
  98. package/dist/esm/tabs.taro-86186dff.js +28 -54
  99. package/dist/esm/tag.taro-95d7f5c2.js +19 -36
  100. package/dist/esm/textarea.taro-388d1f90.js +18 -35
  101. package/dist/esm/timedetail.taro-519808cf.js +15 -28
  102. package/dist/esm/timepannel.taro-9904f6e6.js +5 -12
  103. package/dist/esm/timeselect.taro-73796bfc.js +35 -59
  104. package/dist/esm/toast.taro-86862dff.js +26 -46
  105. package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
  106. package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
  107. package/dist/esm/types/src/packages/searchbar/searchbar.taro.d.ts +2 -0
  108. package/dist/esm/types/src/packages/signature/signature.taro.d.ts +10 -2
  109. package/dist/esm/uploader.taro-6184abe7.js +52 -144
  110. package/dist/esm/{useClientRect-8b7cc406.js → useClientRect-bf69d7b3.js} +1 -40
  111. package/dist/esm/useTouch-a2ea68c6.js +27 -47
  112. package/dist/esm/video-c1090c92.js +8 -19
  113. package/dist/esm/virtuallist.taro-6858f690.js +84 -118
  114. package/dist/locales/base.js +1 -1
  115. package/dist/locales/en-US.js +1 -1
  116. package/dist/locales/id-ID.js +1 -1
  117. package/dist/locales/zh-CN.js +1 -1
  118. package/dist/locales/zh-TW.js +1 -1
  119. package/dist/nutui.react.es.js +10848 -11365
  120. package/dist/nutui.react.umd.js +10840 -11357
  121. package/dist/packages/menu/menu.scss +4 -0
  122. package/dist/packages/menuitem/menuitem.scss +27 -2
  123. package/dist/packages/searchbar/searchbar.scss +20 -3
  124. package/dist/style.css +1 -1
  125. package/dist/style.es.js +1 -1
  126. package/dist/types/index.d.ts +17 -8
  127. package/package.json +1 -1
  128. package/dist/esm/drag.taro-56e8c87a.js +0 -134
  129. package/dist/esm/signature.taro-a9286cd1.js +0 -178
@@ -6,15 +6,10 @@ import _createClass from "@babel/runtime/helpers/createClass";
6
6
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
7
7
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
8
  import _regeneratorRuntime from "@babel/runtime/regenerator";
9
-
10
9
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
-
12
10
  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); }
13
-
14
11
  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; }
15
-
16
12
  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; }
17
-
18
13
  import React__default, { useEffect, useState } from 'react';
19
14
  import classNames from 'classnames';
20
15
  import { P as Popup } from './popup.taro-33d0bbc8.js';
@@ -34,13 +29,11 @@ var defaultProps$1 = {
34
29
  checked: false,
35
30
  chooseItem: function chooseItem() {}
36
31
  };
37
-
38
32
  var InternalCascaderItem = function InternalCascaderItem(props) {
39
33
  var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props),
40
- data = _defaultProps$1$props.data,
41
- checked = _defaultProps$1$props.checked,
42
- chooseItem = _defaultProps$1$props.chooseItem;
43
-
34
+ data = _defaultProps$1$props.data,
35
+ checked = _defaultProps$1$props.checked,
36
+ chooseItem = _defaultProps$1$props.chooseItem;
44
37
  var b = cn('cascader-item');
45
38
  var classes = classNames({
46
39
  active: checked,
@@ -50,10 +43,9 @@ var InternalCascaderItem = function InternalCascaderItem(props) {
50
43
  useEffect(function () {
51
44
  initData();
52
45
  }, [data]);
53
-
54
- var initData = function initData() {// console.log('------data', data)
46
+ var initData = function initData() {
47
+ // console.log('------data', data)
55
48
  };
56
-
57
49
  return React__default.createElement("div", {
58
50
  className: classes,
59
51
  onClick: function onClick() {
@@ -70,25 +62,21 @@ var InternalCascaderItem = function InternalCascaderItem(props) {
70
62
  name: "checklist"
71
63
  }));
72
64
  };
73
-
74
65
  var CascaderItem = React__default.forwardRef(InternalCascaderItem);
75
66
  CascaderItem.defaultProps = defaultProps$1;
76
67
  CascaderItem.displayName = 'NutCascaderItem';
77
-
78
68
  var formatTree = function formatTree(tree, parent, config) {
79
69
  return tree.map(function (node) {
80
70
  var _config$value = config.value,
81
- valueKey = _config$value === void 0 ? 'value' : _config$value,
82
- _config$text = config.text,
83
- textKey = _config$text === void 0 ? 'text' : _config$text,
84
- _config$children = config.children,
85
- childrenKey = _config$children === void 0 ? 'children' : _config$children;
86
-
71
+ valueKey = _config$value === void 0 ? 'value' : _config$value,
72
+ _config$text = config.text,
73
+ textKey = _config$text === void 0 ? 'text' : _config$text,
74
+ _config$children = config.children,
75
+ childrenKey = _config$children === void 0 ? 'children' : _config$children;
87
76
  var value = node[valueKey],
88
- text = node[textKey],
89
- children = node[childrenKey],
90
- others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
91
-
77
+ text = node[textKey],
78
+ children = node[childrenKey],
79
+ others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
92
80
  var newNode = _objectSpread(_objectSpread({
93
81
  loading: false
94
82
  }, others), {}, {
@@ -98,61 +86,51 @@ var formatTree = function formatTree(tree, parent, config) {
98
86
  children: children,
99
87
  _parent: parent
100
88
  });
101
-
102
89
  if (newNode.children && newNode.children.length) {
103
90
  newNode.children = formatTree(newNode.children, newNode, config);
104
91
  }
105
-
106
92
  return newNode;
107
93
  });
108
94
  };
109
-
110
95
  var eachTree = function eachTree(tree, cb) {
111
96
  var i = 0;
112
97
  var node;
113
-
114
98
  while (node = tree[i++]) {
115
99
  if (cb(node) === true) {
116
100
  break;
117
101
  }
118
-
119
102
  if (node.children && node.children.length) {
120
103
  eachTree(node.children, cb);
121
104
  }
122
105
  }
123
106
  };
124
-
125
107
  var defaultConvertConfig = {
126
108
  topId: null,
127
109
  idKey: 'id',
128
110
  pidKey: 'pid',
129
111
  sortKey: ''
130
112
  };
131
-
132
113
  var convertListToOptions = function convertListToOptions(list, options) {
133
114
  var mergedOptions = _objectSpread(_objectSpread({}, defaultConvertConfig), options || {});
134
-
135
115
  var topId = mergedOptions.topId,
136
- idKey = mergedOptions.idKey,
137
- pidKey = mergedOptions.pidKey,
138
- sortKey = mergedOptions.sortKey;
116
+ idKey = mergedOptions.idKey,
117
+ pidKey = mergedOptions.pidKey,
118
+ sortKey = mergedOptions.sortKey;
139
119
  var result = [];
140
120
  var map = {};
141
121
  list.forEach(function (node) {
142
122
  node = _objectSpread({}, node);
143
123
  var _node = node,
144
- id = _node[idKey],
145
- pid = _node[pidKey];
146
- var children = map[pid] = map[pid] || []; // const children = map[pid] || []
147
-
124
+ id = _node[idKey],
125
+ pid = _node[pidKey];
126
+ var children = map[pid] = map[pid] || [];
127
+ // const children = map[pid] || []
148
128
  if (!result.length && pid === topId) {
149
129
  result = children;
150
130
  }
151
-
152
131
  children.push(node);
153
132
  node.children = map[id] || (map[id] = []);
154
133
  });
155
-
156
134
  if (sortKey) {
157
135
  Object.keys(map).forEach(function (i) {
158
136
  if (map[i].length > 1) {
@@ -162,39 +140,29 @@ var convertListToOptions = function convertListToOptions(list, options) {
162
140
  }
163
141
  });
164
142
  }
165
-
166
143
  map = null;
167
144
  return result;
168
145
  };
169
-
170
146
  var Tree = /*#__PURE__*/function () {
171
147
  function Tree(nodes, config) {
172
148
  var _this = this;
173
-
174
149
  _classCallCheck(this, Tree);
175
-
176
150
  _defineProperty(this, "nodes", void 0);
177
-
178
151
  _defineProperty(this, "config", void 0);
179
-
180
152
  _defineProperty(this, "isLeaf", function (node, lazy) {
181
153
  var leaf = node.leaf,
182
- children = node.children;
154
+ children = node.children;
183
155
  var hasChildren = Array.isArray(children) && Boolean(children.length);
184
156
  return leaf || !hasChildren && !lazy;
185
157
  });
186
-
187
158
  _defineProperty(this, "hasChildren", function (node, lazy) {
188
159
  var isLeaf = _this.isLeaf(node, lazy);
189
-
190
160
  if (isLeaf) {
191
161
  return false;
192
162
  }
193
-
194
163
  var children = node.children;
195
164
  return Array.isArray(children) && Boolean(children.length);
196
165
  });
197
-
198
166
  this.config = _objectSpread({
199
167
  value: 'value',
200
168
  text: 'text',
@@ -202,7 +170,6 @@ var Tree = /*#__PURE__*/function () {
202
170
  }, config || {});
203
171
  this.nodes = formatTree(nodes, null, this.config);
204
172
  }
205
-
206
173
  _createClass(Tree, [{
207
174
  key: "updateChildren",
208
175
  value: function updateChildren(nodes, parent) {
@@ -211,8 +178,8 @@ var Tree = /*#__PURE__*/function () {
211
178
  } else {
212
179
  parent.children = formatTree(nodes, parent, this.config);
213
180
  }
214
- } // for test
215
-
181
+ }
182
+ // for test
216
183
  }, {
217
184
  key: "getNodeByValue",
218
185
  value: function getNodeByValue(value) {
@@ -222,7 +189,6 @@ var Tree = /*#__PURE__*/function () {
222
189
  foundNode = node;
223
190
  return true;
224
191
  }
225
-
226
192
  return null;
227
193
  });
228
194
  return foundNode;
@@ -233,30 +199,23 @@ var Tree = /*#__PURE__*/function () {
233
199
  if (!value.length) {
234
200
  return [];
235
201
  }
236
-
237
202
  var pathNodes = [];
238
203
  var currentNodes = this.nodes;
239
-
240
204
  while (currentNodes && currentNodes.length) {
241
205
  var foundNode = currentNodes.find(function (node) {
242
206
  return node.value === value[node.level];
243
207
  });
244
-
245
208
  if (!foundNode) {
246
209
  break;
247
210
  }
248
-
249
211
  pathNodes.push(foundNode);
250
212
  currentNodes = foundNode.children;
251
213
  }
252
-
253
214
  return pathNodes;
254
215
  }
255
216
  }]);
256
-
257
217
  return Tree;
258
218
  }();
259
-
260
219
  var defaultProps = _objectSpread({
261
220
  className: '',
262
221
  style: {},
@@ -278,68 +237,62 @@ var defaultProps = _objectSpread({
278
237
  onChange: function onChange() {},
279
238
  onPathChange: function onPathChange() {}
280
239
  }, Popup.defaultProps);
281
-
282
240
  var InternalCascader = function InternalCascader(props) {
283
241
  var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
284
- className = _defaultProps$props.className,
285
- style = _defaultProps$props.style,
286
- poppable = _defaultProps$props.poppable,
287
- visible = _defaultProps$props.visible,
288
- options = _defaultProps$props.options,
289
- value = _defaultProps$props.value,
290
- title = _defaultProps$props.title,
291
- textKey = _defaultProps$props.textKey,
292
- valueKey = _defaultProps$props.valueKey,
293
- childrenKey = _defaultProps$props.childrenKey,
294
- convertConfig = _defaultProps$props.convertConfig,
295
- closeable = _defaultProps$props.closeable,
296
- closeIconPosition = _defaultProps$props.closeIconPosition,
297
- closeIcon = _defaultProps$props.closeIcon,
298
- lazy = _defaultProps$props.lazy,
299
- lazyLoad = _defaultProps$props.lazyLoad,
300
- onClose = _defaultProps$props.onClose,
301
- onChange = _defaultProps$props.onChange,
302
- onPathChange = _defaultProps$props.onPathChange;
303
-
242
+ className = _defaultProps$props.className,
243
+ style = _defaultProps$props.style,
244
+ poppable = _defaultProps$props.poppable,
245
+ visible = _defaultProps$props.visible,
246
+ options = _defaultProps$props.options,
247
+ value = _defaultProps$props.value,
248
+ title = _defaultProps$props.title,
249
+ textKey = _defaultProps$props.textKey,
250
+ valueKey = _defaultProps$props.valueKey,
251
+ childrenKey = _defaultProps$props.childrenKey,
252
+ convertConfig = _defaultProps$props.convertConfig,
253
+ closeable = _defaultProps$props.closeable,
254
+ closeIconPosition = _defaultProps$props.closeIconPosition,
255
+ closeIcon = _defaultProps$props.closeIcon,
256
+ lazy = _defaultProps$props.lazy,
257
+ lazyLoad = _defaultProps$props.lazyLoad,
258
+ onClose = _defaultProps$props.onClose,
259
+ onChange = _defaultProps$props.onChange,
260
+ onPathChange = _defaultProps$props.onPathChange;
304
261
  var _useState = useState('c1'),
305
- _useState2 = _slicedToArray(_useState, 2),
306
- tabvalue = _useState2[0],
307
- setTabvalue = _useState2[1];
308
-
262
+ _useState2 = _slicedToArray(_useState, 2),
263
+ tabvalue = _useState2[0],
264
+ setTabvalue = _useState2[1];
309
265
  var _useState3 = useState([]),
310
- _useState4 = _slicedToArray(_useState3, 2),
311
- optiosData = _useState4[0],
312
- setOptiosData = _useState4[1];
313
-
266
+ _useState4 = _slicedToArray(_useState3, 2),
267
+ optiosData = _useState4[0],
268
+ setOptiosData = _useState4[1];
314
269
  var isLazy = function isLazy() {
315
270
  return state.configs.lazy && Boolean(state.configs.lazyLoad);
316
271
  };
317
-
318
272
  var _useState5 = useState({
319
- optionsData: [],
320
- panes: [{
321
- nodes: [],
322
- selectedNode: [],
323
- paneKey: ''
324
- }],
325
- innerValue: value,
326
- tree: new Tree([], {}),
327
- tabsCursor: 0,
328
- initLoading: false,
329
- currentProcessNode: [],
330
- configs: {
331
- lazy: lazy,
332
- lazyLoad: lazyLoad,
333
- valueKey: valueKey,
334
- textKey: textKey,
335
- childrenKey: childrenKey,
336
- convertConfig: convertConfig
337
- },
338
- lazyLoadMap: new Map()
339
- }),
340
- _useState6 = _slicedToArray(_useState5, 1),
341
- state = _useState6[0];
342
-
273
+ optionsData: [],
274
+ panes: [{
275
+ nodes: [],
276
+ selectedNode: [],
277
+ paneKey: ''
278
+ }],
279
+ innerValue: value,
280
+ tree: new Tree([], {}),
281
+ tabsCursor: 0,
282
+ initLoading: false,
283
+ currentProcessNode: [],
284
+ configs: {
285
+ lazy: lazy,
286
+ lazyLoad: lazyLoad,
287
+ valueKey: valueKey,
288
+ textKey: textKey,
289
+ childrenKey: childrenKey,
290
+ convertConfig: convertConfig
291
+ },
292
+ lazyLoadMap: new Map()
293
+ }),
294
+ _useState6 = _slicedToArray(_useState5, 1),
295
+ state = _useState6[0];
343
296
  var b = cn('cascader');
344
297
  var classes = classNames(b(''));
345
298
  var classesPane = classNames(_defineProperty({}, "".concat(b(''), "-pane"), true));
@@ -354,7 +307,6 @@ var InternalCascader = function InternalCascader(props) {
354
307
  useEffect(function () {
355
308
  initData();
356
309
  }, [options]);
357
-
358
310
  var initData = /*#__PURE__*/function () {
359
311
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
360
312
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -363,24 +315,20 @@ var InternalCascader = function InternalCascader(props) {
363
315
  case 0:
364
316
  // 初始化开始处理数据
365
317
  state.lazyLoadMap.clear();
366
-
367
318
  if (convertConfig && Object.keys(convertConfig).length > 0) {
368
319
  state.optionsData = convertListToOptions(options, convertConfig);
369
320
  } else {
370
321
  state.optionsData = options;
371
322
  }
372
-
373
323
  state.tree = new Tree(state.optionsData, {
374
324
  value: state.configs.valueKey,
375
325
  text: state.configs.textKey,
376
326
  children: state.configs.childrenKey
377
327
  });
378
-
379
328
  if (!(isLazy() && !state.tree.nodes.length)) {
380
329
  _context.next = 6;
381
330
  break;
382
331
  }
383
-
384
332
  _context.next = 6;
385
333
  return invokeLazyLoad({
386
334
  root: true,
@@ -388,7 +336,6 @@ var InternalCascader = function InternalCascader(props) {
388
336
  text: '',
389
337
  value: ''
390
338
  });
391
-
392
339
  case 6:
393
340
  state.panes = [{
394
341
  nodes: state.tree.nodes,
@@ -397,7 +344,6 @@ var InternalCascader = function InternalCascader(props) {
397
344
  }];
398
345
  syncValue();
399
346
  setOptiosData(state.panes);
400
-
401
347
  case 9:
402
348
  case "end":
403
349
  return _context.stop();
@@ -405,13 +351,11 @@ var InternalCascader = function InternalCascader(props) {
405
351
  }
406
352
  }, _callee);
407
353
  }));
408
-
409
354
  return function initData() {
410
355
  return _ref.apply(this, arguments);
411
356
  };
412
- }(); // 处理有默认值时的数据
413
-
414
-
357
+ }();
358
+ // 处理有默认值时的数据
415
359
  var syncValue = /*#__PURE__*/function () {
416
360
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
417
361
  var currentValue, needToSync, parent, last, pathNodes;
@@ -420,49 +364,39 @@ var InternalCascader = function InternalCascader(props) {
420
364
  switch (_context3.prev = _context3.next) {
421
365
  case 0:
422
366
  currentValue = state.innerValue;
423
-
424
367
  if (!(currentValue === undefined || !state.tree.nodes.length)) {
425
368
  _context3.next = 3;
426
369
  break;
427
370
  }
428
-
429
371
  return _context3.abrupt("return");
430
-
431
372
  case 3:
432
373
  if (!(currentValue.length === 0)) {
433
374
  _context3.next = 6;
434
375
  break;
435
376
  }
436
-
437
- state.tabsCursor = 0; // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
438
-
377
+ state.tabsCursor = 0;
378
+ // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
439
379
  return _context3.abrupt("return");
440
-
441
380
  case 6:
442
381
  needToSync = currentValue;
443
-
444
382
  if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
445
383
  _context3.next = 19;
446
384
  break;
447
385
  }
448
-
449
386
  needToSync = [];
450
387
  parent = state.tree.nodes.find(function (node) {
451
388
  return node.value === currentValue[0];
452
389
  });
453
-
454
390
  if (!parent) {
455
391
  _context3.next = 19;
456
392
  break;
457
393
  }
458
-
459
394
  needToSync = [parent.value];
460
395
  state.initLoading = true;
461
396
  _context3.next = 15;
462
397
  return currentValue.slice(1).reduce( /*#__PURE__*/function () {
463
398
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(p, value) {
464
399
  var _parent$children;
465
-
466
400
  var parent, node;
467
401
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
468
402
  while (1) {
@@ -470,23 +404,18 @@ var InternalCascader = function InternalCascader(props) {
470
404
  case 0:
471
405
  _context2.next = 2;
472
406
  return p;
473
-
474
407
  case 2:
475
408
  parent = _context2.sent;
476
409
  _context2.next = 5;
477
410
  return invokeLazyLoad(parent);
478
-
479
411
  case 5:
480
412
  node = parent === null || parent === void 0 ? void 0 : (_parent$children = parent.children) === null || _parent$children === void 0 ? void 0 : _parent$children.find(function (item) {
481
413
  return item.value === value;
482
414
  });
483
-
484
415
  if (node) {
485
416
  needToSync.push(value);
486
417
  }
487
-
488
418
  return _context2.abrupt("return", Promise.resolve(node));
489
-
490
419
  case 8:
491
420
  case "end":
492
421
  return _context2.stop();
@@ -494,30 +423,25 @@ var InternalCascader = function InternalCascader(props) {
494
423
  }
495
424
  }, _callee2);
496
425
  }));
497
-
498
426
  return function (_x, _x2) {
499
427
  return _ref3.apply(this, arguments);
500
428
  };
501
429
  }(), Promise.resolve(parent));
502
-
503
430
  case 15:
504
431
  last = _context3.sent;
505
432
  _context3.next = 18;
506
433
  return invokeLazyLoad(last);
507
-
508
434
  case 18:
509
435
  state.initLoading = false;
510
-
511
436
  case 19:
512
437
  if (needToSync.length && currentValue === value) {
513
438
  pathNodes = state.tree.getPathNodesByValue(needToSync);
514
439
  pathNodes.forEach(function (node, index) {
515
- state.tabsCursor = index; // 当有默认值时,不触发 chooseItem 里的 emit 事件
516
-
440
+ state.tabsCursor = index;
441
+ // 当有默认值时,不触发 chooseItem 里的 emit 事件
517
442
  _chooseItem(node, true);
518
443
  });
519
444
  }
520
-
521
445
  case 20:
522
446
  case "end":
523
447
  return _context3.stop();
@@ -525,12 +449,10 @@ var InternalCascader = function InternalCascader(props) {
525
449
  }
526
450
  }, _callee3);
527
451
  }));
528
-
529
452
  return function syncValue() {
530
453
  return _ref2.apply(this, arguments);
531
454
  };
532
455
  }();
533
-
534
456
  var invokeLazyLoad = /*#__PURE__*/function () {
535
457
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(node) {
536
458
  var parent, lazyLoadPromise, nodes;
@@ -542,57 +464,44 @@ var InternalCascader = function InternalCascader(props) {
542
464
  _context4.next = 2;
543
465
  break;
544
466
  }
545
-
546
467
  return _context4.abrupt("return");
547
-
548
468
  case 2:
549
469
  if (state.configs.lazyLoad) {
550
470
  _context4.next = 5;
551
471
  break;
552
472
  }
553
-
554
473
  node.leaf = true;
555
474
  return _context4.abrupt("return");
556
-
557
475
  case 5:
558
476
  if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
559
477
  _context4.next = 7;
560
478
  break;
561
479
  }
562
-
563
480
  return _context4.abrupt("return");
564
-
565
481
  case 7:
566
482
  node.loading = true;
567
483
  parent = node.root ? null : node;
568
484
  lazyLoadPromise = state.lazyLoadMap.get(node);
569
-
570
485
  if (!lazyLoadPromise) {
571
486
  lazyLoadPromise = new Promise(function (resolve) {
572
487
  var _state$configs$lazyLo, _state$configs;
573
-
574
488
  // 外部必须resolve
575
489
  (_state$configs$lazyLo = (_state$configs = state.configs).lazyLoad) === null || _state$configs$lazyLo === void 0 ? void 0 : _state$configs$lazyLo.call(_state$configs, node, resolve);
576
490
  });
577
491
  state.lazyLoadMap.set(node, lazyLoadPromise);
578
492
  }
579
-
580
493
  _context4.next = 13;
581
494
  return lazyLoadPromise;
582
-
583
495
  case 13:
584
496
  nodes = _context4.sent;
585
-
586
497
  if (Array.isArray(nodes) && nodes.length > 0) {
587
498
  state.tree.updateChildren(nodes, parent);
588
499
  } else {
589
500
  // 如果加载完成后没有提供子节点,作为叶子节点处理
590
501
  node.leaf = true;
591
502
  }
592
-
593
503
  node.loading = false;
594
504
  state.lazyLoadMap["delete"](node);
595
-
596
505
  case 17:
597
506
  case "end":
598
507
  return _context4.stop();
@@ -600,27 +509,21 @@ var InternalCascader = function InternalCascader(props) {
600
509
  }
601
510
  }, _callee4);
602
511
  }));
603
-
604
512
  return function invokeLazyLoad(_x3) {
605
513
  return _ref4.apply(this, arguments);
606
514
  };
607
515
  }();
608
-
609
516
  var close = function close() {
610
517
  onClose && onClose();
611
518
  };
612
-
613
519
  var closePopup = function closePopup() {
614
520
  close();
615
521
  };
616
522
  /* type: 是否是静默模式,是的话不触发事件
617
523
  tabsCursor: tab的索引 */
618
-
619
-
620
524
  var _chooseItem = /*#__PURE__*/function () {
621
525
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(node, type) {
622
526
  var pathNodes, optionParams, level, _pathNodes, _optionParams;
623
-
624
527
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
625
528
  while (1) {
626
529
  switch (_context5.prev = _context5.next) {
@@ -629,19 +532,15 @@ var InternalCascader = function InternalCascader(props) {
629
532
  _context5.next = 2;
630
533
  break;
631
534
  }
632
-
633
535
  return _context5.abrupt("return");
634
-
635
536
  case 2:
636
537
  if (!state.tree.isLeaf(node, isLazy())) {
637
538
  _context5.next = 10;
638
539
  break;
639
540
  }
640
-
641
541
  node.leaf = true;
642
542
  state.panes[state.tabsCursor].selectedNode = node;
643
543
  state.panes = state.panes.slice(0, node.level + 1);
644
-
645
544
  if (!type) {
646
545
  pathNodes = state.panes.map(function (item) {
647
546
  return item.selectedNode;
@@ -652,17 +551,14 @@ var InternalCascader = function InternalCascader(props) {
652
551
  onChange(optionParams, pathNodes);
653
552
  onPathChange(optionParams, pathNodes);
654
553
  }
655
-
656
554
  setOptiosData(state.panes);
657
555
  close();
658
556
  return _context5.abrupt("return");
659
-
660
557
  case 10:
661
558
  if (!state.tree.hasChildren(node, isLazy())) {
662
559
  _context5.next = 20;
663
560
  break;
664
561
  }
665
-
666
562
  level = node.level + 1;
667
563
  state.panes[state.tabsCursor].selectedNode = node;
668
564
  state.panes = state.panes.slice(0, level);
@@ -674,7 +570,6 @@ var InternalCascader = function InternalCascader(props) {
674
570
  });
675
571
  setTabvalue("c".concat(state.tabsCursor + 1));
676
572
  setOptiosData(state.panes);
677
-
678
573
  if (!type) {
679
574
  _pathNodes = state.panes.map(function (item) {
680
575
  return item.selectedNode;
@@ -684,32 +579,23 @@ var InternalCascader = function InternalCascader(props) {
684
579
  });
685
580
  onPathChange(_optionParams, _pathNodes);
686
581
  }
687
-
688
582
  return _context5.abrupt("return");
689
-
690
583
  case 20:
691
584
  state.currentProcessNode = node;
692
-
693
585
  if (!node.loading) {
694
586
  _context5.next = 23;
695
587
  break;
696
588
  }
697
-
698
589
  return _context5.abrupt("return");
699
-
700
590
  case 23:
701
591
  _context5.next = 25;
702
592
  return invokeLazyLoad(node);
703
-
704
593
  case 25:
705
594
  if (state.currentProcessNode === node) {
706
595
  state.panes[state.tabsCursor].selectedNode = node;
707
-
708
596
  _chooseItem(node, type);
709
597
  }
710
-
711
598
  setOptiosData(state.panes);
712
-
713
599
  case 27:
714
600
  case "end":
715
601
  return _context5.stop();
@@ -717,12 +603,10 @@ var InternalCascader = function InternalCascader(props) {
717
603
  }
718
604
  }, _callee5);
719
605
  }));
720
-
721
606
  return function chooseItem(_x4, _x5) {
722
607
  return _ref5.apply(this, arguments);
723
608
  };
724
609
  }();
725
-
726
610
  var renderItem = function renderItem() {
727
611
  return React__default.createElement("div", {
728
612
  className: "".concat(classes, " ").concat(className),
@@ -734,7 +618,6 @@ var InternalCascader = function InternalCascader(props) {
734
618
  titleNode: function titleNode() {
735
619
  return optiosData.map(function (pane, index) {
736
620
  var _pane$selectedNode, _pane$selectedNode2;
737
-
738
621
  return React__default.createElement("div", {
739
622
  onClick: function onClick() {
740
623
  setTabvalue(pane.paneKey);
@@ -757,7 +640,6 @@ var InternalCascader = function InternalCascader(props) {
757
640
  className: classesPane
758
641
  }, pane.nodes && pane.nodes.map(function (node, index) {
759
642
  var _pane$selectedNode3;
760
-
761
643
  return React__default.createElement(CascaderItem, _objectSpread(_objectSpread({
762
644
  key: index
763
645
  }, props), {}, {
@@ -772,7 +654,6 @@ var InternalCascader = function InternalCascader(props) {
772
654
  className: classesPane
773
655
  }))));
774
656
  };
775
-
776
657
  return React__default.createElement(React__default.Fragment, null, poppable ? React__default.createElement(Popup, {
777
658
  popClass: "cascadar-popup",
778
659
  visible: visible,
@@ -785,7 +666,6 @@ var InternalCascader = function InternalCascader(props) {
785
666
  onClickCloseIcon: closePopup
786
667
  }, renderItem()) : renderItem());
787
668
  };
788
-
789
669
  var Cascader = React__default.forwardRef(InternalCascader);
790
670
  Cascader.defaultProps = defaultProps;
791
671
  Cascader.displayName = 'NutCascader';