@sheinx/hooks 3.6.0-beta.3 → 3.6.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (173) hide show
  1. package/cjs/common/use-filter/use-filter.d.ts.map +1 -1
  2. package/cjs/common/use-pagination-list/index.d.ts.map +1 -1
  3. package/cjs/common/use-pagination-list/index.js +6 -1
  4. package/cjs/common/use-position-style/check-border.d.ts +6 -0
  5. package/cjs/common/use-position-style/check-border.d.ts.map +1 -0
  6. package/cjs/common/use-position-style/check-border.js +35 -0
  7. package/cjs/common/use-position-style/get-position-style.d.ts +1 -0
  8. package/cjs/common/use-position-style/get-position-style.d.ts.map +1 -1
  9. package/cjs/common/use-position-style/get-position-style.js +14 -8
  10. package/cjs/common/use-position-style/index.d.ts +1 -0
  11. package/cjs/common/use-position-style/index.d.ts.map +1 -1
  12. package/cjs/common/use-position-style/index.js +21 -10
  13. package/cjs/components/use-cascader/use-cascader.d.ts.map +1 -1
  14. package/cjs/components/use-cascader/use-cascader.type.d.ts +2 -1
  15. package/cjs/components/use-cascader/use-cascader.type.d.ts.map +1 -1
  16. package/cjs/components/use-check/use-check.d.ts +1 -1
  17. package/cjs/components/use-check/use-check.d.ts.map +1 -1
  18. package/cjs/components/use-check/use-check.js +10 -3
  19. package/cjs/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  20. package/cjs/components/use-datepicker/use-datepicker-format.js +4 -0
  21. package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts +1 -1
  22. package/cjs/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
  23. package/cjs/components/use-form/Provider.d.ts +1 -2
  24. package/cjs/components/use-form/Provider.d.ts.map +1 -1
  25. package/cjs/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  26. package/cjs/components/use-form/use-form-fieldset/fieldset-context.d.ts +1 -1
  27. package/cjs/components/use-form/use-form-fieldset/fieldset-context.d.ts.map +1 -1
  28. package/cjs/components/use-form/use-form-fieldset/fieldset-context.js +3 -2
  29. package/cjs/components/use-form/use-form-fieldset/index.d.ts +1 -0
  30. package/cjs/components/use-form/use-form-fieldset/index.d.ts.map +1 -1
  31. package/cjs/components/use-form/use-form-fieldset/index.js +6 -0
  32. package/cjs/components/use-form/use-form.d.ts +1 -2
  33. package/cjs/components/use-form/use-form.d.ts.map +1 -1
  34. package/cjs/components/use-form/use-form.js +19 -9
  35. package/cjs/components/use-form/use-form.type.d.ts +3 -1
  36. package/cjs/components/use-form/use-form.type.d.ts.map +1 -1
  37. package/cjs/components/use-input/use-input-format.d.ts +1 -1
  38. package/cjs/components/use-input/use-input-format.d.ts.map +1 -1
  39. package/cjs/components/use-input/use-input-format.js +12 -4
  40. package/cjs/components/use-input/use-input-number.d.ts +1 -1
  41. package/cjs/components/use-input/use-input-number.d.ts.map +1 -1
  42. package/cjs/components/use-input/use-input-number.js +1 -0
  43. package/cjs/components/use-popup/use-popup.d.ts.map +1 -1
  44. package/cjs/components/use-popup/use-popup.js +5 -0
  45. package/cjs/components/use-table/index.d.ts +2 -1
  46. package/cjs/components/use-table/index.d.ts.map +1 -1
  47. package/cjs/components/use-table/index.js +7 -0
  48. package/cjs/components/use-table/use-table-filter.d.ts +19 -0
  49. package/cjs/components/use-table/use-table-filter.d.ts.map +1 -0
  50. package/cjs/components/use-table/use-table-filter.js +96 -0
  51. package/cjs/components/use-table/use-table-tree.d.ts +13 -0
  52. package/cjs/components/use-table/use-table-tree.d.ts.map +1 -1
  53. package/cjs/components/use-table/use-table-tree.js +68 -1
  54. package/cjs/components/use-table/use-table-virtual.d.ts.map +1 -1
  55. package/cjs/components/use-table/use-table-virtual.js +6 -4
  56. package/cjs/components/use-table/use-table.type.d.ts +93 -0
  57. package/cjs/components/use-table/use-table.type.d.ts.map +1 -1
  58. package/cjs/components/use-tabs/context.d.ts +1 -1
  59. package/cjs/components/use-tabs/context.d.ts.map +1 -1
  60. package/cjs/components/use-tabs/use-tabs.d.ts +1 -1
  61. package/cjs/components/use-tree/index.d.ts +3 -2
  62. package/cjs/components/use-tree/index.d.ts.map +1 -1
  63. package/cjs/components/use-tree/index.js +18 -2
  64. package/cjs/components/use-tree/use-tree-node.d.ts.map +1 -1
  65. package/cjs/components/use-tree/use-tree-node.js +1 -5
  66. package/cjs/components/use-tree/use-tree-node.type.d.ts +18 -0
  67. package/cjs/components/use-tree/use-tree-node.type.d.ts.map +1 -1
  68. package/cjs/components/use-tree/use-tree-virtual-node.d.ts +13 -0
  69. package/cjs/components/use-tree/use-tree-virtual-node.d.ts.map +1 -0
  70. package/cjs/components/use-tree/use-tree-virtual-node.js +92 -0
  71. package/cjs/components/use-tree/use-tree.d.ts.map +1 -1
  72. package/cjs/components/use-tree/use-tree.js +236 -18
  73. package/cjs/components/use-tree/use-tree.type.d.ts +35 -1
  74. package/cjs/components/use-tree/use-tree.type.d.ts.map +1 -1
  75. package/cjs/components/use-treeselect/use-tiled.d.ts +1 -1
  76. package/cjs/utils/dom/element.d.ts +1 -1
  77. package/cjs/utils/dom/element.d.ts.map +1 -1
  78. package/cjs/utils/dom/element.js +5 -3
  79. package/cjs/utils/is.d.ts +2 -0
  80. package/cjs/utils/is.d.ts.map +1 -1
  81. package/cjs/utils/is.js +5 -2
  82. package/cjs/utils/lazyload.d.ts.map +1 -1
  83. package/cjs/utils/lazyload.js +2 -2
  84. package/cjs/utils/object.d.ts.map +1 -1
  85. package/cjs/utils/object.js +6 -1
  86. package/cjs/utils/warning.js +5 -5
  87. package/esm/common/use-filter/use-filter.d.ts.map +1 -1
  88. package/esm/common/use-pagination-list/index.d.ts.map +1 -1
  89. package/esm/common/use-pagination-list/index.js +6 -1
  90. package/esm/common/use-position-style/check-border.d.ts +6 -0
  91. package/esm/common/use-position-style/check-border.d.ts.map +1 -0
  92. package/esm/common/use-position-style/check-border.js +29 -0
  93. package/esm/common/use-position-style/get-position-style.d.ts +1 -0
  94. package/esm/common/use-position-style/get-position-style.d.ts.map +1 -1
  95. package/esm/common/use-position-style/get-position-style.js +14 -8
  96. package/esm/common/use-position-style/index.d.ts +1 -0
  97. package/esm/common/use-position-style/index.d.ts.map +1 -1
  98. package/esm/common/use-position-style/index.js +21 -10
  99. package/esm/components/use-cascader/use-cascader.d.ts.map +1 -1
  100. package/esm/components/use-cascader/use-cascader.type.d.ts +2 -1
  101. package/esm/components/use-cascader/use-cascader.type.d.ts.map +1 -1
  102. package/esm/components/use-check/use-check.d.ts +1 -1
  103. package/esm/components/use-check/use-check.d.ts.map +1 -1
  104. package/esm/components/use-check/use-check.js +10 -3
  105. package/esm/components/use-datepicker/use-datepicker-format.d.ts.map +1 -1
  106. package/esm/components/use-datepicker/use-datepicker-format.js +4 -0
  107. package/esm/components/use-datepicker/use-datepicker-format.type.d.ts +1 -1
  108. package/esm/components/use-datepicker/use-datepicker-format.type.d.ts.map +1 -1
  109. package/esm/components/use-form/Provider.d.ts +1 -2
  110. package/esm/components/use-form/Provider.d.ts.map +1 -1
  111. package/esm/components/use-form/use-form-control/use-form-control.d.ts.map +1 -1
  112. package/esm/components/use-form/use-form-fieldset/fieldset-context.d.ts +1 -1
  113. package/esm/components/use-form/use-form-fieldset/fieldset-context.d.ts.map +1 -1
  114. package/esm/components/use-form/use-form-fieldset/fieldset-context.js +2 -1
  115. package/esm/components/use-form/use-form-fieldset/index.d.ts +1 -0
  116. package/esm/components/use-form/use-form-fieldset/index.d.ts.map +1 -1
  117. package/esm/components/use-form/use-form-fieldset/index.js +2 -1
  118. package/esm/components/use-form/use-form.d.ts +1 -2
  119. package/esm/components/use-form/use-form.d.ts.map +1 -1
  120. package/esm/components/use-form/use-form.js +19 -9
  121. package/esm/components/use-form/use-form.type.d.ts +3 -1
  122. package/esm/components/use-form/use-form.type.d.ts.map +1 -1
  123. package/esm/components/use-input/use-input-format.d.ts +1 -1
  124. package/esm/components/use-input/use-input-format.d.ts.map +1 -1
  125. package/esm/components/use-input/use-input-format.js +12 -4
  126. package/esm/components/use-input/use-input-number.d.ts +1 -1
  127. package/esm/components/use-input/use-input-number.d.ts.map +1 -1
  128. package/esm/components/use-input/use-input-number.js +1 -0
  129. package/esm/components/use-popup/use-popup.d.ts.map +1 -1
  130. package/esm/components/use-popup/use-popup.js +5 -0
  131. package/esm/components/use-table/index.d.ts +2 -1
  132. package/esm/components/use-table/index.d.ts.map +1 -1
  133. package/esm/components/use-table/index.js +1 -0
  134. package/esm/components/use-table/use-table-filter.d.ts +19 -0
  135. package/esm/components/use-table/use-table-filter.d.ts.map +1 -0
  136. package/esm/components/use-table/use-table-filter.js +89 -0
  137. package/esm/components/use-table/use-table-tree.d.ts +13 -0
  138. package/esm/components/use-table/use-table-tree.d.ts.map +1 -1
  139. package/esm/components/use-table/use-table-tree.js +67 -0
  140. package/esm/components/use-table/use-table-virtual.d.ts.map +1 -1
  141. package/esm/components/use-table/use-table-virtual.js +6 -4
  142. package/esm/components/use-table/use-table.type.d.ts +93 -0
  143. package/esm/components/use-table/use-table.type.d.ts.map +1 -1
  144. package/esm/components/use-tabs/context.d.ts +1 -1
  145. package/esm/components/use-tabs/context.d.ts.map +1 -1
  146. package/esm/components/use-tabs/use-tabs.d.ts +1 -1
  147. package/esm/components/use-tree/index.d.ts +3 -2
  148. package/esm/components/use-tree/index.d.ts.map +1 -1
  149. package/esm/components/use-tree/index.js +3 -2
  150. package/esm/components/use-tree/use-tree-node.d.ts.map +1 -1
  151. package/esm/components/use-tree/use-tree-node.js +1 -5
  152. package/esm/components/use-tree/use-tree-node.type.d.ts +18 -0
  153. package/esm/components/use-tree/use-tree-node.type.d.ts.map +1 -1
  154. package/esm/components/use-tree/use-tree-virtual-node.d.ts +13 -0
  155. package/esm/components/use-tree/use-tree-virtual-node.d.ts.map +1 -0
  156. package/esm/components/use-tree/use-tree-virtual-node.js +85 -0
  157. package/esm/components/use-tree/use-tree.d.ts.map +1 -1
  158. package/esm/components/use-tree/use-tree.js +238 -20
  159. package/esm/components/use-tree/use-tree.type.d.ts +35 -1
  160. package/esm/components/use-tree/use-tree.type.d.ts.map +1 -1
  161. package/esm/components/use-treeselect/use-tiled.d.ts +1 -1
  162. package/esm/utils/dom/element.d.ts +1 -1
  163. package/esm/utils/dom/element.d.ts.map +1 -1
  164. package/esm/utils/dom/element.js +4 -2
  165. package/esm/utils/is.d.ts +2 -0
  166. package/esm/utils/is.d.ts.map +1 -1
  167. package/esm/utils/is.js +4 -1
  168. package/esm/utils/lazyload.d.ts.map +1 -1
  169. package/esm/utils/lazyload.js +3 -3
  170. package/esm/utils/object.d.ts.map +1 -1
  171. package/esm/utils/object.js +6 -1
  172. package/esm/utils/warning.js +5 -5
  173. package/package.json +1 -1
