@donotdev/ui 0.2.3 → 0.3.0

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.
Files changed (85) hide show
  1. package/dist/ChildRowsPicker-63M4EQUQ.js +1 -0
  2. package/dist/ChildRowsPicker-ISP365ON.js +1 -0
  3. package/dist/ChildRowsPicker-PQFE6NCR.js +1 -0
  4. package/dist/ChildRowsPicker-XXFFSMWY.js +1 -0
  5. package/dist/GoToDialog-XBK5EZF4.js +1 -0
  6. package/dist/chunk-3CIZFGST.js +1 -0
  7. package/dist/chunk-LHMKU342.js +1 -0
  8. package/dist/chunk-P2DHZWPY.js +1 -0
  9. package/dist/components/layout/components/Breadcrumbs.d.ts.map +1 -1
  10. package/dist/components/layout/components/Breadcrumbs.js +4 -3
  11. package/dist/components/layout/components/header/SettingsMenu.js +2 -2
  12. package/dist/crud/components/ChildRowsPicker.d.ts +21 -0
  13. package/dist/crud/components/ChildRowsPicker.d.ts.map +1 -0
  14. package/dist/crud/components/ChildRowsPicker.js +68 -0
  15. package/dist/crud/components/EntityCardList.d.ts.map +1 -1
  16. package/dist/crud/components/EntityCardList.js +9 -17
  17. package/dist/crud/components/EntityDisplayRenderer.js +2 -2
  18. package/dist/crud/components/EntityFormRenderer.d.ts +4 -2
  19. package/dist/crud/components/EntityFormRenderer.d.ts.map +1 -1
  20. package/dist/crud/components/EntityFormRenderer.js +137 -55
  21. package/dist/crud/components/EntityList.d.ts +3 -1
  22. package/dist/crud/components/EntityList.d.ts.map +1 -1
  23. package/dist/crud/components/EntityList.js +324 -56
  24. package/dist/crud/components/EntityRecommendations.js +1 -1
  25. package/dist/crud/components/EntityWorkflow.d.ts.map +1 -1
  26. package/dist/crud/components/EntityWorkflow.js +6 -4
  27. package/dist/crud/components/cellEditFor.d.ts +23 -8
  28. package/dist/crud/components/cellEditFor.d.ts.map +1 -1
  29. package/dist/crud/components/cellEditFor.js +40 -20
  30. package/dist/crud/components/entityParent.d.ts +8 -15
  31. package/dist/crud/components/entityParent.d.ts.map +1 -1
  32. package/dist/crud/components/entityParent.js +30 -8
  33. package/dist/crud/components/useRecordBreadcrumb.d.ts +1 -1
  34. package/dist/crud/components/useRecordBreadcrumb.d.ts.map +1 -1
  35. package/dist/crud/components/useRecordBreadcrumb.js +12 -3
  36. package/dist/crud/crudImports.d.ts +11 -2
  37. package/dist/crud/crudImports.d.ts.map +1 -1
  38. package/dist/crud/crudImports.js +10 -1
  39. package/dist/dndev-next.css +302 -51
  40. package/dist/dndev.css +304 -51
  41. package/dist/index.js +4 -4
  42. package/dist/internal/initializers/NextJsStoresInitializer.d.ts +3 -0
  43. package/dist/internal/initializers/NextJsStoresInitializer.d.ts.map +1 -1
  44. package/dist/internal/initializers/NextJsStoresInitializer.js +8 -1
  45. package/dist/internal/layout/components/AutoMetaTags.d.ts.map +1 -1
  46. package/dist/internal/layout/components/AutoMetaTags.js +3 -2
  47. package/dist/internal/layout/components/FontPreloadLinks.d.ts +7 -4
  48. package/dist/internal/layout/components/FontPreloadLinks.d.ts.map +1 -1
  49. package/dist/internal/layout/components/FontPreloadLinks.js +12 -25
  50. package/dist/internal/layout/components/footer/FooterCopyright.d.ts +2 -0
  51. package/dist/internal/layout/components/footer/FooterCopyright.d.ts.map +1 -1
  52. package/dist/internal/layout/components/footer/FooterCopyright.js +4 -0
  53. package/dist/internal/layout/components/footer/useLegalLinks.d.ts +2 -1
  54. package/dist/internal/layout/components/footer/useLegalLinks.d.ts.map +1 -1
  55. package/dist/internal/layout/components/footer/useLegalLinks.js +4 -3
  56. package/dist/internal/providers/UIProviders.d.ts +0 -8
  57. package/dist/internal/providers/UIProviders.d.ts.map +1 -1
  58. package/dist/internal/providers/UIProviders.js +39 -1
  59. package/dist/providers/NextJsAppProviders.d.ts.map +1 -1
  60. package/dist/providers/NextJsAppProviders.js +1 -2
  61. package/dist/providers/ViteAppProviders.d.ts.map +1 -1
  62. package/dist/providers/ViteAppProviders.js +1 -4
  63. package/dist/routing/404.d.ts +8 -1
  64. package/dist/routing/404.d.ts.map +1 -1
  65. package/dist/routing/404.js +6 -2
  66. package/dist/routing/hooks/hooks.next.js +1 -1
  67. package/dist/routing/hooks/useRedirectGuard.next.d.ts +3 -1
  68. package/dist/routing/hooks/useRedirectGuard.next.d.ts.map +1 -1
  69. package/dist/routing/hooks/useRedirectGuard.next.js +11 -9
  70. package/dist/routing/parentRoute.d.ts +27 -0
  71. package/dist/routing/parentRoute.d.ts.map +1 -0
  72. package/dist/routing/parentRoute.js +43 -0
  73. package/dist/routing/useNavigation.d.ts.map +1 -1
  74. package/dist/routing/useNavigation.js +5 -24
  75. package/dist/routing/useRouteDiscovery.d.ts +2 -2
  76. package/dist/routing/useRouteDiscovery.d.ts.map +1 -1
  77. package/dist/routing/useRouteDiscovery.js +6 -5
  78. package/dist/styles/index.css +301 -50
  79. package/dist/symbol-index.json +1 -1
  80. package/guidelines/GOTCHAS.md +2 -0
  81. package/guidelines/LAYOUTS.md +4 -0
  82. package/guidelines/PAGES.md +23 -3
  83. package/guidelines/ROUTING.md +26 -1
  84. package/guidelines/SEO.md +1 -1
  85. package/package.json +8 -8
