@vavt/react-ui 1.2.1 → 1.2.3

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.
Files changed (102) hide show
  1. package/dist/{Cron-DIB4GG4y.js → Cron-C3yEuafY.js} +3 -3
  2. package/dist/{Cron-MhbYMEeJ.cjs → Cron-DyBHGiUj.cjs} +1 -1
  3. package/dist/{DatePicker-Bj709smn.cjs → DatePicker-3DRaRPjg.cjs} +1 -1
  4. package/dist/{DatePicker--13tW0cw.js → DatePicker-IFns1yBl.js} +1 -1
  5. package/dist/{DateTimePicker-ZSScsk-j.cjs → DateTimePicker-Bml1FgyN.cjs} +1 -1
  6. package/dist/{DateTimePicker-Blqs2Bcv.js → DateTimePicker-DnXBZTg0.js} +1 -1
  7. package/dist/{Drawer-yM_r1M0H.js → Drawer-B4vSd2iq.js} +5 -4
  8. package/dist/Drawer-NyC3NpBR.cjs +1 -0
  9. package/dist/{Dropdown-mYCY-LcF.js → Dropdown-CI_C-qdP.js} +3 -3
  10. package/dist/{Dropdown-PHqXNiAZ.cjs → Dropdown-DPY4QNdT.cjs} +1 -1
  11. package/dist/{Form-BkyDHPEI.cjs → Form-BMXJJ8bX.cjs} +1 -1
  12. package/dist/{Form-D_Uv-8HG.js → Form-BvCSJ23z.js} +1 -1
  13. package/dist/MessageBox-70-7jPWP.cjs +1 -0
  14. package/dist/MessageBox-BeEgyiwR.js +166 -0
  15. package/dist/Modal-BYKseLTT.cjs +1 -0
  16. package/dist/{Modal-Du7aVdWl.js → Modal-DWKzYEN8.js} +7 -6
  17. package/dist/Notification-CJraaZIi.js +197 -0
  18. package/dist/Notification-D6m4qHKz.cjs +1 -0
  19. package/dist/{Pagination-DatEegaF.cjs → Pagination-Bi6z9CZE.cjs} +1 -1
  20. package/dist/{Pagination-CpbboRbF.js → Pagination-CXJBTKHs.js} +1 -1
  21. package/dist/{Select-BHWa_6Q2.js → Select-DaIhlOMK.js} +3 -3
  22. package/dist/{Select-C6O0tmM_.cjs → Select-YUrncvbr.cjs} +1 -1
  23. package/dist/{Table-Cfs3XJgN.js → Table-8KkwnZom.js} +1 -1
  24. package/dist/{Table-BNGO_7Rx.cjs → Table-DVb-ByCJ.cjs} +1 -1
  25. package/dist/{TimePicker-DoGbwfkU.cjs → TimePicker-CZAlhs_F.cjs} +1 -1
  26. package/dist/{TimePicker-CYlcUTTM.js → TimePicker-TtKzEbBJ.js} +3 -3
  27. package/dist/{Tooltip-BKPreZML.js → Tooltip-BtUDTfMB.js} +3 -3
  28. package/dist/{Tooltip-DDjGLjoV.cjs → Tooltip-C4CuAEie.cjs} +1 -1
  29. package/dist/cjs/Cron.cjs +1 -1
  30. package/dist/cjs/DatePicker.cjs +1 -1
  31. package/dist/cjs/DateTimePicker.cjs +1 -1
  32. package/dist/cjs/Drawer.cjs +1 -1
  33. package/dist/cjs/Dropdown.cjs +1 -1
  34. package/dist/cjs/Form.cjs +1 -1
  35. package/dist/cjs/MessageBox.cjs +1 -1
  36. package/dist/cjs/Modal.cjs +1 -1
  37. package/dist/cjs/Notification.cjs +1 -0
  38. package/dist/cjs/Pagination.cjs +1 -1
  39. package/dist/cjs/Select.cjs +1 -1
  40. package/dist/cjs/Table.cjs +1 -1
  41. package/dist/cjs/TimePicker.cjs +1 -1
  42. package/dist/cjs/Tooltip.cjs +1 -1
  43. package/dist/cjs/global.cjs +1 -1
  44. package/dist/cjs/index.cjs +1 -1
  45. package/dist/cjs/register.cjs +1 -1
  46. package/dist/css/Modal.css +1 -1
  47. package/dist/css/Notification.css +1 -0
  48. package/dist/{date-picker-Be_1wA3S.cjs → date-picker-Yq0xV3y8.cjs} +1 -1
  49. package/dist/{date-picker-CHP0eBuL.js → date-picker-tq5q60JP.js} +4 -4
  50. package/dist/dialog-shell-B7mE8A1p.cjs +1 -0
  51. package/dist/dialog-shell-FS5nSlBm.js +118 -0
  52. package/dist/es/Cron.mjs +1 -1
  53. package/dist/es/DatePicker.mjs +1 -1
  54. package/dist/es/DateTimePicker.mjs +1 -1
  55. package/dist/es/Drawer.mjs +1 -1
  56. package/dist/es/Dropdown.mjs +1 -1
  57. package/dist/es/Form.mjs +1 -1
  58. package/dist/es/MessageBox.mjs +1 -1
  59. package/dist/es/Modal.mjs +1 -1
  60. package/dist/es/Notification.mjs +3 -0
  61. package/dist/es/Pagination.mjs +1 -1
  62. package/dist/es/Select.mjs +1 -1
  63. package/dist/es/Table.mjs +1 -1
  64. package/dist/es/TimePicker.mjs +1 -1
  65. package/dist/es/Tooltip.mjs +1 -1
  66. package/dist/es/global.mjs +1 -1
  67. package/dist/es/index.mjs +27 -26
  68. package/dist/es/register.mjs +1 -1
  69. package/dist/index.css +1 -1
  70. package/dist/{layer-DDm97-sb.js → layer-C1yCY0MO.js} +1 -1
  71. package/dist/{layer-BgiUZy_t.cjs → layer-DL1xVbJT.cjs} +1 -1
  72. package/dist/registry-BmoI_ib1.js +85 -0
  73. package/dist/registry-DtJjJt6v.cjs +1 -0
  74. package/dist/style/Notification.cjs +8 -0
  75. package/dist/style/Notification.mjs +8 -0
  76. package/dist/types/Notification/Notification.d.cts +4 -0
  77. package/dist/types/Notification/Notification.d.ts +4 -0
  78. package/dist/types/Notification/host.d.cts +9 -0
  79. package/dist/types/Notification/host.d.ts +9 -0
  80. package/dist/types/Notification/index.d.cts +5 -0
  81. package/dist/types/Notification/index.d.ts +5 -0
  82. package/dist/types/Notification/service.d.cts +5 -0
  83. package/dist/types/Notification/service.d.ts +5 -0
  84. package/dist/types/Notification/type.d.cts +55 -0
  85. package/dist/types/Notification/type.d.ts +55 -0
  86. package/dist/types/_shared/dialog.d.cts +5 -1
  87. package/dist/types/_shared/dialog.d.ts +5 -1
  88. package/dist/types/global.d.cts +2 -0
  89. package/dist/types/global.d.ts +2 -0
  90. package/dist/types/index.d.cts +1 -0
  91. package/dist/types/index.d.ts +1 -0
  92. package/dist/types/registry.d.cts +1 -0
  93. package/dist/types/registry.d.ts +1 -0
  94. package/package.json +1 -1
  95. package/dist/Drawer-DcbgMkub.cjs +0 -1
  96. package/dist/MessageBox-D7Ib1f7K.cjs +0 -1
  97. package/dist/MessageBox-DDP6UWFU.js +0 -141
  98. package/dist/Modal-DPxZEr2v.cjs +0 -1
  99. package/dist/dialog-shell-CdYlPT9f.js +0 -111
  100. package/dist/dialog-shell-CzeGytVj.cjs +0 -1
  101. package/dist/registry-BqfLh5B_.cjs +0 -1
  102. package/dist/registry-C8ZL-n-l.js +0 -83
