fan-standard-comp 3.2.11 → 3.2.12

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 (88) hide show
  1. package/dist/fan-standard-comp.umd.js +150 -150
  2. package/es/FormComp/FieldComponent/RefactorTreeSelect.d.ts +4 -0
  3. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +96 -221
  4. package/es/FormComp/FieldComponent/index.js +1 -1
  5. package/es/RefactorTree/util.d.ts +4 -3
  6. package/es/RefactorTree/util.js +52 -8
  7. package/es/hooks/use-language.d.ts +2 -0
  8. package/es/hooks/use-language.js +44 -0
  9. package/es/hooks/use-throttle.d.ts +1 -0
  10. package/es/hooks/use-throttle.js +33 -0
  11. package/es/locales/bn-BD/settings.d.ts +34 -0
  12. package/es/locales/bn-BD/settings.js +36 -0
  13. package/es/locales/bn-BD.d.ts +35 -0
  14. package/es/locales/bn-BD.js +4 -0
  15. package/es/locales/en-US/settings.d.ts +34 -0
  16. package/es/locales/en-US/settings.js +36 -0
  17. package/es/locales/en-US.d.ts +35 -0
  18. package/es/locales/en-US.js +4 -0
  19. package/es/locales/fa-IR/settings.d.ts +34 -0
  20. package/es/locales/fa-IR/settings.js +36 -0
  21. package/es/locales/fa-IR.d.ts +35 -0
  22. package/es/locales/fa-IR.js +4 -0
  23. package/es/locales/id-ID/settings.d.ts +34 -0
  24. package/es/locales/id-ID/settings.js +36 -0
  25. package/es/locales/id-ID.d.ts +35 -0
  26. package/es/locales/id-ID.js +4 -0
  27. package/es/locales/ja-JP/settings.d.ts +33 -0
  28. package/es/locales/ja-JP/settings.js +35 -0
  29. package/es/locales/ja-JP.d.ts +34 -0
  30. package/es/locales/ja-JP.js +4 -0
  31. package/es/locales/pt-BR/settings.d.ts +34 -0
  32. package/es/locales/pt-BR/settings.js +36 -0
  33. package/es/locales/pt-BR.d.ts +35 -0
  34. package/es/locales/pt-BR.js +4 -0
  35. package/es/locales/zh-CN/settings.d.ts +34 -0
  36. package/es/locales/zh-CN/settings.js +36 -0
  37. package/es/locales/zh-CN.d.ts +35 -0
  38. package/es/locales/zh-CN.js +4 -0
  39. package/es/locales/zh-TW/settings.d.ts +34 -0
  40. package/es/locales/zh-TW/settings.js +36 -0
  41. package/es/locales/zh-TW.d.ts +34 -0
  42. package/es/locales/zh-TW.js +2 -0
  43. package/es/utils/getParentNodes.d.ts +109 -0
  44. package/es/utils/getParentNodes.js +119 -20
  45. package/lib/FormComp/FieldComponent/RefactorTreeSelect.d.ts +4 -0
  46. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +94 -218
  47. package/lib/FormComp/FieldComponent/index.js +1 -1
  48. package/lib/RefactorTree/util.d.ts +4 -3
  49. package/lib/RefactorTree/util.js +51 -9
  50. package/lib/hooks/use-language.d.ts +2 -0
  51. package/lib/hooks/use-language.js +51 -0
  52. package/lib/hooks/use-throttle.d.ts +1 -0
  53. package/lib/hooks/use-throttle.js +38 -0
  54. package/lib/locales/bn-BD/settings.d.ts +34 -0
  55. package/lib/locales/bn-BD/settings.js +42 -0
  56. package/lib/locales/bn-BD.d.ts +35 -0
  57. package/lib/locales/bn-BD.js +11 -0
  58. package/lib/locales/en-US/settings.d.ts +34 -0
  59. package/lib/locales/en-US/settings.js +42 -0
  60. package/lib/locales/en-US.d.ts +35 -0
  61. package/lib/locales/en-US.js +11 -0
  62. package/lib/locales/fa-IR/settings.d.ts +34 -0
  63. package/lib/locales/fa-IR/settings.js +42 -0
  64. package/lib/locales/fa-IR.d.ts +35 -0
  65. package/lib/locales/fa-IR.js +11 -0
  66. package/lib/locales/id-ID/settings.d.ts +34 -0
  67. package/lib/locales/id-ID/settings.js +42 -0
  68. package/lib/locales/id-ID.d.ts +35 -0
  69. package/lib/locales/id-ID.js +11 -0
  70. package/lib/locales/ja-JP/settings.d.ts +33 -0
  71. package/lib/locales/ja-JP/settings.js +41 -0
  72. package/lib/locales/ja-JP.d.ts +34 -0
  73. package/lib/locales/ja-JP.js +11 -0
  74. package/lib/locales/pt-BR/settings.d.ts +34 -0
  75. package/lib/locales/pt-BR/settings.js +42 -0
  76. package/lib/locales/pt-BR.d.ts +35 -0
  77. package/lib/locales/pt-BR.js +11 -0
  78. package/lib/locales/zh-CN/settings.d.ts +34 -0
  79. package/lib/locales/zh-CN/settings.js +42 -0
  80. package/lib/locales/zh-CN.d.ts +35 -0
  81. package/lib/locales/zh-CN.js +11 -0
  82. package/lib/locales/zh-TW/settings.d.ts +34 -0
  83. package/lib/locales/zh-TW/settings.js +42 -0
  84. package/lib/locales/zh-TW.d.ts +34 -0
  85. package/lib/locales/zh-TW.js +9 -0
  86. package/lib/utils/getParentNodes.d.ts +109 -0
  87. package/lib/utils/getParentNodes.js +118 -22
  88. package/package.json +1 -1
