@hw-component/form 1.7.6 → 1.7.8
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/Form/FormItem/BasicItem.js +3 -2
- package/es/Form/FormItem/hooks.d.ts +2 -1
- package/es/Form/FormItem/hooks.js +4 -1
- package/es/Form/modal.d.ts +2 -1
- package/es/Input/InputNumberGroup.js +5 -3
- package/es/Select/hooks/changeHooks.js +52 -8
- package/es/index.css +13 -8
- package/lib/Form/FormItem/BasicItem.js +2 -1
- package/lib/Form/FormItem/hooks.d.ts +2 -1
- package/lib/Form/FormItem/hooks.js +4 -0
- package/lib/Form/modal.d.ts +2 -1
- package/lib/Input/InputNumberGroup.js +5 -3
- package/lib/Select/hooks/changeHooks.js +52 -8
- package/lib/index.css +13 -8
- package/package.json +1 -1
- package/src/components/Form/Basic.tsx +1 -0
- package/src/components/Form/FormItem/BasicItem.tsx +3 -2
- package/src/components/Form/FormItem/hooks.tsx +8 -1
- package/src/components/Form/modal.ts +2 -1
- package/src/components/Input/InputNumberGroup.tsx +10 -4
- package/src/components/Input/index.less +9 -2
- package/src/components/Select/hooks/changeHooks.tsx +35 -9
- package/src/pages/Form/index.tsx +79 -64
- package/src/pages/Select/index.tsx +12 -61
|
@@ -15,7 +15,7 @@ import { Col, Form, Space } from 'antd';
|
|
|
15
15
|
import React from 'react';
|
|
16
16
|
import Index$2 from './Helper.js';
|
|
17
17
|
import { useClassName } from '../../hooks/index.js';
|
|
18
|
-
import { usePositionClassName, useHide, useFormItemLabel } from './hooks.js';
|
|
18
|
+
import { usePositionClassName, useHide, useFormItemLabel, useFormItemHover } from './hooks.js';
|
|
19
19
|
import { useFormContext } from '../Context/index.js';
|
|
20
20
|
import { useDefaultRender } from '../hooks/useDefaultRender.js';
|
|
21
21
|
import { useDefaultComponents } from '../hooks/index.js';
|
|
@@ -93,6 +93,7 @@ var Index = function Index(props) {
|
|
|
93
93
|
form: form
|
|
94
94
|
});
|
|
95
95
|
var formItemLabel = useFormItemLabel(form, label);
|
|
96
|
+
var itemHover = useFormItemHover(form, hover);
|
|
96
97
|
if (hideItem) {
|
|
97
98
|
return null;
|
|
98
99
|
}
|
|
@@ -101,7 +102,7 @@ var Index = function Index(props) {
|
|
|
101
102
|
children: jsx(Form.Item, _objectSpread(_objectSpread({
|
|
102
103
|
className: className,
|
|
103
104
|
label: !hideLabel && jsx(Index$1, {
|
|
104
|
-
hover:
|
|
105
|
+
hover: itemHover,
|
|
105
106
|
labelWidth: labelWidth,
|
|
106
107
|
required: required,
|
|
107
108
|
colon: colon,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type { HFormInstance, HItemProps } from "../modal";
|
|
2
|
+
import type { HFormInstance, HItemProps, HoverFn, HoverModal } from "../modal";
|
|
3
3
|
import type { LabelAlignModal } from "../modal";
|
|
4
4
|
import type { HelperModal } from "../modal";
|
|
5
5
|
export declare const useFormItemDomControl: ({ shouldUpdate, hide, dependencies, }: HItemProps) => ({ shouldUpdate, dependencies, hide, itemSpan, ...props }: import("../modal").HFormItemProps) => JSX.Element;
|
|
@@ -10,4 +10,5 @@ export declare const useShouldUpdate: ({ hide, shouldUpdate, }: Omit<HItemProps,
|
|
|
10
10
|
export declare const useHide: ({ hide, form }: UseHideUpItemModal) => boolean;
|
|
11
11
|
export declare const usePositionClassName: (position: LabelAlignModal) => string;
|
|
12
12
|
export declare const useFormItemLabel: (form: HFormInstance, label?: React.ReactNode | HelperModal) => any;
|
|
13
|
+
export declare const useFormItemHover: (form: HFormInstance, hover?: string | HoverModal | HoverFn) => string | HoverModal | undefined;
|
|
13
14
|
export {};
|
|
@@ -48,6 +48,9 @@ var usePositionClassName = function usePositionClassName(position) {
|
|
|
48
48
|
var useFormItemLabel = function useFormItemLabel(form, label) {
|
|
49
49
|
return typeof label === "function" ? label(form) : label;
|
|
50
50
|
};
|
|
51
|
+
var useFormItemHover = function useFormItemHover(form, hover) {
|
|
52
|
+
return typeof hover === "function" ? hover(form) : hover;
|
|
53
|
+
};
|
|
51
54
|
|
|
52
|
-
export { useFormItemDomControl, useFormItemLabel, useHide, usePositionClassName, useShouldUpdate };
|
|
55
|
+
export { useFormItemDomControl, useFormItemHover, useFormItemLabel, useHide, usePositionClassName, useShouldUpdate };
|
|
53
56
|
// powered by hdj
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface HoverModal {
|
|
|
23
23
|
text?: string;
|
|
24
24
|
icon?: React.ReactNode;
|
|
25
25
|
}
|
|
26
|
+
export type HoverFn = (form: HFormInstance) => string | HoverModal;
|
|
26
27
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
27
28
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
28
29
|
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
@@ -39,7 +40,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign" |
|
|
|
39
40
|
itemProps?: ItemPropsType;
|
|
40
41
|
render?: RenderFun;
|
|
41
42
|
helper?: HelperModal | React.ReactNode;
|
|
42
|
-
hover?: string | HoverModal;
|
|
43
|
+
hover?: string | HoverModal | HoverFn;
|
|
43
44
|
labelWidth?: number;
|
|
44
45
|
hide?: boolean | HideModal;
|
|
45
46
|
placeholder?: string | string[];
|
|
@@ -75,6 +75,7 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
75
75
|
var borderClassname = useClassName(["hw-input-group-border"]);
|
|
76
76
|
var oneClassname = useClassName(["hw-input-group-one"]);
|
|
77
77
|
var iconClassname = useClassName(["hw-input-group-icon"]);
|
|
78
|
+
useClassName(["hw-input-group-disabled"]);
|
|
78
79
|
var noHandlerWrapClassname = useClassName(["hw-input-group-no-handler-wrap"]);
|
|
79
80
|
addFormat === null || addFormat === void 0 || addFormat({
|
|
80
81
|
float: {
|
|
@@ -116,7 +117,7 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
116
117
|
value: value,
|
|
117
118
|
onChange: onChange
|
|
118
119
|
}) : addonAfter, jsxs("div", {
|
|
119
|
-
className: "".concat(bodyClassname, " ").concat(focus ? activeClassname : "", " ").concat(noHandlerWrap ? noHandlerWrapClassname : ""),
|
|
120
|
+
className: "".concat(bodyClassname, " \n ").concat(focus ? activeClassname : "", " \n ").concat(noHandlerWrap ? noHandlerWrapClassname : "", "\n \n "),
|
|
120
121
|
children: [jsx("span", {
|
|
121
122
|
className: borderClassname
|
|
122
123
|
}), jsx(InputNumber, _objectSpread({
|
|
@@ -135,8 +136,9 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
135
136
|
change(min, val);
|
|
136
137
|
},
|
|
137
138
|
placeholder: fsPlaceholder
|
|
138
|
-
}, fsProps)), jsx(
|
|
139
|
-
className: iconClassname
|
|
139
|
+
}, fsProps)), jsx("div", {
|
|
140
|
+
className: iconClassname,
|
|
141
|
+
children: jsx(SwapRightOutlined, {})
|
|
140
142
|
}), jsx(InputNumber, _objectSpread({
|
|
141
143
|
bordered: false,
|
|
142
144
|
value: maxVal,
|
|
@@ -1,10 +1,22 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
2
4
|
import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
|
|
3
5
|
import 'core-js/modules/es.array.map.js';
|
|
6
|
+
import 'core-js/modules/es.object.keys.js';
|
|
7
|
+
import 'core-js/modules/es.symbol.js';
|
|
8
|
+
import 'core-js/modules/es.array.filter.js';
|
|
9
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
10
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
11
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
12
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
4
13
|
import { useState, useEffect } from 'react';
|
|
5
14
|
import { itemOpProvider } from '../utils.js';
|
|
6
15
|
import { matchNotFind } from './util.js';
|
|
7
16
|
|
|
17
|
+
var _excluded = ["label", "value"];
|
|
18
|
+
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; }
|
|
19
|
+
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; }
|
|
8
20
|
var useValueChange = function useValueChange(params) {
|
|
9
21
|
var labelInValue = params.labelInValue,
|
|
10
22
|
onChange = params.onChange,
|
|
@@ -18,6 +30,28 @@ var useValueChange = function useValueChange(params) {
|
|
|
18
30
|
_useState2 = _slicedToArray(_useState, 2),
|
|
19
31
|
val = _useState2[0],
|
|
20
32
|
setVal = _useState2[1];
|
|
33
|
+
var labelInValueItemMaker = function labelInValueItemMaker(changeVal) {
|
|
34
|
+
var _objectSpread2;
|
|
35
|
+
var _fieldNames$value = fieldNames.value,
|
|
36
|
+
fieldValue = _fieldNames$value === void 0 ? "value" : _fieldNames$value,
|
|
37
|
+
_fieldNames$label = fieldNames.label,
|
|
38
|
+
fieldLabel = _fieldNames$label === void 0 ? "label" : _fieldNames$label;
|
|
39
|
+
var changeLabel = changeVal.label,
|
|
40
|
+
changeValue = changeVal.value,
|
|
41
|
+
oVal = _objectWithoutProperties(changeVal, _excluded);
|
|
42
|
+
return _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldValue, changeValue), _defineProperty(_objectSpread2, fieldLabel, changeLabel), _objectSpread2), oVal);
|
|
43
|
+
};
|
|
44
|
+
var labelInValueMaker = function labelInValueMaker(changeVal) {
|
|
45
|
+
if (!changeVal) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
if (!Array.isArray(changeVal)) {
|
|
49
|
+
return labelInValueItemMaker(changeVal);
|
|
50
|
+
}
|
|
51
|
+
return changeVal.map(function (item) {
|
|
52
|
+
return labelInValueItemMaker(item);
|
|
53
|
+
});
|
|
54
|
+
};
|
|
21
55
|
var change = function change(changeVal, itemOps) {
|
|
22
56
|
if (!onChange) {
|
|
23
57
|
setVal(changeVal);
|
|
@@ -27,16 +61,17 @@ var useValueChange = function useValueChange(params) {
|
|
|
27
61
|
onChange(changeVal, itemOps);
|
|
28
62
|
return;
|
|
29
63
|
}
|
|
30
|
-
var
|
|
64
|
+
var subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
31
65
|
if (labelInValue) {
|
|
32
|
-
|
|
66
|
+
onChange(labelInValueMaker(changeVal), itemOps);
|
|
67
|
+
return;
|
|
33
68
|
}
|
|
34
|
-
|
|
69
|
+
var newChangeVal = changeVal.value;
|
|
70
|
+
if (Array.isArray(changeVal) && !labelInValue) {
|
|
35
71
|
newChangeVal = changeVal.map(function (item) {
|
|
36
72
|
return item.value;
|
|
37
73
|
});
|
|
38
74
|
}
|
|
39
|
-
var subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
40
75
|
onChange(newChangeVal, subItemOps);
|
|
41
76
|
};
|
|
42
77
|
useEffect(function () {
|
|
@@ -44,7 +79,7 @@ var useValueChange = function useValueChange(params) {
|
|
|
44
79
|
setVal(undefined);
|
|
45
80
|
return;
|
|
46
81
|
}
|
|
47
|
-
if (mode === "tags") {
|
|
82
|
+
if (mode === "tags" || labelInValue) {
|
|
48
83
|
setVal(value);
|
|
49
84
|
return;
|
|
50
85
|
}
|
|
@@ -58,6 +93,18 @@ var useValueChange = function useValueChange(params) {
|
|
|
58
93
|
var itemVal = item.value,
|
|
59
94
|
label = item.label,
|
|
60
95
|
noMatch = item.noMatch;
|
|
96
|
+
var _fieldNames$value2 = fieldNames.value,
|
|
97
|
+
fieldValue = _fieldNames$value2 === void 0 ? "value" : _fieldNames$value2,
|
|
98
|
+
_fieldNames$label2 = fieldNames.label,
|
|
99
|
+
fieldLabel = _fieldNames$label2 === void 0 ? "label" : _fieldNames$label2;
|
|
100
|
+
if (labelInValue) {
|
|
101
|
+
var changeVal = item[fieldValue],
|
|
102
|
+
changeLable = item[fieldLabel];
|
|
103
|
+
return {
|
|
104
|
+
value: changeVal,
|
|
105
|
+
label: changeLable
|
|
106
|
+
};
|
|
107
|
+
}
|
|
61
108
|
if (noMatch) {
|
|
62
109
|
return {
|
|
63
110
|
value: itemVal,
|
|
@@ -72,9 +119,6 @@ var useValueChange = function useValueChange(params) {
|
|
|
72
119
|
};
|
|
73
120
|
};
|
|
74
121
|
var valuesMaker = function valuesMaker() {
|
|
75
|
-
if (labelInValue) {
|
|
76
|
-
return val;
|
|
77
|
-
}
|
|
78
122
|
if (val === undefined || mode === "tags") {
|
|
79
123
|
return val;
|
|
80
124
|
}
|
package/es/index.css
CHANGED
|
@@ -83,15 +83,15 @@
|
|
|
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
|
+
.ant-hw-input-group-disabled .ant-hw-input-group-disabled {
|
|
88
|
+
background-color: #f5f5f5;
|
|
89
|
+
}
|
|
86
90
|
.ant-hw-input-group {
|
|
87
91
|
display: -webkit-box !important;
|
|
88
92
|
display: -webkit-flex !important;
|
|
89
93
|
display: -ms-flexbox !important;
|
|
90
94
|
display: flex !important;
|
|
91
|
-
-webkit-box-align: center;
|
|
92
|
-
-webkit-align-items: center;
|
|
93
|
-
-ms-flex-align: center;
|
|
94
|
-
align-items: center;
|
|
95
95
|
width: 100%;
|
|
96
96
|
color: rgba(0, 0, 0, 0.25);
|
|
97
97
|
}
|
|
@@ -105,10 +105,6 @@
|
|
|
105
105
|
-webkit-flex: 1;
|
|
106
106
|
-ms-flex: 1;
|
|
107
107
|
flex: 1;
|
|
108
|
-
-webkit-box-align: center;
|
|
109
|
-
-webkit-align-items: center;
|
|
110
|
-
-ms-flex-align: center;
|
|
111
|
-
align-items: center;
|
|
112
108
|
border: 1px solid #d9d9d9;
|
|
113
109
|
}
|
|
114
110
|
.ant-hw-input-group .ant-hw-input-group-body:hover {
|
|
@@ -132,7 +128,16 @@
|
|
|
132
128
|
background-color: #40a9ff;
|
|
133
129
|
}
|
|
134
130
|
.ant-hw-input-group .ant-hw-input-group-icon {
|
|
131
|
+
display: -webkit-box;
|
|
132
|
+
display: -webkit-flex;
|
|
133
|
+
display: -ms-flexbox;
|
|
134
|
+
display: flex;
|
|
135
|
+
-webkit-box-align: center;
|
|
136
|
+
-webkit-align-items: center;
|
|
137
|
+
-ms-flex-align: center;
|
|
138
|
+
align-items: center;
|
|
135
139
|
padding: 0 4px;
|
|
140
|
+
color: rgba(0, 0, 0, 0.25);
|
|
136
141
|
}
|
|
137
142
|
.ant-hw-input-group .ant-hw-input-group-one {
|
|
138
143
|
-webkit-box-flex: 1;
|
|
@@ -96,6 +96,7 @@ var Index = function Index(props) {
|
|
|
96
96
|
form: form
|
|
97
97
|
});
|
|
98
98
|
var formItemLabel = hooks.useFormItemLabel(form, label);
|
|
99
|
+
var itemHover = hooks.useFormItemHover(form, hover);
|
|
99
100
|
if (hideItem) {
|
|
100
101
|
return null;
|
|
101
102
|
}
|
|
@@ -104,7 +105,7 @@ var Index = function Index(props) {
|
|
|
104
105
|
children: jsxRuntime.jsx(antd.Form.Item, _objectSpread(_objectSpread({
|
|
105
106
|
className: className,
|
|
106
107
|
label: !hideLabel && jsxRuntime.jsx(Label.default, {
|
|
107
|
-
hover:
|
|
108
|
+
hover: itemHover,
|
|
108
109
|
labelWidth: labelWidth,
|
|
109
110
|
required: required,
|
|
110
111
|
colon: colon,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type { HFormInstance, HItemProps } from "../modal";
|
|
2
|
+
import type { HFormInstance, HItemProps, HoverFn, HoverModal } from "../modal";
|
|
3
3
|
import type { LabelAlignModal } from "../modal";
|
|
4
4
|
import type { HelperModal } from "../modal";
|
|
5
5
|
export declare const useFormItemDomControl: ({ shouldUpdate, hide, dependencies, }: HItemProps) => ({ shouldUpdate, dependencies, hide, itemSpan, ...props }: import("../modal").HFormItemProps) => JSX.Element;
|
|
@@ -10,4 +10,5 @@ export declare const useShouldUpdate: ({ hide, shouldUpdate, }: Omit<HItemProps,
|
|
|
10
10
|
export declare const useHide: ({ hide, form }: UseHideUpItemModal) => boolean;
|
|
11
11
|
export declare const usePositionClassName: (position: LabelAlignModal) => string;
|
|
12
12
|
export declare const useFormItemLabel: (form: HFormInstance, label?: React.ReactNode | HelperModal) => any;
|
|
13
|
+
export declare const useFormItemHover: (form: HFormInstance, hover?: string | HoverModal | HoverFn) => string | HoverModal | undefined;
|
|
13
14
|
export {};
|
|
@@ -49,8 +49,12 @@ var usePositionClassName = function usePositionClassName(position) {
|
|
|
49
49
|
var useFormItemLabel = function useFormItemLabel(form, label) {
|
|
50
50
|
return typeof label === "function" ? label(form) : label;
|
|
51
51
|
};
|
|
52
|
+
var useFormItemHover = function useFormItemHover(form, hover) {
|
|
53
|
+
return typeof hover === "function" ? hover(form) : hover;
|
|
54
|
+
};
|
|
52
55
|
|
|
53
56
|
exports.useFormItemDomControl = useFormItemDomControl;
|
|
57
|
+
exports.useFormItemHover = useFormItemHover;
|
|
54
58
|
exports.useFormItemLabel = useFormItemLabel;
|
|
55
59
|
exports.useHide = useHide;
|
|
56
60
|
exports.usePositionClassName = usePositionClassName;
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface HoverModal {
|
|
|
23
23
|
text?: string;
|
|
24
24
|
icon?: React.ReactNode;
|
|
25
25
|
}
|
|
26
|
+
export type HoverFn = (form: HFormInstance) => string | HoverModal;
|
|
26
27
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
27
28
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
28
29
|
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
@@ -39,7 +40,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign" |
|
|
|
39
40
|
itemProps?: ItemPropsType;
|
|
40
41
|
render?: RenderFun;
|
|
41
42
|
helper?: HelperModal | React.ReactNode;
|
|
42
|
-
hover?: string | HoverModal;
|
|
43
|
+
hover?: string | HoverModal | HoverFn;
|
|
43
44
|
labelWidth?: number;
|
|
44
45
|
hide?: boolean | HideModal;
|
|
45
46
|
placeholder?: string | string[];
|
|
@@ -78,6 +78,7 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
78
78
|
var borderClassname = index.useClassName(["hw-input-group-border"]);
|
|
79
79
|
var oneClassname = index.useClassName(["hw-input-group-one"]);
|
|
80
80
|
var iconClassname = index.useClassName(["hw-input-group-icon"]);
|
|
81
|
+
index.useClassName(["hw-input-group-disabled"]);
|
|
81
82
|
var noHandlerWrapClassname = index.useClassName(["hw-input-group-no-handler-wrap"]);
|
|
82
83
|
addFormat === null || addFormat === void 0 || addFormat({
|
|
83
84
|
float: {
|
|
@@ -119,7 +120,7 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
119
120
|
value: value,
|
|
120
121
|
onChange: onChange
|
|
121
122
|
}) : addonAfter, jsxRuntime.jsxs("div", {
|
|
122
|
-
className: "".concat(bodyClassname, " ").concat(focus ? activeClassname : "", " ").concat(noHandlerWrap ? noHandlerWrapClassname : ""),
|
|
123
|
+
className: "".concat(bodyClassname, " \n ").concat(focus ? activeClassname : "", " \n ").concat(noHandlerWrap ? noHandlerWrapClassname : "", "\n \n "),
|
|
123
124
|
children: [jsxRuntime.jsx("span", {
|
|
124
125
|
className: borderClassname
|
|
125
126
|
}), jsxRuntime.jsx(antd.InputNumber, _objectSpread({
|
|
@@ -138,8 +139,9 @@ var InputNumberGroup = function InputNumberGroup(_ref) {
|
|
|
138
139
|
change(min, val);
|
|
139
140
|
},
|
|
140
141
|
placeholder: fsPlaceholder
|
|
141
|
-
}, fsProps)), jsxRuntime.jsx(
|
|
142
|
-
className: iconClassname
|
|
142
|
+
}, fsProps)), jsxRuntime.jsx("div", {
|
|
143
|
+
className: iconClassname,
|
|
144
|
+
children: jsxRuntime.jsx(icons.SwapRightOutlined, {})
|
|
143
145
|
}), jsxRuntime.jsx(antd.InputNumber, _objectSpread({
|
|
144
146
|
bordered: false,
|
|
145
147
|
value: maxVal,
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
4
|
+
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
3
5
|
var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
|
|
4
6
|
require('core-js/modules/es.array.map.js');
|
|
7
|
+
require('core-js/modules/es.object.keys.js');
|
|
8
|
+
require('core-js/modules/es.symbol.js');
|
|
9
|
+
require('core-js/modules/es.array.filter.js');
|
|
10
|
+
require('core-js/modules/es.object.to-string.js');
|
|
11
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
12
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
13
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
5
14
|
var React = require('react');
|
|
6
15
|
var utils = require('../utils.js');
|
|
7
16
|
var util = require('./util.js');
|
|
8
17
|
|
|
18
|
+
var _excluded = ["label", "value"];
|
|
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
|
+
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; }
|
|
9
21
|
var useValueChange = function useValueChange(params) {
|
|
10
22
|
var labelInValue = params.labelInValue,
|
|
11
23
|
onChange = params.onChange,
|
|
@@ -19,6 +31,28 @@ var useValueChange = function useValueChange(params) {
|
|
|
19
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
20
32
|
val = _useState2[0],
|
|
21
33
|
setVal = _useState2[1];
|
|
34
|
+
var labelInValueItemMaker = function labelInValueItemMaker(changeVal) {
|
|
35
|
+
var _objectSpread2;
|
|
36
|
+
var _fieldNames$value = fieldNames.value,
|
|
37
|
+
fieldValue = _fieldNames$value === void 0 ? "value" : _fieldNames$value,
|
|
38
|
+
_fieldNames$label = fieldNames.label,
|
|
39
|
+
fieldLabel = _fieldNames$label === void 0 ? "label" : _fieldNames$label;
|
|
40
|
+
var changeLabel = changeVal.label,
|
|
41
|
+
changeValue = changeVal.value,
|
|
42
|
+
oVal = _objectWithoutProperties(changeVal, _excluded);
|
|
43
|
+
return _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, fieldValue, changeValue), _defineProperty(_objectSpread2, fieldLabel, changeLabel), _objectSpread2), oVal);
|
|
44
|
+
};
|
|
45
|
+
var labelInValueMaker = function labelInValueMaker(changeVal) {
|
|
46
|
+
if (!changeVal) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
if (!Array.isArray(changeVal)) {
|
|
50
|
+
return labelInValueItemMaker(changeVal);
|
|
51
|
+
}
|
|
52
|
+
return changeVal.map(function (item) {
|
|
53
|
+
return labelInValueItemMaker(item);
|
|
54
|
+
});
|
|
55
|
+
};
|
|
22
56
|
var change = function change(changeVal, itemOps) {
|
|
23
57
|
if (!onChange) {
|
|
24
58
|
setVal(changeVal);
|
|
@@ -28,16 +62,17 @@ var useValueChange = function useValueChange(params) {
|
|
|
28
62
|
onChange(changeVal, itemOps);
|
|
29
63
|
return;
|
|
30
64
|
}
|
|
31
|
-
var
|
|
65
|
+
var subItemOps = utils.itemOpProvider(itemOps, fieldNames);
|
|
32
66
|
if (labelInValue) {
|
|
33
|
-
|
|
67
|
+
onChange(labelInValueMaker(changeVal), itemOps);
|
|
68
|
+
return;
|
|
34
69
|
}
|
|
35
|
-
|
|
70
|
+
var newChangeVal = changeVal.value;
|
|
71
|
+
if (Array.isArray(changeVal) && !labelInValue) {
|
|
36
72
|
newChangeVal = changeVal.map(function (item) {
|
|
37
73
|
return item.value;
|
|
38
74
|
});
|
|
39
75
|
}
|
|
40
|
-
var subItemOps = utils.itemOpProvider(itemOps, fieldNames);
|
|
41
76
|
onChange(newChangeVal, subItemOps);
|
|
42
77
|
};
|
|
43
78
|
React.useEffect(function () {
|
|
@@ -45,7 +80,7 @@ var useValueChange = function useValueChange(params) {
|
|
|
45
80
|
setVal(undefined);
|
|
46
81
|
return;
|
|
47
82
|
}
|
|
48
|
-
if (mode === "tags") {
|
|
83
|
+
if (mode === "tags" || labelInValue) {
|
|
49
84
|
setVal(value);
|
|
50
85
|
return;
|
|
51
86
|
}
|
|
@@ -59,6 +94,18 @@ var useValueChange = function useValueChange(params) {
|
|
|
59
94
|
var itemVal = item.value,
|
|
60
95
|
label = item.label,
|
|
61
96
|
noMatch = item.noMatch;
|
|
97
|
+
var _fieldNames$value2 = fieldNames.value,
|
|
98
|
+
fieldValue = _fieldNames$value2 === void 0 ? "value" : _fieldNames$value2,
|
|
99
|
+
_fieldNames$label2 = fieldNames.label,
|
|
100
|
+
fieldLabel = _fieldNames$label2 === void 0 ? "label" : _fieldNames$label2;
|
|
101
|
+
if (labelInValue) {
|
|
102
|
+
var changeVal = item[fieldValue],
|
|
103
|
+
changeLable = item[fieldLabel];
|
|
104
|
+
return {
|
|
105
|
+
value: changeVal,
|
|
106
|
+
label: changeLable
|
|
107
|
+
};
|
|
108
|
+
}
|
|
62
109
|
if (noMatch) {
|
|
63
110
|
return {
|
|
64
111
|
value: itemVal,
|
|
@@ -73,9 +120,6 @@ var useValueChange = function useValueChange(params) {
|
|
|
73
120
|
};
|
|
74
121
|
};
|
|
75
122
|
var valuesMaker = function valuesMaker() {
|
|
76
|
-
if (labelInValue) {
|
|
77
|
-
return val;
|
|
78
|
-
}
|
|
79
123
|
if (val === undefined || mode === "tags") {
|
|
80
124
|
return val;
|
|
81
125
|
}
|
package/lib/index.css
CHANGED
|
@@ -83,15 +83,15 @@
|
|
|
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
|
+
.ant-hw-input-group-disabled .ant-hw-input-group-disabled {
|
|
88
|
+
background-color: #f5f5f5;
|
|
89
|
+
}
|
|
86
90
|
.ant-hw-input-group {
|
|
87
91
|
display: -webkit-box !important;
|
|
88
92
|
display: -webkit-flex !important;
|
|
89
93
|
display: -ms-flexbox !important;
|
|
90
94
|
display: flex !important;
|
|
91
|
-
-webkit-box-align: center;
|
|
92
|
-
-webkit-align-items: center;
|
|
93
|
-
-ms-flex-align: center;
|
|
94
|
-
align-items: center;
|
|
95
95
|
width: 100%;
|
|
96
96
|
color: rgba(0, 0, 0, 0.25);
|
|
97
97
|
}
|
|
@@ -105,10 +105,6 @@
|
|
|
105
105
|
-webkit-flex: 1;
|
|
106
106
|
-ms-flex: 1;
|
|
107
107
|
flex: 1;
|
|
108
|
-
-webkit-box-align: center;
|
|
109
|
-
-webkit-align-items: center;
|
|
110
|
-
-ms-flex-align: center;
|
|
111
|
-
align-items: center;
|
|
112
108
|
border: 1px solid #d9d9d9;
|
|
113
109
|
}
|
|
114
110
|
.ant-hw-input-group .ant-hw-input-group-body:hover {
|
|
@@ -132,7 +128,16 @@
|
|
|
132
128
|
background-color: #40a9ff;
|
|
133
129
|
}
|
|
134
130
|
.ant-hw-input-group .ant-hw-input-group-icon {
|
|
131
|
+
display: -webkit-box;
|
|
132
|
+
display: -webkit-flex;
|
|
133
|
+
display: -ms-flexbox;
|
|
134
|
+
display: flex;
|
|
135
|
+
-webkit-box-align: center;
|
|
136
|
+
-webkit-align-items: center;
|
|
137
|
+
-ms-flex-align: center;
|
|
138
|
+
align-items: center;
|
|
135
139
|
padding: 0 4px;
|
|
140
|
+
color: rgba(0, 0, 0, 0.25);
|
|
136
141
|
}
|
|
137
142
|
.ant-hw-input-group .ant-hw-input-group-one {
|
|
138
143
|
-webkit-box-flex: 1;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ 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 { useFormItemLabel, useHide, usePositionClassName
|
|
6
|
+
import {useFormItemHover, useFormItemLabel, useHide, usePositionClassName} from "./hooks";
|
|
7
7
|
import { useFormContext } from "../Context";
|
|
8
8
|
import type { HItemProps } from "../modal";
|
|
9
9
|
import { useDefaultRender } from "../hooks/useDefaultRender";
|
|
@@ -68,6 +68,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
68
68
|
const className = usePositionClassName(align);
|
|
69
69
|
const hideItem = useHide({ hide, form });
|
|
70
70
|
const formItemLabel = useFormItemLabel(form, label);
|
|
71
|
+
const itemHover=useFormItemHover(form,hover)
|
|
71
72
|
if (hideItem) {
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
@@ -78,7 +79,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
78
79
|
label={
|
|
79
80
|
!hideLabel && (
|
|
80
81
|
<Label
|
|
81
|
-
hover={
|
|
82
|
+
hover={itemHover}
|
|
82
83
|
labelWidth={labelWidth}
|
|
83
84
|
required={required}
|
|
84
85
|
colon={colon}
|
|
@@ -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 {
|
|
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";
|
|
@@ -61,3 +61,10 @@ export const useFormItemLabel = (
|
|
|
61
61
|
) => {
|
|
62
62
|
return typeof label === "function" ? label(form) : label;
|
|
63
63
|
};
|
|
64
|
+
|
|
65
|
+
export const useFormItemHover = (
|
|
66
|
+
form: HFormInstance,
|
|
67
|
+
hover?:string|HoverModal|HoverFn
|
|
68
|
+
) => {
|
|
69
|
+
return typeof hover === "function" ? hover(form) : hover;
|
|
70
|
+
};
|
|
@@ -62,6 +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
66
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
66
67
|
|
|
67
68
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
@@ -85,7 +86,7 @@ export interface HItemProps
|
|
|
85
86
|
itemProps?: ItemPropsType;
|
|
86
87
|
render?: RenderFun;
|
|
87
88
|
helper?: HelperModal | React.ReactNode;
|
|
88
|
-
hover?: string | HoverModal;
|
|
89
|
+
hover?: string | HoverModal|HoverFn;
|
|
89
90
|
// formItems?: HItemProps[]; 保留感觉没必要
|
|
90
91
|
labelWidth?: number;
|
|
91
92
|
hide?: boolean | HideModal;
|
|
@@ -36,6 +36,7 @@ const InputNumberGroup = ({
|
|
|
36
36
|
addonAfter,
|
|
37
37
|
noHandlerWrap = true,
|
|
38
38
|
addFormat,
|
|
39
|
+
|
|
39
40
|
}: IProps) => {
|
|
40
41
|
const { min, max } = valueMap;
|
|
41
42
|
const { [min]: minVal, [max]: maxVal } = value;
|
|
@@ -48,6 +49,7 @@ const InputNumberGroup = ({
|
|
|
48
49
|
const borderClassname = useClassName(["hw-input-group-border"]);
|
|
49
50
|
const oneClassname = useClassName(["hw-input-group-one"]);
|
|
50
51
|
const iconClassname = useClassName(["hw-input-group-icon"]);
|
|
52
|
+
const disabledClassname=useClassName(["hw-input-group-disabled"])
|
|
51
53
|
const noHandlerWrapClassname = useClassName([
|
|
52
54
|
"hw-input-group-no-handler-wrap",
|
|
53
55
|
]);
|
|
@@ -95,9 +97,11 @@ const InputNumberGroup = ({
|
|
|
95
97
|
? React.cloneElement(addonAfter as any, { value, onChange })
|
|
96
98
|
: addonAfter}
|
|
97
99
|
<div
|
|
98
|
-
className={`${bodyClassname}
|
|
99
|
-
|
|
100
|
-
}
|
|
100
|
+
className={`${bodyClassname}
|
|
101
|
+
${focus ? activeClassname : ""}
|
|
102
|
+
${noHandlerWrap ? noHandlerWrapClassname : ""}
|
|
103
|
+
|
|
104
|
+
`}
|
|
101
105
|
>
|
|
102
106
|
<span className={borderClassname} />
|
|
103
107
|
<InputNumber<number>
|
|
@@ -118,7 +122,9 @@ const InputNumberGroup = ({
|
|
|
118
122
|
placeholder={fsPlaceholder}
|
|
119
123
|
{...fsProps}
|
|
120
124
|
/>
|
|
121
|
-
|
|
125
|
+
<div className={iconClassname}>
|
|
126
|
+
<SwapRightOutlined />
|
|
127
|
+
</div>
|
|
122
128
|
<InputNumber<number>
|
|
123
129
|
bordered={false}
|
|
124
130
|
value={maxVal}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
@import "../styles/local.less";
|
|
2
2
|
@all-input-group: ~"@{ant-prefix}-hw-input-group";
|
|
3
|
+
|
|
4
|
+
.@{all-input-group},.@{all-input-group}-disabled{
|
|
5
|
+
.@{all-input-group}-disabled{
|
|
6
|
+
background-color: #f5f5f5;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
3
9
|
.@{all-input-group} {
|
|
4
10
|
display: flex !important;
|
|
5
|
-
align-items: center;
|
|
6
11
|
width: 100%;
|
|
7
12
|
color: rgba(0, 0, 0, 0.25);
|
|
8
13
|
.@{all-input-group}-body {
|
|
9
14
|
position: relative;
|
|
10
15
|
display: flex !important;
|
|
11
16
|
flex: 1;
|
|
12
|
-
align-items: center;
|
|
13
17
|
border: 1px solid #d9d9d9;
|
|
14
18
|
&:hover {
|
|
15
19
|
border-color: #40a9ff;
|
|
@@ -35,7 +39,10 @@
|
|
|
35
39
|
background-color: #40a9ff;
|
|
36
40
|
}
|
|
37
41
|
.@{all-input-group}-icon {
|
|
42
|
+
display: flex;
|
|
43
|
+
align-items: center;
|
|
38
44
|
padding: 0 4px;
|
|
45
|
+
color:rgba(0, 0, 0, 0.25);
|
|
39
46
|
}
|
|
40
47
|
.@{all-input-group}-one {
|
|
41
48
|
flex: 1;
|
|
@@ -13,7 +13,26 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
13
13
|
fieldNames = {},
|
|
14
14
|
} = params;
|
|
15
15
|
const [val, setVal] = useState<any>();
|
|
16
|
-
|
|
16
|
+
const labelInValueItemMaker=(changeVal)=>{
|
|
17
|
+
const {value:fieldValue="value",label:fieldLabel="label"}=fieldNames;
|
|
18
|
+
const {label:changeLabel,value:changeValue,...oVal}=changeVal;
|
|
19
|
+
return {
|
|
20
|
+
[fieldValue]:changeValue,
|
|
21
|
+
[fieldLabel]:changeLabel,
|
|
22
|
+
...oVal
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const labelInValueMaker=(changeVal)=>{
|
|
26
|
+
if (!changeVal){
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
if (!Array.isArray(changeVal)){
|
|
30
|
+
return labelInValueItemMaker(changeVal)
|
|
31
|
+
}
|
|
32
|
+
return changeVal.map((item)=>{
|
|
33
|
+
return labelInValueItemMaker(item)
|
|
34
|
+
})
|
|
35
|
+
}
|
|
17
36
|
const change = (changeVal, itemOps) => {
|
|
18
37
|
if (!onChange) {
|
|
19
38
|
setVal(changeVal);
|
|
@@ -23,16 +42,17 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
23
42
|
onChange(changeVal, itemOps);
|
|
24
43
|
return;
|
|
25
44
|
}
|
|
26
|
-
|
|
45
|
+
const subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
27
46
|
if (labelInValue) {
|
|
28
|
-
|
|
47
|
+
onChange(labelInValueMaker(changeVal),itemOps);
|
|
48
|
+
return;
|
|
29
49
|
}
|
|
30
|
-
|
|
50
|
+
let newChangeVal = changeVal.value;
|
|
51
|
+
if (Array.isArray(changeVal)&&!labelInValue) {
|
|
31
52
|
newChangeVal = changeVal.map((item) => {
|
|
32
53
|
return item.value;
|
|
33
54
|
});
|
|
34
55
|
}
|
|
35
|
-
const subItemOps = itemOpProvider(itemOps, fieldNames);
|
|
36
56
|
onChange(newChangeVal, subItemOps);
|
|
37
57
|
};
|
|
38
58
|
useEffect(() => {
|
|
@@ -40,10 +60,11 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
40
60
|
setVal(undefined);
|
|
41
61
|
return;
|
|
42
62
|
}
|
|
43
|
-
if (mode === "tags") {
|
|
63
|
+
if (mode === "tags"||labelInValue) {
|
|
44
64
|
setVal(value);
|
|
45
65
|
return;
|
|
46
66
|
}
|
|
67
|
+
|
|
47
68
|
if (options) {
|
|
48
69
|
setVal((oldVale) => {
|
|
49
70
|
return matchNotFind(params, oldVale);
|
|
@@ -52,6 +73,14 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
52
73
|
}, [value, options, mode]);
|
|
53
74
|
const itemMaker = (item) => {
|
|
54
75
|
const { value: itemVal, label, noMatch } = item;
|
|
76
|
+
const {value:fieldValue="value",label:fieldLabel="label"}=fieldNames;
|
|
77
|
+
if (labelInValue){
|
|
78
|
+
const {[fieldValue]:changeVal,[fieldLabel]:changeLable}=item;
|
|
79
|
+
return {
|
|
80
|
+
value:changeVal,
|
|
81
|
+
label: changeLable
|
|
82
|
+
};
|
|
83
|
+
}
|
|
55
84
|
if (noMatch) {
|
|
56
85
|
return {
|
|
57
86
|
value: itemVal,
|
|
@@ -64,9 +93,6 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
64
93
|
};
|
|
65
94
|
};
|
|
66
95
|
const valuesMaker = () => {
|
|
67
|
-
if (labelInValue) {
|
|
68
|
-
return val;
|
|
69
|
-
}
|
|
70
96
|
if (val === undefined || mode === "tags") {
|
|
71
97
|
return val;
|
|
72
98
|
}
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -4,80 +4,100 @@ import {
|
|
|
4
4
|
HFormConfigProvider,
|
|
5
5
|
HSwitch,
|
|
6
6
|
useHForm,
|
|
7
|
+
HSelect
|
|
7
8
|
} from "../../components";
|
|
8
9
|
import { useState } from "react";
|
|
9
|
-
import {
|
|
10
|
+
import {Button, DatePicker, Form, Input, Row, Space} from "antd";
|
|
10
11
|
const Test2 = () => {
|
|
11
12
|
return <Row style={{ background: "red" }} />;
|
|
12
13
|
};
|
|
13
|
-
const Test3 = ({ value, onChange }) => {
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
14
|
+
const Test3 = ({ value={}, onChange }) => {
|
|
15
|
+
const {fs,end}=value;
|
|
16
|
+
return <Space>
|
|
17
|
+
<HSelect
|
|
18
|
+
options={[{value:"1321",key:1}]}
|
|
19
|
+
value={fs}
|
|
20
|
+
allowClear
|
|
21
|
+
onChange={()=>{
|
|
22
|
+
onChange?.({})
|
|
23
|
+
}}
|
|
24
|
+
/>
|
|
25
|
+
<HSelect options={[{value:"112",key:2}]}
|
|
26
|
+
allowClear
|
|
27
|
+
value={end}
|
|
28
|
+
onChange={(val)=>{
|
|
29
|
+
onChange?.({
|
|
30
|
+
...value,
|
|
31
|
+
end:val
|
|
32
|
+
})
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
</Space>
|
|
26
36
|
};
|
|
37
|
+
const TestItem=()=>{
|
|
38
|
+
return <Form.Item name="name1">
|
|
39
|
+
<Test3/>
|
|
40
|
+
</Form.Item>
|
|
41
|
+
}
|
|
42
|
+
const Test3Item=()=>{
|
|
43
|
+
return <Form.List name="users">
|
|
44
|
+
{(fields, { add, remove }) => (
|
|
45
|
+
<>
|
|
46
|
+
{fields.map(({ key, name, ...restField }) => (
|
|
47
|
+
<Form.Item
|
|
48
|
+
{...restField}
|
|
49
|
+
name={name}
|
|
50
|
+
key={key}
|
|
51
|
+
>
|
|
52
|
+
<Test3/>
|
|
53
|
+
</Form.Item>
|
|
54
|
+
))}
|
|
55
|
+
<Form.Item>
|
|
56
|
+
<Button type="dashed" onClick={() => add({})} block>
|
|
57
|
+
Add field
|
|
58
|
+
</Button>
|
|
59
|
+
</Form.Item>
|
|
60
|
+
</>
|
|
61
|
+
)}
|
|
62
|
+
|
|
63
|
+
</Form.List>
|
|
64
|
+
}
|
|
27
65
|
const formData = (options) => {
|
|
28
66
|
return [
|
|
29
67
|
{
|
|
30
|
-
label: "下拉123",
|
|
31
|
-
className: "xiala",
|
|
32
|
-
type: "select",
|
|
33
|
-
name: "name1",
|
|
34
|
-
rules:[{required:true}],
|
|
35
|
-
itemProps: {
|
|
36
|
-
options: [
|
|
37
|
-
{
|
|
38
|
-
value: "选项1",
|
|
39
|
-
key: 1,
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
value: "选项2",
|
|
43
|
-
key: 2,
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
showSearch: true,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
noStyle:true,
|
|
51
68
|
render:()=>{
|
|
52
|
-
return <HBasicForm
|
|
69
|
+
return <HBasicForm
|
|
70
|
+
configData={[
|
|
53
71
|
{
|
|
54
|
-
label: "下拉",
|
|
72
|
+
label: "下拉123",
|
|
55
73
|
className: "xiala",
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
rules:[{required:true}],
|
|
60
|
-
labelAlign:"right",
|
|
61
|
-
itemProps: {
|
|
62
|
-
options: [
|
|
63
|
-
{
|
|
64
|
-
value: "选项1",
|
|
65
|
-
key: 1,
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
value: "选项2",
|
|
69
|
-
key: 2,
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
showSearch: true,
|
|
73
|
-
},
|
|
74
|
+
render:()=>{
|
|
75
|
+
return <TestItem/>
|
|
76
|
+
}
|
|
74
77
|
},
|
|
75
78
|
]}/>
|
|
76
79
|
}
|
|
77
80
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
{
|
|
82
|
+
label: '会员标签',
|
|
83
|
+
hover: '添加新的会员标签后会覆盖用户原有的会员标签类型',
|
|
84
|
+
nameKey: 'userTags',
|
|
85
|
+
style: {
|
|
86
|
+
marginBottom: 0,
|
|
87
|
+
},
|
|
88
|
+
render:()=>{
|
|
89
|
+
return <HBasicForm
|
|
90
|
+
configData={[
|
|
91
|
+
{
|
|
92
|
+
label: "333",
|
|
93
|
+
className: "xiala",
|
|
94
|
+
render:()=>{
|
|
95
|
+
return <Test3Item/>
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
]}/>
|
|
99
|
+
}
|
|
100
|
+
},
|
|
81
101
|
];
|
|
82
102
|
};
|
|
83
103
|
function Ttta({ form }) {
|
|
@@ -129,12 +149,7 @@ export default () => {
|
|
|
129
149
|
console.log(val, "onValuesChange");
|
|
130
150
|
}}
|
|
131
151
|
initialValues={{
|
|
132
|
-
|
|
133
|
-
min: 1,
|
|
134
|
-
max: 2,
|
|
135
|
-
inputNumberGroup: {
|
|
136
|
-
input: "xxxxxxx",
|
|
137
|
-
},
|
|
152
|
+
name1:{}
|
|
138
153
|
}}
|
|
139
154
|
request={(params) => {
|
|
140
155
|
return new Promise<any>((resolve) => {
|
|
@@ -1,56 +1,28 @@
|
|
|
1
1
|
import { HSelect } from "../../components";
|
|
2
|
-
import { Space } from "antd";
|
|
2
|
+
import { Space ,Select} from "antd";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
export default () => {
|
|
5
|
-
const [selectVal, setSelectVal] = useState(
|
|
5
|
+
const [selectVal, setSelectVal] = useState([{name:"11",id:-100}]);
|
|
6
6
|
return (
|
|
7
7
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
8
|
-
<HSelect
|
|
9
|
-
options={[{ label: "测试", value: 1 }]}
|
|
10
|
-
value={1}
|
|
11
|
-
placeholder="基础"
|
|
12
|
-
allowClear={true}
|
|
13
|
-
/>
|
|
14
|
-
<HSelect
|
|
15
|
-
fieldNames={{ label: "name", value: "value" }}
|
|
16
|
-
options={[
|
|
17
|
-
{ name: "测试1", value: 10, userId: 112321, disabled: true },
|
|
18
|
-
{ name: "测试2", value: 20, userId: 112321 },
|
|
19
|
-
]}
|
|
20
|
-
placeholder="多选"
|
|
21
|
-
value={null}
|
|
22
|
-
onChange={(val, option) => {
|
|
23
|
-
console.log(val);
|
|
24
|
-
setSelectVal(val);
|
|
25
|
-
}}
|
|
26
|
-
allSelect={true}
|
|
27
|
-
mode={"multiple"}
|
|
28
|
-
allowClear={true}
|
|
29
|
-
showSearch={true}
|
|
30
|
-
/>
|
|
31
|
-
<HSelect
|
|
32
|
-
mode={"tags"}
|
|
33
|
-
placeholder="tags模式"
|
|
34
|
-
showSearch={true}
|
|
35
|
-
allowClear={true}
|
|
36
|
-
value={null}
|
|
37
|
-
options={[
|
|
38
|
-
{ label: "测试1", value: 10 },
|
|
39
|
-
{ label: "测试2", value: 20 },
|
|
40
|
-
]}
|
|
41
|
-
/>
|
|
42
8
|
<HSelect
|
|
43
9
|
placeholder="分页"
|
|
44
10
|
serviceSearch
|
|
45
11
|
allowClear={true}
|
|
46
12
|
labelInValue
|
|
47
|
-
|
|
48
|
-
|
|
13
|
+
fieldNames={{
|
|
14
|
+
label:"name",
|
|
15
|
+
value:"id"
|
|
16
|
+
}}
|
|
17
|
+
value={selectVal}
|
|
18
|
+
onChange={(val,item)=>{
|
|
19
|
+
setSelectVal(val)
|
|
20
|
+
}}
|
|
49
21
|
request={async (params) => {
|
|
50
22
|
const { page, size } = params;
|
|
51
23
|
const op = [];
|
|
52
|
-
for (let i = 0; i <
|
|
53
|
-
op.push({
|
|
24
|
+
for (let i = 0; i < 5; i += 1) {
|
|
25
|
+
op.push({ name: `第${page}页第${i}条`, id: i + page });
|
|
54
26
|
}
|
|
55
27
|
return Promise.resolve({
|
|
56
28
|
page,
|
|
@@ -61,27 +33,6 @@ export default () => {
|
|
|
61
33
|
}}
|
|
62
34
|
isList
|
|
63
35
|
/>
|
|
64
|
-
<HSelect
|
|
65
|
-
serviceSearch={true}
|
|
66
|
-
request={(params) => {
|
|
67
|
-
return new Promise((resolve) => {
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
resolve([
|
|
70
|
-
{
|
|
71
|
-
label: `我是搜索文案${params.inputValue}`,
|
|
72
|
-
value: new Date().valueOf(),
|
|
73
|
-
},
|
|
74
|
-
{
|
|
75
|
-
label: `我是搜索文案${params.inputValue}`,
|
|
76
|
-
value: new Date().valueOf() + 1,
|
|
77
|
-
},
|
|
78
|
-
]);
|
|
79
|
-
}, 2000);
|
|
80
|
-
});
|
|
81
|
-
}}
|
|
82
|
-
placeholder="远程搜索"
|
|
83
|
-
mode={"multiple"}
|
|
84
|
-
/>
|
|
85
36
|
</Space>
|
|
86
37
|
);
|
|
87
38
|
};
|