@will-ui/vue 1.0.0

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 (699) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -0
  3. package/TAILWIND.md +282 -0
  4. package/dist/_virtual/_rolldown/runtime.js +13 -0
  5. package/dist/components/audioPlayer/AudioPlayer.d.ts +123 -0
  6. package/dist/components/audioPlayer/AudioPlayer.js +375 -0
  7. package/dist/components/audioPlayer/AudioPlayer.js.map +1 -0
  8. package/dist/components/audioPlayer/index.d.ts +2 -0
  9. package/dist/components/audioPlayer/style/index.css +1 -0
  10. package/dist/components/btn/Btn.d.ts +45 -0
  11. package/dist/components/btn/Btn.js +165 -0
  12. package/dist/components/btn/Btn.js.map +1 -0
  13. package/dist/components/btn/config.d.ts +33 -0
  14. package/dist/components/btn/config.js +20 -0
  15. package/dist/components/btn/config.js.map +1 -0
  16. package/dist/components/btn/context.d.ts +12 -0
  17. package/dist/components/btn/context.js +6 -0
  18. package/dist/components/btn/context.js.map +1 -0
  19. package/dist/components/btn/index.d.ts +5 -0
  20. package/dist/components/btn/style/index.css +1 -0
  21. package/dist/components/btnGroup/BtnGroup.d.ts +46 -0
  22. package/dist/components/btnGroup/BtnGroup.js +43 -0
  23. package/dist/components/btnGroup/BtnGroup.js.map +1 -0
  24. package/dist/components/btnGroup/config.d.ts +14 -0
  25. package/dist/components/btnGroup/config.js +11 -0
  26. package/dist/components/btnGroup/config.js.map +1 -0
  27. package/dist/components/btnGroup/index.d.ts +3 -0
  28. package/dist/components/btnGroup/style/index.css +1 -0
  29. package/dist/components/cascade/Cascade.d.ts +1957 -0
  30. package/dist/components/cascade/Cascade.js +283 -0
  31. package/dist/components/cascade/Cascade.js.map +1 -0
  32. package/dist/components/cascade/config.d.ts +30 -0
  33. package/dist/components/cascade/config.js +18 -0
  34. package/dist/components/cascade/config.js.map +1 -0
  35. package/dist/components/cascade/index.d.ts +3 -0
  36. package/dist/components/cascade/style/index.css +1 -0
  37. package/dist/components/checkbox/Checkbox.d.ts +241 -0
  38. package/dist/components/checkbox/Checkbox.js +182 -0
  39. package/dist/components/checkbox/Checkbox.js.map +1 -0
  40. package/dist/components/checkbox/config.d.ts +18 -0
  41. package/dist/components/checkbox/config.js +11 -0
  42. package/dist/components/checkbox/config.js.map +1 -0
  43. package/dist/components/checkbox/index.d.ts +3 -0
  44. package/dist/components/checkbox/style/index.css +1 -0
  45. package/dist/components/choose/Choose.d.ts +1016 -0
  46. package/dist/components/choose/Choose.js +402 -0
  47. package/dist/components/choose/Choose.js.map +1 -0
  48. package/dist/components/choose/config.d.ts +37 -0
  49. package/dist/components/choose/config.js +21 -0
  50. package/dist/components/choose/config.js.map +1 -0
  51. package/dist/components/choose/index.d.ts +3 -0
  52. package/dist/components/choose/injectionKey.d.ts +12 -0
  53. package/dist/components/choose/injectionKey.js +11 -0
  54. package/dist/components/choose/injectionKey.js.map +1 -0
  55. package/dist/components/choose/style/index.css +1 -0
  56. package/dist/components/choose2/Choose2.d.ts +1711 -0
  57. package/dist/components/choose2/Choose2.js +403 -0
  58. package/dist/components/choose2/Choose2.js.map +1 -0
  59. package/dist/components/choose2/config.d.ts +37 -0
  60. package/dist/components/choose2/config.js +20 -0
  61. package/dist/components/choose2/config.js.map +1 -0
  62. package/dist/components/choose2/index.d.ts +3 -0
  63. package/dist/components/choose2/style/index.css +1 -0
  64. package/dist/components/chooseItem/ChooseItem.d.ts +46 -0
  65. package/dist/components/chooseItem/ChooseItem.js +72 -0
  66. package/dist/components/chooseItem/ChooseItem.js.map +1 -0
  67. package/dist/components/chooseItem/config.d.ts +12 -0
  68. package/dist/components/chooseItem/config.js +9 -0
  69. package/dist/components/chooseItem/config.js.map +1 -0
  70. package/dist/components/chooseItem/index.d.ts +3 -0
  71. package/dist/components/chooseItem/style/index.css +1 -0
  72. package/dist/components/circleProgress/CircleProgress.d.ts +83 -0
  73. package/dist/components/circleProgress/CircleProgress.js +108 -0
  74. package/dist/components/circleProgress/CircleProgress.js.map +1 -0
  75. package/dist/components/circleProgress/index.d.ts +1 -0
  76. package/dist/components/circleProgress/style/index.css +1 -0
  77. package/dist/components/close/Close.d.ts +114 -0
  78. package/dist/components/close/Close.js +82 -0
  79. package/dist/components/close/Close.js.map +1 -0
  80. package/dist/components/close/index.d.ts +1 -0
  81. package/dist/components/close/style/index.css +1 -0
  82. package/dist/components/colorPicker/ColorPicker.d.ts +138 -0
  83. package/dist/components/colorPicker/ColorPicker.js +404 -0
  84. package/dist/components/colorPicker/ColorPicker.js.map +1 -0
  85. package/dist/components/colorPicker/config.d.ts +24 -0
  86. package/dist/components/colorPicker/config.js +14 -0
  87. package/dist/components/colorPicker/config.js.map +1 -0
  88. package/dist/components/colorPicker/index.d.ts +4 -0
  89. package/dist/components/colorPicker/style/index.css +1 -0
  90. package/dist/components/confirm/index.d.ts +73 -0
  91. package/dist/components/confirm/index.js +177 -0
  92. package/dist/components/confirm/index.js.map +1 -0
  93. package/dist/components/confirm/src/style/index.css +1 -0
  94. package/dist/components/copy/Copy.d.ts +28 -0
  95. package/dist/components/copy/Copy.js +110 -0
  96. package/dist/components/copy/Copy.js.map +1 -0
  97. package/dist/components/copy/config.d.ts +25 -0
  98. package/dist/components/copy/config.js +13 -0
  99. package/dist/components/copy/config.js.map +1 -0
  100. package/dist/components/copy/index.d.ts +5 -0
  101. package/dist/components/copy/spawnCopyToast.d.ts +13 -0
  102. package/dist/components/copy/spawnCopyToast.js +150 -0
  103. package/dist/components/copy/spawnCopyToast.js.map +1 -0
  104. package/dist/components/copy/style/index.css +1 -0
  105. package/dist/components/cornerEars/CornerEars.d.ts +24 -0
  106. package/dist/components/cornerEars/CornerEars.js +108 -0
  107. package/dist/components/cornerEars/CornerEars.js.map +1 -0
  108. package/dist/components/cornerEars/cornerGeometry.d.ts +8 -0
  109. package/dist/components/cornerEars/cornerGeometry.js +63 -0
  110. package/dist/components/cornerEars/cornerGeometry.js.map +1 -0
  111. package/dist/components/cornerEars/index.d.ts +2 -0
  112. package/dist/components/cornerEars/style/index.css +1 -0
  113. package/dist/components/date/DatePanel.js +398 -0
  114. package/dist/components/date/DatePanel.js.map +1 -0
  115. package/dist/components/date/DatePicker.d.ts +226 -0
  116. package/dist/components/date/DatePicker.js +349 -0
  117. package/dist/components/date/DatePicker.js.map +1 -0
  118. package/dist/components/date/Days.d.ts +44 -0
  119. package/dist/components/date/Days.js +93 -0
  120. package/dist/components/date/Days.js.map +1 -0
  121. package/dist/components/date/Months.d.ts +32 -0
  122. package/dist/components/date/Months.js +87 -0
  123. package/dist/components/date/Months.js.map +1 -0
  124. package/dist/components/date/QuickDate.d.ts +24 -0
  125. package/dist/components/date/QuickDate.js +48 -0
  126. package/dist/components/date/QuickDate.js.map +1 -0
  127. package/dist/components/date/Years.d.ts +38 -0
  128. package/dist/components/date/Years.js +85 -0
  129. package/dist/components/date/Years.js.map +1 -0
  130. package/dist/components/date/_use/quickDate.d.ts +4 -0
  131. package/dist/components/date/_use/quickDate.js +30 -0
  132. package/dist/components/date/_use/quickDate.js.map +1 -0
  133. package/dist/components/date/_use/useDateModules.d.ts +37 -0
  134. package/dist/components/date/_use/useDateModules.js +100 -0
  135. package/dist/components/date/_use/useDateModules.js.map +1 -0
  136. package/dist/components/date/config.d.ts +32 -0
  137. package/dist/components/date/config.js +18 -0
  138. package/dist/components/date/config.js.map +1 -0
  139. package/dist/components/date/index.d.ts +3 -0
  140. package/dist/components/date/style/index.css +1 -0
  141. package/dist/components/date/types.d.ts +32 -0
  142. package/dist/components/drawer/Drawer.d.ts +332 -0
  143. package/dist/components/drawer/Drawer.js +329 -0
  144. package/dist/components/drawer/Drawer.js.map +1 -0
  145. package/dist/components/drawer/config.d.ts +28 -0
  146. package/dist/components/drawer/config.js +16 -0
  147. package/dist/components/drawer/config.js.map +1 -0
  148. package/dist/components/drawer/index.d.ts +3 -0
  149. package/dist/components/drawer/src/style/drawer.css +1 -0
  150. package/dist/components/ellipsis/Ellipsis.d.ts +74 -0
  151. package/dist/components/ellipsis/Ellipsis.js +103 -0
  152. package/dist/components/ellipsis/Ellipsis.js.map +1 -0
  153. package/dist/components/ellipsis/index.d.ts +1 -0
  154. package/dist/components/ellipsis/style/index.css +1 -0
  155. package/dist/components/empty/Empty.d.ts +92 -0
  156. package/dist/components/empty/Empty.js +85 -0
  157. package/dist/components/empty/Empty.js.map +1 -0
  158. package/dist/components/empty/config.d.ts +23 -0
  159. package/dist/components/empty/config.js +14 -0
  160. package/dist/components/empty/config.js.map +1 -0
  161. package/dist/components/empty/index.d.ts +3 -0
  162. package/dist/components/empty/style/index.css +1 -0
  163. package/dist/components/empty/type.d.ts +9 -0
  164. package/dist/components/equalizer/Equalizer.d.ts +62 -0
  165. package/dist/components/equalizer/Equalizer.js +56 -0
  166. package/dist/components/equalizer/Equalizer.js.map +1 -0
  167. package/dist/components/equalizer/index.d.ts +1 -0
  168. package/dist/components/equalizer/style/index.css +1 -0
  169. package/dist/components/fallback/Fallback.d.ts +44 -0
  170. package/dist/components/fallback/Fallback.js +55 -0
  171. package/dist/components/fallback/Fallback.js.map +1 -0
  172. package/dist/components/fallback/index.d.ts +1 -0
  173. package/dist/components/fallback/style/index.css +1 -0
  174. package/dist/components/form/Form.d.ts +169 -0
  175. package/dist/components/form/Form.js +235 -0
  176. package/dist/components/form/Form.js.map +1 -0
  177. package/dist/components/form/_use/formRules.d.ts +18 -0
  178. package/dist/components/form/_use/formRules.js +80 -0
  179. package/dist/components/form/_use/formRules.js.map +1 -0
  180. package/dist/components/form/config.d.ts +35 -0
  181. package/dist/components/form/config.js +20 -0
  182. package/dist/components/form/config.js.map +1 -0
  183. package/dist/components/form/context.d.ts +34 -0
  184. package/dist/components/form/context.js +8 -0
  185. package/dist/components/form/context.js.map +1 -0
  186. package/dist/components/form/index.d.ts +3 -0
  187. package/dist/components/form/style/index.css +1 -0
  188. package/dist/components/formItem/FormItem.d.ts +144 -0
  189. package/dist/components/formItem/FormItem.js +218 -0
  190. package/dist/components/formItem/FormItem.js.map +1 -0
  191. package/dist/components/formItem/config.d.ts +21 -0
  192. package/dist/components/formItem/config.js +12 -0
  193. package/dist/components/formItem/config.js.map +1 -0
  194. package/dist/components/formItem/context.d.ts +22 -0
  195. package/dist/components/formItem/context.js +8 -0
  196. package/dist/components/formItem/context.js.map +1 -0
  197. package/dist/components/formItem/index.d.ts +3 -0
  198. package/dist/components/formItem/style/index.css +1 -0
  199. package/dist/components/icon/Icon.d.ts +117 -0
  200. package/dist/components/icon/Icon.js +116 -0
  201. package/dist/components/icon/Icon.js.map +1 -0
  202. package/dist/components/icon/config.d.ts +28 -0
  203. package/dist/components/icon/config.js +16 -0
  204. package/dist/components/icon/config.js.map +1 -0
  205. package/dist/components/icon/index.d.ts +4 -0
  206. package/dist/components/icon/style/index.css +1 -0
  207. package/dist/components/icon/type.d.ts +16 -0
  208. package/dist/components/image/Image.d.ts +21 -0
  209. package/dist/components/image/Image.js +68 -0
  210. package/dist/components/image/Image.js.map +1 -0
  211. package/dist/components/image/config.d.ts +21 -0
  212. package/dist/components/image/config.js +11 -0
  213. package/dist/components/image/config.js.map +1 -0
  214. package/dist/components/image/index.d.ts +4 -0
  215. package/dist/components/image/style/index.css +1 -0
  216. package/dist/components/index.d.ts +79 -0
  217. package/dist/components/index.js +124 -0
  218. package/dist/components/index.js.map +1 -0
  219. package/dist/components/layer/Layer.d.ts +410 -0
  220. package/dist/components/layer/Layer.js +557 -0
  221. package/dist/components/layer/Layer.js.map +1 -0
  222. package/dist/components/layer/index.d.ts +2 -0
  223. package/dist/components/layer/injectionKey.d.ts +5 -0
  224. package/dist/components/layer/injectionKey.js +6 -0
  225. package/dist/components/layer/injectionKey.js.map +1 -0
  226. package/dist/components/layer/style/index.css +1 -0
  227. package/dist/components/lcdFont/LcdFont.d.ts +126 -0
  228. package/dist/components/lcdFont/LcdFont.js +232 -0
  229. package/dist/components/lcdFont/LcdFont.js.map +1 -0
  230. package/dist/components/lcdFont/config.d.ts +43 -0
  231. package/dist/components/lcdFont/config.js +41 -0
  232. package/dist/components/lcdFont/config.js.map +1 -0
  233. package/dist/components/lcdFont/format.d.ts +8 -0
  234. package/dist/components/lcdFont/format.js +39 -0
  235. package/dist/components/lcdFont/format.js.map +1 -0
  236. package/dist/components/lcdFont/index.d.ts +5 -0
  237. package/dist/components/lcdFont/segments.d.ts +32 -0
  238. package/dist/components/lcdFont/segments.js +326 -0
  239. package/dist/components/lcdFont/segments.js.map +1 -0
  240. package/dist/components/lcdFont/style/index.css +1 -0
  241. package/dist/components/lcdFont/type.d.ts +26 -0
  242. package/dist/components/list/List.d.ts +480 -0
  243. package/dist/components/list/List.js +289 -0
  244. package/dist/components/list/List.js.map +1 -0
  245. package/dist/components/list/config.d.ts +3 -0
  246. package/dist/components/list/index.d.ts +3 -0
  247. package/dist/components/list/style/index.css +1 -0
  248. package/dist/components/loading/Loading.d.ts +97 -0
  249. package/dist/components/loading/Loading.js +124 -0
  250. package/dist/components/loading/Loading.js.map +1 -0
  251. package/dist/components/loading/config.d.ts +22 -0
  252. package/dist/components/loading/config.js +13 -0
  253. package/dist/components/loading/config.js.map +1 -0
  254. package/dist/components/loading/index.d.ts +3 -0
  255. package/dist/components/loading/style/index.css +1 -0
  256. package/dist/components/loading/type.d.ts +13 -0
  257. package/dist/components/mask/Mask.d.ts +79 -0
  258. package/dist/components/mask/Mask.js +82 -0
  259. package/dist/components/mask/Mask.js.map +1 -0
  260. package/dist/components/mask/config.d.ts +21 -0
  261. package/dist/components/mask/config.js +14 -0
  262. package/dist/components/mask/config.js.map +1 -0
  263. package/dist/components/mask/index.d.ts +3 -0
  264. package/dist/components/mask/style/mask.css +1 -0
  265. package/dist/components/match/Match copy.d.ts +1600 -0
  266. package/dist/components/match/Match.d.ts +1621 -0
  267. package/dist/components/match/Match.js +343 -0
  268. package/dist/components/match/Match.js.map +1 -0
  269. package/dist/components/match/config.d.ts +29 -0
  270. package/dist/components/match/config.js +17 -0
  271. package/dist/components/match/config.js.map +1 -0
  272. package/dist/components/match/index.d.ts +3 -0
  273. package/dist/components/match/style/index.css +1 -0
  274. package/dist/components/modal/Modal.d.ts +460 -0
  275. package/dist/components/modal/Modal.js +297 -0
  276. package/dist/components/modal/Modal.js.map +1 -0
  277. package/dist/components/modal/config.d.ts +33 -0
  278. package/dist/components/modal/config.js +19 -0
  279. package/dist/components/modal/config.js.map +1 -0
  280. package/dist/components/modal/index.d.ts +3 -0
  281. package/dist/components/modal/style/index.css +1 -0
  282. package/dist/components/notice/Notice.d.ts +137 -0
  283. package/dist/components/notice/Notice.js +192 -0
  284. package/dist/components/notice/Notice.js.map +1 -0
  285. package/dist/components/notice/index.d.ts +51 -0
  286. package/dist/components/notice/index.js +243 -0
  287. package/dist/components/notice/index.js.map +1 -0
  288. package/dist/components/notice/src/_util/index.d.ts +11 -0
  289. package/dist/components/notice/src/_util/index.js +50 -0
  290. package/dist/components/notice/src/_util/index.js.map +1 -0
  291. package/dist/components/notice/src/style/index.css +1 -0
  292. package/dist/components/notice/types.d.ts +98 -0
  293. package/dist/components/number/Number copy.d.ts +966 -0
  294. package/dist/components/number/Number.d.ts +1034 -0
  295. package/dist/components/number/Number.js +241 -0
  296. package/dist/components/number/Number.js.map +1 -0
  297. package/dist/components/number/config.d.ts +26 -0
  298. package/dist/components/number/config.js +15 -0
  299. package/dist/components/number/config.js.map +1 -0
  300. package/dist/components/number/index.d.ts +3 -0
  301. package/dist/components/number/style/index.css +1 -0
  302. package/dist/components/pagination/index.d.ts +3 -0
  303. package/dist/components/pagination/src/Pagination.d.ts +2830 -0
  304. package/dist/components/pagination/src/Pagination.js +288 -0
  305. package/dist/components/pagination/src/Pagination.js.map +1 -0
  306. package/dist/components/pagination/src/config.d.ts +25 -0
  307. package/dist/components/pagination/src/config.js +20 -0
  308. package/dist/components/pagination/src/config.js.map +1 -0
  309. package/dist/components/pagination/src/style/index.css +1 -0
  310. package/dist/components/picture/Picture.d.ts +18 -0
  311. package/dist/components/picture/Picture.js +254 -0
  312. package/dist/components/picture/Picture.js.map +1 -0
  313. package/dist/components/picture/PictureToolbar.d.ts +29 -0
  314. package/dist/components/picture/PictureToolbar.js +97 -0
  315. package/dist/components/picture/PictureToolbar.js.map +1 -0
  316. package/dist/components/picture/PictureViewport.d.ts +47 -0
  317. package/dist/components/picture/PictureViewport.js +203 -0
  318. package/dist/components/picture/PictureViewport.js.map +1 -0
  319. package/dist/components/picture/config.d.ts +16 -0
  320. package/dist/components/picture/config.js +16 -0
  321. package/dist/components/picture/config.js.map +1 -0
  322. package/dist/components/picture/index.d.ts +5 -0
  323. package/dist/components/picture/pictureFlip.d.ts +16 -0
  324. package/dist/components/picture/pictureFlip.js +103 -0
  325. package/dist/components/picture/pictureFlip.js.map +1 -0
  326. package/dist/components/picture/style/index.css +1 -0
  327. package/dist/components/progress/Progress.d.ts +94 -0
  328. package/dist/components/progress/Progress.js +112 -0
  329. package/dist/components/progress/Progress.js.map +1 -0
  330. package/dist/components/progress/index.d.ts +1 -0
  331. package/dist/components/progress/style/index.css +1 -0
  332. package/dist/components/radio/Radio.d.ts +112 -0
  333. package/dist/components/radio/Radio.js +130 -0
  334. package/dist/components/radio/Radio.js.map +1 -0
  335. package/dist/components/radio/config.d.ts +29 -0
  336. package/dist/components/radio/config.js +18 -0
  337. package/dist/components/radio/config.js.map +1 -0
  338. package/dist/components/radio/index.d.ts +3 -0
  339. package/dist/components/radio/style/index.css +1 -0
  340. package/dist/components/scrollbar/Scrollbar.d.ts +93 -0
  341. package/dist/components/scrollbar/Scrollbar.js +515 -0
  342. package/dist/components/scrollbar/Scrollbar.js.map +1 -0
  343. package/dist/components/scrollbar/index.d.ts +1 -0
  344. package/dist/components/scrollbar/style/index.css +1 -0
  345. package/dist/components/sheet/Sheet.d.ts +1448 -0
  346. package/dist/components/sheet/Sheet.js +592 -0
  347. package/dist/components/sheet/Sheet.js.map +1 -0
  348. package/dist/components/sheet/_cell.d.ts +181 -0
  349. package/dist/components/sheet/_cell.js +132 -0
  350. package/dist/components/sheet/_cell.js.map +1 -0
  351. package/dist/components/sheet/_props.d.ts +170 -0
  352. package/dist/components/sheet/_props.js +183 -0
  353. package/dist/components/sheet/_props.js.map +1 -0
  354. package/dist/components/sheet/_row.d.ts +2 -0
  355. package/dist/components/sheet/_row.js +14 -0
  356. package/dist/components/sheet/_row.js.map +1 -0
  357. package/dist/components/sheet/_tbody.d.ts +348 -0
  358. package/dist/components/sheet/_tbody.js +255 -0
  359. package/dist/components/sheet/_tbody.js.map +1 -0
  360. package/dist/components/sheet/_tfoot.d.ts +195 -0
  361. package/dist/components/sheet/_tfoot.js +78 -0
  362. package/dist/components/sheet/_tfoot.js.map +1 -0
  363. package/dist/components/sheet/_thead.d.ts +529 -0
  364. package/dist/components/sheet/_thead.js +148 -0
  365. package/dist/components/sheet/_thead.js.map +1 -0
  366. package/dist/components/sheet/_use.d.ts +38 -0
  367. package/dist/components/sheet/_use.js +493 -0
  368. package/dist/components/sheet/_use.js.map +1 -0
  369. package/dist/components/sheet/_util.d.ts +34 -0
  370. package/dist/components/sheet/_util.js +111 -0
  371. package/dist/components/sheet/_util.js.map +1 -0
  372. package/dist/components/sheet/index.d.ts +1 -0
  373. package/dist/components/sheet/style/index.css +1 -0
  374. package/dist/components/slideDown/SlideDown.d.ts +62 -0
  375. package/dist/components/slideDown/SlideDown.js +128 -0
  376. package/dist/components/slideDown/SlideDown.js.map +1 -0
  377. package/dist/components/slideDown/index.d.ts +1 -0
  378. package/dist/components/slider/Slider.d.ts +1726 -0
  379. package/dist/components/slider/Slider.js +471 -0
  380. package/dist/components/slider/Slider.js.map +1 -0
  381. package/dist/components/slider/index.d.ts +1 -0
  382. package/dist/components/slider/style/index.css +1 -0
  383. package/dist/components/svgIcon/SvgIcon.d.ts +37 -0
  384. package/dist/components/svgIcon/SvgIcon.js +78 -0
  385. package/dist/components/svgIcon/SvgIcon.js.map +1 -0
  386. package/dist/components/svgIcon/index.d.ts +3 -0
  387. package/dist/components/svgIcon/style/index.css +1 -0
  388. package/dist/components/switch/Switch.d.ts +105 -0
  389. package/dist/components/switch/Switch.js +158 -0
  390. package/dist/components/switch/Switch.js.map +1 -0
  391. package/dist/components/switch/config.d.ts +16 -0
  392. package/dist/components/switch/config.js +11 -0
  393. package/dist/components/switch/config.js.map +1 -0
  394. package/dist/components/switch/index.d.ts +1 -0
  395. package/dist/components/switch/style/index.css +1 -0
  396. package/dist/components/tab/Tab.d.ts +113 -0
  397. package/dist/components/tab/Tab.js +485 -0
  398. package/dist/components/tab/Tab.js.map +1 -0
  399. package/dist/components/tab/index.d.ts +2 -0
  400. package/dist/components/tab/style/index.css +1 -0
  401. package/dist/components/textarea/Textarea.d.ts +37 -0
  402. package/dist/components/textarea/Textarea.js +193 -0
  403. package/dist/components/textarea/Textarea.js.map +1 -0
  404. package/dist/components/textarea/config.d.ts +30 -0
  405. package/dist/components/textarea/config.js +16 -0
  406. package/dist/components/textarea/config.js.map +1 -0
  407. package/dist/components/textarea/index.d.ts +4 -0
  408. package/dist/components/textarea/style/index.css +1 -0
  409. package/dist/components/time/Dial.js +7 -0
  410. package/dist/components/time/Dial.js.map +1 -0
  411. package/dist/components/time/Dial.vue_vue_type_script_setup_true_lang.js +178 -0
  412. package/dist/components/time/Dial.vue_vue_type_script_setup_true_lang.js.map +1 -0
  413. package/dist/components/time/TimePicker.d.ts +1301 -0
  414. package/dist/components/time/TimePicker.js +162 -0
  415. package/dist/components/time/TimePicker.js.map +1 -0
  416. package/dist/components/time/_use/useTimeModules.d.ts +1 -0
  417. package/dist/components/time/index.d.ts +1 -0
  418. package/dist/components/time/style/dial.css +1 -0
  419. package/dist/components/time/style/index.css +1 -0
  420. package/dist/components/toggle/Toggle.d.ts +140 -0
  421. package/dist/components/toggle/Toggle.js +209 -0
  422. package/dist/components/toggle/Toggle.js.map +1 -0
  423. package/dist/components/toggle/index.d.ts +1 -0
  424. package/dist/components/toggle/style/index.css +1 -0
  425. package/dist/components/toggle/style/scale.css +1 -0
  426. package/dist/components/toggle/style/translate.css +1 -0
  427. package/dist/components/tooltip/Tooltip.d.ts +536 -0
  428. package/dist/components/tooltip/Tooltip.js +51 -0
  429. package/dist/components/tooltip/Tooltip.js.map +1 -0
  430. package/dist/components/tooltip/index.d.ts +1 -0
  431. package/dist/components/tooltip/style/index.css +1 -0
  432. package/dist/components/tree/Tree.d.ts +187 -0
  433. package/dist/components/tree/Tree.js +229 -0
  434. package/dist/components/tree/Tree.js.map +1 -0
  435. package/dist/components/tree/TreeItem.d.ts +86 -0
  436. package/dist/components/tree/TreeItem.js +152 -0
  437. package/dist/components/tree/TreeItem.js.map +1 -0
  438. package/dist/components/tree/TreeList.d.ts +86 -0
  439. package/dist/components/tree/TreeList.js +52 -0
  440. package/dist/components/tree/TreeList.js.map +1 -0
  441. package/dist/components/tree/_use/treeState.d.ts +45 -0
  442. package/dist/components/tree/_use/treeState.js +417 -0
  443. package/dist/components/tree/_use/treeState.js.map +1 -0
  444. package/dist/components/tree/config.d.ts +27 -0
  445. package/dist/components/tree/config.js +16 -0
  446. package/dist/components/tree/config.js.map +1 -0
  447. package/dist/components/tree/index.d.ts +4 -0
  448. package/dist/components/tree/style/index.css +1 -0
  449. package/dist/components/tree-choose/TreeChoose.d.ts +833 -0
  450. package/dist/components/tree-choose/TreeChoose.js +320 -0
  451. package/dist/components/tree-choose/TreeChoose.js.map +1 -0
  452. package/dist/components/tree-choose/config.d.ts +41 -0
  453. package/dist/components/tree-choose/config.js +19 -0
  454. package/dist/components/tree-choose/config.js.map +1 -0
  455. package/dist/components/tree-choose/index.d.ts +4 -0
  456. package/dist/components/tree-choose/style/index.css +1 -0
  457. package/dist/components/trigger/Trigger.d.ts +921 -0
  458. package/dist/components/trigger/Trigger.js +105 -0
  459. package/dist/components/trigger/Trigger.js.map +1 -0
  460. package/dist/components/trigger/index.d.ts +1 -0
  461. package/dist/components/trigger/style/index.css +2 -0
  462. package/dist/components/upload/Upload.d.ts +249 -0
  463. package/dist/components/upload/Upload.js +342 -0
  464. package/dist/components/upload/Upload.js.map +1 -0
  465. package/dist/components/upload/config.d.ts +39 -0
  466. package/dist/components/upload/config.js +21 -0
  467. package/dist/components/upload/config.js.map +1 -0
  468. package/dist/components/upload/index.d.ts +4 -0
  469. package/dist/components/upload/style/index.css +1 -0
  470. package/dist/components/upload/types.d.ts +47 -0
  471. package/dist/components/virtual/Virtual.d.ts +57 -0
  472. package/dist/components/virtual/Virtual.js +62 -0
  473. package/dist/components/virtual/Virtual.js.map +1 -0
  474. package/dist/components/virtual/Virtual/345/216/237/347/211/210.d.ts +44 -0
  475. package/dist/components/virtual/index.d.ts +4 -0
  476. package/dist/components/virtual/style/index.css +1 -0
  477. package/dist/components/virtual/useVirtualList.d.ts +50 -0
  478. package/dist/components/virtual/useVirtualList.js +376 -0
  479. package/dist/components/virtual/useVirtualList.js.map +1 -0
  480. package/dist/components/write/Write.d.ts +532 -0
  481. package/dist/components/write/Write.js +228 -0
  482. package/dist/components/write/Write.js.map +1 -0
  483. package/dist/components/write/index.d.ts +1 -0
  484. package/dist/components/write/style/index.css +1 -0
  485. package/dist/config/dictionary.d.ts +21 -0
  486. package/dist/config/dictionary.js +28 -0
  487. package/dist/config/dictionary.js.map +1 -0
  488. package/dist/config/i18n.d.ts +22 -0
  489. package/dist/config/i18n.js +53 -0
  490. package/dist/config/i18n.js.map +1 -0
  491. package/dist/config/plugin.d.ts +88 -0
  492. package/dist/config/plugin.js +13 -0
  493. package/dist/config/plugin.js.map +1 -0
  494. package/dist/config/types.d.ts +56 -0
  495. package/dist/directives/clickOutside.d.ts +10 -0
  496. package/dist/directives/clickOutside.js +69 -0
  497. package/dist/directives/clickOutside.js.map +1 -0
  498. package/dist/directives/index.d.ts +3 -0
  499. package/dist/directives/index.js +13 -0
  500. package/dist/directives/index.js.map +1 -0
  501. package/dist/directives/loading.d.ts +19 -0
  502. package/dist/directives/loading.js +64 -0
  503. package/dist/directives/loading.js.map +1 -0
  504. package/dist/index.d.ts +127 -0
  505. package/dist/index.js +91 -0
  506. package/dist/locales/de-DE/index.d.ts +144 -0
  507. package/dist/locales/de-DE/index.js +140 -0
  508. package/dist/locales/de-DE/index.js.map +1 -0
  509. package/dist/locales/en-US/index.d.ts +144 -0
  510. package/dist/locales/en-US/index.js +140 -0
  511. package/dist/locales/en-US/index.js.map +1 -0
  512. package/dist/locales/index.d.ts +3 -0
  513. package/dist/locales/zh-CN/index.d.ts +144 -0
  514. package/dist/locales/zh-CN/index.js +140 -0
  515. package/dist/locales/zh-CN/index.js.map +1 -0
  516. package/dist/plugin.d.ts +6 -0
  517. package/dist/plugin.js +38 -0
  518. package/dist/plugin.js.map +1 -0
  519. package/dist/styles/index.css +49 -0
  520. package/dist/theme/_transition.css +169 -0
  521. package/dist/theme/index.css +5 -0
  522. package/dist/theme/tokens/_base.css +7 -0
  523. package/dist/theme/tokens/_common.css +37 -0
  524. package/dist/theme/tokens/_scrollbar.css +53 -0
  525. package/dist/theme/tokens/_size.css +18 -0
  526. package/dist/theme/tokens/_text.css +16 -0
  527. package/dist/theme/tokens/_var.css +1087 -0
  528. package/dist/theme/tokens/components/audioPlayer.css +542 -0
  529. package/dist/theme/tokens/components/btn.css +253 -0
  530. package/dist/theme/tokens/components/btnGroup.css +68 -0
  531. package/dist/theme/tokens/components/cascade.css +77 -0
  532. package/dist/theme/tokens/components/checkbox.css +100 -0
  533. package/dist/theme/tokens/components/choose.css +175 -0
  534. package/dist/theme/tokens/components/choose2.css +242 -0
  535. package/dist/theme/tokens/components/chooseItem.css +54 -0
  536. package/dist/theme/tokens/components/circleProgress.css +61 -0
  537. package/dist/theme/tokens/components/close.css +12 -0
  538. package/dist/theme/tokens/components/colorPicker.css +404 -0
  539. package/dist/theme/tokens/components/confirm.css +128 -0
  540. package/dist/theme/tokens/components/copy.css +80 -0
  541. package/dist/theme/tokens/components/cornerEars.css +102 -0
  542. package/dist/theme/tokens/components/date/days.css +79 -0
  543. package/dist/theme/tokens/components/date/index.css +249 -0
  544. package/dist/theme/tokens/components/date/months.css +68 -0
  545. package/dist/theme/tokens/components/drawer.css +189 -0
  546. package/dist/theme/tokens/components/ellipsis.css +46 -0
  547. package/dist/theme/tokens/components/empty.css +24 -0
  548. package/dist/theme/tokens/components/equalizer.css +51 -0
  549. package/dist/theme/tokens/components/fallback.css +4 -0
  550. package/dist/theme/tokens/components/form.css +50 -0
  551. package/dist/theme/tokens/components/formItem.css +194 -0
  552. package/dist/theme/tokens/components/icon.css +41 -0
  553. package/dist/theme/tokens/components/image.css +70 -0
  554. package/dist/theme/tokens/components/layer.css +190 -0
  555. package/dist/theme/tokens/components/lcdFont.css +121 -0
  556. package/dist/theme/tokens/components/list.css +97 -0
  557. package/dist/theme/tokens/components/loading.css +64 -0
  558. package/dist/theme/tokens/components/mask.css +26 -0
  559. package/dist/theme/tokens/components/match.css +119 -0
  560. package/dist/theme/tokens/components/modal.css +136 -0
  561. package/dist/theme/tokens/components/notice.css +264 -0
  562. package/dist/theme/tokens/components/number.css +150 -0
  563. package/dist/theme/tokens/components/pagination.css +215 -0
  564. package/dist/theme/tokens/components/picture.css +299 -0
  565. package/dist/theme/tokens/components/progress.css +101 -0
  566. package/dist/theme/tokens/components/radio.css +183 -0
  567. package/dist/theme/tokens/components/scrollbar.css +160 -0
  568. package/dist/theme/tokens/components/sheet.css +518 -0
  569. package/dist/theme/tokens/components/slider.css +171 -0
  570. package/dist/theme/tokens/components/svgIcon.css +6 -0
  571. package/dist/theme/tokens/components/switch.css +67 -0
  572. package/dist/theme/tokens/components/tab.css +215 -0
  573. package/dist/theme/tokens/components/textarea.css +109 -0
  574. package/dist/theme/tokens/components/time/dial.css +123 -0
  575. package/dist/theme/tokens/components/time/index.css +29 -0
  576. package/dist/theme/tokens/components/toggle/index.css +14 -0
  577. package/dist/theme/tokens/components/toggle/scale.css +34 -0
  578. package/dist/theme/tokens/components/toggle/translate.css +41 -0
  579. package/dist/theme/tokens/components/tooltip.css +77 -0
  580. package/dist/theme/tokens/components/tree-choose.css +154 -0
  581. package/dist/theme/tokens/components/tree.css +172 -0
  582. package/dist/theme/tokens/components/trigger.css +90 -0
  583. package/dist/theme/tokens/components/upload.css +302 -0
  584. package/dist/theme/tokens/components/virtual.css +6 -0
  585. package/dist/theme/tokens/components/write.css +155 -0
  586. package/dist/theme/tokens/iconfont/iconfont.css +103 -0
  587. package/dist/theme/tokens/iconfont/iconfont.ttf +0 -0
  588. package/dist/theme/tokens/iconfont/iconfont.woff +0 -0
  589. package/dist/theme/tokens/iconfont/iconfont.woff2 +0 -0
  590. package/dist/theme/tokens/index.css +19 -0
  591. package/dist/use/index.d.ts +34 -0
  592. package/dist/use/toggle/types.d.ts +27 -0
  593. package/dist/use/toggle/useToggle.d.ts +22 -0
  594. package/dist/use/toggle/useToggleArray.d.ts +14 -0
  595. package/dist/use/toggle/useToggleArray.js +36 -0
  596. package/dist/use/toggle/useToggleArray.js.map +1 -0
  597. package/dist/use/toggle/useToggleCycle.d.ts +11 -0
  598. package/dist/use/toggle/useToggleCycle.js +88 -0
  599. package/dist/use/toggle/useToggleCycle.js.map +1 -0
  600. package/dist/use/toggle/useToggleMap.d.ts +10 -0
  601. package/dist/use/toggle/useToggleObject.d.ts +13 -0
  602. package/dist/use/useAudioPlayer.d.ts +160 -0
  603. package/dist/use/useAudioPlayer.js +799 -0
  604. package/dist/use/useAudioPlayer.js.map +1 -0
  605. package/dist/use/useBoundingClientRect.d.ts +14 -0
  606. package/dist/use/useBoundingClientRect.js +54 -0
  607. package/dist/use/useBoundingClientRect.js.map +1 -0
  608. package/dist/use/useChildComponentsCollector.js +30 -0
  609. package/dist/use/useChildComponentsCollector.js.map +1 -0
  610. package/dist/use/useComponentClass.d.ts +1 -0
  611. package/dist/use/useComponentClass.js +6 -0
  612. package/dist/use/useComponentClass.js.map +1 -0
  613. package/dist/use/useComponentConfig.d.ts +10 -0
  614. package/dist/use/useComponentConfig.js +31 -0
  615. package/dist/use/useComponentConfig.js.map +1 -0
  616. package/dist/use/useCount.d.ts +13 -0
  617. package/dist/use/useCount.js +36 -0
  618. package/dist/use/useCount.js.map +1 -0
  619. package/dist/use/useDate.d.ts +53 -0
  620. package/dist/use/useDate.js +280 -0
  621. package/dist/use/useDate.js.map +1 -0
  622. package/dist/use/useDelay.d.ts +5 -0
  623. package/dist/use/useDelay.js +38 -0
  624. package/dist/use/useDelay.js.map +1 -0
  625. package/dist/use/useDrag.d.ts +17 -0
  626. package/dist/use/useElement.d.ts +15 -0
  627. package/dist/use/useElement.js +41 -0
  628. package/dist/use/useElement.js.map +1 -0
  629. package/dist/use/useEscStack.d.ts +14 -0
  630. package/dist/use/useEscStack.js +62 -0
  631. package/dist/use/useEscStack.js.map +1 -0
  632. package/dist/use/useEvent.d.ts +9 -0
  633. package/dist/use/useEvent.js +43 -0
  634. package/dist/use/useEvent.js.map +1 -0
  635. package/dist/use/useFormItem.d.ts +9 -0
  636. package/dist/use/useFormItem.js +20 -0
  637. package/dist/use/useFormItem.js.map +1 -0
  638. package/dist/use/useGlobalZIndex.d.ts +6 -0
  639. package/dist/use/useGlobalZIndex.js +28 -0
  640. package/dist/use/useGlobalZIndex.js.map +1 -0
  641. package/dist/use/useMouse.d.ts +15 -0
  642. package/dist/use/useMouse.js +36 -0
  643. package/dist/use/useMouse.js.map +1 -0
  644. package/dist/use/useMousePositionInElement.d.ts +6 -0
  645. package/dist/use/useMousePositionInElement.js +27 -0
  646. package/dist/use/useMousePositionInElement.js.map +1 -0
  647. package/dist/use/useParentNode.d.ts +3 -0
  648. package/dist/use/useParentNode.js +25 -0
  649. package/dist/use/useParentNode.js.map +1 -0
  650. package/dist/use/usePercentDrag.d.ts +20 -0
  651. package/dist/use/usePercentDrag.js +59 -0
  652. package/dist/use/usePercentDrag.js.map +1 -0
  653. package/dist/use/usePictureViewport.d.ts +57 -0
  654. package/dist/use/usePictureViewport.js +229 -0
  655. package/dist/use/usePictureViewport.js.map +1 -0
  656. package/dist/use/useRequest.d.ts +7 -0
  657. package/dist/use/useRequest.js +31 -0
  658. package/dist/use/useRequest.js.map +1 -0
  659. package/dist/use/useScaleFromPoint.d.ts +57 -0
  660. package/dist/use/useScaleFromPoint.js +325 -0
  661. package/dist/use/useScaleFromPoint.js.map +1 -0
  662. package/dist/use/useScroll.d.ts +9 -0
  663. package/dist/use/useScroll.js +60 -0
  664. package/dist/use/useScroll.js.map +1 -0
  665. package/dist/use/useSearch.d.ts +11 -0
  666. package/dist/use/useSearch.js +65 -0
  667. package/dist/use/useSearch.js.map +1 -0
  668. package/dist/use/useSlot.d.ts +10 -0
  669. package/dist/use/useSlot.js +57 -0
  670. package/dist/use/useSlot.js.map +1 -0
  671. package/dist/use/useTabIndex.d.ts +1 -0
  672. package/dist/use/useTabIndex.js +18 -0
  673. package/dist/use/useTabIndex.js.map +1 -0
  674. package/dist/use/useUII18n.js +26 -0
  675. package/dist/use/useUII18n.js.map +1 -0
  676. package/dist/use/useUpload.d.ts +49 -0
  677. package/dist/use/useUpload.js +396 -0
  678. package/dist/use/useUpload.js.map +1 -0
  679. package/dist/use/useVisibleResize.d.ts +6 -0
  680. package/dist/use/useVisibleResize.js +77 -0
  681. package/dist/use/useVisibleResize.js.map +1 -0
  682. package/dist/util/calc.d.ts +40 -0
  683. package/dist/util/calc.js +239 -0
  684. package/dist/util/calc.js.map +1 -0
  685. package/dist/util/colors.d.ts +78 -0
  686. package/dist/util/colors.js +320 -0
  687. package/dist/util/colors.js.map +1 -0
  688. package/dist/util/cssVars.d.ts +62 -0
  689. package/dist/util/cssVars.js +170 -0
  690. package/dist/util/cssVars.js.map +1 -0
  691. package/dist/util/dom.d.ts +65 -0
  692. package/dist/util/dom.js +212 -0
  693. package/dist/util/dom.js.map +1 -0
  694. package/dist/util/index.d.ts +5 -0
  695. package/dist/util/tools.d.ts +54 -0
  696. package/dist/util/tools.js +90 -0
  697. package/dist/util/tools.js.map +1 -0
  698. package/dist/util/vnode.d.ts +2 -0
  699. package/package.json +88 -0
