@teamix/pro 1.5.13 → 1.5.15

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 (57) hide show
  1. package/dist/pro.all.min.css +1 -1
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +187 -135
  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/actions/dialog.js +1 -1
  8. package/es/actions/index.scss +1 -1
  9. package/es/card/index.scss +2 -0
  10. package/es/card/xconsole.scss +3 -0
  11. package/es/global.scss +1 -0
  12. package/es/index.d.ts +1 -1
  13. package/es/index.js +1 -1
  14. package/es/next-xconsole.scss +34 -0
  15. package/es/nocode/configurators/ProTable.js +1 -22
  16. package/es/nocode/pages/index.js +1 -26
  17. package/es/page-header/index.scss +2 -1
  18. package/es/page-header/xconsole.scss +5 -0
  19. package/es/table/components/Filter/index.d.ts +5 -3
  20. package/es/table/components/Filter/index.js +84 -63
  21. package/es/table/components/Layout/index.js +5 -2
  22. package/es/table/components/Layout/index.scss +1 -0
  23. package/es/table/index.js +39 -6
  24. package/es/table/typing.d.ts +14 -0
  25. package/es/table/utils/columnRender.d.ts +2 -2
  26. package/es/table/utils/columnRender.js +4 -2
  27. package/es/table/utils/genProColumnToColumn.d.ts +2 -2
  28. package/es/table/utils/genProColumnToColumn.js +3 -1
  29. package/es/table/utils/util.d.ts +5 -0
  30. package/es/table/utils/util.js +19 -0
  31. package/es/xconsole.scss +6 -1
  32. package/lib/actions/dialog.js +1 -1
  33. package/lib/actions/index.scss +1 -1
  34. package/lib/card/index.scss +2 -0
  35. package/lib/card/xconsole.scss +3 -0
  36. package/lib/global.scss +1 -0
  37. package/lib/index.d.ts +1 -1
  38. package/lib/index.js +1 -1
  39. package/lib/next-xconsole.scss +34 -0
  40. package/lib/nocode/configurators/ProTable.js +1 -22
  41. package/lib/nocode/pages/index.js +1 -26
  42. package/lib/page-header/index.scss +2 -1
  43. package/lib/page-header/xconsole.scss +5 -0
  44. package/lib/table/components/Filter/index.d.ts +5 -3
  45. package/lib/table/components/Filter/index.js +83 -62
  46. package/lib/table/components/Layout/index.js +5 -2
  47. package/lib/table/components/Layout/index.scss +1 -0
  48. package/lib/table/index.js +39 -6
  49. package/lib/table/typing.d.ts +14 -0
  50. package/lib/table/utils/columnRender.d.ts +2 -2
  51. package/lib/table/utils/columnRender.js +4 -2
  52. package/lib/table/utils/genProColumnToColumn.d.ts +2 -2
  53. package/lib/table/utils/genProColumnToColumn.js +3 -1
  54. package/lib/table/utils/util.d.ts +5 -0
  55. package/lib/table/utils/util.js +25 -0
  56. package/lib/xconsole.scss +6 -1
  57. package/package.json +1 -1
@@ -210,7 +210,7 @@ export function useDialogAction(action, actionContext, hasForm) {
210
210
  className: classnames('teamix-pro-dialog-footer-description', getFooterAlignClass(isDrawer, footerAlign))
211
211
  }, renderDialogFooterDescription(footerDescription)))), _defineProperty(_objectSpread2, "footerAlign", footerAlign), _defineProperty(_objectSpread2, "className", classnames('teamix-pro-action-dialog', {
212
212
  'has-footer-description': !!footerDescription
213
- })), _defineProperty(_objectSpread2, "footer", addContextForReactNode(footer, dialogContext)), _objectSpread2), containerProps), containerOtherProps);
213
+ })), _defineProperty(_objectSpread2, isDrawer ? 'renderFooter' : 'footer', addContextForReactNode(footer, dialogContext)), _objectSpread2), containerProps), containerOtherProps);
214
214
  // TODO Drawer 基础组件未支持此配置,日后支持,并修改onOk、onCancel写法
215
215
  if ((!dialogType || dialogType === 'dialog') && hideFooter) {
216
216
  quickShowProps['footer'] = !hideFooter;
@@ -10,7 +10,7 @@
10
10
  }
11
11
 
