@hw-component/form 0.0.4-beta-v7 → 0.0.4-beta-v8
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/hooks/index.js +5 -2
- package/es/Form/hooks/useInitConfigData.js +17 -6
- package/es/Form/index.js +0 -1
- package/es/Form/modal.d.ts +2 -1
- package/lib/Form/hooks/index.js +5 -2
- package/lib/Form/hooks/useInitConfigData.js +17 -6
- package/lib/Form/index.js +0 -1
- package/lib/Form/modal.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/Form/hooks/index.ts +3 -2
- package/src/components/Form/hooks/useInitConfigData.tsx +12 -5
- package/src/components/Form/index.tsx +0 -1
- package/src/components/Form/modal.ts +2 -1
package/es/Form/hooks/index.js
CHANGED
|
@@ -124,14 +124,17 @@ 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
|
|
127
|
+
var _dispatchItem$name = dispatchItem[name],
|
|
128
|
+
fnKey = _dispatchItem$name.fnKey,
|
|
129
|
+
reset = _dispatchItem$name.reset;
|
|
128
130
|
form.dispatch({
|
|
129
|
-
key:
|
|
131
|
+
key: fnKey,
|
|
130
132
|
name: name
|
|
131
133
|
}, {
|
|
132
134
|
changedValues: changedValues,
|
|
133
135
|
oldValues: values
|
|
134
136
|
});
|
|
137
|
+
reset && form.resetFields([name]);
|
|
135
138
|
});
|
|
136
139
|
}
|
|
137
140
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(changedValues, values);
|
|
@@ -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,
|
|
103
|
+
return _defineProperty({}, dependencies, _defineProperty({}, name, {
|
|
104
|
+
fnKey: fnKey,
|
|
105
|
+
reset: reset
|
|
106
|
+
}));
|
|
103
107
|
}
|
|
104
|
-
var itemNameDispatch = _defineProperty({}, name,
|
|
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,
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -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,
|
|
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;
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -125,14 +125,17 @@ 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
|
|
128
|
+
var _dispatchItem$name = dispatchItem[name],
|
|
129
|
+
fnKey = _dispatchItem$name.fnKey,
|
|
130
|
+
reset = _dispatchItem$name.reset;
|
|
129
131
|
form.dispatch({
|
|
130
|
-
key:
|
|
132
|
+
key: fnKey,
|
|
131
133
|
name: name
|
|
132
134
|
}, {
|
|
133
135
|
changedValues: changedValues,
|
|
134
136
|
oldValues: values
|
|
135
137
|
});
|
|
138
|
+
reset && form.resetFields([name]);
|
|
136
139
|
});
|
|
137
140
|
}
|
|
138
141
|
onValuesChange === null || onValuesChange === void 0 ? void 0 : onValuesChange(changedValues, values);
|
|
@@ -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,
|
|
106
|
+
return _defineProperty({}, dependencies, _defineProperty({}, name, {
|
|
107
|
+
fnKey: fnKey,
|
|
108
|
+
reset: reset
|
|
109
|
+
}));
|
|
106
110
|
}
|
|
107
|
-
var itemNameDispatch = _defineProperty({}, name,
|
|
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,
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -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,
|
|
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;
|
package/package.json
CHANGED
|
@@ -86,10 +86,10 @@ export const useValuesChange = ({
|
|
|
86
86
|
if (!!dispatchItem) {
|
|
87
87
|
const dispatchKey = Object.keys(dispatchItem);
|
|
88
88
|
dispatchKey.forEach((name) => {
|
|
89
|
-
const
|
|
89
|
+
const {fnKey,reset} = dispatchItem[name];
|
|
90
90
|
form.dispatch(
|
|
91
91
|
{
|
|
92
|
-
key,
|
|
92
|
+
key:fnKey,
|
|
93
93
|
name,
|
|
94
94
|
},
|
|
95
95
|
{
|
|
@@ -97,6 +97,7 @@ export const useValuesChange = ({
|
|
|
97
97
|
oldValues: values,
|
|
98
98
|
}
|
|
99
99
|
);
|
|
100
|
+
reset&&form.resetFields([name]);
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
103
|
onValuesChange?.(changedValues, values);
|
|
@@ -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]:
|
|
113
|
+
[name]:{
|
|
114
|
+
fnKey,
|
|
115
|
+
reset
|
|
116
|
+
},
|
|
114
117
|
},
|
|
115
118
|
};
|
|
116
119
|
}
|
|
117
120
|
const itemNameDispatch = {
|
|
118
|
-
[name]:
|
|
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 {
|
|
@@ -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,
|
|
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;
|