@caribeng/ui 22.1.1 → 22.4.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 (305) hide show
  1. package/README.md +134 -12
  2. package/fesm2022/caribeng-ui-accordion.mjs +4 -4
  3. package/fesm2022/caribeng-ui-anchor.mjs +169 -0
  4. package/fesm2022/caribeng-ui-autocomplete.mjs +10 -8
  5. package/fesm2022/caribeng-ui-avatar.mjs +2 -2
  6. package/fesm2022/caribeng-ui-avatargroup.mjs +9 -3
  7. package/fesm2022/caribeng-ui-badge.mjs +8 -2
  8. package/fesm2022/caribeng-ui-blockui.mjs +12 -4
  9. package/fesm2022/caribeng-ui-breadcrumb.mjs +17 -7
  10. package/fesm2022/caribeng-ui-button.mjs +22 -2
  11. package/fesm2022/caribeng-ui-caribe-alert.mjs +5 -2
  12. package/fesm2022/caribeng-ui-caribe-animation-lottie.mjs +6 -3
  13. package/fesm2022/caribeng-ui-caribe-button-group.mjs +6 -3
  14. package/fesm2022/caribeng-ui-caribe-calendar.mjs +11 -6
  15. package/fesm2022/caribeng-ui-caribe-card-content.mjs +6 -3
  16. package/fesm2022/caribeng-ui-caribe-card-move.mjs +29 -7
  17. package/fesm2022/caribeng-ui-caribe-card-select.mjs +56 -14
  18. package/fesm2022/caribeng-ui-caribe-circle-loading.mjs +10 -7
  19. package/fesm2022/caribeng-ui-caribe-coachmark.mjs +42 -19
  20. package/fesm2022/caribeng-ui-caribe-data-table.mjs +15 -9
  21. package/fesm2022/caribeng-ui-caribe-dots-indicator.mjs +38 -5
  22. package/fesm2022/caribeng-ui-caribe-expansion-panel.mjs +16 -5
  23. package/fesm2022/caribeng-ui-caribe-fab-menu.mjs +56 -7
  24. package/fesm2022/caribeng-ui-caribe-file-download.mjs +68 -27
  25. package/fesm2022/caribeng-ui-caribe-file-select.mjs +22 -17
  26. package/fesm2022/caribeng-ui-caribe-float-menu.mjs +6 -3
  27. package/fesm2022/caribeng-ui-caribe-footer.mjs +8 -4
  28. package/fesm2022/caribeng-ui-caribe-header.mjs +6 -3
  29. package/fesm2022/caribeng-ui-caribe-icon-button.mjs +6 -3
  30. package/fesm2022/caribeng-ui-caribe-illustration.mjs +6 -3
  31. package/fesm2022/caribeng-ui-caribe-inline-alert.mjs +5 -2
  32. package/fesm2022/caribeng-ui-caribe-input-search.mjs +14 -10
  33. package/fesm2022/caribeng-ui-caribe-input-select.mjs +12 -10
  34. package/fesm2022/caribeng-ui-caribe-input-token.mjs +61 -11
  35. package/fesm2022/caribeng-ui-caribe-link.mjs +7 -2
  36. package/fesm2022/caribeng-ui-caribe-loader.mjs +8 -5
  37. package/fesm2022/caribeng-ui-caribe-modal.mjs +32 -16
  38. package/fesm2022/caribeng-ui-caribe-off-canvas.mjs +26 -12
  39. package/fesm2022/caribeng-ui-caribe-onboarding.mjs +44 -19
  40. package/fesm2022/caribeng-ui-caribe-pictogram.mjs +6 -3
  41. package/fesm2022/caribeng-ui-caribe-pop-over.mjs +34 -10
  42. package/fesm2022/caribeng-ui-caribe-preloader.mjs +9 -6
  43. package/fesm2022/caribeng-ui-caribe-progress-bar.mjs +5 -2
  44. package/fesm2022/caribeng-ui-caribe-shortcut.mjs +8 -3
  45. package/fesm2022/caribeng-ui-caribe-step-indicator.mjs +12 -5
  46. package/fesm2022/caribeng-ui-caribe-stroke.mjs +6 -3
  47. package/fesm2022/caribeng-ui-caribe-switch.mjs +5 -3
  48. package/fesm2022/caribeng-ui-caribe-tag-button.mjs +1 -1
  49. package/fesm2022/caribeng-ui-caribe-tracker.mjs +5 -2
  50. package/fesm2022/caribeng-ui-caribe-transaction-status.mjs +1 -1
  51. package/fesm2022/caribeng-ui-caribe-voucher.mjs +11 -8
  52. package/fesm2022/caribeng-ui-carousel.mjs +49 -14
  53. package/fesm2022/caribeng-ui-cascadeselect.mjs +22 -8
  54. package/fesm2022/caribeng-ui-chart.mjs +2601 -303
  55. package/fesm2022/caribeng-ui-chat.mjs +1303 -0
  56. package/fesm2022/caribeng-ui-chip.mjs +9 -4
  57. package/fesm2022/caribeng-ui-chips.mjs +9 -5
  58. package/fesm2022/caribeng-ui-code-block.mjs +332 -0
  59. package/fesm2022/caribeng-ui-colorpicker.mjs +107 -11
  60. package/fesm2022/caribeng-ui-command-palette.mjs +476 -0
  61. package/fesm2022/caribeng-ui-confirmdialog.mjs +140 -10
  62. package/fesm2022/caribeng-ui-confirmpopup.mjs +209 -9
  63. package/fesm2022/caribeng-ui-contextmenu.mjs +13 -6
  64. package/fesm2022/caribeng-ui-copy-button.mjs +230 -0
  65. package/fesm2022/caribeng-ui-dataview.mjs +214 -6
  66. package/fesm2022/caribeng-ui-datepicker.mjs +1630 -393
  67. package/fesm2022/caribeng-ui-descriptions.mjs +124 -0
  68. package/fesm2022/caribeng-ui-dialog.mjs +10 -7
  69. package/fesm2022/caribeng-ui-dock.mjs +58 -15
  70. package/fesm2022/caribeng-ui-drawer.mjs +17 -9
  71. package/fesm2022/caribeng-ui-dynamicdialog.mjs +210 -6
  72. package/fesm2022/caribeng-ui-editor.mjs +4413 -243
  73. package/fesm2022/caribeng-ui-empty.mjs +80 -0
  74. package/fesm2022/caribeng-ui-fieldset.mjs +2 -2
  75. package/fesm2022/caribeng-ui-file-card.mjs +136 -19
  76. package/fesm2022/caribeng-ui-fileupload.mjs +96 -19
  77. package/fesm2022/caribeng-ui-floatlabel.mjs +4 -2
  78. package/fesm2022/caribeng-ui-folder-card.mjs +132 -15
  79. package/fesm2022/caribeng-ui-galleria.mjs +76 -45
  80. package/fesm2022/caribeng-ui-image.mjs +52 -29
  81. package/fesm2022/caribeng-ui-inlinemessage.mjs +2 -2
  82. package/fesm2022/caribeng-ui-inplace.mjs +22 -6
  83. package/fesm2022/caribeng-ui-input-number.mjs +9 -7
  84. package/fesm2022/caribeng-ui-inputgroup.mjs +2 -2
  85. package/fesm2022/caribeng-ui-inputmask.mjs +22 -13
  86. package/fesm2022/caribeng-ui-inputotp.mjs +12 -6
  87. package/fesm2022/caribeng-ui-kanban.mjs +4612 -0
  88. package/fesm2022/caribeng-ui-kbd.mjs +122 -0
  89. package/fesm2022/caribeng-ui-keyfilter.mjs +72 -0
  90. package/fesm2022/caribeng-ui-listbox.mjs +13 -11
  91. package/fesm2022/caribeng-ui-megamenu.mjs +228 -32
  92. package/fesm2022/caribeng-ui-mentions.mjs +495 -0
  93. package/fesm2022/caribeng-ui-menu.mjs +18 -8
  94. package/fesm2022/caribeng-ui-menubar.mjs +17 -8
  95. package/fesm2022/caribeng-ui-message.mjs +13 -7
  96. package/fesm2022/caribeng-ui-metergroup.mjs +29 -11
  97. package/fesm2022/caribeng-ui-multiselect.mjs +399 -97
  98. package/fesm2022/caribeng-ui-orderlist.mjs +230 -11
  99. package/fesm2022/caribeng-ui-organizationchart.mjs +16 -15
  100. package/fesm2022/caribeng-ui-paginator.mjs +18 -15
  101. package/fesm2022/caribeng-ui-panel.mjs +11 -8
  102. package/fesm2022/caribeng-ui-panelmenu.mjs +14 -8
  103. package/fesm2022/caribeng-ui-password.mjs +8 -6
  104. package/fesm2022/caribeng-ui-pdfviewer.mjs +1553 -0
  105. package/fesm2022/caribeng-ui-phone-input.mjs +688 -0
  106. package/fesm2022/caribeng-ui-picklist.mjs +251 -14
  107. package/fesm2022/caribeng-ui-pricing.mjs +272 -75
  108. package/fesm2022/caribeng-ui-qrcode.mjs +564 -0
  109. package/fesm2022/caribeng-ui-rating.mjs +7 -3
  110. package/fesm2022/caribeng-ui-repeater.mjs +223 -0
  111. package/fesm2022/caribeng-ui-result.mjs +91 -0
  112. package/fesm2022/caribeng-ui-ripple.mjs +2 -0
  113. package/fesm2022/caribeng-ui-scrollpanel.mjs +6 -3
  114. package/fesm2022/caribeng-ui-scrolltop.mjs +9 -4
  115. package/fesm2022/caribeng-ui-select.mjs +379 -87
  116. package/fesm2022/caribeng-ui-selectbutton.mjs +2 -2
  117. package/fesm2022/caribeng-ui-sidebar.mjs +573 -0
  118. package/fesm2022/caribeng-ui-slider.mjs +171 -75
  119. package/fesm2022/caribeng-ui-speeddial.mjs +7 -4
  120. package/fesm2022/caribeng-ui-spinner.mjs +5 -2
  121. package/fesm2022/caribeng-ui-splitbutton.mjs +163 -0
  122. package/fesm2022/caribeng-ui-splitter.mjs +5 -2
  123. package/fesm2022/caribeng-ui-statistic.mjs +183 -0
  124. package/fesm2022/caribeng-ui-stepper.mjs +17 -7
  125. package/fesm2022/caribeng-ui-steps.mjs +6 -3
  126. package/fesm2022/caribeng-ui-table.mjs +716 -84
  127. package/fesm2022/caribeng-ui-tabmenu.mjs +13 -6
  128. package/fesm2022/caribeng-ui-tag.mjs +2 -2
  129. package/fesm2022/caribeng-ui-terminal.mjs +45 -9
  130. package/fesm2022/caribeng-ui-themetoggle.mjs +82 -0
  131. package/fesm2022/caribeng-ui-tieredmenu.mjs +113 -20
  132. package/fesm2022/caribeng-ui-timeline.mjs +175 -6
  133. package/fesm2022/caribeng-ui-toast.mjs +7 -4
  134. package/fesm2022/caribeng-ui-togglebutton.mjs +8 -6
  135. package/fesm2022/caribeng-ui-toolbar.mjs +6 -3
  136. package/fesm2022/caribeng-ui-tree.mjs +302 -6
  137. package/fesm2022/caribeng-ui-treeselect.mjs +26 -10
  138. package/fesm2022/caribeng-ui-treetable.mjs +269 -6
  139. package/fesm2022/caribeng-ui-virtualscroller.mjs +123 -10
  140. package/fesm2022/caribeng-ui.mjs +1216 -6
  141. package/package.json +93 -3
  142. package/schematics/collection.json +15 -0
  143. package/schematics/migrate-from-primeng/core-icons.json +1 -0
  144. package/schematics/migrate-from-primeng/icons.js +269 -0
  145. package/schematics/migrate-from-primeng/index.js +290 -0
  146. package/schematics/migrate-from-primeng/mappings/button.js +93 -0
  147. package/schematics/migrate-from-primeng/mappings/card.js +33 -0
  148. package/schematics/migrate-from-primeng/mappings/checkbox.js +44 -0
  149. package/schematics/migrate-from-primeng/mappings/confirm.js +221 -0
  150. package/schematics/migrate-from-primeng/mappings/datepicker.js +121 -0
  151. package/schematics/migrate-from-primeng/mappings/dialog.js +84 -0
  152. package/schematics/migrate-from-primeng/mappings/index.js +88 -0
  153. package/schematics/migrate-from-primeng/mappings/inputnumber.js +62 -0
  154. package/schematics/migrate-from-primeng/mappings/inputtext.js +60 -0
  155. package/schematics/migrate-from-primeng/mappings/menu.js +468 -0
  156. package/schematics/migrate-from-primeng/mappings/multiselect.js +49 -0
  157. package/schematics/migrate-from-primeng/mappings/radiobutton.js +22 -0
  158. package/schematics/migrate-from-primeng/mappings/rules.js +206 -0
  159. package/schematics/migrate-from-primeng/mappings/select.js +97 -0
  160. package/schematics/migrate-from-primeng/mappings/service-calls.js +100 -0
  161. package/schematics/migrate-from-primeng/mappings/table.js +613 -0
  162. package/schematics/migrate-from-primeng/mappings/tabs.js +225 -0
  163. package/schematics/migrate-from-primeng/mappings/tag.js +29 -0
  164. package/schematics/migrate-from-primeng/mappings/textarea.js +44 -0
  165. package/schematics/migrate-from-primeng/mappings/toast.js +173 -0
  166. package/schematics/migrate-from-primeng/mappings/toggleswitch.js +37 -0
  167. package/schematics/migrate-from-primeng/mappings/tooltip.js +44 -0
  168. package/schematics/migrate-from-primeng/mappings/types.js +10 -0
  169. package/schematics/migrate-from-primeng/report.js +79 -0
  170. package/schematics/migrate-from-primeng/schema.js +2 -0
  171. package/schematics/migrate-from-primeng/schema.json +34 -0
  172. package/schematics/migrate-from-primeng/template.js +387 -0
  173. package/schematics/migrate-from-primeng/todo.js +5 -0
  174. package/schematics/migrate-from-primeng/typescript.js +442 -0
  175. package/schematics/migrate-from-primeng/workspace.js +117 -0
  176. package/schematics/ng-add/index.js +140 -0
  177. package/schematics/ng-add/schema.js +2 -0
  178. package/schematics/ng-add/schema.json +66 -0
  179. package/types/caribeng-ui-anchor.d.ts +50 -0
  180. package/types/caribeng-ui-autocomplete.d.ts +4 -2
  181. package/types/caribeng-ui-avatargroup.d.ts +3 -1
  182. package/types/caribeng-ui-badge.d.ts +3 -1
  183. package/types/caribeng-ui-blockui.d.ts +9 -4
  184. package/types/caribeng-ui-breadcrumb.d.ts +11 -0
  185. package/types/caribeng-ui-button.d.ts +9 -1
  186. package/types/caribeng-ui-caribe-alert.d.ts +3 -0
  187. package/types/caribeng-ui-caribe-animation-lottie.d.ts +4 -1
  188. package/types/caribeng-ui-caribe-button-group.d.ts +4 -1
  189. package/types/caribeng-ui-caribe-calendar.d.ts +5 -1
  190. package/types/caribeng-ui-caribe-card-content.d.ts +4 -1
  191. package/types/caribeng-ui-caribe-card-move.d.ts +13 -13
  192. package/types/caribeng-ui-caribe-card-select.d.ts +10 -1
  193. package/types/caribeng-ui-caribe-circle-loading.d.ts +4 -1
  194. package/types/caribeng-ui-caribe-coachmark.d.ts +6 -0
  195. package/types/caribeng-ui-caribe-data-table.d.ts +7 -2
  196. package/types/caribeng-ui-caribe-dots-indicator.d.ts +9 -0
  197. package/types/caribeng-ui-caribe-expansion-panel.d.ts +7 -10
  198. package/types/caribeng-ui-caribe-fab-menu.d.ts +10 -1
  199. package/types/caribeng-ui-caribe-file-download.d.ts +8 -10
  200. package/types/caribeng-ui-caribe-file-select.d.ts +7 -1
  201. package/types/caribeng-ui-caribe-float-menu.d.ts +4 -1
  202. package/types/caribeng-ui-caribe-header.d.ts +3 -0
  203. package/types/caribeng-ui-caribe-icon-button.d.ts +4 -1
  204. package/types/caribeng-ui-caribe-illustration.d.ts +4 -1
  205. package/types/caribeng-ui-caribe-inline-alert.d.ts +3 -0
  206. package/types/caribeng-ui-caribe-input-search.d.ts +4 -2
  207. package/types/caribeng-ui-caribe-input-select.d.ts +4 -2
  208. package/types/caribeng-ui-caribe-input-token.d.ts +16 -1
  209. package/types/caribeng-ui-caribe-link.d.ts +3 -0
  210. package/types/caribeng-ui-caribe-loader.d.ts +4 -1
  211. package/types/caribeng-ui-caribe-modal.d.ts +7 -10
  212. package/types/caribeng-ui-caribe-off-canvas.d.ts +6 -1
  213. package/types/caribeng-ui-caribe-onboarding.d.ts +6 -0
  214. package/types/caribeng-ui-caribe-pictogram.d.ts +4 -1
  215. package/types/caribeng-ui-caribe-pop-over.d.ts +7 -10
  216. package/types/caribeng-ui-caribe-preloader.d.ts +4 -1
  217. package/types/caribeng-ui-caribe-progress-bar.d.ts +3 -0
  218. package/types/caribeng-ui-caribe-shortcut.d.ts +3 -1
  219. package/types/caribeng-ui-caribe-step-indicator.d.ts +6 -0
  220. package/types/caribeng-ui-caribe-stroke.d.ts +4 -1
  221. package/types/caribeng-ui-caribe-switch.d.ts +3 -1
  222. package/types/caribeng-ui-caribe-tracker.d.ts +3 -0
  223. package/types/caribeng-ui-caribe-voucher.d.ts +5 -2
  224. package/types/caribeng-ui-carousel.d.ts +10 -1
  225. package/types/caribeng-ui-cascadeselect.d.ts +7 -2
  226. package/types/caribeng-ui-chart.d.ts +471 -44
  227. package/types/caribeng-ui-chat.d.ts +299 -0
  228. package/types/caribeng-ui-chip.d.ts +6 -0
  229. package/types/caribeng-ui-chips.d.ts +6 -2
  230. package/types/caribeng-ui-code-block.d.ts +65 -0
  231. package/types/caribeng-ui-colorpicker.d.ts +8 -2
  232. package/types/caribeng-ui-command-palette.d.ts +133 -0
  233. package/types/caribeng-ui-confirmdialog.d.ts +57 -6
  234. package/types/caribeng-ui-confirmpopup.d.ts +74 -5
  235. package/types/caribeng-ui-contextmenu.d.ts +11 -1
  236. package/types/caribeng-ui-copy-button.d.ts +90 -0
  237. package/types/caribeng-ui-dataview.d.ts +65 -5
  238. package/types/caribeng-ui-datepicker.d.ts +186 -21
  239. package/types/caribeng-ui-descriptions.d.ts +63 -0
  240. package/types/caribeng-ui-dialog.d.ts +4 -1
  241. package/types/caribeng-ui-dock.d.ts +17 -2
  242. package/types/caribeng-ui-drawer.d.ts +7 -2
  243. package/types/caribeng-ui-dynamicdialog.d.ts +93 -3
  244. package/types/caribeng-ui-editor.d.ts +486 -13
  245. package/types/caribeng-ui-empty.d.ts +34 -0
  246. package/types/caribeng-ui-file-card.d.ts +28 -3
  247. package/types/caribeng-ui-fileupload.d.ts +27 -4
  248. package/types/caribeng-ui-folder-card.d.ts +31 -6
  249. package/types/caribeng-ui-galleria.d.ts +9 -0
  250. package/types/caribeng-ui-image.d.ts +10 -0
  251. package/types/caribeng-ui-inplace.d.ts +8 -0
  252. package/types/caribeng-ui-input-number.d.ts +3 -1
  253. package/types/caribeng-ui-inputmask.d.ts +8 -1
  254. package/types/caribeng-ui-inputotp.d.ts +7 -2
  255. package/types/caribeng-ui-kanban.d.ts +783 -0
  256. package/types/caribeng-ui-kbd.d.ts +36 -0
  257. package/types/caribeng-ui-keyfilter.d.ts +30 -0
  258. package/types/caribeng-ui-listbox.d.ts +5 -3
  259. package/types/caribeng-ui-megamenu.d.ts +37 -2
  260. package/types/caribeng-ui-mentions.d.ts +127 -0
  261. package/types/caribeng-ui-menu.d.ts +14 -2
  262. package/types/caribeng-ui-menubar.d.ts +12 -1
  263. package/types/caribeng-ui-message.d.ts +5 -0
  264. package/types/caribeng-ui-metergroup.d.ts +9 -1
  265. package/types/caribeng-ui-multiselect.d.ts +71 -10
  266. package/types/caribeng-ui-orderlist.d.ts +58 -6
  267. package/types/caribeng-ui-organizationchart.d.ts +7 -1
  268. package/types/caribeng-ui-paginator.d.ts +3 -0
  269. package/types/caribeng-ui-panel.d.ts +3 -0
  270. package/types/caribeng-ui-panelmenu.d.ts +11 -1
  271. package/types/caribeng-ui-password.d.ts +4 -2
  272. package/types/caribeng-ui-pdfviewer.d.ts +258 -0
  273. package/types/caribeng-ui-phone-input.d.ts +168 -0
  274. package/types/caribeng-ui-picklist.d.ts +67 -7
  275. package/types/caribeng-ui-pricing.d.ts +49 -9
  276. package/types/caribeng-ui-qrcode.d.ts +88 -0
  277. package/types/caribeng-ui-rating.d.ts +6 -2
  278. package/types/caribeng-ui-repeater.d.ts +79 -0
  279. package/types/caribeng-ui-result.d.ts +35 -0
  280. package/types/caribeng-ui-scrollpanel.d.ts +4 -1
  281. package/types/caribeng-ui-scrolltop.d.ts +4 -1
  282. package/types/caribeng-ui-select.d.ts +73 -9
  283. package/types/caribeng-ui-sidebar.d.ts +167 -0
  284. package/types/caribeng-ui-slider.d.ts +63 -10
  285. package/types/caribeng-ui-speeddial.d.ts +5 -2
  286. package/types/caribeng-ui-spinner.d.ts +3 -0
  287. package/types/caribeng-ui-splitbutton.d.ts +49 -0
  288. package/types/caribeng-ui-splitter.d.ts +3 -0
  289. package/types/caribeng-ui-statistic.d.ts +65 -0
  290. package/types/caribeng-ui-stepper.d.ts +5 -0
  291. package/types/caribeng-ui-steps.d.ts +4 -1
  292. package/types/caribeng-ui-table.d.ts +185 -17
  293. package/types/caribeng-ui-tabmenu.d.ts +11 -1
  294. package/types/caribeng-ui-terminal.d.ts +10 -0
  295. package/types/caribeng-ui-themetoggle.d.ts +32 -0
  296. package/types/caribeng-ui-tieredmenu.d.ts +22 -3
  297. package/types/caribeng-ui-timeline.d.ts +63 -4
  298. package/types/caribeng-ui-toast.d.ts +3 -0
  299. package/types/caribeng-ui-togglebutton.d.ts +5 -3
  300. package/types/caribeng-ui-toolbar.d.ts +7 -4
  301. package/types/caribeng-ui-tree.d.ts +76 -4
  302. package/types/caribeng-ui-treeselect.d.ts +10 -2
  303. package/types/caribeng-ui-treetable.d.ts +68 -4
  304. package/types/caribeng-ui-virtualscroller.d.ts +45 -5
  305. package/types/caribeng-ui.d.ts +775 -12
