funda-ui 1.0.415 → 1.0.418

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.
@@ -871,16 +871,20 @@ var CascadingSelect = function CascadingSelect(props) {
871
871
  fill: "#000",
872
872
  d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
873
873
  }))) : null, data.map(function (item, level) {
874
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
875
- key: level
876
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Group, {
877
- level: level,
878
- columnTitle: columnTitleData,
879
- data: item,
880
- selectEv: function selectEv(e, value, index) {
881
- return handleClickItem(e, value, index, level);
882
- }
883
- }));
874
+ if (item.length > 0) {
875
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
876
+ key: level
877
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Group, {
878
+ level: level,
879
+ columnTitle: columnTitleData,
880
+ data: item,
881
+ selectEv: function selectEv(e, value, index) {
882
+ return handleClickItem(e, value, index, level);
883
+ }
884
+ }));
885
+ } else {
886
+ return null;
887
+ }
884
888
  }))) : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
885
889
  className: "cascading-select__val",
886
890
  onClick: handleDisplayOptions
@@ -10,6 +10,9 @@ interface fetchArrayConfig {
10
10
  fetchFuncMethod?: string | undefined;
11
11
  fetchFuncMethodParams?: any[] | undefined;
12
12
  fetchCallback?: (data: any) => void;
13
+ hierarchical?: boolean;
14
+ indentation?: string;
15
+ doubleIndent?: boolean;
13
16
  }
14
17
  declare type CascadingSelectE2EProps = {
15
18
  wrapperClassName?: string;
@@ -20,6 +23,10 @@ declare type CascadingSelectE2EProps = {
20
23
  placeholder?: string;
21
24
  disabled?: any;
22
25
  required?: any;
26
+ /** Instead of using `parent_id` of response to match child and parent data
27
+ * (very useful for multiple fetch requests with no directly related fields),
28
+ * this operation will directly use the click event to modify the result. */
29
+ destroyParentIdMatch?: boolean;
23
30
  /** Set headers for each column group */
24
31
  columnTitle?: any[];
25
32
  /** Set whether to use "label" or "value" for the value of this form, they will be separated by commas, such as `Text 1,Text 1_1,Text 1_1_1` or `1,1_1,1_1_1`.
@@ -63,6 +63,155 @@ module.exports = {
63
63
 
64
64
  /***/ }),
65
65
 
