@teamix/pro 1.5.24 → 1.5.26

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.
@@ -0,0 +1,327 @@
1
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
+ 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."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
5
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
+ 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; }
7
+ 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; }
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
+ 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
+ import React, { createRef } from 'react';
11
+ import { getTargetValue } from '@teamix/utils';
12
+ import { renderCell } from './pureColumnRender';
13
+ import { renderColumnsTitle } from './columnRender';
14
+ import { ProActionGroup } from '../../actions';
15
+ import { getProFieldWidth } from '@teamix/pro-field';
16
+ import { renderCellSmartWidth } from './columnRender';
17
+ // 最大宽度
18
+ var maxColumnWidth = 600;
19
+ // 最小宽度
20
+ var minColumnWidth = 48;
21
+ // 每个列可以缩减的最大宽度
22
+ var columnShrinkMaxWidth = 100;
23
+ /**
24
+ * @param fileteredColumns
25
+ * @param ref
26
+ * @param data
27
+ * @returns
28
+ */
29
+ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSelection, actionColumnRef) {
30
+ if (!ref.current) {
31
+ return fileteredColumns;
32
+ }
33
+ var hasLockFlag = false;
34
+ var dom = ref.current;
35
+ var actionColumnDom = actionColumnRef === null || actionColumnRef === void 0 ? void 0 : actionColumnRef.current;
36
+ var childNodes = dom.children;
37
+ var finalColumns = [];
38
+ fileteredColumns.forEach(function (column, index) {
39
+ var render = column.render,
40
+ _column$valueType = column.valueType,
41
+ valueType = _column$valueType === void 0 ? 'text' : _column$valueType,
42
+ _column$autoWidth = column.autoWidth,
43
+ autoWidth = _column$autoWidth === void 0 ? true : _column$autoWidth,
44
+ actionSchema = column.actionSchema,
45
+ sortable = column.sortable,
46
+ lock = column.lock;
47
+ if (lock) {
48
+ hasLockFlag = true;
49
+ }
50
+ //@ts-ignore
51
+ var type = render === null || render === void 0 ? void 0 : render.type;
52
+ var finalType = type || valueType || '';
53
+ var shrink = fieldTypeShrink[finalType];
54
+ column.shrink = column.shrink || (shrink !== undefined ? shrink : 1);
55
+ //@ts-ignore
56
+ // if (!autoWidth) {
57
+ // finalColumns.push(column);
58
+ // return;
59
+ // }
60
+ if (actionSchema) {
61
+ // TODO 操作列暂时未处理,但是应该根据actionSchema的数量直接推测出操作列的宽度
62
+ // console.log('column', column);
63
+ column.shrink = 0;
64
+ // column.width = 280;
65
+ // console.log(
66
+ // 'actionColumnDom',
67
+ // actionColumnDom?.childNodes[0].scrollWidth,
68
+ // );
69
+ if (actionColumnDom === null || actionColumnDom === void 0 ? void 0 : actionColumnDom.childNodes[0]) {
70
+ //@ts-ignore
71
+ var width = actionColumnDom === null || actionColumnDom === void 0 ? void 0 : actionColumnDom.childNodes[0].scrollWidth;
72
+ if (width >= 280) {
73
+ width = 280;
74
+ }
75
+ column.width = defaultPaddingFixer(width, size, false);
76
+ }
77
+ finalColumns.push(column);
78
+ return;
79
+ }
80
+ // @ts-ignore
81
+ var titleWidth = childNodes[index].children[0].scrollWidth;
82
+ // @ts-ignore
83
+ if (fixedWidthTypeList[finalType]) {
84
+ // console.log(
85
+ // 'fixedWidthTypeList[finalType]',
86
+ // fixedWidthTypeList[finalType],
87
+ // );
88
+ // 固定宽度
89
+ column.width = defaultPaddingFixer(
90
+ // @ts-ignore
91
+ Math.max(titleWidth, fixedWidthTypeList[finalType]), size, index === 0 && useRowSelection);
92
+ // @ts-ignore
93
+ } else if (computeableWidthTypeList[finalType]) {
94
+ // 可计算宽度
95
+ column.width = defaultPaddingFixer(
96
+ // @ts-ignore
97
+ Math.max(titleWidth, computeableWidthTypeList[finalType](data, render)), size, index === 0 && useRowSelection);
98
+ } else {
99
+ // 直接根据 dom 计算
100
+ column.width = defaultPaddingFixer(Math.max(titleWidth,
101
+ // @ts-ignore
102
+ calcWidthWithParentDOM(childNodes[index], column.shrink)), size, index === 0 && useRowSelection);
103
+ }
104
+ if (index === 0) {
105
+ // 首列不会被挤占
106
+ column.shrink = 0;
107
+ }
108
+ finalColumns.push(column);
109
+ });
110
+ if (!hasLockFlag) {
111
+ // 如果没有锁列的情况,需要将所有列放到一屏内,此时需要将所有列放到一起计算一次
112
+ var containerWidth = dom.offsetWidth;
113
+ var comboColumns = calcMultiColumnLength(finalColumns, useRowSelection ? containerWidth - 50 : containerWidth);
114
+ return comboColumns;
115
+ }
116
+ return finalColumns;
117
+ }
118
+ export var shadowContainer = function shadowContainer(props) {
119
+ var ref = /*#__PURE__*/createRef();
120
+ var columns = props.columns,
121
+ data = props.data,
122
+ shadowContainerRef = props.shadowContainerRef;
123
+ return /*#__PURE__*/React.createElement("div", {
124
+ ref: shadowContainerRef,
125
+ className: "teamix-pro-table-shadow-container"
126
+ }, columns.map(function (column, index) {
127
+ var dataIndex = column.dataIndex,
128
+ valueType = column.valueType;
129
+ if (!(column === null || column === void 0 ? void 0 : column.actionSchema)) {
130
+ return /*#__PURE__*/React.createElement("div", {
131
+ className: "teamix-pro-table-shadow-container-columns",
132
+ key: index
133
+ }, /*#__PURE__*/React.createElement("div", null, renderColumnsTitle(column, ref)),
134
+ //@ts-ignore
135
+ !computeableWidthTypeList[valueType] &&
136
+ //@ts-ignore
137
+ !fixedWidthTypeList[valueType] && data.map(function (item, index) {
138
+ // @ts-ignore
139
+ column.smartWidth = renderCellSmartWidth(getValueFromRecord(dataIndex, item), column, index, item);
140
+ return renderCell(getValueFromRecord(dataIndex, item), column, index, item);
141
+ }));
142
+ }
143
+ }));
144
+ };
145
+ export var shadowActionColumnContainer = function shadowActionColumnContainer(columns, shadowActionColumnContainerRef) {
146
+ var actionColumn = columns.find(function (column) {
147
+ return column === null || column === void 0 ? void 0 : column.actionSchema;
148
+ });
149
+ if (actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionSchema) {
150
+ return /*#__PURE__*/React.createElement("div", {
151
+ ref: shadowActionColumnContainerRef,
152
+ className: "teamix-pro-table-action-column-shadow-container"
153
+ }, /*#__PURE__*/React.createElement(ProActionGroup, _objectSpread(_objectSpread({
154
+ type: "text"
155
+ }, actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionSchema), {}, {
156
+ context: _objectSpread({}, actionColumn === null || actionColumn === void 0 ? void 0 : actionColumn.actionSchema.context)
157
+ })));
158
+ }
159
+ };
160
+ // 计算操作列的宽度
161
+ function getValueFromRecord(dataIndex, record) {
162
+ if (!dataIndex) {
163
+ return null;
164
+ }
165
+ if (Array.isArray(dataIndex)) {
166
+ var value = dataIndex.map(function (item) {
167
+ return getTargetValue("{{".concat(item, "}}"), _objectSpread(_objectSpread({}, record), {}, {
168
+ record: record
169
+ }));
170
+ });
171
+ return value;
172
+ } else {
173
+ var result = record;
174
+ var array = dataIndex.split('.');
175
+ array.forEach(function (item) {
176
+ return result = result ? result[item] : undefined;
177
+ });
178
+ return result;
179
+ }
180
+ }
181
+ // TODO 某些可以直接算出结果的 profield 类型白名单,待补充,每个类型下支持一个函数,用当前值和渲染类型算出一个结果
182
+ export var computeableWidthTypeList = {
183
+ dateTime: function dateTime(data, render) {
184
+ var result = getProFieldWidth('dateTime', render);
185
+ // @ts-ignore
186
+ return (result === null || result === void 0 ? void 0 : result.minWidth) || 0;
187
+ }
188
+ };
189
+ // TODO 某些固定宽度的 profield 类型白名单,这里的数据可能需要综合考虑 dataFold 和 render.rows
190
+ export var fixedWidthTypeList = {
191
+ // 时间日期
192
+ // dateTime: 142,
193
+ // dateMonth: 74, // 60
194
+ // dateWeek: 74,
195
+ // date: 100,
196
+ // dateYear: 46,
197
+ // dateQuarter: 64,
198
+ // dateRange: 212,
199
+ dateWeekRange: 156,
200
+ dateMonthRange: 156,
201
+ dateYearRange: 102,
202
+ dateQuarterRange: 136,
203
+ dateTimeRange: 326,
204
+ time: 38,
205
+ timeRange: 124
206
+ };
207
+ // TODO 不同类型的 profield 的 shrink,0表示不可以省略号,数字越大越容易被挤占空间
208
+ export var fieldTypeShrink = {
209
+ tag: 0,
210
+ statusTag: 0,
211
+ statusIconTag: 0,
212
+ circle: 0,
213
+ rank: 0,
214
+ progress: 0,
215
+ money: 0,
216
+ number: 0,
217
+ percent: 0,
218
+ dateTime: 0,
219
+ ip: 0
220
+ };
221
+ function calcWidthWithParentDOM(dom, shrink) {
222
+ var childNodes = _toConsumableArray(dom.children);
223
+ childNodes.shift();
224
+ return calcSingleColumnLength(childNodes.map(function (node) {
225
+ return node.scrollWidth;
226
+ }), shrink);
227
+ }
228
+ function calcSingleColumnLength() {
229
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
230
+ var shrink = arguments.length > 1 ? arguments[1] : undefined;
231
+ if (shrink === 0) {
232
+ return Math.ceil(Math.max.apply(null, list));
233
+ }
234
+ return getConfidence90UpperBound(list);
235
+ }
236
+ /**
237
+ * 根据所有列的宽度和权重,结合总宽度,计算出各个列合适的宽度
238
+ * 目前算法:
239
+ * 当前需要的总宽度-总宽度=需要降低的宽度
240
+ * 从后往前,将shrink不为0的列,降低一些宽度到最小宽度
241
+ * 最小宽度可以用百分比去算
242
+ * TODO 当前shrink只用了0,其他的权重也要考虑一下
243
+ * @param list
244
+ * @param max
245
+ * @returns
246
+ */
247
+ function calcMultiColumnLength() {
248
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
249
+ var max = arguments.length > 1 ? arguments[1] : undefined;
250
+ var result = _toConsumableArray(list);
251
+ var targetList = [];
252
+ var needWidth = 0;
253
+ var canShrink = 0;
254
+ list.forEach(function (item) {
255
+ //@ts-ignore
256
+ needWidth += item.width;
257
+ if (item.shrink !== 0) {
258
+ targetList.push(item);
259
+ //@ts-ignore
260
+ canShrink += Math.min(item.width - minColumnWidth, columnShrinkMaxWidth);
261
+ }
262
+ });
263
+ var widthToBeRemoved = needWidth - max;
264
+ if (widthToBeRemoved <= 0) {
265
+ return list;
266
+ }
267
+ // TODO 超过的特别多直接加锁列,这个逻辑怎么设计
268
+ // 目前用可以缩小的宽度加起来比较一下
269
+ if (canShrink < widthToBeRemoved) {
270
+ list[0].lock = 'left';
271
+ if (list[list.length - 1].actionSchema) {
272
+ list[list.length - 1].lock = 'right';
273
+ }
274
+ return list;
275
+ }
276
+ //@ts-ignore
277
+ var sortedList = targetList.sort(function (a, b) {
278
+ return a.width - b.width;
279
+ });
280
+ var shrinkedWidth = 0;
281
+ for (var i = sortedList.length - 1; i >= 0; i--) {
282
+ if (shrinkedWidth >= widthToBeRemoved) {
283
+ break;
284
+ }
285
+ var singleShrinkedWidth = Math.min(sortedList[i].width - minColumnWidth, columnShrinkMaxWidth, widthToBeRemoved - shrinkedWidth);
286
+ sortedList[i].width = sortedList[i].width - singleShrinkedWidth;
287
+ shrinkedWidth += singleShrinkedWidth;
288
+ }
289
+ return result;
290
+ }
291
+ /**
292
+ * 修正内容放在table中默认的padding
293
+ * @param width
294
+ * @returns
295
+ */
296
+ function defaultPaddingFixer(width) {
297
+ var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'medium';
298
+ var half = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
299
+ return size === 'medium' ? width + (half ? 16 : 32) + 0.5 : width + (half ? 8 : 16) + 0.5;
300
+ }
301
+ function sum() {
302
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
303
+ return list.reduce(function (a, b) {
304
+ return a + b;
305
+ });
306
+ }
307
+ /**
308
+ * 假设样本正态分布,取 90% 置信区间的上界
309
+ * 当上界与最大值差距不大(目前是20)的时候,直接用最大值
310
+ * TODO 这里没考虑是否可以直接用标准差做评判依据,如标准差过大时,直接排序并展示前90%,或标准差很小时直接用最大值
311
+ * TODO 这里极限情况是不是会挂? 如:长度为9个100和2个10000,估计会挂,是否置信区间这个不靠谱。。。最差情况就直接展示90%的数据算了
312
+ */
313
+ function getConfidence90UpperBound() {
314
+ var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
315
+ var max = Math.max.apply(null, list);
316
+ var length = list.length;
317
+ var mean = sum(list) / length;
318
+ var std = Math.sqrt(sum(list.map(function (n) {
319
+ return (n - mean) * (n - mean);
320
+ })) / length);
321
+ var interval = length > 30 ? 1.65 * std / Math.sqrt(length) : 2.2622 * std / Math.sqrt(length);
322
+ var bound = Math.ceil(mean + interval);
323
+ if (max - bound < 20) {
324
+ return Math.min(max, maxColumnWidth);
325
+ }
326
+ return Math.min(bound, maxColumnWidth);
327
+ }
@@ -0,0 +1,6 @@
1
+ .theme-xconsole {
2
+ .next-menu-item-inner {
3
+ display: flex;
4
+ align-items: center;
5
+ }
6
+ }
@@ -153,8 +153,7 @@ var BaseItem = function BaseItem(props) {
153
153
  }
