|
1 | 1 | import * as React from 'react';
|
2 | 2 | import toArray from 'rc-util/lib/Children/toArray';
|
3 | 3 | import warning from 'rc-util/lib/warning';
|
4 |
| -import { DataNode, FlattenNode, NodeElement, DataEntity, Key, EventDataNode } from '../interface'; |
| 4 | +import { |
| 5 | + DataNode, |
| 6 | + FlattenNode, |
| 7 | + NodeElement, |
| 8 | + DataEntity, |
| 9 | + Key, |
| 10 | + EventDataNode, |
| 11 | +} from '../interface'; |
5 | 12 | import { getPosition, isTreeNode } from '../util';
|
6 | 13 | import { TreeNodeProps } from '../TreeNode';
|
7 | 14 |
|
@@ -45,12 +52,15 @@ export function warningWithoutKey(treeData: DataNode[] = []) {
|
45 | 52 | */
|
46 | 53 | export function convertTreeToData(rootNodes: React.ReactNode): DataNode[] {
|
47 | 54 | function dig(node: React.ReactNode): DataNode[] {
|
48 |
| - const treeNodes: NodeElement[] = toArray(node); |
| 55 | + const treeNodes = toArray(node) as NodeElement[]; |
49 | 56 | return treeNodes
|
50 | 57 | .map(treeNode => {
|
51 | 58 | // Filter invalidate node
|
52 | 59 | if (!isTreeNode(treeNode)) {
|
53 |
| - warning(!treeNode, 'Tree/TreeNode can only accept TreeNode as children.'); |
| 60 | + warning( |
| 61 | + !treeNode, |
| 62 | + 'Tree/TreeNode can only accept TreeNode as children.', |
| 63 | + ); |
54 | 64 | return null;
|
55 | 65 | }
|
56 | 66 |
|
@@ -161,7 +171,11 @@ export function traverseDataNodes(
|
161 | 171 | // Process children node
|
162 | 172 | if (children) {
|
163 | 173 | children.forEach((subNode, subIndex) => {
|
164 |
| - processNode(subNode, subIndex, { node, pos, level: parent ? parent.level + 1 : -1 }); |
| 174 | + processNode(subNode, subIndex, { |
| 175 | + node, |
| 176 | + pos, |
| 177 | + level: parent ? parent.level + 1 : -1, |
| 178 | + }); |
165 | 179 | });
|
166 | 180 | }
|
167 | 181 | }
|
@@ -278,7 +292,9 @@ export function getTreeNodeProps(
|
278 | 292 | return treeNodeProps;
|
279 | 293 | }
|
280 | 294 |
|
281 |
| -export function convertNodePropsToEventData(props: TreeNodeProps): EventDataNode { |
| 295 | +export function convertNodePropsToEventData( |
| 296 | + props: TreeNodeProps, |
| 297 | +): EventDataNode { |
282 | 298 | const {
|
283 | 299 | data,
|
284 | 300 | expanded,
|
|
0 commit comments