@teamix/pro 1.2.19 → 1.2.23

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 (103) hide show
  1. package/dist/212.js +49 -49
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +3400 -880
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/es/actions/dialog.js +10 -24
  7. package/es/actions/index.d.ts +10 -0
  8. package/es/actions/index.js +11 -16
  9. package/es/form/Components/LightFilter/componentMap.js +2 -1
  10. package/es/form/Components/LightFilter/index.js +16 -4
  11. package/es/form/Components/LightFilter/index.scss +1 -1
  12. package/es/form/Components/SelectTable/index.d.ts +24 -0
  13. package/es/form/Components/SelectTable/index.js +135 -0
  14. package/es/form/Components/SelectTable/index.scss +28 -0
  15. package/es/form/Components/SelectTable/table.d.ts +6 -0
  16. package/es/form/Components/SelectTable/table.js +64 -0
  17. package/es/form/Filter/AdvancedFilter.d.ts +7 -0
  18. package/es/form/Filter/AdvancedFilter.js +114 -0
  19. package/es/form/Filter/LightFilter.d.ts +7 -0
  20. package/es/form/Filter/LightFilter.js +79 -0
  21. package/es/form/Filter/SimpleFilter.d.ts +7 -0
  22. package/es/form/Filter/SimpleFilter.js +74 -0
  23. package/es/form/Filter/index2.js +203 -257
  24. package/es/form/ProForm/index.js +12 -9
  25. package/es/form/ProForm/index.scss +40 -6
  26. package/es/form/ProForm/useFormDisplayValues.js +4 -2
  27. package/es/form/SchemaForm/index.js +16 -10
  28. package/es/form/SchemaForm/initializeDataSource.d.ts +2 -2
  29. package/es/form/SchemaForm/initializeDataSource.js +4 -9
  30. package/es/form/SchemaForm/initializeRequest.d.ts +2 -2
  31. package/es/form/SchemaForm/initializeRequest.js +4 -10
  32. package/es/form/SchemaForm/initializeRules.d.ts +7 -1
  33. package/es/form/SchemaForm/initializeRules.js +9 -13
  34. package/es/form/SchemaForm/reactions.d.ts +5 -5
  35. package/es/form/SchemaForm/reactions.js +27 -29
  36. package/es/form/global.scss +1 -0
  37. package/es/form/typing.d.ts +7 -3
  38. package/es/form/utils.d.ts +8 -7
  39. package/es/form/utils.js +5 -4
  40. package/es/index.d.ts +1 -1
  41. package/es/index.js +1 -1
  42. package/es/table/components/Filter/index.js +1 -0
  43. package/es/table/components/Layout/index.js +22 -12
  44. package/es/table/components/Pagination/index.d.ts +7 -0
  45. package/es/table/components/Pagination/index.js +245 -0
  46. package/es/table/components/Pagination/index.scss +50 -0
  47. package/es/table/components/ToolBar/FilterColumnIcon.js +41 -7
  48. package/es/table/components/ToolBar/index.scss +17 -6
  49. package/es/table/index.js +96 -37
  50. package/es/table/index.scss +7 -1
  51. package/es/table/typing.d.ts +9 -2
  52. package/es/table/utils/columnRender.js +2 -1
  53. package/es/table/utils/index.d.ts +7 -0
  54. package/es/table/utils/index.js +38 -4
  55. package/lib/actions/dialog.js +9 -23
  56. package/lib/actions/index.d.ts +10 -0
  57. package/lib/actions/index.js +11 -16
  58. package/lib/form/Components/LightFilter/componentMap.js +2 -1
  59. package/lib/form/Components/LightFilter/index.js +15 -4
  60. package/lib/form/Components/LightFilter/index.scss +1 -1
  61. package/lib/form/Components/SelectTable/index.d.ts +24 -0
  62. package/lib/form/Components/SelectTable/index.js +157 -0
  63. package/lib/form/Components/SelectTable/index.scss +28 -0
  64. package/lib/form/Components/SelectTable/table.d.ts +6 -0
  65. package/lib/form/Components/SelectTable/table.js +76 -0
  66. package/lib/form/Filter/AdvancedFilter.d.ts +7 -0
  67. package/lib/form/Filter/AdvancedFilter.js +134 -0
  68. package/lib/form/Filter/LightFilter.d.ts +7 -0
  69. package/lib/form/Filter/LightFilter.js +99 -0
  70. package/lib/form/Filter/SimpleFilter.d.ts +7 -0
  71. package/lib/form/Filter/SimpleFilter.js +93 -0
  72. package/lib/form/Filter/index2.js +207 -258
  73. package/lib/form/ProForm/index.js +11 -9
  74. package/lib/form/ProForm/index.scss +40 -6
  75. package/lib/form/ProForm/useFormDisplayValues.js +3 -1
  76. package/lib/form/SchemaForm/index.js +16 -9
  77. package/lib/form/SchemaForm/initializeDataSource.d.ts +2 -2
  78. package/lib/form/SchemaForm/initializeDataSource.js +4 -11
  79. package/lib/form/SchemaForm/initializeRequest.d.ts +2 -2
  80. package/lib/form/SchemaForm/initializeRequest.js +4 -11
  81. package/lib/form/SchemaForm/initializeRules.d.ts +7 -1
  82. package/lib/form/SchemaForm/initializeRules.js +9 -16
  83. package/lib/form/SchemaForm/reactions.d.ts +5 -5
  84. package/lib/form/SchemaForm/reactions.js +29 -31
  85. package/lib/form/global.scss +1 -0
  86. package/lib/form/typing.d.ts +7 -3
  87. package/lib/form/utils.d.ts +8 -7
  88. package/lib/form/utils.js +6 -5
  89. package/lib/index.d.ts +1 -1
  90. package/lib/index.js +1 -1
  91. package/lib/table/components/Layout/index.js +21 -11
  92. package/lib/table/components/Pagination/index.d.ts +7 -0
  93. package/lib/table/components/Pagination/index.js +265 -0
  94. package/lib/table/components/Pagination/index.scss +50 -0
  95. package/lib/table/components/ToolBar/FilterColumnIcon.js +40 -6
  96. package/lib/table/components/ToolBar/index.scss +17 -6
  97. package/lib/table/index.js +96 -36
  98. package/lib/table/index.scss +7 -1
  99. package/lib/table/typing.d.ts +9 -2
  100. package/lib/table/utils/columnRender.js +2 -1
  101. package/lib/table/utils/index.d.ts +7 -0
  102. package/lib/table/utils/index.js +46 -4
  103. package/package.json +2 -2
