@hkyhy/marsun-components-core 0.1.65 → 0.1.67

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,28 @@
1
+ import { CSSProperties, ReactNode } from 'react';
2
+ export type AlertType = 'info' | 'success' | 'warning' | 'error';
3
+ export interface MarsunAlertProps {
4
+ /** 语义类型,默认 info */
5
+ type?: AlertType;
6
+ /** 主文案(必填,建议 ≤2 行) */
7
+ message: ReactNode;
8
+ /** 补充说明;含可操作链接/按钮时再加 */
9
+ description?: ReactNode;
10
+ /** 是否展示左侧图标,默认 true */
11
+ showIcon?: boolean;
12
+ /** 自定义图标,优先级高于默认语义图标 */
13
+ icon?: ReactNode;
14
+ /** 右侧操作区(如按钮) */
15
+ action?: ReactNode;
16
+ /** 是否可关闭 */
17
+ closable?: boolean;
18
+ /** 关闭回调(受控关闭时由业务处理;未受控时内部隐藏) */
19
+ onClose?: () => void;
20
+ className?: string;
21
+ style?: CSSProperties;
22
+ }
23
+ /**
24
+ * 显性提示条:语义色 + 左侧强调线 + core Icons。
25
+ * 静态说明请用 Info + TooltipInfo,勿滥用本组件作页面常驻说明。
26
+ */
27
+ declare const MarsunAlert: React.FC<MarsunAlertProps>;
28
+ export default MarsunAlert;
@@ -0,0 +1,74 @@
1
+ import { jsxs as i, jsx as r } from "react/jsx-runtime";
2
+ import e from "classnames";
3
+ import { useState as b } from "react";
4
+ import a from "./style.module.scss.js";
5
+ import { X as v } from "../Icons/X.js";
6
+ import { CircleX as z } from "../Icons/CircleX.js";
7
+ import { CircleAlert as C } from "../Icons/CircleAlert.js";
8
+ import { CircleCheck as g } from "../Icons/CircleCheck.js";
9
+ import { Info as x } from "../Icons/Info.js";
10
+ const A = {
11
+ info: /* @__PURE__ */ r(x, { size: 16, "aria-hidden": !0 }),
12
+ success: /* @__PURE__ */ r(g, { size: 16, "aria-hidden": !0 }),
13
+ warning: /* @__PURE__ */ r(C, { size: 16, "aria-hidden": !0 }),
14
+ error: /* @__PURE__ */ r(z, { size: 16, "aria-hidden": !0 })
15
+ }, F = ({
16
+ type: s = "info",
17
+ message: m,
18
+ description: l,
19
+ showIcon: u = !0,
20
+ icon: o,
21
+ action: n,
22
+ closable: c = !1,
23
+ onClose: t,
24
+ className: d,
25
+ style: f
26
+ }) => {
27
+ const [h, p] = b(!1);
28
+ if (h) return null;
29
+ const N = () => {
30
+ t == null || t(), p(!0);
31
+ };
32
+ return /* @__PURE__ */ i(
33
+ "div",
34
+ {
35
+ role: "alert",
36
+ className: e(
37
+ "marsun-alert",
38
+ a["marsun-alert"],
39
+ `marsun-alert--${s}`,
40
+ a[`marsun-alert--${s}`],
41
+ d
42
+ ),
43
+ style: f,
44
+ children: [
45
+ u ? /* @__PURE__ */ r("span", { className: e("marsun-alert-icon", a["marsun-alert-icon"]), "aria-hidden": !0, children: o ?? A[s] }) : null,
46
+ /* @__PURE__ */ i("div", { className: e("marsun-alert-body", a["marsun-alert-body"]), children: [
47
+ /* @__PURE__ */ r("div", { className: e("marsun-alert-message", a["marsun-alert-message"]), children: m }),
48
+ l != null && l !== !1 ? /* @__PURE__ */ r(
49
+ "div",
50
+ {
51
+ className: e("marsun-alert-description", a["marsun-alert-description"]),
52
+ children: l
53
+ }
54
+ ) : null
55
+ ] }),
56
+ n ? /* @__PURE__ */ r("div", { className: e("marsun-alert-action", a["marsun-alert-action"]), children: n }) : null,
57
+ c ? /* @__PURE__ */ r(
58
+ "button",
59
+ {
60
+ type: "button",
61
+ className: e("marsun-alert-close", a["marsun-alert-close"]),
62
+ "aria-label": "关闭",
63
+ onClick: N,
64
+ children: /* @__PURE__ */ r(v, { size: 14 })
65
+ }
66
+ ) : null
67
+ ]
68
+ }
69
+ );
70
+ };
71
+ export {
72
+ F as default
73
+ };
74
+ //# sourceMappingURL=Alert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Alert.js","sources":["../../../src/components/Alert/Alert.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport type { CSSProperties, ReactNode } from 'react';\nimport { useState } from 'react';\nimport { CircleAlert, CircleCheck, CircleX, Info, X } from '../Icons';\nimport styles from './style.module.scss';\n\nexport type AlertType = 'info' | 'success' | 'warning' | 'error';\n\nexport interface MarsunAlertProps {\n /** 语义类型,默认 info */\n type?: AlertType;\n /** 主文案(必填,建议 ≤2 行) */\n message: ReactNode;\n /** 补充说明;含可操作链接/按钮时再加 */\n description?: ReactNode;\n /** 是否展示左侧图标,默认 true */\n showIcon?: boolean;\n /** 自定义图标,优先级高于默认语义图标 */\n icon?: ReactNode;\n /** 右侧操作区(如按钮) */\n action?: ReactNode;\n /** 是否可关闭 */\n closable?: boolean;\n /** 关闭回调(受控关闭时由业务处理;未受控时内部隐藏) */\n onClose?: () => void;\n className?: string;\n style?: CSSProperties;\n}\n\nconst DEFAULT_ICON: Record<AlertType, ReactNode> = {\n info: <Info size={16} aria-hidden />,\n success: <CircleCheck size={16} aria-hidden />,\n warning: <CircleAlert size={16} aria-hidden />,\n error: <CircleX size={16} aria-hidden />,\n};\n\n/**\n * 显性提示条:语义色 + 左侧强调线 + core Icons。\n * 静态说明请用 Info + TooltipInfo,勿滥用本组件作页面常驻说明。\n */\nconst MarsunAlert: React.FC<MarsunAlertProps> = ({\n type = 'info',\n message,\n description,\n showIcon = true,\n icon,\n action,\n closable = false,\n onClose,\n className,\n style,\n}) => {\n const [closed, setClosed] = useState(false);\n if (closed) return null;\n\n const handleClose = () => {\n onClose?.();\n setClosed(true);\n };\n\n return (\n <div\n role=\"alert\"\n className={classNames(\n 'marsun-alert',\n styles['marsun-alert'],\n `marsun-alert--${type}`,\n styles[`marsun-alert--${type}`],\n className,\n )}\n style={style}\n >\n {showIcon ? (\n <span className={classNames('marsun-alert-icon', styles['marsun-alert-icon'])} aria-hidden>\n {icon ?? DEFAULT_ICON[type]}\n </span>\n ) : null}\n <div className={classNames('marsun-alert-body', styles['marsun-alert-body'])}>\n <div className={classNames('marsun-alert-message', styles['marsun-alert-message'])}>\n {message}\n </div>\n {description != null && description !== false ? (\n <div\n className={classNames('marsun-alert-description', styles['marsun-alert-description'])}\n >\n {description}\n </div>\n ) : null}\n </div>\n {action ? (\n <div className={classNames('marsun-alert-action', styles['marsun-alert-action'])}>\n {action}\n </div>\n ) : null}\n {closable ? (\n <button\n type=\"button\"\n className={classNames('marsun-alert-close', styles['marsun-alert-close'])}\n aria-label=\"关闭\"\n onClick={handleClose}\n >\n <X size={14} />\n </button>\n ) : null}\n </div>\n );\n};\n\nexport default MarsunAlert;\n"],"names":["DEFAULT_ICON","jsx","Info","CircleCheck","CircleAlert","CircleX","MarsunAlert","type","message","description","showIcon","icon","action","closable","onClose","className","style","closed","setClosed","useState","handleClose","jsxs","classNames","styles","X"],"mappings":";;;;;;;;;AA6BA,MAAMA,IAA6C;AAAA,EACjD,MAAM,gBAAAC,EAACC,GAAA,EAAK,MAAM,IAAI,eAAW,IAAC;AAAA,EAClC,SAAS,gBAAAD,EAACE,GAAA,EAAY,MAAM,IAAI,eAAW,IAAC;AAAA,EAC5C,SAAS,gBAAAF,EAACG,GAAA,EAAY,MAAM,IAAI,eAAW,IAAC;AAAA,EAC5C,OAAO,gBAAAH,EAACI,GAAA,EAAQ,MAAM,IAAI,eAAW,GAAA,CAAC;AACxC,GAMMC,IAA0C,CAAC;AAAA,EAC/C,MAAAC,IAAO;AAAA,EACP,SAAAC;AAAA,EACA,aAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,MAAAC;AAAA,EACA,QAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,SAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC;AACF,MAAM;AACJ,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAAS,EAAK;AAC1C,MAAIF,EAAQ,QAAO;AAEnB,QAAMG,IAAc,MAAM;AACxB,IAAAN,KAAA,QAAAA,KACAI,EAAU,EAAI;AAAA,EAChB;AAEA,SACE,gBAAAG;AAAA,IAAC;AAAA,IAAA;AAAA,MACC,MAAK;AAAA,MACL,WAAWC;AAAA,QACT;AAAA,QACAC,EAAO,cAAc;AAAA,QACrB,iBAAiBhB,CAAI;AAAA,QACrBgB,EAAO,iBAAiBhB,CAAI,EAAE;AAAA,QAC9BQ;AAAA,MAAA;AAAA,MAEF,OAAAC;AAAA,MAEC,UAAA;AAAA,QAAAN,IACC,gBAAAT,EAAC,QAAA,EAAK,WAAWqB,EAAW,qBAAqBC,EAAO,mBAAmB,CAAC,GAAG,eAAW,IACvF,UAAAZ,KAAQX,EAAaO,CAAI,GAC5B,IACE;AAAA,QACJ,gBAAAc,EAAC,SAAI,WAAWC,EAAW,qBAAqBC,EAAO,mBAAmB,CAAC,GACzE,UAAA;AAAA,UAAA,gBAAAtB,EAAC,OAAA,EAAI,WAAWqB,EAAW,wBAAwBC,EAAO,sBAAsB,CAAC,GAC9E,UAAAf,EAAA,CACH;AAAA,UACCC,KAAe,QAAQA,MAAgB,KACtC,gBAAAR;AAAA,YAAC;AAAA,YAAA;AAAA,cACC,WAAWqB,EAAW,4BAA4BC,EAAO,0BAA0B,CAAC;AAAA,cAEnF,UAAAd;AAAA,YAAA;AAAA,UAAA,IAED;AAAA,QAAA,GACN;AAAA,QACCG,IACC,gBAAAX,EAAC,OAAA,EAAI,WAAWqB,EAAW,uBAAuBC,EAAO,qBAAqB,CAAC,GAC5E,UAAAX,EAAA,CACH,IACE;AAAA,QACHC,IACC,gBAAAZ;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,MAAK;AAAA,YACL,WAAWqB,EAAW,sBAAsBC,EAAO,oBAAoB,CAAC;AAAA,YACxE,cAAW;AAAA,YACX,SAASH;AAAA,YAET,UAAA,gBAAAnB,EAACuB,GAAA,EAAE,MAAM,GAAA,CAAI;AAAA,UAAA;AAAA,QAAA,IAEb;AAAA,MAAA;AAAA,IAAA;AAAA,EAAA;AAGV;"}
@@ -0,0 +1,2 @@
1
+ export { default as Alert } from './Alert';
2
+ export type { MarsunAlertProps, AlertType } from './Alert';
@@ -0,0 +1,17 @@
1
+ const a = {
2
+ "marsun-alert": "_marsun-alert_dsoal_1",
3
+ "marsun-alert-icon": "_marsun-alert-icon_dsoal_13",
4
+ "marsun-alert-body": "_marsun-alert-body_dsoal_23",
5
+ "marsun-alert-message": "_marsun-alert-message_dsoal_29",
6
+ "marsun-alert-description": "_marsun-alert-description_dsoal_36",
7
+ "marsun-alert-action": "_marsun-alert-action_dsoal_44",
8
+ "marsun-alert-close": "_marsun-alert-close_dsoal_50",
9
+ "marsun-alert--info": "_marsun-alert--info_dsoal_70",
10
+ "marsun-alert--success": "_marsun-alert--success_dsoal_78",
11
+ "marsun-alert--warning": "_marsun-alert--warning_dsoal_86",
12
+ "marsun-alert--error": "_marsun-alert--error_dsoal_94"
13
+ };
14
+ export {
15
+ a as default
16
+ };
17
+ //# sourceMappingURL=style.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"style.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;"}
@@ -1,4 +1,5 @@
1
1
  import { ReactNode } from 'react';
