litos-ui 0.21.0 → 0.22.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 (381) hide show
  1. package/README.md +119 -15
  2. package/README.zh-CN.md +153 -0
  3. package/lib/base.d.ts +1 -0
  4. package/lib/base.js +1 -1
  5. package/lib/button/index.js +4 -4
  6. package/lib/{style-gKR_qwzm.js → button/index.less_inline.js} +2 -3
  7. package/lib/button/style.js +6 -2
  8. package/lib/calendar/index.js +140 -2
  9. package/lib/calendar/index.less_inline.js +4 -0
  10. package/lib/calendar/langs.js +12 -0
  11. package/lib/card/index.js +64 -2
  12. package/lib/card/index.less_inline.js +4 -0
  13. package/lib/carousel/index.js +257 -2
  14. package/lib/carousel/index.less_inline.js +4 -0
  15. package/lib/carousel/item.js +15 -2
  16. package/lib/carousel/item.less_inline.js +4 -0
  17. package/lib/carousel/timer.js +19 -0
  18. package/lib/check/check.d.ts +1 -0
  19. package/lib/check/check.js +117 -0
  20. package/lib/check/check.less_inline.js +4 -0
  21. package/lib/check/checkbox.js +18 -2
  22. package/lib/{checkbox-DhGHJXwI.js → check/checkbox.less_inline.js} +2 -14
  23. package/lib/check/checkbox_group.js +1 -1
  24. package/lib/check/index.d.ts +1 -0
  25. package/lib/{check-DFlwStH9.js → check/index.js} +10 -9
  26. package/lib/check/index.less_inline.js +4 -0
  27. package/lib/check/radio.js +15 -2
  28. package/lib/{radio-C9NPQWGI.js → check/radio.less_inline.js} +2 -11
  29. package/lib/check/radio_group.js +1 -1
  30. package/lib/collapse/index.js +103 -2
  31. package/lib/collapse/index.less_inline.js +4 -0
  32. package/lib/collapse/item.d.ts +1 -0
  33. package/lib/collapse/item.js +118 -2
  34. package/lib/collapse/item.less_inline.js +4 -0
  35. package/lib/collapse/types.d.ts +1 -0
  36. package/lib/color_picker/index.js +42 -2
  37. package/lib/color_picker/index.less_inline.js +4 -0
  38. package/lib/date_picker/index.js +100 -3
  39. package/lib/date_picker/index.less_inline.js +4 -0
  40. package/lib/date_picker_ori/index.js +121 -2
  41. package/lib/date_picker_ori/index.less_inline.js +4 -0
  42. package/lib/description_panel/index.js +54 -2
  43. package/lib/description_panel/index.less_inline.js +4 -0
  44. package/lib/dialog/dialog_box.js +10 -10
  45. package/lib/{dialog_container_style-C1s0aBf7.js → dialog/dialog_container.css_inline.js} +2 -3
  46. package/lib/dialog/dialog_container.js +2 -2
  47. package/lib/dialog/dialog_container_style.js +6 -2
  48. package/lib/dialog/index.js +1 -1
  49. package/lib/entries/base.d.ts +2 -0
  50. package/lib/entries/base.js +2 -0
  51. package/lib/entries/button.d.ts +2 -0
  52. package/lib/entries/button.js +6 -0
  53. package/lib/entries/calendar.d.ts +2 -0
  54. package/lib/entries/calendar.js +6 -0
  55. package/lib/entries/card.d.ts +2 -0
  56. package/lib/entries/card.js +6 -0
  57. package/lib/entries/carousel-item.d.ts +2 -0
  58. package/lib/entries/carousel-item.js +6 -0
  59. package/lib/entries/carousel.d.ts +5 -0
  60. package/lib/entries/carousel.js +6 -0
  61. package/lib/entries/checkbox-group.d.ts +3 -0
  62. package/lib/entries/checkbox-group.js +6 -0
  63. package/lib/entries/checkbox.d.ts +2 -0
  64. package/lib/entries/checkbox.js +6 -0
  65. package/lib/entries/collapse-item.d.ts +3 -0
  66. package/lib/entries/collapse-item.js +6 -0
  67. package/lib/entries/collapse.d.ts +3 -0
  68. package/lib/entries/collapse.js +6 -0
  69. package/lib/entries/color-picker.d.ts +3 -0
  70. package/lib/entries/color-picker.js +6 -0
  71. package/lib/entries/date-picker-ori.d.ts +2 -0
  72. package/lib/entries/date-picker-ori.js +6 -0
  73. package/lib/entries/date-picker.d.ts +9 -0
  74. package/lib/entries/date-picker.js +6 -0
  75. package/lib/entries/description-panel.d.ts +4 -0
  76. package/lib/entries/description-panel.js +6 -0
  77. package/lib/entries/dialog-box.d.ts +6 -0
  78. package/lib/entries/dialog-box.js +2 -0
  79. package/lib/entries/dialog-container.d.ts +4 -0
  80. package/lib/entries/dialog-container.js +6 -0
  81. package/lib/entries/dialog.d.ts +3 -0
  82. package/lib/entries/dialog.js +2 -0
  83. package/lib/entries/form-item.d.ts +2 -0
  84. package/lib/entries/form-item.js +6 -0
  85. package/lib/entries/form.d.ts +3 -0
  86. package/lib/entries/form.js +6 -0
  87. package/lib/entries/icon-arrow-down.d.ts +2 -0
  88. package/lib/entries/icon-arrow-down.js +6 -0
  89. package/lib/entries/icon-arrow-left.d.ts +2 -0
  90. package/lib/entries/icon-arrow-left.js +6 -0
  91. package/lib/entries/icon-arrow-right.d.ts +2 -0
  92. package/lib/entries/icon-arrow-right.js +6 -0
  93. package/lib/entries/icon-arrow-up.d.ts +2 -0
  94. package/lib/entries/icon-arrow-up.js +6 -0
  95. package/lib/entries/icon-base.d.ts +2 -0
  96. package/lib/entries/icon-base.js +6 -0
  97. package/lib/entries/icon-calendar.d.ts +2 -0
  98. package/lib/entries/icon-calendar.js +6 -0
  99. package/lib/entries/icon-caret-bottom.d.ts +2 -0
  100. package/lib/entries/icon-caret-bottom.js +6 -0
  101. package/lib/entries/icon-caret-top.d.ts +2 -0
  102. package/lib/entries/icon-caret-top.js +6 -0
  103. package/lib/entries/icon-close-filled.d.ts +2 -0
  104. package/lib/entries/icon-close-filled.js +6 -0
  105. package/lib/entries/icon-close.d.ts +2 -0
  106. package/lib/entries/icon-close.js +6 -0
  107. package/lib/entries/icon-copy.d.ts +2 -0
  108. package/lib/entries/icon-copy.js +6 -0
  109. package/lib/entries/icon-d-arrow-left.d.ts +2 -0
  110. package/lib/entries/icon-d-arrow-left.js +6 -0
  111. package/lib/entries/icon-d-arrow-right.d.ts +2 -0
  112. package/lib/entries/icon-d-arrow-right.js +6 -0
  113. package/lib/entries/icon-delete.d.ts +2 -0
  114. package/lib/entries/icon-delete.js +6 -0
  115. package/lib/entries/icon-eye-outline.d.ts +2 -0
  116. package/lib/entries/icon-eye-outline.js +6 -0
  117. package/lib/entries/icon-font-icon.d.ts +2 -0
  118. package/lib/entries/icon-font-icon.js +6 -0
  119. package/lib/entries/icon-info.d.ts +2 -0
  120. package/lib/entries/icon-info.js +6 -0
  121. package/lib/entries/icon-loading.d.ts +2 -0
  122. package/lib/entries/icon-loading.js +6 -0
  123. package/lib/entries/icon-minus.d.ts +2 -0
  124. package/lib/entries/icon-minus.js +6 -0
  125. package/lib/entries/icon-moon.d.ts +2 -0
  126. package/lib/entries/icon-moon.js +6 -0
  127. package/lib/entries/icon-more.d.ts +2 -0
  128. package/lib/entries/icon-more.js +6 -0
  129. package/lib/entries/icon-picture.d.ts +2 -0
  130. package/lib/entries/icon-picture.js +6 -0
  131. package/lib/entries/icon-plus.d.ts +2 -0
  132. package/lib/entries/icon-plus.js +6 -0
  133. package/lib/entries/icon-reduction.d.ts +2 -0
  134. package/lib/entries/icon-reduction.js +6 -0
  135. package/lib/entries/icon-refresh-left.d.ts +2 -0
  136. package/lib/entries/icon-refresh-left.js +6 -0
  137. package/lib/entries/icon-refresh-right.d.ts +2 -0
  138. package/lib/entries/icon-refresh-right.js +6 -0
  139. package/lib/entries/icon-refresh.d.ts +2 -0
  140. package/lib/entries/icon-refresh.js +6 -0
  141. package/lib/entries/icon-search.d.ts +2 -0
  142. package/lib/entries/icon-search.js +6 -0
  143. package/lib/entries/icon-select.d.ts +2 -0
  144. package/lib/entries/icon-select.js +6 -0
  145. package/lib/entries/icon-sort.d.ts +2 -0
  146. package/lib/entries/icon-sort.js +6 -0
  147. package/lib/entries/icon-success.d.ts +2 -0
  148. package/lib/entries/icon-success.js +6 -0
  149. package/lib/entries/icon-sun.d.ts +2 -0
  150. package/lib/entries/icon-sun.js +6 -0
  151. package/lib/entries/icon-theme-default.d.ts +2 -0
  152. package/lib/entries/icon-theme-default.js +6 -0
  153. package/lib/entries/icon-warn.d.ts +2 -0
  154. package/lib/entries/icon-warn.js +6 -0
  155. package/lib/entries/icon-zoom-in.d.ts +2 -0
  156. package/lib/entries/icon-zoom-in.js +6 -0
  157. package/lib/entries/icon-zoom-out.d.ts +2 -0
  158. package/lib/entries/icon-zoom-out.js +6 -0
  159. package/lib/entries/image-preview.d.ts +10 -0
  160. package/lib/entries/image-preview.js +6 -0
  161. package/lib/entries/image.d.ts +2 -0
  162. package/lib/entries/image.js +6 -0
  163. package/lib/entries/input-number.d.ts +2 -0
  164. package/lib/entries/input-number.js +6 -0
  165. package/lib/entries/input.d.ts +2 -0
  166. package/lib/entries/input.js +6 -0
  167. package/lib/entries/list.d.ts +3 -0
  168. package/lib/entries/list.js +6 -0
  169. package/lib/entries/loading.d.ts +2 -0
  170. package/lib/entries/loading.js +2 -0
  171. package/lib/entries/mask.d.ts +2 -0
  172. package/lib/entries/mask.js +6 -0
  173. package/lib/entries/md-input.d.ts +2 -0
  174. package/lib/entries/md-input.js +6 -0
  175. package/lib/entries/menu.d.ts +3 -0
  176. package/lib/entries/menu.js +6 -0
  177. package/lib/entries/message.d.ts +6 -0
  178. package/lib/entries/message.js +2 -0
  179. package/lib/entries/modal-box.d.ts +6 -0
  180. package/lib/entries/modal-box.js +2 -0
  181. package/lib/entries/modal.d.ts +4 -0
  182. package/lib/entries/modal.js +6 -0
  183. package/lib/entries/notification.d.ts +7 -0
  184. package/lib/entries/notification.js +6 -0
  185. package/lib/entries/page-header.d.ts +4 -0
  186. package/lib/entries/page-header.js +6 -0
  187. package/lib/entries/pagination.d.ts +9 -0
  188. package/lib/entries/pagination.js +6 -0
  189. package/lib/entries/polygon.d.ts +2 -0
  190. package/lib/entries/polygon.js +6 -0
  191. package/lib/entries/popconfirm.d.ts +3 -0
  192. package/lib/entries/popconfirm.js +2 -0
  193. package/lib/entries/popover.d.ts +1 -0
  194. package/lib/entries/popover.js +2 -0
  195. package/lib/entries/qrcode.d.ts +2 -0
  196. package/lib/entries/qrcode.js +6 -0
  197. package/lib/entries/radio-group.d.ts +3 -0
  198. package/lib/entries/radio-group.js +6 -0
  199. package/lib/entries/radio.d.ts +2 -0
  200. package/lib/entries/radio.js +6 -0
  201. package/lib/entries/select-ori.d.ts +2 -0
  202. package/lib/entries/select-ori.js +6 -0
  203. package/lib/entries/select.d.ts +4 -0
  204. package/lib/entries/select.js +6 -0
  205. package/lib/entries/space.d.ts +2 -0
  206. package/lib/entries/space.js +6 -0
  207. package/lib/entries/switch.d.ts +2 -0
  208. package/lib/entries/switch.js +6 -0
  209. package/lib/entries/tabbar-item.d.ts +2 -0
  210. package/lib/entries/tabbar-item.js +6 -0
  211. package/lib/entries/tabbar.d.ts +3 -0
  212. package/lib/entries/tabbar.js +6 -0
  213. package/lib/entries/table.d.ts +3 -0
  214. package/lib/entries/table.js +6 -0
  215. package/lib/entries/tabs.d.ts +3 -0
  216. package/lib/entries/tabs.js +2 -0
  217. package/lib/entries/tag.d.ts +2 -0
  218. package/lib/entries/tag.js +6 -0
  219. package/lib/entries/theme-color.d.ts +3 -0
  220. package/lib/entries/theme-color.js +6 -0
  221. package/lib/entries/theme.d.ts +9 -0
  222. package/lib/entries/theme.js +6 -0
  223. package/lib/entries/transition.d.ts +1 -0
  224. package/lib/entries/transition.js +2 -0
  225. package/lib/entries/upload.d.ts +3 -0
  226. package/lib/entries/upload.js +6 -0
  227. package/lib/entries/utils.d.ts +1 -0
  228. package/lib/entries/utils.js +2 -0
  229. package/lib/form/form_inner.d.ts +1 -0
  230. package/lib/{form_inner-Cnwb6f_Q.js → form/form_inner.js} +9 -9
  231. package/lib/form/form_item.d.ts +2 -1
  232. package/lib/form/form_item.js +148 -2
  233. package/lib/form/form_item.less_inline.js +4 -0
  234. package/lib/form/index.d.ts +3 -2
  235. package/lib/form/index.js +191 -2
  236. package/lib/form/index.less_inline.js +4 -0
  237. package/lib/icon/base.js +1 -1
  238. package/lib/icon/delete.d.ts +5 -0
  239. package/lib/icon/delete.js +10 -0
  240. package/lib/icon/eye_outline.d.ts +6 -0
  241. package/lib/icon/eye_outline.js +13 -0
  242. package/lib/icon/icon_style.js +6 -2
  243. package/lib/{icon_style-J7iiDS_a.js → icon/index.less_inline.js} +2 -3
  244. package/lib/icon/minus.d.ts +5 -0
  245. package/lib/icon/minus.js +10 -0
  246. package/lib/icon/picture.d.ts +5 -0
  247. package/lib/icon/picture.js +10 -0
  248. package/lib/icon/plus.d.ts +5 -0
  249. package/lib/icon/plus.js +10 -0
  250. package/lib/image/image_preview.js +91 -2
  251. package/lib/image/image_preview.less_inline.js +4 -0
  252. package/lib/image/index.js +163 -2
  253. package/lib/image/index.less_inline.js +4 -0
  254. package/lib/index.d.ts +11 -0
  255. package/lib/index.js +47 -40
  256. package/lib/input/index.js +4 -4
  257. package/lib/{input-DUBlLEXS.js → input/index.less_inline.js} +1 -1
  258. package/lib/{input_inner-x4GfLGjj.js → input/input_inner.less_inline.js} +1 -1
  259. package/lib/input_number/index.js +3 -3
  260. package/lib/{style-C5wUmE2b.js → input_number/index.less_inline.js} +2 -3
  261. package/lib/input_number/style.js +6 -2
  262. package/lib/list/index.js +52 -2
  263. package/lib/list/index.less_inline.js +4 -0
  264. package/lib/loading/index.js +1 -1
  265. package/lib/mask/index.d.ts +1 -1
  266. package/lib/mask/index.js +109 -2
  267. package/lib/mask/index.less_inline.js +4 -0
  268. package/lib/md_input/index.js +59 -2
  269. package/lib/md_input/index.less_inline.js +4 -0
  270. package/lib/menu/index.js +275 -2
  271. package/lib/menu/index.less_inline.js +4 -0
  272. package/lib/message/index.js +1 -1
  273. package/lib/modal/index.js +199 -2
  274. package/lib/modal/index.less_inline.js +4 -0
  275. package/lib/modal/modal_box.js +21 -22
  276. package/lib/notification/index.d.ts +212 -0
  277. package/lib/notification/index.js +380 -0
  278. package/lib/notification/index.less_inline.js +4 -0
  279. package/lib/notification/placement.d.ts +49 -0
  280. package/lib/notification/placement.js +48 -0
  281. package/lib/notification/style.d.ts +2 -0
  282. package/lib/notification/style.js +6 -0
  283. package/lib/page_header/index.js +100 -2
  284. package/lib/page_header/index.less_inline.js +4 -0
  285. package/lib/pagination/index.js +214 -2
  286. package/lib/pagination/index.less_inline.js +4 -0
  287. package/lib/polygon/index.js +21 -2
  288. package/lib/{polygon-DhhovlrG.js → polygon/index.less_inline.js} +2 -18
  289. package/lib/qrcode/index.js +65 -2
  290. package/lib/qrcode/index.less_inline.js +4 -0
  291. package/lib/select/index.js +355 -3
  292. package/lib/select/index.less_inline.js +4 -0
  293. package/lib/select_ori/index.js +58 -2
  294. package/lib/select_ori/index.less_inline.js +4 -0
  295. package/lib/space/index.js +40 -2
  296. package/lib/space/index.less_inline.js +4 -0
  297. package/lib/{animation-Bo4jbSGK.js → styles/animation/index.css_inline.js} +2 -3
  298. package/lib/styles/animation/index.js +6 -2
  299. package/lib/{mask-Ox6CoyFB.js → styles/mask/index.css_inline.js} +2 -3
  300. package/lib/styles/mask/index.js +6 -2
  301. package/lib/switch/index.js +51 -2
  302. package/lib/switch/index.less_inline.js +4 -0
  303. package/lib/tabbar/index.js +97 -2
  304. package/lib/tabbar/index.less_inline.js +4 -0
  305. package/lib/tabbar/item.js +61 -2
  306. package/lib/tabbar/item.less_inline.js +4 -0
  307. package/lib/table/index.js +234 -2
  308. package/lib/table/index.less_inline.js +4 -0
  309. package/lib/tabs/index.js +1 -1
  310. package/lib/tag/index.js +75 -2
  311. package/lib/tag/index.less_inline.js +4 -0
  312. package/lib/theme/index.js +86 -2
  313. package/lib/theme/index.less_inline.js +4 -0
  314. package/lib/theme/theme_color.js +1 -1
  315. package/lib/upload/index.d.ts +170 -0
  316. package/lib/upload/index.js +848 -0
  317. package/lib/upload/index.less_inline.js +4 -0
  318. package/lib/upload/style.d.ts +2 -0
  319. package/lib/upload/style.js +6 -0
  320. package/lib/utils/context_provide.d.ts +1 -0
  321. package/lib/utils/context_provide.js +1 -1
  322. package/lib/utils/event.d.ts +30 -0
  323. package/lib/utils/index.d.ts +3 -0
  324. package/lib/utils/index.js +1 -1
  325. package/lib/utils/popover.js +1 -1
  326. package/lib/utils/signal_types.d.ts +5 -0
  327. package/lib/utils/transition.d.ts +28 -0
  328. package/lib/utils/transition.js +1 -1
  329. package/package.json +39 -18
  330. package/styles/animation.css +2 -2
  331. package/styles/container.css +8 -8
  332. package/styles/datepicker.css +9 -9
  333. package/styles/dialog.css +7 -7
  334. package/styles/loading.css +17 -17
  335. package/styles/message.css +9 -9
  336. package/styles/modal_box.css +3 -3
  337. package/styles/notification.css +17 -0
  338. package/styles/popover.css +11 -14
  339. package/styles/reset.css +13 -15
  340. package/styles/scrollbar.css +5 -5
  341. package/styles/select.css +6 -6
  342. package/styles/tabs.css +3 -3
  343. package/styles/theme-coral.css +35 -0
  344. package/styles/theme-jade.css +35 -0
  345. package/styles/theme-tangerine.css +35 -0
  346. package/styles/transition.css +1 -1
  347. package/styles/vars.css +41 -7
  348. package/lib/calendar-CvlUsN6w.js +0 -146
  349. package/lib/card-3DM-lJQV.js +0 -63
  350. package/lib/carousel-DvkZ1YXq.js +0 -276
  351. package/lib/check-doQ2ZpQj.js +0 -117
  352. package/lib/collapse-B6-Rn05A.js +0 -102
  353. package/lib/color_picker-0a-IGZY9.js +0 -41
  354. package/lib/date_picker-BDN2PAz5.js +0 -99
  355. package/lib/date_picker_ori-BXFs1eET.js +0 -120
  356. package/lib/description_panel--AKXBzLL.js +0 -53
  357. package/lib/esm-DAha108i.js +0 -270
  358. package/lib/form-DJxvBiLy.js +0 -190
  359. package/lib/form_item-BqPMRABd.js +0 -147
  360. package/lib/image-CVQai6NX.js +0 -162
  361. package/lib/image_preview-DfQAKSJH.js +0 -90
  362. package/lib/item-CQ2Sknbz.js +0 -14
  363. package/lib/item-DI6mQXtB.js +0 -117
  364. package/lib/item-D_ZOPXuE.js +0 -60
  365. package/lib/list-MG8PRzos.js +0 -51
  366. package/lib/mask-Bx-yNIJv.js +0 -108
  367. package/lib/md_input-BX3bujz8.js +0 -58
  368. package/lib/menu-DKscK5mw.js +0 -274
  369. package/lib/modal-Cwi3qlEf.js +0 -198
  370. package/lib/page_header-ujV3pncE.js +0 -99
  371. package/lib/pagination-aRbGd3Rf.js +0 -213
  372. package/lib/qrcode-Dip8uLSA.js +0 -64
  373. package/lib/select-BZMDj5VE.js +0 -354
  374. package/lib/select_ori-C7sUZxen.js +0 -57
  375. package/lib/space-CKuTk0YB.js +0 -39
  376. package/lib/switch-wh2-ivty.js +0 -50
  377. package/lib/tabbar-CBXK-_AV.js +0 -96
  378. package/lib/table-BQxMD2Ae.js +0 -233
  379. package/lib/tag-Di1z9PoZ.js +0 -74
  380. package/lib/theme-CLbBS-in.js +0 -85
  381. package/styles/dark.css +0 -13
