@ethnolib/language-chooser-react-mui 0.0.15 → 0.0.16

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.
Files changed (3) hide show
  1. package/index.js +1 -2
  2. package/index.mjs +1 -2
  3. package/package.json +2 -2
package/index.js CHANGED
@@ -242,7 +242,7 @@ function print() { __p += __j.call(arguments, '') }
242
242
  color: ${An.greys[3]};
243
243
  `,children:a.names.join(Lz)})]})}),hz=({scriptData:a,...n})=>{const t={...n,backgroundColorWhenNotSelected:An.white,backgroundColorWhenSelected:An.blues[1]};return Zn(ix,{...t,children:[Da(Re,{variant:"h2",children:a.name}),Da(Re,{variant:"subtitle1",css:za`
244
244
  color: ${An.greys[3]};
245
- `,children:cz[a.code.toLowerCase()]||""})]})},im="qaa",ox={iso639_3_code:im,languageSubtag:im,autonym:void 0,exonym:"Unknown Language",regionNames:"",scripts:[],alternativeTags:[],names:[]};function Bm(a){return Xt(a.iso639_3_code,im)}function rx(a){var n,t,o,r,l;return zm({languageCode:(n=a.language)==null?void 0:n.languageSubtag,scriptCode:(t=a.script)==null?void 0:t.code,regionCode:(r=(o=a.customDetails)==null?void 0:o.region)==null?void 0:r.code,dialectCode:(l=a.customDetails)==null?void 0:l.dialect})}function bz(a){const n=a.split(/-[xX]-/),t=n[1],r=n[0].split("-"),l=r.shift();let g;if(Xt(l,im)?g=ox:g=VD(l||""),!g)return;const d=r.find(N=>/^[a-zA-Z]{2}$|^[0-9]{3}$/.test(N)),L=lz(d||""),y=/^[a-zA-Z]{4}$/;let b,p=r.find(N=>y.test(N));!p&&g.scripts.length===1&&(b=g.scripts[0]),!b&&!p&&(p=(cg(a)||cg(`${l}-${d}`)||cg(`${l}`)||"").split(/-[xX]-/)[0].split("-").find(S=>y.test(S))),p&&!b&&(b=uz(p));const f=r.find(N=>/^[0-9][a-zA-Z0-9]{3}$|^[a-zA-Z0-9]{5,8}$/.test(N));return{language:g,script:b,customDetails:{displayName:void 0,region:L,dialect:t||f}}}const xz=a=>{var C,T;const[n,t]=hn.useState(""),[o,r]=hn.useState(),[l,g]=hn.useState(),u={displayName:void 0,region:void 0,dialect:void 0},[d,L]=hn.useState(u);function y(){L(u)}const b=!!o&&(!!l||((C=o==null?void 0:o.scripts)==null?void 0:C.length)===0)&&(!Bm||d.dialect!==""&&((T=d.region)==null?void 0:T.name)!==""),p=hn.useMemo(()=>!n||n.length<2?[]:S(n,a),[n]);function f(j,I){var V;r(void 0),g(void 0),y();const q=bz(j);q&&(M(((V=q.language)==null?void 0:V.languageSubtag)||""),r(q.language),N({...q.customDetails,displayName:I},q==null?void 0:q.script))}function N(j,I){g(I),L(j)}function S(j,I){const q=XD(j);return I?I(q,j):ax(q)}function w(j){Xt(j.iso639_3_code,o==null?void 0:o.iso639_3_code)?(r(void 0),g(void 0),y()):(r(j),g(j.scripts.length==1?j.scripts[0]:void 0),L({displayName:xt(j.autonym||j.exonym||"")}))}function P(j){Xt(j.code,l==null?void 0:l.code)?g(void 0):g(j)}function D(){r(ox),g(void 0),y()}function M(j){t(j),r(void 0),g(void 0),y()}return{languageData:p,selectedLanguage:o,selectedScript:l,customizableLanguageDetails:d,searchString:n,onSearchStringChange:M,toggleSelectLanguage:w,toggleSelectScript:P,isReadyToSubmit:b,saveLanguageDetails:N,selectUnlistedLanguage:D,resetTo:f}};var Bu={},pz=qs;Object.defineProperty(Bu,"__esModule",{value:!0});var mx=Bu.default=void 0,Tz=pz(Do()),kz=Z;mx=Bu.default=(0,Tz.default)((0,kz.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit");var Ku={},Nz=qs;Object.defineProperty(Ku,"__esModule",{value:!0});var lx=Ku.default=void 0,vz=Nz(Do()),Sz=Z;lx=Ku.default=(0,vz.default)((0,Sz.jsx)("path",{d:"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"}),"InfoOutlined");const _z=({currentTagPreview:a,forUnlistedLanguage:n,...t})=>Zn(fi,{variant:"outlined",color:"primary",css:za`
245
+ `,children:cz[a.code.toLowerCase()]||""})]})},im="qaa",ox={iso639_3_code:im,languageSubtag:im,autonym:void 0,exonym:"Unknown Language",regionNames:"",scripts:[],alternativeTags:[],names:[]};function Bm(a){return Xt(a.iso639_3_code,im)}function rx(a){var n,t,o,r,l;return zm({languageCode:(n=a.language)==null?void 0:n.languageSubtag,scriptCode:(t=a.script)==null?void 0:t.code,regionCode:(r=(o=a.customDetails)==null?void 0:o.region)==null?void 0:r.code,dialectCode:(l=a.customDetails)==null?void 0:l.dialect})}function bz(a){const n=a.split(/-[xX]-/),t=n[1],r=n[0].split("-"),l=r.shift();let g;if(Xt(l,im)?g=ox:g=VD(l||""),!g)return;const d=r.find(N=>/^[a-zA-Z]{2}$|^[0-9]{3}$/.test(N)),L=lz(d||""),y=/^[a-zA-Z]{4}$/;let b,p=r.find(N=>y.test(N));!p&&g.scripts.length===1&&(b=g.scripts[0]),!b&&!p&&(p=(cg(a)||cg(`${l}-${d}`)||cg(`${l}`)||"").split(/-[xX]-/)[0].split("-").find(S=>y.test(S))),p&&!b&&(b=uz(p));const f=r.find(N=>/^[0-9][a-zA-Z0-9]{3}$|^[a-zA-Z0-9]{5,8}$/.test(N));return{language:g,script:b,customDetails:{displayName:void 0,region:L,dialect:t||f}}}const xz=a=>{var C,T;const[n,t]=hn.useState(""),[o,r]=hn.useState(),[l,g]=hn.useState(),u={displayName:void 0,region:void 0,dialect:void 0},[d,L]=hn.useState(u);function y(){L(u)}const b=!!o&&(!!l||((C=o==null?void 0:o.scripts)==null?void 0:C.length)===0)&&(!Bm(o)||d.dialect!==""&&((T=d.region)==null?void 0:T.name)!==""),p=hn.useMemo(()=>!n||n.length<2?[]:S(n,a),[n]);function f(j,I){var V;r(void 0),g(void 0),y();const q=bz(j);q&&(M(((V=q.language)==null?void 0:V.languageSubtag)||""),r(q.language),N({...q.customDetails,displayName:I},q==null?void 0:q.script))}function N(j,I){g(I),L(j)}function S(j,I){const q=XD(j);return I?I(q,j):ax(q)}function w(j){Xt(j.iso639_3_code,o==null?void 0:o.iso639_3_code)?(r(void 0),g(void 0),y()):(r(j),g(j.scripts.length==1?j.scripts[0]:void 0),L({displayName:xt(j.autonym||j.exonym||"")}))}function P(j){Xt(j.code,l==null?void 0:l.code)?g(void 0):g(j)}function D(){r(ox),g(void 0),y()}function M(j){t(j),r(void 0),g(void 0),y()}return{languageData:p,selectedLanguage:o,selectedScript:l,customizableLanguageDetails:d,searchString:n,onSearchStringChange:M,toggleSelectLanguage:w,toggleSelectScript:P,isReadyToSubmit:b,saveLanguageDetails:N,selectUnlistedLanguage:D,resetTo:f}};var Bu={},pz=qs;Object.defineProperty(Bu,"__esModule",{value:!0});var mx=Bu.default=void 0,Tz=pz(Do()),kz=Z;mx=Bu.default=(0,Tz.default)((0,kz.jsx)("path",{d:"M3 17.25V21h3.75L17.81 9.94l-3.75-3.75zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34a.9959.9959 0 0 0-1.41 0l-1.83 1.83 3.75 3.75z"}),"Edit");var Ku={},Nz=qs;Object.defineProperty(Ku,"__esModule",{value:!0});var lx=Ku.default=void 0,vz=Nz(Do()),Sz=Z;lx=Ku.default=(0,vz.default)((0,Sz.jsx)("path",{d:"M11 7h2v2h-2zm0 4h2v6h-2zm1-9C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8"}),"InfoOutlined");const _z=({currentTagPreview:a,forUnlistedLanguage:n,...t})=>Zn(fi,{variant:"outlined",color:"primary",css:za`
246
246
  border: 1.5px solid ${An.greys[1]};