@@ -1,15 +1,20 @@
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
  });
6
- exports.getParentNodes = exports.getNodePaths = exports.getChildrenNodes = exports.convertToArray = exports.arrayToTree = void 0;
7
- 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); }
8
- 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; }
9
- 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; }
7
+ exports.getParentNodes = exports.getNodePaths = exports.getNode = exports.getChildrenNodes = exports.filterTreeNodes = exports.convertToArray = exports.arrayToTree = exports.addTreeLevels = void 0;
10
8
  function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
11
9
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
12
10
  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); }
11
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
12
+ 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."); }
13
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
14
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
15
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
16
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
17
+ // @ts-nocheck
13
18
  /**
14
19
  * @description 递归查看父级节点数据集合及当前节点数据
15
20
  * @params {Array} list 当前需要过滤查看的数据集合、
@@ -90,7 +95,6 @@ var getParentNodes = exports.getParentNodes = function getParentNodes(list, node
90
95
  }
91
96
  return matchNode; // 返回查找到的节点数据(格式为数组)
92
97
  };
93
-
94
98
  // 查找单个节点
95
99
  var _findMatchItem = function findMatchItem(arrList, key) {
96
100
  var matchItem;
@@ -126,10 +130,9 @@ var getParentNodes = exports.getParentNodes = function getParentNodes(list, node
126
130
  matchNode: matchNode
127
131
  }; // 最终查找到的父节点数组 // nodeParent.concat(result || []);
128
132
  };
129
-
130
133
  /**
131
- * @description 递归查找指定ID所有的子菜单与子功能集合
132
- * @params {Array} childNode 当前需要过滤查看的数据集合、
134
+ * @description 递归查找指定节点的所有子菜单与子功能集合
135
+ * @params {Array} childNode 当前需要过滤查看的子数据集合、
133
136
  * @params {Object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
134
137
  * (childrenParam:指当前子集合数据字段名(字符串表示单个,数组表示当前多个子集合字段名),keyParam: 指当前匹配标识值字段名)
135
138
  * @params {Object} extra
@@ -137,7 +140,6 @@ var getParentNodes = exports.getParentNodes = function getParentNodes(list, node
137
140
  * @result {Array} childKeys 所有子项的id
138
141
  * @result {Array} nodeChildren 当前传入nodeKey值所在的数据对象集合
139
142
  * */
140
-
141
143
  var getChildrenNodes = exports.getChildrenNodes = function getChildrenNodes(childNode) {
142
144
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
143
145
  childrenParam: 'children',
@@ -158,15 +160,15 @@ var getChildrenNodes = exports.getChildrenNodes = function getChildrenNodes(chil
158
160
  nodeChildren: nodeChildren
159
161
  };
160
162
  };
161
-
162
163
  /**
163
- * @description 查找节点路径
164
+ * @description 查找指定节点或节点集合的完整路径数据
164
165
  * @params {Array} list 查询的数据源
165
- * @params {Array} nodeKey 需要查询的key集合
166
+ * @params {Array | String | Number} nodeKey 需要查询的key集合
166
167
  * @params {Object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
167
168
  * (childrenParam:指当前子集合数据字段名(字符串表示单个,数组表示当前多个子集合字段名),keyParam: 指当前匹配标识值字段名)
168
169
  *
169
- * @result {Array} 所有匹配到的层级数据
170
+ * @result {Array} 所有匹配到的层级数据(如果nodeKey是数组,则返回的节点集合会分别按顺序存到数组内
171
+ *
170
172
  * */
