@nutui/nutui-react 2.3.11 → 2.3.12

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 (252) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/esm/ActionSheet.js +30 -86
  3. package/dist/esm/Address.js +80 -184
  4. package/dist/esm/Animate.js +21 -49
  5. package/dist/esm/AnimatingNumbers.js +47 -136
  6. package/dist/esm/Audio.js +88 -159
  7. package/dist/esm/Avatar.js +44 -91
  8. package/dist/esm/AvatarCropper.js +149 -268
  9. package/dist/esm/AvatarGroup.js +13 -44
  10. package/dist/esm/BackTop.js +34 -75
  11. package/dist/esm/Badge.js +0 -3
  12. package/dist/esm/Barrage.js +49 -83
  13. package/dist/esm/Button.js +0 -4
  14. package/dist/esm/Calendar.js +27 -119
  15. package/dist/esm/CalendarCard.js +180 -291
  16. package/dist/esm/CalendarItem.js +253 -314
  17. package/dist/esm/Card.js +38 -72
  18. package/dist/esm/Cascader.js +0 -17
  19. package/dist/esm/Cell.js +27 -62
  20. package/dist/esm/CellGroup.js +16 -45
  21. package/dist/esm/Checkbox.js +0 -6
  22. package/dist/esm/CheckboxGroup.js +49 -88
  23. package/dist/esm/CircleProgress.js +42 -93
  24. package/dist/esm/Col.js +17 -48
  25. package/dist/esm/Collapse.js +18 -49
  26. package/dist/esm/CollapseItem.js +0 -3
  27. package/dist/esm/ConfigProvider.js +3 -4
  28. package/dist/esm/CountDown.js +62 -101
  29. package/dist/esm/DatePicker.js +87 -127
  30. package/dist/esm/Dialog.js +117 -203
  31. package/dist/esm/Divider.js +16 -36
  32. package/dist/esm/Drag.js +32 -76
  33. package/dist/esm/Elevator.js +94 -133
  34. package/dist/esm/Ellipsis.js +71 -92
  35. package/dist/esm/Empty.js +31 -71
  36. package/dist/esm/FixedNav.js +32 -81
  37. package/dist/esm/Form.js +28 -61
  38. package/dist/esm/FormItem.js +0 -3
  39. package/dist/esm/Grid.js +27 -52
  40. package/dist/esm/GridItem.js +0 -4
  41. package/dist/esm/Image.js +47 -102
  42. package/dist/esm/ImagePreview.js +82 -135
  43. package/dist/esm/Indicator.js +0 -2
  44. package/dist/esm/InfiniteLoading.js +77 -159
  45. package/dist/esm/Input.js +57 -125
  46. package/dist/esm/InputNumber.js +66 -96
  47. package/dist/esm/Layout.js +4 -28
  48. package/dist/esm/Loading.js +13 -40
  49. package/dist/esm/Menu.js +51 -114
  50. package/dist/esm/MenuItem.js +0 -13
  51. package/dist/esm/NavBar.js +46 -85
  52. package/dist/esm/NoticeBar.js +153 -226
  53. package/dist/esm/Notify.js +87 -195
  54. package/dist/esm/NumberKeyboard.js +84 -150
  55. package/dist/esm/Overlay.js +0 -8
  56. package/dist/esm/Pagination.js +58 -97
  57. package/dist/esm/Picker.js +215 -283
  58. package/dist/esm/Popover.js +111 -160
  59. package/dist/esm/Popup.js +0 -12
  60. package/dist/esm/Price.js +23 -60
  61. package/dist/esm/Progress.js +47 -77
  62. package/dist/esm/PullToRefresh.js +94 -202
  63. package/dist/esm/Radio.js +0 -6
  64. package/dist/esm/RadioGroup.js +23 -56
  65. package/dist/esm/Range.js +113 -177
  66. package/dist/esm/Rate.js +48 -95
  67. package/dist/esm/Row.js +19 -43
  68. package/dist/esm/SafeArea.js +0 -2
  69. package/dist/esm/SearchBar.js +52 -119
  70. package/dist/esm/ShortPassword.js +58 -106
  71. package/dist/esm/SideNavBar.js +34 -59
  72. package/dist/esm/SideNavBarItem.js +7 -36
  73. package/dist/esm/Signature.js +49 -84
  74. package/dist/esm/Skeleton.js +31 -68
  75. package/dist/esm/Space.js +7 -34
  76. package/dist/esm/Step.js +35 -64
  77. package/dist/esm/Steps.js +16 -40
  78. package/dist/esm/Sticky.js +64 -109
  79. package/dist/esm/SubSideNavBar.js +42 -71
  80. package/dist/esm/Swipe.js +79 -143
  81. package/dist/esm/Swiper.js +136 -183
  82. package/dist/esm/SwiperItem.js +13 -38
  83. package/dist/esm/Switch.js +20 -53
  84. package/dist/esm/TabPane.js +6 -30
  85. package/dist/esm/Tabbar.js +29 -60
  86. package/dist/esm/TabbarItem.js +0 -4
  87. package/dist/esm/Table.js +92 -141
  88. package/dist/esm/Tabs.js +0 -7
  89. package/dist/esm/Tag.js +30 -74
  90. package/dist/esm/TextArea.js +37 -82
  91. package/dist/esm/TimeDetail.js +20 -58
  92. package/dist/esm/TimeSelect.js +57 -95
  93. package/dist/esm/Toast.js +110 -219
  94. package/dist/esm/Tour.js +88 -132
  95. package/dist/esm/TrendArrow.js +32 -74
  96. package/dist/esm/Uploader.js +226 -346
  97. package/dist/esm/UserContext.js +1 -1
  98. package/dist/esm/Video.js +34 -67
  99. package/dist/esm/VirtualList.js +127 -160
  100. package/dist/esm/WaterMark.js +24 -68
  101. package/dist/esm/badge2.js +23 -53
  102. package/dist/esm/button2.js +30 -63
  103. package/dist/esm/can-use-dom.js +1 -1
  104. package/dist/esm/cascader2.js +308 -538
  105. package/dist/esm/checkbox2.js +59 -96
  106. package/dist/esm/collapseitem2.js +48 -86
  107. package/dist/esm/configprovider2.js +43 -1003
  108. package/dist/esm/context.js +1 -1
  109. package/dist/esm/context2.js +1 -1
  110. package/dist/esm/context3.js +1 -1
  111. package/dist/esm/context4.js +1 -1
  112. package/dist/esm/context5.js +8 -8
  113. package/dist/esm/date.js +88 -66
  114. package/dist/esm/formitem2.js +236 -1526
  115. package/dist/esm/get-scroll-parent.js +8 -10
  116. package/dist/esm/griditem2.js +34 -52
  117. package/dist/esm/index.js +5 -12
  118. package/dist/esm/indicator2.js +13 -42
  119. package/dist/esm/menuitem2.js +81 -124
  120. package/dist/esm/overlay2.js +39 -78
  121. package/dist/esm/pad-zero.js +3 -4
  122. package/dist/esm/popup2.js +79 -124
  123. package/dist/esm/px-check.js +2 -2
  124. package/dist/esm/radio2.js +48 -79
  125. package/dist/esm/raf.js +5 -3
  126. package/dist/esm/render.js +17 -54
  127. package/dist/esm/safearea2.js +3 -5
  128. package/dist/esm/supports-passive.js +3 -3
  129. package/dist/esm/tabbaritem2.js +42 -58
  130. package/dist/esm/tabs2.js +82 -120
  131. package/dist/esm/tslib.es6.js +47 -0
  132. package/dist/esm/types/src/packages/button/demos/h5/demo1.d.ts +3 -0
  133. package/dist/esm/types/src/packages/button/demos/h5/demo2.d.ts +3 -0
  134. package/dist/esm/types/src/packages/button/demos/h5/demo3.d.ts +3 -0
  135. package/dist/esm/types/src/packages/button/demos/h5/demo4.d.ts +3 -0
  136. package/dist/esm/types/src/packages/button/demos/h5/demo5.d.ts +3 -0
  137. package/dist/esm/types/src/packages/button/demos/h5/demo6.d.ts +3 -0
  138. package/dist/esm/types/src/packages/button/demos/h5/demo7.d.ts +3 -0
  139. package/dist/esm/types/src/packages/button/demos/h5/demo8.d.ts +3 -0
  140. package/dist/esm/types/src/packages/button/demos/h5/demo9.d.ts +3 -0
  141. package/dist/esm/types/src/packages/button/demos/taro/demo1.d.ts +3 -0
  142. package/dist/esm/types/src/packages/button/demos/taro/demo10.d.ts +3 -0
  143. package/dist/esm/types/src/packages/button/demos/taro/demo2.d.ts +3 -0
  144. package/dist/esm/types/src/packages/button/demos/taro/demo3.d.ts +3 -0
  145. package/dist/esm/types/src/packages/button/demos/taro/demo4.d.ts +3 -0
  146. package/dist/esm/types/src/packages/button/demos/taro/demo5.d.ts +3 -0
  147. package/dist/esm/types/src/packages/button/demos/taro/demo6.d.ts +3 -0
  148. package/dist/esm/types/src/packages/button/demos/taro/demo7.d.ts +3 -0
  149. package/dist/esm/types/src/packages/button/demos/taro/demo8.d.ts +3 -0
  150. package/dist/esm/types/src/packages/button/demos/taro/demo9.d.ts +3 -0
  151. package/dist/esm/types/src/packages/configprovider/configprovider.d.ts +1 -0
  152. package/dist/esm/types/src/packages/configprovider/configprovider.taro.d.ts +1 -0
  153. package/dist/esm/types/src/packages/configprovider/index.d.ts +2 -2
  154. package/dist/esm/types/src/packages/configprovider/index.taro.d.ts +2 -2
  155. package/dist/esm/types/src/packages/inputnumber/inputnumber.taro.d.ts +2 -0
  156. package/dist/esm/typings.js +1 -1
  157. package/dist/esm/use-click-away.js +9 -13
  158. package/dist/esm/use-client-rect.js +4 -4
  159. package/dist/esm/use-props-value.js +10 -15
  160. package/dist/esm/use-refs.js +5 -7
  161. package/dist/esm/use-touch.js +16 -20
  162. package/dist/locales/base.js +1 -1
  163. package/dist/locales/en-US.js +1 -1
  164. package/dist/locales/id-ID.js +1 -1
  165. package/dist/locales/tr-TR.js +1 -1
  166. package/dist/locales/zh-CN.js +1 -1
  167. package/dist/locales/zh-TW.js +1 -1
  168. package/dist/locales/zh-UG.js +1 -1
  169. package/dist/nutui.react.es.js +465 -485
  170. package/dist/nutui.react.umd.js +462 -482
  171. package/dist/style.mjs +1 -1
  172. package/dist/styles/variables-jmapp.scss +4 -0
  173. package/dist/types/index.d.ts +98 -98
  174. package/dist/types/packages/actionsheet/actionsheet.d.ts +1 -1
  175. package/dist/types/packages/actionsheet/actionsheet.taro.d.ts +1 -1
  176. package/dist/types/packages/address/address.d.ts +1 -1
  177. package/dist/types/packages/address/address.taro.d.ts +1 -1
  178. package/dist/types/packages/address/customRender.d.ts +1 -1
  179. package/dist/types/packages/address/customRender.taro.d.ts +1 -1
  180. package/dist/types/packages/avatar/avatar.d.ts +1 -1
  181. package/dist/types/packages/avatar/avatar.taro.d.ts +1 -1
  182. package/dist/types/packages/button/demos/h5/demo1.d.ts +3 -0
  183. package/dist/types/packages/button/demos/h5/demo2.d.ts +3 -0
  184. package/dist/types/packages/button/demos/h5/demo3.d.ts +3 -0
  185. package/dist/types/packages/button/demos/h5/demo4.d.ts +3 -0
  186. package/dist/types/packages/button/demos/h5/demo5.d.ts +3 -0
  187. package/dist/types/packages/button/demos/h5/demo6.d.ts +3 -0
  188. package/dist/types/packages/button/demos/h5/demo7.d.ts +3 -0
  189. package/dist/types/packages/button/demos/h5/demo8.d.ts +3 -0
  190. package/dist/types/packages/button/demos/h5/demo9.d.ts +3 -0
  191. package/dist/types/packages/button/demos/taro/demo1.d.ts +3 -0
  192. package/dist/types/packages/button/demos/taro/demo10.d.ts +3 -0
  193. package/dist/types/packages/button/demos/taro/demo2.d.ts +3 -0
  194. package/dist/types/packages/button/demos/taro/demo3.d.ts +3 -0
  195. package/dist/types/packages/button/demos/taro/demo4.d.ts +3 -0
  196. package/dist/types/packages/button/demos/taro/demo5.d.ts +3 -0
  197. package/dist/types/packages/button/demos/taro/demo6.d.ts +3 -0
  198. package/dist/types/packages/button/demos/taro/demo7.d.ts +3 -0
  199. package/dist/types/packages/button/demos/taro/demo8.d.ts +3 -0
  200. package/dist/types/packages/button/demos/taro/demo9.d.ts +3 -0
  201. package/dist/types/packages/calendaritem/calendaritem.d.ts +1 -1
  202. package/dist/types/packages/calendaritem/calendaritem.taro.d.ts +1 -1
  203. package/dist/types/packages/cascader/cascader.d.ts +1 -1
  204. package/dist/types/packages/cascader/cascader.taro.d.ts +1 -1
  205. package/dist/types/packages/cell/cell.d.ts +1 -1
  206. package/dist/types/packages/cell/cell.taro.d.ts +1 -1
  207. package/dist/types/packages/checkbox/checkbox.d.ts +2 -2
  208. package/dist/types/packages/checkbox/checkbox.taro.d.ts +2 -2
  209. package/dist/types/packages/checkboxgroup/checkboxgroup.d.ts +2 -2
  210. package/dist/types/packages/checkboxgroup/checkboxgroup.taro.d.ts +2 -2
  211. package/dist/types/packages/configprovider/configprovider.d.ts +1 -0
  212. package/dist/types/packages/configprovider/configprovider.taro.d.ts +1 -0
  213. package/dist/types/packages/configprovider/index.d.ts +2 -2
  214. package/dist/types/packages/configprovider/index.taro.d.ts +2 -2
  215. package/dist/types/packages/datepicker/datepicker.d.ts +1 -1
  216. package/dist/types/packages/datepicker/datepicker.taro.d.ts +1 -1
  217. package/dist/types/packages/dialog/dialogwrap.d.ts +1 -1
  218. package/dist/types/packages/empty/empty.d.ts +16 -4
  219. package/dist/types/packages/fixednav/fixednav.d.ts +1 -1
  220. package/dist/types/packages/fixednav/fixednav.taro.d.ts +1 -1
  221. package/dist/types/packages/form/form.d.ts +1 -1
  222. package/dist/types/packages/form/form.taro.d.ts +1 -1
  223. package/dist/types/packages/form/index.d.ts +1 -1
  224. package/dist/types/packages/form/index.taro.d.ts +1 -1
  225. package/dist/types/packages/inputnumber/inputnumber.taro.d.ts +2 -0
  226. package/dist/types/packages/menu/menu.d.ts +1 -1
  227. package/dist/types/packages/menu/menu.taro.d.ts +1 -1
  228. package/dist/types/packages/numberkeyboard/numberkeyboard.d.ts +1 -1
  229. package/dist/types/packages/numberkeyboard/numberkeyboard.taro.d.ts +1 -1
  230. package/dist/types/packages/nutui.react.d.ts +98 -98
  231. package/dist/types/packages/nutui.react.taro.d.ts +98 -98
  232. package/dist/types/packages/nutui.taro.react.build.d.ts +98 -98
  233. package/dist/types/packages/picker/picker.d.ts +1 -1
  234. package/dist/types/packages/picker/picker.taro.d.ts +1 -1
  235. package/dist/types/packages/popover/popover.d.ts +1 -1
  236. package/dist/types/packages/popover/popover.taro.d.ts +1 -1
  237. package/dist/types/packages/popup/popup.d.ts +1 -1
  238. package/dist/types/packages/popup/popup.taro.d.ts +1 -1
  239. package/dist/types/packages/radio/radio.d.ts +2 -2
  240. package/dist/types/packages/radio/radio.taro.d.ts +2 -2
  241. package/dist/types/packages/rate/rate.d.ts +1 -1
  242. package/dist/types/packages/shortpassword/shortpassword.d.ts +1 -1
  243. package/dist/types/packages/shortpassword/shortpassword.taro.d.ts +1 -1
  244. package/dist/types/packages/swiper/index.d.ts +1 -1
  245. package/dist/types/packages/swiper/index.taro.d.ts +1 -1
  246. package/dist/types/packages/tabs/tabs.d.ts +1 -1
  247. package/dist/types/packages/tabs/tabs.taro.d.ts +1 -1
  248. package/dist/types/packages/timedetail/timedetail.d.ts +1 -1
  249. package/dist/types/packages/timedetail/timedetail.taro.d.ts +1 -1
  250. package/dist/types/packages/tour/tour.d.ts +1 -1
  251. package/dist/types/packages/tour/tour.taro.d.ts +1 -1
  252. package/package.json +5 -1
