funda-ui 3.8.821 → 3.9.14

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
@@ -11,433 +11,6 @@
11
11
  return /******/ (() => { // webpackBootstrap
12
12
  /******/ var __webpack_modules__ = ({
13
13
 
14
- /***/ 109:
15
- /***/ (function(module, exports, __webpack_require__) {
16
-
17
- /* module decorator */ module = __webpack_require__.nmd(module);
18
- var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;function _typeof2(obj) { "@babel/helpers - typeof"; return _typeof2 = "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; }, _typeof2(obj); }
19
- (function webpackUniversalModuleDefinition(root, factory) {
20
- if (( false ? 0 : _typeof2(exports)) === 'object' && ( false ? 0 : _typeof2(module)) === 'object') module.exports = factory(__webpack_require__(787));else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [__webpack_require__(787)], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
21
- __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
22
- (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
23
- __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else {}
24
- })(this, function (__WEBPACK_EXTERNAL_MODULE__787__) {
25
- return (/******/function () {
26
- // webpackBootstrap
27
- /******/
28
- "use strict";
29
-
30
- /******/
31
- var __webpack_modules__ = {
32
- /***/787: /***/function _(module) {
33
- module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
34
-
35
- /***/
36
- }
37
-
38
- /******/
39
- };
40
- /************************************************************************/
41
- /******/ // The module cache
42
- /******/
43
- var __webpack_module_cache__ = {};
44
- /******/
45
- /******/ // The require function
46
- /******/
47
- function __nested_webpack_require_1471__(moduleId) {
48
- /******/ // Check if module is in cache
49
- /******/var cachedModule = __webpack_module_cache__[moduleId];
50
- /******/
51
- if (cachedModule !== undefined) {
52
- /******/return cachedModule.exports;
53
- /******/
54
- }
55
- /******/ // Create a new module (and put it into the cache)
56
- /******/
57
- var module = __webpack_module_cache__[moduleId] = {
58
- /******/ // no module.id needed
59
- /******/ // no module.loaded needed
60
- /******/exports: {}
61
- /******/
62
- };
63
- /******/
64
- /******/ // Execute the module function
65
- /******/
66
- __webpack_modules__[moduleId](module, module.exports, __nested_webpack_require_1471__);
67
- /******/
68
- /******/ // Return the exports of the module
69
- /******/
70
- return module.exports;
71
- /******/
72
- }
73
- /******/
74
- /************************************************************************/
75
- /******/ /* webpack/runtime/compat get default export */
76
- /******/
77
- (function () {
78
- /******/ // getDefaultExport function for compatibility with non-harmony modules
79
- /******/__nested_webpack_require_1471__.n = function (module) {
80
- /******/var getter = module && module.__esModule ? /******/function () {
81
- return module['default'];
82
- } : /******/function () {
83
- return module;
84
- };
85
- /******/
86
- __nested_webpack_require_1471__.d(getter, {
87
- a: getter
88
- });
89
- /******/
90
- return getter;
91
- /******/
92
- };
93
- /******/
94
- })();
95
- /******/
96
- /******/ /* webpack/runtime/define property getters */
97
- /******/
98
- (function () {
99
- /******/ // define getter functions for harmony exports
100
- /******/__nested_webpack_require_1471__.d = function (exports, definition) {
101
- /******/for (var key in definition) {
102
- /******/if (__nested_webpack_require_1471__.o(definition, key) && !__nested_webpack_require_1471__.o(exports, key)) {
103
- /******/Object.defineProperty(exports, key, {
104
- enumerable: true,
105
- get: definition[key]
106
- });
107
- /******/
108
- }
109
- /******/
110
- }
111
- /******/
112
- };
113
- /******/
114
- })();
115
- /******/
116
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
117
- /******/
118
- (function () {
119
- /******/__nested_webpack_require_1471__.o = function (obj, prop) {
120
- return Object.prototype.hasOwnProperty.call(obj, prop);
121
- };
122
- /******/
123
- })();
124
- /******/
125
- /******/ /* webpack/runtime/make namespace object */
126
- /******/
127
- (function () {
128
- /******/ // define __esModule on exports
129
- /******/__nested_webpack_require_1471__.r = function (exports) {
130
- /******/if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
131
- /******/Object.defineProperty(exports, Symbol.toStringTag, {
132
- value: 'Module'
133
- });
134
- /******/
135
- }
136
- /******/
137
- Object.defineProperty(exports, '__esModule', {
138
- value: true
139
- });
140
- /******/
141
- };
142
- /******/
143
- })();
144
- /******/
145
- /************************************************************************/
146
- var __webpack_exports__ = {};
147
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
148
- (function () {
149
- __nested_webpack_require_1471__.r(__webpack_exports__);
150
- /* harmony export */
151
- __nested_webpack_require_1471__.d(__webpack_exports__, {
152
- /* harmony export */"default": function _default() {
153
- return __WEBPACK_DEFAULT_EXPORT__;
154
- }
155
- /* harmony export */
156
- });
157
- /* harmony import */
158
- var react__WEBPACK_IMPORTED_MODULE_0__ = __nested_webpack_require_1471__(787);
159
- /* harmony import */
160
- var react__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__nested_webpack_require_1471__.n(react__WEBPACK_IMPORTED_MODULE_0__);
161
- function _typeof(obj) {
162
- "@babel/helpers - typeof";
163
-
164
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
165
- return typeof obj;
166
- } : function (obj) {
167
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
168
- }, _typeof(obj);
169
- }
170
- var _excluded = ["wrapperClassName", "itemSelectedClassName", "disabled", "required", "value", "label", "name", "id", "checked", "indeterminate", "style", "tabIndex", "onChange", "onBlur", "onFocus"];
171
- function _extends() {
172
- _extends = Object.assign ? Object.assign.bind() : function (target) {
173
- for (var i = 1; i < arguments.length; i++) {
174
- var source = arguments[i];
175
- for (var key in source) {
176
- if (Object.prototype.hasOwnProperty.call(source, key)) {
177
- target[key] = source[key];
178
- }
179
- }
180
- }
181
- return target;
182
- };
183
- return _extends.apply(this, arguments);
184
- }
185
- function ownKeys(object, enumerableOnly) {
186
- var keys = Object.keys(object);
187
- if (Object.getOwnPropertySymbols) {
188
- var symbols = Object.getOwnPropertySymbols(object);
189
- enumerableOnly && (symbols = symbols.filter(function (sym) {
190
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
191
- })), keys.push.apply(keys, symbols);
192
- }
193
- return keys;
194
- }
195
- function _objectSpread(target) {
196
- for (var i = 1; i < arguments.length; i++) {
197
- var source = null != arguments[i] ? arguments[i] : {};
198
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
199
- _defineProperty(target, key, source[key]);
200
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
201
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
202
- });
203
- }
204
- return target;
205
- }
206
- function _defineProperty(obj, key, value) {
207
- key = _toPropertyKey(key);
208
- if (key in obj) {
209
- Object.defineProperty(obj, key, {
210
- value: value,
211
- enumerable: true,
212
- configurable: true,
213
- writable: true
214
- });
215
- } else {
216
- obj[key] = value;
217
- }
218
- return obj;
219
- }
220
- function _toPropertyKey(arg) {
221
- var key = _toPrimitive(arg, "string");
222
- return _typeof(key) === "symbol" ? key : String(key);
223
- }
224
- function _toPrimitive(input, hint) {
225
- if (_typeof(input) !== "object" || input === null) return input;
226
- var prim = input[Symbol.toPrimitive];
227
- if (prim !== undefined) {
228
- var res = prim.call(input, hint || "default");
229
- if (_typeof(res) !== "object") return res;
230
- throw new TypeError("@@toPrimitive must return a primitive value.");
231
- }
232
- return (hint === "string" ? String : Number)(input);
233
- }
234
- function _slicedToArray(arr, i) {
235
- return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
236
- }
237
- function _nonIterableRest() {
238
- throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
239
- }
240
- function _unsupportedIterableToArray(o, minLen) {
241
- if (!o) return;
242
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
243
- var n = Object.prototype.toString.call(o).slice(8, -1);
244
- if (n === "Object" && o.constructor) n = o.constructor.name;
245
- if (n === "Map" || n === "Set") return Array.from(o);
246
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
247
- }
248
- function _arrayLikeToArray(arr, len) {
249
- if (len == null || len > arr.length) len = arr.length;
250
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
251
- return arr2;
252
- }
253
- function _iterableToArrayLimit(arr, i) {
254
- var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
255
- if (null != _i) {
256
- var _s,
257
- _e,
258
- _x,
259
- _r,
260
- _arr = [],
261
- _n = !0,
262
- _d = !1;
263
- try {
264
- if (_x = (_i = _i.call(arr)).next, 0 === i) {
265
- if (Object(_i) !== _i) return;
266
- _n = !1;
267
- } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0);
268
- } catch (err) {
269
- _d = !0, _e = err;
270
- } finally {
271
- try {
272
- if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return;
273
- } finally {
274
- if (_d) throw _e;
275
- }
276
- }
277
- return _arr;
278
- }
279
- }
280
- function _arrayWithHoles(arr) {
281
- if (Array.isArray(arr)) return arr;
282
- }
283
- function _objectWithoutProperties(source, excluded) {
284
- if (source == null) return {};
285
- var target = _objectWithoutPropertiesLoose(source, excluded);
286
- var key, i;
287
- if (Object.getOwnPropertySymbols) {
288
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
289
- for (i = 0; i < sourceSymbolKeys.length; i++) {
290
- key = sourceSymbolKeys[i];
291
- if (excluded.indexOf(key) >= 0) continue;
292
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
293
- target[key] = source[key];
294
- }
295
- }
296
- return target;
297
- }
298
- function _objectWithoutPropertiesLoose(source, excluded) {
299
- if (source == null) return {};
300
- var target = {};
301
- var sourceKeys = Object.keys(source);
302
- var key, i;
303
- for (i = 0; i < sourceKeys.length; i++) {
304
- key = sourceKeys[i];
305
- if (excluded.indexOf(key) >= 0) continue;
306
- target[key] = source[key];
307
- }
308
- return target;
309
- }
310
- var Checkbox = /*#__PURE__*/(0, react__WEBPACK_IMPORTED_MODULE_0__.forwardRef)(function (props, _ref) {
311
- var wrapperClassName = props.wrapperClassName,
312
- itemSelectedClassName = props.itemSelectedClassName,
313
- disabled = props.disabled,
314
- required = props.required,
315
- value = props.value,
316
- label = props.label,
317
- name = props.name,
318
- id = props.id,
319
- checked = props.checked,
320
- indeterminate = props.indeterminate,
321
- style = props.style,
322
- tabIndex = props.tabIndex,
323
- onChange = props.onChange,
324
- onBlur = props.onBlur,
325
- onFocus = props.onFocus,
326
- attributes = _objectWithoutProperties(props, _excluded);
327
- var uniqueID = (0, react__WEBPACK_IMPORTED_MODULE_0__.useId)();
328
- var idRes = id || uniqueID;
329
- var rootRef = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
330
- var valRef = (0, react__WEBPACK_IMPORTED_MODULE_0__.useRef)(null);
331
- var _useState = (0, react__WEBPACK_IMPORTED_MODULE_0__.useState)( false || false),
332
- _useState2 = _slicedToArray(_useState, 2),
333
- val = _useState2[0],
334
- setVal = _useState2[1]; // Avoid the error "react checkbox changing an uncontrolled input to be controlled"
335
-
336
- function handleFocus(event) {
337
- var _rootRef$current;
338
- (_rootRef$current = rootRef.current) === null || _rootRef$current === void 0 ? void 0 : _rootRef$current.classList.add('focus');
339
-
340
- //
341
- onFocus === null || onFocus === void 0 ? void 0 : onFocus(event);
342
- }
343
- function handleChange(event) {
344
- var _rootRef$current2;
345
- var _val = event.target.checked;
346
- setVal(_val);
347
-
348
- //----
349
- //remove focus style
350
- (_rootRef$current2 = rootRef.current) === null || _rootRef$current2 === void 0 ? void 0 : _rootRef$current2.classList.remove('focus');
351
-
352
- //
353
- if (typeof onChange === 'function') {
354
- onChange(event, _val);
355
- }
356
- }
357
- function handleBlur(event) {
358
- var _rootRef$current3;
359
- //----
360
- //remove focus style
361
- (_rootRef$current3 = rootRef.current) === null || _rootRef$current3 === void 0 ? void 0 : _rootRef$current3.classList.remove('focus');
362
-
363
- //
364
- onBlur === null || onBlur === void 0 ? void 0 : onBlur(event);
365
- }
366
- (0, react__WEBPACK_IMPORTED_MODULE_0__.useEffect)(function () {
367
- // default value
368
- setVal(checked);
369
-
370
- // Set a checkbox to indeterminate state
371
- if (typeof indeterminate !== 'undefined') {
372
- valRef.current.indeterminate = indeterminate;
373
- }
374
- }, [checked, indeterminate]);
375
- return /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
376
- className: "".concat(wrapperClassName || wrapperClassName === '' ? wrapperClassName : "mb-3 position-relative", " ").concat(val ? itemSelectedClassName || 'item-selected' : ''),
377
- ref: rootRef
378
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("div", {
379
- className: "form-check"
380
- }, /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
381
- ref: function ref(node) {
382
- valRef.current = node;
383
- if (typeof _ref === 'function') {
384
- _ref(node);
385
- } else if (_ref) {
386
- _ref.current = node;
387
- }
388
- },
389
- tabIndex: tabIndex || 0,
390
- type: "checkbox",
391
- className: "form-check-input",
392
- id: "label-".concat(idRes)
393
-
394
- // Don't use "name", it's just a container to display the label
395
- ,
396
-
397
- "data-name": name !== null && name !== void 0 && name.match(/(\[.*?\])/gi) ? "".concat(name.split('[')[0], "-label[]") : "".concat(name, "-label"),
398
- "data-checkbox": true,
399
- "data-checked": val,
400
- disabled: disabled || null,
401
- required: required || null,
402
- onChange: handleChange,
403
- onFocus: handleFocus,
404
- onBlur: handleBlur,
405
- defaultValue: value || '',
406
- checked: val // component status will not change if defaultChecked is used
407
- ,
408
-
409
- style: _objectSpread({
410
- cursor: 'pointer'
411
- }, style)
412
- }, attributes)), /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("input", _extends({
413
- type: "hidden",
414
- id: idRes,
415
- name: name,
416
- value: val ? value || '' : '' // do not use `defaultValue`
417
- }, attributes)), label ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement(react__WEBPACK_IMPORTED_MODULE_0___default().Fragment, null, typeof label === 'string' ? /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
418
- htmlFor: "label-".concat(idRes),
419
- className: "form-check-label",
420
- dangerouslySetInnerHTML: {
421
- __html: "".concat(label)
422
- }
423
- }) : /*#__PURE__*/react__WEBPACK_IMPORTED_MODULE_0___default().createElement("label", {
424
- htmlFor: "label-".concat(idRes),
425
- className: "form-check-label"
426
- }, label)) : null)));
427
- });
428
- /* harmony default export */
429
- var __WEBPACK_DEFAULT_EXPORT__ = Checkbox;
430
- })();
431
-
432
- /******/
433
- return __webpack_exports__;
434
- /******/
435
- }()
436
- );
437
- });
438
-
439
- /***/ }),
440
-
441
14
  /***/ 426:
