@djangocfg/layouts 2.1.145 → 2.1.147

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.145",
3
+ "version": "2.1.147",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -74,12 +74,12 @@
74
74
  "check": "tsc --noEmit"
75
75
  },
76
76
  "peerDependencies": {
77
- "@djangocfg/api": "^2.1.145",
78
- "@djangocfg/centrifugo": "^2.1.145",
79
- "@djangocfg/i18n": "^2.1.145",
80
- "@djangocfg/ui-core": "^2.1.145",
81
- "@djangocfg/ui-nextjs": "^2.1.145",
82
- "@djangocfg/ui-tools": "^2.1.145",
77
+ "@djangocfg/api": "^2.1.147",
78
+ "@djangocfg/centrifugo": "^2.1.147",
79
+ "@djangocfg/i18n": "^2.1.147",
80
+ "@djangocfg/ui-core": "^2.1.147",
81
+ "@djangocfg/ui-nextjs": "^2.1.147",
82
+ "@djangocfg/ui-tools": "^2.1.147",
83
83
  "@hookform/resolvers": "^5.2.2",
84
84
  "consola": "^3.4.2",
85
85
  "lucide-react": "^0.545.0",
@@ -102,13 +102,13 @@
102
102
  "uuid": "^11.1.0"
103
103
  },
104
104
  "devDependencies": {
105
- "@djangocfg/api": "^2.1.145",
106
- "@djangocfg/i18n": "^2.1.145",
107
- "@djangocfg/centrifugo": "^2.1.145",
108
- "@djangocfg/typescript-config": "^2.1.145",
109
- "@djangocfg/ui-core": "^2.1.145",
110
- "@djangocfg/ui-nextjs": "^2.1.145",
111
- "@djangocfg/ui-tools": "^2.1.145",
105
+ "@djangocfg/api": "^2.1.147",
106
+ "@djangocfg/i18n": "^2.1.147",
107
+ "@djangocfg/centrifugo": "^2.1.147",
108
+ "@djangocfg/typescript-config": "^2.1.147",
109
+ "@djangocfg/ui-core": "^2.1.147",
110
+ "@djangocfg/ui-nextjs": "^2.1.147",
111
+ "@djangocfg/ui-tools": "^2.1.147",
112
112
  "@types/node": "^24.7.2",
113
113
  "@types/react": "^19.1.0",
114
114
  "@types/react-dom": "^19.1.0",
@@ -0,0 +1 @@
1
+ export { usePathnameWithoutLocale, stripLocalePrefix } from './usePathnameWithoutLocale';
@@ -0,0 +1,39 @@
1
+ 'use client';
2
+
3
+ import { usePathname } from 'next/navigation';
4
+ import { useMemo } from 'react';
5
+
6
+ /**
7
+ * Strip locale prefix from pathname
8
+ * Handles: /xx/path, /xx-XX/path (e.g., /en, /ko, /pt-BR)
9
+ */
10
+ function stripLocalePrefix(pathname: string): string {
11
+ // Match /xx or /xx-XX at the start
12
+ const match = pathname.match(/^\/[a-z]{2}(-[A-Z]{2})?(\/|$)/);
13
+
14
+ if (match) {
15
+ const rest = pathname.slice(match[0].length - 1) || '/';
16
+ return rest.startsWith('/') ? rest : '/' + rest;
17
+ }
18
+
19
+ return pathname;
20
+ }
21
+
22
+ /**
23
+ * usePathnameWithoutLocale
24
+ *
25
+ * Returns pathname without locale prefix.
26
+ * Useful for route matching when using next-intl or similar i18n routing.
27
+ *
28
+ * @example
29
+ * // URL: /ko/private/dashboard
30
+ * const pathname = usePathnameWithoutLocale();
31
+ * // pathname = '/private/dashboard'
32
+ */
33
+ export function usePathnameWithoutLocale(): string {
34
+ const pathname = usePathname();
35
+
36
+ return useMemo(() => stripLocalePrefix(pathname), [pathname]);
37
+ }
38
+
39
+ export { stripLocalePrefix };
package/src/index.ts CHANGED
@@ -43,5 +43,8 @@ export * from './components';
43
43
  // Utils
44
44
  export * from './utils';
45
45
 
46
+ // Hooks
47
+ export * from './hooks';
48
+
46
49
  // Pages
47
50
  export * from './pages';
@@ -32,10 +32,10 @@
32
32
 
33
33
  'use client';
34
34
 
35
- import { usePathname } from 'next/navigation';
36
35
  import React, { ReactNode, useMemo } from 'react';
37
36
 
38
37
  import { ClientOnly, Suspense } from '../../components/core';
38
+ import { usePathnameWithoutLocale } from '../../hooks';
39
39
  import { BaseApp } from './BaseApp';
40
40
 
41
41
  import type {
@@ -57,11 +57,11 @@ export type LayoutMode = 'public' | 'private' | 'admin';
57
57
  */
58
58
  function matchesPath(pathname: string, enabledPath?: string | string[]): boolean {
59
59
  if (!enabledPath) return false;
60
-
60
+
61
61
  if (typeof enabledPath === 'string') {
62
62
  return pathname === enabledPath || pathname.startsWith(enabledPath + '/');
63
63
  }
64
-
64
+
65
65
  // Array of paths
66
66
  return enabledPath.some(path => pathname === path || pathname.startsWith(path + '/'));
67
67
  }
@@ -164,7 +164,8 @@ function AppLayoutContent({
164
164
  noLayoutPaths,
165
165
  i18n,
166
166
  }: AppLayoutProps) {
167
- const pathname = usePathname();
167
+ // Use pathname without locale prefix for route matching
168
+ const pathname = usePathnameWithoutLocale();
168
169
 
169
170
  // Check if current path should skip layout
170
171
  const shouldSkipLayout = useMemo(