@@ -1,48 +1,4 @@
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 _defineProperty from "@babel/runtime/helpers/defineProperty";
7
- import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
8
- import _regeneratorRuntime from "@babel/runtime/regenerator";
9
- function ownKeys(e, r) {
10
- var t = Object.keys(e);
11
- if (Object.getOwnPropertySymbols) {
12
- var o = Object.getOwnPropertySymbols(e);
13
- r && (o = o.filter(function(r2) {
14
- return Object.getOwnPropertyDescriptor(e, r2).enumerable;
15
- })), t.push.apply(t, o);
16
- }
17
- return t;
18
- }
19
- function _objectSpread(e) {
20
- for (var r = 1; r < arguments.length; r++) {
21
- var t = null != arguments[r] ? arguments[r] : {};
22
- r % 2 ? ownKeys(Object(t), true).forEach(function(r2) {
23
- _defineProperty(e, r2, t[r2]);
24
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r2) {
25
- Object.defineProperty(e, r2, Object.getOwnPropertyDescriptor(t, r2));
26
- });
27
- }
28
- return e;
29
- }
30
- function _toPropertyKey(arg) {
31
- var key = _toPrimitive(arg, "string");
32
- return _typeof(key) === "symbol" ? key : String(key);
33
- }
34
- function _toPrimitive(input, hint) {
35
- if (_typeof(input) !== "object" || input === null)
36
- return input;
37
- var prim = input[Symbol.toPrimitive];
38
- if (prim !== void 0) {
39
- var res = prim.call(input, hint || "default");
40
- if (_typeof(res) !== "object")
41
- return res;
42
- throw new TypeError("@@toPrimitive must return a primitive value.");
43
- }
44
- return (hint === "string" ? String : Number)(input);
45
- }
1
+ import { _ as __rest, a as __awaiter } from "./tslib.es6.js";
46
2
  import React__default, { useState, useImperativeHandle, useEffect, isValidElement } from "react";
