@hw-component/form 1.4.1 → 1.4.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.
@@ -41,20 +41,30 @@ var HFormConnect = (function (component) {
41
41
  var _config$format = config.format,
42
42
  format = _config$format === void 0 ? {} : _config$format;
43
43
  var Index = function Index(props, ref) {
44
- var _props$name = props.name,
45
- name = _props$name === void 0 ? "" : _props$name,
46
- dispatch = props.dispatch;
47
44
  var _useFormContext = useFormContext(),
48
45
  form = _useFormContext.form,
49
46
  _useFormContext$value = _useFormContext.valueType,
50
47
  valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
51
48
  useEffect(function () {
49
+ var name = props.name;
50
+ if (!name) {
51
+ return;
52
+ }
52
53
  form === null || form === void 0 || form.addFormat(name, formatMaker(props, format[valueType]));
53
54
  }, [valueType, props]);
54
55
  var addFormat = function addFormat(aFormat) {
56
+ var name = props.name;
57
+ if (!name) {
58
+ return;
59
+ }
55
60
  form === null || form === void 0 || form.addFormat(name, formatMaker(props, aFormat[valueType]));
56
61
  };
57
62
  var addDispatchListener = function addDispatchListener(key, fn) {
63
+ var name = props.name,
64
+ dispatch = props.dispatch;
65
+ if (!name) {
66
+ return;
67
+ }
58
68
  form === null || form === void 0 || form.addDispatchListener({
59
69
  key: key,
60
70
  name: name,
package/es/Form/config.js CHANGED
@@ -22,7 +22,7 @@ import TrimInput from '../Input/TrimInput.js';
22
22
  import TrimTextArea from '../TextArea/TrimTextArea.js';
23
23
 
24
24
  var placeholderConfig = {
25
- inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload"],
25
+ inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea"],
26
26
  selectType: ["select", "datePicker", "timePicker", "colorInput"]
27
27
  };
28
28
  var componentConfig = {
@@ -69,6 +69,7 @@ var useHForm = (function () {
69
69
  if (!format) {
70
70
  return;
71
71
  }
72
+ console.log(name, "nnnnnnnn");
72
73
  var inputValue = format.inputValue,
73
74
  outputValue = format.outputValue;
74
75
  formatSourceData[name] = {
@@ -44,20 +44,30 @@ var HFormConnect = (function (component) {
44
44
  var _config$format = config.format,
45
45
  format = _config$format === void 0 ? {} : _config$format;
46
46
  var Index = function Index(props, ref) {
47
- var _props$name = props.name,
48
- name = _props$name === void 0 ? "" : _props$name,
49
- dispatch = props.dispatch;
50
47
  var _useFormContext = index.useFormContext(),
51
48
  form = _useFormContext.form,
52
49
  _useFormContext$value = _useFormContext.valueType,
53
50
  valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
54
51
  React.useEffect(function () {
52
+ var name = props.name;
53
+ if (!name) {
54
+ return;
55
+ }
55
56
  form === null || form === void 0 || form.addFormat(name, formatMaker(props, format[valueType]));
56
57
  }, [valueType, props]);
57
58
  var addFormat = function addFormat(aFormat) {
59
+ var name = props.name;
60
+ if (!name) {
61
+ return;
62
+ }
58
63
  form === null || form === void 0 || form.addFormat(name, formatMaker(props, aFormat[valueType]));
59
64
  };
60
65
  var addDispatchListener = function addDispatchListener(key, fn) {
66
+ var name = props.name,
67
+ dispatch = props.dispatch;
68
+ if (!name) {
69
+ return;
70
+ }
61
71
  form === null || form === void 0 || form.addDispatchListener({
62
72
  key: key,
63
73
  name: name,
@@ -25,7 +25,7 @@ var TrimInput = require('../Input/TrimInput.js');
25
25
  var TrimTextArea = require('../TextArea/TrimTextArea.js');
26
26
 
27
27
  var placeholderConfig = {
28
- inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload"],
28
+ inputType: ["input", "inputNumber", "selectInput", "buttonInput", "verificationCodeInput", "trimInput", "urlUpload", "textArea"],
29
29
  selectType: ["select", "datePicker", "timePicker", "colorInput"]
30
30
  };
31
31
  var componentConfig = {
@@ -72,6 +72,7 @@ var useHForm = (function () {
72
72
  if (!format) {
73
73
  return;
74
74
  }
75
+ console.log(name, "nnnnnnnn");
75
76
  var inputValue = format.inputValue,
76
77
  outputValue = format.outputValue;
77
78
  formatSourceData[name] = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.4.1",
3
+ "version": "1.4.3",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,17 +43,28 @@ export default (
43
43
  props: HFormItemProps,
44
44
  ref
45
45
  ) => {
46
- const { name = "", dispatch } = props;
47
46
 
48
47
  const { form, valueType = "float" } = useFormContext();
49
48
 
50
49
  useEffect(() => {
50
+ const {name}=props;
51
+ if (!name){
52
+ return;
53
+ }
51
54
  form?.addFormat(name, formatMaker(props, format[valueType]));
52
55
  }, [valueType, props]);
53
56
  const addFormat = (aFormat: Record<string, addFormatItemModal>) => {
57
+ const {name}=props;
58
+ if (!name){
59
+ return;
60
+ }
54
61
  form?.addFormat(name, formatMaker(props, aFormat[valueType]));
55
62
  };
56
63
  const addDispatchListener = (key: string, fn: argsFn) => {
64
+ const { name , dispatch } = props;
65
+ if (!name){
66
+ return;
67
+ }
57
68
  form?.addDispatchListener({ key, name, dispatch }, fn);
58
69
  };
59
70
  const Component = component as React.ForwardRefRenderFunction<
@@ -28,6 +28,7 @@ export const placeholderConfig = {
28
28
  "verificationCodeInput",
29
29
  "trimInput",
30
30
  "urlUpload",
31
+ "textArea"
31
32
  ],
32
33
  selectType: ["select", "datePicker", "timePicker", "colorInput"],
33
34
  };
@@ -55,6 +55,7 @@ export default () => {
55
55
  if (!format) {
56
56
  return;
57
57
  }
58
+ console.log(name,"nnnnnnnn")
58
59
  const { inputValue, outputValue } = format;
59
60
  formatSourceData[name] = {
60
61
  inputValue,
@@ -43,7 +43,7 @@ const Index: React.FC<HSwitchProps> = ({
43
43
  float: {
44
44
  inputValue: (item, initValue) => {
45
45
  const { close } = valueSwitchMap;
46
- const { name: valueName = "" } = item;
46
+ const { name: valueName="" } = item;
47
47
  let val = initValue[valueName];
48
48
  if (typeof val === "undefined" || val === null) {
49
49
  val = close;
@@ -1,7 +1,11 @@
1
- import { HForm, HFormConfigProvider, useHForm } from "../../components";
1
+ import {HForm, HFormConfigProvider, HSwitch, useHForm} from "../../components";
2
2
  import { useState } from "react";
3
- import { Button, DatePicker, Form, Input } from "antd";
3
+ import {Button, DatePicker, Form, Input, Row} from "antd";
4
+ const Test2=()=>{
5
+ return <Row style={{background:"red"}}>
4
6
 
7
+ </Row>
8
+ }
5
9
  const formData = (options) => {
6
10
  const op = [
7
11
  {
@@ -14,104 +18,18 @@ const formData = (options) => {
14
18
  },
15
19
  ];
16
20
  return [
21
+ {
22
+ label: "12321",
23
+ className: "3",
24
+ name:"3",
25
+ },
17
26
  {
18
27
  label: "测试12312",
19
28
  className: "hdjd",
20
- name:"test"
21
- },
22
- {
23
- label: "测试1",
24
- type: "select",
25
- },
26
- {
27
- label: "测试1",
28
- type: "inputNumber",
29
- },
30
- {
31
- noStyle: true,
32
- render: () => {
33
- return <div>你好a</div>;
34
- },
35
- },
36
- {
37
- label: "时间",
38
- type: "rangePicker",
39
- name: "rangePicker",
40
- itemProps: {
41
- subProvider: () => {
42
- return {
43
- hdj: "fff",
44
- };
45
- },
46
- },
47
- },
48
- {
49
- label: "选择",
50
- name: "checkboxGroup",
51
- type: "checkboxGroup",
52
- rules: [{ required: true }],
53
- helper: "帮助我",
54
- options: [
55
- { value: "选择1", key: "check1" },
56
- { value: "选择2", key: "check2" },
57
- ],
58
- direction: "vertical",
59
- labelAlign: "topLeft",
60
- },
61
- {
62
- label: "file",
63
- name: "file",
64
- type: "upload",
65
- direction: "vertical",
66
- labelAlign: "topLeft",
67
- },
68
- {
69
- label: "开关",
70
- name: "switch",
71
- type: "switch",
72
- rules: [{ required: true }],
73
- itemProps: {
74
- valueMap: {
75
- open: 1,
76
- close: 0,
77
- },
78
- },
79
- },
80
- {
81
- type: "submit",
82
- itemProps: {
83
- extraList: [
84
- <Button
85
- key="wh"
86
- onClick={() => {
87
- console.log("起飞");
88
- }}
89
- >
90
- 芜湖
91
- </Button>,
92
- "666",
93
- "reset",
94
- ],
95
- },
96
- },
97
- {
98
- type: "submit",
99
- itemProps: {
100
- extraList: [
101
- <Button
102
- key="wh"
103
- onClick={() => {
104
- console.log("起飞");
105
- }}
106
- >
107
- 芜湖
108
- </Button>,
109
- <Ttta key="aa" />,
110
- "666",
111
- "submit",
112
- "reset",
113
- ],
114
- },
29
+ name:"test",
30
+ render:()=>{
31
+ return <Test2/>
32
+ }
115
33
  },
116
34
  ];
117
35
  };
@@ -161,7 +79,6 @@ export default () => {
161
79
  <HForm
162
80
  configData={formData(options)}
163
81
  labelWidth={200}
164
- itemSpan={{ span: 6 }}
165
82
  form={form}
166
83
  labelAlign={"right"}
167
84
  onFinish={(value) => {
@@ -183,8 +100,9 @@ export default () => {
183
100
  />
184
101
  </HFormConfigProvider>
185
102
  <div
186
- onClick={() => {
187
- aForm.resetFields();
103
+ onClick={async () => {
104
+ const result=await form.validateFields();
105
+ console.log(result);
188
106
  }}
189
107
  >
190
108
  点我