funda-ui 4.7.171 → 4.7.181

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.
package/Tree/index.js CHANGED
@@ -1035,6 +1035,19 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try
1035
1035
  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); }); }; }
1036
1036
  var initUlHeight = function initUlHeight(inputUl) {
1037
1037
  [].slice.call(inputUl).forEach(function (el) {
1038
+ // Check whether the parent node has "active"
1039
+ /*
1040
+ Fixed:
1041
+
1042
+ 1. After asynchronously loading child nodes (after "initDefaultValue()"), manually collapse the node
1043
+ 2. When clicking other nodes, the child node ul height of the previously collapsed node is not correctly reset to 0
1044
+ 3. It causes the visual display to be expanded, but the arrow is actually collapsed
1045
+ */
1046
+ var parentLi = el.parentElement;
1047
+ if (!parentLi || !parentLi.classList.contains('active')) {
1048
+ // If the parent node does not have an active class, keep maxHeight to 0
1049
+ return;
1050
+ }
1038
1051
  if (typeof el.dataset.maxheight === 'undefined') {
1039
1052
  var _li = [].slice.call(el.querySelectorAll('li'));
1040
1053
  var _allHeight = 0;
@@ -1082,13 +1095,22 @@ var activeClass = function activeClass(el, mode) {
1082
1095
  }
1083
1096
  };
1084
1097
  ;// CONCATENATED MODULE: ./src/TreeList.tsx
1098
+ function TreeList_typeof(obj) { "@babel/helpers - typeof"; return TreeList_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, TreeList_typeof(obj); }
1085
1099
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1086
1100
  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."); }
1087
1101
  function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
1088
1102
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1103
+ function TreeList_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ TreeList_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == TreeList_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1104
+ function TreeList_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); } }
1105
+ function TreeList_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { TreeList_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { TreeList_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1089
1106
  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 (_e2) { function e(_x2) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (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 (_e3) { function e(_x3) { return _e3.apply(this, arguments); } e.toString = function () { return _e3.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
1090
1107
  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); }
1091
1108
  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; }
1109
+ 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; }
1110
+ 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; }
1111
+ 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; }
1112
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return TreeList_typeof(key) === "symbol" ? key : String(key); }
1113
+ function _toPrimitive(input, hint) { if (TreeList_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (TreeList_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1092
1114
 
1093
1115
 
1094
1116
  // HAS CHECKBOX
@@ -1101,6 +1123,7 @@ function TreeList(props) {
1101
1123
  var rootNode = props.rootNode,
1102
1124
  checkboxNamePrefix = props.checkboxNamePrefix,
1103
1125
  alternateCollapse = props.alternateCollapse,
1126
+ renderOption = props.renderOption,
1104
1127
  first = props.first,
1105
1128
  disableArrow = props.disableArrow,
1106
1129
  disableCollapse = props.disableCollapse,
@@ -1113,12 +1136,20 @@ function TreeList(props) {
1113
1136
  updateCheckedPrint = props.updateCheckedPrint,
1114
1137
  getCheckedData = props.getCheckedData,
1115
1138
  updategetCheckedData = props.updategetCheckedData,
1139
+ expandedMap = props.expandedMap,
1116
1140
  onSelect = props.onSelect,
1117
1141
  onDoubleSelect = props.onDoubleSelect,
1118
1142
  onCollapse = props.onCollapse,
1119
1143
  onCheck = props.onCheck,
1120
1144
  evInitValue = props.evInitValue;
1121
1145
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1146
+ var mergedData = data === null ? [] : data.map(function (item) {
1147
+ var _expandedMap$itemData;
1148
+ var itemData = typeof item === 'string' ? JSON.parse(item) : item;
1149
+ return _objectSpread(_objectSpread({}, itemData), {}, {
1150
+ isExpanded: (_expandedMap$itemData = expandedMap === null || expandedMap === void 0 ? void 0 : expandedMap[itemData.key]) !== null && _expandedMap$itemData !== void 0 ? _expandedMap$itemData : false
1151
+ });
1152
+ });
1122
1153
  var customIcon = /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("var", {
1123
1154
  className: "default-icon"
1124
1155
  }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("svg", {
@@ -1253,78 +1284,6 @@ function TreeList(props) {
1253
1284
  updateIndeterminateData(orginalData, checkedData);
1254
1285
  return [checkedData, printData];
1255
1286
  };
1256
- var closeChild = function closeChild(hyperlink, ul) {
1257
- if (ul.length === 0) return;
1258
- activeClass(hyperlink, 'remove');
1259
- hyperlink.setAttribute('aria-expanded', 'false');
1260
- activeClass(hyperlink.parentNode, 'remove');
1261
-
1262
- //to close
1263
- [].slice.call(ul).forEach(function (element) {
1264
- element.style.maxHeight = 0;
1265
- });
1266
- };
1267
- var openChild = function openChild(hyperlink, ul) {
1268
- if (ul.length === 0) return;
1269
- activeClass(hyperlink, 'add');
1270
- hyperlink.setAttribute('aria-expanded', 'true');
1271
- activeClass(hyperlink.parentNode, 'add');
1272
-
1273
- // init <ul> height
1274
- initUlHeight(ul);
1275
- };
1276
- function handleCollapse(e) {
1277
- if (disableCollapse) return;
1278
- e.preventDefault();
1279
- e.stopPropagation();
1280
- var hyperlink = e.currentTarget;
1281
- var url = hyperlink.getAttribute('href');
1282
- var subElement = (0,dom.getNextSiblings)(hyperlink, 'ul');
1283
-
1284
- // loading
1285
- //=====================
1286
- if (hyperlink.classList.contains('async-ready')) {
1287
- activeClass(hyperlink, 'add', 'loading');
1288
- }
1289
-
1290
- // calback
1291
- //=====================
1292
- var fetchFunc = hyperlink.classList.contains('async-ready') ? typeof evInitValue !== 'function' ? function () {
1293
- return void 0;
1294
- } : evInitValue : function () {
1295
- return void 0;
1296
- };
1297
- onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(e, {
1298
- key: hyperlink.dataset.key,
1299
- slug: hyperlink.dataset.slug,
1300
- link: hyperlink.dataset.link,
1301
- optiondata: hyperlink.dataset.optiondata
1302
- }, fetchFunc);
1303
-
1304
- // hide child if expandedLink doesn't exist, on the contrary
1305
- //=====================
1306
- if (hyperlink.classList.contains('loading')) return;
1307
- if (hyperlink.getAttribute('aria-expanded') === 'false' || hyperlink.getAttribute('aria-expanded') === null) {
1308
- //Hide all other siblings of the selected <ul>
1309
- if (alternateCollapse) {
1310
- [].slice.call(rootRef.current.children).forEach(function (li) {
1311
- activeClass(li, 'remove');
1312
- var _li = li.firstChild;
1313
- activeClass(_li, 'remove');
1314
- _li.setAttribute('aria-expanded', false);
1315
- [].slice.call((0,dom.getNextSiblings)(_li, 'ul')).forEach(function (element) {
1316
- element.style.maxHeight = 0;
1317
- });
1318
- });
1319
- }
1320
-
1321
- //open current
1322
- openChild(hyperlink, subElement);
1323
- } else {
1324
- //close current
1325
- closeChild(hyperlink, subElement);
1326
- }
1327
- }
1328
1287
  function handleSelect(e) {
1329
1288
  e.preventDefault();
1330
1289
  e.stopPropagation();
@@ -1332,9 +1291,12 @@ function TreeList(props) {
1332
1291
  if (hyperlink.classList.contains('selected')) {
1333
1292
  activeClass(hyperlink, 'remove', 'selected');
1334
1293
  } else {
1335
- [].slice.call(hyperlink.closest('.tree-diagram__wrapper').querySelectorAll('li > a')).forEach(function (node) {
1336
- activeClass(node, 'remove', 'selected');
1337
- });
1294
+ var wrapper = hyperlink.closest('.tree-diagram__wrapper');
1295
+ if (wrapper) {
1296
+ [].slice.call(wrapper.querySelectorAll('li > div.nav-link')).forEach(function (node) {
1297
+ activeClass(node, 'remove', 'selected');
1298
+ });
1299
+ }
1338
1300
  activeClass(hyperlink, 'add', 'selected');
1339
1301
  }
1340
1302
  onSelect === null || onSelect === void 0 ? void 0 : onSelect(e, {
@@ -1342,11 +1304,24 @@ function TreeList(props) {
1342
1304
  slug: hyperlink.dataset.slug,
1343
1305
  link: hyperlink.dataset.link,
1344
1306
  optiondata: hyperlink.dataset.optiondata
1345
- }, typeof evInitValue !== 'function' ? function () {
1346
- return void 0;
1347
- } : evInitValue);
1307
+ }, /*#__PURE__*/TreeList_asyncToGenerator( /*#__PURE__*/TreeList_regeneratorRuntime().mark(function _callee() {
1308
+ return TreeList_regeneratorRuntime().wrap(function _callee$(_context) {
1309
+ while (1) switch (_context.prev = _context.next) {
1310
+ case 0:
1311
+ if (!(typeof evInitValue === 'function')) {
1312
+ _context.next = 3;
1313
+ break;
1314
+ }
1315
+ _context.next = 3;
1316
+ return evInitValue(hyperlink.dataset.key, null);
1317
+ case 3:
1318
+ case "end":
1319
+ return _context.stop();
1320
+ }
1321
+ }, _callee);
1322
+ })));
1348
1323
  if (disableArrow) {
1349
- handleCollapse(e);
1324
+ onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(e);
1350
1325
  }
1351
1326
  }
1352
1327
  function handleDoubleSelect(e) {
@@ -1356,7 +1331,7 @@ function TreeList(props) {
1356
1331
  if (hyperlink.classList.contains('selected')) {
1357
1332
  activeClass(hyperlink, 'remove', 'selected');
1358
1333
  } else {
1359
- [].slice.call(hyperlink.closest('.tree-diagram__wrapper').querySelectorAll('li > a')).forEach(function (node) {
1334
+ [].slice.call(hyperlink.closest('.tree-diagram__wrapper').querySelectorAll('li > div.nav-link')).forEach(function (node) {
1360
1335
  activeClass(node, 'remove', 'selected');
1361
1336
  });
1362
1337
  activeClass(hyperlink, 'add', 'selected');
@@ -1366,11 +1341,24 @@ function TreeList(props) {
1366
1341
  slug: hyperlink.dataset.slug,
1367
1342
  link: hyperlink.dataset.link,
1368
1343
  optiondata: hyperlink.dataset.optiondata
1369
- }, typeof evInitValue !== 'function' ? function () {
1370
- return void 0;
1371
- } : evInitValue);
1344
+ }, /*#__PURE__*/TreeList_asyncToGenerator( /*#__PURE__*/TreeList_regeneratorRuntime().mark(function _callee2() {
1345
+ return TreeList_regeneratorRuntime().wrap(function _callee2$(_context2) {
1346
+ while (1) switch (_context2.prev = _context2.next) {
1347
+ case 0:
1348
+ if (!(typeof evInitValue === 'function')) {
1349
+ _context2.next = 3;
1350
+ break;
1351
+ }
1352
+ _context2.next = 3;
1353
+ return evInitValue(hyperlink.dataset.key, null);
1354
+ case 3:
1355
+ case "end":
1356
+ return _context2.stop();
1357
+ }
1358
+ }, _callee2);
1359
+ })));
1372
1360
  if (disableArrow) {
1373
- handleCollapse(e);
1361
+ onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(e);
1374
1362
  }
1375
1363
  }
1376
1364
  function titleArrowGenerator() {
@@ -1456,10 +1444,10 @@ function TreeList(props) {
1456
1444
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
1457
1445
  // Activate current item
1458
1446
  //=====================
1459
- var allItems = rootRef.current ? [].slice.call(document.querySelectorAll(".".concat(childClassName, " a"))).map(function (item) {
1447
+ var allItems = rootRef.current ? [].slice.call(document.querySelectorAll(".".concat(childClassName, " div.nav-link"))).map(function (item) {
1460
1448
  var _item$parentNode$clas;
1461
1449
  return {
1462
- href: item.getAttribute('href'),
1450
+ href: item.dataset.href,
1463
1451
  el: item,
1464
1452
  actived: (_item$parentNode$clas = item.parentNode.classList) !== null && _item$parentNode$clas !== void 0 && _item$parentNode$clas.contains('active') ? true : false,
1465
1453
  expandedLink: document.body.contains(item.parentNode.parentNode.previousSibling) ? item.parentNode.parentNode.previousSibling : false
@@ -1494,10 +1482,11 @@ function TreeList(props) {
1494
1482
  style: !first ? {
1495
1483
  maxHeight: '0px'
1496
1484
  } : {}
1497
- }, data.map(function (item, i) {
1485
+ }, mergedData.map(function (item, i) {
1498
1486
  var _filter$, _filter$2;
1499
1487
  var _async = item.childrenAsync ? 'async-ready' : '';
1500
1488
  var _cusIcons = arrowIcons ? 'custom-icons' : '';
1489
+ var optiondata = typeof item.optiondata !== 'undefined' ? item.optiondata : '{}';
1501
1490
  if (item.heading) return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
1502
1491
  className: (0,cls.combinedCls)('nav-item', {
1503
1492
  'first': first
@@ -1518,11 +1507,11 @@ function TreeList(props) {
1518
1507
  dangerouslySetInnerHTML: {
1519
1508
  __html: "".concat(item.icon)
1520
1509
  }
1521
- }) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("i", {
1510
+ }) : null, typeof renderOption === 'function' ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, renderOption(item, item.key)) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("i", {
1522
1511
  dangerouslySetInnerHTML: {
1523
1512
  __html: "".concat(item.title)
1524
1513
  }
1525
- }))));
1514
+ })))));
1526
1515
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
1527
1516
  className: (0,cls.combinedCls)('nav-item', {
1528
1517
  'first': first,
@@ -1536,9 +1525,9 @@ function TreeList(props) {
1536
1525
  return void 0;
1537
1526
  }
1538
1527
  }, item.children && item.children.length || item.childrenAsync ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
1539
- "aria-expanded": item.active ? 'true' : 'false',
1528
+ "aria-expanded": JSON.parse(optiondata).isExpanded || item.active ? 'true' : 'false',
1540
1529
  className: item.active ? "arrow active ".concat(_async, " ").concat(_cusIcons) : "arrow ".concat(_async, " ").concat(_cusIcons),
1541
- onClick: handleCollapse,
1530
+ onClick: onCollapse,
1542
1531
  "data-link": item.link,
1543
1532
  "data-slug": item.slug,
1544
1533
  "data-key": item.key,
@@ -1571,13 +1560,14 @@ function TreeList(props) {
1571
1560
  return cur.key === item.key;
1572
1561
  })[0]) !== null && _filter$3 !== void 0 && _filter$3.checked));
1573
1562
  }
1574
- })))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
1563
+ })))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1575
1564
  tabIndex: -1,