@@ -1,31 +1,88 @@
1
1
  import { DOCUMENT } from '@angular/common';
2
2
  import * as i0 from '@angular/core';
3
- import { inject, model, input, output, effect, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { inject, model, input, output, signal, computed, effect, untracked, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
4
  import * as i1 from '@angular/cdk/a11y';
5
5
  import { A11yModule } from '@angular/cdk/a11y';
6
+ import { injectCbTranslation, CbConfirmationService } from '@caribeng/ui';
7
+ import { CbButton } from '@caribeng/ui/button';
6
8
 
7
9
  let nextUid = 0;
8
10
  /**
9
11
  * Diálogo de confirmación (`role="alertdialog"`) con trampa de foco, cierre con
10
- * Escape (equivale a cancelar) y restauración del foco al cerrarse.
12
+ * Escape (equivale a cancelar) y restauración del foco al cerrarse. Al abrirse,
13
+ * el foco va al botón de cancelar (la opción segura).
14
+ *
15
+ * @example
16
+ * ```html
17
+ * <cb-confirm-dialog
18
+ * [(visible)]="confirmar"
19
+ * header="Eliminar cuenta"
20
+ * message="Esta acción no se puede deshacer."
21
+ * acceptSeverity="danger"
22
+ * (accepted)="eliminar()"
23
+ * />
24
+ * ```
25
+ *
26
+ * Con `service` muestra las confirmaciones pedidas desde código con
27
+ * `CbConfirmationService` (como `ConfirmationService` de PrimeNG):
28
+ *
29
+ * ```html
30
+ * <cb-confirm-dialog service />
31
+ * ```
32
+ * ```ts
33
+ * inject(CbConfirmationService).confirm({ message: '¿Eliminar?', accept: () => this.eliminar() });
34
+ * ```
11
35
  */
12
36
  class CbConfirmDialog {
13
37
  constructor() {
38
+ this.t = injectCbTranslation();
14
39
  this.document = inject(DOCUMENT);
40
+ this.confirmation = inject(CbConfirmationService);
41
+ /** Visibilidad (two-way). */
15
42
  this.visible = model(false, /* @ts-ignore */
16
43
  ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
17
- this.header = input('Confirmar', /* @ts-ignore */
44
+ /** Título. Por defecto, "Confirmar" del idioma activo. */
45
+ this.header = input(undefined, /* @ts-ignore */
18
46
  ...(ngDevMode ? [{ debugName: "header" }] : /* istanbul ignore next */ []));
19
- this.message = input('¿Deseas continuar?', /* @ts-ignore */
47
+ /** Mensaje. Por defecto, "¿Deseas continuar?" del idioma activo. */
48
+ this.message = input(undefined, /* @ts-ignore */
20
49
  ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
21
- this.acceptLabel = input('Aceptar', /* @ts-ignore */
50
+ this.acceptLabel = input(undefined, /* @ts-ignore */
22
51
  ...(ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []));
23
- this.rejectLabel = input('Cancelar', /* @ts-ignore */
52
+ this.rejectLabel = input(undefined, /* @ts-ignore */
24
53
  ...(ngDevMode ? [{ debugName: "rejectLabel" }] : /* istanbul ignore next */ []));
54
+ /** Severidad del botón de aceptar (p. ej. `danger` para acciones destructivas). */
55
+ this.acceptSeverity = input('primary', /* @ts-ignore */
56
+ ...(ngDevMode ? [{ debugName: "acceptSeverity" }] : /* istanbul ignore next */ []));
57
+ /**
58
+ * Muestra las confirmaciones pedidas con `CbConfirmationService`. Sin él, el
59
+ * componente solo responde a `[(visible)]` (así un diálogo declarativo no se
60
+ * abre con las confirmaciones de otra parte de la app).
61
+ */
62
+ this.service = input(false, { ...(ngDevMode ? { debugName: "service" } : /* istanbul ignore next */ {}), transform: toBoolean });
63
+ /** Con `service`: atiende solo las confirmaciones con este mismo `key` (o sin key si no se indica). */
64
+ this.key = input(undefined, /* @ts-ignore */
65
+ ...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
25
66
  this.accepted = output();
26
67
  this.rejected = output();
27
68
  this.titleId = `cb-confirm-dialog-${++nextUid}-title`;
28
69
  this.messageId = `${this.titleId.replace('-title', '')}-message`;
70
+ /** Confirmación pedida con `CbConfirmationService` que se está mostrando. */
71
+ this.active = signal(null, /* @ts-ignore */
72
+ ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
73
+ /** Textos visibles: los de la confirmación del servicio, si la hay; si no, los inputs y el idioma. */
74
+ this.shown = computed(() => {
75
+ const active = this.active();
76
+ const t = this.t();
77
+ return {
78
+ header: active?.header ?? this.header() ?? t.confirm,
79
+ message: active?.message ?? this.message() ?? t.confirmMessage,
80
+ acceptLabel: active?.acceptLabel ?? this.acceptLabel() ?? t.accept,
81
+ rejectLabel: active?.rejectLabel ?? this.rejectLabel() ?? t.cancel,
82
+ acceptSeverity: active?.acceptSeverity ?? this.acceptSeverity(),
83
+ };
84
+ }, /* @ts-ignore */
85
+ ...(ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []));
29
86
  /** Elemento enfocado antes de abrir; recibe el foco de vuelta al cerrar. */
30
87
  this.previouslyFocused = null;
31
88
  effect(() => {
@@ -38,6 +95,22 @@ class CbConfirmDialog {
38
95
  queueMicrotask(() => el.focus?.());
39
96
  }
40
97
  });
98
+ effect(() => {
99
+ if (!this.service())
100
+ return;
101
+ const request = this.confirmation.request();
102
+ untracked(() => {
103
+ if (request && request.confirmation.key === this.key()) {
104
+ this.active.set(request.confirmation);
105
+ this.visible.set(true);
106
+ }
107
+ else if (!request && this.active()) {
108
+ // Cerrada desde el servicio (close()).
109
+ this.active.set(null);
110
+ this.visible.set(false);
111
+ }
112
+ });
113
+ });
41
114
  }
42
115
  onEscape() {
43
116
  if (this.visible())
@@ -45,19 +118,76 @@ class CbConfirmDialog {
45
118
  }
46
119
  confirm() {
47
120
  this.accepted.emit();
48
- this.visible.set(false);
121
+ this.finish('accept');
49
122
  }
50
123
  reject() {
51
124
  this.rejected.emit();
125
+ this.finish('reject');
126
+ }
127
+ /** Cierra y, si venía del servicio, lo libera y ejecuta su callback (que puede pedir otra confirmación). */
128
+ finish(action) {
129
+ const active = this.active();
130
+ this.active.set(null);
52
131
  this.visible.set(false);
132
+ if (active) {
133
+ this.confirmation.close();
134
+ active[action]?.();
135
+ }
53
136
  }
54
137
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmDialog, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
55
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmDialog, isStandalone: true, selector: "cb-confirm-dialog", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", accepted: "accepted", rejected: "rejected" }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, ngImport: i0, template: `@if(visible()){<div class="cb-confirm-dialog__mask" (click)="reject()"><section class="cb-confirm-dialog" role="alertdialog" aria-modal="true" [attr.aria-labelledby]="titleId" [attr.aria-describedby]="messageId" cdkTrapFocus cdkTrapFocusAutoCapture (click)="$event.stopPropagation()"><h2 [id]="titleId">{{header()}}</h2><p [id]="messageId">{{message()}}</p><footer><button type="button" (click)="reject()">{{rejectLabel()}}</button><button type="button" (click)="confirm()">{{acceptLabel()}}</button></footer></section></div>}`, isInline: true, styles: [":host{display:contents}.cb-confirm-dialog__mask{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:#0006}.cb-confirm-dialog{width:min(28rem,calc(100vw - 2rem));padding:1.25rem;border-radius:.75rem;background:var(--cb-color-surface,#fff);color:var(--cb-color-text,#111827);box-shadow:0 1rem 3rem #0003}.cb-confirm-dialog h2{margin:0 0 .75rem;font-size:1.15rem}.cb-confirm-dialog footer{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1.25rem}.cb-confirm-dialog button{padding:.5rem .8rem}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
138
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmDialog, isStandalone: true, selector: "cb-confirm-dialog", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, header: { classPropertyName: "header", publicName: "header", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null }, acceptSeverity: { classPropertyName: "acceptSeverity", publicName: "acceptSeverity", isSignal: true, isRequired: false, transformFunction: null }, service: { classPropertyName: "service", publicName: "service", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", accepted: "accepted", rejected: "rejected" }, host: { listeners: { "document:keydown.escape": "onEscape()" } }, ngImport: i0, template: `
139
+ @if (visible()) {
140
+ <div class="cb-confirm-dialog__mask" (click)="reject()">
141
+ <section
142
+ class="cb-confirm-dialog"
143
+ role="alertdialog"
144
+ aria-modal="true"
145
+ [attr.aria-labelledby]="titleId"
146
+ [attr.aria-describedby]="messageId"
147
+ cdkTrapFocus
148
+ cdkTrapFocusAutoCapture
149
+ (click)="$event.stopPropagation()"
150
+ >
151
+ <h2 class="cb-confirm-dialog__title" [id]="titleId">{{ shown().header }}</h2>
152
+ <p class="cb-confirm-dialog__message" [id]="messageId">{{ shown().message }}</p>
153
+ <footer class="cb-confirm-dialog__actions">
154
+ <cb-button variant="text" severity="secondary" (click)="reject()">{{ shown().rejectLabel }}</cb-button>
155
+ <cb-button [severity]="shown().acceptSeverity" (click)="confirm()">{{ shown().acceptLabel }}</cb-button>
156
+ </footer>
157
+ </section>
158
+ </div>
159
+ }
160
+ `, isInline: true, styles: [":host{display:contents}.cb-confirm-dialog__mask{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:var(--cb-space-4, 1rem);background:color-mix(in srgb,#000 40%,transparent)}.cb-confirm-dialog{box-sizing:border-box;width:min(28rem,100%);padding:var(--cb-space-6, 1.5rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:var(--cb-shadow-lg, 0 1rem 3rem rgb(0 0 0 / 20%))}.cb-confirm-dialog__title{margin:0 0 var(--cb-space-2, .5rem);font-size:var(--cb-text-lg, 1.125rem);font-weight:var(--cb-font-weight-semibold, 600);color:var(--cb-color-text-strong)}.cb-confirm-dialog__message{margin:0;color:var(--cb-color-text-muted);line-height:1.55}.cb-confirm-dialog__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem);margin-top:var(--cb-space-6, 1.5rem)}\n"], dependencies: [{ kind: "ngmodule", type: A11yModule }, { kind: "directive", type: i1.CdkTrapFocus, selector: "[cdkTrapFocus]", inputs: ["cdkTrapFocus", "cdkTrapFocusAutoCapture"], exportAs: ["cdkTrapFocus"] }, { kind: "component", type: CbButton, selector: "cb-button", inputs: ["severity", "variant", "size", "disabled", "loading", "fullWidth", "type", "ariaLabel", "ariaHaspopup", "ariaExpanded", "ariaControls"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
56
161
  }
57
162
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmDialog, decorators: [{
58
163
  type: Component,
59
- args: [{ selector: 'cb-confirm-dialog', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, imports: [A11yModule], host: { '(document:keydown.escape)': 'onEscape()' }, template: `@if(visible()){<div class="cb-confirm-dialog__mask" (click)="reject()"><section class="cb-confirm-dialog" role="alertdialog" aria-modal="true" [attr.aria-labelledby]="titleId" [attr.aria-describedby]="messageId" cdkTrapFocus cdkTrapFocusAutoCapture (click)="$event.stopPropagation()"><h2 [id]="titleId">{{header()}}</h2><p [id]="messageId">{{message()}}</p><footer><button type="button" (click)="reject()">{{rejectLabel()}}</button><button type="button" (click)="confirm()">{{acceptLabel()}}</button></footer></section></div>}`, styles: [":host{display:contents}.cb-confirm-dialog__mask{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;background:#0006}.cb-confirm-dialog{width:min(28rem,calc(100vw - 2rem));padding:1.25rem;border-radius:.75rem;background:var(--cb-color-surface,#fff);color:var(--cb-color-text,#111827);box-shadow:0 1rem 3rem #0003}.cb-confirm-dialog h2{margin:0 0 .75rem;font-size:1.15rem}.cb-confirm-dialog footer{display:flex;justify-content:flex-end;gap:.5rem;margin-top:1.25rem}.cb-confirm-dialog button{padding:.5rem .8rem}\n"] }]
60
- }], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], header: [{ type: i0.Input, args: [{ isSignal: true, alias: "header", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], rejectLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "rejectLabel", required: false }] }], accepted: [{ type: i0.Output, args: ["accepted"] }], rejected: [{ type: i0.Output, args: ["rejected"] }] } });
164
+ args: [{ selector: 'cb-confirm-dialog', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [A11yModule, CbButton], host: { '(document:keydown.escape)': 'onEscape()' }, template: `
165
+ @if (visible()) {
166
+ <div class="cb-confirm-dialog__mask" (click)="reject()">
167
+ <section
168
+ class="cb-confirm-dialog"
169
+ role="alertdialog"
170
+ aria-modal="true"
171
+ [attr.aria-labelledby]="titleId"
172
+ [attr.aria-describedby]="messageId"
173
+ cdkTrapFocus
174
+ cdkTrapFocusAutoCapture
175
+ (click)="$event.stopPropagation()"
176
+ >
177
+ <h2 class="cb-confirm-dialog__title" [id]="titleId">{{ shown().header }}</h2>
178
+ <p class="cb-confirm-dialog__message" [id]="messageId">{{ shown().message }}</p>
179
+ <footer class="cb-confirm-dialog__actions">
180
+ <cb-button variant="text" severity="secondary" (click)="reject()">{{ shown().rejectLabel }}</cb-button>
181
+ <cb-button [severity]="shown().acceptSeverity" (click)="confirm()">{{ shown().acceptLabel }}</cb-button>
182
+ </footer>
183
+ </section>
184
+ </div>
185
+ }
186
+ `, styles: [":host{display:contents}.cb-confirm-dialog__mask{position:fixed;inset:0;z-index:1000;display:grid;place-items:center;padding:var(--cb-space-4, 1rem);background:color-mix(in srgb,#000 40%,transparent)}.cb-confirm-dialog{box-sizing:border-box;width:min(28rem,100%);padding:var(--cb-space-6, 1.5rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:var(--cb-shadow-lg, 0 1rem 3rem rgb(0 0 0 / 20%))}.cb-confirm-dialog__title{margin:0 0 var(--cb-space-2, .5rem);font-size:var(--cb-text-lg, 1.125rem);font-weight:var(--cb-font-weight-semibold, 600);color:var(--cb-color-text-strong)}.cb-confirm-dialog__message{margin:0;color:var(--cb-color-text-muted);line-height:1.55}.cb-confirm-dialog__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem);margin-top:var(--cb-space-6, 1.5rem)}\n"] }]
187
+ }], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], header: [{ type: i0.Input, args: [{ isSignal: true, alias: "header", required: false }] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], rejectLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "rejectLabel", required: false }] }], acceptSeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptSeverity", required: false }] }], service: [{ type: i0.Input, args: [{ isSignal: true, alias: "service", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], accepted: [{ type: i0.Output, args: ["accepted"] }], rejected: [{ type: i0.Output, args: ["rejected"] }] } });
188
+ function toBoolean(value) {
189
+ return value !== false && value != null && `${value}` !== 'false';
190
+ }
61
191
 
62
192
  /**
63
193
  * Generated bundle index. Do not edit.
@@ -1,28 +1,228 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
1
2
  import * as i0 from '@angular/core';
2
- import { model, input, output, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { inject, ViewContainerRef, Injector, model, input, output, viewChild, signal, computed, effect, untracked, afterNextRender, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
+ import { Overlay } from '@angular/cdk/overlay';
5
+ import { TemplatePortal } from '@angular/cdk/portal';
6
+ import { injectCbTranslation, CbConfirmationService } from '@caribeng/ui';
7
+ import { CbButton } from '@caribeng/ui/button';
3
8
 
9
+ let nextUid = 0;
10
+ /**
11
+ * Confirmación breve de CaribeNG. Ábrela anclada al botón que la dispara con
12
+ * `confirm($event)` (como PrimeNG), o en línea con `[(visible)]`. Escape o un
13
+ * clic fuera la cancelan; el foco vuelve al disparador al cerrarse.
14
+ *
15
+ * @example
16
+ * ```html
17
+ * <cb-button severity="danger" (click)="borrar.confirm($event)">Eliminar</cb-button>
18
+ * <cb-confirm-popup #borrar message="¿Eliminar este archivo?" (accepted)="eliminar()" />
19
+ * ```
20
+ *
21
+ * Con `service` muestra las confirmaciones de `CbConfirmationService` que traen
22
+ * `target` (como `ConfirmationService` de PrimeNG):
23
+ *
24
+ * ```html
25
+ * <cb-button (click)="borrar($event)">Eliminar</cb-button>
26
+ * <cb-confirm-popup service />
27
+ * ```
28
+ * ```ts
29
+ * borrar(event: Event) {
30
+ * inject(CbConfirmationService).confirm({ target: event.currentTarget, message: '¿Eliminar?', accept: () => this.eliminar() });
31
+ * }
32
+ * ```
33
+ */
4
34
  class CbConfirmPopup {
5
35
  constructor() {
36
+ this.t = injectCbTranslation();
37
+ this.overlay = inject(Overlay);
38
+ this.vcr = inject(ViewContainerRef);
39
+ this.injector = inject(Injector);
40
+ this.confirmation = inject(CbConfirmationService);
41
+ this.messageId = `cb-confirm-popup-${++nextUid}-message`;
42
+ /** Visibilidad (two-way). Con `[(visible)]` se muestra en línea. */
6
43
  this.visible = model(false, /* @ts-ignore */
7
44
  ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
8
- this.message = input('¿Confirmas la acción?', /* @ts-ignore */
45
+ /** Pregunta a confirmar. Por defecto, la del idioma activo. */
46
+ this.message = input(undefined, /* @ts-ignore */
9
47
  ...(ngDevMode ? [{ debugName: "message" }] : /* istanbul ignore next */ []));
10
- this.acceptLabel = input('Aceptar', /* @ts-ignore */
48
+ this.acceptLabel = input(undefined, /* @ts-ignore */
11
49
  ...(ngDevMode ? [{ debugName: "acceptLabel" }] : /* istanbul ignore next */ []));
12
- this.rejectLabel = input('Cancelar', /* @ts-ignore */
50
+ this.rejectLabel = input(undefined, /* @ts-ignore */
13
51
  ...(ngDevMode ? [{ debugName: "rejectLabel" }] : /* istanbul ignore next */ []));
52
+ /** Severidad del botón de aceptar (p. ej. `danger` para acciones destructivas). */
53
+ this.acceptSeverity = input('primary', /* @ts-ignore */
54
+ ...(ngDevMode ? [{ debugName: "acceptSeverity" }] : /* istanbul ignore next */ []));
55
+ /**
56
+ * Muestra las confirmaciones pedidas con `CbConfirmationService`. Sin él, el
57
+ * componente solo responde a `[(visible)]` (así un diálogo declarativo no se
58
+ * abre con las confirmaciones de otra parte de la app).
59
+ */
60
+ this.service = input(false, { ...(ngDevMode ? { debugName: "service" } : /* istanbul ignore next */ {}), transform: toBoolean });
61
+ /** Con `service`: atiende solo las confirmaciones con este mismo `key` (o sin key si no se indica). */
62
+ this.key = input(undefined, /* @ts-ignore */
63
+ ...(ngDevMode ? [{ debugName: "key" }] : /* istanbul ignore next */ []));
14
64
  this.accepted = output();
15
65
  this.rejected = output();
66
+ this.panel = viewChild.required('panel');
67
+ /** Abierta como overlay anclado a un disparador. */
68
+ this.anchored = signal(false, /* @ts-ignore */
69
+ ...(ngDevMode ? [{ debugName: "anchored" }] : /* istanbul ignore next */ []));
70
+ this.overlayRef = null;
71
+ this.trigger = null;
72
+ /** Confirmación pedida con `CbConfirmationService` que se está mostrando. */
73
+ this.active = signal(null, /* @ts-ignore */
74
+ ...(ngDevMode ? [{ debugName: "active" }] : /* istanbul ignore next */ []));
75
+ /** Textos visibles: los de la confirmación del servicio, si la hay; si no, los inputs y el idioma. */
76
+ this.shown = computed(() => {
77
+ const active = this.active();
78
+ const t = this.t();
79
+ return {
80
+ message: active?.message ?? this.message() ?? t.confirmMessage,
81
+ acceptLabel: active?.acceptLabel ?? this.acceptLabel() ?? t.accept,
82
+ rejectLabel: active?.rejectLabel ?? this.rejectLabel() ?? t.cancel,
83
+ acceptSeverity: active?.acceptSeverity ?? this.acceptSeverity(),
84
+ };
85
+ }, /* @ts-ignore */
86
+ ...(ngDevMode ? [{ debugName: "shown" }] : /* istanbul ignore next */ []));
87
+ this.positions = [
88
+ { originX: 'start', originY: 'bottom', overlayX: 'start', overlayY: 'top', offsetY: 8 },
89
+ { originX: 'start', originY: 'top', overlayX: 'start', overlayY: 'bottom', offsetY: -8 },
90
+ ];
91
+ effect(() => {
92
+ if (!this.service())
93
+ return;
94
+ const request = this.confirmation.request();
95
+ untracked(() => {
96
+ const target = request?.confirmation.target;
97
+ if (request && request.confirmation.key === this.key() && target instanceof HTMLElement) {
98
+ // Una nueva petición sustituye a la que estuviera abierta.
99
+ if (this.overlayRef)
100
+ this.dispose();
101
+ this.active.set(request.confirmation);
102
+ this.show(target);
103
+ }
104
+ else if (!request && this.active()) {
105
+ // Cerrada desde el servicio (close()).
106
+ this.active.set(null);
107
+ this.close();
108
+ }
109
+ });
110
+ });
111
+ }
112
+ /** Abre la confirmación anclada al elemento que recibió el evento. */
113
+ confirm(event) {
114
+ this.show(event.currentTarget);
115
+ }
116
+ /** Abre la confirmación anclada a `target`. */
117
+ show(target) {
118
+ if (this.overlayRef)
119
+ return;
120
+ this.trigger = target;
121
+ this.overlayRef = this.overlay.create({
122
+ positionStrategy: this.overlay.position().flexibleConnectedTo(target).withPositions(this.positions).withPush(true),
123
+ scrollStrategy: this.overlay.scrollStrategies.reposition(),
124
+ hasBackdrop: true,
125
+ backdropClass: 'cdk-overlay-transparent-backdrop',
126
+ });
127
+ this.overlayRef.attach(new TemplatePortal(this.panel(), this.vcr));
128
+ this.overlayRef.backdropClick().subscribe(() => this.reject());
129
+ this.anchored.set(true);
130
+ this.visible.set(true);
131
+ // Foco en la opción segura (cancelar), como en ConfirmDialog.
132
+ afterNextRender(() => this.overlayRef?.overlayElement.querySelector('button')?.focus(), {
133
+ injector: this.injector,
134
+ });
135
+ }
136
+ accept() {
137
+ this.accepted.emit();
138
+ this.finish('accept');
139
+ }
140
+ reject() {
141
+ this.rejected.emit();
142
+ this.finish('reject');
143
+ }
144
+ /** Cierra y, si venía del servicio, lo libera y ejecuta su callback (que puede pedir otra confirmación). */
145
+ finish(action) {
146
+ const active = this.active();
147
+ this.active.set(null);
148
+ this.close();
149
+ if (active) {
150
+ this.confirmation.close();
151
+ active[action]?.();
152
+ }
153
+ }
154
+ close() {
155
+ this.visible.set(false);
156
+ if (this.overlayRef) {
157
+ this.dispose();
158
+ this.trigger?.focus();
159
+ this.trigger = null;
160
+ }
161
+ }
162
+ /** Quita el overlay sin devolver el foco. */
163
+ dispose() {
164
+ this.overlayRef?.dispose();
165
+ this.overlayRef = null;
166
+ this.anchored.set(false);
16
167
  }
17
- confirm() { this.accepted.emit(); this.visible.set(false); }
18
- reject() { this.rejected.emit(); this.visible.set(false); }
19
168
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmPopup, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
20
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmPopup, isStandalone: true, selector: "cb-confirm-popup", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", accepted: "accepted", rejected: "rejected" }, ngImport: i0, template: `@if(visible()){<section class="cb-confirm-popup" role="alertdialog" aria-modal="false"><p>{{message()}}</p><div><button type="button" (click)="reject()">{{rejectLabel()}}</button><button type="button" (click)="confirm()">{{acceptLabel()}}</button></div></section>}`, isInline: true, styles: [":host{display:inline-block}.cb-confirm-popup{min-width:14rem;padding:1rem;border:1px solid var(--cb-color-border,#d1d5db);border-radius:.65rem;background:var(--cb-color-surface,#fff);color:var(--cb-color-text,#111827);box-shadow:0 .5rem 1.5rem #0002}.cb-confirm-popup p{margin:0 0 .75rem}.cb-confirm-popup div{display:flex;justify-content:flex-end;gap:.4rem}.cb-confirm-popup button{padding:.4rem .65rem}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
169
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbConfirmPopup, isStandalone: true, selector: "cb-confirm-popup", inputs: { visible: { classPropertyName: "visible", publicName: "visible", isSignal: true, isRequired: false, transformFunction: null }, message: { classPropertyName: "message", publicName: "message", isSignal: true, isRequired: false, transformFunction: null }, acceptLabel: { classPropertyName: "acceptLabel", publicName: "acceptLabel", isSignal: true, isRequired: false, transformFunction: null }, rejectLabel: { classPropertyName: "rejectLabel", publicName: "rejectLabel", isSignal: true, isRequired: false, transformFunction: null }, acceptSeverity: { classPropertyName: "acceptSeverity", publicName: "acceptSeverity", isSignal: true, isRequired: false, transformFunction: null }, service: { classPropertyName: "service", publicName: "service", isSignal: true, isRequired: false, transformFunction: null }, key: { classPropertyName: "key", publicName: "key", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { visible: "visibleChange", accepted: "accepted", rejected: "rejected" }, host: { classAttribute: "cb-confirm-popup-host" }, viewQueries: [{ propertyName: "panel", first: true, predicate: ["panel"], descendants: true, isSignal: true }], ngImport: i0, template: `
170
+ @if (visible() && !anchored()) {
171
+ <ng-container *ngTemplateOutlet="panel" />
172
+ }
173
+
174
+ <ng-template #panel>
175
+ <section
176
+ class="cb-confirm-popup"
177
+ role="alertdialog"
178
+ aria-modal="false"
179
+ [attr.aria-describedby]="messageId"
180
+ (keydown.escape)="reject()"
181
+ >
182
+ <p class="cb-confirm-popup__message" [id]="messageId">{{ shown().message }}</p>
183
+ <div class="cb-confirm-popup__actions">
184
+ <cb-button size="sm" variant="text" severity="secondary" (click)="reject()">
185
+ {{ shown().rejectLabel }}
186
+ </cb-button>
187
+ <cb-button size="sm" [severity]="shown().acceptSeverity" (click)="accept()">
188
+ {{ shown().acceptLabel }}
189
+ </cb-button>
190
+ </div>
191
+ </section>
192
+ </ng-template>
193
+ `, isInline: true, styles: [":host{display:inline-block}.cb-confirm-popup{min-width:15rem;max-width:22rem;padding:var(--cb-space-4, 1rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:0 .75rem 2rem color-mix(in srgb,#000 18%,transparent)}.cb-confirm-popup__message{margin:0 0 var(--cb-space-3, .75rem);font-size:var(--cb-text-sm, .875rem);line-height:1.5}.cb-confirm-popup__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CbButton, selector: "cb-button", inputs: ["severity", "variant", "size", "disabled", "loading", "fullWidth", "type", "ariaLabel", "ariaHaspopup", "ariaExpanded", "ariaControls"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
21
194
  }
22
195
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbConfirmPopup, decorators: [{
23
196
  type: Component,
24
- args: [{ selector: 'cb-confirm-popup', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `@if(visible()){<section class="cb-confirm-popup" role="alertdialog" aria-modal="false"><p>{{message()}}</p><div><button type="button" (click)="reject()">{{rejectLabel()}}</button><button type="button" (click)="confirm()">{{acceptLabel()}}</button></div></section>}`, styles: [":host{display:inline-block}.cb-confirm-popup{min-width:14rem;padding:1rem;border:1px solid var(--cb-color-border,#d1d5db);border-radius:.65rem;background:var(--cb-color-surface,#fff);color:var(--cb-color-text,#111827);box-shadow:0 .5rem 1.5rem #0002}.cb-confirm-popup p{margin:0 0 .75rem}.cb-confirm-popup div{display:flex;justify-content:flex-end;gap:.4rem}.cb-confirm-popup button{padding:.4rem .65rem}\n"] }]
25
- }], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], rejectLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "rejectLabel", required: false }] }], accepted: [{ type: i0.Output, args: ["accepted"] }], rejected: [{ type: i0.Output, args: ["rejected"] }] } });
197
+ args: [{ selector: 'cb-confirm-popup', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [NgTemplateOutlet, CbButton], host: { class: 'cb-confirm-popup-host' }, template: `
198
+ @if (visible() && !anchored()) {
199
+ <ng-container *ngTemplateOutlet="panel" />
200
+ }
201
+
202
+ <ng-template #panel>
203
+ <section
204
+ class="cb-confirm-popup"
205
+ role="alertdialog"
206
+ aria-modal="false"
207
+ [attr.aria-describedby]="messageId"
208
+ (keydown.escape)="reject()"
209
+ >
210
+ <p class="cb-confirm-popup__message" [id]="messageId">{{ shown().message }}</p>
211
+ <div class="cb-confirm-popup__actions">
212
+ <cb-button size="sm" variant="text" severity="secondary" (click)="reject()">
213
+ {{ shown().rejectLabel }}
214
+ </cb-button>
215
+ <cb-button size="sm" [severity]="shown().acceptSeverity" (click)="accept()">
216
+ {{ shown().acceptLabel }}
217
+ </cb-button>
218
+ </div>
219
+ </section>
220
+ </ng-template>
221
+ `, styles: [":host{display:inline-block}.cb-confirm-popup{min-width:15rem;max-width:22rem;padding:var(--cb-space-4, 1rem);border:1px solid var(--cb-color-border);border-radius:var(--cb-radius-lg, .75rem);background:var(--cb-color-surface-raised);color:var(--cb-color-text);box-shadow:0 .75rem 2rem color-mix(in srgb,#000 18%,transparent)}.cb-confirm-popup__message{margin:0 0 var(--cb-space-3, .75rem);font-size:var(--cb-text-sm, .875rem);line-height:1.5}.cb-confirm-popup__actions{display:flex;justify-content:flex-end;gap:var(--cb-space-2, .5rem)}\n"] }]
222
+ }], ctorParameters: () => [], propDecorators: { visible: [{ type: i0.Input, args: [{ isSignal: true, alias: "visible", required: false }] }, { type: i0.Output, args: ["visibleChange"] }], message: [{ type: i0.Input, args: [{ isSignal: true, alias: "message", required: false }] }], acceptLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptLabel", required: false }] }], rejectLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "rejectLabel", required: false }] }], acceptSeverity: [{ type: i0.Input, args: [{ isSignal: true, alias: "acceptSeverity", required: false }] }], service: [{ type: i0.Input, args: [{ isSignal: true, alias: "service", required: false }] }], key: [{ type: i0.Input, args: [{ isSignal: true, alias: "key", required: false }] }], accepted: [{ type: i0.Output, args: ["accepted"] }], rejected: [{ type: i0.Output, args: ["rejected"] }], panel: [{ type: i0.ViewChild, args: ['panel', { isSignal: true }] }] } });
223
+ function toBoolean(value) {
224
+ return value !== false && value != null && `${value}` !== 'false';
225
+ }
26
226
 
27
227
  /**
28
228
  * Generated bundle index. Do not edit.
@@ -1,18 +1,24 @@
1
1
  import * as i0 from '@angular/core';
2
- import { inject, ViewContainerRef, DestroyRef, input, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { inject, ViewContainerRef, DestroyRef, input, computed, output, viewChild, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
3
3
  import { Overlay } from '@angular/cdk/overlay';
4
4
  import { TemplatePortal } from '@angular/cdk/portal';
5
5
  import { CbIcon } from '@caribeng/ui/icon';
6
+ import { injectCbTranslation, cbVisibleItems, cbRunCommand } from '@caribeng/ui';
6
7
 
7
8
  /** Context menu that opens at the pointer position on right click. */
8
9
  class CbContextMenu {
9
10
  constructor() {
11
+ /** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
12
+ this.t = injectCbTranslation();
10
13
  this.overlay = inject(Overlay);
11
14
  this.vcr = inject(ViewContainerRef);
12
15
  this.destroyRef = inject(DestroyRef);
13
16
  this.items = input([], /* @ts-ignore */
14
17
  ...(ngDevMode ? [{ debugName: "items" }] : /* istanbul ignore next */ []));
15
- this.ariaLabel = input('Context menu', /* @ts-ignore */
18
+ /** Items sin los de `visible: false`. */
19
+ this.visibleItems = computed(() => cbVisibleItems(this.items()), /* @ts-ignore */
20
+ ...(ngDevMode ? [{ debugName: "visibleItems" }] : /* istanbul ignore next */ []));
21
+ this.ariaLabel = input(undefined, /* @ts-ignore */
16
22
  ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
17
23
  this.itemSelect = output();
18
24
  this.content = viewChild.required('content');
@@ -55,6 +61,7 @@ class CbContextMenu {
55
61
  select(item) {
56
62
  if (item.disabled || item.separator)
57
63
  return;
64
+ cbRunCommand(item);
58
65
  this.itemSelect.emit(item);
59
66
  this.close();
60
67
  }
@@ -66,8 +73,8 @@ class CbContextMenu {
66
73
  static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbContextMenu, isStandalone: true, selector: "cb-contextmenu", inputs: { items: { classPropertyName: "items", publicName: "items", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { itemSelect: "itemSelect" }, host: { listeners: { "contextmenu": "open($event)" }, classAttribute: "cb-contextmenu" }, viewQueries: [{ propertyName: "content", first: true, predicate: ["content"], descendants: true, isSignal: true }], ngImport: i0, template: `
67
74
  <ng-content />
68
75
  <ng-template #content>
69
- <div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="ariaLabel()">
70
- @for (item of items(); track $index) {
76
+ <div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="(ariaLabel() ?? t().contextMenu)">
77
+ @for (item of visibleItems(); track $index) {
71
78
  @if (item.separator) { <div class="cb-contextmenu__separator" role="separator"></div> }
72
79
  @else {
73
80
  <button class="cb-contextmenu__item" type="button" role="menuitem" [disabled]="item.disabled" (click)="select(item)">
@@ -85,8 +92,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
85
92
  args: [{ selector: 'cb-contextmenu', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [CbIcon], host: { class: 'cb-contextmenu', '(contextmenu)': 'open($event)' }, template: `
86
93
  <ng-content />
87
94
  <ng-template #content>
88
- <div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="ariaLabel()">
89
- @for (item of items(); track $index) {
95
+ <div class="cb-contextmenu__panel" role="menu" [attr.aria-label]="(ariaLabel() ?? t().contextMenu)">
96
+ @for (item of visibleItems(); track $index) {
90
97
  @if (item.separator) { <div class="cb-contextmenu__separator" role="separator"></div> }
91
98
  @else {
92
99
  <button class="cb-contextmenu__item" type="button" role="menuitem" [disabled]="item.disabled" (click)="select(item)">