@nutui/nutui-react 1.5.1 → 2.0.0-alpha.0

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 (234) hide show
  1. package/CHANGELOG.md +1 -35
  2. package/dist/esm/ActionSheet.js +62 -54
  3. package/dist/esm/Address/style/index.js +0 -1
  4. package/dist/esm/Address.js +235 -330
  5. package/dist/esm/Animate.js +43 -32
  6. package/dist/esm/AnimatingNumbers.js +88 -49
  7. package/dist/esm/Audio/style/index.js +0 -1
  8. package/dist/esm/Audio.js +104 -114
  9. package/dist/esm/Avatar.js +65 -78
  10. package/dist/esm/AvatarContext.js +5 -0
  11. package/dist/esm/AvatarGroup.js +46 -27
  12. package/dist/esm/BackTop/style/index.js +1 -1
  13. package/dist/esm/BackTop.js +74 -76
  14. package/dist/esm/Badge.js +57 -54
  15. package/dist/esm/Barrage.js +45 -32
  16. package/dist/esm/Button/style/index.js +1 -1
  17. package/dist/esm/Button.js +66 -87
  18. package/dist/esm/Calendar.js +80 -79
  19. package/dist/esm/CalendarItem.js +199 -231
  20. package/dist/esm/Card.js +44 -37
  21. package/dist/esm/Cascader.js +430 -433
  22. package/dist/esm/Cell/style/index.js +1 -1
  23. package/dist/esm/Cell.js +57 -87
  24. package/dist/esm/CellGroup.js +7 -5
  25. package/dist/esm/Checkbox/style/index.js +0 -1
  26. package/dist/esm/Checkbox.js +11 -8
  27. package/dist/esm/CheckboxGroup.js +78 -71
  28. package/dist/esm/CircleProgress.js +50 -40
  29. package/dist/esm/Col.js +46 -41
  30. package/dist/esm/Collapse.js +44 -44
  31. package/dist/esm/CollapseItem/style/index.js +1 -1
  32. package/dist/esm/CollapseItem.js +64 -104
  33. package/dist/esm/ConfigProvider.js +400 -101
  34. package/dist/esm/CountDown.js +90 -95
  35. package/dist/esm/DatePicker.js +104 -123
  36. package/dist/esm/Dialog.js +98 -104
  37. package/dist/esm/Divider.js +36 -27
  38. package/dist/esm/Drag.js +55 -59
  39. package/dist/esm/Elevator.js +77 -88
  40. package/dist/esm/Ellipsis.js +80 -79
  41. package/dist/esm/Empty.js +50 -44
  42. package/dist/esm/FixedNav/style/index.js +0 -1
  43. package/dist/esm/FixedNav.js +57 -65
  44. package/dist/esm/Form.js +1154 -123
  45. package/dist/esm/FormItem.js +7 -5
  46. package/dist/esm/Grid/style/index.js +1 -1
  47. package/dist/esm/Grid.js +51 -55
  48. package/dist/esm/GridItem.js +7 -124
  49. package/dist/esm/Icon.js +83 -5
  50. package/dist/esm/Image.js +123 -122
  51. package/dist/esm/ImagePreview.js +75 -93
  52. package/dist/esm/Indicator.js +41 -36
  53. package/dist/esm/Infiniteloading/style/index.js +1 -1
  54. package/dist/esm/Infiniteloading.js +77 -93
  55. package/dist/esm/Input/style/index.js +1 -1
  56. package/dist/esm/Input.js +120 -172
  57. package/dist/esm/InputNumber/style/index.js +1 -1
  58. package/dist/esm/InputNumber.js +133 -167
  59. package/dist/esm/Layout.js +27 -6
  60. package/dist/esm/Menu.js +84 -86
  61. package/dist/esm/MenuItem/style/index.js +0 -1
  62. package/dist/esm/MenuItem.js +76 -86
  63. package/dist/esm/NavBar/style/index.js +1 -1
  64. package/dist/esm/NavBar.js +59 -63
  65. package/dist/esm/NoticeBar/style/index.js +1 -1
  66. package/dist/esm/NoticeBar.js +173 -290
  67. package/dist/esm/Notify.js +112 -78
  68. package/dist/esm/NumberKeyboard.js +110 -109
  69. package/dist/esm/Overlay.js +7 -6
  70. package/dist/esm/Pagination.js +94 -135
  71. package/dist/esm/Picker.js +149 -201
  72. package/dist/esm/Popover/style/index.js +0 -1
  73. package/dist/esm/Popover.js +121 -116
  74. package/dist/esm/Popup/style/index.js +0 -1
  75. package/dist/esm/Popup.js +109 -119
  76. package/dist/esm/Price.js +51 -39
  77. package/dist/esm/Progress/style/index.js +1 -1
  78. package/dist/esm/Progress.js +59 -64
  79. package/dist/esm/PullToRefresh.js +173 -149
  80. package/dist/esm/Radio/style/index.js +0 -1
  81. package/dist/esm/Radio.js +8 -6
  82. package/dist/esm/RadioGroup.js +64 -84
  83. package/dist/esm/Range.js +93 -122
  84. package/dist/esm/Rate/style/index.js +1 -1
  85. package/dist/esm/Rate.js +77 -95
  86. package/dist/esm/Row.js +46 -35
  87. package/dist/esm/SearchBar/style/index.js +1 -1
  88. package/dist/esm/SearchBar.js +110 -120
  89. package/dist/esm/ShortPassword/style/index.js +0 -1
  90. package/dist/esm/ShortPassword.js +120 -116
  91. package/dist/esm/SideNavBar.js +39 -27
  92. package/dist/esm/SideNavBarItem.js +31 -14
  93. package/dist/esm/Signature.js +65 -61
  94. package/dist/esm/Skeleton.js +48 -40
  95. package/dist/esm/Step/style/index.js +1 -1
  96. package/dist/esm/Step.js +49 -49
  97. package/dist/esm/Steps.js +37 -23
  98. package/dist/esm/Sticky.js +111 -120
  99. package/dist/esm/SubSideNavBar.js +50 -38
  100. package/dist/esm/Swipe.js +75 -63
  101. package/dist/esm/Swiper.js +171 -206
  102. package/dist/esm/SwiperItem.js +39 -22
  103. package/dist/esm/Switch.js +46 -37
  104. package/dist/esm/TabPane.js +8 -6
  105. package/dist/esm/Tabbar.js +47 -39
  106. package/dist/esm/TabbarItem/style/index.js +1 -1
  107. package/dist/esm/TabbarItem.js +50 -52
  108. package/dist/esm/Table/style/index.js +1 -1
  109. package/dist/esm/Table.js +70 -70
  110. package/dist/esm/Tabs/style/index.js +1 -2
  111. package/dist/esm/Tabs.js +11 -9
  112. package/dist/esm/Tag/style/index.js +1 -1
  113. package/dist/esm/Tag.js +69 -70
  114. package/dist/esm/TextArea.js +70 -64
  115. package/dist/esm/TimeDetail.js +47 -38
  116. package/dist/esm/TimePannel.js +35 -19
  117. package/dist/esm/TimeSelect.js +60 -68
  118. package/dist/esm/Toast/style/index.js +1 -1
  119. package/dist/esm/Toast.js +126 -98
  120. package/dist/esm/TrendArrow/style/index.js +1 -1
  121. package/dist/esm/TrendArrow.js +59 -55
  122. package/dist/esm/Uploader/style/index.js +0 -1
  123. package/dist/esm/Uploader.js +180 -229
  124. package/dist/esm/UserContext.js +5 -0
  125. package/dist/esm/UserContext2.js +5 -0
  126. package/dist/esm/UserContext3.js +5 -0
  127. package/dist/esm/Video.js +49 -39
  128. package/dist/esm/VirtualList.js +111 -146
  129. package/dist/esm/WaterMark.js +57 -60
  130. package/dist/esm/bem.js +10 -0
  131. package/dist/esm/cellgroup2.js +49 -0
  132. package/dist/esm/checkbox2.js +145 -0
  133. package/dist/esm/{date-c7aad4c0.js → date.js} +13 -11
  134. package/dist/esm/{formitem-8a73a5fb.js → formitem2.js} +83 -50
  135. package/dist/esm/get-scroll-parent.js +26 -0
  136. package/dist/esm/griditem2.js +96 -0
  137. package/dist/esm/index.js +14 -0
  138. package/dist/esm/nutui-react.es.js +188 -94
  139. package/dist/esm/offsetContext.js +19 -0
  140. package/dist/esm/overlay2.js +98 -0
  141. package/dist/esm/px-check.js +6 -0
  142. package/dist/esm/radio2.js +129 -0
  143. package/dist/esm/render.js +95 -0
  144. package/dist/esm/tabpane2.js +44 -0
  145. package/dist/esm/tabs2.js +175 -0
  146. package/dist/esm/typings.js +7 -0
  147. package/dist/esm/use-client-rect.js +32 -0
  148. package/dist/esm/use-props-value.js +18 -0
  149. package/dist/esm/use-touch.js +74 -0
  150. package/dist/locales/base.d.ts +2 -2
  151. package/dist/locales/base.js +1 -1
  152. package/dist/locales/en-US.js +3 -3
  153. package/dist/locales/id-ID.js +3 -3
  154. package/dist/locales/zh-CN.js +3 -3
  155. package/dist/locales/zh-TW.js +3 -3
  156. package/dist/locales/zh-UG.js +3 -3
  157. package/dist/nutui.react.mjs +8327 -4829
  158. package/dist/nutui.react.umd.js +8328 -4830
  159. package/dist/packages/actionsheet/actionsheet.scss +10 -2
  160. package/dist/packages/backtop/backtop.scss +0 -8
  161. package/dist/packages/badge/badge.scss +3 -4
  162. package/dist/packages/button/button.scss +80 -93
  163. package/dist/packages/cell/cell.scss +18 -90
  164. package/dist/packages/cellgroup/cellgroup.scss +26 -20
  165. package/dist/packages/collapseitem/collapseitem.scss +0 -1
  166. package/dist/packages/dialog/dialog.scss +1 -1
  167. package/dist/packages/divider/divider.scss +3 -17
  168. package/dist/packages/grid/grid.scss +1 -0
  169. package/dist/packages/griditem/griditem.scss +2 -17
  170. package/dist/packages/icon/icon.scss +0 -132
  171. package/dist/packages/image/image.scss +0 -12
  172. package/dist/packages/indicator/indicator.scss +21 -39
  173. package/dist/packages/infiniteloading/infiniteloading.scss +4 -12
  174. package/dist/packages/input/input.scss +4 -0
  175. package/dist/packages/inputnumber/inputnumber.scss +10 -26
  176. package/dist/packages/menuitem/menuitem.scss +2 -0
  177. package/dist/packages/navbar/navbar.scss +4 -5
  178. package/dist/packages/overlay/overlay.scss +0 -19
  179. package/dist/packages/picker/picker.scss +97 -103
  180. package/dist/packages/progress/progress.scss +0 -1
  181. package/dist/packages/radio/radio.scss +8 -0
  182. package/dist/packages/rate/rate.scss +29 -6
  183. package/dist/packages/searchbar/searchbar.scss +0 -1
  184. package/dist/packages/shortpassword/shortpassword.scss +4 -1
  185. package/dist/packages/step/step.scss +0 -1
  186. package/dist/packages/sticky/sticky.scss +1 -1
  187. package/dist/packages/swiper/swiper.scss +8 -0
  188. package/dist/packages/tabbaritem/tabbaritem.scss +0 -1
  189. package/dist/packages/table/table.scss +0 -1
  190. package/dist/packages/tag/tag.scss +9 -2
  191. package/dist/packages/timedetail/timedetail.scss +9 -3
  192. package/dist/packages/timeselect/timeselect.scss +1 -1
  193. package/dist/packages/toast/toast.scss +0 -1
  194. package/dist/style.css +1 -1
  195. package/dist/style.mjs +1 -1
  196. package/dist/styles/font-jmapp/config.json +175 -0
  197. package/dist/styles/font-jmapp/demo.css +539 -0
  198. package/dist/styles/font-jmapp/demo_index.html +1821 -0
  199. package/dist/styles/font-jmapp/iconfont.css +299 -0
  200. package/dist/styles/font-jmapp/iconfont.eot +0 -0
  201. package/dist/styles/font-jmapp/iconfont.js +68 -0
  202. package/dist/styles/font-jmapp/iconfont.json +506 -0
  203. package/dist/styles/font-jmapp/iconfont.svg +356 -0
  204. package/dist/styles/font-jmapp/iconfont.ttf +0 -0
  205. package/dist/styles/font-jmapp/iconfont.woff +0 -0
  206. package/dist/styles/font-jmapp/iconfont.woff2 +0 -0
  207. package/dist/styles/theme-default.scss +1 -0
  208. package/dist/styles/theme-jmapp.scss +41 -0
  209. package/dist/styles/themes/default.scss +0 -1
  210. package/dist/styles/variables-jmapp.scss +2601 -0
  211. package/dist/styles/variables.scss +49 -73
  212. package/dist/types/index.d.ts +147 -240
  213. package/package.json +23 -154
  214. package/dist/esm/AvatarContext-15733596.js +0 -3
  215. package/dist/esm/Icon/style/index.js +0 -4
  216. package/dist/esm/UserContext-101ad4a4.js +0 -3
  217. package/dist/esm/UserContext-2629d479.js +0 -3
  218. package/dist/esm/UserContext-b33bcf21.js +0 -3
  219. package/dist/esm/bem-3b438e61.js +0 -8
  220. package/dist/esm/cellgroup-fcc72767.js +0 -34
  221. package/dist/esm/checkbox-44e13cd0.js +0 -137
  222. package/dist/esm/get-scroll-parent-5f85dee8.js +0 -24
  223. package/dist/esm/grid.context-2ee27d95.js +0 -6
  224. package/dist/esm/icon-4ef1581c.js +0 -70
  225. package/dist/esm/index-030b7245.js +0 -11
  226. package/dist/esm/offsetContext-3ab00d40.js +0 -16
  227. package/dist/esm/overlay-de6c79d5.js +0 -83
  228. package/dist/esm/radio-9f141e6b.js +0 -118
  229. package/dist/esm/render-bbebb760.js +0 -79
  230. package/dist/esm/tabpane-01075e6c.js +0 -29
  231. package/dist/esm/tabs-e1b4e4b1.js +0 -181
  232. package/dist/esm/typings-f27b58f4.js +0 -8
  233. package/dist/esm/useClientRect-56bb675b.js +0 -39
  234. package/dist/esm/useTouch-cf73a407.js +0 -99
