@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,22 @@
|
|
|
1
|
+
import { LanguageDetectorLingui } from '@regardio/js/intl/language-detector';
|
|
2
|
+
import { createCookie } from 'react-router';
|
|
3
|
+
export interface LocaleConfigOptions {
|
|
4
|
+
defaultLocale: string;
|
|
5
|
+
supportedLocales: readonly string[];
|
|
6
|
+
cookieOptions?: {
|
|
7
|
+
name?: string;
|
|
8
|
+
maxAge?: number;
|
|
9
|
+
httpOnly?: boolean;
|
|
10
|
+
secure?: boolean;
|
|
11
|
+
sameSite?: 'strict' | 'lax' | 'none';
|
|
12
|
+
};
|
|
13
|
+
detectionOptions?: {
|
|
14
|
+
order?: Array<'urlPath' | 'cookie' | 'header'>;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export interface LocaleConfig {
|
|
18
|
+
localeCookie: ReturnType<typeof createCookie>;
|
|
19
|
+
languageDetector: LanguageDetectorLingui;
|
|
20
|
+
}
|
|
21
|
+
export declare function createLocaleConfig(options: LocaleConfigOptions): LocaleConfig;
|
|
22
|
+
//# sourceMappingURL=locale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../../src/utils/locale.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAK5C,MAAM,WAAW,mBAAmB;IAIlC,aAAa,EAAE,MAAM,CAAC;IAKtB,gBAAgB,EAAE,SAAS,MAAM,EAAE,CAAC;IAKpC,aAAa,CAAC,EAAE;QAId,IAAI,CAAC,EAAE,MAAM,CAAC;QAKd,MAAM,CAAC,EAAE,MAAM,CAAC;QAKhB,QAAQ,CAAC,EAAE,OAAO,CAAC;QAKnB,MAAM,CAAC,EAAE,OAAO,CAAC;QAKjB,QAAQ,CAAC,EAAE,QAAQ,GAAG,KAAK,GAAG,MAAM,CAAC;KACtC,CAAC;IAKF,gBAAgB,CAAC,EAAE;QAIjB,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;KAChD,CAAC;CACH;AAKD,MAAM,WAAW,YAAY;IAI3B,YAAY,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IAK9C,gBAAgB,EAAE,sBAAsB,CAAC;CAC1C;AAoBD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,mBAAmB,GAAG,YAAY,CAmC7E"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { LanguageDetectorLingui } from '@regardio/js/intl/language-detector';
|
|
2
|
+
import { createCookie } from 'react-router';
|
|
3
|
+
export function createLocaleConfig(options) {
|
|
4
|
+
const { defaultLocale, supportedLocales, cookieOptions = {}, detectionOptions = {} } = options;
|
|
5
|
+
const { name = 'locale', maxAge = 60 * 60 * 24 * 365, httpOnly = false, secure = import.meta.env.MODE !== 'development', sameSite = 'lax', } = cookieOptions;
|
|
6
|
+
const { order = ['urlPath', 'cookie', 'header'] } = detectionOptions;
|
|
7
|
+
const localeCookie = createCookie(name, {
|
|
8
|
+
httpOnly,
|
|
9
|
+
maxAge,
|
|
10
|
+
sameSite,
|
|
11
|
+
secure,
|
|
12
|
+
});
|
|
13
|
+
const languageDetector = new LanguageDetectorLingui({
|
|
14
|
+
detection: {
|
|
15
|
+
cookie: localeCookie,
|
|
16
|
+
fallbackLanguage: defaultLocale,
|
|
17
|
+
order,
|
|
18
|
+
supportedLanguages: [...supportedLocales],
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
languageDetector,
|
|
23
|
+
localeCookie,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locale.test.d.ts","sourceRoot":"","sources":["../../src/utils/locale.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { LanguageDetectorLingui } from '@regardio/js/intl/language-detector';
|
|
2
|
+
import { beforeEach, describe, expect, test } from 'vitest';
|
|
3
|
+
import { createLocaleConfig } from './locale';
|
|
4
|
+
describe('createLocaleConfig', () => {
|
|
5
|
+
const originalEnvMode = import.meta.env.MODE;
|
|
6
|
+
beforeEach(() => {
|
|
7
|
+
import.meta.env.MODE = originalEnvMode;
|
|
8
|
+
});
|
|
9
|
+
test('creates config with default options', async () => {
|
|
10
|
+
const config = createLocaleConfig({
|
|
11
|
+
defaultLocale: 'en',
|
|
12
|
+
supportedLocales: ['en', 'de'],
|
|
13
|
+
});
|
|
14
|
+
expect(config.localeCookie).toBeDefined();
|
|
15
|
+
expect(config.localeCookie.name).toBe('locale');
|
|
16
|
+
const request = new Request('https://example.com', {
|
|
17
|
+
headers: {
|
|
18
|
+
Cookie: await config.localeCookie.serialize('en'),
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
const parsedValue = await config.localeCookie.parse(request.headers.get('Cookie'));
|
|
22
|
+
expect(parsedValue).toBe('en');
|
|
23
|
+
expect(config.languageDetector).toBeInstanceOf(LanguageDetectorLingui);
|
|
24
|
+
const mockRequest = new Request('https://example.com/en/page', {
|
|
25
|
+
headers: { 'Accept-Language': 'de' },
|
|
26
|
+
});
|
|
27
|
+
const detectedLocale = await config.languageDetector.getLocale(mockRequest);
|
|
28
|
+
expect(detectedLocale).toBe('en');
|
|
29
|
+
});
|
|
30
|
+
test('creates config with custom cookie options', async () => {
|
|
31
|
+
const config = createLocaleConfig({
|
|
32
|
+
cookieOptions: {
|
|
33
|
+
httpOnly: true,
|
|
34
|
+
maxAge: 3600,
|
|
35
|
+
name: 'custom-locale',
|
|
36
|
+
sameSite: 'strict',
|
|
37
|
+
secure: true,
|
|
38
|
+
},
|
|
39
|
+
defaultLocale: 'fr',
|
|
40
|
+
supportedLocales: ['fr', 'es'],
|
|
41
|
+
});
|
|
42
|
+
expect(config.localeCookie.name).toBe('custom-locale');
|
|
43
|
+
const cookieHeader = await config.localeCookie.serialize('fr');
|
|
44
|
+
console.log('Custom cookie header:', cookieHeader);
|
|
45
|
+
expect(typeof cookieHeader).toBe('string');
|
|
46
|
+
expect(cookieHeader.includes('custom-locale=')).toBe(true);
|
|
47
|
+
expect(/samesite=strict/i.test(cookieHeader)).toBe(true);
|
|
48
|
+
expect(/httponly/i.test(cookieHeader)).toBe(true);
|
|
49
|
+
expect(/secure/i.test(cookieHeader)).toBe(true);
|
|
50
|
+
expect(/max-age=3600/i.test(cookieHeader)).toBe(true);
|
|
51
|
+
});
|
|
52
|
+
test('creates config with custom detection order', async () => {
|
|
53
|
+
const config = createLocaleConfig({
|
|
54
|
+
defaultLocale: 'de',
|
|
55
|
+
detectionOptions: {
|
|
56
|
+
order: ['header', 'cookie', 'urlPath'],
|
|
57
|
+
},
|
|
58
|
+
supportedLocales: ['de', 'en'],
|
|
59
|
+
});
|
|
60
|
+
const mockRequest = new Request('https://example.com/en/page', {
|
|
61
|
+
headers: { 'Accept-Language': 'de' },
|
|
62
|
+
});
|
|
63
|
+
const detectedLocale = await config.languageDetector.getLocale(mockRequest);
|
|
64
|
+
expect(detectedLocale).toBe('de');
|
|
65
|
+
});
|
|
66
|
+
test('secure cookie defaults to true in production environment', async () => {
|
|
67
|
+
import.meta.env.MODE = 'production';
|
|
68
|
+
const config = createLocaleConfig({
|
|
69
|
+
defaultLocale: 'en',
|
|
70
|
+
supportedLocales: ['en', 'de'],
|
|
71
|
+
});
|
|
72
|
+
const cookieHeader = await config.localeCookie.serialize('en');
|
|
73
|
+
console.log('Production cookie header:', cookieHeader);
|
|
74
|
+
expect(typeof cookieHeader).toBe('string');
|
|
75
|
+
expect(/secure/i.test(cookieHeader)).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
test('secure cookie defaults to false in development environment', async () => {
|
|
78
|
+
import.meta.env.MODE = 'development';
|
|
79
|
+
const config = createLocaleConfig({
|
|
80
|
+
defaultLocale: 'en',
|
|
81
|
+
supportedLocales: ['en', 'de'],
|
|
82
|
+
});
|
|
83
|
+
const cookieHeader = await config.localeCookie.serialize('en');
|
|
84
|
+
console.log('Development cookie header:', cookieHeader);
|
|
85
|
+
expect(typeof cookieHeader).toBe('string');
|
|
86
|
+
expect(/secure/i.test(cookieHeader)).toBe(false);
|
|
87
|
+
});
|
|
88
|
+
test('handles readonly supportedLocales array', async () => {
|
|
89
|
+
const supportedLocales = ['en', 'de'];
|
|
90
|
+
const config = createLocaleConfig({
|
|
91
|
+
defaultLocale: 'en',
|
|
92
|
+
supportedLocales,
|
|
93
|
+
});
|
|
94
|
+
const enRequest = new Request('https://example.com/en/page');
|
|
95
|
+
expect(await config.languageDetector.getLocale(enRequest)).toBe('en');
|
|
96
|
+
const deRequest = new Request('https://example.com/de/page');
|
|
97
|
+
expect(await config.languageDetector.getLocale(deRequest)).toBe('de');
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import React, { type ReactNode } from 'react';
|
|
2
|
+
export declare const lowerCaseSzett: (text: ReactNode | string, _returnType?: "string") => ReactNode;
|
|
3
|
+
export declare function toBoolean(value: string | boolean | null | undefined): boolean;
|
|
4
|
+
export declare function shy(input: string | ReactNode | null): string | ReactNode | null;
|
|
5
|
+
export declare function typographicQuotes(text: string, locale: string): string;
|
|
6
|
+
export declare function replaceSpecialChars(text: string, locale: string): React.ReactNode;
|
|
7
|
+
//# sourceMappingURL=text.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/utils/text.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAmD,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE/F,eAAO,MAAM,cAAc,GAAI,MAAM,SAAS,GAAG,MAAM,EAAE,cAAc,QAAQ,KAAG,SA2CjF,CAAC;AAEF,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAM7E;AAkCD,wBAAgB,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAU/E;AA6FD,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAWtE;AAKD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,mBAE/D"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React, { cloneElement, isValidElement } from 'react';
|
|
3
|
+
export const lowerCaseSzett = (text, _returnType) => {
|
|
4
|
+
const processString = (str) => {
|
|
5
|
+
const parts = str.split(/(ß)/g);
|
|
6
|
+
return parts.map((part, index) => part === 'ß' ? (_jsx("span", { className: "lowercase", children: part }, index.toString())) : (part));
|
|
7
|
+
};
|
|
8
|
+
if (typeof text === 'string') {
|
|
9
|
+
return processString(text);
|
|
10
|
+
}
|
|
11
|
+
if (isValidElement(text)) {
|
|
12
|
+
const element = text;
|
|
13
|
+
const { children, ...props } = element.props;
|
|
14
|
+
return cloneElement(element, {
|
|
15
|
+
...props,
|
|
16
|
+
children: lowerCaseSzett(children),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
if (Array.isArray(text)) {
|
|
20
|
+
return text.map((child, index) => (_jsx(React.Fragment, { children: lowerCaseSzett(child) }, index.toString())));
|
|
21
|
+
}
|
|
22
|
+
return text;
|
|
23
|
+
};
|
|
24
|
+
export function toBoolean(value) {
|
|
25
|
+
if (typeof value === 'boolean') {
|
|
26
|
+
return value;
|
|
27
|
+
}
|
|
28
|
+
return value === 'true' || value === '1';
|
|
29
|
+
}
|
|
30
|
+
function replaceShyInString(input) {
|
|
31
|
+
return input.replace(/­/g, '\u00AD');
|
|
32
|
+
}
|
|
33
|
+
function replaceShyInReactNode(node) {
|
|
34
|
+
if (typeof node === 'string') {
|
|
35
|
+
return node.replace(/\u00AD/g, '');
|
|
36
|
+
}
|
|
37
|
+
if (isValidElement(node)) {
|
|
38
|
+
const element = node;
|
|
39
|
+
const { children, ...props } = element.props;
|
|
40
|
+
return cloneElement(element, {
|
|
41
|
+
...props,
|
|
42
|
+
children: replaceShyInReactNode(children),
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (Array.isArray(node)) {
|
|
46
|
+
return node.map((child, index) => (_jsx(React.Fragment, { children: replaceShyInReactNode(child) }, index.toString())));
|
|
47
|
+
}
|
|
48
|
+
return node;
|
|
49
|
+
}
|
|
50
|
+
export function shy(input) {
|
|
51
|
+
if (input === null) {
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
if (typeof input === 'string') {
|
|
55
|
+
return replaceShyInString(input);
|
|
56
|
+
}
|
|
57
|
+
return replaceShyInReactNode(input);
|
|
58
|
+
}
|
|
59
|
+
const quoteStyles = {
|
|
60
|
+
cs: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
|
|
61
|
+
da: { close: '\u00AB', closeSingle: '\u203A', open: '\u00BB', openSingle: '\u2039' },
|
|
62
|
+
de: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
|
|
63
|
+
'de-ch': { close: '\u00BB', closeSingle: '\u203A', open: '\u00AB', openSingle: '\u2039' },
|
|
64
|
+
en: { close: '\u201D', closeSingle: '\u2019', open: '\u201C', openSingle: '\u2018' },
|
|
65
|
+
es: { close: '\u00BB', closeSingle: '\u201D', open: '\u00AB', openSingle: '\u201C' },
|
|
66
|
+
fi: { close: '\u201D', closeSingle: '\u2019', open: '\u201D', openSingle: '\u2019' },
|
|
67
|
+
fr: { close: ' \u00BB', closeSingle: ' \u203A', open: '\u00AB ', openSingle: '\u2039 ' },
|
|
68
|
+
hu: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
|
|
69
|
+
it: { close: '\u00BB', closeSingle: '\u201D', open: '\u00AB', openSingle: '\u201C' },
|
|
70
|
+
ja: { close: '\u300D', closeSingle: '\u300F', open: '\u300C', openSingle: '\u300E' },
|
|
71
|
+
nl: { close: '\u2019', closeSingle: '\u2019', open: '\u2018', openSingle: '\u2018' },
|
|
72
|
+
no: { close: '\u00AB', closeSingle: '\u203A', open: '\u00BB', openSingle: '\u2039' },
|
|
73
|
+
pl: { close: '\u201D', closeSingle: '\u2019', open: '\u201E', openSingle: '\u201A' },
|
|
74
|
+
pt: { close: '\u00BB', closeSingle: '\u201D', open: '\u00AB', openSingle: '\u201C' },
|
|
75
|
+
ru: { close: '\u00BB', closeSingle: '\u2019', open: '\u00AB', openSingle: '\u201A' },
|
|
76
|
+
sv: { close: '\u201D', closeSingle: '\u2019', open: '\u201D', openSingle: '\u2019' },
|
|
77
|
+
zh: { close: '\u300D', closeSingle: '\u300F', open: '\u300C', openSingle: '\u300E' },
|
|
78
|
+
};
|
|
79
|
+
function getQuoteStyle(locale) {
|
|
80
|
+
const normalized = locale.toLowerCase();
|
|
81
|
+
const exactMatch = quoteStyles[normalized];
|
|
82
|
+
if (exactMatch) {
|
|
83
|
+
return exactMatch;
|
|
84
|
+
}
|
|
85
|
+
const baseLanguage = normalized.split('-')[0];
|
|
86
|
+
if (baseLanguage) {
|
|
87
|
+
const baseMatch = quoteStyles[baseLanguage];
|
|
88
|
+
if (baseMatch) {
|
|
89
|
+
return baseMatch;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return quoteStyles.en;
|
|
93
|
+
}
|
|
94
|
+
export function typographicQuotes(text, locale) {
|
|
95
|
+
const style = getQuoteStyle(locale);
|
|
96
|
+
let result = text.replace(/"([^"]*)"/g, `${style.open}$1${style.close}`);
|
|
97
|
+
result = result.replace(/'([^']*)'/g, `${style.openSingle}$1${style.closeSingle}`);
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
export function replaceSpecialChars(text, locale) {
|
|
101
|
+
return shy(typographicQuotes(text, locale));
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"text.test.d.ts","sourceRoot":"","sources":["../../src/utils/text.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
import { replaceSpecialChars, shy, toBoolean, typographicQuotes } from './text';
|
|
3
|
+
describe('toBoolean', () => {
|
|
4
|
+
test('returns true for boolean true', () => {
|
|
5
|
+
expect(toBoolean(true)).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
test('returns false for boolean false', () => {
|
|
8
|
+
expect(toBoolean(false)).toBe(false);
|
|
9
|
+
});
|
|
10
|
+
test('returns true for string "true"', () => {
|
|
11
|
+
expect(toBoolean('true')).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
test('returns true for string "1"', () => {
|
|
14
|
+
expect(toBoolean('1')).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
test('returns false for string "false"', () => {
|
|
17
|
+
expect(toBoolean('false')).toBe(false);
|
|
18
|
+
});
|
|
19
|
+
test('returns false for string "0"', () => {
|
|
20
|
+
expect(toBoolean('0')).toBe(false);
|
|
21
|
+
});
|
|
22
|
+
test('returns false for null', () => {
|
|
23
|
+
expect(toBoolean(null)).toBe(false);
|
|
24
|
+
});
|
|
25
|
+
test('returns false for undefined', () => {
|
|
26
|
+
expect(toBoolean(undefined)).toBe(false);
|
|
27
|
+
});
|
|
28
|
+
test('returns false for other strings', () => {
|
|
29
|
+
expect(toBoolean('yes')).toBe(false);
|
|
30
|
+
expect(toBoolean('no')).toBe(false);
|
|
31
|
+
expect(toBoolean('')).toBe(false);
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe('shy', () => {
|
|
35
|
+
test('returns null for null input', () => {
|
|
36
|
+
expect(shy(null)).toBe(null);
|
|
37
|
+
});
|
|
38
|
+
test('replaces ­ with soft hyphen in strings', () => {
|
|
39
|
+
const result = shy('hello­world');
|
|
40
|
+
expect(result).toBe('hello\u00ADworld');
|
|
41
|
+
});
|
|
42
|
+
test('handles strings without ­', () => {
|
|
43
|
+
expect(shy('hello world')).toBe('hello world');
|
|
44
|
+
});
|
|
45
|
+
test('handles multiple ­ occurrences', () => {
|
|
46
|
+
const result = shy('one­two­three');
|
|
47
|
+
expect(result).toBe('one\u00ADtwo\u00ADthree');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
describe('replaceSpecialChars', () => {
|
|
51
|
+
test('replaces straight quotes for de locale', () => {
|
|
52
|
+
const result = replaceSpecialChars('"Hello"', 'de');
|
|
53
|
+
const str = String(result);
|
|
54
|
+
expect(str).not.toContain('"Hello"');
|
|
55
|
+
expect(str).toContain('Hello');
|
|
56
|
+
});
|
|
57
|
+
test('replaces straight quotes for de-DE locale', () => {
|
|
58
|
+
const result = replaceSpecialChars('"Hello"', 'de-DE');
|
|
59
|
+
const str = String(result);
|
|
60
|
+
expect(str).not.toContain('"Hello"');
|
|
61
|
+
expect(str).toContain('Hello');
|
|
62
|
+
});
|
|
63
|
+
test('replaces straight quotes for en locale', () => {
|
|
64
|
+
const result = replaceSpecialChars('"Hello"', 'en');
|
|
65
|
+
const str = String(result);
|
|
66
|
+
expect(str).not.toContain('"Hello"');
|
|
67
|
+
expect(str).toContain('Hello');
|
|
68
|
+
});
|
|
69
|
+
test('handles multiple quoted strings', () => {
|
|
70
|
+
const result = replaceSpecialChars('"one" and "two"', 'de');
|
|
71
|
+
const str = String(result);
|
|
72
|
+
expect(str).toContain('one');
|
|
73
|
+
expect(str).toContain('two');
|
|
74
|
+
expect(str).toContain('and');
|
|
75
|
+
});
|
|
76
|
+
test('also applies shy replacement', () => {
|
|
77
|
+
const result = replaceSpecialChars('"Hello­World"', 'en');
|
|
78
|
+
expect(String(result)).toContain('\u00AD');
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
describe('typographicQuotes', () => {
|
|
82
|
+
test('replaces double quotes with English curly quotes', () => {
|
|
83
|
+
const result = typographicQuotes('"Hello"', 'en');
|
|
84
|
+
expect(result).toBe('\u201CHello\u201D');
|
|
85
|
+
});
|
|
86
|
+
test('replaces double quotes with German quotes', () => {
|
|
87
|
+
const result = typographicQuotes('"Hello"', 'de');
|
|
88
|
+
expect(result).toBe('\u201EHello\u201D');
|
|
89
|
+
});
|
|
90
|
+
test('replaces double quotes with French guillemets', () => {
|
|
91
|
+
const result = typographicQuotes('"Hello"', 'fr');
|
|
92
|
+
expect(result).toBe('\u00AB Hello \u00BB');
|
|
93
|
+
});
|
|
94
|
+
test('handles de-DE locale (falls back to de)', () => {
|
|
95
|
+
const result = typographicQuotes('"Hello"', 'de-DE');
|
|
96
|
+
expect(result).toBe('\u201EHello\u201D');
|
|
97
|
+
});
|
|
98
|
+
test('handles de-CH locale (Swiss German with guillemets)', () => {
|
|
99
|
+
const result = typographicQuotes('"Hello"', 'de-CH');
|
|
100
|
+
expect(result).toBe('\u00ABHello\u00BB');
|
|
101
|
+
});
|
|
102
|
+
test('handles unknown locale (falls back to English)', () => {
|
|
103
|
+
const result = typographicQuotes('"Hello"', 'xx-YY');
|
|
104
|
+
expect(result).toBe('\u201CHello\u201D');
|
|
105
|
+
});
|
|
106
|
+
test('replaces single quotes', () => {
|
|
107
|
+
const result = typographicQuotes("'Hello'", 'en');
|
|
108
|
+
expect(result).toBe('\u2018Hello\u2019');
|
|
109
|
+
});
|
|
110
|
+
test('handles multiple quoted strings', () => {
|
|
111
|
+
const result = typographicQuotes('"one" and "two"', 'de');
|
|
112
|
+
expect(result).toBe('\u201Eone\u201D and \u201Etwo\u201D');
|
|
113
|
+
});
|
|
114
|
+
test('handles Japanese quotes', () => {
|
|
115
|
+
const result = typographicQuotes('"Hello"', 'ja');
|
|
116
|
+
expect(result).toBe('\u300CHello\u300D');
|
|
117
|
+
});
|
|
118
|
+
test('preserves text without quotes', () => {
|
|
119
|
+
const result = typographicQuotes('Hello World', 'en');
|
|
120
|
+
expect(result).toBe('Hello World');
|
|
121
|
+
});
|
|
122
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://www.schemastore.org/package.json",
|
|
3
|
+
"author": "Bernd Matzner <bernd.matzner@regard.io>",
|
|
4
|
+
"bugs": {
|
|
5
|
+
"url": "https://github.com/regardio/react/issues"
|
|
6
|
+
},
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@base-ui/react": "1.0.0",
|
|
9
|
+
"@maptiler/leaflet-maptilersdk": "4.1.1",
|
|
10
|
+
"@maptiler/sdk": "3.9.0",
|
|
11
|
+
"@mdx-js/react": "3.1.1",
|
|
12
|
+
"@regardio/js": "0.3.0",
|
|
13
|
+
"@supabase/supabase-js": "2.89.0",
|
|
14
|
+
"cmdk": "1.1.1",
|
|
15
|
+
"cva": "beta",
|
|
16
|
+
"embla-carousel": "8.6.0",
|
|
17
|
+
"embla-carousel-react": "8.6.0",
|
|
18
|
+
"fluid-tailwindcss": "1.0.5",
|
|
19
|
+
"input-otp": "1.4.2",
|
|
20
|
+
"intl-parse-accept-language": "1.0.0",
|
|
21
|
+
"leaflet": "alpha",
|
|
22
|
+
"lucide-react": "0.562.0",
|
|
23
|
+
"markdown-to-jsx": "9.5.0",
|
|
24
|
+
"react": "19.2.3",
|
|
25
|
+
"react-day-picker": "9.13.0",
|
|
26
|
+
"react-dom": "19.2.3",
|
|
27
|
+
"react-hook-form": "7.70.0",
|
|
28
|
+
"react-resizable-panels": "4.2.1",
|
|
29
|
+
"react-router": "7.11.0",
|
|
30
|
+
"tailwind-merge": "3.4.0",
|
|
31
|
+
"vaul": "1.1.2",
|
|
32
|
+
"zod": "4.3.5"
|
|
33
|
+
},
|
|
34
|
+
"description": "Regardio React UI components",
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@regardio/dev": "1.9.4",
|
|
37
|
+
"@storybook/addon-a11y": "10.1.11",
|
|
38
|
+
"@storybook/addon-docs": "10.1.11",
|
|
39
|
+
"@storybook/addon-vitest": "10.1.11",
|
|
40
|
+
"@storybook/react-vite": "10.1.11",
|
|
41
|
+
"@tailwindcss/vite": "4.1.18",
|
|
42
|
+
"@testing-library/jest-dom": "6.9.1",
|
|
43
|
+
"@testing-library/react": "16.3.1",
|
|
44
|
+
"@total-typescript/ts-reset": "0.6.1",
|
|
45
|
+
"@types/leaflet": "1.9.21",
|
|
46
|
+
"@types/node": "25.0.3",
|
|
47
|
+
"@types/react": "19.2.7",
|
|
48
|
+
"@types/react-dom": "19.2.3",
|
|
49
|
+
"@vitejs/plugin-react": "5.1.2",
|
|
50
|
+
"@vitest/browser-playwright": "4.0.16",
|
|
51
|
+
"@vitest/coverage-v8": "4.0.16",
|
|
52
|
+
"@vitest/ui": "4.0.16",
|
|
53
|
+
"jsdom": "27.4.0",
|
|
54
|
+
"playwright": "^1.57.0",
|
|
55
|
+
"storybook": "10.1.11",
|
|
56
|
+
"tailwindcss": "4.1.18",
|
|
57
|
+
"typescript": "5.9.3",
|
|
58
|
+
"vite": "7.3.0",
|
|
59
|
+
"vitest": "4.0.16"
|
|
60
|
+
},
|
|
61
|
+
"engines": {
|
|
62
|
+
"node": ">=18"
|
|
63
|
+
},
|
|
64
|
+
"exports": {
|
|
65
|
+
"./components/*": {
|
|
66
|
+
"import": "./dist/components/*.js",
|
|
67
|
+
"types": "./dist/components/*.d.ts"
|
|
68
|
+
},
|
|
69
|
+
"./hooks/*": {
|
|
70
|
+
"import": "./dist/hooks/*.js",
|
|
71
|
+
"types": "./dist/hooks/*.d.ts"
|
|
72
|
+
},
|
|
73
|
+
"./tailwind.css": "./src/styles/tailwind.css",
|
|
74
|
+
"./utils/*": {
|
|
75
|
+
"import": "./dist/utils/*.js",
|
|
76
|
+
"types": "./dist/utils/*.d.ts"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"files": ["dist", "src"],
|
|
80
|
+
"homepage": "https://github.com/regardio/react/blob/main/README.md",
|
|
81
|
+
"keywords": ["react", "components", "ui", "regardio", "tailwindcss"],
|
|
82
|
+
"license": "MIT",
|
|
83
|
+
"name": "@regardio/react",
|
|
84
|
+
"private": false,
|
|
85
|
+
"publishConfig": {
|
|
86
|
+
"access": "public"
|
|
87
|
+
},
|
|
88
|
+
"repository": {
|
|
89
|
+
"directory": "packages/react",
|
|
90
|
+
"type": "git",
|
|
91
|
+
"url": "https://github.com/regardio/react.git"
|
|
92
|
+
},
|
|
93
|
+
"scripts": {
|
|
94
|
+
"build": "exec-tsc --project tsconfig.build.json",
|
|
95
|
+
"clean": "exec-clean .turbo dist",
|
|
96
|
+
"dev": "exec-tsc --project tsconfig.build.json --watch",
|
|
97
|
+
"fix": "exec-p fix:*",
|
|
98
|
+
"fix:biome": "lint-biome check --write --unsafe .",
|
|
99
|
+
"fix:md": "lint-md --fix",
|
|
100
|
+
"lint": "exec-p lint:*",
|
|
101
|
+
"lint:biome": "lint-biome check .",
|
|
102
|
+
"lint:md": "lint-md",
|
|
103
|
+
"prepare": "exec-husky",
|
|
104
|
+
"release": "flow-release",
|
|
105
|
+
"report": "exec-s report:*",
|
|
106
|
+
"report:unit": "vitest run --reporter html",
|
|
107
|
+
"storybook": "storybook dev -p 6006",
|
|
108
|
+
"storybook:build": "storybook build -o storybook-static",
|
|
109
|
+
"test": "exec-s test:*",
|
|
110
|
+
"test:unit": "vitest run",
|
|
111
|
+
"typecheck": "exec-tsc --noEmit",
|
|
112
|
+
"version": "flow-changeset version"
|
|
113
|
+
},
|
|
114
|
+
"sideEffects": ["./src/styles/tailwind.css"],
|
|
115
|
+
"type": "module",
|
|
116
|
+
"version": "0.3.2"
|
|
117
|
+
}
|