package/es/table/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest"];
1
+ var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType"];
2
2
 
3
3
  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); }
4
4
 
@@ -33,13 +33,14 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
33
33
  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; }
34
34
 
35
35
  import React, { useState, useEffect, useRef, useMemo } from 'react';
36
- import { Table, Pagination, Checkbox } from '@alicloudfe/components';
36
+ import { Table, Checkbox } from '@alicloudfe/components';
37
+ import Pagination from './components/Pagination';
37
38
  import genProColumnToColumn from './utils/genProColumnToColumn';
38
39
  import { baseClass, useRequest, request as utilResquest, getDeepValue, getMessage, pickProps } from '@teamix/utils';
39
40
  import { ProSkeletonRaw as Skeleton } from '../skeleton';
40
41
  import './index.scss';
41
42
  import Layout from './components/Layout';
42
- import { useActionType } from './utils';
43
+ import { emit, initActionRef, useActionType } from './utils';
43
44
  import getTableProps from './utils/getTableProps';
44
45
  import getTableSortIcons from './utils/getTableSortIcons';
45
46
  import useTableSelection from './utils/useTableSelection';
@@ -64,25 +65,29 @@ var processColumns = function processColumns(columns, initialColumns) {
64
65
  return item.columnFilters !== false;
65
66
  }); // 处理只剩一列批量选择的情况下宽度错乱问题
66
67
 
67
- if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) && (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
68
- var _filterColumns$, _filterColumns$2;
68
+ if (filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) {
69
+ var _initialColumns$;
69
70
 
70
- if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
71
- delete filterColumns[0].width;
72
- }
71
+ if ((filterColumns === null || filterColumns === void 0 ? void 0 : filterColumns.length) === 1) {
72
+ var _filterColumns$, _filterColumns$2;
73
73
 
74
- if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
75
- filterColumns[0].lock = false;
76
- }
77
- } else {
78
- var _initialColumns$, _initialColumns$2;
74
+ if ((_filterColumns$ = filterColumns[0]) === null || _filterColumns$ === void 0 ? void 0 : _filterColumns$.width) {
75
+ delete filterColumns[0].width;
76
+ }
79
77
 
80
- if ((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.width) {
81
- filterColumns[0].width = initialColumns[0].width;
82
- }
78
+ if ((_filterColumns$2 = filterColumns[0]) === null || _filterColumns$2 === void 0 ? void 0 : _filterColumns$2.lock) {
79
+ filterColumns[0].lock = false;
80
+ }
81
+ } else if (((_initialColumns$ = initialColumns[0]) === null || _initialColumns$ === void 0 ? void 0 : _initialColumns$.columnFilters) !== false) {
82
+ var _initialColumns$2, _initialColumns$3;
83
+
84
+ if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.width) {
85
+ filterColumns[0].width = initialColumns[0].width;
86
+ }
83
87
 
84
- if ((_initialColumns$2 = initialColumns[0]) === null || _initialColumns$2 === void 0 ? void 0 : _initialColumns$2.lock) {
85
- filterColumns[0].lock = initialColumns[0].lock;
88
+ if ((_initialColumns$3 = initialColumns[0]) === null || _initialColumns$3 === void 0 ? void 0 : _initialColumns$3.lock) {
89
+ filterColumns[0].lock = initialColumns[0].lock;
90
+ }
86
91
  }
87
92
  }
