@teamix/pro 1.5.33 → 1.5.35

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 (69) hide show
  1. package/dist/pro.all.min.css +1 -1
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +1246 -620
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/dist/pro.xconsole.min.css +1 -1
  7. package/es/form/Components/FormItem2/index.js +0 -1
  8. package/es/form/Components/SelectTable2/index.d.ts +97 -0
  9. package/es/form/Components/SelectTable2/index.js +39 -0
  10. package/es/form/Filter/AdvancedFilter.js +39 -18
  11. package/es/form/ProForm/index.js +3 -1
  12. package/es/form/SchemaForm/adapterDecorator.js +1 -1
  13. package/es/form/SchemaForm/adapterType.js +2 -1
  14. package/es/form/typing.d.ts +12 -0
  15. package/es/global.scss +9 -0
  16. package/es/index.d.ts +1 -1
  17. package/es/index.js +1 -1
  18. package/es/table/components/Cell/index.d.ts +18 -0
  19. package/es/table/components/Cell/index.js +219 -0
  20. package/es/table/components/Filter/index.js +0 -1
  21. package/es/table/components/Layout/index.js +9 -7
  22. package/es/table/components/Pagination/index.d.ts +5 -4
  23. package/es/table/components/Pagination/index.js +5 -3
  24. package/es/table/components/TableContent/index.d.ts +7 -0
  25. package/es/table/components/TableContent/index.js +23 -0
  26. package/es/table/components/ToolBar/FilterColumnIcon.js +14 -6
  27. package/es/table/index.js +127 -127
  28. package/es/table/index.scss +11 -2
  29. package/es/table/typing.d.ts +9 -2
  30. package/es/table/utils/genAutoWidthColumns.d.ts +2 -2
  31. package/es/table/utils/genAutoWidthColumns.js +65 -16
  32. package/es/table/utils/genProColumnToColumn.d.ts +1 -1
  33. package/es/table/utils/genProColumnToColumn.js +43 -4
  34. package/es/table/utils/processColumns.d.ts +8 -0
  35. package/es/table/utils/processColumns.js +39 -0
  36. package/es/table/utils/useTableSelection.js +54 -5
  37. package/es/xconsole.scss +4 -4
  38. package/lib/form/Components/FormItem2/index.js +0 -1
  39. package/lib/form/Components/SelectTable2/index.d.ts +97 -0
  40. package/lib/form/Components/SelectTable2/index.js +47 -0
  41. package/lib/form/Filter/AdvancedFilter.js +39 -18
  42. package/lib/form/ProForm/index.js +3 -1
  43. package/lib/form/SchemaForm/adapterDecorator.js +1 -1
  44. package/lib/form/SchemaForm/adapterType.js +2 -1
  45. package/lib/form/typing.d.ts +12 -0
  46. package/lib/global.scss +9 -0
  47. package/lib/index.d.ts +1 -1
  48. package/lib/index.js +1 -1
  49. package/lib/table/components/Cell/index.d.ts +18 -0
  50. package/lib/table/components/Cell/index.js +224 -0
  51. package/lib/table/components/Filter/index.js +0 -1
  52. package/lib/table/components/Layout/index.js +8 -6
  53. package/lib/table/components/Pagination/index.d.ts +5 -4
  54. package/lib/table/components/Pagination/index.js +4 -2
  55. package/lib/table/components/TableContent/index.d.ts +7 -0
  56. package/lib/table/components/TableContent/index.js +34 -0
  57. package/lib/table/components/ToolBar/FilterColumnIcon.js +14 -6
  58. package/lib/table/index.js +129 -129
  59. package/lib/table/index.scss +11 -2
  60. package/lib/table/typing.d.ts +9 -2
  61. package/lib/table/utils/genAutoWidthColumns.d.ts +2 -2
  62. package/lib/table/utils/genAutoWidthColumns.js +64 -15
  63. package/lib/table/utils/genProColumnToColumn.d.ts +1 -1
  64. package/lib/table/utils/genProColumnToColumn.js +42 -3
  65. package/lib/table/utils/processColumns.d.ts +8 -0
  66. package/lib/table/utils/processColumns.js +46 -0
  67. package/lib/table/utils/useTableSelection.js +57 -5
  68. package/lib/xconsole.scss +4 -4
  69. package/package.json +1 -1
