@pisell/materials 1.0.397 → 1.0.399

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.
@@ -109,7 +109,7 @@ var BasicTable = function BasicTable(props) {
109
109
  type: 'setCurrentDataSource',
110
110
  payload: (_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list) || []
111
111
  });
112
- }, [_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list]);
112
+ }, [JSON.stringify(_dataSource === null || _dataSource === void 0 ? void 0 : _dataSource.list)]);
113
113
  return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Table, _extends({
114
114
  key: defaultExpandedRowKeys.join('-')
115
115
  }, other, {
@@ -1,4 +1,4 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  declare const _default: React.NamedExoticComponent<any>;
4
4
  export default _default;
@@ -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 "react";
15
- import { Form } from "antd";
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 "ahooks";
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, useResponsive } from "../../../hooks";
28
+ import { useSharedState } from "../../../hooks";
29
29
  import "./index.less";
30
30
  var GridViewTable = function GridViewTable(_ref) {
31
- var _tableProps$paginatio, _tableProps$paginatio2, _tableProps$paginatio7, _tableProps$paginatio8, _tableProps$paginatio9, _tableProps$paginatio10;
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("column_setting", {
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: "setDataSource",
55
+ type: 'setDataSource',
59
56
  payload: newData
60
57
  });
61
58
  });
62
59
  var handleResize = function handleResize(index) {
63
- return function (e, _ref3) {
64
- var size = _ref3.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("column_setting", nextColumns);
66
+ form.setFieldValue('column_setting', nextColumns);
70
67
  setTableSetting(form.getFieldsValue());
71
68
  };
72
69
  };
@@ -90,7 +87,7 @@ var GridViewTable = function GridViewTable(_ref) {
90
87
  });
91
88
  useEffect(function () {
92
89
  dispatch({
93
- type: "setOriginResultDataSource",
90
+ type: 'setOriginResultDataSource',
94
91
  payload: dataSource || []
95
92
  });
96
93
  }, [dataSource]);
@@ -100,24 +97,10 @@ var GridViewTable = function GridViewTable(_ref) {
100
97
  var components = useGenTableComponents({
101
98
  form: form
102
99
  });
103
- var isShowPagination = useMemo(function () {
104
- var _tableProps$paginatio3, _tableProps$paginatio4, _tableProps$paginatio5, _tableProps$paginatio6;
105
- 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;
106
- if (tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio4 = tableProps.pagination) !== null && _tableProps$paginatio4 !== void 0 && _tableProps$paginatio4.localPagination) {
107
- total = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0;
108
- }
109
- 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);
110
- }, [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]]);
111
- var scroll = useGenScroll({
112
- wrapHeight: height || 500,
113
- scroll: tableProps.scroll,
114
- columns: columns,
115
- isShowPagination: isShowPagination
116
- });
117
100
  var showTotal = useCallback(function (total, range, pageSize) {
118
101
  var start = range[0] - 1;
119
102
  var _current = start / pageSize + 1;
120
- return getText("table-pagination-total")(_current, Math.ceil(total / pageSize));
103
+ return getText('table-pagination-total')(_current, Math.ceil(total / pageSize));
121
104
  }, []);