2
+ import { PageShellActionItem } from '../PageShell';
2
3
  export type ModulePageShellProps = {
3
4
  title?: string;
4
5
  description?: ReactNode;
@@ -8,7 +9,7 @@ export type ModulePageShellProps = {
8
9
  spinning?: boolean;
9
10
  /** 是否同步 title/description/actions 到 PageShellProvider(App 顶栏),默认 true */
10
11
  syncPageMeta?: boolean;
11
- actions?: Record<string, unknown>[];
12
+ actions?: PageShellActionItem[];
12
13
  children?: ReactNode;
13
14
  className?: string;
14
15
  bodyClassName?: string;
@@ -27,13 +27,7 @@ const w = ({
27
27
  }, [m, r, i, n, a]), /* @__PURE__ */ h("div", { className: l("module-page-shell", o["module-page-shell"], t), children: [
28
28
  s ? /* @__PURE__ */ e("div", { className: l("module-page-breadcrumb", o["module-page-breadcrumb"]), children: s }) : null,
29
29
  d ? /* @__PURE__ */ e("div", { className: l("module-page-toolbar", o["module-page-toolbar"]), children: d }) : null,
30
- /* @__PURE__ */ e(
31
- "div",
32
- {
33
- className: l("module-page-body", o["module-page-body"], g),
34
- children: /* @__PURE__ */ e(N, { spinning: f, children: p })
35
- }
36
- )
30
+ /* @__PURE__ */ e("div", { className: l("module-page-body", o["module-page-body"], g), children: /* @__PURE__ */ e(N, { spinning: f, children: p }) })
37
31
  ] });
38
32
  };
39
33
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/Layout/ModulePageShell/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport type { ReactNode } from 'react';\nimport { useEffect } from 'react';\nimport PageSpin from '../PageSpin';\nimport { usePageShell } from '../PageShell';\nimport styles from './style.module.scss';\n\nexport type ModulePageShellProps = {\n title?: string;\n description?: ReactNode;\n breadcrumb?: ReactNode;\n toolbar?: ReactNode;\n /** 页面级 loading,与 usePageShellLoading 注册的 ctx loading 合并 */\n spinning?: boolean;\n /** 是否同步 title/description/actions 到 PageShellProvider(App 顶栏),默认 true */\n syncPageMeta?: boolean;\n actions?: Record<string, unknown>[];\n children?: ReactNode;\n className?: string;\n bodyClassName?: string;\n};\n\nconst ModulePageShell: React.FC<ModulePageShellProps> = ({\n title,\n description,\n breadcrumb,\n toolbar,\n spinning = false,\n syncPageMeta = true,\n actions,\n children,\n className,\n bodyClassName,\n}) => {\n const { setPageMeta, pageLoading: ctxLoading } = usePageShell();\n const showSpinning = Boolean(spinning || ctxLoading);\n\n useEffect(() => {\n if (!syncPageMeta) return;\n setPageMeta({\n title,\n description,\n actionItems: actions,\n });\n return () => setPageMeta({});\n }, [title, description, actions, syncPageMeta, setPageMeta]);\n\n return (\n <div className={classNames('module-page-shell', styles['module-page-shell'], className)}>\n {breadcrumb ? (\n <div className={classNames('module-page-breadcrumb', styles['module-page-breadcrumb'])}>\n {breadcrumb}\n </div>\n ) : null}\n\n {toolbar ? (\n <div className={classNames('module-page-toolbar', styles['module-page-toolbar'])}>\n {toolbar}\n </div>\n ) : null}\n\n <div\n className={classNames('module-page-body', styles['module-page-body'], bodyClassName)}\n >\n <PageSpin spinning={showSpinning}>{children}</PageSpin>\n </div>\n </div>\n );\n};\n\nexport default ModulePageShell;\n"],"names":["ModulePageShell","title","description","breadcrumb","toolbar","spinning","syncPageMeta","actions","children","className","bodyClassName","setPageMeta","ctxLoading","usePageShell","showSpinning","useEffect","jsxs","classNames","styles","jsx","PageSpin"],"mappings":";;;;;;AAsBA,MAAMA,IAAkD,CAAC;AAAA,EACvD,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA,EACf,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AACF,MAAM;AACJ,QAAM,EAAE,aAAAC,GAAa,aAAaC,EAAA,IAAeC,EAAA,GAC3CC,IAAe,GAAQT,KAAYO;AAEzC,SAAAG,EAAU,MAAM;AACd,QAAKT;AACL,aAAAK,EAAY;AAAA,QACV,OAAAV;AAAA,QACA,aAAAC;AAAA,QACA,aAAaK;AAAA,MAAA,CACd,GACM,MAAMI,EAAY,EAAE;AAAA,EAC7B,GAAG,CAACV,GAAOC,GAAaK,GAASD,GAAcK,CAAW,CAAC,GAGzD,gBAAAK,EAAC,SAAI,WAAWC,EAAW,qBAAqBC,EAAO,mBAAmB,GAAGT,CAAS,GACnF,UAAA;AAAA,IAAAN,IACC,gBAAAgB,EAAC,OAAA,EAAI,WAAWF,EAAW,0BAA0BC,EAAO,wBAAwB,CAAC,GAClF,UAAAf,EAAA,CACH,IACE;AAAA,IAEHC,IACC,gBAAAe,EAAC,OAAA,EAAI,WAAWF,EAAW,uBAAuBC,EAAO,qBAAqB,CAAC,GAC5E,UAAAd,EAAA,CACH,IACE;AAAA,IAEJ,gBAAAe;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,WAAWF,EAAW,oBAAoBC,EAAO,kBAAkB,GAAGR,CAAa;AAAA,QAEnF,UAAA,gBAAAS,EAACC,GAAA,EAAS,UAAUN,GAAe,UAAAN,EAAA,CAAS;AAAA,MAAA;AAAA,IAAA;AAAA,EAC9C,GACF;AAEJ;"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/Layout/ModulePageShell/index.tsx"],"sourcesContent":["import classNames from 'classnames';\nimport type { ReactNode } from 'react';\nimport { useEffect } from 'react';\nimport PageSpin from '../PageSpin';\nimport { usePageShell, type PageShellActionItem } from '../PageShell';\nimport styles from './style.module.scss';\n\nexport type ModulePageShellProps = {\n title?: string;\n description?: ReactNode;\n breadcrumb?: ReactNode;\n toolbar?: ReactNode;\n /** 页面级 loading,与 usePageShellLoading 注册的 ctx loading 合并 */\n spinning?: boolean;\n /** 是否同步 title/description/actions 到 PageShellProvider(App 顶栏),默认 true */\n syncPageMeta?: boolean;\n actions?: PageShellActionItem[];\n children?: ReactNode;\n className?: string;\n bodyClassName?: string;\n};\n\nconst ModulePageShell: React.FC<ModulePageShellProps> = ({\n title,\n description,\n breadcrumb,\n toolbar,\n spinning = false,\n syncPageMeta = true,\n actions,\n children,\n className,\n bodyClassName,\n}) => {\n const { setPageMeta, pageLoading: ctxLoading } = usePageShell();\n const showSpinning = Boolean(spinning || ctxLoading);\n\n useEffect(() => {\n if (!syncPageMeta) return;\n setPageMeta({\n title,\n description,\n actionItems: actions,\n });\n return () => setPageMeta({});\n }, [title, description, actions, syncPageMeta, setPageMeta]);\n\n return (\n <div className={classNames('module-page-shell', styles['module-page-shell'], className)}>\n {breadcrumb ? (\n <div className={classNames('module-page-breadcrumb', styles['module-page-breadcrumb'])}>\n {breadcrumb}\n </div>\n ) : null}\n\n {toolbar ? (\n <div className={classNames('module-page-toolbar', styles['module-page-toolbar'])}>\n {toolbar}\n </div>\n ) : null}\n\n <div className={classNames('module-page-body', styles['module-page-body'], bodyClassName)}>\n <PageSpin spinning={showSpinning}>{children}</PageSpin>\n </div>\n </div>\n );\n};\n\nexport default ModulePageShell;\n"],"names":["ModulePageShell","title","description","breadcrumb","toolbar","spinning","syncPageMeta","actions","children","className","bodyClassName","setPageMeta","ctxLoading","usePageShell","showSpinning","useEffect","jsxs","classNames","styles","jsx","PageSpin"],"mappings":";;;;;;AAsBA,MAAMA,IAAkD,CAAC;AAAA,EACvD,OAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,cAAAC,IAAe;AAAA,EACf,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AACF,MAAM;AACJ,QAAM,EAAE,aAAAC,GAAa,aAAaC,EAAA,IAAeC,EAAA,GAC3CC,IAAe,GAAQT,KAAYO;AAEzC,SAAAG,EAAU,MAAM;AACd,QAAKT;AACL,aAAAK,EAAY;AAAA,QACV,OAAAV;AAAA,QACA,aAAAC;AAAA,QACA,aAAaK;AAAA,MAAA,CACd,GACM,MAAMI,EAAY,EAAE;AAAA,EAC7B,GAAG,CAACV,GAAOC,GAAaK,GAASD,GAAcK,CAAW,CAAC,GAGzD,gBAAAK,EAAC,SAAI,WAAWC,EAAW,qBAAqBC,EAAO,mBAAmB,GAAGT,CAAS,GACnF,UAAA;AAAA,IAAAN,IACC,gBAAAgB,EAAC,OAAA,EAAI,WAAWF,EAAW,0BAA0BC,EAAO,wBAAwB,CAAC,GAClF,UAAAf,EAAA,CACH,IACE;AAAA,IAEHC,IACC,gBAAAe,EAAC,OAAA,EAAI,WAAWF,EAAW,uBAAuBC,EAAO,qBAAqB,CAAC,GAC5E,UAAAd,EAAA,CACH,IACE;AAAA,IAEJ,gBAAAe,EAAC,OAAA,EAAI,WAAWF,EAAW,oBAAoBC,EAAO,kBAAkB,GAAGR,CAAa,GACtF,UAAA,gBAAAS,EAACC,GAAA,EAAS,UAAUN,GAAe,UAAAN,GAAS,EAAA,CAC9C;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,8 +1,15 @@
1
- import { ReactNode } from 'react';
1
+ import { Key, ReactNode } from 'react';
2
+ /** ButtonGroup list 项:对象配置 或 自定义渲染函数(如 Dropdown 主按钮) */
3
+ export type PageShellActionItem = Record<string, unknown> | ((props: {
4
+ className?: string;
5
+ key?: Key;
6
+ }, ctx?: {
7
+ isDropdown?: boolean;
8
+ }) => ReactNode);
2
9
  export type PageShellMeta = {
3
10
  title?: string;
4
11
  description?: ReactNode;
5
- actionItems?: Record<string, unknown>[];
12
+ actionItems?: PageShellActionItem[];
6
13
  };
