zmdms-webui 1.8.6 → 1.8.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.
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React__default from 'react';
|
|
2
|
+
|
|
3
|
+
interface IBadgeProps {
|
|
4
|
+
/** 角标提示文本 */
|
|
5
|
+
title?: string;
|
|
6
|
+
/** 角标颜色 */
|
|
7
|
+
color?: string;
|
|
8
|
+
/** 角标大小 */
|
|
9
|
+
size?: "small" | "default" | "large";
|
|
10
|
+
/** 是否显示角标 */
|
|
11
|
+
show?: boolean;
|
|
12
|
+
/** 角标样式 */
|
|
13
|
+
style?: React__default.CSSProperties;
|
|
14
|
+
/** 角标类名 */
|
|
15
|
+
className?: string;
|
|
16
|
+
/** 子元素 */
|
|
17
|
+
children?: React__default.ReactNode;
|
|
18
|
+
/** 角标位置 */
|
|
19
|
+
position?: "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
|
20
|
+
/** 触发方式 */
|
|
21
|
+
trigger?: "click" | "hover" | "focus";
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { IBadgeProps };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { __rest, __assign } from '../../_virtual/_tslib.js';
|
|
2
|
+
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { Tooltip } from 'antd';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 角标组件
|
|
7
|
+
* 右上角显示三角形角标,鼠标悬停显示提示文本
|
|
8
|
+
*/
|
|
9
|
+
var Badge = function (_a) {
|
|
10
|
+
var title = _a.title, _b = _a.color, color = _b === void 0 ? "#f50" : _b, _c = _a.size, size = _c === void 0 ? "default" : _c, _d = _a.show, show = _d === void 0 ? true : _d, style = _a.style, className = _a.className, children = _a.children, _e = _a.position, position = _e === void 0 ? "top-right" : _e, _f = _a.trigger, trigger = _f === void 0 ? "click" : _f, restProps = __rest(_a, ["title", "color", "size", "show", "style", "className", "children", "position", "trigger"]);
|
|
11
|
+
// 如果不显示角标,直接返回子元素
|
|
12
|
+
if (!show) {
|
|
13
|
+
return jsx(Fragment, { children: children });
|
|
14
|
+
}
|
|
15
|
+
// 根据位置计算样式
|
|
16
|
+
var getPositionStyle = function () {
|
|
17
|
+
var baseStyle = {
|
|
18
|
+
position: "absolute",
|
|
19
|
+
width: 0,
|
|
20
|
+
height: 0,
|
|
21
|
+
borderStyle: "solid",
|
|
22
|
+
};
|
|
23
|
+
var sizeMap = {
|
|
24
|
+
small: 6,
|
|
25
|
+
default: 8,
|
|
26
|
+
large: 10,
|
|
27
|
+
};
|
|
28
|
+
var triangleSize = sizeMap[size];
|
|
29
|
+
switch (position) {
|
|
30
|
+
case "top-right":
|
|
31
|
+
return __assign(__assign({}, baseStyle), { top: 0, right: 0, borderWidth: "0 ".concat(triangleSize, "px ").concat(triangleSize, "px 0"), borderColor: "transparent ".concat(color, " transparent transparent") });
|
|
32
|
+
case "top-left":
|
|
33
|
+
return __assign(__assign({}, baseStyle), { top: 0, left: 0, borderWidth: "".concat(triangleSize, "px ").concat(triangleSize, "px 0 0"), borderColor: "".concat(color, " transparent transparent transparent") });
|
|
34
|
+
case "bottom-right":
|
|
35
|
+
return __assign(__assign({}, baseStyle), { bottom: 0, right: 0, borderWidth: "0 0 ".concat(triangleSize, "px ").concat(triangleSize, "px"), borderColor: "transparent transparent ".concat(color, " transparent") });
|
|
36
|
+
case "bottom-left":
|
|
37
|
+
return __assign(__assign({}, baseStyle), { bottom: 0, left: 0, borderWidth: "".concat(triangleSize, "px 0 0 ").concat(triangleSize, "px"), borderColor: "transparent transparent transparent ".concat(color) });
|
|
38
|
+
default:
|
|
39
|
+
return __assign(__assign({}, baseStyle), { top: 0, right: 0, borderWidth: "0 ".concat(triangleSize, "px ").concat(triangleSize, "px 0"), borderColor: "transparent ".concat(color, " transparent transparent") });
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var badge = jsx("div", { style: getPositionStyle() });
|
|
43
|
+
// 如果有 title,则包装在 Tooltip 中
|
|
44
|
+
if (title) {
|
|
45
|
+
badge = (jsx(Tooltip, __assign({ title: title, placement: "top", trigger: trigger }, { children: jsx("div", { style: getPositionStyle() }) })));
|
|
46
|
+
}
|
|
47
|
+
var badgeElement = (jsxs("div", __assign({ style: __assign({}, style), className: className }, restProps, { children: [children, badge] })));
|
|
48
|
+
return badgeElement;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { Badge as default };
|
|
@@ -6,6 +6,7 @@ import { IInputNumberProps } from '../inputnumber/inputNumber.js';
|
|
|
6
6
|
import { IDynamicItem } from '../dynamicsetting/interface.js';
|
|
7
7
|
import _default from './components/TitleDirectionColumn.js';
|
|
8
8
|
import { IS_SUMMARY } from './constant.js';
|
|
9
|
+
import { IBadgeProps } from './components/Badge.js';
|
|
9
10
|
|
|
10
11
|
type IEditableConfigOtherProps = IInputProps & IInputNumberProps & TextAreaProps;
|
|
11
12
|
interface IEditableConfig extends Partial<IEditableConfigOtherProps> {
|
|
@@ -224,6 +225,10 @@ interface IColumnType<RecordType> extends Omit<ColumnType<RecordType>, "render">
|
|
|
224
225
|
* 开启合并的字段,按其他字段维度合并
|
|
225
226
|
*/
|
|
226
227
|
mergeKey?: string;
|
|
228
|
+
/**
|
|
229
|
+
* 添加角标
|
|
230
|
+
*/
|
|
231
|
+
badge?: IBadgeProps | ((record: any) => IBadgeProps);
|
|
227
232
|
}
|
|
228
233
|
interface IRenderOptions {
|
|
229
234
|
insertTableFromClipboard: IFuncInsertTableFromClipboard;
|
|
@@ -3,7 +3,7 @@ import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { useRef } from 'react';
|
|
4
4
|
import { getTableColumns, parsePasteData, getFilterRecords, startColumnInsertTableData } from './utils.js';
|
|
5
5
|
import '../node_modules/classnames/index.js';
|
|
6
|
-
import { MERGE_INDEX } from './constant.js';
|
|
6
|
+
import { MERGE_INDEX, IS_SUMMARY } from './constant.js';
|
|
7
7
|
import 'ahooks';
|
|
8
8
|
import './components/EnhanceHeaderCell.js';
|
|
9
9
|
import ColumnDynamic from './components/ColumnDynamic.js';
|
|
@@ -12,6 +12,7 @@ import TitleOperation from './components/TitleOperation.js';
|
|
|
12
12
|
import SortTitle from './components/SortTitle.js';
|
|
13
13
|
import PopoverIcon from './components/PopoverIcon.js';
|
|
14
14
|
import FilterDropdown, { createFilterValue, filterHandle } from './components/FilterDropdown.js';
|
|
15
|
+
import Badge from './components/Badge.js';
|
|
15
16
|
import { PLACEHOLDER_NULL } from '../config/constant.js';
|
|
16
17
|
import { useMergeAddAndDel } from './hooks.js';
|
|
17
18
|
import SearchOutlined from '../node_modules/@ant-design/icons/es/icons/SearchOutlined.js';
|
|
@@ -293,6 +294,23 @@ function useColumns(columns, options) {
|
|
|
293
294
|
return fn_1(record, preRecord);
|
|
294
295
|
};
|
|
295
296
|
}
|
|
297
|
+
// 添加角标
|
|
298
|
+
if (_column.badge) {
|
|
299
|
+
var render_1 = _column.render;
|
|
300
|
+
_column.render = function (text, record, index, options) {
|
|
301
|
+
var v = render_1 ? render_1(text, record, index, options) : text;
|
|
302
|
+
if (record[IS_SUMMARY]) {
|
|
303
|
+
return v;
|
|
304
|
+
}
|
|
305
|
+
var props = typeof _column.badge === "function"
|
|
306
|
+
? _column.badge(record)
|
|
307
|
+
: _column.badge;
|
|
308
|
+
if (!props) {
|
|
309
|
+
return v;
|
|
310
|
+
}
|
|
311
|
+
return jsx(Badge, __assign({}, props, { children: v }));
|
|
312
|
+
};
|
|
313
|
+
}
|
|
296
314
|
// 添加render字段,
|
|
297
315
|
if (!_column.render && !_column.editable) {
|
|
298
316
|
_column.render = function (text, record, index) {
|