@hw-component/form 1.1.7 → 1.1.9
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/es/Input/ButtonInput.js +3 -2
- package/es/Input/VerificationCodeInput.d.ts +3 -3
- package/es/Input/VerificationCodeInput.js +9 -6
- package/es/Input/modal.d.ts +1 -1
- package/es/index.css +3 -3
- package/lib/Input/ButtonInput.js +3 -2
- package/lib/Input/VerificationCodeInput.d.ts +3 -3
- package/lib/Input/VerificationCodeInput.js +9 -6
- package/lib/Input/modal.d.ts +1 -1
- package/lib/index.css +3 -3
- package/package.json +1 -1
- package/src/components/Form/index.less +3 -5
- package/src/components/Input/ButtonInput.tsx +2 -2
- package/src/components/Input/VerificationCodeInput.tsx +9 -3
- package/src/components/Input/modal.ts +1 -1
- package/src/pages/Form/index.tsx +25 -0
package/es/Input/ButtonInput.js
CHANGED
|
@@ -15,7 +15,7 @@ import { Input, Button } from 'antd';
|
|
|
15
15
|
import { useRequest } from 'ahooks';
|
|
16
16
|
|
|
17
17
|
var _excluded = ["buttonProps", "value", "onChange", "children", "request"],
|
|
18
|
-
_excluded2 = ["onClick", "type"];
|
|
18
|
+
_excluded2 = ["onClick", "type", "loading"];
|
|
19
19
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
21
|
var Index = function Index(_ref) {
|
|
@@ -29,6 +29,7 @@ var Index = function Index(_ref) {
|
|
|
29
29
|
var onClick = buttonProps.onClick,
|
|
30
30
|
_buttonProps$type = buttonProps.type,
|
|
31
31
|
type = _buttonProps$type === void 0 ? "primary" : _buttonProps$type,
|
|
32
|
+
btnLoading = buttonProps.loading,
|
|
32
33
|
oProps = _objectWithoutProperties(buttonProps, _excluded2);
|
|
33
34
|
var _useRequest = useRequest(function (val) {
|
|
34
35
|
return request === null || request === void 0 ? void 0 : request(val);
|
|
@@ -81,7 +82,7 @@ var Index = function Index(_ref) {
|
|
|
81
82
|
})), jsx(Button, _objectSpread(_objectSpread({}, oProps), {}, {
|
|
82
83
|
type: type,
|
|
83
84
|
onClick: click,
|
|
84
|
-
loading: loading,
|
|
85
|
+
loading: loading || btnLoading,
|
|
85
86
|
style: {
|
|
86
87
|
marginLeft: 4
|
|
87
88
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HFormInstance } from "../Form/modal";
|
|
2
|
-
import
|
|
3
|
-
export interface HVerificationCodeInputProps extends Omit<
|
|
2
|
+
import { HButtonInputProps } from "@/components/Input/modal";
|
|
3
|
+
export interface HVerificationCodeInputProps extends Omit<HButtonInputProps, "form"> {
|
|
4
4
|
request?: (value: any) => Promise<any>;
|
|
5
5
|
form?: HFormInstance;
|
|
6
6
|
}
|
|
7
|
-
declare const _default: ({ value, request, form, onChange, ...props }: HVerificationCodeInputProps) => JSX.Element;
|
|
7
|
+
declare const _default: ({ value, request, form, onChange, buttonProps, ...props }: HVerificationCodeInputProps) => JSX.Element;
|
|
8
8
|
export default _default;
|
|
@@ -17,7 +17,7 @@ import { useState, useMemo, useCallback, useEffect } from 'react';
|
|
|
17
17
|
import Index from './ButtonInput.js';
|
|
18
18
|
import { useRequest } from 'ahooks';
|
|
19
19
|
|
|
20
|
-
var _excluded = ["value", "request", "form", "onChange"];
|
|
20
|
+
var _excluded = ["value", "request", "form", "onChange", "buttonProps"];
|
|
21
21
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
22
22
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
23
23
|
var VerificationCodeInput = (function (_ref) {
|
|
@@ -25,6 +25,8 @@ var VerificationCodeInput = (function (_ref) {
|
|
|
25
25
|
request = _ref.request,
|
|
26
26
|
form = _ref.form,
|
|
27
27
|
onChange = _ref.onChange,
|
|
28
|
+
_ref$buttonProps = _ref.buttonProps,
|
|
29
|
+
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
|
|
28
30
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
29
31
|
var _useState = useState(0),
|
|
30
32
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -93,14 +95,15 @@ var VerificationCodeInput = (function (_ref) {
|
|
|
93
95
|
}
|
|
94
96
|
return "".concat(countdownStr, "\u79D2\u540E\u91CD\u65B0\u83B7\u53D6");
|
|
95
97
|
};
|
|
98
|
+
var defaultButtonProps = {
|
|
99
|
+
onClick: run,
|
|
100
|
+
loading: loading,
|
|
101
|
+
disabled: !!countdown
|
|
102
|
+
};
|
|
96
103
|
return jsx(Index, _objectSpread(_objectSpread({
|
|
97
104
|
value: value,
|
|
98
105
|
onChange: onChange,
|
|
99
|
-
buttonProps: {
|
|
100
|
-
onClick: run,
|
|
101
|
-
loading: loading,
|
|
102
|
-
disabled: !!countdown
|
|
103
|
-
}
|
|
106
|
+
buttonProps: _objectSpread(_objectSpread({}, defaultButtonProps), buttonProps)
|
|
104
107
|
}, props), {}, {
|
|
105
108
|
children: text()
|
|
106
109
|
}));
|
package/es/Input/modal.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface HSelectInputProps extends Omit<HInputProps, "value" | "onChange
|
|
|
25
25
|
subParams?: (formatValue: Record<string, any>) => any;
|
|
26
26
|
}
|
|
27
27
|
export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
|
|
28
|
-
onClick
|
|
28
|
+
onClick?: (value: string | readonly string[] | number | undefined, onChange?: (val: any) => void) => void;
|
|
29
29
|
}
|
|
30
30
|
export interface HButtonInputProps extends HInputProps {
|
|
31
31
|
buttonProps?: HButtonProps;
|
package/es/index.css
CHANGED
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
.ant-hw-form-base-item-top-left .ant-hw-form-label-item {
|
|
39
39
|
position: relative;
|
|
40
40
|
}
|
|
41
|
-
.ant-hw-form-base-item-left .ant-form-item-label > label {
|
|
42
|
-
height: 32px;
|
|
43
|
-
}
|
|
44
41
|
.ant-hw-form-base-item-top-right .ant-form-item-label > label {
|
|
45
42
|
height: auto;
|
|
46
43
|
}
|
|
@@ -67,6 +64,9 @@
|
|
|
67
64
|
.ant-hw-form-base-item-left .ant-hw-form-label-item {
|
|
68
65
|
position: relative;
|
|
69
66
|
}
|
|
67
|
+
.ant-hw-form-base-item-left .ant-form-item-label > label {
|
|
68
|
+
height: 32px;
|
|
69
|
+
}
|
|
70
70
|
.ant-hw-form-item-no-required {
|
|
71
71
|
display: none;
|
|
72
72
|
}
|
package/lib/Input/ButtonInput.js
CHANGED
|
@@ -18,7 +18,7 @@ var antd = require('antd');
|
|
|
18
18
|
var ahooks = require('ahooks');
|
|
19
19
|
|
|
20
20
|
var _excluded = ["buttonProps", "value", "onChange", "children", "request"],
|
|
21
|
-
_excluded2 = ["onClick", "type"];
|
|
21
|
+
_excluded2 = ["onClick", "type", "loading"];
|
|
22
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
23
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
24
24
|
var Index = function Index(_ref) {
|
|
@@ -32,6 +32,7 @@ var Index = function Index(_ref) {
|
|
|
32
32
|
var onClick = buttonProps.onClick,
|
|
33
33
|
_buttonProps$type = buttonProps.type,
|
|
34
34
|
type = _buttonProps$type === void 0 ? "primary" : _buttonProps$type,
|
|
35
|
+
btnLoading = buttonProps.loading,
|
|
35
36
|
oProps = _objectWithoutProperties(buttonProps, _excluded2);
|
|
36
37
|
var _useRequest = ahooks.useRequest(function (val) {
|
|
37
38
|
return request === null || request === void 0 ? void 0 : request(val);
|
|
@@ -84,7 +85,7 @@ var Index = function Index(_ref) {
|
|
|
84
85
|
})), jsxRuntime.jsx(antd.Button, _objectSpread(_objectSpread({}, oProps), {}, {
|
|
85
86
|
type: type,
|
|
86
87
|
onClick: click,
|
|
87
|
-
loading: loading,
|
|
88
|
+
loading: loading || btnLoading,
|
|
88
89
|
style: {
|
|
89
90
|
marginLeft: 4
|
|
90
91
|
},
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { HFormInstance } from "../Form/modal";
|
|
2
|
-
import
|
|
3
|
-
export interface HVerificationCodeInputProps extends Omit<
|
|
2
|
+
import { HButtonInputProps } from "@/components/Input/modal";
|
|
3
|
+
export interface HVerificationCodeInputProps extends Omit<HButtonInputProps, "form"> {
|
|
4
4
|
request?: (value: any) => Promise<any>;
|
|
5
5
|
form?: HFormInstance;
|
|
6
6
|
}
|
|
7
|
-
declare const _default: ({ value, request, form, onChange, ...props }: HVerificationCodeInputProps) => JSX.Element;
|
|
7
|
+
declare const _default: ({ value, request, form, onChange, buttonProps, ...props }: HVerificationCodeInputProps) => JSX.Element;
|
|
8
8
|
export default _default;
|
|
@@ -20,7 +20,7 @@ var React = require('react');
|
|
|
20
20
|
var ButtonInput = require('./ButtonInput.js');
|
|
21
21
|
var ahooks = require('ahooks');
|
|
22
22
|
|
|
23
|
-
var _excluded = ["value", "request", "form", "onChange"];
|
|
23
|
+
var _excluded = ["value", "request", "form", "onChange", "buttonProps"];
|
|
24
24
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
25
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
26
|
var VerificationCodeInput = (function (_ref) {
|
|
@@ -28,6 +28,8 @@ var VerificationCodeInput = (function (_ref) {
|
|
|
28
28
|
request = _ref.request,
|
|
29
29
|
form = _ref.form,
|
|
30
30
|
onChange = _ref.onChange,
|
|
31
|
+
_ref$buttonProps = _ref.buttonProps,
|
|
32
|
+
buttonProps = _ref$buttonProps === void 0 ? {} : _ref$buttonProps,
|
|
31
33
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
32
34
|
var _useState = React.useState(0),
|
|
33
35
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -96,14 +98,15 @@ var VerificationCodeInput = (function (_ref) {
|
|
|
96
98
|
}
|
|
97
99
|
return "".concat(countdownStr, "\u79D2\u540E\u91CD\u65B0\u83B7\u53D6");
|
|
98
100
|
};
|
|
101
|
+
var defaultButtonProps = {
|
|
102
|
+
onClick: run,
|
|
103
|
+
loading: loading,
|
|
104
|
+
disabled: !!countdown
|
|
105
|
+
};
|
|
99
106
|
return jsxRuntime.jsx(ButtonInput.default, _objectSpread(_objectSpread({
|
|
100
107
|
value: value,
|
|
101
108
|
onChange: onChange,
|
|
102
|
-
buttonProps: {
|
|
103
|
-
onClick: run,
|
|
104
|
-
loading: loading,
|
|
105
|
-
disabled: !!countdown
|
|
106
|
-
}
|
|
109
|
+
buttonProps: _objectSpread(_objectSpread({}, defaultButtonProps), buttonProps)
|
|
107
110
|
}, props), {}, {
|
|
108
111
|
children: text()
|
|
109
112
|
}));
|
package/lib/Input/modal.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ export interface HSelectInputProps extends Omit<HInputProps, "value" | "onChange
|
|
|
25
25
|
subParams?: (formatValue: Record<string, any>) => any;
|
|
26
26
|
}
|
|
27
27
|
export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
|
|
28
|
-
onClick
|
|
28
|
+
onClick?: (value: string | readonly string[] | number | undefined, onChange?: (val: any) => void) => void;
|
|
29
29
|
}
|
|
30
30
|
export interface HButtonInputProps extends HInputProps {
|
|
31
31
|
buttonProps?: HButtonProps;
|
package/lib/index.css
CHANGED
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
.ant-hw-form-base-item-top-left .ant-hw-form-label-item {
|
|
39
39
|
position: relative;
|
|
40
40
|
}
|
|
41
|
-
.ant-hw-form-base-item-left .ant-form-item-label > label {
|
|
42
|
-
height: 32px;
|
|
43
|
-
}
|
|
44
41
|
.ant-hw-form-base-item-top-right .ant-form-item-label > label {
|
|
45
42
|
height: auto;
|
|
46
43
|
}
|
|
@@ -67,6 +64,9 @@
|
|
|
67
64
|
.ant-hw-form-base-item-left .ant-hw-form-label-item {
|
|
68
65
|
position: relative;
|
|
69
66
|
}
|
|
67
|
+
.ant-hw-form-base-item-left .ant-form-item-label > label {
|
|
68
|
+
height: 32px;
|
|
69
|
+
}
|
|
70
70
|
.ant-hw-form-item-no-required {
|
|
71
71
|
display: none;
|
|
72
72
|
}
|
package/package.json
CHANGED
|
@@ -26,11 +26,6 @@
|
|
|
26
26
|
position: relative;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
.@{ant-prefix}-hw-form-base-item-left {
|
|
30
|
-
.@{ant-prefix}-form-item-label > label {
|
|
31
|
-
height: 32px;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
29
|
.@{ant-prefix}-hw-form-base-item-top-right {
|
|
35
30
|
.@{ant-prefix}-form-item-label > label {
|
|
36
31
|
height: auto;
|
|
@@ -65,6 +60,9 @@
|
|
|
65
60
|
.@{ant-prefix}-hw-form-label-item{
|
|
66
61
|
position: relative;
|
|
67
62
|
}
|
|
63
|
+
.@{ant-prefix}-form-item-label > label {
|
|
64
|
+
height: 32px;
|
|
65
|
+
}
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
.@{ant-prefix}-hw-form-item-no-required{
|
|
@@ -11,7 +11,7 @@ const Index: React.FC<HButtonInputProps> = ({
|
|
|
11
11
|
request,
|
|
12
12
|
...props
|
|
13
13
|
}) => {
|
|
14
|
-
const { onClick, type = "primary",
|
|
14
|
+
const { onClick, type = "primary", loading:btnLoading,...oProps } = buttonProps;
|
|
15
15
|
const { run, loading } = useRequest(
|
|
16
16
|
(val) => {
|
|
17
17
|
return request?.(val);
|
|
@@ -36,7 +36,7 @@ const Index: React.FC<HButtonInputProps> = ({
|
|
|
36
36
|
{...oProps}
|
|
37
37
|
type={type}
|
|
38
38
|
onClick={click}
|
|
39
|
-
loading={loading}
|
|
39
|
+
loading={loading||btnLoading}
|
|
40
40
|
style={{ marginLeft: 4 }}
|
|
41
41
|
>
|
|
42
42
|
{children}
|
|
@@ -2,8 +2,8 @@ import React, { useCallback, useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import ButtonInput from "./ButtonInput";
|
|
3
3
|
import { useRequest } from "ahooks";
|
|
4
4
|
import type { HFormInstance } from "../Form/modal";
|
|
5
|
-
import
|
|
6
|
-
export interface HVerificationCodeInputProps extends Omit<
|
|
5
|
+
import {HButtonInputProps} from "@/components/Input/modal";
|
|
6
|
+
export interface HVerificationCodeInputProps extends Omit<HButtonInputProps, "form"> {
|
|
7
7
|
request?: (value: any) => Promise<any>;
|
|
8
8
|
form?: HFormInstance;
|
|
9
9
|
}
|
|
@@ -12,6 +12,7 @@ export default ({
|
|
|
12
12
|
request,
|
|
13
13
|
form,
|
|
14
14
|
onChange,
|
|
15
|
+
buttonProps={},
|
|
15
16
|
...props
|
|
16
17
|
}: HVerificationCodeInputProps) => {
|
|
17
18
|
const [countdown, setCountdown] = useState<number>(0);
|
|
@@ -61,11 +62,16 @@ export default ({
|
|
|
61
62
|
}
|
|
62
63
|
return `${countdownStr}秒后重新获取`;
|
|
63
64
|
};
|
|
65
|
+
const defaultButtonProps={
|
|
66
|
+
onClick: run,
|
|
67
|
+
loading,
|
|
68
|
+
disabled: !!countdown
|
|
69
|
+
}
|
|
64
70
|
return (
|
|
65
71
|
<ButtonInput
|
|
66
72
|
value={value}
|
|
67
73
|
onChange={onChange}
|
|
68
|
-
buttonProps={{
|
|
74
|
+
buttonProps={{...defaultButtonProps,...buttonProps}}
|
|
69
75
|
{...props}
|
|
70
76
|
>
|
|
71
77
|
{text()}
|
|
@@ -29,7 +29,7 @@ export interface HSelectInputProps
|
|
|
29
29
|
subParams?: (formatValue: Record<string, any>) => any;
|
|
30
30
|
}
|
|
31
31
|
export interface HButtonProps extends Omit<ButtonProps, "onClick"> {
|
|
32
|
-
onClick
|
|
32
|
+
onClick?: (
|
|
33
33
|
value: string | readonly string[] | number | undefined,
|
|
34
34
|
onChange?: (val: any) => void
|
|
35
35
|
) => void;
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HForm, HFormConfigProvider, useHForm } from "../../components";
|
|
2
2
|
import { Button, Form, Input } from "antd";
|
|
3
|
+
import React from "react";
|
|
3
4
|
|
|
4
5
|
const formData = () => {
|
|
5
6
|
return [
|
|
@@ -73,6 +74,30 @@ const formData = () => {
|
|
|
73
74
|
],
|
|
74
75
|
},
|
|
75
76
|
},
|
|
77
|
+
{
|
|
78
|
+
type: "verificationCodeInput",
|
|
79
|
+
name:"verificationCodeInput",
|
|
80
|
+
label:"验证码",
|
|
81
|
+
shouldUpdate:(prevValue,curValue)=>{
|
|
82
|
+
return prevValue.switch!==curValue.switch;
|
|
83
|
+
},
|
|
84
|
+
itemProps: {
|
|
85
|
+
request:()=>{
|
|
86
|
+
return new Promise((resolve)=>{
|
|
87
|
+
setTimeout(()=>{
|
|
88
|
+
resolve({})
|
|
89
|
+
},4000);
|
|
90
|
+
})
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
render:(item,node,form)=>{
|
|
94
|
+
const phone=form.getFieldValue("switch");
|
|
95
|
+
if (!phone){
|
|
96
|
+
return React.cloneElement(node,{buttonProps:{ghost: true,disabled:true}});
|
|
97
|
+
}
|
|
98
|
+
return React.cloneElement(node,{buttonProps:{ghost:true}})
|
|
99
|
+
}
|
|
100
|
+
},
|
|
76
101
|
{
|
|
77
102
|
type: "submit",
|
|
78
103
|
itemProps: {
|