@teamix/pro 1.2.24 → 1.2.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/dist/pro.css +1 -1
  2. package/dist/pro.js +1043 -94
  3. package/dist/pro.min.css +1 -1
  4. package/dist/pro.min.js +1 -1
  5. package/es/actions/dialog.js +1 -1
  6. package/es/actions/index.d.ts +13 -9
  7. package/es/actions/index.js +63 -18
  8. package/es/actions/index.scss +12 -1
  9. package/es/form/SchemaForm/index.js +8 -6
  10. package/es/form/SchemaForm/initializeDataSource.d.ts +1 -1
  11. package/es/form/SchemaForm/initializeDataSource.js +2 -2
  12. package/es/form/SchemaForm/initializeRequest.d.ts +1 -1
  13. package/es/form/SchemaForm/initializeRequest.js +2 -2
  14. package/es/form/SchemaForm/initializeRules.d.ts +1 -1
  15. package/es/form/SchemaForm/initializeRules.js +3 -3
  16. package/es/form/typing.d.ts +0 -9
  17. package/es/form/utils.d.ts +2 -2
  18. package/es/form/utils.js +2 -2
  19. package/es/index.d.ts +5 -2
  20. package/es/index.js +6 -3
  21. package/es/step/ProStepItem/components/HozStepItem/index.d.ts +5 -0
  22. package/es/step/ProStepItem/components/HozStepItem/index.js +235 -0
  23. package/es/step/ProStepItem/components/HozStepItem/index.scss +279 -0
  24. package/es/step/ProStepItem/components/VerStepItem/index.d.ts +5 -0
  25. package/es/step/ProStepItem/components/VerStepItem/index.js +295 -0
  26. package/es/step/ProStepItem/components/VerStepItem/index.scss +287 -0
  27. package/es/step/ProStepItem/index.d.ts +4 -0
  28. package/es/step/ProStepItem/index.js +57 -0
  29. package/es/step/index.d.ts +9 -0
  30. package/es/step/index.js +101 -0
  31. package/es/step/typing.d.ts +96 -0
  32. package/es/step/typing.js +1 -0
  33. package/es/table/components/Filter/index.js +2 -17
  34. package/es/table/index.js +7 -3
  35. package/es/table/typing.d.ts +11 -2
  36. package/es/table/utils/index.d.ts +7 -0
  37. package/es/table/utils/index.js +36 -0
  38. package/es/utils/index.d.ts +1 -0
  39. package/es/utils/index.js +1 -0
  40. package/lib/actions/dialog.js +1 -1
  41. package/lib/actions/index.d.ts +13 -9
  42. package/lib/actions/index.js +63 -18
  43. package/lib/actions/index.scss +12 -1
  44. package/lib/form/SchemaForm/index.js +8 -6
  45. package/lib/form/SchemaForm/initializeDataSource.d.ts +1 -1
  46. package/lib/form/SchemaForm/initializeDataSource.js +2 -2
  47. package/lib/form/SchemaForm/initializeRequest.d.ts +1 -1
  48. package/lib/form/SchemaForm/initializeRequest.js +2 -2
  49. package/lib/form/SchemaForm/initializeRules.d.ts +1 -1
  50. package/lib/form/SchemaForm/initializeRules.js +3 -3
  51. package/lib/form/typing.d.ts +0 -9
  52. package/lib/form/utils.d.ts +2 -2
  53. package/lib/form/utils.js +2 -2
  54. package/lib/index.d.ts +5 -2
  55. package/lib/index.js +35 -3
  56. package/lib/step/ProStepItem/components/HozStepItem/index.d.ts +5 -0
  57. package/lib/step/ProStepItem/components/HozStepItem/index.js +258 -0
  58. package/lib/step/ProStepItem/components/HozStepItem/index.scss +279 -0
  59. package/lib/step/ProStepItem/components/VerStepItem/index.d.ts +5 -0
  60. package/lib/step/ProStepItem/components/VerStepItem/index.js +315 -0
  61. package/lib/step/ProStepItem/components/VerStepItem/index.scss +287 -0
  62. package/lib/step/ProStepItem/index.d.ts +4 -0
  63. package/lib/step/ProStepItem/index.js +69 -0
  64. package/lib/step/index.d.ts +9 -0
  65. package/lib/step/index.js +124 -0
  66. package/lib/step/typing.d.ts +96 -0
  67. package/lib/step/typing.js +5 -0
  68. package/lib/table/components/Filter/index.js +2 -17
  69. package/lib/table/index.js +6 -2
  70. package/lib/table/typing.d.ts +11 -2
  71. package/lib/table/utils/index.d.ts +7 -0
  72. package/lib/table/utils/index.js +38 -0
  73. package/lib/utils/index.d.ts +1 -0
  74. package/lib/utils/index.js +13 -0
  75. package/package.json +1 -1
