@hw-component/form 0.0.3-beta-v6 → 0.0.3-beta-v7

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.
@@ -2,6 +2,8 @@ import type { ButtonProps, FormInstance } from "antd/es";
2
2
  export interface ISubmitProps extends Omit<ButtonProps, "form"> {
3
3
  text?: string;
4
4
  form: FormInstance;
5
+ reset?: boolean;
6
+ position?: "start" | "end";
5
7
  }
6
- declare const _default: ({ text, type, form, loading, ...props }: ISubmitProps) => JSX.Element;
8
+ declare const _default: ({ text, type, form, loading, position, reset, ...props }: ISubmitProps) => JSX.Element;
7
9
  export default _default;
@@ -1,11 +1,11 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import _extends from '@babel/runtime-corejs3/helpers/extends';
3
3
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
4
- import { Button } from 'antd';
4
+ import { Row, Button } from 'antd';
5
5
  import React from 'react';
6
6
  import { useFormContext } from '../Form/Context/index.js';
7
7
 
8
- var _excluded = ["text", "type", "form", "loading"];
8
+ var _excluded = ["text", "type", "form", "loading", "position", "reset"];
9
9
  var HSubmit = (function (_ref) {
10
10
  var _ref$text = _ref.text,
11
11
  text = _ref$text === void 0 ? "提交" : _ref$text,
@@ -13,15 +13,27 @@ var HSubmit = (function (_ref) {
13
13
  type = _ref$type === void 0 ? "primary" : _ref$type,
14
14
  form = _ref.form,
15
15
  loading = _ref.loading,
16
+ _ref$position = _ref.position,
17
+ position = _ref$position === void 0 ? "start" : _ref$position,
18
+ reset = _ref.reset,
16
19
  props = _objectWithoutProperties(_ref, _excluded);
17
20
  var _useFormContext = useFormContext(),
18
21
  _useFormContext$loadi = _useFormContext.loading,
19
22
  formSubLoading = _useFormContext$loadi === void 0 ? loading : _useFormContext$loadi;
20
- return /*#__PURE__*/React.createElement(Button, _extends({}, props, {
23
+ return /*#__PURE__*/React.createElement(Row, {
24
+ justify: position,
25
+ style: {
26
+ width: "100%"
27
+ }
28
+ }, reset && /*#__PURE__*/React.createElement(Button, _extends({}, props, {
29
+ onClick: function onClick() {
30
+ form.resetFields();
31
+ }
32
+ }), "\u91CD\u5236"), /*#__PURE__*/React.createElement(Button, _extends({}, props, {
21
33
  type: type,
22
34
  onClick: form.submit,
23
35
  loading: formSubLoading
24
- }), text);
36
+ }), text));
25
37
  });
26
38
 
27
39
  export { HSubmit as default };
@@ -2,6 +2,8 @@ import type { ButtonProps, FormInstance } from "antd/es";
2
2
  export interface ISubmitProps extends Omit<ButtonProps, "form"> {
3
3
  text?: string;
4
4
  form: FormInstance;
5
+ reset?: boolean;
6
+ position?: "start" | "end";
5
7
  }
6
- declare const _default: ({ text, type, form, loading, ...props }: ISubmitProps) => JSX.Element;
8
+ declare const _default: ({ text, type, form, loading, position, reset, ...props }: ISubmitProps) => JSX.Element;
7
9
  export default _default;
@@ -8,7 +8,7 @@ var antd = require('antd');
8
8
  var React = require('react');
9
9
  var index = require('../Form/Context/index.js');
10
10
 
11
- var _excluded = ["text", "type", "form", "loading"];
11
+ var _excluded = ["text", "type", "form", "loading", "position", "reset"];
12
12
  var HSubmit = (function (_ref) {
13
13
  var _ref$text = _ref.text,
14
14
  text = _ref$text === void 0 ? "提交" : _ref$text,
@@ -16,15 +16,27 @@ var HSubmit = (function (_ref) {
16
16
  type = _ref$type === void 0 ? "primary" : _ref$type,
17
17
  form = _ref.form,
18
18
  loading = _ref.loading,
19
+ _ref$position = _ref.position,
20
+ position = _ref$position === void 0 ? "start" : _ref$position,
21
+ reset = _ref.reset,
19
22
  props = _objectWithoutProperties(_ref, _excluded);
20
23
  var _useFormContext = index.useFormContext(),
21
24
  _useFormContext$loadi = _useFormContext.loading,
22
25
  formSubLoading = _useFormContext$loadi === void 0 ? loading : _useFormContext$loadi;
23
- return /*#__PURE__*/React.createElement(antd.Button, _extends({}, props, {
26
+ return /*#__PURE__*/React.createElement(antd.Row, {
27
+ justify: position,
28
+ style: {
29
+ width: "100%"
30
+ }
31
+ }, reset && /*#__PURE__*/React.createElement(antd.Button, _extends({}, props, {
32
+ onClick: function onClick() {
33
+ form.resetFields();
34
+ }
35
+ }), "\u91CD\u5236"), /*#__PURE__*/React.createElement(antd.Button, _extends({}, props, {
24
36
  type: type,
25
37
  onClick: form.submit,
26
38
  loading: formSubLoading
27
- }), text);
39
+ }), text));
28
40
  });
29
41
 
30
42
  exports.default = HSubmit;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.3-beta-v6",
3
+ "version": "0.0.3-beta-v7",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,8 +32,8 @@
32
32
  "ahooks": "2.10.9",
33
33
  "antd": "4.20.7",
34
34
  "react": "17.0.0",
35
- "react-color": "^2.19.3",
36
35
  "react-dom": "17.0.2",
36
+ "react-color": "^2.19.3",
37
37
  "react-router-dom": "^6.11.2"
38
38
  },
39
39
  "devDependencies": {
@@ -1,4 +1,4 @@
1
- import { Button } from "antd";
1
+ import {Button, Row} from "antd";
2
2
  import React from "react";
3
3
  import { useFormContext } from "../Form/Context";
4
4
  import type { ButtonProps, FormInstance } from "antd/es";
@@ -6,23 +6,37 @@ import type { ButtonProps, FormInstance } from "antd/es";
6
6
  export interface ISubmitProps extends Omit<ButtonProps, "form"> {
7
7
  text?: string;
8
8
  form: FormInstance;
9
+ reset?:boolean;
10
+ position?:"start"|"end"
9
11
  }
10
12
  export default ({
11
13
  text = "提交",
12
14
  type = "primary",
13
15
  form,
14
16
  loading,
17
+ position="start",
18
+ reset,
15
19
  ...props
16
20
  }: ISubmitProps) => {
17
21
  const { loading: formSubLoading = loading } = useFormContext();
18
22
  return (
19
- <Button
20
- {...props}
21
- type={type}
22
- onClick={form.submit}
23
- loading={formSubLoading}
24
- >
25
- {text}
26
- </Button>
23
+ <Row justify={position} style={{width:"100%"}}>
24
+ {reset&&<Button
25
+ {...props}
26
+ onClick={()=>{
27
+ form.resetFields();
28
+ }}
29
+ >
30
+ 重制
31
+ </Button>}
32
+ <Button
33
+ {...props}
34
+ type={type}
35
+ onClick={form.submit}
36
+ loading={formSubLoading}
37
+ >
38
+ {text}
39
+ </Button>
40
+ </Row>
27
41
  );
28
42
  };