@hkyhy/marsun-components-core 0.1.60 → 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.
- package/dist/components/Layout/FullscreenBox/index.d.ts +28 -0
- package/dist/components/Layout/FullscreenBox/index.js +75 -0
- package/dist/components/Layout/FullscreenBox/index.js.map +1 -0
- package/dist/components/Layout/FullscreenBox/style.module.scss.js +10 -0
- package/dist/components/Layout/FullscreenBox/style.module.scss.js.map +1 -0
- package/dist/components/Layout/FullscreenBox/useFullscreen.d.ts +6 -0
- package/dist/components/Layout/FullscreenBox/useFullscreen.js +9 -0
- package/dist/components/Layout/FullscreenBox/useFullscreen.js.map +1 -0
- package/dist/components/Layout/index.d.ts +2 -0
- package/dist/components/TooltipInfo/TooltipInfo.d.ts +6 -0
- package/dist/components/TooltipInfo/TooltipInfo.js +28 -27
- package/dist/components/TooltipInfo/TooltipInfo.js.map +1 -1
- package/dist/index.js +492 -487
- package/dist/index.js.map +1 -1
- package/dist/marsun-components-core.css +1 -1
- package/dist/styles/global.css +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
export type FullscreenBoxProps = {
|
|
3
|
+
children: ReactNode;
|
|
4
|
+
className?: string;
|
|
5
|
+
/** 全屏时附加 class(如加大 padding) */
|
|
6
|
+
fullscreenClassName?: string;
|
|
7
|
+
fullscreen: boolean;
|
|
8
|
+
onFullscreenChange?: (fullscreen: boolean) => void;
|
|
9
|
+
/** Esc 退出,默认 true */
|
|
10
|
+
exitOnEsc?: boolean;
|
|
11
|
+
/** 全屏时锁定 body 滚动,默认 true */
|
|
12
|
+
lockScroll?: boolean;
|
|
13
|
+
} & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;
|
|
14
|
+
/**
|
|
15
|
+
* CSS 铺满视口(非浏览器 Fullscreen API)。Esc 退出;z-index 1100 对齐业务浮层。
|
|
16
|
+
* 弹层(Modal / FormModal)须高于 1100(core `zIndexPopupBase` = 1200)。
|
|
17
|
+
*/
|
|
18
|
+
declare const FullscreenBox: React.FC<FullscreenBoxProps>;
|
|
19
|
+
export type FullscreenToggleProps = {
|
|
20
|
+
fullscreen: boolean;
|
|
21
|
+
onToggle: () => void;
|
|
22
|
+
className?: string;
|
|
23
|
+
/** 图标旁标题(如对比矩阵:点标题也可全屏) */
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
};
|
|
26
|
+
export declare const FullscreenToggle: React.FC<FullscreenToggleProps>;
|
|
27
|
+
export default FullscreenBox;
|
|
28
|
+
export { useFullscreen } from './useFullscreen';
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Tooltip as c, Button as y } from "antd";
|
|
3
|
+
import n from "classnames";
|
|
4
|
+
import { useEffect as v } from "react";
|
|
5
|
+
import m from "./style.module.scss.js";
|
|
6
|
+
import { Minimize2 as b } from "../../Icons/Minimize2.js";
|
|
7
|
+
import { Maximize2 as w } from "../../Icons/Maximize2.js";
|
|
8
|
+
const B = ({
|
|
9
|
+
children: t,
|
|
10
|
+
className: s,
|
|
11
|
+
fullscreenClassName: i,
|
|
12
|
+
fullscreen: e,
|
|
13
|
+
onFullscreenChange: r,
|
|
14
|
+
exitOnEsc: l = !0,
|
|
15
|
+
lockScroll: a = !0,
|
|
16
|
+
...d
|
|
17
|
+
}) => (v(() => {
|
|
18
|
+
if (!e) return;
|
|
19
|
+
const u = (p) => {
|
|
20
|
+
!l || p.key !== "Escape" || document.querySelector(".ant-modal-wrap") || r == null || r(!1);
|
|
21
|
+
}, f = document.body.style.overflow;
|
|
22
|
+
return a && (document.body.style.overflow = "hidden"), document.addEventListener("keydown", u), () => {
|
|
23
|
+
a && (document.body.style.overflow = f), document.removeEventListener("keydown", u);
|
|
24
|
+
};
|
|
25
|
+
}, [l, e, a, r]), /* @__PURE__ */ o(
|
|
26
|
+
"div",
|
|
27
|
+
{
|
|
28
|
+
...d,
|
|
29
|
+
className: n(
|
|
30
|
+
"marsun-fullscreen-box",
|
|
31
|
+
m["marsun-fullscreen-box"],
|
|
32
|
+
e && m["marsun-fullscreen-box--open"],
|
|
33
|
+
s,
|
|
34
|
+
e && i
|
|
35
|
+
),
|
|
36
|
+
"data-fullscreen": e ? "1" : void 0,
|
|
37
|
+
children: t
|
|
38
|
+
}
|
|
39
|
+
)), L = ({
|
|
40
|
+
fullscreen: t,
|
|
41
|
+
onToggle: s,
|
|
42
|
+
className: i,
|
|
43
|
+
children: e
|
|
44
|
+
}) => /* @__PURE__ */ o(c, { title: t ? "退出全屏(Esc)" : "铺满全屏", children: /* @__PURE__ */ o(
|
|
45
|
+
y,
|
|
46
|
+
{
|
|
47
|
+
type: "text",
|
|
48
|
+
size: "small",
|
|
49
|
+
htmlType: "button",
|
|
50
|
+
className: n(
|
|
51
|
+
"marsun-fullscreen-toggle",
|
|
52
|
+
m["marsun-fullscreen-toggle"],
|
|
53
|
+
i
|
|
54
|
+
),
|
|
55
|
+
icon: t ? /* @__PURE__ */ o(b, { size: 16 }) : /* @__PURE__ */ o(w, { size: 16 }),
|
|
56
|
+
"aria-label": t ? "退出全屏" : "铺满全屏",
|
|
57
|
+
"aria-pressed": t,
|
|
58
|
+
onClick: s,
|
|
59
|
+
children: e ? /* @__PURE__ */ o(
|
|
60
|
+
"span",
|
|
61
|
+
{
|
|
62
|
+
className: n(
|
|
63
|
+
"marsun-fullscreen-toggle-title",
|
|
64
|
+
m["marsun-fullscreen-toggle-title"]
|
|
65
|
+
),
|
|
66
|
+
children: e
|
|
67
|
+
}
|
|
68
|
+
) : null
|
|
69
|
+
}
|
|
70
|
+
) });
|
|
71
|
+
export {
|
|
72
|
+
L as FullscreenToggle,
|
|
73
|
+
B as default
|
|
74
|
+
};
|
|
75
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/components/Layout/FullscreenBox/index.tsx"],"sourcesContent":["import { Maximize2, Minimize2 } from '@/components/Icons';\nimport { Button, Tooltip } from 'antd';\nimport classNames from 'classnames';\nimport { useEffect, type HTMLAttributes, type ReactNode } from 'react';\nimport styles from './style.module.scss';\n\nexport type FullscreenBoxProps = {\n children: ReactNode;\n className?: string;\n /** 全屏时附加 class(如加大 padding) */\n fullscreenClassName?: string;\n fullscreen: boolean;\n onFullscreenChange?: (fullscreen: boolean) => void;\n /** Esc 退出,默认 true */\n exitOnEsc?: boolean;\n /** 全屏时锁定 body 滚动,默认 true */\n lockScroll?: boolean;\n} & Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\n/**\n * CSS 铺满视口(非浏览器 Fullscreen API)。Esc 退出;z-index 1100 对齐业务浮层。\n * 弹层(Modal / FormModal)须高于 1100(core `zIndexPopupBase` = 1200)。\n */\nconst FullscreenBox: React.FC<FullscreenBoxProps> = ({\n children,\n className,\n fullscreenClassName,\n fullscreen,\n onFullscreenChange,\n exitOnEsc = true,\n lockScroll = true,\n ...rest\n}) => {\n useEffect(() => {\n if (!fullscreen) return undefined;\n\n const onKey = (e: KeyboardEvent) => {\n if (!exitOnEsc || e.key !== 'Escape') return;\n if (document.querySelector('.ant-modal-wrap')) return;\n onFullscreenChange?.(false);\n };\n const prevOverflow = document.body.style.overflow;\n if (lockScroll) document.body.style.overflow = 'hidden';\n document.addEventListener('keydown', onKey);\n return () => {\n if (lockScroll) document.body.style.overflow = prevOverflow;\n document.removeEventListener('keydown', onKey);\n };\n }, [exitOnEsc, fullscreen, lockScroll, onFullscreenChange]);\n\n return (\n <div\n {...rest}\n className={classNames(\n 'marsun-fullscreen-box',\n styles['marsun-fullscreen-box'],\n fullscreen && styles['marsun-fullscreen-box--open'],\n className,\n fullscreen && fullscreenClassName,\n )}\n data-fullscreen={fullscreen ? '1' : undefined}\n >\n {children}\n </div>\n );\n};\n\nexport type FullscreenToggleProps = {\n fullscreen: boolean;\n onToggle: () => void;\n className?: string;\n /** 图标旁标题(如对比矩阵:点标题也可全屏) */\n children?: ReactNode;\n};\n\nexport const FullscreenToggle: React.FC<FullscreenToggleProps> = ({\n fullscreen,\n onToggle,\n className,\n children,\n}) => (\n <Tooltip title={fullscreen ? '退出全屏(Esc)' : '铺满全屏'}>\n <Button\n type=\"text\"\n size=\"small\"\n htmlType=\"button\"\n className={classNames(\n 'marsun-fullscreen-toggle',\n styles['marsun-fullscreen-toggle'],\n className,\n )}\n icon={fullscreen ? <Minimize2 size={16} /> : <Maximize2 size={16} />}\n aria-label={fullscreen ? '退出全屏' : '铺满全屏'}\n aria-pressed={fullscreen}\n onClick={onToggle}\n >\n {children ? (\n <span\n className={classNames(\n 'marsun-fullscreen-toggle-title',\n styles['marsun-fullscreen-toggle-title'],\n )}\n >\n {children}\n </span>\n ) : null}\n </Button>\n </Tooltip>\n);\n\nexport default FullscreenBox;\nexport { useFullscreen } from './useFullscreen';\n"],"names":["FullscreenBox","children","className","fullscreenClassName","fullscreen","onFullscreenChange","exitOnEsc","lockScroll","rest","useEffect","onKey","e","prevOverflow","jsx","classNames","styles","FullscreenToggle","onToggle","Tooltip","Button","Minimize2","Maximize2"],"mappings":";;;;;;;AAuBA,MAAMA,IAA8C,CAAC;AAAA,EACnD,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,YAAAC,IAAa;AAAA,EACb,GAAGC;AACL,OACEC,EAAU,MAAM;AACd,MAAI,CAACL,EAAY;AAEjB,QAAMM,IAAQ,CAACC,MAAqB;AAClC,IAAI,CAACL,KAAaK,EAAE,QAAQ,YACxB,SAAS,cAAc,iBAAiB,KAC5CN,KAAA,QAAAA,EAAqB;AAAA,EACvB,GACMO,IAAe,SAAS,KAAK,MAAM;AACzC,SAAIL,MAAY,SAAS,KAAK,MAAM,WAAW,WAC/C,SAAS,iBAAiB,WAAWG,CAAK,GACnC,MAAM;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
3
|
+
"marsun-fullscreen-box--open": "_marsun-fullscreen-box--open_14tsc_7",
|
|
4
|
+
"marsun-fullscreen-toggle": "_marsun-fullscreen-toggle_14tsc_21",
|
|
5
|
+
"marsun-fullscreen-toggle-title": "_marsun-fullscreen-toggle-title_14tsc_38"
|
|
6
|
+
};
|
|
7
|
+
export {
|
|
8
|
+
e as default
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=style.module.scss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useState as r, useCallback as s } from "react";
|
|
2
|
+
function a(t = !1) {
|
|
3
|
+
const [l, e] = r(t), n = s(() => e((o) => !o), []), c = s(() => e(!1), []);
|
|
4
|
+
return { fullscreen: l, setFullscreen: e, toggle: n, exit: c };
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
a as useFullscreen
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=useFullscreen.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFullscreen.js","sources":["../../../../src/components/Layout/FullscreenBox/useFullscreen.ts"],"sourcesContent":["import { useCallback, useState } from 'react';\n\nexport function useFullscreen(defaultFullscreen = false) {\n const [fullscreen, setFullscreen] = useState(defaultFullscreen);\n const toggle = useCallback(() => setFullscreen((v) => !v), []);\n const exit = useCallback(() => setFullscreen(false), []);\n return { fullscreen, setFullscreen, toggle, exit };\n}\n"],"names":["useFullscreen","defaultFullscreen","fullscreen","setFullscreen","useState","toggle","useCallback","v","exit"],"mappings":";AAEO,SAASA,EAAcC,IAAoB,IAAO;AACvD,QAAM,CAACC,GAAYC,CAAa,IAAIC,EAASH,CAAiB,GACxDI,IAASC,EAAY,MAAMH,EAAc,CAACI,MAAM,CAACA,CAAC,GAAG,EAAE,GACvDC,IAAOF,EAAY,MAAMH,EAAc,EAAK,GAAG,CAAA,CAAE;AACvD,SAAO,EAAE,YAAAD,GAAY,eAAAC,GAAe,QAAAE,GAAQ,MAAAG,EAAA;AAC9C;"}
|
|
@@ -10,3 +10,5 @@ export { AgentAppShell } from './AgentAppShell';
|
|
|
10
10
|
export type { AgentAppShellProps } from './AgentAppShell';
|
|
11
11
|
export { default as ContentCard } from './ContentCard';
|
|
12
12
|
export type { ContentCardProps } from './ContentCard';
|
|
13
|
+
export { default as FullscreenBox, FullscreenToggle, useFullscreen } from './FullscreenBox';
|
|
14
|
+
export type { FullscreenBoxProps, FullscreenToggleProps } from './FullscreenBox';
|
|
@@ -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;AAC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