@hw-component/form 1.9.6 → 1.9.8
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/FormItem/BasicItem.js +1 -0
- package/es/Form/hooks/index.d.ts +1 -1
- package/es/Form/hooks/index.js +3 -2
- package/es/Form/hooks/useHForm.js +2 -2
- package/es/Form/index.d.ts +1 -1
- package/es/Form/index.js +6 -3
- package/es/Form/modal.d.ts +1 -1
- package/es/Select/hooks/util.js +14 -10
- package/es/Upload/modal.d.ts +2 -1
- package/lib/Form/FormItem/BasicItem.js +1 -0
- package/lib/Form/hooks/index.d.ts +1 -1
- package/lib/Form/hooks/index.js +3 -2
- package/lib/Form/hooks/useHForm.js +2 -2
- package/lib/Form/index.d.ts +1 -1
- package/lib/Form/index.js +6 -3
- package/lib/Form/modal.d.ts +1 -1
- package/lib/Select/hooks/util.js +14 -10
- package/lib/Upload/modal.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/Form/FormItem/BasicItem.tsx +1 -0
- package/src/components/Form/hooks/index.ts +2 -1
- package/src/components/Form/hooks/useHForm.ts +3 -3
- package/src/components/Form/index.tsx +4 -1
- package/src/components/Form/modal.ts +2 -1
- package/src/components/Select/hooks/changeHooks.tsx +2 -1
- package/src/components/Select/hooks/util.ts +9 -5
- package/src/components/Select/index.tsx +1 -0
- package/src/components/Upload/hooks/customRequest.ts +1 -4
- package/src/components/Upload/index.tsx +0 -1
- package/src/components/Upload/modal.ts +1 -1
- package/src/pages/Select/index.tsx +14 -2
package/es/Form/hooks/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ interface UseValuesChangeModal {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
9
9
|
type ParamsModal = Omit<HFormProps, "configData">;
|
|
10
|
-
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
|
|
10
|
+
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, preserve }: ParamsModal) => {
|
|
11
11
|
subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
12
12
|
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<any, [reqParams?: any]>;
|
|
13
13
|
};
|
package/es/Form/hooks/index.js
CHANGED
|
@@ -27,7 +27,8 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
27
27
|
form = _ref.form,
|
|
28
28
|
params = _ref.params,
|
|
29
29
|
request = _ref.request,
|
|
30
|
-
onFinish = _ref.onFinish
|
|
30
|
+
onFinish = _ref.onFinish,
|
|
31
|
+
preserve = _ref.preserve;
|
|
31
32
|
var reqData = useMemo(function () {
|
|
32
33
|
var saveParams = params || {};
|
|
33
34
|
return {
|
|
@@ -40,7 +41,7 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
40
41
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
41
42
|
while (1) switch (_context.prev = _context.next) {
|
|
42
43
|
case 0:
|
|
43
|
-
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
44
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
|
|
44
45
|
if (!request) {
|
|
45
46
|
_context.next = 4;
|
|
46
47
|
break;
|
|
@@ -177,8 +177,8 @@ var useHForm = (function () {
|
|
|
177
177
|
}
|
|
178
178
|
Reflect.deleteProperty(dispatchSourceData, key);
|
|
179
179
|
},
|
|
180
|
-
outputValues: function outputValues(value) {
|
|
181
|
-
var val = value || form.getFieldsValue();
|
|
180
|
+
outputValues: function outputValues(value, preserve) {
|
|
181
|
+
var val = value || form.getFieldsValue(preserve);
|
|
182
182
|
return formatValuesFn(val, "outputValue");
|
|
183
183
|
}
|
|
184
184
|
}, form), {}, {
|
package/es/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, ...props }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, preserve, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/es/Form/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { useState, useEffect } from 'react';
|
|
|
18
18
|
import InitSet from './InitSet.js';
|
|
19
19
|
import Basic from './Basic.js';
|
|
20
20
|
|
|
21
|
-
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter"];
|
|
21
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter", "preserve"];
|
|
22
22
|
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; }
|
|
23
23
|
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; }
|
|
24
24
|
var HForm = (function (_ref) {
|
|
@@ -46,6 +46,7 @@ var HForm = (function (_ref) {
|
|
|
46
46
|
_ref$colon = _ref.colon,
|
|
47
47
|
colon = _ref$colon === void 0 ? true : _ref$colon,
|
|
48
48
|
dismissOnPressEnter = _ref.dismissOnPressEnter,
|
|
49
|
+
preserve = _ref.preserve,
|
|
49
50
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
51
|
var hForm = useCurrentForm(form);
|
|
51
52
|
var _useState = useState({}),
|
|
@@ -59,7 +60,8 @@ var HForm = (function (_ref) {
|
|
|
59
60
|
valueType: valueType,
|
|
60
61
|
form: hForm,
|
|
61
62
|
infoRequest: infoRequest,
|
|
62
|
-
params: params
|
|
63
|
+
params: params,
|
|
64
|
+
preserve: preserve
|
|
63
65
|
}),
|
|
64
66
|
subControl = _useInfoReq.subControl,
|
|
65
67
|
infoControl = _useInfoReq.infoControl;
|
|
@@ -106,7 +108,8 @@ var HForm = (function (_ref) {
|
|
|
106
108
|
children: jsxs(Form, _objectSpread(_objectSpread({
|
|
107
109
|
form: hForm,
|
|
108
110
|
onFinish: run,
|
|
109
|
-
onValuesChange: valuesChange
|
|
111
|
+
onValuesChange: valuesChange,
|
|
112
|
+
preserve: preserve
|
|
110
113
|
}, props), {}, {
|
|
111
114
|
children: [jsx(Basic, {
|
|
112
115
|
configData: configData,
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ export interface HFormInstance extends FormInstance {
|
|
|
127
127
|
initValues: VoidFunction;
|
|
128
128
|
formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
|
|
129
129
|
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
130
|
-
outputValues: (values?: Record<string, any
|
|
130
|
+
outputValues: (values?: Record<string, any>, preserve?: HFormProps["preserve"]) => Record<string, any>;
|
|
131
131
|
addDispatchListener: AddDispatchListenerFn;
|
|
132
132
|
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
133
133
|
reload: PromiseFnResult;
|
package/es/Select/hooks/util.js
CHANGED
|
@@ -80,15 +80,8 @@ var resultProvider = function resultProvider(newData, oldData, value) {
|
|
|
80
80
|
});
|
|
81
81
|
return newResult;
|
|
82
82
|
};
|
|
83
|
-
var
|
|
84
|
-
|
|
85
|
-
value = _ref3.value;
|
|
86
|
-
var _sourceDataProvider = sourceDataProvider({
|
|
87
|
-
value: value
|
|
88
|
-
}, oldVal),
|
|
89
|
-
newData = _sourceDataProvider.newData,
|
|
90
|
-
oldData = _sourceDataProvider.oldData;
|
|
91
|
-
var newMatchVal = newData.map(function (item) {
|
|
83
|
+
var notMatchArray = function notMatchArray(data, options) {
|
|
84
|
+
return data.map(function (item) {
|
|
92
85
|
var itemVal = item.value,
|
|
93
86
|
index = item.index;
|
|
94
87
|
var newItem = single({
|
|
@@ -99,7 +92,18 @@ var multiple = function multiple(_ref3, oldVal) {
|
|
|
99
92
|
index: index
|
|
100
93
|
});
|
|
101
94
|
});
|
|
102
|
-
|
|
95
|
+
};
|
|
96
|
+
var multiple = function multiple(_ref3, oldVal) {
|
|
97
|
+
var options = _ref3.options,
|
|
98
|
+
value = _ref3.value;
|
|
99
|
+
var _sourceDataProvider = sourceDataProvider({
|
|
100
|
+
value: value
|
|
101
|
+
}, oldVal),
|
|
102
|
+
newData = _sourceDataProvider.newData,
|
|
103
|
+
oldData = _sourceDataProvider.oldData;
|
|
104
|
+
var notMatchOldVal = notMatchArray(oldData, options);
|
|
105
|
+
var newMatchVal = notMatchArray(newData, options);
|
|
106
|
+
return resultProvider(newMatchVal, notMatchOldVal, value);
|
|
103
107
|
};
|
|
104
108
|
var tag = function tag(_ref4, oldVal) {
|
|
105
109
|
var options = _ref4.options,
|
package/es/Upload/modal.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
9
9
|
exFiles?: string[] | null;
|
|
10
10
|
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
11
11
|
url: string;
|
|
12
|
-
|
|
12
|
+
thumbUrl?: string;
|
|
13
|
+
}>;
|
|
13
14
|
errorType?: "alert" | "show";
|
|
14
15
|
onChange?: (fileList: UploadFile[]) => void;
|
|
15
16
|
value?: UploadFile[];
|
|
@@ -7,7 +7,7 @@ interface UseValuesChangeModal {
|
|
|
7
7
|
}
|
|
8
8
|
export declare const useCurrentForm: (form?: HFormInstance) => HFormInstance;
|
|
9
9
|
type ParamsModal = Omit<HFormProps, "configData">;
|
|
10
|
-
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, }: ParamsModal) => {
|
|
10
|
+
export declare const useInfoReq: ({ initialValues, infoRequest, form, params, request, onFinish, preserve }: ParamsModal) => {
|
|
11
11
|
subControl: import("@ahooksjs/use-request/lib/types").BaseResult<void, [value: any]>;
|
|
12
12
|
infoControl: import("@ahooksjs/use-request/lib/types").BaseResult<any, [reqParams?: any]>;
|
|
13
13
|
};
|
package/lib/Form/hooks/index.js
CHANGED
|
@@ -28,7 +28,8 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
28
28
|
form = _ref.form,
|
|
29
29
|
params = _ref.params,
|
|
30
30
|
request = _ref.request,
|
|
31
|
-
onFinish = _ref.onFinish
|
|
31
|
+
onFinish = _ref.onFinish,
|
|
32
|
+
preserve = _ref.preserve;
|
|
32
33
|
var reqData = React.useMemo(function () {
|
|
33
34
|
var saveParams = params || {};
|
|
34
35
|
return {
|
|
@@ -41,7 +42,7 @@ var useInfoReq = function useInfoReq(_ref) {
|
|
|
41
42
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
42
43
|
while (1) switch (_context.prev = _context.next) {
|
|
43
44
|
case 0:
|
|
44
|
-
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value);
|
|
45
|
+
subVal = form === null || form === void 0 ? void 0 : form.outputValues(value, preserve);
|
|
45
46
|
if (!request) {
|
|
46
47
|
_context.next = 4;
|
|
47
48
|
break;
|
|
@@ -180,8 +180,8 @@ var useHForm = (function () {
|
|
|
180
180
|
}
|
|
181
181
|
Reflect.deleteProperty(dispatchSourceData, key);
|
|
182
182
|
},
|
|
183
|
-
outputValues: function outputValues(value) {
|
|
184
|
-
var val = value || form.getFieldsValue();
|
|
183
|
+
outputValues: function outputValues(value, preserve) {
|
|
184
|
+
var val = value || form.getFieldsValue(preserve);
|
|
185
185
|
return formatValuesFn(val, "outputValue");
|
|
186
186
|
}
|
|
187
187
|
}, form), {}, {
|
package/lib/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, ...props }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, colon, dismissOnPressEnter, preserve, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/lib/Form/index.js
CHANGED
|
@@ -21,7 +21,7 @@ var React = require('react');
|
|
|
21
21
|
var InitSet = require('./InitSet.js');
|
|
22
22
|
var Basic = require('./Basic.js');
|
|
23
23
|
|
|
24
|
-
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter"];
|
|
24
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps", "colon", "dismissOnPressEnter", "preserve"];
|
|
25
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; }
|
|
26
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; }
|
|
27
27
|
var HForm = (function (_ref) {
|
|
@@ -49,6 +49,7 @@ var HForm = (function (_ref) {
|
|
|
49
49
|
_ref$colon = _ref.colon,
|
|
50
50
|
colon = _ref$colon === void 0 ? true : _ref$colon,
|
|
51
51
|
dismissOnPressEnter = _ref.dismissOnPressEnter,
|
|
52
|
+
preserve = _ref.preserve,
|
|
52
53
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
53
54
|
var hForm = index.useCurrentForm(form);
|
|
54
55
|
var _useState = React.useState({}),
|
|
@@ -62,7 +63,8 @@ var HForm = (function (_ref) {
|
|
|
62
63
|
valueType: valueType,
|
|
63
64
|
form: hForm,
|
|
64
65
|
infoRequest: infoRequest,
|
|
65
|
-
params: params
|
|
66
|
+
params: params,
|
|
67
|
+
preserve: preserve
|
|
66
68
|
}),
|
|
67
69
|
subControl = _useInfoReq.subControl,
|
|
68
70
|
infoControl = _useInfoReq.infoControl;
|
|
@@ -109,7 +111,8 @@ var HForm = (function (_ref) {
|
|
|
109
111
|
children: jsxRuntime.jsxs(antd.Form, _objectSpread(_objectSpread({
|
|
110
112
|
form: hForm,
|
|
111
113
|
onFinish: run,
|
|
112
|
-
onValuesChange: valuesChange
|
|
114
|
+
onValuesChange: valuesChange,
|
|
115
|
+
preserve: preserve
|
|
113
116
|
}, props), {}, {
|
|
114
117
|
children: [jsxRuntime.jsx(Basic.default, {
|
|
115
118
|
configData: configData,
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -127,7 +127,7 @@ export interface HFormInstance extends FormInstance {
|
|
|
127
127
|
initValues: VoidFunction;
|
|
128
128
|
formatValues: (values?: Record<string, any>, formatKey?: string) => Record<string, any>;
|
|
129
129
|
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
130
|
-
outputValues: (values?: Record<string, any
|
|
130
|
+
outputValues: (values?: Record<string, any>, preserve?: HFormProps["preserve"]) => Record<string, any>;
|
|
131
131
|
addDispatchListener: AddDispatchListenerFn;
|
|
132
132
|
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
133
133
|
reload: PromiseFnResult;
|
package/lib/Select/hooks/util.js
CHANGED
|
@@ -81,15 +81,8 @@ var resultProvider = function resultProvider(newData, oldData, value) {
|
|
|
81
81
|
});
|
|
82
82
|
return newResult;
|
|
83
83
|
};
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
value = _ref3.value;
|
|
87
|
-
var _sourceDataProvider = sourceDataProvider({
|
|
88
|
-
value: value
|
|
89
|
-
}, oldVal),
|
|
90
|
-
newData = _sourceDataProvider.newData,
|
|
91
|
-
oldData = _sourceDataProvider.oldData;
|
|
92
|
-
var newMatchVal = newData.map(function (item) {
|
|
84
|
+
var notMatchArray = function notMatchArray(data, options) {
|
|
85
|
+
return data.map(function (item) {
|
|
93
86
|
var itemVal = item.value,
|
|
94
87
|
index = item.index;
|
|
95
88
|
var newItem = single({
|
|
@@ -100,7 +93,18 @@ var multiple = function multiple(_ref3, oldVal) {
|
|
|
100
93
|
index: index
|
|
101
94
|
});
|
|
102
95
|
});
|
|
103
|
-
|
|
96
|
+
};
|
|
97
|
+
var multiple = function multiple(_ref3, oldVal) {
|
|
98
|
+
var options = _ref3.options,
|
|
99
|
+
value = _ref3.value;
|
|
100
|
+
var _sourceDataProvider = sourceDataProvider({
|
|
101
|
+
value: value
|
|
102
|
+
}, oldVal),
|
|
103
|
+
newData = _sourceDataProvider.newData,
|
|
104
|
+
oldData = _sourceDataProvider.oldData;
|
|
105
|
+
var notMatchOldVal = notMatchArray(oldData, options);
|
|
106
|
+
var newMatchVal = notMatchArray(newData, options);
|
|
107
|
+
return resultProvider(newMatchVal, notMatchOldVal, value);
|
|
104
108
|
};
|
|
105
109
|
var tag = function tag(_ref4, oldVal) {
|
|
106
110
|
var options = _ref4.options,
|
package/lib/Upload/modal.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
9
9
|
exFiles?: string[] | null;
|
|
10
10
|
request?: (file: Exclude<BeforeUploadFileType, File | boolean> | RcFile) => Promise<{
|
|
11
11
|
url: string;
|
|
12
|
-
|
|
12
|
+
thumbUrl?: string;
|
|
13
|
+
}>;
|
|
13
14
|
errorType?: "alert" | "show";
|
|
14
15
|
onChange?: (fileList: UploadFile[]) => void;
|
|
15
16
|
value?: UploadFile[];
|
package/package.json
CHANGED
|
@@ -25,6 +25,7 @@ export const useInfoReq = ({
|
|
|
25
25
|
params,
|
|
26
26
|
request,
|
|
27
27
|
onFinish,
|
|
28
|
+
preserve
|
|
28
29
|
}: ParamsModal) => {
|
|
29
30
|
const reqData = useMemo(() => {
|
|
30
31
|
const saveParams = params || {};
|
|
@@ -35,7 +36,7 @@ export const useInfoReq = ({
|
|
|
35
36
|
|
|
36
37
|
const subControl = useRequest(
|
|
37
38
|
async (value) => {
|
|
38
|
-
const subVal = form?.outputValues(value);
|
|
39
|
+
const subVal = form?.outputValues(value,preserve);
|
|
39
40
|
if (request) {
|
|
40
41
|
await request(subVal, reqData.params);
|
|
41
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo } from "react";
|
|
2
2
|
import { Form } from "antd";
|
|
3
3
|
import type { FormatItemModal, HFormInstance } from "../modal";
|
|
4
4
|
import type { argsFn } from "../modal";
|
|
@@ -147,8 +147,8 @@ export default () => {
|
|
|
147
147
|
}
|
|
148
148
|
Reflect.deleteProperty(dispatchSourceData, key);
|
|
149
149
|
},
|
|
150
|
-
outputValues(value) {
|
|
151
|
-
const val = value || form.getFieldsValue();
|
|
150
|
+
outputValues(value,preserve) {
|
|
151
|
+
const val = value || form.getFieldsValue((preserve as any));
|
|
152
152
|
return formatValuesFn(val, "outputValue");
|
|
153
153
|
},
|
|
154
154
|
...form,
|
|
@@ -27,6 +27,7 @@ export default ({
|
|
|
27
27
|
itemProps: formItemProps = {},
|
|
28
28
|
colon = true,
|
|
29
29
|
dismissOnPressEnter,
|
|
30
|
+
preserve,
|
|
30
31
|
...props
|
|
31
32
|
}: HFormProps) => {
|
|
32
33
|
const hForm = useCurrentForm(form);
|
|
@@ -40,6 +41,7 @@ export default ({
|
|
|
40
41
|
form: hForm,
|
|
41
42
|
infoRequest,
|
|
42
43
|
params,
|
|
44
|
+
preserve
|
|
43
45
|
});
|
|
44
46
|
const valuesChange = useValuesChange({
|
|
45
47
|
onValuesChange,
|
|
@@ -93,9 +95,10 @@ export default ({
|
|
|
93
95
|
form={hForm}
|
|
94
96
|
onFinish={run}
|
|
95
97
|
onValuesChange={valuesChange}
|
|
98
|
+
preserve={preserve}
|
|
96
99
|
{...props}
|
|
97
100
|
>
|
|
98
|
-
<Basic
|
|
101
|
+
<Basic configData={configData} dismissOnPressEnter={dismissOnPressEnter} gutter={gutter} />
|
|
99
102
|
<InitSet />
|
|
100
103
|
</Form>
|
|
101
104
|
</FormContext.Provider>
|
|
@@ -35,6 +35,7 @@ import type { DataFnProvider } from "../modal";
|
|
|
35
35
|
import type { ColProps } from "antd/lib/grid/col";
|
|
36
36
|
import type { Gutter } from "antd/lib/grid/row";
|
|
37
37
|
import type { IUrlUploadProps } from "../Upload/modal";
|
|
38
|
+
import {NamePath} from "rc-field-form/es/interface";
|
|
38
39
|
|
|
39
40
|
type RenderFun = (
|
|
40
41
|
props: HItemProps,
|
|
@@ -183,7 +184,7 @@ export interface HFormInstance extends FormInstance {
|
|
|
183
184
|
formatKey?: string
|
|
184
185
|
) => Record<string, any>;
|
|
185
186
|
dispatch: (action: ActionModal, ...args: any[]) => void;
|
|
186
|
-
outputValues: (values?: Record<string, any
|
|
187
|
+
outputValues: (values?: Record<string, any>,preserve?:HFormProps["preserve"]) => Record<string, any>;
|
|
187
188
|
addDispatchListener: AddDispatchListenerFn;
|
|
188
189
|
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
189
190
|
reload: PromiseFnResult;
|
|
@@ -56,6 +56,7 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
56
56
|
}
|
|
57
57
|
onChange(newChangeVal, subItemOps);
|
|
58
58
|
};
|
|
59
|
+
|
|
59
60
|
useEffect(() => {
|
|
60
61
|
if (value === null || value === undefined) {
|
|
61
62
|
setVal(undefined);
|
|
@@ -68,7 +69,7 @@ export const useValueChange = (params: PartialHSelectProps) => {
|
|
|
68
69
|
|
|
69
70
|
if (options) {
|
|
70
71
|
setVal((oldVale) => {
|
|
71
|
-
return
|
|
72
|
+
return matchNotFind(params, oldVale);
|
|
72
73
|
});
|
|
73
74
|
}
|
|
74
75
|
}, [value, options, mode]);
|
|
@@ -75,17 +75,21 @@ const resultProvider = (
|
|
|
75
75
|
});
|
|
76
76
|
return newResult;
|
|
77
77
|
};
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const newMatchVal = newData.map((item) => {
|
|
78
|
+
const notMatchArray=(data,options)=>{
|
|
79
|
+
return data.map((item)=>{
|
|
81
80
|
const { value: itemVal, index } = item;
|
|
82
81
|
const newItem = single({ options, value: itemVal });
|
|
83
82
|
return {
|
|
84
83
|
...newItem,
|
|
85
84
|
index,
|
|
86
85
|
};
|
|
87
|
-
})
|
|
88
|
-
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
const multiple = ({ options, value }: PartialHSelectProps, oldVal?: any[]) => {
|
|
89
|
+
const { newData, oldData } = sourceDataProvider({ value }, oldVal);
|
|
90
|
+
const notMatchOldVal=notMatchArray(oldData,options);
|
|
91
|
+
const newMatchVal = notMatchArray(newData,options);
|
|
92
|
+
return resultProvider(newMatchVal, notMatchOldVal, value);
|
|
89
93
|
}; //多选
|
|
90
94
|
|
|
91
95
|
const tag = ({ options, value }: PartialHSelectProps, oldVal?: any[]) => {
|
|
@@ -3,13 +3,10 @@ import type { UploadFile } from "antd/es/upload/interface";
|
|
|
3
3
|
import type { RcFile } from "antd/lib/upload";
|
|
4
4
|
import { useEffect, useMemo } from "react";
|
|
5
5
|
import type { UploadFileStatus } from "antd/es/upload/interface";
|
|
6
|
-
import type { BeforeUploadFileType } from "rc-upload/lib/interface";
|
|
7
6
|
import { message } from "antd";
|
|
8
7
|
|
|
9
8
|
interface SubReqParamsModal {
|
|
10
|
-
request?:
|
|
11
|
-
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
12
|
-
) => Promise<{ url: string; thumbUrl?: string }>;
|
|
9
|
+
request?:IUpLoadProps['request'];
|
|
13
10
|
file: RcFile;
|
|
14
11
|
}
|
|
15
12
|
interface ResultModal {
|
|
@@ -10,7 +10,7 @@ export interface IUpLoadProps extends Omit<UploadProps, "onChange"> {
|
|
|
10
10
|
exFiles?: string[] | null;
|
|
11
11
|
request?: (
|
|
12
12
|
file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
|
|
13
|
-
) => Promise<{ url: string }
|
|
13
|
+
) => Promise<{ url: string; thumbUrl?: string }>;
|
|
14
14
|
errorType?: "alert" | "show";
|
|
15
15
|
onChange?: (fileList: UploadFile[]) => void;
|
|
16
16
|
value?: UploadFile[];
|
|
@@ -3,6 +3,8 @@ import { Space, Select } from "antd";
|
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
export default () => {
|
|
5
5
|
const [selectVal, setSelectVal] = useState([{ name: "11", id: -100 }]);
|
|
6
|
+
const [op,setOp]=useState([{label:"1",value:1}])
|
|
7
|
+
const [val,setVal]=useState([2,3]);
|
|
6
8
|
return (
|
|
7
9
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
8
10
|
<HSelect
|
|
@@ -34,9 +36,19 @@ export default () => {
|
|
|
34
36
|
isList
|
|
35
37
|
/>
|
|
36
38
|
<HSelect
|
|
37
|
-
value={
|
|
38
|
-
|
|
39
|
+
value={val}
|
|
40
|
+
onChange={(v)=>{
|
|
41
|
+
console.log(v);
|
|
42
|
+
setVal(v);
|
|
43
|
+
}}
|
|
44
|
+
mode="multiple"
|
|
45
|
+
options={op}
|
|
39
46
|
/>
|
|
47
|
+
<div onClick={()=>{
|
|
48
|
+
setOp([{label:"2",value:2}])
|
|
49
|
+
}}>
|
|
50
|
+
改变
|
|
51
|
+
</div>
|
|
40
52
|
</Space>
|
|
41
53
|
);
|
|
42
54
|
};
|