@veltra/desktop 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (400) hide show
  1. package/dist/components/action/action-group.vue.d.ts +4 -4
  2. package/dist/components/action/action.vue.d.ts +4 -2
  3. package/dist/components/action/index.d.ts +3 -2
  4. package/dist/components/action/style.d.ts +2 -1
  5. package/dist/components/auto-complete/auto-complete.vue.d.ts +4 -3
  6. package/dist/components/auto-complete/index.d.ts +2 -1
  7. package/dist/components/auto-complete/style.d.ts +4 -1
  8. package/dist/components/auto-complete/use-keyboard.js +1 -1
  9. package/dist/components/auto-complete/use-keyboard.js.map +1 -1
  10. package/dist/components/badge/badge.vue.d.ts +2 -1
  11. package/dist/components/badge/index.d.ts +2 -1
  12. package/dist/components/batch-edit/batch-edit.vue.d.ts +11 -9
  13. package/dist/components/batch-edit/helper.d.ts +1 -0
  14. package/dist/components/batch-edit/index.d.ts +3 -2
  15. package/dist/components/batch-edit/style.d.ts +5 -1
  16. package/dist/components/batch-edit/use-features.js +1 -1
  17. package/dist/components/batch-edit/use-features.js.map +1 -1
  18. package/dist/components/breadcrumb/breadcrumb.vue.d.ts +2 -1
  19. package/dist/components/breadcrumb/index.d.ts +2 -1
  20. package/dist/components/button/button-group.vue.d.ts +2 -1
  21. package/dist/components/button/button.vue.d.ts +2 -1
  22. package/dist/components/button/index.d.ts +3 -2
  23. package/dist/components/button/style.d.ts +1 -1
  24. package/dist/components/calendar/calendar.vue.d.ts +2 -1
  25. package/dist/components/calendar/index.d.ts +2 -1
  26. package/dist/components/card/card-action.vue.d.ts +2 -1
  27. package/dist/components/card/card-content.vue.d.ts +2 -1
  28. package/dist/components/card/card-cover.vue.d.ts +2 -1
  29. package/dist/components/card/card-header.vue.d.ts +1 -1
  30. package/dist/components/card/card.vue.d.ts +2 -1
  31. package/dist/components/card/index.d.ts +6 -5
  32. package/dist/components/cascade/cascade.vue.d.ts +7 -6
  33. package/dist/components/cascade/index.d.ts +2 -1
  34. package/dist/components/cascade/style.d.ts +3 -1
  35. package/dist/components/check-tag/check-tag.vue.d.ts +2 -1
  36. package/dist/components/check-tag/index.d.ts +2 -1
  37. package/dist/components/checkbox/checkbox-button.vue.d.ts +3 -2
  38. package/dist/components/checkbox/checkbox.vue.d.ts +2 -1
  39. package/dist/components/checkbox/index.d.ts +3 -2
  40. package/dist/components/checkbox/style.d.ts +1 -1
  41. package/dist/components/checkbox-group/checkbox-group.vue.d.ts +4 -3
  42. package/dist/components/checkbox-group/index.d.ts +2 -1
  43. package/dist/components/checkbox-group/style.d.ts +1 -1
  44. package/dist/components/code-editor/code-editor.vue.d.ts +4 -3
  45. package/dist/components/code-editor/index.d.ts +2 -1
  46. package/dist/components/code-editor/langs/spel/language.js +2 -2
  47. package/dist/components/code-editor/langs/spel/language.js.map +1 -1
  48. package/dist/components/code-editor/style.d.ts +1 -1
  49. package/dist/components/collapse/collapse-item.vue.d.ts +4 -3
  50. package/dist/components/collapse/collapse.vue.d.ts +2 -1
  51. package/dist/components/collapse/index.d.ts +3 -2
  52. package/dist/components/condition-editor/condition-editor.vue.d.ts +3 -1
  53. package/dist/components/condition-editor/core/evaluator.d.ts +1 -0
  54. package/dist/components/condition-editor/index.d.ts +3 -2
  55. package/dist/components/condition-editor/style.d.ts +2 -1
  56. package/dist/components/contextmenu/api.d.ts +1 -0
  57. package/dist/components/contextmenu/contextmenu.vue.d.ts +2 -1
  58. package/dist/components/contextmenu/index.d.ts +3 -2
  59. package/dist/components/contextmenu/style.d.ts +2 -1
  60. package/dist/components/date-panel/date-panel.vue.d.ts +3 -2
  61. package/dist/components/date-panel/index.d.ts +2 -1
  62. package/dist/components/date-picker/date-picker.vue.d.ts +4 -3
  63. package/dist/components/date-picker/index.d.ts +2 -1
  64. package/dist/components/date-picker/style.d.ts +2 -1
  65. package/dist/components/date-range-picker/date-range-picker.vue.d.ts +4 -3
  66. package/dist/components/date-range-picker/index.d.ts +2 -1
  67. package/dist/components/date-range-picker/style.d.ts +1 -1
  68. package/dist/components/dialog/dialog.vue.d.ts +5 -2
  69. package/dist/components/dialog/index.d.ts +2 -1
  70. package/dist/components/dialog/style.d.ts +1 -1
  71. package/dist/components/drawer/drawer.vue.d.ts +3 -1
  72. package/dist/components/drawer/index.d.ts +2 -1
  73. package/dist/components/drawer/style.d.ts +1 -1
  74. package/dist/components/dropdown/dropdown.vue.d.ts +6 -2
  75. package/dist/components/dropdown/index.d.ts +2 -1
  76. package/dist/components/dropdown/style.d.ts +1 -1
  77. package/dist/components/dual-nav/dual-nav.vue.d.ts +2 -1
  78. package/dist/components/dual-nav/index.d.ts +2 -1
  79. package/dist/components/dual-nav/style.d.ts +1 -1
  80. package/dist/components/empty/empty.vue.d.ts +3 -2
  81. package/dist/components/empty/index.d.ts +2 -1
  82. package/dist/components/expression-editor/expression-editor.vue.d.ts +3 -1
  83. package/dist/components/expression-editor/index.d.ts +2 -1
  84. package/dist/components/file-picker/file-picker.js +6 -3
  85. package/dist/components/file-picker/file-picker.js.map +1 -1
  86. package/dist/components/file-picker/file-picker.vue.d.ts +2 -1
  87. package/dist/components/file-picker/index.d.ts +2 -1
  88. package/dist/components/file-viewer/file-viewer.js +2 -2
  89. package/dist/components/file-viewer/file-viewer.js.map +1 -1
  90. package/dist/components/file-viewer/file-viewer.vue.d.ts +1 -2
  91. package/dist/components/file-viewer/helper.js +4 -4
  92. package/dist/components/file-viewer/helper.js.map +1 -1
  93. package/dist/components/file-viewer/index.d.ts +2 -1
  94. package/dist/components/float-button/float-button.vue.d.ts +2 -1
  95. package/dist/components/float-button/index.d.ts +2 -1
  96. package/dist/components/float-button/style.d.ts +1 -1
  97. package/dist/components/form/form.vue.d.ts +2 -1
  98. package/dist/components/form/index.d.ts +2 -1
  99. package/dist/components/form-item/form-item.vue.d.ts +4 -2
  100. package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js +1 -1
  101. package/dist/components/form-item/form-item.vue_vue_type_script_setup_true_lang.js.map +1 -1
  102. package/dist/components/form-item/index.d.ts +2 -1
  103. package/dist/components/gantt-chart/gantt-chart.vue.d.ts +2 -1
  104. package/dist/components/gantt-chart/index.d.ts +2 -1
  105. package/dist/components/grid/grid-item.vue.d.ts +2 -1
  106. package/dist/components/grid/grid.vue.d.ts +3 -1
  107. package/dist/components/grid/index.d.ts +3 -2
  108. package/dist/components/grid/use-responsive.js +2 -1
  109. package/dist/components/grid/use-responsive.js.map +1 -1
  110. package/dist/components/grid-input/grid-input.vue.d.ts +3 -1
  111. package/dist/components/grid-input/index.d.ts +2 -1
  112. package/dist/components/group-input/group-input.vue.d.ts +4 -3
  113. package/dist/components/group-input/index.d.ts +2 -1
  114. package/dist/components/group-input/style.d.ts +1 -1
  115. package/dist/components/group-nav/group-nav.vue.d.ts +1 -2
  116. package/dist/components/group-nav/index.d.ts +2 -1
  117. package/dist/components/icon/icon.vue.d.ts +2 -1
  118. package/dist/components/icon/index.d.ts +2 -1
  119. package/dist/components/index.d.ts +168 -92
  120. package/dist/components/index.js +5 -5
  121. package/dist/components/input/index.d.ts +2 -1
  122. package/dist/components/input/input.vue.d.ts +10 -9
  123. package/dist/components/input/style.d.ts +1 -1
  124. package/dist/components/kbd/kbd.vue.d.ts +1 -1
  125. package/dist/components/layout/index.d.ts +2 -1
  126. package/dist/components/layout/layout.vue.d.ts +2 -1
  127. package/dist/components/list/index.d.ts +3 -2
  128. package/dist/components/list/list-item.vue.d.ts +1 -1
  129. package/dist/components/list/list.vue.d.ts +2 -1
  130. package/dist/components/list/style.d.ts +1 -1
  131. package/dist/components/loading/directive.d.ts +0 -1
  132. package/dist/components/loading/index.d.ts +3 -2
  133. package/dist/components/loading/loading.vue.d.ts +3 -1
  134. package/dist/components/loading/style.d.ts +1 -1
  135. package/dist/components/message/index.d.ts +3 -2
  136. package/dist/components/message/message.d.ts +1 -0
  137. package/dist/components/message/message.vue.d.ts +3 -1
  138. package/dist/components/message-confirm/index.d.ts +3 -2
  139. package/dist/components/message-confirm/message-confirm-box.js +39 -0
  140. package/dist/components/message-confirm/message-confirm-box.js.map +1 -0
  141. package/dist/components/message-confirm/message-confirm.d.ts +5 -7
  142. package/dist/components/message-confirm/message-confirm.js +32 -46
  143. package/dist/components/message-confirm/message-confirm.js.map +1 -1
  144. package/dist/components/message-confirm/message-confirm.vue.d.ts +8 -4
  145. package/dist/components/message-confirm/message-confirm2.js +98 -23
  146. package/dist/components/message-confirm/message-confirm2.js.map +1 -1
  147. package/dist/components/message-confirm/style2.css +9 -9
  148. package/dist/components/multi-select/index.d.ts +2 -1
  149. package/dist/components/multi-select/multi-select.vue.d.ts +10 -9
  150. package/dist/components/multi-select/style.d.ts +5 -1
  151. package/dist/components/multi-tree-select/index.d.ts +2 -1
  152. package/dist/components/multi-tree-select/multi-tree-select.vue.d.ts +6 -6
  153. package/dist/components/multi-tree-select/style.d.ts +6 -1
  154. package/dist/components/nav/index.d.ts +4 -3
  155. package/dist/components/nav/nav-item.vue.d.ts +2 -1
  156. package/dist/components/nav/nav-sub.vue.d.ts +2 -1
  157. package/dist/components/nav/nav.vue.d.ts +2 -1
  158. package/dist/components/node-render/index.d.ts +2 -1
  159. package/dist/components/node-render/node-render.d.ts +1 -2
  160. package/dist/components/notification/index.d.ts +3 -8
  161. package/dist/components/notification/notification-box.js +130 -0
  162. package/dist/components/notification/notification-box.js.map +1 -0
  163. package/dist/components/notification/notification.d.ts +8 -0
  164. package/dist/components/notification/notification.js +62 -84
  165. package/dist/components/notification/notification.js.map +1 -1
  166. package/dist/components/notification/notification.vue.d.ts +10 -5
  167. package/dist/components/notification/notification2.js +134 -0
  168. package/dist/components/notification/notification2.js.map +1 -0
  169. package/dist/components/notification/style2.css +62 -32
  170. package/dist/components/number/index.d.ts +2 -1
  171. package/dist/components/number/number.vue.d.ts +2 -1
  172. package/dist/components/number-input/index.d.ts +2 -1
  173. package/dist/components/number-input/number-input.js +2 -1
  174. package/dist/components/number-input/number-input.js.map +1 -1
  175. package/dist/components/number-input/number-input.vue.d.ts +8 -6
  176. package/dist/components/number-input/style.d.ts +2 -1
  177. package/dist/components/number-range-input/index.d.ts +2 -1
  178. package/dist/components/number-range-input/number-range-input.js +4 -2
  179. package/dist/components/number-range-input/number-range-input.js.map +1 -1
  180. package/dist/components/number-range-input/number-range-input.vue.d.ts +3 -2
  181. package/dist/components/number-range-input/style.d.ts +1 -1
  182. package/dist/components/paginator/index.d.ts +2 -1
  183. package/dist/components/paginator/paginator.vue.d.ts +2 -1
  184. package/dist/components/paginator/style.d.ts +2 -1
  185. package/dist/components/palette/index.d.ts +2 -1
  186. package/dist/components/palette/palette-sv.js +4 -2
  187. package/dist/components/palette/palette-sv.js.map +1 -1
  188. package/dist/components/palette/palette.vue.d.ts +2 -1
  189. package/dist/components/palette/style.d.ts +2 -1
  190. package/dist/components/password-input/index.d.ts +2 -1
  191. package/dist/components/password-input/password-input.vue.d.ts +3 -2
  192. package/dist/components/password-input/style.d.ts +1 -1
  193. package/dist/components/pop-confirm/index.d.ts +2 -1
  194. package/dist/components/pop-confirm/pop-confirm.vue.d.ts +3 -1
  195. package/dist/components/pop-confirm/style.d.ts +1 -1
  196. package/dist/components/progress/index.d.ts +2 -1
  197. package/dist/components/progress/progress.vue.d.ts +4 -3
  198. package/dist/components/progress-nodes/index.d.ts +2 -1
  199. package/dist/components/progress-nodes/progress-nodes.js +2 -1
  200. package/dist/components/progress-nodes/progress-nodes.js.map +1 -1
  201. package/dist/components/progress-nodes/progress-nodes.vue.d.ts +8 -7
  202. package/dist/components/radio/index.d.ts +2 -1
  203. package/dist/components/radio/radio.vue.d.ts +2 -1
  204. package/dist/components/radio/style.d.ts +1 -1
  205. package/dist/components/radio-group/index.d.ts +2 -1
  206. package/dist/components/radio-group/radio-group.vue.d.ts +4 -3
  207. package/dist/components/radio-group/style.d.ts +1 -1
  208. package/dist/components/rich-text-editor/index.d.ts +2 -1
  209. package/dist/components/rich-text-editor/rich-text-editor.js +2 -1
  210. package/dist/components/rich-text-editor/rich-text-editor.js.map +1 -1
  211. package/dist/components/rich-text-editor/rich-text-editor.vue.d.ts +4 -2
  212. package/dist/components/rich-text-editor/toolbar.js +2 -1
  213. package/dist/components/rich-text-editor/toolbar.js.map +1 -1
  214. package/dist/components/scroll/index.d.ts +2 -1
  215. package/dist/components/scroll/scroll.vue.d.ts +5 -2
  216. package/dist/components/select/index.d.ts +2 -1
  217. package/dist/components/select/select.vue.d.ts +7 -4
  218. package/dist/components/select/style.d.ts +3 -1
  219. package/dist/components/slider/index.d.ts +2 -1
  220. package/dist/components/slider/slider.vue.d.ts +4 -3
  221. package/dist/components/steps/index.d.ts +2 -1
  222. package/dist/components/steps/steps.vue.d.ts +4 -3
  223. package/dist/components/switch/index.d.ts +2 -1
  224. package/dist/components/switch/switch.vue.d.ts +2 -1
  225. package/dist/components/table/index.d.ts +3 -2
  226. package/dist/components/table/node/col.d.ts +1 -1
  227. package/dist/components/table/node/row.d.ts +0 -1
  228. package/dist/components/table/style.d.ts +3 -1
  229. package/dist/components/table/table-row.js +2 -1
  230. package/dist/components/table/table-row.js.map +1 -1
  231. package/dist/components/table/table.vue.d.ts +3 -1
  232. package/dist/components/table/use-columns.d.ts +3 -0
  233. package/dist/components/table/use-columns.js +2 -1
  234. package/dist/components/table/use-columns.js.map +1 -1
  235. package/dist/components/table-editor/index.d.ts +2 -1
  236. package/dist/components/table-editor/style.d.ts +2 -1
  237. package/dist/components/table-editor/table-editor.vue.d.ts +2 -1
  238. package/dist/components/tabs/index.d.ts +4 -3
  239. package/dist/components/tabs/style.d.ts +2 -1
  240. package/dist/components/tabs/tabs-horizontal.vue.d.ts +5 -4
  241. package/dist/components/tabs/tabs-vertical.vue.d.ts +5 -4
  242. package/dist/components/tabs/tabs.vue.d.ts +5 -4
  243. package/dist/components/tag/index.d.ts +2 -1
  244. package/dist/components/tag/tag.vue.d.ts +2 -1
  245. package/dist/components/text/index.d.ts +2 -1
  246. package/dist/components/text/text.vue.d.ts +2 -1
  247. package/dist/components/textarea/index.d.ts +2 -1
  248. package/dist/components/textarea/style.d.ts +1 -1
  249. package/dist/components/textarea/textarea.js +4 -2
  250. package/dist/components/textarea/textarea.js.map +1 -1
  251. package/dist/components/textarea/textarea.vue.d.ts +6 -5
  252. package/dist/components/theme/index.d.ts +2 -1
  253. package/dist/components/theme/style.d.ts +5 -1
  254. package/dist/components/theme/theme.vue.d.ts +2 -1
  255. package/dist/components/tip/index.d.ts +2 -1
  256. package/dist/components/tip/tip.vue.d.ts +3 -1
  257. package/dist/components/tree/di.d.ts +2 -0
  258. package/dist/components/tree/index.d.ts +2 -1
  259. package/dist/components/tree/style.d.ts +1 -1
  260. package/dist/components/tree/tree.vue.d.ts +3 -1
  261. package/dist/components/tree-select/index.d.ts +2 -1
  262. package/dist/components/tree-select/style.d.ts +3 -1
  263. package/dist/components/tree-select/tree-select.vue.d.ts +9 -7
  264. package/dist/components/watermark/index.d.ts +2 -1
  265. package/dist/components/watermark/watermark.vue.d.ts +2 -1
  266. package/dist/index.d.ts +97 -98
  267. package/dist/index.js +3 -3
  268. package/dist/install.d.ts +1 -1
  269. package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js +13 -4
  270. package/dist/node_modules/.bun/@codemirror_autocomplete@6.20.3/node_modules/@codemirror/autocomplete/dist/index.js.map +1 -1
  271. package/dist/node_modules/.bun/@codemirror_commands@6.10.4/node_modules/@codemirror/commands/dist/index.js +1 -1
  272. package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js +3 -2
  273. package/dist/node_modules/.bun/@codemirror_lang-css@6.3.1/node_modules/@codemirror/lang-css/dist/index.js.map +1 -1
  274. package/dist/node_modules/.bun/@codemirror_lang-html@6.4.11/node_modules/@codemirror/lang-html/dist/index.js +1 -1
  275. package/dist/node_modules/.bun/@codemirror_lang-java@6.0.2/node_modules/@codemirror/lang-java/dist/index.js +1 -1
  276. package/dist/node_modules/.bun/@codemirror_lang-javascript@6.2.5/node_modules/@codemirror/lang-javascript/dist/index.js +1 -1
  277. package/dist/node_modules/.bun/@codemirror_lang-json@6.0.2/node_modules/@codemirror/lang-json/dist/index.js +1 -1
  278. package/dist/node_modules/.bun/@codemirror_lang-markdown@6.5.1/node_modules/@codemirror/lang-markdown/dist/index.js +1 -1
  279. package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js +31 -5
  280. package/dist/node_modules/.bun/@codemirror_lang-sql@6.10.0/node_modules/@codemirror/lang-sql/dist/index.js.map +1 -1
  281. package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js +5 -3
  282. package/dist/node_modules/.bun/@codemirror_language@6.12.4/node_modules/@codemirror/language/dist/index.js.map +1 -1
  283. package/dist/node_modules/.bun/@codemirror_lint@6.9.7/node_modules/@codemirror/lint/dist/index.js +1 -1
  284. package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js +3 -2
  285. package/dist/node_modules/.bun/@codemirror_search@6.7.1/node_modules/@codemirror/search/dist/index.js.map +1 -1
  286. package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js +3 -2
  287. package/dist/node_modules/.bun/@codemirror_state@6.7.0/node_modules/@codemirror/state/dist/index.js.map +1 -1
  288. package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js +30 -7
  289. package/dist/node_modules/.bun/@codemirror_theme-one-dark@6.1.3/node_modules/@codemirror/theme-one-dark/dist/index.js.map +1 -1
  290. package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js +11 -5
  291. package/dist/node_modules/.bun/@codemirror_view@6.43.4/node_modules/@codemirror/view/dist/index.js.map +1 -1
  292. package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js +3 -2
  293. package/dist/node_modules/.bun/@lezer_common@1.5.2/node_modules/@lezer/common/dist/index.js.map +1 -1
  294. package/dist/node_modules/.bun/@lezer_css@1.3.4/node_modules/@lezer/css/dist/index.js +20 -2
  295. package/dist/node_modules/.bun/@lezer_css@1.3.4/node_modules/@lezer/css/dist/index.js.map +1 -1
  296. package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js +15 -2
  297. package/dist/node_modules/.bun/@lezer_highlight@1.2.3/node_modules/@lezer/highlight/dist/index.js.map +1 -1
  298. package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js +42 -3
  299. package/dist/node_modules/.bun/@lezer_html@1.3.13/node_modules/@lezer/html/dist/index.js.map +1 -1
  300. package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js +23 -2
  301. package/dist/node_modules/.bun/@lezer_javascript@1.5.4/node_modules/@lezer/javascript/dist/index.js.map +1 -1
  302. package/dist/node_modules/.bun/@lezer_lr@1.4.10/node_modules/@lezer/lr/dist/index.js +1 -1
  303. package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js +39 -29
  304. package/dist/node_modules/.bun/@lezer_markdown@1.7.2/node_modules/@lezer/markdown/dist/index.js.map +1 -1
  305. package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js +3 -2
  306. package/dist/node_modules/.bun/@marijn_find-cluster-break@1.0.2/node_modules/@marijn/find-cluster-break/src/index.js.map +1 -1
  307. package/dist/style.d.ts +39 -1
  308. package/dist/types/action.d.ts +0 -1
  309. package/dist/types/animation.d.ts +0 -1
  310. package/dist/types/auto-complete.d.ts +0 -1
  311. package/dist/types/badge.d.ts +0 -1
  312. package/dist/types/batch-edit.d.ts +18 -13
  313. package/dist/types/breadcrumb.d.ts +0 -1
  314. package/dist/types/button.d.ts +0 -1
  315. package/dist/types/calendar.d.ts +0 -1
  316. package/dist/types/card.d.ts +0 -1
  317. package/dist/types/cascade.d.ts +0 -1
  318. package/dist/types/check-tag.d.ts +0 -1
  319. package/dist/types/checkbox-group.d.ts +0 -1
  320. package/dist/types/checkbox.d.ts +0 -1
  321. package/dist/types/code-editor.d.ts +0 -1
  322. package/dist/types/collapse.d.ts +0 -1
  323. package/dist/types/condition-editor.d.ts +0 -1
  324. package/dist/types/contextmenu.d.ts +0 -1
  325. package/dist/types/css-transition.d.ts +0 -1
  326. package/dist/types/date-panel.d.ts +0 -1
  327. package/dist/types/date-picker.d.ts +0 -1
  328. package/dist/types/date-range-picker.d.ts +0 -1
  329. package/dist/types/dialog.d.ts +0 -1
  330. package/dist/types/drawer.d.ts +0 -1
  331. package/dist/types/dropdown.d.ts +2 -2
  332. package/dist/types/dual-nav.d.ts +0 -1
  333. package/dist/types/empty.d.ts +0 -1
  334. package/dist/types/expression-editor.d.ts +0 -1
  335. package/dist/types/file-picker.d.ts +0 -1
  336. package/dist/types/file-viewer.d.ts +0 -1
  337. package/dist/types/float-button.d.ts +0 -1
  338. package/dist/types/form-item.d.ts +0 -1
  339. package/dist/types/form.d.ts +0 -1
  340. package/dist/types/grid-input.d.ts +0 -1
  341. package/dist/types/grid.d.ts +1 -2
  342. package/dist/types/group-input.d.ts +0 -1
  343. package/dist/types/group-nav.d.ts +0 -1
  344. package/dist/types/index.d.ts +4 -6
  345. package/dist/types/input.d.ts +0 -1
  346. package/dist/types/layout.d.ts +0 -1
  347. package/dist/types/list.d.ts +0 -1
  348. package/dist/types/loading.d.ts +0 -1
  349. package/dist/types/message-confirm.d.ts +48 -5
  350. package/dist/types/message.d.ts +3 -2
  351. package/dist/types/multi-auto-complete.d.ts +0 -1
  352. package/dist/types/multi-select.d.ts +0 -1
  353. package/dist/types/multi-tree-select.d.ts +0 -1
  354. package/dist/types/nav.d.ts +0 -1
  355. package/dist/types/node-render.d.ts +0 -1
  356. package/dist/types/notification.d.ts +67 -17
  357. package/dist/types/number-input.d.ts +0 -1
  358. package/dist/types/number-range-input.d.ts +0 -1
  359. package/dist/types/paginator.d.ts +0 -1
  360. package/dist/types/palette.d.ts +0 -1
  361. package/dist/types/password-input.d.ts +0 -1
  362. package/dist/types/pop-confirm.d.ts +0 -1
  363. package/dist/types/pop.d.ts +0 -1
  364. package/dist/types/progress-nodes.d.ts +0 -1
  365. package/dist/types/progress.d.ts +0 -1
  366. package/dist/types/quick-batch-edit.d.ts +0 -1
  367. package/dist/types/radio-group.d.ts +0 -1
  368. package/dist/types/radio.d.ts +0 -1
  369. package/dist/types/rich-text-editor.d.ts +0 -1
  370. package/dist/types/scroll.d.ts +11 -6
  371. package/dist/types/select.d.ts +0 -1
  372. package/dist/types/slider.d.ts +0 -1
  373. package/dist/types/steps.d.ts +0 -1
  374. package/dist/types/switch.d.ts +0 -1
  375. package/dist/types/table-editor.d.ts +0 -1
  376. package/dist/types/table.d.ts +0 -1
  377. package/dist/types/tabs.d.ts +2 -2
  378. package/dist/types/tag.d.ts +0 -1
  379. package/dist/types/text-editor.d.ts +0 -1
  380. package/dist/types/textarea.d.ts +0 -1
  381. package/dist/types/theme.d.ts +0 -1
  382. package/dist/types/tip.d.ts +0 -1
  383. package/dist/types/tree-select.d.ts +0 -1
  384. package/dist/types/tree.d.ts +0 -1
  385. package/dist/types/watermark.d.ts +0 -1
  386. package/package.json +19 -19
  387. package/src/components/message-confirm/index.ts +1 -1
  388. package/src/components/message-confirm/message-confirm-box.vue +36 -0
  389. package/src/components/message-confirm/message-confirm.ts +113 -21
  390. package/src/components/message-confirm/message-confirm.vue +30 -37
  391. package/src/components/message-confirm/style.scss +10 -12
  392. package/src/components/notification/index.ts +1 -143
  393. package/src/components/notification/notification-box.vue +150 -0
  394. package/src/components/notification/notification.ts +142 -0
  395. package/src/components/notification/notification.vue +40 -66
  396. package/src/components/notification/style.scss +65 -38
  397. package/src/types/message-confirm.ts +52 -3
  398. package/src/types/notification.ts +71 -15
  399. package/dist/components/notification/index.js +0 -140
  400. package/dist/components/notification/index.js.map +0 -1