442
15
  /***/ ((module) => {
443
16
 
@@ -567,16 +140,13 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
567
140
  /******/ }
568
141
  /******/ // Create a new module (and put it into the cache)
569
142
  /******/ var module = __webpack_module_cache__[moduleId] = {
570
- /******/ id: moduleId,
571
- /******/ loaded: false,
143
+ /******/ // no module.id needed
144
+ /******/ // no module.loaded needed
572
145
  /******/ exports: {}
573
146
  /******/ };
574
147
  /******/
575
148
  /******/ // Execute the module function
576
- /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
577
- /******/
578
- /******/ // Flag the module as loaded
579
- /******/ module.loaded = true;
149
+ /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
580
150
  /******/
581
151
  /******/ // Return the exports of the module
582
152
  /******/ return module.exports;
@@ -623,15 +193,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__787__;
623
193
  /******/ };
624
194
  /******/ })();
625
195
  /******/
626
- /******/ /* webpack/runtime/node module decorator */
627
- /******/ (() => {
628
- /******/ __webpack_require__.nmd = (module) => {
629
- /******/ module.paths = [];
630
- /******/ if (!module.children) module.children = [];
631
- /******/ return module;
632
- /******/ };
633
- /******/ })();
634
- /******/
635
196
  /************************************************************************/