@@ -6,98 +6,125 @@ 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
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
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); }
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; }
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; }
13
- import React__default, { useState, useEffect } from 'react';
14
- import classNames from 'classnames';
15
- import Popup from './Popup.js';
16
- import { T as Tabs } from './tabs-e1b4e4b1.js';
17
- import { T as TabPane } from './tabpane-01075e6c.js';
18
- import { I as Icon } from './icon-4ef1581c.js';
19
- import { c as cn } from './bem-3b438e61.js';
20
- import './Icon.js';
21
- import './typings-f27b58f4.js';
22
- import './TabPane.js';
23
- import '@bem-react/classname';
9
+ function _toPropertyKey(arg) {
10
+ var key = _toPrimitive(arg, "string");
11
+ return _typeof(key) === "symbol" ? key : String(key);
12
+ }
13
+ function _toPrimitive(input, hint) {
14
+ if (_typeof(input) !== "object" || input === null)
15
+ return input;
16
+ var prim = input[Symbol.toPrimitive];
17
+ if (prim !== void 0) {
18
+ var res = prim.call(input, hint || "default");
19
+ if (_typeof(res) !== "object")
20
+ return res;
21
+ throw new TypeError("@@toPrimitive must return a primitive value.");
22
+ }
23
+ return (hint === "string" ? String : Number)(input);
24
+ }
25
+ function ownKeys(object, enumerableOnly) {
26
+ var keys = Object.keys(object);
27
+ if (Object.getOwnPropertySymbols) {
28
+ var symbols = Object.getOwnPropertySymbols(object);
29
+ enumerableOnly && (symbols = symbols.filter(function(sym) {
30
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
31
+ })), keys.push.apply(keys, symbols);
32
+ }
33
+ return keys;
34
+ }
35
+ function _objectSpread(target) {
36
+ for (var i = 1; i < arguments.length; i++) {
37
+ var source = null != arguments[i] ? arguments[i] : {};
38
+ i % 2 ? ownKeys(Object(source), true).forEach(function(key) {
39
+ _defineProperty(target, key, source[key]);
40
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function(key) {
41
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
42
+ });
43
+ }
44
+ return target;
45
+ }
46
+ import React__default, { isValidElement, useState, useEffect } from "react";
47
+ import classNames from "classnames";
48
+ import Popup from "./Popup.js";
49
+ import { T as Tabs } from "./tabs2.js";
50
+ import { T as TabPane } from "./tabpane2.js";
51
+ import { Loading, Checklist } from "@nutui/icons-react";
52
+ import { c as cn } from "./bem.js";
53
+ import "./typings.js";
54
+ import "./TabPane.js";
55
+ import "@bem-react/classname";
24
56
  var defaultProps$1 = {
25
57
  data: {
26
- text: '',
27
- value: '',
28
- paneKey: '',
58
+ text: "",
59
+ value: "",
60
+ paneKey: "",
29
61
  disabled: false,
30
62
  loading: false,
31
63
  children: []
32
64
  },
33
- activeColor: '#fa2c19',
65
+ activeColor: "",
34
66
  checked: false,
35
- checkedIcon: 'checklist',
36
- chooseItem: function chooseItem() {}
67
+ checkedIcon: "checklist",
68
+ chooseItem: function chooseItem() {
69
+ }
37
70
  };
38
- var InternalCascaderItem = function InternalCascaderItem(props, ref) {
39
- var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props),
40
- data = _defaultProps$1$props.data,
41
- checked = _defaultProps$1$props.checked,
42
- checkedIcon = _defaultProps$1$props.checkedIcon,
43
- chooseItem = _defaultProps$1$props.chooseItem,
44
- activeColor = _defaultProps$1$props.activeColor;
45
- var b = cn('cascader-item');
71
+ var InternalCascaderItem = function InternalCascaderItem2(props, ref) {
72
+ var _defaultProps$1$props = _objectSpread(_objectSpread({}, defaultProps$1), props), data = _defaultProps$1$props.data, checked = _defaultProps$1$props.checked, checkedIcon = _defaultProps$1$props.checkedIcon, chooseItem2 = _defaultProps$1$props.chooseItem, activeColor = _defaultProps$1$props.activeColor;
73
+ var b = cn("cascader-item");
46
74
  var classes = classNames({
47
75
  active: checked,
48
76
  disabled: data.disabled
49
- }, b(''));
50
- var classesTitle = classNames(_defineProperty({}, "".concat(b(''), "__title"), true));
77
+ }, b(""));
78
+ var classesTitle = classNames(_defineProperty({}, "".concat(b(""), "__title"), true));
79
+ var renderIcon = function renderIcon2() {
80
+ if (checked) {
81
+ if (isValidElement(checkedIcon)) {
82
+ return checkedIcon;
83
+ }
84
+ return React__default.createElement(Checklist, {
85
+ className: "".concat(checked ? b("icon-check") : "")
86
+ });
87
+ }
88
+ return null;
89
+ };
51
90
  return React__default.createElement("div", {
52
91
  style: {
53
- color: checked ? activeColor : ''
92
+ color: checked ? activeColor : ""
54
93
  },
55
94
  className: classes,
56
95
  onClick: function onClick() {
57
- chooseItem(data);
96
+ chooseItem2(data);
58
97
  }
59
98
  }, React__default.createElement("div", {
60
99
  className: classesTitle
61
- }, data.text), data.loading ? React__default.createElement(Icon, {
100
+ }, data.text), data.loading ? React__default.createElement(Loading, {
62
101
  color: "#969799",
63
- className: "nut-cascader-item__icon-loading",
64
- name: "loading"
65
- }) : React__default.createElement(Icon, {
66
- className: "".concat(checked ? b('icon-check') : ''),
67
- name: checked ? checkedIcon : ''
68
- }));
102
+ className: "nut-cascader-item__icon-loading"
103
+ }) : renderIcon());
69
104
  };
