@regardio/react 0.3.3 → 0.4.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/dist/components/background-slideshow.d.ts +7 -5
- package/dist/components/background-slideshow.js +172 -74
- package/dist/components/blurry-gradient.d.ts +11 -4
- package/dist/components/blurry-gradient.js +121 -5
- package/dist/components/box.d.ts +12 -9
- package/dist/components/box.js +48 -23
- package/dist/components/carousel.d.ts +12 -10
- package/dist/components/carousel.js +146 -66
- package/dist/components/countdown.d.ts +5 -2
- package/dist/components/countdown.js +55 -21
- package/dist/components/definition-list.d.ts +19 -16
- package/dist/components/definition-list.js +83 -51
- package/dist/components/generic-error.d.ts +25 -5
- package/dist/components/generic-error.js +42 -34
- package/dist/components/heading.d.ts +14 -11
- package/dist/components/heading.js +114 -25
- package/dist/components/highlight.d.ts +11 -8
- package/dist/components/highlight.js +65 -17
- package/dist/components/icon-button.d.ts +7 -4
- package/dist/components/icon-button.js +16 -5
- package/dist/components/if.d.ts +6 -4
- package/dist/components/if.js +22 -14
- package/dist/components/iframe.d.ts +6 -4
- package/dist/components/iframe.js +26 -3
- package/dist/components/item.d.ts +18 -15
- package/dist/components/item.js +504 -301
- package/dist/components/leaflet-map.d.ts +5 -4
- package/dist/components/leaflet-map.js +192 -186
- package/dist/components/link.d.ts +24 -16
- package/dist/components/link.js +191 -102
- package/dist/components/list-item.d.ts +11 -8
- package/dist/components/list-item.js +35 -17
- package/dist/components/maptiler-map.d.ts +5 -4
- package/dist/components/maptiler-map.js +125 -112
- package/dist/components/markdown-container.d.ts +10 -8
- package/dist/components/markdown-container.js +181 -82
- package/dist/components/password-input.d.ts +7 -5
- package/dist/components/password-input.js +50 -8
- package/dist/components/picture.d.ts +19 -7
- package/dist/components/picture.js +75 -34
- package/dist/components/protected-email.d.ts +14 -3
- package/dist/components/protected-email.js +29 -15
- package/dist/components/text.d.ts +12 -9
- package/dist/components/text.js +42 -24
- package/dist/components/unordered-list.d.ts +11 -8
- package/dist/components/unordered-list.js +37 -19
- package/dist/hooks/use-current-route-data.d.ts +7 -2
- package/dist/hooks/use-current-route-data.js +13 -9
- package/dist/hooks/use-focus-search.d.ts +6 -3
- package/dist/hooks/use-focus-search.js +17 -13
- package/dist/hooks/use-matches-data.d.ts +9 -2
- package/dist/hooks/use-matches-data.js +12 -8
- package/dist/hooks/use-media-query.d.ts +8 -2
- package/dist/hooks/use-media-query.js +19 -15
- package/dist/hooks/use-mobile.d.ts +3 -2
- package/dist/hooks/use-mobile.js +18 -14
- package/dist/hooks/use-nonce.d.ts +12 -5
- package/dist/hooks/use-nonce.js +11 -7
- package/dist/hooks/use-orientation.d.ts +11 -3
- package/dist/hooks/use-orientation.js +28 -24
- package/dist/hooks/use-user.d.ts +43 -8
- package/dist/hooks/use-user.js +21 -13
- package/dist/utils/author.d.ts +4 -4
- package/dist/utils/author.js +49 -31
- package/dist/utils/cn.d.ts +8 -4
- package/dist/utils/cn.js +12 -8
- package/dist/utils/is-route-active.d.ts +19 -3
- package/dist/utils/is-route-active.js +45 -43
- package/dist/utils/locale.d.ts +66 -4
- package/dist/utils/locale.js +33 -22
- package/dist/utils/text.d.ts +24 -7
- package/dist/utils/text.js +114 -89
- package/package.json +5 -4
- package/dist/components/background-slideshow.d.ts.map +0 -1
- package/dist/components/blurry-gradient.d.ts.map +0 -1
- package/dist/components/box.d.ts.map +0 -1
- package/dist/components/carousel.d.ts.map +0 -1
- package/dist/components/countdown.d.ts.map +0 -1
- package/dist/components/definition-list.d.ts.map +0 -1
- package/dist/components/generic-error.d.ts.map +0 -1
- package/dist/components/heading.d.ts.map +0 -1
- package/dist/components/highlight.d.ts.map +0 -1
- package/dist/components/icon-button.d.ts.map +0 -1
- package/dist/components/if.d.ts.map +0 -1
- package/dist/components/iframe.d.ts.map +0 -1
- package/dist/components/item.d.ts.map +0 -1
- package/dist/components/leaflet-map.d.ts.map +0 -1
- package/dist/components/link.d.ts.map +0 -1
- package/dist/components/link.test.d.ts +0 -2
- package/dist/components/link.test.d.ts.map +0 -1
- package/dist/components/link.test.js +0 -204
- package/dist/components/list-item.d.ts.map +0 -1
- package/dist/components/maptiler-map.d.ts.map +0 -1
- package/dist/components/markdown-container.d.ts.map +0 -1
- package/dist/components/password-input.d.ts.map +0 -1
- package/dist/components/picture.d.ts.map +0 -1
- package/dist/components/protected-email.d.ts.map +0 -1
- package/dist/components/text.d.ts.map +0 -1
- package/dist/components/unordered-list.d.ts.map +0 -1
- package/dist/hooks/use-current-route-data.d.ts.map +0 -1
- package/dist/hooks/use-focus-search.d.ts.map +0 -1
- package/dist/hooks/use-matches-data.d.ts.map +0 -1
- package/dist/hooks/use-media-query.d.ts.map +0 -1
- package/dist/hooks/use-mobile.d.ts.map +0 -1
- package/dist/hooks/use-nonce.d.ts.map +0 -1
- package/dist/hooks/use-nonce.test.d.ts +0 -2
- package/dist/hooks/use-nonce.test.d.ts.map +0 -1
- package/dist/hooks/use-nonce.test.js +0 -27
- package/dist/hooks/use-orientation.d.ts.map +0 -1
- package/dist/hooks/use-user.d.ts.map +0 -1
- package/dist/shadcn/accordion.d.ts +0 -25
- package/dist/shadcn/accordion.d.ts.map +0 -1
- package/dist/shadcn/accordion.js +0 -45
- package/dist/shadcn/alert-dialog.d.ts +0 -73
- package/dist/shadcn/alert-dialog.d.ts.map +0 -1
- package/dist/shadcn/alert-dialog.js +0 -93
- package/dist/shadcn/alert.d.ts +0 -34
- package/dist/shadcn/alert.d.ts.map +0 -1
- package/dist/shadcn/alert.js +0 -42
- package/dist/shadcn/aspect-ratio.d.ts +0 -6
- package/dist/shadcn/aspect-ratio.d.ts.map +0 -1
- package/dist/shadcn/aspect-ratio.js +0 -7
- package/dist/shadcn/avatar.d.ts +0 -16
- package/dist/shadcn/avatar.d.ts.map +0 -1
- package/dist/shadcn/avatar.js +0 -27
- package/dist/shadcn/badge.d.ts +0 -29
- package/dist/shadcn/badge.d.ts.map +0 -1
- package/dist/shadcn/badge.js +0 -29
- package/dist/shadcn/breadcrumb.d.ts +0 -42
- package/dist/shadcn/breadcrumb.d.ts.map +0 -1
- package/dist/shadcn/breadcrumb.js +0 -74
- package/dist/shadcn/button.d.ts +0 -38
- package/dist/shadcn/button.d.ts.map +0 -1
- package/dist/shadcn/button.js +0 -38
- package/dist/shadcn/calendar.d.ts +0 -23
- package/dist/shadcn/calendar.d.ts.map +0 -1
- package/dist/shadcn/calendar.js +0 -163
- package/dist/shadcn/card.d.ts +0 -31
- package/dist/shadcn/card.d.ts.map +0 -1
- package/dist/shadcn/card.js +0 -55
- package/dist/shadcn/carousel.d.ts +0 -51
- package/dist/shadcn/carousel.d.ts.map +0 -1
- package/dist/shadcn/carousel.js +0 -161
- package/dist/shadcn/chart.d.ts +0 -103
- package/dist/shadcn/chart.d.ts.map +0 -1
- package/dist/shadcn/chart.js +0 -248
- package/dist/shadcn/checkbox.d.ts +0 -8
- package/dist/shadcn/checkbox.d.ts.map +0 -1
- package/dist/shadcn/checkbox.js +0 -22
- package/dist/shadcn/collapsible.d.ts +0 -16
- package/dist/shadcn/collapsible.d.ts.map +0 -1
- package/dist/shadcn/collapsible.js +0 -19
- package/dist/shadcn/command.d.ts +0 -61
- package/dist/shadcn/command.d.ts.map +0 -1
- package/dist/shadcn/command.js +0 -123
- package/dist/shadcn/context-menu.d.ts +0 -107
- package/dist/shadcn/context-menu.d.ts.map +0 -1
- package/dist/shadcn/context-menu.js +0 -151
- package/dist/shadcn/dialog.d.ts +0 -57
- package/dist/shadcn/dialog.d.ts.map +0 -1
- package/dist/shadcn/dialog.js +0 -96
- package/dist/shadcn/drawer.d.ts +0 -54
- package/dist/shadcn/drawer.d.ts.map +0 -1
- package/dist/shadcn/drawer.js +0 -96
- package/dist/shadcn/dropdown-menu.d.ts +0 -110
- package/dist/shadcn/dropdown-menu.d.ts.map +0 -1
- package/dist/shadcn/dropdown-menu.js +0 -152
- package/dist/shadcn/form.d.ts +0 -59
- package/dist/shadcn/form.d.ts.map +0 -1
- package/dist/shadcn/form.js +0 -99
- package/dist/shadcn/hover-card.d.ts +0 -20
- package/dist/shadcn/hover-card.d.ts.map +0 -1
- package/dist/shadcn/hover-card.js +0 -26
- package/dist/shadcn/input-otp.d.ts +0 -25
- package/dist/shadcn/input-otp.d.ts.map +0 -1
- package/dist/shadcn/input-otp.js +0 -54
- package/dist/shadcn/input.d.ts +0 -14
- package/dist/shadcn/input.d.ts.map +0 -1
- package/dist/shadcn/input.js +0 -48
- package/dist/shadcn/label.d.ts +0 -8
- package/dist/shadcn/label.d.ts.map +0 -1
- package/dist/shadcn/label.js +0 -16
- package/dist/shadcn/menubar.d.ts +0 -108
- package/dist/shadcn/menubar.d.ts.map +0 -1
- package/dist/shadcn/menubar.js +0 -174
- package/dist/shadcn/navigation-menu.d.ts +0 -79
- package/dist/shadcn/navigation-menu.d.ts.map +0 -1
- package/dist/shadcn/navigation-menu.js +0 -108
- package/dist/shadcn/pagination.d.ts +0 -45
- package/dist/shadcn/pagination.d.ts.map +0 -1
- package/dist/shadcn/pagination.js +0 -83
- package/dist/shadcn/popover.d.ts +0 -19
- package/dist/shadcn/popover.d.ts.map +0 -1
- package/dist/shadcn/popover.js +0 -29
- package/dist/shadcn/progress.d.ts +0 -9
- package/dist/shadcn/progress.d.ts.map +0 -1
- package/dist/shadcn/progress.js +0 -17
- package/dist/shadcn/radio-group.d.ts +0 -12
- package/dist/shadcn/radio-group.d.ts.map +0 -1
- package/dist/shadcn/radio-group.js +0 -32
- package/dist/shadcn/resizable.d.ts +0 -20
- package/dist/shadcn/resizable.d.ts.map +0 -1
- package/dist/shadcn/resizable.js +0 -32
- package/dist/shadcn/scroll-area.d.ts +0 -16
- package/dist/shadcn/scroll-area.d.ts.map +0 -1
- package/dist/shadcn/scroll-area.js +0 -40
- package/dist/shadcn/select.d.ts +0 -63
- package/dist/shadcn/select.d.ts.map +0 -1
- package/dist/shadcn/select.js +0 -120
- package/dist/shadcn/separator.d.ts +0 -10
- package/dist/shadcn/separator.d.ts.map +0 -1
- package/dist/shadcn/separator.js +0 -18
- package/dist/shadcn/sheet.d.ts +0 -48
- package/dist/shadcn/sheet.d.ts.map +0 -1
- package/dist/shadcn/sheet.js +0 -99
- package/dist/shadcn/sidebar.d.ts +0 -200
- package/dist/shadcn/sidebar.d.ts.map +0 -1
- package/dist/shadcn/sidebar.js +0 -528
- package/dist/shadcn/skeleton.d.ts +0 -6
- package/dist/shadcn/skeleton.d.ts.map +0 -1
- package/dist/shadcn/skeleton.js +0 -11
- package/dist/shadcn/slider.d.ts +0 -12
- package/dist/shadcn/slider.d.ts.map +0 -1
- package/dist/shadcn/slider.js +0 -50
- package/dist/shadcn/sonner.d.ts +0 -7
- package/dist/shadcn/sonner.d.ts.map +0 -1
- package/dist/shadcn/sonner.js +0 -20
- package/dist/shadcn/switch.d.ts +0 -8
- package/dist/shadcn/switch.d.ts.map +0 -1
- package/dist/shadcn/switch.js +0 -22
- package/dist/shadcn/table.d.ts +0 -35
- package/dist/shadcn/table.d.ts.map +0 -1
- package/dist/shadcn/table.js +0 -73
- package/dist/shadcn/tabs.d.ts +0 -20
- package/dist/shadcn/tabs.d.ts.map +0 -1
- package/dist/shadcn/tabs.js +0 -40
- package/dist/shadcn/textarea.d.ts +0 -7
- package/dist/shadcn/textarea.d.ts.map +0 -1
- package/dist/shadcn/textarea.js +0 -14
- package/dist/shadcn/toggle-group.d.ts +0 -22
- package/dist/shadcn/toggle-group.d.ts.map +0 -1
- package/dist/shadcn/toggle-group.js +0 -43
- package/dist/shadcn/toggle.d.ts +0 -29
- package/dist/shadcn/toggle.d.ts.map +0 -1
- package/dist/shadcn/toggle.js +0 -31
- package/dist/shadcn/tooltip.d.ts +0 -20
- package/dist/shadcn/tooltip.d.ts.map +0 -1
- package/dist/shadcn/tooltip.js +0 -40
- package/dist/stories/BackgroundSlideshow.stories.d.ts +0 -9
- package/dist/stories/BackgroundSlideshow.stories.d.ts.map +0 -1
- package/dist/stories/BackgroundSlideshow.stories.js +0 -60
- package/dist/stories/BlurryGradient.stories.d.ts +0 -11
- package/dist/stories/BlurryGradient.stories.d.ts.map +0 -1
- package/dist/stories/BlurryGradient.stories.js +0 -53
- package/dist/stories/Box.stories.d.ts +0 -13
- package/dist/stories/Box.stories.d.ts.map +0 -1
- package/dist/stories/Box.stories.js +0 -50
- package/dist/stories/Carousel.stories.d.ts +0 -9
- package/dist/stories/Carousel.stories.d.ts.map +0 -1
- package/dist/stories/Carousel.stories.js +0 -30
- package/dist/stories/Countdown.stories.d.ts +0 -7
- package/dist/stories/Countdown.stories.d.ts.map +0 -1
- package/dist/stories/Countdown.stories.js +0 -11
- package/dist/stories/DefinitionList.stories.d.ts +0 -9
- package/dist/stories/DefinitionList.stories.d.ts.map +0 -1
- package/dist/stories/DefinitionList.stories.js +0 -20
- package/dist/stories/GenericError.stories.d.ts +0 -9
- package/dist/stories/GenericError.stories.d.ts.map +0 -1
- package/dist/stories/GenericError.stories.js +0 -39
- package/dist/stories/Heading.stories.d.ts +0 -15
- package/dist/stories/Heading.stories.d.ts.map +0 -1
- package/dist/stories/Heading.stories.js +0 -61
- package/dist/stories/Highlight.stories.d.ts +0 -8
- package/dist/stories/Highlight.stories.d.ts.map +0 -1
- package/dist/stories/Highlight.stories.js +0 -19
- package/dist/stories/IconButton.stories.d.ts +0 -10
- package/dist/stories/IconButton.stories.d.ts.map +0 -1
- package/dist/stories/IconButton.stories.js +0 -32
- package/dist/stories/If.stories.d.ts +0 -13
- package/dist/stories/If.stories.d.ts.map +0 -1
- package/dist/stories/If.stories.js +0 -54
- package/dist/stories/Iframe.stories.d.ts +0 -8
- package/dist/stories/Iframe.stories.d.ts.map +0 -1
- package/dist/stories/Iframe.stories.js +0 -23
- package/dist/stories/Item.stories.d.ts +0 -10
- package/dist/stories/Item.stories.d.ts.map +0 -1
- package/dist/stories/Item.stories.js +0 -32
- package/dist/stories/Link.stories.d.ts +0 -10
- package/dist/stories/Link.stories.d.ts.map +0 -1
- package/dist/stories/Link.stories.js +0 -36
- package/dist/stories/ListItem.stories.d.ts +0 -9
- package/dist/stories/ListItem.stories.d.ts.map +0 -1
- package/dist/stories/ListItem.stories.js +0 -26
- package/dist/stories/MarkdownContainer.stories.d.ts +0 -11
- package/dist/stories/MarkdownContainer.stories.d.ts.map +0 -1
- package/dist/stories/MarkdownContainer.stories.js +0 -66
- package/dist/stories/PasswordInput.stories.d.ts +0 -9
- package/dist/stories/PasswordInput.stories.d.ts.map +0 -1
- package/dist/stories/PasswordInput.stories.js +0 -27
- package/dist/stories/Picture.stories.d.ts +0 -10
- package/dist/stories/Picture.stories.d.ts.map +0 -1
- package/dist/stories/Picture.stories.js +0 -46
- package/dist/stories/ProtectedEmail.stories.d.ts +0 -10
- package/dist/stories/ProtectedEmail.stories.d.ts.map +0 -1
- package/dist/stories/ProtectedEmail.stories.js +0 -34
- package/dist/stories/Text.stories.d.ts +0 -10
- package/dist/stories/Text.stories.d.ts.map +0 -1
- package/dist/stories/Text.stories.js +0 -31
- package/dist/stories/UnorderedList.stories.d.ts +0 -10
- package/dist/stories/UnorderedList.stories.d.ts.map +0 -1
- package/dist/stories/UnorderedList.stories.js +0 -24
- package/dist/test-setup.d.ts +0 -2
- package/dist/test-setup.d.ts.map +0 -1
- package/dist/test-setup.js +0 -1
- package/dist/utils/author.d.ts.map +0 -1
- package/dist/utils/author.test.d.ts +0 -2
- package/dist/utils/author.test.d.ts.map +0 -1
- package/dist/utils/author.test.js +0 -46
- package/dist/utils/cn.d.ts.map +0 -1
- package/dist/utils/cn.test.d.ts +0 -2
- package/dist/utils/cn.test.d.ts.map +0 -1
- package/dist/utils/cn.test.js +0 -33
- package/dist/utils/is-route-active.d.ts.map +0 -1
- package/dist/utils/is-route-active.test.d.ts +0 -2
- package/dist/utils/is-route-active.test.d.ts.map +0 -1
- package/dist/utils/is-route-active.test.js +0 -61
- package/dist/utils/locale.d.ts.map +0 -1
- package/dist/utils/locale.test.d.ts +0 -2
- package/dist/utils/locale.test.d.ts.map +0 -1
- package/dist/utils/locale.test.js +0 -99
- package/dist/utils/text.d.ts.map +0 -1
- package/dist/utils/text.test.d.ts +0 -2
- package/dist/utils/text.test.d.ts.map +0 -1
- package/dist/utils/text.test.js +0 -122
package/dist/utils/author.js
CHANGED
|
@@ -1,37 +1,55 @@
|
|
|
1
|
-
import { jsx
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (trimmedName) {
|
|
13
|
-
result.name = trimmedName;
|
|
14
|
-
}
|
|
15
|
-
if (url) {
|
|
16
|
-
result.url = url;
|
|
17
|
-
}
|
|
18
|
-
return result;
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
|
|
3
|
+
// src/utils/author.tsx
|
|
4
|
+
var regex = /^(.*?)\s*(?:<([^>]+)>)?\s*(?:\(([^)]+)\))?$/;
|
|
5
|
+
function parseAuthorString(input) {
|
|
6
|
+
const match = input.match(regex);
|
|
7
|
+
if (match) {
|
|
8
|
+
const [, name, email, url] = match;
|
|
9
|
+
const result = {};
|
|
10
|
+
if (email) {
|
|
11
|
+
result.email = email;
|
|
19
12
|
}
|
|
20
|
-
|
|
13
|
+
const trimmedName = name?.trim();
|
|
14
|
+
if (trimmedName) {
|
|
15
|
+
result.name = trimmedName;
|
|
16
|
+
}
|
|
17
|
+
if (url) {
|
|
18
|
+
result.url = url;
|
|
19
|
+
}
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
return {};
|
|
21
23
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
function generateLinkFromAuthorString(input) {
|
|
25
|
+
const match = input.match(regex);
|
|
26
|
+
if (match) {
|
|
27
|
+
const [, name, email, url] = match.map((part) => {
|
|
28
|
+
return part?.trim();
|
|
29
|
+
});
|
|
30
|
+
if (email) {
|
|
31
|
+
return /* @__PURE__ */ jsx(
|
|
32
|
+
"a",
|
|
33
|
+
{
|
|
34
|
+
className: "u-email p-name",
|
|
35
|
+
href: `mailto:${email}`,
|
|
36
|
+
children: name
|
|
30
37
|
}
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
if (url && (url.startsWith("/") || url.startsWith("http"))) {
|
|
41
|
+
return /* @__PURE__ */ jsx(
|
|
42
|
+
"a",
|
|
43
|
+
{
|
|
44
|
+
className: "u-url p-name",
|
|
45
|
+
href: url,
|
|
46
|
+
children: name
|
|
33
47
|
}
|
|
34
|
-
|
|
48
|
+
);
|
|
35
49
|
}
|
|
36
|
-
return;
|
|
50
|
+
return /* @__PURE__ */ jsx("span", { className: "p-name", children: name });
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
37
53
|
}
|
|
54
|
+
|
|
55
|
+
export { generateLinkFromAuthorString, parseAuthorString };
|
package/dist/utils/cn.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import * as cva$1 from 'cva';
|
|
1
2
|
import { cx } from 'cva';
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export { VariantProps } from 'cva';
|
|
4
|
+
|
|
5
|
+
declare const cva: cva$1.CVA;
|
|
6
|
+
declare const compose: cva$1.Compose;
|
|
7
|
+
declare const cn: (...inputs: Parameters<typeof cx>) => string;
|
|
8
|
+
|
|
9
|
+
export { cn, compose, cva };
|
package/dist/utils/cn.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineConfig, cx } from 'cva';
|
|
2
2
|
import { twMerge } from 'fluid-tailwindcss/tailwind-merge';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
|
|
4
|
+
// src/utils/cn.ts
|
|
5
|
+
var { cva, compose } = defineConfig({
|
|
6
|
+
hooks: {
|
|
7
|
+
onComplete: (className) => {
|
|
8
|
+
return twMerge(className);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
9
11
|
});
|
|
10
|
-
|
|
12
|
+
var cn = (...inputs) => twMerge(cx(inputs));
|
|
13
|
+
|
|
14
|
+
export { cn, compose, cva };
|
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @name isRouteActive
|
|
3
|
+
* @description A function to check if a route is active. This is used to
|
|
4
|
+
* @param end
|
|
5
|
+
* @param path
|
|
6
|
+
* @param currentPath
|
|
7
|
+
*/
|
|
8
|
+
declare function isRouteActive(path: string, currentPath: string, end?: boolean | ((path: string) => boolean) | undefined): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* @name checkIfRouteIsActive
|
|
11
|
+
* @description A function to check if a route is active. This is used to
|
|
12
|
+
* highlight the active link in the navigation.
|
|
13
|
+
* @param targetLink - The link to check against
|
|
14
|
+
* @param currentRoute - the current route
|
|
15
|
+
* @param depth - how far down should segments be matched?
|
|
16
|
+
*/
|
|
17
|
+
declare function checkIfRouteIsActive(targetLink: string, currentRoute: string, depth?: number): boolean;
|
|
18
|
+
|
|
19
|
+
export { checkIfRouteIsActive, isRouteActive };
|
|
@@ -1,54 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
// src/utils/is-route-active.ts
|
|
2
|
+
var ROOT_PATH = "/";
|
|
3
|
+
function isRouteActive(path, currentPath, end) {
|
|
4
|
+
if (path === currentPath) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
if (typeof end === "function") {
|
|
8
|
+
return !end(currentPath);
|
|
9
|
+
}
|
|
10
|
+
const defaultEnd = end ?? true;
|
|
11
|
+
const oneLevelDeep = 1;
|
|
12
|
+
const threeLevelsDeep = 3;
|
|
13
|
+
const depth = defaultEnd ? oneLevelDeep : threeLevelsDeep;
|
|
14
|
+
return checkIfRouteIsActive(path, currentPath, depth);
|
|
14
15
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
16
|
+
function checkIfRouteIsActive(targetLink, currentRoute, depth = 1) {
|
|
17
|
+
const currentRoutePath = currentRoute.split("?")[0] ?? "";
|
|
18
|
+
if (!isRoot(currentRoutePath) && isRoot(targetLink)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (!currentRoutePath.includes(targetLink)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
const isSameRoute = targetLink === currentRoutePath;
|
|
25
|
+
if (isSameRoute) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
return hasMatchingSegments(targetLink, currentRoutePath, depth);
|
|
28
29
|
}
|
|
29
30
|
function splitIntoSegments(href) {
|
|
30
|
-
|
|
31
|
+
return href.split("/").filter(Boolean);
|
|
31
32
|
}
|
|
32
33
|
function hasMatchingSegments(targetLink, currentRoute, depth) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
34
|
+
const segments = splitIntoSegments(targetLink);
|
|
35
|
+
const matchingSegments = numberOfMatchingSegments(currentRoute, segments);
|
|
36
|
+
if (targetLink === currentRoute) {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return matchingSegments > segments.length - (depth - 1);
|
|
39
40
|
}
|
|
40
41
|
function numberOfMatchingSegments(href, segments) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return count;
|
|
48
|
-
}
|
|
42
|
+
let count = 0;
|
|
43
|
+
for (const segment of splitIntoSegments(href)) {
|
|
44
|
+
if (segments.includes(segment)) {
|
|
45
|
+
count += 1;
|
|
46
|
+
} else {
|
|
47
|
+
return count;
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
}
|
|
50
|
+
return count;
|
|
51
51
|
}
|
|
52
52
|
function isRoot(path) {
|
|
53
|
-
|
|
53
|
+
return path === ROOT_PATH;
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
export { checkIfRouteIsActive, isRouteActive };
|
package/dist/utils/locale.d.ts
CHANGED
|
@@ -1,22 +1,84 @@
|
|
|
1
1
|
import { LanguageDetectorLingui } from '@regardio/js/intl/language-detector';
|
|
2
2
|
import { createCookie } from 'react-router';
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Configuration options for creating locale utilities
|
|
6
|
+
*/
|
|
7
|
+
interface LocaleConfigOptions {
|
|
8
|
+
/**
|
|
9
|
+
* Default locale to use as fallback
|
|
10
|
+
*/
|
|
4
11
|
defaultLocale: string;
|
|
12
|
+
/**
|
|
13
|
+
* List of supported locales
|
|
14
|
+
*/
|
|
5
15
|
supportedLocales: readonly string[];
|
|
16
|
+
/**
|
|
17
|
+
* Cookie options for storing locale preference
|
|
18
|
+
*/
|
|
6
19
|
cookieOptions?: {
|
|
20
|
+
/**
|
|
21
|
+
* Name of the cookie (default: 'locale')
|
|
22
|
+
*/
|
|
7
23
|
name?: string;
|
|
24
|
+
/**
|
|
25
|
+
* Max age of the cookie in seconds (default: 1 year)
|
|
26
|
+
*/
|
|
8
27
|
maxAge?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the cookie should be HTTP only (default: false)
|
|
30
|
+
*/
|
|
9
31
|
httpOnly?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Whether the cookie should be secure (default: true in production)
|
|
34
|
+
*/
|
|
10
35
|
secure?: boolean;
|
|
36
|
+
/**
|
|
37
|
+
* SameSite attribute for the cookie (default: 'lax')
|
|
38
|
+
*/
|
|
11
39
|
sameSite?: 'strict' | 'lax' | 'none';
|
|
12
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Detection options for the language detector
|
|
43
|
+
*/
|
|
13
44
|
detectionOptions?: {
|
|
45
|
+
/**
|
|
46
|
+
* Order of detection methods (default: ['urlPath', 'cookie', 'header'])
|
|
47
|
+
*/
|
|
14
48
|
order?: Array<'urlPath' | 'cookie' | 'header'>;
|
|
15
49
|
};
|
|
16
50
|
}
|
|
17
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Result of createLocaleConfig
|
|
53
|
+
*/
|
|
54
|
+
interface LocaleConfig {
|
|
55
|
+
/**
|
|
56
|
+
* Cookie for storing locale preference
|
|
57
|
+
*/
|
|
18
58
|
localeCookie: ReturnType<typeof createCookie>;
|
|
59
|
+
/**
|
|
60
|
+
* Language detector instance
|
|
61
|
+
*/
|
|
19
62
|
languageDetector: LanguageDetectorLingui;
|
|
20
63
|
}
|
|
21
|
-
|
|
22
|
-
|
|
64
|
+
/**
|
|
65
|
+
* Create locale configuration utilities
|
|
66
|
+
*
|
|
67
|
+
* This function creates a unified locale cookie and language detector
|
|
68
|
+
* based on the provided configuration options.
|
|
69
|
+
*
|
|
70
|
+
* @param options Configuration options
|
|
71
|
+
* @returns Locale configuration utilities
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* // In your app's configuration file
|
|
76
|
+
* const { localeCookie, languageDetector } = createLocaleConfig({
|
|
77
|
+
* defaultLocale: 'en',
|
|
78
|
+
* supportedLocales: ['en', 'de', 'fr'],
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare function createLocaleConfig(options: LocaleConfigOptions): LocaleConfig;
|
|
83
|
+
|
|
84
|
+
export { type LocaleConfig, type LocaleConfigOptions, createLocaleConfig };
|
package/dist/utils/locale.js
CHANGED
|
@@ -1,25 +1,36 @@
|
|
|
1
1
|
import { LanguageDetectorLingui } from '@regardio/js/intl/language-detector';
|
|
2
2
|
import { createCookie } from 'react-router';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
3
|
+
|
|
4
|
+
// src/utils/locale.ts
|
|
5
|
+
function createLocaleConfig(options) {
|
|
6
|
+
const { defaultLocale, supportedLocales, cookieOptions = {}, detectionOptions = {} } = options;
|
|
7
|
+
const {
|
|
8
|
+
name = "locale",
|
|
9
|
+
maxAge = 60 * 60 * 24 * 365,
|
|
10
|
+
// 1 year
|
|
11
|
+
httpOnly = false,
|
|
12
|
+
secure = import.meta.env.MODE !== "development",
|
|
13
|
+
sameSite = "lax"
|
|
14
|
+
} = cookieOptions;
|
|
15
|
+
const { order = ["urlPath", "cookie", "header"] } = detectionOptions;
|
|
16
|
+
const localeCookie = createCookie(name, {
|
|
17
|
+
httpOnly,
|
|
18
|
+
maxAge,
|
|
19
|
+
sameSite,
|
|
20
|
+
secure
|
|
21
|
+
});
|
|
22
|
+
const languageDetector = new LanguageDetectorLingui({
|
|
23
|
+
detection: {
|
|
24
|
+
cookie: localeCookie,
|
|
25
|
+
fallbackLanguage: defaultLocale,
|
|
26
|
+
order,
|
|
27
|
+
supportedLanguages: [...supportedLocales]
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
languageDetector,
|
|
32
|
+
localeCookie
|
|
33
|
+
};
|
|
25
34
|
}
|
|
35
|
+
|
|
36
|
+
export { createLocaleConfig };
|
package/dist/utils/text.d.ts
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import react__default, { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
declare const lowerCaseSzett: (text: ReactNode | string, _returnType?: "string") => ReactNode;
|
|
4
|
+
declare function toBoolean(value: string | boolean | null | undefined): boolean;
|
|
5
|
+
declare function shy(input: string | ReactNode | null): string | ReactNode | null;
|
|
6
|
+
/**
|
|
7
|
+
* Replace straight quotes with typographically correct quotes for the given locale.
|
|
8
|
+
*
|
|
9
|
+
* @param text - The text containing straight quotes
|
|
10
|
+
* @param locale - The locale to use for quote style (e.g., 'en', 'de', 'fr')
|
|
11
|
+
* @returns Text with typographic quotes
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* typographicQuotes('"Hello"', 'en') // → '"Hello"'
|
|
15
|
+
* typographicQuotes('"Hello"', 'de') // → '„Hello"'
|
|
16
|
+
* typographicQuotes('"Hello"', 'fr') // → '« Hello »'
|
|
17
|
+
*/
|
|
18
|
+
declare function typographicQuotes(text: string, locale: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use `typographicQuotes` for quote replacement and `shy` separately
|
|
21
|
+
*/
|
|
22
|
+
declare function replaceSpecialChars(text: string, locale: string): react__default.ReactNode;
|
|
23
|
+
|
|
24
|
+
export { lowerCaseSzett, replaceSpecialChars, shy, toBoolean, typographicQuotes };
|