1 | "use client";
|
2 |
|
3 | var __rest = this && this.__rest || function (s, e) {
|
4 | var t = {};
|
5 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
6 | if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
7 | if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
8 | }
|
9 | return t;
|
10 | };
|
11 | import * as React from 'react';
|
12 | import { List } from 'rc-field-form';
|
13 | import { devUseWarning } from '../_util/warning';
|
14 | import { ConfigContext } from '../config-provider';
|
15 | import { FormItemPrefixContext } from './context';
|
16 | const FormList = _a => {
|
17 | var {
|
18 | prefixCls: customizePrefixCls,
|
19 | children
|
20 | } = _a,
|
21 | props = __rest(_a, ["prefixCls", "children"]);
|
22 | if (process.env.NODE_ENV !== 'production') {
|
23 | const warning = devUseWarning('Form.List');
|
24 | process.env.NODE_ENV !== "production" ? warning(typeof props.name === 'number' || (Array.isArray(props.name) ? !!props.name.length : !!props.name), 'usage', 'Miss `name` prop.') : void 0;
|
25 | }
|
26 | const {
|
27 | getPrefixCls
|
28 | } = React.useContext(ConfigContext);
|
29 | const prefixCls = getPrefixCls('form', customizePrefixCls);
|
30 | const contextValue = React.useMemo(() => ({
|
31 | prefixCls,
|
32 | status: 'error'
|
33 | }), [prefixCls]);
|
34 | return React.createElement(List, Object.assign({}, props), (fields, operation, meta) => ( React.createElement(FormItemPrefixContext.Provider, {
|
35 | value: contextValue
|
36 | }, children(fields.map(field => Object.assign(Object.assign({}, field), {
|
37 | fieldKey: field.key
|
38 | })), operation, {
|
39 | errors: meta.errors,
|
40 | warnings: meta.warnings
|
41 | }))));
|
42 | };
|
43 | export default FormList; |
\ | No newline at end of file |