7
14
  type PageShellContextValue = {
8
15
  meta: PageShellMeta;
@@ -1,39 +1,39 @@
1
- import { jsx as f } from "react/jsx-runtime";
2
- import { useState as g, useCallback as r, useMemo as d, useContext as m, useEffect as L, createContext as M } from "react";
3
- const c = {}, l = M({
4
- meta: c,
1
+ import { jsx as d } from "react/jsx-runtime";
2
+ import { useState as c, useCallback as r, useMemo as m, useContext as L, useEffect as M, createContext as S } from "react";
3
+ const g = {}, u = S({
4
+ meta: g,
5
5
  setPageMeta: () => {
6
6
  },
7
7
  pageLoading: !1,
8
8
  setPageLoading: () => {
9
9
  }
10
10
  });
11
- function S() {
12
- return m(l);
11
+ function h() {
12
+ return L(u);
13
13
  }
14
- function p(t) {
15
- const { setPageLoading: e } = S();
16
- L(() => (e(t), () => e(!1)), [t, e]);
14
+ function p(o) {
15
+ const { setPageLoading: a } = h();
16
+ M(() => (a(o), () => a(!1)), [o, a]);
17
17
  }
18
- function C({ children: t }) {
19
- const [e, u] = g(c), [o, P] = g(!1), s = r((a) => {
20
- u(a);
21
- }, []), n = r((a) => {
22
- P(a);
23
- }, []), i = d(
18
+ function x({ children: o }) {
19
+ const [a, l] = c(g), [s, P] = c(!1), n = r((e) => {
20
+ l((t) => t.title === e.title && t.description === e.description && t.actionItems === e.actionItems ? t : e);
21
+ }, []), i = r((e) => {
22
+ P((t) => t === e ? t : e);
23
+ }, []), f = m(
24
24
  () => ({
25
- meta: e,
26
- setPageMeta: s,
27
- pageLoading: o,
28
- setPageLoading: n
25
+ meta: a,
26
+ setPageMeta: n,
27
+ pageLoading: s,
28
+ setPageLoading: i
29
29
  }),
30
- [e, s, o, n]
30
+ [a, n, s, i]
31
31
  );
32
- return /* @__PURE__ */ f(l.Provider, { value: i, children: t });
32
+ return /* @__PURE__ */ d(u.Provider, { value: f, children: o });
33
33
  }
34
34
  export {
35
- C as PageShellProvider,
36
- S as usePageShell,
35
+ x as PageShellProvider,
36
+ h as usePageShell,
37
37
  p as usePageShellLoading
38
38
  };
39
39
  //# sourceMappingURL=PageShellContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageShellContext.js","sources":["../../../../src/components/Layout/PageShell/PageShellContext.tsx"],"sourcesContent":["import type { ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\nexport type PageShellMeta = {\n title?: string;\n description?: ReactNode;\n actionItems?: Record<string, unknown>[];\n};\n\ntype PageShellContextValue = {\n meta: PageShellMeta;\n setPageMeta: (next: PageShellMeta) => void;\n pageLoading: boolean;\n setPageLoading: (loading: boolean) => void;\n};\n\nconst EMPTY_META: PageShellMeta = {};\n\nconst PageShellContext = createContext<PageShellContextValue>({\n meta: EMPTY_META,\n setPageMeta: () => {},\n pageLoading: false,\n setPageLoading: () => {},\n});\n\nexport function usePageShell() {\n return useContext(PageShellContext);\n}\n\n/** 深层子组件向 Layout body Spin 注册 loading(卸载时自动清除) */\nexport function usePageShellLoading(spinning: boolean) {\n const { setPageLoading } = usePageShell();\n useEffect(() => {\n setPageLoading(spinning);\n return () => setPageLoading(false);\n }, [spinning, setPageLoading]);\n}\n\nexport type PageShellProviderProps = {\n children: ReactNode;\n};\n\nexport function PageShellProvider({ children }: PageShellProviderProps) {\n const [meta, setMeta] = useState<PageShellMeta>(EMPTY_META);\n const [pageLoading, setPageLoadingState] = useState(false);\n\n const setPageMeta = useCallback((next: PageShellMeta) => {\n setMeta(next);\n }, []);\n\n const setPageLoading = useCallback((loading: boolean) => {\n setPageLoadingState(loading);\n }, []);\n\n const value = useMemo(\n () => ({\n meta,\n setPageMeta,\n pageLoading,\n setPageLoading,\n }),\n [meta, setPageMeta, pageLoading, setPageLoading],\n );\n\n return <PageShellContext.Provider value={value}>{children}</PageShellContext.Provider>;\n}\n"],"names":["EMPTY_META","PageShellContext","createContext","usePageShell","useContext","usePageShellLoading","spinning","setPageLoading","useEffect","PageShellProvider","children","meta","setMeta","useState","pageLoading","setPageLoadingState","setPageMeta","useCallback","next","loading","value","useMemo","jsx"],"mappings":";;AAgBA,MAAMA,IAA4B,CAAA,GAE5BC,IAAmBC,EAAqC;AAAA,EAC5D,MAAMF;AAAA,EACN,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AACzB,CAAC;AAEM,SAASG,IAAe;AAC7B,SAAOC,EAAWH,CAAgB;AACpC;AAGO,SAASI,EAAoBC,GAAmB;AACrD,QAAM,EAAE,gBAAAC,EAAA,IAAmBJ,EAAA;AAC3B,EAAAK,EAAU,OACRD,EAAeD,CAAQ,GAChB,MAAMC,EAAe,EAAK,IAChC,CAACD,GAAUC,CAAc,CAAC;AAC/B;AAMO,SAASE,EAAkB,EAAE,UAAAC,KAAoC;AACtE,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAwBb,CAAU,GACpD,CAACc,GAAaC,CAAmB,IAAIF,EAAS,EAAK,GAEnDG,IAAcC,EAAY,CAACC,MAAwB;AACvD,IAAAN,EAAQM,CAAI;AAAA,EACd,GAAG,CAAA,CAAE,GAECX,IAAiBU,EAAY,CAACE,MAAqB;AACvD,IAAAJ,EAAoBI,CAAO;AAAA,EAC7B,GAAG,CAAA,CAAE,GAECC,IAAQC;AAAA,IACZ,OAAO;AAAA,MACL,MAAAV;AAAA,MACA,aAAAK;AAAA,MACA,aAAAF;AAAA,MACA,gBAAAP;AAAA,IAAA;AAAA,IAEF,CAACI,GAAMK,GAAaF,GAAaP,CAAc;AAAA,EAAA;AAGjD,SAAO,gBAAAe,EAACrB,EAAiB,UAAjB,EAA0B,OAAAmB,GAAe,UAAAV,EAAA,CAAS;AAC5D;"}
1
+ {"version":3,"file":"PageShellContext.js","sources":["../../../../src/components/Layout/PageShell/PageShellContext.tsx"],"sourcesContent":["import type { Key, ReactNode } from 'react';\nimport { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react';\n\n/** ButtonGroup list 项:对象配置 或 自定义渲染函数(如 Dropdown 主按钮) */\nexport type PageShellActionItem =\n | Record<string, unknown>\n | ((props: { className?: string; key?: Key }, ctx?: { isDropdown?: boolean }) => ReactNode);\n\nexport type PageShellMeta = {\n title?: string;\n description?: ReactNode;\n actionItems?: PageShellActionItem[];\n};\n\ntype PageShellContextValue = {\n meta: PageShellMeta;\n setPageMeta: (next: PageShellMeta) => void;\n pageLoading: boolean;\n setPageLoading: (loading: boolean) => void;\n};\n\nconst EMPTY_META: PageShellMeta = {};\n\nconst PageShellContext = createContext<PageShellContextValue>({\n meta: EMPTY_META,\n setPageMeta: () => {},\n pageLoading: false,\n setPageLoading: () => {},\n});\n\nexport function usePageShell() {\n return useContext(PageShellContext);\n}\n\n/** 深层子组件向 Layout body Spin 注册 loading(卸载时自动清除) */\nexport function usePageShellLoading(spinning: boolean) {\n const { setPageLoading } = usePageShell();\n useEffect(() => {\n setPageLoading(spinning);\n return () => setPageLoading(false);\n }, [spinning, setPageLoading]);\n}\n\nexport type PageShellProviderProps = {\n children: ReactNode;\n};\n\nexport function PageShellProvider({ children }: PageShellProviderProps) {\n const [meta, setMeta] = useState<PageShellMeta>(EMPTY_META);\n const [pageLoading, setPageLoadingState] = useState(false);\n\n const setPageMeta = useCallback((next: PageShellMeta) => {\n setMeta((prev) => {\n if (\n prev.title === next.title &&\n prev.description === next.description &&\n prev.actionItems === next.actionItems\n ) {\n return prev;\n }\n return next;\n });\n }, []);\n\n const setPageLoading = useCallback((loading: boolean) => {\n setPageLoadingState((prev) => (prev === loading ? prev : loading));\n }, []);\n\n const value = useMemo(\n () => ({\n meta,\n setPageMeta,\n pageLoading,\n setPageLoading,\n }),\n [meta, setPageMeta, pageLoading, setPageLoading],\n );\n\n return <PageShellContext.Provider value={value}>{children}</PageShellContext.Provider>;\n}\n"],"names":["EMPTY_META","PageShellContext","createContext","usePageShell","useContext","usePageShellLoading","spinning","setPageLoading","useEffect","PageShellProvider","children","meta","setMeta","useState","pageLoading","setPageLoadingState","setPageMeta","useCallback","next","prev","loading","value","useMemo","jsx"],"mappings":";;AAqBA,MAAMA,IAA4B,CAAA,GAE5BC,IAAmBC,EAAqC;AAAA,EAC5D,MAAMF;AAAA,EACN,aAAa,MAAM;AAAA,EAAC;AAAA,EACpB,aAAa;AAAA,EACb,gBAAgB,MAAM;AAAA,EAAC;AACzB,CAAC;AAEM,SAASG,IAAe;AAC7B,SAAOC,EAAWH,CAAgB;AACpC;AAGO,SAASI,EAAoBC,GAAmB;AACrD,QAAM,EAAE,gBAAAC,EAAA,IAAmBJ,EAAA;AAC3B,EAAAK,EAAU,OACRD,EAAeD,CAAQ,GAChB,MAAMC,EAAe,EAAK,IAChC,CAACD,GAAUC,CAAc,CAAC;AAC/B;AAMO,SAASE,EAAkB,EAAE,UAAAC,KAAoC;AACtE,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAwBb,CAAU,GACpD,CAACc,GAAaC,CAAmB,IAAIF,EAAS,EAAK,GAEnDG,IAAcC,EAAY,CAACC,MAAwB;AACvD,IAAAN,EAAQ,CAACO,MAELA,EAAK,UAAUD,EAAK,SACpBC,EAAK,gBAAgBD,EAAK,eAC1BC,EAAK,gBAAgBD,EAAK,cAEnBC,IAEFD,CACR;AAAA,EACH,GAAG,CAAA,CAAE,GAECX,IAAiBU,EAAY,CAACG,MAAqB;AACvD,IAAAL,EAAoB,CAACI,MAAUA,MAASC,IAAUD,IAAOC,CAAQ;AAAA,EACnE,GAAG,CAAA,CAAE,GAECC,IAAQC;AAAA,IACZ,OAAO;AAAA,MACL,MAAAX;AAAA,MACA,aAAAK;AAAA,MACA,aAAAF;AAAA,MACA,gBAAAP;AAAA,IAAA;AAAA,IAEF,CAACI,GAAMK,GAAaF,GAAaP,CAAc;AAAA,EAAA;AAGjD,SAAO,gBAAAgB,EAACtB,EAAiB,UAAjB,EAA0B,OAAAoB,GAAe,UAAAX,EAAA,CAAS;AAC5D;"}
@@ -1,2 +1,2 @@
1
- export { PageShellProvider, usePageShell, usePageShellLoading, } from './PageShellContext';
2
- export type { PageShellMeta, PageShellProviderProps } from './PageShellContext';
1
+ export { PageShellProvider, usePageShell, usePageShellLoading } from './PageShellContext';
2
+ export type { PageShellMeta, PageShellProviderProps, PageShellActionItem, } from './PageShellContext';
@@ -3,7 +3,7 @@ export type { PageHeaderLayoutProps } from './PageHeaderLayout';
3
3
  export { default as PageSpin } from './PageSpin';
4
4
  export type { PageSpinProps } from './PageSpin';
5
5
  export { PageShellProvider, usePageShell, usePageShellLoading } from './PageShell';
6
- export type { PageShellMeta, PageShellProviderProps } from './PageShell';
6
+ export type { PageShellMeta, PageShellProviderProps, PageShellActionItem } from './PageShell';
7
7
  export { default as ModulePageShell } from './ModulePageShell';
8
8
  export type { ModulePageShellProps } from './ModulePageShell';
9
9
  export { AgentAppShell } from './AgentAppShell';
@@ -13,6 +13,13 @@ export type OrgTreeProps = {
13
13
  /** 展示节点内增删改操作 */
14
14
  editable?: boolean;
15
15
  className?: string;
16
+ /**
17
+ * 初始展开深度:0=全部折叠;1=展开根(露出一级子,默认);
18
+ * 传很大的数或 Infinity ≈ 全展开(仅小树建议)。
19
+ */
20
+ defaultExpandDepth?: number;
21
+ /** 虚拟列表可视高度(px);节点多时默认开启 */
22
+ virtualHeight?: number | false;
16
23
  /** 受控选中(点选节点,如右侧岗位面板) */
17
24
  selectedKeys?: Key[];
18
25
  onSelect?: (node: {
@@ -38,8 +45,8 @@ export type OrgTreeProps = {
38
45
  deleteOkType?: 'primary' | 'danger';
39
46
  };
40
47
  /**
41
- * 组织树(对齐 Assets 组织架构行为):默认展开、节点 hover 增删改。
42
- * 纯 UI,无业务 API。
48
+ * 组织树(对齐 Assets 组织架构行为):可配置展开深度、节点 hover 增删改。
49
+ * 纯 UI,无业务 API。大树勿默认全展开(会卡死 DOM)。
43
50
  */
44
51
  declare const OrgTree: React.FC<OrgTreeProps>;
45
52
  export default OrgTree;