@@ -48,11 +48,7 @@ var useTreeNode = function useTreeNode(props) {
48
48
  break;
49
49
  }
50
50
  });
51
- var handleToggle = function handleToggle() {
52
- // const newExpand = !expanded;
53
- // setExpanded(newExpand);
54
- // if (onToggle) onToggle(id, newExpand);
55
- };
51
+ var handleToggle = function handleToggle() {};
56
52
  var isLeaf = function isLeaf() {
57
53
  var children = data[childrenKey];
58
54
  if (children && children.length > 0) return false;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { KeygenResult } from '../../common/type';
3
+ import { TreeDatum } from './use-tree.type';
3
4
  export type UpdateType = 'active' | 'expanded' | 'fetching';
4
5
  export type UpdateFunc = (name: string, active: boolean) => void;
5
6
  export interface NodeState {
@@ -12,8 +13,25 @@ export interface BaseTreeNodeProps<DataItem, Value> {
12
13
  data: DataItem;
13
14
  childrenKey: keyof DataItem;
14
15
  element: React.RefObject<HTMLDivElement>;
16
+ dragImageStyle?: React.CSSProperties;
15
17
  dragImageSelector: (data?: DataItem) => string | undefined;
18
+ bindNode: (id: KeygenResult, update: UpdateFunc, data: DataItem) => {
19
+ expanded: boolean;
20
+ active: boolean;
21
+ };
22
+ content: HTMLDivElement | null;
23
+ loader?: (key: KeygenResult, data: DataItem) => void;
24
+ onToggle?: (id: Value, expanded: boolean) => void;
25
+ onDrop?: (data: DataItem[], key: KeygenResult, targetKey: KeygenResult, position: number) => void;
26
+ }
27
+ export interface BaseTreeVirtualNodeProps<DataItem, Value> {
28
+ id: KeygenResult;
29
+ data: DataItem;
30
+ expanded?: boolean;
31
+ childrenKey: keyof DataItem;
32
+ element: React.RefObject<HTMLDivElement>;
16
33
  dragImageStyle?: React.CSSProperties;
34
+ datum?: TreeDatum<DataItem>;
17
35
  bindNode: (id: KeygenResult, update: UpdateFunc, data: DataItem) => {
18
36
  expanded: boolean;
19
37
  active: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"use-tree-node.type.d.ts","sourceRoot":"","sources":["use-tree-node.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,EAAE,KAAK;IAChD,EAAE,EAAE,YAAY,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,QAAQ,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,MAAM,GAAG,SAAS,CAAC;IAC3D,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,QAAQ,EAAE,CACR,EAAE,EAAE,YAAY,EAChB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,KACX;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5C,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACnG"}
1
+ {"version":3,"file":"use-tree-node.type.d.ts","sourceRoot":"","sources":["use-tree-node.type.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,UAAU,CAAC;AAE5D,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,KAAK,IAAI,CAAC;AAEjE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,OAAO,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,iBAAiB,CAAC,QAAQ,EAAE,KAAK;IAChD,EAAE,EAAE,YAAY,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,WAAW,EAAE,MAAM,QAAQ,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,iBAAiB,EAAE,CAAC,IAAI,CAAC,EAAE,QAAQ,KAAK,MAAM,GAAG,SAAS,CAAC;IAC3D,QAAQ,EAAE,CACR,EAAE,EAAE,YAAY,EAChB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,KACX;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5C,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACnG;AAED,MAAM,WAAW,wBAAwB,CAAC,QAAQ,EAAE,KAAK;IACvD,EAAE,EAAE,YAAY,CAAC;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,QAAQ,CAAC;IAC5B,OAAO,EAAE,KAAK,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACzC,cAAc,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IACrC,KAAK,CAAC,EAAE,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC5B,QAAQ,EAAE,CACR,EAAE,EAAE,YAAY,EAChB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,QAAQ,KACX;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,MAAM,EAAE,OAAO,CAAA;KAAE,CAAC;IAC5C,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,MAAM,CAAC,EAAE,CAAC,GAAG,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACrD,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAC;IAClD,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE,GAAG,EAAE,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACnG"}
@@ -0,0 +1,13 @@
1
+ import { BaseTreeVirtualNodeProps } from './use-tree-node.type';
2
+ declare const useTreeVirtualNode: <DataItem, Value>(props: BaseTreeVirtualNodeProps<DataItem, Value>) => {
3
+ update: (key: string, value: boolean) => void;
4
+ active: boolean;
5
+ expanded: boolean;
6
+ fetching: boolean;
7
+ isLeaf: () => boolean;
8
+ setFetching: (v: boolean) => void;
9
+ setExpanded: (v: boolean) => void;
10
+ onToggle: () => void;
11
+ };
12
+ export default useTreeVirtualNode;
13
+ //# sourceMappingURL=use-tree-virtual-node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-tree-virtual-node.d.ts","sourceRoot":"","sources":["use-tree-virtual-node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGhE,QAAA,MAAM,kBAAkB;kBAMY,MAAM,SAAS,OAAO;;;;;qBAoB1B,OAAO;qBASP,OAAO;;CAkCtC,CAAC;AACF,eAAe,kBAAkB,CAAC"}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _usePersistFn = _interopRequireDefault(require("../../common/use-persist-fn"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
11
+ 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."); }
12
+ 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); }
13
+ 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; }
14
+ 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; } }
15
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
16
+ var useTreeVirtualNode = function useTreeVirtualNode(props) {
17
+ var _datum$dataFlatStatus, _datum$dataFlatStatus2, _datum$dataFlatStatus3;
18
+ var id = props.id,
19
+ data = props.data,
20
+ childrenKey = props.childrenKey,
21
+ bindNode = props.bindNode,
22
+ loader = props.loader,
23
+ datum = props.datum;
24
+ var _useState = (0, _react.useState)((datum === null || datum === void 0 || (_datum$dataFlatStatus = datum.dataFlatStatusMap.get(id)) === null || _datum$dataFlatStatus === void 0 ? void 0 : _datum$dataFlatStatus.active) || false),
25
+ _useState2 = _slicedToArray(_useState, 2),
26
+ active = _useState2[0],
27
+ setActive = _useState2[1];
28
+ var _useState3 = (0, _react.useState)((datum === null || datum === void 0 || (_datum$dataFlatStatus2 = datum.dataFlatStatusMap.get(id)) === null || _datum$dataFlatStatus2 === void 0 ? void 0 : _datum$dataFlatStatus2.expanded) || false),
29
+ _useState4 = _slicedToArray(_useState3, 2),
30
+ expanded = _useState4[0],
31
+ setExpanded = _useState4[1];
32
+ var _useState5 = (0, _react.useState)((datum === null || datum === void 0 || (_datum$dataFlatStatus3 = datum.dataFlatStatusMap.get(id)) === null || _datum$dataFlatStatus3 === void 0 ? void 0 : _datum$dataFlatStatus3.fetching) || false),
33
+ _useState6 = _slicedToArray(_useState5, 2),
34
+ fetching = _useState6[0],
35
+ setFetching = _useState6[1];
36
+ var update = (0, _usePersistFn.default)(function (key, value) {
37
+ switch (key) {
38
+ case 'active':
39
+ if (value !== active) {
40
+ setActive(value);
41
+ }
42
+ break;
43
+ case 'expanded':
44
+ setExpanded(value);
45
+ break;
46
+ case 'fetching':
47
+ if (value !== fetching) {
48
+ setFetching(value);
49
+ }
50
+ break;
51
+ }
52
+ });
53
+ var handleToggle = function handleToggle() {};
54
+ var handleSetFetchind = function handleSetFetchind(v) {
55
+ datum === null || datum === void 0 || datum.dataFlatStatusMap.set(id, {
56
+ active: active,
57
+ expanded: expanded,
58
+ fetching: v
59
+ });
60
+ setFetching(v);
61
+ };
62
+ var handleSetExpanded = function handleSetExpanded(v) {
63
+ datum === null || datum === void 0 || datum.dataFlatStatusMap.set(id, {
64
+ active: active,
65
+ expanded: v,
66
+ fetching: fetching
67
+ });
68
+ setExpanded(v);
69
+ };
70
+ var isLeaf = function isLeaf() {
71
+ var children = data[childrenKey];
72
+ if (children && children.length > 0) return false;
73
+ if (Array.isArray(children) || children === null) return true;
74
+ if (fetching && !children) return false;
75
+ if (loader && !fetching) return false;
76
+ return true;
77
+ };
78
+ (0, _react.useEffect)(function () {
79
+ bindNode(id, update, data);
80
+ }, []);
81
+ return {
82
+ update: update,
83
+ active: active,
84
+ expanded: expanded,
85
+ fetching: fetching,
86
+ isLeaf: isLeaf,
87
+ setFetching: handleSetFetchind,
88
+ setExpanded: handleSetExpanded,
89
+ onToggle: handleToggle
90
+ };
91
+ };
92
+ var _default = exports.default = useTreeVirtualNode;
@@ -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;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"}
1
+ {"version":3,"file":"use-tree.d.ts","sourceRoot":"","sources":["use-tree.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,aAAa,EAKb,SAAS,EAGV,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAiBjD,eAAO,MAAM,IAAI;IACf;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEJ,CAAC;AAEF,QAAA,MAAM,OAAO;;;;;CAurBZ,CAAC;AAEF,eAAe,OAAO,CAAC"}
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
@@ -7,10 +8,16 @@ exports.default = exports.MODE = void 0;
7
8
  var _react = require("react");
8
9
  var _useLatestObj = _interopRequireDefault(require("../../common/use-latest-obj"));
9
10
  var _useInputAble2 = require("../../common/use-input-able");
11
+ var _useTableTree = require("../use-table/use-table-tree");
10
12
  var _usePersistFn = require("../../common/use-persist-fn");
11
13
  var _is = require("../../utils/is");
12
14
  var _utils = require("../../utils");
13
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
+ 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; }
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
20
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
14
21
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
15
22
  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."); }
