xertica-ui 2.1.4 → 2.1.6
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.
- package/CHANGELOG.md +56 -0
- package/README.md +1 -1
- package/assets/xertica-logo.svg +37 -37
- package/assets/xertica-x-logo.svg +20 -20
- package/bin/cli.ts +1 -1
- package/components/assistant/index.ts +6 -6
- package/components/assistant/xertica-assistant/hooks/index.ts +8 -0
- package/components/assistant/xertica-assistant/hooks/use-assistant-conversations.ts +119 -0
- package/components/assistant/xertica-assistant/hooks/use-assistant-messages.ts +323 -0
- package/components/assistant/xertica-assistant/hooks/use-assistant-suggestions.ts +64 -0
- package/components/assistant/xertica-assistant/use-assistant.ts +294 -559
- package/components/assistant/xertica-assistant/xertica-assistant.tsx +5 -13
- package/components/blocks/card-patterns/ActivityCard.tsx +72 -72
- package/components/blocks/card-patterns/FeatureCard.tsx +100 -100
- package/components/blocks/card-patterns/NotificationCard.tsx +127 -127
- package/components/blocks/card-patterns/ProfileCard.tsx +84 -84
- package/components/blocks/card-patterns/ProjectCard.tsx +89 -89
- package/components/blocks/card-patterns/QuickActionCard.tsx +62 -62
- package/components/blocks/card-patterns/card-patterns.stories.tsx +445 -445
- package/components/blocks/card-patterns/card-patterns.test.tsx +448 -0
- package/components/blocks/card-patterns/index.ts +17 -17
- package/components/blocks/index.ts +1 -1
- package/components/brand/index.ts +6 -6
- package/components/brand/xertica-provider/XerticaProvider.tsx +48 -48
- package/components/brand/xertica-provider/xertica-provider.mdx +61 -61
- package/components/brand/xertica-provider/xertica-provider.test.tsx +52 -52
- package/components/examples/MapExamples.tsx +282 -282
- package/components/examples/SimpleFilterableMap.tsx +191 -191
- package/components/examples/index.ts +51 -51
- package/components/figma/ImageWithFallback.tsx +27 -27
- package/components/hooks/index.ts +12 -0
- package/components/index.ts +5 -5
- package/components/layout/header/header.test.tsx +8 -8
- package/components/layout/header/header.tsx +4 -4
- package/components/layout/index.ts +2 -2
- package/components/layout/sidebar/sidebar.mdx +1 -1
- package/components/layout/sidebar/sidebar.test.tsx +11 -11
- package/components/layout/sidebar/sidebar.tsx +25 -10
- package/components/media/FloatingMediaWrapper.tsx +11 -11
- package/components/media/audio-player/use-audio-player.ts +15 -5
- package/components/media/index.ts +3 -3
- package/components/pages/home-content/HomeContent.tsx +7 -7
- package/components/pages/home-content/home-content.mdx +62 -62
- package/components/pages/home-page/HomePage.stories.tsx +39 -39
- package/components/pages/home-page/home-page.mdx +53 -53
- package/components/pages/index.ts +8 -8
- package/components/pages/template-content/template-content.mdx +61 -61
- package/components/pages/template-page/TemplatePage.stories.tsx +39 -39
- package/components/pages/template-page/template-page.mdx +53 -53
- package/components/public-api-smoke.test.tsx +52 -52
- package/components/shared/assistant-utils.ts +43 -43
- package/components/ui/accordion/accordion.mdx +8 -8
- package/components/ui/accordion/accordion.stories.tsx +53 -53
- package/components/ui/alert/alert.mdx +8 -8
- package/components/ui/alert-dialog/alert-dialog.mdx +8 -8
- package/components/ui/aspect-ratio/aspect-ratio.mdx +8 -8
- package/components/ui/assistant-chart/assistant-chart.mdx +8 -8
- package/components/ui/avatar/avatar.mdx +8 -8
- package/components/ui/badge/badge.mdx +8 -8
- package/components/ui/badge/badge.tsx +9 -9
- package/components/ui/breadcrumb/breadcrumb.mdx +8 -8
- package/components/ui/button/button.mdx +8 -8
- package/components/ui/calendar/calendar.mdx +8 -8
- package/components/ui/calendar/calendar.tsx +258 -258
- package/components/ui/card/card.mdx +8 -8
- package/components/ui/card/card.stories.tsx +245 -245
- package/components/ui/carousel/carousel.mdx +8 -8
- package/components/ui/chart/chart.mdx +8 -8
- package/components/ui/chart/chart.stories.tsx +1303 -1303
- package/components/ui/chart/chart.test.tsx +254 -83
- package/components/ui/chart/chart.tsx +79 -2367
- package/components/ui/chart/parts/chart-dashboard.tsx +1025 -0
- package/components/ui/chart/parts/chart-metric.tsx +622 -0
- package/components/ui/chart/parts/chart-primitives.tsx +432 -0
- package/components/ui/chart/parts/chart-shared.tsx +201 -0
- package/components/ui/chart/parts/chart-utils.ts +145 -0
- package/components/ui/chart/parts/index.ts +5 -0
- package/components/ui/checkbox/checkbox.mdx +8 -8
- package/components/ui/checkbox/checkbox.stories.tsx +20 -20
- package/components/ui/collapsible/collapsible.mdx +8 -8
- package/components/ui/command/command.mdx +8 -8
- package/components/ui/context-menu/context-menu.mdx +8 -8
- package/components/ui/dialog/dialog.mdx +8 -8
- package/components/ui/drawer/drawer.mdx +8 -8
- package/components/ui/dropdown-menu/dropdown-menu.mdx +8 -8
- package/components/ui/empty/empty.mdx +8 -8
- package/components/ui/file-upload/file-upload.mdx +8 -8
- package/components/ui/file-upload/file-upload.test.tsx +6 -2
- package/components/ui/file-upload/file-upload.tsx +17 -5
- package/components/ui/file-upload/use-file-upload.test.ts +173 -0
- package/components/ui/file-upload/use-file-upload.ts +76 -25
- package/components/ui/google-maps-loader/google-maps-loader.tsx +2 -2
- package/components/ui/hover-card/hover-card.mdx +8 -8
- package/components/ui/index.ts +1 -1
- package/components/ui/input/input.mdx +8 -8
- package/components/ui/input-otp/input-otp.mdx +8 -8
- package/components/ui/input-otp/input-otp.stories.tsx +6 -6
- package/components/ui/label/label.mdx +8 -8
- package/components/ui/map/map.mdx +8 -8
- package/components/ui/map/map.stories.tsx +51 -51
- package/components/ui/map/map.tsx +2 -2
- package/components/ui/menubar/menubar.mdx +8 -8
- package/components/ui/navigation-menu/navigation-menu.mdx +8 -8
- package/components/ui/notification-badge/notification-badge.mdx +8 -8
- package/components/ui/pagination/pagination.mdx +8 -8
- package/components/ui/pagination/pagination.tsx +17 -0
- package/components/ui/pagination/use-pagination.test.ts +104 -0
- package/components/ui/pagination/use-pagination.ts +33 -16
- package/components/ui/popover/popover.mdx +8 -8
- package/components/ui/progress/progress.mdx +8 -8
- package/components/ui/progress/progress.tsx +68 -68
- package/components/ui/radio-group/radio-group.mdx +8 -8
- package/components/ui/rating/rating.mdx +8 -8
- package/components/ui/resizable/resizable.mdx +8 -8
- package/components/ui/rich-text-editor/rich-text-editor.tsx +9 -3
- package/components/ui/rich-text-editor/use-rich-text-editor.test.ts +110 -0
- package/components/ui/rich-text-editor/use-rich-text-editor.ts +42 -15
- package/components/ui/route-map/route-map.mdx +8 -8
- package/components/ui/route-map/route-map.stories.tsx +54 -54
- package/components/ui/route-map/route-map.tsx +2 -2
- package/components/ui/scroll-area/scroll-area.mdx +8 -8
- package/components/ui/search/search.mdx +8 -8
- package/components/ui/select/select.mdx +8 -8
- package/components/ui/select/select.stories.tsx +9 -9
- package/components/ui/separator/separator.mdx +8 -8
- package/components/ui/sheet/sheet.mdx +8 -8
- package/components/ui/sheet/sheet.stories.tsx +95 -95
- package/components/ui/simple-map/simple-map.mdx +8 -8
- package/components/ui/simple-map/simple-map.stories.tsx +48 -48
- package/components/ui/skeleton/skeleton.mdx +8 -8
- package/components/ui/slider/slider.mdx +8 -8
- package/components/ui/sonner/sonner.mdx +8 -8
- package/components/ui/stats-card/stats-card.mdx +8 -8
- package/components/ui/stepper/stepper.mdx +8 -8
- package/components/ui/stepper/stepper.tsx +21 -2
- package/components/ui/stepper/use-stepper.test.ts +109 -0
- package/components/ui/stepper/use-stepper.ts +4 -1
- package/components/ui/switch/switch.mdx +8 -8
- package/components/ui/switch/switch.stories.tsx +20 -20
- package/components/ui/table/table.mdx +8 -8
- package/components/ui/tabs/tabs.mdx +8 -8
- package/components/ui/tabs/tabs.stories.tsx +26 -26
- package/components/ui/textarea/textarea.mdx +8 -8
- package/components/ui/timeline/timeline.mdx +8 -8
- package/components/ui/toggle/toggle.mdx +8 -8
- package/components/ui/toggle-group/toggle-group.mdx +8 -8
- package/components/ui/tooltip/tooltip.mdx +8 -8
- package/components/ui/tree-view/tree-view.mdx +8 -8
- package/components/ui/tree-view/tree-view.tsx +29 -4
- package/components/ui/tree-view/use-tree-view.test.ts +91 -0
- package/components/ui/tree-view/use-tree-view.ts +38 -19
- package/components.json +1512 -1512
- package/contexts/ApiKeyContext.tsx +72 -72
- package/contexts/LanguageContext.tsx +13 -13
- package/contexts/LayoutContext.test.tsx +11 -11
- package/contexts/ThemeContext.tsx +26 -26
- package/contexts/theme-data.ts +4 -4
- package/dist/{AssistantChart-CVzmmhx4.js → AssistantChart-C_hwFRRr.js} +4 -4
- package/dist/{AssistantChart-BAudAfne.cjs → AssistantChart-CldVCVDe.cjs} +5 -5
- package/dist/{AssistantChart-BP8upjMk.js → AssistantChart-Cu3m7RBo.js} +5 -5
- package/dist/AssistantChart-DIpshm3i.js +4784 -0
- package/dist/{AssistantChart-9w31gdAb.cjs → AssistantChart-DoZCyS5r.cjs} +4 -4
- package/dist/AssistantChart-zjsy2GaZ.cjs +4810 -0
- package/dist/AudioPlayer-B1lt5cPl.cjs +989 -0
- package/dist/AudioPlayer-BZ7bibzU.cjs +982 -0
- package/dist/AudioPlayer-C12BjQBV.cjs +997 -0
- package/dist/{AudioPlayer-DuKXrCfy.js → AudioPlayer-CGRUtUdN.js} +1 -1
- package/dist/AudioPlayer-DMcG_c7L.js +990 -0
- package/dist/AudioPlayer-DcFKRJE_.js +998 -0
- package/dist/{AudioPlayer-1ypwE2Wh.cjs → AudioPlayer-IAU5q5T1.cjs} +1 -1
- package/dist/AudioPlayer-e8LfNoqO.js +983 -0
- package/dist/{xertica-assistant-Qp3ydksa.cjs → CodeBlock-7TTgmdGG.cjs} +263 -51
- package/dist/{xertica-assistant-gnCJdcZY.js → CodeBlock-BeSt1h5P.js} +219 -7
- package/dist/CodeBlock-BgfYL_rD.cjs +2094 -0
- package/dist/CodeBlock-BlcqlA9M.cjs +2094 -0
- package/dist/CodeBlock-Bnmeu5ez.cjs +2094 -0
- package/dist/CodeBlock-BtfPlbAI.js +2078 -0
- package/dist/CodeBlock-CIySIuYr.js +2078 -0
- package/dist/CodeBlock-CuPtUM-7.cjs +2094 -0
- package/dist/CodeBlock-D6ffWXgc.js +2078 -0
- package/dist/CodeBlock-D8dcwbit.cjs +2094 -0
- package/dist/CodeBlock-DMZrFnlw.cjs +2094 -0
- package/dist/CodeBlock-DlBehYN8.js +2078 -0
- package/dist/CodeBlock-DnYNI8rQ.js +2078 -0
- package/dist/CodeBlock-DvKWbSnE.cjs +2094 -0
- package/dist/CodeBlock-DwMCfkFY.js +2078 -0
- package/dist/CodeBlock-Dy6CNYyj.js +2078 -0
- package/dist/CodeBlock-U1pPOQI7.cjs +2094 -0
- package/dist/CodeBlock-f_GpNhEB.js +2078 -0
- package/dist/CodeBlock-oB6u8nI1.js +2078 -0
- package/dist/CodeBlock-tZC31B73.cjs +2094 -0
- package/dist/FeatureCard-CxC-7C-C.cjs +300 -0
- package/dist/FeatureCard-DbHWCb4E.js +301 -0
- package/dist/ImageWithFallback-CGtidP6B.cjs +4542 -0
- package/dist/ImageWithFallback-lsg3pdFg.js +4508 -0
- package/dist/{LanguageContext-DvUt5jBg.cjs → LanguageContext-B_KFTCzT.cjs} +2 -2
- package/dist/{LanguageContext-BwhwC3G2.js → LanguageContext-CS14yCpi.js} +2 -2
- package/dist/LanguageSelector-B5YfbHra.js +231 -0
- package/dist/LanguageSelector-D6uacAIM.cjs +230 -0
- package/dist/LayoutContext-BAql6ZRY.js +97 -0
- package/dist/LayoutContext-BvK-ggDa.cjs +96 -0
- package/dist/ThemeContext-BoH4NLfN.js +734 -0
- package/dist/{ThemeContext-BbBNoFTG.js → ThemeContext-C2EwAPDt.js} +2 -2
- package/dist/ThemeContext-r69W20Xg.cjs +733 -0
- package/dist/{ThemeContext-Cmr8Ex8H.cjs → ThemeContext-vTjumZeM.cjs} +2 -2
- package/dist/{VerifyEmailPage-C_ihbcth.js → VerifyEmailPage-C0c2e5n0.js} +6 -6
- package/dist/{VerifyEmailPage-DMBh4NM9.cjs → VerifyEmailPage-CYXtbKi3.cjs} +1 -1
- package/dist/{VerifyEmailPage-CbgjOF0v.js → VerifyEmailPage-CqKsR2v8.js} +10 -11
- package/dist/{VerifyEmailPage-Bae2cBXT.cjs → VerifyEmailPage-Cwi3kbol.cjs} +7 -7
- package/dist/{VerifyEmailPage-CdYPSJoO.js → VerifyEmailPage-DvMLZgFt.js} +1 -1
- package/dist/{VerifyEmailPage-Dt7zgA4w.cjs → VerifyEmailPage-s-1X3LDJ.cjs} +142 -143
- package/dist/XerticaOrbe-KL1RBHzw.cjs +1354 -0
- package/dist/XerticaOrbe-zwS1p2a8.js +1355 -0
- package/dist/XerticaProvider-6btlAlzc.js +17 -0
- package/dist/{XerticaProvider-siSt9uG2.js → XerticaProvider-B7EVH-NF.js} +2 -2
- package/dist/XerticaProvider-BNoNOxQ5.cjs +16 -0
- package/dist/XerticaProvider-BlY2limY.cjs +38 -0
- package/dist/{XerticaProvider-BITjgC5p.js → XerticaProvider-CEoWMTxu.js} +2 -2
- package/dist/{XerticaProvider-By8q3Roe.cjs → XerticaProvider-CllrbMEJ.cjs} +2 -2
- package/dist/XerticaProvider-DDuiIcKo.js +39 -0
- package/dist/{XerticaProvider-CW9hpCdF.cjs → XerticaProvider-ET0ihewn.cjs} +2 -2
- package/dist/XerticaProvider-cI9hSs27.cjs +38 -0
- package/dist/XerticaProvider-hSwhNQex.js +39 -0
- package/dist/{alert-dialog-yckpaOpy.cjs → alert-dialog-DSKByiKZ.cjs} +3 -3
- package/dist/{alert-dialog-iDe5VE5o.js → alert-dialog-s-vmNkJ_.js} +3 -3
- package/dist/assistant.cjs.js +1 -1
- package/dist/assistant.es.js +1 -1
- package/dist/blocks.cjs.js +1 -1
- package/dist/blocks.es.js +1 -1
- package/dist/brand.cjs.js +1 -1
- package/dist/brand.es.js +1 -1
- package/dist/breadcrumb-CqJ7bHY5.js +161 -0
- package/dist/breadcrumb-m9Hb2_XN.cjs +177 -0
- package/dist/cli.js +1 -1
- package/dist/components/assistant/xertica-assistant/hooks/index.d.ts +6 -0
- package/dist/components/assistant/xertica-assistant/hooks/use-assistant-conversations.d.ts +21 -0
- package/dist/components/assistant/xertica-assistant/hooks/use-assistant-messages.d.ts +49 -0
- package/dist/components/assistant/xertica-assistant/hooks/use-assistant-suggestions.d.ts +16 -0
- package/dist/components/assistant/xertica-assistant/xertica-assistant.d.ts +5 -13
- package/dist/components/blocks/audio-player/AudioPlayer.d.ts +35 -0
- package/dist/components/blocks/audio-player/index.d.ts +1 -0
- package/dist/components/blocks/document-editor/DocumentEditor.d.ts +26 -0
- package/dist/components/blocks/document-editor/index.d.ts +1 -0
- package/dist/components/blocks/podcast-player/PodcastPlayer.d.ts +41 -0
- package/dist/components/blocks/podcast-player/index.d.ts +1 -0
- package/dist/components/hooks/index.d.ts +10 -0
- package/dist/components/ui/chart/chart.d.ts +9 -324
- package/dist/components/ui/chart/parts/chart-dashboard.d.ts +113 -0
- package/dist/components/ui/chart/parts/chart-metric.d.ts +118 -0
- package/dist/components/ui/chart/parts/chart-primitives.d.ts +101 -0
- package/dist/components/ui/chart/parts/chart-shared.d.ts +20 -0
- package/dist/components/ui/chart/parts/chart-utils.d.ts +12 -0
- package/dist/components/ui/chart/parts/index.d.ts +5 -0
- package/dist/components/ui/file-upload/use-file-upload.d.ts +9 -15
- package/dist/components/ui/index.d.ts +1 -1
- package/dist/components/ui/pagination/pagination.d.ts +5 -3
- package/dist/components/ui/tree-view/tree-view.d.ts +2 -0
- package/dist/dropdown-menu-BDB5CmQs.cjs +247 -0
- package/dist/dropdown-menu-DQidbKBD.js +231 -0
- package/dist/google-maps-loader-BFWp6VPd.js +287 -0
- package/dist/{google-maps-loader-t2IlYBzw.js → google-maps-loader-CTYySAun.js} +4 -0
- package/dist/{google-maps-loader-BqsYL48U.cjs → google-maps-loader-Y-QkD-Li.cjs} +5 -0
- package/dist/google-maps-loader-eS3uQ5TA.cjs +287 -0
- package/dist/header-Cgy6vYPk.cjs +731 -0
- package/dist/header-DRlT4jgI.js +715 -0
- package/dist/header-Dux00SI4.cjs +731 -0
- package/dist/header-EkGKXPsD.js +715 -0
- package/dist/header-WfEywpyc.cjs +731 -0
- package/dist/header-tifNQn2U.js +715 -0
- package/dist/hooks.cjs.js +9 -2
- package/dist/hooks.es.js +10 -3
- package/dist/index-BhapVLVj.js +8 -0
- package/dist/{index-D3RLKRAs.cjs → index-COtD8bRW.cjs} +1 -1
- package/dist/index-D6fxYEY8.cjs +7 -0
- package/dist/index-DW5tYe26.js +8 -0
- package/dist/index.cjs.js +54 -40
- package/dist/index.es.js +259 -245
- package/dist/index.umd.js +1043 -470
- package/dist/input-2R4loU86.js +127 -0
- package/dist/input-DWANSKGb.cjs +145 -0
- package/dist/layout.cjs.js +1 -1
- package/dist/layout.es.js +1 -1
- package/dist/media.cjs.js +1 -1
- package/dist/media.es.js +1 -1
- package/dist/pages.cjs.js +1 -1
- package/dist/pages.es.js +1 -1
- package/dist/progress-DPtzoVV8.js +175 -0
- package/dist/progress-EeaoqqUs.cjs +191 -0
- package/dist/rich-text-editor-0mraWT5y.cjs +2376 -0
- package/dist/rich-text-editor-B6jMRLzk.cjs +1939 -0
- package/dist/rich-text-editor-B8_oYcIR.js +1730 -0
- package/dist/rich-text-editor-B9UbSXNb.js +1203 -0
- package/dist/rich-text-editor-BYuRBNBU.js +2373 -0
- package/dist/rich-text-editor-Bb9pySTs.cjs +2374 -0
- package/dist/rich-text-editor-BcL6L3cm.cjs +2374 -0
- package/dist/rich-text-editor-BoVZYtTs.cjs +2391 -0
- package/dist/rich-text-editor-CMgSN_w2.js +1189 -0
- package/dist/rich-text-editor-CPV1lEPH.cjs +1748 -0
- package/dist/rich-text-editor-CoKqbCtu.cjs +1799 -0
- package/dist/rich-text-editor-Cw56T_mB.js +2356 -0
- package/dist/rich-text-editor-Cyt8qs2b.js +1921 -0
- package/dist/rich-text-editor-D6H84OcX.cjs +1220 -0
- package/dist/rich-text-editor-D76gD-QI.js +2328 -0
- package/dist/rich-text-editor-DKkokOnA.js +1781 -0
- package/dist/rich-text-editor-DNsdpN64.cjs +2359 -0
- package/dist/rich-text-editor-DfG8bCyY.js +2358 -0
- package/dist/rich-text-editor-Dxjw31Z4.js +2341 -0
- package/dist/rich-text-editor-DzP0Epmb.js +2356 -0
- package/dist/rich-text-editor-lyYE2ZG5.cjs +1207 -0
- package/dist/rich-text-editor-skplNlBM.cjs +2345 -0
- package/dist/select-Bkbr0f-Z.cjs +162 -0
- package/dist/select-CvIVdX2n.js +145 -0
- package/dist/{sidebar-CmvwjnVb.js → sidebar-BViy8Eeu.js} +17 -9
- package/dist/{sidebar-CVUGHOS_.cjs → sidebar-BxGXsDAd.cjs} +16 -8
- package/dist/sidebar-CK_0ZQHj.cjs +803 -0
- package/dist/sidebar-CUuOvYhK.js +787 -0
- package/dist/slider-Bc5Hd0y1.js +56 -0
- package/dist/slider-N7hFFj6X.cjs +73 -0
- package/dist/tooltip-Ded96neP.cjs +137 -0
- package/dist/tooltip-HDOoD2-0.js +120 -0
- package/dist/ui.cjs.js +48 -34
- package/dist/ui.es.js +237 -223
- package/dist/{use-audio-player-Dn1NR9xN.cjs → use-audio-player-NKsWyjWu.cjs} +7 -3
- package/dist/{use-audio-player-Bkh23vQ3.js → use-audio-player-nv8ZSGa1.js} +7 -3
- package/dist/use-file-upload-BcjEo2S5.js +404 -0
- package/dist/use-file-upload-CRJR68Tj.cjs +403 -0
- package/dist/use-mobile-B0hNy_Y6.cjs +4303 -0
- package/dist/{AssistantChart-CVko2A1W.js → use-mobile-BXuYROXM.js} +1025 -171
- package/dist/use-mobile-Bbd51ASU.cjs +4392 -0
- package/dist/use-mobile-Bk6CX-TC.js +4359 -0
- package/dist/use-mobile-BvYdisLP.js +4202 -0
- package/dist/use-mobile-BzuxjzNX.cjs +4392 -0
- package/dist/{AssistantChart-BAx9VQvb.cjs → use-mobile-CG2-SdXV.cjs} +1070 -209
- package/dist/use-mobile-CKb5pqTs.js +4269 -0
- package/dist/use-mobile-CYuAuGDl.js +4202 -0
- package/dist/use-mobile-CaENcqm-.js +4508 -0
- package/dist/use-mobile-CbrYgJGJ.js +4203 -0
- package/dist/use-mobile-DMOvImGQ.cjs +4542 -0
- package/dist/use-mobile-DRB3BQgD.cjs +4235 -0
- package/dist/use-mobile-DZvv7QMR.js +4359 -0
- package/dist/use-mobile-DdI_TXam.cjs +4235 -0
- package/dist/use-mobile-DlceKf8a.js +4359 -0
- package/dist/use-mobile-DsOnow1o.cjs +4236 -0
- package/dist/use-mobile-Kcj6jSnK.cjs +4392 -0
- package/dist/use-mobile-bnKcua_i.js +4202 -0
- package/dist/use-mobile-ncXBeE2z.cjs +4235 -0
- package/dist/use-rich-text-editor-DjiddBGv.js +282 -0
- package/dist/use-rich-text-editor-lpeswbCs.cjs +281 -0
- package/dist/{xertica-assistant-BMqdyRVi.js → xertica-assistant-BdiZag0h.js} +232 -127
- package/dist/{xertica-assistant-Bj3vBCq_.cjs → xertica-assistant-DUBpmEgo.cjs} +231 -126
- package/dist/{xertica-assistant-B1IaHXnB.cjs → xertica-assistant-dyP7KHM5.cjs} +533 -392
- package/dist/{xertica-assistant-DPsESB6t.js → xertica-assistant-yX1CFBBo.js} +535 -394
- package/dist/xertica-ui.css +2 -2
- package/docs/components/calendar.md +154 -154
- package/docs/components/card-patterns.md +337 -337
- package/docs/components/card.md +235 -235
- package/docs/components/chart.md +11 -0
- package/docs/components/file-upload.md +15 -9
- package/docs/components/hooks.md +479 -0
- package/docs/components/map.md +84 -84
- package/docs/components/pagination.md +16 -5
- package/docs/components/rich-text-editor.md +2 -1
- package/docs/components/sidebar.md +43 -11
- package/docs/components/stepper.md +1 -0
- package/docs/components/tree-view.md +3 -2
- package/docs/components/xertica-provider.md +24 -24
- package/docs/decision-tree.md +287 -287
- package/guidelines/Guidelines.md +252 -252
- package/hooks/useTheme.ts +3 -3
- package/imports/Podcast.tsx +388 -388
- package/imports/XerticaAi.tsx +45 -45
- package/imports/XerticaX.tsx +19 -19
- package/imports/svg-aueiaqngck.ts +11 -11
- package/imports/svg-v9krss1ozd.ts +16 -16
- package/imports/svg-vhrdofe3qe.ts +5 -5
- package/llms-compact.txt +376 -327
- package/llms-full.txt +8 -3
- package/llms.txt +160 -160
- package/package.json +203 -203
- package/styles/xertica/app-overrides/chat.css +61 -61
- package/styles/xertica/app-overrides/scrollbar.css +33 -33
- package/styles/xertica/integrations/google-maps.css +76 -76
- package/styles/xertica/integrations/sonner.css +73 -73
- package/templates/CLAUDE.md +231 -182
- package/templates/README.md +152 -0
- package/templates/guidelines/Guidelines.md +560 -325
- package/templates/package.json +5 -2
- package/templates/src/app/App.tsx +6 -1
- package/templates/src/app/components/AppLayout.tsx +7 -5
- package/templates/src/app/components/AuthGuard.tsx +53 -30
- package/templates/src/features/auth/index.ts +4 -4
- package/templates/src/features/auth/ui/AuthPageShell.tsx +34 -34
- package/templates/src/features/auth/ui/ForgotPasswordContent.tsx +68 -70
- package/templates/src/features/auth/ui/LoginContent.tsx +91 -90
- package/templates/src/features/auth/ui/ResetPasswordContent.tsx +152 -151
- package/templates/src/features/auth/ui/SocialLoginButtons.tsx +59 -59
- package/templates/src/features/auth/ui/VerifyEmailContent.tsx +80 -82
- package/templates/src/features/home/index.ts +1 -1
- package/templates/src/features/home/ui/HomeContent.tsx +119 -100
- package/templates/src/features/settings/index.ts +1 -0
- package/templates/src/features/settings/ui/SettingsContent.tsx +210 -0
- package/templates/src/features/template/index.ts +5 -5
- package/templates/src/features/template/ui/CrudTemplate.tsx +268 -106
- package/templates/src/features/template/ui/DashboardTemplate.tsx +201 -101
- package/templates/src/features/template/ui/FormTemplate.tsx +227 -120
- package/templates/src/features/template/ui/LoginTemplate.tsx +4 -6
- package/templates/src/pages/AssistantPage.tsx +333 -328
- package/templates/src/pages/ForgotPasswordPage.tsx +6 -6
- package/templates/src/pages/HomePage.tsx +47 -57
- package/templates/src/pages/LoginPage.tsx +10 -10
- package/templates/src/pages/NotFoundPage.tsx +29 -0
- package/templates/src/pages/ResetPasswordPage.tsx +6 -6
- package/templates/src/pages/SettingsPage.tsx +21 -0
- package/templates/src/pages/TemplatePage.tsx +30 -30
- package/templates/src/pages/VerifyEmailPage.tsx +6 -6
- package/templates/src/shared/config/assistant.ts +20 -0
- package/templates/src/shared/config/navigation.ts +21 -20
- package/templates/src/shared/lib/api.ts +79 -0
- package/templates/src/shared/lib/auth.ts +31 -20
- package/templates/src/shared/types/auth.ts +9 -3
- package/templates/src/shared/ui/PageContent.tsx +35 -0
- package/templates/src/styles/index.css +2 -2
- package/templates/src/vite-env.d.ts +12 -0
- package/templates/tsconfig.json +5 -5
- package/utils/gemini.ts +140 -140
- package/dist/VerifyEmailPage-BE-L9mB7.js +0 -2828
- package/dist/VerifyEmailPage-CR7kb5df.cjs +0 -2827
- package/dist/index-CkTUgOwX.js +0 -8
- package/dist/{rich-text-editor-BmsjY03B.js → rich-text-editor-DgF8s7xW.js} +26 -26
- package/dist/{rich-text-editor-GS2kpTAK.cjs → rich-text-editor-mWoaSCE4.cjs} +26 -26
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { useState, useRef, useCallback, useEffect } from 'react';
|
|
2
|
+
import { toast } from 'sonner';
|
|
3
|
+
import { gerarResposta } from '../../../shared/assistant-utils';
|
|
4
|
+
import type { Message, Suggestion, MockResponse } from '../types';
|
|
5
|
+
|
|
6
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
// Props & Return types
|
|
8
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
9
|
+
|
|
10
|
+
export interface UseAssistantMessagesProps {
|
|
11
|
+
initialMessages?: Message[];
|
|
12
|
+
isProcessing?: boolean;
|
|
13
|
+
demoMode?: boolean;
|
|
14
|
+
customResponses?: MockResponse[];
|
|
15
|
+
responseGenerator?: (message: string) => Promise<string | Partial<Message>> | string | Partial<Message>;
|
|
16
|
+
onSendMessage?: (message: string) => void;
|
|
17
|
+
onEvaluation?: (messageId: string, type: 'like' | 'dislike', reason?: string) => void;
|
|
18
|
+
/** Current tab — used to drive auto-scroll */
|
|
19
|
+
abaSelecionada: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface EvaluationState {
|
|
23
|
+
isOpen: boolean;
|
|
24
|
+
messageId: string | null;
|
|
25
|
+
type: 'dislike' | null;
|
|
26
|
+
category?: string | null;
|
|
27
|
+
reason: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface UseAssistantMessagesReturn {
|
|
31
|
+
mensagens: Message[];
|
|
32
|
+
setMensagens: React.Dispatch<React.SetStateAction<Message[]>>;
|
|
33
|
+
mensagem: string;
|
|
34
|
+
setMensagem: (value: string) => void;
|
|
35
|
+
copiedId: string | null;
|
|
36
|
+
generatingPodcastId: string | null;
|
|
37
|
+
editingDocument: { content: string; title: string } | null;
|
|
38
|
+
setEditingDocument: (doc: { content: string; title: string } | null) => void;
|
|
39
|
+
evaluationState: EvaluationState;
|
|
40
|
+
setEvaluationState: React.Dispatch<React.SetStateAction<EvaluationState>>;
|
|
41
|
+
messagesEndRef: React.RefObject<HTMLDivElement>;
|
|
42
|
+
handleEnviarMensagem: (arg?: string) => Promise<void>;
|
|
43
|
+
handleToggleFavorite: (messageId: string) => void;
|
|
44
|
+
handleCopyMessage: (content: string, messageId: string) => Promise<void>;
|
|
45
|
+
handleGeneratePodcast: (messageId: string, content: string) => Promise<void>;
|
|
46
|
+
handleDownloadDocument: (content: string, fileName: string) => void;
|
|
47
|
+
handleDownloadPodcast: (audioUrl: string, fileName: string) => void;
|
|
48
|
+
handleEditDocument: (content: string, title: string) => void;
|
|
49
|
+
handleEvaluationClick: (messageId: string, type: 'like' | 'dislike') => void;
|
|
50
|
+
openFeedbackDialog: (messageId: string, category: string | null) => void;
|
|
51
|
+
handleSubmitDislike: () => void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
55
|
+
// Hook
|
|
56
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
57
|
+
|
|
58
|
+
export function useAssistantMessages({
|
|
59
|
+
initialMessages = [],
|
|
60
|
+
isProcessing = false,
|
|
61
|
+
demoMode = true,
|
|
62
|
+
customResponses = [],
|
|
63
|
+
responseGenerator,
|
|
64
|
+
onSendMessage,
|
|
65
|
+
onEvaluation,
|
|
66
|
+
abaSelecionada,
|
|
67
|
+
}: UseAssistantMessagesProps): UseAssistantMessagesReturn {
|
|
68
|
+
|
|
69
|
+
const [mensagens, setMensagens] = useState<Message[]>(initialMessages);
|
|
70
|
+
const [mensagem, setMensagem] = useState('');
|
|
71
|
+
const [copiedId, setCopiedId] = useState<string | null>(null);
|
|
72
|
+
const [generatingPodcastId, setGeneratingPodcastId] = useState<string | null>(null);
|
|
73
|
+
const [editingDocument, setEditingDocument] = useState<{ content: string; title: string } | null>(null);
|
|
74
|
+
const [evaluationState, setEvaluationState] = useState<EvaluationState>({
|
|
75
|
+
isOpen: false,
|
|
76
|
+
messageId: null,
|
|
77
|
+
type: null,
|
|
78
|
+
category: null,
|
|
79
|
+
reason: '',
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const messagesEndRef = useRef<HTMLDivElement>(null);
|
|
83
|
+
|
|
84
|
+
// Ref to cancel the AI response timer when the component unmounts (UM-1)
|
|
85
|
+
const responseTimerRef = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
|
|
86
|
+
useEffect(() => () => clearTimeout(responseTimerRef.current), []);
|
|
87
|
+
|
|
88
|
+
// Auto-scroll only when the user is already near the bottom (UM-5).
|
|
89
|
+
// Firing unconditionally would forcibly scroll users who have scrolled up to read history.
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
if (abaSelecionada !== 'chat' || !messagesEndRef.current) return;
|
|
92
|
+
const viewport = messagesEndRef.current.closest('[data-radix-scroll-area-viewport]')
|
|
93
|
+
?? messagesEndRef.current.parentElement;
|
|
94
|
+
if (viewport) {
|
|
95
|
+
const nearBottom =
|
|
96
|
+
viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight < 120;
|
|
97
|
+
if (nearBottom) messagesEndRef.current.scrollIntoView({ behavior: 'smooth' });
|
|
98
|
+
} else {
|
|
99
|
+
// Fallback when no scroll container is found
|
|
100
|
+
messagesEndRef.current.scrollIntoView({ behavior: 'smooth' });
|
|
101
|
+
}
|
|
102
|
+
}, [mensagens, abaSelecionada]);
|
|
103
|
+
|
|
104
|
+
// Sync initial messages exactly once on mount (UM-3).
|
|
105
|
+
// Using a ref guard prevents the effect from resetting the conversation every
|
|
106
|
+
// time the parent re-renders and passes a new array reference.
|
|
107
|
+
const hydratedRef = useRef(false);
|
|
108
|
+
useEffect(() => {
|
|
109
|
+
if (!hydratedRef.current && initialMessages.length > 0) {
|
|
110
|
+
setMensagens(initialMessages);
|
|
111
|
+
hydratedRef.current = true;
|
|
112
|
+
}
|
|
113
|
+
}, [initialMessages]);
|
|
114
|
+
|
|
115
|
+
const handleEnviarMensagem = useCallback(async (arg?: string) => {
|
|
116
|
+
let msgToSend = mensagem;
|
|
117
|
+
|
|
118
|
+
if (typeof arg === 'string' && !['document', 'podcast', 'search'].includes(arg)) {
|
|
119
|
+
msgToSend = arg;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (!msgToSend.trim() || isProcessing) return;
|
|
123
|
+
|
|
124
|
+
const novaMensagem: Message = {
|
|
125
|
+
id: `msg-${Date.now()}`,
|
|
126
|
+
type: 'user',
|
|
127
|
+
content: msgToSend,
|
|
128
|
+
timestamp: new Date(),
|
|
129
|
+
isFavorite: false,
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
setMensagens(prev => [...prev, novaMensagem]);
|
|
133
|
+
|
|
134
|
+
if (onSendMessage) {
|
|
135
|
+
onSendMessage(msgToSend);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (demoMode || responseGenerator) {
|
|
139
|
+
const mensagemAtual = msgToSend;
|
|
140
|
+
responseTimerRef.current = setTimeout(async () => {
|
|
141
|
+
let resposta: string | Partial<Message>;
|
|
142
|
+
|
|
143
|
+
if (responseGenerator) {
|
|
144
|
+
resposta = await responseGenerator(mensagemAtual);
|
|
145
|
+
} else {
|
|
146
|
+
resposta = gerarResposta(mensagemAtual, customResponses);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
let novaMensagemIA: Message = {
|
|
150
|
+
id: `msg-${Date.now()}-ia`,
|
|
151
|
+
type: 'assistant',
|
|
152
|
+
content: '',
|
|
153
|
+
timestamp: new Date(),
|
|
154
|
+
isFavorite: false,
|
|
155
|
+
};
|
|
156
|
+
|
|
157
|
+
if (typeof resposta === 'string') {
|
|
158
|
+
novaMensagemIA.content = resposta;
|
|
159
|
+
} else {
|
|
160
|
+
novaMensagemIA = { ...novaMensagemIA, ...resposta };
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
setMensagens(prev => [...prev, novaMensagemIA]);
|
|
164
|
+
}, 1000 + Math.random() * 1000);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
setMensagem('');
|
|
168
|
+
}, [mensagem, isProcessing, onSendMessage, demoMode, responseGenerator, customResponses]);
|
|
169
|
+
|
|
170
|
+
const handleToggleFavorite = useCallback((messageId: string) => {
|
|
171
|
+
setMensagens(prev =>
|
|
172
|
+
prev.map(msg =>
|
|
173
|
+
msg.id === messageId ? { ...msg, isFavorite: !msg.isFavorite } : msg
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
}, []);
|
|
177
|
+
|
|
178
|
+
const handleCopyMessage = useCallback(async (content: string, messageId: string) => {
|
|
179
|
+
try {
|
|
180
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
181
|
+
try {
|
|
182
|
+
await navigator.clipboard.writeText(content);
|
|
183
|
+
setCopiedId(messageId);
|
|
184
|
+
setTimeout(() => setCopiedId(null), 2000);
|
|
185
|
+
} catch (clipboardError: any) {
|
|
186
|
+
if (clipboardError.name === 'NotAllowedError' || clipboardError.message.includes('permissions policy')) {
|
|
187
|
+
throw new Error('Clipboard permission denied, falling back');
|
|
188
|
+
}
|
|
189
|
+
throw clipboardError;
|
|
190
|
+
}
|
|
191
|
+
} else {
|
|
192
|
+
throw new Error('Clipboard API not available');
|
|
193
|
+
}
|
|
194
|
+
} catch {
|
|
195
|
+
try {
|
|
196
|
+
const textArea = document.createElement('textarea');
|
|
197
|
+
textArea.value = content;
|
|
198
|
+
textArea.style.position = 'fixed';
|
|
199
|
+
textArea.style.left = '-999999px';
|
|
200
|
+
textArea.style.top = '-999999px';
|
|
201
|
+
document.body.appendChild(textArea);
|
|
202
|
+
textArea.focus();
|
|
203
|
+
textArea.select();
|
|
204
|
+
const successful = document.execCommand('copy');
|
|
205
|
+
document.body.removeChild(textArea);
|
|
206
|
+
if (successful) {
|
|
207
|
+
setCopiedId(messageId);
|
|
208
|
+
setTimeout(() => setCopiedId(null), 2000);
|
|
209
|
+
}
|
|
210
|
+
} catch (fallbackErr) {
|
|
211
|
+
console.error('Falha ao copiar:', fallbackErr);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}, []);
|
|
215
|
+
|
|
216
|
+
const handleGeneratePodcast = useCallback(async (messageId: string, content: string) => {
|
|
217
|
+
setGeneratingPodcastId(messageId);
|
|
218
|
+
setTimeout(() => {
|
|
219
|
+
setMensagens(prev =>
|
|
220
|
+
prev.map(msg =>
|
|
221
|
+
msg.id === messageId
|
|
222
|
+
? {
|
|
223
|
+
...msg,
|
|
224
|
+
attachmentType: 'podcast' as const,
|
|
225
|
+
attachmentName: 'Podcast - ' + content.substring(0, 30) + '...',
|
|
226
|
+
audioUrl: 'data:audio/mpeg;base64,//uQx...',
|
|
227
|
+
}
|
|
228
|
+
: msg
|
|
229
|
+
)
|
|
230
|
+
);
|
|
231
|
+
setGeneratingPodcastId(null);
|
|
232
|
+
}, 2000);
|
|
233
|
+
}, []);
|
|
234
|
+
|
|
235
|
+
const handleDownloadDocument = useCallback((content: string, fileName: string) => {
|
|
236
|
+
const blob = new Blob([content], { type: 'text/markdown' });
|
|
237
|
+
const url = URL.createObjectURL(blob);
|
|
238
|
+
const a = document.createElement('a');
|
|
239
|
+
a.href = url;
|
|
240
|
+
a.download = fileName.endsWith('.md') ? fileName : fileName + '.md';
|
|
241
|
+
document.body.appendChild(a);
|
|
242
|
+
a.click();
|
|
243
|
+
document.body.removeChild(a);
|
|
244
|
+
URL.revokeObjectURL(url);
|
|
245
|
+
}, []);
|
|
246
|
+
|
|
247
|
+
const handleDownloadPodcast = useCallback((audioUrl: string, fileName: string) => {
|
|
248
|
+
const a = document.createElement('a');
|
|
249
|
+
a.href = audioUrl;
|
|
250
|
+
a.download = fileName.endsWith('.mp3') ? fileName : fileName + '.mp3';
|
|
251
|
+
document.body.appendChild(a);
|
|
252
|
+
a.click();
|
|
253
|
+
document.body.removeChild(a);
|
|
254
|
+
}, []);
|
|
255
|
+
|
|
256
|
+
const handleEditDocument = useCallback((content: string, title: string) => {
|
|
257
|
+
setEditingDocument({ content, title });
|
|
258
|
+
}, []);
|
|
259
|
+
|
|
260
|
+
const handleEvaluationClick = useCallback((messageId: string, type: 'like' | 'dislike') => {
|
|
261
|
+
if (type === 'like') {
|
|
262
|
+
if (onEvaluation) onEvaluation(messageId, 'like');
|
|
263
|
+
setMensagens(prev => prev.map(m => m.id === messageId ? { ...m, evaluation: 'like' as const } : m));
|
|
264
|
+
toast.success("Obrigado por avaliar positivamente!");
|
|
265
|
+
}
|
|
266
|
+
}, [onEvaluation]);
|
|
267
|
+
|
|
268
|
+
const openFeedbackDialog = useCallback((messageId: string, category: string | null) => {
|
|
269
|
+
setEvaluationState({
|
|
270
|
+
isOpen: true,
|
|
271
|
+
messageId,
|
|
272
|
+
type: 'dislike',
|
|
273
|
+
category,
|
|
274
|
+
reason: '',
|
|
275
|
+
});
|
|
276
|
+
}, []);
|
|
277
|
+
|
|
278
|
+
const handleSubmitDislike = useCallback(() => {
|
|
279
|
+
if (evaluationState.messageId) {
|
|
280
|
+
const finalReason = evaluationState.category
|
|
281
|
+
? (evaluationState.reason ? `${evaluationState.category}: ${evaluationState.reason}` : evaluationState.category)
|
|
282
|
+
: evaluationState.reason;
|
|
283
|
+
|
|
284
|
+
if (onEvaluation) {
|
|
285
|
+
onEvaluation(evaluationState.messageId, 'dislike', finalReason);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
setMensagens(prev =>
|
|
289
|
+
prev.map(m =>
|
|
290
|
+
m.id === evaluationState.messageId
|
|
291
|
+
? { ...m, evaluation: 'dislike' as const, evaluationReason: finalReason }
|
|
292
|
+
: m
|
|
293
|
+
)
|
|
294
|
+
);
|
|
295
|
+
toast.success("Obrigado pelo seu feedback. Vamos melhorar.");
|
|
296
|
+
}
|
|
297
|
+
setEvaluationState({ isOpen: false, messageId: null, type: null, category: null, reason: '' });
|
|
298
|
+
}, [evaluationState, onEvaluation]);
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
mensagens,
|
|
302
|
+
setMensagens,
|
|
303
|
+
mensagem,
|
|
304
|
+
setMensagem,
|
|
305
|
+
copiedId,
|
|
306
|
+
generatingPodcastId,
|
|
307
|
+
editingDocument,
|
|
308
|
+
setEditingDocument,
|
|
309
|
+
evaluationState,
|
|
310
|
+
setEvaluationState,
|
|
311
|
+
messagesEndRef,
|
|
312
|
+
handleEnviarMensagem,
|
|
313
|
+
handleToggleFavorite,
|
|
314
|
+
handleCopyMessage,
|
|
315
|
+
handleGeneratePodcast,
|
|
316
|
+
handleDownloadDocument,
|
|
317
|
+
handleDownloadPodcast,
|
|
318
|
+
handleEditDocument,
|
|
319
|
+
handleEvaluationClick,
|
|
320
|
+
openFeedbackDialog,
|
|
321
|
+
handleSubmitDislike,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { useState, useCallback } from 'react';
|
|
2
|
+
import type { Suggestion } from '../types';
|
|
3
|
+
|
|
4
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
5
|
+
// Default suggestions
|
|
6
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
7
|
+
|
|
8
|
+
export const DEFAULT_SUGGESTIONS: Suggestion[] = [
|
|
9
|
+
{ id: '1', text: 'Me ajude a criar um documento profissional' },
|
|
10
|
+
{ id: '2', text: 'Buscar nos meus arquivos por "relatório"' },
|
|
11
|
+
{ id: '3', text: 'Resuma as conversas importantes desta semana' },
|
|
12
|
+
{ id: '4', text: 'Crie um podcast sobre o último projeto' },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
16
|
+
// Props & Return types
|
|
17
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
18
|
+
|
|
19
|
+
export interface UseAssistantSuggestionsProps {
|
|
20
|
+
suggestions?: Suggestion[];
|
|
21
|
+
richSuggestions?: Suggestion[];
|
|
22
|
+
onRichAction?: (actionId: string, actionText: string) => void;
|
|
23
|
+
/** handleEnviarMensagem from useAssistantMessages, passed in to avoid circular deps */
|
|
24
|
+
handleEnviarMensagem: (arg?: string | any) => Promise<void>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface UseAssistantSuggestionsReturn {
|
|
28
|
+
sugestoes: Suggestion[];
|
|
29
|
+
showMoreSuggestions: boolean;
|
|
30
|
+
setShowMoreSuggestions: (show: boolean) => void;
|
|
31
|
+
handleRichSuggestionClick: (suggestion: Suggestion) => void;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
35
|
+
// Hook
|
|
36
|
+
// ─────────────────────────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
export function useAssistantSuggestions({
|
|
39
|
+
suggestions,
|
|
40
|
+
richSuggestions = [],
|
|
41
|
+
onRichAction,
|
|
42
|
+
handleEnviarMensagem,
|
|
43
|
+
}: UseAssistantSuggestionsProps): UseAssistantSuggestionsReturn {
|
|
44
|
+
|
|
45
|
+
const [showMoreSuggestions, setShowMoreSuggestions] = useState(false);
|
|
46
|
+
|
|
47
|
+
const sugestoes = suggestions ?? DEFAULT_SUGGESTIONS;
|
|
48
|
+
|
|
49
|
+
const handleRichSuggestionClick = useCallback((suggestion: Suggestion) => {
|
|
50
|
+
if (onRichAction) {
|
|
51
|
+
onRichAction(suggestion.id, suggestion.text);
|
|
52
|
+
} else {
|
|
53
|
+
handleEnviarMensagem(suggestion.text);
|
|
54
|
+
}
|
|
55
|
+
setShowMoreSuggestions(false);
|
|
56
|
+
}, [onRichAction, handleEnviarMensagem]);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
sugestoes,
|
|
60
|
+
showMoreSuggestions,
|
|
61
|
+
setShowMoreSuggestions,
|
|
62
|
+
handleRichSuggestionClick,
|
|
63
|
+
};
|
|
64
|
+
}
|