@teamix/pro 1.3.6 → 1.3.9
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/pro.css +1 -1
- package/dist/pro.js +3664 -10438
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/dist/pro.min.js.LICENSE.txt +0 -9
- package/es/actions/dialog-form.d.ts +2 -0
- package/es/actions/dialog-form.js +5 -2
- package/es/actions/dialog.js +8 -3
- package/es/actions/index.d.ts +5 -1
- package/es/actions/index.js +30 -9
- package/es/form/Components/LightFilter/index.js +8 -6
- package/es/form/Filter/LightFilter.js +12 -2
- package/es/form/Filter/useSpecialProps.js +2 -2
- package/es/form/ProForm/index.js +20 -10
- package/es/form/ProForm/index.scss +16 -8
- package/es/form/SchemaForm/index.js +18 -26
- package/es/form/SchemaForm/reactions.js +2 -2
- package/es/form/typing.d.ts +1 -0
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/ProInfoItem/index.js +2 -6
- package/es/info/components/ProInfoItem/index.scss +0 -4
- package/es/info/components/baseInfo/index.js +15 -8
- package/es/info/typing.d.ts +1 -2
- package/es/info/utils/index.d.ts +0 -8
- package/es/info/utils/index.js +1 -28
- package/es/sidebar/components/tree/index.js +17 -13
- package/es/sidebar/components/tree-node/components/IconSwitch/index.js +1 -1
- package/es/sidebar/index.js +5 -4
- package/es/sidebar/utils/index.d.ts +12 -0
- package/es/sidebar/utils/index.js +58 -0
- package/es/table/components/Pagination/index.js +4 -4
- package/es/table/components/ToolBar/FilterColumnIcon.js +5 -1
- package/es/table/index.js +9 -4
- package/es/table/typing.d.ts +3 -1
- package/lib/actions/dialog-form.d.ts +2 -0
- package/lib/actions/dialog-form.js +5 -2
- package/lib/actions/dialog.js +8 -3
- package/lib/actions/index.d.ts +5 -1
- package/lib/actions/index.js +29 -7
- package/lib/form/Components/LightFilter/index.js +5 -3
- package/lib/form/Filter/LightFilter.js +14 -2
- package/lib/form/Filter/useSpecialProps.js +1 -1
- package/lib/form/ProForm/index.js +19 -9
- package/lib/form/ProForm/index.scss +16 -8
- package/lib/form/SchemaForm/index.js +17 -26
- package/lib/form/SchemaForm/reactions.js +1 -1
- package/lib/form/typing.d.ts +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/ProInfoItem/index.js +2 -6
- package/lib/info/components/ProInfoItem/index.scss +0 -4
- package/lib/info/components/baseInfo/index.js +14 -7
- package/lib/info/typing.d.ts +1 -2
- package/lib/info/utils/index.d.ts +0 -8
- package/lib/info/utils/index.js +1 -32
- package/lib/sidebar/components/tree/index.js +19 -16
- package/lib/sidebar/components/tree-node/components/IconSwitch/index.js +1 -1
- package/lib/sidebar/index.js +6 -4
- package/lib/sidebar/utils/index.d.ts +12 -0
- package/lib/sidebar/utils/index.js +60 -0
- package/lib/table/components/Pagination/index.js +3 -3
- package/lib/table/components/ToolBar/FilterColumnIcon.js +5 -1
- package/lib/table/index.js +8 -3
- package/lib/table/typing.d.ts +3 -1
- package/package.json +18 -4
package/es/info/utils/index.js
CHANGED
@@ -30,31 +30,4 @@ export function getDataIndexValue(dataIndex, dataSource) {
|
|
30
30
|
}
|
31
31
|
|
32
32
|
return getDeepValue(dataIndex !== null && dataIndex !== void 0 ? dataIndex : '', dataSource);
|
33
|
-
}
|
34
|
-
/**
|
35
|
-
* 是否是最后一样的元素
|
36
|
-
* @param columnsLength
|
37
|
-
* @param layoutSpan
|
38
|
-
* @params itemIndex
|
39
|
-
* @returns
|
40
|
-
*/
|
41
|
-
|
42
|
-
export var isLastRow = function isLastRow(columnsLength, layoutSpan, itemIndex) {
|
43
|
-
if (!columnsLength || !layoutSpan) return;
|
44
|
-
var lastRowColumnsIndexList = [];
|
45
|
-
var rowCount = 24 / layoutSpan;
|
46
|
-
|
47
|
-
if (columnsLength % rowCount === 0) {
|
48
|
-
while (rowCount--) {
|
49
|
-
lastRowColumnsIndexList.push(columnsLength--);
|
50
|
-
}
|
51
|
-
} else {
|
52
|
-
var lastRowCount = columnsLength % rowCount;
|
53
|
-
|
54
|
-
while (lastRowCount--) {
|
55
|
-
lastRowColumnsIndexList.push(columnsLength--);
|
56
|
-
}
|
57
|
-
}
|
58
|
-
|
59
|
-
return lastRowColumnsIndexList.includes(itemIndex + 1);
|
60
|
-
};
|
33
|
+
}
|
@@ -36,10 +36,9 @@ import { Tree } from '@alicloudfe/components';
|
|
36
36
|
import { baseClass } from '@teamix/utils';
|
37
37
|
import React, { useEffect, useMemo, useState } from 'react';
|
38
38
|
import { renderTreeNode, renderTreeNodeDependenceValue } from '../tree-node';
|
39
|
-
import { debounce } from 'lodash';
|
40
39
|
import './index.scss';
|
41
40
|
import '../tree-node/index.scss';
|
42
|
-
import {
|
41
|
+
import { filterTreeData, getAllNodeKey, getTreeLevelKey, loop } from '../../utils';
|
43
42
|
import { useUpdateEffect } from '@teamix/hooks';
|
44
43
|
import { useActionType } from '../../utils/action-ref';
|
45
44
|
import cloneDeep from 'lodash.clonedeep';
|
@@ -121,7 +120,11 @@ var ProSidebarTree = function ProSidebarTree(props) {
|
|
121
120
|
|
122
121
|
useEffect(function () {
|
123
122
|
setDefaultExpandedKeys();
|
124
|
-
}, []); //
|
123
|
+
}, []); // 监听 selectedKeys,用于受控
|
124
|
+
|
125
|
+
useEffect(function () {
|
126
|
+
setSelectedKeys(selectedKeysProp);
|
127
|
+
}, [selectedKeysProp]); // 更新外部传入的 dataSource
|
125
128
|
|
126
129
|
useUpdateEffect(function () {
|
127
130
|
setDataSource(processDataSource(dataSourceProp !== null && dataSourceProp !== void 0 ? dataSourceProp : []));
|
@@ -211,7 +214,7 @@ var ProSidebarTree = function ProSidebarTree(props) {
|
|
211
214
|
}; // 过滤
|
212
215
|
|
213
216
|
|
214
|
-
var filterDataSource =
|
217
|
+
var filterDataSource = function filterDataSource(value) {
|
215
218
|
var searchDataSource = processDataSource(dataSourceProp !== null && dataSourceProp !== void 0 ? dataSourceProp : []);
|
216
219
|
var expandedKeys = [];
|
217
220
|
|
@@ -223,21 +226,22 @@ var ProSidebarTree = function ProSidebarTree(props) {
|
|
223
226
|
return;
|
224
227
|
}
|
225
228
|
|
226
|
-
|
229
|
+
var _filterTreeData = filterTreeData(searchDataSource, function (node) {
|
230
|
+
var _node$label;
|
231
|
+
|
232
|
+
return ((_node$label = node === null || node === void 0 ? void 0 : node.label) !== null && _node$label !== void 0 ? _node$label : '').includes(value);
|
233
|
+
}),
|
234
|
+
filterTreeValue = _filterTreeData.filterTreeValue;
|
235
|
+
|
236
|
+
loop(filterTreeValue, function (item) {
|
227
237
|
hasSearchValue(value, item) && expandedKeys.push(String(item['value']));
|
228
238
|
}, {
|
229
239
|
children: 'children'
|
230
240
|
});
|
231
|
-
setExpandedKeys([].concat(expandedKeys));
|
232
241
|
setMatchedKeys(matchedKeys);
|
233
242
|
handleExpand(expandedKeys);
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
return ((_node$label = node === null || node === void 0 ? void 0 : node.label) !== null && _node$label !== void 0 ? _node$label : '').includes(value);
|
238
|
-
});
|
239
|
-
setDataSource(filterDataSource);
|
240
|
-
}, 100);
|
243
|
+
setDataSource(filterTreeValue);
|
244
|
+
};
|
241
245
|
|
242
246
|
var filterTreeNode = function filterTreeNode(node) {
|
243
247
|
return matchedKeys && matchedKeys.indexOf(node.props.eventKey) > -1;
|
@@ -33,7 +33,7 @@ var ProIconSwitch = function ProIconSwitch(props) {
|
|
33
33
|
setVisible = _useState2[1];
|
34
34
|
|
35
35
|
useEffect(function () {
|
36
|
-
setVisible(visibleProp !== null && visibleProp !== void 0 ? visibleProp :
|
36
|
+
setVisible(visibleProp !== null && visibleProp !== void 0 ? visibleProp : true);
|
37
37
|
}, [visibleProp]); // 点击操作
|
38
38
|
|
39
39
|
var clickHandle = function clickHandle(e, state) {
|
package/es/sidebar/index.js
CHANGED
@@ -29,6 +29,7 @@ import ProSidebarContainer from './components/sidebar-container';
|
|
29
29
|
import ProSidebarTree from './components/tree';
|
30
30
|
import { getTreeLevel, ProSkeletonRaw } from '..';
|
31
31
|
import { useActionType } from './utils/action-ref';
|
32
|
+
import debounce from 'lodash.debounce';
|
32
33
|
export * from './typing';
|
33
34
|
export * from './utils';
|
34
35
|
var cls = baseClass('teamix-pro-sidebar');
|
@@ -40,7 +41,7 @@ var ProSidebar = function ProSidebar(props) {
|
|
40
41
|
_props$className = props.className,
|
41
42
|
className = _props$className === void 0 ? '' : _props$className,
|
42
43
|
style = props.style,
|
43
|
-
|
44
|
+
searchOnChange = props.searchOnChange,
|
44
45
|
_props$showSearch = props.showSearch,
|
45
46
|
showSearch = _props$showSearch === void 0 ? true : _props$showSearch,
|
46
47
|
onSelect = props.onSelect,
|
@@ -174,12 +175,12 @@ var ProSidebar = function ProSidebar(props) {
|
|
174
175
|
}), " ").concat(className),
|
175
176
|
style: style
|
176
177
|
}, /*#__PURE__*/React.createElement(ProSidebarContainer, _objectSpread(_objectSpread({
|
177
|
-
searchOnChange: function
|
178
|
+
searchOnChange: debounce(function (value) {
|
178
179
|
if (showSearch) {
|
179
|
-
|
180
|
+
searchOnChange === null || searchOnChange === void 0 ? void 0 : searchOnChange(value);
|
180
181
|
setSearchKey(value);
|
181
182
|
}
|
182
|
-
},
|
183
|
+
}, 300),
|
183
184
|
onExpandAllChange: onExpandAllChange,
|
184
185
|
onExpandLevelChange: onExpandLevelChange,
|
185
186
|
showSearch: showSearch,
|
@@ -69,3 +69,15 @@ export declare function getTreeLevelKey(data: any[], level: number, aliasMap?: {
|
|
69
69
|
key: string;
|
70
70
|
children: string;
|
71
71
|
}): any[];
|
72
|
+
/**
|
73
|
+
* 深度遍历并查找节点(展开查找到的字节点路径)
|
74
|
+
* @param nodes 数据
|
75
|
+
* @param predicate 条件
|
76
|
+
* @param aliasMap 标识
|
77
|
+
* @returns
|
78
|
+
*/
|
79
|
+
export declare function filterTreeData<T>(nodes: any[], predicate: (node: T) => boolean, aliasMap?: {
|
80
|
+
children: string;
|
81
|
+
}): {
|
82
|
+
filterTreeValue: T[];
|
83
|
+
};
|
@@ -1,3 +1,5 @@
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
2
|
+
|
1
3
|
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; }
|
2
4
|
|
3
5
|
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; }
|
@@ -225,4 +227,60 @@ export function getTreeLevelKey(data, level, aliasMap) {
|
|
225
227
|
children: children
|
226
228
|
});
|
227
229
|
return result;
|
230
|
+
}
|
231
|
+
/**
|
232
|
+
* 深度遍历并查找节点(展开查找到的字节点路径)
|
233
|
+
* @param nodes 数据
|
234
|
+
* @param predicate 条件
|
235
|
+
* @param aliasMap 标识
|
236
|
+
* @returns
|
237
|
+
*/
|
238
|
+
|
239
|
+
export function filterTreeData(nodes, predicate, aliasMap) {
|
240
|
+
if (!(nodes && nodes.length)) {
|
241
|
+
return {
|
242
|
+
filterTreeValue: []
|
243
|
+
};
|
244
|
+
}
|
245
|
+
|
246
|
+
var _ref8 = aliasMap !== null && aliasMap !== void 0 ? aliasMap : {},
|
247
|
+
_ref8$children = _ref8.children,
|
248
|
+
children = _ref8$children === void 0 ? 'children' : _ref8$children;
|
249
|
+
|
250
|
+
var filterTreeValue = [];
|
251
|
+
|
252
|
+
var _iterator2 = _createForOfIteratorHelper(nodes),
|
253
|
+
_step2;
|
254
|
+
|
255
|
+
try {
|
256
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
257
|
+
var node = _step2.value;
|
258
|
+
|
259
|
+
var others = _extends({}, node);
|
260
|
+
|
261
|
+
if (predicate(node)) {
|
262
|
+
var _node$children3;
|
263
|
+
|
264
|
+
filterTreeValue.push(_objectSpread(_objectSpread({}, others), {}, {
|
265
|
+
children: filterTreeData((_node$children3 = node[children]) !== null && _node$children3 !== void 0 ? _node$children3 : [], predicate, aliasMap).filterTreeValue
|
266
|
+
}));
|
267
|
+
} else {
|
268
|
+
var subs = filterTreeData(node[children], predicate, aliasMap);
|
269
|
+
|
270
|
+
if (subs && subs.filterTreeValue.length) {
|
271
|
+
filterTreeValue.push(_objectSpread(_objectSpread({}, others), {}, {
|
272
|
+
children: subs.filterTreeValue
|
273
|
+
}));
|
274
|
+
}
|
275
|
+
}
|
276
|
+
}
|
277
|
+
} catch (err) {
|
278
|
+
_iterator2.e(err);
|
279
|
+
} finally {
|
280
|
+
_iterator2.f();
|
281
|
+
}
|
282
|
+
|
283
|
+
return {
|
284
|
+
filterTreeValue: filterTreeValue
|
285
|
+
};
|
228
286
|
}
|
@@ -25,7 +25,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
|
|
25
25
|
// 自适应宽度的翻页器
|
26
26
|
import React, { useState, useEffect } from 'react';
|
27
27
|
import { Pagination, Balloon, Select, Button, Input, Icon } from '@alicloudfe/components';
|
28
|
-
import { getMessage, baseClass } from '@teamix/utils';
|
28
|
+
import { getMessage, baseClass, usePrefixCls } from '@teamix/utils';
|
29
29
|
import { useResponsiveProps } from '@teamix/hooks';
|
30
30
|
import './index.scss';
|
31
31
|
var cls = baseClass('teamix-pro-pagination');
|
@@ -160,7 +160,7 @@ export default (function (props) {
|
|
160
160
|
return /*#__PURE__*/React.createElement("div", {
|
161
161
|
className: cls('custom-jumper')
|
162
162
|
}, /*#__PURE__*/React.createElement(Button, {
|
163
|
-
className: "
|
163
|
+
className: "".concat(usePrefixCls(), "prev ").concat(usePrefixCls(), "pagination-item"),
|
164
164
|
onClick: handlePrevClick,
|
165
165
|
disabled: Number(currentPage) <= 1
|
166
166
|
}, /*#__PURE__*/React.createElement(Icon, {
|
@@ -182,7 +182,7 @@ export default (function (props) {
|
|
182
182
|
marginRight: 4
|
183
183
|
}
|
184
184
|
}, "/"), getTotalPage(total, pageSize)), /*#__PURE__*/React.createElement(Button, {
|
185
|
-
className: "next
|
185
|
+
className: "".concat(usePrefixCls(), "next ").concat(usePrefixCls(), "pagination-item"),
|
186
186
|
onClick: handleNextClick,
|
187
187
|
//@ts-ignore
|
188
188
|
disabled: total && Number(currentPage) >= getTotalPage(total, pageSize)
|
@@ -200,7 +200,7 @@ export default (function (props) {
|
|
200
200
|
}, otherProps));
|
201
201
|
} else {
|
202
202
|
return /*#__PURE__*/React.createElement("div", {
|
203
|
-
className: "".concat(cls('custom-mini-pagination'), "
|
203
|
+
className: "".concat(cls('custom-mini-pagination'), " ").concat(usePrefixCls(), "pagination")
|
204
204
|
}, customTotalRender(total), customJumpRender());
|
205
205
|
}
|
206
206
|
}
|
@@ -47,8 +47,12 @@ var processColumns = function processColumns(columns) {
|
|
47
47
|
columns = columns.filter(function (item) {
|
48
48
|
return item.valueType !== 'selectGroup';
|
49
49
|
});
|
50
|
-
}
|
50
|
+
} // hidden 为 true 时不展示
|
51
|
+
|
51
52
|
|
53
|
+
columns = columns.filter(function (item) {
|
54
|
+
return (item === null || item === void 0 ? void 0 : item.hidden) !== true;
|
55
|
+
});
|
52
56
|
return columns.map(function (item) {
|
53
57
|
if (item.columnFilters === false) {
|
54
58
|
return item;
|
package/es/table/index.js
CHANGED
@@ -36,7 +36,7 @@ import React, { useState, useEffect, useRef } from 'react';
|
|
36
36
|
import { Table, Checkbox } from '@alicloudfe/components';
|
37
37
|
import Pagination from './components/Pagination';
|
38
38
|
import genProColumnToColumn from './utils/genProColumnToColumn';
|
39
|
-
import { baseClass, useRequest, request as utilResquest, getDeepValue, getMessage, pickProps, getCookie } from '@teamix/utils';
|
39
|
+
import { baseClass, useRequest, request as utilResquest, getDeepValue, getMessage, pickProps, getCookie, usePrefixCls } from '@teamix/utils';
|
40
40
|
import { ProSkeletonRaw as Skeleton } from '../skeleton';
|
41
41
|
import './index.scss';
|
42
42
|
import Layout from './components/Layout';
|
@@ -65,7 +65,7 @@ var processColumns = function processColumns(columns, initialColumns) {
|
|
65
65
|
var _filterColumns;
|
66
66
|
|
67
67
|
var filterColumns = columns.filter(function (item) {
|
68
|
-
return item.columnFilters !== false;
|
68
|
+
return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true;
|
69
69
|
});
|
70
70
|
|
71
71
|
if (isRoot) {
|
@@ -269,7 +269,7 @@ var ProTable = function ProTable(props) {
|
|
269
269
|
|
270
270
|
var tableDom = tableRef.current;
|
271
271
|
var headerDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements = tableDom.getElementsByClassName('teamix-pro-table-layout')) === null || _tableDom$getElements === void 0 ? void 0 : _tableDom$getElements[0];
|
272
|
-
var tableHeaderDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements2 = tableDom.getElementsByClassName(
|
272
|
+
var tableHeaderDom = tableDom === null || tableDom === void 0 ? void 0 : (_tableDom$getElements2 = tableDom.getElementsByClassName("".concat(usePrefixCls(), "table-header-inner"))) === null || _tableDom$getElements2 === void 0 ? void 0 : _tableDom$getElements2[0];
|
273
273
|
return new Promise(function (resolve) {
|
274
274
|
setTimeout(function () {
|
275
275
|
var _headerDom$offsetHeig, _tableHeaderDom$offse;
|
@@ -692,6 +692,11 @@ var ProTable = function ProTable(props) {
|
|
692
692
|
setTotal(total || (data === null || data === void 0 ? void 0 : data.length));
|
693
693
|
setShowSkeleton(false);
|
694
694
|
setCustomTableLoading(false);
|
695
|
+
} // 重新计算是否需要吸底
|
696
|
+
|
697
|
+
|
698
|
+
if (footerSuction) {
|
699
|
+
getFooterSuctionState();
|
695
700
|
}
|
696
701
|
});
|
697
702
|
} else {
|
@@ -750,7 +755,7 @@ var ProTable = function ProTable(props) {
|
|
750
755
|
onInit: function onInit(values) {
|
751
756
|
// 表单初始化请求处理
|
752
757
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onInit(values));
|
753
|
-
!fullscreenState && _request({}, false, values);
|
758
|
+
!fullscreenState && requestWhenMount && _request({}, false, values);
|
754
759
|
return true;
|
755
760
|
},
|
756
761
|
onFilter: function onFilter(values) {
|
package/es/table/typing.d.ts
CHANGED
@@ -33,7 +33,9 @@ export declare type ProTableColumnProps = {
|
|
33
33
|
tooltipIcon?: React.ReactNode;
|
34
34
|
/** 对应 ProField 里面的 type */
|
35
35
|
valueType?: ProFieldType;
|
36
|
-
/**
|
36
|
+
/** 是否隐藏表格列,列配置也不显示 */
|
37
|
+
hidden?: boolean;
|
38
|
+
/** 【列配置】是否默认隐藏表格列,但列配置显示 */
|
37
39
|
columnFilters?: boolean;
|
38
40
|
/** 【列配置】是否禁用隐藏列 */
|
39
41
|
columnFiltersDisabled?: boolean;
|
@@ -20,6 +20,8 @@ export interface DialogFormAction extends DialogAction {
|
|
20
20
|
schema: ProFormSchema | Omit<ProFormProps, 'form'>;
|
21
21
|
/** 外部传来的 formRef,用于获取内置 form 实例 */
|
22
22
|
formRef?: React.MutableRefObject<ProFormType | undefined>;
|
23
|
+
/** 是否开启懒惰校验,只校验第一个非法规则,默认开启 */
|
24
|
+
validateFirst?: boolean;
|
23
25
|
}
|
24
26
|
export declare function useDialogFormAction(action: DialogFormAction, context?: any): {
|
25
27
|
[x: string]: (e: React.MouseEvent<HTMLElement, MouseEvent>) => Promise<void>;
|
@@ -111,14 +111,17 @@ var DialogForm = function DialogForm(props) {
|
|
111
111
|
formProps = props.formProps,
|
112
112
|
context = props.context,
|
113
113
|
formRef = props.formRef,
|
114
|
-
innerFormRef = props.innerFormRef
|
114
|
+
innerFormRef = props.innerFormRef,
|
115
|
+
_props$validateFirst = props.validateFirst,
|
116
|
+
validateFirst = _props$validateFirst === void 0 ? true : _props$validateFirst;
|
115
117
|
|
116
118
|
var _getSchemaAndFormProp = getSchemaAndFormProps(schema, formProps),
|
117
119
|
formSchema = _getSchemaAndFormProp.schema,
|
118
120
|
others = _objectWithoutProperties(_getSchemaAndFormProp, _excluded);
|
119
121
|
|
120
122
|
var form = (0, _form.createForm)({
|
121
|
-
initialValues: (0, _utils.getTargetValue)(initialValues, context)
|
123
|
+
initialValues: (0, _utils.getTargetValue)(initialValues, context),
|
124
|
+
validateFirst: validateFirst
|
122
125
|
});
|
123
126
|
|
124
127
|
var _useState = (0, _react.useState)(false),
|
package/lib/actions/dialog.js
CHANGED
@@ -200,17 +200,22 @@ function useDialogAction(action, actionContext) {
|
|
200
200
|
case 6:
|
201
201
|
onFinish && onFinish();
|
202
202
|
resolve(true);
|
203
|
-
_context.next =
|
203
|
+
_context.next = 16;
|
204
204
|
break;
|
205
205
|
|
206
206
|
case 10:
|
207
207
|
_context.prev = 10;
|
208
208
|
_context.t0 = _context["catch"](2);
|
209
|
-
setLoading(false);
|
209
|
+
setLoading(false); // 如果 beforeRequest 中返回了 false,则直接关闭弹窗
|
210
|
+
|
211
|
+
if (beforeRequest) {
|
212
|
+
resolve(true);
|
213
|
+
}
|
214
|
+
|
210
215
|
resolve(false);
|
211
216
|
return _context.abrupt("return");
|
212
217
|
|
213
|
-
case
|
218
|
+
case 16:
|
214
219
|
case "end":
|
215
220
|
return _context.stop();
|
216
221
|
}
|
package/lib/actions/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
import React from 'react';
|
1
|
+
import React, { ReactNode } from 'react';
|
2
2
|
import { ButtonProps } from '@alicloudfe/components/types/button';
|
3
3
|
import { MenuButtonProps } from '@alicloudfe/components/types/menu-button';
|
4
|
+
import { TooltipProps } from '@alicloudfe/components/types/balloon';
|
4
5
|
import { LinkAction } from './link';
|
5
6
|
import { RequestAction } from './request';
|
6
7
|
import { DialogAction } from './dialog';
|
@@ -29,7 +30,10 @@ export declare function useAction(config?: ProActionConfig, context?: any): any;
|
|
29
30
|
export interface ProActionButtonProps extends ProActionCommonProps, ButtonProps {
|
30
31
|
config?: ProActionConfig;
|
31
32
|
disabled?: any;
|
33
|
+
tooltip?: ReactNode;
|
34
|
+
disabledTooltip?: ReactNode;
|
32
35
|
icon?: string;
|
36
|
+
tooltipProps?: TooltipProps;
|
33
37
|
onClick?: (event: React.MouseEvent<Element, MouseEvent>, context?: any) => void;
|
34
38
|
}
|
35
39
|
export declare const ProActionButton: (props: ProActionButtonProps) => JSX.Element;
|
package/lib/actions/index.js
CHANGED
@@ -54,7 +54,7 @@ var _dangerPopConfirm = require("./danger-pop-confirm");
|
|
54
54
|
require("./index.scss");
|
55
55
|
|
56
56
|
var _excluded = ["type"],
|
57
|
-
_excluded2 = ["config", "icon", "iconSize", "type", "context", "children", "visible", "onClick"],
|
57
|
+
_excluded2 = ["config", "icon", "iconSize", "type", "context", "children", "visible", "disabled", "onClick", "tooltip", "disabledTooltip", "tooltipProps"],
|
58
58
|
_excluded3 = ["loading"],
|
59
59
|
_excluded4 = ["icon", "iconSize", "label", "actions", "children", "context", "type", "className", "noArrow"],
|
60
60
|
_excluded5 = ["context", "text"],
|
@@ -202,18 +202,40 @@ var ProActionButton = function ProActionButton(props) {
|
|
202
202
|
context = props.context,
|
203
203
|
children = props.children,
|
204
204
|
visible = props.visible,
|
205
|
+
disabled = props.disabled,
|
205
206
|
_onClick = props.onClick,
|
207
|
+
tooltip = props.tooltip,
|
208
|
+
disabledTooltip = props.disabledTooltip,
|
209
|
+
tooltipProps = props.tooltipProps,
|
206
210
|
others = _objectWithoutProperties(props, _excluded2);
|
207
211
|
|
208
212
|
var actionProps = useAction(config, context);
|
209
|
-
var buttonProps = _onClick ? _objectSpread(_objectSpread(_objectSpread({
|
213
|
+
var buttonProps = _onClick ? _objectSpread(_objectSpread(_objectSpread({
|
214
|
+
disabled: disabled
|
215
|
+
}, actionProps), others), {}, {
|
210
216
|
onClick: function onClick(e) {
|
211
217
|
return _onClick(e, context);
|
212
218
|
}
|
213
|
-
}) : _objectSpread(_objectSpread({
|
214
|
-
|
219
|
+
}) : _objectSpread(_objectSpread({
|
220
|
+
disabled: disabled
|
221
|
+
}, actionProps), others);
|
222
|
+
|
223
|
+
var content = /*#__PURE__*/_react.default.createElement(_components.Button, _objectSpread({
|
215
224
|
type: type
|
216
225
|
}, buttonProps), buttonContent(children, icon, iconSize, context));
|
226
|
+
|
227
|
+
var baseToolTipProps = _objectSpread({
|
228
|
+
triggerType: 'hover',
|
229
|
+
align: 't',
|
230
|
+
trigger: content
|
231
|
+
}, tooltipProps);
|
232
|
+
|
233
|
+
if (tooltip || disabledTooltip) {
|
234
|
+
var showToolTip = disabled ? disabledTooltip : tooltip;
|
235
|
+
content = /*#__PURE__*/_react.default.createElement(_components.Balloon.Tooltip, _objectSpread({}, baseToolTipProps), showToolTip);
|
236
|
+
}
|
237
|
+
|
238
|
+
return content;
|
217
239
|
};
|
218
240
|
|
219
241
|
exports.ProActionButton = ProActionButton;
|
@@ -241,9 +263,7 @@ var ProActionMenuButtonItem = function ProActionMenuButtonItem(props) {
|
|
241
263
|
}
|
242
264
|
}) : _objectSpread({}, menuItemProps);
|
243
265
|
return /*#__PURE__*/_react.default.createElement("div", _objectSpread({
|
244
|
-
className: (0, _classnames.default)('teamix-pro-action-menu-item',
|
245
|
-
'next-disabled': disabled
|
246
|
-
})
|
266
|
+
className: (0, _classnames.default)('teamix-pro-action-menu-item', "".concat((0, _utils.usePrefixCls)(), "menu-item"), _defineProperty({}, "".concat((0, _utils.usePrefixCls)(), "disabled"), disabled))
|
247
267
|
}, buttonProps), buttonContent(children, icon, undefined, context));
|
248
268
|
};
|
249
269
|
|
@@ -405,6 +425,8 @@ function getActionConfig(action, index, context) {
|
|
405
425
|
key: getKey(index, _key),
|
406
426
|
actions: actions.map(function (a, j) {
|
407
427
|
return getActionConfig(a, j, context);
|
428
|
+
}).filter(function (action) {
|
429
|
+
return action.visible !== false;
|
408
430
|
})
|
409
431
|
}, (0, _utils.getTargetValue)(_others, context));
|
410
432
|
}
|
@@ -78,13 +78,14 @@ var useMain = function useMain(active) {
|
|
78
78
|
}; // 筛选项数据
|
79
79
|
|
80
80
|
|
81
|
-
var useFilterItems = function useFilterItems(filterValues) {
|
81
|
+
var useFilterItems = function useFilterItems(filterValues, scope) {
|
82
82
|
var schema = (0, _react2.useFieldSchema)();
|
83
83
|
var filterItems = [];
|
84
84
|
schema.mapProperties(function (schema, name) {
|
85
85
|
if (!filterValues || filterValues && filterValues.includes(schema.name)) {
|
86
|
+
var label = /{{.*}}/.test(schema.title) ? (0, _utils.getTargetValue)(schema.title, scope) : schema.title;
|
86
87
|
filterItems.push({
|
87
|
-
label:
|
88
|
+
label: label,
|
88
89
|
value: schema.name
|
89
90
|
});
|
90
91
|
}
|
@@ -107,7 +108,8 @@ var LightFilter = (0, _react2.observer)(function (props) {
|
|
107
108
|
onFilterChange = props.onFilterChange,
|
108
109
|
filterProps = props.filterProps,
|
109
110
|
buttonProps = props.buttonProps;
|
110
|
-
var
|
111
|
+
var scope = (0, _react.useContext)(_react2.SchemaExpressionScopeContext);
|
112
|
+
var filterItems = useFilterItems(filterValues, scope);
|
111
113
|
|
112
114
|
var _useState = (0, _react.useState)(defaultFilterValue || ((_filterItems$ = filterItems[0]) === null || _filterItems$ === void 0 ? void 0 : _filterItems$.value)),
|
113
115
|
_useState2 = _slicedToArray(_useState, 2),
|
@@ -11,6 +11,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
11
11
|
|
12
12
|
var _classnames = _interopRequireDefault(require("classnames"));
|
13
13
|
|
14
|
+
var _reactive = require("@formily/reactive");
|
15
|
+
|
14
16
|
var _utils = require("@teamix/utils");
|
15
17
|
|
16
18
|
var _ProForm = _interopRequireDefault(require("../ProForm"));
|
@@ -33,9 +35,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
33
35
|
|
34
36
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
35
37
|
|
38
|
+
var lightFilterObs = (0, _reactive.observable)({
|
39
|
+
onFilter: function onFilter() {}
|
40
|
+
});
|
36
41
|
/**
|
37
42
|
* 轻量筛选
|
38
43
|
*/
|
44
|
+
|
39
45
|
var LightFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
|
40
46
|
var _schema$;
|
41
47
|
|
@@ -87,7 +93,7 @@ var LightFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
87
93
|
filterValues: filterValues,
|
88
94
|
onFilterChange: onFilterChange,
|
89
95
|
buttonProps: {
|
90
|
-
onClick: onFilter
|
96
|
+
onClick: "{{lightFilterObs.onFilter}}"
|
91
97
|
}
|
92
98
|
},
|
93
99
|
children: schema
|
@@ -99,8 +105,14 @@ var LightFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
|
|
99
105
|
}
|
100
106
|
}
|
101
107
|
}];
|
102
|
-
}, [schema,
|
108
|
+
}, [schema, onFilterChange, defaultFilterValue]);
|
109
|
+
(0, _react.useEffect)(function () {
|
110
|
+
lightFilterObs.onFilter = onFilter;
|
111
|
+
}, [onChange]);
|
103
112
|
return /*#__PURE__*/_react.default.createElement(_ProForm.default, _objectSpread(_objectSpread({}, otherProps), {}, {
|
113
|
+
scope: _objectSpread(_objectSpread({}, otherProps === null || otherProps === void 0 ? void 0 : otherProps.scope), {}, {
|
114
|
+
lightFilterObs: lightFilterObs
|
115
|
+
}),
|
104
116
|
form: form,
|
105
117
|
className: (0, _classnames.default)(prefixCls, props.className),
|
106
118
|
schema: LightSchema,
|
@@ -24,7 +24,7 @@ var useSpecialProps = function useSpecialProps(props) {
|
|
24
24
|
dataSource = item.dataSource,
|
25
25
|
children = item.children; // 字符串变量配置default值会触发onChange
|
26
26
|
|
27
|
-
hasChangeDefault = hasChangeDefault || !!((0, _utils.
|
27
|
+
hasChangeDefault = hasChangeDefault || !!((0, _utils.isPlainObj)(dataSource) && (0, _utils.isStr)(value) && value.indexOf('.dataSource'));
|
28
28
|
hasDefault = hasDefault || (0, _utils.isUsable)(value);
|
29
29
|
hasRequired = hasRequired || required || !!rules;
|
30
30
|
|
@@ -31,7 +31,7 @@ var _validate = _interopRequireDefault(require("../locales/validate"));
|
|
31
31
|
|
32
32
|
require("./index.scss");
|
33
33
|
|
34
|
-
var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "onInitialComplete", "className"];
|
34
|
+
var _excluded = ["form", "initialValues", "initialRequest", "schema", "scope", "context", "components", "children", "layout", "labelAlign", "wrapperAlign", "labelCol", "wrapperCol", "breakpoints", "onChange", "onSubmit", "onSubmitFailed", "onInitialComplete", "className", "validateFirst"];
|
35
35
|
|
36
36
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
37
37
|
|
@@ -70,21 +70,30 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
70
70
|
onSubmitFailed = _ref.onSubmitFailed,
|
71
71
|
onInitialComplete = _ref.onInitialComplete,
|
72
72
|
className = _ref.className,
|
73
|
+
validateFirst = _ref.validateFirst,
|
73
74
|
otherProps = _objectWithoutProperties(_ref, _excluded);
|
74
75
|
|
76
|
+
// 获取全局配置
|
77
|
+
var _ref2 = (0, _utils.getGlobalConfig)('ProForm') || {},
|
78
|
+
globalComponents = _ref2.components,
|
79
|
+
globalScope = _ref2.scope;
|
80
|
+
|
75
81
|
var form = (0, _react.useMemo)(function () {
|
76
82
|
return outerForm || (0, _core.createForm)({
|
77
|
-
validateFirst:
|
83
|
+
validateFirst: validateFirst
|
78
84
|
});
|
79
85
|
}, []);
|
80
86
|
var prefixCls = (0, _utils.usePrefixCls)('', {
|
81
87
|
prefix: 'teamix-pro-form'
|
82
88
|
});
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
89
|
+
|
90
|
+
var mergedScope = _objectSpread(_objectSpread(_objectSpread({}, globalScope), scope), {}, {
|
91
|
+
context: context
|
92
|
+
}); // context需要实名不能解构
|
93
|
+
|
94
|
+
|
95
|
+
var mergedComponents = _objectSpread(_objectSpread({}, globalComponents), components);
|
96
|
+
|
88
97
|
var onAutoSubmit = (0, _useAutoSubmit.default)(onSubmit); // todo 需要formily支持断点下的属性更新
|
89
98
|
|
90
99
|
var getTeamixLayout = (0, _react.useMemo)(function () {
|
@@ -141,12 +150,13 @@ var ProForm = /*#__PURE__*/(0, _react.memo)(function (_ref) {
|
|
141
150
|
}), /*#__PURE__*/_react.default.createElement(_SchemaForm.default, {
|
142
151
|
schema: schema,
|
143
152
|
scope: mergedScope,
|
144
|
-
components:
|
153
|
+
components: mergedComponents
|
145
154
|
}), children);
|
146
155
|
});
|
147
156
|
ProForm.defaultProps = {
|
148
157
|
colon: false,
|
149
|
-
labelAlign: 'left'
|
158
|
+
labelAlign: 'left',
|
159
|
+
validateFirst: true
|
150
160
|
};
|
151
161
|
var _default = ProForm;
|
152
162
|
exports.default = _default;
|