@kne/super-select 0.1.21 → 0.1.22
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.
- package/README.md +17 -9
- package/dist/index.js +31 -17
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +19 -7
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -16,6 +16,7 @@ import SearchInput from '@kne/search-input';
|
|
|
16
16
|
import { FetchScrollLoader } from '@kne/scroll-loader';
|
|
17
17
|
import '@kne/scroll-loader/dist/index.css';
|
|
18
18
|
import memoize from 'lodash/memoize';
|
|
19
|
+
import isNil from 'lodash/isNil';
|
|
19
20
|
import omit from 'lodash/omit';
|
|
20
21
|
import pick from 'lodash/pick';
|
|
21
22
|
import merge from 'lodash/merge';
|
|
@@ -1643,19 +1644,23 @@ var style = {"list":"_YTqxA","is-popup":"_TR-1a","default-list":"_IZN7r","is-sel
|
|
|
1643
1644
|
|
|
1644
1645
|
const _excluded = ["children"],
|
|
1645
1646
|
_excluded2 = ["data"];
|
|
1646
|
-
const parseTreeData = memoize((data = []
|
|
1647
|
+
const parseTreeData = memoize((data = [], {
|
|
1648
|
+
parentKey,
|
|
1649
|
+
valueKey,
|
|
1650
|
+
childrenKey
|
|
1651
|
+
}) => {
|
|
1647
1652
|
const parseTree = output => {
|
|
1648
1653
|
return output.map(node => {
|
|
1649
1654
|
const children = data.filter(item => {
|
|
1650
|
-
return item
|
|
1655
|
+
return !isNil(node[valueKey]) && item[parentKey] === node[valueKey];
|
|
1651
1656
|
});
|
|
1652
1657
|
return Object.assign({}, node, {
|
|
1653
|
-
|
|
1658
|
+
[childrenKey]: parseTree(children)
|
|
1654
1659
|
});
|
|
1655
1660
|
});
|
|
1656
1661
|
};
|
|
1657
1662
|
return {
|
|
1658
|
-
treeData: parseTree(data.filter(item => !item
|
|
1663
|
+
treeData: parseTree(data.filter(item => !item[parentKey])),
|
|
1659
1664
|
ids: data.map(item => item.id)
|
|
1660
1665
|
};
|
|
1661
1666
|
});
|
|
@@ -1667,6 +1672,8 @@ const SelectTree = forwardRef((_ref, ref) => {
|
|
|
1667
1672
|
const fetchListRef = useRef(null);
|
|
1668
1673
|
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
1669
1674
|
const props = Object.assign({}, {
|
|
1675
|
+
parentKey: 'parentId',
|
|
1676
|
+
childrenKey: 'children',
|
|
1670
1677
|
renderItemContent: ({
|
|
1671
1678
|
item,
|
|
1672
1679
|
props
|
|
@@ -1739,12 +1746,17 @@ const SelectTree = forwardRef((_ref, ref) => {
|
|
|
1739
1746
|
renderItem,
|
|
1740
1747
|
valueKey,
|
|
1741
1748
|
labelKey,
|
|
1742
|
-
childrenKey
|
|
1749
|
+
childrenKey,
|
|
1750
|
+
parentKey
|
|
1743
1751
|
} = props;
|
|
1744
1752
|
const {
|
|
1745
1753
|
treeData,
|
|
1746
1754
|
ids
|
|
1747
|
-
} = parseTreeData(data
|
|
1755
|
+
} = parseTreeData(data, {
|
|
1756
|
+
valueKey,
|
|
1757
|
+
parentKey,
|
|
1758
|
+
childrenKey
|
|
1759
|
+
});
|
|
1748
1760
|
return /*#__PURE__*/React.createElement(Tree, {
|
|
1749
1761
|
className: classnames(style['default-list'], {
|
|
1750
1762
|
[style['is-selected-all']]: isSelectedAll
|
|
@@ -1755,7 +1767,7 @@ const SelectTree = forwardRef((_ref, ref) => {
|
|
|
1755
1767
|
fieldNames: {
|
|
1756
1768
|
title: labelKey,
|
|
1757
1769
|
key: valueKey,
|
|
1758
|
-
children: childrenKey
|
|
1770
|
+
children: childrenKey
|
|
1759
1771
|
},
|
|
1760
1772
|
treeData: treeData,
|
|
1761
1773
|
onExpand: expandedKeys => {
|