@@ -8,7 +8,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
8
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
9
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
10
  import React, { createRef } from 'react';
11
- import { getTargetValue } from '@teamix/utils';
11
+ import { getTargetValue, _ } from '@teamix/utils';
12
12
  import { renderCell } from './pureColumnRender';
13
13
  import { renderColumnsTitle } from './columnRender';
14
14
  import { ProActionGroup } from '../../actions';
@@ -26,21 +26,25 @@ var columnShrinkMaxWidth = 100;
26
26
  * @param data
27
27
  * @returns
28
28
  */
29
- export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSelection, actionColumnRef) {
30
- if (!ref.current) {
31
- return fileteredColumns;
29
+ export function genAutoWidthColumns(columns, ref, data, size, useRowSelection, actionColumnRef) {
30
+ if (!(ref === null || ref === void 0 ? void 0 : ref.current)) {
31
+ return columns;
32
32
  }
33
33
  var hasLockFlag = false;
34
34
  var dom = ref.current;
35
35
  var actionColumnDom = actionColumnRef === null || actionColumnRef === void 0 ? void 0 : actionColumnRef.current;
36
36
  var childNodes = dom.children;
37
+ if (dom.children.length === 0) {
38
+ return columns;
39
+ }
37
40
  var finalColumns = [];
38
- fileteredColumns.forEach(function (column, index) {
41
+ var filterdColumnsResult = _.cloneDeep(columns);
42
+ filterdColumnsResult.forEach(function (column, index) {
39
43
  var render = column.render,
40
44
  _column$valueType = column.valueType,
41
45
  valueType = _column$valueType === void 0 ? 'text' : _column$valueType,
42
- _column$autoWidth = column.autoWidth,
43
- autoWidth = _column$autoWidth === void 0 ? true : _column$autoWidth,
46
+ _column$isAutoWidth = column.isAutoWidth,
47
+ isAutoWidth = _column$isAutoWidth === void 0 ? true : _column$isAutoWidth,
44
48
  actionSchema = column.actionSchema,
45
49
  sortable = column.sortable,
46
50
  lock = column.lock;
@@ -52,6 +56,17 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
52
56
  var finalType = type || valueType || '';
53
57
  var shrink = fieldTypeShrink[finalType];
54
58
  column.shrink = column.shrink || (shrink !== undefined ? shrink : 1);
59
+ if ((column === null || column === void 0 ? void 0 : column.isAutoWidth) === false) {
60
+ // console.log(column.title, 'isAutoWidth')
61
+ finalColumns.push(column);
62
+ return;
63
+ }
64
+ ;
65
+ if ((column === null || column === void 0 ? void 0 : column.columnFilters) === false) {
66
+ finalColumns.push(column);
67
+ return;
68
+ }
69
+ // column.isAutoWidth = true
55
70
  //@ts-ignore
56
71
  // if (!autoWidth) {
57
72
  // finalColumns.push(column);
@@ -72,13 +87,20 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
72
87
  if (width >= 280) {
73
88
  width = 280;
74
89
  }
90
+ column.isAutoWidth = false;
75
91
  column.width = defaultPaddingFixer(width, size, false);
76
92
  }
77
93
  finalColumns.push(column);
78
94
  return;
79
95
  }
96
+ // 当列没出来的时候不比较
97
+ // @ts-ignore
98
+ if ((column === null || column === void 0 ? void 0 : column.columnFilters) === false) {
99
+ finalColumns.push(column);
100
+ return;
101
+ }
80
102
  // @ts-ignore
81
- var titleWidth = childNodes[index].children[0].scrollWidth;
103
+ var titleWidth = _.get(childNodes, '[index]?.children[0].scrollWidth', 0);
82
104
  // @ts-ignore
83
105
  if (fixedWidthTypeList[finalType]) {
84
106
  // console.log(
@@ -86,20 +108,37 @@ export function genAutoWidthColumns(fileteredColumns, ref, data, size, useRowSel
86
108
  // fixedWidthTypeList[finalType],
87
109
  // );
88
110
  // 固定宽度
111
+ // console.log(column.title, '固定宽度')
112
+ column.isAutoWidth = false;
89
113
  column.width = defaultPaddingFixer(
90
114
  // @ts-ignore
91
115
  Math.max(titleWidth, fixedWidthTypeList[finalType]), size, index === 0 && useRowSelection);
92
116
  // @ts-ignore
93
117
  } else if (computeableWidthTypeList[finalType]) {
94
118
  // 可计算宽度
119
+ // console.log(column.title, '可计算宽度')
120
+ column.isAutoWidth = false;
95
121
  column.width = defaultPaddingFixer(
96
122
  // @ts-ignore
97
123
  Math.max(titleWidth, computeableWidthTypeList[finalType](data, render)), size, index === 0 && useRowSelection);
98
124
  } else {
125
+ var _column$render;
99
126
  // 直接根据 dom 计算
127
+ // console.log(column.title, '可计算 dom')
128
+ column.isAutoWidth = false;
100
129
  column.width = defaultPaddingFixer(Math.max(titleWidth,
101
130
  // @ts-ignore
102
131
  calcWidthWithParentDOM(childNodes[index], column.shrink)), size, index === 0 && useRowSelection);
132
+ if ((column === null || column === void 0 ? void 0 : column.sortable) && ((column === null || column === void 0 ? void 0 : column.tooltip) || (column === null || column === void 0 ? void 0 : column.filters))) {
133
+ // 检测有 sortable 和 tooltip 的时候增加宽度
134
+ column.width = column.width + 40;
135
+ } else if (column === null || column === void 0 ? void 0 : column.sortable) {
136
+ column.width = column.width + 24;
137
+ }
138
+ // @ts-ignore
139
+ if (column === null || column === void 0 ? void 0 : (_column$render = column.render) === null || _column$render === void 0 ? void 0 : _column$render.copy) {
140
+ column.width = column.width + 16;
141
+ }
103
142
  }
104
143
  if (index === 0) {
105
144
  // 首列不会被挤占
@@ -120,6 +159,7 @@ export var shadowContainer = function shadowContainer(props) {
120
159
  var columns = props.columns,
121
160
  data = props.data,
122
161
  shadowContainerRef = props.shadowContainerRef;
162
+ if (data.length === 0) return null;
123
163
  return /*#__PURE__*/React.createElement("div", {
124
164
  ref: shadowContainerRef,
125
165
  className: "teamix-pro-table-shadow-container"
@@ -136,8 +176,12 @@ export var shadowContainer = function shadowContainer(props) {
136
176
  //@ts-ignore
137
177
  !fixedWidthTypeList[valueType] && data.map(function (item, index) {
138
178
  // @ts-ignore
139
- column.smartWidth = renderCellSmartWidth(getValueFromRecord(dataIndex, item), column, index, item);
140
- return renderCell(getValueFromRecord(dataIndex, item), column, index, item);
179
+ var newColumn = _.cloneDeep(column);
180
+ newColumn.smartWidth = renderCellSmartWidth(getValueFromRecord(dataIndex, item), column, index, item);
181
+ newColumn.render = _objectSpread(_objectSpread({}, column.render), {}, {
182
+ description: ''
183
+ });
184
+ return renderCell(getValueFromRecord(dataIndex, item), newColumn, index, item);
141
185
  }));
142
186
  }
143
187
  }));
@@ -219,11 +263,15 @@ export var fieldTypeShrink = {
219
263
  ip: 0
220
264
  };
221
265
  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);
266
+ if (dom) {
267
+ var childNodes = _toConsumableArray(dom.children);
268
+ childNodes.shift();
269
+ return calcSingleColumnLength(childNodes.map(function (node) {
270
+ return node.scrollWidth;
271
+ }), shrink);
272
+ } else {
273
+ return 0;
274
+ }
227
275
  }
228
276
  function calcSingleColumnLength() {
229
277
  var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
@@ -300,7 +348,8 @@ function defaultPaddingFixer(width) {
300
348
  }
301
349
  function sum() {
302
350
  var list = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
303
- return list.reduce(function (a, b) {
351
+ if (list.length === 0) return 0;
352
+ return list === null || list === void 0 ? void 0 : list.reduce(function (a, b) {
304
353
  return a + b;
305
354
  });
306
355
  }
@@ -9,5 +9,5 @@ declare type FixedColumnProps = ColumnProps & {
9
9
  */
10
10
  export default function genProColumnToColumn(columns: ProTableColumnProps[],
11
11
  /** 是否渲染骨架屏 */
12
- showSkeleton: boolean, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any, dataTeamixSpm?: string, bindUrl?: ProTableProps['bindUrl'], bindUrlProps?: ProTableProps['bindUrlProps']): FixedColumnProps[];
12
+ showSkeleton: boolean, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any, dataTeamixSpm?: string, bindUrl?: ProTableProps['bindUrl'], bindUrlProps?: ProTableProps['bindUrlProps'], forcedUpdate?: boolean): FixedColumnProps[];
13
13
  export {};
@@ -1,13 +1,15 @@
1
1
  var _excluded = ["filters", "dataIndex", "children"];
2
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
2
3
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
4
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
6
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
7
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
7
8
  import React from 'react';
8
- import { renderColumnsTitle, renderCell } from './columnRender';
9
+ import { renderColumnsTitle } from './columnRender';
9
10
  import { ProSkeletonRaw as Skeleton } from '../../skeleton';
10
11
  import { getLanguage } from '@teamix/utils';
12
+ import Cell from '../components/Cell';
11
13
  /**
12
14
  * ProColumn => Column
13
15
  */
@@ -19,6 +21,9 @@ showSkeleton, actionRef) {
19
21
  dataTeamixSpm = arguments.length > 4 ? arguments[4] : undefined;
20
22
  var bindUrl = arguments.length > 5 ? arguments[5] : undefined;
21
23
  var bindUrlProps = arguments.length > 6 ? arguments[6] : undefined;
24
+ var
25
+ // 是否强制刷新
26
+ forcedUpdate = arguments.length > 7 ? arguments[7] : undefined;
22
27
  return columns.map(function (columnProps) {
23
28
  var filters = columnProps.filters,
24
29
  dataIndex = columnProps.dataIndex,
@@ -30,8 +35,24 @@ showSkeleton, actionRef) {
30
35
  sortable: false,
31
36
  dataIndex: dataIndex === null || dataIndex === void 0 ? void 0 : dataIndex.toString(),
32
37
  title: /*#__PURE__*/React.createElement(Skeleton.Table.TH, null),
33
- cell: function cell() {
34
- return /*#__PURE__*/React.createElement(Skeleton.Table.TD, null);
38
+ cell: function cell(value, rowIndex) {
39
+ var _columnProps$render;
40
+ // 按默认5行做渐变
41
+ var opacity = Math.min(Math.max(1 - rowIndex * 0.2, 0), 1);
42
+ // 如果是field并且有descrition字段,就认为是两行,其他情况默认一行
43
+ return _typeof(columnProps === null || columnProps === void 0 ? void 0 : columnProps.render) === 'object' && (columnProps === null || columnProps === void 0 ? void 0 : (_columnProps$render = columnProps.render) === null || _columnProps$render === void 0 ? void 0 : _columnProps$render.description) ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(Skeleton.Table.TD, {
44
+ style: {
45
+ opacity: opacity
46
+ }
47
+ }), /*#__PURE__*/React.createElement(Skeleton.Table.TD, {
48
+ style: {
49
+ opacity: opacity
50
+ }
51
+ })) : /*#__PURE__*/React.createElement(Skeleton.Table.TD, {
52
+ style: {
53
+ opacity: opacity
54
+ }
55
+ });
35
56
  }
36
57
  });
37
58
  }
@@ -44,7 +65,25 @@ showSkeleton, actionRef) {
44
65
  dataIndex: dataIndex === null || dataIndex === void 0 ? void 0 : dataIndex.toString(),
45
66
  title: renderColumnsTitle(columnProps, actionRef, bindUrl, bindUrlProps),
46
67
  cell: function cell(value, index, record) {
47
- return renderCell(value, columnProps, index, record, actionRef, context, dataTeamixSpm);
68
+ return /*#__PURE__*/React.createElement(Cell, {
69
+ value: value,
70
+ item: columnProps,
71
+ index: index,
72
+ record: record,
73
+ actionRef: actionRef,
74
+ context: context,
75
+ dataTeamixSpm: dataTeamixSpm,
76
+ forcedUpdate: forcedUpdate
77
+ });
78
+ // return renderCell(
79
+ // value,
80
+ // columnProps,
81
+ // index,
82
+ // record,
83
+ // actionRef,
84
+ // context,
85
+ // dataTeamixSpm
86
+ // )
48
87
  }
49
88
  });
50
89
  });
@@ -0,0 +1,8 @@
1
+ import { ProTableColumnProps } from '../typing';
2
+ /**
3
+ * 处理原生传入的 columns 以便于 选择列 方便处理
4
+ * @param columns 原生传入的 columns
5
+ * @returns
6
+ */
7
+ declare const processColumns: (columns: ProTableColumnProps[], initialColumns: ProTableColumnProps[]) => ProTableColumnProps[];
8
+ export default processColumns;
@@ -0,0 +1,39 @@
1
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
+ 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; }
4
+ import { getGlobalConfig } from '@teamix/utils';
5
+ /**
6
+ * 处理原生传入的 columns 以便于 选择列 方便处理
7
+ * @param columns 原生传入的 columns
8
+ * @returns
9
+ */
10
+ var processColumns = function processColumns(columns, initialColumns) {
11
+ var _getGlobalConfig;
12
+ var globalFilterColumns = (_getGlobalConfig = getGlobalConfig('ProTable')) === null || _getGlobalConfig === void 0 ? void 0 : _getGlobalConfig.filterColumns;
13
+ var filterColumns = columns.filter(function (item) {
14
+ return item.columnFilters !== false && (item === null || item === void 0 ? void 0 : item.hidden) !== true && (!globalFilterColumns || globalFilterColumns(_objectSpread({}, item)));
15
+ });
16
+ // 处理只剩一列批量选择的情况下宽度错乱问题
17
+ if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
18
+ var _initialColumns$;
19
+ if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
20
+ var _filterColumns$, _filterColumns$2;
21
+ if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
22
+ delete filterColumns[0].width;
23
+ }
24
+ if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
25
+ filterColumns[0].lock = false;
26
+ }
27
+ } else if (((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.columnFilters) !== false) {
28
+ var _initialColumns$2, _initialColumns$3;
29
+ if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.width) {
30
+ filterColumns[0].width = initialColumns[0].width;
31
+ }
32
+ if ((_initialColumns$3 = initialColumns[0]) === null || _initialColumns$3 === void 0 ? void 0 : _initialColumns$3.lock) {
33
+ filterColumns[0].lock = initialColumns[0].lock;
34
+ }
35
+ }
36
+ }
37
+ return filterColumns;
38
+ };
39
+ export default processColumns;
@@ -1,6 +1,9 @@
1
+ var _excluded = ["primaryKey"];
1
2
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
2
3
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
3
4
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
6
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
4
7
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
5
8
  function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