@@ -50,4 +50,4 @@ var i = e(null), a = {
50
50
  children: t
51
51
  });
52
52
  //#endregion
53
- export { a as n, u as r, d as t };
53
+ export { u as a, c as i, o as n, a as r, d as t };
@@ -1 +1 @@
1
- let e=require("react"),t=require("react/jsx-runtime");var n=(0,e.createContext)(null),r={dropdown:`var(--vl-z-dropdown)`,popover:`var(--vl-z-popover)`,tooltip:`var(--vl-z-tooltip)`,modal:`var(--vl-z-modal)`},i={[r.dropdown]:1e3,[r.popover]:1100,[r.tooltip]:1e3,[r.modal]:1200},a=e=>typeof e==`string`?i[e]:void 0,o=({base:e,offset:t})=>t===0?e:typeof e==`number`?e+t:`calc(${e} ${t>0?`+`:`-`} ${Math.abs(t)})`,s=(e,t)=>o({...e,offset:e.offset+t}),c=({defaultZIndex:t,zIndex:r,withMask:i=!1})=>{let c=(0,e.useContext)(n),l=(0,e.useMemo)(()=>{if(r!==void 0)return{base:r,offset:0};let e=a(t);if(c){let t=i?2:1,n=c.offset+t,r=c.rank;if(!(e!==void 0&&r!==void 0&&e>r+n))return{base:c.base,offset:n,rank:r}}return{base:t,offset:0,rank:e}},[t,c,i,r]),u=r===void 0&&l.offset===0&&l.base===t?void 0:o(l);return{layer:l,zIndex:u,maskZIndex:u===void 0?void 0:s(l,-1)}},l=({layer:e,children:r})=>(0,t.jsx)(n.Provider,{value:e,children:r});Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
1
+ let e=require("react"),t=require("react/jsx-runtime");var n=(0,e.createContext)(null),r={dropdown:`var(--vl-z-dropdown)`,popover:`var(--vl-z-popover)`,tooltip:`var(--vl-z-tooltip)`,modal:`var(--vl-z-modal)`},i={[r.dropdown]:1e3,[r.popover]:1100,[r.tooltip]:1e3,[r.modal]:1200},a=e=>typeof e==`string`?i[e]:void 0,o=({base:e,offset:t})=>t===0?e:typeof e==`number`?e+t:`calc(${e} ${t>0?`+`:`-`} ${Math.abs(t)})`,s=(e,t)=>o({...e,offset:e.offset+t}),c=({defaultZIndex:t,zIndex:r,withMask:i=!1})=>{let c=(0,e.useContext)(n),l=(0,e.useMemo)(()=>{if(r!==void 0)return{base:r,offset:0};let e=a(t);if(c){let t=i?2:1,n=c.offset+t,r=c.rank;if(!(e!==void 0&&r!==void 0&&e>r+n))return{base:c.base,offset:n,rank:r}}return{base:t,offset:0,rank:e}},[t,c,i,r]),u=r===void 0&&l.offset===0&&l.base===t?void 0:o(l);return{layer:l,zIndex:u,maskZIndex:u===void 0?void 0:s(l,-1)}},l=({layer:e,children:r})=>(0,t.jsx)(n.Provider,{value:e,children:r});Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
@@ -0,0 +1,85 @@
1
+ import { n as e } from "./Alert-BGyLKuv0.js";
2
+ import { n as t } from "./Anchor-CAZPkv56.js";
3
+ import { n } from "./Announcement-DzzaTvcO.js";
4
+ import { n as r } from "./Button-CwkWSWau.js";
5
+ import { n as i } from "./Card-DCLfLn1x.js";
6
+ import { n as a } from "./Checkbox-bHOjYdMp.js";
7
+ import { n as o } from "./Col-CZjR94ac.js";
8
+ import { n as s } from "./Transition-DiO4GsP3.js";
9
+ import { n as c } from "./Input-BRy5Xuwy.js";
10
+ import { n as l } from "./Tabs-HWLkyrQR.js";
11
+ import { n as u } from "./NumberInput-CB-nKZgs.js";
12
+ import { n as d } from "./Cron-C3yEuafY.js";
13
+ import { n as f } from "./Dropdown-CI_C-qdP.js";
14
+ import { n as p } from "./DatePicker-IFns1yBl.js";
15
+ import { n as m } from "./DateTimePicker-DnXBZTg0.js";
16
+ import { n as h } from "./Divider-BXNZyvHY.js";
17
+ import { n as g } from "./Drawer-B4vSd2iq.js";
18
+ import { n as _ } from "./Empty-MmxZitR8.js";
19
+ import { t as v } from "./Form-BvCSJ23z.js";
20
+ import { n as y } from "./Tooltip-BtUDTfMB.js";
21
+ import { n as b } from "./Loading-CL0wUgYK.js";
22
+ import { n as x } from "./Scrollbar-BdMGZrYi.js";
23
+ import { n as S } from "./Modal-DWKzYEN8.js";
24
+ import { t as C } from "./MessageBox-BeEgyiwR.js";
25
+ import { t as w } from "./Notification-CJraaZIi.js";
26
+ import { n as T } from "./Select-DaIhlOMK.js";
27
+ import { n as E } from "./Pagination-CXJBTKHs.js";
28
+ import { n as D } from "./Progress-D2C6LCml.js";
29
+ import { VlRadio as O } from "./es/Radio.mjs";
30
+ import { VlRow as k } from "./es/Row.mjs";
31
+ import { n as A } from "./Sidebar-u980T-QB.js";
32
+ import { n as j } from "./Slider-CKU03SsT.js";
33
+ import { n as M } from "./Space-gnVH7rEt.js";
34
+ import { n as N } from "./Switch-CqTFvp-k.js";
35
+ import { n as P } from "./Table-8KkwnZom.js";
36
+ import { n as F } from "./Tag-TeYTDdHt.js";
37
+ import { n as I } from "./Textarea-CA6Vzu7t.js";
38
+ import { n as L } from "./Timeline-euWvUS4e.js";
39
+ import { n as R } from "./TimePicker-TtKzEbBJ.js";
40
+ import { n as z } from "./Upload-DZ6VaM7r.js";
41
+ //#region components/registry.ts
42
+ var B = {
43
+ VlAlert: e,
44
+ VlAnchor: t,
45
+ VlAnnouncement: n,
46
+ VlButton: r,
47
+ VlCard: i,
48
+ VlCheckbox: a,
49
+ VlCol: o,
50
+ VlCron: d,
51
+ VlDatePicker: p,
52
+ VlDateTimePicker: m,
53
+ VlDivider: h,
54
+ VlDrawer: g,
55
+ VlDropdown: f,
56
+ VlEmpty: _,
57
+ VlForm: v,
58
+ VlInput: c,
59
+ VlLoading: b,
60
+ VlMessageBox: C,
61
+ VlModal: S,
62
+ VlNotification: w,
63
+ VlNumberInput: u,
64
+ VlPagination: E,
65
+ VlProgress: D,
66
+ VlRadio: O,
67
+ VlRow: k,
68
+ VlScrollbar: x,
69
+ VlSelect: T,
70
+ VlSidebar: A,
71
+ VlSlider: j,
72
+ VlSpace: M,
73
+ VlSwitch: N,
74
+ VlTable: P,
75
+ VlTabs: l,
76
+ VlTag: F,
77
+ VlTextarea: I,
78
+ VlTimeline: L,
79
+ VlTimePicker: R,
80
+ VlTooltip: y,
81
+ VlTransition: s,
82
+ VlUpload: z
83
+ }, V = (e = globalThis) => (Object.assign(e, B), B);
84
+ //#endregion
85
+ export { V as n, B as t };
@@ -0,0 +1 @@
1
+ const e=require("./Alert-tPSJmCXK.cjs"),t=require("./Anchor-CmuV1Ump.cjs"),n=require("./Announcement-D0hZE2sM.cjs"),r=require("./Button-qURrKHQ0.cjs"),i=require("./Card-BkZhLXQ5.cjs"),a=require("./Checkbox-CzNGP2tH.cjs"),o=require("./Col-qcq7T83y.cjs"),s=require("./Transition-X_89ga-e.cjs"),c=require("./Input-C9ESmbJ7.cjs"),l=require("./Tabs-BZ0Zc0bL.cjs"),u=require("./NumberInput-Dp1vTDkW.cjs"),d=require("./Cron-DyBHGiUj.cjs"),f=require("./Dropdown-DPY4QNdT.cjs"),p=require("./DatePicker-3DRaRPjg.cjs"),m=require("./DateTimePicker-Bml1FgyN.cjs"),h=require("./Divider-BnmUNmy2.cjs"),g=require("./Drawer-NyC3NpBR.cjs"),_=require("./Empty-Dny96c3p.cjs"),v=require("./Form-BMXJJ8bX.cjs"),y=require("./Tooltip-C4CuAEie.cjs"),b=require("./Loading-C2pY-4fA.cjs"),x=require("./Scrollbar-CEQT6Ao_.cjs"),S=require("./Modal-BYKseLTT.cjs"),C=require("./MessageBox-70-7jPWP.cjs"),w=require("./Notification-D6m4qHKz.cjs"),T=require("./Select-YUrncvbr.cjs"),E=require("./Pagination-Bi6z9CZE.cjs"),D=require("./Progress-DTAjlgwZ.cjs"),O=require("./cjs/Radio.cjs"),k=require("./cjs/Row.cjs"),A=require("./Sidebar-BPXVnP7y.cjs"),j=require("./Slider-CU9OS2HB.cjs"),M=require("./Space-DJGRG2rt.cjs"),N=require("./Switch-CpXDMcPW.cjs"),P=require("./Table-DVb-ByCJ.cjs"),F=require("./Tag-4iZGcfrg.cjs"),I=require("./Textarea-CEhAvE10.cjs"),L=require("./Timeline-ROggEQnD.cjs"),R=require("./TimePicker-CZAlhs_F.cjs"),z=require("./Upload-wHEEoe1c.cjs");var B={VlAlert:e.n,VlAnchor:t.n,VlAnnouncement:n.n,VlButton:r.n,VlCard:i.n,VlCheckbox:a.n,VlCol:o.n,VlCron:d.n,VlDatePicker:p.n,VlDateTimePicker:m.n,VlDivider:h.n,VlDrawer:g.n,VlDropdown:f.n,VlEmpty:_.n,VlForm:v.t,VlInput:c.n,VlLoading:b.n,VlMessageBox:C.t,VlModal:S.n,VlNotification:w.t,VlNumberInput:u.n,VlPagination:E.n,VlProgress:D.n,VlRadio:O.VlRadio,VlRow:k.VlRow,VlScrollbar:x.n,VlSelect:T.n,VlSidebar:A.n,VlSlider:j.n,VlSpace:M.n,VlSwitch:N.n,VlTable:P.n,VlTabs:l.n,VlTag:F.n,VlTextarea:I.n,VlTimeline:L.n,VlTimePicker:R.n,VlTooltip:y.n,VlTransition:s.n,VlUpload:z.n},V=(e=globalThis)=>(Object.assign(e,B),B);Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return V}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return B}});
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 此文件由 scripts/generate-style-entries.ts 依据组件 import 图自动生成,请勿手工修改。
3
+ *
4
+ * 纯副作用模块:依赖的样式入口在前、自身 CSS 在后,共享模块由打包器按模块 id 去重。
5
+ */
6
+ require("../base.css");
7
+ require("./Transition.cjs");
8
+ require("../css/Notification.css");
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 此文件由 scripts/generate-style-entries.ts 依据组件 import 图自动生成,请勿手工修改。
3
+ *
4
+ * 纯副作用模块:依赖的样式入口在前、自身 CSS 在后,共享模块由打包器按模块 id 去重。
5
+ */
6
+ import "../base.css";
7
+ import "./Transition.mjs";
8
+ import "../css/Notification.css";
@@ -0,0 +1,4 @@
1
+ import type { NotificationProps } from './type.cjs';
2
+ /** 非阻断通知:不夺取焦点、不锁定页面滚动,离场期间继续占据堆叠位置。 */
3
+ declare const Notification: import("react").ForwardRefExoticComponent<NotificationProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default Notification;
@@ -0,0 +1,4 @@
1
+ import type { NotificationProps } from './type.js';
2
+ /** 非阻断通知:不夺取焦点、不锁定页面滚动,离场期间继续占据堆叠位置。 */
3
+ declare const Notification: import("react").ForwardRefExoticComponent<NotificationProps & import("react").RefAttributes<HTMLDivElement>>;
4
+ export default Notification;
@@ -0,0 +1,9 @@
1
+ import type { NotificationPlacement } from './type.cjs';
2
+ /**
3
+ * 声明式与命令式实例共享同一布局容器,CSS flex 负责不同高度内容的堆叠。
4
+ * 仅在客户端 effect 中申请;引用计数兼容 StrictMode 重挂载,最后一个使用者离开时释放 DOM。
5
+ */
6
+ export declare const acquireNotificationHost: (placement: NotificationPlacement) => {
7
+ element: HTMLDivElement;
8
+ release: () => void;
9
+ };
@@ -0,0 +1,9 @@
1
+ import type { NotificationPlacement } from './type.js';
2
+ /**
3
+ * 声明式与命令式实例共享同一布局容器,CSS flex 负责不同高度内容的堆叠。
4
+ * 仅在客户端 effect 中申请;引用计数兼容 StrictMode 重挂载,最后一个使用者离开时释放 DOM。
5
+ */
6
+ export declare const acquireNotificationHost: (placement: NotificationPlacement) => {
7
+ element: HTMLDivElement;
8
+ release: () => void;
9
+ };
@@ -0,0 +1,5 @@
1
+ import type { NotificationComponent } from './type.cjs';
2
+ /** 通知组件,同时提供 open、四种语义快捷方法和 closeAll。 */
3
+ export declare const VlNotification: NotificationComponent;
4
+ export type { NotificationProps, NotificationOptions, NotificationStatus, NotificationPlacement, NotificationRef, NotificationHandle, NotificationComponent } from './type.cjs';
5
+ export default VlNotification;
@@ -0,0 +1,5 @@
1
+ import type { NotificationComponent } from './type.js';
2
+ /** 通知组件,同时提供 open、四种语义快捷方法和 closeAll。 */
3
+ export declare const VlNotification: NotificationComponent;
4
+ export type { NotificationProps, NotificationOptions, NotificationStatus, NotificationPlacement, NotificationRef, NotificationHandle, NotificationComponent } from './type.js';
5
+ export default VlNotification;
@@ -0,0 +1,5 @@
1
+ import type { NotificationHandle, NotificationOptions } from './type.cjs';
2
+ /** 为每次调用创建独立 root,显隐与计时仍交给声明式组件。 */
3
+ export declare const open: (options: NotificationOptions) => NotificationHandle;
4
+ /** 取快照后关闭,onClose 新建的通知属于下一批,不应被本次 closeAll 误关。 */
5
+ export declare const closeAll: () => void;
@@ -0,0 +1,5 @@
1
+ import type { NotificationHandle, NotificationOptions } from './type.js';
2
+ /** 为每次调用创建独立 root,显隐与计时仍交给声明式组件。 */
3
+ export declare const open: (options: NotificationOptions) => NotificationHandle;
4
+ /** 取快照后关闭,onClose 新建的通知属于下一批,不应被本次 closeAll 误关。 */
5
+ export declare const closeAll: () => void;
@@ -0,0 +1,55 @@
1
+ import type { ForwardRefExoticComponent, HTMLAttributes, ReactNode, RefAttributes } from 'react';
2
+ import type { DecorativeIcon } from '../_shared/icon.cjs';
3
+ export type NotificationStatus = 'info' | 'success' | 'warning' | 'error';
4
+ export type NotificationPlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
5
+ export type NotificationRef = HTMLDivElement;
6
+ /** 通知通过 Portal 共享四角容器;声明式内容仍保留调用方的 React Context。 */
7
+ export interface NotificationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'onChange'> {
8
+ /** 受控显示状态,显式传入 undefined 也视为受控。 */
9
+ open?: boolean;
10
+ /** 非受控初始显示状态,默认为 false。 */
11
+ defaultOpen?: boolean;
12
+ title?: ReactNode;
13
+ /** 语义状态及默认图标,默认为 info。 */
14
+ status?: NotificationStatus;
15
+ /** 自定义图标,null 隐藏图标。 */
16
+ icon?: DecorativeIcon | null;
17
+ /** 四角位置,同位置的通知按打开顺序从视口边缘向内排列,默认为 top-right。 */
18
+ placement?: NotificationPlacement;
19
+ /** 自动关闭等待时间(毫秒),默认为 4500;小于等于 0 时保持显示。 */
20
+ duration?: number;
21
+ /** 是否显示关闭按钮,默认为 true。 */
22
+ closable?: boolean;
23
+ /** 悬停时暂停倒计时,默认为 true。 */
24
+ pauseOnHover?: boolean;
25
+ /** 内部元素聚焦时暂停倒计时,默认为 true。 */
26
+ pauseOnFocus?: boolean;
27
+ /** 焦点位于通知内时允许 Escape 关闭,默认为 true;不监听全局键盘。 */
28
+ closeOnPressEscape?: boolean;
29
+ /** 正文下方的操作区。 */
30
+ action?: ReactNode;
31
+ /** 关闭请求;受控模式需要调用方回传 open=false。 */
32
+ onChange?: (open: boolean) => void;
33
+ /** 关闭按钮、倒计时或 Escape 发起关闭时触发,每次显示只触发一次。 */
34
+ onClose?: () => void;
35
+ /** 离场动画结束后触发,直接卸载组件不会触发。 */
36
+ onAfterClose?: () => void;
37
+ }
38
+ export interface NotificationOptions extends Omit<NotificationProps, 'children' | 'content' | 'open' | 'defaultOpen' | 'onChange'> {
39
+ /** 命令式通知正文,对应声明式 children。 */
40
+ content?: ReactNode;
41
+ }
42
+ export interface NotificationHandle {
43
+ /** 关闭当前通知;可重复调用,也可在通知首次渲染前调用。 */
44
+ close: () => void;
45
+ }
46
+ /** 静态方法仅供浏览器事件或客户端组件调用,返回可手动关闭的句柄。 */
47
+ export interface NotificationComponent extends ForwardRefExoticComponent<NotificationProps & RefAttributes<NotificationRef>> {
48
+ open: (options: NotificationOptions) => NotificationHandle;
49
+ info: (options: NotificationOptions) => NotificationHandle;
50
+ success: (options: NotificationOptions) => NotificationHandle;
51
+ warning: (options: NotificationOptions) => NotificationHandle;
52
+ error: (options: NotificationOptions) => NotificationHandle;
53
+ /** 关闭所有命令式通知;声明式实例仍由各自的 open 状态管理。 */
54
+ closeAll: () => void;
55
+ }
@@ -0,0 +1,55 @@
1
+ import type { ForwardRefExoticComponent, HTMLAttributes, ReactNode, RefAttributes } from 'react';
2
+ import type { DecorativeIcon } from '../_shared/icon.js';
3
+ export type NotificationStatus = 'info' | 'success' | 'warning' | 'error';
4
+ export type NotificationPlacement = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left';
5
+ export type NotificationRef = HTMLDivElement;
6
+ /** 通知通过 Portal 共享四角容器;声明式内容仍保留调用方的 React Context。 */
7
+ export interface NotificationProps extends Omit<HTMLAttributes<HTMLDivElement>, 'title' | 'onChange'> {
8
+ /** 受控显示状态,显式传入 undefined 也视为受控。 */
9
+ open?: boolean;
10
+ /** 非受控初始显示状态,默认为 false。 */
11
+ defaultOpen?: boolean;
12
+ title?: ReactNode;
13
+ /** 语义状态及默认图标,默认为 info。 */
14
+ status?: NotificationStatus;
15
+ /** 自定义图标,null 隐藏图标。 */
16
+ icon?: DecorativeIcon | null;
17
+ /** 四角位置,同位置的通知按打开顺序从视口边缘向内排列,默认为 top-right。 */
18
+ placement?: NotificationPlacement;
19
+ /** 自动关闭等待时间(毫秒),默认为 4500;小于等于 0 时保持显示。 */
20
+ duration?: number;
21
+ /** 是否显示关闭按钮,默认为 true。 */
22
+ closable?: boolean;
23
+ /** 悬停时暂停倒计时,默认为 true。 */
24
+ pauseOnHover?: boolean;
25
+ /** 内部元素聚焦时暂停倒计时,默认为 true。 */
26
+ pauseOnFocus?: boolean;
27
+ /** 焦点位于通知内时允许 Escape 关闭,默认为 true;不监听全局键盘。 */
28
+ closeOnPressEscape?: boolean;
29
+ /** 正文下方的操作区。 */
30
+ action?: ReactNode;
31
+ /** 关闭请求;受控模式需要调用方回传 open=false。 */
32
+ onChange?: (open: boolean) => void;
33
+ /** 关闭按钮、倒计时或 Escape 发起关闭时触发,每次显示只触发一次。 */
34
+ onClose?: () => void;
35
+ /** 离场动画结束后触发,直接卸载组件不会触发。 */
36
+ onAfterClose?: () => void;
37
+ }
38
+ export interface NotificationOptions extends Omit<NotificationProps, 'children' | 'content' | 'open' | 'defaultOpen' | 'onChange'> {
39
+ /** 命令式通知正文,对应声明式 children。 */
40
+ content?: ReactNode;
41
+ }
42
+ export interface NotificationHandle {
43
+ /** 关闭当前通知;可重复调用,也可在通知首次渲染前调用。 */
44
+ close: () => void;
45
+ }
46
+ /** 静态方法仅供浏览器事件或客户端组件调用,返回可手动关闭的句柄。 */
47
+ export interface NotificationComponent extends ForwardRefExoticComponent<NotificationProps & RefAttributes<NotificationRef>> {
48
+ open: (options: NotificationOptions) => NotificationHandle;
49
+ info: (options: NotificationOptions) => NotificationHandle;
50
+ success: (options: NotificationOptions) => NotificationHandle;
51
+ warning: (options: NotificationOptions) => NotificationHandle;
52
+ error: (options: NotificationOptions) => NotificationHandle;
53
+ /** 关闭所有命令式通知;声明式实例仍由各自的 open 状态管理。 */
54
+ closeAll: () => void;
55
+ }
@@ -1,8 +1,12 @@
1
1
  import type { RefObject } from 'react';
