@pisell/materials 2.2.20 → 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.
Files changed (40) hide show
  1. package/build/lowcode/assets-daily.json +11 -11
  2. package/build/lowcode/assets-dev.json +2 -2
  3. package/build/lowcode/assets-prod.json +11 -11
  4. package/build/lowcode/index.js +1 -1
  5. package/build/lowcode/meta.js +1 -1
  6. package/build/lowcode/preview.js +4 -4
  7. package/build/lowcode/render/default/view.css +1 -1
  8. package/build/lowcode/render/default/view.js +12 -12
  9. package/build/lowcode/view.css +1 -1
  10. package/build/lowcode/view.js +15 -15
  11. package/es/components/page/index.js +4 -2
  12. package/es/components/table/BasicTable/index.js +5 -3
  13. package/es/components/table/Table/fields/rangePicker/Edit/index.js +13 -11
  14. package/es/components/table/Table/index.d.ts +2 -2
  15. package/es/components/table/Table/index.js +66 -41
  16. package/es/components/table/Table/index.less +3 -0
  17. package/es/components/table/Table/utils.d.ts +1 -1
  18. package/es/components/table/View/index.d.ts +2 -2
  19. package/es/components/table/View/index.js +27 -16
  20. package/es/components/table/hooks/useGenScroll.js +1 -1
  21. package/es/components/table/hooks/useTableSetting.js +3 -2
  22. package/es/components/table/hooks/useTransDataSource.js +2 -2
  23. package/es/components/table/index.js +7 -5
  24. package/es/components/table/index.less +9 -0
  25. package/lib/components/page/index.js +3 -2
  26. package/lib/components/table/BasicTable/index.js +2 -3
  27. package/lib/components/table/Table/fields/rangePicker/Edit/index.js +1 -9
  28. package/lib/components/table/Table/index.d.ts +2 -2
  29. package/lib/components/table/Table/index.js +59 -33
  30. package/lib/components/table/Table/index.less +3 -0
  31. package/lib/components/table/Table/utils.d.ts +1 -1
  32. package/lib/components/table/View/index.d.ts +2 -2
  33. package/lib/components/table/View/index.js +28 -19
  34. package/lib/components/table/hooks/useGenScroll.js +1 -1
  35. package/lib/components/table/hooks/useTableSetting.js +3 -2
  36. package/lib/components/table/hooks/useTransDataSource.js +1 -1
  37. package/lib/components/table/index.js +4 -4
  38. package/lib/components/table/index.less +9 -0
  39. package/lowcode/page/meta.ts +1 -0
  40. package/package.json +1 -1
@@ -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];
@@ -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
- }, [responsive, tableProps.pagination]);
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
- import_SortRow.default,
133
+ AutoSizerContent,
155
134
  {
156
- rowKey: tableProps.rowKey,
157
- onSortChange: tableProps.onSortChange
158
- },
159
- /* @__PURE__ */ import_react.default.createElement(
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: scroll == null ? void 0 : scroll.y,
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: _paginationConfig
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);
@@ -29,4 +29,7 @@
29
29
 
30
30
  .materials-grid-table-wrap {
31
31
  flex: 1;
32
+ // 使用overflow hidden 计算 materials-grid-table-wrap高度时不会动态变更
33
+ overflow: hidden;
34
+ padding-bottom: 24px;
32
35
  }
@@ -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
- }) => ("view_mode" | "column_setting" | "order_by" | "group_by" | "gallery_setting" | "filter_setting")[];
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 "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,8 @@ 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");
40
+ var import_ahooks = require("ahooks");
39
41
  var View = (props) => {
40
42
  const {
41
43
  dataSource,
@@ -62,24 +64,31 @@ var View = (props) => {
62
64
  form,
63
65
  preserve: true
64
66
  });
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
- ));
67
+ const debouncedFilter = (0, import_ahooks.useDebounce)(filter, { wait: 200 });
68
+ const memoOnDataSourceChange = (0, import_ahooks.useMemoizedFn)(
69
+ (v) => onDataSourceChange == null ? void 0 : onDataSourceChange(v)
70
+ );
71
+ const memoContent = (0, import_react.useMemo)(() => {
72
+ return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, viewMode === "grid" && /* @__PURE__ */ import_react.default.createElement(
73
+ import_Table.default,
74
+ {
75
+ tableProps: other,
76
+ filter,
77
+ setTableSetting,
78
+ onDataSourceChange: memoOnDataSourceChange
79
+ }
80
+ ), viewMode === "gallery" && /* @__PURE__ */ import_react.default.createElement(
81
+ import_Gallery.default,
82
+ {
83
+ loading: other == null ? void 0 : other.loading,
84
+ gallery,
85
+ pagination: other.pagination,
86
+ filter,
87
+ rowKey: other.rowKey,
88
+ onDataSourceChange: memoOnDataSourceChange
89
+ }
90
+ ));
91
+ }, [viewMode, (0, import_utils.stringify)(other), debouncedFilter, memoOnDataSourceChange, gallery]);
92
+ return memoContent;
84
93
  };
