@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,26 +1,322 @@
1
+ import { NgTemplateOutlet } from '@angular/common';
1
2
  import * as i0 from '@angular/core';
2
- import { input, model, signal, ChangeDetectionStrategy, Component } from '@angular/core';
3
+ import { inject, TemplateRef, Directive, ElementRef, input, model, output, contentChild, signal, computed, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
4
+ import { injectCbTranslation, cbFormat } from '@caribeng/ui';
5
+ import { CbIcon } from '@caribeng/ui/icon';
3
6
 
7
+ /** Plantilla para el contenido de cada nodo. */
8
+ class CbTreeNodeTemplate {
9
+ constructor() {
10
+ this.template = inject(TemplateRef);
11
+ }
12
+ static ngTemplateContextGuard(_dir, ctx) {
13
+ return true;
14
+ }
15
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTreeNodeTemplate, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
16
+ static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "22.0.5", type: CbTreeNodeTemplate, isStandalone: true, selector: "ng-template[cbTreeNode]", ngImport: i0 }); }
17
+ }
18
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTreeNodeTemplate, decorators: [{
19
+ type: Directive,
20
+ args: [{ selector: 'ng-template[cbTreeNode]' }]
21
+ }] });
22
+ let nextUid = 0;
23
+ /**
24
+ * Árbol jerárquico de CaribeNG con niveles ilimitados, selección simple y
25
+ * navegación con teclado según el patrón *tree* de WAI-ARIA.
26
+ *
27
+ * @example
28
+ * ```html
29
+ * <cb-tree [value]="nodes" [(selection)]="selected" ariaLabel="Documentos" />
30
+ *
31
+ * <cb-tree [value]="nodes">
32
+ * <ng-template cbTreeNode let-node>{{ node.label }} ({{ node.children?.length ?? 0 }})</ng-template>
33
+ * </cb-tree>
34
+ * ```
35
+ */
4
36
  class CbTree {
5
37
  constructor() {
38
+ this.t = injectCbTranslation();
39
+ this.fmt = cbFormat;
40
+ this.host = inject(ElementRef);
41
+ this.uid = `cb-tree-${++nextUid}`;
42
+ /** Nodos raíz. */
6
43
  this.value = input([], /* @ts-ignore */
7
44
  ...(ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []));
45
+ /** Nodo seleccionado (two-way). */
8
46
  this.selection = model(null, /* @ts-ignore */
9
47
  ...(ngDevMode ? [{ debugName: "selection" }] : /* istanbul ignore next */ []));
48
+ /** Nombre accesible del árbol. */
49
+ this.ariaLabel = input('', /* @ts-ignore */
50
+ ...(ngDevMode ? [{ debugName: "ariaLabel" }] : /* istanbul ignore next */ []));
51
+ /** Se emite al expandir un nodo. */
52
+ this.nodeExpand = output();
53
+ /** Se emite al contraer un nodo. */
54
+ this.nodeCollapse = output();
55
+ /** Se emite al seleccionar un nodo. */
56
+ this.nodeSelect = output();
57
+ this.nodeTemplate = contentChild(CbTreeNodeTemplate, /* @ts-ignore */
58
+ ...(ngDevMode ? [{ debugName: "nodeTemplate" }] : /* istanbul ignore next */ []));
10
59
  this.expanded = signal(new Set(), /* @ts-ignore */
11
60
  ...(ngDevMode ? [{ debugName: "expanded" }] : /* istanbul ignore next */ []));
61
+ /** Último nodo enfocado por el usuario. */
62
+ this.activeKey = signal(null, /* @ts-ignore */
63
+ ...(ngDevMode ? [{ debugName: "activeKey" }] : /* istanbul ignore next */ []));
64
+ /** Nodo que recibe el foco con Tab (roving tabindex): el activo, el seleccionado o el primero. */
65
+ this.tabbableKey = computed(() => this.activeKey() ?? this.selection()?.key ?? this.value()[0]?.key ?? null, /* @ts-ignore */
66
+ ...(ngDevMode ? [{ debugName: "tabbableKey" }] : /* istanbul ignore next */ []));
67
+ /** Nodos visibles en orden de lectura (solo ramas expandidas). */
68
+ this.visible = computed(() => {
69
+ const out = [];
70
+ const walk = (nodes, level, parentKey) => {
71
+ for (const node of nodes) {
72
+ out.push({ node, level, parentKey });
73
+ if (node.children?.length && this.expanded().has(node.key))
74
+ walk(node.children, level + 1, node.key);
75
+ }
76
+ };
77
+ walk(this.value(), 1, null);
78
+ return out;
79
+ }, /* @ts-ignore */
80
+ ...(ngDevMode ? [{ debugName: "visible" }] : /* istanbul ignore next */ []));
81
+ }
82
+ /** Expande todos los nodos. */
83
+ expandAll() {
84
+ const keys = new Set();
85
+ const walk = (nodes) => nodes.forEach((n) => {
86
+ if (n.children?.length) {
87
+ keys.add(n.key);
88
+ walk(n.children);
89
+ }
90
+ });
91
+ walk(this.value());
92
+ this.expanded.set(keys);
93
+ }
94
+ /** Contrae todos los nodos. */
95
+ collapseAll() {
96
+ this.expanded.set(new Set());
97
+ }
98
+ hasChildren(node) {
99
+ return !!node.children?.length;
100
+ }
101
+ isExpanded(node) {
102
+ return this.expanded().has(node.key);
103
+ }
104
+ isSelected(node) {
105
+ return this.selection()?.key === node.key;
106
+ }
107
+ itemId(node) {
108
+ return `${this.uid}-${node.key}`;
109
+ }
110
+ toggle(node, event) {
111
+ event?.stopPropagation();
112
+ this.setExpanded(node, !this.isExpanded(node));
113
+ }
114
+ onClick(event, node) {
115
+ event.stopPropagation();
116
+ this.activeKey.set(node.key);
117
+ this.select(node);
118
+ }
119
+ onKeydown(event) {
120
+ const list = this.visible();
121
+ const index = list.findIndex((v) => v.node.key === this.tabbableKey());
122
+ if (index < 0)
123
+ return;
124
+ const current = list[index];
125
+ let target;
126
+ switch (event.key) {
127
+ case 'ArrowDown':
128
+ target = list[index + 1];
129
+ break;
130
+ case 'ArrowUp':
131
+ target = list[index - 1];
132
+ break;
133
+ case 'Home':
134
+ target = list[0];
135
+ break;
136
+ case 'End':
137
+ target = list[list.length - 1];
138
+ break;
139
+ case 'ArrowRight':
140
+ if (this.hasChildren(current.node)) {
141
+ if (!this.isExpanded(current.node))
142
+ this.setExpanded(current.node, true);
143
+ else
144
+ target = list[index + 1];
145
+ }
146
+ break;
147
+ case 'ArrowLeft':
148
+ if (this.hasChildren(current.node) && this.isExpanded(current.node))
149
+ this.setExpanded(current.node, false);
150
+ else if (current.parentKey)
151
+ target = list.find((v) => v.node.key === current.parentKey);
152
+ break;
153
+ case 'Enter':
154
+ case ' ':
155
+ this.select(current.node);
156
+ break;
157
+ default:
158
+ return;
159
+ }
160
+ event.preventDefault();
161
+ if (target)
162
+ this.focus(target.node);
163
+ }
164
+ select(node) {
165
+ if (node.disabled)
166
+ return;
167
+ this.selection.set(node);
168
+ this.nodeSelect.emit(node);
169
+ }
170
+ setExpanded(node, open) {
171
+ if (open === this.isExpanded(node))
172
+ return;
173
+ const next = new Set(this.expanded());
174
+ if (open)
175
+ next.add(node.key);
176
+ else
177
+ next.delete(node.key);
178
+ this.expanded.set(next);
179
+ (open ? this.nodeExpand : this.nodeCollapse).emit(node);
180
+ }
181
+ focus(node) {
182
+ this.activeKey.set(node.key);
183
+ const id = this.itemId(node);
184
+ Array.from(this.host.nativeElement.querySelectorAll('[role="treeitem"]'))
185
+ .find((el) => el.id === id)
186
+ ?.focus();
12
187
  }
13
- toggle(key) { const next = new Set(this.expanded()); next.has(key) ? next.delete(key) : next.add(key); this.expanded.set(next); }
14
188
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTree, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
15
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTree, isStandalone: true, selector: "cb-tree", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selection: "selectionChange" }, ngImport: i0, template: `<ul class="cb-tree" role="tree">@for(node of value();track node.key){<li role="treeitem" [attr.aria-expanded]="node.children?.length ? expanded().has(node.key) : null"><div class="cb-tree__row">@if(node.children?.length){<button type="button" (click)="toggle(node.key)" [attr.aria-label]="expanded().has(node.key)?'Contraer '+node.label:'Expandir '+node.label">{{expanded().has(node.key)?'−':'+'}}</button>}<button class="cb-tree__label" type="button" (click)="selection.set(node)">{{node.label}}</button></div>@if(node.children?.length&&expanded().has(node.key)){<ul role="group">@for(child of node.children;track child.key){<li role="treeitem"><button class="cb-tree__label" type="button" (click)="selection.set(child)">{{child.label}}</button></li>}</ul>}</li>}</ul>`, isInline: true, styles: [":host{display:block}.cb-tree,.cb-tree ul{list-style:none;margin:0;padding-inline-start:1rem}.cb-tree__row{display:flex;gap:.35rem;align-items:center}.cb-tree button{font:inherit;color:var(--cb-color-text,#111827);background:transparent;border:0;padding:.4rem;cursor:pointer}.cb-tree button:focus-visible{outline:2px solid var(--cb-color-primary,#10b981);outline-offset:2px}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
189
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTree, isStandalone: true, selector: "cb-tree", inputs: { value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null }, selection: { classPropertyName: "selection", publicName: "selection", isSignal: true, isRequired: false, transformFunction: null }, ariaLabel: { classPropertyName: "ariaLabel", publicName: "ariaLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { selection: "selectionChange", nodeExpand: "nodeExpand", nodeCollapse: "nodeCollapse", nodeSelect: "nodeSelect" }, host: { classAttribute: "cb-tree-host" }, queries: [{ propertyName: "nodeTemplate", first: true, predicate: CbTreeNodeTemplate, descendants: true, isSignal: true }], ngImport: i0, template: `
190
+ <ul class="cb-tree" role="tree" [attr.aria-label]="ariaLabel() || null" (keydown)="onKeydown($event)">
191
+ <ng-container *ngTemplateOutlet="branch; context: { $implicit: value(), level: 1 }" />
192
+ </ul>
193
+
194
+ <ng-template #branch let-nodes let-level="level">
195
+ @for (node of nodes; track node.key; let i = $index) {
196
+ <li
197
+ class="cb-tree__item"
198
+ role="treeitem"
199
+ [id]="itemId(node)"
200
+ [attr.aria-level]="level"
201
+ [attr.aria-setsize]="nodes.length"
202
+ [attr.aria-posinset]="i + 1"
203
+ [attr.aria-expanded]="hasChildren(node) ? isExpanded(node) : null"
204
+ [attr.aria-selected]="node.disabled ? null : isSelected(node)"
205
+ [attr.aria-disabled]="node.disabled ? 'true' : null"
206
+ [attr.tabindex]="node.key === tabbableKey() ? 0 : -1"
207
+ (focus)="activeKey.set(node.key)"
208
+ (click)="onClick($event, node)"
209
+ >
210
+ <div
211
+ class="cb-tree__row"
212
+ [class.cb-is-selected]="isSelected(node)"
213
+ [class.cb-is-disabled]="node.disabled"
214
+ [style.padding-inline-start]="'calc(' + (level - 1) + ' * var(--cb-tree-indent, 1.25rem) + 0.25rem)'"
215
+ >
216
+ @if (hasChildren(node)) {
217
+ <button
218
+ type="button"
219
+ class="cb-tree__toggler"
220
+ tabindex="-1"
221
+ [attr.aria-label]="fmt(isExpanded(node) ? t().collapseItem : t().expandItem, node.label)"
222
+ (click)="toggle(node, $event)"
223
+ >
224
+ <cb-icon name="chevron-right" [size]="14" [class.cb-is-open]="isExpanded(node)" aria-hidden="true" />
225
+ </button>
226
+ } @else {
227
+ <span class="cb-tree__spacer" aria-hidden="true"></span>
228
+ }
229
+ @if (node.icon) {
230
+ <cb-icon class="cb-tree__icon" [name]="node.icon" [size]="16" aria-hidden="true" />
231
+ }
232
+ <span class="cb-tree__label">
233
+ @if (nodeTemplate(); as tpl) {
234
+ <ng-container
235
+ *ngTemplateOutlet="tpl.template; context: { $implicit: node, level, expanded: isExpanded(node), selected: isSelected(node) }"
236
+ />
237
+ } @else {
238
+ {{ node.label }}
239
+ }
240
+ </span>
241
+ </div>
242
+ @if (hasChildren(node) && isExpanded(node)) {
243
+ <ul class="cb-tree__group" role="group">
244
+ <ng-container *ngTemplateOutlet="branch; context: { $implicit: node.children, level: level + 1 }" />
245
+ </ul>
246
+ }
247
+ </li>
248
+ }
249
+ </ng-template>
250
+ `, isInline: true, styles: [":host{display:block;color:var(--cb-color-text);font-size:var(--cb-text-sm, .875rem)}.cb-tree,.cb-tree__group{list-style:none;margin:0;padding:0}.cb-tree__item{outline:none}.cb-tree__row{display:flex;align-items:center;gap:var(--cb-space-1, .25rem);min-height:2.25rem;padding-inline-end:var(--cb-space-2, .5rem);border-radius:var(--cb-radius-md, .5rem);cursor:pointer;transition:background var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__row:hover{background:var(--cb-color-surface-hover)}.cb-tree__row.cb-is-selected{color:var(--cb-color-primary-700);background:color-mix(in srgb,var(--cb-color-primary-500) 14%,transparent);font-weight:var(--cb-font-weight-medium, 500)}.cb-tree__row.cb-is-disabled{opacity:.55;cursor:default}.cb-tree__item:focus-visible>.cb-tree__row{box-shadow:0 0 0 2px var(--cb-color-focus-ring, var(--cb-color-primary-500))}.cb-tree__toggler{display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;flex:none;padding:0;border:0;border-radius:var(--cb-radius-sm, 4px);background:transparent;color:var(--cb-color-text-muted);cursor:pointer}.cb-tree__toggler:hover{color:var(--cb-color-text);background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}.cb-tree__toggler cb-icon{transition:transform var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__toggler cb-icon.cb-is-open{transform:rotate(90deg)}.cb-tree__spacer{width:1.5rem;flex:none}.cb-tree__icon{flex:none;color:var(--cb-color-text-muted)}.cb-tree__label{flex:1;min-width:0}:host-context([data-theme=\"dark\"]) .cb-tree__row:hover{background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}:host-context([data-theme=\"dark\"]) .cb-tree__row.cb-is-selected{color:var(--cb-color-primary-300)}\n"], dependencies: [{ kind: "directive", type: NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet", "ngTemplateOutletInjector"] }, { kind: "component", type: CbIcon, selector: "cb-icon", inputs: ["name", "size", "spin", "ariaLabel"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
16
251
  }
17
252
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTree, decorators: [{
18
253
  type: Component,
19
- args: [{ selector: 'cb-tree', standalone: true, changeDetection: ChangeDetectionStrategy.OnPush, template: `<ul class="cb-tree" role="tree">@for(node of value();track node.key){<li role="treeitem" [attr.aria-expanded]="node.children?.length ? expanded().has(node.key) : null"><div class="cb-tree__row">@if(node.children?.length){<button type="button" (click)="toggle(node.key)" [attr.aria-label]="expanded().has(node.key)?'Contraer '+node.label:'Expandir '+node.label">{{expanded().has(node.key)?'−':'+'}}</button>}<button class="cb-tree__label" type="button" (click)="selection.set(node)">{{node.label}}</button></div>@if(node.children?.length&&expanded().has(node.key)){<ul role="group">@for(child of node.children;track child.key){<li role="treeitem"><button class="cb-tree__label" type="button" (click)="selection.set(child)">{{child.label}}</button></li>}</ul>}</li>}</ul>`, styles: [":host{display:block}.cb-tree,.cb-tree ul{list-style:none;margin:0;padding-inline-start:1rem}.cb-tree__row{display:flex;gap:.35rem;align-items:center}.cb-tree button{font:inherit;color:var(--cb-color-text,#111827);background:transparent;border:0;padding:.4rem;cursor:pointer}.cb-tree button:focus-visible{outline:2px solid var(--cb-color-primary,#10b981);outline-offset:2px}\n"] }]
20
- }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }] } });
254
+ args: [{ selector: 'cb-tree', changeDetection: ChangeDetectionStrategy.OnPush, encapsulation: ViewEncapsulation.Emulated, imports: [NgTemplateOutlet, CbIcon], host: { class: 'cb-tree-host' }, template: `
255
+ <ul class="cb-tree" role="tree" [attr.aria-label]="ariaLabel() || null" (keydown)="onKeydown($event)">
256
+ <ng-container *ngTemplateOutlet="branch; context: { $implicit: value(), level: 1 }" />
257
+ </ul>
258
+
259
+ <ng-template #branch let-nodes let-level="level">
260
+ @for (node of nodes; track node.key; let i = $index) {
261
+ <li
262
+ class="cb-tree__item"
263
+ role="treeitem"
264
+ [id]="itemId(node)"
265
+ [attr.aria-level]="level"
266
+ [attr.aria-setsize]="nodes.length"
267
+ [attr.aria-posinset]="i + 1"
268
+ [attr.aria-expanded]="hasChildren(node) ? isExpanded(node) : null"
269
+ [attr.aria-selected]="node.disabled ? null : isSelected(node)"
270
+ [attr.aria-disabled]="node.disabled ? 'true' : null"
271
+ [attr.tabindex]="node.key === tabbableKey() ? 0 : -1"
272
+ (focus)="activeKey.set(node.key)"
273
+ (click)="onClick($event, node)"
274
+ >
275
+ <div
276
+ class="cb-tree__row"
277
+ [class.cb-is-selected]="isSelected(node)"
278
+ [class.cb-is-disabled]="node.disabled"
279
+ [style.padding-inline-start]="'calc(' + (level - 1) + ' * var(--cb-tree-indent, 1.25rem) + 0.25rem)'"
280
+ >
281
+ @if (hasChildren(node)) {
282
+ <button
283
+ type="button"
284
+ class="cb-tree__toggler"
285
+ tabindex="-1"
286
+ [attr.aria-label]="fmt(isExpanded(node) ? t().collapseItem : t().expandItem, node.label)"
287
+ (click)="toggle(node, $event)"
288
+ >
289
+ <cb-icon name="chevron-right" [size]="14" [class.cb-is-open]="isExpanded(node)" aria-hidden="true" />
290
+ </button>
291
+ } @else {
292
+ <span class="cb-tree__spacer" aria-hidden="true"></span>
293
+ }
294
+ @if (node.icon) {
295
+ <cb-icon class="cb-tree__icon" [name]="node.icon" [size]="16" aria-hidden="true" />
296
+ }
297
+ <span class="cb-tree__label">
298
+ @if (nodeTemplate(); as tpl) {
299
+ <ng-container
300
+ *ngTemplateOutlet="tpl.template; context: { $implicit: node, level, expanded: isExpanded(node), selected: isSelected(node) }"
301
+ />
302
+ } @else {
303
+ {{ node.label }}
304
+ }
305
+ </span>
306
+ </div>
307
+ @if (hasChildren(node) && isExpanded(node)) {
308
+ <ul class="cb-tree__group" role="group">
309
+ <ng-container *ngTemplateOutlet="branch; context: { $implicit: node.children, level: level + 1 }" />
310
+ </ul>
311
+ }
312
+ </li>
313
+ }
314
+ </ng-template>
315
+ `, styles: [":host{display:block;color:var(--cb-color-text);font-size:var(--cb-text-sm, .875rem)}.cb-tree,.cb-tree__group{list-style:none;margin:0;padding:0}.cb-tree__item{outline:none}.cb-tree__row{display:flex;align-items:center;gap:var(--cb-space-1, .25rem);min-height:2.25rem;padding-inline-end:var(--cb-space-2, .5rem);border-radius:var(--cb-radius-md, .5rem);cursor:pointer;transition:background var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__row:hover{background:var(--cb-color-surface-hover)}.cb-tree__row.cb-is-selected{color:var(--cb-color-primary-700);background:color-mix(in srgb,var(--cb-color-primary-500) 14%,transparent);font-weight:var(--cb-font-weight-medium, 500)}.cb-tree__row.cb-is-disabled{opacity:.55;cursor:default}.cb-tree__item:focus-visible>.cb-tree__row{box-shadow:0 0 0 2px var(--cb-color-focus-ring, var(--cb-color-primary-500))}.cb-tree__toggler{display:inline-flex;align-items:center;justify-content:center;width:1.5rem;height:1.5rem;flex:none;padding:0;border:0;border-radius:var(--cb-radius-sm, 4px);background:transparent;color:var(--cb-color-text-muted);cursor:pointer}.cb-tree__toggler:hover{color:var(--cb-color-text);background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}.cb-tree__toggler cb-icon{transition:transform var(--cb-duration-fast, .12s) var(--cb-ease, ease)}.cb-tree__toggler cb-icon.cb-is-open{transform:rotate(90deg)}.cb-tree__spacer{width:1.5rem;flex:none}.cb-tree__icon{flex:none;color:var(--cb-color-text-muted)}.cb-tree__label{flex:1;min-width:0}:host-context([data-theme=\"dark\"]) .cb-tree__row:hover{background:color-mix(in srgb,var(--cb-color-text) 8%,transparent)}:host-context([data-theme=\"dark\"]) .cb-tree__row.cb-is-selected{color:var(--cb-color-primary-300)}\n"] }]
316
+ }], propDecorators: { value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }], selection: [{ type: i0.Input, args: [{ isSignal: true, alias: "selection", required: false }] }, { type: i0.Output, args: ["selectionChange"] }], ariaLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "ariaLabel", required: false }] }], nodeExpand: [{ type: i0.Output, args: ["nodeExpand"] }], nodeCollapse: [{ type: i0.Output, args: ["nodeCollapse"] }], nodeSelect: [{ type: i0.Output, args: ["nodeSelect"] }], nodeTemplate: [{ type: i0.ContentChild, args: [i0.forwardRef(() => CbTreeNodeTemplate), { isSignal: true }] }] } });
21
317
 
22
318
  /**
23
319
  * Generated bundle index. Do not edit.
24
320
  */
25
321
 
26
- export { CbTree };
322
+ export { CbTree, CbTreeNodeTemplate };
@@ -1,17 +1,21 @@
1
1
  import * as i0 from '@angular/core';
2
- import { input, booleanAttribute, model, signal, computed, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
2
+ import { input, booleanAttribute, model, signal, computed, viewChild, forwardRef, ViewEncapsulation, ChangeDetectionStrategy, Component } from '@angular/core';
3
3
  import { NG_VALUE_ACCESSOR } from '@angular/forms';
4
4
  import { CbIcon } from '@caribeng/ui/icon';
5
- import { cbFieldState } from '@caribeng/ui';
5
+ import { injectCbTranslation, cbFormat, cbFieldState } from '@caribeng/ui';
6
6
 
7
7
  /**
8
8
  * TreeSelect de CaribeNG: selector desplegable jerárquico con soporte CVA.
9
9
  */
10
10
  class CbTreeSelect {
11
11
  constructor() {
12
+ /** Textos de interfaz en el idioma activo (`provideCaribeNG({ locale })`). */
13
+ this.t = injectCbTranslation();
14
+ /** Rellena `{0}`, `{1}`… de un texto traducido. */
15
+ this.fmt = cbFormat;
12
16
  this.nodes = input([], /* @ts-ignore */
13
17
  ...(ngDevMode ? [{ debugName: "nodes" }] : /* istanbul ignore next */ []));
14
- this.placeholder = input('Seleccionar nodo…', /* @ts-ignore */
18
+ this.placeholder = input(undefined, /* @ts-ignore */
15
19
  ...(ngDevMode ? [{ debugName: "placeholder" }] : /* istanbul ignore next */ []));
16
20
  this.disabled = input(false, /* @ts-ignore */
17
21
  ...(ngDevMode ? [{ debugName: "disabled" }] : /* istanbul ignore next */ []));
@@ -54,6 +58,7 @@ class CbTreeSelect {
54
58
  ...(ngDevMode ? [{ debugName: "visibleNodes" }] : /* istanbul ignore next */ []));
55
59
  this.onChange = () => { };
56
60
  this.onTouched = () => { };
61
+ this.trigger = viewChild.required('trigger');
57
62
  }
58
63
  writeValue(val) {
59
64
  this.value.set(val ?? null);
@@ -67,6 +72,14 @@ class CbTreeSelect {
67
72
  setDisabledState(isDisabled) {
68
73
  this.cvaDisabled.set(isDisabled);
69
74
  }
75
+ /** Escape cierra el panel y devuelve el foco al disparador. */
76
+ closeOnEscape(event) {
77
+ if (!this.open())
78
+ return;
79
+ event.preventDefault();
80
+ this.open.set(false);
81
+ this.trigger().nativeElement.focus();
82
+ }
70
83
  toggleOpen() {
71
84
  if (this.isDisabled())
72
85
  return;
@@ -105,14 +118,15 @@ class CbTreeSelect {
105
118
  return null;
106
119
  }
107
120
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.5", ngImport: i0, type: CbTreeSelect, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
108
- static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTreeSelect, isStandalone: true, selector: "cb-tree-select", inputs: { nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { properties: { "class.cb-is-open": "open()", "class.cb-is-disabled": "isDisabled()" }, classAttribute: "cb-tree-select" }, providers: [
121
+ static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "22.0.5", type: CbTreeSelect, isStandalone: true, selector: "cb-tree-select", inputs: { nodes: { classPropertyName: "nodes", publicName: "nodes", isSignal: true, isRequired: false, transformFunction: null }, placeholder: { classPropertyName: "placeholder", publicName: "placeholder", isSignal: true, isRequired: false, transformFunction: null }, disabled: { classPropertyName: "disabled", publicName: "disabled", isSignal: true, isRequired: false, transformFunction: null }, invalid: { classPropertyName: "invalid", publicName: "invalid", isSignal: true, isRequired: false, transformFunction: null }, value: { classPropertyName: "value", publicName: "value", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { value: "valueChange" }, host: { listeners: { "keydown.escape": "closeOnEscape($event)" }, properties: { "class.cb-is-open": "open()", "class.cb-is-disabled": "isDisabled()" }, classAttribute: "cb-tree-select" }, providers: [
109
122
  {
110
123
  provide: NG_VALUE_ACCESSOR,
111
124
  useExisting: forwardRef(() => CbTreeSelect),
112
125
  multi: true,
113
126
  },
114
- ], ngImport: i0, template: `
127
+ ], viewQueries: [{ propertyName: "trigger", first: true, predicate: ["trigger"], descendants: true, isSignal: true }], ngImport: i0, template: `
115
128
  <button
129
+ #trigger
116
130
  type="button"
117
131
  class="cb-tree-select__trigger"
118
132
  [class.cb-is-invalid]="fieldState.invalid()"
@@ -125,7 +139,7 @@ class CbTreeSelect {
125
139
  (click)="toggleOpen()"
126
140
  >
127
141
  <span class="cb-tree-select__label" [class.cb-is-placeholder]="!selectedLabel()">
128
- {{ selectedLabel() || placeholder() }}
142
+ {{ selectedLabel() || (placeholder() ?? t().select) }}
129
143
  </span>
130
144
  <cb-icon name="chevron-down" [size]="16" aria-hidden="true" />
131
145
  </button>
@@ -146,7 +160,7 @@ class CbTreeSelect {
146
160
  type="button"
147
161
  class="cb-tree-select__expander"
148
162
  (click)="toggleNode(item.node.key, $event)"
149
- [attr.aria-label]="'Expandir ' + item.node.label"
163
+ [attr.aria-label]="fmt(t().expandItem, item.node.label)"
150
164
  >
151
165
  <cb-icon
152
166
  [name]="isExpanded(item.node.key) ? 'chevron-down' : 'chevron-right'"
@@ -184,9 +198,11 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
184
198
  ], host: {
185
199
  class: 'cb-tree-select',
186
200
  '[class.cb-is-open]': 'open()',
201
+ '(keydown.escape)': 'closeOnEscape($event)',
187
202
  '[class.cb-is-disabled]': 'isDisabled()',
188
203
  }, template: `
189
204
  <button
205
+ #trigger
190
206
  type="button"
191
207
  class="cb-tree-select__trigger"
192
208
  [class.cb-is-invalid]="fieldState.invalid()"
@@ -199,7 +215,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
199
215
  (click)="toggleOpen()"
200
216
  >
201
217
  <span class="cb-tree-select__label" [class.cb-is-placeholder]="!selectedLabel()">
202
- {{ selectedLabel() || placeholder() }}
218
+ {{ selectedLabel() || (placeholder() ?? t().select) }}
203
219
  </span>
204
220
  <cb-icon name="chevron-down" [size]="16" aria-hidden="true" />
205
221
  </button>
@@ -220,7 +236,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
220
236
  type="button"
221
237
  class="cb-tree-select__expander"
222
238
  (click)="toggleNode(item.node.key, $event)"
223
- [attr.aria-label]="'Expandir ' + item.node.label"
239
+ [attr.aria-label]="fmt(t().expandItem, item.node.label)"
224
240
  >
225
241
  <cb-icon
226
242
  [name]="isExpanded(item.node.key) ? 'chevron-down' : 'chevron-right'"
@@ -246,7 +262,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.5", ngImpor
246
262
  </div>
247
263
  }