1576
1565
  className: (0,cls.combinedCls)('nav-link', _async, {
1577
1566
  'selected': item.selected,
1578
- 'active': item.active
1567
+ 'active': item.active,
1568
+ 'disabled': item.disabled
1579
1569
  }),
1580
- href: item.link === '#' ? "".concat(item.link, "-").concat(i) : item.link,
1570
+ "data-href": item.link === '#' ? "".concat(item.link, "-").concat(i) : item.link,
1581
1571
  "aria-expanded": "false",
1582
1572
  onClick: handleSelect,
1583
1573
  onDoubleClick: handleDoubleSelect,
@@ -1597,12 +1587,13 @@ function TreeList(props) {
1597
1587
  dangerouslySetInnerHTML: {
1598
1588
  __html: "".concat(item.icon)
1599
1589
  }
1600
- }) : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("i", {
1590
+ }) : null, typeof renderOption === 'function' ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, renderOption(item, item.key)) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("i", {
1601
1591
  dangerouslySetInnerHTML: {
1602
1592
  __html: "".concat(item.title)
1603
1593
  }
1604
- }), titleArrowGenerator()), item.customContentToHyperlink), item.customContentToLiTag, item.children && item.children.length > 0 && /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(TreeList, {
1594
+ })), titleArrowGenerator()), item.customContentToHyperlink), item.customContentToLiTag, item.children && item.children.length > 0 && /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(TreeList, {
1605
1595
  rootNode: rootNode,
1596
+ renderOption: renderOption,
1606
1597
  checkboxNamePrefix: checkboxNamePrefix,
1607
1598
  orginalData: orginalData,
1608
1599
  data: item.children,
@@ -1610,7 +1601,6 @@ function TreeList(props) {
1610
1601
  arrow: arrow,
1611
1602
  onSelect: onSelect,
1612
1603
  onDoubleSelect: onDoubleSelect,
1613
- onCollapse: onCollapse,
1614
1604
  onCheck: onCheck,
1615
1605
  disableArrow: disableArrow,
1616
1606
  disableCollapse: disableCollapse,
@@ -1620,6 +1610,11 @@ function TreeList(props) {
1620
1610
  updateCheckedPrint: updateCheckedPrint,
1621
1611
  getCheckedData: getCheckedData,
1622
1612
  updategetCheckedData: updategetCheckedData
1613
+
1614
+ // Collapse
1615
+ ,
1616
+ expandedMap: expandedMap,
1617
+ onCollapse: onCollapse
1623
1618
  }));
1624
1619
  })));
