@teamias/rex-pro 0.0.10 → 0.0.12

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.
package/LICENSE CHANGED
File without changes
package/README.md CHANGED
File without changes
@@ -1,11 +1,11 @@
1
- import { DataCell, type IBaseTableProps } from '@teamias/rex-design';
1
+ import { BaseDescriptions, DataCell, type IBaseTableProps } from '@teamias/rex-design';
2
2
  import { CardProps, GetProps } from 'antd';
3
3
  export interface CardBasicInfoProps<T extends object = object> extends Omit<CardProps, 'type'> {
4
4
  /**
5
5
  * 卡片类型
6
6
  * @default info
7
7
  */
8
- type?: 'info' | 'table';
8
+ type?: 'info' | 'table' | 'descriptions';
9
9
  /**
10
10
  * 数据源
11
11
  */
@@ -19,6 +19,10 @@ export interface CardBasicInfoProps<T extends object = object> extends Omit<Card
19
19
  * type=table时生效
20
20
  */
21
21
  tableProps?: IBaseTableProps<T>;
22
+ /** type=descriptions时生效 */
23
+ descriptionsProps?: GetProps<typeof BaseDescriptions>;
24
+ /** 隐藏卡片样式 */
25
+ hideCardStyle?: boolean;
22
26
  onDataCellClick?: GetProps<typeof DataCell>['onClick'];
23
27
  }
24
- export declare function CardBasicInfo<T extends object = object>({ dataSource, col, type, tableProps, rootClassName, onDataCellClick, ...cardProps }: CardBasicInfoProps<T>): import("react/jsx-runtime").JSX.Element;
28
+ export declare function CardBasicInfo<T extends object = object>({ dataSource, col, type, tableProps, rootClassName, hideCardStyle, descriptionsProps, onDataCellClick, ...cardProps }: CardBasicInfoProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
- var _excluded = ["dataSource", "col", "type", "tableProps", "rootClassName", "onDataCellClick"];
2
+ var _excluded = ["dataSource", "col", "type", "tableProps", "rootClassName", "hideCardStyle", "descriptionsProps", "onDataCellClick"];
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
5
5
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
@@ -7,11 +7,12 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
7
7
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
8
8
  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; }
9
9
  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; }
10
- import { BaseTable, DataCell } from '@teamias/rex-design';
10
+ import { BaseDescriptions, BaseTable, DataCell } from '@teamias/rex-design';
11
11
  import { Col, Row } from 'antd';
12
12
  import classNames from 'classnames';
13
13
  import { useMemo } from 'react';
14
14
  import { Card } from "./style";
15
+ import { Fragment as _Fragment } from "react/jsx-runtime";
15
16
  import { jsx as _jsx } from "react/jsx-runtime";