16
23
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -26,7 +33,6 @@ function toArray(value) {
26
33
  if (!Array.isArray(value)) return [value];
27
34
  return value;
28
35
  }
29
- var global_tree_map = new Map();
30
36
  var MODE = exports.MODE = {
31
37
  /**
32
38
  * 返回全选数据,包含父节点和子节点
@@ -59,6 +65,7 @@ var useTree = function useTree(props) {
59
65
  childrenKey = _props$childrenKey === void 0 ? 'children' : _props$childrenKey,
60
66
  keygen = props.keygen,
61
67
  mode = props.mode,
68
+ virtual = props.virtual,
62
69
  activeProp = props.active,
63
70
  expandedProp = props.expanded,
64
71
  _props$dataUpdate = props.dataUpdate,
@@ -66,14 +73,19 @@ var useTree = function useTree(props) {
66
73
  _props$defaultExpande = props.defaultExpanded,
67
74
  defaultExpanded = _props$defaultExpande === void 0 ? [] : _props$defaultExpande,
68
75
  defaultExpandAll = props.defaultExpandAll,
69
- disabledProps = props.disabled,
70
76
  unmatch = props.unmatch,
71
77
  isControlled = props.isControlled,
72
78
  onExpandProp = props.onExpand;
79
+ var disabledProps = (0, _is.isOptionalDisabled)(props.disabled) ? props.disabled.disabled : props.disabled;
80
+ var isRealtime = (0, _is.isOptionalDisabled)(props.disabled) ? props.disabled.isRealtime : false;
73
81
  var _useState = (0, _react.useState)(false),
74
82
  _useState2 = _slicedToArray(_useState, 2),
75
83
  inited = _useState2[0],
76
84
  setInited = _useState2[1];
85
+ var _useState3 = (0, _react.useState)([]),
86
+ _useState4 = _slicedToArray(_useState3, 2),
87
+ dataFlat = _useState4[0],
88
+ setDataFlat = _useState4[1];
77
89
  var _useInputAble = (0, _useInputAble2.useInputAble)({
78
90
  value: expandedProp,
79
91
  defaultValue: defaultExpanded,
@@ -86,6 +98,8 @@ var useTree = function useTree(props) {
86
98
  var _useRef = (0, _react.useRef)({
87
99
  pathMap: new Map(),
88
100
  dataMap: new Map(),
101
+ dataFlatStatusMap: new Map(),
102
+ dataFlat: [],
89
103
  forceUpdateMap: new Map(),
90
104
  valueMap: new Map(),
91
105
  updateMap: new Map(),
@@ -117,11 +131,27 @@ var useTree = function useTree(props) {
117
131
  expanded: shouldDefaultExpand
118
132
  };
119
133
  }
134
+ if (virtual) {
135
+ return {
136
+ active: isActive,
137
+ expanded: context.dataFlatStatusMap.get(id).expanded
138
+ };
139
+ }
120
140
  return {
121
141
  active: isActive,
122
142
  expanded: !!(expandeds && expandeds.indexOf(id) >= 0)
123
143
  };
124
144
  };
145
+
146
+ // 注册节点
147
+ var bindVirtualNode = function bindVirtualNode(id, update) {
148
+ context.updateMap.set(id, update);
149
+ var isActive = activeProp === id;
150
+ return {
151
+ active: isActive,
152
+ expanded: context.dataFlatStatusMap.get(id).expanded
153
+ };
154
+ };
125
155
  var get = function get(id) {
126
156
  return context.valueMap.get(id);
127
157
  };
@@ -134,7 +164,6 @@ var useTree = function useTree(props) {
134
164
  if (keygen && ((0, _is.isString)(keygen) || (0, _is.isNumber)(keygen))) {
135
165
  return item[keygen];
136
166
  }
137
-
138
167
  // 降级处理
139
168
  return id + (id ? ',' : '') + index;
140
169
  };
@@ -232,6 +261,8 @@ var useTree = function useTree(props) {
232
261
  };
233
262
  var initData = function initData(data, path, disabled) {
234
263
  var index = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
264
+ var level = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 1;
265
+ var pid = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : null;
235
266
  var ids = [];
236
267
  for (var i = 0; i < data.length; i++) {
237
268
  var item = data[i];
@@ -243,6 +274,28 @@ var useTree = function useTree(props) {
243
274
  }
244
275
  // 制作 data mapping
245
276
  context.dataMap.set(id, item);
277
+ if (virtual) {
278
+ context.dataFlatStatusMap.set(id, {
279
+ active: false,
280
+ expanded: defaultExpandAll ? true : (expanded === null || expanded === void 0 ? void 0 : expanded.includes(id)) || false,
281
+ fetching: false
282
+ });
283
+ var node = {
284
+ id: id,
285
+ level: level,
286
+ data: item,
287
+ pid: pid
288
+ };
289
+ if (defaultExpandAll) {
290
+ context.dataFlat.push(node);
291
+ } else {
292
+ if (level === 1) {
293
+ context.dataFlat.push(node);
294
+ } else if (expanded && pid !== null && expanded.indexOf(pid) >= 0) {
295
+ context.dataFlat.push(node);
296
+ }
297
+ }
298
+ }
246
299
  var _isDisabled = !!disabled;
247
300
  if (_isDisabled === false) {
248
301
  _isDisabled = getDisabled()(item);
@@ -251,7 +304,7 @@ var useTree = function useTree(props) {
251
304
  ids.push(id);
252
305
  var children = [];
253
306
  if (Array.isArray(item[childrenKey])) {
254
- var _children = initData(item[childrenKey], [].concat(_toConsumableArray(path), [id]), mode === MODE.MODE_4 ? disabled : _isDisabled, indexPath);
307
+ var _children = initData(item[childrenKey], [].concat(_toConsumableArray(path), [id]), mode === MODE.MODE_4 ? disabled : _isDisabled, indexPath, level + 1, id);
255
308
  if (_children) children = _children;
256
309
  }
257
310
  context.pathMap.set(id, {
@@ -264,6 +317,34 @@ var useTree = function useTree(props) {
264
317
  }
265
318
  return ids;
266
319
  };
320
+ var initFlatData = function initFlatData(data, path) {
321
+ var level = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
322
+ var pid = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;
323
+ var result = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
324
+ for (var i = 0; i < data.length; i++) {
325
+ var item = data[i];
326
+ var id = getKey(item, path[path.length - 1], i);
327
+ var node = {
328
+ id: id,
329
+ level: level,
330
+ data: item,
331
+ pid: pid
332
+ };
333
+ if (defaultExpandAll) {
334
+ result.push(node);
335
+ } else {
336
+ if (level === 1) {
337
+ result.push(node);
338
+ } else if (expanded && pid !== null && expanded.indexOf(pid) >= 0) {
339
+ result.push(node);
340
+ }
341
+ }
342
+ if (Array.isArray(item[childrenKey])) {
343
+ initFlatData(item[childrenKey], [].concat(_toConsumableArray(path), [id]), level + 1, id, result);
344
+ }
345
+ }
346
+ return result;
347
+ };
267
348
  var initValue = function initValue(ids_outer, forceCheck) {
268
349
  var ids = ids_outer;
269
350
  if (!context.data || !context.value) {
@@ -329,7 +410,15 @@ var useTree = function useTree(props) {
329
410
  var isDisabled = function isDisabled(id) {
330
411
  if ((0, _is.isFunc)(disabledProps)) {
331
412
  var node = context.pathMap.get(id);
332
- if (node) return node.isDisabled;
413
+ if (node) {
414
+ if (isRealtime) {
415
+ var item = context.dataMap.get(id);
416
+ if (!item) return false;
417
+ return getDisabled()(item);
418
+ } else {
419
+ return node.isDisabled;
420
+ }
421
+ }
333
422
  return false;
334
423
  }
335
424
  return !!disabledProps;
@@ -346,28 +435,26 @@ var useTree = function useTree(props) {
346
435
  return 2;
347
436
  };
348
437
  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
-
358
438
  var prevValue = context.value || [];
359
439
  context.cachedValue = [];
360
440
  context.pathMap = new Map();
361
441
  context.dataMap = new Map();
442
+ context.dataFlat = [];
443
+ context.dataFlatStatusMap = new Map();
362
444
  context.valueMap = new Map();
363
445
  context.unmatchedValueMap = new Map();
364
446
  context.data = toArray(data);
447
+ if (virtual) {
448
+ context.dataFlat = [];
449
+ setDataFlat([]);
450
+ }
365
451
  if (!data) return;
366
452
  initData(context.data, []);
453
+ if (virtual) {
454
+ setDataFlat(context.dataFlat);
455
+ }
367
456
  initValue();
368
457
  setValue(prevValue);
369
-
370
- // global_tree_map.set(data, context)
371
458
  };
372
459
  var set = function set(id, checked, direction) {
373
460
  if (!isDisabled(id)) {
@@ -409,6 +496,123 @@ var useTree = function useTree(props) {
409
496
  }
410
497
  return current;
411
498
  };
499
+ var updateInnerCheckStatus = function updateInnerCheckStatus() {
500
+ var _context$value;
501
+ if (mode !== MODE.MODE_0) return;
502
+ (_context$value = context.value) === null || _context$value === void 0 || _context$value.forEach(function (id) {
503
+ var _ref3 = context.pathMap.get(id),
504
+ children = _ref3.children;
505
+ if (children.length) {
506
+ var noCheckedChildren = children.filter(function (cid) {
507
+ var _context$value2;
508
+ return !((_context$value2 = context.value) !== null && _context$value2 !== void 0 && _context$value2.includes(cid));
509
+ });
510
+ if (noCheckedChildren.length > 0) {
511
+ setTimeout(function () {
512
+ setValueMap(id, 2);
513
+ noCheckedChildren.forEach(function (cid) {
514
+ setValueMap(cid, 0);
515
+ });
516
+ }, 0);
517
+ }
518
+ }
519
+ });
520
+ };
521
+ var appendChildrenExpanded = function appendChildrenExpanded(child, level, pid, insertData) {
522
+ if (!child) return;
523
+ child.forEach(function (item, i) {
524
+ var _context$dataFlatStat;
525
+ var childId = getKey(item, pid, i);
526
+ var node = {
527
+ id: childId,
528
+ level: level,
529
+ data: item,
530
+ pid: pid
531
+ };
532
+ insertData.push(node);
533
+ if ((_context$dataFlatStat = context.dataFlatStatusMap.get(childId)) !== null && _context$dataFlatStat !== void 0 && _context$dataFlatStat.expanded && item[childrenKey]) {
534
+ appendChildrenExpanded(item[childrenKey], level + 1, childId, insertData);
535
+ }
536
+ });
537
+ };
538
+ var insertFlat = function insertFlat(id) {
539
+ var item = getDataById(id);
540
+ if ((0, _is.isUnMatchedData)(item)) return;
541
+ if (!item) return;
542
+ var status = context.dataFlatStatusMap.get(id);
543
+ if (!status) return;
544
+ var childrenData = item[childrenKey];
545
+ var insertStartNode = dataFlat.find(function (item) {
546
+ return item.id === id;
547
+ });
548
+ context.dataFlatStatusMap.set(id, _objectSpread(_objectSpread({}, status), {}, {
549
+ expanded: true,
550
+ fetching: false
551
+ }));
552
+ if (!insertStartNode) return;
553
+ var insertData = [];
554
+ appendChildrenExpanded(childrenData, insertStartNode.level + 1, id, insertData);
555
+ var insertIndex = dataFlat.indexOf(insertStartNode);
556
+ var nextDataFlat = (0, _utils.produce)(dataFlat, function (draft) {
557
+ draft.splice.apply(draft, [insertIndex + 1, 0].concat(_toConsumableArray(insertData)));
558
+ });
559
+ setDataFlat(nextDataFlat);
560
+ };
561
+ var removeFlat = function removeFlat(id) {
562
+ var item = getDataById(id);
563
+ if ((0, _is.isUnMatchedData)(item)) return;
564
+ if (!item) return;
565
+ var removeNode = dataFlat.find(function (item) {
566
+ return item.id === id;
567
+ });
568
+ if (!removeNode) return;
569
+ var status = context.dataFlatStatusMap.get(id);
570
+ if (!status) return;
571
+ context.dataFlatStatusMap.set(id, _objectSpread(_objectSpread({}, status), {}, {
572
+ fetching: false,
573
+ expanded: false
574
+ }));
575
+ var removeStartIndex = dataFlat.indexOf(removeNode);
576
+ var removeEndIndex = 0;
577
+ for (var i = removeStartIndex + 1; i < dataFlat.length; i++) {
578
+ if (dataFlat[i].level <= removeNode.level) {
579
+ removeEndIndex = i;
580
+ break;
581
+ }
582
+ if (i === dataFlat.length - 1) {
583
+ removeEndIndex = i + 1;
584
+ break;
585
+ }
586
+ }
587
+ var nextDataFlat = (0, _utils.produce)(dataFlat, function (draft) {
588
+ draft.splice(removeStartIndex + 1, removeEndIndex - removeStartIndex - 1);
589
+ });
590
+ setDataFlat(nextDataFlat);
591
+ };
592
+ var expandedFlat = function expandedFlat(expanded) {
593
+ if (!context.data) return;
594
+ context.dataFlatStatusMap.forEach(function (status, id) {
595
+ context.dataFlatStatusMap.set(id, _objectSpread(_objectSpread({}, status), {}, {
596
+ expanded: false
597
+ }));
598
+ });
599
+ expanded.forEach(function (id) {
600
+ var status = context.dataFlatStatusMap.get(id);
601
+ if (!status) return;
602
+ context.dataFlatStatusMap.set(id, _objectSpread(_objectSpread({}, status), {}, {
603
+ expanded: true
604
+ }));
605
+ });
606
+ var _getExpandVirtualData = (0, _useTableTree.getExpandVirtualData)(props.tiledData || context.data, expanded, getKey, childrenKey),
607
+ treeDataInfo = _getExpandVirtualData.treeDataInfo;
608
+ if (!treeDataInfo) {
609
+ return;
610
+ }
611
+ setDataFlat(treeDataInfo);
612
+ };
613
+ var getFlatData = function getFlatData() {
614
+ return context.dataFlat;
615
+ };
412
616
  (0, _react.useEffect)(function () {
413
617
  if (defaultExpandAll) {
414
618
  var nextExpanded = [];
@@ -419,41 +623,55 @@ var useTree = function useTree(props) {
419
623
  });
420
624
  onExpand(nextExpanded);
421
625
  }
422
- }, []);
626
+ }, [context.dataMap]);
423
627
  (0, _react.useEffect)(function () {
424
628
  if (props.datum) return;
425
629
  if (!dataUpdate) return;
426
630
  setData(data);
631
+ updateInnerCheckStatus();
427
632
  }, [data]);
428
633
  (0, _react.useEffect)(function () {
429
634
  if (props.datum) return;
430
635
  setValue(value);
431
636
  }, [value]);
637
+ (0, _react.useEffect)(function () {
638
+ if (!virtual) return;
639
+ if (!props.tiledData) return;
640
+ var tiledFlatData = initFlatData(props.tiledData, [], 1);
641
+ setDataFlat(tiledFlatData);
642
+ }, [props.tiledData]);
432
643
  (0, _react.useEffect)(function () {
433
644
  setInited(true);
434
645
  }, []);
435
646
  var datum = (0, _useLatestObj.default)({
436
647
  get: get,
437
648
  set: set,
649
+ insertFlat: insertFlat,
650
+ removeFlat: removeFlat,
651
+ expandedFlat: expandedFlat,
438
652
  getPath: getPath,
439
653
  getValue: getValue,
440
654
  getChecked: getChecked,
441
655
  getKey: getKey,
656
+ getFlatData: getFlatData,
442
657
  getDataByValues: getDataByValues,
443
658
  setValue: setValue,
444
659
  setData: setData,
445
660
  isDisabled: isDisabled,
446
661
  bindNode: bindNode,
662
+ bindVirtualNode: bindVirtualNode,
447
663
  getDataById: getDataById,
448
664
  bindUpdate: bindUpdate,
449
665
  unBindUpdate: unBindUpdate,
450
666
  isUnMatched: isUnMatched,
451
667
  childrenKey: childrenKey,
452
668
  data: data,
669
+ dataFlat: dataFlat,
453
670
  pathMap: context.pathMap,
454
671
  dataMap: context.dataMap,
455
672
  valueMap: context.valueMap,
456
- updateMap: context.updateMap
673
+ updateMap: context.updateMap,
674
+ dataFlatStatusMap: context.dataFlatStatusMap
457
675
  });
458
676
  return {
459
677
  inited: inited,
@@ -2,9 +2,22 @@ import { StructKeygenStringType, KeygenResult, ObjectKey } from '../../common/ty
2
2
  export type CheckedStatusType = 0 | 1 | 2;
3
3
  export type TreeModeType = 0 | 1 | 2 | 3 | 4;
4
4
  export type UpdateFunc = (name: string, active: boolean) => void;
5
+ export type FlatNodeType<DataItem> = {
6
+ id: KeygenResult;
7
+ data: DataItem;
8
+ level: number;
9
+ pid?: KeygenResult | null;
10
+ };
11
+ export type FlatMapType = {
12
+ active: boolean;
13
+ expanded: boolean;
14
+ fetching: boolean;
15
+ };
5
16
  export interface TreeContext<DataItem> {
6
17
  pathMap: Map<KeygenResult, TreePathType>;
7
18
  dataMap: Map<KeygenResult, DataItem>;
19
+ dataFlat: FlatNodeType<DataItem>[];
20
+ dataFlatStatusMap: Map<KeygenResult, FlatMapType>;
8
21
  valueMap: Map<KeygenResult, CheckedStatusType>;
9
22
  unmatchedValueMap: Map<any, any>;
10
23
  updateMap: Map<KeygenResult, UpdateFunc>;
@@ -21,11 +34,19 @@ export interface TreePathType {
21
34
  indexPath: number[];
22
35
  index: number;
23
36
  }
37
+ export interface DisabledOption<DataItem> {
38
+ disabled: (data: DataItem) => boolean;
39
+ isRealtime: boolean;
40
+ }
24
41
  export interface BaseTreeProps<DataItem> {
25
42
  /**
26
43
  * @private 内部属性
27
44
  */
28
45
  isControlled: boolean;
46
+ /**
47
+ * @private 内部属性
48
+ */
49
+ tiledData?: DataItem[];
29
50
  active?: KeygenResult;
30
51
  /**
31
52
  * @en Selected key (controlled)
@@ -63,7 +84,7 @@ export interface BaseTreeProps<DataItem> {
63
84
  * @cn 显示选择框时有效,为 true 时,所有节点禁用选择,为函数时,根据函数返回结果确定是否禁用
64
85
  * @default false
65
86
  */
66
- disabled?: boolean | ((item: DataItem) => boolean);
87
+ disabled?: boolean | ((item: DataItem) => boolean) | DisabledOption<DataItem>;
67
88
  /**
68
89
  * @en Auxiliary method for generating key. When it is a function, use the return value of this function. When it is a string, use the data value corresponding to this string. For example, "id" is the same thing as (d) => d.id
69
90
  * @cn 生成 key 的辅助方法, 为函数时,使用此函数返回值, 为 string 时,使用这个 string 对应的数据值。如 "id",相当于 (d) => d.id
@@ -106,10 +127,17 @@ export interface BaseTreeProps<DataItem> {
106
127
  * @private 内部数据处理
107
128
  */
108
129
  datum?: TreeDatum<DataItem>;
130
+ /**
131
+ * @private 是否虚拟化
132
+ */
133
+ virtual?: boolean;
109
134
  }