12
12
  &.teamix-pro-actions-type-button {
13
- & > button {
13
+ & > button,& > span {
14
14
  &:not(:last-child) {
15
15
  margin-right: var(--s-2);
16
16
  }
@@ -1,3 +1,5 @@
1
+ @import "xconsole";
2
+
1
3
  .teamix-pro-card {
2
4
  width: 100%;
3
5
 
@@ -0,0 +1,3 @@
1
+ .theme-xconsole {
2
+
3
+ }
package/es/global.scss CHANGED
@@ -1,4 +1,5 @@
1
1
  @import "./xconsole.scss";
2
+ @import "next-xconsole";
2
3
  // transition 切换主题优化,暂时先写到 pro 里,后面加到基础组件里
3
4
 
4
5
  // table 行背景色
package/es/index.d.ts CHANGED
@@ -28,5 +28,5 @@ export * from './table';
28
28
  export * from './sidebar';
29
29
  export * from './utils';
30
30
  export * from './timeline';
31
- declare const version = "1.5.13";
31
+ declare const version = "1.5.15";
32
32
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, hooks, nocode, templates, utils, };
package/es/index.js CHANGED
@@ -35,7 +35,7 @@ export * from './table';
35
35
  export * from './sidebar';
36
36
  export * from './utils';
37
37
  export * from './timeline';
38
- var version = '1.5.13';
38
+ var version = '1.5.15';
39
39
  // By TeamixTest
40
40
  window.postMessage({
41
41
  source: 'teamix-test-devtools',
@@ -0,0 +1,34 @@
1
+ .theme-xconsole {
2
+ //.next-drawer-header {
3
+ // color: var(--color-text-1, #1A1A1A)
4
+ //}
5
+ //.next-message.next-message-success.next-toast .next-message-title {
6
+ // color: var(--color-text-1, #1A1A1A)
7
+ //}
8
+
9
+ --message-success-color-border-toast: var(--color-border-4, #E5E5E5);
10
+
11
+ /* --card-border-color: var(--color-text1-4, #E3E4E6); */
12
+ --card-border-color: var(--color-border-4, #E5E5E5);
13
+ /* --tab-pure-divider-border-color: var(--color-text1-4, #e5e5e5); */
14
+ --tab-pure-divider-border-color: var(--color-border-4, #E5E5E5);
15
+ --drawer-title-border-color: var(--color-border-4, #E5E5E5);
16
+
17
+ --popup-local-border-color: var(--color-border-4, #E5E5E5);
18
+
19
+ --btn-pure-normal-bg-disabled: var(--color-fill-2, #F7F7F7);
20
+ --checkbox-disabled-bg-color: var(--color-border-1, #D9D9D9);
21
+
22
+ --btn-pure-normal-border-color-disabled: var(--color-border-1, #D9D9D9);
23
+ --btn-pure-primary-border-color-disabled: var(--color-border-1, #D9D9D9);
24
+
25
+ --tab-item-margin-lr-size-m: 16px;
26
+ --tab-pure-hover-bg: transparent;
27
+
28
+ --progress-line-underlay-color: var(--color-border-4, #E5E5E5);
29
+ --range-normal-unselected-color: var(--color-border-4, #E5E5E5);
30
+
31
+ .next-formily-item-inset {
32
+ border: 1px solid var(--color-border-1, #D9D9D9);
33
+ }
34
+ }
@@ -1,27 +1,6 @@
1
1
  import { array, actions, actionGroup, filter } from './common';
2
2
  var initialValues = {
3
- columns: [{
4
- dataIndex: 'instanceName',
5
- title: '实例ID/实例名称'
6
- }, {
7
- dataIndex: 'organizationName',
8
- title: '组织',
9
- tooltip: '我这一列是可以被复制的~',
10
- render: {
11
- copy: true
12
- }
13
- }],
14
- url: 'https://oneapi.alibaba-inc.com/mock/teamix-pro/api/getTableResource',
15
- formatResult: {
16
- data: 'data',
17
- total: 'pageInfo.total'
18
- },
19
- mainAction: {
20
- actions: [{
21
- key: 'action',
22
- children: '操作按钮'
23
- }]
24
- }
3
+ columns: []
25
4
  };
26
5
  var defaultValues = {
27
6
  showSkeleton: true,
@@ -10,32 +10,7 @@ export var PageMap = {
10
10
  };
11
11
  // 全部页面模板默认初始值
12
12
  export var PageDefaultInitialValues = {
13
- LIST: {
14
- header: {
15
- title: '页面标题'
16
- },
17
- content: {
18
- header: {
19
- title: '表格标题'
20
- },
21
- columns: [{
22
- dataIndex: 'instanceName',
23
- title: '实例ID/实例名称'
24
- }, {
25
- dataIndex: 'organizationName',
26
- title: '组织',
27
- tooltip: '我这一列是可以被复制的~',
28
- render: {
29
- copy: true
30
- }
31
- }],
32
- url: 'https://oneapi.alibaba-inc.com/mock/teamix-pro/api/getTableResource',
33
- formatResult: {
34
- data: 'data',
35
- total: 'pageInfo.total'
36
- }
37
- }
38
- },
13
+ LIST: {},
39
14
  DETAIL: {},
40
15
  FORM: {}
41
16
  };
@@ -1,3 +1,4 @@
1
+ @import "xconsole";
1
2
  $prefix: 'teamix-pro-page-header';
2
3
 
3
4
  .#{$prefix} {
@@ -12,7 +13,7 @@ $prefix: 'teamix-pro-page-header';
12
13
  justify-content: space-between;
13
14
  align-items: center;
14
15
  min-height: 18px;
15
- height: var(--layout-header-height, auto);
16
+ height: auto;
16
17
  margin-bottom: var(--s-2, 8px);
17
18
 
18
19
  &.with-description {
@@ -0,0 +1,5 @@
1
+ .theme-xconsole {
2
+ .teamix-pro-page-header .teamix-pro-page-header-title{
3
+ color: var(--color-text-1, #1A1A1A);
4
+ }
5
+ }
@@ -1,10 +1,12 @@
1
1
  import React from 'react';
2
2
  import './index.scss';
3
- import { ProTableColumnProps, ProTableActionType } from '../../typing';
3
+ import { ProTableColumnProps, ProTableActionType, ProTableProps } from '../../typing';
4
4
  declare type ProTableFilterProps = {
5
5
  column: ProTableColumnProps;
6
6
  actionRef: React.MutableRefObject<ProTableActionType | undefined>;
7
7
  switchCardView?: 'table' | 'card';
8
+ bindUrl?: ProTableProps['bindUrl'];
9
+ bindUrlProps?: ProTableProps['bindUrlProps'];
8
10
  };
9
- declare const Filter: React.FC<ProTableFilterProps>;
10
- export default Filter;
11
+ declare const _default: React.NamedExoticComponent<ProTableFilterProps>;
12
+ export default _default;
@@ -12,22 +12,30 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
12
12
  function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
13
13
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
14
14
  // 表格项列筛选
15
- import React, { useEffect, useMemo, useState } from 'react';
15
+ import React, { useEffect, useMemo, useState, memo } from 'react';
16
16
  import TeamixIcon from '@teamix/icon';
17
17
  import { Button, Dropdown, Menu } from '@alicloudfe/components';
18
18
  import { usePrefixCls, getMessage } from '@teamix/utils';
19
19
  import './index.scss';
20
+ import { useUrlState } from '@teamix/hooks';
20
21
  var CheckboxItem = Menu.CheckboxItem;
21
22
  var cls = usePrefixCls('teamix-pro-table-toolbar-filter');
22
23
  var RadioItem = Menu.RadioItem;
23
24
  var Filter = function Filter(props) {
25
+ var _urlState$split, _urlState, _urlState$split2;
24
26
  var column = props.column,
25
27
  actionRef = props.actionRef,
26
- switchCardView = props.switchCardView;
28
+ switchCardView = props.switchCardView,
29
+ bindUrlProps = props.bindUrlProps,
30
+ bindUrl = props.bindUrl;
27
31
  var _column$filtersWidth = column.filtersWidth,
28
32
  filtersWidth = _column$filtersWidth === void 0 ? 130 : _column$filtersWidth;
33
+ var _useUrlState = useUrlState(),
34
+ _useUrlState2 = _slicedToArray(_useUrlState, 2),
35
+ urlState = _useUrlState2[0],
36
+ setUrlState = _useUrlState2[1];
29
37
  // 选中过滤项
30
- var _useState = useState([]),
38
+ var _useState = useState((_urlState$split = urlState === null || urlState === void 0 ? void 0 : (_urlState = urlState["filter".concat(column === null || column === void 0 ? void 0 : column.dataIndex)]) === null || _urlState === void 0 ? void 0 : (_urlState$split2 = _urlState.split) === null || _urlState$split2 === void 0 ? void 0 : _urlState$split2.call(_urlState, ',')) !== null && _urlState$split !== void 0 ? _urlState$split : []),
31
39
  _useState2 = _slicedToArray(_useState, 2),
32
40
  selected = _useState2[0],
33
41
  setSelected = _useState2[1];
@@ -39,7 +47,10 @@ var Filter = function Filter(props) {
39
47
  var _actionRef$current$ge, _actionRef$current, _actionRef$current$ge2, _actionRef$current$ge3, _actionRef$current$ge4, _actionRef$current$ge5;
40
48
  // 从全局状态中读取上次存储的条件
41
49
  var rules = (_actionRef$current$ge = (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$ge2 = _actionRef$current.getState) === null || _actionRef$current$ge2 === void 0 ? void 0 : (_actionRef$current$ge3 = _actionRef$current$ge2.call(_actionRef$current)) === null || _actionRef$current$ge3 === void 0 ? void 0 : (_actionRef$current$ge4 = _actionRef$current$ge3.filterRules) === null || _actionRef$current$ge4 === void 0 ? void 0 : (_actionRef$current$ge5 = _actionRef$current$ge4[column.dataIndex]) === null || _actionRef$current$ge5 === void 0 ? void 0 : _actionRef$current$ge5.rules) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : [];
42
- setSelected(rules);
50
+ // 全局状态中需要有值才赋值。优先级:全局状态 > urlState
51
+ if (rules && rules.length > 0) {
52
+ setSelected(rules);
53
+ }
43
54
  }, []);
44
55
  // 获取过滤项
45
56
  var filters = useMemo(function () {
@@ -66,6 +77,72 @@ var Filter = function Filter(props) {
66
77
  // console.log(filters);
67
78
  return filters;
68
79
  }, []);
80
+ // 点击确定回调
81
+ var onFilterOk = function onFilterOk() {
82
+ var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge6, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current4$s, _actionRef$current5, _actionRef$current7, _actionRef$current7$r, _actionRef$current8, _actionRef$current8$r, _actionRef$current9, _actionRef$current9$c;
83
+ (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$f = _actionRef$current2.filterDataSource) === null || _actionRef$current2$f === void 0 ? void 0 : _actionRef$current2$f.call(_actionRef$current2, column.dataIndex);
84
+ // 先获取此列的param
85
+ var param = '';
86
+ if (column.beforeFilter) {
87
+ var _column$beforeFilter;
88
+ param = (_column$beforeFilter = column.beforeFilter) === null || _column$beforeFilter === void 0 ? void 0 : _column$beforeFilter.call(column, selected);
89
+ } else {
90
+ param = selected.join(',');
91
+ }
92
+ // 需要带上其他所有的信息
93
+ var rules = (_actionRef$current$ge6 = (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$g = _actionRef$current3.getState) === null || _actionRef$current3$g === void 0 ? void 0 : (_actionRef$current3$g2 = _actionRef$current3$g.call(_actionRef$current3)) === null || _actionRef$current3$g2 === void 0 ? void 0 : _actionRef$current3$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
94
+ // 再设置所有的列筛选状态
95
+ (_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, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
96
+ rules: selected,
97
+ params: param
98
+ })));
99
+ var targetPageKey = 'currentPage';
100
+ var pageInfo = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : _actionRef$current5.pageInfo;
101
+ if (pageInfo && (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey)) {
102
+ targetPageKey = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey;
103
+ }
104
+ if (switchCardView === 'card') {
105
+ var _actionRef$current6, _actionRef$current6$s;
106
+ (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$s = _actionRef$current6.setData) === null || _actionRef$current6$s === void 0 ? void 0 : _actionRef$current6$s.call(_actionRef$current6, []);
107
+ }
108
+ // 发送请求
109
+ (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.request) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7, _defineProperty({}, targetPageKey, 1));
110
+ (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$r = _actionRef$current8.resetPage) === null || _actionRef$current8$r === void 0 ? void 0 : _actionRef$current8$r.call(_actionRef$current8);
111
+ // 清空表格选择
112
+ (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$c = _actionRef$current9.clearRowSelection) === null || _actionRef$current9$c === void 0 ? void 0 : _actionRef$current9$c.call(_actionRef$current9);
113
+ setVisible(false);
114
+ // 设置 url
115
+ if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.headerFilters) !== false && (urlState === null || urlState === void 0 ? void 0 : urlState["filter".concat(column === null || column === void 0 ? void 0 : column.dataIndex)]) !== selected.join(',')) {
116
+ setUrlState(_defineProperty({}, "filter".concat(column === null || column === void 0 ? void 0 : column.dataIndex), selected.join(',')));
117
+ }
118
+ };
119
+ // 重置回调
120
+ var onFilterReset = function onFilterReset() {
121
+ var _actionRef$current$ge7, _actionRef$current10, _actionRef$current10$, _actionRef$current10$2, _actionRef$current11, _actionRef$current11$, _actionRef$current12, _actionRef$current12$;
122
+ setSelected([]);
123
+ var rules = (_actionRef$current$ge7 = (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.getState) === null || _actionRef$current10$ === void 0 ? void 0 : (_actionRef$current10$2 = _actionRef$current10$.call(_actionRef$current10)) === null || _actionRef$current10$2 === void 0 ? void 0 : _actionRef$current10$2.filterRules) !== null && _actionRef$current$ge7 !== void 0 ? _actionRef$current$ge7 : {};
124
+ (_actionRef$current11 = actionRef.current) === null || _actionRef$current11 === void 0 ? void 0 : (_actionRef$current11$ = _actionRef$current11.setFilterRules) === null || _actionRef$current11$ === void 0 ? void 0 : _actionRef$current11$.call(_actionRef$current11, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
125
+ rules: [],
126
+ params: ''
127
+ })));
128
+ (_actionRef$current12 = actionRef.current) === null || _actionRef$current12 === void 0 ? void 0 : (_actionRef$current12$ = _actionRef$current12.filterDataSource) === null || _actionRef$current12$ === void 0 ? void 0 : _actionRef$current12$.call(_actionRef$current12, column.dataIndex);
129
+ if (selected.length > 0) {
130
+ var _actionRef$current13, _actionRef$current14, _actionRef$current14$, _actionRef$current15, _actionRef$current15$, _actionRef$current16, _actionRef$current16$;
131
+ var targetPageKey = 'currentPage';
132
+ var pageInfo = (_actionRef$current13 = actionRef.current) === null || _actionRef$current13 === void 0 ? void 0 : _actionRef$current13.pageInfo;
133
+ if (pageInfo && (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey)) {
134
+ targetPageKey = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey;
135
+ }
136
+ // 发送请求
137
+ (_actionRef$current14 = actionRef.current) === null || _actionRef$current14 === void 0 ? void 0 : (_actionRef$current14$ = _actionRef$current14.request) === null || _actionRef$current14$ === void 0 ? void 0 : _actionRef$current14$.call(_actionRef$current14, _defineProperty({}, targetPageKey, 1));
138
+ (_actionRef$current15 = actionRef.current) === null || _actionRef$current15 === void 0 ? void 0 : (_actionRef$current15$ = _actionRef$current15.resetPage) === null || _actionRef$current15$ === void 0 ? void 0 : _actionRef$current15$.call(_actionRef$current15);
139
+ // 清空表格选择
140
+ (_actionRef$current16 = actionRef.current) === null || _actionRef$current16 === void 0 ? void 0 : (_actionRef$current16$ = _actionRef$current16.clearRowSelection) === null || _actionRef$current16$ === void 0 ? void 0 : _actionRef$current16$.call(_actionRef$current16);
141
+ if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.headerFilters) !== false) {
142
+ setUrlState(_defineProperty({}, "filter".concat(column === null || column === void 0 ? void 0 : column.dataIndex), undefined));
143
+ }
144
+ }
145
+ };
69
146
  // 渲染单选
70
147
  var renderSingle = function renderSingle() {
71
148
  return filters === null || filters === void 0 ? void 0 : filters.map(function (_ref3) {
@@ -145,70 +222,14 @@ var Filter = function Filter(props) {
145
222
  className: cls({
146
223
  btn: true
147
224
  }),
148
- onClick: function onClick() {
149
- var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge6, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current4$s, _actionRef$current5, _actionRef$current7, _actionRef$current7$r, _actionRef$current8, _actionRef$current8$r, _actionRef$current9, _actionRef$current9$c;
150
- (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$f = _actionRef$current2.filterDataSource) === null || _actionRef$current2$f === void 0 ? void 0 : _actionRef$current2$f.call(_actionRef$current2, column.dataIndex);
151
- // 先获取此列的param
152
- var param = '';
153
- if (column.beforeFilter) {
154
- var _column$beforeFilter;
155
- param = (_column$beforeFilter = column.beforeFilter) === null || _column$beforeFilter === void 0 ? void 0 : _column$beforeFilter.call(column, selected);
156
- } else {
157
- param = selected.join(',');
158
- }
159
- // 需要带上其他所有的信息
160
- var rules = (_actionRef$current$ge6 = (_actionRef$current3 = actionRef.current) === null || _actionRef$current3 === void 0 ? void 0 : (_actionRef$current3$g = _actionRef$current3.getState) === null || _actionRef$current3$g === void 0 ? void 0 : (_actionRef$current3$g2 = _actionRef$current3$g.call(_actionRef$current3)) === null || _actionRef$current3$g2 === void 0 ? void 0 : _actionRef$current3$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
161
- // 再设置所有的列筛选状态
162
- (_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, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
163
- rules: selected,
164
- params: param
165
- })));
166
- var targetPageKey = 'currentPage';
167
- var pageInfo = (_actionRef$current5 = actionRef.current) === null || _actionRef$current5 === void 0 ? void 0 : _actionRef$current5.pageInfo;
168
- if (pageInfo && (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey)) {
169
- targetPageKey = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey;
170
- }
171
- if (switchCardView === 'card') {
172
- var _actionRef$current6, _actionRef$current6$s;
173
- (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$s = _actionRef$current6.setData) === null || _actionRef$current6$s === void 0 ? void 0 : _actionRef$current6$s.call(_actionRef$current6, []);
174
- }
175
- // 发送请求
176
- (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.request) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7, _defineProperty({}, targetPageKey, 1));
177
- (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$r = _actionRef$current8.resetPage) === null || _actionRef$current8$r === void 0 ? void 0 : _actionRef$current8$r.call(_actionRef$current8);
178
- // 清空表格选择
179
- (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$c = _actionRef$current9.clearRowSelection) === null || _actionRef$current9$c === void 0 ? void 0 : _actionRef$current9$c.call(_actionRef$current9);
180
- setVisible(false);
181
- }
225
+ onClick: onFilterOk
182
226
  }, getMessage('ok')), /*#__PURE__*/React.createElement(Button, {
183
227
  type: "normal",
184
228
  size: "small",
185
229
  className: cls({
186
230
  btn: true
187
231
  }),
188
- onClick: function onClick() {
189
- var _actionRef$current$ge7, _actionRef$current10, _actionRef$current10$, _actionRef$current10$2, _actionRef$current11, _actionRef$current11$, _actionRef$current12, _actionRef$current12$;
190
- setSelected([]);
191
- var rules = (_actionRef$current$ge7 = (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.getState) === null || _actionRef$current10$ === void 0 ? void 0 : (_actionRef$current10$2 = _actionRef$current10$.call(_actionRef$current10)) === null || _actionRef$current10$2 === void 0 ? void 0 : _actionRef$current10$2.filterRules) !== null && _actionRef$current$ge7 !== void 0 ? _actionRef$current$ge7 : {};
192
- (_actionRef$current11 = actionRef.current) === null || _actionRef$current11 === void 0 ? void 0 : (_actionRef$current11$ = _actionRef$current11.setFilterRules) === null || _actionRef$current11$ === void 0 ? void 0 : _actionRef$current11$.call(_actionRef$current11, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
193
- rules: [],
194
- params: ''
195
- })));
196
- (_actionRef$current12 = actionRef.current) === null || _actionRef$current12 === void 0 ? void 0 : (_actionRef$current12$ = _actionRef$current12.filterDataSource) === null || _actionRef$current12$ === void 0 ? void 0 : _actionRef$current12$.call(_actionRef$current12, column.dataIndex);
197
- if (selected.length > 0) {
198
- var _actionRef$current13, _actionRef$current14, _actionRef$current14$, _actionRef$current15, _actionRef$current15$, _actionRef$current16, _actionRef$current16$;
199
- var targetPageKey = 'currentPage';
200
- var pageInfo = (_actionRef$current13 = actionRef.current) === null || _actionRef$current13 === void 0 ? void 0 : _actionRef$current13.pageInfo;
201
- if (pageInfo && (pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey)) {
202
- targetPageKey = pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.targetPageKey;
203
- }
204
- // 发送请求
205
- (_actionRef$current14 = actionRef.current) === null || _actionRef$current14 === void 0 ? void 0 : (_actionRef$current14$ = _actionRef$current14.request) === null || _actionRef$current14$ === void 0 ? void 0 : _actionRef$current14$.call(_actionRef$current14, _defineProperty({}, targetPageKey, 1));
206
- (_actionRef$current15 = actionRef.current) === null || _actionRef$current15 === void 0 ? void 0 : (_actionRef$current15$ = _actionRef$current15.resetPage) === null || _actionRef$current15$ === void 0 ? void 0 : _actionRef$current15$.call(_actionRef$current15);
207
- // 清空表格选择
208
- (_actionRef$current16 = actionRef.current) === null || _actionRef$current16 === void 0 ? void 0 : (_actionRef$current16$ = _actionRef$current16.clearRowSelection) === null || _actionRef$current16$ === void 0 ? void 0 : _actionRef$current16$.call(_actionRef$current16);
209
- }
210
- // setVisible(!visible);
211
- }
232
+ onClick: onFilterReset
212
233
  }, getMessage('reset'))))));
213
234
  };
214
- export default Filter;
235
+ export default /*#__PURE__*/memo(Filter);
@@ -1,4 +1,4 @@
1
- var _excluded = ["header", "mainAction", "extra", "actionRef", "dataFilter", "dataFilterFormRef", "afterDataFilter", "rowSelection", "toolBar", "dataTeamixSpm"];
1
+ var _excluded = ["header", "mainAction", "extra", "actionRef", "dataFilter", "dataFilterFormRef", "afterDataFilter", "rowSelection", "toolBar", "dataTeamixSpm", "bindUrl", "bindUrlProps"];
2
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; }
3
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; }
4
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; }
@@ -25,6 +25,8 @@ var Layout = function Layout(props) {
25
25
  rowSelection = props.rowSelection,
26
26
  toolBar = props.toolBar,
27
27
  dataTeamixSpm = props.dataTeamixSpm,
28
+ bindUrl = props.bindUrl,
29
+ bindUrlProps = props.bindUrlProps,
28
30
  otherProps = _objectWithoutProperties(props, _excluded);
29
31
  // 渲染主操作区
30
32
  var renderMainAction = function renderMainAction() {
@@ -103,7 +105,8 @@ var Layout = function Layout(props) {
103
105
  (dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.onExpand) && (dataFilter === null || dataFilter === void 0 ? void 0 : dataFilter.onExpand(expand));
104
106
  },
105
107
  addonBefore: renderMainAction(),
106
- addonAfter: renderAddonAfter()
108
+ addonAfter: renderAddonAfter(),
109
+ bindUrl: bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.filters) !== false
107
110
  }, dataFilter)), afterDataFilter && /*#__PURE__*/React.createElement("div", {
108
111
  className: "mb8 ".concat(cls('after-data-filter-wrapper'))
109
112
  }, afterDataFilter));