636
197
  var __webpack_exports__ = {};
637
198
  // This entry need to be wrapped in an IIFE because it need to be in strict mode.
@@ -648,9 +209,6 @@ __webpack_require__.d(__webpack_exports__, {
648
209
  // EXTERNAL MODULE: external {"root":"React","commonjs2":"react","commonjs":"react","amd":"react"}
649
210
  var external_root_React_commonjs2_react_commonjs_react_amd_react_ = __webpack_require__(787);
650
211
  var external_root_React_commonjs2_react_commonjs_react_amd_react_default = /*#__PURE__*/__webpack_require__.n(external_root_React_commonjs2_react_commonjs_react_amd_react_);
651
- // EXTERNAL MODULE: ../Checkbox/dist/cjs/index.js
652
- var cjs = __webpack_require__(109);
653
- var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
654
212
  // EXTERNAL MODULE: ./src/utils/dom.js
655
213
  var dom = __webpack_require__(426);
656
214
  ;// CONCATENATED MODULE: ./src/init-height.tsx
@@ -692,6 +250,57 @@ var initAsyncItems = /*#__PURE__*/function () {
692
250
  };
693
251
  }();
694
252
 
253
+ ;// CONCATENATED MODULE: ./src/tree-utils.ts
254
+ function tree_utils_typeof(obj) { "@babel/helpers - typeof"; return tree_utils_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; }, tree_utils_typeof(obj); }
255
+ var removeItemOnce = function removeItemOnce(arr, key) {
256
+ return arr.filter(function (item) {
257
+ return item.key !== key;
258
+ });
259
+ };
260
+ var activeClass = function activeClass(el, mode) {
261
+ var classname = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'active';
262
+ if (mode === 'add') {
263
+ el.classList.add(classname);
264
+ } else {
265
+ el.classList.remove(classname);
266
+ }
267
+ };
268
+ var deepClone = function deepClone(obj) {
269
+ if (Array.isArray(obj)) {
270
+ return obj.map(function (item) {
271
+ return deepClone(item);
272
+ });
273
+ } else if (tree_utils_typeof(obj) === 'object' && obj !== null) {
274
+ var clone = {};
275
+ for (var key in obj) {
276
+ if (obj.hasOwnProperty(key)) {
277
+ clone[key] = deepClone(obj[key]);
278
+ }
279
+ }
280
+ return clone;
281
+ } else {
282
+ return obj;
283
+ }
284
+ };
285
+ var flatOriginalData = function flatOriginalData(data) {
286
+ var result = [];
287
+ var iterate = function iterate(obj) {
288
+ if (!obj) {
289
+ return;
290
+ }
291
+ obj.forEach(function (item) {
292
+ result.push(item);
293
+ if (item.children) {
294
+ iterate(item.children);
295
+ }
296
+
297
+ // delete current item children
298
+ delete item.children;
299
+ });
300
+ };
301
+ iterate(data);
302
+ return result;
303
+ };
695
304
  ;// CONCATENATED MODULE: ./src/TreeList.tsx
