@pisell/materials 2.2.21 → 2.2.22
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/build/lowcode/assets-daily.json +11 -11
- package/build/lowcode/assets-dev.json +2 -2
- package/build/lowcode/assets-prod.json +11 -11
- package/build/lowcode/index.js +1 -1
- package/build/lowcode/meta.js +1 -1
- package/build/lowcode/preview.js +4 -4
- package/build/lowcode/render/default/view.css +1 -1
- package/build/lowcode/render/default/view.js +11 -11
- package/build/lowcode/view.css +1 -1
- package/build/lowcode/view.js +15 -15
- package/es/components/table/BasicTable/index.js +5 -3
- package/es/components/table/Table/index.d.ts +2 -2
- package/es/components/table/Table/index.js +66 -41
- package/es/components/table/Table/index.less +3 -0
- package/es/components/table/Table/utils.d.ts +1 -1
- package/es/components/table/View/index.d.ts +2 -2
- package/es/components/table/View/index.js +27 -16
- package/es/components/table/hooks/useGenScroll.js +1 -1
- package/es/components/table/hooks/useTableSetting.js +3 -2
- package/es/components/table/hooks/useTransDataSource.js +2 -2
- package/es/components/table/index.js +7 -5
- package/es/components/table/index.less +9 -0
- package/lib/components/table/BasicTable/index.js +2 -3
- package/lib/components/table/Table/index.d.ts +2 -2
- package/lib/components/table/Table/index.js +59 -33
- package/lib/components/table/Table/index.less +3 -0
- package/lib/components/table/Table/utils.d.ts +1 -1
- package/lib/components/table/View/index.d.ts +2 -2
- package/lib/components/table/View/index.js +28 -19
- package/lib/components/table/hooks/useGenScroll.js +1 -1
- package/lib/components/table/hooks/useTableSetting.js +3 -2
- package/lib/components/table/hooks/useTransDataSource.js +1 -1
- package/lib/components/table/index.js +4 -4
- package/lib/components/table/index.less +9 -0
- package/package.json +3 -3
|
@@ -84,7 +84,6 @@ var BasicTable = function BasicTable(props) {
|
|
|
84
84
|
total: _total
|
|
85
85
|
};
|
|
86
86
|
}, [localPagination, dataSource, formPagination === null || formPagination === void 0 ? void 0 : formPagination.page, formPagination === null || formPagination === void 0 ? void 0 : formPagination.size, filter, sort, other.columns]);
|
|
87
|
-
console.log(pagination, 'wh8888');
|
|
88
87
|
|
|
89
88
|
// 总数
|
|
90
89
|
var total = useMemo(function () {
|
|
@@ -110,7 +109,7 @@ var BasicTable = function BasicTable(props) {
|
|
|
110
109
|
type: 'setCurrentDataSource',
|
|
111
110
|
payload: (_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list) || []
|
|
112
111
|
});
|
|
113
|
-
}, [_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list]);
|
|
112
|
+
}, [JSON.stringify(_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list)]);
|
|
114
113
|
return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Table, _extends({
|
|
115
114
|
key: defaultExpandedRowKeys.join('-')
|
|
116
115
|
}, other, {
|
|
@@ -140,7 +139,10 @@ var BasicTable = function BasicTable(props) {
|
|
|
140
139
|
defaultExpandAllRows: true
|
|
141
140
|
}
|
|
142
141
|
})), total > ((pagination === null || pagination === void 0 ? void 0 : pagination.pageSize) || (pagination === null || pagination === void 0 ? void 0 : (_pagination$pageSizeO = pagination.pageSizeOptions) === null || _pagination$pageSizeO === void 0 ? void 0 : _pagination$pageSizeO[0]) || 10) || pagination !== null && pagination !== void 0 && pagination.showPagination && total > 10 ? /*#__PURE__*/React.createElement(Form.Item, {
|
|
143
|
-
name: "pagination"
|
|
142
|
+
name: "pagination",
|
|
143
|
+
style: {
|
|
144
|
+
margin: 0
|
|
145
|
+
}
|
|
144
146
|
}, /*#__PURE__*/React.createElement(FormPagination, _extends({}, pagination, {
|
|
145
147
|
showTotal: _showTotal,
|
|
146
148
|
total: total
|
|
@@ -11,10 +11,10 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
11
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
12
|
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
13
13
|
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; }
|
|
14
|
-
import React, { memo, useCallback, useEffect, useMemo, useRef } from
|
|
15
|
-
import { Form } from
|
|
14
|
+
import React, { memo, useCallback, useEffect, useMemo, useRef } from 'react';
|
|
15
|
+
import { Form } from 'antd';
|
|
16
16
|
// import { Access } from '@umijs/max';
|
|
17
|
-
import { useMemoizedFn, useSize } from
|
|
17
|
+
import { useDebounce, useMemoizedFn, useSize } from 'ahooks';
|
|
18
18
|
import { Context } from "../model";
|
|
19
19
|
// import AddFieldModal from "./AddFieldModal";
|
|
20
20
|
import BasicTable from "../BasicTable";
|
|
@@ -25,26 +25,23 @@ import useTransDataSource from "../hooks/useTransDataSource";
|
|
|
25
25
|
import useTransColumns from "../hooks/useTransColumns";
|
|
26
26
|
import useGenTableComponents from "../hooks/useGenTableComponents";
|
|
27
27
|
import useGenScroll from "../hooks/useGenScroll";
|
|
28
|
-
import { useSharedState
|
|
28
|
+
import { useSharedState } from "../../../hooks";
|
|
29
29
|
import "./index.less";
|
|
30
30
|
var GridViewTable = function GridViewTable(_ref) {
|
|
31
|
-
var _tableProps$paginatio, _tableProps$paginatio2
|
|
31
|
+
var _tableProps$paginatio, _tableProps$paginatio2;
|
|
32
32
|
var tableProps = _ref.tableProps,
|
|
33
33
|
filter = _ref.filter,
|
|
34
34
|
setTableSetting = _ref.setTableSetting,
|
|
35
35
|
onDataSourceChange = _ref.onDataSourceChange;
|
|
36
|
-
var responsive = useResponsive();
|
|
37
36
|
var _useSharedState = useSharedState(Context),
|
|
38
37
|
state = _useSharedState.state,
|
|
39
38
|
dispatch = _useSharedState.dispatch;
|
|
40
39
|
var form = Form.useFormInstance();
|
|
41
|
-
var column_setting = Form.useWatch(
|
|
40
|
+
var column_setting = Form.useWatch('column_setting', {
|
|
42
41
|
form: form,
|
|
43
42
|
preserve: true
|
|
44
43
|
}) || [];
|
|
45
44
|
var tableWrapRef = useRef(null);
|
|
46
|
-
var _ref2 = useSize(tableWrapRef) || {},
|
|
47
|
-
height = _ref2.height;
|
|
48
45
|
var defaultDataSource = state.dataSource,
|
|
49
46
|
originDataSource = state.originDataSource;
|
|
50
47
|
var handleSave = useMemoizedFn(function (row) {
|
|
@@ -55,18 +52,18 @@ var GridViewTable = function GridViewTable(_ref) {
|
|
|
55
52
|
var item = newData[index];
|
|
56
53
|
newData.splice(index, 1, _objectSpread(_objectSpread({}, item), row));
|
|
57
54
|
dispatch({
|
|
58
|
-
type:
|
|
55
|
+
type: 'setDataSource',
|
|
59
56
|
payload: newData
|
|
60
57
|
});
|
|
61
58
|
});
|
|
62
59
|
var handleResize = function handleResize(index) {
|
|
63
|
-
return function (e,
|
|
64
|
-
var size =
|
|
60
|
+
return function (e, _ref2) {
|
|
61
|
+
var size = _ref2.size;
|
|
65
62
|
var nextColumns = _toConsumableArray(columns);
|
|
66
63
|
nextColumns[index] = _objectSpread(_objectSpread({}, nextColumns[index]), {}, {
|
|
67
64
|
width: size.width
|
|
68
65
|
});
|
|
69
|
-
form.setFieldValue(
|
|
66
|
+
form.setFieldValue('column_setting', nextColumns);
|
|
70
67
|
setTableSetting(form.getFieldsValue());
|
|
71
68
|
};
|
|
72
69
|
};
|
|
@@ -89,7 +86,7 @@ var GridViewTable = function GridViewTable(_ref) {
|
|
|
89
86
|
});
|
|
90
87
|
useEffect(function () {
|
|
91
88
|
dispatch({
|
|
92
|
-
type:
|
|
89
|
+
type: 'setOriginResultDataSource',
|
|
93
90
|
payload: dataSource || []
|
|
94
91
|
});
|
|
95
92
|
}, [dataSource]);
|
|
@@ -99,24 +96,10 @@ var GridViewTable = function GridViewTable(_ref) {
|
|
|
99
96
|
var components = useGenTableComponents({
|
|
100
97
|
form: form
|
|
101
98
|
});
|
|
102
|
-
var isShowPagination = useMemo(function () {
|
|
103
|
-
var _tableProps$paginatio3, _tableProps$paginatio4, _tableProps$paginatio5, _tableProps$paginatio6;
|
|
104
|
-
var total = (tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio3 = tableProps.pagination) === null || _tableProps$paginatio3 === void 0 ? void 0 : _tableProps$paginatio3.total) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0;
|
|
105
|
-
if (tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio4 = tableProps.pagination) !== null && _tableProps$paginatio4 !== void 0 && _tableProps$paginatio4.localPagination) {
|
|
106
|
-
total = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0;
|
|
107
|
-
}
|
|
108
|
-
return total > ((tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio5 = tableProps.pagination) === null || _tableProps$paginatio5 === void 0 ? void 0 : (_tableProps$paginatio6 = _tableProps$paginatio5.pageSizeOptions) === null || _tableProps$paginatio6 === void 0 ? void 0 : _tableProps$paginatio6[0]) || 10);
|
|
109
|
-
}, [tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio7 = tableProps.pagination) === null || _tableProps$paginatio7 === void 0 ? void 0 : _tableProps$paginatio7.localPagination, tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio8 = tableProps.pagination) === null || _tableProps$paginatio8 === void 0 ? void 0 : _tableProps$paginatio8.total, dataSource.length, tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio9 = tableProps.pagination) === null || _tableProps$paginatio9 === void 0 ? void 0 : (_tableProps$paginatio10 = _tableProps$paginatio9.pageSizeOptions) === null || _tableProps$paginatio10 === void 0 ? void 0 : _tableProps$paginatio10[0]]);
|
|
110
|
-
var scroll = useGenScroll({
|
|
111
|
-
wrapHeight: height || 500,
|
|
112
|
-
scroll: tableProps.scroll,
|
|
113
|
-
columns: columns,
|
|
114
|
-
isShowPagination: isShowPagination
|
|
115
|
-
});
|
|
116
99
|
var showTotal = useCallback(function (total, range, pageSize) {
|
|
117
100
|
var start = range[0] - 1;
|
|
118
101
|
var _current = start / pageSize + 1;
|
|
119
|
-
return getText(
|
|
102
|
+
return getText('table-pagination-total')(_current, Math.ceil(total / pageSize));
|
|
120
103
|
}, []);
|
|
121
104
|
var _paginationConfig = useMemo(function () {
|
|
122
105
|
if (tableProps.pagination === false) {
|
|
@@ -125,22 +108,64 @@ var GridViewTable = function GridViewTable(_ref) {
|
|
|
125
108
|
return _objectSpread(_objectSpread(_objectSpread({}, paginationConfig), tableProps.pagination), {}, {
|
|
126
109
|
showTotal: showTotal
|
|
127
110
|
});
|
|
128
|
-
}, [
|
|
111
|
+
}, [tableProps.pagination]);
|
|
129
112
|
return /*#__PURE__*/React.createElement("div", {
|
|
130
|
-
className:
|
|
113
|
+
className: 'materials-grid-table-wrap',
|
|
131
114
|
ref: tableWrapRef
|
|
132
|
-
}, /*#__PURE__*/React.createElement(
|
|
133
|
-
|
|
134
|
-
onSortChange: tableProps.onSortChange
|
|
135
|
-
}, /*#__PURE__*/React.createElement(BasicTable, _extends({
|
|
136
|
-
key: scroll === null || scroll === void 0 ? void 0 : scroll.y,
|
|
115
|
+
}, /*#__PURE__*/React.createElement(AutoSizerContent, {
|
|
116
|
+
tableWrapRef: tableWrapRef,
|
|
137
117
|
dataSource: dataSource,
|
|
118
|
+
tableProps: tableProps,
|
|
138
119
|
columns: columns,
|
|
139
|
-
|
|
120
|
+
paginationConfig: _paginationConfig,
|
|
140
121
|
components: components
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
122
|
+
}));
|
|
123
|
+
};
|
|
124
|
+
var AutoSizerContent = function AutoSizerContent(props) {
|
|
125
|
+
var _tableProps$paginatio9, _tableProps$paginatio10, _tableProps$paginatio11, _tableProps$paginatio12;
|
|
126
|
+
var tableProps = props.tableProps,
|
|
127
|
+
dataSource = props.dataSource,
|
|
128
|
+
paginationConfig = props.paginationConfig,
|
|
129
|
+
columns = props.columns,
|
|
130
|
+
components = props.components,
|
|
131
|
+
tableWrapRef = props.tableWrapRef;
|
|
132
|
+
var _ref3 = useSize(tableWrapRef) || {},
|
|
133
|
+
height = _ref3.height;
|
|
134
|
+
var debouncedHeight = useDebounce(height, {
|
|
135
|
+
wait: 500
|
|
136
|
+
});
|
|
137
|
+
var isShowPagination = useMemo(function () {
|
|
138
|
+
var _tableProps$paginatio3, _tableProps$paginatio4, _tableProps$paginatio5, _tableProps$paginatio6, _tableProps$paginatio7, _tableProps$paginatio8;
|
|
139
|
+
var total = (tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio3 = tableProps.pagination) === null || _tableProps$paginatio3 === void 0 ? void 0 : _tableProps$paginatio3.total) || (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0;
|
|
140
|
+
if (tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio4 = tableProps.pagination) !== null && _tableProps$paginatio4 !== void 0 && _tableProps$paginatio4.localPagination) {
|
|
141
|
+
total = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0;
|
|
142
|
+
}
|
|
143
|
+
return total > ((tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio5 = tableProps.pagination) === null || _tableProps$paginatio5 === void 0 ? void 0 : _tableProps$paginatio5.pageSize) || (tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio6 = tableProps.pagination) === null || _tableProps$paginatio6 === void 0 ? void 0 : (_tableProps$paginatio7 = _tableProps$paginatio6.pageSizeOptions) === null || _tableProps$paginatio7 === void 0 ? void 0 : _tableProps$paginatio7[0]) || 10) || (tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio8 = tableProps.pagination) === null || _tableProps$paginatio8 === void 0 ? void 0 : _tableProps$paginatio8.showPagination) && total > 10;
|
|
144
|
+
}, [tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio9 = tableProps.pagination) === null || _tableProps$paginatio9 === void 0 ? void 0 : _tableProps$paginatio9.localPagination, tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio10 = tableProps.pagination) === null || _tableProps$paginatio10 === void 0 ? void 0 : _tableProps$paginatio10.total, dataSource.length, tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$paginatio11 = tableProps.pagination) === null || _tableProps$paginatio11 === void 0 ? void 0 : (_tableProps$paginatio12 = _tableProps$paginatio11.pageSizeOptions) === null || _tableProps$paginatio12 === void 0 ? void 0 : _tableProps$paginatio12[0]]);
|
|
145
|
+
var scroll = useGenScroll({
|
|
146
|
+
wrapHeight: debouncedHeight || 500,
|
|
147
|
+
scroll: tableProps.scroll,
|
|
148
|
+
columns: columns,
|
|
149
|
+
isShowPagination: isShowPagination
|
|
150
|
+
});
|
|
151
|
+
var debouncedScroll = useDebounce(scroll, {
|
|
152
|
+
wait: 200
|
|
153
|
+
});
|
|
154
|
+
var basicTable = useMemo(function () {
|
|
155
|
+
return /*#__PURE__*/React.createElement(BasicTable, _extends({
|
|
156
|
+
key: debouncedScroll,
|
|
157
|
+
dataSource: dataSource,
|
|
158
|
+
columns: columns,
|
|
159
|
+
className: 'grid-view-table',
|
|
160
|
+
components: components
|
|
161
|
+
}, tableProps, {
|
|
162
|
+
scroll: debouncedScroll,
|
|
163
|
+
pagination: paginationConfig
|
|
164
|
+
}));
|
|
165
|
+
}, [debouncedScroll, dataSource, columns, components, paginationConfig, tableProps]);
|
|
166
|
+
return /*#__PURE__*/React.createElement(SortRow, {
|
|
167
|
+
rowKey: tableProps.rowKey,
|
|
168
|
+
onSortChange: tableProps.onSortChange
|
|
169
|
+
}, basicTable);
|
|
145
170
|
};
|
|
146
171
|
export default /*#__PURE__*/memo(GridViewTable);
|
|
@@ -155,7 +155,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
|
|
|
155
155
|
sort?: SortType | undefined;
|
|
156
156
|
mode: "" | "localStorage" | "remote";
|
|
157
157
|
currentViewMode: ModeType;
|
|
158
|
-
}) => ("
|
|
158
|
+
}) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
|
|
159
159
|
export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
|
|
160
160
|
export declare const stringify: (obj: Record<string, any>) => string;
|
|
161
161
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { GridViewProps } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GridViewProps } from '../types';
|
|
3
3
|
declare const View: (props: GridViewProps & {
|
|
4
4
|
setTableSetting: (values: Record<string, any>) => void;
|
|
5
5
|
}) => React.JSX.Element;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
var _excluded = ["dataSource", "columns", "dispatch", "style", "filter", "sort", "buttons", "actionButtons", "title", "summary", "onValuesChange", "columnSetting", "dataSourceGroup", "view", "gallery", "setTableSetting", "onDataSourceChange"];
|
|
2
2
|
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; }
|
|
3
3
|
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
|
-
import React from
|
|
5
|
-
import { Form } from
|
|
4
|
+
import React, { useMemo } from 'react';
|
|
5
|
+
import { Form } from 'antd';
|
|
6
6
|
import GridViewTable from "../Table";
|
|
7
7
|
import Gallery from "../Gallery";
|
|
8
|
+
import { stringify } from "../Table/utils";
|
|
9
|
+
import { useDebounce, useMemoizedFn } from 'ahooks';
|
|
8
10
|
var View = function View(props) {
|
|
9
11
|
var dataSource = props.dataSource,
|
|
10
12
|
columns = props.columns,
|
|
@@ -25,22 +27,31 @@ var View = function View(props) {
|
|
|
25
27
|
onDataSourceChange = props.onDataSourceChange,
|
|
26
28
|
other = _objectWithoutProperties(props, _excluded);
|
|
27
29
|
var form = Form.useFormInstance();
|
|
28
|
-
var viewMode = Form.useWatch(
|
|
30
|
+
var viewMode = Form.useWatch('view_mode', {
|
|
29
31
|
form: form,
|
|
30
32
|
preserve: true
|
|
31
33
|
});
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
onDataSourceChange: onDataSourceChange
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
34
|
+
var debouncedFilter = useDebounce(filter, {
|
|
35
|
+
wait: 200
|
|
36
|
+
});
|
|
37
|
+
var memoOnDataSourceChange = useMemoizedFn(function (v) {
|
|
38
|
+
return onDataSourceChange === null || onDataSourceChange === void 0 ? void 0 : onDataSourceChange(v);
|
|
39
|
+
});
|
|
40
|
+
var memoContent = useMemo(function () {
|
|
41
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, viewMode === 'grid' && /*#__PURE__*/React.createElement(GridViewTable, {
|
|
42
|
+
tableProps: other,
|
|
43
|
+
filter: filter,
|
|
44
|
+
setTableSetting: setTableSetting,
|
|
45
|
+
onDataSourceChange: memoOnDataSourceChange
|
|
46
|
+
}), viewMode === 'gallery' && /*#__PURE__*/React.createElement(Gallery, {
|
|
47
|
+
loading: other === null || other === void 0 ? void 0 : other.loading,
|
|
48
|
+
gallery: gallery,
|
|
49
|
+
pagination: other.pagination,
|
|
50
|
+
filter: filter,
|
|
51
|
+
rowKey: other.rowKey,
|
|
52
|
+
onDataSourceChange: memoOnDataSourceChange
|
|
53
|
+
}));
|
|
54
|
+
}, [viewMode, stringify(other), debouncedFilter, memoOnDataSourceChange, gallery]);
|
|
55
|
+
return memoContent;
|
|
45
56
|
};
|
|
46
57
|
export default View;
|
|
@@ -10,7 +10,7 @@ var useGenScroll = function useGenScroll(params) {
|
|
|
10
10
|
x: (propsScroll === null || propsScroll === void 0 ? void 0 : propsScroll.x) || columns.reduce(function (p, c) {
|
|
11
11
|
return p + (c.width || 250);
|
|
12
12
|
}, 0) || 2000,
|
|
13
|
-
y: (propsScroll === null || propsScroll === void 0 ? void 0 : propsScroll.y) || Math.max(wrapHeight - 48 - (isShowPagination ? 50 + 24 :
|
|
13
|
+
y: (propsScroll === null || propsScroll === void 0 ? void 0 : propsScroll.y) || Math.max(wrapHeight - 48 - (isShowPagination ? 50 + 24 : 24), 100),
|
|
14
14
|
scrollToFirstRowOnChange: propsScroll === null || propsScroll === void 0 ? void 0 : propsScroll.scrollToFirstRowOnChange
|
|
15
15
|
};
|
|
16
16
|
}
|
|
@@ -6,6 +6,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
|
|
|
6
6
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
7
7
|
import { useMemo } from "react";
|
|
8
8
|
import { getSettingKeyArrByMode, getTableSettingByCurrentViewMode, getTableSettingFromLocalStorage, mergeColumnSetting, mergeFilterSetting, setFormValuesToLocalStorage } from "../Table/utils";
|
|
9
|
+
import { useMemoizedFn } from "ahooks";
|
|
9
10
|
var useTableSetting = function useTableSetting(params) {
|
|
10
11
|
var tableId = params.tableId,
|
|
11
12
|
filter = params.filter,
|
|
@@ -156,7 +157,7 @@ var useTableSetting = function useTableSetting(params) {
|
|
|
156
157
|
* 更新 tableSetting
|
|
157
158
|
* @param values
|
|
158
159
|
*/
|
|
159
|
-
var setTableSetting = function
|
|
160
|
+
var setTableSetting = useMemoizedFn(function (values) {
|
|
160
161
|
setFormValuesToLocalStorage({
|
|
161
162
|
tableId: tableId,
|
|
162
163
|
allValues: values,
|
|
@@ -164,7 +165,7 @@ var useTableSetting = function useTableSetting(params) {
|
|
|
164
165
|
currentViewMode: currentViewMode,
|
|
165
166
|
currentSettingHash: currentSettingHash
|
|
166
167
|
});
|
|
167
|
-
};
|
|
168
|
+
});
|
|
168
169
|
var tableSetting = useMemo(function () {
|
|
169
170
|
return _objectSpread(_objectSpread({}, tableLocalSetting), defaultTableSetting);
|
|
170
171
|
}, [tableLocalSetting, defaultTableSetting]);
|
|
@@ -7,7 +7,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
7
7
|
import { useMemo } from "react";
|
|
8
8
|
import { isArr } from "@pisell/utils";
|
|
9
9
|
import { Form } from "antd";
|
|
10
|
-
import { filterDataSource, groupDataSource, sortDataSource } from "../Table/utils";
|
|
10
|
+
import { filterDataSource, groupDataSource, sortDataSource, stringify } from "../Table/utils";
|
|
11
11
|
var defaultObj = {};
|
|
12
12
|
var useTransDataSource = function useTransDataSource(params) {
|
|
13
13
|
var form = params.form,
|
|
@@ -68,7 +68,7 @@ var useTransDataSource = function useTransDataSource(params) {
|
|
|
68
68
|
return filter === null || filter === void 0 ? void 0 : filter.list.filter(function (item) {
|
|
69
69
|
return item.localFilter;
|
|
70
70
|
});
|
|
71
|
-
}, [filter]);
|
|
71
|
+
}, [stringify(filter)]);
|
|
72
72
|
var dataSource = useMemo(function () {
|
|
73
73
|
// 如果不是本地分页,则直接返回默认数据
|
|
74
74
|
if (!localPagination) {
|
|
@@ -14,7 +14,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
|
|
|
14
14
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
15
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
16
|
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; }
|
|
17
|
-
import { useSize } from 'ahooks';
|
|
17
|
+
import { useDebounce, useSize } from 'ahooks';
|
|
18
18
|
import { Form } from 'antd';
|
|
19
19
|
import React, { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react';
|
|
20
20
|
import { useSharedState } from "../../hooks";
|
|
@@ -75,9 +75,11 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
75
75
|
var initialValuesRef = useRef({});
|
|
76
76
|
var _ref = useSize(wrapRef) || {},
|
|
77
77
|
width = _ref.width;
|
|
78
|
+
var debouncedWidth = useDebounce(width, {
|
|
79
|
+
wait: 100
|
|
80
|
+
});
|
|
78
81
|
var utils = context === null || context === void 0 ? void 0 : (_context$appHelper = context.appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils;
|
|
79
82
|
var tableId = useMemo(function () {
|
|
80
|
-
console.log(props, 'wh');
|
|
81
83
|
if (props.__designMode === 'design') {
|
|
82
84
|
return 'designMode-mock-table-id';
|
|
83
85
|
}
|
|
@@ -131,13 +133,13 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
131
133
|
}
|
|
132
134
|
}, [currentSettingHash, tableId]);
|
|
133
135
|
useEffect(function () {
|
|
134
|
-
if (
|
|
136
|
+
if (debouncedWidth) {
|
|
135
137
|
modal.dispatch({
|
|
136
138
|
type: 'setTableWidth',
|
|
137
|
-
payload:
|
|
139
|
+
payload: debouncedWidth || {}
|
|
138
140
|
});
|
|
139
141
|
}
|
|
140
|
-
}, [
|
|
142
|
+
}, [debouncedWidth]);
|
|
141
143
|
var _useTableSetting = useTableSetting({
|
|
142
144
|
tableId: tableId,
|
|
143
145
|
filter: filter,
|
|
@@ -9,6 +9,15 @@
|
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: column;
|
|
11
11
|
|
|
12
|
+
.pisell-lowcode-table-body {
|
|
13
|
+
overscroll-behavior: none;
|
|
14
|
+
}
|
|
15
|
+
.pisell-lowcode-table-placeholder {
|
|
16
|
+
.cell-provider {
|
|
17
|
+
display: block;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
12
21
|
.pisell-lowcode-table-thead {
|
|
13
22
|
.pisell-lowcode-table-cell {
|
|
14
23
|
padding: 0 14px;
|
|
@@ -93,7 +93,6 @@ var BasicTable = (props) => {
|
|
|
93
93
|
sort,
|
|
94
94
|
other.columns
|
|
95
95
|
]);
|
|
96
|
-
console.log(pagination, "wh8888");
|
|
97
96
|
const total = (0, import_react.useMemo)(() => {
|
|
98
97
|
if (localPagination) {
|
|
99
98
|
return (_dataSource == null ? void 0 : _dataSource.total) || 0;
|
|
@@ -115,7 +114,7 @@ var BasicTable = (props) => {
|
|
|
115
114
|
type: "setCurrentDataSource",
|
|
116
115
|
payload: (_dataSource == null ? void 0 : _dataSource.list) || []
|
|
117
116
|
});
|
|
118
|
-
}, [_dataSource == null ? void 0 : _dataSource.list]);
|
|
117
|
+
}, [JSON.stringify(_dataSource == null ? void 0 : _dataSource.list)]);
|
|
119
118
|
return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
|
|
120
119
|
import_antd.Table,
|
|
121
120
|
{
|
|
@@ -148,7 +147,7 @@ var BasicTable = (props) => {
|
|
|
148
147
|
defaultExpandAllRows: true
|
|
149
148
|
}
|
|
150
149
|
}
|
|
151
|
-
), total > ((pagination == null ? void 0 : pagination.pageSize) || ((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) || 10) || (pagination == null ? void 0 : pagination.showPagination) && total > 10 ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "pagination" }, /* @__PURE__ */ import_react.default.createElement(
|
|
150
|
+
), total > ((pagination == null ? void 0 : pagination.pageSize) || ((_a = pagination == null ? void 0 : pagination.pageSizeOptions) == null ? void 0 : _a[0]) || 10) || (pagination == null ? void 0 : pagination.showPagination) && total > 10 ? /* @__PURE__ */ import_react.default.createElement(import_antd.Form.Item, { name: "pagination", style: { margin: 0 } }, /* @__PURE__ */ import_react.default.createElement(
|
|
152
151
|
import_Pagination.FormPagination,
|
|
153
152
|
{
|
|
154
153
|
...pagination,
|
|
@@ -52,13 +52,11 @@ var GridViewTable = ({
|
|
|
52
52
|
setTableSetting,
|
|
53
53
|
onDataSourceChange
|
|
54
54
|
}) => {
|
|
55
|
-
var _a, _b
|
|
56
|
-
const responsive = (0, import_hooks.useResponsive)();
|
|
55
|
+
var _a, _b;
|
|
57
56
|
const { state, dispatch } = (0, import_hooks.useSharedState)(import_model.Context);
|
|
58
57
|
const form = import_antd.Form.useFormInstance();
|
|
59
58
|
const column_setting = import_antd.Form.useWatch("column_setting", { form, preserve: true }) || [];
|
|
60
59
|
const tableWrapRef = (0, import_react.useRef)(null);
|
|
61
|
-
const { height } = (0, import_ahooks.useSize)(tableWrapRef) || {};
|
|
62
60
|
const { dataSource: defaultDataSource, originDataSource } = state;
|
|
63
61
|
const handleSave = (0, import_ahooks.useMemoizedFn)((row) => {
|
|
64
62
|
const newData = [...defaultDataSource];
|
|
@@ -110,25 +108,6 @@ var GridViewTable = ({
|
|
|
110
108
|
const components = (0, import_useGenTableComponents.default)({
|
|
111
109
|
form
|
|
112
110
|
});
|
|
113
|
-
const isShowPagination = (0, import_react.useMemo)(() => {
|
|
114
|
-
var _a2, _b2, _c2, _d2;
|
|
115
|
-
let total = ((_a2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _a2.total) || (dataSource == null ? void 0 : dataSource.length) || 0;
|
|
116
|
-
if ((_b2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _b2.localPagination) {
|
|
117
|
-
total = (dataSource == null ? void 0 : dataSource.length) || 0;
|
|
118
|
-
}
|
|
119
|
-
return total > (((_d2 = (_c2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c2.pageSizeOptions) == null ? void 0 : _d2[0]) || 10);
|
|
120
|
-
}, [
|
|
121
|
-
(_c = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c.localPagination,
|
|
122
|
-
(_d = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _d.total,
|
|
123
|
-
dataSource.length,
|
|
124
|
-
(_f = (_e = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _e.pageSizeOptions) == null ? void 0 : _f[0]
|
|
125
|
-
]);
|
|
126
|
-
const scroll = (0, import_useGenScroll.default)({
|
|
127
|
-
wrapHeight: height || 500,
|
|
128
|
-
scroll: tableProps.scroll,
|
|
129
|
-
columns,
|
|
130
|
-
isShowPagination
|
|
131
|
-
});
|
|
132
111
|
const showTotal = (0, import_react.useCallback)(
|
|
133
112
|
(total, range, pageSize) => {
|
|
134
113
|
let start = range[0] - 1;
|
|
@@ -149,26 +128,73 @@ var GridViewTable = ({
|
|
|
149
128
|
...tableProps.pagination,
|
|
150
129
|
showTotal
|
|
151
130
|
};
|
|
152
|
-
}, [
|
|
131
|
+
}, [tableProps.pagination]);
|
|
153
132
|
return /* @__PURE__ */ import_react.default.createElement("div", { className: "materials-grid-table-wrap", ref: tableWrapRef }, /* @__PURE__ */ import_react.default.createElement(
|
|
154
|
-
|
|
133
|
+
AutoSizerContent,
|
|
155
134
|
{
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
135
|
+
tableWrapRef,
|
|
136
|
+
dataSource,
|
|
137
|
+
tableProps,
|
|
138
|
+
columns,
|
|
139
|
+
paginationConfig: _paginationConfig,
|
|
140
|
+
components
|
|
141
|
+
}
|
|
142
|
+
));
|
|
143
|
+
};
|
|
144
|
+
var AutoSizerContent = (props) => {
|
|
145
|
+
var _a, _b, _c, _d;
|
|
146
|
+
const {
|
|
147
|
+
tableProps,
|
|
148
|
+
dataSource,
|
|
149
|
+
paginationConfig: paginationConfig2,
|
|
150
|
+
columns,
|
|
151
|
+
components,
|
|
152
|
+
tableWrapRef
|
|
153
|
+
} = props;
|
|
154
|
+
const { height } = (0, import_ahooks.useSize)(tableWrapRef) || {};
|
|
155
|
+
const debouncedHeight = (0, import_ahooks.useDebounce)(height, { wait: 500 });
|
|
156
|
+
const isShowPagination = (0, import_react.useMemo)(() => {
|
|
157
|
+
var _a2, _b2, _c2, _d2, _e, _f;
|
|
158
|
+
let total = ((_a2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _a2.total) || (dataSource == null ? void 0 : dataSource.length) || 0;
|
|
159
|
+
if ((_b2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _b2.localPagination) {
|
|
160
|
+
total = (dataSource == null ? void 0 : dataSource.length) || 0;
|
|
161
|
+
}
|
|
162
|
+
return total > (((_c2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c2.pageSize) || ((_e = (_d2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _d2.pageSizeOptions) == null ? void 0 : _e[0]) || 10) || ((_f = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _f.showPagination) && total > 10;
|
|
163
|
+
}, [
|
|
164
|
+
(_a = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _a.localPagination,
|
|
165
|
+
(_b = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _b.total,
|
|
166
|
+
dataSource.length,
|
|
167
|
+
(_d = (_c = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c.pageSizeOptions) == null ? void 0 : _d[0]
|
|
168
|
+
]);
|
|
169
|
+
const scroll = (0, import_useGenScroll.default)({
|
|
170
|
+
wrapHeight: debouncedHeight || 500,
|
|
171
|
+
scroll: tableProps.scroll,
|
|
172
|
+
columns,
|
|
173
|
+
isShowPagination
|
|
174
|
+
});
|
|
175
|
+
const debouncedScroll = (0, import_ahooks.useDebounce)(scroll, { wait: 200 });
|
|
176
|
+
const basicTable = (0, import_react.useMemo)(() => {
|
|
177
|
+
return /* @__PURE__ */ import_react.default.createElement(
|
|
160
178
|
import_BasicTable.default,
|
|
161
179
|
{
|
|
162
|
-
key:
|
|
180
|
+
key: debouncedScroll,
|
|
163
181
|
dataSource,
|
|
164
182
|
columns,
|
|
165
183
|
className: "grid-view-table",
|
|
166
184
|
components,
|
|
167
185
|
...tableProps,
|
|
168
|
-
scroll,
|
|
169
|
-
pagination:
|
|
186
|
+
scroll: debouncedScroll,
|
|
187
|
+
pagination: paginationConfig2
|
|
170
188
|
}
|
|
171
|
-
)
|
|
172
|
-
|
|
189
|
+
);
|
|
190
|
+
}, [
|
|
191
|
+
debouncedScroll,
|
|
192
|
+
dataSource,
|
|
193
|
+
columns,
|
|
194
|
+
components,
|
|
195
|
+
paginationConfig2,
|
|
196
|
+
tableProps
|
|
197
|
+
]);
|
|
198
|
+
return /* @__PURE__ */ import_react.default.createElement(import_SortRow.default, { rowKey: tableProps.rowKey, onSortChange: tableProps.onSortChange }, basicTable);
|
|
173
199
|
};
|
|
174
200
|
var Table_default = (0, import_react.memo)(GridViewTable);
|
|
@@ -155,7 +155,7 @@ export declare const getSettingKeyArrByMode: ({ filter, columnSetting, dataSourc
|
|
|
155
155
|
sort?: SortType | undefined;
|
|
156
156
|
mode: "" | "localStorage" | "remote";
|
|
157
157
|
currentViewMode: ModeType;
|
|
158
|
-
}) => ("
|
|
158
|
+
}) => ("filter_setting" | "column_setting" | "gallery_setting" | "view_mode" | "group_by" | "order_by")[];
|
|
159
159
|
export declare const omit: (obj: Record<string, any>, keys: string[]) => Record<string, any>;
|
|
160
160
|
export declare const stringify: (obj: Record<string, any>) => string;
|
|
161
161
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { GridViewProps } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { GridViewProps } from '../types';
|
|
3
3
|
declare const View: (props: GridViewProps & {
|
|
4
4
|
setTableSetting: (values: Record<string, any>) => void;
|
|
5
5
|
}) => React.JSX.Element;
|