@@ -43,5 +43,6 @@ $prefix: 'teamix-pro-table-layout';
43
43
  &-addon-after-wrapper {
44
44
  display: flex;
45
45
  align-items: center;
46
+ margin-bottom: 8px;
46
47
  }
47
48
  }
package/es/table/index.js CHANGED
@@ -1,4 +1,4 @@
1
- var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "autoRefreshProps", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps"],
1
+ var _excluded = ["header", "className", "tableClassName", "mainAction", "extra", "dataFilter", "afterDataFilter", "toolBar", "columns", "useRowSelection", "rowSelection", "onChangeRowSelection", "getRowSelection", "primaryKey", "footerAction", "footer", "url", "pageKey", "pageSizeKey", "method", "params", "formatSort", "formatParams", "formatResult", "requestConfig", "requestWhenMount", "showPagination", "pageSizeList", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "autoRefreshProps", "customRequest", "filterColumnType", "defaultFilterParams", "reserveSelectedRecords", "size", "disableSelectAll", "context", "fixedTableBody", "isTree", "toolBarAutoWidth", "data-teamix-spm", "switchCardView", "cardViewProps", "defaultView", "emptyProps", "bindUrlProps", "bindUrl"],
2
2
  _excluded2 = ["onChange"];
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
  function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
