@teamix/pro 1.2.28 → 1.2.32

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 (61) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +368 -252
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/common.scss +22 -0
  6. package/es/form/Filter/SimpleFilter.js +10 -3
  7. package/es/form/typing.d.ts +1 -1
  8. package/es/index.d.ts +1 -1
  9. package/es/index.js +1 -1
  10. package/es/info/components/InfoValueItem/index.js +38 -12
  11. package/es/info/components/InfoValueItem/index.scss +1 -0
  12. package/es/info/components/ProInfoItem/index.js +4 -2
  13. package/es/info/components/ProInfoItem/index.scss +5 -0
  14. package/es/info/components/baseInfo/index.js +4 -2
  15. package/es/info/components/headerInfo/index.js +2 -1
  16. package/es/info/components/tableInfo/index.js +2 -1
  17. package/es/info/index.scss +2 -0
  18. package/es/info/typing.d.ts +3 -0
  19. package/es/table/components/Filter/index.js +6 -6
  20. package/es/table/components/Layout/index.js +18 -3
  21. package/es/table/components/ToolBar/Fullscreen.js +7 -11
  22. package/es/table/index.js +96 -35
  23. package/es/table/index.scss +4 -0
  24. package/es/table/typing.d.ts +2 -2
  25. package/es/table/utils/columnRender.js +1 -1
  26. package/es/table/utils/index.d.ts +2 -1
  27. package/es/table/utils/index.js +62 -113
  28. package/lib/common.scss +22 -0
  29. package/lib/form/Filter/SimpleFilter.js +8 -1
  30. package/lib/form/typing.d.ts +1 -1
  31. package/lib/index.d.ts +1 -1
  32. package/lib/index.js +1 -1
  33. package/lib/info/components/InfoValueItem/index.js +38 -12
  34. package/lib/info/components/InfoValueItem/index.scss +1 -0
  35. package/lib/info/components/ProInfoItem/index.js +4 -2
  36. package/lib/info/components/ProInfoItem/index.scss +5 -0
  37. package/lib/info/components/baseInfo/index.js +4 -2
  38. package/lib/info/components/headerInfo/index.js +2 -1
  39. package/lib/info/components/tableInfo/index.js +2 -1
  40. package/lib/info/index.scss +2 -0
  41. package/lib/info/typing.d.ts +3 -0
  42. package/lib/table/components/Filter/index.js +6 -6
  43. package/lib/table/components/Layout/index.js +18 -3
  44. package/lib/table/components/ToolBar/Fullscreen.js +7 -11
  45. package/lib/table/index.js +95 -34
  46. package/lib/table/index.scss +4 -0
  47. package/lib/table/typing.d.ts +2 -2
  48. package/lib/table/utils/columnRender.js +1 -1
  49. package/lib/table/utils/index.d.ts +2 -1
  50. package/lib/table/utils/index.js +63 -112
  51. package/package.json +1 -1
  52. package/es/form/Components/SelectTable/index.d.ts +0 -24
  53. package/es/form/Components/SelectTable/index.js +0 -135
  54. package/es/form/Components/SelectTable/index.scss +0 -28
  55. package/es/form/Components/SelectTable/table.d.ts +0 -6
  56. package/es/form/Components/SelectTable/table.js +0 -64
  57. package/lib/form/Components/SelectTable/index.d.ts +0 -24
  58. package/lib/form/Components/SelectTable/index.js +0 -157
  59. package/lib/form/Components/SelectTable/index.scss +0 -28
  60. package/lib/form/Components/SelectTable/table.d.ts +0 -6
  61. package/lib/form/Components/SelectTable/table.js +0 -76
