@hw-component/form 0.0.8-beta-v3 → 0.0.8-beta-v5

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.
@@ -73,7 +73,9 @@ var useValueProvider = function useValueProvider(_ref2) {
73
73
  });
74
74
  }, [valueMap]);
75
75
  useEffect(function () {
76
- var checked = oldValueCheckMap.valueMap.checked;
76
+ var _oldValueCheckMap$val = oldValueCheckMap.valueMap,
77
+ checked = _oldValueCheckMap$val.checked,
78
+ noChecked = _oldValueCheckMap$val.noChecked;
77
79
  if (!value) {
78
80
  return;
79
81
  }
@@ -83,6 +85,9 @@ var useValueProvider = function useValueProvider(_ref2) {
83
85
  }
84
86
  setVal(function (oldVal) {
85
87
  var newVal = _objectSpread({}, oldVal);
88
+ Object.keys(newVal).forEach(function (key) {
89
+ newVal[key] = noChecked;
90
+ });
86
91
  value.forEach(function (itemVal) {
87
92
  newVal[itemVal] = checked;
88
93
  });
@@ -66,6 +66,9 @@ var Index = function Index(_ref) {
66
66
  name = _item$name2 === void 0 ? "" : _item$name2;
67
67
  var _outputValue$name = _outputValue[name],
68
68
  itemVal = _outputValue$name === void 0 ? {} : _outputValue$name;
69
+ if (Array.isArray(itemVal)) {
70
+ return _defineProperty({}, name, itemVal);
71
+ }
69
72
  return _objectSpread({}, itemVal);
70
73
  }
71
74
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
- export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, autoClear }: ModifyPropsModal) => {
3
+ export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, autoClear, }: ModifyPropsModal) => {
4
4
  modalFormData: import("../Form/modal").HItemProps[];
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
@@ -165,7 +165,8 @@ var useHForm = (function () {
165
165
  Reflect.deleteProperty(dispatchSourceData, key);
166
166
  },
167
167
  outputValues: function outputValues(value) {
168
- return this.formatValues(value, "outputValue");
168
+ var val = value || form.getFieldsValue();
169
+ return this.formatValues(val, "outputValue");
169
170
  }
170
171
  }, form), {}, {
171
172
  setFieldsValue: function setFieldsValue(values) {
@@ -74,7 +74,9 @@ var useValueProvider = function useValueProvider(_ref2) {
74
74
  });
75
75
  }, [valueMap]);
