@teamix/pro 1.2.20 → 1.2.24
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 +2138 -568
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/dialog.js +13 -23
- package/es/actions/index.d.ts +10 -0
- package/es/actions/index.js +11 -16
- package/es/form/Components/LightFilter/componentMap.js +2 -1
- package/es/form/Components/LightFilter/index.js +15 -3
- package/es/form/Components/SelectTable/index.d.ts +24 -0
- package/es/form/Components/SelectTable/index.js +135 -0
- package/es/form/Components/SelectTable/index.scss +28 -0
- package/es/form/Components/SelectTable/table.d.ts +6 -0
- package/es/form/Components/SelectTable/table.js +64 -0
- package/es/form/Filter/AdvancedFilter.js +1 -0
- package/es/form/Filter/index2.js +8 -8
- package/es/form/ProForm/index.js +5 -4
- package/es/form/ProForm/index.scss +37 -6
- package/es/form/ProForm/useFormDisplayValues.js +4 -2
- package/es/form/SchemaForm/index.js +16 -10
- package/es/form/SchemaForm/initializeDataSource.d.ts +2 -2
- package/es/form/SchemaForm/initializeDataSource.js +4 -9
- package/es/form/SchemaForm/initializeRequest.d.ts +2 -2
- package/es/form/SchemaForm/initializeRequest.js +4 -10
- package/es/form/SchemaForm/initializeRules.d.ts +7 -1
- package/es/form/SchemaForm/initializeRules.js +9 -13
- package/es/form/SchemaForm/reactions.d.ts +5 -5
- package/es/form/SchemaForm/reactions.js +27 -29
- package/es/form/global.scss +1 -0
- package/es/form/typing.d.ts +10 -1
- package/es/form/utils.d.ts +8 -7
- package/es/form/utils.js +5 -4
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/table/components/Filter/index.js +1 -0
- package/es/table/components/Layout/index.js +22 -12
- package/es/table/components/Pagination/index.d.ts +5 -1
- package/es/table/components/Pagination/index.js +179 -17
- package/es/table/components/Pagination/index.scss +55 -0
- package/es/table/components/ToolBar/FilterColumnIcon.js +24 -3
- package/es/table/components/ToolBar/index.scss +9 -4
- package/es/table/index.js +79 -26
- package/es/table/index.scss +5 -5
- package/es/table/typing.d.ts +9 -9
- package/es/table/utils/columnRender.js +2 -1
- package/es/table/utils/index.d.ts +7 -0
- package/es/table/utils/index.js +38 -4
- package/lib/actions/dialog.js +12 -22
- package/lib/actions/index.d.ts +10 -0
- package/lib/actions/index.js +11 -16
- package/lib/form/Components/LightFilter/componentMap.js +2 -1
- package/lib/form/Components/LightFilter/index.js +14 -3
- package/lib/form/Components/SelectTable/index.d.ts +24 -0
- package/lib/form/Components/SelectTable/index.js +157 -0
- package/lib/form/Components/SelectTable/index.scss +28 -0
- package/lib/form/Components/SelectTable/table.d.ts +6 -0
- package/lib/form/Components/SelectTable/table.js +76 -0
- package/lib/form/Filter/AdvancedFilter.js +1 -0
- package/lib/form/Filter/index2.js +9 -8
- package/lib/form/ProForm/index.js +5 -5
- package/lib/form/ProForm/index.scss +37 -6
- package/lib/form/ProForm/useFormDisplayValues.js +3 -1
- package/lib/form/SchemaForm/index.js +16 -9
- package/lib/form/SchemaForm/initializeDataSource.d.ts +2 -2
- package/lib/form/SchemaForm/initializeDataSource.js +4 -11
- package/lib/form/SchemaForm/initializeRequest.d.ts +2 -2
- package/lib/form/SchemaForm/initializeRequest.js +4 -11
- package/lib/form/SchemaForm/initializeRules.d.ts +7 -1
- package/lib/form/SchemaForm/initializeRules.js +9 -16
- package/lib/form/SchemaForm/reactions.d.ts +5 -5
- package/lib/form/SchemaForm/reactions.js +29 -31
- package/lib/form/global.scss +1 -0
- package/lib/form/typing.d.ts +10 -1
- package/lib/form/utils.d.ts +8 -7
- package/lib/form/utils.js +6 -5
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/table/components/Layout/index.js +21 -11
- package/lib/table/components/Pagination/index.d.ts +5 -1
- package/lib/table/components/Pagination/index.js +186 -17
- package/lib/table/components/Pagination/index.scss +55 -0
- package/lib/table/components/ToolBar/FilterColumnIcon.js +23 -2
- package/lib/table/components/ToolBar/index.scss +9 -4
- package/lib/table/index.js +79 -24
- package/lib/table/index.scss +5 -5
- package/lib/table/typing.d.ts +9 -9
- package/lib/table/utils/columnRender.js +2 -1
- package/lib/table/utils/index.d.ts +7 -0
- package/lib/table/utils/index.js +46 -4
- package/package.json +1 -1
package/lib/table/index.js
CHANGED
@@ -10,6 +10,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
|
11
11
|
var _components = require("@alicloudfe/components");
|
12
12
|
|
13
|
+
var _Pagination = _interopRequireDefault(require("./components/Pagination"));
|
14
|
+
|
13
15
|
var _genProColumnToColumn = _interopRequireDefault(require("./utils/genProColumnToColumn"));
|
14
16
|
|
15
17
|
var _utils = require("@teamix/utils");
|
@@ -55,7 +57,7 @@ Object.keys(_typing).forEach(function (key) {
|
|
55
57
|
}
|
56
58
|
});
|
57
59
|
});
|
58
|
-
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType"];
|
60
|
+
var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType"];
|
59
61
|
|
60
62
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
61
63
|
|
@@ -109,6 +111,8 @@ var processColumns = function processColumns(columns, initialColumns) {
|
|
109
111
|
}); // 处理只剩一列批量选择的情况下宽度错乱问题
|
110
112
|
|
111
113
|
if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
|
114
|
+
var _initialColumns$;
|
115
|
+
|
112
116
|
if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
|
113
117
|
var _filterColumns$, _filterColumns$2;
|
114
118
|
|
@@ -119,14 +123,14 @@ var processColumns = function processColumns(columns, initialColumns) {
|
|
119
123
|
if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
|
120
124
|
filterColumns[0].lock = false;
|
121
125
|
}
|
122
|
-
} else {
|
123
|
-
var _initialColumns
|
126
|
+
} else if (((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.columnFilters) !== false) {
|
127
|
+
var _initialColumns$2, _initialColumns$3;
|
124
128
|
|
125
|
-
if ((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns
|
129
|
+
if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.width) {
|
126
130
|
filterColumns[0].width = initialColumns[0].width;
|
127
131
|
}
|
128
132
|
|
129
|
-
if ((_initialColumns$
|
133
|
+
if ((_initialColumns$3 = initialColumns[0]) === null || _initialColumns$3 === void 0 ? void 0 : _initialColumns$3.lock) {
|
130
134
|
filterColumns[0].lock = initialColumns[0].lock;
|
131
135
|
}
|
132
136
|
}
|
@@ -187,6 +191,7 @@ var ProTable = function ProTable(props) {
|
|
187
191
|
showPagination = _props$showPagination === void 0 ? true : _props$showPagination,
|
188
192
|
_props$pageSizeList = props.pageSizeList,
|
189
193
|
pageSizeList = _props$pageSizeList === void 0 ? [5, 10, 20, 50, 100] : _props$pageSizeList,
|
194
|
+
responsivePaginationType = props.responsivePaginationType,
|
190
195
|
_props$showSkeleton = props.showSkeleton,
|
191
196
|
propsShowSkeleton = _props$showSkeleton === void 0 ? true : _props$showSkeleton,
|
192
197
|
_props$skeletonSize = props.skeletonSize,
|
@@ -247,8 +252,10 @@ var ProTable = function ProTable(props) {
|
|
247
252
|
var _useState13 = (0, _react.useState)(true),
|
248
253
|
_useState14 = _slicedToArray(_useState13, 2),
|
249
254
|
customTableLoading = _useState14[0],
|
250
|
-
setCustomTableLoading = _useState14[1];
|
255
|
+
setCustomTableLoading = _useState14[1]; // 用于存放 Search 组件之前值的 ref
|
256
|
+
|
251
257
|
|
258
|
+
var searchValueRef = (0, _react.useRef)('');
|
252
259
|
var tableRef = (0, _react.useRef)(null);
|
253
260
|
var actionRef = (0, _react.useRef)(); // 传给 table 的过滤后的 columns
|
254
261
|
|
@@ -447,9 +454,14 @@ var ProTable = function ProTable(props) {
|
|
447
454
|
setColumn: function setColumn(newColumns) {
|
448
455
|
var _actionRef$current2, _actionRef$current2$s;
|
449
456
|
|
457
|
+
var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
450
458
|
var columns = processColumns(newColumns, propsColumns);
|
451
459
|
setFilteredColumns(columns);
|
452
460
|
(_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$s = _actionRef$current2.setState) === null || _actionRef$current2$s === void 0 ? void 0 : _actionRef$current2$s.call(_actionRef$current2, 'filterColumns', columns);
|
461
|
+
|
462
|
+
if (update) {
|
463
|
+
(0, _utils2.emit)('refreshFilterState', newColumns);
|
464
|
+
}
|
453
465
|
},
|
454
466
|
setSize: function setSize(mode) {
|
455
467
|
_setSize(mode);
|
@@ -653,10 +665,8 @@ var ProTable = function ProTable(props) {
|
|
653
665
|
}
|
654
666
|
|
655
667
|
(0, _react.useEffect)(function () {
|
656
|
-
|
657
|
-
|
658
|
-
// 初始化 state 状态
|
659
|
-
actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$i = _actionRef$current5.initState) === null || _actionRef$current5$i === void 0 ? void 0 : _actionRef$current5$i.call(_actionRef$current5); // 监听 浏览器变化 更吸底状态
|
668
|
+
// 初始化 actionRef state、callback 此时 actionRef 已初始化完成
|
669
|
+
(0, _utils2.initActionRef)(); // 监听 浏览器变化 更吸底状态
|
660
670
|
|
661
671
|
if (footerSuction) {
|
662
672
|
getFooterSuctionState();
|
@@ -670,6 +680,14 @@ var ProTable = function ProTable(props) {
|
|
670
680
|
_request();
|
671
681
|
}
|
672
682
|
|
683
|
+
var searchName = getSearchName();
|
684
|
+
|
685
|
+
if (searchName) {
|
686
|
+
// 如果有初始值,需要赋值
|
687
|
+
var initialValues = toJS(dataFilterForm.initialValues);
|
688
|
+
searchValueRef.current = initialValues[searchName][1];
|
689
|
+
}
|
690
|
+
|
673
691
|
return function () {
|
674
692
|
if (autoRefreshTimerRef.current) {
|
675
693
|
clearTimeout(autoRefreshTimerRef.current);
|
@@ -689,18 +707,54 @@ var ProTable = function ProTable(props) {
|
|
689
707
|
setSort(nextSort);
|
690
708
|
|
691
709
|
_request(targetFormatSort(nextSort));
|
692
|
-
} //
|
710
|
+
} // 找到 Search 组件对应的 name
|
693
711
|
|
694
712
|
|
695
|
-
var
|
696
|
-
|
697
|
-
|
713
|
+
var getSearchName = function getSearchName() {
|
714
|
+
var _dataFilter$schema;
|
715
|
+
|
716
|
+
if ((dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.schema) && ((_dataFilter$schema = dataFilter.schema) === null || _dataFilter$schema === void 0 ? void 0 : _dataFilter$schema.length) > 0) {
|
717
|
+
var searchSchema = dataFilter.schema.find(function (item) {
|
718
|
+
return item.component === 'Search';
|
719
|
+
});
|
720
|
+
|
721
|
+
if (searchSchema) {
|
722
|
+
var searchName = searchSchema.name;
|
723
|
+
return searchName;
|
724
|
+
}
|
725
|
+
}
|
726
|
+
}; // 处理 dataFilter 中的 onFilter、onReset
|
727
|
+
|
728
|
+
|
729
|
+
var dataFilter = _objectSpread(_objectSpread({
|
730
|
+
mode: 'inline'
|
731
|
+
}, propsDataFilter), {}, {
|
732
|
+
onFilter: (0, _lodash.default)(function (values) {
|
733
|
+
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values));
|
698
734
|
|
699
735
|
if (dataFilterForm.validate()) {
|
700
|
-
var _actionRef$
|
736
|
+
var _actionRef$current5, _actionRef$current5$c;
|
737
|
+
|
738
|
+
/**
|
739
|
+
* 针对 inline 模式下的 Search 组件做特殊处理
|
740
|
+
* 当切换条件且输入内容为空的时候,类似[a, ''] => [b, ''] 不触发请求
|
741
|
+
*/
|
742
|
+
if (dataFilter.mode === 'inline') {
|
743
|
+
var searchName = getSearchName();
|
744
|
+
|
745
|
+
if (searchName) {
|
746
|
+
var searchValue = values[searchName][1];
|
701
747
|
|
702
|
-
|
703
|
-
|
748
|
+
if (searchValue === (searchValueRef === null || searchValueRef === void 0 ? void 0 : searchValueRef.current)) {
|
749
|
+
return;
|
750
|
+
}
|
751
|
+
|
752
|
+
searchValueRef.current = searchValue;
|
753
|
+
}
|
754
|
+
} // 搜索变化时,暂时先清空选择
|
755
|
+
|
756
|
+
|
757
|
+
(_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$c = _actionRef$current5.clearRowSelection) === null || _actionRef$current5$c === void 0 ? void 0 : _actionRef$current5$c.call(_actionRef$current5);
|
704
758
|
setCurrentPage(1);
|
705
759
|
|
706
760
|
_request(_defineProperty({}, targetPageKey, 1));
|
@@ -795,21 +849,21 @@ var ProTable = function ProTable(props) {
|
|
795
849
|
|
796
850
|
var renderFooter = function renderFooter() {
|
797
851
|
function onChangePagination(currentPage) {
|
798
|
-
var _actionRef$
|
852
|
+
var _actionRef$current6, _actionRef$current6$c;
|
799
853
|
|
800
854
|
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
801
855
|
// 翻页暂时先清空选择
|
802
|
-
(_actionRef$
|
856
|
+
(_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
|
803
857
|
setCurrentPage(currentPage);
|
804
858
|
|
805
859
|
_request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
|
806
860
|
}
|
807
861
|
|
808
862
|
function onChangePaginationSize(currentPageSize) {
|
809
|
-
var _actionRef$
|
863
|
+
var _actionRef$current7, _actionRef$current7$c, _request5;
|
810
864
|
|
811
865
|
// 翻页暂时先清空选择
|
812
|
-
(_actionRef$
|
866
|
+
(_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
|
813
867
|
setPageSize(currentPageSize);
|
814
868
|
setCurrentPage(1);
|
815
869
|
|
@@ -843,14 +897,15 @@ var ProTable = function ProTable(props) {
|
|
843
897
|
})
|
844
898
|
}, renderRowSelection(), /*#__PURE__*/_react.default.createElement("div", {
|
845
899
|
className: cls('footer-right-wrapper')
|
846
|
-
}, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : /*#__PURE__*/_react.default.createElement(
|
900
|
+
}, showSkeleton ? /*#__PURE__*/_react.default.createElement(_skeleton.ProSkeletonRaw.Footer.Pagination, null) : /*#__PURE__*/_react.default.createElement(_Pagination.default, _objectSpread({
|
847
901
|
className: cls('pagination'),
|
848
902
|
onChange: function onChange(number) {
|
849
903
|
return onChangePagination(number);
|
850
904
|
},
|
851
905
|
total: total,
|
852
|
-
|
853
|
-
|
906
|
+
responsivePaginationType: responsivePaginationType,
|
907
|
+
// shape="arrow-only"
|
908
|
+
// pageSizePosition="end"
|
854
909
|
totalRender: function totalRender(total) {
|
855
910
|
return (0, _utils.getMessage)('total', {
|
856
911
|
total: total
|
package/lib/table/index.scss
CHANGED
@@ -40,11 +40,6 @@ $fullscreenPadding: 24px;
|
|
40
40
|
justify-content: flex-end;
|
41
41
|
width: 100%;
|
42
42
|
}
|
43
|
-
.pagination-wrapper {
|
44
|
-
display: flex;
|
45
|
-
justify-content: flex-end;
|
46
|
-
width: 100%;
|
47
|
-
}
|
48
43
|
&-footer-action {
|
49
44
|
margin-left: 16px;
|
50
45
|
}
|
@@ -114,4 +109,9 @@ $fullscreenPadding: 24px;
|
|
114
109
|
|
115
110
|
.next-table-empty {
|
116
111
|
--table-empty-padding: 48px;
|
112
|
+
}
|
113
|
+
|
114
|
+
// 后面在基础组件里面覆盖
|
115
|
+
.next-table.next-table td .next-table-cell-wrapper {
|
116
|
+
text-overflow: unset;
|
117
117
|
}
|
package/lib/table/typing.d.ts
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
*/
|
4
4
|
import { ColumnProps, TableProps } from '@alicloudfe/components/types/table';
|
5
5
|
import { ProFieldType, ProFieldRenderProps, ProFieldDataSourceItem } from '../field';
|
6
|
-
import {
|
6
|
+
import { QueryFilterProps } from '../form';
|
7
7
|
import { ProActionGroupProps, ProActionButtonProps } from '../actions';
|
8
8
|
import { PaginationProps } from '@alicloudfe/components/types/pagination';
|
9
9
|
import { HeaderProps as ProTableHeaderProps } from '@teamix/utils';
|
@@ -12,7 +12,7 @@ import React from 'react';
|
|
12
12
|
import type { Form as FormType } from '@formily/core';
|
13
13
|
declare type IFieldRenderProps = keyof ProFieldRenderProps;
|
14
14
|
/** 列record函数 */
|
15
|
-
declare type ProTableCellFunProp = (value: any, index: number, record: any) => any;
|
15
|
+
declare type ProTableCellFunProp = (value: any, index: number, record: any, ...others: any) => any;
|
16
16
|
declare type ITableCellRender = {
|
17
17
|
[key in IFieldRenderProps]?: ProFieldRenderProps[key] | ProTableCellFunProp;
|
18
18
|
} | ((...other: any) => React.ReactNode);
|
@@ -22,6 +22,7 @@ declare type TDataService = {
|
|
22
22
|
/** 表格数据 */
|
23
23
|
data?: any;
|
24
24
|
};
|
25
|
+
export declare type responsivePaginationType = 'mini' | 'small' | 'simple' | 'normal';
|
25
26
|
export declare type ProTableColumnProps = {
|
26
27
|
/**
|
27
28
|
* 会在 title 之后展示一个 icon,hover 之后提示一些信息
|
@@ -92,6 +93,8 @@ export declare type ProTableProps = {
|
|
92
93
|
paginationProps?: PaginationProps;
|
93
94
|
/** 是否显示翻页器 */
|
94
95
|
showPagination?: boolean;
|
96
|
+
/** 手动指定响应式翻页器的 type */
|
97
|
+
responsivePaginationType?: responsivePaginationType;
|
95
98
|
/** 是否使用内置的 rowSelection */
|
96
99
|
useRowSelection?: boolean;
|
97
100
|
/** 内置 rowSelection 变化时的回调 */
|
@@ -146,7 +149,7 @@ export declare type ProTableActionType = {
|
|
146
149
|
/** 全屏展示 */
|
147
150
|
fullScreen?: () => boolean;
|
148
151
|
/** 设置显示列 */
|
149
|
-
setColumn?: (newColumns: ProColumnProps[]) => void;
|
152
|
+
setColumn?: (newColumns: ProColumnProps[], update?: boolean) => void;
|
150
153
|
/** 设置表格大小 */
|
151
154
|
setSize?: (mode: 'small' | 'medium') => void;
|
152
155
|
/** 刷新表格 */
|
@@ -212,15 +215,12 @@ export declare type ProTableActionTypeState = {
|
|
212
215
|
[key: string]: any;
|
213
216
|
};
|
214
217
|
export declare type ProTableDataFilterProps = {
|
215
|
-
/** 展示形式 */
|
216
|
-
mode?: 'inline' | 'panel';
|
217
|
-
/** mode='panel' 时是否默认展开 */
|
218
|
-
expand?: boolean;
|
219
|
-
/** 搜索时是否传入值为undefined的参数,默认不传 */
|
220
218
|
searchUndefined?: boolean;
|
221
219
|
/** 搜索时是否传入值为空字符串的参数,默认不传 */
|
222
220
|
searchEmptyString?: boolean;
|
223
|
-
|
221
|
+
/** 自定义内容 */
|
222
|
+
content?: React.ReactNode;
|
223
|
+
} & QueryFilterProps;
|
224
224
|
export declare type dataFilterProps = ProTableDataFilterProps;
|
225
225
|
export declare type ProTableTopAreaProps = {
|
226
226
|
/** 标题区 */
|
@@ -220,7 +220,8 @@ var processRenderFunction = function processRenderFunction() {
|
|
220
220
|
var value = arguments.length > 1 ? arguments[1] : undefined;
|
221
221
|
var index = arguments.length > 2 ? arguments[2] : undefined;
|
222
222
|
var record = arguments.length > 3 ? arguments[3] : undefined;
|
223
|
-
|
223
|
+
// 当 ProField render 类型为 function 时。需要表格预先处理以塞入 record
|
224
|
+
var external = ['linkOnClick', 'link', 'value', 'renderEdit', 'descriptionRenderEdit', 'editPopConfirmProps', 'descriptionEditPopConfirmProps', 'editOnClick', 'descriptionEditOnClick'];
|
224
225
|
return Object.fromEntries(Object.entries(render).map(function (_ref3) {
|
225
226
|
var _ref4 = _slicedToArray(_ref3, 2),
|
226
227
|
k = _ref4[0],
|
@@ -1,4 +1,11 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { ProTableActionType } from '../typing';
|
3
|
+
export declare function initActionRef(): void;
|
4
|
+
/** table 组件内监听 不对外暴露 */
|
5
|
+
export declare function on(fun: any, key: string): void;
|
6
|
+
/** table 组件内销毁监听 不对外暴露 */
|
7
|
+
export declare function off(key: string): void;
|
8
|
+
/** table 组件内触发事件 不对外暴露 */
|
9
|
+
export declare function emit(key: string, ...args: any): void;
|
3
10
|
export declare function useActionType<T>(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
|
4
11
|
export declare function cloneDeep<T>(obj: T): T;
|
package/lib/table/utils/index.js
CHANGED
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
5
5
|
});
|
6
6
|
exports.cloneDeep = cloneDeep;
|
7
|
+
exports.emit = emit;
|
8
|
+
exports.initActionRef = initActionRef;
|
9
|
+
exports.off = off;
|
10
|
+
exports.on = on;
|
7
11
|
exports.useActionType = useActionType;
|
8
12
|
|
9
13
|
var _lodash = _interopRequireDefault(require("lodash.clonedeep"));
|
@@ -28,19 +32,23 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
28
32
|
|
29
33
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
30
34
|
|
31
|
-
// 组件内全局状态
|
35
|
+
// 组件内全局状态 每次初始化 ActionRef 会重新深拷贝对象
|
32
36
|
var state = {
|
33
37
|
fullScreenState: false,
|
34
38
|
filterRules: {},
|
35
39
|
filterColumns: []
|
36
40
|
};
|
37
41
|
|
38
|
-
var _initState = (0, _lodash.default)(state); //
|
42
|
+
var _initState = (0, _lodash.default)(state); // state监听事件 每次初始化 ActionRef 会重新深拷贝对象
|
39
43
|
|
40
44
|
|
41
45
|
var callback = {
|
42
46
|
fullScreenState: {}
|
43
|
-
};
|
47
|
+
};
|
48
|
+
var initCallback = (0, _lodash.default)(callback); // 所有 ProTable 组件公用一套组件内事件转发机制
|
49
|
+
|
50
|
+
var tableCallback = {}; // 组件内监听事件
|
51
|
+
// 组件内对全局状态的更改
|
44
52
|
|
45
53
|
var mutations = {
|
46
54
|
getState: function getState() {
|
@@ -140,7 +148,41 @@ var useOn = function useOn(state) {
|
|
140
148
|
}
|
141
149
|
});
|
142
150
|
}
|
143
|
-
};
|
151
|
+
}; // 初始化 actionRef
|
152
|
+
|
153
|
+
|
154
|
+
function initActionRef() {
|
155
|
+
state = (0, _lodash.default)(_initState);
|
156
|
+
callback = (0, _lodash.default)(initCallback);
|
157
|
+
}
|
158
|
+
/** table 组件内监听 不对外暴露 */
|
159
|
+
|
160
|
+
|
161
|
+
function on(fun, key) {
|
162
|
+
tableCallback[key] = fun;
|
163
|
+
}
|
164
|
+
/** table 组件内销毁监听 不对外暴露 */
|
165
|
+
|
166
|
+
|
167
|
+
function off(key) {
|
168
|
+
if (tableCallback[key]) {
|
169
|
+
delete tableCallback[key];
|
170
|
+
}
|
171
|
+
}
|
172
|
+
/** table 组件内触发事件 不对外暴露 */
|
173
|
+
|
174
|
+
|
175
|
+
function emit(key) {
|
176
|
+
var fun = tableCallback[key];
|
177
|
+
|
178
|
+
if (fun) {
|
179
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
180
|
+
args[_key2 - 1] = arguments[_key2];
|
181
|
+
}
|
182
|
+
|
183
|
+
fun.apply(void 0, args);
|
184
|
+
}
|
185
|
+
}
|
144
186
|
|
145
187
|
function useActionType(ref, action) {
|
146
188
|
// 合并自定义事件
|