@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,195 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import 'leaflet/dist/leaflet.css';
|
|
3
|
+
import L from 'leaflet';
|
|
4
|
+
import { useEffect, useRef } from 'react';
|
|
5
|
+
export const LeafletMap = ({ markers, mapUrl, center, zoom = 12, icon = {
|
|
6
|
+
iconAnchor: [12, 41],
|
|
7
|
+
iconSize: [25, 41],
|
|
8
|
+
iconUrl: '/marker-icon-2x.png',
|
|
9
|
+
}, attribution = '', showPopupsOnHover = false, }) => {
|
|
10
|
+
const mapContainerRef = useRef(null);
|
|
11
|
+
const mapRef = useRef(null);
|
|
12
|
+
const markersRef = useRef([]);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (!mapContainerRef.current || typeof window === 'undefined')
|
|
15
|
+
return;
|
|
16
|
+
let calculatedCenter;
|
|
17
|
+
if (center) {
|
|
18
|
+
calculatedCenter = [center.lat, center.lng];
|
|
19
|
+
}
|
|
20
|
+
else if (markers.length > 0) {
|
|
21
|
+
const firstMarker = markers[0];
|
|
22
|
+
if (firstMarker) {
|
|
23
|
+
calculatedCenter = [firstMarker.lat, firstMarker.lng];
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
calculatedCenter = [52.520008, 13.404954];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
calculatedCenter = [52.520008, 13.404954];
|
|
31
|
+
}
|
|
32
|
+
if (mapRef.current) {
|
|
33
|
+
try {
|
|
34
|
+
markersRef.current.forEach((marker) => {
|
|
35
|
+
try {
|
|
36
|
+
mapRef.current?.removeLayer(marker);
|
|
37
|
+
}
|
|
38
|
+
catch (_error) {
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
mapRef.current.remove();
|
|
42
|
+
}
|
|
43
|
+
catch (_error) {
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
const container = mapContainerRef.current;
|
|
47
|
+
if (container) {
|
|
48
|
+
container.innerHTML = '';
|
|
49
|
+
const leafletContainer = container;
|
|
50
|
+
if (leafletContainer._leaflet_id) {
|
|
51
|
+
delete leafletContainer._leaflet_id;
|
|
52
|
+
}
|
|
53
|
+
container.setAttribute('data-map-initialized', 'false');
|
|
54
|
+
}
|
|
55
|
+
const map = new L.Map(mapContainerRef.current, {
|
|
56
|
+
center: calculatedCenter,
|
|
57
|
+
scrollWheelZoom: false,
|
|
58
|
+
tapTolerance: 100,
|
|
59
|
+
zoom: zoom,
|
|
60
|
+
});
|
|
61
|
+
new L.TileLayer(mapUrl, {
|
|
62
|
+
attribution,
|
|
63
|
+
}).addTo(map);
|
|
64
|
+
const customIcon = new L.Icon({
|
|
65
|
+
iconAnchor: icon.iconAnchor,
|
|
66
|
+
iconSize: icon.iconSize,
|
|
67
|
+
iconUrl: icon.iconUrl,
|
|
68
|
+
});
|
|
69
|
+
const newMarkers = [];
|
|
70
|
+
markers.forEach((marker) => {
|
|
71
|
+
const markerLatLng = [marker.lat, marker.lng];
|
|
72
|
+
const leafletMarker = new L.Marker(markerLatLng, {
|
|
73
|
+
icon: customIcon,
|
|
74
|
+
}).addTo(map);
|
|
75
|
+
const offset = marker.offset || { x: 0, y: 0 };
|
|
76
|
+
let popupContent = '';
|
|
77
|
+
if (marker.htmlContent) {
|
|
78
|
+
popupContent = marker.htmlContent;
|
|
79
|
+
}
|
|
80
|
+
else if (marker.content) {
|
|
81
|
+
popupContent = marker.content;
|
|
82
|
+
}
|
|
83
|
+
if (marker.imageUrl) {
|
|
84
|
+
const imageHtml = `<img src="${marker.imageUrl}" alt="${marker.imageAlt || ''}" style="max-width: 100%; height: auto; display: block; margin-bottom: 8px;" />`;
|
|
85
|
+
popupContent = imageHtml + popupContent;
|
|
86
|
+
}
|
|
87
|
+
if (popupContent) {
|
|
88
|
+
const popup = new L.Popup({
|
|
89
|
+
className: 'custom-map-popup',
|
|
90
|
+
closeButton: false,
|
|
91
|
+
offset: [offset.x, offset.y],
|
|
92
|
+
}).setContent(popupContent);
|
|
93
|
+
leafletMarker.bindPopup(popup);
|
|
94
|
+
if (showPopupsOnHover) {
|
|
95
|
+
leafletMarker.on('mouseover', () => {
|
|
96
|
+
leafletMarker.openPopup();
|
|
97
|
+
});
|
|
98
|
+
leafletMarker.on('mouseout', () => {
|
|
99
|
+
leafletMarker.closePopup();
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
newMarkers.push(leafletMarker);
|
|
104
|
+
});
|
|
105
|
+
markersRef.current = newMarkers;
|
|
106
|
+
if (markers.length > 0) {
|
|
107
|
+
const bounds = new L.LatLngBounds(markers.map((m) => new L.LatLng(m.lat, m.lng)));
|
|
108
|
+
map.fitBounds(bounds, { padding: [20, 20] });
|
|
109
|
+
}
|
|
110
|
+
mapRef.current = map;
|
|
111
|
+
return () => {
|
|
112
|
+
if (mapRef.current) {
|
|
113
|
+
try {
|
|
114
|
+
markersRef.current.forEach((marker) => {
|
|
115
|
+
try {
|
|
116
|
+
mapRef.current?.removeLayer(marker);
|
|
117
|
+
}
|
|
118
|
+
catch (_error) {
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
mapRef.current.remove();
|
|
122
|
+
mapRef.current = null;
|
|
123
|
+
if (mapContainerRef.current) {
|
|
124
|
+
mapContainerRef.current.innerHTML = '';
|
|
125
|
+
mapContainerRef.current.removeAttribute('data-map-initialized');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
catch (_error) {
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
markersRef.current = [];
|
|
132
|
+
};
|
|
133
|
+
}, [markers, mapUrl, zoom, icon, attribution, center, showPopupsOnHover]);
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
const map = mapRef.current;
|
|
136
|
+
if (!map || typeof window === 'undefined')
|
|
137
|
+
return;
|
|
138
|
+
markersRef.current.forEach((marker) => {
|
|
139
|
+
try {
|
|
140
|
+
map.removeLayer(marker);
|
|
141
|
+
}
|
|
142
|
+
catch (_error) {
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
markersRef.current = [];
|
|
146
|
+
const customIcon = new L.Icon({
|
|
147
|
+
iconAnchor: icon.iconAnchor,
|
|
148
|
+
iconSize: icon.iconSize,
|
|
149
|
+
iconUrl: icon.iconUrl,
|
|
150
|
+
});
|
|
151
|
+
const newMarkers = [];
|
|
152
|
+
markers.forEach((marker) => {
|
|
153
|
+
const markerLatLng = [marker.lat, marker.lng];
|
|
154
|
+
const leafletMarker = new L.Marker(markerLatLng, {
|
|
155
|
+
icon: customIcon,
|
|
156
|
+
}).addTo(map);
|
|
157
|
+
const offset = marker.offset || { x: 0, y: 0 };
|
|
158
|
+
let popupContent = '';
|
|
159
|
+
if (marker.htmlContent) {
|
|
160
|
+
popupContent = marker.htmlContent;
|
|
161
|
+
}
|
|
162
|
+
else if (marker.content) {
|
|
163
|
+
popupContent = marker.content;
|
|
164
|
+
}
|
|
165
|
+
if (marker.imageUrl) {
|
|
166
|
+
const imageHtml = `<img src="${marker.imageUrl}" alt="${marker.imageAlt || ''}" style="max-width: 100%; height: auto; display: block; margin-bottom: 8px;" />`;
|
|
167
|
+
popupContent = imageHtml + popupContent;
|
|
168
|
+
}
|
|
169
|
+
if (popupContent) {
|
|
170
|
+
const popup = new L.Popup({
|
|
171
|
+
className: 'custom-map-popup',
|
|
172
|
+
closeButton: false,
|
|
173
|
+
offset: [offset.x, offset.y],
|
|
174
|
+
}).setContent(popupContent);
|
|
175
|
+
leafletMarker.bindPopup(popup);
|
|
176
|
+
if (showPopupsOnHover) {
|
|
177
|
+
leafletMarker.on('mouseover', () => {
|
|
178
|
+
leafletMarker.openPopup();
|
|
179
|
+
});
|
|
180
|
+
leafletMarker.on('mouseout', () => {
|
|
181
|
+
leafletMarker.closePopup();
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
newMarkers.push(leafletMarker);
|
|
186
|
+
});
|
|
187
|
+
markersRef.current = newMarkers;
|
|
188
|
+
if (markers.length > 0) {
|
|
189
|
+
const bounds = new L.LatLngBounds(markers.map((m) => new L.LatLng(m.lat, m.lng)));
|
|
190
|
+
map.fitBounds(bounds, { padding: [20, 20] });
|
|
191
|
+
}
|
|
192
|
+
}, [markers, icon, showPopupsOnHover]);
|
|
193
|
+
return (_jsx("div", { className: "h-full w-full", ref: mapContainerRef }));
|
|
194
|
+
};
|
|
195
|
+
export default LeafletMap;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { NavLinkProps } from 'react-router';
|
|
2
|
+
import { type VariantProps } from '../utils/cn';
|
|
3
|
+
export type PathResolver = (routeKey: string) => string;
|
|
4
|
+
export declare const PathResolverProvider: import("react").Provider<PathResolver | null>;
|
|
5
|
+
export declare function usePathResolver(): PathResolver | null;
|
|
6
|
+
export interface LinkBaseProps extends Omit<NavLinkProps, 'to'> {
|
|
7
|
+
to?: string | Partial<{
|
|
8
|
+
pathname?: string;
|
|
9
|
+
search?: string;
|
|
10
|
+
hash?: string;
|
|
11
|
+
}> | undefined;
|
|
12
|
+
routeKey?: string;
|
|
13
|
+
viewTransition?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare const LinkBase: ({ className, to, routeKey, children, onClick, viewTransition, ...props }: LinkBaseProps) => import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare const link: (props?: ({
|
|
17
|
+
arrow?: "darr" | "larr" | "rarr" | "uarr" | undefined;
|
|
18
|
+
variant?: "code" | "link" | "button" | "primary" | "navtitle" | "subtitle" | undefined;
|
|
19
|
+
} & ({
|
|
20
|
+
class?: import("cva").ClassValue;
|
|
21
|
+
className?: never;
|
|
22
|
+
} | {
|
|
23
|
+
class?: never;
|
|
24
|
+
className?: import("cva").ClassValue;
|
|
25
|
+
})) | undefined) => string;
|
|
26
|
+
export interface LinkProps extends Omit<NavLinkProps, 'to'>, VariantProps<typeof link> {
|
|
27
|
+
to?: string | Partial<{
|
|
28
|
+
pathname?: string;
|
|
29
|
+
search?: string;
|
|
30
|
+
hash?: string;
|
|
31
|
+
}>;
|
|
32
|
+
routeKey?: string;
|
|
33
|
+
viewTransition?: boolean;
|
|
34
|
+
}
|
|
35
|
+
export declare const Link: ({ arrow, children, className, routeKey, to, variant, viewTransition, ...props }: LinkProps) => import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
export interface MarkdownLinkProps extends Omit<LinkProps, 'to'> {
|
|
37
|
+
href?: string;
|
|
38
|
+
}
|
|
39
|
+
export declare const MarkdownLink: React.FC<MarkdownLinkProps>;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.d.ts","sourceRoot":"","sources":["../../src/components/link.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAsB,MAAM,cAAc,CAAC;AAErE,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAOrD,MAAM,MAAM,YAAY,GAAG,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;AAIxD,eAAO,MAAM,oBAAoB,+CAA+B,CAAC;AAEjE,wBAAgB,eAAe,IAAI,YAAY,GAAG,IAAI,CAErD;AAED,MAAM,WAAW,aAAc,SAAQ,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;IAC7D,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,GAAG,SAAS,CAAC;IACzF,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,QAAQ,GAAI,0EAQtB,aAAa,4CAsFf,CAAC;AAEF,QAAA,MAAM,IAAI;;;;;;;;;0BA+BR,CAAC;AAEH,MAAM,WAAW,SAAU,SAAQ,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,EAAE,YAAY,CAAC,OAAO,IAAI,CAAC;IACpF,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,eAAO,MAAM,IAAI,GAAI,iFASlB,SAAS,4CAgBX,CAAC;AAEF,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC;IAC9D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CAapD,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext } from 'react';
|
|
3
|
+
import { NavLink } from 'react-router';
|
|
4
|
+
import { cva } from '../utils/cn';
|
|
5
|
+
import { lowerCaseSzett } from '../utils/text';
|
|
6
|
+
const PathResolverContext = createContext(null);
|
|
7
|
+
export const PathResolverProvider = PathResolverContext.Provider;
|
|
8
|
+
export function usePathResolver() {
|
|
9
|
+
return useContext(PathResolverContext);
|
|
10
|
+
}
|
|
11
|
+
export const LinkBase = ({ className, to, routeKey, children, onClick, viewTransition = true, ...props }) => {
|
|
12
|
+
const pathResolver = usePathResolver();
|
|
13
|
+
let path;
|
|
14
|
+
if (routeKey && pathResolver) {
|
|
15
|
+
path = pathResolver(routeKey);
|
|
16
|
+
}
|
|
17
|
+
else if (typeof to === 'string') {
|
|
18
|
+
path = to;
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
path = to?.pathname ?? '';
|
|
22
|
+
if (to?.search)
|
|
23
|
+
path += to.search;
|
|
24
|
+
if (to?.hash)
|
|
25
|
+
path += to.hash;
|
|
26
|
+
}
|
|
27
|
+
const isExternal = path.startsWith('tel:') ||
|
|
28
|
+
path.startsWith('mailto:') ||
|
|
29
|
+
path.startsWith('#') ||
|
|
30
|
+
path.startsWith('http');
|
|
31
|
+
const handleClick = useCallback((event) => {
|
|
32
|
+
onClick?.(event);
|
|
33
|
+
if (event.defaultPrevented)
|
|
34
|
+
return;
|
|
35
|
+
if (path.startsWith('tel:') || path.startsWith('mailto:')) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
if (path.startsWith('#')) {
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
const element = document.getElementById(path.substring(1));
|
|
41
|
+
if (element) {
|
|
42
|
+
element.scrollIntoView({ behavior: 'smooth' });
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
if (path.startsWith('http')) {
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
window.open(path, '_blank', 'noopener,noreferrer');
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
}, [onClick, path]);
|
|
52
|
+
if (!path) {
|
|
53
|
+
return _jsx(_Fragment, { children: typeof children === 'function' ? null : children });
|
|
54
|
+
}
|
|
55
|
+
if (isExternal) {
|
|
56
|
+
const externalState = {
|
|
57
|
+
isActive: false,
|
|
58
|
+
isPending: false,
|
|
59
|
+
isTransitioning: false,
|
|
60
|
+
};
|
|
61
|
+
const resolvedClassName = typeof className === 'function' ? className(externalState) : className;
|
|
62
|
+
const resolvedStyle = typeof props.style === 'function' ? props.style(externalState) : props.style;
|
|
63
|
+
return (_jsx("a", { className: resolvedClassName, href: path, onClick: handleClick, style: resolvedStyle, children: typeof children === 'function' ? children(externalState) : children }));
|
|
64
|
+
}
|
|
65
|
+
return (_jsx(NavLink, { ...props, className: className, onClick: handleClick, to: path, viewTransition: viewTransition, children: children }));
|
|
66
|
+
};
|
|
67
|
+
const link = cva({
|
|
68
|
+
base: [],
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
variant: 'primary',
|
|
71
|
+
},
|
|
72
|
+
variants: {
|
|
73
|
+
arrow: {
|
|
74
|
+
darr: 'darr',
|
|
75
|
+
larr: 'larr',
|
|
76
|
+
rarr: 'rarr',
|
|
77
|
+
uarr: 'uarr',
|
|
78
|
+
},
|
|
79
|
+
variant: {
|
|
80
|
+
button: [
|
|
81
|
+
'block',
|
|
82
|
+
'button',
|
|
83
|
+
'mt-s',
|
|
84
|
+
'relative',
|
|
85
|
+
'rarr',
|
|
86
|
+
'text-right',
|
|
87
|
+
'text-sm',
|
|
88
|
+
'tracking-wider',
|
|
89
|
+
'uppercase',
|
|
90
|
+
],
|
|
91
|
+
code: ['font-monospace'],
|
|
92
|
+
link: ['rarr', '!bg-transparent', 'uppercase', '!tracking-wider'],
|
|
93
|
+
navtitle: ['block', 'uppercase', 'tracking-wider'],
|
|
94
|
+
primary: [],
|
|
95
|
+
subtitle: ['text-lg'],
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
export const Link = ({ arrow, children, className, routeKey, to, variant, viewTransition, ...props }) => {
|
|
100
|
+
return (_jsx(LinkBase, { ...props, className: link({
|
|
101
|
+
arrow,
|
|
102
|
+
className,
|
|
103
|
+
variant,
|
|
104
|
+
}), routeKey: routeKey, to: to, viewTransition: viewTransition, children: lowerCaseSzett(children) }));
|
|
105
|
+
};
|
|
106
|
+
export const MarkdownLink = ({ children, href, ...props }) => {
|
|
107
|
+
if (href) {
|
|
108
|
+
return (_jsx(Link, { to: href, ...props, children: children }));
|
|
109
|
+
}
|
|
110
|
+
return null;
|
|
111
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.test.d.ts","sourceRoot":"","sources":["../../src/components/link.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { fireEvent, render, screen } from '@testing-library/react';
|
|
3
|
+
import { MemoryRouter } from 'react-router';
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
5
|
+
import { Link, LinkBase, MarkdownLink, PathResolverProvider, usePathResolver } from './link';
|
|
6
|
+
const renderWithRouter = (ui, { route = '/' } = {}) => {
|
|
7
|
+
return render(_jsx(MemoryRouter, { initialEntries: [route], children: ui }));
|
|
8
|
+
};
|
|
9
|
+
describe('LinkBase', () => {
|
|
10
|
+
describe('path resolution', () => {
|
|
11
|
+
test('renders with string "to" prop', () => {
|
|
12
|
+
renderWithRouter(_jsx(LinkBase, { to: "/about", children: "About" }));
|
|
13
|
+
const link = screen.getByRole('link', { name: 'About' });
|
|
14
|
+
expect(link).toHaveAttribute('href', '/about');
|
|
15
|
+
});
|
|
16
|
+
test('renders with object "to" prop containing pathname', () => {
|
|
17
|
+
renderWithRouter(_jsx(LinkBase, { to: { pathname: '/contact' }, children: "Contact" }));
|
|
18
|
+
const link = screen.getByRole('link', { name: 'Contact' });
|
|
19
|
+
expect(link).toHaveAttribute('href', '/contact');
|
|
20
|
+
});
|
|
21
|
+
test('renders with object "to" prop containing pathname, search, and hash', () => {
|
|
22
|
+
renderWithRouter(_jsx(LinkBase, { to: { hash: '#section', pathname: '/page', search: '?foo=bar' }, children: "Full Path" }));
|
|
23
|
+
const link = screen.getByRole('link', { name: 'Full Path' });
|
|
24
|
+
expect(link).toHaveAttribute('href', '/page?foo=bar#section');
|
|
25
|
+
});
|
|
26
|
+
test('uses pathResolver when routeKey is provided', () => {
|
|
27
|
+
const mockResolver = vi.fn().mockReturnValue('/resolved-path');
|
|
28
|
+
renderWithRouter(_jsx(PathResolverProvider, { value: mockResolver, children: _jsx(LinkBase, { routeKey: "home", children: "Home" }) }));
|
|
29
|
+
expect(mockResolver).toHaveBeenCalledWith('home');
|
|
30
|
+
const link = screen.getByRole('link', { name: 'Home' });
|
|
31
|
+
expect(link).toHaveAttribute('href', '/resolved-path');
|
|
32
|
+
});
|
|
33
|
+
test('falls back to "to" prop when no pathResolver is available', () => {
|
|
34
|
+
renderWithRouter(_jsx(LinkBase, { routeKey: "home", to: "/fallback", children: "Home" }));
|
|
35
|
+
const link = screen.getByRole('link', { name: 'Home' });
|
|
36
|
+
expect(link).toHaveAttribute('href', '/fallback');
|
|
37
|
+
});
|
|
38
|
+
test('renders children only when path is empty', () => {
|
|
39
|
+
renderWithRouter(_jsx(LinkBase, { children: "No Link" }));
|
|
40
|
+
expect(screen.queryByRole('link')).toBeNull();
|
|
41
|
+
expect(screen.getByText('No Link')).toBeInTheDocument();
|
|
42
|
+
});
|
|
43
|
+
test('renders nothing for function children when path is empty', () => {
|
|
44
|
+
const { container } = renderWithRouter(_jsx(LinkBase, { children: () => _jsx("span", { children: "Function Child" }) }));
|
|
45
|
+
expect(screen.queryByRole('link')).toBeNull();
|
|
46
|
+
expect(container.textContent).toBe('');
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
describe('external links', () => {
|
|
50
|
+
let windowOpenSpy;
|
|
51
|
+
beforeEach(() => {
|
|
52
|
+
windowOpenSpy = vi.spyOn(window, 'open').mockImplementation(() => null);
|
|
53
|
+
});
|
|
54
|
+
afterEach(() => {
|
|
55
|
+
windowOpenSpy.mockRestore();
|
|
56
|
+
});
|
|
57
|
+
test('renders tel: links as anchor elements', () => {
|
|
58
|
+
renderWithRouter(_jsx(LinkBase, { to: "tel:+1234567890", children: "Call Us" }));
|
|
59
|
+
const link = screen.getByRole('link', { name: 'Call Us' });
|
|
60
|
+
expect(link.tagName).toBe('A');
|
|
61
|
+
expect(link).toHaveAttribute('href', 'tel:+1234567890');
|
|
62
|
+
});
|
|
63
|
+
test('renders mailto: links as anchor elements', () => {
|
|
64
|
+
renderWithRouter(_jsx(LinkBase, { to: "mailto:test@example.com", children: "Email Us" }));
|
|
65
|
+
const link = screen.getByRole('link', { name: 'Email Us' });
|
|
66
|
+
expect(link.tagName).toBe('A');
|
|
67
|
+
expect(link).toHaveAttribute('href', 'mailto:test@example.com');
|
|
68
|
+
});
|
|
69
|
+
test('opens http links in new tab on click', () => {
|
|
70
|
+
renderWithRouter(_jsx(LinkBase, { to: "https://example.com", children: "External" }));
|
|
71
|
+
const link = screen.getByRole('link', { name: 'External' });
|
|
72
|
+
fireEvent.click(link);
|
|
73
|
+
expect(windowOpenSpy).toHaveBeenCalledWith('https://example.com', '_blank', 'noopener,noreferrer');
|
|
74
|
+
});
|
|
75
|
+
test('handles hash links with smooth scroll', () => {
|
|
76
|
+
const mockElement = document.createElement('div');
|
|
77
|
+
mockElement.id = 'section';
|
|
78
|
+
mockElement.scrollIntoView = vi.fn();
|
|
79
|
+
document.body.appendChild(mockElement);
|
|
80
|
+
renderWithRouter(_jsx(LinkBase, { to: "#section", children: "Go to Section" }));
|
|
81
|
+
const link = screen.getByRole('link', { name: 'Go to Section' });
|
|
82
|
+
fireEvent.click(link);
|
|
83
|
+
expect(mockElement.scrollIntoView).toHaveBeenCalledWith({ behavior: 'smooth' });
|
|
84
|
+
document.body.removeChild(mockElement);
|
|
85
|
+
});
|
|
86
|
+
test('does not scroll if hash element does not exist', () => {
|
|
87
|
+
renderWithRouter(_jsx(LinkBase, { to: "#nonexistent", children: "Missing Section" }));
|
|
88
|
+
const link = screen.getByRole('link', { name: 'Missing Section' });
|
|
89
|
+
expect(() => fireEvent.click(link)).not.toThrow();
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
describe('onClick handling', () => {
|
|
93
|
+
test('calls custom onClick handler', () => {
|
|
94
|
+
const handleClick = vi.fn();
|
|
95
|
+
renderWithRouter(_jsx(LinkBase, { onClick: handleClick, to: "/page", children: "Click Me" }));
|
|
96
|
+
const link = screen.getByRole('link', { name: 'Click Me' });
|
|
97
|
+
fireEvent.click(link);
|
|
98
|
+
expect(handleClick).toHaveBeenCalled();
|
|
99
|
+
});
|
|
100
|
+
test('respects preventDefault from custom onClick', () => {
|
|
101
|
+
const windowOpenSpy = vi.spyOn(window, 'open').mockImplementation(() => null);
|
|
102
|
+
const handleClick = vi.fn((e) => e.preventDefault());
|
|
103
|
+
renderWithRouter(_jsx(LinkBase, { onClick: handleClick, to: "https://example.com", children: "External" }));
|
|
104
|
+
const link = screen.getByRole('link', { name: 'External' });
|
|
105
|
+
fireEvent.click(link);
|
|
106
|
+
expect(handleClick).toHaveBeenCalled();
|
|
107
|
+
expect(windowOpenSpy).not.toHaveBeenCalled();
|
|
108
|
+
windowOpenSpy.mockRestore();
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
describe('className and style handling', () => {
|
|
112
|
+
test('applies static className to external links', () => {
|
|
113
|
+
renderWithRouter(_jsx(LinkBase, { className: "custom-class", to: "https://example.com", children: "External" }));
|
|
114
|
+
const link = screen.getByRole('link', { name: 'External' });
|
|
115
|
+
expect(link).toHaveClass('custom-class');
|
|
116
|
+
});
|
|
117
|
+
test('resolves function className for external links', () => {
|
|
118
|
+
renderWithRouter(_jsx(LinkBase, { className: ({ isActive }) => (isActive ? 'active' : 'inactive'), to: "https://example.com", children: "External" }));
|
|
119
|
+
const link = screen.getByRole('link', { name: 'External' });
|
|
120
|
+
expect(link).toHaveClass('inactive');
|
|
121
|
+
});
|
|
122
|
+
test('resolves function style for external links', () => {
|
|
123
|
+
renderWithRouter(_jsx(LinkBase, { style: ({ isActive }) => ({ color: isActive ? 'red' : 'blue' }), to: "https://example.com", children: "External" }));
|
|
124
|
+
const link = screen.getByRole('link', { name: 'External' });
|
|
125
|
+
expect(link).toHaveStyle({ color: 'rgb(0, 0, 255)' });
|
|
126
|
+
});
|
|
127
|
+
test('resolves function children for external links', () => {
|
|
128
|
+
renderWithRouter(_jsx(LinkBase, { to: "https://example.com", children: ({ isActive }) => (isActive ? 'Active' : 'Inactive') }));
|
|
129
|
+
expect(screen.getByText('Inactive')).toBeInTheDocument();
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe('viewTransition prop', () => {
|
|
133
|
+
test('defaults to true for internal links', () => {
|
|
134
|
+
renderWithRouter(_jsx(LinkBase, { to: "/page", children: "Page" }));
|
|
135
|
+
const link = screen.getByRole('link', { name: 'Page' });
|
|
136
|
+
expect(link).toBeInTheDocument();
|
|
137
|
+
});
|
|
138
|
+
test('can be disabled', () => {
|
|
139
|
+
renderWithRouter(_jsx(LinkBase, { to: "/page", viewTransition: false, children: "Page" }));
|
|
140
|
+
const link = screen.getByRole('link', { name: 'Page' });
|
|
141
|
+
expect(link).toBeInTheDocument();
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
describe('Link', () => {
|
|
146
|
+
test('applies variant classes', () => {
|
|
147
|
+
renderWithRouter(_jsx(Link, { to: "/page", variant: "button", children: "Button Link" }));
|
|
148
|
+
const link = screen.getByRole('link', { name: 'Button Link' });
|
|
149
|
+
expect(link).toHaveClass('button');
|
|
150
|
+
});
|
|
151
|
+
test('applies arrow classes', () => {
|
|
152
|
+
renderWithRouter(_jsx(Link, { arrow: "rarr", to: "/page", children: "Arrow Link" }));
|
|
153
|
+
const link = screen.getByRole('link', { name: 'Arrow Link' });
|
|
154
|
+
expect(link).toHaveClass('rarr');
|
|
155
|
+
});
|
|
156
|
+
test('merges custom className with variant classes', () => {
|
|
157
|
+
renderWithRouter(_jsx(Link, { className: "custom", to: "/page", variant: "code", children: "Code Link" }));
|
|
158
|
+
const link = screen.getByRole('link', { name: 'Code Link' });
|
|
159
|
+
expect(link).toHaveClass('font-monospace');
|
|
160
|
+
expect(link).toHaveClass('custom');
|
|
161
|
+
});
|
|
162
|
+
test('passes through routeKey to LinkBase', () => {
|
|
163
|
+
const mockResolver = vi.fn().mockReturnValue('/resolved');
|
|
164
|
+
renderWithRouter(_jsx(PathResolverProvider, { value: mockResolver, children: _jsx(Link, { routeKey: "test", children: "Test" }) }));
|
|
165
|
+
expect(mockResolver).toHaveBeenCalledWith('test');
|
|
166
|
+
});
|
|
167
|
+
});
|
|
168
|
+
describe('MarkdownLink', () => {
|
|
169
|
+
test('renders Link when href is provided', () => {
|
|
170
|
+
renderWithRouter(_jsx(MarkdownLink, { href: "/page", children: "Markdown Link" }));
|
|
171
|
+
const link = screen.getByRole('link', { name: 'Markdown Link' });
|
|
172
|
+
expect(link).toHaveAttribute('href', '/page');
|
|
173
|
+
});
|
|
174
|
+
test('renders null when href is not provided', () => {
|
|
175
|
+
const { container } = renderWithRouter(_jsx(MarkdownLink, { children: "No Href" }));
|
|
176
|
+
expect(container.textContent).toBe('');
|
|
177
|
+
});
|
|
178
|
+
test('passes through Link props', () => {
|
|
179
|
+
renderWithRouter(_jsx(MarkdownLink, { href: "/page", variant: "subtitle", children: "Styled Link" }));
|
|
180
|
+
const link = screen.getByRole('link', { name: 'Styled Link' });
|
|
181
|
+
expect(link).toHaveClass('text-lg');
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
describe('usePathResolver', () => {
|
|
185
|
+
test('returns null when no provider is present', () => {
|
|
186
|
+
let resolverValue = vi.fn();
|
|
187
|
+
const TestComponent = () => {
|
|
188
|
+
resolverValue = usePathResolver();
|
|
189
|
+
return null;
|
|
190
|
+
};
|
|
191
|
+
render(_jsx(TestComponent, {}));
|
|
192
|
+
expect(resolverValue).toBeNull();
|
|
193
|
+
});
|
|
194
|
+
test('returns resolver function when provider is present', () => {
|
|
195
|
+
const mockResolver = vi.fn().mockReturnValue('/path');
|
|
196
|
+
let resolverValue = null;
|
|
197
|
+
const TestComponent = () => {
|
|
198
|
+
resolverValue = usePathResolver();
|
|
199
|
+
return null;
|
|
200
|
+
};
|
|
201
|
+
render(_jsx(PathResolverProvider, { value: mockResolver, children: _jsx(TestComponent, {}) }));
|
|
202
|
+
expect(resolverValue).toBe(mockResolver);
|
|
203
|
+
});
|
|
204
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { type VariantProps } from '../utils/cn';
|
|
3
|
+
declare const li: (props?: ({
|
|
4
|
+
variant?: "primary" | undefined;
|
|
5
|
+
} & ({
|
|
6
|
+
class?: import("cva").ClassValue;
|
|
7
|
+
className?: never;
|
|
8
|
+
} | {
|
|
9
|
+
class?: never;
|
|
10
|
+
className?: import("cva").ClassValue;
|
|
11
|
+
})) | undefined) => string;
|
|
12
|
+
export interface ListItemProps extends ComponentProps<'li'>, VariantProps<typeof li> {
|
|
13
|
+
}
|
|
14
|
+
export declare const ListItem: (props: ListItemProps) => import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=list-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"list-item.d.ts","sourceRoot":"","sources":["../../src/components/list-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAC5C,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAErD,QAAA,MAAM,EAAE;;;;;;;;0BASN,CAAC;AAEH,MAAM,WAAW,aAAc,SAAQ,cAAc,CAAC,IAAI,CAAC,EAAE,YAAY,CAAC,OAAO,EAAE,CAAC;CAAG;AAEvF,eAAO,MAAM,QAAQ,GAAI,OAAO,aAAa,4CAa5C,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { cva } from '../utils/cn';
|
|
3
|
+
const li = cva({
|
|
4
|
+
defaultVariants: {
|
|
5
|
+
variant: 'primary',
|
|
6
|
+
},
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
primary: [],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
});
|
|
13
|
+
export const ListItem = (props) => {
|
|
14
|
+
const { children, className, variant } = props;
|
|
15
|
+
return (_jsx("li", { className: li({
|
|
16
|
+
className,
|
|
17
|
+
variant,
|
|
18
|
+
}), children: children }));
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '@maptiler/sdk/dist/maptiler-sdk.css';
|
|
2
|
+
interface MapTilerMarker {
|
|
3
|
+
lat: number;
|
|
4
|
+
lng: number;
|
|
5
|
+
id: string;
|
|
6
|
+
content?: string;
|
|
7
|
+
htmlContent?: string;
|
|
8
|
+
offset?: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface MapTilerMapProps {
|
|
14
|
+
markers: MapTilerMarker[];
|
|
15
|
+
center?: {
|
|
16
|
+
lat: number;
|
|
17
|
+
lng: number;
|
|
18
|
+
};
|
|
19
|
+
zoom?: number;
|
|
20
|
+
mapStyle?: string;
|
|
21
|
+
apiKey: string;
|
|
22
|
+
showPopupsImmediately?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const MapTilerMap: ({ markers, center, zoom, mapStyle, apiKey, showPopupsImmediately, }: MapTilerMapProps) => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export {};
|
|
26
|
+
//# sourceMappingURL=maptiler-map.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maptiler-map.d.ts","sourceRoot":"","sources":["../../src/components/maptiler-map.tsx"],"names":[],"mappings":"AAEA,OAAO,qCAAqC,CAAC;AAE7C,UAAU,cAAc;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACnC;AAED,UAAU,gBAAgB;IACxB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;AAED,eAAO,MAAM,WAAW,GAAI,qEAOzB,gBAAgB,4CAuJlB,CAAC"}
|