@@ -0,0 +1,101 @@
1
+ var _excluded = ["mode", "items", "shape", "children"];
2
+
3
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
4
+
5
+ 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; }
6
+
7
+ 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; }
8
+
9
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
10
+
11
+ 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; }
12
+
13
+ import React, { useMemo } from 'react';
14
+ import { Step, Timeline } from '@alicloudfe/components';
15
+ import ProStepItem from './ProStepItem';
16
+
17
+ var ProStep = function ProStep(props) {
18
+ var mode = props.mode,
19
+ items = props.items,
20
+ shape = props.shape,
21
+ children = props.children,
22
+ others = _objectWithoutProperties(props, _excluded);
23
+
24
+ var current = props.current,
25
+ labelPlacement = props.labelPlacement,
26
+ readOnly = props.readOnly,
27
+ animation = props.animation,
28
+ size = props.size;
29
+ var fold = props.fold; // 判断渲染组件是不是 ProStepItem, 并返回筛选后的children
30
+
31
+ var renderChildren = useMemo(function () {
32
+ return React.Children.map(children, function (child, index) {
33
+ var childElement = child;
34
+ var displayName = childElement.type.displayName;
35
+
36
+ if (displayName === 'ProStepItem') {
37
+ return /*#__PURE__*/React.cloneElement(childElement, {
38
+ _size: size,
39
+ _mode: mode,
40
+ _index: index,
41
+ _current: current,
42
+ _shape: shape
43
+ });
44
+ } // 如果不是 ProStepItem
45
+
46
+
47
+ console.error('Warning: ProStep has a child which is not a ProStepItem component');
48
+ });
49
+ }, [children]); // 设置circle, 覆盖 dot 阻止重新渲染节点样式
50
+
51
+ var shapeMap = function shapeMap() {
52
+ if (shape === 'arrow') return 'arrow';
53
+ return 'circle';
54
+ }; // 渲染 ProStepItem
55
+
56
+
57
+ var renderItem = function renderItem() {
58
+ // 传递了 item 采用 item 渲染数组的方式
59
+ if (items) {
60
+ return items.map(function (item, index) {
61
+ return /*#__PURE__*/React.createElement(ProStepItem, _objectSpread({
62
+ key: index,
63
+ _mode: mode,
64
+ _shape: shape,
65
+ _index: index,
66
+ _current: current,
67
+ _size: size
68
+ }, item));
69
+ });
70
+ } else {
71
+ return renderChildren;
72
+ }
73
+ }; // 渲染 ProStep
74
+
75
+
76
+ var renderProStep = function renderProStep() {
77
+ if (mode === 'ver') {
78
+ return /*#__PURE__*/React.createElement(Timeline, _objectSpread({
79
+ fold: fold
80
+ }, others), renderItem());
81
+ }
82
+
83
+ return /*#__PURE__*/React.createElement(Step, _objectSpread({
84
+ current: current,
85
+ shape: shapeMap(),
86
+ labelPlacement: labelPlacement,
87
+ readOnly: readOnly,
88
+ animation: animation
89
+ }, others), renderItem());
90
+ };
91
+
92
+ return /*#__PURE__*/React.createElement("div", {
93
+ className: "teamix-pro-step"
94
+ }, renderProStep());
95
+ };
96
+
97
+ ProStep.Item = ProStepItem;
98
+ ProStep.defaultProps = {
99
+ mode: 'hoz'
100
+ };
101
+ export { ProStep, ProStepItem };
@@ -0,0 +1,96 @@
1
+ import { ItemProps as StepItemProps } from '@alicloudfe/components/types/step';
2
+ import { ItemProps as TimeLineItemProps } from '@alicloudfe/components/types/timeline';
3
+ import { ReactNode } from 'react';
4
+ import { ProTagItem } from '@teamix/utils';
5
+ export declare type ProStepItemStatus = 'success' | 'fail' | 'process' | 'warning' | 'wait';
6
+ export declare type ModeStatusFromProStep = {
7
+ _mode?: string | 'hoz' | 'ver';
8
+ };
9
+ export declare type FoldProps = {
10
+ foldArea: [number, number];
11
+ foldShow: boolean;
12
+ };
13
+ export declare type ProStepProps = HozStepProps | VerTimeLineProps;
14
+ export declare type ProStepBaseProps = {
15
+ /** 步骤条:节点展示类型*/
16
+ shape?: 'icon' | 'arrow' | 'dot' | 'number';
17
+ /** style */
18
+ style?: React.CSSProperties;
19
+ /** className */
20
+ className?: string;
21
+ } & React.HTMLAttributes<HTMLElement>;
22
+ export interface HozStepProps extends ProStepBaseProps {
23
+ /** 当前组件的展示形式 */
24
+ mode?: 'hoz';
25
+ /** 内部渲染自组件 */
26
+ items?: HozStepItemProps[];
27
+ /** 步骤条:当前步骤 */
28
+ current?: number;
29
+ /** 步骤条: 横向布局时( direction 为 hoz )的内容排列*/
30
+ labelPlacement?: 'hoz' | 'ver';
31
+ /** 步骤条: 是否可读模式 */
32
+ readOnly?: boolean;
33
+ /** 步骤条: 是否开启动效 */
34
+ animation?: boolean;
35
+ /**dot 形态下切换size */
36
+ size?: 'normal' | 'small';
37
+ }
38
+ export interface VerTimeLineProps extends ProStepBaseProps {
39
+ /** 当前组件的展示形式 */
40
+ mode?: 'ver';
41
+ /** 内部渲染自组件 */
42
+ items?: VerStepItemProps[];
43
+ /** 时间线: 自定义折叠选项 */
44
+ fold?: FoldProps[];
45
+ }
46
+ export interface ProStepItemBaseProps {
47
+ /**步骤条:节点展示类型 */
48
+ _shape?: 'icon' | 'arrow' | 'dot' | 'number';
49
+ /**节点索引 */
50
+ _index?: number;
51
+ /**活跃节点 */
52
+ _current?: number;
53
+ /**节点状态 */
54
+ status?: string | ProStepItemStatus;
55
+ /**节点设置为 icon 图标 */
56
+ icon?: string;
57
+ /**节点的内容 */
58
+ content?: ReactNode;
59
+ /**节点标题 */
60
+ title?: ReactNode;
61
+ /**自定义渲染 */
62
+ dotRender?: (index?: number, status?: string) => ReactNode;
63
+ /**点击事件 */
64
+ onClick?: (index: number) => void;
65
+ /**百分比展示 */
66
+ percent?: number;
67
+ /**是否禁用当前节点 */
68
+ disabled?: boolean;
69
+ }
70
+ export interface HozStepItemProps extends ProStepItemBaseProps {
71
+ /**dot 形态下切换size */
72
+ _size?: 'normal' | 'small';
73
+ }
74
+ export interface VerStepItemProps extends ProStepItemBaseProps {
75
+ /**节点副标题,在 timeline 可以展示格式化后的时间 */
76
+ subTitle?: ReactNode;
77
+ /**节点对应描述 */
78
+ discription?: ReactNode;
79
+ /**节点的 tag */
80
+ tags?: ProTagItem[] | ReactNode;
81
+ /**左侧展示内容 */
82
+ timeLeft?: ReactNode;
83
+ /**头像 */
84
+ image?: string | ReactNode;
85
+ /**是否需要 animation 动画 */
86
+ animation?: boolean;
87
+ /**卡片是否可折叠 */
88
+ collapsible?: boolean;
89
+ /**默认是否折叠,用于非受控模式 */
90
+ defaultCollapsed?: boolean;
91
+ /**是否折叠,受控模式 */
92
+ collapsed?: boolean;
93
+ /**折叠状态改变的回调函数 */
94
+ onCollapse?: (collapsed: boolean) => void;
95
+ }
96
+ export declare type ProStepItemProps = (HozStepItemProps | VerStepItemProps) & React.HTMLAttributes<HTMLElement> & StepItemProps & TimeLineItemProps;
@@ -0,0 +1 @@
1
+ export {};
@@ -150,8 +150,6 @@ var Filter = function Filter(props) {
150
150
  setVisible(!visible);
151
151
  }