@@ -0,0 +1,130 @@
1
+ import _sfc_main$1 from "./notification.js";
2
+ import { Fragment, TransitionGroup, computed, createElementBlock, createVNode, defineComponent, mergeProps, normalizeClass, normalizeStyle, onBeforeUnmount, openBlock, reactive, ref, renderList, unref, withCtx } from "vue";
3
+ import { bem } from "@veltra/utils";
4
+ //#region src/components/notification/notification-box.vue
5
+ const _hoisted_1 = ["data-key"];
6
+ const GAP = 10;
7
+ /** 折叠态每层露出的高度 */
8
+ const PEEK = 14;
9
+ /** 折叠态最多露出的卡片数 */
10
+ const MAX_VISIBLE = 3;
11
+ const _sfc_main = /*@__PURE__*/ defineComponent({
12
+ name: "UNotificationBox",
13
+ __name: "notification-box",
14
+ props: {
15
+ notifications: {},
16
+ position: {}
17
+ },
18
+ emits: ["closed", "close"],
19
+ setup(__props, { emit: __emit }) {
20
+ /** 通知项数据结构 */
21
+ const props = __props;
22
+ const emit = __emit;
23
+ const cls = bem("notification");
24
+ /** 展开态卡片间距 */
25
+ const hovering = ref(false);
26
+ /** 各卡片实测高度, 驱动展开态位移与容器高度 */
27
+ const heights = reactive({});
28
+ const vertical = computed(() => props.position.startsWith("top") ? "top" : "bottom");
29
+ /** 底部锚定向上堆叠(负向偏移), 顶部锚定向下堆叠 */
30
+ const direction = computed(() => vertical.value === "bottom" ? -1 : 1);
31
+ const observer = new ResizeObserver((entries) => {
32
+ for (const entry of entries) {
33
+ const el = entry.target;
34
+ const key = el.dataset.key;
35
+ if (key) heights[key] = el.offsetHeight;
36
+ }
37
+ });
38
+ function observeItem(el, key) {
39
+ if (el) observer.observe(el);
40
+ }
41
+ onBeforeUnmount(() => observer.disconnect());
42
+ /** 数组末尾为最新通知, 位于堆叠最前 */
43
+ function cardStyle(index) {
44
+ const items = props.notifications;
45
+ const stackIndex = items.length - 1 - index;
46
+ if (hovering.value) {
47
+ let offset = 0;
48
+ for (let i = index + 1; i < items.length; i++) offset += (heights[items[i].key] ?? 0) + GAP;
49
+ return {
50
+ transform: `translateY(${direction.value * offset}px) scale(1)`,
51
+ opacity: 1,
52
+ pointerEvents: "auto"
53
+ };
54
+ }
55
+ const clamped = Math.min(stackIndex, MAX_VISIBLE - 1);
56
+ return {
57
+ transform: `translateY(${direction.value * clamped * PEEK}px) scale(${1 - clamped * .05})`,
58
+ opacity: stackIndex >= MAX_VISIBLE ? 0 : 1,
59
+ pointerEvents: stackIndex === 0 ? "auto" : "none"
60
+ };
61
+ }
62
+ const stackStyle = computed(() => {
63
+ const items = props.notifications;
64
+ if (!items.length) return { height: "0px" };
65
+ if (hovering.value) return { height: `${items.reduce((sum, item) => sum + (heights[item.key] ?? 0), 0) + (items.length - 1) * GAP}px` };
66
+ return { height: `${(heights[items[items.length - 1].key] ?? 0) + Math.min(items.length - 1, MAX_VISIBLE - 1) * PEEK}px` };
67
+ });
68
+ function toCardProps(item) {
69
+ return {
70
+ title: item.title,
71
+ message: item.message,
72
+ type: item.type,
73
+ closable: item.closable,
74
+ duration: item.duration,
75
+ icon: item.icon,
76
+ buttonText: item.buttonText,
77
+ size: item.size
78
+ };
79
+ }
80
+ function handleAfterLeave(el) {
81
+ const key = el.dataset.key;
82
+ observer.unobserve(el);
83
+ delete heights[key];
84
+ emit("closed", key);
85
+ }
86
+ function handleClose(key, onClose) {
87
+ emit("close", key);
88
+ onClose?.();
89
+ }
90
+ function handleAction(key, onClick, onClose, e) {
91
+ onClick?.(e);
92
+ handleClose(key, onClose);
93
+ }
94
+ return (_ctx, _cache) => {
95
+ return openBlock(), createElementBlock("div", {
96
+ class: normalizeClass([unref(cls).e("stack"), unref(cls).em("stack", __props.position)]),
97
+ style: normalizeStyle(stackStyle.value),
98
+ onMouseenter: _cache[0] || (_cache[0] = ($event) => hovering.value = true),
99
+ onMouseleave: _cache[1] || (_cache[1] = ($event) => hovering.value = false)
100
+ }, [createVNode(TransitionGroup, {
101
+ name: `notification-${vertical.value}`,
102
+ appear: "",
103
+ onAfterLeave: handleAfterLeave
104
+ }, {
105
+ default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.notifications, (item, index) => {
106
+ return openBlock(), createElementBlock("div", {
107
+ key: item.key,
108
+ ref_for: true,
109
+ ref: (el) => observeItem(el, item.key),
110
+ "data-key": item.key,
111
+ class: normalizeClass(unref(cls).e("item"))
112
+ }, [createVNode(_sfc_main$1, mergeProps({ ref_for: true }, toCardProps(item), {
113
+ style: cardStyle(index),
114
+ onClose: ($event) => handleClose(item.key, item.onClose),
115
+ onAction: ($event) => handleAction(item.key, item.onClick, item.onClose, $event)
116
+ }), null, 16, [
117
+ "style",
118
+ "onClose",
119
+ "onAction"
120
+ ])], 10, _hoisted_1);
121
+ }), 128))]),
122
+ _: 1
123
+ }, 8, ["name"])], 38);
124
+ };
125
+ }
126
+ });
127
+ //#endregion
128
+ export { _sfc_main as default };
129
+
130
+ //# sourceMappingURL=notification-box.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-box.js","names":[],"sources":["../../../src/components/notification/notification-box.vue"],"sourcesContent":["<template>\n <div\n :class=\"[cls.e('stack'), cls.em('stack', position)]\"\n :style=\"stackStyle\"\n @mouseenter=\"hovering = true\"\n @mouseleave=\"hovering = false\"\n >\n <transition-group :name=\"`notification-${vertical}`\" appear @after-leave=\"handleAfterLeave\">\n <div\n v-for=\"(item, index) of notifications\"\n :key=\"item.key\"\n :ref=\"(el) => observeItem(el, item.key)\"\n :data-key=\"item.key\"\n :class=\"cls.e('item')\"\n >\n <UNotification\n v-bind=\"toCardProps(item)\"\n :style=\"cardStyle(index)\"\n @close=\"handleClose(item.key, item.onClose)\"\n @action=\"handleAction(item.key, item.onClick, item.onClose, $event)\"\n />\n </div>\n </transition-group>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, reactive, ref, type CSSProperties } from 'vue'\n\nimport type { NotificationOptions, NotificationPosition, NotificationProps } from '../../types'\nimport UNotification from './notification.vue'\n\ndefineOptions({ name: 'UNotificationBox' })\n\n/** 通知项数据结构 */\ntype NotificationItem = NotificationOptions & { key: string }\n\nconst props = defineProps<{ notifications: NotificationItem[]; position: NotificationPosition }>()\n\nconst emit = defineEmits<{ (e: 'closed', key: string): void; (e: 'close', key: string): void }>()\n\nconst cls = bem('notification')\n\n/** 展开态卡片间距 */\nconst GAP = 10\n/** 折叠态每层露出的高度 */\nconst PEEK = 14\n/** 折叠态最多露出的卡片数 */\nconst MAX_VISIBLE = 3\n\nconst hovering = ref(false)\n\n/** 各卡片实测高度, 驱动展开态位移与容器高度 */\nconst heights = reactive<Record<string, number>>({})\n\nconst vertical = computed(() => (props.position.startsWith('top') ? 'top' : 'bottom'))\n\n/** 底部锚定向上堆叠(负向偏移), 顶部锚定向下堆叠 */\nconst direction = computed(() => (vertical.value === 'bottom' ? -1 : 1))\n\nconst observer = new ResizeObserver((entries) => {\n for (const entry of entries) {\n const el = entry.target as HTMLElement\n const key = el.dataset.key\n if (key) heights[key] = el.offsetHeight\n }\n})\n\nfunction observeItem(el: Element | null, key: string) {\n if (el) observer.observe(el)\n}\n\nonBeforeUnmount(() => observer.disconnect())\n\n/** 数组末尾为最新通知, 位于堆叠最前 */\nfunction cardStyle(index: number): CSSProperties {\n const items = props.notifications\n const stackIndex = items.length - 1 - index\n\n if (hovering.value) {\n // 展开态: 按前方卡片累计高度偏移\n let offset = 0\n for (let i = index + 1; i < items.length; i++) {\n offset += (heights[items[i]!.key] ?? 0) + GAP\n }\n return {\n transform: `translateY(${direction.value * offset}px) scale(1)`,\n opacity: 1,\n pointerEvents: 'auto'\n }\n }\n\n const clamped = Math.min(stackIndex, MAX_VISIBLE - 1)\n return {\n transform: `translateY(${direction.value * clamped * PEEK}px) scale(${1 - clamped * 0.05})`,\n opacity: stackIndex >= MAX_VISIBLE ? 0 : 1,\n pointerEvents: stackIndex === 0 ? 'auto' : 'none'\n }\n}\n\nconst stackStyle = computed<CSSProperties>(() => {\n const items = props.notifications\n if (!items.length) return { height: '0px' }\n\n if (hovering.value) {\n const total = items.reduce((sum, item) => sum + (heights[item.key] ?? 0), 0)\n return { height: `${total + (items.length - 1) * GAP}px` }\n }\n\n const frontHeight = heights[items[items.length - 1]!.key] ?? 0\n const behind = Math.min(items.length - 1, MAX_VISIBLE - 1)\n return { height: `${frontHeight + behind * PEEK}px` }\n})\n\nfunction toCardProps(item: NotificationItem): NotificationProps {\n return {\n title: item.title,\n message: item.message,\n type: item.type,\n closable: item.closable,\n duration: item.duration,\n icon: item.icon,\n buttonText: item.buttonText,\n size: item.size\n }\n}\n\nfunction handleAfterLeave(el: Element) {\n const key = (el as HTMLElement).dataset.key as string\n observer.unobserve(el as HTMLElement)\n delete heights[key]\n emit('closed', key)\n}\n\nfunction handleClose(key: string, onClose?: () => void) {\n emit('close', key)\n onClose?.()\n}\n\nfunction handleAction(\n key: string,\n onClick: NotificationItem['onClick'],\n onClose: NotificationItem['onClose'],\n e: MouseEvent\n) {\n onClick?.(e)\n handleClose(key, onClose)\n}\n</script>\n"],"mappings":";;;;;AA6CA,MAAM,MAAM;;AAEZ,MAAM,OAAO;;AAEb,MAAM,cAAc;;;;;;;;;;;EAXpB,MAAM,QAAQ;EAEd,MAAM,OAAO;EAEb,MAAM,MAAM,IAAI,cAAc;;EAS9B,MAAM,WAAW,IAAI,KAAK;;EAG1B,MAAM,UAAU,SAAiC,CAAC,CAAC;EAEnD,MAAM,WAAW,eAAgB,MAAM,SAAS,WAAW,KAAK,IAAI,QAAQ,QAAS;;EAGrF,MAAM,YAAY,eAAgB,SAAS,UAAU,WAAW,KAAK,CAAE;EAEvE,MAAM,WAAW,IAAI,gBAAgB,YAAY;GAC/C,KAAK,MAAM,SAAS,SAAS;IAC3B,MAAM,KAAK,MAAM;IACjB,MAAM,MAAM,GAAG,QAAQ;IACvB,IAAI,KAAK,QAAQ,OAAO,GAAG;GAC7B;EACF,CAAC;EAED,SAAS,YAAY,IAAoB,KAAa;GACpD,IAAI,IAAI,SAAS,QAAQ,EAAE;EAC7B;EAEA,sBAAsB,SAAS,WAAW,CAAC;;EAG3C,SA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G;EACpB;EAEA,SAAS,YAAY,KAAa,SAAsB;GACtD,KAAK,SAAS,GAAG;GACjB,UAAU;EACZ;EAEA,SAAS,aACP,KACA,SACA,SACA,GACA;GACA,UAAU,CAAC;GACX,YAAY,KAAK,OAAO;EAC1B;;uBAnJE,mBAsBM,OAAA;IArBH,OAAK,eAAA,CAAG,MAAA,GAAA,CAAG,CAAC,EAAC,OAAA,GAAW,MAAA,GAAA,CAAG,CAAC,GAAE,SAAU,QAAA,QAAQ,CAAA,CAAA;IAChD,OAAK,eAAE,WAAA,KAAU;IACjB,cAAU,OAAA,OAAA,OAAA,MAAA,WAAE,SAAA,QAAQ;IACpB,cAAU,OAAA,OAAA,OAAA,MAAA,WAAE,SAAA,QAAQ;OAErB,YAemB,iBAAA;IAfA,MAAI,gBAAkB,SAAA;IAAY,QAAA;IAAQ,cAAa;;2BAEhC,EAAA,UAAA,IAAA,GADxC,mBAaM,UAAA,MAAA,WAZoB,QAAA,gBAAhB,MAAM,UAAK;yBADrB,mBAaM,OAAA;MAXH,KAAK,KAAK;;MACV,MAAM,OAAO,YAAY,IAAI,KAAK,GAAG;MACrC,YAAU,KAAK;MACf,OAAK,eAAE,MAAA,GAAA,CAAG,CAAC,EAAC,MAAA,CAAA;SAEb,YAKE,aALF,WAKE,EAAA,SAAA,KAAA,GAJQ,YAAY,IAAI,GAAA;MACvB,OAAO,UAAU,KAAK;MACtB,UAAK,WAAE,YAAY,KAAK,KAAK,KAAK,OAAO;MACzC,WAAM,WAAE,aAAa,KAAK,KAAK,KAAK,SAAS,KAAK,SAAS,MAAM"}
@@ -0,0 +1,8 @@
1
+ import { Notification } from "../../types/notification.js";
2
+ import "../../types/index.js";
3
+ //#region src/components/notification/notification.d.ts
4
+ /** --- 导出 API --- */
5
+ declare const notification: Notification;
6
+ //#endregion
7
+ export { notification };
8
+ //# sourceMappingURL=notification.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import _sfc_main$1 from "../icon/icon.js";
2
2
  import _sfc_main$2 from "../button/button.js";