85
94
  var View_default = View;
@@ -31,7 +31,7 @@ var useGenScroll = (params) => {
31
31
  x: (propsScroll == null ? void 0 : propsScroll.x) || columns.reduce((p, c) => {
32
32
  return p + (c.width || 250);
33
33
  }, 0) || 2e3,
34
- y: (propsScroll == null ? void 0 : propsScroll.y) || Math.max(wrapHeight - 48 - (isShowPagination ? 50 + 24 : 0), 100),
34
+ y: (propsScroll == null ? void 0 : propsScroll.y) || Math.max(wrapHeight - 48 - (isShowPagination ? 50 + 24 : 24), 100),
35
35
  scrollToFirstRowOnChange: propsScroll == null ? void 0 : propsScroll.scrollToFirstRowOnChange
36
36
  };
37
37
  }
@@ -24,6 +24,7 @@ __export(useTableSetting_exports, {
24
24
  module.exports = __toCommonJS(useTableSetting_exports);
25
25
  var import_react = require("react");
26
26
  var import_utils = require("../Table/utils");
27
+ var import_ahooks = require("ahooks");
27
28
  var useTableSetting = (params) => {
28
29
  const {
29
30
  tableId,
@@ -185,7 +186,7 @@ var useTableSetting = (params) => {
185
186
  quickFilterMaxLength,
186
187
  sortButtonShow
187
188
  ]);
188
- const setTableSetting = (values) => {
189
+ const setTableSetting = (0, import_ahooks.useMemoizedFn)((values) => {
189
190
  (0, import_utils.setFormValuesToLocalStorage)({
190
191
  tableId,
191
192
  allValues: values,
@@ -193,7 +194,7 @@ var useTableSetting = (params) => {
193
194
  currentViewMode,
194
195
  currentSettingHash
195
196
  });
196
- };
197
+ });
197
198
  const tableSetting = (0, import_react.useMemo)(() => {
198
199
  return {
199
200
  ...tableLocalSetting,
@@ -60,7 +60,7 @@ var useTransDataSource = (params) => {
60
60
  return [];
61
61
  }
62
62
  return filter == null ? void 0 : filter.list.filter((item) => item.localFilter);
63
- }, [filter]);
63
+ }, [(0, import_utils2.stringify)(filter)]);
64
64
  const dataSource = (0, import_react.useMemo)(() => {
65
65
  if (!localPagination) {
66
66
  return pDataSource;
@@ -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: 100 });
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,13 @@ 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
148
  modal.dispatch({
149
149
  type: "setTableWidth",
150
- payload: width || {}
150
+ payload: debouncedWidth || {}
151
151
  });
152
152
  }
153
- }, [width]);
153
+ }, [debouncedWidth]);
154
154
  const { setTableSetting, tableSetting } = (0, import_useTableSetting.default)({
155
155
  tableId,
156
156
  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;
@@ -25,6 +25,7 @@ const PageMeta: ComponentMetadata = {
25
25
  ],
26
26
  supports: {
27
27
  style: true,
28
+ className: true,
28
29
  },
29
30
  component: {
30
31
  isContainer: true,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pisell/materials",
3
- "version": "2.2.20",
3
+ "version": "2.2.22",
4
4
  "main": "./lib/index.js",
5
5
  "module": "./es/index.js",
6
6
  "types": "./lib/index.d.ts",