package/es/table/index.js CHANGED
@@ -40,7 +40,7 @@ import { baseClass, useRequest, request as utilResquest, getDeepValue, getMessag
40
40
  import { ProSkeletonRaw as Skeleton } from '../skeleton';
41
41
  import './index.scss';
42
42
  import Layout from './components/Layout';
43
- import { emit, initActionRef, processDefaultFilter, useActionType } from './utils';
43
+ import { actionRefUseStateOn, emit, initActionRef, processDefaultFilter, useActionType } from './utils';
44
44
  import getTableProps from './utils/getTableProps';
45
45
  import getTableSortIcons from './utils/getTableSortIcons';
46
46
  import useTableSelection from './utils/useTableSelection';
@@ -237,7 +237,24 @@ var ProTable = function ProTable(props) {
237
237
  var _useState19 = useState(true),
238
238
  _useState20 = _slicedToArray(_useState19, 2),
239
239
  showLoading = _useState20[0],
240
- setShowLoading = _useState20[1]; // 存储定时器 id
240
+ setShowLoading = _useState20[1]; // 存储能够被 on 监听到的 ProTable 状态
241
+ // 因为只做存储用。不需要更新视图以及需要同步更改。所以不使用 setState 更新
242
+
243
+
244
+ var _useState21 = useState({
245
+ fullScreenState: false,
246
+ filterRules: {},
247
+ filterColumns: []
248
+ }),
249
+ _useState22 = _slicedToArray(_useState21, 1),
250
+ actionRefState = _useState22[0]; // 存储 on 监听事件
251
+
252
+
253
+ var _useState23 = useState({
254
+ fullScreenState: {}
255
+ }),
256
+ _useState24 = _slicedToArray(_useState23, 1),
257
+ actionRefCallback = _useState24[0]; // 存储定时器 id
241
258
 
242
259
 
243
260
  var autoRefreshTimerRef = useRef(); // 获取header高度,用作全屏吸底吸底高度计算
@@ -261,16 +278,16 @@ var ProTable = function ProTable(props) {
261
278
  }; // header 区域高度。用作全屏计算吸顶吸底高度。默认不做计算
262
279
 
263
280
 
264
- var _useState21 = useState(0),
265
- _useState22 = _slicedToArray(_useState21, 2),
266
- headerHeight = _useState22[0],
267
- setHeaderHeight = _useState22[1]; // 全屏显示 className
281
+ var _useState25 = useState(0),
282
+ _useState26 = _slicedToArray(_useState25, 2),
283
+ headerHeight = _useState26[0],
284
+ setHeaderHeight = _useState26[1]; // 全屏显示 className
268
285
 
269
286
 
270
- var _useState23 = useState(false),
271
- _useState24 = _slicedToArray(_useState23, 2),
272
- fullscreenState = _useState24[0],
273
- setFullscreenState = _useState24[1]; // 非全屏状态下的
287
+ var _useState27 = useState(false),
288
+ _useState28 = _slicedToArray(_useState27, 2),
289
+ fullscreenState = _useState28[0],
290
+ setFullscreenState = _useState28[1]; // 非全屏状态下的
274
291
 
275
292
 
276
293
  var normalDataFilterFormRef = useRef();
@@ -281,10 +298,10 @@ var ProTable = function ProTable(props) {
281
298
  var dataFilterFormRef = !fullscreenState ? normalDataFilterFormRef : fullscreenDataFilterFormRef;
282
299
  var dataFilterForm = dataFilterFormRef.current; // 整个内容区是否超过一屏。用于表格在非全屏模式下的吸底
283
300
 
284
- var _useState25 = useState(false),
285
- _useState26 = _slicedToArray(_useState25, 2),
286
- footerSuctionState = _useState26[0],
287
- setFooterSuctionState = _useState26[1]; // TODO 获取内容区是否超出一屏(暂时仅支持全家桶)
301
+ var _useState29 = useState(false),
302
+ _useState30 = _slicedToArray(_useState29, 2),
303
+ footerSuctionState = _useState30[0],
304
+ setFooterSuctionState = _useState30[1]; // TODO 获取内容区是否超出一屏(暂时仅支持全家桶)
288
305
 
289
306
 
290
307
  var getFooterSuctionState = function getFooterSuctionState() {
@@ -407,25 +424,63 @@ var ProTable = function ProTable(props) {
407
424
  if (propsDataSource) {
408
425
  setData(propsDataSource);
409
426
  }
410
- }, [propsDataSource]); // 绑定 Actions
427
+ }, [propsDataSource]); // 初始化 ActionRef。
428
+
429
+ initActionRef(actionRef, {
430
+ getState: function getState() {
431
+ return actionRefState;
432
+ },
433
+ getCallback: function getCallback() {
434
+ return actionRefCallback;
435
+ },
436
+ setState: function setState(key, value) {
437
+ actionRefState[key] = value;
438
+ actionRefUseStateOn(actionRefCallback, key, value);
439
+ },
440
+ on: function on(fun, state, name) {
441
+ if (!actionRefCallback[state]) {
442
+ actionRefCallback[state] = {};
443
+ }
444
+
445
+ actionRefCallback[state][name] = fun;
446
+ },
447
+ off: function off(name) {
448
+ actionRefCallback = Object.fromEntries(Object.entries(actionRefCallback).map(function (_ref) {
449
+ var _ref2 = _slicedToArray(_ref, 2),
450
+ k = _ref2[0],
451
+ v = _ref2[1];
452
+
453
+ var filterV = Object.fromEntries(Object.entries(v).filter(function (_ref3) {
454
+ var _ref4 = _slicedToArray(_ref3, 1),
455
+ k = _ref4[0];
456
+
457
+ return k !== name;
458
+ }));
459
+ return [k, filterV];
460
+ }));
461
+ }
462
+ }); // 绑定 Actions
411
463
 
412
464
  useActionType(actionRef, {
413
465
  fullScreen: function fullScreen() {
466
+ var _actionRef$current2, _actionRef$current2$s;
467
+
414
468
  var state = !fullscreenState; // 全屏时需要重新计算header高度
415
469
 
416
470
  getHeaderHeight().then(function (height) {
417
471
  setHeaderHeight(height);
418
472
  });
419
473
  setFullscreenState(state);
474
+ 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);
420
475
  return state;
421
476
  },
422
477
  setColumn: function setColumn(newColumns) {
423
- var _actionRef$current2, _actionRef$current2$s;
478
+ var _actionRef$current3, _actionRef$current3$s;
424
479
 
425
480
  var update = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
426
481
  var columns = processColumns(newColumns, propsColumns);
427
482
  setFilteredColumns(columns);
428
- (_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);
483
+ (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setState) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, 'filterColumns', columns);
429
484
 
430
485
  if (update) {
431
486
  emit('refreshFilterState', newColumns);
@@ -450,11 +505,11 @@ var ProTable = function ProTable(props) {
450
505
  _request(params);
451
506
  },
452
507
  reset: function reset() {
453
- var _actionRef$current3, _actionRef$current3$s, _dataFilterForm;
508
+ var _actionRef$current4, _actionRef$current4$s, _dataFilterForm;
454
509
 
455
510
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset()); // 清空列过滤参数
456
511
 
457
- (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setFilterRules) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, {});
512
+ (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$s = _actionRef$current4.setFilterRules) === null || _actionRef$current4$s === void 0 ? void 0 : _actionRef$current4$s.call(_actionRef$current4, {});
458
513
  (_dataFilterForm = dataFilterForm) === null || _dataFilterForm === void 0 ? void 0 : _dataFilterForm.reset();
459
514
  setCurrentPage(1);
460
515
 
@@ -569,7 +624,7 @@ var ProTable = function ProTable(props) {
569
624
  }); // 请求函数
570
625
 
571
626
  function _request(params, noLoading) {
572
- var _dataFilterForm2, _actionRef$current$ge, _actionRef$current4, _actionRef$current4$g, _objectSpread2;
627
+ var _dataFilterForm2, _actionRef$current$ge, _actionRef$current5, _actionRef$current5$g, _objectSpread2;
573
628
 
574
629
  // 如果没有传 url 且没有 customRequest,直接返回
575
630
  if (!url && !customRequest) {
@@ -584,7 +639,7 @@ var ProTable = function ProTable(props) {
584
639
 
585
640
  var dataFilterParams = toJS((_dataFilterForm2 = dataFilterForm) === null || _dataFilterForm2 === void 0 ? void 0 : _dataFilterForm2.values); // 列过滤请求参数
586
641
 
587
- var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$g = _actionRef$current4.getFilterRules) === null || _actionRef$current4$g === void 0 ? void 0 : _actionRef$current4$g.call(_actionRef$current4)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
642
+ var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : (_actionRef$current5$g = _actionRef$current5.getFilterRules) === null || _actionRef$current5$g === void 0 ? void 0 : _actionRef$current5$g.call(_actionRef$current5)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
588
643
 
589
644
  var requestData = formatParams(_objectSpread(_objectSpread({}, !showPagination ? _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, dataFilterParams), propsParams), sortParams), columnsFilterParams) : _objectSpread(_objectSpread(_objectSpread(_objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, targetPageKey, currentPage), _defineProperty(_objectSpread2, targetPageSizeKey, pageSize), _objectSpread2), dataFilterParams), propsParams), sortParams), columnsFilterParams)), params));
