@donotdev/ui 0.2.1 → 0.2.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/dist/{GoToDialog-CICRYHHG.js → GoToDialog-KSBGOIWO.js} +1 -1
- package/dist/chunk-MS7ZIW5Z.js +1 -0
- package/dist/components/auth/AuthHeader.d.ts.map +1 -1
- package/dist/components/auth/AuthHeader.js +0 -2
- package/dist/components/auth/AuthMenu.d.ts.map +1 -1
- package/dist/components/auth/AuthMenu.js +6 -40
- package/dist/components/common/TechBento.d.ts +2 -6
- package/dist/components/common/TechBento.d.ts.map +1 -1
- package/dist/components/common/TechBento.js +14 -16
- package/dist/components/common/icon.d.ts.map +1 -1
- package/dist/components/common/icon.js +2 -1
- package/dist/components/common/lucideIconByName.d.ts +9 -0
- package/dist/components/common/lucideIconByName.d.ts.map +1 -0
- package/dist/components/common/lucideIconByName.js +32 -0
- package/dist/components/layout/GameFlow.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
- package/dist/components/layout/components/Breadcrumbs.js +14 -9
- package/dist/components/layout/components/header/CacheSettings.d.ts.map +1 -1
- package/dist/components/layout/components/header/CacheSettings.js +6 -4
- package/dist/components/layout/components/header/SettingsMenu.d.ts.map +1 -1
- package/dist/components/layout/components/header/SettingsMenu.js +2 -1
- package/dist/components/layout/components/header/ThemeToggle.d.ts.map +1 -1
- package/dist/components/layout/components/header/ThemeToggle.js +2 -1
- package/dist/crud/components/CrudCardLink.d.ts +6 -6
- package/dist/crud/components/CrudCardLink.d.ts.map +1 -1
- package/dist/crud/components/CrudCardLink.js +3 -9
- package/dist/crud/components/EntityCardList.d.ts.map +1 -1
- package/dist/crud/components/EntityCardList.js +3 -11
- package/dist/crud/components/EntityDisplayRenderer.d.ts +1 -1
- package/dist/crud/components/EntityDisplayRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityDisplayRenderer.js +17 -58
- package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
- package/dist/crud/components/EntityFormRenderer.js +27 -5
- package/dist/crud/components/EntityList.d.ts +4 -4
- package/dist/crud/components/EntityList.d.ts.map +1 -1
- package/dist/crud/components/EntityList.js +136 -59
- package/dist/crud/components/Form.d.ts +1 -1
- package/dist/crud/components/Form.d.ts.map +1 -1
- package/dist/crud/components/Form.js +2 -2
- package/dist/crud/components/cellEditFor.d.ts +28 -0
- package/dist/crud/components/cellEditFor.d.ts.map +1 -0
- package/dist/crud/components/cellEditFor.js +54 -0
- package/dist/crud/components/entityParent.d.ts +40 -0
- package/dist/crud/components/entityParent.d.ts.map +1 -0
- package/dist/crud/components/entityParent.js +54 -0
- package/dist/crud/components/useRecordBreadcrumb.d.ts +11 -0
- package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -0
- package/dist/crud/components/useRecordBreadcrumb.js +34 -0
- package/dist/crud/crudImports.d.ts +3 -0
- package/dist/crud/crudImports.d.ts.map +1 -1
- package/dist/crud/crudImports.js +3 -0
- package/dist/dndev-next.css +483 -145
- package/dist/dndev.css +483 -145
- package/dist/index.js +4 -4
- package/dist/internal/common/RouteErrorFallback.d.ts.map +1 -1
- package/dist/internal/common/RouteErrorFallback.js +2 -4
- package/dist/internal/devtools/components/ConfigTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/ConfigTab.js +1 -1
- package/dist/internal/devtools/components/CookieTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/CookieTab.js +1 -5
- package/dist/internal/devtools/components/DesignTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/DesignTab.js +18 -7
- package/dist/internal/devtools/components/StoresTab.d.ts.map +1 -1
- package/dist/internal/devtools/components/StoresTab.js +17 -3
- package/dist/internal/devtools/types.d.ts +3 -3
- package/dist/internal/devtools/types.d.ts.map +1 -1
- package/dist/internal/devtools/utils/maskSensitive.d.ts +1 -1
- package/dist/internal/devtools/utils/maskSensitive.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.d.ts.map +1 -1
- package/dist/internal/layout/DnDevLayout.js +21 -21
- package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
- package/dist/internal/layout/components/AutoMetaTags.js +45 -58
- package/dist/internal/layout/components/footer/FooterLegalLinks.js +2 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts +0 -2
- package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
- package/dist/internal/layout/components/footer/useLegalLinks.js +0 -2
- package/dist/internal/layout/components/i18nSeoMeta.d.ts +54 -0
- package/dist/internal/layout/components/i18nSeoMeta.d.ts.map +1 -0
- package/dist/internal/layout/components/i18nSeoMeta.js +53 -0
- package/dist/internal/layout/components/index.d.ts +1 -1
- package/dist/internal/layout/components/index.js +1 -1
- package/dist/internal/layout/zones/DnDevMergedBar.js +3 -3
- package/dist/internal/providers/UIProviders.d.ts.map +1 -1
- package/dist/internal/providers/UIProviders.js +7 -2
- package/dist/providers/NextJsAppProviders.d.ts +5 -1
- package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
- package/dist/providers/NextJsAppProviders.js +36 -6
- package/dist/providers/ViteAppProviders.d.ts.map +1 -1
- package/dist/providers/ViteAppProviders.js +42 -4
- package/dist/routing/404.js +4 -4
- package/dist/routing/AuthGuard.d.ts +0 -4
- package/dist/routing/AuthGuard.d.ts.map +1 -1
- package/dist/routing/AuthGuard.js +0 -4
- package/dist/routing/AuthGuardFallback.d.ts.map +1 -1
- package/dist/routing/AuthGuardFallback.js +1 -2
- package/dist/routing/AuthReturnTo.d.ts.map +1 -1
- package/dist/routing/AuthReturnTo.js +9 -2
- package/dist/routing/GoTo.d.ts +0 -6
- package/dist/routing/GoTo.d.ts.map +1 -1
- package/dist/routing/GoTo.js +5 -8
- package/dist/routing/Link.d.ts +4 -2
- package/dist/routing/Link.d.ts.map +1 -1
- package/dist/routing/Link.js +8 -5
- package/dist/routing/SignedInRedirect.d.ts +27 -0
- package/dist/routing/SignedInRedirect.d.ts.map +1 -0
- package/dist/routing/SignedInRedirect.js +47 -0
- package/dist/routing/hooks/hooks.next.d.ts +2 -0
- package/dist/routing/hooks/hooks.next.d.ts.map +1 -1
- package/dist/routing/hooks/hooks.next.js +1 -1
- package/dist/routing/hooks/hooks.vite.d.ts +2 -0
- package/dist/routing/hooks/hooks.vite.d.ts.map +1 -1
- package/dist/routing/hooks/hooks.vite.js +1 -1
- package/dist/routing/hooks/useLocation.next.d.ts +12 -0
- package/dist/routing/hooks/useLocation.next.d.ts.map +1 -1
- package/dist/routing/hooks/useLocation.next.js +17 -4
- package/dist/routing/hooks/useMatch.next.d.ts +6 -0
- package/dist/routing/hooks/useMatch.next.d.ts.map +1 -1
- package/dist/routing/hooks/useMatch.next.js +8 -2
- package/dist/routing/hooks/useNavigate.next.d.ts +6 -1
- package/dist/routing/hooks/useNavigate.next.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.next.js +13 -4
- package/dist/routing/hooks/useNavigate.vite.d.ts +7 -1
- package/dist/routing/hooks/useNavigate.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useNavigate.vite.js +20 -4
- package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.next.js +7 -1
- package/dist/routing/hooks/useRedirectGuard.vite.d.ts.map +1 -1
- package/dist/routing/hooks/useRedirectGuard.vite.js +7 -1
- package/dist/routing/hooks/useRoutePath.next.d.ts +23 -0
- package/dist/routing/hooks/useRoutePath.next.d.ts.map +1 -0
- package/dist/routing/hooks/useRoutePath.next.js +36 -0
- package/dist/routing/hooks/useRoutePath.vite.d.ts +13 -0
- package/dist/routing/hooks/useRoutePath.vite.d.ts.map +1 -0
- package/dist/routing/hooks/useRoutePath.vite.js +25 -0
- package/dist/routing/hooks/useUrlLanguage.next.d.ts +28 -0
- package/dist/routing/hooks/useUrlLanguage.next.d.ts.map +1 -0
- package/dist/routing/hooks/useUrlLanguage.next.js +50 -0
- package/dist/routing/hooks/useUrlLanguage.vite.d.ts +22 -0
- package/dist/routing/hooks/useUrlLanguage.vite.d.ts.map +1 -0
- package/dist/routing/hooks/useUrlLanguage.vite.js +41 -0
- package/dist/routing/index.d.ts +3 -1
- package/dist/routing/index.d.ts.map +1 -1
- package/dist/routing/index.js +2 -1
- package/dist/routing/useNavigation.js +4 -4
- package/dist/styles/index.css +483 -145
- package/dist/symbol-index.json +1 -1
- package/dist/utils/assetResolver.d.ts.map +1 -1
- package/dist/utils/assetResolver.js +1 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +3 -0
- package/dist/utils/useDeleteAccountSafe.d.ts +17 -0
- package/dist/utils/useDeleteAccountSafe.d.ts.map +1 -0
- package/dist/utils/useDeleteAccountSafe.js +52 -0
- package/dist/utils/useFormStoreSafe.d.ts.map +1 -1
- package/dist/utils/useFormStoreSafe.js +1 -0
- package/dist/utils/useSeo.d.ts +10 -2
- package/dist/utils/useSeo.d.ts.map +1 -1
- package/dist/utils/useSeo.js +44 -9
- package/dist/vite-routing/AppRoutes.d.ts.map +1 -1
- package/dist/vite-routing/AppRoutes.js +37 -4
- package/guidelines/COMPONENTS.md +2 -1
- package/guidelines/PAGES.md +7 -0
- package/guidelines/ROUTING.md +4 -0
- package/guidelines/SEO.md +64 -0
- package/package.json +9 -9
- package/dist/CookieConsent-5NH5DNTP.js +0 -1
- package/dist/CookieConsent-W7UE647Y.js +0 -1
- package/dist/GoToDialog-YGBON6FR.js +0 -1
- package/dist/chunk-DRFM6WXH.js +0 -1
- package/dist/chunk-MIPTBUWY.js +0 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts +0 -57
- package/dist/internal/layout/components/NextJsAutoMetaTags.d.ts.map +0 -1
- package/dist/internal/layout/components/NextJsAutoMetaTags.js +0 -182
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview SEO fields from a namespace's `meta` translations
|
|
3
|
+
* @description Reads `<ns>:meta.*` key by key, as the i18n convention requires:
|
|
4
|
+
* `useTranslation` returns strings only, never objects or arrays.
|
|
5
|
+
*
|
|
6
|
+
* @version 0.2.2
|
|
7
|
+
* @since 0.2.2
|
|
8
|
+
* @author AMBROISE PARK Consulting
|
|
9
|
+
*/
|
|
10
|
+
import type { TFunction } from 'i18next';
|
|
11
|
+
/**
|
|
12
|
+
* Resolves a title or description: explicit value, else its translation.
|
|
13
|
+
*
|
|
14
|
+
* @param seoValue - `null` omits the field, a string is used as is, `undefined` looks up the translation
|
|
15
|
+
* @param translationKey - Namespaced key, e.g. `home:description`
|
|
16
|
+
* @param t - Translation function loaded with the key's namespace
|
|
17
|
+
* @returns The resolved text, or undefined when omitted or not translated
|
|
18
|
+
*
|
|
19
|
+
* @version 0.2.2
|
|
20
|
+
* @since 0.2.2
|
|
21
|
+
* @author AMBROISE PARK Consulting
|
|
22
|
+
*/
|
|
23
|
+
export declare function resolveSeoField(seoValue: string | null | undefined, translationKey: string, t: TFunction): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* SEO fields a namespace can define under `meta`.
|
|
26
|
+
*
|
|
27
|
+
* @version 0.2.2
|
|
28
|
+
* @since 0.2.2
|
|
29
|
+
* @author AMBROISE PARK Consulting
|
|
30
|
+
*/
|
|
31
|
+
export interface I18nSeoMeta {
|
|
32
|
+
fullTitle?: string;
|
|
33
|
+
image?: string;
|
|
34
|
+
type?: string;
|
|
35
|
+
keywords?: string[];
|
|
36
|
+
author?: string;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Reads the SEO fields of a namespace from its translations.
|
|
40
|
+
*
|
|
41
|
+
* @param t - Translation function loaded with `ns`
|
|
42
|
+
* @param ns - Namespace holding the `meta` object
|
|
43
|
+
* @returns The defined fields; a missing or empty field is undefined
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // JSON: { "meta": { "image": "/og.png", "keywords": ["a", "b"] } }
|
|
47
|
+
* readI18nSeoMeta(t, 'home'); // { image: '/og.png', keywords: ['a', 'b'] }
|
|
48
|
+
*
|
|
49
|
+
* @version 0.2.2
|
|
50
|
+
* @since 0.2.2
|
|
51
|
+
* @author AMBROISE PARK Consulting
|
|
52
|
+
*/
|
|
53
|
+
export declare function readI18nSeoMeta(t: TFunction, ns: string): I18nSeoMeta;
|
|
54
|
+
//# sourceMappingURL=i18nSeoMeta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"i18nSeoMeta.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/components/i18nSeoMeta.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAUzC;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,cAAc,EAAE,MAAM,EACtB,CAAC,EAAE,SAAS,GACX,MAAM,GAAG,SAAS,CAIpB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,WAAW;IAC1B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,eAAe,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,MAAM,GAAG,WAAW,CAmBrE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// packages/ui/src/internal/layout/components/i18nSeoMeta.ts
|
|
2
|
+
import { translateArray } from '@donotdev/core';
|
|
3
|
+
/** Upper bound for translateArray: keywords past it are not emitted. */
|
|
4
|
+
const MAX_KEYWORDS = 20;
|
|
5
|
+
/** An empty default is how a missing key is detected: on a namespaced key, i18next returns the key without its namespace. */
|
|
6
|
+
const EMPTY_WHEN_MISSING = { defaultValue: '' };
|
|
7
|
+
/**
|
|
8
|
+
* Resolves a title or description: explicit value, else its translation.
|
|
9
|
+
*
|
|
10
|
+
* @param seoValue - `null` omits the field, a string is used as is, `undefined` looks up the translation
|
|
11
|
+
* @param translationKey - Namespaced key, e.g. `home:description`
|
|
12
|
+
* @param t - Translation function loaded with the key's namespace
|
|
13
|
+
* @returns The resolved text, or undefined when omitted or not translated
|
|
14
|
+
*
|
|
15
|
+
* @version 0.2.2
|
|
16
|
+
* @since 0.2.2
|
|
17
|
+
* @author AMBROISE PARK Consulting
|
|
18
|
+
*/
|
|
19
|
+
export function resolveSeoField(seoValue, translationKey, t) {
|
|
20
|
+
if (seoValue === null)
|
|
21
|
+
return undefined;
|
|
22
|
+
if (seoValue !== undefined)
|
|
23
|
+
return seoValue;
|
|
24
|
+
return t(translationKey, EMPTY_WHEN_MISSING) || undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Reads the SEO fields of a namespace from its translations.
|
|
28
|
+
*
|
|
29
|
+
* @param t - Translation function loaded with `ns`
|
|
30
|
+
* @param ns - Namespace holding the `meta` object
|
|
31
|
+
* @returns The defined fields; a missing or empty field is undefined
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // JSON: { "meta": { "image": "/og.png", "keywords": ["a", "b"] } }
|
|
35
|
+
* readI18nSeoMeta(t, 'home'); // { image: '/og.png', keywords: ['a', 'b'] }
|
|
36
|
+
*
|
|
37
|
+
* @version 0.2.2
|
|
38
|
+
* @since 0.2.2
|
|
39
|
+
* @author AMBROISE PARK Consulting
|
|
40
|
+
*/
|
|
41
|
+
export function readI18nSeoMeta(t, ns) {
|
|
42
|
+
// why: TFunction is an i18next overload set; a single-signature wrapper cannot satisfy it structurally
|
|
43
|
+
const translateOrEmpty = ((key) => t(key, EMPTY_WHEN_MISSING));
|
|
44
|
+
const field = (name) => translateOrEmpty(`${ns}:meta.${name}`) || undefined;
|
|
45
|
+
const keywords = translateArray(translateOrEmpty, `${ns}:meta.keywords`, MAX_KEYWORDS);
|
|
46
|
+
return {
|
|
47
|
+
fullTitle: field('fullTitle'),
|
|
48
|
+
image: field('image'),
|
|
49
|
+
type: field('type'),
|
|
50
|
+
keywords: keywords.length > 0 ? keywords : undefined,
|
|
51
|
+
author: field('author'),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
export { FooterCopyright } from './footer/FooterCopyright';
|
|
10
10
|
export { FooterLegalLinks } from './footer/FooterLegalLinks';
|
|
11
11
|
export { FooterBranding } from './footer/FooterBranding';
|
|
12
|
-
export {
|
|
12
|
+
export { getLegalLinks } from './footer/useLegalLinks';
|
|
13
13
|
export type { FooterLegalLink } from './footer/useLegalLinks';
|
|
14
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -10,4 +10,4 @@
|
|
|
10
10
|
export { FooterCopyright } from './footer/FooterCopyright';
|
|
11
11
|
export { FooterLegalLinks } from './footer/FooterLegalLinks';
|
|
12
12
|
export { FooterBranding } from './footer/FooterBranding';
|
|
13
|
-
export {
|
|
13
|
+
export { getLegalLinks } from './footer/useLegalLinks';
|
|
@@ -16,7 +16,7 @@ import { ChevronUp, Menu } from 'lucide-react';
|
|
|
16
16
|
import { memo, useState, useEffect } from 'react';
|
|
17
17
|
import { Stack, Button, Sheet, BUTTON_VARIANT, Separator, SEPARATOR_VARIANT, } from '@donotdev/components';
|
|
18
18
|
import { useTranslation } from '@donotdev/core';
|
|
19
|
-
import {
|
|
19
|
+
import { useRoutePath } from '@donotdev/ui/routing/hooks';
|
|
20
20
|
/**
|
|
21
21
|
* DnDevMergedBar - Mobile navigation zone
|
|
22
22
|
*
|
|
@@ -39,11 +39,11 @@ function DnDevMergedBarComponent({ position, height, trigger, top, content, bott
|
|
|
39
39
|
// For RTL apps, this would need Sheet to support 'start'/'end' sides — tracked separately.
|
|
40
40
|
const sheetSide = position === 'top' ? 'left' : position;
|
|
41
41
|
const [open, setOpen] = useState(false);
|
|
42
|
-
const
|
|
42
|
+
const pathname = useRoutePath();
|
|
43
43
|
// Close sheet when route changes
|
|
44
44
|
useEffect(() => {
|
|
45
45
|
setOpen(false);
|
|
46
|
-
}, [
|
|
46
|
+
}, [pathname]);
|
|
47
47
|
// Build sheet content
|
|
48
48
|
const sheetNode = (_jsxs(Stack, { direction: "column", className: "merged-bar-sheet-content", children: [top && (_jsxs(_Fragment, { children: [top, _jsx(Separator, { variant: SEPARATOR_VARIANT.MUTED })] })), content && _jsx("div", { className: "merged-bar-sheet-scroll", children: content }), bottom && (_jsxs(_Fragment, { children: [_jsx(Separator, { variant: SEPARATOR_VARIANT.MUTED }), bottom] }))] }));
|
|
49
49
|
const triggerButton = (_jsx(Button, { variant: BUTTON_VARIANT.GHOST, icon: Icon, "aria-label": "Open navigation" }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UIProviders.d.ts","sourceRoot":"","sources":["../../../src/internal/providers/UIProviders.tsx"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"UIProviders.d.ts","sourceRoot":"","sources":["../../../src/internal/providers/UIProviders.tsx"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,OAAO,CAAC;AA2BrE,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,GAAG,YAAY,CAYxE"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { Dialog, LinkRendererProvider, Toaster, TooltipProvider, } from '@donotdev/components';
|
|
4
4
|
import { useOverlayStore } from '@donotdev/core';
|
|
5
|
+
import { Link } from '../../routing/Link';
|
|
5
6
|
import DnDevErrorBoundary from '../common/DnDevErrorBoundary';
|
|
6
7
|
import GlobalErrorFallback from '../common/GlobalErrorFallback';
|
|
8
|
+
/** Router link for components' `href` props (Card): Next Link or react-router Link. */
|
|
9
|
+
function RouterLinkRenderer({ href, ...rest }) {
|
|
10
|
+
return _jsx(Link, { path: href, ...rest });
|
|
11
|
+
}
|
|
7
12
|
function UIGlobalErrorFallback(props) {
|
|
8
13
|
return _jsx(GlobalErrorFallback, { ...props });
|
|
9
14
|
}
|
|
@@ -15,7 +20,7 @@ function UIGlobalErrorFallback(props) {
|
|
|
15
20
|
* @author AMBROISE PARK Consulting
|
|
16
21
|
*/
|
|
17
22
|
export function UIProviders({ children }) {
|
|
18
|
-
return (_jsx(DnDevErrorBoundary, { level: "app", fallback: UIGlobalErrorFallback, children: _jsxs(TooltipProvider, { children: [children, _jsx(Toaster, {}), _jsx(ModalDialog, {})] }) }));
|
|
23
|
+
return (_jsx(DnDevErrorBoundary, { level: "app", fallback: UIGlobalErrorFallback, children: _jsx(LinkRendererProvider, { value: RouterLinkRenderer, children: _jsxs(TooltipProvider, { children: [children, _jsx(Toaster, {}), _jsx(ModalDialog, {})] }) }) }));
|
|
19
24
|
}
|
|
20
25
|
/**
|
|
21
26
|
* ModalDialog - Renders modal dialog using store directly
|
|
@@ -4,9 +4,13 @@ import type { AppProvidersProps } from '@donotdev/core';
|
|
|
4
4
|
*
|
|
5
5
|
* Clean provider hierarchy with configuration via context (no prop drilling).
|
|
6
6
|
*
|
|
7
|
+
* Language: the URL's with 2+ languages (one URL per language), else the request's
|
|
8
|
+
* (`serverCookies` / `acceptLanguage`). Language switchers navigate client-side to the
|
|
9
|
+
* other language's URL (LanguageNavigationProvider, Next router).
|
|
10
|
+
*
|
|
7
11
|
* Provider hierarchy:
|
|
8
12
|
* 1. AppConfigProvider (configuration context)
|
|
9
|
-
* 2.
|
|
13
|
+
* 2. AutoMetaTags (SEO head, server-rendered; no Helmet on Next)
|
|
10
14
|
* 3. NextJsStoresInitializer (store setup, SSR-safe)
|
|
11
15
|
* 4. QueryProviders (React Query)
|
|
12
16
|
* 5. UIProviders (design system)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAwF1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IAChE;;;;OAIG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+EAA+E;IAC/E,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC;AAQD,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,+BA6FhE"}
|
|
@@ -9,14 +9,17 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
|
|
|
9
9
|
* @since 0.0.1
|
|
10
10
|
* @author AMBROISE PARK Consulting
|
|
11
11
|
*/
|
|
12
|
+
import { useRouter } from 'next/navigation';
|
|
12
13
|
import { lazy, Suspense, useEffect, useMemo, useState } from 'react';
|
|
13
14
|
import { ReactQueryStreamedHydration } from '@tanstack/react-query-next-experimental';
|
|
14
|
-
import { AppConfigProvider, AuthSessionProvider, getProvider, getRequestLanguage, hasProvider, QueryProviders, RequestLanguageProvider, } from '@donotdev/core';
|
|
15
|
+
import { AppConfigProvider, AuthSessionProvider, getI18nInstance, getLanguageRouting, getProvider, getRequestLanguage, hasProvider, isMultilingual, LanguageNavigationProvider, QueryProviders, RequestLanguageProvider, } from '@donotdev/core';
|
|
15
16
|
import { useConsent } from '@donotdev/core';
|
|
17
|
+
// Platform-specific hooks via conditional exports
|
|
18
|
+
import { useUrlLanguage } from '@donotdev/ui/routing/hooks';
|
|
16
19
|
import { NextJsStoresInitializer } from '../internal/initializers/NextJsStoresInitializer';
|
|
20
|
+
import { AutoMetaTags } from '../internal/layout/components/AutoMetaTags';
|
|
17
21
|
import FaviconHead from '../internal/layout/components/FaviconHead';
|
|
18
22
|
import PerformanceHints from '../internal/layout/components/PerformanceHints';
|
|
19
|
-
// import NextJsAutoMetaTags from '../internal/layout/components/NextJsAutoMetaTags'; // Deprecated - metadata now server-side
|
|
20
23
|
import { DnDevLayout } from '../internal/layout/DnDevLayout';
|
|
21
24
|
import { SentryInitializer } from '../internal/providers/SentryInitializer';
|
|
22
25
|
import { UIProviders } from '../internal/providers/UIProviders';
|
|
@@ -49,6 +52,29 @@ function ConsentBanner() {
|
|
|
49
52
|
}
|
|
50
53
|
return (_jsx(Suspense, { fallback: null, children: _jsx(CookieConsent, {}) }));
|
|
51
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Language of the render. 2+ languages: the URL's (`/en/…`, the default language at
|
|
57
|
+
* the root; the generated proxy already moved a first visit to the visitor's
|
|
58
|
+
* language). One language: from the request headers (language cookie >
|
|
59
|
+
* Accept-Language > fallback). Same inputs on the server and in the hydration pass.
|
|
60
|
+
*/
|
|
61
|
+
function useRenderLanguage(serverCookies, acceptLanguage) {
|
|
62
|
+
const urlLanguage = useUrlLanguage();
|
|
63
|
+
const multilingual = isMultilingual(getLanguageRouting().languages);
|
|
64
|
+
const requestLanguage = useMemo(() => getRequestLanguage(serverCookies, acceptLanguage), [serverCookies, acceptLanguage]);
|
|
65
|
+
return multilingual ? urlLanguage : requestLanguage;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The live i18n instance follows the render language: a language switch navigates
|
|
69
|
+
* client-side to the other language's URL, and the page re-renders in it.
|
|
70
|
+
*/
|
|
71
|
+
function useFollowLanguage(language) {
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
const instance = getI18nInstance();
|
|
74
|
+
if (instance.language !== language)
|
|
75
|
+
void instance.changeLanguage(language);
|
|
76
|
+
}, [language]);
|
|
77
|
+
}
|
|
52
78
|
/** Auth session snapshot of the request, `null` when the auth provider cannot tell. */
|
|
53
79
|
function readAuthSnapshot(cookieHeader) {
|
|
54
80
|
if (cookieHeader === undefined || !hasProvider('auth'))
|
|
@@ -57,9 +83,13 @@ function readAuthSnapshot(cookieHeader) {
|
|
|
57
83
|
}
|
|
58
84
|
export function NextJsAppProviders(props) {
|
|
59
85
|
const { config = {}, layout, children, serverCookies, acceptLanguage, customStores, } = props;
|
|
60
|
-
// Same header values on the server and in the hydration pass → same language
|
|
61
|
-
// signed-in state on both, so the first paint is final (no keys, no auth swap).
|
|
62
|
-
const
|
|
86
|
+
// Same URL and header values on the server and in the hydration pass → same language
|
|
87
|
+
// and signed-in state on both, so the first paint is final (no keys, no auth swap).
|
|
88
|
+
const language = useRenderLanguage(serverCookies, acceptLanguage);
|
|
89
|
+
useFollowLanguage(language);
|
|
90
|
+
// Language switchers (core) open the other language's URL through the Next router
|
|
91
|
+
const router = useRouter();
|
|
92
|
+
const navigateToLanguage = (url) => router.push(url, { scroll: false });
|
|
63
93
|
const authSnapshot = useMemo(() => readAuthSnapshot(serverCookies), [serverCookies]);
|
|
64
94
|
// SSR is the default for Next apps: render the provider tree on the server so
|
|
65
95
|
// page content is present in the initial HTML (crawlable, real SSR). An app
|
|
@@ -74,5 +104,5 @@ export function NextJsAppProviders(props) {
|
|
|
74
104
|
if (!ssr && !isMounted) {
|
|
75
105
|
return _jsx(_Fragment, { children: children });
|
|
76
106
|
}
|
|
77
|
-
return (_jsx(RequestLanguageProvider, { language:
|
|
107
|
+
return (_jsx(RequestLanguageProvider, { language: language, children: _jsx(LanguageNavigationProvider, { navigate: navigateToLanguage, children: _jsx(AuthSessionProvider, { snapshot: authSnapshot, children: _jsxs(AppConfigProvider, { config: config, platform: "nextjs", children: [_jsx(SentryInitializer, {}), _jsxs(NextJsStoresInitializer, { serverCookies: serverCookies, customStores: customStores, children: [_jsx(FaviconHead, {}), _jsx(PerformanceHints, {}), _jsx(QueryProviders, { children: _jsx(ReactQueryStreamedHydration, { children: _jsxs(UIProviders, { children: [_jsx(AutoMetaTags, {}), _jsx(DnDevLayout, { layout: layout, children: children }), _jsx(ConsentBanner, {}), _jsx(AuthReturnTo, {}), _jsx(PasswordResetCallback, {}), _jsx(Suspense, { fallback: null, children: _jsx(PWAUpdateNotification, {}) }), _jsx(Suspense, { fallback: null, children: _jsx(RedirectOverlay, {}) })] }) }) })] })] }) }) }) }));
|
|
78
108
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ViteAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/ViteAppProviders.tsx"],"names":[],"mappings":"AAcA,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"ViteAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/ViteAppProviders.tsx"],"names":[],"mappings":"AAcA,OAAO,aAAa,CAAC;AACrB,OAAO,gBAAgB,CAAC;AACxB,OAAO,sBAAsB,CAAC;AAC9B,OAAO,gBAAgB,CAAC;AACxB,OAAO,gBAAgB,CAAC;AAUxB,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAyC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,+BA+DxD"}
|
|
@@ -8,14 +8,14 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
8
8
|
* @since 0.0.1
|
|
9
9
|
* @author AMBROISE PARK Consulting
|
|
10
10
|
*/
|
|
11
|
-
import { lazy, Suspense, useMemo } from 'react';
|
|
11
|
+
import { lazy, Suspense, useEffect, useMemo, useRef, useState } from 'react';
|
|
12
12
|
// Import virtual modules to populate globalThis._DNDEV_CONFIG_ before any components load
|
|
13
13
|
import 'virtual:env';
|
|
14
14
|
import 'virtual:themes';
|
|
15
15
|
import 'virtual:i18n-mapping';
|
|
16
16
|
import 'virtual:routes';
|
|
17
17
|
import 'virtual:assets';
|
|
18
|
-
import { AppConfigProvider } from '@donotdev/core';
|
|
18
|
+
import { AppConfigProvider, applyFirstVisitLanguage, getI18nInstance, getLanguageRouting, getUrlLanguage, LanguageNavigationProvider, } from '@donotdev/core';
|
|
19
19
|
import { ViteStoresInitializer } from '../internal/initializers/ViteStoresInitializer';
|
|
20
20
|
import { NavigationProvider } from '../internal/providers/NavigationProvider';
|
|
21
21
|
import { SentryInitializer } from '../internal/providers/SentryInitializer';
|
|
@@ -33,6 +33,19 @@ const FaviconHead = lazy(() => import('../internal/layout/components/FaviconHead
|
|
|
33
33
|
const PerformanceHints = lazy(() => import('../internal/layout/components/PerformanceHints').then((m) => ({
|
|
34
34
|
default: m.default,
|
|
35
35
|
})));
|
|
36
|
+
/** Language of the browser URL (prefix, else the default language). */
|
|
37
|
+
function currentUrlLanguage() {
|
|
38
|
+
return getUrlLanguage(window.location.pathname);
|
|
39
|
+
}
|
|
40
|
+
/** Stop the history listener of a router replaced by a language switch. */
|
|
41
|
+
function useDisposeReplacedRouter(router) {
|
|
42
|
+
const previous = useRef(router);
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (previous.current !== router)
|
|
45
|
+
previous.current.dispose();
|
|
46
|
+
previous.current = router;
|
|
47
|
+
}, [router]);
|
|
48
|
+
}
|
|
36
49
|
/**
|
|
37
50
|
* ViteAppProviders - Vite platform-specific app providers
|
|
38
51
|
*
|
|
@@ -77,6 +90,31 @@ export function ViteAppProviders(props) {
|
|
|
77
90
|
// Virtual modules are loaded at module level (lines 20-26), so routes are available
|
|
78
91
|
// HomePage.tsx is automatically assigned path "/" by RouteDiscovery convention
|
|
79
92
|
// Memoized so the router instance is stable across re-renders (Item 86)
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
// The router runs under the URL's language prefix (createAppRouter basename). A
|
|
94
|
+
// language switch moves the URL to the other language's prefix and recreates the
|
|
95
|
+
// router under it: client-side, no document reload.
|
|
96
|
+
const [urlLanguage, setUrlLanguage] = useState(currentUrlLanguage);
|
|
97
|
+
const router = useMemo(() => createAppRouter({ routeGroups, layout }),
|
|
98
|
+
// urlLanguage: a new router (new basename) per URL language
|
|
99
|
+
[routeGroups, layout, urlLanguage]);
|
|
100
|
+
useDisposeReplacedRouter(router);
|
|
101
|
+
// Back/forward across languages: the router of the other prefix takes over
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
const onPopState = () => {
|
|
104
|
+
// Same rule as a first visit (and as the Next proxy) for an unprefixed URL
|
|
105
|
+
const routing = getLanguageRouting();
|
|
106
|
+
applyFirstVisitLanguage(routing.languages, routing.defaultLanguage);
|
|
107
|
+
const language = currentUrlLanguage();
|
|
108
|
+
void getI18nInstance().changeLanguage(language);
|
|
109
|
+
setUrlLanguage(language);
|
|
110
|
+
};
|
|
111
|
+
window.addEventListener('popstate', onPopState);
|
|
112
|
+
return () => window.removeEventListener('popstate', onPopState);
|
|
113
|
+
}, []);
|
|
114
|
+
const navigateToLanguage = (url, language) => {
|
|
115
|
+
window.history.pushState(null, '', url);
|
|
116
|
+
void getI18nInstance().changeLanguage(language);
|
|
117
|
+
setUrlLanguage(language);
|
|
118
|
+
};
|
|
119
|
+
return (_jsxs(AppConfigProvider, { config: config, platform: "vite", children: [_jsx(SentryInitializer, {}), _jsx(ViteStoresInitializer, { customStores: customStores, children: _jsx(Suspense, { fallback: null, children: _jsxs(HelmetProvider, { children: [_jsx(FaviconHead, {}), _jsx(PerformanceHints, {}), _jsx(LanguageNavigationProvider, { navigate: navigateToLanguage, children: _jsx(NavigationProvider, { router: router }) })] }) }) })] }));
|
|
82
120
|
}
|
package/dist/routing/404.js
CHANGED
|
@@ -14,7 +14,7 @@ import { useMemo } from 'react';
|
|
|
14
14
|
import { Button, BUTTON_VARIANT, Stack, Text } from '@donotdev/components';
|
|
15
15
|
import { useTranslation } from '@donotdev/core';
|
|
16
16
|
// Platform-specific hooks via conditional exports
|
|
17
|
-
import {
|
|
17
|
+
import { useNavigate, useRoutePath } from '@donotdev/ui/routing/hooks';
|
|
18
18
|
import { Link } from './Link';
|
|
19
19
|
import { useNavigationItems } from './useNavigation';
|
|
20
20
|
import { Icon } from '../components/common/icon';
|
|
@@ -45,7 +45,7 @@ export const meta = {
|
|
|
45
45
|
*/
|
|
46
46
|
export default function NotFoundPage() {
|
|
47
47
|
const { t } = useTranslation('dndev');
|
|
48
|
-
const
|
|
48
|
+
const pathname = useRoutePath();
|
|
49
49
|
const navigate = useNavigate();
|
|
50
50
|
const navigationItems = useNavigationItems();
|
|
51
51
|
/**
|
|
@@ -83,7 +83,7 @@ export default function NotFoundPage() {
|
|
|
83
83
|
color: 'var(--muted-foreground)',
|
|
84
84
|
textAlign: 'center',
|
|
85
85
|
margin: 0,
|
|
86
|
-
}, children: t('errors.notFound.description', "The page you're looking for doesn't exist or has been moved.") }),
|
|
86
|
+
}, children: t('errors.notFound.description', "The page you're looking for doesn't exist or has been moved.") }), pathname && (_jsx("code", { style: {
|
|
87
87
|
padding: 'var(--gap-sm) var(--gap-md)',
|
|
88
88
|
background: 'var(--muted)',
|
|
89
89
|
borderRadius: 'var(--radius-md)',
|
|
@@ -95,7 +95,7 @@ export default function NotFoundPage() {
|
|
|
95
95
|
overflow: 'hidden',
|
|
96
96
|
textOverflow: 'ellipsis',
|
|
97
97
|
border: '1px solid var(--border-hairline)',
|
|
98
|
-
}, children:
|
|
98
|
+
}, children: pathname }))] }), suggestedRoutes.length > 0 && (_jsxs(Stack, { align: "center", children: [_jsx("p", { className: "dndev-text-base", style: {
|
|
99
99
|
fontSize: 'var(--font-size-md)',
|
|
100
100
|
fontWeight: 'var(--font-weight-semibold)',
|
|
101
101
|
margin: 0,
|
|
@@ -33,10 +33,6 @@ export declare function AuthGuard({ auth, children, fallback: Fallback, }: AuthG
|
|
|
33
33
|
* @author AMBROISE PARK Consulting
|
|
34
34
|
*/
|
|
35
35
|
export declare function useCanNavigate(auth: PageAuth | false): boolean;
|
|
36
|
-
/**
|
|
37
|
-
* @deprecated Use useCanNavigate instead
|
|
38
|
-
*/
|
|
39
|
-
export declare const useCanAccess: typeof useCanNavigate;
|
|
40
36
|
/**
|
|
41
37
|
* Hook to get current user's role - directly from store
|
|
42
38
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuard.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EAEL,UAAU,EACV,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM/C;;GAEG;AACH,UAAU,cAAc;IACtB,wCAAwC;IACxC,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,QAAQ,EAAE,QAAoC,GAC/C,EAAE,cAAc,+BA0ChB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAG9D;AAED
|
|
1
|
+
{"version":3,"file":"AuthGuard.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuard.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtD,OAAO,EAEL,UAAU,EACV,kBAAkB,EAGnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAM/C;;GAEG;AACH,UAAU,cAAc;IACtB,wCAAwC;IACxC,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;IACvB,wCAAwC;IACxC,QAAQ,EAAE,SAAS,CAAC;IACpB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,aAAa,CAAC;CAC1B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,QAAQ,EACR,QAAQ,EAAE,QAAoC,GAC/C,EAAE,cAAc,+BA0ChB;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,QAAQ,GAAG,KAAK,GAAG,OAAO,CAG9D;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,IACvB,OAAO,UAAU,CAAC,KAAK,GACvB,OAAO,UAAU,CAAC,IAAI,GACtB,OAAO,UAAU,CAAC,KAAK,CAS1B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACxB,IAAI,EACA,OAAO,UAAU,CAAC,KAAK,GACvB,OAAO,UAAU,CAAC,IAAI,GACtB,OAAO,UAAU,CAAC,KAAK,GAC1B,OAAO,CAIT;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY;;;;;;EAW3B;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,MAAM,EACvC,SAAS,EAAE,aAAa,CAAC,CAAC,CAAC,EAC3B,IAAI,EAAE,QAAQ,GAAG,KAAK,WAEW,CAAC,iCAOnC;AAED;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB;IAC3B,iCAAiC;kBACrB,KAAK;IAEjB,oCAAoC;oBACtB,QAAQ;IAEtB,yCAAyC;gBAC/B,QAAQ;IAKlB,uDAAuD;iBAC5C,QAAQ;IAKnB,gCAAgC;iBAExB,CAAC,OAAO,kBAAkB,EAAE,MAAM,OAAO,kBAAkB,CAAC,KACjE,QAAQ;IAKX,eAAe;eACN,QAAQ;IAKjB,mBAAmB;mBACN,QAAQ;IAKrB,sCAAsC;oBACxB,QAAQ;IAMtB,wBAAwB;uBACL,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,KAAG,QAAQ;CAItE,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -72,10 +72,6 @@ export function useCanNavigate(auth) {
|
|
|
72
72
|
const can = useAuthSafe('can');
|
|
73
73
|
return can?.navigate(auth) ?? false;
|
|
74
74
|
}
|
|
75
|
-
/**
|
|
76
|
-
* @deprecated Use useCanNavigate instead
|
|
77
|
-
*/
|
|
78
|
-
export const useCanAccess = useCanNavigate;
|
|
79
75
|
/**
|
|
80
76
|
* Hook to get current user's role - directly from store
|
|
81
77
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthGuardFallback.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuardFallback.tsx"],"names":[],"mappings":"AA6BA,UAAU,sBAAsB;IAC9B,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,cAAqB,EACrB,MAAM,EACN,SAAc,GACf,EAAE,sBAAsB,+
|
|
1
|
+
{"version":3,"file":"AuthGuardFallback.d.ts","sourceRoot":"","sources":["../../src/routing/AuthGuardFallback.tsx"],"names":[],"mappings":"AA6BA,UAAU,sBAAsB;IAC9B,oCAAoC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oCAAoC;IACpC,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,WAAW,EACX,cAAqB,EACrB,MAAM,EACN,SAAc,GACf,EAAE,sBAAsB,+BAqHxB;AAED,eAAe,iBAAiB,CAAC"}
|
|
@@ -14,7 +14,7 @@ import { Card, Button, Separator, Stack, cn } from '@donotdev/components';
|
|
|
14
14
|
import { useTranslation } from '@donotdev/core';
|
|
15
15
|
import { useBreakpoint } from '@donotdev/core';
|
|
16
16
|
// Platform-specific hooks via conditional exports
|
|
17
|
-
import {
|
|
17
|
+
import { useBack } from '@donotdev/ui/routing/hooks';
|
|
18
18
|
import { PageContainer } from '../components/layout/PageContainer';
|
|
19
19
|
// Lazy load MultipleAuthProviders to enable code splitting
|
|
20
20
|
const MultipleAuthProviders = lazy(() => import('@donotdev/auth').then((module) => ({
|
|
@@ -33,7 +33,6 @@ const MultipleAuthProviders = lazy(() => import('@donotdev/auth').then((module)
|
|
|
33
33
|
*/
|
|
34
34
|
export function AuthGuardFallback({ title, description, showBackButton = true, onBack, className = '', }) {
|
|
35
35
|
const { t } = useTranslation(['auth', 'common']);
|
|
36
|
-
const location = useLocation();
|
|
37
36
|
const back = useBack();
|
|
38
37
|
const handleBack = () => {
|
|
39
38
|
if (onBack) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthReturnTo.d.ts","sourceRoot":"","sources":["../../src/routing/AuthReturnTo.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AuthReturnTo.d.ts","sourceRoot":"","sources":["../../src/routing/AuthReturnTo.tsx"],"names":[],"mappings":"AA+BA;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,SAoC3B"}
|
|
@@ -19,6 +19,10 @@ import { useToast } from '@donotdev/components';
|
|
|
19
19
|
import { isClient, safeSessionStorage, useTranslation } from '@donotdev/core';
|
|
20
20
|
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
21
21
|
import { useAuthSafe } from '../utils/useAuthSafe';
|
|
22
|
+
/** A path on this site (`/x`), never `//host` or `https://…` (no open redirect). */
|
|
23
|
+
function isSameOriginPath(value) {
|
|
24
|
+
return value.startsWith('/') && !value.startsWith('//') && !value.startsWith('/\\');
|
|
25
|
+
}
|
|
22
26
|
/**
|
|
23
27
|
* AuthReturnTo - Restores navigation after OAuth redirect.
|
|
24
28
|
*
|
|
@@ -45,11 +49,14 @@ export function AuthReturnTo() {
|
|
|
45
49
|
safeSessionStorage.removeItem('dndev.auth.guardToast');
|
|
46
50
|
toast('warning', t('guard.signInRequired', 'Please sign in to access this page'));
|
|
47
51
|
}, []);
|
|
48
|
-
// Return-to after sign-in
|
|
52
|
+
// Return-to after sign-in: saved by AuthGuard (sessionStorage) or passed as
|
|
53
|
+
// `?returnTo=` by the generated proxy's server redirect. Same-origin paths only.
|
|
49
54
|
useEffect(() => {
|
|
50
55
|
if (!user || !isClient())
|
|
51
56
|
return;
|
|
52
|
-
const
|
|
57
|
+
const fromQuery = new URLSearchParams(window.location.search).get('returnTo');
|
|
58
|
+
const returnTo = safeSessionStorage.getItem('dndev.auth.returnTo') ??
|
|
59
|
+
(fromQuery && isSameOriginPath(fromQuery) ? fromQuery : null);
|
|
53
60
|
if (!returnTo)
|
|
54
61
|
return;
|
|
55
62
|
safeSessionStorage.removeItem('dndev.auth.returnTo');
|
package/dist/routing/GoTo.d.ts
CHANGED
|
@@ -11,12 +11,6 @@ export interface GoToProps {
|
|
|
11
11
|
/** Optional callback called after opening command dialog (e.g., to close parent dropdown) */
|
|
12
12
|
onOpen?: () => void;
|
|
13
13
|
}
|
|
14
|
-
/**
|
|
15
|
-
* GoTo - Command palette trigger button
|
|
16
|
-
*
|
|
17
|
-
* Simple button: Search icon + "Go to" label + keyboard shortcut.
|
|
18
|
-
* Opens command dialog on click.
|
|
19
|
-
*/
|
|
20
14
|
export declare const GoTo: ({ display, className, onOpen, }: GoToProps) => import("react").JSX.Element;
|
|
21
15
|
export default GoTo;
|
|
22
16
|
//# sourceMappingURL=GoTo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GoTo.d.ts","sourceRoot":"","sources":["../../src/routing/GoTo.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvE,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"GoTo.d.ts","sourceRoot":"","sources":["../../src/routing/GoTo.tsx"],"names":[],"mappings":"AAaA,OAAO,EAA0B,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAGvE,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,OAAO,OAAO,CAAC,CAAC;IACjD,2BAA2B;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6FAA6F;IAC7F,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;CACrB;AAkBD,eAAO,MAAM,IAAI,GAAI,iCAIlB,SAAS,gCAyCX,CAAC;AAEF,eAAe,IAAI,CAAC"}
|
package/dist/routing/GoTo.js
CHANGED
|
@@ -11,20 +11,17 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
11
|
import { Search } from 'lucide-react';
|
|
12
12
|
import { Button, BUTTON_VARIANT, DISPLAY } from '@donotdev/components';
|
|
13
13
|
import { useOverlayStore, useTranslation } from '@donotdev/core';
|
|
14
|
-
/**
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* Opens command dialog on click.
|
|
19
|
-
*/
|
|
14
|
+
/** Reads the UA-CH platform when the browser exposes it. */
|
|
15
|
+
function readUserAgentPlatform(nav) {
|
|
16
|
+
return nav.userAgentData?.platform;
|
|
17
|
+
}
|
|
20
18
|
export const GoTo = ({ display = DISPLAY.AUTO, className, onOpen, }) => {
|
|
21
19
|
const { t } = useTranslation('dndev');
|
|
22
20
|
const openCommandDialog = useOverlayStore((state) => state.openCommandDialog);
|
|
23
21
|
// Platform-aware shortcut (Mac: ⌘K, others: Ctrl+K)
|
|
24
22
|
// navigator.userAgentData?.platform is modern; navigator.platform is the deprecated fallback
|
|
25
23
|
const isMac = typeof navigator !== 'undefined' &&
|
|
26
|
-
/Mac|iPhone|iPad/.test(navigator
|
|
27
|
-
.userAgentData?.platform ?? navigator.platform);
|
|
24
|
+
/Mac|iPhone|iPad/.test(readUserAgentPlatform(navigator) ?? navigator.platform);
|
|
28
25
|
const shortcut = isMac ? '⌘K' : 'Ctrl+K';
|
|
29
26
|
const handleClick = () => {
|
|
30
27
|
openCommandDialog();
|
package/dist/routing/Link.d.ts
CHANGED
|
@@ -21,9 +21,11 @@ export interface LinkProps extends AnchorHTMLAttributes<HTMLAnchorElement> {
|
|
|
21
21
|
'aria-describedby'?: string;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Link component
|
|
24
|
+
* Link component. Internal paths are app paths (`/produits`): the rendered `href` and
|
|
25
|
+
* 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).
|
|
25
27
|
*
|
|
26
|
-
* @version 0.
|
|
28
|
+
* @version 0.2.0
|
|
27
29
|
* @since 0.0.1
|
|
28
30
|
* @author AMBROISE PARK Consulting
|
|
29
31
|
*/
|
|
@@ -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,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;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,aAAa,CAAC,SAAS,CA0JzC,CAAC"}
|
package/dist/routing/Link.js
CHANGED
|
@@ -13,17 +13,20 @@ import { Link as LinkIcon } from 'lucide-react';
|
|
|
13
13
|
import { cn } from '@donotdev/components';
|
|
14
14
|
import { useConsent } from '@donotdev/core';
|
|
15
15
|
// Platform-specific hooks via conditional exports
|
|
16
|
-
import { useNavigate } from '@donotdev/ui/routing/hooks';
|
|
16
|
+
import { useLocalizedPath, useNavigate } from '@donotdev/ui/routing/hooks';
|
|
17
17
|
import { Icon } from '../components/common/icon';
|
|
18
18
|
/**
|
|
19
|
-
* Link component
|
|
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).
|
|
20
22
|
*
|
|
21
|
-
* @version 0.
|
|
23
|
+
* @version 0.2.0
|
|
22
24
|
* @since 0.0.1
|
|
23
25
|
* @author AMBROISE PARK Consulting
|
|
24
26
|
*/
|
|
25
27
|
export const Link = ({ path, replace, prefetch = true, children, icon, iconEnd = false, label, onClick, className, 'aria-label': ariaLabel, 'aria-describedby': ariaDescribedBy, target, rel, ...rest }) => {
|
|
26
28
|
const navigate = useNavigate();
|
|
29
|
+
const localize = useLocalizedPath();
|
|
27
30
|
const showCookieBanner = useConsent('showCookieBanner');
|
|
28
31
|
// Special framework trigger: #cookie-settings
|
|
29
32
|
if (path === '#cookie-settings') {
|
|
@@ -97,8 +100,8 @@ export const Link = ({ path, replace, prefetch = true, children, icon, iconEnd =
|
|
|
97
100
|
gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
|
|
98
101
|
}, ...accessibilityProps, ...rest, children: linkContent }));
|
|
99
102
|
}
|
|
100
|
-
// Internal links:
|
|
101
|
-
return (_jsx("a", { href: path, onClick: handleClick, className: className, style: {
|
|
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: {
|
|
102
105
|
display: icon && (label || children) ? 'flex' : undefined,
|
|
103
106
|
alignItems: icon && (label || children) ? 'center' : undefined,
|
|
104
107
|
gap: icon && (label || children) ? 'var(--gap-sm)' : undefined,
|