76
76
  React.useEffect(function () {
77
- var checked = oldValueCheckMap.valueMap.checked;
77
+ var _oldValueCheckMap$val = oldValueCheckMap.valueMap,
78
+ checked = _oldValueCheckMap$val.checked,
79
+ noChecked = _oldValueCheckMap$val.noChecked;
78
80
  if (!value) {
79
81
  return;
80
82
  }
@@ -84,6 +86,9 @@ var useValueProvider = function useValueProvider(_ref2) {
84
86
  }
85
87
  setVal(function (oldVal) {
86
88
  var newVal = _objectSpread({}, oldVal);
89
+ Object.keys(newVal).forEach(function (key) {
90
+ newVal[key] = noChecked;
91
+ });
87
92
  value.forEach(function (itemVal) {
88
93
  newVal[itemVal] = checked;
89
94
  });
@@ -69,6 +69,9 @@ var Index = function Index(_ref) {
69
69
  name = _item$name2 === void 0 ? "" : _item$name2;
70
70
  var _outputValue$name = _outputValue[name],
71
71
  itemVal = _outputValue$name === void 0 ? {} : _outputValue$name;
72
+ if (Array.isArray(itemVal)) {
73
+ return _defineProperty({}, name, itemVal);
74
+ }
72
75
  return _objectSpread({}, itemVal);
73
76
  }
74
77
  }
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { DialogFormProps, HDialogFormInstance, ModifyPropsModal } from "./modal";
3
- export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, autoClear }: ModifyPropsModal) => {
3
+ export declare const useModifyProps: ({ visible, configData, initialValues, dialogForm, afterClose, params, title, onCancel, autoClear, }: ModifyPropsModal) => {
4
4
  modalFormData: import("../Form/modal").HItemProps[];
5
5
  modalVisible: boolean | undefined;
6
6
  setModalVisible: import("react").Dispatch<import("react").SetStateAction<boolean | undefined>>;
@@ -168,7 +168,8 @@ var useHForm = (function () {
168
168
  Reflect.deleteProperty(dispatchSourceData, key);
169
169
  },
170
170
  outputValues: function outputValues(value) {
171
- return this.formatValues(value, "outputValue");
171
+ var val = value || form.getFieldsValue();
172
+ return this.formatValues(val, "outputValue");
172
173
  }
173
174
  }, form), {}, {
174
175
  setFieldsValue: function setFieldsValue(values) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.8-beta-v3",
3
+ "version": "0.0.8-beta-v5",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -58,7 +58,7 @@ export const useValueProvider = ({
58
58
  }, [valueMap]);
59
59
 
60
60
  useEffect(() => {
61
- const { checked } = oldValueCheckMap.valueMap;
61
+ const { checked, noChecked } = oldValueCheckMap.valueMap;
62
62
  if (!value) {
63
63
  return;
64
64
  }
@@ -68,6 +68,9 @@ export const useValueProvider = ({
68
68
  }
69
69
  setVal((oldVal) => {
70
70
  const newVal = { ...oldVal };
71
+ Object.keys(newVal).forEach((key) => {
72
+ newVal[key] = noChecked;
73
+ });
71
74
  value.forEach((itemVal) => {
72
75
  newVal[itemVal] = checked;
73
76
  });
@@ -47,6 +47,11 @@ const Index = ({
47
47
  outputValue: (item, outputValue) => {
48
48
  const { name = "" } = item;
49
49
  const { [name]: itemVal = {} } = outputValue;
50
+ if (Array.isArray(itemVal)) {
51
+ return {
52
+ [name]: itemVal,
53
+ };
54
+ }
50
55
  return {
51
56
  ...itemVal,
52
57
  };
@@ -26,7 +26,7 @@ export default ({
26
26
  footer,
27
27
  params,
28
28
  onValuesChange,
29
- autoClear=true,
29
+ autoClear = true,
30
30
  ...props
31
31
  }: DialogFormProps) => {
32
32
  const currentForm = useCurrentForm(dialogForm);
@@ -47,7 +47,7 @@ export default ({
47
47
  params,
48
48
  title,
49
49
  onCancel,
50
- autoClear
50
+ autoClear,
51
51
  });
52
52
  const cancel = () => {
53
53
  onAfterClose();
@@ -19,7 +19,7 @@ export default ({
19
19
  params,
20
20
  onOk,
21
21
  onValuesChange,
22
- autoClear=true,
22
+ autoClear = true,
23
23
  ...props
24
24
  }: DialogFormProps) => {
25
25
  const currentForm = useCurrentForm(dialogForm);
@@ -54,7 +54,7 @@ export default ({
54
54
  onCancel={cancel}
55
55
  confirmLoading={loading}
56
56
  afterClose={() => {
57
- if (autoClear){
57
+ if (autoClear) {
58
58
  currentForm.clear();
59
59
  }
60
60
  afterClose?.();
@@ -16,7 +16,7 @@ export const useModifyProps = ({
16
16
  params,
17
17
  title,
18
18
  onCancel,
19
- autoClear
19
+ autoClear,
20
20
  }: ModifyPropsModal) => {
21
21
  const [modalVisible, setModalVisible] = useState(visible);
22
22
  const [modalFormData, setModalFormData] = useState(configData);
@@ -26,7 +26,7 @@ autoClear
26
26
  const onAfterClose = () => {
27
27
  onCancel?.();
28
28
  setTimeout(() => {
29
- if (autoClear){
29
+ if (autoClear) {
30
30
  dialogForm.clear();
31
31
  }
32
32
  afterClose?.();
@@ -13,7 +13,7 @@ export interface ModifyPropsModal<P = any> {
13
13
  params?: P;
14
14
  title?: DialogFormProps["title"];
15
15
  onCancel?: VoidFunction;
16
- autoClear?:boolean;
16
+ autoClear?: boolean;
17
17
  }
18
18
  export interface ShowParamsModal<P = any, T = any> {
19
19
  configData?: HItemProps[];
@@ -35,5 +35,5 @@ export interface DialogFormProps<P = any, T = any>
35
35
  onCancel?: VoidFunction;
36
36
  onOk?: (data: T, params: P) => boolean | void;
37
37
  infoRequest?: (params: P) => Promise<T>;
38
- autoClear?:boolean;
38
+ autoClear?: boolean;
39
39
  }
@@ -140,7 +140,8 @@ export default () => {
140
140
  Reflect.deleteProperty(dispatchSourceData, key);
141
141
  },
142
142
  outputValues(value) {
143
- return this.formatValues(value, "outputValue");
143
+ const val=value||form.getFieldsValue()
144
+ return this.formatValues(val, "outputValue");
144
145
  },
145
146
  ...form,
146
147
  setFieldsValue(values) {
@@ -8,7 +8,6 @@ export default () => {
8
8
  { label: "测试", value: "uu" },
9
9
  { label: "测试1", value: "uu1" },
10
10
  ]}
11
- value={{ uu: 0 }}
12
11
  />
13
12
  </Space>
14
13
  );
@@ -73,8 +73,8 @@ const formData = (options) => {
73
73
  rules: [{ required: true }],
74
74
  helper: "帮助我",
75
75
  options: [
76
- { label: "选择1", value: "check1" },
77
- { label: "选择2", value: "check2" },
76
+ { value: "选择1", key: "check1" },
77
+ { value: "选择2", key: "check2" },
78
78
  ],
79
79
  },
80
80
  {