247
247
  :hover {
248
248
  border-color: ${An.black};
@@ -412,7 +412,6 @@ function print() { __p += __j.call(arguments, '') }
412
412
  padding: 10px 15px 10px 20px;
413
413
  `,children:[Da("div",{id:"right-panel-component-container",children:a.rightPanelComponent}),Zn("div",{id:"right-pane-language-chooser-section",children:[n.selectedLanguage&&Zn("div",{id:"right-pane-language-details=section",children:[Da(vo,{htmlFor:"language-name-bar",label:"Display this language this way"}),Da(wi,{type:"text",inputProps:{spellCheck:!1},css:za`
414
414
  background-color: white;
415
- margin-right: 16px;
416
415
  margin-bottom: 10px;
417
416
  font-size: 1.625rem; // 26px
418
417
  font-weight: 700;
package/index.mjs CHANGED
@@ -313087,7 +313087,7 @@ const wz = (a) => {
313087
313087
  }
313088
313088
  const b = !!o && // either a script is selected or there are no scripts for the selected language
313089
313089
  (!!l || ((C = o == null ? void 0 : o.scripts) == null ? void 0 : C.length) === 0) && // if unlisted language, name and country are required
313090
- (!Ru || d.dialect !== "" && ((T = d.region) == null ? void 0 : T.name) !== ""), p = I_(() => !n || n.length < 2 ? [] : S(n, a), [n]);
313090
+ (!Ru(o) || d.dialect !== "" && ((T = d.region) == null ? void 0 : T.name) !== ""), p = I_(() => !n || n.length < 2 ? [] : S(n, a), [n]);
313091
313091
  function f(D, I) {
313092
313092
  var X;
313093
313093
  r(void 0), g(void 0), y();
@@ -314171,7 +314171,6 @@ const lB = (a) => {
314171
314171
  },
314172
314172
  css: za`
314173
314173
  background-color: white;
314174
- margin-right: 16px;
314175
314174
  margin-bottom: 10px;
314176
314175
  font-size: 1.625rem; // 26px
314177
314176
  font-weight: 700;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "A language chooser React component using MUI",
4
4
  "author": "SIL Global",
5
5
  "license": "MIT",
6
- "version": "0.0.15",
6
+ "version": "0.0.16",
7
7
  "main": "./index.js",
8
8
  "types": "./index.d.ts",
9
9
  "exports": {
@@ -20,7 +20,7 @@
20
20
  "lodash": "^4.17.21",
21
21
  "react-lazyload": "^3.2.1",
22
22
  "@ethnolib/find-language": "0.0.9",
23
- "@ethnolib/language-chooser-react-hook": "0.0.3"
23
+ "@ethnolib/language-chooser-react-hook": "0.0.4"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@nx/storybook": "^19.8.0",