xertica-ui 2.5.2 → 2.6.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 (577) hide show
  1. package/CHANGELOG.md +687 -656
  2. package/README.md +482 -482
  3. package/assets/xertica-logo.svg +37 -37
  4. package/assets/xertica-x-logo.svg +20 -20
  5. package/bin/cli.ts +1293 -1256
  6. package/bin/generate-tokens.ts +256 -262
  7. package/bin/language-config.test.ts +32 -0
  8. package/bin/language-config.ts +36 -11
  9. package/components/Introduction.mdx +121 -121
  10. package/components/assistant/code-block/CodeBlock.tsx +7 -6
  11. package/components/assistant/code-block/code-block.mdx +38 -38
  12. package/components/assistant/code-block/code-block.test.tsx +2 -1
  13. package/components/assistant/formatted-document/FormattedDocument.tsx +3 -0
  14. package/components/assistant/formatted-document/formatted-document.mdx +31 -31
  15. package/components/assistant/formatted-document/formatted-document.test.tsx +5 -4
  16. package/components/assistant/markdown-message/MarkdownMessage.tsx +1 -1
  17. package/components/assistant/markdown-message/markdown-message.mdx +44 -44
  18. package/components/assistant/modern-chat-input/modern-chat-input.mdx +71 -71
  19. package/components/assistant/modern-chat-input/modern-chat-input.test.tsx +3 -2
  20. package/components/assistant/xertica-assistant/parts/AssistantMessageBubble.tsx +1 -1
  21. package/components/assistant/xertica-assistant/types.ts +3 -2
  22. package/components/assistant/xertica-assistant/use-assistant.ts +5 -4
  23. package/components/assistant/xertica-assistant/xertica-assistant.mdx +66 -66
  24. package/components/assistant/xertica-assistant/xertica-assistant.test.tsx +2 -1
  25. package/components/blocks/card-patterns/card-patterns.mdx +123 -123
  26. package/components/brand/branding/branding.mdx +27 -27
  27. package/components/brand/language-selector/language-selector.mdx +126 -126
  28. package/components/brand/theme-toggle/theme-toggle.mdx +47 -47
  29. package/components/brand/theme-toggle/theme-toggle.test.tsx +6 -2
  30. package/components/brand/xertica-logo/xertica-logo.mdx +56 -56
  31. package/components/brand/xertica-orbe/xertica-orbe.mdx +38 -38
  32. package/components/brand/xertica-provider/XerticaProvider.tsx +112 -112
  33. package/components/brand/xertica-provider/xertica-provider.mdx +61 -61
  34. package/components/brand/xertica-provider/xertica-provider.test.tsx +25 -13
  35. package/components/brand/xertica-xlogo/xertica-xlogo.mdx +55 -55
  36. package/components/examples/DrawingMapExample.tsx +1 -4
  37. package/components/layout/header/header.mdx +117 -117
  38. package/components/layout/header/header.test.tsx +2 -1
  39. package/components/layout/sidebar/sidebar.mdx +99 -99
  40. package/components/layout/sidebar/sidebar.stories.tsx +1033 -1033
  41. package/components/layout/sidebar/sidebar.test.tsx +2 -1
  42. package/components/layout/sidebar/sidebar.tsx +1509 -1501
  43. package/components/media/audio-player/AudioPlayer.mdx +67 -67
  44. package/components/media/audio-player/AudioPlayer.test.tsx +2 -1
  45. package/components/media/floating-media-wrapper.mdx +74 -74
  46. package/components/media/video-player/VideoPlayer.mdx +102 -102
  47. package/components/media/video-player/VideoPlayer.test.tsx +3 -2
  48. package/components/pages/forgot-password-page/ForgotPasswordPage.tsx +188 -188
  49. package/components/pages/forgot-password-page/forgot-password-page.mdx +60 -60
  50. package/components/pages/forgot-password-page/forgot-password-page.test.tsx +2 -1
  51. package/components/pages/home-content/HomeContent.tsx +2 -3
  52. package/components/pages/home-content/home-content.mdx +62 -62
  53. package/components/pages/home-page/HomePage.stories.tsx +8 -15
  54. package/components/pages/home-page/home-page.mdx +53 -53
  55. package/components/pages/home-page/home-page.test.tsx +2 -1
  56. package/components/pages/login-page/LoginPage.mdx +31 -31
  57. package/components/pages/login-page/LoginPage.tsx +218 -218
  58. package/components/pages/login-page/login-page.test.tsx +2 -1
  59. package/components/pages/reset-password-page/ResetPasswordPage.tsx +243 -243
  60. package/components/pages/reset-password-page/reset-password-page.mdx +63 -63
  61. package/components/pages/template-content/TemplateContent.tsx +2 -3
  62. package/components/pages/template-content/template-content.mdx +61 -61
  63. package/components/pages/template-page/TemplatePage.stories.tsx +32 -32
  64. package/components/pages/template-page/template-page.mdx +53 -53
  65. package/components/pages/template-page/template-page.test.tsx +2 -1
  66. package/components/pages/verify-email-page/VerifyEmailPage.tsx +206 -206
  67. package/components/pages/verify-email-page/verify-email-page.mdx +55 -55
  68. package/components/public-api-smoke.test.tsx +10 -6
  69. package/components/shared/assistant-utils.ts +3 -2
  70. package/components/shared/navigation.ts +2 -2
  71. package/components/ui/accordion/accordion.mdx +29 -29
  72. package/components/ui/alert/alert.mdx +29 -29
  73. package/components/ui/alert-dialog/alert-dialog.mdx +26 -26
  74. package/components/ui/aspect-ratio/aspect-ratio.mdx +25 -25
  75. package/components/ui/assistant-chart/AssistantChart.tsx +8 -2
  76. package/components/ui/assistant-chart/assistant-chart.mdx +25 -25
  77. package/components/ui/avatar/avatar.mdx +26 -26
  78. package/components/ui/badge/badge.mdx +28 -28
  79. package/components/ui/breadcrumb/breadcrumb.mdx +26 -26
  80. package/components/ui/button/button.mdx +29 -29
  81. package/components/ui/calendar/calendar.mdx +26 -26
  82. package/components/ui/card/card.mdx +26 -26
  83. package/components/ui/carousel/carousel.mdx +26 -26
  84. package/components/ui/chart/chart.mdx +26 -26
  85. package/components/ui/chart/chart.test.tsx +178 -178
  86. package/components/ui/chart/chart.tsx +2252 -2245
  87. package/components/ui/checkbox/checkbox.mdx +26 -26
  88. package/components/ui/collapsible/collapsible.mdx +25 -25
  89. package/components/ui/command/command.mdx +26 -26
  90. package/components/ui/context-menu/context-menu.mdx +26 -26
  91. package/components/ui/dialog/dialog.mdx +26 -26
  92. package/components/ui/drawer/drawer.mdx +26 -26
  93. package/components/ui/dropdown-menu/dropdown-menu.mdx +26 -26
  94. package/components/ui/empty/empty.mdx +26 -26
  95. package/components/ui/file-upload/file-upload.mdx +26 -26
  96. package/components/ui/form/form.mdx +20 -20
  97. package/components/ui/google-maps-loader/google-maps-loader.mdx +68 -68
  98. package/components/ui/hover-card/hover-card.mdx +26 -26
  99. package/components/ui/input/input.mdx +29 -29
  100. package/components/ui/input-otp/input-otp.mdx +26 -26
  101. package/components/ui/label/label.mdx +25 -25
  102. package/components/ui/map/map.mdx +26 -26
  103. package/components/ui/map/map.tsx +6 -1
  104. package/components/ui/menubar/menubar.mdx +26 -26
  105. package/components/ui/navigation-menu/navigation-menu.mdx +26 -26
  106. package/components/ui/notification-badge/notification-badge.mdx +26 -26
  107. package/components/ui/page-header/page-header.mdx +44 -44
  108. package/components/ui/pagination/pagination.mdx +26 -26
  109. package/components/ui/popover/popover.mdx +26 -26
  110. package/components/ui/progress/progress.mdx +25 -25
  111. package/components/ui/radio-group/radio-group.mdx +26 -26
  112. package/components/ui/rating/rating.mdx +26 -26
  113. package/components/ui/resizable/resizable.mdx +26 -26
  114. package/components/ui/resizable/resizable.tsx +13 -8
  115. package/components/ui/rich-text-editor/rich-text-editor.mdx +47 -47
  116. package/components/ui/route-map/route-map.mdx +26 -26
  117. package/components/ui/scroll-area/scroll-area.mdx +25 -25
  118. package/components/ui/search/search.mdx +27 -27
  119. package/components/ui/select/select.mdx +26 -26
  120. package/components/ui/separator/separator.mdx +25 -25
  121. package/components/ui/sheet/sheet.mdx +26 -26
  122. package/components/ui/simple-map/simple-map.mdx +25 -25
  123. package/components/ui/skeleton/skeleton.mdx +25 -25
  124. package/components/ui/slider/slider.mdx +26 -26
  125. package/components/ui/sonner/sonner.mdx +26 -26
  126. package/components/ui/stats-card/stats-card.mdx +26 -26
  127. package/components/ui/stats-card/stats-card.stories.tsx +117 -117
  128. package/components/ui/stats-card/stats-card.tsx +109 -109
  129. package/components/ui/stepper/stepper.mdx +26 -26
  130. package/components/ui/switch/switch.mdx +25 -25
  131. package/components/ui/table/table.mdx +27 -27
  132. package/components/ui/tabs/tabs.mdx +26 -26
  133. package/components/ui/textarea/textarea.mdx +25 -25
  134. package/components/ui/timeline/timeline.mdx +26 -26
  135. package/components/ui/toggle/toggle.mdx +26 -26
  136. package/components/ui/toggle-group/toggle-group.mdx +26 -26
  137. package/components/ui/tooltip/tooltip.mdx +26 -26
  138. package/components/ui/tree-view/tree-view.mdx +26 -26
  139. package/components.json +511 -511
  140. package/contexts/BrandColorsContext.tsx +282 -282
  141. package/contexts/i18n-singleton.test.tsx +57 -0
  142. package/contexts/theme-data.ts +391 -391
  143. package/dist/{AssistantChart-DMJJ_Amf.js → AssistantChart-BMNSA_Pk.js} +5 -5
  144. package/dist/{AssistantChart-D0A1FPYt.cjs → AssistantChart-BzM7plyc.cjs} +150 -114
  145. package/dist/{AssistantChart-BXU1ACnh.js → AssistantChart-C842evTi.js} +134 -240
  146. package/dist/{AssistantChart-BZTPJ5dP.cjs → AssistantChart-CVF2uh37.cjs} +5 -5
  147. package/dist/{AssistantChart-COGiOV-g.cjs → AssistantChart-JooMdVQU.cjs} +17 -7
  148. package/dist/{AssistantChart-CWX1OWNM.js → AssistantChart-KHS-tp-L.js} +17 -7
  149. package/dist/{BrandColorsContext-BwY-b6M4.cjs → BrandColorsContext-B4_81eas.cjs} +2 -2
  150. package/dist/{BrandColorsContext-BMRJ04Wf.js → BrandColorsContext-DbK5LnQ_.js} +2 -2
  151. package/dist/{CodeBlock-CjeFavqV.js → CodeBlock-DiKO8ocT.js} +11 -11
  152. package/dist/{CodeBlock-CV6dtsTM.cjs → CodeBlock-ZYThr7Kn.cjs} +12 -9
  153. package/dist/{XerticaXLogo-mqjoBiLI.js → LanguageSelector-CmTj3lWq.js} +85 -82
  154. package/dist/{XerticaXLogo-BX3ueACh.js → LanguageSelector-DxW6o7bt.js} +81 -81
  155. package/dist/{XerticaXLogo-uQgwns_E.cjs → LanguageSelector-Sw73qvWV.cjs} +84 -81
  156. package/dist/{ThemeContext-BgclCB35.js → ThemeContext-BGeh_Kdr.js} +290 -212
  157. package/dist/{ThemeContext-BblcjQup.cjs → ThemeContext-D50irx5T.cjs} +291 -205
  158. package/dist/{VerifyEmailPage-C_Zk6Gen.cjs → VerifyEmailPage-B6bOrybJ.cjs} +17 -17
  159. package/dist/{VerifyEmailPage-B31mCrMc.js → VerifyEmailPage-BRE5Fz59.js} +8 -8
  160. package/dist/{VerifyEmailPage-BJjAMUTW.js → VerifyEmailPage-BcCluouh.js} +151 -78
  161. package/dist/VerifyEmailPage-Bx1sr0uQ.cjs +3298 -0
  162. package/dist/{VerifyEmailPage-X14vhdyl.js → VerifyEmailPage-DUYyXCX9.js} +12 -12
  163. package/dist/VerifyEmailPage-DXXMHbzq.js +3289 -0
  164. package/dist/{VerifyEmailPage-u_Dn7t1U.cjs → VerifyEmailPage-DpYtFk35.cjs} +21 -21
  165. package/dist/{VerifyEmailPage-Cyl55sJb.js → VerifyEmailPage-NXKWW3Dk.js} +134 -64
  166. package/dist/{VerifyEmailPage-Bv8Ah_TK.cjs → VerifyEmailPage-QrCz4Wqr.cjs} +143 -73
  167. package/dist/{VerifyEmailPage-CkBYfsNy.cjs → VerifyEmailPage-ZmQra0Wi.cjs} +160 -87
  168. package/dist/{XerticaProvider-BErr83Bg.js → XerticaProvider-BF3q_myt.js} +5 -4
  169. package/dist/{XerticaProvider-CeS5G_n5.cjs → XerticaProvider-C_JSOz1U.cjs} +2 -2
  170. package/dist/{XerticaProvider-CwOkHxiT.cjs → XerticaProvider-D5zjrqZq.cjs} +5 -4
  171. package/dist/{XerticaProvider-ra2NciRq.js → XerticaProvider-KTGl4Cn1.js} +2 -2
  172. package/dist/{alert-dialog-DqlRW_An.js → alert-dialog-BrpwXKwS.js} +3 -3
  173. package/dist/{alert-dialog-DhwPioBa.cjs → alert-dialog-CZU1Zase.cjs} +3 -3
  174. package/dist/{alert-dialog-KpoabzJb.js → alert-dialog-ClRoLH7l.js} +40 -56
  175. package/dist/{alert-dialog-B4M3vQKS.cjs → alert-dialog-DBBqvU-V.cjs} +53 -38
  176. package/dist/assistant.cjs.js +2 -2
  177. package/dist/assistant.es.js +2 -2
  178. package/dist/brand.cjs.js +6 -6
  179. package/dist/brand.es.js +2 -2
  180. package/dist/cli.js +63 -21
  181. package/dist/components/assistant/code-block/CodeBlock.d.ts +2 -1
  182. package/dist/components/assistant/formatted-document/FormattedDocument.d.ts +2 -1
  183. package/dist/components/assistant/markdown-message/MarkdownMessage.d.ts +2 -1
  184. package/dist/components/assistant/modern-chat-input/ModernChatInput.d.ts +2 -1
  185. package/dist/components/assistant/xertica-assistant/parts/AssistantCollapsedView.d.ts +2 -1
  186. package/dist/components/assistant/xertica-assistant/parts/AssistantConversationList.d.ts +2 -1
  187. package/dist/components/assistant/xertica-assistant/parts/AssistantDocumentEditor.d.ts +2 -1
  188. package/dist/components/assistant/xertica-assistant/parts/AssistantFeedbackDialog.d.ts +2 -1
  189. package/dist/components/assistant/xertica-assistant/parts/AssistantHeader.d.ts +2 -1
  190. package/dist/components/assistant/xertica-assistant/parts/AssistantMessageBubble.d.ts +2 -1
  191. package/dist/components/assistant/xertica-assistant/parts/AssistantTabBar.d.ts +2 -1
  192. package/dist/components/assistant/xertica-assistant/parts/AssistantTypingIndicator.d.ts +2 -1
  193. package/dist/components/assistant/xertica-assistant/parts/AssistantWelcomeScreen.d.ts +2 -1
  194. package/dist/components/assistant/xertica-assistant/types.d.ts +3 -2
  195. package/dist/components/assistant/xertica-assistant/use-assistant.d.ts +1 -1
  196. package/dist/components/assistant/xertica-assistant/xertica-assistant.d.ts +2 -1
  197. package/dist/components/blocks/card-patterns/ActivityCard.d.ts +1 -1
  198. package/dist/components/blocks/card-patterns/ActivityCardSkeleton.d.ts +1 -1
  199. package/dist/components/blocks/card-patterns/FeatureCard.d.ts +1 -1
  200. package/dist/components/blocks/card-patterns/FeatureCardSkeleton.d.ts +1 -1
  201. package/dist/components/blocks/card-patterns/NotificationCard.d.ts +1 -1
  202. package/dist/components/blocks/card-patterns/NotificationCardSkeleton.d.ts +1 -1
  203. package/dist/components/blocks/card-patterns/ProfileCard.d.ts +1 -1
  204. package/dist/components/blocks/card-patterns/ProfileCardSkeleton.d.ts +1 -1
  205. package/dist/components/blocks/card-patterns/ProjectCard.d.ts +1 -1
  206. package/dist/components/blocks/card-patterns/ProjectCardSkeleton.d.ts +1 -1
  207. package/dist/components/blocks/card-patterns/QuickActionCard.d.ts +1 -1
  208. package/dist/components/blocks/card-patterns/QuickActionCardSkeleton.d.ts +1 -1
  209. package/dist/components/brand/language-selector/LanguageSelector.d.ts +2 -1
  210. package/dist/components/brand/theme-toggle/ThemeToggle.d.ts +2 -1
  211. package/dist/components/brand/xertica-logo/XerticaLogo.d.ts +2 -1
  212. package/dist/components/brand/xertica-orbe/XerticaOrbe.d.ts +2 -1
  213. package/dist/components/brand/xertica-provider/XerticaProvider.d.ts +1 -1
  214. package/dist/components/brand/xertica-xlogo/XerticaXLogo.d.ts +2 -1
  215. package/dist/components/examples/DrawingMapExample.d.ts +2 -1
  216. package/dist/components/examples/FilterableMapExample.d.ts +1 -1
  217. package/dist/components/examples/MapShowcase.d.ts +2 -1
  218. package/dist/components/examples/SimpleFilterableMap.d.ts +2 -1
  219. package/dist/components/figma/ImageWithFallback.d.ts +1 -1
  220. package/dist/components/layout/header/header.d.ts +1 -1
  221. package/dist/components/layout/sidebar/sidebar.d.ts +25 -13
  222. package/dist/components/media/FloatingMediaWrapper.d.ts +1 -1
  223. package/dist/components/media/audio-player/AudioPlayer.d.ts +2 -1
  224. package/dist/components/media/video-player/VideoPlayer.d.ts +2 -1
  225. package/dist/components/pages/forgot-password-page/ForgotPasswordPage.d.ts +2 -1
  226. package/dist/components/pages/home-content/HomeContent.d.ts +2 -1
  227. package/dist/components/pages/home-page/HomePage.d.ts +2 -1
  228. package/dist/components/pages/login-page/LoginPage.d.ts +2 -1
  229. package/dist/components/pages/reset-password-page/ResetPasswordPage.d.ts +2 -1
  230. package/dist/components/pages/template-content/TemplateContent.d.ts +2 -1
  231. package/dist/components/pages/template-page/TemplatePage.d.ts +2 -1
  232. package/dist/components/pages/verify-email-page/VerifyEmailPage.d.ts +2 -1
  233. package/dist/components/shared/CustomTooltipContent.d.ts +1 -1
  234. package/dist/components/shared/assistant-utils.d.ts +3 -2
  235. package/dist/components/shared/error-boundary.d.ts +4 -4
  236. package/dist/components/shared/error-fallbacks.d.ts +4 -3
  237. package/dist/components/shared/navigation.d.ts +6 -2
  238. package/dist/components/ui/accordion/accordion.d.ts +4 -4
  239. package/dist/components/ui/alert/alert.d.ts +3 -3
  240. package/dist/components/ui/alert-dialog/alert-dialog.d.ts +10 -10
  241. package/dist/components/ui/aspect-ratio/aspect-ratio.d.ts +1 -1
  242. package/dist/components/ui/assistant-chart/AssistantChart.d.ts +4 -3
  243. package/dist/components/ui/avatar/avatar.d.ts +3 -3
  244. package/dist/components/ui/badge/badge.d.ts +1 -1
  245. package/dist/components/ui/breadcrumb/breadcrumb.d.ts +7 -7
  246. package/dist/components/ui/calendar/calendar.d.ts +2 -2
  247. package/dist/components/ui/card/card.d.ts +7 -7
  248. package/dist/components/ui/carousel/carousel.d.ts +5 -5
  249. package/dist/components/ui/chart/chart.d.ts +16 -16
  250. package/dist/components/ui/collapsible/collapsible.d.ts +3 -3
  251. package/dist/components/ui/command/command.d.ts +9 -9
  252. package/dist/components/ui/context-menu/context-menu.d.ts +15 -15
  253. package/dist/components/ui/dialog/dialog.d.ts +9 -9
  254. package/dist/components/ui/drawer/drawer.d.ts +10 -10
  255. package/dist/components/ui/dropdown-menu/dropdown-menu.d.ts +15 -15
  256. package/dist/components/ui/form/form.d.ts +7 -7
  257. package/dist/components/ui/google-maps-loader/google-maps-loader.d.ts +3 -3
  258. package/dist/components/ui/hover-card/hover-card.d.ts +3 -3
  259. package/dist/components/ui/input-otp/input-otp.d.ts +4 -4
  260. package/dist/components/ui/label/label.d.ts +1 -1
  261. package/dist/components/ui/menubar/menubar.d.ts +16 -16
  262. package/dist/components/ui/navigation-menu/navigation-menu.d.ts +8 -8
  263. package/dist/components/ui/page-header/page-header.d.ts +3 -3
  264. package/dist/components/ui/pagination/pagination.d.ts +7 -7
  265. package/dist/components/ui/popover/popover.d.ts +4 -4
  266. package/dist/components/ui/progress/progress.d.ts +1 -1
  267. package/dist/components/ui/resizable/resizable.d.ts +11 -7
  268. package/dist/components/ui/rich-text-editor/rich-text-editor.d.ts +1 -1
  269. package/dist/components/ui/scroll-area/scroll-area.d.ts +2 -2
  270. package/dist/components/ui/separator/separator.d.ts +1 -1
  271. package/dist/components/ui/sheet/sheet.d.ts +10 -10
  272. package/dist/components/ui/skeleton/skeleton.d.ts +1 -1
  273. package/dist/components/ui/sonner/sonner.d.ts +2 -1
  274. package/dist/components/ui/stats-card/stats-card-skeleton.d.ts +1 -1
  275. package/dist/components/ui/table/table.d.ts +8 -8
  276. package/dist/components/ui/tabs/tabs.d.ts +4 -4
  277. package/dist/components/ui/tooltip/tooltip.d.ts +4 -4
  278. package/dist/contexts/ApiKeyContext.d.ts +2 -2
  279. package/dist/contexts/AssistenteContext.d.ts +1 -1
  280. package/dist/contexts/AuthContext.d.ts +1 -1
  281. package/dist/contexts/LanguageContext.d.ts +2 -2
  282. package/dist/contexts/LayoutContext.d.ts +2 -2
  283. package/dist/contexts/ThemeContext.d.ts +1 -1
  284. package/dist/features/assistant/hooks/useAssistantConfig.d.ts +1 -1
  285. package/dist/features/home/hooks/useDashboardStats.d.ts +1 -1
  286. package/dist/features/home/hooks/useFeatureCards.d.ts +1 -1
  287. package/dist/features/home/hooks/useTeamMembers.d.ts +1 -1
  288. package/dist/{google-maps-loader-BCe58h9D.js → google-maps-loader-BOug999f.js} +0 -4
  289. package/dist/{google-maps-loader-casMyxlo.cjs → google-maps-loader-DfeBRI8Q.cjs} +0 -5
  290. package/dist/hooks.cjs.js +2 -2
  291. package/dist/hooks.es.js +2 -2
  292. package/dist/{index-9GWd0qxq.cjs → index-BQjx1Mdf.cjs} +1 -1
  293. package/dist/index-Bei5DzAL.js +6 -0
  294. package/dist/index.cjs.js +18 -18
  295. package/dist/index.es.js +12 -12
  296. package/dist/{input-cc-PTD4R.js → input-B0_vbA3g.js} +3 -61
  297. package/dist/{input-C_UiS2Py.cjs → input-ByYuOv8A.cjs} +1 -62
  298. package/dist/layout.cjs.js +1 -1
  299. package/dist/layout.es.js +1 -1
  300. package/dist/pages.cjs.js +1 -1
  301. package/dist/pages.es.js +1 -1
  302. package/dist/{rich-text-editor-DxO1Hz3a.cjs → rich-text-editor-BuqSu718.cjs} +70 -5
  303. package/dist/{rich-text-editor-DqLICivI.js → rich-text-editor-CV8FtA_l.js} +68 -6
  304. package/dist/{rich-text-editor-DloeW0wc.js → rich-text-editor-DV1SixzE.js} +61 -3
  305. package/dist/{rich-text-editor-B2CKz7nx.cjs → rich-text-editor-DnSDglzW.cjs} +63 -2
  306. package/dist/{sidebar-BS1p2V7t.cjs → sidebar-BGJ0j567.cjs} +367 -9
  307. package/dist/{sidebar-3XyzjVBw.js → sidebar-BI6mZlC8.js} +364 -6
  308. package/dist/{sidebar-DyYvgyBj.cjs → sidebar-BtmotOg-.cjs} +367 -9
  309. package/dist/{sidebar-Duermn32.js → sidebar-D3EgGVxF.js} +77 -63
  310. package/dist/{sidebar-CLmIjgNd.cjs → sidebar-DDTqMGnR.cjs} +80 -66
  311. package/dist/{sidebar-B4ZWaMrE.js → sidebar-I7EXyf5D.js} +364 -6
  312. package/dist/ui.cjs.js +7 -7
  313. package/dist/ui.es.js +5 -5
  314. package/dist/{xertica-assistant-QFUnv5I2.cjs → xertica-assistant-BrF9jScR.cjs} +4 -4
  315. package/dist/{xertica-assistant-BbgzsgsG.js → xertica-assistant-CJVnvMqU.js} +55 -45
  316. package/dist/{xertica-assistant-d2qs2Vd9.cjs → xertica-assistant-CKPtc1z5.cjs} +58 -40
  317. package/dist/{xertica-assistant-CyikE3N_.js → xertica-assistant-CsBsxTsI.js} +2 -2
  318. package/dist/{xertica-assistant-CIaUlbIt.cjs → xertica-assistant-DER0brPQ.cjs} +6 -5
  319. package/dist/{xertica-assistant-B1NaSFFj.js → xertica-assistant-DQCjpk5M.js} +4 -3
  320. package/dist/{xertica-assistant-B687qEPU.js → xertica-assistant-Dk-9AJzw.js} +16 -7
  321. package/dist/{xertica-assistant-sOHwTgIP.cjs → xertica-assistant-DxhIKvuY.cjs} +18 -9
  322. package/dist/xertica-ui.css +2 -2
  323. package/docs/components/audio-player.md +1 -1
  324. package/docs/components/sidebar.md +331 -331
  325. package/docs/components/stats-card.md +138 -138
  326. package/docs/components/toggle.md +12 -0
  327. package/docs/doc-audit.md +35 -229
  328. package/docs/i18n.md +31 -10
  329. package/docs/llms.md +6 -4
  330. package/llms-compact.txt +444 -444
  331. package/llms-full.txt +12144 -12144
  332. package/llms.txt +187 -187
  333. package/package.json +223 -219
  334. package/scripts/a11y-audit.mjs +162 -162
  335. package/scripts/fix-stories.cjs +19 -19
  336. package/styles/globals.css +0 -1
  337. package/styles/xertica/base.css +8 -0
  338. package/styles/xertica/tokens.css +240 -240
  339. package/templates/.env.example +2 -2
  340. package/templates/.prettierignore +4 -4
  341. package/templates/.prettierrc +10 -10
  342. package/templates/guidelines/Guidelines.md +865 -865
  343. package/templates/index.html +13 -13
  344. package/templates/package.json +69 -69
  345. package/templates/src/app/components/AuthGuard.tsx +11 -0
  346. package/templates/src/features/auth/ui/AuthPageShell.tsx +32 -32
  347. package/templates/src/features/home/ui/HomeContent.tsx +2 -3
  348. package/templates/src/features/settings/index.ts +2 -0
  349. package/templates/src/features/settings/ui/SettingsContent.tsx +134 -0
  350. package/templates/src/features/template/ui/TemplateContent.tsx +2 -3
  351. package/templates/src/i18n.ts +36 -13
  352. package/templates/src/locales/en/pages/settings.json +15 -0
  353. package/templates/src/locales/es/pages/settings.json +15 -0
  354. package/templates/src/locales/pt-BR/pages/settings.json +15 -0
  355. package/templates/src/pages/SettingsPage.tsx +28 -0
  356. package/templates/src/shared/config/navigation.ts +2 -2
  357. package/templates/src/styles/xertica/tokens.css +240 -240
  358. package/templates/vite.config.d.ts +2 -2
  359. package/templates/vite.config.js +20 -20
  360. package/utils/gemini.ts +2 -2
  361. package/dist/AssistantChart-9w31gdAb.cjs +0 -3363
  362. package/dist/AssistantChart-BAudAfne.cjs +0 -3591
  363. package/dist/AssistantChart-BAx9VQvb.cjs +0 -3374
  364. package/dist/AssistantChart-BP8upjMk.js +0 -3565
  365. package/dist/AssistantChart-CVko2A1W.js +0 -3348
  366. package/dist/AssistantChart-CVzmmhx4.js +0 -3337
  367. package/dist/AssistantChart-CeU2dIb6.js +0 -3469
  368. package/dist/AssistantChart-DO5UuX4J.cjs +0 -3495
  369. package/dist/AudioPlayer-1ypwE2Wh.cjs +0 -936
  370. package/dist/AudioPlayer-BJ2IuRQW.cjs +0 -1275
  371. package/dist/AudioPlayer-BWDW6TN9.cjs +0 -1279
  372. package/dist/AudioPlayer-CM962GEh.js +0 -1280
  373. package/dist/AudioPlayer-CbZId7cj.cjs +0 -998
  374. package/dist/AudioPlayer-DU8zt8-z.js +0 -999
  375. package/dist/AudioPlayer-DuKXrCfy.js +0 -937
  376. package/dist/AudioPlayer-Xxma6_-H.js +0 -1276
  377. package/dist/BrandColorsContext-DLVJgtmH.js +0 -666
  378. package/dist/BrandColorsContext-DZT7JjeD.js +0 -659
  379. package/dist/BrandColorsContext-GUyFmkX0.cjs +0 -665
  380. package/dist/BrandColorsContext-awnBCmC4.cjs +0 -666
  381. package/dist/CodeBlock-C2ZUXt8V.js +0 -219
  382. package/dist/CodeBlock-C5oYnLQp.cjs +0 -218
  383. package/dist/CodeBlock-DuxdtN-l.js +0 -219
  384. package/dist/CodeBlock-POVYONvC.cjs +0 -218
  385. package/dist/CustomTooltipContent-BT6brkVJ.cjs +0 -49
  386. package/dist/CustomTooltipContent-CfOfikhq.js +0 -33
  387. package/dist/CustomTooltipContent-DHjkY0ww.js +0 -40
  388. package/dist/CustomTooltipContent-c_K-DWRr.cjs +0 -56
  389. package/dist/FeatureCard-9GhnlgL3.js +0 -336
  390. package/dist/FeatureCard-Bcb3Zi54.js +0 -302
  391. package/dist/FeatureCard-Cfs6Ishq.js +0 -485
  392. package/dist/FeatureCard-CkPd2psQ.cjs +0 -301
  393. package/dist/FeatureCard-Dkp-xmzM.cjs +0 -335
  394. package/dist/FeatureCard-ie3L8Fpr.cjs +0 -484
  395. package/dist/FeatureCardSkeleton-CAgu8stE.js +0 -27
  396. package/dist/FeatureCardSkeleton-mO3Bdm_V.cjs +0 -26
  397. package/dist/LanguageContext-BwhwC3G2.js +0 -657
  398. package/dist/LanguageContext-DvUt5jBg.cjs +0 -656
  399. package/dist/LayoutContext-BDmcZfMH.cjs +0 -84
  400. package/dist/LayoutContext-C4kKN9RV.cjs +0 -93
  401. package/dist/LayoutContext-CGEe1oPq.js +0 -94
  402. package/dist/LayoutContext-CwT5KLiW.cjs +0 -104
  403. package/dist/LayoutContext-DVLCsoQn.js +0 -105
  404. package/dist/LayoutContext-dbQvdC4O.js +0 -85
  405. package/dist/ThemeContext-BbBNoFTG.js +0 -735
  406. package/dist/ThemeContext-Bo-W2WZH.js +0 -1856
  407. package/dist/ThemeContext-CP3a0jxy.cjs +0 -1855
  408. package/dist/ThemeContext-Cmr8Ex8H.cjs +0 -734
  409. package/dist/ThemeContext-CpqYShLq.cjs +0 -324
  410. package/dist/ThemeContext-D3LzacmG.js +0 -188
  411. package/dist/ThemeContext-DQUOeziy.cjs +0 -1855
  412. package/dist/ThemeContext-Du2nE1PL.js +0 -325
  413. package/dist/ThemeContext-GeEBTJ3q.cjs +0 -1621
  414. package/dist/ThemeContext-JyLK9B1o.js +0 -1622
  415. package/dist/ThemeContext-RTy1m2Uq.js +0 -82
  416. package/dist/ThemeContext-U4dEYc6C.cjs +0 -187
  417. package/dist/ThemeContext-bSzuOit2.cjs +0 -81
  418. package/dist/ThemeContext-ept8jhXI.js +0 -1856
  419. package/dist/VerifyEmailPage-BE-L9mB7.js +0 -2828
  420. package/dist/VerifyEmailPage-BIBOKV7Z.js +0 -3214
  421. package/dist/VerifyEmailPage-BRSP-Pwt.cjs +0 -3196
  422. package/dist/VerifyEmailPage-Bae2cBXT.cjs +0 -2827
  423. package/dist/VerifyEmailPage-BiRm7Nh4.cjs +0 -3213
  424. package/dist/VerifyEmailPage-Bvfv8HVQ.js +0 -3214
  425. package/dist/VerifyEmailPage-CR7kb5df.cjs +0 -2827
  426. package/dist/VerifyEmailPage-C_ihbcth.js +0 -2828
  427. package/dist/VerifyEmailPage-CbgjOF0v.js +0 -2828
  428. package/dist/VerifyEmailPage-CdYPSJoO.js +0 -2828
  429. package/dist/VerifyEmailPage-D-FRj5TU.cjs +0 -3213
  430. package/dist/VerifyEmailPage-DF2ilhum.cjs +0 -3210
  431. package/dist/VerifyEmailPage-DMBh4NM9.cjs +0 -2827
  432. package/dist/VerifyEmailPage-DTtFfC-J.js +0 -3197
  433. package/dist/VerifyEmailPage-Dt7zgA4w.cjs +0 -2827
  434. package/dist/VerifyEmailPage-EhudUdqF.js +0 -3211
  435. package/dist/VerifyEmailPage-RrUApqBN.js +0 -3214
  436. package/dist/VerifyEmailPage-VoMI7MYH.cjs +0 -3213
  437. package/dist/VerifyEmailPage-hdB8JQGv.cjs +0 -3213
  438. package/dist/VerifyEmailPage-vYHbYK3q.js +0 -3214
  439. package/dist/XerticaOrbe-BCUVSPPB.cjs +0 -1924
  440. package/dist/XerticaOrbe-BGIB1CTK.js +0 -1355
  441. package/dist/XerticaOrbe-By8eEvR-.js +0 -1925
  442. package/dist/XerticaOrbe-FWGjBj0U.cjs +0 -1354
  443. package/dist/XerticaProvider-AChwphCO.cjs +0 -48
  444. package/dist/XerticaProvider-AbWlr7Af.cjs +0 -48
  445. package/dist/XerticaProvider-B8CaV7xu.cjs +0 -39
  446. package/dist/XerticaProvider-BITjgC5p.js +0 -39
  447. package/dist/XerticaProvider-BSyFrmC0.js +0 -49
  448. package/dist/XerticaProvider-By8q3Roe.cjs +0 -38
  449. package/dist/XerticaProvider-CUYJZc32.js +0 -49
  450. package/dist/XerticaProvider-CW9hpCdF.cjs +0 -39
  451. package/dist/XerticaProvider-CWgby5mY.js +0 -49
  452. package/dist/XerticaProvider-CWs6EwNa.js +0 -49
  453. package/dist/XerticaProvider-CiNKjMx1.cjs +0 -48
  454. package/dist/XerticaProvider-CjQAQPcn.cjs +0 -48
  455. package/dist/XerticaProvider-D5lLumH-.js +0 -49
  456. package/dist/XerticaProvider-DQtvJU7m.js +0 -40
  457. package/dist/XerticaProvider-DUOJg9iX.js +0 -49
  458. package/dist/XerticaProvider-Dl_b72_l.cjs +0 -51
  459. package/dist/XerticaProvider-qQUDop71.cjs +0 -48
  460. package/dist/XerticaProvider-siSt9uG2.js +0 -40
  461. package/dist/XerticaXLogo-8TTzBjHw.cjs +0 -251
  462. package/dist/XerticaXLogo-B2svDGZh.cjs +0 -251
  463. package/dist/XerticaXLogo-BWaag64t.js +0 -252
  464. package/dist/XerticaXLogo-CFuIlYFH.js +0 -252
  465. package/dist/XerticaXLogo-CU-U-GP4.cjs +0 -251
  466. package/dist/XerticaXLogo-ChryA6xj.js +0 -252
  467. package/dist/XerticaXLogo-CowGv7BC.js +0 -252
  468. package/dist/XerticaXLogo-CziKMQil.cjs +0 -242
  469. package/dist/XerticaXLogo-D8jf0SNv.cjs +0 -214
  470. package/dist/XerticaXLogo-DHz5SugF.js +0 -252
  471. package/dist/XerticaXLogo-DTee_y8X.cjs +0 -251
  472. package/dist/XerticaXLogo-DfUvz-lD.js +0 -243
  473. package/dist/XerticaXLogo-DzXKZBtG.js +0 -231
  474. package/dist/XerticaXLogo-fAJMy3H4.js +0 -215
  475. package/dist/XerticaXLogo-kslQ8Tk_.cjs +0 -251
  476. package/dist/XerticaXLogo-xWbElCZj.cjs +0 -230
  477. package/dist/alert-dialog-iDe5VE5o.js +0 -842
  478. package/dist/alert-dialog-yckpaOpy.cjs +0 -865
  479. package/dist/avatar-Cq5_E8r9.cjs +0 -78
  480. package/dist/avatar-CuYu2MKt.cjs +0 -72
  481. package/dist/avatar-Cxyofu1H.js +0 -56
  482. package/dist/avatar-DSBfJMRJ.js +0 -62
  483. package/dist/breadcrumb-CVzzzqfo.js +0 -103
  484. package/dist/breadcrumb-DIJ0X3Ot.js +0 -96
  485. package/dist/breadcrumb-DjSxkjlQ.cjs +0 -95
  486. package/dist/breadcrumb-DnDlQFg2.cjs +0 -102
  487. package/dist/button-0CXwCRTm.cjs +0 -85
  488. package/dist/button-Bnv9SvYK.cjs +0 -79
  489. package/dist/button-C6uvh0rV.js +0 -63
  490. package/dist/button-qkz7Icqf.js +0 -69
  491. package/dist/card-B8-Gl5DL.js +0 -73
  492. package/dist/card-Bv_c57KU.cjs +0 -72
  493. package/dist/card-DJTsYhLL.cjs +0 -89
  494. package/dist/card-fi8zAN-I.js +0 -90
  495. package/dist/dropdown-menu-B_uEXNc4.cjs +0 -220
  496. package/dist/dropdown-menu-CFuCssWA.js +0 -204
  497. package/dist/dropdown-menu-Ze1YZFyc.cjs +0 -247
  498. package/dist/dropdown-menu-nc_Lvg-u.js +0 -231
  499. package/dist/google-maps-loader-BVoVhUwA.js +0 -316
  500. package/dist/google-maps-loader-BqsYL48U.cjs +0 -285
  501. package/dist/google-maps-loader-DjJaYhV6.cjs +0 -316
  502. package/dist/google-maps-loader-t2IlYBzw.js +0 -286
  503. package/dist/index-B7A523O_.js +0 -8
  504. package/dist/index-BabBx2pa.js +0 -6
  505. package/dist/index-CkTUgOwX.js +0 -8
  506. package/dist/index-D3RLKRAs.cjs +0 -7
  507. package/dist/index-DmHhnb7a.cjs +0 -7
  508. package/dist/index.umd.js +0 -13712
  509. package/dist/input-CNFHVKvo.cjs +0 -145
  510. package/dist/input-CPl84zAx.cjs +0 -151
  511. package/dist/input-D-6IsAca.js +0 -133
  512. package/dist/input-wPYg0d0P.js +0 -127
  513. package/dist/progress-BLwqortq.cjs +0 -105
  514. package/dist/progress-Cs9i4DPx.js +0 -81
  515. package/dist/progress-D9mtsf6j.js +0 -89
  516. package/dist/progress-DDeuWPZw.cjs +0 -97
  517. package/dist/rich-text-editor-1UW3Y2JK.js +0 -2891
  518. package/dist/rich-text-editor-BM-LPpTh.js +0 -2902
  519. package/dist/rich-text-editor-BmsjY03B.js +0 -2949
  520. package/dist/rich-text-editor-BrdC5evx.js +0 -2244
  521. package/dist/rich-text-editor-CyggTOLQ.cjs +0 -2908
  522. package/dist/rich-text-editor-DbV-S7Fi.cjs +0 -2261
  523. package/dist/rich-text-editor-DoCkKhzk.cjs +0 -2919
  524. package/dist/rich-text-editor-GS2kpTAK.cjs +0 -2966
  525. package/dist/routes.d.ts +0 -10
  526. package/dist/select-Cmb8zF7w.cjs +0 -156
  527. package/dist/select-CprSNX0z.js +0 -139
  528. package/dist/select-DT7Zjn42.cjs +0 -162
  529. package/dist/select-En8DkoaQ.js +0 -145
  530. package/dist/sidebar-B3EYhli0.cjs +0 -800
  531. package/dist/sidebar-B9NR0lCe.cjs +0 -800
  532. package/dist/sidebar-BcJ6LxvX.cjs +0 -733
  533. package/dist/sidebar-BvF5I2Ue.cjs +0 -800
  534. package/dist/sidebar-C5B_LHek.cjs +0 -795
  535. package/dist/sidebar-CA6_ek3f.js +0 -801
  536. package/dist/sidebar-CRMiBtAi.js +0 -801
  537. package/dist/sidebar-CVUGHOS_.cjs +0 -756
  538. package/dist/sidebar-CZ2mWaMM.cjs +0 -800
  539. package/dist/sidebar-CmvwjnVb.js +0 -757
  540. package/dist/sidebar-CplprZpM.js +0 -801
  541. package/dist/sidebar-Dz7bd3zP.js +0 -796
  542. package/dist/sidebar-KIS0C2JH.js +0 -801
  543. package/dist/sidebar-OTO_up7Z.js +0 -801
  544. package/dist/sidebar-WoKvFWCN.js +0 -717
  545. package/dist/sidebar-zowjejT2.cjs +0 -800
  546. package/dist/skeleton-4zoHiFJ_.cjs +0 -83
  547. package/dist/skeleton-C4bHqUBf.js +0 -84
  548. package/dist/slider-C0JKA9k3.js +0 -56
  549. package/dist/slider-CPmwzm_3.cjs +0 -73
  550. package/dist/slider-DcJharR9.cjs +0 -73
  551. package/dist/slider-Pay3fka2.js +0 -56
  552. package/dist/sonner-DeUIj0Zg.cjs +0 -63
  553. package/dist/sonner-g9RIfi35.js +0 -47
  554. package/dist/tooltip-CNtsL5cB.cjs +0 -71
  555. package/dist/tooltip-CTyZCD8h.js +0 -55
  556. package/dist/tooltip-CwgSdy3h.cjs +0 -67
  557. package/dist/tooltip-D-OrYnKO.js +0 -51
  558. package/dist/use-audio-player-BJFV24XW.js +0 -188
  559. package/dist/use-audio-player-Bkh23vQ3.js +0 -177
  560. package/dist/use-audio-player-Dn1NR9xN.cjs +0 -176
  561. package/dist/use-audio-player-DyVYlOnR.cjs +0 -187
  562. package/dist/use-mobile-BB4M_4Ru.cjs +0 -47
  563. package/dist/use-mobile-CLu9nqGL.js +0 -31
  564. package/dist/use-mobile-CNwiBNxu.js +0 -33
  565. package/dist/use-mobile-Dlf74ufz.cjs +0 -49
  566. package/dist/xertica-assistant-B1IaHXnB.cjs +0 -1894
  567. package/dist/xertica-assistant-BMqdyRVi.js +0 -2082
  568. package/dist/xertica-assistant-Bj3vBCq_.cjs +0 -2081
  569. package/dist/xertica-assistant-CfBCo21g.js +0 -2148
  570. package/dist/xertica-assistant-DIM_Do1k.js +0 -1866
  571. package/dist/xertica-assistant-DPsESB6t.js +0 -1878
  572. package/dist/xertica-assistant-DrsRwla1.cjs +0 -2147
  573. package/dist/xertica-assistant-Qp3ydksa.cjs +0 -1882
  574. package/dist/xertica-assistant-gnCJdcZY.js +0 -1866
  575. package/dist/xertica-assistant-yyrR0JKl.cjs +0 -1882
  576. package/styles/xertica/app-overrides/scrollbar.css +0 -33
  577. package/dist/{XerticaXLogo-qBPhwK3g.cjs → LanguageSelector-1cINLJ23.cjs} +80 -80
