@bothub-chat/ui 2.43.2-develop-e9066765-2b2d-43ee-b92a-30e8def75005 → 2.43.2-develop-72fd8a54-50c7-41cc-a4fc-1a75f041f09d

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
@@ -1,24 +1,24 @@
1
- <p align="center">
2
- <img src="https://bothub.chat/icon-144x144.png" />
3
- </p>
4
- <h1 align="center">Bothub Chat</h1>
5
- <p align="center">UI Components from Bothub.</p>
6
- <p align="center">
7
- <a href="https://bothub-docs.vercel.app/">Documentation</a>
8
- </p>
9
-
10
- <h2>Installing</h2>
11
- <p>Preliminary requirements:</p>
12
- <ul>
13
- <li><a href="https://nodejs.org/">Node.js</a> >= <code>18.12.1</code></li>
14
- <li><a href="https://www.npmjs.com/">npm</a> >= <code>9.1.2</code></li>
15
- <li><a href="https://yarnpkg.com/">yarn</a> >= <code>1.22.19</code></li>
16
- </ul>
17
- <p>Installing peer dependencies:</p>
18
- <pre>yarn add framer-motion@10.16.3 react@18.2.0 react-dom@18.2.0 styled-components@6.0.7 react-helmet@6.1.0 normalize.css@8.0.1 react-slider@2.0.6 react-markdown@8.0.5 highlight.js@11.9.0 react-highlight@0.15.0</pre>
19
- <p>Installing package:</p>
20
- <pre>yarn add @bothub-chat/ui</pre>
21
-
22
-
23
- <h2>License</h2>
1
+ <p align="center">
2
+ <img src="https://bothub.chat/icon-144x144.png" />
3
+ </p>
4
+ <h1 align="center">Bothub Chat</h1>
5
+ <p align="center">UI Components from Bothub.</p>
6
+ <p align="center">
7
+ <a href="https://bothub-docs.vercel.app/">Documentation</a>
8
+ </p>
9
+
10
+ <h2>Installing</h2>
11
+ <p>Preliminary requirements:</p>
12
+ <ul>
13
+ <li><a href="https://nodejs.org/">Node.js</a> >= <code>18.12.1</code></li>
14
+ <li><a href="https://www.npmjs.com/">npm</a> >= <code>9.1.2</code></li>
15
+ <li><a href="https://yarnpkg.com/">yarn</a> >= <code>1.22.19</code></li>
16
+ </ul>
17
+ <p>Installing peer dependencies:</p>
18
+ <pre>yarn add framer-motion@10.16.3 react@18.2.0 react-dom@18.2.0 styled-components@6.0.7 react-helmet@6.1.0 normalize.css@8.0.1 react-slider@2.0.6 react-markdown@8.0.5 highlight.js@11.9.0 react-highlight@0.15.0</pre>
19
+ <p>Installing package:</p>
20
+ <pre>yarn add @bothub-chat/ui</pre>
21
+
22
+
23
+ <h2>License</h2>
24
24
  <p><a href="https://github.com/matbea-dev/bothub/blob/main/LICENSE">MIT</a></p>
@@ -68,3 +68,4 @@ export * from './theme-schemes';
68
68
  export * from './theme-preview';
69
69
  export * from './color-picker';
70
70
  export * from './theme-switcher';
71
+ export * from './lang-switcher';
@@ -0,0 +1,18 @@
1
+ import { SelectFieldDataItemComplex } from '../select-field';
2
+ export type LangSwitcherProps = {
3
+ region: {
4
+ value: string;
5
+ label: string;
6
+ };
7
+ lang: {
8
+ value: string;
9
+ label: string;
10
+ };
11
+ dataRegions: SelectFieldDataItemComplex[];
12
+ dataLanguages: SelectFieldDataItemComplex[];
13
+ onChange: ({ lang, region }: {
14
+ lang: string;
15
+ region: string;
16
+ }) => void;
17
+ };
18
+ export declare const LangSwitcher: React.FC<LangSwitcherProps>;
@@ -0,0 +1 @@
1
+ import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useTransition as n}from"@react-spring/web";import{useRef as o,useState as r,useMemo as a,useCallback as c,useEffect as i}from"react";import{LangSwitcherStyled as l,LangSwitcherButton as s,LangSwitcherIcon as d,LangSwitcherItem as u,LangSwitcherList as v,LangSwitcherLabel as f,LangSwitcherInput as m}from"./styled.js";const p=({lang:p,region:g,dataRegions:b,dataLanguages:h,onChange:y})=>{const w=o(null),[j,L]=r(!1),E=a((()=>b.find((e=>"object"==typeof e&&e.value===g.value))),[b,g]),k=a((()=>h.find((e=>"object"==typeof e&&e.value===p.value))),[h,p]),C=c((()=>{L(!j)}),[j]),H=c((()=>{L(!1)}),[]);i((()=>{if(!j)return;const e=e=>{const t=w.current,n=e.target;t&&t.contains(n)||H()};return window.addEventListener("scroll",e,!0),()=>{window.removeEventListener("scroll",e,!0)}}),[j]),i((()=>{const e=w.current;if(null!==e){const t=t=>{e.contains(t.target)||L(!1)},n=()=>L(!1);return document.addEventListener("click",t),window.addEventListener("blur",n),()=>{document.removeEventListener("click",t),window.removeEventListener("blur",n)}}}),[]);const x=c(((e,t)=>{"object"==typeof e&&e.value&&y({lang:"lang"===t?e.value:p.value,region:"region"===t?e.value:g.value})}),[y]),O=n(j,{from:{opacity:0,transform:"scale(0)"},enter:{opacity:j?1:.5,transform:`scale(${j?1:.999})`},leave:{opacity:0,transform:"scale(0.999)"},config:{duration:150}});return e(l,{children:[t(s,{onClick:C,disableHoverColor:!0,endIcon:t(d,{$open:j}),children:e(u,{children:["object"==typeof E&&E.icon,"/ ","object"==typeof k&&k.value]})}),O(((n,o)=>o&&e(v,{style:n,children:[t(f,{children:p.label}),t(m,{contentHeight:"fit-content",compactWidth:!0,onOptionClick:e=>x(e,"lang"),value:k,data:h}),t(f,{children:p.label}),t(m,{contentHeight:"fit-content",compactWidth:!0,onOptionClick:e=>x(e,"region"),value:E,data:b})]})))]})};export{p as LangSwitcher};