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