@korioinc/next-core 2.0.57 → 3.0.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.
- package/README.md +6 -9
- package/dist/components/index.d.ts +0 -2
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/locale-switcher/index.d.ts +4 -5
- package/dist/components/locale-switcher/index.d.ts.map +1 -1
- package/dist/components/locale-switcher/index.js +2 -2
- package/dist/components/theme-switcher/index.d.ts +6 -10
- package/dist/components/theme-switcher/index.d.ts.map +1 -1
- package/dist/components/theme-switcher/index.js +5 -12
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -204,30 +204,27 @@ export default function Layout({ children }: { children: ReactNode }) {
|
|
|
204
204
|
}
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
The switchers keep theme state, system-theme resolution, locale cookies, and routing inside the kit. Consumer apps can supply catalog-owned
|
|
207
|
+
The switchers keep theme state, system-theme resolution, locale cookies, and routing inside the kit. Consumer apps can supply catalog-owned labels through the component API. Omitting the props uses concise English defaults.
|
|
208
208
|
|
|
209
209
|
```tsx
|
|
210
210
|
'use client';
|
|
211
211
|
|
|
212
|
-
import { LocaleSwitcher, ThemeSwitcher
|
|
212
|
+
import { LocaleSwitcher, ThemeSwitcher } from '@korioinc/next-core/components';
|
|
213
213
|
import { useLingui } from '@lingui/react/macro';
|
|
214
214
|
|
|
215
215
|
export function PreferenceControls() {
|
|
216
216
|
const { t } = useLingui();
|
|
217
|
-
const
|
|
217
|
+
const themeLabels = {
|
|
218
218
|
light: t`Light`,
|
|
219
219
|
dark: t`Dark`,
|
|
220
220
|
system: t`System`,
|
|
221
|
-
|
|
222
|
-
formatTriggerAriaLabel: (currentThemeLabel) => t`Switch theme (current: ${currentThemeLabel})`,
|
|
223
|
-
formatTriggerTitle: (currentThemeLabel) => t`Theme: ${currentThemeLabel} (click to change)`,
|
|
221
|
+
changeTheme: t`Change theme`,
|
|
224
222
|
};
|
|
225
|
-
const localeTriggerLabel = t`Change language`;
|
|
226
223
|
|
|
227
224
|
return (
|
|
228
225
|
<>
|
|
229
|
-
<ThemeSwitcher
|
|
230
|
-
<LocaleSwitcher
|
|
226
|
+
<ThemeSwitcher labels={themeLabels} />
|
|
227
|
+
<LocaleSwitcher ariaLabel={t`Change language`} />
|
|
231
228
|
</>
|
|
232
229
|
);
|
|
233
230
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { default as LocaleSwitcher } from './locale-switcher';
|
|
2
|
-
export type { LocaleSwitcherProps } from './locale-switcher';
|
|
3
2
|
export { default as ThemeSwitcher } from './theme-switcher';
|
|
4
|
-
export type { ThemeSwitcherMessages, ThemeSwitcherProps } from './theme-switcher';
|
|
5
3
|
export { default as Tooltip } from './tooltip';
|
|
6
4
|
export { HeadManifest } from './head-manifest';
|
|
7
5
|
export { JsonLd } from './json-ld';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAG/C,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
interface LocaleSwitcherProps {
|
|
2
2
|
/**
|
|
3
3
|
* Array of language codes to display in the switcher.
|
|
4
4
|
* Example: ['en', 'ko', 'ja']
|
|
@@ -6,9 +6,8 @@ export interface LocaleSwitcherProps {
|
|
|
6
6
|
*/
|
|
7
7
|
languages?: string[];
|
|
8
8
|
/** Accessible name for the language menu trigger. */
|
|
9
|
-
|
|
10
|
-
/** Optional tooltip text for the language menu trigger. */
|
|
11
|
-
triggerTitle?: string;
|
|
9
|
+
ariaLabel?: string;
|
|
12
10
|
}
|
|
13
|
-
export default function LocaleSwitcher({ languages,
|
|
11
|
+
export default function LocaleSwitcher({ languages, ariaLabel }?: LocaleSwitcherProps): import("react").JSX.Element | null;
|
|
12
|
+
export {};
|
|
14
13
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/locale-switcher/index.tsx"],"names":[],"mappings":"AAeA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/locale-switcher/index.tsx"],"names":[],"mappings":"AAeA,UAAU,mBAAmB;IAC3B;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,cAAc,CAAC,EAAE,SAAS,EAAE,SAA6B,EAAE,GAAE,mBAAwB,sCAmG5G"}
|
|
@@ -9,7 +9,7 @@ import { allLanguages } from './language-options';
|
|
|
9
9
|
import { resolveVisibleLanguages } from './resolve-visible-languages';
|
|
10
10
|
import { setCookie } from 'cookies-next/client';
|
|
11
11
|
import linguiConfig from 'lingui.config';
|
|
12
|
-
export default function LocaleSwitcher({ languages,
|
|
12
|
+
export default function LocaleSwitcher({ languages, ariaLabel = 'Change language' } = {}) {
|
|
13
13
|
const router = useRouter();
|
|
14
14
|
const pathname = usePathname();
|
|
15
15
|
const { i18n } = useLingui();
|
|
@@ -53,5 +53,5 @@ export default function LocaleSwitcher({ languages, triggerAriaLabel = 'Change l
|
|
|
53
53
|
if (!currentLanguage) {
|
|
54
54
|
return null;
|
|
55
55
|
}
|
|
56
|
-
return (_jsxs(Menu, { as: 'div', className: 'relative', children: [_jsx(MenuButton, { "aria-label":
|
|
56
|
+
return (_jsxs(Menu, { as: 'div', className: 'relative', children: [_jsx(MenuButton, { "aria-label": ariaLabel, className: 'glass glass-border-subtle hover:bg-glass-interactive relative inline-flex h-9 w-9 items-center justify-center rounded-md border transition-colors', children: currentLanguage.flag }), _jsx(Transition, { as: Fragment, enter: 'transition ease-out duration-100', enterFrom: 'transform opacity-0 scale-95', enterTo: 'transform opacity-100 scale-100', leave: 'transition ease-in duration-75', leaveFrom: 'transform opacity-100 scale-100', leaveTo: 'transform opacity-0 scale-95', children: _jsx(MenuItems, { anchor: 'bottom end', className: 'glass-surface glass-backdrop-md glass-shadow-sm glass-border-faint z-100 w-48 rounded-md border ring-1 ring-black/5 [--anchor-gap:8px] focus:outline-none', children: _jsx("div", { className: 'py-1', children: availableLanguages.map((language) => (_jsx(MenuItem, { children: _jsxs("button", { onClick: () => changeLanguage(language.code), className: 'data-[focus]:bg-glass-interactive text-foreground group flex w-full items-center gap-2 px-3 py-2 text-sm transition-colors', children: [language.flag, _jsx("span", { className: 'whitespace-nowrap', children: language.name }), currentLocale === language.code && (_jsx("svg", { className: 'ml-auto h-4 w-4', fill: 'none', stroke: 'currentColor', viewBox: '0 0 24 24', children: _jsx("path", { strokeLinecap: 'round', strokeLinejoin: 'round', strokeWidth: 2, d: 'M5 13l4 4L19 7' }) }))] }) }, language.code))) }) }) })] }));
|
|
57
57
|
}
|
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
interface ThemeSwitcherLabels {
|
|
3
3
|
light: string;
|
|
4
4
|
dark: string;
|
|
5
5
|
system: string;
|
|
6
|
-
|
|
7
|
-
formatTriggerAriaLabel: (currentThemeLabel: string) => string;
|
|
8
|
-
formatTriggerTitle: (currentThemeLabel: string) => string;
|
|
6
|
+
changeTheme: string;
|
|
9
7
|
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
messages?: ThemeSwitcherMessages;
|
|
8
|
+
interface ThemeSwitcherProps {
|
|
9
|
+
/** Consumer-owned labels. Omit to use the English defaults. */
|
|
10
|
+
labels?: ThemeSwitcherLabels;
|
|
15
11
|
}
|
|
16
|
-
declare const ThemeSwitcher: ({
|
|
12
|
+
declare const ThemeSwitcher: ({ labels }?: ThemeSwitcherProps) => React.JSX.Element;
|
|
17
13
|
export default ThemeSwitcher;
|
|
18
14
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/theme-switcher/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/theme-switcher/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAM/B,UAAU,mBAAmB;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,kBAAkB;IAC1B,+DAA+D;IAC/D,MAAM,CAAC,EAAE,mBAAmB,CAAC;CAC9B;AAwCD,QAAA,MAAM,aAAa,GAAI,aAA4C,kBAAuB,sBAoGzF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -2,13 +2,11 @@
|
|
|
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 '../../theme';
|
|
5
|
-
const
|
|
5
|
+
const DEFAULT_THEME_SWITCHER_LABELS = {
|
|
6
6
|
light: 'Light',
|
|
7
7
|
dark: 'Dark',
|
|
8
8
|
system: 'System',
|
|
9
|
-
|
|
10
|
-
formatTriggerAriaLabel: (currentThemeLabel) => `Switch theme (current: ${currentThemeLabel})`,
|
|
11
|
-
formatTriggerTitle: (currentThemeLabel) => `Theme: ${currentThemeLabel} (click to change)`,
|
|
9
|
+
changeTheme: 'Change theme',
|
|
12
10
|
};
|
|
13
11
|
const FALLBACK_THEME_ORDER = ['light', 'dark'];
|
|
14
12
|
const isThemeMode = (value) => value === 'light' || value === 'dark' || value === 'system';
|
|
@@ -25,7 +23,7 @@ const normalizeTheme = ({ theme, resolvedTheme, themeOrder, }) => {
|
|
|
25
23
|
}
|
|
26
24
|
return themeOrder[0] ?? 'light';
|
|
27
25
|
};
|
|
28
|
-
const ThemeSwitcher = ({
|
|
26
|
+
const ThemeSwitcher = ({ labels = DEFAULT_THEME_SWITCHER_LABELS } = {}) => {
|
|
29
27
|
const { theme, resolvedTheme, setTheme, themes } = useTheme();
|
|
30
28
|
const [mounted, setMounted] = React.useState(false);
|
|
31
29
|
const [canAnimateColors, setCanAnimateColors] = React.useState(false);
|
|
@@ -38,12 +36,7 @@ const ThemeSwitcher = ({ messages = DEFAULT_THEME_SWITCHER_MESSAGES } = {}) => {
|
|
|
38
36
|
}, []);
|
|
39
37
|
const themeOrder = getThemeOrder(themes);
|
|
40
38
|
const currentTheme = normalizeTheme({ theme, resolvedTheme, themeOrder });
|
|
41
|
-
const
|
|
42
|
-
const currentThemeLabel = currentTheme === 'system'
|
|
43
|
-
? messages.formatSystem(messages.system, resolvedThemeLabel)
|
|
44
|
-
: currentTheme === 'dark'
|
|
45
|
-
? messages.dark
|
|
46
|
-
: messages.light;
|
|
39
|
+
const currentThemeLabel = currentTheme === 'system' ? labels.system : currentTheme === 'dark' ? labels.dark : labels.light;
|
|
47
40
|
const toggleTheme = () => {
|
|
48
41
|
const currentIndex = themeOrder.indexOf(currentTheme);
|
|
49
42
|
const nextTheme = themeOrder[(currentIndex + 1) % themeOrder.length];
|
|
@@ -52,6 +45,6 @@ const ThemeSwitcher = ({ messages = DEFAULT_THEME_SWITCHER_MESSAGES } = {}) => {
|
|
|
52
45
|
if (!mounted) {
|
|
53
46
|
return (_jsx("button", { className: 'glass glass-border-subtle relative inline-flex h-9 w-9 items-center justify-center rounded-md border opacity-0', "aria-hidden": 'true', children: _jsx("div", { className: 'h-5 w-5' }) }));
|
|
54
47
|
}
|
|
55
|
-
return (_jsxs("button", { onClick: toggleTheme, className: `glass glass-border-subtle hover:bg-glass-interactive relative inline-flex h-9 w-9 items-center justify-center rounded-md border ${canAnimateColors ? 'transition-colors' : ''}`, "aria-label":
|
|
48
|
+
return (_jsxs("button", { onClick: toggleTheme, className: `glass glass-border-subtle hover:bg-glass-interactive relative inline-flex h-9 w-9 items-center justify-center rounded-md border ${canAnimateColors ? 'transition-colors' : ''}`, "aria-label": `${labels.changeTheme}: ${currentThemeLabel}`, children: [_jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', className: `absolute h-5 w-5 transition-all ${currentTheme === 'light' ? 'scale-100 rotate-0 opacity-100' : 'scale-0 rotate-90 opacity-0'}`, children: [_jsx("circle", { cx: '12', cy: '12', r: '5' }), _jsx("line", { x1: '12', y1: '1', x2: '12', y2: '3' }), _jsx("line", { x1: '12', y1: '21', x2: '12', y2: '23' }), _jsx("line", { x1: '4.22', y1: '4.22', x2: '5.64', y2: '5.64' }), _jsx("line", { x1: '18.36', y1: '18.36', x2: '19.78', y2: '19.78' }), _jsx("line", { x1: '1', y1: '12', x2: '3', y2: '12' }), _jsx("line", { x1: '21', y1: '12', x2: '23', y2: '12' }), _jsx("line", { x1: '4.22', y1: '19.78', x2: '5.64', y2: '18.36' }), _jsx("line", { x1: '18.36', y1: '5.64', x2: '19.78', y2: '4.22' })] }), _jsx("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', className: `absolute h-5 w-5 transition-all ${currentTheme === 'dark' ? 'scale-100 rotate-0 opacity-100' : 'scale-0 -rotate-90 opacity-0'}`, children: _jsx("path", { d: 'M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z' }) }), _jsxs("svg", { xmlns: 'http://www.w3.org/2000/svg', viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: '2', strokeLinecap: 'round', strokeLinejoin: 'round', className: `absolute h-5 w-5 transition-all ${currentTheme === 'system' ? 'scale-100 rotate-0 opacity-100' : 'scale-0 rotate-90 opacity-0'}`, children: [_jsx("rect", { x: '3', y: '4', width: '18', height: '12', rx: '2' }), _jsx("line", { x1: '8', y1: '20', x2: '16', y2: '20' }), _jsx("line", { x1: '12', y1: '16', x2: '12', y2: '20' })] })] }));
|
|
56
49
|
};
|
|
57
50
|
export default ThemeSwitcher;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@korioinc/next-core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./ads": {
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"tw-animate-css": "^1.4.0",
|
|
91
91
|
"typescript": "^6.0.3",
|
|
92
92
|
"vitest": "^4.1.10",
|
|
93
|
-
"@korioinc/next-configs": "
|
|
93
|
+
"@korioinc/next-configs": "3.0.0"
|
|
94
94
|
},
|
|
95
95
|
"dependencies": {
|
|
96
96
|
"@floating-ui/react": "^0.27.20",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"schema-dts": "^2.0.0",
|
|
106
106
|
"tailwind-merge": "^3.6.0",
|
|
107
107
|
"valtio": "^2.3.2",
|
|
108
|
-
"@korioinc/next-conf": "
|
|
108
|
+
"@korioinc/next-conf": "3.0.0"
|
|
109
109
|
},
|
|
110
110
|
"publishConfig": {
|
|
111
111
|
"access": "public",
|