696
305
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
697
306
  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."); }
@@ -701,6 +310,9 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
701
310
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
702
311
 
703
312
 
313
+ // HAS CHECKBOX
314
+
315
+
704
316
 
705
317
 
706
318
  function TreeList(props) {
@@ -765,11 +377,6 @@ function TreeList(props) {
765
377
  fill: "currentColor",
766
378
  d: "M437.026,134.798c16.52-16.52,16.52-43.304,0-59.824c-16.519-16.511-43.304-16.52-59.823,0c-16.52,16.52-16.503,43.295,0,59.815C393.722,151.309,420.507,151.309,437.026,134.798z"
767
379
  }))));
768
- var removeItemOnce = function removeItemOnce(arr, key) {
769
- return arr.filter(function (item) {
770
- return item.key !== key;
771
- });
772
- };
773
380
  var formatCheckboxControlVal = function formatCheckboxControlVal(el) {
774
381
  var _el$dataset$name;
775
382
  return {
@@ -801,7 +408,7 @@ function TreeList(props) {
801
408
  //---
802
409
  _parentsLi.forEach(function (node) {
803
410
  var _checkboxes = (0,dom.getChildren)(node, '[type="checkbox"]');
804
- var parentKey = _checkboxes[0].dataset.key;
411
+ var parentKey = typeof _checkboxes[0] === 'undefined' ? '' : _checkboxes[0].dataset.key;
805
412
 
806
413
  //
807
414
  var _checkedLengthCalcArr = [];
@@ -835,14 +442,6 @@ function TreeList(props) {
835
442
  });
836
443
  return [checkedData, printData];
837
444
  };
838
- var activeClass = function activeClass(el, mode) {
839
- var classname = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'active';
840
- if (mode === 'add') {
841
- el.classList.add(classname);
842
- } else {
843
- el.classList.remove(classname);
844
- }
845
- };
846
445
  var closeChild = function closeChild(hyperlink, ul) {
847
446
  if (ul.length === 0) return;
848
447
  activeClass(hyperlink, 'remove');
@@ -949,6 +548,74 @@ function TreeList(props) {
949
548
  return arrow ? arrow : /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((external_root_React_commonjs2_react_commonjs_react_amd_react_default()).Fragment, null, customIcon, loadingIcon);
950
549
  }
951
550
  }
551
+ function checkedAct(el, val) {
552
+ if (el === null) return;
553
+ var _curKey = el.dataset.key;
554
+ var _checkedData = getCheckedData;
555
+ var _res = getCheckedPrint;
556
+
557
+ // STEP 1:
558
+ // Current checkbox
559
+ //-----------
560
+ if (val === true) {
561
+ _res.push(formatCheckboxControlVal(el));
562
+ setCheckboxIndeterminateData(_checkedData, _curKey, false);
563
+ setCheckboxCheckedData(_checkedData, _curKey, true);
564
+ } else {
565
+ setCheckboxCheckedData(_checkedData, _curKey, false);
566
+ _res = removeItemOnce(_res, _curKey);
567
+ }
568
+
569
+ // STEP 2:
570
+ // All child checkboxes
571
+ //-----------
572
+ [].slice.call((0,dom.getChildren)(el.closest('li'), '[type="checkbox"]')).forEach(function (node) {
573
+ if (val === true) {
574
+ if (node.dataset.key !== _curKey) {
575
+ setCheckboxIndeterminateData(_checkedData, node.dataset.key, false);
576
+ setCheckboxCheckedData(_checkedData, node.dataset.key, true);
577
+ _res.push(formatCheckboxControlVal(node));
578
+ }
579
+ } else {
580
+ setCheckboxCheckedData(_checkedData, node.dataset.key, false);
581
+ _res = removeItemOnce(_res, node.dataset.key);
582
+ }
583
+ });
584
+
585
+ // STEP 3:
586
+ // ALl parent checkboxes
587
+ //-----------
588
+ var _setCheckboxIndetermi = setCheckboxIndeterminateStatus(_checkedData, _res, el),
589
+ _setCheckboxIndetermi2 = _slicedToArray(_setCheckboxIndetermi, 2),
590
+ updatedCheckedData = _setCheckboxIndetermi2[0],
591
+ updatedPrintData = _setCheckboxIndetermi2[1];
592
+ var _updatedCheckedData = updatedCheckedData;
593
+ var _updatedPrintData = updatedPrintData;
594
+
595
+ // STEP 4:
596
+ // Update checked data
597
+ //-----------
598
+ updategetCheckedData(_updatedCheckedData);
599
+
600
+ // STEP 5:
601
+ // Array deduplication
602
+ //-----------
603
+ _updatedPrintData = _updatedPrintData.filter(function (item, index, self) {
604
+ return index === self.findIndex(function (t) {
605
+ return t.key === item.key;
606
+ });
607
+ });
608
+
609
+ // STEP 6:
610
+ // Update checked print
611
+ //-----------
612
+ updateCheckedPrint(_updatedPrintData);
613
+
614
+ // STEP 7:
615
+ // callback
616
+ //-----------
617
+ onCheck === null || onCheck === void 0 ? void 0 : onCheck(_updatedPrintData);
618
+ }
952
619
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
953
620
  // Activate current item
954
621
  //=====================
@@ -1032,89 +699,33 @@ function TreeList(props) {
1032
699
  "data-key": item.key
1033
700
  }, arrowGenerator()) : '', /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("span", {
1034
701
  className: "checkbox-trigger"
1035
- }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement((cjs_default()), {
1036
- wrapperClassName: "",
702
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
703
+ className: "form-check__wrapper"
704
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("div", {
705
+ className: "form-check d-inline-block"
706
+ }, /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("input", {
707
+ type: "checkbox",
708
+ className: "form-check-input ".concat((_filter$ = getCheckedData.filter(function (cur) {
709
+ return cur.key === item.key;
710
+ })[0]) !== null && _filter$ !== void 0 && _filter$.indeterminate ? 'indeterminate' : ''),
1037
711
  name: "checkbox-".concat(checkboxNamePrefix, "-").concat(item.key),
1038
712
  tabIndex: -1,
713
+ "data-name": "checkbox-".concat(checkboxNamePrefix, "-").concat(item.key),
1039
714
  "data-key": item.key,
1040
715
  "data-link": item.link,
1041
716
  value: item.slug,
1042
- indeterminate: (_filter$ = getCheckedData.filter(function (cur) {
1043
- return cur.key === item.key;
1044
- })[0]) === null || _filter$ === void 0 ? void 0 : _filter$.indeterminate,
1045
717
  checked: (_filter$2 = getCheckedData.filter(function (cur) {
1046
718
  return cur.key === item.key;
1047
719
  })[0]) === null || _filter$2 === void 0 ? void 0 : _filter$2.checked,
1048
- onChange: function onChange(e, val) {
1049
- var _curKey = e.target.dataset.key;
1050
- var _checkedData = getCheckedData;
1051
- var _res = getCheckedPrint;
1052
-
1053
- // STEP 1:
1054
- // Current checkbox
1055
- //-----------
1056
- if (val === true) {
1057
- _res.push(formatCheckboxControlVal(e.target));
1058
- setCheckboxIndeterminateData(_checkedData, _curKey, false);
1059
- setCheckboxCheckedData(_checkedData, _curKey, true);
1060
- } else {
1061
- setCheckboxCheckedData(_checkedData, _curKey, false);
1062
- _res = removeItemOnce(_res, _curKey);
1063
- }
1064
-
1065
- // STEP 2:
1066
- // All child checkboxes
1067
- //-----------
1068
- [].slice.call((0,dom.getChildren)(e.target.closest('li'), '[type="checkbox"]')).forEach(function (node) {
1069
- if (val === true) {
1070
- if (node.dataset.key !== _curKey) {
1071
- setCheckboxIndeterminateData(_checkedData, node.dataset.key, false);
1072
- setCheckboxCheckedData(_checkedData, node.dataset.key, true);
1073
- _res.push(formatCheckboxControlVal(node));
1074
- }
1075
- } else {
1076
- setCheckboxCheckedData(_checkedData, node.dataset.key, false);
1077
- _res = removeItemOnce(_res, node.dataset.key);
1078
- }
1079
- });
1080
-
1081
- // STEP 3:
1082
- // ALl parent checkboxes
1083
- //-----------
1084
- var _setCheckboxIndetermi = setCheckboxIndeterminateStatus(_checkedData, _res, e.target),
1085
- _setCheckboxIndetermi2 = _slicedToArray(_setCheckboxIndetermi, 2),
1086
- updatedCheckedData = _setCheckboxIndetermi2[0],
1087
- updatedPrintData = _setCheckboxIndetermi2[1];
1088
- var _updatedCheckedData = updatedCheckedData;
1089
- var _updatedPrintData = updatedPrintData;
1090
-
1091
- // STEP 4:
1092
- // Update checked data
1093
- //-----------
1094
- updategetCheckedData(_updatedCheckedData);
1095
-
1096
- // STEP 5:
1097
- // Array deduplication
1098
- //-----------
1099
- _updatedPrintData = _updatedPrintData.filter(function (item, index, self) {
1100
- return index === self.findIndex(function (t) {
1101
- return t.key === item.key;
1102
- });
1103
- });
1104
-
1105
- // STEP 6:
1106
- // Update checked print
1107
- //-----------
1108
- updateCheckedPrint(_updatedPrintData);
1109
-
1110
- // STEP 7:
1111
- // callback
1112
- //-----------
1113
- onCheck === null || onCheck === void 0 ? void 0 : onCheck(_updatedPrintData);
720
+ onChange: function onChange(e) {
721
+ var _filter$3;
722
+ checkedAct(e.target, !((_filter$3 = getCheckedData.filter(function (cur) {
723
+ return cur.key === item.key;
724
+ })[0]) !== null && _filter$3 !== void 0 && _filter$3.checked));
1114
725
  }
1115
- })), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
726
+ })))), /*#__PURE__*/external_root_React_commonjs2_react_commonjs_react_amd_react_default().createElement("a", {
1116
727
  tabIndex: -1,
1117
- className: item.active ? "nav-link active ".concat(_async, " ").concat(item.selected ? 'selected' : '') : "nav-link ".concat(_async, " ").concat(item.selected ? 'selected' : ''),
728
+ className: "nav-link ".concat(_async, " ").concat(item.selected ? 'selected' : '', " ").concat(item.active ? 'active' : ''),
1118
729
  href: item.link === '#' ? "".concat(item.link, "-").concat(i) : item.link,
1119
730
  "aria-expanded": "false",
1120
731
  onClick: handleSelect,
@@ -1183,6 +794,7 @@ function src_arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1183
794
 
1184
795
 
1185
796
 
797
+
1186
798
  var Tree = function Tree(props) {
1187
799
  var id = props.id,
1188
800
  checkable = props.checkable,
@@ -1196,6 +808,7 @@ var Tree = function Tree(props) {
1196
808
  treeClassName = props.treeClassName,
1197
809
  childClassName = props.childClassName,
1198
810
  data = props.data,
811
+ retrieveData = props.retrieveData,
1199
812
  onSelect = props.onSelect,
1200
813
  onCollapse = props.onCollapse,
1201
814
  onCheck = props.onCheck;
@@ -1204,16 +817,20 @@ var Tree = function Tree(props) {
1204
817
  var rootRef = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useRef)(null);
1205
818
  var _useState = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)(null),
1206
819
  _useState2 = src_slicedToArray(_useState, 2),
1207
- val = _useState2[0],
1208
- setVal = _useState2[1];
820
+ list = _useState2[0],
821
+ setList = _useState2[1];
1209
822
  var _useState3 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
1210
823
  _useState4 = src_slicedToArray(_useState3, 2),
1211
- checkedPrint = _useState4[0],
1212
- setCheckedPrint = _useState4[1];
824
+ flatList = _useState4[0],
825
+ setFlatList = _useState4[1];
1213
826
  var _useState5 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
1214
827
  _useState6 = src_slicedToArray(_useState5, 2),
1215
- checkedData = _useState6[0],
1216
- setCheckedData = _useState6[1];
828
+ checkedPrint = _useState6[0],
829
+ setCheckedPrint = _useState6[1];
830
+ var _useState7 = (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useState)([]),
831
+ _useState8 = src_slicedToArray(_useState7, 2),
832
+ checkedData = _useState8[0],
833
+ setCheckedData = _useState8[1];
1217
834
  var expandClassName = "".concat(showLine ? 'show-line' : '', " ").concat(disableArrow ? 'hide-arrow' : '', " ").concat(disableCollapse ? 'collapse-disabled' : '', " ").concat(lineStyle ? "line--".concat(lineStyle) : '', " ").concat(checkable ? 'has-checkbox' : '');
1218
835
  var updateTreeData = function updateTreeData(list, key, children) {
1219
836
  return list ? list.map(function (node) {
@@ -1278,6 +895,33 @@ var Tree = function Tree(props) {
1278
895
  }));
1279
896
  return _fetchData.apply(this, arguments);
1280
897
  }
898
+ function updateShowProp(obj, retrieveData) {
899
+ var val = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
900
+ obj.forEach(function (item, index) {
901
+ if (retrieveData.length === 0) {
902
+ item.show = true;
903
+ } else {
904
+ if (typeof val !== 'undefined') {
905
+ item.show = val;
906
+ } else {
907
+ var _item$title;
908
+ if (retrieveData.map(function (v) {
909
+ var _v$title;
910
+ return (_v$title = v.title) === null || _v$title === void 0 ? void 0 : _v$title.toLowerCase();
911
+ }).includes((_item$title = item.title) === null || _item$title === void 0 ? void 0 : _item$title.toLowerCase())) {
912
+ item.show = true;
913
+ } else {
914
+ item.show = false;
915
+ }
916
+ }
917
+ }
918
+
919
+ //
920
+ if (item.children) {
921
+ updateShowProp(item.children, retrieveData, val);
922
+ }
923
+ });
924
+ }
1281
925
  function addKey(obj, depth, init) {
1282
926
  obj.forEach(function (item, index) {
1283
927
  item.key = "".concat(depth, "-").concat(index).substring(1);
@@ -1307,6 +951,7 @@ var Tree = function Tree(props) {
1307
951
  return [{
1308
952
  key: item.key,
1309
953
  checked: item.checked === true,
954
+ show: true,
1310
955
  indeterminate: false
1311
956
  }].concat(_toConsumableArray(prevState));
1312
957
  });
@@ -1318,15 +963,29 @@ var Tree = function Tree(props) {
1318
963
  function initDefaultValue(key) {
1319
964
  var fetch = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1320
965
  var firstRender = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
966
+ var retrieveData = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
1321
967
  if (firstRender) {
1322
968
  addKey(data, '', 0);
1323
- setVal(data);
969
+
970
+ // filter showing items
971
+ if (Array.isArray(retrieveData)) {
972
+ updateShowProp(data, retrieveData);
973
+ } else {
974
+ updateShowProp(data, retrieveData, true);
975
+ }
1324
976
 
1325
977
  // Initialize default value of checkboxes
1326
978
  if (checkable) {
1327
979
  initCheckboxesVal(data);
1328
980
  initCheckboxesData(data);
1329
981
  }
982
+
983
+ // update list
984
+ setList(data);
985
+
986
+ // update retrive list
987
+ var _clone = deepClone(data);
988
+ setFlatList(flatOriginalData(_clone));
1330
989
  return;
1331
990
  }
1332
991
  if (fetch && src_typeof(fetch.fetchFuncAsync) === 'object') {
@@ -1336,11 +995,17 @@ var Tree = function Tree(props) {
1336
995
  var _childrenData = response;
1337
996
  if (_childrenData.length > 0) {
1338
997
  // add children to node
1339
- var _newData = updateTreeData(val, key ? key : '', _childrenData);
998
+ var _newData = updateTreeData(list, key ? key : '', _childrenData);
1340
999
 
1341
1000
  // update data
1342
1001
  addKey(_newData, '', 0);
1343
- setVal(_newData);
1002
+
1003
+ // filter showing items
1004
+ if (Array.isArray(retrieveData)) {
1005
+ updateShowProp(_newData, retrieveData);
1006
+ } else {
1007
+ updateShowProp(_newData, retrieveData, true);
1008
+ }
1344
1009
 
1345
1010
  // Initialize default value of checkboxes
1346
1011
  if (checkable) {
@@ -1349,11 +1014,19 @@ var Tree = function Tree(props) {
1349
1014
  return [{
1350
1015
  key: newitem.key,
1351
1016
  checked: newitem.checked === true,
1017
+ show: true,
1352
1018
  indeterminate: false
1353
1019
  }].concat(_toConsumableArray(prevState));
1354
1020
  });
1355
1021
  });
1356
1022
  }
1023
+
1024
+ // update list
1025
+ setList(_newData);
1026
+
1027
+ // update retrive list
1028
+ var _clone2 = deepClone(_newData);
1029
+ setFlatList(flatOriginalData(_clone2));
1357
1030
  }
1358
1031
 
1359
1032
  // loading status
@@ -1376,9 +1049,18 @@ var Tree = function Tree(props) {
1376
1049
  });
1377
1050
  }
1378
1051
  }
1052
+ function filterRetriveData(flatData, retrieveData) {
1053
+ return flatData.filter(function (item) {
1054
+ var _item$title2;
1055
+ return retrieveData.map(function (v) {
1056
+ var _v$title2;
1057
+ return (_v$title2 = v.title) === null || _v$title2 === void 0 ? void 0 : _v$title2.toLowerCase();
1058
+ }).includes((_item$title2 = item.title) === null || _item$title2 === void 0 ? void 0 : _item$title2.toLowerCase());
1059
+ });
1060
+ }
1379
1061
  (0,external_root_React_commonjs2_react_commonjs_react_amd_react_.useEffect)(function () {
1380
- initDefaultValue(null, null, true);
1381
- }, [data]);
1062
+ initDefaultValue(null, null, true, retrieveData);
1063
+ }, [data, retrieveData]);
1382
1064
  return /*#__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("nav", {
1383
1065
  tabIndex: 0,
1384
1066
  id: idRes,
@@ -1393,7 +1075,7 @@ var Tree = function Tree(props) {
1393
1075
  disableCollapse: disableCollapse,
1394
1076
  arrow: arrow,
1395
1077
  arrowIcons: arrowIcons,
1396
- data: val,
1078
+ data: Array.isArray(retrieveData) && retrieveData.length > 0 ? filterRetriveData(flatList, retrieveData) : list,
1397
1079
  childClassName: childClassName || 'tree-diagram-default-nav',
1398
1080
  onSelect: onSelect,
1399
1081
  onCollapse: onCollapse,