@hw-component/form 1.2.6 → 1.2.7
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/Select/index.js +8 -6
- package/lib/Select/index.js +8 -6
- package/package.json +1 -1
- package/src/components/Select/index.tsx +2 -1
- package/src/pages/Form/index.tsx +174 -190
- package/src/pages/Select/index.tsx +1 -0
package/es/Select/index.js
CHANGED
|
@@ -10,6 +10,7 @@ import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
|
10
10
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
11
11
|
import 'core-js/modules/es.array.map.js';
|
|
12
12
|
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
import { createElement } from 'react';
|
|
13
14
|
import { Select } from 'antd';
|
|
14
15
|
import { useFilterOption, useOptionReq } from './hooks/norHooks.js';
|
|
15
16
|
import { useValueChange } from './hooks/changeHooks.js';
|
|
@@ -19,7 +20,8 @@ import Index$2 from './components/AllSelect.js';
|
|
|
19
20
|
import { useMatchConfigProps, useChangeOptions } from '../hooks/index.js';
|
|
20
21
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
21
22
|
|
|
22
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"]
|
|
23
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"],
|
|
24
|
+
_excluded2 = ["value", "label"];
|
|
23
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; }
|
|
24
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; }
|
|
25
27
|
var Option = Select.Option;
|
|
@@ -130,16 +132,16 @@ var Index = function Index(_ref) {
|
|
|
130
132
|
}, props), {}, {
|
|
131
133
|
children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
132
134
|
var optionValue = item.value,
|
|
133
|
-
label = item.label
|
|
135
|
+
label = item.label,
|
|
136
|
+
oItem = _objectWithoutProperties(item, _excluded2);
|
|
134
137
|
var result = (filterProvider === null || filterProvider === void 0 ? void 0 : filterProvider(item)) || label;
|
|
135
138
|
var filter = _defineProperty({}, optionFilterProp, result);
|
|
136
|
-
return
|
|
139
|
+
return /*#__PURE__*/createElement(Option, _objectSpread(_objectSpread({}, oItem), {}, {
|
|
137
140
|
value: optionValue,
|
|
141
|
+
key: optionValue,
|
|
138
142
|
label: label,
|
|
139
143
|
mode: mode
|
|
140
|
-
}, filter),
|
|
141
|
-
children: render ? render(item, val) : label
|
|
142
|
-
}), optionValue);
|
|
144
|
+
}, filter), render ? render(item, val) : label);
|
|
143
145
|
})
|
|
144
146
|
}));
|
|
145
147
|
};
|
package/lib/Select/index.js
CHANGED
|
@@ -13,6 +13,7 @@ var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
|
13
13
|
var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
14
14
|
require('core-js/modules/es.array.map.js');
|
|
15
15
|
var jsxRuntime = require('react/jsx-runtime');
|
|
16
|
+
var React = require('react');
|
|
16
17
|
var antd = require('antd');
|
|
17
18
|
var norHooks = require('./hooks/norHooks.js');
|
|
18
19
|
var changeHooks = require('./hooks/changeHooks.js');
|
|
@@ -22,7 +23,8 @@ var AllSelect = require('./components/AllSelect.js');
|
|
|
22
23
|
var index = require('../hooks/index.js');
|
|
23
24
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
24
25
|
|
|
25
|
-
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"]
|
|
26
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"],
|
|
27
|
+
_excluded2 = ["value", "label"];
|
|
26
28
|
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; }
|
|
27
29
|
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; }
|
|
28
30
|
var Option = antd.Select.Option;
|
|
@@ -133,16 +135,16 @@ var Index = function Index(_ref) {
|
|
|
133
135
|
}, props), {}, {
|
|
134
136
|
children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
135
137
|
var optionValue = item.value,
|
|
136
|
-
label = item.label
|
|
138
|
+
label = item.label,
|
|
139
|
+
oItem = _objectWithoutProperties(item, _excluded2);
|
|
137
140
|
var result = (filterProvider === null || filterProvider === void 0 ? void 0 : filterProvider(item)) || label;
|
|
138
141
|
var filter = _defineProperty({}, optionFilterProp, result);
|
|
139
|
-
return
|
|
142
|
+
return /*#__PURE__*/React.createElement(Option, _objectSpread(_objectSpread({}, oItem), {}, {
|
|
140
143
|
value: optionValue,
|
|
144
|
+
key: optionValue,
|
|
141
145
|
label: label,
|
|
142
146
|
mode: mode
|
|
143
|
-
}, filter),
|
|
144
|
-
children: render ? render(item, val) : label
|
|
145
|
-
}), optionValue);
|
|
147
|
+
}, filter), render ? render(item, val) : label);
|
|
146
148
|
})
|
|
147
149
|
}));
|
|
148
150
|
};
|
package/package.json
CHANGED
|
@@ -105,11 +105,12 @@ const Index: React.FC<HSelectProps> = ({
|
|
|
105
105
|
{...props}
|
|
106
106
|
>
|
|
107
107
|
{data?.map((item) => {
|
|
108
|
-
const { value: optionValue, label } = item;
|
|
108
|
+
const { value: optionValue, label ,...oItem} = item;
|
|
109
109
|
const result = filterProvider?.(item) || label;
|
|
110
110
|
const filter = { [optionFilterProp]: result };
|
|
111
111
|
return (
|
|
112
112
|
<Option
|
|
113
|
+
{...oItem}
|
|
113
114
|
value={optionValue}
|
|
114
115
|
key={optionValue}
|
|
115
116
|
label={label}
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,203 +1,187 @@
|
|
|
1
1
|
import { HForm, HFormConfigProvider, useHForm } from "../../components";
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {useRequest} from "ahooks";
|
|
5
|
-
import {MediaTypeEnum} from "../../components/Upload/enums";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Button, DatePicker, Form, Input } from "antd";
|
|
6
4
|
|
|
7
|
-
const formData = () => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
name:"nameTest"
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
label: "测试1",
|
|
16
|
-
type: "select",
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
label: "测试1",
|
|
20
|
-
type: "inputNumber",
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
noStyle: true,
|
|
24
|
-
render: () => {
|
|
25
|
-
return <div>你好a</div>;
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
label: "时间",
|
|
30
|
-
type: "rangePicker",
|
|
31
|
-
name: "rangePicker",
|
|
32
|
-
itemProps: {
|
|
33
|
-
subProvider: () => {
|
|
34
|
-
console.log("fff");
|
|
5
|
+
const formData = (options) => {
|
|
6
|
+
const op = [
|
|
7
|
+
{
|
|
8
|
+
key: 1,
|
|
9
|
+
value: "是",
|
|
35
10
|
},
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
label:(form)=>{
|
|
40
|
-
const nameTest=form.getFieldValue("nameTest")
|
|
41
|
-
return nameTest;
|
|
42
|
-
},
|
|
43
|
-
name: "checkboxGroup",
|
|
44
|
-
type: "checkboxGroup",
|
|
45
|
-
rules: [{ required: true }],
|
|
46
|
-
shouldUpdate:()=>{
|
|
47
|
-
return true;
|
|
48
|
-
},
|
|
49
|
-
helper: "帮助我",
|
|
50
|
-
options: [
|
|
51
|
-
{ value: "选择1", key: "check1" },
|
|
52
|
-
{ value: "选择2", key: "check2" },
|
|
53
|
-
],
|
|
54
|
-
direction: "vertical",
|
|
55
|
-
labelAlign: "topLeft",
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
label: "开关",
|
|
59
|
-
name: "switch",
|
|
60
|
-
type: "switch",
|
|
61
|
-
rules: [{ required: true }],
|
|
62
|
-
itemProps: {
|
|
63
|
-
valueMap: {
|
|
64
|
-
open: 1,
|
|
65
|
-
close: 0,
|
|
11
|
+
{
|
|
12
|
+
key: 0,
|
|
13
|
+
value: "否",
|
|
66
14
|
},
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
},
|
|
96
|
-
})
|
|
15
|
+
];
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
label: "测试",
|
|
19
|
+
className: "hdjd",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "测试1",
|
|
23
|
+
type: "select",
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: "测试1",
|
|
27
|
+
type: "inputNumber",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
noStyle: true,
|
|
31
|
+
render: () => {
|
|
32
|
+
return <div>你好a</div>;
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
label: "时间",
|
|
37
|
+
type: "rangePicker",
|
|
38
|
+
name: "rangePicker",
|
|
39
|
+
itemProps: {
|
|
40
|
+
subProvider: () => {
|
|
41
|
+
console.log("fff");
|
|
42
|
+
},
|
|
43
|
+
},
|
|
97
44
|
},
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
manual:false
|
|
111
|
-
},
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
type: "urlUpload",
|
|
115
|
-
name:"urlUpload",
|
|
116
|
-
label:"测试",
|
|
117
|
-
helper:"123123",
|
|
118
|
-
itemProps: {
|
|
119
|
-
inputHelper:"fff",
|
|
120
|
-
style:{
|
|
121
|
-
width:368
|
|
45
|
+
{
|
|
46
|
+
label: "选择",
|
|
47
|
+
name: "checkboxGroup",
|
|
48
|
+
type: "checkboxGroup",
|
|
49
|
+
rules: [{ required: true }],
|
|
50
|
+
helper: "帮助我",
|
|
51
|
+
options: [
|
|
52
|
+
{ value: "选择1", key: "check1" },
|
|
53
|
+
{ value: "选择2", key: "check2" },
|
|
54
|
+
],
|
|
55
|
+
direction: "vertical",
|
|
56
|
+
labelAlign: "topLeft",
|
|
122
57
|
},
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
58
|
+
{
|
|
59
|
+
label: "开关",
|
|
60
|
+
name: "switch",
|
|
61
|
+
type: "switch",
|
|
62
|
+
rules: [{ required: true }],
|
|
63
|
+
itemProps: {
|
|
64
|
+
valueMap: {
|
|
65
|
+
open: 1,
|
|
66
|
+
close: 0,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: "submit",
|
|
72
|
+
itemProps: {
|
|
73
|
+
extraList: [
|
|
74
|
+
<Button
|
|
75
|
+
key="wh"
|
|
76
|
+
onClick={() => {
|
|
77
|
+
console.log("起飞");
|
|
78
|
+
}}
|
|
79
|
+
>
|
|
80
|
+
芜湖
|
|
81
|
+
</Button>,
|
|
82
|
+
"666",
|
|
83
|
+
"reset",
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
type: "submit",
|
|
89
|
+
itemProps: {
|
|
90
|
+
extraList: [
|
|
91
|
+
<Button
|
|
92
|
+
key="wh"
|
|
93
|
+
onClick={() => {
|
|
94
|
+
console.log("起飞");
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
芜湖
|
|
98
|
+
</Button>,
|
|
99
|
+
<Ttta key="aa" />,
|
|
100
|
+
"666",
|
|
101
|
+
"submit",
|
|
102
|
+
"reset",
|
|
103
|
+
],
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
];
|
|
130
107
|
};
|
|
131
108
|
function Ttta({ form }) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
109
|
+
return (
|
|
110
|
+
<div
|
|
111
|
+
onClick={() => {
|
|
112
|
+
console.log("form", form);
|
|
113
|
+
form.setFieldsValue({ switch: 1 });
|
|
114
|
+
}}
|
|
115
|
+
>
|
|
116
|
+
ttta
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
142
119
|
}
|
|
143
120
|
|
|
144
121
|
const Test = (props) => {
|
|
145
|
-
|
|
122
|
+
return <div>ffff</div>;
|
|
146
123
|
};
|
|
147
124
|
export default () => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
125
|
+
const form = useHForm();
|
|
126
|
+
const [options, setOptions] = useState([{ label: "1", value: 1 }]);
|
|
127
|
+
const [aForm] = Form.useForm();
|
|
128
|
+
return (
|
|
129
|
+
<div style={{ overflow: "auto", height: "90vh" }}>
|
|
130
|
+
<Form form={aForm} initialValues={{ ttim: "132123" }}>
|
|
131
|
+
<Form.Item name="ttim" rules={[{ required: true }]}>
|
|
132
|
+
<Input />
|
|
133
|
+
</Form.Item>
|
|
134
|
+
</Form>
|
|
135
|
+
<HFormConfigProvider
|
|
136
|
+
valueSwitchMap={{ open: 1, close: 2 }}
|
|
137
|
+
valueCheckMap={{ noChecked: 0, checked: 1 }}
|
|
138
|
+
defaultComponent={{
|
|
139
|
+
test: Test,
|
|
140
|
+
}}
|
|
141
|
+
itemProps={{
|
|
142
|
+
style: {
|
|
143
|
+
borderRadius: 10,
|
|
144
|
+
},
|
|
145
|
+
}}
|
|
146
|
+
fieldNames={{
|
|
147
|
+
label: "value",
|
|
148
|
+
value: "key",
|
|
149
|
+
}}
|
|
150
|
+
>
|
|
151
|
+
<HForm
|
|
152
|
+
configData={formData(options)}
|
|
153
|
+
labelWidth={200}
|
|
154
|
+
form={form}
|
|
155
|
+
labelAlign={"right"}
|
|
156
|
+
onFinish={(value) => {
|
|
157
|
+
console.log(value);
|
|
158
|
+
}}
|
|
159
|
+
onValuesChange={(val) => {
|
|
160
|
+
console.log(val, "onValuesChange");
|
|
161
|
+
}}
|
|
162
|
+
request={(params) => {
|
|
163
|
+
return new Promise<any>((resolve) => {
|
|
164
|
+
setTimeout(() => {
|
|
165
|
+
resolve(params);
|
|
166
|
+
}, 3000);
|
|
167
|
+
});
|
|
168
|
+
}}
|
|
169
|
+
/>
|
|
170
|
+
</HFormConfigProvider>
|
|
171
|
+
<div
|
|
172
|
+
onClick={() => {
|
|
173
|
+
aForm.resetFields();
|
|
174
|
+
}}
|
|
175
|
+
>
|
|
176
|
+
点我
|
|
177
|
+
</div>
|
|
178
|
+
<div
|
|
179
|
+
onClick={() => {
|
|
180
|
+
form.resetFieldsInitValue();
|
|
181
|
+
}}
|
|
182
|
+
>
|
|
183
|
+
重置
|
|
184
|
+
</div>
|
|
185
|
+
</div>
|
|
186
|
+
);
|
|
187
|
+
};
|