@teamix/pro 1.2.27 → 1.2.31
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 +250 -202
- package/dist/pro.min.css +1 -1
- package/dist/pro.min.js +1 -1
- package/es/actions/index.d.ts +2 -3
- package/es/actions/index.js +15 -19
- package/es/form/Filter/SimpleFilter.js +10 -3
- package/es/form/typing.d.ts +1 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/info/components/baseInfo/index.js +2 -1
- package/es/table/components/Filter/index.js +6 -6
- package/es/table/components/Layout/index.js +18 -3
- package/es/table/index.js +92 -29
- package/es/table/index.scss +4 -0
- package/es/table/typing.d.ts +2 -2
- package/es/table/utils/columnRender.js +1 -1
- package/es/table/utils/index.d.ts +2 -1
- package/es/table/utils/index.js +62 -113
- package/lib/actions/index.d.ts +2 -3
- package/lib/actions/index.js +15 -19
- package/lib/form/Filter/SimpleFilter.js +8 -1
- package/lib/form/typing.d.ts +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/info/components/baseInfo/index.js +2 -1
- package/lib/table/components/Filter/index.js +6 -6
- package/lib/table/components/Layout/index.js +18 -3
- package/lib/table/index.js +91 -28
- package/lib/table/index.scss +4 -0
- package/lib/table/typing.d.ts +2 -2
- package/lib/table/utils/columnRender.js +1 -1
- package/lib/table/utils/index.d.ts +2 -1
- package/lib/table/utils/index.js +63 -112
- package/package.json +1 -1
- package/es/form/Components/SelectTable/index.d.ts +0 -24
- package/es/form/Components/SelectTable/index.js +0 -135
- package/es/form/Components/SelectTable/index.scss +0 -28
- package/es/form/Components/SelectTable/table.d.ts +0 -6
- package/es/form/Components/SelectTable/table.js +0 -64
- package/lib/form/Components/SelectTable/index.d.ts +0 -24
- package/lib/form/Components/SelectTable/index.js +0 -157
- package/lib/form/Components/SelectTable/index.scss +0 -28
- package/lib/form/Components/SelectTable/table.d.ts +0 -6
- package/lib/form/Components/SelectTable/table.js +0 -76
package/lib/table/index.js
CHANGED
@@ -165,7 +165,7 @@ var globalFormatSort = function globalFormatSort(sort) {
|
|
165
165
|
};
|
166
166
|
|
167
167
|
var ProTable = function ProTable(props) {
|
168
|
-
var _rowSelection$selecte;
|
168
|
+
var _rowSelection$selecte, _dataFilterForm4;
|
169
169
|
|
170
170
|
var header = props.header,
|
171
171
|
className = props.className,
|
@@ -281,7 +281,24 @@ var ProTable = function ProTable(props) {
|
|
281
281
|
var _useState19 = (0, _react.useState)(true),
|
282
282
|
_useState20 = _slicedToArray(_useState19, 2),
|
283
283
|
showLoading = _useState20[0],
|
284
|
-
setShowLoading = _useState20[1]; //
|
284
|
+
setShowLoading = _useState20[1]; // 存储能够被 on 监听到的 ProTable 状态
|
285
|
+
// 因为只做存储用。不需要更新视图以及需要同步更改。所以不使用 setState 更新
|
286
|
+
|
287
|
+
|
288
|
+
var _useState21 = (0, _react.useState)({
|
289
|
+
fullScreenState: false,
|
290
|
+
filterRules: {},
|
291
|
+
filterColumns: []
|
292
|
+
}),
|
293
|
+
_useState22 = _slicedToArray(_useState21, 1),
|
294
|
+
actionRefState = _useState22[0]; // 存储 on 监听事件
|
295
|
+
|
296
|
+
|
297
|
+
var _useState23 = (0, _react.useState)({
|
298
|
+
fullScreenState: {}
|
299
|
+
}),
|
300
|
+
_useState24 = _slicedToArray(_useState23, 1),
|
301
|
+
actionRefCallback = _useState24[0]; // 存储定时器 id
|
285
302
|
|
286
303
|
|
287
304
|
var autoRefreshTimerRef = (0, _react.useRef)(); // 获取header高度,用作全屏吸底吸底高度计算
|
@@ -305,16 +322,16 @@ var ProTable = function ProTable(props) {
|
|
305
322
|
}; // header 区域高度。用作全屏计算吸顶吸底高度。默认不做计算
|
306
323
|
|
307
324
|
|
308
|
-
var
|
309
|
-
|
310
|
-
headerHeight =
|
311
|
-
setHeaderHeight =
|
325
|
+
var _useState25 = (0, _react.useState)(0),
|
326
|
+
_useState26 = _slicedToArray(_useState25, 2),
|
327
|
+
headerHeight = _useState26[0],
|
328
|
+
setHeaderHeight = _useState26[1]; // 全屏显示 className
|
312
329
|
|
313
330
|
|
314
|
-
var
|
315
|
-
|
316
|
-
fullscreenState =
|
317
|
-
setFullscreenState =
|
331
|
+
var _useState27 = (0, _react.useState)(false),
|
332
|
+
_useState28 = _slicedToArray(_useState27, 2),
|
333
|
+
fullscreenState = _useState28[0],
|
334
|
+
setFullscreenState = _useState28[1]; // 非全屏状态下的
|
318
335
|
|
319
336
|
|
320
337
|
var normalDataFilterFormRef = (0, _react.useRef)();
|
@@ -322,13 +339,13 @@ var ProTable = function ProTable(props) {
|
|
322
339
|
var normalDataFilterForm = normalDataFilterFormRef.current;
|
323
340
|
var fullscreenDataFilterForm = fullscreenDataFilterFormRef.current; // 传给 QueryFilter 的 formRef
|
324
341
|
|
325
|
-
var dataFilterFormRef = fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
|
342
|
+
var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
|
326
343
|
var dataFilterForm = dataFilterFormRef.current; // 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
|
327
344
|
|
328
|
-
var
|
329
|
-
|
330
|
-
footerSuctionState =
|
331
|
-
setFooterSuctionState =
|
345
|
+
var _useState29 = (0, _react.useState)(false),
|
346
|
+
_useState30 = _slicedToArray(_useState29, 2),
|
347
|
+
footerSuctionState = _useState30[0],
|
348
|
+
setFooterSuctionState = _useState30[1]; // TODO 获取内容区是否超出一屏(暂时仅支持全家桶)
|
332
349
|
|
333
350
|
|
334
351
|
var getFooterSuctionState = function getFooterSuctionState() {
|
@@ -451,7 +468,42 @@ var ProTable = function ProTable(props) {
|
|
451
468
|
if (propsDataSource) {
|
452
469
|
setData(propsDataSource);
|
453
470
|
}
|
454
|
-
}, [propsDataSource]); //
|
471
|
+
}, [propsDataSource]); // 初始化 ActionRef。
|
472
|
+
|
473
|
+
(0, _utils2.initActionRef)(actionRef, {
|
474
|
+
getState: function getState() {
|
475
|
+
return actionRefState;
|
476
|
+
},
|
477
|
+
getCallback: function getCallback() {
|
478
|
+
return actionRefCallback;
|
479
|
+
},
|
480
|
+
setState: function setState(key, value) {
|
481
|
+
actionRefState[key] = value;
|
482
|
+
(0, _utils2.actionRefUseStateOn)(actionRefCallback, key, value);
|
483
|
+
},
|
484
|
+
on: function on(fun, state, name) {
|
485
|
+
if (!actionRefCallback[state]) {
|
486
|
+
actionRefCallback[state] = {};
|
487
|
+
}
|
488
|
+
|
489
|
+
actionRefCallback[state][name] = fun;
|
490
|
+
},
|
491
|
+
off: function off(name) {
|
492
|
+
actionRefCallback = Object.fromEntries(Object.entries(actionRefCallback).map(function (_ref) {
|
493
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
494
|
+
k = _ref2[0],
|
495
|
+
v = _ref2[1];
|
496
|
+
|
497
|
+
var filterV = Object.fromEntries(Object.entries(v).filter(function (_ref3) {
|
498
|
+
var _ref4 = _slicedToArray(_ref3, 1),
|
499
|
+
k = _ref4[0];
|
500
|
+
|
501
|
+
return k !== name;
|
502
|
+
}));
|
503
|
+
return [k, filterV];
|
504
|
+
}));
|
505
|
+
}
|
506
|
+
}); // 绑定 Actions
|
455
507
|
|
456
508
|
(0, _utils2.useActionType)(actionRef, {
|
457
509
|
fullScreen: function fullScreen() {
|
@@ -494,12 +546,12 @@ var ProTable = function ProTable(props) {
|
|
494
546
|
_request(params);
|
495
547
|
},
|
496
548
|
reset: function reset() {
|
497
|
-
var _actionRef$current3, _actionRef$current3$s;
|
549
|
+
var _actionRef$current3, _actionRef$current3$s, _dataFilterForm;
|
498
550
|
|
499
551
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset()); // 清空列过滤参数
|
500
552
|
|
501
553
|
(_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setFilterRules) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, {});
|
502
|
-
dataFilterForm === null ||
|
554
|
+
(_dataFilterForm = dataFilterForm) === null || _dataFilterForm === void 0 ? void 0 : _dataFilterForm.reset();
|
503
555
|
setCurrentPage(1);
|
504
556
|
|
505
557
|
_request(_defineProperty({}, targetPageKey, 1));
|
@@ -613,7 +665,7 @@ var ProTable = function ProTable(props) {
|
|
613
665
|
}); // 请求函数
|
614
666
|
|
615
667
|
function _request(params, noLoading) {
|
616
|
-
var _actionRef$current$ge, _actionRef$current4, _actionRef$current4$g, _objectSpread2;
|
668
|
+
var _dataFilterForm2, _actionRef$current$ge, _actionRef$current4, _actionRef$current4$g, _objectSpread2;
|
617
669
|
|
618
670
|
// 如果没有传 url 且没有 customRequest,直接返回
|
619
671
|
if (!url && !customRequest) {
|
@@ -626,7 +678,7 @@ var ProTable = function ProTable(props) {
|
|
626
678
|
|
627
679
|
var sortParams = targetFormatSort(sort); // 筛选区请求参数
|
628
680
|
|
629
|
-
var dataFilterParams = toJS(dataFilterForm === null ||
|
681
|
+
var dataFilterParams = toJS((_dataFilterForm2 = dataFilterForm) === null || _dataFilterForm2 === void 0 ? void 0 : _dataFilterForm2.values); // 列过滤请求参数
|
630
682
|
|
631
683
|
var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$g = _actionRef$current4.getFilterRules) === null || _actionRef$current4$g === void 0 ? void 0 : _actionRef$current4$g.call(_actionRef$current4)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
|
632
684
|
|
@@ -677,8 +729,7 @@ var ProTable = function ProTable(props) {
|
|
677
729
|
}
|
678
730
|
|
679
731
|
(0, _react.useEffect)(function () {
|
680
|
-
|
681
|
-
(0, _utils2.initActionRef)(); // 监听 浏览器变化 更吸底状态
|
732
|
+
dataFilterForm = dataFilterFormRef.current; // 监听 浏览器变化 更吸底状态
|
682
733
|
|
683
734
|
if (footerSuction) {
|
684
735
|
getFooterSuctionState();
|
@@ -688,11 +739,21 @@ var ProTable = function ProTable(props) {
|
|
688
739
|
};
|
689
740
|
}
|
690
741
|
|
691
|
-
if (
|
692
|
-
|
693
|
-
|
742
|
+
if (propsDataFilter) {
|
743
|
+
var _dataFilterForm3;
|
744
|
+
|
745
|
+
if (requestWhenMount && ((_dataFilterForm3 = dataFilterForm) === null || _dataFilterForm3 === void 0 ? void 0 : _dataFilterForm3.id)) {
|
746
|
+
// 在请求发送之前 处理漏斗默认数据
|
747
|
+
(0, _utils2.processDefaultFilter)(propsColumns, actionRef, defaultFilterParams);
|
694
748
|
|
695
|
-
|
749
|
+
_request();
|
750
|
+
}
|
751
|
+
} else {
|
752
|
+
if (requestWhenMount) {
|
753
|
+
(0, _utils2.processDefaultFilter)(propsColumns, actionRef, defaultFilterParams);
|
754
|
+
|
755
|
+
_request();
|
756
|
+
}
|
696
757
|
}
|
697
758
|
|
698
759
|
return function () {
|
@@ -706,7 +767,7 @@ var ProTable = function ProTable(props) {
|
|
706
767
|
|
707
768
|
actionRef.current = undefined;
|
708
769
|
};
|
709
|
-
}, []);
|
770
|
+
}, [(_dataFilterForm4 = dataFilterForm) === null || _dataFilterForm4 === void 0 ? void 0 : _dataFilterForm4.id]);
|
710
771
|
|
711
772
|
function onSort(dataIndex, order) {
|
712
773
|
var nextSort = _defineProperty({}, dataIndex, order);
|
@@ -731,8 +792,10 @@ var ProTable = function ProTable(props) {
|
|
731
792
|
_request(_defineProperty({}, targetPageKey, 1));
|
732
793
|
},
|
733
794
|
onReset: function onReset() {
|
795
|
+
var _dataFilterForm5;
|
796
|
+
|
734
797
|
(propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset());
|
735
|
-
dataFilterForm === null ||
|
798
|
+
(_dataFilterForm5 = dataFilterForm) === null || _dataFilterForm5 === void 0 ? void 0 : _dataFilterForm5.reset();
|
736
799
|
setCurrentPage(1);
|
737
800
|
|
738
801
|
_request(_defineProperty({}, targetPageKey, 1));
|
package/lib/table/index.scss
CHANGED
package/lib/table/typing.d.ts
CHANGED
@@ -201,8 +201,6 @@ export declare type ProTableActionTypeMutations = {
|
|
201
201
|
getState?: () => ProTableActionTypeState;
|
202
202
|
/** 设置state 状态 */
|
203
203
|
setState?: (key: string, value: any) => void;
|
204
|
-
/** 初始化 state 状态 */
|
205
|
-
initState?: () => void;
|
206
204
|
/** 设置全屏状态 */
|
207
205
|
setFullScreenState?: (state: boolean) => void;
|
208
206
|
/** 绑定state监听事件 */
|
@@ -217,6 +215,8 @@ export declare type ProTableActionTypeMutations = {
|
|
217
215
|
resetTableMaxBodyHeight?: () => void;
|
218
216
|
/** 列筛选规则 */
|
219
217
|
filterColumns?: any[];
|
218
|
+
/** 获取所有 on 监听事件 */
|
219
|
+
getCallback?: () => any;
|
220
220
|
};
|
221
221
|
/** action Mutations 定义 */
|
222
222
|
export declare type ProTableActionTypeState = {
|
@@ -157,7 +157,7 @@ var renderCell = function renderCell(value, item, index, record, actionRef) {
|
|
157
157
|
|
158
158
|
if (valueType === 'selectGroup') {
|
159
159
|
newRender = _objectSpread(_objectSpread({
|
160
|
-
maxShowNumber:
|
160
|
+
maxShowNumber: 'auto',
|
161
161
|
foldText: 'more',
|
162
162
|
editOnClick: function editOnClick() {},
|
163
163
|
edit: true
|
@@ -1,13 +1,14 @@
|
|
1
1
|
/// <reference types="react" />
|
2
2
|
import { ProTableActionType } from '../typing';
|
3
3
|
import { ProTableProps, ProTableColumnProps } from '..';
|
4
|
-
export declare function
|
4
|
+
export declare function actionRefUseStateOn(callback: any, state: string, ...args: any): void;
|
5
5
|
/** table 组件内监听 不对外暴露 */
|
6
6
|
export declare function on(fun: any, key: string): void;
|
7
7
|
/** table 组件内销毁监听 不对外暴露 */
|
8
8
|
export declare function off(key: string): void;
|
9
9
|
/** table 组件内触发事件 不对外暴露 */
|
10
10
|
export declare function emit(key: string, ...args: any): void;
|
11
|
+
export declare function initActionRef(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
|
11
12
|
export declare function useActionType<T>(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
|
12
13
|
export declare function cloneDeep<T>(obj: T): T;
|
13
14
|
/**
|
package/lib/table/utils/index.js
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
+
exports.actionRefUseStateOn = actionRefUseStateOn;
|
6
7
|
exports.cloneDeep = cloneDeep;
|
7
8
|
exports.emit = emit;
|
8
9
|
exports.initActionRef = initActionRef;
|
@@ -33,128 +34,75 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
|
|
33
34
|
|
34
35
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
35
36
|
|
36
|
-
//
|
37
|
-
var
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
},
|
83
|
-
|
84
|
-
/**
|
85
|
-
* 获取筛选规则。为params
|
86
|
-
*/
|
87
|
-
getFilterRules: function getFilterRules() {
|
88
|
-
var result = {};
|
89
|
-
|
90
|
-
if (state.filterRules) {
|
91
|
-
result = Object.entries(state.filterRules).map(function (_ref) {
|
92
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
93
|
-
k = _ref2[0],
|
94
|
-
v = _ref2[1];
|
95
|
-
|
96
|
-
return _defineProperty({}, k, v.params);
|
97
|
-
}).reduce(function (acc, cur) {
|
98
|
-
acc = _objectSpread(_objectSpread({}, acc), cur);
|
99
|
-
return acc;
|
100
|
-
}, {});
|
101
|
-
}
|
37
|
+
// 所有 ProTable 组件公用一套组件内事件转发机制
|
38
|
+
var tableCallback = {}; // 组件内对全局状态的更改
|
39
|
+
|
40
|
+
var getMutations = function getMutations(actionRef) {
|
41
|
+
var _actionRef$current2, _actionRef$current2$g, _actionRef$current2$g2;
|
42
|
+
|
43
|
+
return {
|
44
|
+
setFullScreenState: function setFullScreenState(fullScreenState) {
|
45
|
+
var _actionRef$current, _actionRef$current$se;
|
46
|
+
|
47
|
+
(_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$se = _actionRef$current.setState) === null || _actionRef$current$se === void 0 ? void 0 : _actionRef$current$se.call(_actionRef$current, 'fullScreenState', fullScreenState);
|
48
|
+
},
|
49
|
+
filterColumns: (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$g = _actionRef$current2.getState) === null || _actionRef$current2$g === void 0 ? void 0 : (_actionRef$current2$g2 = _actionRef$current2$g.call(_actionRef$current2)) === null || _actionRef$current2$g2 === void 0 ? void 0 : _actionRef$current2$g2.filterColumns,
|
50
|
+
|
51
|
+
/**
|
52
|
+
* 设置筛选列规则
|
53
|
+
* @param rules 规则
|
54
|
+
* @param dataIndex column.dataIndex
|
55
|
+
*/
|
56
|
+
setFilterRules: function setFilterRules(rules) {
|
57
|
+
var _actionRef$current3, _actionRef$current3$s;
|
58
|
+
|
59
|
+
(_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setState) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, 'filterRules', rules);
|
60
|
+
},
|
61
|
+
|
62
|
+
/**
|
63
|
+
* 获取筛选规则。为params
|
64
|
+
*/
|
65
|
+
getFilterRules: function getFilterRules() {
|
66
|
+
var _actionRef$current4, _actionRef$current4$g;
|
67
|
+
|
68
|
+
var result = {};
|
69
|
+
var filterRules = (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$g = _actionRef$current4.getState) === null || _actionRef$current4$g === void 0 ? void 0 : _actionRef$current4$g.call(_actionRef$current4).filterRules;
|
70
|
+
|
71
|
+
if (filterRules) {
|
72
|
+
result = Object.entries(filterRules).map(function (_ref) {
|
73
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
74
|
+
k = _ref2[0],
|
75
|
+
v = _ref2[1];
|
76
|
+
|
77
|
+
return _defineProperty({}, k, v.params);
|
78
|
+
}).reduce(function (acc, cur) {
|
79
|
+
acc = _objectSpread(_objectSpread({}, acc), cur);
|
80
|
+
return acc;
|
81
|
+
}, {});
|
82
|
+
}
|
102
83
|
|
103
|
-
|
104
|
-
},
|
105
|
-
|
106
|
-
/**
|
107
|
-
* 绑定监听函数
|
108
|
-
* @param fun 监听函数
|
109
|
-
* @param state 需要监听的state
|
110
|
-
* @param name 监听名(作为销毁唯一id使用)
|
111
|
-
*/
|
112
|
-
on: function on(fun, state, name) {
|
113
|
-
if (!callback[state]) {
|
114
|
-
callback[state] = {};
|
84
|
+
return result;
|
115
85
|
}
|
116
|
-
|
117
|
-
callback[state][name] = fun;
|
118
|
-
},
|
119
|
-
off: function off(name) {
|
120
|
-
callback = Object.fromEntries(Object.entries(callback).map(function (_ref4) {
|
121
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
122
|
-
k = _ref5[0],
|
123
|
-
v = _ref5[1];
|
124
|
-
|
125
|
-
var filterV = Object.fromEntries(Object.entries(v).filter(function (_ref6) {
|
126
|
-
var _ref7 = _slicedToArray(_ref6, 1),
|
127
|
-
k = _ref7[0];
|
128
|
-
|
129
|
-
return k !== name;
|
130
|
-
}));
|
131
|
-
return [k, filterV];
|
132
|
-
}));
|
133
|
-
}
|
86
|
+
};
|
134
87
|
}; // 调用绑定的监听函数
|
135
88
|
|
136
|
-
|
137
|
-
|
138
|
-
|
89
|
+
|
90
|
+
function actionRefUseStateOn(callback, state) {
|
91
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
92
|
+
args[_key - 2] = arguments[_key];
|
139
93
|
}
|
140
94
|
|
141
95
|
if (callback[state]) {
|
142
|
-
Object.entries(callback[state]).forEach(function (
|
143
|
-
var
|
144
|
-
k =
|
145
|
-
v =
|
96
|
+
Object.entries(callback[state]).forEach(function (_ref4) {
|
97
|
+
var _ref5 = _slicedToArray(_ref4, 2),
|
98
|
+
k = _ref5[0],
|
99
|
+
v = _ref5[1];
|
146
100
|
|
147
101
|
if (v) {
|
148
102
|
v === null || v === void 0 ? void 0 : v.apply(void 0, args);
|
149
103
|
}
|
150
104
|
});
|
151
105
|
}
|
152
|
-
}; // 初始化 actionRef
|
153
|
-
|
154
|
-
|
155
|
-
function initActionRef() {
|
156
|
-
state = (0, _lodash.default)(_initState);
|
157
|
-
callback = (0, _lodash.default)(initCallback);
|
158
106
|
}
|
159
107
|
/** table 组件内监听 不对外暴露 */
|
160
108
|
|
@@ -185,13 +133,16 @@ function emit(key) {
|
|
185
133
|
}
|
186
134
|
}
|
187
135
|
|
188
|
-
function
|
189
|
-
|
190
|
-
var userAction = _objectSpread(_objectSpread({}, action), mutations);
|
136
|
+
function initActionRef(ref, action) {
|
137
|
+
var userAction = _objectSpread(_objectSpread({}, action), getMutations(ref));
|
191
138
|
|
192
139
|
ref.current = userAction;
|
193
140
|
}
|
194
141
|
|
142
|
+
function useActionType(ref, action) {
|
143
|
+
ref.current = _objectSpread(_objectSpread({}, ref.current), action);
|
144
|
+
}
|
145
|
+
|
195
146
|
function cloneDeep(obj) {
|
196
147
|
return (0, _lodash.default)(obj);
|
197
148
|
}
|
package/package.json
CHANGED
@@ -1,24 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import { TableProps, ColumnProps } from '@alifd/next/types/table';
|
3
|
-
import './index.scss';
|
4
|
-
declare type ISelectTableFilterOption = boolean | ((optipn: any, kewword: string) => boolean);
|
5
|
-
declare type ISelectTableFilterSort = (optionA: any, optionB: any) => number;
|
6
|
-
export interface ISelectTableColumnProps extends ColumnProps {
|
7
|
-
key: React.ReactText;
|
8
|
-
}
|
9
|
-
export interface ISelectTableProps extends TableProps {
|
10
|
-
mode?: 'multiple' | 'single';
|
11
|
-
dataSource?: any[];
|
12
|
-
optionAsValue?: boolean;
|
13
|
-
showSearch?: boolean;
|
14
|
-
filterOption?: ISelectTableFilterOption;
|
15
|
-
filterSort?: ISelectTableFilterSort;
|
16
|
-
onSearch?: (kekword: string) => void;
|
17
|
-
onChange?: (value: any) => void;
|
18
|
-
value?: any;
|
19
|
-
}
|
20
|
-
declare type ComposedSelectTable = React.FC<ISelectTableProps> & {
|
21
|
-
TableColumn?: React.FC<ISelectTableColumnProps>;
|
22
|
-
};
|
23
|
-
declare const SelectTable: ComposedSelectTable;
|
24
|
-
export default SelectTable;
|
@@ -1,135 +0,0 @@
|
|
1
|
-
var _excluded = ["mode", "dataSource", "optionAsValue", "showSearch", "filterOption", "filterSort", "onSearch", "className", "value", "onChange", "rowSelection"];
|
2
|
-
|
3
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
4
|
-
|
5
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
6
|
-
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
8
|
-
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
10
|
-
|
11
|
-
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
12
|
-
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
14
|
-
|
15
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
16
|
-
|
17
|
-
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; }
|
18
|
-
|
19
|
-
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; }
|
20
|
-
|
21
|
-
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; }
|
22
|
-
|
23
|
-
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
24
|
-
|
25
|
-
import React, { useEffect, useState } from 'react';
|
26
|
-
import { Table, Search } from '@alicloudfe/components';
|
27
|
-
import { observer, useFieldSchema } from '@formily/react';
|
28
|
-
import cls from 'classnames';
|
29
|
-
import { isArr } from '@formily/shared';
|
30
|
-
import { usePrefixCls } from '@teamix/utils';
|
31
|
-
import './index.scss';
|
32
|
-
|
33
|
-
var useColumns = function useColumns() {
|
34
|
-
var schema = useFieldSchema();
|
35
|
-
var columns = [];
|
36
|
-
schema.mapProperties(function (schema, name) {
|
37
|
-
var _schema$xComponent;
|
38
|
-
|
39
|
-
if (((_schema$xComponent = schema['x-component']) === null || _schema$xComponent === void 0 ? void 0 : _schema$xComponent.indexOf('Column')) > -1) {
|
40
|
-
var props = schema === null || schema === void 0 ? void 0 : schema['x-component-props'];
|
41
|
-
columns.push({
|
42
|
-
name: name,
|
43
|
-
props: _objectSpread(_objectSpread({}, props), {}, {
|
44
|
-
title: (props === null || props === void 0 ? void 0 : props.title) || (schema === null || schema === void 0 ? void 0 : schema.title),
|
45
|
-
dataIndex: (props === null || props === void 0 ? void 0 : props.dataIndex) || name
|
46
|
-
}),
|
47
|
-
schema: schema
|
48
|
-
});
|
49
|
-
}
|
50
|
-
});
|
51
|
-
return columns;
|
52
|
-
};
|
53
|
-
|
54
|
-
var SelectTable = observer(function (props) {
|
55
|
-
var mode = props.mode,
|
56
|
-
dataSource = props.dataSource,
|
57
|
-
optionAsValue = props.optionAsValue,
|
58
|
-
showSearch = props.showSearch,
|
59
|
-
filterOption = props.filterOption,
|
60
|
-
filterSort = props.filterSort,
|
61
|
-
onSearch = props.onSearch,
|
62
|
-
className = props.className,
|
63
|
-
value = props.value,
|
64
|
-
onChange = props.onChange,
|
65
|
-
rowSelection = props.rowSelection,
|
66
|
-
otherTableProps = _objectWithoutProperties(props, _excluded);
|
67
|
-
|
68
|
-
var prefixCls = usePrefixCls('formily-selectTable', props);
|
69
|
-
|
70
|
-
var _useState = useState(),
|
71
|
-
_useState2 = _slicedToArray(_useState, 2),
|
72
|
-
selected = _useState2[0],
|
73
|
-
setSelected = _useState2[1];
|
74
|
-
|
75
|
-
var tabs = useColumns();
|
76
|
-
|
77
|
-
var expandedRowRender = function expandedRowRender(record, index) {
|
78
|
-
var children = isArr(record.children) ? record.children : [];
|
79
|
-
return /*#__PURE__*/React.createElement(Table, {
|
80
|
-
dataSource: children,
|
81
|
-
key: index
|
82
|
-
}, tabs.map(function (_ref, key) {
|
83
|
-
var props = _ref.props;
|
84
|
-
return /*#__PURE__*/React.createElement(Table.Column, _objectSpread({
|
85
|
-
key: key
|
86
|
-
}, props));
|
87
|
-
}));
|
88
|
-
};
|
89
|
-
|
90
|
-
var onInnerChange = function onInnerChange(selectedRowKeys, records) {
|
91
|
-
var outputValue = optionAsValue ? records : selectedRowKeys;
|
92
|
-
outputValue = mode === 'single' ? outputValue[0] : outputValue;
|
93
|
-
onChange && onChange(outputValue);
|
94
|
-
};
|
95
|
-
|
96
|
-
useEffect(function () {
|
97
|
-
var primaryKey = props.primaryKey;
|
98
|
-
var inputValue = mode === 'single' ? [value] : isArr(value) ? value : [];
|
99
|
-
inputValue = optionAsValue ? inputValue.map(function (v) {
|
100
|
-
return v === null || v === void 0 ? void 0 : v[primaryKey];
|
101
|
-
}) : inputValue;
|
102
|
-
setSelected(inputValue);
|
103
|
-
}, [value, mode]);
|
104
|
-
return /*#__PURE__*/React.createElement("div", {
|
105
|
-
className: cls(prefixCls, props.className)
|
106
|
-
}, showSearch ? /*#__PURE__*/React.createElement(Search, {
|
107
|
-
className: "".concat(prefixCls, "-search"),
|
108
|
-
onSearch: console.log
|
109
|
-
}) : null, /*#__PURE__*/React.createElement(Table, _objectSpread({
|
110
|
-
className: "".concat(prefixCls, "-table"),
|
111
|
-
dataSource: dataSource,
|
112
|
-
rowSelection: _objectSpread(_objectSpread({}, rowSelection), {}, {
|
113
|
-
mode: mode,
|
114
|
-
onChange: onInnerChange,
|
115
|
-
selectedRowKeys: selected
|
116
|
-
})
|
117
|
-
}, otherTableProps), tabs.map(function (_ref2, key) {
|
118
|
-
var props = _ref2.props;
|
119
|
-
return /*#__PURE__*/React.createElement(Table.Column, _objectSpread({
|
120
|
-
key: key
|
121
|
-
}, props));
|
122
|
-
})));
|
123
|
-
});
|
124
|
-
|
125
|
-
var TableColumn = function TableColumn(_ref3) {
|
126
|
-
var children = _ref3.children;
|
127
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
128
|
-
};
|
129
|
-
|
130
|
-
SelectTable.TableColumn = TableColumn;
|
131
|
-
SelectTable.defaultProps = {
|
132
|
-
showSearch: false,
|
133
|
-
primaryKey: 'key'
|
134
|
-
};
|
135
|
-
export default SelectTable;
|