47
3
  import classNames from "classnames";
48
4
  import { Loading, Checklist } from "@nutui/icons-react";
@@ -50,52 +6,48 @@ import { P as Popup } from "./popup2.js";
50
6
  import { T as Tabs } from "./tabs2.js";
51
7
  import { C as ComponentDefaults } from "./typings.js";
52
8
  import { u as usePropsValue } from "./use-props-value.js";
53
- var formatTree = function formatTree2(tree, parent, config) {
54
- return tree.map(function(node) {
55
- var _config$value = config.value, valueKey = _config$value === void 0 ? "value" : _config$value, _config$text = config.text, textKey = _config$text === void 0 ? "text" : _config$text, _config$children = config.children, childrenKey = _config$children === void 0 ? "children" : _config$children;
56
- var value = node[valueKey], text = node[textKey], children = node[childrenKey], others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
57
- var newNode = _objectSpread(_objectSpread({
58
- loading: false
59
- }, others), {}, {
60
- level: parent ? (parent && parent.level || 0) + 1 : 0,
61
- value,
62
- text,
63
- children,
64
- _parent: parent
65
- });
66
- if (newNode.children && newNode.children.length) {
67
- newNode.children = formatTree2(newNode.children, newNode, config);
68
- }
69
- return newNode;
9
+ const formatTree = (tree, parent, config) => tree.map((node) => {
10
+ const { value: valueKey = "value", text: textKey = "text", children: childrenKey = "children" } = config;
11
+ const _a = node, _b = valueKey, value = _a[_b], _c = textKey, text = _a[_c], _d = childrenKey, children = _a[_d], others = __rest(_a, [typeof _b === "symbol" ? _b : _b + "", typeof _c === "symbol" ? _c : _c + "", typeof _d === "symbol" ? _d : _d + ""]);
12
+ const newNode = Object.assign(Object.assign({ loading: false }, others), {
13
+ level: parent ? (parent && parent.level || 0) + 1 : 0,
14
+ value,
15
+ text,
16
+ children,
17
+ _parent: parent
70
18
  });
71
- };
72
- var eachTree = function eachTree2(tree, cb) {
73
- var i = 0;
74
- var node;
19
+ if (newNode.children && newNode.children.length) {
20
+ newNode.children = formatTree(newNode.children, newNode, config);
21
+ }
22
+ return newNode;
23
+ });
24
+ const eachTree = (tree, cb) => {
25
+ let i = 0;
26
+ let node;
75
27
  while (node = tree[i++]) {
76
28
  if (cb(node) === true) {
77
29
  break;
78
30
  }
79
31
  if (node.children && node.children.length) {
80
- eachTree2(node.children, cb);
32
+ eachTree(node.children, cb);
81
33
  }
82
34
  }
83
35
  };
84
- var defaultConvertConfig = {
36
+ const defaultConvertConfig = {
85
37
  topId: null,
86
38
  idKey: "id",
87
39
  pidKey: "pid",
88
40
  sortKey: ""
89
41
  };
90
- var convertListToOptions = function convertListToOptions2(list, options) {
91
- var mergedOptions = _objectSpread(_objectSpread({}, defaultConvertConfig), options || {});
92
- var topId = mergedOptions.topId, idKey = mergedOptions.idKey, pidKey = mergedOptions.pidKey, sortKey = mergedOptions.sortKey;
93
- var result = [];
94
- var map = {};
95
- list.forEach(function(node) {
96
- node = _objectSpread({}, node);
97
- var _node = node, id = _node[idKey], pid = _node[pidKey];
98
- var children = map[pid] = map[pid] || [];
42
+ const convertListToOptions = (list, options) => {
43
+ const mergedOptions = Object.assign(Object.assign({}, defaultConvertConfig), options || {});
44
+ const { topId, idKey, pidKey, sortKey } = mergedOptions;
45
+ let result = [];
46
+ let map = {};
47
+ list.forEach((node) => {
48
+ node = Object.assign({}, node);
49
+ const { [idKey]: id, [pidKey]: pid } = node;
50
+ const children = map[pid] = map[pid] || [];
99
51
  if (!result.length && pid === topId) {
100
52
  result = children;
101
53
  }
@@ -103,529 +55,347 @@ var convertListToOptions = function convertListToOptions2(list, options) {
103
55
  node.children = map[id] || (map[id] = []);
104
56
  });
105
57
  if (sortKey) {
106
- Object.keys(map).forEach(function(i) {
58
+ Object.keys(map).forEach((i) => {
107
59
  if (map[i].length > 1) {
108
- map[i].sort(function(a, b) {
109
- return a[sortKey] - b[sortKey];
110
- });
60
+ map[i].sort((a, b) => a[sortKey] - b[sortKey]);
111
61
  }
112
62
  });
113
63
  }
114
64
  map = null;
115
65
  return result;
116
66
  };
117
- var Tree = /* @__PURE__ */ function() {
118
- function Tree2(nodes, config) {
119
- var _this = this;
120
- _classCallCheck(this, Tree2);
121
- _defineProperty(this, "nodes", void 0);
122
- _defineProperty(this, "config", void 0);
123
- _defineProperty(this, "isLeaf", function(node, lazy) {
124
- var leaf = node.leaf, children = node.children;
125
- var hasChildren = Array.isArray(children) && Boolean(children.length);
67
+ class Tree {
68
+ constructor(nodes, config) {
69
+ this.isLeaf = (node, lazy) => {
70
+ const { leaf, children } = node;
71
+ const hasChildren = Array.isArray(children) && Boolean(children.length);
126
72
  return leaf || !hasChildren && !lazy;
127
- });
128
- _defineProperty(this, "hasChildren", function(node, lazy) {
129
- var isLeaf = _this.isLeaf(node, lazy);
73
+ };
74
+ this.hasChildren = (node, lazy) => {
75
+ const isLeaf = this.isLeaf(node, lazy);
130
76
  if (isLeaf) {
131
77
  return false;
132
78
  }
133
- var children = node.children;
79
+ const { children } = node;
134
80
  return Array.isArray(children) && Boolean(children.length);
135
- });
136
- this.config = _objectSpread({
137
- value: "value",
138
- text: "text",
139
- children: "children"
140
- }, config || {});
81
+ };
82
+ this.config = Object.assign({ value: "value", text: "text", children: "children" }, config || {});
141
83
  this.nodes = formatTree(nodes, null, this.config);
142
84
  }
143
- _createClass(Tree2, [{
144
- key: "updateChildren",
145
- value: function updateChildren(nodes, parent) {
146
- if (!parent) {
147
- this.nodes = formatTree(nodes, null, this.config);
148
- } else {
149
- parent.children = formatTree(nodes, parent, this.config);
150
- }
85
+ updateChildren(nodes, parent) {
86
+ if (!parent) {
87
+ this.nodes = formatTree(nodes, null, this.config);
88
+ } else {
89
+ parent.children = formatTree(nodes, parent, this.config);
151
90
  }
152
- // for test
153
- }, {
154
- key: "getNodeByValue",
155
- value: function getNodeByValue(value) {
156
- var foundNode;
157
- eachTree(this.nodes, function(node) {
158
- if (node.value === value) {
159
- foundNode = node;
160
- return true;
161
- }
162
- return null;
163
- });
164
- return foundNode;
165
- }
166
- }, {
167
- key: "getPathNodesByValue",
168
- value: function getPathNodesByValue(value) {
169
- if (!value.length) {
170
- return [];
91
+ }
92
+ // for test
93
+ getNodeByValue(value) {
94
+ let foundNode;
95
+ eachTree(this.nodes, (node) => {
96
+ if (node.value === value) {
97
+ foundNode = node;
98
+ return true;
171
99
  }
172
- var pathNodes = [];
173
- var currentNodes = this.nodes;
174
- while (currentNodes && currentNodes.length) {
175
- var foundNode = currentNodes.find(function(node) {
176
- return node.value === value[node.level];
177
- });
178
- if (!foundNode) {
179
- break;
180
- }
181
- pathNodes.push(foundNode);
182
- currentNodes = foundNode.children;
100
+ return null;
101
+ });
102
+ return foundNode;
103
+ }
104
+ getPathNodesByValue(value) {
105
+ if (!value.length) {
106
+ return [];
107
+ }
108
+ const pathNodes = [];
109
+ let currentNodes = this.nodes;
110
+ while (currentNodes && currentNodes.length) {
111
+ const foundNode = currentNodes.find((node) => node.value === value[node.level]);
112
+ if (!foundNode) {
113
+ break;
183
114
  }
184
- return pathNodes;
115
+ pathNodes.push(foundNode);
116
+ currentNodes = foundNode.children;
185
117
  }
186
- }]);
187
- return Tree2;
188
- }();
189
- var Tree$1 = Tree;
190
- var defaultProps = _objectSpread(_objectSpread({}, ComponentDefaults), {}, {
191
- activeColor: "",
192
- activeIcon: "checklist",
193
- popup: true,
194
- options: [],
195
- optionKey: {
196
- textKey: "text",
197
- valueKey: "value",
198
- childrenKey: "children"
199
- },
200
- format: {},
201
- closeable: false,
202
- closeIconPosition: "top-right",
203
- closeIcon: "close",
204
- lazy: false,
205
- onLoad: function onLoad() {
206
- },
207
- onClose: function onClose() {
208
- },
209
- onChange: function onChange() {
210
- },
211
- onPathChange: function onPathChange() {
118
+ return pathNodes;
212
119
  }
213
- });
214
- var InternalCascader = function InternalCascader2(props, ref) {
215
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style, activeColor = _defaultProps$props.activeColor, activeIcon = _defaultProps$props.activeIcon, popup = _defaultProps$props.popup, _defaultProps$props$p = _defaultProps$props.popupProps, popupProps = _defaultProps$props$p === void 0 ? {} : _defaultProps$props$p, visible = _defaultProps$props.visible, options = _defaultProps$props.options, value = _defaultProps$props.value, defaultValue = _defaultProps$props.defaultValue, optionKey = _defaultProps$props.optionKey, format = _defaultProps$props.format, closeable = _defaultProps$props.closeable, closeIconPosition = _defaultProps$props.closeIconPosition, closeIcon = _defaultProps$props.closeIcon, lazy = _defaultProps$props.lazy, onLoad2 = _defaultProps$props.onLoad, onClose2 = _defaultProps$props.onClose, onChange2 = _defaultProps$props.onChange, onPathChange2 = _defaultProps$props.onPathChange;
216
- var _useState = useState("c1"), _useState2 = _slicedToArray(_useState, 2), tabvalue = _useState2[0], setTabvalue = _useState2[1];
217
- var _useState3 = useState([]), _useState4 = _slicedToArray(_useState3, 2), optionsData = _useState4[0], setOptionsData = _useState4[1];
218
- var isLazy = function isLazy2() {
219
- return state.configs.lazy && Boolean(state.configs.onLoad);
220
- };
221
- var _usePropsValue = usePropsValue({
120
+ }
121
+ const defaultProps = Object.assign(Object.assign({}, ComponentDefaults), { activeColor: "", activeIcon: "checklist", popup: true, options: [], optionKey: { textKey: "text", valueKey: "value", childrenKey: "children" }, format: {}, closeable: false, closeIconPosition: "top-right", closeIcon: "close", lazy: false, onLoad: () => {
122
+ }, onClose: () => {
123
+ }, onChange: () => {
124
+ }, onPathChange: () => {
125
+ } });
126
+ const InternalCascader = (props, ref) => {
127
+ const { className, style, activeColor, activeIcon, popup, popupProps = {}, visible, options, value, defaultValue, optionKey, format, closeable, closeIconPosition, closeIcon, lazy, onLoad, onClose, onChange, onPathChange } = Object.assign(Object.assign({}, defaultProps), props);
128
+ const [tabvalue, setTabvalue] = useState("c1");
129
+ const [optionsData, setOptionsData] = useState([]);
130
+ const isLazy = () => state.configs.lazy && Boolean(state.configs.onLoad);
131
+ const [innerValue, setInnerValue] = usePropsValue({
222
132
  value,
223
133
  defaultValue,
224
134
  finalValue: defaultValue
225
- }), _usePropsValue2 = _slicedToArray(_usePropsValue, 2), innerValue = _usePropsValue2[0], setInnerValue = _usePropsValue2[1];
226
- var _usePropsValue3 = usePropsValue({
135
+ });
136
+ const [innerVisible, setInnerVisible] = usePropsValue({
227
137
  value: props.visible,
228
138
  defaultValue: void 0,
229
139
  finalValue: false
230
- }), _usePropsValue4 = _slicedToArray(_usePropsValue3, 2), innerVisible = _usePropsValue4[0], setInnerVisible = _usePropsValue4[1];
231
- var actions = {
232
- open: function open() {
140
+ });
141
+ const actions = {
142
+ open: () => {
233
143
  setInnerVisible(true);
234
144
  },
235
- close: function close2() {
145
+ close: () => {
236
146
  setInnerVisible(false);
237
147
  }
238
148
  };
239
- useImperativeHandle(ref, function() {
240
- return actions;
241
- });
242
- var _useState5 = useState({
149
+ useImperativeHandle(ref, () => actions);
150
+ const [state] = useState({
243
151
  optionsData: [],
244
- panes: [{
245
- nodes: [],
246
- selectedNode: [],
247
- paneKey: ""
248
- }],
249
- tree: new Tree$1([], {}),
152
+ panes: [
153
+ {
154
+ nodes: [],
155
+ selectedNode: [],
156
+ paneKey: ""
157
+ }
158
+ ],
159
+ tree: new Tree([], {}),
250
160
  tabsCursor: 0,
251
161
  initLoading: false,
252
162
  currentProcessNode: [],
253
163
  configs: {
254
164
  lazy,
255
- onLoad: onLoad2,
165
+ onLoad,
256
166
  optionKey,
257
167
  format
258
168
  },
259
169
  lazyLoadMap: /* @__PURE__ */ new Map()
260
- }), _useState6 = _slicedToArray(_useState5, 1), state = _useState6[0];
261
- var classPrefix = classNames("nut-cascader");
262
- var classesPane = classNames(_defineProperty({}, "".concat(classPrefix, "-pane"), true));
263
- useEffect(function() {
170
+ });
171
+ const classPrefix = classNames(`nut-cascader`);
172
+ const classesPane = classNames({
173
+ [`${classPrefix}-pane`]: true
174
+ });
175
+ useEffect(() => {
264
176
  initData();
265
177
  }, [options, format]);
266
- var initData = /* @__PURE__ */ function() {
267
- var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee() {
268
- return _regeneratorRuntime.wrap(function _callee$(_context) {
269
- while (1)
270
- switch (_context.prev = _context.next) {
271
- case 0:
272
- state.lazyLoadMap.clear();
273
- if (format && Object.keys(format).length > 0) {
274
- state.optionsData = convertListToOptions(options, format);
275
- } else {
276
- state.optionsData = options;
277
- }
278
- state.tree = new Tree$1(state.optionsData, {
279
- value: state.configs.optionKey.valueKey,
280
- text: state.configs.optionKey.textKey,
281
- children: state.configs.optionKey.childrenKey
282
- });
283
- if (!(isLazy() && !state.tree.nodes.length)) {
284
- _context.next = 6;
285
- break;
286
- }
287
- _context.next = 6;
288
- return invokeLazyLoad({
289
- root: true,
290
- loading: true,
291
- text: "",
292
- value: ""
293
- });
294
- case 6:
295
- state.panes = [{
296
- nodes: state.tree.nodes,
297
- selectedNode: null,
298
- paneKey: "c1"
299
- }];
300
- syncValue();
301
- setOptionsData(state.panes);
302
- case 9:
303
- case "end":
304
- return _context.stop();
305
- }
306
- }, _callee);
307
- }));
308
- return function initData2() {
309
- return _ref.apply(this, arguments);
310
- };
311
- }();
312
- var syncValue = /* @__PURE__ */ function() {
313
- var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee3() {
314
- var currentValue, needToSync, parent, last, pathNodes;
315
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
316
- while (1)
317
- switch (_context3.prev = _context3.next) {
318
- case 0:
319
- currentValue = innerValue;
320
- if (!(currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length)) {
321
- _context3.next = 3;
322
- break;
323
- }
324
- return _context3.abrupt("return");
325
- case 3:
326
- if (!(currentValue.length === 0)) {
327
- _context3.next = 6;
328
- break;
329
- }
330
- state.tabsCursor = 0;
331
- return _context3.abrupt("return");
332
- case 6:
333
- needToSync = currentValue;
334
- if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
335
- _context3.next = 19;
336
- break;
337
- }
338
- needToSync = [];
339
- parent = state.tree.nodes.find(function(node) {
340
- return node.value === currentValue[0];
341
- });
342
- if (!parent) {
343
- _context3.next = 19;
344
- break;
345
- }
346
- needToSync = [parent.value];
347
- state.initLoading = true;
348
- _context3.next = 15;
349
- return currentValue.slice(1).reduce(/* @__PURE__ */ function() {
350
- var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee2(p, value2) {
351
- var _parent2$children;
352
- var parent2, node;
353
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
354
- while (1)
355
- switch (_context2.prev = _context2.next) {
356
- case 0:
357
- _context2.next = 2;
358
- return p;
359
- case 2:
360
- parent2 = _context2.sent;
361
- _context2.next = 5;
362
- return invokeLazyLoad(parent2);
363
- case 5:
364
- node = parent2 === null || parent2 === void 0 || (_parent2$children = parent2.children) === null || _parent2$children === void 0 ? void 0 : _parent2$children.find(function(item) {
365
- return item.value === value2;
366
- });
367
- if (node) {
368
- needToSync.push(value2);
369
- }
370
- return _context2.abrupt("return", Promise.resolve(node));
371
- case 8:
372
- case "end":
373
- return _context2.stop();
374
- }
375
- }, _callee2);
376
- }));
377
- return function(_x, _x2) {
378
- return _ref3.apply(this, arguments);
379
- };
380
- }(), Promise.resolve(parent));
381
- case 15:
382
- last = _context3.sent;
383
- _context3.next = 18;
384
- return invokeLazyLoad(last);
385
- case 18:
386
- state.initLoading = false;
387
- case 19:
388
- if (needToSync.length && currentValue === defaultValue) {
389
- pathNodes = state.tree.getPathNodesByValue(needToSync);
390
- pathNodes.forEach(function(node, index) {
391
- state.tabsCursor = index;
392
- chooseItem(node, true);
393
- });
394
- }
395
- case 20:
396
- case "end":
397
- return _context3.stop();
398
- }
399
- }, _callee3);
400
- }));
401
- return function syncValue2() {
402
- return _ref2.apply(this, arguments);
403
- };
404
- }();
405
- var invokeLazyLoad = /* @__PURE__ */ function() {
406
- var _ref4 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee4(node) {
407
- var parent, lazyLoadPromise, nodes;
408
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
409
- while (1)
410
- switch (_context4.prev = _context4.next) {
411
- case 0:
412
- if (node) {
413
- _context4.next = 2;
414
- break;
415
- }
416
- return _context4.abrupt("return");
417
- case 2:
418
- if (state.configs.onLoad) {
419
- _context4.next = 5;
420
- break;
421
- }
422
- node.leaf = true;
423
- return _context4.abrupt("return");
424
- case 5:
425
- if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
426
- _context4.next = 7;
427
- break;
428
- }
429
- return _context4.abrupt("return");
430
- case 7:
431
- node.loading = true;
432
- parent = node.root ? null : node;
433
- lazyLoadPromise = state.lazyLoadMap.get(node);
434
- if (!lazyLoadPromise) {
435
- lazyLoadPromise = new Promise(function(resolve) {
436
- var _state$configs$onLoad, _state$configs;
437
- (_state$configs$onLoad = (_state$configs = state.configs).onLoad) === null || _state$configs$onLoad === void 0 || _state$configs$onLoad.call(_state$configs, node, resolve);
438
- });
439
- state.lazyLoadMap.set(node, lazyLoadPromise);
440
- }
441
- _context4.next = 13;
442
- return lazyLoadPromise;
443
- case 13:
444
- nodes = _context4.sent;
445
- if (Array.isArray(nodes) && nodes.length > 0) {
446
- state.tree.updateChildren(nodes, parent);
447
- } else {
448
- node.leaf = true;
449
- }
450
- node.loading = false;
451
- state.lazyLoadMap["delete"](node);
452
- case 17:
453
- case "end":
454
- return _context4.stop();
178
+ const initData = () => __awaiter(void 0, void 0, void 0, function* () {
179
+ state.lazyLoadMap.clear();
180
+ if (format && Object.keys(format).length > 0) {
181
+ state.optionsData = convertListToOptions(options, format);
182
+ } else {
183
+ state.optionsData = options;
184
+ }
185
+ state.tree = new Tree(state.optionsData, {
186
+ value: state.configs.optionKey.valueKey,
187
+ text: state.configs.optionKey.textKey,
188
+ children: state.configs.optionKey.childrenKey
189
+ });
190
+ if (isLazy() && !state.tree.nodes.length) {
191
+ yield invokeLazyLoad({
192
+ root: true,
193
+ loading: true,
194
+ text: "",
195
+ value: ""
196
+ });
197
+ }
198
+ state.panes = [
199
+ {
200
+ nodes: state.tree.nodes,
201
+ selectedNode: null,
202
+ paneKey: "c1"
203
+ }
204
+ ];
205
+ syncValue();
206
+ setOptionsData(state.panes);
207
+ });
208
+ const syncValue = () => __awaiter(void 0, void 0, void 0, function* () {
209
+ const currentValue = innerValue;
210
+ if (currentValue === void 0 || currentValue !== defaultValue || !state.tree.nodes.length) {
211
+ return;
212
+ }
213
+ if (currentValue.length === 0) {
214
+ state.tabsCursor = 0;
215
+ return;
216
+ }
217
+ let needToSync = currentValue;
218
+ if (isLazy() && Array.isArray(currentValue) && currentValue.length) {
219
+ needToSync = [];
220
+ const parent = state.tree.nodes.find((node) => node.value === currentValue[0]);
221
+ if (parent) {
222
+ needToSync = [parent.value];
223
+ state.initLoading = true;
224
+ const last = yield currentValue.slice(1).reduce((p, value2) => __awaiter(void 0, void 0, void 0, function* () {
225
+ var _a;
226
+ const parent2 = yield p;
227
+ yield invokeLazyLoad(parent2);
228
+ const node = (_a = parent2 === null || parent2 === void 0 ? void 0 : parent2.children) === null || _a === void 0 ? void 0 : _a.find((item) => item.value === value2);
229
+ if (node) {
230
+ needToSync.push(value2);
455
231
  }
456
- }, _callee4);
457
- }));
458
- return function invokeLazyLoad2(_x3) {
459
- return _ref4.apply(this, arguments);
460
- };
461
- }();
462
- var close = function close2() {
232
+ return Promise.resolve(node);
233
+ }), Promise.resolve(parent));
234
+ yield invokeLazyLoad(last);
235
+ state.initLoading = false;
236
+ }
237
+ }
238
+ if (needToSync.length && currentValue === defaultValue) {
239
+ const pathNodes = state.tree.getPathNodesByValue(needToSync);
240
+ pathNodes.forEach((node, index) => {
241
+ state.tabsCursor = index;
242
+ chooseItem(node, true);
243
+ });
244
+ }
245
+ });
246
+ const invokeLazyLoad = (node) => __awaiter(void 0, void 0, void 0, function* () {
247
+ if (!node) {
248
+ return;
249
+ }
250
+ if (!state.configs.onLoad) {
251
+ node.leaf = true;
252
+ return;
253
+ }
254
+ if (state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy())) {
255
+ return;
256
+ }
257
+ node.loading = true;
258
+ const parent = node.root ? null : node;
259
+ let lazyLoadPromise = state.lazyLoadMap.get(node);
260
+ if (!lazyLoadPromise) {
261
+ lazyLoadPromise = new Promise((resolve) => {
262
+ var _a, _b;
263
+ (_b = (_a = state.configs).onLoad) === null || _b === void 0 ? void 0 : _b.call(_a, node, resolve);
264
+ });
265
+ state.lazyLoadMap.set(node, lazyLoadPromise);
266
+ }
267
+ const nodes = yield lazyLoadPromise;
268
+ if (Array.isArray(nodes) && nodes.length > 0) {
269
+ state.tree.updateChildren(nodes, parent);
270
+ } else {
271
+ node.leaf = true;
272
+ }
273
+ node.loading = false;
274
+ state.lazyLoadMap.delete(node);
275
+ });
276
+ const close = () => {
463
277
  setInnerVisible(false);
464
- onClose2 && onClose2();
278
+ onClose && onClose();
465
279
  };
466
- var closePopup = function closePopup2() {
280
+ const closePopup = () => {
467
281
  close();
468
282
  };
469
- var chooseItem = /* @__PURE__ */ function() {
470
- var _ref5 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee5(node, type) {
471
- var pathNodes, optionParams, level, _pathNodes, _optionParams;
472
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
473
- while (1)
474
- switch (_context5.prev = _context5.next) {
475
- case 0:
476
- if (!(!type && node.disabled || !state.panes[state.tabsCursor])) {
477
- _context5.next = 2;
478
- break;
479
- }
480
- return _context5.abrupt("return");
481
- case 2:
482
- if (!state.tree.isLeaf(node, isLazy())) {
483
- _context5.next = 10;
484
- break;
485
- }
486
- node.leaf = true;
487
- state.panes[state.tabsCursor].selectedNode = node;
488
- state.panes = state.panes.slice(0, node.level + 1);
489
- if (!type) {
490
- pathNodes = state.panes.map(function(item) {
491
- return item.selectedNode;
492
- });
493
- optionParams = pathNodes.map(function(item) {
494
- return item.value;
495
- });
496
- onChange2(optionParams, pathNodes);
497
- onPathChange2(optionParams, pathNodes);
498
- setInnerValue(optionParams);
499
- }
500
- setOptionsData(state.panes);
501
- close();
502
- return _context5.abrupt("return");
503
- case 10:
504
- if (!state.tree.hasChildren(node, isLazy())) {
505
- _context5.next = 20;
506
- break;
507
- }
508
- level = node.level + 1;
509
- state.panes[state.tabsCursor].selectedNode = node;
510
- state.panes = state.panes.slice(0, level);
511
- state.tabsCursor = level;
512
- state.panes.push({
513
- nodes: node.children || [],
514
- selectedNode: null,
515
- paneKey: "c".concat(state.tabsCursor + 1)
516
- });
517
- setOptionsData(state.panes);
518
- setTabvalue("c".concat(state.tabsCursor + 1));
519
- if (!type) {
520
- _pathNodes = state.panes.map(function(item) {
521
- return item.selectedNode;
522
- });
523
- _optionParams = _pathNodes.map(function(item) {
524
- return item === null || item === void 0 ? void 0 : item.value;
525
- });
526
- onPathChange2(_optionParams, _pathNodes);
527
- }
528
- return _context5.abrupt("return");
529
- case 20:
530
- state.currentProcessNode = node;
531
- if (!node.loading) {
532
- _context5.next = 23;
533
- break;
534
- }
535
- return _context5.abrupt("return");
536
- case 23:
537
- _context5.next = 25;
538
- return invokeLazyLoad(node);
539
- case 25:
540
- if (state.currentProcessNode === node) {
541
- state.panes[state.tabsCursor].selectedNode = node;
542
- chooseItem(node, type);
543
- }
544
- setOptionsData(state.panes);
545
- case 27:
546
- case "end":
547
- return _context5.stop();
548
- }
549
- }, _callee5);
550
- }));
551
- return function chooseItem2(_x4, _x5) {
552
- return _ref5.apply(this, arguments);
553
- };
554
- }();
555
- var renderItem = function renderItem2(pane, node, index) {
556
- var _pane$selectedNode;
557
- var classPrefix2 = "nut-cascader-item";
558
- var checked = ((_pane$selectedNode = pane.selectedNode) === null || _pane$selectedNode === void 0 ? void 0 : _pane$selectedNode.value) === node.value;
559
- var classes = classNames({
283
+ const chooseItem = (node, type) => __awaiter(void 0, void 0, void 0, function* () {
284
+ if (!type && node.disabled || !state.panes[state.tabsCursor]) {
285
+ return;
286
+ }
287
+ if (state.tree.isLeaf(node, isLazy())) {
288
+ node.leaf = true;
289
+ state.panes[state.tabsCursor].selectedNode = node;
290
+ state.panes = state.panes.slice(0, node.level + 1);
291
+ if (!type) {
292
+ const pathNodes = state.panes.map((item) => item.selectedNode);
293
+ const optionParams = pathNodes.map((item) => item.value);
294
+ onChange(optionParams, pathNodes);
295
+ onPathChange(optionParams, pathNodes);
296
+ setInnerValue(optionParams);
297
+ }
298
+ setOptionsData(state.panes);
299
+ close();
300
+ return;
301
+ }
302
+ if (state.tree.hasChildren(node, isLazy())) {
303
+ const level = node.level + 1;
304
+ state.panes[state.tabsCursor].selectedNode = node;
305
+ state.panes = state.panes.slice(0, level);
306
+ state.tabsCursor = level;
307
+ state.panes.push({
308
+ nodes: node.children || [],
309
+ selectedNode: null,
310
+ paneKey: `c${state.tabsCursor + 1}`
311
+ });
312
+ setOptionsData(state.panes);
313
+ setTabvalue(`c${state.tabsCursor + 1}`);
314
+ if (!type) {
315
+ const pathNodes = state.panes.map((item) => item.selectedNode);
316
+ const optionParams = pathNodes.map((item) => item === null || item === void 0 ? void 0 : item.value);
317
+ onPathChange(optionParams, pathNodes);
318
+ }
319
+ return;
320
+ }
321
+ state.currentProcessNode = node;
322
+ if (node.loading) {
323
+ return;
324
+ }
325
+ yield invokeLazyLoad(node);
326
+ if (state.currentProcessNode === node) {
327
+ state.panes[state.tabsCursor].selectedNode = node;
328
+ chooseItem(node, type);
329
+ }
330
+ setOptionsData(state.panes);
331
+ });
332
+ const renderItem = (pane, node, index) => {
333
+ var _a;
334
+ const classPrefix2 = "nut-cascader-item";
335
+ const checked = ((_a = pane.selectedNode) === null || _a === void 0 ? void 0 : _a.value) === node.value;
336
+ const classes = classNames({
560
337
  active: checked,
561
338
  disabled: node.disabled
562
339
  }, classPrefix2);
563
- var classesTitle = classNames(_defineProperty({}, "".concat(classPrefix2, "-title"), true));
564
- var renderIcon = function renderIcon2() {
340
+ const classesTitle = classNames({
341
+ [`${classPrefix2}-title`]: true
342
+ });
343
+ const renderIcon = () => {
565
344
  if (checked) {
566
345
  if (isValidElement(activeIcon)) {
567
346
  return activeIcon;
568
347
  }
569
- return React__default.createElement(Checklist, {
570
- className: "".concat(checked ? "".concat(classPrefix, "-icon-check") : "")
571
- });
348
+ return React__default.createElement(Checklist, { className: `${checked ? `${classPrefix}-icon-check` : ""}` });
572
349
  }
573
350
  return null;
574
351
  };
575
- return React__default.createElement("div", {
576
- style: {
577
- color: checked ? activeColor : ""
578
- },
579
- className: classes,
580
- key: index,
581
- onClick: function onClick() {
352
+ return React__default.createElement(
353
+ "div",
354
+ { style: { color: checked ? activeColor : "" }, className: classes, key: index, onClick: () => {
582
355
  chooseItem(node, false);
583
- }
584
- }, React__default.createElement("div", {
585
- className: classesTitle
586
- }, node.text), node.loading ? React__default.createElement(Loading, {
587
- color: "#969799",
588
- className: "nut-cascader-item-icon-loading"
589
- }) : renderIcon());
356
+ } },
357
+ React__default.createElement("div", { className: classesTitle }, node.text),
358
+ node.loading ? React__default.createElement(Loading, { color: "#969799", className: "nut-cascader-item-icon-loading" }) : renderIcon()
359
+ );
590
360
  };
591
- var renderTabs = function renderTabs2() {
592
- return React__default.createElement("div", {
593
- className: "".concat(classPrefix, " ").concat(className),
594
- style
595
- }, React__default.createElement(Tabs, {
596
- value: tabvalue,
597
- title: function title() {
598
- return optionsData.map(function(pane, index) {
599
- var _pane$selectedNode2, _pane$selectedNode3;
600
- return React__default.createElement("div", {
601
- onClick: function onClick() {
361
+ const renderTabs = () => {
362
+ return React__default.createElement(
363
+ "div",
364
+ { className: `${classPrefix} ${className}`, style },
365
+ React__default.createElement(Tabs, { value: tabvalue, title: () => {
366
+ return optionsData.map((pane, index) => {
367
+ var _a, _b;
368
+ return React__default.createElement(
369
+ "div",
370
+ { onClick: () => {
602
371
  setTabvalue(pane.paneKey);
603
372
  state.tabsCursor = index;
604
- },
605
- className: "nut-tabs-titles-item ".concat(tabvalue === pane.paneKey ? "nut-tabs-titles-item-active" : ""),
606
- key: pane.paneKey
607
- }, React__default.createElement("span", {
608
- className: "nut-tabs-titles-item-text"
609
- }, !state.initLoading && state.panes.length && (pane === null || pane === void 0 || (_pane$selectedNode2 = pane.selectedNode) === null || _pane$selectedNode2 === void 0 ? void 0 : _pane$selectedNode2.text), !state.initLoading && state.panes.length && !(pane !== null && pane !== void 0 && (_pane$selectedNode3 = pane.selectedNode) !== null && _pane$selectedNode3 !== void 0 && _pane$selectedNode3.text) && "请选择", !(!state.initLoading && state.panes.length) && "Loading..."), React__default.createElement("span", {
610
- className: "nut-tabs-titles-item-line"
611
- }));
373
+ }, className: `nut-tabs-titles-item ${tabvalue === pane.paneKey ? "nut-tabs-titles-item-active" : ""}`, key: pane.paneKey },
374
+ React__default.createElement(
375
+ "span",
376
+ { className: "nut-tabs-titles-item-text" },
377
+ !state.initLoading && state.panes.length && ((_a = pane === null || pane === void 0 ? void 0 : pane.selectedNode) === null || _a === void 0 ? void 0 : _a.text),
378
+ !state.initLoading && state.panes.length && !((_b = pane === null || pane === void 0 ? void 0 : pane.selectedNode) === null || _b === void 0 ? void 0 : _b.text) && "请选择",
379
+ !(!state.initLoading && state.panes.length) && "Loading..."
380
+ ),
381
+ React__default.createElement("span", { className: "nut-tabs-titles-item-line" })
382
+ );
612
383
  });
613
- }
614
- }, !state.initLoading && state.panes.length ? optionsData.map(function(pane) {
615
- var _pane$nodes;
616
- return React__default.createElement(Tabs.TabPane, {
617
- key: pane.paneKey,
618
- value: pane.paneKey
619
- }, React__default.createElement("div", {
620
- className: classesPane
621
- }, (_pane$nodes = pane.nodes) === null || _pane$nodes === void 0 ? void 0 : _pane$nodes.map(function(node, index) {
622
- return renderItem(pane, node, index);
623
- })));
624
- }) : React__default.createElement(Tabs.TabPane, null, React__default.createElement("div", {
625
- className: classesPane
626
- }))));
384
+ } }, !state.initLoading && state.panes.length ? optionsData.map((pane) => {
385
+ var _a;
386
+ return React__default.createElement(
387
+ Tabs.TabPane,
388
+ { key: pane.paneKey, value: pane.paneKey },
389
+ React__default.createElement("div", { className: classesPane }, (_a = pane.nodes) === null || _a === void 0 ? void 0 : _a.map((node, index) => renderItem(pane, node, index)))
390
+ );
391
+ }) : React__default.createElement(
392
+ Tabs.TabPane,
393
+ null,
394
+ React__default.createElement("div", { className: classesPane })
395
+ ))
396
+ );
627
397
  };
628
- return React__default.createElement(React__default.Fragment, null, popup ? React__default.createElement(Popup, _objectSpread(_objectSpread({}, popupProps), {}, {
398
+ return React__default.createElement(React__default.Fragment, null, popup ? React__default.createElement(Popup, Object.assign({}, popupProps, {
629
399
  visible: innerVisible,
630
400
  position: "bottom",
631
401
  round: true,
@@ -639,7 +409,7 @@ var InternalCascader = function InternalCascader2(props, ref) {
639
409
  onCloseIconClick: closePopup
640
410
  }), renderTabs()) : renderTabs());
641
411
  };
642
- var Cascader = React__default.forwardRef(InternalCascader);
412
+ const Cascader = React__default.forwardRef(InternalCascader);
643
413
  Cascader.defaultProps = defaultProps;
644
414
  Cascader.displayName = "NutCascader";
645
415
  export {