tntd 2.8.9 → 2.8.11

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 (166) hide show
  1. package/es/array-input/index.js +10 -1
  2. package/es/array-input/index.js.map +1 -1
  3. package/es/index.js +2 -0
  4. package/es/index.js.map +1 -1
  5. package/es/locale/en_US.js +17 -1
  6. package/es/locale/en_US.js.map +1 -1
  7. package/es/locale/zh_CN.js +16 -0
  8. package/es/locale/zh_CN.js.map +1 -1
  9. package/es/prev-locale.js +32 -2
  10. package/es/prev-locale.js.map +1 -1
  11. package/es/query-list-scene/index.less +4 -0
  12. package/es/svg-components/illustration-offline.js +11 -29
  13. package/es/svg-components/illustration-offline.js.map +1 -1
  14. package/es/table/index.js +2 -2
  15. package/es/table/index.js.map +1 -1
  16. package/es/table/resizableTable/index.js +87 -0
  17. package/es/table/resizableTable/index.js.map +1 -0
  18. package/es/table/resizableTable/index.less +36 -0
  19. package/es/table/table-hoc.js +26 -0
  20. package/es/table/table-hoc.js.map +1 -0
  21. package/es/table/table.js +27 -25
  22. package/es/table/table.js.map +1 -1
  23. package/es/title/index.js +18 -4
  24. package/es/title/index.js.map +1 -1
  25. package/es/title/index.less +88 -34
  26. package/es/tntd-reference/AHref/index.js +39 -0
  27. package/es/tntd-reference/AHref/index.js.map +1 -0
  28. package/es/tntd-reference/ReferenceBatchCheck/index.js +153 -0
  29. package/es/tntd-reference/ReferenceBatchCheck/index.js.map +1 -0
  30. package/es/tntd-reference/ReferenceBatchCheck/index.less +21 -0
  31. package/es/tntd-reference/ReferenceBatchDrawer/index.js +102 -0
  32. package/es/tntd-reference/ReferenceBatchDrawer/index.js.map +1 -0
  33. package/es/tntd-reference/ReferenceBatchDrawer/index.less +0 -0
  34. package/es/tntd-reference/ReferenceCheck/index.js +117 -0
  35. package/es/tntd-reference/ReferenceCheck/index.js.map +1 -0
  36. package/es/tntd-reference/ReferenceCheck/index.less +10 -0
  37. package/es/tntd-reference/ReferenceDrawer/index.js +69 -0
  38. package/es/tntd-reference/ReferenceDrawer/index.js.map +1 -0
  39. package/es/tntd-reference/ReferenceDrawer/index.less +0 -0
  40. package/es/tntd-reference/ReferenceInfo/index.js +150 -0
  41. package/es/tntd-reference/ReferenceInfo/index.js.map +1 -0
  42. package/es/tntd-reference/ReferenceInfo/index.less +31 -0
  43. package/es/tntd-reference/index.js +13 -0
  44. package/es/tntd-reference/index.js.map +1 -0
  45. package/es/tntd-virtual-tree/index.js +229 -0
  46. package/es/tntd-virtual-tree/index.js.map +1 -0
  47. package/es/tntd-virtual-tree/index.less +59 -0
  48. package/es/tntd-virtual-tree/utils.js +296 -0
  49. package/es/tntd-virtual-tree/utils.js.map +1 -0
  50. package/es/tntd-virtual-tree-select/index.js +98 -22
  51. package/es/tntd-virtual-tree-select/index.js.map +1 -1
  52. package/es/tntd-virtual-tree-select/utils.js +20 -124
  53. package/es/tntd-virtual-tree-select/utils.js.map +1 -1
  54. package/lib/array-input/index.d.ts.map +1 -1
  55. package/lib/array-input/index.js +14 -1
  56. package/lib/array-input/index.js.map +1 -1
  57. package/lib/index.d.ts +2 -0
  58. package/lib/index.d.ts.map +1 -1
  59. package/lib/index.js +14 -0
  60. package/lib/index.js.map +1 -1
  61. package/lib/locale/default.d.ts +16 -0
  62. package/lib/locale/default.d.ts.map +1 -1
  63. package/lib/locale/en_US.d.ts +16 -0
  64. package/lib/locale/en_US.d.ts.map +1 -1
  65. package/lib/locale/en_US.js +17 -1
  66. package/lib/locale/en_US.js.map +1 -1
  67. package/lib/locale/zh_CN.d.ts +16 -0
  68. package/lib/locale/zh_CN.d.ts.map +1 -1
  69. package/lib/locale/zh_CN.js +16 -0
  70. package/lib/locale/zh_CN.js.map +1 -1
  71. package/lib/prev-locale.d.ts +42 -0
  72. package/lib/prev-locale.d.ts.map +1 -1
  73. package/lib/prev-locale.js +32 -2
  74. package/lib/prev-locale.js.map +1 -1
  75. package/lib/query-list-scene/index.less +4 -0
  76. package/lib/segmented/index.d.ts +1 -1
  77. package/lib/svg-components/illustration-offline.d.ts.map +1 -1
  78. package/lib/svg-components/illustration-offline.js +11 -29
  79. package/lib/svg-components/illustration-offline.js.map +1 -1
  80. package/lib/table/index.d.ts +2 -2
  81. package/lib/table/index.d.ts.map +1 -1
  82. package/lib/table/index.js +7 -7
  83. package/lib/table/index.js.map +1 -1
  84. package/lib/table/resizableTable/index.d.ts +12 -0
  85. package/lib/table/resizableTable/index.d.ts.map +1 -0
  86. package/lib/table/resizableTable/index.js +110 -0
  87. package/lib/table/resizableTable/index.js.map +1 -0
  88. package/lib/table/resizableTable/index.less +36 -0
  89. package/lib/table/table-hoc.d.ts +7 -0
  90. package/lib/table/table-hoc.d.ts.map +1 -0
  91. package/lib/{spin/spin.js → table/table-hoc.js} +12 -22
  92. package/lib/table/table-hoc.js.map +1 -0
  93. package/lib/table/table.js +18 -15
  94. package/lib/table/table.js.map +1 -1
  95. package/lib/table/table.stories.d.ts +1 -1
  96. package/lib/title/index.d.ts +1 -0
  97. package/lib/title/index.d.ts.map +1 -1
  98. package/lib/title/index.js +18 -4
  99. package/lib/title/index.js.map +1 -1
  100. package/lib/title/index.less +88 -34
  101. package/lib/tntd-reference/AHref/index.d.ts +4 -0
  102. package/lib/tntd-reference/AHref/index.d.ts.map +1 -0
  103. package/lib/tntd-reference/AHref/index.js +44 -0
  104. package/lib/tntd-reference/AHref/index.js.map +1 -0
  105. package/lib/tntd-reference/ReferenceBatchCheck/index.d.ts +3 -0
  106. package/lib/tntd-reference/ReferenceBatchCheck/index.d.ts.map +1 -0
  107. package/lib/tntd-reference/ReferenceBatchCheck/index.js +165 -0
  108. package/lib/tntd-reference/ReferenceBatchCheck/index.js.map +1 -0
  109. package/lib/tntd-reference/ReferenceBatchCheck/index.less +21 -0
  110. package/lib/tntd-reference/ReferenceBatchDrawer/index.d.ts +4 -0
  111. package/lib/tntd-reference/ReferenceBatchDrawer/index.d.ts.map +1 -0
  112. package/lib/tntd-reference/ReferenceBatchDrawer/index.js +126 -0
  113. package/lib/tntd-reference/ReferenceBatchDrawer/index.js.map +1 -0
  114. package/lib/tntd-reference/ReferenceBatchDrawer/index.less +0 -0
  115. package/lib/tntd-reference/ReferenceCheck/index.d.ts +3 -0
  116. package/lib/tntd-reference/ReferenceCheck/index.d.ts.map +1 -0
  117. package/lib/tntd-reference/ReferenceCheck/index.js +126 -0
  118. package/lib/tntd-reference/ReferenceCheck/index.js.map +1 -0
  119. package/lib/tntd-reference/ReferenceCheck/index.less +10 -0
  120. package/lib/tntd-reference/ReferenceDrawer/index.d.ts +4 -0
  121. package/lib/tntd-reference/ReferenceDrawer/index.d.ts.map +1 -0
  122. package/lib/tntd-reference/ReferenceDrawer/index.js +93 -0
  123. package/lib/tntd-reference/ReferenceDrawer/index.js.map +1 -0
  124. package/lib/tntd-reference/ReferenceDrawer/index.less +0 -0
  125. package/lib/tntd-reference/ReferenceInfo/index.d.ts +4 -0
  126. package/lib/tntd-reference/ReferenceInfo/index.d.ts.map +1 -0
  127. package/lib/tntd-reference/ReferenceInfo/index.js +164 -0
  128. package/lib/tntd-reference/ReferenceInfo/index.js.map +1 -0
  129. package/lib/tntd-reference/ReferenceInfo/index.less +31 -0
  130. package/lib/tntd-reference/index.d.ts +15 -0
  131. package/lib/tntd-reference/index.d.ts.map +1 -0
  132. package/lib/tntd-reference/index.js +20 -0
  133. package/lib/tntd-reference/index.js.map +1 -0
  134. package/lib/tntd-virtual-tree/index.d.ts +20 -0
  135. package/lib/tntd-virtual-tree/index.d.ts.map +1 -0
  136. package/lib/tntd-virtual-tree/index.js +263 -0
  137. package/lib/tntd-virtual-tree/index.js.map +1 -0
  138. package/lib/tntd-virtual-tree/index.less +59 -0
  139. package/lib/tntd-virtual-tree/utils.d.ts +17 -0
  140. package/lib/tntd-virtual-tree/utils.d.ts.map +1 -0
  141. package/lib/tntd-virtual-tree/utils.js +353 -0
  142. package/lib/tntd-virtual-tree/utils.js.map +1 -0
  143. package/lib/tntd-virtual-tree-select/index.d.ts +13 -4
  144. package/lib/tntd-virtual-tree-select/index.d.ts.map +1 -1
  145. package/lib/tntd-virtual-tree-select/index.js +100 -19
  146. package/lib/tntd-virtual-tree-select/index.js.map +1 -1
  147. package/lib/tntd-virtual-tree-select/utils.d.ts +2 -9
  148. package/lib/tntd-virtual-tree-select/utils.d.ts.map +1 -1
  149. package/lib/tntd-virtual-tree-select/utils.js +23 -142
  150. package/lib/tntd-virtual-tree-select/utils.js.map +1 -1
  151. package/package.json +4 -2
  152. package/es/spin/spin.js +0 -36
  153. package/es/spin/spin.js.map +0 -1
  154. package/es/spin/spin.less +0 -9
  155. package/es/tntd-virtual-tree-select/VirtualTree.js +0 -125
  156. package/es/tntd-virtual-tree-select/VirtualTree.js.map +0 -1
  157. package/es/tntd-virtual-tree-select/tree.less +0 -29
  158. package/lib/spin/spin.d.ts +0 -9
  159. package/lib/spin/spin.d.ts.map +0 -1
  160. package/lib/spin/spin.js.map +0 -1
  161. package/lib/spin/spin.less +0 -9
  162. package/lib/tntd-virtual-tree-select/VirtualTree.d.ts +0 -13
  163. package/lib/tntd-virtual-tree-select/VirtualTree.d.ts.map +0 -1
  164. package/lib/tntd-virtual-tree-select/VirtualTree.js +0 -155
  165. package/lib/tntd-virtual-tree-select/VirtualTree.js.map +0 -1
  166. package/lib/tntd-virtual-tree-select/tree.less +0 -29
