@nutui/nutui-react 1.3.5-beta.1 → 1.3.6

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 (108) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/esm/ActionSheet.js +15 -25
  3. package/dist/esm/Address.js +151 -221
  4. package/dist/esm/AnimatingNumbers.js +7 -31
  5. package/dist/esm/Audio.js +31 -66
  6. package/dist/esm/Avatar.js +25 -51
  7. package/dist/esm/AvatarGroup.js +2 -9
  8. package/dist/esm/BackTop.js +29 -55
  9. package/dist/esm/Badge.js +9 -20
  10. package/dist/esm/Barrage.js +8 -20
  11. package/dist/esm/Button.js +22 -37
  12. package/dist/esm/Calendar.js +23 -37
  13. package/dist/esm/CalendarItem.js +86 -186
  14. package/dist/esm/Card.js +14 -20
  15. package/dist/esm/Cascader.js +77 -197
  16. package/dist/esm/Cell.js +20 -30
  17. package/dist/esm/CellGroup.js +6 -12
  18. package/dist/esm/Checkbox.js +27 -48
  19. package/dist/esm/CheckboxGroup.js +12 -30
  20. package/dist/esm/CircleProgress.js +11 -28
  21. package/dist/esm/Col.js +11 -22
  22. package/dist/esm/Collapse.js +11 -27
  23. package/dist/esm/CollapseItem.js +33 -47
  24. package/dist/esm/ConfigProvider.js +4 -15
  25. package/dist/esm/CountDown.js +37 -74
  26. package/dist/esm/DatePicker.js +44 -106
  27. package/dist/esm/Dialog.js +31 -89
  28. package/dist/esm/Divider.js +8 -15
  29. package/dist/esm/Drag.js +30 -45
  30. package/dist/esm/Elevator.js +37 -74
  31. package/dist/esm/Empty.js +11 -24
  32. package/dist/esm/FixedNav.js +18 -29
  33. package/dist/esm/Grid.js +13 -28
  34. package/dist/esm/GridItem.js +18 -34
  35. package/dist/esm/ImagePreview.js +36 -71
  36. package/dist/esm/Indicator.js +9 -20
  37. package/dist/esm/Infiniteloading.js +26 -55
  38. package/dist/esm/Input.js +62 -106
  39. package/dist/esm/InputNumber.js +25 -52
  40. package/dist/esm/Layout.js +0 -6
  41. package/dist/esm/Menu.js +24 -46
  42. package/dist/esm/MenuItem.js +29 -52
  43. package/dist/esm/NavBar.js +18 -34
  44. package/dist/esm/NoticeBar.js +54 -102
  45. package/dist/esm/Notify.js +9 -38
  46. package/dist/esm/NumberKeyboard.js +21 -52
  47. package/dist/esm/Pagination.js +38 -71
  48. package/dist/esm/Picker.js +91 -178
  49. package/dist/esm/Popover.js +32 -72
  50. package/dist/esm/Popup.js +40 -72
  51. package/dist/esm/Price.js +7 -24
  52. package/dist/esm/Progress.js +35 -50
  53. package/dist/esm/PullToRefresh.js +28 -83
  54. package/dist/esm/Radio.js +24 -47
  55. package/dist/esm/RadioGroup.js +14 -24
  56. package/dist/esm/Range.js +44 -116
  57. package/dist/esm/Rate.js +21 -39
  58. package/dist/esm/Row.js +7 -16
  59. package/dist/esm/SearchBar.js +47 -68
  60. package/dist/esm/ShortPassword.js +29 -56
  61. package/dist/esm/SideNavBar.js +9 -16
  62. package/dist/esm/SideNavBarItem.js +4 -11
  63. package/dist/esm/Signature.js +13 -43
  64. package/dist/esm/Skeleton.js +13 -23
  65. package/dist/esm/Step.js +12 -28
  66. package/dist/esm/Steps.js +6 -14
  67. package/dist/esm/Sticky.js +24 -52
  68. package/dist/esm/SubSideNavBar.js +7 -22
  69. package/dist/esm/Swipe.js +15 -54
  70. package/dist/esm/Swiper.js +102 -186
  71. package/dist/esm/SwiperItem.js +2 -12
  72. package/dist/esm/Switch.js +13 -27
  73. package/dist/esm/Tabbar.js +13 -25
  74. package/dist/esm/TabbarItem.js +15 -23
  75. package/dist/esm/Table.js +19 -39
  76. package/dist/esm/Tag.js +19 -36
  77. package/dist/esm/TextArea.js +19 -43
  78. package/dist/esm/TimeDetail.js +15 -28
  79. package/dist/esm/TimePannel.js +5 -12
  80. package/dist/esm/TimeSelect.js +35 -59
  81. package/dist/esm/Toast.js +16 -49
  82. package/dist/esm/Uploader.js +57 -152
  83. package/dist/esm/Video.js +8 -19
  84. package/dist/esm/VirtualList.js +84 -118
  85. package/dist/esm/date-710f8c7c.js +9 -33
  86. package/dist/esm/get-scroll-parent-3dcd3f53.js +1 -9
  87. package/dist/esm/icon-8dc4de10.js +11 -21
  88. package/dist/esm/offsetContext-0e3d04b3.js +0 -3
  89. package/dist/esm/overlay-ed3eb37d.js +12 -23
  90. package/dist/esm/render-18227751.js +0 -11
  91. package/dist/esm/tabpane-c957ab14.js +4 -10
  92. package/dist/esm/tabs-0896a61b.js +28 -56
  93. package/dist/esm/types/src/packages/elevator/demo.d.ts +1 -0
  94. package/dist/esm/types/src/packages/searchbar/searchbar.d.ts +2 -0
  95. package/dist/esm/useClientRect-839d18c5.js +0 -5
  96. package/dist/esm/useTouch-a2ea68c6.js +27 -47
  97. package/dist/locales/base.js +1 -1
  98. package/dist/locales/en-US.js +1 -1
  99. package/dist/locales/id-ID.js +1 -1
  100. package/dist/locales/zh-CN.js +1 -1
  101. package/dist/locales/zh-TW.js +1 -1
  102. package/dist/nutui.react.es.js +424 -406
  103. package/dist/nutui.react.umd.js +416 -398
  104. package/dist/packages/searchbar/searchbar.scss +20 -3
  105. package/dist/style.css +1 -1
  106. package/dist/style.es.js +1 -1
  107. package/dist/types/index.d.ts +2 -0
  108. package/package.json +1 -1
