@teamix/pro 1.5.33-beta-2 → 1.5.33-beta-4
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/es/form/Components/FormItem2/index.js +0 -1
- package/es/form/Components/SelectTable2/index.d.ts +97 -0
- package/es/form/Components/SelectTable2/index.js +39 -0
- package/es/form/ProForm/index.js +3 -1
- package/es/form/SchemaForm/adapterDecorator.js +1 -1
- package/es/form/SchemaForm/adapterType.js +2 -1
- package/es/index.d.ts +1 -1
- package/es/index.js +1 -1
- package/es/table/components/Cell/index.js +7 -1
- package/es/table/index.js +26 -4
- package/es/table/typing.d.ts +7 -2
- package/es/table/utils/genAutoWidthColumns.d.ts +2 -2
- package/es/table/utils/genAutoWidthColumns.js +25 -12
- package/es/table/utils/useTableSelection.js +54 -5
- package/lib/form/Components/FormItem2/index.js +0 -1
- package/lib/form/Components/SelectTable2/index.d.ts +97 -0
- package/lib/form/Components/SelectTable2/index.js +47 -0
- package/lib/form/ProForm/index.js +3 -1
- package/lib/form/SchemaForm/adapterDecorator.js +1 -1
- package/lib/form/SchemaForm/adapterType.js +2 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +1 -1
- package/lib/table/components/Cell/index.js +7 -1
- package/lib/table/index.js +26 -4
- package/lib/table/typing.d.ts +7 -2
- package/lib/table/utils/genAutoWidthColumns.d.ts +2 -2
- package/lib/table/utils/genAutoWidthColumns.js +25 -12
- package/lib/table/utils/useTableSelection.js +57 -5
- package/package.json +1 -1
- package/dist/fonts/txddinmedium.woff +0 -0
- package/dist/pro.all.min.css +0 -1
- package/dist/pro.css +0 -1
- package/dist/pro.js +0 -124262
- package/dist/pro.min.css +0 -1
- package/dist/pro.min.js +0 -2
- package/dist/pro.min.js.LICENSE.txt +0 -56
- package/dist/pro.xconsole.min.css +0 -1
|
@@ -78,7 +78,6 @@ var ICON_MAP = {
|
|
|
78
78
|
};
|
|
79
79
|
export var BaseItem = function BaseItem(props) {
|
|
80
80
|
var _cls, _cls3, _cls4, _cls5, _cls6;
|
|
81
|
-
console.log('FormItem2');
|
|
82
81
|
var children = props.children,
|
|
83
82
|
others = _objectWithoutProperties(props, _excluded);
|
|
84
83
|
var _useState3 = useState(false),
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const SelectTable2: React.ForwardRefExoticComponent<Partial<{
|
|
3
|
+
field: any;
|
|
4
|
+
} & {
|
|
5
|
+
autoWidth?: boolean | undefined;
|
|
6
|
+
columns: import("../../../table").ProTableColumnProps[];
|
|
7
|
+
url?: string | undefined;
|
|
8
|
+
method?: import("axios").Method | undefined;
|
|
9
|
+
params?: {
|
|
10
|
+
[propName: string]: any;
|
|
11
|
+
} | undefined;
|
|
12
|
+
formatSort?: ((sort: object) => object) | undefined;
|
|
13
|
+
formatParams?: string | ((params: any) => any) | undefined;
|
|
14
|
+
formatResult?: string | {
|
|
15
|
+
total?: string | number | undefined;
|
|
16
|
+
data?: any;
|
|
17
|
+
} | ((res: any) => {
|
|
18
|
+
total?: string | number | undefined;
|
|
19
|
+
data?: any;
|
|
20
|
+
}) | undefined;
|
|
21
|
+
onFormatResult?: ((data: any[]) => void) | undefined;
|
|
22
|
+
requestWhenMount?: boolean | undefined;
|
|
23
|
+
onSuccess?: ((res: any) => void) | undefined;
|
|
24
|
+
onError?: ((error: Error) => void) | undefined;
|
|
25
|
+
requestConfig?: import("axios").AxiosRequestConfig | undefined;
|
|
26
|
+
pageKey?: string | undefined;
|
|
27
|
+
pageSizeKey?: string | undefined;
|
|
28
|
+
pageSize?: number | undefined;
|
|
29
|
+
pageSizeList?: any[] | undefined;
|
|
30
|
+
paginationProps?: import("@alifd/next/types/pagination").PaginationProps | undefined;
|
|
31
|
+
showPagination?: boolean | undefined;
|
|
32
|
+
responsivePaginationType?: import("../../../table").responsivePaginationType | undefined;
|
|
33
|
+
useRowSelection?: boolean | undefined;
|
|
34
|
+
onChangeRowSelection?: ((selectedRowKeys: string[]) => void) | undefined;
|
|
35
|
+
getRowSelection?: ((rowSelection: import("../../../table").innerRowSelectionType) => void) | undefined;
|
|
36
|
+
footerAction?: React.ReactNode | import("../../..").ProActionGroupProps;
|
|
37
|
+
footer?: React.ReactNode;
|
|
38
|
+
filterDebounce?: number | undefined;
|
|
39
|
+
actionRef?: React.MutableRefObject<import("../../../table").ProTableActionType | undefined> | undefined;
|
|
40
|
+
showSkeleton?: boolean | undefined;
|
|
41
|
+
skeletonSize?: number | undefined;
|
|
42
|
+
tableClassName?: string | undefined;
|
|
43
|
+
footerSuction?: boolean | Element | undefined;
|
|
44
|
+
autoRefresh?: boolean | ((dataSource: any[]) => number | boolean) | undefined;
|
|
45
|
+
autoRefreshProps?: {
|
|
46
|
+
dataSource?: {
|
|
47
|
+
label?: React.ReactNode;
|
|
48
|
+
value?: number | undefined;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
customRequest?: ((params: any) => Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
data: any[];
|
|
54
|
+
total?: number | undefined;
|
|
55
|
+
}>) | undefined;
|
|
56
|
+
reserveSelectedRecords?: boolean | undefined;
|
|
57
|
+
defaultFilterParams?: {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
} | undefined;
|
|
60
|
+
disableSelectAll?: boolean | undefined;
|
|
61
|
+
context?: any;
|
|
62
|
+
fixedTableBody?: boolean | undefined;
|
|
63
|
+
'data-teamix-spm'?: string | undefined;
|
|
64
|
+
switchCardView?: boolean | undefined;
|
|
65
|
+
cardViewProps?: import("../../../table").ProTableCardProps | undefined;
|
|
66
|
+
defaultView?: "table" | "card" | undefined;
|
|
67
|
+
emptyProps?: import("@teamix/pro-field").EmptyContentProps | undefined;
|
|
68
|
+
bindUrl?: boolean | undefined;
|
|
69
|
+
bindUrlProps?: import("../../../table").ProTableBindUrlProps | undefined;
|
|
70
|
+
autoRedirect?: boolean | undefined;
|
|
71
|
+
useMaxData?: boolean | undefined;
|
|
72
|
+
rowSelection?: ({
|
|
73
|
+
getProps?: ((record: any, index: number) => any) | undefined;
|
|
74
|
+
onChange?: ((selectedRowKeys: any[], records: any[]) => void) | undefined;
|
|
75
|
+
onSelect?: ((selected: boolean, record: any, records: any[]) => void) | undefined;
|
|
76
|
+
onSelectAll?: ((selected: boolean, records: any[]) => void) | undefined;
|
|
77
|
+
selectedRowKeys?: any[] | undefined;
|
|
78
|
+
selectedRecords?: any[] | undefined;
|
|
79
|
+
mode?: "multiple" | "single" | undefined;
|
|
80
|
+
titleProps?: (() => any) | undefined;
|
|
81
|
+
columnProps?: (() => any) | undefined;
|
|
82
|
+
titleAddons?: (() => any) | undefined;
|
|
83
|
+
defaultSelectedRowKeys?: any[] | undefined;
|
|
84
|
+
defaultSelectedRecords?: any[] | undefined;
|
|
85
|
+
} & {
|
|
86
|
+
getProps?: ((record: any, index: number) => void) | undefined;
|
|
87
|
+
onChange?: ((selectedRowKeys: any[], records: any[]) => void) | undefined;
|
|
88
|
+
onSelect?: ((selected: boolean, record: any, records: any[]) => void) | undefined;
|
|
89
|
+
onSelectAll?: ((selected: boolean, records: any[]) => void) | undefined;
|
|
90
|
+
selectedRowKeys?: any[] | undefined;
|
|
91
|
+
mode?: "multiple" | "single" | undefined;
|
|
92
|
+
titleProps?: (() => any) | undefined;
|
|
93
|
+
columnProps?: (() => any) | undefined;
|
|
94
|
+
titleAddons?: (() => any) | undefined;
|
|
95
|
+
}) | undefined;
|
|
96
|
+
} & Omit<import("@alifd/next/types/table").TableProps, "rowSelection" | "columns"> & import("../../../table").ProTableTopAreaProps> & React.RefAttributes<unknown>>;
|
|
97
|
+
export default SelectTable2;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var _excluded = ["columns", "field"];
|
|
2
|
+
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; }
|
|
3
|
+
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; }
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { connect, mapProps, observer } from '@formily/react';
|
|
9
|
+
import ProTable from '../../../table';
|
|
10
|
+
var Component = observer(function (props) {
|
|
11
|
+
var _props$columns = props.columns,
|
|
12
|
+
columns = _props$columns === void 0 ? [] : _props$columns,
|
|
13
|
+
field = props.field,
|
|
14
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
15
|
+
var onChange = function onChange(value) {
|
|
16
|
+
field.setValue(value);
|
|
17
|
+
};
|
|
18
|
+
return /*#__PURE__*/React.createElement(ProTable, _objectSpread({
|
|
19
|
+
toolBar: false,
|
|
20
|
+
showPagination: false,
|
|
21
|
+
columns: columns,
|
|
22
|
+
useRowSelection: true,
|
|
23
|
+
rowSelection: {
|
|
24
|
+
defaultSelectedRowKeys: field.value
|
|
25
|
+
},
|
|
26
|
+
onChangeRowSelection: onChange,
|
|
27
|
+
loading: field.loading,
|
|
28
|
+
showSkeleton: false,
|
|
29
|
+
dataSource: field.dataSource
|
|
30
|
+
}, others));
|
|
31
|
+
});
|
|
32
|
+
var SelectTable2 = connect(Component, mapProps(function (props, field) {
|
|
33
|
+
var dataSource = field.dataSource;
|
|
34
|
+
return _objectSpread(_objectSpread({}, props), {}, {
|
|
35
|
+
dataSource: dataSource,
|
|
36
|
+
field: field
|
|
37
|
+
});
|
|
38
|
+
}));
|
|
39
|
+
export default SelectTable2;
|
package/es/form/ProForm/index.js
CHANGED
|
@@ -23,6 +23,7 @@ import useInitialRequest from './useInitialRequest';
|
|
|
23
23
|
import validateLocale from '../locales/validate';
|
|
24
24
|
import './index.scss';
|
|
25
25
|
import FormItem2 from '../Components/FormItem2';
|
|
26
|
+
import SelectTable2 from '../Components/SelectTable2';
|
|
26
27
|
registerValidateLocale(validateLocale);
|
|
27
28
|
var formilyComponents = {
|
|
28
29
|
FormLayout: FormLayout,
|
|
@@ -51,7 +52,8 @@ var formilyComponents = {
|
|
|
51
52
|
Affix: Affix,
|
|
52
53
|
LightFilter: LightFilter,
|
|
53
54
|
Text: Text,
|
|
54
|
-
FormItem2: FormItem2
|
|
55
|
+
FormItem2: FormItem2,
|
|
56
|
+
SelectTable2: SelectTable2
|
|
55
57
|
};
|
|
56
58
|
var ProForm = /*#__PURE__*/memo(function (_ref) {
|
|
57
59
|
var outerForm = _ref.form,
|
|
@@ -13,7 +13,7 @@ export default (function (decorator, component) {
|
|
|
13
13
|
if (decorator !== undefined) {
|
|
14
14
|
return decorator;
|
|
15
15
|
}
|
|
16
|
-
if ([].concat(_toConsumableArray(Object.keys(fieldTypeMap)), ['Upload', 'SelectTable', 'ArrayCards', 'ArrayCollapse', 'ArrayTable', 'ArrayItems']).includes(component)) {
|
|
16
|
+
if ([].concat(_toConsumableArray(Object.keys(fieldTypeMap)), ['Upload', 'SelectTable', 'SelectTable2', 'ArrayCards', 'ArrayCollapse', 'ArrayTable', 'ArrayItems']).includes(component)) {
|
|
17
17
|
return 'FormItem';
|
|
18
18
|
}
|
|
19
19
|
return decorator;
|
|
@@ -48,7 +48,8 @@ var typeMap = (_typeMap = {
|
|
|
48
48
|
Range: 'string',
|
|
49
49
|
Search: 'array',
|
|
50
50
|
SelectGroup: 'array',
|
|
51
|
-
SelectTable: 'array'
|
|
51
|
+
SelectTable: 'array',
|
|
52
|
+
SelectTable2: 'array'
|
|
52
53
|
}, _defineProperty(_typeMap, 'SelectTable.Column', 'string'), _defineProperty(_typeMap, "ArrayCollapse", 'array'), _defineProperty(_typeMap, "ArrayCards", 'array'), _defineProperty(_typeMap, "ArrayTable", 'array'), _defineProperty(_typeMap, "ArrayItems", 'array'), _defineProperty(_typeMap, 'Editable.Popover', 'object'), _defineProperty(_typeMap, 'Editable.Dialog', 'object'), _defineProperty(_typeMap, 'Editable.Drawer', 'object'), _typeMap);
|
|
53
54
|
export default (function (type, component) {
|
|
54
55
|
return type || typeMap[component] || 'void';
|
package/es/index.d.ts
CHANGED
|
@@ -30,5 +30,5 @@ export * from './sidebar';
|
|
|
30
30
|
export * from './utils';
|
|
31
31
|
export * from './timeline';
|
|
32
32
|
export * from './image';
|
|
33
|
-
declare const version = "1.5.33-beta";
|
|
33
|
+
declare const version = "1.5.33-beta-4";
|
|
34
34
|
export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, ProImage, hooks, nocode, templates, utils, };
|
package/es/index.js
CHANGED
|
@@ -124,7 +124,9 @@ var Cell = function Cell(props) {
|
|
|
124
124
|
value: value,
|
|
125
125
|
render: newRender,
|
|
126
126
|
dataSource: newDataSource,
|
|
127
|
-
format: format
|
|
127
|
+
format: format,
|
|
128
|
+
// 预留 context 位置
|
|
129
|
+
context: context
|
|
128
130
|
}, itemProps));
|
|
129
131
|
};
|
|
130
132
|
/**
|
|
@@ -189,6 +191,10 @@ var processBuriedPoint = function processBuriedPoint() {
|
|
|
189
191
|
var equalColumns = function equalColumns(prevProps, nextProps) {
|
|
190
192
|
var preValue = prevProps.value;
|
|
191
193
|
var nextValue = nextProps.value;
|
|
194
|
+
// 操作列的时候强制刷新
|
|
195
|
+
if (preValue === false && nextValue === false) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
192
198
|
if (preValue === nextValue) {
|
|
193
199
|
return true;
|
|
194
200
|
}
|
package/es/table/index.js
CHANGED
|
@@ -420,7 +420,9 @@ var ProTable = function ProTable(props) {
|
|
|
420
420
|
if (showSkeleton && result) {
|
|
421
421
|
result.disabled = true;
|
|
422
422
|
}
|
|
423
|
-
return
|
|
423
|
+
return _objectSpread({
|
|
424
|
+
_primaryKey: props.primaryKey
|
|
425
|
+
}, result);
|
|
424
426
|
},
|
|
425
427
|
titleProps: function titleProps() {
|
|
426
428
|
var result = {};
|
|
@@ -490,11 +492,22 @@ var ProTable = function ProTable(props) {
|
|
|
490
492
|
var columns = processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : [], propsColumns);
|
|
491
493
|
setFilteredColumns(columns);
|
|
492
494
|
(_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, 'filterColumns', columns);
|
|
495
|
+
if (autoWidth) {
|
|
496
|
+
reGenFilteredColumnsByAutoWidth(columns);
|
|
497
|
+
}
|
|
493
498
|
}, [propsColumns]);
|
|
494
499
|
// dataSource 受控
|
|
495
500
|
useEffect(function () {
|
|
496
501
|
if (propsDataSource) {
|
|
497
502
|
_setData(propsDataSource);
|
|
503
|
+
if (autoWidth) {
|
|
504
|
+
shadowContainer({
|
|
505
|
+
columns: filteredColumns,
|
|
506
|
+
data: propsDataSource,
|
|
507
|
+
shadowContainerRef: shadowContainerRef
|
|
508
|
+
});
|
|
509
|
+
reGenFilteredColumnsByAutoWidth();
|
|
510
|
+
}
|
|
498
511
|
}
|
|
499
512
|
}, [propsDataSource]);
|
|
500
513
|
// 初始化 ActionRef。
|
|
@@ -914,7 +927,7 @@ var ProTable = function ProTable(props) {
|
|
|
914
927
|
getData.run(requestData);
|
|
915
928
|
}
|
|
916
929
|
}
|
|
917
|
-
}, [bindUrl, bindUrlProps, dataRef, url, customRequest]);
|
|
930
|
+
}, [bindUrl, bindUrlProps, dataRef, url, customRequest, currentPage, pageSize, propsParams]);
|
|
918
931
|
var onSort = useCallback(function (dataIndex, order) {
|
|
919
932
|
var nextSort = _defineProperty({}, dataIndex, order);
|
|
920
933
|
setSort(nextSort);
|
|
@@ -967,6 +980,11 @@ var ProTable = function ProTable(props) {
|
|
|
967
980
|
return showLoading && !showSkeleton && (customTableLoading || props.loading);
|
|
968
981
|
}
|
|
969
982
|
}, [customRequest, showLoading, showSkeleton, customTableLoading, props.loading, getData]);
|
|
983
|
+
useEffect(function () {
|
|
984
|
+
if (autoWidth) {
|
|
985
|
+
reGenFilteredColumnsByAutoWidth();
|
|
986
|
+
}
|
|
987
|
+
}, [shadowContainerRef === null || shadowContainerRef === void 0 ? void 0 : shadowContainerRef.current]);
|
|
970
988
|
var memorizedGenProColumnToColumn = useMemo(function () {
|
|
971
989
|
var result = genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm, bindUrl, bindUrlProps);
|
|
972
990
|
return result;
|
|
@@ -997,7 +1015,11 @@ var ProTable = function ProTable(props) {
|
|
|
997
1015
|
autoRefreshProps: autoRefreshProps,
|
|
998
1016
|
bindUrlProps: bindUrlProps,
|
|
999
1017
|
bindUrl: bindUrl
|
|
1000
|
-
}),
|
|
1018
|
+
}), autoWidth && shadowContainer({
|
|
1019
|
+
columns: filteredColumns,
|
|
1020
|
+
data: data,
|
|
1021
|
+
shadowContainerRef: shadowContainerRef
|
|
1022
|
+
}), hasActionColumn && shadowActionColumnContainer(filteredColumns, shadowActionColumnContainerRef), switchViewState === 'table' && /*#__PURE__*/React.createElement(TableContent, _objectSpread({
|
|
1001
1023
|
hasBorder: false,
|
|
1002
1024
|
dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
|
|
1003
1025
|
columns: memorizedGenProColumnToColumn,
|
|
@@ -1175,7 +1197,7 @@ var ProTable = function ProTable(props) {
|
|
|
1175
1197
|
// 'footer-suction': footerSuctionState && footerSuction,
|
|
1176
1198
|
}),
|
|
1177
1199
|
ref: tableRef
|
|
1178
|
-
},
|
|
1200
|
+
}, autoWidth && shadowContainer({
|
|
1179
1201
|
columns: filteredColumns,
|
|
1180
1202
|
data: data,
|
|
1181
1203
|
shadowContainerRef: shadowContainerRef
|
package/es/table/typing.d.ts
CHANGED
|
@@ -184,7 +184,8 @@ export declare type ProTableProps = {
|
|
|
184
184
|
autoRedirect?: boolean;
|
|
185
185
|
/** 使用超大数据模式 **/
|
|
186
186
|
useMaxData?: boolean;
|
|
187
|
-
|
|
187
|
+
rowSelection?: rowSelectionType;
|
|
188
|
+
} & Omit<TableProps, 'columns' | 'rowSelection'> & ProTableTopAreaProps;
|
|
188
189
|
export declare type rowSelectionType = {
|
|
189
190
|
getProps?: (record: any, index: number) => any;
|
|
190
191
|
onChange?: (selectedRowKeys: Array<any>, records: Array<any>) => void;
|
|
@@ -196,7 +197,11 @@ export declare type rowSelectionType = {
|
|
|
196
197
|
titleProps?: () => any;
|
|
197
198
|
columnProps?: () => any;
|
|
198
199
|
titleAddons?: () => any;
|
|
199
|
-
|
|
200
|
+
/** 默认选中的 Key 值 **/
|
|
201
|
+
defaultSelectedRowKeys?: any[];
|
|
202
|
+
/** 默认选中的 record 值 **/
|
|
203
|
+
defaultSelectedRecords?: any[];
|
|
204
|
+
} & TableProps['rowSelection'];
|
|
200
205
|
export declare type innerRowSelectionType = {
|
|
201
206
|
rowSelection: rowSelectionType;
|
|
202
207
|
selectedRowKeys: string[];
|
|
@@ -6,13 +6,13 @@ import { ProTableColumnProps, ITableCellRender } from '../typing';
|
|
|
6
6
|
* @param data
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
export declare function genAutoWidthColumns(
|
|
9
|
+
export declare function genAutoWidthColumns(columns: ProTableColumnProps[], ref: MutableRefObject<HTMLDivElement | null>, data: any[], size: 'small' | 'medium', useRowSelection?: boolean | undefined, actionColumnRef?: MutableRefObject<HTMLDivElement | null>): ProTableColumnProps[];
|
|
10
10
|
interface IShadowContainerProps {
|
|
11
11
|
columns: ProTableColumnProps[];
|
|
12
12
|
data: any[];
|
|
13
13
|
shadowContainerRef: MutableRefObject<null>;
|
|
14
14
|
}
|
|
15
|
-
export declare const shadowContainer: (props: IShadowContainerProps) => JSX.Element;
|
|
15
|
+
export declare const shadowContainer: (props: IShadowContainerProps) => JSX.Element | null;
|
|
16
16
|
export declare const shadowActionColumnContainer: (columns: ProTableColumnProps[], shadowActionColumnContainerRef: MutableRefObject<null>) => JSX.Element | undefined;
|
|
17
17
|
export declare const computeableWidthTypeList: {
|
|
18
18
|
dateTime: (data: any[], render: ITableCellRender) => any;
|
|
@@ -8,7 +8,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
8
8
|
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; }
|
|
9
9
|
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; }
|
|
10
10
|
import React, { createRef } from 'react';
|
|
11
|
-
import { getTargetValue } from '@teamix/utils';
|
|
11
|
+
import { getTargetValue, _ } from '@teamix/utils';
|
|
12
12
|
import { renderCell } from './pureColumnRender';
|
|
13
13
|
import { renderColumnsTitle } from './columnRender';
|
|
14
14
|
import { ProActionGroup } from '../../actions';
|
|
@@ -26,17 +26,20 @@ var columnShrinkMaxWidth = 100;
|
|
|
26
26
|
* @param data
|
|
27
27
|
* @returns
|
|
28
28
|
*/
|
|
29
|
-
export function genAutoWidthColumns(
|
|
30
|
-
if (!ref.current) {
|
|
31
|
-
return
|
|
29
|
+
export function genAutoWidthColumns(columns, ref, data, size, useRowSelection, actionColumnRef) {
|
|
30
|
+
if (!(ref === null || ref === void 0 ? void 0 : ref.current)) {
|
|
31
|
+
return columns;
|
|
32
32
|
}
|
|
33
33
|
var hasLockFlag = false;
|
|
34
34
|
var dom = ref.current;
|
|
35
35
|
var actionColumnDom = actionColumnRef === null || actionColumnRef === void 0 ? void 0 : actionColumnRef.current;
|
|
36
36
|
var childNodes = dom.children;
|
|
37
|
+
if (dom.children.length === 0) {
|
|
38
|
+
return columns;
|
|
39
|
+
}
|
|
37
40
|
var finalColumns = [];
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
var filterdColumnsResult = _.cloneDeep(columns);
|
|
42
|
+
filterdColumnsResult.forEach(function (column, index) {
|
|
40
43
|
var render = column.render,
|
|
41
44
|
_column$valueType = column.valueType,
|
|
42
45
|
valueType = _column$valueType === void 0 ? 'text' : _column$valueType,
|
|
@@ -97,7 +100,7 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
|
|
|
97
100
|
return;
|
|
98
101
|
}
|
|
99
102
|
// @ts-ignore
|
|
100
|
-
var titleWidth = (
|
|
103
|
+
var titleWidth = _.get(childNodes, '[index]?.children[0].scrollWidth', 0);
|
|
101
104
|
// @ts-ignore
|
|
102
105
|
if (fixedWidthTypeList[finalType]) {
|
|
103
106
|
// console.log(
|
|
@@ -119,6 +122,7 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
|
|
|
119
122
|
// @ts-ignore
|
|
120
123
|
Math.max(titleWidth, computeableWidthTypeList[finalType](data, render)), size, index === 0 && useRowSelection);
|
|
121
124
|
} else {
|
|
125
|
+
var _column$render;
|
|
122
126
|
// 直接根据 dom 计算
|
|
123
127
|
// console.log(column.title, '可计算 dom')
|
|
124
128
|
column.isAutoWidth = false;
|
|
@@ -131,6 +135,10 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
|
|
|
131
135
|
} else if (column === null || column === void 0 ? void 0 : column.sortable) {
|
|
132
136
|
column.width = column.width + 24;
|
|
133
137
|
}
|
|
138
|
+
// @ts-ignore
|
|
139
|
+
if (column === null || column === void 0 ? void 0 : (_column$render = column.render) === null || _column$render === void 0 ? void 0 : _column$render.copy) {
|
|
140
|
+
column.width = column.width + 16;
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
if (index === 0) {
|
|
136
144
|
// 首列不会被挤占
|
|
@@ -151,6 +159,7 @@ export var shadowContainer = function shadowContainer(props) {
|
|
|
151
159
|
var columns = props.columns,
|
|
152
160
|
data = props.data,
|
|
153
161
|
shadowContainerRef = props.shadowContainerRef;
|
|
162
|
+
if (data.length === 0) return null;
|
|
154
163
|
return /*#__PURE__*/React.createElement("div", {
|
|
155
164
|
ref: shadowContainerRef,
|
|
156
165
|
className: "teamix-pro-table-shadow-container"
|
|
@@ -254,11 +263,15 @@ export var fieldTypeShrink = {
|
|
|
254
263
|
ip: 0
|
|
255
264
|
};
|
|
256
265
|
function calcWidthWithParentDOM(dom, shrink) {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
return node
|
|
261
|
-
|
|
266
|
+
if (dom) {
|
|
267
|
+
var childNodes = _toConsumableArray(dom.children);
|
|
268
|
+
childNodes.shift();
|
|
269
|
+
return calcSingleColumnLength(childNodes.map(function (node) {
|
|
270
|
+
return node.scrollWidth;
|
|
271
|
+
}), shrink);
|
|
272
|
+
} else {
|
|
273
|
+
return 0;
|
|
274
|
+
}
|
|
262
275
|
}
|
|
263
276
|
function calcSingleColumnLength() {
|
|
264
277
|
var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
var _excluded = ["primaryKey"];
|
|
1
2
|
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
3
|
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; }
|
|
3
4
|
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
4
7
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
8
|
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
9
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
@@ -15,20 +18,26 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
15
18
|
* 处理表格 rowSelection hooks
|
|
16
19
|
* 除了基本 rowSelection 之外返回平铺后的 selectedRowKeys、selectedRecords
|
|
17
20
|
*/
|
|
18
|
-
import { useState } from 'react';
|
|
21
|
+
import React, { useState } from 'react';
|
|
19
22
|
import { getDeepValue } from '@teamix/utils';
|
|
23
|
+
import { Balloon, Checkbox } from '@alicloudfe/components';
|
|
24
|
+
var Tooltip = Balloon.Tooltip;
|
|
20
25
|
function useTableSelection() {
|
|
21
26
|
var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
22
27
|
var primaryKey = arguments.length > 1 ? arguments[1] : undefined;
|
|
23
|
-
var
|
|
28
|
+
var _config$defaultSelect = config.defaultSelectedRecords,
|
|
29
|
+
defaultSelectedRecords = _config$defaultSelect === void 0 ? [] : _config$defaultSelect,
|
|
30
|
+
_config$defaultSelect2 = config.defaultSelectedRowKeys,
|
|
31
|
+
defaultSelectedRowKeys = _config$defaultSelect2 === void 0 ? [] : _config$defaultSelect2;
|
|
32
|
+
var _useState = useState(defaultSelectedRowKeys),
|
|
24
33
|
_useState2 = _slicedToArray(_useState, 2),
|
|
25
34
|
selectedRowKeys = _useState2[0],
|
|
26
35
|
setSelectedRowKeys = _useState2[1];
|
|
27
|
-
var _useState3 = useState(
|
|
36
|
+
var _useState3 = useState(defaultSelectedRecords),
|
|
28
37
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
29
38
|
selectedRecords = _useState4[0],
|
|
30
39
|
setSelectedRecords = _useState4[1];
|
|
31
|
-
function
|
|
40
|
+
function _onChange(value, records) {
|
|
32
41
|
if (primaryKey) {
|
|
33
42
|
var newValue = value.filter(function (v) {
|
|
34
43
|
return !selectedRowKeys.includes(v);
|
|
@@ -63,11 +72,51 @@ function useTableSelection() {
|
|
|
63
72
|
config.onChange(value, records);
|
|
64
73
|
}
|
|
65
74
|
}
|
|
75
|
+
var renderCheckBox = function renderCheckBox(props) {
|
|
76
|
+
var primaryKey = props.primaryKey,
|
|
77
|
+
others = _objectWithoutProperties(props, _excluded);
|
|
78
|
+
return /*#__PURE__*/React.createElement(Checkbox, _objectSpread({
|
|
79
|
+
checked: selectedRowKeys.includes(primaryKey),
|
|
80
|
+
onChange: function onChange(checked) {
|
|
81
|
+
if (checked) {
|
|
82
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange([].concat(_toConsumableArray(selectedRowKeys), [primaryKey]), [props]);
|
|
83
|
+
} else {
|
|
84
|
+
_onChange === null || _onChange === void 0 ? void 0 : _onChange(selectedRowKeys.filter(function (item) {
|
|
85
|
+
return item !== primaryKey;
|
|
86
|
+
}), [props]);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, others));
|
|
90
|
+
};
|
|
91
|
+
var getProps = function getProps(record, index) {
|
|
92
|
+
var _config$getProps;
|
|
93
|
+
var propResult = config === null || config === void 0 ? void 0 : (_config$getProps = config.getProps) === null || _config$getProps === void 0 ? void 0 : _config$getProps.call(config, record, index);
|
|
94
|
+
// console.log('propResult', propResult, selectedRowKeys);
|
|
95
|
+
var resultProps = _objectSpread(_objectSpread({}, record), propResult);
|
|
96
|
+
var primaryKey = record === null || record === void 0 ? void 0 : record[resultProps === null || resultProps === void 0 ? void 0 : resultProps['_primaryKey']];
|
|
97
|
+
return _objectSpread(_objectSpread({}, resultProps), {}, {
|
|
98
|
+
isPreview: true,
|
|
99
|
+
renderPreview: function renderPreview() {
|
|
100
|
+
if (resultProps.disabled === true && resultProps.disabledTooltip) {
|
|
101
|
+
return /*#__PURE__*/React.createElement(Tooltip, {
|
|
102
|
+
trigger: renderCheckBox(_objectSpread(_objectSpread({}, propResult), {}, {
|
|
103
|
+
primaryKey: primaryKey
|
|
104
|
+
})),
|
|
105
|
+
align: "t"
|
|
106
|
+
}, propResult.disabledTooltip);
|
|
107
|
+
}
|
|
108
|
+
return renderCheckBox(_objectSpread(_objectSpread({}, propResult), {}, {
|
|
109
|
+
primaryKey: primaryKey
|
|
110
|
+
}));
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
};
|
|
66
114
|
var rowSelection = _objectSpread(_objectSpread({
|
|
67
115
|
selectedRowKeys: selectedRowKeys,
|
|
68
116
|
selectedRecords: selectedRecords
|
|
69
117
|
}, config), {}, {
|
|
70
|
-
onChange:
|
|
118
|
+
onChange: _onChange,
|
|
119
|
+
getProps: getProps
|
|
71
120
|
});
|
|
72
121
|
return {
|
|
73
122
|
rowSelection: rowSelection,
|
|
@@ -88,7 +88,6 @@ var ICON_MAP = {
|
|
|
88
88
|
};
|
|
89
89
|
var BaseItem = function BaseItem(props) {
|
|
90
90
|
var _cls, _cls3, _cls4, _cls5, _cls6;
|
|
91
|
-
console.log('FormItem2');
|
|
92
91
|
var children = props.children,
|
|
93
92
|
others = _objectWithoutProperties(props, _excluded);
|
|
94
93
|
var _useState3 = (0, _react.useState)(false),
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
declare const SelectTable2: React.ForwardRefExoticComponent<Partial<{
|
|
3
|
+
field: any;
|
|
4
|
+
} & {
|
|
5
|
+
autoWidth?: boolean | undefined;
|
|
6
|
+
columns: import("../../../table").ProTableColumnProps[];
|
|
7
|
+
url?: string | undefined;
|
|
8
|
+
method?: import("axios").Method | undefined;
|
|
9
|
+
params?: {
|
|
10
|
+
[propName: string]: any;
|
|
11
|
+
} | undefined;
|
|
12
|
+
formatSort?: ((sort: object) => object) | undefined;
|
|
13
|
+
formatParams?: string | ((params: any) => any) | undefined;
|
|
14
|
+
formatResult?: string | {
|
|
15
|
+
total?: string | number | undefined;
|
|
16
|
+
data?: any;
|
|
17
|
+
} | ((res: any) => {
|
|
18
|
+
total?: string | number | undefined;
|
|
19
|
+
data?: any;
|
|
20
|
+
}) | undefined;
|
|
21
|
+
onFormatResult?: ((data: any[]) => void) | undefined;
|
|
22
|
+
requestWhenMount?: boolean | undefined;
|
|
23
|
+
onSuccess?: ((res: any) => void) | undefined;
|
|
24
|
+
onError?: ((error: Error) => void) | undefined;
|
|
25
|
+
requestConfig?: import("axios").AxiosRequestConfig | undefined;
|
|
26
|
+
pageKey?: string | undefined;
|
|
27
|
+
pageSizeKey?: string | undefined;
|
|
28
|
+
pageSize?: number | undefined;
|
|
29
|
+
pageSizeList?: any[] | undefined;
|
|
30
|
+
paginationProps?: import("@alifd/next/types/pagination").PaginationProps | undefined;
|
|
31
|
+
showPagination?: boolean | undefined;
|
|
32
|
+
responsivePaginationType?: import("../../../table").responsivePaginationType | undefined;
|
|
33
|
+
useRowSelection?: boolean | undefined;
|
|
34
|
+
onChangeRowSelection?: ((selectedRowKeys: string[]) => void) | undefined;
|
|
35
|
+
getRowSelection?: ((rowSelection: import("../../../table").innerRowSelectionType) => void) | undefined;
|
|
36
|
+
footerAction?: React.ReactNode | import("../../..").ProActionGroupProps;
|
|
37
|
+
footer?: React.ReactNode;
|
|
38
|
+
filterDebounce?: number | undefined;
|
|
39
|
+
actionRef?: React.MutableRefObject<import("../../../table").ProTableActionType | undefined> | undefined;
|
|
40
|
+
showSkeleton?: boolean | undefined;
|
|
41
|
+
skeletonSize?: number | undefined;
|
|
42
|
+
tableClassName?: string | undefined;
|
|
43
|
+
footerSuction?: boolean | Element | undefined;
|
|
44
|
+
autoRefresh?: boolean | ((dataSource: any[]) => number | boolean) | undefined;
|
|
45
|
+
autoRefreshProps?: {
|
|
46
|
+
dataSource?: {
|
|
47
|
+
label?: React.ReactNode;
|
|
48
|
+
value?: number | undefined;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
} | undefined;
|
|
51
|
+
customRequest?: ((params: any) => Promise<{
|
|
52
|
+
success: boolean;
|
|
53
|
+
data: any[];
|
|
54
|
+
total?: number | undefined;
|
|
55
|
+
}>) | undefined;
|
|
56
|
+
reserveSelectedRecords?: boolean | undefined;
|
|
57
|
+
defaultFilterParams?: {
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
} | undefined;
|
|
60
|
+
disableSelectAll?: boolean | undefined;
|
|
61
|
+
context?: any;
|
|
62
|
+
fixedTableBody?: boolean | undefined;
|
|
63
|
+
'data-teamix-spm'?: string | undefined;
|
|
64
|
+
switchCardView?: boolean | undefined;
|
|
65
|
+
cardViewProps?: import("../../../table").ProTableCardProps | undefined;
|
|
66
|
+
defaultView?: "table" | "card" | undefined;
|
|
67
|
+
emptyProps?: import("@teamix/pro-field").EmptyContentProps | undefined;
|
|
68
|
+
bindUrl?: boolean | undefined;
|
|
69
|
+
bindUrlProps?: import("../../../table").ProTableBindUrlProps | undefined;
|
|
70
|
+
autoRedirect?: boolean | undefined;
|
|
71
|
+
useMaxData?: boolean | undefined;
|
|
72
|
+
rowSelection?: ({
|
|
73
|
+
getProps?: ((record: any, index: number) => any) | undefined;
|
|
74
|
+
onChange?: ((selectedRowKeys: any[], records: any[]) => void) | undefined;
|
|
75
|
+
onSelect?: ((selected: boolean, record: any, records: any[]) => void) | undefined;
|
|
76
|
+
onSelectAll?: ((selected: boolean, records: any[]) => void) | undefined;
|
|
77
|
+
selectedRowKeys?: any[] | undefined;
|
|
78
|
+
selectedRecords?: any[] | undefined;
|
|
79
|
+
mode?: "multiple" | "single" | undefined;
|
|
80
|
+
titleProps?: (() => any) | undefined;
|
|
81
|
+
columnProps?: (() => any) | undefined;
|
|
82
|
+
titleAddons?: (() => any) | undefined;
|
|
83
|
+
defaultSelectedRowKeys?: any[] | undefined;
|
|
84
|
+
defaultSelectedRecords?: any[] | undefined;
|
|
85
|
+
} & {
|
|
86
|
+
getProps?: ((record: any, index: number) => void) | undefined;
|
|
87
|
+
onChange?: ((selectedRowKeys: any[], records: any[]) => void) | undefined;
|
|
88
|
+
onSelect?: ((selected: boolean, record: any, records: any[]) => void) | undefined;
|
|
89
|
+
onSelectAll?: ((selected: boolean, records: any[]) => void) | undefined;
|
|
90
|
+
selectedRowKeys?: any[] | undefined;
|
|
91
|
+
mode?: "multiple" | "single" | undefined;
|
|
92
|
+
titleProps?: (() => any) | undefined;
|
|
93
|
+
columnProps?: (() => any) | undefined;
|
|
94
|
+
titleAddons?: (() => any) | undefined;
|
|
95
|
+
}) | undefined;
|
|
96
|
+
} & Omit<import("@alifd/next/types/table").TableProps, "rowSelection" | "columns"> & import("../../../table").ProTableTopAreaProps> & React.RefAttributes<unknown>>;
|
|
97
|
+
export default SelectTable2;
|