tntd 3.0.12-beta.3 → 3.0.13

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 (34) hide show
  1. package/es/index.js +1 -1
  2. package/es/index.js.map +1 -1
  3. package/es/query-list-scene/List.js +1 -14
  4. package/es/query-list-scene/List.js.map +1 -1
  5. package/es/query-list-scene/QueryForm.js +3 -6
  6. package/es/query-list-scene/QueryForm.js.map +1 -1
  7. package/es/tntd-select/index.js.map +1 -1
  8. package/es/tntd-virtual-tree/index.less +3 -1
  9. package/es/tntd-virtual-tree-select/index.js +12 -7
  10. package/es/tntd-virtual-tree-select/index.js.map +1 -1
  11. package/es/tntd-virtual-tree-select/utils.js +34 -0
  12. package/es/tntd-virtual-tree-select/utils.js.map +1 -1
  13. package/lib/index.d.ts +1 -1
  14. package/lib/index.d.ts.map +1 -1
  15. package/lib/index.js +2 -2
  16. package/lib/index.js.map +1 -1
  17. package/lib/query-list-scene/List.d.ts.map +1 -1
  18. package/lib/query-list-scene/List.js +1 -15
  19. package/lib/query-list-scene/List.js.map +1 -1
  20. package/lib/query-list-scene/QueryForm.d.ts +2 -2
  21. package/lib/query-list-scene/QueryForm.d.ts.map +1 -1
  22. package/lib/query-list-scene/QueryForm.js +8 -10
  23. package/lib/query-list-scene/QueryForm.js.map +1 -1
  24. package/lib/tntd-select/index.d.ts.map +1 -1
  25. package/lib/tntd-select/index.js.map +1 -1
  26. package/lib/tntd-virtual-tree/index.less +3 -1
  27. package/lib/tntd-virtual-tree-select/index.d.ts.map +1 -1
  28. package/lib/tntd-virtual-tree-select/index.js +17 -6
  29. package/lib/tntd-virtual-tree-select/index.js.map +1 -1
  30. package/lib/tntd-virtual-tree-select/utils.d.ts +2 -0
  31. package/lib/tntd-virtual-tree-select/utils.d.ts.map +1 -1
  32. package/lib/tntd-virtual-tree-select/utils.js +38 -1
  33. package/lib/tntd-virtual-tree-select/utils.js.map +1 -1
  34. package/package.json +1 -1
@@ -1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AQ,GAAG,UAAU,CAAA;AAE3C,kBAAe,qBAAqB,CAAC","sourcesContent":["/*\n * @Descripttion: 用select包裹虚拟树\n * @Author: 郑泳健\n * @Date: 2024-08-05 10:50:17\n * @LastEditors: 郑泳健\n * @LastEditTime: 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
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/index.jsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;GAMG;AACH,+CAAyD;AACzD,uEAAyC;AACzC,6EAAmD;AACnD,yCAA8F;AAC9F,wBAAsB;AAEtB,MAAM,qBAAqB,GAAG,CAAC,EAiB9B,EAAE,EAAE;QAjB0B,EAC7B,KAAK,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,UAAU,EACV,wBAAwB,EACxB,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,iBAAiB,EACjB,oBAAoB,EACpB,gBAA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,CAAC;aACxH;iBAAM;gBACL,GAAG,mCAAQ,GAAG,KAAE,KAAK,GAAE,CAAC;aACzB;YACD,OAAO,YAAY,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC,IACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,qBAAqB,CAAC,UAAU,GAAG,YAAY,CAAA;AAC/C,qBAAqB,CAAC,QAAQ,GAAG,UAAU,CAAA;AAE3C,kBAAe,qBAAqB,CAAC","sourcesContent":["/*\n * @Descripttion: 用select包裹虚拟树\n * @Author: 郑泳健\n * @Date: 2024-08-05 10:50:17\n * @LastEditors: 郑泳健\n * @LastEditTime: 2024-09-02 19:37:37\n */\nimport React, { useState, useRef, useMemo } from 'react';\nimport RcSelect from '../tntd-rc-select';\nimport TntdVirtualTree from '../tntd-virtual-tree';\nimport { filterLastestNode, flatWithParents, getLableByValue, flatTreeData } 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 treeList = useMemo(() => {\n return flatTreeData(treeData, fieldNames)\n }, [treeData, fieldNames])\n\n\n const selectValue = useMemo(() => {\n if(!treeCheckable) {\n return getLableByValue(treeList, value)\n }\n\n if(Array.isArray(value)) {\n if(showCheckedStrategy === TntdVirtualTreeSelect.SHOW_ALL) {\n return value.map(i => getLableByValue(treeList, i))\n }\n // 过滤掉有子节点,\n const filterList = value.filter(i => {\n return filterLastestNode(treeNodeWithParents, i, value)\n })\n return filterList.map(i => getLableByValue(treeList, i))\n }\n return undefined\n\n }, [treeCheckable, treeNodeWithParents, value, showCheckedStrategy, treeList])\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 const item = Array.isArray(treeList) ? treeList.find(i => i.value === val) : {}\n onChange?.(val, item);\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,3 +1,5 @@
1
1
  export function flatWithParents(treeData: any, fieldNames?: any, parents?: any, result?: {}): {};
2
2
  export function filterLastestNode(treeNodeWithParents: any, item: any, list: any): boolean;
3
+ export function flatTreeData(treeData: any, fieldNames?: any, result?: any[]): any[];
4
+ export function getLableByValue(treeList: any, value: any): any;
3
5
  //# 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":"AAOO,iGAaN;AAEM,2FAQN"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/utils.js"],"names":[],"mappings":"AAOO,iGAaN;AAEM,2FAQN;AAQM,qFAcN;AAEM,gEAMN"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.flatWithParents = exports.filterLastestNode = void 0;
6
+ exports.getLableByValue = exports.flatWithParents = exports.flatTreeData = exports.filterLastestNode = void 0;
7
7
  function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
8
8
  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."); }
9
9
  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; } }
@@ -45,4 +45,41 @@ var filterLastestNode = exports.filterLastestNode = function filterLastestNode(t
45
45
  });
