@regardio/react 0.3.2
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/LICENSE +9 -0
- package/README.md +133 -0
- package/dist/components/background-slideshow.d.ts +22 -0
- package/dist/components/background-slideshow.d.ts.map +1 -0
- package/dist/components/background-slideshow.js +76 -0
- package/dist/components/blurry-gradient.d.ts +9 -0
- package/dist/components/blurry-gradient.d.ts.map +1 -0
- package/dist/components/blurry-gradient.js +6 -0
- package/dist/components/box.d.ts +17 -0
- package/dist/components/box.d.ts.map +1 -0
- package/dist/components/box.js +25 -0
- package/dist/components/carousel.d.ts +26 -0
- package/dist/components/carousel.d.ts.map +1 -0
- package/dist/components/carousel.js +87 -0
- package/dist/components/countdown.d.ts +2 -0
- package/dist/components/countdown.d.ts.map +1 -0
- package/dist/components/countdown.js +48 -0
- package/dist/components/definition-list.d.ts +40 -0
- package/dist/components/definition-list.d.ts.map +1 -0
- package/dist/components/definition-list.js +57 -0
- package/dist/components/generic-error.d.ts +23 -0
- package/dist/components/generic-error.d.ts.map +1 -0
- package/dist/components/generic-error.js +39 -0
- package/dist/components/heading.d.ts +24 -0
- package/dist/components/heading.d.ts.map +1 -0
- package/dist/components/heading.js +29 -0
- package/dist/components/highlight.d.ts +16 -0
- package/dist/components/highlight.d.ts.map +1 -0
- package/dist/components/highlight.js +19 -0
- package/dist/components/icon-button.d.ts +6 -0
- package/dist/components/icon-button.d.ts.map +1 -0
- package/dist/components/icon-button.js +6 -0
- package/dist/components/if.d.ts +8 -0
- package/dist/components/if.d.ts.map +1 -0
- package/dist/components/if.js +16 -0
- package/dist/components/iframe.d.ts +8 -0
- package/dist/components/iframe.d.ts.map +1 -0
- package/dist/components/iframe.js +3 -0
- package/dist/components/item.d.ts +67 -0
- package/dist/components/item.d.ts.map +1 -0
- package/dist/components/item.js +309 -0
- package/dist/components/leaflet-map.d.ts +33 -0
- package/dist/components/leaflet-map.d.ts.map +1 -0
- package/dist/components/leaflet-map.js +195 -0
- package/dist/components/link.d.ts +41 -0
- package/dist/components/link.d.ts.map +1 -0
- package/dist/components/link.js +111 -0
- package/dist/components/link.test.d.ts +2 -0
- package/dist/components/link.test.d.ts.map +1 -0
- package/dist/components/link.test.js +204 -0
- package/dist/components/list-item.d.ts +16 -0
- package/dist/components/list-item.d.ts.map +1 -0
- package/dist/components/list-item.js +19 -0
- package/dist/components/maptiler-map.d.ts +26 -0
- package/dist/components/maptiler-map.d.ts.map +1 -0
- package/dist/components/maptiler-map.js +116 -0
- package/dist/components/markdown-container.d.ts +20 -0
- package/dist/components/markdown-container.d.ts.map +1 -0
- package/dist/components/markdown-container.js +93 -0
- package/dist/components/password-input.d.ts +9 -0
- package/dist/components/password-input.d.ts.map +1 -0
- package/dist/components/password-input.js +13 -0
- package/dist/components/picture.d.ts +26 -0
- package/dist/components/picture.d.ts.map +1 -0
- package/dist/components/picture.js +36 -0
- package/dist/components/protected-email.d.ts +9 -0
- package/dist/components/protected-email.d.ts.map +1 -0
- package/dist/components/protected-email.js +16 -0
- package/dist/components/text.d.ts +17 -0
- package/dist/components/text.d.ts.map +1 -0
- package/dist/components/text.js +27 -0
- package/dist/components/unordered-list.d.ts +16 -0
- package/dist/components/unordered-list.d.ts.map +1 -0
- package/dist/components/unordered-list.js +21 -0
- package/dist/hooks/use-current-route-data.d.ts +2 -0
- package/dist/hooks/use-current-route-data.d.ts.map +1 -0
- package/dist/hooks/use-current-route-data.js +12 -0
- package/dist/hooks/use-focus-search.d.ts +3 -0
- package/dist/hooks/use-focus-search.d.ts.map +1 -0
- package/dist/hooks/use-focus-search.js +15 -0
- package/dist/hooks/use-matches-data.d.ts +2 -0
- package/dist/hooks/use-matches-data.d.ts.map +1 -0
- package/dist/hooks/use-matches-data.js +11 -0
- package/dist/hooks/use-media-query.d.ts +2 -0
- package/dist/hooks/use-media-query.d.ts.map +1 -0
- package/dist/hooks/use-media-query.js +16 -0
- package/dist/hooks/use-mobile.d.ts +2 -0
- package/dist/hooks/use-mobile.d.ts.map +1 -0
- package/dist/hooks/use-mobile.js +15 -0
- package/dist/hooks/use-nonce.d.ts +5 -0
- package/dist/hooks/use-nonce.d.ts.map +1 -0
- package/dist/hooks/use-nonce.js +9 -0
- package/dist/hooks/use-nonce.test.d.ts +2 -0
- package/dist/hooks/use-nonce.test.d.ts.map +1 -0
- package/dist/hooks/use-nonce.test.js +27 -0
- package/dist/hooks/use-orientation.d.ts +3 -0
- package/dist/hooks/use-orientation.d.ts.map +1 -0
- package/dist/hooks/use-orientation.js +25 -0
- package/dist/hooks/use-user.d.ts +15 -0
- package/dist/hooks/use-user.d.ts.map +1 -0
- package/dist/hooks/use-user.js +17 -0
- package/dist/shadcn/accordion.d.ts +25 -0
- package/dist/shadcn/accordion.d.ts.map +1 -0
- package/dist/shadcn/accordion.js +45 -0
- package/dist/shadcn/alert-dialog.d.ts +73 -0
- package/dist/shadcn/alert-dialog.d.ts.map +1 -0
- package/dist/shadcn/alert-dialog.js +93 -0
- package/dist/shadcn/alert.d.ts +34 -0
- package/dist/shadcn/alert.d.ts.map +1 -0
- package/dist/shadcn/alert.js +42 -0
- package/dist/shadcn/aspect-ratio.d.ts +6 -0
- package/dist/shadcn/aspect-ratio.d.ts.map +1 -0
- package/dist/shadcn/aspect-ratio.js +7 -0
- package/dist/shadcn/avatar.d.ts +16 -0
- package/dist/shadcn/avatar.d.ts.map +1 -0
- package/dist/shadcn/avatar.js +27 -0
- package/dist/shadcn/badge.d.ts +29 -0
- package/dist/shadcn/badge.d.ts.map +1 -0
- package/dist/shadcn/badge.js +29 -0
- package/dist/shadcn/breadcrumb.d.ts +42 -0
- package/dist/shadcn/breadcrumb.d.ts.map +1 -0
- package/dist/shadcn/breadcrumb.js +74 -0
- package/dist/shadcn/button.d.ts +38 -0
- package/dist/shadcn/button.d.ts.map +1 -0
- package/dist/shadcn/button.js +38 -0
- package/dist/shadcn/calendar.d.ts +23 -0
- package/dist/shadcn/calendar.d.ts.map +1 -0
- package/dist/shadcn/calendar.js +163 -0
- package/dist/shadcn/card.d.ts +31 -0
- package/dist/shadcn/card.d.ts.map +1 -0
- package/dist/shadcn/card.js +55 -0
- package/dist/shadcn/carousel.d.ts +51 -0
- package/dist/shadcn/carousel.d.ts.map +1 -0
- package/dist/shadcn/carousel.js +161 -0
- package/dist/shadcn/chart.d.ts +103 -0
- package/dist/shadcn/chart.d.ts.map +1 -0
- package/dist/shadcn/chart.js +248 -0
- package/dist/shadcn/checkbox.d.ts +8 -0
- package/dist/shadcn/checkbox.d.ts.map +1 -0
- package/dist/shadcn/checkbox.js +22 -0
- package/dist/shadcn/collapsible.d.ts +16 -0
- package/dist/shadcn/collapsible.d.ts.map +1 -0
- package/dist/shadcn/collapsible.js +19 -0
- package/dist/shadcn/command.d.ts +61 -0
- package/dist/shadcn/command.d.ts.map +1 -0
- package/dist/shadcn/command.js +123 -0
- package/dist/shadcn/context-menu.d.ts +107 -0
- package/dist/shadcn/context-menu.d.ts.map +1 -0
- package/dist/shadcn/context-menu.js +151 -0
- package/dist/shadcn/dialog.d.ts +57 -0
- package/dist/shadcn/dialog.d.ts.map +1 -0
- package/dist/shadcn/dialog.js +96 -0
- package/dist/shadcn/drawer.d.ts +54 -0
- package/dist/shadcn/drawer.d.ts.map +1 -0
- package/dist/shadcn/drawer.js +96 -0
- package/dist/shadcn/dropdown-menu.d.ts +110 -0
- package/dist/shadcn/dropdown-menu.d.ts.map +1 -0
- package/dist/shadcn/dropdown-menu.js +152 -0
- package/dist/shadcn/form.d.ts +59 -0
- package/dist/shadcn/form.d.ts.map +1 -0
- package/dist/shadcn/form.js +99 -0
- package/dist/shadcn/hover-card.d.ts +20 -0
- package/dist/shadcn/hover-card.d.ts.map +1 -0
- package/dist/shadcn/hover-card.js +26 -0
- package/dist/shadcn/input-otp.d.ts +25 -0
- package/dist/shadcn/input-otp.d.ts.map +1 -0
- package/dist/shadcn/input-otp.js +54 -0
- package/dist/shadcn/input.d.ts +14 -0
- package/dist/shadcn/input.d.ts.map +1 -0
- package/dist/shadcn/input.js +48 -0
- package/dist/shadcn/label.d.ts +8 -0
- package/dist/shadcn/label.d.ts.map +1 -0
- package/dist/shadcn/label.js +16 -0
- package/dist/shadcn/menubar.d.ts +108 -0
- package/dist/shadcn/menubar.d.ts.map +1 -0
- package/dist/shadcn/menubar.js +174 -0
- package/dist/shadcn/navigation-menu.d.ts +79 -0
- package/dist/shadcn/navigation-menu.d.ts.map +1 -0
- package/dist/shadcn/navigation-menu.js +108 -0
- package/dist/shadcn/pagination.d.ts +45 -0
- package/dist/shadcn/pagination.d.ts.map +1 -0
- package/dist/shadcn/pagination.js +83 -0
- package/dist/shadcn/popover.d.ts +19 -0
- package/dist/shadcn/popover.d.ts.map +1 -0
- package/dist/shadcn/popover.js +29 -0
- package/dist/shadcn/progress.d.ts +9 -0
- package/dist/shadcn/progress.d.ts.map +1 -0
- package/dist/shadcn/progress.js +17 -0
- package/dist/shadcn/radio-group.d.ts +12 -0
- package/dist/shadcn/radio-group.d.ts.map +1 -0
- package/dist/shadcn/radio-group.js +32 -0
- package/dist/shadcn/resizable.d.ts +20 -0
- package/dist/shadcn/resizable.d.ts.map +1 -0
- package/dist/shadcn/resizable.js +32 -0
- package/dist/shadcn/scroll-area.d.ts +16 -0
- package/dist/shadcn/scroll-area.d.ts.map +1 -0
- package/dist/shadcn/scroll-area.js +40 -0
- package/dist/shadcn/select.d.ts +63 -0
- package/dist/shadcn/select.d.ts.map +1 -0
- package/dist/shadcn/select.js +120 -0
- package/dist/shadcn/separator.d.ts +10 -0
- package/dist/shadcn/separator.d.ts.map +1 -0
- package/dist/shadcn/separator.js +18 -0
- package/dist/shadcn/sheet.d.ts +48 -0
- package/dist/shadcn/sheet.d.ts.map +1 -0
- package/dist/shadcn/sheet.js +99 -0
- package/dist/shadcn/sidebar.d.ts +200 -0
- package/dist/shadcn/sidebar.d.ts.map +1 -0
- package/dist/shadcn/sidebar.js +528 -0
- package/dist/shadcn/skeleton.d.ts +6 -0
- package/dist/shadcn/skeleton.d.ts.map +1 -0
- package/dist/shadcn/skeleton.js +11 -0
- package/dist/shadcn/slider.d.ts +12 -0
- package/dist/shadcn/slider.d.ts.map +1 -0
- package/dist/shadcn/slider.js +50 -0
- package/dist/shadcn/sonner.d.ts +7 -0
- package/dist/shadcn/sonner.d.ts.map +1 -0
- package/dist/shadcn/sonner.js +20 -0
- package/dist/shadcn/switch.d.ts +8 -0
- package/dist/shadcn/switch.d.ts.map +1 -0
- package/dist/shadcn/switch.js +22 -0
- package/dist/shadcn/table.d.ts +35 -0
- package/dist/shadcn/table.d.ts.map +1 -0
- package/dist/shadcn/table.js +73 -0
- package/dist/shadcn/tabs.d.ts +20 -0
- package/dist/shadcn/tabs.d.ts.map +1 -0
- package/dist/shadcn/tabs.js +40 -0
- package/dist/shadcn/textarea.d.ts +7 -0
- package/dist/shadcn/textarea.d.ts.map +1 -0
- package/dist/shadcn/textarea.js +14 -0
- package/dist/shadcn/toggle-group.d.ts +22 -0
- package/dist/shadcn/toggle-group.d.ts.map +1 -0
- package/dist/shadcn/toggle-group.js +43 -0
- package/dist/shadcn/toggle.d.ts +29 -0
- package/dist/shadcn/toggle.d.ts.map +1 -0
- package/dist/shadcn/toggle.js +31 -0
- package/dist/shadcn/tooltip.d.ts +20 -0
- package/dist/shadcn/tooltip.d.ts.map +1 -0
- package/dist/shadcn/tooltip.js +40 -0
- package/dist/stories/BackgroundSlideshow.stories.d.ts +9 -0
- package/dist/stories/BackgroundSlideshow.stories.d.ts.map +1 -0
- package/dist/stories/BackgroundSlideshow.stories.js +60 -0
- package/dist/stories/BlurryGradient.stories.d.ts +11 -0
- package/dist/stories/BlurryGradient.stories.d.ts.map +1 -0
- package/dist/stories/BlurryGradient.stories.js +53 -0
- package/dist/stories/Box.stories.d.ts +13 -0
- package/dist/stories/Box.stories.d.ts.map +1 -0
- package/dist/stories/Box.stories.js +50 -0
- package/dist/stories/Carousel.stories.d.ts +9 -0
- package/dist/stories/Carousel.stories.d.ts.map +1 -0
- package/dist/stories/Carousel.stories.js +30 -0
- package/dist/stories/Countdown.stories.d.ts +7 -0
- package/dist/stories/Countdown.stories.d.ts.map +1 -0
- package/dist/stories/Countdown.stories.js +11 -0
- package/dist/stories/DefinitionList.stories.d.ts +9 -0
- package/dist/stories/DefinitionList.stories.d.ts.map +1 -0
- package/dist/stories/DefinitionList.stories.js +20 -0
- package/dist/stories/GenericError.stories.d.ts +9 -0
- package/dist/stories/GenericError.stories.d.ts.map +1 -0
- package/dist/stories/GenericError.stories.js +39 -0
- package/dist/stories/Heading.stories.d.ts +15 -0
- package/dist/stories/Heading.stories.d.ts.map +1 -0
- package/dist/stories/Heading.stories.js +61 -0
- package/dist/stories/Highlight.stories.d.ts +8 -0
- package/dist/stories/Highlight.stories.d.ts.map +1 -0
- package/dist/stories/Highlight.stories.js +19 -0
- package/dist/stories/IconButton.stories.d.ts +10 -0
- package/dist/stories/IconButton.stories.d.ts.map +1 -0
- package/dist/stories/IconButton.stories.js +32 -0
- package/dist/stories/If.stories.d.ts +13 -0
- package/dist/stories/If.stories.d.ts.map +1 -0
- package/dist/stories/If.stories.js +54 -0
- package/dist/stories/Iframe.stories.d.ts +8 -0
- package/dist/stories/Iframe.stories.d.ts.map +1 -0
- package/dist/stories/Iframe.stories.js +23 -0
- package/dist/stories/Item.stories.d.ts +10 -0
- package/dist/stories/Item.stories.d.ts.map +1 -0
- package/dist/stories/Item.stories.js +32 -0
- package/dist/stories/Link.stories.d.ts +10 -0
- package/dist/stories/Link.stories.d.ts.map +1 -0
- package/dist/stories/Link.stories.js +36 -0
- package/dist/stories/ListItem.stories.d.ts +9 -0
- package/dist/stories/ListItem.stories.d.ts.map +1 -0
- package/dist/stories/ListItem.stories.js +25 -0
- package/dist/stories/MarkdownContainer.stories.d.ts +11 -0
- package/dist/stories/MarkdownContainer.stories.d.ts.map +1 -0
- package/dist/stories/MarkdownContainer.stories.js +66 -0
- package/dist/stories/PasswordInput.stories.d.ts +9 -0
- package/dist/stories/PasswordInput.stories.d.ts.map +1 -0
- package/dist/stories/PasswordInput.stories.js +27 -0
- package/dist/stories/Picture.stories.d.ts +10 -0
- package/dist/stories/Picture.stories.d.ts.map +1 -0
- package/dist/stories/Picture.stories.js +46 -0
- package/dist/stories/ProtectedEmail.stories.d.ts +10 -0
- package/dist/stories/ProtectedEmail.stories.d.ts.map +1 -0
- package/dist/stories/ProtectedEmail.stories.js +34 -0
- package/dist/stories/Text.stories.d.ts +10 -0
- package/dist/stories/Text.stories.d.ts.map +1 -0
- package/dist/stories/Text.stories.js +31 -0
- package/dist/stories/UnorderedList.stories.d.ts +10 -0
- package/dist/stories/UnorderedList.stories.d.ts.map +1 -0
- package/dist/stories/UnorderedList.stories.js +24 -0
- package/dist/test-setup.d.ts +2 -0
- package/dist/test-setup.d.ts.map +1 -0
- package/dist/test-setup.js +1 -0
- package/dist/utils/author.d.ts +9 -0
- package/dist/utils/author.d.ts.map +1 -0
- package/dist/utils/author.js +37 -0
- package/dist/utils/author.test.d.ts +2 -0
- package/dist/utils/author.test.d.ts.map +1 -0
- package/dist/utils/author.test.js +46 -0
- package/dist/utils/cn.d.ts +5 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +10 -0
- package/dist/utils/cn.test.d.ts +2 -0
- package/dist/utils/cn.test.d.ts.map +1 -0
- package/dist/utils/cn.test.js +33 -0
- package/dist/utils/is-route-active.d.ts +3 -0
- package/dist/utils/is-route-active.d.ts.map +1 -0
- package/dist/utils/is-route-active.js +54 -0
- package/dist/utils/is-route-active.test.d.ts +2 -0
- package/dist/utils/is-route-active.test.d.ts.map +1 -0
- package/dist/utils/is-route-active.test.js +61 -0
- package/dist/utils/locale.d.ts +22 -0
- package/dist/utils/locale.d.ts.map +1 -0
- package/dist/utils/locale.js +25 -0
- package/dist/utils/locale.test.d.ts +2 -0
- package/dist/utils/locale.test.d.ts.map +1 -0
- package/dist/utils/locale.test.js +99 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.d.ts.map +1 -0
- package/dist/utils/text.js +102 -0
- package/dist/utils/text.test.d.ts +2 -0
- package/dist/utils/text.test.d.ts.map +1 -0
- package/dist/utils/text.test.js +122 -0
- package/package.json +117 -0
- package/src/components/background-slideshow.tsx +172 -0
- package/src/components/blurry-gradient.tsx +97 -0
- package/src/components/box.tsx +45 -0
- package/src/components/carousel.tsx +197 -0
- package/src/components/countdown.tsx +82 -0
- package/src/components/definition-list.tsx +90 -0
- package/src/components/generic-error.tsx +104 -0
- package/src/components/heading.tsx +60 -0
- package/src/components/highlight.tsx +53 -0
- package/src/components/icon-button.tsx +20 -0
- package/src/components/if.tsx +29 -0
- package/src/components/iframe.tsx +19 -0
- package/src/components/item.tsx +340 -0
- package/src/components/leaflet-map.tsx +294 -0
- package/src/components/link.test.tsx +387 -0
- package/src/components/link.tsx +206 -0
- package/src/components/list-item.tsx +30 -0
- package/src/components/maptiler-map.tsx +181 -0
- package/src/components/markdown-container.tsx +153 -0
- package/src/components/password-input.tsx +49 -0
- package/src/components/picture.tsx +107 -0
- package/src/components/protected-email.tsx +49 -0
- package/src/components/text.tsx +38 -0
- package/src/components/unordered-list.tsx +32 -0
- package/src/hooks/use-current-route-data.ts +18 -0
- package/src/hooks/use-focus-search.ts +20 -0
- package/src/hooks/use-matches-data.ts +19 -0
- package/src/hooks/use-media-query.ts +33 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-nonce.test.ts +35 -0
- package/src/hooks/use-nonce.ts +20 -0
- package/src/hooks/use-orientation.ts +48 -0
- package/src/hooks/use-user.tsx +72 -0
- package/src/stories/BackgroundSlideshow.stories.tsx +68 -0
- package/src/stories/BlurryGradient.stories.tsx +62 -0
- package/src/stories/Box.stories.tsx +83 -0
- package/src/stories/Carousel.stories.tsx +95 -0
- package/src/stories/Countdown.stories.tsx +16 -0
- package/src/stories/DefinitionList.stories.tsx +51 -0
- package/src/stories/GenericError.stories.tsx +58 -0
- package/src/stories/Heading.stories.tsx +82 -0
- package/src/stories/Highlight.stories.tsx +28 -0
- package/src/stories/IconButton.stories.tsx +90 -0
- package/src/stories/If.stories.tsx +72 -0
- package/src/stories/Iframe.stories.tsx +29 -0
- package/src/stories/Item.stories.tsx +79 -0
- package/src/stories/Link.stories.tsx +58 -0
- package/src/stories/ListItem.stories.tsx +37 -0
- package/src/stories/MarkdownContainer.stories.tsx +76 -0
- package/src/stories/PasswordInput.stories.tsx +34 -0
- package/src/stories/Picture.stories.tsx +54 -0
- package/src/stories/ProtectedEmail.stories.tsx +57 -0
- package/src/stories/Text.stories.tsx +44 -0
- package/src/stories/UnorderedList.stories.tsx +73 -0
- package/src/styles/storybook.css +1 -0
- package/src/styles/tailwind.css +7 -0
- package/src/test-setup.ts +1 -0
- package/src/utils/author.test.ts +54 -0
- package/src/utils/author.tsx +73 -0
- package/src/utils/cn.test.ts +48 -0
- package/src/utils/cn.ts +14 -0
- package/src/utils/is-route-active.test.ts +80 -0
- package/src/utils/is-route-active.ts +100 -0
- package/src/utils/locale.test.ts +148 -0
- package/src/utils/locale.ts +127 -0
- package/src/utils/text.test.ts +152 -0
- package/src/utils/text.tsx +209 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext } from 'react';
|
|
2
|
+
import type { NavLinkProps, NavLinkRenderProps } from 'react-router';
|
|
3
|
+
import { NavLink } from 'react-router';
|
|
4
|
+
import { cva, type VariantProps } from '../utils/cn';
|
|
5
|
+
import { lowerCaseSzett } from '../utils/text';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Context for providing a path resolver function.
|
|
9
|
+
* This allows projects to inject their own localization logic.
|
|
10
|
+
*/
|
|
11
|
+
export type PathResolver = (routeKey: string) => string;
|
|
12
|
+
|
|
13
|
+
const PathResolverContext = createContext<PathResolver | null>(null);
|
|
14
|
+
|
|
15
|
+
export const PathResolverProvider = PathResolverContext.Provider;
|
|
16
|
+
|
|
17
|
+
export function usePathResolver(): PathResolver | null {
|
|
18
|
+
return useContext(PathResolverContext);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface LinkBaseProps extends Omit<NavLinkProps, 'to'> {
|
|
22
|
+
to?: string | Partial<{ pathname?: string; search?: string; hash?: string }> | undefined;
|
|
23
|
+
routeKey?: string;
|
|
24
|
+
viewTransition?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const LinkBase = ({
|
|
28
|
+
className,
|
|
29
|
+
to,
|
|
30
|
+
routeKey,
|
|
31
|
+
children,
|
|
32
|
+
onClick,
|
|
33
|
+
viewTransition = true,
|
|
34
|
+
...props
|
|
35
|
+
}: LinkBaseProps) => {
|
|
36
|
+
const pathResolver = usePathResolver();
|
|
37
|
+
|
|
38
|
+
let path: string;
|
|
39
|
+
|
|
40
|
+
if (routeKey && pathResolver) {
|
|
41
|
+
path = pathResolver(routeKey);
|
|
42
|
+
} else if (typeof to === 'string') {
|
|
43
|
+
path = to;
|
|
44
|
+
} else {
|
|
45
|
+
path = to?.pathname ?? '';
|
|
46
|
+
if (to?.search) path += to.search;
|
|
47
|
+
if (to?.hash) path += to.hash;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const isExternal =
|
|
51
|
+
path.startsWith('tel:') ||
|
|
52
|
+
path.startsWith('mailto:') ||
|
|
53
|
+
path.startsWith('#') ||
|
|
54
|
+
path.startsWith('http');
|
|
55
|
+
|
|
56
|
+
const handleClick = useCallback(
|
|
57
|
+
(event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
|
|
58
|
+
onClick?.(event);
|
|
59
|
+
if (event.defaultPrevented) return;
|
|
60
|
+
|
|
61
|
+
if (path.startsWith('tel:') || path.startsWith('mailto:')) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (path.startsWith('#')) {
|
|
66
|
+
event.preventDefault();
|
|
67
|
+
const element = document.getElementById(path.substring(1));
|
|
68
|
+
if (element) {
|
|
69
|
+
element.scrollIntoView({ behavior: 'smooth' });
|
|
70
|
+
}
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (path.startsWith('http')) {
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
window.open(path, '_blank', 'noopener,noreferrer');
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
[onClick, path],
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (!path) {
|
|
84
|
+
return <>{typeof children === 'function' ? null : children}</>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (isExternal) {
|
|
88
|
+
const externalState: NavLinkRenderProps = {
|
|
89
|
+
isActive: false,
|
|
90
|
+
isPending: false,
|
|
91
|
+
isTransitioning: false,
|
|
92
|
+
};
|
|
93
|
+
const resolvedClassName =
|
|
94
|
+
typeof className === 'function' ? className(externalState) : className;
|
|
95
|
+
const resolvedStyle =
|
|
96
|
+
typeof props.style === 'function' ? props.style(externalState) : props.style;
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<a
|
|
100
|
+
className={resolvedClassName}
|
|
101
|
+
href={path}
|
|
102
|
+
onClick={handleClick}
|
|
103
|
+
style={resolvedStyle}
|
|
104
|
+
>
|
|
105
|
+
{typeof children === 'function' ? children(externalState) : children}
|
|
106
|
+
</a>
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<NavLink
|
|
112
|
+
{...props}
|
|
113
|
+
className={className}
|
|
114
|
+
onClick={handleClick}
|
|
115
|
+
to={path}
|
|
116
|
+
viewTransition={viewTransition}
|
|
117
|
+
>
|
|
118
|
+
{children}
|
|
119
|
+
</NavLink>
|
|
120
|
+
);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
const link = cva({
|
|
124
|
+
base: [],
|
|
125
|
+
defaultVariants: {
|
|
126
|
+
variant: 'primary',
|
|
127
|
+
},
|
|
128
|
+
variants: {
|
|
129
|
+
arrow: {
|
|
130
|
+
darr: 'darr',
|
|
131
|
+
larr: 'larr',
|
|
132
|
+
rarr: 'rarr',
|
|
133
|
+
uarr: 'uarr',
|
|
134
|
+
},
|
|
135
|
+
variant: {
|
|
136
|
+
button: [
|
|
137
|
+
'block',
|
|
138
|
+
'button',
|
|
139
|
+
'mt-s',
|
|
140
|
+
'relative',
|
|
141
|
+
'rarr',
|
|
142
|
+
'text-right',
|
|
143
|
+
'text-sm',
|
|
144
|
+
'tracking-wider',
|
|
145
|
+
'uppercase',
|
|
146
|
+
],
|
|
147
|
+
code: ['font-monospace'],
|
|
148
|
+
link: ['rarr', '!bg-transparent', 'uppercase', '!tracking-wider'],
|
|
149
|
+
navtitle: ['block', 'uppercase', 'tracking-wider'],
|
|
150
|
+
primary: [],
|
|
151
|
+
subtitle: ['text-lg'],
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export interface LinkProps extends Omit<NavLinkProps, 'to'>, VariantProps<typeof link> {
|
|
157
|
+
to?: string | Partial<{ pathname?: string; search?: string; hash?: string }>;
|
|
158
|
+
routeKey?: string;
|
|
159
|
+
viewTransition?: boolean;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const Link = ({
|
|
163
|
+
arrow,
|
|
164
|
+
children,
|
|
165
|
+
className,
|
|
166
|
+
routeKey,
|
|
167
|
+
to,
|
|
168
|
+
variant,
|
|
169
|
+
viewTransition,
|
|
170
|
+
...props
|
|
171
|
+
}: LinkProps) => {
|
|
172
|
+
return (
|
|
173
|
+
<LinkBase
|
|
174
|
+
{...props}
|
|
175
|
+
className={link({
|
|
176
|
+
arrow,
|
|
177
|
+
className,
|
|
178
|
+
variant,
|
|
179
|
+
})}
|
|
180
|
+
routeKey={routeKey}
|
|
181
|
+
to={to}
|
|
182
|
+
viewTransition={viewTransition}
|
|
183
|
+
>
|
|
184
|
+
{lowerCaseSzett(children as React.ReactNode)}
|
|
185
|
+
</LinkBase>
|
|
186
|
+
);
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export interface MarkdownLinkProps extends Omit<LinkProps, 'to'> {
|
|
190
|
+
href?: string;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
export const MarkdownLink: React.FC<MarkdownLinkProps> = ({ children, href, ...props }) => {
|
|
194
|
+
if (href) {
|
|
195
|
+
return (
|
|
196
|
+
<Link
|
|
197
|
+
to={href}
|
|
198
|
+
{...props}
|
|
199
|
+
>
|
|
200
|
+
{children}
|
|
201
|
+
</Link>
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return null;
|
|
206
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { cva, type VariantProps } from '../utils/cn';
|
|
3
|
+
|
|
4
|
+
const li = cva({
|
|
5
|
+
defaultVariants: {
|
|
6
|
+
variant: 'primary',
|
|
7
|
+
},
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
primary: [],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export interface ListItemProps extends ComponentProps<'li'>, VariantProps<typeof li> {}
|
|
16
|
+
|
|
17
|
+
export const ListItem = (props: ListItemProps) => {
|
|
18
|
+
const { children, className, variant } = props;
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
<li
|
|
22
|
+
className={li({
|
|
23
|
+
className,
|
|
24
|
+
variant,
|
|
25
|
+
})}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</li>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { config, Map as MapTiler, Marker, Popup } from '@maptiler/sdk';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
import '@maptiler/sdk/dist/maptiler-sdk.css';
|
|
4
|
+
|
|
5
|
+
interface MapTilerMarker {
|
|
6
|
+
lat: number;
|
|
7
|
+
lng: number;
|
|
8
|
+
id: string;
|
|
9
|
+
content?: string;
|
|
10
|
+
htmlContent?: string;
|
|
11
|
+
offset?: { x: number; y: number };
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface MapTilerMapProps {
|
|
15
|
+
markers: MapTilerMarker[];
|
|
16
|
+
center?: { lat: number; lng: number };
|
|
17
|
+
zoom?: number;
|
|
18
|
+
mapStyle?: string;
|
|
19
|
+
apiKey: string;
|
|
20
|
+
showPopupsImmediately?: boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const MapTilerMap = ({
|
|
24
|
+
markers,
|
|
25
|
+
center,
|
|
26
|
+
zoom = 12,
|
|
27
|
+
mapStyle = 'streets',
|
|
28
|
+
apiKey,
|
|
29
|
+
showPopupsImmediately = false,
|
|
30
|
+
}: MapTilerMapProps) => {
|
|
31
|
+
const mapContainerRef = useRef<HTMLDivElement>(null);
|
|
32
|
+
const mapRef = useRef<MapTiler | null>(null);
|
|
33
|
+
const markersRef = useRef<Marker[]>([]);
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (!mapContainerRef.current || typeof window === 'undefined') return;
|
|
37
|
+
|
|
38
|
+
// Set MapTiler API key globally
|
|
39
|
+
config.apiKey = apiKey;
|
|
40
|
+
|
|
41
|
+
// Calculate center
|
|
42
|
+
let calculatedCenter: [number, number];
|
|
43
|
+
if (center) {
|
|
44
|
+
calculatedCenter = [center.lng, center.lat];
|
|
45
|
+
} else if (markers.length > 0) {
|
|
46
|
+
const firstMarker = markers[0];
|
|
47
|
+
if (firstMarker) {
|
|
48
|
+
calculatedCenter = [firstMarker.lng, firstMarker.lat];
|
|
49
|
+
} else {
|
|
50
|
+
calculatedCenter = [13.404954, 52.520008]; // Berlin [lng, lat]
|
|
51
|
+
}
|
|
52
|
+
} else {
|
|
53
|
+
calculatedCenter = [13.404954, 52.520008]; // Berlin [lng, lat]
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// Initialize map with proper style URL
|
|
57
|
+
const map = new MapTiler({
|
|
58
|
+
center: calculatedCenter,
|
|
59
|
+
container: mapContainerRef.current,
|
|
60
|
+
style: `https://api.maptiler.com/maps/${mapStyle}/style.json?key=${apiKey}`,
|
|
61
|
+
zoom: zoom,
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Handle missing images gracefully - provide fallback markers
|
|
65
|
+
map.on('styleimagemissing', (e) => {
|
|
66
|
+
const id = e.id;
|
|
67
|
+
console.warn(`Missing sprite image: ${id}`);
|
|
68
|
+
// Don't attempt to add missing images, let the SDK handle it gracefully
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
mapRef.current = map;
|
|
72
|
+
|
|
73
|
+
// Add markers
|
|
74
|
+
const newMarkers: Marker[] = [];
|
|
75
|
+
|
|
76
|
+
markers.forEach((marker) => {
|
|
77
|
+
const markerInstance = new Marker().setLngLat([marker.lng, marker.lat]).addTo(map);
|
|
78
|
+
|
|
79
|
+
// Create popup content
|
|
80
|
+
let popupContent = '';
|
|
81
|
+
if (marker.htmlContent) {
|
|
82
|
+
popupContent = marker.htmlContent;
|
|
83
|
+
} else if (marker.content) {
|
|
84
|
+
popupContent = marker.content;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (popupContent) {
|
|
88
|
+
const popup = new Popup({
|
|
89
|
+
closeButton: false,
|
|
90
|
+
offset: marker.offset ? [marker.offset.x, marker.offset.y] : [0, 0],
|
|
91
|
+
}).setHTML(popupContent);
|
|
92
|
+
|
|
93
|
+
markerInstance.setPopup(popup);
|
|
94
|
+
|
|
95
|
+
if (showPopupsImmediately) {
|
|
96
|
+
markerInstance.togglePopup();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
newMarkers.push(markerInstance);
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
markersRef.current = newMarkers;
|
|
104
|
+
|
|
105
|
+
// Cleanup function
|
|
106
|
+
return () => {
|
|
107
|
+
if (mapRef.current) {
|
|
108
|
+
mapRef.current.remove();
|
|
109
|
+
mapRef.current = null;
|
|
110
|
+
}
|
|
111
|
+
markersRef.current = [];
|
|
112
|
+
};
|
|
113
|
+
}, [markers, apiKey, mapStyle, zoom, center, showPopupsImmediately]);
|
|
114
|
+
|
|
115
|
+
// Update markers when they change
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
const map = mapRef.current;
|
|
118
|
+
if (!map) return;
|
|
119
|
+
|
|
120
|
+
// Remove existing markers
|
|
121
|
+
markersRef.current.forEach((marker) => {
|
|
122
|
+
marker.remove();
|
|
123
|
+
});
|
|
124
|
+
markersRef.current = [];
|
|
125
|
+
|
|
126
|
+
// Add new markers
|
|
127
|
+
const newMarkers: Marker[] = [];
|
|
128
|
+
|
|
129
|
+
markers.forEach((marker) => {
|
|
130
|
+
const markerInstance = new Marker().setLngLat([marker.lng, marker.lat]).addTo(map);
|
|
131
|
+
|
|
132
|
+
// Create popup content
|
|
133
|
+
let popupContent = '';
|
|
134
|
+
if (marker.htmlContent) {
|
|
135
|
+
popupContent = marker.htmlContent;
|
|
136
|
+
} else if (marker.content) {
|
|
137
|
+
popupContent = marker.content;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
if (popupContent) {
|
|
141
|
+
const popup = new Popup({
|
|
142
|
+
closeButton: false,
|
|
143
|
+
offset: marker.offset ? [marker.offset.x, marker.offset.y] : [0, 0],
|
|
144
|
+
}).setHTML(popupContent);
|
|
145
|
+
|
|
146
|
+
markerInstance.setPopup(popup);
|
|
147
|
+
|
|
148
|
+
if (showPopupsImmediately) {
|
|
149
|
+
markerInstance.togglePopup();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
newMarkers.push(markerInstance);
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
markersRef.current = newMarkers;
|
|
157
|
+
|
|
158
|
+
if (markers.length > 1) {
|
|
159
|
+
const lngs = markers.map((m) => m.lng);
|
|
160
|
+
const lats = markers.map((m) => m.lat);
|
|
161
|
+
const minLng = Math.min(...lngs);
|
|
162
|
+
const maxLng = Math.max(...lngs);
|
|
163
|
+
const minLat = Math.min(...lats);
|
|
164
|
+
const maxLat = Math.max(...lats);
|
|
165
|
+
map.fitBounds(
|
|
166
|
+
[
|
|
167
|
+
[minLng, minLat],
|
|
168
|
+
[maxLng, maxLat],
|
|
169
|
+
],
|
|
170
|
+
{ padding: 20 },
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
}, [markers, showPopupsImmediately]);
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<div
|
|
177
|
+
className="h-full w-full"
|
|
178
|
+
ref={mapContainerRef}
|
|
179
|
+
/>
|
|
180
|
+
);
|
|
181
|
+
};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { MDXProvider } from '@mdx-js/react';
|
|
2
|
+
import Markdown, { type MarkdownToJSX } from 'markdown-to-jsx';
|
|
3
|
+
import type React from 'react';
|
|
4
|
+
import { cn } from '../utils/cn';
|
|
5
|
+
import { replaceSpecialChars } from '../utils/text';
|
|
6
|
+
|
|
7
|
+
const doubleNewlineRegex = /\n\n+/;
|
|
8
|
+
|
|
9
|
+
function processTextOutsideMDXComponents(text: string, locale: string): string {
|
|
10
|
+
// Regex to match MDX components or HTML tags
|
|
11
|
+
const mdxTagRegex = /(<\/?[A-Za-z][^>]*>)/g;
|
|
12
|
+
|
|
13
|
+
return text
|
|
14
|
+
.split(mdxTagRegex)
|
|
15
|
+
.map((part) => (mdxTagRegex.test(part) ? part : replaceSpecialChars(part, locale)))
|
|
16
|
+
.join('');
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function transformLink(
|
|
20
|
+
to: string | Partial<{ pathname?: string; search?: string; hash?: string }> | undefined,
|
|
21
|
+
): string {
|
|
22
|
+
const targetDomainSubstring = 'regard';
|
|
23
|
+
|
|
24
|
+
if (typeof to === 'string') {
|
|
25
|
+
try {
|
|
26
|
+
const url = new URL(to);
|
|
27
|
+
if (url.hostname.includes(targetDomainSubstring)) {
|
|
28
|
+
return url.pathname + (url.search ?? '') + (url.hash ?? '');
|
|
29
|
+
}
|
|
30
|
+
return to;
|
|
31
|
+
} catch {
|
|
32
|
+
return to;
|
|
33
|
+
}
|
|
34
|
+
} else if (to?.pathname) {
|
|
35
|
+
return to.pathname + (to.search ?? '') + (to.hash ?? '');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export type MDXComponent<P = object> = React.ComponentType<P>;
|
|
42
|
+
export type MarkdownOverrides = MarkdownToJSX.Options['overrides'];
|
|
43
|
+
|
|
44
|
+
export type MarkdownContainerProps = React.PropsWithChildren<{
|
|
45
|
+
characters?: number;
|
|
46
|
+
className?: string;
|
|
47
|
+
locale: string;
|
|
48
|
+
paragraphs?: number;
|
|
49
|
+
sentences?: number;
|
|
50
|
+
mdxComponents?: Record<string, MDXComponent>;
|
|
51
|
+
markdownOverrides?: MarkdownOverrides;
|
|
52
|
+
}>;
|
|
53
|
+
|
|
54
|
+
const truncateText = (
|
|
55
|
+
text: string,
|
|
56
|
+
maxSentences: number | undefined,
|
|
57
|
+
maxCharacters: number | undefined,
|
|
58
|
+
maxParagraphs: number | undefined,
|
|
59
|
+
) => {
|
|
60
|
+
if (maxSentences === undefined && maxCharacters === undefined && maxParagraphs === undefined) {
|
|
61
|
+
return text;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const paragraphs = text.split(doubleNewlineRegex);
|
|
65
|
+
|
|
66
|
+
let truncatedText = '';
|
|
67
|
+
let charCount = 0;
|
|
68
|
+
let sentenceCount = 0;
|
|
69
|
+
let paragraphCount = 0;
|
|
70
|
+
|
|
71
|
+
for (const paragraph of paragraphs) {
|
|
72
|
+
if (maxParagraphs !== undefined && paragraphCount >= maxParagraphs) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const sentenceRegex = /(?<!\.\.\.)(?<!\b\w\.)\.(?:\s+|\n+)/g;
|
|
77
|
+
const parts = paragraph.split(sentenceRegex);
|
|
78
|
+
const delimiters = paragraph.match(sentenceRegex) || [];
|
|
79
|
+
|
|
80
|
+
for (let i = 0; i < parts.length; i++) {
|
|
81
|
+
const part = parts[i];
|
|
82
|
+
const delimiter = delimiters[i] || '';
|
|
83
|
+
|
|
84
|
+
if (part !== undefined) {
|
|
85
|
+
if (
|
|
86
|
+
(maxSentences === undefined || sentenceCount < maxSentences) &&
|
|
87
|
+
(maxCharacters === undefined ||
|
|
88
|
+
charCount + part.length + delimiter.length <= maxCharacters)
|
|
89
|
+
) {
|
|
90
|
+
truncatedText += part + delimiter;
|
|
91
|
+
charCount += part.length + delimiter.length;
|
|
92
|
+
|
|
93
|
+
if (delimiter.includes('.')) {
|
|
94
|
+
sentenceCount++;
|
|
95
|
+
}
|
|
96
|
+
} else {
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
paragraphCount++;
|
|
103
|
+
|
|
104
|
+
if (
|
|
105
|
+
(maxSentences !== undefined && sentenceCount >= maxSentences) ||
|
|
106
|
+
(maxCharacters !== undefined && charCount >= maxCharacters)
|
|
107
|
+
) {
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (paragraphCount < paragraphs.length) {
|
|
112
|
+
truncatedText += '\n\n';
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return truncatedText.trim();
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
export const MarkdownContainer: React.FC<MarkdownContainerProps> = (props) => {
|
|
120
|
+
const rawText = props.children?.toString() || '';
|
|
121
|
+
|
|
122
|
+
let processedText = processTextOutsideMDXComponents(rawText, props.locale);
|
|
123
|
+
|
|
124
|
+
const shouldTruncate =
|
|
125
|
+
Number.isInteger(props.sentences) ||
|
|
126
|
+
Number.isInteger(props.characters) ||
|
|
127
|
+
Number.isInteger(props.paragraphs);
|
|
128
|
+
|
|
129
|
+
if (shouldTruncate) {
|
|
130
|
+
processedText = truncateText(
|
|
131
|
+
processedText,
|
|
132
|
+
props.sentences,
|
|
133
|
+
props.characters,
|
|
134
|
+
props.paragraphs,
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
return (
|
|
139
|
+
<MDXProvider components={props.mdxComponents}>
|
|
140
|
+
<Markdown
|
|
141
|
+
className={cn('markdown', props.className)}
|
|
142
|
+
options={{
|
|
143
|
+
disableParsingRawHTML: false,
|
|
144
|
+
forceWrapper: true,
|
|
145
|
+
tagfilter: false,
|
|
146
|
+
...(props.markdownOverrides ? { overrides: props.markdownOverrides } : {}),
|
|
147
|
+
}}
|
|
148
|
+
>
|
|
149
|
+
{processedText}
|
|
150
|
+
</Markdown>
|
|
151
|
+
</MDXProvider>
|
|
152
|
+
);
|
|
153
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Button } from '@base-ui/react/button';
|
|
2
|
+
import { Input } from '@base-ui/react/input';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { cn } from '../utils/cn';
|
|
5
|
+
|
|
6
|
+
export interface InputProps extends React.ComponentPropsWithoutRef<typeof Input> {}
|
|
7
|
+
|
|
8
|
+
export interface PasswordInputProps extends InputProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const PasswordInput = ({ className, ...props }: PasswordInputProps) => {
|
|
13
|
+
const [showPassword, setShowPassword] = useState(false);
|
|
14
|
+
|
|
15
|
+
const togglePasswordVisibility = () => {
|
|
16
|
+
setShowPassword(!showPassword);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<div className={'relative'}>
|
|
21
|
+
<Input
|
|
22
|
+
autoComplete={'off'}
|
|
23
|
+
className={cn(className)}
|
|
24
|
+
type={showPassword ? 'text' : 'password'}
|
|
25
|
+
{...props}
|
|
26
|
+
/>
|
|
27
|
+
<Button
|
|
28
|
+
className={cn(
|
|
29
|
+
'absolute',
|
|
30
|
+
'right-[14px]',
|
|
31
|
+
'top-[35px]',
|
|
32
|
+
'flex',
|
|
33
|
+
'h-6',
|
|
34
|
+
'w-[20px]',
|
|
35
|
+
'cursor-pointer',
|
|
36
|
+
'flex-col',
|
|
37
|
+
'items-end',
|
|
38
|
+
'justify-center',
|
|
39
|
+
'text-gray-500',
|
|
40
|
+
)}
|
|
41
|
+
onClick={togglePasswordVisibility}
|
|
42
|
+
>
|
|
43
|
+
{showPassword ? 'Off' : 'On'}
|
|
44
|
+
</Button>
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export { PasswordInput };
|