@qsxy/element-plus-react 1.0.2 → 1.0.3

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 (216) hide show
  1. package/dist/Alert/Alert.d.ts +7 -0
  2. package/dist/Alert/Alert.js +98 -0
  3. package/dist/Alert/index.d.ts +2 -0
  4. package/dist/Alert/index.js +1 -0
  5. package/dist/Alert/typings.d.ts +45 -0
  6. package/dist/Alert/typings.js +1 -0
  7. package/dist/Card/Card.js +5 -3
  8. package/dist/Cascader/useCascader.d.ts +0 -14
  9. package/dist/Cascader/useCascader.js +33 -32
  10. package/dist/Checkbox/Checkbox.js +3 -2
  11. package/dist/ConfigProvider/ConfigProvider.js +2 -24
  12. package/dist/ConfigProvider/ConfigProviderContext.js +1 -1
  13. package/dist/ConfigProvider/typings.d.ts +1 -1
  14. package/dist/Container/Main.d.ts +1 -1
  15. package/dist/Container/typings.d.ts +1 -1
  16. package/dist/Dialog/Dialog.js +5 -12
  17. package/dist/Input/Input.js +68 -43
  18. package/dist/Input/TextArea.js +1 -1
  19. package/dist/Input/typings.d.ts +42 -1
  20. package/dist/Input/utils.d.ts +1 -0
  21. package/dist/Input/utils.js +5 -1
  22. package/dist/InputNumber/InputNumber.js +351 -141
  23. package/dist/InputNumber/typings.d.ts +15 -1
  24. package/dist/Loading/Loading.js +5 -2
  25. package/dist/Menu/Menu.js +25 -1
  26. package/dist/Menu/MenuItem.js +4 -2
  27. package/dist/Menu/SubMenu.js +2 -2
  28. package/dist/Menu/SubMenuCollapseTransition.js +14 -9
  29. package/dist/Menu/typings.d.ts +2 -1
  30. package/dist/Message/Message.js +51 -23
  31. package/dist/Message/index.js +8 -10
  32. package/dist/Message/typings.d.ts +8 -5
  33. package/dist/MessageBox/MessageBox.js +52 -30
  34. package/dist/MessageBox/index.d.ts +2 -1
  35. package/dist/MessageBox/index.js +4 -2
  36. package/dist/MessageBox/typings.d.ts +3 -0
  37. package/dist/Notification/Notification.js +26 -19
  38. package/dist/Select/SelectContext.d.ts +2 -1
  39. package/dist/Select/SelectContext.js +2 -1
  40. package/dist/Select/SelectCore.js +13 -7
  41. package/dist/Select/SelectDropdown.js +23 -15
  42. package/dist/Select/index.d.ts +1 -1
  43. package/dist/Select/typings.d.ts +13 -9
  44. package/dist/Select/useSelect.d.ts +13 -10
  45. package/dist/Select/useSelect.js +34 -26
  46. package/dist/Space/Space.d.ts +4 -0
  47. package/dist/Space/Space.js +128 -0
  48. package/dist/Space/SpaceItem.d.ts +7 -0
  49. package/dist/Space/SpaceItem.js +14 -0
  50. package/dist/Space/index.d.ts +3 -0
  51. package/dist/Space/index.js +2 -0
  52. package/dist/Space/typings.d.ts +26 -0
  53. package/dist/Space/typings.js +1 -0
  54. package/dist/Space/useSpace.d.ts +7 -0
  55. package/dist/Space/useSpace.js +104 -0
  56. package/dist/Statistic/Statistic.d.ts +4 -0
  57. package/dist/Statistic/Statistic.js +92 -0
  58. package/dist/Statistic/index.d.ts +2 -0
  59. package/dist/Statistic/index.js +1 -0
  60. package/dist/Statistic/typings.d.ts +28 -0
  61. package/dist/Statistic/typings.js +1 -0
  62. package/dist/Switch/Switch.js +2 -2
  63. package/dist/Table/Table.js +3 -0
  64. package/dist/Table/typings.d.ts +2 -0
  65. package/dist/Tag/typings.d.ts +1 -1
  66. package/dist/Text/Text.d.ts +4 -0
  67. package/dist/Text/Text.js +84 -0
  68. package/dist/Text/index.d.ts +2 -0
  69. package/dist/Text/index.js +1 -0
  70. package/dist/Text/typings.d.ts +15 -0
  71. package/dist/Text/typings.js +1 -0
  72. package/dist/Tree/CollapseTransition.d.ts +7 -0
  73. package/dist/Tree/CollapseTransition.js +60 -0
  74. package/dist/Tree/Tree.d.ts +3 -140
  75. package/dist/Tree/Tree.js +350 -77
  76. package/dist/Tree/TreeContext.d.ts +9 -0
  77. package/dist/Tree/TreeContext.js +14 -0
  78. package/dist/Tree/TreeNode.d.ts +5 -3
  79. package/dist/Tree/TreeNode.js +321 -331
  80. package/dist/Tree/TreeNodeContent.d.ts +9 -0
  81. package/dist/Tree/TreeNodeContent.js +22 -0
  82. package/dist/Tree/index.d.ts +3 -8
  83. package/dist/Tree/index.js +1 -4
  84. package/dist/Tree/model/node.d.ts +62 -0
  85. package/dist/Tree/model/node.js +601 -0
  86. package/dist/Tree/model/tree-store.d.ts +52 -0
  87. package/dist/Tree/model/tree-store.js +510 -0
  88. package/dist/Tree/model/useDragNode.d.ts +30 -0
  89. package/dist/Tree/model/useDragNode.js +293 -0
  90. package/dist/Tree/model/useKeydown.d.ts +0 -0
  91. package/dist/Tree/model/useKeydown.js +104 -0
  92. package/dist/Tree/model/useNodeExpandEventBroadcast.d.ts +15 -0
  93. package/dist/Tree/model/useNodeExpandEventBroadcast.js +54 -0
  94. package/dist/Tree/model/util.d.ts +7 -0
  95. package/dist/Tree/model/util.js +24 -0
  96. package/dist/Tree/typings.d.ts +225 -114
  97. package/dist/TreeSelect/TreeSelect.d.ts +2 -10
  98. package/dist/TreeSelect/TreeSelect.js +90 -566
  99. package/dist/TreeSelect/TreeSelectOption.d.ts +6 -0
  100. package/dist/TreeSelect/TreeSelectOption.js +62 -0
  101. package/dist/TreeSelect/cacheOptions.d.ts +9 -0
  102. package/dist/TreeSelect/cacheOptions.js +22 -0
  103. package/dist/TreeSelect/index.d.ts +0 -1
  104. package/dist/TreeSelect/typings.d.ts +11 -63
  105. package/dist/TreeSelect/useSelect.d.ts +125 -0
  106. package/dist/TreeSelect/useSelect.js +104 -0
  107. package/dist/TreeSelect/useTree.d.ts +130 -0
  108. package/dist/TreeSelect/useTree.js +285 -0
  109. package/dist/TreeSelect/utils.d.ts +10 -0
  110. package/dist/TreeSelect/utils.js +38 -0
  111. package/dist/Upload/UploadContent.js +2 -0
  112. package/dist/Upload/ajax.js +3 -0
  113. package/dist/Upload/typings.d.ts +4 -0
  114. package/dist/Util/aria.js +12 -12
  115. package/dist/Util/base.d.ts +5 -0
  116. package/dist/Util/base.js +140 -1
  117. package/dist/config/Constants.d.ts +3 -0
  118. package/dist/config/Constants.js +8 -0
  119. package/dist/hooks/index.d.ts +1 -0
  120. package/dist/hooks/index.js +1 -0
  121. package/dist/hooks/popperPropsUtils.js +1 -1
  122. package/dist/hooks/treePropsUtils.d.ts +3 -3
  123. package/dist/hooks/treePropsUtils.js +2 -2
  124. package/dist/hooks/useConfigProvider.d.ts +27 -0
  125. package/dist/hooks/useConfigProvider.js +78 -0
  126. package/dist/hooks/useResizeObserver.js +6 -6
  127. package/dist/index.css +1 -1
  128. package/dist/index.d.ts +18 -11
  129. package/dist/index.js +11 -5
  130. package/package.json +1 -1
  131. package/theme-chalk/alert.scss +115 -0
  132. package/theme-chalk/aside.scss +8 -8
  133. package/theme-chalk/button-group.scss +80 -80
  134. package/theme-chalk/button.scss +304 -304
  135. package/theme-chalk/calendar/date-table.scss +164 -164
  136. package/theme-chalk/checkbox.scss +34 -0
  137. package/theme-chalk/color/index.scss +20 -20
  138. package/theme-chalk/common/transition.scss +142 -142
  139. package/theme-chalk/container.scss +14 -14
  140. package/theme-chalk/dark/css-vars.scss +39 -39
  141. package/theme-chalk/dark/var.scss +225 -225
  142. package/theme-chalk/date-picker.scss +12 -12
  143. package/theme-chalk/drawer.scss +1 -0
  144. package/theme-chalk/footer.scss +12 -12
  145. package/theme-chalk/header.scss +12 -12
  146. package/theme-chalk/index.scss +4 -0
  147. package/theme-chalk/input/input-range.scss +2 -1
  148. package/theme-chalk/input/input.scss +439 -424
  149. package/theme-chalk/input-number.bak +172 -0
  150. package/theme-chalk/input-number.scss +192 -172
  151. package/theme-chalk/link.scss +87 -87
  152. package/theme-chalk/main.scss +14 -14
  153. package/theme-chalk/menu.scss +353 -353
  154. package/theme-chalk/message.scss +104 -178
  155. package/theme-chalk/mixins/_button.scss +224 -224
  156. package/theme-chalk/mixins/_col.scss +33 -33
  157. package/theme-chalk/mixins/_var.scss +67 -67
  158. package/theme-chalk/mixins/config.scss +5 -5
  159. package/theme-chalk/mixins/function.scss +99 -99
  160. package/theme-chalk/mixins/mixins.scss +240 -240
  161. package/theme-chalk/mixins/utils.scss +39 -39
  162. package/theme-chalk/notification.bak +156 -0
  163. package/theme-chalk/notification.scss +109 -156
  164. package/theme-chalk/popper.scss +104 -104
  165. package/theme-chalk/radio-button.scss +169 -169
  166. package/theme-chalk/select/index.scss +278 -272
  167. package/theme-chalk/space.scss +20 -0
  168. package/theme-chalk/statistic.scss +35 -0
  169. package/theme-chalk/switch.scss +300 -300
  170. package/theme-chalk/tag.scss +181 -181
  171. package/theme-chalk/text.scss +48 -0
  172. package/theme-chalk/transition.scss +34 -4
  173. package/theme-chalk/tree-select.scss +41 -25
  174. package/theme-chalk/tree.scss +136 -0
  175. package/theme-chalk/var.scss +83 -83
  176. package/dist/Input/Input.1.d.ts +0 -16
  177. package/dist/Input/Input.1.js +0 -376
  178. package/dist/Tree/DirectoryTree.d.ts +0 -15
  179. package/dist/Tree/DirectoryTree.js +0 -183
  180. package/dist/Tree/DropIndicator.d.ts +0 -8
  181. package/dist/Tree/DropIndicator.js +0 -34
  182. package/dist/Tree/Indent.d.ts +0 -9
  183. package/dist/Tree/Indent.js +0 -25
  184. package/dist/Tree/MotionTreeNode.d.ts +0 -14
  185. package/dist/Tree/MotionTreeNode.js +0 -125
  186. package/dist/Tree/NodeList.d.ts +0 -50
  187. package/dist/Tree/NodeList.js +0 -301
  188. package/dist/Tree/RCTree.d.ts +0 -248
  189. package/dist/Tree/RCTree.js +0 -1216
  190. package/dist/Tree/contextTypes.d.ts +0 -69
  191. package/dist/Tree/contextTypes.js +0 -9
  192. package/dist/Tree/typings.tsx--bak +0 -245
  193. package/dist/Tree/useUnmount.d.ts +0 -5
  194. package/dist/Tree/useUnmount.js +0 -34
  195. package/dist/Tree/util.d.ts +0 -51
  196. package/dist/Tree/util.js +0 -303
  197. package/dist/Tree/utils/conductUtil.d.ts +0 -17
  198. package/dist/Tree/utils/conductUtil.js +0 -209
  199. package/dist/Tree/utils/dictUtil.d.ts +0 -13
  200. package/dist/Tree/utils/dictUtil.js +0 -75
  201. package/dist/Tree/utils/diffUtil.d.ts +0 -7
  202. package/dist/Tree/utils/diffUtil.js +0 -48
  203. package/dist/Tree/utils/dropIndicator.d.ts +0 -11
  204. package/dist/Tree/utils/dropIndicator.js +0 -36
  205. package/dist/Tree/utils/iconUtil.d.ts +0 -5
  206. package/dist/Tree/utils/iconUtil.js +0 -62
  207. package/dist/Tree/utils/keyUtil.d.ts +0 -2
  208. package/dist/Tree/utils/keyUtil.js +0 -3
  209. package/dist/Tree/utils/motion.d.ts +0 -10
  210. package/dist/Tree/utils/motion.js +0 -54
  211. package/dist/Tree/utils/pickAttrs.d.ts +0 -11
  212. package/dist/Tree/utils/pickAttrs.js +0 -51
  213. package/dist/Tree/utils/treeUtil.d.ts +0 -86
  214. package/dist/Tree/utils/treeUtil.js +0 -364
  215. package/dist/TreeSelect/Utils.d.ts +0 -3
  216. package/dist/TreeSelect/Utils.js +0 -20
