@sheinx/hooks 3.6.0-beta.1 → 3.6.0-beta.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -262,7 +262,7 @@ var usePositionStyle = exports.usePositionStyle = function usePositionStyle(conf
262
262
  style: hideStyle
263
263
  };
264
264
  var rect = context.parentRect;
265
- if (scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
265
+ if (!show && scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
266
266
  var _scrollElRef$current2;
267
267
  var visibleRect = ((_scrollElRef$current2 = scrollElRef.current) === null || _scrollElRef$current2 === void 0 ? void 0 : _scrollElRef$current2.getBoundingClientRect()) || {};
268
268
  if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom || rect.right < visibleRect.left || rect.left > visibleRect.right) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CA4bZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAYjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CAucZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -26,6 +26,7 @@ function toArray(value) {
26
26
  if (!Array.isArray(value)) return [value];
27
27
  return value;
28
28
  }
29
+ var global_tree_map = new Map();
29
30
  var MODE = exports.MODE = {
30
31
  /**
31
32
  * 返回全选数据,包含父节点和子节点
@@ -345,6 +346,15 @@ var useTree = function useTree(props) {
345
346
  return 2;
346
347
  };
347
348
  var setData = function setData(data) {
349
+ // if(data && global_tree_map.get(data)){
350
+ // context.cachedValue = global_tree_map.get(data)?.cachedValue || []
351
+ // context.pathMap = global_tree_map.get(data)?.pathMap || new Map()
352
+ // context.dataMap = global_tree_map.get(data)?.dataMap || new Map()
353
+ // context.valueMap = global_tree_map.get(data)?.valueMap || new Map()
354
+ // context.unmatchedValueMap = global_tree_map.get(data)?.unmatchedValueMap || new Map()
355
+ // return
356
+ // }
357
+
348
358
  var prevValue = context.value || [];
349
359
  context.cachedValue = [];
350
360
  context.pathMap = new Map();
@@ -356,6 +366,8 @@ var useTree = function useTree(props) {
356
366
  initData(context.data, []);
357
367
  initValue();
358
368
  setValue(prevValue);
369
+
370
+ // global_tree_map.set(data, context)
359
371
  };
360
372
  var set = function set(id, checked, direction) {
361
373
  if (!isDisabled(id)) {
@@ -5,7 +5,7 @@ declare const useTiled: <DataItem>(props: UseTiledProps<DataItem>) => {
5
5
  onFilter: ((text: string, from?: string | undefined) => void) | undefined;
6
6
  expandIcons?: undefined;
7
7
  } | {
8
- data: any[];
8
+ data: any;
9
9
  onFilter: (text: string, from?: string) => void;
10
10
  expandIcons: ((item: DataItem) => string | number | boolean | import("react").ReactFragment | JSX.Element | null | undefined)[];
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-tiled.d.ts","sourceRoot":"","sources":["use-tiled.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,QAAA,MAAM,QAAQ;;;;;;qBA4BgB,MAAM,SAAS,MAAM;;CA8ClD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"use-tiled.d.ts","sourceRoot":"","sources":["use-tiled.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,QAAA,MAAM,QAAQ;;;;;;qBAkCgB,MAAM,SAAS,MAAM;;CAyClD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _react = require("react");
8
- var _useTree3 = require("../use-tree");
8
+ var _useTree2 = require("../use-tree");
9
9
  var _tree = require("../../utils/tree");
10
10
  var _jsxRuntime = require("react/jsx-runtime");
11
11
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -19,7 +19,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
19
19
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
20
20
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
21
21
  var useTiled = function useTiled(props) {
22
- var data = props.data,
22
+ var filterData = props.data,
23
23
  keygen = props.keygen,
24
24
  _props$childrenKey = props.childrenKey,
25
25
  childrenKey = _props$childrenKey === void 0 ? 'children' : _props$childrenKey,
@@ -35,20 +35,20 @@ var useTiled = function useTiled(props) {
35
35
  _useState2 = _slicedToArray(_useState, 2),
36
36
  tileds = _useState2[0],
37
37
  setTileds = _useState2[1];
38
- var _useTree = (0, _useTree3.useTree)({
39
- data: data,
40
- childrenKey: childrenKey,
41
- keygen: keygen,
42
- isControlled: false
43
- }),
44
- datum = _useTree.datum;
45
- var _useTree2 = (0, _useTree3.useTree)({
38
+ var _useTree = (0, _useTree2.useTree)({
46
39
  data: rawData,
40
+ datum: props.rawDatum,
47
41
  childrenKey: childrenKey,
48
42
  keygen: keygen,
49
43
  isControlled: false
50
44
  }),
51
- rawDatum = _useTree2.datum;
45
+ rawDatum = _useTree.datum;
46
+ if (!filterText || !onAdvancedFilter) {
47
+ return {
48
+ data: filterData,
49
+ onFilter: onFilter
50
+ };
51
+ }
52
52
  var handleToggle = function handleToggle(e, key) {
53
53
  e.stopPropagation();
54
54
  var nextTileds = _toConsumableArray(tileds);
@@ -80,13 +80,7 @@ var useTiled = function useTiled(props) {
80
80
  children: moreIcon()
81
81
  });
82
82
  };
83
- if (!filterText || !onAdvancedFilter) {
84
- return {
85
- data: data,
86
- onFilter: onFilter
87
- };
88
- }
89
- var nextData = (0, _tree.mergeFilteredTree)(datum, rawDatum, tileds);
83
+ var nextData = (0, _tree.mergeFilteredTree)(filterData, rawDatum, tileds);
90
84
  return {
91
85
  data: nextData,
92
86
  onFilter: handleFilter,
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import { TreeKeygenType, KeygenResult, ObjectKey } from '../../common/type';
3
+ import { TreeDatum } from '../use-tree/use-tree.type';
3
4
  export type FilterFormType = 'blur' | 'edit';
4
5
  export interface UseTiledProps<DataItem> {
5
6
  data: DataItem[];
6
7
  rawData: DataItem[];
8
+ rawDatum?: TreeDatum<DataItem>;
7
9
  onFilter?: (text: string, from?: string) => void;
8
10
  keygen: TreeKeygenType<DataItem>;
9
11
  childrenKey?: ObjectKey<DataItem>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-tiled.type.d.ts","sourceR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AE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC/B,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,cAAc,CAAC,QAAQ,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAClC,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IAC5B,QAAQ,EAAE,MAAM,KAAK,CAAC,SAAS,CAAC;IAChC,gBAAgB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;CAClE"}
@@ -9,6 +9,6 @@ type FilterDatum<DataItem> = {
9
9
  getKey: (node: DataItem) => KeygenResult;
10
10
  getDataById: (id: KeygenResult) => DataItem;
11
11
  };
12
- export declare const mergeFilteredTree: (filterDatum: FilterDatum<any>, rawDatum: FilterDatum<any>, tiledId: KeygenResult[]) => any[];
12
+ export declare const mergeFilteredTree: (filterData: any, rawDatum: FilterDatum<any>, tiledId: KeygenResult[]) => any;
13
13
  export {};
14
14
  //# sourceMappingURL=tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,cAAc,+CAGlB,OAAO,UAkBf,CAAC;AAEF,eAAO,MAAM,aAAa,2CAA4C,YAAY,6EAE5B,OAAO,iCACzC,YAAY,EAAE,GAAG,SAAS,2EAGxB,OAAO,wCACU,IAAI;;yBA4B1C,CAAC;AAEF,KAAK,WAAW,CAAC,QAAQ,IAAI;IAC3B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,YAAY,CAAC;IACzC,WAAW,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,QAAQ,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBACf,YAAY,GAAG,CAAC,YACnB,YAAY,GAAG,CAAC,WACjB,YAAY,EAAE,UAqBxB,CAAC"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,cAAc,+CAGlB,OAAO,UAkBf,CAAC;AAEF,eAAO,MAAM,aAAa,2CAA4C,YAAY,6EAE5B,OAAO,iCACzC,YAAY,EAAE,GAAG,SAAS,2EAGxB,OAAO,wCACU,IAAI;;yBA4B1C,CAAC;AAEF,KAAK,WAAW,CAAC,QAAQ,IAAI;IAC3B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,YAAY,CAAC;IACzC,WAAW,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,QAAQ,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAChB,GAAG,YACL,YAAY,GAAG,CAAC,WACjB,YAAY,EAAE,QAexB,CAAC"}
package/cjs/utils/tree.js CHANGED
@@ -68,19 +68,13 @@ var getFilterTree = exports.getFilterTree = function getFilterTree(treeNodes, fi
68
68
  return node;
69
69
  });
70
70
  };
71
- var mergeFilteredTree = exports.mergeFilteredTree = function mergeFilteredTree(filterDatum, rawDatum, tiledId) {
72
- var filterData = filterDatum.data;
73
- var childrenKey = filterDatum.childrenKey;
71
+ var mergeFilteredTree = exports.mergeFilteredTree = function mergeFilteredTree(filterData, rawDatum, tiledId) {
72
+ var childrenKey = rawDatum.childrenKey;
74
73
  if (tiledId.length === 0) return filterData;
75
74
  var recursion = function recursion(node) {
76
- var nodeKey = filterDatum.getKey(node);
75
+ var nodeKey = rawDatum.getKey(node);
77
76
  if (tiledId.indexOf(nodeKey) >= 0) {
78
77
  node[childrenKey] = (0, _clone.deepClone)(rawDatum.getDataById(nodeKey)[childrenKey] || []);
79
- } else {
80
- var item = filterDatum.getDataById(nodeKey);
81
- if (item && item[childrenKey]) {
82
- node[childrenKey] = (0, _clone.deepClone)(item[childrenKey] || []);
83
- }
84
78
  }
85
79
  var children = node[childrenKey] || [];
86
80
  children.map(recursion);
@@ -253,7 +253,7 @@ export var usePositionStyle = function usePositionStyle(config) {
253
253
  style: hideStyle
254
254
  };
255
255
  var rect = context.parentRect;
256
- if (scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
256
+ if (!show && scrollElRef !== null && scrollElRef !== void 0 && scrollElRef.current && (_scrollElRef$current = scrollElRef.current) !== null && _scrollElRef$current !== void 0 && _scrollElRef$current.contains(parentElRef.current)) {
257
257
  var _scrollElRef$current2;
258
258
  var visibleRect = ((_scrollElRef$current2 = scrollElRef.current) === null || _scrollElRef$current2 === void 0 ? void 0 : _scrollElRef$current2.getBoundingClientRect()) || {};
259
259
  if (rect.bottom < visibleRect.top || rect.top > visibleRect.bottom || rect.right < visibleRect.left || rect.left > visibleRect.right) {
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAUjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CA4bZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAYjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CAucZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -19,6 +19,7 @@ function toArray(value) {
19
19
  if (!Array.isArray(value)) return [value];
20
20
  return value;
21
21
  }
22
+ var global_tree_map = new Map();
22
23
  export var MODE = {
23
24
  /**
24
25
  * 返回全选数据,包含父节点和子节点
@@ -338,6 +339,15 @@ var useTree = function useTree(props) {
338
339
  return 2;
339
340
  };
340
341
  var setData = function setData(data) {
342
+ // if(data && global_tree_map.get(data)){
343
+ // context.cachedValue = global_tree_map.get(data)?.cachedValue || []
344
+ // context.pathMap = global_tree_map.get(data)?.pathMap || new Map()
345
+ // context.dataMap = global_tree_map.get(data)?.dataMap || new Map()
346
+ // context.valueMap = global_tree_map.get(data)?.valueMap || new Map()
347
+ // context.unmatchedValueMap = global_tree_map.get(data)?.unmatchedValueMap || new Map()
348
+ // return
349
+ // }
350
+
341
351
  var prevValue = context.value || [];
342
352
  context.cachedValue = [];
343
353
  context.pathMap = new Map();
@@ -349,6 +359,8 @@ var useTree = function useTree(props) {
349
359
  initData(context.data, []);
350
360
  initValue();
351
361
  setValue(prevValue);
362
+
363
+ // global_tree_map.set(data, context)
352
364
  };
353
365
  var set = function set(id, checked, direction) {
354
366
  if (!isDisabled(id)) {
@@ -5,7 +5,7 @@ declare const useTiled: <DataItem>(props: UseTiledProps<DataItem>) => {
5
5
  onFilter: ((text: string, from?: string | undefined) => void) | undefined;
6
6
  expandIcons?: undefined;
7
7
  } | {
8
- data: any[];
8
+ data: any;
9
9
  onFilter: (text: string, from?: string) => void;
10
10
  expandIcons: ((item: DataItem) => string | number | boolean | import("react").ReactFragment | JSX.Element | null | undefined)[];
11
11
  };
@@ -1 +1 @@
1
- {"version":3,"file":"use-tiled.d.ts","sourceRoot":"","sources":["use-tiled.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,QAAA,MAAM,QAAQ;;;;;;qBA4BgB,MAAM,SAAS,MAAM;;CA8ClD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"use-tiled.d.ts","sourceRoot":"","sources":["use-tiled.tsx"],"names":[],"mappings":";AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGjD,QAAA,MAAM,QAAQ;;;;;;qBAkCgB,MAAM,SAAS,MAAM;;CAyClD,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -13,7 +13,7 @@ import { useTree } from "../use-tree";
13
13
  import { mergeFilteredTree } from "../../utils/tree";
14
14
  import { jsx as _jsx } from "react/jsx-runtime";
15
15
  var useTiled = function useTiled(props) {
16
- var data = props.data,
16
+ var filterData = props.data,
17
17
  keygen = props.keygen,
18
18
  _props$childrenKey = props.childrenKey,
19
19
  childrenKey = _props$childrenKey === void 0 ? 'children' : _props$childrenKey,
@@ -30,19 +30,19 @@ var useTiled = function useTiled(props) {
30
30
  tileds = _useState2[0],
31
31
  setTileds = _useState2[1];
32
32
  var _useTree = useTree({
33
- data: data,
34
- childrenKey: childrenKey,
35
- keygen: keygen,
36
- isControlled: false
37
- }),
38
- datum = _useTree.datum;
39
- var _useTree2 = useTree({
40
33
  data: rawData,
34
+ datum: props.rawDatum,
41
35
  childrenKey: childrenKey,
42
36
  keygen: keygen,
43
37
  isControlled: false
44
38
  }),
45
- rawDatum = _useTree2.datum;
39
+ rawDatum = _useTree.datum;
40
+ if (!filterText || !onAdvancedFilter) {
41
+ return {
42
+ data: filterData,
43
+ onFilter: onFilter
44
+ };
45
+ }
46
46
  var handleToggle = function handleToggle(e, key) {
47
47
  e.stopPropagation();
48
48
  var nextTileds = _toConsumableArray(tileds);
@@ -74,13 +74,7 @@ var useTiled = function useTiled(props) {
74
74
  children: moreIcon()
75
75
  });
76
76
  };
77
- if (!filterText || !onAdvancedFilter) {
78
- return {
79
- data: data,
80
- onFilter: onFilter
81
- };
82
- }
83
- var nextData = mergeFilteredTree(datum, rawDatum, tileds);
77
+ var nextData = mergeFilteredTree(filterData, rawDatum, tileds);
84
78
  return {
85
79
  data: nextData,
86
80
  onFilter: handleFilter,
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import { TreeKeygenType, KeygenResult, ObjectKey } from '../../common/type';
3
+ import { TreeDatum } from '../use-tree/use-tree.type';
3
4
  export type FilterFormType = 'blur' | 'edit';
4
5
  export interface UseTiledProps<DataItem> {
5
6
  data: DataItem[];
6
7
  rawData: DataItem[];
8
+ rawDatum?: TreeDatum<DataItem>;
7
9
  onFilter?: (text: string, from?: string) => void;
8
10
  keygen: TreeKeygenType<DataItem>;
9
11
  childrenKey?: ObjectKey<DataItem>;
@@ -1 +1 @@
1
- {"version":3,"file":"use-tiled.type.d.ts","sourceRoot":"","sources":["use-tiled.type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAE5E,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,CAAC;AAE7C,MAAM,WAAW,aAAa,CAAC,QAAQ;IACrC,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,OAAO,EAAE,QAAQ,EAAE,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACjD,MAAM,EAAE,cAAc,CAAC,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AI,EAAE,MAAM,KAAK,CAAC,IAAI,EAAE,QAAQ,KAAK,OAAO,CAAC;CAClE"}
@@ -9,6 +9,6 @@ type FilterDatum<DataItem> = {
9
9
  getKey: (node: DataItem) => KeygenResult;
10
10
  getDataById: (id: KeygenResult) => DataItem;
11
11
  };
12
- export declare const mergeFilteredTree: (filterDatum: FilterDatum<any>, rawDatum: FilterDatum<any>, tiledId: KeygenResult[]) => any[];
12
+ export declare const mergeFilteredTree: (filterData: any, rawDatum: FilterDatum<any>, tiledId: KeygenResult[]) => any;
13
13
  export {};
14
14
  //# sourceMappingURL=tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,cAAc,+CAGlB,OAAO,UAkBf,CAAC;AAEF,eAAO,MAAM,aAAa,2CAA4C,YAAY,6EAE5B,OAAO,iCACzC,YAAY,EAAE,GAAG,SAAS,2EAGxB,OAAO,wCACU,IAAI;;yBA4B1C,CAAC;AAEF,KAAK,WAAW,CAAC,QAAQ,IAAI;IAC3B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,YAAY,CAAC;IACzC,WAAW,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,QAAQ,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,gBACf,YAAY,GAAG,CAAC,YACnB,YAAY,GAAG,CAAC,WACjB,YAAY,EAAE,UAqBxB,CAAC"}
1
+ {"version":3,"file":"tree.d.ts","sourceRoot":"","sources":["tree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,eAAO,MAAM,cAAc,+CAGlB,OAAO,UAkBf,CAAC;AAEF,eAAO,MAAM,aAAa,2CAA4C,YAAY,6EAE5B,OAAO,iCACzC,YAAY,EAAE,GAAG,SAAS,2EAGxB,OAAO,wCACU,IAAI;;yBA4B1C,CAAC;AAEF,KAAK,WAAW,CAAC,QAAQ,IAAI;IAC3B,IAAI,EAAE,QAAQ,EAAE,CAAC;IACjB,WAAW,EAAE,GAAG,CAAC;IACjB,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,YAAY,CAAC;IACzC,WAAW,EAAE,CAAC,EAAE,EAAE,YAAY,KAAK,QAAQ,CAAC;CAC7C,CAAC;AAEF,eAAO,MAAM,iBAAiB,eAChB,GAAG,YACL,YAAY,GAAG,CAAC,WACjB,YAAY,EAAE,QAexB,CAAC"}
package/esm/utils/tree.js CHANGED
@@ -62,19 +62,13 @@ export var getFilterTree = function getFilterTree(treeNodes, filterFunc, filterE
62
62
  return node;
63
63
  });
64
64
  };
65
- export var mergeFilteredTree = function mergeFilteredTree(filterDatum, rawDatum, tiledId) {
66
- var filterData = filterDatum.data;
67
- var childrenKey = filterDatum.childrenKey;
65
+ export var mergeFilteredTree = function mergeFilteredTree(filterData, rawDatum, tiledId) {
66
+ var childrenKey = rawDatum.childrenKey;
68
67
  if (tiledId.length === 0) return filterData;
69
68
  var recursion = function recursion(node) {
70
- var nodeKey = filterDatum.getKey(node);
69
+ var nodeKey = rawDatum.getKey(node);
71
70
  if (tiledId.indexOf(nodeKey) >= 0) {
72
71
  node[childrenKey] = deepClone(rawDatum.getDataById(nodeKey)[childrenKey] || []);
73
- } else {
74
- var item = filterDatum.getDataById(nodeKey);
75
- if (item && item[childrenKey]) {
76
- node[childrenKey] = deepClone(item[childrenKey] || []);
77
- }
78
72
  }
79
73
  var children = node[childrenKey] || [];
80
74
  children.map(recursion);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sheinx/hooks",
3
- "version": "3.6.0-beta.1",
3
+ "version": "3.6.0-beta.2",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "license": "MIT",