590
645
 
@@ -633,10 +688,6 @@ var ProTable = function ProTable(props) {
633
688
  }
634
689
 
635
690
  useEffect(function () {
636
- var _dataFilterForm3;
637
-
638
- // 初始化 actionRef state、callback 此时 actionRef 已初始化完成
639
- initActionRef();
640
691
  dataFilterForm = dataFilterFormRef.current; // 监听 浏览器变化 更吸底状态
641
692
 
642
693
  if (footerSuction) {
@@ -647,11 +698,21 @@ var ProTable = function ProTable(props) {
647
698
  };
648
699
  }
649
700
 
650
- if (requestWhenMount && ((_dataFilterForm3 = dataFilterForm) === null || _dataFilterForm3 === void 0 ? void 0 : _dataFilterForm3.id)) {
651
- // 在请求发送之前 处理漏斗默认数据
652
- processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
701
+ if (propsDataFilter) {
702
+ var _dataFilterForm3;
703
+
704
+ if (requestWhenMount && ((_dataFilterForm3 = dataFilterForm) === null || _dataFilterForm3 === void 0 ? void 0 : _dataFilterForm3.id)) {
705
+ // 在请求发送之前 处理漏斗默认数据
706
+ processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
707
+
708
+ _request();
709
+ }
710
+ } else {
711
+ if (requestWhenMount) {
712
+ processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
653
713
 
654
- _request();
714
+ _request();
715
+ }
655
716
  }
656
717
 
657
718
  return function () {
@@ -680,11 +741,11 @@ var ProTable = function ProTable(props) {
680
741
  mode: 'inline'
681
742
  }, propsDataFilter), {}, {
682
743
  onFilter: function onFilter(values) {
683
- var _actionRef$current5, _actionRef$current5$c;
744
+ var _actionRef$current6, _actionRef$current6$c;
684
745
 
685
746
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(values)); // 搜索变化时,暂时先清空选择
686
747
 
687
- (_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);
748
+ (_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);
688
749
  setCurrentPage(1);
689
750
 
690
751
  _request(_defineProperty({}, targetPageKey, 1));
@@ -780,21 +841,21 @@ var ProTable = function ProTable(props) {
780
841
 
781
842
  var renderFooter = function renderFooter() {
782
843
  function onChangePagination(currentPage) {
783
- var _actionRef$current6, _actionRef$current6$c;
844
+ var _actionRef$current7, _actionRef$current7$c;
784
845
 
785
846
  var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
786
847
  // 翻页暂时先清空选择
787
- (_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);
848
+ (_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);
788
849
  setCurrentPage(currentPage);
789
850
 
790
851
  _request(_objectSpread(_defineProperty({}, targetPageKey, currentPage), params));
791
852
  }
792
853
 
793
854
  function onChangePaginationSize(currentPageSize) {
794
- var _actionRef$current7, _actionRef$current7$c, _request5;
855
+ var _actionRef$current8, _actionRef$current8$c, _request5;
795
856
 
796
857
  // 翻页暂时先清空选择
797
- (_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);
858
+ (_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);
798
859
  setPageSize(currentPageSize);
799
860
  setCurrentPage(1);
800
861
 
@@ -114,4 +114,8 @@ $fullscreenPadding: 24px;
114
114
  // 后面在基础组件里面覆盖
115
115
  .next-table.next-table td .next-table-cell-wrapper {
116
116
  text-overflow: unset;
117
+ }
118
+
119
+ .mb8 {
120
+ margin-bottom: 8px;
117
121
  }
@@ -201,8 +201,6 @@ export declare type ProTableActionTypeMutations = {
201
201
  getState?: () => ProTableActionTypeState;
202
202
  /** 设置state 状态 */
203
203
  setState?: (key: string, value: any) => void;
204
- /** 初始化 state 状态 */
205
- initState?: () => void;
206
204
  /** 设置全屏状态 */
207
205
  setFullScreenState?: (state: boolean) => void;
208
206
  /** 绑定state监听事件 */
@@ -217,6 +215,8 @@ export declare type ProTableActionTypeMutations = {
217
215
  resetTableMaxBodyHeight?: () => void;
218
216
  /** 列筛选规则 */
219
217
  filterColumns?: any[];
218
+ /** 获取所有 on 监听事件 */
219
+ getCallback?: () => any;
220
220
  };
221
221
  /** action Mutations 定义 */
222
222
  export declare type ProTableActionTypeState = {
@@ -144,7 +144,7 @@ export var renderCell = function renderCell(value, item, index, record, actionRe
144
144
 
145
145
  if (valueType === 'selectGroup') {
146
146
  newRender = _objectSpread(_objectSpread({
147
- maxShowNumber: 1,
147
+ maxShowNumber: 'auto',
148
148
  foldText: 'more',
149
149
  editOnClick: function editOnClick() {},
150
150
  edit: true
@@ -1,13 +1,14 @@
1
1
  /// <reference types="react" />
2
2
  import { ProTableActionType } from '../typing';
3
3
  import { ProTableProps, ProTableColumnProps } from '..';
4
- export declare function initActionRef(): void;
4
+ export declare function actionRefUseStateOn(callback: any, state: string, ...args: any): void;
5
5
  /** table 组件内监听 不对外暴露 */
6
6
  export declare function on(fun: any, key: string): void;
7
7
  /** table 组件内销毁监听 不对外暴露 */
8
8
  export declare function off(key: string): void;
9
9
  /** table 组件内触发事件 不对外暴露 */
10
10
  export declare function emit(key: string, ...args: any): void;
11
+ export declare function initActionRef(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
11
12
  export declare function useActionType<T>(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
12
13
  export declare function cloneDeep<T>(obj: T): T;
13
14
  /**
@@ -16,129 +16,76 @@ 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'; // 组件内全局状态 每次初始化 ActionRef 会重新深拷贝对象
20
-
21
- var state = {
22
- fullScreenState: false,
23
- filterRules: {},
24
- filterColumns: []
25
- };
26
-
27
- var _initState = cloneDeepLodash(state); // state监听事件 每次初始化 ActionRef 会重新深拷贝对象
28
-
29
-
30
- var callback = {
31
- fullScreenState: {}
32
- };
33
- var initCallback = cloneDeepLodash(callback); // 所有 ProTable 组件公用一套组件内事件转发机制
34
-
35
- var tableCallback = {}; // 组件内监听事件
36
- // 组件内对全局状态的更改
37
-
38
- var mutations = {
39
- getState: function getState() {
40
- return state;
41
- },
42
- setState: function setState(key, value) {
43
- state[key] = value;
44
- useOn(key, value);
45
-
46
- if (mutations.hasOwnProperty(key)) {
47
- mutations[key] = value;
48
- }
49
- },
50
- initState: function initState() {
51
- state = cloneDeepLodash(_initState);
52
- },
53
- filterColumns: state.filterColumns,
54
- setFullScreenState: function setFullScreenState(fullScreenState) {
55
- state.fullScreenState = fullScreenState;
56
- useOn('fullScreenState', fullScreenState);
57
- },
58
-
59
- /**
60
- * 设置筛选列规则
61
- * @param rules 规则
62
- * @param dataIndex column.dataIndex
63
- */
64
- setFilterRules: function setFilterRules(rules) {
65
- state.filterRules = rules;
66
- },
67
-
68
- /**
69
- * 获取筛选规则。为params
70
- */
71
- getFilterRules: function getFilterRules() {
72
- var result = {};
73
-
74
- if (state.filterRules) {
75
- result = Object.entries(state.filterRules).map(function (_ref) {
76
- var _ref2 = _slicedToArray(_ref, 2),
77
- k = _ref2[0],
78
- v = _ref2[1];
79
-
80
- return _defineProperty({}, k, v.params);
81
- }).reduce(function (acc, cur) {
82
- acc = _objectSpread(_objectSpread({}, acc), cur);
83
- return acc;
84
- }, {});
85
- }
19
+ import cloneDeepLodash from 'lodash.clonedeep'; // 所有 ProTable 组件公用一套组件内事件转发机制
20
+
21
+ var tableCallback = {}; // 组件内对全局状态的更改
22
+
23
+ var getMutations = function getMutations(actionRef) {
24
+ var _actionRef$current2, _actionRef$current2$g, _actionRef$current2$g2;
25
+
26
+ return {
27
+ setFullScreenState: function setFullScreenState(fullScreenState) {
28
+ var _actionRef$current, _actionRef$current$se;
29
+
30
+ (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$se = _actionRef$current.setState) === null || _actionRef$current$se === void 0 ? void 0 : _actionRef$current$se.call(_actionRef$current, 'fullScreenState', fullScreenState);
31
+ },
32
+ filterColumns: (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$g = _actionRef$current2.getState) === null || _actionRef$current2$g === void 0 ? void 0 : (_actionRef$current2$g2 = _actionRef$current2$g.call(_actionRef$current2)) === null || _actionRef$current2$g2 === void 0 ? void 0 : _actionRef$current2$g2.filterColumns,
33
+
34
+ /**
35
+ * 设置筛选列规则
36
+ * @param rules 规则
37
+ * @param dataIndex column.dataIndex
38
+ */
39
+ setFilterRules: function setFilterRules(rules) {
40
+ var _actionRef$current3, _actionRef$current3$s;
41
+
42
+ (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$s = _actionRef$current3.setState) === null || _actionRef$current3$s === void 0 ? void 0 : _actionRef$current3$s.call(_actionRef$current3, 'filterRules', rules);
43
+ },
44
+
45
+ /**
46
+ * 获取筛选规则。为params
47
+ */
48
+ getFilterRules: function getFilterRules() {
49
+ var _actionRef$current4, _actionRef$current4$g;
50
+
51
+ var result = {};
52
+ var filterRules = (_actionRef$current4 = actionRef.current) === null || _actionRef$current4 === void 0 ? void 0 : (_actionRef$current4$g = _actionRef$current4.getState) === null || _actionRef$current4$g === void 0 ? void 0 : _actionRef$current4$g.call(_actionRef$current4).filterRules;
53
+
54
+ if (filterRules) {
55
+ result = Object.entries(filterRules).map(function (_ref) {
56
+ var _ref2 = _slicedToArray(_ref, 2),
57
+ k = _ref2[0],
58
+ v = _ref2[1];
59
+
60
+ return _defineProperty({}, k, v.params);
61
+ }).reduce(function (acc, cur) {
62
+ acc = _objectSpread(_objectSpread({}, acc), cur);
63
+ return acc;
64
+ }, {});
65
+ }
86
66
 
87
- return result;
88
- },
89
-
90
- /**
91
- * 绑定监听函数
92
- * @param fun 监听函数
93
- * @param state 需要监听的state
94
- * @param name 监听名(作为销毁唯一id使用)
95
- */
96
- on: function on(fun, state, name) {
97
- if (!callback[state]) {
98
- callback[state] = {};
67
+ return result;
99
68
  }
100
-
101
- callback[state][name] = fun;
102
- },
103
- off: function off(name) {
104
- callback = Object.fromEntries(Object.entries(callback).map(function (_ref4) {
105
- var _ref5 = _slicedToArray(_ref4, 2),
106
- k = _ref5[0],
107
- v = _ref5[1];
108
-
109
- var filterV = Object.fromEntries(Object.entries(v).filter(function (_ref6) {
110
- var _ref7 = _slicedToArray(_ref6, 1),
111
- k = _ref7[0];
112
-
113
- return k !== name;
114
- }));
115
- return [k, filterV];
116
- }));
117
- }
69
+ };
118
70
  }; // 调用绑定的监听函数
119
71
 
120
- var useOn = function useOn(state) {
121
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
122
- args[_key - 1] = arguments[_key];
72
+
73
+ export function actionRefUseStateOn(callback, state) {
74
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
75
+ args[_key - 2] = arguments[_key];
123
76
  }
124
77
 
125
78
  if (callback[state]) {
126
- Object.entries(callback[state]).forEach(function (_ref8) {
127
- var _ref9 = _slicedToArray(_ref8, 2),
128
- k = _ref9[0],
129
- v = _ref9[1];
79
+ Object.entries(callback[state]).forEach(function (_ref4) {
80
+ var _ref5 = _slicedToArray(_ref4, 2),
81
+ k = _ref5[0],
82
+ v = _ref5[1];
130
83
 
131
84
  if (v) {
132
85
  v === null || v === void 0 ? void 0 : v.apply(void 0, args);
133
86
  }
134
87
  });
135
88
  }
136
- }; // 初始化 actionRef
137
-
138
-
139
- export function initActionRef() {
140
- state = cloneDeepLodash(_initState);
141
- callback = cloneDeepLodash(initCallback);
142
89
  }
143
90
  /** table 组件内监听 不对外暴露 */
144
91
 
@@ -165,12 +112,14 @@ export function emit(key) {
165
112
  fun.apply(void 0, args);
166
113
  }
167
114
  }
168
- export function useActionType(ref, action) {
169
- // 合并自定义事件
170
- var userAction = _objectSpread(_objectSpread({}, action), mutations);
115
+ export function initActionRef(ref, action) {
116
+ var userAction = _objectSpread(_objectSpread({}, action), getMutations(ref));
171
117
 
172
118
  ref.current = userAction;
173
119
  }
120
+ export function useActionType(ref, action) {
121
+ ref.current = _objectSpread(_objectSpread({}, ref.current), action);
122
+ }
174
123
  export function cloneDeep(obj) {
175
124
  return cloneDeepLodash(obj);
176
125
  }
@@ -0,0 +1,22 @@
1
+ // 容器滚动条样式
2
+ @mixin hybridcloud-scrollbar {
3
+ &::-webkit-scrollbar {
4
+ width: 12px;
5
+ height: 12px;
6
+ }
7
+ &::-webkit-scrollbar-thumb {
8
+ border-color: transparent;
9
+ border-style: solid;
10
+ border-width: 4px;
11
+ background-clip: content-box;
12
+ border-radius: 6px;
13
+ background-color: var(--scrollbar-thumb-bg);
14
+ &:hover {
15
+ border-width: 3px;
16
+ background-color: var(--scrollbar-thumb-hover-bg);
17
+ }
18
+ }
19
+ &::-webkit-scrollbar-track {
20
+ background-color: transparent;
21
+ }
22
+ }
@@ -35,7 +35,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
35
35
 
36
36
  // 初始化Search组件,内置部分属性
37
37
  var initializeSearch = function initializeSearch(schema) {
38
- var searchName;
38
+ var searchName = '';
39
39
  var initializedSchema = schema.map(function (item) {
40
40
  if (item.component === 'Search') {
41
41
  searchName = item.name;
@@ -104,6 +104,13 @@ var SimpleFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
104
104
  onChange === null || onChange === void 0 ? void 0 : onChange(values, name, value);
105
105
  }
106
106
  }, [searchName, searchValue.current]);
107
+ (0, _react.useEffect)(function () {
108
+ var _props$form$initialVa, _props$form$initialVa2;
109
+
110
+ // 处理Search组件,缓存input的默认值
111
+ var searchDefaultValue = (_props$form$initialVa = props.form.initialValues) === null || _props$form$initialVa === void 0 ? void 0 : (_props$form$initialVa2 = _props$form$initialVa[searchName]) === null || _props$form$initialVa2 === void 0 ? void 0 : _props$form$initialVa2[1];
112
+ searchValue.current = (0, _utils.isValid)(searchDefaultValue) ? searchDefaultValue : '';
113
+ }, []);
107
114
  return /*#__PURE__*/_react.default.createElement(_ProForm.default, _objectSpread(_objectSpread({}, otherProps), {}, {
108
115
  className: (0, _classnames.default)(prefixCls, props.className),
109
116
  schema: simpleSchema,
@@ -24,7 +24,7 @@ export interface ProFormSchemaItem {
24
24
  name?: string;
25
25
  description?: React.ReactNode;
26
26
  title?: string;
27
- component?: IBaseComponent | IButtonComponent | IComboComponent | ILayoutComponent | 'ProField' | any;
27
+ component?: IBaseComponent | IButtonComponent | IComboComponent | ILayoutComponent | any;
28
28
  props?: AnyObject | any;
29
29
  decorator?: string | null;
30
30
  decoratorProps?: AnyObject;
package/lib/index.d.ts CHANGED
@@ -24,5 +24,5 @@ export * from './skeleton';
24
24
  export * from './table';
25
25
  export * from './utils';
26
26
  export * from './step';
27
- declare const version = "1.2.28";
27
+ declare const version = "1.2.32";
28
28
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProStep, hooks, nocode, templates, utils, };
package/lib/index.js CHANGED
@@ -285,5 +285,5 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
285
285
  // 设置图标源
286
286
  _icon.default.setConfig(_utils.default.getTeamixIconConfig());
287
287
 
288
- var version = '1.2.28';
288
+ var version = '1.2.32';
289
289
  exports.version = version;