16
17
  /**
17
18
  * 平分列数
@@ -35,28 +36,48 @@ export function CardBasicInfo(_ref) {
35
36
  type = _ref$type === void 0 ? 'info' : _ref$type,
36
37
  tableProps = _ref.tableProps,
37
38
  rootClassName = _ref.rootClassName,
39
+ hideCardStyle = _ref.hideCardStyle,
40
+ descriptionsProps = _ref.descriptionsProps,
38
41
  onDataCellClick = _ref.onDataCellClick,
39
42
  cardProps = _objectWithoutProperties(_ref, _excluded);
40
43
  var span = useSpan(dataSource.length, col);
41
- return /*#__PURE__*/_jsx(Card, _objectSpread(_objectSpread({}, cardProps), {}, {
42
- rootClassName: classNames('card-basic-info', rootClassName),
43
- children: type === 'info' ? /*#__PURE__*/_jsx(Row, {
44
- gutter: [20, 20],
45
- children: dataSource.map(function (item, index) {
46
- return /*#__PURE__*/_jsx(Col, {
47
- span: span,
48
- children: /*#__PURE__*/_jsx(Row, {
49
- align: "middle",
50
- style: {
51
- gap: 10
52
- },
53
- children: /*#__PURE__*/_jsx(DataCell, {
54
- items: item,
55
- onClick: onDataCellClick
44
+ var renderNode = function renderNode(node) {
45
+ if (hideCardStyle) return /*#__PURE__*/_jsx(_Fragment, {
46
+ children: node
47
+ });
48
+ return /*#__PURE__*/_jsx(Card, _objectSpread(_objectSpread({}, cardProps), {}, {
49
+ rootClassName: classNames('card-basic-info', rootClassName),
50
+ children: node
51
+ }));
52
+ };
53
+ return renderNode( /*#__PURE__*/_jsx(_Fragment, {
54
+ children: function () {
55
+ if (type === 'table') {
56
+ return /*#__PURE__*/_jsx(BaseTable, _objectSpread({}, tableProps));
57
+ }
58
+ if (type === 'descriptions') {
59
+ return /*#__PURE__*/_jsx(BaseDescriptions, _objectSpread({
60
+ column: col
61
+ }, descriptionsProps));
62
+ }
63
+ return /*#__PURE__*/_jsx(Row, {
64
+ gutter: [20, 20],
65
+ children: dataSource.map(function (item, index) {
66
+ return /*#__PURE__*/_jsx(Col, {
67
+ span: span,
68
+ children: /*#__PURE__*/_jsx(Row, {
69
+ align: "middle",
70
+ style: {
71
+ gap: 10
72
+ },
73
+ children: /*#__PURE__*/_jsx(DataCell, {
74
+ items: item,
75
+ onClick: onDataCellClick
76
+ })
56
77
  })
57
- })
58
- }, index);
59
- })
60
- }) : /*#__PURE__*/_jsx(BaseTable, _objectSpread({}, tableProps))
78
+ }, index);
79
+ })
80
+ });
81
+ }()
61
82
  }));
62
83
  }
@@ -0,0 +1,2 @@
1
+ declare const _default: () => import("react/jsx-runtime").JSX.Element;
2
+ export default _default;
@@ -0,0 +1,126 @@
1
+ import { CardBasicInfo } from "../card-basic-info";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ export default (function () {
4
+ return /*#__PURE__*/_jsx(CardBasicInfo, {
5
+ type: "descriptions",
6
+ title: "\u6D4B\u8BD5\u63CF\u8FF0\u7C7B\u578B",
7
+ hideCardStyle: false,
8
+ descriptionsProps: {
9
+ items: [{
10
+ label: 'Address',
11
+ span: 2,
12
+ children: [[{
13
+ type: 'group-v2',
14
+ props: {
15
+ label: 'label',
16
+ // labelStyle: {},
17
+ // itemsGap: 2,
18
+ // itemsStyle: {},
19
+ // itemsSeparator: '/',
20
+ // itemsDirection: 'row',
21
+ items: [{
22
+ type: 'text',
23
+ value: 'qweqweqweqwe',
24
+ action: 'url',
25
+ url: 'http://baidu.com'
26
+ }, {
27
+ type: 'icon',
28
+ iconsType: 'iconify',
29
+ name: 'svg-spinners:ring-resize',
30
+ size: 12,
31
+ action: 'url',
32
+ url: 'http://baidu.com'
33
+ }, {
34
+ type: 'text',
35
+ value: 'qweqweqweqwe',
36
+ copyable: true,
37
+ tooltip: true,
38
+ style: {
39
+ color: 'red'
40
+ }
41
+ }, {
42
+ type: 'tag',
43
+ value: '33123',
44
+ color: 'red'
45
+ }, {
46
+ type: 'img',
47
+ src: 'http://qweqe'
48
+ }]
49
+ }
50
+ }, {
51
+ type: 'group-v2',
52
+ props: {
53
+ items: [{
54
+ type: 'img',
55
+ src: 'http://qweqe'
56
+ }, {
57
+ type: 'group-v2',
58
+ props: {
59
+ itemsDirection: 'column',
60
+ items: [{
61
+ type: 'text',
62
+ value: 'qweqweqweqwe',
63
+ action: 'url',
64
+ url: 'http://baidu.com',
65
+ ellipsis: 1,
66
+ copyable: true
67
+ }, {
68
+ type: 'text',
69
+ value: 'qweqweqweqwe2',
70
+ ellipsis: 1,
71
+ copyable: '自定义复制'
72
+ }, {
73
+ type: 'text',
74
+ value: 'qweqweqweqwe3',
75
+ tooltip: '自定义提示'
76
+ }]
77
+ }
78
+ }]
79
+ }
80
+ }, {
81
+ type: 'group-v2',
82
+ props: {
83
+ items: [{
84
+ type: 'img',
85
+ src: 'http://qweqe'
86
+ }, {
87
+ type: 'group-v2',
88
+ props: {
89
+ itemsDirection: 'column',
90
+ items: [{
91
+ type: 'group-v2',
92
+ props: {
93
+ itemsDirection: 'column',
94
+ label: 'label',
95
+ items: [{
96
+ type: 'text',
97
+ value: 'qweqweqweqwe'
98
+ }]
99
+ }
100
+ }, {
101
+ type: 'group-v2',
102
+ props: {
103
+ itemsDirection: 'column',
104
+ label: 'label',
105
+ items: [{
106
+ type: 'text',
107
+ value: 'qweqweqweqwe2',
108
+ action: 'custom'
109
+ }]
110
+ }
111
+ }]
112
+ }
113
+ }]
114
+ }
115
+ }]]
116
+ }, {
117
+ label: 'Remark',
118
+ children: 'empty'
119
+ }],
120
+ bordered: true,
121
+ onDataCellClick: function onDataCellClick(data) {
122
+ console.log(data);
123
+ }
124
+ }
125
+ });
126
+ });
@@ -20,7 +20,7 @@ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) r
20
20
  /* eslint-disable no-param-reassign */
21
21
  import { ProForm } from '@ant-design/pro-components';
22
22
  import { BaseForm, getFieldsDefaultValues, useRequestFields, useRequestFieldsConfig, useRexProConfigProvider, useStateData } from '@teamias/rex-design';
23
- import { Button, Dropdown, Skeleton, Space, Checkbox } from 'antd';
23
+ import { Button, Checkbox, Dropdown, Skeleton, Space } from 'antd';
24
24
  import { cloneDeep } from 'lodash';
25
25
  import { useEffect, useImperativeHandle, useRef } from 'react';
26
26
  import { FilterFormAutoWidthStyle, FilterFormStyle } from "./style";
@@ -71,8 +71,9 @@ export var FilterForm = function FilterForm(_ref) {
71
71
  fetchLoading: false,
72
72
  fields: [],
73
73
  currentInit: true,
74
- customFields: [],
75
- selectedCustomFields: []
74
+ allFields: [],
75
+ // 单一数据源
76
+ selectedCustomFieldKeys: new Set() // 使用 Set 存储选中的自定义字段 key
76
77
  };
77
78
  }),
78
79
  state = _useStateData.state,
@@ -131,43 +132,31 @@ export var FilterForm = function FilterForm(_ref) {
131
132
  });
