@djangocfg/nextjs 2.1.111 → 2.1.112

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/nextjs",
3
- "version": "2.1.111",
3
+ "version": "2.1.112",
4
4
  "description": "Next.js server utilities: sitemap, health, OG images, contact forms, navigation, config",
5
5
  "keywords": [
6
6
  "nextjs",
@@ -160,8 +160,8 @@
160
160
  "pwa": "tsx src/pwa/cli.ts"
161
161
  },
162
162
  "peerDependencies": {
163
- "@djangocfg/i18n": "^2.1.111",
164
- "@djangocfg/ui-core": "^2.1.111",
163
+ "@djangocfg/i18n": "^2.1.112",
164
+ "@djangocfg/ui-core": "^2.1.112",
165
165
  "next": "^16.0.10"
166
166
  },
167
167
  "peerDependenciesMeta": {
@@ -181,11 +181,11 @@
181
181
  "web-push": "^3.6.7"
182
182
  },
183
183
  "devDependencies": {
184
- "@djangocfg/i18n": "^2.1.111",
185
- "@djangocfg/ui-core": "^2.1.111",
186
- "@djangocfg/imgai": "^2.1.111",
187
- "@djangocfg/layouts": "^2.1.111",
188
- "@djangocfg/typescript-config": "^2.1.111",
184
+ "@djangocfg/i18n": "^2.1.112",
185
+ "@djangocfg/ui-core": "^2.1.112",
186
+ "@djangocfg/imgai": "^2.1.112",
187
+ "@djangocfg/layouts": "^2.1.112",
188
+ "@djangocfg/typescript-config": "^2.1.112",
189
189
  "@types/node": "^24.7.2",
190
190
  "@types/react": "19.2.2",
191
191
  "@types/react-dom": "19.2.1",
@@ -1,7 +1,8 @@
1
1
  /**
2
- * LocaleSwitcher Component
2
+ * LocaleSwitcher Component (Smart)
3
3
  *
4
- * Ready-to-use locale switcher dropdown using @djangocfg/ui-core components
4
+ * Wrapper around @djangocfg/layouts LocaleSwitcher with next-intl hooks.
5
+ * Automatically gets locale data from routing config.
5
6
  *
6
7
  * @example
7
8
  * ```tsx
@@ -26,99 +27,34 @@
26
27
 
27
28
  'use client';
28
29
 
29
- import { Globe } from 'lucide-react';
30
-
31
30
  import {
32
- Button,
33
- DropdownMenu,
34
- DropdownMenuContent,
35
- DropdownMenuItem,
36
- DropdownMenuTrigger,
37
- } from '@djangocfg/ui-core/components';
31
+ LocaleSwitcher as BaseLocaleSwitcher,
32
+ type LocaleSwitcherProps as BaseLocaleSwitcherProps,
33
+ } from '@djangocfg/layouts';
38
34
 
39
35
  import { useLocaleSwitcher } from '../client';
40
36
  import type { LocaleCode } from '../types';
41
37
 
42
- // Default locale labels
43
- const DEFAULT_LABELS: Record<string, string> = {
44
- en: 'English',
45
- ru: 'Русский',
46
- ko: '한국어',
47
- zh: '中文',
48
- ja: '日本語',
49
- es: 'Español',
50
- fr: 'Français',
51
- de: 'Deutsch',
52
- pt: 'Português',
53
- it: 'Italiano',
54
- ar: 'العربية',
55
- hi: 'हिन्दी',
56
- tr: 'Türkçe',
57
- pl: 'Polski',
58
- nl: 'Nederlands',
59
- uk: 'Українська',
60
- };
61
-
62
- export interface LocaleSwitcherProps {
38
+ export interface LocaleSwitcherProps
39
+ extends Omit<BaseLocaleSwitcherProps, 'locale' | 'locales' | 'onChange'> {
63
40
  /** Available locales (defaults to all from routing config) */
64
41
  locales?: LocaleCode[];
65
- /** Custom labels for locales */
66
- labels?: Record<string, string>;
67
- /** Show locale code instead of/with label */
68
- showCode?: boolean;
69
- /** Button variant */
70
- variant?: 'ghost' | 'outline' | 'default';
71
- /** Button size */
72
- size?: 'sm' | 'default' | 'lg' | 'icon';
73
- /** Show icon */
74
- showIcon?: boolean;
75
- /** Custom className */
76
- className?: string;
77
42
  }
78
43
 
79
44
  export function LocaleSwitcher({
80
45
  locales: customLocales,
81
- labels = {},
82
- showCode = false,
83
- variant = 'ghost',
84
- size = 'sm',
85
- showIcon = true,
86
- className,
46
+ ...props
87
47
  }: LocaleSwitcherProps) {
88
48
  const { locale, locales: routingLocales, changeLocale } = useLocaleSwitcher();
89
49
 
90
50
  const availableLocales = customLocales || routingLocales;
91
- const allLabels = { ...DEFAULT_LABELS, ...labels };
92
-
93
- const getLabel = (code: LocaleCode) => {
94
- const label = allLabels[code] || code.toUpperCase();
95
- if (showCode) {
96
- return `${code.toUpperCase()} - ${label}`;
97
- }
98
- return label;
99
- };
100
-
101
- const currentLabel = showCode ? locale.toUpperCase() : getLabel(locale);
102
51
 
103
52
  return (
104
- <DropdownMenu>
105
- <DropdownMenuTrigger asChild>
106
- <Button variant={variant} size={size} className={className}>
107
- {showIcon && <Globe className="h-4 w-4 mr-1" />}
108
- <span>{currentLabel}</span>
109
- </Button>
110
- </DropdownMenuTrigger>
111
- <DropdownMenuContent align="end">
112
- {availableLocales.map((code) => (
113
- <DropdownMenuItem
114
- key={code}
115
- onClick={() => changeLocale(code)}
116
- className={code === locale ? 'bg-accent' : ''}
117
- >
118
- {getLabel(code)}
119
- </DropdownMenuItem>
120
- ))}
121
- </DropdownMenuContent>
122
- </DropdownMenu>
53
+ <BaseLocaleSwitcher
54
+ locale={locale}
55
+ locales={availableLocales}
56
+ onChange={changeLocale}
57
+ {...props}
58
+ />
123
59
  );
124
60
  }
@@ -36,7 +36,7 @@ const DEFAULT_LOCALE: LocaleCode = 'en';
36
36
  export function createRouting(config?: Partial<I18nConfig>) {
37
37
  const locales = config?.locales ?? DEFAULT_LOCALES;
38
38
  const defaultLocale = config?.defaultLocale ?? DEFAULT_LOCALE;
39
- const localePrefix = config?.localePrefix ?? 'always';
39
+ const localePrefix = config?.localePrefix ?? 'as-needed';
40
40
 
41
41
  return defineRouting({
42
42
  locales,