tntd 2.8.0-beta.13 → 2.8.0-beta.15
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/es/descriptions/descriptions.js +83 -44
- package/es/descriptions/descriptions.js.map +1 -1
- package/es/descriptions/descriptions.less +57 -60
- package/es/drawer/index.less +5 -11
- package/es/handle-icon/index.js +35 -17
- package/es/handle-icon/index.js.map +1 -1
- package/es/handle-icon/index.less +28 -15
- package/es/input/input.js +10 -6
- package/es/input/input.js.map +1 -1
- package/es/input/style/mixin.less +1 -1
- package/es/select/select.js +5 -3
- package/es/select/select.js.map +1 -1
- package/es/select/style/index.less +4 -4
- package/es/tntd-select/index.js +5 -3
- package/es/tntd-select/index.js.map +1 -1
- package/lib/descriptions/descriptions.d.ts +11 -6
- package/lib/descriptions/descriptions.d.ts.map +1 -1
- package/lib/descriptions/descriptions.js +84 -45
- package/lib/descriptions/descriptions.js.map +1 -1
- package/lib/descriptions/descriptions.less +57 -60
- package/lib/drawer/index.less +5 -11
- package/lib/handle-icon/index.d.ts.map +1 -1
- package/lib/handle-icon/index.js +29 -10
- package/lib/handle-icon/index.js.map +1 -1
- package/lib/handle-icon/index.less +28 -15
- package/lib/input/input.js +8 -4
- package/lib/input/input.js.map +1 -1
- package/lib/input/style/mixin.less +1 -1
- package/lib/select/select.d.ts.map +1 -1
- package/lib/select/select.js +4 -2
- package/lib/select/select.js.map +1 -1
- package/lib/select/style/index.less +4 -4
- package/lib/tntd-select/index.d.ts.map +1 -1
- package/lib/tntd-select/index.js +4 -2
- package/lib/tntd-select/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -8,80 +8,119 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
8
8
|
};
|
|
9
9
|
/*
|
|
10
10
|
* @Author: 周泽飞 zefei.zhou@tongdun.net
|
|
11
|
-
* @Date:
|
|
11
|
+
* @Date: 2024-06-08 11:59:04
|
|
12
12
|
* @LastEditors: 周泽飞 zefei.zhou@tongdun.net
|
|
13
|
-
* @LastEditTime: 2024-
|
|
13
|
+
* @LastEditTime: 2024-06-08 13:39:25
|
|
14
14
|
* @FilePath: /tntd/packages/tntd/src/descriptions/descriptions.tsx
|
|
15
15
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
16
16
|
*/
|
|
17
17
|
import React, { forwardRef } from 'react';
|
|
18
|
-
import 'antd/es/locale-provider/LocaleReceiver';
|
|
19
18
|
import classNames from 'classnames';
|
|
19
|
+
import toArray from 'rc-util/es/Children/toArray';
|
|
20
20
|
import { ConfigConsumer } from 'antd/es/config-provider';
|
|
21
21
|
import { default as AntdDescriptions } from 'antd/es/descriptions';
|
|
22
22
|
import Ellipsis from '../ellipsis';
|
|
23
|
+
import { doUpperTitle } from '../utils';
|
|
24
|
+
import { getLanguage } from '../prev-locale';
|
|
23
25
|
export * from 'antd/es/descriptions';
|
|
24
26
|
export const Descriptions = forwardRef((_a, ref) => {
|
|
25
27
|
var {
|
|
26
28
|
className,
|
|
27
29
|
tdType = true,
|
|
28
|
-
|
|
30
|
+
titleWeight,
|
|
31
|
+
titleType,
|
|
29
32
|
colon,
|
|
30
|
-
children
|
|
33
|
+
children,
|
|
34
|
+
undoUpper = false,
|
|
35
|
+
upperCaseIgnore = [],
|
|
36
|
+
title
|
|
31
37
|
} = _a,
|
|
32
|
-
rest = __rest(_a, ["className", "tdType", "
|
|
33
|
-
return React.createElement(ConfigConsumer, null, (
|
|
38
|
+
rest = __rest(_a, ["className", "tdType", "titleWeight", "titleType", "colon", "children", "undoUpper", "upperCaseIgnore", "title"]);
|
|
39
|
+
return React.createElement(ConfigConsumer, null, ({
|
|
40
|
+
getPrefixCls
|
|
41
|
+
}) => {
|
|
42
|
+
const prefixCls = getPrefixCls('descriptions');
|
|
34
43
|
const {
|
|
35
44
|
layout,
|
|
36
45
|
ellipsis,
|
|
46
|
+
ellipsisLine = 1,
|
|
47
|
+
hideTooltip = false,
|
|
37
48
|
bordered
|
|
38
49
|
} = rest || {};
|
|
39
50
|
// 非垂直 且 同盾
|
|
40
51
|
const tdDescriptions = layout !== 'vertical' && tdType;
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
props
|
|
46
|
-
} = element;
|
|
47
|
-
if (type.name === 'DescriptionsItem') {
|
|
48
|
-
const childProps = props || {};
|
|
49
|
-
const {
|
|
50
|
-
label,
|
|
51
|
-
children
|
|
52
|
-
} = childProps;
|
|
53
|
-
return React.createElement("div", null, React.createElement(Ellipsis, {
|
|
54
|
-
className: "tntd-description-item",
|
|
55
|
-
prefix: React.createElement("div", {
|
|
56
|
-
className: "tntd-description-label-title"
|
|
57
|
-
}, label),
|
|
58
|
-
title: element
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
if (props && props.children) {
|
|
62
|
-
const modifiedChildren = React.Children.map(props.children, child => {
|
|
63
|
-
return decorateNoBorderChild(child);
|
|
64
|
-
});
|
|
65
|
-
return React.cloneElement(element, props, modifiedChildren);
|
|
66
|
-
}
|
|
52
|
+
const tntPrefixCls = 'tnt-descriptions';
|
|
53
|
+
const flattenChildren = children => {
|
|
54
|
+
if (!children) {
|
|
55
|
+
return [];
|
|
67
56
|
}
|
|
68
|
-
return
|
|
57
|
+
return toArray(children).reduce(function (flatChildren, child) {
|
|
58
|
+
if (child && child.type === React.Fragment) {
|
|
59
|
+
return flatChildren.concat(flattenChildren(child.props.children));
|
|
60
|
+
}
|
|
61
|
+
flatChildren.push(child);
|
|
62
|
+
return flatChildren;
|
|
63
|
+
}, []);
|
|
69
64
|
};
|
|
65
|
+
children = flattenChildren(children);
|
|
70
66
|
return React.createElement(AntdDescriptions, Object.assign({
|
|
71
|
-
className: classNames(
|
|
72
|
-
|
|
73
|
-
}, {
|
|
74
|
-
'
|
|
67
|
+
className: classNames(`${prefixCls}-${getLanguage()}`, {
|
|
68
|
+
[tntPrefixCls]: tdDescriptions
|
|
69
|
+
}, `${tntPrefixCls}-title-theme${titleType ? '-' + titleType : ''}`, {
|
|
70
|
+
[tntPrefixCls + '-title-weight']: titleWeight
|
|
75
71
|
}, {
|
|
76
|
-
'
|
|
77
|
-
}, className)
|
|
72
|
+
[tntPrefixCls + '-ellipsis']: ellipsis
|
|
73
|
+
}, className),
|
|
74
|
+
title: undoUpper ? title : doUpperTitle(title, upperCaseIgnore)
|
|
78
75
|
}, rest, {
|
|
79
|
-
colon: tdDescriptions
|
|
80
|
-
|
|
76
|
+
colon: tdDescriptions ? false : colon,
|
|
77
|
+
ref: ref
|
|
78
|
+
}), tdDescriptions && !bordered && !hideTooltip && React.Children.map(children, child => {
|
|
81
79
|
if (React.isValidElement(child)) {
|
|
82
|
-
|
|
80
|
+
const childProps = child.props || {};
|
|
81
|
+
const {
|
|
82
|
+
label,
|
|
83
|
+
labelPrefix,
|
|
84
|
+
children: childContext
|
|
85
|
+
} = childProps;
|
|
86
|
+
return React.createElement("div", null, React.createElement(Ellipsis, {
|
|
87
|
+
lines: ellipsisLine,
|
|
88
|
+
className: "tnt-descriptions-item",
|
|
89
|
+
prefix: React.createElement("div", {
|
|
90
|
+
className: "tnt-descriptions-label-title"
|
|
91
|
+
}, React.createElement(Ellipsis, {
|
|
92
|
+
prefix: labelPrefix ? React.createElement("span", {
|
|
93
|
+
className: "tnt-descriptions-label-tag"
|
|
94
|
+
}, labelPrefix) : null,
|
|
95
|
+
lines: ellipsisLine,
|
|
96
|
+
title: label
|
|
97
|
+
})),
|
|
98
|
+
title: childContext
|
|
99
|
+
}));
|
|
100
|
+
}
|
|
101
|
+
}), tdDescriptions && bordered && ellipsis && !hideTooltip && React.Children.map(children, child => {
|
|
102
|
+
if (React.isValidElement(child)) {
|
|
103
|
+
const childProps = child.props || {};
|
|
104
|
+
const {
|
|
105
|
+
label,
|
|
106
|
+
labelPrefix,
|
|
107
|
+
children: childContext
|
|
108
|
+
} = childProps;
|
|
109
|
+
return React.cloneElement(child, Object.assign(Object.assign({}, child.props), {
|
|
110
|
+
label: React.createElement(Ellipsis, {
|
|
111
|
+
prefix: labelPrefix ? React.createElement("span", {
|
|
112
|
+
className: "tnt-descriptions-label-tag"
|
|
113
|
+
}, labelPrefix) : null,
|
|
114
|
+
lines: ellipsisLine,
|
|
115
|
+
title: label
|
|
116
|
+
}),
|
|
117
|
+
children: React.createElement(Ellipsis, {
|
|
118
|
+
lines: ellipsisLine,
|
|
119
|
+
title: childContext
|
|
120
|
+
})
|
|
121
|
+
}));
|
|
83
122
|
}
|
|
84
|
-
})
|
|
123
|
+
}), (!tdDescriptions || bordered && !ellipsis || hideTooltip) && children);
|
|
85
124
|
});
|
|
86
125
|
});
|
|
87
126
|
Descriptions.Item = AntdDescriptions.Item;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../src/descriptions/descriptions.tsx"],"names":[],"mappings":";;;;;;;;;;;AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AACzC,OAA2B,wCAAwC,CAAA;AAGnE,OAAO,UAAU,MAAM,YAAY,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAElE,OAAO,QAAQ,MAAM,aAAa,CAAA;AAElC,cAAc,sBAAsB,CAAA;AAoBpC,MAAM,CAAC,MAAM,YAAY,GAAG,UAAU,CAGpC,CAAC,EAA6D,EAAE,GAAG,EAAE,EAAE;QAAtE,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,OAAW,EAAN,IAAI,cAA3D,qDAA6D,CAAF;IAC5D,OAAO,CACL,oBAAC,cAAc,QACZ,GAAG,EAAE;QACJ,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,Q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E,cAAc;aACpC,EACD;gBACE,4BAA4B,EAAE,QAAQ;aACvC,EACD,SAAS,CACV,IACG,IAAI,IACR,KAAK,EAAE,cAAc,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,KAGjD,cAAc,IAAI,CAAC,QAAQ;YAC1B,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;gBACrC,IAAI,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE;oBAC/B,OAAO,qBAAqB,CAAC,KAAK,CAAC,CAAA;iBACpC;YACH,CAAC,CAAC;YACJ,CAAC,CAAC,QAAQ,CACK,CACpB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CAA0B,CAAA;AAE3B,YAAY,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAA","sourcesContent":["/*\n * @Author: 周泽飞 zefei.zhou@tongdun.net\n * @Date: 2023-05-05 15:48:09\n * @LastEditors: 周泽飞 zefei.zhou@tongdun.net\n * @LastEditTime: 2024-01-18 15:27:45\n * @FilePath: /tntd/packages/tntd/src/descriptions/descriptions.tsx\n * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\n */\nimport React, { forwardRef } from 'react'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport type { DescriptionsProps as AntdDescriptionsProps } from 'antd/es/descriptions'\nimport type { DescriptionsItemProps as AntdDescriptionsItemProps } from 'antd/es/descriptions'\nimport classNames from 'classnames'\nimport { ConfigConsumer } from 'antd/es/config-provider'\nimport { default as AntdDescriptions } from 'antd/es/descriptions'\n\nimport Ellipsis from '../ellipsis'\n\nexport * from 'antd/es/descriptions'\n\nexport interface DescriptionsProps extends AntdDescriptionsProps {\n tdType: boolean\n ellipsis: boolean\n theme: string\n}\n\nexport interface DescriptionsItemProps extends AntdDescriptionsItemProps {\n tdType: boolean\n theme: string\n}\n\ninterface DescriptionsComponent\n extends React.ForwardRefExoticComponent<\n DescriptionsProps & React.RefAttributes<AntdDescriptions>\n > {\n Item: typeof AntdDescriptions.Item\n}\n\nexport const Descriptions = forwardRef<\n AntdDescriptions,\n DescriptionsProps & { capitalize?: boolean }\n>(({ className, tdType = true, theme, colon, children, ...rest }, ref) => {\n return (\n <ConfigConsumer>\n {() => {\n const { layout, ellipsis, bordered } = rest || {}\n // 非垂直 且 同盾\n const tdDescriptions = layout !== 'vertical' && tdType\n\n const decorateNoBorderChild = (element: React.ReactElement): React.ReactElement => {\n if (React.isValidElement(element)) {\n const { type, props } = element as React.ReactElement | any\n if (type.name === 'DescriptionsItem') {\n const childProps = (props || {}) as any\n const { label, children } = childProps\n return (\n <div>\n <Ellipsis\n className=\"tntd-description-item\"\n prefix={<div className=\"tntd-description-label-title\">{label}</div>}\n title={element}\n />\n </div>\n )\n }\n if (props && props.children) {\n const modifiedChildren = React.Children.map(props.children, (child) => {\n return decorateNoBorderChild(child)\n })\n return React.cloneElement(element, props, modifiedChildren)\n }\n }\n return element\n }\n\n return (\n <AntdDescriptions\n className={classNames(\n `theme-${theme || (bordered ? 'line' : 'block')}`,\n {\n 'tntd-descriptions-no-border': !bordered,\n },\n {\n 'tntd-descriptions': tdDescriptions,\n },\n {\n 'tntd-descriptions-ellipsis': ellipsis,\n },\n className\n )}\n {...rest}\n colon={tdDescriptions && !bordered ? false : colon}\n >\n {/* 非边框的同盾内置样式 */}\n {tdDescriptions && !bordered\n ? React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n return decorateNoBorderChild(child)\n }\n })\n : children}\n </AntdDescriptions>\n )\n }}\n </ConfigConsumer>\n )\n}) as DescriptionsComponent\n\nDescriptions.Item = AntdDescriptions.Item\n"]}
|
|
1
|
+
{"version":3,"file":"descriptions.js","sourceRoot":"","sources":["../../src/descriptions/descriptions.tsx"],"names":[],"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AAK,EAAE,YAAY,GAAI,IAChE,CAAA;qBACH;gBACH,CAAC,CAAC;YAEH,CAAC,CAAC,cAAc,IAAI,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,IAAI,WAAW,CAAC,IAAI,QAAQ,CACvD,CACpB,CAAA;IACH,CAAC,CACc,CAClB,CAAA;AACH,CAAC,CACuB,CAAA;AAE1B,YAAY,CAAC,IAAI,GAAG,gBAAgB,CAAC,IAAI,CAAA","sourcesContent":["/*\n * @Author: 周泽飞 zefei.zhou@tongdun.net\n * @Date: 2024-06-08 11:59:04\n * @LastEditors: 周泽飞 zefei.zhou@tongdun.net\n * @LastEditTime: 2024-06-08 13:39:25\n * @FilePath: /tntd/packages/tntd/src/descriptions/descriptions.tsx\n * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE\n */\nimport React, { forwardRef } from 'react'\nimport type { DescriptionsProps as AntdDescriptionsProps } from 'antd/es/descriptions'\nimport type { DescriptionsItemProps as AntdDescriptionsItemProps } from 'antd/es/descriptions'\nimport classNames from 'classnames'\nimport toArray from 'rc-util/es/Children/toArray'\nimport { ConfigConsumer } from 'antd/es/config-provider'\nimport { default as AntdDescriptions } from 'antd/es/descriptions'\n\nimport Ellipsis from '../ellipsis'\nimport { doUpperTitle } from '../utils'\nimport { getLanguage } from '../prev-locale'\n\nexport * from 'antd/es/descriptions'\n\nexport interface DescriptionsProps extends AntdDescriptionsProps {\n tdType?: boolean\n ellipsis?: boolean\n ellipsisLine?: number\n hideTooltip?: boolean\n undoUpper?: boolean\n upperCaseIgnore?: Array<string>\n titleType?: string\n titleWeight?: boolean\n}\n\nexport interface DescriptionsItemProps extends AntdDescriptionsItemProps {\n labelPrefix?: React.ReactNode\n}\n\ndeclare const DescriptionsItem: React.FC<DescriptionsItemProps>\ninterface DescriptionsComponent\n extends React.ForwardRefExoticComponent<\n DescriptionsProps & React.RefAttributes<AntdDescriptions>\n > {\n Item: typeof DescriptionsItem\n}\n\nexport const Descriptions = forwardRef<\n AntdDescriptions,\n DescriptionsProps & { capitalize?: boolean }\n>(\n (\n {\n className,\n tdType = true,\n titleWeight,\n titleType,\n colon,\n children,\n undoUpper = false,\n upperCaseIgnore = [],\n title,\n ...rest\n },\n ref\n ) => {\n return (\n <ConfigConsumer>\n {({ getPrefixCls }) => {\n const prefixCls = getPrefixCls('descriptions')\n const { layout, ellipsis, ellipsisLine = 1, hideTooltip = false, bordered } = rest || {}\n // 非垂直 且 同盾\n const tdDescriptions = layout !== 'vertical' && tdType\n\n const tntPrefixCls = 'tnt-descriptions'\n\n const flattenChildren = (children: React.ReactNode): React.ReactNode[] => {\n if (!children) {\n return []\n }\n return toArray(children).reduce(function (\n flatChildren: React.ReactNode[],\n child: React.ReactNode\n ) {\n if (child && (child as any).type === React.Fragment) {\n return flatChildren.concat(flattenChildren((child as any).props.children))\n }\n\n flatChildren.push(child)\n return flatChildren\n },\n [])\n }\n\n children = flattenChildren(children)\n\n return (\n <AntdDescriptions\n className={classNames(\n `${prefixCls}-${getLanguage()}`,\n {\n [tntPrefixCls]: tdDescriptions,\n },\n `${tntPrefixCls}-title-theme${titleType ? '-' + titleType : ''}`,\n {\n [tntPrefixCls + '-title-weight']: titleWeight,\n },\n {\n [tntPrefixCls + '-ellipsis']: ellipsis,\n },\n className\n )}\n title={undoUpper ? title : doUpperTitle(title, upperCaseIgnore)} // 默认转大写\n {...rest}\n colon={tdDescriptions ? false : colon}\n ref={ref}\n >\n {/*同盾描述框 非边框 开启默认tooltip */}\n {tdDescriptions &&\n !bordered &&\n !hideTooltip &&\n React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = (child.props || {}) as any\n const { label, labelPrefix, children: childContext } = childProps\n return (\n <div>\n <Ellipsis\n lines={ellipsisLine}\n className=\"tnt-descriptions-item\"\n prefix={\n <div className=\"tnt-descriptions-label-title\">\n <Ellipsis\n prefix={\n labelPrefix ? (\n <span className=\"tnt-descriptions-label-tag\">\n {labelPrefix}\n </span>\n ) : null\n }\n lines={ellipsisLine}\n title={label}\n />\n </div>\n }\n title={childContext}\n />\n </div>\n )\n }\n })}\n\n {/*同盾描述框 有边框 不换行 开启默认tooltip */}\n {tdDescriptions &&\n bordered &&\n ellipsis &&\n !hideTooltip &&\n React.Children.map(children, (child) => {\n if (React.isValidElement(child)) {\n const childProps = (child.props || {}) as any\n const { label, labelPrefix, children: childContext } = childProps\n return React.cloneElement(child, {\n ...child.props,\n label: (\n <Ellipsis\n prefix={\n labelPrefix ? (\n <span className=\"tnt-descriptions-label-tag\">{labelPrefix}</span>\n ) : null\n }\n lines={ellipsisLine}\n title={label}\n />\n ),\n children: <Ellipsis lines={ellipsisLine} title={childContext} />,\n })\n }\n })}\n {/* 非同盾模式下 或者 带边框但换行 或者 不开启默认tooltip 走默认逻辑 */}\n {(!tdDescriptions || (bordered && !ellipsis) || hideTooltip) && children}\n </AntdDescriptions>\n )\n }}\n </ConfigConsumer>\n )\n }\n) as DescriptionsComponent\n\nDescriptions.Item = AntdDescriptions.Item\n"]}
|
|
@@ -5,94 +5,90 @@
|
|
|
5
5
|
@descriptions-small-padding: 8px 16px;
|
|
6
6
|
@descriptions-bg: #e1e6ee;
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
.tnt-descriptions{
|
|
9
|
+
&.@{descriptions-prefix-cls} {
|
|
10
|
+
// 加粗的头部
|
|
11
|
+
&.tnt-descriptions-title-weight{
|
|
12
|
+
>.@{descriptions-prefix-cls}-title{
|
|
13
|
+
font-weight: 600 !important;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// label中有标签前缀
|
|
18
|
+
.tnt-descriptions-label-tag{
|
|
19
|
+
color:@primary-color;
|
|
20
|
+
margin-right: 4px;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// title样式
|
|
24
|
+
&[class*="tnt-descriptions-title-theme"]{
|
|
13
25
|
// 默认色主题
|
|
14
|
-
|
|
26
|
+
>.@{descriptions-prefix-cls}-title{
|
|
15
27
|
font-size:@font-size-base;
|
|
16
28
|
position: relative;
|
|
17
29
|
margin-bottom:12px;
|
|
18
30
|
padding-left:12px;
|
|
31
|
+
font-weight: 400;
|
|
19
32
|
&::before{
|
|
20
33
|
content: '';
|
|
21
34
|
width: 4px;
|
|
22
35
|
height: 12px;
|
|
23
36
|
background-color: @primary-color;
|
|
24
|
-
border-radius: 8px;
|
|
37
|
+
border-radius: @border-radius-base;//8px;
|
|
25
38
|
position: absolute;
|
|
26
39
|
top:6px;
|
|
27
40
|
left:0;
|
|
28
41
|
}
|
|
29
42
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
// 默认没有前面的线条展示
|
|
44
|
+
&.title-theme-none{
|
|
45
|
+
>.@{descriptions-prefix-cls}-title{
|
|
46
|
+
padding-left:0;
|
|
34
47
|
&::before{
|
|
35
48
|
content: '';
|
|
36
|
-
|
|
49
|
+
display: none;
|
|
37
50
|
}
|
|
38
51
|
}
|
|
39
52
|
}
|
|
40
|
-
|
|
41
53
|
}
|
|
42
54
|
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
font-size:@font-size-base;
|
|
47
|
-
max-width: 100%;
|
|
48
|
-
display: inline-block;
|
|
49
|
-
padding: 6px 20px 6px 16px;
|
|
50
|
-
border-radius: 8px 20px 20px 0px;
|
|
51
|
-
background: linear-gradient(0deg, rgba(18, 107, 251, 0.16) 0%, rgba(18, 107, 251, 0.08) 76.56%);
|
|
52
|
-
margin-right: 4px;
|
|
53
|
-
margin-bottom:8px;
|
|
54
|
-
white-space: nowrap;
|
|
55
|
-
overflow: hidden;
|
|
56
|
-
text-overflow: ellipsis;
|
|
57
|
-
font-weight: 600;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&-bordered {
|
|
63
|
-
&.tntd-descriptions {
|
|
64
|
-
&.tntd-descriptions-ellipsis{
|
|
55
|
+
// 带边框
|
|
56
|
+
&-bordered {
|
|
57
|
+
&.tnt-descriptions-ellipsis{
|
|
65
58
|
.@{descriptions-prefix-cls}-item-label,
|
|
66
59
|
.@{descriptions-prefix-cls}-item-content {
|
|
67
|
-
white-space: nowrap;
|
|
68
60
|
overflow: hidden;
|
|
69
61
|
text-overflow: ellipsis;
|
|
62
|
+
-webkit-box-orient: vertical;
|
|
70
63
|
}
|
|
71
|
-
|
|
72
64
|
.@{descriptions-prefix-cls}-item-label{
|
|
73
|
-
width: 180px;
|
|
65
|
+
width: 180px; // 其他语言模式默认180
|
|
66
|
+
background-color: @fill-color-quaternary; //#F8F9FB;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
&.@{descriptions-prefix-cls}-cn{
|
|
70
|
+
.@{descriptions-prefix-cls}-item-label{
|
|
71
|
+
width: 160px; // 中文160
|
|
74
72
|
}
|
|
75
73
|
}
|
|
76
74
|
.@{descriptions-prefix-cls}-view > table {
|
|
77
75
|
table-layout: fixed;
|
|
78
76
|
}
|
|
77
|
+
.@{descriptions-prefix-cls}-item-label{
|
|
78
|
+
background-color: fade(@descriptions-bg, 40%); ;
|
|
79
|
+
}
|
|
80
|
+
.@{descriptions-prefix-cls}-item-label,
|
|
81
|
+
.@{descriptions-prefix-cls}-item-content {
|
|
82
|
+
padding: @descriptions-small-padding;
|
|
83
|
+
}
|
|
79
84
|
}
|
|
80
|
-
.@{descriptions-prefix-cls}-item-label{
|
|
81
|
-
background-color: fade(@descriptions-bg, 40%); ;
|
|
82
|
-
}
|
|
83
|
-
.@{descriptions-prefix-cls}-item-label,
|
|
84
|
-
.@{descriptions-prefix-cls}-item-content {
|
|
85
|
-
padding: 10px 16px;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
85
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
height:
|
|
93
|
-
line-height:
|
|
86
|
+
// 不带边框
|
|
87
|
+
&:not(.@{descriptions-prefix-cls}-bordered ){
|
|
88
|
+
.@{descriptions-prefix-cls}-item{
|
|
89
|
+
height: 30px;
|
|
90
|
+
line-height: 30px;
|
|
94
91
|
position: relative;
|
|
95
|
-
padding-right: 12px;
|
|
96
92
|
padding:0;
|
|
97
93
|
&:not(:first-of-type){
|
|
98
94
|
padding-left: 12px;
|
|
@@ -101,29 +97,30 @@
|
|
|
101
97
|
left:0;
|
|
102
98
|
position: absolute;
|
|
103
99
|
width:1px;
|
|
104
|
-
background-color:
|
|
100
|
+
background-color: @descriptions-bg;
|
|
105
101
|
height:16px;
|
|
106
102
|
top: 50%;
|
|
107
103
|
margin-top:-8px;
|
|
108
104
|
}
|
|
109
105
|
}
|
|
110
|
-
|
|
106
|
+
.@{descriptions-prefix-cls}-item-no-label{
|
|
111
107
|
display: none;
|
|
112
108
|
}
|
|
113
|
-
|
|
109
|
+
.@{descriptions-prefix-cls}-item-content{
|
|
114
110
|
display: flex;
|
|
115
111
|
width: 100%;
|
|
116
|
-
&>.tntd-ellipsis{
|
|
112
|
+
&>.tntd-ellipsis,>.tnt-ellipsis{
|
|
117
113
|
width: 100%;
|
|
118
|
-
.
|
|
114
|
+
.tnt-descriptions-label-title{
|
|
119
115
|
max-width: 70%;
|
|
120
116
|
margin-right: 4px;
|
|
121
|
-
color
|
|
122
|
-
white-space: nowrap;
|
|
117
|
+
color: tint(@bg-color-spotilight, 50%);//#8B919E;
|
|
123
118
|
overflow: hidden;
|
|
124
119
|
text-overflow: ellipsis;
|
|
125
|
-
|
|
120
|
+
-webkit-box-orient: vertical;
|
|
121
|
+
&+.tnt-descriptions-item{
|
|
126
122
|
flex:1;
|
|
123
|
+
padding-right: 8px;
|
|
127
124
|
}
|
|
128
125
|
}
|
|
129
126
|
}
|
package/es/drawer/index.less
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
.@{drawer-prefix-cls}-wrapper-body {
|
|
22
22
|
margin-top: 48px;
|
|
23
|
-
max-height: ~'calc(100vh -
|
|
23
|
+
max-height: ~'calc(100vh - 48px)';
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
&-footer {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
.@{drawer-prefix-cls}-wrapper-body {
|
|
37
|
-
max-height: ~'calc(100vh -
|
|
37
|
+
max-height: ~'calc(100vh - 96px)' !important;
|
|
38
38
|
margin-top: 48px !important;
|
|
39
39
|
margin-bottom: 48px !important;
|
|
40
40
|
}
|
|
@@ -47,11 +47,6 @@
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
.@{drawer-prefix-cls}-close {
|
|
50
|
-
color: fade(@text-color, 50%);
|
|
51
|
-
width: 62px;
|
|
52
|
-
top: -4px;
|
|
53
|
-
|
|
54
|
-
|
|
55
50
|
position: absolute;
|
|
56
51
|
top: -2px;
|
|
57
52
|
right: 0;
|
|
@@ -133,8 +128,7 @@
|
|
|
133
128
|
}
|
|
134
129
|
|
|
135
130
|
.@{drawer-prefix-cls}-body {
|
|
136
|
-
padding:
|
|
137
|
-
|
|
131
|
+
padding: 24px !important;
|
|
138
132
|
}
|
|
139
133
|
|
|
140
134
|
|
|
@@ -145,11 +139,11 @@
|
|
|
145
139
|
right: 0;
|
|
146
140
|
bottom: 0;
|
|
147
141
|
width: 100%;
|
|
148
|
-
padding:
|
|
142
|
+
padding: 10px 24px;
|
|
149
143
|
background: #fff;
|
|
150
144
|
text-align: right;
|
|
151
145
|
.@{ant-prefix}-btn {
|
|
152
|
-
margin-left:
|
|
146
|
+
margin-left: 15px;
|
|
153
147
|
}
|
|
154
148
|
}
|
|
155
149
|
|
package/es/handle-icon/index.js
CHANGED
|
@@ -8,7 +8,9 @@ var __rest = this && this.__rest || function (s, e) {
|
|
|
8
8
|
};
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver';
|
|
11
|
+
import toArray from "rc-util/es/Children/toArray";
|
|
11
12
|
import Icon from '../icon';
|
|
13
|
+
import PopConfirm from "../popconfirm";
|
|
12
14
|
import Divider from '../divider';
|
|
13
15
|
import Dropdown from '../dropdown';
|
|
14
16
|
import Tooltip from '../tooltip';
|
|
@@ -21,17 +23,32 @@ const HandleIcon = props => {
|
|
|
21
23
|
const _a = props || {},
|
|
22
24
|
{
|
|
23
25
|
children = [],
|
|
24
|
-
num =
|
|
26
|
+
num = 5,
|
|
25
27
|
divider = false,
|
|
26
|
-
stopPropagation = true
|
|
28
|
+
stopPropagation = true,
|
|
29
|
+
size = 'large'
|
|
27
30
|
} = _a,
|
|
28
|
-
rest = __rest(_a, ["children", "num", "divider", "stopPropagation"]);
|
|
31
|
+
rest = __rest(_a, ["children", "num", "divider", "stopPropagation", "size"]);
|
|
29
32
|
let newChildren = [];
|
|
30
33
|
if (Array.isArray(children)) {
|
|
31
34
|
newChildren = (children === null || children === void 0 ? void 0 : children.filter(item => !!item)) || [];
|
|
32
35
|
} else if (children) {
|
|
33
36
|
newChildren.push(children);
|
|
34
37
|
}
|
|
38
|
+
const flattenChildren = children => {
|
|
39
|
+
if (!children) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
return toArray(children).reduce(function (flatChildren, child) {
|
|
43
|
+
if (child && child.type === React.Fragment) {
|
|
44
|
+
return flatChildren.concat(flattenChildren(child.props.children));
|
|
45
|
+
}
|
|
46
|
+
flatChildren.push(child);
|
|
47
|
+
return flatChildren;
|
|
48
|
+
}, []);
|
|
49
|
+
};
|
|
50
|
+
// 解决需要Fragment包的场景
|
|
51
|
+
newChildren = flattenChildren(newChildren);
|
|
35
52
|
let [preChildPart, lastChildPart] = [newChildren, null];
|
|
36
53
|
// 只有1个时不适配
|
|
37
54
|
if (newChildren.length - num === 1) {
|
|
@@ -52,7 +69,7 @@ const HandleIcon = props => {
|
|
|
52
69
|
type,
|
|
53
70
|
props
|
|
54
71
|
} = element;
|
|
55
|
-
if (type
|
|
72
|
+
if (type === PopConfirm) {
|
|
56
73
|
const placement = {
|
|
57
74
|
placement: 'left'
|
|
58
75
|
};
|
|
@@ -96,7 +113,7 @@ const HandleIcon = props => {
|
|
|
96
113
|
});
|
|
97
114
|
}
|
|
98
115
|
const menu = childArr => React.createElement(Menu, {
|
|
99
|
-
className:
|
|
116
|
+
className: `menu-handle-icon-more tnt-handle-icon-${size}`
|
|
100
117
|
}, childArr === null || childArr === void 0 ? void 0 : childArr.map((child, i) => React.createElement(Menu.Item, {
|
|
101
118
|
key: i
|
|
102
119
|
}, child)));
|
|
@@ -107,7 +124,7 @@ const HandleIcon = props => {
|
|
|
107
124
|
}
|
|
108
125
|
}
|
|
109
126
|
}, rest, {
|
|
110
|
-
className: `tnt-handle-icon-wrap ${(rest === null || rest === void 0 ? void 0 : rest.className) || ''}`
|
|
127
|
+
className: `tnt-handle-icon-wrap tnt-handle-icon-${size} ${(rest === null || rest === void 0 ? void 0 : rest.className) || ''}`
|
|
111
128
|
}), preChildPart, !!(lastChildPart === null || lastChildPart === void 0 ? void 0 : lastChildPart.length) && React.createElement(Dropdown, {
|
|
112
129
|
overlay: menu(lastChildPart || []),
|
|
113
130
|
arrow: true,
|
|
@@ -122,13 +139,14 @@ const HandleIcon = props => {
|
|
|
122
139
|
};
|
|
123
140
|
HandleIcon.Item = props => {
|
|
124
141
|
const {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
142
|
+
children,
|
|
143
|
+
title,
|
|
144
|
+
desc,
|
|
145
|
+
tooltip = true,
|
|
146
|
+
inMore,
|
|
147
|
+
disabled
|
|
148
|
+
} = props,
|
|
149
|
+
rest = __rest(props, ["children", "title", "desc", "tooltip", "inMore", "disabled"]);
|
|
132
150
|
const replaceIconWithText = element => {
|
|
133
151
|
if (React.isValidElement(element)) {
|
|
134
152
|
const {
|
|
@@ -144,12 +162,12 @@ HandleIcon.Item = props => {
|
|
|
144
162
|
};
|
|
145
163
|
}
|
|
146
164
|
// 如果是更多需要替换文字
|
|
147
|
-
if (type
|
|
165
|
+
if (type === Icon || type === 'img') {
|
|
148
166
|
if (inMore) {
|
|
149
167
|
return React.createElement("a", Object.assign({}, eleProps, disabledProps), title);
|
|
150
168
|
}
|
|
151
169
|
}
|
|
152
|
-
if (disabled && type
|
|
170
|
+
if (disabled && (type === Icon || ['img', 'a'].includes(type))) {
|
|
153
171
|
return React.cloneElement(element, Object.assign(Object.assign({}, (element === null || element === void 0 ? void 0 : element.props) || {}), disabledProps || {}));
|
|
154
172
|
}
|
|
155
173
|
if (eleProps && eleProps.children) {
|
|
@@ -168,9 +186,9 @@ HandleIcon.Item = props => {
|
|
|
168
186
|
newChildren = replaceIconWithText(children);
|
|
169
187
|
}
|
|
170
188
|
if ((inMore && desc || !inMore) && tooltip) {
|
|
171
|
-
return React.createElement(Tooltip, {
|
|
189
|
+
return React.createElement(Tooltip, Object.assign({
|
|
172
190
|
title: desc || title
|
|
173
|
-
}, newChildren);
|
|
191
|
+
}, rest || {}), newChildren);
|
|
174
192
|
}
|
|
175
193
|
return newChildren;
|
|
176
194
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handle-icon/index.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,cAAc,CAAA;AAErB,MAAM,UAAU,GAAI,CAAC,KAAK,EAAE,EAAE;IAC5B,OAAO,CACL,oBAAC,cAAc,IAAC,aA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eAAe,UAAU,CAAA","sourcesContent":["import React from 'react'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport Icon from '../icon'\nimport Divider from '../divider'\nimport Dropdown from '../dropdown'\nimport Tooltip from '../tooltip'\nimport Menu from '../menu'\nimport './index.less'\n\nconst HandleIcon = (props) => {\n return (\n <LocaleReceiver componentName=\"HandleIcon\">\n {() => {\n const {\n children = [],\n num = 6,\n divider = false,\n stopPropagation=true,\n ...rest\n } = props || {}\n\n \n let newChildren = []\n if (Array.isArray(children)) {\n newChildren = children?.filter((item) => !!item) || []\n } else if (children) {\n newChildren.push(children)\n }\n\n let [preChildPart, lastChildPart] = [newChildren, null];\n \n // 只有1个时不适配\n if (newChildren.length - num === 1) {\n preChildPart = newChildren\n } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {\n preChildPart = newChildren.slice(0, num)\n lastChildPart = newChildren.slice(num)\n }\n \n if (divider && preChildPart) {\n preChildPart = preChildPart?.map((dom, i) => (\n <>\n {dom}\n {!(\n (i === preChildPart?.length - 1 && !lastChildPart?.length) // 没有更多 且 是最后一个时 不显示 Divider\n ) && <Divider type=\"vertical\" />}\n </>\n ))\n }\n\n const decoratePopconfirm = (element, parentElement) => {\n if (React.isValidElement(element)) {\n const { type, props } = element;\n if (type.name === 'Popconfirm' ) {\n const placement = { placement: 'left' }\n const {disabled} = parentElement?.props||{}\n let disableProps={};\n if(disabled){\n disableProps={\n disabled,\n onConfirm:()=>{}\n };\n }\n return React.cloneElement(element, {\n overlayStyle: { width: 180 },\n ...(props || {}),\n onClick: (e) => e.stopPropagation(),\n ...placement,\n trigger: 'hover',\n getPopupContainer: (trigger) => trigger.parentNode,\n ...disableProps||{}\n })\n }\n if (props && props.children) {\n const modifiedChildren = React.Children.map(props.children, (child) => {\n return decoratePopconfirm(child,element);\n });\n return React.cloneElement(element, props, modifiedChildren);\n }\n }\n return element;\n };\n \n\n // 对更多的popConfirm\n if(lastChildPart?.length){\n lastChildPart?.forEach((v, i) => {\n v = decoratePopconfirm(v);\n lastChildPart[i] = React.cloneElement(v, {\n ...(v?.props || {}),\n inMore:true,\n })\n }) \n }\n \n const menu = (childArr)=>(\n <Menu className=\"menu-handle-icon-more\">\n {\n childArr?.map(\n (child,i) => (\n <Menu.Item key={i}>\n {child}\n </Menu.Item>\n )\n )\n }\n </Menu>\n );\n\n return (\n <div\n onClick={(e) => {\n if(stopPropagation){\n e.stopPropagation()\n }\n }}\n {...rest}\n className={`tnt-handle-icon-wrap ${rest?.className||''}`}\n >\n {preChildPart}\n {!!lastChildPart?.length && (\n <Dropdown \n overlay={menu(lastChildPart || [])} \n arrow \n onClick={(e)=>{\n stopPropagation && e.stopPropagation()\n }}\n >\n <Icon type=\"more\" className='tnt-handle-icon-more'/>\n </Dropdown>\n )}\n </div>\n )\n }}\n </LocaleReceiver>\n )\n}\n\nHandleIcon.Item = (props) => {\n const {children, title, desc, tooltip=true, inMore, disabled} = props\n const replaceIconWithText = (element) => {\n if (React.isValidElement(element)) {\n const { type, props:eleProps } = element;\n let disabledProps = {}\n if(disabled){\n disabledProps = {\n disabled,\n onClick:()=>{},\n className:(eleProps?.className || \"\")+ (disabled?' disabled':\"\")\n }\n }\n // 如果是更多需要替换文字\n if (type.name === 'Icon' || type ==='img') {\n if(inMore){\n return (\n <a \n {...eleProps}\n {...disabledProps}\n \n >{title}</a>\n );\n }\n }\n\n if(disabled && type.name==='Icon' || ['img','a'].includes(type)){\n return React.cloneElement(element, {\n ...element?.props || {} ,\n ...disabledProps||{}\n })\n }\n\n if (eleProps && eleProps.children) {\n const modifiedChildren = React.Children.map(eleProps.children, (child) => {\n return replaceIconWithText(child);\n });\n return React.cloneElement(element, eleProps, modifiedChildren);\n }\n }\n return element;\n };\n\n let newChildren = children;\n if(Array.isArray(newChildren)){\n newChildren= children?.map(child=> replaceIconWithText(child))\n }else{\n newChildren= replaceIconWithText(children)\n }\n\n if(((inMore && desc) || !inMore) && tooltip){\n return (\n <Tooltip title={desc||title}>\n {newChildren}\n </Tooltip>\n )\n }\n\n return newChildren\n \n}\nexport default HandleIcon"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handle-icon/index.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,cAAc,MAAM,wCAAwC,CAAA;AACnE,OAAO,OAAO,MAAM,6BAA6B,CAAC;AAClD,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,UAAU,MAAM,eAAe,CAAA;AACtC,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,QAAQ,MAAM,aAAa,CAAA;AAClC,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,IAAI,MAAM,SAAS,CAAA;AAC1B,OAAO,cAAc,CAAA;AAErB,MAAM,UAAU,GAAI,CAAC,KAAK,EAAE,EAAE;IAC5B,OAAO,CACL,oBAAC,cAAc,IAAC,aAAa,EAAC,YAAY,IACvC,GAAG,EAAE;QACJ,MAAM,KAOF,KAAK,IAAI,EAAE,EAPT,EACF,QAAQ,GAAG,EAAE,EACb,GAAG,GAAG,CAAC,EACP,OAAO,GAAG,KAAK,EACf,eAAe,GAAC,IAAI,EACpB,IAAI,GAAE,OAAO,OAEF,EADR,IAAI,cANL,yDAOL,CAAc,CAAA;QAGf,IAAI,WAAW,GAAG,EAAE,CAAA;QACpB,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE;YAC3B,WAAW,GAAG,CAAA,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,KAAI,EAAE,CAAA;SACvD;aAAM,IAAI,QAAQ,EAAE;YACnB,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;SAC3B;QAED,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,EAAE;YACjC,IAAI,CAAC,QAAQ,EAAE;g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B,CAAC,CAAA;AACD,eAAe,UAAU,CAAA","sourcesContent":["import React from 'react'\nimport LocaleReceiver from 'antd/es/locale-provider/LocaleReceiver'\nimport toArray from \"rc-util/es/Children/toArray\";\nimport Icon from '../icon'\nimport PopConfirm from \"../popconfirm\"\nimport Divider from '../divider'\nimport Dropdown from '../dropdown'\nimport Tooltip from '../tooltip'\nimport Menu from '../menu'\nimport './index.less'\n\nconst HandleIcon = (props) => {\n return (\n <LocaleReceiver componentName=\"HandleIcon\">\n {() => {\n const {\n children = [],\n num = 5,\n divider = false,\n stopPropagation=true,\n size= 'large',\n ...rest\n } = props || {}\n\n \n let newChildren = []\n if (Array.isArray(children)) {\n newChildren = children?.filter((item) => !!item) || []\n } else if (children) {\n newChildren.push(children)\n }\n\n const flattenChildren = (children) => {\n if (!children) {\n return [];\n }\n return toArray(children).reduce(function (flatChildren, child) {\n if (child && child.type === React.Fragment) {\n return flatChildren.concat(flattenChildren(child.props.children));\n }\n \n flatChildren.push(child);\n return flatChildren;\n }, []);\n }\n\n // 解决需要Fragment包的场景\n newChildren = flattenChildren(newChildren);\n\n let [preChildPart, lastChildPart] = [newChildren, null];\n \n // 只有1个时不适配\n if (newChildren.length - num === 1) {\n preChildPart = newChildren\n } else if (newChildren && num && !isNaN(num) && newChildren.length > num) {\n preChildPart = newChildren.slice(0, num)\n lastChildPart = newChildren.slice(num)\n }\n \n if (divider && preChildPart) {\n preChildPart = preChildPart?.map((dom, i) => (\n <>\n {dom}\n {!(\n (i === preChildPart?.length - 1 && !lastChildPart?.length) // 没有更多 且 是最后一个时 不显示 Divider\n ) && <Divider type=\"vertical\" />}\n </>\n ))\n }\n\n const decoratePopconfirm = (element, parentElement) => {\n if (React.isValidElement(element)) {\n const { type, props } = element;\n if (type === PopConfirm ) {\n const placement = { placement: 'left' }\n const {disabled} = parentElement?.props||{}\n let disableProps={};\n if(disabled){\n disableProps={\n disabled,\n onConfirm:()=>{}\n };\n }\n return React.cloneElement(element, {\n overlayStyle: { width: 180 },\n ...(props || {}),\n onClick: (e) => e.stopPropagation(),\n ...placement,\n trigger: 'hover',\n getPopupContainer: (trigger) => trigger.parentNode,\n ...disableProps||{}\n })\n }\n if (props && props.children) {\n const modifiedChildren = React.Children.map(props.children, (child) => {\n return decoratePopconfirm(child,element);\n });\n return React.cloneElement(element, props, modifiedChildren);\n }\n }\n return element;\n };\n \n\n // 对更多的popConfirm\n if(lastChildPart?.length){\n lastChildPart?.forEach((v, i) => {\n v = decoratePopconfirm(v);\n lastChildPart[i] = React.cloneElement(v, {\n ...(v?.props || {}),\n inMore:true,\n })\n }) \n }\n \n const menu = (childArr)=>(\n <Menu className={`menu-handle-icon-more tnt-handle-icon-${size}`}>\n {\n childArr?.map(\n (child,i) => (\n <Menu.Item key={i}>\n {child}\n </Menu.Item>\n )\n )\n }\n </Menu>\n );\n\n return (\n <div\n onClick={(e) => {\n if(stopPropagation){\n e.stopPropagation()\n }\n }}\n {...rest}\n className={`tnt-handle-icon-wrap tnt-handle-icon-${size} ${rest?.className||''}`}\n >\n {preChildPart}\n {!!lastChildPart?.length && (\n <Dropdown \n overlay={menu(lastChildPart || [])} \n arrow \n onClick={(e)=>{\n stopPropagation && e.stopPropagation()\n }}\n >\n <Icon type=\"more\" className='tnt-handle-icon-more'/>\n </Dropdown>\n )}\n </div>\n )\n }}\n </LocaleReceiver>\n )\n}\n\nHandleIcon.Item = (props) => {\n const {children, title, desc, tooltip=true, inMore, disabled,...rest} = props\n const replaceIconWithText = (element) => {\n if (React.isValidElement(element)) {\n const { type, props:eleProps } = element;\n let disabledProps = {}\n if(disabled){\n disabledProps = {\n disabled,\n onClick:()=>{},\n className:(eleProps?.className || \"\")+ (disabled?' disabled':\"\")\n }\n }\n // 如果是更多需要替换文字\n if (type === Icon || type ==='img') {\n if(inMore){\n return (\n <a \n {...eleProps}\n {...disabledProps}\n \n >{title}</a>\n );\n }\n }\n\n if(disabled && (type===Icon || ['img','a'].includes(type))){\n return React.cloneElement(element, {\n ...element?.props || {} ,\n ...disabledProps||{}\n })\n }\n\n if (eleProps && eleProps.children) {\n const modifiedChildren = React.Children.map(eleProps.children, (child) => {\n return replaceIconWithText(child);\n });\n return React.cloneElement(element, eleProps, modifiedChildren);\n }\n }\n return element;\n };\n\n let newChildren = children;\n if(Array.isArray(newChildren)){\n newChildren= children?.map(child=> replaceIconWithText(child))\n }else{\n newChildren= replaceIconWithText(children)\n }\n\n if(((inMore && desc) || !inMore) && tooltip){\n return (\n <Tooltip title={desc||title} {...(rest||{})}>\n {newChildren}\n </Tooltip>\n )\n }\n\n return newChildren\n \n}\nexport default HandleIcon"]}
|