152
152
  }),
153
- //@ts-ignore
154
- v2: true,
155
153
  triggerType: ['click'],
156
154
  align: "tl bl",
157
155
  visible: visible,
@@ -189,20 +187,7 @@ var Filter = function Filter(props) {
189
187
  } // 需要带上其他所有的信息
190
188
 
191
189
 
192
- var rules = (_actionRef$current$ge5 = (_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$ge5 !== void 0 ? _actionRef$current$ge5 : {};
193
- var params = Object.fromEntries([].concat(_toConsumableArray(Object.entries(rules).map(function (_ref5) {
194
- var _ref6 = _slicedToArray(_ref5, 2),
195
- k = _ref6[0],
196
- v = _ref6[1];
197
-
198
- if (v) {
199
- return [k, v.params];
200
- }
201
-
202
- return null;
203
- })), [[column.dataIndex, param]]).filter(function (item) {
204
- return item && (item === null || item === void 0 ? void 0 : item[1]);
205
- })); // 再设置所有的列筛选状态
190
+ var rules = (_actionRef$current$ge5 = (_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$ge5 !== void 0 ? _actionRef$current$ge5 : {}; // 再设置所有的列筛选状态
206
191
 
207
192
  (_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, {
208
193
  rules: selected,
@@ -220,7 +205,7 @@ var Filter = function Filter(props) {
220
205
  } // 发送请求
221
206
 
222
207
 
223
- (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$r = _actionRef$current6.request) === null || _actionRef$current6$r === void 0 ? void 0 : _actionRef$current6$r.call(_actionRef$current6, _objectSpread(_objectSpread({}, params), {}, _defineProperty({}, targetPageKey, 1)));
208
+ (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$r = _actionRef$current6.request) === null || _actionRef$current6$r === void 0 ? void 0 : _actionRef$current6$r.call(_actionRef$current6, _defineProperty({}, targetPageKey, 1));
224
209
  (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.resetPage) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7); // 清空表格选择
225
210
 
226
211
  (_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);
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", "responsivePaginationType", "showSkeleton", "skeletonSize", "actionRef", "dataSource", "filterDebounce", "footerSuction", "autoRefresh", "customRequest", "filterColumnType"];
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", "defaultFilterParams"];
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
 
@@ -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, useActionType } from './utils';
43
+ import { 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';
@@ -164,6 +164,7 @@ var ProTable = function ProTable(props) {
164
164
  customRequest = props.customRequest,
165
165
  _props$filterColumnTy = props.filterColumnType,
166
166
  filterColumnType = _props$filterColumnTy === void 0 ? 'auto' : _props$filterColumnTy,
167
+ defaultFilterParams = props.defaultFilterParams,
167
168
  otherProps = _objectWithoutProperties(props, _excluded);
168
169
 
169
170
  var targetPageKey = pageKey || globalPageKey;
@@ -632,6 +633,9 @@ var ProTable = function ProTable(props) {
632
633
  }
633
634
 
634
635
  if (requestWhenMount) {
636
+ // 在请求发送之前 处理漏斗默认数据
637
+ processDefaultFilter(propsColumns, actionRef, defaultFilterParams);
638
+
635
639
  _request();
636
640
  }
637
641
 
@@ -786,7 +790,7 @@ var ProTable = function ProTable(props) {
786
790
 
787
791
  var targetActions = footerAction.actions.map(function (action) {
788
792
  return _objectSpread(_objectSpread({}, action), {}, {
789
- disabled: action.disabled || selectedCount === 0
793
+ disabled: (action === null || action === void 0 ? void 0 : action.disabled) || selectedCount === 0
790
794
  });
791
795
  });
792
796
 
@@ -3,7 +3,7 @@
3
3
  */
4
4
  import { ColumnProps, TableProps } from '@alicloudfe/components/types/table';
5
5
  import { ProFieldType, ProFieldRenderProps, ProFieldDataSourceItem } from '../field';
6
- import { QueryFilterProps } from '../form';
6
+ import { IFilterProps } from '../form';
7
7
  import { ProActionGroupProps, ProActionButtonProps } from '../actions';
8
8
  import { PaginationProps } from '@alicloudfe/components/types/pagination';
9
9
  import { HeaderProps as ProTableHeaderProps } from '@teamix/utils';
@@ -125,6 +125,10 @@ export declare type ProTableProps = {
125
125
  data: any[];
126
126
  total?: number;
127
127
  }>;
128
+ /** 默认漏斗过滤条件 */
129
+ defaultFilterParams?: {
130
+ [key: string]: any[] | any;
131
+ };
128
132
  } & Omit<TableProps, 'columns'> & ProTableTopAreaProps;
129
133
  export declare type rowSelectionType = {
130
134
  getProps?: (record: any, index: number) => any;
@@ -215,12 +219,17 @@ export declare type ProTableActionTypeState = {
215
219
  [key: string]: any;
216
220
  };
217
221
  export declare type ProTableDataFilterProps = {
222
+ /** 展示形式 */
223
+ mode?: 'inline' | 'panel';
224
+ /** mode='panel' 时是否默认展开 */
225
+ expand?: boolean;
226
+ /** 搜索时是否传入值为undefined的参数,默认不传 */
218
227
  searchUndefined?: boolean;
219
228
  /** 搜索时是否传入值为空字符串的参数,默认不传 */
220
229
  searchEmptyString?: boolean;
221
230
  /** 自定义内容 */
222
231
  content?: React.ReactNode;
223
- } & QueryFilterProps;
232
+ } & IFilterProps;
224
233
  export declare type dataFilterProps = ProTableDataFilterProps;
225
234
  export declare type ProTableTopAreaProps = {
226
235
  /** 标题区 */
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ProTableActionType } from '../typing';
3
+ import { ProTableProps, ProTableColumnProps } from '..';
3
4
  export declare function initActionRef(): void;
4
5
  /** table 组件内监听 不对外暴露 */
5
6
  export declare function on(fun: any, key: string): void;
@@ -9,3 +10,9 @@ export declare function off(key: string): void;
9
10
  export declare function emit(key: string, ...args: any): void;
10
11
  export declare function useActionType<T>(ref: React.MutableRefObject<ProTableActionType | undefined>, action: ProTableActionType): void;
11
12
  export declare function cloneDeep<T>(obj: T): T;
13
+ /**
14
+ * 处理默认过滤参数
15
+ * @param columns
16
+ * @param ref
17
+ */
18
+ export declare function processDefaultFilter(columns: ProTableColumnProps[], ref: React.MutableRefObject<ProTableActionType | undefined>, defaultFilterParams: ProTableProps['defaultFilterParams']): void;
@@ -173,4 +173,40 @@ export function useActionType(ref, action) {
173
173
  }
174
174
  export function cloneDeep(obj) {
175
175
  return cloneDeepLodash(obj);
176
+ }
177
+ /**
178
+ * 处理默认过滤参数
179
+ * @param columns
180
+ * @param ref
181
+ */
182
+
183
+ export function processDefaultFilter(columns, ref, defaultFilterParams) {
184
+ columns.forEach(function (column) {
185
+ var _column$dataIndex$toS, _column$dataIndex;
186
+
187
+ var defaultRules = defaultFilterParams === null || defaultFilterParams === void 0 ? void 0 : defaultFilterParams[(_column$dataIndex$toS = column === null || column === void 0 ? void 0 : (_column$dataIndex = column.dataIndex) === null || _column$dataIndex === void 0 ? void 0 : _column$dataIndex.toString()) !== null && _column$dataIndex$toS !== void 0 ? _column$dataIndex$toS : ''];
188
+
189
+ if (defaultRules) {
190
+ var _ref$current$getState, _ref$current, _ref$current$getState2, _ref$current$getState3, _ref$current2, _ref$current2$setFilt;
191
+
192
+ var params = '';
193
+ var rules = [];
194
+
195
+ if (Array.isArray(defaultRules)) {
196
+ params = defaultRules.join(',');
197
+ rules = defaultRules;
198
+ } else {
199
+ params = defaultRules;
200
+ rules = [defaultRules];
201
+ } // 需要带上其他所有的信息
202
+
203
+
204
+ var otherRules = (_ref$current$getState = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : (_ref$current$getState2 = _ref$current.getState) === null || _ref$current$getState2 === void 0 ? void 0 : (_ref$current$getState3 = _ref$current$getState2.call(_ref$current)) === null || _ref$current$getState3 === void 0 ? void 0 : _ref$current$getState3.filterRules) !== null && _ref$current$getState !== void 0 ? _ref$current$getState : {}; // 再设置所有的列筛选状态
205
+
206
+ (_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : (_ref$current2$setFilt = _ref$current2.setFilterRules) === null || _ref$current2$setFilt === void 0 ? void 0 : _ref$current2$setFilt.call(_ref$current2, _objectSpread(_objectSpread({}, otherRules), {}, _defineProperty({}, column.dataIndex, {
207
+ rules: rules,
208
+ params: params
209
+ })));
210
+ }
211
+ });
176
212
  }
@@ -1,2 +1,3 @@
1
1
  import * as utils from '@teamix/utils';
2
+ export * from '@teamix/utils';
2
3
  export default utils;
package/es/utils/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  import * as utils from '@teamix/utils';
2
+ export * from '@teamix/utils';
2
3
  export default utils;
@@ -255,7 +255,7 @@ function useDialogAction(action, actionContext) {
255
255
  })), _objectSpread2), containerProps), containerOtherProps);
256
256
 
257
257
  var ret = container.show(quickShowProps);
258
- store.hide = ret.hide;
258
+ store.hide = ret ? ret.hide || ret.close : function () {};
259
259
  };
260
260
 
261
261
  return _objectSpread({}, (0, _base.eventHandler)(action, actionContext, onActionStart));
@@ -26,25 +26,27 @@ export declare type ProActionConfig = ({
26
26
  } & LinkAction);
27
27
  export declare function registerActionHandler(id: string, extendActionId: string, defaultConfig: any): void;
28
28
  export declare function useAction(config?: ProActionConfig, context?: any): any;
29
- export interface ProActionButtonProps extends ButtonProps {
30
- key?: string | number;
29
+ export interface ProActionButtonProps extends ProActionCommonProps, ButtonProps {
31
30
  config?: ProActionConfig;
32
- visible?: any;
33
31
  disabled?: any;
34
32
  icon?: string;
35
- context?: any;
36
33
  onClick?: (event: React.MouseEvent<Element, MouseEvent>, context?: any) => void;
37
34
  }
38
35
  export declare const ProActionButton: (props: ProActionButtonProps) => JSX.Element;
39
- export interface ProActionMenuButtonProps extends MenuButtonProps {
36
+ export interface ProActionCommonProps {
40
37
  key?: string | number;
41
- actions: ProActionProps[];
42
38
  visible?: any;
43
- icon?: string;
44
39
  context?: any;
45
40
  }
41
+ export interface ProActionMenuButtonProps extends ProActionCommonProps, Omit<MenuButtonProps, 'visible'> {
42
+ actions: ProActionProps[];
43
+ icon?: string;
44
+ }
46
45
  export declare const ProActionMenuButton: (props: ProActionMenuButtonProps) => JSX.Element;
47
- export declare type ProActionProps = ProActionButtonProps | ProActionMenuButtonProps;
46
+ export interface ProActionDividerProps extends ProActionCommonProps {
47
+ type: 'divider';
48
+ }
49
+ export declare type ProActionProps = ProActionButtonProps | ProActionMenuButtonProps | ProActionDividerProps;
48
50
  export declare type ProActionGroupProps = {
49
51
  /** 操作组类型:按钮、文字按钮 */
50
52
  type?: 'button' | 'text';
@@ -59,7 +61,9 @@ export declare type ProActionGroupProps = {
59
61
  */
60
62
  moreText?: string;
61
63
  /** 更多按钮的配置,只有在actions数量超过max时才有效 */
62
- more?: string | ProActionButtonProps;
64
+ more?: string | (ProActionButtonProps & {
65
+ noArrow?: boolean;
66
+ });
63
67
  /** 是否有分割线,只有type="text"时生效,默认有分割线 */
64
68
  divider?: boolean;
65
69
  } & React.HTMLAttributes<HTMLElement>;
@@ -58,9 +58,10 @@ var _excluded = ["type"],
58
58
  _excluded3 = ["loading"],
59
59
  _excluded4 = ["icon", "iconSize", "label", "actions", "children", "context", "type"],
60
60
  _excluded5 = ["context", "text"],
61
- _excluded6 = ["key", "actions"],
62
- _excluded7 = ["key", "config"],
63
- _excluded8 = ["type", "divider", "max", "moreText", "more", "context", "actions", "className"];
61
+ _excluded6 = ["noArrow", "className"],
62
+ _excluded7 = ["key", "actions"],
63
+ _excluded8 = ["key", "config"],
64
+ _excluded9 = ["type", "divider", "max", "moreText", "more", "context", "actions", "className"];
64
65
 
65
66
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
66
67
 
@@ -248,6 +249,12 @@ var ProActionMenuButtonItem = function ProActionMenuButtonItem(props) {
248
249
  };
249
250
 
250
251
  function renderCommonActionButtonMenuItem(action, key, context) {
252
+ if (action.type === 'divider') {
253
+ return /*#__PURE__*/_react.default.createElement(_components.Menu.Divider, {
254
+ key: key
255
+ });
256
+ }
257
+
251
258
  var menuBtn = action;
252
259
 
253
260
  if (menuBtn.actions && menuBtn.actions.length && menuBtn.disabled !== true) {
@@ -292,27 +299,48 @@ var ProActionMenuButton = function ProActionMenuButton(props) {
292
299
  }, others), actions.map(function (action, i) {
293
300
  return renderCommonActionButtonMenuItem(action, action.key || i, context);
294
301
  }));
295
- }; // 如果 actions 数量超过了 max,则把第 max 个和剩余超出部分折叠起来成为一个 menu
302
+ }; // 超出 max,则折叠起来
296
303
 
297
304
 
298
305
  exports.ProActionMenuButton = ProActionMenuButton;
299
306
 
300
- function formatGroupActions(actions, max, moreConfig) {
301
- var MAX = max < 1 ? MAX_ACTTIONS : max;
302
-
303
- if (actions.length <= MAX) {
307
+ function foldExtraActions(actions, max, moreConfig) {
308
+ if (actions.length <= max) {
304
309
  return actions;
305
310
  }
306
311
 
307
- return [].concat(_toConsumableArray(actions.slice(0, MAX - 1)), [_objectSpread(_objectSpread({
312
+ return [].concat(_toConsumableArray(actions.slice(0, max - 1)), [_objectSpread(_objectSpread({
308
313
  key: '__teamix_pro_action_group_more_btn'
309
314
  }, moreConfig), {}, {
310
- actions: actions.slice(MAX - 1)
315
+ actions: actions.slice(max - 1)
311
316
  })]);
317
+ } // 如果 actions 数量超过了 max,则把第 max 个和剩余超出部分折叠起来成为一个 menu
318
+ // divider 不计数
319
+
320
+
321
+ function formatGroupActions(actions, max, moreConfig) {
322
+ var MAX = max < 1 ? MAX_ACTTIONS : max;
323
+ var count = 0;
324
+ var index = 0;
325
+
326
+ for (; index < actions.length && count < MAX; index++) {
327
+ if (actions[index].type !== 'divider') {
328
+ count += 1;
329
+ }
330
+ }
331
+
332
+ return foldExtraActions(actions, Math.max(index, MAX), moreConfig);
312
333
  } // 渲染一个 button 或者 menu button
313
334
 
314
335
 
315
336
  function renderCommonActionButton(button, context, isTypeText) {
337
+ if (button.type === 'divider') {
338
+ return /*#__PURE__*/_react.default.createElement(_components.Divider, {
339
+ key: button.key,
340
+ direction: "ver"
341
+ });
342
+ }
343
+
316
344
  var buttonContext = button.context,
317
345
  text = button.text,
318
346
  others = _objectWithoutProperties(button, _excluded5);
@@ -330,18 +358,35 @@ function renderCommonActionButton(button, context, isTypeText) {
330
358
  }
331
359
 
332
360
  function getDefaultMoreButton(type, more) {
333
- var moreConfig = typeof more === 'string' ? {
334
- children: more
335
- } : more;
361
+ var noArrowClassName = 'teamix-pro-actions-text-menu-btn-no-arrow';
336
362
  var defaultConfig = type === 'button' ? {
337
363
  children: (0, _utils.getMessage)('more')
338
364
  } : {
339
365
  icon: 'more-line',
340
366
  // iconSize: 'small',
341
367
  autoWidth: false,
342
- className: 'teamix-pro-actions-text-menu-btn-no-arrow'
368
+ className: noArrowClassName
343
369
  };
344
- return Object.assign(defaultConfig, moreConfig);
370
+
371
+ if (!more) {
372
+ return defaultConfig;
373
+ }
374
+
375
+ var moreConfig = typeof more === 'string' ? {
376
+ children: more
377
+ } : more;
378
+
379
+ if (type === 'button') {
380
+ return Object.assign(defaultConfig, moreConfig);
381
+ }
382
+
383
+ var noArrow = moreConfig.noArrow,
384
+ className = moreConfig.className,
385
+ others = _objectWithoutProperties(moreConfig, _excluded6);
386
+
387
+ return _objectSpread({
388
+ className: (0, _classnames.default)(className, _defineProperty({}, "".concat(noArrowClassName), noArrow))
389
+ }, others);
345
390
  }
346
391
 
347
392
  var MAX_ACTTIONS = 4;
@@ -358,7 +403,7 @@ function getActionConfig(action, index, context) {
358
403
  if (action.actions) {
359
404
  var _key = action.key,
360
405
  actions = action.actions,
361
- _others = _objectWithoutProperties(action, _excluded6);
406
+ _others = _objectWithoutProperties(action, _excluded7);
362
407
 
363
408
  return _objectSpread({
364
409
  key: getKey(index, _key),
@@ -370,7 +415,7 @@ function getActionConfig(action, index, context) {
370
415
 
371
416
  var key = action.key,
372
417
  config = action.config,
373
- others = _objectWithoutProperties(action, _excluded7);
418
+ others = _objectWithoutProperties(action, _excluded8);
374
419
 
375
420
  return _objectSpread({
376
421
  key: getKey(index, key),
@@ -391,7 +436,7 @@ function ProActionGroup(props) {
391
436
  _props$actions = props.actions,
392
437
  actions = _props$actions === void 0 ? [] : _props$actions,
393
438
  className = props.className,
394
- containerProps = _objectWithoutProperties(props, _excluded8);
439
+ containerProps = _objectWithoutProperties(props, _excluded9);
395
440
 
396
441
  var isTypeText = type === 'text';
397
442
  var filteredActions = actions.map(function (action, index) {
@@ -2,12 +2,23 @@
2
2
  display: flex;
3
3
  align-items: center;
4
4
  flex-wrap: wrap;
5
+
6
+ & > .next-divider {
7
+ & + .next-divider {
8
+ display: none;
9
+ }
10
+ }
11
+
5
12
  &.teamix-pro-actions-type-button {
6
13
  & > button {
7
14
  &:not(:last-child) {
8
15
  margin-right: var(--s-2);
9
16
  }
10
17
  }
18
+ & > .next-divider {
19
+ margin-left: 0;
20
+ margin-right: var(--s-2);
21
+ }
11
22
  }
12
23
 
13
24
  &.teamix-pro-actions-type-text:not(.teamix-pro-actions-divider) {
@@ -109,4 +120,4 @@
109
120
  }
110
121
  }
111
122
  }
112
- }
123
+ }