@@ -0,0 +1,212 @@
1
+ import BaseComponent from "../base";
2
+ import type { NotificationPlacement } from "./placement";
3
+ export type { NotificationPlacement };
4
+ /** 通知状态类型 */
5
+ export type NotificationType = "info" | "success" | "error" | "warning";
6
+ /** 命令式调用配置 */
7
+ export interface NotificationOptions {
8
+ /** 自定义通知 id, 不传则自动生成 */
9
+ id?: string;
10
+ /** 标题 */
11
+ title?: string;
12
+ /** 消息内容, 支持 HTML 字符串 */
13
+ message?: string;
14
+ /** 状态类型, 默认: `info` */
15
+ type?: NotificationType;
16
+ /** 显示方位, 默认: `topRight` */
17
+ placement?: NotificationPlacement;
18
+ /** 自动关闭时间(毫秒), 设置为 `0` 时不自动关闭, 默认: `4500` */
19
+ duration?: number;
20
+ /** 是否显示关闭按钮, 默认: `true` */
21
+ closable?: boolean;
22
+ /** 是否显示状态图标, 默认: `true` */
23
+ showIcon?: boolean;
24
+ /** 通知宽度, 数字会自动转换为 `px` */
25
+ width?: string | number;
26
+ /** 距离视口边缘的距离(px), 默认: `16` */
27
+ offset?: number;
28
+ /** 层级, 默认: `2000` */
29
+ zIndex?: number;
30
+ /** 同一个方位最多同时显示的通知数量, `0` 表示不限制 */
31
+ maxCount?: number;
32
+ /** 行动点按钮文本, 用于给出用户下一步的操作 */
33
+ action?: string;
34
+ /** 自定义类名, 多个使用空格分隔 */
35
+ customClass?: string;
36
+ /** 关闭后的回调 */
37
+ onClose?: (id: string) => void;
38
+ /** 点击行动点的回调 */
39
+ onAction?: (id: string) => void;
40
+ }
41
+ type NotificationState = {
42
+ open: boolean;
43
+ type: NotificationType;
44
+ title: string;
45
+ message: string;
46
+ placement: NotificationPlacement;
47
+ duration: number;
48
+ closable: boolean;
49
+ showIcon: boolean;
50
+ width: string;
51
+ offset: number;
52
+ zIndex: number;
53
+ maxCount: number;
54
+ action: string;
55
+ customClass: string;
56
+ };
57
+ /**
58
+ * 设置全局默认配置, 之后创建的通知都会使用该配置
59
+ * @param option 配置项
60
+ */
61
+ declare function configNotification(option: NotificationOptions): void;
62
+ /**
63
+ * 创建一条通知
64
+ * @param option 通知内容或配置项
65
+ * @param type 状态类型, 会覆盖配置项中的 `type`
66
+ * @returns 通知 id, 可以配合 `Notification.close` 手动关闭
67
+ */
68
+ declare function showNotification(option: string | NotificationOptions, type?: NotificationType): string;
69
+ /**
70
+ * 关闭指定 id 的通知
71
+ * @param id 通知 id
72
+ */
73
+ declare function closeNotification(id: string): void;
74
+ /**
75
+ * 关闭所有通知
76
+ * @param placement 只关闭指定方位的通知, 不传递则关闭所有方位
77
+ */
78
+ declare function closeAllNotification(placement?: NotificationPlacement): void;
79
+ export default class Notification extends BaseComponent<NotificationState> {
80
+ static baseName: string;
81
+ /** 显示通知, 返回通知 id */
82
+ static show: typeof showNotification;
83
+ /** 显示普通通知 */
84
+ static info: (option: string | NotificationOptions) => string;
85
+ /** 显示成功通知 */
86
+ static success: (option: string | NotificationOptions) => string;
87
+ /** 显示错误通知 */
88
+ static error: (option: string | NotificationOptions) => string;
89
+ /** 显示警告通知 */
90
+ static warning: (option: string | NotificationOptions) => string;
91
+ /** 显示警告通知, `warning` 的别名 */
92
+ static warn: (option: string | NotificationOptions) => string;
93
+ /** 关闭指定 id 的通知 */
94
+ static close: typeof closeNotification;
95
+ /** 关闭所有通知 */
96
+ static closeAll: typeof closeAllNotification;
97
+ /** 设置全局默认配置 */
98
+ static config: typeof configNotification;
99
+ /** 关闭后是否从文档中移除, 命令式 API 创建的通知为 `true` */
100
+ removeOnClose: boolean;
101
+ /** 当前是否显示 */
102
+ private _visible;
103
+ /** 自动关闭定时器 */
104
+ private _timer?;
105
+ /** 定时器开始时间 */
106
+ private _startTime;
107
+ /** 剩余自动关闭时间 */
108
+ private _remaining;
109
+ /** 已经应用到宿主节点上的自定义类名 */
110
+ private _appliedClasses;
111
+ /** 取消当前进行中的动画 */
112
+ private _cancelAnimation?;
113
+ /** 监听内容尺寸变化, 尺寸变化时重新排布 */
114
+ private _resizeObserver?;
115
+ private $icon?;
116
+ private $title?;
117
+ private $titleText?;
118
+ private $message?;
119
+ private $messageText?;
120
+ private $actionWrap?;
121
+ private $actionBtn?;
122
+ private $actionSlot?;
123
+ private $closeBtn?;
124
+ constructor();
125
+ /** 距离视口边缘的距离(px) */
126
+ get notificationOffset(): number;
127
+ /** 与相邻通知的间距(px) */
128
+ get notificationGap(): number;
129
+ /** 当前显示方位 */
130
+ get placement(): NotificationPlacement;
131
+ get open(): boolean;
132
+ set open(value: boolean);
133
+ static get observedAttributes(): string[];
134
+ protected attributeChanged(name: string, _oldValue: string, newValue: string): void;
135
+ protected updateDOM(changedProps: Set<string>): void;
136
+ connectedCallback(): void;
137
+ disconnectedCallback(): void;
138
+ render_v2(): {
139
+ styleSheets: CSSStyleSheet[];
140
+ template: HTMLElement;
141
+ };
142
+ afterInit(): void;
143
+ beforeDestroy(): void;
144
+ render(): HTMLElement;
145
+ /** 显示通知 */
146
+ show(): void;
147
+ /** 关闭通知 */
148
+ close(): void;
149
+ private _initRefs;
150
+ private _bindEvents;
151
+ private _unbindEvents;
152
+ private _syncAll;
153
+ /** 同步状态图标 */
154
+ private _syncIcon;
155
+ /** 同步标题与内容 */
156
+ private _syncSections;
157
+ /**
158
+ * 同步内容区域
159
+ * @param $wrap 区域节点
160
+ * @param $text 通过属性渲染的内容节点
161
+ * @param value 属性值
162
+ * @param asText 是否按照纯文本渲染, 否则按照 HTML 渲染
163
+ */
164
+ private _syncSection;
165
+ /** 同步行动点 */
166
+ private _syncActions;
167
+ /** 同步关闭按钮 */
168
+ private _syncClose;
169
+ /** 同步宽度 */
170
+ private _syncWidth;
171
+ /** 同步偏移与层级 */
172
+ private _syncOffset;
173
+ /** 同步自定义类名 */
174
+ private _syncCustomClass;
175
+ /** 插槽中是否存在有效内容(忽略空白文本) */
176
+ private _hasSlotContent;
177
+ /** 方位变化时重新排布 */
178
+ private _updatePlacement;
179
+ private _toggleOpen;
180
+ private _show;
181
+ private _hide;
182
+ /** 超出同一方位的最大数量时, 关闭最早的通知 */
183
+ private _enforceMaxCount;
184
+ /**
185
+ * 入场动画
186
+ *
187
+ * 先应用起始状态(此时还没有过渡), 再开启过渡并移除起始状态,
188
+ * 避免从已显示状态反向过渡。
189
+ */
190
+ private _enter;
191
+ /** 离场动画 */
192
+ private _leave;
193
+ /** 过渡时长(毫秒) */
194
+ private _transitionDuration;
195
+ /** 监听指定属性的过渡结束, 同时提供兜底处理 */
196
+ private _onceTransitionEnd;
197
+ private _cancelPendingAnimation;
198
+ /** 内容尺寸变化时重新排布 */
199
+ private _observeSize;
200
+ private _unobserveSize;
201
+ private _startTimer;
202
+ private _clearTimer;
203
+ /** 鼠标悬浮时暂停自动关闭 */
204
+ private _pauseTimer;
205
+ /** 鼠标移出时继续自动关闭 */
206
+ private _resumeTimer;
207
+ private _handleMouseEnter;
208
+ private _handleMouseLeave;
209
+ private _handleCloseClick;
210
+ private _handleActionClick;
211
+ private _handleSlotChange;
212
+ }
@@ -0,0 +1,380 @@
1
+ import e from "../base.js";
2
+ import { kebabToCamel as t, parseAttrValue as n, regist as r, unitNumberStr as i, useId as a } from "../utils/index.js";
3
+ import o from "../icon/close_filled.js";
4
+ import s from "../icon/success.js";
5
+ import c from "../icon/warn.js";
6
+ import l from "../icon/info.js";
7
+ import u from "../icon/close.js";
8
+ import d from "./style.js";
9
+ import { DEFAULT_ZINDEX as f, getGroupSize as p, getOldestNotification as m, layoutGroup as h, normalizePlacement as g, registerNotification as _, unregisterNotification as v } from "./placement.js";
10
+ import { $$ as y, $one as b, off as x, on as S } from "utilane/browser";
11
+ //#region src/components/notification/index.ts
12
+ var C = "l-notification", w = 4500, T = {
13
+ info: "info",
14
+ success: "success",
15
+ error: "close-filled",
16
+ warning: "warn"
17
+ }, E = !1, D = {};
18
+ function O() {
19
+ E ||= (r([
20
+ l,
21
+ s,
22
+ c,
23
+ o,
24
+ u
25
+ ]), !0);
26
+ }
27
+ function k(e) {
28
+ D = {
29
+ ...D,
30
+ ...e
31
+ };
32
+ }
33
+ function A(e, t) {
34
+ O(), r(N);
35
+ let n = {
36
+ ...D,
37
+ ...typeof e == "string" ? { message: e } : e
38
+ };
39
+ t && (n.type = t);
40
+ let i = n.id || a(), o = g(n.placement), s = document.createElement(C);
41
+ return s.id = i, s.removeOnClose = !0, s.setAttribute("open", ""), s.setAttribute("type", n.type || "info"), s.setAttribute("placement", o), n.title != null && s.setAttribute("title", n.title), n.message != null && s.setAttribute("message", n.message), s.setAttribute("duration", `${n.duration ?? w}`), n.closable === !1 && s.setAttribute("closable", "false"), n.showIcon === !1 && s.setAttribute("show-icon", "false"), n.width != null && s.setAttribute("width", `${n.width}`), n.offset != null && s.setAttribute("offset", `${n.offset}`), n.zIndex != null && s.setAttribute("z-index", `${n.zIndex}`), n.maxCount != null && s.setAttribute("max-count", `${n.maxCount}`), n.action && s.setAttribute("action", n.action), n.customClass && s.setAttribute("custom-class", n.customClass), n.onClose && S(s, "close", () => n.onClose?.(i)), n.onAction && S(s, "action", () => n.onAction?.(i)), document.body.appendChild(s), i;
42
+ }
43
+ function j(e) {
44
+ let t = document.getElementById(e);
45
+ t && typeof t.close == "function" && t.close();
46
+ }
47
+ function M(e) {
48
+ let t = e ? [g(e)] : void 0, n = document.querySelectorAll(C);
49
+ for (let e of Array.from(n)) {
50
+ let n = e;
51
+ typeof n.close == "function" && (t && !t.includes(n.placement) || n.close());
52
+ }
53
+ }
54
+ var N = class extends e {
55
+ static baseName = "notification";
56
+ static show = A;
57
+ static info = (e) => A(e, "info");
58
+ static success = (e) => A(e, "success");
59
+ static error = (e) => A(e, "error");
60
+ static warning = (e) => A(e, "warning");
61
+ static warn = (e) => A(e, "warning");
62
+ static close = j;
63
+ static closeAll = M;
64
+ static config = k;
65
+ removeOnClose = !1;
66
+ _visible = !1;
67
+ _timer;
68
+ _startTime = 0;
69
+ _remaining = 0;
70
+ _appliedClasses = [];
71
+ _cancelAnimation;
72
+ _resizeObserver;
73
+ $icon;
74
+ $title;
75
+ $titleText;
76
+ $message;
77
+ $messageText;
78
+ $actionWrap;
79
+ $actionBtn;
80
+ $actionSlot;
81
+ $closeBtn;
82
+ constructor() {
83
+ super(), this.version = 2, this._state = {
84
+ open: !1,
85
+ type: "info",
86
+ title: "",
87
+ message: "",
88
+ placement: "topRight",
89
+ duration: 0,
90
+ closable: !0,
91
+ showIcon: !0,
92
+ width: "",
93
+ offset: 16,
94
+ zIndex: f,
95
+ maxCount: 0,
96
+ action: "",
97
+ customClass: ""
98
+ };
99
+ }
100
+ get notificationOffset() {
101
+ return this._state.offset;
102
+ }
103
+ get notificationGap() {
104
+ let e = parseFloat(getComputedStyle(this).getPropertyValue("--l-notification-gap"));
105
+ return Number.isFinite(e) ? e : 16;
106
+ }
107
+ get placement() {
108
+ return this._state.placement;
109
+ }
110
+ get open() {
111
+ return this._state.open;
112
+ }
113
+ set open(e) {
114
+ e ? this.show() : this.close();
115
+ }
116
+ static get observedAttributes() {
117
+ return [
118
+ "open",
119
+ "type",
120
+ "title",
121
+ "message",
122
+ "placement",
123
+ "duration",
124
+ "closable",
125
+ "show-icon",
126
+ "width",
127
+ "offset",
128
+ "z-index",
129
+ "max-count",
130
+ "action",
131
+ "custom-class"
132
+ ];
133
+ }
134
+ attributeChanged(e, r, a) {
135
+ switch (e) {
136
+ case "type":
137
+ this._state.type = a || "info";
138
+ break;
139
+ case "title":
140
+ this._state.title = a || "";
141
+ break;
142
+ case "message":
143
+ this._state.message = a || "";
144
+ break;
145
+ case "action":
146
+ this._state.action = a || "";
147
+ break;
148
+ case "custom-class":
149
+ this._state.customClass = a || "";
150
+ break;
151
+ case "placement":
152
+ this._state.placement = g(a);
153
+ break;
154
+ case "width":
155
+ this._state.width = i(a) || "";
156
+ break;
157
+ case "duration":
158
+ case "offset":
159
+ case "z-index":
160
+ case "max-count":
161
+ this._state[t(e)] = Number(a) || 0;
162
+ break;
163
+ case "open":
164
+ case "closable":
165
+ case "show-icon": this._state[t(e)] = n(a, !1, e);
166
+ }
167
+ }
168
+ updateDOM(e) {
169
+ (e.has("type") || e.has("show-icon")) && this._syncIcon(), (e.has("title") || e.has("message")) && this._syncSections(), e.has("action") && this._syncActions(), e.has("closable") && this._syncClose(), e.has("width") && this._syncWidth(), e.has("custom-class") && this._syncCustomClass(), (e.has("offset") || e.has("z-index")) && this._syncOffset(), e.has("placement") && this._updatePlacement(), e.has("duration") && this._visible && this._startTimer(), e.has("open") && this._toggleOpen();
170
+ }
171
+ connectedCallback() {
172
+ O(), super.connectedCallback();
173
+ }
174
+ disconnectedCallback() {
175
+ super.disconnectedCallback(), v(this), this._cancelPendingAnimation(), this._unobserveSize(), this._clearTimer(), this._visible = !1;
176
+ }
177
+ render_v2() {
178
+ return this._changedProperties.clear(), {
179
+ styleSheets: [d],
180
+ template: this.render()
181
+ };
182
+ }
183
+ afterInit() {
184
+ this._initRefs(), this._bindEvents(), this._syncAll(), this._state.open ? this._visible ? this._startTimer() : this._show() : (this._visible = !1, this.setAttribute("hidden", ""));
185
+ }
186
+ beforeDestroy() {
187
+ this._unbindEvents();
188
+ }
189
+ render() {
190
+ let e = y("div", {
191
+ class: "l-notification",
192
+ part: "default"
193
+ });
194
+ e.appendChild(y("div", {
195
+ class: "l-notification-icon",
196
+ part: "icon"
197
+ }));
198
+ let t = y("div", { class: "l-notification-content" });
199
+ return t.innerHTML = [
200
+ "<div class=\"l-notification-title\" part=\"title\">",
201
+ "<span class=\"l-notification-title-text\"></span>",
202
+ "<slot name=\"title\"></slot>",
203
+ "</div>",
204
+ "<div class=\"l-notification-message\" part=\"message\">",
205
+ "<span class=\"l-notification-message-text\"></span>",
206
+ "<slot></slot>",
207
+ "</div>",
208
+ "<div class=\"l-notification-actions\" part=\"actions\">",
209
+ "<button type=\"button\" class=\"l-notification-action\" part=\"action\"></button>",
210
+ "<slot name=\"action\"></slot>",
211
+ "</div>"
212
+ ].join(""), e.appendChild(t), e.appendChild(y("button", {
213
+ class: "l-notification-close",
214
+ part: "close",
215
+ type: "button",
216
+ "aria-label": "关闭",
217
+ innerHTML: "<l-close-icon></l-close-icon>"
218
+ })), e;
219
+ }
220
+ show() {
221
+ this._state.open = !0, this._toggleOpen();
222
+ }
223
+ close() {
224
+ this._state.open = !1, this._toggleOpen();
225
+ }
226
+ _initRefs() {
227
+ let e = this.root;
228
+ this.$icon = b(".l-notification-icon", e), this.$title = b(".l-notification-title", e), this.$titleText = b(".l-notification-title-text", e), this.$message = b(".l-notification-message", e), this.$messageText = b(".l-notification-message-text", e), this.$actionWrap = b(".l-notification-actions", e), this.$actionBtn = b(".l-notification-action", e), this.$actionSlot = b("slot[name=\"action\"]", e), this.$closeBtn = b(".l-notification-close", e);
229
+ }
230
+ _bindEvents() {
231
+ S(this, "mouseenter", this._handleMouseEnter), S(this, "mouseleave", this._handleMouseLeave), this.$closeBtn && S(this.$closeBtn, "click", this._handleCloseClick), this.$actionBtn && S(this.$actionBtn, "click", this._handleActionClick), this.root.querySelectorAll("slot").forEach((e) => {
232
+ S(e, "slotchange", this._handleSlotChange);
233
+ });
234
+ }
235
+ _unbindEvents() {
236
+ x(this, "mouseenter", this._handleMouseEnter), x(this, "mouseleave", this._handleMouseLeave), this.$closeBtn && x(this.$closeBtn, "click", this._handleCloseClick), this.$actionBtn && x(this.$actionBtn, "click", this._handleActionClick), this.root.querySelectorAll("slot").forEach((e) => {
237
+ x(e, "slotchange", this._handleSlotChange);
238
+ });
239
+ }
240
+ _syncAll() {
241
+ this._syncIcon(), this._syncSections(), this._syncActions(), this._syncClose(), this._syncWidth(), this._syncOffset(), this._syncCustomClass();
242
+ }
243
+ _syncIcon() {
244
+ let e = this.$icon;
245
+ if (!e) return;
246
+ let t = T[this._state.type] || T.info;
247
+ e.dataset.icon !== t && (e.dataset.icon = t, e.innerHTML = `<l-${t}-icon></l-${t}-icon>`), e.toggleAttribute("hidden", !this._state.showIcon);
248
+ }
249
+ _syncSections() {
250
+ this._syncSection(this.$title, this.$titleText, this._state.title, !0), this._syncSection(this.$message, this.$messageText, this._state.message, !1);
251
+ }
252
+ _syncSection(e, t, n = "", r = !1) {
253
+ if (!e || !t) return;
254
+ r ? t.textContent = n : t.innerHTML = n;
255
+ let i = e.querySelector("slot"), a = this._hasSlotContent(i), o = n !== "";
256
+ t.toggleAttribute("hidden", a || !o), e.toggleAttribute("hidden", !(a || o));
257
+ }
258
+ _syncActions() {
259
+ let e = this.$actionWrap, t = this.$actionBtn;
260
+ if (!e || !t) return;
261
+ let n = this._state.action;
262
+ t.textContent = n;
263
+ let r = this._hasSlotContent(this.$actionSlot);
264
+ t.toggleAttribute("hidden", r || n === ""), e.toggleAttribute("hidden", !(r || n !== ""));
265
+ }
266
+ _syncClose() {
267
+ this.$closeBtn && this.$closeBtn.toggleAttribute("hidden", !this._state.closable);
268
+ }
269
+ _syncWidth() {
270
+ this._state.width ? this.style.setProperty("--l-notification-width", this._state.width) : this.style.removeProperty("--l-notification-width");
271
+ }
272
+ _syncOffset() {
273
+ this.style.setProperty("--l-notification-offset", `${this._state.offset}px`), this.style.setProperty("--l-notification-zindex", `${this._state.zIndex}`), this._visible && h(this._state.placement);
274
+ }
275
+ _syncCustomClass() {
276
+ for (let e of this._appliedClasses) this.classList.remove(e);
277
+ this._appliedClasses = this._state.customClass ? this._state.customClass.split(/\s+/).filter(Boolean) : [];
278
+ for (let e of this._appliedClasses) this.classList.add(e);
279
+ }
280
+ _hasSlotContent(e) {
281
+ return e ? e.assignedNodes().some((e) => e.nodeType !== 3 || (e.textContent || "").trim() !== "") : !1;
282
+ }
283
+ _updatePlacement() {
284
+ this._visible && _(this, this._state.placement);
285
+ }
286
+ _toggleOpen() {
287
+ this.rendered && (this._state.open ? this._show() : this._hide());
288
+ }
289
+ _show() {
290
+ this._visible || (this._visible = !0, this.removeAttribute("hidden"), _(this, this._state.placement), this._observeSize(), this._enter(), this._startTimer(), this._enforceMaxCount());
291
+ }
292
+ _hide() {
293
+ this._visible && (this._visible = !1, this._clearTimer(), this._unobserveSize(), v(this), this.emit("close", { detail: { id: this.id } }), this._leave(() => {
294
+ this.removeOnClose ? this.remove() : this.setAttribute("hidden", "");
295
+ }));
296
+ }
297
+ _enforceMaxCount() {
298
+ let e = this._state.maxCount;
299
+ if (e <= 0) return;
300
+ let t = this._state.placement;
301
+ for (; p(t) > e;) {
302
+ let e = m(t);
303
+ if (!e || e === this) break;
304
+ e.close();
305
+ }
306
+ }
307
+ _enter() {
308
+ this.classList.add("l-notification-enter"), this.offsetHeight, this.classList.add("l-notification-enter-active"), this.classList.remove("l-notification-enter"), this._onceTransitionEnd("opacity", () => {
309
+ this.classList.remove("l-notification-enter-active");
310
+ });
311
+ }
312
+ _leave(e) {
313
+ this.classList.add("l-notification-leave-active"), this.offsetHeight, this.classList.add("l-notification-leave"), this._onceTransitionEnd("opacity", () => {
314
+ this.classList.remove("l-notification-leave-active"), this.classList.remove("l-notification-leave"), e();
315
+ });
316
+ }
317
+ _transitionDuration() {
318
+ let e = (getComputedStyle(this).transitionDuration || "").split(",")[0].trim(), t = parseFloat(e);
319
+ return t ? e.endsWith("ms") ? t : t * 1e3 : 300;
320
+ }
321
+ _onceTransitionEnd(e, t) {
322
+ this._cancelPendingAnimation();
323
+ let n = !1, r = 0, i = (t) => {
324
+ let n = t;
325
+ n.target === this && n.propertyName === e && a();
326
+ }, a = () => {
327
+ n || (n = !0, this.removeEventListener("transitionend", i), clearTimeout(r), this._cancelAnimation = void 0, t());
328
+ };
329
+ this._cancelAnimation = () => {
330
+ n = !0, this.removeEventListener("transitionend", i), clearTimeout(r), this._cancelAnimation = void 0;
331
+ }, this.addEventListener("transitionend", i), r = window.setTimeout(a, this._transitionDuration() + 100);
332
+ }
333
+ _cancelPendingAnimation() {
334
+ let e = this._cancelAnimation;
335
+ e && (this._cancelAnimation = void 0, e());
336
+ }
337
+ _observeSize() {
338
+ this._resizeObserver || typeof ResizeObserver > "u" || (this._resizeObserver = new ResizeObserver(() => {
339
+ this._visible && h(this._state.placement);
340
+ }), this._resizeObserver.observe(this));
341
+ }
342
+ _unobserveSize() {
343
+ this._resizeObserver &&= (this._resizeObserver.disconnect(), void 0);
344
+ }
345
+ _startTimer() {
346
+ this._clearTimer();
347
+ let e = this._state.duration;
348
+ e <= 0 || (this._remaining = e, this._startTime = Date.now(), this._timer = window.setTimeout(() => {
349
+ this._timer = void 0, this.close();
350
+ }, e));
351
+ }
352
+ _clearTimer() {
353
+ this._timer != null && (clearTimeout(this._timer), this._timer = void 0), this._remaining = 0;
354
+ }
355
+ _pauseTimer() {
356
+ this._timer != null && (clearTimeout(this._timer), this._timer = void 0, this._remaining = Math.max(0, this._remaining - (Date.now() - this._startTime)));
357
+ }
358
+ _resumeTimer() {
359
+ this._timer != null || this._remaining <= 0 || (this._startTime = Date.now(), this._timer = window.setTimeout(() => {
360
+ this._timer = void 0, this.close();
361
+ }, this._remaining));
362
+ }
363
+ _handleMouseEnter = () => {
364
+ this._pauseTimer();
365
+ };
366
+ _handleMouseLeave = () => {
367
+ this._resumeTimer();
368
+ };
369
+ _handleCloseClick = (e) => {
370
+ e.stopPropagation(), this.close();
371
+ };
372
+ _handleActionClick = () => {
373
+ this.emit("action", { detail: { id: this.id } });
374
+ };
375
+ _handleSlotChange = () => {
376
+ this._syncSections(), this._syncActions();
377
+ };
378
+ };
379
+ //#endregion
380
+ export { N as default };
@@ -0,0 +1,4 @@
1
+ //#region src/components/notification/index.less?inline
2
+ var e = ":host{--l-notification-width:330px;--l-notification-gap:16px;--l-notification-offset:16px;--l-notification-zindex:2000;--l-notification-padding:16px;--l-notification-radius:8px;--l-notification-background:#fff;--l-notification-shadow:0 6px 16px 0 #00000014, 0 3px 6px -4px #0000001f, 0 9px 28px 8px #0000000d;--l-notification-title-color:#000000e0;--l-notification-message-color:#000000a6;--l-notification-icon-size:22px;--l-notification-anim-duration:.3s;--l-notification-enter-offset:-20px;--l-notification-color:var(--l-primary-color,#007bff);--l-notification-action-hover-background:#0000000a;--l-notification-close-hover-background:#0000000f;z-index:var(--l-notification-zindex,2000);width:var(--l-notification-width);box-sizing:border-box;max-width:calc(100vw - 32px);color:var(--l-notification-title-color);transition:top var(--l-notification-anim-duration) ease, bottom var(--l-notification-anim-duration) ease;font-size:14px;line-height:1.5715;position:fixed}:host([placement=topLeft]),:host([placement=bottomLeft]){left:var(--l-notification-offset,16px);right:auto}:host([placement=topRight]),:host([placement=bottomRight]){right:var(--l-notification-offset,16px);left:auto}:host([placement=bottomLeft]),:host([placement=bottomRight]){--l-notification-enter-offset:20px}:host([hidden]){display:none}:host([type=info]){--l-notification-color:var(--l-primary-color,#007bff)}:host([type=success]){--l-notification-color:var(--l-success-color,#52c41a)}:host([type=error]){--l-notification-color:var(--l-error-color,#f5222d)}:host([type=warning]){--l-notification-color:var(--l-warning-color,#faad14)}:host(.l-notification-enter),:host(.l-notification-leave){opacity:0;transform:translateY(var(--l-notification-enter-offset)) scale(.95)}:host(.l-notification-enter-active),:host(.l-notification-leave-active){transition:top var(--l-notification-anim-duration) ease, bottom var(--l-notification-anim-duration) ease, opacity var(--l-notification-anim-duration) ease, transform var(--l-notification-anim-duration) ease}.l-notification{padding:var(--l-notification-padding);background:var(--l-notification-background);border-radius:var(--l-notification-radius);box-shadow:var(--l-notification-shadow);border-left:4px solid var(--l-notification-color);box-sizing:border-box;align-items:flex-start;gap:10px;display:flex;position:relative}.l-notification-icon{height:calc(var(--l-notification-icon-size) * 1.4);font-size:var(--l-notification-icon-size);color:var(--l-notification-color);flex:none;justify-content:center;align-items:center;display:inline-flex}.l-notification-content{flex:1;min-width:0}.l-notification-title{color:var(--l-notification-title-color);word-break:break-word;margin-bottom:4px;font-size:16px;font-weight:500}.l-notification-message{color:var(--l-notification-message-color);word-break:break-word}.l-notification-message-text{display:block}.l-notification-actions{align-items:center;gap:8px;margin-top:12px;display:flex}.l-notification-action{border:1px solid var(--l-notification-color);border-radius:var(--l-border-radius,3px);height:28px;color:var(--l-notification-color);cursor:pointer;background:0 0;justify-content:center;align-items:center;padding:0 12px;font-size:14px;line-height:1;transition:opacity .3s,background-color .3s;display:inline-flex}.l-notification-action:hover{opacity:.8;background:var(--l-notification-action-hover-background)}.l-notification-close{width:22px;height:22px;color:var(--l-notification-message-color);cursor:pointer;background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;margin-left:auto;padding:0;font-size:14px;transition:color .3s,background-color .3s;display:inline-flex}.l-notification-close:hover{color:var(--l-notification-title-color);background:var(--l-notification-close-hover-background)}.l-notification-title[hidden],.l-notification-message[hidden],.l-notification-actions[hidden],.l-notification-icon[hidden],.l-notification-close[hidden],.l-notification-title-text[hidden],.l-notification-message-text[hidden]{display:none}";
3
+ //#endregion
4
+ export { e as default };
@@ -0,0 +1,49 @@
1
+ /**
2
+ * 通知方位与布局管理
3
+ *
4
+ * 同一个方位上的通知不会相互叠加: 每个通知都是 `position: fixed`,
5
+ * 由这里统一计算它们在所在方位上的位置, 新增/移除时重新排布,
6
+ * 位置变化通过 CSS 过渡形成平滑的位移动画。
7
+ *
8
+ * 通知节点不会被移动到其他位置, 因此声明式使用时依然由使用方管理其生命周期。
9
+ */
10
+ /** 通知显示方位 */
11
+ export type NotificationPlacement = "topLeft" | "topRight" | "bottomLeft" | "bottomRight";
12
+ export declare const PLACEMENTS: NotificationPlacement[];
13
+ /** 默认显示方位 */
14
+ export declare const DEFAULT_PLACEMENT: NotificationPlacement;
15
+ /** 默认距离视口边缘的距离(px) */
16
+ export declare const DEFAULT_OFFSET = 16;
17
+ /** 默认层级 */
18
+ export declare const DEFAULT_ZINDEX = 2000;
19
+ /** 默认通知之间的间距(px) */
20
+ export declare const DEFAULT_GAP = 16;
21
+ /** 参与布局的通知需要提供的信息 */
22
+ export interface NotificationLayoutItem extends HTMLElement {
23
+ /** 距离视口边缘的距离(px) */
24
+ readonly notificationOffset: number;
25
+ /** 与相邻通知的间距(px) */
26
+ readonly notificationGap: number;
27
+ }
28
+ /** 是否为顶部方位 */
29
+ export declare function isTopPlacement(placement: string): boolean;
30
+ /** 是否为左侧方位 */
31
+ export declare function isLeftPlacement(placement: string): boolean;
32
+ /** 规范化方位, 非法值回退为 `topRight` */
33
+ export declare function normalizePlacement(placement?: string | null): NotificationPlacement;
34
+ /** 查询通知所在的方位 */
35
+ export declare function findPlacement($el: HTMLElement): NotificationPlacement | undefined;
36
+ /** 某个方位上正在显示的通知数量 */
37
+ export declare function getGroupSize(placement: NotificationPlacement): number;
38
+ /** 某个方位上最早创建的通知(最远离角落) */
39
+ export declare function getOldestNotification(placement: NotificationPlacement): NotificationLayoutItem | undefined;
40
+ /**
41
+ * 注册到方位分组并重新排布
42
+ *
43
+ * 最新创建的通知放在最靠近角落的位置, 已有的通知依次向后移动。
44
+ */
45
+ export declare function registerNotification($el: NotificationLayoutItem, placement: NotificationPlacement): void;
46
+ /** 从方位分组中移除并重新排布 */
47
+ export declare function unregisterNotification($el: NotificationLayoutItem): void;
48
+ /** 重新计算某个方位上所有通知的位置 */
49
+ export declare function layoutGroup(placement: NotificationPlacement): void;