@@ -0,0 +1,353 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNodeValuess = exports.getNodeStr = exports.getNodeParentChoosed = exports.getNodeNoDisabledLastestChildrenValues = exports.getNodeNoDisabledChildrenValues = exports.getIndeterminate = exports.getFullExpandedKeys = exports.getFullCheckedKeys = exports.flatTreeData = exports.findNodeDetail = exports.addTreeNodeAttrs = void 0;
7
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
8
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
+ 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."); }
10
+ 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); }
11
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
12
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
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
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
15
+ var t = {};
16
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ /**
23
+ * 初始化给树的每个节点增加以下属性字段
24
+ * childrenValues: 当前节点下的所有子节点的value和(包含了disabled节点)用户展开/收起
25
+ * titleTotal: 当前节点下的所有子节点的title和 (包含了disabled节点)用于搜索
26
+ * needCheckedChildrenValues: 当前节点下的节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中
27
+ * needCheckedLastestChildrenValues: 当前节点下的最底层节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中
28
+ * needCheckedSiblingsValue: 当前节点所有上级节点的兄弟节点, [{ key: '上级节点value', list: [xx] }] list包含非disabled节点 用于选中/取消选中
29
+ * 用于判断后续展开/收起
30
+ * @param {*} treeData
31
+ */
32
+ var addTreeNodeAttrs = exports.addTreeNodeAttrs = function addTreeNodeAttrs(treeData) {
33
+ var fieldNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
34
+ title: 'title',
35
+ value: 'value',
36
+ children: 'children',
37
+ disabled: 'disabled'
38
+ };
39
+ var needCheckedSiblingsValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
40
+ if (Array.isArray(treeData) && !!treeData.length) {
41
+ return treeData.map(function (item) {
42
+ item.children = item[fieldNames['children']];
43
+ item.title = item[fieldNames['title']];
44
+ item.value = item[fieldNames['value']];
45
+ var children = item.children,
46
+ query = __rest(item, ["children"]);
47
+ if (Array.isArray(children) && !!children.length) {
48
+ var siblingsSum = needCheckedSiblingsValue;
49
+ if (!item[fieldNames['disabled']]) {
50
+ // 这里注意要逆序,要不然校验的时候会出问题
51
+ siblingsSum = [{
52
+ key: item[fieldNames['value']],
53
+ list: children.reduce(function (total, item) {
54
+ if (!item[fieldNames['disabled']]) {
55
+ total.push(item[fieldNames['value']]);
56
+ }
57
+ return total;
58
+ }, [])
59
+ }].concat(_toConsumableArray(siblingsSum));
60
+ } else {
61
+ siblingsSum = [];
62
+ }
63
+ query.children = addTreeNodeAttrs(children, fieldNames, siblingsSum);
64
+ }
65
+ return Object.assign(Object.assign({}, query), {
66
+ title: query[fieldNames['title']],
67
+ value: query[fieldNames['value']],
68
+ disabled: query[fieldNames['disabled']],
69
+ childrenValues: getNodeValuess(query, false),
70
+ titleTotal: getNodeStr(query, fieldNames['title']),
71
+ needCheckedLastestChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledLastestChildrenValues(item, fieldNames) : [],
72
+ needCheckedChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledChildrenValues(item, fieldNames) : [],
73
+ needCheckedSiblingsValue: !item[fieldNames['disabled']] ? needCheckedSiblingsValue : []
74
+ });
75
+ });
76
+ }
77
+ return [];
78
+ };
79
+ var getNodeStr = exports.getNodeStr = function getNodeStr(node, key) {
80
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
81
+ result.push(node[key]);
82
+ if (Array.isArray(node.children) && !!node.children.length) {
83
+ node.children.forEach(function (element) {
84
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeStr(element, key)));
85
+ });
86
+ }
87
+ return result;
88
+ };
89
+ /**
90
+ * 获取每个节点下面所有子节点的value值
91
+ * @param {*} node
92
+ * @param {*} widthSelf 是否包含自己
93
+ * @param {*} result
94
+ * @returns []
95
+ */
96
+ var getNodeValuess = exports.getNodeValuess = function getNodeValuess(node) {
97
+ var widthSelf = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
98
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
99
+ if (widthSelf) {
100
+ result.push(node.value);
101
+ }
102
+ if (Array.isArray(node.children) && !!node.children.length) {
103
+ node.children.forEach(function (element) {
104
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeValuess(element)));
105
+ });
106
+ }
107
+ return result;
108
+ };
109
+ /**
110
+ * 扁平树
111
+ * @param {*} treeData
112
+ * @param {*} expandedKeys 展开的节点
113
+ * @param {*} treeDefaultExpandAll
114
+ * @param {*} level
115
+ * @param {*} result
116
+ * @returns
117
+ */
118
+ var flatTreeData = exports.flatTreeData = function flatTreeData(treeData) {
119
+ var filterKey = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
120
+ var expandedKeys = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
121
+ var treeDefaultExpandAll = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
122
+ var level = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
123
+ var result = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : [];
124
+ if (Array.isArray(treeData)) {
125
+ var _iterator = _createForOfIteratorHelper(treeData),
126
+ _step;
127
+ try {
128
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
129
+ var i = _step.value;
130
+ var value = i.value,
131
+ children = i.children,
132
+ titleTotal = i.titleTotal,
133
+ title = i.title,
134
+ rest = __rest(i, ["value", "children", "titleTotal", "title"]);
135
+ // 判断是否命中过滤
136
+ var bingo = true;
137
+ var transFilterKey = !['', null, undefined].includes(filterKey);
138
+ if (transFilterKey) {
139
+ bingo = Array.isArray(titleTotal) ? titleTotal.some(function (i) {
140
+ return i.includes(filterKey);
141
+ }) : false;
142
+ }
143
+ if (bingo) {
144
+ result.push(Object.assign({
145
+ level: level
146
+ }, i));
147
+ }
148
+ var selfIn = Array.isArray(expandedKeys) ? expandedKeys.includes(value) : false;
149
+ if ((treeDefaultExpandAll || selfIn || transFilterKey && bingo) && Array.isArray(children) && !!children.length) {
150
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(flatTreeData(children, filterKey, expandedKeys, treeDefaultExpandAll, level + 1)));
151
+ }
152
+ }
153
+ } catch (err) {
154
+ _iterator.e(err);
155
+ } finally {
156
+ _iterator.f();
157
+ }
158
+ }
159
+ return result;
160
+ };
161
+ /**
162
+ * 获取所有展开的节点 (组件传入最后一层,需要将其上层全部加入到expandedKeys)
163
+ * @param {*} treeDataWithKeys
164
+ * @param {*} treeExpandedKeys
165
+ * @param {*} result
166
+ * @returns
167
+ */
168
+ var getFullExpandedKeys = exports.getFullExpandedKeys = function getFullExpandedKeys(treeDataWithKeys) {
169
+ var treeExpandedKeys = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
170
+ var treeDefaultExpandAll = arguments.length > 2 ? arguments[2] : undefined;
171
+ var result = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
172
+ if (!treeDefaultExpandAll && (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(treeExpandedKeys) || !treeExpandedKeys.length)) {
173
+ return [];
174
+ }
175
+ treeDataWithKeys.forEach(function (i) {
176
+ var childrenValues = i.childrenValues,
177
+ value = i.value,
178
+ children = i.children;
179
+ if (treeDefaultExpandAll || Array.isArray(childrenValues) && [].concat(_toConsumableArray(childrenValues), [value]).some(function (el) {
180
+ return treeExpandedKeys.includes(el);
181
+ })) {
182
+ result.push(value);
183
+ if (Array.isArray(children) && !!children.length) {
184
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getFullExpandedKeys(children, treeExpandedKeys, treeDefaultExpandAll)));
185
+ }
186
+ }
187
+ });
188
+ return result;
189
+ };
190
+ /**
191
+ * 初始化根据用户传入的值获取其关联节点是否要在checkList
192
+ * @param {*} treeDataWithKeys
193
+ * @param {*} transCheckedKeys
194
+ * @param {*} result
195
+ * @returns
196
+ */
197
+ var getFullCheckedKeys = exports.getFullCheckedKeys = function getFullCheckedKeys(treeDataWithKeys, transCheckedKeys) {
198
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
199
+ if (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(transCheckedKeys) || !transCheckedKeys.length) {
200
+ return [];
201
+ }
202
+ treeDataWithKeys.forEach(function (i) {
203
+ var value = i.value,
204
+ children = i.children,
205
+ disabled = i.disabled;
206
+ var bingo = transCheckedKeys.includes(value);
207
+ if (bingo) {
208
+ result.push(value);
209
+ }
210
+ if (Array.isArray(children) && !!children.length) {
211
+ var lastestUnDisabledChildrenValues = i.needCheckedLastestChildrenValues;
212
+ // 如果当前节点是被命中,就将其下面所有子节点都选中
213
+ if (Array.isArray(lastestUnDisabledChildrenValues) && !!lastestUnDisabledChildrenValues.length && lastestUnDisabledChildrenValues.every(function (el) {
214
+ return transCheckedKeys.includes(el);
215
+ })) {
216
+ result.push(value);
217
+ }
218
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getFullCheckedKeys(children, transCheckedKeys)));
219
+ }
220
+ });
221
+ return result;
222
+ };
223
+ /**
224
+ * 递归获取某个节点所有最下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了
225
+ * @param {*} node
226
+ * @param {*} node
227
+ * @returns
228
+ */
229
+ var getNodeNoDisabledLastestChildrenValues = exports.getNodeNoDisabledLastestChildrenValues = function getNodeNoDisabledLastestChildrenValues(node, fieldNames) {
230
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
231
+ if (Array.isArray(node.children) && !!node.children.length) {
232
+ node.children.forEach(function (element) {
233
+ if (!element[fieldNames['disabled']]) {
234
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeNoDisabledLastestChildrenValues(element, fieldNames)));
235
+ }
236
+ });
237
+ } else {
238
+ if (!node[fieldNames['disabled']]) {
239
+ result.push(node[fieldNames['value']]);
240
+ }
241
+ }
242
+ return result;
243
+ };
244
+ /**
245
+ * 递归获取某个节点所有下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了
246
+ * @param {*} node
247
+ * @param {*} node
248
+ * @returns
249
+ */
250
+ var getNodeNoDisabledChildrenValues = exports.getNodeNoDisabledChildrenValues = function getNodeNoDisabledChildrenValues(node, fieldNames) {
251
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
252
+ if (Array.isArray(node.children) && !!node.children.length) {
253
+ node.children.forEach(function (element) {
254
+ if (!element[fieldNames['disabled']]) {
255
+ result.push(element[fieldNames['value']]);
256
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(getNodeNoDisabledChildrenValues(element, fieldNames)));
257
+ }
258
+ });
259
+ } else {
260
+ if (!node[fieldNames['disabled']]) {
261
+ result.push(node[fieldNames['value']]);
262
+ }
263
+ }
264
+ return result;
265
+ };
266
+ /**
267
+ * 判断当前节点是否半选
268
+ * @param {*} item
269
+ * @param {*} checkedList
270
+ */
271
+ var getIndeterminate = exports.getIndeterminate = function getIndeterminate(item, checkedList, disabledList) {
272
+ // 如果没有子节点,就没有半选情况
273
+ if (!Array.isArray(item.children) || !item.children.length) {
274
+ return false;
275
+ }
276
+ if (!Array.isArray(checkedList) || !checkedList.length) {
277
+ return false;
278
+ }
279
+ // 当前节点下的去掉disabled的所有末级节点
280
+ var list = Array.isArray(item.needCheckedLastestChildrenValues) ? item.needCheckedLastestChildrenValues : [];
281
+ var childrenCheckedList = list.filter(function (i) {
282
+ return checkedList === null || checkedList === void 0 ? void 0 : checkedList.includes(i);
283
+ });
284
+ return childrenCheckedList.length > 0 && childrenCheckedList.length < list.length;
285
+ };
286
+ /**
287
+ * 获取当前节点的父亲节点是否需要被选中
288
+ * @param {*} needCheckedSiblingsValue
289
+ * @param {*} checkedList
290
+ * @returns
291
+ */
292
+ var getNodeParentChoosed = exports.getNodeParentChoosed = function getNodeParentChoosed(needCheckedSiblingsValue, checkedList) {
293
+ if (!Array.isArray(checkedList) || !checkedList.length) {
294
+ return [];
295
+ }
296
+ var result = [];
297
+ var _iterator2 = _createForOfIteratorHelper(needCheckedSiblingsValue),
298
+ _step2;
299
+ try {
300
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
301
+ var item = _step2.value;
302
+ var _ref = item || {},
303
+ key = _ref.key,
304
+ list = _ref.list;
305
+ // 过滤掉子节点为disabled的
306
+ var bool = Array.isArray(list) ? list.every(function (it) {
307
+ return checkedList.includes(it);
308
+ }) : false;
309
+ if (bool) {
310
+ checkedList.push(key);
311
+ result.push(key);
312
+ }
313
+ }
314
+ } catch (err) {
315
+ _iterator2.e(err);
316
+ } finally {
317
+ _iterator2.f();
318
+ }
319
+ return result;
320
+ };
321
+ /**
322
+ * 获取节点的信息
323
+ * @param {*} tree
324
+ * @param {*} key
325
+ * @param {*} result
326
+ * @returns
327
+ */
328
+ var findNodeDetail = exports.findNodeDetail = function findNodeDetail(tree, key, result) {
329
+ if (Array.isArray(tree) && !!key) {
330
+ var _iterator3 = _createForOfIteratorHelper(tree),
331
+ _step3;
332
+ try {
333
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
334
+ var i = _step3.value;
335
+ if (i.value === key) {
336
+ result = i;
337
+ break;
338
+ }
339
+ if (Array.isArray(i.children) && !!i.children.length) {
340
+ result = findNodeDetail(i.children, key);
341
+ if (result) {
342
+ break;
343
+ }
344
+ }
345
+ }
346
+ } catch (err) {
347
+ _iterator3.e(err);
348
+ } finally {
349
+ _iterator3.f();
350
+ }
351
+ }
352
+ return result;
353
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree/utils.js"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA;;;;;;;;;GASG;AACI,MAAM,gBAAgB,GAAG,CAC9B,QAAQ,EACR,UAAU,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,EAC3F,wBAAwB,GAAG,EAAE,EAC7B,EAAE;IACF,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE;QAChD,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;YAC3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;YAC7C,IAAI,CAAC,KA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,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAhBW,QAAA,oBAAoB,wBAgB/B;AAEF;;;;;;GAMG;AACI,MAAM,cAAc,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE;IAClD,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE;QAChC,KAAK,IAAI,CAAC,IAAI,IAAI,EAAE;YAClB,IAAI,CAAC,CAAC,KAAK,KAAK,GAAG,EAAE;gBACnB,MAAM,GAAG,CAAC,CAAC;gBACX,MAAM;aACP;YACD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE;gBACpD,MAAM,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;gBACzC,IAAI,MAAM,EAAE;oBACV,MAAM;iBACP;aACF;SACF;KACF;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAjBW,QAAA,cAAc,kBAiBzB","sourcesContent":["/**\n * 初始化给树的每个节点增加以下属性字段\n * childrenValues: 当前节点下的所有子节点的value和(包含了disabled节点)用户展开/收起\n * titleTotal: 当前节点下的所有子节点的title和 (包含了disabled节点)用于搜索\n * needCheckedChildrenValues: 当前节点下的节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中\n * needCheckedLastestChildrenValues: 当前节点下的最底层节点(即无children)的value和(不包含了disabled节点),用于选中/取消选中\n * needCheckedSiblingsValue: 当前节点所有上级节点的兄弟节点, [{ key: '上级节点value', list: [xx] }] list包含非disabled节点 用于选中/取消选中\n * 用于判断后续展开/收起\n * @param {*} treeData\n */\nexport const addTreeNodeAttrs = (\n treeData,\n fieldNames = { title: 'title', value: 'value', children: 'children', disabled: 'disabled' },\n needCheckedSiblingsValue = []\n) => {\n if (Array.isArray(treeData) && !!treeData.length) {\n return treeData.map((item) => {\n item.children = item[fieldNames['children']];\n item.title = item[fieldNames['title']];\n item.value = item[fieldNames['value']];\n const { children, ...query } = item;\n if (Array.isArray(children) && !!children.length) {\n let siblingsSum = needCheckedSiblingsValue;\n if (!item[fieldNames['disabled']]) {\n // 这里注意要逆序,要不然校验的时候会出问题\n siblingsSum = [\n {\n key: item[fieldNames['value']],\n list: children.reduce((total, item) => {\n if (!item[fieldNames['disabled']]) {\n total.push(item[fieldNames['value']]);\n }\n return total;\n }, [])\n },\n ...siblingsSum\n ];\n } else {\n siblingsSum = [];\n }\n query.children = addTreeNodeAttrs(children, fieldNames, siblingsSum);\n }\n return {\n ...query,\n title: query[fieldNames['title']],\n value: query[fieldNames['value']],\n disabled: query[fieldNames['disabled']],\n childrenValues: getNodeValuess(query, false),\n titleTotal: getNodeStr(query, fieldNames['title']),\n needCheckedLastestChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledLastestChildrenValues(item, fieldNames) : [],\n needCheckedChildrenValues: !item[fieldNames['disabled']] ? getNodeNoDisabledChildrenValues(item, fieldNames) : [],\n needCheckedSiblingsValue: !item[fieldNames['disabled']] ? needCheckedSiblingsValue : []\n };\n });\n }\n\n return [];\n};\n\nexport const getNodeStr = (node, key, result = []) => {\n result.push(node[key]);\n\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n result = [...result, ...getNodeStr(element, key)];\n });\n }\n\n return result;\n};\n\n/**\n * 获取每个节点下面所有子节点的value值\n * @param {*} node\n * @param {*} widthSelf 是否包含自己\n * @param {*} result\n * @returns []\n */\nexport const getNodeValuess = (node, widthSelf = true, result = []) => {\n if (widthSelf) {\n result.push(node.value);\n }\n\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n result = [...result, ...getNodeValuess(element)];\n });\n }\n\n return result;\n};\n\n/**\n * 扁平树\n * @param {*} treeData\n * @param {*} expandedKeys 展开的节点\n * @param {*} treeDefaultExpandAll\n * @param {*} level\n * @param {*} result\n * @returns\n */\nexport const flatTreeData = (treeData, filterKey = '', expandedKeys = [], treeDefaultExpandAll = false, level = 0, result = []) => {\n if (Array.isArray(treeData)) {\n for (const i of treeData) {\n const { value, children, titleTotal, title, ...rest } = i;\n\n // 判断是否命中过滤\n let bingo = true;\n const transFilterKey = !['', null, undefined].includes(filterKey);\n if (transFilterKey) {\n bingo = Array.isArray(titleTotal) ? titleTotal.some((i) => i.includes(filterKey)) : false;\n }\n\n if (bingo) {\n result.push({ level, ...i });\n }\n\n const selfIn = Array.isArray(expandedKeys) ? expandedKeys.includes(value) : false;\n if ((treeDefaultExpandAll || selfIn || (transFilterKey && bingo)) && Array.isArray(children) && !!children.length) {\n result = [...result, ...flatTreeData(children, filterKey, expandedKeys, treeDefaultExpandAll, level + 1)];\n }\n }\n }\n return result;\n};\n\n/**\n * 获取所有展开的节点 (组件传入最后一层,需要将其上层全部加入到expandedKeys)\n * @param {*} treeDataWithKeys\n * @param {*} treeExpandedKeys\n * @param {*} result\n * @returns\n */\nexport const getFullExpandedKeys = (treeDataWithKeys, treeExpandedKeys = [], treeDefaultExpandAll, result = []) => {\n if (\n !treeDefaultExpandAll &&\n (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(treeExpandedKeys) || !treeExpandedKeys.length)\n ) {\n return [];\n }\n\n treeDataWithKeys.forEach((i) => {\n const { childrenValues, value, children } = i;\n\n if (treeDefaultExpandAll || (Array.isArray(childrenValues) && [...childrenValues, value].some((el) => treeExpandedKeys.includes(el)))) {\n result.push(value);\n\n if (Array.isArray(children) && !!children.length) {\n result = [...result, ...getFullExpandedKeys(children, treeExpandedKeys, treeDefaultExpandAll)];\n }\n }\n });\n\n return result;\n};\n\n/**\n * 初始化根据用户传入的值获取其关联节点是否要在checkList\n * @param {*} treeDataWithKeys\n * @param {*} transCheckedKeys\n * @param {*} result\n * @returns\n */\nexport const getFullCheckedKeys = (treeDataWithKeys, transCheckedKeys, result = []) => {\n if (!Array.isArray(treeDataWithKeys) || !treeDataWithKeys.length || !Array.isArray(transCheckedKeys) || !transCheckedKeys.length) {\n return [];\n }\n\n treeDataWithKeys.forEach((i) => {\n const { value, children, disabled } = i;\n const bingo = transCheckedKeys.includes(value);\n if (bingo) {\n result.push(value);\n }\n\n if (Array.isArray(children) && !!children.length) {\n const lastestUnDisabledChildrenValues = i.needCheckedLastestChildrenValues;\n // 如果当前节点是被命中,就将其下面所有子节点都选中\n if (\n Array.isArray(lastestUnDisabledChildrenValues) &&\n !!lastestUnDisabledChildrenValues.length &&\n lastestUnDisabledChildrenValues.every((el) => transCheckedKeys.includes(el))\n ) {\n result.push(value);\n }\n result = [...result, ...getFullCheckedKeys(children, transCheckedKeys)];\n }\n });\n\n return result;\n};\n\n/**\n * 递归获取某个节点所有最下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了\n * @param {*} node\n * @param {*} node\n * @returns\n */\nexport const getNodeNoDisabledLastestChildrenValues = (node, fieldNames, result = []) => {\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n if (!element[fieldNames['disabled']]) {\n result = [...result, ...getNodeNoDisabledLastestChildrenValues(element, fieldNames)];\n }\n });\n } else {\n if (!node[fieldNames['disabled']]) {\n result.push(node[fieldNames['value']]);\n }\n }\n return result;\n};\n\n/**\n * 递归获取某个节点所有下层(没有children)的values集合,递归遇到disable的节点就不继续往下递归了\n * @param {*} node\n * @param {*} node\n * @returns\n */\nexport const getNodeNoDisabledChildrenValues = (node, fieldNames, result = []) => {\n if (Array.isArray(node.children) && !!node.children.length) {\n node.children.forEach((element) => {\n if (!element[fieldNames['disabled']]) {\n result.push(element[fieldNames['value']]);\n result = [...result, ...getNodeNoDisabledChildrenValues(element, fieldNames)];\n }\n });\n } else {\n if (!node[fieldNames['disabled']]) {\n result.push(node[fieldNames['value']]);\n }\n }\n return result;\n}\n\n/**\n * 判断当前节点是否半选\n * @param {*} item\n * @param {*} checkedList\n */\nexport const getIndeterminate = (item, checkedList, disabledList) => {\n // 如果没有子节点,就没有半选情况\n if (!Array.isArray(item.children) || !item.children.length) {\n return false;\n }\n\n if (!Array.isArray(checkedList) || !checkedList.length) {\n return false;\n }\n\n // 当前节点下的去掉disabled的所有末级节点\n const list = Array.isArray(item.needCheckedLastestChildrenValues) ? item.needCheckedLastestChildrenValues : [];\n const childrenCheckedList = list.filter((i) => checkedList?.includes(i));\n\n return childrenCheckedList.length > 0 && childrenCheckedList.length < list.length;\n};\n\n/**\n * 获取当前节点的父亲节点是否需要被选中\n * @param {*} needCheckedSiblingsValue\n * @param {*} checkedList\n * @returns\n */\nexport const getNodeParentChoosed = (needCheckedSiblingsValue, checkedList) => {\n if (!Array.isArray(checkedList) || !checkedList.length) {\n return [];\n }\n let result = [];\n for (let item of needCheckedSiblingsValue) {\n const { key, list } = item || {};\n // 过滤掉子节点为disabled的\n const bool = Array.isArray(list) ? list.every((it) => checkedList.includes(it)) : false;\n if (bool) {\n checkedList.push(key);\n result.push(key);\n }\n }\n\n return result;\n};\n\n/**\n * 获取节点的信息\n * @param {*} tree \n * @param {*} key \n * @param {*} result \n * @returns \n */\nexport const findNodeDetail = (tree, key, result) => {\n if (Array.isArray(tree) && !!key) {\n for (let i of tree) {\n if (i.value === key) {\n result = i;\n break;\n }\n if (Array.isArray(i.children) && !!i.children.length) {\n result = findNodeDetail(i.children, key);\n if (result) {\n break;\n }\n }\n }\n }\n\n return result;\n};\n"]}
@@ -1,16 +1,25 @@
1
1
  export default TntdVirtualTreeSelect;
