@hw-component/form 1.8.1 → 1.8.3
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/.eslintcache +1 -1
- package/.stylelintrc.js +6 -2
- package/es/Form/Basic.d.ts +1 -1
- package/es/Form/Basic.js +4 -2
- package/es/Form/index.d.ts +1 -1
- package/es/Form/index.js +3 -1
- package/es/Form/modal.d.ts +1 -0
- package/es/config.js +12 -3
- package/es/index.css +3 -3
- package/es/index.d.ts +1 -1
- package/lib/Form/Basic.d.ts +1 -1
- package/lib/Form/Basic.js +4 -2
- package/lib/Form/index.d.ts +1 -1
- package/lib/Form/index.js +3 -1
- package/lib/Form/modal.d.ts +1 -0
- package/lib/config.js +12 -3
- package/lib/index.css +3 -3
- package/lib/index.d.ts +1 -1
- package/package.json +2 -2
- package/src/components/Form/Basic.tsx +55 -43
- package/src/components/Form/FormItem/BasicItem.tsx +7 -2
- package/src/components/Form/FormItem/hooks.tsx +3 -3
- package/src/components/Form/FormItem/index.tsx +13 -12
- package/src/components/Form/index.less +2 -2
- package/src/components/Form/index.tsx +15 -14
- package/src/components/Form/modal.ts +3 -2
- package/src/components/Input/InputNumberGroup.tsx +8 -8
- package/src/components/Input/index.less +4 -6
- package/src/components/Select/hooks/changeHooks.tsx +31 -29
- package/src/components/Select/hooks/norHooks.ts +1 -1
- package/src/components/Upload/UrlUpload/index.tsx +1 -1
- package/src/components/config.ts +12 -3
- package/src/components/index.tsx +1 -1
- package/src/pages/Form/index.tsx +61 -83
- package/src/pages/Input/index.tsx +7 -5
- package/src/pages/Select/index.tsx +16 -12
- package/src/pages/Upload/index.tsx +1 -2
package/.stylelintrc.js
CHANGED
package/es/Form/Basic.d.ts
CHANGED
package/es/Form/Basic.js
CHANGED
|
@@ -20,7 +20,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
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 Basic = (function (_ref) {
|
|
22
22
|
var configData = _ref.configData,
|
|
23
|
-
gutter = _ref.gutter
|
|
23
|
+
gutter = _ref.gutter,
|
|
24
|
+
_ref$dismissOnPressEn = _ref.dismissOnPressEnter,
|
|
25
|
+
dismissOnPressEnter = _ref$dismissOnPressEn === void 0 ? true : _ref$dismissOnPressEn;
|
|
24
26
|
var _useFormContext = useFormContext(),
|
|
25
27
|
form = _useFormContext.form,
|
|
26
28
|
formItemProps = _useFormContext.itemProps,
|
|
@@ -54,7 +56,7 @@ var Basic = (function (_ref) {
|
|
|
54
56
|
itemProps = _itemData$itemProps === void 0 ? {} : _itemData$itemProps,
|
|
55
57
|
itemColon = itemData.colon;
|
|
56
58
|
var defaultItemProps = _objectSpread(_objectSpread({
|
|
57
|
-
onPressEnter: defaultOnPressEnter
|
|
59
|
+
onPressEnter: dismissOnPressEnter ? undefined : defaultOnPressEnter
|
|
58
60
|
}, formItemProps), itemProps);
|
|
59
61
|
return /*#__PURE__*/createElement(Item, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
60
62
|
labelAlign: labelAlign,
|
package/es/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, ...props }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/es/Form/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { useState, useEffect } from 'react';
|
|
|
18
18
|
import InitSet from './InitSet.js';
|
|
19
19
|
import Basic from './Basic.js';
|
|
20
20
|
|
|
21
|
-
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon"];
|
|
21
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter"];
|
|
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 HForm = (function (_ref) {
|
|
@@ -45,6 +45,7 @@ var HForm = (function (_ref) {
|
|
|
45
45
|
formItemProps = _ref$itemProps === void 0 ? {} : _ref$itemProps,
|
|
46
46
|
_ref$colon = _ref.colon,
|
|
47
47
|
colon = _ref$colon === void 0 ? true : _ref$colon,
|
|
48
|
+
dismissOnPressEnter = _ref.dismissOnPressEnter,
|
|
48
49
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
49
50
|
var hForm = useCurrentForm(form);
|
|
50
51
|
var _useState = useState({}),
|
|
@@ -109,6 +110,7 @@ var HForm = (function (_ref) {
|
|
|
109
110
|
}, props), {}, {
|
|
110
111
|
children: [jsx(Basic, {
|
|
111
112
|
configData: configData,
|
|
113
|
+
dismissOnPressEnter: dismissOnPressEnter,
|
|
112
114
|
gutter: gutter
|
|
113
115
|
}), jsx(InitSet, {})]
|
|
114
116
|
}))
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "
|
|
|
67
67
|
labelAlign?: LabelAlignModal;
|
|
68
68
|
formItemStyle?: React.CSSProperties;
|
|
69
69
|
itemProps?: ItemPropsType;
|
|
70
|
+
dismissOnPressEnter?: boolean;
|
|
70
71
|
}
|
|
71
72
|
export interface HFormItemProps extends HItemProps {
|
|
72
73
|
required?: boolean;
|
package/es/config.js
CHANGED
|
@@ -4,6 +4,9 @@ import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
|
4
4
|
import moment from 'moment';
|
|
5
5
|
import { fileToBase64 } from './Upload/util.js';
|
|
6
6
|
|
|
7
|
+
var rangeStartDay = function rangeStartDay(day) {
|
|
8
|
+
return moment().subtract(day, "days").startOf("days");
|
|
9
|
+
};
|
|
7
10
|
var baseConfig = {
|
|
8
11
|
fieldNames: {
|
|
9
12
|
label: "label",
|
|
@@ -26,9 +29,15 @@ var baseConfig = {
|
|
|
26
29
|
}
|
|
27
30
|
},
|
|
28
31
|
dateRanges: {
|
|
29
|
-
最近三天:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
+
最近三天: function 最近三天() {
|
|
33
|
+
return [rangeStartDay(2), moment()];
|
|
34
|
+
},
|
|
35
|
+
最近七天: function 最近七天() {
|
|
36
|
+
return [rangeStartDay(6), moment()];
|
|
37
|
+
},
|
|
38
|
+
最近三十天: function 最近三十天() {
|
|
39
|
+
return [rangeStartDay(29), moment()];
|
|
40
|
+
}
|
|
32
41
|
},
|
|
33
42
|
uploadProps: {
|
|
34
43
|
exFiles: ["JPG", "PNG", "JPEG", "GIF"],
|
package/es/index.css
CHANGED
|
@@ -83,9 +83,6 @@
|
|
|
83
83
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
84
84
|
overflow: visible;
|
|
85
85
|
}
|
|
86
|
-
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
87
|
-
background-color: #f5f5f5;
|
|
88
|
-
}
|
|
89
86
|
.ant-hw-input-group {
|
|
90
87
|
display: -webkit-box !important;
|
|
91
88
|
display: -webkit-flex !important;
|
|
@@ -94,6 +91,9 @@
|
|
|
94
91
|
width: 100%;
|
|
95
92
|
color: rgba(0, 0, 0, 0.25);
|
|
96
93
|
}
|
|
94
|
+
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
95
|
+
background-color: #f5f5f5;
|
|
96
|
+
}
|
|
97
97
|
.ant-hw-input-group .ant-hw-input-group-body {
|
|
98
98
|
position: relative;
|
|
99
99
|
display: -webkit-box !important;
|
package/es/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { default as useHForm } from "./Form/hooks/useHForm";
|
|
|
5
5
|
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
6
|
export { default as HFormConnect } from "./Form/HFormConnect";
|
|
7
7
|
export { default as HFormConfigProvider } from "./Form/Context/FormConfigProvider";
|
|
8
|
-
export { default as HBasicForm } from
|
|
8
|
+
export { default as HBasicForm } from "./Form/Basic";
|
|
9
9
|
export declare const HSelect: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
export declare const HInput: ({ copy, value, addonAfter, ...props }: import("./Input/modal").HInputProps<any>) => JSX.Element;
|
|
11
11
|
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
package/lib/Form/Basic.d.ts
CHANGED
package/lib/Form/Basic.js
CHANGED
|
@@ -23,7 +23,9 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
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 Basic = (function (_ref) {
|
|
25
25
|
var configData = _ref.configData,
|
|
26
|
-
gutter = _ref.gutter
|
|
26
|
+
gutter = _ref.gutter,
|
|
27
|
+
_ref$dismissOnPressEn = _ref.dismissOnPressEnter,
|
|
28
|
+
dismissOnPressEnter = _ref$dismissOnPressEn === void 0 ? true : _ref$dismissOnPressEn;
|
|
27
29
|
var _useFormContext = index.useFormContext(),
|
|
28
30
|
form = _useFormContext.form,
|
|
29
31
|
formItemProps = _useFormContext.itemProps,
|
|
@@ -57,7 +59,7 @@ var Basic = (function (_ref) {
|
|
|
57
59
|
itemProps = _itemData$itemProps === void 0 ? {} : _itemData$itemProps,
|
|
58
60
|
itemColon = itemData.colon;
|
|
59
61
|
var defaultItemProps = _objectSpread(_objectSpread({
|
|
60
|
-
onPressEnter: defaultOnPressEnter
|
|
62
|
+
onPressEnter: dismissOnPressEnter ? undefined : defaultOnPressEnter
|
|
61
63
|
}, formItemProps), itemProps);
|
|
62
64
|
return /*#__PURE__*/React.createElement(index$1.default, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
63
65
|
labelAlign: labelAlign,
|
package/lib/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, ...props }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/lib/Form/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var React = require('react');
|
|
|
21
21
|
var InitSet = require('./InitSet.js');
|
|
22
22
|
var Basic = require('./Basic.js');
|
|
23
23
|
|
|
24
|
-
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon"];
|
|
24
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter"];
|
|
25
25
|
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; }
|
|
26
26
|
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; }
|
|
27
27
|
var HForm = (function (_ref) {
|
|
@@ -48,6 +48,7 @@ var HForm = (function (_ref) {
|
|
|
48
48
|
formItemProps = _ref$itemProps === void 0 ? {} : _ref$itemProps,
|
|
49
49
|
_ref$colon = _ref.colon,
|
|
50
50
|
colon = _ref$colon === void 0 ? true : _ref$colon,
|
|
51
|
+
dismissOnPressEnter = _ref.dismissOnPressEnter,
|
|
51
52
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
52
53
|
var hForm = index.useCurrentForm(form);
|
|
53
54
|
var _useState = React.useState({}),
|
|
@@ -112,6 +113,7 @@ var HForm = (function (_ref) {
|
|
|
112
113
|
}, props), {}, {
|
|
113
114
|
children: [jsxRuntime.jsx(Basic.default, {
|
|
114
115
|
configData: configData,
|
|
116
|
+
dismissOnPressEnter: dismissOnPressEnter,
|
|
115
117
|
gutter: gutter
|
|
116
118
|
}), jsxRuntime.jsx(InitSet.default, {})]
|
|
117
119
|
}))
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -67,6 +67,7 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "
|
|
|
67
67
|
labelAlign?: LabelAlignModal;
|
|
68
68
|
formItemStyle?: React.CSSProperties;
|
|
69
69
|
itemProps?: ItemPropsType;
|
|
70
|
+
dismissOnPressEnter?: boolean;
|
|
70
71
|
}
|
|
71
72
|
export interface HFormItemProps extends HItemProps {
|
|
72
73
|
required?: boolean;
|
package/lib/config.js
CHANGED
|
@@ -5,6 +5,9 @@ var _regeneratorRuntime = require('@babel/runtime-corejs3/regenerator');
|
|
|
5
5
|
var moment = require('moment');
|
|
6
6
|
var util = require('./Upload/util.js');
|
|
7
7
|
|
|
8
|
+
var rangeStartDay = function rangeStartDay(day) {
|
|
9
|
+
return moment().subtract(day, "days").startOf("days");
|
|
10
|
+
};
|
|
8
11
|
var baseConfig = {
|
|
9
12
|
fieldNames: {
|
|
10
13
|
label: "label",
|
|
@@ -27,9 +30,15 @@ var baseConfig = {
|
|
|
27
30
|
}
|
|
28
31
|
},
|
|
29
32
|
dateRanges: {
|
|
30
|
-
最近三天:
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
最近三天: function 最近三天() {
|
|
34
|
+
return [rangeStartDay(2), moment()];
|
|
35
|
+
},
|
|
36
|
+
最近七天: function 最近七天() {
|
|
37
|
+
return [rangeStartDay(6), moment()];
|
|
38
|
+
},
|
|
39
|
+
最近三十天: function 最近三十天() {
|
|
40
|
+
return [rangeStartDay(29), moment()];
|
|
41
|
+
}
|
|
33
42
|
},
|
|
34
43
|
uploadProps: {
|
|
35
44
|
exFiles: ["JPG", "PNG", "JPEG", "GIF"],
|
package/lib/index.css
CHANGED
|
@@ -83,9 +83,6 @@
|
|
|
83
83
|
.ant-hw-form-form-item .ant-form-item-label {
|
|
84
84
|
overflow: visible;
|
|
85
85
|
}
|
|
86
|
-
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
87
|
-
background-color: #f5f5f5;
|
|
88
|
-
}
|
|
89
86
|
.ant-hw-input-group {
|
|
90
87
|
display: -webkit-box !important;
|
|
91
88
|
display: -webkit-flex !important;
|
|
@@ -94,6 +91,9 @@
|
|
|
94
91
|
width: 100%;
|
|
95
92
|
color: rgba(0, 0, 0, 0.25);
|
|
96
93
|
}
|
|
94
|
+
.ant-hw-input-group .ant-hw-input-group-disabled {
|
|
95
|
+
background-color: #f5f5f5;
|
|
96
|
+
}
|
|
97
97
|
.ant-hw-input-group .ant-hw-input-group-body {
|
|
98
98
|
position: relative;
|
|
99
99
|
display: -webkit-box !important;
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export { default as useHForm } from "./Form/hooks/useHForm";
|
|
|
5
5
|
export { useHDialogForm } from "./DialogForm/hooks";
|
|
6
6
|
export { default as HFormConnect } from "./Form/HFormConnect";
|
|
7
7
|
export { default as HFormConfigProvider } from "./Form/Context/FormConfigProvider";
|
|
8
|
-
export { default as HBasicForm } from
|
|
8
|
+
export { default as HBasicForm } from "./Form/Basic";
|
|
9
9
|
export declare const HSelect: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
10
10
|
export declare const HInput: ({ copy, value, addonAfter, ...props }: import("./Input/modal").HInputProps<any>) => JSX.Element;
|
|
11
11
|
export declare const HSelectInput: import("react").ForwardRefExoticComponent<import("./Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hw-component/form",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.3",
|
|
4
4
|
"description": "基于antd二次开发",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"lint-staged": {
|
|
24
24
|
"**/*.less": "npm run lint:style",
|
|
25
|
-
"**/*.{js,jsx,ts,tsx}": "npm run lint:
|
|
25
|
+
"**/*.{js,jsx,ts,tsx}": "npm run lint:js",
|
|
26
26
|
"**/*.{js,jsx,tsx,ts,less,md,json}": [
|
|
27
27
|
"prettier --write"
|
|
28
28
|
]
|
|
@@ -1,52 +1,64 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type {
|
|
2
|
+
HFormProps,
|
|
3
|
+
HItemProps,
|
|
4
|
+
ItemPropsType,
|
|
5
|
+
} from "@/components/Form/modal";
|
|
2
6
|
import Item from "./FormItem";
|
|
3
|
-
import {Row} from "antd";
|
|
4
|
-
import {useFormContext} from "./Context";
|
|
7
|
+
import { Row } from "antd";
|
|
8
|
+
import { useFormContext } from "./Context";
|
|
5
9
|
import useInitConfigData from "./hooks/useInitConfigData";
|
|
6
|
-
import {useEffect} from "react";
|
|
10
|
+
import { useEffect } from "react";
|
|
7
11
|
|
|
8
|
-
export default ({configData,gutter}: HFormProps)=>{
|
|
9
|
-
const {
|
|
12
|
+
export default ({ configData, gutter ,dismissOnPressEnter=true}: HFormProps) => {
|
|
13
|
+
const {
|
|
14
|
+
form,
|
|
15
|
+
itemProps: formItemProps,
|
|
16
|
+
itemSpan,
|
|
17
|
+
colon: formColon,
|
|
18
|
+
setData,
|
|
19
|
+
} = useFormContext();
|
|
10
20
|
const { newConfigData, dispatchSourceData } = useInitConfigData({
|
|
11
21
|
configData,
|
|
12
22
|
form,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
23
|
+
});
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setData?.(dispatchSourceData);
|
|
26
|
+
}, []);
|
|
27
|
+
const defaultOnPressEnter = () => {
|
|
28
|
+
form.submit();
|
|
29
|
+
};
|
|
30
|
+
return (
|
|
31
|
+
<Row gutter={gutter} style={{ width: "100%" }}>
|
|
21
32
|
{newConfigData.map((itemData: HItemProps, index) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
33
|
+
const {
|
|
34
|
+
labelWidth: itemLabelWidth,
|
|
35
|
+
hideLabel,
|
|
36
|
+
labelAlign,
|
|
37
|
+
name,
|
|
38
|
+
style,
|
|
39
|
+
itemProps = {},
|
|
40
|
+
colon: itemColon,
|
|
41
|
+
} = itemData;
|
|
42
|
+
const defaultItemProps = {
|
|
43
|
+
onPressEnter: dismissOnPressEnter?undefined:defaultOnPressEnter,
|
|
44
|
+
...formItemProps,
|
|
45
|
+
...itemProps,
|
|
46
|
+
};
|
|
36
47
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
return (
|
|
49
|
+
<Item
|
|
50
|
+
{...itemData}
|
|
51
|
+
labelAlign={labelAlign}
|
|
52
|
+
key={name || index}
|
|
53
|
+
style={style}
|
|
54
|
+
itemProps={defaultItemProps as ItemPropsType}
|
|
55
|
+
hideLabel={hideLabel}
|
|
56
|
+
itemSpan={itemSpan}
|
|
57
|
+
labelWidth={itemLabelWidth}
|
|
58
|
+
colon={typeof itemColon === "undefined" ? formColon : itemColon}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
50
61
|
})}
|
|
51
|
-
|
|
52
|
-
|
|
62
|
+
</Row>
|
|
63
|
+
);
|
|
64
|
+
};
|
|
@@ -3,7 +3,12 @@ import { Form, Space, Col } from "antd";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import Helper from "./Helper";
|
|
5
5
|
import { useClassName } from "../../hooks";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
useFormItemHover,
|
|
8
|
+
useFormItemLabel,
|
|
9
|
+
useHide,
|
|
10
|
+
usePositionClassName,
|
|
11
|
+
} from "./hooks";
|
|
7
12
|
import { useFormContext } from "../Context";
|
|
8
13
|
import type { HItemProps } from "../modal";
|
|
9
14
|
import { useDefaultRender } from "../hooks/useDefaultRender";
|
|
@@ -68,7 +73,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
68
73
|
const className = usePositionClassName(align);
|
|
69
74
|
const hideItem = useHide({ hide, form });
|
|
70
75
|
const formItemLabel = useFormItemLabel(form, label);
|
|
71
|
-
const itemHover=useFormItemHover(form,hover)
|
|
76
|
+
const itemHover = useFormItemHover(form, hover);
|
|
72
77
|
if (hideItem) {
|
|
73
78
|
return null;
|
|
74
79
|
}
|
|
@@ -2,7 +2,7 @@ import UpFormItem from "./UpFormItem";
|
|
|
2
2
|
import RegularFormItem from "./RegularFormItem";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import type {HFormInstance, HItemProps, HoverFn, HoverModal} from "../modal";
|
|
5
|
+
import type { HFormInstance, HItemProps, HoverFn, HoverModal } from "../modal";
|
|
6
6
|
import type { LabelAlignModal } from "../modal";
|
|
7
7
|
import { useClassName } from "../../hooks";
|
|
8
8
|
import type { HelperModal } from "../modal";
|
|
@@ -63,8 +63,8 @@ export const useFormItemLabel = (
|
|
|
63
63
|
};
|
|
64
64
|
|
|
65
65
|
export const useFormItemHover = (
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
form: HFormInstance,
|
|
67
|
+
hover?: string | HoverModal | HoverFn
|
|
68
68
|
) => {
|
|
69
69
|
return typeof hover === "function" ? hover(form) : hover;
|
|
70
70
|
};
|
|
@@ -6,26 +6,27 @@ import { useFormContext } from "../Context";
|
|
|
6
6
|
export default (props: HItemProps) => {
|
|
7
7
|
const {
|
|
8
8
|
labelWidth: formLabelWidth,
|
|
9
|
-
labelAlign: formLabelAlign
|
|
10
|
-
hideLabel:formLabelHide,
|
|
9
|
+
labelAlign: formLabelAlign,
|
|
10
|
+
hideLabel: formLabelHide,
|
|
11
11
|
formItemStyle,
|
|
12
|
-
colon:formColon
|
|
12
|
+
colon: formColon,
|
|
13
13
|
} = useFormContext();
|
|
14
14
|
const {
|
|
15
15
|
labelWidth = formLabelWidth,
|
|
16
16
|
labelAlign = formLabelAlign,
|
|
17
|
-
hideLabel=formLabelHide,
|
|
18
|
-
style=formItemStyle,
|
|
19
|
-
colon
|
|
17
|
+
hideLabel = formLabelHide,
|
|
18
|
+
style = formItemStyle,
|
|
19
|
+
colon,
|
|
20
20
|
} = props;
|
|
21
21
|
const Component = useFormItemDomControl(props);
|
|
22
22
|
return (
|
|
23
|
-
<Component
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
<Component
|
|
24
|
+
{...props}
|
|
25
|
+
labelAlign={labelAlign}
|
|
26
|
+
labelWidth={labelWidth}
|
|
27
|
+
hideLabel={hideLabel}
|
|
28
|
+
style={style}
|
|
29
|
+
colon={typeof colon !== "undefined" ? colon : formColon}
|
|
29
30
|
/>
|
|
30
31
|
);
|
|
31
32
|
};
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
height: auto;
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
.@{ant-prefix}-hw-form-base-item-right
|
|
42
|
+
.@{ant-prefix}-hw-form-base-item-right > .@{ant-prefix}-form-item-label {
|
|
43
43
|
.@{ant-prefix}-hw-form-label-item {
|
|
44
44
|
text-align: right;
|
|
45
45
|
}
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
.@{ant-prefix}-hw-form-base-item-left
|
|
51
|
+
.@{ant-prefix}-hw-form-base-item-left > .@{ant-prefix}-form-item-label {
|
|
52
52
|
.@{ant-prefix}-hw-form-label-item {
|
|
53
53
|
text-align: left;
|
|
54
54
|
}
|
|
@@ -4,7 +4,7 @@ import { useCurrentForm, useInfoReq, useValuesChange } from "./hooks";
|
|
|
4
4
|
import { FormContext } from "./Context";
|
|
5
5
|
import PageHandler from "../PageHandler";
|
|
6
6
|
import useInitConfigData from "./hooks/useInitConfigData";
|
|
7
|
-
import {useEffect, useMemo, useState} from "react";
|
|
7
|
+
import { useEffect, useMemo, useState } from "react";
|
|
8
8
|
import InitSet from "./InitSet";
|
|
9
9
|
import Basic from "./Basic";
|
|
10
10
|
|
|
@@ -27,10 +27,11 @@ export default ({
|
|
|
27
27
|
formItemStyle,
|
|
28
28
|
itemProps: formItemProps = {},
|
|
29
29
|
colon = true,
|
|
30
|
+
dismissOnPressEnter,
|
|
30
31
|
...props
|
|
31
32
|
}: HFormProps) => {
|
|
32
33
|
const hForm = useCurrentForm(form);
|
|
33
|
-
const [dispatchSourceData,setDispatchSourceData]=useState({});
|
|
34
|
+
const [dispatchSourceData, setDispatchSourceData] = useState({});
|
|
34
35
|
|
|
35
36
|
const { subControl, infoControl } = useInfoReq({
|
|
36
37
|
initialValues,
|
|
@@ -59,14 +60,14 @@ export default ({
|
|
|
59
60
|
hForm.removeDispatchListener();
|
|
60
61
|
};
|
|
61
62
|
}, []);
|
|
62
|
-
const setData=(newData)=>{
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
63
|
+
const setData = (newData) => {
|
|
64
|
+
setDispatchSourceData((oldData) => {
|
|
65
|
+
return {
|
|
66
|
+
...oldData,
|
|
67
|
+
...newData,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
};
|
|
70
71
|
return (
|
|
71
72
|
<PageHandler
|
|
72
73
|
loading={infoLoading}
|
|
@@ -82,11 +83,11 @@ export default ({
|
|
|
82
83
|
labelAlign: formLabelAlign,
|
|
83
84
|
labelWidth,
|
|
84
85
|
formItemStyle,
|
|
85
|
-
hideLabel:formHideLabel,
|
|
86
|
+
hideLabel: formHideLabel,
|
|
86
87
|
colon,
|
|
87
|
-
itemProps:formItemProps,
|
|
88
|
+
itemProps: formItemProps,
|
|
88
89
|
itemSpan,
|
|
89
|
-
setData
|
|
90
|
+
setData,
|
|
90
91
|
}}
|
|
91
92
|
>
|
|
92
93
|
<Form
|
|
@@ -95,7 +96,7 @@ export default ({
|
|
|
95
96
|
onValuesChange={valuesChange}
|
|
96
97
|
{...props}
|
|
97
98
|
>
|
|
98
|
-
<Basic configData={configData} gutter={gutter}/>
|
|
99
|
+
<Basic configData={configData} dismissOnPressEnter={dismissOnPressEnter} gutter={gutter} />
|
|
99
100
|
<InitSet />
|
|
100
101
|
</Form>
|
|
101
102
|
</FormContext.Provider>
|
|
@@ -62,7 +62,7 @@ export interface HoverModal {
|
|
|
62
62
|
text?: string;
|
|
63
63
|
icon?: React.ReactNode;
|
|
64
64
|
}
|
|
65
|
-
export type HoverFn=(form: HFormInstance) => string|HoverModal
|
|
65
|
+
export type HoverFn = (form: HFormInstance) => string | HoverModal;
|
|
66
66
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
67
67
|
|
|
68
68
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
@@ -86,7 +86,7 @@ export interface HItemProps
|
|
|
86
86
|
itemProps?: ItemPropsType;
|
|
87
87
|
render?: RenderFun;
|
|
88
88
|
helper?: HelperModal | React.ReactNode;
|
|
89
|
-
hover?: string | HoverModal|HoverFn;
|
|
89
|
+
hover?: string | HoverModal | HoverFn;
|
|
90
90
|
// formItems?: HItemProps[]; 保留感觉没必要
|
|
91
91
|
labelWidth?: number;
|
|
92
92
|
hide?: boolean | HideModal;
|
|
@@ -116,6 +116,7 @@ export interface HFormProps<T = any, R = any>
|
|
|
116
116
|
labelAlign?: LabelAlignModal;
|
|
117
117
|
formItemStyle?: React.CSSProperties;
|
|
118
118
|
itemProps?: ItemPropsType;
|
|
119
|
+
dismissOnPressEnter?:boolean;
|
|
119
120
|
}
|
|
120
121
|
export interface HFormItemProps extends HItemProps {
|
|
121
122
|
required?: boolean;
|
|
@@ -18,7 +18,7 @@ interface IProps<T = any> {
|
|
|
18
18
|
onChange: (value: T) => void;
|
|
19
19
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
20
20
|
noHandlerWrap?: boolean;
|
|
21
|
-
disabled?:boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
22
|
}
|
|
23
23
|
const useArrayProps = (props: any) => {
|
|
24
24
|
return useMemo(() => {
|
|
@@ -37,7 +37,7 @@ const InputNumberGroup = ({
|
|
|
37
37
|
addonAfter,
|
|
38
38
|
noHandlerWrap = true,
|
|
39
39
|
addFormat,
|
|
40
|
-
|
|
40
|
+
disabled,
|
|
41
41
|
}: IProps) => {
|
|
42
42
|
const { min, max } = valueMap;
|
|
43
43
|
const { [min]: minVal, [max]: maxVal } = value;
|
|
@@ -50,8 +50,8 @@ const InputNumberGroup = ({
|
|
|
50
50
|
const borderClassname = useClassName(["hw-input-group-border"]);
|
|
51
51
|
const oneClassname = useClassName(["hw-input-group-one"]);
|
|
52
52
|
const iconClassname = useClassName(["hw-input-group-icon"]);
|
|
53
|
-
const disabledClassname=useClassName(["hw-input-group-disabled"]);
|
|
54
|
-
const notDisabledClassname=useClassName(["hw-input-group-not-disabled"])
|
|
53
|
+
const disabledClassname = useClassName(["hw-input-group-disabled"]);
|
|
54
|
+
const notDisabledClassname = useClassName(["hw-input-group-not-disabled"]);
|
|
55
55
|
|
|
56
56
|
const noHandlerWrapClassname = useClassName([
|
|
57
57
|
"hw-input-group-no-handler-wrap",
|
|
@@ -103,7 +103,7 @@ const InputNumberGroup = ({
|
|
|
103
103
|
className={`${bodyClassname}
|
|
104
104
|
${focus ? activeClassname : ""}
|
|
105
105
|
${noHandlerWrap ? noHandlerWrapClassname : ""}
|
|
106
|
-
${disabled?disabledClassname:notDisabledClassname}
|
|
106
|
+
${disabled ? disabledClassname : notDisabledClassname}
|
|
107
107
|
`}
|
|
108
108
|
>
|
|
109
109
|
<span className={borderClassname} />
|
|
@@ -126,9 +126,9 @@ const InputNumberGroup = ({
|
|
|
126
126
|
{...fsProps}
|
|
127
127
|
disabled={disabled}
|
|
128
128
|
/>
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
<div className={iconClassname}>
|
|
130
|
+
<SwapRightOutlined />
|
|
131
|
+
</div>
|
|
132
132
|
<InputNumber<number>
|
|
133
133
|
bordered={false}
|
|
134
134
|
value={maxVal}
|