9
  function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
@@ -15,20 +18,26 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
18
  * 处理表格 rowSelection hooks
16
19
  * 除了基本 rowSelection 之外返回平铺后的 selectedRowKeys、selectedRecords
17
20
  */
18
- import { useState } from 'react';
21
+ import React, { useState } from 'react';
19
22
  import { getDeepValue } from '@teamix/utils';
23
+ import { Balloon, Checkbox } from '@alicloudfe/components';
24
+ var Tooltip = Balloon.Tooltip;
20
25
  function useTableSelection() {
21
26
  var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
22
27
  var primaryKey = arguments.length > 1 ? arguments[1] : undefined;
23
- var _useState = useState([]),
28
+ var _config$defaultSelect = config.defaultSelectedRecords,
29
+ defaultSelectedRecords = _config$defaultSelect === void 0 ? [] : _config$defaultSelect,
30
+ _config$defaultSelect2 = config.defaultSelectedRowKeys,
31
+ defaultSelectedRowKeys = _config$defaultSelect2 === void 0 ? [] : _config$defaultSelect2;
32
+ var _useState = useState(defaultSelectedRowKeys),
24
33
  _useState2 = _slicedToArray(_useState, 2),
25
34
  selectedRowKeys = _useState2[0],
26
35
  setSelectedRowKeys = _useState2[1];
27
- var _useState3 = useState([]),
36
+ var _useState3 = useState(defaultSelectedRecords),
28
37
  _useState4 = _slicedToArray(_useState3, 2),
29
38
  selectedRecords = _useState4[0],
30
39
  setSelectedRecords = _useState4[1];
31
- function onChange(value, records) {
40
+ function _onChange(value, records) {
32
41
  if (primaryKey) {
33
42
  var newValue = value.filter(function (v) {
34
43
  return !selectedRowKeys.includes(v);
@@ -63,11 +72,51 @@ function useTableSelection() {
63
72
  config.onChange(value, records);
64
73
  }
65
74
  }
75
+ var renderCheckBox = function renderCheckBox(props) {
76
+ var primaryKey = props.primaryKey,
77
+ others = _objectWithoutProperties(props, _excluded);
78
+ return /*#__PURE__*/React.createElement(Checkbox, _objectSpread({
79
+ checked: selectedRowKeys.includes(primaryKey),
80
+ onChange: function onChange(checked) {
81
+ if (checked) {
82
+ _onChange === null || _onChange === void 0 ? void 0 : _onChange([].concat(_toConsumableArray(selectedRowKeys), [primaryKey]), [props]);
83
+ } else {
84
+ _onChange === null || _onChange === void 0 ? void 0 : _onChange(selectedRowKeys.filter(function (item) {
85
+ return item !== primaryKey;
86
+ }), [props]);
87
+ }
88
+ }
89
+ }, others));
90
+ };
91
+ var getProps = function getProps(record, index) {
92
+ var _config$getProps;
93
+ var propResult = config === null || config === void 0 ? void 0 : (_config$getProps = config.getProps) === null || _config$getProps === void 0 ? void 0 : _config$getProps.call(config, record, index);
94
+ // console.log('propResult', propResult, selectedRowKeys);
95
+ var resultProps = _objectSpread(_objectSpread({}, record), propResult);
96
+ var primaryKey = record === null || record === void 0 ? void 0 : record[resultProps === null || resultProps === void 0 ? void 0 : resultProps['_primaryKey']];
97
+ return _objectSpread(_objectSpread({}, resultProps), {}, {
98
+ isPreview: true,
99
+ renderPreview: function renderPreview() {
100
+ if (resultProps.disabled === true && resultProps.disabledTooltip) {
101
+ return /*#__PURE__*/React.createElement(Tooltip, {
102
+ trigger: renderCheckBox(_objectSpread(_objectSpread({}, propResult), {}, {
103
+ primaryKey: primaryKey
104
+ })),
105
+ align: "t"
106
+ }, propResult.disabledTooltip);
107
+ }
108
+ return renderCheckBox(_objectSpread(_objectSpread({}, propResult), {}, {
109
+ primaryKey: primaryKey
110
+ }));
111
+ }
112
+ });
113
+ };
66
114
  var rowSelection = _objectSpread(_objectSpread({
67
115
  selectedRowKeys: selectedRowKeys,
68
116
  selectedRecords: selectedRecords
69
117
  }, config), {}, {
70
- onChange: onChange
118
+ onChange: _onChange,
119
+ getProps: getProps
71
120
  });
72
121
  return {
73
122
  rowSelection: rowSelection,
package/es/xconsole.scss CHANGED
@@ -16,15 +16,15 @@
16
16
  --color-error-9: rgba(125, 18, 7, 1);
17
17
  --color-error-8: rgba(161, 31, 19, 1);
18
18
  --color-error-7: rgba(196, 49, 35, 1);
19
- --color-error-5: rgba(237, 103, 90, 1);
20
- --color-error-6: rgba(232, 71, 56, 1);
19
+ --color-error-5: #C80000;
20
+ --color-error-6: #C80000;
21
21
  --color-error-4: rgba(242, 136, 126, 1);
22
22
  --color-error-1: rgba(255, 236, 235, 1);
23
23
  --color-warning-10: rgba(82, 42, 0, 1);
24
24
  --color-warning-9: rgba(119, 65, 6, 1);
25
25
  --color-warning-8: rgba(163, 90, 10, 1);
26
26
  --color-warning-7: rgba(207, 116, 18, 1);
27
- --color-warning-5: rgba(247, 168, 84, 1);
27
+ --color-warning-5: #FAC800;
28
28
  --color-warning-6: rgba(249, 142, 26, 1);
29
29
  --color-warning-4: rgba(255, 185, 110, 1);
30
30
  --color-warning-1: rgba(255, 245, 235, 1);
@@ -33,7 +33,7 @@
33
33
  --color-success-8: rgba(10, 130, 67, 1);
34
34
  --color-success-7: rgba(21, 153, 83, 1);
35
35
  --color-success-5: rgba(67, 191, 126, 1);
36
- --color-success-6: rgba(35, 176, 102, 1);
36
+ --color-success-6: #00A700;
37
37
  --color-success-4: rgba(103, 207, 152, 1);
38
38
  --color-success-2: rgba(209, 244, 225, 1);
39
39
  --color-success-1: rgba(235, 255, 246, 1);
@@ -88,7 +88,6 @@ var ICON_MAP = {
88
88
  };
89
89
  var BaseItem = function BaseItem(props) {
90
90
  var _cls, _cls3, _cls4, _cls5, _cls6;
91
- console.log('FormItem2');
92
91
  var children = props.children,
93
92
  others = _objectWithoutProperties(props, _excluded);
94
93
  var _useState3 = (0, _react.useState)(false),
@@ -0,0 +1,97 @@
1
+ import React from 'react';
2
+ declare const SelectTable2: React.ForwardRefExoticComponent<Partial<{
3
+ field: any;
4
+ } & {
5
+ autoWidth?: boolean | undefined;
6
+ columns: import("../../../table").ProTableColumnProps[];
7
+ url?: string | undefined;
8
+ method?: import("axios").Method | undefined;
9
+ params?: {
10
+ [propName: string]: any;
11
+ } | undefined;
12
+ formatSort?: ((sort: object) => object) | undefined;
13
+ formatParams?: string | ((params: any) => any) | undefined;
14
+ formatResult?: string | {
15
+ total?: string | number | undefined;
16
+ data?: any;
17
+ } | ((res: any) => {
18
+ total?: string | number | undefined;
19
+ data?: any;
20
+ }) | undefined;
21
+ onFormatResult?: ((data: any[]) => void) | undefined;
22
+ requestWhenMount?: boolean | undefined;
23
+ onSuccess?: ((res: any) => void) | undefined;
24
+ onError?: ((error: Error) => void) | undefined;
25
+ requestConfig?: import("axios").AxiosRequestConfig | undefined;
26
+ pageKey?: string | undefined;
27
+ pageSizeKey?: string | undefined;
28
+ pageSize?: number | undefined;
29
+ pageSizeList?: any[] | undefined;
30
+ paginationProps?: import("@alifd/next/types/pagination").PaginationProps | undefined;
31
+ showPagination?: boolean | undefined;
32
+ responsivePaginationType?: import("../../../table").responsivePaginationType | undefined;
33
+ useRowSelection?: boolean | undefined;
34
+ onChangeRowSelection?: ((selectedRowKeys: string[]) => void) | undefined;
35
+ getRowSelection?: ((rowSelection: import("../../../table").innerRowSelectionType) => void) | undefined;
36
+ footerAction?: React.ReactNode | import("../../..").ProActionGroupProps;
37
+ footer?: React.ReactNode;
38
+ filterDebounce?: number | undefined;
39
+ actionRef?: React.MutableRefObject<import("../../../table").ProTableActionType | undefined> | undefined;
40
+ showSkeleton?: boolean | undefined;
41
+ skeletonSize?: number | undefined;
42
+ tableClassName?: string | undefined;
43
+ footerSuction?: boolean | Element | undefined;
44
+ autoRefresh?: boolean | ((dataSource: any[]) => number | boolean) | undefined;
45
+ autoRefreshProps?: {
46
+ dataSource?: {
47
+ label?: React.ReactNode;
48
+ value?: number | undefined;
49
+ }[] | undefined;
50
+ } | undefined;
51
+ customRequest?: ((params: any) => Promise<{
52
+ success: boolean;
53
+ data: any[];
54
+ total?: number | undefined;
55
+ }>) | undefined;
56
+ reserveSelectedRecords?: boolean | undefined;
57
+ defaultFilterParams?: {
58
+ [key: string]: any;
59
+ } | undefined;
60
+ disableSelectAll?: boolean | undefined;
61
+ context?: any;
62
+ fixedTableBody?: boolean | undefined;
63
+ 'data-teamix-spm'?: string | undefined;
64
+ switchCardView?: boolean | undefined;
65
+ cardViewProps?: import("../../../table").ProTableCardProps | undefined;
66
+ defaultView?: "table" | "card" | undefined;
67
+ emptyProps?: import("@teamix/pro-field").EmptyContentProps | undefined;
68
+ bindUrl?: boolean | undefined;
69
+ bindUrlProps?: import("../../../table").ProTableBindUrlProps | undefined;
70
+ autoRedirect?: boolean | undefined;
71
+ useMaxData?: boolean | undefined;
72
+ rowSelection?: ({
73
+ getProps?: ((record: any, index: number) => any) | undefined;
74
+ onChange?: ((selectedRowKeys: any[], records: any[]) => void) | undefined;
75
+ onSelect?: ((selected: boolean, record: any, records: any[]) => void) | undefined;
76
+ onSelectAll?: ((selected: boolean, records: any[]) => void) | undefined;
77
+ selectedRowKeys?: any[] | undefined;
78
+ selectedRecords?: any[] | undefined;
79
+ mode?: "multiple" | "single" | undefined;
80
+ titleProps?: (() => any) | undefined;
81
+ columnProps?: (() => any) | undefined;
82
+ titleAddons?: (() => any) | undefined;
83
+ defaultSelectedRowKeys?: any[] | undefined;
84
+ defaultSelectedRecords?: any[] | undefined;
85
+ } & {
86
+ getProps?: ((record: any, index: number) => void) | undefined;
87
+ onChange?: ((selectedRowKeys: any[], records: any[]) => void) | undefined;
88
+ onSelect?: ((selected: boolean, record: any, records: any[]) => void) | undefined;
89
+ onSelectAll?: ((selected: boolean, records: any[]) => void) | undefined;
90
+ selectedRowKeys?: any[] | undefined;
91
+ mode?: "multiple" | "single" | undefined;
92
+ titleProps?: (() => any) | undefined;
93
+ columnProps?: (() => any) | undefined;
94
+ titleAddons?: (() => any) | undefined;
95
+ }) | undefined;
96
+ } & Omit<import("@alifd/next/types/table").TableProps, "rowSelection" | "columns"> & import("../../../table").ProTableTopAreaProps> & React.RefAttributes<unknown>>;
97
+ export default SelectTable2;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _react2 = require("@formily/react");
9
+ var _table = _interopRequireDefault(require("../../../table"));
10
+ var _excluded = ["columns", "field"];
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
12
+ 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; }
13
+ 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; }
14
+ 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; }
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
+ 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
+ var Component = (0, _react2.observer)(function (props) {
18
+ var _props$columns = props.columns,
19
+ columns = _props$columns === void 0 ? [] : _props$columns,
20
+ field = props.field,
21
+ others = _objectWithoutProperties(props, _excluded);
22
+ var onChange = function onChange(value) {
23
+ field.setValue(value);
24
+ };
25
+ return /*#__PURE__*/_react.default.createElement(_table.default, _objectSpread({
26
+ toolBar: false,
27
+ showPagination: false,
28
+ columns: columns,
29
+ useRowSelection: true,
30
+ rowSelection: {
31
+ defaultSelectedRowKeys: field.value
32
+ },
33
+ onChangeRowSelection: onChange,
34
+ loading: field.loading,
35
+ showSkeleton: false,
36
+ dataSource: field.dataSource
37
+ }, others));
38
+ });
39
+ var SelectTable2 = (0, _react2.connect)(Component, (0, _react2.mapProps)(function (props, field) {
40
+ var dataSource = field.dataSource;
41
+ return _objectSpread(_objectSpread({}, props), {}, {
42
+ dataSource: dataSource,
43
+ field: field
44
+ });
45
+ }));
46
+ var _default = SelectTable2;
47
+ exports.default = _default;