@@ -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 Popup from './Popup.js';
@@ -37,13 +32,11 @@ var defaultProps$1 = {
37
32
  checked: false,
38
33
  chooseItem: function chooseItem() {}
39
34
  };
40
-
41
35
  var InternalCascaderItem = function InternalCascaderItem(props) {
42
36
  var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props),
43
- data = _defaultProps$1$props.data,
44
- checked = _defaultProps$1$props.checked,
45
- chooseItem = _defaultProps$1$props.chooseItem;
46
-
37
+ data = _defaultProps$1$props.data,
38
+ checked = _defaultProps$1$props.checked,
39
+ chooseItem = _defaultProps$1$props.chooseItem;
47
40
  var b = cn('cascader-item');
48
41
  var classes = classNames({
49
42
  active: checked,
@@ -53,10 +46,9 @@ var InternalCascaderItem = function InternalCascaderItem(props) {
53
46
  useEffect(function () {
54
47
  initData();
55
48
  }, [data]);
56
-
57
- var initData = function initData() {// console.log('------data', data)
49
+ var initData = function initData() {
50
+ // console.log('------data', data)
58
51
  };
59
-
60
52
  return React__default.createElement("div", {
61
53
  className: classes,
62
54
  onClick: function onClick() {
@@ -73,25 +65,21 @@ var InternalCascaderItem = function InternalCascaderItem(props) {
73
65
  name: "checklist"
74
66
  }));
75
67
  };
76
-
77
68
  var CascaderItem = React__default.forwardRef(InternalCascaderItem);
78
69
  CascaderItem.defaultProps = defaultProps$1;
79
70
  CascaderItem.displayName = 'NutCascaderItem';
80
-
81
71
  var formatTree = function formatTree(tree, parent, config) {
82
72
  return tree.map(function (node) {
83
73
  var _config$value = config.value,
84
- valueKey = _config$value === void 0 ? 'value' : _config$value,
85
- _config$text = config.text,
86
- textKey = _config$text === void 0 ? 'text' : _config$text,
87
- _config$children = config.children,
88
- childrenKey = _config$children === void 0 ? 'children' : _config$children;
89
-
74
+ valueKey = _config$value === void 0 ? 'value' : _config$value,
75
+ _config$text = config.text,
76
+ textKey = _config$text === void 0 ? 'text' : _config$text,
77
+ _config$children = config.children,
78
+ childrenKey = _config$children === void 0 ? 'children' : _config$children;
90
79
  var value = node[valueKey],
91
- text = node[textKey],
92
- children = node[childrenKey],
93
- others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
94
-
80
+ text = node[textKey],
81
+ children = node[childrenKey],
82
+ others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
95
83
  var newNode = _objectSpread(_objectSpread({
96
84
  loading: false
97
85
  }, others), {}, {
@@ -101,61 +89,51 @@ var formatTree = function formatTree(tree, parent, config) {
101
89
  children: children,
102
90
  _parent: parent
103
91
  });
104
-
105
92
  if (newNode.children && newNode.children.length) {
106
93
  newNode.children = formatTree(newNode.children, newNode, config);
107
94
  }
108
-
109
95
  return newNode;
110
96
  });
111
97
  };
112
-
113
98
  var eachTree = function eachTree(tree, cb) {
114
99
  var i = 0;
115
100
  var node;
116
-
117
101
  while (node = tree[i++]) {
118
102
  if (cb(node) === true) {
119
103
  break;
120
104
  }
121
-
122
105
  if (node.children && node.children.length) {
123
106
  eachTree(node.children, cb);
124
107
  }
125
108
  }
126
109
  };
127
-
128
110
  var defaultConvertConfig = {
129
111
  topId: null,
130
112
  idKey: 'id',
131
113
  pidKey: 'pid',
132
114
  sortKey: ''
133
115
  };
134
-
135
116
  var convertListToOptions = function convertListToOptions(list, options) {
136
117
  var mergedOptions = _objectSpread(_objectSpread({}, defaultConvertConfig), options || {});
137
-
138
118
  var topId = mergedOptions.topId,
139
- idKey = mergedOptions.idKey,
140
- pidKey = mergedOptions.pidKey,
141
- sortKey = mergedOptions.sortKey;
119
+ idKey = mergedOptions.idKey,
120
+ pidKey = mergedOptions.pidKey,
121
+ sortKey = mergedOptions.sortKey;
142
122
  var result = [];
143
123
  var map = {};
144
124
  list.forEach(function (node) {
145
125
  node = _objectSpread({}, node);
146
126
  var _node = node,
147
- id = _node[idKey],
148
- pid = _node[pidKey];
149
- var children = map[pid] = map[pid] || []; // const children = map[pid] || []
150
-
127
+ id = _node[idKey],
128
+ pid = _node[pidKey];
129
+ var children = map[pid] = map[pid] || [];
130
+ // const children = map[pid] || []
151
131
  if (!result.length && pid === topId) {
152
132
  result = children;
153
133
  }
154
-
155
134
  children.push(node);
156
135
  node.children = map[id] || (map[id] = []);
157
136
  });
158
-
159
137
  if (sortKey) {
160
138
  Object.keys(map).forEach(function (i) {
161
139
  if (map[i].length > 1) {
@@ -165,39 +143,29 @@ var convertListToOptions = function convertListToOptions(list, options) {
165
143
  }
166
144
  });
167
145
  }
168
-
169
146
  map = null;
170
147
  return result;
171
148
  };
172
-
173
149
  var Tree = /*#__PURE__*/function () {
174
150
  function Tree(nodes, config) {
175
151
  var _this = this;
176
-
177
152
  _classCallCheck(this, Tree);
178
-
179
153
  _defineProperty(this, "nodes", void 0);
180
-
181
154
  _defineProperty(this, "config", void 0);
182
-
183
155
  _defineProperty(this, "isLeaf", function (node, lazy) {
184
156
  var leaf = node.leaf,
185
- children = node.children;
157
+ children = node.children;
186
158
  var hasChildren = Array.isArray(children) && Boolean(children.length);
187
159
  return leaf || !hasChildren && !lazy;
188
160
  });
189
-
190
161
  _defineProperty(this, "hasChildren", function (node, lazy) {
191
162
  var isLeaf = _this.isLeaf(node, lazy);
192
-
193
163
  if (isLeaf) {
194
164
  return false;
195
165
  }
196
-
197
166
  var children = node.children;
198
167
  return Array.isArray(children) && Boolean(children.length);
199
168
  });
200
-
201
169
  this.config = _objectSpread({
202
170
  value: 'value',
203
171
  text: 'text',
@@ -205,7 +173,6 @@ var Tree = /*#__PURE__*/function () {
205
173
  }, config || {});
206
174
  this.nodes = formatTree(nodes, null, this.config);
207
175
  }
208
-
209
176
  _createClass(Tree, [{
210
177
  key: "updateChildren",
211
178
  value: function updateChildren(nodes, parent) {
@@ -214,8 +181,8 @@ var Tree = /*#__PURE__*/function () {
214
181
  } else {
215
182
  parent.children = formatTree(nodes, parent, this.config);
216
183
  }
217
- } // for test
218
-
184
+ }
185
+ // for test
219
186
  }, {
220
187
  key: "getNodeByValue",
221
188
  value: function getNodeByValue(value) {
@@ -225,7 +192,6 @@ var Tree = /*#__PURE__*/function () {
225
192
  foundNode = node;
226
193
  return true;
227
194
  }
228
-
229
195
  return null;
230
196
  });
231
197
  return foundNode;
@@ -236,30 +202,23 @@ var Tree = /*#__PURE__*/function () {
236
202
  if (!value.length) {
237
203
  return [];
238
204
  }
239
-
240
205
  var pathNodes = [];
241
206
  var currentNodes = this.nodes;
242
-
243
207
  while (currentNodes && currentNodes.length) {
244
208
  var foundNode = currentNodes.find(function (node) {
245
209
  return node.value === value[node.level];
246
210
  });
247
-
248
211
  if (!foundNode) {
249
212
  break;
250
213
  }
251
-
252
214
  pathNodes.push(foundNode);
253
215
  currentNodes = foundNode.children;
254
216
  }
255
-
256
217
  return pathNodes;
257
218
  }
258
219
  }]);
259
-
260
220
  return Tree;
261
221
  }();
262
-
263
222
  var defaultProps = _objectSpread({
264
223
  className: '',
265
224
  style: {},
@@ -281,68 +240,62 @@ var defaultProps = _objectSpread({
281
240
  onChange: function onChange() {},
282
241
  onPathChange: function onPathChange() {}
283
242
  }, Popup.defaultProps);
284
-
285
243
  var InternalCascader = function InternalCascader(props) {
286
244
  var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
287
- className = _defaultProps$props.className,
288
- style = _defaultProps$props.style,
289
- poppable = _defaultProps$props.poppable,
290
- visible = _defaultProps$props.visible,
291
- options = _defaultProps$props.options,
292
- value = _defaultProps$props.value,
293
- title = _defaultProps$props.title,
294
- textKey = _defaultProps$props.textKey,
295
- valueKey = _defaultProps$props.valueKey,
296
- childrenKey = _defaultProps$props.childrenKey,
297
- convertConfig = _defaultProps$props.convertConfig,
298
- closeable = _defaultProps$props.closeable,
299
- closeIconPosition = _defaultProps$props.closeIconPosition,
300
- closeIcon = _defaultProps$props.closeIcon,
301
- lazy = _defaultProps$props.lazy,
302
- lazyLoad = _defaultProps$props.lazyLoad,
303
- onClose = _defaultProps$props.onClose,
304
- onChange = _defaultProps$props.onChange,
305
- onPathChange = _defaultProps$props.onPathChange;
306
-
245
+ className = _defaultProps$props.className,
246
+ style = _defaultProps$props.style,
247
+ poppable = _defaultProps$props.poppable,
248
+ visible = _defaultProps$props.visible,
249
+ options = _defaultProps$props.options,
250
+ value = _defaultProps$props.value,
251
+ title = _defaultProps$props.title,
252
+ textKey = _defaultProps$props.textKey,
253
+ valueKey = _defaultProps$props.valueKey,
254
+ childrenKey = _defaultProps$props.childrenKey,
255
+ convertConfig = _defaultProps$props.convertConfig,
256
+ closeable = _defaultProps$props.closeable,
257
+ closeIconPosition = _defaultProps$props.closeIconPosition,
258
+ closeIcon = _defaultProps$props.closeIcon,
259
+ lazy = _defaultProps$props.lazy,
260
+ lazyLoad = _defaultProps$props.lazyLoad,
261
+ onClose = _defaultProps$props.onClose,
262
+ onChange = _defaultProps$props.onChange,
263
+ onPathChange = _defaultProps$props.onPathChange;
307
264
  var _useState = useState('c1'),
308
- _useState2 = _slicedToArray(_useState, 2),
309
- tabvalue = _useState2[0],
310
- setTabvalue = _useState2[1];
311
-
265
+ _useState2 = _slicedToArray(_useState, 2),
266
+ tabvalue = _useState2[0],
267
+ setTabvalue = _useState2[1];
312
268
  var _useState3 = useState([]),
313
- _useState4 = _slicedToArray(_useState3, 2),
314
- optiosData = _useState4[0],
315
- setOptiosData = _useState4[1];
316
-
269
+ _useState4 = _slicedToArray(_useState3, 2),
270
+ optiosData = _useState4[0],
271
+ setOptiosData = _useState4[1];
317
272
  var isLazy = function isLazy() {
318
273
  return state.configs.lazy && Boolean(state.configs.lazyLoad);
319
274
  };
320
-
321
275
  var _useState5 = useState({
322
- optionsData: [],
323
- panes: [{
324
- nodes: [],
325
- selectedNode: [],
326
- paneKey: ''
327
- }],
328
- innerValue: value,
329
- tree: new Tree([], {}),
330
- tabsCursor: 0,
331
- initLoading: false,
332
- currentProcessNode: [],
333
- configs: {
334
- lazy: lazy,
335
- lazyLoad: lazyLoad,
336
- valueKey: valueKey,
337
- textKey: textKey,
338
- childrenKey: childrenKey,
339
- convertConfig: convertConfig
340
- },
341
- lazyLoadMap: new Map()
342
- }),
343
- _useState6 = _slicedToArray(_useState5, 1),
344
- state = _useState6[0];
345
-
276
+ optionsData: [],
277
+ panes: [{
278
+ nodes: [],
279
+ selectedNode: [],
280
+ paneKey: ''
281
+ }],
282
+ innerValue: value,
283
+ tree: new Tree([], {}),
284
+ tabsCursor: 0,
285
+ initLoading: false,
286
+ currentProcessNode: [],
287
+ configs: {
288
+ lazy: lazy,
289
+ lazyLoad: lazyLoad,
290
+ valueKey: valueKey,
291
+ textKey: textKey,
292
+ childrenKey: childrenKey,
293
+ convertConfig: convertConfig
294
+ },
295
+ lazyLoadMap: new Map()
296
+ }),
297
+ _useState6 = _slicedToArray(_useState5, 1),
298
+ state = _useState6[0];
346
299
  var b = cn('cascader');
347
300
  var classes = classNames(b(''));
348
301
  var classesPane = classNames(_defineProperty({}, "".concat(b(''), "-pane"), true));
@@ -357,7 +310,6 @@ var InternalCascader = function InternalCascader(props) {
357
310
  useEffect(function () {
358
311
  initData();
359
312
  }, [options]);
360
-
361
313
  var initData = /*#__PURE__*/function () {
362
314
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
363
315
  return _regeneratorRuntime.wrap(function _callee$(_context) {
@@ -366,24 +318,20 @@ var InternalCascader = function InternalCascader(props) {
366
318
  case 0:
367
319
  // 初始化开始处理数据
368
320
  state.lazyLoadMap.clear();
369
-
370
321
  if (convertConfig && Object.keys(convertConfig).length > 0) {
371
322
  state.optionsData = convertListToOptions(options, convertConfig);
372
323
  } else {
373
324
  state.optionsData = options;
374
325
  }
375
-
376
326
  state.tree = new Tree(state.optionsData, {
377
327
  value: state.configs.valueKey,
378
328
  text: state.configs.textKey,
379
329
  children: state.configs.childrenKey
380
330
  });
381
-
382
331
  if (!(isLazy() && !state.tree.nodes.length)) {
383
332
  _context.next = 6;
384
333
  break;
385
334
  }
386
-
387
335
  _context.next = 6;
388
336
  return invokeLazyLoad({
389
337
  root: true,
@@ -391,7 +339,6 @@ var InternalCascader = function InternalCascader(props) {
391
339
  text: '',
392
340
  value: ''
393
341
  });
394
-
395
342
  case 6:
396
343
  state.panes = [{
397
344
  nodes: state.tree.nodes,
@@ -400,7 +347,6 @@ var InternalCascader = function InternalCascader(props) {
400
347
  }];
401
348
  syncValue();
402
349
  setOptiosData(state.panes);
403
-
404
350
  case 9:
405
351
  case "end":
406
352
  return _context.stop();
@@ -408,13 +354,11 @@ var InternalCascader = function InternalCascader(props) {
408
354
  }
409
355
  }, _callee);
410
356
  }));
411
-
412
357
  return function initData() {
413
358
  return _ref.apply(this, arguments);
414
359
  };
415
- }(); // 处理有默认值时的数据
416
-
417
-
360
+ }();
361
+ // 处理有默认值时的数据
418
362
  var syncValue = /*#__PURE__*/function () {
419
363
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
420
364
  var currentValue, needToSync, parent, last, pathNodes;
@@ -423,49 +367,39 @@ var InternalCascader = function InternalCascader(props) {
423
367
  switch (_context3.prev = _context3.next) {
424
368
  case 0:
425
369
  currentValue = state.innerValue;
426
-
427
370
  if (!(currentValue === undefined || !state.tree.nodes.length)) {
428
371
  _context3.next = 3;
429
372
  break;
430
373
  }
431
-
432
374
  return _context3.abrupt("return");
433
-
434
375
  case 3:
435
376
  if (!(currentValue.length === 0)) {
436
377
  _context3.next = 6;
437
378
  break;
438
379
  }
439
-
440
- state.tabsCursor = 0; // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
441
-
380
+ state.tabsCursor = 0;
381
+ // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
442
382
  return _context3.abrupt("return");
443
-
444
383
  case 6:
445
384
  needToSync = currentValue;
446
-
447
385
  if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
448
386
  _context3.next = 19;
449
387
  break;
450
388
  }
451
-
452
389
  needToSync = [];
453
390
  parent = state.tree.nodes.find(function (node) {
454
391
  return node.value === currentValue[0];
455
392
  });
456
-
457
393
  if (!parent) {
458
394
  _context3.next = 19;
459
395
  break;
460
396
  }
461
-
462
397
  needToSync = [parent.value];
463
398
  state.initLoading = true;
464
399
  _context3.next = 15;
465
400
  return currentValue.slice(1).reduce( /*#__PURE__*/function () {
466
401
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(p, value) {
467
402
  var _parent$children;
468
-
469
403
  var parent, node;
470
404
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
471
405
  while (1) {
@@ -473,23 +407,18 @@ var InternalCascader = function InternalCascader(props) {
473
407
  case 0:
474
408
  _context2.next = 2;
475
409
  return p;
476
-
477
410
  case 2:
478
411
  parent = _context2.sent;
479
412
  _context2.next = 5;
480
413
  return invokeLazyLoad(parent);
481
-
482
414
  case 5:
483
415
  node = parent === null || parent === void 0 ? void 0 : (_parent$children = parent.children) === null || _parent$children === void 0 ? void 0 : _parent$children.find(function (item) {
484
416
  return item.value === value;
485
417
  });
486
-
487
418
  if (node) {
488
419
  needToSync.push(value);
489
420
  }
490
-
491
421
  return _context2.abrupt("return", Promise.resolve(node));
492
-
493
422
  case 8:
494
423
  case "end":
495
424
  return _context2.stop();
@@ -497,30 +426,25 @@ var InternalCascader = function InternalCascader(props) {
497
426
  }
498
427
  }, _callee2);
499
428
  }));
500
-
501
429
  return function (_x, _x2) {
502
430
  return _ref3.apply(this, arguments);
503
431
  };
504
432
  }(), Promise.resolve(parent));
505
-
506
433
  case 15:
507
434
  last = _context3.sent;
508
435
  _context3.next = 18;
509
436
  return invokeLazyLoad(last);
510
-
511
437
  case 18:
512
438
  state.initLoading = false;
513
-
514
439
  case 19:
515
440
  if (needToSync.length && currentValue === value) {
516
441
  pathNodes = state.tree.getPathNodesByValue(needToSync);
517
442
  pathNodes.forEach(function (node, index) {
518
- state.tabsCursor = index; // 当有默认值时,不触发 chooseItem 里的 emit 事件
519
-
443
+ state.tabsCursor = index;
444
+ // 当有默认值时,不触发 chooseItem 里的 emit 事件
520
445
  _chooseItem(node, true);
521
446
  });
522
447
  }
523
-
524
448
  case 20:
525
449
  case "end":
526
450
  return _context3.stop();
@@ -528,12 +452,10 @@ var InternalCascader = function InternalCascader(props) {
528
452
  }
529
453
  }, _callee3);
530
454
  }));
531
-
532
455
  return function syncValue() {
533
456
  return _ref2.apply(this, arguments);
534
457
  };
535
458
  }();