46
46
  }
47
47
  return false;
48
+ };
49
+ /**
50
+ * 扁平树
51
+ * @param {*} treeData
52
+ * @param {*} fieldNames 展开的节点
53
+ * @returns
54
+ */
55
+ var _flatTreeData = exports.flatTreeData = function flatTreeData(treeData) {
56
+ var fieldNames = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
57
+ title: 'title',
58
+ value: 'value',
59
+ children: 'children',
60
+ disabled: 'disabled'
61
+ };
62
+ var result = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
63
+ if (Array.isArray(treeData)) {
64
+ treeData.forEach(function (i) {
65
+ i['title'] = i[fieldNames['title']];
66
+ i['value'] = i[fieldNames['value']];
67
+ i['children'] = i[fieldNames['children']];
68
+ result.push(i);
69
+ if (Array.isArray(i.children) && !!i.children.length) {
70
+ result = [].concat(_toConsumableArray(result), _toConsumableArray(_flatTreeData(i.children, fieldNames)));
71
+ }
72
+ });
73
+ }
74
+ return result;
75
+ };
76
+ var getLableByValue = exports.getLableByValue = function getLableByValue(treeList, value) {
77
+ if (Array.isArray(treeList)) {
78
+ var _ref = treeList.find(function (i) {
79
+ return i.value === value;
80
+ }) || {},
81
+ title = _ref.title;
82
+ return title;
83
+ }
84
+ return undefined;
48
85
  };
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/utils.js"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,UAAU,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE;IAClK,IAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC1B,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACnB,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;YACzC,IAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC;gBAC1C,MAAM,IAAI,GAAG,IAAA,uBAAe,EAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;gBACzG,MAAM,mCAAO,MAAM,GAAK,IAAI,CAAC,CAAA;aAC9B;iBAAI;aAEJ;QACH,CAAC,CAAC,CAAA;KACH;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAbY,QAAA,eAAe,mBAa3B;AAEM,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;IACnE,MAAM,OAAO,GAAG,mBAAmB,CAAC,IAAI,CAAC,IAAI,EAAE,CAAA;IAE/C,IAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE;QACrF,OAAO,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;KAC/C;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AARY,QAAA,iBAAiB,qBAQ7B","sourcesContent":["/**\n * 给每个节点增加一个parent字段,记录其父节点用于showCheckedStrategy\n * @param {*} treeData \n * @param {*} fieldNames \n * @param {*} parents \n * @returns \n */\nexport const flatWithParents = (treeData, fieldNames = { title: 'title', value: 'value', children: 'children', disabled: 'disabled' }, parents = [], result = {}) => {\n if(Array.isArray(treeData)) {\n treeData.forEach(i => {\n result[i[fieldNames['value']]] = parents;\n if(Array.isArray(i[fieldNames['children']])){\n const list = flatWithParents(i[fieldNames['children']], fieldNames, [...parents, i[fieldNames['value']]])\n result = {...result, ...list}\n }else{\n \n }\n })\n }\n return result\n}\n\nexport const filterLastestNode = (treeNodeWithParents, item, list) => {\n const parents = treeNodeWithParents[item] || {}\n \n if(Array.isArray(parents) && !!parents.length && Array.isArray(list) && !!list.length) {\n return parents.every(el => !list.includes(el))\n }\n\n return false\n}\n\n"]}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/tntd-virtual-tree-select/utils.js"],"names":[],"mappings":";;;AAAA;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,UAAU,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,UAAU,EAAE,EAAE,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,EAAE,EAAE,EAAE;IAClK,IAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC1B,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;YACnB,MAAM,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC;YACzC,IAAG,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,EAAC;gBAC1C,MAAM,IAAI,GAAG,IAAA,uBAAe,EAAC,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,OAAO,EAAE,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAA;gBACzG,MAAM,mCAAO,MAAM,GAAK,IAAI,CAAC,CAAA;aAC9B;iBAAI;aAEJ;QACH,CAAC,CAAC,CAAA;KACH;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAbY,QAAA,eAAe,mBAa3B;AAEM,MAAM,iBAAiB,GAAG,CAAC,mBAAmB,EAAE,IAAI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,GAAG,IAAA,oBAAY,EAAC,CAAC,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAA;aAC9D;QACH,CAAC,CAAC,CAAA;KACH;IACD,OAAO,MAAM,CAAA;AACf,CAAC,CAAC;AAdW,QAAA,YAAY,gBAcvB;AAEK,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;IACjD,IAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;QAC1B,MAAM,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,KAAK,CAAC,IAAI,EAAE,CAAA;QAC7D,OAAO,KAAK,CAAC;KACd;IACD,OAAO,SAAS,CAAA;AAClB,CAAC,CAAA;AANY,QAAA,eAAe,mBAM3B","sourcesContent":["/**\n * 给每个节点增加一个parent字段,记录其父节点用于showCheckedStrategy\n * @param {*} treeData \n * @param {*} fieldNames \n * @param {*} parents \n * @returns \n */\nexport const flatWithParents = (treeData, fieldNames = { title: 'title', value: 'value', children: 'children', disabled: 'disabled' }, parents = [], result = {}) => {\n if(Array.isArray(treeData)) {\n treeData.forEach(i => {\n result[i[fieldNames['value']]] = parents;\n if(Array.isArray(i[fieldNames['children']])){\n const list = flatWithParents(i[fieldNames['children']], fieldNames, [...parents, i[fieldNames['value']]])\n result = {...result, ...list}\n }else{\n \n }\n })\n }\n return result\n}\n\nexport const filterLastestNode = (treeNodeWithParents, item, list) => {\n const parents = treeNodeWithParents[item] || {}\n \n if(Array.isArray(parents) && !!parents.length && Array.isArray(list) && !!list.length) {\n return parents.every(el => !list.includes(el))\n }\n\n return false\n}\n\n/**\n * 扁平树\n * @param {*} treeData\n * @param {*} fieldNames 展开的节点\n * @returns\n */\nexport const flatTreeData = (treeData, fieldNames = { title: 'title', value: 'value', children: 'children', disabled: 'disabled' }, result = []) => {\n if(Array.isArray(treeData)) {\n treeData.forEach(i => {\n i['title'] = i[fieldNames['title']];\n i['value'] = i[fieldNames['value']]\n i['children'] = i[fieldNames['children']]\n result.push(i);\n\n if(Array.isArray(i.children) && !!i.children.length) {\n result = [...result, ...flatTreeData(i.children, fieldNames)]\n }\n })\n }\n return result\n};\n\nexport const getLableByValue = (treeList, value) => {\n if(Array.isArray(treeList)) {\n const { title } = treeList.find(i => i.value === value) || {}\n return title;\n }\n return undefined\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tntd",
3
- "version": "3.0.12-beta.3",
3
+ "version": "3.0.13",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "start": "heft start --storybook",