66
+ /***/ 602:
67
+ /***/ ((module) => {
68
+
69
+ function _typeof(obj) { "@babel/helpers - typeof"; return _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; }, _typeof(obj); }
70
+ var _excluded = ["children"];
71
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
72
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
73
+ 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; }
74
+ 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; }
75
+ 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; }
76
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
77
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
78
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
79
+ 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."); }
80
+ 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); }
81
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
82
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
83
+ 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; }
84
+ function _objectDestructuringEmpty(obj) { if (obj == null) throw new TypeError("Cannot destructure " + obj); }
85
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
86
+ /**
87
+ * Convert Tree
88
+ * @param {Array} arr - Flat array
89
+ * @param {?String | ?Number} parentId - Parent id
90
+ * @param {?String} keyId - Key value of id.
91
+ * @param {?String} keyParentId - Key value of parent id.
92
+ * @returns Array
93
+ */
94
+ function convertTree(arr) {
95
+ var parentId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
96
+ var keyId = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'id';
97
+ var keyParentId = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'parent_id';
98
+ if (!parentId) {
99
+ // If there is no parent id (when recursing for the first time), all parents will be queried
100
+ return arr.filter(function (item) {
101
+ return !item[keyParentId];
102
+ }).map(function (item) {
103
+ // Query all child nodes by parent node ID
104
+ item.children = convertTree(arr, item[keyId], keyId, keyParentId);
105
+ return item;
106
+ });
107
+ } else {
108
+ return arr.filter(function (item) {
109
+ return item[keyParentId] === parentId;
110
+ }).map(function (item) {
111
+ // Query all child nodes by parent node ID
112
+ item.children = convertTree(arr, item[keyId], keyId, keyParentId);
113
+ return item;
114
+ });
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Flat tree
120
+ * @param {Array} arr - Hierarchical array
121
+ * @returns Array
122
+ */
123
+ function flatTree(arr) {
124
+ var flatData = function flatData(_ref) {
125
+ var rest = _extends({}, (_objectDestructuringEmpty(_ref), _ref));
126
+ var _rest$children = rest.children,
127
+ children = _rest$children === void 0 ? [] : _rest$children;
128
+ return [_objectSpread({}, rest)].concat(_toConsumableArray(children.flatMap(flatData)));
129
+ };
130
+ var result = arr.flatMap(flatData);
131
+
132
+ //remove children from item
133
+ result = result.map(function (item) {
134
+ delete item.children;
135
+ return item;
136
+ });
137
+ return result;
138
+ }
139
+
140
+ /**
141
+ * Get all depth
142
+ * @param {Object} node
143
+ * @returns Number
144
+ */
145
+ function getAllDepth(arr) {
146
+ var count = function count(children) {
147
+ return children.reduce(function (depth, child) {
148
+ return Math.max(depth, 1 + count(child.children)); // increment depth of children by 1, and compare it with accumulated depth of other children within the same element
149
+ }, 0); //default value 0 that's returned if there are no children
150
+ };
151
+
152
+ return count(arr);
153
+ }
154
+
155
+ /**
156
+ * Add depth to each item in the tree
157
+ * @param {Array} arr - Hierarchical array
158
+ * @param {?String} keyId - Key value of id.
159
+ * @param {?String} keyParentId - Key value of parent id.
160
+ * @param {?Number} depth - Depth of the item.
161
+ * @returns Number
162
+ */
163
+ function addTreeDepth(arr) {
164
+ var keyId = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'id';
165
+ var parentItem = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
166
+ var depth = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
167
+ return arr.reduce(function (acc, el) {
168
+ var children = el.children,
169
+ otherProps = _objectWithoutProperties(el, _excluded);
170
+ acc.push(_objectSpread(_objectSpread({}, otherProps), {}, {
171
+ parentItem: parentItem,
172
+ depth: depth
173
+ }));
174
+ if (children) {
175
+ return acc.concat(addTreeDepth(children, keyId, el[keyId], depth + 1));
176
+ }
177
+ return acc;
178
+ }, []);
179
+ }
180
+
181
+ /**
182
+ * Add indent placeholder
183
+ * @param {Array} arr - Flat array
184
+ * @param {?String} placeholder - String of placeholder
185
+ * @param {?String} lastPlaceholder - Last String of placeholder
186
+ * @param {?String} keyName - Key value of name.
187
+ * @returns Array
188
+ */
189
+ function addTreeIndent(arr) {
190
+ var placeholder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '&nbsp;&nbsp;&nbsp;&nbsp;';
191
+ var lastPlaceholder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
192
+ var keyName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 'label';
193
+ arr.forEach(function (item) {
194
+ var indent = '';
195
+ if (item.depth) {
196
+ Array(item.depth).fill(0).forEach(function (k, i) {
197
+ indent += placeholder;
198
+ if (i === item.depth - 1) {
199
+ item[keyName] = indent + lastPlaceholder + item[keyName];
200
+ }
201
+ });
202
+ }
203
+ });
204
+ }
205
+ module.exports = {
206
+ getAllDepth: getAllDepth,
207
+ convertTree: convertTree,
208
+ flatTree: flatTree,
209
+ addTreeDepth: addTreeDepth,
210
+ addTreeIndent: addTreeIndent
211
+ };
212
+
213
+ /***/ }),
214
+
66
215
  /***/ 787:
67
216
  /***/ ((module) => {
68
217
 
@@ -175,7 +324,7 @@ function Group(props) {
175
324
  return selectEv(e, item, index);
176
325
  },
177
326
  dangerouslySetInnerHTML: {
178
- __html: item.name
327
+ __html: typeof item.label !== 'undefined' ? item.label : item.name // "item.label" usually uses hierarchical style
179
328
  }
180
329
  });
181
330
  } else {
@@ -195,8 +344,10 @@ function Group(props) {
195
344
  }
196
345
  }));
197
346
  }
347
+ // EXTERNAL MODULE: ./src/utils/tree.js
348
+ var tree = __webpack_require__(602);
198
349
  ;// CONCATENATED MODULE: ./src/index.tsx
199
- var _excluded = ["wrapperClassName", "controlClassName", "disabled", "required", "value", "label", "placeholder", "name", "id", "columnTitle", "depth", "loader", "displayResult", "displayResultArrow", "controlArrow", "valueType", "showCloseBtn", "style", "tabIndex", "triggerClassName", "triggerContent", "fetchArray", "onFetch", "onChange", "onBlur", "onFocus"];
350
+ var _excluded = ["wrapperClassName", "controlClassName", "disabled", "required", "value", "label", "placeholder", "name", "id", "destroyParentIdMatch", "columnTitle", "depth", "loader", "displayResult", "displayResultArrow", "controlArrow", "valueType", "showCloseBtn", "style", "tabIndex", "triggerClassName", "triggerContent", "fetchArray", "onFetch", "onChange", "onBlur", "onFocus"];
200
351
  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 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" == _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; }