110
135
  export interface TreeDatum<DataItem> {
111
136
  get: (id: KeygenResult) => CheckedStatusType | undefined;
112
137
  set: (id: KeygenResult, checked: CheckedStatusType, direction?: 'asc' | 'desc') => CheckedStatusType | null;
138
+ insertFlat: (id: KeygenResult) => void;
139
+ removeFlat: (id: KeygenResult) => void;
140
+ expandedFlat: (id: KeygenResult[]) => void;
113
141
  getPath: (id: KeygenResult) => TreePathType | undefined;
114
142
  getValue: () => KeygenResult[];
115
143
  getChecked: (id: KeygenResult) => boolean | 'indeterminate';
@@ -122,6 +150,10 @@ export interface TreeDatum<DataItem> {
122
150
  active: boolean;
123
151
  expanded: boolean;
124
152
  };
153
+ bindVirtualNode: (id: KeygenResult, update: UpdateFunc, data: DataItem) => {
154
+ active: boolean;
155
+ expanded: boolean;
156
+ };
125
157
  getDataById: (id: KeygenResult) => DataItem | {
126
158
  IS_NOT_MATCHED_VALUE: boolean;
127
159
  value: KeygenResult | null;
@@ -132,8 +164,10 @@ export interface TreeDatum<DataItem> {
132
164
  updateMap: Map<KeygenResult, UpdateFunc>;
133
165
  childrenKey: string;
134
166
  data: DataItem[];
167
+ dataFlat: FlatNodeType<DataItem>[];
135
168
  pathMap: Map<KeygenResult, TreePathType>;
136
169
  dataMap: Map<KeygenResult, DataItem>;
137
170
  valueMap: Map<KeygenResult, CheckedStatusType>;
171
+ dataFlatStatusMap: Map<KeygenResult, FlatMapType>;
138
172
  }
139
173
  //# sourceMappingURL=use-tree.type.d.ts.map