doui-react 2.0.7 → 2.0.8

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 (55) hide show
  1. package/es/color-picker/component/index.d.ts +2 -0
  2. package/es/color-picker/component/index.js +17 -0
  3. package/es/color-picker/index.d.ts +2 -0
  4. package/es/color-picker/index.js +2 -0
  5. package/es/color-picker/type/index.d.ts +7 -0
  6. package/es/color-picker/type/index.js +1 -0
  7. package/es/form/component/form-item-map.d.ts +2 -0
  8. package/es/form/component/form-item-map.js +2 -0
  9. package/es/form/component/utils.d.ts +8 -8
  10. package/es/index.d.ts +2 -1
  11. package/es/index.js +1 -0
  12. package/es/open-modal/style/index.js +1 -1
  13. package/es/radio/component/abstract-box.d.ts +30 -30
  14. package/es/table/component/display-column.d.ts +2 -0
  15. package/es/table/component/display-column.js +95 -0
  16. package/es/table/component/index.d.ts +2 -0
  17. package/es/table/component/index.js +3 -1
  18. package/es/table/component/table.js +3 -1
  19. package/es/table/component/utils.d.ts +2 -2
  20. package/es/table/component/utils.js +37 -20
  21. package/es/table/style/index.d.ts +1 -0
  22. package/es/table/style/index.js +3 -2
  23. package/es/table/type/display-column.d.ts +9 -0
  24. package/es/table/type/display-column.js +1 -0
  25. package/es/table/type/index.d.ts +6 -0
  26. package/es/table/type/index.js +1 -0
  27. package/es/tabs/component/utils.d.ts +7 -7
  28. package/lib/color-picker/component/index.d.ts +2 -0
  29. package/lib/color-picker/component/index.js +24 -0
  30. package/lib/color-picker/index.d.ts +2 -0
  31. package/lib/color-picker/index.js +27 -0
  32. package/lib/color-picker/type/index.d.ts +7 -0
  33. package/lib/color-picker/type/index.js +5 -0
  34. package/lib/form/component/form-item-map.d.ts +2 -0
  35. package/lib/form/component/form-item-map.js +2 -0
  36. package/lib/form/component/utils.d.ts +8 -8
  37. package/lib/index.d.ts +2 -1
  38. package/lib/index.js +8 -0
  39. package/lib/open-modal/style/index.js +1 -1
  40. package/lib/radio/component/abstract-box.d.ts +30 -30
  41. package/lib/table/component/display-column.d.ts +2 -0
  42. package/lib/table/component/display-column.js +102 -0
  43. package/lib/table/component/index.d.ts +2 -0
  44. package/lib/table/component/index.js +3 -1
  45. package/lib/table/component/table.js +3 -1
  46. package/lib/table/component/utils.d.ts +2 -2
  47. package/lib/table/component/utils.js +38 -20
  48. package/lib/table/style/index.d.ts +1 -0
  49. package/lib/table/style/index.js +3 -2
  50. package/lib/table/type/display-column.d.ts +9 -0
  51. package/lib/table/type/display-column.js +5 -0
  52. package/lib/table/type/index.d.ts +6 -0
  53. package/lib/table/type/index.js +11 -0
  54. package/lib/tabs/component/utils.d.ts +7 -7
  55. package/package.json +1 -1
@@ -9,6 +9,7 @@ exports.generateColumns = generateColumns;
9
9
  exports.getRowSelection = getRowSelection;
10
10
  exports.getTableAndFormProps = getTableAndFormProps;
11
11
  exports.getTableFormInitialValues = getTableFormInitialValues;
12
+ exports.isActionsColumn = isActionsColumn;
12
13
  exports.isUseFormWrapper = isUseFormWrapper;
13
14
  exports.updateDataSourceByFormValues = updateDataSourceByFormValues;
14
15
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
@@ -40,9 +41,22 @@ var componentMap = exports.componentMap = {
40
41
  return props.children;
41
42
  }
42
43
  };