201
352
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
202
353
  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."); }
@@ -217,6 +368,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
217
368
 
218
369
 
219
370
 
371
+
220
372
  var CascadingSelectE2E = function CascadingSelectE2E(props) {
221
373
  var wrapperClassName = props.wrapperClassName,
222
374
  controlClassName = props.controlClassName,
@@ -227,6 +379,7 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
227
379
  placeholder = props.placeholder,
228
380
  name = props.name,
229
381
  id = props.id,
382
+ destroyParentIdMatch = props.destroyParentIdMatch,
230
383
  columnTitle = props.columnTitle,
231
384
  depth = props.depth,
232
385
  loader = props.loader,
@@ -312,6 +465,32 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
312
465
  isShow = _useState24[0],
313
466
  setIsShow = _useState24[1];
314
467
 
468
+ // destroy `parent_id` match
469
+ var _useState25 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)({
470
+ labels: [],
471
+ values: [],
472
+ queryIds: []
473
+ }),
474
+ _useState26 = _slicedToArray(_useState25, 2),
475
+ selectedDataByClick = _useState26[0],
476
+ setSelectedDataByClick = _useState26[1];
477
+
478
+ /**
479
+ * Format indent value
480
+ * @param {String|Array} str
481
+ * @returns {String|Array}
482
+ */
483
+ function formatIndentVal(str, indentLastPlaceholder) {
484
+ var reVar = new RegExp(indentLastPlaceholder, 'g');
485
+ if (Array.isArray(str)) {
486
+ return str.map(function (s) {
487
+ return s.replace(reVar, '').replace(/\&nbsp;/ig, '');
488
+ });
489
+ } else {
490
+ return str.replace(reVar, '').replace(/\&nbsp;/ig, '');
491
+ }
492
+ }
493
+
315
494
  /**
316
495
  * Check if an element is in the viewport
317
496
  * @param {HTMLElement} elem
@@ -358,6 +537,11 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
358
537
  fetchFuncAsync,
359
538
  fetchFuncMethod,
360
539
  fetchCallback,
540
+ hierarchical,
541
+ indentation,
542
+ doubleIndent,
543
+ INDENT_PLACEHOLDER,
544
+ INDENT_LAST_PLACEHOLDER,
361
545
  response,
362
546
  _ORGIN_DATA,
363
547
  _TEMP_ALL_DATA,
@@ -371,26 +555,31 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
371
555
  parentId = _args.length > 3 && _args[3] !== undefined ? _args[3] : 0;
372
556
  fetchFuncAsync = _fetchArray.fetchFuncAsync;
373
557
  fetchFuncMethod = _fetchArray.fetchFuncMethod;
374
- fetchCallback = _fetchArray.fetchCallback;
558
+ fetchCallback = _fetchArray.fetchCallback; //
559
+ hierarchical = _fetchArray.hierarchical;
560
+ indentation = _fetchArray.indentation;
561
+ doubleIndent = _fetchArray.doubleIndent;
562
+ INDENT_PLACEHOLDER = doubleIndent ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" : "&nbsp;&nbsp;&nbsp;&nbsp;";
563
+ INDENT_LAST_PLACEHOLDER = "".concat(typeof indentation !== 'undefined' && indentation !== '' ? "".concat(indentation, "&nbsp;&nbsp;") : '');
375
564
  if (!(_typeof(fetchFuncAsync) === 'object')) {
376
- _context.next = 27;
565
+ _context.next = 33;
377
566
  break;
378
567
  }
379
568
  //
380
569
  setLoading(true);
381
- _context.next = 8;
570
+ _context.next = 13;
382
571
  return fetchFuncAsync["".concat(fetchFuncMethod)].apply(fetchFuncAsync, _toConsumableArray(params.split(',')));
383
- case 8:
572
+ case 13:
384
573
  response = _context.sent;
385
574
  _ORGIN_DATA = response.data;
386
575
  _TEMP_ALL_DATA = []; // loading
387
576
  setLoading(false);
388
577
  if (!(typeof _ORGIN_DATA[0] === 'undefined')) {
389
- _context.next = 14;
578
+ _context.next = 19;
390
579
  break;
391
580
  }
392
581
  return _context.abrupt("return");
393
- case 14:
582
+ case 19:
394
583
  // reset data structure
395
584
  if (typeof fetchCallback === 'function') {
396
585
  _ORGIN_DATA = fetchCallback(_ORGIN_DATA);
@@ -403,9 +592,17 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
403
592
  _ORGIN_DATA = [];
404
593
  }
405
594
 
595
+ // STEP 0-1: ===========
596
+ // Set hierarchical categories ( with sub-categories )
597
+ if (hierarchical) {
598
+ _ORGIN_DATA = (0,tree.addTreeDepth)(_ORGIN_DATA);
599
+ (0,tree.addTreeIndent)(_ORGIN_DATA, INDENT_PLACEHOLDER, INDENT_LAST_PLACEHOLDER, 'label');
600
+ }
601
+
602
+ // STEP 0-2: ===========
406
603
  // add data depth
407
604
  _ORGIN_DATA.forEach(function (item) {
408
- item.depth = dataDepth;
605
+ item.itemDepth = dataDepth;
409
606
  });
410
607
  if (dataDepth === 0) {
411
608
  // STEP 1: ===========
@@ -456,9 +653,9 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
456
653
  //
457
654
  onFetch === null || onFetch === void 0 ? void 0 : onFetch(_EMPTY_SUPPORTED_DATA, _ORGIN_DATA);
458
655
  return _context.abrupt("return", [_ORGIN_DATA, _EMPTY_SUPPORTED_DATA]);
459
- case 27:
656
+ case 33:
460
657
  return _context.abrupt("return", []);
461
- case 28:
658
+ case 34:
462
659
  case "end":
463
660
  return _context.stop();
464
661
  }
@@ -533,15 +730,51 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
533
730
  }, 0);
534
731
  }
535
732
  function handleClickItem(e, resValue, index, level) {
536
- var dataDepthMax = resValue.depth === fetchArray.length - 1;
733
+ var dataDepthMax = resValue.itemDepth === fetchArray.length - 1;
537
734
  var parentId = e.currentTarget.dataset.query;
538
735
  var emptyAction = resValue.id.toString().indexOf('$EMPTY_ID_') < 0 ? false : true;
539
736
 
737
+ //update selected data by clicked item
738
+ //////////////////////////////////////////
739
+ setSelectedDataByClick(function (prevState) {
740
+ var _valueData = prevState.values.slice(0, level + 1);
741
+ var _labelData = prevState.labels.slice(0, level + 1);
742
+ var _queryIdsData = prevState.queryIds.slice(0, level + 1);
743
+ _valueData.splice(level, 1, resValue.id);
744
+ _labelData.splice(level, 1, resValue.name);
745
+ _queryIdsData.splice(level, 1, resValue.queryId);
746
+ console.log('****', {
747
+ labels: _labelData.filter(function (v) {
748
+ return v != '';
749
+ }),
750
+ values: _valueData.filter(function (v) {
751
+ return v.toString().indexOf('$EMPTY_ID_') < 0;
752
+ }),
753
+ queryIds: _queryIdsData.filter(function (v) {
754
+ return v != undefined;
755
+ })
756
+ });
757
+ return {
758
+ labels: _labelData.filter(function (v) {
759
+ return v != '';
760
+ }),
761
+ values: _valueData.filter(function (v) {
762
+ return v.toString().indexOf('$EMPTY_ID_') < 0;
763
+ }),
764
+ queryIds: _queryIdsData.filter(function (v) {
765
+ return v != undefined;
766
+ })
767
+ };
768
+ });
769
+
770
+ // update dis
771
+ //////////////////////////////////////////
772
+
540
773
  // update data depth
541
774
  //////////////////////////////////////////
542
- setCurrentDataDepth(resValue.depth + 1);
775
+ setCurrentDataDepth(resValue.itemDepth + 1);
543
776
  setCurrentDataDepth(function (prevState) {
544
- var _currentDataDepth = resValue.depth + 1;
777
+ var _currentDataDepth = resValue.itemDepth + 1;
545
778
 
546
779
  // Execute the fetch task
547
780
  //////////////////////////////////////////
@@ -668,6 +901,11 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
668
901
 
669
902
  // update selected data
670
903
  //////////////////////////////////////////
904
+ if (destroyParentIdMatch) {
905
+ _valueData = selectedDataByClick.values;
906
+ _labelData = selectedDataByClick.labels;
907
+ _queryIdsData = selectedDataByClick.queryIds;
908
+ }
671
909
  var inputVal_0 = _valueData.map(function (item, i) {
672
910
  return "".concat(item, "[").concat(_queryIdsData[i], "]");
673
911
  }).join(',');
@@ -693,6 +931,11 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
693
931
  values: [],
694
932
  queryIds: []
695
933
  });
934
+ setSelectedDataByClick({
935
+ labels: [],
936
+ values: [],
937
+ queryIds: []
938
+ });
696
939
  setAllData([]);
697
940
  setDictionaryData([]);
698
941
  setOptData([]);
@@ -786,7 +1029,9 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
786
1029
  // all data from fetched data
787
1030
  if (typeof values[curDepth] !== 'undefined') {
788
1031
  var childList = values[curDepth][0];
789
- newData[activedIndex].children = childList;
1032
+
1033
+ // if the value of some column is not fetched
1034
+ if (typeof newData[activedIndex] !== 'undefined') newData[activedIndex].children = childList;
790
1035
  }
791
1036
  _TEMP_ALL_DATA.forEach(function (item) {
792
1037
  if (item.id === queryIds[i]) item.children = newData;
@@ -826,6 +1071,11 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
826
1071
  values: _allValues,
827
1072
  queryIds: queryIds
828
1073
  });
1074
+ setSelectedDataByClick({
1075
+ labels: _allLables,
1076
+ values: _allValues,
1077
+ queryIds: queryIds
1078
+ });
829
1079
  });
830
1080
  });
831
1081
  }
@@ -845,7 +1095,10 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
845
1095
  setColumnTitleData(newColumnTitleData);
846
1096
  }
847
1097
  function addChildrenOpt(obj, parentId, childrenData) {
1098
+ // Traverse the results obtained by all fetch
848
1099
  obj.forEach(function (item) {
1100
+ // !!!IMPORTANT:
1101
+ // You need to put the contents of other columns after fetch into the "children" attribute
849
1102
  if (item.id === parentId) item.children = childrenData;
850
1103
  if (item.children) {
851
1104
  addChildrenOpt(item.children, parentId, childrenData);
@@ -857,7 +1110,7 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
857
1110
  obj.unshift({
858
1111
  id: "$EMPTY_ID_" + index,
859
1112
  name: "",
860
- depth: obj.length === 0 ? 0 : obj[0].depth
1113
+ itemDepth: obj.length === 0 ? 0 : obj[0].itemDepth
861
1114
  });
862
1115
  obj.forEach(function (item, depth) {
863
1116
  if (item.children) {
@@ -945,8 +1198,9 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
945
1198
  }
946
1199
  return resAll;
947
1200
  }
948
- function displayInfo() {
949
- return selectedData.labels ? selectedData.labels.map(function (item, i, arr) {
1201
+ function displayInfo(destroyParentId) {
1202
+ var _data = destroyParentId ? selectedDataByClick : selectedData;
1203
+ return _data.labels ? _data.labels.map(function (item, i, arr) {
950
1204
  if (arr.length - 1 === i) {
951
1205
  return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
952
1206
  key: i
@@ -1041,28 +1295,38 @@ var CascadingSelectE2E = function CascadingSelectE2E(props) {
1041
1295
  fill: "#000",
1042
1296
  d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
1043
1297
  }))) : null, data.map(function (item, level) {
1044
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
1045
- key: level
1046
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Group, {
1047
- level: level,
1048
- columnTitle: columnTitleData,
1049
- data: item,
1050
- selectEv: function selectEv(e, value, index) {
1051
- return handleClickItem(e, value, index, level);
1052
- }
1053
- }));
1298
+ if (item.length > 0) {
1299
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
1300
+ key: level
1301
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Group, {
1302
+ level: level,
1303
+ columnTitle: columnTitleData,
1304
+ data: item,
1305
+ selectEv: function selectEv(e, value, index) {
1306
+ return handleClickItem(e, value, index, level);
1307
+ }
1308
+ }));
1309
+ } else {
1310
+ return null;
1311
+ }
1054
1312
  }))) : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1055
1313
  className: "cascading-select-e2e__val",
1056
1314
  onClick: handleDisplayOptions
1057
- }, displayResult ? selectedData.labels && selectedData.labels.length > 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1315
+ }, destroyParentIdMatch ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, displayResult ? selectedDataByClick.labels && selectedDataByClick.labels.length > 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1316
+ className: "cascading-select-e2e__result"
1317
+ }, displayInfo(true)) : null : null) : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, displayResult ? selectedData.labels && selectedData.labels.length > 0 ? /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
1058
1318
  className: "cascading-select-e2e__result"
1059
- }, displayInfo()) : null : null, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", _extends({
1319
+ }, displayInfo(false)) : null : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", _extends({
1060
1320
  ref: valRef,
1061
1321
  id: idRes,
1062
1322
  name: name,
1063
1323
  className: controlClassName || controlClassName === '' ? controlClassName : "form-control",
1064
1324
  placeholder: placeholder,
1065
- value: changedVal // placeholder will not change if defaultValue is used
1325
+ value: destroyParentIdMatch ? valueType === 'value' ? selectedDataByClick.values.map(function (item, i) {
1326
+ return "".concat(item, "[").concat(selectedDataByClick.queryIds[i], "]");
1327
+ }).join(',') : selectedDataByClick.labels.map(function (item, i) {
1328
+ return "".concat(item, "[").concat(selectedDataByClick.queryIds[i], "]");
1329
+ }).join(',') : changedVal // placeholder will not change if defaultValue is used
1066
1330
  ,
1067
1331
  onFocus: handleFocus,
1068
1332
  onBlur: handleBlur,
@@ -771,9 +771,11 @@ var LiveSearch = function LiveSearch(props) {
771
771
  res = [];
772
772
  filterRes = function filterRes(data) {
773
773
  return data.filter(function (item) {
774
- if ((item.queryString.split(',').some(function (l) {
774
+ // Avoid fatal errors causing page crashes
775
+ var _queryString = typeof item.queryString !== 'undefined' ? item.queryString : '';
776
+ if ((_queryString.split(',').some(function (l) {
775
777
  return l.charAt(0) === val.toLowerCase();
776
- }) || item.queryString.split(',').some(function (l) {
778
+ }) || _queryString.split(',').some(function (l) {
777
779
  return l.replace(/ /g, '').indexOf(val.toLowerCase()) >= 0;
778
780
  }) || item.label.toLowerCase().indexOf(val.toLowerCase()) >= 0) && val != '') {
779
781
  return true;
@@ -35,8 +35,8 @@ declare type MultiFuncSelectProps = {
35
35
  options?: OptionConfig[] | string;
36
36
  hierarchical?: boolean;
37
37
  indentation?: string;
38
- winWidth?: string | Function;
39
38
  doubleIndent?: boolean;
39
+ winWidth?: string | Function;
40
40
  controlArrow?: React.ReactNode;
41
41
  fetchTrigger?: boolean;
42
42
  fetchTriggerForDefaultData?: MultiSelectDataConfig | null;
@@ -486,9 +486,11 @@ var MultiFuncSelect = /*#__PURE__*/(0,external_root_React_commonjs2_react_common
486
486
  var update = function update(inputData) {
487
487
  var filterRes = function filterRes(data) {
488
488
  return inputData.filter(function (item) {
489
- if ((item.queryString.split(',').some(function (l) {
489
+ // Avoid fatal errors causing page crashes
490
+ var _queryString = typeof item.queryString !== 'undefined' ? item.queryString : '';
491
+ if ((_queryString.split(',').some(function (l) {
490
492
  return l.charAt(0) === val.toLowerCase();
491
- }) || item.queryString.split(',').some(function (l) {
493
+ }) || _queryString.split(',').some(function (l) {
492
494
  return l.replace(/ /g, '').indexOf(val.toLowerCase()) >= 0;
493
495
  }) || item.label.toLowerCase().indexOf(val.toLowerCase()) >= 0) && val != '') {
494
496
  return true;
@@ -871,16 +871,20 @@ var CascadingSelect = function CascadingSelect(props) {
871
871
  fill: "#000",
872
872
  d: "M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z"
873
873
  }))) : null, data.map(function (item, level) {
874
- return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
875
- key: level
876
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Group, {
877
- level: level,
878
- columnTitle: columnTitleData,
879
- data: item,
880
- selectEv: function selectEv(e, value, index) {
881
- return handleClickItem(e, value, index, level);
882
- }
883
- }));
874
+ if (item.length > 0) {
875
+ return /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("li", {
876
+ key: level
877
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement(Group, {
878
+ level: level,
879
+ columnTitle: columnTitleData,
880
+ data: item,
881
+ selectEv: function selectEv(e, value, index) {
882
+ return handleClickItem(e, value, index, level);
883
+ }
884
+ }));
885
+ } else {
886
+ return null;
887
+ }
884
888
  }))) : null), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
885
889
  className: "cascading-select__val",
886
890
  onClick: handleDisplayOptions