2
- declare function TntdVirtualTreeSelect({ value, onChange, renderItem, treeData, showSearch, treeDefaultExpandAll, treeExpandedKeys, fieldNames, dropdownMatchSelectWidth, dropdownStyle, ...restProps }: {
2
+ declare function TntdVirtualTreeSelect({ value, onChange, treeData, showSearch, fieldNames, dropdownMatchSelectWidth, dropdownStyle, showCheckedStrategy, treeCheckable, treeCheckStrictly, treeDefaultExpandAll, treeExpandedKeys, onTreeCheck, onTreeExpand, treeTitleRender, ...restProps }: {
3
3
  [x: string]: any;
4
4
  value: any;
5
5
  onChange: any;
6
- renderItem: any;
7
6
  treeData: any;
8
7
  showSearch: any;
9
- treeDefaultExpandAll: any;
10
- treeExpandedKeys: any;
11
8
  fieldNames: any;
12
9
  dropdownMatchSelectWidth: any;
13
10
  dropdownStyle: any;
11
+ showCheckedStrategy: any;
12
+ treeCheckable: any;
13
+ treeCheckStrictly: any;
14
+ treeDefaultExpandAll: any;
15
+ treeExpandedKeys: any;
16
+ onTreeCheck: any;
17
+ onTreeExpand: any;
18
+ treeTitleRender: any;
14
19
  }): React.JSX.Element;
20
+ declare namespace TntdVirtualTreeSelect {
21
+ const SHOW_CHILD: string;
22
+ const SHOW_ALL: string;
23
+ }
15
24
  import React from "react";
16
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/index.jsx"],"names":[],"mappings":";AAYA;;;;;;;;;;;;sBA0BC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/index.jsx"],"names":[],"mappings":";AAaA;;;;;;;;;;;;;;;;;sBAoHC"}
@@ -7,11 +7,18 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports["default"] = void 0;
8
8
  var _react = _interopRequireWildcard(require("react"));
9
9
  var _tntdRcSelect = _interopRequireDefault(require("../tntd-rc-select"));
10
- var _VirtualTree = _interopRequireDefault(require("./VirtualTree"));
10
+ var _tntdVirtualTree = _interopRequireDefault(require("../tntd-virtual-tree"));
11
+ var _utils = require("./utils.js");
11
12
  require("./index.less");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
16
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
+ 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."); }
18
+ 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); }
19
+ 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; }
20
+ 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; } }
21
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
22
  var __rest = void 0 && (void 0).__rest || function (s, e) {
16
23
  var t = {};
17
24
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
@@ -25,50 +32,124 @@ var __rest = void 0 && (void 0).__rest || function (s, e) {
25
32
  * @Author: 郑泳健
26
33
  * @Date: 2024-08-05 10:50:17
27
34
  * @LastEditors: 郑泳健
28
- * @LastEditTime: 2024-08-05 15:00:41
35
+ * @LastEditTime: 2024-08-20 15:03:16
29
36
  */
30
37
 
31
38
  var TntdVirtualTreeSelect = function TntdVirtualTreeSelect(_a) {
32
39
  var value = _a.value,
33
40
  onChange = _a.onChange,
34
- renderItem = _a.renderItem,
35
41
  treeData = _a.treeData,
36
42
  showSearch = _a.showSearch,
37
- treeDefaultExpandAll = _a.treeDefaultExpandAll,
38
- treeExpandedKeys = _a.treeExpandedKeys,
39
43
  fieldNames = _a.fieldNames,
40
44
  dropdownMatchSelectWidth = _a.dropdownMatchSelectWidth,
41
45
  dropdownStyle = _a.dropdownStyle,
42
- restProps = __rest(_a, ["value", "onChange", "renderItem", "treeData", "showSearch", "treeDefaultExpandAll", "treeExpandedKeys", "fieldNames", "dropdownMatchSelectWidth", "dropdownStyle"]);
46
+ showCheckedStrategy = _a.showCheckedStrategy,
47
+ treeCheckable = _a.treeCheckable,
48
+ treeCheckStrictly = _a.treeCheckStrictly,
49
+ treeDefaultExpandAll = _a.treeDefaultExpandAll,
50
+ treeExpandedKeys = _a.treeExpandedKeys,
51
+ onTreeCheck = _a.onTreeCheck,
52
+ onTreeExpand = _a.onTreeExpand,
53
+ treeTitleRender = _a.treeTitleRender,
54
+ restProps = __rest(_a, ["value", "onChange", "treeData", "showSearch", "fieldNames", "dropdownMatchSelectWidth", "dropdownStyle", "showCheckedStrategy", "treeCheckable", "treeCheckStrictly", "treeDefaultExpandAll", "treeExpandedKeys", "onTreeCheck", "onTreeExpand", "treeTitleRender"]);
55
+ var selectRef = (0, _react.useRef)(null);
56
+ var _useState = (0, _react.useState)(undefined),
57
+ _useState2 = _slicedToArray(_useState, 2),
58
+ filterKey = _useState2[0],
59
+ setFilterKey = _useState2[1];
43
60
  var mergeDropdownStyle = (0, _react.useMemo)(function () {
44
61
  return Array.isArray(treeData) && treeData.length ? dropdownStyle : {};
45
62
  }, [dropdownStyle, treeData]);
46
63
  var mergeDropdownMatchSelectWidth = (0, _react.useMemo)(function () {
47
64
  return Array.isArray(treeData) && treeData.length ? dropdownMatchSelectWidth : true;
48
65
  }, [dropdownMatchSelectWidth, treeData]);
49
- var handleRender = function handleRender(rest) {
66
+ var treeNodeWithParents = (0, _react.useMemo)(function () {
67
+ return (0, _utils.flatWithParents)(treeData, fieldNames);
68
+ }, [treeData, fieldNames]);
69
+ var selectValue = (0, _react.useMemo)(function () {
70
+ if (!treeCheckable) {
71
+ return value;
72
+ }
73
+ if (Array.isArray(value)) {
74
+ if (showCheckedStrategy === TntdVirtualTreeSelect.SHOW_ALL) {
75
+ return value;
76
+ }
77
+ // 过滤掉有子节点,
78
+ return value.filter(function (i) {
79
+ return (0, _utils.filterLastestNode)(treeNodeWithParents, i, value);
80
+ });
81
+ }
82
+ return undefined;
83
+ }, [treeCheckable, treeNodeWithParents, value, showCheckedStrategy]);
84
+ var mergeMode = (0, _react.useMemo)(function () {
85
+ if (treeCheckable) {
86
+ return {
87
+ multiple: true,
88
+ mode: 'tags'
89
+ };
90
+ }
91
+ return {};
92
+ }, [treeCheckable]);
93
+ var handleRender = function handleRender(_a) {
94
+ var showSearch = _a.showSearch,
95
+ rest = __rest(_a, ["showSearch"]);
50
96
  return _react["default"].createElement("div", {
51
- className: 'virtual-tree-options'
52
- }, _react["default"].createElement(_VirtualTree["default"], Object.assign({}, rest)));
97
+ className: "virtual-tree-options"
98
+ }, _react["default"].createElement(_tntdVirtualTree["default"], Object.assign({}, rest)));
99
+ };
100
+ var handleChange = function handleChange(val) {
101
+ onChange(val);
102
+ };
103
+ var handleSearch = function handleSearch(val) {
104
+ setFilterKey(val);
53
105
  };
54
- return _react["default"].createElement(_tntdRcSelect["default"], Object.assign({}, restProps, {
106
+ var handleSelect = function handleSelect(val) {
107
+ var _a;
108
+ onChange === null || onChange === void 0 ? void 0 : onChange(val);
109
+ if (selectRef.current) {
110
+ // 主动触发下拉框消失
111
+ (_a = selectRef.current) === null || _a === void 0 ? void 0 : _a.blur();
112
+ }
113
+ };
114
+ return _react["default"].createElement(_tntdRcSelect["default"], Object.assign({
115
+ ref: selectRef,
116
+ value: selectValue,
117
+ onChange: handleChange,
118
+ showSearch: showSearch,
119
+ onSearch: handleSearch
120
+ }, mergeMode, restProps, {
55
121
  dropdownMatchSelectWidth: mergeDropdownMatchSelectWidth,
56
122
  dropdownStyle: Object.assign({
57
123
  maxHeight: '100vh',
58
124
  overflow: 'auto'
59
125
  }, mergeDropdownStyle),
60
126
  dropdownRender: function dropdownRender() {
61
- return handleRender({
62
- value: value,
63
- onChange: onChange,
64
- renderItem: renderItem,
127
+ var obj = {
65
128
  treeData: treeData,
66
- showSearch: showSearch,
67
- treeDefaultExpandAll: treeDefaultExpandAll,
68
- treeExpandedKeys: treeExpandedKeys,
69
- fieldNames: fieldNames
70
- });
129
+ filterKey: filterKey,
130
+ defaultExpandAll: treeDefaultExpandAll,
131
+ expandedKeys: treeExpandedKeys,
132
+ fieldNames: fieldNames,
133
+ onExpand: onTreeExpand,
134
+ titleRender: treeTitleRender,
135
+ onSelect: handleSelect
136
+ };
137
+ if (treeCheckable) {
138
+ obj = Object.assign(Object.assign({}, obj), {
139
+ checkedKeys: value,
140
+ checkStrictly: treeCheckStrictly,
141
+ checkable: treeCheckable,
142
+ onCheck: onTreeCheck
143
+ });
144
+ } else {
145
+ obj = Object.assign(Object.assign({}, obj), {
146
+ value: value
147
+ });
148
+ }
149
+ return handleRender(obj);
71
150
  }
72
151
  }));
73
152
  };
153
+ TntdVirtualTreeSelect.SHOW_CHILD = 'SHOW_CHILD';
154
+ TntdVirtualTreeSelect.SHOW_ALL = 'SHOW_ALL';
74
155
  var _default = exports["default"] = TntdVirtualTreeSelect;
@@ -1 +1 @@
1
- {"version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AkB,GAC5E,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,UAAU,EAAE,CAAC,IAC7I,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,kBAAe,qBAAqB,CAAA","sourcesContent":["/*\n * @Descripttion: 用select包裹虚拟树\n * @Author: 郑泳健\n * @Date: 2024-08-05 10:50:17\n * @LastEditors: 郑泳健\n * @LastEditTime: 2024-08-05 15:00:41\n */\nimport React, { useState, useMemo } from 'react';\nimport RcSelect from '../tntd-rc-select'\nimport VirtualTree from './VirtualTree';\nimport './index.less';\n\nconst TntdVirtualTreeSelect = ({ value, onChange, renderItem, treeData, showSearch, treeDefaultExpandAll, treeExpandedKeys, fieldNames, dropdownMatchSelectWidth, dropdownStyle, ...restProps }) => {\n \n const mergeDropdownStyle = useMemo(() => {\n return Array.isArray(treeData) && treeData.length ? dropdownStyle : {}\n }, [dropdownStyle, treeData])\n\n const mergeDropdownMatchSelectWidth = useMemo(() => {\n return Array.isArray(treeData) && treeData.length ? dropdownMatchSelectWidth : true\n }, [dropdownMatchSelectWidth, treeData])\n\n const handleRender = (rest) => {\n return (\n <div className='virtual-tree-options'>\n <VirtualTree {...rest} />\n </div>\n )\n }\n\n return (\n <RcSelect\n {...restProps}\n dropdownMatchSelectWidth={mergeDropdownMatchSelectWidth}\n dropdownStyle={{ maxHeight: '100vh', overflow: 'auto', ...mergeDropdownStyle }}\n dropdownRender={() => handleRender({ value, onChange, renderItem, treeData, showSearch, treeDefaultExpandAll, treeExpandedKeys, fieldNames })}\n />\n );\n};\n\nexport default TntdVirtualTreeSelect\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/index.jsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,+C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Time: 2024-08-20 15:03:16\n */\nimport React, { useState, useRef, useMemo } from 'react';\nimport RcSelect from '../tntd-rc-select';\nimport TntdVirtualTree from '../tntd-virtual-tree';\nimport { filterLastestNode, flatWithParents } from './utils.js'\nimport './index.less';\n\nconst TntdVirtualTreeSelect = ({\n value,\n onChange,\n treeData,\n showSearch,\n fieldNames,\n dropdownMatchSelectWidth,\n dropdownStyle,\n showCheckedStrategy,\n treeCheckable,\n treeCheckStrictly,\n treeDefaultExpandAll,\n treeExpandedKeys,\n onTreeCheck,\n onTreeExpand,\n treeTitleRender,\n ...restProps\n}) => {\n const selectRef = useRef(null);\n const [filterKey, setFilterKey] = useState(undefined);\n\n const mergeDropdownStyle = useMemo(() => {\n return Array.isArray(treeData) && treeData.length ? dropdownStyle : {};\n }, [dropdownStyle, treeData]);\n\n const mergeDropdownMatchSelectWidth = useMemo(() => {\n return Array.isArray(treeData) && treeData.length ? dropdownMatchSelectWidth : true;\n }, [dropdownMatchSelectWidth, treeData]);\n\n const treeNodeWithParents = useMemo(() => {\n return flatWithParents(treeData, fieldNames)\n }, [treeData, fieldNames])\n\n const selectValue = useMemo(() => {\n if(!treeCheckable) {\n return value\n }\n\n if(Array.isArray(value)) {\n if(showCheckedStrategy === TntdVirtualTreeSelect.SHOW_ALL) {\n return value;\n }\n // 过滤掉有子节点,\n return value.filter(i => {\n return filterLastestNode(treeNodeWithParents, i, value)\n })\n }\n return undefined\n\n }, [treeCheckable, treeNodeWithParents, value, showCheckedStrategy])\n\n const mergeMode = useMemo(() => {\n if(treeCheckable) {\n return {\n multiple: true,\n mode: 'tags'\n }\n }\n return {}\n }, [treeCheckable])\n\n const handleRender = ({ showSearch, ...rest }) => {\n return (\n <div className=\"virtual-tree-options\">\n <TntdVirtualTree {...rest} />\n </div>\n );\n };\n\n const handleChange = (val) => {\n onChange(val);\n };\n\n const handleSearch = (val) => {\n setFilterKey(val);\n };\n\n const handleSelect = (val) => {\n onChange?.(val);\n if (selectRef.current) {\n // 主动触发下拉框消失\n selectRef.current?.blur();\n }\n };\n\n return (\n <RcSelect\n ref={selectRef}\n value={selectValue}\n onChange={handleChange}\n showSearch={showSearch}\n onSearch={handleSearch}\n {...mergeMode}\n {...restProps}\n dropdownMatchSelectWidth={mergeDropdownMatchSelectWidth}\n dropdownStyle={{ maxHeight: '100vh', overflow: 'auto', ...mergeDropdownStyle }}\n dropdownRender={() => {\n let obj = {\n treeData,\n filterKey,\n defaultExpandAll: treeDefaultExpandAll,\n expandedKeys: treeExpandedKeys,\n fieldNames,\n onExpand: onTreeExpand,\n titleRender: treeTitleRender,\n onSelect: handleSelect\n };\n if (treeCheckable) {\n obj = { ...obj, checkedKeys: value, checkStrictly: treeCheckStrictly, checkable: treeCheckable, onCheck: onTreeCheck };\n } else {\n obj = { ...obj, value };\n }\n return handleRender(obj);\n }}\n />\n );\n};\n\nTntdVirtualTreeSelect.SHOW_CHILD = 'SHOW_CHILD'\nTntdVirtualTreeSelect.SHOW_ALL = 'SHOW_ALL'\n\nexport default TntdVirtualTreeSelect;\n"]}
@@ -1,10 +1,3 @@
1
- export function addTreeNodeKeys(treeData: any, fieldNames?: {
2
- title: string;
3
- value: string;
4
- children: string;
5
- }): any[];
6
- export function getNodeStr(node: any, key: any, result?: any[]): any[];
7
- export function getNodeKeys(node: any, widthSelf?: any, result?: any): any;
8
- export function flatTreeData(treeData: any, filterKey?: string, expandedKeys?: any, treeDefaultExpandAll?: any, level?: any, result?: any): any;
9
- export function getFullExpandedKeys(treeDataWithKeys: any, treeExpandedKeys: any, treeDefaultExpandAll: any, result?: any): any;
1
+ export function flatWithParents(treeData: any, fieldNames?: any, parents?: any, result?: {}): {};
2
+ export function filterLastestNode(treeNodeWithParents: any, item: any, list: any): boolean;
10
3
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/utils.js"],"names":[],"mappings":"AAKO;;;;UAqBN;AAEM,uEAUN;AASM,2EAYN;AAWM,gJAuBN;AASM,gIAkBN"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/utils.js"],"names":[],"mappings":"AAOO,iGAaN;AAEM,2FAQN"}