@@ -0,0 +1,192 @@
1
+ import Icon_default from "../icon/Icon.js";
2
+ import { getBoundingClientRect } from "../../util/dom.js";
3
+ import { mergeStyle, propColorToCssVars, propSizeToCssVars, toCssVarsStyle } from "../../util/cssVars.js";
4
+ import Close_default from "../close/Close.js";
5
+ import { Transition, computed, createVNode, defineComponent, getCurrentInstance, onMounted, onUnmounted, ref, watch } from "vue";
6
+ //#region components/notice/Notice.tsx
7
+ var TYPE_ICON_MAP = {
8
+ info: "w-icon-warning",
9
+ success: "w-icon-duihao",
10
+ warning: "w-icon-warning",
11
+ error: "w-icon-close-fill"
12
+ };
13
+ /** 退场前锁死当前高度,好让 height → 0 能过渡 */
14
+ function lockLeaveHeight(el) {
15
+ const h = getBoundingClientRect(el).height;
16
+ if (h > 0) {
17
+ el.style.setProperty("--__notice-item-height", `${h}px`);
18
+ el.style.height = `${h}px`;
19
+ el.offsetHeight;
20
+ }
21
+ }
22
+ var Notice_default = /* @__PURE__ */ defineComponent({
23
+ inheritAttrs: false,
24
+ name: "Notice",
25
+ props: {
26
+ show: {
27
+ type: Boolean,
28
+ default: false
29
+ },
30
+ placement: {
31
+ type: String,
32
+ default: "top-end"
33
+ },
34
+ duration: {
35
+ type: Number,
36
+ default: 4500
37
+ },
38
+ manual: {
39
+ type: Boolean,
40
+ default: false
41
+ },
42
+ showClose: {
43
+ type: Boolean,
44
+ default: true
45
+ },
46
+ type: {
47
+ type: String,
48
+ default: "default"
49
+ },
50
+ title: { type: [
51
+ String,
52
+ Object,
53
+ Function
54
+ ] },
55
+ icon: {
56
+ type: [
57
+ String,
58
+ Boolean,
59
+ Object,
60
+ Function
61
+ ],
62
+ default: void 0
63
+ },
64
+ itemClass: { type: [
65
+ String,
66
+ Object,
67
+ Array
68
+ ] },
69
+ itemStyle: { type: Object },
70
+ hoverKeep: {
71
+ type: Boolean,
72
+ default: true
73
+ },
74
+ color: {
75
+ type: String,
76
+ default: void 0
77
+ },
78
+ /** 实例尺度(px)→ `--w-prop-notice-size` */
79
+ size: {
80
+ type: Number,
81
+ default: void 0
82
+ },
83
+ /** 实例 CSS 变量 */
84
+ cssVars: {
85
+ type: Object,
86
+ default: void 0
87
+ }
88
+ },
89
+ emits: [
90
+ "update:show",
91
+ "after-enter",
92
+ "after-leave",
93
+ "close",
94
+ "get-uid",
95
+ "closing"
96
+ ],
97
+ setup(props, { emit, slots, expose }) {
98
+ const ins = getCurrentInstance();
99
+ const visible = ref(props.show);
100
+ let timer = null;
101
+ const isManual = computed(() => props.manual || !props.duration || props.duration <= 0);
102
+ function clearTimer() {
103
+ if (timer != null) {
104
+ clearTimeout(timer);
105
+ timer = null;
106
+ }
107
+ }
108
+ function startTimer() {
109
+ clearTimer();
110
+ if (isManual.value) return;
111
+ timer = setTimeout(() => {
112
+ visible.value = false;
113
+ }, props.duration);
114
+ }
115
+ function close() {
116
+ if (!visible.value) return;
117
+ emit("closing");
118
+ clearTimer();
119
+ visible.value = false;
120
+ }
121
+ emit("close", close);
122
+ emit("get-uid", ins?.uid);
123
+ watch(() => props.show, (s) => {
124
+ visible.value = s;
125
+ });
126
+ watch(visible, (v) => {
127
+ emit("update:show", v);
128
+ if (v) startTimer();
129
+ else clearTimer();
130
+ });
131
+ onMounted(() => {
132
+ visible.value = true;
133
+ });
134
+ onUnmounted(() => {
135
+ clearTimer();
136
+ });
137
+ expose({ close });
138
+ function renderIcon() {
139
+ const { icon, type } = props;
140
+ if (icon === false) return null;
141
+ if (typeof icon === "function") return createVNode("div", { "class": "w-notice-icon" }, [icon()]);
142
+ if (icon !== void 0 && icon !== true && typeof icon !== "string") return createVNode("div", { "class": "w-notice-icon" }, [icon]);
143
+ const name = typeof icon === "string" ? icon : type !== "default" ? TYPE_ICON_MAP[type] : "";
144
+ if (!name) return null;
145
+ return createVNode("div", { "class": "w-notice-icon" }, [createVNode(Icon_default, { "name": name }, null)]);
146
+ }
147
+ function onMouseEnter() {
148
+ if (props.hoverKeep && !isManual.value) clearTimer();
149
+ }
150
+ function onMouseLeave() {
151
+ if (props.hoverKeep && !isManual.value && visible.value) startTimer();
152
+ }
153
+ return () => {
154
+ const style = mergeStyle(toCssVarsStyle({
155
+ ...propSizeToCssVars("notice", props.size),
156
+ ...propColorToCssVars("notice", props.color),
157
+ ...props.cssVars
158
+ }), props.itemStyle);
159
+ return createVNode(Transition, {
160
+ "name": "w-notice-transition",
161
+ "onBefore-leave": (el) => {
162
+ lockLeaveHeight(el);
163
+ },
164
+ "onAfter-enter": (el) => {
165
+ emit("after-enter", el);
166
+ },
167
+ "onAfter-leave": (el) => {
168
+ emit("after-leave", el, ins?.uid);
169
+ }
170
+ }, { default: () => [visible.value && createVNode("div", {
171
+ "class": [
172
+ "w-notice-item",
173
+ `w-notice-item--${props.placement}`,
174
+ `w-notice-item--${props.type}`,
175
+ props.itemClass
176
+ ],
177
+ "style": style,
178
+ "role": "alert",
179
+ "onMouseenter": onMouseEnter,
180
+ "onMouseleave": onMouseLeave
181
+ }, [createVNode("div", { "class": "w-notice-inner" }, [renderIcon(), createVNode("div", { "class": "w-notice-body" }, [props.title != null && props.title !== false && createVNode("div", { "class": "w-notice-title" }, [props.title]), createVNode("div", { "class": "w-notice-content" }, [slots.default?.()])])]), props.showClose && createVNode(Close_default, {
182
+ "name": "w-icon-close-fill",
183
+ "class": "w-notice-close",
184
+ "onClick": close
185
+ }, null)])] });
186
+ };
187
+ }
188
+ });
189
+ //#endregion
190
+ export { Notice_default as default };
191
+
192
+ //# sourceMappingURL=Notice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Notice.js","names":["defineComponent","getCurrentInstance","onMounted","onUnmounted","ref","Transition","watch","computed","createVNode","_createVNode","Icon","getBoundingClientRect","mergeStyle","propColorToCssVars","propSizeToCssVars","toCssVarsStyle","Close","TYPE_ICON_MAP","info","success","warning","error","lockLeaveHeight","el","h","height","style","setProperty","offsetHeight","inheritAttrs","name","props","show","type","Boolean","default","placement","String","duration","Number","manual","showClose","title","Object","Function","icon","undefined","itemClass","Array","itemStyle","hoverKeep","color","size","cssVars","emits","setup","emit","slots","expose","ins","visible","timer","isManual","clearTimer","clearTimeout","startTimer","value","setTimeout","close","uid","s","v","renderIcon","onMouseEnter","onMouseLeave"],"sources":["../../../components/notice/Notice.tsx"],"sourcesContent":["import {\r\n defineComponent,\r\n getCurrentInstance,\r\n onMounted,\r\n onUnmounted,\r\n ref,\r\n Transition,\r\n watch,\r\n computed,\r\n} from 'vue'\r\nimport type { PropType, CSSProperties, VNodeChild } from 'vue'\r\nimport Icon from '../icon'\r\nimport { getBoundingClientRect, mergeStyle, propColorToCssVars, propSizeToCssVars, toCssVarsStyle, type CssVars } from '../../util'\r\nimport Close from '../close'\r\nimport type { NoticePlacementType, NoticeType } from './types'\r\n\r\nconst TYPE_ICON_MAP: Record<Exclude<NoticeType, 'default'>, string> = {\r\n info: 'w-icon-warning',\r\n success: 'w-icon-duihao',\r\n warning: 'w-icon-warning',\r\n error: 'w-icon-close-fill',\r\n}\r\n\r\n/** 退场前锁死当前高度,好让 height → 0 能过渡 */\r\nfunction lockLeaveHeight(el: HTMLElement) {\r\n const h = getBoundingClientRect(el).height\r\n if (h > 0) {\r\n el.style.setProperty('--__notice-item-height', `${h}px`)\r\n el.style.height = `${h}px`\r\n void el.offsetHeight\r\n }\r\n}\r\n\r\nexport default defineComponent({\r\n inheritAttrs: false,\r\n name: 'Notice',\r\n props: {\r\n show: { type: Boolean, default: false },\r\n placement: {\r\n type: String as PropType<NoticePlacementType>,\r\n default: 'top-end',\r\n },\r\n duration: { type: Number, default: 4500 },\r\n manual: { type: Boolean, default: false },\r\n showClose: { type: Boolean, default: true },\r\n type: {\r\n type: String as PropType<NoticeType>,\r\n default: 'default',\r\n },\r\n title: { type: [String, Object, Function] as PropType<VNodeChild> },\r\n icon: {\r\n type: [String, Boolean, Object, Function] as PropType<\r\n string | boolean | VNodeChild | (() => VNodeChild)\r\n >,\r\n default: undefined,\r\n },\r\n itemClass: { type: [String, Object, Array] as PropType<any> },\r\n itemStyle: {\r\n type: Object as PropType<CSSProperties | Record<string, string>>,\r\n },\r\n hoverKeep: { type: Boolean, default: true },\r\n color: { type: String, default: undefined },\r\n /** 实例尺度(px)→ `--w-prop-notice-size` */\r\n size: { type: Number, default: undefined },\r\n /** 实例 CSS 变量 */\r\n cssVars: { type: Object as PropType<CssVars>, default: undefined },\r\n },\r\n emits: ['update:show', 'after-enter', 'after-leave', 'close', 'get-uid', 'closing'],\r\n setup(props, { emit, slots, expose }) {\r\n const ins = getCurrentInstance()\r\n const visible = ref(props.show)\r\n let timer: ReturnType<typeof setTimeout> | null = null\r\n\r\n const isManual = computed(\r\n () => props.manual || !props.duration || props.duration <= 0,\r\n )\r\n\r\n function clearTimer() {\r\n if (timer != null) {\r\n clearTimeout(timer)\r\n timer = null\r\n }\r\n }\r\n\r\n function startTimer() {\r\n clearTimer()\r\n if (isManual.value) return\r\n timer = setTimeout(() => {\r\n visible.value = false\r\n }, props.duration)\r\n }\r\n\r\n function close() {\r\n if (!visible.value) return\r\n emit('closing')\r\n clearTimer()\r\n visible.value = false\r\n }\r\n\r\n emit('close', close)\r\n emit('get-uid', ins?.uid as number)\r\n\r\n watch(\r\n () => props.show,\r\n (s) => {\r\n visible.value = s\r\n },\r\n )\r\n\r\n watch(visible, (v) => {\r\n emit('update:show', v)\r\n if (v) {\r\n startTimer()\r\n } else {\r\n clearTimer()\r\n }\r\n })\r\n\r\n onMounted(() => {\r\n visible.value = true\r\n })\r\n\r\n onUnmounted(() => {\r\n clearTimer()\r\n })\r\n\r\n expose({ close })\r\n\r\n function renderIcon() {\r\n const { icon, type } = props\r\n if (icon === false) return null\r\n\r\n if (typeof icon === 'function') {\r\n return <div class=\"w-notice-icon\">{(icon as () => VNodeChild)()}</div>\r\n }\r\n\r\n if (icon !== undefined && icon !== true && typeof icon !== 'string') {\r\n return <div class=\"w-notice-icon\">{icon}</div>\r\n }\r\n\r\n const name =\r\n typeof icon === 'string'\r\n ? icon\r\n : type !== 'default'\r\n ? TYPE_ICON_MAP[type]\r\n : ''\r\n\r\n if (!name) return null\r\n\r\n return (\r\n <div class=\"w-notice-icon\">\r\n <Icon name={name} />\r\n </div>\r\n )\r\n }\r\n\r\n function onMouseEnter() {\r\n if (props.hoverKeep && !isManual.value) clearTimer()\r\n }\r\n\r\n function onMouseLeave() {\r\n if (props.hoverKeep && !isManual.value && visible.value) startTimer()\r\n }\r\n\r\n return () => {\r\n const style = mergeStyle(\r\n toCssVarsStyle({\r\n ...propSizeToCssVars('notice', props.size),\r\n ...propColorToCssVars('notice', props.color),\r\n ...props.cssVars,\r\n }),\r\n props.itemStyle as Record<string, string> | undefined,\r\n )\r\n\r\n return (\r\n <Transition\r\n name=\"w-notice-transition\"\r\n onBefore-leave={(el: Element) => {\r\n lockLeaveHeight(el as HTMLElement)\r\n }}\r\n onAfter-enter={(el: Element) => {\r\n emit('after-enter', el as HTMLElement)\r\n }}\r\n onAfter-leave={(el: Element) => {\r\n emit('after-leave', el as HTMLElement, ins?.uid)\r\n }}>\r\n {visible.value && (\r\n <div\r\n class={[\r\n 'w-notice-item',\r\n `w-notice-item--${props.placement}`,\r\n `w-notice-item--${props.type}`,\r\n props.itemClass,\r\n ]}\r\n style={style}\r\n role=\"alert\"\r\n onMouseenter={onMouseEnter}\r\n onMouseleave={onMouseLeave}>\r\n <div class=\"w-notice-inner\">\r\n {renderIcon()}\r\n <div class=\"w-notice-body\">\r\n {props.title != null && props.title !== false && (\r\n <div class=\"w-notice-title\">{props.title as any}</div>\r\n )}\r\n <div class=\"w-notice-content\">{slots.default?.()}</div>\r\n </div>\r\n </div>\r\n {props.showClose && (\r\n <Close\r\n name=\"w-icon-close-fill\"\r\n class=\"w-notice-close\"\r\n onClick={close}\r\n />\r\n )}\r\n </div>\r\n )}\r\n </Transition>\r\n )\r\n }\r\n },\r\n})\r\n\r\nexport type {\r\n NoticePlacementType,\r\n NoticeOptions,\r\n NoticeType,\r\n} from './types'\r\n"],"mappings":";;;;;;AAgBA,IAAMiB,gBAAgE;CACpEC,MAAM;CACNC,SAAS;CACTC,SAAS;CACTC,OAAO;AACT;;AAGA,SAASC,gBAAgBC,IAAiB;CACxC,MAAMC,IAAIb,sBAAsBY,EAAE,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IAAA,CAEjB,CAAA,CAEJ,EAAA,CAAA;EAGP;CACF;AACF,CAAC"}
@@ -0,0 +1,51 @@
1
+ import { App } from 'vue';
2
+ import { NoticeOptions, NoticeGlobalConfig, NoticeInstance, NoticeShortcut } from './types';
3
+ export type { NoticeOptions, NoticeGlobalConfig, NoticeInstance, NoticeApi, NoticeContent, NoticeClose, NoticePlacementType, NoticeType, NoticeShortcut, } from './types';
4
+ /**
5
+ * 运行时 / 全局默认配置
6
+ * 也可通过 `app.use(UI, { components: { Notice: {...} } })` 注入
7
+ *
8
+ * @example
9
+ * config({ placement: 'bottom-end', duration: 2500, maxCount: 3 })
10
+ */
11
+ declare function config(options?: NoticeGlobalConfig): void;
12
+ /**
13
+ * 打开通知。返回实例,优先用 `instance.close()` 关闭。
14
+ *
15
+ * @example
16
+ * const n = open({ content: '已保存', duration: 3000 })
17
+ * n.close()
18
+ *
19
+ * @example
20
+ * // 同 key 会立刻替换旧通知(适合上传进度)
21
+ * open({ key: 'upload', content: '30%', manual: true })
22
+ * open({ key: 'upload', content: '完成', duration: 2000 })
23
+ */
24
+ declare function open(options: NoticeOptions): NoticeInstance;
25
+ /**
26
+ * 关闭指定通知(带动画)。更推荐直接 `instance.close()`。
27
+ */
28
+ declare function close(app: App): void;
29
+ /** 关闭全部通知(带动画) */
30
+ declare function closeAll(): void;
31
+ declare const success: NoticeShortcut;
32
+ declare const info: NoticeShortcut;
33
+ declare const warning: NoticeShortcut;
34
+ declare const error: NoticeShortcut;
35
+ /**
36
+ * Vue 插件安装:挂载 `$notice`,并读取 UI 全局 `components.Notice` 配置
37
+ */
38
+ declare function install(app: App): void;
39
+ declare const NoticePlugin: {
40
+ install: typeof install;
41
+ open: typeof open;
42
+ close: typeof close;
43
+ closeAll: typeof closeAll;
44
+ config: typeof config;
45
+ success: NoticeShortcut;
46
+ info: NoticeShortcut;
47
+ warning: NoticeShortcut;
48
+ error: NoticeShortcut;
49
+ };
50
+ export default NoticePlugin;
51
+ export { open, close, closeAll, config, success, info, warning, error };
@@ -0,0 +1,243 @@
1
+ import { UI_CONFIG_KEY } from "../../config/plugin.js";
2
+ import Notice_default from "./Notice.js";
3
+ import { clearNoticeWrapper, createNoticeWrapper } from "./src/_util/index.js";
4
+ import { createApp, createVNode } from "vue";
5
+ import "./src/style/index.css";
6
+ //#region components/notice/index.ts
7
+ var NoticeAppMap = /* @__PURE__ */ new Map();
8
+ var NoticeKeyMap = /* @__PURE__ */ new Map();
9
+ var hostApp = null;
10
+ var defaultOptions = {
11
+ placement: "top-end",
12
+ duration: 4500,
13
+ manual: false,
14
+ showClose: true,
15
+ type: "default",
16
+ hoverKeep: true
17
+ };
18
+ var globalConfig = {};
19
+ /**
20
+ * 运行时 / 全局默认配置
21
+ * 也可通过 `app.use(UI, { components: { Notice: {...} } })` 注入
22
+ *
23
+ * @example
24
+ * config({ placement: 'bottom-end', duration: 2500, maxCount: 3 })
25
+ */
26
+ function config(options = {}) {
27
+ globalConfig = {
28
+ ...globalConfig,
29
+ ...options
30
+ };
31
+ }
32
+ function getMergedOptions(options) {
33
+ return {
34
+ ...defaultOptions,
35
+ ...globalConfig,
36
+ ...options
37
+ };
38
+ }
39
+ function runAfterClose(record) {
40
+ if (!record || record.afterCloseCalled) return;
41
+ record.afterCloseCalled = true;
42
+ record.afterClose?.();
43
+ }
44
+ function inheritAppContext(notice) {
45
+ if (!hostApp) return;
46
+ notice._context.provides = Object.create(hostApp._context.provides);
47
+ }
48
+ function enforceMaxCount(placement) {
49
+ const maxCount = globalConfig.maxCount;
50
+ if (!maxCount || maxCount <= 0) return;
51
+ const samePlacement = [];
52
+ NoticeAppMap.forEach((record) => {
53
+ if (record.noticeWrapper.classList.contains(`w-notice--${placement}`)) samePlacement.push(record);
54
+ });
55
+ const overflow = samePlacement.length + 1 - maxCount;
56
+ if (overflow <= 0) return;
57
+ samePlacement.slice(0, overflow).forEach((record) => {
58
+ record.close();
59
+ });
60
+ }
61
+ /** 跳过退场动画立刻拆掉(同 key 替换用,避免新旧叠动画) */
62
+ function destroyImmediate(uid) {
63
+ const record = NoticeAppMap.get(uid);
64
+ if (!record) return;
65
+ _destroy(record.noticeWrapper, record.itemWrapper, record.app, uid);
66
+ if (NoticeAppMap.size === 0) clearNoticeWrapper();
67
+ }
68
+ /**
69
+ * 打开通知。返回实例,优先用 `instance.close()` 关闭。
70
+ *
71
+ * @example
72
+ * const n = open({ content: '已保存', duration: 3000 })
73
+ * n.close()
74
+ *
75
+ * @example
76
+ * // 同 key 会立刻替换旧通知(适合上传进度)
77
+ * open({ key: 'upload', content: '30%', manual: true })
78
+ * open({ key: 'upload', content: '完成', duration: 2000 })
79
+ */
80
+ function open(options) {
81
+ const { placement = defaultOptions.placement, manual, duration, content, showClose, afterClose, onClose, type, title, icon, class: itemClass, style: itemStyle, wrapperClass, wrapperStyle, offset, zIndex, key, hoverKeep, color, size, cssVars } = getMergedOptions(options);
82
+ if (key !== void 0 && NoticeKeyMap.has(key)) destroyImmediate(NoticeKeyMap.get(key));
83
+ enforceMaxCount(placement);
84
+ const itemWrapper = document.createElement("div");
85
+ const noticeWrapper = createNoticeWrapper(placement, {
86
+ offset: offset ?? globalConfig.offset,
87
+ zIndex: zIndex ?? globalConfig.zIndex,
88
+ wrapperClass: wrapperClass ?? globalConfig.wrapperClass,
89
+ wrapperStyle: wrapperStyle || globalConfig.wrapperStyle
90
+ });
91
+ const closeRef = { current: () => {} };
92
+ let notice;
93
+ const vm = createVNode(Notice_default, {
94
+ placement,
95
+ manual,
96
+ duration,
97
+ showClose,
98
+ type,
99
+ title,
100
+ icon,
101
+ itemClass: itemClass ?? globalConfig.class,
102
+ itemStyle: itemStyle ?? globalConfig.style,
103
+ hoverKeep,
104
+ color,
105
+ size,
106
+ cssVars,
107
+ onClosing: () => {
108
+ onClose?.();
109
+ },
110
+ "onAfter-leave": (_el, uid) => {
111
+ const record = NoticeAppMap.get(uid);
112
+ _destroy(noticeWrapper, itemWrapper, notice, uid);
113
+ runAfterClose(record);
114
+ if (NoticeAppMap.size === 0) clearNoticeWrapper();
115
+ },
116
+ onClose: (closeFn) => {
117
+ closeRef.current = closeFn;
118
+ },
119
+ "onGet-uid": (uid) => {
120
+ NoticeAppMap.set(uid, {
121
+ noticeWrapper,
122
+ itemWrapper,
123
+ close: () => closeRef.current(),
124
+ afterClose,
125
+ key,
126
+ app: notice
127
+ });
128
+ if (key !== void 0) NoticeKeyMap.set(key, uid);
129
+ }
130
+ }, { default: () => {
131
+ if (typeof content === "function") return content(() => closeRef.current());
132
+ return content;
133
+ } });
134
+ notice = createApp(vm);
135
+ inheritAppContext(notice);
136
+ notice.close = () => close(notice);
137
+ notice.mount(itemWrapper);
138
+ noticeWrapper.appendChild(itemWrapper);
139
+ return notice;
140
+ }
141
+ /**
142
+ * 关闭指定通知(带动画)。更推荐直接 `instance.close()`。
143
+ */
144
+ function close(app) {
145
+ const uid = app._instance?.uid;
146
+ if (uid === void 0) return;
147
+ const record = NoticeAppMap.get(uid);
148
+ if (!record) return;
149
+ record.close();
150
+ }
151
+ /** 关闭全部通知(带动画) */
152
+ function closeAll() {
153
+ Array.from(NoticeAppMap.values()).forEach((record) => {
154
+ record.close();
155
+ });
156
+ }
157
+ function isPlainOptions(input) {
158
+ if (input == null || typeof input !== "object" || Array.isArray(input) || input.__v_isVNode) return false;
159
+ return [
160
+ "content",
161
+ "title",
162
+ "placement",
163
+ "duration",
164
+ "manual",
165
+ "showClose",
166
+ "class",
167
+ "style",
168
+ "icon",
169
+ "key",
170
+ "wrapperClass",
171
+ "wrapperStyle",
172
+ "offset",
173
+ "zIndex",
174
+ "hoverKeep",
175
+ "color",
176
+ "size",
177
+ "cssVars",
178
+ "afterClose",
179
+ "onClose"
180
+ ].some((k) => k in input);
181
+ }
182
+ function createShortcut(type) {
183
+ return (content, options) => {
184
+ if (isPlainOptions(content)) return open({
185
+ ...content,
186
+ type,
187
+ content: content.content ?? ""
188
+ });
189
+ return open({
190
+ ...options,
191
+ type,
192
+ content
193
+ });
194
+ };
195
+ }
196
+ var success = createShortcut("success");
197
+ var info = createShortcut("info");
198
+ var warning = createShortcut("warning");
199
+ var error = createShortcut("error");
200
+ /**
201
+ * Vue 插件安装:挂载 `$notice`,并读取 UI 全局 `components.Notice` 配置
202
+ */
203
+ function install(app) {
204
+ hostApp = app;
205
+ const noticeCfg = app._context.provides[UI_CONFIG_KEY]?.components?.Notice;
206
+ if (noticeCfg) config(noticeCfg);
207
+ const api = {
208
+ open,
209
+ close,
210
+ closeAll,
211
+ config,
212
+ success,
213
+ info,
214
+ warning,
215
+ error
216
+ };
217
+ app.config.globalProperties.$notice = api;
218
+ }
219
+ function _destroy(noticeWrapper, wrapper, app_notice, uid) {
220
+ const id = uid ?? app_notice._instance?.uid;
221
+ if (id !== void 0) {
222
+ const record = NoticeAppMap.get(id);
223
+ if (record?.key !== void 0 && NoticeKeyMap.get(record.key) === id) NoticeKeyMap.delete(record.key);
224
+ NoticeAppMap.delete(id);
225
+ }
226
+ app_notice.unmount();
227
+ if (wrapper.parentNode) noticeWrapper.removeChild(wrapper);
228
+ }
229
+ var NoticePlugin = {
230
+ install,
231
+ open,
232
+ close,
233
+ closeAll,
234
+ config,
235
+ success,
236
+ info,
237
+ warning,
238
+ error
239
+ };
240
+ //#endregion
241
+ export { close, closeAll, config, NoticePlugin as default, error, info, open, success, warning };
242
+
243
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../components/notice/index.ts"],"sourcesContent":["import type { App } from 'vue'\r\nimport { createVNode, createApp } from 'vue'\r\nimport MainNotice from './Notice'\r\nimport { createNoticeWrapper, clearNoticeWrapper } from './src/_util/index'\r\nimport { UI_CONFIG_KEY, type UIPluginConfig } from '../../config/plugin'\r\nimport type {\r\n NoticeOptions,\r\n NoticeGlobalConfig,\r\n NoticeInstance,\r\n NoticeApi,\r\n NoticeContent,\r\n NoticeShortcut,\r\n NoticeType,\r\n} from './types'\r\n\r\nexport type {\r\n NoticeOptions,\r\n NoticeGlobalConfig,\r\n NoticeInstance,\r\n NoticeApi,\r\n NoticeContent,\r\n NoticeClose,\r\n NoticePlacementType,\r\n NoticeType,\r\n NoticeShortcut,\r\n} from './types'\r\n\r\ninterface NoticeRecord {\r\n noticeWrapper: HTMLElement\r\n itemWrapper: HTMLElement\r\n close: () => void\r\n afterClose?: () => void\r\n afterCloseCalled?: boolean\r\n key?: string | number\r\n app: App\r\n}\r\n\r\nconst NoticeAppMap = new Map<number, NoticeRecord>()\r\nconst NoticeKeyMap = new Map<string | number, number>()\r\n\r\nlet hostApp: App | null = null\r\n\r\nconst defaultOptions: Required<\r\n Pick<\r\n NoticeOptions,\r\n | 'placement'\r\n | 'duration'\r\n | 'manual'\r\n | 'showClose'\r\n | 'type'\r\n | 'hoverKeep'\r\n >\r\n> = {\r\n placement: 'top-end',\r\n duration: 4500,\r\n manual: false,\r\n showClose: true,\r\n type: 'default',\r\n hoverKeep: true,\r\n}\r\n\r\nlet globalConfig: NoticeGlobalConfig = {}\r\n\r\n/**\r\n * 运行时 / 全局默认配置\r\n * 也可通过 `app.use(UI, { components: { Notice: {...} } })` 注入\r\n *\r\n * @example\r\n * config({ placement: 'bottom-end', duration: 2500, maxCount: 3 })\r\n */\r\nfunction config(options: NoticeGlobalConfig = {}): void {\r\n globalConfig = { ...globalConfig, ...options }\r\n}\r\n\r\nfunction getMergedOptions(options: NoticeOptions): NoticeOptions {\r\n return {\r\n ...defaultOptions,\r\n ...globalConfig,\r\n ...options,\r\n }\r\n}\r\n\r\nfunction runAfterClose(record?: NoticeRecord) {\r\n if (!record || record.afterCloseCalled) return\r\n record.afterCloseCalled = true\r\n record.afterClose?.()\r\n}\r\n\r\nfunction inheritAppContext(notice: App) {\r\n if (!hostApp) return\r\n notice._context.provides = Object.create(hostApp._context.provides)\r\n}\r\n\r\nfunction enforceMaxCount(placement: string) {\r\n const maxCount = globalConfig.maxCount\r\n if (!maxCount || maxCount <= 0) return\r\n\r\n const samePlacement: NoticeRecord[] = []\r\n NoticeAppMap.forEach((record) => {\r\n if (record.noticeWrapper.classList.contains(`w-notice--${placement}`)) {\r\n samePlacement.push(record)\r\n }\r\n })\r\n\r\n const overflow = samePlacement.length + 1 - maxCount\r\n if (overflow <= 0) return\r\n\r\n samePlacement.slice(0, overflow).forEach((record) => {\r\n record.close()\r\n })\r\n}\r\n\r\n/** 跳过退场动画立刻拆掉(同 key 替换用,避免新旧叠动画) */\r\nfunction destroyImmediate(uid: number) {\r\n const record = NoticeAppMap.get(uid)\r\n if (!record) return\r\n _destroy(record.noticeWrapper, record.itemWrapper, record.app, uid)\r\n if (NoticeAppMap.size === 0) {\r\n clearNoticeWrapper()\r\n }\r\n}\r\n\r\n/**\r\n * 打开通知。返回实例,优先用 `instance.close()` 关闭。\r\n *\r\n * @example\r\n * const n = open({ content: '已保存', duration: 3000 })\r\n * n.close()\r\n *\r\n * @example\r\n * // 同 key 会立刻替换旧通知(适合上传进度)\r\n * open({ key: 'upload', content: '30%', manual: true })\r\n * open({ key: 'upload', content: '完成', duration: 2000 })\r\n */\r\nfunction open(options: NoticeOptions): NoticeInstance {\r\n const merged = getMergedOptions(options)\r\n const {\r\n placement = defaultOptions.placement,\r\n manual,\r\n duration,\r\n content,\r\n showClose,\r\n afterClose,\r\n onClose,\r\n type,\r\n title,\r\n icon,\r\n class: itemClass,\r\n style: itemStyle,\r\n wrapperClass,\r\n wrapperStyle,\r\n offset,\r\n zIndex,\r\n key,\r\n hoverKeep,\r\n color,\r\n size,\r\n cssVars,\r\n } = merged\r\n\r\n if (key !== undefined && NoticeKeyMap.has(key)) {\r\n destroyImmediate(NoticeKeyMap.get(key)!)\r\n }\r\n\r\n enforceMaxCount(placement)\r\n\r\n const itemWrapper = document.createElement('div')\r\n const noticeWrapper = createNoticeWrapper(placement, {\r\n offset: offset ?? globalConfig.offset,\r\n zIndex: zIndex ?? globalConfig.zIndex,\r\n wrapperClass: wrapperClass ?? globalConfig.wrapperClass,\r\n wrapperStyle: (wrapperStyle ||\r\n globalConfig.wrapperStyle) as Record<string, string>,\r\n })\r\n\r\n const closeRef: { current: () => void } = {\r\n current: () => {},\r\n }\r\n\r\n let notice!: NoticeInstance\r\n\r\n const vm = createVNode(\r\n MainNotice,\r\n {\r\n placement,\r\n manual,\r\n duration,\r\n showClose,\r\n type,\r\n title,\r\n icon,\r\n itemClass: itemClass ?? globalConfig.class,\r\n itemStyle: itemStyle ?? globalConfig.style,\r\n hoverKeep,\r\n color,\r\n size,\r\n cssVars,\r\n onClosing: () => {\r\n onClose?.()\r\n },\r\n 'onAfter-leave': (_el: HTMLElement, uid: number) => {\r\n const record = NoticeAppMap.get(uid)\r\n _destroy(noticeWrapper, itemWrapper, notice, uid)\r\n runAfterClose(record)\r\n if (NoticeAppMap.size === 0) {\r\n clearNoticeWrapper()\r\n }\r\n },\r\n onClose: (closeFn: () => void) => {\r\n closeRef.current = closeFn\r\n },\r\n 'onGet-uid': (uid: number) => {\r\n NoticeAppMap.set(uid, {\r\n noticeWrapper,\r\n itemWrapper,\r\n close: () => closeRef.current(),\r\n afterClose,\r\n key,\r\n app: notice,\r\n })\r\n if (key !== undefined) {\r\n NoticeKeyMap.set(key, uid)\r\n }\r\n },\r\n },\r\n {\r\n default: () => {\r\n if (typeof content === 'function') {\r\n return content(() => closeRef.current())\r\n }\r\n return content\r\n },\r\n },\r\n )\r\n\r\n notice = createApp(vm) as NoticeInstance\r\n inheritAppContext(notice)\r\n notice.close = () => close(notice)\r\n notice.mount(itemWrapper)\r\n noticeWrapper.appendChild(itemWrapper)\r\n\r\n return notice\r\n}\r\n\r\n/**\r\n * 关闭指定通知(带动画)。更推荐直接 `instance.close()`。\r\n */\r\nfunction close(app: App): void {\r\n const uid = app._instance?.uid\r\n if (uid === undefined) return\r\n const record = NoticeAppMap.get(uid)\r\n if (!record) return\r\n record.close()\r\n}\r\n\r\n/** 关闭全部通知(带动画) */\r\nfunction closeAll(): void {\r\n const list = Array.from(NoticeAppMap.values())\r\n list.forEach((record) => {\r\n record.close()\r\n })\r\n}\r\n\r\nfunction isPlainOptions(\r\n input: NoticeContent | (Omit<NoticeOptions, 'type'> & { content?: NoticeContent }),\r\n): input is Omit<NoticeOptions, 'type'> & { content?: NoticeContent } {\r\n if (\r\n input == null ||\r\n typeof input !== 'object' ||\r\n Array.isArray(input) ||\r\n (input as any).__v_isVNode\r\n ) {\r\n return false\r\n }\r\n const keys = [\r\n 'content',\r\n 'title',\r\n 'placement',\r\n 'duration',\r\n 'manual',\r\n 'showClose',\r\n 'class',\r\n 'style',\r\n 'icon',\r\n 'key',\r\n 'wrapperClass',\r\n 'wrapperStyle',\r\n 'offset',\r\n 'zIndex',\r\n 'hoverKeep',\r\n 'color',\r\n 'size',\r\n 'cssVars',\r\n 'afterClose',\r\n 'onClose',\r\n ]\r\n return keys.some((k) => k in (input as object))\r\n}\r\n\r\nfunction createShortcut(type: NoticeType): NoticeShortcut {\r\n return (content, options) => {\r\n if (isPlainOptions(content)) {\r\n return open({\r\n ...content,\r\n type,\r\n content: (content.content ?? '') as NoticeContent,\r\n })\r\n }\r\n return open({\r\n ...options,\r\n type,\r\n content: content as NoticeContent,\r\n })\r\n }\r\n}\r\n\r\nconst success = createShortcut('success')\r\nconst info = createShortcut('info')\r\nconst warning = createShortcut('warning')\r\nconst error = createShortcut('error')\r\n\r\n/**\r\n * Vue 插件安装:挂载 `$notice`,并读取 UI 全局 `components.Notice` 配置\r\n */\r\nfunction install(app: App): void {\r\n hostApp = app\r\n\r\n const uiConfig = app._context.provides[UI_CONFIG_KEY as any] as\r\n | UIPluginConfig\r\n | undefined\r\n const noticeCfg = uiConfig?.components?.Notice as NoticeGlobalConfig | undefined\r\n if (noticeCfg) {\r\n config(noticeCfg)\r\n }\r\n\r\n const api: NoticeApi = {\r\n open,\r\n close,\r\n closeAll,\r\n config,\r\n success,\r\n info,\r\n warning,\r\n error,\r\n }\r\n\r\n app.config.globalProperties.$notice = api\r\n}\r\n\r\nfunction _destroy(\r\n noticeWrapper: HTMLElement,\r\n wrapper: HTMLElement,\r\n app_notice: App,\r\n uid?: number,\r\n): void {\r\n const id = uid ?? app_notice._instance?.uid\r\n if (id !== undefined) {\r\n const record = NoticeAppMap.get(id)\r\n if (\r\n record?.key !== undefined &&\r\n NoticeKeyMap.get(record.key) === id\r\n ) {\r\n NoticeKeyMap.delete(record.key)\r\n }\r\n NoticeAppMap.delete(id)\r\n }\r\n app_notice.unmount()\r\n if (wrapper.parentNode) {\r\n noticeWrapper.removeChild(wrapper)\r\n }\r\n}\r\n\r\nconst NoticePlugin = {\r\n install,\r\n open,\r\n close,\r\n closeAll,\r\n config,\r\n success,\r\n info,\r\n warning,\r\n error,\r\n}\r\n\r\nexport default NoticePlugin\r\nexport { open, close, closeAll, config, success, info, warning, error }\r\n\r\nimport './src/style/index.css'\r\n"],"mappings":";;;;;;AAqCA,IAAM,+BAAe,IAAI,IAA0B;AACnD,IAAM,+BAAe,IAAI,IAA6B;AAEtD,IAAI,UAAsB;AAE1B,IAAM,iBAUF;CACF,WAAW;CACX,UAAU;CACV,QAAQ;CACR,WAAW;CACX,MAAM;CACN,WAAW;AACb;AAEA,IAAI,eAAmC,CAAC;;;;;;;;AASxC,SAAS,OAAO,UAA8B,CAAC,GAAS;CACtD,eAAe;EAAE,GAAG;EAAc,GAAG;CAAQ;AAC/C;AAEA,SAAS,iBAAiB,SAAuC;CAC/D,OAAO;EACL,GAAG;EACH,GAAG;EACH,GAAG;CACL;AACF;AAEA,SAAS,cAAc,QAAuB;CAC5C,IAAI,CAAC,UAAU,OAAO,kBAAkB;CACxC,OAAO,mBAAmB;CAC1B,OAAO,aAAa;AACtB;AAEA,SAAS,kBAAkB,QAAa;CACtC,IAAI,CAAC,SAAS;CACd,OAAO,SAAS,WAAW,OAAO,OAAO,QAAQ,SAAS,QAAQ;AACpE;AAEA,SAAS,gBAAgB,WAAmB;CAC1C,MAAM,WAAW,aAAa;CAC9B,IAAI,CAAC,YAAY,YAAY,GAAG;CAEhC,MAAM,gBAAgC,CAAC;CACvC,aAAa,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AAQ,WAAW;EAC/B,CAAC;EAEH,OAAO,KAAK;GACV,GAAG;GACH;GACS;EACX,CAAC;CACH;AACF;AAEA,IAAM,UAAU,eAAe,SAAS;AACxC,IAAM,OAAO,eAAe,MAAM;AAClC,IAAM,UAAU,eAAe,SAAS;AACxC,IAAM,QAAQ,eAAe,OAAO;;;;AAKpC,SAAS,QAAQ,KAAgB;CAC/B,UAAU;CAKV,MAAM,YAHW,IAAI,SAAS,SAAS,cAGrB,EAAU,YAAY;CACxC,IAAI,WACF,OAAO,SAAS;CAGlB,MAAM,MAAiB;EACrB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACF;CAEA,IAAI,OAAO,iBAAiB,UAAU;AACxC;AAEA,SAAS,SACP,eACA,SACA,YACA,KACM;CACN,MAAM,KAAK,OAAO,WAAW,WAAW;CACxC,IAAI,OAAO,KAAA,GAAW;EACpB,MAAM,SAAS,aAAa,IAAI,EAAE;EAClC,IACE,QAAQ,QAAQ,KAAA,KAChB,aAAa,IAAI,OAAO,GAAG,MAAM,IAEjC,aAAa,OAAO,OAAO,GAAG;EAEhC,aAAa,OAAO,EAAE;CACxB;CACA,WAAW,QAAQ;CACnB,IAAI,QAAQ,YACV,cAAc,YAAY,OAAO;AAErC;AAEA,IAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF"}
@@ -0,0 +1,11 @@
1
+ import { NoticePlacementType } from '../types';
2
+ declare function createNoticeWrapper(placement: NoticePlacementType | string, options?: {
3
+ offset?: number | string;
4
+ zIndex?: number;
5
+ wrapperClass?: any;
6
+ wrapperStyle?: Record<string, string>;
7
+ }): HTMLElement;
8
+ declare function removeNoticeWrapper(el: HTMLElement): void;
9
+ declare function clearNoticeWrapper(): void;
10
+ declare function getWrapperCount(placement?: string): number;
11
+ export { createNoticeWrapper, removeNoticeWrapper, clearNoticeWrapper, getWrapperCount, };
@@ -0,0 +1,50 @@
1
+ import useGlobalZIndex from "../../../../use/useGlobalZIndex.js";
2
+ //#region components/notice/src/_util/index.ts
3
+ var WRAPPERS = {};
4
+ function normalizeOffset(offset) {
5
+ if (offset === void 0 || offset === null || offset === "") return void 0;
6
+ return typeof offset === "number" ? `${offset}px` : String(offset);
7
+ }
8
+ function applyWrapperStyle(el, options) {
9
+ const { offset, zIndex, wrapperClass, wrapperStyle } = options || {};
10
+ if (wrapperClass) {
11
+ const extra = Array.isArray(wrapperClass) ? wrapperClass.filter(Boolean).join(" ") : typeof wrapperClass === "string" ? wrapperClass : Object.keys(wrapperClass).filter((k) => wrapperClass[k]).join(" ");
12
+ el.getAttribute("data-base-class") || el.className;
13
+ if (!el.getAttribute("data-base-class")) el.setAttribute("data-base-class", el.className);
14
+ el.className = `${el.getAttribute("data-base-class")} ${extra}`.trim();
15
+ }
16
+ if (wrapperStyle) Object.assign(el.style, wrapperStyle);
17
+ const offsetValue = normalizeOffset(offset);
18
+ if (offsetValue) el.style.setProperty("--w-notice-offset", offsetValue);
19
+ if (typeof zIndex === "number") el.style.zIndex = String(zIndex);
20
+ }
21
+ function createNoticeWrapper(placement, options) {
22
+ const { zIndex, add } = useGlobalZIndex();
23
+ if (placement in WRAPPERS) {
24
+ const el = WRAPPERS[placement];
25
+ el.style.zIndex = options?.zIndex != null ? String(options.zIndex) : String(add());
26
+ applyWrapperStyle(el, options);
27
+ return el;
28
+ }
29
+ const el = document.createElement("div");
30
+ const id = `notice_container_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`;
31
+ const klass = `w-notice w-notice--${placement}`;
32
+ el.id = id;
33
+ el.className = klass;
34
+ el.setAttribute("data-base-class", klass);
35
+ el.style.zIndex = options?.zIndex != null ? String(options.zIndex) : String(zIndex.value);
36
+ applyWrapperStyle(el, options);
37
+ WRAPPERS[placement] = el;
38
+ document.body.appendChild(el);
39
+ return el;
40
+ }
41
+ function clearNoticeWrapper() {
42
+ for (const p in WRAPPERS) if (WRAPPERS[p]) {
43
+ if (WRAPPERS[p].parentNode) document.body.removeChild(WRAPPERS[p]);
44
+ delete WRAPPERS[p];
45
+ }
46
+ }
47
+ //#endregion
48
+ export { clearNoticeWrapper, createNoticeWrapper };
49
+
50
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../../../components/notice/src/_util/index.ts"],"sourcesContent":["import useGlobalZIndex from '../../../../use/useGlobalZIndex'\r\nimport type { NoticePlacementType } from '../types'\r\n\r\ninterface WrapperType {\r\n [k: string]: HTMLElement\r\n}\r\n\r\nlet WRAPPERS: WrapperType = {}\r\n\r\nfunction normalizeOffset(offset?: number | string) {\r\n if (offset === undefined || offset === null || offset === '') return undefined\r\n return typeof offset === 'number' ? `${offset}px` : String(offset)\r\n}\r\n\r\nfunction applyWrapperStyle(\r\n el: HTMLElement,\r\n options?: {\r\n offset?: number | string\r\n zIndex?: number\r\n wrapperClass?: any\r\n wrapperStyle?: Record<string, string>\r\n },\r\n) {\r\n const { offset, zIndex, wrapperClass, wrapperStyle } = options || {}\r\n\r\n if (wrapperClass) {\r\n const extra = Array.isArray(wrapperClass)\r\n ? wrapperClass.filter(Boolean).join(' ')\r\n : typeof wrapperClass === 'string'\r\n ? wrapperClass\r\n : Object.keys(wrapperClass)\r\n .filter((k) => (wrapperClass as Record<string, boolean>)[k])\r\n .join(' ')\r\n const base = el.getAttribute('data-base-class') || el.className\r\n if (!el.getAttribute('data-base-class')) {\r\n el.setAttribute('data-base-class', el.className)\r\n }\r\n el.className = `${el.getAttribute('data-base-class')} ${extra}`.trim()\r\n }\r\n\r\n if (wrapperStyle) {\r\n Object.assign(el.style, wrapperStyle)\r\n }\r\n\r\n const offsetValue = normalizeOffset(offset)\r\n if (offsetValue) {\r\n el.style.setProperty('--w-notice-offset', offsetValue)\r\n }\r\n\r\n if (typeof zIndex === 'number') {\r\n el.style.zIndex = String(zIndex)\r\n }\r\n}\r\n\r\nfunction createNoticeWrapper(\r\n placement: NoticePlacementType | string,\r\n options?: {\r\n offset?: number | string\r\n zIndex?: number\r\n wrapperClass?: any\r\n wrapperStyle?: Record<string, string>\r\n },\r\n) {\r\n const { zIndex, add } = useGlobalZIndex()\r\n\r\n if (placement in WRAPPERS) {\r\n const el = WRAPPERS[placement]\r\n el.style.zIndex =\r\n options?.zIndex != null ? String(options.zIndex) : String(add())\r\n applyWrapperStyle(el, options)\r\n return el\r\n }\r\n\r\n const el = document.createElement('div')\r\n const id = `notice_container_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`\r\n const klass = `w-notice w-notice--${placement}`\r\n el.id = id\r\n el.className = klass\r\n el.setAttribute('data-base-class', klass)\r\n el.style.zIndex =\r\n options?.zIndex != null ? String(options.zIndex) : String(zIndex.value)\r\n applyWrapperStyle(el, options)\r\n WRAPPERS[placement] = el\r\n document.body.appendChild(el)\r\n return el\r\n}\r\n\r\nfunction removeNoticeWrapper(el: HTMLElement) {\r\n let p = ''\r\n for (const pla in WRAPPERS) {\r\n if (WRAPPERS[pla] === el) {\r\n p = pla\r\n }\r\n }\r\n if (p) {\r\n if (el.parentNode) {\r\n document.body.removeChild(el)\r\n }\r\n delete WRAPPERS[p]\r\n }\r\n}\r\n\r\nfunction clearNoticeWrapper() {\r\n for (const p in WRAPPERS) {\r\n if (WRAPPERS[p]) {\r\n if (WRAPPERS[p].parentNode) {\r\n document.body.removeChild(WRAPPERS[p])\r\n }\r\n delete WRAPPERS[p]\r\n }\r\n }\r\n}\r\n\r\nfunction getWrapperCount(placement?: string) {\r\n if (placement) {\r\n const el = WRAPPERS[placement]\r\n return el ? el.childElementCount : 0\r\n }\r\n return Object.values(WRAPPERS).reduce((n, el) => n + el.childElementCount, 0)\r\n}\r\n\r\nexport {\r\n createNoticeWrapper,\r\n removeNoticeWrapper,\r\n clearNoticeWrapper,\r\n getWrapperCount,\r\n}\r\n"],"mappings":";;AAOA,IAAI,WAAwB,CAAC;AAE7B,SAAS,gBAAgB,QAA0B;CACjD,IAAI,WAAW,KAAA,KAAa,WAAW,QAAQ,WAAW,IAAI,OAAO,KAA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