ztxkui 4.2.23-317 → 4.2.23-319-beta
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/dist/DemoCom/FormDemo.js
CHANGED
|
@@ -191,7 +191,7 @@ var FormDemo = function () {
|
|
|
191
191
|
// configInfo={configInfoMemo}
|
|
192
192
|
isDynamic: true, dynamicStorageKey: "symbol-key-00001", isToggle: true, toggleNum: 16, handleRef: handleRef },
|
|
193
193
|
React.createElement(SearchItem, { name: "applyPersonName1", label: "\u8D77\u8349\u4EBA" },
|
|
194
|
-
React.createElement(Input, { allowClear: true
|
|
194
|
+
React.createElement(Input, { allowClear: true })),
|
|
195
195
|
React.createElement(SearchItem, { name: "applyPersonName2", label: "\u8D77\u8349\u4EBA", suffix: React.createElement(React.Fragment, null) },
|
|
196
196
|
React.createElement(Input, { allowClear: true })),
|
|
197
197
|
React.createElement(SearchItem, { name: "applyPersonName3", label: "\u8D77\u8349\u4EBA", suffix: React.createElement(React.Fragment, null, drafterMode === 0 ? (React.createElement(Tooltip, { title: "\u5207\u6362\u6210\u9009\u62E9\u6846" },
|
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { FormProps } from 'antd/lib/form';
|
|
3
|
-
export interface IProps extends FormProps {
|
|
2
|
+
import { FormProps, FormInstance as AntFormInstance } from 'antd/lib/form';
|
|
3
|
+
export interface IProps extends Omit<FormProps, 'form'> {
|
|
4
|
+
form?: FormInstance;
|
|
4
5
|
}
|
|
6
|
+
interface FormInstance extends AntFormInstance {
|
|
7
|
+
setDynamicList: (list: any[]) => void;
|
|
8
|
+
}
|
|
9
|
+
export declare const FormContext: React.Context<{
|
|
10
|
+
form?: FormInstance;
|
|
11
|
+
}>;
|
|
5
12
|
declare function Form(props: IProps): JSX.Element;
|
|
6
13
|
declare namespace Form {
|
|
7
14
|
var Item: typeof import("antd/lib/form/FormItem").default;
|
|
8
15
|
var List: React.FC<import("antd/lib/form").FormListProps>;
|
|
9
16
|
var ErrorList: typeof import("antd/lib/form/ErrorList").default;
|
|
10
|
-
var useForm:
|
|
17
|
+
var useForm: (_form?: FormInstance) => [FormInstance];
|
|
11
18
|
var Provider: React.FC<import("antd/lib/form/context").FormProviderProps>;
|
|
12
19
|
}
|
|
13
20
|
export default Form;
|
|
@@ -20,11 +20,12 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React from 'react';
|
|
23
|
+
import React, { createContext } from 'react';
|
|
24
24
|
import { Form as AntForm } from 'antd';
|
|
25
25
|
import { FormProvider } from 'antd/lib/form/context';
|
|
26
26
|
import SearchContainer from '../business/SearchContainer/index';
|
|
27
27
|
var SearchRight = SearchContainer.SearchRight;
|
|
28
|
+
export var FormContext = createContext({});
|
|
28
29
|
function Form(props) {
|
|
29
30
|
var children = props.children, form = props.form, resetProps = __rest(props, ["children", "form"]);
|
|
30
31
|
var newChildren = React.Children.map(children, function (child) {
|
|
@@ -60,11 +61,31 @@ function Form(props) {
|
|
|
60
61
|
form === null || form === void 0 ? void 0 : form.setFieldsValue(formValues);
|
|
61
62
|
}
|
|
62
63
|
}
|
|
63
|
-
return (React.createElement(
|
|
64
|
+
return (React.createElement(FormContext.Provider, { value: { form: form } },
|
|
65
|
+
React.createElement(AntForm, __assign({ form: form }, resetProps), newChildren)));
|
|
66
|
+
}
|
|
67
|
+
function useForm(_form) {
|
|
68
|
+
var antForm = AntForm.useForm(_form)[0];
|
|
69
|
+
var dynamicList = React.useRef();
|
|
70
|
+
var form = __assign(__assign({}, antForm), { setDynamicList: setDynamicList, getFieldsValue: function (nameList, filterFunc) {
|
|
71
|
+
var values = __assign({}, antForm.getFieldsValue(nameList, filterFunc));
|
|
72
|
+
if (dynamicList.current) {
|
|
73
|
+
dynamicList.current.forEach(function (item) {
|
|
74
|
+
if (!item.show) {
|
|
75
|
+
values[item.name] = undefined;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return values;
|
|
80
|
+
} });
|
|
81
|
+
return [form];
|
|
82
|
+
function setDynamicList(list) {
|
|
83
|
+
dynamicList.current = list;
|
|
84
|
+
}
|
|
64
85
|
}
|
|
65
86
|
Form.Item = AntForm.Item;
|
|
66
87
|
Form.List = AntForm.List;
|
|
67
88
|
Form.ErrorList = AntForm.ErrorList;
|
|
68
|
-
Form.useForm =
|
|
89
|
+
Form.useForm = useForm;
|
|
69
90
|
Form.Provider = FormProvider;
|
|
70
91
|
export default Form;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import React, { useCallback, useEffect, useState, useRef, useImperativeHandle, } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState, useRef, useImperativeHandle, useContext, } from 'react';
|
|
2
2
|
import classNames from 'classnames';
|
|
3
3
|
import SearchDrawer from './search-drawer';
|
|
4
4
|
import { SettingOutlined, DownOutlined } from '@ant-design/icons';
|
|
5
5
|
import useDynamic, { setDynamicKey, getNewChildren } from './hooks/useDynamic';
|
|
6
6
|
import useToggle from './hooks/useToggle';
|
|
7
|
+
import { FormContext } from '../../Form/form';
|
|
7
8
|
function useConfigChildren(children, isDynamic) {
|
|
8
9
|
var _a = useState(null), configChildren = _a[0], setConfigChildren = _a[1];
|
|
9
10
|
useEffect(function () {
|
|
@@ -40,6 +41,12 @@ var SearchLeft = function (_a) {
|
|
|
40
41
|
useEffect(function () {
|
|
41
42
|
setDynamicList(dynamicArr);
|
|
42
43
|
}, [dynamicArr]);
|
|
44
|
+
// 获取form
|
|
45
|
+
var form = useContext(FormContext).form;
|
|
46
|
+
// 绑定自定义配置类型
|
|
47
|
+
useEffect(function () {
|
|
48
|
+
form === null || form === void 0 ? void 0 : form.setDynamicList(dynamicList);
|
|
49
|
+
}, [form, dynamicList]);
|
|
43
50
|
/** 表单容器Ref */
|
|
44
51
|
var containerRef = useRef(null);
|
|
45
52
|
var _g = useToggle(containerRef, dynamicList, isToggle, toggleNum), toggle = _g.toggle, onToggleChange = _g.onToggleChange, setToggleHandle = _g.setToggleHandle;
|