1625
1620
  } else {
@@ -1627,19 +1622,20 @@ function TreeList(props) {
1627
1622
  }
1628
1623
  }
1629
1624
  ;// CONCATENATED MODULE: ./src/index.tsx
1630
- function src_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ src_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == src_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1625
+ function src_createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = src_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 (_e2) { function e(_x9) { return _e2.apply(this, arguments); } e.toString = function () { return _e2.toString(); }; return e; }(function (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 (_e3) { function e(_x10) { return _e3.apply(this, arguments); } e.toString = function () { return _e3.toString(); }; return e; }(function (e) { didErr = true; err = e; }), f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
1631
1626
  function src_typeof(obj) { "@babel/helpers - typeof"; return src_typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, src_typeof(obj); }
1632
1627
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || src_unsupportedIterableToArray(arr) || _nonIterableSpread(); }
1633
1628
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1634
1629
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
1635
1630
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return src_arrayLikeToArray(arr); }
1631
+ function src_regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ src_regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == src_typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
1632
+ function src_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; }
1633
+ function src_objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? src_ownKeys(Object(source), !0).forEach(function (key) { src_defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : src_ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
1634
+ function src_defineProperty(obj, key, value) { key = src_toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1635
+ function src_toPropertyKey(arg) { var key = src_toPrimitive(arg, "string"); return src_typeof(key) === "symbol" ? key : String(key); }
1636
+ function src_toPrimitive(input, hint) { if (src_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (src_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1636
1637
  function src_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); } }
1637
1638
  function src_asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { src_asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
1638
- 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; }
1639
- 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; }
1640
- 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; }
1641
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return src_typeof(key) === "symbol" ? key : String(key); }
1642
- function _toPrimitive(input, hint) { if (src_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (src_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
1643
1639
  function src_slicedToArray(arr, i) { return src_arrayWithHoles(arr) || src_iterableToArrayLimit(arr, i) || src_unsupportedIterableToArray(arr, i) || src_nonIterableRest(); }
1644
1640
  function src_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."); }
1645
1641
  function src_unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return src_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 src_arrayLikeToArray(o, minLen); }
@@ -1651,12 +1647,15 @@ function src_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1651
1647
 
1652
1648
 
1653
1649
 
1650
+
1651
+
1654
1652
  var Tree = function Tree(props) {
1655
1653
  var id = props.id,
1656
1654
  checkable = props.checkable,
1657
1655
  showLine = props.showLine,
1658
1656
  lineStyle = props.lineStyle,
1659
1657
  alternateCollapse = props.alternateCollapse,
1658
+ renderOption = props.renderOption,
1660
1659
  disableArrow = props.disableArrow,
1661
1660
  disableCollapse = props.disableCollapse,
1662
1661
  arrow = props.arrow,
@@ -1693,41 +1692,231 @@ var Tree = function Tree(props) {
1693
1692
  checkedData = _useState10[0],
1694
1693
  setCheckedData = _useState10[1];
1695
1694
  var expandClassName = "".concat(showLine ? 'show-line' : '', " ").concat(disableArrow ? 'hide-arrow' : '', " ").concat(disableCollapse ? 'collapse-disabled' : '', " ").concat(lineStyle ? "line--".concat(lineStyle) : '', " ").concat(checkable ? 'has-checkbox' : '');
1696
- var updateTreeData = function updateTreeData(list, key, children) {
1697
- return list ? list.map(function (node) {
1698
- if (node.key === key) {
1699
- return _objectSpread(_objectSpread({}, node), {}, {
1700
- children: children
1701
- });
1695
+ var _useState11 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({}),
1696
+ _useState12 = src_slicedToArray(_useState11, 2),
1697
+ expandedMap = _useState12[0],
1698
+ setExpandedMap = _useState12[1]; // { [key]: true/false }
1699
+
1700
+ // Handle DOM operations
1701
+ var handleDOMOperations = function handleDOMOperations() {
1702
+ // loading status
1703
+ [].slice.call(rootRef.current.querySelectorAll('.arrow.async-ready, .nav-link.async-ready')).forEach(function (node) {
1704
+ node.classList.remove('loading');
1705
+ if (node.parentElement.querySelector('ul') !== null) {
1706
+ node.classList.remove('async-ready');
1707
+ node.click();
1702
1708
  }
1703
- if (node.children) {
1704
- return _objectSpread(_objectSpread({}, node), {}, {
1705
- children: updateTreeData(node.children, key, children)
1709
+ });
1710
+
1711
+ // init <ul> height
1712
+ // Initialize async items
1713
+ var ul = [].slice.call(rootRef.current.querySelectorAll('ul'));
1714
+ initAsyncItems(ul).then(function () {
1715
+ initUlHeight(ul);
1716
+ });
1717
+ };
1718
+ var observeDOMChanges = function observeDOMChanges() {
1719
+ if (!rootRef.current) return;
1720
+ var observer = new MutationObserver(function (mutations) {
1721
+ // Check whether any new ul elements have been added
1722
+ var hasNewUL = mutations.some(function (mutation) {
1723
+ return Array.from(mutation.addedNodes).some(function (node) {
1724
+ return node.nodeName === 'UL';
1706
1725
  });
1726
+ });
1727
+ if (hasNewUL) {
1728
+ observer.disconnect();
1729
+ handleDOMOperations();
1707
1730
  }
1708
- return node;
1709
- }) : [];
1731
+ });
1732
+ observer.observe(rootRef.current, {
1733
+ childList: true,
1734
+ subtree: true
1735
+ });
1710
1736
  };
1711
- function fetchData(_x2, _x3) {
1737
+ var updateTreeData = /*#__PURE__*/function () {
1738
+ var _ref = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee2(list, key, children) {
1739
+ var updatedList;
1740
+ return src_regeneratorRuntime().wrap(function _callee2$(_context2) {
1741
+ while (1) switch (_context2.prev = _context2.next) {
1742
+ case 0:
1743
+ if (list) {
1744
+ _context2.next = 2;
1745
+ break;
1746
+ }
1747
+ return _context2.abrupt("return", []);
1748
+ case 2:
1749
+ _context2.next = 4;
1750
+ return Promise.all(list.map( /*#__PURE__*/function () {
1751
+ var _ref2 = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee(node) {
1752
+ return src_regeneratorRuntime().wrap(function _callee$(_context) {
1753
+ while (1) switch (_context.prev = _context.next) {
1754
+ case 0:
1755
+ if (!(node.key === key)) {
1756
+ _context.next = 2;
1757
+ break;
1758
+ }
1759
+ return _context.abrupt("return", src_objectSpread(src_objectSpread({}, node), {}, {
1760
+ children: children
1761
+ }));
1762
+ case 2:
1763
+ if (!node.children) {
1764
+ _context.next = 11;
1765
+ break;
1766
+ }
1767
+ _context.t0 = src_objectSpread;
1768
+ _context.t1 = src_objectSpread({}, node);
1769
+ _context.t2 = {};
1770
+ _context.next = 8;
1771
+ return updateTreeData(node.children, key, children);
1772
+ case 8:
1773
+ _context.t3 = _context.sent;
1774
+ _context.t4 = {
1775
+ children: _context.t3
1776
+ };
1777
+ return _context.abrupt("return", (0, _context.t0)(_context.t1, _context.t2, _context.t4));
1778
+ case 11:
1779
+ return _context.abrupt("return", node);
1780
+ case 12:
1781
+ case "end":
1782
+ return _context.stop();
1783
+ }
1784
+ }, _callee);
1785
+ }));
1786
+ return function (_x5) {
1787
+ return _ref2.apply(this, arguments);
1788
+ };
1789
+ }()));
1790
+ case 4:
1791
+ updatedList = _context2.sent;
1792
+ return _context2.abrupt("return", updatedList);
1793
+ case 6:
1794
+ case "end":
1795
+ return _context2.stop();
1796
+ }
1797
+ }, _callee2);
1798
+ }));
1799
+ return function updateTreeData(_x2, _x3, _x4) {
1800
+ return _ref.apply(this, arguments);
1801
+ };
1802
+ }();
1803
+ var closeChild = function closeChild(hyperlink, ul) {
1804
+ if (ul.length === 0) return;
1805
+ activeClass(hyperlink, 'remove');
1806
+ hyperlink.setAttribute('aria-expanded', 'false');
1807
+ activeClass(hyperlink.parentNode, 'remove');
1808
+
1809
+ //to close
1810
+ [].slice.call(ul).forEach(function (element) {
1811
+ element.style.maxHeight = 0;
1812
+ });
1813
+ };
1814
+ var openChild = function openChild(hyperlink, ul) {
1815
+ if (ul.length === 0) return;
1816
+ activeClass(hyperlink, 'add');
1817
+ hyperlink.setAttribute('aria-expanded', 'true');
1818
+ activeClass(hyperlink.parentNode, 'add');
1819
+
1820
+ // init <ul> height
1821
+ initUlHeight(ul);
1822
+ };
1823
+ function handleCollapse(e) {
1824
+ if (disableCollapse) return;
1825
+ e.preventDefault();
1826
+ e.stopPropagation();
1827
+ var hyperlink = e.currentTarget;
1828
+ var url = hyperlink.dataset.href;
1829
+ var subElement = (0,dom.getNextSiblings)(hyperlink, 'ul');
1830
+ var asyncReqReady = hyperlink.classList.contains('async-ready');
1831
+
1832
+ // loading
1833
+ //=====================
1834
+ if (asyncReqReady) {
1835
+ activeClass(hyperlink, 'add', 'loading');
1836
+ }
1837
+
1838
+ // calback
1839
+ //=====================
1840
+ var fetchFunc = asyncReqReady ? typeof initDefaultValue !== 'function' ? /*#__PURE__*/src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee3() {
1841
+ return src_regeneratorRuntime().wrap(function _callee3$(_context3) {
1842
+ while (1) switch (_context3.prev = _context3.next) {
1843
+ case 0:
1844
+ return _context3.abrupt("return", void 0);
1845
+ case 1:
1846
+ case "end":
1847
+ return _context3.stop();
1848
+ }
1849
+ }, _callee3);
1850
+ })) : initDefaultValue : /*#__PURE__*/src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee4() {
1851
+ return src_regeneratorRuntime().wrap(function _callee4$(_context4) {
1852
+ while (1) switch (_context4.prev = _context4.next) {
1853
+ case 0:
1854
+ return _context4.abrupt("return", void 0);
1855
+ case 1:
1856
+ case "end":
1857
+ return _context4.stop();
1858
+ }
1859
+ }, _callee4);
1860
+ }));
1861
+ var optiondata = typeof hyperlink.dataset.optiondata !== 'undefined' ? hyperlink.dataset.optiondata : '{}';
1862
+ onCollapse === null || onCollapse === void 0 ? void 0 : onCollapse(e, {
1863
+ key: hyperlink.dataset.key,
1864
+ slug: hyperlink.dataset.slug,
1865
+ link: hyperlink.dataset.link,
1866
+ optiondata: optiondata
1867
+ }, fetchFunc, JSON.parse(optiondata).isExpanded);
1868
+
1869
+ // update expanded status
1870
+ //=====================
1871
+ var isExpanded = hyperlink.getAttribute('aria-expanded') === 'true';
1872
+ setExpandedMap(function (prev) {
1873
+ return src_objectSpread(src_objectSpread({}, prev), {}, src_defineProperty({}, hyperlink.dataset.key, !isExpanded));
1874
+ });
1875
+
1876
+ // hide child if expandedLink doesn't exist, on the contrary
1877
+ //=====================
1878
+ if (hyperlink.classList.contains('loading')) return;
1879
+ if (hyperlink.getAttribute('aria-expanded') === 'false' || hyperlink.getAttribute('aria-expanded') === null) {
1880
+ //Hide all other siblings of the selected <ul>
1881
+ if (alternateCollapse) {
1882
+ [].slice.call(rootRef.current.firstChild.children).forEach(function (li) {
1883
+ activeClass(li, 'remove');
1884
+ var _li = li.firstChild;
1885
+ activeClass(_li, 'remove');
1886
+ _li.setAttribute('aria-expanded', false);
1887
+ [].slice.call((0,dom.getNextSiblings)(_li, 'ul')).forEach(function (element) {
1888
+ element.style.maxHeight = 0;
1889
+ });
1890
+ });
1891
+ }
1892
+
1893
+ //open current
1894
+ openChild(hyperlink, subElement);
1895
+ } else {
1896
+ //close current
1897
+ closeChild(hyperlink, subElement);
1898
+ }
1899
+ }
1900
+ function fetchData(_x6, _x7) {
1712
1901
  return _fetchData.apply(this, arguments);
1713
1902
  }
1714
1903
  function _fetchData() {
1715
- _fetchData = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee(fetch, params) {
1904
+ _fetchData = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee5(fetch, params) {
1716
1905
  var _fetch$fetchFuncAsync, response, _ORGIN_DATA;
1717
- return src_regeneratorRuntime().wrap(function _callee$(_context) {
1718
- while (1) switch (_context.prev = _context.next) {
1906
+ return src_regeneratorRuntime().wrap(function _callee5$(_context5) {
1907
+ while (1) switch (_context5.prev = _context5.next) {
1719
1908
  case 0:
1720
1909
  if (!(src_typeof(fetch.fetchFuncAsync) === 'object')) {
1721
- _context.next = 14;
1910
+ _context5.next = 14;
1722
1911
  break;
1723
1912
  }
1724
- _context.next = 3;
1913
+ _context5.next = 3;
1725
1914
  return (_fetch$fetchFuncAsync = fetch.fetchFuncAsync)["".concat(fetch.fetchFuncMethod)].apply(_fetch$fetchFuncAsync, _toConsumableArray(params.split(',')));
1726
1915
  case 3:
1727
- response = _context.sent;
1916
+ response = _context5.sent;
1728
1917
  _ORGIN_DATA = response.data;
1729
1918
  if (!(Array.isArray(_ORGIN_DATA) && _ORGIN_DATA.length > 0)) {
1730
- _context.next = 11;
1919
+ _context5.next = 11;
1731
1920
  break;
1732
1921
  }
1733
1922
  // reset data structure
@@ -1740,19 +1929,19 @@ var Tree = function Tree(props) {
1740
1929
  console.warn('The data structure does not match, please refer to the example in the component documentation.');
1741
1930
  _ORGIN_DATA = [];
1742
1931
  }
1743
- return _context.abrupt("return", _ORGIN_DATA);
1932
+ return _context5.abrupt("return", _ORGIN_DATA);
1744
1933
  case 11:
1745
- return _context.abrupt("return", []);
1934
+ return _context5.abrupt("return", []);
1746
1935
  case 12:
1747
- _context.next = 15;
1936
+ _context5.next = 15;
1748
1937
  break;
1749
1938
  case 14:
1750
- return _context.abrupt("return", []);
1939
+ return _context5.abrupt("return", []);
1751
1940
  case 15:
1752
1941
  case "end":
1753
- return _context.stop();
1942
+ return _context5.stop();
1754
1943
  }
1755
- }, _callee);
1944
+ }, _callee5);
1756
1945
  }));
1757
1946
  return _fetchData.apply(this, arguments);
1758
1947
  }
@@ -1821,94 +2010,141 @@ var Tree = function Tree(props) {
1821
2010
  }
1822
2011
  });
