next-language-selector 0.3.0 → 0.3.1

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 CHANGED
@@ -2,8 +2,9 @@
2
2
 
3
3
  ![npm version](https://img.shields.io/npm/v/next-language-selector?color=3178C6&style=flat-square)
4
4
  ![bundle size](https://img.shields.io/bundlephobia/minzip/next-language-selector?color=black&style=flat-square)
5
+ [![codecov](https://codecov.io/gh/kirilinsky/next-language-selector/graph/badge.svg)](https://codecov.io/gh/kirilinsky/next-language-selector)
5
6
  ![security score](https://socket.dev/api/badge/npm/package/next-language-selector?style=flat-square)
6
- ![license](https://img.shields.io/npm/l/next-language-selector?color=gray&style=flat-square)
7
+ ![license](https://img.shields.io/npm/l/next-language-selector?color=2E7D32&style=flat-square)
7
8
 
8
9
  A lightweight, unstyled language selector for Next.js (App Router & Pages Router).
9
10
  Manages the `NEXT_LOCALE` cookie and works with `next-intl` or any i18n solution.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";var m=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var h=(t,o)=>{for(var r in o)m(t,r,{get:o[r],enumerable:!0})},P=(t,o,r,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of E(o))!x.call(t,n)&&n!==r&&m(t,n,{get:()=>o[n],enumerable:!(a=v(o,n))||a.enumerable});return t};var b=t=>P(m({},"__esModule",{value:!0}),t);var I={};h(I,{LanguageSelector:()=>w,setLocaleCookie:()=>i});module.exports=b(I);var s=require("react");var i=(t,o="NEXT_LOCALE",r=!0)=>{if(typeof document>"u")return;let a=encodeURIComponent(o),n=encodeURIComponent(t);document.cookie=`${a}=${n}; max-age=31536000; path=/; SameSite=Lax`,r&&window.location.reload()};var c=require("react/jsx-runtime");function k(t){let{locales:o,defaultLocale:r,cookieName:a="NEXT_LOCALE",isDropdown:n=!1,autoReload:p=!0,renderCustom:d,className:f,itemClassName:g}=t,[N,R]=(0,s.useState)(!1),[l,L]=(0,s.useState)(r);(0,s.useEffect)(()=>{let e=encodeURIComponent(a),C=document.cookie.split("; ").find(y=>y.startsWith(`${e}=`)),S=C?decodeURIComponent(C.split("=").slice(1).join("=")):null;S&&L(S),R(!0)},[a]);let u=(0,s.useCallback)(e=>{L(e),i(e,a,p)},[a,p]);return N?d?(0,c.jsx)(c.Fragment,{children:d({locales:o,currentLocale:l,onChange:u})}):n?(0,c.jsx)("select",{value:l,onChange:e=>u(e.target.value),className:f,children:o.map(e=>(0,c.jsxs)("option",{value:e.code,className:g,children:[e.flag," ",e.name]},e.code))}):(0,c.jsx)("div",{className:f,children:o.map(e=>(0,c.jsxs)("button",{onClick:()=>u(e.code),"data-active":l===e.code,"aria-pressed":l===e.code,className:g,children:[e.flag," ",e.name]},e.code))}):null}var w=k;0&&(module.exports={LanguageSelector,setLocaleCookie});
1
+ "use strict";var f=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var x=Object.prototype.hasOwnProperty;var h=(t,o)=>{for(var a in o)f(t,a,{get:o[a],enumerable:!0})},P=(t,o,a,n)=>{if(o&&typeof o=="object"||typeof o=="function")for(let c of E(o))!x.call(t,c)&&c!==a&&f(t,c,{get:()=>o[c],enumerable:!(n=v(o,c))||n.enumerable});return t};var b=t=>P(f({},"__esModule",{value:!0}),t);var I={};h(I,{LanguageSelector:()=>w,setLocaleCookie:()=>i});module.exports=b(I);var s=require("react");var i=(t,o="NEXT_LOCALE",a=!0)=>{if(typeof document>"u")return;let n=encodeURIComponent(o),c=encodeURIComponent(t);document.cookie=`${n}=${c}; max-age=31536000; path=/; SameSite=Lax`,a&&window.location.reload()};var r=require("react/jsx-runtime");function N(t){let{locales:o,defaultLocale:a,cookieName:n="NEXT_LOCALE",isDropdown:c=!1,autoReload:g=!0,renderCustom:L,className:C,itemClassName:S}=t,[R,y]=(0,s.useState)(!1),[l,u]=(0,s.useState)(a);(0,s.useEffect)(()=>{let e=encodeURIComponent(n),k=document.cookie.split("; ").find(d=>d.startsWith(`${e}=`)),p=k?decodeURIComponent(k.split("=").slice(1).join("=")):null;p&&o.some(d=>d.code===p)?u(p):u(a),y(!0)},[n,a,o]);let m=(0,s.useCallback)(e=>{u(e),i(e,n,g)},[n,g]);return R?L?(0,r.jsx)(r.Fragment,{children:L({locales:o,currentLocale:l,onChange:m})}):c?(0,r.jsx)("select",{value:l,onChange:e=>m(e.target.value),className:C,children:o.map(e=>(0,r.jsxs)("option",{value:e.code,className:S,children:[e.flag," ",e.name]},e.code))}):(0,r.jsx)("div",{className:C,children:o.map(e=>(0,r.jsxs)("button",{onClick:()=>m(e.code),"data-active":l===e.code,"aria-pressed":l===e.code,className:S,children:[e.flag," ",e.name]},e.code))}):null}var w=N;0&&(module.exports={LanguageSelector,setLocaleCookie});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{useCallback as v,useEffect as E,useState as C}from"react";var l=(n,t="NEXT_LOCALE",c=!0)=>{if(typeof document>"u")return;let o=encodeURIComponent(t),r=encodeURIComponent(n);document.cookie=`${o}=${r}; max-age=31536000; path=/; SameSite=Lax`,c&&window.location.reload()};import{Fragment as x,jsx as i,jsxs as S}from"react/jsx-runtime";function k(n){let{locales:t,defaultLocale:c,cookieName:o="NEXT_LOCALE",isDropdown:r=!1,autoReload:u=!0,renderCustom:m,className:p,itemClassName:d}=n,[N,R]=C(!1),[a,f]=C(c);E(()=>{let e=encodeURIComponent(o),g=document.cookie.split("; ").find(y=>y.startsWith(`${e}=`)),L=g?decodeURIComponent(g.split("=").slice(1).join("=")):null;L&&f(L),R(!0)},[o]);let s=v(e=>{f(e),l(e,o,u)},[o,u]);return N?m?i(x,{children:m({locales:t,currentLocale:a,onChange:s})}):r?i("select",{value:a,onChange:e=>s(e.target.value),className:p,children:t.map(e=>S("option",{value:e.code,className:d,children:[e.flag," ",e.name]},e.code))}):i("div",{className:p,children:t.map(e=>S("button",{onClick:()=>s(e.code),"data-active":a===e.code,"aria-pressed":a===e.code,className:d,children:[e.flag," ",e.name]},e.code))}):null}var A=k;export{A as LanguageSelector,l as setLocaleCookie};
1
+ import{useCallback as v,useEffect as E,useState as S}from"react";var m=(c,o="NEXT_LOCALE",a=!0)=>{if(typeof document>"u")return;let t=encodeURIComponent(o),r=encodeURIComponent(c);document.cookie=`${t}=${r}; max-age=31536000; path=/; SameSite=Lax`,a&&window.location.reload()};import{Fragment as x,jsx as p,jsxs as k}from"react/jsx-runtime";function N(c){let{locales:o,defaultLocale:a,cookieName:t="NEXT_LOCALE",isDropdown:r=!1,autoReload:d=!0,renderCustom:f,className:g,itemClassName:L}=c,[R,y]=S(!1),[n,s]=S(a);E(()=>{let e=encodeURIComponent(t),C=document.cookie.split("; ").find(u=>u.startsWith(`${e}=`)),i=C?decodeURIComponent(C.split("=").slice(1).join("=")):null;i&&o.some(u=>u.code===i)?s(i):s(a),y(!0)},[t,a,o]);let l=v(e=>{s(e),m(e,t,d)},[t,d]);return R?f?p(x,{children:f({locales:o,currentLocale:n,onChange:l})}):r?p("select",{value:n,onChange:e=>l(e.target.value),className:g,children:o.map(e=>k("option",{value:e.code,className:L,children:[e.flag," ",e.name]},e.code))}):p("div",{className:g,children:o.map(e=>k("button",{onClick:()=>l(e.code),"data-active":n===e.code,"aria-pressed":n===e.code,className:L,children:[e.flag," ",e.name]},e.code))}):null}var A=N;export{A as LanguageSelector,m as setLocaleCookie};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-language-selector",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Configurable language selector for Next.js",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -59,5 +59,6 @@
59
59
  "typescript": "^5.9.3",
60
60
  "vitest": "^4.1.2"
61
61
  },
62
- "sideEffects": false
62
+ "sideEffects": false,
63
+ "packageManager": "pnpm@10.32.1"
63
64
  }