@@ -35,6 +35,8 @@ import classNames from 'classnames';
35
35
  import ProPageContainer from '../page-container';
36
36
  import debounce from 'lodash.debounce';
37
37
  import CardView from './components/CardView';
38
+ import { useUrlState } from '@teamix/hooks';
39
+ import { getUrlStateFilter } from './utils/util';
38
40
  export * from './typing';
39
41
  var cls = usePrefixCls('teamix-pro-table');
40
42
  /**
@@ -83,7 +85,7 @@ var globalFormatSort = function globalFormatSort(sort) {
83
85
  return {};
84
86
  };
85
87
  var ProTable = function ProTable(props) {
86
- var _rowSelection$selecte;
88
+ var _urlState$currentPage, _rowSelection$selecte;
87
89
  var header = props.header,
88
90
  className = props.className,
89
91
  tableClassName = props.tableClassName,
@@ -156,15 +158,21 @@ var ProTable = function ProTable(props) {
156
158
  _props$defaultView = props.defaultView,
157
159
  defaultView = _props$defaultView === void 0 ? 'table' : _props$defaultView,
158
160
  emptyProps = props.emptyProps,
161
+ bindUrlProps = props.bindUrlProps,
162
+ bindUrl = props.bindUrl,
159
163
  otherProps = _objectWithoutProperties(props, _excluded);
160
164
  var targetPageKey = pageKey || globalPageKey;
161
165
  var targetPageSizeKey = pageSizeKey || globalPageSizeKey;
162
166
  var targetFormatSort = formatSort || globalFormatSort;
163
- var _useState = useState(1),
167
+ var _useUrlState = useUrlState(),
168
+ _useUrlState2 = _slicedToArray(_useUrlState, 2),
169
+ urlState = _useUrlState2[0],
170
+ setUrlState = _useUrlState2[1];
171
+ var _useState = useState((_urlState$currentPage = urlState === null || urlState === void 0 ? void 0 : urlState.currentPage) !== null && _urlState$currentPage !== void 0 ? _urlState$currentPage : 1),
164
172
  _useState2 = _slicedToArray(_useState, 2),
165
173
  currentPage = _useState2[0],
166
174
  setCurrentPage = _useState2[1];
167
- var _useState3 = useState(props.pageSize || 10),
175
+ var _useState3 = useState((urlState === null || urlState === void 0 ? void 0 : urlState.pageSize) || props.pageSize || 10),
168
176
  _useState4 = _slicedToArray(_useState3, 2),
169
177
  pageSize = _useState4[0],
170
178
  setPageSize = _useState4[1];
@@ -206,6 +214,24 @@ var ProTable = function ProTable(props) {
206
214
  _useState20 = _slicedToArray(_useState19, 2),
207
215
  showLoading = _useState20[0],
208
216
  setShowLoading = _useState20[1];
217
+ // 表格内部用作存储的 Ref,标识 Table 组件是否被第一次渲染。用作 useUrlState filter 第一次渲染时使用 state 数据请求
218
+ var dataRef = useRef({
219
+ flag: true
220
+ });
221
+ useEffect(function () {
222
+ if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.pagination) !== false) {
223
+ if ((urlState === null || urlState === void 0 ? void 0 : urlState.currentPage) !== currentPage) {
224
+ setUrlState({
225
+ currentPage: currentPage
226
+ });
227
+ }
228
+ if ((urlState === null || urlState === void 0 ? void 0 : urlState.pageSize) !== pageSize) {
229
+ setUrlState({
230
+ pageSize: pageSize
231
+ });
232
+ }
233
+ }
234
+ }, [currentPage, pageSize, urlState]);
209
235
  // 存储能够被 on 监听到的 ProTable 状态
210
236
  // 因为只做存储用。不需要更新视图以及需要同步更改。所以不使用 setState 更新
211
237
  var _useState21 = useState({
@@ -734,6 +760,11 @@ var ProTable = function ProTable(props) {
734
760
  // 请求函数
735
761
  function _request(params, noLoading, filterParams, isReset) {
736
762
  var _dataFilterFormRef$cu2, _actionRef$current$ge, _actionRef$current6, _actionRef$current6$g, _objectSpread3;
763
+ // 首次渲染表格,获取 urlState 上的 表头 filter 数据
764
+ if (bindUrl && (bindUrlProps === null || bindUrlProps === void 0 ? void 0 : bindUrlProps.headerFilters) !== false && dataRef.current.flag) {
765
+ getUrlStateFilter(urlState, actionRef);
766
+ dataRef.current.flag = false;
767
+ }
737
768
  // 如果没有传 url 且没有 customRequest,直接返回
738
769
  if (!url && !customRequest) {
739
770
  return;
@@ -906,11 +937,13 @@ var ProTable = function ProTable(props) {
906
937
  switchCardView: switchCardView,
907
938
  defaultView: defaultView,
908
939
  autoRefresh: autoRefresh,
909
- autoRefreshProps: autoRefreshProps
940
+ autoRefreshProps: autoRefreshProps,
941
+ bindUrlProps: bindUrlProps,
942
+ bindUrl: bindUrl
910
943
  }), switchViewState === 'table' && /*#__PURE__*/React.createElement(Table.StickyLock, _objectSpread({
911
944
  hasBorder: false,
912
945
  dataSource: showSkeleton ? skeletonDataSource : data || props.dataSource,
913
- columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm),
946
+ columns: genProColumnToColumn(filteredColumns, showSkeleton, actionRef, context, dataTeamixSpm, bindUrl, bindUrlProps),
914
947
  loading: getTableLoading(),
915
948
  className: classNames('teamix-pro-table', tableClassName, {
916
949
  'with-row-select': rowSelection,
@@ -168,6 +168,10 @@ export declare type ProTableProps = {
168
168
  defaultView?: 'table' | 'card';
169
169
  /** 空状态配置 **/
170
170
  emptyProps?: EmptyContentProps;
171
+ /** 是否绑定 url **/
172
+ bindUrl?: boolean;
173
+ /** 绑定 url 配置 **/
174
+ bindUrlProps?: ProTableBindUrlProps;
171
175
  } & Omit<TableProps, 'columns'> & ProTableTopAreaProps;
172
176
  export declare type rowSelectionType = {
173
177
  getProps?: (record: any, index: number) => any;
@@ -315,6 +319,8 @@ export declare type ProTableLayoutProps = {
315
319
  defaultView?: 'table' | 'card';
316
320
  autoRefresh?: ProTableProps['autoRefresh'];
317
321
  autoRefreshProps?: ProTableProps['autoRefreshProps'];
322
+ bindUrl?: ProTableProps['bindUrl'];
323
+ bindUrlProps?: ProTableProps['bindUrlProps'];
318
324
  } & ProTableTopAreaProps;
319
325
  /** columns 列过滤 */
320
326
  export declare type ProTableColumnsFilterItemProps = {
@@ -401,4 +407,12 @@ export declare type ProTableCardViewProps = {
401
407
  /** 表格分页器参数 **/
402
408
  tablePaginationProps?: PaginationProps;
403
409
  };
410
+ export declare type ProTableBindUrlProps = {
411
+ /** 翻页器区域 **/
412
+ pagination?: boolean;
413
+ /** 搜索区域 **/
414
+ filters?: boolean;
415
+ /** 表格标题过滤器区域 **/
416
+ headerFilters?: boolean;
417
+ };
404
418
  export {};
@@ -2,11 +2,11 @@
2
2
  * 渲染列的逻辑函数
3
3
  */
4
4
  import React from 'react';
5
- import { ProTableColumnProps, ProTableActionType } from '../typing';
5
+ import { ProTableColumnProps, ProTableActionType, ProTableProps } from '../typing';
6
6
  /**
7
7
  * 增加了 icon 的功能 render title
8
8
  */
9
- export declare const renderColumnsTitle: (item: ProTableColumnProps, actionRef: React.MutableRefObject<ProTableActionType | undefined>) => JSX.Element;
9
+ export declare const renderColumnsTitle: (item: ProTableColumnProps, actionRef: React.MutableRefObject<ProTableActionType | undefined>, bindUrl?: ProTableProps['bindUrl'], bindUrlProps?: ProTableProps['bindUrlProps']) => JSX.Element;
10
10
  /**
11
11
  * 负责单元格的具体渲染
12
12
  */
@@ -22,7 +22,7 @@ import Filter from '../components/Filter';
22
22
  /**
23
23
  * 增加了 icon 的功能 render title
24
24
  */
25
- export var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
25
+ export var renderColumnsTitle = function renderColumnsTitle(item, actionRef, bindUrl, bindUrlProps) {
26
26
  var filterMode = item.filterMode,
27
27
  filters = item.filters,
28
28
  dataSource = item.dataSource,
@@ -79,7 +79,9 @@ export var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
79
79
  icon: item.tooltipIcon
80
80
  }), item.filters && /*#__PURE__*/React.createElement(Filter, {
81
81
  column: item,
82
- actionRef: actionRef
82
+ actionRef: actionRef,
83
+ bindUrl: bindUrl,
84
+ bindUrlProps: bindUrlProps
83
85
  }));
84
86
  };
85
87
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ProTableColumnProps, ProTableActionType } from '../typing';
2
+ import { ProTableColumnProps, ProTableActionType, ProTableProps } from '../typing';
3
3
  import { ColumnProps } from '@alicloudfe/components/types/table';
4
4
  declare type FixedColumnProps = ColumnProps & {
5
5
  wordBreak?: string;
@@ -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): FixedColumnProps[];
12
+ showSkeleton: boolean, actionRef: React.MutableRefObject<ProTableActionType | undefined>, context?: any, dataTeamixSpm?: string, bindUrl?: ProTableProps['bindUrl'], bindUrlProps?: ProTableProps['bindUrlProps']): FixedColumnProps[];
13
13
  export {};
@@ -17,6 +17,8 @@ showSkeleton, actionRef) {
17
17
  var
18
18
  // 用于埋点
19
19
  dataTeamixSpm = arguments.length > 4 ? arguments[4] : undefined;
20
+ var bindUrl = arguments.length > 5 ? arguments[5] : undefined;
21
+ var bindUrlProps = arguments.length > 6 ? arguments[6] : undefined;
20
22
  return columns.map(function (columnProps) {
21
23
  var filters = columnProps.filters,
22
24
  dataIndex = columnProps.dataIndex,
@@ -40,7 +42,7 @@ showSkeleton, actionRef) {
40
42
  }, others), {}, {
41
43
  children: children ? genProColumnToColumn(children, showSkeleton, actionRef, context) : undefined,
42
44
  dataIndex: dataIndex === null || dataIndex === void 0 ? void 0 : dataIndex.toString(),
43
- title: renderColumnsTitle(columnProps, actionRef),
45
+ title: renderColumnsTitle(columnProps, actionRef, bindUrl, bindUrlProps),
44
46
  cell: function cell(value, index, record) {
45
47
  return renderCell(value, columnProps, index, record, actionRef, context, dataTeamixSpm);
46
48
  }