1823
2012
  }
1824
- function initDefaultValue(key) {
1825
- var fetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1826
- var firstRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
1827
- var retrieveData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1828
- if (firstRender) {
1829
- addKey(data, '', 0);
1830
-
1831
- // filter showing items
1832
- if (Array.isArray(retrieveData)) {
1833
- updateShowProp(data, retrieveData);
1834
- } else {
1835
- updateShowProp(data, retrieveData, true);
1836
- }
2013
+ function initDefaultValue(_x8) {
2014
+ return _initDefaultValue.apply(this, arguments);
2015
+ }
2016
+ function _initDefaultValue() {
2017
+ _initDefaultValue = src_asyncToGenerator( /*#__PURE__*/src_regeneratorRuntime().mark(function _callee6(key) {
2018
+ var fetch,
2019
+ firstRender,
2020
+ retrieveData,
2021
+ _clone,
2022
+ _newData,
2023
+ _params,
2024
+ response,
2025
+ _childrenData,
2026
+ findAndUpdateNode,
2027
+ _clone2,
2028
+ _args6 = arguments;
2029
+ return src_regeneratorRuntime().wrap(function _callee6$(_context6) {
2030
+ while (1) switch (_context6.prev = _context6.next) {
2031
+ case 0:
2032
+ fetch = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : null;
2033
+ firstRender = _args6.length > 2 && _args6[2] !== undefined ? _args6[2] : false;
2034
+ retrieveData = _args6.length > 3 && _args6[3] !== undefined ? _args6[3] : [];
2035
+ if (!firstRender) {
2036
+ _context6.next = 11;
2037
+ break;
2038
+ }
2039
+ addKey(data, '', 0);
1837
2040
 
1838
- // Initialize default value of checkboxes
1839
- if (checkable) {
1840
- initCheckboxesVal(data);
1841
- initCheckboxesData(data);
1842
- }
2041
+ // filter showing items
2042
+ if (Array.isArray(retrieveData)) {
2043
+ updateShowProp(data, retrieveData);
2044
+ } else {
2045
+ updateShowProp(data, retrieveData, true);
2046
+ }
1843
2047
 
1844
- // update list
1845
- setList(data);
2048
+ // Initialize default value of checkboxes
2049
+ if (checkable) {
2050
+ initCheckboxesVal(data);
2051
+ initCheckboxesData(data);
2052
+ }
1846
2053
 
1847
- // update retrive list
1848
- var _clone = (0,object.deepClone)(data);
1849
- setFlatList((0,object.flatData)(_clone));
1850
- return;
1851
- }
1852
- if (fetch && src_typeof(fetch.fetchFuncAsync) === 'object') {
1853
- //
1854
- var _params = fetch.fetchFuncMethodParams || [];
1855
- fetchData(fetch, _params.join(',')).then(function (response) {
1856
- var _childrenData = response;
1857
- if (_childrenData.length > 0) {
1858
- // add children to node
1859
- var _newData = updateTreeData(list, key ? key : '', _childrenData);
1860
-
1861
- // update data
1862
- addKey(_newData, '', 0);
1863
-
1864
- // filter showing items
1865
- if (Array.isArray(retrieveData)) {
1866
- updateShowProp(_newData, retrieveData);
1867
- } else {
1868
- updateShowProp(_newData, retrieveData, true);
1869
- }
2054
+ // update list
2055
+ setList(data);
1870
2056
 
1871
- // Initialize default value of checkboxes
1872
- if (checkable) {
1873
- _childrenData.forEach(function (newitem) {
1874
- setCheckedData(function (prevState) {
1875
- return [{
1876
- key: newitem.key,
1877
- checked: newitem.checked === true,
1878
- show: true,
1879
- indeterminate: false
1880
- }].concat(_toConsumableArray(prevState));
1881
- });
1882
- });
1883
- }
2057
+ // update retrive list
2058
+ _clone = (0,object.deepClone)(data);
2059
+ setFlatList((0,object.flatData)(_clone));
2060
+ return _context6.abrupt("return", data);
2061
+ case 11:
2062
+ if (!(fetch && src_typeof(fetch.fetchFuncAsync) === 'object')) {
2063
+ _context6.next = 31;
2064
+ break;
2065
+ }
2066
+ _newData = list; //
2067
+ _params = fetch.fetchFuncMethodParams || [];
2068
+ _context6.next = 16;
2069
+ return fetchData(fetch, _params.join(','));
2070
+ case 16:
2071
+ response = _context6.sent;
2072
+ _childrenData = response;
2073
+ if (!(_childrenData.length > 0)) {
2074
+ _context6.next = 29;
2075
+ break;
2076
+ }
2077
+ _context6.next = 21;
2078
+ return updateTreeData(list, key ? key : '', _childrenData);
2079
+ case 21:
2080
+ _newData = _context6.sent;
2081
+ // set its childrenAsync property to false and active to true since we've successfully loaded its children
2082
+ if (key) {
2083
+ findAndUpdateNode = function findAndUpdateNode(nodes) {
2084
+ var _iterator = src_createForOfIteratorHelper(nodes),
2085
+ _step;
2086
+ try {
2087
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
2088
+ var node = _step.value;
2089
+ if (node.key === key) {
2090
+ node.childrenAsync = false;
2091
+ node.active = true; // Add this line to set active to true
2092
+ break;
2093
+ }
2094
+ if (node.children) {
2095
+ findAndUpdateNode(node.children);
2096
+ }
2097
+ }
2098
+ } catch (err) {
2099
+ _iterator.e(err);
2100
+ } finally {
2101
+ _iterator.f();
2102
+ }
2103
+ };
2104
+ findAndUpdateNode(_newData);
2105
+ }
1884
2106
 
1885
- // update list
1886
- setList(_newData);
2107
+ // update data
2108
+ addKey(_newData, '', 0);
1887
2109
 
1888
- // update retrive list
1889
- var _clone2 = (0,object.deepClone)(_newData);
1890
- setFlatList((0,object.flatData)(_clone2));
1891
- }
2110
+ // filter showing items
2111
+ if (Array.isArray(retrieveData)) {
2112
+ updateShowProp(_newData, retrieveData);
2113
+ } else {
2114
+ updateShowProp(_newData, retrieveData, true);
2115
+ }
1892
2116
 
1893
- // loading status
1894
- setTimeout(function () {
1895
- [].slice.call(rootRef.current.querySelectorAll('.arrow.async-ready, .nav-link.async-ready')).forEach(function (node) {
1896
- node.classList.remove('loading');
1897
- if (node.parentElement.querySelector('ul') !== null) {
1898
- node.classList.remove('async-ready');
1899
- node.click();
2117
+ // Initialize default value of checkboxes
2118
+ if (checkable) {
2119
+ _childrenData.forEach(function (newitem) {
2120
+ setCheckedData(function (prevState) {
2121
+ return [{
2122
+ key: newitem.key,
2123
+ checked: newitem.checked === true,
2124
+ show: true,
2125
+ indeterminate: false
2126
+ }].concat(_toConsumableArray(prevState));
2127
+ });
2128
+ });
1900
2129
  }
1901
- });
1902
2130
 
1903
- // init <ul> height
1904
- // Initialize async items
1905
- var ul = [].slice.call(rootRef.current.querySelectorAll('ul'));
1906
- initAsyncItems(ul).then(function () {
1907
- initUlHeight(ul);
1908
- });
1909
- }, 500);
1910
- });
1911
- }
2131
+ // update list
2132
+ setList(_newData);
2133
+
2134
+ // update retrive list
2135
+ _clone2 = (0,object.deepClone)(_newData);
2136
+ setFlatList((0,object.flatData)(_clone2));
2137
+ case 29:
2138
+ // dom init
2139
+ observeDOMChanges();
2140
+ return _context6.abrupt("return", _newData);
2141
+ case 31:
2142
+ case "end":
2143
+ return _context6.stop();
2144
+ }
2145
+ }, _callee6);
2146
+ }));
2147
+ return _initDefaultValue.apply(this, arguments);
1912
2148
  }
1913
2149
  function filterRetriveData(flatData, retrieveData) {
1914
2150
  return flatData.filter(function (item) {
@@ -1932,6 +2168,7 @@ var Tree = function Tree(props) {
1932
2168
  rootNode: rootRef,
1933
2169
  checkboxNamePrefix: idRes,
1934
2170
  alternateCollapse: alternateCollapse,
2171
+ renderOption: renderOption,
1935
2172
  first: true,
1936
2173
  disableArrow: disableArrow,
1937
2174
  disableCollapse: disableCollapse,
@@ -1942,13 +2179,17 @@ var Tree = function Tree(props) {
1942
2179
  childClassName: childClassName || 'tree-diagram-default-nav',
1943
2180
  onSelect: onSelect,
1944
2181
  onDoubleSelect: onDoubleSelect,
1945
- onCollapse: onCollapse,
1946
2182
  onCheck: onCheck,
1947
2183
  evInitValue: initDefaultValue,
1948
2184
  updateCheckedPrint: setCheckedPrint,
1949
2185
  getCheckedPrint: checkedPrint,
1950
2186
  updategetCheckedData: setCheckedData,
1951
2187
  getCheckedData: checkedData
2188
+
2189
+ // Collapse
2190
+ ,
2191
+ expandedMap: expandedMap,
2192
+ onCollapse: handleCollapse
1952
2193
  })));
1953
2194
  };
1954
2195
  /* harmony default export */ const src = (Tree);