3
- import { Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, onMounted, openBlock, ref, resolveDynamicComponent, toDisplayString, unref, vShow, withCtx, withDirectives, withModifiers } from "vue";
3
+ import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, onBeforeUnmount, onMounted, openBlock, resolveDynamicComponent, toDisplayString, unref, withCtx, withModifiers } from "vue";
4
4
  import { useFallbackProps } from "@veltra/compositions";
5
5
  import { bem } from "@veltra/utils";
6
6
  import { CircleCheckFilled, CircleClose, Close, InfoFilled, QuestionFilled, WarningFilled } from "@veltra/icons/normal";
@@ -9,7 +9,6 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
9
9
  name: "UNotification",
10
10
  __name: "notification",
11
11
  props: {
12
- modelValue: {},
13
12
  title: {},
14
13
  message: {},
15
14
  type: {},
@@ -18,18 +17,14 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
18
17
  default: false
19
18
  },
20
19
  duration: { default: 4500 },
21
- offset: { default: 20 },
22
- onClose: {},
23
- onClick: {},
24
- id: {},
25
20
  icon: {},
26
- zIndex: {},
27
21
  buttonText: { default: "" },
28
- width: {},
29
- position: { default: "bottom-right" }
22
+ size: {}
30
23
  },
31
- setup(__props, { expose: __expose }) {
24
+ emits: ["close", "action"],
25
+ setup(__props, { emit: __emit }) {
32
26
  const props = __props;
27
+ const emit = __emit;
33
28
  const { type, size } = useFallbackProps([props], {
34
29
  type: "primary",
35
30
  size: "default"
@@ -44,86 +39,69 @@ const _sfc_main = /*@__PURE__*/ defineComponent({
44
39
  }[type.value];
45
40
  });
46
41
  const cls = bem("notification");
47
- const visible = ref(false);
42
+ /** 剩余时长制的自动关闭计时器, 悬停暂停 */
43
+ let startTime = 0;
44
+ let timer = 0;
45
+ let restDuration = 0;
46
+ function startTimer() {
47
+ if (!props.duration) return;
48
+ startTime = Date.now();
49
+ timer = setTimeout(() => emit("close"), restDuration);
50
+ }
51
+ function suspendTimer() {
52
+ if (!props.duration) return;
53
+ clearTimeout(timer);
54
+ restDuration -= Date.now() - startTime;
55
+ }
48
56
  onMounted(() => {
49
- visible.value = true;
57
+ restDuration = props.duration;
50
58
  startTimer();
51
59
  });
52
- const close = () => {
53
- visible.value = false;
54
- };
55
- const customStyle = computed(() => {
56
- return props.offset > 0 ? {
57
- [`${props.position.split("-")[0]}`]: `${props.offset}px`,
58
- zIndex: props.zIndex,
59
- transform: props.position.split("-")[0] === "bottom" ? `translateY(-${props.offset}px)` : `translateY(${props.offset}px)`,
60
- transition: `opacity 0.3s, transform 0.4s, top 0.4s`
61
- } : {
62
- [`${props.position.split("-")[0]}`]: `${props.offset}px`,
63
- zIndex: props.zIndex
64
- };
65
- });
66
- let timer = 0;
67
- const startTimer = () => {
68
- if (props.duration) timer = setTimeout(() => {
69
- close();
70
- }, props.duration);
71
- };
72
- const clearTimer = () => clearTimeout(timer);
73
- const handleClick = (e) => {
74
- if (props.onClick) props.onClick(e);
75
- close();
76
- };
77
- __expose({
78
- startTimer,
79
- clearTimer
80
- });
60
+ onBeforeUnmount(() => clearTimeout(timer));
81
61
  return (_ctx, _cache) => {
82
- return openBlock(), createBlock(Transition, {
83
- name: `notification-fade-${__props.position.split("-")[0]}`,
84
- onBeforeLeave: __props.onClose,
85
- onAfterLeave: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("destroy")),
86
- persisted: ""
87
- }, {
88
- default: withCtx(() => [withDirectives(createElementVNode("div", {
89
- class: normalizeClass([
90
- unref(cls).b,
91
- unref(cls).m(unref(size)),
92
- unref(cls).e(unref(type)),
93
- unref(cls).e(__props.position)
94
- ]),
95
- style: normalizeStyle(customStyle.value)
96
- }, [
97
- createElementVNode("div", { class: normalizeClass(unref(cls).e("icon")) }, [createVNode(unref(_sfc_main$1), null, {
98
- default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(typeIcon.value)))]),
99
- _: 1
100
- })], 2),
101
- createElementVNode("div", { class: normalizeClass(unref(cls).e("content")) }, [
102
- createElementVNode("div", { class: normalizeClass(unref(cls).em("content", "title")) }, toDisplayString(__props.title), 3),
103
- createElementVNode("div", { class: normalizeClass(unref(cls).em("content", "message")) }, toDisplayString(__props.message), 3),
104
- __props.buttonText ? (openBlock(), createElementBlock("div", {
105
- key: 0,
106
- class: normalizeClass(unref(cls).em("content", "button"))
107
- }, [createVNode(unref(_sfc_main$2), {
108
- type: unref(type),
109
- plain: "",
110
- onClick: handleClick
111
- }, {
112
- default: withCtx(() => [createTextVNode(toDisplayString(__props.buttonText), 1)]),
113
- _: 1
114
- }, 8, ["type"])], 2)) : createCommentVNode("v-if", true)
115
- ], 2),
116
- __props.closable ? (openBlock(), createElementBlock("div", {
62
+ return openBlock(), createElementBlock("div", {
63
+ class: normalizeClass([
64
+ unref(cls).b,
65
+ unref(cls).m(unref(size)),
66
+ unref(cls).e(unref(type))
67
+ ]),
68
+ onMouseenter: suspendTimer,
69
+ onMouseleave: startTimer
70
+ }, [
71
+ createElementVNode("div", { class: normalizeClass(unref(cls).e("icon")) }, [createVNode(unref(_sfc_main$1), null, {
72
+ default: withCtx(() => [(openBlock(), createBlock(resolveDynamicComponent(typeIcon.value)))]),
73
+ _: 1
74
+ })], 2),
75
+ createElementVNode("div", { class: normalizeClass(unref(cls).e("content")) }, [
76
+ __props.title ? (openBlock(), createElementBlock("div", {
117
77
  key: 0,
118
- class: normalizeClass(unref(cls).e("close")),
119
- onClick: withModifiers(close, ["stop"])
120
- }, [createVNode(unref(_sfc_main$1), null, {
121
- default: withCtx(() => [createVNode(unref(Close))]),
78
+ class: normalizeClass(unref(cls).em("content", "title"))
79
+ }, toDisplayString(__props.title), 3)) : createCommentVNode("v-if", true),
80
+ __props.message ? (openBlock(), createElementBlock("div", {
81
+ key: 1,
82
+ class: normalizeClass(unref(cls).em("content", "message"))
83
+ }, toDisplayString(__props.message), 3)) : createCommentVNode("v-if", true),
84
+ __props.buttonText ? (openBlock(), createElementBlock("div", {
85
+ key: 2,
86
+ class: normalizeClass(unref(cls).em("content", "button"))
87
+ }, [createVNode(unref(_sfc_main$2), {
88
+ type: unref(type),
89
+ plain: "",
90
+ onClick: _cache[0] || (_cache[0] = (e) => emit("action", e))
91
+ }, {
92
+ default: withCtx(() => [createTextVNode(toDisplayString(__props.buttonText), 1)]),
122
93
  _: 1
123
- })], 2)) : createCommentVNode("v-if", true)
124
- ], 6), [[vShow, visible.value]])]),
125
- _: 1
126
- }, 8, ["name", "onBeforeLeave"]);
94
+ }, 8, ["type"])], 2)) : createCommentVNode("v-if", true)
95
+ ], 2),
96
+ __props.closable || __props.duration === 0 ? (openBlock(), createElementBlock("div", {
97
+ key: 0,
98
+ class: normalizeClass(unref(cls).e("close")),
99
+ onClick: _cache[1] || (_cache[1] = withModifiers(($event) => emit("close"), ["stop"]))
100
+ }, [createVNode(unref(_sfc_main$1), null, {
101
+ default: withCtx(() => [createVNode(unref(Close))]),
102
+ _: 1
103
+ })], 2)) : createCommentVNode("v-if", true)
104
+ ], 34);
127
105
  };