70
105
  var CascaderItem = React__default.forwardRef(InternalCascaderItem);
71
106
  CascaderItem.defaultProps = defaultProps$1;
72
- CascaderItem.displayName = 'NutCascaderItem';
73
- var formatTree = function formatTree(tree, parent, config) {
74
- return tree.map(function (node) {
75
- var _config$value = config.value,
76
- valueKey = _config$value === void 0 ? 'value' : _config$value,
77
- _config$text = config.text,
78
- textKey = _config$text === void 0 ? 'text' : _config$text,
79
- _config$children = config.children,
80
- childrenKey = _config$children === void 0 ? 'children' : _config$children;
81
- var value = node[valueKey],
82
- text = node[textKey],
83
- children = node[childrenKey],
84
- others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
107
+ CascaderItem.displayName = "NutCascaderItem";
108
+ var formatTree = function formatTree2(tree, parent, config) {
109
+ return tree.map(function(node) {
110
+ 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;
111
+ var value = node[valueKey], text = node[textKey], children = node[childrenKey], others = _objectWithoutProperties(node, [valueKey, textKey, childrenKey].map(_toPropertyKey));
85
112
  var newNode = _objectSpread(_objectSpread({
86
113
  loading: false
87
114
  }, others), {}, {
88
115
  level: parent ? (parent && parent.level || 0) + 1 : 0,
89
- value: value,
90
- text: text,
91
- children: children,
116
+ value,
117
+ text,
118
+ children,
92
119
  _parent: parent
93
120
  });
94
121
  if (newNode.children && newNode.children.length) {
95
- newNode.children = formatTree(newNode.children, newNode, config);
122
+ newNode.children = formatTree2(newNode.children, newNode, config);
96
123
  }
97
124
  return newNode;
98
125
  });
99
126
  };
100
- var eachTree = function eachTree(tree, cb) {
127
+ var eachTree = function eachTree2(tree, cb) {
101
128
  var i = 0;
102
129
  var node;
103
130
  while (node = tree[i++]) {
@@ -105,31 +132,25 @@ var eachTree = function eachTree(tree, cb) {
105
132
  break;
106
133
  }
107
134
  if (node.children && node.children.length) {
108
- eachTree(node.children, cb);
135
+ eachTree2(node.children, cb);
109
136
  }
110
137
  }
111
138
  };
112
139
  var defaultConvertConfig = {
113
140
  topId: null,
114
- idKey: 'id',
115
- pidKey: 'pid',
116
- sortKey: ''
141
+ idKey: "id",
142
+ pidKey: "pid",
143
+ sortKey: ""
117
144
  };
118
- var convertListToOptions = function convertListToOptions(list, options) {
145
+ var convertListToOptions = function convertListToOptions2(list, options) {
119
146
  var mergedOptions = _objectSpread(_objectSpread({}, defaultConvertConfig), options || {});
120
- var topId = mergedOptions.topId,
121
- idKey = mergedOptions.idKey,
122
- pidKey = mergedOptions.pidKey,
123
- sortKey = mergedOptions.sortKey;
147
+ var topId = mergedOptions.topId, idKey = mergedOptions.idKey, pidKey = mergedOptions.pidKey, sortKey = mergedOptions.sortKey;
124
148
  var result = [];
125
149
  var map = {};
126
- list.forEach(function (node) {
150
+ list.forEach(function(node) {
127
151
  node = _objectSpread({}, node);
128
- var _node = node,
129
- id = _node[idKey],
130
- pid = _node[pidKey];
152
+ var _node = node, id = _node[idKey], pid = _node[pidKey];
131
153
  var children = map[pid] = map[pid] || [];
132
- // const children = map[pid] || []
133
154
  if (!result.length && pid === topId) {
134
155
  result = children;
135
156
  }
@@ -137,9 +158,9 @@ var convertListToOptions = function convertListToOptions(list, options) {
137
158
  node.children = map[id] || (map[id] = []);
138
159
  });
139
160
  if (sortKey) {
140
- Object.keys(map).forEach(function (i) {
161
+ Object.keys(map).forEach(function(i) {
141
162
  if (map[i].length > 1) {
142
- map[i].sort(function (a, b) {
163
+ map[i].sort(function(a, b) {
143
164
  return a[sortKey] - b[sortKey];
144
165
  });
145
166
  }
@@ -148,19 +169,18 @@ var convertListToOptions = function convertListToOptions(list, options) {
148
169
  map = null;
149
170
  return result;
150
171
  };
151
- var Tree = /*#__PURE__*/function () {
152
- function Tree(nodes, config) {
172
+ var Tree = /* @__PURE__ */ function() {
173
+ function Tree2(nodes, config) {
153
174
  var _this = this;
154
- _classCallCheck(this, Tree);
175
+ _classCallCheck(this, Tree2);
155
176
  _defineProperty(this, "nodes", void 0);
156
177
  _defineProperty(this, "config", void 0);
157
- _defineProperty(this, "isLeaf", function (node, lazy) {
158
- var leaf = node.leaf,
159
- children = node.children;
178
+ _defineProperty(this, "isLeaf", function(node, lazy) {
179
+ var leaf = node.leaf, children = node.children;
160
180
  var hasChildren = Array.isArray(children) && Boolean(children.length);
161
181
  return leaf || !hasChildren && !lazy;
162
182
  });
163
- _defineProperty(this, "hasChildren", function (node, lazy) {
183
+ _defineProperty(this, "hasChildren", function(node, lazy) {
164
184
  var isLeaf = _this.isLeaf(node, lazy);
165
185
  if (isLeaf) {
166
186
  return false;
@@ -169,13 +189,13 @@ var Tree = /*#__PURE__*/function () {
169
189
  return Array.isArray(children) && Boolean(children.length);
170
190
  });
171
191
  this.config = _objectSpread({
172
- value: 'value',
173
- text: 'text',
174
- children: 'children'
192
+ value: "value",
193
+ text: "text",
194
+ children: "children"
175
195
  }, config || {});
176
196
  this.nodes = formatTree(nodes, null, this.config);
177
197
  }
178
- _createClass(Tree, [{
198
+ _createClass(Tree2, [{
179
199
  key: "updateChildren",
180
200
  value: function updateChildren(nodes, parent) {
181
201
  if (!parent) {
@@ -189,7 +209,7 @@ var Tree = /*#__PURE__*/function () {
189
209
  key: "getNodeByValue",
190
210
  value: function getNodeByValue(value) {
191
211
  var foundNode;
192
- eachTree(this.nodes, function (node) {
212
+ eachTree(this.nodes, function(node) {
193
213
  if (node.value === value) {
194
214
  foundNode = node;
195
215
  return true;
@@ -207,7 +227,7 @@ var Tree = /*#__PURE__*/function () {
207
227
  var pathNodes = [];
208
228
  var currentNodes = this.nodes;
209
229
  while (currentNodes && currentNodes.length) {
210
- var foundNode = currentNodes.find(function (node) {
230
+ var foundNode = currentNodes.find(function(node) {
211
231
  return node.value === value[node.level];
212
232
  });
213
233
  if (!foundNode) {
@@ -219,413 +239,388 @@ var Tree = /*#__PURE__*/function () {
219
239
  return pathNodes;
220
240
  }
221
241
  }]);
222
- return Tree;
242
+ return Tree2;
223
243
  }();
244
+ var Tree$1 = Tree;
224
245
  var defaultProps = _objectSpread({
225
- className: '',
246
+ className: "",
226
247
  style: {},
227
- activeColor: '#fa2c19',
228
- checkedIcon: 'checklist',
229
- tabsColor: '',
248
+ activeColor: "",
249
+ checkedIcon: "checklist",
250
+ tabsColor: "",
230
251
  poppable: true,
231
252
  visible: false,
232
253
  options: [],
233
254
  value: [],
234
- title: '',
235
- textKey: 'text',
236
- valueKey: 'value',
237
- childrenKey: 'children',
255
+ title: "",
256
+ textKey: "text",
257
+ valueKey: "value",
258
+ childrenKey: "children",
238
259
  convertConfig: {},
239
260
  closeable: false,
240
- closeIconPosition: 'top-right',
241
- closeIcon: 'close',
261
+ closeIconPosition: "top-right",
262
+ closeIcon: "close",
242
263
  lazy: false,
243
- lazyLoad: function lazyLoad() {},
244
- onClose: function onClose() {},
245
- onChange: function onChange() {},
246
- onPathChange: function onPathChange() {}
264
+ lazyLoad: function lazyLoad() {
265
+ },
266
+ onClose: function onClose() {
267
+ },
268
+ onChange: function onChange() {
269
+ },
270
+ onPathChange: function onPathChange() {
271
+ }
247
272
  }, Popup.defaultProps);
248
- var InternalCascader = function InternalCascader(props, ref) {
249
- var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props),
250
- className = _defaultProps$props.className,
251
- style = _defaultProps$props.style,
252
- tabsColor = _defaultProps$props.tabsColor,
253
- poppable = _defaultProps$props.poppable,
254
- visible = _defaultProps$props.visible,
255
- options = _defaultProps$props.options,
256
- value = _defaultProps$props.value,
257
- title = _defaultProps$props.title,
258
- textKey = _defaultProps$props.textKey,
259
- valueKey = _defaultProps$props.valueKey,
260
- childrenKey = _defaultProps$props.childrenKey,
261
- convertConfig = _defaultProps$props.convertConfig,
262
- closeable = _defaultProps$props.closeable,
263
- closeIconPosition = _defaultProps$props.closeIconPosition,
264
- closeIcon = _defaultProps$props.closeIcon,
265
- lazy = _defaultProps$props.lazy,
266
- lazyLoad = _defaultProps$props.lazyLoad,
267
- onClose = _defaultProps$props.onClose,
268
- onChange = _defaultProps$props.onChange,
269
- onPathChange = _defaultProps$props.onPathChange;
270
- var _useState = useState('c1'),
271
- _useState2 = _slicedToArray(_useState, 2),
272
- tabvalue = _useState2[0],
273
- setTabvalue = _useState2[1];
274
- var _useState3 = useState([]),
275
- _useState4 = _slicedToArray(_useState3, 2),
276
- optionsData = _useState4[0],
277
- setOptionsData = _useState4[1];
278
- var isLazy = function isLazy() {
273
+ var InternalCascader = function InternalCascader2(props, ref) {
274
+ var _defaultProps$props = _objectSpread(_objectSpread({}, defaultProps), props), className = _defaultProps$props.className, style = _defaultProps$props.style, tabsColor = _defaultProps$props.tabsColor, poppable = _defaultProps$props.poppable, visible = _defaultProps$props.visible, options = _defaultProps$props.options, value = _defaultProps$props.value, title = _defaultProps$props.title, textKey = _defaultProps$props.textKey, valueKey = _defaultProps$props.valueKey, childrenKey = _defaultProps$props.childrenKey, convertConfig = _defaultProps$props.convertConfig, closeable = _defaultProps$props.closeable, closeIconPosition = _defaultProps$props.closeIconPosition, closeIcon = _defaultProps$props.closeIcon, lazy = _defaultProps$props.lazy, lazyLoad2 = _defaultProps$props.lazyLoad, onClose2 = _defaultProps$props.onClose, onChange2 = _defaultProps$props.onChange, onPathChange2 = _defaultProps$props.onPathChange;
275
+ var _useState = useState("c1"), _useState2 = _slicedToArray(_useState, 2), tabvalue = _useState2[0], setTabvalue = _useState2[1];
276
+ var _useState3 = useState([]), _useState4 = _slicedToArray(_useState3, 2), optionsData = _useState4[0], setOptionsData = _useState4[1];
277
+ var isLazy = function isLazy2() {
279
278
  return state.configs.lazy && Boolean(state.configs.lazyLoad);
280
279
  };
281
280
  var _useState5 = useState({
282
- optionsData: [],
283
- panes: [{
284
- nodes: [],
285
- selectedNode: [],
286
- paneKey: ''
287
- }],
288
- innerValue: value,
289
- tree: new Tree([], {}),
290
- tabsCursor: 0,
291
- initLoading: false,
292
- currentProcessNode: [],
293
- configs: {
294
- lazy: lazy,
295
- lazyLoad: lazyLoad,
296
- valueKey: valueKey,
297
- textKey: textKey,
298
- childrenKey: childrenKey,
299
- convertConfig: convertConfig
300
- },
301
- lazyLoadMap: new Map()
302
- }),
303
- _useState6 = _slicedToArray(_useState5, 1),
304
- state = _useState6[0];
305
- var b = cn('cascader');
306
- var classes = classNames(b(''));
307
- var classesPane = classNames(_defineProperty({}, "".concat(b(''), "-pane"), true));
308
- useEffect(function () {
281
+ optionsData: [],
282
+ panes: [{
283
+ nodes: [],
284
+ selectedNode: [],
285
+ paneKey: ""
286
+ }],
287
+ innerValue: value,
288
+ tree: new Tree$1([], {}),
289
+ tabsCursor: 0,
290
+ initLoading: false,
291
+ currentProcessNode: [],
292
+ configs: {
293
+ lazy,
294
+ lazyLoad: lazyLoad2,
295
+ valueKey,
296
+ textKey,
297
+ childrenKey,
298
+ convertConfig
299
+ },
300
+ lazyLoadMap: /* @__PURE__ */ new Map()
301
+ }), _useState6 = _slicedToArray(_useState5, 1), state = _useState6[0];
302
+ var b = cn("cascader");
303
+ var classes = classNames(b(""));
304
+ var classesPane = classNames(_defineProperty({}, "".concat(b(""), "-pane"), true));
305
+ useEffect(function() {
309
306
  initData();
310
307
  }, []);
311
- useEffect(function () {
308
+ useEffect(function() {
312
309
  if (value !== state.innerValue) {
313
310
  state.innerValue = value;
314
311
  }
315
312
  }, [value]);
316
- useEffect(function () {
313
+ useEffect(function() {
317
314
  initData();
318
315
  }, [options]);
319
- var initData = /*#__PURE__*/function () {
320
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
316
+ var initData = /* @__PURE__ */ function() {
317
+ var _ref = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee() {
321
318
  return _regeneratorRuntime.wrap(function _callee$(_context) {
322
- while (1) switch (_context.prev = _context.next) {
323
- case 0:
324
- // 初始化开始处理数据
325
- state.lazyLoadMap.clear();
326
- if (convertConfig && Object.keys(convertConfig).length > 0) {
327
- state.optionsData = convertListToOptions(options, convertConfig);
328
- } else {
329
- state.optionsData = options;
330
- }
331
- state.tree = new Tree(state.optionsData, {
332
- value: state.configs.valueKey,
333
- text: state.configs.textKey,
334
- children: state.configs.childrenKey
335
- });
336
- if (!(isLazy() && !state.tree.nodes.length)) {
319
+ while (1)
320
+ switch (_context.prev = _context.next) {
321
+ case 0:
322
+ state.lazyLoadMap.clear();
323
+ if (convertConfig && Object.keys(convertConfig).length > 0) {
324
+ state.optionsData = convertListToOptions(options, convertConfig);
325
+ } else {
326
+ state.optionsData = options;
327
+ }
328
+ state.tree = new Tree$1(state.optionsData, {
329
+ value: state.configs.valueKey,
330
+ text: state.configs.textKey,
331
+ children: state.configs.childrenKey
332
+ });
333
+ if (!(isLazy() && !state.tree.nodes.length)) {
334
+ _context.next = 6;
335
+ break;
336
+ }
337
337
  _context.next = 6;
338
- break;
339
- }
340
- _context.next = 6;
341
- return invokeLazyLoad({
342
- root: true,
343
- loading: true,
344
- text: '',
345
- value: ''
346
- });
347
- case 6:
348
- state.panes = [{
349
- nodes: state.tree.nodes,
350
- selectedNode: null,
351
- paneKey: 'c1'
352
- }];
353
- syncValue();
354
- setOptionsData(state.panes);
355
- case 9:
356
- case "end":
357
- return _context.stop();
358
- }
338
+ return invokeLazyLoad({
339
+ root: true,
340
+ loading: true,
341
+ text: "",
342
+ value: ""
343
+ });
344
+ case 6:
345
+ state.panes = [{
346
+ nodes: state.tree.nodes,
347
+ selectedNode: null,
348
+ paneKey: "c1"
349
+ }];
350
+ syncValue();
351
+ setOptionsData(state.panes);
352
+ case 9:
353
+ case "end":
354
+ return _context.stop();
355
+ }
359
356
  }, _callee);
360
357
  }));
361
- return function initData() {
358
+ return function initData2() {
362
359
  return _ref.apply(this, arguments);
363
360
  };
364
361
  }();
365
- // 处理有默认值时的数据
366
- var syncValue = /*#__PURE__*/function () {
367
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
362
+ var syncValue = /* @__PURE__ */ function() {
363
+ var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee3() {
368
364
  var currentValue, needToSync, parent, last, pathNodes;
369
365
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
370
- while (1) switch (_context3.prev = _context3.next) {
371
- case 0:
372
- currentValue = state.innerValue;
373
- if (!(currentValue === undefined || !state.tree.nodes.length)) {
374
- _context3.next = 3;
375
- break;
376
- }
377
- return _context3.abrupt("return");
378
- case 3:
379
- if (!(currentValue.length === 0)) {
380
- _context3.next = 6;
381
- break;
382
- }
383
- state.tabsCursor = 0;
384
- return _context3.abrupt("return");
385
- case 6:
386
- needToSync = currentValue;
387
- if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
388
- _context3.next = 19;
389
- break;
390
- }
391
- needToSync = [];
392
- parent = state.tree.nodes.find(function (node) {
393
- return node.value === currentValue[0];
394
- });
395
- if (!parent) {
396
- _context3.next = 19;
397
- break;
398
- }
399
- needToSync = [parent.value];
400
- state.initLoading = true;
401
- _context3.next = 15;
402
- return currentValue.slice(1).reduce( /*#__PURE__*/function () {
403
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(p, value) {
404
- var _parent$children;
405
- var parent, node;
406
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
407
- while (1) switch (_context2.prev = _context2.next) {
408
- case 0:
409
- _context2.next = 2;
410
- return p;
411
- case 2:
412
- parent = _context2.sent;
413
- _context2.next = 5;
414
- return invokeLazyLoad(parent);
415
- case 5:
416
- node = parent === null || parent === void 0 ? void 0 : (_parent$children = parent.children) === null || _parent$children === void 0 ? void 0 : _parent$children.find(function (item) {
417
- return item.value === value;
418
- });
419
- if (node) {
420
- needToSync.push(value);
421
- }
422
- return _context2.abrupt("return", Promise.resolve(node));
423
- case 8:
424
- case "end":
425
- return _context2.stop();
426
- }
427
- }, _callee2);
428
- }));
429
- return function (_x, _x2) {
430
- return _ref3.apply(this, arguments);
431
- };
432
- }(), Promise.resolve(parent));
433
- case 15:
434
- last = _context3.sent;
435
- _context3.next = 18;
436
- return invokeLazyLoad(last);
437
- case 18:
438
- state.initLoading = false;
439
- case 19:
440
- if (needToSync.length && currentValue === value) {
441
- pathNodes = state.tree.getPathNodesByValue(needToSync);
442
- pathNodes.forEach(function (node, index) {
443
- state.tabsCursor = index;
444
- // 当有默认值时,不触发 chooseItem 里的 emit 事件
445
- _chooseItem(node, true);
366
+ while (1)
367
+ switch (_context3.prev = _context3.next) {
368
+ case 0:
369
+ currentValue = state.innerValue;
370
+ if (!(currentValue === void 0 || !state.tree.nodes.length)) {
371
+ _context3.next = 3;
372
+ break;
373
+ }
374
+ return _context3.abrupt("return");
375
+ case 3:
376
+ if (!(currentValue.length === 0)) {
377
+ _context3.next = 6;
378
+ break;
379
+ }
380
+ state.tabsCursor = 0;
381
+ return _context3.abrupt("return");
382
+ case 6:
383
+ needToSync = currentValue;
384
+ if (!(isLazy() && Array.isArray(currentValue) && currentValue.length)) {
385
+ _context3.next = 19;
386
+ break;
387
+ }
388
+ needToSync = [];
389
+ parent = state.tree.nodes.find(function(node) {
390
+ return node.value === currentValue[0];
446
391
  });
447
- }
448
- case 20:
449
- case "end":
450
- return _context3.stop();
451
- }
392
+ if (!parent) {
393
+ _context3.next = 19;
394
+ break;
395
+ }
396
+ needToSync = [parent.value];
397
+ state.initLoading = true;
398
+ _context3.next = 15;
399
+ return currentValue.slice(1).reduce(/* @__PURE__ */ function() {
400
+ var _ref3 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee2(p, value2) {
401
+ var _parent2$children;
402
+ var parent2, node;
403
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
404
+ while (1)
405
+ switch (_context2.prev = _context2.next) {
406
+ case 0:
407
+ _context2.next = 2;
408
+ return p;
409
+ case 2:
410
+ parent2 = _context2.sent;
411
+ _context2.next = 5;
412
+ return invokeLazyLoad(parent2);
413
+ case 5:
414
+ node = parent2 === null || parent2 === void 0 ? void 0 : (_parent2$children = parent2.children) === null || _parent2$children === void 0 ? void 0 : _parent2$children.find(function(item) {
415
+ return item.value === value2;
416
+ });
417
+ if (node) {
418
+ needToSync.push(value2);
419
+ }
420
+ return _context2.abrupt("return", Promise.resolve(node));
421
+ case 8:
422
+ case "end":
423
+ return _context2.stop();
424
+ }
425
+ }, _callee2);
426
+ }));
427
+ return function(_x, _x2) {
428
+ return _ref3.apply(this, arguments);
429
+ };
430
+ }(), Promise.resolve(parent));
431
+ case 15:
432
+ last = _context3.sent;
433
+ _context3.next = 18;
434
+ return invokeLazyLoad(last);
435
+ case 18:
436
+ state.initLoading = false;
437
+ case 19:
438
+ if (needToSync.length && currentValue === value) {
439
+ pathNodes = state.tree.getPathNodesByValue(needToSync);
440
+ pathNodes.forEach(function(node, index) {
441
+ state.tabsCursor = index;
442
+ _chooseItem(node, true);
443
+ });
444
+ }
445
+ case 20:
446
+ case "end":
447
+ return _context3.stop();
448
+ }
452
449
  }, _callee3);
453
450
  }));
454
- return function syncValue() {
451
+ return function syncValue2() {
455
452
  return _ref2.apply(this, arguments);
456
453
  };
457
454
  }();
458
- var invokeLazyLoad = /*#__PURE__*/function () {
459
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(node) {
455
+ var invokeLazyLoad = /* @__PURE__ */ function() {
456
+ var _ref4 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee4(node) {
460
457
  var parent, lazyLoadPromise, nodes;
461
458
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
462
- while (1) switch (_context4.prev = _context4.next) {
463
- case 0:
464
- if (node) {
465
- _context4.next = 2;
466
- break;
467
- }
468
- return _context4.abrupt("return");
469
- case 2:
470
- if (state.configs.lazyLoad) {
471
- _context4.next = 5;
472
- break;
473
- }
474
- node.leaf = true;
475
- return _context4.abrupt("return");
476
- case 5:
477
- if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
478
- _context4.next = 7;
479
- break;
480
- }
481
- return _context4.abrupt("return");
482
- case 7:
483
- node.loading = true;
484
- parent = node.root ? null : node;
485
- lazyLoadPromise = state.lazyLoadMap.get(node);
486
- if (!lazyLoadPromise) {
487
- lazyLoadPromise = new Promise(function (resolve) {
488
- var _state$configs$lazyLo, _state$configs;
489
- // 外部必须resolve
490
- (_state$configs$lazyLo = (_state$configs = state.configs).lazyLoad) === null || _state$configs$lazyLo === void 0 ? void 0 : _state$configs$lazyLo.call(_state$configs, node, resolve);
491
- });
492
- state.lazyLoadMap.set(node, lazyLoadPromise);
493
- }
494
- _context4.next = 13;
495
- return lazyLoadPromise;
496
- case 13:
497
- nodes = _context4.sent;
498
- if (Array.isArray(nodes) && nodes.length > 0) {
499
- state.tree.updateChildren(nodes, parent);
500
- } else {
501
- // 如果加载完成后没有提供子节点,作为叶子节点处理
459
+ while (1)
460
+ switch (_context4.prev = _context4.next) {
461
+ case 0:
462
+ if (node) {
463
+ _context4.next = 2;
464
+ break;
465
+ }
466
+ return _context4.abrupt("return");
467
+ case 2:
468
+ if (state.configs.lazyLoad) {
469
+ _context4.next = 5;
470
+ break;
471
+ }
502
472
  node.leaf = true;
503
- }
504
- node.loading = false;
505
- state.lazyLoadMap["delete"](node);
506
- case 17:
507
- case "end":
508
- return _context4.stop();
509
- }
473
+ return _context4.abrupt("return");
474
+ case 5:
475
+ if (!(state.tree.isLeaf(node, isLazy()) || state.tree.hasChildren(node, isLazy()))) {
476
+ _context4.next = 7;
477
+ break;
478
+ }
479
+ return _context4.abrupt("return");
480
+ case 7:
481
+ node.loading = true;
482
+ parent = node.root ? null : node;
483
+ lazyLoadPromise = state.lazyLoadMap.get(node);
484
+ if (!lazyLoadPromise) {
485
+ lazyLoadPromise = new Promise(function(resolve) {
486
+ var _state$configs$lazyLo, _state$configs;
487
+ (_state$configs$lazyLo = (_state$configs = state.configs).lazyLoad) === null || _state$configs$lazyLo === void 0 ? void 0 : _state$configs$lazyLo.call(_state$configs, node, resolve);
488
+ });
489
+ state.lazyLoadMap.set(node, lazyLoadPromise);
490
+ }
491
+ _context4.next = 13;
492
+ return lazyLoadPromise;
493
+ case 13:
494
+ nodes = _context4.sent;
495
+ if (Array.isArray(nodes) && nodes.length > 0) {
496
+ state.tree.updateChildren(nodes, parent);
497
+ } else {
498
+ node.leaf = true;
499
+ }
500
+ node.loading = false;
501
+ state.lazyLoadMap["delete"](node);
502
+ case 17:
503
+ case "end":
504
+ return _context4.stop();
505
+ }
510
506
  }, _callee4);
511
507
  }));
512
- return function invokeLazyLoad(_x3) {
508
+ return function invokeLazyLoad2(_x3) {
513
509
  return _ref4.apply(this, arguments);
514
510
  };
515
511
  }();
516
- var close = function close() {
517
- onClose && onClose();
512
+ var close = function close2() {
513
+ onClose2 && onClose2();
518
514
  };
519
- var closePopup = function closePopup() {
515
+ var closePopup = function closePopup2() {
520
516
  close();
521
517
  };
522
- /* type: 是否是静默模式,是的话不触发事件
523
- tabsCursor: tab的索引 */
524
- var _chooseItem = /*#__PURE__*/function () {
525
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(node, type) {
518
+ var _chooseItem = /* @__PURE__ */ function() {
519
+ var _ref5 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime.mark(function _callee5(node, type) {
526
520
  var pathNodes, optionParams, level, _pathNodes, _optionParams;
527
521
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
528
- while (1) switch (_context5.prev = _context5.next) {
529
- case 0:
530
- if (!(!type && node.disabled || !state.panes[state.tabsCursor])) {
531
- _context5.next = 2;
532
- break;
533
- }
534
- return _context5.abrupt("return");
535
- case 2:
536
- if (!state.tree.isLeaf(node, isLazy())) {
537
- _context5.next = 10;
538
- break;
539
- }
540
- node.leaf = true;
541
- state.panes[state.tabsCursor].selectedNode = node;
542
- state.panes = state.panes.slice(0, node.level + 1);
543
- if (!type) {
544
- pathNodes = state.panes.map(function (item) {
545
- return item.selectedNode;
546
- });
547
- optionParams = pathNodes.map(function (item) {
548
- return item.value;
549
- });
550
- onChange(optionParams, pathNodes);
551
- onPathChange(optionParams, pathNodes);
552
- }
553
- setOptionsData(state.panes);
554
- close();
555
- return _context5.abrupt("return");
556
- case 10:
557
- if (!state.tree.hasChildren(node, isLazy())) {
558
- _context5.next = 20;
559
- break;
560
- }
561
- level = node.level + 1;
562
- state.panes[state.tabsCursor].selectedNode = node;
563
- state.panes = state.panes.slice(0, level);
564
- state.tabsCursor = level;
565
- state.panes.push({
566
- nodes: node.children || [],
567
- selectedNode: null,
568
- paneKey: "c".concat(state.tabsCursor + 1)
569
- });
570
- setTabvalue("c".concat(state.tabsCursor + 1));
571
- setOptionsData(state.panes);
572
- if (!type) {
573
- _pathNodes = state.panes.map(function (item) {
574
- return item.selectedNode;
575
- });
576
- _optionParams = _pathNodes.map(function (item) {
577
- return item === null || item === void 0 ? void 0 : item.value;
578
- });
579
- onPathChange(_optionParams, _pathNodes);
580
- }
581
- return _context5.abrupt("return");
582
- case 20:
583
- state.currentProcessNode = node;
584
- if (!node.loading) {
585
- _context5.next = 23;
586
- break;
587
- }
588
- return _context5.abrupt("return");
589
- case 23:
590
- _context5.next = 25;
591
- return invokeLazyLoad(node);
592
- case 25:
593
- if (state.currentProcessNode === node) {
522
+ while (1)
523
+ switch (_context5.prev = _context5.next) {
524
+ case 0:
525
+ if (!(!type && node.disabled || !state.panes[state.tabsCursor])) {
526
+ _context5.next = 2;
527
+ break;
528
+ }
529
+ return _context5.abrupt("return");
530
+ case 2:
531
+ if (!state.tree.isLeaf(node, isLazy())) {
532
+ _context5.next = 10;
533
+ break;
534
+ }
535
+ node.leaf = true;
594
536
  state.panes[state.tabsCursor].selectedNode = node;
595
- _chooseItem(node, type);
596
- }
597
- setOptionsData(state.panes);
598
- case 27:
599
- case "end":
600
- return _context5.stop();
601
- }
537
+ state.panes = state.panes.slice(0, node.level + 1);
538
+ if (!type) {
539
+ pathNodes = state.panes.map(function(item) {
540
+ return item.selectedNode;
541
+ });
542
+ optionParams = pathNodes.map(function(item) {
543
+ return item.value;
544
+ });
545
+ onChange2(optionParams, pathNodes);
546
+ onPathChange2(optionParams, pathNodes);
547
+ }
548
+ setOptionsData(state.panes);
549
+ close();
550
+ return _context5.abrupt("return");
551
+ case 10:
552
+ if (!state.tree.hasChildren(node, isLazy())) {
553
+ _context5.next = 20;
554
+ break;
555
+ }
556
+ level = node.level + 1;
557
+ state.panes[state.tabsCursor].selectedNode = node;
558
+ state.panes = state.panes.slice(0, level);
559
+ state.tabsCursor = level;
560
+ state.panes.push({
561
+ nodes: node.children || [],
562
+ selectedNode: null,
563
+ paneKey: "c".concat(state.tabsCursor + 1)
564
+ });
565
+ setTabvalue("c".concat(state.tabsCursor + 1));
566
+ setOptionsData(state.panes);
567
+ if (!type) {
568
+ _pathNodes = state.panes.map(function(item) {
569
+ return item.selectedNode;
570
+ });
571
+ _optionParams = _pathNodes.map(function(item) {
572
+ return item === null || item === void 0 ? void 0 : item.value;
573
+ });
574
+ onPathChange2(_optionParams, _pathNodes);
575
+ }
576
+ return _context5.abrupt("return");
577
+ case 20:
578
+ state.currentProcessNode = node;
579
+ if (!node.loading) {
580
+ _context5.next = 23;
581
+ break;
582
+ }
583
+ return _context5.abrupt("return");
584
+ case 23:
585
+ _context5.next = 25;
586
+ return invokeLazyLoad(node);
587
+ case 25:
588
+ if (state.currentProcessNode === node) {
589
+ state.panes[state.tabsCursor].selectedNode = node;
590
+ _chooseItem(node, type);
591
+ }
592
+ setOptionsData(state.panes);
593
+ case 27:
594
+ case "end":
595
+ return _context5.stop();
596
+ }
602
597
  }, _callee5);
603
598
  }));
604
- return function chooseItem(_x4, _x5) {
599
+ return function chooseItem2(_x4, _x5) {
605
600
  return _ref5.apply(this, arguments);
606
601
  };
607
602
  }();
608
- var renderItem = function renderItem() {
603
+ var renderItem = function renderItem2() {
609
604
  return React__default.createElement("div", {
610
605
  className: "".concat(classes, " ").concat(className),
611
- style: style
606
+ style
612
607
  }, poppable && React__default.createElement("div", {
613
- className: b('title')
608
+ className: b("title")
614
609
  }, title), React__default.createElement(Tabs, {
615
610
  value: tabvalue,
616
611
  titleNode: function titleNode() {
617
- return optionsData.map(function (pane, index) {
612
+ return optionsData.map(function(pane, index) {
618
613
  var _pane$selectedNode, _pane$selectedNode2;
619
614
  return React__default.createElement("div", {
620
615
  onClick: function onClick() {
621
616
  setTabvalue(pane.paneKey);
622
617
  state.tabsCursor = index;
623
618
  },
624
- className: "nut-tabs__titles-item ".concat(tabvalue === pane.paneKey ? 'active' : ''),
619
+ className: "nut-tabs__titles-item ".concat(tabvalue === pane.paneKey ? "active" : ""),
625
620
  key: pane.paneKey
626
621
  }, React__default.createElement("span", {
627
622
  className: "nut-tabs__titles-item__text"
628
- }, !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", {
623
+ }, !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", {
629
624
  className: "nut-tabs__titles-item__line",
630
625
  style: {
631
626
  background: tabsColor
@@ -633,21 +628,21 @@ var InternalCascader = function InternalCascader(props, ref) {
633
628
  }));
634
629
  });
635
630
  }
636
- }, !state.initLoading && state.panes.length ? optionsData.map(function (pane) {
631
+ }, !state.initLoading && state.panes.length ? optionsData.map(function(pane) {
637
632
  return React__default.createElement(TabPane, {
638
633
  key: pane.paneKey,
639
634
  paneKey: pane.paneKey
640
635
  }, React__default.createElement("div", {
641
636
  className: classesPane
642
- }, pane.nodes && pane.nodes.map(function (node, index) {
637
+ }, pane.nodes && pane.nodes.map(function(node, index) {
643
638
  var _pane$selectedNode3;
644
639
  return React__default.createElement(CascaderItem, _objectSpread(_objectSpread({
645
640
  key: index
646
641
  }, props), {}, {
647
642
  data: node,
648
643
  checked: ((_pane$selectedNode3 = pane.selectedNode) === null || _pane$selectedNode3 === void 0 ? void 0 : _pane$selectedNode3.value) === node.value,
649
- chooseItem: function chooseItem(node) {
650
- return _chooseItem(node, false);
644
+ chooseItem: function chooseItem2(node2) {
645
+ return _chooseItem(node2, false);
651
646
  }
652
647
  }));
653
648
  })));
@@ -657,17 +652,19 @@ var InternalCascader = function InternalCascader(props, ref) {
657
652
  };
658
653
  return React__default.createElement(React__default.Fragment, null, poppable ? React__default.createElement(Popup, {
659
654
  popClass: "cascadar-popup",
660
- visible: visible,
655
+ visible,
661
656
  position: "bottom",
662
657
  round: true,
663
- closeable: closeable,
664
- closeIconPosition: closeIconPosition,
665
- closeIcon: closeIcon,
658
+ closeIcon,
659
+ closeable,
660
+ closeIconPosition,
666
661
  onClickOverlay: closePopup,
667
662
  onClickCloseIcon: closePopup
668
663
  }, renderItem()) : renderItem());
669
664
  };
670
665
  var Cascader = React__default.forwardRef(InternalCascader);
671
666
  Cascader.defaultProps = defaultProps;
672
- Cascader.displayName = 'NutCascader';
673
- export { Cascader as default };
667
+ Cascader.displayName = "NutCascader";
668
+ export {
669
+ Cascader as default
670
+ };