@donotdev/ui 0.3.1 → 0.3.3
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/README.md +2 -3
- package/dist/components/auth/AuthHeader.js +1 -93
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +3 -286
- package/dist/components/auth/index.js +1 -9
- package/dist/components/common/FeatureCard.d.ts.map +1 -1
- package/dist/components/common/FeatureCard.js +1 -86
- package/dist/components/common/FeatureDisabled.js +1 -67
- package/dist/components/common/IconPlaceholder.d.ts +24 -0
- package/dist/components/common/IconPlaceholder.d.ts.map +1 -0
- package/dist/components/common/IconPlaceholder.js +1 -0
- package/dist/components/common/LazyLucideIcon.d.ts +39 -0
- package/dist/components/common/LazyLucideIcon.d.ts.map +1 -0
- package/dist/components/common/LazyLucideIcon.js +1 -0
- package/dist/components/common/ProgressBar.js +1 -84
- package/dist/components/common/RedirectOverlay.js +1 -243
- package/dist/components/common/Skeleton.js +1 -144
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +1 -53
- package/dist/components/common/icon.d.ts +1 -1
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +1 -84
- package/dist/components/common/iconByName.d.ts +33 -0
- package/dist/components/common/iconByName.d.ts.map +1 -0
- package/dist/components/common/iconByName.js +1 -0
- package/dist/components/common/index.js +1 -16
- package/dist/components/cookie-consent/ConsentBanner.d.ts +3 -1
- package/dist/components/cookie-consent/ConsentBanner.d.ts.map +1 -1
- package/dist/components/cookie-consent/ConsentBanner.js +1 -31
- package/dist/components/cookie-consent/CookieConsent.d.ts.map +1 -1
- package/dist/components/cookie-consent/CookieConsent.js +1 -183
- package/dist/components/cookie-consent/index.js +1 -11
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts +7 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.d.ts.map +1 -0
- package/dist/components/cookie-consent/useCookieNoticeRequired.js +1 -0
- package/dist/components/index.js +1 -13
- package/dist/components/layout/GameContainer.d.ts.map +1 -1
- package/dist/components/layout/GameContainer.js +1 -72
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/GameFlow.js +1 -93
- package/dist/components/layout/PageConfig.d.ts.map +1 -1
- package/dist/components/layout/PageConfig.js +1 -47
- package/dist/components/layout/PageContainer.d.ts.map +1 -1
- package/dist/components/layout/PageContainer.js +1 -38
- package/dist/components/layout/components/Breadcrumbs.d.ts +2 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +1 -89
- package/dist/components/layout/components/DropdownNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/DropdownNavigation.js +1 -30
- package/dist/components/layout/components/FloatingLanguageSwitcher.d.ts.map +1 -1
- package/dist/components/layout/components/FloatingLanguageSwitcher.js +1 -26
- package/dist/components/layout/components/Notifications.js +1 -182
- package/dist/components/layout/components/header/AppBranding.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppBranding.js +1 -54
- package/dist/components/layout/components/header/AppIcon.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppIcon.js +1 -59
- package/dist/components/layout/components/header/AppTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/AppTitle.js +1 -40
- package/dist/components/layout/components/header/CacheSettings.js +1 -225
- package/dist/components/layout/components/header/GameTitle.d.ts.map +1 -1
- package/dist/components/layout/components/header/GameTitle.js +1 -66
- package/dist/components/layout/components/header/HeaderMenu.js +1 -75
- package/dist/components/layout/components/header/HeaderNavigation.d.ts.map +1 -1
- package/dist/components/layout/components/header/HeaderNavigation.js +1 -66
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +1 -85
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +1 -93
- package/dist/components/layout/components/index.js +1 -25
- package/dist/components/layout/index.js +1 -14
- package/dist/crud/components/ChildRowsPicker.js +1 -68
- package/dist/crud/components/CrudCardLink.js +1 -14
- package/dist/crud/components/EntityCardList.d.ts +4 -1
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +1 -184
- package/dist/crud/components/EntityDisplayRenderer.js +1 -130
- package/dist/crud/components/EntityFormRenderer.js +1 -433
- package/dist/crud/components/EntityList.js +1 -521
- package/dist/crud/components/EntityRecommendations.js +1 -87
- package/dist/crud/components/EntityWorkflow.js +1 -55
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +1 -198
- package/dist/crud/components/cellEditFor.js +1 -74
- package/dist/crud/components/entityParent.js +1 -76
- package/dist/crud/components/index.js +1 -16
- package/dist/crud/components/useRecordBreadcrumb.d.ts +3 -1
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
- package/dist/crud/components/useRecordBreadcrumb.js +1 -43
- package/dist/crud/crudImports.js +1 -51
- package/dist/crud/index.js +1 -11
- package/dist/data/techLogos.js +1 -99
- package/dist/dndev-next.css +113 -41
- package/dist/dndev.css +113 -41
- package/dist/index.js +1 -5
- package/dist/internal/common/DnDevErrorBoundary.js +1 -55
- package/dist/internal/common/ErrorFallback.js +3 -214
- package/dist/internal/common/GlobalErrorFallback.js +1 -45
- package/dist/internal/common/RouteErrorFallback.js +3 -140
- package/dist/internal/devtools/DebugTools.js +1 -131
- package/dist/internal/devtools/components/AuthDebugButton.js +1 -72
- package/dist/internal/devtools/components/ConfigTab.js +1 -61
- package/dist/internal/devtools/components/CookieTab.js +1 -156
- package/dist/internal/devtools/components/DebugDialog.js +1 -48
- package/dist/internal/devtools/components/DesignTab.js +1 -469
- package/dist/internal/devtools/components/LayoutReset.js +1 -214
- package/dist/internal/devtools/components/MaskedValue.js +1 -39
- package/dist/internal/devtools/components/StoresTab.js +1 -90
- package/dist/internal/devtools/components/index.js +1 -16
- package/dist/internal/devtools/index.js +1 -13
- package/dist/internal/devtools/types.js +0 -2
- package/dist/internal/devtools/utils/envVarDiscovery.js +1 -106
- package/dist/internal/devtools/utils/index.js +1 -12
- package/dist/internal/devtools/utils/maskSensitive.js +1 -59
- package/dist/internal/devtools/utils/virtualModuleInspector.js +1 -309
- package/dist/internal/initializers/BaseStoresInitializer.js +1 -367
- package/dist/internal/initializers/NextJsStoresInitializer.js +1 -78
- package/dist/internal/initializers/ViteStoresInitializer.js +1 -20
- package/dist/internal/initializers/index.js +1 -11
- package/dist/internal/layout/DnDevLayout.js +1 -321
- package/dist/internal/layout/components/AutoMetaTags.d.ts +5 -0
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +1 -338
- package/dist/internal/layout/components/FaviconHead.d.ts +18 -14
- package/dist/internal/layout/components/FaviconHead.d.ts.map +1 -1
- package/dist/internal/layout/components/FaviconHead.js +1 -60
- package/dist/internal/layout/components/FontPreloadLinks.js +1 -31
- package/dist/internal/layout/components/HeadTags.js +1 -20
- package/dist/internal/layout/components/PWAUpdateNotification.js +1 -131
- package/dist/internal/layout/components/footer/FooterBranding.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterBranding.js +1 -35
- package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterCopyright.js +1 -37
- package/dist/internal/layout/components/footer/FooterLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +1 -44
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +4 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +1 -21
- package/dist/internal/layout/components/headTagElement.d.ts +16 -0
- package/dist/internal/layout/components/headTagElement.d.ts.map +1 -0
- package/dist/internal/layout/components/headTagElement.js +1 -0
- package/dist/internal/layout/components/index.js +1 -13
- package/dist/internal/layout/components/prerenderedHead.d.ts +15 -0
- package/dist/internal/layout/components/prerenderedHead.d.ts.map +1 -0
- package/dist/internal/layout/components/prerenderedHead.js +1 -0
- package/dist/internal/layout/components/trailingSlash.d.ts +13 -0
- package/dist/internal/layout/components/trailingSlash.d.ts.map +1 -0
- package/dist/internal/layout/components/trailingSlash.js +1 -0
- package/dist/internal/layout/config/defaults.js +1 -47
- package/dist/internal/layout/config/index.js +1 -11
- package/dist/internal/layout/config/presets/admin.js +1 -35
- package/dist/internal/layout/config/presets/blog.js +1 -31
- package/dist/internal/layout/config/presets/docs.js +1 -51
- package/dist/internal/layout/config/presets/game.js +1 -53
- package/dist/internal/layout/config/presets/index.js +1 -24
- package/dist/internal/layout/config/presets/landing.js +1 -42
- package/dist/internal/layout/config/presets/moolti.js +1 -52
- package/dist/internal/layout/config/presets/plain.js +1 -25
- package/dist/internal/layout/renderers/index.js +0 -10
- package/dist/internal/layout/zones/DnDevFooter.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevFooter.js +1 -67
- package/dist/internal/layout/zones/DnDevHeader.js +1 -41
- package/dist/internal/layout/zones/DnDevMergedBar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +1 -52
- package/dist/internal/layout/zones/DnDevSidebar.d.ts.map +1 -1
- package/dist/internal/layout/zones/DnDevSidebar.js +1 -181
- package/dist/internal/layout/zones/index.js +1 -14
- package/dist/internal/providers/NavigationProvider.d.ts.map +1 -1
- package/dist/internal/providers/NavigationProvider.js +1 -71
- package/dist/internal/providers/SentryInitializer.d.ts.map +1 -1
- package/dist/internal/providers/SentryInitializer.js +1 -36
- package/dist/internal/providers/UIProviders.js +1 -79
- package/dist/internal/providers/index.js +1 -12
- package/dist/next.js +1 -11
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +1 -107
- package/dist/providers/ViteAppProviders.d.ts +11 -9
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +1 -117
- package/dist/providers/index.js +1 -11
- package/dist/routing/404.js +1 -108
- package/dist/routing/AuthGuard.js +1 -178
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -67
- package/dist/routing/AuthReturnTo.js +1 -68
- package/dist/routing/DnDevNavigationMenu.d.ts.map +1 -1
- package/dist/routing/DnDevNavigationMenu.js +1 -138
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +1 -38
- package/dist/routing/GoToDialog.d.ts.map +1 -1
- package/dist/routing/GoToDialog.js +1 -97
- package/dist/routing/GoToInput.d.ts.map +1 -1
- package/dist/routing/GoToInput.js +1 -49
- package/dist/routing/GoToWrapper.d.ts.map +1 -1
- package/dist/routing/GoToWrapper.js +1 -59
- package/dist/routing/Link.d.ts +10 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +1 -109
- package/dist/routing/NavigationItem.d.ts.map +1 -1
- package/dist/routing/NavigationItem.js +1 -44
- package/dist/routing/NotFoundDocument.d.ts +33 -0
- package/dist/routing/NotFoundDocument.d.ts.map +1 -0
- package/dist/routing/NotFoundDocument.js +1 -0
- package/dist/routing/SignedInRedirect.js +1 -47
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/index.js +1 -26
- package/dist/routing/hooks/types.js +0 -2
- package/dist/routing/hooks/useLocation.next.js +1 -35
- package/dist/routing/hooks/useLocation.vite.js +1 -13
- package/dist/routing/hooks/useMatch.next.js +1 -31
- package/dist/routing/hooks/useMatch.vite.js +1 -6
- package/dist/routing/hooks/useNavigate.next.js +1 -64
- package/dist/routing/hooks/useNavigate.vite.js +1 -61
- package/dist/routing/hooks/useParams.next.js +1 -9
- package/dist/routing/hooks/useParams.vite.js +1 -6
- package/dist/routing/hooks/useQueryParams.next.js +1 -66
- package/dist/routing/hooks/useQueryParams.vite.js +1 -66
- package/dist/routing/hooks/useRedirectGuard.next.js +1 -119
- package/dist/routing/hooks/useRedirectGuard.vite.js +1 -117
- package/dist/routing/hooks/useRouteParam.next.js +1 -38
- package/dist/routing/hooks/useRouteParam.vite.js +1 -38
- package/dist/routing/hooks/useRoutePath.next.d.ts +5 -3
- package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRoutePath.next.js +1 -36
- package/dist/routing/hooks/useRoutePath.vite.js +1 -25
- package/dist/routing/hooks/useSearchParams.next.js +1 -22
- package/dist/routing/hooks/useSearchParams.vite.js +1 -22
- package/dist/routing/hooks/useUrlLanguage.next.js +1 -50
- package/dist/routing/hooks/useUrlLanguage.vite.js +1 -41
- package/dist/routing/index.d.ts +1 -0
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +1 -32
- package/dist/routing/link/InternalLink.next.d.ts +23 -0
- package/dist/routing/link/InternalLink.next.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.next.js +1 -0
- package/dist/routing/link/InternalLink.vite.d.ts +22 -0
- package/dist/routing/link/InternalLink.vite.d.ts.map +1 -0
- package/dist/routing/link/InternalLink.vite.js +1 -0
- package/dist/routing/link/absolutePath.d.ts +17 -0
- package/dist/routing/link/absolutePath.d.ts.map +1 -0
- package/dist/routing/link/absolutePath.js +1 -0
- package/dist/routing/link/link.next.d.ts +12 -0
- package/dist/routing/link/link.next.d.ts.map +1 -0
- package/dist/routing/link/link.next.js +1 -0
- package/dist/routing/link/link.vite.d.ts +12 -0
- package/dist/routing/link/link.vite.d.ts.map +1 -0
- package/dist/routing/link/link.vite.js +1 -0
- package/dist/routing/link/types.d.ts +30 -0
- package/dist/routing/link/types.d.ts.map +1 -0
- package/dist/routing/link/types.js +0 -0
- package/dist/routing/parentRoute.js +1 -43
- package/dist/routing/useGoTo.d.ts.map +1 -1
- package/dist/routing/useGoTo.js +1 -59
- package/dist/routing/useNavigation.d.ts.map +1 -1
- package/dist/routing/useNavigation.js +1 -114
- package/dist/routing/useRouteDiscovery.d.ts +4 -0
- package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
- package/dist/routing/useRouteDiscovery.js +1 -313
- package/dist/rsc.d.ts +28 -0
- package/dist/rsc.d.ts.map +1 -0
- package/dist/rsc.js +1 -0
- package/dist/styles/index.css +113 -41
- package/dist/styles/index.js +1 -10
- package/dist/styles/layoutConstants.js +1 -134
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts +19 -19
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -297
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -23
- package/dist/utils/sanitizeSvg.js +1 -51
- package/dist/utils/tList.js +1 -42
- package/dist/utils/useAISafe.d.ts.map +1 -1
- package/dist/utils/useAISafe.js +1 -53
- package/dist/utils/useAuthSafe.d.ts.map +1 -1
- package/dist/utils/useAuthSafe.js +1 -78
- package/dist/utils/useAuthVisibility.d.ts.map +1 -1
- package/dist/utils/useAuthVisibility.js +1 -63
- package/dist/utils/useBillingVisibility.d.ts.map +1 -1
- package/dist/utils/useBillingVisibility.js +1 -57
- package/dist/utils/useCrudSafe.d.ts.map +1 -1
- package/dist/utils/useCrudSafe.js +1 -75
- package/dist/utils/useDeleteAccountSafe.js +1 -52
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -85
- package/dist/utils/useOAuthSafe.d.ts.map +1 -1
- package/dist/utils/useOAuthSafe.js +1 -38
- package/dist/utils/useStripeBillingSafe.d.ts.map +1 -1
- package/dist/utils/useStripeBillingSafe.js +1 -81
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +1 -235
- package/dist/vite-routing/RootLayout.d.ts.map +1 -1
- package/dist/vite-routing/RootLayout.js +1 -205
- package/dist/vite-routing/index.js +1 -11
- package/dist/vite.js +1 -10
- package/guidelines/COMPONENTS.md +3 -3
- package/guidelines/PAGES.md +3 -0
- package/guidelines/ROUTING.md +16 -0
- package/guidelines/SEO.md +160 -142
- package/package.json +18 -8
- package/dist/ChildRowsPicker-63M4EQUQ.js +0 -1
- package/dist/ChildRowsPicker-ISP365ON.js +0 -1
- package/dist/ChildRowsPicker-PQFE6NCR.js +0 -1
- package/dist/ChildRowsPicker-XXFFSMWY.js +0 -1
- package/dist/CookieConsent-QOUAY6B4.js +0 -1
- package/dist/GoToDialog-KSBGOIWO.js +0 -1
- package/dist/GoToDialog-XBK5EZF4.js +0 -1
- package/dist/chunk-3CIZFGST.js +0 -1
- package/dist/chunk-LHMKU342.js +0 -1
- package/dist/chunk-MS7ZIW5Z.js +0 -1
- package/dist/chunk-O2XFH626.js +0 -1
- package/dist/chunk-P2DHZWPY.js +0 -1
- package/dist/components/common/lucideIconByName.d.ts +0 -9
- package/dist/components/common/lucideIconByName.d.ts.map +0 -1
- package/dist/components/common/lucideIconByName.js +0 -32
- package/dist/internal/layout/components/PerformanceHints.d.ts +0 -71
- package/dist/internal/layout/components/PerformanceHints.d.ts.map +0 -1
- package/dist/internal/layout/components/PerformanceHints.js +0 -71
- package/dist/internal/layout/components/i18nSeoMeta.d.ts +0 -54
- package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +0 -1
- package/dist/internal/layout/components/i18nSeoMeta.js +0 -53
- package/dist/utils/useSeo.d.ts +0 -129
- package/dist/utils/useSeo.d.ts.map +0 -1
- package/dist/utils/useSeo.js +0 -151
|
@@ -1,49 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
// packages/ui/src/routing/GoToInput.tsx
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview GoToInput - Typeable navigation input
|
|
5
|
-
* @description Real input that opens command dialog with current search value
|
|
6
|
-
*
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @since 0.0.1
|
|
9
|
-
* @author AMBROISE PARK Consulting
|
|
10
|
-
*/
|
|
11
|
-
import { Search } from 'lucide-react';
|
|
12
|
-
import { useEffect, useState, useRef } from 'react';
|
|
13
|
-
import { Stack } from '@donotdev/components';
|
|
14
|
-
import { useOverlayStore } from '@donotdev/core';
|
|
15
|
-
import { useTranslation } from '@donotdev/core';
|
|
16
|
-
/**
|
|
17
|
-
* Navigation input - typeable search that syncs with command dialog
|
|
18
|
-
*/
|
|
19
|
-
/** Detect macOS/iOS for keyboard shortcut label (defaults to ⌘K during SSR) */
|
|
20
|
-
const isMac = typeof navigator !== 'undefined' &&
|
|
21
|
-
/Mac|iPhone|iPad/.test(navigator.userAgent);
|
|
22
|
-
const GoToInput = () => {
|
|
23
|
-
const { t } = useTranslation('dndev');
|
|
24
|
-
const [value, setValue] = useState('');
|
|
25
|
-
const inputRef = useRef(null);
|
|
26
|
-
const isCommandDialogOpen = useOverlayStore((state) => state.isCommandDialogOpen);
|
|
27
|
-
// Clear input when dialog closes
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
if (!isCommandDialogOpen) {
|
|
30
|
-
setValue('');
|
|
31
|
-
}
|
|
32
|
-
}, [isCommandDialogOpen]);
|
|
33
|
-
const handleFocus = () => {
|
|
34
|
-
useOverlayStore.getState().openCommandDialog(value);
|
|
35
|
-
};
|
|
36
|
-
const handleKeyDown = (e) => {
|
|
37
|
-
if (e.key === 'Enter') {
|
|
38
|
-
e.preventDefault();
|
|
39
|
-
useOverlayStore.getState().openCommandDialog(value);
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
return (_jsxs(Stack, { direction: "row", align: "center", className: "dndev-relative dndev-w-full dndev-max-w-sm", role: "search", children: [_jsx(Search, { className: "dndev-absolute dndev-size-md", style: { insetInlineStart: '0.75rem', opacity: 0.5 }, "aria-hidden": "true" }), _jsx("input", { ref: inputRef, type: "text", value: value, onChange: (e) => setValue(e.target.value), onFocus: handleFocus, onKeyDown: handleKeyDown, placeholder: t('globalGoTo.searchPlaceholder', 'Search pages...'), className: "dndev-input dndev-w-full", style: { paddingInlineStart: '2.5rem', paddingInlineEnd: '5rem' }, "aria-label": t('globalGoTo.ariaLabel', 'Search navigation') }), _jsx("div", { className: "dndev-absolute dndev-flex dndev-items-center dndev-text-sm", style: { insetInlineEnd: '0.75rem', gap: '0.25rem', opacity: 0.5 }, "aria-hidden": "true", children: _jsx("kbd", { style: {
|
|
43
|
-
padding: '0.25rem 0.5rem',
|
|
44
|
-
fontSize: 'var(--font-size-xs)',
|
|
45
|
-
fontFamily: 'var(--font-mono)',
|
|
46
|
-
borderRadius: 'var(--radius-sm)',
|
|
47
|
-
}, children: isMac ? '⌘K' : 'Ctrl+K' }) })] }));
|
|
48
|
-
};
|
|
49
|
-
export default GoToInput;
|
|
1
|
+
"use client";import{Search as i}from"lucide-react";import{useEffect as s,useState as m,useRef as c}from"react";import{Stack as u}from"@donotdev/components";import{useOverlayStore as t}from"@donotdev/core";import{useTranslation as p}from"@donotdev/core";import{jsx as n,jsxs as g}from"react/jsx-runtime";var v=typeof navigator<"u"&&/Mac|iPhone|iPad/.test(navigator.userAgent),f=()=>{let{t:o}=p("dndev"),[a,d]=m(""),l=c(null),r=t(e=>e.isCommandDialogOpen);return s(()=>{r||d("")},[r]),g(u,{direction:"row",align:"center",className:"dndev-relative dndev-w-full dndev-max-w-sm",role:"search",children:[n(i,{className:"dndev-absolute dndev-size-md",style:{insetInlineStart:"0.75rem",opacity:.5},"aria-hidden":"true"}),n("input",{ref:l,type:"text",value:a,onChange:e=>d(e.target.value),onFocus:()=>{t.getState().openCommandDialog(a)},onKeyDown:e=>{e.key==="Enter"&&(e.preventDefault(),t.getState().openCommandDialog(a))},placeholder:o("globalGoTo.searchPlaceholder","Search pages..."),className:"dndev-input dndev-w-full",style:{paddingInlineStart:"2.5rem",paddingInlineEnd:"5rem"},"aria-label":o("globalGoTo.ariaLabel","Search navigation")}),n("div",{className:"dndev-absolute dndev-flex dndev-items-center dndev-text-sm",style:{insetInlineEnd:"0.75rem",gap:"0.25rem",opacity:.5},"aria-hidden":"true",children:n("kbd",{style:{padding:"0.25rem 0.5rem",fontSize:"var(--font-size-xs)",fontFamily:"var(--font-mono)",borderRadius:"var(--radius-sm)"},children:v?"\u2318K":"Ctrl+K"})})]})},I=f;export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoToWrapper.d.ts","sourceRoot":"","sources":["../../src/routing/GoToWrapper.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GoToWrapper.d.ts","sourceRoot":"","sources":["../../src/routing/GoToWrapper.tsx"],"names":[],"mappings":"AAwBA;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,WAAW,mCAsChB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1,59 +1 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
// packages/ui/src/routing/GoToWrapper.tsx
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview GoToWrapper Component
|
|
5
|
-
* @description Navigation command palette wrapper with Cmd+K listener
|
|
6
|
-
*
|
|
7
|
-
* Features:
|
|
8
|
-
* - Cmd+K keyboard shortcut for quick access
|
|
9
|
-
* - Lazy-loaded dialog for optimal performance
|
|
10
|
-
* - CSR/SSR safe with graceful fallbacks
|
|
11
|
-
*
|
|
12
|
-
* @version 0.1.0
|
|
13
|
-
* @since 0.0.1
|
|
14
|
-
* @author AMBROISE PARK Consulting
|
|
15
|
-
*/
|
|
16
|
-
import { Suspense, lazy } from 'react';
|
|
17
|
-
import { useEventListener, useOverlayStore } from '@donotdev/core';
|
|
18
|
-
// Lazy load the dialog
|
|
19
|
-
const GoToDialog = lazy(() => import('./GoToDialog'));
|
|
20
|
-
/**
|
|
21
|
-
* GoToWrapper - Keyboard listener + lazy dialog
|
|
22
|
-
*
|
|
23
|
-
* Performance:
|
|
24
|
-
* - Zero code loaded until dialog opens
|
|
25
|
-
* - Cmd+K listener always active
|
|
26
|
-
* - Dialog lazy-loaded on first open
|
|
27
|
-
*
|
|
28
|
-
* @version 0.1.0
|
|
29
|
-
* @since 0.0.1
|
|
30
|
-
* @author AMBROISE PARK Consulting
|
|
31
|
-
*/
|
|
32
|
-
const GoToWrapper = () => {
|
|
33
|
-
const openCommandDialog = useOverlayStore((state) => state.openCommandDialog);
|
|
34
|
-
// Cmd+K keyboard shortcut
|
|
35
|
-
useEventListener('keydown', (event) => {
|
|
36
|
-
if ((event.metaKey || event.ctrlKey) && event.key === 'k') {
|
|
37
|
-
// Don't intercept Cmd+K in form fields where it may have native meaning
|
|
38
|
-
const target = event.target;
|
|
39
|
-
if (target.tagName === 'INPUT' ||
|
|
40
|
-
target.tagName === 'TEXTAREA' ||
|
|
41
|
-
target.isContentEditable) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
event.preventDefault();
|
|
45
|
-
openCommandDialog();
|
|
46
|
-
}
|
|
47
|
-
}, {
|
|
48
|
-
// `document` is referenced at render time (hook argument), so guard it for
|
|
49
|
-
// SSR — the listener itself only attaches in an effect (client). Without
|
|
50
|
-
// this, server rendering throws `document is not defined`.
|
|
51
|
-
target: typeof document !== 'undefined' ? document : undefined,
|
|
52
|
-
options: {
|
|
53
|
-
passive: false,
|
|
54
|
-
capture: false,
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
return (_jsx(Suspense, { fallback: null, children: _jsx(GoToDialog, {}) }));
|
|
58
|
-
};
|
|
59
|
-
export default GoToWrapper;
|
|
1
|
+
"use client";import{Suspense as n,lazy as r}from"react";import{useEventListener as s,useOverlayStore as l}from"@donotdev/core";import{jsx as o}from"react/jsx-runtime";var i=r(()=>import("./GoToDialog.js")),m=()=>{let a=l(e=>e.openCommandDialog);return s("keydown",e=>{if((e.metaKey||e.ctrlKey)&&e.key==="k"){let t=e.target;if(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)return;e.preventDefault(),a()}},{target:typeof document<"u"?document:void 0,options:{passive:!1,capture:!1}}),o(n,{fallback:null,children:o(i,{})})},d=m;export{d as default};
|
package/dist/routing/Link.d.ts
CHANGED
|
@@ -9,6 +9,12 @@ import type { ReactNode, ComponentType, AnchorHTMLAttributes } from 'react';
|
|
|
9
9
|
export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
10
10
|
path: string;
|
|
11
11
|
replace?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Next.js: internal links render next/link, prefetched with its default behaviour for
|
|
14
|
+
* guests and in full for signed-in visitors (their pages render per request, which the
|
|
15
|
+
* default skips); `false` disables prefetching. Vite: no effect.
|
|
16
|
+
* @default true
|
|
17
|
+
*/
|
|
12
18
|
prefetch?: boolean;
|
|
13
19
|
children?: ReactNode;
|
|
14
20
|
/** Icon component or string name */
|
|
@@ -23,9 +29,11 @@ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
23
29
|
/**
|
|
24
30
|
* Link component. Internal paths are app paths (`/produits`): the rendered `href` and
|
|
25
31
|
* the navigation use the current language's URL (`/en/produits` on an English page,
|
|
26
|
-
* unchanged in the default language or a one-language app).
|
|
32
|
+
* unchanged in the default language or a one-language app). Internal links render
|
|
33
|
+
* next/link on Next.js (route prefetch, client-side navigation) and an `<a href>`
|
|
34
|
+
* navigated by react-router on Vite; both output a real `<a href>`.
|
|
27
35
|
*
|
|
28
|
-
* @version 0.
|
|
36
|
+
* @version 0.3.0
|
|
29
37
|
* @since 0.0.1
|
|
30
38
|
* @author AMBROISE PARK Consulting
|
|
31
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/routing/Link.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,oBAAoB,EACrB,MAAM,OAAO,CAAC;AASf;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED
|
|
1
|
+
{"version":3,"file":"Link.d.ts","sourceRoot":"","sources":["../../src/routing/Link.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EACV,SAAS,EACT,aAAa,EAEb,oBAAoB,EACrB,MAAM,OAAO,CAAC;AASf;;;;;;GAMG;AACH,MAAM,WAAW,SAAU,SAAQ,oBAAoB,CAAC,iBAAiB,CAAC;IACxE,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,oCAAoC;IACpC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,iDAAiD;IACjD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,IAAI,EAAE,aAAa,CAAC,SAAS,CA8HzC,CAAC"}
|
package/dist/routing/Link.js
CHANGED
|
@@ -1,109 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/routing/Link.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview Link component
|
|
6
|
-
* @description Platform-agnostic link component for navigation
|
|
7
|
-
*
|
|
8
|
-
* @version 0.1.0
|
|
9
|
-
* @since 0.0.1
|
|
10
|
-
* @author AMBROISE PARK Consulting
|
|
11
|
-
*/
|
|
12
|
-
import { Link as LinkIcon } from 'lucide-react';
|
|
13
|
-
import { cn } from '@donotdev/components';
|
|
14
|
-
import { useConsent } from '@donotdev/core';
|
|
15
|
-
// Platform-specific hooks via conditional exports
|
|
16
|
-
import { useLocalizedPath, useNavigate } from '@donotdev/ui/routing/hooks';
|
|
17
|
-
import { Icon } from '../components/common/icon';
|
|
18
|
-
/**
|
|
19
|
-
* Link component. Internal paths are app paths (`/produits`): the rendered `href` and
|
|
20
|
-
* the navigation use the current language's URL (`/en/produits` on an English page,
|
|
21
|
-
* unchanged in the default language or a one-language app).
|
|
22
|
-
*
|
|
23
|
-
* @version 0.2.0
|
|
24
|
-
* @since 0.0.1
|
|
25
|
-
* @author AMBROISE PARK Consulting
|
|
26
|
-
*/
|
|
27
|
-
export const Link = ({ path, replace, prefetch = true, children, icon, iconEnd = false, label, onClick, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, target, rel, ...rest }) => {
|
|
28
|
-
const navigate = useNavigate();
|
|
29
|
-
const localize = useLocalizedPath();
|
|
30
|
-
const showCookieBanner = useConsent('showCookieBanner');
|
|
31
|
-
// Special framework trigger: #cookie-settings
|
|
32
|
-
if (path === '#cookie-settings') {
|
|
33
|
-
const handleCookieSettings = (e) => {
|
|
34
|
-
// Honor browser native open-in-new-tab on modifier+click or non-left-click.
|
|
35
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
|
|
36
|
-
if (onClick)
|
|
37
|
-
onClick(e);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
e.stopPropagation();
|
|
42
|
-
try {
|
|
43
|
-
showCookieBanner();
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
console.error('Failed to show cookie banner:', error);
|
|
47
|
-
}
|
|
48
|
-
if (onClick) {
|
|
49
|
-
onClick(e);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
return (_jsxs("a", { href: "#cookie-settings", onClick: handleCookieSettings, className: className, style: {
|
|
53
|
-
display: icon && (label || children) ? 'flex' : undefined,
|
|
54
|
-
alignItems: icon && (label || children) ? 'center' : undefined,
|
|
55
|
-
gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
|
|
56
|
-
...rest.style,
|
|
57
|
-
}, "aria-label": ariaLabel || label || 'Cookie Settings', "aria-describedby": ariaDescribedBy, ...rest, children: [icon && !iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon }), label && _jsx("span", { children: label }), children, icon && iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon })] }));
|
|
58
|
-
}
|
|
59
|
-
// Auto-detect external URLs
|
|
60
|
-
const isExternal = path.startsWith('http://') ||
|
|
61
|
-
path.startsWith('https://') ||
|
|
62
|
-
path.startsWith('mailto:') ||
|
|
63
|
-
path.startsWith('tel:');
|
|
64
|
-
const handleClick = (e) => {
|
|
65
|
-
// External links: let browser handle naturally
|
|
66
|
-
if (isExternal) {
|
|
67
|
-
if (onClick) {
|
|
68
|
-
onClick(e);
|
|
69
|
-
}
|
|
70
|
-
return; // Don't prevent default for external links
|
|
71
|
-
}
|
|
72
|
-
// Honor browser native open-in-new-tab on modifier+click or non-left-click.
|
|
73
|
-
// Without this, preventDefault() below would block the browser default,
|
|
74
|
-
// and Ctrl/Cmd-click would silently navigate in the same tab.
|
|
75
|
-
if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey || e.button !== 0) {
|
|
76
|
-
if (onClick)
|
|
77
|
-
onClick(e);
|
|
78
|
-
return; // browser handles new tab / new window
|
|
79
|
-
}
|
|
80
|
-
// Internal links: use framework navigation
|
|
81
|
-
e.preventDefault();
|
|
82
|
-
if (onClick) {
|
|
83
|
-
onClick(e);
|
|
84
|
-
}
|
|
85
|
-
// Ensure path is absolute (starts with /) to prevent relative navigation issues
|
|
86
|
-
// but preserve intentional relative paths (starting with '.' or '..')
|
|
87
|
-
const absolutePath = path.startsWith('/') || path.startsWith('.') ? path : `/${path}`;
|
|
88
|
-
navigate(absolutePath, { replace });
|
|
89
|
-
};
|
|
90
|
-
const accessibilityProps = {
|
|
91
|
-
'aria-label': ariaLabel || label,
|
|
92
|
-
'aria-describedby': ariaDescribedBy,
|
|
93
|
-
};
|
|
94
|
-
const linkContent = (_jsxs(_Fragment, { children: [icon && !iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon }), label && _jsx("span", { children: label }), children, icon && iconEnd && _jsx(Icon, { icon: icon, fallback: LinkIcon })] }));
|
|
95
|
-
// External links: use regular <a> with target/rel
|
|
96
|
-
if (isExternal) {
|
|
97
|
-
return (_jsx("a", { href: path, onClick: handleClick, target: target || '_blank', rel: rel || 'noopener noreferrer', className: className, style: {
|
|
98
|
-
display: icon && (label || children) ? 'flex' : undefined,
|
|
99
|
-
alignItems: icon && (label || children) ? 'center' : undefined,
|
|
100
|
-
gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
|
|
101
|
-
}, ...accessibilityProps, ...rest, children: linkContent }));
|
|
102
|
-
}
|
|
103
|
-
// Internal links: the URL in the current language (`/en/…`), same as navigate()
|
|
104
|
-
return (_jsx("a", { href: localize(path), onClick: handleClick, className: className, style: {
|
|
105
|
-
display: icon && (label || children) ? 'flex' : undefined,
|
|
106
|
-
alignItems: icon && (label || children) ? 'center' : undefined,
|
|
107
|
-
gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
|
|
108
|
-
}, ...accessibilityProps, ...rest, children: linkContent }));
|
|
109
|
-
};
|
|
1
|
+
"use client";import{Link as p}from"lucide-react";import{useConsent as x}from"@donotdev/core";import{InternalLink as A}from"@donotdev/ui/routing/link";import{Icon as d}from"../components/common/icon.js";import{useCookieNoticeRequired as M}from"../components/cookie-consent/useCookieNoticeRequired.js";import{Fragment as N,jsx as o,jsxs as l}from"react/jsx-runtime";var E=({path:s,replace:y,prefetch:b=!0,children:r,icon:e,iconEnd:i=!1,label:t,onClick:a,className:u,"aria-label":m,"aria-describedby":c,target:L,rel:h,...f})=>{let C=x("showCookieBanner"),I=M();if(s==="#cookie-settings")return I?l("a",{href:"#cookie-settings",onClick:n=>{if(n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||n.button!==0){a&&a(n);return}n.preventDefault(),n.stopPropagation();try{C()}catch{}a&&a(n)},className:u,style:{display:e&&(t||r)?"flex":void 0,alignItems:e&&(t||r)?"center":void 0,gap:e&&(t||r)?"var(--gap-sm)":void 0,...f.style},"aria-label":m||t||"Cookie Settings","aria-describedby":c,...f,children:[e&&!i&&o(d,{icon:e,fallback:p}),t&&o("span",{children:t}),r,e&&i&&o(d,{icon:e,fallback:p})]}):null;let v=s.startsWith("http://")||s.startsWith("https://")||s.startsWith("mailto:")||s.startsWith("tel:"),g={"aria-label":m||t,"aria-describedby":c},k=l(N,{children:[e&&!i&&o(d,{icon:e,fallback:p}),t&&o("span",{children:t}),r,e&&i&&o(d,{icon:e,fallback:p})]});return v?o("a",{href:s,onClick:a,target:L||"_blank",rel:h||"noopener noreferrer",className:u,style:{display:e&&(t||r)?"flex":void 0,alignItems:e&&(t||r)?"center":void 0,gap:e&&(t||r)?"var(--gap-sm)":void 0},...g,...f,children:k}):o(A,{path:s,replace:y,prefetch:b,onClick:a,className:u,style:{display:e&&(t||r)?"flex":void 0,alignItems:e&&(t||r)?"center":void 0,gap:e&&(t||r)?"var(--gap-sm)":void 0},...g,...f,children:k})};export{E as Link};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NavigationItem.d.ts","sourceRoot":"","sources":["../../src/routing/NavigationItem.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NavigationItem.d.ts","sourceRoot":"","sources":["../../src/routing/NavigationItem.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAG3C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAMtD;;;;;;GAMG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAC9B;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,KAAK,CAAA;CAAE,GAC/B;IAAE,KAAK,EAAE,eAAe,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,CAC3C,GAAG;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,uBAAuB,EAAE,aAAa,CAAC,mBAAmB,CAuBtE,CAAC"}
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
// packages/ui/src/routing/NavigationItem.tsx
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview NavigationItem component
|
|
5
|
-
* @description Universal navigation item component with icon and label
|
|
6
|
-
*
|
|
7
|
-
* @version 0.1.0
|
|
8
|
-
* @since 0.0.1
|
|
9
|
-
* @author AMBROISE PARK Consulting
|
|
10
|
-
*/
|
|
11
|
-
import { Link as LinkIcon } from 'lucide-react';
|
|
12
|
-
import { navigationMenuTriggerStylePrimitive } from '@donotdev/components';
|
|
13
|
-
import { Link } from './Link';
|
|
14
|
-
import { useNavigationItems } from './useNavigation';
|
|
15
|
-
import { Icon } from '../components/common/icon';
|
|
16
|
-
/**
|
|
17
|
-
* Universal NavigationItem component — nav-trigger style link with icon + label.
|
|
18
|
-
*
|
|
19
|
-
* Used internally in menus, sidebars, and dropdowns.
|
|
20
|
-
* Pass `path` to auto-resolve label, icon, and active state from the navigation store.
|
|
21
|
-
* Pass `route` for an explicit one-off item not registered in the store.
|
|
22
|
-
*
|
|
23
|
-
* For standalone Button-style navigation (e.g. header end slot), use
|
|
24
|
-
* `useNavigationRoute(path)` and compose with `Button` + `render` prop directly.
|
|
25
|
-
*
|
|
26
|
-
* @version 0.1.0
|
|
27
|
-
* @since 0.0.1
|
|
28
|
-
* @author AMBROISE PARK Consulting
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* <NavigationItemComponent path="/pricing" />
|
|
33
|
-
* <NavigationItemComponent route={{ path: '/pricing', label: t('pricing'), icon: Tag }} />
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
export const NavigationItemComponent = ({ path, route: routeProp, showIcons = true, }) => {
|
|
37
|
-
const allItems = useNavigationItems();
|
|
38
|
-
const route = routeProp ?? allItems.find((item) => item.path === path);
|
|
39
|
-
if (!route)
|
|
40
|
-
return null;
|
|
41
|
-
const hasIcon = showIcons && !!route.icon;
|
|
42
|
-
const hasLabel = !!route.label;
|
|
43
|
-
return (_jsxs(Link, { path: route.path, className: navigationMenuTriggerStylePrimitive(), ...(hasIcon && !hasLabel && { 'data-display': 'compact' }), children: [showIcons && _jsx(Icon, { icon: route.icon, fallback: LinkIcon }), _jsx("span", { children: route.label })] }));
|
|
44
|
-
};
|
|
1
|
+
"use client";import{Link as s}from"lucide-react";import{navigationMenuTriggerStylePrimitive as c}from"@donotdev/components";import{Link as l}from"./Link.js";import{useNavigationItems as u}from"./useNavigation.js";import{Icon as v}from"../components/common/icon.js";import{jsx as e,jsxs as f}from"react/jsx-runtime";var b=({path:n,route:a,showIcons:t=!0})=>{let i=u(),o=a??i.find(m=>m.path===n);if(!o)return null;let r=t&&!!o.icon,p=!!o.label;return f(l,{path:o.path,className:c(),...r&&!p&&{"data-display":"compact"},children:[t&&e(v,{icon:o.icon,fallback:s}),e("span",{children:o.label})]})};export{b as NavigationItemComponent};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Wraps the providers of a 404 document. Rendered by the framework's generated 404
|
|
4
|
+
* pages; an app renders it only in a 404 page of its own.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* <NotFoundDocument>
|
|
9
|
+
* <ClientLayout serverCookies="" acceptLanguage={null}>
|
|
10
|
+
* <NotFoundPage showRequestedPath={false} />
|
|
11
|
+
* </ClientLayout>
|
|
12
|
+
* </NotFoundDocument>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @version 0.1.0
|
|
16
|
+
* @since 0.3.2
|
|
17
|
+
* @author AMBROISE PARK Consulting
|
|
18
|
+
*/
|
|
19
|
+
export declare function NotFoundDocument({ children }: {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Whether the render is inside a NotFoundDocument (the 404 document, served for
|
|
24
|
+
* any unknown URL): URL-derived output must be omitted there.
|
|
25
|
+
*
|
|
26
|
+
* @returns `true` inside a NotFoundDocument
|
|
27
|
+
*
|
|
28
|
+
* @version 0.1.0
|
|
29
|
+
* @since 0.3.2
|
|
30
|
+
* @author AMBROISE PARK Consulting
|
|
31
|
+
*/
|
|
32
|
+
export declare function useIsNotFoundDocument(): boolean;
|
|
33
|
+
//# sourceMappingURL=NotFoundDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotFoundDocument.d.ts","sourceRoot":"","sources":["../../src/routing/NotFoundDocument.tsx"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,+BAMrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,IAAI,OAAO,CAE/C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use client";import{createContext as e,useContext as n}from"react";import{jsx as r}from"react/jsx-runtime";var o=e(!1);function c({children:t}){return r(o.Provider,{value:!0,children:t})}function d(){return n(o)}export{c as NotFoundDocument,d as useIsNotFoundDocument};
|
|
@@ -1,47 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
// packages/ui/src/routing/SignedInRedirect.tsx
|
|
4
|
-
/**
|
|
5
|
-
* @fileoverview SignedInRedirect component
|
|
6
|
-
* @description Client side of PageMeta `signedInRedirect`: sends a signed-in visitor
|
|
7
|
-
* of the page to another path. The generated Next proxy redirects before render when
|
|
8
|
-
* it can read the session cookie; this covers sign-ins on the page itself (no server
|
|
9
|
-
* request) and sessions the server cannot read.
|
|
10
|
-
*
|
|
11
|
-
* @version 0.1.0
|
|
12
|
-
* @since 0.6.0
|
|
13
|
-
* @author AMBROISE PARK Consulting
|
|
14
|
-
*/
|
|
15
|
-
import { useEffect } from 'react';
|
|
16
|
-
import { isClient, safeSessionStorage } from '@donotdev/core';
|
|
17
|
-
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
18
|
-
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
19
|
-
/**
|
|
20
|
-
* SignedInRedirect - sends signed-in visitors of a page to `to` (replace).
|
|
21
|
-
*
|
|
22
|
-
* Renders the page for everyone (server render, signed-out visitors). Once the auth
|
|
23
|
-
* user is known, navigates to `to` unless a return-to is pending (`?returnTo=` or
|
|
24
|
-
* the saved `dndev.auth.returnTo`): AuthReturnTo takes the visitor there instead.
|
|
25
|
-
* Generated route wrappers (Next) and createAppRouter (Vite) mount it for pages whose
|
|
26
|
-
* PageMeta sets `signedInRedirect`.
|
|
27
|
-
*
|
|
28
|
-
* @component
|
|
29
|
-
* @example
|
|
30
|
-
* ```tsx
|
|
31
|
-
* <SignedInRedirect to="/catalogue"><HomePage /></SignedInRedirect>
|
|
32
|
-
* ```
|
|
33
|
-
*/
|
|
34
|
-
export function SignedInRedirect({ to, children }) {
|
|
35
|
-
const user = useAuthSafe('user');
|
|
36
|
-
const navigate = useNavigate();
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (!user || !isClient())
|
|
39
|
-
return;
|
|
40
|
-
if (new URLSearchParams(window.location.search).has('returnTo'))
|
|
41
|
-
return;
|
|
42
|
-
if (safeSessionStorage.getItem('dndev.auth.returnTo'))
|
|
43
|
-
return;
|
|
44
|
-
navigate(to, { replace: true });
|
|
45
|
-
}, [user, to, navigate]);
|
|
46
|
-
return _jsx(_Fragment, { children: children });
|
|
47
|
-
}
|
|
1
|
+
"use client";import{useEffect as o}from"react";import{isClient as i,safeSessionStorage as a}from"@donotdev/core";import{useNavigate as s}from"@donotdev/ui/routing/hooks";import{useAuthSafe as c}from"../utils/useAuthSafe.js";import{Fragment as u,jsx as f}from"react/jsx-runtime";function S({to:e,children:n}){let r=c("user"),t=s();return o(()=>{!r||!i()||new URLSearchParams(window.location.search).has("returnTo")||a.getItem("dndev.auth.returnTo")||t(e,{replace:!0})},[r,e,t]),f(u,{children:n})}export{S as SignedInRedirect};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useRouter as d}from"next/navigation";import{isClient as G,useOverlayStore as $}from"@donotdev/core";import{usePathname as
|
|
1
|
+
"use client";import{useRouter as d}from"next/navigation";import{isClient as G,useOverlayStore as $}from"@donotdev/core";import{usePathname as C}from"next/navigation";import{getLanguageRouting as b,localizePath as L,publicPathname as N,splitLanguagePath as I}from"@donotdev/core";function w(){return I(N(C()??"/"),b()).language}function h(){let e=w(),t=b();return r=>L(r,e,t)}function P(){let e=d(),t=$(n=>n.closeAll),r=h();return(n,o)=>{if(n==="back")return t(),e.back();t();let u=r(n);if(o?.preserveScroll&&G()){let s=window.scrollY;o?.replace?e.replace(u):e.push(u),requestAnimationFrame(()=>{window.scrollTo({top:s,behavior:"auto"})});return}return o?.replace?e.replace(u):e.push(u)}}function U(){let e=d();return()=>e.back()}function K(){let e=d();return()=>e.refresh()}function E(){let e=d(),t=h();return r=>e.prefetch(t(r))}import{useSearchParams as F}from"next/navigation";import{usePathname as O}from"next/navigation";import{getLanguageRouting as z,publicPathname as q,splitLanguagePath as Q,stripTrailingSlash as D}from"@donotdev/core";function m(){return Q(q(D(O()??"/")),z()).path}function R(){let e=m(),r=F().toString(),n=r?`?${r}`:void 0;return{pathname:e,search:n,hash:"",state:null}}import{useParams as M}from"next/navigation";function x(){let e=M();return e||{}}function j(e){let r=x()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as _}from"next/navigation";function A(){return _()}function B(e){let t=m(),r=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),n=new RegExp(`^${r}$`),o=t.match(n);if(!o)return null;let u=e.match(/:[^/]+/g)?.map(a=>a.slice(1))||[],s={};return u.forEach((a,i)=>{s[a]=o[i+1]||""}),{params:s,pathname:t,pattern:e}}import{useCallback as S}from"react";function Y(){let e=A(),t=P(),r=R(),n=S((s,a)=>{let i=new URLSearchParams(e.toString());i.set(s,a);let p=i.toString(),c=`${r.pathname||"/"}${p?`?${p}`:""}`;t(c)},[e,t,r.pathname]),o=S(s=>{let a=new URLSearchParams(e.toString());a.delete(s);let i=a.toString(),l=`${r.pathname||"/"}${i?`?${i}`:""}`;t(l)},[e,t,r.pathname]),u=S(()=>{let s=r.pathname||"/";t(s)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:o,clearQueries:u}}import{useMemo as J}from"react";import{isClient as V,FEATURE_STATUS as W}from"@donotdev/core";import{useAppConfig as X,useAuthConfig as ee}from"@donotdev/core";import*as k from"@donotdev/auth";import{DEGRADED_AUTH_API as H}from"@donotdev/core";var v=k?.useAuth;function Z(e){return H[e]}function g(e){return v?v(e):Z(e)}var Le=k?.PasswordResetCallback??(()=>null);function te(e={}){let{auth:t,redirectTo:r,condition:n}=e,o=ee(),u=X().auth===!1,s=g("user"),a=g("can"),i=g("status");return J(()=>{let l={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!V())return l;if(i===W.INITIALIZING)return{...l,isChecking:!0};if(n){let c=n(s,i);return{shouldRedirect:c,redirectTo:c&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!a)return l;if(!a.navigate(t)){if(u&&!r)throw new Error("[dndev] This route declares auth requirements but AppConfig.auth is false, so there is no auth route to redirect to. Enable auth in AppConfig or remove the route's auth requirement.");let c=null;if(typeof t=="object"&&t.required&&!s){let f=window.location.search,T=f.includes("code=")||f.includes("state=")||f.includes("error="),y=o.authRoute;T?c=`${y}${f}`:c=y}else typeof t=="object"&&t.role?c=o.roleRoute:typeof t=="object"&&t.tier?c=o.tierRoute:c=o.roleRoute;return{shouldRedirect:!0,redirectTo:r||c,isChecking:!1}}}return l},[t,i,s,a,n,r,u,o.authRoute,o.roleRoute,o.tierRoute])}export{U as useBack,h as useLocalizedPath,R as useLocation,B as useMatch,P as useNavigate,x as useParams,E as usePrefetch,Y as useQueryParams,te as useRedirectGuard,K as useRefresh,j as useRouteParam,m as useRoutePath,A as useSearchParams,w as useUrlLanguage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use client";import{useNavigate as S}from"react-router-dom";import{getLanguageRouting as T,isClient as G,splitLanguagePath as U,useOverlayStore as N}from"@donotdev/core";import{useHref as b}from"react-router-dom";import{getLanguageRouting as y,localizePath as C,splitLanguagePath as k}from"@donotdev/core";function p(){return k(b("/"),y()).language}function I(){let e=p(),t=y();return r=>C(r,e,t)}function g(){let e=S(),t=N(n=>n.closeAll),r=p();return(n,a)=>{if(n==="back")return t(),e(-1);t();let o=n.startsWith("/")?U(n,T()):null;if(o?.prefixed&&o.language!==r){window.location.assign(n);return}let s=o?.prefixed?o.path:n;return a?.replace?e(s,{replace:!0}):e(s)}}function K(){let e=S();return()=>e(-1)}function O(){return()=>{G()&&window.location.reload()}}function $(){return e=>{}}import{useLocation as E}from"react-router-dom";function m(){return E()}import{useLocation as M}from"react-router-dom";function Q(){return M().pathname}import{useParams as q}from"react-router-dom";function R(){return q()}function D(e){let r=R()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as _}from"react-router-dom";function P(){return _()[0]}import{useMatch as j}from"react-router-dom";function z(e){return j(e)}import{useCallback as A}from"react";function F(){let e=P(),t=g(),r=m(),n=A((s,c)=>{let u=new URLSearchParams(e.toString());u.set(s,c);let
|
|
1
|
+
"use client";import{useNavigate as S}from"react-router-dom";import{getLanguageRouting as T,isClient as G,splitLanguagePath as U,useOverlayStore as N}from"@donotdev/core";import{useHref as b}from"react-router-dom";import{getLanguageRouting as y,localizePath as C,splitLanguagePath as k}from"@donotdev/core";function p(){return k(b("/"),y()).language}function I(){let e=p(),t=y();return r=>C(r,e,t)}function g(){let e=S(),t=N(n=>n.closeAll),r=p();return(n,a)=>{if(n==="back")return t(),e(-1);t();let o=n.startsWith("/")?U(n,T()):null;if(o?.prefixed&&o.language!==r){window.location.assign(n);return}let s=o?.prefixed?o.path:n;return a?.replace?e(s,{replace:!0}):e(s)}}function K(){let e=S();return()=>e(-1)}function O(){return()=>{G()&&window.location.reload()}}function $(){return e=>{}}import{useLocation as E}from"react-router-dom";function m(){return E()}import{useLocation as M}from"react-router-dom";function Q(){return M().pathname}import{useParams as q}from"react-router-dom";function R(){return q()}function D(e){let r=R()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as _}from"react-router-dom";function P(){return _()[0]}import{useMatch as j}from"react-router-dom";function z(e){return j(e)}import{useCallback as A}from"react";function F(){let e=P(),t=g(),r=m(),n=A((s,c)=>{let u=new URLSearchParams(e.toString());u.set(s,c);let l=u.toString(),f=`${r.pathname||"/"}${l?`?${l}`:""}`;t(f)},[e,t,r.pathname]),a=A(s=>{let c=new URLSearchParams(e.toString());c.delete(s);let u=c.toString(),d=`${r.pathname||"/"}${u?`?${u}`:""}`;t(d)},[e,t,r.pathname]),o=A(()=>{let s=r.pathname||"/";t(s)},[t,r.pathname]);return{query:e,setQuery:n,removeQuery:a,clearQueries:o}}import{useMemo as W}from"react";import{isClient as Z,FEATURE_STATUS as J}from"@donotdev/core";import{useAppConfig as V,useAuthConfig as X}from"@donotdev/core";import*as L from"@donotdev/auth";import{DEGRADED_AUTH_API as B}from"@donotdev/core";var v=L?.useAuth;function H(e){return B[e]}function h(e){return v?v(e):H(e)}var we=L?.PasswordResetCallback??(()=>null);function Y(e={}){let{auth:t,redirectTo:r,condition:n}=e,a=m(),o=X(),s=V().auth===!1,c=h("user"),u=h("can"),l=h("status");return W(()=>{let f={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!Z())return f;if(l===J.INITIALIZING)return{...f,isChecking:!0};if(n){let i=n(c,l);return{shouldRedirect:i,redirectTo:i&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!u)return f;if(!u.navigate(t)){if(s&&!r)throw new Error("[dndev] This route declares auth requirements but AppConfig.auth is false, so there is no auth route to redirect to. Enable auth in AppConfig or remove the route's auth requirement.");let i=null;if(typeof t=="object"&&t.required&&!c){let w=a.search.includes("code=")||a.search.includes("state=")||a.search.includes("error="),x=o.authRoute;w?i=`${x}${a.search}`:i=x}else typeof t=="object"&&t.role?i=o.roleRoute:typeof t=="object"&&t.tier?i=o.tierRoute:i=o.roleRoute;return{shouldRedirect:!0,redirectTo:r||i,isChecking:!1}}}return f},[t,l,c,u,n,r,a.search,s,o.authRoute,o.roleRoute,o.tierRoute])}export{K as useBack,I as useLocalizedPath,m as useLocation,z as useMatch,g as useNavigate,R as useParams,$ as usePrefetch,F as useQueryParams,Y as useRedirectGuard,O as useRefresh,D as useRouteParam,Q as useRoutePath,P as useSearchParams,p as useUrlLanguage};
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// packages/ui/src/routing/hooks/index.ts
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview Routing hooks barrel - DO NOT IMPORT DIRECTLY
|
|
5
|
-
* @description This file exists for backwards compatibility and local development.
|
|
6
|
-
*
|
|
7
|
-
* IMPORTANT: Components should import from '@donotdev/ui' (main entry point).
|
|
8
|
-
* The routing/index.ts re-exports from '@donotdev/ui/routing/hooks' which triggers
|
|
9
|
-
* conditional exports to resolve the correct platform implementation.
|
|
10
|
-
*
|
|
11
|
-
* This file uses direct relative imports as a fallback for:
|
|
12
|
-
* - TypeScript type checking during development
|
|
13
|
-
* - Direct file resolution in non-bundled contexts
|
|
14
|
-
*
|
|
15
|
-
* When bundled properly:
|
|
16
|
-
* - Vite: resolve.conditions ['vite-app'] → hooks.vite.ts (React Router)
|
|
17
|
-
* - Next.js: default → hooks.next.ts (App Router)
|
|
18
|
-
*
|
|
19
|
-
* @version 0.1.0
|
|
20
|
-
* @since 0.0.1
|
|
21
|
-
* @author AMBROISE PARK Consulting
|
|
22
|
-
*/
|
|
23
|
-
// For direct imports and TypeScript, re-export from the Next.js implementation
|
|
24
|
-
// (this file should rarely be imported directly - use @donotdev/ui instead)
|
|
25
|
-
// The bundler-resolved subpath export in routing/index.ts handles actual resolution
|
|
26
|
-
export * from './hooks.next';
|
|
1
|
+
"use client";export{useBack,useLocalizedPath,useLocation,useMatch,useNavigate,useParams,usePrefetch,useQueryParams,useRedirectGuard,useRefresh,useRouteParam,useRoutePath,useSearchParams,useUrlLanguage}from"./hooks.next.js";
|
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// packages/ui/src/routing/hooks/useLocation.next.ts
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview Next.js-specific location hook
|
|
5
|
-
*
|
|
6
|
-
* @version 0.2.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { useSearchParams as useNextSearchParams } from 'next/navigation';
|
|
11
|
-
import { useRoutePath } from './useRoutePath.next';
|
|
12
|
-
/**
|
|
13
|
-
* Current location, route-relative: `pathname` has no language prefix (`/en/produits`
|
|
14
|
-
* → `/produits`), so route matching, breadcrumbs and guards see app paths.
|
|
15
|
-
*
|
|
16
|
-
* Reads the query string (`search`): in a cached (static) render that moves the
|
|
17
|
-
* render to the browser up to the nearest Suspense boundary. Use `useRoutePath()`
|
|
18
|
-
* when only the path is needed.
|
|
19
|
-
*
|
|
20
|
-
* @version 0.2.0
|
|
21
|
-
* @since 0.0.1
|
|
22
|
-
* @author AMBROISE PARK Consulting
|
|
23
|
-
*/
|
|
24
|
-
export function useLocation() {
|
|
25
|
-
const pathname = useRoutePath();
|
|
26
|
-
const searchParams = useNextSearchParams();
|
|
27
|
-
const searchString = searchParams.toString();
|
|
28
|
-
const search = searchString ? `?${searchString}` : undefined;
|
|
29
|
-
return {
|
|
30
|
-
pathname,
|
|
31
|
-
search,
|
|
32
|
-
hash: '',
|
|
33
|
-
state: null,
|
|
34
|
-
};
|
|
35
|
-
}
|
|
1
|
+
"use client";import{useSearchParams as t}from"next/navigation";import{useRoutePath as r}from"./useRoutePath.next.js";function h(){let e=r(),a=t().toString(),s=a?`?${a}`:void 0;return{pathname:e,search:s,hash:"",state:null}}export{h as useLocation};
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// packages/ui/src/routing/hooks/useLocation.vite.ts
|
|
3
|
-
/**
|
|
4
|
-
* @fileoverview Vite-specific location hook
|
|
5
|
-
*
|
|
6
|
-
* @version 0.1.0
|
|
7
|
-
* @since 0.0.1
|
|
8
|
-
* @author AMBROISE PARK Consulting
|
|
9
|
-
*/
|
|
10
|
-
import { useLocation as useRouterLocation } from 'react-router-dom';
|
|
11
|
-
export function useLocation() {
|
|
12
|
-
return useRouterLocation();
|
|
13
|
-
}
|
|
1
|
+
"use client";import{useLocation as o}from"react-router-dom";function e(){return o()}export{e as useLocation};
|
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// packages/ui/src/routing/hooks/useMatch.next.ts
|
|
3
|
-
import { useRoutePath } from './useRoutePath.next';
|
|
4
|
-
/**
|
|
5
|
-
* Match the current route path (language prefix stripped) against a pattern.
|
|
6
|
-
*
|
|
7
|
-
* @version 0.2.0
|
|
8
|
-
* @since 0.0.1
|
|
9
|
-
*/
|
|
10
|
-
export function useMatch(pattern) {
|
|
11
|
-
const pathname = useRoutePath();
|
|
12
|
-
// Simple pattern matching for Next.js
|
|
13
|
-
const regexPattern = pattern
|
|
14
|
-
.replace(/:[^/]+/g, '([^/]+)') // Replace :param with regex group
|
|
15
|
-
.replace(/\*/g, '.*'); // Replace * with .*
|
|
16
|
-
const regex = new RegExp(`^${regexPattern}$`);
|
|
17
|
-
const match = pathname.match(regex);
|
|
18
|
-
if (!match)
|
|
19
|
-
return null;
|
|
20
|
-
// Extract params from the pattern
|
|
21
|
-
const paramNames = pattern.match(/:[^/]+/g)?.map((p) => p.slice(1)) || [];
|
|
22
|
-
const params = {};
|
|
23
|
-
paramNames.forEach((name, index) => {
|
|
24
|
-
params[name] = match[index + 1] || '';
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
params,
|
|
28
|
-
pathname,
|
|
29
|
-
pattern,
|
|
30
|
-
};
|
|
31
|
-
}
|
|
1
|
+
"use client";import{useRoutePath as g}from"./useRoutePath.next.js";function u(e){let c=g(),a=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),s=new RegExp(`^${a}$`),r=c.match(s);if(!r)return null;let o=e.match(/:[^/]+/g)?.map(t=>t.slice(1))||[],n={};return o.forEach((t,m)=>{n[t]=r[m+1]||""}),{params:n,pathname:c,pattern:e}}export{u as useMatch};
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
|
|
2
|
-
// packages/ui/src/routing/hooks/useMatch.vite.ts
|
|
3
|
-
import { useMatch as useRouterMatch } from 'react-router-dom';
|
|
4
|
-
export function useMatch(pattern) {
|
|
5
|
-
return useRouterMatch(pattern);
|
|
6
|
-
}
|
|
1
|
+
"use client";import{useMatch as e}from"react-router-dom";function u(t){return e(t)}export{u as useMatch};
|