122
105
  var _paginationConfig = useMemo(function () {
123
106
  if (tableProps.pagination === false) {
@@ -126,22 +109,64 @@ var GridViewTable = function GridViewTable(_ref) {
126
109
  return _objectSpread(_objectSpread(_objectSpread({}, paginationConfig), tableProps.pagination), {}, {
127
110
  showTotal: showTotal
128
111
  });
129
- }, [responsive, tableProps.pagination]);
112
+ }, [tableProps.pagination]);
130
113
  return /*#__PURE__*/React.createElement("div", {
131
- className: "materials-grid-table-wrap",
114
+ className: 'materials-grid-table-wrap',
132
115
  ref: tableWrapRef
133
- }, /*#__PURE__*/React.createElement(SortRow, {
134
- rowKey: tableProps.rowKey,
135
- onSortChange: tableProps.onSortChange
136
- }, /*#__PURE__*/React.createElement(BasicTable, _extends({
137
- key: scroll === null || scroll === void 0 ? void 0 : scroll.y,
116
+ }, /*#__PURE__*/React.createElement(AutoSizerContent, {
117
+ tableWrapRef: tableWrapRef,
138
118
  dataSource: dataSource,
119
+ tableProps: tableProps,
139
120
  columns: columns,
140
- className: "grid-view-table",
121
+ paginationConfig: _paginationConfig,
141
122
  components: components
142
- }, tableProps, {
143
- scroll: scroll,
144
- pagination: _paginationConfig
145
- }))));
123
+ }));
124
+ };
125
+ var AutoSizerContent = function AutoSizerContent(props) {
126
+ var _tableProps$paginatio7, _tableProps$paginatio8, _tableProps$paginatio9, _tableProps$paginatio10;
127
+ var tableProps = props.tableProps,
128
+ dataSource = props.dataSource,
129
+ paginationConfig = props.paginationConfig,
130
+ columns = props.columns,
131
+ components = props.components,
132
+ tableWrapRef = props.tableWrapRef;
133
+ var _ref3 = useSize(tableWrapRef) || {},
134
+ height = _ref3.height;
135
+ var debouncedHeight = useDebounce(height, {
136
+ wait: 500
137
+ });
138
+ var isShowPagination = useMemo(function () {
139
+ var _tableProps$paginatio3, _tableProps$paginatio4, _tableProps$paginatio5, _tableProps$paginatio6;
140
+ 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;
141
+ if (tableProps !== null && tableProps !== void 0 && (_tableProps$paginatio4 = tableProps.pagination) !== null && _tableProps$paginatio4 !== void 0 && _tableProps$paginatio4.localPagination) {
142
+ total = (dataSource === null || dataSource === void 0 ? void 0 : dataSource.length) || 0;
143
+ }
144
+ 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);
145
+ }, [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]]);
146
+ var scroll = useGenScroll({
147
+ wrapHeight: debouncedHeight || 500,
148
+ scroll: tableProps.scroll,
149
+ columns: columns,
150
+ isShowPagination: isShowPagination
151
+ });
152
+ var debouncedScroll = useDebounce(scroll, {
153
+ wait: 500
154
+ });
155
+ var basicTable = useMemo(function () {
156
+ return /*#__PURE__*/React.createElement(BasicTable, _extends({
157
+ key: debouncedScroll,
158
+ dataSource: dataSource,
159
+ columns: columns,
160
+ className: 'grid-view-table',
161
+ components: components
162
+ }, tableProps, {
163
+ scroll: debouncedScroll,
164
+ pagination: paginationConfig
165
+ }));
166
+ }, [debouncedScroll, dataSource, columns, components, paginationConfig, tableProps]);
167
+ return /*#__PURE__*/React.createElement(SortRow, {
168
+ rowKey: tableProps.rowKey,
169
+ onSortChange: tableProps.onSortChange
170
+ }, basicTable);
146
171
  };