154
154
  var prefixCls = (0, _builtins__.usePrefixCls)('formily-item', props);
155
155
  var prefix = (0, _builtins__.usePrefixCls)();
156
- console.log('feedbackLayout', feedbackLayout);
157
- var formatChildren = feedbackLayout === 'popover' || feedbackLayout === 'hover-popover' ? /*#__PURE__*/_react.default.createElement(_components.Balloon, _objectSpread({
156
+ var formatChildren = (feedbackLayout === 'popover' || feedbackLayout === 'hover-popover') && !!feedbackText ? /*#__PURE__*/_react.default.createElement(_components.Balloon, _objectSpread({
158
157
  needAdjust: true,
159
158
  align: "t",
160
159
  closable: false,
package/lib/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.24";
33
+ declare const version = "1.5.26";
34
34
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, ProImage, hooks, nocode, templates, utils, };
package/lib/index.js CHANGED
@@ -299,7 +299,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
299
299
  if (!((_window = window) === null || _window === void 0 ? void 0 : _window.TEAMIXPRO_WITHOUT_ICON)) {
300
300
  _icon.default.setConfig(_utils.default.getTeamixIconConfig());
301
301
  }
302
- var version = '1.5.24';
302
+ var version = '1.5.26';
303
303
  // By TeamixTest
304
304
  exports.version = version;
305
305
  window.postMessage({
@@ -176,7 +176,7 @@ var ToolBar = function ToolBar(props) {
176
176
  flat: flat
177
177
  }),
178
178
  ref: toolBarRef
179
- }, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape, /*#__PURE__*/_react.default.createElement("div", {
179
+ }, !flat && !fullScreenState ? renderUnFlatShape() : renderFlatShape, toolBarAutoWidth && /*#__PURE__*/_react.default.createElement("div", {
180
180
  className: cls('shadow'),
181
181
  ref: toolBarContentRef
182
182
  }, renderFlatShape));
@@ -22,6 +22,7 @@ var _proField = require("@teamix/pro-field");
22
22
  var _actions = require("../actions");
23
23
  var _classnames = _interopRequireDefault(require("classnames"));
24
24
  var _pageContainer = _interopRequireDefault(require("../page-container"));
25
+ var _genAutoWidthColumns = require("./utils/genAutoWidthColumns");
25
26
  var _lodash = _interopRequireDefault(require("lodash.debounce"));
26
27
  var _CardView = _interopRequireDefault(require("./components/CardView"));
27
28
  var _hooks = require("@teamix/hooks");
@@ -38,7 +39,7 @@ Object.keys(_typing).forEach(function (key) {
38
39
  }
39
40
  });
40
41
  });
41
- var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "autoRefreshProps", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps", "bindUrlProps", "bindUrl", "autoRedirect", "useMaxData"],
42
+ var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "autoRefreshProps", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "autoWidth", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps", "bindUrlProps", "bindUrl", "autoRedirect", "useMaxData"],
42
43
  _excluded2 = ["onChange"];
43
44
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
44
45
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -167,6 +168,8 @@ var ProTable = function ProTable(props) {
167
168
  propsSize = _props$size === void 0 ? 'medium' : _props$size,
168
169
  disableSelectAll = props.disableSelectAll,
169
170
  context = props.context,
171
+ _props$autoWidth = props.autoWidth,
172
+ autoWidth = _props$autoWidth === void 0 ? false : _props$autoWidth,
170
173
  _props$fixedTableBody = props.fixedTableBody,
171
174
  fixedTableBody = _props$fixedTableBody === void 0 ? false : _props$fixedTableBody,
172
175
  isTree = props.isTree,
@@ -230,6 +233,14 @@ var ProTable = function ProTable(props) {
230
233
  _useState16 = _slicedToArray(_useState15, 2),
231
234
  filteredColumns = _useState16[0],
232
235
  setFilteredColumns = _useState16[1];
236
+ // 判断是否有操作列,有的话则渲染一个 shadow dom
237
+ var hasActionColumn = false;
238
+ if (autoWidth) {
239
+ hasActionColumn = filteredColumns.some(function (column) {
240
+ var _column$actionSchema, _column$actionSchema$;
241
+ return (column === null || column === void 0 ? void 0 : column.actionSchema) && ((_column$actionSchema = column.actionSchema) === null || _column$actionSchema === void 0 ? void 0 : (_column$actionSchema$ = _column$actionSchema.actions) === null || _column$actionSchema$ === void 0 ? void 0 : _column$actionSchema$.length) > 0;
242
+ });
243
+ }
233
244
  var _useState17 = (0, _react.useState)(propsSize),
234
245
  _useState18 = _slicedToArray(_useState17, 2),
235
246
  size = _useState18[0],
@@ -238,6 +249,13 @@ var ProTable = function ProTable(props) {
238
249
  _useState20 = _slicedToArray(_useState19, 2),
239
250
  showLoading = _useState20[0],
240
251
  setShowLoading = _useState20[1];
252
+ // 自动计算列宽需要的一些hook
253
+ var _useState21 = (0, _react.useState)(false),
254
+ _useState22 = _slicedToArray(_useState21, 2),
255
+ showShadowContainer = _useState22[0],
256
+ setShowShadowContainer = _useState22[1];
257
+ var shadowContainerRef = (0, _react.useRef)(null);
258
+ var shadowActionColumnContainerRef = (0, _react.useRef)(null);
241
259
  // 表格内部用作存储的 Ref,标识 Table 组件是否被第一次渲染。用作 useUrlState filter 第一次渲染时使用 state 数据请求
242
260
  var dataRef = (0, _react.useRef)({
243
261
  flag: true
@@ -258,19 +276,19 @@ var ProTable = function ProTable(props) {
258
276
  }, [currentPage, pageSize, urlState]);
259
277
  // 存储能够被 on 监听到的 ProTable 状态
260
278
  // 因为只做存储用。不需要更新视图以及需要同步更改。所以不使用 setState 更新
261
- var _useState21 = (0, _react.useState)({
279
+ var _useState23 = (0, _react.useState)({
262
280
  fullScreenState: false,
263
281
  filterRules: {},
264
282
  filterColumns: []
265
283
  }),
266
- _useState22 = _slicedToArray(_useState21, 1),
267
- actionRefState = _useState22[0];
284
+ _useState24 = _slicedToArray(_useState23, 1),
285
+ actionRefState = _useState24[0];
268
286
  // 存储 on 监听事件
269
- var _useState23 = (0, _react.useState)({
287
+ var _useState25 = (0, _react.useState)({
270
288
  fullScreenState: {}
271
289
  }),
272
- _useState24 = _slicedToArray(_useState23, 1),
273
- actionRefCallback = _useState24[0];
290
+ _useState26 = _slicedToArray(_useState25, 1),
291
+ actionRefCallback = _useState26[0];
274
292
  // 存储定时器 id
275
293
  var autoRefreshTimerRef = (0, _react.useRef)();
276
294
  var onResize = null;
@@ -382,20 +400,20 @@ var ProTable = function ProTable(props) {
382
400
  }, 50);
383
401
  };
384
402
  // header 区域高度。用作全屏计算吸顶吸底高度。默认不做计算
385
- var _useState25 = (0, _react.useState)(0),
386
- _useState26 = _slicedToArray(_useState25, 2),
387
- headerHeight = _useState26[0],
388
- setHeaderHeight = _useState26[1];
389
- // 全屏显示 className
390
- var _useState27 = (0, _react.useState)(false),
403
+ var _useState27 = (0, _react.useState)(0),
391
404
  _useState28 = _slicedToArray(_useState27, 2),
392
- fullscreenState = _useState28[0],
393
- setFullscreenState = _useState28[1];
394
- // 切换视角
395
- var _useState29 = (0, _react.useState)(defaultView !== null && defaultView !== void 0 ? defaultView : 'table'),
405
+ headerHeight = _useState28[0],
406
+ setHeaderHeight = _useState28[1];
407
+ // 全屏显示 className
408
+ var _useState29 = (0, _react.useState)(false),
396
409
  _useState30 = _slicedToArray(_useState29, 2),
397
- switchViewState = _useState30[0],
398
- setSwitchViewState = _useState30[1];
410
+ fullscreenState = _useState30[0],
411
+ setFullscreenState = _useState30[1];
412
+ // 切换视角
413
+ var _useState31 = (0, _react.useState)(defaultView !== null && defaultView !== void 0 ? defaultView : 'table'),
414
+ _useState32 = _slicedToArray(_useState31, 2),
415
+ switchViewState = _useState32[0],
416
+ setSwitchViewState = _useState32[1];
399
417
  // 切换全屏搜索开关
400
418
  var filterEnableRef = (0, _react.useRef)({
401
419
  fullscreen: false,
@@ -415,10 +433,10 @@ var ProTable = function ProTable(props) {
415
433
  var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
416
434
  // let dataFilterForm = dataFilterFormRef.current;
417
435
  // 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
418
- var _useState31 = (0, _react.useState)(false),
419
- _useState32 = _slicedToArray(_useState31, 2),
420
- footerSuctionState = _useState32[0],
421
- setFooterSuctionState = _useState32[1];
436
+ var _useState33 = (0, _react.useState)(false),
437
+ _useState34 = _slicedToArray(_useState33, 2),
438
+ footerSuctionState = _useState34[0],
439
+ setFooterSuctionState = _useState34[1];
422
440
  // TODO 获取内容区是否超出一屏(暂时仅支持全家桶)
423
441
  var getFooterSuctionState = function getFooterSuctionState() {
424
442
  if (!footerSuction) {
@@ -569,6 +587,9 @@ var ProTable = function ProTable(props) {
569
587
  setFullscreenState(state);
570
588
  getHeaderHeight(state);
571
589
  actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$s = _actionRef$current2.setState) === null || _actionRef$current2$s === void 0 ? void 0 : _actionRef$current2$s.call(_actionRef$current2, 'fullScreenState', state);
590
+ if (autoWidth) {
591
+ reGenFilteredColumnsByAutoWidth();
592
+ }
572
593
  return state;
573
594
  },
574
595
  setColumn: function setColumn(newColumns) {
@@ -580,10 +601,16 @@ var ProTable = function ProTable(props) {
580
601
  if (update) {
581
602
  (0, _utils2.emit)('refreshFilterState', newColumns);
582
603
  }
604
+ if (autoWidth) {
605
+ reGenFilteredColumnsByAutoWidth();
606
+ }
583
607
  },
584
608
  size: size,
585
609
  setSize: function setSize(mode) {
586
610
  _setSize(mode);
611
+ if (autoWidth) {
612
+ reGenFilteredColumnsByAutoWidth();
613
+ }
587
614
  },
588
615
  refresh: function refresh(params) {
589
616
  // card视角的刷新等于重新请求
@@ -693,6 +720,21 @@ var ProTable = function ProTable(props) {
693
720
  if (propsActionRef) {
694
721
  propsActionRef.current = actionRef.current;
695
722
  }
723
+ function reGenFilteredColumnsByAutoWidth() {
724
+ if (!autoWidth) {
725
+ return;
726
+ }
727
+ setShowShadowContainer(true);
728
+ var authWidthedColumns = (0, _genAutoWidthColumns.genAutoWidthColumns)(filteredColumns, shadowContainerRef, data, size, useRowSelection, shadowActionColumnContainerRef);
729
+ setFilteredColumns(authWidthedColumns);
730
+ // 移除 shadow dom
731
+ // setTimeout(() => {
732
+ // if (document.querySelector('.teamix-pro-table-shadow-container')) {
733
+ // document.querySelector('.teamix-pro-table-shadow-container')?.remove();
734
+ // }
735
+ // }, 0);
736
+ }
737
+
696
738
  function onFormatResult(next) {
697
739
  props.onFormatResult && props.onFormatResult(next);
698
740
  // 如果开启了 autoRedirect 当当前页数不为1,并且data为空的时候,重定向到第一页
@@ -732,6 +774,9 @@ var ProTable = function ProTable(props) {
732
774
  setTotal(total + (next.total || ((_next$data3 = next.data) === null || _next$data3 === void 0 ? void 0 : _next$data3.length)));
733
775
  }
734
776
  setShowSkeleton(false);
777
+ if (autoWidth) {
778
+ reGenFilteredColumnsByAutoWidth();
779
+ }
735
780
  }
736
781
  // 请求表格数据工具函数
737
782
  var getData = (0, _utils.useRequest)(function (params) {
@@ -878,6 +923,9 @@ var ProTable = function ProTable(props) {
878
923
  _setData([].concat(_toConsumableArray(data), _toConsumableArray(dataRes || [])));
879
924
  setTotal(total + (totalRes || (dataRes === null || dataRes === void 0 ? void 0 : dataRes.length)));
880
925
  }
926
+ if (autoWidth) {
927
+ reGenFilteredColumnsByAutoWidth();
928
+ }
881
929
  setShowSkeleton(false);
882
930
  setCustomTableLoading(false);
883
931
  }
@@ -1168,7 +1216,11 @@ var ProTable = function ProTable(props) {
1168
1216
  // 'footer-suction': footerSuctionState && footerSuction,
1169
1217
  }),
1170
1218
  ref: tableRef
1171
- }, renderTable(isFullScreen), fixFooterState && /*#__PURE__*/_react.default.createElement(_pageContainer.default.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
1219
+ }, showShadowContainer && (0, _genAutoWidthColumns.shadowContainer)({
1220
+ columns: filteredColumns,
1221
+ data: data,
1222
+ shadowContainerRef: shadowContainerRef
1223
+ }), hasActionColumn && (0, _genAutoWidthColumns.shadowActionColumnContainer)(filteredColumns, shadowActionColumnContainerRef), renderTable(isFullScreen), fixFooterState && /*#__PURE__*/_react.default.createElement(_pageContainer.default.FixedFooter, null, renderFooter()), !fixFooterState && renderFooter());
1172
1224
  });
1173
1225
  };
1174
1226
  var _default = ProTable;
@@ -1,3 +1,4 @@
1
+ @import "xconsole";
1
2
  $prefix: 'teamix-pro-table';
2
3
  $fullscreenPadding: 24px;
3
4
 
@@ -77,6 +78,32 @@ $fullscreenPadding: 24px;
77
78
  transition: all 0.1s;
78
79
  }
79
80
  }
81
+ &-shadow-container {
82
+ overflow: hidden;
83
+ position: absolute;
84
+ right: 0;
85
+ left: 0;
86
+ top: 0;
87
+ visibility: hidden;
88
+ pointer-events: none;
89
+ }
90
+ &-shadow-container-columns {
91
+ display: flex;
92
+ >* {
93
+ flex-shrink: 0;
94
+ }
95
+ }
96
+ &-action-column-shadow-container {
97
+ overflow: hidden;
98
+ position: absolute;
99
+ right: 0;
100
+ left: 0;
101
+ top: 0;
102
+ visibility: hidden;
103
+ pointer-events: none;
104
+ display: flex;
105
+ }
106
+
80
107
  // sort icon
81
108
  .next-table-sort.next-table-header-icon {
82
109
  line-height: 16px;
@@ -13,7 +13,7 @@ import { ProCardProps } from '../card';
13
13
  declare type IFieldRenderProps = keyof ProFieldRenderProps;
14
14
  /** 列record函数 */
15
15
  declare type ProTableCellFunProp = (value: any, index: number, record: any, ...others: any) => any;
16
- declare type ITableCellRender = {
16
+ export declare type ITableCellRender = {
17
17
  [key in IFieldRenderProps]?: ProFieldRenderProps[key] | ProTableCellFunProp;
18
18
  } | ((...other: any) => React.ReactNode);
19
19
  declare type TDataService = {
@@ -24,6 +24,10 @@ declare type TDataService = {
24
24
  };
25
25
  export declare type responsivePaginationType = 'mini' | 'small' | 'simple' | 'normal';
26
26
  export declare type ProTableColumnProps = {
27
+ /** 自动计算宽度时的被挤占的情况 */
28
+ shrink?: number;
29
+ /** 是否自动适应该列宽度 */
30
+ autoWidth?: boolean;
27
31
  /**
28
32
  * 会在 title 之后展示一个 icon,hover 之后提示一些信息
29
33
  */
@@ -65,6 +69,8 @@ export declare type ProTableColumnProps = {
65
69
  } & Omit<ColumnProps, 'filters' | 'dataIndex' | 'filtersMode' | 'children'>;
66
70
  export declare type ProColumnProps = ProTableColumnProps;
67
71
  export declare type ProTableProps = {
72
+ /** 表格是否自适应宽度 */
73
+ autoWidth?: boolean;
68
74
  /** ProColums 定义,取代 Table 的 columns */
69
75
  columns: ProTableColumnProps[];
70
76
  /** 请求地址 */
@@ -11,3 +11,4 @@ export declare const renderColumnsTitle: (item: ProTableColumnProps, actionRef:
11
11
  * 负责单元格的具体渲染
12
12
  */
13
13
  export declare const renderCell: (value: any, item: ProTableColumnProps, index: number, record: any, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any, dataTeamixSpm?: string) => JSX.Element;
14
+ export declare const renderCellSmartWidth: (value: any, item: ProTableColumnProps, index: number, record: any) => 0 | import("@teamix/pro-field/lib/autoWidth/typing").ProFieldAutoWidthPropsItem;