536
-
537
459
  var invokeLazyLoad = /*#__PURE__*/function () {
538
460
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(node) {
539
461
  var parent, lazyLoadPromise, nodes;
@@ -545,57 +467,44 @@ var InternalCascader = function InternalCascader(props) {
545
467
  _context4.next = 2;
546
468
  break;
547
469
  }
548
-
549
470
  return _context4.abrupt("return");
550
-
551
471
  case 2:
552
472
  if (state.configs.lazyLoad) {
553
473
  _context4.next = 5;
554
474
  break;
555
475
  }
556
-
557
476
  node.leaf = true;
558
477
  return _context4.abrupt("return");
559
-
560
478
  case 5:
561
479
  if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
562
480
  _context4.next = 7;
563
481
  break;
564
482
  }
565
-
566
483
  return _context4.abrupt("return");
567
-
568
484
  case 7:
569
485
  node.loading = true;
570
486
  parent = node.root ? null : node;
571
487
  lazyLoadPromise = state.lazyLoadMap.get(node);
572
-
573
488
  if (!lazyLoadPromise) {
574
489
  lazyLoadPromise = new Promise(function (resolve) {
575
490
  var _state$configs$lazyLo, _state$configs;
576
-
577
491
  // 外部必须resolve
578
492
  (_state$configs$lazyLo = (_state$configs = state.configs).lazyLoad) === null || _state$configs$lazyLo === void 0 ? void 0 : _state$configs$lazyLo.call(_state$configs, node, resolve);
579
493
  });
580
494
  state.lazyLoadMap.set(node, lazyLoadPromise);
581
495
  }
582
-
583
496
  _context4.next = 13;
584
497
  return lazyLoadPromise;
585
-
586
498
  case 13:
587
499
  nodes = _context4.sent;
588
-
589
500
  if (Array.isArray(nodes) && nodes.length > 0) {
590
501
  state.tree.updateChildren(nodes, parent);
591
502
  } else {
592
503
  // 如果加载完成后没有提供子节点,作为叶子节点处理
593
504
  node.leaf = true;
594
505
  }
595
-
596
506
  node.loading = false;
597
507
  state.lazyLoadMap["delete"](node);
598
-
599
508
  case 17:
600
509
  case "end":
601
510
  return _context4.stop();
@@ -603,27 +512,21 @@ var InternalCascader = function InternalCascader(props) {
603
512
  }
604
513
  }, _callee4);
