@nutui/nutui-react 1.3.0 → 1.3.1-beta.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.
Files changed (158) hide show
  1. package/dist/esm/Audio/style/index.js +4 -0
  2. package/dist/esm/Audio.js +293 -0
  3. package/dist/esm/Calendar/style/index.js +1 -2
  4. package/dist/esm/Calendar.js +80 -33
  5. package/dist/esm/CalendarItem.js +429 -231
  6. package/dist/esm/Cascader/style/index.js +2 -0
  7. package/dist/esm/Cascader.js +788 -0
  8. package/dist/esm/ConfigProvider.js +16 -0
  9. package/dist/esm/DatePicker.js +37 -6
  10. package/dist/esm/Dialog.js +9 -16
  11. package/dist/esm/Elevator.js +16 -5
  12. package/dist/esm/Grid/style/index.js +2 -0
  13. package/dist/esm/Grid.js +91 -0
  14. package/dist/esm/GridItem/style/index.js +2 -0
  15. package/dist/esm/GridItem.js +99 -0
  16. package/dist/esm/ImagePreview/style/index.js +2 -0
  17. package/dist/esm/ImagePreview.js +257 -0
  18. package/dist/esm/Menu/style/index.js +3 -0
  19. package/dist/esm/Menu.js +153 -0
  20. package/dist/esm/MenuItem/style/index.js +3 -0
  21. package/dist/esm/MenuItem.js +197 -0
  22. package/dist/esm/NoticeBar.js +3 -2
  23. package/dist/esm/Notify.js +2 -1
  24. package/dist/esm/Popover.js +4 -11
  25. package/dist/esm/Range.js +2 -45
  26. package/dist/esm/Swipe/style/index.js +2 -0
  27. package/dist/esm/Swipe.js +265 -0
  28. package/dist/esm/Swiper.js +2 -1
  29. package/dist/esm/TabPane.js +5 -33
  30. package/dist/esm/Tabs.js +6 -196
  31. package/dist/esm/TextArea.js +45 -4
  32. package/dist/esm/Toast.js +2 -1
  33. package/dist/esm/nutui-react.es.js +8 -0
  34. package/dist/esm/render-4a3856cb.js +32 -0
  35. package/dist/esm/tabpane-c957ab14.js +33 -0
  36. package/dist/esm/tabs-a48583e9.js +196 -0
  37. package/dist/esm/useClientRect-839d18c5.js +44 -0
  38. package/dist/locales/base.d.ts +16 -0
  39. package/dist/locales/base.js +1 -1
  40. package/dist/locales/en-US.js +17 -1
  41. package/dist/locales/id-ID.js +17 -1
  42. package/dist/locales/zh-CN.js +17 -1
  43. package/dist/locales/zh-TW.js +17 -1
  44. package/dist/nutui.react.es.js +2338 -530
  45. package/dist/nutui.react.umd.js +2345 -529
  46. package/dist/packages/audio/audio.scss +80 -0
  47. package/dist/packages/calendar/calendar.scss +57 -36
  48. package/dist/packages/calendaritem/calendaritem.scss +0 -191
  49. package/dist/packages/cascader/cascader.scss +69 -0
  50. package/dist/packages/grid/grid.scss +10 -0
  51. package/dist/packages/griditem/griditem.scss +103 -0
  52. package/dist/packages/imagepreview/imagepreview.scss +51 -0
  53. package/dist/packages/menu/menu.scss +72 -0
  54. package/dist/packages/menuitem/menuitem.scss +90 -0
  55. package/dist/packages/popup/popup.scss +1 -1
  56. package/dist/packages/searchbar/searchbar.scss +1 -0
  57. package/dist/packages/shortpassword/shortpassword.scss +6 -1
  58. package/dist/packages/swipe/swipe.scss +33 -0
  59. package/dist/packages/textarea/textarea.scss +16 -1
  60. package/dist/style.css +1 -1
  61. package/dist/style.es.js +1 -1
  62. package/dist/styles/font/iconfont.js +20 -18
  63. package/dist/styles/themes/default.scss +8 -0
  64. package/dist/styles/variables.scss +59 -8
  65. package/dist/types/audio/__test__/audio.spec.d.ts +1 -0
  66. package/dist/types/audio/audio.d.ts +18 -0
  67. package/dist/types/audio/audio.taro.d.ts +18 -0
  68. package/dist/types/audio/demo.d.ts +4 -0
  69. package/dist/types/audio/index.d.ts +2 -0
  70. package/dist/types/audio/index.taro.d.ts +2 -0
  71. package/dist/types/backtop/__test__/backtop.spec.d.ts +1 -0
  72. package/dist/types/calendar/__tests__/calendar.spec.d.ts +1 -0
  73. package/dist/types/calendar/calendar.d.ts +22 -2
  74. package/dist/types/calendar/demo.d.ts +1 -0
  75. package/dist/types/calendaritem/calendaritem.d.ts +21 -3
  76. package/dist/types/cascader/__tests__/cascader.spec.d.ts +1 -0
  77. package/dist/types/cascader/cascader.d.ts +25 -0
  78. package/dist/types/cascader/cascader.taro.d.ts +25 -0
  79. package/dist/types/cascader/cascaderItem.d.ts +25 -0
  80. package/dist/types/cascader/cascaderItem.taro.d.ts +25 -0
  81. package/dist/types/cascader/demo.d.ts +3 -0
  82. package/dist/types/cascader/helper.d.ts +4 -0
  83. package/dist/types/cascader/index.d.ts +2 -0
  84. package/dist/types/cascader/index.taro.d.ts +2 -0
  85. package/dist/types/cascader/tree.d.ts +12 -0
  86. package/dist/types/cascader/types.d.ts +28 -0
  87. package/dist/types/checkbox/checkbox.d.ts +2 -2
  88. package/dist/types/checkbox/checkbox.taro.d.ts +2 -2
  89. package/dist/types/checkboxgroup/checkboxgroup.d.ts +2 -2
  90. package/dist/types/checkboxgroup/checkboxgroup.taro.d.ts +2 -2
  91. package/dist/types/dialog/__test__/dialog.spec.d.ts +1 -0
  92. package/dist/types/dialog/config.d.ts +3 -3
  93. package/dist/types/dialog/dialog.d.ts +2 -1
  94. package/dist/types/dialog/dialog.taro.d.ts +2 -1
  95. package/dist/types/fixednav/fixednav.d.ts +2 -2
  96. package/dist/types/grid/__test__/grid.spec.d.ts +1 -0
  97. package/dist/types/grid/demo.d.ts +3 -0
  98. package/dist/types/grid/grid.d.ts +16 -0
  99. package/dist/types/grid/grid.taro.d.ts +16 -0
  100. package/dist/types/grid/index.d.ts +2 -0
  101. package/dist/types/grid/index.taro.d.ts +2 -0
  102. package/dist/types/griditem/griditem.d.ts +20 -0
  103. package/dist/types/griditem/griditem.taro.d.ts +20 -0
  104. package/dist/types/griditem/index.d.ts +2 -0
  105. package/dist/types/griditem/index.taro.d.ts +2 -0
  106. package/dist/types/icon/icon.d.ts +1 -2
  107. package/dist/types/icon/icon.taro.d.ts +1 -2
  108. package/dist/types/imagepreview/__test__/imagepreview.spec.d.ts +1 -0
  109. package/dist/types/imagepreview/demo.d.ts +3 -0
  110. package/dist/types/imagepreview/imagepreview.d.ts +26 -0
  111. package/dist/types/imagepreview/imagepreview.taro.d.ts +26 -0
  112. package/dist/types/imagepreview/index.d.ts +2 -0
  113. package/dist/types/imagepreview/index.taro.d.ts +2 -0
  114. package/dist/types/input/__test__/input.spec.d.ts +1 -0
  115. package/dist/types/menu/__test__/menu.spec.d.ts +1 -0
  116. package/dist/types/menu/demo.d.ts +4 -0
  117. package/dist/types/menu/index.d.ts +2 -0
  118. package/dist/types/menu/index.taro.d.ts +2 -0
  119. package/dist/types/menu/menu.d.ts +12 -0
  120. package/dist/types/menu/menu.taro.d.ts +12 -0
  121. package/dist/types/menuitem/index.d.ts +2 -0
  122. package/dist/types/menuitem/index.taro.d.ts +2 -0
  123. package/dist/types/menuitem/menuitem.d.ts +23 -0
  124. package/dist/types/menuitem/menuitem.taro.d.ts +23 -0
  125. package/dist/types/notify/__test__/notify.spec.d.ts +1 -0
  126. package/dist/types/notify/notify.d.ts +13 -0
  127. package/dist/types/notify/notify.taro.d.ts +13 -0
  128. package/dist/types/nutui.react.d.ts +95 -1
  129. package/dist/types/picker/doc.en.d.ts +142 -0
  130. package/dist/types/picker/picker.d.ts +2 -2
  131. package/dist/types/picker/picker.taro.d.ts +2 -2
  132. package/dist/types/popup/popup.d.ts +1 -1
  133. package/dist/types/popup/popup.taro.d.ts +1 -1
  134. package/dist/types/shortpassword/shortpassword.taro.d.ts +3 -3
  135. package/dist/types/sidenavbar/sidenavbar.d.ts +14 -2
  136. package/dist/types/sidenavbar/sidenavbar.taro.d.ts +14 -2
  137. package/dist/types/sidenavbaritem/sidenavbaritem.d.ts +10 -2
  138. package/dist/types/sidenavbaritem/sidenavbaritem.taro.d.ts +10 -2
  139. package/dist/types/subsidenavbar/subsidenavbar.d.ts +13 -3
  140. package/dist/types/subsidenavbar/subsidenavbar.taro.d.ts +13 -3
  141. package/dist/types/swipe/__tests__/swipe.spec.d.ts +1 -0
  142. package/dist/types/swipe/demo.d.ts +3 -0
  143. package/dist/types/swipe/index.d.ts +2 -0
  144. package/dist/types/swipe/index.taro.d.ts +2 -0
  145. package/dist/types/swipe/swipe.d.ts +41 -0
  146. package/dist/types/swipe/swipe.taro.d.ts +41 -0
  147. package/dist/types/swiper/swiper.d.ts +1 -2
  148. package/dist/types/swiperitem/swiperitem.d.ts +1 -2
  149. package/dist/types/table/table.d.ts +2 -1
  150. package/dist/types/table/table.taro.d.ts +2 -1
  151. package/dist/types/table/types.d.ts +1 -1
  152. package/dist/types/textarea/__test__/textarea.spec.d.ts +1 -0
  153. package/dist/types/toast/toast.d.ts +21 -0
  154. package/dist/types/toast/toast.taro.d.ts +18 -0
  155. package/dist/types/virtuallist/type.d.ts +1 -1
  156. package/dist/types/virtuallist/virtuallist.d.ts +2 -1
  157. package/dist/types/virtuallist/virtuallist.taro.d.ts +2 -1
  158. package/package.json +4 -4
