@korioinc/next-core 2.0.20 → 2.0.21

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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/locale-switcher/index.tsx"],"names":[],"mappings":"AAoDA,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,SAAS,EAAE,GAAE,mBAAwB,kDA4E7E"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/locale-switcher/index.tsx"],"names":[],"mappings":"AAoDA,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,SAAS,EAAE,GAAE,mBAAwB,kDAiF7E"}
@@ -46,8 +46,13 @@ export default function LocaleSwitcher({ languages } = {}) {
46
46
  useEffect(() => {
47
47
  setMounted(true);
48
48
  }, []);
49
- // Filter languages based on provided codes or use all
50
- const availableLanguages = languages ? allLanguages.filter((lang) => languages.includes(lang.code)) : allLanguages;
49
+ // Build visible language list, preserving user-provided order.
50
+ const languageMap = new Map(allLanguages.map((language) => [language.code, language]));
51
+ const availableLanguages = languages
52
+ ? Array.from(new Set(languages))
53
+ .map((code) => languageMap.get(code))
54
+ .filter((language) => Boolean(language))
55
+ : allLanguages;
51
56
  // Get current locale from Lingui
52
57
  const currentLocale = i18n.locale;
53
58
  // Always provide a fallback to ensure currentLanguage is never undefined
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/theme-switcher/index.tsx"],"names":[],"mappings":"AAkBA,QAAA,MAAM,aAAa,+CA4FlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/theme-switcher/index.tsx"],"names":[],"mappings":"AAuCA,QAAA,MAAM,aAAa,+CA6FlB,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -2,25 +2,34 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import * as React from 'react';
4
4
  import { useTheme } from 'next-themes';
5
- const THEME_ORDER = ['system', 'light', 'dark'];
6
- const normalizeTheme = (value) => {
7
- if (value === 'light' || value === 'dark' || value === 'system') {
8
- return value;
5
+ const FALLBACK_THEME_ORDER = ['light', 'dark'];
6
+ const isThemeMode = (value) => value === 'light' || value === 'dark' || value === 'system';
7
+ const getThemeOrder = (themes) => {
8
+ const availableThemes = themes.filter(isThemeMode);
9
+ return availableThemes.length > 0 ? availableThemes : FALLBACK_THEME_ORDER;
10
+ };
11
+ const normalizeTheme = ({ theme, resolvedTheme, themeOrder, }) => {
12
+ if (isThemeMode(theme) && themeOrder.includes(theme)) {
13
+ return theme;
14
+ }
15
+ if (isThemeMode(resolvedTheme) && themeOrder.includes(resolvedTheme)) {
16
+ return resolvedTheme;
9
17
  }
10
- return 'system';
18
+ return themeOrder[0] ?? 'light';
11
19
  };
12
20
  const ThemeSwitcher = () => {
13
- const { theme, resolvedTheme, setTheme } = useTheme();
21
+ const { theme, resolvedTheme, setTheme, themes } = useTheme();
14
22
  const [mounted, setMounted] = React.useState(false);
15
23
  React.useEffect(() => {
16
24
  setMounted(true);
17
25
  }, []);
18
- const currentTheme = normalizeTheme(theme);
26
+ const themeOrder = getThemeOrder(themes);
27
+ const currentTheme = normalizeTheme({ theme, resolvedTheme, themeOrder });
19
28
  const resolvedThemeLabel = resolvedTheme === 'dark' ? 'Dark' : 'Light';
20
29
  const currentThemeLabel = currentTheme === 'system' ? `System (${resolvedThemeLabel})` : currentTheme === 'dark' ? 'Dark' : 'Light';
21
30
  const toggleTheme = () => {
22
- const currentIndex = THEME_ORDER.indexOf(currentTheme);
23
- const nextTheme = THEME_ORDER[(currentIndex + 1) % THEME_ORDER.length];
31
+ const currentIndex = themeOrder.indexOf(currentTheme);
32
+ const nextTheme = themeOrder[(currentIndex + 1) % themeOrder.length];
24
33
  setTheme(nextTheme);
25
34
  };
26
35
  if (!mounted) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korioinc/next-core",
3
- "version": "2.0.20",
3
+ "version": "2.0.21",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./ads": {
@@ -79,7 +79,7 @@
79
79
  "tsc-alias": "^1.8.16",
80
80
  "tw-animate-css": "^1.4.0",
81
81
  "typescript": "^5.9.3",
82
- "@korioinc/next-configs": "2.0.20"
82
+ "@korioinc/next-configs": "2.0.21"
83
83
  },
84
84
  "dependencies": {
85
85
  "@floating-ui/react": "^0.27.17",
@@ -94,7 +94,7 @@
94
94
  "schema-dts": "^1.1.5",
95
95
  "tailwind-merge": "^3.4.0",
96
96
  "valtio": "^2.3.0",
97
- "@korioinc/next-conf": "2.0.20"
97
+ "@korioinc/next-conf": "2.0.21"
98
98
  },
99
99
  "publishConfig": {
100
100
  "access": "public",