@@ -11,6 +11,9 @@ interface NextJsStoresInitializerProps {
11
11
  *
12
12
  * Wraps BaseStoresInitializer with Next.js-specific handlers and SSR cookie hydration.
13
13
  * Hydrates theme store from cookies before render to prevent FOUC (Flash of Unstyled Content).
14
+ * Refreshes the Next router when the signed-in identity changes (onQueryCacheIdentityChange):
15
+ * the client router cache holds payloads and proxy redirects of the previous session
16
+ * (e.g. `/` → signedInRedirect target), replayed on the next navigation otherwise.
14
17
  * Automatically skips initialization in test environments.
15
18
  *
16
19
  * @version 0.1.0
@@ -1 +1 @@
1
- {"version":3,"file":"NextJsStoresInitializer.d.ts","sourceRoot":"","sources":["../../../src/internal/initializers/NextJsStoresInitializer.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOxD,UAAU,4BAA4B;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,GACd,EAAE,4BAA4B,+BAqD9B"}
1
+ {"version":3,"file":"NextJsStoresInitializer.d.ts","sourceRoot":"","sources":["../../../src/internal/initializers/NextJsStoresInitializer.tsx"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AASvC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAOxD,UAAU,4BAA4B;IACpC,QAAQ,EAAE,SAAS,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB;AAQD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,aAAa,EACb,YAAY,EACZ,aAAa,GACd,EAAE,4BAA4B,+BAyD9B"}
@@ -9,8 +9,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
9
9
  * @since 0.0.1
10
10
  * @author AMBROISE PARK Consulting
11
11
  */
12
+ import { useRouter } from 'next/navigation';
12
13
  import { useEffect } from 'react';
13
- import { isTest, isClient, getDndevConfig } from '@donotdev/core';
14
+ import { isTest, isClient, getDndevConfig, onQueryCacheIdentityChange, } from '@donotdev/core';
14
15
  import { useThemeStore } from '@donotdev/core';
15
16
  import { BaseStoresInitializer, } from './BaseStoresInitializer';
16
17
  function createNextJsHandlers() {
@@ -23,6 +24,9 @@ function createNextJsHandlers() {
23
24
  *
24
25
  * Wraps BaseStoresInitializer with Next.js-specific handlers and SSR cookie hydration.
25
26
  * Hydrates theme store from cookies before render to prevent FOUC (Flash of Unstyled Content).
27
+ * Refreshes the Next router when the signed-in identity changes (onQueryCacheIdentityChange):
28
+ * the client router cache holds payloads and proxy redirects of the previous session
29
+ * (e.g. `/` → signedInRedirect target), replayed on the next navigation otherwise.
26
30
  * Automatically skips initialization in test environments.
27
31
  *
28
32
  * @version 0.1.0
@@ -32,6 +36,9 @@ function createNextJsHandlers() {
32
36
  export function NextJsStoresInitializer({ children, serverCookies, customStores, skipStoreInit, }) {
33
37
  const skip = skipStoreInit ?? isTest();
34
38
  const handlers = createNextJsHandlers();
39
+ const router = useRouter();
40
+ // Synchronous on the identity reset: refreshed before the caller's next navigation
41
+ useEffect(() => onQueryCacheIdentityChange(() => router.refresh()), [router]);
35
42
  // Next.js SSR: Hydrate theme store from cookies before render
36
43
  // Flow: 1) Next.js layout reads cookie and applies theme class (SSR)
37
44
  // 2) This component hydrates Zustand store with theme from cookie (client-side only)
@@ -1 +1 @@
1
- {"version":3,"file":"AutoMetaTags.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/components/AutoMetaTags.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA0N3C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,aAgU1B,CAAC;AAEF;;;GAGG;AAEH,eAAe,YAAY,CAAC"}
1
+ {"version":3,"file":"AutoMetaTags.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/components/AutoMetaTags.tsx"],"names":[],"mappings":"AAuBA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA0N3C;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,YAAY,EAAE,aAmU1B,CAAC;AAEF;;;GAGG;AAEH,eAAe,YAAY,CAAC"}
@@ -317,11 +317,12 @@ export const AutoMetaTags = () => {
317
317
  name: siteName,
318
318
  logo: {
319
319
  '@type': 'ImageObject',
320
- url: AssetResolver.assetExists('/icon-512x512.png')
320
+ // Absolute: schema.org consumers (Google) ignore a relative logo URL
321
+ url: `${baseUrl}${AssetResolver.assetExists('/icon-512x512.png')
321
322
  ? '/icon-512x512.png'
322
323
  : AssetResolver.assetExists('/icon-192x192.png')
323
324
  ? '/icon-192x192.png'
324
- : '/logo.svg',
325
+ : '/logo.svg'}`,
325
326
  },
326
327
  },
327
328
  }) })), breadcrumbSchemaEnabled && pathname !== '/' && (_jsx("script", { type: "application/ld+json", children: JSON.stringify(buildBreadcrumbSchema(pathname, baseUrl, siteName, localize)) })), websiteSchemaEnabled && baseUrl && (_jsx("script", { type: "application/ld+json", children: JSON.stringify(buildWebSiteSchema(baseUrl, siteName)) })), organizationSchemaEnabled &&
@@ -1,15 +1,18 @@
1
1
  /**
2
2
  * @fileoverview FontPreloadLinks - Server-only component for Next.js
3
- * @description Reads public/dndev-font-preloads.json (written at build by FontPreloadWebpackPlugin) and renders preload link tags for Lighthouse-friendly LCP. Include in root layout so initial HTML contains the links.
3
+ * @description Links public/dndev-fonts.css, the @font-face rules of the framework
4
+ * fonts the app's theme uses (written at build by copyFontsToPublic). Renders nothing
5
+ * when the theme uses none (an app that packs its own fonts). Include in the root
6
+ * document's <head>.
4
7
  *
5
- * @version 0.1.0
8
+ * @version 0.2.0
6
9
  * @since 0.0.1
7
10
  * @author AMBROISE PARK Consulting
8
11
  */
9
12
  import type { ReactNode } from 'react';
10
13
  /**
11
- * Server component: renders preload links for fonts listed in public/dndev-font-preloads.json.
12
- * No-op if manifest is missing or empty. Use in root layout.tsx for SSR preload in initial HTML.
14
+ * Server component: `<link rel="stylesheet" href="/dndev-fonts.css">` when discovery
15
+ * generated that file (the theme renders text in a framework font), else null.
13
16
  */
14
17
  export declare function FontPreloadLinks(): Promise<ReactNode>;
15
18
  export default FontPreloadLinks;
@@ -1 +1 @@
1
- {"version":3,"file":"FontPreloadLinks.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/components/FontPreloadLinks.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAUvC;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,SAAS,CAAC,CA0C3D;AAED,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"FontPreloadLinks.d.ts","sourceRoot":"","sources":["../../../../src/internal/layout/components/FontPreloadLinks.tsx"],"names":[],"mappings":"AACA;;;;;;;;;;GAUG;AAKH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;;GAGG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,SAAS,CAAC,CAQ3D;AAED,eAAe,gBAAgB,CAAC"}
@@ -1,44 +1,31 @@
1
- import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  // packages/ui/src/internal/layout/components/FontPreloadLinks.tsx
3
3
  /**
4
4
  * @fileoverview FontPreloadLinks - Server-only component for Next.js
5
- * @description Reads public/dndev-font-preloads.json (written at build by FontPreloadWebpackPlugin) and renders preload link tags for Lighthouse-friendly LCP. Include in root layout so initial HTML contains the links.
5
+ * @description Links public/dndev-fonts.css, the @font-face rules of the framework
6
+ * fonts the app's theme uses (written at build by copyFontsToPublic). Renders nothing
7
+ * when the theme uses none (an app that packs its own fonts). Include in the root
8
+ * document's <head>.
6
9
  *
7
- * @version 0.1.0
10
+ * @version 0.2.0
8
11
  * @since 0.0.1
9
12
  * @author AMBROISE PARK Consulting
10
13
  */
11
14
  import fs from 'node:fs/promises';
12
15
  import path from 'node:path';
13
- const MANIFEST_FILENAME = 'dndev-font-preloads.json';
14
16
  const FONTS_CSS_FILENAME = 'dndev-fonts.css';
15
17
  /**
16
- * Server component: renders preload links for fonts listed in public/dndev-font-preloads.json.
17
- * No-op if manifest is missing or empty. Use in root layout.tsx for SSR preload in initial HTML.
18
+ * Server component: `<link rel="stylesheet" href="/dndev-fonts.css">` when discovery
19
+ * generated that file (the theme renders text in a framework font), else null.
18
20
  */
19
21
  export async function FontPreloadLinks() {
20
- const publicDir = path.join(process.cwd(), 'public');
21
- // Load preload manifest (optional — may not exist on first build or static export)
22
- let entries = [];
23
22
  try {
24
- const content = await fs.readFile(path.join(publicDir, MANIFEST_FILENAME), 'utf8');
25
- const parsed = JSON.parse(content);
26
- entries = Array.isArray(parsed) ? parsed : [];
23
+ await fs.access(path.join(process.cwd(), 'public', FONTS_CSS_FILENAME));
27
24
  }
28
25
  catch {
29
- // No manifest — preload links won't render, but font stylesheet still can
30
- }
31
- // Check if public/dndev-fonts.css exists (generated by copyFontsToPublic for Next.js)
32
- let hasFontsCss = false;
33
- try {
34
- await fs.access(path.join(publicDir, FONTS_CSS_FILENAME));
35
- hasFontsCss = true;
36
- }
37
- catch {
38
- // No generated font CSS — fonts come from @fontsource CSS imports (Vite)
39
- }
40
- if (entries.length === 0 && !hasFontsCss)
26
+ // Not generated: the theme uses no framework font
41
27
  return null;
42
- return (_jsxs(_Fragment, { children: [hasFontsCss && _jsx("link", { rel: "stylesheet", href: `/${FONTS_CSS_FILENAME}` }), entries.map((e) => (_jsx("link", { rel: "preload", as: "font", href: e.href, type: e.type ?? 'font/woff2', crossOrigin: "anonymous" }, e.href)))] }));
28
+ }
29
+ return _jsx("link", { rel: "stylesheet", href: `/${FONTS_CSS_FILENAME}` });
43
30
  }
44
31
  export default FontPreloadLinks;
@@ -11,6 +11,8 @@ export interface FooterCopyrightProps {
11
11
  *
12
12
  * Uses useTranslation internally, so it re-renders when language changes.
13
13
  * If appName not provided, reads from app config automatically.
14
+ * Renders nothing when the app has no footer (`app.footer: null`), as DnDevFooter,
15
+ * including in presets that show it in the sidebar.
14
16
  *
15
17
  * @version 0.1.0
16
18
  * @since 0.0.1
@@ -1 +1 @@
1
- {"version":3,"file":"FooterCopyright.d.ts","sourceRoot":"","sources":["../../../../../src/internal/layout/components/footer/FooterCopyright.tsx"],"names":[],"mappings":"AAcA,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAqBrE,CAAC;AAEF,eAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"FooterCopyright.d.ts","sourceRoot":"","sources":["../../../../../src/internal/layout/components/footer/FooterCopyright.tsx"],"names":[],"mappings":"AAcA,MAAM,WAAW,oBAAoB;IACnC,wDAAwD;IACxD,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,gDAAgD;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,6BAA6B;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,aAAa,CAAC,oBAAoB,CAuBrE,CAAC;AAEF,eAAe,eAAe,CAAC"}
@@ -15,6 +15,8 @@ import { useTranslation, useAppConfig } from '@donotdev/core';
15
15
  *
16
16
  * Uses useTranslation internally, so it re-renders when language changes.
17
17
  * If appName not provided, reads from app config automatically.
18
+ * Renders nothing when the app has no footer (`app.footer: null`), as DnDevFooter,
19
+ * including in presets that show it in the sidebar.
18
20
  *
19
21
  * @version 0.1.0
20
22
  * @since 0.0.1
@@ -24,6 +26,8 @@ export const FooterCopyright = ({ appName, year = new Date().getFullYear(), clas
24
26
  const { t } = useTranslation('dndev');
25
27
  const app = useAppConfig('app');
26
28
  const resolvedAppName = appName || app?.name || 'App';
29
+ if (app?.footer === null)
30
+ return null;
27
31
  return (_jsxs("span", { className: cn(className), style: {
28
32
  flexShrink: 0,
29
33
  color: 'var(--muted-foreground)',
@@ -5,7 +5,8 @@ export interface FooterLegalLink {
5
5
  }
6
6
  /**
7
7
  * Returns the configured legal links for the footer.
8
- * Handles the logic: null = hide, undefined = defaults, array = custom
8
+ * Handles the logic: `footer: null` or `legalLinks: null` = hide, undefined = defaults,
9
+ * array = custom
9
10
  *
10
11
  * @remarks Not a hook — no React state or effects. Named with `get` prefix.
11
12
  */
@@ -1 +1 @@
1
- {"version":3,"file":"useLegalLinks.d.ts","sourceRoot":"","sources":["../../../../../src/internal/layout/components/footer/useLegalLinks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAQD;;;;;GAKG;AACH,eAAO,MAAM,aAAa,GACxB,cAAc,WAAW,CAAC,QAAQ,CAAC,KAClC,eAAe,EAQjB,CAAC"}
1
+ {"version":3,"file":"useLegalLinks.d.ts","sourceRoot":"","sources":["../../../../../src/internal/layout/components/footer/useLegalLinks.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAElD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAQD;;;;;;GAMG;AACH,eAAO,MAAM,aAAa,GACxB,cAAc,WAAW,CAAC,QAAQ,CAAC,KAClC,eAAe,EAQjB,CAAC"}
@@ -6,13 +6,14 @@ const DEFAULT_LINKS = [
6
6
  ];
7
7
  /**
8
8
  * Returns the configured legal links for the footer.
9
- * Handles the logic: null = hide, undefined = defaults, array = custom
9
+ * Handles the logic: `footer: null` or `legalLinks: null` = hide, undefined = defaults,
10
+ * array = custom
10
11
  *
11
12
  * @remarks Not a hook — no React state or effects. Named with `get` prefix.
12
13
  */
13
14
  export const getLegalLinks = (footerConfig) => {
14
- // If explicitly null, return empty array (hidden)
15
- if (footerConfig?.legalLinks === null) {
15
+ // No footer at all, or links explicitly null: hidden (also in presets that show them in the sidebar)
16
+ if (footerConfig === null || footerConfig?.legalLinks === null) {
16
17
  return [];
17
18
  }
18
19
  // Use configured links or defaults
@@ -1,11 +1,3 @@
1
- /**
2
- * @fileoverview UIProviders component
3
- * @description Provides wrapper to basic UI components
4
- *
5
- * @version 0.1.0
6
- * @since 0.0.1
7
- * @author AMBROISE PARK Consulting
8
- */
9
1
  import type { ReactNode, ReactElement } from 'react';
10
2
  interface UIProvidersProps {
11
3
  children: ReactNode;
@@ -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;AA2BrE,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,GAAG,YAAY,CAYxE"}
1
+ {"version":3,"file":"UIProviders.d.ts","sourceRoot":"","sources":["../../../src/internal/providers/UIProviders.tsx"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAkB,MAAM,OAAO,CAAC;AA6DrE,UAAU,gBAAgB;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE,gBAAgB,GAAG,YAAY,CAiBxE"}
@@ -1,8 +1,23 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // packages/ui/src/internal/providers/UIProviders.tsx
4
+ /**
5
+ * @fileoverview UIProviders component
6
+ * @description Provides wrapper to basic UI components
7
+ *
8
+ * @version 0.1.0
9
+ * @since 0.0.1
10
+ * @author AMBROISE PARK Consulting
11
+ */
12
+ import { useEffect, useRef, useState } from 'react';
3
13
  import { Dialog, LinkRendererProvider, Toaster, TooltipProvider, } from '@donotdev/components';
4
14
  import { useOverlayStore } from '@donotdev/core';
15
+ // Platform-specific hooks via conditional exports
16
+ import { useNavigate, useRoutePath } from '@donotdev/ui/routing/hooks';
17
+ import { FormNavigationProvider, isCrudModuleAvailable } from '../../crud/crudImports';
5
18
  import { Link } from '../../routing/Link';
19
+ import { getParentRoutePath } from '../../routing/parentRoute';
20
+ import { useAllRoutes } from '../../routing/useRouteDiscovery';
6
21
  import DnDevErrorBoundary from '../common/DnDevErrorBoundary';
7
22
  import GlobalErrorFallback from '../common/GlobalErrorFallback';
8
23
  /** Router link for components' `href` props (Card): Next Link or react-router Link. */
@@ -12,6 +27,29 @@ function RouterLinkRenderer({ href, ...rest }) {
12
27
  function UIGlobalErrorFallback(props) {
13
28
  return _jsx(GlobalErrorFallback, { ...props });
14
29
  }
30
+ /**
31
+ * Fills crud's form navigation placeholder with the app router, so
32
+ * `useEntityForm` can leave for the previous breadcrumb on save.
33
+ * Functions read the latest route at call time; the context value never
34
+ * changes, so forms do not re-render on navigation because of it.
35
+ */
36
+ function FormNavigationBridge({ children }) {
37
+ const navigate = useNavigate();
38
+ const pathname = useRoutePath();
39
+ const routes = useAllRoutes();
40
+ const latest = useRef({ navigate, pathname, routes });
41
+ useEffect(() => {
42
+ latest.current = { navigate, pathname, routes };
43
+ });
44
+ const [value] = useState(() => ({
45
+ navigate: (path) => {
46
+ void latest.current.navigate(path);
47
+ },
48
+ currentPath: () => latest.current.pathname,
49
+ parentPath: () => getParentRoutePath(latest.current.pathname, new Set(latest.current.routes.map((route) => route.path))),
50
+ }));
51
+ return _jsx(FormNavigationProvider, { value: value, children: children });
52
+ }
15
53
  /**
16
54
  * Provides a wrapper to basic UI components
17
55
  *
@@ -20,7 +58,7 @@ function UIGlobalErrorFallback(props) {
20
58
  * @author AMBROISE PARK Consulting
21
59
  */
22
60
  export function UIProviders({ children }) {
23
- return (_jsx(DnDevErrorBoundary, { level: "app", fallback: UIGlobalErrorFallback, children: _jsx(LinkRendererProvider, { value: RouterLinkRenderer, children: _jsxs(TooltipProvider, { children: [children, _jsx(Toaster, {}), _jsx(ModalDialog, {})] }) }) }));
61
+ return (_jsx(DnDevErrorBoundary, { level: "app", fallback: UIGlobalErrorFallback, children: _jsx(LinkRendererProvider, { value: RouterLinkRenderer, children: _jsxs(TooltipProvider, { children: [isCrudModuleAvailable ? (_jsx(FormNavigationBridge, { children: children })) : (children), _jsx(Toaster, {}), _jsx(ModalDialog, {})] }) }) }));
24
62
  }
25
63
  /**
26
64
  * ModalDialog - Renders modal dialog using store directly
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"NextJsAppProviders.d.ts","sourceRoot":"","sources":["../../src/providers/NextJsAppProviders.tsx"],"names":[],"mappings":"AAoCA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAuF1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,+BA0FhE"}
@@ -19,7 +19,6 @@ import { useUrlLanguage } from '@donotdev/ui/routing/hooks';
19
19
  import { NextJsStoresInitializer } from '../internal/initializers/NextJsStoresInitializer';
20
20
  import { AutoMetaTags } from '../internal/layout/components/AutoMetaTags';
21
21
  import FaviconHead from '../internal/layout/components/FaviconHead';
22
- import PerformanceHints from '../internal/layout/components/PerformanceHints';
23
22
  import { DnDevLayout } from '../internal/layout/DnDevLayout';
24
23
  import { SentryInitializer } from '../internal/providers/SentryInitializer';
25
24
  import { UIProviders } from '../internal/providers/UIProviders';
@@ -104,5 +103,5 @@ export function NextJsAppProviders(props) {
104
103
  if (!ssr && !isMounted) {
105
104
  return _jsx(_Fragment, { children: children });
106
105
  }
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, {}) })] }) }) })] })] }) }) }) }));
106
+ 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(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, {}) })] }) }) })] })] }) }) }) }));
108
107
  }
@@ -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;AAUxB,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,gBAAgB,CAAC;AAyC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,+BA+DxD"}
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;AAoC1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,+BA4DxD"}
@@ -30,9 +30,6 @@ const HelmetProvider = lazy(() => import('react-helmet-async').then((m) => ({ de
30
30
  const FaviconHead = lazy(() => import('../internal/layout/components/FaviconHead').then((m) => ({
31
31
  default: m.default,
32
32
  })));
33
- const PerformanceHints = lazy(() => import('../internal/layout/components/PerformanceHints').then((m) => ({
34
- default: m.default,
35
- })));
36
33
  /** Language of the browser URL (prefix, else the default language). */
37
34
  function currentUrlLanguage() {
38
35
  return getUrlLanguage(window.location.pathname);
@@ -116,5 +113,5 @@ export function ViteAppProviders(props) {
116
113
  void getI18nInstance().changeLanguage(language);
117
114
  setUrlLanguage(language);
118
115
  };
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 }) })] }) }) })] }));
116
+ 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(LanguageNavigationProvider, { navigate: navigateToLanguage, children: _jsx(NavigationProvider, { router: router }) })] }) }) })] }));
120
117
  }