2
+ import type { OverlayLayer } from './layer.cjs';
3
+ /** 命令式弹层跨越 React root,用已打开面板的层级快照补回无法继承的 Context。 */
4
+ export declare const getActiveDialogLayers: () => OverlayLayer[];
2
5
  /** 拖拽期间禁止文本选择;使用引用计数以兼容嵌套弹层或同时结束的拖拽清理。 */
3
6
  export declare const acquireBodyUserSelectLock: () => () => void;
4
7
  export interface DialogInteractionOptions {
5
8
  active: boolean;
9
+ layer: OverlayLayer;
6
10
  containerRef: RefObject<HTMLElement | null>;
7
11
  closeOnPressEscape: boolean;
8
12
  lockScroll: boolean;
@@ -15,6 +19,6 @@ export interface DialogInteractionOptions {
15
19
  * 当上层弹层关闭时,订阅栈变化的父层会重新确认焦点是否仍在自身内部。最终卸载会恢复打开前焦点;
16
20
  * 若仍有父弹层存在,其 focusin 陷阱会自然把焦点约束回父层,因此无需在这里感知具体父子关系。
17
21
  */
18
- export declare const useDialogInteraction: ({ active, containerRef, closeOnPressEscape, lockScroll, onRequestClose }: DialogInteractionOptions) => {
22
+ export declare const useDialogInteraction: ({ active, layer, containerRef, closeOnPressEscape, lockScroll, onRequestClose }: DialogInteractionOptions) => {
19
23
  isTopLayer: () => boolean;
20
24
  };
@@ -1,8 +1,12 @@
1
1
  import type { RefObject } from 'react';
2
+ import type { OverlayLayer } from './layer.js';
3
+ /** 命令式弹层跨越 React root,用已打开面板的层级快照补回无法继承的 Context。 */
4
+ export declare const getActiveDialogLayers: () => OverlayLayer[];
2
5
  /** 拖拽期间禁止文本选择;使用引用计数以兼容嵌套弹层或同时结束的拖拽清理。 */
3
6
  export declare const acquireBodyUserSelectLock: () => () => void;
4
7
  export interface DialogInteractionOptions {
5
8
  active: boolean;
9
+ layer: OverlayLayer;
6
10
  containerRef: RefObject<HTMLElement | null>;
7
11
  closeOnPressEscape: boolean;
8
12
  lockScroll: boolean;
@@ -15,6 +19,6 @@ export interface DialogInteractionOptions {
15
19
  * 当上层弹层关闭时,订阅栈变化的父层会重新确认焦点是否仍在自身内部。最终卸载会恢复打开前焦点;
16
20
  * 若仍有父弹层存在,其 focusin 陷阱会自然把焦点约束回父层,因此无需在这里感知具体父子关系。
17
21
  */
18
- export declare const useDialogInteraction: ({ active, containerRef, closeOnPressEscape, lockScroll, onRequestClose }: DialogInteractionOptions) => {
22
+ export declare const useDialogInteraction: ({ active, layer, containerRef, closeOnPressEscape, lockScroll, onRequestClose }: DialogInteractionOptions) => {
19
23
  isTopLayer: () => boolean;
20
24
  };
@@ -21,6 +21,7 @@ import type { VlInput as VlInputComponent } from './Input/index.cjs';
21
21
  import type { VlLoading as VlLoadingComponent } from './Loading/index.cjs';
22
22
  import type { VlMessageBox as VlMessageBoxComponent } from './MessageBox/index.cjs';
23
23
  import type { VlModal as VlModalComponent } from './Modal/index.cjs';
24
+ import type { VlNotification as VlNotificationComponent } from './Notification/index.cjs';
24
25
  import type { VlNumberInput as VlNumberInputComponent } from './NumberInput/index.cjs';
25
26
  import type { VlPagination as VlPaginationComponent } from './Pagination/index.cjs';
26
27
  import type { VlProgress as VlProgressComponent } from './Progress/index.cjs';
@@ -67,6 +68,7 @@ declare global {
67
68
  const VlLoading: typeof VlLoadingComponent;
68
69
  const VlMessageBox: typeof VlMessageBoxComponent;
69
70
  const VlModal: typeof VlModalComponent;
71
+ const VlNotification: typeof VlNotificationComponent;
70
72
  const VlNumberInput: typeof VlNumberInputComponent;
71
73
  const VlPagination: typeof VlPaginationComponent;
72
74
  const VlProgress: typeof VlProgressComponent;
@@ -21,6 +21,7 @@ import type { VlInput as VlInputComponent } from './Input/index.js';
21
21
  import type { VlLoading as VlLoadingComponent } from './Loading/index.js';
22
22
  import type { VlMessageBox as VlMessageBoxComponent } from './MessageBox/index.js';
23
23
  import type { VlModal as VlModalComponent } from './Modal/index.js';
24
+ import type { VlNotification as VlNotificationComponent } from './Notification/index.js';
24
25
  import type { VlNumberInput as VlNumberInputComponent } from './NumberInput/index.js';
25
26
  import type { VlPagination as VlPaginationComponent } from './Pagination/index.js';
26
27
  import type { VlProgress as VlProgressComponent } from './Progress/index.js';
@@ -67,6 +68,7 @@ declare global {
67
68
  const VlLoading: typeof VlLoadingComponent;
68
69
  const VlMessageBox: typeof VlMessageBoxComponent;
69
70
  const VlModal: typeof VlModalComponent;
71
+ const VlNotification: typeof VlNotificationComponent;
70
72
  const VlNumberInput: typeof VlNumberInputComponent;
71
73
  const VlPagination: typeof VlPaginationComponent;
72
74
  const VlProgress: typeof VlProgressComponent;
@@ -22,6 +22,7 @@ export * from './Input/index.cjs';
22
22
  export * from './Loading/index.cjs';
23
23
  export * from './MessageBox/index.cjs';
24
24
  export * from './Modal/index.cjs';
25
+ export * from './Notification/index.cjs';
25
26
  export * from './NumberInput/index.cjs';
26
27
  export * from './Pagination/index.cjs';
27
28
  export * from './Progress/index.cjs';
@@ -22,6 +22,7 @@ export * from './Input/index.js';
22
22
  export * from './Loading/index.js';
23
23
  export * from './MessageBox/index.js';
24
24
  export * from './Modal/index.js';
25
+ export * from './Notification/index.js';
25
26
  export * from './NumberInput/index.js';
26
27
  export * from './Pagination/index.js';
27
28
  export * from './Progress/index.js';
@@ -30,6 +30,7 @@ export declare const globalComponents: {
30
30
  readonly VlLoading: import("react").ForwardRefExoticComponent<import("./Loading/index.cjs").LoadingProps & import("react").RefAttributes<HTMLDivElement>>;
31
31
  readonly VlMessageBox: import("./MessageBox/index.cjs").MessageBoxComponent;
32
32
  readonly VlModal: import("react").ForwardRefExoticComponent<import("./Modal/index.cjs").ModalProps & import("react").RefAttributes<HTMLDivElement>>;
33
+ readonly VlNotification: import("./Notification/index.cjs").NotificationComponent;
33
34
  readonly VlNumberInput: import("react").ForwardRefExoticComponent<import("./NumberInput/index.cjs").NumberInputProps & import("react").RefAttributes<HTMLInputElement>>;
34
35
  readonly VlPagination: import("react").ForwardRefExoticComponent<import("./Pagination/index.cjs").PaginationProps & import("react").RefAttributes<HTMLElement>>;
35
36
  readonly VlProgress: import("react").ForwardRefExoticComponent<import("./Progress/index.cjs").ProgressProps & import("react").RefAttributes<HTMLDivElement>>;
@@ -30,6 +30,7 @@ export declare const globalComponents: {
30
30
  readonly VlLoading: import("react").ForwardRefExoticComponent<import("./Loading/index.js").LoadingProps & import("react").RefAttributes<HTMLDivElement>>;
31
31
  readonly VlMessageBox: import("./MessageBox/index.js").MessageBoxComponent;
32
32
  readonly VlModal: import("react").ForwardRefExoticComponent<import("./Modal/index.js").ModalProps & import("react").RefAttributes<HTMLDivElement>>;
33
+ readonly VlNotification: import("./Notification/index.js").NotificationComponent;
33
34
  readonly VlNumberInput: import("react").ForwardRefExoticComponent<import("./NumberInput/index.js").NumberInputProps & import("react").RefAttributes<HTMLInputElement>>;
34
35
  readonly VlPagination: import("react").ForwardRefExoticComponent<import("./Pagination/index.js").PaginationProps & import("react").RefAttributes<HTMLElement>>;
35
36
  readonly VlProgress: import("react").ForwardRefExoticComponent<import("./Progress/index.js").ProgressProps & import("react").RefAttributes<HTMLDivElement>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vavt/react-ui",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "author": "zbf <zbfcqtl@gmail.com>",
5
5
  "license": "MIT",
6
6
  "description": "A modern React component library",
@@ -1 +0,0 @@
1
- const e=require("./state-BuUx1onZ.cjs"),t=require("./client-BkoqeUs3.cjs"),n=require("./refs-DCqd87V8.cjs"),r=require("./content-DCGQZQp8.cjs"),i=require("./number-B7qJF_ZY.cjs"),ee=require("./id-CF0zOP1G.cjs"),a=require("./layer-BgiUZy_t.cjs"),o=require("./dialog-shell-CzeGytVj.cjs");let s=require("lucide-react"),c=require("react"),l=require("react/jsx-runtime");var u=(0,c.forwardRef)((u,d)=>{let{open:f,defaultOpen:p=!1,title:m,header:h,footer:g,placement:_=`right`,width:v=360,height:y=320,mask:b=!0,closeOnClickOverlay:x=!0,closeOnPressEscape:S=!0,showClose:C=!0,lockScroll:w=!0,destroyOnClose:T=!1,zIndex:E,className:D,style:O,children:te,onClick:ne,onChange:k,onOpen:A,onClose:j,"aria-label":M,"aria-labelledby":N,"aria-describedby":P,...F}=u,I=t.t(),L=typeof O?.zIndex==`number`?O.zIndex:void 0,R=a.r({defaultZIndex:a.n.modal,zIndex:E??L,withMask:!0}),z=(0,c.useRef)(null),B=(0,c.useMemo)(()=>n.n(z,d),[d]),V=(0,c.useRef)(!1),H=e.t(u,`open`),[U,W]=e.n({value:!!f,defaultValue:p,controlled:H,onChange:k}),G=(0,c.useCallback)(()=>W(!1),[W]),{isTopLayer:K}=o.r({active:I&&U,containerRef:z,closeOnPressEscape:S,lockScroll:w,onRequestClose:G}),q=ee.t(`vl-drawer-title`);(0,c.useEffect)(()=>{let e=V.current;U&&!e?A?.():!U&&e&&j?.(),V.current=U},[U,A,j]);let J=()=>{x&&K()&&G()},Y=e=>{e.stopPropagation(),ne?.(e)},X=[`vl-drawer`,`is-${_}`,D||``].filter(Boolean).join(` `),Z={...O};R.zIndex!==void 0&&(Z.zIndex=R.zIndex),_===`left`||_===`right`?(Z.width=i.n(v)??`360px`,Z.height=`100vh`):(Z.height=i.n(y)??`320px`,Z.width=`100vw`);let Q=h??(m?(0,l.jsx)(`div`,{id:q,className:`vl-drawer__title`,children:m}):null),$=N??(!h&&m?q:void 0),re=M??($?void 0:typeof m==`string`?m:`抽屉`);return(0,l.jsx)(a.t,{layer:R.layer,children:(0,l.jsxs)(o.t,{clientReady:I,open:U,mask:b,destroyOnClose:T,maskUnmountOnExit:T,maskTransitionName:`vl-drawer-mask`,transitionName:`vl-drawer-${_}`,maskClassName:`vl-drawer__mask`,panelClassName:X,panelStyle:Z,maskStyle:R.maskZIndex===void 0?void 0:{zIndex:R.maskZIndex},panelRef:B,role:`dialog`,ariaLabel:re,ariaLabelledBy:$,ariaDescribedBy:P,onMaskClick:J,onPanelClick:Y,panelProps:F,children:[r.t(Q)||C?(0,l.jsx)(`div`,{className:`vl-drawer__header`,children:(0,l.jsxs)(`div`,{className:`vl-drawer__headerInner`,children:[(0,l.jsx)(`div`,{className:`vl-drawer__headerMain`,children:Q}),C?(0,l.jsx)(`button`,{type:`button`,className:`vl-drawer__close`,"aria-label":`关闭抽屉`,onClick:G,children:(0,l.jsx)(s.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,l.jsx)(`div`,{className:`vl-drawer__body`,children:te}),r.t(g)?(0,l.jsx)(`div`,{className:`vl-drawer__footer`,children:g}):null]})})});u.displayName=`VlDrawer`;var d=u,f=u;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
@@ -1 +0,0 @@
1
- const e=require("./state-BuUx1onZ.cjs"),t=require("./Button-qURrKHQ0.cjs"),n=require("./focus-D-h8CbGr.cjs"),r=require("./Modal-DPxZEr2v.cjs");let i=require("lucide-react"),a=require("react"),o=require("react/jsx-runtime"),s=require("react-dom/client");var c={info:i.Info,success:i.CircleCheck,warning:i.CircleAlert,error:i.CircleX},l={info:`primary`,success:`success`,warning:`warning`,error:`error`},u={[n.t]:!0},d=e=>(typeof e==`object`||typeof e==`function`)&&e!==null&&`then`in e&&typeof e.then==`function`,f=(0,a.forwardRef)((n,s)=>{let{open:f,defaultOpen:p=!1,title:m=`提示`,type:h=`info`,showCancelButton:g=!1,confirmButtonText:_=`确定`,confirmButtonLoadingText:v,cancelButtonText:y=`取消`,width:b=420,closeOnClickOverlay:x=!1,closeOnPressEscape:S=!0,showClose:C=!0,draggable:w=!1,className:T,children:E,onChange:D,onConfirm:O,onCancel:k,onClose:A,onConfirmError:j,...M}=n,N=e.t(n,`open`),[P,F]=e.n({value:!!f,defaultValue:p,controlled:N,onChange:D}),[I,L]=(0,a.useState)(!1),R=(0,a.useRef)(!1),z=e=>{R.current||(e===`cancel`?k?.():A?.(),F(!1))},B=async()=>{if(!R.current)try{let e=O?.();d(e)&&(R.current=!0,L(!0),await e),F(!1)}catch(e){j?.(e)}finally{R.current=!1,L(!1)}},V=c[h],H=[`vl-message-box`,`is-${h}`,T||``].filter(Boolean).join(` `);return(0,o.jsx)(r.t,{...M,ref:s,open:P,title:m,width:b,draggable:w,closeOnClickOverlay:!I&&x,closeOnPressEscape:!I&&S,showClose:!1,className:H,header:(0,o.jsxs)(`div`,{className:`vl-message-box__header`,children:[(0,o.jsx)(`div`,{className:`vl-message-box__title`,children:m}),C?(0,o.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭消息框`,disabled:I,onClick:()=>z(`close`),children:(0,o.jsx)(i.X,{size:20,"aria-hidden":`true`})}):null]}),footer:(0,o.jsxs)(`div`,{className:`vl-message-box__actions`,children:[g?(0,o.jsx)(t.t,{disabled:I,onClick:()=>z(`cancel`),children:y}):null,(0,o.jsx)(t.t,{...u,status:l[h],variant:`solid`,loading:I,loadingText:v,onClick:B,children:_})]}),onChange:e=>{e||z(`close`)},children:(0,o.jsxs)(`div`,{className:`vl-message-box__content`,children:[(0,o.jsx)(V,{className:`vl-message-box__icon`,"aria-hidden":`true`}),(0,o.jsx)(`div`,{className:`vl-message-box__message`,children:E})]})})});f.displayName=`VlMessageBox`;var p=(e,t={},n)=>typeof document>`u`?Promise.reject(Error(`VlMessageBox imperative APIs are only available in a browser environment.`)):new Promise((r,i)=>{let c=document.createElement(`div`);c.className=`vl-message-box-container`,document.body.appendChild(c);let l=(0,s.createRoot)(c);l.render((0,o.jsx)(()=>{let[s,u]=(0,a.useState)(!0);return(0,o.jsx)(f,{...t,open:s,showCancelButton:n,onChange:u,onConfirm:async()=>{await t.onConfirm?.(),r(`confirm`)},onCancel:()=>{t.onCancel?.(),i(`cancel`)},onClose:()=>{t.onClose?.(),i(`close`)},onAfterClose:()=>{try{t.onAfterClose?.()}finally{queueMicrotask(()=>{l.unmount(),c.remove()})}},children:e})},{}))}),m=Object.assign(f,{alert:(e,t)=>p(e,t,!1),confirm:(e,t)=>p(e,t,!0)});Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return m}});
@@ -1,141 +0,0 @@
1
- import { n as e, t } from "./state-BSDh-Ob2.js";
2
- import { t as n } from "./Button-CwkWSWau.js";
3
- import { t as r } from "./focus-BDDJyKk3.js";
4
- import { t as i } from "./Modal-Du7aVdWl.js";
5
- import { CircleAlert as a, CircleCheck as o, CircleX as s, Info as c, X as l } from "lucide-react";
6
- import { forwardRef as u, useRef as d, useState as f } from "react";
7
- import { jsx as p, jsxs as m } from "react/jsx-runtime";
8
- import { createRoot as h } from "react-dom/client";
9
- //#region components/MessageBox/MessageBox.tsx
10
- var g = {
11
- info: c,
12
- success: o,
13
- warning: a,
14
- error: s
15
- }, _ = {
16
- info: "primary",
17
- success: "success",
18
- warning: "warning",
19
- error: "error"
20
- }, v = { [r]: !0 }, y = (e) => (typeof e == "object" || typeof e == "function") && e !== null && "then" in e && typeof e.then == "function", b = u((r, a) => {
21
- let { open: o, defaultOpen: s = !1, title: c = "提示", type: u = "info", showCancelButton: h = !1, confirmButtonText: b = "确定", confirmButtonLoadingText: x, cancelButtonText: S = "取消", width: C = 420, closeOnClickOverlay: w = !1, closeOnPressEscape: T = !0, showClose: E = !0, draggable: D = !1, className: O, children: k, onChange: A, onConfirm: j, onCancel: M, onClose: N, onConfirmError: P, ...F } = r, I = t(r, "open"), [L, R] = e({
22
- value: !!o,
23
- defaultValue: s,
24
- controlled: I,
25
- onChange: A
26
- }), [z, B] = f(!1), V = d(!1), H = (e) => {
27
- V.current || (e === "cancel" ? M?.() : N?.(), R(!1));
28
- }, U = async () => {
29
- if (!V.current) try {
30
- let e = j?.();
31
- y(e) && (V.current = !0, B(!0), await e), R(!1);
32
- } catch (e) {
33
- P?.(e);
34
- } finally {
35
- V.current = !1, B(!1);
36
- }
37
- }, W = g[u], G = [
38
- "vl-message-box",
39
- `is-${u}`,
40
- O || ""
41
- ].filter(Boolean).join(" ");
42
- return /* @__PURE__ */ p(i, {
43
- ...F,
44
- ref: a,
45
- open: L,
46
- title: c,
47
- width: C,
48
- draggable: D,
49
- closeOnClickOverlay: !z && w,
50
- closeOnPressEscape: !z && T,
51
- showClose: !1,
52
- className: G,
53
- header: /* @__PURE__ */ m("div", {
54
- className: "vl-message-box__header",
55
- children: [/* @__PURE__ */ p("div", {
56
- className: "vl-message-box__title",
57
- children: c
58
- }), E ? /* @__PURE__ */ p("button", {
59
- type: "button",
60
- className: "vl-modal__close",
61
- "aria-label": "关闭消息框",
62
- disabled: z,
63
- onClick: () => H("close"),
64
- children: /* @__PURE__ */ p(l, {
65
- size: 20,
66
- "aria-hidden": "true"
67
- })
68
- }) : null]
69
- }),
70
- footer: /* @__PURE__ */ m("div", {
71
- className: "vl-message-box__actions",
72
- children: [h ? /* @__PURE__ */ p(n, {
73
- disabled: z,
74
- onClick: () => H("cancel"),
75
- children: S
76
- }) : null, /* @__PURE__ */ p(n, {
77
- ...v,
78
- status: _[u],
79
- variant: "solid",
80
- loading: z,
81
- loadingText: x,
82
- onClick: U,
83
- children: b
84
- })]
85
- }),
86
- onChange: (e) => {
87
- e || H("close");
88
- },
89
- children: /* @__PURE__ */ m("div", {
90
- className: "vl-message-box__content",
91
- children: [/* @__PURE__ */ p(W, {
92
- className: "vl-message-box__icon",
93
- "aria-hidden": "true"
94
- }), /* @__PURE__ */ p("div", {
95
- className: "vl-message-box__message",
96
- children: k
97
- })]
98
- })
99
- });
100
- });
101
- b.displayName = "VlMessageBox";
102
- //#endregion
103
- //#region components/MessageBox/service.tsx
104
- var x = (e, t = {}, n) => typeof document > "u" ? Promise.reject(/* @__PURE__ */ Error("VlMessageBox imperative APIs are only available in a browser environment.")) : new Promise((r, i) => {
105
- let a = document.createElement("div");
106
- a.className = "vl-message-box-container", document.body.appendChild(a);
107
- let o = h(a);
108
- o.render(/* @__PURE__ */ p(() => {
109
- let [s, c] = f(!0);
110
- return /* @__PURE__ */ p(b, {
111
- ...t,
112
- open: s,
113
- showCancelButton: n,
114
- onChange: c,
115
- onConfirm: async () => {
116
- await t.onConfirm?.(), r("confirm");
117
- },
118
- onCancel: () => {
119
- t.onCancel?.(), i("cancel");
120
- },
121
- onClose: () => {
122
- t.onClose?.(), i("close");
123
- },
124
- onAfterClose: () => {
125
- try {
126
- t.onAfterClose?.();
127
- } finally {
128
- queueMicrotask(() => {
129
- o.unmount(), a.remove();
130
- });
131
- }
132
- },
133
- children: e
134
- });
135
- }, {}));
136
- }), S = Object.assign(b, {
137
- alert: (e, t) => x(e, t, !1),
138
- confirm: (e, t) => x(e, t, !0)
139
- });
140
- //#endregion
141
- export { S as t };
@@ -1 +0,0 @@
1
- const e=require("./effect-BpNxm_06.cjs"),t=require("./state-BuUx1onZ.cjs"),n=require("./client-BkoqeUs3.cjs"),r=require("./refs-DCqd87V8.cjs"),i=require("./content-DCGQZQp8.cjs"),a=require("./number-B7qJF_ZY.cjs"),o=require("./id-CF0zOP1G.cjs"),s=require("./layer-BgiUZy_t.cjs"),c=require("./dialog-shell-CzeGytVj.cjs"),ee=require("./Scrollbar-CEQT6Ao_.cjs");let te=require("lucide-react"),l=require("react"),u=require("react/jsx-runtime");var ne=.25,re=0,ie=e=>{if(typeof e==`number`)return Number.isFinite(e)?e:0;if(typeof e==`string`){let t=e.trim();if(t.endsWith(`vh`)){let e=parseFloat(t);return Number.isFinite(e)?window.innerHeight*e/100:0}if(t.endsWith(`px`)){let e=parseFloat(t);return Number.isFinite(e)?e:0}let n=parseFloat(t);return Number.isFinite(n)?n:0}return 0},d=(0,l.forwardRef)((d,f)=>{let{open:p,defaultOpen:ae=!1,title:m,width:oe=520,offsetY:h=re,center:g=!1,mask:se=!0,closeOnClickOverlay:ce=!0,closeOnPressEscape:le=!0,showClose:_=!0,lockScroll:ue=!0,destroyOnClose:v=!1,draggable:y=!0,fullscreen:b=!1,zIndex:de,header:x,footer:S,className:fe,style:C,children:pe,onClick:me,onChange:he,onOpen:w,onClose:T,onAfterClose:ge,"aria-label":_e,"aria-labelledby":ve,"aria-describedby":ye,...be}=d,E=n.t(),xe=typeof C?.zIndex==`number`?C.zIndex:void 0,D=s.r({defaultZIndex:s.n.modal,zIndex:de??xe,withMask:!0}),O=(0,l.useRef)(null),Se=(0,l.useMemo)(()=>r.n(O,f),[f]),Ce=t.t(d,`open`),[k,A]=t.n({value:!!p,defaultValue:ae,controlled:Ce,onChange:he}),[we,j]=(0,l.useState)(!1),M=(0,l.useRef)({x:0,y:0}),N=(0,l.useRef)(!1),P=(0,l.useRef)(!1),F=(0,l.useRef)({x:0,y:0}),I=(0,l.useRef)(null),L=(0,l.useRef)(!1),R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=o.t(`vl-modal-title`),V=(0,l.useCallback)(()=>A(!1),[A]),{isTopLayer:H}=c.r({active:E&&k,containerRef:O,closeOnPressEscape:le,lockScroll:ue,onRequestClose:V}),U=(0,l.useCallback)(e=>{O.current&&(O.current.style.visibility=e?`visible`:`hidden`)},[]),W=(0,l.useCallback)((e,t)=>{M.current={x:e,y:t},O.current&&(O.current.style.left=`${e}px`,O.current.style.top=`${t}px`)},[]),G=(0,l.useCallback)((e,t)=>{let n=e.getBoundingClientRect();return{rect:n,maxX:Math.max(t,window.innerWidth-n.width-t),maxY:Math.max(t,window.innerHeight-n.height-t)}},[]),K=(0,l.useCallback)(()=>{let e=O.current;if(!e||typeof window>`u`)return;if(b){W(0,0),N.current=!1;return}let{rect:t,maxX:n,maxY:r}=G(e,12),i=(g?(window.innerHeight-t.height)/2:window.innerHeight*ne)+ie(h);W(Math.round(a.t((window.innerWidth-t.width)/2,12,n)),Math.round(a.t(i,12,r)))},[g,b,G,h,W]),q=(0,l.useCallback)(()=>{let e=O.current;if(!e)return;let{maxX:t,maxY:n}=G(e,12);W(Math.round(a.t(M.current.x,12,t)),Math.round(a.t(M.current.y,12,n)))},[G,W]),J=(0,l.useCallback)((e,t)=>{let n=O.current;if(!n||b)return;let{maxX:r,maxY:i}=G(n,12),o=a.t(e-F.current.x,12,r),s=a.t(t-F.current.y,12,i);W(Math.round(o),Math.round(s)),N.current=!0},[b,G,W]),Y=(0,l.useRef)(J);e.t(()=>{Y.current=J},[J]);let Te=(0,l.useCallback)(e=>{P.current&&Y.current(e.clientX,e.clientY)},[]),X=(0,l.useCallback)(()=>{z.current?.abort(),z.current=null,I.current?.(),I.current=null},[]),Z=(0,l.useCallback)(()=>{P.current&&(P.current=!1,j(!1),X())},[X]),Ee=e=>{if(!y||b||!k||!H()||e.button!==0||e.target.closest(`.vl-modal__close, .vl-modal__title, .vl-message-box__title, [class*='__title'], [data-drag-cancel], button, input, textarea, select, a`))return;let t=O.current;if(!t)return;let n=window.getSelection();n&&n.rangeCount>0&&n.removeAllRanges(),e.preventDefault();let r=t.getBoundingClientRect();F.current={x:e.clientX-r.left,y:e.clientY-r.top},P.current=!0,j(!0),I.current=c.n(),z.current=new AbortController;let{signal:i}=z.current;window.addEventListener(`pointermove`,Te,{signal:i}),window.addEventListener(`pointerup`,Z,{once:!0,signal:i})};(0,l.useEffect)(()=>{let e=L.current;k&&!e?w?.():!k&&e&&T?.(),L.current=k},[k,w,T]),e.t(()=>{!k||!E||(U(!1),b?W(0,0):!v&&N.current?q():K(),U(!0))},[k,E,b,v,K,q,W,U]),(0,l.useEffect)(()=>{k||Z()},[k,Z]),(0,l.useEffect)(()=>{if(!k)return;let e=()=>{P.current||(R.current!==null&&window.clearTimeout(R.current),R.current=window.setTimeout(()=>{R.current=null,N.current?q():K()},100))};return window.addEventListener(`resize`,e,{passive:!0}),()=>{window.removeEventListener(`resize`,e),R.current!==null&&(window.clearTimeout(R.current),R.current=null)}},[k,K,q]),(0,l.useEffect)(()=>()=>{X(),R.current!==null&&(window.clearTimeout(R.current),R.current=null)},[X]);let De=()=>{ce&&H()&&V()},Oe=e=>{e.stopPropagation(),me?.(e)},ke=[`vl-modal`,we?`is-dragging`:``,g?`is-center`:``,b?`is-fullscreen`:``,fe||``].filter(Boolean).join(` `),Ae=[`vl-modal__header`,y&&!b?`is-draggable`:``].filter(Boolean).join(` `),Q={...C};D.zIndex!==void 0&&(Q.zIndex=D.zIndex),b?(Q.width=`100vw`,Q.height=`100vh`):Q.width=a.n(oe)??`520px`;let $=x??(m?(0,u.jsx)(`div`,{id:B,className:`vl-modal__title`,children:m}):null),je=ve??(!x&&m?B:void 0),Me=_e??(je?void 0:typeof m==`string`?m:`对话框`);return(0,u.jsx)(s.t,{layer:D.layer,children:(0,u.jsxs)(c.t,{clientReady:E,open:k,mask:se,destroyOnClose:v,maskTransitionName:`vl-modal-mask`,transitionName:`vl-modal`,maskClassName:`vl-modal__mask`,panelClassName:ke,panelStyle:Q,maskStyle:D.maskZIndex===void 0?void 0:{zIndex:D.maskZIndex},panelRef:Se,role:`dialog`,ariaLabel:Me,ariaLabelledBy:je,ariaDescribedBy:ye,onMaskClick:De,onPanelClick:Oe,onAfterLeave:()=>{Z(),v&&(N.current=!1),ge?.()},panelProps:be,children:[i.t($)||_?(0,u.jsx)(`div`,{className:Ae,onPointerDown:Ee,children:(0,u.jsxs)(`div`,{className:`vl-modal__headerInner`,children:[(0,u.jsx)(`div`,{className:`vl-modal__headerMain`,children:$}),_?(0,u.jsx)(`button`,{type:`button`,className:`vl-modal__close`,"aria-label":`关闭对话框`,onClick:V,children:(0,u.jsx)(te.X,{size:20,"aria-hidden":`true`})}):null]})}):null,(0,u.jsx)(ee.t,{className:`vl-modal__body`,children:pe}),i.t(S)?(0,u.jsx)(`div`,{className:`vl-modal__footer`,children:S}):null]})})});d.displayName=`VlModal`;var f=d,p=d;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return p}});