@@ -1,2891 +0,0 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
- import * as React from "react";
3
- import { useRef, useState, useCallback, useEffect } from "react";
4
- import * as RechartsPrimitive from "recharts";
5
- import { c as cn, B as Button } from "./button-C6uvh0rV.js";
6
- import { cva } from "class-variance-authority";
7
- import { XCircle, AlertTriangle, Info, CheckCircle, RefreshCw, BarChart3, WifiOff, XIcon, Undo, Redo, ChevronDown, Type, Heading1, Heading2, Heading3, Bold, Italic, Underline, AlignLeft, AlignCenter, AlignRight, List, ListOrdered, Link, X, Search, ChevronUp } from "lucide-react";
8
- import { C as Card, e as CardHeader, f as CardTitle, c as CardDescription, a as CardAction, b as CardContent, d as CardFooter, S as Skeleton } from "./skeleton-C4bHqUBf.js";
9
- import { S as Select, h as SelectTrigger, i as SelectValue, a as SelectContent, c as SelectItem } from "./select-CprSNX0z.js";
10
- import * as DialogPrimitive from "@radix-ui/react-dialog";
11
- import { D as DropdownMenu, n as DropdownMenuTrigger, b as DropdownMenuContent, d as DropdownMenuItem } from "./dropdown-menu-CFuCssWA.js";
12
- import { P as Popover, c as PopoverTrigger, b as PopoverContent, I as Input } from "./input-wPYg0d0P.js";
13
- const alertVariants = cva(
14
- "relative w-full rounded-[var(--radius)] border-l-4 px-4 py-3 grid has-[>svg]:grid-cols-[calc(var(--spacing)*4)_1fr] grid-cols-[0_1fr] has-[>svg]:gap-x-3 gap-y-0.5 items-start [&>svg]:size-5 [&>svg]:translate-y-0.5 [&>svg]:text-current",
15
- {
16
- variants: {
17
- variant: {
18
- default: "bg-muted/50 border-l-border text-foreground [&>svg]:text-muted-foreground",
19
- success: "bg-[color:var(--success)]/10 dark:bg-[color:var(--success)]/20 border-l-[color:var(--success)] text-foreground [&>svg]:text-[color:var(--success)]",
20
- info: "bg-[color:var(--info)]/10 dark:bg-[color:var(--info)]/20 border-l-[color:var(--info)] text-foreground [&>svg]:text-[color:var(--info)]",
21
- warning: "bg-[color:var(--warning)]/10 dark:bg-[color:var(--warning)]/20 border-l-[color:var(--warning)] text-foreground [&>svg]:text-[color:var(--warning)]",
22
- destructive: "bg-[color:var(--destructive)]/10 dark:bg-[color:var(--destructive)]/20 border-l-[color:var(--destructive)] text-foreground [&>svg]:text-[color:var(--destructive)]"
23
- }
24
- },
25
- defaultVariants: {
26
- variant: "default"
27
- }
28
- }
29
- );
30
- const alertIcons = {
31
- default: Info,
32
- success: CheckCircle,
33
- info: Info,
34
- warning: AlertTriangle,
35
- destructive: XCircle
36
- };
37
- function Alert({ className, variant, icon, children, ...props }) {
38
- const alertVariant = variant && variant in alertIcons ? variant : "default";
39
- const DefaultIcon = alertIcons[alertVariant];
40
- return /* @__PURE__ */ jsxs(
41
- "div",
42
- {
43
- "data-slot": "alert",
44
- role: "alert",
45
- className: cn(alertVariants({ variant }), className),
46
- ...props,
47
- children: [
48
- icon !== void 0 ? icon : /* @__PURE__ */ jsx(DefaultIcon, { className: "flex-shrink-0" }),
49
- /* @__PURE__ */ jsx("div", { className: "flex-1", children })
50
- ]
51
- }
52
- );
53
- }
54
- function AlertTitle({ className, ...props }) {
55
- return /* @__PURE__ */ jsx(
56
- "div",
57
- {
58
- "data-slot": "alert-title",
59
- className: cn("font-medium mb-1 leading-tight", className),
60
- ...props
61
- }
62
- );
63
- }
64
- function AlertDescription({ className, ...props }) {
65
- return /* @__PURE__ */ jsx("div", { "data-slot": "alert-description", className: cn("leading-relaxed", className), ...props });
66
- }
67
- const Empty = React.forwardRef(
68
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
69
- "div",
70
- {
71
- ref,
72
- className: cn(
73
- "flex min-h-[400px] flex-col items-center justify-center rounded-[var(--radius-card)] border border-dashed border-border p-8 text-center animate-in fade-in-50",
74
- className
75
- ),
76
- ...props
77
- }
78
- )
79
- );
80
- Empty.displayName = "Empty";
81
- const EmptyIcon = React.forwardRef(
82
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
83
- "div",
84
- {
85
- ref,
86
- className: cn(
87
- "mx-auto flex h-20 w-20 items-center justify-center rounded-full bg-muted",
88
- className
89
- ),
90
- ...props
91
- }
92
- )
93
- );
94
- EmptyIcon.displayName = "EmptyIcon";
95
- const EmptyImage = React.forwardRef(
96
- ({ className, alt, ...props }, ref) => /* @__PURE__ */ jsx(
97
- "img",
98
- {
99
- ref,
100
- alt,
101
- className: cn("mx-auto mb-4 h-48 w-48 object-contain opacity-50", className),
102
- ...props
103
- }
104
- )
105
- );
106
- EmptyImage.displayName = "EmptyImage";
107
- const EmptyTitle = React.forwardRef(
108
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx("h3", { ref, className: cn("mt-4 font-semibold text-foreground", className), ...props })
109
- );
110
- EmptyTitle.displayName = "EmptyTitle";
111
- const EmptyDescription = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
112
- "p",
113
- {
114
- ref,
115
- className: cn("mt-2 text-sm text-muted-foreground max-w-sm mx-auto", className),
116
- ...props
117
- }
118
- ));
119
- EmptyDescription.displayName = "EmptyDescription";
120
- const EmptyAction = React.forwardRef(
121
- ({ className, ...props }, ref) => /* @__PURE__ */ jsx(
122
- "div",
123
- {
124
- ref,
125
- className: cn("mt-6 flex flex-col gap-2 sm:flex-row sm:gap-4", className),
126
- ...props
127
- }
128
- )
129
- );
130
- EmptyAction.displayName = "EmptyAction";
131
- const THEMES = { light: "", dark: ".dark" };
132
- const defaultPeriods = [
133
- { value: "7d", label: "7 days" },
134
- { value: "30d", label: "30 days" },
135
- { value: "90d", label: "90 days" }
136
- ];
137
- const defaultChartColors = [
138
- "var(--chart-1)",
139
- "var(--chart-2)",
140
- "var(--chart-3)",
141
- "var(--chart-4)",
142
- "var(--chart-5)",
143
- "var(--chart-6)",
144
- "var(--chart-7)",
145
- "var(--chart-8)"
146
- ];
147
- const chartBarSizes = {
148
- sm: 8,
149
- md: 14,
150
- lg: 22,
151
- xl: 32
152
- };
153
- const ChartContext = React.createContext(null);
154
- function useChart() {
155
- const context = React.useContext(ChartContext);
156
- if (!context) {
157
- throw new Error("useChart must be used within a <ChartContainer />");
158
- }
159
- return context;
160
- }
161
- function ChartContainer({
162
- id,
163
- className,
164
- children,
165
- config,
166
- ...props
167
- }) {
168
- const uniqueId = React.useId();
169
- const chartId = `chart-${id || uniqueId.replace(/:/g, "")}`;
170
- return /* @__PURE__ */ jsx(ChartContext.Provider, { value: { config }, children: /* @__PURE__ */ jsxs(
171
- "div",
172
- {
173
- "data-slot": "chart",
174
- "data-chart": chartId,
175
- className: cn(
176
- "[&_.recharts-cartesian-axis-tick_text]:fill-muted-foreground [&_.recharts-cartesian-grid_line[stroke='#ccc']]:stroke-border/50 [&_.recharts-curve.recharts-tooltip-cursor]:stroke-border [&_.recharts-polar-grid_[stroke='#ccc']]:stroke-border [&_.recharts-radial-bar-background-sector]:fill-muted [&_.recharts-rectangle.recharts-tooltip-cursor]:fill-muted [&_.recharts-reference-line_[stroke='#ccc']]:stroke-border relative h-[300px] min-h-[200px] w-full min-w-0 overflow-hidden text-xs [&_.recharts-dot[stroke='#fff']]:stroke-transparent [&_.recharts-layer]:outline-hidden [&_.recharts-sector]:outline-hidden [&_.recharts-sector[stroke='#fff']]:stroke-transparent [&_.recharts-surface]:outline-hidden",
177
- className
178
- ),
179
- ...props,
180
- children: [
181
- /* @__PURE__ */ jsx(ChartStyle, { id: chartId, config }),
182
- /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { width: "100%", height: "100%", children })
183
- ]
184
- }
185
- ) });
186
- }
187
- const ChartStyle = ({ id, config }) => {
188
- const colorConfig = Object.entries(config).filter(([, config2]) => config2.theme || config2.color);
189
- if (!colorConfig.length) {
190
- return null;
191
- }
192
- return /* @__PURE__ */ jsx(
193
- "style",
194
- {
195
- dangerouslySetInnerHTML: {
196
- __html: Object.entries(THEMES).map(
197
- ([theme, prefix]) => `
198
- ${prefix} [data-chart=${id}] {
199
- ${colorConfig.map(([key, itemConfig]) => {
200
- var _a;
201
- const color = ((_a = itemConfig.theme) == null ? void 0 : _a[theme]) || itemConfig.color;
202
- return color ? ` --color-${key}: ${color};` : null;
203
- }).join("\n")}
204
- }
205
- `
206
- ).join("\n")
207
- }
208
- }
209
- );
210
- };
211
- const ChartTooltip = RechartsPrimitive.Tooltip;
212
- function ChartTooltipContent({
213
- active,
214
- payload,
215
- className,
216
- indicator = "dot",
217
- hideLabel = false,
218
- hideIndicator = false,
219
- label,
220
- labelFormatter,
221
- labelClassName,
222
- formatter,
223
- color,
224
- nameKey,
225
- labelKey
226
- }) {
227
- const { config } = useChart();
228
- const tooltipLabel = React.useMemo(() => {
229
- var _a;
230
- if (hideLabel || !(payload == null ? void 0 : payload.length)) {
231
- return null;
232
- }
233
- const [item] = payload;
234
- const key = `${labelKey || (item == null ? void 0 : item.dataKey) || (item == null ? void 0 : item.name) || "value"}`;
235
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
236
- const value = !labelKey && typeof label === "string" ? ((_a = config[label]) == null ? void 0 : _a.label) || label : itemConfig == null ? void 0 : itemConfig.label;
237
- if (labelFormatter) {
238
- return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: labelFormatter(value, payload) });
239
- }
240
- if (!value) {
241
- return null;
242
- }
243
- return /* @__PURE__ */ jsx("div", { className: cn("font-medium", labelClassName), children: value });
244
- }, [label, labelFormatter, payload, hideLabel, labelClassName, config, labelKey]);
245
- if (!active || !(payload == null ? void 0 : payload.length)) {
246
- return null;
247
- }
248
- const nestLabel = payload.length === 1 && indicator !== "dot";
249
- return /* @__PURE__ */ jsxs(
250
- "div",
251
- {
252
- className: cn(
253
- "border-border/50 bg-background/95 backdrop-blur-sm grid min-w-[8rem] items-start gap-1.5 rounded-xl border px-3 py-2 text-xs shadow-xl",
254
- className
255
- ),
256
- children: [
257
- !nestLabel ? tooltipLabel : null,
258
- /* @__PURE__ */ jsx("div", { className: "grid gap-1.5", children: payload.map((item, index) => {
259
- var _a;
260
- const key = `${nameKey || item.name || item.dataKey || "value"}`;
261
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
262
- const indicatorColor = color || ((_a = item.payload) == null ? void 0 : _a.fill) || item.color;
263
- return /* @__PURE__ */ jsx(
264
- "div",
265
- {
266
- className: cn(
267
- "[&>svg]:text-muted-foreground flex w-full flex-wrap items-stretch gap-2 [&>svg]:h-2.5 [&>svg]:w-2.5",
268
- indicator === "dot" && "items-center"
269
- ),
270
- children: formatter && (item == null ? void 0 : item.value) !== void 0 && item.name ? formatter(item.value, item.name, item, index, item.payload) : /* @__PURE__ */ jsxs(Fragment, { children: [
271
- (itemConfig == null ? void 0 : itemConfig.icon) ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : !hideIndicator && /* @__PURE__ */ jsx(
272
- "div",
273
- {
274
- className: cn(
275
- "shrink-0 rounded-[2px] border-(--color-border) bg-(--color-bg)",
276
- {
277
- "h-2.5 w-2.5": indicator === "dot",
278
- "w-1": indicator === "line",
279
- "w-0 border-[1.5px] border-dashed bg-transparent": indicator === "dashed",
280
- "my-0.5": nestLabel && indicator === "dashed"
281
- }
282
- ),
283
- style: {
284
- "--color-bg": indicatorColor,
285
- "--color-border": indicatorColor
286
- }
287
- }
288
- ),
289
- /* @__PURE__ */ jsxs(
290
- "div",
291
- {
292
- className: cn(
293
- "flex flex-1 justify-between leading-none",
294
- nestLabel ? "items-end" : "items-center"
295
- ),
296
- children: [
297
- /* @__PURE__ */ jsxs("div", { className: "grid gap-1.5", children: [
298
- nestLabel ? tooltipLabel : null,
299
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: (itemConfig == null ? void 0 : itemConfig.label) || item.name })
300
- ] }),
301
- item.value && /* @__PURE__ */ jsx("span", { className: "text-foreground font-mono font-semibold tabular-nums", children: item.value.toLocaleString() })
302
- ]
303
- }
304
- )
305
- ] })
306
- },
307
- item.dataKey
308
- );
309
- }) })
310
- ]
311
- }
312
- );
313
- }
314
- const ChartLegend = RechartsPrimitive.Legend;
315
- function ChartLegendContent({
316
- className,
317
- hideIcon = false,
318
- payload,
319
- verticalAlign = "bottom",
320
- nameKey
321
- }) {
322
- const { config } = useChart();
323
- if (!(payload == null ? void 0 : payload.length)) {
324
- return null;
325
- }
326
- return /* @__PURE__ */ jsx(
327
- "div",
328
- {
329
- className: cn(
330
- "flex items-center justify-center gap-4",
331
- verticalAlign === "top" ? "pb-3" : "pt-3",
332
- className
333
- ),
334
- children: payload.map((item) => {
335
- const key = `${nameKey ? item.value : item.dataKey || item.value || "value"}`;
336
- const itemConfig = getPayloadConfigFromPayload(config, item, key);
337
- return /* @__PURE__ */ jsxs(
338
- "div",
339
- {
340
- className: cn(
341
- "[&>svg]:text-muted-foreground flex items-center gap-1.5 [&>svg]:h-3 [&>svg]:w-3"
342
- ),
343
- children: [
344
- (itemConfig == null ? void 0 : itemConfig.icon) && !hideIcon ? /* @__PURE__ */ jsx(itemConfig.icon, {}) : /* @__PURE__ */ jsx(
345
- "div",
346
- {
347
- className: "h-2 w-2 shrink-0 rounded-full bg-(--color-bg)",
348
- style: {
349
- "--color-bg": item.color || `var(--color-${key})`
350
- }
351
- }
352
- ),
353
- /* @__PURE__ */ jsx("span", { className: "text-muted-foreground text-xs", children: (itemConfig == null ? void 0 : itemConfig.label) || item.value })
354
- ]
355
- },
356
- item.value
357
- );
358
- })
359
- }
360
- );
361
- }
362
- function getPayloadConfigFromPayload(config, payload, key) {
363
- if (typeof payload !== "object" || payload === null) {
364
- return void 0;
365
- }
366
- const payloadPayload = "payload" in payload && typeof payload.payload === "object" && payload.payload !== null ? payload.payload : void 0;
367
- let configLabelKey = key;
368
- if (key in payload && typeof payload[key] === "string") {
369
- configLabelKey = payload[key];
370
- } else if (payloadPayload && key in payloadPayload && typeof payloadPayload[key] === "string") {
371
- configLabelKey = payloadPayload[key];
372
- }
373
- return configLabelKey in config ? config[configLabelKey] : config[key];
374
- }
375
- function getChartSeries(config, series) {
376
- if (series == null ? void 0 : series.length) {
377
- return series;
378
- }
379
- return Object.entries(config).map(([key, item]) => ({
380
- key,
381
- label: item.label
382
- }));
383
- }
384
- function getSeriesColor(key, index, colors) {
385
- if (Array.isArray(colors)) {
386
- return colors[index] || defaultChartColors[index % defaultChartColors.length];
387
- }
388
- return (colors == null ? void 0 : colors[key]) || defaultChartColors[index % defaultChartColors.length];
389
- }
390
- function getChartConfigWithColors(config, keys, colors) {
391
- return keys.reduce((nextConfig, key, index) => {
392
- const item = config[key];
393
- if ((item == null ? void 0 : item.theme) && !colors) {
394
- nextConfig[key] = item;
395
- return nextConfig;
396
- }
397
- nextConfig[key] = {
398
- label: (item == null ? void 0 : item.label) || key,
399
- icon: item == null ? void 0 : item.icon,
400
- color: colors ? getSeriesColor(key, index, colors) : (item == null ? void 0 : item.color) || getSeriesColor(key, index)
401
- };
402
- return nextConfig;
403
- }, {});
404
- }
405
- function buildChartConfig(keys, colors) {
406
- return keys.reduce((cfg, key, index) => {
407
- cfg[key] = {
408
- label: key,
409
- color: getSeriesColor(key, index, colors)
410
- };
411
- return cfg;
412
- }, {});
413
- }
414
- function formatTick(value) {
415
- if (typeof value !== "number") {
416
- return value;
417
- }
418
- return Intl.NumberFormat("en", {
419
- notation: "compact",
420
- maximumFractionDigits: 1
421
- }).format(value);
422
- }
423
- function defaultFilterData(data, period) {
424
- const match = period.match(/^(\d+)/);
425
- if (!match) {
426
- return data;
427
- }
428
- const limit = Number(match[1]);
429
- return data.slice(Math.max(data.length - limit, 0));
430
- }
431
- function getErrorDescription(error) {
432
- if (typeof error === "string") {
433
- return error;
434
- }
435
- if (error instanceof Error) {
436
- return error.message;
437
- }
438
- return void 0;
439
- }
440
- function getBarSize(barSize = "md") {
441
- return typeof barSize === "number" ? barSize : chartBarSizes[barSize];
442
- }
443
- function hasChartData(data, series) {
444
- if (!data.length || !series.length) {
445
- return false;
446
- }
447
- return data.some(
448
- (item) => series.some((serie) => {
449
- const value = item[serie.key];
450
- return value !== null && value !== void 0 && value !== "";
451
- })
452
- );
453
- }
454
- function hasPieData(data, nameKey, valueKey) {
455
- return data.some((item) => {
456
- const name = item[nameKey];
457
- const value = item[valueKey];
458
- return name !== null && name !== void 0 && name !== "" && value !== null && value !== void 0 && value !== "";
459
- });
460
- }
461
- function ChartState({
462
- type,
463
- className,
464
- error,
465
- onRetry,
466
- retryLabel = "Try again",
467
- emptyTitle = "No data available",
468
- emptyDescription = "There is no data available for this chart yet.",
469
- errorTitle = "Connection error",
470
- errorDescription,
471
- loadingLabel = "Loading chart data"
472
- }) {
473
- if (type === "loading") {
474
- return /* @__PURE__ */ jsxs(
475
- "div",
476
- {
477
- className: cn(
478
- "flex min-h-[240px] flex-col justify-end gap-3 rounded-[var(--radius-card)] border border-border p-6",
479
- className
480
- ),
481
- "aria-label": typeof loadingLabel === "string" ? loadingLabel : void 0,
482
- children: [
483
- /* @__PURE__ */ jsx(Skeleton, { className: "h-8 w-2/5" }),
484
- /* @__PURE__ */ jsx(Skeleton, { className: "h-14 w-3/5" }),
485
- /* @__PURE__ */ jsx(Skeleton, { className: "h-24 w-4/5" }),
486
- /* @__PURE__ */ jsx(Skeleton, { className: "h-36 w-full" })
487
- ]
488
- }
489
- );
490
- }
491
- if (type === "error") {
492
- return /* @__PURE__ */ jsx(
493
- "div",
494
- {
495
- className: cn(
496
- "flex min-h-[240px] items-center justify-center rounded-[var(--radius-card)] border border-border p-6",
497
- className
498
- ),
499
- children: /* @__PURE__ */ jsxs(Alert, { variant: "destructive", className: "max-w-xl", children: [
500
- /* @__PURE__ */ jsx(AlertTitle, { children: errorTitle }),
501
- /* @__PURE__ */ jsx(AlertDescription, { children: errorDescription || getErrorDescription(error) || "Unable to load chart data. Check your connection and try again." }),
502
- onRetry ? /* @__PURE__ */ jsx("div", { className: "mt-3", children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: onRetry, children: [
503
- /* @__PURE__ */ jsx(RefreshCw, { className: "size-4" }),
504
- retryLabel
505
- ] }) }) : null
506
- ] })
507
- }
508
- );
509
- }
510
- return /* @__PURE__ */ jsxs(Empty, { className: cn("min-h-[240px]", className), children: [
511
- /* @__PURE__ */ jsx(EmptyIcon, { children: /* @__PURE__ */ jsx(BarChart3, { className: "size-10 text-muted-foreground" }) }),
512
- /* @__PURE__ */ jsx(EmptyTitle, { children: emptyTitle }),
513
- /* @__PURE__ */ jsx(EmptyDescription, { children: emptyDescription }),
514
- onRetry ? /* @__PURE__ */ jsx(EmptyAction, { children: /* @__PURE__ */ jsxs(Button, { size: "sm", variant: "outline", onClick: onRetry, children: [
515
- /* @__PURE__ */ jsx(WifiOff, { className: "size-4" }),
516
- retryLabel
517
- ] }) }) : null
518
- ] });
519
- }
520
- function getChartState(state, hasData, className) {
521
- if (state.isLoading) {
522
- return /* @__PURE__ */ jsx(ChartState, { ...state, type: "loading", className });
523
- }
524
- if (state.error) {
525
- return /* @__PURE__ */ jsx(ChartState, { ...state, type: "error", className });
526
- }
527
- if (!hasData) {
528
- return /* @__PURE__ */ jsx(ChartState, { ...state, type: "empty", className });
529
- }
530
- return null;
531
- }
532
- function ChartCard({
533
- title,
534
- description,
535
- action,
536
- footer,
537
- children,
538
- className,
539
- contentClassName,
540
- ...props
541
- }) {
542
- return /* @__PURE__ */ jsxs(Card, { className: cn("w-full min-w-0 overflow-hidden", className), ...props, children: [
543
- /* @__PURE__ */ jsxs(CardHeader, { children: [
544
- /* @__PURE__ */ jsx(CardTitle, { children: title }),
545
- description ? /* @__PURE__ */ jsx(CardDescription, { children: description }) : null,
546
- action ? /* @__PURE__ */ jsx(CardAction, { children: action }) : null
547
- ] }),
548
- /* @__PURE__ */ jsx(CardContent, { className: contentClassName, children }),
549
- footer ? /* @__PURE__ */ jsx(CardFooter, { children: footer }) : null
550
- ] });
551
- }
552
- function AreaGradientDefs({
553
- seriesKeys,
554
- opacity = 0.3
555
- }) {
556
- return /* @__PURE__ */ jsx("defs", { children: seriesKeys.map((key) => /* @__PURE__ */ jsxs("linearGradient", { id: `gradient-${key}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
557
- /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: `var(--color-${key})`, stopOpacity: opacity }),
558
- /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: `var(--color-${key})`, stopOpacity: 0 })
559
- ] }, key)) });
560
- }
561
- function DashboardBarChart({
562
- data,
563
- config,
564
- indexKey = "name",
565
- series,
566
- colors,
567
- barSize = "md",
568
- stacked = false,
569
- showGrid = true,
570
- showLegend = true,
571
- valueFormatter = formatTick,
572
- isLoading,
573
- error,
574
- onRetry,
575
- retryLabel,
576
- emptyTitle,
577
- emptyDescription,
578
- errorTitle,
579
- errorDescription,
580
- loadingLabel,
581
- stateClassName,
582
- className,
583
- ...props
584
- }) {
585
- const chartSeries = getChartSeries(config, series);
586
- const chartConfig = getChartConfigWithColors(
587
- config,
588
- chartSeries.map((item) => item.key),
589
- colors
590
- );
591
- const chartState = getChartState(
592
- {
593
- isLoading,
594
- error,
595
- onRetry,
596
- retryLabel,
597
- emptyTitle,
598
- emptyDescription,
599
- errorTitle,
600
- errorDescription,
601
- loadingLabel
602
- },
603
- hasChartData(data, chartSeries),
604
- cn("h-[320px] w-full", stateClassName)
605
- );
606
- const barElements = React.useMemo(() => {
607
- const topOfStack = /* @__PURE__ */ new Set();
608
- if (stacked) {
609
- const lastByStack = /* @__PURE__ */ new Map();
610
- chartSeries.forEach((s) => lastByStack.set(s.stackId || "total", s.key));
611
- lastByStack.forEach((key) => topOfStack.add(key));
612
- }
613
- return chartSeries.map((item) => {
614
- const isTop = !stacked || topOfStack.has(item.key);
615
- return /* @__PURE__ */ jsx(
616
- RechartsPrimitive.Bar,
617
- {
618
- dataKey: item.key,
619
- fill: `var(--color-${item.key})`,
620
- radius: isTop ? [4, 4, 0, 0] : [0, 0, 0, 0],
621
- barSize: getBarSize(barSize),
622
- stackId: stacked ? item.stackId || "total" : item.stackId,
623
- isAnimationActive: true,
624
- animationDuration: 600,
625
- animationEasing: "ease-out"
626
- },
627
- item.key
628
- );
629
- });
630
- }, [stacked, chartSeries]);
631
- if (chartState) {
632
- return chartState;
633
- }
634
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.BarChart, { data, accessibilityLayer: true, barGap: 4, children: [
635
- showGrid ? /* @__PURE__ */ jsx(
636
- RechartsPrimitive.CartesianGrid,
637
- {
638
- vertical: false,
639
- strokeDasharray: "3 3",
640
- stroke: "var(--border)",
641
- strokeOpacity: 0.5
642
- }
643
- ) : null,
644
- /* @__PURE__ */ jsx(
645
- RechartsPrimitive.XAxis,
646
- {
647
- dataKey: indexKey,
648
- tickLine: false,
649
- axisLine: false,
650
- tickMargin: 8
651
- }
652
- ),
653
- /* @__PURE__ */ jsx(
654
- RechartsPrimitive.YAxis,
655
- {
656
- tickLine: false,
657
- axisLine: false,
658
- tickMargin: 8,
659
- tickFormatter: valueFormatter
660
- }
661
- ),
662
- /* @__PURE__ */ jsx(
663
- ChartTooltip,
664
- {
665
- cursor: { fill: "var(--muted)", opacity: 0.4, radius: 4 },
666
- content: /* @__PURE__ */ jsx(ChartTooltipContent, {})
667
- }
668
- ),
669
- showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
670
- barElements
671
- ] }) });
672
- }
673
- function DashboardLineChart({
674
- data,
675
- config,
676
- indexKey = "name",
677
- series,
678
- colors,
679
- showDots = false,
680
- showGrid = true,
681
- showLegend = true,
682
- curveType = "monotone",
683
- strokeWidth = 2,
684
- valueFormatter = formatTick,
685
- isLoading,
686
- error,
687
- onRetry,
688
- retryLabel,
689
- emptyTitle,
690
- emptyDescription,
691
- errorTitle,
692
- errorDescription,
693
- loadingLabel,
694
- stateClassName,
695
- className,
696
- ...props
697
- }) {
698
- const chartSeries = getChartSeries(config, series);
699
- const chartConfig = getChartConfigWithColors(
700
- config,
701
- chartSeries.map((item) => item.key),
702
- colors
703
- );
704
- const chartState = getChartState(
705
- {
706
- isLoading,
707
- error,
708
- onRetry,
709
- retryLabel,
710
- emptyTitle,
711
- emptyDescription,
712
- errorTitle,
713
- errorDescription,
714
- loadingLabel
715
- },
716
- hasChartData(data, chartSeries),
717
- cn("h-[320px] w-full", stateClassName)
718
- );
719
- if (chartState) {
720
- return chartState;
721
- }
722
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.LineChart, { data, accessibilityLayer: true, children: [
723
- showGrid ? /* @__PURE__ */ jsx(
724
- RechartsPrimitive.CartesianGrid,
725
- {
726
- vertical: false,
727
- strokeDasharray: "3 3",
728
- stroke: "var(--border)",
729
- strokeOpacity: 0.5
730
- }
731
- ) : null,
732
- /* @__PURE__ */ jsx(
733
- RechartsPrimitive.XAxis,
734
- {
735
- dataKey: indexKey,
736
- tickLine: false,
737
- axisLine: false,
738
- tickMargin: 8
739
- }
740
- ),
741
- /* @__PURE__ */ jsx(
742
- RechartsPrimitive.YAxis,
743
- {
744
- tickLine: false,
745
- axisLine: false,
746
- tickMargin: 8,
747
- tickFormatter: valueFormatter
748
- }
749
- ),
750
- /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { indicator: "line" }) }),
751
- showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
752
- chartSeries.map((item) => /* @__PURE__ */ jsx(
753
- RechartsPrimitive.Line,
754
- {
755
- type: curveType,
756
- dataKey: item.key,
757
- stroke: `var(--color-${item.key})`,
758
- strokeWidth,
759
- dot: showDots ? { r: 3, fill: `var(--color-${item.key})`, strokeWidth: 0 } : false,
760
- activeDot: { r: 5, strokeWidth: 0 },
761
- yAxisId: item.yAxisId,
762
- isAnimationActive: true,
763
- animationDuration: 600,
764
- animationEasing: "ease-out"
765
- },
766
- item.key
767
- ))
768
- ] }) });
769
- }
770
- function HorizontalBarChart({
771
- data,
772
- config,
773
- indexKey = "name",
774
- series,
775
- colors,
776
- barSize = "md",
777
- stacked = false,
778
- categoryWidth = 96,
779
- showGrid = true,
780
- showLegend = true,
781
- valueFormatter = formatTick,
782
- isLoading,
783
- error,
784
- onRetry,
785
- retryLabel,
786
- emptyTitle,
787
- emptyDescription,
788
- errorTitle,
789
- errorDescription,
790
- loadingLabel,
791
- stateClassName,
792
- className,
793
- ...props
794
- }) {
795
- const chartSeries = getChartSeries(config, series);
796
- const chartConfig = getChartConfigWithColors(
797
- config,
798
- chartSeries.map((item) => item.key),
799
- colors
800
- );
801
- const chartState = getChartState(
802
- {
803
- isLoading,
804
- error,
805
- onRetry,
806
- retryLabel,
807
- emptyTitle,
808
- emptyDescription,
809
- errorTitle,
810
- errorDescription,
811
- loadingLabel
812
- },
813
- hasChartData(data, chartSeries),
814
- cn("h-[320px] w-full", stateClassName)
815
- );
816
- if (chartState) {
817
- return chartState;
818
- }
819
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(
820
- RechartsPrimitive.BarChart,
821
- {
822
- data,
823
- layout: "vertical",
824
- accessibilityLayer: true,
825
- margin: { left: 8, right: 16 },
826
- children: [
827
- showGrid ? /* @__PURE__ */ jsx(
828
- RechartsPrimitive.CartesianGrid,
829
- {
830
- horizontal: false,
831
- strokeDasharray: "3 3",
832
- stroke: "var(--border)",
833
- strokeOpacity: 0.5
834
- }
835
- ) : null,
836
- /* @__PURE__ */ jsx(
837
- RechartsPrimitive.XAxis,
838
- {
839
- type: "number",
840
- tickLine: false,
841
- axisLine: false,
842
- tickMargin: 8,
843
- tickFormatter: valueFormatter
844
- }
845
- ),
846
- /* @__PURE__ */ jsx(
847
- RechartsPrimitive.YAxis,
848
- {
849
- dataKey: indexKey,
850
- type: "category",
851
- tickLine: false,
852
- axisLine: false,
853
- tickMargin: 8,
854
- width: categoryWidth
855
- }
856
- ),
857
- /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
858
- showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
859
- chartSeries.map((item) => /* @__PURE__ */ jsx(
860
- RechartsPrimitive.Bar,
861
- {
862
- dataKey: item.key,
863
- fill: `var(--color-${item.key})`,
864
- radius: [0, 4, 4, 0],
865
- barSize: getBarSize(barSize),
866
- stackId: stacked ? item.stackId || "total" : item.stackId,
867
- isAnimationActive: true,
868
- animationDuration: 600,
869
- animationEasing: "ease-out"
870
- },
871
- item.key
872
- ))
873
- ]
874
- }
875
- ) });
876
- }
877
- function InteractiveTimeSeriesChart({
878
- data,
879
- config,
880
- indexKey = "date",
881
- series,
882
- colors,
883
- periods = defaultPeriods,
884
- defaultPeriod = ((_a) => (_a = periods[1]) == null ? void 0 : _a.value)() || ((_b) => (_b = periods[0]) == null ? void 0 : _b.value)() || "30d",
885
- defaultSeries,
886
- filterData = defaultFilterData,
887
- showGrid = true,
888
- showLegend = false,
889
- showDots = false,
890
- gradientFill = true,
891
- curveType = "monotone",
892
- strokeWidth = 2,
893
- valueFormatter = formatTick,
894
- isLoading,
895
- error,
896
- onRetry,
897
- retryLabel,
898
- emptyTitle,
899
- emptyDescription,
900
- errorTitle,
901
- errorDescription,
902
- loadingLabel,
903
- stateClassName,
904
- className,
905
- ...props
906
- }) {
907
- var _a2;
908
- const chartSeries = getChartSeries(config, series);
909
- const chartConfig = getChartConfigWithColors(
910
- config,
911
- chartSeries.map((item) => item.key),
912
- colors
913
- );
914
- const [period, setPeriod] = React.useState(defaultPeriod);
915
- const [activeSeries, setActiveSeries] = React.useState(
916
- defaultSeries || ((_a2 = chartSeries[0]) == null ? void 0 : _a2.key) || ""
917
- );
918
- const filteredData = React.useMemo(() => filterData(data, period), [data, filterData, period]);
919
- const visibleSeries = chartSeries.length > 1 ? chartSeries.filter((item) => item.key === activeSeries) : chartSeries;
920
- const chartState = getChartState(
921
- {
922
- isLoading,
923
- error,
924
- onRetry,
925
- retryLabel,
926
- emptyTitle,
927
- emptyDescription,
928
- errorTitle,
929
- errorDescription,
930
- loadingLabel
931
- },
932
- hasChartData(filteredData, visibleSeries),
933
- cn("h-[320px] w-full", stateClassName)
934
- );
935
- return /* @__PURE__ */ jsxs("div", { className: "w-full space-y-4", children: [
936
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
937
- chartSeries.length > 1 ? /* @__PURE__ */ jsx(
938
- "div",
939
- {
940
- className: "inline-flex h-10 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
941
- role: "group",
942
- "aria-label": "Selecionar metrica do grafico",
943
- children: chartSeries.map((item) => {
944
- var _a3;
945
- const label = item.label || ((_a3 = config[item.key]) == null ? void 0 : _a3.label) || item.key;
946
- return /* @__PURE__ */ jsx(
947
- Button,
948
- {
949
- type: "button",
950
- variant: "ghost",
951
- size: "sm",
952
- "aria-pressed": activeSeries === item.key,
953
- onClick: () => setActiveSeries(item.key),
954
- className: cn(
955
- "h-8 px-3 text-sm font-medium transition-all",
956
- activeSeries === item.key ? "bg-background text-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"
957
- ),
958
- children: label
959
- },
960
- item.key
961
- );
962
- })
963
- }
964
- ) : /* @__PURE__ */ jsx("div", {}),
965
- /* @__PURE__ */ jsxs(Select, { value: period, onValueChange: setPeriod, children: [
966
- /* @__PURE__ */ jsx(
967
- SelectTrigger,
968
- {
969
- className: "w-full sm:w-[160px]",
970
- size: "sm",
971
- "aria-label": "Selecionar periodo do grafico",
972
- children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Period" })
973
- }
974
- ),
975
- /* @__PURE__ */ jsx(SelectContent, { children: periods.map((item) => /* @__PURE__ */ jsx(SelectItem, { value: item.value, children: item.label }, item.value)) })
976
- ] })
977
- ] }),
978
- chartState || /* @__PURE__ */ jsx(
979
- ChartContainer,
980
- {
981
- config: chartConfig,
982
- className: cn("h-[320px] w-full", className),
983
- ...props,
984
- children: /* @__PURE__ */ jsxs(RechartsPrimitive.AreaChart, { data: filteredData, accessibilityLayer: true, children: [
985
- gradientFill && /* @__PURE__ */ jsx(AreaGradientDefs, { seriesKeys: visibleSeries.map((s) => s.key), opacity: 0.4 }),
986
- showGrid ? /* @__PURE__ */ jsx(
987
- RechartsPrimitive.CartesianGrid,
988
- {
989
- vertical: false,
990
- strokeDasharray: "3 3",
991
- stroke: "var(--border)",
992
- strokeOpacity: 0.5
993
- }
994
- ) : null,
995
- /* @__PURE__ */ jsx(
996
- RechartsPrimitive.XAxis,
997
- {
998
- dataKey: indexKey,
999
- tickLine: false,
1000
- axisLine: false,
1001
- tickMargin: 8
1002
- }
1003
- ),
1004
- /* @__PURE__ */ jsx(
1005
- RechartsPrimitive.YAxis,
1006
- {
1007
- tickLine: false,
1008
- axisLine: false,
1009
- tickMargin: 8,
1010
- tickFormatter: valueFormatter
1011
- }
1012
- ),
1013
- /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, { indicator: "line" }) }),
1014
- showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
1015
- visibleSeries.map((item) => /* @__PURE__ */ jsx(
1016
- RechartsPrimitive.Area,
1017
- {
1018
- type: curveType,
1019
- dataKey: item.key,
1020
- stroke: `var(--color-${item.key})`,
1021
- fill: gradientFill ? `url(#gradient-${item.key})` : `var(--color-${item.key})`,
1022
- fillOpacity: gradientFill ? 1 : 0.16,
1023
- strokeWidth,
1024
- dot: showDots ? { r: 3, fill: `var(--color-${item.key})`, strokeWidth: 0 } : false,
1025
- activeDot: { r: 5, strokeWidth: 0 },
1026
- isAnimationActive: true,
1027
- animationDuration: 600,
1028
- animationEasing: "ease-out"
1029
- },
1030
- item.key
1031
- ))
1032
- ] })
1033
- }
1034
- )
1035
- ] });
1036
- }
1037
- function ComboMetricChart({
1038
- data,
1039
- config,
1040
- indexKey = "name",
1041
- series,
1042
- colors,
1043
- barSize = "md",
1044
- showGrid = true,
1045
- showLegend = true,
1046
- gradientFill = false,
1047
- curveType = "monotone",
1048
- valueFormatter = formatTick,
1049
- isLoading,
1050
- error,
1051
- onRetry,
1052
- retryLabel,
1053
- emptyTitle,
1054
- emptyDescription,
1055
- errorTitle,
1056
- errorDescription,
1057
- loadingLabel,
1058
- stateClassName,
1059
- className,
1060
- ...props
1061
- }) {
1062
- const chartSeries = getChartSeries(config, series);
1063
- const chartConfig = getChartConfigWithColors(
1064
- config,
1065
- chartSeries.map((item) => item.key),
1066
- colors
1067
- );
1068
- const chartState = getChartState(
1069
- {
1070
- isLoading,
1071
- error,
1072
- onRetry,
1073
- retryLabel,
1074
- emptyTitle,
1075
- emptyDescription,
1076
- errorTitle,
1077
- errorDescription,
1078
- loadingLabel
1079
- },
1080
- hasChartData(data, chartSeries),
1081
- cn("h-[340px] w-full", stateClassName)
1082
- );
1083
- if (chartState) {
1084
- return chartState;
1085
- }
1086
- const areaSeries = gradientFill ? chartSeries.filter((s) => s.type === "area").map((s) => s.key) : [];
1087
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[340px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.ComposedChart, { data, accessibilityLayer: true, children: [
1088
- gradientFill && areaSeries.length > 0 && /* @__PURE__ */ jsx(AreaGradientDefs, { seriesKeys: areaSeries, opacity: 0.35 }),
1089
- showGrid ? /* @__PURE__ */ jsx(
1090
- RechartsPrimitive.CartesianGrid,
1091
- {
1092
- vertical: false,
1093
- strokeDasharray: "3 3",
1094
- stroke: "var(--border)",
1095
- strokeOpacity: 0.5
1096
- }
1097
- ) : null,
1098
- /* @__PURE__ */ jsx(
1099
- RechartsPrimitive.XAxis,
1100
- {
1101
- dataKey: indexKey,
1102
- tickLine: false,
1103
- axisLine: false,
1104
- tickMargin: 8
1105
- }
1106
- ),
1107
- /* @__PURE__ */ jsx(
1108
- RechartsPrimitive.YAxis,
1109
- {
1110
- tickLine: false,
1111
- axisLine: false,
1112
- tickMargin: 8,
1113
- tickFormatter: valueFormatter
1114
- }
1115
- ),
1116
- /* @__PURE__ */ jsx(ChartTooltip, { content: /* @__PURE__ */ jsx(ChartTooltipContent, {}) }),
1117
- showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }) : null,
1118
- chartSeries.map(
1119
- (item) => item.type === "line" ? /* @__PURE__ */ jsx(
1120
- RechartsPrimitive.Line,
1121
- {
1122
- type: curveType,
1123
- dataKey: item.key,
1124
- stroke: `var(--color-${item.key})`,
1125
- strokeWidth: 2,
1126
- dot: false,
1127
- activeDot: { r: 5, strokeWidth: 0 },
1128
- yAxisId: item.yAxisId,
1129
- isAnimationActive: true,
1130
- animationDuration: 600,
1131
- animationEasing: "ease-out"
1132
- },
1133
- item.key
1134
- ) : item.type === "area" ? /* @__PURE__ */ jsx(
1135
- RechartsPrimitive.Area,
1136
- {
1137
- type: curveType,
1138
- dataKey: item.key,
1139
- stroke: `var(--color-${item.key})`,
1140
- fill: gradientFill ? `url(#gradient-${item.key})` : `var(--color-${item.key})`,
1141
- fillOpacity: gradientFill ? 1 : 0.12,
1142
- strokeWidth: 2,
1143
- dot: false,
1144
- activeDot: { r: 5, strokeWidth: 0 },
1145
- yAxisId: item.yAxisId,
1146
- isAnimationActive: true,
1147
- animationDuration: 600,
1148
- animationEasing: "ease-out"
1149
- },
1150
- item.key
1151
- ) : /* @__PURE__ */ jsx(
1152
- RechartsPrimitive.Bar,
1153
- {
1154
- dataKey: item.key,
1155
- fill: `var(--color-${item.key})`,
1156
- radius: [4, 4, 0, 0],
1157
- barSize: getBarSize(barSize),
1158
- yAxisId: item.yAxisId,
1159
- isAnimationActive: true,
1160
- animationDuration: 600,
1161
- animationEasing: "ease-out"
1162
- },
1163
- item.key
1164
- )
1165
- )
1166
- ] }) });
1167
- }
1168
- function DonutBreakdownChart({
1169
- data,
1170
- config,
1171
- nameKey = "name",
1172
- valueKey = "value",
1173
- colors,
1174
- centerLabel,
1175
- centerValue,
1176
- showLegend = true,
1177
- innerRadius = "58%",
1178
- outerRadius = "82%",
1179
- isLoading,
1180
- error,
1181
- onRetry,
1182
- retryLabel,
1183
- emptyTitle,
1184
- emptyDescription,
1185
- errorTitle,
1186
- errorDescription,
1187
- loadingLabel,
1188
- stateClassName,
1189
- className,
1190
- ...props
1191
- }) {
1192
- const [activeIndex, setActiveIndex] = React.useState(0);
1193
- const chartKeys = data.map((entry, index) => String(entry[nameKey] || `segment-${index}`));
1194
- const chartConfig = getChartConfigWithColors(config, chartKeys, colors);
1195
- const chartState = getChartState(
1196
- {
1197
- isLoading,
1198
- error,
1199
- onRetry,
1200
- retryLabel,
1201
- emptyTitle,
1202
- emptyDescription,
1203
- errorTitle,
1204
- errorDescription,
1205
- loadingLabel
1206
- },
1207
- hasPieData(data, nameKey, valueKey),
1208
- cn("h-[320px] w-full", stateClassName)
1209
- );
1210
- if (chartState) {
1211
- return chartState;
1212
- }
1213
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[320px] w-full", className), ...props, children: /* @__PURE__ */ jsxs(RechartsPrimitive.PieChart, { accessibilityLayer: true, children: [
1214
- /* @__PURE__ */ jsx(
1215
- ChartTooltip,
1216
- {
1217
- cursor: false,
1218
- content: /* @__PURE__ */ jsx(ChartTooltipContent, { hideLabel: true, nameKey })
1219
- }
1220
- ),
1221
- showLegend ? /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, { nameKey }), verticalAlign: "bottom" }) : null,
1222
- /* @__PURE__ */ jsxs(
1223
- RechartsPrimitive.Pie,
1224
- {
1225
- data,
1226
- dataKey: valueKey,
1227
- nameKey,
1228
- innerRadius,
1229
- outerRadius,
1230
- paddingAngle: 3,
1231
- activeIndex,
1232
- onMouseEnter: (_, index) => setActiveIndex(index),
1233
- isAnimationActive: true,
1234
- animationDuration: 600,
1235
- animationEasing: "ease-out",
1236
- children: [
1237
- data.map((entry, index) => {
1238
- const key = String(entry[nameKey] || `segment-${index}`);
1239
- return /* @__PURE__ */ jsx(
1240
- RechartsPrimitive.Cell,
1241
- {
1242
- fill: `var(--color-${key})`,
1243
- opacity: index === activeIndex ? 1 : 0.7,
1244
- stroke: "transparent"
1245
- },
1246
- key
1247
- );
1248
- }),
1249
- centerValue || centerLabel ? /* @__PURE__ */ jsx(
1250
- RechartsPrimitive.Label,
1251
- {
1252
- position: "center",
1253
- content: ({ viewBox }) => {
1254
- if (!viewBox || !("cx" in viewBox) || !("cy" in viewBox)) {
1255
- return null;
1256
- }
1257
- return /* @__PURE__ */ jsxs("text", { x: viewBox.cx, y: viewBox.cy, textAnchor: "middle", dominantBaseline: "middle", children: [
1258
- centerValue ? /* @__PURE__ */ jsx(
1259
- "tspan",
1260
- {
1261
- x: viewBox.cx,
1262
- y: viewBox.cy,
1263
- className: "fill-foreground text-2xl font-semibold",
1264
- children: centerValue
1265
- }
1266
- ) : null,
1267
- centerLabel ? /* @__PURE__ */ jsx(
1268
- "tspan",
1269
- {
1270
- x: viewBox.cx,
1271
- y: Number(viewBox.cy) + 22,
1272
- className: "fill-muted-foreground text-xs",
1273
- children: centerLabel
1274
- }
1275
- ) : null
1276
- ] });
1277
- }
1278
- }
1279
- ) : null
1280
- ]
1281
- }
1282
- )
1283
- ] }) });
1284
- }
1285
- function SparklineChart({
1286
- data,
1287
- dataKey,
1288
- color = "var(--chart-1)",
1289
- filled = true,
1290
- showEndDot = true,
1291
- curveType = "monotone",
1292
- strokeWidth = 2,
1293
- className
1294
- }) {
1295
- const sparkId = React.useId().replace(/:/g, "");
1296
- const lastPoint = data[data.length - 1];
1297
- const lastValue = lastPoint ? lastPoint[dataKey] : void 0;
1298
- return /* @__PURE__ */ jsxs("div", { className: cn("relative h-12 w-full min-w-0", className), children: [
1299
- /* @__PURE__ */ jsx(RechartsPrimitive.ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
1300
- RechartsPrimitive.AreaChart,
1301
- {
1302
- data,
1303
- margin: { top: 4, right: showEndDot ? 8 : 0, bottom: 0, left: 0 },
1304
- children: [
1305
- filled && /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsxs("linearGradient", { id: `spark-gradient-${sparkId}`, x1: "0", y1: "0", x2: "0", y2: "1", children: [
1306
- /* @__PURE__ */ jsx("stop", { offset: "5%", stopColor: color, stopOpacity: 0.3 }),
1307
- /* @__PURE__ */ jsx("stop", { offset: "95%", stopColor: color, stopOpacity: 0 })
1308
- ] }) }),
1309
- /* @__PURE__ */ jsx(
1310
- RechartsPrimitive.Area,
1311
- {
1312
- type: curveType,
1313
- dataKey,
1314
- stroke: color,
1315
- strokeWidth,
1316
- fill: filled ? `url(#spark-gradient-${sparkId})` : "none",
1317
- fillOpacity: 1,
1318
- dot: false,
1319
- activeDot: false,
1320
- isAnimationActive: true,
1321
- animationDuration: 600,
1322
- animationEasing: "ease-out"
1323
- }
1324
- )
1325
- ]
1326
- }
1327
- ) }),
1328
- showEndDot && lastValue !== void 0 && lastValue !== null && /* @__PURE__ */ jsx(
1329
- "div",
1330
- {
1331
- className: "pointer-events-none absolute right-0 top-1/2 h-2.5 w-2.5 -translate-y-1/2 rounded-full ring-2 ring-background",
1332
- style: { backgroundColor: color }
1333
- }
1334
- )
1335
- ] });
1336
- }
1337
- function RadarMetricChart({
1338
- data,
1339
- labelKey,
1340
- series,
1341
- colors,
1342
- filled = true,
1343
- fillOpacity = 0.25,
1344
- showDots = false,
1345
- showGrid = true,
1346
- showLegend,
1347
- valueFormatter,
1348
- isLoading,
1349
- error,
1350
- onRetry,
1351
- retryLabel,
1352
- emptyTitle,
1353
- emptyDescription,
1354
- errorTitle,
1355
- errorDescription,
1356
- loadingLabel,
1357
- stateClassName,
1358
- className
1359
- }) {
1360
- const chartConfig = React.useMemo(
1361
- () => buildChartConfig(
1362
- series.map((s) => s.key),
1363
- colors
1364
- ),
1365
- [series, colors]
1366
- );
1367
- const hasData = data.length > 0 && series.length > 0;
1368
- const chartState = getChartState(
1369
- {
1370
- isLoading,
1371
- error,
1372
- emptyTitle,
1373
- emptyDescription,
1374
- errorTitle,
1375
- errorDescription,
1376
- loadingLabel,
1377
- stateClassName,
1378
- onRetry,
1379
- retryLabel
1380
- },
1381
- hasData
1382
- );
1383
- const displayLegend = showLegend ?? series.length > 1;
1384
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[300px] w-full", className), children: chartState ?? /* @__PURE__ */ jsxs(RechartsPrimitive.RadarChart, { data, accessibilityLayer: true, children: [
1385
- showGrid && /* @__PURE__ */ jsx(RechartsPrimitive.PolarGrid, { stroke: "var(--border)", strokeOpacity: 0.6 }),
1386
- /* @__PURE__ */ jsx(
1387
- RechartsPrimitive.PolarAngleAxis,
1388
- {
1389
- dataKey: labelKey,
1390
- tick: { fill: "var(--muted-foreground)", fontSize: 12 }
1391
- }
1392
- ),
1393
- /* @__PURE__ */ jsx(
1394
- RechartsPrimitive.PolarRadiusAxis,
1395
- {
1396
- tick: false,
1397
- axisLine: false,
1398
- tickFormatter: valueFormatter
1399
- }
1400
- ),
1401
- /* @__PURE__ */ jsx(
1402
- ChartTooltip,
1403
- {
1404
- content: /* @__PURE__ */ jsx(
1405
- ChartTooltipContent,
1406
- {
1407
- formatter: valueFormatter ? (v) => valueFormatter(v) : void 0
1408
- }
1409
- )
1410
- }
1411
- ),
1412
- displayLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, {}) }),
1413
- series.map((s) => /* @__PURE__ */ jsx(
1414
- RechartsPrimitive.Radar,
1415
- {
1416
- name: s.label ?? s.key,
1417
- dataKey: s.key,
1418
- stroke: `var(--color-${s.key})`,
1419
- fill: filled ? `var(--color-${s.key})` : "none",
1420
- fillOpacity: filled ? fillOpacity : 0,
1421
- dot: showDots ? { r: 3, fill: `var(--color-${s.key})` } : false,
1422
- isAnimationActive: true,
1423
- animationDuration: 600,
1424
- animationEasing: "ease-out"
1425
- },
1426
- s.key
1427
- ))
1428
- ] }) });
1429
- }
1430
- function PieMetricChart({
1431
- data,
1432
- nameKey,
1433
- valueKey,
1434
- colors,
1435
- outerRadius = "80%",
1436
- innerRadius = 0,
1437
- showLabels = false,
1438
- showLegend = true,
1439
- explodeIndex,
1440
- explodeOffset = 12,
1441
- valueFormatter,
1442
- isLoading,
1443
- error,
1444
- onRetry,
1445
- retryLabel,
1446
- emptyTitle,
1447
- emptyDescription,
1448
- errorTitle,
1449
- errorDescription,
1450
- loadingLabel,
1451
- stateClassName,
1452
- className
1453
- }) {
1454
- const names = React.useMemo(() => data.map((d) => String(d[nameKey] ?? "")), [data, nameKey]);
1455
- const chartConfig = React.useMemo(() => buildChartConfig(names, colors), [names, colors]);
1456
- const hasData = hasPieData(data, nameKey, valueKey);
1457
- const chartState = getChartState(
1458
- {
1459
- isLoading,
1460
- error,
1461
- emptyTitle,
1462
- emptyDescription,
1463
- errorTitle,
1464
- errorDescription,
1465
- loadingLabel,
1466
- stateClassName,
1467
- onRetry,
1468
- retryLabel
1469
- },
1470
- hasData
1471
- );
1472
- return /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: cn("h-[300px] w-full", className), children: chartState ?? /* @__PURE__ */ jsxs(RechartsPrimitive.PieChart, { accessibilityLayer: true, children: [
1473
- /* @__PURE__ */ jsx(
1474
- ChartTooltip,
1475
- {
1476
- content: /* @__PURE__ */ jsx(
1477
- ChartTooltipContent,
1478
- {
1479
- nameKey,
1480
- formatter: valueFormatter ? (v) => valueFormatter(v) : void 0
1481
- }
1482
- )
1483
- }
1484
- ),
1485
- showLegend && /* @__PURE__ */ jsx(ChartLegend, { content: /* @__PURE__ */ jsx(ChartLegendContent, { nameKey }) }),
1486
- /* @__PURE__ */ jsx(
1487
- RechartsPrimitive.Pie,
1488
- {
1489
- data,
1490
- dataKey: valueKey,
1491
- nameKey,
1492
- outerRadius,
1493
- innerRadius,
1494
- paddingAngle: 2,
1495
- label: showLabels ? ({ cx, cy, midAngle, innerRadius: ir, outerRadius: or, percent }) => {
1496
- const RADIAN = Math.PI / 180;
1497
- const radius = Number(ir) + (Number(or) - Number(ir)) * 1.35;
1498
- const x = Number(cx) + radius * Math.cos(-midAngle * RADIAN);
1499
- const y = Number(cy) + radius * Math.sin(-midAngle * RADIAN);
1500
- return percent > 0.04 ? /* @__PURE__ */ jsx(
1501
- "text",
1502
- {
1503
- x,
1504
- y,
1505
- fill: "var(--foreground)",
1506
- textAnchor: x > Number(cx) ? "start" : "end",
1507
- dominantBaseline: "central",
1508
- fontSize: 12,
1509
- fontWeight: 500,
1510
- children: `${(percent * 100).toFixed(0)}%`
1511
- }
1512
- ) : null;
1513
- } : false,
1514
- labelLine: false,
1515
- isAnimationActive: true,
1516
- animationDuration: 600,
1517
- animationEasing: "ease-out",
1518
- children: data.map((entry, index) => {
1519
- var _a, _b;
1520
- const name = String(entry[nameKey] ?? "");
1521
- const isExploded = index === explodeIndex;
1522
- return /* @__PURE__ */ jsx(
1523
- RechartsPrimitive.Cell,
1524
- {
1525
- fill: ((_a = chartConfig[name]) == null ? void 0 : _a.color) ?? `var(--chart-${index % 8 + 1})`,
1526
- stroke: "var(--background)",
1527
- strokeWidth: 2,
1528
- style: isExploded ? {
1529
- filter: `drop-shadow(0 4px 8px color-mix(in srgb, ${((_b = chartConfig[name]) == null ? void 0 : _b.color) ?? "var(--chart-1)"} 40%, transparent))`
1530
- } : void 0
1531
- },
1532
- `cell-${index}`
1533
- );
1534
- })
1535
- }
1536
- )
1537
- ] }) });
1538
- }
1539
- function RadialBarMetricChart({
1540
- data,
1541
- dataKey = "value",
1542
- nameKey = "name",
1543
- colors,
1544
- innerRadius = "30%",
1545
- outerRadius = "100%",
1546
- startAngle = 90,
1547
- endAngle = -270,
1548
- showBackground = true,
1549
- showLegend = true,
1550
- valueFormatter,
1551
- isLoading,
1552
- error,
1553
- onRetry,
1554
- retryLabel,
1555
- emptyTitle,
1556
- emptyDescription,
1557
- errorTitle,
1558
- errorDescription,
1559
- loadingLabel,
1560
- stateClassName,
1561
- className
1562
- }) {
1563
- const names = React.useMemo(() => data.map((d) => String(d[nameKey] ?? "")), [data, nameKey]);
1564
- const chartConfig = React.useMemo(() => buildChartConfig(names, colors), [names, colors]);
1565
- const hasData = data.length > 0;
1566
- const chartState = getChartState(
1567
- {
1568
- isLoading,
1569
- error,
1570
- emptyTitle,
1571
- emptyDescription,
1572
- errorTitle,
1573
- errorDescription,
1574
- loadingLabel,
1575
- stateClassName,
1576
- onRetry,
1577
- retryLabel
1578
- },
1579
- hasData
1580
- );
1581
- const coloredData = React.useMemo(
1582
- () => data.map((item, index) => {
1583
- var _a;
1584
- const name = String(item[nameKey] ?? "");
1585
- return {
1586
- ...item,
1587
- fill: ((_a = chartConfig[name]) == null ? void 0 : _a.color) ?? `var(--chart-${index % 8 + 1})`
1588
- };
1589
- }),
1590
- [data, nameKey, chartConfig]
1591
- );
1592
- return /* @__PURE__ */ jsxs("div", { className: cn("flex w-full flex-col gap-3", className), children: [
1593
- /* @__PURE__ */ jsx(ChartContainer, { config: chartConfig, className: "h-[260px] w-full", children: chartState ?? /* @__PURE__ */ jsxs(
1594
- RechartsPrimitive.RadialBarChart,
1595
- {
1596
- data: coloredData,
1597
- innerRadius,
1598
- outerRadius,
1599
- startAngle,
1600
- endAngle,
1601
- accessibilityLayer: true,
1602
- children: [
1603
- /* @__PURE__ */ jsx(
1604
- ChartTooltip,
1605
- {
1606
- cursor: false,
1607
- content: /* @__PURE__ */ jsx(
1608
- ChartTooltipContent,
1609
- {
1610
- nameKey,
1611
- formatter: valueFormatter ? (v) => valueFormatter(v) : void 0
1612
- }
1613
- )
1614
- }
1615
- ),
1616
- /* @__PURE__ */ jsx(
1617
- RechartsPrimitive.RadialBar,
1618
- {
1619
- dataKey,
1620
- background: showBackground ? { fill: "var(--muted)" } : false,
1621
- cornerRadius: 6,
1622
- isAnimationActive: true,
1623
- animationDuration: 700,
1624
- animationEasing: "ease-out"
1625
- }
1626
- )
1627
- ]
1628
- }
1629
- ) }),
1630
- showLegend && !chartState && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-x-4 gap-y-1.5 px-2", children: coloredData.map((item, index) => {
1631
- const d = item;
1632
- const name = String(d[nameKey] ?? "");
1633
- const fillColor = d.fill ?? `var(--chart-${index % 8 + 1})`;
1634
- const val = d[dataKey];
1635
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1636
- /* @__PURE__ */ jsx(
1637
- "span",
1638
- {
1639
- className: "inline-block h-2.5 w-2.5 shrink-0 rounded-full",
1640
- style: { backgroundColor: fillColor }
1641
- }
1642
- ),
1643
- /* @__PURE__ */ jsxs("span", { className: "text-xs text-muted-foreground", children: [
1644
- name,
1645
- val !== void 0 && val !== null && /* @__PURE__ */ jsx("span", { className: "ml-1 font-medium text-foreground", children: valueFormatter ? valueFormatter(val) : String(val) })
1646
- ] })
1647
- ] }, name);
1648
- }) })
1649
- ] });
1650
- }
1651
- function GaugeChart({
1652
- value,
1653
- min = 0,
1654
- max = 100,
1655
- thresholds,
1656
- label,
1657
- valueFormatter,
1658
- showNeedle = true,
1659
- className
1660
- }) {
1661
- const percent = Math.min(1, Math.max(0, (value - min) / (max - min)));
1662
- const percentInt = Math.round(percent * 100);
1663
- const activeColor = React.useMemo(() => {
1664
- if (!thresholds || thresholds.length === 0) return "var(--chart-1)";
1665
- for (const t of thresholds) {
1666
- if (percentInt <= t.value) return t.color;
1667
- }
1668
- return thresholds[thresholds.length - 1].color;
1669
- }, [thresholds, percentInt]);
1670
- const displayText = valueFormatter ? valueFormatter(value, percentInt) : `${percentInt}%`;
1671
- const cx = 100;
1672
- const cy = 100;
1673
- const R = 80;
1674
- const r = 54;
1675
- const polar = (angleDeg, radius) => {
1676
- const rad = angleDeg * Math.PI / 180;
1677
- return {
1678
- x: cx + radius * Math.cos(rad),
1679
- y: cy - radius * Math.sin(rad)
1680
- };
1681
- };
1682
- const trackStart = polar(180, R);
1683
- const trackEnd = polar(0, R);
1684
- const trackStartI = polar(180, r);
1685
- const trackEndI = polar(0, r);
1686
- const trackPath = [
1687
- `M ${trackStart.x} ${trackStart.y}`,
1688
- `A ${R} ${R} 0 0 1 ${trackEnd.x} ${trackEnd.y}`,
1689
- `L ${trackEndI.x} ${trackEndI.y}`,
1690
- `A ${r} ${r} 0 0 0 ${trackStartI.x} ${trackStartI.y}`,
1691
- "Z"
1692
- ].join(" ");
1693
- const valueAngle = 180 - percent * 180;
1694
- const valueEnd = polar(valueAngle, R);
1695
- const valueEndI = polar(valueAngle, r);
1696
- const valuePath = percent <= 0 ? "" : percent >= 1 ? trackPath : [
1697
- `M ${trackStart.x} ${trackStart.y}`,
1698
- `A ${R} ${R} 0 0 1 ${valueEnd.x} ${valueEnd.y}`,
1699
- `L ${valueEndI.x} ${valueEndI.y}`,
1700
- `A ${r} ${r} 0 0 0 ${trackStartI.x} ${trackStartI.y}`,
1701
- "Z"
1702
- ].join(" ");
1703
- const needleAngle = 180 - percent * 180;
1704
- const needleTip = polar(needleAngle, r - 6);
1705
- const needleBase1 = polar(needleAngle + 90, 5);
1706
- const needleBase2 = polar(needleAngle - 90, 5);
1707
- return /* @__PURE__ */ jsxs("div", { className: cn("flex flex-col items-center gap-2", className), children: [
1708
- /* @__PURE__ */ jsx("div", { className: "relative w-full max-w-[260px]", children: /* @__PURE__ */ jsxs("svg", { viewBox: "0 0 200 130", className: "w-full", "aria-label": `Gauge: ${displayText}`, children: [
1709
- /* @__PURE__ */ jsx("path", { d: trackPath, fill: "var(--muted)" }),
1710
- valuePath && /* @__PURE__ */ jsx("path", { d: valuePath, fill: activeColor }),
1711
- showNeedle && /* @__PURE__ */ jsxs("g", { children: [
1712
- /* @__PURE__ */ jsx(
1713
- "polygon",
1714
- {
1715
- points: `${needleTip.x},${needleTip.y} ${needleBase1.x},${needleBase1.y} ${needleBase2.x},${needleBase2.y}`,
1716
- fill: "var(--foreground)",
1717
- opacity: 0.85
1718
- }
1719
- ),
1720
- /* @__PURE__ */ jsx("circle", { cx, cy, r: 5, fill: "var(--foreground)" })
1721
- ] }),
1722
- /* @__PURE__ */ jsx(
1723
- "text",
1724
- {
1725
- x: cx,
1726
- y: cy + 18,
1727
- textAnchor: "middle",
1728
- dominantBaseline: "middle",
1729
- fontSize: 22,
1730
- fontWeight: 700,
1731
- fill: "currentColor",
1732
- className: "fill-foreground",
1733
- children: displayText
1734
- }
1735
- ),
1736
- label && /* @__PURE__ */ jsx(
1737
- "text",
1738
- {
1739
- x: cx,
1740
- y: cy + 36,
1741
- textAnchor: "middle",
1742
- dominantBaseline: "middle",
1743
- fontSize: 10,
1744
- fill: "currentColor",
1745
- className: "fill-muted-foreground",
1746
- children: label
1747
- }
1748
- )
1749
- ] }) }),
1750
- thresholds && thresholds.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap justify-center gap-x-3 gap-y-1", children: thresholds.map((t, i) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
1751
- /* @__PURE__ */ jsx(
1752
- "span",
1753
- {
1754
- className: "inline-block h-2 w-2 shrink-0 rounded-full",
1755
- style: { backgroundColor: t.color }
1756
- }
1757
- ),
1758
- /* @__PURE__ */ jsx("span", { className: "text-xs text-muted-foreground", children: t.label })
1759
- ] }, i)) })
1760
- ] });
1761
- }
1762
- function Table({ className, ...props }) {
1763
- return /* @__PURE__ */ jsx("div", { "data-slot": "table-container", className: "relative w-full overflow-x-auto", children: /* @__PURE__ */ jsx(
1764
- "table",
1765
- {
1766
- "data-slot": "table",
1767
- className: cn("w-full caption-bottom text-sm", className),
1768
- ...props
1769
- }
1770
- ) });
1771
- }
1772
- function TableHeader({ className, ...props }) {
1773
- return /* @__PURE__ */ jsx("thead", { "data-slot": "table-header", className: cn("[&_tr]:border-b", className), ...props });
1774
- }
1775
- function TableBody({ className, ...props }) {
1776
- return /* @__PURE__ */ jsx(
1777
- "tbody",
1778
- {
1779
- "data-slot": "table-body",
1780
- className: cn("[&_tr:last-child]:border-0", className),
1781
- ...props
1782
- }
1783
- );
1784
- }
1785
- function TableFooter({ className, ...props }) {
1786
- return /* @__PURE__ */ jsx(
1787
- "tfoot",
1788
- {
1789
- "data-slot": "table-footer",
1790
- className: cn("bg-muted/50 border-t font-medium [&>tr]:last:border-b-0", className),
1791
- ...props
1792
- }
1793
- );
1794
- }
1795
- function TableRow({ className, ...props }) {
1796
- return /* @__PURE__ */ jsx(
1797
- "tr",
1798
- {
1799
- "data-slot": "table-row",
1800
- className: cn(
1801
- "hover:bg-muted/50 data-[state=selected]:bg-muted border-b transition-colors",
1802
- className
1803
- ),
1804
- ...props
1805
- }
1806
- );
1807
- }
1808
- function TableHead({ className, ...props }) {
1809
- return /* @__PURE__ */ jsx(
1810
- "th",
1811
- {
1812
- "data-slot": "table-head",
1813
- className: cn(
1814
- "text-foreground h-10 px-2 text-left align-middle font-medium whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1815
- className
1816
- ),
1817
- ...props
1818
- }
1819
- );
1820
- }
1821
- function TableCell({ className, ...props }) {
1822
- return /* @__PURE__ */ jsx(
1823
- "td",
1824
- {
1825
- "data-slot": "table-cell",
1826
- className: cn(
1827
- "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-[2px]",
1828
- className
1829
- ),
1830
- ...props
1831
- }
1832
- );
1833
- }
1834
- function TableCaption({ className, ...props }) {
1835
- return /* @__PURE__ */ jsx(
1836
- "caption",
1837
- {
1838
- "data-slot": "table-caption",
1839
- className: cn("text-muted-foreground mt-4 text-sm", className),
1840
- ...props
1841
- }
1842
- );
1843
- }
1844
- const Textarea = React.forwardRef(
1845
- ({ className, size = "md", ...props }, ref) => {
1846
- const sizeClasses = {
1847
- sm: "px-2 py-1 text-sm",
1848
- md: "px-3 py-2 text-base",
1849
- lg: "px-4 py-3 text-base"
1850
- };
1851
- return /* @__PURE__ */ jsx(
1852
- "textarea",
1853
- {
1854
- "data-slot": "textarea",
1855
- className: cn(
1856
- "flex min-h-16 w-full bg-background rounded-[var(--radius)] border border-border transition-colors outline-none resize-none text-foreground",
1857
- "placeholder:text-muted-foreground",
1858
- "focus:ring-2 focus:ring-primary focus:border-transparent",
1859
- "disabled:cursor-not-allowed disabled:opacity-50",
1860
- sizeClasses[size],
1861
- className
1862
- ),
1863
- ref,
1864
- ...props
1865
- }
1866
- );
1867
- }
1868
- );
1869
- Textarea.displayName = "Textarea";
1870
- function Dialog({ ...props }) {
1871
- return /* @__PURE__ */ jsx(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
1872
- }
1873
- function DialogTrigger({ ...props }) {
1874
- return /* @__PURE__ */ jsx(DialogPrimitive.Trigger, { "data-slot": "dialog-trigger", ...props });
1875
- }
1876
- function DialogPortal({ ...props }) {
1877
- return /* @__PURE__ */ jsx(DialogPrimitive.Portal, { "data-slot": "dialog-portal", ...props });
1878
- }
1879
- function DialogClose({ ...props }) {
1880
- return /* @__PURE__ */ jsx(DialogPrimitive.Close, { "data-slot": "dialog-close", ...props });
1881
- }
1882
- const DialogOverlay = React.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsx(
1883
- DialogPrimitive.Overlay,
1884
- {
1885
- ref,
1886
- "data-slot": "dialog-overlay",
1887
- className: cn(
1888
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/40 backdrop-blur-sm",
1889
- className
1890
- ),
1891
- ...props
1892
- }
1893
- ));
1894
- DialogOverlay.displayName = DialogPrimitive.Overlay.displayName;
1895
- const dialogVariants = cva(
1896
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 flex flex-col w-full translate-x-[-50%] translate-y-[-50%] border shadow-elevation-sm duration-200 rounded-[var(--radius-card)] overflow-hidden max-h-[calc(100dvh-2rem)]",
1897
- {
1898
- variants: {
1899
- size: {
1900
- sm: "max-w-sm",
1901
- md: "max-w-md",
1902
- lg: "max-w-lg",
1903
- xl: "max-w-xl",
1904
- "2xl": "max-w-2xl",
1905
- "3xl": "max-w-3xl",
1906
- "4xl": "max-w-4xl",
1907
- "5xl": "max-w-5xl",
1908
- full: "max-w-[calc(100vw-2rem)] h-[calc(100dvh-2rem)]"
1909
- }
1910
- },
1911
- defaultVariants: {
1912
- size: "lg"
1913
- }
1914
- }
1915
- );
1916
- const DialogContent = React.forwardRef(({ className, children, size, showClose = true, ...props }, ref) => /* @__PURE__ */ jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
1917
- /* @__PURE__ */ jsx(DialogOverlay, {}),
1918
- /* @__PURE__ */ jsxs(
1919
- DialogPrimitive.Content,
1920
- {
1921
- ref,
1922
- "data-slot": "dialog-content",
1923
- className: cn(dialogVariants({ size }), className),
1924
- ...props,
1925
- children: [
1926
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-4 p-6 overflow-y-auto flex-1 min-h-0", children }),
1927
- showClose && /* @__PURE__ */ jsxs(DialogPrimitive.Close, { className: "absolute top-4 right-4 z-10 rounded-full p-2 opacity-70 transition-all hover:opacity-100 hover:bg-accent focus:ring-2 focus:ring-primary focus:ring-offset-2 focus:outline-none disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", children: [
1928
- /* @__PURE__ */ jsx(XIcon, {}),
1929
- /* @__PURE__ */ jsx("span", { className: "sr-only", children: "Close" })
1930
- ] })
1931
- ]
1932
- }
1933
- )
1934
- ] }));
1935
- DialogContent.displayName = DialogPrimitive.Content.displayName;
1936
- function DialogHeader({ className, ...props }) {
1937
- return /* @__PURE__ */ jsx(
1938
- "div",
1939
- {
1940
- "data-slot": "dialog-header",
1941
- className: cn("flex flex-col gap-2 text-left shrink-0", className),
1942
- ...props
1943
- }
1944
- );
1945
- }
1946
- function DialogBody({ className, ...props }) {
1947
- return /* @__PURE__ */ jsx(
1948
- "div",
1949
- {
1950
- "data-slot": "dialog-body",
1951
- className: cn("flex-1 overflow-y-auto min-h-0 -mx-6 px-6", className),
1952
- ...props
1953
- }
1954
- );
1955
- }
1956
- function DialogFooter({ className, ...props }) {
1957
- return /* @__PURE__ */ jsx(
1958
- "div",
1959
- {
1960
- "data-slot": "dialog-footer",
1961
- className: cn("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end shrink-0", className),
1962
- ...props
1963
- }
1964
- );
1965
- }
1966
- function DialogTitle({ className, ...props }) {
1967
- return /* @__PURE__ */ jsx(
1968
- DialogPrimitive.Title,
1969
- {
1970
- "data-slot": "dialog-title",
1971
- className: cn(
1972
- "text-foreground font-semibold leading-tight text-[length:var(--text-h4)]",
1973
- className
1974
- ),
1975
- ...props
1976
- }
1977
- );
1978
- }
1979
- function DialogDescription({
1980
- className,
1981
- ...props
1982
- }) {
1983
- return /* @__PURE__ */ jsx(
1984
- DialogPrimitive.Description,
1985
- {
1986
- "data-slot": "dialog-description",
1987
- className: cn("text-muted-foreground", className),
1988
- ...props
1989
- }
1990
- );
1991
- }
1992
- function useRichTextEditor({
1993
- value,
1994
- onChange
1995
- }) {
1996
- const editorRef = useRef(null);
1997
- const searchInputRef = useRef(null);
1998
- const linkInputRef = useRef(null);
1999
- const savedSelection = useRef(null);
2000
- const [wordCount, setWordCount] = useState(0);
2001
- const [characterCount, setCharacterCount] = useState(0);
2002
- const [activeFormats, setActiveFormats] = useState({
2003
- bold: false,
2004
- italic: false,
2005
- underline: false,
2006
- justifyLeft: false,
2007
- justifyCenter: false,
2008
- justifyRight: false,
2009
- insertUnorderedList: false,
2010
- insertOrderedList: false,
2011
- link: false,
2012
- h1: false,
2013
- h2: false,
2014
- h3: false,
2015
- p: true
2016
- });
2017
- const [isSearchOpen, setIsSearchOpen] = useState(false);
2018
- const [searchQuery, setSearchQuery] = useState("");
2019
- const [linkUrl, setLinkUrl] = useState("https://");
2020
- const [isLinkOpen, setIsLinkOpen] = useState(false);
2021
- const [hasSavedSelection, setHasSavedSelection] = useState(false);
2022
- const findParentTag = useCallback((node, tagName) => {
2023
- let current = node;
2024
- while (current && current !== editorRef.current) {
2025
- if (current.nodeName === tagName) return current;
2026
- current = current.parentNode;
2027
- }
2028
- return null;
2029
- }, []);
2030
- const updateActiveFormats = useCallback(() => {
2031
- let formatBlock = "";
2032
- try {
2033
- formatBlock = document.queryCommandValue("formatBlock");
2034
- } catch (_e) {
2035
- }
2036
- const selection = window.getSelection();
2037
- const anchorNode = selection == null ? void 0 : selection.anchorNode;
2038
- const focusNode = selection == null ? void 0 : selection.focusNode;
2039
- setActiveFormats({
2040
- bold: document.queryCommandState("bold"),
2041
- italic: document.queryCommandState("italic"),
2042
- underline: document.queryCommandState("underline"),
2043
- justifyLeft: document.queryCommandState("justifyLeft"),
2044
- justifyCenter: document.queryCommandState("justifyCenter"),
2045
- justifyRight: document.queryCommandState("justifyRight"),
2046
- insertUnorderedList: document.queryCommandState("insertUnorderedList"),
2047
- insertOrderedList: document.queryCommandState("insertOrderedList"),
2048
- link: !!(findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A")),
2049
- h1: formatBlock === "h1" || formatBlock === "H1",
2050
- h2: formatBlock === "h2" || formatBlock === "H2",
2051
- h3: formatBlock === "h3" || formatBlock === "H3",
2052
- p: formatBlock === "p" || formatBlock === "P" || formatBlock === "div" || formatBlock === "DIV" || formatBlock === ""
2053
- });
2054
- }, [findParentTag]);
2055
- const updateActiveFormatsRef = useRef(updateActiveFormats);
2056
- useEffect(() => {
2057
- updateActiveFormatsRef.current = updateActiveFormats;
2058
- }, [updateActiveFormats]);
2059
- useEffect(() => {
2060
- if (editorRef.current && editorRef.current.innerHTML !== value) {
2061
- editorRef.current.innerHTML = value;
2062
- }
2063
- const handleSelectionChange = () => {
2064
- if (document.activeElement === editorRef.current) {
2065
- updateActiveFormatsRef.current();
2066
- }
2067
- };
2068
- document.addEventListener("selectionchange", handleSelectionChange);
2069
- return () => document.removeEventListener("selectionchange", handleSelectionChange);
2070
- }, []);
2071
- useEffect(() => {
2072
- var _a;
2073
- const text = ((_a = editorRef.current) == null ? void 0 : _a.innerText) || "";
2074
- setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
2075
- setCharacterCount(text.trim() ? text.length : 0);
2076
- }, [value]);
2077
- const handleInput = useCallback(() => {
2078
- if (editorRef.current) {
2079
- onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
2080
- updateActiveFormats();
2081
- const text = editorRef.current.innerText || "";
2082
- setWordCount(text.trim() ? text.trim().split(/\s+/).length : 0);
2083
- setCharacterCount(text.trim() ? text.length : 0);
2084
- }
2085
- }, [onChange, updateActiveFormats]);
2086
- const execCommand = useCallback(
2087
- (command, val = "") => {
2088
- var _a;
2089
- document.execCommand(command, false, val);
2090
- updateActiveFormats();
2091
- (_a = editorRef.current) == null ? void 0 : _a.focus();
2092
- if (editorRef.current) {
2093
- onChange == null ? void 0 : onChange(editorRef.current.innerHTML);
2094
- }
2095
- },
2096
- [onChange, updateActiveFormats]
2097
- );
2098
- const performSearch = useCallback((text, backward = false) => {
2099
- var _a, _b;
2100
- if (!text || !editorRef.current) return;
2101
- const editor = editorRef.current;
2102
- const selection = window.getSelection();
2103
- if (!selection) return;
2104
- const walker = document.createTreeWalker(editor, NodeFilter.SHOW_TEXT);
2105
- const segments = [];
2106
- let offset = 0;
2107
- let node;
2108
- while (node = walker.nextNode()) {
2109
- segments.push({ node, start: offset });
2110
- offset += node.length;
2111
- }
2112
- const fullText = segments.reduce((acc, s) => acc + (s.node.textContent ?? ""), "");
2113
- let searchFrom = 0;
2114
- if (selection.rangeCount > 0) {
2115
- const range2 = selection.getRangeAt(0);
2116
- if (editor.contains(range2.startContainer)) {
2117
- const seg = segments.find((s) => s.node === range2.startContainer);
2118
- if (seg) {
2119
- searchFrom = backward ? seg.start + range2.startOffset - 1 : seg.start + range2.endOffset;
2120
- }
2121
- }
2122
- }
2123
- const lowerFull = fullText.toLowerCase();
2124
- const lowerQuery = text.toLowerCase();
2125
- let matchStart = -1;
2126
- if (backward) {
2127
- matchStart = lowerFull.lastIndexOf(lowerQuery, Math.max(0, searchFrom));
2128
- if (matchStart === -1) matchStart = lowerFull.lastIndexOf(lowerQuery);
2129
- } else {
2130
- matchStart = lowerFull.indexOf(lowerQuery, searchFrom);
2131
- if (matchStart === -1) matchStart = lowerFull.indexOf(lowerQuery);
2132
- }
2133
- if (matchStart === -1) return;
2134
- const matchEnd = matchStart + text.length;
2135
- const range = document.createRange();
2136
- let startSet = false;
2137
- let endSet = false;
2138
- for (let i = 0; i < segments.length && !endSet; i++) {
2139
- const seg = segments[i];
2140
- const segEnd = seg.start + seg.node.length;
2141
- if (!startSet && matchStart < segEnd && matchStart >= seg.start) {
2142
- range.setStart(seg.node, matchStart - seg.start);
2143
- startSet = true;
2144
- }
2145
- if (startSet && matchEnd <= segEnd) {
2146
- range.setEnd(seg.node, matchEnd - seg.start);
2147
- endSet = true;
2148
- }
2149
- }
2150
- if (startSet && endSet) {
2151
- selection.removeAllRanges();
2152
- selection.addRange(range);
2153
- (_b = (_a = range.startContainer.parentElement) == null ? void 0 : _a.scrollIntoView) == null ? void 0 : _b.call(_a, { block: "nearest" });
2154
- }
2155
- }, []);
2156
- const handleCreateLink = useCallback(() => {
2157
- if (savedSelection.current) {
2158
- const selection2 = window.getSelection();
2159
- selection2 == null ? void 0 : selection2.removeAllRanges();
2160
- selection2 == null ? void 0 : selection2.addRange(savedSelection.current);
2161
- }
2162
- const selection = window.getSelection();
2163
- const anchorNode = selection == null ? void 0 : selection.anchorNode;
2164
- const existingLink = findParentTag(anchorNode || null, "A");
2165
- if (existingLink) {
2166
- if (linkUrl) {
2167
- existingLink.setAttribute("href", linkUrl);
2168
- existingLink.setAttribute("target", "_blank");
2169
- existingLink.setAttribute("rel", "noopener noreferrer");
2170
- existingLink.style.color = "hsl(var(--primary))";
2171
- existingLink.style.textDecoration = "underline";
2172
- existingLink.style.cursor = "pointer";
2173
- }
2174
- handleInput();
2175
- setIsLinkOpen(false);
2176
- savedSelection.current = null;
2177
- return;
2178
- }
2179
- if (!selection || selection.rangeCount === 0 || selection.isCollapsed) {
2180
- return;
2181
- }
2182
- if (linkUrl) {
2183
- document.execCommand("createLink", false, linkUrl);
2184
- setTimeout(() => {
2185
- var _a;
2186
- const anchor = findParentTag(((_a = window.getSelection()) == null ? void 0 : _a.anchorNode) || null, "A");
2187
- if (anchor) {
2188
- anchor.setAttribute("target", "_blank");
2189
- anchor.setAttribute("rel", "noopener noreferrer");
2190
- anchor.style.color = "hsl(var(--primary))";
2191
- anchor.style.textDecoration = "underline";
2192
- anchor.style.cursor = "pointer";
2193
- }
2194
- handleInput();
2195
- }, 10);
2196
- setIsLinkOpen(false);
2197
- savedSelection.current = null;
2198
- }
2199
- }, [linkUrl, findParentTag, handleInput]);
2200
- const handleUnlink = useCallback(() => {
2201
- const selection = window.getSelection();
2202
- const anchorNode = selection == null ? void 0 : selection.anchorNode;
2203
- const existingLink = findParentTag(anchorNode || null, "A");
2204
- if (existingLink) {
2205
- const parent = existingLink.parentNode;
2206
- while (existingLink.firstChild) {
2207
- parent == null ? void 0 : parent.insertBefore(existingLink.firstChild, existingLink);
2208
- }
2209
- parent == null ? void 0 : parent.removeChild(existingLink);
2210
- handleInput();
2211
- } else {
2212
- document.execCommand("unlink", false, "");
2213
- }
2214
- }, [findParentTag, handleInput]);
2215
- const onLinkPopoverOpenChange = useCallback(
2216
- (open) => {
2217
- if (open) {
2218
- const selection = window.getSelection();
2219
- const anchorNode = selection == null ? void 0 : selection.anchorNode;
2220
- const focusNode = selection == null ? void 0 : selection.focusNode;
2221
- const existingLink = findParentTag(anchorNode || null, "A") || findParentTag(focusNode || null, "A");
2222
- if (existingLink) {
2223
- setLinkUrl(existingLink.getAttribute("href") || "https://");
2224
- } else {
2225
- setLinkUrl("https://");
2226
- }
2227
- if (selection && selection.rangeCount > 0 && (!selection.isCollapsed || existingLink)) {
2228
- savedSelection.current = selection.getRangeAt(0).cloneRange();
2229
- setHasSavedSelection(true);
2230
- } else {
2231
- savedSelection.current = null;
2232
- setHasSavedSelection(false);
2233
- }
2234
- setTimeout(() => {
2235
- var _a;
2236
- return (_a = linkInputRef.current) == null ? void 0 : _a.focus();
2237
- }, 100);
2238
- } else {
2239
- setHasSavedSelection(false);
2240
- }
2241
- setIsLinkOpen(open);
2242
- },
2243
- [findParentTag]
2244
- );
2245
- return {
2246
- // Refs
2247
- editorRef,
2248
- searchInputRef,
2249
- linkInputRef,
2250
- // State
2251
- activeFormats,
2252
- isSearchOpen,
2253
- setIsSearchOpen,
2254
- searchQuery,
2255
- setSearchQuery,
2256
- linkUrl,
2257
- setLinkUrl,
2258
- isLinkOpen,
2259
- hasSavedSelection,
2260
- // Computed
2261
- wordCount,
2262
- characterCount,
2263
- // Handlers
2264
- updateActiveFormats,
2265
- execCommand,
2266
- handleInput,
2267
- performSearch,
2268
- handleCreateLink,
2269
- handleUnlink,
2270
- onLinkPopoverOpenChange
2271
- };
2272
- }
2273
- function RichTextEditor({
2274
- value,
2275
- onChange,
2276
- placeholder,
2277
- className,
2278
- actionButton,
2279
- allowSearch = true,
2280
- allowLinks = true,
2281
- allowUndoRedo = true,
2282
- allowHeadings = true,
2283
- allowFormatting = true,
2284
- allowAlignment = true,
2285
- allowLists = true,
2286
- showWordCount = true,
2287
- showCharacterCount = true,
2288
- disabled = false,
2289
- readOnly = false,
2290
- onFocus,
2291
- onBlur,
2292
- minHeight,
2293
- maxHeight
2294
- }) {
2295
- const isEditable = !disabled && !readOnly;
2296
- const showToolbar = isEditable;
2297
- const {
2298
- editorRef,
2299
- searchInputRef,
2300
- linkInputRef,
2301
- activeFormats,
2302
- isSearchOpen,
2303
- setIsSearchOpen,
2304
- searchQuery,
2305
- setSearchQuery,
2306
- linkUrl,
2307
- setLinkUrl,
2308
- isLinkOpen,
2309
- hasSavedSelection,
2310
- wordCount,
2311
- characterCount,
2312
- updateActiveFormats,
2313
- execCommand,
2314
- handleInput,
2315
- performSearch,
2316
- handleCreateLink,
2317
- handleUnlink,
2318
- onLinkPopoverOpenChange
2319
- } = useRichTextEditor({ value, onChange });
2320
- const getCurrentBlockLabel = () => {
2321
- if (activeFormats.h1)
2322
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2323
- /* @__PURE__ */ jsx(Heading1, { className: "w-4 h-4 mr-1 shrink-0" }),
2324
- /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 1" })
2325
- ] });
2326
- if (activeFormats.h2)
2327
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2328
- /* @__PURE__ */ jsx(Heading2, { className: "w-4 h-4 mr-1 shrink-0" }),
2329
- /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 2" })
2330
- ] });
2331
- if (activeFormats.h3)
2332
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2333
- /* @__PURE__ */ jsx(Heading3, { className: "w-4 h-4 mr-1 shrink-0" }),
2334
- /* @__PURE__ */ jsx("span", { className: "truncate", children: "Título 3" })
2335
- ] });
2336
- return /* @__PURE__ */ jsxs(Fragment, { children: [
2337
- /* @__PURE__ */ jsx(Type, { className: "w-4 h-4 mr-1 shrink-0" }),
2338
- /* @__PURE__ */ jsx("span", { className: "truncate", children: "Parágrafo" })
2339
- ] });
2340
- };
2341
- return /* @__PURE__ */ jsxs(
2342
- "div",
2343
- {
2344
- className: cn(
2345
- "flex flex-col h-full w-full bg-background sm:border border-border sm:shadow-sm sm:rounded-lg overflow-hidden",
2346
- disabled && "opacity-50 pointer-events-none",
2347
- className
2348
- ),
2349
- children: [
2350
- /* @__PURE__ */ jsx("style", { children: `
2351
- [contenteditable]:empty:before {
2352
- content: attr(data-placeholder);
2353
- color: hsl(var(--muted-foreground));
2354
- pointer-events: none;
2355
- display: block;
2356
- }
2357
- .prose-editor ul {
2358
- list-style-type: disc !important;
2359
- padding-left: 1.5rem !important;
2360
- margin-top: 0.5rem !important;
2361
- margin-bottom: 0.5rem !important;
2362
- }
2363
- .prose-editor ol {
2364
- list-style-type: decimal !important;
2365
- padding-left: 1.5rem !important;
2366
- margin-top: 0.5rem !important;
2367
- margin-bottom: 0.5rem !important;
2368
- }
2369
- .prose-editor b, .prose-editor strong {
2370
- font-weight: 600 !important;
2371
- }
2372
- .prose-editor i, .prose-editor em {
2373
- font-style: italic !important;
2374
- }
2375
- .prose-editor u {
2376
- text-decoration: underline !important;
2377
- }
2378
- .prose-editor h1 {
2379
- font-size: 2.25rem !important;
2380
- font-weight: 700 !important;
2381
- margin-bottom: 1.25rem !important;
2382
- line-height: 1.2 !important;
2383
- margin-top: 2rem !important;
2384
- color: hsl(var(--foreground));
2385
- }
2386
- .prose-editor h2 {
2387
- font-size: 1.75rem !important;
2388
- font-weight: 600 !important;
2389
- margin-bottom: 1rem !important;
2390
- margin-top: 1.5rem !important;
2391
- color: hsl(var(--foreground));
2392
- }
2393
- .prose-editor h3 {
2394
- font-size: 1.35rem !important;
2395
- font-weight: 600 !important;
2396
- margin-bottom: 0.75rem !important;
2397
- margin-top: 1.25rem !important;
2398
- color: hsl(var(--foreground));
2399
- }
2400
- .prose-editor p {
2401
- margin-bottom: 1rem !important;
2402
- line-height: 1.6 !important;
2403
- }
2404
- .prose-editor a {
2405
- color: var(--info) !important;
2406
- text-decoration: underline !important;
2407
- cursor: pointer !important;
2408
- }
2409
- .prose-editor h1:first-child, .prose-editor h2:first-child, .prose-editor h3:first-child, .prose-editor p:first-child {
2410
- margin-top: 0 !important;
2411
- }
2412
- .prose-editor {
2413
- outline: none !important;
2414
- }
2415
- ` }),
2416
- showToolbar && /* @__PURE__ */ jsxs("div", { className: "px-3 py-2 border-b border-border bg-muted/30 flex items-center gap-1 flex-wrap shrink-0", children: [
2417
- allowUndoRedo && /* @__PURE__ */ jsxs(Fragment, { children: [
2418
- /* @__PURE__ */ jsx(
2419
- Button,
2420
- {
2421
- variant: "ghost",
2422
- size: "icon",
2423
- className: "h-8 w-8 text-muted-foreground",
2424
- onClick: () => execCommand("undo"),
2425
- title: "Desfazer",
2426
- "aria-label": "Desfazer",
2427
- children: /* @__PURE__ */ jsx(Undo, { className: "w-4 h-4" })
2428
- }
2429
- ),
2430
- /* @__PURE__ */ jsx(
2431
- Button,
2432
- {
2433
- variant: "ghost",
2434
- size: "icon",
2435
- className: "h-8 w-8 text-muted-foreground",
2436
- onClick: () => execCommand("redo"),
2437
- title: "Refazer",
2438
- "aria-label": "Refazer",
2439
- children: /* @__PURE__ */ jsx(Redo, { className: "w-4 h-4" })
2440
- }
2441
- ),
2442
- /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2443
- ] }),
2444
- allowHeadings && /* @__PURE__ */ jsxs(Fragment, { children: [
2445
- /* @__PURE__ */ jsxs(DropdownMenu, { modal: false, children: [
2446
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsxs(
2447
- Button,
2448
- {
2449
- variant: "ghost",
2450
- size: "sm",
2451
- className: "h-8 gap-0 text-muted-foreground w-[120px] justify-start px-2",
2452
- children: [
2453
- getCurrentBlockLabel(),
2454
- /* @__PURE__ */ jsx(ChevronDown, { className: "w-3 h-3 ml-auto opacity-50 shrink-0" })
2455
- ]
2456
- }
2457
- ) }),
2458
- /* @__PURE__ */ jsxs(DropdownMenuContent, { align: "start", className: "w-[160px]", style: { zIndex: 9999 }, children: [
2459
- /* @__PURE__ */ jsxs(
2460
- DropdownMenuItem,
2461
- {
2462
- onPointerDown: (e) => e.preventDefault(),
2463
- onClick: () => execCommand("formatBlock", "P"),
2464
- className: "gap-2",
2465
- children: [
2466
- /* @__PURE__ */ jsx(Type, { className: "w-4 h-4 text-muted-foreground" }),
2467
- " Parágrafo"
2468
- ]
2469
- }
2470
- ),
2471
- /* @__PURE__ */ jsxs(
2472
- DropdownMenuItem,
2473
- {
2474
- onPointerDown: (e) => e.preventDefault(),
2475
- onClick: () => execCommand("formatBlock", "H1"),
2476
- className: "gap-2",
2477
- children: [
2478
- /* @__PURE__ */ jsx(Heading1, { className: "w-4 h-4 text-muted-foreground" }),
2479
- " Título 1"
2480
- ]
2481
- }
2482
- ),
2483
- /* @__PURE__ */ jsxs(
2484
- DropdownMenuItem,
2485
- {
2486
- onPointerDown: (e) => e.preventDefault(),
2487
- onClick: () => execCommand("formatBlock", "H2"),
2488
- className: "gap-2",
2489
- children: [
2490
- /* @__PURE__ */ jsx(Heading2, { className: "w-4 h-4 text-muted-foreground" }),
2491
- " Título 2"
2492
- ]
2493
- }
2494
- ),
2495
- /* @__PURE__ */ jsxs(
2496
- DropdownMenuItem,
2497
- {
2498
- onPointerDown: (e) => e.preventDefault(),
2499
- onClick: () => execCommand("formatBlock", "H3"),
2500
- className: "gap-2",
2501
- children: [
2502
- /* @__PURE__ */ jsx(Heading3, { className: "w-4 h-4 text-muted-foreground" }),
2503
- " Título 3"
2504
- ]
2505
- }
2506
- )
2507
- ] })
2508
- ] }),
2509
- /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2510
- ] }),
2511
- allowFormatting && /* @__PURE__ */ jsxs(Fragment, { children: [
2512
- /* @__PURE__ */ jsx(
2513
- Button,
2514
- {
2515
- variant: "ghost",
2516
- size: "icon",
2517
- className: cn(
2518
- "h-8 w-8 text-muted-foreground",
2519
- activeFormats.bold && "bg-muted text-foreground"
2520
- ),
2521
- onClick: () => execCommand("bold"),
2522
- title: "Negrito",
2523
- "aria-label": "Negrito",
2524
- children: /* @__PURE__ */ jsx(Bold, { className: "w-4 h-4" })
2525
- }
2526
- ),
2527
- /* @__PURE__ */ jsx(
2528
- Button,
2529
- {
2530
- variant: "ghost",
2531
- size: "icon",
2532
- className: cn(
2533
- "h-8 w-8 text-muted-foreground",
2534
- activeFormats.italic && "bg-muted text-foreground"
2535
- ),
2536
- onClick: () => execCommand("italic"),
2537
- title: "Itálico",
2538
- "aria-label": "Itálico",
2539
- children: /* @__PURE__ */ jsx(Italic, { className: "w-4 h-4" })
2540
- }
2541
- ),
2542
- /* @__PURE__ */ jsx(
2543
- Button,
2544
- {
2545
- variant: "ghost",
2546
- size: "icon",
2547
- className: cn(
2548
- "h-8 w-8 text-muted-foreground",
2549
- activeFormats.underline && "bg-muted text-foreground"
2550
- ),
2551
- onClick: () => execCommand("underline"),
2552
- title: "Sublinhado",
2553
- "aria-label": "Sublinhado",
2554
- children: /* @__PURE__ */ jsx(Underline, { className: "w-4 h-4" })
2555
- }
2556
- ),
2557
- /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2558
- ] }),
2559
- allowAlignment && /* @__PURE__ */ jsxs(Fragment, { children: [
2560
- /* @__PURE__ */ jsx(
2561
- Button,
2562
- {
2563
- variant: "ghost",
2564
- size: "icon",
2565
- className: cn(
2566
- "h-8 w-8 text-muted-foreground",
2567
- activeFormats.justifyLeft && "bg-muted text-foreground"
2568
- ),
2569
- onClick: () => execCommand("justifyLeft"),
2570
- title: "Alinhar à esquerda",
2571
- "aria-label": "Alinhar à esquerda",
2572
- children: /* @__PURE__ */ jsx(AlignLeft, { className: "w-4 h-4" })
2573
- }
2574
- ),
2575
- /* @__PURE__ */ jsx(
2576
- Button,
2577
- {
2578
- variant: "ghost",
2579
- size: "icon",
2580
- className: cn(
2581
- "h-8 w-8 text-muted-foreground",
2582
- activeFormats.justifyCenter && "bg-muted text-foreground"
2583
- ),
2584
- onClick: () => execCommand("justifyCenter"),
2585
- title: "Centralizar",
2586
- "aria-label": "Centralizar",
2587
- children: /* @__PURE__ */ jsx(AlignCenter, { className: "w-4 h-4" })
2588
- }
2589
- ),
2590
- /* @__PURE__ */ jsx(
2591
- Button,
2592
- {
2593
- variant: "ghost",
2594
- size: "icon",
2595
- className: cn(
2596
- "h-8 w-8 text-muted-foreground",
2597
- activeFormats.justifyRight && "bg-muted text-foreground"
2598
- ),
2599
- onClick: () => execCommand("justifyRight"),
2600
- title: "Alinhar à direita",
2601
- "aria-label": "Alinhar à direita",
2602
- children: /* @__PURE__ */ jsx(AlignRight, { className: "w-4 h-4" })
2603
- }
2604
- ),
2605
- /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2606
- ] }),
2607
- allowLists && /* @__PURE__ */ jsxs(Fragment, { children: [
2608
- /* @__PURE__ */ jsx(
2609
- Button,
2610
- {
2611
- variant: "ghost",
2612
- size: "icon",
2613
- className: cn(
2614
- "h-8 w-8 text-muted-foreground",
2615
- activeFormats.insertUnorderedList && "bg-muted text-foreground"
2616
- ),
2617
- onClick: () => execCommand("insertUnorderedList"),
2618
- title: "Lista com marcadores",
2619
- "aria-label": "Lista com marcadores",
2620
- children: /* @__PURE__ */ jsx(List, { className: "w-4 h-4" })
2621
- }
2622
- ),
2623
- /* @__PURE__ */ jsx(
2624
- Button,
2625
- {
2626
- variant: "ghost",
2627
- size: "icon",
2628
- className: cn(
2629
- "h-8 w-8 text-muted-foreground",
2630
- activeFormats.insertOrderedList && "bg-muted text-foreground"
2631
- ),
2632
- onClick: () => execCommand("insertOrderedList"),
2633
- title: "Lista numerada",
2634
- "aria-label": "Lista numerada",
2635
- children: /* @__PURE__ */ jsx(ListOrdered, { className: "w-4 h-4" })
2636
- }
2637
- ),
2638
- /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2639
- ] }),
2640
- allowLinks && /* @__PURE__ */ jsxs(Fragment, { children: [
2641
- /* @__PURE__ */ jsxs(Popover, { open: isLinkOpen, onOpenChange: onLinkPopoverOpenChange, modal: false, children: [
2642
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ jsx(
2643
- Button,
2644
- {
2645
- variant: "ghost",
2646
- size: "icon",
2647
- className: cn(
2648
- "h-8 w-8 text-muted-foreground",
2649
- (activeFormats.link || isLinkOpen) && "bg-muted text-foreground"
2650
- ),
2651
- title: "Inserir link",
2652
- "aria-label": "Inserir link",
2653
- children: /* @__PURE__ */ jsx(Link, { className: "w-4 h-4" })
2654
- }
2655
- ) }),
2656
- /* @__PURE__ */ jsx(PopoverContent, { className: "w-80 p-3", align: "start", style: { zIndex: 9999 }, children: !activeFormats.link && !hasSavedSelection ? /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground py-1", children: "Selecione um texto para criar um link." }) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
2657
- /* @__PURE__ */ jsx("div", { className: "text-xs font-medium", children: activeFormats.link ? "Editar Link" : "Inserir Link" }),
2658
- /* @__PURE__ */ jsxs("div", { className: "flex gap-2", children: [
2659
- /* @__PURE__ */ jsx(
2660
- Input,
2661
- {
2662
- ref: linkInputRef,
2663
- placeholder: "https://...",
2664
- value: linkUrl,
2665
- onChange: (e) => setLinkUrl(e.target.value),
2666
- onKeyDown: (e) => {
2667
- if (e.key === "Enter") {
2668
- e.preventDefault();
2669
- e.stopPropagation();
2670
- handleCreateLink();
2671
- }
2672
- },
2673
- className: "h-8 text-xs"
2674
- }
2675
- ),
2676
- /* @__PURE__ */ jsx(Button, { size: "sm", className: "h-8", onClick: handleCreateLink, children: "Aplicar" })
2677
- ] })
2678
- ] }) })
2679
- ] }),
2680
- /* @__PURE__ */ jsx(
2681
- Button,
2682
- {
2683
- variant: "ghost",
2684
- size: "icon",
2685
- className: "h-8 w-8 text-muted-foreground",
2686
- onClick: handleUnlink,
2687
- title: "Remover link",
2688
- "aria-label": "Remover link",
2689
- children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
2690
- }
2691
- ),
2692
- /* @__PURE__ */ jsx("div", { className: "w-px h-6 bg-border mx-1 hidden sm:block" })
2693
- ] }),
2694
- (allowFormatting || allowHeadings || allowAlignment || allowLists || allowLinks) && /* @__PURE__ */ jsx(
2695
- Button,
2696
- {
2697
- variant: "ghost",
2698
- size: "icon",
2699
- className: "h-8 w-8 text-muted-foreground",
2700
- onClick: () => execCommand("removeFormat"),
2701
- title: "Limpar formatação",
2702
- "aria-label": "Limpar formatação",
2703
- children: /* @__PURE__ */ jsx(Type, { className: "w-4 h-4" })
2704
- }
2705
- ),
2706
- allowSearch && /* @__PURE__ */ jsx(
2707
- Button,
2708
- {
2709
- variant: "ghost",
2710
- size: "icon",
2711
- className: cn(
2712
- "h-8 w-8 text-muted-foreground",
2713
- isSearchOpen && "bg-muted text-foreground"
2714
- ),
2715
- onClick: () => {
2716
- setIsSearchOpen(!isSearchOpen);
2717
- if (!isSearchOpen) setTimeout(() => {
2718
- var _a;
2719
- return (_a = searchInputRef.current) == null ? void 0 : _a.focus();
2720
- }, 100);
2721
- },
2722
- title: "Buscar",
2723
- "aria-label": "Buscar",
2724
- children: /* @__PURE__ */ jsx(Search, { className: "w-4 h-4" })
2725
- }
2726
- ),
2727
- actionButton && /* @__PURE__ */ jsxs(Fragment, { children: [
2728
- /* @__PURE__ */ jsx("div", { className: "flex-1" }),
2729
- actionButton
2730
- ] })
2731
- ] }),
2732
- isSearchOpen && /* @__PURE__ */ jsxs("div", { className: "px-3 py-1.5 border-b border-border bg-muted/20 flex items-center gap-2", children: [
2733
- /* @__PURE__ */ jsxs("div", { className: "relative flex-1 max-w-sm", children: [
2734
- /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground" }),
2735
- /* @__PURE__ */ jsx(
2736
- Input,
2737
- {
2738
- ref: searchInputRef,
2739
- placeholder: "Buscar no texto...",
2740
- value: searchQuery,
2741
- onChange: (e) => setSearchQuery(e.target.value),
2742
- onKeyDown: (e) => {
2743
- if (e.key === "Enter") {
2744
- e.preventDefault();
2745
- performSearch(searchQuery, e.shiftKey);
2746
- }
2747
- if (e.key === "Escape") {
2748
- setIsSearchOpen(false);
2749
- }
2750
- },
2751
- className: "h-8 pl-8 text-xs bg-background"
2752
- }
2753
- )
2754
- ] }),
2755
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1", children: [
2756
- /* @__PURE__ */ jsx(
2757
- Button,
2758
- {
2759
- variant: "ghost",
2760
- size: "icon",
2761
- className: "h-7 w-7",
2762
- onMouseDown: (e) => e.preventDefault(),
2763
- onClick: () => performSearch(searchQuery, true),
2764
- title: "Anterior",
2765
- children: /* @__PURE__ */ jsx(ChevronUp, { className: "w-4 h-4" })
2766
- }
2767
- ),
2768
- /* @__PURE__ */ jsx(
2769
- Button,
2770
- {
2771
- variant: "ghost",
2772
- size: "icon",
2773
- className: "h-7 w-7",
2774
- onMouseDown: (e) => e.preventDefault(),
2775
- onClick: () => performSearch(searchQuery, false),
2776
- title: "Próximo",
2777
- children: /* @__PURE__ */ jsx(ChevronDown, { className: "w-4 h-4" })
2778
- }
2779
- ),
2780
- /* @__PURE__ */ jsx("div", { className: "w-px h-4 bg-border mx-1" }),
2781
- /* @__PURE__ */ jsx(
2782
- Button,
2783
- {
2784
- variant: "ghost",
2785
- size: "icon",
2786
- className: "h-7 w-7 text-muted-foreground hover:text-foreground",
2787
- onClick: () => setIsSearchOpen(false),
2788
- title: "Fechar busca",
2789
- children: /* @__PURE__ */ jsx(X, { className: "w-4 h-4" })
2790
- }
2791
- )
2792
- ] }),
2793
- /* @__PURE__ */ jsx("div", { className: "hidden sm:block text-[10px] text-muted-foreground ml-auto uppercase tracking-wider font-medium", children: "Pressione Enter para buscar" })
2794
- ] }),
2795
- /* @__PURE__ */ jsx(
2796
- "div",
2797
- {
2798
- className: "flex-1 overflow-y-auto p-4 sm:p-8 bg-background scrollbar-thin",
2799
- style: { minHeight, maxHeight },
2800
- children: /* @__PURE__ */ jsx(
2801
- "div",
2802
- {
2803
- ref: editorRef,
2804
- contentEditable: isEditable,
2805
- role: "textbox",
2806
- "aria-multiline": "true",
2807
- "aria-label": placeholder || "Editor de texto",
2808
- "aria-readonly": readOnly,
2809
- "aria-disabled": disabled,
2810
- onInput: handleInput,
2811
- onSelect: isEditable ? updateActiveFormats : void 0,
2812
- onFocus: () => {
2813
- updateActiveFormats();
2814
- onFocus == null ? void 0 : onFocus();
2815
- },
2816
- onBlur,
2817
- className: "prose-editor min-h-full max-w-none focus:outline-none",
2818
- "data-placeholder": placeholder
2819
- }
2820
- )
2821
- }
2822
- ),
2823
- (showWordCount || showCharacterCount) && /* @__PURE__ */ jsx("div", { className: "px-4 py-2 border-t border-border bg-muted/20 flex items-center justify-between", children: /* @__PURE__ */ jsxs("div", { className: "text-[10px] sm:text-xs text-muted-foreground font-medium uppercase tracking-wider flex items-center gap-2", children: [
2824
- showWordCount && /* @__PURE__ */ jsxs("span", { children: [
2825
- wordCount,
2826
- " ",
2827
- wordCount === 1 ? "palavra" : "palavras"
2828
- ] }),
2829
- showWordCount && showCharacterCount && /* @__PURE__ */ jsx("span", { className: "text-muted-foreground", children: "•" }),
2830
- showCharacterCount && /* @__PURE__ */ jsxs("span", { children: [
2831
- characterCount,
2832
- " ",
2833
- characterCount === 1 ? "caractere" : "caracteres"
2834
- ] })
2835
- ] }) })
2836
- ]
2837
- }
2838
- );
2839
- }
2840
- export {
2841
- Alert as A,
2842
- EmptyTitle as B,
2843
- ChartCard as C,
2844
- DashboardBarChart as D,
2845
- Empty as E,
2846
- RadialBarMetricChart as F,
2847
- GaugeChart as G,
2848
- HorizontalBarChart as H,
2849
- InteractiveTimeSeriesChart as I,
2850
- RichTextEditor as J,
2851
- TableBody as K,
2852
- TableCaption as L,
2853
- TableCell as M,
2854
- TableFooter as N,
2855
- TableHead as O,
2856
- PieMetricChart as P,
2857
- TableHeader as Q,
2858
- RadarMetricChart as R,
2859
- SparklineChart as S,
2860
- Table as T,
2861
- TableRow as U,
2862
- Textarea as V,
2863
- useChart as W,
2864
- useRichTextEditor as X,
2865
- AlertDescription as a,
2866
- AlertTitle as b,
2867
- ChartContainer as c,
2868
- ChartLegend as d,
2869
- ChartLegendContent as e,
2870
- ChartStyle as f,
2871
- ChartTooltip as g,
2872
- ChartTooltipContent as h,
2873
- ComboMetricChart as i,
2874
- DashboardLineChart as j,
2875
- Dialog as k,
2876
- DialogBody as l,
2877
- DialogClose as m,
2878
- DialogContent as n,
2879
- DialogDescription as o,
2880
- DialogFooter as p,
2881
- DialogHeader as q,
2882
- DialogOverlay as r,
2883
- DialogPortal as s,
2884
- DialogTitle as t,
2885
- DialogTrigger as u,
2886
- DonutBreakdownChart as v,
2887
- EmptyAction as w,
2888
- EmptyDescription as x,
2889
- EmptyIcon as y,
2890
- EmptyImage as z
2891
- };