248
264
  `, styles: [":host{position:relative;display:inline-block;width:100%;font-family:var(--cb-font-sans)}.cb-tree-select__trigger{width:100%;display:flex;align-items:center;justify-content:space-between;gap:var(--cb-space-2);padding:var(--cb-space-2) var(--cb-space-3);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-md);background:var(--cb-color-surface);color:var(--cb-color-text);font-family:inherit;font-size:var(--cb-text-sm);cursor:pointer}.cb-tree-select__label.cb-is-placeholder{color:var(--cb-color-text-muted)}.cb-tree-select__panel{position:absolute;top:calc(100% + 4px);left:0;right:0;z-index:30;max-height:240px;overflow:auto;padding:var(--cb-space-1);border:var(--cb-border-width) solid var(--cb-color-border);border-radius:var(--cb-radius-md);background:var(--cb-color-surface);box-shadow:var(--cb-shadow-md, 0 8px 20px rgba(0, 0, 0, .12))}.cb-tree-select__item{display:flex;align-items:center;gap:.25rem;border-radius:var(--cb-radius-sm)}.cb-tree-select__item.cb-is-selected{background:color-mix(in srgb,var(--cb-color-primary-500) 14%,transparent)}.cb-tree-select__expander{display:inline-flex;align-items:center;justify-content:center;width:1.25rem;height:1.25rem;padding:0;border:none;background:transparent;color:var(--cb-color-text-muted);cursor:pointer}.cb-tree-select__spacer{display:inline-block;width:1.25rem}.cb-tree-select__node-btn{flex:1;display:inline-flex;align-items:center;gap:.375rem;padding:.375rem .5rem;border:none;background:transparent;color:var(--cb-color-text);font-family:inherit;font-size:var(--cb-text-sm);text-align:left;cursor:pointer}.cb-tree-select__trigger.cb-is-invalid{border-color:var(--cb-color-danger)}\n"] }]
249
- }], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }] } });
265
+ }], propDecorators: { nodes: [{ type: i0.Input, args: [{ isSignal: true, alias: "nodes", required: false }] }], placeholder: [{ type: i0.Input, args: [{ isSignal: true, alias: "placeholder", required: false }] }], disabled: [{ type: i0.Input, args: [{ isSignal: true, alias: "disabled", required: false }] }], invalid: [{ type: i0.Input, args: [{ isSignal: true, alias: "invalid", required: false }] }], value: [{ type: i0.Input, args: [{ isSignal: true, alias: "value", required: false }] }, { type: i0.Output, args: ["valueChange"] }], trigger: [{ type: i0.ViewChild, args: ['trigger', { isSignal: true }] }] } });
250
266
 
251
267
  /**
252
268
  * Generated bundle index. Do not edit.