@@ -0,0 +1,788 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
5
+ import _createClass from "@babel/runtime/helpers/createClass";
6
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
9
+
10
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
11
+
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); }
13
+
14
+ 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
+ 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
+ import React__default, { useEffect, useState } from 'react';
19
+ import classNames from 'classnames';
20
+ import Popup from './Popup.js';
21
+ import { T as Tabs } from './tabs-a48583e9.js';
22
+ import { T as TabPane } from './tabpane-c957ab14.js';
23
+ import { I as Icon } from './icon-8dc4de10.js';
24
+ import { c as cn } from './bem-893ad28d.js';
25
+ import './Icon.js';
26
+ import '@bem-react/classname';
27
+ var defaultProps$1 = {
28
+ data: {
29
+ text: '',
30
+ value: '',
31
+ paneKey: '',
32
+ disabled: false,
33
+ loading: false,
34
+ children: []
35
+ },
36
+ checked: false,
37
+ chooseItem: function chooseItem() {}
38
+ };
39
+
40
+ var InternalCascaderItem = function InternalCascaderItem(props) {
41
+ var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props),
42
+ data = _defaultProps$1$props.data,
43
+ checked = _defaultProps$1$props.checked,
44
+ chooseItem = _defaultProps$1$props.chooseItem;
45
+
46
+ var b = cn('cascader-item');
47
+ var classes = classNames({
48
+ active: checked,
49
+ disabled: data.disabled
50
+ }, b(''));
51
+ var classesTitle = classNames(_defineProperty({}, "".concat(b(''), "__title"), true));
52
+ useEffect(function () {
53
+ initData();
54
+ }, [data]);
55
+
56
+ var initData = function initData() {// console.log('------data', data)
57
+ };
58
+
59
+ return React__default.createElement("div", {
60
+ className: classes,
61
+ onClick: function onClick() {
62
+ chooseItem(data);
63
+ }
64
+ }, React__default.createElement("div", {
65
+ className: classesTitle
66
+ }, data.text), data.loading ? React__default.createElement(Icon, {
67
+ color: "#969799",
68
+ className: "nut-cascader-item__icon-loading",
69
+ name: "loading"
70
+ }) : React__default.createElement(Icon, {
71
+ className: "".concat(checked ? b('icon-check') : ''),
72
+ name: "checklist"
73
+ }));
74
+ };
75
+
76
+ var CascaderItem = React__default.forwardRef(InternalCascaderItem);
77
+ CascaderItem.defaultProps = defaultProps$1;
78
+ CascaderItem.displayName = 'NutCascaderItem';
79
+
80
+ var formatTree = function formatTree(tree, parent, config) {
81
+ return tree.map(function (node) {
82
+ var _config$value = config.value,
83
+ valueKey = _config$value === void 0 ? 'value' : _config$value,
84
+ _config$text = config.text,
85
+ textKey = _config$text === void 0 ? 'text' : _config$text,
86
+ _config$children = config.children,
87
+ childrenKey = _config$children === void 0 ? 'children' : _config$children;
88
+
89
+ var value = node[valueKey],
90
+ text = node[textKey],
91
+ children = node[childrenKey],
92
+ others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
93
+
94
+ var newNode = _objectSpread(_objectSpread({
95
+ loading: false
96
+ }, others), {}, {
97
+ level: parent ? (parent && parent.level || 0) + 1 : 0,
98
+ value: value,
99
+ text: text,
100
+ children: children,
101
+ _parent: parent
102
+ });
103
+
104
+ if (newNode.children && newNode.children.length) {
105
+ newNode.children = formatTree(newNode.children, newNode, config);
106
+ }
107
+
108
+ return newNode;
109
+ });
110
+ };
111
+
112
+ var eachTree = function eachTree(tree, cb) {
113
+ var i = 0;
114
+ var node;
115
+
116
+ while (node = tree[i++]) {
117
+ if (cb(node) === true) {
118
+ break;
119
+ }
120
+
121
+ if (node.children && node.children.length) {
122
+ eachTree(node.children, cb);
123
+ }
124
+ }
125
+ };
126
+
127
+ var defaultConvertConfig = {
128
+ topId: null,
129
+ idKey: 'id',
130
+ pidKey: 'pid',
131
+ sortKey: ''
132
+ };
133
+
134
+ var convertListToOptions = function convertListToOptions(list, options) {
135
+ var mergedOptions = _objectSpread(_objectSpread({}, defaultConvertConfig), options || {});
136
+
137
+ var topId = mergedOptions.topId,
138
+ idKey = mergedOptions.idKey,
139
+ pidKey = mergedOptions.pidKey,
140
+ sortKey = mergedOptions.sortKey;
141
+ var result = [];
142
+ var map = {};
143
+ list.forEach(function (node) {
144
+ node = _objectSpread({}, node);
145
+ var _node = node,
146
+ id = _node[idKey],
147
+ pid = _node[pidKey];
148
+ var children = map[pid] = map[pid] || []; // const children = map[pid] || []
149
+
150
+ if (!result.length && pid === topId) {
151
+ result = children;
152
+ }
153
+
154
+ children.push(node);
155
+ node.children = map[id] || (map[id] = []);
156
+ });
157
+
158
+ if (sortKey) {
159
+ Object.keys(map).forEach(function (i) {
160
+ if (map[i].length > 1) {
161
+ map[i].sort(function (a, b) {
162
+ return a[sortKey] - b[sortKey];
163
+ });
164
+ }
165
+ });
166
+ }
167
+
168
+ map = null;
169
+ return result;
170
+ };
171
+
172
+ var Tree = /*#__PURE__*/function () {
173
+ function Tree(nodes, config) {
174
+ var _this = this;
175
+
176
+ _classCallCheck(this, Tree);
177
+
178
+ _defineProperty(this, "nodes", void 0);
179
+
180
+ _defineProperty(this, "config", void 0);
181
+
182
+ _defineProperty(this, "isLeaf", function (node, lazy) {
183
+ var leaf = node.leaf,
184
+ children = node.children;
185
+ var hasChildren = Array.isArray(children) && Boolean(children.length);
186
+ return leaf || !hasChildren && !lazy;
187
+ });
188
+
189
+ _defineProperty(this, "hasChildren", function (node, lazy) {
190
+ var isLeaf = _this.isLeaf(node, lazy);
191
+
192
+ if (isLeaf) {
193
+ return false;
194
+ }
195
+
196
+ var children = node.children;
197
+ return Array.isArray(children) && Boolean(children.length);
198
+ });
199
+
200
+ this.config = _objectSpread({
201
+ value: 'value',
202
+ text: 'text',
203
+ children: 'children'
204
+ }, config || {});
205
+ this.nodes = formatTree(nodes, null, this.config);
206
+ }
207
+
208
+ _createClass(Tree, [{
209
+ key: "updateChildren",
210
+ value: function updateChildren(nodes, parent) {
211
+ if (!parent) {
212
+ this.nodes = formatTree(nodes, null, this.config);
213
+ } else {
214
+ parent.children = formatTree(nodes, parent, this.config);
215
+ }
216
+ } // for test
217
+
218
+ }, {
219
+ key: "getNodeByValue",
220
+ value: function getNodeByValue(value) {
221
+ var foundNode;
222
+ eachTree(this.nodes, function (node) {
223
+ if (node.value === value) {
224
+ foundNode = node;
225
+ return true;
226
+ }
227
+
228
+ return null;
229
+ });
230
+ return foundNode;
231
+ }
232
+ }, {
233
+ key: "getPathNodesByValue",
234
+ value: function getPathNodesByValue(value) {
235
+ if (!value.length) {
236
+ return [];
237
+ }
238
+
239
+ var pathNodes = [];
240
+ var currentNodes = this.nodes;
241
+
242
+ while (currentNodes && currentNodes.length) {
243
+ var foundNode = currentNodes.find(function (node) {
244
+ return node.value === value[node.level];
245
+ });
246
+
247
+ if (!foundNode) {
248
+ break;
249
+ }
250
+
251
+ pathNodes.push(foundNode);
252
+ currentNodes = foundNode.children;
253
+ }
254
+
255
+ return pathNodes;
256
+ }
257
+ }]);
258
+
259
+ return Tree;
260
+ }();
261
+
262
+ var defaultProps = _objectSpread({
263
+ className: '',
264
+ style: {},
265
+ visible: false,
266
+ options: [],
267
+ value: [],
268
+ title: '',
269
+ textKey: 'text',
270
+ valueKey: 'value',
271
+ childrenKey: 'children',
272
+ convertConfig: {},
273
+ closeable: false,
274
+ closeIconPosition: 'top-right',
275
+ closeIcon: 'close',
276
+ lazy: false,
277
+ lazyLoad: function lazyLoad() {},
278
+ onClose: function onClose() {},
279
+ onChange: function onChange() {},
280
+ onPathChange: function onPathChange() {}
281
+ }, Popup.defaultProps);
282
+
283
+ var InternalCascader = function InternalCascader(props) {
284
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
285
+ className = _defaultProps$props.className,
286
+ style = _defaultProps$props.style,
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
+
304
+ var _useState = useState('c1'),
305
+ _useState2 = _slicedToArray(_useState, 2),
306
+ tabvalue = _useState2[0],
307
+ setTabvalue = _useState2[1];
308
+
309
+ var _useState3 = useState([]),
310
+ _useState4 = _slicedToArray(_useState3, 2),
311
+ optiosData = _useState4[0],
312
+ setOptiosData = _useState4[1];
313
+
314
+ var isLazy = function isLazy() {
315
+ return state.configs.lazy && Boolean(state.configs.lazyLoad);
316
+ };
317
+
318
+ 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
+
343
+ var b = cn('cascader');
344
+ var classes = classNames(b(''));
345
+ var classesPane = classNames(_defineProperty({}, "".concat(b(''), "-pane"), true));
346
+ useEffect(function () {
347
+ initData();
348
+ }, []);
349
+ useEffect(function () {
350
+ if (value !== state.innerValue) {
351
+ state.innerValue = value;
352
+ }
353
+ }, [value]);
354
+ useEffect(function () {
355
+ initData();
356
+ }, [options]);
357
+
358
+ var initData = /*#__PURE__*/function () {
359
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
360
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
361
+ while (1) {
362
+ switch (_context.prev = _context.next) {
363
+ case 0:
364
+ // 初始化开始处理数据
365
+ state.lazyLoadMap.clear();
366
+
367
+ if (convertConfig && Object.keys(convertConfig).length > 0) {
368
+ state.optionsData = convertListToOptions(options, convertConfig);
369
+ } else {
370
+ state.optionsData = options;
371
+ }
372
+
373
+ state.tree = new Tree(state.optionsData, {
374
+ value: state.configs.valueKey,
375
+ text: state.configs.textKey,
376
+ children: state.configs.childrenKey
377
+ });
378
+
379
+ if (!(isLazy() && !state.tree.nodes.length)) {
380
+ _context.next = 6;
381
+ break;
382
+ }
383
+
384
+ _context.next = 6;
385
+ return invokeLazyLoad({
386
+ root: true,
387
+ loading: true,
388
+ text: '',
389
+ value: ''
390
+ });
391
+
392
+ case 6:
393
+ state.panes = [{
394
+ nodes: state.tree.nodes,
395
+ selectedNode: null,
396
+ paneKey: 'c1'
397
+ }];
398
+ syncValue();
399
+ setOptiosData(state.panes);
400
+
401
+ case 9:
402
+ case "end":
403
+ return _context.stop();
404
+ }
405
+ }
406
+ }, _callee);
407
+ }));
408
+
409
+ return function initData() {
410
+ return _ref.apply(this, arguments);
411
+ };
412
+ }(); // 处理有默认值时的数据
413
+
414
+
415
+ var syncValue = /*#__PURE__*/function () {
416
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
417
+ var currentValue, needToSync, parent, last, pathNodes;
418
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
419
+ while (1) {
420
+ switch (_context3.prev = _context3.next) {
421
+ case 0:
422
+ currentValue = state.innerValue;
423
+
424
+ if (!(currentValue === undefined || !state.tree.nodes.length)) {
425
+ _context3.next = 3;
426
+ break;
427
+ }
428
+
429
+ return _context3.abrupt("return");
430
+
431
+ case 3:
432
+ if (!(currentValue.length === 0)) {
433
+ _context3.next = 6;
434
+ break;
435
+ }
436
+
437
+ state.tabsCursor = 0; // state.panes = [{ nodes: state.tree.nodes, selectedNode: null }];
438
+
439
+ return _context3.abrupt("return");
440
+
441
+ case 6:
442
+ needToSync = currentValue;
443
+
444
+ if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
445
+ _context3.next = 19;
446
+ break;
447
+ }
448
+
449
+ needToSync = [];
450
+ parent = state.tree.nodes.find(function (node) {
451
+ return node.value === currentValue[0];
452
+ });
453
+
454
+ if (!parent) {
455
+ _context3.next = 19;
456
+ break;
457
+ }
458
+
459
+ needToSync = [parent.value];
460
+ state.initLoading = true;
461
+ _context3.next = 15;
462
+ return currentValue.slice(1).reduce( /*#__PURE__*/function () {
463
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(p, value) {
464
+ var _parent$children;
465
+
466
+ var parent, node;
467
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
468
+ while (1) {
469
+ switch (_context2.prev = _context2.next) {
470
+ case 0:
471
+ _context2.next = 2;
472
+ return p;
473
+
474
+ case 2:
475
+ parent = _context2.sent;
476
+ _context2.next = 5;
477
+ return invokeLazyLoad(parent);
478
+
479
+ case 5:
480
+ 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
+ return item.value === value;
482
+ });
483
+
484
+ if (node) {
485
+ needToSync.push(value);
486
+ }
487
+
488
+ return _context2.abrupt("return", Promise.resolve(node));
489
+
490
+ case 8:
491
+ case "end":
492
+ return _context2.stop();
493
+ }
494
+ }
495
+ }, _callee2);
496
+ }));
497
+
498
+ return function (_x, _x2) {
499
+ return _ref3.apply(this, arguments);
500
+ };
501
+ }(), Promise.resolve(parent));
502
+
503
+ case 15:
504
+ last = _context3.sent;
505
+ _context3.next = 18;
506
+ return invokeLazyLoad(last);
507
+
508
+ case 18:
509
+ state.initLoading = false;
510
+
511
+ case 19:
512
+ if (needToSync.length && currentValue === value) {
513
+ pathNodes = state.tree.getPathNodesByValue(needToSync);
514
+ pathNodes.forEach(function (node, index) {
515
+ state.tabsCursor = index; // 当有默认值时,不触发 chooseItem 里的 emit 事件
516
+
517
+ _chooseItem(node, true);
518
+ });
519
+ }
520
+
521
+ case 20:
522
+ case "end":
523
+ return _context3.stop();
524
+ }
525
+ }
526
+ }, _callee3);
527
+ }));
528
+
529
+ return function syncValue() {
530
+ return _ref2.apply(this, arguments);
531
+ };
532
+ }();
533
+
534
+ var invokeLazyLoad = /*#__PURE__*/function () {
535
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(node) {
536
+ var parent, lazyLoadPromise, nodes;
537
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
538
+ while (1) {
539
+ switch (_context4.prev = _context4.next) {
540
+ case 0:
541
+ if (node) {
542
+ _context4.next = 2;
543
+ break;
544
+ }
545
+
546
+ return _context4.abrupt("return");
547
+
548
+ case 2:
549
+ if (state.configs.lazyLoad) {
550
+ _context4.next = 5;
551
+ break;
552
+ }
553
+
554
+ node.leaf = true;
555
+ return _context4.abrupt("return");
556
+
557
+ case 5:
558
+ if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
559
+ _context4.next = 7;
560
+ break;
561
+ }
562
+
563
+ return _context4.abrupt("return");
564
+
565
+ case 7:
566
+ node.loading = true;
567
+ parent = node.root ? null : node;
568
+ lazyLoadPromise = state.lazyLoadMap.get(node);
569
+
570
+ if (!lazyLoadPromise) {
571
+ lazyLoadPromise = new Promise(function (resolve) {
572
+ var _state$configs$lazyLo, _state$configs;
573
+
574
+ // 外部必须resolve
575
+ (_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
+ });
577
+ state.lazyLoadMap.set(node, lazyLoadPromise);
578
+ }
579
+
580
+ _context4.next = 13;
581
+ return lazyLoadPromise;
582
+
583
+ case 13:
584
+ nodes = _context4.sent;
585
+
586
+ if (Array.isArray(nodes) && nodes.length > 0) {
587
+ state.tree.updateChildren(nodes, parent);
588
+ } else {
589
+ // 如果加载完成后没有提供子节点,作为叶子节点处理
590
+ node.leaf = true;
591
+ }
592
+
593
+ node.loading = false;
594
+ state.lazyLoadMap["delete"](node);
595
+
596
+ case 17:
597
+ case "end":
598
+ return _context4.stop();
599
+ }
600
+ }
601
+ }, _callee4);
602
+ }));
603
+
604
+ return function invokeLazyLoad(_x3) {
605
+ return _ref4.apply(this, arguments);
606
+ };
607
+ }();
608
+
609
+ var close = function close() {
610
+ onClose && onClose();
611
+ };
612
+
613
+ var closePopup = function closePopup() {
614
+ close();
615
+ };
616
+ /* type: 是否是静默模式,是的话不触发事件
617
+ tabsCursor: tab的索引 */
618
+
619
+
620
+ var _chooseItem = /*#__PURE__*/function () {
621
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(node, type) {
622
+ var pathNodes, optionParams, level, _pathNodes, _optionParams;
623
+
624
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
625
+ while (1) {
626
+ switch (_context5.prev = _context5.next) {
627
+ case 0:
628
+ if (!(!type && node.disabled || !state.panes[state.tabsCursor])) {
629
+ _context5.next = 2;
630
+ break;
631
+ }
632
+
633
+ return _context5.abrupt("return");
634
+
635
+ case 2:
636
+ if (!state.tree.isLeaf(node, isLazy())) {
637
+ _context5.next = 10;
638
+ break;
639
+ }
640
+
641
+ node.leaf = true;
642
+ state.panes[state.tabsCursor].selectedNode = node;
643
+ state.panes = state.panes.slice(0, node.level + 1);
644
+
645
+ if (!type) {
646
+ pathNodes = state.panes.map(function (item) {
647
+ return item.selectedNode;
648
+ });
649
+ optionParams = pathNodes.map(function (item) {
650
+ return item.value;
651
+ });
652
+ onChange(optionParams, pathNodes);
653
+ onPathChange(optionParams, pathNodes);
654
+ }
655
+
656
+ setOptiosData(state.panes);
657
+ close();
658
+ return _context5.abrupt("return");
659
+
660
+ case 10:
661
+ if (!state.tree.hasChildren(node, isLazy())) {
662
+ _context5.next = 20;
663
+ break;
664
+ }
665
+
666
+ level = node.level + 1;
667
+ state.panes[state.tabsCursor].selectedNode = node;
668
+ state.panes = state.panes.slice(0, level);
669
+ state.tabsCursor = level;
670
+ state.panes.push({
671
+ nodes: node.children || [],
672
+ selectedNode: null,
673
+ paneKey: "c".concat(state.tabsCursor + 1)
674
+ });
675
+ setTabvalue("c".concat(state.tabsCursor + 1));
676
+ setOptiosData(state.panes);
677
+
678
+ if (!type) {
679
+ _pathNodes = state.panes.map(function (item) {
680
+ return item.selectedNode;
681
+ });
682
+ _optionParams = _pathNodes.map(function (item) {
683
+ return item === null || item === void 0 ? void 0 : item.value;
684
+ });
685
+ onPathChange(_optionParams, _pathNodes);
686
+ }
687
+
688
+ return _context5.abrupt("return");
689
+
690
+ case 20:
691
+ state.currentProcessNode = node;
692
+
693
+ if (!node.loading) {
694
+ _context5.next = 23;
695
+ break;
696
+ }
697
+
698
+ return _context5.abrupt("return");
699
+
700
+ case 23:
701
+ _context5.next = 25;
702
+ return invokeLazyLoad(node);
703
+
704
+ case 25:
705
+ if (state.currentProcessNode === node) {
706
+ state.panes[state.tabsCursor].selectedNode = node;
707
+
708
+ _chooseItem(node, type);
709
+ }
710
+
711
+ setOptiosData(state.panes);
712
+
713
+ case 27:
714
+ case "end":
715
+ return _context5.stop();
716
+ }
717
+ }
718
+ }, _callee5);
719
+ }));
720
+
721
+ return function chooseItem(_x4, _x5) {
722
+ return _ref5.apply(this, arguments);
723
+ };
724
+ }();
725
+
726
+ return React__default.createElement("div", {
727
+ className: "".concat(classes, " ").concat(className),
728
+ style: style
729
+ }, React__default.createElement(Popup, {
730
+ popClass: "cascadar-popup",
731
+ visible: visible,
732
+ position: "bottom",
733
+ round: true,
734
+ closeable: closeable,
735
+ closeIconPosition: closeIconPosition,
736
+ closeIcon: closeIcon,
737
+ onClickOverlay: closePopup,
738
+ onClickCloseIcon: closePopup
739
+ }, React__default.createElement("div", {
740
+ className: b('title')
741
+ }, title), React__default.createElement(Tabs, {
742
+ value: tabvalue,
743
+ titleNode: function titleNode() {
744
+ return optiosData.map(function (pane, index) {
745
+ var _pane$selectedNode, _pane$selectedNode2;
746
+
747
+ return React__default.createElement("div", {
748
+ onClick: function onClick() {
749
+ setTabvalue(pane.paneKey);
750
+ state.tabsCursor = index;
751
+ },
752
+ className: "nut-tabs__titles-item ".concat(tabvalue === pane.paneKey ? 'active' : ''),
753
+ key: pane.paneKey
754
+ }, React__default.createElement("span", {
755
+ className: "nut-tabs__titles-item__text"
756
+ }, !state.initLoading && state.panes.length && (pane === null || pane === void 0 ? void 0 : (_pane$selectedNode = pane.selectedNode) === null || _pane$selectedNode === void 0 ? void 0 : _pane$selectedNode.text), !state.initLoading && state.panes.length && !(pane !== null && pane !== void 0 && (_pane$selectedNode2 = pane.selectedNode) !== null && _pane$selectedNode2 !== void 0 && _pane$selectedNode2.text) && '请选择', !(!state.initLoading && state.panes.length) && 'Loading...'), React__default.createElement("span", {
757
+ className: "nut-tabs__titles-item__line"
758
+ }));
759
+ });
760
+ }
761
+ }, !state.initLoading && state.panes.length ? optiosData.map(function (pane) {
762
+ return React__default.createElement(TabPane, {
763
+ key: pane.paneKey,
764
+ paneKey: pane.paneKey
765
+ }, React__default.createElement("div", {
766
+ className: classesPane
767
+ }, pane.nodes && pane.nodes.map(function (node, index) {
768
+ var _pane$selectedNode3;
769
+
770
+ return React__default.createElement(CascaderItem, _objectSpread(_objectSpread({
771
+ key: index
772
+ }, props), {}, {
773
+ data: node,
774
+ checked: ((_pane$selectedNode3 = pane.selectedNode) === null || _pane$selectedNode3 === void 0 ? void 0 : _pane$selectedNode3.value) === node.value,
775
+ chooseItem: function chooseItem(node) {
776
+ return _chooseItem(node, false);
777
+ }
778
+ }));
779
+ })));
780
+ }) : React__default.createElement(TabPane, null, React__default.createElement("div", {
781
+ className: classesPane
782
+ })))));
783
+ };
784
+
785
+ var Cascader = React__default.forwardRef(InternalCascader);
786
+ Cascader.defaultProps = defaultProps;
787
+ Cascader.displayName = 'NutCascader';
788
+ export { Cascader as default };