@teamias/rex-design 0.1.21 → 0.1.22
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/dist/components/data-cell/data-cell.js +26 -7
- package/dist/components/data-cell/demo/DropdownDemo.d.ts +6 -0
- package/dist/components/data-cell/demo/DropdownDemo.js +133 -0
- package/dist/components/data-cell/modules/cellItemMap.d.ts +1 -1
- package/dist/components/data-cell/modules/cellItemMap.js +44 -18
- package/dist/components/data-cell/types.d.ts +20 -3
- package/package.json +1 -1
|
@@ -5,6 +5,7 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
|
|
|
5
5
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
6
|
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); }
|
|
7
7
|
import { ErrorBoundaryProvider, useErrorBoundary, useRexProConfigProvider } from "../../context";
|
|
8
|
+
import { Dropdown } from 'antd';
|
|
8
9
|
import React from 'react';
|
|
9
10
|
import { cellItemMap } from "./modules/cellItemMap";
|
|
10
11
|
import { Wrapper } from "./style";
|
|
@@ -13,22 +14,40 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
|
13
14
|
/** 内部渲染组件,会在检测到父级有 ErrorBoundary 时直接抛出错误 */
|
|
14
15
|
var DataCellInner = function DataCellInner(_ref) {
|
|
15
16
|
var items = _ref.items,
|
|
16
|
-
|
|
17
|
+
_onClick = _ref.onClick,
|
|
17
18
|
propSystemHistory = _ref.systemHistory;
|
|
18
19
|
var _useRexProConfigProvi = useRexProConfigProvider(),
|
|
19
20
|
contextSystemHistory = _useRexProConfigProvi.systemHistory;
|
|
20
21
|
var systemHistory = propSystemHistory !== null && propSystemHistory !== void 0 ? propSystemHistory : contextSystemHistory;
|
|
21
22
|
return /*#__PURE__*/_jsx(_Fragment, {
|
|
22
23
|
children: items.map(function (item, index) {
|
|
23
|
-
var _cellItemMap$item$typ;
|
|
24
|
+
var _cellItemMap$item$typ, _dropdown$items, _dropdown$trigger;
|
|
25
|
+
var content = (_cellItemMap$item$typ = cellItemMap[item.type]) === null || _cellItemMap$item$typ === void 0 ? void 0 : _cellItemMap$item$typ.call(cellItemMap, {
|
|
26
|
+
item: item,
|
|
27
|
+
click: _onClick,
|
|
28
|
+
systemHistory: systemHistory
|
|
29
|
+
});
|
|
30
|
+
var dropdown = item.dropdown;
|
|
24
31
|
return /*#__PURE__*/_jsx(Wrapper, {
|
|
25
32
|
style: item.rootStyle,
|
|
26
33
|
className: "data-cell-row-item ".concat(item.type),
|
|
27
|
-
children: (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
34
|
+
children: dropdown !== null && dropdown !== void 0 && (_dropdown$items = dropdown.items) !== null && _dropdown$items !== void 0 && _dropdown$items.length ? /*#__PURE__*/_jsx(Dropdown, {
|
|
35
|
+
menu: {
|
|
36
|
+
items: dropdown.items,
|
|
37
|
+
onClick: function onClick(_ref2) {
|
|
38
|
+
var key = _ref2.key;
|
|
39
|
+
return _onClick === null || _onClick === void 0 ? void 0 : _onClick(item, undefined, key);
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
trigger: (_dropdown$trigger = dropdown.trigger) !== null && _dropdown$trigger !== void 0 ? _dropdown$trigger : ['click'],
|
|
43
|
+
placement: dropdown.placement,
|
|
44
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
45
|
+
style: {
|
|
46
|
+
cursor: 'pointer'
|
|
47
|
+
},
|
|
48
|
+
children: content
|
|
49
|
+
})
|
|
50
|
+
}) : content
|
|
32
51
|
}, index);
|
|
33
52
|
})
|
|
34
53
|
});
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* title: Dropdown 下拉菜单
|
|
3
|
+
* description: 所有类型均支持 `dropdown` 配置。默认点击触发,可通过 `trigger` 修改为 click / hover / contextMenu。菜单项点击通过统一的 `onClick` 回调抛出,第三个参数 `dropdownKey` 为菜单项的 key。
|
|
4
|
+
*/
|
|
5
|
+
declare const _default: () => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export default _default;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { DataCell, RexProConfigProvider } from "../../..";
|
|
2
|
+
import { message } from 'antd';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* title: Dropdown 下拉菜单
|
|
6
|
+
* description: 所有类型均支持 `dropdown` 配置。默认点击触发,可通过 `trigger` 修改为 click / hover / contextMenu。菜单项点击通过统一的 `onClick` 回调抛出,第三个参数 `dropdownKey` 为菜单项的 key。
|
|
7
|
+
*/
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
export default (function () {
|
|
10
|
+
return /*#__PURE__*/_jsx(RexProConfigProvider, {
|
|
11
|
+
value: {},
|
|
12
|
+
children: /*#__PURE__*/_jsx(DataCell, {
|
|
13
|
+
onClick: function onClick(item, subItem, dropdownKey) {
|
|
14
|
+
if (dropdownKey) {
|
|
15
|
+
message.info("\u83DC\u5355\u9879\u70B9\u51FB: key=".concat(dropdownKey, ", type=").concat(item.type));
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
items: [
|
|
19
|
+
// 文本类型 + dropdown(点击触发)
|
|
20
|
+
{
|
|
21
|
+
type: 'text',
|
|
22
|
+
props: {
|
|
23
|
+
label: '商品名称',
|
|
24
|
+
value: '右键点击我试试'
|
|
25
|
+
},
|
|
26
|
+
dropdown: {
|
|
27
|
+
items: [{
|
|
28
|
+
key: 'edit',
|
|
29
|
+
label: '编辑'
|
|
30
|
+
}, {
|
|
31
|
+
key: 'copy',
|
|
32
|
+
label: '复制'
|
|
33
|
+
}, {
|
|
34
|
+
key: 'delete',
|
|
35
|
+
label: '删除',
|
|
36
|
+
danger: true
|
|
37
|
+
}],
|
|
38
|
+
trigger: ['contextMenu'] // 右键触发
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
// 标签类型 + dropdown(点击触发)
|
|
42
|
+
{
|
|
43
|
+
type: 'tag',
|
|
44
|
+
props: {
|
|
45
|
+
label: '状态',
|
|
46
|
+
value: '进行中',
|
|
47
|
+
color: 'processing'
|
|
48
|
+
},
|
|
49
|
+
dropdown: {
|
|
50
|
+
items: [{
|
|
51
|
+
key: 'pending',
|
|
52
|
+
label: '待处理'
|
|
53
|
+
}, {
|
|
54
|
+
key: 'processing',
|
|
55
|
+
label: '进行中'
|
|
56
|
+
}, {
|
|
57
|
+
key: 'done',
|
|
58
|
+
label: '已完成'
|
|
59
|
+
}],
|
|
60
|
+
trigger: ['hover']
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
// group-v2 顶层 dropdown
|
|
64
|
+
{
|
|
65
|
+
type: 'group-v2',
|
|
66
|
+
dropdown: {
|
|
67
|
+
items: [{
|
|
68
|
+
key: 'expand',
|
|
69
|
+
label: '展开详情'
|
|
70
|
+
}, {
|
|
71
|
+
key: 'collapse',
|
|
72
|
+
label: '收起'
|
|
73
|
+
}]
|
|
74
|
+
},
|
|
75
|
+
props: {
|
|
76
|
+
label: '订单信息',
|
|
77
|
+
itemsDirection: 'row',
|
|
78
|
+
itemsGap: 8,
|
|
79
|
+
itemsSeparator: ' / ',
|
|
80
|
+
items: [{
|
|
81
|
+
type: 'text',
|
|
82
|
+
value: 'ORD-20240110'
|
|
83
|
+
}, {
|
|
84
|
+
type: 'tag',
|
|
85
|
+
value: '已发货',
|
|
86
|
+
color: 'blue'
|
|
87
|
+
}]
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
// group-v2 子项级别 dropdown
|
|
91
|
+
{
|
|
92
|
+
type: 'group-v2',
|
|
93
|
+
props: {
|
|
94
|
+
label: '子项菜单',
|
|
95
|
+
itemsDirection: 'row',
|
|
96
|
+
itemsGap: 12,
|
|
97
|
+
items: [{
|
|
98
|
+
type: 'text',
|
|
99
|
+
value: '右键我',
|
|
100
|
+
style: {
|
|
101
|
+
color: '#1890ff',
|
|
102
|
+
cursor: 'pointer'
|
|
103
|
+
},
|
|
104
|
+
dropdown: {
|
|
105
|
+
items: [{
|
|
106
|
+
key: 'view',
|
|
107
|
+
label: '查看'
|
|
108
|
+
}, {
|
|
109
|
+
key: 'share',
|
|
110
|
+
label: '分享'
|
|
111
|
+
}],
|
|
112
|
+
trigger: ['contextMenu']
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
type: 'tag',
|
|
116
|
+
value: '点击我',
|
|
117
|
+
color: 'green',
|
|
118
|
+
dropdown: {
|
|
119
|
+
items: [{
|
|
120
|
+
key: 'pin',
|
|
121
|
+
label: '置顶'
|
|
122
|
+
}, {
|
|
123
|
+
key: 'archive',
|
|
124
|
+
label: '归档'
|
|
125
|
+
}],
|
|
126
|
+
trigger: ['click']
|
|
127
|
+
}
|
|
128
|
+
}]
|
|
129
|
+
}
|
|
130
|
+
}]
|
|
131
|
+
})
|
|
132
|
+
});
|
|
133
|
+
});
|
|
@@ -4,7 +4,7 @@ import { IDataCellProps, TDataCellType, TGroupV2 } from '../types';
|
|
|
4
4
|
export declare const cellItemMap: TCellItemMap;
|
|
5
5
|
type TCellItemFnData = {
|
|
6
6
|
item: IDataCellProps['items'][number];
|
|
7
|
-
click?: (rawItem: IDataCellProps['items'][number], subItem?: Exclude<TGroupV2['props'], undefined>['items'][number]) => void;
|
|
7
|
+
click?: (rawItem: IDataCellProps['items'][number], subItem?: Exclude<TGroupV2['props'], undefined>['items'][number], dropdownKey?: string) => void;
|
|
8
8
|
systemHistory?: ReturnType<typeof useRexProConfigProvider>['systemHistory'];
|
|
9
9
|
};
|
|
10
10
|
type TCellItemMap = Record<TDataCellType, (data: TCellItemFnData) => React.ReactNode>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["ellipsis", "tooltip", "copyable", "action", "urlTarget", "url", "style", "type"],
|
|
1
|
+
var _excluded = ["ellipsis", "tooltip", "copyable", "action", "urlTarget", "url", "style", "type", "dropdown"],
|
|
2
2
|
_excluded2 = ["mediaViewerType"],
|
|
3
3
|
_excluded3 = ["value"],
|
|
4
4
|
_excluded4 = ["iconsType"];
|
|
@@ -12,7 +12,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
12
12
|
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); }
|
|
13
13
|
import { EyeOutlined } from '@ant-design/icons';
|
|
14
14
|
import { downloadResourceFile, Icons, MediaViewer, showFileViewer } from "../../..";
|
|
15
|
-
import { Tag, Tooltip, Typography } from 'antd';
|
|
15
|
+
import { Dropdown, Tag, Tooltip, Typography } from 'antd';
|
|
16
16
|
import React, { cloneElement } from 'react';
|
|
17
17
|
import { DataCell } from "../data-cell";
|
|
18
18
|
import { DataCellRowText, DataCellRowTextLabel, DataCellRowTextValue } from "../style";
|
|
@@ -334,6 +334,7 @@ export var cellItemMap = {
|
|
|
334
334
|
url = subItem.url,
|
|
335
335
|
style = subItem.style,
|
|
336
336
|
type = subItem.type,
|
|
337
|
+
dropdown = subItem.dropdown,
|
|
337
338
|
other = _objectWithoutProperties(subItem, _excluded);
|
|
338
339
|
var renderBox = function renderBox(content) {
|
|
339
340
|
var afterContent = /*#__PURE__*/_jsx(DataCellRowTextValue, {
|
|
@@ -435,23 +436,48 @@ export var cellItemMap = {
|
|
|
435
436
|
children: afterContent
|
|
436
437
|
}, "renderItem-".concat(index, "-").concat(count++));
|
|
437
438
|
};
|
|
439
|
+
var wrapDropdown = function wrapDropdown(node) {
|
|
440
|
+
var _dropdown$items;
|
|
441
|
+
if (dropdown !== null && dropdown !== void 0 && (_dropdown$items = dropdown.items) !== null && _dropdown$items !== void 0 && _dropdown$items.length) {
|
|
442
|
+
var _dropdown$trigger;
|
|
443
|
+
return /*#__PURE__*/_jsx(Dropdown, {
|
|
444
|
+
menu: {
|
|
445
|
+
items: dropdown.items,
|
|
446
|
+
onClick: function onClick(_ref9) {
|
|
447
|
+
var key = _ref9.key;
|
|
448
|
+
return click === null || click === void 0 ? void 0 : click(item, subItem, key);
|
|
449
|
+
}
|
|
450
|
+
},
|
|
451
|
+
trigger: (_dropdown$trigger = dropdown.trigger) !== null && _dropdown$trigger !== void 0 ? _dropdown$trigger : ['click'],
|
|
452
|
+
placement: dropdown.placement,
|
|
453
|
+
children: /*#__PURE__*/_jsx("div", {
|
|
454
|
+
style: {
|
|
455
|
+
display: 'inline-flex',
|
|
456
|
+
cursor: 'pointer'
|
|
457
|
+
},
|
|
458
|
+
children: node
|
|
459
|
+
})
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
return node;
|
|
463
|
+
};
|
|
438
464
|
switch (type) {
|
|
439
465
|
case 'text':
|
|
440
|
-
return renderBox(subItem.value);
|
|
466
|
+
return wrapDropdown(renderBox(subItem.value));
|
|
441
467
|
case 'img':
|
|
442
468
|
{
|
|
443
|
-
var
|
|
444
|
-
mediaViewerType =
|
|
445
|
-
otherProps = _objectWithoutProperties(
|
|
446
|
-
return renderBox( /*#__PURE__*/_jsx(MediaViewer, _objectSpread({
|
|
469
|
+
var _ref10 = other,
|
|
470
|
+
mediaViewerType = _ref10.mediaViewerType,
|
|
471
|
+
otherProps = _objectWithoutProperties(_ref10, _excluded2);
|
|
472
|
+
return wrapDropdown(renderBox( /*#__PURE__*/_jsx(MediaViewer, _objectSpread({
|
|
447
473
|
type: mediaViewerType
|
|
448
|
-
}, otherProps)));
|
|
474
|
+
}, otherProps))));
|
|
449
475
|
}
|
|
450
476
|
case 'tag':
|
|
451
477
|
{
|
|
452
|
-
var
|
|
453
|
-
value =
|
|
454
|
-
_otherProps = _objectWithoutProperties(
|
|
478
|
+
var _ref11 = other,
|
|
479
|
+
value = _ref11.value,
|
|
480
|
+
_otherProps = _objectWithoutProperties(_ref11, _excluded3);
|
|
455
481
|
var color = function () {
|
|
456
482
|
if (subItem.color !== null && _typeof(subItem.color) === 'object') {
|
|
457
483
|
var _subItem$color, _subItem$color$toHexS;
|
|
@@ -462,19 +488,19 @@ export var cellItemMap = {
|
|
|
462
488
|
}
|
|
463
489
|
return '#2db7f5';
|
|
464
490
|
}();
|
|
465
|
-
return renderBox(isEmpty(value) ? '' : /*#__PURE__*/_jsx(Tag, _objectSpread(_objectSpread({}, _otherProps), {}, {
|
|
491
|
+
return wrapDropdown(renderBox(isEmpty(value) ? '' : /*#__PURE__*/_jsx(Tag, _objectSpread(_objectSpread({}, _otherProps), {}, {
|
|
466
492
|
color: color,
|
|
467
493
|
children: value
|
|
468
|
-
})));
|
|
494
|
+
}))));
|
|
469
495
|
}
|
|
470
496
|
case 'icon':
|
|
471
497
|
{
|
|
472
|
-
var
|
|
473
|
-
iconsType =
|
|
474
|
-
_otherProps2 = _objectWithoutProperties(
|
|
475
|
-
return renderBox( /*#__PURE__*/_jsx(Icons, _objectSpread({
|
|
498
|
+
var _ref12 = other,
|
|
499
|
+
iconsType = _ref12.iconsType,
|
|
500
|
+
_otherProps2 = _objectWithoutProperties(_ref12, _excluded4);
|
|
501
|
+
return wrapDropdown(renderBox( /*#__PURE__*/_jsx(Icons, _objectSpread({
|
|
476
502
|
type: iconsType
|
|
477
|
-
}, _otherProps2)));
|
|
503
|
+
}, _otherProps2))));
|
|
478
504
|
}
|
|
479
505
|
default:
|
|
480
506
|
break;
|
|
@@ -1,12 +1,23 @@
|
|
|
1
1
|
import { Icons, MediaViewer, useRexProConfigProvider } from "../..";
|
|
2
|
-
import { GetProps, Tag } from 'antd';
|
|
2
|
+
import { Dropdown, GetProps, Tag } from 'antd';
|
|
3
3
|
import { HTMLAttributeAnchorTarget } from 'react';
|
|
4
|
+
/** Dropdown 配置 */
|
|
5
|
+
export interface IDataCellDropdown {
|
|
6
|
+
/** 下拉菜单项 */
|
|
7
|
+
items: Exclude<GetProps<typeof Dropdown>['menu'], undefined>['items'];
|
|
8
|
+
/** 触发方式 @default ['click'] */
|
|
9
|
+
trigger?: GetProps<typeof Dropdown>['trigger'];
|
|
10
|
+
/** 弹出位置 */
|
|
11
|
+
placement?: GetProps<typeof Dropdown>['placement'];
|
|
12
|
+
}
|
|
4
13
|
/** 组件props */
|
|
5
14
|
export interface IDataCellProps {
|
|
6
15
|
/** 每一行展示内容 */
|
|
7
16
|
items: Array<TGroupV2 | IDataCellItem<TDataCellType>>;
|
|
8
|
-
/**
|
|
9
|
-
onClick?: (item: IDataCellItem, subItem?: Exclude<TGroupV2['props'], undefined>['items'][number]
|
|
17
|
+
/** 点击回调(action='custom' 或 Dropdown 菜单项点击时触发) */
|
|
18
|
+
onClick?: (item: IDataCellItem, subItem?: Exclude<TGroupV2['props'], undefined>['items'][number],
|
|
19
|
+
/** Dropdown 菜单项点击时的 key */
|
|
20
|
+
dropdownKey?: string) => void;
|
|
10
21
|
/** 系统路由历史对象,用于内部跳转 */
|
|
11
22
|
systemHistory?: ReturnType<typeof useRexProConfigProvider>['systemHistory'];
|
|
12
23
|
}
|
|
@@ -17,6 +28,8 @@ export interface IDataCellItem<T extends TDataCellType = TDataCellType> {
|
|
|
17
28
|
props?: ICellPropsMap[T];
|
|
18
29
|
/** 顶层样式 */
|
|
19
30
|
rootStyle?: React.CSSProperties;
|
|
31
|
+
/** 下拉菜单配置 */
|
|
32
|
+
dropdown?: IDataCellDropdown;
|
|
20
33
|
/** 扩展信息 */
|
|
21
34
|
extra?: {
|
|
22
35
|
rowSpan?: number;
|
|
@@ -129,6 +142,8 @@ export type TGroupV2 = {
|
|
|
129
142
|
iconsType?: GetProps<typeof Icons>['type'];
|
|
130
143
|
} & ICommonGroupV2 & Omit<GetProps<typeof Icons>, 'type'>) | TGroupV2>;
|
|
131
144
|
};
|
|
145
|
+
/** 下拉菜单配置 */
|
|
146
|
+
dropdown?: IDataCellDropdown;
|
|
132
147
|
/** 顶层样式 */
|
|
133
148
|
rootStyle?: React.CSSProperties;
|
|
134
149
|
/** 扩展信息 */
|
|
@@ -139,6 +154,8 @@ export type TGroupV2 = {
|
|
|
139
154
|
};
|
|
140
155
|
/** 为 group-v2 公共属性 */
|
|
141
156
|
export interface ICommonGroupV2 {
|
|
157
|
+
/** 下拉菜单配置 */
|
|
158
|
+
dropdown?: IDataCellDropdown;
|
|
142
159
|
/**
|
|
143
160
|
* 缺省
|
|
144
161
|
* @default 2
|