@teamix/pro 1.2.12 → 1.2.13

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.
@@ -393,7 +393,11 @@ var ProTable = function ProTable(props) {
393
393
  }
394
394
  }, [propsActionRef]);
395
395
  (0, _react.useEffect)(function () {
396
- setFilteredColumns(processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : []));
396
+ var _actionRef$current, _actionRef$current$se;
397
+
398
+ var columns = processColumns(propsColumns !== null && propsColumns !== void 0 ? propsColumns : []);
399
+ setFilteredColumns(columns);
400
+ (_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, 'filterColumns', columns);
397
401
  }, [propsColumns]); // 绑定 Actions
398
402
 
399
403
  (0, _utils2.useActionType)(actionRef, {
@@ -407,7 +411,11 @@ var ProTable = function ProTable(props) {
407
411
  return state;
408
412
  },
409
413
  setColumn: function setColumn(newColumns) {
410
- setFilteredColumns(processColumns(newColumns));
414
+ var _actionRef$current2, _actionRef$current2$s;
415
+
416
+ var columns = processColumns(newColumns);
417
+ setFilteredColumns(columns);
418
+ (_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);
411
419
  },
412
420
  setSize: function setSize(mode) {
413
421
  _setSize(mode);
@@ -421,11 +429,11 @@ var ProTable = function ProTable(props) {
421
429
  }
422
430
  },
423
431
  reset: function reset() {
424
- var _actionRef$current, _actionRef$current$se;
432
+ var _actionRef$current3, _actionRef$current3$s;
425
433
 
426
434
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onReset()); // 清空列过滤参数
427
435
 
428
- (_actionRef$current = actionRef.current) === null || _actionRef$current === void 0 ? void 0 : (_actionRef$current$se = _actionRef$current.setFilterRules) === null || _actionRef$current$se === void 0 ? void 0 : _actionRef$current$se.call(_actionRef$current, {});
436
+ (_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, {});
429
437
  dataFilterForm.reset();
430
438
  setCurrentPage(1);
431
439
 
@@ -536,7 +544,7 @@ var ProTable = function ProTable(props) {
536
544
  }); // 请求函数
537
545
 
538
546
  function _request(params, noLoading) {
539
- var _actionRef$current$ge, _actionRef$current2, _actionRef$current2$g, _objectSpread2;
547
+ var _actionRef$current$ge, _actionRef$current4, _actionRef$current4$g, _objectSpread2;
540
548
 
541
549
  // 如果没有传 url 且没有 customRequest,直接返回
542
550
  if (!url && !customRequest) {
@@ -551,7 +559,7 @@ var ProTable = function ProTable(props) {
551
559
 
552
560
  var dataFilterParams = toJS(dataFilterForm.values); // 列过滤请求参数
553
561
 
554
- var columnsFilterParams = (_actionRef$current$ge = (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$g = _actionRef$current2.getFilterRules) === null || _actionRef$current2$g === void 0 ? void 0 : _actionRef$current2$g.call(_actionRef$current2)) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {}; // 格式化后的请求参数
562
+ 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 : {}; // 格式化后的请求参数
555
563
 
556
564
  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));
557
565
 
@@ -638,7 +646,10 @@ var ProTable = function ProTable(props) {
638
646
  (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter) && (propsDataFilter === null || propsDataFilter === void 0 ? void 0 : propsDataFilter.onFilter(_objectSpread({}, toJS(dataFilterForm.values))));
639
647
 
640
648
  if (dataFilterForm.validate()) {
641
- setCurrentPage(1);
649
+ setCurrentPage(1); // const { mode, schema } = propsDataFilter as ProTableDataFilterProps;
650
+ // TODO: 针对 inline 模式下的 search 组件做一下处理,如果空值切换下拉的时候不触发请求
651
+ // if (mode === 'inline') {
652
+ // }
642
653
 
643
654
  _request(_defineProperty({}, targetPageKey, 1));
644
655
  }
@@ -180,6 +180,8 @@ export declare type ProTableActionType = {
180
180
  export declare type ProTableActionTypeMutations = {
181
181
  /** 获取state状态 */
182
182
  getState?: () => ProTableActionTypeState;
183
+ /** 设置state状态 */
184
+ setState?: (key: string, value: any) => void;
183
185
  /** 设置全屏状态 */
184
186
  setFullScreenState?: (state: boolean) => void;
185
187
  /** 绑定state监听事件 */
@@ -192,11 +194,15 @@ export declare type ProTableActionTypeMutations = {
192
194
  getFilterRules?: () => object;
193
195
  /** 重新计算表格maxHeight高度 */
194
196
  resetTableMaxBodyHeight?: () => void;
197
+ /** 列筛选规则 */
198
+ filterColumns?: any[];
195
199
  };
196
200
  /** action Mutations 定义 */
197
201
  export declare type ProTableActionTypeState = {
198
202
  fullScreenState: boolean;
199
203
  filterRules: ProTableColumnsFilterRulesItem;
204
+ filterColumns: ProTableColumnProps[];
205
+ [key: string]: any;
200
206
  };
201
207
  export declare type ProTableDataFilterProps = {
202
208
  /** 展示形式 */
@@ -47,8 +47,45 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
47
47
  * 增加了 icon 的功能 render title
48
48
  */
49
49
  var renderColumnsTitle = function renderColumnsTitle(item, actionRef) {
50
+ var filterMode = item.filterMode,
51
+ filters = item.filters,
52
+ dataIndex = item.dataIndex,
53
+ dataSource = item.dataSource;
54
+
55
+ var getItemLable = function getItemLable() {
56
+ if (filterMode !== 'multiple') {
57
+ var _actionRef$current$ge, _actionRef$current, _actionRef$current$ge2;
58
+
59
+ var selectedItem = (_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$ge2.call(_actionRef$current).filterRules) !== null && _actionRef$current$ge !== void 0 ? _actionRef$current$ge : {};
60
+
61
+ if (Object.keys(selectedItem).length > 0) {
62
+ var _selectedItem$dataInd;
63
+
64
+ if ((_selectedItem$dataInd = selectedItem[dataIndex]) === null || _selectedItem$dataInd === void 0 ? void 0 : _selectedItem$dataInd.params) {
65
+ var _targetFilters$find;
66
+
67
+ // 找到对应的 label
68
+ var targetFilters = filters !== null && filters !== void 0 ? filters : [];
69
+
70
+ if (filters === true) {
71
+ targetFilters = dataSource !== null && dataSource !== void 0 ? dataSource : [];
72
+ }
73
+
74
+ var label = (_targetFilters$find = targetFilters.find(function (item) {
75
+ var _selectedItem$dataInd2;
76
+
77
+ return item.value === ((_selectedItem$dataInd2 = selectedItem[dataIndex]) === null || _selectedItem$dataInd2 === void 0 ? void 0 : _selectedItem$dataInd2.params);
78
+ })) === null || _targetFilters$find === void 0 ? void 0 : _targetFilters$find.label;
79
+ return "".concat(item.title, " (").concat(label, ")");
80
+ }
81
+ }
82
+ }
83
+
84
+ return item.title;
85
+ };
86
+
50
87
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_utils.LabelIconTip, {
51
- label: item.title,
88
+ label: getItemLable(),
52
89
  tooltip: item.tooltip,
53
90
  icon: item.tooltipIcon
54
91
  }), item.filters && /*#__PURE__*/_react.default.createElement(_Filter.default, {
@@ -31,7 +31,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
31
31
  // 组件内全局状态
32
32
  var state = {
33
33
  fullScreenState: false,
34
- filterRules: {}
34
+ filterRules: {},
35
+ filterColumns: []
35
36
  }; // 组件内全局监听事件
36
37
 
37
38
  var callback = {
@@ -42,6 +43,15 @@ var mutations = {
42
43
  getState: function getState() {
43
44
  return state;
44
45
  },
46
+ setState: function setState(key, value) {
47
+ state[key] = value;
48
+ useOn(key, value);
49
+
50
+ if (mutations.hasOwnProperty(key)) {
51
+ mutations[key] = value;
52
+ }
53
+ },
54
+ filterColumns: state.filterColumns,
45
55
  setFullScreenState: function setFullScreenState(fullScreenState) {
46
56
  state.fullScreenState = fullScreenState;
47
57
  useOn('fullScreenState', fullScreenState);
@@ -85,6 +95,10 @@ var mutations = {
85
95
  * @param name 监听名(作为销毁唯一id使用)
86
96
  */
87
97
  on: function on(fun, state, name) {
98
+ if (!callback[state]) {
99
+ callback[state] = {};
100
+ }
101
+
88
102
  callback[state][name] = fun;
89
103
  },
90
104
  off: function off(name) {
@@ -1,3 +1,4 @@
1
+ import React from 'react';
1
2
  import { TagProps, CloseableProps } from '@alicloudfe/components/types/tag';
2
3
  import './index.scss';
3
4
  export declare type ProTagItem = (TagProps | (CloseableProps & {
@@ -8,4 +9,7 @@ export declare type ProTagItem = (TagProps | (CloseableProps & {
8
9
  */
9
10
  text?: string;
10
11
  };
11
- export declare const renderTags: (tags?: ProTagItem[] | undefined, size?: "small" | "large" | "medium" | undefined) => JSX.Element | null;
12
+ export declare type ProTagProps = ProTagItem[] | ProTagItem | React.ReactNode | React.ReactNode[];
13
+ /** 全局注册 tag 配置 */
14
+ export declare type GlobalTagProps = ProTagItem[];
15
+ export declare const renderTags: (tags?: ProTagProps, size?: "small" | "medium" | "large" | undefined) => JSX.Element | null;
@@ -1,21 +1,25 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  Object.defineProperty(exports, "__esModule", {
4
6
  value: true
5
7
  });
6
8
  exports.renderTags = void 0;
7
9
 
8
- var _react = _interopRequireDefault(require("react"));
10
+ var _react = _interopRequireWildcard(require("react"));
9
11
 
10
12
  var _components = require("@alicloudfe/components");
11
13
 
12
- var _utils = require("@teamix/utils");
14
+ var _src = require("../../../../../utils/src");
13
15
 
14
16
  require("./index.scss");
15
17
 
16
- var _excluded = ["text", "children", "closable"];
18
+ var _excluded = ["text", "children", "closable", "color"];
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
21
 
18
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
23
 
20
24
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
21
25
 
@@ -27,39 +31,83 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
27
31
 
28
32
  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; }
29
33
 
30
- var cls = (0, _utils.baseClass)('teamix-pro-tags');
34
+ var cls = (0, _src.baseClass)('teamix-pro-tags');
31
35
 
32
36
  var renderTags = function renderTags(tags, size) {
33
- if (!tags || !tags.length) {
37
+ if (!tags || Array.isArray(tags) && !tags.length) {
34
38
  return null;
35
- }
39
+ } // 获取全局 tag
36
40
 
37
- return /*#__PURE__*/_react.default.createElement(_components.Tag.Group, {
38
- className: cls('')
39
- }, tags.map(function (tag, i) {
41
+
42
+ var getGlobalTag = function getGlobalTag() {
43
+ var globalTag = (0, _src.getGlobalConfig)('tag'); // GlobalTagNodePropsItem 类型
44
+
45
+ if (globalTag) {
46
+ var globalTagMap = new Map(globalTag.map(function (item) {
47
+ return [item.color, item];
48
+ }));
49
+ return globalTagMap;
50
+ }
51
+
52
+ return null;
53
+ }; // 渲染单个 tag
54
+
55
+
56
+ var renderTag = function renderTag(item, index) {
40
57
  // @ts-ignore
41
- var text = tag.text,
42
- children = tag.children,
43
- closable = tag.closable,
44
- others = _objectWithoutProperties(tag, _excluded);
58
+ var text = item.text,
59
+ children = item.children,
60
+ closable = item.closable,
61
+ colorProps = item.color,
62
+ others = _objectWithoutProperties(item, _excluded);
63
+
64
+ var color = (0, _src.getTagColor)(colorProps !== null && colorProps !== void 0 ? colorProps : '', 'tag');
65
+ var otherProps = {};
66
+ var globalTagMap = getGlobalTag();
67
+
68
+ if (globalTagMap && globalTagMap.get(color)) {
69
+ var _globalTagMap$get;
70
+
71
+ otherProps = (_globalTagMap$get = globalTagMap.get(color)) !== null && _globalTagMap$get !== void 0 ? _globalTagMap$get : {};
72
+ }
45
73
 
46
74
  if (closable) {
47
- return /*#__PURE__*/_react.default.createElement(_components.Tag.Closeable, _objectSpread({
48
- key: i,
75
+ return /*#__PURE__*/_react.default.createElement(_components.Tag.Closeable, _objectSpread(_objectSpread({
76
+ key: index,
49
77
  size: size,
50
78
  style: {
51
79
  marginBottom: 0
52
- }
53
- }, others), text || children);
80
+ },
81
+ color: color
82
+ }, otherProps), others), text || children);
54
83
  }
55
84
 
56
- return /*#__PURE__*/_react.default.createElement(_components.Tag, _objectSpread({
57
- key: i,
85
+ return /*#__PURE__*/_react.default.createElement(_components.Tag, _objectSpread(_objectSpread({
86
+ key: index,
58
87
  size: size,
59
88
  style: {
60
89
  marginBottom: 0
61
- }
62
- }, others), text || children);
90
+ },
91
+ color: color
92
+ }, otherProps), others), text || children);
93
+ };
94
+
95
+ if (!Array.isArray(tags)) {
96
+ if ( /*#__PURE__*/(0, _react.isValidElement)(tags)) {
97
+ return tags;
98
+ }
99
+
100
+ return renderTag(tags, 0);
101
+ }
102
+
103
+ return /*#__PURE__*/_react.default.createElement(_components.Tag.Group, {
104
+ className: cls('')
105
+ }, tags.map(function (tag, i) {
106
+ if ( /*#__PURE__*/(0, _react.isValidElement)(tags)) {
107
+ return tags;
108
+ }
109
+
110
+ return renderTag(tag, i);
63
111
  }));
64
112
  };
65
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamix/pro",
3
- "version": "1.2.12",
3
+ "version": "1.2.13",
4
4
  "description": "TeamixPro大包",
5
5
  "repository": "http://gitlab.alibaba-inc.com/teamix/pro",
6
6
  "author": "Velociraptor(迅猛龙)",