132
133
  return arr;
133
134
  };
134
- useEffect(function () {
135
- if (loading) return;
136
- var allFields = cloneDeep(fields);
137
135
 
138
- // 分离自定义字段和普通字段
139
- var customFields = allFields.filter(function (field) {
140
- return field.isCustom;
141
- });
142
- var normalFields = allFields.filter(function (field) {
143
- return !field.isCustom;
144
- });
145
-
146
- // 合并普通字段和已选择的自定义字段
147
- var combinedFields = [].concat(_toConsumableArray(normalFields), _toConsumableArray(state.selectedCustomFields));
148
- if (displayType === 'average') {
149
- state.fields = combinedFields;
150
- state.customFields = customFields;
151
- state.currentInit = false;
152
- update();
136
+ // 切换自定义字段的显示状态
137
+ var handleToggleCustomField = function handleToggleCustomField(fieldKey) {
138
+ var isSelected = state.selectedCustomFieldKeys.has(fieldKey);
139
+ if (isSelected) {
140
+ // 移除字段
141
+ state.selectedCustomFieldKeys.delete(fieldKey);
153
142
  } else {
154
- handlerSelectStyle(combinedFields);
155
- state.fields = combinedFields;
156
- state.customFields = customFields;
157
- state.currentInit = false;
158
- update();
143
+ // 添加字段
144
+ state.selectedCustomFieldKeys.add(fieldKey);
159
145
  }
160
- }, [fields, state.selectedCustomFields]);
146
+
147
+ // 创建新的 Set 以触发状态更新
148
+ state.selectedCustomFieldKeys = new Set(state.selectedCustomFieldKeys);
149
+ update();
150
+ };
161
151
 
162
152
  // 创建下拉菜单内容
163
153
  var getDropdownMenu = function getDropdownMenu() {
164
- var _state$customFields;
165
- // 使用 Map 来快速查找已选择的字段
166
- var selectedFieldsMap = new Map(state.selectedCustomFields.map(function (field) {
167
- return [field.field, field];
168
- }));
169
- var items = (_state$customFields = state.customFields) === null || _state$customFields === void 0 ? void 0 : _state$customFields.map(function (field) {
170
- var isSelected = selectedFieldsMap.has(field.field);
154
+ // 筛选出所有自定义字段
155
+ var customFields = state.allFields.filter(function (field) {
156
+ return field.isCustom;
157
+ });
158
+ var items = customFields.map(function (field) {
159
+ var isSelected = state.selectedCustomFieldKeys.has(field.field);
171
160
  return {
172
161
  key: field.field,
173
162
  label: /*#__PURE__*/_jsx("div", {
@@ -191,31 +180,51 @@ export var FilterForm = function FilterForm(_ref) {
191
180
  items: items
192
181
  };
193
182
  };
183
+ useEffect(function () {
184
+ if (loading) return;
185
+ var allFields = cloneDeep(fields);
186
+ state.allFields = allFields;
194
187
 
195
- // 切换自定义字段的显示状态
196
- var handleToggleCustomField = function handleToggleCustomField(fieldKey) {
197
- // 使用 Map 来快速查找已选择的字段
198
- var selectedFieldsMap = new Map(state.selectedCustomFields.map(function (field) {
199
- return [field.field, field];
188
+ // 清理已选择的自定义字段keys,移除那些不再是自定义字段的项
189
+ var currentCustomFieldKeys = new Set(allFields.filter(function (field) {
190
+ return field.isCustom;
191
+ }).map(function (field) {
192
+ return field.field;
200
193
  }));
201
- var customFieldsMap = new Map(state.customFields.map(function (field) {
202
- return [field.field, field];
194
+
195
+ // 只保留仍然是自定义字段的选中项
196
+ var validSelectedKeys = new Set(_toConsumableArray(state.selectedCustomFieldKeys).filter(function (key) {
197
+ return currentCustomFieldKeys.has(key);
203
198
  }));
204
- var isSelected = selectedFieldsMap.has(fieldKey);
205
- if (isSelected) {
206
- // 移除字段
207
- state.selectedCustomFields = state.selectedCustomFields.filter(function (field) {
208
- return field.field !== fieldKey;
209
- });
199
+
200
+ // 如果选中的keys发生了变化,更新状态
201
+ if (validSelectedKeys.size !== state.selectedCustomFieldKeys.size) {
202
+ state.selectedCustomFieldKeys = validSelectedKeys;
203
+ }
204
+
205
+ // 筛选出普通字段(非自定义字段)
206
+ var normalFields = allFields.filter(function (field) {
207
+ return !field.isCustom;
208
+ });
209
+
210
+ // 筛选出已选择的自定义字段
211
+ var selectedCustomFields = allFields.filter(function (field) {
212
+ return field.isCustom && state.selectedCustomFieldKeys.has(field.field);
213
+ });
214
+
215
+ // 合并普通字段和已选择的自定义字段
216
+ var combinedFields = [].concat(_toConsumableArray(normalFields), _toConsumableArray(selectedCustomFields));
217
+ if (displayType === 'average') {
218
+ state.fields = combinedFields;
219
+ state.currentInit = false;
220
+ update();
210
221
  } else {
211
- // 添加字段
212
- var fieldToAdd = customFieldsMap.get(fieldKey);
213
- if (fieldToAdd) {
214
- state.selectedCustomFields = [].concat(_toConsumableArray(state.selectedCustomFields), [fieldToAdd]);
215
- }
222
+ handlerSelectStyle(combinedFields);
223
+ state.fields = combinedFields;
224
+ state.currentInit = false;
225
+ update();
216
226
  }
217
- update();
218
- };
227
+ }, [fields, state.selectedCustomFieldKeys]);
219
228
  useImperativeHandle(actionRef, function () {
220
229
  return {
221
230
  getAllValues: function getAllValues() {
@@ -300,7 +309,9 @@ export var FilterForm = function FilterForm(_ref) {
300
309
  id: 'pro.components.filter-form.search',
301
310
  defaultMessage: '查询'
302
311
  })
303
- }), state.customFields.length > 0 && /*#__PURE__*/_jsx(Dropdown, {
312
+ }), state.allFields.filter(function (field) {
313
+ return field.isCustom;
314
+ }).length > 0 && /*#__PURE__*/_jsx(Dropdown, {
304
315
  menu: getDropdownMenu(),
305
316
  trigger: ['click'],
306
317
  placement: "bottomLeft",
package/dist/index.d.ts CHANGED
@@ -49,6 +49,7 @@ export declare const proLocales: {
49
49
  "filter-form": {
50
50
  reset: string;
51
51
  search: string;
52
+ "custom-filters": string;
52
53
  };
53
54
  };
54
55
  };
@@ -19,7 +19,8 @@
19
19
  },
20
20
  "filter-form": {
21
21
  "reset": "Reset",
22
- "search": "Search"
22
+ "search": "Search",
23
+ "custom-filters": "Custom filters"
23
24
  }
24
25
  }
25
26
  }
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-pro",
3
- "version": "0.0.10",
3
+ "version": "0.0.12",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -23,7 +23,8 @@
23
23
  "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
24
24
  "prepare": "husky install && dumi setup",
25
25
  "prepublishOnly": "father doctor && npm run build",
26
- "start": "npm run dev"
26
+ "start": "npm run dev",
27
+ "update:lib": "pnpm add @teamias/rex-design@latest"
27
28
  },
28
29
  "commitlint": {
29
30
  "extends": [
@@ -50,7 +51,7 @@
50
51
  "dependencies": {
51
52
  "@ant-design/icons": "^6.0.0",
52
53
  "@ant-design/pro-components": "^2.8.10",
53
- "@teamias/rex-design": "^0.0.10",
54
+ "@teamias/rex-design": "^0.0.20",
54
55
  "ahooks": "^3.9.0",
55
56
  "antd": "^5.26.7",
56
57
  "classnames": "^2.5.1",