171
173
  var getNodePaths = exports.getNodePaths = function getNodePaths(list, nodeKey) {
172
174
  var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
@@ -195,7 +197,6 @@ var getNodePaths = exports.getNodePaths = function getNodePaths(list, nodeKey) {
195
197
  nodePathArray.pop();
196
198
  }
197
199
  };
198
-
199
200
  // 用于存储节点唯一标识值路径数组
200
201
  var nodePathArray = [];
201
202
  try {
@@ -212,17 +213,42 @@ var getNodePaths = exports.getNodePaths = function getNodePaths(list, nodeKey) {
212
213
  var pathItems = getPathByKey(key, list);
213
214
  if (pathItems) pathNode.push(pathItems);
214
215
  });
216
+ } else if (typeof nodeKey === 'string') {
217
+ var pathItems = getPathByKey(nodeKey, list);
218
+ pathNode = pathItems || [];
215
219
  }
216
220
  return pathNode;
217
221
  };
218
-
219
222
  /**
220
- * 数组转树形结构
221
- * @param {array} list 被转换的数组
222
- * @param {number|string} root 根节点(最外层节点)的 id
223
- * @param {object} params 字段值(默认 { keyParam: 'id', parentParam: 'parentId' })
224
- * @return array
223
+ * @description 查找节点数据:点击获取对应ID的完整数据(即从树数据中深层查找与ID值相匹配的相关数据对象)
224
+ *
225
+ * @param [array] list 需要过滤的数据
226
+ * @param [string] key 指定过滤的key值
227
+ * @param [Object] optionName 指定value与children相关字段名
228
+ *
229
+ * @data list:<array:[{ value: '', label: '', children: []}]> 列表数据格式
225
230
  */
231
+ var getNode = exports.getNode = function getNode(list, key) {
232
+ var optionName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
233
+ value: 'value',
234
+ children: 'children'
235
+ };
236
+ var matchCurrentItem = {};
237
+ // 深层过滤当前选中的节点
238
+ var _deepFilterMatchItem = function deepFilterMatchItem(treeData, targetId) {
239
+ (treeData || []).some(function (item) {
240
+ if (item[optionName.value] == targetId) {
241
+ matchCurrentItem = item;
242
+ return true;
243
+ }
244
+ if (item[optionName.children]) {
245
+ _deepFilterMatchItem(item[optionName.children], targetId); // 没有查找到继续过滤
246
+ }
247
+ });
248
+ };
249
+ _deepFilterMatchItem(list, key);
250
+ return matchCurrentItem;
251
+ };
226
252
  /**
227
253
  * 数组转树形结构
228
254
  * @param {array} list 被转换的数组
@@ -253,7 +279,6 @@ var _arrayToTree = exports.arrayToTree = function arrayToTree(list, rootId) {
253
279
  * @param {array} tree 被转换的树(仅限于只有一个根的树
254
280
  * @return array
255
281
  */
