|
1 | | -import React, { Children, HTMLProps, ReactNode, isValidElement, cloneElement } from 'react'; |
| 1 | +import React, { |
| 2 | + Children, |
| 3 | + ReactNode, |
| 4 | + isValidElement, |
| 5 | + cloneElement, |
| 6 | +} from 'react'; |
2 | 7 | import { Tooltip, Split, SplitItem } from '@patternfly/react-core'; |
3 | 8 | import { OutlinedQuestionCircleIcon } from '@patternfly/react-icons'; |
4 | | -import { HTMLFieldProps, connectField, filterDOMProps, joinName } from 'uniforms/es5'; |
| 9 | +import { HTMLFieldProps, connectField, filterDOMProps } from 'uniforms/es5'; |
5 | 10 |
|
6 | 11 | import ListItemField from './ListItemField'; |
7 | 12 | import ListAddField from './ListAddField'; |
8 | | -import { ListDelField } from '.'; |
9 | | - |
10 | | -// export type ListFieldProps = { |
11 | | -// value: unknown[]; |
12 | | -// children?: ReactNode; |
13 | | -// addIcon?: any; |
14 | | -// error?: boolean; |
15 | | -// info?: boolean; |
16 | | -// errorMessage?: string; |
17 | | -// initialCount?: number; |
18 | | -// itemProps?: {}; |
19 | | -// labelCol?: any; |
20 | | -// label: string; |
21 | | -// wrapperCol?: any; |
22 | | -// name: string; |
23 | | -// showInlineError?: boolean; |
24 | | -// } & Omit<HTMLProps<HTMLDivElement>, 'children' | 'name'>; |
| 13 | +import ListDelField from './ListDelField'; |
25 | 14 |
|
26 | 15 | export type ListFieldProps = HTMLFieldProps< |
27 | 16 | unknown[], |
@@ -84,17 +73,17 @@ function ListField({ |
84 | 73 | </Split> |
85 | 74 |
|
86 | 75 | <div> |
87 | | - {value?.map((item, itemIndex) => |
88 | | - Children.map(children, (child, childIndex) => |
89 | | - isValidElement(child) |
90 | | - ? cloneElement(child, { |
91 | | - key: `${itemIndex}-${childIndex}`, |
92 | | - name: child.props.name?.replace('$', '' + itemIndex), |
93 | | - ...itemProps, |
94 | | - }) |
95 | | - : child, |
96 | | - ), |
97 | | - )} |
| 76 | + {value?.map((item, itemIndex) => |
| 77 | + Children.map(children, (child, childIndex) => |
| 78 | + isValidElement(child) |
| 79 | + ? cloneElement(child, { |
| 80 | + key: `${itemIndex}-${childIndex}`, |
| 81 | + name: child.props.name?.replace('$', '' + itemIndex), |
| 82 | + ...itemProps, |
| 83 | + }) |
| 84 | + : child |
| 85 | + ) |
| 86 | + )} |
98 | 87 | </div> |
99 | 88 | </div> |
100 | 89 | ); |
|
0 commit comments