@@ -14,12 +14,19 @@ export declare const meta: PageMeta;
14
14
  * - Full-viewport centered design for professional appearance
15
15
  * - Translation system integration (i18n)
16
16
  * - Dynamic route suggestions from discovered routes
17
+ * - Optional requested-path badge (shown by default for existing consumers)
17
18
  * - Accessible design with proper semantic HTML
18
19
  * - Responsive across all viewports
19
20
  *
21
+ * Legacy errors.notFound keys are compatibility references to the canonical
22
+ * messages.notFound resources. Keep lookups here so legacy app overrides win.
23
+ *
20
24
  * @version 0.1.0
21
25
  * @since 0.0.1
22
26
  * @author AMBROISE PARK Consulting
23
27
  */
24
- export default function NotFoundPage(): import("react").JSX.Element;
28
+ export default function NotFoundPage({ showRequestedPath, }?: {
29
+ /** Display the current route path. Disable for shared, statically generated fallbacks. */
30
+ showRequestedPath?: boolean;
31
+ }): import("react").JSX.Element;
25
32
  //# sourceMappingURL=404.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"404.d.ts","sourceRoot":"","sources":["../../src/routing/404.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAS/C;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,EAAE,QAElB,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,gCAyJnC"}
1
+ {"version":3,"file":"404.d.ts","sourceRoot":"","sources":["../../src/routing/404.tsx"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAS/C;;;;;;GAMG;AACH,eAAO,MAAM,IAAI,EAAE,QAElB,CAAC;AAEF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,iBAAwB,GACzB,GAAE;IACD,0FAA0F;IAC1F,iBAAiB,CAAC,EAAE,OAAO,CAAC;CACxB,+BAyJL"}
@@ -36,14 +36,18 @@ export const meta = {
36
36
  * - Full-viewport centered design for professional appearance
37
37
  * - Translation system integration (i18n)
38
38
  * - Dynamic route suggestions from discovered routes
39
+ * - Optional requested-path badge (shown by default for existing consumers)
39
40
  * - Accessible design with proper semantic HTML
40
41
  * - Responsive across all viewports
41
42
  *
43
+ * Legacy errors.notFound keys are compatibility references to the canonical
44
+ * messages.notFound resources. Keep lookups here so legacy app overrides win.
45
+ *
42
46
  * @version 0.1.0
43
47
  * @since 0.0.1
44
48
  * @author AMBROISE PARK Consulting
45
49
  */
46
- export default function NotFoundPage() {
50
+ export default function NotFoundPage({ showRequestedPath = true, } = {}) {
47
51
  const { t } = useTranslation('dndev');
48
52
  const pathname = useRoutePath();
49
53
  const navigate = useNavigate();
@@ -83,7 +87,7 @@ export default function NotFoundPage() {
83
87
  color: 'var(--muted-foreground)',
84
88
  textAlign: 'center',
85
89
  margin: 0,
86
- }, children: t('errors.notFound.description', "The page you're looking for doesn't exist or has been moved.") }), pathname && (_jsx("code", { style: {
90
+ }, children: t('errors.notFound.description', "The page you're looking for doesn't exist or has been moved.") }), showRequestedPath && pathname && (_jsx("code", { style: {
87
91
  padding: 'var(--gap-sm) var(--gap-md)',
88
92
  background: 'var(--muted)',
89
93
  borderRadius: 'var(--radius-md)',
@@ -1 +1 @@
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 T,publicPathname as N,splitLanguagePath as I}from"@donotdev/core";function v(){return I(N(C()??"/"),b()).language}function h(){let e=v(),t=b();return r=>T(r,e,t)}function R(){let e=d(),t=$(s=>s.closeAll),r=h();return(s,n)=>{if(s==="back")return t(),e.back();t();let o=r(s);if(n?.preserveScroll&&G()){let a=window.scrollY;n?.replace?e.replace(o):e.push(o),requestAnimationFrame(()=>{window.scrollTo({top:a,behavior:"auto"})});return}return n?.replace?e.replace(o):e.push(o)}}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 D}from"next/navigation";import{usePathname as O}from"next/navigation";import{getLanguageRouting as z,publicPathname as q,splitLanguagePath as Q}from"@donotdev/core";function p(){return Q(q(O()??"/"),z()).path}function f(){let e=p(),r=D().toString(),s=r?`?${r}`:void 0;return{pathname:e,search:s,hash:"",state:null}}import{useParams as F}from"next/navigation";function x(){let e=F();return e||{}}function M(e){let r=x()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as j}from"next/navigation";function A(){return j()}function _(e){let t=p(),r=e.replace(/:[^/]+/g,"([^/]+)").replace(/\*/g,".*"),s=new RegExp(`^${r}$`),n=t.match(s);if(!n)return null;let o=e.match(/:[^/]+/g)?.map(u=>u.slice(1))||[],a={};return o.forEach((u,i)=>{a[u]=n[i+1]||""}),{params:a,pathname:t,pattern:e}}import{useCallback as S}from"react";function B(){let e=A(),t=R(),r=f(),s=S((a,u)=>{let i=new URLSearchParams(e.toString());i.set(a,u);let m=i.toString(),l=`${r.pathname||"/"}${m?`?${m}`:""}`;t(l)},[e,t,r.pathname]),n=S(a=>{let u=new URLSearchParams(e.toString());u.delete(a);let i=u.toString(),P=`${r.pathname||"/"}${i?`?${i}`:""}`;t(P)},[e,t,r.pathname]),o=S(()=>{let a=r.pathname||"/";t(a)},[t,r.pathname]);return{query:e,setQuery:s,removeQuery:n,clearQueries:o}}import{useMemo as Z}from"react";import{isClient as J,FEATURE_STATUS as V}from"@donotdev/core";import{useAppConfig as W,useAuthConfig as X}from"@donotdev/core";import*as k from"@donotdev/auth";import{DEGRADED_AUTH_API as Y}from"@donotdev/core";var w=k?.useAuth;function H(e){return Y[e]}function g(e){return w?w(e):H(e)}var Ce=k?.PasswordResetCallback??(()=>null);function ee(e={}){let{auth:t,redirectTo:r,condition:s}=e,n=f(),o=X(),a=W().auth===!1,u=g("user"),i=g("can"),m=g("status");return Z(()=>{let l={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!J())return l;if(m===V.INITIALIZING)return{...l,isChecking:!0};if(s){let c=s(u,m);return{shouldRedirect:c,redirectTo:c&&r||null,isChecking:!1}}if(t!==!1&&t!==void 0){if(!i)return l;if(!i.navigate(t)){if(a&&!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&&!u){let L=n.search?.includes("code=")||n.search?.includes("state=")||n.search?.includes("error="),y=o.authRoute;L?c=`${y}${n.search}`: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,m,u,i,s,r,n.search,a,o.authRoute,o.roleRoute,o.tierRoute])}export{U as useBack,h as useLocalizedPath,f as useLocation,_ as useMatch,R as useNavigate,x as useParams,E as usePrefetch,B as useQueryParams,ee as useRedirectGuard,K as useRefresh,M as useRouteParam,p as useRoutePath,A as useSearchParams,v as useUrlLanguage};
1
+ "use client";import{useRouter as d}from"next/navigation";import{isClient as G,useOverlayStore as $}from"@donotdev/core";import{usePathname as L}from"next/navigation";import{getLanguageRouting as b,localizePath as T,publicPathname as N,splitLanguagePath as I}from"@donotdev/core";function w(){return I(N(L()??"/"),b()).language}function h(){let e=w(),t=b();return r=>T(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 D}from"next/navigation";import{usePathname as O}from"next/navigation";import{getLanguageRouting as z,publicPathname as q,splitLanguagePath as Q}from"@donotdev/core";function m(){return Q(q(O()??"/"),z()).path}function R(){let e=m(),r=D().toString(),n=r?`?${r}`:void 0;return{pathname:e,search:n,hash:"",state:null}}import{useParams as F}from"next/navigation";function x(){let e=F();return e||{}}function M(e){let r=x()[e];if(typeof r=="string")return r;if(Array.isArray(r)&&r.length>0)return r[0]}import{useSearchParams as j}from"next/navigation";function A(){return j()}function _(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 B(){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 Z}from"react";import{isClient as J,FEATURE_STATUS as V}from"@donotdev/core";import{useAppConfig as W,useAuthConfig as X}from"@donotdev/core";import*as k from"@donotdev/auth";import{DEGRADED_AUTH_API as Y}from"@donotdev/core";var v=k?.useAuth;function H(e){return Y[e]}function g(e){return v?v(e):H(e)}var Le=k?.PasswordResetCallback??(()=>null);function ee(e={}){let{auth:t,redirectTo:r,condition:n}=e,o=X(),u=W().auth===!1,s=g("user"),a=g("can"),i=g("status");return Z(()=>{let l={shouldRedirect:!1,redirectTo:null,isChecking:!1};if(!J())return l;if(i===V.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,C=f.includes("code=")||f.includes("state=")||f.includes("error="),y=o.authRoute;C?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,_ as useMatch,P as useNavigate,x as useParams,E as usePrefetch,B as useQueryParams,ee as useRedirectGuard,K as useRefresh,M as useRouteParam,m as useRoutePath,A as useSearchParams,w as useUrlLanguage};
@@ -21,7 +21,9 @@ export interface RedirectGuardResult {
21
21
  * Hook that checks if redirect should happen before render
22
22
  *
23
23
  * Prevents content flash by determining redirect state synchronously.
24
- * Returns safe defaults on server (SSR-safe).
24
+ * Returns safe defaults on server (SSR-safe). Reads the query string from
25
+ * `window.location` when it redirects, not through `useSearchParams`: a cached
26
+ * (static) page using it keeps its server-rendered HTML.
25
27
  *
26
28
  * @param options - Redirect guard configuration
27
29
  * @returns Redirect guard state
@@ -1 +1 @@
1
- {"version":3,"file":"useRedirectGuard.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAK9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IAEnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAwGrB"}
1
+ {"version":3,"file":"useRedirectGuard.next.d.ts","sourceRoot":"","sources":["../../../src/routing/hooks/useRedirectGuard.next.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAI9D,yDAAyD;AACzD,MAAM,WAAW,oBAAoB;IACnC,wCAAwC;IACxC,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IACxB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,mEAAmE;IAEnE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,MAAM,EAAE,aAAa,KAAK,OAAO,CAAC;CAC3D;AAED,iDAAiD;AACjD,MAAM,WAAW,mBAAmB;IAClC,qCAAqC;IACrC,cAAc,EAAE,OAAO,CAAC;IACxB,uDAAuD;IACvD,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,gDAAgD;IAChD,UAAU,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,GAAE,oBAAyB,GACjC,mBAAmB,CAyGrB"}
@@ -11,21 +11,22 @@
11
11
  import { useMemo } from 'react';
12
12
  import { isClient, FEATURE_STATUS } from '@donotdev/core';
13
13
  import { useAppConfig, useAuthConfig } from '@donotdev/core';
14
- import { useLocation } from './useLocation.next';
15
14
  import { useAuthSafe } from '../../utils/useAuthSafe';
16
15
  /**
17
16
  * Hook that checks if redirect should happen before render
18
17
  *
19
18
  * Prevents content flash by determining redirect state synchronously.
20
- * Returns safe defaults on server (SSR-safe).
19
+ * Returns safe defaults on server (SSR-safe). Reads the query string from
20
+ * `window.location` when it redirects, not through `useSearchParams`: a cached
21
+ * (static) page using it keeps its server-rendered HTML.
21
22
  *
22
23
  * @param options - Redirect guard configuration
23
24
  * @returns Redirect guard state
24
25
  */
25
26
  export function useRedirectGuard(options = {}) {
26
27
  const { auth, redirectTo: customRedirectTo, condition } = options;
27
- // Hooks must be called unconditionally (Rules of Hooks)
28
- const location = useLocation();
28
+ // Hooks must be called unconditionally (Rules of Hooks). No useLocation(): reading
29
+ // the query string through a hook would move a cached (static) page to the browser.
29
30
  const authConfig = useAuthConfig();
30
31
  const authDisabled = useAppConfig().auth === false;
31
32
  const user = useAuthSafe('user');
@@ -68,12 +69,14 @@ export function useRedirectGuard(options = {}) {
68
69
  // Authentication failure (not logged in) → always redirect
69
70
  if (typeof auth === 'object' && auth.required && !user) {
70
71
  // Check if we have OAuth parameters that need to be preserved
71
- const hasOAuthParams = location.search?.includes('code=') ||
72
- location.search?.includes('state=') ||
73
- location.search?.includes('error=');
72
+ // (client only, see isClient() above: read at decision time)
73
+ const search = window.location.search;
74
+ const hasOAuthParams = search.includes('code=') ||
75
+ search.includes('state=') ||
76
+ search.includes('error=');
74
77
  const authRoute = authConfig.authRoute;
75
78
  if (hasOAuthParams) {
76
- targetRoute = `${authRoute}${location.search}`;
79
+ targetRoute = `${authRoute}${search}`;
77
80
  }
78
81
  else {
79
82
  targetRoute = authRoute;
@@ -107,7 +110,6 @@ export function useRedirectGuard(options = {}) {
107
110
  can,
108
111
  condition,
109
112
  customRedirectTo,
110
- location.search,
111
113
  authDisabled,
112
114
  authConfig.authRoute,
113
115
  authConfig.roleRoute,
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @fileoverview Breadcrumb path rules
3
+ * @description One rule for Breadcrumbs and form navigation: every cumulative
4
+ * path prefix is a crumb, and a crumb links only when it is a known route.
5
+ *
6
+ * @version 0.1.0
7
+ * @since 0.2.5
8
+ * @author AMBROISE PARK Consulting
9
+ */
10
+ /**
11
+ * Cumulative prefixes of a pathname: `/a/b/c` → `['/a', '/a/b', '/a/b/c']`.
12
+ *
13
+ * @param pathname - App path (no language prefix)
14
+ * @returns One entry per segment, in order
15
+ */
16
+ export declare function getPathPrefixes(pathname: string): string[];
17
+ /**
18
+ * Previous breadcrumb: the nearest parent prefix that is a known route, else home.
19
+ * `/routines/abc` → `/routines`; `/reglages` → `/`.
20
+ *
21
+ * @param pathname - App path (no language prefix)
22
+ * @param routePaths - Known route paths (what Breadcrumbs links)
23
+ * @param homePath - Path when no parent route exists
24
+ * @returns The path the previous breadcrumb links to
25
+ */
26
+ export declare function getParentRoutePath(pathname: string, routePaths: ReadonlySet<string>, homePath?: string): string;
27
+ //# sourceMappingURL=parentRoute.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parentRoute.d.ts","sourceRoot":"","sources":["../../src/routing/parentRoute.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAQ1D;AAED;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,WAAW,CAAC,MAAM,CAAC,EAC/B,QAAQ,SAAM,GACb,MAAM,CAOR"}
@@ -0,0 +1,43 @@
1
+ // packages/ui/src/routing/parentRoute.ts
2
+ /**
3
+ * @fileoverview Breadcrumb path rules
4
+ * @description One rule for Breadcrumbs and form navigation: every cumulative
5
+ * path prefix is a crumb, and a crumb links only when it is a known route.
6
+ *
7
+ * @version 0.1.0
8
+ * @since 0.2.5
9
+ * @author AMBROISE PARK Consulting
10
+ */
11
+ /**
12
+ * Cumulative prefixes of a pathname: `/a/b/c` → `['/a', '/a/b', '/a/b/c']`.
13
+ *
14
+ * @param pathname - App path (no language prefix)
15
+ * @returns One entry per segment, in order
16
+ */
17
+ export function getPathPrefixes(pathname) {
18
+ const prefixes = [];
19
+ let current = '';
20
+ for (const segment of pathname.split('/').filter(Boolean)) {
21
+ current += `/${segment}`;
22
+ prefixes.push(current);
23
+ }
24
+ return prefixes;
25
+ }
26
+ /**
27
+ * Previous breadcrumb: the nearest parent prefix that is a known route, else home.
28
+ * `/routines/abc` → `/routines`; `/reglages` → `/`.
29
+ *
30
+ * @param pathname - App path (no language prefix)
31
+ * @param routePaths - Known route paths (what Breadcrumbs links)
32
+ * @param homePath - Path when no parent route exists
33
+ * @returns The path the previous breadcrumb links to
34
+ */
35
+ export function getParentRoutePath(pathname, routePaths, homePath = '/') {
36
+ const parents = getPathPrefixes(pathname).slice(0, -1);
37
+ for (let index = parents.length - 1; index >= 0; index--) {
38
+ const path = parents[index];
39
+ if (path !== undefined && routePaths.has(path))
40
+ return path;
41
+ }
42
+ return homePath;
43
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../../src/routing/useNavigation.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAQtD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAkDrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAG3E"}
1
+ {"version":3,"file":"useNavigation.d.ts","sourceRoot":"","sources":["../../src/routing/useNavigation.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAYtD;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,eAAe;IACrD,mEAAmE;IACnE,QAAQ,EAAE,OAAO,CAAC;IAClB,yCAAyC;IACzC,WAAW,EAAE,OAAO,CAAC;IACrB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CAyBrD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,GAAG,SAAS,CAG3E"}