128
106
  }
129
107
  });
@@ -1 +1 @@
1
- {"version":3,"file":"notification.js","names":["$emit"],"sources":["../../../src/components/notification/notification.vue"],"sourcesContent":["<template>\n <transition\n :name=\"`notification-fade-${position.split('-')[0]}`\"\n @before-leave=\"onClose\"\n @after-leave=\"$emit('destroy')\"\n >\n <div\n :class=\"[cls.b, cls.m(size), cls.e(type), cls.e(position)]\"\n v-show=\"visible\"\n :style=\"customStyle\"\n >\n <div :class=\"cls.e('icon')\">\n <UIcon>\n <component :is=\"typeIcon\" />\n </UIcon>\n </div>\n <div :class=\"cls.e('content')\">\n <div :class=\"cls.em('content', 'title')\">{{ title }}</div>\n <div :class=\"cls.em('content', 'message')\">{{ message }}</div>\n <div :class=\"cls.em('content', 'button')\" v-if=\"buttonText\">\n <UButton :type=\"type\" plain @click=\"handleClick\">{{ buttonText }}</UButton>\n </div>\n </div>\n <div :class=\"cls.e('close')\" v-if=\"closable\" @click.stop=\"close\">\n <UIcon><Close /></UIcon>\n </div>\n </div>\n </transition>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFallbackProps } from '@veltra/compositions'\nimport {\n CircleCheckFilled,\n CircleClose,\n Close,\n InfoFilled,\n QuestionFilled,\n WarningFilled\n} from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { ref, computed, onMounted, type CSSProperties } from 'vue'\n\nimport type { NotificationProps, NotificationExposed, ColorType } from '../../types'\nimport { UButton } from '../button'\nimport { UIcon } from '../icon'\n\ndefineOptions({ name: 'UNotification' })\n\nconst props = withDefaults(defineProps<NotificationProps>(), {\n closable: false,\n duration: 4500,\n offset: 20,\n buttonText: '',\n position: 'bottom-right'\n})\n\nconst { type, size } = useFallbackProps([props], { type: 'primary' as ColorType, size: 'default' })\n\nconst typeIcon = computed(() => {\n return (\n props.icon ||\n {\n primary: InfoFilled,\n info: QuestionFilled,\n success: CircleCheckFilled,\n warning: WarningFilled,\n danger: CircleClose\n }[type.value]\n )\n})\n\nconst cls = bem('notification')\n\nconst visible = ref<boolean>(false)\n\nonMounted(() => {\n visible.value = true\n startTimer()\n})\n\nconst close = () => {\n visible.value = false\n}\n\nconst customStyle = computed<CSSProperties>(() => {\n return props.offset > 0\n ? {\n [`${props.position.split('-')[0]}`]: `${props.offset}px`,\n zIndex: props.zIndex,\n transform:\n props.position.split('-')[0] === 'bottom'\n ? `translateY(-${props.offset}px)`\n : `translateY(${props.offset}px)`,\n transition: `opacity 0.3s, transform 0.4s, top 0.4s`\n }\n : { [`${props.position.split('-')[0]}`]: `${props.offset}px`, zIndex: props.zIndex }\n})\n\nlet timer = 0\n\nconst startTimer = () => {\n if (props.duration) {\n timer = setTimeout(() => {\n close()\n }, props.duration)\n }\n}\n\nconst clearTimer = () => clearTimeout(timer)\n\nconst handleClick = (e: MouseEvent) => {\n if (props.onClick) props.onClick(e)\n close()\n}\n\ndefineExpose<NotificationExposed>({ startTimer, clearTimer })\n</script>\n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GAAA,CAAG,CAAC,EAAC,OAAA,CAAA;MAA4B,SAAK,cAAO,OAAK,CAAA,MAAA,CAAA;SAC7D,YAAwB,MAAA,WAAA,GAAA,MAAA;6BAAR,CAAT,YAAS,MAAA,KAAA,CAAA,CAAA,CAAA;;;oBAhBV,QAAA,KAAO,CAAA,CAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"notification.js","names":[],"sources":["../../../src/components/notification/notification.vue"],"sourcesContent":["<template>\n <div\n :class=\"[cls.b, cls.m(size), cls.e(type)]\"\n @mouseenter=\"suspendTimer\"\n @mouseleave=\"startTimer\"\n >\n <div :class=\"cls.e('icon')\">\n <UIcon>\n <component :is=\"typeIcon\" />\n </UIcon>\n </div>\n <div :class=\"cls.e('content')\">\n <div :class=\"cls.em('content', 'title')\" v-if=\"title\">{{ title }}</div>\n <div :class=\"cls.em('content', 'message')\" v-if=\"message\">{{ message }}</div>\n <div :class=\"cls.em('content', 'button')\" v-if=\"buttonText\">\n <UButton :type=\"type\" plain @click=\"(e) => emit('action', e)\">{{ buttonText }}</UButton>\n </div>\n </div>\n <div :class=\"cls.e('close')\" v-if=\"closable || duration === 0\" @click.stop=\"emit('close')\">\n <UIcon><Close /></UIcon>\n </div>\n </div>\n</template>\n\n<script lang=\"ts\" setup>\nimport { useFallbackProps } from '@veltra/compositions'\nimport {\n CircleCheckFilled,\n CircleClose,\n Close,\n InfoFilled,\n QuestionFilled,\n WarningFilled\n} from '@veltra/icons/normal'\nimport { bem } from '@veltra/utils'\nimport { computed, onBeforeUnmount, onMounted } from 'vue'\n\nimport type { NotificationEmits, NotificationProps, ColorType } from '../../types'\nimport { UButton } from '../button'\nimport { UIcon } from '../icon'\n\ndefineOptions({ name: 'UNotification' })\n\nconst props = withDefaults(defineProps<NotificationProps>(), {\n closable: false,\n duration: 4500,\n buttonText: ''\n})\n\nconst emit = defineEmits<NotificationEmits>()\n\nconst { type, size } = useFallbackProps([props], { type: 'primary' as ColorType, size: 'default' })\n\nconst typeIcon = computed(() => {\n return (\n props.icon ||\n {\n primary: InfoFilled,\n info: QuestionFilled,\n success: CircleCheckFilled,\n warning: WarningFilled,\n danger: CircleClose\n }[type.value]\n )\n})\n\nconst cls = bem('notification')\n\n/** 剩余时长制的自动关闭计时器, 悬停暂停 */\nlet startTime = 0\nlet timer = 0\nlet restDuration = 0\n\nfunction startTimer() {\n if (!props.duration) return\n startTime = Date.now()\n timer = setTimeout(() => emit('close'), restDuration)\n}\n\nfunction suspendTimer() {\n if (!props.duration) return\n clearTimeout(timer)\n restDuration -= Date.now() - startTime\n}\n\nonMounted(() => {\n restDuration = props.duration\n startTimer()\n})\n\nonBeforeUnmount(() => clearTimeout(timer))\n</script>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EA2CA,MAAM,QAAQ;EAMd,MAAM,OAAO;EAEb,MAAM,EAAE,MAAM,SAAS,iBAAiB,CAAC,KAAK,GAAG;GAAE,MAAM;GAAwB,MAAM;EAAU,CAAC;EAElG,MAAM,WAAW,eAAe;GAC9B,OACE,MAAM,QACN;IACE,SAAS;IACT,MAAM;IACN,SAAS;IACT,SAAS;IACT,QAAQ;GACV,EAAE,KAAK;EAEX,CAAC;EAED,MAAM,MAAM,IAAI,cAAc;;EAG9B,IAAI,YAAY;EAChB,IAAI,QAAQ;EACZ,IAAI,eAAe;EAEnB,SAAS,aAAa;GACpB,IAAI,CAAC,MAAM,UAAU;GACrB,YAAY,KAAK,IAAI;GACrB,QAAQ,iBAAiB,KAAK,OAAO,GAAG,YAAY;EACtD;EAEA,SAAS,eAAe;GACtB,IAAI,CAAC,MAAM,UAAU;GACrB,aAAa,KAAK;GAClB,gBAAgB,KAAK,IAAI,IAAI;EAC/B;EAEA,gBAAgB;GACd,eAAe,MAAM;GACrB,WAAW;EACb,CAAC;EAED,sBAAsB,aAAa,KAAK,CAAC;;uBAzFvC,mBAoBM,OAAA;IAnBH,OAAK,eAAA;KAAG,MAAA,GAAA,CAAG,CAAC;KAAG,MAAA,GAAA,CAAG,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AA,eAAA,WAAO,KAAI,OAAA,GAAA,CAAA,MAAA,CAAA;QAC9E,YAAwB,MAAA,WAAA,GAAA,MAAA;4BAAR,CAAT,YAAS,MAAA,KAAA,CAAA,CAAA,CAAA"}
@@ -1,13 +1,18 @@
1
- import { NotificationProps, _NotificationExposed } from "../../types/notification.js";
1
+ import { NotificationProps } from "../../types/notification.js";
2
+ import "../../types/index.js";
2
3
  //#region src/components/notification/notification.vue.d.ts
3
- declare const __VLS_export: import("vue").DefineComponent<NotificationProps, import("@veltra/utils").DeconstructValue<_NotificationExposed>, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<NotificationProps> & Readonly<{}>, {
4
+ declare const __VLS_export: import("vue").DefineComponent<NotificationProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
5
+ close: () => any;
6
+ action: (evt: MouseEvent) => any;
7
+ }, string, import("vue").PublicProps, Readonly<NotificationProps> & Readonly<{
8
+ onClose?: (() => any) | undefined;
9
+ onAction?: ((evt: MouseEvent) => any) | undefined;
10
+ }>, {
4
11
  closable: boolean;
5
12
  duration: number;
6
- offset: number;
7
13
  buttonText: string;
8
- position: "top-left" | "top-right" | "bottom-left" | "bottom-right";
9
14
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
10
15
  declare const _default: typeof __VLS_export;
11
16
  //#endregion
12
- export { _default };
17
+ export { _default as default };
13
18
  //# sourceMappingURL=notification.vue.d.ts.map
@@ -0,0 +1,134 @@
1
+ import _sfc_main from "./notification-box.js";
2
+ import { h, render, shallowReactive } from "vue";
3
+ import { bem, setStyles, zIndex } from "@veltra/utils";
4
+ //#region src/components/notification/notification.ts
5
+ const cls = bem("notification");
6
+ /** --- 状态管理 --- */
7
+ const stacks = {
8
+ "top-left": {
9
+ container: null,
10
+ items: shallowReactive([]),
11
+ activeCount: 0
12
+ },
13
+ "top-right": {
14
+ container: null,
15
+ items: shallowReactive([]),
16
+ activeCount: 0
17
+ },
18
+ "bottom-left": {
19
+ container: null,
20
+ items: shallowReactive([]),
21
+ activeCount: 0
22
+ },
23
+ "bottom-right": {
24
+ container: null,
25
+ items: shallowReactive([]),
26
+ activeCount: 0
27
+ }
28
+ };
29
+ /** 通知关闭后回调 */
30
+ const closedCallbacks = /* @__PURE__ */ new Map();
31
+ let uid = 0;
32
+ /** --- 内部辅助函数 --- */
33
+ /** 彻底销毁容器 */
34
+ const destroy = (stack) => {
35
+ if (stack.container) {
36
+ render(null, stack.container);
37
+ document.body.removeChild(stack.container);
38
+ stack.container = null;
39
+ }
40
+ };
41
+ /** 离开动画结束后的清理 */
42
+ const handleClosed = (stack, key) => {
43
+ stack.activeCount--;
44
+ const cb = closedCallbacks.get(key);
45
+ if (cb) {
46
+ cb();
47
+ closedCallbacks.delete(key);
48
+ }
49
+ if (stack.activeCount === 0) destroy(stack);
50
+ };
51
+ /** 触发关闭 (仅从数组移除,触发 Transition 离开动画) */
52
+ const handleClose = (stack, key) => {
53
+ const index = stack.items.findIndex((n) => n.key === key);
54
+ if (index !== -1) stack.items.splice(index, 1);
55
+ };
56
+ /** 挂载并渲染容器 */
57
+ const updateView = (position, options) => {
58
+ const stack = stacks[position];
59
+ if (!stack.container) {
60
+ stack.container = document.createElement("div");
61
+ stack.container.className = cls.e("container");
62
+ document.body.appendChild(stack.container);
63
+ }
64
+ const offset = options.offset ?? 20;
65
+ const [vertical, horizontal] = position.split("-");
66
+ setStyles(stack.container, {
67
+ position: "fixed",
68
+ zIndex: options.zIndex ?? zIndex(),
69
+ [vertical]: `${offset}px`,
70
+ [horizontal]: `${offset}px`
71
+ });
72
+ const vnode = h(_sfc_main, {
73
+ notifications: stack.items,
74
+ position,
75
+ onClosed: (key) => handleClosed(stack, key),
76
+ onClose: (key) => handleClose(stack, key)
77
+ });
78
+ vnode.appContext = notification._context;
79
+ render(vnode, stack.container);
80
+ };
81
+ /** 创建通知实例 */
82
+ const createNotification = (options) => {
83
+ const { onClosed: userOnClosed, position = "bottom-right", ...notificationOptions } = options;
84
+ const stack = stacks[position];
85
+ const id = `notification_${uid++}`;
86
+ stack.activeCount++;
87
+ let resolveClosed;
88
+ const onClosed = new Promise((r) => resolveClosed = r);
89
+ closedCallbacks.set(id, () => {
90
+ userOnClosed?.();
91
+ resolveClosed();
92
+ });
93
+ stack.items.push({
94
+ ...notificationOptions,
95
+ position,
96
+ key: id
97
+ });
98
+ updateView(position, options);
99
+ return {
100
+ id,
101
+ close: () => handleClose(stack, id),
102
+ onClosed
103
+ };
104
+ };
105
+ /** --- 导出 API --- */
106
+ const notification = ((options) => {
107
+ return createNotification(typeof options === "string" ? { message: options } : options);
108
+ });
109
+ notification._context = null;
110
+ [
111
+ "primary",
112
+ "success",
113
+ "info",
114
+ "warning",
115
+ "danger"
116
+ ].forEach((type) => {
117
+ notification[type] = (msg, config) => notification({
118
+ ...config,
119
+ message: msg,
120
+ type
121
+ });
122
+ });
123
+ /** 关闭所有通知,可指定方位 */
124
+ notification.closeAll = (position) => {
125
+ if (position) {
126
+ stacks[position].items.splice(0);
127
+ return;
128
+ }
129
+ Object.keys(stacks).forEach((p) => stacks[p].items.splice(0));
130
+ };
131
+ //#endregion
132
+ export { notification };
133
+
134
+ //# sourceMappingURL=notification2.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification2.js","names":["UNotificationBox"],"sources":["../../../src/components/notification/notification.ts"],"sourcesContent":["import { bem, setStyles, zIndex } from '@veltra/utils'\nimport { h, render, shallowReactive } from 'vue'\n\nimport type {\n Notification,\n NotificationInstance,\n NotificationOptions,\n NotificationPosition\n} from '../../types'\nimport UNotificationBox from './notification-box.vue'\n\nconst cls = bem('notification')\n\n/** 通知项数据结构 */\ntype NotificationItem = NotificationOptions & { key: string }\n\n/** 单个方位的堆叠状态 */\ninterface NotificationStack {\n container: HTMLElement | null\n items: NotificationItem[]\n /** 正在显示的通知数 (包含动画执行中) */\n activeCount: number\n}\n\n/** --- 状态管理 --- */\nconst stacks: Record<NotificationPosition, NotificationStack> = {\n 'top-left': { container: null, items: shallowReactive([]), activeCount: 0 },\n 'top-right': { container: null, items: shallowReactive([]), activeCount: 0 },\n 'bottom-left': { container: null, items: shallowReactive([]), activeCount: 0 },\n 'bottom-right': { container: null, items: shallowReactive([]), activeCount: 0 }\n}\n\n/** 通知关闭后回调 */\nconst closedCallbacks = new Map<string, () => void>()\n\nlet uid = 0\n\n/** --- 内部辅助函数 --- */\n\n/** 彻底销毁容器 */\nconst destroy = (stack: NotificationStack) => {\n if (stack.container) {\n render(null, stack.container)\n document.body.removeChild(stack.container)\n stack.container = null\n }\n}\n\n/** 离开动画结束后的清理 */\nconst handleClosed = (stack: NotificationStack, key: string) => {\n stack.activeCount--\n\n const cb = closedCallbacks.get(key)\n if (cb) {\n cb()\n closedCallbacks.delete(key)\n }\n\n // 没有活跃通知时销毁容器,保持页面干净\n if (stack.activeCount === 0) destroy(stack)\n}\n\n/** 触发关闭 (仅从数组移除,触发 Transition 离开动画) */\nconst handleClose = (stack: NotificationStack, key: string) => {\n const index = stack.items.findIndex((n) => n.key === key)\n if (index !== -1) stack.items.splice(index, 1)\n}\n\n/** 挂载并渲染容器 */\nconst updateView = (position: NotificationPosition, options: NotificationOptions) => {\n const stack = stacks[position]\n\n if (!stack.container) {\n stack.container = document.createElement('div')\n stack.container.className = cls.e('container')\n document.body.appendChild(stack.container)\n }\n\n const offset = options.offset ?? 20\n const [vertical, horizontal] = position.split('-') as ['top' | 'bottom', 'left' | 'right']\n setStyles(stack.container, {\n position: 'fixed',\n zIndex: options.zIndex ?? zIndex(),\n [vertical]: `${offset}px`,\n [horizontal]: `${offset}px`\n })\n\n const vnode = h(UNotificationBox, {\n notifications: stack.items,\n position,\n onClosed: (key: string) => handleClosed(stack, key),\n onClose: (key: string) => handleClose(stack, key)\n })\n\n vnode.appContext = notification._context\n render(vnode, stack.container)\n}\n\n/** 创建通知实例 */\nconst createNotification = (options: NotificationOptions): NotificationInstance => {\n const { onClosed: userOnClosed, position = 'bottom-right', ...notificationOptions } = options\n const stack = stacks[position]\n const id = `notification_${uid++}`\n stack.activeCount++\n\n // 生命周期 Promise\n let resolveClosed: () => void\n const onClosed = new Promise<void>((r) => (resolveClosed = r))\n\n closedCallbacks.set(id, () => {\n userOnClosed?.()\n resolveClosed()\n })\n\n stack.items.push({ ...notificationOptions, position, key: id })\n updateView(position, options)\n\n return { id, close: () => handleClose(stack, id), onClosed }\n}\n\n/** --- 导出 API --- */\n\nexport const notification = ((options) => {\n return createNotification(typeof options === 'string' ? { message: options } : options)\n}) as Notification\n\nnotification._context = null\n\n// 挂载快捷方法: notification.success(...)\nconst notificationTypes = ['primary', 'success', 'info', 'warning', 'danger'] as const\nnotificationTypes.forEach((type) => {\n notification[type] = (msg, config) => notification({ ...config, message: msg, type })\n})\n\n/** 关闭所有通知,可指定方位 */\nnotification.closeAll = (position?: NotificationPosition) => {\n if (position) {\n stacks[position].items.splice(0)\n return\n }\n ;(Object.keys(stacks) as NotificationPosition[]).forEach((p) => stacks[p].items.splice(0))\n}\n"],"mappings":";;;;AAWA,MAAM,MAAM,IAAI,cAAc;;AAc9B,MAAM,SAA0D;CAC9D,YAAY;EAAE,WAAW;EAAM,OAAO,gBAAgB,CAAC,CAAC;EAAG,aAAa;CAAE;CAC1E,aAAa;EAAE,WAAW;EAAM,OAAO,gBAAgB,CAAC,CAAC;EAAG,aAAa;CAAE;CAC3E,eAAe;EAAE,WAAW;EAAM,OAAO,gBAAgB,CAAC,CAAC;EAAG,aAAa;CAAE;CAC7E,gBAAgB;EAAE,WAAW;EAAM,OAAO,gBAAgB,CAAC,CAAC;EAAG,aAAa;CAAE;AAChF;;AAGA,MAAM,kCAAkB,IAAI,IAAwB;AAEpD,IAAI,MAAM;;;AAKV,MAAM,WAAW,UAA6B;CAC5C,IAAI,MAAM,WAAW;EACnB,OAAO,MAAM,MAAM,SAAS;EAC5B,SAAS,KAAK,YAAY,MAAM,SAAS;EACzC,MAAM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