43
- function generateColumns(_ref) {
44
- var columns = _ref.columns,
45
- getSearchColumn = _ref.getSearchColumn;
44
+ function isHiddenColumn(_ref) {
45
+ var context = _ref.context,
46
+ column = _ref.column;
47
+ var displayColumnKeys = _lodash.default.get(context, 'displayColumnKeys');
48
+ if (!displayColumnKeys || isActionsColumn(column)) {
49
+ return;
50
+ }
51
+ return !_lodash.default.includes(displayColumnKeys, column.dataIndex);
52
+ }
53
+ function isActionsColumn(column) {
54
+ return column.type === 'actions';
55
+ }
56
+ function generateColumns(_ref2) {
57
+ var columns = _ref2.columns,
58
+ getSearchColumn = _ref2.getSearchColumn,
59
+ context = _ref2.context;
46
60
  return _lodash.default.map(columns, function (column) {
47
61
  var newColumn = _lodash.default.clone(column);
48
62
  var dataIndex = newColumn.dataIndex,
@@ -68,7 +82,7 @@ function generateColumns(_ref) {
68
82
  if (!_lodash.default.isEmpty(filters)) {
69
83
  _lodash.default.assign(newColumn, (0, _filter.getFilterColumn)(newColumn));
70
84
  }
71
- if (newColumn.type === 'actions') {
85
+ if (isActionsColumn(newColumn)) {
72
86
  var _newColumn$fixed;
73
87
  (_newColumn$fixed = newColumn.fixed) !== null && _newColumn$fixed !== void 0 ? _newColumn$fixed : newColumn.fixed = 'right';
74
88
  }
@@ -97,6 +111,10 @@ function generateColumns(_ref) {
97
111
  };
98
112
  return (0, _objectSpread2.default)((0, _objectSpread2.default)({}, newColumn), {}, {
99
113
  dataIndex: (0, _utils.transformNameToPath)(dataIndex),
114
+ hidden: isHiddenColumn({
115
+ context: context,
116
+ column: newColumn
117
+ }),
100
118
  align: align,
101
119
  render: render
102
120
  });
@@ -123,10 +141,10 @@ function renderComponent(props) {
123
141
  children: (0, _jsxRuntime.jsx)(Component, (0, _objectSpread2.default)({}, props))
124
142
  }));
125
143
  }
126
- function getColumnWidth(_ref2) {
127
- var width = _ref2.width,
128
- minWidth = _ref2.minWidth,
129
- maxWidth = _ref2.maxWidth;
144
+ function getColumnWidth(_ref3) {
145
+ var width = _ref3.width,
146
+ minWidth = _ref3.minWidth,
147
+ maxWidth = _ref3.maxWidth;
130
148
  var style;
131
149
  if (_lodash.default.isNil(width)) {
132
150
  style = {
@@ -145,10 +163,10 @@ function getColumnWidth(_ref2) {
145
163
  }
146
164
  };
147
165
  }
148
- function getRowSelection(_ref3) {
149
- var rowKey = _ref3.rowKey,
150
- columns = _ref3.columns,
151
- context = _ref3.context;
166
+ function getRowSelection(_ref4) {
167
+ var rowKey = _ref4.rowKey,
168
+ columns = _ref4.columns,
169
+ context = _ref4.context;
152
170
  var column = _lodash.default.find(columns, {
153
171
  type: 'selection'
154
172
  });
@@ -209,10 +227,10 @@ function getTableAndFormProps(props) {
209
227
  tableProps: tableProps
210
228
  };
211
229
  }
212
- function isUseFormWrapper(_ref4) {
213
- var columns = _ref4.columns,
214
- context = _ref4.context,
215
- form = _ref4.form;
230
+ function isUseFormWrapper(_ref5) {
231
+ var columns = _ref5.columns,
232
+ context = _ref5.context,
233
+ form = _ref5.form;
216
234
  // 在 Form 中时,将 context 挂载给 formContext
217
235
  if (form) {
218
236
  _lodash.default.assign(form.getContext(), context);
@@ -222,10 +240,10 @@ function isUseFormWrapper(_ref4) {
222
240
  type: 'editor'
223
241
  });
224
242
  }
225
- function getTableFormInitialValues(_ref5) {
226
- var rowKey = _ref5.rowKey,
227
- columns = _ref5.columns,
228
- dataSource = _ref5.dataSource;
243
+ function getTableFormInitialValues(_ref6) {
244
+ var rowKey = _ref6.rowKey,
245
+ columns = _ref6.columns,
246
+ dataSource = _ref6.dataSource;
229
247
  var dataIndex = _lodash.default.map(columns, function (col) {
230
248
  return col.type === 'editor' && col.dataIndex;
231
249
  });
@@ -5,5 +5,6 @@ declare const style: {
5
5
  ellipsisText: (rows: number) => import("@emotion/react").SerializedStyles;
6
6
  editor: import("@emotion/react").SerializedStyles;
7
7
  divider: import("@emotion/react").SerializedStyles;
8
+ displayColumn: import("@emotion/react").SerializedStyles;
8
9
  };
9
10
  export default style;
@@ -8,7 +8,7 @@ exports.default = void 0;
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
9
  var _api = require("../../api");
10
10
  var _react = require("@emotion/react");
11
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5;
11
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
12
12
  var style = {
13
13
  wrapper: function wrapper(maxHeight) {
14
14
  return (0, _react.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n width: 100%;\n height: 100%;\n display: flex;\n flex-direction: column;\n\n .ant-table-wrapper,\n .ant-spin-nested-loading,\n .ant-spin-container,\n .ant-table,\n .ant-table-container {\n width: 100%;\n max-height: 100%;\n display: flex;\n flex-direction: column;\n min-height: 0;\n }\n\n .ant-table-content {\n overflow: auto !important;\n width: calc(100% + 1px); // \u4FEE\u590D\u7A7A\u6570\u636E\u65F6\uFF0C\u51FA\u73B0\u6EDA\u52A8\u6761\u7684 bug\n max-height: ", ";\n }\n\n .ant-table-thead {\n position: sticky;\n top: 0;\n z-index: 10;\n }\n\n .ant-table-pagination.ant-pagination {\n margin-bottom: 0;\n }\n "])), (0, _api.transformValueWithStyleUnit)(maxHeight));
@@ -18,6 +18,7 @@ var style = {
18
18
  return (0, _react.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n -webkit-line-clamp: ", " !important;\n "])), rows);
19
19
  },
20
20
  editor: (0, _react.css)(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n margin-bottom: 0;\n\n .ant-form-item-label {\n display: none !important;\n }\n "]))),
21
- divider: (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: 0;\n "])))
21
+ divider: (0, _react.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n margin: 0;\n "]))),
22
+ displayColumn: (0, _react.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n & {\n flex-direction: column;\n max-width: 200px;\n }\n\n .do-checkbox-all {\n padding-bottom: 10px;\n border-bottom: 1px solid #f0f0f0;\n }\n\n .ant-checkbox-group {\n flex-direction: column;\n width: 100%;\n }\n\n .do-checkbox,\n .do-box-label {\n width: 100%;\n }\n "])))
22
23
  };
23
24
  var _default = exports.default = style;
@@ -0,0 +1,9 @@
1
+ import { ButtonProps } from "../../button";
2
+ export interface DisplayColumnProps extends Omit<ButtonProps, 'onChange'> {
3
+ /**
4
+ * @description 缓存列时, 需要保证key唯一
5
+ */
6
+ storageKey?: string;
7
+ value?: string[];
8
+ onChange?: (keys: string[]) => void;
9
+ }
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -6,6 +6,7 @@ import { TableProps as AntdTableProps } from 'antd';
6
6
  import { ReactNode } from 'react';
7
7
  export * from './action';
8
8
  export * from './column';
9
+ export * from './display-column';
9
10
  export type DataSource = any[];
10
11
  export interface TableContext {
11
12
  /**
@@ -37,8 +38,13 @@ export interface TableContext {
37
38
  * @description 设置表格上下文
38
39
  */
39
40
  setContext(state: any): void;
41
+ /**
42
+ * @description 列配置
43
+ */
44
+ columns: Column[];
40
45
  rowKey: string;
41
46
  editorValueKey: string;
47
+ displayColumnKeys?: string[];
42
48
  [key: string]: any;
43
49
  }
44
50
  export interface RefreshProps {
@@ -24,4 +24,15 @@ Object.keys(_column).forEach(function (key) {
24
24
  return _column[key];
25
25
  }
26
26
  });
27
+ });
28
+ var _displayColumn = require("./display-column");
29
+ Object.keys(_displayColumn).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _displayColumn[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function get() {
35
+ return _displayColumn[key];
36
+ }
37
+ });
27
38
  });
@@ -6,19 +6,19 @@ export declare function getRenderTabBar({ type, items, size, tabBarGutter, tabBa
6
6
  export declare function generateTabItems({ items }: TabsProps): {
7
7
  label: import("@emotion/react/jsx-runtime").JSX.Element;
8
8
  key: string;
9
- children?: import("react").ReactNode;
9
+ prefixCls?: string | undefined;
10
+ disabled?: boolean | undefined;
10
11
  className?: string | undefined;
11
12
  style?: import("react").CSSProperties | undefined;
12
- closable?: boolean | undefined;
13
- prefixCls?: string | undefined;
14
- closeIcon?: import("react").ReactNode;
13
+ children?: import("react").ReactNode;
15
14
  forceRender?: boolean | undefined;
16
15
  id?: string | undefined;
17
- disabled?: boolean | undefined;
18
- icon?: import("react").ReactNode;
19
- active?: boolean | undefined;
20
16
  destroyInactiveTabPane?: boolean | undefined;
21
17
  animated?: boolean | undefined;
18
+ closable?: boolean | undefined;
19
+ closeIcon?: import("react").ReactNode;
20
+ icon?: import("react").ReactNode;
22
21
  tabKey?: string | undefined;
22
+ active?: boolean | undefined;
23
23
  }[];
24
24
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "doui-react",
3
- "version": "2.0.7",
3
+ "version": "2.0.8",
4
4
  "description": "A React UI library based on Ant Design",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",