@hw-component/form 0.0.4-beta-v7 → 0.0.4-beta-v9

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.
@@ -124,9 +124,16 @@ var useValuesChange = function useValuesChange(_ref4) {
124
124
  if (!!dispatchItem) {
125
125
  var dispatchKey = _Object$keys(dispatchItem);
126
126
  _forEachInstanceProperty(dispatchKey).call(dispatchKey, function (name) {
127
- var key = dispatchItem[name];
127
+ var _dispatchItem$name = dispatchItem[name],
128
+ fnKey = _dispatchItem$name.fnKey,
129
+ reset = _dispatchItem$name.reset;
130
+ reset && form.setFields([{
131
+ name: name,
132
+ value: null,
133
+ errors: []
134
+ }]);
128
135
  form.dispatch({
129
- key: key,
136
+ key: fnKey,
130
137
  name: name
131
138
  }, {
132
139
  changedValues: changedValues,
@@ -96,12 +96,19 @@ var itemControl = function itemControl(item, form, defaultComponents) {
96
96
  };
97
97
  var itemDispatchProvider = function itemDispatchProvider(name, config, dispatchSourceData) {
98
98
  var dependencies = config.dependencies,
99
- fnKey = config.fnKey;
99
+ fnKey = config.fnKey,
100
+ reset = config.reset;
100
101
  var itemDispatch = dispatchSourceData[dependencies];
101
102
  if (!itemDispatch) {
102
- return _defineProperty({}, dependencies, _defineProperty({}, name, fnKey));
103
+ return _defineProperty({}, dependencies, _defineProperty({}, name, {
104
+ fnKey: fnKey,
105
+ reset: reset
106
+ }));
103
107
  }
104
- var itemNameDispatch = _defineProperty({}, name, fnKey);
108
+ var itemNameDispatch = _defineProperty({}, name, {
109
+ fnKey: fnKey,
110
+ reset: reset
111
+ });
105
112
  return _defineProperty({}, dependencies, _objectSpread(_objectSpread({}, itemDispatch), itemNameDispatch));
106
113
  };
107
114
  var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
@@ -115,7 +122,9 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
115
122
  _dispatch$dependencie = dispatch.dependencies,
116
123
  dispatchDependencies = _dispatch$dependencie === void 0 ? dependencies : _dispatch$dependencie,
117
124
  _dispatch$manual = dispatch.manual,
118
- manual = _dispatch$manual === void 0 ? true : _dispatch$manual;
125
+ manual = _dispatch$manual === void 0 ? true : _dispatch$manual,
126
+ _dispatch$reset = dispatch.reset,
127
+ reset = _dispatch$reset === void 0 ? true : _dispatch$reset;
119
128
  if (!fnKey) {
120
129
  return {};
121
130
  }
@@ -125,7 +134,8 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
125
134
  var itemDispatch = itemDispatchProvider(name, {
126
135
  dependencies: key,
127
136
  fnKey: fnKey,
128
- manual: manual
137
+ manual: manual,
138
+ reset: reset
129
139
  }, dispatchSourceData);
130
140
  allDispatch = _objectSpread(_objectSpread({}, allDispatch), itemDispatch);
131
141
  });
@@ -134,7 +144,8 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
134
144
  var itemDispatch = itemDispatchProvider(name, {
135
145
  dependencies: dispatchDependencies,
136
146
  fnKey: fnKey,
137
- manual: manual
147
+ manual: manual,
148
+ reset: reset
138
149
  }, dispatchSourceData);
139
150
  return _objectSpread(_objectSpread({}, dispatchSourceData), itemDispatch);
140
151
  };
package/es/Form/index.js CHANGED
@@ -44,7 +44,6 @@ var HForm = (function (_ref) {
44
44
  }),
45
45
  newConfigData = _useInitConfigData.newConfigData,
46
46
  dispatchSourceData = _useInitConfigData.dispatchSourceData;
47
- console.log(dispatchSourceData, "dispatchSourceData");
48
47
  var _useInfoReq = useInfoReq({
49
48
  initialValues: initialValues,
50
49
  request: request,
@@ -23,11 +23,12 @@ export interface HoverModal {
23
23
  type HelperModal = (form: HFormInstance) => React.ReactNode | string;
24
24
  export type HideModal = (form: HFormInstance) => boolean;
25
25
  export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
26
- export type DispatchSourceDataModal = Record<string, Record<string, string>>;
26
+ export type DispatchSourceDataModal = Record<string, Record<string, DispatchModal>>;
27
27
  export interface DispatchModal<T = string | string[]> {
28
28
  fnKey?: string;
29
29
  dependencies?: T;
30
30
  manual?: boolean;
31
+ reset?: boolean;
31
32
  }
32
33
  export interface HItemProps extends Omit<FormItemProps, "name"> {
33
34
  type?: string;
@@ -178,7 +178,7 @@ var useValueChange = function useValueChange(params) {
178
178
  onChange(newChangeVal, subItemOps);
179
179
  };
180
180
  useEffect(function () {
181
- if (mode === "tags") {
181
+ if (mode === "tags" || value === null || value === undefined) {
182
182
  setVal(value);
183
183
  return;
184
184
  }
@@ -125,9 +125,16 @@ var useValuesChange = function useValuesChange(_ref4) {
125
125
  if (!!dispatchItem) {
126
126
  var dispatchKey = _Object$keys(dispatchItem);
127
127
  _forEachInstanceProperty(dispatchKey).call(dispatchKey, function (name) {
128
- var key = dispatchItem[name];
128
+ var _dispatchItem$name = dispatchItem[name],
129
+ fnKey = _dispatchItem$name.fnKey,
130
+ reset = _dispatchItem$name.reset;
131
+ reset && form.setFields([{
132
+ name: name,
133
+ value: null,
134
+ errors: []
135
+ }]);
129
136
  form.dispatch({
130
- key: key,
137
+ key: fnKey,
131
138
  name: name
132
139
  }, {
133
140
  changedValues: changedValues,
@@ -99,12 +99,19 @@ var itemControl = function itemControl(item, form, defaultComponents) {
99
99
  };
100
100
  var itemDispatchProvider = function itemDispatchProvider(name, config, dispatchSourceData) {
101
101
  var dependencies = config.dependencies,
102
- fnKey = config.fnKey;
102
+ fnKey = config.fnKey,
103
+ reset = config.reset;
103
104
  var itemDispatch = dispatchSourceData[dependencies];
104
105
  if (!itemDispatch) {
105
- return _defineProperty({}, dependencies, _defineProperty({}, name, fnKey));
106
+ return _defineProperty({}, dependencies, _defineProperty({}, name, {
107
+ fnKey: fnKey,
108
+ reset: reset
109
+ }));
106
110
  }
107
- var itemNameDispatch = _defineProperty({}, name, fnKey);
111
+ var itemNameDispatch = _defineProperty({}, name, {
112
+ fnKey: fnKey,
113
+ reset: reset
114
+ });
108
115
  return _defineProperty({}, dependencies, _objectSpread(_objectSpread({}, itemDispatch), itemNameDispatch));
109
116
  };
110
117
  var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
@@ -118,7 +125,9 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
118
125
  _dispatch$dependencie = dispatch.dependencies,
119
126
  dispatchDependencies = _dispatch$dependencie === void 0 ? dependencies : _dispatch$dependencie,
120
127
  _dispatch$manual = dispatch.manual,
121
- manual = _dispatch$manual === void 0 ? true : _dispatch$manual;
128
+ manual = _dispatch$manual === void 0 ? true : _dispatch$manual,
129
+ _dispatch$reset = dispatch.reset,
130
+ reset = _dispatch$reset === void 0 ? true : _dispatch$reset;
122
131
  if (!fnKey) {
123
132
  return {};
124
133
  }
@@ -128,7 +137,8 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
128
137
  var itemDispatch = itemDispatchProvider(name, {
129
138
  dependencies: key,
130
139
  fnKey: fnKey,
131
- manual: manual
140
+ manual: manual,
141
+ reset: reset
132
142
  }, dispatchSourceData);
133
143
  allDispatch = _objectSpread(_objectSpread({}, allDispatch), itemDispatch);
134
144
  });
@@ -137,7 +147,8 @@ var dispatchProvider = function dispatchProvider(item, dispatchSourceData) {
137
147
  var itemDispatch = itemDispatchProvider(name, {
138
148
  dependencies: dispatchDependencies,
139
149
  fnKey: fnKey,
140
- manual: manual
150
+ manual: manual,
151
+ reset: reset
141
152
  }, dispatchSourceData);
142
153
  return _objectSpread(_objectSpread({}, dispatchSourceData), itemDispatch);
143
154
  };
package/lib/Form/index.js CHANGED
@@ -47,7 +47,6 @@ var HForm = (function (_ref) {
47
47
  }),
48
48
  newConfigData = _useInitConfigData.newConfigData,
49
49
  dispatchSourceData = _useInitConfigData.dispatchSourceData;
50
- console.log(dispatchSourceData, "dispatchSourceData");
51
50
  var _useInfoReq = index.useInfoReq({
52
51
  initialValues: initialValues,
53
52
  request: request,
@@ -23,11 +23,12 @@ export interface HoverModal {
23
23
  type HelperModal = (form: HFormInstance) => React.ReactNode | string;
24
24
  export type HideModal = (form: HFormInstance) => boolean;
25
25
  export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
26
- export type DispatchSourceDataModal = Record<string, Record<string, string>>;
26
+ export type DispatchSourceDataModal = Record<string, Record<string, DispatchModal>>;
27
27
  export interface DispatchModal<T = string | string[]> {
28
28
  fnKey?: string;
29
29
  dependencies?: T;
30
30
  manual?: boolean;
31
+ reset?: boolean;
31
32
  }
32
33
  export interface HItemProps extends Omit<FormItemProps, "name"> {
33
34
  type?: string;
@@ -179,7 +179,7 @@ var useValueChange = function useValueChange(params) {
179
179
  onChange(newChangeVal, subItemOps);
180
180
  };
181
181
  React.useEffect(function () {
182
- if (mode === "tags") {
182
+ if (mode === "tags" || value === null || value === undefined) {
183
183
  setVal(value);
184
184
  return;
185
185
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "0.0.4-beta-v7",
3
+ "version": "0.0.4-beta-v9",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -86,10 +86,11 @@ export const useValuesChange = ({
86
86
  if (!!dispatchItem) {
87
87
  const dispatchKey = Object.keys(dispatchItem);
88
88
  dispatchKey.forEach((name) => {
89
- const key = dispatchItem[name];
89
+ const {fnKey,reset} = dispatchItem[name];
90
+ reset&&form.setFields([{name,value:null,errors:[]}]);
90
91
  form.dispatch(
91
92
  {
92
- key,
93
+ key:fnKey,
93
94
  name,
94
95
  },
95
96
  {
@@ -16,6 +16,7 @@ export default () => {
16
16
  const initDispatch: Record<string, argsFn> = {};
17
17
  let cacheValues: Record<string, any> = {};
18
18
  let isLoading = false;
19
+
19
20
  const norAddItemDispatch = (name, manual, fn) => {
20
21
  if (manual === false&&name) {
21
22
  initDispatch[name]=fn;
@@ -105,17 +105,23 @@ const itemDispatchProvider = (
105
105
  config: Required<DispatchModal<string>>,
106
106
  dispatchSourceData: DispatchSourceDataModal
107
107
  ) => {
108
- const { dependencies, fnKey } = config;
108
+ const { dependencies, fnKey ,reset} = config;
109
109
  const itemDispatch = dispatchSourceData[dependencies as string];
110
110
  if (!itemDispatch) {
111
111
  return {
112
112
  [dependencies]: {
113
- [name]: fnKey,
113
+ [name]:{
114
+ fnKey,
115
+ reset
116
+ },
114
117
  },
115
118
  };
116
119
  }
117
120
  const itemNameDispatch = {
118
- [name]: fnKey,
121
+ [name]:{
122
+ fnKey,
123
+ reset
124
+ },
119
125
  };
120
126
  return {
121
127
  [dependencies]: {
@@ -133,6 +139,7 @@ const dispatchProvider = (
133
139
  fnKey,
134
140
  dependencies: dispatchDependencies = dependencies as string | string[],
135
141
  manual = true,
142
+ reset=true
136
143
  } = dispatch;
137
144
  if (!fnKey) {
138
145
  return {};
@@ -144,7 +151,7 @@ const dispatchProvider = (
144
151
  dispatchDependencies.forEach((key) => {
145
152
  const itemDispatch = itemDispatchProvider(
146
153
  name,
147
- { dependencies: key, fnKey, manual },
154
+ { dependencies: key, fnKey, manual ,reset},
148
155
  dispatchSourceData
149
156
  );
150
157
  allDispatch = {
@@ -156,7 +163,7 @@ const dispatchProvider = (
156
163
  }
157
164
  const itemDispatch = itemDispatchProvider(
158
165
  name,
159
- { dependencies: dispatchDependencies, fnKey, manual },
166
+ { dependencies: dispatchDependencies, fnKey, manual ,reset},
160
167
  dispatchSourceData
161
168
  );
162
169
  return {
@@ -26,7 +26,6 @@ export default ({
26
26
  configData,
27
27
  form: hForm,
28
28
  });
29
- console.log(dispatchSourceData,"dispatchSourceData")
30
29
  const { subControl, infoControl } = useInfoReq({
31
30
  initialValues,
32
31
  request,
@@ -57,11 +57,12 @@ type HelperModal = (form: HFormInstance) => React.ReactNode | string;
57
57
  export type HideModal = (form: HFormInstance) => boolean;
58
58
 
59
59
  export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
60
- export type DispatchSourceDataModal = Record<string, Record<string, string>>;
60
+ export type DispatchSourceDataModal = Record<string, Record<string, DispatchModal>>;
61
61
  export interface DispatchModal<T = string | string[]> {
62
62
  fnKey?: string;
63
63
  dependencies?: T;
64
64
  manual?: boolean;
65
+ reset?:boolean;
65
66
  }
66
67
  export interface HItemProps extends Omit<FormItemProps, "name"> {
67
68
  type?: string;
@@ -138,10 +138,11 @@ export const useValueChange = (params: PartialHSelectProps) => {
138
138
  onChange(newChangeVal, subItemOps);
139
139
  };
140
140
  useEffect(() => {
141
- if (mode === "tags") {
141
+ if (mode === "tags"||value===null||value===undefined) {
142
142
  setVal(value);
143
143
  return;
144
144
  }
145
+
145
146
  if (options && value) {
146
147
  setVal((oldVale) => {
147
148
  return matchNotFind(params, oldVale);
@@ -37,7 +37,6 @@ const Index: React.FC<HSelectProps> = ({
37
37
  }) => {
38
38
  const { icon, render } = modeConfig?.[mode || ""] || {};
39
39
  const { fieldNames } = useMatchConfigProps({ fieldNames: propsFieldNames });
40
-
41
40
  const selfFilterOption = useFilterOption({ filterOption, serviceSearch });
42
41
  const {
43
42
  run,
@@ -27,7 +27,6 @@ const formData = (options) => {
27
27
  dispatch: {
28
28
  fnKey: "reload",
29
29
  dependencies: ["selectInput", "sz"],
30
- manual: false,
31
30
  },
32
31
  itemProps: {
33
32
  request: (params = {}, values) => {