88
93
 
@@ -141,6 +146,7 @@ var ProTable = function ProTable(props) {
141
146
  showPagination = _props$showPagination === void 0 ? true : _props$showPagination,
142
147
  _props$pageSizeList = props.pageSizeList,
143
148
  pageSizeList = _props$pageSizeList === void 0 ? [5, 10, 20, 50, 100] : _props$pageSizeList,
149
+ responsivePaginationType = props.responsivePaginationType,
144
150
  _props$showSkeleton = props.showSkeleton,
145
151
  propsShowSkeleton = _props$showSkeleton === void 0 ? true : _props$showSkeleton,
146
152
  _props$skeletonSize = props.skeletonSize,
@@ -156,6 +162,8 @@ var ProTable = function ProTable(props) {
156
162
  return false;
157
163
  } : _props$autoRefresh,
158
164
  customRequest = props.customRequest,
165
+ _props$filterColumnTy = props.filterColumnType,
166
+ filterColumnType = _props$filterColumnTy === void 0 ? 'auto' : _props$filterColumnTy,
159
167
  otherProps = _objectWithoutProperties(props, _excluded);
160
168
 
161
169
  var targetPageKey = pageKey || globalPageKey;
@@ -199,8 +207,10 @@ var ProTable = function ProTable(props) {
199
207
  var _useState13 = useState(true),
200
208
  _useState14 = _slicedToArray(_useState13, 2),
201
209
  customTableLoading = _useState14[0],
202
- setCustomTableLoading = _useState14[1];
210
+ setCustomTableLoading = _useState14[1]; // 用于存放 Search 组件之前值的 ref
203
211
 
212
+
213
+ var searchValueRef = useRef('');
204
214
  var tableRef = useRef(null);
205
215
  var actionRef = useRef(); // 传给 table 的过滤后的 columns
206
216
 
@@ -399,9 +409,14 @@ var ProTable = function ProTable(props) {
399
409
  setColumn: function setColumn(newColumns) {
400
410
  var _actionRef$current2, _actionRef$current2$s;
401
411
 
412
+ var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
402
413
  var columns = processColumns(newColumns, propsColumns);
403
414
  setFilteredColumns(columns);
404
415
  (_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, 'filterColumns', columns);
416
+
417
+ if (update) {
418
+ emit('refreshFilterState', newColumns);
419
+ }
405
420
  },
406
421
  setSize: function setSize(mode) {
407
422
  _setSize(mode);
@@ -605,10 +620,8 @@ var ProTable = function ProTable(props) {
605
620
  }
606
621
 
607
622
  useEffect(function () {
608
- var _actionRef$current5, _actionRef$current5$i;
609
-
610
- // 初始化 state 状态
611
- actionRef === null || actionRef === void 0 ? void 0 : (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$i = _actionRef$current5.initState) === null || _actionRef$current5$i === void 0 ? void 0 : _actionRef$current5$i.call(_actionRef$current5); // 监听 浏览器变化 更吸底状态
623
+ // 初始化 actionRef state、callback 此时 actionRef 已初始化完成
624
+ initActionRef(); // 监听 浏览器变化 更吸底状态
612
625
 
613
626
  if (footerSuction) {
614
627
  getFooterSuctionState();
@@ -622,6 +635,14 @@ var ProTable = function ProTable(props) {
622
635
  _request();
623
636
  }
624
637
 
638
+ var searchName = getSearchName();
639
+
640
+ if (searchName) {
641
+ // 如果有初始值,需要赋值
642
+ var initialValues = toJS(dataFilterForm.initialValues);
643
+ searchValueRef.current = initialValues[searchName][1];
644
+ }
645
+
625
646
  return function () {
626
647
  if (autoRefreshTimerRef.current) {
627
648
  clearTimeout(autoRefreshTimerRef.current);
@@ -641,18 +662,54 @@ var ProTable = function ProTable(props) {
641
662
  setSort(nextSort);
642
663
 
643
664
  _request(targetFormatSort(nextSort));
644
- } // 处理 dataFilter 中的 onFilter、onReset
665
+ } // 找到 Search 组件对应的 name
666
+
645
667
 
668
+ var getSearchName = function getSearchName() {
669
+ var _dataFilter$schema;
646
670
 
647
- var dataFilter = _objectSpread(_objectSpread({}, propsDataFilter), {}, {
648
- onFilter: debounce(function () {
649
- (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(_objectSpread({}, toJS(dataFilterForm.values))));
671
+ if ((dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.schema) && ((_dataFilter$schema = dataFilter.schema) === null || _dataFilter$schema === void 0 ? void 0 : _dataFilter$schema.length) > 0) {
672
+ var searchSchema = dataFilter.schema.find(function (item) {
673
+ return item.component === 'Search';
674
+ });
675
+
676
+ if (searchSchema) {
677
+ var searchName = searchSchema.name;
678
+ return searchName;
679
+ }
680
+ }
681
+ }; // 处理 dataFilter 中的 onFilter、onReset
682
+
683
+
684
+ var dataFilter = _objectSpread(_objectSpread({
685
+ mode: 'inline'
686
+ }, propsDataFilter), {}, {
687
+ onFilter: debounce(function (values) {
688
+ (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values));
650
689
 
651
690
  if (dataFilterForm.validate()) {
652
- var _actionRef$current6, _actionRef$current6$c;
691
+ var _actionRef$current5, _actionRef$current5$c;
692
+
693
+ /**
694
+ * 针对 inline 模式下的 Search 组件做特殊处理
695
+ * 当切换条件且输入内容为空的时候,类似[a, ''] => [b, ''] 不触发请求
696
+ */
697
+ if (dataFilter.mode === 'inline') {
698
+ var searchName = getSearchName();
699
+
700
+ if (searchName) {
701
+ var searchValue = values[searchName][1];
653
702
 
654
- // 搜索变化时,暂时先清空选择
655
- (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
703
+ if (searchValue === (searchValueRef === null || searchValueRef === void 0 ? void 0 : searchValueRef.current)) {
704
+ return;
705
+ }
706
+
707
+ searchValueRef.current = searchValue;
708
+ }
709
+ } // 搜索变化时,暂时先清空选择
710
+
711
+
712
+ (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$c = _actionRef$current5.clearRowSelection) === null || _actionRef$current5$c === void 0 ? void 0 : _actionRef$current5$c.call(_actionRef$current5);
656
713
  setCurrentPage(1);
657
714
 
658
715
  _request(_defineProperty({}, targetPageKey, 1));
@@ -688,7 +745,8 @@ var ProTable = function ProTable(props) {
688
745
  columns: propsColumns,
689
746
  dataFilter: dataFilter,
690
747
  dataFilterForm: dataFilterForm,
691
- rowSelection: rowSelection
748
+ rowSelection: rowSelection,
749
+ filterColumnType: filterColumnType
692
750
  }), /*#__PURE__*/React.createElement(Table.StickyLock, _objectSpread({
693
751
  hasBorder: false,
694
752
  dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
@@ -746,21 +804,21 @@ var ProTable = function ProTable(props) {
746
804
 
747
805
  var renderFooter = function renderFooter() {
748
806
  function onChangePagination(currentPage) {
749
- var _actionRef$current7, _actionRef$current7$c;
807
+ var _actionRef$current6, _actionRef$current6$c;
750
808
 
751
809
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
752
810
  // 翻页暂时先清空选择
753
- (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
811
+ (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$c = _actionRef$current6.clearRowSelection) === null || _actionRef$current6$c === void 0 ? void 0 : _actionRef$current6$c.call(_actionRef$current6);
754
812
  setCurrentPage(currentPage);
755
813
 
756
814
  _request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
757
815
  }
758
816
 
759
817
  function onChangePaginationSize(currentPageSize) {
760
- var _actionRef$current8, _actionRef$current8$c, _request5;
818
+ var _actionRef$current7, _actionRef$current7$c, _request5;
761
819
 
762
820
  // 翻页暂时先清空选择
763
- (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
821
+ (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$c = _actionRef$current7.clearRowSelection) === null || _actionRef$current7$c === void 0 ? void 0 : _actionRef$current7$c.call(_actionRef$current7);
764
822
  setPageSize(currentPageSize);
765
823
  setCurrentPage(1);
766
824
 
@@ -800,6 +858,9 @@ var ProTable = function ProTable(props) {
800
858
  return onChangePagination(number);
801
859
  },
802
860
  total: total,
861
+ responsivePaginationType: responsivePaginationType,
862
+ // shape="arrow-only"
863
+ // pageSizePosition="end"
803
864
  totalRender: function totalRender(total) {
804
865
  return getMessage('total', {
805
866
  total: total
@@ -807,10 +868,8 @@ var ProTable = function ProTable(props) {
807
868
  },
808
869
  pageSize: pageSize,
809
870
  current: currentPage,
810
- shape: "arrow-only",
811
871
  pageSizeList: pageSizeList,
812
872
  pageSizeSelector: total > (props.pageSize || 10) * 2 ? 'dropdown' : false,
813
- pageSizePosition: "end",
814
873
  type: total / pageSize <= 2 ? 'simple' : 'normal',
815
874
  onPageSizeChange: function onPageSizeChange(number) {
816
875
  return onChangePaginationSize(number);
@@ -32,12 +32,18 @@ $fullscreenPadding: 24px;
32
32
  }
33
33
  &-footer-left-wrapper {
34
34
  display: flex;
35
- flex: 1;
35
+ flex-shrink: 0;
36
36
  align-items: center;
37
37
  }
38
38
  &-footer-right-wrapper {
39
39
  display: flex;
40
40
  justify-content: flex-end;
41
+ width: 100%;
42
+ }
43
+ .teamix-pro-pagination-wrapper {
44
+ display: flex;
45
+ justify-content: flex-end;
46
+ width: 100%;
41
47
  }
42
48
  &-footer-action {
43
49
  margin-left: 16px;
@@ -12,7 +12,7 @@ import React from 'react';
12
12
  import type { Form as FormType } from '@formily/core';
13
13
  declare type IFieldRenderProps = keyof ProFieldRenderProps;
14
14
  /** 列record函数 */
15
- declare type ProTableCellFunProp = (value: any, index: number, record: any) => any;
15
+ declare type ProTableCellFunProp = (value: any, index: number, record: any, ...others: any) => any;
16
16
  declare type ITableCellRender = {
17
17
  [key in IFieldRenderProps]?: ProFieldRenderProps[key] | ProTableCellFunProp;
18
18
  } | ((...other: any) => React.ReactNode);
@@ -22,6 +22,7 @@ declare type TDataService = {
22
22
  /** 表格数据 */
23
23
  data?: any;
24
24
  };
25
+ export declare type responsivePaginationType = 'mini' | 'small' | 'simple' | 'normal';
25
26
  export declare type ProTableColumnProps = {
26
27
  /**
27
28
  * 会在 title 之后展示一个 icon,hover 之后提示一些信息
@@ -92,6 +93,8 @@ export declare type ProTableProps = {
92
93
  paginationProps?: PaginationProps;
93
94
  /** 是否显示翻页器 */
94
95
  showPagination?: boolean;
96
+ /** 手动指定响应式翻页器的 type */
97
+ responsivePaginationType?: responsivePaginationType;
95
98
  /** 是否使用内置的 rowSelection */
96
99
  useRowSelection?: boolean;
97
100
  /** 内置 rowSelection 变化时的回调 */
@@ -146,7 +149,7 @@ export declare type ProTableActionType = {
146
149
  /** 全屏展示 */
147
150
  fullScreen?: () => boolean;
148
151
  /** 设置显示列 */
149
- setColumn?: (newColumns: ProColumnProps[]) => void;
152
+ setColumn?: (newColumns: ProColumnProps[], update?: boolean) => void;
150
153
  /** 设置表格大小 */
151
154
  setSize?: (mode: 'small' | 'medium') => void;
152
155
  /** 刷新表格 */
@@ -220,6 +223,8 @@ export declare type ProTableDataFilterProps = {
220
223
  searchUndefined?: boolean;
221
224
  /** 搜索时是否传入值为空字符串的参数,默认不传 */
222
225
  searchEmptyString?: boolean;
226
+ /** 自定义内容 */
227
+ content?: React.ReactNode;
223
228
  } & IFilterProps;
224
229
  export declare type dataFilterProps = ProTableDataFilterProps;
225
230
  export declare type ProTableTopAreaProps = {
@@ -235,6 +240,8 @@ export declare type ProTableTopAreaProps = {
235
240
  dataFilter?: ProTableDataFilterProps;
236
241
  /** 数据过滤区 form 表单模型 */
237
242
  dataFilterForm?: FormType;
243
+ /** 排序、筛选列展示状态 */
244
+ filterColumnType?: 'dialog' | 'dropdown' | 'auto';
238
245
  };
239
246
  /** 单个工具栏 */
240
247
  export declare type ProTableToolBarItem = React.ReactNode | 'refresh' | 'density' | 'filterColumn' | 'fullscreen';
@@ -204,7 +204,8 @@ var processRenderFunction = function processRenderFunction() {
204
204
  var value = arguments.length > 1 ? arguments[1] : undefined;
205
205
  var index = arguments.length > 2 ? arguments[2] : undefined;
206
206
  var record = arguments.length > 3 ? arguments[3] : undefined;
207
- var external = ['linkOnClick', 'link', 'value'];
207
+ // ProField render 类型为 function 时。需要表格预先处理以塞入 record
208
+ var external = ['linkOnClick', 'link', 'value', 'renderEdit', 'descriptionRenderEdit', 'editPopConfirmProps', 'descriptionEditPopConfirmProps', 'editOnClick', 'descriptionEditOnClick'];
208
209
  return Object.fromEntries(Object.entries(render).map(function (_ref3) {
209
210
  var _ref4 = _slicedToArray(_ref3, 2),
210
211
  k = _ref4[0],
@@ -1,4 +1,11 @@
1
1
  /// <reference types="react" />
2
2
  import { ProTableActionType } from '../typing';
3
+ export declare function initActionRef(): void;
4
+ /** table 组件内监听 不对外暴露 */
5
+ export declare function on(fun: any, key: string): void;
6
+ /** table 组件内销毁监听 不对外暴露 */
7
+ export declare function off(key: string): void;
8
+ /** table 组件内触发事件 不对外暴露 */
9
+ export declare function emit(key: string, ...args: any): void;
3
10
  export declare function useActionType<T>(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
4
11
  export declare function cloneDeep<T>(obj: T): T;
@@ -16,7 +16,7 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
16
16
 
17
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
- import cloneDeepLodash from 'lodash.clonedeep'; // 组件内全局状态
19
+ import cloneDeepLodash from 'lodash.clonedeep'; // 组件内全局状态 每次初始化 ActionRef 会重新深拷贝对象
20
20
 
21
21
  var state = {
22
22
  fullScreenState: false,
@@ -24,12 +24,16 @@ var state = {
24
24
  filterColumns: []
25
25
  };
26
26
 
27
- var _initState = cloneDeepLodash(state); // 组件内全局监听事件
27
+ var _initState = cloneDeepLodash(state); // state监听事件 每次初始化 ActionRef 会重新深拷贝对象
28
28
 
29
29
 
30
30
  var callback = {
31
31
  fullScreenState: {}
32
- }; // 组件内对全局状态的更改
32
+ };
33
+ var initCallback = cloneDeepLodash(callback); // 所有 ProTable 组件公用一套组件内事件转发机制
34
+
35
+ var tableCallback = {}; // 组件内监听事件
36
+ // 组件内对全局状态的更改
33
37
 
34
38
  var mutations = {
35
39
  getState: function getState() {
@@ -129,8 +133,38 @@ var useOn = function useOn(state) {
129
133
  }
130
134
  });
131
135
  }
132
- };
136
+ }; // 初始化 actionRef
137
+
138
+
139
+ export function initActionRef() {
140
+ state = cloneDeepLodash(_initState);
141
+ callback = cloneDeepLodash(initCallback);
142
+ }
143
+ /** table 组件内监听 不对外暴露 */
144
+
145
+ export function on(fun, key) {
146
+ tableCallback[key] = fun;
147
+ }
148
+ /** table 组件内销毁监听 不对外暴露 */
133
149
 
150
+ export function off(key) {
151
+ if (tableCallback[key]) {
152
+ delete tableCallback[key];
153
+ }
154
+ }
155
+ /** table 组件内触发事件 不对外暴露 */
156
+
157
+ export function emit(key) {
158
+ var fun = tableCallback[key];
159
+
160
+ if (fun) {
161
+ for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
162
+ args[_key2 - 1] = arguments[_key2];
163
+ }
164
+
165
+ fun.apply(void 0, args);
166
+ }
167
+ }
134
168
  export function useActionType(ref, action) {
135
169
  // 合并自定义事件
136
170
  var userAction = _objectSpread(_objectSpread({}, action), mutations);
@@ -187,48 +187,34 @@ function useDialogAction(action, actionContext) {
187
187
  while (1) {
188
188
  switch (_context.prev = _context.next) {
189
189
  case 0:
190
- if (url) {
191
- _context.next = 5;
192
- break;
193
- }
194
-
195
- if (link) {
196
- (0, _utils.goToLink)(link, history);
197
- }
198
-
199
- onFinish && onFinish();
200
- resolve(true);
201
- return _context.abrupt("return");
202
-
203
- case 5:
204
190
  setLoading(true);
205
191
  footerDescriptionValues = Object.assign({}, footerDescriptionRef === null || footerDescriptionRef === void 0 ? void 0 : (_footerDescriptionRef = footerDescriptionRef.current) === null || _footerDescriptionRef === void 0 ? void 0 : _footerDescriptionRef.values);
206
- _context.prev = 7;
192
+ _context.prev = 2;
207
193
  requestContext = Object.assign({
208
194
  footer: footerDescriptionValues
209
195
  }, context);
210
- _context.next = 11;
196
+ _context.next = 6;
211
197
  return (0, _request.doRequest)(action, requestContext, history, footerDescriptionValues);
212
198
 
213
- case 11:
199
+ case 6:
214
200
  onFinish && onFinish();
215
201
  resolve(true);
216
- _context.next = 20;
202
+ _context.next = 15;
217
203
  break;
218
204
 
219
- case 15:
220
- _context.prev = 15;
221
- _context.t0 = _context["catch"](7);
205
+ case 10:
206
+ _context.prev = 10;
207
+ _context.t0 = _context["catch"](2);
222
208
  setLoading(false);
223
209
  resolve(false);
224
210
  return _context.abrupt("return");
225
211
 
226
- case 20:
212
+ case 15:
227
213
  case "end":
228
214
  return _context.stop();
229
215
  }
230
216
  }
231
- }, _callee, null, [[7, 15]]);
217
+ }, _callee, null, [[2, 10]]);
232
218
  }));
233
219
 
234
220
  return function (_x) {
@@ -46,11 +46,21 @@ export interface ProActionMenuButtonProps extends MenuButtonProps {
46
46
  export declare const ProActionMenuButton: (props: ProActionMenuButtonProps) => JSX.Element;
47
47
  export declare type ProActionProps = ProActionButtonProps | ProActionMenuButtonProps;
48
48
  export declare type ProActionGroupProps = {
49
+ /** 操作组类型:按钮、文字按钮 */
49
50
  type?: 'button' | 'text';
51
+ /** 上下文 */
50
52
  context?: any;
53
+ /** 操作项配置 */
51
54
  actions: ProActionProps[];
55
+ /** 操作按钮最长数量,超出后折叠,默认为4 */
52
56
  max?: number;
57
+ /**
58
+ * @deprecated 建议使用 more 代替
59
+ */
53
60
  moreText?: string;
61
+ /** 更多按钮的配置,只有在actions数量超过max时才有效 */
62
+ more?: string | ProActionButtonProps;
63
+ /** 是否有分割线,只有type="text"时生效,默认有分割线 */
54
64
  divider?: boolean;
55
65
  } & React.HTMLAttributes<HTMLElement>;
56
66
  export declare function ProActionGroup(props: ProActionGroupProps): JSX.Element;
@@ -60,7 +60,7 @@ var _excluded = ["type"],
60
60
  _excluded5 = ["context", "text"],
61
61
  _excluded6 = ["key", "actions"],
62
62
  _excluded7 = ["key", "config"],
63
- _excluded8 = ["type", "divider", "max", "moreText", "context", "actions", "className"];
63
+ _excluded8 = ["type", "divider", "max", "moreText", "more", "context", "actions", "className"];
64
64
 
65
65
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66
66
 
@@ -329,25 +329,19 @@ function renderCommonActionButton(button, context, isTypeText) {
329
329
  return /*#__PURE__*/_react.default.createElement(ProActionMenuButton, _objectSpread({}, buttonProps));
330
330
  }
331
331
 
332
- function getDefaultMoreButton(type, moreText) {
333
- if (type === 'button') {
334
- return {
335
- label: moreText || (0, _utils.getMessage)('more')
336
- };
337
- }
338
-
339
- if (moreText) {
340
- return {
341
- label: moreText
342
- };
343
- }
344
-
345
- return {
332
+ function getDefaultMoreButton(type, more) {
333
+ var moreConfig = typeof more === 'string' ? {
334
+ children: more
335
+ } : more;
336
+ var defaultConfig = type === 'button' ? {
337
+ children: (0, _utils.getMessage)('more')
338
+ } : {
346
339
  icon: 'more-line',
347
340
  // iconSize: 'small',
348
341
  autoWidth: false,
349
342
  className: 'teamix-pro-actions-text-menu-btn-no-arrow'
350
343
  };
344
+ return Object.assign(defaultConfig, moreConfig);
351
345
  }
352
346
 
353
347
  var MAX_ACTTIONS = 4;
@@ -392,6 +386,7 @@ function ProActionGroup(props) {
392
386
  _props$max = props.max,
393
387
  max = _props$max === void 0 ? MAX_ACTTIONS : _props$max,
394
388
  moreText = props.moreText,
389
+ more = props.more,
395
390
  context = props.context,
396
391
  _props$actions = props.actions,
397
392
  actions = _props$actions === void 0 ? [] : _props$actions,
@@ -404,7 +399,7 @@ function ProActionGroup(props) {
404
399
  }).filter(function (action) {
405
400
  return action.visible !== false;
406
401
  });
407
- var formatedActions = formatGroupActions(filteredActions, max, getDefaultMoreButton(type, moreText));
402
+ var formatedActions = formatGroupActions(filteredActions, max, getDefaultMoreButton(type, more || moreText));
408
403
  return /*#__PURE__*/_react.default.createElement("div", _objectSpread({
409
404
  className: (0, _classnames.default)('teamix-pro-actions', "teamix-pro-actions-type-".concat(type), className, {
410
405
  'teamix-pro-actions-divider': type === 'button' ? false : divider
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.inputCategory = exports.componentMap = void 0;
7
7
  var componentMap = {
8
8
  Radio: 'Select',
9
- Checkbox: 'Select'
9
+ Checkbox: 'Select',
10
+ CheckboxGroup: 'MultipleSelect'
10
11
  };
11
12
  exports.componentMap = componentMap;
12
13
  var inputCategory = ['Input', 'Password', 'TextArea', 'NumberPicker', 'Percent', 'Money'];
@@ -47,18 +47,29 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
47
47
 
48
48
  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; }
49
49
 
50
- // 主激活区内容
50
+ var formatComponent = function formatComponent(schema) {
51
+ var _schema$enum;
52
+
53
+ var component = schema['x-component'];
54
+
55
+ if (component === 'Checkbox' && ((_schema$enum = schema['enum']) === null || _schema$enum === void 0 ? void 0 : _schema$enum.length)) {
56
+ component = 'CheckboxGroup';
57
+ }
58
+
59
+ return _componentMap.componentMap[component] || component;
60
+ }; // 主激活区内容
61
+
62
+
51
63
  var useMain = function useMain(active) {
52
64
  var schema = (0, _react2.useFieldSchema)();
53
65
  var main = [];
54
66
  schema.mapProperties(function (schema, name) {
55
- // console.log(schema.required); // 添加 *
56
67
  if (schema.name === active) {
57
68
  main.push({
58
69
  name: name,
59
70
  schema: _objectSpread(_objectSpread({}, schema), {}, {
60
71
  title: '',
61
- 'x-component': _componentMap.componentMap[schema['x-component']] || schema['x-component']
72
+ 'x-component': formatComponent(schema)
62
73
  })
63
74
  });
64
75
  }
@@ -117,7 +128,7 @@ var LightFilter = (0, _react2.observer)(function (props) {
117
128
  });
118
129
  var onSelectChange = (0, _react.useCallback)(function (value) {
119
130
  setActive(value);
120
- onFilterChange && onFilterChange(currentSchema);
131
+ onFilterChange && onFilterChange(value);
121
132
  }, [onFilterChange]);
122
133
  return /*#__PURE__*/_react.default.createElement("span", {
123
134
  className: (0, _classnames.default)(prefixCls, "".concat(defaultCls).concat(size), isInputCategory(currentSchema) ? "".concat(prefixCls, "-input-category") : '')
@@ -27,7 +27,7 @@ $light-filter: #{teamix-pro-form}-light-filter;
27
27
  border: 0;
28
28
  box-shadow: none;
29
29
  .#{$css-prefix}input-text-field {
30
- padding-right: 0;
30
+ padding-right: 4px;
31
31
  }
32
32
  }
33
33
  .#{$css-prefix}input {
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import { TableProps, ColumnProps } from '@alifd/next/types/table';
3
+ import './index.scss';
4
+ declare type ISelectTableFilterOption = boolean | ((optipn: any, kewword: string) => boolean);
5
+ declare type ISelectTableFilterSort = (optionA: any, optionB: any) => number;
6
+ export interface ISelectTableColumnProps extends ColumnProps {
7
+ key: React.ReactText;
8
+ }
9
+ export interface ISelectTableProps extends TableProps {
10
+ mode?: 'multiple' | 'single';
11
+ dataSource?: any[];
12
+ optionAsValue?: boolean;
13
+ showSearch?: boolean;
14
+ filterOption?: ISelectTableFilterOption;
15
+ filterSort?: ISelectTableFilterSort;
16
+ onSearch?: (kekword: string) => void;
17
+ onChange?: (value: any) => void;
18
+ value?: any;
19
+ }
20
+ declare type ComposedSelectTable = React.FC<ISelectTableProps> & {
21
+ TableColumn?: React.FC<ISelectTableColumnProps>;
22
+ };
23
+ declare const SelectTable: ComposedSelectTable;
24
+ export default SelectTable;