@@ -0,0 +1,510 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
8
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
9
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
10
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
11
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
12
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
13
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
14
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
15
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
16
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
17
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
18
+ import { isObject, isPropAbsent, nextTick } from "../../Util";
19
+ import isEqual from 'lodash/isEqual';
20
+ import isNil from 'lodash/isNil';
21
+ import noop from 'lodash/noop';
22
+ import Node from "./node";
23
+ import { getNodeKey } from "./util";
24
+ var TreeStore = /*#__PURE__*/function () {
25
+ function TreeStore(options) {
26
+ _classCallCheck(this, TreeStore);
27
+ _defineProperty(this, "currentNode", void 0);
28
+ _defineProperty(this, "currentNodeKey", void 0);
29
+ _defineProperty(this, "nodesMap", void 0);
30
+ _defineProperty(this, "root", void 0);
31
+ _defineProperty(this, "data", void 0);
32
+ _defineProperty(this, "lazy", false);
33
+ _defineProperty(this, "load", void 0);
34
+ _defineProperty(this, "filterNodeMethod", void 0);
35
+ _defineProperty(this, "key", void 0);
36
+ _defineProperty(this, "defaultCheckedKeys", void 0);
37
+ _defineProperty(this, "checkStrictly", false);
38
+ _defineProperty(this, "defaultExpandedKeys", void 0);
39
+ _defineProperty(this, "autoExpandParent", false);
40
+ _defineProperty(this, "defaultExpandAll", false);
41
+ _defineProperty(this, "checkDescendants", false);
42
+ _defineProperty(this, "props", void 0);
43
+ _defineProperty(this, "forceUpdate", void 0);
44
+ this.currentNode = null;
45
+ this.currentNodeKey = null;
46
+ for (var option in options) {
47
+ if (Object.prototype.hasOwnProperty.call(options, option)) {
48
+ this[option] = options[option];
49
+ }
50
+ }
51
+ this.nodesMap = {};
52
+ }
53
+ _createClass(TreeStore, [{
54
+ key: "initialize",
55
+ value: function initialize() {
56
+ var _this = this;
57
+ this.root = new Node({
58
+ data: this.data,
59
+ store: this
60
+ });
61
+ this.root.initialize();
62
+ if (this.lazy && this.load) {
63
+ var loadFn = this.load;
64
+ loadFn(this.root, function (data) {
65
+ _this.root.doCreateChildren(data);
66
+ _this._initDefaultCheckedNodes();
67
+ _this.forceUpdate();
68
+ }, noop);
69
+ } else {
70
+ this._initDefaultCheckedNodes();
71
+ }
72
+ }
73
+ }, {
74
+ key: "filter",
75
+ value: function filter(value) {
76
+ var _this2 = this;
77
+ var filterNodeMethod = this.filterNodeMethod;
78
+ var lazy = this.lazy;
79
+ var traverse = /*#__PURE__*/function () {
80
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(node) {
81
+ var childNodes, _iterator, _step, _step$value, index, child, allHidden;
82
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
83
+ while (1) switch (_context.prev = _context.next) {
84
+ case 0:
85
+ childNodes = node.root ? node.root.childNodes : node.childNodes;
86
+ _iterator = _createForOfIteratorHelper(childNodes.entries());
87
+ _context.prev = 2;
88
+ _iterator.s();
89
+ case 4:
90
+ if ((_step = _iterator.n()).done) {
91
+ _context.next = 14;
92
+ break;
93
+ }
94
+ _step$value = _slicedToArray(_step.value, 2), index = _step$value[0], child = _step$value[1];
95
+ child.visible = !!(filterNodeMethod !== null && filterNodeMethod !== void 0 && filterNodeMethod.call(child, value, child.data, child));
96
+ if (!(index % 80 === 0 && index > 0)) {
97
+ _context.next = 10;
98
+ break;
99
+ }
100
+ _context.next = 10;
101
+ return nextTick();
102
+ case 10:
103
+ _context.next = 12;
104
+ return traverse(child);
105
+ case 12:
106
+ _context.next = 4;
107
+ break;
108
+ case 14:
109
+ _context.next = 19;
110
+ break;
111
+ case 16:
112
+ _context.prev = 16;
113
+ _context.t0 = _context["catch"](2);
114
+ _iterator.e(_context.t0);
115
+ case 19:
116
+ _context.prev = 19;
117
+ _iterator.f();
118
+ return _context.finish(19);
119
+ case 22:
120
+ if (!node.visible && childNodes.length) {
121
+ allHidden = true;
122
+ allHidden = !childNodes.some(function (child) {
123
+ return child.visible;
124
+ });
125
+ if (node.root) {
126
+ node.root.visible = allHidden === false;
127
+ } else {
128
+ node.visible = allHidden === false;
129
+ }
130
+ }
131
+ if (value) {
132
+ _context.next = 25;
133
+ break;
134
+ }
135
+ return _context.abrupt("return");
136
+ case 25:
137
+ if (node.visible && !node.isLeaf) {
138
+ if (!lazy || node.loaded) {
139
+ node.expand();
140
+ }
141
+ }
142
+ case 26:
143
+ case "end":
144
+ return _context.stop();
145
+ }
146
+ }, _callee, null, [[2, 16, 19, 22]]);
147
+ }));
148
+ return function traverse(_x) {
149
+ return _ref.apply(this, arguments);
150
+ };
151
+ }();
152
+ traverse(this).then(function () {
153
+ _this2.forceUpdate();
154
+ });
155
+ }
156
+ }, {
157
+ key: "setData",
158
+ value: function setData(newVal) {
159
+ var instanceChanged = !isEqual(newVal, this.root.data);
160
+ if (instanceChanged) {
161
+ this.nodesMap = {};
162
+ this.root.setData(newVal);
163
+ this._initDefaultCheckedNodes();
164
+ this.setCurrentNodeKey(this.currentNodeKey);
165
+ } else {
166
+ this.root.updateChildren();
167
+ }
168
+ }
169
+ }, {
170
+ key: "getNode",
171
+ value: function getNode(data) {
172
+ if (data instanceof Node) {
173
+ return data;
174
+ }
175
+ // @ts-ignore
176
+ var key = isObject(data) ? getNodeKey(this.key, data) : data;
177
+ return this.nodesMap[key] || null;
178
+ }
179
+ }, {
180
+ key: "insertBefore",
181
+ value: function insertBefore(data, refData) {
182
+ var _refNode$parent;
183
+ var refNode = this.getNode(refData);
184
+ (_refNode$parent = refNode.parent) === null || _refNode$parent === void 0 || _refNode$parent.insertBefore({
185
+ data: data
186
+ }, refNode);
187
+ }
188
+ }, {
189
+ key: "insertAfter",
190
+ value: function insertAfter(data, refData) {
191
+ var _refNode$parent2;
192
+ var refNode = this.getNode(refData);
193
+ (_refNode$parent2 = refNode.parent) === null || _refNode$parent2 === void 0 || _refNode$parent2.insertAfter({
194
+ data: data
195
+ }, refNode);
196
+ }
197
+ }, {
198
+ key: "remove",
199
+ value: function remove(data) {
200
+ var node = this.getNode(data);
201
+ if (node && node.parent) {
202
+ if (node === this.currentNode) {
203
+ this.currentNode = null;
204
+ }
205
+ node.parent.removeChild(node);
206
+ }
207
+ }
208
+ }, {
209
+ key: "append",
210
+ value: function append(data, parentData) {
211
+ var parentNode = !isPropAbsent(parentData) ? this.getNode(parentData) : this.root;
212
+ if (parentNode) {
213
+ parentNode.insertChild({
214
+ data: data
215
+ });
216
+ }
217
+ }
218
+ }, {
219
+ key: "_initDefaultCheckedNodes",
220
+ value: function _initDefaultCheckedNodes() {
221
+ var _this3 = this;
222
+ var defaultCheckedKeys = this.defaultCheckedKeys || [];
223
+ var nodesMap = this.nodesMap;
224
+ defaultCheckedKeys.forEach(function (checkedKey) {
225
+ var node = nodesMap[checkedKey];
226
+ if (node) {
227
+ node.setChecked(true, !_this3.checkStrictly);
228
+ }
229
+ });
230
+ }
231
+ }, {
232
+ key: "_initDefaultCheckedNode",
233
+ value: function _initDefaultCheckedNode(node) {
234
+ var defaultCheckedKeys = this.defaultCheckedKeys || [];
235
+ if (!isNil(node.key) && defaultCheckedKeys.includes(node.key)) {
236
+ node.setChecked(true, !this.checkStrictly);
237
+ }
238
+ }
239
+ }, {
240
+ key: "setDefaultCheckedKey",
241
+ value: function setDefaultCheckedKey(newVal) {
242
+ if (newVal !== this.defaultCheckedKeys) {
243
+ this.defaultCheckedKeys = newVal;
244
+ this._initDefaultCheckedNodes();
245
+ }
246
+ }
247
+ }, {
248
+ key: "registerNode",
249
+ value: function registerNode(node) {
250
+ var key = this.key;
251
+ if (!node || !node.data) {
252
+ return;
253
+ }
254
+ if (!key) {
255
+ this.nodesMap[node.id] = node;
256
+ } else {
257
+ var nodeKey = node.key;
258
+ if (!isNil(nodeKey)) {
259
+ this.nodesMap[nodeKey] = node;
260
+ }
261
+ }
262
+ }
263
+ }, {
264
+ key: "deregisterNode",
265
+ value: function deregisterNode(node) {
266
+ var _this4 = this;
267
+ var key = this.key;
268
+ if (!key || !node || !node.data) {
269
+ return;
270
+ }
271
+ node.childNodes.forEach(function (child) {
272
+ _this4.deregisterNode(child);
273
+ });
274
+ delete this.nodesMap[node.key];
275
+ }
276
+ }, {
277
+ key: "getCheckedNodes",
278
+ value: function getCheckedNodes() {
279
+ var leafOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
280
+ var includeHalfChecked = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
281
+ var checkedNodes = [];
282
+ var traverse = function traverse(node) {
283
+ var childNodes = node.root ? node.root.childNodes : node.childNodes;
284
+ childNodes.forEach(function (child) {
285
+ if ((child.checked || includeHalfChecked && child.indeterminate) && (!leafOnly || leafOnly && child.isLeaf)) {
286
+ checkedNodes.push(child.data);
287
+ }
288
+ traverse(child);
289
+ });
290
+ };
291
+ traverse(this);
292
+ return checkedNodes;
293
+ }
294
+ }, {
295
+ key: "getCheckedKeys",
296
+ value: function getCheckedKeys() {
297
+ var _this5 = this;
298
+ var leafOnly = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
299
+ return this.getCheckedNodes(leafOnly).map(function (data) {
300
+ return (data || {})[_this5.key];
301
+ });
302
+ }
303
+ }, {
304
+ key: "getHalfCheckedNodes",
305
+ value: function getHalfCheckedNodes() {
306
+ var nodes = [];
307
+ var traverse = function traverse(node) {
308
+ var childNodes = node.root ? node.root.childNodes : node.childNodes;
309
+ childNodes.forEach(function (child) {
310
+ if (child.indeterminate) {
311
+ nodes.push(child.data);
312
+ }
313
+ traverse(child);
314
+ });
315
+ };
316
+ traverse(this);
317
+ return nodes;
318
+ }
319
+ }, {
320
+ key: "getHalfCheckedKeys",
321
+ value: function getHalfCheckedKeys() {
322
+ var _this6 = this;
323
+ return this.getHalfCheckedNodes().map(function (data) {
324
+ return (data || {})[_this6.key];
325
+ });
326
+ }
327
+ }, {
328
+ key: "_getAllNodes",
329
+ value: function _getAllNodes() {
330
+ var allNodes = [];
331
+ var nodesMap = this.nodesMap;
332
+ for (var nodeKey in nodesMap) {
333
+ if (Object.prototype.hasOwnProperty.call(nodesMap, nodeKey)) {
334
+ allNodes.push(nodesMap[nodeKey]);
335
+ }
336
+ }
337
+ return allNodes;
338
+ }
339
+ }, {
340
+ key: "updateChildren",
341
+ value: function updateChildren(key, data) {
342
+ var node = this.nodesMap[key];
343
+ if (!node) {
344
+ return;
345
+ }
346
+ var childNodes = node.childNodes;
347
+ for (var i = childNodes.length - 1; i >= 0; i--) {
348
+ var child = childNodes[i];
349
+ this.remove(child.data);
350
+ }
351
+ for (var _i = 0, j = data.length; _i < j; _i++) {
352
+ var _child = data[_i];
353
+ this.append(_child, node.data);
354
+ }
355
+ }
356
+ }, {
357
+ key: "_setCheckedKeys",
358
+ value: function _setCheckedKeys(key) {
359
+ var _this7 = this;
360
+ var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
361
+ var checkedKeys = arguments.length > 2 ? arguments[2] : undefined;
362
+ var allNodes = this._getAllNodes().sort(function (a, b) {
363
+ return a.level - b.level;
364
+ });
365
+ var cache = Object.create(null);
366
+ var keys = Object.keys(checkedKeys);
367
+ allNodes.forEach(function (node) {
368
+ return node.setChecked(false, false);
369
+ });
370
+ var cacheCheckedChild = function cacheCheckedChild(node) {
371
+ node.childNodes.forEach(function (child) {
372
+ var _child$childNodes;
373
+ cache[child.data[key]] = true;
374
+ if ((_child$childNodes = child.childNodes) !== null && _child$childNodes !== void 0 && _child$childNodes.length) {
375
+ cacheCheckedChild(child);
376
+ }
377
+ });
378
+ };
379
+ var _loop = function _loop() {
380
+ var node = allNodes[i];
381
+ var nodeKey = node.data[key].toString();
382
+ var checked = keys.includes(nodeKey);
383
+ if (!checked) {
384
+ if (node.checked && !cache[nodeKey]) {
385
+ node.setChecked(false, false);
386
+ }
387
+ return 0; // continue
388
+ }
389
+ if (node.childNodes.length) {
390
+ cacheCheckedChild(node);
391
+ }
392
+ if (node.isLeaf || _this7.checkStrictly) {
393
+ node.setChecked(true, false);
394
+ return 0; // continue
395
+ }
396
+ node.setChecked(true, true);
397
+ if (leafOnly) {
398
+ node.setChecked(false, false);
399
+ var traverse = function traverse(node) {
400
+ var childNodes = node.childNodes;
401
+ childNodes.forEach(function (child) {
402
+ if (!child.isLeaf) {
403
+ child.setChecked(false, false);
404
+ }
405
+ traverse(child);
406
+ });
407
+ };
408
+ traverse(node);
409
+ }
410
+ },
411
+ _ret;
412
+ for (var i = 0, j = allNodes.length; i < j; i++) {
413
+ _ret = _loop();
414
+ if (_ret === 0) continue;
415
+ }
416
+ }
417
+ }, {
418
+ key: "setCheckedNodes",
419
+ value: function setCheckedNodes(array) {
420
+ var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
421
+ var key = this.key;
422
+ var checkedKeys = {};
423
+ array.forEach(function (item) {
424
+ checkedKeys[(item || {})[key]] = true;
425
+ });
426
+ this._setCheckedKeys(key, leafOnly, checkedKeys);
427
+ }
428
+ }, {
429
+ key: "setCheckedKeys",
430
+ value: function setCheckedKeys(keys) {
431
+ var leafOnly = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
432
+ this.defaultCheckedKeys = keys;
433
+ var key = this.key;
434
+ var checkedKeys = {};
435
+ keys.forEach(function (key) {
436
+ checkedKeys[key] = true;
437
+ });
438
+ this._setCheckedKeys(key, leafOnly, checkedKeys);
439
+ }
440
+ }, {
441
+ key: "setDefaultExpandedKeys",
442
+ value: function setDefaultExpandedKeys(keys) {
443
+ var _this8 = this;
444
+ keys = keys || [];
445
+ this.defaultExpandedKeys = keys;
446
+ keys.forEach(function (key) {
447
+ var node = _this8.getNode(key);
448
+ if (node) {
449
+ node.expand(null, _this8.autoExpandParent);
450
+ }
451
+ });
452
+ }
453
+ }, {
454
+ key: "setChecked",
455
+ value: function setChecked(data, checked, deep) {
456
+ var node = this.getNode(data);
457
+ if (node) {
458
+ node.setChecked(!!checked, deep);
459
+ }
460
+ }
461
+ }, {
462
+ key: "getCurrentNode",
463
+ value: function getCurrentNode() {
464
+ return this.currentNode;
465
+ }
466
+ }, {
467
+ key: "setCurrentNode",
468
+ value: function setCurrentNode(currentNode) {
469
+ var prevCurrentNode = this.currentNode;
470
+ if (prevCurrentNode) {
471
+ prevCurrentNode.isCurrent = false;
472
+ }
473
+ this.currentNode = currentNode;
474
+ this.currentNode.isCurrent = true;
475
+ }
476
+ }, {
477
+ key: "setUserCurrentNode",
478
+ value: function setUserCurrentNode(node) {
479
+ var shouldAutoExpandParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
480
+ var key = node.data[this.key];
481
+ var currNode = this.nodesMap[key];
482
+ this.setCurrentNode(currNode);
483
+ if (shouldAutoExpandParent && this.currentNode && this.currentNode.level > 1) {
484
+ var _this$currentNode$par;
485
+ (_this$currentNode$par = this.currentNode.parent) === null || _this$currentNode$par === void 0 || _this$currentNode$par.expand(null, true);
486
+ }
487
+ }
488
+ }, {
489
+ key: "setCurrentNodeKey",
490
+ value: function setCurrentNodeKey(key) {
491
+ var shouldAutoExpandParent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
492
+ this.currentNodeKey = key;
493
+ if (isPropAbsent(key)) {
494
+ this.currentNode && (this.currentNode.isCurrent = false);
495
+ this.currentNode = null;
496
+ return;
497
+ }
498
+ var node = this.getNode(key);
499
+ if (node) {
500
+ this.setCurrentNode(node);
501
+ if (shouldAutoExpandParent && this.currentNode && this.currentNode.level > 1) {
502
+ var _this$currentNode$par2;
503
+ (_this$currentNode$par2 = this.currentNode.parent) === null || _this$currentNode$par2 === void 0 || _this$currentNode$par2.expand(null, true);
504
+ }
505
+ }
506
+ }
507
+ }]);
508
+ return TreeStore;
509
+ }();
510
+ export { TreeStore as default };
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { TreeProps } from '../typings';
3
+ import type Node from './node';
4
+ import type TreeStore from './tree-store';
5
+ export interface TreeNode {
6
+ node: Node;
7
+ $el?: HTMLElement;
8
+ }
9
+ export interface DragOptions {
10
+ event: React.DragEvent<HTMLDivElement>;
11
+ treeNode: TreeNode;
12
+ }
13
+ interface Props {
14
+ props: TreeProps;
15
+ elRef: React.RefObject<HTMLElement>;
16
+ dropIndicatorRef: React.RefObject<HTMLElement>;
17
+ store: TreeStore;
18
+ }
19
+ export interface DragEvents {
20
+ treeNodeDragStart: (options: DragOptions) => void;
21
+ treeNodeDragOver: (options: DragOptions) => void;
22
+ treeNodeDragEnd: (event: React.DragEvent<HTMLDivElement>) => void;
23
+ }
24
+ export declare const dragEventsKey: unique symbol;
25
+ export declare function useDragNodeHandler({ props, elRef, dropIndicatorRef, store }: Props): {
26
+ treeNodeDragStart: ({ event, treeNode }: DragOptions) => false;
27
+ treeNodeDragOver: ({ event, treeNode }: DragOptions) => void;
28
+ treeNodeDragEnd: (event: React.DragEvent<HTMLDivElement>) => void;
29
+ };
30
+ export {};