@jswork/react-ant-form-schema 1.0.2 → 1.0.4
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/dist/main.cjs.js +21 -21
- package/dist/main.cjs.js.map +1 -1
- package/dist/main.d.mts +1 -5
- package/dist/main.d.ts +2 -4
- package/dist/main.esm.js +21 -21
- package/dist/main.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +20 -16
- package/src/main.tsx +2 -0
package/package.json
CHANGED
package/src/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import cx from 'classnames';
|
|
2
2
|
import React, { FC, ReactNode } from 'react';
|
|
3
|
-
import { Form, FormProps
|
|
3
|
+
import { Form, FormProps } from 'antd';
|
|
4
4
|
import NiceForm, { NiceFormMeta } from '@ebay/nice-form-react';
|
|
5
5
|
import { deepMerge } from './utils';
|
|
6
6
|
|
|
@@ -36,30 +36,34 @@ export type ReactAntdFormSchemaProps = {
|
|
|
36
36
|
* The form content.
|
|
37
37
|
*/
|
|
38
38
|
footerClassName?: string;
|
|
39
|
-
/**
|
|
40
|
-
* Form loading status.
|
|
41
|
-
*/
|
|
42
|
-
loading?: boolean;
|
|
43
39
|
} & FormProps;
|
|
44
40
|
|
|
41
|
+
const defaultProps = {
|
|
42
|
+
className: '',
|
|
43
|
+
header: null,
|
|
44
|
+
footer: null,
|
|
45
|
+
footerClassName: '',
|
|
46
|
+
};
|
|
47
|
+
|
|
45
48
|
const ReactAntdFormSchema: FC<ReactAntdFormSchemaProps> = (props) => {
|
|
46
|
-
const { className, meta, header, footer, children,
|
|
49
|
+
const { className, meta, header, footer, children, footerClassName, ...rest } = {
|
|
50
|
+
...defaultProps,
|
|
51
|
+
...props,
|
|
52
|
+
};
|
|
47
53
|
const footerNode = footer || (children as ReactNode);
|
|
48
54
|
const _meta = deepMerge(DEFAULT_META, meta);
|
|
49
55
|
const _offset = _meta?.wrapperProps?.labelCol?.span || 4;
|
|
50
56
|
|
|
51
57
|
return (
|
|
52
58
|
<Form data-component={CLASS_NAME} className={cx(CLASS_NAME, className)} {...rest}>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
</Form.Item>
|
|
62
|
-
</Spin>
|
|
59
|
+
{header}
|
|
60
|
+
<NiceForm meta={_meta} />
|
|
61
|
+
<Form.Item
|
|
62
|
+
wrapperCol={{ offset: _offset }}
|
|
63
|
+
className={footerClassName}
|
|
64
|
+
style={{ marginBottom: 0 }}>
|
|
65
|
+
{footerNode}
|
|
66
|
+
</Form.Item>
|
|
63
67
|
</Form>
|
|
64
68
|
);
|
|
65
69
|
};
|