vap1 0.1.0 → 0.1.1
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/components/Box/Box.js +9 -2
- package/components/Tables/ApiTable.d.ts +2 -2
- package/components/Tables/ApiTableModal.d.ts +1 -1
- package/components/Tables/TopTable.js +14 -15
- package/components/Tables/VTable.js +6 -4
- package/components/Trees/ActionTree.js +1 -1
- package/components/Trees/BaseTree.d.ts +2 -6
- package/components/Trees/BaseTree.js +2 -1
- package/components/Trees/DTree.js +2 -8
- package/components/Trees/FTree.js +6 -1
- package/components/Trees/STree.js +6 -1
- package/components/UForm/UForm.d.ts +1 -17
- package/components/UForm/UForm.js +26 -58
- package/components/UForm/UInfoModal.js +0 -3
- package/components/UForm/index.d.ts +16 -0
- package/components/Upload/UploadFile.js +0 -1
- package/components/_adapt/ColorPicker.d.ts +23 -4
- package/components/_adapt/ColorPicker.js +103 -39
- package/components/_adapt/InputNumber.d.ts +2 -2
- package/components/_adapt/InputNumber.js +8 -29
- package/components/_adapt/Layout.js +3 -2
- package/components/_adapt/Table.js +5 -8
- package/components/_common/AutoComplete.js +1 -1
- package/components/_setup/SearchField/SearchFieldSelect.js +6 -4
- package/components/_setup/UForm/UFormAdvanceInput.js +59 -34
- package/components/_setup/UForm/UFormInput.js +20 -23
- package/components/_setup/UForm/UFormJSON.js +2 -2
- package/components/_setup/UForm/UFormSelect.js +2 -2
- package/hooks/_list.d.ts +5 -2
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -1
- package/hooks/useApi.d.ts +2 -68
- package/hooks/useApi.js +5 -333
- package/hooks/useApiBase.d.ts +68 -0
- package/hooks/useApiBase.js +331 -0
- package/hooks/useApiGlobal.d.ts +11 -0
- package/hooks/useApiGlobal.js +39 -5
- package/index.d.ts +1 -2
- package/index.js +1 -1
- package/package.json +1 -1
package/components/Box/Box.js
CHANGED
|
@@ -67,7 +67,8 @@ exports.useBox = useBox;
|
|
|
67
67
|
exports.Box = react_1.default.forwardRef((props, ref) => {
|
|
68
68
|
const app = (0, hooks_1.useApp)();
|
|
69
69
|
const [state, setState] = (0, hooks_1.useSetState)(null);
|
|
70
|
-
const _layoutRef = (0, react_1.useRef)(null);
|
|
70
|
+
const _layoutRef = (0, react_1.useRef)(null); // 向下兼容
|
|
71
|
+
const domId = (0, react_1.useMemo)(() => utils_1.StringUtil.genKey(), []); // 向下兼容
|
|
71
72
|
const rootRef = (0, react_1.useRef)(null);
|
|
72
73
|
const contextRef = (0, react_1.useRef)(null);
|
|
73
74
|
const selectRef = (0, react_1.useRef)(null);
|
|
@@ -134,9 +135,15 @@ exports.Box = react_1.default.forwardRef((props, ref) => {
|
|
|
134
135
|
// if (props.pagination && props.mode == 'inner') {
|
|
135
136
|
// paginationProps.hideOnSinglePage = true;
|
|
136
137
|
// }
|
|
137
|
-
return react_1.default.createElement(Layout_1.Layout, { className: utils_1.StringUtil.className(className, props.className), style: style, ref: _layoutRef },
|
|
138
|
+
return react_1.default.createElement(Layout_1.Layout, { id: domId, className: utils_1.StringUtil.className(className, props.className), style: style, ref: _layoutRef },
|
|
138
139
|
props.selectBar && (0, _register_1.getSelectBar)(props.selectBar.type) != null && react_1.default.createElement(SelectBar_1.SelectBar, Object.assign({}, props.selectBar, { ref: selectRef, onSelect: (...args) => setState({ selected: args }) })),
|
|
139
140
|
react_1.default.createElement(Layout_1.Layout.Content, { style: { overflow: props.overflowAuto ? 'auto' : 'hidden' }, ref: () => {
|
|
141
|
+
if (_layoutRef.current == null) {
|
|
142
|
+
let layout = document.getElementById(domId);
|
|
143
|
+
if (layout) {
|
|
144
|
+
_layoutRef.current = layout;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
140
147
|
if (_layoutRef.current != null) {
|
|
141
148
|
let el = lodash_1.default.find(_layoutRef.current.children, (item) => lodash_1.default.toLower(item.tagName) == 'main');
|
|
142
149
|
if (el != null)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseTableProps } from './index';
|
|
3
3
|
import type { ApiModel } from '../../hooks/_list';
|
|
4
|
-
import type { ApiOption } from '../../hooks/
|
|
4
|
+
import type { ApiOption } from '../../hooks/useApiBase';
|
|
5
5
|
export type ApiTableProps = BaseTableProps & Pick<ApiOption, 'api' | 'aop' | 'tipDisabled' | 'tipField'>;
|
|
6
6
|
export declare const ApiTable: React.ForwardRefExoticComponent<import("./index").TableDefine & {
|
|
7
7
|
mode?: import("../Box/Box").BoxMode;
|
|
@@ -15,4 +15,4 @@ export declare const ApiTable: React.ForwardRefExoticComponent<import("./index")
|
|
|
15
15
|
searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
|
|
16
16
|
default?: import("../..").PlainObject;
|
|
17
17
|
autoLoad?: false;
|
|
18
|
-
} & Pick<ApiOption, "api" | "
|
|
18
|
+
} & Pick<ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & React.RefAttributes<ApiModel>>;
|
|
@@ -15,7 +15,7 @@ export declare const ApiTableModal: React.ForwardRefExoticComponent<import(".").
|
|
|
15
15
|
searchBar?: Omit<import("../SearchBar").SearchBarProps, "onChange" | "onSearch">;
|
|
16
16
|
default?: import("../..").PlainObject;
|
|
17
17
|
autoLoad?: false;
|
|
18
|
-
} & Pick<import("../../hooks/
|
|
18
|
+
} & Pick<import("../../hooks/useApiBase").ApiOption, "api" | "tipField" | "tipDisabled" | "aop"> & Omit<import("antd/es/modal").ModalProps, "visible" | "onCancel" | "onOk"> & {
|
|
19
19
|
open?: boolean;
|
|
20
20
|
onOk?: (data?: import("../..").PlainObject) => void;
|
|
21
21
|
onCancel?: () => void;
|
|
@@ -137,21 +137,20 @@ const TopTable = props => {
|
|
|
137
137
|
}
|
|
138
138
|
});
|
|
139
139
|
}
|
|
140
|
-
return react_1.default.createElement(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
140
|
+
return react_1.default.createElement("div", { ref: tableRef, className: 'c-table-top-container' },
|
|
141
|
+
react_1.default.createElement(Table_1.Table, Object.assign({}, tableProps, props, { rowClassName: (record, i) => {
|
|
142
|
+
let clazz = [];
|
|
143
|
+
if (i <= 3)
|
|
144
|
+
clazz.push('c-table-top-' + i);
|
|
145
|
+
if (lodash_1.default.isFunction(props.onRowSelect)) {
|
|
146
|
+
if (selected && selected[rowKey] == record[rowKey]) {
|
|
147
|
+
clazz.push('ant-table-row-selected');
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
clazz.push('c-table-top-cursor');
|
|
151
|
+
}
|
|
149
152
|
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
return clazz.join(' ');
|
|
155
|
-
}, scroll: scroll, className: utils_1.StringUtil.className(['c-table', 'c-table-top'], props.className), columns: columns, dataSource: list, loading: isQuerying }));
|
|
153
|
+
return clazz.join(' ');
|
|
154
|
+
}, scroll: scroll, className: utils_1.StringUtil.className(['c-table', 'c-table-top'], props.className), columns: columns, dataSource: list, loading: isQuerying })));
|
|
156
155
|
};
|
|
157
156
|
exports.TopTable = TopTable;
|
|
@@ -51,7 +51,7 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
51
51
|
const update = (0, hooks_1.useUpdate)();
|
|
52
52
|
const { state, root, resize } = (0, Box_1.useBox)();
|
|
53
53
|
const [scroll, setScroll] = (0, react_1.useState)(undefined);
|
|
54
|
-
const { rowKey, list, isQuerying, pageNo, pageSize, orderBy, query } = props.model;
|
|
54
|
+
const { rowKey, list, isQuerying, pageNo, pageSize, orderBy, query, total } = props.model;
|
|
55
55
|
let start = (0, react_1.useRef)(0);
|
|
56
56
|
const tableProps = {};
|
|
57
57
|
(0, react_1.useEffect)(() => {
|
|
@@ -122,6 +122,10 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
122
122
|
(0, react_1.useEffect)(() => {
|
|
123
123
|
if (props.autoLoad === false)
|
|
124
124
|
return;
|
|
125
|
+
console.log(props.model);
|
|
126
|
+
// @ts-ignore
|
|
127
|
+
if (props.model.mode == 'api-global' && total > 0)
|
|
128
|
+
return;
|
|
125
129
|
// @ts-ignore
|
|
126
130
|
if (lodash_1.default.has(props.selectBar, 'config.mustSelect') && props.selectBar.config['mustSelect'])
|
|
127
131
|
return;
|
|
@@ -179,9 +183,7 @@ const _VTable = react_1.default.forwardRef((props, ref) => {
|
|
|
179
183
|
},
|
|
180
184
|
};
|
|
181
185
|
}
|
|
182
|
-
return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey:
|
|
183
|
-
// scroll={scroll}
|
|
184
|
-
// tableLayout="fixed"
|
|
186
|
+
return react_1.default.createElement(Table_1.Table, Object.assign({ rowKey: props.rowKey || rowKey, scroll: scroll, tableLayout: "fixed",
|
|
185
187
|
// showSorterTooltip={false}
|
|
186
188
|
size: utils_1.GLOBAL.CONFIG.TABLE.SIZE }, props, tableProps, { className: utils_1.StringUtil.className(['c-table'], props.className), pagination: false, columns: columns, locale: { emptyText: react_1.default.createElement(antd_1.Empty, { style: { marginTop: 24 } }) }, dataSource: list, loading: isQuerying, onChange: (x, y, field) => {
|
|
187
189
|
if (field.column) {
|
|
@@ -647,7 +647,7 @@ const renderNode = (props, node, position, state, search, context, parentLen) =>
|
|
|
647
647
|
};
|
|
648
648
|
const renderNodes = (props, state, data, position, search, context) => data.map((item, idx) => renderNode(props, item, [...position, idx], state, search, context, data.length));
|
|
649
649
|
const renderRoot = (props, state, context) => {
|
|
650
|
-
const { search, treeData
|
|
650
|
+
const { search, treeData } = state;
|
|
651
651
|
if (search.keyword) {
|
|
652
652
|
if (search.match.size == 0)
|
|
653
653
|
return react_1.default.createElement(antd_1.Tree.TreeNode, { isLeaf: true, title: react_1.default.createElement(antd_1.Empty, { description: txt(Const_1.V.TXT_FIND_NULL, search.word) }), selectable: false, className: "c-tree-empty" });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Language } from '../../utils/_Support';
|
|
3
3
|
import type { BaseTreeOpts, SearchResult, TreeNodeData } from '../../utils/TreeUtil';
|
|
4
|
-
import type { AntTreeNodeProps, TreeProps } from 'antd/es/tree';
|
|
4
|
+
import type { AntTreeNodeProps, AntTreeNodeSelectedEvent, TreeProps } from 'antd/es/tree';
|
|
5
5
|
import type { PropsWithChildren, ReactNode } from 'react';
|
|
6
6
|
import type { BaseTreeProps } from './index';
|
|
7
7
|
import type { Key, PlainObject } from '../../basetype';
|
|
@@ -19,11 +19,7 @@ export type BaseTreeState = Required<BaseTreeOpts> & {
|
|
|
19
19
|
field: string;
|
|
20
20
|
}[];
|
|
21
21
|
};
|
|
22
|
-
type OnSelectFunction = (selectedKeys: Key[], info:
|
|
23
|
-
selected?: boolean;
|
|
24
|
-
selectedNodes: any[];
|
|
25
|
-
nativeEvent?: MouseEvent;
|
|
26
|
-
}, tree?: PlainObject[]) => void;
|
|
22
|
+
type OnSelectFunction = (selectedKeys: Key[], info: AntTreeNodeSelectedEvent, tree?: PlainObject[]) => void;
|
|
27
23
|
type BaseTreeContext = {
|
|
28
24
|
treeState: BaseTreeState;
|
|
29
25
|
onSelect: OnSelectFunction;
|
|
@@ -120,7 +120,8 @@ const BaseTree = (props) => {
|
|
|
120
120
|
const setTreeData = (treeData) => setState({ treeData: [...treeData] });
|
|
121
121
|
(0, react_1.useEffect)(() => searchByKeyWord(props.searchValue), [props.searchValue]);
|
|
122
122
|
const onSelect = (0, react_1.useCallback)((selectedKeys, evt, tree) => {
|
|
123
|
-
|
|
123
|
+
if (evt.nativeEvent)
|
|
124
|
+
utils_1.PageUtil.stopEvent(evt.nativeEvent);
|
|
124
125
|
if (props.mustSelect && selectedKeys.length == 0)
|
|
125
126
|
return;
|
|
126
127
|
if (selectedKeys.length == 0) {
|
|
@@ -105,6 +105,7 @@ const _Dtree = (props) => {
|
|
|
105
105
|
onSelect([
|
|
106
106
|
tree[0][treeState.keyField]
|
|
107
107
|
], {
|
|
108
|
+
selected: true,
|
|
108
109
|
selectedNodes: [
|
|
109
110
|
// @ts-ignore
|
|
110
111
|
{ props: { data: { node: tree[0], position: [0] } } }
|
|
@@ -134,12 +135,5 @@ const _Dtree = (props) => {
|
|
|
134
135
|
data.children = children;
|
|
135
136
|
setTreeData(tree);
|
|
136
137
|
});
|
|
137
|
-
return react_1.default.createElement(antd_1.Tree, Object.assign({}, treeState.baseProps, treeProps, { className: treeState.className, loadData: loadData,
|
|
138
|
-
// disabled={props.disabled}
|
|
139
|
-
onSelect: (keys, evt) => {
|
|
140
|
-
console.log(keys, evt);
|
|
141
|
-
},
|
|
142
|
-
// onSelect={onSelect}
|
|
143
|
-
// selectedKeys={treeState.selectedKeys}
|
|
144
|
-
selectedKeys: treeState.selectedKeys }), (0, ActionTree_1.renderRoot)(props, treeState, actionContext));
|
|
138
|
+
return react_1.default.createElement(antd_1.Tree, Object.assign({}, treeState.baseProps, treeProps, { className: treeState.className, loadData: loadData, disabled: props.disabled, onSelect: onSelect, selectedKeys: treeState.selectedKeys }), (0, ActionTree_1.renderRoot)(props, treeState, actionContext));
|
|
145
139
|
};
|
|
@@ -59,7 +59,12 @@ const _Ftree = (props) => {
|
|
|
59
59
|
const tree = utils_1.TreeUtil.buildFlatTree(treeState, (0, ActionTree_1.getResponseList)(rootResp));
|
|
60
60
|
setTreeData(tree);
|
|
61
61
|
if (props.mustSelect && tree.length > 0) {
|
|
62
|
-
onSelect([tree[0][treeState.keyField]], {
|
|
62
|
+
onSelect([tree[0][treeState.keyField]], {
|
|
63
|
+
selectedNodes: [
|
|
64
|
+
// @ts-ignore
|
|
65
|
+
{ props: { data: { node: tree[0], position: [0] } } },
|
|
66
|
+
]
|
|
67
|
+
}, tree);
|
|
63
68
|
}
|
|
64
69
|
setInit(true);
|
|
65
70
|
}));
|
|
@@ -56,7 +56,12 @@ const _Stree = (props) => {
|
|
|
56
56
|
}
|
|
57
57
|
setTreeData(tree);
|
|
58
58
|
if (props.mustSelect && tree.length > 0) {
|
|
59
|
-
onSelect([tree[0][treeState.keyField]], {
|
|
59
|
+
onSelect([tree[0][treeState.keyField]], {
|
|
60
|
+
selectedNodes: [
|
|
61
|
+
//@ts-ignore
|
|
62
|
+
{ props: { data: { node: tree[0], position: [0] } } }
|
|
63
|
+
]
|
|
64
|
+
}, tree);
|
|
60
65
|
}
|
|
61
66
|
setInit(true);
|
|
62
67
|
}, [props.treeData]);
|
|
@@ -1,22 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import type { UFromProps } from './index';
|
|
2
|
+
import type { UFromProps, UFormFunctions } from './index';
|
|
3
3
|
import type { FormState } from './FormWrapper';
|
|
4
|
-
import type { PlainObject } from '../../basetype';
|
|
5
|
-
export type UFormFunctions = {
|
|
6
|
-
/**
|
|
7
|
-
* 获取当前表单数据
|
|
8
|
-
*/
|
|
9
|
-
data: () => PlainObject;
|
|
10
|
-
/**
|
|
11
|
-
* 获取当前表单数据
|
|
12
|
-
* 会先进行验证表单有效性,验证不通过则不返回
|
|
13
|
-
*/
|
|
14
|
-
validate: () => Promise<PlainObject>;
|
|
15
|
-
/**
|
|
16
|
-
* 重置表单
|
|
17
|
-
*/
|
|
18
|
-
reset: () => void;
|
|
19
|
-
};
|
|
20
4
|
export declare const initValue: (props: UFromProps & {
|
|
21
5
|
state: FormState;
|
|
22
6
|
}) => {
|
|
@@ -58,21 +58,25 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
58
58
|
let size = 0;
|
|
59
59
|
let needUpdate = false;
|
|
60
60
|
const pushBus = (targetField, result) => {
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
61
|
+
if (result === null) {
|
|
62
|
+
value[targetField] = undefined;
|
|
63
|
+
}
|
|
64
|
+
else if (lodash_1.default.isPlainObject(result)) {
|
|
65
|
+
const data = result;
|
|
66
|
+
if (lodash_1.default.has(data, 'value'))
|
|
67
|
+
value[targetField] = data.value;
|
|
68
|
+
if (lodash_1.default.has(data, 'required')) {
|
|
65
69
|
if (!requireFields.current.has(targetField)) {
|
|
66
70
|
needUpdate = true;
|
|
67
|
-
requireFields.current.set(targetField,
|
|
71
|
+
requireFields.current.set(targetField, data.required);
|
|
68
72
|
}
|
|
69
|
-
else if (requireFields.current.get(targetField) !=
|
|
73
|
+
else if (requireFields.current.get(targetField) != data.required) {
|
|
70
74
|
needUpdate = true;
|
|
71
|
-
requireFields.current.set(targetField,
|
|
75
|
+
requireFields.current.set(targetField, data.required);
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
|
-
if (lodash_1.default.has(
|
|
75
|
-
if (
|
|
78
|
+
if (lodash_1.default.has(data, 'disabled')) {
|
|
79
|
+
if (data.disabled) {
|
|
76
80
|
if (!disableFields.current.has(targetField)) {
|
|
77
81
|
needUpdate = true;
|
|
78
82
|
disableFields.current.add(targetField);
|
|
@@ -83,8 +87,8 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
83
87
|
disableFields.current.delete(targetField);
|
|
84
88
|
}
|
|
85
89
|
}
|
|
86
|
-
if (lodash_1.default.has(
|
|
87
|
-
if (
|
|
90
|
+
if (lodash_1.default.has(data, 'show')) {
|
|
91
|
+
if (data.show) {
|
|
88
92
|
if (hiddenFields.current.has(targetField)) {
|
|
89
93
|
needUpdate = true;
|
|
90
94
|
hiddenFields.current.delete(targetField);
|
|
@@ -95,16 +99,16 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
95
99
|
hiddenFields.current.add(targetField);
|
|
96
100
|
}
|
|
97
101
|
}
|
|
98
|
-
if (lodash_1.default.has(
|
|
99
|
-
if (
|
|
102
|
+
if (lodash_1.default.has(data, 'options')) {
|
|
103
|
+
if (data.options === null) {
|
|
100
104
|
if (optionFields.current.has(targetField)) {
|
|
101
105
|
needUpdate = true;
|
|
102
106
|
optionFields.current.delete(targetField);
|
|
103
107
|
}
|
|
104
108
|
}
|
|
105
|
-
else if (optionFields.current.get(targetField) !=
|
|
109
|
+
else if (optionFields.current.get(targetField) != data.options) {
|
|
106
110
|
needUpdate = true;
|
|
107
|
-
optionFields.current.set(targetField,
|
|
111
|
+
optionFields.current.set(targetField, data.options);
|
|
108
112
|
}
|
|
109
113
|
}
|
|
110
114
|
}
|
|
@@ -121,9 +125,10 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
121
125
|
};
|
|
122
126
|
field.link.map(link => {
|
|
123
127
|
const resp = link.call(values, getValue(multipleFields.current, form.getFieldsValue()), extra);
|
|
124
|
-
if (resp === null)
|
|
125
|
-
|
|
126
|
-
|
|
128
|
+
if (resp === null) {
|
|
129
|
+
pushBus(link.field, null);
|
|
130
|
+
}
|
|
131
|
+
else if (resp instanceof Promise) {
|
|
127
132
|
resp.then(result => pushBus(link.field, result));
|
|
128
133
|
}
|
|
129
134
|
else {
|
|
@@ -132,15 +137,6 @@ const onChangeEvent = (state, field, form, update, values, extra) => {
|
|
|
132
137
|
});
|
|
133
138
|
return values;
|
|
134
139
|
};
|
|
135
|
-
// const FieldContent = (component: InputComponent, field: UFormField)=>{
|
|
136
|
-
// React.createElement(component.element, {
|
|
137
|
-
// form: this.props.form,
|
|
138
|
-
// field,
|
|
139
|
-
// disabled: this.disableFields.has(field.field),
|
|
140
|
-
// options: (this.reOptions.has(field.field) ? this.reOptions.get(field.field) : undefined)
|
|
141
|
-
// })
|
|
142
|
-
// }
|
|
143
|
-
// export type FormFieldComponent = ComponentType<FormFieldProps>;
|
|
144
140
|
const renderFormField = (state, field, form, update, data) => {
|
|
145
141
|
const input = (0, _register_1.getUFormInput)(field.type || 'text');
|
|
146
142
|
const { labelSpan, inputSpan, colSpan, cols, disableFields, hiddenFields, requireFields, optionFields, } = state;
|
|
@@ -347,11 +343,9 @@ const _FormField = (props) => {
|
|
|
347
343
|
const { form } = props;
|
|
348
344
|
const update = (0, useUpdate_1.useUpdate)();
|
|
349
345
|
(0, react_1.useEffect)(() => {
|
|
350
|
-
// console.log('dfdsaupdate')
|
|
351
346
|
const values = (0, exports.initValue)(props);
|
|
352
347
|
props.initRef.current = values;
|
|
353
|
-
|
|
354
|
-
form.setFieldsValue(props.initRef.current);
|
|
348
|
+
form.setFieldsValue(values);
|
|
355
349
|
props.fields.map(field => {
|
|
356
350
|
if (field == null || field == false)
|
|
357
351
|
return;
|
|
@@ -361,12 +355,9 @@ const _FormField = (props) => {
|
|
|
361
355
|
if (lodash_1.default.isArray(field.link) && field.link.length > 0)
|
|
362
356
|
setTimeout(() => onChangeEvent(props.state, field, form, update, values[field.field]), 2);
|
|
363
357
|
});
|
|
364
|
-
// console.log('google')
|
|
365
358
|
update();
|
|
366
359
|
}, []);
|
|
367
|
-
//
|
|
368
|
-
// return Const.NONE
|
|
369
|
-
// if (props.initRef.current === null) return Const.NONE;
|
|
360
|
+
// if (props.initRef.current === null) return Const.NONE; 1.5 版本必须注释此行
|
|
370
361
|
const data = form.getFieldsValue();
|
|
371
362
|
return props.fields.map(field => {
|
|
372
363
|
if (field == null || field === false)
|
|
@@ -397,7 +388,7 @@ const _FormGroup = (props) => {
|
|
|
397
388
|
});
|
|
398
389
|
update();
|
|
399
390
|
}, []);
|
|
400
|
-
// if (props.initRef.current === null) return Const.NONE;
|
|
391
|
+
// if (props.initRef.current === null) return Const.NONE; 1.5 版本必须注释此行
|
|
401
392
|
const data = form.getFieldsValue();
|
|
402
393
|
return props.fields.map(group => {
|
|
403
394
|
if (group == null || group === false)
|
|
@@ -453,33 +444,10 @@ const _UForm = (0, react_1.forwardRef)((props, ref) => {
|
|
|
453
444
|
checkMultiple(item);
|
|
454
445
|
}
|
|
455
446
|
});
|
|
456
|
-
// initRef.current = initValue({ ...props, state })
|
|
457
|
-
// if (state.isGroup) {
|
|
458
|
-
// props.fields.map(group => {
|
|
459
|
-
// if (group == null || group == false) return;
|
|
460
|
-
// (group as UFormFieldGroup).fields.map(field => {
|
|
461
|
-
// // @ts-ignore
|
|
462
|
-
// if (field == null || field == false) return;
|
|
463
|
-
// if (!_.has(initRef.current, field.field) || initRef.current[field.field] === null || initRef.current[field.field] === undefined) return;
|
|
464
|
-
// // setFieldsValue 要 render 后才能get ,延时执行 link事件
|
|
465
|
-
// // if (_.isArray(field.link) && field.link.length > 0) setTimeout(() => onChangeEvent(state, field, form, update, values[field.field]), 2);
|
|
466
|
-
// })
|
|
467
|
-
// })
|
|
468
|
-
// } else {
|
|
469
|
-
// props.fields.map(field => {
|
|
470
|
-
// if (field == null || field == false) return;
|
|
471
|
-
// if (!_.has(initRef.current, field.field) || initRef.current[field.field] === null || initRef.current[field.field] === undefined) return;
|
|
472
|
-
// // setFieldsValue 要 render 后才能get ,延时执行 link事件
|
|
473
|
-
// // if (_.isArray(field.link) && field.link.length > 0) setTimeout(() => onChangeEvent(props.state, field, form, update, values[field.field]), 2);
|
|
474
|
-
// })
|
|
475
|
-
// }
|
|
476
|
-
// form.setFieldsValue(initRef.current, () => setChecked(true))
|
|
477
447
|
setChecked(true);
|
|
478
448
|
}, []);
|
|
479
449
|
if (!checked)
|
|
480
450
|
return utils_1.Const.NONE;
|
|
481
|
-
// console.log(initRef)
|
|
482
|
-
// console.log('fdsafd')
|
|
483
451
|
return react_1.default.createElement(antd_1.Form
|
|
484
452
|
// defaultValue={initRef.current}
|
|
485
453
|
// initialValues={props.default}
|
|
@@ -13,9 +13,6 @@ const Const_1 = require("../_setup/Const");
|
|
|
13
13
|
const FormWrapper_1 = require("./FormWrapper");
|
|
14
14
|
const FORM_FIELDS = ['layout', 'fields', 'groupType', 'isEdit', 'tip', 'default', 'data', 'mode', 'hideBorder', 'theme'];
|
|
15
15
|
const UInfoModal = (props) => {
|
|
16
|
-
const [open, afterClose] = (0, Modal_1.useDestoryModal)(props);
|
|
17
|
-
if (!open)
|
|
18
|
-
return utils_1.Const.NONE;
|
|
19
16
|
const param = lodash_1.default.omit(props, FORM_FIELDS);
|
|
20
17
|
if (!lodash_1.default.has(props, 'title') && lodash_1.default.has(props, 'autoTitle')) {
|
|
21
18
|
let name = null;
|
|
@@ -270,6 +270,7 @@ export type UFromAction = ButtonProps & {
|
|
|
270
270
|
/**
|
|
271
271
|
* icon
|
|
272
272
|
*/
|
|
273
|
+
icon?: string;
|
|
273
274
|
/**
|
|
274
275
|
* 1. submit 点击时会触发验证,不通过不回调 onClick
|
|
275
276
|
* 2. button 不会触发验证
|
|
@@ -390,3 +391,18 @@ export type UDescriptionsItemProps = BaseItem & {
|
|
|
390
391
|
*/
|
|
391
392
|
children: React.ReactNode;
|
|
392
393
|
};
|
|
394
|
+
export type UFormFunctions = {
|
|
395
|
+
/**
|
|
396
|
+
* 获取当前表单数据
|
|
397
|
+
*/
|
|
398
|
+
data: () => PlainObject;
|
|
399
|
+
/**
|
|
400
|
+
* 获取当前表单数据
|
|
401
|
+
* 会先进行验证表单有效性,验证不通过则不返回
|
|
402
|
+
*/
|
|
403
|
+
validate: () => Promise<PlainObject>;
|
|
404
|
+
/**
|
|
405
|
+
* 重置表单
|
|
406
|
+
*/
|
|
407
|
+
reset: () => void;
|
|
408
|
+
};
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.UploadFile = void 0;
|
|
7
7
|
const react_1 = __importDefault(require("react"));
|
|
8
8
|
const utils_1 = require("../../utils");
|
|
9
|
-
// import { Icon } from '../../components/_adapt/Icon';
|
|
10
9
|
const useUpload_1 = require("./useUpload");
|
|
11
10
|
const antd_1 = require("antd");
|
|
12
11
|
const Button_1 = require("../_adapt/Button");
|
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import type { FC } from 'react';
|
|
1
|
+
import type { FC, ReactNode, PropsWithChildren } from 'react';
|
|
2
|
+
import type { PopoverProps } from './Popover';
|
|
3
|
+
interface PresetsItem {
|
|
4
|
+
label: ReactNode;
|
|
5
|
+
colors: string[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* 说明1.5版本仅支持HEX
|
|
9
|
+
*/
|
|
10
|
+
type ColorFormat = 'hex';
|
|
2
11
|
export type ColorPickerProps = {
|
|
12
|
+
allowClear?: boolean;
|
|
13
|
+
arrow?: boolean;
|
|
14
|
+
size?: 'large' | 'middle' | 'small';
|
|
15
|
+
placement?: PopoverProps['placement'];
|
|
3
16
|
value?: string;
|
|
4
17
|
defaultValue?: string;
|
|
5
|
-
|
|
18
|
+
defaultFormat?: ColorFormat;
|
|
19
|
+
format?: ColorFormat;
|
|
6
20
|
disabled?: boolean;
|
|
7
|
-
|
|
21
|
+
disabledAlpha?: boolean;
|
|
22
|
+
destroyTooltipOnHide?: boolean;
|
|
23
|
+
onChange?: (value: any, hex: string) => void;
|
|
24
|
+
presets?: PresetsItem[];
|
|
25
|
+
showText?: boolean;
|
|
8
26
|
};
|
|
9
|
-
export declare const ColorPicker: FC<ColorPickerProps
|
|
27
|
+
export declare const ColorPicker: FC<PropsWithChildren<ColorPickerProps>>;
|
|
28
|
+
export {};
|
|
@@ -1,47 +1,111 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.ColorPicker = void 0;
|
|
7
|
-
const react_1 =
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
30
|
+
const react_1 = __importStar(require("react"));
|
|
31
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
32
|
+
const Popover_1 = require("./Popover");
|
|
33
|
+
const Icon_1 = require("./Icon");
|
|
34
|
+
const react_color_1 = require("react-color");
|
|
35
|
+
const hooks_1 = require("../../hooks");
|
|
36
|
+
const utils_1 = require("../../utils");
|
|
37
|
+
const ColorPicker = props => {
|
|
38
|
+
const [open, show] = (0, hooks_1.useToggle)();
|
|
39
|
+
const spanRef = (0, react_1.useRef)();
|
|
40
|
+
const [value, setValue] = (0, react_1.useState)(props.value || props.defaultValue);
|
|
41
|
+
const content = (0, react_1.useMemo)(() => {
|
|
42
|
+
if (props.children)
|
|
43
|
+
return props.children;
|
|
44
|
+
return react_1.default.createElement(react_1.default.Fragment, null,
|
|
45
|
+
react_1.default.createElement("i", { style: { backgroundColor: value } }),
|
|
46
|
+
" ",
|
|
47
|
+
react_1.default.createElement("strong", null, (props.showText && value != null) ? react_1.default.createElement("span", null, value) : utils_1.Const.NONE));
|
|
48
|
+
}, [value]);
|
|
49
|
+
const popoverProps = (0, react_1.useMemo)(() => {
|
|
50
|
+
const popoverProps = {
|
|
51
|
+
placement: 'bottomLeft',
|
|
52
|
+
arrow: true,
|
|
53
|
+
overlayClassName: 'v-color-picker',
|
|
54
|
+
defaultOpen: false,
|
|
55
|
+
trigger: 'click',
|
|
56
|
+
getTooltipContainer: () => spanRef.current
|
|
57
|
+
};
|
|
58
|
+
if (lodash_1.default.has(props, 'placement'))
|
|
59
|
+
popoverProps.placement = props.placement;
|
|
60
|
+
if (lodash_1.default.has(props, 'arrow'))
|
|
61
|
+
popoverProps.arrow = props.arrow;
|
|
62
|
+
return popoverProps;
|
|
63
|
+
}, []);
|
|
64
|
+
const spanProps = (0, react_1.useMemo)(() => {
|
|
65
|
+
const spanProps = { className: 'v-color-picker-brick', };
|
|
66
|
+
if (props.size)
|
|
67
|
+
spanProps.className = spanProps.className + ' v-color-picker-brick-' + props.size;
|
|
68
|
+
return spanProps;
|
|
69
|
+
}, [props.disabled, props.value]);
|
|
70
|
+
const colorProps = (0, react_1.useMemo)(() => {
|
|
71
|
+
const colorProps = {
|
|
72
|
+
disableAlpha: false,
|
|
73
|
+
onChangeComplete: (color, evt) => {
|
|
74
|
+
utils_1.PageUtil.stopEvent(evt);
|
|
75
|
+
setValue(color.hex);
|
|
76
|
+
if (lodash_1.default.isFunction(props.onChange)) {
|
|
77
|
+
props.onChange(color, color.hex);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
if (props.presets) {
|
|
82
|
+
let colors = [];
|
|
83
|
+
props.presets.map(item => {
|
|
84
|
+
item.colors.map(color => colors.push(color));
|
|
85
|
+
// return {
|
|
86
|
+
// color: item.colors,
|
|
87
|
+
// title: item.label,
|
|
88
|
+
// }
|
|
89
|
+
});
|
|
90
|
+
colorProps.presetColors = colors;
|
|
91
|
+
}
|
|
92
|
+
if (props.disabledAlpha)
|
|
93
|
+
colorProps.disableAlpha = true;
|
|
94
|
+
return colorProps;
|
|
95
|
+
}, []);
|
|
96
|
+
const clearColor = () => {
|
|
97
|
+
setValue(null);
|
|
98
|
+
props.onChange(null, null);
|
|
99
|
+
};
|
|
100
|
+
return react_1.default.createElement(react_1.default.Fragment, null,
|
|
101
|
+
react_1.default.createElement("span", Object.assign({}, spanProps, { ref: spanRef, onClick: evt => utils_1.PageUtil.stopEvent(evt, show) }),
|
|
102
|
+
content,
|
|
103
|
+
value != null && props.allowClear && react_1.default.createElement(Icon_1.Icon, { type: 'close', onClick: clearColor })),
|
|
104
|
+
"\u00A0",
|
|
105
|
+
react_1.default.createElement(Popover_1.Popover, Object.assign({ open: open }, popoverProps, { onOpenChange: (isOpen) => {
|
|
106
|
+
if (!isOpen) {
|
|
107
|
+
show(false);
|
|
108
|
+
}
|
|
109
|
+
}, content: react_1.default.createElement(react_color_1.SketchPicker, Object.assign({}, colorProps, { color: value })) })));
|
|
46
110
|
};
|
|
47
111
|
exports.ColorPicker = ColorPicker;
|