256
-
257
282
  var convertToArray = exports.convertToArray = function convertToArray(tree) {
258
283
  var _ref2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
259
284
  _ref2$keyParam = _ref2.keyParam,
@@ -267,7 +292,7 @@ var convertToArray = exports.convertToArray = function convertToArray(tree) {
267
292
  tree.forEach(function (item) {
268
293
  var _loop = function loop(data) {
269
294
  sortCount++;
270
- result.push(_objectSpread(_objectSpread({}, data), {}, {
295
+ result.push(Object.assign(Object.assign({}, data), {
271
296
  sort: sortCount
272
297
  }));
273
298
  var child = data[childrenParam];
@@ -280,4 +305,75 @@ var convertToArray = exports.convertToArray = function convertToArray(tree) {
280
305
  _loop(item);
281
306
  });
282
307
  return result;
308
+ };
309
+ /**
310
+ * 树过滤(默认按名称过滤,也可按指定的字段名过滤)
311
+ * @param {array} list 需要过滤的树
312
+ * @param {string | number} nodeKey 需要筛选的名称(默认搜索名称,如果需要指定其他字段值,则参数传object
313
+ * @param {object} params 指定当前数据中,筛选对应子集合字段名及匹配标识值字段名
314
+ * @value { childrenParam: 'children', keyParam: 'name' } childrenParam:指当前子集合数据字段名,keyParam: 指当前匹配标识值字段名)
315
+ *
316
+ * @return array 返回新的数组
317
+ * */
318
+ var _filterTreeNodes = exports.filterTreeNodes = function filterTreeNodes(list, nodeKey) {
319
+ var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
320
+ childrenParam: 'children',
321
+ keyParam: 'name'
322
+ };
323
+ var result = [];
324
+ var filterList = _toConsumableArray(list);
325
+ filterList.forEach(function (item) {
326
+ var nItem = null;
327
+ if (item[params.keyParam || 'name'].toLowerCase().includes(nodeKey.toLowerCase())) {
328
+ nItem = Object.assign(Object.assign({}, item), _defineProperty({}, params.childrenParam || 'children', []));
329
+ }
330
+ if (item[params.childrenParam || 'children'] && item[params.childrenParam || 'children'].length) {
331
+ var subList = _filterTreeNodes(item[params.childrenParam || 'children'], nodeKey, params);
332
+ if (subList.length) {
333
+ nItem = Object.assign(Object.assign({}, item), _defineProperty({}, params.childrenParam || 'children', subList));
334
+ }
335
+ }
336
+ if (nItem) {
337
+ result.push(nItem);
338
+ }
339
+ });
340
+ return result;
341
+ };
342
+ // 给节点每个层级加上level,并且将当前节点完整的路径序号值拼接起来
343
+ /**
344
+ * @param {Array} data 树数组数据
345
+ * @param {Number} level 起始层级序号
346
+ * @param {Number} level 起始层级序号
347
+ * @param {Array} parentIndexPath 父级序号集合
348
+ * @param {Array} parentNamePath 父级名称集合
349
+ * @param {Object} optionName 指定字段名 {children: '', label: '', title: '', name: ''}
350
+ * @param {Object} extra 扩展配置 {separator: '/'}
351
+ * */
352
+ var _addTreeLevels = exports.addTreeLevels = function addTreeLevels(data) {
353
+ var level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
354
+ var parentIndexPath = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
355
+ var parentNamePath = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
356
+ var optionName = arguments.length > 4 ? arguments[4] : undefined;
357
+ var extra = arguments.length > 5 ? arguments[5] : undefined;
358
+ if (!Array.isArray(data)) return [];
359
+ return data.map(function (item, index) {
360
+ // 创建当前节点副本
361
+ // 完整的名称路径
362
+ var fullNamePath = _toConsumableArray(parentNamePath).concat(item[(optionName === null || optionName === void 0 ? void 0 : optionName.title) || (optionName === null || optionName === void 0 ? void 0 : optionName.label) || 'label' || 'title'] ? [item[(optionName === null || optionName === void 0 ? void 0 : optionName.title) || (optionName === null || optionName === void 0 ? void 0 : optionName.label) || 'label' || 'title']] : []);
363
+ var node = Object.assign(Object.assign({}, item), {
364
+ treeNodeLevel: level,
365
+ treeParentIndexPath: _toConsumableArray(parentIndexPath),
366
+ treeParentNamePath: _toConsumableArray(parentNamePath),
367
+ treeFullLevelNamePath: fullNamePath,
368
+ treeFullLevelName: fullNamePath.join((extra === null || extra === void 0 ? void 0 : extra.separator) || '/')
369
+ });
370
+ // 当前节点的完整路径(用于构建子节点的父级路径)
371
+ var currentIndexPath = [].concat(_toConsumableArray(parentIndexPath), [index]);
372
+ var currentNamePath = [].concat(_toConsumableArray(parentNamePath), [item[(optionName === null || optionName === void 0 ? void 0 : optionName.title) || (optionName === null || optionName === void 0 ? void 0 : optionName.label) || 'label' || 'title']]);
373
+ // 递归处理子节点
374
+ if (Array.isArray(node[(optionName === null || optionName === void 0 ? void 0 : optionName.children) || 'children']) && node[(optionName === null || optionName === void 0 ? void 0 : optionName.children) || 'children'].length > 0) {
375
+ node[(optionName === null || optionName === void 0 ? void 0 : optionName.children) || 'children'] = _addTreeLevels(node[(optionName === null || optionName === void 0 ? void 0 : optionName.children) || 'children'], level + 1, currentIndexPath, currentNamePath, optionName, extra);
376
+ }
377
+ return node;
378
+ });
283
379
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fan-standard-comp",
3
- "version": "3.2.11",
3
+ "version": "3.2.12",
4
4
  "description": "FZ standard-comp,basic of antd4.0 and custom component.",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",