147
172
  export default /*#__PURE__*/memo(GridViewTable);
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { GridViewProps } from "../types";
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,11 @@
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 "react";
5
- import { Form } from "antd";
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";
8
9
  var View = function View(props) {
9
10
  var dataSource = props.dataSource,
10
11
  columns = props.columns,
@@ -25,22 +26,25 @@ var View = function View(props) {
25
26
  onDataSourceChange = props.onDataSourceChange,
26
27
  other = _objectWithoutProperties(props, _excluded);
27
28
  var form = Form.useFormInstance();
28
- var viewMode = Form.useWatch("view_mode", {
29
+ var viewMode = Form.useWatch('view_mode', {
29
30
  form: form,
30
31
  preserve: true
31
32
  });
32
- return /*#__PURE__*/React.createElement(React.Fragment, null, viewMode === "grid" && /*#__PURE__*/React.createElement(GridViewTable, {
33
- tableProps: other,
34
- filter: filter,
35
- setTableSetting: setTableSetting,
36
- onDataSourceChange: onDataSourceChange
37
- }), viewMode === "gallery" && /*#__PURE__*/React.createElement(Gallery, {
38
- loading: other === null || other === void 0 ? void 0 : other.loading,
39
- gallery: gallery,
40
- pagination: other.pagination,
41
- filter: filter,
42
- rowKey: other.rowKey,
43
- onDataSourceChange: onDataSourceChange
44
- }));
33
+ var memoContent = useMemo(function () {
34
+ return /*#__PURE__*/React.createElement(React.Fragment, null, viewMode === 'grid' && /*#__PURE__*/React.createElement(GridViewTable, {
35
+ tableProps: other,
36
+ filter: filter,
37
+ setTableSetting: setTableSetting,
38
+ onDataSourceChange: onDataSourceChange
39
+ }), viewMode === 'gallery' && /*#__PURE__*/React.createElement(Gallery, {
40
+ loading: other === null || other === void 0 ? void 0 : other.loading,
41
+ gallery: gallery,
42
+ pagination: other.pagination,
43
+ filter: filter,
44
+ rowKey: other.rowKey,
45
+ onDataSourceChange: onDataSourceChange
46
+ }));
47
+ }, [viewMode, stringify(other), filter, onDataSourceChange, gallery]);
48
+ return memoContent;
45
49
  };
46
50
  export default View;
@@ -7,6 +7,7 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
7
7
  import { useMemo } from "react";
8
8
  import { getSettingKeyArrByMode, getTableSettingByCurrentViewMode, getTableSettingFromLocalStorage, mergeColumnSetting, mergeFilterSetting, setFormValuesToLocalStorage } from "../Table/utils";
9
9
  import useEngineContext from "../../../hooks/useEngineContext";
10
+ import { useMemoizedFn } from "ahooks";
10
11
  var useTableSetting = function useTableSetting(params) {
11
12
  var _context$appHelper;
12
13
  var tableId = params.tableId,
@@ -162,7 +163,7 @@ var useTableSetting = function useTableSetting(params) {
162
163
  * 更新 tableSetting
163
164
  * @param values
164
165
  */
165
- var setTableSetting = function setTableSetting(values) {
166
+ var setTableSetting = useMemoizedFn(function (values) {
166
167
  var result = setFormValuesToLocalStorage({
167
168
  tableId: tableId,
168
169
  allValues: values,
@@ -184,7 +185,7 @@ var useTableSetting = function useTableSetting(params) {
184
185
  })
185
186
  }
186
187
  */
187
- };
188
+ });
188
189
 
189
190
  var tableSetting = useMemo(function () {
190
191
  return _objectSpread(_objectSpread({}, tableLocalSetting), defaultTableSetting);
@@ -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: 500
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,14 @@ var GridView = Provider( /*#__PURE__*/forwardRef(function (props, ref) {
131
133
  }
132
134
  }, [currentSettingHash, tableId]);
133
135
  useEffect(function () {
134
- if (width) {
136
+ if (debouncedWidth) {
137
+ console.log('modal.dispatch', 'setTableWidth');
135
138
  modal.dispatch({
136
139
  type: 'setTableWidth',
137
- payload: width || {}
140
+ payload: debouncedWidth || {}
138
141
  });
139
142
  }
140
- }, [width]);
143
+ }, [debouncedWidth]);
141
144
  var _useTableSetting = useTableSetting({
142
145
  tableId: tableId,
143
146
  filter: filter,
@@ -9,6 +9,10 @@
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
 
12
+ .pisell-lowcode-table-body {
13
+ overscroll-behavior: none;
14
+ }
15
+
12
16
  .pisell-lowcode-table-thead {
13
17
  .pisell-lowcode-table-cell {
14
18
  padding: 0 14px;
@@ -114,7 +114,7 @@ var BasicTable = (props) => {
114
114
  type: "setCurrentDataSource",
115
115
  payload: (_dataSource == null ? void 0 : _dataSource.list) || []
116
116
  });
117
- }, [_dataSource == null ? void 0 : _dataSource.list]);
117
+ }, [JSON.stringify(_dataSource == null ? void 0 : _dataSource.list)]);
118
118
  return /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
119
119
  import_antd.Table,
120
120
  {
@@ -1,4 +1,4 @@
1
- import React from "react";
2
- import "./index.less";
1
+ import React from 'react';
2
+ import './index.less';
3
3
  declare const _default: React.NamedExoticComponent<any>;
4
4
  export default _default;
@@ -52,13 +52,11 @@ var GridViewTable = ({
52
52
  setTableSetting,
53
53
  onDataSourceChange
54
54
  }) => {
55
- var _a, _b, _c, _d, _e, _f;
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];
@@ -111,25 +109,6 @@ var GridViewTable = ({
111
109
  const components = (0, import_useGenTableComponents.default)({
112
110
  form
113
111
  });
114
- const isShowPagination = (0, import_react.useMemo)(() => {
115
- var _a2, _b2, _c2, _d2;
116
- let total = ((_a2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _a2.total) || (dataSource == null ? void 0 : dataSource.length) || 0;
117
- if ((_b2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _b2.localPagination) {
118
- total = (dataSource == null ? void 0 : dataSource.length) || 0;
119
- }
120
- return total > (((_d2 = (_c2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c2.pageSizeOptions) == null ? void 0 : _d2[0]) || 10);
121
- }, [
122
- (_c = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c.localPagination,
123
- (_d = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _d.total,
124
- dataSource.length,
125
- (_f = (_e = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _e.pageSizeOptions) == null ? void 0 : _f[0]
126
- ]);
127
- const scroll = (0, import_useGenScroll.default)({
128
- wrapHeight: height || 500,
129
- scroll: tableProps.scroll,
130
- columns,
131
- isShowPagination
132
- });
133
112
  const showTotal = (0, import_react.useCallback)(
134
113
  (total, range, pageSize) => {
135
114
  let start = range[0] - 1;
@@ -150,26 +129,73 @@ var GridViewTable = ({
150
129
  ...tableProps.pagination,
151
130
  showTotal
152
131
  };
153
- }, [responsive, tableProps.pagination]);
132
+ }, [tableProps.pagination]);
154
133
  return /* @__PURE__ */ import_react.default.createElement("div", { className: "materials-grid-table-wrap", ref: tableWrapRef }, /* @__PURE__ */ import_react.default.createElement(
155
- import_SortRow.default,
134
+ AutoSizerContent,
156
135
  {
157
- rowKey: tableProps.rowKey,
158
- onSortChange: tableProps.onSortChange
159
- },
160
- /* @__PURE__ */ import_react.default.createElement(
136
+ tableWrapRef,
137
+ dataSource,
138
+ tableProps,
139
+ columns,
140
+ paginationConfig: _paginationConfig,
141
+ components
142
+ }
143
+ ));
144
+ };
145
+ var AutoSizerContent = (props) => {
146
+ var _a, _b, _c, _d;
147
+ const {
148
+ tableProps,
149
+ dataSource,
150
+ paginationConfig: paginationConfig2,
151
+ columns,
152
+ components,
153
+ tableWrapRef
154
+ } = props;
155
+ const { height } = (0, import_ahooks.useSize)(tableWrapRef) || {};
156
+ const debouncedHeight = (0, import_ahooks.useDebounce)(height, { wait: 500 });
157
+ const isShowPagination = (0, import_react.useMemo)(() => {
158
+ var _a2, _b2, _c2, _d2;
159
+ let total = ((_a2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _a2.total) || (dataSource == null ? void 0 : dataSource.length) || 0;
160
+ if ((_b2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _b2.localPagination) {
161
+ total = (dataSource == null ? void 0 : dataSource.length) || 0;
162
+ }
163
+ return total > (((_d2 = (_c2 = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c2.pageSizeOptions) == null ? void 0 : _d2[0]) || 10);
164
+ }, [
165
+ (_a = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _a.localPagination,
166
+ (_b = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _b.total,
167
+ dataSource.length,
168
+ (_d = (_c = tableProps == null ? void 0 : tableProps.pagination) == null ? void 0 : _c.pageSizeOptions) == null ? void 0 : _d[0]
169
+ ]);
170
+ const scroll = (0, import_useGenScroll.default)({
171
+ wrapHeight: debouncedHeight || 500,
172
+ scroll: tableProps.scroll,
173
+ columns,
174
+ isShowPagination
175
+ });
176
+ const debouncedScroll = (0, import_ahooks.useDebounce)(scroll, { wait: 500 });
177
+ const basicTable = (0, import_react.useMemo)(() => {
178
+ return /* @__PURE__ */ import_react.default.createElement(
161
179
  import_BasicTable.default,
162
180
  {
163
- key: scroll == null ? void 0 : scroll.y,
181
+ key: debouncedScroll,
164
182
  dataSource,
165
183
  columns,
166
184
  className: "grid-view-table",
167
185
  components,
168
186
  ...tableProps,
169
- scroll,
170
- pagination: _paginationConfig
187
+ scroll: debouncedScroll,
188
+ pagination: paginationConfig2
171
189
  }
172
- )
173
- ));
190
+ );
191
+ }, [
192
+ debouncedScroll,
193
+ dataSource,
194
+ columns,
195
+ components,
196
+ paginationConfig2,
197
+ tableProps
198
+ ]);
199
+ return /* @__PURE__ */ import_react.default.createElement(import_SortRow.default, { rowKey: tableProps.rowKey, onSortChange: tableProps.onSortChange }, basicTable);
174
200
  };
175
201
  var Table_default = (0, import_react.memo)(GridViewTable);
@@ -1,5 +1,5 @@
1
- import React from "react";
2
- import { GridViewProps } from "../types";
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;
@@ -36,6 +36,7 @@ var import_react = __toESM(require("react"));
36
36
  var import_antd = require("antd");
37
37
  var import_Table = __toESM(require("../Table"));
38
38
  var import_Gallery = __toESM(require("../Gallery"));
39
+ var import_utils = require("../Table/utils");
39
40
  var View = (props) => {
40
41
  const {
41
42
  dataSource,
@@ -62,24 +63,27 @@ var View = (props) => {
62
63
  form,
63
64
  preserve: true
64
65
  });
65
- return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, viewMode === "grid" && /* @__PURE__ */ import_react.default.createElement(
66
- import_Table.default,
67
- {
68
- tableProps: other,
69
- filter,
70
- setTableSetting,
71
- onDataSourceChange
72
- }
73
- ), viewMode === "gallery" && /* @__PURE__ */ import_react.default.createElement(
74
- import_Gallery.default,
75
- {
76
- loading: other == null ? void 0 : other.loading,
77
- gallery,
78
- pagination: other.pagination,
79
- filter,
80
- rowKey: other.rowKey,
81
- onDataSourceChange
82
- }
83
- ));
66
+ const memoContent = (0, import_react.useMemo)(() => {
67
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, viewMode === "grid" && /* @__PURE__ */ import_react.default.createElement(
68
+ import_Table.default,
69
+ {
70
+ tableProps: other,
71
+ filter,
72
+ setTableSetting,
73
+ onDataSourceChange
74
+ }
75
+ ), viewMode === "gallery" && /* @__PURE__ */ import_react.default.createElement(
76
+ import_Gallery.default,
77
+ {
78
+ loading: other == null ? void 0 : other.loading,
79
+ gallery,
80
+ pagination: other.pagination,
81
+ filter,
82
+ rowKey: other.rowKey,
83
+ onDataSourceChange
84
+ }
85
+ ));
86
+ }, [viewMode, (0, import_utils.stringify)(other), filter, onDataSourceChange, gallery]);
87
+ return memoContent;
84
88
  };
85
89
  var View_default = View;
@@ -35,6 +35,7 @@ module.exports = __toCommonJS(useTableSetting_exports);
35
35
  var import_react = require("react");
36
36
  var import_utils = require("../Table/utils");
37
37
  var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
38
+ var import_ahooks = require("ahooks");
38
39
  var useTableSetting = (params) => {
39
40
  var _a;
40
41
  const {
@@ -199,7 +200,7 @@ var useTableSetting = (params) => {
199
200
  quickFilterMaxLength,
200
201
  sortButtonShow
201
202
  ]);
202
- const setTableSetting = (values) => {
203
+ const setTableSetting = (0, import_ahooks.useMemoizedFn)((values) => {
203
204
  const result = (0, import_utils.setFormValuesToLocalStorage)({
204
205
  tableId,
205
206
  allValues: values,
@@ -207,7 +208,7 @@ var useTableSetting = (params) => {
207
208
  currentViewMode,
208
209
  currentSettingHash
209
210
  });
210
- };
211
+ });
211
212
  const tableSetting = (0, import_react.useMemo)(() => {
212
213
  return {
213
214
  ...tableLocalSetting,
@@ -89,9 +89,9 @@ var GridView = (0, import_model.Provider)(
89
89
  const filterDefaultRef = (0, import_react.useRef)({});
90
90
  const initialValuesRef = (0, import_react.useRef)({});
91
91
  const { width } = (0, import_ahooks.useSize)(wrapRef) || {};
92
+ const debouncedWidth = (0, import_ahooks.useDebounce)(width, { wait: 500 });
92
93
  const utils = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils;
93
94
  const tableId = (0, import_react.useMemo)(() => {
94
- console.log(props, "wh");
95
95
  if (props.__designMode === "design") {
96
96
  return "designMode-mock-table-id";
97
97
  }
@@ -144,13 +144,14 @@ var GridView = (0, import_model.Provider)(
144
144
  }
145
145
  }, [currentSettingHash, tableId]);
146
146
  (0, import_react.useEffect)(() => {
147
- if (width) {
147
+ if (debouncedWidth) {
148
+ console.log("modal.dispatch", "setTableWidth");
148
149
  modal.dispatch({
149
150
  type: "setTableWidth",
150
- payload: width || {}
151
+ payload: debouncedWidth || {}
151
152
  });
152
153
  }
153
- }, [width]);
154
+ }, [debouncedWidth]);
154
155
  const { setTableSetting, tableSetting } = (0, import_useTableSetting.default)({
155
156
  tableId,
156
157
  filter,
@@ -9,6 +9,10 @@
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
 
12
+ .pisell-lowcode-table-body {
13
+ overscroll-behavior: none;
14
+ }
15
+
12
16
  .pisell-lowcode-table-thead {
13
17
  .pisell-lowcode-table-cell {
14
18
  padding: 0 14px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "1.0.397",
3
+ "version": "1.0.399",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",
@@ -64,8 +64,8 @@
64
64
  "react-virtualized-auto-sizer": "^1.0.20",
65
65
  "crypto-js": "^4.2.0",
66
66
  "@zxing/library": "0.21.2",
67
- "@pisell/utils": "1.0.37",
68
- "@pisell/date-picker": "1.0.104",
67
+ "@pisell/utils": "1.0.38",
68
+ "@pisell/date-picker": "1.0.105",
69
69
  "@pisell/icon": "0.0.10"
70
70
  },
71
71
  "peerDependencies": {