@hkyhy/marsun-components-core 0.1.61 → 0.1.62
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.
|
@@ -18,6 +18,12 @@ export interface TooltipInfoProps extends Pick<TooltipProps, 'placement' | 'mous
|
|
|
18
18
|
children: React.ReactNode;
|
|
19
19
|
/** CommonDescriptions 列数,默认 1(仅 descriptions 形态) */
|
|
20
20
|
column?: number;
|
|
21
|
+
/**
|
|
22
|
+
* descriptions 是否带边框表格样式。
|
|
23
|
+
* 默认 false(气泡内用 dl,避免 table 在 Tooltip 里宽度塌陷);
|
|
24
|
+
* 需要 CommonDescriptions 默认「灰底标签格子」时传 true,并建议设 minWidth/maxWidth。
|
|
25
|
+
*/
|
|
26
|
+
bordered?: boolean;
|
|
21
27
|
/** 为 true 时不展示 Tooltip;descriptions 形态下 content 为空也不展示 */
|
|
22
28
|
hidden?: boolean;
|
|
23
29
|
/** 气泡最小宽度,默认 descriptions 220 / note 240 */
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
import { jsx as o, Fragment as
|
|
2
|
-
import { Tooltip as
|
|
3
|
-
import
|
|
4
|
-
const
|
|
1
|
+
import { jsx as o, Fragment as W, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as N } from "antd";
|
|
3
|
+
import j from "../Descriptions/CommonDescriptions.js";
|
|
4
|
+
const S = ({
|
|
5
5
|
type: a = "descriptions",
|
|
6
6
|
content: i,
|
|
7
7
|
note: r,
|
|
8
8
|
children: e,
|
|
9
9
|
column: l = 1,
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
bordered: p = !1,
|
|
11
|
+
hidden: d = !1,
|
|
12
|
+
minWidth: f,
|
|
13
|
+
maxWidth: m,
|
|
14
|
+
placement: c = "top",
|
|
15
|
+
overlayClassName: x,
|
|
16
|
+
overlayStyle: b,
|
|
17
|
+
mouseEnterDelay: g = 0.3,
|
|
18
|
+
...h
|
|
18
19
|
}) => {
|
|
19
|
-
const t = a === "note",
|
|
20
|
-
if (
|
|
21
|
-
return /* @__PURE__ */ o(
|
|
22
|
-
const n =
|
|
20
|
+
const t = a === "note", u = t ? !r : !i || i.length === 0;
|
|
21
|
+
if (d || u)
|
|
22
|
+
return /* @__PURE__ */ o(W, { children: e });
|
|
23
|
+
const n = f ?? (t ? 240 : 220), s = m ?? (t ? 380 : 320), v = t ? /* @__PURE__ */ y("div", { className: "tooltip-info-note", children: [
|
|
23
24
|
/* @__PURE__ */ o("div", { className: "tooltip-info-note-title", children: r.title }),
|
|
24
25
|
/* @__PURE__ */ o("div", { className: "tooltip-info-note-desc", children: r.description })
|
|
25
26
|
] }) : (
|
|
26
|
-
// bordered=false:
|
|
27
|
-
//
|
|
28
|
-
/* @__PURE__ */ o(
|
|
27
|
+
// 默认 bordered=false:dl 布局,避免 table-layout:fixed 在气泡内宽度塌陷。
|
|
28
|
+
// 显式 bordered 时用表格灰底标签(对齐页面内 CommonDescriptions 默认观感)。
|
|
29
|
+
/* @__PURE__ */ o(j, { content: i, column: l, size: "small", bordered: p })
|
|
29
30
|
);
|
|
30
31
|
return /* @__PURE__ */ o(
|
|
31
|
-
|
|
32
|
+
N,
|
|
32
33
|
{
|
|
33
|
-
placement:
|
|
34
|
-
mouseEnterDelay:
|
|
34
|
+
placement: c,
|
|
35
|
+
mouseEnterDelay: g,
|
|
35
36
|
destroyOnHidden: !0,
|
|
36
|
-
classNames: { root: ["tooltip-info-overlay",
|
|
37
|
+
classNames: { root: ["tooltip-info-overlay", x].filter(Boolean).join(" ") },
|
|
37
38
|
styles: {
|
|
38
39
|
root: {
|
|
39
40
|
// 覆盖 antd 默认 width:max-content,给气泡确定的最小宽度,避免子元素循环塌陷
|
|
@@ -49,17 +50,17 @@ const C = ({
|
|
|
49
50
|
background: "var(--tooltip-info-bg, var(--bg-color-white, #ffffff))",
|
|
50
51
|
color: "var(--tooltip-info-color, var(--font-color, #222222))",
|
|
51
52
|
boxShadow: "0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12)",
|
|
52
|
-
...
|
|
53
|
+
...b
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
56
|
getPopupContainer: () => document.body,
|
|
56
|
-
title:
|
|
57
|
-
...
|
|
57
|
+
title: v,
|
|
58
|
+
...h,
|
|
58
59
|
children: e
|
|
59
60
|
}
|
|
60
61
|
);
|
|
61
62
|
};
|
|
62
63
|
export {
|
|
63
|
-
|
|
64
|
+
S as default
|
|
64
65
|
};
|
|
65
66
|
//# sourceMappingURL=TooltipInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TooltipInfo.js","sources":["../../../src/components/TooltipInfo/TooltipInfo.tsx"],"sourcesContent":["import type { TooltipProps } from 'antd';\nimport { Tooltip } from 'antd';\nimport React from 'react';\nimport type { DescriptionItem } from '../Descriptions/CommonDescriptions';\nimport CommonDescriptions from '../Descriptions/CommonDescriptions';\nimport './style.module.scss';\n\n/** Tooltip 展示形态:descriptions=结构化详情(默认);note=标题+描述分层 */\nexport type TooltipInfoType = 'descriptions' | 'note';\n\n/** note 形态内容:标题(粗体)+ 描述(次级色) */\nexport interface TooltipInfoNote {\n title: React.ReactNode;\n description: React.ReactNode;\n}\n\nexport interface TooltipInfoProps extends Pick<\n TooltipProps,\n 'placement' | 'mouseEnterDelay' | 'mouseLeaveDelay' | 'open' | 'onOpenChange'\n> {\n /** 展示形态,默认 descriptions */\n type?: TooltipInfoType;\n /** type='descriptions' 的详情项(默认形态) */\n content?: DescriptionItem[];\n /** type='note' 的标题与描述 */\n note?: TooltipInfoNote;\n children: React.ReactNode;\n /** CommonDescriptions 列数,默认 1(仅 descriptions 形态) */\n column?: number;\n /** 为 true 时不展示 Tooltip;descriptions 形态下 content 为空也不展示 */\n hidden?: boolean;\n /** 气泡最小宽度,默认 descriptions 220 / note 240 */\n minWidth?: number;\n /** 气泡最大宽度,默认 descriptions 320 / note 380 */\n maxWidth?: number;\n /** @deprecated 使用 classNames.root */\n overlayClassName?: string;\n /** @deprecated 使用 styles.root */\n overlayStyle?: React.CSSProperties;\n}\n\n/** Tooltip 详情展示:descriptions 形态用 CommonDescriptions;note 形态用标题+描述分层 */\nconst TooltipInfo: React.FC<TooltipInfoProps> = ({\n type = 'descriptions',\n content,\n note,\n children,\n column = 1,\n hidden = false,\n minWidth,\n maxWidth,\n placement = 'top',\n overlayClassName,\n overlayStyle,\n mouseEnterDelay = 0.3,\n ...rest\n}) => {\n const isNote = type === 'note';\n const empty = isNote ? !note : !content || content.length === 0;\n if (hidden || empty) {\n return <>{children}</>;\n }\n\n const minW = minWidth ?? (isNote ? 240 : 220);\n const maxW = maxWidth ?? (isNote ? 380 : 320);\n\n const title = isNote ? (\n <div className=\"tooltip-info-note\">\n <div className=\"tooltip-info-note-title\">{note!.title}</div>\n <div className=\"tooltip-info-note-desc\">{note!.description}</div>\n </div>\n ) : (\n // bordered=false:
|
|
1
|
+
{"version":3,"file":"TooltipInfo.js","sources":["../../../src/components/TooltipInfo/TooltipInfo.tsx"],"sourcesContent":["import type { TooltipProps } from 'antd';\nimport { Tooltip } from 'antd';\nimport React from 'react';\nimport type { DescriptionItem } from '../Descriptions/CommonDescriptions';\nimport CommonDescriptions from '../Descriptions/CommonDescriptions';\nimport './style.module.scss';\n\n/** Tooltip 展示形态:descriptions=结构化详情(默认);note=标题+描述分层 */\nexport type TooltipInfoType = 'descriptions' | 'note';\n\n/** note 形态内容:标题(粗体)+ 描述(次级色) */\nexport interface TooltipInfoNote {\n title: React.ReactNode;\n description: React.ReactNode;\n}\n\nexport interface TooltipInfoProps extends Pick<\n TooltipProps,\n 'placement' | 'mouseEnterDelay' | 'mouseLeaveDelay' | 'open' | 'onOpenChange'\n> {\n /** 展示形态,默认 descriptions */\n type?: TooltipInfoType;\n /** type='descriptions' 的详情项(默认形态) */\n content?: DescriptionItem[];\n /** type='note' 的标题与描述 */\n note?: TooltipInfoNote;\n children: React.ReactNode;\n /** CommonDescriptions 列数,默认 1(仅 descriptions 形态) */\n column?: number;\n /**\n * descriptions 是否带边框表格样式。\n * 默认 false(气泡内用 dl,避免 table 在 Tooltip 里宽度塌陷);\n * 需要 CommonDescriptions 默认「灰底标签格子」时传 true,并建议设 minWidth/maxWidth。\n */\n bordered?: boolean;\n /** 为 true 时不展示 Tooltip;descriptions 形态下 content 为空也不展示 */\n hidden?: boolean;\n /** 气泡最小宽度,默认 descriptions 220 / note 240 */\n minWidth?: number;\n /** 气泡最大宽度,默认 descriptions 320 / note 380 */\n maxWidth?: number;\n /** @deprecated 使用 classNames.root */\n overlayClassName?: string;\n /** @deprecated 使用 styles.root */\n overlayStyle?: React.CSSProperties;\n}\n\n/** Tooltip 详情展示:descriptions 形态用 CommonDescriptions;note 形态用标题+描述分层 */\nconst TooltipInfo: React.FC<TooltipInfoProps> = ({\n type = 'descriptions',\n content,\n note,\n children,\n column = 1,\n bordered = false,\n hidden = false,\n minWidth,\n maxWidth,\n placement = 'top',\n overlayClassName,\n overlayStyle,\n mouseEnterDelay = 0.3,\n ...rest\n}) => {\n const isNote = type === 'note';\n const empty = isNote ? !note : !content || content.length === 0;\n if (hidden || empty) {\n return <>{children}</>;\n }\n\n const minW = minWidth ?? (isNote ? 240 : 220);\n const maxW = maxWidth ?? (isNote ? 380 : 320);\n\n const title = isNote ? (\n <div className=\"tooltip-info-note\">\n <div className=\"tooltip-info-note-title\">{note!.title}</div>\n <div className=\"tooltip-info-note-desc\">{note!.description}</div>\n </div>\n ) : (\n // 默认 bordered=false:dl 布局,避免 table-layout:fixed 在气泡内宽度塌陷。\n // 显式 bordered 时用表格灰底标签(对齐页面内 CommonDescriptions 默认观感)。\n <CommonDescriptions content={content!} column={column} size=\"small\" bordered={bordered} />\n );\n\n return (\n <Tooltip\n placement={placement}\n mouseEnterDelay={mouseEnterDelay}\n destroyOnHidden\n classNames={{ root: ['tooltip-info-overlay', overlayClassName].filter(Boolean).join(' ') }}\n styles={{\n root: {\n // 覆盖 antd 默认 width:max-content,给气泡确定的最小宽度,避免子元素循环塌陷\n width: 'auto',\n minWidth: minW,\n maxWidth: maxW,\n },\n container: {\n boxSizing: 'border-box',\n minWidth: minW,\n maxWidth: maxW,\n padding: '8px 12px',\n background: 'var(--tooltip-info-bg, var(--bg-color-white, #ffffff))',\n color: 'var(--tooltip-info-color, var(--font-color, #222222))',\n boxShadow: '0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12)',\n ...overlayStyle,\n },\n }}\n getPopupContainer={() => document.body}\n title={title}\n {...rest}\n >\n {children}\n </Tooltip>\n );\n};\n\nexport default TooltipInfo;\n"],"names":["TooltipInfo","type","content","note","children","column","bordered","hidden","minWidth","maxWidth","placement","overlayClassName","overlayStyle","mouseEnterDelay","rest","isNote","empty","minW","maxW","title","jsxs","jsx","CommonDescriptions","Tooltip"],"mappings":";;;AAgDA,MAAMA,IAA0C,CAAC;AAAA,EAC/C,MAAAC,IAAO;AAAA,EACP,SAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC;AAAA,EACA,QAAAC,IAAS;AAAA,EACT,UAAAC,IAAW;AAAA,EACX,QAAAC,IAAS;AAAA,EACT,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,kBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,iBAAAC,IAAkB;AAAA,EAClB,GAAGC;AACL,MAAM;AACJ,QAAMC,IAASd,MAAS,QAClBe,IAAQD,IAAS,CAACZ,IAAO,CAACD,KAAWA,EAAQ,WAAW;AAC9D,MAAIK,KAAUS;AACZ,kCAAU,UAAAZ,GAAS;AAGrB,QAAMa,IAAOT,MAAaO,IAAS,MAAM,MACnCG,IAAOT,MAAaM,IAAS,MAAM,MAEnCI,IAAQJ,IACZ,gBAAAK,EAAC,OAAA,EAAI,WAAU,qBACb,UA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