605
514
  }));
606
-
607
515
  return function invokeLazyLoad(_x3) {
608
516
  return _ref4.apply(this, arguments);
609
517
  };
610
518
  }();
611
-
612
519
  var close = function close() {
613
520
  onClose && onClose();
614
521
  };
615
-
616
522
  var closePopup = function closePopup() {
617
523
  close();
618
524
  };
619
525
  /* type: 是否是静默模式,是的话不触发事件
620
526
  tabsCursor: tab的索引 */
621
-
622
-
623
527
  var _chooseItem = /*#__PURE__*/function () {
624
528
  var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(node, type) {
625
529
  var pathNodes, optionParams, level, _pathNodes, _optionParams;
626
-
627
530
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
628
531
  while (1) {
629
532
  switch (_context5.prev = _context5.next) {
@@ -632,19 +535,15 @@ var InternalCascader = function InternalCascader(props) {
632
535
  _context5.next = 2;
633
536
  break;
634
537
  }
635
-
636
538
  return _context5.abrupt("return");
637
-
638
539
  case 2:
639
540
  if (!state.tree.isLeaf(node, isLazy())) {
640
541
  _context5.next = 10;
641
542
  break;
642
543
  }
643
-
644
544
  node.leaf = true;
645
545
  state.panes[state.tabsCursor].selectedNode = node;
646
546
  state.panes = state.panes.slice(0, node.level + 1);
647
-
648
547
  if (!type) {
649
548
  pathNodes = state.panes.map(function (item) {
650
549
  return item.selectedNode;
@@ -655,17 +554,14 @@ var InternalCascader = function InternalCascader(props) {
655
554
  onChange(optionParams, pathNodes);
656
555
  onPathChange(optionParams, pathNodes);
657
556
  }
658
-
659
557
  setOptiosData(state.panes);
660
558
  close();
661
559
  return _context5.abrupt("return");
662
-
663
560
  case 10:
664
561
  if (!state.tree.hasChildren(node, isLazy())) {
665
562
  _context5.next = 20;
666
563
  break;
667
564
  }
668
-
669
565
  level = node.level + 1;
670
566
  state.panes[state.tabsCursor].selectedNode = node;
671
567
  state.panes = state.panes.slice(0, level);
@@ -677,7 +573,6 @@ var InternalCascader = function InternalCascader(props) {
677
573
  });
678
574
  setTabvalue("c".concat(state.tabsCursor + 1));
679
575
  setOptiosData(state.panes);
680
-
681
576
  if (!type) {
682
577
  _pathNodes = state.panes.map(function (item) {
683
578
  return item.selectedNode;
@@ -687,32 +582,23 @@ var InternalCascader = function InternalCascader(props) {
687
582
  });
688
583
  onPathChange(_optionParams, _pathNodes);
689
584
  }
690
-
691
585
  return _context5.abrupt("return");
692
-
693
586
  case 20:
694
587
  state.currentProcessNode = node;
695
-
696
588
  if (!node.loading) {
697
589
  _context5.next = 23;
698
590
  break;
699
591
  }
700
-
701
592
  return _context5.abrupt("return");
702
-
703
593
  case 23:
704
594
  _context5.next = 25;
705
595
  return invokeLazyLoad(node);
706
-
707
596
  case 25:
708
597
  if (state.currentProcessNode === node) {
709
598
  state.panes[state.tabsCursor].selectedNode = node;
710
-
711
599
  _chooseItem(node, type);
712
600
  }
713
-
714
601
  setOptiosData(state.panes);
715
-
716
602
  case 27:
717
603
  case "end":
718
604
  return _context5.stop();
@@ -720,12 +606,10 @@ var InternalCascader = function InternalCascader(props) {
720
606
  }
721
607
  }, _callee5);
722
608
  }));
723
-
724
609
  return function chooseItem(_x4, _x5) {
725
610
  return _ref5.apply(this, arguments);
726
611
  };
727
612
  }();
728
-
729
613
  var renderItem = function renderItem() {
730
614
  return React__default.createElement("div", {
731
615
  className: "".concat(classes, " ").concat(className),
@@ -737,7 +621,6 @@ var InternalCascader = function InternalCascader(props) {
737
621
  titleNode: function titleNode() {
738
622
  return optiosData.map(function (pane, index) {
739
623
  var _pane$selectedNode, _pane$selectedNode2;
740
-
741
624
  return React__default.createElement("div", {
742
625
  onClick: function onClick() {
743
626
  setTabvalue(pane.paneKey);
@@ -760,7 +643,6 @@ var InternalCascader = function InternalCascader(props) {
760
643
  className: classesPane
761
644
  }, pane.nodes && pane.nodes.map(function (node, index) {
762
645
  var _pane$selectedNode3;
763
-
764
646
  return React__default.createElement(CascaderItem, _objectSpread(_objectSpread({
765
647
  key: index
766
648
  }, props), {}, {
@@ -775,7 +657,6 @@ var InternalCascader = function InternalCascader(props) {
775
657
  className: classesPane
776
658
  }))));
777
659
  };
778
-
779
660
  return React__default.createElement(React__default.Fragment, null, poppable ? React__default.createElement(Popup, {
780
661
  popClass: "cascadar-popup",
781
662
  visible: visible,
@@ -788,7 +669,6 @@ var InternalCascader = function InternalCascader(props) {
788
669
  onClickCloseIcon: closePopup
789
670
  }, renderItem()) : renderItem());
790
671
  };
791
-
792
672
  var Cascader = React__default.forwardRef(InternalCascader);
793
673
  Cascader.defaultProps = defaultProps;
794
674
  Cascader.displayName = 'NutCascader';